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 CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.3 (Fat Man, 9th August 1945)
2
+ * Add shortcut to Slim to set data-role and class.
3
+ * Run callback on every block copy in page.
4
+
1
5
  == 0.2 (Little Boy, 6th August 1945)
2
6
  * Support non-Rails applications in gem.
3
7
 
@@ -80,36 +80,36 @@
80
80
  */
81
81
  window.evil.block = function (selector, callback) {
82
82
  $(function () {
83
- var block = $(selector);
84
- if ( !block.length ) {
85
- return;
86
- }
83
+ var blocks = $(selector);
84
+ for ( var i = 0; i < blocks.length; i++ ) {
85
+ var block = $(blocks[i]);
87
86
 
88
- var b = function (subselector) {
89
- return $(subselector, block);
90
- };
91
- var actives = { };
92
- block.find('[data-role]').each(function (_, el) {
93
- var roles = el.attributes['data-role'].value.split(' ');
94
- for ( var i = 0; i < roles.length; i++ ) {
95
- var role = roles[i].replace(/-\w/g, function (s) {
96
- return s[1].toUpperCase();
97
- });
98
- if ( !actives[role] ) {
99
- actives[role] = [];
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
- actives[role].push(el);
102
- }
103
- });
102
+ });
104
103
 
105
- for ( var role in actives ) {
106
- b[role] = $(actives[role]);
107
- }
104
+ for ( var role in actives ) {
105
+ b[role] = $(actives[role]);
106
+ }
108
107
 
109
- var inits = callback($, b, block);
110
- if ( typeof(inits) == 'object' ) {
111
- for ( var i in inits ) {
112
- inits[i]($, b, block);
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
  });
@@ -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]['@'] = { :attr => 'data-role' }
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.2.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-05-22 00:00:00.000000000 Z
12
+ date: 2013-06-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sprockets