evil-blocks-rails 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +3 -0
- data/lib/assets/javascripts/evil-blocks.js +43 -18
- metadata +2 -2
data/ChangeLog
CHANGED
@@ -109,6 +109,27 @@
|
|
109
109
|
}
|
110
110
|
};
|
111
111
|
|
112
|
+
/**
|
113
|
+
* Create callback wrapper for block listener.
|
114
|
+
*/
|
115
|
+
var blockCallback = function (self, func) {
|
116
|
+
return function () {
|
117
|
+
func.apply(self, arguments);
|
118
|
+
}
|
119
|
+
};
|
120
|
+
|
121
|
+
/**
|
122
|
+
* Create callback wrapper for element listener.
|
123
|
+
*/
|
124
|
+
var elemCallback = function (self, func) {
|
125
|
+
return function () {
|
126
|
+
var args = Array.prototype.slice.call(arguments);
|
127
|
+
var el = $(this);
|
128
|
+
args.unshift(el);
|
129
|
+
func.apply(self, args);
|
130
|
+
}
|
131
|
+
};
|
132
|
+
|
112
133
|
/**
|
113
134
|
* Convert block class to callback.
|
114
135
|
*/
|
@@ -116,26 +137,30 @@
|
|
116
137
|
return function ($, obj, block) {
|
117
138
|
obj.block = block;
|
118
139
|
|
119
|
-
for ( var
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
140
|
+
for ( var name in klass ) {
|
141
|
+
var prop = klass[name];
|
142
|
+
|
143
|
+
(function (name, prop) {
|
144
|
+
if ( name.indexOf('on ') == -1 ) {
|
145
|
+
obj[name] = prop;
|
146
|
+
return;
|
147
|
+
}
|
148
|
+
|
149
|
+
var parts = name.split(' on ');
|
150
|
+
|
151
|
+
if ( parts[1] == 'body' ) {
|
152
|
+
$('body').on(parts[0], blockCallback(obj, prop));
|
153
|
+
|
154
|
+
} else if ( parts[1] == 'window' ) {
|
155
|
+
$(window).on(parts[0], blockCallback(obj, prop));
|
156
|
+
|
157
|
+
} else if ( parts[1] ) {
|
158
|
+
block.on(parts[0], parts[1], elemCallback(obj, prop));
|
159
|
+
|
135
160
|
} else {
|
136
|
-
|
161
|
+
block.on(parts[0], blockCallback(obj, prop));
|
137
162
|
}
|
138
|
-
})(prop);
|
163
|
+
})(name, prop);
|
139
164
|
}
|
140
165
|
|
141
166
|
if ( typeof(obj.init) == 'function' ) {
|
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.
|
4
|
+
version: 0.4.1
|
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-09-
|
12
|
+
date: 2013-09-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sprockets
|