isotope.pkgd.js 89 KB

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