cash-rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e381bfb258ac25363624cb983ed93886f81f3fb7
4
+ data.tar.gz: 7484d53ec3937aff052206ec4f2f40c945eedd15
5
+ SHA512:
6
+ metadata.gz: e88e454e90ae4e1e3009cbfe95b5ddfa08bb626a39ec966899337cedd70d87bf5b1defa37d0a3e5f1c3f5d9d4ac40d43d44d83ca50e6d8c7e8724184148f6607
7
+ data.tar.gz: b1a70849ff54528f81ed300c2fcdf26a1279191a664acf64b0826cd7008051b860ee625d97f8b814c5c9a4fd61b151b273234e26d7a3eb66143e7b992f3ddee8
@@ -0,0 +1,3 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Martin Jagusch
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,14 @@
1
+ # cash-rails
2
+
3
+ Provides [cash](https://github.com/kenwheeler/cash), an absurdly small jQuery alternative for modern browsers, for your Rails application.
4
+
5
+
6
+ ## Installation
7
+
8
+ Add the following line to your Gemfile.
9
+
10
+ gem 'cash-rails'
11
+
12
+ The cash JavaScript files will be added to the asset pipeline and available for you to use. If they're not already in `app/assets/javascripts/application.js` by default, add these lines:
13
+
14
+ //= require cash
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,18 @@
1
+ require File.expand_path('../lib/cash/rails/version', __FILE__)
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'cash-rails'
5
+ spec.version = Cash::Rails::VERSION
6
+ spec.authors = ['Martin Jagusch']
7
+ spec.email = ['_@mj.io']
8
+ spec.summary = 'Provides cash, an absurdly small jQuery alternative for modern browsers, for your Rails application.'
9
+ spec.description = 'Cash is a small library for modern browsers that provides jQuery style syntax for manipulating the DOM'
10
+ spec.homepage = 'https://github.com/mjio/cash-rails'
11
+ spec.license = 'MIT'
12
+
13
+ spec.files = `git ls-files -z`.split("\x0")
14
+ spec.require_paths = ['lib']
15
+
16
+ spec.add_development_dependency 'bundler', '~> 1.12'
17
+ spec.add_development_dependency 'rake', '~> 10.0'
18
+ end
@@ -0,0 +1,5 @@
1
+ module Cash
2
+ module Rails
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
@@ -0,0 +1,870 @@
1
+ "use strict";
2
+
3
+ /*! cash-dom 1.3.4, https://github.com/kenwheeler/cash @license MIT */
4
+ (function (root, factory) {
5
+ if (typeof define === "function" && define.amd) {
6
+ define(factory);
7
+ } else if (typeof exports !== "undefined") {
8
+ module.exports = factory();
9
+ } else {
10
+ root.cash = root.$ = factory();
11
+ }
12
+ })(this, function () {
13
+ var doc = document, win = window, ArrayProto = Array.prototype, slice = ArrayProto.slice, filter = ArrayProto.filter, push = ArrayProto.push;
14
+
15
+ var noop = function () {}, isFunction = function (item) {
16
+ return typeof item === typeof noop;
17
+ }, isString = function (item) {
18
+ return typeof item === typeof "";
19
+ };
20
+
21
+ var idMatch = /^#[\w-]*$/, classMatch = /^\.[\w-]*$/, htmlMatch = /<.+>/, singlet = /^\w+$/;
22
+
23
+ function find(selector, context) {
24
+ context = context || doc;
25
+ var elems = (classMatch.test(selector) ? context.getElementsByClassName(selector.slice(1)) : singlet.test(selector) ? context.getElementsByTagName(selector) : context.querySelectorAll(selector));
26
+ return elems;
27
+ }
28
+
29
+ var frag, tmp;
30
+ function parseHTML(str) {
31
+ frag = frag || doc.createDocumentFragment();
32
+ tmp = tmp || frag.appendChild(doc.createElement("div"));
33
+ tmp.innerHTML = str;
34
+ return tmp.childNodes;
35
+ }
36
+
37
+ function onReady(fn) {
38
+ if (doc.readyState !== "loading") {
39
+ fn();
40
+ } else {
41
+ doc.addEventListener("DOMContentLoaded", fn);
42
+ }
43
+ }
44
+
45
+ function Init(selector, context) {
46
+ if (!selector) {
47
+ return this;
48
+ }
49
+
50
+ // If already a cash collection, don't do any further processing
51
+ if (selector.cash && selector !== win) {
52
+ return selector;
53
+ }
54
+
55
+ var elems = selector, i = 0, length;
56
+
57
+ if (isString(selector)) {
58
+ elems = (idMatch.test(selector) ?
59
+ // If an ID use the faster getElementById check
60
+ doc.getElementById(selector.slice(1)) : htmlMatch.test(selector) ?
61
+ // If HTML, parse it into real elements
62
+ parseHTML(selector) :
63
+ // else use `find`
64
+ find(selector, context));
65
+
66
+ // If function, use as shortcut for DOM ready
67
+ } else if (isFunction(selector)) {
68
+ onReady(selector);return this;
69
+ }
70
+
71
+ if (!elems) {
72
+ return this;
73
+ }
74
+
75
+ // If a single DOM element is passed in or received via ID, return the single element
76
+ if (elems.nodeType || elems === win) {
77
+ this[0] = elems;
78
+ this.length = 1;
79
+ } else {
80
+ // Treat like an array and loop through each item.
81
+ length = this.length = elems.length;
82
+ for (; i < length; i++) {
83
+ this[i] = elems[i];
84
+ }
85
+ }
86
+
87
+ return this;
88
+ }
89
+
90
+ function cash(selector, context) {
91
+ return new Init(selector, context);
92
+ }
93
+
94
+ var fn = cash.fn = cash.prototype = Init.prototype = { // jshint ignore:line
95
+ constructor: cash,
96
+ cash: true,
97
+ length: 0,
98
+ push: push,
99
+ splice: ArrayProto.splice,
100
+ map: ArrayProto.map,
101
+ init: Init
102
+ };
103
+
104
+ cash.parseHTML = parseHTML;
105
+ cash.noop = noop;
106
+ cash.isFunction = isFunction;
107
+ cash.isString = isString;
108
+
109
+ cash.extend = fn.extend = function (target) {
110
+ target = target || {};
111
+
112
+ var args = slice.call(arguments), length = args.length, i = 1;
113
+
114
+ if (args.length === 1) {
115
+ target = this;
116
+ i = 0;
117
+ }
118
+
119
+ for (; i < length; i++) {
120
+ if (!args[i]) {
121
+ continue;
122
+ }
123
+ for (var key in args[i]) {
124
+ if (args[i].hasOwnProperty(key)) {
125
+ target[key] = args[i][key];
126
+ }
127
+ }
128
+ }
129
+
130
+ return target;
131
+ };
132
+
133
+ function each(collection, callback) {
134
+ var l = collection.length, i = 0;
135
+
136
+ for (; i < l; i++) {
137
+ if (callback.call(collection[i], collection[i], i, collection) === false) {
138
+ break;
139
+ }
140
+ }
141
+ }
142
+
143
+ function matches(el, selector) {
144
+ var m = el && (el.matches || el.webkitMatchesSelector || el.mozMatchesSelector || el.msMatchesSelector || el.oMatchesSelector);
145
+ return !!m && m.call(el, selector);
146
+ }
147
+
148
+ function unique(collection) {
149
+ return cash(slice.call(collection).filter(function (item, index, self) {
150
+ return self.indexOf(item) === index;
151
+ }));
152
+ }
153
+
154
+ cash.extend({
155
+ merge: function (first, second) {
156
+ var len = +second.length, i = first.length, j = 0;
157
+
158
+ for (; j < len; i++, j++) {
159
+ first[i] = second[j];
160
+ }
161
+
162
+ first.length = i;
163
+ return first;
164
+ },
165
+
166
+ each: each,
167
+ matches: matches,
168
+ unique: unique,
169
+ isArray: Array.isArray,
170
+ isNumeric: function (n) {
171
+ return !isNaN(parseFloat(n)) && isFinite(n);
172
+ }
173
+
174
+ });
175
+
176
+ var uid = cash.uid = "_cash" + Date.now();
177
+
178
+ function getDataCache(node) {
179
+ return (node[uid] = node[uid] || {});
180
+ }
181
+
182
+ function setData(node, key, value) {
183
+ return (getDataCache(node)[key] = value);
184
+ }
185
+
186
+ function getData(node, key) {
187
+ var c = getDataCache(node);
188
+ if (c[key] === undefined) {
189
+ c[key] = node.dataset ? node.dataset[key] : cash(node).attr("data-" + key);
190
+ }
191
+ return c[key];
192
+ }
193
+
194
+ function removeData(node, key) {
195
+ var c = getDataCache(node);
196
+ if (c) {
197
+ delete c[key];
198
+ } else if (node.dataset) {
199
+ delete node.dataset[key];
200
+ } else {
201
+ cash(node).removeAttr("data-" + name);
202
+ }
203
+ }
204
+
205
+ fn.extend({
206
+ data: function (name, value) {
207
+ if (isString(name)) {
208
+ return (value === undefined ? getData(this[0], name) : this.each(function (v) {
209
+ return setData(v, name, value);
210
+ }));
211
+ }
212
+
213
+ for (var key in name) {
214
+ this.data(key, name[key]);
215
+ }
216
+
217
+ return this;
218
+ },
219
+
220
+ removeData: function (key) {
221
+ return this.each(function (v) {
222
+ return removeData(v, key);
223
+ });
224
+ }
225
+
226
+ });
227
+
228
+ var notWhiteMatch = /\S+/g;
229
+
230
+ function getClasses(c) {
231
+ return isString(c) && c.match(notWhiteMatch);
232
+ }
233
+
234
+ function hasClass(v, c) {
235
+ return (v.classList ? v.classList.contains(c) : new RegExp("(^| )" + c + "( |$)", "gi").test(v.className));
236
+ }
237
+
238
+ function addClass(v, c, spacedName) {
239
+ if (v.classList) {
240
+ v.classList.add(c);
241
+ } else if (spacedName.indexOf(" " + c + " ")) {
242
+ v.className += " " + c;
243
+ }
244
+ }
245
+
246
+ function removeClass(v, c) {
247
+ if (v.classList) {
248
+ v.classList.remove(c);
249
+ } else {
250
+ v.className = v.className.replace(c, "");
251
+ }
252
+ }
253
+
254
+ fn.extend({
255
+ addClass: function (c) {
256
+ var classes = getClasses(c);
257
+
258
+ return (classes ? this.each(function (v) {
259
+ var spacedName = " " + v.className + " ";
260
+ each(classes, function (c) {
261
+ addClass(v, c, spacedName);
262
+ });
263
+ }) : this);
264
+ },
265
+
266
+ attr: function (name, value) {
267
+ if (!name) {
268
+ return undefined;
269
+ }
270
+
271
+ if (isString(name)) {
272
+ if (value === undefined) {
273
+ return this[0] ? this[0].getAttribute ? this[0].getAttribute(name) : this[0][name] : undefined;
274
+ }
275
+
276
+ return this.each(function (v) {
277
+ if (v.setAttribute) {
278
+ v.setAttribute(name, value);
279
+ } else {
280
+ v[name] = value;
281
+ }
282
+ });
283
+ }
284
+
285
+ for (var key in name) {
286
+ this.attr(key, name[key]);
287
+ }
288
+
289
+ return this;
290
+ },
291
+
292
+ hasClass: function (c) {
293
+ var check = false, classes = getClasses(c);
294
+ if (classes && classes.length) {
295
+ this.each(function (v) {
296
+ check = hasClass(v, classes[0]);
297
+ return !check;
298
+ });
299
+ }
300
+ return check;
301
+ },
302
+
303
+ prop: function (name, value) {
304
+ if (isString(name)) {
305
+ return (value === undefined ? this[0][name] : this.each(function (v) {
306
+ v[name] = value;
307
+ }));
308
+ }
309
+
310
+ for (var key in name) {
311
+ this.prop(key, name[key]);
312
+ }
313
+
314
+ return this;
315
+ },
316
+
317
+ removeAttr: function (name) {
318
+ return this.each(function (v) {
319
+ if (v.removeAttribute) {
320
+ v.removeAttribute(name);
321
+ } else {
322
+ delete v[name];
323
+ }
324
+ });
325
+ },
326
+
327
+ removeClass: function (c) {
328
+ if (!arguments.length) {
329
+ return this.attr("class", "");
330
+ }
331
+ var classes = getClasses(c);
332
+ return (classes ? this.each(function (v) {
333
+ each(classes, function (c) {
334
+ removeClass(v, c);
335
+ });
336
+ }) : this);
337
+ },
338
+
339
+ removeProp: function (name) {
340
+ return this.each(function (v) {
341
+ delete v[name];
342
+ });
343
+ },
344
+
345
+ toggleClass: function (c, state) {
346
+ if (state !== undefined) {
347
+ return this[state ? "addClass" : "removeClass"](c);
348
+ }
349
+ var classes = getClasses(c);
350
+ return (classes ? this.each(function (v) {
351
+ var spacedName = " " + v.className + " ";
352
+ each(classes, function (c) {
353
+ if (hasClass(v, c)) {
354
+ removeClass(v, c);
355
+ } else {
356
+ addClass(v, c, spacedName);
357
+ }
358
+ });
359
+ }) : this);
360
+ } });
361
+
362
+ fn.extend({
363
+ add: function (selector, context) {
364
+ return unique(cash.merge(this, cash(selector, context)));
365
+ },
366
+
367
+ each: function (callback) {
368
+ each(this, callback);
369
+ return this;
370
+ },
371
+
372
+ eq: function (index) {
373
+ return cash(this.get(index));
374
+ },
375
+
376
+ filter: function (selector) {
377
+ return cash(filter.call(this, (isString(selector) ? function (e) {
378
+ return matches(e, selector);
379
+ } : selector)));
380
+ },
381
+
382
+ first: function () {
383
+ return this.eq(0);
384
+ },
385
+
386
+ get: function (index) {
387
+ if (index === undefined) {
388
+ return slice.call(this);
389
+ }
390
+ return (index < 0 ? this[index + this.length] : this[index]);
391
+ },
392
+
393
+ index: function (elem) {
394
+ var child = elem ? cash(elem)[0] : this[0], collection = elem ? this : cash(child).parent().children();
395
+ return slice.call(collection).indexOf(child);
396
+ },
397
+
398
+ last: function () {
399
+ return this.eq(-1);
400
+ }
401
+
402
+ });
403
+
404
+ var camelCase = (function () {
405
+ var camelRegex = /(?:^\w|[A-Z]|\b\w)/g, whiteSpace = /[\s-_]+/g;
406
+ return function (str) {
407
+ return str.replace(camelRegex, function (letter, index) {
408
+ return letter[index === 0 ? "toLowerCase" : "toUpperCase"]();
409
+ }).replace(whiteSpace, "");
410
+ };
411
+ }());
412
+
413
+ var getPrefixedProp = (function () {
414
+ var cache = {}, doc = document, div = doc.createElement("div"), style = div.style;
415
+
416
+ return function (prop) {
417
+ prop = camelCase(prop);
418
+ if (cache[prop]) {
419
+ return cache[prop];
420
+ }
421
+
422
+ var ucProp = prop.charAt(0).toUpperCase() + prop.slice(1), prefixes = ["webkit", "moz", "ms", "o"], props = (prop + " " + (prefixes).join(ucProp + " ") + ucProp).split(" ");
423
+
424
+ each(props, function (p) {
425
+ if (p in style) {
426
+ cache[p] = prop = cache[prop] = p;
427
+ return false;
428
+ }
429
+ });
430
+
431
+ return cache[prop];
432
+ };
433
+ }());
434
+
435
+ cash.prefixedProp = getPrefixedProp;
436
+ cash.camelCase = camelCase;
437
+
438
+ fn.extend({
439
+ css: function (prop, value) {
440
+ if (isString(prop)) {
441
+ prop = getPrefixedProp(prop);
442
+ return (arguments.length > 1 ? this.each(function (v) {
443
+ return v.style[prop] = value;
444
+ }) : win.getComputedStyle(this[0])[prop]);
445
+ }
446
+
447
+ for (var key in prop) {
448
+ this.css(key, prop[key]);
449
+ }
450
+
451
+ return this;
452
+ }
453
+
454
+ });
455
+
456
+ function compute(el, prop) {
457
+ return parseInt(win.getComputedStyle(el[0], null)[prop], 10) || 0;
458
+ }
459
+
460
+ each(["Width", "Height"], function (v) {
461
+ var lower = v.toLowerCase();
462
+
463
+ fn[lower] = function () {
464
+ return this[0].getBoundingClientRect()[lower];
465
+ };
466
+
467
+ fn["inner" + v] = function () {
468
+ return this[0]["client" + v];
469
+ };
470
+
471
+ fn["outer" + v] = function (margins) {
472
+ return this[0]["offset" + v] + (margins ? compute(this, "margin" + (v === "Width" ? "Left" : "Top")) + compute(this, "margin" + (v === "Width" ? "Right" : "Bottom")) : 0);
473
+ };
474
+ });
475
+
476
+ function registerEvent(node, eventName, callback) {
477
+ var eventCache = getData(node, "_cashEvents") || setData(node, "_cashEvents", {});
478
+ eventCache[eventName] = eventCache[eventName] || [];
479
+ eventCache[eventName].push(callback);
480
+ node.addEventListener(eventName, callback);
481
+ }
482
+
483
+ function removeEvent(node, eventName, callback) {
484
+ var eventCache = getData(node, "_cashEvents")[eventName];
485
+ if (callback) {
486
+ node.removeEventListener(eventName, callback);
487
+ } else {
488
+ each(eventCache, function (event) {
489
+ node.removeEventListener(eventName, event);
490
+ });
491
+ eventCache = [];
492
+ }
493
+ }
494
+
495
+ fn.extend({
496
+ off: function (eventName, callback) {
497
+ return this.each(function (v) {
498
+ return removeEvent(v, eventName, callback);
499
+ });
500
+ },
501
+
502
+ on: function (eventName, delegate, callback, runOnce) {
503
+ // jshint ignore:line
504
+
505
+ var originalCallback;
506
+
507
+ if (!isString(eventName)) {
508
+ for (var key in eventName) {
509
+ this.on(key, delegate, eventName[key]);
510
+ }
511
+ return this;
512
+ }
513
+
514
+ if (isFunction(delegate)) {
515
+ callback = delegate;
516
+ delegate = null;
517
+ }
518
+
519
+ if (eventName === "ready") {
520
+ onReady(callback);
521
+ return this;
522
+ }
523
+
524
+ if (delegate) {
525
+ originalCallback = callback;
526
+ callback = function (e) {
527
+ var t = e.target;
528
+
529
+ while (!matches(t, delegate)) {
530
+ if (t === this) {
531
+ return (t = false);
532
+ }
533
+ t = t.parentNode;
534
+ }
535
+
536
+ if (t) {
537
+ originalCallback.call(t, e);
538
+ }
539
+ };
540
+ }
541
+
542
+ return this.each(function (v) {
543
+ var finalCallback = callback;
544
+ if (runOnce) {
545
+ finalCallback = function () {
546
+ callback.apply(this, arguments);
547
+ removeEvent(v, eventName, finalCallback);
548
+ };
549
+ }
550
+ registerEvent(v, eventName, finalCallback);
551
+ });
552
+ },
553
+
554
+ one: function (eventName, delegate, callback) {
555
+ return this.on(eventName, delegate, callback, true);
556
+ },
557
+
558
+ ready: onReady,
559
+
560
+ trigger: function (eventName, data) {
561
+ var evt = doc.createEvent("HTMLEvents");
562
+ evt.data = data;
563
+ evt.initEvent(eventName, true, false);
564
+ return this.each(function (v) {
565
+ return v.dispatchEvent(evt);
566
+ });
567
+ }
568
+
569
+ });
570
+
571
+ function encode(name, value) {
572
+ return "&" + encodeURIComponent(name) + "=" + encodeURIComponent(value).replace(/%20/g, "+");
573
+ }
574
+ function isCheckable(field) {
575
+ return field.type === "radio" || field.type === "checkbox";
576
+ }
577
+
578
+ var formExcludes = ["file", "reset", "submit", "button"];
579
+
580
+ fn.extend({
581
+ serialize: function () {
582
+ var formEl = this[0].elements, query = "";
583
+
584
+ each(formEl, function (field) {
585
+ if (field.name && formExcludes.indexOf(field.type) < 0) {
586
+ if (field.type === "select-multiple") {
587
+ each(field.options, function (o) {
588
+ if (o.selected) {
589
+ query += encode(field.name, o.value);
590
+ }
591
+ });
592
+ } else if (!isCheckable(field) || (isCheckable(field) && field.checked)) {
593
+ query += encode(field.name, field.value);
594
+ }
595
+ }
596
+ });
597
+
598
+ return query.substr(1);
599
+ },
600
+
601
+ val: function (value) {
602
+ if (value === undefined) {
603
+ return this[0].value;
604
+ } else {
605
+ return this.each(function (v) {
606
+ return v.value = value;
607
+ });
608
+ }
609
+ }
610
+
611
+ });
612
+
613
+ function insertElement(el, child, prepend) {
614
+ if (prepend) {
615
+ var first = el.childNodes[0];
616
+ el.insertBefore(child, first);
617
+ } else {
618
+ el.appendChild(child);
619
+ }
620
+ }
621
+
622
+ function insertContent(parent, child, prepend) {
623
+ var str = isString(child);
624
+
625
+ if (!str && child.length) {
626
+ each(child, function (v) {
627
+ return insertContent(parent, v, prepend);
628
+ });
629
+ return;
630
+ }
631
+
632
+ each(parent, str ? function (v) {
633
+ return v.insertAdjacentHTML(prepend ? "afterbegin" : "beforeend", child);
634
+ } : function (v, i) {
635
+ return insertElement(v, (i === 0 ? child : child.cloneNode(true)), prepend);
636
+ });
637
+ }
638
+
639
+ fn.extend({
640
+ after: function (selector) {
641
+ cash(selector).insertAfter(this);
642
+ return this;
643
+ },
644
+
645
+ append: function (content) {
646
+ insertContent(this, content);
647
+ return this;
648
+ },
649
+
650
+ appendTo: function (parent) {
651
+ insertContent(cash(parent), this);
652
+ return this;
653
+ },
654
+
655
+ before: function (selector) {
656
+ cash(selector).insertBefore(this);
657
+ return this;
658
+ },
659
+
660
+ clone: function () {
661
+ return cash(this.map(function (v) {
662
+ return v.cloneNode(true);
663
+ }));
664
+ },
665
+
666
+ empty: function () {
667
+ this.html("");
668
+ return this;
669
+ },
670
+
671
+ html: function (content) {
672
+ if (content === undefined) {
673
+ return this[0].innerHTML;
674
+ }
675
+ var source = (content.nodeType ? content[0].outerHTML : content);
676
+ return this.each(function (v) {
677
+ return v.innerHTML = source;
678
+ });
679
+ },
680
+
681
+ insertAfter: function (selector) {
682
+ var _this = this;
683
+
684
+
685
+ cash(selector).each(function (el, i) {
686
+ var parent = el.parentNode, sibling = el.nextSibling;
687
+ _this.each(function (v) {
688
+ parent.insertBefore((i === 0 ? v : v.cloneNode(true)), sibling);
689
+ });
690
+ });
691
+
692
+ return this;
693
+ },
694
+
695
+ insertBefore: function (selector) {
696
+ var _this2 = this;
697
+ cash(selector).each(function (el, i) {
698
+ var parent = el.parentNode;
699
+ _this2.each(function (v) {
700
+ parent.insertBefore((i === 0 ? v : v.cloneNode(true)), el);
701
+ });
702
+ });
703
+ return this;
704
+ },
705
+
706
+ prepend: function (content) {
707
+ insertContent(this, content, true);
708
+ return this;
709
+ },
710
+
711
+ prependTo: function (parent) {
712
+ insertContent(cash(parent), this, true);
713
+ return this;
714
+ },
715
+
716
+ remove: function () {
717
+ return this.each(function (v) {
718
+ return v.parentNode.removeChild(v);
719
+ });
720
+ },
721
+
722
+ text: function (content) {
723
+ if (content === undefined) {
724
+ return this[0].textContent;
725
+ }
726
+ return this.each(function (v) {
727
+ return v.textContent = content;
728
+ });
729
+ }
730
+
731
+ });
732
+
733
+ var docEl = doc.documentElement;
734
+
735
+ fn.extend({
736
+ position: function () {
737
+ var el = this[0];
738
+ return {
739
+ left: el.offsetLeft,
740
+ top: el.offsetTop
741
+ };
742
+ },
743
+
744
+ offset: function () {
745
+ var rect = this[0].getBoundingClientRect();
746
+ return {
747
+ top: rect.top + win.pageYOffset - docEl.clientTop,
748
+ left: rect.left + win.pageXOffset - docEl.clientLeft
749
+ };
750
+ },
751
+
752
+ offsetParent: function () {
753
+ return cash(this[0].offsetParent);
754
+ }
755
+
756
+ });
757
+
758
+ function directCompare(el, selector) {
759
+ return el === selector;
760
+ }
761
+
762
+ fn.extend({
763
+ children: function (selector) {
764
+ var elems = [];
765
+ this.each(function (el) {
766
+ push.apply(elems, el.children);
767
+ });
768
+ elems = unique(elems);
769
+
770
+ return (!selector ? elems : elems.filter(function (v) {
771
+ return matches(v, selector);
772
+ }));
773
+ },
774
+
775
+ closest: function (selector) {
776
+ if (!selector || matches(this[0], selector)) {
777
+ return this;
778
+ }
779
+ return this.parent().closest(selector);
780
+ },
781
+
782
+ is: function (selector) {
783
+ if (!selector) {
784
+ return false;
785
+ }
786
+
787
+ var match = false, comparator = (isString(selector) ? matches : selector.cash ? function (el) {
788
+ return selector.is(el);
789
+ } : directCompare);
790
+
791
+ this.each(function (el, i) {
792
+ match = comparator(el, selector, i);
793
+ return !match;
794
+ });
795
+
796
+ return match;
797
+ },
798
+
799
+ find: function (selector) {
800
+ if (!selector) {
801
+ return cash();
802
+ }
803
+
804
+ var elems = [];
805
+ this.each(function (el) {
806
+ push.apply(elems, find(selector, el));
807
+ });
808
+
809
+ return unique(elems);
810
+ },
811
+
812
+ has: function (selector) {
813
+ return filter.call(this, function (el) {
814
+ return cash(el).find(selector).length !== 0;
815
+ });
816
+ },
817
+
818
+ next: function () {
819
+ return cash(this[0].nextElementSibling);
820
+ },
821
+
822
+ not: function (selector) {
823
+ return filter.call(this, function (el) {
824
+ return !matches(el, selector);
825
+ });
826
+ },
827
+
828
+ parent: function () {
829
+ var result = this.map(function (item) {
830
+ return item.parentElement || doc.body.parentNode;
831
+ });
832
+
833
+ return unique(result);
834
+ },
835
+
836
+ parents: function (selector) {
837
+ var last, result = [];
838
+
839
+ this.each(function (item) {
840
+ last = item;
841
+
842
+ while (last !== doc.body.parentNode) {
843
+ last = last.parentElement;
844
+
845
+ if (!selector || (selector && matches(last, selector))) {
846
+ result.push(last);
847
+ }
848
+ }
849
+ });
850
+
851
+ return unique(result);
852
+ },
853
+
854
+ prev: function () {
855
+ return cash(this[0].previousElementSibling);
856
+ },
857
+
858
+ siblings: function () {
859
+ var collection = this.parent().children(), el = this[0];
860
+
861
+ return filter.call(collection, function (i) {
862
+ return i !== el;
863
+ });
864
+ }
865
+
866
+ });
867
+
868
+
869
+ return cash;
870
+ });
@@ -0,0 +1,2 @@
1
+ "use strict";/*! cash-dom 1.3.4, https://github.com/kenwheeler/cash @license MIT */
2
+ !function(t,n){"function"==typeof define&&define.amd?define(n):"undefined"!=typeof exports?module.exports=n():t.cash=t.$=n()}(this,function(){function t(t,n){n=n||w;var e=$.test(t)?n.getElementsByClassName(t.slice(1)):k.test(t)?n.getElementsByTagName(t):n.querySelectorAll(t);return e}function n(t){return E=E||w.createDocumentFragment(),A=A||E.appendChild(w.createElement("div")),A.innerHTML=t,A.childNodes}function e(t){"loading"!==w.readyState?t():w.addEventListener("DOMContentLoaded",t)}function r(r,i){if(!r)return this;if(r.cash&&r!==T)return r;var o,u=r,s=0;if(q(r))u=P.test(r)?w.getElementById(r.slice(1)):_.test(r)?n(r):t(r,i);else if(R(r))return e(r),this;if(!u)return this;if(u.nodeType||u===T)this[0]=u,this.length=1;else for(o=this.length=u.length;o>s;s++)this[s]=u[s];return this}function i(t,n){return new r(t,n)}function o(t,n){for(var e=t.length,r=0;e>r&&n.call(t[r],t[r],r,t)!==!1;r++);}function u(t,n){var e=t&&(t.matches||t.webkitMatchesSelector||t.mozMatchesSelector||t.msMatchesSelector||t.oMatchesSelector);return!!e&&e.call(t,n)}function s(t){return i(M.call(t).filter(function(t,n,e){return e.indexOf(t)===n}))}function c(t){return t[F]=t[F]||{}}function a(t,n,e){return c(t)[n]=e}function f(t,n){var e=c(t);return void 0===e[n]&&(e[n]=t.dataset?t.dataset[n]:i(t).attr("data-"+n)),e[n]}function h(t,n){var e=c(t);e?delete e[n]:t.dataset?delete t.dataset[n]:i(t).removeAttr("data-"+name)}function l(t){return q(t)&&t.match(I)}function d(t,n){return t.classList?t.classList.contains(n):new RegExp("(^| )"+n+"( |$)","gi").test(t.className)}function p(t,n,e){t.classList?t.classList.add(n):e.indexOf(" "+n+" ")&&(t.className+=" "+n)}function v(t,n){t.classList?t.classList.remove(n):t.className=t.className.replace(n,"")}function m(t,n){return parseInt(T.getComputedStyle(t[0],null)[n],10)||0}function g(t,n,e){var r=f(t,"_cashEvents")||a(t,"_cashEvents",{});r[n]=r[n]||[],r[n].push(e),t.addEventListener(n,e)}function y(t,n,e){var r=f(t,"_cashEvents")[n];e?t.removeEventListener(n,e):(o(r,function(e){t.removeEventListener(n,e)}),r=[])}function x(t,n){return"&"+encodeURIComponent(t)+"="+encodeURIComponent(n).replace(/%20/g,"+")}function C(t){return"radio"===t.type||"checkbox"===t.type}function L(t,n,e){if(e){var r=t.childNodes[0];t.insertBefore(n,r)}else t.appendChild(n)}function N(t,n,e){var r=q(n);return!r&&n.length?void o(n,function(n){return N(t,n,e)}):void o(t,r?function(t){return t.insertAdjacentHTML(e?"afterbegin":"beforeend",n)}:function(t,r){return L(t,0===r?n:n.cloneNode(!0),e)})}function b(t,n){return t===n}var E,A,w=document,T=window,S=Array.prototype,M=S.slice,B=S.filter,H=S.push,O=function(){},R=function(t){return typeof t==typeof O},q=function(t){return"string"==typeof t},P=/^#[\w-]*$/,$=/^\.[\w-]*$/,_=/<.+>/,k=/^\w+$/,D=i.fn=i.prototype=r.prototype={constructor:i,cash:!0,length:0,push:H,splice:S.splice,map:S.map,init:r};i.parseHTML=n,i.noop=O,i.isFunction=R,i.isString=q,i.extend=D.extend=function(t){t=t||{};var n=M.call(arguments),e=n.length,r=1;for(1===n.length&&(t=this,r=0);e>r;r++)if(n[r])for(var i in n[r])n[r].hasOwnProperty(i)&&(t[i]=n[r][i]);return t},i.extend({merge:function(t,n){for(var e=+n.length,r=t.length,i=0;e>i;r++,i++)t[r]=n[i];return t.length=r,t},each:o,matches:u,unique:s,isArray:Array.isArray,isNumeric:function(t){return!isNaN(parseFloat(t))&&isFinite(t)}});var F=i.uid="_cash"+Date.now();D.extend({data:function(t,n){if(q(t))return void 0===n?f(this[0],t):this.each(function(e){return a(e,t,n)});for(var e in t)this.data(e,t[e]);return this},removeData:function(t){return this.each(function(n){return h(n,t)})}});var I=/\S+/g;D.extend({addClass:function(t){var n=l(t);return n?this.each(function(t){var e=" "+t.className+" ";o(n,function(n){p(t,n,e)})}):this},attr:function(t,n){if(t){if(q(t))return void 0===n?this[0]?this[0].getAttribute?this[0].getAttribute(t):this[0][t]:void 0:this.each(function(e){e.setAttribute?e.setAttribute(t,n):e[t]=n});for(var e in t)this.attr(e,t[e]);return this}},hasClass:function(t){var n=!1,e=l(t);return e&&e.length&&this.each(function(t){return n=d(t,e[0]),!n}),n},prop:function(t,n){if(q(t))return void 0===n?this[0][t]:this.each(function(e){e[t]=n});for(var e in t)this.prop(e,t[e]);return this},removeAttr:function(t){return this.each(function(n){n.removeAttribute?n.removeAttribute(t):delete n[t]})},removeClass:function(t){if(!arguments.length)return this.attr("class","");var n=l(t);return n?this.each(function(t){o(n,function(n){v(t,n)})}):this},removeProp:function(t){return this.each(function(n){delete n[t]})},toggleClass:function(t,n){if(void 0!==n)return this[n?"addClass":"removeClass"](t);var e=l(t);return e?this.each(function(t){var n=" "+t.className+" ";o(e,function(e){d(t,e)?v(t,e):p(t,e,n)})}):this}}),D.extend({add:function(t,n){return s(i.merge(this,i(t,n)))},each:function(t){return o(this,t),this},eq:function(t){return i(this.get(t))},filter:function(t){return i(B.call(this,q(t)?function(n){return u(n,t)}:t))},first:function(){return this.eq(0)},get:function(t){return void 0===t?M.call(this):0>t?this[t+this.length]:this[t]},index:function(t){var n=t?i(t)[0]:this[0],e=t?this:i(n).parent().children();return M.call(e).indexOf(n)},last:function(){return this.eq(-1)}});var U=function(){var t=/(?:^\w|[A-Z]|\b\w)/g,n=/[\s-_]+/g;return function(e){return e.replace(t,function(t,n){return t[0===n?"toLowerCase":"toUpperCase"]()}).replace(n,"")}}(),z=function(){var t={},n=document,e=n.createElement("div"),r=e.style;return function(n){if(n=U(n),t[n])return t[n];var e=n.charAt(0).toUpperCase()+n.slice(1),i=["webkit","moz","ms","o"],u=(n+" "+i.join(e+" ")+e).split(" ");return o(u,function(e){return e in r?(t[e]=n=t[n]=e,!1):void 0}),t[n]}}();i.prefixedProp=z,i.camelCase=U,D.extend({css:function(t,n){if(q(t))return t=z(t),arguments.length>1?this.each(function(e){return e.style[t]=n}):T.getComputedStyle(this[0])[t];for(var e in t)this.css(e,t[e]);return this}}),o(["Width","Height"],function(t){var n=t.toLowerCase();D[n]=function(){return this[0].getBoundingClientRect()[n]},D["inner"+t]=function(){return this[0]["client"+t]},D["outer"+t]=function(n){return this[0]["offset"+t]+(n?m(this,"margin"+("Width"===t?"Left":"Top"))+m(this,"margin"+("Width"===t?"Right":"Bottom")):0)}}),D.extend({off:function(t,n){return this.each(function(e){return y(e,t,n)})},on:function(t,n,r,i){var o;if(!q(t)){for(var s in t)this.on(s,n,t[s]);return this}return R(n)&&(r=n,n=null),"ready"===t?(e(r),this):(n&&(o=r,r=function(t){for(var e=t.target;!u(e,n);){if(e===this)return e=!1;e=e.parentNode}e&&o.call(e,t)}),this.each(function(n){var e=r;i&&(e=function(){r.apply(this,arguments),y(n,t,e)}),g(n,t,e)}))},one:function(t,n,e){return this.on(t,n,e,!0)},ready:e,trigger:function(t,n){var e=w.createEvent("HTMLEvents");return e.data=n,e.initEvent(t,!0,!1),this.each(function(t){return t.dispatchEvent(e)})}});var W=["file","reset","submit","button"];D.extend({serialize:function(){var t=this[0].elements,n="";return o(t,function(t){t.name&&W.indexOf(t.type)<0&&("select-multiple"===t.type?o(t.options,function(e){e.selected&&(n+=x(t.name,e.value))}):(!C(t)||C(t)&&t.checked)&&(n+=x(t.name,t.value)))}),n.substr(1)},val:function(t){return void 0===t?this[0].value:this.each(function(n){return n.value=t})}}),D.extend({after:function(t){return i(t).insertAfter(this),this},append:function(t){return N(this,t),this},appendTo:function(t){return N(i(t),this),this},before:function(t){return i(t).insertBefore(this),this},clone:function(){return i(this.map(function(t){return t.cloneNode(!0)}))},empty:function(){return this.html(""),this},html:function(t){if(void 0===t)return this[0].innerHTML;var n=t.nodeType?t[0].outerHTML:t;return this.each(function(t){return t.innerHTML=n})},insertAfter:function(t){var n=this;return i(t).each(function(t,e){var r=t.parentNode,i=t.nextSibling;n.each(function(t){r.insertBefore(0===e?t:t.cloneNode(!0),i)})}),this},insertBefore:function(t){var n=this;return i(t).each(function(t,e){var r=t.parentNode;n.each(function(n){r.insertBefore(0===e?n:n.cloneNode(!0),t)})}),this},prepend:function(t){return N(this,t,!0),this},prependTo:function(t){return N(i(t),this,!0),this},remove:function(){return this.each(function(t){return t.parentNode.removeChild(t)})},text:function(t){return void 0===t?this[0].textContent:this.each(function(n){return n.textContent=t})}});var j=w.documentElement;return D.extend({position:function(){var t=this[0];return{left:t.offsetLeft,top:t.offsetTop}},offset:function(){var t=this[0].getBoundingClientRect();return{top:t.top+T.pageYOffset-j.clientTop,left:t.left+T.pageXOffset-j.clientLeft}},offsetParent:function(){return i(this[0].offsetParent)}}),D.extend({children:function(t){var n=[];return this.each(function(t){H.apply(n,t.children)}),n=s(n),t?n.filter(function(n){return u(n,t)}):n},closest:function(t){return!t||u(this[0],t)?this:this.parent().closest(t)},is:function(t){if(!t)return!1;var n=!1,e=q(t)?u:t.cash?function(n){return t.is(n)}:b;return this.each(function(r,i){return n=e(r,t,i),!n}),n},find:function(n){if(!n)return i();var e=[];return this.each(function(r){H.apply(e,t(n,r))}),s(e)},has:function(t){return B.call(this,function(n){return 0!==i(n).find(t).length})},next:function(){return i(this[0].nextElementSibling)},not:function(t){return B.call(this,function(n){return!u(n,t)})},parent:function(){var t=this.map(function(t){return t.parentElement||w.body.parentNode});return s(t)},parents:function(t){var n,e=[];return this.each(function(r){for(n=r;n!==w.body.parentNode;)n=n.parentElement,(!t||t&&u(n,t))&&e.push(n)}),s(e)},prev:function(){return i(this[0].previousElementSibling)},siblings:function(){var t=this.parent().children(),n=this[0];return B.call(t,function(t){return t!==n})}}),i});
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cash-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Martin Jagusch
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-06-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Cash is a small library for modern browsers that provides jQuery style
42
+ syntax for manipulating the DOM
43
+ email:
44
+ - _@mj.io
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - cash-rails.gemspec
55
+ - lib/cash/rails/version.rb
56
+ - vendor/assets/javascripts/cash.js
57
+ - vendor/assets/javascripts/cash.min.js
58
+ homepage: https://github.com/mjio/cash-rails
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.6.4
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: Provides cash, an absurdly small jQuery alternative for modern browsers,
82
+ for your Rails application.
83
+ test_files: []