evil-blocks-rails 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +4 -0
- data/lib/assets/javascripts/evil-blocks.js +26 -26
- data/lib/evil-blocks-rails.rb +3 -1
- metadata +2 -2
data/ChangeLog
CHANGED
@@ -80,36 +80,36 @@
|
|
80
80
|
*/
|
81
81
|
window.evil.block = function (selector, callback) {
|
82
82
|
$(function () {
|
83
|
-
var
|
84
|
-
|
85
|
-
|
86
|
-
}
|
83
|
+
var blocks = $(selector);
|
84
|
+
for ( var i = 0; i < blocks.length; i++ ) {
|
85
|
+
var block = $(blocks[i]);
|
87
86
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
87
|
+
var b = function (subselector) {
|
88
|
+
return $(subselector, block);
|
89
|
+
};
|
90
|
+
var actives = { };
|
91
|
+
block.find('[data-role]').each(function (_, el) {
|
92
|
+
var roles = el.attributes['data-role'].value.split(' ');
|
93
|
+
for ( var i = 0; i < roles.length; i++ ) {
|
94
|
+
var role = roles[i].replace(/-\w/g, function (s) {
|
95
|
+
return s[1].toUpperCase();
|
96
|
+
});
|
97
|
+
if ( !actives[role] ) {
|
98
|
+
actives[role] = [];
|
99
|
+
}
|
100
|
+
actives[role].push(el);
|
100
101
|
}
|
101
|
-
|
102
|
-
}
|
103
|
-
});
|
102
|
+
});
|
104
103
|
|
105
|
-
|
106
|
-
|
107
|
-
|
104
|
+
for ( var role in actives ) {
|
105
|
+
b[role] = $(actives[role]);
|
106
|
+
}
|
108
107
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
108
|
+
var inits = callback($, b, block);
|
109
|
+
if ( typeof(inits) == 'object' ) {
|
110
|
+
for ( var i in inits ) {
|
111
|
+
inits[i]($, b, block);
|
112
|
+
}
|
113
113
|
}
|
114
114
|
}
|
115
115
|
});
|
data/lib/evil-blocks-rails.rb
CHANGED
@@ -23,7 +23,9 @@ module EvilBlocks
|
|
23
23
|
#
|
24
24
|
# Copy from role-rails by Sasha Koss.
|
25
25
|
# https://github.com/kossnocorp/role-rails
|
26
|
-
Slim::Parser.default_options[:shortcut]
|
26
|
+
shortcut = Slim::Parser.default_options[:shortcut]
|
27
|
+
shortcut['@'] = { :attr => 'data-role' }
|
28
|
+
shortcut['@.'] = { :attr => ['data-role', 'class'] }
|
27
29
|
Slim::Engine.default_options[:merge_attrs]['data-role'] = ' '
|
28
30
|
end
|
29
31
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evil-blocks-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-06-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sprockets
|