weld-js-rails 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +37 -0
- data/Rakefile +1 -0
- data/lib/weld-js-rails.rb +2 -0
- data/lib/weld-js-rails/engine.rb +12 -0
- data/lib/weld-js-rails/version.rb +9 -0
- data/vendor/assets/javascripts/weld-jquery.js +15 -0
- data/vendor/assets/javascripts/weld.js +454 -0
- data/vendor/assets/javascripts/weld.min.js +1 -0
- data/weld-js-rails.gemspec +25 -0
- metadata +67 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Weld-js-rails
|
2
|
+
|
3
|
+
Weld! For Rails! So great.
|
4
|
+
|
5
|
+
## Rails 3.1
|
6
|
+
|
7
|
+
This gem vendors weld for browser use in Rails 3.1 and greater. The files will be added to the asset pipeline and available for you to use.
|
8
|
+
|
9
|
+
### Installation
|
10
|
+
|
11
|
+
In your Gemfile, add this line:
|
12
|
+
|
13
|
+
gem "weld-js-rails"
|
14
|
+
|
15
|
+
Then, run `bundle install`.
|
16
|
+
|
17
|
+
Add the following line to application.js
|
18
|
+
|
19
|
+
//= require weld
|
20
|
+
|
21
|
+
You're done!
|
22
|
+
|
23
|
+
### jQuery
|
24
|
+
|
25
|
+
If you'd like weld integrated with jQuery, add the following line to application.js after weld:
|
26
|
+
|
27
|
+
//= require weld-jquery
|
28
|
+
|
29
|
+
Then you can do this:
|
30
|
+
|
31
|
+
$('contacts').weld([ { name: 'John' } ])
|
32
|
+
|
33
|
+
|
34
|
+
## Rails 3.0
|
35
|
+
|
36
|
+
This gem does not support Rails 3.0, just download weld from https://github.com/hij1nx/weld.
|
37
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
@function {jQuery object}
|
3
|
+
Turn weld into a jQuery plugin.
|
4
|
+
@param {object} data
|
5
|
+
The data which will be used for the weld.
|
6
|
+
@param {object} config
|
7
|
+
An optional configuration object.
|
8
|
+
|
9
|
+
Example: $('contacts').weld([ { name: 'John' } ])
|
10
|
+
*/
|
11
|
+
$.fn.weld = function (data, config) {
|
12
|
+
return this.each (function () {
|
13
|
+
weld(this, data, config);
|
14
|
+
});
|
15
|
+
};
|
@@ -0,0 +1,454 @@
|
|
1
|
+
;(function(exports) {
|
2
|
+
// shim out Object.keys
|
3
|
+
// ES5 15.2.3.14
|
4
|
+
// http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
|
5
|
+
if (!Object.keys) {
|
6
|
+
|
7
|
+
var hasDontEnumBug = true,
|
8
|
+
dontEnums = [
|
9
|
+
'toString',
|
10
|
+
'toLocaleString',
|
11
|
+
'valueOf',
|
12
|
+
'hasOwnProperty',
|
13
|
+
'isPrototypeOf',
|
14
|
+
'propertyIsEnumerable',
|
15
|
+
'constructor'
|
16
|
+
],
|
17
|
+
dontEnumsLength = dontEnums.length;
|
18
|
+
|
19
|
+
for (var key in {"toString": null}) {
|
20
|
+
hasDontEnumBug = false;
|
21
|
+
}
|
22
|
+
Object.keys = function keys(object) {
|
23
|
+
|
24
|
+
if (typeof object !== "object" &&
|
25
|
+
typeof object !== "function" ||
|
26
|
+
object === null)
|
27
|
+
{
|
28
|
+
throw new TypeError("Object.keys called on a non-object");
|
29
|
+
}
|
30
|
+
|
31
|
+
var keys = [];
|
32
|
+
for (var name in object) {
|
33
|
+
if (object.hasOwnProperty(name)) {
|
34
|
+
keys.push(name);
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
if (hasDontEnumBug) {
|
39
|
+
for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
|
40
|
+
var dontEnum = dontEnums[i];
|
41
|
+
if (object.hasOwnProperty(dontEnum)) {
|
42
|
+
keys.push(dontEnum);
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}
|
46
|
+
return keys;
|
47
|
+
};
|
48
|
+
}
|
49
|
+
|
50
|
+
|
51
|
+
// Start: DEBUGGING
|
52
|
+
// ----------------
|
53
|
+
|
54
|
+
/* Since weld runs browser/server, ensure there is a console implementation.
|
55
|
+
*/
|
56
|
+
|
57
|
+
var logger = (typeof console === 'undefined') ? { log : function(){} } : console;
|
58
|
+
var nodejs = false;
|
59
|
+
|
60
|
+
if (typeof require !== 'undefined' && !exports.define) {
|
61
|
+
var tty = require('tty');
|
62
|
+
if (tty.isatty && tty.isatty(0)) {
|
63
|
+
nodejs = true;
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
var color = {
|
68
|
+
gray: '\033[37m',
|
69
|
+
darkgray: '\033[40;30m',
|
70
|
+
red: '\033[31m',
|
71
|
+
green: '\033[32m',
|
72
|
+
yellow: '\033[33m',
|
73
|
+
lightblue: '\033[1;34m',
|
74
|
+
cyan: '\033[36m',
|
75
|
+
white: '\033[1;37m'
|
76
|
+
};
|
77
|
+
|
78
|
+
var inputRegex = /input|select|textarea|option|button/i;
|
79
|
+
var imageRegex = /img/i;
|
80
|
+
var depth = 0; // The current depth of the traversal, used for debugging.
|
81
|
+
var successIndicator = nodejs ? (color.green + ' ✓' + color.gray) : ' Success';
|
82
|
+
var failureIndicator = nodejs ? (color.red + ' ✗' + color.gray) : ' Fail';
|
83
|
+
|
84
|
+
var debuggable = function debuggable(name, operation) {
|
85
|
+
|
86
|
+
var label = name.toUpperCase();
|
87
|
+
|
88
|
+
// All of the ops have the same signature, so this is sane.
|
89
|
+
return function(parent, element, key, value) {
|
90
|
+
logger.log(
|
91
|
+
pad(),
|
92
|
+
((nodejs ? (color.gray + '┌ ') : '+ ') + label + ' -'),
|
93
|
+
'parent:', colorize(parent) + ',',
|
94
|
+
'element:', colorize(element) + ',',
|
95
|
+
'key:', colorize(key) + ',',
|
96
|
+
'value:', colorize(value)
|
97
|
+
);
|
98
|
+
|
99
|
+
depth+=1;
|
100
|
+
|
101
|
+
if (operation) {
|
102
|
+
var res = operation(parent, element, key, value);
|
103
|
+
depth-=1;
|
104
|
+
logger.log(pad(), (nodejs ? '└ ' : '+ ') + element + '' + (res !== false ? successIndicator : failureIndicator));
|
105
|
+
return res;
|
106
|
+
}
|
107
|
+
|
108
|
+
depth-=1;
|
109
|
+
d('- OPERATION NOT FOUND: ', label);
|
110
|
+
};
|
111
|
+
};
|
112
|
+
|
113
|
+
/* Generates padding used for indenting debugger statements.
|
114
|
+
*/
|
115
|
+
|
116
|
+
var pad = function pad() {
|
117
|
+
var l = depth, ret = '';
|
118
|
+
while(l--) {
|
119
|
+
ret += nodejs ? ' │ ' : ' | ';
|
120
|
+
}
|
121
|
+
return ret;
|
122
|
+
};
|
123
|
+
|
124
|
+
/* Debugger statement, terse, accepts any number of arguments
|
125
|
+
* that are passed to a logger.log statement.
|
126
|
+
*/
|
127
|
+
|
128
|
+
var d = function d() {
|
129
|
+
var args = Array.prototype.slice.call(arguments);
|
130
|
+
|
131
|
+
// This is done because on the browser you cannot call console.log.apply
|
132
|
+
logger.log(pad(), args.join(' '));
|
133
|
+
};
|
134
|
+
|
135
|
+
var colorize = function colorize(val) {
|
136
|
+
var sval = val+'', u='undefined';
|
137
|
+
if(nodejs) {
|
138
|
+
if(sval === 'false' || sval === 'null' || sval === '' || sval === u || typeof val === u || val === false) {
|
139
|
+
if(sval === '') { sval = '(empty string)' };
|
140
|
+
return color.red + sval + color.gray;
|
141
|
+
}
|
142
|
+
else {
|
143
|
+
return color.yellow + sval + color.gray;
|
144
|
+
}
|
145
|
+
}
|
146
|
+
return sval;
|
147
|
+
};
|
148
|
+
|
149
|
+
// End: DEBUGGING
|
150
|
+
// --------------
|
151
|
+
|
152
|
+
|
153
|
+
/* Weld!
|
154
|
+
* @param {HTMLElement} DOMTarget
|
155
|
+
* The target html node that will be used as the subject of data binding.
|
156
|
+
* @param {Object|Array} data
|
157
|
+
* The data that will be used.
|
158
|
+
* @param {Object} pconfig
|
159
|
+
* The configuration object.
|
160
|
+
*/
|
161
|
+
exports.weld = function weld(DOMTarget, data, pconfig) {
|
162
|
+
|
163
|
+
var parent = DOMTarget.parentNode;
|
164
|
+
var currentOpKey, p, fn, debug;
|
165
|
+
|
166
|
+
/*
|
167
|
+
* Configuration Object.
|
168
|
+
* @member {Object}
|
169
|
+
* Contains an explicit mapping of data-keys to element name/id/classes
|
170
|
+
* @member {Boolean}
|
171
|
+
* Determines if debugging will be enabled.
|
172
|
+
* @method {Boolean|Function}
|
173
|
+
* Determines the method of insertion, can be a functon or false.
|
174
|
+
*/
|
175
|
+
|
176
|
+
var config = {
|
177
|
+
alias : {},
|
178
|
+
debug : false,
|
179
|
+
insert: false // Default to append
|
180
|
+
};
|
181
|
+
|
182
|
+
// Merge the user configuration over the existing config
|
183
|
+
if(pconfig) {
|
184
|
+
for(p in pconfig) {
|
185
|
+
if (pconfig.hasOwnProperty(p)) {
|
186
|
+
config[p] = pconfig[p];
|
187
|
+
}
|
188
|
+
}
|
189
|
+
}
|
190
|
+
|
191
|
+
debug = config.debug;
|
192
|
+
|
193
|
+
/* An interface to the interal operations, implements common
|
194
|
+
* debugging output based on a standard set of parameters.
|
195
|
+
*
|
196
|
+
* @param {Function} operation
|
197
|
+
* The function to call in "debug mode"
|
198
|
+
*/
|
199
|
+
|
200
|
+
var ops = {
|
201
|
+
siblings : function siblings(parent, element, key, value) {
|
202
|
+
var remove = [],
|
203
|
+
sibling,
|
204
|
+
classes,
|
205
|
+
cc,
|
206
|
+
match,
|
207
|
+
siblings = parent.children;
|
208
|
+
cs = siblings.length; // Current Sibling
|
209
|
+
element.weld = {
|
210
|
+
parent : parent,
|
211
|
+
classes : element.className.split(' ')
|
212
|
+
};
|
213
|
+
|
214
|
+
// Find all siblings that match the exact classes that exist in the originally
|
215
|
+
// matched element node
|
216
|
+
while (cs--) {
|
217
|
+
sibling = siblings[cs];
|
218
|
+
|
219
|
+
if (sibling === element) {
|
220
|
+
// If this is not the last item in the list, store where new items should be inserted
|
221
|
+
if (cs < siblings.length) {
|
222
|
+
element.weld.insertBefore = siblings[cs+1];
|
223
|
+
}
|
224
|
+
|
225
|
+
// remove the element here because siblings is a live list.
|
226
|
+
// which means, if you remove it before hand, the length will mismatch and cause problems
|
227
|
+
if (debug) {
|
228
|
+
d('- REMOVE - element:', colorize(element), 'class:', colorize(element.className), 'id:', colorize(element.id));
|
229
|
+
}
|
230
|
+
|
231
|
+
parent.removeChild(element);
|
232
|
+
|
233
|
+
// Check for the same class
|
234
|
+
} else {
|
235
|
+
classes = sibling.className.split(' ');
|
236
|
+
cc = classes.length;
|
237
|
+
match = true;
|
238
|
+
while (cc--) {
|
239
|
+
// TODO: optimize
|
240
|
+
if (element.weld.classes.indexOf(classes[cc]) < 0) {
|
241
|
+
match = false;
|
242
|
+
break;
|
243
|
+
}
|
244
|
+
}
|
245
|
+
|
246
|
+
// This element matched, you win a prize! DIE.
|
247
|
+
if (match) {
|
248
|
+
if (debug) {
|
249
|
+
d('- REMOVE - element:', colorize(sibling), 'class:', colorize(sibling.className), 'id:', colorize(sibling.id));
|
250
|
+
}
|
251
|
+
parent.removeChild(sibling);
|
252
|
+
}
|
253
|
+
}
|
254
|
+
}
|
255
|
+
},
|
256
|
+
traverse : function traverse(parent, element, key, value) {
|
257
|
+
|
258
|
+
var type, target, i, keys, l, obj;
|
259
|
+
var template = element;
|
260
|
+
var templateParent = element.parentNode;
|
261
|
+
|
262
|
+
// LEAF
|
263
|
+
|
264
|
+
if(~({}).toString.call(value).indexOf('Date')) {
|
265
|
+
value = value.toString();
|
266
|
+
}
|
267
|
+
|
268
|
+
if (value.nodeType || typeof value !== 'object') {
|
269
|
+
ops.set(parent, element, key, value);
|
270
|
+
|
271
|
+
// ARRAY / NodeList
|
272
|
+
} else if (value.length && value[0]) {
|
273
|
+
if (templateParent) {
|
274
|
+
ops.siblings(templateParent, template, key, value);
|
275
|
+
} else if (template.weld && template.weld.parent) {
|
276
|
+
templateParent = template.weld.parent;
|
277
|
+
}
|
278
|
+
|
279
|
+
l = value.length;
|
280
|
+
for (i=0; i<l; i++) {
|
281
|
+
if (debug) {
|
282
|
+
d('- CLONE - element:', colorize(element), 'class:', colorize(element.className), 'id:', colorize(element.id));
|
283
|
+
}
|
284
|
+
target = element.cloneNode(true);
|
285
|
+
target.weld = {};
|
286
|
+
|
287
|
+
// Clone weld params
|
288
|
+
if (element.weld) {
|
289
|
+
var keys = Object.keys(element.weld), currentKey = keys.length, weldParam;
|
290
|
+
while(currentKey--) {
|
291
|
+
weldParam = keys[currentKey];
|
292
|
+
target.weld[weldParam] = element.weld[weldParam];
|
293
|
+
}
|
294
|
+
}
|
295
|
+
ops.traverse(templateParent, target, i, value[i]);
|
296
|
+
ops.insert(templateParent, target, i, value[i]);
|
297
|
+
}
|
298
|
+
|
299
|
+
// OBJECT
|
300
|
+
} else {
|
301
|
+
var keys = Object.keys(value), current = keys.length, obj;
|
302
|
+
while (current--) {
|
303
|
+
var lkey = keys[current];
|
304
|
+
obj = value[lkey];
|
305
|
+
target = ops.match(template, element, lkey, obj);
|
306
|
+
|
307
|
+
if (target) {
|
308
|
+
ops.traverse(template, target, lkey, obj);
|
309
|
+
|
310
|
+
// Handle the case where a parent data key doesn't
|
311
|
+
// match a dom node, but the child data object may.
|
312
|
+
// don't continue traversing if the child data object
|
313
|
+
// is not an array/object
|
314
|
+
} else if (target !== false &&
|
315
|
+
typeof obj === 'object' &&
|
316
|
+
Object.keys(obj).length > 0) // TODO: optimize
|
317
|
+
{
|
318
|
+
ops.traverse(templateParent, template, lkey, obj);
|
319
|
+
}
|
320
|
+
}
|
321
|
+
}
|
322
|
+
},
|
323
|
+
elementType : function elementType(parent, element, key, value) {
|
324
|
+
if (element) {
|
325
|
+
var nodeName = element.nodeName;
|
326
|
+
|
327
|
+
if (typeof nodeName === "string") {
|
328
|
+
if (inputRegex.test(nodeName)) {
|
329
|
+
return 'input';
|
330
|
+
}
|
331
|
+
|
332
|
+
if (imageRegex.test(nodeName)) {
|
333
|
+
return 'image';
|
334
|
+
}
|
335
|
+
}
|
336
|
+
}
|
337
|
+
},
|
338
|
+
map : false, // this is a user-defined operation
|
339
|
+
insert : function(parent, element) {
|
340
|
+
// Insert the template back into document
|
341
|
+
if (element.weld && element.weld.insertBefore) {
|
342
|
+
parent.insertBefore(element, element.weld.insertBefore);
|
343
|
+
} else {
|
344
|
+
parent.appendChild(element);
|
345
|
+
}
|
346
|
+
},
|
347
|
+
set : function set(parent, element, key, value) {
|
348
|
+
|
349
|
+
if(ops.map && ops.map(parent, element, key, value) === false) {
|
350
|
+
return false;
|
351
|
+
}
|
352
|
+
|
353
|
+
if(debug) {
|
354
|
+
d('- SET: value is', value.tagName);
|
355
|
+
}
|
356
|
+
|
357
|
+
var type = ops.elementType(parent, element, key, value), res = false;
|
358
|
+
|
359
|
+
if (value && value.nodeType) { // imports.
|
360
|
+
|
361
|
+
if (element.ownerDocument !== value.ownerDocument) {
|
362
|
+
value = element.ownerDocument.importNode(value, true);
|
363
|
+
} else if (value.parentNode) {
|
364
|
+
value.parentNode.removeChild(value);
|
365
|
+
}
|
366
|
+
|
367
|
+
while (element.firstChild) { // clean first.
|
368
|
+
element.removeChild(element.firstChild);
|
369
|
+
}
|
370
|
+
|
371
|
+
element.appendChild(value);
|
372
|
+
res = true;
|
373
|
+
}
|
374
|
+
else if (type === 'input') { // special cases.
|
375
|
+
element.setAttribute('value', value);
|
376
|
+
res = true;
|
377
|
+
}
|
378
|
+
else if (type === 'image') {
|
379
|
+
element.setAttribute('src', value);
|
380
|
+
res = true;
|
381
|
+
}
|
382
|
+
else { // simple text assignment.
|
383
|
+
element.textContent = value;
|
384
|
+
res = true;
|
385
|
+
}
|
386
|
+
return res;
|
387
|
+
},
|
388
|
+
match : function match(parent, element, key, value) {
|
389
|
+
if(typeof config.alias[key] !== 'undefined') {
|
390
|
+
if(typeof config.alias[key] === 'function') {
|
391
|
+
key = config.alias[key](parent, element, key, value) || key;
|
392
|
+
}
|
393
|
+
else if(config.alias[key] === false) {
|
394
|
+
return false;
|
395
|
+
}
|
396
|
+
else {
|
397
|
+
key = config.alias[key];
|
398
|
+
}
|
399
|
+
}
|
400
|
+
|
401
|
+
// Alias can be a node, for explicit binding.
|
402
|
+
// Alias can also be a method that returns a string or DOMElement
|
403
|
+
if (key && key.nodeType) {
|
404
|
+
return key;
|
405
|
+
}
|
406
|
+
|
407
|
+
if(element) {
|
408
|
+
if(element.querySelector) {
|
409
|
+
return element.querySelector('.' + key + ',#' + key + ',[name="' + key + '"]');
|
410
|
+
}
|
411
|
+
else {
|
412
|
+
var els = element.getElementsByTagName('*'), l = els.length, e, i;
|
413
|
+
// find the _first_ best match
|
414
|
+
for (i=0; i<l; i++) {
|
415
|
+
e = els[i];
|
416
|
+
if(e.id === key || e.name === key || e.className.split(' ').indexOf(key) > -1) {
|
417
|
+
return e;
|
418
|
+
}
|
419
|
+
}
|
420
|
+
}
|
421
|
+
}
|
422
|
+
}
|
423
|
+
};
|
424
|
+
|
425
|
+
|
426
|
+
// Allow the caller to overwrite the internals of weld
|
427
|
+
for (currentOpKey in ops) {
|
428
|
+
if (ops.hasOwnProperty(currentOpKey)) {
|
429
|
+
currentOp = ops[currentOpKey];
|
430
|
+
fn = config[currentOpKey] || ops[currentOpKey];
|
431
|
+
|
432
|
+
if (debug) {
|
433
|
+
fn = debuggable(currentOpKey, fn);
|
434
|
+
}
|
435
|
+
|
436
|
+
ops[currentOpKey] = fn;
|
437
|
+
}
|
438
|
+
}
|
439
|
+
|
440
|
+
// Kick it off
|
441
|
+
ops.traverse(null, DOMTarget, null, data);
|
442
|
+
|
443
|
+
if (config.debug) {
|
444
|
+
logger.log(DOMTarget.outerHTML);
|
445
|
+
}
|
446
|
+
};
|
447
|
+
|
448
|
+
if (typeof exports.define !== "undefined" && exports.define.amd) {
|
449
|
+
define('weld',[], function() {return window.weld });
|
450
|
+
}
|
451
|
+
|
452
|
+
})((typeof exports === "undefined") ? window : exports);
|
453
|
+
|
454
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
(function(i){var o=(typeof console==="undefined")?{log:function(){}}:console;var a=false;if(typeof require!=="undefined"){var m=require("tty");if(m.isatty&&m.isatty(0)){a=true}}var h={gray:"\033[37m",darkgray:"\033[40;30m",red:"\033[31m",green:"\033[32m",yellow:"\033[33m",lightblue:"\033[1;34m",cyan:"\033[36m",white:"\033[1;37m"},c=/input|select|textarea|option|button/i,g=/img/i,l=0,f=a?(h.green+" ✓"+h.gray):" Success",k=a?(h.red+" ✗"+h.gray):" Fail",j=function j(r,d){var q=r.toUpperCase();return function(v,u,t,w){o.log(e(),((a?(h.gray+"┌ "):"+ ")+q+" -"),"parent:",b(v)+",","element:",b(u)+",","key:",b(t)+",","value:",b(w));l+=1;if(d){var s=d(v,u,t,w);l-=1;o.log(e(),(a?"└ ":"+ ")+u+""+(s!==false?f:k));return s}l-=1;n("- OPERATION NOT FOUND: ",q)}},e=function e(){var d=l,q="";while(d--){q+=a?" │ ":" | "}return q},n=function n(){var d=Array.prototype.slice.call(arguments);o.log(e(),d.join(" "))},b=function b(r){var q=r+"",d="undefined";if(a){if(q==="false"||q==="null"||q===""||q===d||typeof r===d||r===false){if(q===""){q="(empty string)"}return h.red+q+h.gray}else{return h.yellow+q+h.gray}}return q};i.weld=function p(y,u,D){var t={alias:{},debug:false,insert:false},s={siblings:function A(L,G,N,K){var H=[],M,F,E,I,J=L.children;cs=J.length;G.weld={parent:L,classes:G.className.split(" ")};while(cs--){M=J[cs];if(M===G){if(cs<J.length){G.weld.insertBefore=J[cs+1]}if(d){n("- REMOVE - element:",b(G),"class:",b(G.className),"id:",b(G.id))}L.removeChild(G)}else{F=M.className.split(" ");E=F.length;I=true;while(E--){if(G.weld.classes.indexOf(F[E])<0){I=false;break}}if(I){if(d){n("- REMOVE - element:",b(M),"class:",b(M.className),"id:",b(M.id))}L.removeChild(M)}}}},traverse:function w(O,G,Q,N){var L,K,H,S,E,F,P=G,R=G.parentNode;if(N.nodeType||typeof N!=="object"){s.set(O,G,Q,N)}else{if(N.length&&N[0]){if(R){s.siblings(R,P,Q,N)}else{if(P.weld&&P.weld.parent){R=P.weld.parent}}E=N.length;for(H=0;H<E;H++){if(d){n("- CLONE - element:",b(G),"class:",b(G.className),"id:",b(G.id))}K=G.cloneNode(true);K.weld={};if(G.weld){if(Object.keys){var S=Object.keys(G.weld),M=S.length,I;while(M--){I=S[M];K.weld[I]=G.weld[I]}}else{for(var I in G.weld){if(G.weld.hasOwnProperty(I)){K.weld[I]=G.weld[I]}}}}s.traverse(R,K,H,N[H]);s.insert(R,K)}}else{if(Object.keys){var S=Object.keys(N),J=S.length;while(J--){Q=S[J];F=N[Q];K=s.match(P,G,Q,F);if(K){s.traverse(P,K,Q,F)}}}else{for(Q in N){if(N.hasOwnProperty(Q)){F=N[Q];K=s.match(P,G,Q,F);if(K){s.traverse(P,K,Q,F)}}}}}}},elementType:function x(G,F,E,H){if(F){var I=F.nodeName;if(typeof I==="string"){if(c.test(I)){return"input"}if(g.test(I)){return"image"}}}},map:false,insert:function(F,E){if(E.weld&&E.weld.insertBefore){F.insertBefore(E,E.weld.insertBefore)}else{F.appendChild(E)}},set:function C(I,G,F,J){if(s.map&&s.map(I,G,F,J)===false){return false}if(d){n("- SET: value is",J.tagName)}var H=s.elementType(I,G,F,J),E=false;if(J&&J.nodeType){if(G.ownerDocument!==J.ownerDocument){J=G.ownerDocument.importNode(J,true)}else{if(J.parentNode){J.parentNode.removeChild(J)}}while(G.firstChild){G.removeChild(G.firstChild)}G.appendChild(J);E=true}else{if(H==="input"){G.setAttribute("value",J);E=true}else{if(H==="image"){G.setAttribute("src",J);E=true}else{G.textContent=J;E=true}}}return E},match:function v(J,I,H,K){if(typeof t.alias[H]!=="undefined"){if(typeof t.alias[H]==="function"){H=t.alias[H](J,I,H,K)||H}else{if(t.alias[H]===false){return false}else{H=t.alias[H]}}}if(H&&H.nodeType){return H}if(I){if(I.querySelector){return I.querySelector("."+H+",#"+H+',[name="'+H+'"]')}else{var G=I.getElementsByTagName("*"),E=G.length,L,F;for(F=0;F<E;F++){L=G[F];if(L.id===H||L.name===H||L.className.split(" ").indexOf(H)>-1){return L}}}}}},B=y.parentNode,q,r,z,d;if(D){for(r in D){if(D.hasOwnProperty(r)){t[r]=D[r]}}}d=t.debug;for(q in s){if(s.hasOwnProperty(q)){currentOp=s[q];z=t[q]||s[q];if(d){z=j(q,z)}s[q]=z}}s.traverse(null,y,null,u);if(t.debug){o.log(B.innerHTML)}}})((typeof exports==="undefined")?window:exports);
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "weld-js-rails/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "weld-js-rails"
|
7
|
+
s.version = Weld::Js::Rails::VERSION
|
8
|
+
s.authors = ["Amiel Martin"]
|
9
|
+
s.email = ["amiel@carnesmedia.com"]
|
10
|
+
s.homepage = "http://github.com/amiel/weld-js-rails"
|
11
|
+
s.summary = %q{A gem to automate using weld with Rails 3.1}
|
12
|
+
# s.description = %q{TODO: Write a gem description}
|
13
|
+
|
14
|
+
|
15
|
+
s.rubyforge_project = "weld-js-rails"
|
16
|
+
|
17
|
+
s.add_dependency "railties", "~> 3.1"
|
18
|
+
|
19
|
+
s.files = `git ls-files`.split("\n")
|
20
|
+
s.require_path = "lib"
|
21
|
+
|
22
|
+
# specify any dependencies here; for example:
|
23
|
+
# s.add_development_dependency "rspec"
|
24
|
+
# s.add_runtime_dependency "rest-client"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: weld-js-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Amiel Martin
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-09-02 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: railties
|
16
|
+
requirement: &70267834482040 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.1'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70267834482040
|
25
|
+
description:
|
26
|
+
email:
|
27
|
+
- amiel@carnesmedia.com
|
28
|
+
executables: []
|
29
|
+
extensions: []
|
30
|
+
extra_rdoc_files: []
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- Gemfile
|
34
|
+
- README.md
|
35
|
+
- Rakefile
|
36
|
+
- lib/weld-js-rails.rb
|
37
|
+
- lib/weld-js-rails/engine.rb
|
38
|
+
- lib/weld-js-rails/version.rb
|
39
|
+
- vendor/assets/javascripts/weld-jquery.js
|
40
|
+
- vendor/assets/javascripts/weld.js
|
41
|
+
- vendor/assets/javascripts/weld.min.js
|
42
|
+
- weld-js-rails.gemspec
|
43
|
+
homepage: http://github.com/amiel/weld-js-rails
|
44
|
+
licenses: []
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options: []
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubyforge_project: weld-js-rails
|
63
|
+
rubygems_version: 1.8.10
|
64
|
+
signing_key:
|
65
|
+
specification_version: 3
|
66
|
+
summary: A gem to automate using weld with Rails 3.1
|
67
|
+
test_files: []
|