123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369 |
- "use strict";
- var projectCards;
- (function ($) {
- jQuery(document).ready(function () {
- var isMobile = false, isTablet = false, isLaptop = false;
- function detectDevice() {
- if (window.innerWidth <= 425) {
- isMobile = true;
- isTablet = false;
- isLaptop = false;
- } else if (window.innerWidth <= 768) {
- isMobile = false;
- isTablet = true;
- isLaptop = false;
- } else {
- isMobile = false;
- isTablet = false;
- isLaptop = true;
- }
- }
- detectDevice();
- // =========== Typing Carousel ================
- // get data from hidden ul and set as typing data
- if (document.getElementById('typing-carousel-data') != undefined) {
- var ul = document.getElementById('typing-carousel-data').children;
- if (ul.length != 0) {
- var data = [];
- Array.from(ul).forEach(el => {
- data.push(el.textContent);
- })
- ityped.init('#ityped', {
- strings: data,
- startDelay: 200,
- loop: true
- });
- }
- }
- // ============== Fix Timelines Horizontal Lines =========
- var hLines = document.getElementsByClassName("horizontal-line");
- for (let i = 0; i < hLines.length; i++) {
- if (i % 2) {
- hLines[i].children[0].children[0].classList.add("bottom-right");
- hLines[i].children[2].children[0].classList.add("top-left");
- } else {
- hLines[i].children[0].children[0].classList.add("top-right");
- hLines[i].children[2].children[0].classList.add("bottom-left");
- }
- }
- // ============== Fix Timelines Vertical lines =========
- var vLines = document.getElementsByClassName("vertical-line");
- for (let i = 0; i < vLines.length; i++) {
- if (i % 2) {
- vLines[i].classList.add("vertical-line-left-adjustment");
- }
- }
- // ==================== Adjust height of the skills card =============
- function adjustSkillCardsHeight() {
- if (!isMobile) { // no need to adjust height for mobile devices
- // primary skills
- var skillCards = document.getElementById("primary-skills");
- if (skillCards != null) {
- var cardElems = skillCards.getElementsByClassName("card");
- var maxHeight = 0;
- for (let i = 0; i < cardElems.length; i++) {
- if (cardElems.item(i).clientHeight > maxHeight) {
- maxHeight = cardElems.item(i).clientHeight;
- }
- }
- for (let i = 0; i < cardElems.length; i++) {
- cardElems.item(i).setAttribute("style", "min-height: " + maxHeight + "px;");
- }
- }
- }
- }
- $(window).on("load", function () {
- adjustSkillCardsHeight();
- });
- // ================== Project cards =====================
- // Add click action on project category selector buttons
- var filterButtons = document.getElementById("project-filter-buttons");
- if (filterButtons != null) {
- var btns = filterButtons.children;
- for (let i = 0; i < btns.length; i++) {
- btns[i].onclick = function () {
- showGithubStars(btns[i].id);
- }
- }
- }
- var projectCardHolder = document.getElementById("project-card-holder");
- if (projectCardHolder != null && projectCardHolder.children.length != 0) {
- projectCards = $(".filtr-projects").filterizr({ layout: 'sameWidth' });
- }
- function showGithubStars() {
- // fix the github button class
- // we had set it to github-button-inactive in projects holder cards so that respective javascript
- // don't render it and replace respective span with shadow root
- let githubButtons = document.getElementsByClassName("github-button-inactive");
- while (githubButtons.length > 0) {
- if (githubButtons[0].classList != undefined) {
- githubButtons[0].classList.replace("github-button-inactive", "github-button");
- }
- }
- // now render github button. it will call the github API and fill the respective fields
- renderGithubButton();
- }
- showGithubStars();
- // ==================== Adjust height of the recent-posts card =============
- function adjustRecentPostsHeight() {
- if (!isMobile) { // no need to adjust height for mobile devices
- let recentPostCards = document.getElementById("recent-post-cards")
- if (recentPostCards != null) {
- let el = recentPostCards.children;
- let maxHeight = 0;
- for (let i = 0; i < el.length; i++) {
- if (el[i].children[1].clientHeight > maxHeight) {
- maxHeight = el[i].children[1].clientHeight;
- }
- }
- for (let i = 0; i < el.length; i++) {
- el[i].children[1].setAttribute("style", "min-height: " + maxHeight + "px;")
- }
- }
- }
- }
- adjustRecentPostsHeight();
- // =============== Achievements ===========
- function fourColumRow(gallery, entries, i) {
- let entry1 = document.createElement("div");
- entry1.classList.add("col-lg-6", "m-0", "p-0");
- entry1.appendChild(entries[i].cloneNode(true));
- entry1.children[0].classList.add("img-type-1");
- gallery.appendChild(entry1);
- i++;
- let entry2 = document.createElement("div");
- entry2.classList.add("col-lg-3", "m-0", "p-0");
- entry2.appendChild(entries[i].cloneNode(true));
- entry2.children[0].classList.add("img-type-1");
- gallery.appendChild(entry2);
- i++;
- let entry3 = document.createElement("div");
- entry3.classList.add("col-lg-3", "m-0", "p-0");
- entry3.appendChild(entries[i].cloneNode(true));
- entry3.children[0].classList.add("img-type-2");
- i++;
- entry3.appendChild(entries[i].cloneNode(true));
- entry3.children[1].classList.add("img-type-2");
- gallery.appendChild(entry3);
- i++;
- }
- function fourColumnReversedRow(gallery, entries, i) {
- let entry1 = document.createElement("div");
- entry1.classList.add("col-lg-3", "m-0", "p-0");
- entry1.appendChild(entries[i].cloneNode(true));
- entry1.children[0].classList.add("img-type-2");
- i++;
- entry1.appendChild(entries[i].cloneNode(true));
- entry1.children[1].classList.add("img-type-2");
- gallery.appendChild(entry1);
- i++;
- let entry2 = document.createElement("div");
- entry2.classList.add("col-lg-3", "m-0", "p-0");
- entry2.appendChild(entries[i].cloneNode(true));
- entry2.children[0].classList.add("img-type-1");
- gallery.appendChild(entry2);
- i++;
- let entry3 = document.createElement("div");
- entry3.classList.add("col-lg-6", "m-0", "p-0");
- entry3.appendChild(entries[i].cloneNode(true));
- entry3.children[0].classList.add("img-type-1");
- gallery.appendChild(entry3);
- i++;
- }
- function threeColumnRow(gallery, entries, i) {
- console.log(i);
- let entry1 = document.createElement("div");
- entry1.classList.add("col-lg-6", "col-md-6", "m-0", "p-0");
- entry1.appendChild(entries[i].cloneNode(true));
- entry1.children[0].classList.add("img-type-1");
- gallery.appendChild(entry1);
- i++;
- let entry2 = document.createElement("div");
- entry2.classList.add("col-lg-3", "col-md-3", "m-0", "p-0");
- entry2.appendChild(entries[i].cloneNode(true));
- entry2.children[0].classList.add("img-type-1");
- gallery.appendChild(entry2);
- i++;
- let entry3 = document.createElement("div");
- entry3.classList.add("col-lg-3", "col-md-3", "m-0", "p-0");
- entry3.appendChild(entries[i].cloneNode(true));
- entry3.children[0].classList.add("img-type-1");
- gallery.appendChild(entry3);
- i++;
- }
- function threeColumnReversedRow(gallery, entries, i) {
- let entry1 = document.createElement("div");
- entry1.classList.add("col-lg-3", "col-md-3", "m-0", "p-0");
- entry1.appendChild(entries[i].cloneNode(true));
- entry1.children[0].classList.add("img-type-1");
- gallery.appendChild(entry1);
- i++;
- let entry2 = document.createElement("div");
- entry2.classList.add("col-lg-3", "col-md-3", "m-0", "p-0");
- entry2.appendChild(entries[i].cloneNode(true));
- entry2.children[0].classList.add("img-type-1");
- gallery.appendChild(entry2);
- i++;
- let entry3 = document.createElement("div");
- entry3.classList.add("col-lg-6", "col-md-3", "m-0", "p-0");
- entry3.appendChild(entries[i].cloneNode(true));
- entry3.children[0].classList.add("img-type-1");
- gallery.appendChild(entry3);
- i++;
- }
- function twoColumnRow(gallery, entries, i) {
- let entry1 = document.createElement("div");
- entry1.classList.add("col-6", "m-0", "p-0");
- entry1.appendChild(entries[i].cloneNode(true));
- entry1.children[0].classList.add("img-type-1");
- gallery.appendChild(entry1);
- i++;
- let entry2 = document.createElement("div");
- entry2.classList.add("col-6", "m-0", "p-0");
- entry2.appendChild(entries[i].cloneNode(true));
- entry2.children[0].classList.add("img-type-1");
- gallery.appendChild(entry2);
- i++;
- }
- function singleColumnRow(gallery, entries, i) {
- let entry1 = document.createElement("div");
- entry1.classList.add("col-12", "m-0", "p-0");
- entry1.appendChild(entries[i].cloneNode(true));
- entry1.children[0].classList.add("img-type-1");
- gallery.appendChild(entry1);
- i++;
- }
- function showAchievements() {
- // show achievements from achievements-holder div
- let gallery = document.getElementById("gallery");
- if (gallery == null) {
- return
- }
- gallery.innerHTML = "";
- const entries = document.getElementById("achievements-holder").children;
- let len = entries.length;
- let i = 0;
- let rowNumber = 1;
- while (i < len) {
- if (isLaptop) {
- if (i + 4 <= len) {
- if (rowNumber % 2) {
- fourColumRow(gallery, entries, i);
- } else {
- fourColumnReversedRow(gallery, entries, i);
- }
- i += 4;
- } else if (i + 3 <= len) {
- if (rowNumber % 2) {
- threeColumnRow(gallery, entries, i);
- } else {
- threeColumnReversedRow(gallery, entries, i);
- }
- i += 3;
- } else if (i + 2 <= len) {
- twoColumnRow(gallery, entries, i);
- i += 2;
- } else {
- singleColumnRow(gallery, entries, i);
- i++;
- }
- } else if (isTablet) {
- if (i + 2 <= len) {
- twoColumnRow(gallery, entries, i);
- i += 2;
- } else {
- singleColumnRow(gallery, entries, i);
- i++;
- }
- } else {
- singleColumnRow(gallery, entries, i);
- i++;
- }
- rowNumber++;
- }
- // show full image on click
- let elements = document.getElementsByClassName("achievement-entry");
- len = elements.length;
- for (let i = 0; i < len; i++) {
- elements[i].onclick = function () {
- let achievements = document.getElementsByClassName("achievement-entry");
- let len2 = achievements.length;
- for (let j = 0; j < len2; j++) {
- achievements[j].classList.toggle("hidden");
- }
- this.classList.toggle("achievement-details");
- this.classList.toggle("hidden");
- this.parentElement.classList.toggle("col-lg-12");
- this.parentElement.classList.toggle("col-md-12");
- this.parentElement.classList.toggle("col-sm-12");
- if (this.children["SmallImage"].hasAttribute("active")) {
- let mainLogo = this.children["LargeImage"].getAttribute("Style");
- this.children["LargeImage"].setAttribute("active",true);
- this.children["SmallImage"].removeAttribute("active");
- this.setAttribute("Style", mainLogo);
- } else {
- let mainLogo = this.children["SmallImage"].getAttribute("Style");
- this.children["SmallImage"].setAttribute("active",true);
- this.children["LargeImage"].removeAttribute("active");
- this.setAttribute("Style", mainLogo);
- }
-
- if (this.children["caption"] != undefined) {
- this.children["caption"].classList.toggle("hidden");
- }
- if (this.children["enlarge-icon"] != undefined) {
- this.children["enlarge-icon"].classList.toggle("fa-search-plus");
- this.children["enlarge-icon"].classList.toggle("fa-times");
- }
- if (this.children["achievement-title"] != undefined) {
- this.children["achievement-title"].classList.toggle("hidden");
- }
- }
- }
- }
- showAchievements();
- // re-render custom functions on window resize
- window.onresize = function () {
- detectDevice();
- adjustSkillCardsHeight();
- adjustRecentPostsHeight();
- showAchievements();
- };
- });
- })(jQuery);
|