trusty-cms 4.2.2 → 4.3.2

Sign up to get free protection for your applications and to get access to all the features.
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
+ define( [
2
+ "../var/document",
3
+ "../var/support"
4
+ ], function( document, support ) {
5
+
6
+ "use strict";
7
+
8
+ ( function() {
9
+ var input = document.createElement( "input" ),
10
+ select = document.createElement( "select" ),
11
+ opt = select.appendChild( document.createElement( "option" ) );
12
+
13
+ input.type = "checkbox";
14
+
15
+ // Support: Android <=4.3 only
16
+ // Default value for a checkbox should be "on"
17
+ support.checkOn = input.value !== "";
18
+
19
+ // Support: IE <=11 only
20
+ // Must access selectedIndex to make default options select
21
+ support.optSelected = opt.selected;
22
+
23
+ // Support: IE <=11 only
24
+ // An input loses its value after becoming a radio
25
+ input = document.createElement( "input" );
26
+ input.value = "t";
27
+ input.type = "radio";
28
+ support.radioValue = input.value === "t";
29
+ } )();
30
+
31
+ return support;
32
+
33
+ } );
@@ -0,0 +1,191 @@
1
+ define( [
2
+ "../core",
3
+ "../core/stripAndCollapse",
4
+ "./support",
5
+ "../core/nodeName",
6
+ "../var/isFunction",
7
+
8
+ "../core/init"
9
+ ], function( jQuery, stripAndCollapse, support, nodeName, isFunction ) {
10
+
11
+ "use strict";
12
+
13
+ var rreturn = /\r/g;
14
+
15
+ jQuery.fn.extend( {
16
+ val: function( value ) {
17
+ var hooks, ret, valueIsFunction,
18
+ elem = this[ 0 ];
19
+
20
+ if ( !arguments.length ) {
21
+ if ( elem ) {
22
+ hooks = jQuery.valHooks[ elem.type ] ||
23
+ jQuery.valHooks[ elem.nodeName.toLowerCase() ];
24
+
25
+ if ( hooks &&
26
+ "get" in hooks &&
27
+ ( ret = hooks.get( elem, "value" ) ) !== undefined
28
+ ) {
29
+ return ret;
30
+ }
31
+
32
+ ret = elem.value;
33
+
34
+ // Handle most common string cases
35
+ if ( typeof ret === "string" ) {
36
+ return ret.replace( rreturn, "" );
37
+ }
38
+
39
+ // Handle cases where value is null/undef or number
40
+ return ret == null ? "" : ret;
41
+ }
42
+
43
+ return;
44
+ }
45
+
46
+ valueIsFunction = isFunction( value );
47
+
48
+ return this.each( function( i ) {
49
+ var val;
50
+
51
+ if ( this.nodeType !== 1 ) {
52
+ return;
53
+ }
54
+
55
+ if ( valueIsFunction ) {
56
+ val = value.call( this, i, jQuery( this ).val() );
57
+ } else {
58
+ val = value;
59
+ }
60
+
61
+ // Treat null/undefined as ""; convert numbers to string
62
+ if ( val == null ) {
63
+ val = "";
64
+
65
+ } else if ( typeof val === "number" ) {
66
+ val += "";
67
+
68
+ } else if ( Array.isArray( val ) ) {
69
+ val = jQuery.map( val, function( value ) {
70
+ return value == null ? "" : value + "";
71
+ } );
72
+ }
73
+
74
+ hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
75
+
76
+ // If set returns undefined, fall back to normal setting
77
+ if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
78
+ this.value = val;
79
+ }
80
+ } );
81
+ }
82
+ } );
83
+
84
+ jQuery.extend( {
85
+ valHooks: {
86
+ option: {
87
+ get: function( elem ) {
88
+
89
+ var val = jQuery.find.attr( elem, "value" );
90
+ return val != null ?
91
+ val :
92
+
93
+ // Support: IE <=10 - 11 only
94
+ // option.text throws exceptions (#14686, #14858)
95
+ // Strip and collapse whitespace
96
+ // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
97
+ stripAndCollapse( jQuery.text( elem ) );
98
+ }
99
+ },
100
+ select: {
101
+ get: function( elem ) {
102
+ var value, option, i,
103
+ options = elem.options,
104
+ index = elem.selectedIndex,
105
+ one = elem.type === "select-one",
106
+ values = one ? null : [],
107
+ max = one ? index + 1 : options.length;
108
+
109
+ if ( index < 0 ) {
110
+ i = max;
111
+
112
+ } else {
113
+ i = one ? index : 0;
114
+ }
115
+
116
+ // Loop through all the selected options
117
+ for ( ; i < max; i++ ) {
118
+ option = options[ i ];
119
+
120
+ // Support: IE <=9 only
121
+ // IE8-9 doesn't update selected after form reset (#2551)
122
+ if ( ( option.selected || i === index ) &&
123
+
124
+ // Don't return options that are disabled or in a disabled optgroup
125
+ !option.disabled &&
126
+ ( !option.parentNode.disabled ||
127
+ !nodeName( option.parentNode, "optgroup" ) ) ) {
128
+
129
+ // Get the specific value for the option
130
+ value = jQuery( option ).val();
131
+
132
+ // We don't need an array for one selects
133
+ if ( one ) {
134
+ return value;
135
+ }
136
+
137
+ // Multi-Selects return an array
138
+ values.push( value );
139
+ }
140
+ }
141
+
142
+ return values;
143
+ },
144
+
145
+ set: function( elem, value ) {
146
+ var optionSet, option,
147
+ options = elem.options,
148
+ values = jQuery.makeArray( value ),
149
+ i = options.length;
150
+
151
+ while ( i-- ) {
152
+ option = options[ i ];
153
+
154
+ /* eslint-disable no-cond-assign */
155
+
156
+ if ( option.selected =
157
+ jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
158
+ ) {
159
+ optionSet = true;
160
+ }
161
+
162
+ /* eslint-enable no-cond-assign */
163
+ }
164
+
165
+ // Force browsers to behave consistently when non-matching value is set
166
+ if ( !optionSet ) {
167
+ elem.selectedIndex = -1;
168
+ }
169
+ return values;
170
+ }
171
+ }
172
+ }
173
+ } );
174
+
175
+ // Radios and checkboxes getter/setter
176
+ jQuery.each( [ "radio", "checkbox" ], function() {
177
+ jQuery.valHooks[ this ] = {
178
+ set: function( elem, value ) {
179
+ if ( Array.isArray( value ) ) {
180
+ return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
181
+ }
182
+ }
183
+ };
184
+ if ( !support.checkOn ) {
185
+ jQuery.valHooks[ this ].get = function( elem ) {
186
+ return elem.getAttribute( "value" ) === null ? "on" : elem.value;
187
+ };
188
+ }
189
+ } );
190
+
191
+ } );
@@ -0,0 +1,236 @@
1
+ define( [
2
+ "./core",
3
+ "./core/toType",
4
+ "./var/isFunction",
5
+ "./var/rnothtmlwhite"
6
+ ], function( jQuery, toType, isFunction, rnothtmlwhite ) {
7
+
8
+ "use strict";
9
+
10
+ // Convert String-formatted options into Object-formatted ones
11
+ function createOptions( options ) {
12
+ var object = {};
13
+ jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
14
+ object[ flag ] = true;
15
+ } );
16
+ return object;
17
+ }
18
+
19
+ /*
20
+ * Create a callback list using the following parameters:
21
+ *
22
+ * options: an optional list of space-separated options that will change how
23
+ * the callback list behaves or a more traditional option object
24
+ *
25
+ * By default a callback list will act like an event callback list and can be
26
+ * "fired" multiple times.
27
+ *
28
+ * Possible options:
29
+ *
30
+ * once: will ensure the callback list can only be fired once (like a Deferred)
31
+ *
32
+ * memory: will keep track of previous values and will call any callback added
33
+ * after the list has been fired right away with the latest "memorized"
34
+ * values (like a Deferred)
35
+ *
36
+ * unique: will ensure a callback can only be added once (no duplicate in the list)
37
+ *
38
+ * stopOnFalse: interrupt callings when a callback returns false
39
+ *
40
+ */
41
+ jQuery.Callbacks = function( options ) {
42
+
43
+ // Convert options from String-formatted to Object-formatted if needed
44
+ // (we check in cache first)
45
+ options = typeof options === "string" ?
46
+ createOptions( options ) :
47
+ jQuery.extend( {}, options );
48
+
49
+ var // Flag to know if list is currently firing
50
+ firing,
51
+
52
+ // Last fire value for non-forgettable lists
53
+ memory,
54
+
55
+ // Flag to know if list was already fired
56
+ fired,
57
+
58
+ // Flag to prevent firing
59
+ locked,
60
+
61
+ // Actual callback list
62
+ list = [],
63
+
64
+ // Queue of execution data for repeatable lists
65
+ queue = [],
66
+
67
+ // Index of currently firing callback (modified by add/remove as needed)
68
+ firingIndex = -1,
69
+
70
+ // Fire callbacks
71
+ fire = function() {
72
+
73
+ // Enforce single-firing
74
+ locked = locked || options.once;
75
+
76
+ // Execute callbacks for all pending executions,
77
+ // respecting firingIndex overrides and runtime changes
78
+ fired = firing = true;
79
+ for ( ; queue.length; firingIndex = -1 ) {
80
+ memory = queue.shift();
81
+ while ( ++firingIndex < list.length ) {
82
+
83
+ // Run callback and check for early termination
84
+ if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
85
+ options.stopOnFalse ) {
86
+
87
+ // Jump to end and forget the data so .add doesn't re-fire
88
+ firingIndex = list.length;
89
+ memory = false;
90
+ }
91
+ }
92
+ }
93
+
94
+ // Forget the data if we're done with it
95
+ if ( !options.memory ) {
96
+ memory = false;
97
+ }
98
+
99
+ firing = false;
100
+
101
+ // Clean up if we're done firing for good
102
+ if ( locked ) {
103
+
104
+ // Keep an empty list if we have data for future add calls
105
+ if ( memory ) {
106
+ list = [];
107
+
108
+ // Otherwise, this object is spent
109
+ } else {
110
+ list = "";
111
+ }
112
+ }
113
+ },
114
+
115
+ // Actual Callbacks object
116
+ self = {
117
+
118
+ // Add a callback or a collection of callbacks to the list
119
+ add: function() {
120
+ if ( list ) {
121
+
122
+ // If we have memory from a past run, we should fire after adding
123
+ if ( memory && !firing ) {
124
+ firingIndex = list.length - 1;
125
+ queue.push( memory );
126
+ }
127
+
128
+ ( function add( args ) {
129
+ jQuery.each( args, function( _, arg ) {
130
+ if ( isFunction( arg ) ) {
131
+ if ( !options.unique || !self.has( arg ) ) {
132
+ list.push( arg );
133
+ }
134
+ } else if ( arg && arg.length && toType( arg ) !== "string" ) {
135
+
136
+ // Inspect recursively
137
+ add( arg );
138
+ }
139
+ } );
140
+ } )( arguments );
141
+
142
+ if ( memory && !firing ) {
143
+ fire();
144
+ }
145
+ }
146
+ return this;
147
+ },
148
+
149
+ // Remove a callback from the list
150
+ remove: function() {
151
+ jQuery.each( arguments, function( _, arg ) {
152
+ var index;
153
+ while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
154
+ list.splice( index, 1 );
155
+
156
+ // Handle firing indexes
157
+ if ( index <= firingIndex ) {
158
+ firingIndex--;
159
+ }
160
+ }
161
+ } );
162
+ return this;
163
+ },
164
+
165
+ // Check if a given callback is in the list.
166
+ // If no argument is given, return whether or not list has callbacks attached.
167
+ has: function( fn ) {
168
+ return fn ?
169
+ jQuery.inArray( fn, list ) > -1 :
170
+ list.length > 0;
171
+ },
172
+
173
+ // Remove all callbacks from the list
174
+ empty: function() {
175
+ if ( list ) {
176
+ list = [];
177
+ }
178
+ return this;
179
+ },
180
+
181
+ // Disable .fire and .add
182
+ // Abort any current/pending executions
183
+ // Clear all callbacks and values
184
+ disable: function() {
185
+ locked = queue = [];
186
+ list = memory = "";
187
+ return this;
188
+ },
189
+ disabled: function() {
190
+ return !list;
191
+ },
192
+
193
+ // Disable .fire
194
+ // Also disable .add unless we have memory (since it would have no effect)
195
+ // Abort any pending executions
196
+ lock: function() {
197
+ locked = queue = [];
198
+ if ( !memory && !firing ) {
199
+ list = memory = "";
200
+ }
201
+ return this;
202
+ },
203
+ locked: function() {
204
+ return !!locked;
205
+ },
206
+
207
+ // Call all callbacks with the given context and arguments
208
+ fireWith: function( context, args ) {
209
+ if ( !locked ) {
210
+ args = args || [];
211
+ args = [ context, args.slice ? args.slice() : args ];
212
+ queue.push( args );
213
+ if ( !firing ) {
214
+ fire();
215
+ }
216
+ }
217
+ return this;
218
+ },
219
+
220
+ // Call all the callbacks with the given arguments
221
+ fire: function() {
222
+ self.fireWith( this, arguments );
223
+ return this;
224
+ },
225
+
226
+ // To know if the callbacks have already been called at least once
227
+ fired: function() {
228
+ return !!fired;
229
+ }
230
+ };
231
+
232
+ return self;
233
+ };
234
+
235
+ return jQuery;
236
+ } );