spine-rails 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -3
- data/README.md +21 -21
- data/app/assets/javascripts/spine.js +279 -222
- data/app/assets/javascripts/spine/ajax.js +152 -94
- data/app/assets/javascripts/spine/list.js +29 -21
- data/app/assets/javascripts/spine/local.js +5 -3
- data/app/assets/javascripts/spine/manager.js +62 -38
- data/app/assets/javascripts/spine/relation.js +102 -85
- data/app/assets/javascripts/spine/route.js +73 -60
- data/app/assets/javascripts/spine/tabs.js +31 -23
- data/app/assets/javascripts/spine/tmpl.js +6 -1
- data/lib/generators/spine/scaffold/templates/controller.coffee.erb +2 -2
- data/lib/generators/spine/scaffold/templates/new.jst.erb +1 -1
- data/lib/spine/rails/version.rb +2 -2
- metadata +34 -65
@@ -1,34 +1,41 @@
|
|
1
1
|
(function() {
|
2
|
-
var $, escapeRegExp, hashStrip, namedParam, splatParam
|
3
|
-
|
4
|
-
for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
return child;
|
10
|
-
}, __slice = Array.prototype.slice;
|
11
|
-
if (typeof Spine === "undefined" || Spine === null) {
|
12
|
-
Spine = require('spine');
|
13
|
-
}
|
2
|
+
var $, escapeRegExp, hashStrip, namedParam, splatParam,
|
3
|
+
__hasProp = Object.prototype.hasOwnProperty,
|
4
|
+
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; },
|
5
|
+
__slice = Array.prototype.slice;
|
6
|
+
|
7
|
+
if (typeof Spine === "undefined" || Spine === null) Spine = require('spine');
|
8
|
+
|
14
9
|
$ = Spine.$;
|
10
|
+
|
15
11
|
hashStrip = /^#*/;
|
12
|
+
|
16
13
|
namedParam = /:([\w\d]+)/g;
|
14
|
+
|
17
15
|
splatParam = /\*([\w\d]+)/g;
|
16
|
+
|
18
17
|
escapeRegExp = /[-[\]{}()+?.,\\^$|#\s]/g;
|
19
|
-
|
20
|
-
|
18
|
+
|
19
|
+
Spine.Route = (function(_super) {
|
20
|
+
var _ref;
|
21
|
+
|
22
|
+
__extends(Route, _super);
|
23
|
+
|
21
24
|
Route.extend(Spine.Events);
|
22
|
-
|
25
|
+
|
26
|
+
Route.historySupport = ((_ref = window.history) != null ? _ref.pushState : void 0) != null;
|
27
|
+
|
23
28
|
Route.routes = [];
|
29
|
+
|
24
30
|
Route.options = {
|
25
31
|
trigger: true,
|
26
32
|
history: false,
|
27
33
|
shim: false
|
28
34
|
};
|
35
|
+
|
29
36
|
Route.add = function(path, callback) {
|
30
37
|
var key, value, _results;
|
31
|
-
if (typeof path ===
|
38
|
+
if (typeof path === 'object' && !(path instanceof RegExp)) {
|
32
39
|
_results = [];
|
33
40
|
for (key in path) {
|
34
41
|
value = path[key];
|
@@ -39,115 +46,115 @@
|
|
39
46
|
return this.routes.push(new this(path, callback));
|
40
47
|
}
|
41
48
|
};
|
49
|
+
|
42
50
|
Route.setup = function(options) {
|
43
|
-
if (options == null) {
|
44
|
-
options = {};
|
45
|
-
}
|
51
|
+
if (options == null) options = {};
|
46
52
|
this.options = $.extend({}, this.options, options);
|
47
53
|
if (this.options.history) {
|
48
54
|
this.history = this.historySupport && this.options.history;
|
49
55
|
}
|
50
|
-
if (this.options.shim)
|
51
|
-
return;
|
52
|
-
}
|
56
|
+
if (this.options.shim) return;
|
53
57
|
if (this.history) {
|
54
|
-
$(window).bind(
|
58
|
+
$(window).bind('popstate', this.change);
|
55
59
|
} else {
|
56
|
-
$(window).bind(
|
60
|
+
$(window).bind('hashchange', this.change);
|
57
61
|
}
|
58
62
|
return this.change();
|
59
63
|
};
|
64
|
+
|
60
65
|
Route.unbind = function() {
|
61
66
|
if (this.history) {
|
62
|
-
return $(window).unbind(
|
67
|
+
return $(window).unbind('popstate', this.change);
|
63
68
|
} else {
|
64
|
-
return $(window).unbind(
|
69
|
+
return $(window).unbind('hashchange', this.change);
|
65
70
|
}
|
66
71
|
};
|
72
|
+
|
67
73
|
Route.navigate = function() {
|
68
74
|
var args, lastArg, options, path;
|
69
75
|
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
70
76
|
options = {};
|
71
77
|
lastArg = args[args.length - 1];
|
72
|
-
if (typeof lastArg ===
|
78
|
+
if (typeof lastArg === 'object') {
|
73
79
|
options = args.pop();
|
74
|
-
} else if (typeof lastArg ===
|
80
|
+
} else if (typeof lastArg === 'boolean') {
|
75
81
|
options.trigger = args.pop();
|
76
82
|
}
|
77
83
|
options = $.extend({}, this.options, options);
|
78
|
-
path = args.join(
|
79
|
-
if (this.path === path)
|
80
|
-
return;
|
81
|
-
}
|
84
|
+
path = args.join('/');
|
85
|
+
if (this.path === path) return;
|
82
86
|
this.path = path;
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
if (options.shim) {
|
87
|
-
return;
|
88
|
-
}
|
87
|
+
this.trigger('navigate', this.path);
|
88
|
+
if (options.trigger) this.matchRoute(this.path, options);
|
89
|
+
if (options.shim) return;
|
89
90
|
if (this.history) {
|
90
|
-
return history.pushState({}, document.title, this.
|
91
|
+
return history.pushState({}, document.title, this.path);
|
91
92
|
} else {
|
92
93
|
return window.location.hash = this.path;
|
93
94
|
}
|
94
95
|
};
|
96
|
+
|
95
97
|
Route.getPath = function() {
|
96
|
-
|
98
|
+
var path;
|
99
|
+
path = window.location.pathname;
|
100
|
+
if (path.substr(0, 1) !== '/') path = '/' + path;
|
101
|
+
return path;
|
97
102
|
};
|
103
|
+
|
98
104
|
Route.getHash = function() {
|
99
105
|
return window.location.hash;
|
100
106
|
};
|
107
|
+
|
101
108
|
Route.getFragment = function() {
|
102
|
-
return this.getHash().replace(hashStrip,
|
109
|
+
return this.getHash().replace(hashStrip, '');
|
103
110
|
};
|
111
|
+
|
104
112
|
Route.getHost = function() {
|
105
|
-
return (document.location +
|
113
|
+
return (document.location + '').replace(this.getPath() + this.getHash(), '');
|
106
114
|
};
|
115
|
+
|
107
116
|
Route.change = function() {
|
108
117
|
var path;
|
109
|
-
path = this.
|
110
|
-
if (path === this.path)
|
111
|
-
return;
|
112
|
-
}
|
118
|
+
path = this.getFragment() !== '' ? this.getFragment() : this.getPath();
|
119
|
+
if (path === this.path) return;
|
113
120
|
this.path = path;
|
114
121
|
return this.matchRoute(this.path);
|
115
122
|
};
|
123
|
+
|
116
124
|
Route.matchRoute = function(path, options) {
|
117
|
-
var route, _i, _len,
|
118
|
-
|
119
|
-
for (_i = 0, _len =
|
120
|
-
route =
|
125
|
+
var route, _i, _len, _ref2;
|
126
|
+
_ref2 = this.routes;
|
127
|
+
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
128
|
+
route = _ref2[_i];
|
121
129
|
if (route.match(path, options)) {
|
122
|
-
this.trigger(
|
130
|
+
this.trigger('change', route, path);
|
123
131
|
return route;
|
124
132
|
}
|
125
133
|
}
|
126
134
|
};
|
135
|
+
|
127
136
|
function Route(path, callback) {
|
128
137
|
var match;
|
129
138
|
this.path = path;
|
130
139
|
this.callback = callback;
|
131
140
|
this.names = [];
|
132
|
-
if (typeof path ===
|
141
|
+
if (typeof path === 'string') {
|
142
|
+
namedParam.lastIndex = 0;
|
133
143
|
while ((match = namedParam.exec(path)) !== null) {
|
134
144
|
this.names.push(match[1]);
|
135
145
|
}
|
136
|
-
path = path.replace(escapeRegExp,
|
146
|
+
path = path.replace(escapeRegExp, '\\$&').replace(namedParam, '([^\/]*)').replace(splatParam, '(.*?)');
|
137
147
|
this.route = new RegExp('^' + path + '$');
|
138
148
|
} else {
|
139
149
|
this.route = path;
|
140
150
|
}
|
141
151
|
}
|
152
|
+
|
142
153
|
Route.prototype.match = function(path, options) {
|
143
154
|
var i, match, param, params, _len;
|
144
|
-
if (options == null) {
|
145
|
-
options = {};
|
146
|
-
}
|
155
|
+
if (options == null) options = {};
|
147
156
|
match = this.route.exec(path);
|
148
|
-
if (!match)
|
149
|
-
return false;
|
150
|
-
}
|
157
|
+
if (!match) return false;
|
151
158
|
options.match = match;
|
152
159
|
params = match.slice(1);
|
153
160
|
if (this.names.length) {
|
@@ -158,9 +165,13 @@
|
|
158
165
|
}
|
159
166
|
return this.callback.call(null, options) !== false;
|
160
167
|
};
|
168
|
+
|
161
169
|
return Route;
|
162
|
-
|
170
|
+
|
171
|
+
})(Spine.Module);
|
172
|
+
|
163
173
|
Spine.Route.change = Spine.Route.proxy(Spine.Route.change);
|
174
|
+
|
164
175
|
Spine.Controller.include({
|
165
176
|
route: function(path, callback) {
|
166
177
|
return Spine.Route.add(path, this.proxy(callback));
|
@@ -178,7 +189,9 @@
|
|
178
189
|
return Spine.Route.navigate.apply(Spine.Route, arguments);
|
179
190
|
}
|
180
191
|
});
|
192
|
+
|
181
193
|
if (typeof module !== "undefined" && module !== null) {
|
182
194
|
module.exports = Spine.Route;
|
183
195
|
}
|
196
|
+
|
184
197
|
}).call(this);
|
@@ -1,58 +1,66 @@
|
|
1
1
|
(function() {
|
2
|
-
var
|
3
|
-
|
4
|
-
|
5
|
-
function ctor() { this.constructor = child; }
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
return child;
|
10
|
-
};
|
11
|
-
if (typeof Spine === "undefined" || Spine === null) {
|
12
|
-
Spine = require('spine');
|
13
|
-
}
|
2
|
+
var $,
|
3
|
+
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
|
4
|
+
__hasProp = Object.prototype.hasOwnProperty,
|
5
|
+
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
|
6
|
+
|
7
|
+
if (typeof Spine === "undefined" || Spine === null) Spine = require('spine');
|
8
|
+
|
14
9
|
$ = Spine.$;
|
15
|
-
|
16
|
-
|
10
|
+
|
11
|
+
Spine.Tabs = (function(_super) {
|
12
|
+
|
13
|
+
__extends(Tabs, _super);
|
14
|
+
|
17
15
|
Tabs.prototype.events = {
|
18
16
|
'click [data-name]': 'click'
|
19
17
|
};
|
18
|
+
|
20
19
|
function Tabs() {
|
21
20
|
this.change = __bind(this.change, this); Tabs.__super__.constructor.apply(this, arguments);
|
22
21
|
this.bind('change', this.change);
|
23
22
|
}
|
23
|
+
|
24
24
|
Tabs.prototype.change = function(name) {
|
25
|
-
if (!name)
|
26
|
-
return;
|
27
|
-
}
|
25
|
+
if (!name) return;
|
28
26
|
this.current = name;
|
29
27
|
this.children().removeClass('active');
|
30
|
-
return this.children("[data-name=" + this.current).addClass('active');
|
28
|
+
return this.children("[data-name=" + this.current + "]").addClass('active');
|
31
29
|
};
|
30
|
+
|
32
31
|
Tabs.prototype.render = function() {
|
33
32
|
this.change(this.current);
|
34
33
|
if (!(this.children('.active').length || this.current)) {
|
35
34
|
return this.children(':first').click();
|
36
35
|
}
|
37
36
|
};
|
37
|
+
|
38
38
|
Tabs.prototype.children = function(sel) {
|
39
39
|
return this.el.children(sel);
|
40
40
|
};
|
41
|
+
|
41
42
|
Tabs.prototype.click = function(e) {
|
42
43
|
var name;
|
43
44
|
name = $(e.currentTarget).attr('data-name');
|
44
45
|
return this.trigger('change', name);
|
45
46
|
};
|
47
|
+
|
46
48
|
Tabs.prototype.connect = function(tabName, controller) {
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
49
|
+
var _this = this;
|
50
|
+
this.bind('change', function(name) {
|
51
|
+
if (name === tabName) return controller.active();
|
52
|
+
});
|
53
|
+
return controller.bind('active', function() {
|
54
|
+
return _this.change(tabName);
|
51
55
|
});
|
52
56
|
};
|
57
|
+
|
53
58
|
return Tabs;
|
54
|
-
|
59
|
+
|
60
|
+
})(Spine.Controller);
|
61
|
+
|
55
62
|
if (typeof module !== "undefined" && module !== null) {
|
56
63
|
module.exports = Spine.Tabs;
|
57
64
|
}
|
65
|
+
|
58
66
|
}).call(this);
|
@@ -1,12 +1,16 @@
|
|
1
1
|
(function() {
|
2
2
|
var $;
|
3
|
+
|
3
4
|
$ = typeof jQuery !== "undefined" && jQuery !== null ? jQuery : require("jqueryify");
|
5
|
+
|
4
6
|
$.fn.item = function() {
|
5
7
|
var item;
|
6
8
|
item = $(this);
|
7
9
|
item = item.data("item") || (typeof item.tmplItem === "function" ? item.tmplItem().data : void 0);
|
8
|
-
|
10
|
+
if (item != null) if (typeof item.reload === "function") item.reload();
|
11
|
+
return item;
|
9
12
|
};
|
13
|
+
|
10
14
|
$.fn.forItem = function(item) {
|
11
15
|
return this.filter(function() {
|
12
16
|
var compare;
|
@@ -14,4 +18,5 @@
|
|
14
18
|
return (typeof item.eql === "function" ? item.eql(compare) : void 0) || item === compare;
|
15
19
|
});
|
16
20
|
};
|
21
|
+
|
17
22
|
}).call(this);
|
@@ -53,7 +53,7 @@ class Edit extends Spine.Controller
|
|
53
53
|
|
54
54
|
class Show extends Spine.Controller
|
55
55
|
events:
|
56
|
-
'click [
|
56
|
+
'click [data-type=edit]': 'edit'
|
57
57
|
'click [data-type=back]': 'back'
|
58
58
|
|
59
59
|
constructor: ->
|
@@ -105,7 +105,7 @@ class Index extends Spine.Controller
|
|
105
105
|
new: ->
|
106
106
|
@navigate '/<%= controller_name %>/new'
|
107
107
|
|
108
|
-
class
|
108
|
+
class <%= app_class %>.<%= controller_class %> extends Spine.Stack
|
109
109
|
controllers:
|
110
110
|
index: Index
|
111
111
|
edit: Edit
|
data/lib/spine/rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,63 +1,45 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: spine-rails
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 9
|
10
|
-
version: 0.0.9
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Alex MacCaw
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-02-12 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: rails
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70126037581420 !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 3
|
30
|
-
segments:
|
31
|
-
- 3
|
32
|
-
- 1
|
33
|
-
- 0
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
34
21
|
version: 3.1.0
|
35
22
|
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: bundler
|
39
23
|
prerelease: false
|
40
|
-
|
24
|
+
version_requirements: *70126037581420
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: bundler
|
27
|
+
requirement: &70126037579920 !ruby/object:Gem::Requirement
|
41
28
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
|
46
|
-
segments:
|
47
|
-
- 0
|
48
|
-
version: "0"
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
49
33
|
type: :development
|
50
|
-
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70126037579920
|
51
36
|
description: This gem provides Spine for your Rails 3 application.
|
52
|
-
email:
|
37
|
+
email:
|
53
38
|
- info@eribium.org
|
54
39
|
executables: []
|
55
|
-
|
56
40
|
extensions: []
|
57
|
-
|
58
41
|
extra_rdoc_files: []
|
59
|
-
|
60
|
-
files:
|
42
|
+
files:
|
61
43
|
- .gitignore
|
62
44
|
- Gemfile
|
63
45
|
- Gemfile.lock
|
@@ -96,41 +78,28 @@ files:
|
|
96
78
|
- lib/spine/rails/engine.rb
|
97
79
|
- lib/spine/rails/version.rb
|
98
80
|
- spine-rails.gemspec
|
99
|
-
has_rdoc: true
|
100
81
|
homepage: http://rubygems.org/gems/spine-rails
|
101
82
|
licenses: []
|
102
|
-
|
103
83
|
post_install_message:
|
104
84
|
rdoc_options: []
|
105
|
-
|
106
|
-
require_paths:
|
85
|
+
require_paths:
|
107
86
|
- lib
|
108
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
88
|
none: false
|
110
|
-
requirements:
|
111
|
-
- -
|
112
|
-
- !ruby/object:Gem::Version
|
113
|
-
|
114
|
-
|
115
|
-
- 0
|
116
|
-
version: "0"
|
117
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ! '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
94
|
none: false
|
119
|
-
requirements:
|
120
|
-
- -
|
121
|
-
- !ruby/object:Gem::Version
|
122
|
-
hash: 23
|
123
|
-
segments:
|
124
|
-
- 1
|
125
|
-
- 3
|
126
|
-
- 6
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
127
98
|
version: 1.3.6
|
128
99
|
requirements: []
|
129
|
-
|
130
100
|
rubyforge_project: spine-rails
|
131
|
-
rubygems_version: 1.
|
101
|
+
rubygems_version: 1.8.15
|
132
102
|
signing_key:
|
133
103
|
specification_version: 3
|
134
104
|
summary: Use Spine with Rails 3
|
135
105
|
test_files: []
|
136
|
-
|