packery-rails 1.2.4 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0581871b683618307059bab7583350c7216572a
4
- data.tar.gz: 3242208df7205b1c245dfa3d1b3b4d0cfe495480
3
+ metadata.gz: 1f42385808ec41ee382408728ab0a78c56bde6a8
4
+ data.tar.gz: 1c2caad372a317ca1f4036770d9ff5deb220e49d
5
5
  SHA512:
6
- metadata.gz: 867afb6b13ac555cb7e88a7df529d1d141e6fc52875d358ae1a772ca36cc20b86aacdba7fb26a038958f94095940df094b6c70aa570b5c86b4762a3bb416fea2
7
- data.tar.gz: cfa44c526dcc6221d7c5290dd700dc545d338b9845f68a8cdcfb6f171d2846c30e5652356a1e8fac0862411e2b3e09643e70192bc61bb3dfcab6fe281781325d
6
+ metadata.gz: 59bb63d4b3c0a7e746dfdf39abddeede8555499f4185a53a5ad840b99a60c26e8a83ab646765ffe4c30ea8b4725f40ffd055798b8b130a059912e89be2c06959
7
+ data.tar.gz: b7c25444a29830ebe97caba5ea9dae7162b51a1fb703b77bf8f01fc84a159e31e47d64bbcbb45467f41ba7477a67d45101ab9523eedcfd717edd8896ae22878b
data/.gitignore CHANGED
@@ -1 +1,3 @@
1
+ Gemfile.lock
1
2
  pkg
3
+ tmp
@@ -1,5 +1,5 @@
1
1
  module Packery
2
2
  module Rails
3
- VERSION = '1.2.4'.freeze
3
+ VERSION = '1.3.0'.freeze
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Packery PACKAGED v1.2.4
2
+ * Packery PACKAGED v1.3.0
3
3
  * bin-packing layout library
4
4
  * http://packery.metafizzy.co
5
5
  *
@@ -13,7 +13,8 @@
13
13
 
14
14
  /**
15
15
  * Bridget makes jQuery widgets
16
- * v1.0.1
16
+ * v1.1.0
17
+ * MIT license
17
18
  */
18
19
 
19
20
  ( function( window ) {
@@ -57,7 +58,6 @@ function addOptionMethod( PluginClass ) {
57
58
  };
58
59
  }
59
60
 
60
-
61
61
  // -------------------------- plugin bridge -------------------------- //
62
62
 
63
63
  // helper function for logging errors
@@ -142,6 +142,8 @@ return $.bridget;
142
142
  if ( typeof define === 'function' && define.amd ) {
143
143
  // AMD
144
144
  define( 'jquery-bridget/jquery.bridget',[ 'jquery' ], defineBridget );
145
+ } else if ( typeof exports === 'object' ) {
146
+ defineBridget( require('jquery') );
145
147
  } else {
146
148
  // get jquery from browser global
147
149
  defineBridget( window.jQuery );
@@ -236,9 +238,10 @@ if ( typeof define === 'function' && define.amd ) {
236
238
  })( window );
237
239
 
238
240
  /*!
239
- * getStyleProperty v1.0.3
241
+ * getStyleProperty v1.0.4
240
242
  * original by kangax
241
243
  * http://perfectionkills.com/feature-testing-css-properties/
244
+ * MIT license
242
245
  */
243
246
 
244
247
  /*jshint browser: true, strict: true, undef: true */
@@ -290,13 +293,14 @@ if ( typeof define === 'function' && define.amd ) {
290
293
 
291
294
  })( window );
292
295
 
293
- /**
294
- * getSize v1.1.7
296
+ /*!
297
+ * getSize v1.2.2
295
298
  * measure size of elements
299
+ * MIT license
296
300
  */
297
301
 
298
302
  /*jshint browser: true, strict: true, undef: true, unused: true */
299
- /*global define: false, exports: false, require: false, module: false */
303
+ /*global define: false, exports: false, require: false, module: false, console: false */
300
304
 
301
305
  ( function( window, undefined ) {
302
306
 
@@ -304,15 +308,6 @@ if ( typeof define === 'function' && define.amd ) {
304
308
 
305
309
  // -------------------------- helpers -------------------------- //
306
310
 
307
- var getComputedStyle = window.getComputedStyle;
308
- var getStyle = getComputedStyle ?
309
- function( elem ) {
310
- return getComputedStyle( elem, null );
311
- } :
312
- function( elem ) {
313
- return elem.currentStyle;
314
- };
315
-
316
311
  // get a number from a string, not a percentage
317
312
  function getStyleSize( value ) {
318
313
  var num = parseFloat( value );
@@ -321,6 +316,13 @@ function getStyleSize( value ) {
321
316
  return isValid && num;
322
317
  }
323
318
 
319
+ function noop() {}
320
+
321
+ var logError = typeof console === 'undefined' ? noop :
322
+ function( message ) {
323
+ console.error( message );
324
+ };
325
+
324
326
  // -------------------------- measurements -------------------------- //
325
327
 
326
328
  var measurements = [
@@ -358,39 +360,76 @@ function getZeroSize() {
358
360
 
359
361
  function defineGetSize( getStyleProperty ) {
360
362
 
361
- // -------------------------- box sizing -------------------------- //
363
+ // -------------------------- setup -------------------------- //
364
+
365
+ var isSetup = false;
362
366
 
363
- var boxSizingProp = getStyleProperty('boxSizing');
364
- var isBoxSizeOuter;
367
+ var getStyle, boxSizingProp, isBoxSizeOuter;
365
368
 
366
369
  /**
367
- * WebKit measures the outer-width on style.width on border-box elems
368
- * IE & Firefox measures the inner-width
370
+ * setup vars and functions
371
+ * do it on initial getSize(), rather than on script load
372
+ * For Firefox bug https://bugzilla.mozilla.org/show_bug.cgi?id=548397
369
373
  */
370
- ( function() {
371
- if ( !boxSizingProp ) {
374
+ function setup() {
375
+ // setup once
376
+ if ( isSetup ) {
372
377
  return;
373
378
  }
379
+ isSetup = true;
374
380
 
375
- var div = document.createElement('div');
376
- div.style.width = '200px';
377
- div.style.padding = '1px 2px 3px 4px';
378
- div.style.borderStyle = 'solid';
379
- div.style.borderWidth = '1px 2px 3px 4px';
380
- div.style[ boxSizingProp ] = 'border-box';
381
+ var getComputedStyle = window.getComputedStyle;
382
+ getStyle = ( function() {
383
+ var getStyleFn = getComputedStyle ?
384
+ function( elem ) {
385
+ return getComputedStyle( elem, null );
386
+ } :
387
+ function( elem ) {
388
+ return elem.currentStyle;
389
+ };
381
390
 
382
- var body = document.body || document.documentElement;
383
- body.appendChild( div );
384
- var style = getStyle( div );
391
+ return function getStyle( elem ) {
392
+ var style = getStyleFn( elem );
393
+ if ( !style ) {
394
+ logError( 'Style returned ' + style +
395
+ '. Are you running this code in a hidden iframe on Firefox? ' +
396
+ 'See http://bit.ly/getsizebug1' );
397
+ }
398
+ return style;
399
+ };
400
+ })();
385
401
 
386
- isBoxSizeOuter = getStyleSize( style.width ) === 200;
387
- body.removeChild( div );
388
- })();
402
+ // -------------------------- box sizing -------------------------- //
403
+
404
+ boxSizingProp = getStyleProperty('boxSizing');
405
+
406
+ /**
407
+ * WebKit measures the outer-width on style.width on border-box elems
408
+ * IE & Firefox measures the inner-width
409
+ */
410
+ if ( boxSizingProp ) {
411
+ var div = document.createElement('div');
412
+ div.style.width = '200px';
413
+ div.style.padding = '1px 2px 3px 4px';
414
+ div.style.borderStyle = 'solid';
415
+ div.style.borderWidth = '1px 2px 3px 4px';
416
+ div.style[ boxSizingProp ] = 'border-box';
417
+
418
+ var body = document.body || document.documentElement;
419
+ body.appendChild( div );
420
+ var style = getStyle( div );
421
+
422
+ isBoxSizeOuter = getStyleSize( style.width ) === 200;
423
+ body.removeChild( div );
424
+ }
389
425
 
426
+ }
390
427
 
391
428
  // -------------------------- getSize -------------------------- //
392
429
 
393
430
  function getSize( elem ) {
431
+ setup();
432
+
394
433
  // use querySeletor if elem is string
395
434
  if ( typeof elem === 'string' ) {
396
435
  elem = document.querySelector( elem );
@@ -462,7 +501,7 @@ function getSize( elem ) {
462
501
  // taken from jQuery's curCSS
463
502
  function mungeNonPixel( elem, value ) {
464
503
  // IE8 and has percent value
465
- if ( getComputedStyle || value.indexOf('%') === -1 ) {
504
+ if ( window.getComputedStyle || value.indexOf('%') === -1 ) {
466
505
  return value;
467
506
  }
468
507
  var style = elem.style;
@@ -497,7 +536,7 @@ if ( typeof define === 'function' && define.amd ) {
497
536
  define( 'get-size/get-size',[ 'get-style-property/get-style-property' ], defineGetSize );
498
537
  } else if ( typeof exports === 'object' ) {
499
538
  // CommonJS for Component
500
- module.exports = defineGetSize( require('get-style-property') );
539
+ module.exports = defineGetSize( require('desandro-get-style-property') );
501
540
  } else {
502
541
  // browser global
503
542
  window.getSize = defineGetSize( window.getStyleProperty );
@@ -589,13 +628,13 @@ if ( typeof define === 'function' && define.amd ) {
589
628
  })( this );
590
629
 
591
630
  /*!
592
- * docReady v1.0.3
631
+ * docReady v1.0.4
593
632
  * Cross browser DOMContentLoaded event emitter
594
633
  * MIT license
595
634
  */
596
635
 
597
636
  /*jshint browser: true, strict: true, undef: true, unused: true*/
598
- /*global define: false */
637
+ /*global define: false, require: false, module: false */
599
638
 
600
639
  ( function( window ) {
601
640
 
@@ -623,14 +662,18 @@ function docReady( fn ) {
623
662
  docReady.isReady = false;
624
663
 
625
664
  // triggered on various doc ready events
626
- function init( event ) {
627
- // bail if IE8 document is not ready just yet
665
+ function onReady( event ) {
666
+ // bail if already triggered or IE8 document is not ready just yet
628
667
  var isIE8NotReady = event.type === 'readystatechange' && document.readyState !== 'complete';
629
668
  if ( docReady.isReady || isIE8NotReady ) {
630
669
  return;
631
670
  }
632
- docReady.isReady = true;
633
671
 
672
+ trigger();
673
+ }
674
+
675
+ function trigger() {
676
+ docReady.isReady = true;
634
677
  // process queue
635
678
  for ( var i=0, len = queue.length; i < len; i++ ) {
636
679
  var fn = queue[i];
@@ -639,9 +682,15 @@ function init( event ) {
639
682
  }
640
683
 
641
684
  function defineDocReady( eventie ) {
642
- eventie.bind( document, 'DOMContentLoaded', init );
643
- eventie.bind( document, 'readystatechange', init );
644
- eventie.bind( window, 'load', init );
685
+ // trigger ready if page is ready
686
+ if ( document.readyState === 'complete' ) {
687
+ trigger();
688
+ } else {
689
+ // listen for events
690
+ eventie.bind( document, 'DOMContentLoaded', onReady );
691
+ eventie.bind( document, 'readystatechange', onReady );
692
+ eventie.bind( window, 'load', onReady );
693
+ }
645
694
 
646
695
  return docReady;
647
696
  }
@@ -649,8 +698,6 @@ function defineDocReady( eventie ) {
649
698
  // transport
650
699
  if ( typeof define === 'function' && define.amd ) {
651
700
  // AMD
652
- // if RequireJS, then doc is already ready
653
- docReady.isReady = typeof requirejs === 'function';
654
701
  define( 'doc-ready/doc-ready',[ 'eventie/eventie' ], defineDocReady );
655
702
  } else if ( typeof exports === 'object' ) {
656
703
  module.exports = defineDocReady( require('eventie') );
@@ -662,7 +709,7 @@ if ( typeof define === 'function' && define.amd ) {
662
709
  })( window );
663
710
 
664
711
  /*!
665
- * EventEmitter v4.2.7 - git.io/ee
712
+ * EventEmitter v4.2.9 - git.io/ee
666
713
  * Oliver Caldwell
667
714
  * MIT license
668
715
  * @preserve
@@ -685,7 +732,7 @@ if ( typeof define === 'function' && define.amd ) {
685
732
  var originalGlobalValue = exports.EventEmitter;
686
733
 
687
734
  /**
688
- * Finds the index of the listener for the event in it's storage array.
735
+ * Finds the index of the listener for the event in its storage array.
689
736
  *
690
737
  * @param {Function[]} listeners Array of listeners to search through.
691
738
  * @param {Function} listener Method to look for.
@@ -816,7 +863,7 @@ if ( typeof define === 'function' && define.amd ) {
816
863
 
817
864
  /**
818
865
  * Semi-alias of addListener. It will add a listener that will be
819
- * automatically removed after it's first execution.
866
+ * automatically removed after its first execution.
820
867
  *
821
868
  * @param {String|RegExp} evt Name of the event to attach the listener to.
822
869
  * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
@@ -938,7 +985,7 @@ if ( typeof define === 'function' && define.amd ) {
938
985
  var single = remove ? this.removeListener : this.addListener;
939
986
  var multiple = remove ? this.removeListeners : this.addListeners;
940
987
 
941
- // If evt is an object then pass each of it's properties to this method
988
+ // If evt is an object then pass each of its properties to this method
942
989
  if (typeof evt === 'object' && !(evt instanceof RegExp)) {
943
990
  for (i in evt) {
944
991
  if (evt.hasOwnProperty(i) && (value = evt[i])) {
@@ -1130,7 +1177,7 @@ if ( typeof define === 'function' && define.amd ) {
1130
1177
  module.exports = EventEmitter;
1131
1178
  }
1132
1179
  else {
1133
- this.EventEmitter = EventEmitter;
1180
+ exports.EventEmitter = EventEmitter;
1134
1181
  }
1135
1182
  }.call(this));
1136
1183
 
@@ -1750,6 +1797,13 @@ if ( typeof define === 'function' && define.amd ) {
1750
1797
  'get-style-property/get-style-property'
1751
1798
  ],
1752
1799
  outlayerItemDefinition );
1800
+ } else if (typeof exports === 'object') {
1801
+ // CommonJS
1802
+ module.exports = outlayerItemDefinition(
1803
+ require('wolfy87-eventemitter'),
1804
+ require('get-size'),
1805
+ require('desandro-get-style-property')
1806
+ );
1753
1807
  } else {
1754
1808
  // browser global
1755
1809
  window.Outlayer = {};
@@ -1763,7 +1817,7 @@ if ( typeof define === 'function' && define.amd ) {
1763
1817
  })( window );
1764
1818
 
1765
1819
  /*!
1766
- * Outlayer v1.2.0
1820
+ * Outlayer v1.3.0
1767
1821
  * the brains and guts of a layout library
1768
1822
  * MIT license
1769
1823
  */
@@ -1777,7 +1831,6 @@ if ( typeof define === 'function' && define.amd ) {
1777
1831
  var document = window.document;
1778
1832
  var console = window.console;
1779
1833
  var jQuery = window.jQuery;
1780
-
1781
1834
  var noop = function() {};
1782
1835
 
1783
1836
  // -------------------------- helpers -------------------------- //
@@ -1815,7 +1868,7 @@ function makeArray( obj ) {
1815
1868
  }
1816
1869
 
1817
1870
  // http://stackoverflow.com/a/384380/182183
1818
- var isElement = ( typeof HTMLElement === 'object' ) ?
1871
+ var isElement = ( typeof HTMLElement === 'function' || typeof HTMLElement === 'object' ) ?
1819
1872
  function isElementDOM2( obj ) {
1820
1873
  return obj instanceof HTMLElement;
1821
1874
  } :
@@ -2633,6 +2686,8 @@ Outlayer.prototype.destroy = function() {
2633
2686
 
2634
2687
  this.unbindResize();
2635
2688
 
2689
+ var id = this.element.outlayerGUID;
2690
+ delete instances[ id ]; // remove reference to instance by id
2636
2691
  delete this.element.outlayerGUID;
2637
2692
  // remove data for jQuery
2638
2693
  if ( jQuery ) {
@@ -2758,6 +2813,16 @@ if ( typeof define === 'function' && define.amd ) {
2758
2813
  './item'
2759
2814
  ],
2760
2815
  outlayerDefinition );
2816
+ } else if ( typeof exports === 'object' ) {
2817
+ // CommonJS
2818
+ module.exports = outlayerDefinition(
2819
+ require('eventie'),
2820
+ require('doc-ready'),
2821
+ require('wolfy87-eventemitter'),
2822
+ require('get-size'),
2823
+ require('desandro-matches-selector'),
2824
+ require('./item')
2825
+ );
2761
2826
  } else {
2762
2827
  // browser global
2763
2828
  window.Outlayer = outlayerDefinition(
@@ -2924,6 +2989,9 @@ return Rect;
2924
2989
  if ( typeof define === 'function' && define.amd ) {
2925
2990
  // AMD
2926
2991
  define( 'packery/js/rect',rectDefinition );
2992
+ } else if ( typeof exports === 'object' ) {
2993
+ // CommonJS
2994
+ module.exports = rectDefinition();
2927
2995
  } else {
2928
2996
  // browser global
2929
2997
  window.Packery = window.Packery || {};
@@ -3011,12 +3079,21 @@ Packer.prototype.placed = function( rect ) {
3011
3079
 
3012
3080
  this.spaces = revisedSpaces;
3013
3081
 
3082
+ this.mergeSortSpaces();
3083
+ };
3084
+
3085
+ Packer.prototype.mergeSortSpaces = function() {
3014
3086
  // remove redundant spaces
3015
3087
  Packer.mergeRects( this.spaces );
3016
-
3017
3088
  this.spaces.sort( this.sorter );
3018
3089
  };
3019
3090
 
3091
+ // add a space back
3092
+ Packer.prototype.addSpace = function( rect ) {
3093
+ this.spaces.push( rect );
3094
+ this.mergeSortSpaces();
3095
+ };
3096
+
3020
3097
  // -------------------------- utility functions -------------------------- //
3021
3098
 
3022
3099
  /**
@@ -3081,6 +3158,11 @@ return Packer;
3081
3158
  if ( typeof define === 'function' && define.amd ) {
3082
3159
  // AMD
3083
3160
  define( 'packery/js/packer',[ './rect' ], packerDefinition );
3161
+ } else if ( typeof exports === 'object' ) {
3162
+ // CommonJS
3163
+ module.exports = packerDefinition(
3164
+ require('./rect')
3165
+ );
3084
3166
  } else {
3085
3167
  // browser global
3086
3168
  var Packery = window.Packery = window.Packery || {};
@@ -3230,6 +3312,18 @@ Item.prototype.copyPlaceRectPosition = function() {
3230
3312
  this.rect.y = this.placeRect.y;
3231
3313
  };
3232
3314
 
3315
+ // ----- ----- //
3316
+
3317
+ // remove element from DOM
3318
+ Item.prototype.removeElem = function() {
3319
+ this.element.parentNode.removeChild( this.element );
3320
+ // add space back to packer
3321
+ this.layout.packer.addSpace( this.rect );
3322
+ this.emitEvent( 'remove', [ this ] );
3323
+ };
3324
+
3325
+ // ----- ----- //
3326
+
3233
3327
  return Item;
3234
3328
 
3235
3329
  }
@@ -3244,6 +3338,13 @@ if ( typeof define === 'function' && define.amd ) {
3244
3338
  './rect'
3245
3339
  ],
3246
3340
  itemDefinition );
3341
+ } else if ( typeof exports === 'object' ) {
3342
+ // CommonJS
3343
+ module.exports = itemDefinition(
3344
+ require('desandro-get-style-property'),
3345
+ require('outlayer'),
3346
+ require('./rect')
3347
+ );
3247
3348
  } else {
3248
3349
  // browser global
3249
3350
  window.Packery.Item = itemDefinition(
@@ -3256,7 +3357,7 @@ if ( typeof define === 'function' && define.amd ) {
3256
3357
  })( window );
3257
3358
 
3258
3359
  /*!
3259
- * Packery v1.2.4
3360
+ * Packery v1.3.0
3260
3361
  * bin-packing layout library
3261
3362
  * http://packery.metafizzy.co
3262
3363
  *
@@ -3714,6 +3815,16 @@ if ( typeof define === 'function' && define.amd ) {
3714
3815
  'packery/js/item'
3715
3816
  ],
3716
3817
  packeryDefinition );
3818
+ } else if ( typeof exports === 'object' ) {
3819
+ // CommonJS
3820
+ module.exports = packeryDefinition(
3821
+ require('desandro-classie'),
3822
+ require('get-size'),
3823
+ require('outlayer'),
3824
+ require('./rect'),
3825
+ require('./packer'),
3826
+ require('./item')
3827
+ );
3717
3828
  } else {
3718
3829
  // browser global
3719
3830
  window.Packery = packeryDefinition(
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: packery-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leonid Beder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-18 00:00:00.000000000 Z
11
+ date: 2014-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -33,7 +33,6 @@ extra_rdoc_files: []
33
33
  files:
34
34
  - ".gitignore"
35
35
  - Gemfile
36
- - Gemfile.lock
37
36
  - LICENSE
38
37
  - README.md
39
38
  - Rakefile
data/Gemfile.lock DELETED
@@ -1,48 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- packery-rails (1.2.4)
5
- railties (>= 3.1.0)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- actionpack (4.1.8)
11
- actionview (= 4.1.8)
12
- activesupport (= 4.1.8)
13
- rack (~> 1.5.2)
14
- rack-test (~> 0.6.2)
15
- actionview (4.1.8)
16
- activesupport (= 4.1.8)
17
- builder (~> 3.1)
18
- erubis (~> 2.7.0)
19
- activesupport (4.1.8)
20
- i18n (~> 0.6, >= 0.6.9)
21
- json (~> 1.7, >= 1.7.7)
22
- minitest (~> 5.1)
23
- thread_safe (~> 0.1)
24
- tzinfo (~> 1.1)
25
- builder (3.2.2)
26
- erubis (2.7.0)
27
- i18n (0.6.11)
28
- json (1.8.1)
29
- minitest (5.4.3)
30
- rack (1.5.2)
31
- rack-test (0.6.2)
32
- rack (>= 1.0)
33
- railties (4.1.8)
34
- actionpack (= 4.1.8)
35
- activesupport (= 4.1.8)
36
- rake (>= 0.8.7)
37
- thor (>= 0.18.1, < 2.0)
38
- rake (10.3.2)
39
- thor (0.19.1)
40
- thread_safe (0.3.4)
41
- tzinfo (1.2.2)
42
- thread_safe (~> 0.1)
43
-
44
- PLATFORMS
45
- ruby
46
-
47
- DEPENDENCIES
48
- packery-rails!