padrino-gen 0.9.23 → 0.9.24

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,91 @@
1
+ /*
2
+ * Padrino Javascript Jquery Adapter
3
+ * Created for use with Padrino Ruby Web Framework (http://www.padrinorb.com)
4
+ **/
5
+
6
+ /* Remote Form Support
7
+ * form_for @user, '/user', :remote => true
8
+ **/
9
+
10
+ $("form[data-remote=true]").live('submit', function(e) {
11
+ e.preventDefault(); e.stopped = true;
12
+ var element = $(e.target);
13
+ var message = element.data('confirm');
14
+ if (message && !confirm(message)) { return false; }
15
+ JSAdapter.sendRequest(element, {
16
+ verb: element.data('method') || element.attr('method') || 'post',
17
+ url: element.attr('action'),
18
+ params: element.serializeArray()
19
+ });
20
+ });
21
+
22
+ /* Confirmation Support
23
+ * link_to 'sign out', '/logout', :confirm => "Log out?"
24
+ **/
25
+
26
+ $("a[data-confirm]").live('click', function(e) {
27
+ var message = $(this).data('confirm');
28
+ if (!confirm(message)) { e.preventDefault(); e.stopped = true; }
29
+ });
30
+
31
+ /*
32
+ * Link Remote Support
33
+ * link_to 'add item', '/create', :remote => true
34
+ **/
35
+
36
+ $("a[data-remote=true]").live('click', function(e) {
37
+ var element = $(this);
38
+ if (e.stopped) return;
39
+ e.preventDefault(); e.stopped = true;
40
+ JSAdapter.sendRequest(element, {
41
+ verb: element.data('method') || 'get',
42
+ url: element.attr('href')
43
+ });
44
+ });
45
+
46
+ /*
47
+ * Link Method Support
48
+ * link_to 'delete item', '/destroy', :method => :delete
49
+ **/
50
+
51
+ $("a[data-method]:not([data-remote])").live('click', function(e) {
52
+ if (e.stopped) return;
53
+ JSAdapter.sendMethod($(e.target));
54
+ e.preventDefault(); e.stopped = true;
55
+ });
56
+
57
+ /* JSAdapter */
58
+ var JSAdapter = {
59
+ // Sends an xhr request to the specified url with given verb and params
60
+ // JSAdapter.sendRequest(element, { verb: 'put', url : '...', params: {} });
61
+ sendRequest : function(element, options) {
62
+ var verb = options.verb, url = options.url, params = options.params;
63
+ var event = element.trigger("ajax:before");
64
+ if (event.stopped) return false;
65
+ $.ajax({
66
+ url: url,
67
+ type: verb.toUpperCase() || 'POST',
68
+ data: params || [],
69
+ dataType: 'script',
70
+
71
+ beforeSend: function(request) { element.trigger("ajax:loading", [ request ]); },
72
+ complete: function(request) { element.trigger("ajax:complete", [ request ]); },
73
+ success: function(request) { element.trigger("ajax:success", [ request ]); },
74
+ error: function(request) { element.trigger("ajax:failure", [ request ]); }
75
+ });
76
+ element.trigger("ajax:after");
77
+ },
78
+ // Triggers a particular method verb to be triggered in a form posting to the url
79
+ // JSAdapter.sendMethod(element);
80
+ sendMethod : function(element) {
81
+ var verb = element.data('method');
82
+ var url = element.attr('href');
83
+ var form = $('<form method="post" action="'+url+'"></form>');
84
+ form.hide().appendTo('body');
85
+ if (verb !== 'post') {
86
+ var field = '<input type="hidden" name="_method" value="' + verb + '" />';
87
+ form.append(field);
88
+ }
89
+ form.submit();
90
+ }
91
+ };
@@ -0,0 +1,104 @@
1
+ /*
2
+ * Padrino Javascript Mootools Adapter
3
+ * Created for use with Padrino Ruby Web Framework (http://www.padrinorb.com)
4
+ **/
5
+
6
+ // Halt Definition
7
+ Event.implement({ halt: function() { this.stop(); this.stopped = true; }});
8
+
9
+ window.addEvent('domready', function() {
10
+
11
+ /* Remote Form Support
12
+ * form_for @user, '/user', :remote => true
13
+ **/
14
+
15
+ document.body.delegateEvent('submit', { "form[data-remote=true]" :
16
+ function(e) {
17
+ e.halt();
18
+ var element = e.target;
19
+ var message = element.get('data-confirm');
20
+ if (message && !confirm(message)) { return false; }
21
+ JSAdapter.sendRequest(element, {
22
+ verb: element.get('data-method') || element.get('method') || 'post',
23
+ url: element.get('action'),
24
+ params: element.toQueryString()
25
+ });
26
+ }
27
+ });
28
+
29
+ /* Confirmation Support
30
+ * link_to 'sign out', '/logout', :confirm => "Log out?"
31
+ **/
32
+
33
+ document.body.delegateEvent('click', { "a[data-confirm]" :
34
+ function(e) {
35
+ var message = e.target.get('data-confirm');
36
+ if (message && !confirm(message)) { e.halt(); }
37
+ }
38
+ });
39
+
40
+ /*
41
+ * Link Remote Support
42
+ * link_to 'add item', '/create', :remote => true
43
+ **/
44
+
45
+ document.body.delegateEvent('click', { "a[data-remote]" :
46
+ function(e) {
47
+ if (e.stopped) return; e.halt();
48
+ var element = e.target;
49
+ JSAdapter.sendRequest(element, {
50
+ verb: element.get('data-method') || 'get',
51
+ url: element.get('href')
52
+ });
53
+ }
54
+ });
55
+
56
+ /*
57
+ * Link Method Support
58
+ * link_to 'delete item', '/destroy', :method => :delete
59
+ **/
60
+
61
+ document.body.delegateEvent('click', { "a[data-method]:not([data-remote])" :
62
+ function(e) {
63
+ if (e.stopped) return;
64
+ console.log(e.target);
65
+ JSAdapter.sendMethod(e.target);
66
+ e.halt();
67
+ }});
68
+ });
69
+
70
+ /* JSAdapter */
71
+ var JSAdapter = {
72
+ // Sends an xhr request to the specified url with given verb and params
73
+ // JSAdapter.sendRequest(element, { verb: 'put', url : '...', params: {} });
74
+ sendRequest : function(element, options) {
75
+ var verb = options.verb, url = options.url, params = options.params;
76
+ var event = element.fireEvent("ajax:before");
77
+ if (event.stopped) return false;
78
+ new Request({
79
+ url: url,
80
+ method: verb || 'post',
81
+ data: params || '',
82
+ evalScripts: true,
83
+
84
+ onRequest: function(request) { element.fireEvent("ajax:loading", {request: request}); },
85
+ onComplete: function(request) { element.fireEvent("ajax:complete", {request: request}); },
86
+ onSuccess: function(request) { element.fireEvent("ajax:success", {request: request}); },
87
+ onFailure: function(request) { element.fireEvent("ajax:failure", {request: request}); }
88
+ }).send();
89
+ element.fireEvent("ajax:after");
90
+ },
91
+ // Triggers a particular method verb to be triggered in a form posting to the url
92
+ // JSAdapter.sendMethod(element);
93
+ sendMethod : function(element) {
94
+ var verb = element.get('data-method');
95
+ var url = element.get('href');
96
+ var form = new Element('form', { method: "POST", action: url, style: "display: none;" });
97
+ element.parentNode.adopt(form);
98
+ if (verb !== 'post') {
99
+ var field = new Element('input', { type: 'hidden', name: '_method', value: verb });
100
+ form.adopt(field);
101
+ }
102
+ form.submit();
103
+ }
104
+ };
@@ -0,0 +1,106 @@
1
+ /*
2
+ * Padrino Javascript Prototype + LowPro Adapter
3
+ * Created for use with Padrino Ruby Web Framework (http://www.padrinorb.com)
4
+ **/
5
+
6
+ document.observe("dom:loaded", function() {
7
+
8
+ /* Remote Form Support
9
+ * form_for @user, '/user', :remote => true
10
+ **/
11
+
12
+ document.observe("submit", function(e) {
13
+ var element = e.findElement("form[data-remote=true]");
14
+ if (element) {
15
+ e.stop();
16
+ var message = element.readAttribute('data-confirm');
17
+ if (message && !confirm(message)) { return false; }
18
+ JSAdapter.sendRequest(element, {
19
+ verb:element.readAttribute('data-method') || element.readAttribute('method') || 'post',
20
+ url: element.readAttribute('action'),
21
+ params: element.serialize(true)
22
+ });
23
+ }
24
+ });
25
+
26
+ /* Confirmation Support
27
+ * link_to 'sign out', '/logout', :confirm => "Log out?"
28
+ **/
29
+
30
+ document.observe("click", function(e) {
31
+ var element = e.findElement("a[data-confirm]");
32
+ if (element) {
33
+ var message = element.readAttribute('data-confirm');
34
+ if (!confirm(message)) { e.stop(); }
35
+ }
36
+ });
37
+
38
+ /*
39
+ * Link Remote Support
40
+ * link_to 'add item', '/create', :remote => true
41
+ **/
42
+
43
+ document.observe("click", function(e) {
44
+ var element = e.findElement("a[data-remote]");
45
+ if (element) {
46
+ if (e.stopped) return;
47
+ e.stop();
48
+ JSAdapter.sendRequest(element, {
49
+ verb: element.readAttribute('data-method') || 'get',
50
+ url: element.readAttribute('href')
51
+ });
52
+ }
53
+ });
54
+
55
+ /*
56
+ * Link Method Support
57
+ * link_to 'delete item', '/destroy', :method => :delete
58
+ **/
59
+
60
+ document.observe("click", function(e) {
61
+ var element = e.findElement("a[data-method]:not([data-remote])");
62
+ if (element) {
63
+ if (e.stopped) return;
64
+ JSAdapter.sendMethod(e.target);
65
+ e.stop();
66
+ }
67
+ });
68
+
69
+ });
70
+
71
+ /* JSAdapter */
72
+ var JSAdapter = {
73
+ // Sends an xhr request to the specified url with given verb and params
74
+ // JSAdapter.sendRequest(element, { verb: 'put', url : '...', params: {} });
75
+ sendRequest : function(element, options) {
76
+ var verb = options.verb, url = options.url, params = options.params;
77
+ var event = element.fire("ajax:before");
78
+ if (event.stopped) return false;
79
+ new Ajax.Request(url, {
80
+ method: verb || 'post',
81
+ parameters: params || {},
82
+ evalScripts: true,
83
+
84
+ onLoading: function(request) { element.fire("ajax:loading", {request: request}); },
85
+ onLoaded: function(request) { element.fire("ajax:loaded", {request: request}); },
86
+ onInteractive: function(request) { element.fire("ajax:interactive", {request: request}); },
87
+ onComplete: function(request) { element.fire("ajax:complete", {request: request}); },
88
+ onSuccess: function(request) { element.fire("ajax:success", {request: request}); },
89
+ onFailure: function(request) { element.fire("ajax:failure", {request: request}); }
90
+ });
91
+ element.fire("ajax:after");
92
+ },
93
+ // Triggers a particular method verb to be triggered in a form posting to the url
94
+ // JSAdapter.sendMethod(element);
95
+ sendMethod : function(element) {
96
+ var verb = element.readAttribute('data-method');
97
+ var url = element.readAttribute('href');
98
+ var form = new Element('form', { method: "POST", action: url, style: "display: none;" });
99
+ element.parentNode.insert(form);
100
+ if (verb !== 'post') {
101
+ var field = new Element('input', { type: 'hidden', name: '_method', value: verb });
102
+ form.insert(field);
103
+ }
104
+ form.submit();
105
+ }
106
+ };
@@ -0,0 +1,95 @@
1
+ /*
2
+ * Padrino RightJS UJS Adapter
3
+ * Created for use with Padrino Ruby Web Framework (http://www.padrinorb.com)
4
+ **/
5
+
6
+ // Halt Definition
7
+ Event.include({ halt: function() { this.stop(); this.stopped = true; }});
8
+
9
+ /* Remote Form Support
10
+ * form_for @user, '/user', :remote => true
11
+ **/
12
+
13
+ "form[data-remote=true]".on('submit', function(e) {
14
+ e.halt();
15
+ var element = e.target;
16
+ var message = element.get('data-confirm');
17
+ if (message && !confirm(message)) { return false; }
18
+ JSAdapter.sendRequest(element, {
19
+ verb: element.get('data-method') || element.get('method') || 'post',
20
+ url: element.get('action'),
21
+ params: element.values()
22
+ });
23
+ });
24
+
25
+ /* Confirmation Support
26
+ * link_to 'sign out', '/logout', :confirm => "Log out?"
27
+ **/
28
+
29
+ "a[data-confirm]".on('click', function(e) {
30
+ var message = e.target.get('data-confirm');
31
+ if (!confirm(message)) { e.halt(); }
32
+ });
33
+
34
+ /*
35
+ * Link Remote Support
36
+ * link_to 'add item', '/create', :remote => true
37
+ **/
38
+
39
+ "a[data-remote=true]".on('click', function(e) {
40
+ var element = e.target;
41
+ if (e.stopped) return;
42
+ e.halt();
43
+ JSAdapter.sendRequest(element, {
44
+ verb: element.get('data-method') || 'get',
45
+ url: element.get('href')
46
+ });
47
+ });
48
+
49
+ /*
50
+ * Link Method Support
51
+ * link_to 'delete item', '/destroy', :method => :delete
52
+ **/
53
+
54
+ "a[data-method]:not([data-remote])".on('click', function(e) {
55
+ if (e.stopped) return;
56
+ JSAdapter.sendMethod(e.target);
57
+ e.halt();
58
+ });
59
+
60
+ /* JSAdapter */
61
+ var JSAdapter = {
62
+ // Sends an xhr request to the specified url with given verb and params
63
+ // JSAdapter.sendRequest(element, { verb: 'put', url : '...', params: {} });
64
+ sendRequest : function(element, options) {
65
+ var verb = options.verb, url = options.url, params = options.params;
66
+ var event = element.fire("ajax:before");
67
+ if (event.stopped) return false;
68
+ Xhr.load(url, {
69
+ method: verb || 'post',
70
+ params: params || {},
71
+ evalScripts: true,
72
+
73
+ onLoading: function(request) { element.fire("ajax:loading", {request: request}); },
74
+ onLoaded: function(request) { element.fire("ajax:loaded", {request: request}); },
75
+ onInteractive: function(request) { element.fire("ajax:interactive", {request: request}); },
76
+ onComplete: function(request) { element.fire("ajax:complete", {request: request}); },
77
+ onSuccess: function(request) { element.fire("ajax:success", {request: request}); },
78
+ onFailure: function(request) { element.fire("ajax:failure", {request: request}); }
79
+ });
80
+ element.fire("ajax:after");
81
+ },
82
+ // Triggers a particular method verb to be triggered in a form posting to the url
83
+ // JSAdapter.sendMethod(element);
84
+ sendMethod : function(element) {
85
+ var verb = element.get('data-method');
86
+ var url = element.get('href');
87
+ var form = new Element('form', { method: "POST", action: url, style: "display: none;" });
88
+ element.parentNode.insert(form);
89
+ if (verb !== 'post') {
90
+ var field = new Element('input', { type: 'hidden', name: '_method', value: verb });
91
+ form.insert(field);
92
+ }
93
+ form.submit();
94
+ }
95
+ };
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: padrino-gen
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 23
10
- version: 0.9.23
9
+ - 24
10
+ version: 0.9.24
11
11
  platform: ruby
12
12
  authors:
13
13
  - Padrino Team
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2011-03-07 00:00:00 +01:00
21
+ date: 2011-04-28 00:00:00 +02:00
22
22
  default_executable: padrino-gen
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
@@ -29,12 +29,12 @@ dependencies:
29
29
  requirements:
30
30
  - - "="
31
31
  - !ruby/object:Gem::Version
32
- hash: 21
32
+ hash: 11
33
33
  segments:
34
34
  - 0
35
35
  - 9
36
- - 23
37
- version: 0.9.23
36
+ - 24
37
+ version: 0.9.24
38
38
  type: :runtime
39
39
  version_requirements: *id001
40
40
  - !ruby/object:Gem::Dependency
@@ -144,6 +144,20 @@ files:
144
144
  - lib/padrino-gen/generators/templates/scripts/mootools-core.js
145
145
  - lib/padrino-gen/generators/templates/scripts/protopak.js
146
146
  - lib/padrino-gen/generators/templates/scripts/right.js
147
+ - lib/padrino-gen/generators/templates/static/js/dojo.js
148
+ - lib/padrino-gen/generators/templates/static/js/ext.js
149
+ - lib/padrino-gen/generators/templates/static/js/jquery.js
150
+ - lib/padrino-gen/generators/templates/static/js/lowpro.js
151
+ - lib/padrino-gen/generators/templates/static/js/mootools.js
152
+ - lib/padrino-gen/generators/templates/static/js/protopak.js
153
+ - lib/padrino-gen/generators/templates/static/js/right.js
154
+ - lib/padrino-gen/generators/templates/static/README.rdoc
155
+ - lib/padrino-gen/generators/templates/static/ujs/dojo.js
156
+ - lib/padrino-gen/generators/templates/static/ujs/ext.js
157
+ - lib/padrino-gen/generators/templates/static/ujs/jquery.js
158
+ - lib/padrino-gen/generators/templates/static/ujs/mootools.js
159
+ - lib/padrino-gen/generators/templates/static/ujs/prototype.js
160
+ - lib/padrino-gen/generators/templates/static/ujs/right.js
147
161
  - lib/padrino-gen/padrino-tasks/activerecord.rb
148
162
  - lib/padrino-gen/padrino-tasks/datamapper.rb
149
163
  - lib/padrino-gen/padrino-tasks/mongoid.rb