joosy 1.2.0.alpha.67 → 1.2.0.alpha.68
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gruntfile.coffee +1 -1
- data/bower.json +1 -1
- data/build/joosy.js +27 -20
- data/build/joosy/extensions/resources.js +25 -7
- data/package.json +1 -1
- data/source/joosy/application.coffee +1 -1
- data/source/joosy/extensions/resources/base.coffee +34 -11
- data/source/joosy/extensions/resources/rest.coffee +0 -1
- data/source/joosy/modules/dom.coffee +21 -18
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 007fa5ba359b8c5f4c5e52a53b483a285149c575
|
4
|
+
data.tar.gz: 15ac5b0c7eaf9eb93b08b487b0e493fcd8ec7075
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b33c07dd76c9a907ff66ce830a55f321b3ae54f9d9e5598e0d5c48aeab9d98c9a4ddfbe11a766fbff3c6b80173c22b90716bbabbdcf6fa1b8328361989a8148f
|
7
|
+
data.tar.gz: 9548d59875b23556613071537c1c09893ac777a7782dfb1fa2284e5de26c0ab3ceffb88f8b60aac3564c76eca419e992ab35529f96a7dce4cd6208782959deb2
|
data/Gruntfile.coffee
CHANGED
@@ -101,7 +101,7 @@ module.exports = (grunt) ->
|
|
101
101
|
#
|
102
102
|
grunt.registerTask 'default', 'testem'
|
103
103
|
|
104
|
-
grunt.registerTask 'build', 'grill:compile'
|
104
|
+
grunt.registerTask 'build', ['bowerize', 'grill:compile']
|
105
105
|
|
106
106
|
grunt.registerTask 'test', ->
|
107
107
|
grunt.task.run 'coffeelint'
|
data/bower.json
CHANGED
data/build/joosy.js
CHANGED
@@ -511,26 +511,33 @@
|
|
511
511
|
if (!events) {
|
512
512
|
return;
|
513
513
|
}
|
514
|
-
return Object.each(events, function(
|
515
|
-
var callback, eventName, match, selector;
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
514
|
+
return Object.each(events, function(keys, method) {
|
515
|
+
var callback, eventName, key, match, selector, _i, _len, _ref, _results;
|
516
|
+
_ref = keys.split(',');
|
517
|
+
_results = [];
|
518
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
519
|
+
key = _ref[_i];
|
520
|
+
key = key.replace(/^\s+/, '');
|
521
|
+
if (!Object.isFunction(method)) {
|
522
|
+
method = _this[method];
|
523
|
+
}
|
524
|
+
callback = function(event) {
|
525
|
+
return method.call(module, $(this), event);
|
526
|
+
};
|
527
|
+
match = key.match(_this.eventSplitter);
|
528
|
+
eventName = match[1];
|
529
|
+
selector = _this.__extractSelector(match[2]);
|
530
|
+
if (selector === "") {
|
531
|
+
_this.$container.bind(eventName, callback);
|
532
|
+
_results.push(Joosy.Modules.Log.debugAs(_this, "" + eventName + " binded on container"));
|
533
|
+
} else if (selector === void 0) {
|
534
|
+
throw new Error("Unknown element " + match[2] + " in " + (Joosy.Module.__className(_this.constructor)) + " (maybe typo?)");
|
535
|
+
} else {
|
536
|
+
_this.$container.on(eventName, selector, callback);
|
537
|
+
_results.push(Joosy.Modules.Log.debugAs(_this, "" + eventName + " binded on " + selector));
|
538
|
+
}
|
533
539
|
}
|
540
|
+
return _results;
|
534
541
|
});
|
535
542
|
},
|
536
543
|
__clearContainer: function() {
|
@@ -2370,7 +2377,7 @@
|
|
2370
2377
|
} else if (Object.isFunction(action)) {
|
2371
2378
|
return action(params);
|
2372
2379
|
} else {
|
2373
|
-
throw new "Unknown kind of route action";
|
2380
|
+
throw new Error("Unknown kind of route action: " + action);
|
2374
2381
|
}
|
2375
2382
|
});
|
2376
2383
|
return this.initialized = true;
|
@@ -9,18 +9,15 @@
|
|
9
9
|
|
10
10
|
Base.include(Joosy.Modules.Events);
|
11
11
|
|
12
|
+
Base.include(Joosy.Modules.Filters);
|
13
|
+
|
12
14
|
Base.prototype.__primaryKey = 'id';
|
13
15
|
|
14
16
|
Base.resetIdentity = function() {
|
15
17
|
return Joosy.Resources.Base.identity = {};
|
16
18
|
};
|
17
19
|
|
18
|
-
Base.beforeLoad
|
19
|
-
if (!this.prototype.hasOwnProperty('__beforeLoads')) {
|
20
|
-
this.prototype.__beforeLoads = [].concat(this.__super__.__beforeLoads || []);
|
21
|
-
}
|
22
|
-
return this.prototype.__beforeLoads.push(action);
|
23
|
-
};
|
20
|
+
Base.registerPlainFilters('beforeLoad');
|
24
21
|
|
25
22
|
Base.primaryKey = function(primaryKey) {
|
26
23
|
return this.prototype.__primaryKey = primaryKey;
|
@@ -93,6 +90,10 @@
|
|
93
90
|
return shim;
|
94
91
|
};
|
95
92
|
|
93
|
+
Base.grab = function(form) {
|
94
|
+
return this.build({}).grab(form);
|
95
|
+
};
|
96
|
+
|
96
97
|
Base.__makeShim = function(proto) {
|
97
98
|
var key, shim, value;
|
98
99
|
shim = function() {
|
@@ -137,6 +138,24 @@
|
|
137
138
|
return this;
|
138
139
|
};
|
139
140
|
|
141
|
+
Base.prototype.grab = function(form) {
|
142
|
+
var data, field, _i, _len, _ref;
|
143
|
+
data = {};
|
144
|
+
_ref = $(form).serializeArray();
|
145
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
146
|
+
field = _ref[_i];
|
147
|
+
if (!data[field.name]) {
|
148
|
+
data[field.name] = field.value;
|
149
|
+
} else {
|
150
|
+
if (!(data[field.name] instanceof Array)) {
|
151
|
+
data[field.name] = [data[field.name]];
|
152
|
+
}
|
153
|
+
data[field.name].push(field.value);
|
154
|
+
}
|
155
|
+
}
|
156
|
+
return this.load(data);
|
157
|
+
};
|
158
|
+
|
140
159
|
Base.prototype.__get = function(path) {
|
141
160
|
var target;
|
142
161
|
target = this.__callTarget(path, true);
|
@@ -696,7 +715,6 @@
|
|
696
715
|
this.prototype.__requestOptions(options);
|
697
716
|
} else if (this.prototype.__requestOptions) {
|
698
717
|
Joosy.Module.merge(options, this.prototype.__requestOptions);
|
699
|
-
console.log(this.prototype.__requestOptions);
|
700
718
|
}
|
701
719
|
return $.ajax(options);
|
702
720
|
};
|
data/package.json
CHANGED
@@ -17,10 +17,18 @@
|
|
17
17
|
#
|
18
18
|
# @include Joosy.Modules.Log
|
19
19
|
# @include Joosy.Modules.Events
|
20
|
+
# @include Joosy.Modules.Filters
|
21
|
+
#
|
22
|
+
# @method .beforeLoad(callback)
|
23
|
+
# Allows to modify data before it gets stored.
|
24
|
+
# You can define several beforeLoad filters that will be chained.
|
25
|
+
# @param [Function] action `(Object) -> Object` to call
|
26
|
+
#
|
20
27
|
#
|
21
28
|
class Joosy.Resources.Base extends Joosy.Module
|
22
29
|
@include Joosy.Modules.Log
|
23
30
|
@include Joosy.Modules.Events
|
31
|
+
@include Joosy.Modules.Filters
|
24
32
|
|
25
33
|
#
|
26
34
|
# Default primary key field 'id'
|
@@ -34,16 +42,7 @@ class Joosy.Resources.Base extends Joosy.Module
|
|
34
42
|
@resetIdentity: ->
|
35
43
|
Joosy.Resources.Base.identity = {}
|
36
44
|
|
37
|
-
|
38
|
-
# Allows to modify data before it gets stored.
|
39
|
-
# You can define several beforeLoad filters that will be chained.
|
40
|
-
#
|
41
|
-
# @param [Function] action `(Object) -> Object` to call
|
42
|
-
#
|
43
|
-
@beforeLoad: (action) ->
|
44
|
-
unless @::hasOwnProperty '__beforeLoads'
|
45
|
-
@::__beforeLoads = [].concat @.__super__.__beforeLoads || []
|
46
|
-
@::__beforeLoads.push action
|
45
|
+
@registerPlainFilters 'beforeLoad'
|
47
46
|
|
48
47
|
#
|
49
48
|
# Sets the field containing primary key.
|
@@ -149,6 +148,14 @@ class Joosy.Resources.Base extends Joosy.Module
|
|
149
148
|
|
150
149
|
shim
|
151
150
|
|
151
|
+
#
|
152
|
+
# Creates new instance of Resource using values from form
|
153
|
+
#
|
154
|
+
# @param [DOMElement] form Form to grab
|
155
|
+
#
|
156
|
+
@grab: (form) ->
|
157
|
+
@build({}).grab form
|
158
|
+
|
152
159
|
#
|
153
160
|
# Makes base shim-function for making instances through build or making instance clones
|
154
161
|
#
|
@@ -193,7 +200,23 @@ class Joosy.Resources.Base extends Joosy.Module
|
|
193
200
|
load: (data, clear=false) ->
|
194
201
|
@data = {} if clear
|
195
202
|
@__fillData data
|
196
|
-
return
|
203
|
+
return @
|
204
|
+
|
205
|
+
#
|
206
|
+
# Updates the Resource with a data from given form
|
207
|
+
#
|
208
|
+
# @param [DOMElement] form Form to grab
|
209
|
+
#
|
210
|
+
grab: (form) ->
|
211
|
+
data = {}
|
212
|
+
for field in $(form).serializeArray()
|
213
|
+
unless data[field.name]
|
214
|
+
data[field.name] = field.value
|
215
|
+
else
|
216
|
+
data[field.name] = [data[field.name]] unless data[field.name] instanceof Array
|
217
|
+
data[field.name].push field.value
|
218
|
+
|
219
|
+
@load data
|
197
220
|
|
198
221
|
#
|
199
222
|
# Getter for wrapped data
|
@@ -110,24 +110,27 @@ Joosy.Modules.DOM =
|
|
110
110
|
|
111
111
|
return unless events
|
112
112
|
|
113
|
-
Object.each events, (
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
113
|
+
Object.each events, (keys, method) =>
|
114
|
+
for key in keys.split(',')
|
115
|
+
key = key.replace(/^\s+/, '')
|
116
|
+
|
117
|
+
unless Object.isFunction method
|
118
|
+
method = @[method]
|
119
|
+
callback = (event) ->
|
120
|
+
method.call module, $(this), event
|
121
|
+
|
122
|
+
match = key.match @eventSplitter
|
123
|
+
eventName = match[1]
|
124
|
+
selector = @__extractSelector match[2]
|
125
|
+
|
126
|
+
if selector == ""
|
127
|
+
@$container.bind eventName, callback
|
128
|
+
Joosy.Modules.Log.debugAs @, "#{eventName} binded on container"
|
129
|
+
else if selector == undefined
|
130
|
+
throw new Error "Unknown element #{match[2]} in #{Joosy.Module.__className @constructor} (maybe typo?)"
|
131
|
+
else
|
132
|
+
@$container.on eventName, selector, callback
|
133
|
+
Joosy.Modules.Log.debugAs @, "#{eventName} binded on #{selector}"
|
131
134
|
|
132
135
|
# @private
|
133
136
|
__clearContainer: ->
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: joosy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.0.alpha.
|
4
|
+
version: 1.2.0.alpha.68
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Boris Staal
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-08-
|
13
|
+
date: 2013-08-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: sprockets
|