{"version":3,"sources":["src/scripts/components/timeline.js"],"names":["applyTimlineHeight","timelineHeight","numOfActiveItems","container","finalItemNumber","children","length","jQuery","attr","i","item","outerHeight","css","expandTimeline","on","e","parseInt"],"mappings":";;;;;AAAA;AACA;;;AAKA;AACA,SAASA,kBAAT,CAA4BC,cAA5B,EAA4CC,gBAA5C,EAA8DC,SAA9D,EAAyE;;AAEvE;AACA,MAAIC,kBAAkB,CAAtB;;AAEA;AACA,MAAGF,mBAAmB,CAAnB,IAAwBC,UAAUE,QAAV,GAAqBC,MAAhD,EAAwD;;AAEtD;AACAF,sBAAkBD,UAAUE,QAAV,GAAqBC,MAAvC;;AAEA;AACAC,WAAO,0BAAP,EAAmCC,IAAnC,CAAwC,OAAxC,EAAiD,UAAjD;;AAEA;AACAL,cAAUK,IAAV,CAAe,WAAf,EAA4B,EAA5B;AACD;;AAED;AAZA,OAaK;;AAEH;AACAJ,wBAAkBF,mBAAmB,CAArC;AACD;;AAED;AACA,OAAI,IAAIO,IAAIP,gBAAZ,EAA8BO,IAAIL,eAAlC,EAAmDK,GAAnD,EAAwD;;AAEtD;AACA,QAAIC,OAAOP,UAAUE,QAAV,GAAqBI,CAArB,CAAX;;AAEA;AACAR,sBAAkBM,OAAOG,IAAP,EAAaC,WAAb,CAAyB,IAAzB,CAAlB;;AAEA;AACAT;AACD;;AAED;AACAC,YAAUS,GAAV,CAAc,QAAd,EAAwBX,iBAAe,IAAvC,EAA6CO,IAA7C,CAAkD,mBAAlD,EAAuEN,gBAAvE;AACD;;AAED;AACA,SAASW,cAAT,GAA0B;;AAExB;AACA,MAAGN,OAAO,WAAP,EAAoBD,MAApB,GAA6B,CAAhC,EAAmC;;AAEjC;AACA,QAAIH,YAAYI,OAAO,kBAAP,CAAhB;;AAEA;AACA,QAAIL,mBAAmB,CAAvB;;AAEA;AACA,QAAID,iBAAiB,CAArB;;AAEA;AACA,QAAGE,UAAUE,QAAV,GAAqBC,MAArB,GAA8B,CAAjC,EAAoC;;AAElC;AACAN,yBAAmBC,cAAnB,EAAmCC,gBAAnC,EAAqDC,SAArD;AACD;;AAED;AACAI,WAAO,0BAAP,EAAmCO,EAAnC,CAAsC,OAAtC,EAA+C,UAASC,CAAT,EAAY;;AAEzD;AACA,UAAIZ,YAAYI,OAAO,kBAAP,CAAhB;;AAEA;AACA,UAAIL,mBAAmBc,SAASb,UAAUK,IAAV,CAAe,mBAAf,CAAT,CAAvB;;AAEA;AACAP,uBAAiBE,UAAUQ,WAAV,EAAjB;;AAEA;AACAX,yBAAmBC,cAAnB,EAAmCC,gBAAnC,EAAqDC,SAArD;AAED,KAdD;AAeD;AACF;;QAEQU,c,GAAAA,c","file":"timeline.js","sourcesContent":["//var $ = jQuery;\n//import {debounce} from '../utils/utilities.js';\n\n\n\n\n// Applies height onto the timeline.\nfunction applyTimlineHeight(timelineHeight, numOfActiveItems, container) {\n\n // Creating a variable to keep track of where the for loop will end.\n var finalItemNumber = 0;\n\n // If we are at the end of the timeline.\n if(numOfActiveItems + 3 >= container.children().length) {\n\n // Only show the number of remaining items.\n finalItemNumber = container.children().length;\n\n // Disable the timline expand button.\n jQuery('#timeline__expand-button').attr('state', 'disabled');\n\n // Hide the fade at the end of the timeline.\n container.attr('hide-fade', '');\n }\n\n // If we are not at the end of the timeline.\n else {\n\n // Determine how many more items we are going to show.\n finalItemNumber = numOfActiveItems + 3;\n }\n\n // Cycling through each of the newly active items.\n for(var i = numOfActiveItems; i < finalItemNumber; i++) {\n\n // Caching the item element.\n var item = container.children()[i];\n\n // Adding the item height to the overall height of the timeline.\n timelineHeight += jQuery(item).outerHeight(true);\n\n // Adding up how many items are active.\n numOfActiveItems++;\n }\n\n // Applying the new inline styles height.\n container.css('height', timelineHeight+'px').attr('data-active-items', numOfActiveItems);\n}\n\n// The initialization function for the expanding functionality.\nfunction expandTimeline() {\n\n // Checking if there is a timeline on the page before running any scripts.\n if(jQuery('.timeline').length > 0) {\n\n // Caching the items container.\n var container = jQuery('#timeline__items');\n\n // Setting how many items are currently active.\n var numOfActiveItems = 0;\n\n // Setting the current height of the timeline.\n var timelineHeight = 0;\n\n // Checking if there are more than 3 timeline items.\n if(container.children().length > 3) {\n\n // Applying the height of the timeline for the first 3 items.\n applyTimlineHeight(timelineHeight, numOfActiveItems, container);\n }\n\n // Binding the expand button to a click event.\n jQuery('#timeline__expand-button').on('click', function(e) {\n\n // Caching the items container.\n var container = jQuery('#timeline__items');\n\n // Checking how many items are currently active.\n var numOfActiveItems = parseInt(container.attr('data-active-items'));\n\n // Getting the height of the timeline.\n timelineHeight = container.outerHeight();\n\n // Applying the height of the timeine to container up to 3 more items.\n applyTimlineHeight(timelineHeight, numOfActiveItems, container);\n\n });\n }\n}\n\nexport { expandTimeline };\n"]}