honkster-jelly 0.7.4 → 0.7.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/VERSION.yml +1 -1
- data/generators/jelly/templates/javascripts/ajax_with_jelly.js +1 -6
- data/generators/jelly/templates/javascripts/jelly.js +50 -46
- data/jelly.gemspec +2 -2
- metadata +2 -2
data/Rakefile
CHANGED
@@ -25,7 +25,7 @@ end
|
|
25
25
|
begin
|
26
26
|
require 'jeweler'
|
27
27
|
Jeweler::Tasks.new do |gemspec|
|
28
|
-
|
28
|
+
gemspec.name = ENV["GEM_PREFIX"] ? "#{ENV["GEM_PREFIX"]}-jelly" : "jelly"
|
29
29
|
gemspec.summary = "a sweet unobtrusive javascript framework for jQuery and Rails"
|
30
30
|
gemspec.description = "Jelly provides a set of tools and conventions for creating rich ajax/javascript web applications with jQuery and Ruby on Rails."
|
31
31
|
gemspec.email = "opensource@pivotallabs.com"
|
data/VERSION.yml
CHANGED
@@ -22,12 +22,7 @@ if(!window.Jelly) Jelly = new Object();
|
|
22
22
|
return $.extend({
|
23
23
|
dataType: 'json',
|
24
24
|
cache: false,
|
25
|
-
success :
|
25
|
+
success : Jelly.notifyObservers.bind(Jelly)
|
26
26
|
}, otherParams);
|
27
27
|
};
|
28
|
-
|
29
|
-
$.ajaxWithJelly.onSuccess = function(json) {
|
30
|
-
Jelly.notifyObservers(json);
|
31
|
-
return true;
|
32
|
-
};
|
33
28
|
})(jQuery);
|
@@ -12,9 +12,18 @@
|
|
12
12
|
*/
|
13
13
|
|
14
14
|
if (!window.Jelly) Jelly = new Object();
|
15
|
+
if (!Function.prototype.bind) {
|
16
|
+
Function.prototype.bind = function(object) {
|
17
|
+
var self = this;
|
18
|
+
return function() {
|
19
|
+
return self.apply(object, arguments);
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
15
23
|
Jelly.init = function() {
|
16
24
|
this.components = [];
|
17
25
|
this.observers = [];
|
26
|
+
this.notifyObservers = this.Observers.notify;
|
18
27
|
this.Components.initCalled = false;
|
19
28
|
this.Pages.init();
|
20
29
|
var self = this;
|
@@ -40,67 +49,62 @@ Jelly.attach = function() {
|
|
40
49
|
}
|
41
50
|
};
|
42
51
|
|
43
|
-
Jelly.
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
observers.push(Jelly.observers[i]);
|
52
|
+
Jelly.Components = {
|
53
|
+
init: function() {
|
54
|
+
for (var i = 0; i < Jelly.components.length; i++) {
|
55
|
+
this.initComponentFromDefinition(Jelly.components[i]);
|
48
56
|
}
|
57
|
+
this.initCalled = true;
|
58
|
+
},
|
59
|
+
initComponentFromDefinition: function(definition) {
|
60
|
+
var observer;
|
61
|
+
if (definition.component.init) {
|
62
|
+
observer = definition.component.init.apply(definition.component, definition.arguments);
|
63
|
+
}
|
64
|
+
Jelly.observers.push(observer ? observer : definition.component);
|
65
|
+
}
|
66
|
+
};
|
67
|
+
|
68
|
+
Jelly.Observers = {
|
69
|
+
notify: function(params) {
|
70
|
+
if (this == Jelly) return Jelly.Observers.notify.call(this.observers, params);
|
71
|
+
var observers = this.slice(0);
|
49
72
|
|
50
73
|
// Deprecate 'on' in favor of making each page action a Component.
|
51
74
|
if (params.on) {
|
52
75
|
var additionalObserver = eval(params.on);
|
53
|
-
|
54
|
-
for (var i = 0; i < observers.length; i++) {
|
55
|
-
if (observers[i] == additionalObserver) {
|
56
|
-
additionalObserverAlreadyAnObserver = true;
|
57
|
-
break;
|
58
|
-
}
|
59
|
-
}
|
60
|
-
if (!additionalObserverAlreadyAnObserver) {
|
76
|
+
if (observers.indexOf(additionalObserver) == -1) {
|
61
77
|
observers.push(additionalObserver);
|
62
78
|
}
|
63
79
|
}
|
64
|
-
}
|
65
80
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
81
|
+
for (var i = 0; i < observers.length; i++) {
|
82
|
+
var observer = observers[i];
|
83
|
+
if (observer[params.method]) {
|
84
|
+
if (observer.detach && observer.detach()) {
|
85
|
+
Jelly.Observers.garbageCollectObserver.call(this, observer);
|
86
|
+
} else {
|
87
|
+
observer[params.method].apply(observer, params.arguments);
|
88
|
+
}
|
73
89
|
}
|
74
90
|
}
|
75
|
-
}
|
76
|
-
};
|
77
|
-
|
78
|
-
Jelly.garbageCollectObserver = function(observer) {
|
79
|
-
var index = Jelly.observers.indexOf(observer);
|
80
|
-
if (index > -1) {
|
81
|
-
this.arrayRemove(Jelly.observers, index, index + 1);
|
82
|
-
}
|
83
|
-
};
|
84
91
|
|
85
|
-
|
86
|
-
|
87
|
-
array.length = from < 0 ? array.length + from : from;
|
88
|
-
return array.push.apply(array, rest);
|
89
|
-
};
|
90
|
-
|
91
|
-
Jelly.Components = {
|
92
|
-
init: function() {
|
93
|
-
for (var i = 0; i < Jelly.components.length; i++) {
|
94
|
-
this.initComponentFromDefinition(Jelly.components[i]);
|
92
|
+
if (params.attach) {
|
93
|
+
Jelly.attach.apply(Jelly, params.attach);
|
95
94
|
}
|
96
|
-
this.initCalled = true;
|
97
95
|
},
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
96
|
+
|
97
|
+
garbageCollectObserver: function(observer) {
|
98
|
+
var index = this.indexOf(observer);
|
99
|
+
if (index > -1) {
|
100
|
+
Jelly.Observers.remove.call(this, index, index + 1);
|
102
101
|
}
|
103
|
-
|
102
|
+
},
|
103
|
+
|
104
|
+
remove: function(from, to) {
|
105
|
+
var rest = this.slice((to || from) + 1 || this.length);
|
106
|
+
this.length = from < 0 ? this.length + from : from;
|
107
|
+
return this.push.apply(this, rest);
|
104
108
|
}
|
105
109
|
};
|
106
110
|
|
data/jelly.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{jelly}
|
8
|
-
s.version = "0.7.
|
8
|
+
s.version = "0.7.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Pivotal Labs, Inc"]
|
12
|
-
s.date = %q{2009-12-
|
12
|
+
s.date = %q{2009-12-28}
|
13
13
|
s.description = %q{Jelly provides a set of tools and conventions for creating rich ajax/javascript web applications with jQuery and Ruby on Rails.}
|
14
14
|
s.email = %q{opensource@pivotallabs.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: honkster-jelly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pivotal Labs, Inc
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-12-
|
12
|
+
date: 2009-12-28 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|