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.
- checksums.yaml +4 -4
- data/ChangeLog.md +3 -0
- data/lib/evil-blocks.js +17 -7
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5be4b6d7fdc3df28a8ad6bc1cd73f4024f6396f6
|
4
|
+
data.tar.gz: 3dfc6a88f8d0da7aa01cd5c93c1ec1363f14e6fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 771a05c59ed27eaa63d918fcd0b68971c86b7e7afe072d1e07d20406a7b549b5a91438856c1ed257f21fadb3bfceb53f4c6438be9254afb3efb908fc29952c90
|
7
|
+
data.tar.gz: 633c478e433f53c3e431bd0d12f076088b88e177660052ce34d4b08f3030e85e48396dc0566c5b4228bf25bbc39e1847c07d16051559726a73de702ab1db8444
|
data/ChangeLog.md
CHANGED
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
|
-
|
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
|
-
|
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
|
239
|
-
inits.push( vitalize(base,
|
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.
|
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-
|
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.
|
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
|