diff --git a/.gitignore b/.gitignore index 927e22e..0402acd 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ isotope-site.zip components/ bower_components/ node_modules/ +sandbox/**/bundle.js diff --git a/js/isotope.js b/js/isotope.js index 72405c0..96d1d89 100644 --- a/js/isotope.js +++ b/js/isotope.js @@ -628,6 +628,7 @@ if ( typeof define === 'function' && define.amd ) { require('get-size'), require('desandro-matches-selector'), require('./item'), + require('./layout-mode'), // include default layout modes require('./layout-modes/masonry'), require('./layout-modes/fit-rows'), diff --git a/package.json b/package.json index 8047c6e..5a644e8 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,9 @@ "masonry-layout": "3.2.x" }, "devDependencies": { + "desandro-matches-selector": "^1.0.2", "doc-ready": "1.x", + "eventie": "^1.0.5", "jquery": ">=1.4.3 <2", "jquery-bridget": "1.1.x", "qunitjs": "^1.15", diff --git a/sandbox/browserify/browserify.html b/sandbox/browserify/browserify.html new file mode 100644 index 0000000..9365b55 --- /dev/null +++ b/sandbox/browserify/browserify.html @@ -0,0 +1,145 @@ + + + + + + Browserify + + + + + + +

Browserify

+ +
+

Filter

+
+ + + + +
+

Sort

+
+ + + + + + +
+
+ +
+ +
+

80

+

Hg

+

Mercury

+

200.59

+
+ +
+

52

+

Te

+

Tellurium

+

127.6

+
+ +
+

83

+

Bi

+

Bismuth

+

208.9804

+
+ +
+

48

+

Cd

+

Cadmium

+

112.411

+
+ +
+

20

+

Ca

+

Calcium

+

40.078

+
+ +
+

75

+

Re

+

Rhenium

+

186.207

+
+ +
+

81

+

Tl

+

Thallium

+

204.3833

+
+ +
+

51

+

Sb

+

Antimony

+

121.76

+
+ +
+

27

+

Co

+

Cobalt

+

58.933195

+
+ +
+

71

+

Lu

+

Lutetium

+

174.9668

+
+ +
+

18

+

Ar

+

Argon

+

39.948

+
+ +
+

37

+

Rb

+

Rubidium

+

85.4678

+
+ +
+

7

+

N

+

Nitrogen

+

14.0067

+
+ +
+

93

+

Np

+

Neptunium

+

(237)

+
+ +
+

89

+

Ac

+

Actinium

+

(227)

+
+
+ + + + + diff --git a/sandbox/browserify/main.js b/sandbox/browserify/main.js new file mode 100644 index 0000000..52fb520 --- /dev/null +++ b/sandbox/browserify/main.js @@ -0,0 +1,47 @@ +var Isotope = window.Isotope = require('../../js/isotope'); +var eventie = require('eventie'); +var matchesSelector = require('desandro-matches-selector'); + +function getText( elem ) { + return elem.textContent || elem.innerText; +} + +var iso = window.iso = new Isotope( '#container', { + layoutMode: 'fitRows', + transitionDuration: '0.8s', + cellsByRow: { + columnWidth: 130, + rowHeight: 140 + }, + getSortData: { + number: '.number parseInt', + symbol: '.symbol', + name: '.name', + category: '[data-category]', + weight: function( itemElem ) { + // remove parenthesis + return parseFloat( getText( itemElem.querySelector('.weight') ).replace( /[\(\)]/g, '') ); + } + } +}); + +var options = document.querySelector('#options'); + +eventie.bind( options, 'click', function( event ) { + if ( !matchesSelector( event.target, 'button' ) ) { + return; + } + + var key = event.target.parentNode.getAttribute('data-isotope-key'); + var value = event.target.getAttribute('data-isotope-value'); + + if ( key === 'filter' && value === 'number-greater-than-50' ) { + value = function( elem ) { + var numberText = getText( elem.querySelector('.number') ); + return parseInt( numberText, 10 ) > 40; + }; + } + console.log( key, value ); + iso.options[ key ] = value; + iso.arrange(); +});