evil-blocks-rails 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog.md +3 -0
  3. data/lib/evil-blocks.js +17 -7
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d18be5dfc85ca1bdff5b9748f2a033f09ab24a81
4
- data.tar.gz: 58bc3e5399b808b2e8025c91df312e2472d34943
3
+ metadata.gz: 5be4b6d7fdc3df28a8ad6bc1cd73f4024f6396f6
4
+ data.tar.gz: 3dfc6a88f8d0da7aa01cd5c93c1ec1363f14e6fa
5
5
  SHA512:
6
- metadata.gz: 7bc25d378340da42e2533f0b1eb7baf366a7f74b76f74a44093ffee067442cad9036e143d30d28779f9259b1468cd4a7f1868ab0f5cbcbbdbdc496857e983d4b
7
- data.tar.gz: 4daffdd46ff66ec0f9a133c4c9186e5220858d140848a0153f37e7d7d9ed7a35eabd1f46085e1784229ce0e8239925da4d87e26ea9469a88868f61edfaa933c3
6
+ metadata.gz: 771a05c59ed27eaa63d918fcd0b68971c86b7e7afe072d1e07d20406a7b549b5a91438856c1ed257f21fadb3bfceb53f4c6438be9254afb3efb908fc29952c90
7
+ data.tar.gz: 633c478e433f53c3e431bd0d12f076088b88e177660052ce34d4b08f3030e85e48396dc0566c5b4228bf25bbc39e1847c07d16051559726a73de702ab1db8444
data/ChangeLog.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.5.1
2
+ * Fix block vitalizing, when multiple blocks was binded to same DOM node.
3
+
1
4
  ## 0.5 (RDS-1, 29th August 1949)
2
5
  * Current event target was moved from first argument to `event.el`.
3
6
  * Inside finder was moved from `@(selector)` to `@$(selector)`.
data/lib/evil-blocks.js CHANGED
@@ -77,7 +77,7 @@
77
77
  /**
78
78
  * Execute `callback` on every finded `selector` inside `base`.
79
79
  */
80
- var vitalize = function (base, selector, klass) {
80
+ var vitalize = function (base, id, selector, klass) {
81
81
  var blocks = $().add( base.filter(selector) ).
82
82
  add( base.find(selector) );
83
83
 
@@ -90,10 +90,14 @@
90
90
  for ( var i = 0; i < blocks.length; i++ ) {
91
91
  var block = $(blocks[i]);
92
92
 
93
- if ( block.data('evil-vitalized') ) {
93
+ var vitalized = block.data('evil-vitalized');
94
+ if ( !vitalized ) {
95
+ vitalized = [];
96
+ } else if ( vitalized.indexOf(id) != -1 ) {
94
97
  continue;
95
98
  }
96
- block.data('evil-vitalized', true);
99
+ vitalized.push(id);
100
+ block.data('evil-vitalized', vitalized);
97
101
 
98
102
  var obj = { };
99
103
 
@@ -163,6 +167,9 @@
163
167
  }
164
168
  };
165
169
 
170
+ // Latest block ID
171
+ var lastBlock = 0;
172
+
166
173
  /**
167
174
  * Create object for every `selector` finded in page and call their
168
175
  * `init` method.
@@ -199,14 +206,17 @@
199
206
  * # init method
200
207
  */
201
208
  window.evil.block = function (selector, vitalizer) {
209
+ lastBlock += 1;
210
+ var id = lastBlock;
211
+
202
212
  if ( typeof(vitalizer) == 'function' ) {
203
213
  vitalizer = { init: vitalizer };
204
214
  }
205
215
 
206
- window.evil.block.vitalizers.push([selector, vitalizer]);
216
+ window.evil.block.vitalizers.push([id, selector, vitalizer]);
207
217
 
208
218
  if ( ready ) {
209
- var init = vitalize($(document), selector, vitalizer);
219
+ var init = vitalize($(document), id, selector, vitalizer);
210
220
  if ( init ) {
211
221
  init();
212
222
  }
@@ -235,8 +245,8 @@
235
245
 
236
246
  var inits = [];
237
247
  for ( var i = 0; i < window.evil.block.vitalizers.length; i++ ) {
238
- var vitalizer = window.evil.block.vitalizers[i];
239
- inits.push( vitalize(base, vitalizer[0], vitalizer[1]) );
248
+ var block = window.evil.block.vitalizers[i];
249
+ inits.push( vitalize(base, block[0], block[1], block[2]) );
240
250
  }
241
251
 
242
252
  for ( var i = 0; i < inits.length; i++ ) {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evil-blocks-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Sitnik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-19 00:00:00.000000000 Z
11
+ date: 2014-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sprockets
@@ -59,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
59
  version: '0'
60
60
  requirements: []
61
61
  rubyforge_project:
62
- rubygems_version: 2.2.0
62
+ rubygems_version: 2.2.2
63
63
  signing_key:
64
64
  specification_version: 4
65
65
  summary: Tiny JS framework for web pages to split your app to independent blocks