navi 0.0.17 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/.gitignore +50 -0
  2. data/.rvmrc +1 -1
  3. data/Gemfile +1 -46
  4. data/Gemfile.lock +136 -116
  5. data/{README.textile → README.md} +32 -28
  6. data/Rakefile +1 -44
  7. data/features/step_definitions/category_steps.rb +1 -1
  8. data/features/step_definitions/page_steps.rb +1 -1
  9. data/lib/navi.rb +4 -11
  10. data/lib/navi/navigable/base.rb +1 -0
  11. data/lib/navi/navigable/instance_methods.rb +27 -1
  12. data/lib/navi/version.rb +3 -0
  13. data/navi.gemspec +44 -272
  14. data/spec/dummy/Rakefile +1 -1
  15. data/spec/dummy/app/assets/javascripts/application.js +7 -0
  16. data/spec/dummy/{public → app/assets}/javascripts/jquery-ui.js +0 -0
  17. data/spec/dummy/{public → app/assets}/javascripts/jquery-ui.min.js +0 -0
  18. data/spec/dummy/{public → app/assets}/javascripts/jquery.js +0 -0
  19. data/spec/dummy/{public → app/assets}/javascripts/jquery.min.js +0 -0
  20. data/spec/dummy/{public → app/assets}/javascripts/jquery_ujs.js +0 -0
  21. data/spec/dummy/{public → app/assets}/javascripts/menu_items/index.js +0 -0
  22. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  23. data/spec/dummy/app/controllers/categories_controller.rb +1 -0
  24. data/spec/dummy/{lib/tasks → app/mailers}/.gitkeep +0 -0
  25. data/spec/dummy/{public/stylesheets → app/models}/.gitkeep +0 -0
  26. data/spec/dummy/app/views/layouts/application.html.erb +1 -1
  27. data/spec/dummy/app/views/menu_items/index.html.haml +0 -3
  28. data/spec/dummy/config/application.rb +14 -9
  29. data/spec/dummy/config/boot.rb +1 -1
  30. data/spec/dummy/config/database.yml +13 -7
  31. data/spec/dummy/config/environments/development.rb +7 -3
  32. data/spec/dummy/config/environments/production.rb +23 -12
  33. data/spec/dummy/config/environments/test.rb +5 -1
  34. data/spec/dummy/config/initializers/{navigable.rb → navi.rb} +0 -0
  35. data/spec/dummy/config/initializers/secret_token.rb +1 -1
  36. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  37. data/spec/dummy/config/locales/en.yml +1 -1
  38. data/spec/dummy/config/routes.rb +1 -57
  39. data/spec/dummy/db/seeds.rb +4 -4
  40. data/spec/dummy/{vendor/plugins → lib/assets}/.gitkeep +0 -0
  41. data/spec/factories.rb +15 -0
  42. data/spec/navi/navi_spec.rb +1 -1
  43. data/spec/navi/navigable_spec.rb +23 -0
  44. data/spec/navi/navigator_spec.rb +24 -12
  45. data/spec/spec_helper.rb +18 -3
  46. metadata +284 -504
  47. data/VERSION +0 -1
  48. data/spec/blueprints.rb +0 -23
  49. data/spec/dummy/.gitignore +0 -6
  50. data/spec/dummy/config/cucumber.yml +0 -8
  51. data/spec/dummy/config/navigation.rb +0 -7
  52. data/spec/dummy/lib/tasks/cucumber.rake +0 -57
  53. data/spec/dummy/public/images/rails.png +0 -0
  54. data/spec/dummy/public/index.html +0 -239
  55. data/spec/dummy/public/javascripts/application.js +0 -2
  56. data/spec/dummy/public/javascripts/rails.js +0 -315
  57. data/spec/dummy/public/robots.txt +0 -5
  58. data/spec/dummy/script/cucumber +0 -10
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.0.17
@@ -1,23 +0,0 @@
1
- require 'machinist/active_record'
2
- require 'sham'
3
- require 'faker'
4
-
5
- Sham.name { Faker::Name.name }
6
- Sham.email { Faker::Internet.email }
7
- Sham.title { Faker::Lorem.sentence }
8
- Sham.body { Faker::Lorem.paragraph }
9
- #Sham.url { "http://somedomain.com" }
10
-
11
- Category.blueprint do
12
- name
13
- end
14
-
15
- MenuItem.blueprint do
16
- label {Sham.name}
17
- url { "http://somedomain.com" }
18
- site_id {1}
19
- end
20
-
21
- Page.blueprint do
22
- name
23
- end
@@ -1,6 +0,0 @@
1
- .bundle
2
- db/*.sqlite3
3
- log/*.log
4
- tmp/
5
- *.sw*
6
- **/*.sw*
@@ -1,8 +0,0 @@
1
- <%
2
- rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
3
- rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
4
- std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
5
- %>
6
- default: <%= std_opts %> features
7
- wip: --tags @wip:3 --wip features
8
- rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
@@ -1,7 +0,0 @@
1
- # May not need this file since the items are given dynamically
2
- # unless there are global config stuff needed
3
- #
4
- # This is here though because SimpleNavigation complains
5
- # if this isn't here
6
- SimpleNavigation::Configuration.run do |navigation|
7
- end
@@ -1,57 +0,0 @@
1
- # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2
- # It is recommended to regenerate this file in the future when you upgrade to a
3
- # newer version of cucumber-rails. Consider adding your own code to a new file
4
- # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
- # files.
6
-
7
-
8
- unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
9
-
10
- vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
11
- $LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
12
-
13
- begin
14
- require 'cucumber/rake/task'
15
-
16
- namespace :cucumber do
17
- Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t|
18
- t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
19
- t.fork = true # You may get faster startup if you set this to false
20
- t.profile = 'default'
21
- end
22
-
23
- Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t|
24
- t.binary = vendored_cucumber_bin
25
- t.fork = true # You may get faster startup if you set this to false
26
- t.profile = 'wip'
27
- end
28
-
29
- Cucumber::Rake::Task.new({:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t|
30
- t.binary = vendored_cucumber_bin
31
- t.fork = true # You may get faster startup if you set this to false
32
- t.profile = 'rerun'
33
- end
34
-
35
- desc 'Run all features'
36
- task :all => [:ok, :wip]
37
- end
38
- desc 'Alias for cucumber:ok'
39
- task :cucumber => 'cucumber:ok'
40
-
41
- task :default => :cucumber
42
-
43
- task :features => :cucumber do
44
- STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
45
- end
46
-
47
- # In case we don't have ActiveRecord, append a no-op task that we can depend upon.
48
- task 'db:test:prepare' do
49
- end
50
- rescue LoadError
51
- desc 'cucumber rake task not available (cucumber not installed)'
52
- task :cucumber do
53
- abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
54
- end
55
- end
56
-
57
- end
@@ -1,239 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Ruby on Rails: Welcome aboard</title>
5
- <style type="text/css" media="screen">
6
- body {
7
- margin: 0;
8
- margin-bottom: 25px;
9
- padding: 0;
10
- background-color: #f0f0f0;
11
- font-family: "Lucida Grande", "Bitstream Vera Sans", "Verdana";
12
- font-size: 13px;
13
- color: #333;
14
- }
15
-
16
- h1 {
17
- font-size: 28px;
18
- color: #000;
19
- }
20
-
21
- a {color: #03c}
22
- a:hover {
23
- background-color: #03c;
24
- color: white;
25
- text-decoration: none;
26
- }
27
-
28
-
29
- #page {
30
- background-color: #f0f0f0;
31
- width: 750px;
32
- margin: 0;
33
- margin-left: auto;
34
- margin-right: auto;
35
- }
36
-
37
- #content {
38
- float: left;
39
- background-color: white;
40
- border: 3px solid #aaa;
41
- border-top: none;
42
- padding: 25px;
43
- width: 500px;
44
- }
45
-
46
- #sidebar {
47
- float: right;
48
- width: 175px;
49
- }
50
-
51
- #footer {
52
- clear: both;
53
- }
54
-
55
-
56
- #header, #about, #getting-started {
57
- padding-left: 75px;
58
- padding-right: 30px;
59
- }
60
-
61
-
62
- #header {
63
- background-image: url("images/rails.png");
64
- background-repeat: no-repeat;
65
- background-position: top left;
66
- height: 64px;
67
- }
68
- #header h1, #header h2 {margin: 0}
69
- #header h2 {
70
- color: #888;
71
- font-weight: normal;
72
- font-size: 16px;
73
- }
74
-
75
-
76
- #about h3 {
77
- margin: 0;
78
- margin-bottom: 10px;
79
- font-size: 14px;
80
- }
81
-
82
- #about-content {
83
- background-color: #ffd;
84
- border: 1px solid #fc0;
85
- margin-left: -55px;
86
- margin-right: -10px;
87
- }
88
- #about-content table {
89
- margin-top: 10px;
90
- margin-bottom: 10px;
91
- font-size: 11px;
92
- border-collapse: collapse;
93
- }
94
- #about-content td {
95
- padding: 10px;
96
- padding-top: 3px;
97
- padding-bottom: 3px;
98
- }
99
- #about-content td.name {color: #555}
100
- #about-content td.value {color: #000}
101
-
102
- #about-content ul {
103
- padding: 0;
104
- list-style-type: none;
105
- }
106
-
107
- #about-content.failure {
108
- background-color: #fcc;
109
- border: 1px solid #f00;
110
- }
111
- #about-content.failure p {
112
- margin: 0;
113
- padding: 10px;
114
- }
115
-
116
-
117
- #getting-started {
118
- border-top: 1px solid #ccc;
119
- margin-top: 25px;
120
- padding-top: 15px;
121
- }
122
- #getting-started h1 {
123
- margin: 0;
124
- font-size: 20px;
125
- }
126
- #getting-started h2 {
127
- margin: 0;
128
- font-size: 14px;
129
- font-weight: normal;
130
- color: #333;
131
- margin-bottom: 25px;
132
- }
133
- #getting-started ol {
134
- margin-left: 0;
135
- padding-left: 0;
136
- }
137
- #getting-started li {
138
- font-size: 18px;
139
- color: #888;
140
- margin-bottom: 25px;
141
- }
142
- #getting-started li h2 {
143
- margin: 0;
144
- font-weight: normal;
145
- font-size: 18px;
146
- color: #333;
147
- }
148
- #getting-started li p {
149
- color: #555;
150
- font-size: 13px;
151
- }
152
-
153
-
154
- #sidebar ul {
155
- margin-left: 0;
156
- padding-left: 0;
157
- }
158
- #sidebar ul h3 {
159
- margin-top: 25px;
160
- font-size: 16px;
161
- padding-bottom: 10px;
162
- border-bottom: 1px solid #ccc;
163
- }
164
- #sidebar li {
165
- list-style-type: none;
166
- }
167
- #sidebar ul.links li {
168
- margin-bottom: 5px;
169
- }
170
-
171
- </style>
172
- <script type="text/javascript">
173
- function about() {
174
- info = document.getElementById('about-content');
175
- if (window.XMLHttpRequest)
176
- { xhr = new XMLHttpRequest(); }
177
- else
178
- { xhr = new ActiveXObject("Microsoft.XMLHTTP"); }
179
- xhr.open("GET","rails/info/properties",false);
180
- xhr.send("");
181
- info.innerHTML = xhr.responseText;
182
- info.style.display = 'block'
183
- }
184
- </script>
185
- </head>
186
- <body>
187
- <div id="page">
188
- <div id="sidebar">
189
- <ul id="sidebar-items">
190
- <li>
191
- <h3>Browse the documentation</h3>
192
- <ul class="links">
193
- <li><a href="http://api.rubyonrails.org/">Rails API</a></li>
194
- <li><a href="http://stdlib.rubyonrails.org/">Ruby standard library</a></li>
195
- <li><a href="http://corelib.rubyonrails.org/">Ruby core</a></li>
196
- <li><a href="http://guides.rubyonrails.org/">Rails Guides</a></li>
197
- </ul>
198
- </li>
199
- </ul>
200
- </div>
201
-
202
- <div id="content">
203
- <div id="header">
204
- <h1>Welcome aboard</h1>
205
- <h2>You&rsquo;re riding Ruby on Rails!</h2>
206
- </div>
207
-
208
- <div id="about">
209
- <h3><a href="rails/info/properties" onclick="about(); return false">About your application&rsquo;s environment</a></h3>
210
- <div id="about-content" style="display: none"></div>
211
- </div>
212
-
213
- <div id="getting-started">
214
- <h1>Getting started</h1>
215
- <h2>Here&rsquo;s how to get rolling:</h2>
216
-
217
- <ol>
218
- <li>
219
- <h2>Use <code>rails generate</code> to create your models and controllers</h2>
220
- <p>To see all available options, run it without parameters.</p>
221
- </li>
222
-
223
- <li>
224
- <h2>Set up a default route and remove or rename this file</h2>
225
- <p>Routes are set up in config/routes.rb.</p>
226
- </li>
227
-
228
- <li>
229
- <h2>Create your database</h2>
230
- <p>Run <code>rake db:migrate</code> to create your database. If you're not using SQLite (the default), edit <code>config/database.yml</code> with your username and password.</p>
231
- </li>
232
- </ol>
233
- </div>
234
- </div>
235
-
236
- <div id="footer">&nbsp;</div>
237
- </div>
238
- </body>
239
- </html>
@@ -1,2 +0,0 @@
1
- // Place your application-specific JavaScript functions and classes here
2
- // This file is automatically included by javascript_include_tag :defaults
@@ -1,315 +0,0 @@
1
- /**
2
- * Unobtrusive scripting adapter for jQuery
3
- *
4
- * Requires jQuery 1.4.4 or later.
5
- * https://github.com/rails/jquery-ujs
6
-
7
- * Uploading file using rails.js
8
- * =============================
9
- *
10
- * By default, browsers do not allow files to be uploaded via AJAX. As a result, if there are any non-blank file fields
11
- * in the remote form, this adapter aborts the AJAX submission and allows the form to submit through standard means.
12
- *
13
- * The `ajax:aborted:file` event allows you to bind your own handler to process the form submission however you wish.
14
- *
15
- * Ex:
16
- * $('form').live('ajax:aborted:file', function(event, elements){
17
- * // Implement own remote file-transfer handler here for non-blank file inputs passed in `elements`.
18
- * // Returning false in this handler tells rails.js to disallow standard form submission
19
- * return false;
20
- * });
21
- *
22
- * The `ajax:aborted:file` event is fired when a file-type input is detected with a non-blank value.
23
- *
24
- * Third-party tools can use this hook to detect when an AJAX file upload is attempted, and then use
25
- * techniques like the iframe method to upload the file instead.
26
- *
27
- * Required fields in rails.js
28
- * ===========================
29
- *
30
- * If any blank required inputs (required="required") are detected in the remote form, the whole form submission
31
- * is canceled. Note that this is unlike file inputs, which still allow standard (non-AJAX) form submission.
32
- *
33
- * The `ajax:aborted:required` event allows you to bind your own handler to inform the user of blank required inputs.
34
- *
35
- * !! Note that Opera does not fire the form's submit event if there are blank required inputs, so this event may never
36
- * get fired in Opera. This event is what causes other browsers to exhibit the same submit-aborting behavior.
37
- *
38
- * Ex:
39
- * $('form').live('ajax:aborted:required', function(event, elements){
40
- * // Returning false in this handler tells rails.js to submit the form anyway.
41
- * // The blank required inputs are passed to this function in `elements`.
42
- * return ! confirm("Would you like to submit the form with missing info?");
43
- * });
44
- */
45
-
46
- (function($) {
47
- // Shorthand to make it a little easier to call public rails functions from within rails.js
48
- var rails;
49
-
50
- $.rails = rails = {
51
- // Link elements bound by jquery-ujs
52
- linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote]',
53
-
54
- // Form elements bound by jquery-ujs
55
- formSubmitSelector: 'form',
56
-
57
- // Form input elements bound by jquery-ujs
58
- formInputClickSelector: 'form input[type=submit], form input[type=image], form button[type=submit], form button:not([type])',
59
-
60
- // Form input elements disabled during form submission
61
- disableSelector: 'input[data-disable-with], button[data-disable-with], textarea[data-disable-with]',
62
-
63
- // Form input elements re-enabled after form submission
64
- enableSelector: 'input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled',
65
-
66
- // Form required input elements
67
- requiredInputSelector: 'input[name][required]:not([disabled]),textarea[name][required]:not([disabled])',
68
-
69
- // Form file input elements
70
- fileInputSelector: 'input:file',
71
-
72
- // Make sure that every Ajax request sends the CSRF token
73
- CSRFProtection: function(xhr) {
74
- var token = $('meta[name="csrf-token"]').attr('content');
75
- if (token) xhr.setRequestHeader('X-CSRF-Token', token);
76
- },
77
-
78
- // Triggers an event on an element and returns false if the event result is false
79
- fire: function(obj, name, data) {
80
- var event = $.Event(name);
81
- obj.trigger(event, data);
82
- return event.result !== false;
83
- },
84
-
85
- // Default confirm dialog, may be overridden with custom confirm dialog in $.rails.confirm
86
- confirm: function(message) {
87
- return confirm(message);
88
- },
89
-
90
- // Default ajax function, may be overridden with custom function in $.rails.ajax
91
- ajax: function(options) {
92
- return $.ajax(options);
93
- },
94
-
95
- // Submits "remote" forms and links with ajax
96
- handleRemote: function(element) {
97
- var method, url, data,
98
- dataType = element.data('type') || ($.ajaxSettings && $.ajaxSettings.dataType);
99
-
100
- if (rails.fire(element, 'ajax:before')) {
101
-
102
- if (element.is('form')) {
103
- method = element.attr('method');
104
- url = element.attr('action');
105
- data = element.serializeArray();
106
- // memoized value from clicked submit button
107
- var button = element.data('ujs:submit-button');
108
- if (button) {
109
- data.push(button);
110
- element.data('ujs:submit-button', null);
111
- }
112
- } else {
113
- method = element.data('method');
114
- url = element.attr('href');
115
- data = element.data('params') || null;
116
- }
117
-
118
- rails.ajax({
119
- url: url, type: method || 'GET', data: data, dataType: dataType,
120
- // stopping the "ajax:beforeSend" event will cancel the ajax request
121
- beforeSend: function(xhr, settings) {
122
- if (settings.dataType === undefined) {
123
- xhr.setRequestHeader('accept', '*/*;q=0.5, ' + settings.accepts.script);
124
- }
125
- return rails.fire(element, 'ajax:beforeSend', [xhr, settings]);
126
- },
127
- success: function(data, status, xhr) {
128
- element.trigger('ajax:success', [data, status, xhr]);
129
- },
130
- complete: function(xhr, status) {
131
- element.trigger('ajax:complete', [xhr, status]);
132
- },
133
- error: function(xhr, status, error) {
134
- element.trigger('ajax:error', [xhr, status, error]);
135
- }
136
- });
137
- }
138
- },
139
-
140
- // Handles "data-method" on links such as:
141
- // <a href="/users/5" data-method="delete" rel="nofollow" data-confirm="Are you sure?">Delete</a>
142
- handleMethod: function(link) {
143
- var href = link.attr('href'),
144
- method = link.data('method'),
145
- csrf_token = $('meta[name=csrf-token]').attr('content'),
146
- csrf_param = $('meta[name=csrf-param]').attr('content'),
147
- form = $('<form method="post" action="' + href + '"></form>'),
148
- metadata_input = '<input name="_method" value="' + method + '" type="hidden" />';
149
-
150
- if (csrf_param !== undefined && csrf_token !== undefined) {
151
- metadata_input += '<input name="' + csrf_param + '" value="' + csrf_token + '" type="hidden" />';
152
- }
153
-
154
- form.hide().append(metadata_input).appendTo('body');
155
- form.submit();
156
- },
157
-
158
- /* Disables form elements:
159
- - Caches element value in 'ujs:enable-with' data store
160
- - Replaces element text with value of 'data-disable-with' attribute
161
- - Adds disabled=disabled attribute
162
- */
163
- disableFormElements: function(form) {
164
- form.find(rails.disableSelector).each(function() {
165
- var element = $(this), method = element.is('button') ? 'html' : 'val';
166
- element.data('ujs:enable-with', element[method]());
167
- element[method](element.data('disable-with'));
168
- element.attr('disabled', 'disabled');
169
- });
170
- },
171
-
172
- /* Re-enables disabled form elements:
173
- - Replaces element text with cached value from 'ujs:enable-with' data store (created in `disableFormElements`)
174
- - Removes disabled attribute
175
- */
176
- enableFormElements: function(form) {
177
- form.find(rails.enableSelector).each(function() {
178
- var element = $(this), method = element.is('button') ? 'html' : 'val';
179
- if (element.data('ujs:enable-with')) element[method](element.data('ujs:enable-with'));
180
- element.removeAttr('disabled');
181
- });
182
- },
183
-
184
- /* For 'data-confirm' attribute:
185
- - Fires `confirm` event
186
- - Shows the confirmation dialog
187
- - Fires the `confirm:complete` event
188
-
189
- Returns `true` if no function stops the chain and user chose yes; `false` otherwise.
190
- Attaching a handler to the element's `confirm` event that returns a `falsy` value cancels the confirmation dialog.
191
- Attaching a handler to the element's `confirm:complete` event that returns a `falsy` value makes this function
192
- return false. The `confirm:complete` event is fired whether or not the user answered true or false to the dialog.
193
- */
194
- allowAction: function(element) {
195
- var message = element.data('confirm'),
196
- answer = false, callback;
197
- if (!message) { return true; }
198
-
199
- if (rails.fire(element, 'confirm')) {
200
- answer = rails.confirm(message);
201
- callback = rails.fire(element, 'confirm:complete', [answer]);
202
- }
203
- return answer && callback;
204
- },
205
-
206
- // Helper function which checks for blank inputs in a form that match the specified CSS selector
207
- blankInputs: function(form, specifiedSelector, nonBlank) {
208
- var inputs = $(), input,
209
- selector = specifiedSelector || 'input,textarea';
210
- form.find(selector).each(function() {
211
- input = $(this);
212
- // Collect non-blank inputs if nonBlank option is true, otherwise, collect blank inputs
213
- if (nonBlank ? input.val() : !input.val()) {
214
- inputs = inputs.add(input);
215
- }
216
- });
217
- return inputs.length ? inputs : false;
218
- },
219
-
220
- // Helper function which checks for non-blank inputs in a form that match the specified CSS selector
221
- nonBlankInputs: function(form, specifiedSelector) {
222
- return rails.blankInputs(form, specifiedSelector, true); // true specifies nonBlank
223
- },
224
-
225
- // Helper function, needed to provide consistent behavior in IE
226
- stopEverything: function(e) {
227
- $(e.target).trigger('ujs:everythingStopped');
228
- e.stopImmediatePropagation();
229
- return false;
230
- },
231
-
232
- // find all the submit events directly bound to the form and
233
- // manually invoke them. If anyone returns false then stop the loop
234
- callFormSubmitBindings: function(form) {
235
- var events = form.data('events'), continuePropagation = true;
236
- if (events !== undefined && events['submit'] !== undefined) {
237
- $.each(events['submit'], function(i, obj){
238
- if (typeof obj.handler === 'function') return continuePropagation = obj.handler(obj.data);
239
- });
240
- }
241
- return continuePropagation;
242
- }
243
- };
244
-
245
- // ajaxPrefilter is a jQuery 1.5 feature
246
- if ('ajaxPrefilter' in $) {
247
- $.ajaxPrefilter(function(options, originalOptions, xhr){ rails.CSRFProtection(xhr); });
248
- } else {
249
- $(document).ajaxSend(function(e, xhr){ rails.CSRFProtection(xhr); });
250
- }
251
-
252
- $(rails.linkClickSelector).live('click.rails', function(e) {
253
- var link = $(this);
254
- if (!rails.allowAction(link)) return rails.stopEverything(e);
255
-
256
- if (link.data('remote') !== undefined) {
257
- rails.handleRemote(link);
258
- return false;
259
- } else if (link.data('method')) {
260
- rails.handleMethod(link);
261
- return false;
262
- }
263
- });
264
-
265
- $(rails.formSubmitSelector).live('submit.rails', function(e) {
266
- var form = $(this),
267
- remote = form.data('remote') !== undefined,
268
- blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector),
269
- nonBlankFileInputs = rails.nonBlankInputs(form, rails.fileInputSelector);
270
-
271
- if (!rails.allowAction(form)) return rails.stopEverything(e);
272
-
273
- // skip other logic when required values are missing or file upload is present
274
- if (blankRequiredInputs && rails.fire(form, 'ajax:aborted:required', [blankRequiredInputs])) {
275
- return rails.stopEverything(e);
276
- }
277
-
278
- if (remote) {
279
- if (nonBlankFileInputs) {
280
- return rails.fire(form, 'ajax:aborted:file', [nonBlankFileInputs]);
281
- }
282
-
283
- // If browser does not support submit bubbling, then this live-binding will be called before direct
284
- // bindings. Therefore, we should directly call any direct bindings before remotely submitting form.
285
- if (!$.support.submitBubbles && rails.callFormSubmitBindings(form) === false) return rails.stopEverything(e);
286
-
287
- rails.handleRemote(form);
288
- return false;
289
- } else {
290
- // slight timeout so that the submit button gets properly serialized
291
- setTimeout(function(){ rails.disableFormElements(form); }, 13);
292
- }
293
- });
294
-
295
- $(rails.formInputClickSelector).live('click.rails', function(event) {
296
- var button = $(this);
297
-
298
- if (!rails.allowAction(button)) return rails.stopEverything(event);
299
-
300
- // register the pressed submit button
301
- var name = button.attr('name'),
302
- data = name ? {name:name, value:button.val()} : null;
303
-
304
- button.closest('form').data('ujs:submit-button', data);
305
- });
306
-
307
- $(rails.formSubmitSelector).live('ajax:beforeSend.rails', function(event) {
308
- if (this == event.target) rails.disableFormElements($(this));
309
- });
310
-
311
- $(rails.formSubmitSelector).live('ajax:complete.rails', function(event) {
312
- if (this == event.target) rails.enableFormElements($(this));
313
- });
314
-
315
- })( jQuery );