coolerator.vision 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +18 -0
- data/Rakefile +47 -0
- data/VERSION +1 -0
- data/app/placeholder.txt +0 -0
- data/coolerator.vision.gemspec +76 -0
- data/lib/coolerator.vision.rb +1 -0
- data/public/javascripts/vendor/coolerator/coolerator.base.js +42 -0
- data/public/javascripts/vendor/coolerator/coolerator.filter.js +49 -0
- data/public/javascripts/vendor/coolerator/coolerator.module.js +3 -0
- data/public/javascripts/vendor/coolerator/coolerator.registrar.js +87 -0
- data/public/javascripts/vendor/coolerator/coolerator.remote.js +234 -0
- data/public/javascripts/vendor/coolerator/coolerator.view.js +82 -0
- data/public/javascripts/vendor/jquery/jquery.easing.js +205 -0
- data/public/javascripts/vendor/jquery/jquery.js +4376 -0
- data/public/javascripts/vendor/prez/prez.js +466 -0
- data/rails/init.rb +2 -0
- data/spec/coolerator.vision_spec.rb +7 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +9 -0
- metadata +87 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Corey Innis
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
= coolerator.vision
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(if you want to have your own version, that is fine but
|
13
|
+
bump version in a commit by itself I can ignore when I pull)
|
14
|
+
* Send me a pull request. Bonus points for topic branches.
|
15
|
+
|
16
|
+
== Copyright
|
17
|
+
|
18
|
+
Copyright (c) 2009 Corey Innis. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "coolerator.vision"
|
8
|
+
gem.summary = "A Rails plugin"
|
9
|
+
gem.description = "A Rails plugin"
|
10
|
+
gem.email = "corey@coolerator.net"
|
11
|
+
gem.homepage = "http://github.com/coreyti/coolerator.vision"
|
12
|
+
gem.authors = ["Corey Innis"]
|
13
|
+
gem.files += Dir['app/**/*.*']
|
14
|
+
gem.files += Dir['public/**/*.*']
|
15
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
16
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
17
|
+
end
|
18
|
+
Jeweler::GemcutterTasks.new
|
19
|
+
rescue LoadError
|
20
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
21
|
+
end
|
22
|
+
|
23
|
+
require 'spec/rake/spectask'
|
24
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
25
|
+
spec.libs << 'lib' << 'spec'
|
26
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
27
|
+
end
|
28
|
+
|
29
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
30
|
+
spec.libs << 'lib' << 'spec'
|
31
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
32
|
+
spec.rcov = true
|
33
|
+
end
|
34
|
+
|
35
|
+
task :spec => :check_dependencies
|
36
|
+
|
37
|
+
task :default => :spec
|
38
|
+
|
39
|
+
require 'rake/rdoctask'
|
40
|
+
Rake::RDocTask.new do |rdoc|
|
41
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
42
|
+
|
43
|
+
rdoc.rdoc_dir = 'rdoc'
|
44
|
+
rdoc.title = "coolerator.vision #{version}"
|
45
|
+
rdoc.rdoc_files.include('README*')
|
46
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
47
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/app/placeholder.txt
ADDED
File without changes
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{coolerator.vision}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Corey Innis"]
|
12
|
+
s.date = %q{2009-11-10}
|
13
|
+
s.description = %q{A Rails plugin}
|
14
|
+
s.email = %q{corey@coolerator.net}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"app/placeholder.txt",
|
27
|
+
"app/placeholder.txt",
|
28
|
+
"coolerator.vision.gemspec",
|
29
|
+
"lib/coolerator.vision.rb",
|
30
|
+
"public/javascripts/vendor/coolerator/coolerator.base.js",
|
31
|
+
"public/javascripts/vendor/coolerator/coolerator.base.js",
|
32
|
+
"public/javascripts/vendor/coolerator/coolerator.filter.js",
|
33
|
+
"public/javascripts/vendor/coolerator/coolerator.filter.js",
|
34
|
+
"public/javascripts/vendor/coolerator/coolerator.module.js",
|
35
|
+
"public/javascripts/vendor/coolerator/coolerator.module.js",
|
36
|
+
"public/javascripts/vendor/coolerator/coolerator.registrar.js",
|
37
|
+
"public/javascripts/vendor/coolerator/coolerator.registrar.js",
|
38
|
+
"public/javascripts/vendor/coolerator/coolerator.remote.js",
|
39
|
+
"public/javascripts/vendor/coolerator/coolerator.remote.js",
|
40
|
+
"public/javascripts/vendor/coolerator/coolerator.view.js",
|
41
|
+
"public/javascripts/vendor/coolerator/coolerator.view.js",
|
42
|
+
"public/javascripts/vendor/jquery/jquery.easing.js",
|
43
|
+
"public/javascripts/vendor/jquery/jquery.easing.js",
|
44
|
+
"public/javascripts/vendor/jquery/jquery.js",
|
45
|
+
"public/javascripts/vendor/jquery/jquery.js",
|
46
|
+
"public/javascripts/vendor/prez/prez.js",
|
47
|
+
"public/javascripts/vendor/prez/prez.js",
|
48
|
+
"rails/init.rb",
|
49
|
+
"spec/coolerator.vision_spec.rb",
|
50
|
+
"spec/spec.opts",
|
51
|
+
"spec/spec_helper.rb"
|
52
|
+
]
|
53
|
+
s.homepage = %q{http://github.com/coreyti/coolerator.vision}
|
54
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
55
|
+
s.require_paths = ["lib"]
|
56
|
+
s.rubygems_version = %q{1.3.5}
|
57
|
+
s.summary = %q{A Rails plugin}
|
58
|
+
s.test_files = [
|
59
|
+
"spec/coolerator.vision_spec.rb",
|
60
|
+
"spec/spec_helper.rb"
|
61
|
+
]
|
62
|
+
|
63
|
+
if s.respond_to? :specification_version then
|
64
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
65
|
+
s.specification_version = 3
|
66
|
+
|
67
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
68
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
69
|
+
else
|
70
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
71
|
+
end
|
72
|
+
else
|
73
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
module CooleratorVision ; end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
(function($) {
|
2
|
+
// $.noConflict();
|
3
|
+
|
4
|
+
Coolerator = {
|
5
|
+
DOM : {
|
6
|
+
ELEMENT_NODE : 1,
|
7
|
+
ATTRIBUTE_NODE : 2,
|
8
|
+
TEXT_NODE : 3,
|
9
|
+
CDATA_SECTION_NODE : 4,
|
10
|
+
ENTITY_REFERENCE_NODE : 5,
|
11
|
+
ENTITY_NODE : 6,
|
12
|
+
PROCESSING_INSTRUCTION_NODE : 7,
|
13
|
+
COMMENT_NODE : 8,
|
14
|
+
DOCUMENT_NODE : 9,
|
15
|
+
DOCUMENT_TYPE_NODE : 10,
|
16
|
+
DOCUMENT_FRAGMENT_NODE : 11,
|
17
|
+
NOTATION_NODE : 12
|
18
|
+
},
|
19
|
+
|
20
|
+
REGEX : {
|
21
|
+
FUNCTION_BODY : /^[^\{]*{((.*\n*)*)}/m
|
22
|
+
}
|
23
|
+
};
|
24
|
+
|
25
|
+
$.fn.extend({
|
26
|
+
match_for : function match_for(selector) {
|
27
|
+
var match = undefined;
|
28
|
+
|
29
|
+
$.each(this, function(i, content) {
|
30
|
+
if(Coolerator.DOM.ELEMENT_NODE === content.nodeType) {
|
31
|
+
match = (content = $(content)) && content.is(selector) ? content : content.find(selector);
|
32
|
+
|
33
|
+
if(match.length) {
|
34
|
+
return false;
|
35
|
+
}
|
36
|
+
}
|
37
|
+
});
|
38
|
+
|
39
|
+
return match;
|
40
|
+
}
|
41
|
+
});
|
42
|
+
})(jQuery);
|
@@ -0,0 +1,49 @@
|
|
1
|
+
(function($) {
|
2
|
+
$.extend(Coolerator, {
|
3
|
+
Filters : {
|
4
|
+
global : [],
|
5
|
+
scoped : {},
|
6
|
+
|
7
|
+
get : function get(scope) {
|
8
|
+
return $.merge(this.global, this.scoped[scope]);
|
9
|
+
}
|
10
|
+
},
|
11
|
+
|
12
|
+
Filter : function Filter() {
|
13
|
+
var config = $.merge(arguments, ['*'])[0];
|
14
|
+
|
15
|
+
if('object' === typeof(config)) {
|
16
|
+
var scope = config.scope || '*';
|
17
|
+
var filter = {
|
18
|
+
before : (config.before || function no_op() {}),
|
19
|
+
after : (config.after || function no_op() {})
|
20
|
+
};
|
21
|
+
}
|
22
|
+
else {
|
23
|
+
var scope = config;
|
24
|
+
var filter = this;
|
25
|
+
}
|
26
|
+
|
27
|
+
if(scope === '*') {
|
28
|
+
Coolerator.Filters.global.push(filter);
|
29
|
+
}
|
30
|
+
else {
|
31
|
+
Coolerator.Filters.scoped[scope] = $.merge(Coolerator.Filters.scoped[scope] || [], [filter]);
|
32
|
+
}
|
33
|
+
}
|
34
|
+
});
|
35
|
+
|
36
|
+
$.extend(Coolerator.Filter.prototype, {
|
37
|
+
before : function before(fn) {
|
38
|
+
if('function' == typeof fn) {
|
39
|
+
this.before = fn;
|
40
|
+
}
|
41
|
+
},
|
42
|
+
|
43
|
+
after : function after(fn) {
|
44
|
+
if('function' == typeof fn) {
|
45
|
+
this.after = fn;
|
46
|
+
}
|
47
|
+
}
|
48
|
+
});
|
49
|
+
})(jQuery);
|
@@ -0,0 +1,87 @@
|
|
1
|
+
(function($) {
|
2
|
+
$.extend(Coolerator, {
|
3
|
+
Registrar : {
|
4
|
+
subscriptions : {},
|
5
|
+
|
6
|
+
subscribe : function subscribe(listener, fn) {
|
7
|
+
var self = this;
|
8
|
+
|
9
|
+
function register(event_type, subscription) {
|
10
|
+
if(subscription.selector.jquery) {
|
11
|
+
subscription.selector.bind(event_type, function(e) {
|
12
|
+
subscription.handler.call(e.target, $.extend(e, { listener : listener }));
|
13
|
+
});
|
14
|
+
}
|
15
|
+
else {
|
16
|
+
$(subscription.selector).live(event_type, function(e) {
|
17
|
+
if(e.button && e.button !== 0) {
|
18
|
+
return; // primary button click only
|
19
|
+
}
|
20
|
+
|
21
|
+
var target = $(e.target);
|
22
|
+
var actual = subscription.selector === 'body' ? target : target.closest(subscription.selector);
|
23
|
+
var result = subscription.handler.call(actual, $.extend(e, { listener : listener }));
|
24
|
+
|
25
|
+
if(false === result) {
|
26
|
+
e.preventDefault();
|
27
|
+
e.stopImmediatePropagation();
|
28
|
+
// return false;
|
29
|
+
}
|
30
|
+
else if('object' === typeof result) {
|
31
|
+
// TODO: allow the chain to be broken (and the bubble as well);
|
32
|
+
result.before && result.before.call(actual, e);
|
33
|
+
result.render && result.render.call(actual, e);
|
34
|
+
result.after && result.after .call(actual, e);
|
35
|
+
}
|
36
|
+
});
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
function subscription(callback) {
|
41
|
+
var result = {
|
42
|
+
on : function on(event_type, selector) {
|
43
|
+
var selector = selector || 'body';
|
44
|
+
|
45
|
+
function use(handler) {
|
46
|
+
if($.isArray(selector)) {
|
47
|
+
$.each(selector, function each_selector() {
|
48
|
+
callback(event_type, { selector: this, handler: handler });
|
49
|
+
});
|
50
|
+
}
|
51
|
+
else {
|
52
|
+
callback(event_type, { selector: selector, handler: handler });
|
53
|
+
}
|
54
|
+
|
55
|
+
return this;
|
56
|
+
}
|
57
|
+
|
58
|
+
return {
|
59
|
+
use : use
|
60
|
+
};
|
61
|
+
},
|
62
|
+
|
63
|
+
use : function use(handler) {
|
64
|
+
function on(event_type, selector) {
|
65
|
+
var selector = selector || 'body';
|
66
|
+
|
67
|
+
callback(event_type, { selector: selector, handler: handler });
|
68
|
+
return this;
|
69
|
+
}
|
70
|
+
|
71
|
+
return {
|
72
|
+
on : on
|
73
|
+
};
|
74
|
+
}
|
75
|
+
};
|
76
|
+
|
77
|
+
return result;
|
78
|
+
}
|
79
|
+
|
80
|
+
$(function ready() {
|
81
|
+
// HMM... this register passed as a callback is completely unnecessary.
|
82
|
+
fn.call(listener, subscription(register));
|
83
|
+
});
|
84
|
+
}
|
85
|
+
}
|
86
|
+
});
|
87
|
+
})(jQuery);
|
@@ -0,0 +1,234 @@
|
|
1
|
+
(function($) {
|
2
|
+
$.extend(Coolerator, {
|
3
|
+
Remote : {
|
4
|
+
// $c.get(...) ??? - or - $c8r.get(...) ???
|
5
|
+
get : function get(options) {
|
6
|
+
var self = this;
|
7
|
+
var data = options.data || [];
|
8
|
+
var source = $(options.source); // defaults to Document
|
9
|
+
|
10
|
+
$.ajax({
|
11
|
+
type : 'GET',
|
12
|
+
url : options.url,
|
13
|
+
data : data,
|
14
|
+
dataType : options.dataType || 'json',
|
15
|
+
success : function success(response, status) {
|
16
|
+
self.responder.success.call(self, source, response, status, options);
|
17
|
+
},
|
18
|
+
complete : function complete(request, status) {
|
19
|
+
self.responder.complete.call(self, source, request, status);
|
20
|
+
}
|
21
|
+
});
|
22
|
+
},
|
23
|
+
|
24
|
+
post : function post() {
|
25
|
+
|
26
|
+
},
|
27
|
+
|
28
|
+
put : function put() {
|
29
|
+
|
30
|
+
},
|
31
|
+
|
32
|
+
delete : function delete() {
|
33
|
+
|
34
|
+
},
|
35
|
+
|
36
|
+
// TODO: consider allowing for an optional scope argument.
|
37
|
+
capture : function capture() {
|
38
|
+
var self = this;
|
39
|
+
// TODO: consider binding even if the value is false, but
|
40
|
+
// only handling if the value is truthy. this would
|
41
|
+
// allow the behavior to be changed on the fly.
|
42
|
+
var attribute = '[data-remote]:not([data-remote=false])';
|
43
|
+
var selectors = {
|
44
|
+
form : 'form' + attribute,
|
45
|
+
link : 'a' + attribute
|
46
|
+
};
|
47
|
+
|
48
|
+
function filter() {
|
49
|
+
Coolerator.Filter({
|
50
|
+
before : function before(view) {
|
51
|
+
$.each(view, function(name, partial) {
|
52
|
+
var match = partial.match_for(selectors.form);
|
53
|
+
|
54
|
+
if(match) {
|
55
|
+
match.bind('submit', function(e) {
|
56
|
+
return self.form.handle.call(e.target, $.extend(e, { listener : self }));
|
57
|
+
});
|
58
|
+
}
|
59
|
+
});
|
60
|
+
}
|
61
|
+
});
|
62
|
+
}
|
63
|
+
|
64
|
+
function subscribe() {
|
65
|
+
Coolerator.Registrar.subscribe(self, function(registrar) {
|
66
|
+
with(registrar) {
|
67
|
+
on('click', selectors.link)
|
68
|
+
.use(this.link.handle);
|
69
|
+
|
70
|
+
on('click', selectors.form + ' input[type=submit]')
|
71
|
+
.use(this.form.on_click);
|
72
|
+
|
73
|
+
on('keypress', selectors.form + ' :input')
|
74
|
+
.use(this.form.on_keypress);
|
75
|
+
}
|
76
|
+
});
|
77
|
+
}
|
78
|
+
|
79
|
+
filter()
|
80
|
+
subscribe();
|
81
|
+
},
|
82
|
+
|
83
|
+
link : {
|
84
|
+
exceptions : [],
|
85
|
+
|
86
|
+
handle : function handle(e) {
|
87
|
+
var self = e.listener;
|
88
|
+
var link = $(this);
|
89
|
+
|
90
|
+
// TODO: consider filters
|
91
|
+
function trigger() {
|
92
|
+
link.trigger('remote/request');
|
93
|
+
}
|
94
|
+
|
95
|
+
function send() {
|
96
|
+
trigger();
|
97
|
+
|
98
|
+
var type = link.attr('data-remote').toUpperCase();
|
99
|
+
type = (type === 'TRUE' ) ? 'GET' : type;
|
100
|
+
var data = (type === 'DELETE') ? { _method : 'delete' } : {};
|
101
|
+
var mime = link.attr('data-mimetype') || 'json';
|
102
|
+
|
103
|
+
$.ajax({
|
104
|
+
type : type,
|
105
|
+
url : link.attr('href'),
|
106
|
+
data : data,
|
107
|
+
dataType : mime,
|
108
|
+
success : function success(response, status) {
|
109
|
+
self.responder.success.call(self, link, response, status);
|
110
|
+
},
|
111
|
+
complete : function complete(request, status) {
|
112
|
+
self.responder.complete.call(self, link, request, status);
|
113
|
+
}
|
114
|
+
});
|
115
|
+
|
116
|
+
return false;
|
117
|
+
}
|
118
|
+
|
119
|
+
$.each(self.link.exceptions, function(i, selector) {
|
120
|
+
if(link.is(selector)) {
|
121
|
+
send = function send() {};
|
122
|
+
}
|
123
|
+
});
|
124
|
+
|
125
|
+
return send();
|
126
|
+
},
|
127
|
+
|
128
|
+
except : function except(selector) {
|
129
|
+
this.exceptions.push(selector);
|
130
|
+
}
|
131
|
+
},
|
132
|
+
|
133
|
+
form : {
|
134
|
+
handle : function handle(e) {
|
135
|
+
var self = e.listener;
|
136
|
+
var form = $(this).closest('form');
|
137
|
+
|
138
|
+
function send() {
|
139
|
+
var type = (form.attr('data-remote') || form.attr('method')).toUpperCase();
|
140
|
+
type = (type === 'TRUE') ? 'POST' : type;
|
141
|
+
var data = form.serialize();
|
142
|
+
var mime = form.attr('data-mimetype') || 'json';
|
143
|
+
|
144
|
+
$.ajax({
|
145
|
+
type : type,
|
146
|
+
url : form.attr('action'),
|
147
|
+
data : data,
|
148
|
+
dataType : mime,
|
149
|
+
success : function success(response, status) {
|
150
|
+
// this : jQuery XHR (?)
|
151
|
+
// self : Coolerator.Remote
|
152
|
+
// form : jQuery form instance
|
153
|
+
// e : submit event
|
154
|
+
// response : response from server
|
155
|
+
self.responder.success.call(self, form, response, status);
|
156
|
+
},
|
157
|
+
complete : function complete(request, status) {
|
158
|
+
self.responder.complete.call(self, form, request, status);
|
159
|
+
}
|
160
|
+
});
|
161
|
+
|
162
|
+
return false;
|
163
|
+
}
|
164
|
+
|
165
|
+
return send();
|
166
|
+
},
|
167
|
+
|
168
|
+
on_click : function on_click(e) {
|
169
|
+
this.closest('form').submit();
|
170
|
+
return false;
|
171
|
+
},
|
172
|
+
|
173
|
+
on_keypress : function on_keypress(e) {
|
174
|
+
if(e.which === 13) {
|
175
|
+
this.closest('form').submit();
|
176
|
+
return false;
|
177
|
+
}
|
178
|
+
}
|
179
|
+
},
|
180
|
+
|
181
|
+
// TODO: rename this as 'responder'
|
182
|
+
responder : {
|
183
|
+
success : function success(source, response, status, options) {
|
184
|
+
// this : Coolerator.Remote
|
185
|
+
// source : source form/link
|
186
|
+
|
187
|
+
this.filters.prepare(response);
|
188
|
+
this.filters.before (response);
|
189
|
+
|
190
|
+
var e = $.extend($.Event(response.trigger), {
|
191
|
+
presenter : response.presenter,
|
192
|
+
templates : response.templates,
|
193
|
+
options : options,
|
194
|
+
status : status
|
195
|
+
});
|
196
|
+
|
197
|
+
source.trigger(e);
|
198
|
+
options && options.success && options.success.apply(source, [response, status]);
|
199
|
+
|
200
|
+
this.filters.after(response);
|
201
|
+
},
|
202
|
+
|
203
|
+
complete : function complete(source, request, status) {
|
204
|
+
console.info('TODO: response.complete', source, request, status);
|
205
|
+
}
|
206
|
+
},
|
207
|
+
|
208
|
+
filters : {
|
209
|
+
prepare : function prepare(response) {
|
210
|
+
$.each(response.templates, function prepare_views(name, content) {
|
211
|
+
response.templates[name] = $(content);
|
212
|
+
response.filters = Coolerator.Filters.get(response.trigger);
|
213
|
+
});
|
214
|
+
},
|
215
|
+
|
216
|
+
before : function before(response) {
|
217
|
+
if(response.filters) {
|
218
|
+
$.each(response.filters, function(i, filter) {
|
219
|
+
filter.before(response.templates);
|
220
|
+
});
|
221
|
+
}
|
222
|
+
},
|
223
|
+
|
224
|
+
after : function after(response) {
|
225
|
+
if(response.filters) {
|
226
|
+
$.each(response.filters, function(i, filter) {
|
227
|
+
filter.after(response.templates);
|
228
|
+
});
|
229
|
+
}
|
230
|
+
}
|
231
|
+
}
|
232
|
+
}
|
233
|
+
});
|
234
|
+
})(jQuery);
|