appjs-rails 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +14 -0
- data/app/assets/javascripts/app.js +25 -1
- data/appjs-rails.gemspec +1 -0
- data/lib/appjs/rails/version.rb +1 -1
- data/spec/javascripts/appSpec.js +37 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -56,6 +56,20 @@ Generation UUID
|
|
56
56
|
app._uuid(); //6b644386-6ccb-98af-1144-6b8de194387a
|
57
57
|
```
|
58
58
|
|
59
|
+
We can Extend Array object by using function
|
60
|
+
|
61
|
+
```javascript
|
62
|
+
app._config.array()
|
63
|
+
```
|
64
|
+
|
65
|
+
Now all Array object has got functions
|
66
|
+
|
67
|
+
```javascript
|
68
|
+
[1, 2, 3].equal('2, 3'); // false
|
69
|
+
[1, 2, 3].any(); // true
|
70
|
+
[1, 2, 3].empty(); // false
|
71
|
+
['1', '2', '3'].each(function(item) {console.log('item: ' + item)} );
|
72
|
+
```
|
59
73
|
# License
|
60
74
|
|
61
75
|
appjs-rails uses the MIT license. Please check the [LICENSE][] file for more details.
|
@@ -33,7 +33,31 @@ var app = (function() {
|
|
33
33
|
_ajax: {
|
34
34
|
addEvent: {
|
35
35
|
lockAfterClick: function() {
|
36
|
-
$("a[data-remote='true']").bind('ajax:')
|
36
|
+
$("a[data-remote='true']").bind('ajax:beforeSend', function(){
|
37
|
+
window.example = "beforeSend"
|
38
|
+
}).bind("ajax:success", function() {
|
39
|
+
window.example += 'success';
|
40
|
+
}).bind("ajax:complete", function(event, data, status, xhr) {
|
41
|
+
window.example += 'complete';
|
42
|
+
});
|
43
|
+
}
|
44
|
+
}
|
45
|
+
},
|
46
|
+
_config: {
|
47
|
+
array: function(){
|
48
|
+
Array.prototype.each = function(fn) {
|
49
|
+
for(var i=0; i<this.length; i++) {
|
50
|
+
fn(this[i]);
|
51
|
+
}
|
52
|
+
}
|
53
|
+
Array.prototype.any = function() {
|
54
|
+
return (this.length > 0);
|
55
|
+
}
|
56
|
+
Array.prototype.empty = function() {
|
57
|
+
return (this.length == 0);
|
58
|
+
}
|
59
|
+
Array.prototype.equal = function(nextArray) {
|
60
|
+
return JSON.stringify(this) == JSON.stringify(nextArray);
|
37
61
|
}
|
38
62
|
}
|
39
63
|
},
|
data/appjs-rails.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
22
|
spec.add_development_dependency "jasmine"
|
23
23
|
spec.add_development_dependency "rails", '>= 3.0.0'
|
24
|
+
# spec.add_development_dependency "jquery-rails", '>= 2.0.0'
|
24
25
|
spec.add_development_dependency "rake"
|
25
26
|
end
|
26
27
|
|
data/lib/appjs/rails/version.rb
CHANGED
data/spec/javascripts/appSpec.js
CHANGED
@@ -12,7 +12,43 @@ describe("app", function() {
|
|
12
12
|
});
|
13
13
|
});
|
14
14
|
|
15
|
-
it("
|
15
|
+
it("#_uuid", function() {
|
16
16
|
expect(app._uuid()).toMatch(/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/);
|
17
17
|
});
|
18
|
+
|
19
|
+
describe('#_config', function(){
|
20
|
+
|
21
|
+
beforeEach(function(){
|
22
|
+
app._config.array();
|
23
|
+
})
|
24
|
+
|
25
|
+
it('#array', function(){
|
26
|
+
var result = "";
|
27
|
+
['-3', '4', 'example'].each(function(item){
|
28
|
+
result = result + item;
|
29
|
+
})
|
30
|
+
expect(result).toEqual('-34example');
|
31
|
+
})
|
32
|
+
|
33
|
+
it('#any', function(){
|
34
|
+
expect(['-3', '4', 'example'].any()).toEqual(true);
|
35
|
+
})
|
36
|
+
|
37
|
+
it('#empty', function(){
|
38
|
+
expect([].empty()).toEqual(true);
|
39
|
+
})
|
40
|
+
|
41
|
+
it('#equal', function(){
|
42
|
+
expect([1, '2', 3].equal([1, 3])).toEqual(false);
|
43
|
+
expect([1, '2', 3].equal([1, '2', 3])).toEqual(true);
|
44
|
+
})
|
45
|
+
|
46
|
+
});
|
47
|
+
|
48
|
+
describe('#_ajax', function(){
|
49
|
+
it('#addEvent', function(){
|
50
|
+
//app._ajax.addEvent.lockAfterClick();
|
51
|
+
})
|
52
|
+
})
|
53
|
+
|
18
54
|
});
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appjs-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-01-
|
12
|
+
date: 2014-01-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|