isotope.pkgd.js 93 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559
  1. /*!
  2. Isotope
  3. Version: v3.0.6
  4. Plugin URL: https://isotope.metafizzy.co
  5. License: Copyright 2010-2018 Metafizzy | Licensed GPLv3 for open source use or Isotope Commercial License for commercial use
  6. !*/
  7. /**
  8. * Bridget makes jQuery widgets
  9. * v2.0.1
  10. * MIT license
  11. */
  12. /* jshint browser: true, strict: true, undef: true, unused: true */
  13. ( function( window, factory ) {
  14. // universal module definition
  15. /*jshint strict: false */ /* globals define, module, require */
  16. if ( typeof define == 'function' && define.amd ) {
  17. // AMD
  18. define( 'jquery-bridget/jquery-bridget',[ 'jquery' ], function( jQuery ) {
  19. return factory( window, jQuery );
  20. });
  21. } else if ( typeof module == 'object' && module.exports ) {
  22. // CommonJS
  23. module.exports = factory(
  24. window,
  25. require('jquery')
  26. );
  27. } else {
  28. // browser global
  29. window.jQueryBridget = factory(
  30. window,
  31. window.jQuery
  32. );
  33. }
  34. }( window, function factory( window, jQuery ) {
  35. 'use strict';
  36. // ----- utils ----- //
  37. var arraySlice = Array.prototype.slice;
  38. // helper function for logging errors
  39. // $.error breaks jQuery chaining
  40. var console = window.console;
  41. var logError = typeof console == 'undefined' ? function() {} :
  42. function( message ) {
  43. console.error( message );
  44. };
  45. // ----- jQueryBridget ----- //
  46. function jQueryBridget( namespace, PluginClass, $ ) {
  47. $ = $ || jQuery || window.jQuery;
  48. if ( !$ ) {
  49. return;
  50. }
  51. // add option method -> $().plugin('option', {...})
  52. if ( !PluginClass.prototype.option ) {
  53. // option setter
  54. PluginClass.prototype.option = function( opts ) {
  55. // bail out if not an object
  56. if ( !$.isPlainObject( opts ) ){
  57. return;
  58. }
  59. this.options = $.extend( true, this.options, opts );
  60. };
  61. }
  62. // make jQuery plugin
  63. $.fn[ namespace ] = function( arg0 /*, arg1 */ ) {
  64. if ( typeof arg0 == 'string' ) {
  65. // method call $().plugin( 'methodName', { options } )
  66. // shift arguments by 1
  67. var args = arraySlice.call( arguments, 1 );
  68. return methodCall( this, arg0, args );
  69. }
  70. // just $().plugin({ options })
  71. plainCall( this, arg0 );
  72. return this;
  73. };
  74. // $().plugin('methodName')
  75. function methodCall( $elems, methodName, args ) {
  76. var returnValue;
  77. var pluginMethodStr = '$().' + namespace + '("' + methodName + '")';
  78. $elems.each( function( i, elem ) {
  79. // get instance
  80. var instance = $.data( elem, namespace );
  81. if ( !instance ) {
  82. logError( namespace + ' not initialized. Cannot call methods, i.e. ' +
  83. pluginMethodStr );
  84. return;
  85. }
  86. var method = instance[ methodName ];
  87. if ( !method || methodName.charAt(0) == '_' ) {
  88. logError( pluginMethodStr + ' is not a valid method' );
  89. return;
  90. }
  91. // apply method, get return value
  92. var value = method.apply( instance, args );
  93. // set return value if value is returned, use only first value
  94. returnValue = returnValue === undefined ? value : returnValue;
  95. });
  96. return returnValue !== undefined ? returnValue : $elems;
  97. }
  98. function plainCall( $elems, options ) {
  99. $elems.each( function( i, elem ) {
  100. var instance = $.data( elem, namespace );
  101. if ( instance ) {
  102. // set options & init
  103. instance.option( options );
  104. instance._init();
  105. } else {
  106. // initialize new instance
  107. instance = new PluginClass( elem, options );
  108. $.data( elem, namespace, instance );
  109. }
  110. });
  111. }
  112. updateJQuery( $ );
  113. }
  114. // ----- updateJQuery ----- //
  115. // set $.bridget for v1 backwards compatibility
  116. function updateJQuery( $ ) {
  117. if ( !$ || ( $ && $.bridget ) ) {
  118. return;
  119. }
  120. $.bridget = jQueryBridget;
  121. }
  122. updateJQuery( jQuery || window.jQuery );
  123. // ----- ----- //
  124. return jQueryBridget;
  125. }));
  126. /**
  127. * EvEmitter v1.1.0
  128. * Lil' event emitter
  129. * MIT License
  130. */
  131. /* jshint unused: true, undef: true, strict: true */
  132. ( function( global, factory ) {
  133. // universal module definition
  134. /* jshint strict: false */ /* globals define, module, window */
  135. if ( typeof define == 'function' && define.amd ) {
  136. // AMD - RequireJS
  137. define( 'ev-emitter/ev-emitter',factory );
  138. } else if ( typeof module == 'object' && module.exports ) {
  139. // CommonJS - Browserify, Webpack
  140. module.exports = factory();
  141. } else {
  142. // Browser globals
  143. global.EvEmitter = factory();
  144. }
  145. }( typeof window != 'undefined' ? window : this, function() {
  146. function EvEmitter() {}
  147. var proto = EvEmitter.prototype;
  148. proto.on = function( eventName, listener ) {
  149. if ( !eventName || !listener ) {
  150. return;
  151. }
  152. // set events hash
  153. var events = this._events = this._events || {};
  154. // set listeners array
  155. var listeners = events[ eventName ] = events[ eventName ] || [];
  156. // only add once
  157. if ( listeners.indexOf( listener ) == -1 ) {
  158. listeners.push( listener );
  159. }
  160. return this;
  161. };
  162. proto.once = function( eventName, listener ) {
  163. if ( !eventName || !listener ) {
  164. return;
  165. }
  166. // add event
  167. this.on( eventName, listener );
  168. // set once flag
  169. // set onceEvents hash
  170. var onceEvents = this._onceEvents = this._onceEvents || {};
  171. // set onceListeners object
  172. var onceListeners = onceEvents[ eventName ] = onceEvents[ eventName ] || {};
  173. // set flag
  174. onceListeners[ listener ] = true;
  175. return this;
  176. };
  177. proto.off = function( eventName, listener ) {
  178. var listeners = this._events && this._events[ eventName ];
  179. if ( !listeners || !listeners.length ) {
  180. return;
  181. }
  182. var index = listeners.indexOf( listener );
  183. if ( index != -1 ) {
  184. listeners.splice( index, 1 );
  185. }
  186. return this;
  187. };
  188. proto.emitEvent = function( eventName, args ) {
  189. var listeners = this._events && this._events[ eventName ];
  190. if ( !listeners || !listeners.length ) {
  191. return;
  192. }
  193. // copy over to avoid interference if .off() in listener
  194. listeners = listeners.slice(0);
  195. args = args || [];
  196. // once stuff
  197. var onceListeners = this._onceEvents && this._onceEvents[ eventName ];
  198. for ( var i=0; i < listeners.length; i++ ) {
  199. var listener = listeners[i]
  200. var isOnce = onceListeners && onceListeners[ listener ];
  201. if ( isOnce ) {
  202. // remove listener
  203. // remove before trigger to prevent recursion
  204. this.off( eventName, listener );
  205. // unset once flag
  206. delete onceListeners[ listener ];
  207. }
  208. // trigger listener
  209. listener.apply( this, args );
  210. }
  211. return this;
  212. };
  213. proto.allOff = function() {
  214. delete this._events;
  215. delete this._onceEvents;
  216. };
  217. return EvEmitter;
  218. }));
  219. /*!
  220. * getSize v2.0.3
  221. * measure size of elements
  222. * MIT license
  223. */
  224. /* jshint browser: true, strict: true, undef: true, unused: true */
  225. /* globals console: false */
  226. ( function( window, factory ) {
  227. /* jshint strict: false */ /* globals define, module */
  228. if ( typeof define == 'function' && define.amd ) {
  229. // AMD
  230. define( 'get-size/get-size',factory );
  231. } else if ( typeof module == 'object' && module.exports ) {
  232. // CommonJS
  233. module.exports = factory();
  234. } else {
  235. // browser global
  236. window.getSize = factory();
  237. }
  238. })( window, function factory() {
  239. 'use strict';
  240. // -------------------------- helpers -------------------------- //
  241. // get a number from a string, not a percentage
  242. function getStyleSize( value ) {
  243. var num = parseFloat( value );
  244. // not a percent like '100%', and a number
  245. var isValid = value.indexOf('%') == -1 && !isNaN( num );
  246. return isValid && num;
  247. }
  248. function noop() {}
  249. var logError = typeof console == 'undefined' ? noop :
  250. function( message ) {
  251. console.error( message );
  252. };
  253. // -------------------------- measurements -------------------------- //
  254. var measurements = [
  255. 'paddingLeft',
  256. 'paddingRight',
  257. 'paddingTop',
  258. 'paddingBottom',
  259. 'marginLeft',
  260. 'marginRight',
  261. 'marginTop',
  262. 'marginBottom',
  263. 'borderLeftWidth',
  264. 'borderRightWidth',
  265. 'borderTopWidth',
  266. 'borderBottomWidth'
  267. ];
  268. var measurementsLength = measurements.length;
  269. function getZeroSize() {
  270. var size = {
  271. width: 0,
  272. height: 0,
  273. innerWidth: 0,
  274. innerHeight: 0,
  275. outerWidth: 0,
  276. outerHeight: 0
  277. };
  278. for ( var i=0; i < measurementsLength; i++ ) {
  279. var measurement = measurements[i];
  280. size[ measurement ] = 0;
  281. }
  282. return size;
  283. }
  284. // -------------------------- getStyle -------------------------- //
  285. /**
  286. * getStyle, get style of element, check for Firefox bug
  287. * https://bugzilla.mozilla.org/show_bug.cgi?id=548397
  288. */
  289. function getStyle( elem ) {
  290. var style = getComputedStyle( elem );
  291. if ( !style ) {
  292. logError( 'Style returned ' + style +
  293. '. Are you running this code in a hidden iframe on Firefox? ' +
  294. 'See https://bit.ly/getsizebug1' );
  295. }
  296. return style;
  297. }
  298. // -------------------------- setup -------------------------- //
  299. var isSetup = false;
  300. var isBoxSizeOuter;
  301. /**
  302. * setup
  303. * check isBoxSizerOuter
  304. * do on first getSize() rather than on page load for Firefox bug
  305. */
  306. function setup() {
  307. // setup once
  308. if ( isSetup ) {
  309. return;
  310. }
  311. isSetup = true;
  312. // -------------------------- box sizing -------------------------- //
  313. /**
  314. * Chrome & Safari measure the outer-width on style.width on border-box elems
  315. * IE11 & Firefox<29 measures the inner-width
  316. */
  317. var div = document.createElement('div');
  318. div.style.width = '200px';
  319. div.style.padding = '1px 2px 3px 4px';
  320. div.style.borderStyle = 'solid';
  321. div.style.borderWidth = '1px 2px 3px 4px';
  322. div.style.boxSizing = 'border-box';
  323. var body = document.body || document.documentElement;
  324. body.appendChild( div );
  325. var style = getStyle( div );
  326. // round value for browser zoom. desandro/masonry#928
  327. isBoxSizeOuter = Math.round( getStyleSize( style.width ) ) == 200;
  328. getSize.isBoxSizeOuter = isBoxSizeOuter;
  329. body.removeChild( div );
  330. }
  331. // -------------------------- getSize -------------------------- //
  332. function getSize( elem ) {
  333. setup();
  334. // use querySeletor if elem is string
  335. if ( typeof elem == 'string' ) {
  336. elem = document.querySelector( elem );
  337. }
  338. // do not proceed on non-objects
  339. if ( !elem || typeof elem != 'object' || !elem.nodeType ) {
  340. return;
  341. }
  342. var style = getStyle( elem );
  343. // if hidden, everything is 0
  344. if ( style.display == 'none' ) {
  345. return getZeroSize();
  346. }
  347. var size = {};
  348. size.width = elem.offsetWidth;
  349. size.height = elem.offsetHeight;
  350. var isBorderBox = size.isBorderBox = style.boxSizing == 'border-box';
  351. // get all measurements
  352. for ( var i=0; i < measurementsLength; i++ ) {
  353. var measurement = measurements[i];
  354. var value = style[ measurement ];
  355. var num = parseFloat( value );
  356. // any 'auto', 'medium' value will be 0
  357. size[ measurement ] = !isNaN( num ) ? num : 0;
  358. }
  359. var paddingWidth = size.paddingLeft + size.paddingRight;
  360. var paddingHeight = size.paddingTop + size.paddingBottom;
  361. var marginWidth = size.marginLeft + size.marginRight;
  362. var marginHeight = size.marginTop + size.marginBottom;
  363. var borderWidth = size.borderLeftWidth + size.borderRightWidth;
  364. var borderHeight = size.borderTopWidth + size.borderBottomWidth;
  365. var isBorderBoxSizeOuter = isBorderBox && isBoxSizeOuter;
  366. // overwrite width and height if we can get it from style
  367. var styleWidth = getStyleSize( style.width );
  368. if ( styleWidth !== false ) {
  369. size.width = styleWidth +
  370. // add padding and border unless it's already including it
  371. ( isBorderBoxSizeOuter ? 0 : paddingWidth + borderWidth );
  372. }
  373. var styleHeight = getStyleSize( style.height );
  374. if ( styleHeight !== false ) {
  375. size.height = styleHeight +
  376. // add padding and border unless it's already including it
  377. ( isBorderBoxSizeOuter ? 0 : paddingHeight + borderHeight );
  378. }
  379. size.innerWidth = size.width - ( paddingWidth + borderWidth );
  380. size.innerHeight = size.height - ( paddingHeight + borderHeight );
  381. size.outerWidth = size.width + marginWidth;
  382. size.outerHeight = size.height + marginHeight;
  383. return size;
  384. }
  385. return getSize;
  386. });
  387. /**
  388. * matchesSelector v2.0.2
  389. * matchesSelector( element, '.selector' )
  390. * MIT license
  391. */
  392. /*jshint browser: true, strict: true, undef: true, unused: true */
  393. ( function( window, factory ) {
  394. /*global define: false, module: false */
  395. 'use strict';
  396. // universal module definition
  397. if ( typeof define == 'function' && define.amd ) {
  398. // AMD
  399. define( 'desandro-matches-selector/matches-selector',factory );
  400. } else if ( typeof module == 'object' && module.exports ) {
  401. // CommonJS
  402. module.exports = factory();
  403. } else {
  404. // browser global
  405. window.matchesSelector = factory();
  406. }
  407. }( window, function factory() {
  408. 'use strict';
  409. var matchesMethod = ( function() {
  410. var ElemProto = window.Element.prototype;
  411. // check for the standard method name first
  412. if ( ElemProto.matches ) {
  413. return 'matches';
  414. }
  415. // check un-prefixed
  416. if ( ElemProto.matchesSelector ) {
  417. return 'matchesSelector';
  418. }
  419. // check vendor prefixes
  420. var prefixes = [ 'webkit', 'moz', 'ms', 'o' ];
  421. for ( var i=0; i < prefixes.length; i++ ) {
  422. var prefix = prefixes[i];
  423. var method = prefix + 'MatchesSelector';
  424. if ( ElemProto[ method ] ) {
  425. return method;
  426. }
  427. }
  428. })();
  429. return function matchesSelector( elem, selector ) {
  430. return elem[ matchesMethod ]( selector );
  431. };
  432. }));
  433. /**
  434. * Fizzy UI utils v2.0.7
  435. * MIT license
  436. */
  437. /*jshint browser: true, undef: true, unused: true, strict: true */
  438. ( function( window, factory ) {
  439. // universal module definition
  440. /*jshint strict: false */ /*globals define, module, require */
  441. if ( typeof define == 'function' && define.amd ) {
  442. // AMD
  443. define( 'fizzy-ui-utils/utils',[
  444. 'desandro-matches-selector/matches-selector'
  445. ], function( matchesSelector ) {
  446. return factory( window, matchesSelector );
  447. });
  448. } else if ( typeof module == 'object' && module.exports ) {
  449. // CommonJS
  450. module.exports = factory(
  451. window,
  452. require('desandro-matches-selector')
  453. );
  454. } else {
  455. // browser global
  456. window.fizzyUIUtils = factory(
  457. window,
  458. window.matchesSelector
  459. );
  460. }
  461. }( window, function factory( window, matchesSelector ) {
  462. var utils = {};
  463. // ----- extend ----- //
  464. // extends objects
  465. utils.extend = function( a, b ) {
  466. for ( var prop in b ) {
  467. a[ prop ] = b[ prop ];
  468. }
  469. return a;
  470. };
  471. // ----- modulo ----- //
  472. utils.modulo = function( num, div ) {
  473. return ( ( num % div ) + div ) % div;
  474. };
  475. // ----- makeArray ----- //
  476. var arraySlice = Array.prototype.slice;
  477. // turn element or nodeList into an array
  478. utils.makeArray = function( obj ) {
  479. if ( Array.isArray( obj ) ) {
  480. // use object if already an array
  481. return obj;
  482. }
  483. // return empty array if undefined or null. #6
  484. if ( obj === null || obj === undefined ) {
  485. return [];
  486. }
  487. var isArrayLike = typeof obj == 'object' && typeof obj.length == 'number';
  488. if ( isArrayLike ) {
  489. // convert nodeList to array
  490. return arraySlice.call( obj );
  491. }
  492. // array of single index
  493. return [ obj ];
  494. };
  495. // ----- removeFrom ----- //
  496. utils.removeFrom = function( ary, obj ) {
  497. var index = ary.indexOf( obj );
  498. if ( index != -1 ) {
  499. ary.splice( index, 1 );
  500. }
  501. };
  502. // ----- getParent ----- //
  503. utils.getParent = function( elem, selector ) {
  504. while ( elem.parentNode && elem != document.body ) {
  505. elem = elem.parentNode;
  506. if ( matchesSelector( elem, selector ) ) {
  507. return elem;
  508. }
  509. }
  510. };
  511. // ----- getQueryElement ----- //
  512. // use element as selector string
  513. utils.getQueryElement = function( elem ) {
  514. if ( typeof elem == 'string' ) {
  515. return document.querySelector( elem );
  516. }
  517. return elem;
  518. };
  519. // ----- handleEvent ----- //
  520. // enable .ontype to trigger from .addEventListener( elem, 'type' )
  521. utils.handleEvent = function( event ) {
  522. var method = 'on' + event.type;
  523. if ( this[ method ] ) {
  524. this[ method ]( event );
  525. }
  526. };
  527. // ----- filterFindElements ----- //
  528. utils.filterFindElements = function( elems, selector ) {
  529. // make array of elems
  530. elems = utils.makeArray( elems );
  531. var ffElems = [];
  532. elems.forEach( function( elem ) {
  533. // check that elem is an actual element
  534. if ( !( elem instanceof HTMLElement ) ) {
  535. return;
  536. }
  537. // add elem if no selector
  538. if ( !selector ) {
  539. ffElems.push( elem );
  540. return;
  541. }
  542. // filter & find items if we have a selector
  543. // filter
  544. if ( matchesSelector( elem, selector ) ) {
  545. ffElems.push( elem );
  546. }
  547. // find children
  548. var childElems = elem.querySelectorAll( selector );
  549. // concat childElems to filterFound array
  550. for ( var i=0; i < childElems.length; i++ ) {
  551. ffElems.push( childElems[i] );
  552. }
  553. });
  554. return ffElems;
  555. };
  556. // ----- debounceMethod ----- //
  557. utils.debounceMethod = function( _class, methodName, threshold ) {
  558. threshold = threshold || 100;
  559. // original method
  560. var method = _class.prototype[ methodName ];
  561. var timeoutName = methodName + 'Timeout';
  562. _class.prototype[ methodName ] = function() {
  563. var timeout = this[ timeoutName ];
  564. clearTimeout( timeout );
  565. var args = arguments;
  566. var _this = this;
  567. this[ timeoutName ] = setTimeout( function() {
  568. method.apply( _this, args );
  569. delete _this[ timeoutName ];
  570. }, threshold );
  571. };
  572. };
  573. // ----- docReady ----- //
  574. utils.docReady = function( callback ) {
  575. var readyState = document.readyState;
  576. if ( readyState == 'complete' || readyState == 'interactive' ) {
  577. // do async to allow for other scripts to run. metafizzy/flickity#441
  578. setTimeout( callback );
  579. } else {
  580. document.addEventListener( 'DOMContentLoaded', callback );
  581. }
  582. };
  583. // ----- htmlInit ----- //
  584. // http://jamesroberts.name/blog/2010/02/22/string-functions-for-javascript-trim-to-camel-case-to-dashed-and-to-underscore/
  585. utils.toDashed = function( str ) {
  586. return str.replace( /(.)([A-Z])/g, function( match, $1, $2 ) {
  587. return $1 + '-' + $2;
  588. }).toLowerCase();
  589. };
  590. var console = window.console;
  591. /**
  592. * allow user to initialize classes via [data-namespace] or .js-namespace class
  593. * htmlInit( Widget, 'widgetName' )
  594. * options are parsed from data-namespace-options
  595. */
  596. utils.htmlInit = function( WidgetClass, namespace ) {
  597. utils.docReady( function() {
  598. var dashedNamespace = utils.toDashed( namespace );
  599. var dataAttr = 'data-' + dashedNamespace;
  600. var dataAttrElems = document.querySelectorAll( '[' + dataAttr + ']' );
  601. var jsDashElems = document.querySelectorAll( '.js-' + dashedNamespace );
  602. var elems = utils.makeArray( dataAttrElems )
  603. .concat( utils.makeArray( jsDashElems ) );
  604. var dataOptionsAttr = dataAttr + '-options';
  605. var jQuery = window.jQuery;
  606. elems.forEach( function( elem ) {
  607. var attr = elem.getAttribute( dataAttr ) ||
  608. elem.getAttribute( dataOptionsAttr );
  609. var options;
  610. try {
  611. options = attr && JSON.parse( attr );
  612. } catch ( error ) {
  613. // log error, do not initialize
  614. if ( console ) {
  615. console.error( 'Error parsing ' + dataAttr + ' on ' + elem.className +
  616. ': ' + error );
  617. }
  618. return;
  619. }
  620. // initialize
  621. var instance = new WidgetClass( elem, options );
  622. // make available via $().data('namespace')
  623. if ( jQuery ) {
  624. jQuery.data( elem, namespace, instance );
  625. }
  626. });
  627. });
  628. };
  629. // ----- ----- //
  630. return utils;
  631. }));
  632. /**
  633. * Outlayer Item
  634. */
  635. ( function( window, factory ) {
  636. // universal module definition
  637. /* jshint strict: false */ /* globals define, module, require */
  638. if ( typeof define == 'function' && define.amd ) {
  639. // AMD - RequireJS
  640. define( 'outlayer/item',[
  641. 'ev-emitter/ev-emitter',
  642. 'get-size/get-size'
  643. ],
  644. factory
  645. );
  646. } else if ( typeof module == 'object' && module.exports ) {
  647. // CommonJS - Browserify, Webpack
  648. module.exports = factory(
  649. require('ev-emitter'),
  650. require('get-size')
  651. );
  652. } else {
  653. // browser global
  654. window.Outlayer = {};
  655. window.Outlayer.Item = factory(
  656. window.EvEmitter,
  657. window.getSize
  658. );
  659. }
  660. }( window, function factory( EvEmitter, getSize ) {
  661. 'use strict';
  662. // ----- helpers ----- //
  663. function isEmptyObj( obj ) {
  664. for ( var prop in obj ) {
  665. return false;
  666. }
  667. prop = null;
  668. return true;
  669. }
  670. // -------------------------- CSS3 support -------------------------- //
  671. var docElemStyle = document.documentElement.style;
  672. var transitionProperty = typeof docElemStyle.transition == 'string' ?
  673. 'transition' : 'WebkitTransition';
  674. var transformProperty = typeof docElemStyle.transform == 'string' ?
  675. 'transform' : 'WebkitTransform';
  676. var transitionEndEvent = {
  677. WebkitTransition: 'webkitTransitionEnd',
  678. transition: 'transitionend'
  679. }[ transitionProperty ];
  680. // cache all vendor properties that could have vendor prefix
  681. var vendorProperties = {
  682. transform: transformProperty,
  683. transition: transitionProperty,
  684. transitionDuration: transitionProperty + 'Duration',
  685. transitionProperty: transitionProperty + 'Property',
  686. transitionDelay: transitionProperty + 'Delay'
  687. };
  688. // -------------------------- Item -------------------------- //
  689. function Item( element, layout ) {
  690. if ( !element ) {
  691. return;
  692. }
  693. this.element = element;
  694. // parent layout class, i.e. Masonry, Isotope, or Packery
  695. this.layout = layout;
  696. this.position = {
  697. x: 0,
  698. y: 0
  699. };
  700. this._create();
  701. }
  702. // inherit EvEmitter
  703. var proto = Item.prototype = Object.create( EvEmitter.prototype );
  704. proto.constructor = Item;
  705. proto._create = function() {
  706. // transition objects
  707. this._transn = {
  708. ingProperties: {},
  709. clean: {},
  710. onEnd: {}
  711. };
  712. this.css({
  713. position: 'absolute'
  714. });
  715. };
  716. // trigger specified handler for event type
  717. proto.handleEvent = function( event ) {
  718. var method = 'on' + event.type;
  719. if ( this[ method ] ) {
  720. this[ method ]( event );
  721. }
  722. };
  723. proto.getSize = function() {
  724. this.size = getSize( this.element );
  725. };
  726. /**
  727. * apply CSS styles to element
  728. * @param {Object} style
  729. */
  730. proto.css = function( style ) {
  731. var elemStyle = this.element.style;
  732. for ( var prop in style ) {
  733. // use vendor property if available
  734. var supportedProp = vendorProperties[ prop ] || prop;
  735. elemStyle[ supportedProp ] = style[ prop ];
  736. }
  737. };
  738. // measure position, and sets it
  739. proto.getPosition = function() {
  740. var style = getComputedStyle( this.element );
  741. var isOriginLeft = this.layout._getOption('originLeft');
  742. var isOriginTop = this.layout._getOption('originTop');
  743. var xValue = style[ isOriginLeft ? 'left' : 'right' ];
  744. var yValue = style[ isOriginTop ? 'top' : 'bottom' ];
  745. var x = parseFloat( xValue );
  746. var y = parseFloat( yValue );
  747. // convert percent to pixels
  748. var layoutSize = this.layout.size;
  749. if ( xValue.indexOf('%') != -1 ) {
  750. x = ( x / 100 ) * layoutSize.width;
  751. }
  752. if ( yValue.indexOf('%') != -1 ) {
  753. y = ( y / 100 ) * layoutSize.height;
  754. }
  755. // clean up 'auto' or other non-integer values
  756. x = isNaN( x ) ? 0 : x;
  757. y = isNaN( y ) ? 0 : y;
  758. // remove padding from measurement
  759. x -= isOriginLeft ? layoutSize.paddingLeft : layoutSize.paddingRight;
  760. y -= isOriginTop ? layoutSize.paddingTop : layoutSize.paddingBottom;
  761. this.position.x = x;
  762. this.position.y = y;
  763. };
  764. // set settled position, apply padding
  765. proto.layoutPosition = function() {
  766. var layoutSize = this.layout.size;
  767. var style = {};
  768. var isOriginLeft = this.layout._getOption('originLeft');
  769. var isOriginTop = this.layout._getOption('originTop');
  770. // x
  771. var xPadding = isOriginLeft ? 'paddingLeft' : 'paddingRight';
  772. var xProperty = isOriginLeft ? 'left' : 'right';
  773. var xResetProperty = isOriginLeft ? 'right' : 'left';
  774. var x = this.position.x + layoutSize[ xPadding ];
  775. // set in percentage or pixels
  776. style[ xProperty ] = this.getXValue( x );
  777. // reset other property
  778. style[ xResetProperty ] = '';
  779. // y
  780. var yPadding = isOriginTop ? 'paddingTop' : 'paddingBottom';
  781. var yProperty = isOriginTop ? 'top' : 'bottom';
  782. var yResetProperty = isOriginTop ? 'bottom' : 'top';
  783. var y = this.position.y + layoutSize[ yPadding ];
  784. // set in percentage or pixels
  785. style[ yProperty ] = this.getYValue( y );
  786. // reset other property
  787. style[ yResetProperty ] = '';
  788. this.css( style );
  789. this.emitEvent( 'layout', [ this ] );
  790. };
  791. proto.getXValue = function( x ) {
  792. var isHorizontal = this.layout._getOption('horizontal');
  793. return this.layout.options.percentPosition && !isHorizontal ?
  794. ( ( x / this.layout.size.width ) * 100 ) + '%' : x + 'px';
  795. };
  796. proto.getYValue = function( y ) {
  797. var isHorizontal = this.layout._getOption('horizontal');
  798. return this.layout.options.percentPosition && isHorizontal ?
  799. ( ( y / this.layout.size.height ) * 100 ) + '%' : y + 'px';
  800. };
  801. proto._transitionTo = function( x, y ) {
  802. this.getPosition();
  803. // get current x & y from top/left
  804. var curX = this.position.x;
  805. var curY = this.position.y;
  806. var didNotMove = x == this.position.x && y == this.position.y;
  807. // save end position
  808. this.setPosition( x, y );
  809. // if did not move and not transitioning, just go to layout
  810. if ( didNotMove && !this.isTransitioning ) {
  811. this.layoutPosition();
  812. return;
  813. }
  814. var transX = x - curX;
  815. var transY = y - curY;
  816. var transitionStyle = {};
  817. transitionStyle.transform = this.getTranslate( transX, transY );
  818. this.transition({
  819. to: transitionStyle,
  820. onTransitionEnd: {
  821. transform: this.layoutPosition
  822. },
  823. isCleaning: true
  824. });
  825. };
  826. proto.getTranslate = function( x, y ) {
  827. // flip cooridinates if origin on right or bottom
  828. var isOriginLeft = this.layout._getOption('originLeft');
  829. var isOriginTop = this.layout._getOption('originTop');
  830. x = isOriginLeft ? x : -x;
  831. y = isOriginTop ? y : -y;
  832. return 'translate3d(' + x + 'px, ' + y + 'px, 0)';
  833. };
  834. // non transition + transform support
  835. proto.goTo = function( x, y ) {
  836. this.setPosition( x, y );
  837. this.layoutPosition();
  838. };
  839. proto.moveTo = proto._transitionTo;
  840. proto.setPosition = function( x, y ) {
  841. this.position.x = parseFloat( x );
  842. this.position.y = parseFloat( y );
  843. };
  844. // ----- transition ----- //
  845. /**
  846. * @param {Object} style - CSS
  847. * @param {Function} onTransitionEnd
  848. */
  849. // non transition, just trigger callback
  850. proto._nonTransition = function( args ) {
  851. this.css( args.to );
  852. if ( args.isCleaning ) {
  853. this._removeStyles( args.to );
  854. }
  855. for ( var prop in args.onTransitionEnd ) {
  856. args.onTransitionEnd[ prop ].call( this );
  857. }
  858. };
  859. /**
  860. * proper transition
  861. * @param {Object} args - arguments
  862. * @param {Object} to - style to transition to
  863. * @param {Object} from - style to start transition from
  864. * @param {Boolean} isCleaning - removes transition styles after transition
  865. * @param {Function} onTransitionEnd - callback
  866. */
  867. proto.transition = function( args ) {
  868. // redirect to nonTransition if no transition duration
  869. if ( !parseFloat( this.layout.options.transitionDuration ) ) {
  870. this._nonTransition( args );
  871. return;
  872. }
  873. var _transition = this._transn;
  874. // keep track of onTransitionEnd callback by css property
  875. for ( var prop in args.onTransitionEnd ) {
  876. _transition.onEnd[ prop ] = args.onTransitionEnd[ prop ];
  877. }
  878. // keep track of properties that are transitioning
  879. for ( prop in args.to ) {
  880. _transition.ingProperties[ prop ] = true;
  881. // keep track of properties to clean up when transition is done
  882. if ( args.isCleaning ) {
  883. _transition.clean[ prop ] = true;
  884. }
  885. }
  886. // set from styles
  887. if ( args.from ) {
  888. this.css( args.from );
  889. // force redraw. http://blog.alexmaccaw.com/css-transitions
  890. var h = this.element.offsetHeight;
  891. // hack for JSHint to hush about unused var
  892. h = null;
  893. }
  894. // enable transition
  895. this.enableTransition( args.to );
  896. // set styles that are transitioning
  897. this.css( args.to );
  898. this.isTransitioning = true;
  899. };
  900. // dash before all cap letters, including first for
  901. // WebkitTransform => -webkit-transform
  902. function toDashedAll( str ) {
  903. return str.replace( /([A-Z])/g, function( $1 ) {
  904. return '-' + $1.toLowerCase();
  905. });
  906. }
  907. var transitionProps = 'opacity,' + toDashedAll( transformProperty );
  908. proto.enableTransition = function(/* style */) {
  909. // HACK changing transitionProperty during a transition
  910. // will cause transition to jump
  911. if ( this.isTransitioning ) {
  912. return;
  913. }
  914. // make `transition: foo, bar, baz` from style object
  915. // HACK un-comment this when enableTransition can work
  916. // while a transition is happening
  917. // var transitionValues = [];
  918. // for ( var prop in style ) {
  919. // // dash-ify camelCased properties like WebkitTransition
  920. // prop = vendorProperties[ prop ] || prop;
  921. // transitionValues.push( toDashedAll( prop ) );
  922. // }
  923. // munge number to millisecond, to match stagger
  924. var duration = this.layout.options.transitionDuration;
  925. duration = typeof duration == 'number' ? duration + 'ms' : duration;
  926. // enable transition styles
  927. this.css({
  928. transitionProperty: transitionProps,
  929. transitionDuration: duration,
  930. transitionDelay: this.staggerDelay || 0
  931. });
  932. // listen for transition end event
  933. this.element.addEventListener( transitionEndEvent, this, false );
  934. };
  935. // ----- events ----- //
  936. proto.onwebkitTransitionEnd = function( event ) {
  937. this.ontransitionend( event );
  938. };
  939. proto.onotransitionend = function( event ) {
  940. this.ontransitionend( event );
  941. };
  942. // properties that I munge to make my life easier
  943. var dashedVendorProperties = {
  944. '-webkit-transform': 'transform'
  945. };
  946. proto.ontransitionend = function( event ) {
  947. // disregard bubbled events from children
  948. if ( event.target !== this.element ) {
  949. return;
  950. }
  951. var _transition = this._transn;
  952. // get property name of transitioned property, convert to prefix-free
  953. var propertyName = dashedVendorProperties[ event.propertyName ] || event.propertyName;
  954. // remove property that has completed transitioning
  955. delete _transition.ingProperties[ propertyName ];
  956. // check if any properties are still transitioning
  957. if ( isEmptyObj( _transition.ingProperties ) ) {
  958. // all properties have completed transitioning
  959. this.disableTransition();
  960. }
  961. // clean style
  962. if ( propertyName in _transition.clean ) {
  963. // clean up style
  964. this.element.style[ event.propertyName ] = '';
  965. delete _transition.clean[ propertyName ];
  966. }
  967. // trigger onTransitionEnd callback
  968. if ( propertyName in _transition.onEnd ) {
  969. var onTransitionEnd = _transition.onEnd[ propertyName ];
  970. onTransitionEnd.call( this );
  971. delete _transition.onEnd[ propertyName ];
  972. }
  973. this.emitEvent( 'transitionEnd', [ this ] );
  974. };
  975. proto.disableTransition = function() {
  976. this.removeTransitionStyles();
  977. this.element.removeEventListener( transitionEndEvent, this, false );
  978. this.isTransitioning = false;
  979. };
  980. /**
  981. * removes style property from element
  982. * @param {Object} style
  983. **/
  984. proto._removeStyles = function( style ) {
  985. // clean up transition styles
  986. var cleanStyle = {};
  987. for ( var prop in style ) {
  988. cleanStyle[ prop ] = '';
  989. }
  990. this.css( cleanStyle );
  991. };
  992. var cleanTransitionStyle = {
  993. transitionProperty: '',
  994. transitionDuration: '',
  995. transitionDelay: ''
  996. };
  997. proto.removeTransitionStyles = function() {
  998. // remove transition
  999. this.css( cleanTransitionStyle );
  1000. };
  1001. // ----- stagger ----- //
  1002. proto.stagger = function( delay ) {
  1003. delay = isNaN( delay ) ? 0 : delay;
  1004. this.staggerDelay = delay + 'ms';
  1005. };
  1006. // ----- show/hide/remove ----- //
  1007. // remove element from DOM
  1008. proto.removeElem = function() {
  1009. this.element.parentNode.removeChild( this.element );
  1010. // remove display: none
  1011. this.css({ display: '' });
  1012. this.emitEvent( 'remove', [ this ] );
  1013. };
  1014. proto.remove = function() {
  1015. // just remove element if no transition support or no transition
  1016. if ( !transitionProperty || !parseFloat( this.layout.options.transitionDuration ) ) {
  1017. this.removeElem();
  1018. return;
  1019. }
  1020. // start transition
  1021. this.once( 'transitionEnd', function() {
  1022. this.removeElem();
  1023. });
  1024. this.hide();
  1025. };
  1026. proto.reveal = function() {
  1027. delete this.isHidden;
  1028. // remove display: none
  1029. this.css({ display: '' });
  1030. var options = this.layout.options;
  1031. var onTransitionEnd = {};
  1032. var transitionEndProperty = this.getHideRevealTransitionEndProperty('visibleStyle');
  1033. onTransitionEnd[ transitionEndProperty ] = this.onRevealTransitionEnd;
  1034. this.transition({
  1035. from: options.hiddenStyle,
  1036. to: options.visibleStyle,
  1037. isCleaning: true,
  1038. onTransitionEnd: onTransitionEnd
  1039. });
  1040. };
  1041. proto.onRevealTransitionEnd = function() {
  1042. // check if still visible
  1043. // during transition, item may have been hidden
  1044. if ( !this.isHidden ) {
  1045. this.emitEvent('reveal');
  1046. }
  1047. };
  1048. /**
  1049. * get style property use for hide/reveal transition end
  1050. * @param {String} styleProperty - hiddenStyle/visibleStyle
  1051. * @returns {String}
  1052. */
  1053. proto.getHideRevealTransitionEndProperty = function( styleProperty ) {
  1054. var optionStyle = this.layout.options[ styleProperty ];
  1055. // use opacity
  1056. if ( optionStyle.opacity ) {
  1057. return 'opacity';
  1058. }
  1059. // get first property
  1060. for ( var prop in optionStyle ) {
  1061. return prop;
  1062. }
  1063. };
  1064. proto.hide = function() {
  1065. // set flag
  1066. this.isHidden = true;
  1067. // remove display: none
  1068. this.css({ display: '' });
  1069. var options = this.layout.options;
  1070. var onTransitionEnd = {};
  1071. var transitionEndProperty = this.getHideRevealTransitionEndProperty('hiddenStyle');
  1072. onTransitionEnd[ transitionEndProperty ] = this.onHideTransitionEnd;
  1073. this.transition({
  1074. from: options.visibleStyle,
  1075. to: options.hiddenStyle,
  1076. // keep hidden stuff hidden
  1077. isCleaning: true,
  1078. onTransitionEnd: onTransitionEnd
  1079. });
  1080. };
  1081. proto.onHideTransitionEnd = function() {
  1082. // check if still hidden
  1083. // during transition, item may have been un-hidden
  1084. if ( this.isHidden ) {
  1085. this.css({ display: 'none' });
  1086. this.emitEvent('hide');
  1087. }
  1088. };
  1089. proto.destroy = function() {
  1090. this.css({
  1091. position: '',
  1092. left: '',
  1093. right: '',
  1094. top: '',
  1095. bottom: '',
  1096. transition: '',
  1097. transform: ''
  1098. });
  1099. };
  1100. return Item;
  1101. }));
  1102. /*!
  1103. * Outlayer v2.1.1
  1104. * the brains and guts of a layout library
  1105. * MIT license
  1106. */
  1107. ( function( window, factory ) {
  1108. 'use strict';
  1109. // universal module definition
  1110. /* jshint strict: false */ /* globals define, module, require */
  1111. if ( typeof define == 'function' && define.amd ) {
  1112. // AMD - RequireJS
  1113. define( 'outlayer/outlayer',[
  1114. 'ev-emitter/ev-emitter',
  1115. 'get-size/get-size',
  1116. 'fizzy-ui-utils/utils',
  1117. './item'
  1118. ],
  1119. function( EvEmitter, getSize, utils, Item ) {
  1120. return factory( window, EvEmitter, getSize, utils, Item);
  1121. }
  1122. );
  1123. } else if ( typeof module == 'object' && module.exports ) {
  1124. // CommonJS - Browserify, Webpack
  1125. module.exports = factory(
  1126. window,
  1127. require('ev-emitter'),
  1128. require('get-size'),
  1129. require('fizzy-ui-utils'),
  1130. require('./item')
  1131. );
  1132. } else {
  1133. // browser global
  1134. window.Outlayer = factory(
  1135. window,
  1136. window.EvEmitter,
  1137. window.getSize,
  1138. window.fizzyUIUtils,
  1139. window.Outlayer.Item
  1140. );
  1141. }
  1142. }( window, function factory( window, EvEmitter, getSize, utils, Item ) {
  1143. 'use strict';
  1144. // ----- vars ----- //
  1145. var console = window.console;
  1146. var jQuery = window.jQuery;
  1147. var noop = function() {};
  1148. // -------------------------- Outlayer -------------------------- //
  1149. // globally unique identifiers
  1150. var GUID = 0;
  1151. // internal store of all Outlayer intances
  1152. var instances = {};
  1153. /**
  1154. * @param {Element, String} element
  1155. * @param {Object} options
  1156. * @constructor
  1157. */
  1158. function Outlayer( element, options ) {
  1159. var queryElement = utils.getQueryElement( element );
  1160. if ( !queryElement ) {
  1161. if ( console ) {
  1162. console.error( 'Bad element for ' + this.constructor.namespace +
  1163. ': ' + ( queryElement || element ) );
  1164. }
  1165. return;
  1166. }
  1167. this.element = queryElement;
  1168. // add jQuery
  1169. if ( jQuery ) {
  1170. this.$element = jQuery( this.element );
  1171. }
  1172. // options
  1173. this.options = utils.extend( {}, this.constructor.defaults );
  1174. this.option( options );
  1175. // add id for Outlayer.getFromElement
  1176. var id = ++GUID;
  1177. this.element.outlayerGUID = id; // expando
  1178. instances[ id ] = this; // associate via id
  1179. // kick it off
  1180. this._create();
  1181. var isInitLayout = this._getOption('initLayout');
  1182. if ( isInitLayout ) {
  1183. this.layout();
  1184. }
  1185. }
  1186. // settings are for internal use only
  1187. Outlayer.namespace = 'outlayer';
  1188. Outlayer.Item = Item;
  1189. // default options
  1190. Outlayer.defaults = {
  1191. containerStyle: {
  1192. position: 'relative'
  1193. },
  1194. initLayout: true,
  1195. originLeft: true,
  1196. originTop: true,
  1197. resize: true,
  1198. resizeContainer: true,
  1199. // item options
  1200. transitionDuration: '0.4s',
  1201. hiddenStyle: {
  1202. opacity: 0,
  1203. transform: 'scale(0.001)'
  1204. },
  1205. visibleStyle: {
  1206. opacity: 1,
  1207. transform: 'scale(1)'
  1208. }
  1209. };
  1210. var proto = Outlayer.prototype;
  1211. // inherit EvEmitter
  1212. utils.extend( proto, EvEmitter.prototype );
  1213. /**
  1214. * set options
  1215. * @param {Object} opts
  1216. */
  1217. proto.option = function( opts ) {
  1218. utils.extend( this.options, opts );
  1219. };
  1220. /**
  1221. * get backwards compatible option value, check old name
  1222. */
  1223. proto._getOption = function( option ) {
  1224. var oldOption = this.constructor.compatOptions[ option ];
  1225. return oldOption && this.options[ oldOption ] !== undefined ?
  1226. this.options[ oldOption ] : this.options[ option ];
  1227. };
  1228. Outlayer.compatOptions = {
  1229. // currentName: oldName
  1230. initLayout: 'isInitLayout',
  1231. horizontal: 'isHorizontal',
  1232. layoutInstant: 'isLayoutInstant',
  1233. originLeft: 'isOriginLeft',
  1234. originTop: 'isOriginTop',
  1235. resize: 'isResizeBound',
  1236. resizeContainer: 'isResizingContainer'
  1237. };
  1238. proto._create = function() {
  1239. // get items from children
  1240. this.reloadItems();
  1241. // elements that affect layout, but are not laid out
  1242. this.stamps = [];
  1243. this.stamp( this.options.stamp );
  1244. // set container style
  1245. utils.extend( this.element.style, this.options.containerStyle );
  1246. // bind resize method
  1247. var canBindResize = this._getOption('resize');
  1248. if ( canBindResize ) {
  1249. this.bindResize();
  1250. }
  1251. };
  1252. // goes through all children again and gets bricks in proper order
  1253. proto.reloadItems = function() {
  1254. // collection of item elements
  1255. this.items = this._itemize( this.element.children );
  1256. };
  1257. /**
  1258. * turn elements into Outlayer.Items to be used in layout
  1259. * @param {Array or NodeList or HTMLElement} elems
  1260. * @returns {Array} items - collection of new Outlayer Items
  1261. */
  1262. proto._itemize = function( elems ) {
  1263. var itemElems = this._filterFindItemElements( elems );
  1264. var Item = this.constructor.Item;
  1265. // create new Outlayer Items for collection
  1266. var items = [];
  1267. for ( var i=0; i < itemElems.length; i++ ) {
  1268. var elem = itemElems[i];
  1269. var item = new Item( elem, this );
  1270. items.push( item );
  1271. }
  1272. return items;
  1273. };
  1274. /**
  1275. * get item elements to be used in layout
  1276. * @param {Array or NodeList or HTMLElement} elems
  1277. * @returns {Array} items - item elements
  1278. */
  1279. proto._filterFindItemElements = function( elems ) {
  1280. return utils.filterFindElements( elems, this.options.itemSelector );
  1281. };
  1282. /**
  1283. * getter method for getting item elements
  1284. * @returns {Array} elems - collection of item elements
  1285. */
  1286. proto.getItemElements = function() {
  1287. return this.items.map( function( item ) {
  1288. return item.element;
  1289. });
  1290. };
  1291. // ----- init & layout ----- //
  1292. /**
  1293. * lays out all items
  1294. */
  1295. proto.layout = function() {
  1296. this._resetLayout();
  1297. this._manageStamps();
  1298. // don't animate first layout
  1299. var layoutInstant = this._getOption('layoutInstant');
  1300. var isInstant = layoutInstant !== undefined ?
  1301. layoutInstant : !this._isLayoutInited;
  1302. this.layoutItems( this.items, isInstant );
  1303. // flag for initalized
  1304. this._isLayoutInited = true;
  1305. };
  1306. // _init is alias for layout
  1307. proto._init = proto.layout;
  1308. /**
  1309. * logic before any new layout
  1310. */
  1311. proto._resetLayout = function() {
  1312. this.getSize();
  1313. };
  1314. proto.getSize = function() {
  1315. this.size = getSize( this.element );
  1316. };
  1317. /**
  1318. * get measurement from option, for columnWidth, rowHeight, gutter
  1319. * if option is String -> get element from selector string, & get size of element
  1320. * if option is Element -> get size of element
  1321. * else use option as a number
  1322. *
  1323. * @param {String} measurement
  1324. * @param {String} size - width or height
  1325. * @private
  1326. */
  1327. proto._getMeasurement = function( measurement, size ) {
  1328. var option = this.options[ measurement ];
  1329. var elem;
  1330. if ( !option ) {
  1331. // default to 0
  1332. this[ measurement ] = 0;
  1333. } else {
  1334. // use option as an element
  1335. if ( typeof option == 'string' ) {
  1336. elem = this.element.querySelector( option );
  1337. } else if ( option instanceof HTMLElement ) {
  1338. elem = option;
  1339. }
  1340. // use size of element, if element
  1341. this[ measurement ] = elem ? getSize( elem )[ size ] : option;
  1342. }
  1343. };
  1344. /**
  1345. * layout a collection of item elements
  1346. * @api public
  1347. */
  1348. proto.layoutItems = function( items, isInstant ) {
  1349. items = this._getItemsForLayout( items );
  1350. this._layoutItems( items, isInstant );
  1351. this._postLayout();
  1352. };
  1353. /**
  1354. * get the items to be laid out
  1355. * you may want to skip over some items
  1356. * @param {Array} items
  1357. * @returns {Array} items
  1358. */
  1359. proto._getItemsForLayout = function( items ) {
  1360. return items.filter( function( item ) {
  1361. return !item.isIgnored;
  1362. });
  1363. };
  1364. /**
  1365. * layout items
  1366. * @param {Array} items
  1367. * @param {Boolean} isInstant
  1368. */
  1369. proto._layoutItems = function( items, isInstant ) {
  1370. this._emitCompleteOnItems( 'layout', items );
  1371. if ( !items || !items.length ) {
  1372. // no items, emit event with empty array
  1373. return;
  1374. }
  1375. var queue = [];
  1376. items.forEach( function( item ) {
  1377. // get x/y object from method
  1378. var position = this._getItemLayoutPosition( item );
  1379. // enqueue
  1380. position.item = item;
  1381. position.isInstant = isInstant || item.isLayoutInstant;
  1382. queue.push( position );
  1383. }, this );
  1384. this._processLayoutQueue( queue );
  1385. };
  1386. /**
  1387. * get item layout position
  1388. * @param {Outlayer.Item} item
  1389. * @returns {Object} x and y position
  1390. */
  1391. proto._getItemLayoutPosition = function( /* item */ ) {
  1392. return {
  1393. x: 0,
  1394. y: 0
  1395. };
  1396. };
  1397. /**
  1398. * iterate over array and position each item
  1399. * Reason being - separating this logic prevents 'layout invalidation'
  1400. * thx @paul_irish
  1401. * @param {Array} queue
  1402. */
  1403. proto._processLayoutQueue = function( queue ) {
  1404. this.updateStagger();
  1405. queue.forEach( function( obj, i ) {
  1406. this._positionItem( obj.item, obj.x, obj.y, obj.isInstant, i );
  1407. }, this );
  1408. };
  1409. // set stagger from option in milliseconds number
  1410. proto.updateStagger = function() {
  1411. var stagger = this.options.stagger;
  1412. if ( stagger === null || stagger === undefined ) {
  1413. this.stagger = 0;
  1414. return;
  1415. }
  1416. this.stagger = getMilliseconds( stagger );
  1417. return this.stagger;
  1418. };
  1419. /**
  1420. * Sets position of item in DOM
  1421. * @param {Outlayer.Item} item
  1422. * @param {Number} x - horizontal position
  1423. * @param {Number} y - vertical position
  1424. * @param {Boolean} isInstant - disables transitions
  1425. */
  1426. proto._positionItem = function( item, x, y, isInstant, i ) {
  1427. if ( isInstant ) {
  1428. // if not transition, just set CSS
  1429. item.goTo( x, y );
  1430. } else {
  1431. item.stagger( i * this.stagger );
  1432. item.moveTo( x, y );
  1433. }
  1434. };
  1435. /**
  1436. * Any logic you want to do after each layout,
  1437. * i.e. size the container
  1438. */
  1439. proto._postLayout = function() {
  1440. this.resizeContainer();
  1441. };
  1442. proto.resizeContainer = function() {
  1443. var isResizingContainer = this._getOption('resizeContainer');
  1444. if ( !isResizingContainer ) {
  1445. return;
  1446. }
  1447. var size = this._getContainerSize();
  1448. if ( size ) {
  1449. this._setContainerMeasure( size.width, true );
  1450. this._setContainerMeasure( size.height, false );
  1451. }
  1452. };
  1453. /**
  1454. * Sets width or height of container if returned
  1455. * @returns {Object} size
  1456. * @param {Number} width
  1457. * @param {Number} height
  1458. */
  1459. proto._getContainerSize = noop;
  1460. /**
  1461. * @param {Number} measure - size of width or height
  1462. * @param {Boolean} isWidth
  1463. */
  1464. proto._setContainerMeasure = function( measure, isWidth ) {
  1465. if ( measure === undefined ) {
  1466. return;
  1467. }
  1468. var elemSize = this.size;
  1469. // add padding and border width if border box
  1470. if ( elemSize.isBorderBox ) {
  1471. measure += isWidth ? elemSize.paddingLeft + elemSize.paddingRight +
  1472. elemSize.borderLeftWidth + elemSize.borderRightWidth :
  1473. elemSize.paddingBottom + elemSize.paddingTop +
  1474. elemSize.borderTopWidth + elemSize.borderBottomWidth;
  1475. }
  1476. measure = Math.max( measure, 0 );
  1477. this.element.style[ isWidth ? 'width' : 'height' ] = measure + 'px';
  1478. };
  1479. /**
  1480. * emit eventComplete on a collection of items events
  1481. * @param {String} eventName
  1482. * @param {Array} items - Outlayer.Items
  1483. */
  1484. proto._emitCompleteOnItems = function( eventName, items ) {
  1485. var _this = this;
  1486. function onComplete() {
  1487. _this.dispatchEvent( eventName + 'Complete', null, [ items ] );
  1488. }
  1489. var count = items.length;
  1490. if ( !items || !count ) {
  1491. onComplete();
  1492. return;
  1493. }
  1494. var doneCount = 0;
  1495. function tick() {
  1496. doneCount++;
  1497. if ( doneCount == count ) {
  1498. onComplete();
  1499. }
  1500. }
  1501. // bind callback
  1502. items.forEach( function( item ) {
  1503. item.once( eventName, tick );
  1504. });
  1505. };
  1506. /**
  1507. * emits events via EvEmitter and jQuery events
  1508. * @param {String} type - name of event
  1509. * @param {Event} event - original event
  1510. * @param {Array} args - extra arguments
  1511. */
  1512. proto.dispatchEvent = function( type, event, args ) {
  1513. // add original event to arguments
  1514. var emitArgs = event ? [ event ].concat( args ) : args;
  1515. this.emitEvent( type, emitArgs );
  1516. if ( jQuery ) {
  1517. // set this.$element
  1518. this.$element = this.$element || jQuery( this.element );
  1519. if ( event ) {
  1520. // create jQuery event
  1521. var $event = jQuery.Event( event );
  1522. $event.type = type;
  1523. this.$element.trigger( $event, args );
  1524. } else {
  1525. // just trigger with type if no event available
  1526. this.$element.trigger( type, args );
  1527. }
  1528. }
  1529. };
  1530. // -------------------------- ignore & stamps -------------------------- //
  1531. /**
  1532. * keep item in collection, but do not lay it out
  1533. * ignored items do not get skipped in layout
  1534. * @param {Element} elem
  1535. */
  1536. proto.ignore = function( elem ) {
  1537. var item = this.getItem( elem );
  1538. if ( item ) {
  1539. item.isIgnored = true;
  1540. }
  1541. };
  1542. /**
  1543. * return item to layout collection
  1544. * @param {Element} elem
  1545. */
  1546. proto.unignore = function( elem ) {
  1547. var item = this.getItem( elem );
  1548. if ( item ) {
  1549. delete item.isIgnored;
  1550. }
  1551. };
  1552. /**
  1553. * adds elements to stamps
  1554. * @param {NodeList, Array, Element, or String} elems
  1555. */
  1556. proto.stamp = function( elems ) {
  1557. elems = this._find( elems );
  1558. if ( !elems ) {
  1559. return;
  1560. }
  1561. this.stamps = this.stamps.concat( elems );
  1562. // ignore
  1563. elems.forEach( this.ignore, this );
  1564. };
  1565. /**
  1566. * removes elements to stamps
  1567. * @param {NodeList, Array, or Element} elems
  1568. */
  1569. proto.unstamp = function( elems ) {
  1570. elems = this._find( elems );
  1571. if ( !elems ){
  1572. return;
  1573. }
  1574. elems.forEach( function( elem ) {
  1575. // filter out removed stamp elements
  1576. utils.removeFrom( this.stamps, elem );
  1577. this.unignore( elem );
  1578. }, this );
  1579. };
  1580. /**
  1581. * finds child elements
  1582. * @param {NodeList, Array, Element, or String} elems
  1583. * @returns {Array} elems
  1584. */
  1585. proto._find = function( elems ) {
  1586. if ( !elems ) {
  1587. return;
  1588. }
  1589. // if string, use argument as selector string
  1590. if ( typeof elems == 'string' ) {
  1591. elems = this.element.querySelectorAll( elems );
  1592. }
  1593. elems = utils.makeArray( elems );
  1594. return elems;
  1595. };
  1596. proto._manageStamps = function() {
  1597. if ( !this.stamps || !this.stamps.length ) {
  1598. return;
  1599. }
  1600. this._getBoundingRect();
  1601. this.stamps.forEach( this._manageStamp, this );
  1602. };
  1603. // update boundingLeft / Top
  1604. proto._getBoundingRect = function() {
  1605. // get bounding rect for container element
  1606. var boundingRect = this.element.getBoundingClientRect();
  1607. var size = this.size;
  1608. this._boundingRect = {
  1609. left: boundingRect.left + size.paddingLeft + size.borderLeftWidth,
  1610. top: boundingRect.top + size.paddingTop + size.borderTopWidth,
  1611. right: boundingRect.right - ( size.paddingRight + size.borderRightWidth ),
  1612. bottom: boundingRect.bottom - ( size.paddingBottom + size.borderBottomWidth )
  1613. };
  1614. };
  1615. /**
  1616. * @param {Element} stamp
  1617. **/
  1618. proto._manageStamp = noop;
  1619. /**
  1620. * get x/y position of element relative to container element
  1621. * @param {Element} elem
  1622. * @returns {Object} offset - has left, top, right, bottom
  1623. */
  1624. proto._getElementOffset = function( elem ) {
  1625. var boundingRect = elem.getBoundingClientRect();
  1626. var thisRect = this._boundingRect;
  1627. var size = getSize( elem );
  1628. var offset = {
  1629. left: boundingRect.left - thisRect.left - size.marginLeft,
  1630. top: boundingRect.top - thisRect.top - size.marginTop,
  1631. right: thisRect.right - boundingRect.right - size.marginRight,
  1632. bottom: thisRect.bottom - boundingRect.bottom - size.marginBottom
  1633. };
  1634. return offset;
  1635. };
  1636. // -------------------------- resize -------------------------- //
  1637. // enable event handlers for listeners
  1638. // i.e. resize -> onresize
  1639. proto.handleEvent = utils.handleEvent;
  1640. /**
  1641. * Bind layout to window resizing
  1642. */
  1643. proto.bindResize = function() {
  1644. window.addEventListener( 'resize', this );
  1645. this.isResizeBound = true;
  1646. };
  1647. /**
  1648. * Unbind layout to window resizing
  1649. */
  1650. proto.unbindResize = function() {
  1651. window.removeEventListener( 'resize', this );
  1652. this.isResizeBound = false;
  1653. };
  1654. proto.onresize = function() {
  1655. this.resize();
  1656. };
  1657. utils.debounceMethod( Outlayer, 'onresize', 100 );
  1658. proto.resize = function() {
  1659. // don't trigger if size did not change
  1660. // or if resize was unbound. See #9
  1661. if ( !this.isResizeBound || !this.needsResizeLayout() ) {
  1662. return;
  1663. }
  1664. this.layout();
  1665. };
  1666. /**
  1667. * check if layout is needed post layout
  1668. * @returns Boolean
  1669. */
  1670. proto.needsResizeLayout = function() {
  1671. var size = getSize( this.element );
  1672. // check that this.size and size are there
  1673. // IE8 triggers resize on body size change, so they might not be
  1674. var hasSizes = this.size && size;
  1675. return hasSizes && size.innerWidth !== this.size.innerWidth;
  1676. };
  1677. // -------------------------- methods -------------------------- //
  1678. /**
  1679. * add items to Outlayer instance
  1680. * @param {Array or NodeList or Element} elems
  1681. * @returns {Array} items - Outlayer.Items
  1682. **/
  1683. proto.addItems = function( elems ) {
  1684. var items = this._itemize( elems );
  1685. // add items to collection
  1686. if ( items.length ) {
  1687. this.items = this.items.concat( items );
  1688. }
  1689. return items;
  1690. };
  1691. /**
  1692. * Layout newly-appended item elements
  1693. * @param {Array or NodeList or Element} elems
  1694. */
  1695. proto.appended = function( elems ) {
  1696. var items = this.addItems( elems );
  1697. if ( !items.length ) {
  1698. return;
  1699. }
  1700. // layout and reveal just the new items
  1701. this.layoutItems( items, true );
  1702. this.reveal( items );
  1703. };
  1704. /**
  1705. * Layout prepended elements
  1706. * @param {Array or NodeList or Element} elems
  1707. */
  1708. proto.prepended = function( elems ) {
  1709. var items = this._itemize( elems );
  1710. if ( !items.length ) {
  1711. return;
  1712. }
  1713. // add items to beginning of collection
  1714. var previousItems = this.items.slice(0);
  1715. this.items = items.concat( previousItems );
  1716. // start new layout
  1717. this._resetLayout();
  1718. this._manageStamps();
  1719. // layout new stuff without transition
  1720. this.layoutItems( items, true );
  1721. this.reveal( items );
  1722. // layout previous items
  1723. this.layoutItems( previousItems );
  1724. };
  1725. /**
  1726. * reveal a collection of items
  1727. * @param {Array of Outlayer.Items} items
  1728. */
  1729. proto.reveal = function( items ) {
  1730. this._emitCompleteOnItems( 'reveal', items );
  1731. if ( !items || !items.length ) {
  1732. return;
  1733. }
  1734. var stagger = this.updateStagger();
  1735. items.forEach( function( item, i ) {
  1736. item.stagger( i * stagger );
  1737. item.reveal();
  1738. });
  1739. };
  1740. /**
  1741. * hide a collection of items
  1742. * @param {Array of Outlayer.Items} items
  1743. */
  1744. proto.hide = function( items ) {
  1745. this._emitCompleteOnItems( 'hide', items );
  1746. if ( !items || !items.length ) {
  1747. return;
  1748. }
  1749. var stagger = this.updateStagger();
  1750. items.forEach( function( item, i ) {
  1751. item.stagger( i * stagger );
  1752. item.hide();
  1753. });
  1754. };
  1755. /**
  1756. * reveal item elements
  1757. * @param {Array}, {Element}, {NodeList} items
  1758. */
  1759. proto.revealItemElements = function( elems ) {
  1760. var items = this.getItems( elems );
  1761. this.reveal( items );
  1762. };
  1763. /**
  1764. * hide item elements
  1765. * @param {Array}, {Element}, {NodeList} items
  1766. */
  1767. proto.hideItemElements = function( elems ) {
  1768. var items = this.getItems( elems );
  1769. this.hide( items );
  1770. };
  1771. /**
  1772. * get Outlayer.Item, given an Element
  1773. * @param {Element} elem
  1774. * @param {Function} callback
  1775. * @returns {Outlayer.Item} item
  1776. */
  1777. proto.getItem = function( elem ) {
  1778. // loop through items to get the one that matches
  1779. for ( var i=0; i < this.items.length; i++ ) {
  1780. var item = this.items[i];
  1781. if ( item.element == elem ) {
  1782. // return item
  1783. return item;
  1784. }
  1785. }
  1786. };
  1787. /**
  1788. * get collection of Outlayer.Items, given Elements
  1789. * @param {Array} elems
  1790. * @returns {Array} items - Outlayer.Items
  1791. */
  1792. proto.getItems = function( elems ) {
  1793. elems = utils.makeArray( elems );
  1794. var items = [];
  1795. elems.forEach( function( elem ) {
  1796. var item = this.getItem( elem );
  1797. if ( item ) {
  1798. items.push( item );
  1799. }
  1800. }, this );
  1801. return items;
  1802. };
  1803. /**
  1804. * remove element(s) from instance and DOM
  1805. * @param {Array or NodeList or Element} elems
  1806. */
  1807. proto.remove = function( elems ) {
  1808. var removeItems = this.getItems( elems );
  1809. this._emitCompleteOnItems( 'remove', removeItems );
  1810. // bail if no items to remove
  1811. if ( !removeItems || !removeItems.length ) {
  1812. return;
  1813. }
  1814. removeItems.forEach( function( item ) {
  1815. item.remove();
  1816. // remove item from collection
  1817. utils.removeFrom( this.items, item );
  1818. }, this );
  1819. };
  1820. // ----- destroy ----- //
  1821. // remove and disable Outlayer instance
  1822. proto.destroy = function() {
  1823. // clean up dynamic styles
  1824. var style = this.element.style;
  1825. style.height = '';
  1826. style.position = '';
  1827. style.width = '';
  1828. // destroy items
  1829. this.items.forEach( function( item ) {
  1830. item.destroy();
  1831. });
  1832. this.unbindResize();
  1833. var id = this.element.outlayerGUID;
  1834. delete instances[ id ]; // remove reference to instance by id
  1835. delete this.element.outlayerGUID;
  1836. // remove data for jQuery
  1837. if ( jQuery ) {
  1838. jQuery.removeData( this.element, this.constructor.namespace );
  1839. }
  1840. };
  1841. // -------------------------- data -------------------------- //
  1842. /**
  1843. * get Outlayer instance from element
  1844. * @param {Element} elem
  1845. * @returns {Outlayer}
  1846. */
  1847. Outlayer.data = function( elem ) {
  1848. elem = utils.getQueryElement( elem );
  1849. var id = elem && elem.outlayerGUID;
  1850. return id && instances[ id ];
  1851. };
  1852. // -------------------------- create Outlayer class -------------------------- //
  1853. /**
  1854. * create a layout class
  1855. * @param {String} namespace
  1856. */
  1857. Outlayer.create = function( namespace, options ) {
  1858. // sub-class Outlayer
  1859. var Layout = subclass( Outlayer );
  1860. // apply new options and compatOptions
  1861. Layout.defaults = utils.extend( {}, Outlayer.defaults );
  1862. utils.extend( Layout.defaults, options );
  1863. Layout.compatOptions = utils.extend( {}, Outlayer.compatOptions );
  1864. Layout.namespace = namespace;
  1865. Layout.data = Outlayer.data;
  1866. // sub-class Item
  1867. Layout.Item = subclass( Item );
  1868. // -------------------------- declarative -------------------------- //
  1869. utils.htmlInit( Layout, namespace );
  1870. // -------------------------- jQuery bridge -------------------------- //
  1871. // make into jQuery plugin
  1872. if ( jQuery && jQuery.bridget ) {
  1873. jQuery.bridget( namespace, Layout );
  1874. }
  1875. return Layout;
  1876. };
  1877. function subclass( Parent ) {
  1878. function SubClass() {
  1879. Parent.apply( this, arguments );
  1880. }
  1881. SubClass.prototype = Object.create( Parent.prototype );
  1882. SubClass.prototype.constructor = SubClass;
  1883. return SubClass;
  1884. }
  1885. // ----- helpers ----- //
  1886. // how many milliseconds are in each unit
  1887. var msUnits = {
  1888. ms: 1,
  1889. s: 1000
  1890. };
  1891. // munge time-like parameter into millisecond number
  1892. // '0.4s' -> 40
  1893. function getMilliseconds( time ) {
  1894. if ( typeof time == 'number' ) {
  1895. return time;
  1896. }
  1897. var matches = time.match( /(^\d*\.?\d*)(\w*)/ );
  1898. var num = matches && matches[1];
  1899. var unit = matches && matches[2];
  1900. if ( !num.length ) {
  1901. return 0;
  1902. }
  1903. num = parseFloat( num );
  1904. var mult = msUnits[ unit ] || 1;
  1905. return num * mult;
  1906. }
  1907. // ----- fin ----- //
  1908. // back in global
  1909. Outlayer.Item = Item;
  1910. return Outlayer;
  1911. }));
  1912. /**
  1913. * Isotope Item
  1914. **/
  1915. ( function( window, factory ) {
  1916. // universal module definition
  1917. /* jshint strict: false */ /*globals define, module, require */
  1918. if ( typeof define == 'function' && define.amd ) {
  1919. // AMD
  1920. define( 'isotope-layout/js/item',[
  1921. 'outlayer/outlayer'
  1922. ],
  1923. factory );
  1924. } else if ( typeof module == 'object' && module.exports ) {
  1925. // CommonJS
  1926. module.exports = factory(
  1927. require('outlayer')
  1928. );
  1929. } else {
  1930. // browser global
  1931. window.Isotope = window.Isotope || {};
  1932. window.Isotope.Item = factory(
  1933. window.Outlayer
  1934. );
  1935. }
  1936. }( window, function factory( Outlayer ) {
  1937. 'use strict';
  1938. // -------------------------- Item -------------------------- //
  1939. // sub-class Outlayer Item
  1940. function Item() {
  1941. Outlayer.Item.apply( this, arguments );
  1942. }
  1943. var proto = Item.prototype = Object.create( Outlayer.Item.prototype );
  1944. var _create = proto._create;
  1945. proto._create = function() {
  1946. // assign id, used for original-order sorting
  1947. this.id = this.layout.itemGUID++;
  1948. _create.call( this );
  1949. this.sortData = {};
  1950. };
  1951. proto.updateSortData = function() {
  1952. if ( this.isIgnored ) {
  1953. return;
  1954. }
  1955. // default sorters
  1956. this.sortData.id = this.id;
  1957. // for backward compatibility
  1958. this.sortData['original-order'] = this.id;
  1959. this.sortData.random = Math.random();
  1960. // go thru getSortData obj and apply the sorters
  1961. var getSortData = this.layout.options.getSortData;
  1962. var sorters = this.layout._sorters;
  1963. for ( var key in getSortData ) {
  1964. var sorter = sorters[ key ];
  1965. this.sortData[ key ] = sorter( this.element, this );
  1966. }
  1967. };
  1968. var _destroy = proto.destroy;
  1969. proto.destroy = function() {
  1970. // call super
  1971. _destroy.apply( this, arguments );
  1972. // reset display, #741
  1973. this.css({
  1974. display: ''
  1975. });
  1976. };
  1977. return Item;
  1978. }));
  1979. /**
  1980. * Isotope LayoutMode
  1981. */
  1982. ( function( window, factory ) {
  1983. // universal module definition
  1984. /* jshint strict: false */ /*globals define, module, require */
  1985. if ( typeof define == 'function' && define.amd ) {
  1986. // AMD
  1987. define( 'isotope-layout/js/layout-mode',[
  1988. 'get-size/get-size',
  1989. 'outlayer/outlayer'
  1990. ],
  1991. factory );
  1992. } else if ( typeof module == 'object' && module.exports ) {
  1993. // CommonJS
  1994. module.exports = factory(
  1995. require('get-size'),
  1996. require('outlayer')
  1997. );
  1998. } else {
  1999. // browser global
  2000. window.Isotope = window.Isotope || {};
  2001. window.Isotope.LayoutMode = factory(
  2002. window.getSize,
  2003. window.Outlayer
  2004. );
  2005. }
  2006. }( window, function factory( getSize, Outlayer ) {
  2007. 'use strict';
  2008. // layout mode class
  2009. function LayoutMode( isotope ) {
  2010. this.isotope = isotope;
  2011. // link properties
  2012. if ( isotope ) {
  2013. this.options = isotope.options[ this.namespace ];
  2014. this.element = isotope.element;
  2015. this.items = isotope.filteredItems;
  2016. this.size = isotope.size;
  2017. }
  2018. }
  2019. var proto = LayoutMode.prototype;
  2020. /**
  2021. * some methods should just defer to default Outlayer method
  2022. * and reference the Isotope instance as `this`
  2023. **/
  2024. var facadeMethods = [
  2025. '_resetLayout',
  2026. '_getItemLayoutPosition',
  2027. '_manageStamp',
  2028. '_getContainerSize',
  2029. '_getElementOffset',
  2030. 'needsResizeLayout',
  2031. '_getOption'
  2032. ];
  2033. facadeMethods.forEach( function( methodName ) {
  2034. proto[ methodName ] = function() {
  2035. return Outlayer.prototype[ methodName ].apply( this.isotope, arguments );
  2036. };
  2037. });
  2038. // ----- ----- //
  2039. // for horizontal layout modes, check vertical size
  2040. proto.needsVerticalResizeLayout = function() {
  2041. // don't trigger if size did not change
  2042. var size = getSize( this.isotope.element );
  2043. // check that this.size and size are there
  2044. // IE8 triggers resize on body size change, so they might not be
  2045. var hasSizes = this.isotope.size && size;
  2046. return hasSizes && size.innerHeight != this.isotope.size.innerHeight;
  2047. };
  2048. // ----- measurements ----- //
  2049. proto._getMeasurement = function() {
  2050. this.isotope._getMeasurement.apply( this, arguments );
  2051. };
  2052. proto.getColumnWidth = function() {
  2053. this.getSegmentSize( 'column', 'Width' );
  2054. };
  2055. proto.getRowHeight = function() {
  2056. this.getSegmentSize( 'row', 'Height' );
  2057. };
  2058. /**
  2059. * get columnWidth or rowHeight
  2060. * segment: 'column' or 'row'
  2061. * size 'Width' or 'Height'
  2062. **/
  2063. proto.getSegmentSize = function( segment, size ) {
  2064. var segmentName = segment + size;
  2065. var outerSize = 'outer' + size;
  2066. // columnWidth / outerWidth // rowHeight / outerHeight
  2067. this._getMeasurement( segmentName, outerSize );
  2068. // got rowHeight or columnWidth, we can chill
  2069. if ( this[ segmentName ] ) {
  2070. return;
  2071. }
  2072. // fall back to item of first element
  2073. var firstItemSize = this.getFirstItemSize();
  2074. this[ segmentName ] = firstItemSize && firstItemSize[ outerSize ] ||
  2075. // or size of container
  2076. this.isotope.size[ 'inner' + size ];
  2077. };
  2078. proto.getFirstItemSize = function() {
  2079. var firstItem = this.isotope.filteredItems[0];
  2080. return firstItem && firstItem.element && getSize( firstItem.element );
  2081. };
  2082. // ----- methods that should reference isotope ----- //
  2083. proto.layout = function() {
  2084. this.isotope.layout.apply( this.isotope, arguments );
  2085. };
  2086. proto.getSize = function() {
  2087. this.isotope.getSize();
  2088. this.size = this.isotope.size;
  2089. };
  2090. // -------------------------- create -------------------------- //
  2091. LayoutMode.modes = {};
  2092. LayoutMode.create = function( namespace, options ) {
  2093. function Mode() {
  2094. LayoutMode.apply( this, arguments );
  2095. }
  2096. Mode.prototype = Object.create( proto );
  2097. Mode.prototype.constructor = Mode;
  2098. // default options
  2099. if ( options ) {
  2100. Mode.options = options;
  2101. }
  2102. Mode.prototype.namespace = namespace;
  2103. // register in Isotope
  2104. LayoutMode.modes[ namespace ] = Mode;
  2105. return Mode;
  2106. };
  2107. return LayoutMode;
  2108. }));
  2109. /*!
  2110. * Masonry v4.2.1
  2111. * Cascading grid layout library
  2112. * https://masonry.desandro.com
  2113. * MIT License
  2114. * by David DeSandro
  2115. */
  2116. ( function( window, factory ) {
  2117. // universal module definition
  2118. /* jshint strict: false */ /*globals define, module, require */
  2119. if ( typeof define == 'function' && define.amd ) {
  2120. // AMD
  2121. define( 'masonry-layout/masonry',[
  2122. 'outlayer/outlayer',
  2123. 'get-size/get-size'
  2124. ],
  2125. factory );
  2126. } else if ( typeof module == 'object' && module.exports ) {
  2127. // CommonJS
  2128. module.exports = factory(
  2129. require('outlayer'),
  2130. require('get-size')
  2131. );
  2132. } else {
  2133. // browser global
  2134. window.Masonry = factory(
  2135. window.Outlayer,
  2136. window.getSize
  2137. );
  2138. }
  2139. }( window, function factory( Outlayer, getSize ) {
  2140. // -------------------------- masonryDefinition -------------------------- //
  2141. // create an Outlayer layout class
  2142. var Masonry = Outlayer.create('masonry');
  2143. // isFitWidth -> fitWidth
  2144. Masonry.compatOptions.fitWidth = 'isFitWidth';
  2145. var proto = Masonry.prototype;
  2146. proto._resetLayout = function() {
  2147. this.getSize();
  2148. this._getMeasurement( 'columnWidth', 'outerWidth' );
  2149. this._getMeasurement( 'gutter', 'outerWidth' );
  2150. this.measureColumns();
  2151. // reset column Y
  2152. this.colYs = [];
  2153. for ( var i=0; i < this.cols; i++ ) {
  2154. this.colYs.push( 0 );
  2155. }
  2156. this.maxY = 0;
  2157. this.horizontalColIndex = 0;
  2158. };
  2159. proto.measureColumns = function() {
  2160. this.getContainerWidth();
  2161. // if columnWidth is 0, default to outerWidth of first item
  2162. if ( !this.columnWidth ) {
  2163. var firstItem = this.items[0];
  2164. var firstItemElem = firstItem && firstItem.element;
  2165. // columnWidth fall back to item of first element
  2166. this.columnWidth = firstItemElem && getSize( firstItemElem ).outerWidth ||
  2167. // if first elem has no width, default to size of container
  2168. this.containerWidth;
  2169. }
  2170. var columnWidth = this.columnWidth += this.gutter;
  2171. // calculate columns
  2172. var containerWidth = this.containerWidth + this.gutter;
  2173. var cols = containerWidth / columnWidth;
  2174. // fix rounding errors, typically with gutters
  2175. var excess = columnWidth - containerWidth % columnWidth;
  2176. // if overshoot is less than a pixel, round up, otherwise floor it
  2177. var mathMethod = excess && excess < 1 ? 'round' : 'floor';
  2178. cols = Math[ mathMethod ]( cols );
  2179. this.cols = Math.max( cols, 1 );
  2180. };
  2181. proto.getContainerWidth = function() {
  2182. // container is parent if fit width
  2183. var isFitWidth = this._getOption('fitWidth');
  2184. var container = isFitWidth ? this.element.parentNode : this.element;
  2185. // check that this.size and size are there
  2186. // IE8 triggers resize on body size change, so they might not be
  2187. var size = getSize( container );
  2188. this.containerWidth = size && size.innerWidth;
  2189. };
  2190. proto._getItemLayoutPosition = function( item ) {
  2191. item.getSize();
  2192. // how many columns does this brick span
  2193. var remainder = item.size.outerWidth % this.columnWidth;
  2194. var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
  2195. // round if off by 1 pixel, otherwise use ceil
  2196. var colSpan = Math[ mathMethod ]( item.size.outerWidth / this.columnWidth );
  2197. colSpan = Math.min( colSpan, this.cols );
  2198. // use horizontal or top column position
  2199. var colPosMethod = this.options.horizontalOrder ?
  2200. '_getHorizontalColPosition' : '_getTopColPosition';
  2201. var colPosition = this[ colPosMethod ]( colSpan, item );
  2202. // position the brick
  2203. var position = {
  2204. x: this.columnWidth * colPosition.col,
  2205. y: colPosition.y
  2206. };
  2207. // apply setHeight to necessary columns
  2208. var setHeight = colPosition.y + item.size.outerHeight;
  2209. var setMax = colSpan + colPosition.col;
  2210. for ( var i = colPosition.col; i < setMax; i++ ) {
  2211. this.colYs[i] = setHeight;
  2212. }
  2213. return position;
  2214. };
  2215. proto._getTopColPosition = function( colSpan ) {
  2216. var colGroup = this._getTopColGroup( colSpan );
  2217. // get the minimum Y value from the columns
  2218. var minimumY = Math.min.apply( Math, colGroup );
  2219. return {
  2220. col: colGroup.indexOf( minimumY ),
  2221. y: minimumY,
  2222. };
  2223. };
  2224. /**
  2225. * @param {Number} colSpan - number of columns the element spans
  2226. * @returns {Array} colGroup
  2227. */
  2228. proto._getTopColGroup = function( colSpan ) {
  2229. if ( colSpan < 2 ) {
  2230. // if brick spans only one column, use all the column Ys
  2231. return this.colYs;
  2232. }
  2233. var colGroup = [];
  2234. // how many different places could this brick fit horizontally
  2235. var groupCount = this.cols + 1 - colSpan;
  2236. // for each group potential horizontal position
  2237. for ( var i = 0; i < groupCount; i++ ) {
  2238. colGroup[i] = this._getColGroupY( i, colSpan );
  2239. }
  2240. return colGroup;
  2241. };
  2242. proto._getColGroupY = function( col, colSpan ) {
  2243. if ( colSpan < 2 ) {
  2244. return this.colYs[ col ];
  2245. }
  2246. // make an array of colY values for that one group
  2247. var groupColYs = this.colYs.slice( col, col + colSpan );
  2248. // and get the max value of the array
  2249. return Math.max.apply( Math, groupColYs );
  2250. };
  2251. // get column position based on horizontal index. #873
  2252. proto._getHorizontalColPosition = function( colSpan, item ) {
  2253. var col = this.horizontalColIndex % this.cols;
  2254. var isOver = colSpan > 1 && col + colSpan > this.cols;
  2255. // shift to next row if item can't fit on current row
  2256. col = isOver ? 0 : col;
  2257. // don't let zero-size items take up space
  2258. var hasSize = item.size.outerWidth && item.size.outerHeight;
  2259. this.horizontalColIndex = hasSize ? col + colSpan : this.horizontalColIndex;
  2260. return {
  2261. col: col,
  2262. y: this._getColGroupY( col, colSpan ),
  2263. };
  2264. };
  2265. proto._manageStamp = function( stamp ) {
  2266. var stampSize = getSize( stamp );
  2267. var offset = this._getElementOffset( stamp );
  2268. // get the columns that this stamp affects
  2269. var isOriginLeft = this._getOption('originLeft');
  2270. var firstX = isOriginLeft ? offset.left : offset.right;
  2271. var lastX = firstX + stampSize.outerWidth;
  2272. var firstCol = Math.floor( firstX / this.columnWidth );
  2273. firstCol = Math.max( 0, firstCol );
  2274. var lastCol = Math.floor( lastX / this.columnWidth );
  2275. // lastCol should not go over if multiple of columnWidth #425
  2276. lastCol -= lastX % this.columnWidth ? 0 : 1;
  2277. lastCol = Math.min( this.cols - 1, lastCol );
  2278. // set colYs to bottom of the stamp
  2279. var isOriginTop = this._getOption('originTop');
  2280. var stampMaxY = ( isOriginTop ? offset.top : offset.bottom ) +
  2281. stampSize.outerHeight;
  2282. for ( var i = firstCol; i <= lastCol; i++ ) {
  2283. this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
  2284. }
  2285. };
  2286. proto._getContainerSize = function() {
  2287. this.maxY = Math.max.apply( Math, this.colYs );
  2288. var size = {
  2289. height: this.maxY
  2290. };
  2291. if ( this._getOption('fitWidth') ) {
  2292. size.width = this._getContainerFitWidth();
  2293. }
  2294. return size;
  2295. };
  2296. proto._getContainerFitWidth = function() {
  2297. var unusedCols = 0;
  2298. // count unused columns
  2299. var i = this.cols;
  2300. while ( --i ) {
  2301. if ( this.colYs[i] !== 0 ) {
  2302. break;
  2303. }
  2304. unusedCols++;
  2305. }
  2306. // fit container to columns that have been used
  2307. return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
  2308. };
  2309. proto.needsResizeLayout = function() {
  2310. var previousWidth = this.containerWidth;
  2311. this.getContainerWidth();
  2312. return previousWidth != this.containerWidth;
  2313. };
  2314. return Masonry;
  2315. }));
  2316. /*!
  2317. * Masonry layout mode
  2318. * sub-classes Masonry
  2319. * https://masonry.desandro.com
  2320. */
  2321. ( function( window, factory ) {
  2322. // universal module definition
  2323. /* jshint strict: false */ /*globals define, module, require */
  2324. if ( typeof define == 'function' && define.amd ) {
  2325. // AMD
  2326. define( 'isotope-layout/js/layout-modes/masonry',[
  2327. '../layout-mode',
  2328. 'masonry-layout/masonry'
  2329. ],
  2330. factory );
  2331. } else if ( typeof module == 'object' && module.exports ) {
  2332. // CommonJS
  2333. module.exports = factory(
  2334. require('../layout-mode'),
  2335. require('masonry-layout')
  2336. );
  2337. } else {
  2338. // browser global
  2339. factory(
  2340. window.Isotope.LayoutMode,
  2341. window.Masonry
  2342. );
  2343. }
  2344. }( window, function factory( LayoutMode, Masonry ) {
  2345. 'use strict';
  2346. // -------------------------- masonryDefinition -------------------------- //
  2347. // create an Outlayer layout class
  2348. var MasonryMode = LayoutMode.create('masonry');
  2349. var proto = MasonryMode.prototype;
  2350. var keepModeMethods = {
  2351. _getElementOffset: true,
  2352. layout: true,
  2353. _getMeasurement: true
  2354. };
  2355. // inherit Masonry prototype
  2356. for ( var method in Masonry.prototype ) {
  2357. // do not inherit mode methods
  2358. if ( !keepModeMethods[ method ] ) {
  2359. proto[ method ] = Masonry.prototype[ method ];
  2360. }
  2361. }
  2362. var measureColumns = proto.measureColumns;
  2363. proto.measureColumns = function() {
  2364. // set items, used if measuring first item
  2365. this.items = this.isotope.filteredItems;
  2366. measureColumns.call( this );
  2367. };
  2368. // point to mode options for fitWidth
  2369. var _getOption = proto._getOption;
  2370. proto._getOption = function( option ) {
  2371. if ( option == 'fitWidth' ) {
  2372. return this.options.isFitWidth !== undefined ?
  2373. this.options.isFitWidth : this.options.fitWidth;
  2374. }
  2375. return _getOption.apply( this.isotope, arguments );
  2376. };
  2377. return MasonryMode;
  2378. }));
  2379. /**
  2380. * fitRows layout mode
  2381. */
  2382. ( function( window, factory ) {
  2383. // universal module definition
  2384. /* jshint strict: false */ /*globals define, module, require */
  2385. if ( typeof define == 'function' && define.amd ) {
  2386. // AMD
  2387. define( 'isotope-layout/js/layout-modes/fit-rows',[
  2388. '../layout-mode'
  2389. ],
  2390. factory );
  2391. } else if ( typeof exports == 'object' ) {
  2392. // CommonJS
  2393. module.exports = factory(
  2394. require('../layout-mode')
  2395. );
  2396. } else {
  2397. // browser global
  2398. factory(
  2399. window.Isotope.LayoutMode
  2400. );
  2401. }
  2402. }( window, function factory( LayoutMode ) {
  2403. 'use strict';
  2404. var FitRows = LayoutMode.create('fitRows');
  2405. var proto = FitRows.prototype;
  2406. proto._resetLayout = function() {
  2407. this.x = 0;
  2408. this.y = 0;
  2409. this.maxY = 0;
  2410. this._getMeasurement( 'gutter', 'outerWidth' );
  2411. };
  2412. proto._getItemLayoutPosition = function( item ) {
  2413. item.getSize();
  2414. var itemWidth = item.size.outerWidth + this.gutter;
  2415. // if this element cannot fit in the current row
  2416. var containerWidth = this.isotope.size.innerWidth + this.gutter;
  2417. if ( this.x !== 0 && itemWidth + this.x > containerWidth ) {
  2418. this.x = 0;
  2419. this.y = this.maxY;
  2420. }
  2421. var position = {
  2422. x: this.x,
  2423. y: this.y
  2424. };
  2425. this.maxY = Math.max( this.maxY, this.y + item.size.outerHeight );
  2426. this.x += itemWidth;
  2427. return position;
  2428. };
  2429. proto._getContainerSize = function() {
  2430. return { height: this.maxY };
  2431. };
  2432. return FitRows;
  2433. }));
  2434. /**
  2435. * vertical layout mode
  2436. */
  2437. ( function( window, factory ) {
  2438. // universal module definition
  2439. /* jshint strict: false */ /*globals define, module, require */
  2440. if ( typeof define == 'function' && define.amd ) {
  2441. // AMD
  2442. define( 'isotope-layout/js/layout-modes/vertical',[
  2443. '../layout-mode'
  2444. ],
  2445. factory );
  2446. } else if ( typeof module == 'object' && module.exports ) {
  2447. // CommonJS
  2448. module.exports = factory(
  2449. require('../layout-mode')
  2450. );
  2451. } else {
  2452. // browser global
  2453. factory(
  2454. window.Isotope.LayoutMode
  2455. );
  2456. }
  2457. }( window, function factory( LayoutMode ) {
  2458. 'use strict';
  2459. var Vertical = LayoutMode.create( 'vertical', {
  2460. horizontalAlignment: 0
  2461. });
  2462. var proto = Vertical.prototype;
  2463. proto._resetLayout = function() {
  2464. this.y = 0;
  2465. };
  2466. proto._getItemLayoutPosition = function( item ) {
  2467. item.getSize();
  2468. var x = ( this.isotope.size.innerWidth - item.size.outerWidth ) *
  2469. this.options.horizontalAlignment;
  2470. var y = this.y;
  2471. this.y += item.size.outerHeight;
  2472. return { x: x, y: y };
  2473. };
  2474. proto._getContainerSize = function() {
  2475. return { height: this.y };
  2476. };
  2477. return Vertical;
  2478. }));
  2479. /*!
  2480. * Isotope v3.0.6
  2481. *
  2482. * Licensed GPLv3 for open source use
  2483. * or Isotope Commercial License for commercial use
  2484. *
  2485. * https://isotope.metafizzy.co
  2486. * Copyright 2010-2018 Metafizzy
  2487. */
  2488. ( function( window, factory ) {
  2489. // universal module definition
  2490. /* jshint strict: false */ /*globals define, module, require */
  2491. if ( typeof define == 'function' && define.amd ) {
  2492. // AMD
  2493. define( [
  2494. 'outlayer/outlayer',
  2495. 'get-size/get-size',
  2496. 'desandro-matches-selector/matches-selector',
  2497. 'fizzy-ui-utils/utils',
  2498. 'isotope-layout/js/item',
  2499. 'isotope-layout/js/layout-mode',
  2500. // include default layout modes
  2501. 'isotope-layout/js/layout-modes/masonry',
  2502. 'isotope-layout/js/layout-modes/fit-rows',
  2503. 'isotope-layout/js/layout-modes/vertical'
  2504. ],
  2505. function( Outlayer, getSize, matchesSelector, utils, Item, LayoutMode ) {
  2506. return factory( window, Outlayer, getSize, matchesSelector, utils, Item, LayoutMode );
  2507. });
  2508. } else if ( typeof module == 'object' && module.exports ) {
  2509. // CommonJS
  2510. module.exports = factory(
  2511. window,
  2512. require('outlayer'),
  2513. require('get-size'),
  2514. require('desandro-matches-selector'),
  2515. require('fizzy-ui-utils'),
  2516. require('isotope-layout/js/item'),
  2517. require('isotope-layout/js/layout-mode'),
  2518. // include default layout modes
  2519. require('isotope-layout/js/layout-modes/masonry'),
  2520. require('isotope-layout/js/layout-modes/fit-rows'),
  2521. require('isotope-layout/js/layout-modes/vertical')
  2522. );
  2523. } else {
  2524. // browser global
  2525. window.Isotope = factory(
  2526. window,
  2527. window.Outlayer,
  2528. window.getSize,
  2529. window.matchesSelector,
  2530. window.fizzyUIUtils,
  2531. window.Isotope.Item,
  2532. window.Isotope.LayoutMode
  2533. );
  2534. }
  2535. }( window, function factory( window, Outlayer, getSize, matchesSelector, utils,
  2536. Item, LayoutMode ) {
  2537. // -------------------------- vars -------------------------- //
  2538. var jQuery = window.jQuery;
  2539. // -------------------------- helpers -------------------------- //
  2540. var trim = String.prototype.trim ?
  2541. function( str ) {
  2542. return str.trim();
  2543. } :
  2544. function( str ) {
  2545. return str.replace( /^\s+|\s+$/g, '' );
  2546. };
  2547. // -------------------------- isotopeDefinition -------------------------- //
  2548. // create an Outlayer layout class
  2549. var Isotope = Outlayer.create( 'isotope', {
  2550. layoutMode: 'masonry',
  2551. isJQueryFiltering: true,
  2552. sortAscending: true
  2553. });
  2554. Isotope.Item = Item;
  2555. Isotope.LayoutMode = LayoutMode;
  2556. var proto = Isotope.prototype;
  2557. proto._create = function() {
  2558. this.itemGUID = 0;
  2559. // functions that sort items
  2560. this._sorters = {};
  2561. this._getSorters();
  2562. // call super
  2563. Outlayer.prototype._create.call( this );
  2564. // create layout modes
  2565. this.modes = {};
  2566. // start filteredItems with all items
  2567. this.filteredItems = this.items;
  2568. // keep of track of sortBys
  2569. this.sortHistory = [ 'original-order' ];
  2570. // create from registered layout modes
  2571. for ( var name in LayoutMode.modes ) {
  2572. this._initLayoutMode( name );
  2573. }
  2574. };
  2575. proto.reloadItems = function() {
  2576. // reset item ID counter
  2577. this.itemGUID = 0;
  2578. // call super
  2579. Outlayer.prototype.reloadItems.call( this );
  2580. };
  2581. proto._itemize = function() {
  2582. var items = Outlayer.prototype._itemize.apply( this, arguments );
  2583. // assign ID for original-order
  2584. for ( var i=0; i < items.length; i++ ) {
  2585. var item = items[i];
  2586. item.id = this.itemGUID++;
  2587. }
  2588. this._updateItemsSortData( items );
  2589. return items;
  2590. };
  2591. // -------------------------- layout -------------------------- //
  2592. proto._initLayoutMode = function( name ) {
  2593. var Mode = LayoutMode.modes[ name ];
  2594. // set mode options
  2595. // HACK extend initial options, back-fill in default options
  2596. var initialOpts = this.options[ name ] || {};
  2597. this.options[ name ] = Mode.options ?
  2598. utils.extend( Mode.options, initialOpts ) : initialOpts;
  2599. // init layout mode instance
  2600. this.modes[ name ] = new Mode( this );
  2601. };
  2602. proto.layout = function() {
  2603. // if first time doing layout, do all magic
  2604. if ( !this._isLayoutInited && this._getOption('initLayout') ) {
  2605. this.arrange();
  2606. return;
  2607. }
  2608. this._layout();
  2609. };
  2610. // private method to be used in layout() & magic()
  2611. proto._layout = function() {
  2612. // don't animate first layout
  2613. var isInstant = this._getIsInstant();
  2614. // layout flow
  2615. this._resetLayout();
  2616. this._manageStamps();
  2617. this.layoutItems( this.filteredItems, isInstant );
  2618. // flag for initalized
  2619. this._isLayoutInited = true;
  2620. };
  2621. // filter + sort + layout
  2622. proto.arrange = function( opts ) {
  2623. // set any options pass
  2624. this.option( opts );
  2625. this._getIsInstant();
  2626. // filter, sort, and layout
  2627. // filter
  2628. var filtered = this._filter( this.items );
  2629. this.filteredItems = filtered.matches;
  2630. this._bindArrangeComplete();
  2631. if ( this._isInstant ) {
  2632. this._noTransition( this._hideReveal, [ filtered ] );
  2633. } else {
  2634. this._hideReveal( filtered );
  2635. }
  2636. this._sort();
  2637. this._layout();
  2638. };
  2639. // alias to _init for main plugin method
  2640. proto._init = proto.arrange;
  2641. proto._hideReveal = function( filtered ) {
  2642. this.reveal( filtered.needReveal );
  2643. this.hide( filtered.needHide );
  2644. };
  2645. // HACK
  2646. // Don't animate/transition first layout
  2647. // Or don't animate/transition other layouts
  2648. proto._getIsInstant = function() {
  2649. var isLayoutInstant = this._getOption('layoutInstant');
  2650. var isInstant = isLayoutInstant !== undefined ? isLayoutInstant :
  2651. !this._isLayoutInited;
  2652. this._isInstant = isInstant;
  2653. return isInstant;
  2654. };
  2655. // listen for layoutComplete, hideComplete and revealComplete
  2656. // to trigger arrangeComplete
  2657. proto._bindArrangeComplete = function() {
  2658. // listen for 3 events to trigger arrangeComplete
  2659. var isLayoutComplete, isHideComplete, isRevealComplete;
  2660. var _this = this;
  2661. function arrangeParallelCallback() {
  2662. if ( isLayoutComplete && isHideComplete && isRevealComplete ) {
  2663. _this.dispatchEvent( 'arrangeComplete', null, [ _this.filteredItems ] );
  2664. }
  2665. }
  2666. this.once( 'layoutComplete', function() {
  2667. isLayoutComplete = true;
  2668. arrangeParallelCallback();
  2669. });
  2670. this.once( 'hideComplete', function() {
  2671. isHideComplete = true;
  2672. arrangeParallelCallback();
  2673. });
  2674. this.once( 'revealComplete', function() {
  2675. isRevealComplete = true;
  2676. arrangeParallelCallback();
  2677. });
  2678. };
  2679. // -------------------------- filter -------------------------- //
  2680. proto._filter = function( items ) {
  2681. var filter = this.options.filter;
  2682. filter = filter || '*';
  2683. var matches = [];
  2684. var hiddenMatched = [];
  2685. var visibleUnmatched = [];
  2686. var test = this._getFilterTest( filter );
  2687. // test each item
  2688. for ( var i=0; i < items.length; i++ ) {
  2689. var item = items[i];
  2690. if ( item.isIgnored ) {
  2691. continue;
  2692. }
  2693. // add item to either matched or unmatched group
  2694. var isMatched = test( item );
  2695. // item.isFilterMatched = isMatched;
  2696. // add to matches if its a match
  2697. if ( isMatched ) {
  2698. matches.push( item );
  2699. }
  2700. // add to additional group if item needs to be hidden or revealed
  2701. if ( isMatched && item.isHidden ) {
  2702. hiddenMatched.push( item );
  2703. } else if ( !isMatched && !item.isHidden ) {
  2704. visibleUnmatched.push( item );
  2705. }
  2706. }
  2707. // return collections of items to be manipulated
  2708. return {
  2709. matches: matches,
  2710. needReveal: hiddenMatched,
  2711. needHide: visibleUnmatched
  2712. };
  2713. };
  2714. // get a jQuery, function, or a matchesSelector test given the filter
  2715. proto._getFilterTest = function( filter ) {
  2716. if ( jQuery && this.options.isJQueryFiltering ) {
  2717. // use jQuery
  2718. return function( item ) {
  2719. return jQuery( item.element ).is( filter );
  2720. };
  2721. }
  2722. if ( typeof filter == 'function' ) {
  2723. // use filter as function
  2724. return function( item ) {
  2725. return filter( item.element );
  2726. };
  2727. }
  2728. // default, use filter as selector string
  2729. return function( item ) {
  2730. return matchesSelector( item.element, filter );
  2731. };
  2732. };
  2733. // -------------------------- sorting -------------------------- //
  2734. /**
  2735. * @params {Array} elems
  2736. * @public
  2737. */
  2738. proto.updateSortData = function( elems ) {
  2739. // get items
  2740. var items;
  2741. if ( elems ) {
  2742. elems = utils.makeArray( elems );
  2743. items = this.getItems( elems );
  2744. } else {
  2745. // update all items if no elems provided
  2746. items = this.items;
  2747. }
  2748. this._getSorters();
  2749. this._updateItemsSortData( items );
  2750. };
  2751. proto._getSorters = function() {
  2752. var getSortData = this.options.getSortData;
  2753. for ( var key in getSortData ) {
  2754. var sorter = getSortData[ key ];
  2755. this._sorters[ key ] = mungeSorter( sorter );
  2756. }
  2757. };
  2758. /**
  2759. * @params {Array} items - of Isotope.Items
  2760. * @private
  2761. */
  2762. proto._updateItemsSortData = function( items ) {
  2763. // do not update if no items
  2764. var len = items && items.length;
  2765. for ( var i=0; len && i < len; i++ ) {
  2766. var item = items[i];
  2767. item.updateSortData();
  2768. }
  2769. };
  2770. // ----- munge sorter ----- //
  2771. // encapsulate this, as we just need mungeSorter
  2772. // other functions in here are just for munging
  2773. var mungeSorter = ( function() {
  2774. // add a magic layer to sorters for convienent shorthands
  2775. // `.foo-bar` will use the text of .foo-bar querySelector
  2776. // `[foo-bar]` will use attribute
  2777. // you can also add parser
  2778. // `.foo-bar parseInt` will parse that as a number
  2779. function mungeSorter( sorter ) {
  2780. // if not a string, return function or whatever it is
  2781. if ( typeof sorter != 'string' ) {
  2782. return sorter;
  2783. }
  2784. // parse the sorter string
  2785. var args = trim( sorter ).split(' ');
  2786. var query = args[0];
  2787. // check if query looks like [an-attribute]
  2788. var attrMatch = query.match( /^\[(.+)\]$/ );
  2789. var attr = attrMatch && attrMatch[1];
  2790. var getValue = getValueGetter( attr, query );
  2791. // use second argument as a parser
  2792. var parser = Isotope.sortDataParsers[ args[1] ];
  2793. // parse the value, if there was a parser
  2794. sorter = parser ? function( elem ) {
  2795. return elem && parser( getValue( elem ) );
  2796. } :
  2797. // otherwise just return value
  2798. function( elem ) {
  2799. return elem && getValue( elem );
  2800. };
  2801. return sorter;
  2802. }
  2803. // get an attribute getter, or get text of the querySelector
  2804. function getValueGetter( attr, query ) {
  2805. // if query looks like [foo-bar], get attribute
  2806. if ( attr ) {
  2807. return function getAttribute( elem ) {
  2808. return elem.getAttribute( attr );
  2809. };
  2810. }
  2811. // otherwise, assume its a querySelector, and get its text
  2812. return function getChildText( elem ) {
  2813. var child = elem.querySelector( query );
  2814. return child && child.textContent;
  2815. };
  2816. }
  2817. return mungeSorter;
  2818. })();
  2819. // parsers used in getSortData shortcut strings
  2820. Isotope.sortDataParsers = {
  2821. 'parseInt': function( val ) {
  2822. return parseInt( val, 10 );
  2823. },
  2824. 'parseFloat': function( val ) {
  2825. return parseFloat( val );
  2826. }
  2827. };
  2828. // ----- sort method ----- //
  2829. // sort filteredItem order
  2830. proto._sort = function() {
  2831. if ( !this.options.sortBy ) {
  2832. return;
  2833. }
  2834. // keep track of sortBy History
  2835. var sortBys = utils.makeArray( this.options.sortBy );
  2836. if ( !this._getIsSameSortBy( sortBys ) ) {
  2837. // concat all sortBy and sortHistory, add to front, oldest goes in last
  2838. this.sortHistory = sortBys.concat( this.sortHistory );
  2839. }
  2840. // sort magic
  2841. var itemSorter = getItemSorter( this.sortHistory, this.options.sortAscending );
  2842. this.filteredItems.sort( itemSorter );
  2843. };
  2844. // check if sortBys is same as start of sortHistory
  2845. proto._getIsSameSortBy = function( sortBys ) {
  2846. for ( var i=0; i < sortBys.length; i++ ) {
  2847. if ( sortBys[i] != this.sortHistory[i] ) {
  2848. return false;
  2849. }
  2850. }
  2851. return true;
  2852. };
  2853. // returns a function used for sorting
  2854. function getItemSorter( sortBys, sortAsc ) {
  2855. return function sorter( itemA, itemB ) {
  2856. // cycle through all sortKeys
  2857. for ( var i = 0; i < sortBys.length; i++ ) {
  2858. var sortBy = sortBys[i];
  2859. var a = itemA.sortData[ sortBy ];
  2860. var b = itemB.sortData[ sortBy ];
  2861. if ( a > b || a < b ) {
  2862. // if sortAsc is an object, use the value given the sortBy key
  2863. var isAscending = sortAsc[ sortBy ] !== undefined ? sortAsc[ sortBy ] : sortAsc;
  2864. var direction = isAscending ? 1 : -1;
  2865. return ( a > b ? 1 : -1 ) * direction;
  2866. }
  2867. }
  2868. return 0;
  2869. };
  2870. }
  2871. // -------------------------- methods -------------------------- //
  2872. // get layout mode
  2873. proto._mode = function() {
  2874. var layoutMode = this.options.layoutMode;
  2875. var mode = this.modes[ layoutMode ];
  2876. if ( !mode ) {
  2877. // TODO console.error
  2878. throw new Error( 'No layout mode: ' + layoutMode );
  2879. }
  2880. // HACK sync mode's options
  2881. // any options set after init for layout mode need to be synced
  2882. mode.options = this.options[ layoutMode ];
  2883. return mode;
  2884. };
  2885. proto._resetLayout = function() {
  2886. // trigger original reset layout
  2887. Outlayer.prototype._resetLayout.call( this );
  2888. this._mode()._resetLayout();
  2889. };
  2890. proto._getItemLayoutPosition = function( item ) {
  2891. return this._mode()._getItemLayoutPosition( item );
  2892. };
  2893. proto._manageStamp = function( stamp ) {
  2894. this._mode()._manageStamp( stamp );
  2895. };
  2896. proto._getContainerSize = function() {
  2897. return this._mode()._getContainerSize();
  2898. };
  2899. proto.needsResizeLayout = function() {
  2900. return this._mode().needsResizeLayout();
  2901. };
  2902. // -------------------------- adding & removing -------------------------- //
  2903. // HEADS UP overwrites default Outlayer appended
  2904. proto.appended = function( elems ) {
  2905. var items = this.addItems( elems );
  2906. if ( !items.length ) {
  2907. return;
  2908. }
  2909. // filter, layout, reveal new items
  2910. var filteredItems = this._filterRevealAdded( items );
  2911. // add to filteredItems
  2912. this.filteredItems = this.filteredItems.concat( filteredItems );
  2913. };
  2914. // HEADS UP overwrites default Outlayer prepended
  2915. proto.prepended = function( elems ) {
  2916. var items = this._itemize( elems );
  2917. if ( !items.length ) {
  2918. return;
  2919. }
  2920. // start new layout
  2921. this._resetLayout();
  2922. this._manageStamps();
  2923. // filter, layout, reveal new items
  2924. var filteredItems = this._filterRevealAdded( items );
  2925. // layout previous items
  2926. this.layoutItems( this.filteredItems );
  2927. // add to items and filteredItems
  2928. this.filteredItems = filteredItems.concat( this.filteredItems );
  2929. this.items = items.concat( this.items );
  2930. };
  2931. proto._filterRevealAdded = function( items ) {
  2932. var filtered = this._filter( items );
  2933. this.hide( filtered.needHide );
  2934. // reveal all new items
  2935. this.reveal( filtered.matches );
  2936. // layout new items, no transition
  2937. this.layoutItems( filtered.matches, true );
  2938. return filtered.matches;
  2939. };
  2940. /**
  2941. * Filter, sort, and layout newly-appended item elements
  2942. * @param {Array or NodeList or Element} elems
  2943. */
  2944. proto.insert = function( elems ) {
  2945. var items = this.addItems( elems );
  2946. if ( !items.length ) {
  2947. return;
  2948. }
  2949. // append item elements
  2950. var i, item;
  2951. var len = items.length;
  2952. for ( i=0; i < len; i++ ) {
  2953. item = items[i];
  2954. this.element.appendChild( item.element );
  2955. }
  2956. // filter new stuff
  2957. var filteredInsertItems = this._filter( items ).matches;
  2958. // set flag
  2959. for ( i=0; i < len; i++ ) {
  2960. items[i].isLayoutInstant = true;
  2961. }
  2962. this.arrange();
  2963. // reset flag
  2964. for ( i=0; i < len; i++ ) {
  2965. delete items[i].isLayoutInstant;
  2966. }
  2967. this.reveal( filteredInsertItems );
  2968. };
  2969. var _remove = proto.remove;
  2970. proto.remove = function( elems ) {
  2971. elems = utils.makeArray( elems );
  2972. var removeItems = this.getItems( elems );
  2973. // do regular thing
  2974. _remove.call( this, elems );
  2975. // bail if no items to remove
  2976. var len = removeItems && removeItems.length;
  2977. // remove elems from filteredItems
  2978. for ( var i=0; len && i < len; i++ ) {
  2979. var item = removeItems[i];
  2980. // remove item from collection
  2981. utils.removeFrom( this.filteredItems, item );
  2982. }
  2983. };
  2984. proto.shuffle = function() {
  2985. // update random sortData
  2986. for ( var i=0; i < this.items.length; i++ ) {
  2987. var item = this.items[i];
  2988. item.sortData.random = Math.random();
  2989. }
  2990. this.options.sortBy = 'random';
  2991. this._sort();
  2992. this._layout();
  2993. };
  2994. /**
  2995. * trigger fn without transition
  2996. * kind of hacky to have this in the first place
  2997. * @param {Function} fn
  2998. * @param {Array} args
  2999. * @returns ret
  3000. * @private
  3001. */
  3002. proto._noTransition = function( fn, args ) {
  3003. // save transitionDuration before disabling
  3004. var transitionDuration = this.options.transitionDuration;
  3005. // disable transition
  3006. this.options.transitionDuration = 0;
  3007. // do it
  3008. var returnValue = fn.apply( this, args );
  3009. // re-enable transition for reveal
  3010. this.options.transitionDuration = transitionDuration;
  3011. return returnValue;
  3012. };
  3013. // ----- helper methods ----- //
  3014. /**
  3015. * getter method for getting filtered item elements
  3016. * @returns {Array} elems - collection of item elements
  3017. */
  3018. proto.getFilteredItemElements = function() {
  3019. return this.filteredItems.map( function( item ) {
  3020. return item.element;
  3021. });
  3022. };
  3023. // ----- ----- //
  3024. return Isotope;
  3025. }));