riotjs-rails 0.9.1 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 74a7163cae2196d8853cf81863190d0da4b18ae8
4
- data.tar.gz: a6d3e2df9d5bb4804987956509c72bc3808e4683
3
+ metadata.gz: 9f5502b82d3614366a5255f3ead2804df572f30b
4
+ data.tar.gz: bf6620022db75e138a06318a3960d2406e13f5f5
5
5
  SHA512:
6
- metadata.gz: 9aa7563eac2cf41b1e9746095c03f6bec1c2733cbaf9a92751e1ba0b47307b9c7e2291006f3cfedc61bda0e87b42d64433589c6818a37c39391085476fc382dd
7
- data.tar.gz: 4a710a8b704587e302b9d5402bfe7475bde9504e06a8d819151130fd21b2cb8b611da571eceb185be9d8c228fac7c9ca3c44c773c0a6e5a78648af81e889e784
6
+ metadata.gz: 7c0e7d2137ca1c9bfd7d26936243ad81af0f3e97c35fec2c0a9da6bc672d6028e7e933bad4e4d22b9bdedfbabcec4480229f1a4a0f49eb0dbd2592605dc97ceb
7
+ data.tar.gz: f54d329404bf242f6121e69f3d083c9640333437fa942c5049ce919e12321fc104bbf31a23bbf49c71f4d7cd603354d7bf1b9b9ad53dfdfeed4182de4ccd0eda
@@ -1,5 +1,5 @@
1
1
  module Riot
2
2
  module Rails
3
- VERSION = "0.9.1"
3
+ VERSION = "0.9.4"
4
4
  end
5
5
  end
@@ -1,82 +1,133 @@
1
- /* Riot.js 0.9.1 | moot.it/riotjs | (c) 2013 Moot Inc | @license: MIT */
2
- (function($, win) {
3
1
 
4
- // Precompiled templates (JavaScript functions)
5
- var FN = {},
2
+ /*
3
+ Riot.js 0.9.4 | moot.it/riotjs | @license MIT
4
+ (c) 2013 Tero Piirainen, Moot Inc and other contributors.
5
+ */
6
+ (function(top) { "use strict";
7
+
8
+ var $ = top.$ = top.$ || {};
9
+
10
+ // avoid multiple execution. popstate should be fired only once etc.
11
+ if ($.riot) return;
12
+
13
+ $.riot = "0.9.4";
14
+
15
+ function isFunction(el) {
16
+ return Object.prototype.toString.call(el) == '[object Function]';
17
+ }
18
+
19
+ $.observable = function(el) {
20
+
21
+ var callbacks = {},
6
22
  slice = [].slice;
7
23
 
24
+ el.on = function(events, fn) {
25
+ if (isFunction(fn)) {
26
+ events = events.split(/\s+/);
8
27
 
9
- // Render a template with data
10
- $.render = function(template, data) {
11
- return (FN[template] = FN[template] || Function("_", "return '" +
12
- $.trim(template)
13
- .replace(/\n/g, "\\n")
14
- .replace(/'/g, "\\'")
15
- .replace(/\{(\w+)\}/g, "' + (_.$1 || '') + '") + "'")
16
- )(data);
17
- }
28
+ for (var i = 0, len = events.length, type; i < len; i++) {
29
+ type = events[i];
30
+ (callbacks[type] = callbacks[type] || []).push(fn);
31
+ if (len > 1) fn.typed = true;
32
+ }
33
+ }
34
+ return el;
35
+ };
18
36
 
19
- // A classic pattern for separating concerns
20
- $.observable = function(obj) {
21
- var jq = $({});
37
+ el.off = function(events, fn) {
38
+ events = events.split(/\s+/);
22
39
 
23
- $.each(['on', 'one', 'trigger', 'off'], function(i, name) {
24
- obj[name] = function(names, fn) {
40
+ for (var j = 0, type; j < events.length; j++) {
41
+ type = events[j];
25
42
 
26
- if (i < 2) {
27
- jq[name](names, function(e) {
28
- var args = slice.call(arguments, 1)
29
- if (names.split(" ")[1]) args.unshift(e.type)
30
- fn.apply(obj, args)
31
- })
43
+ // remove single type
44
+ if (!fn) { callbacks[type] = []; continue; }
32
45
 
33
- } else if (i == 2) {
34
- jq.trigger(names, slice.call(arguments, 1));
46
+ var fns = callbacks[type] || [],
47
+ pos = -1;
35
48
 
36
- } else {
37
- jq.off(names, fn);
38
- }
49
+ for (var i = 0, len = fns.length; i < len; i++) {
50
+ if (fns[i] === fn || fns[i].listener === fn) { pos = i; break; }
51
+ }
39
52
 
40
- return obj;
41
- }
53
+ if (pos >= 0) fns.splice(pos, 1);
54
+ }
55
+ return el;
56
+ };
42
57
 
43
- })
58
+ // only single event supported
59
+ el.one = function(type, fn) {
44
60
 
45
- return obj;
46
- }
61
+ function on() {
62
+ el.off(type, fn);
63
+ fn.apply(el, arguments);
64
+ }
47
65
 
48
- // jQueried window object
49
- win = $(win);
66
+ if (isFunction(fn)) {
67
+ on.listener = fn;
68
+ el.on(type, on);
69
+ }
50
70
 
51
- // emit window.popstate event consistently on page load, on every browser
52
- var page_popped;
71
+ return el;
72
+ };
53
73
 
54
- win.on("load", function(e) {
55
- setTimeout(function() {
56
- if (!page_popped) win.trigger("popstate")
57
- }, 1);
74
+ el.trigger = function(type) {
58
75
 
59
- }).on("popstate", function(e) {
60
- if (!page_popped) page_popped = true;
76
+ var args = slice.call(arguments, 1),
77
+ fns = callbacks[type] || [];
61
78
 
62
- })
79
+ for (var i = 0, len = fns.length, fn, added; i < len; ++i) {
80
+ fn = fns[i];
63
81
 
64
- // Change the browser URL or listen to changes on the URL
65
- $.route = function(to) {
82
+ // possibly removed
83
+ if (!fn) continue;
66
84
 
67
- // listen
68
- if ($.isFunction(to)) {
69
- win.on("popstate", function(e, hash) {
70
- to(hash || location.hash)
71
- })
85
+ // add event argument when multiple listeners
86
+ fn.apply(el, fn.typed ? [type].concat(args) : args);
72
87
 
73
- // fire
74
- } else if (to != location.hash) {
75
- if (history.pushState) history.pushState("", "", to)
76
- win.trigger("popstate", [to]);
77
88
  }
78
89
 
79
- }
90
+ return el;
91
+ };
92
+
93
+ return el;
94
+
95
+ };
96
+
97
+ // emit window.popstate event consistently on page load, on every browser
98
+ var page_popped,
99
+ fn = $.observable({});
100
+
101
+ function pop(hash) {
102
+ fn.trigger("pop", hash || top.location.hash);
103
+ }
104
+
105
+ function on(event, fn) {
106
+ top.addEventListener(event, fn, false);
107
+ }
108
+
109
+ on("load", function() {
110
+ top.setTimeout(function() { page_popped || pop(); }, 1);
111
+ });
112
+
113
+ on("popstate", function(e) {
114
+ if (!page_popped) page_popped = true;
115
+ pop();
116
+ });
117
+
118
+ // Change the browser URL or listen to changes on the URL
119
+ $.route = function(to) {
120
+
121
+ // listen
122
+ if (isFunction(to)) {
123
+ fn.on("pop", to);
124
+
125
+ // fire
126
+ } else if (to != top.location.hash) {
127
+ if (top.history.pushState) top.history.pushState("", "", to);
128
+ pop(to);
129
+ }
80
130
 
131
+ };
81
132
 
82
- })(jQuery, window)
133
+ })(window);
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riotjs-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Butler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-08 00:00:00.000000000 Z
11
+ date: 2013-11-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A simple asset-pipeline wrapper for riot.js by moot
14
14
  email: