riotjs-rails 0.9.4 → 0.9.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9f5502b82d3614366a5255f3ead2804df572f30b
4
- data.tar.gz: bf6620022db75e138a06318a3960d2406e13f5f5
3
+ metadata.gz: bddaf38a81cc9901335a8f5d909f1c21c05aea20
4
+ data.tar.gz: 474140b905184903f4c0c3ce8bccf1c5eebced54
5
5
  SHA512:
6
- metadata.gz: 7c0e7d2137ca1c9bfd7d26936243ad81af0f3e97c35fec2c0a9da6bc672d6028e7e933bad4e4d22b9bdedfbabcec4480229f1a4a0f49eb0dbd2592605dc97ceb
7
- data.tar.gz: f54d329404bf242f6121e69f3d083c9640333437fa942c5049ce919e12321fc104bbf31a23bbf49c71f4d7cd603354d7bf1b9b9ad53dfdfeed4182de4ccd0eda
6
+ metadata.gz: 93c5cba307dce5b0cf803a33cad2a64dc8895a0a50c03dab806d14680a57d0417b84e2e5abce69a38658481c78903c5e4160dac05b149faef73eef5e768df4a3
7
+ data.tar.gz: 77a67d977f1dc15202efba82399d6369bb9600502609f41f1431837ea61aa3de739704ad6ee12833dd0ed8009fc6849a323dd0964567d8d009e15f4ec9cd4d37
@@ -1,5 +1,5 @@
1
1
  module Riot
2
2
  module Rails
3
- VERSION = "0.9.4"
3
+ VERSION = "0.9.5"
4
4
  end
5
5
  end
@@ -1,20 +1,15 @@
1
1
 
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
2
 
8
- var $ = top.$ = top.$ || {};
3
+ (function(is_node) { "use strict";
4
+ /*global exports, window, setTimeout, history, location, document */
5
+
6
+ var top = is_node ? exports : window,
7
+ $ = is_node ? top : top.$ = top.$ || {};
9
8
 
10
9
  // avoid multiple execution. popstate should be fired only once etc.
11
10
  if ($.riot) return;
12
11
 
13
- $.riot = "0.9.4";
14
-
15
- function isFunction(el) {
16
- return Object.prototype.toString.call(el) == '[object Function]';
17
- }
12
+ $.riot = "0.9.5";
18
13
 
19
14
  $.observable = function(el) {
20
15
 
@@ -22,7 +17,8 @@
22
17
  slice = [].slice;
23
18
 
24
19
  el.on = function(events, fn) {
25
- if (isFunction(fn)) {
20
+
21
+ if (typeof fn == "function") {
26
22
  events = events.split(/\s+/);
27
23
 
28
24
  for (var i = 0, len = events.length, type; i < len; i++) {
@@ -34,41 +30,21 @@
34
30
  return el;
35
31
  };
36
32
 
37
- el.off = function(events, fn) {
33
+ el.off = function(events) {
38
34
  events = events.split(/\s+/);
39
35
 
40
- for (var j = 0, type; j < events.length; j++) {
41
- type = events[j];
42
-
43
- // remove single type
44
- if (!fn) { callbacks[type] = []; continue; }
45
-
46
- var fns = callbacks[type] || [],
47
- pos = -1;
48
-
49
- for (var i = 0, len = fns.length; i < len; i++) {
50
- if (fns[i] === fn || fns[i].listener === fn) { pos = i; break; }
51
- }
52
-
53
- if (pos >= 0) fns.splice(pos, 1);
36
+ for (var i = 0; i < events.length; i++) {
37
+ callbacks[events[i]] = [];
54
38
  }
39
+
55
40
  return el;
56
41
  };
57
42
 
58
43
  // only single event supported
59
44
  el.one = function(type, fn) {
45
+ if (fn) fn.one = true;
46
+ return el.on(type, fn);
60
47
 
61
- function on() {
62
- el.off(type, fn);
63
- fn.apply(el, arguments);
64
- }
65
-
66
- if (isFunction(fn)) {
67
- on.listener = fn;
68
- el.on(type, on);
69
- }
70
-
71
- return el;
72
48
  };
73
49
 
74
50
  el.trigger = function(type) {
@@ -76,15 +52,15 @@
76
52
  var args = slice.call(arguments, 1),
77
53
  fns = callbacks[type] || [];
78
54
 
79
- for (var i = 0, len = fns.length, fn, added; i < len; ++i) {
55
+ for (var i = 0, fn; i < fns.length; ++i) {
80
56
  fn = fns[i];
81
57
 
82
- // possibly removed
83
- if (!fn) continue;
58
+ if (fn.one && fn.done) continue;
84
59
 
85
60
  // add event argument when multiple listeners
86
61
  fn.apply(el, fn.typed ? [type].concat(args) : args);
87
62
 
63
+ fn.done = true;
88
64
  }
89
65
 
90
66
  return el;
@@ -94,40 +70,41 @@
94
70
 
95
71
  };
96
72
 
97
- // emit window.popstate event consistently on page load, on every browser
98
- var page_popped,
99
- fn = $.observable({});
73
+ if (is_node) return;
74
+
75
+ // cross browser popstate
76
+ var currentHash,
77
+ fn = $.observable({}),
78
+ listen = top.addEventListener,
79
+ doc = document;
100
80
 
101
81
  function pop(hash) {
102
- fn.trigger("pop", hash || top.location.hash);
82
+ hash = hash.type ? location.hash : hash;
83
+ if (hash != currentHash) fn.trigger("pop", hash);
84
+ currentHash = hash;
103
85
  }
104
86
 
105
- function on(event, fn) {
106
- top.addEventListener(event, fn, false);
107
- }
87
+ if (listen) {
88
+ listen("popstate", pop, false);
89
+ doc.addEventListener("DOMContentLoaded", pop, false);
108
90
 
109
- on("load", function() {
110
- top.setTimeout(function() { page_popped || pop(); }, 1);
111
- });
91
+ } else {
92
+ doc.attachEvent("onreadystatechange", function() {
93
+ if (doc.readyState == "complete") pop("");
94
+ });
112
95
 
113
- on("popstate", function(e) {
114
- if (!page_popped) page_popped = true;
115
- pop();
116
- });
96
+ }
117
97
 
118
98
  // Change the browser URL or listen to changes on the URL
119
99
  $.route = function(to) {
120
100
 
121
101
  // listen
122
- if (isFunction(to)) {
123
- fn.on("pop", to);
102
+ if (typeof to == "function") return fn.on("pop", to);
124
103
 
125
104
  // fire
126
- } else if (to != top.location.hash) {
127
- if (top.history.pushState) top.history.pushState("", "", to);
128
- pop(to);
129
- }
105
+ if (history.pushState) history.pushState(0, 0, to);
106
+ pop(to);
130
107
 
131
108
  };
132
109
 
133
- })(window);
110
+ })(typeof exports == "object");
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.4
4
+ version: 0.9.5
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-10 00:00:00.000000000 Z
11
+ date: 2013-11-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A simple asset-pipeline wrapper for riot.js by moot
14
14
  email: