trusty-cms 4.2.2 → 4.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -1
  3. data/Gemfile.lock +98 -89
  4. data/app/assets/config/trusty-cms/manifest.js +7 -0
  5. data/app/assets/javascripts/admin/custom_file_upload.js +7 -0
  6. data/app/controllers/admin/assets_controller.rb +1 -1
  7. data/app/models/page.rb +2 -2
  8. data/app/views/admin/assets/new.html.haml +2 -0
  9. data/config/database.yml +4 -0
  10. data/config/initializers/assets.rb +0 -4
  11. data/coverage/index.html +155 -155
  12. data/lib/trusty_cms.rb +1 -1
  13. data/node_modules/hosted-git-info/CHANGELOG.md +10 -0
  14. data/node_modules/hosted-git-info/index.js +2 -2
  15. data/node_modules/hosted-git-info/package.json +1 -1
  16. data/node_modules/lodash/README.md +2 -2
  17. data/node_modules/lodash/_baseClone.js +2 -1
  18. data/node_modules/lodash/_baseOrderBy.js +17 -2
  19. data/node_modules/lodash/_baseSet.js +4 -0
  20. data/node_modules/lodash/_baseSortedIndexBy.js +7 -4
  21. data/node_modules/lodash/_baseTrim.js +19 -0
  22. data/node_modules/lodash/_equalArrays.js +5 -4
  23. data/node_modules/lodash/_equalObjects.js +5 -4
  24. data/node_modules/lodash/_trimmedEndIndex.js +19 -0
  25. data/node_modules/lodash/core.js +48 -6
  26. data/node_modules/lodash/core.min.js +9 -9
  27. data/node_modules/lodash/filter.js +4 -0
  28. data/node_modules/lodash/flake.lock +40 -0
  29. data/node_modules/lodash/flake.nix +20 -0
  30. data/node_modules/lodash/lodash.js +59 -11
  31. data/node_modules/lodash/lodash.min.js +126 -125
  32. data/node_modules/lodash/matches.js +7 -0
  33. data/node_modules/lodash/matchesProperty.js +7 -0
  34. data/node_modules/lodash/overEvery.js +4 -0
  35. data/node_modules/lodash/overSome.js +7 -0
  36. data/node_modules/lodash/package.json +1 -1
  37. data/node_modules/lodash/parseInt.js +1 -1
  38. data/node_modules/lodash/release.md +48 -0
  39. data/node_modules/lodash/sortBy.js +3 -3
  40. data/node_modules/lodash/template.js +24 -5
  41. data/node_modules/lodash/toNumber.js +3 -5
  42. data/node_modules/lodash/trim.js +2 -4
  43. data/node_modules/lodash/trimEnd.js +3 -5
  44. data/node_modules/lodash/trimStart.js +1 -1
  45. data/spec/dummy/log/development.log +9 -163
  46. data/spec/dummy/log/test.log +536 -0
  47. data/spec/dummy/node_modules/jquery-ui-bundle/AUTHORS.txt +333 -0
  48. data/spec/dummy/node_modules/jquery-ui-bundle/LICENSE.txt +43 -0
  49. data/spec/dummy/node_modules/jquery-ui-bundle/external/jquery/jquery.js +11008 -0
  50. data/spec/dummy/node_modules/jquery-ui-bundle/images/ui-icons_444444_256x240.png +0 -0
  51. data/spec/dummy/node_modules/jquery-ui-bundle/images/ui-icons_555555_256x240.png +0 -0
  52. data/spec/dummy/node_modules/jquery-ui-bundle/images/ui-icons_777620_256x240.png +0 -0
  53. data/spec/dummy/node_modules/jquery-ui-bundle/images/ui-icons_777777_256x240.png +0 -0
  54. data/spec/dummy/node_modules/jquery-ui-bundle/images/ui-icons_cc0000_256x240.png +0 -0
  55. data/spec/dummy/node_modules/jquery-ui-bundle/images/ui-icons_ffffff_256x240.png +0 -0
  56. data/spec/dummy/node_modules/jquery-ui-bundle/index.html +559 -0
  57. data/spec/dummy/node_modules/jquery-ui-bundle/jquery-ui.css +1312 -0
  58. data/spec/dummy/node_modules/jquery-ui-bundle/jquery-ui.js +18706 -0
  59. data/spec/dummy/node_modules/jquery-ui-bundle/jquery-ui.min.css +7 -0
  60. data/spec/dummy/node_modules/jquery-ui-bundle/jquery-ui.min.js +13 -0
  61. data/spec/dummy/node_modules/jquery-ui-bundle/jquery-ui.structure.css +886 -0
  62. data/spec/dummy/node_modules/jquery-ui-bundle/jquery-ui.structure.min.css +5 -0
  63. data/spec/dummy/node_modules/jquery-ui-bundle/jquery-ui.theme.css +443 -0
  64. data/spec/dummy/node_modules/jquery-ui-bundle/jquery-ui.theme.min.css +5 -0
  65. data/spec/dummy/node_modules/jquery-ui-bundle/package.json +33 -0
  66. data/spec/dummy/node_modules/jquery-ujs/CONTRIBUTING.md +109 -0
  67. data/spec/dummy/node_modules/jquery-ujs/MIT-LICENSE +20 -0
  68. data/spec/dummy/node_modules/jquery-ujs/README.md +86 -0
  69. data/spec/dummy/node_modules/jquery-ujs/RELEASE.md +23 -0
  70. data/spec/dummy/node_modules/jquery-ujs/bower.json +19 -0
  71. data/spec/dummy/node_modules/jquery-ujs/package.json +26 -0
  72. data/spec/dummy/node_modules/jquery-ujs/src/rails.js +555 -0
  73. data/spec/dummy/node_modules/jquery/AUTHORS.txt +327 -0
  74. data/spec/dummy/node_modules/jquery/LICENSE.txt +20 -0
  75. data/spec/dummy/node_modules/jquery/README.md +62 -0
  76. data/spec/dummy/node_modules/jquery/bower.json +14 -0
  77. data/spec/dummy/node_modules/jquery/dist/jquery.js +10872 -0
  78. data/spec/dummy/node_modules/jquery/dist/jquery.min.js +2 -0
  79. data/spec/dummy/node_modules/jquery/dist/jquery.min.map +1 -0
  80. data/spec/dummy/node_modules/jquery/dist/jquery.slim.js +8777 -0
  81. data/spec/dummy/node_modules/jquery/dist/jquery.slim.min.js +2 -0
  82. data/spec/dummy/node_modules/jquery/dist/jquery.slim.min.map +1 -0
  83. data/spec/dummy/node_modules/jquery/external/sizzle/LICENSE.txt +36 -0
  84. data/spec/dummy/node_modules/jquery/external/sizzle/dist/sizzle.js +2478 -0
  85. data/spec/dummy/node_modules/jquery/external/sizzle/dist/sizzle.min.js +3 -0
  86. data/spec/dummy/node_modules/jquery/external/sizzle/dist/sizzle.min.map +1 -0
  87. data/spec/dummy/node_modules/jquery/package.json +117 -0
  88. data/spec/dummy/node_modules/jquery/src/ajax.js +873 -0
  89. data/spec/dummy/node_modules/jquery/src/ajax/jsonp.js +103 -0
  90. data/spec/dummy/node_modules/jquery/src/ajax/load.js +77 -0
  91. data/spec/dummy/node_modules/jquery/src/ajax/script.js +74 -0
  92. data/spec/dummy/node_modules/jquery/src/ajax/var/location.js +5 -0
  93. data/spec/dummy/node_modules/jquery/src/ajax/var/nonce.js +5 -0
  94. data/spec/dummy/node_modules/jquery/src/ajax/var/rquery.js +5 -0
  95. data/spec/dummy/node_modules/jquery/src/ajax/xhr.js +170 -0
  96. data/spec/dummy/node_modules/jquery/src/attributes.js +13 -0
  97. data/spec/dummy/node_modules/jquery/src/attributes/attr.js +141 -0
  98. data/spec/dummy/node_modules/jquery/src/attributes/classes.js +186 -0
  99. data/spec/dummy/node_modules/jquery/src/attributes/prop.js +143 -0
  100. data/spec/dummy/node_modules/jquery/src/attributes/support.js +33 -0
  101. data/spec/dummy/node_modules/jquery/src/attributes/val.js +191 -0
  102. data/spec/dummy/node_modules/jquery/src/callbacks.js +236 -0
  103. data/spec/dummy/node_modules/jquery/src/core.js +400 -0
  104. data/spec/dummy/node_modules/jquery/src/core/DOMEval.js +43 -0
  105. data/spec/dummy/node_modules/jquery/src/core/access.js +72 -0
  106. data/spec/dummy/node_modules/jquery/src/core/camelCase.js +23 -0
  107. data/spec/dummy/node_modules/jquery/src/core/init.js +129 -0
  108. data/spec/dummy/node_modules/jquery/src/core/isAttached.js +26 -0
  109. data/spec/dummy/node_modules/jquery/src/core/nodeName.js +13 -0
  110. data/spec/dummy/node_modules/jquery/src/core/parseHTML.js +65 -0
  111. data/spec/dummy/node_modules/jquery/src/core/parseXML.js +30 -0
  112. data/spec/dummy/node_modules/jquery/src/core/ready-no-deferred.js +97 -0
  113. data/spec/dummy/node_modules/jquery/src/core/ready.js +86 -0
  114. data/spec/dummy/node_modules/jquery/src/core/readyException.js +13 -0
  115. data/spec/dummy/node_modules/jquery/src/core/stripAndCollapse.js +14 -0
  116. data/spec/dummy/node_modules/jquery/src/core/support.js +20 -0
  117. data/spec/dummy/node_modules/jquery/src/core/toType.js +20 -0
  118. data/spec/dummy/node_modules/jquery/src/core/var/rsingleTag.js +7 -0
  119. data/spec/dummy/node_modules/jquery/src/css.js +494 -0
  120. data/spec/dummy/node_modules/jquery/src/css/addGetHookIf.js +26 -0
  121. data/spec/dummy/node_modules/jquery/src/css/adjustCSS.js +74 -0
  122. data/spec/dummy/node_modules/jquery/src/css/curCSS.js +65 -0
  123. data/spec/dummy/node_modules/jquery/src/css/finalPropName.js +42 -0
  124. data/spec/dummy/node_modules/jquery/src/css/hiddenVisibleSelectors.js +15 -0
  125. data/spec/dummy/node_modules/jquery/src/css/showHide.js +105 -0
  126. data/spec/dummy/node_modules/jquery/src/css/support.js +133 -0
  127. data/spec/dummy/node_modules/jquery/src/css/var/cssExpand.js +5 -0
  128. data/spec/dummy/node_modules/jquery/src/css/var/getStyles.js +17 -0
  129. data/spec/dummy/node_modules/jquery/src/css/var/isHiddenWithinTree.js +34 -0
  130. data/spec/dummy/node_modules/jquery/src/css/var/rboxStyle.js +7 -0
  131. data/spec/dummy/node_modules/jquery/src/css/var/rnumnonpx.js +7 -0
  132. data/spec/dummy/node_modules/jquery/src/css/var/swap.js +26 -0
  133. data/spec/dummy/node_modules/jquery/src/data.js +180 -0
  134. data/spec/dummy/node_modules/jquery/src/data/Data.js +162 -0
  135. data/spec/dummy/node_modules/jquery/src/data/var/acceptData.js +19 -0
  136. data/spec/dummy/node_modules/jquery/src/data/var/dataPriv.js +7 -0
  137. data/spec/dummy/node_modules/jquery/src/data/var/dataUser.js +7 -0
  138. data/spec/dummy/node_modules/jquery/src/deferred.js +399 -0
  139. data/spec/dummy/node_modules/jquery/src/deferred/exceptionHook.js +21 -0
  140. data/spec/dummy/node_modules/jquery/src/deprecated.js +87 -0
  141. data/spec/dummy/node_modules/jquery/src/deprecated/ajax-event-alias.js +22 -0
  142. data/spec/dummy/node_modules/jquery/src/deprecated/event.js +48 -0
  143. data/spec/dummy/node_modules/jquery/src/dimensions.js +57 -0
  144. data/spec/dummy/node_modules/jquery/src/effects.js +701 -0
  145. data/spec/dummy/node_modules/jquery/src/effects/Tween.js +125 -0
  146. data/spec/dummy/node_modules/jquery/src/effects/animatedSelector.js +15 -0
  147. data/spec/dummy/node_modules/jquery/src/event.js +892 -0
  148. data/spec/dummy/node_modules/jquery/src/event/focusin.js +58 -0
  149. data/spec/dummy/node_modules/jquery/src/event/support.js +11 -0
  150. data/spec/dummy/node_modules/jquery/src/event/trigger.js +201 -0
  151. data/spec/dummy/node_modules/jquery/src/exports/amd.js +26 -0
  152. data/spec/dummy/node_modules/jquery/src/exports/global.js +34 -0
  153. data/spec/dummy/node_modules/jquery/src/jquery.js +41 -0
  154. data/spec/dummy/node_modules/jquery/src/manipulation.js +480 -0
  155. data/spec/dummy/node_modules/jquery/src/manipulation/_evalUrl.js +32 -0
  156. data/spec/dummy/node_modules/jquery/src/manipulation/buildFragment.js +106 -0
  157. data/spec/dummy/node_modules/jquery/src/manipulation/getAll.js +32 -0
  158. data/spec/dummy/node_modules/jquery/src/manipulation/setGlobalEval.js +22 -0
  159. data/spec/dummy/node_modules/jquery/src/manipulation/support.js +41 -0
  160. data/spec/dummy/node_modules/jquery/src/manipulation/var/rscriptType.js +5 -0
  161. data/spec/dummy/node_modules/jquery/src/manipulation/var/rtagName.js +8 -0
  162. data/spec/dummy/node_modules/jquery/src/manipulation/wrapMap.js +30 -0
  163. data/spec/dummy/node_modules/jquery/src/offset.js +238 -0
  164. data/spec/dummy/node_modules/jquery/src/queue.js +145 -0
  165. data/spec/dummy/node_modules/jquery/src/queue/delay.js +24 -0
  166. data/spec/dummy/node_modules/jquery/src/selector-native.js +241 -0
  167. data/spec/dummy/node_modules/jquery/src/selector-sizzle.js +19 -0
  168. data/spec/dummy/node_modules/jquery/src/selector.js +3 -0
  169. data/spec/dummy/node_modules/jquery/src/serialize.js +136 -0
  170. data/spec/dummy/node_modules/jquery/src/traversing.js +198 -0
  171. data/spec/dummy/node_modules/jquery/src/traversing/findFilter.js +97 -0
  172. data/spec/dummy/node_modules/jquery/src/traversing/var/dir.js +22 -0
  173. data/spec/dummy/node_modules/jquery/src/traversing/var/rneedsContext.js +8 -0
  174. data/spec/dummy/node_modules/jquery/src/traversing/var/siblings.js +17 -0
  175. data/spec/dummy/node_modules/jquery/src/var/ObjectFunctionString.js +7 -0
  176. data/spec/dummy/node_modules/jquery/src/var/arr.js +5 -0
  177. data/spec/dummy/node_modules/jquery/src/var/class2type.js +6 -0
  178. data/spec/dummy/node_modules/jquery/src/var/document.js +5 -0
  179. data/spec/dummy/node_modules/jquery/src/var/documentElement.js +7 -0
  180. data/spec/dummy/node_modules/jquery/src/var/flat.js +16 -0
  181. data/spec/dummy/node_modules/jquery/src/var/fnToString.js +7 -0
  182. data/spec/dummy/node_modules/jquery/src/var/getProto.js +5 -0
  183. data/spec/dummy/node_modules/jquery/src/var/hasOwn.js +7 -0
  184. data/spec/dummy/node_modules/jquery/src/var/indexOf.js +7 -0
  185. data/spec/dummy/node_modules/jquery/src/var/isFunction.js +13 -0
  186. data/spec/dummy/node_modules/jquery/src/var/isWindow.js +8 -0
  187. data/spec/dummy/node_modules/jquery/src/var/pnum.js +5 -0
  188. data/spec/dummy/node_modules/jquery/src/var/push.js +7 -0
  189. data/spec/dummy/node_modules/jquery/src/var/rcheckableType.js +5 -0
  190. data/spec/dummy/node_modules/jquery/src/var/rcssNum.js +9 -0
  191. data/spec/dummy/node_modules/jquery/src/var/rnothtmlwhite.js +8 -0
  192. data/spec/dummy/node_modules/jquery/src/var/slice.js +7 -0
  193. data/spec/dummy/node_modules/jquery/src/var/support.js +6 -0
  194. data/spec/dummy/node_modules/jquery/src/var/toString.js +7 -0
  195. data/spec/dummy/node_modules/jquery/src/wrap.js +78 -0
  196. data/spec/dummy/tmp/cache/747/A70/TrustyCms%3A%3AConfig +5 -0
  197. data/spec/dummy/tmp/cache/85C/FA0/TrustyCms.cache_mtime +1 -0
  198. data/trusty_cms.gemspec +3 -2
  199. data/yarn.lock +9 -9
  200. metadata +354 -50
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "jquery-ui-bundle",
3
+ "version": "1.12.1",
4
+ "homepage": "http://jqueryui.com",
5
+ "description": "A curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library.",
6
+ "main": "jquery-ui.js",
7
+ "scripts": {},
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+ssh://git@github.com/imsky/jquery-ui-bundle.git"
11
+ },
12
+ "keywords": [
13
+ "jquery",
14
+ "jquery",
15
+ "ui"
16
+ ],
17
+ "author": {
18
+ "name": "jQuery Foundation and other contributors",
19
+ "url": "https://github.com/jquery/jquery-ui/blob/1.12.1/AUTHORS.txt"
20
+ },
21
+ "maintainers": [
22
+ {
23
+ "name": "Ivan Malopinsky",
24
+ "email": "ivan@imsky.co",
25
+ "url": "http://imsky.co"
26
+ }
27
+ ],
28
+ "license": "MIT",
29
+ "bugs": {
30
+ "url": "https://github.com/imsky/jquery-ui-bundle/issues"
31
+ },
32
+ "homepage": "https://github.com/imsky/jquery-ui-bundle#readme"
33
+ }
@@ -0,0 +1,109 @@
1
+ Contributing to jquery-ujs
2
+ =====================
3
+
4
+ [![Build Status](https://travis-ci.org/rails/jquery-ujs.svg?branch=master)](https://travis-ci.org/rails/jquery-ujs)
5
+
6
+ jquery-ujs is work of [many contributors](https://github.com/rails/jquery-ujs/graphs/contributors). You're encouraged to submit [pull requests](https://github.com/rails/jquery-ujs/pulls), [propose features and discuss issues](https://github.com/rails/jquery-ujs/issues).
7
+
8
+ #### Fork the Project
9
+
10
+ Fork the [project on Github](https://github.com/rails/jquery-ujs) and check out your copy.
11
+
12
+ ```
13
+ git clone https://github.com/contributor/jquery-ujs.git
14
+ cd jquery-ujs
15
+ git remote add upstream https://github.com/rails/jquery-ujs.git
16
+ ```
17
+
18
+ #### Create a Topic Branch
19
+
20
+ Make sure your fork is up-to-date and create a topic branch for your feature or bug fix.
21
+
22
+ ```
23
+ git checkout master
24
+ git pull upstream master
25
+ git checkout -b my-feature-branch
26
+ ```
27
+
28
+ #### Bundle Install and Test
29
+
30
+ Ensure that you can build the project and run tests. Run `rake test:server` first, and then run the web tests by visiting [[http://localhost:4567]] in your browser. Click the version links at the top right of the page to run the test suite with the different supported versions of jQuery.
31
+
32
+ ```
33
+ bundle install
34
+ rake test:server
35
+ ```
36
+
37
+ #### Write Tests
38
+
39
+ Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. Add to [test](test).
40
+
41
+ Here are some additional notes to keep in mind when developing your patch for jquery-ujs.
42
+
43
+ * The tests can be found in:
44
+ ```
45
+ |~test
46
+ |~public
47
+ |~test
48
+ ```
49
+ * Some tests ensure consistent behavior across the major browsers, meaning it is possible for tests to pass in Firefox, but fail in Internet Explorer. If possible, it helps if you can run the test suite in multiple browsers before submitting patches.
50
+
51
+ We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix.
52
+
53
+ #### Write Code
54
+
55
+ Implement your feature or bug fix.
56
+
57
+ Make sure that `bundle exec rake test` completes without errors.
58
+
59
+ #### Write Documentation
60
+
61
+ Document any external behavior in the [README](README.md).
62
+
63
+ #### Commit Changes
64
+
65
+ Make sure git knows your name and email address:
66
+
67
+ ```
68
+ git config --global user.name "Your Name"
69
+ git config --global user.email "contributor@example.com"
70
+ ```
71
+
72
+ Writing good commit logs is important. A commit log should describe what changed and why.
73
+
74
+ ```
75
+ git add ...
76
+ git commit
77
+ ```
78
+
79
+ #### Push
80
+
81
+ ```
82
+ git push origin my-feature-branch
83
+ ```
84
+
85
+ #### Make a Pull Request
86
+
87
+ Go to https://github.com/contributor/jquery-ujs and select your feature branch. Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.
88
+
89
+ #### Rebase
90
+
91
+ If you've been working on a change for a while, rebase with upstream/master.
92
+
93
+ ```
94
+ git fetch upstream
95
+ git rebase upstream/master
96
+ git push origin my-feature-branch -f
97
+ ```
98
+
99
+ #### Check on Your Pull Request
100
+
101
+ Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above.
102
+
103
+ #### Be Patient
104
+
105
+ It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang on there!
106
+
107
+ #### Thank You
108
+
109
+ Please do know that we really appreciate and value your time and work. We love you, really.
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2007-2016 Contributors at http://github.com/rails/jquery-ujs/contributors
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.
@@ -0,0 +1,86 @@
1
+ Unobtrusive scripting adapter for jQuery
2
+ ========================================
3
+
4
+ This unobtrusive scripting support file is developed for the Ruby on Rails framework, but is not strictly tied to any specific backend. You can drop this into any application to:
5
+
6
+ - force confirmation dialogs for various actions;
7
+ - make non-GET requests from hyperlinks;
8
+ - make forms or hyperlinks submit data asynchronously with Ajax;
9
+ - have submit buttons become automatically disabled on form submit to prevent double-clicking.
10
+
11
+ These features are achieved by adding certain ["data" attributes][data] to your HTML markup. In Rails, they are added by the framework's template helpers.
12
+
13
+ Full [documentation is on the wiki][wiki], including the [list of published Ajax events][events].
14
+
15
+ Requirements
16
+ ------------
17
+
18
+ - [jQuery 1.8.x or higher][jquery];
19
+ - HTML5 doctype (optional).
20
+
21
+ If you don't use HTML5, adding "data" attributes to your HTML4 or XHTML pages might make them fail [W3C markup validation][validator]. However, this shouldn't create any issues for web browsers or other user agents.
22
+
23
+ Installation using the jquery-rails gem
24
+ ------------
25
+
26
+ For automated installation in Rails, use the "jquery-rails" gem. Place this in your Gemfile:
27
+
28
+ ```ruby
29
+ gem 'jquery-rails'
30
+ ```
31
+
32
+ And run:
33
+
34
+ ```shell
35
+ $ bundle install
36
+ ```
37
+
38
+ Require both `jquery` and `jquery_ujs` into your application.js manifest.
39
+
40
+ ```javascript
41
+ //= require jquery
42
+ //= require jquery_ujs
43
+ ```
44
+
45
+ Installation using npm.
46
+ ------------
47
+
48
+ Run `npm install --save jquery-ujs` to install the jquery-ujs package.
49
+
50
+ Installation using Bower
51
+ ------------
52
+
53
+ Run `bower install jquery-ujs --save` to install the jquery-ujs package.
54
+
55
+ Usage
56
+ ------------
57
+
58
+ Require both `jquery` and `jquery-ujs` into your application.js manifest.
59
+
60
+ ```javascript
61
+ //= require jquery
62
+ //= require jquery-ujs
63
+ ```
64
+
65
+ How to run tests
66
+ ------------
67
+
68
+ Follow [this wiki](https://github.com/rails/jquery-ujs/wiki/Running-Tests-and-Contributing) to run tests.
69
+
70
+ ## Contributing to jquery-ujs
71
+
72
+ jquery-ujs is work of many contributors. You're encouraged to submit pull requests, propose
73
+ features and discuss issues.
74
+
75
+ See [CONTRIBUTING](CONTRIBUTING.md).
76
+
77
+ ## License
78
+ jquery-ujs is released under the [MIT License](MIT-LICENSE).
79
+
80
+ [data]: http://www.w3.org/TR/html5/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes "Embedding custom non-visible data with the data-* attributes"
81
+ [wiki]: https://github.com/rails/jquery-ujs/wiki
82
+ [events]: https://github.com/rails/jquery-ujs/wiki/ajax
83
+ [jquery]: http://docs.jquery.com/Downloading_jQuery
84
+ [validator]: http://validator.w3.org/
85
+ [csrf]: http://api.rubyonrails.org/classes/ActionController/RequestForgeryProtection.html
86
+ [adapter]: https://github.com/rails/jquery-ujs/raw/master/src/rails.js
@@ -0,0 +1,23 @@
1
+ ## Releasing jquery-ujs
2
+
3
+ ### Releasing to npm
4
+
5
+ Make sure npm's configuration `sign-git-tag` is set to true.
6
+
7
+ ```
8
+ npm config set sign-git-tag true
9
+ ```
10
+
11
+ Release it to npm using the [npm version command](https://docs.npmjs.com/cli/version). Like:
12
+
13
+ ```
14
+ npm version patch
15
+ ```
16
+
17
+ This will:
18
+
19
+ * Bump a patch version
20
+ * Commit the change
21
+ * Generate the tag
22
+ * Push the commit and the tag to the repository
23
+ * Publish the package in https://www.npmjs.com
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "jquery-ujs",
3
+ "homepage": "https://github.com/rails/jquery-ujs",
4
+ "authors": ["Stephen St. Martin", "Steve Schwartz"],
5
+ "description": "Ruby on Rails unobtrusive scripting adapter for jQuery",
6
+ "main": "src/rails.js",
7
+ "license": "MIT",
8
+ "dependencies": {
9
+ "jquery": ">1.8.*"
10
+ },
11
+ "ignore": [
12
+ "**/.*",
13
+ "Gemfile*",
14
+ "Rakefile",
15
+ "bower_components",
16
+ "script",
17
+ "test"
18
+ ]
19
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "jquery-ujs",
3
+ "version": "1.2.2",
4
+ "description": "Unobtrusive scripting adapter for jQuery",
5
+ "main": "src/rails.js",
6
+ "scripts": {
7
+ "test": "echo \"See the wiki: https://github.com/rails/jquery-ujs/wiki/Running-Tests-and-Contributing\" && exit 1",
8
+ "postversion": "git push && git push --tags && npm publish"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/rails/jquery-ujs.git"
13
+ },
14
+ "author": [
15
+ "Stephen St. Martin",
16
+ "Steve Schwartz"
17
+ ],
18
+ "license": "MIT",
19
+ "bugs": {
20
+ "url": "https://github.com/rails/jquery-ujs/issues"
21
+ },
22
+ "homepage": "https://github.com/rails/jquery-ujs#readme",
23
+ "dependencies": {
24
+ "jquery": ">=1.8.0"
25
+ }
26
+ }
@@ -0,0 +1,555 @@
1
+ (function($, undefined) {
2
+
3
+ /**
4
+ * Unobtrusive scripting adapter for jQuery
5
+ * https://github.com/rails/jquery-ujs
6
+ *
7
+ * Requires jQuery 1.8.0 or later.
8
+ *
9
+ * Released under the MIT license
10
+ *
11
+ */
12
+
13
+ // Cut down on the number of issues from people inadvertently including jquery_ujs twice
14
+ // by detecting and raising an error when it happens.
15
+ 'use strict';
16
+
17
+ if ( $.rails !== undefined ) {
18
+ $.error('jquery-ujs has already been loaded!');
19
+ }
20
+
21
+ // Shorthand to make it a little easier to call public rails functions from within rails.js
22
+ var rails;
23
+ var $document = $(document);
24
+
25
+ $.rails = rails = {
26
+ // Link elements bound by jquery-ujs
27
+ linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote]:not([disabled]), a[data-disable-with], a[data-disable]',
28
+
29
+ // Button elements bound by jquery-ujs
30
+ buttonClickSelector: 'button[data-remote]:not([form]):not(form button), button[data-confirm]:not([form]):not(form button)',
31
+
32
+ // Select elements bound by jquery-ujs
33
+ inputChangeSelector: 'select[data-remote], input[data-remote], textarea[data-remote]',
34
+
35
+ // Form elements bound by jquery-ujs
36
+ formSubmitSelector: 'form',
37
+
38
+ // Form input elements bound by jquery-ujs
39
+ formInputClickSelector: 'form input[type=submit], form input[type=image], form button[type=submit], form button:not([type]), input[type=submit][form], input[type=image][form], button[type=submit][form], button[form]:not([type])',
40
+
41
+ // Form input elements disabled during form submission
42
+ disableSelector: 'input[data-disable-with]:enabled, button[data-disable-with]:enabled, textarea[data-disable-with]:enabled, input[data-disable]:enabled, button[data-disable]:enabled, textarea[data-disable]:enabled',
43
+
44
+ // Form input elements re-enabled after form submission
45
+ enableSelector: 'input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled, input[data-disable]:disabled, button[data-disable]:disabled, textarea[data-disable]:disabled',
46
+
47
+ // Form required input elements
48
+ requiredInputSelector: 'input[name][required]:not([disabled]), textarea[name][required]:not([disabled])',
49
+
50
+ // Form file input elements
51
+ fileInputSelector: 'input[name][type=file]:not([disabled])',
52
+
53
+ // Link onClick disable selector with possible reenable after remote submission
54
+ linkDisableSelector: 'a[data-disable-with], a[data-disable]',
55
+
56
+ // Button onClick disable selector with possible reenable after remote submission
57
+ buttonDisableSelector: 'button[data-remote][data-disable-with], button[data-remote][data-disable]',
58
+
59
+ // Up-to-date Cross-Site Request Forgery token
60
+ csrfToken: function() {
61
+ return $('meta[name=csrf-token]').attr('content');
62
+ },
63
+
64
+ // URL param that must contain the CSRF token
65
+ csrfParam: function() {
66
+ return $('meta[name=csrf-param]').attr('content');
67
+ },
68
+
69
+ // Make sure that every Ajax request sends the CSRF token
70
+ CSRFProtection: function(xhr) {
71
+ var token = rails.csrfToken();
72
+ if (token) xhr.setRequestHeader('X-CSRF-Token', token);
73
+ },
74
+
75
+ // Make sure that all forms have actual up-to-date tokens (cached forms contain old ones)
76
+ refreshCSRFTokens: function(){
77
+ $('form input[name="' + rails.csrfParam() + '"]').val(rails.csrfToken());
78
+ },
79
+
80
+ // Triggers an event on an element and returns false if the event result is false
81
+ fire: function(obj, name, data) {
82
+ var event = $.Event(name);
83
+ obj.trigger(event, data);
84
+ return event.result !== false;
85
+ },
86
+
87
+ // Default confirm dialog, may be overridden with custom confirm dialog in $.rails.confirm
88
+ confirm: function(message) {
89
+ return confirm(message);
90
+ },
91
+
92
+ // Default ajax function, may be overridden with custom function in $.rails.ajax
93
+ ajax: function(options) {
94
+ return $.ajax(options);
95
+ },
96
+
97
+ // Default way to get an element's href. May be overridden at $.rails.href.
98
+ href: function(element) {
99
+ return element[0].href;
100
+ },
101
+
102
+ // Checks "data-remote" if true to handle the request through a XHR request.
103
+ isRemote: function(element) {
104
+ return element.data('remote') !== undefined && element.data('remote') !== false;
105
+ },
106
+
107
+ // Submits "remote" forms and links with ajax
108
+ handleRemote: function(element) {
109
+ var method, url, data, withCredentials, dataType, options;
110
+
111
+ if (rails.fire(element, 'ajax:before')) {
112
+ withCredentials = element.data('with-credentials') || null;
113
+ dataType = element.data('type') || ($.ajaxSettings && $.ajaxSettings.dataType);
114
+
115
+ if (element.is('form')) {
116
+ method = element.data('ujs:submit-button-formmethod') || element.attr('method');
117
+ url = element.data('ujs:submit-button-formaction') || element.attr('action');
118
+ data = $(element[0]).serializeArray();
119
+ // memoized value from clicked submit button
120
+ var button = element.data('ujs:submit-button');
121
+ if (button) {
122
+ data.push(button);
123
+ element.data('ujs:submit-button', null);
124
+ }
125
+ element.data('ujs:submit-button-formmethod', null);
126
+ element.data('ujs:submit-button-formaction', null);
127
+ } else if (element.is(rails.inputChangeSelector)) {
128
+ method = element.data('method');
129
+ url = element.data('url');
130
+ data = element.serialize();
131
+ if (element.data('params')) data = data + '&' + element.data('params');
132
+ } else if (element.is(rails.buttonClickSelector)) {
133
+ method = element.data('method') || 'get';
134
+ url = element.data('url');
135
+ data = element.serialize();
136
+ if (element.data('params')) data = data + '&' + element.data('params');
137
+ } else {
138
+ method = element.data('method');
139
+ url = rails.href(element);
140
+ data = element.data('params') || null;
141
+ }
142
+
143
+ options = {
144
+ type: method || 'GET', data: data, dataType: dataType,
145
+ // stopping the "ajax:beforeSend" event will cancel the ajax request
146
+ beforeSend: function(xhr, settings) {
147
+ if (settings.dataType === undefined) {
148
+ xhr.setRequestHeader('accept', '*/*;q=0.5, ' + settings.accepts.script);
149
+ }
150
+ if (rails.fire(element, 'ajax:beforeSend', [xhr, settings])) {
151
+ element.trigger('ajax:send', xhr);
152
+ } else {
153
+ return false;
154
+ }
155
+ },
156
+ success: function(data, status, xhr) {
157
+ element.trigger('ajax:success', [data, status, xhr]);
158
+ },
159
+ complete: function(xhr, status) {
160
+ element.trigger('ajax:complete', [xhr, status]);
161
+ },
162
+ error: function(xhr, status, error) {
163
+ element.trigger('ajax:error', [xhr, status, error]);
164
+ },
165
+ crossDomain: rails.isCrossDomain(url)
166
+ };
167
+
168
+ // There is no withCredentials for IE6-8 when
169
+ // "Enable native XMLHTTP support" is disabled
170
+ if (withCredentials) {
171
+ options.xhrFields = {
172
+ withCredentials: withCredentials
173
+ };
174
+ }
175
+
176
+ // Only pass url to `ajax` options if not blank
177
+ if (url) { options.url = url; }
178
+
179
+ return rails.ajax(options);
180
+ } else {
181
+ return false;
182
+ }
183
+ },
184
+
185
+ // Determines if the request is a cross domain request.
186
+ isCrossDomain: function(url) {
187
+ var originAnchor = document.createElement('a');
188
+ originAnchor.href = location.href;
189
+ var urlAnchor = document.createElement('a');
190
+
191
+ try {
192
+ urlAnchor.href = url;
193
+ // This is a workaround to a IE bug.
194
+ urlAnchor.href = urlAnchor.href;
195
+
196
+ // If URL protocol is false or is a string containing a single colon
197
+ // *and* host are false, assume it is not a cross-domain request
198
+ // (should only be the case for IE7 and IE compatibility mode).
199
+ // Otherwise, evaluate protocol and host of the URL against the origin
200
+ // protocol and host.
201
+ return !(((!urlAnchor.protocol || urlAnchor.protocol === ':') && !urlAnchor.host) ||
202
+ (originAnchor.protocol + '//' + originAnchor.host ===
203
+ urlAnchor.protocol + '//' + urlAnchor.host));
204
+ } catch (e) {
205
+ // If there is an error parsing the URL, assume it is crossDomain.
206
+ return true;
207
+ }
208
+ },
209
+
210
+ // Handles "data-method" on links such as:
211
+ // <a href="/users/5" data-method="delete" rel="nofollow" data-confirm="Are you sure?">Delete</a>
212
+ handleMethod: function(link) {
213
+ var href = rails.href(link),
214
+ method = link.data('method'),
215
+ target = link.attr('target'),
216
+ csrfToken = rails.csrfToken(),
217
+ csrfParam = rails.csrfParam(),
218
+ form = $('<form method="post" action="' + href + '"></form>'),
219
+ metadataInput = '<input name="_method" value="' + method + '" type="hidden" />';
220
+
221
+ if (csrfParam !== undefined && csrfToken !== undefined && !rails.isCrossDomain(href)) {
222
+ metadataInput += '<input name="' + csrfParam + '" value="' + csrfToken + '" type="hidden" />';
223
+ }
224
+
225
+ if (target) { form.attr('target', target); }
226
+
227
+ form.hide().append(metadataInput).appendTo('body');
228
+ form.submit();
229
+ },
230
+
231
+ // Helper function that returns form elements that match the specified CSS selector
232
+ // If form is actually a "form" element this will return associated elements outside the from that have
233
+ // the html form attribute set
234
+ formElements: function(form, selector) {
235
+ return form.is('form') ? $(form[0].elements).filter(selector) : form.find(selector);
236
+ },
237
+
238
+ /* Disables form elements:
239
+ - Caches element value in 'ujs:enable-with' data store
240
+ - Replaces element text with value of 'data-disable-with' attribute
241
+ - Sets disabled property to true
242
+ */
243
+ disableFormElements: function(form) {
244
+ rails.formElements(form, rails.disableSelector).each(function() {
245
+ rails.disableFormElement($(this));
246
+ });
247
+ },
248
+
249
+ disableFormElement: function(element) {
250
+ var method, replacement;
251
+
252
+ method = element.is('button') ? 'html' : 'val';
253
+ replacement = element.data('disable-with');
254
+
255
+ if (replacement !== undefined) {
256
+ element.data('ujs:enable-with', element[method]());
257
+ element[method](replacement);
258
+ }
259
+
260
+ element.prop('disabled', true);
261
+ element.data('ujs:disabled', true);
262
+ },
263
+
264
+ /* Re-enables disabled form elements:
265
+ - Replaces element text with cached value from 'ujs:enable-with' data store (created in `disableFormElements`)
266
+ - Sets disabled property to false
267
+ */
268
+ enableFormElements: function(form) {
269
+ rails.formElements(form, rails.enableSelector).each(function() {
270
+ rails.enableFormElement($(this));
271
+ });
272
+ },
273
+
274
+ enableFormElement: function(element) {
275
+ var method = element.is('button') ? 'html' : 'val';
276
+ if (element.data('ujs:enable-with') !== undefined) {
277
+ element[method](element.data('ujs:enable-with'));
278
+ element.removeData('ujs:enable-with'); // clean up cache
279
+ }
280
+ element.prop('disabled', false);
281
+ element.removeData('ujs:disabled');
282
+ },
283
+
284
+ /* For 'data-confirm' attribute:
285
+ - Fires `confirm` event
286
+ - Shows the confirmation dialog
287
+ - Fires the `confirm:complete` event
288
+
289
+ Returns `true` if no function stops the chain and user chose yes; `false` otherwise.
290
+ Attaching a handler to the element's `confirm` event that returns a `falsy` value cancels the confirmation dialog.
291
+ Attaching a handler to the element's `confirm:complete` event that returns a `falsy` value makes this function
292
+ return false. The `confirm:complete` event is fired whether or not the user answered true or false to the dialog.
293
+ */
294
+ allowAction: function(element) {
295
+ var message = element.data('confirm'),
296
+ answer = false, callback;
297
+ if (!message) { return true; }
298
+
299
+ if (rails.fire(element, 'confirm')) {
300
+ try {
301
+ answer = rails.confirm(message);
302
+ } catch (e) {
303
+ (console.error || console.log).call(console, e.stack || e);
304
+ }
305
+ callback = rails.fire(element, 'confirm:complete', [answer]);
306
+ }
307
+ return answer && callback;
308
+ },
309
+
310
+ // Helper function which checks for blank inputs in a form that match the specified CSS selector
311
+ blankInputs: function(form, specifiedSelector, nonBlank) {
312
+ var foundInputs = $(),
313
+ input,
314
+ valueToCheck,
315
+ radiosForNameWithNoneSelected,
316
+ radioName,
317
+ selector = specifiedSelector || 'input,textarea',
318
+ requiredInputs = form.find(selector),
319
+ checkedRadioButtonNames = {};
320
+
321
+ requiredInputs.each(function() {
322
+ input = $(this);
323
+ if (input.is('input[type=radio]')) {
324
+
325
+ // Don't count unchecked required radio as blank if other radio with same name is checked,
326
+ // regardless of whether same-name radio input has required attribute or not. The spec
327
+ // states https://www.w3.org/TR/html5/forms.html#the-required-attribute
328
+ radioName = input.attr('name');
329
+
330
+ // Skip if we've already seen the radio with this name.
331
+ if (!checkedRadioButtonNames[radioName]) {
332
+
333
+ // If none checked
334
+ if (form.find('input[type=radio]:checked[name="' + radioName + '"]').length === 0) {
335
+ radiosForNameWithNoneSelected = form.find(
336
+ 'input[type=radio][name="' + radioName + '"]');
337
+ foundInputs = foundInputs.add(radiosForNameWithNoneSelected);
338
+ }
339
+
340
+ // We only need to check each name once.
341
+ checkedRadioButtonNames[radioName] = radioName;
342
+ }
343
+ } else {
344
+ valueToCheck = input.is('input[type=checkbox],input[type=radio]') ? input.is(':checked') : !!input.val();
345
+ if (valueToCheck === nonBlank) {
346
+ foundInputs = foundInputs.add(input);
347
+ }
348
+ }
349
+ });
350
+ return foundInputs.length ? foundInputs : false;
351
+ },
352
+
353
+ // Helper function which checks for non-blank inputs in a form that match the specified CSS selector
354
+ nonBlankInputs: function(form, specifiedSelector) {
355
+ return rails.blankInputs(form, specifiedSelector, true); // true specifies nonBlank
356
+ },
357
+
358
+ // Helper function, needed to provide consistent behavior in IE
359
+ stopEverything: function(e) {
360
+ $(e.target).trigger('ujs:everythingStopped');
361
+ e.stopImmediatePropagation();
362
+ return false;
363
+ },
364
+
365
+ // Replace element's html with the 'data-disable-with' after storing original html
366
+ // and prevent clicking on it
367
+ disableElement: function(element) {
368
+ var replacement = element.data('disable-with');
369
+
370
+ if (replacement !== undefined) {
371
+ element.data('ujs:enable-with', element.html()); // store enabled state
372
+ element.html(replacement);
373
+ }
374
+
375
+ element.bind('click.railsDisable', function(e) { // prevent further clicking
376
+ return rails.stopEverything(e);
377
+ });
378
+ element.data('ujs:disabled', true);
379
+ },
380
+
381
+ // Restore element to its original state which was disabled by 'disableElement' above
382
+ enableElement: function(element) {
383
+ if (element.data('ujs:enable-with') !== undefined) {
384
+ element.html(element.data('ujs:enable-with')); // set to old enabled state
385
+ element.removeData('ujs:enable-with'); // clean up cache
386
+ }
387
+ element.unbind('click.railsDisable'); // enable element
388
+ element.removeData('ujs:disabled');
389
+ }
390
+ };
391
+
392
+ if (rails.fire($document, 'rails:attachBindings')) {
393
+
394
+ $.ajaxPrefilter(function(options, originalOptions, xhr){ if ( !options.crossDomain ) { rails.CSRFProtection(xhr); }});
395
+
396
+ // This event works the same as the load event, except that it fires every
397
+ // time the page is loaded.
398
+ //
399
+ // See https://github.com/rails/jquery-ujs/issues/357
400
+ // See https://developer.mozilla.org/en-US/docs/Using_Firefox_1.5_caching
401
+ $(window).on('pageshow.rails', function () {
402
+ $($.rails.enableSelector).each(function () {
403
+ var element = $(this);
404
+
405
+ if (element.data('ujs:disabled')) {
406
+ $.rails.enableFormElement(element);
407
+ }
408
+ });
409
+
410
+ $($.rails.linkDisableSelector).each(function () {
411
+ var element = $(this);
412
+
413
+ if (element.data('ujs:disabled')) {
414
+ $.rails.enableElement(element);
415
+ }
416
+ });
417
+ });
418
+
419
+ $document.on('ajax:complete', rails.linkDisableSelector, function() {
420
+ rails.enableElement($(this));
421
+ });
422
+
423
+ $document.on('ajax:complete', rails.buttonDisableSelector, function() {
424
+ rails.enableFormElement($(this));
425
+ });
426
+
427
+ $document.on('click.rails', rails.linkClickSelector, function(e) {
428
+ var link = $(this), method = link.data('method'), data = link.data('params'), metaClick = e.metaKey || e.ctrlKey;
429
+ if (!rails.allowAction(link)) return rails.stopEverything(e);
430
+
431
+ if (!metaClick && link.is(rails.linkDisableSelector)) rails.disableElement(link);
432
+
433
+ if (rails.isRemote(link)) {
434
+ if (metaClick && (!method || method === 'GET') && !data) { return true; }
435
+
436
+ var handleRemote = rails.handleRemote(link);
437
+ // Response from rails.handleRemote() will either be false or a deferred object promise.
438
+ if (handleRemote === false) {
439
+ rails.enableElement(link);
440
+ } else {
441
+ handleRemote.fail( function() { rails.enableElement(link); } );
442
+ }
443
+ return false;
444
+
445
+ } else if (method) {
446
+ rails.handleMethod(link);
447
+ return false;
448
+ }
449
+ });
450
+
451
+ $document.on('click.rails', rails.buttonClickSelector, function(e) {
452
+ var button = $(this);
453
+
454
+ if (!rails.allowAction(button) || !rails.isRemote(button)) return rails.stopEverything(e);
455
+
456
+ if (button.is(rails.buttonDisableSelector)) rails.disableFormElement(button);
457
+
458
+ var handleRemote = rails.handleRemote(button);
459
+ // Response from rails.handleRemote() will either be false or a deferred object promise.
460
+ if (handleRemote === false) {
461
+ rails.enableFormElement(button);
462
+ } else {
463
+ handleRemote.fail( function() { rails.enableFormElement(button); } );
464
+ }
465
+ return false;
466
+ });
467
+
468
+ $document.on('change.rails', rails.inputChangeSelector, function(e) {
469
+ var link = $(this);
470
+ if (!rails.allowAction(link) || !rails.isRemote(link)) return rails.stopEverything(e);
471
+
472
+ rails.handleRemote(link);
473
+ return false;
474
+ });
475
+
476
+ $document.on('submit.rails', rails.formSubmitSelector, function(e) {
477
+ var form = $(this),
478
+ remote = rails.isRemote(form),
479
+ blankRequiredInputs,
480
+ nonBlankFileInputs;
481
+
482
+ if (!rails.allowAction(form)) return rails.stopEverything(e);
483
+
484
+ // Skip other logic when required values are missing or file upload is present
485
+ if (form.attr('novalidate') === undefined) {
486
+ if (form.data('ujs:formnovalidate-button') === undefined) {
487
+ blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector, false);
488
+ if (blankRequiredInputs && rails.fire(form, 'ajax:aborted:required', [blankRequiredInputs])) {
489
+ return rails.stopEverything(e);
490
+ }
491
+ } else {
492
+ // Clear the formnovalidate in case the next button click is not on a formnovalidate button
493
+ // Not strictly necessary to do here, since it is also reset on each button click, but just to be certain
494
+ form.data('ujs:formnovalidate-button', undefined);
495
+ }
496
+ }
497
+
498
+ if (remote) {
499
+ nonBlankFileInputs = rails.nonBlankInputs(form, rails.fileInputSelector);
500
+ if (nonBlankFileInputs) {
501
+ // Slight timeout so that the submit button gets properly serialized
502
+ // (make it easy for event handler to serialize form without disabled values)
503
+ setTimeout(function(){ rails.disableFormElements(form); }, 13);
504
+ var aborted = rails.fire(form, 'ajax:aborted:file', [nonBlankFileInputs]);
505
+
506
+ // Re-enable form elements if event bindings return false (canceling normal form submission)
507
+ if (!aborted) { setTimeout(function(){ rails.enableFormElements(form); }, 13); }
508
+
509
+ return aborted;
510
+ }
511
+
512
+ rails.handleRemote(form);
513
+ return false;
514
+
515
+ } else {
516
+ // Slight timeout so that the submit button gets properly serialized
517
+ setTimeout(function(){ rails.disableFormElements(form); }, 13);
518
+ }
519
+ });
520
+
521
+ $document.on('click.rails', rails.formInputClickSelector, function(event) {
522
+ var button = $(this);
523
+
524
+ if (!rails.allowAction(button)) return rails.stopEverything(event);
525
+
526
+ // Register the pressed submit button
527
+ var name = button.attr('name'),
528
+ data = name ? {name:name, value:button.val()} : null;
529
+
530
+ var form = button.closest('form');
531
+ if (form.length === 0) {
532
+ form = $('#' + button.attr('form'));
533
+ }
534
+ form.data('ujs:submit-button', data);
535
+
536
+ // Save attributes from button
537
+ form.data('ujs:formnovalidate-button', button.attr('formnovalidate'));
538
+ form.data('ujs:submit-button-formaction', button.attr('formaction'));
539
+ form.data('ujs:submit-button-formmethod', button.attr('formmethod'));
540
+ });
541
+
542
+ $document.on('ajax:send.rails', rails.formSubmitSelector, function(event) {
543
+ if (this === event.target) rails.disableFormElements($(this));
544
+ });
545
+
546
+ $document.on('ajax:complete.rails', rails.formSubmitSelector, function(event) {
547
+ if (this === event.target) rails.enableFormElements($(this));
548
+ });
549
+
550
+ $(function(){
551
+ rails.refreshCSRFTokens();
552
+ });
553
+ }
554
+
555
+ })( jQuery );