category-rows.html 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>Category rows &middot; Isotope </title>
  6. <!--[if lt IE 9]><script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
  7. <link rel="stylesheet" href="../css/style.css" />
  8. <!-- scripts at bottom of page -->
  9. </head>
  10. <body class="custom-layout-modes ">
  11. <nav id="site-nav">
  12. <h1><a href="../index.html">Isotope</a></h1>
  13. <h2>Docs</h2>
  14. <ul>
  15. <li><a href="../docs/introduction.html">Introduction</a>
  16. <li><a href="../docs/options.html">Options</a>
  17. <li><a href="../docs/methods.html">Methods</a>
  18. <li><a href="../docs/layout-modes.html">Layout modes</a>
  19. <li><a href="../docs/filtering.html">Filtering</a>
  20. <li><a href="../docs/sorting.html">Sorting</a>
  21. <li><a href="../docs/animating.html">Animating</a>
  22. <li><a href="../docs/adding-items.html">Adding items</a>
  23. <li><a href="../docs/extending-isotope.html">Extending Isotope</a>
  24. <li><a href="../docs/hash-history-jquery-bbq.html">Hash history with jQuery BBQ</a>
  25. <li><a href="../docs/help.html">Help</a>
  26. <li><a href="../docs/license.html">License</a>
  27. </ul>
  28. <h2>Demos</h2>
  29. <ul>
  30. <li><a href="../demos/basic.html">Basic</a>
  31. <li><a href="../demos/elements-complete.html">Elements Complete</a>
  32. <li><a href="../demos/elements-partial.html">Elements Partial</a>
  33. <li><a href="../demos/layout-modes.html">Layout modes</a>
  34. <li><a href="../demos/filtering.html">Filtering</a>
  35. <li><a href="../demos/sorting.html">Sorting</a>
  36. <li><a href="../demos/relayout.html">reLayout</a>
  37. <li><a href="../demos/adding-items.html">Adding items</a>
  38. <li><a href="../demos/infinite-scroll.html">Infinite Scroll</a>
  39. <li><a href="../demos/images.html">Images</a>
  40. <li><a href="../demos/combination-filters.html">Combination filters</a>
  41. <li><a href="../demos/hash-history.html">Hash history</a>
  42. <li><a href="../demos/fluid-responsive.html">Fluid / responsive</a>
  43. </ul>
  44. <h2>Custom layout modes</h2>
  45. <ul>
  46. <li><a href="../custom-layout-modes/centered-masonry.html">Centered Masonry</a>
  47. <li class="current"><a href="#content">Category rows</a></li>
  48. <li><a href="../custom-layout-modes/masonry-corner-stamp.html">Masonry corner stamp</a>
  49. <li><a href="../custom-layout-modes/masonry-gutters.html">Masonry gutters</a>
  50. <li><a href="../custom-layout-modes/spine-align.html">Spine align</a>
  51. </ul>
  52. <h2><a href="../tests/index.html">Tests</a></h2>
  53. </nav> <!-- #site-nav -->
  54. <section id="content">
  55. <h1>Category rows</h1>
  56. <section id="copy">
  57. <p>This demo uses a <a href="../docs/extending-isotope.html">custom layout mode</a>, <code>categoryRows</code> that arranges elements into rows based on their category. The layout mode logic relies on sorting to define rows.</p>
  58. </section>
  59. <section id="options" class="clearfix">
  60. <h3>Filters</h3>
  61. <ul id="filters" class="option-set clearfix" data-option-key="filter">
  62. <li><a href="#filter" data-option-value="*" class="selected">show all</a></li>
  63. <li><a href="#filter" data-option-value=".metal">metal</a></li>
  64. <li><a href="#filter" data-option-value=".transition">transition</a></li>
  65. <li><a href="#filter" data-option-value=".post-transition">post-transition</a></li>
  66. <li><a href="#filter" data-option-value=".nonmetal">nonmetal</a></li>
  67. <li><a href="#filter" data-option-value=".inner-transition">inner-transition</a></li>
  68. <li><a href="#filter" data-option-value=".alkali, .alkaline-earth">alkali and alkaline-earth</a></li>
  69. <li><a href="#filter" data-option-value=":not(.transition)">not transition</a></li>
  70. <li><a href="#filter" data-option-value=".metal:not(.transition)">metal but not transition</a></li>
  71. </ul>
  72. <h3>Etc</h3>
  73. <ul id="etc" class="clearfix">
  74. <li id="toggle-sizes"><a href="#toggle-sizes">Toggle variable sizes</a></li>
  75. <li id="insert"><a href="#insert">Insert new elements</a></li>
  76. </ul>
  77. </section> <!-- #options -->
  78. <div id="container" class="clearfix">
  79. <div class="element alkaline-earth metal " data-symbol="Mg" data-category="alkaline-earth">
  80. <p class="number">12</p>
  81. <h3 class="symbol">Mg</h3>
  82. <h2 class="name">Magnesium</h2>
  83. <p class="weight">24.305</p>
  84. </div>
  85. <div class="element actinoid metal inner-transition " data-symbol="U" data-category="actinoid">
  86. <p class="number">92</p>
  87. <h3 class="symbol">U</h3>
  88. <h2 class="name">Uranium</h2>
  89. <p class="weight">238.02891</p>
  90. </div>
  91. <div class="element lanthanoid metal inner-transition " data-symbol="Gd" data-category="lanthanoid">
  92. <p class="number">64</p>
  93. <h3 class="symbol">Gd</h3>
  94. <h2 class="name">Gadolinium</h2>
  95. <p class="weight">157.25</p>
  96. </div>
  97. <div class="element transition metal " data-symbol="Y" data-category="transition">
  98. <p class="number">39</p>
  99. <h3 class="symbol">Y</h3>
  100. <h2 class="name">Yttrium</h2>
  101. <p class="weight">88.90585</p>
  102. </div>
  103. <div class="element metalloid " data-symbol="B" data-category="metalloid">
  104. <p class="number">5</p>
  105. <h3 class="symbol">B</h3>
  106. <h2 class="name">Boron</h2>
  107. <p class="weight">10.811</p>
  108. </div>
  109. <div class="element transition metal " data-symbol="Fe" data-category="transition">
  110. <p class="number">26</p>
  111. <h3 class="symbol">Fe</h3>
  112. <h2 class="name">Iron</h2>
  113. <p class="weight">55.845</p>
  114. </div>
  115. <div class="element actinoid metal inner-transition " data-symbol="Am" data-category="actinoid">
  116. <p class="number">95</p>
  117. <h3 class="symbol">Am</h3>
  118. <h2 class="name">Americium</h2>
  119. <p class="weight">(243)</p>
  120. </div>
  121. <div class="element transition metal " data-symbol="Zn" data-category="transition">
  122. <p class="number">30</p>
  123. <h3 class="symbol">Zn</h3>
  124. <h2 class="name">Zinc</h2>
  125. <p class="weight">65.38</p>
  126. </div>
  127. <div class="element lanthanoid metal inner-transition " data-symbol="Pm" data-category="lanthanoid">
  128. <p class="number">61</p>
  129. <h3 class="symbol">Pm</h3>
  130. <h2 class="name">Promethium</h2>
  131. <p class="weight">(145)</p>
  132. </div>
  133. <div class="element post-transition metal " data-symbol="In" data-category="post-transition">
  134. <p class="number">49</p>
  135. <h3 class="symbol">In</h3>
  136. <h2 class="name">Indium</h2>
  137. <p class="weight">114.818</p>
  138. </div>
  139. <div class="element metalloid " data-symbol="As" data-category="metalloid">
  140. <p class="number">33</p>
  141. <h3 class="symbol">As</h3>
  142. <h2 class="name">Arsenic</h2>
  143. <p class="weight">74.9216</p>
  144. </div>
  145. <div class="element lanthanoid metal inner-transition " data-symbol="Er" data-category="lanthanoid">
  146. <p class="number">68</p>
  147. <h3 class="symbol">Er</h3>
  148. <h2 class="name">Erbium</h2>
  149. <p class="weight">167.259</p>
  150. </div>
  151. <div class="element other nonmetal " data-symbol="Se" data-category="other">
  152. <p class="number">34</p>
  153. <h3 class="symbol">Se</h3>
  154. <h2 class="name">Selenium</h2>
  155. <p class="weight">78.96</p>
  156. </div>
  157. <div class="element alkaline-earth metal " data-symbol="Sr" data-category="alkaline-earth">
  158. <p class="number">38</p>
  159. <h3 class="symbol">Sr</h3>
  160. <h2 class="name">Strontium</h2>
  161. <p class="weight">87.62</p>
  162. </div>
  163. <div class="element transition metal " data-symbol="Zr" data-category="transition">
  164. <p class="number">40</p>
  165. <h3 class="symbol">Zr</h3>
  166. <h2 class="name">Zirconium</h2>
  167. <p class="weight">91.224</p>
  168. </div>
  169. <div class="element halogen nonmetal " data-symbol="At" data-category="halogen">
  170. <p class="number">85</p>
  171. <h3 class="symbol">At</h3>
  172. <h2 class="name">Astatine</h2>
  173. <p class="weight">(210)</p>
  174. </div>
  175. <div class="element transition metal " data-symbol="Nb" data-category="transition">
  176. <p class="number">41</p>
  177. <h3 class="symbol">Nb</h3>
  178. <h2 class="name">Niobium</h2>
  179. <p class="weight">92.90638</p>
  180. </div>
  181. <div class="element other nonmetal " data-symbol="O" data-category="other">
  182. <p class="number">8</p>
  183. <h3 class="symbol">O</h3>
  184. <h2 class="name">Oxygen</h2>
  185. <p class="weight">15.9994</p>
  186. </div>
  187. <div class="element actinoid metal inner-transition " data-symbol="Bk" data-category="actinoid">
  188. <p class="number">97</p>
  189. <h3 class="symbol">Bk</h3>
  190. <h2 class="name">Berkelium</h2>
  191. <p class="weight">(247)</p>
  192. </div>
  193. <div class="element halogen nonmetal " data-symbol="F" data-category="halogen">
  194. <p class="number">9</p>
  195. <h3 class="symbol">F</h3>
  196. <h2 class="name">Fluorine</h2>
  197. <p class="weight">18.9984032</p>
  198. </div>
  199. <div class="element actinoid metal inner-transition " data-symbol="Cf" data-category="actinoid">
  200. <p class="number">98</p>
  201. <h3 class="symbol">Cf</h3>
  202. <h2 class="name">Californium</h2>
  203. <p class="weight">(251)</p>
  204. </div>
  205. <div class="element noble-gas nonmetal " data-symbol="Ne" data-category="noble-gas">
  206. <p class="number">10</p>
  207. <h3 class="symbol">Ne</h3>
  208. <h2 class="name">Neon</h2>
  209. <p class="weight">20.1797</p>
  210. </div>
  211. <div class="element other nonmetal " data-symbol="P" data-category="other">
  212. <p class="number">15</p>
  213. <h3 class="symbol">P</h3>
  214. <h2 class="name">Phosphorus</h2>
  215. <p class="weight">30.973762</p>
  216. </div>
  217. <div class="element actinoid metal inner-transition " data-symbol="Fm" data-category="actinoid">
  218. <p class="number">100</p>
  219. <h3 class="symbol">Fm</h3>
  220. <h2 class="name">Fermium</h2>
  221. <p class="weight">(257)</p>
  222. </div>
  223. <div class="element other nonmetal " data-symbol="S" data-category="other">
  224. <p class="number">16</p>
  225. <h3 class="symbol">S</h3>
  226. <h2 class="name">Sulfur</h2>
  227. <p class="weight">32.065</p>
  228. </div>
  229. <div class="element alkaline-earth metal " data-symbol="Ca" data-category="alkaline-earth">
  230. <p class="number">20</p>
  231. <h3 class="symbol">Ca</h3>
  232. <h2 class="name">Calcium</h2>
  233. <p class="weight">40.078</p>
  234. </div>
  235. <div class="element other nonmetal " data-symbol="C" data-category="other">
  236. <p class="number">6</p>
  237. <h3 class="symbol">C</h3>
  238. <h2 class="name">Carbon</h2>
  239. <p class="weight">12.0107</p>
  240. </div>
  241. <div class="element alkali metal " data-symbol="Rb" data-category="alkali">
  242. <p class="number">37</p>
  243. <h3 class="symbol">Rb</h3>
  244. <h2 class="name">Rubidium</h2>
  245. <p class="weight">85.4678</p>
  246. </div>
  247. <div class="element post-transition metal " data-symbol="Uup" data-category="post-transition">
  248. <p class="number">115</p>
  249. <h3 class="symbol">Uup</h3>
  250. <h2 class="name">Ununpentium</h2>
  251. <p class="weight">(288)</p>
  252. </div>
  253. <div class="element transition metal " data-symbol="Sc" data-category="transition">
  254. <p class="number">21</p>
  255. <h3 class="symbol">Sc</h3>
  256. <h2 class="name">Scandium</h2>
  257. <p class="weight">44.955912</p>
  258. </div>
  259. <div class="element post-transition metal " data-symbol="Ga" data-category="post-transition">
  260. <p class="number">31</p>
  261. <h3 class="symbol">Ga</h3>
  262. <h2 class="name">Gallium</h2>
  263. <p class="weight">69.723</p>
  264. </div>
  265. <div class="element post-transition metal " data-symbol="Tl" data-category="post-transition">
  266. <p class="number">81</p>
  267. <h3 class="symbol">Tl</h3>
  268. <h2 class="name">Thallium</h2>
  269. <p class="weight">204.3833</p>
  270. </div>
  271. <div class="element metalloid " data-symbol="Si" data-category="metalloid">
  272. <p class="number">14</p>
  273. <h3 class="symbol">Si</h3>
  274. <h2 class="name">Silicon</h2>
  275. <p class="weight">28.0855</p>
  276. </div>
  277. <div class="element transition metal " data-symbol="Cd" data-category="transition">
  278. <p class="number">48</p>
  279. <h3 class="symbol">Cd</h3>
  280. <h2 class="name">Cadmium</h2>
  281. <p class="weight">112.411</p>
  282. </div>
  283. <div class="element transition metal " data-symbol="Ti" data-category="transition">
  284. <p class="number">22</p>
  285. <h3 class="symbol">Ti</h3>
  286. <h2 class="name">Titanium</h2>
  287. <p class="weight">47.867</p>
  288. </div>
  289. <div class="element alkaline-earth metal " data-symbol="Be" data-category="alkaline-earth">
  290. <p class="number">4</p>
  291. <h3 class="symbol">Be</h3>
  292. <h2 class="name">Beryllium</h2>
  293. <p class="weight">9.012182</p>
  294. </div>
  295. <div class="element transition metal " data-symbol="V" data-category="transition">
  296. <p class="number">23</p>
  297. <h3 class="symbol">V</h3>
  298. <h2 class="name">Vanadium</h2>
  299. <p class="weight">50.9415</p>
  300. </div>
  301. <div class="element metalloid " data-symbol="Ge" data-category="metalloid">
  302. <p class="number">32</p>
  303. <h3 class="symbol">Ge</h3>
  304. <h2 class="name">Germanium</h2>
  305. <p class="weight">72.64</p>
  306. </div>
  307. <div class="element alkali metal " data-symbol="Cs" data-category="alkali">
  308. <p class="number">55</p>
  309. <h3 class="symbol">Cs</h3>
  310. <h2 class="name">Caesium</h2>
  311. <p class="weight">132.9054519</p>
  312. </div>
  313. <div class="element lanthanoid metal inner-transition " data-symbol="Ho" data-category="lanthanoid">
  314. <p class="number">67</p>
  315. <h3 class="symbol">Ho</h3>
  316. <h2 class="name">Holmium</h2>
  317. <p class="weight">164.93032</p>
  318. </div>
  319. <div class="element alkaline-earth metal " data-symbol="Ba" data-category="alkaline-earth">
  320. <p class="number">56</p>
  321. <h3 class="symbol">Ba</h3>
  322. <h2 class="name">Barium</h2>
  323. <p class="weight">137.327</p>
  324. </div>
  325. <div class="element transition metal " data-symbol="Hf" data-category="transition">
  326. <p class="number">72</p>
  327. <h3 class="symbol">Hf</h3>
  328. <h2 class="name">Hafnium</h2>
  329. <p class="weight">178.49</p>
  330. </div>
  331. <div class="element noble-gas nonmetal " data-symbol="He" data-category="noble-gas">
  332. <p class="number">2</p>
  333. <h3 class="symbol">He</h3>
  334. <h2 class="name">Helium</h2>
  335. <p class="weight">4.002602</p>
  336. </div>
  337. <div class="element transition metal " data-symbol="Cr" data-category="transition">
  338. <p class="number">24</p>
  339. <h3 class="symbol">Cr</h3>
  340. <h2 class="name">Chromium</h2>
  341. <p class="weight">51.9961</p>
  342. </div>
  343. <div class="element transition metal " data-symbol="Mo" data-category="transition">
  344. <p class="number">42</p>
  345. <h3 class="symbol">Mo</h3>
  346. <h2 class="name">Molybdenum</h2>
  347. <p class="weight">95.96</p>
  348. </div>
  349. <div class="element lanthanoid metal inner-transition " data-symbol="Lu" data-category="lanthanoid">
  350. <p class="number">71</p>
  351. <h3 class="symbol">Lu</h3>
  352. <h2 class="name">Lutetium</h2>
  353. <p class="weight">174.9668</p>
  354. </div>
  355. <div class="element alkali metal " data-symbol="Li" data-category="alkali">
  356. <p class="number">3</p>
  357. <h3 class="symbol">Li</h3>
  358. <h2 class="name">Lithium</h2>
  359. <p class="weight">6.941</p>
  360. </div>
  361. <div class="element transition metal " data-symbol="Pt" data-category="transition">
  362. <p class="number">78</p>
  363. <h3 class="symbol">Pt</h3>
  364. <h2 class="name">Platinum</h2>
  365. <p class="weight">195.084</p>
  366. </div>
  367. <div class="element noble-gas nonmetal " data-symbol="Uuo" data-category="noble-gas">
  368. <p class="number">118</p>
  369. <h3 class="symbol">Uuo</h3>
  370. <h2 class="name">Ununoctium</h2>
  371. <p class="weight">(294)</p>
  372. </div>
  373. <div class="element transition metal " data-symbol="Hg" data-category="transition">
  374. <p class="number">80</p>
  375. <h3 class="symbol">Hg</h3>
  376. <h2 class="name">Mercury</h2>
  377. <p class="weight">200.59</p>
  378. </div>
  379. <div class="element transition metal " data-symbol="Tc" data-category="transition">
  380. <p class="number">43</p>
  381. <h3 class="symbol">Tc</h3>
  382. <h2 class="name">Technetium</h2>
  383. <p class="weight">(98)</p>
  384. </div>
  385. <div class="element actinoid metal inner-transition " data-symbol="Cm" data-category="actinoid">
  386. <p class="number">96</p>
  387. <h3 class="symbol">Cm</h3>
  388. <h2 class="name">Curium</h2>
  389. <p class="weight">(247)</p>
  390. </div>
  391. <div class="element transition metal " data-symbol="Ag" data-category="transition">
  392. <p class="number">47</p>
  393. <h3 class="symbol">Ag</h3>
  394. <h2 class="name">Silver</h2>
  395. <p class="weight">107.8682</p>
  396. </div>
  397. <div class="element metalloid " data-symbol="Sb" data-category="metalloid">
  398. <p class="number">51</p>
  399. <h3 class="symbol">Sb</h3>
  400. <h2 class="name">Antimony</h2>
  401. <p class="weight">121.76</p>
  402. </div>
  403. <div class="element lanthanoid metal inner-transition " data-symbol="Yb" data-category="lanthanoid">
  404. <p class="number">70</p>
  405. <h3 class="symbol">Yb</h3>
  406. <h2 class="name">Ytterbium</h2>
  407. <p class="weight">173.054</p>
  408. </div>
  409. <div class="element noble-gas nonmetal " data-symbol="Xe" data-category="noble-gas">
  410. <p class="number">54</p>
  411. <h3 class="symbol">Xe</h3>
  412. <h2 class="name">Xenon</h2>
  413. <p class="weight">131.293</p>
  414. </div>
  415. <div class="element lanthanoid metal inner-transition " data-symbol="La" data-category="lanthanoid">
  416. <p class="number">57</p>
  417. <h3 class="symbol">La</h3>
  418. <h2 class="name">Lanthanum</h2>
  419. <p class="weight">138.90547</p>
  420. </div>
  421. <div class="element transition metal " data-symbol="Ta" data-category="transition">
  422. <p class="number">73</p>
  423. <h3 class="symbol">Ta</h3>
  424. <h2 class="name">Tantalum</h2>
  425. <p class="weight">180.94788</p>
  426. </div>
  427. <div class="element metalloid " data-symbol="Te" data-category="metalloid">
  428. <p class="number">52</p>
  429. <h3 class="symbol">Te</h3>
  430. <h2 class="name">Tellurium</h2>
  431. <p class="weight">127.6</p>
  432. </div>
  433. <div class="element transition metal " data-symbol="W" data-category="transition">
  434. <p class="number">74</p>
  435. <h3 class="symbol">W</h3>
  436. <h2 class="name">Tungsten</h2>
  437. <p class="weight">183.84</p>
  438. </div>
  439. </div>
  440. <script src="../js/jquery-1.6.4.min.js"></script>
  441. <script src="../jquery.isotope.min.js"></script>
  442. <script src="../js/fake-element.js"></script>
  443. <script>
  444. // categoryRows custom layout mode
  445. $.extend( $.Isotope.prototype, {
  446. _categoryRowsReset : function() {
  447. this.categoryRows = {
  448. x : 0,
  449. y : 0,
  450. height : 0,
  451. currentCategory : null
  452. };
  453. },
  454. _categoryRowsLayout : function( $elems ) {
  455. var instance = this,
  456. containerWidth = this.element.width(),
  457. sortBy = this.options.sortBy,
  458. props = this.categoryRows;
  459. $elems.each( function() {
  460. var $this = $(this),
  461. atomW = $this.outerWidth(true),
  462. atomH = $this.outerHeight(true),
  463. category = $.data( this, 'isotope-sort-data' )[ sortBy ],
  464. x, y;
  465. if ( category !== props.currentCategory ) {
  466. // new category, new row
  467. props.x = 0;
  468. props.height += props.currentCategory ? instance.options.categoryRows.gutter : 0;
  469. props.y = props.height;
  470. props.currentCategory = category;
  471. } else if ( props.x !== 0 && atomW + props.x > containerWidth ) {
  472. // if this element cannot fit in the current row
  473. props.x = 0;
  474. props.y = props.height;
  475. }
  476. // position the atom
  477. instance._pushPosition( $this, props.x, props.y );
  478. props.height = Math.max( props.y + atomH, props.height );
  479. props.x += atomW;
  480. });
  481. },
  482. _categoryRowsGetContainerSize : function () {
  483. return { height : this.categoryRows.height };
  484. },
  485. _categoryRowsResizeChanged : function() {
  486. return true;
  487. }
  488. });
  489. $(function(){
  490. var $container = $('#container');
  491. // add randomish size classes
  492. $container.find('.element').each(function(){
  493. var $this = $(this),
  494. number = parseInt( $this.find('.number').text(), 10 );
  495. if ( number % 7 % 2 === 1 ) {
  496. $this.addClass('width2');
  497. }
  498. if ( number % 3 === 0 ) {
  499. $this.addClass('height2');
  500. }
  501. });
  502. $container.isotope({
  503. itemSelector : '.element',
  504. layoutMode : 'categoryRows',
  505. categoryRows : {
  506. gutter : 20
  507. },
  508. getSortData : {
  509. category : function( $elem ) {
  510. return $elem.attr('data-category');
  511. }
  512. },
  513. sortBy: 'category'
  514. });
  515. var $optionSets = $('#options .option-set'),
  516. $optionLinks = $optionSets.find('a');
  517. $optionLinks.click(function(){
  518. var $this = $(this);
  519. // don't proceed if already selected
  520. if ( $this.hasClass('selected') ) {
  521. return false;
  522. }
  523. var $optionSet = $this.parents('.option-set');
  524. $optionSet.find('.selected').removeClass('selected');
  525. $this.addClass('selected');
  526. // make option object dynamically, i.e. { filter: '.my-filter-class' }
  527. var options = {},
  528. key = $optionSet.attr('data-option-key'),
  529. value = $this.attr('data-option-value');
  530. // parse 'false' as false boolean
  531. value = value === 'false' ? false : value;
  532. options[ key ] = value;
  533. if ( key === 'layoutMode' && typeof changeLayoutMode === 'function' ) {
  534. // changes in layout modes need extra logic
  535. changeLayoutMode( $this, options )
  536. } else {
  537. // otherwise, apply new options
  538. $container.isotope( options );
  539. }
  540. return false;
  541. });
  542. $('#insert a').click(function(){
  543. var $newEls = $( fakeElement.getGroup() );
  544. $container.isotope( 'insert', $newEls );
  545. return false;
  546. });
  547. $('#append a').click(function(){
  548. var $newEls = $( fakeElement.getGroup() );
  549. $container.append( $newEls ).isotope( 'appended', $newEls );
  550. return false;
  551. });
  552. // toggle variable sizes of all elements
  553. $('#toggle-sizes').find('a').click(function(){
  554. $container
  555. .toggleClass('variable-sizes')
  556. .isotope('reLayout');
  557. return false;
  558. });
  559. });
  560. </script>
  561. <footer>
  562. Isotope by <a href="http://desandro.com">David DeSandro</a> / <a href="http://metafizzy.co">Metafizzy</a>
  563. </footer>
  564. </section> <!-- #content -->
  565. </body>
  566. </html>