eyeballs 0.5.10 → 0.5.10.1

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.
data/Rakefile CHANGED
@@ -27,7 +27,7 @@ begin
27
27
  require 'jeweler'
28
28
  Jeweler::Tasks.new do |s|
29
29
  s.name = "eyeballs"
30
- s.version = "0.5.10"
30
+ s.version = "0.5.10.1"
31
31
  s.author = "Paul Campbell"
32
32
  s.email = "paul@rslw.com"
33
33
  s.homepage = "http://www.github.com/paulca/eyeballs.js"
data/eyeballs.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{eyeballs}
8
- s.version = "0.5.10"
8
+ s.version = "0.5.10.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Paul Campbell"]
@@ -59,19 +59,13 @@ o_O.routes = {
59
59
  draw: function(callback){
60
60
  $(function(){
61
61
  callback(o_O.routes.router());
62
- if(location.hash.o_O_trim() == '')
63
- {
64
- if(typeof o_O.routes.rules['root'] === 'object')
65
- {
66
- o_O.routes.rules['root'].action();
67
- }
68
-
69
- }
70
62
 
71
- var route_on_hash = function(){
72
- var parts = location.hash.split('?')
73
- var hash = parts[0].replace(/^(#)/, '').o_O_trim('/');
74
- var query_string_parts;
63
+ var parts, hash, query_string_parts;
64
+
65
+ var update_hash_parts = function(){
66
+ parts = location.hash.split('?')
67
+ hash = parts[0].replace(/^(#)/, '').o_O_trim('/');
68
+ query_string_parts;
75
69
  if(typeof parts[1] === 'string')
76
70
  {
77
71
  query_string_parts = parts[1].replace('&', '&').split('&');
@@ -80,9 +74,54 @@ o_O.routes = {
80
74
  {
81
75
  query_string_parts = '';
82
76
  }
77
+ }
78
+
79
+ var compute_params = function(rule){
80
+ return function(attr){
81
+ var params = {}
82
+ if(rule)
83
+ {
84
+ for(j = 0; j < rule.matchers.length; j++)
85
+ {
86
+ params[rule.matchers[j].replace(/^:/, '')] = match[j+1];
87
+ }
88
+ }
89
+
90
+ if(query_string_parts.length > 0)
91
+ {
92
+ for(k = 0; k < query_string_parts.length; k++)
93
+ {
94
+ var param_parts = query_string_parts[k].split('=')
95
+ params[param_parts[0]] = param_parts[1];
96
+ }
97
+ }
98
+ if(attr)
99
+ {
100
+ return params[attr];
101
+ }
102
+ else
103
+ {
104
+ return params;
105
+ }
106
+ }
107
+ }
108
+
109
+ if(location.hash.o_O_trim() == '')
110
+ {
111
+ update_hash_parts()
112
+ if(typeof o_O.routes.rules['root'] === 'object')
113
+ {
114
+ o_O.routes.rules['root'].action(compute_params());
115
+ }
116
+
117
+ }
118
+
119
+ var route_on_hash = function(){
120
+ update_hash_parts();
83
121
  if(o_O.routes.urls.indexOf(hash) >= 0)
84
122
  {
85
- o_O.routes.rules[hash].action(o_O.routes.rules[hash].with_args);
123
+ console.log(compute_params()())
124
+ o_O.routes.rules[hash].action(compute_params());
86
125
  }
87
126
  else
88
127
  {
@@ -91,30 +130,7 @@ o_O.routes = {
91
130
  if(match = hash.match(o_O.routes.regex_urls[i].regex))
92
131
  {
93
132
  var rule = o_O.routes.rules[o_O.routes.regex_urls[i].matcher];
94
- rule.action(function(attr){
95
- var params = {}
96
- for(j = 0; j < rule.matchers.length; j++)
97
- {
98
- params[rule.matchers[j].replace(/^:/, '')] = match[j+1];
99
- }
100
-
101
- if(query_string_parts.length > 0)
102
- {
103
- for(k = 0; k < query_string_parts.length; k++)
104
- {
105
- var param_parts = query_string_parts[k].split('=')
106
- params[param_parts[0]] = param_parts[1];
107
- }
108
- }
109
- if(attr)
110
- {
111
- return params[attr];
112
- }
113
- else
114
- {
115
- return params;
116
- }
117
- });
133
+ rule.action(compute_params(rule));
118
134
  return;
119
135
  }
120
136
  }
@@ -21,33 +21,18 @@
21
21
  $('div#root').html('rooting for you')
22
22
  },
23
23
  index: function(bit){
24
- var out;
25
- if(bit == 'test')
26
- {
27
- out = 'clicked!'
28
- }
29
- else
30
- {
31
- out = 'indexed!'
32
- }
33
- $('div#index').html(out);
24
+ $('div#index').html('clicked!');
34
25
  return 'whoop!'
35
26
  },
36
27
  namespaced_index: function(bit){
37
- var out;
38
- if(bit == 'test')
39
- {
40
- out = 'namespaced and clicked!'
41
- }
42
- else
43
- {
44
- out = 'namespaced and indexed!'
45
- }
46
- $('div#namespaced-index').html(out);
28
+ $('div#namespaced-index').html('namespaced and clicked!');
47
29
  return 'awesome!'
48
30
  },
49
31
  sending_params: function(params){
50
32
  $('div#with_params').html(params('test') + params('other_test'));
33
+ },
34
+ sending_params_normal: function(params){
35
+ $('div#with_params_normal').html(params('other_test'));
51
36
  }
52
37
  });
53
38
 
@@ -69,11 +54,12 @@
69
54
 
70
55
  o_O.routes.draw(function(map){
71
56
  map.root({to: "reviews#root"})
72
- map.match('/reviews/index/', {to: "reviews#index", with_args: 'test'});
57
+ map.match('/reviews/index/', {to: "reviews#index"});
73
58
  map.namespace('my', function(my){
74
- my.match('action', {to: "reviews#namespaced_index", with_args: 'test'})
59
+ my.match('action', {to: "reviews#namespaced_index"})
75
60
  })
76
61
  map.match('/reviews/:test', {to: 'reviews#sending_params'})
62
+ map.match('gobble', {to: 'reviews#sending_params_normal'})
77
63
 
78
64
  map.resources('songs')
79
65
  })
@@ -121,6 +107,14 @@
121
107
  start();
122
108
  },100)
123
109
  })
110
+
111
+ asyncTest('withparams normal route',function(){
112
+ $('a#with-params-normal').trigger('click');
113
+ setTimeout(function(){
114
+ equals($('div#with_params_normal').html(), 'else', "should pass the params");
115
+ start();
116
+ },100)
117
+ })
124
118
 
125
119
  asyncTest('resources new', function(){
126
120
  $('a#add-song').click()
@@ -168,7 +162,9 @@
168
162
  <a id="index-link" data-ajax-history="true" href="/reviews/index">Hello!</a>
169
163
  <a id="namespaced-index-link" data-ajax-history="true" href="/my/action">Hello!</a>
170
164
 
171
- <a id="with-params" data-ajax-history="true" href="/reviews/something?other_test=else">Hello!</a>
165
+ <a id="with-params" data-ajax-history="true" href="/reviews/something?other_test=else">With Params</a>
166
+
167
+ <a id="with-params-normal" data-ajax-history="true" href="/gobble?other_test=else">With Params Normal</a>
172
168
 
173
169
  <div id="index">
174
170
  </div>
@@ -176,6 +172,7 @@
176
172
  </div>
177
173
  <div id="root"></div>
178
174
  <div id="with_params"></div>
175
+ <div id="with_params_normal"></div>
179
176
 
180
177
  <a id="add-song" href="/songs/new" data-ajax-history="true">New Song</a>
181
178
  <div id="songs-add"></div>
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eyeballs
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 77
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
9
  - 10
10
- version: 0.5.10
10
+ - 1
11
+ version: 0.5.10.1
11
12
  platform: ruby
12
13
  authors:
13
14
  - Paul Campbell