unpoly-rails 0.57.0 → 0.60.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of unpoly-rails might be problematic. Click here for more details.

Files changed (186) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +393 -1
  3. data/Gemfile.lock +5 -2
  4. data/README.md +1 -1
  5. data/README_RAILS.md +1 -1
  6. data/Rakefile +10 -1
  7. data/design/es6.js +32 -0
  8. data/design/ie11.txt +9 -0
  9. data/design/measure_jquery/element_list.js +41 -0
  10. data/design/measure_jquery/up.on_vs_addEventListener.js +56 -0
  11. data/design/todo_jquery.txt +13 -0
  12. data/dist/unpoly-bootstrap3.js +8 -8
  13. data/dist/unpoly-bootstrap3.min.js +1 -1
  14. data/dist/unpoly.css +22 -20
  15. data/dist/unpoly.js +6990 -5336
  16. data/dist/unpoly.min.css +1 -1
  17. data/dist/unpoly.min.js +4 -4
  18. data/lib/assets/javascripts/unpoly-bootstrap3/viewport-ext.coffee +5 -0
  19. data/lib/assets/javascripts/unpoly.coffee +8 -6
  20. data/lib/assets/javascripts/unpoly/browser.coffee.erb +23 -118
  21. data/lib/assets/javascripts/unpoly/classes/body_shifter.coffee +36 -0
  22. data/lib/assets/javascripts/unpoly/classes/cache.coffee +4 -4
  23. data/lib/assets/javascripts/unpoly/classes/compile_pass.coffee +45 -39
  24. data/lib/assets/javascripts/unpoly/classes/config.coffee +9 -0
  25. data/lib/assets/javascripts/unpoly/classes/css_transition.coffee +18 -27
  26. data/lib/assets/javascripts/unpoly/classes/divertible_chain.coffee +39 -0
  27. data/lib/assets/javascripts/unpoly/classes/event_listener.coffee +116 -0
  28. data/lib/assets/javascripts/unpoly/classes/extract_cascade.coffee +8 -8
  29. data/lib/assets/javascripts/unpoly/classes/extract_plan.coffee +19 -19
  30. data/lib/assets/javascripts/unpoly/classes/field_observer.coffee +54 -31
  31. data/lib/assets/javascripts/unpoly/classes/{focus_tracker.coffee → focus_follower.coffee} +2 -2
  32. data/lib/assets/javascripts/unpoly/classes/follow_variant.coffee +25 -25
  33. data/lib/assets/javascripts/unpoly/classes/html_parser.coffee +4 -11
  34. data/lib/assets/javascripts/unpoly/classes/motion_controller.coffee +157 -0
  35. data/lib/assets/javascripts/unpoly/classes/params.coffee.erb +525 -0
  36. data/lib/assets/javascripts/unpoly/classes/record.coffee +8 -2
  37. data/lib/assets/javascripts/unpoly/classes/rect.js +21 -0
  38. data/lib/assets/javascripts/unpoly/classes/request.coffee +41 -35
  39. data/lib/assets/javascripts/unpoly/classes/response.coffee +7 -3
  40. data/lib/assets/javascripts/unpoly/classes/reveal_motion.coffee +102 -0
  41. data/lib/assets/javascripts/unpoly/classes/scroll_motion.coffee +67 -0
  42. data/lib/assets/javascripts/unpoly/classes/selector.coffee +60 -0
  43. data/lib/assets/javascripts/unpoly/classes/tether.coffee +105 -0
  44. data/lib/assets/javascripts/unpoly/classes/url_set.coffee +12 -7
  45. data/lib/assets/javascripts/unpoly/element.coffee.erb +1126 -0
  46. data/lib/assets/javascripts/unpoly/event.coffee.erb +437 -0
  47. data/lib/assets/javascripts/unpoly/feedback.coffee +73 -94
  48. data/lib/assets/javascripts/unpoly/form.coffee.erb +188 -181
  49. data/lib/assets/javascripts/unpoly/{dom.coffee.erb → fragment.coffee.erb} +250 -283
  50. data/lib/assets/javascripts/unpoly/framework.coffee +67 -0
  51. data/lib/assets/javascripts/unpoly/history.coffee +29 -28
  52. data/lib/assets/javascripts/unpoly/legacy.coffee +60 -0
  53. data/lib/assets/javascripts/unpoly/link.coffee.erb +127 -119
  54. data/lib/assets/javascripts/unpoly/log.coffee +99 -19
  55. data/lib/assets/javascripts/unpoly/modal.coffee.erb +95 -118
  56. data/lib/assets/javascripts/unpoly/motion.coffee.erb +158 -138
  57. data/lib/assets/javascripts/unpoly/namespace.coffee.erb +0 -5
  58. data/lib/assets/javascripts/unpoly/popup.coffee.erb +119 -102
  59. data/lib/assets/javascripts/unpoly/protocol.coffee +11 -15
  60. data/lib/assets/javascripts/unpoly/proxy.coffee +62 -65
  61. data/lib/assets/javascripts/unpoly/radio.coffee +3 -5
  62. data/lib/assets/javascripts/unpoly/rails.coffee +8 -9
  63. data/lib/assets/javascripts/unpoly/syntax.coffee.erb +173 -125
  64. data/lib/assets/javascripts/unpoly/toast.coffee +25 -24
  65. data/lib/assets/javascripts/unpoly/tooltip.coffee +89 -79
  66. data/lib/assets/javascripts/unpoly/util.coffee.erb +579 -1074
  67. data/lib/assets/javascripts/unpoly/{layout.coffee.erb → viewport.coffee.erb} +334 -264
  68. data/lib/assets/stylesheets/unpoly/dom.sass +1 -1
  69. data/lib/assets/stylesheets/unpoly/layout.sass +2 -0
  70. data/lib/assets/stylesheets/unpoly/popup.sass +0 -1
  71. data/lib/assets/stylesheets/unpoly/tooltip.sass +17 -12
  72. data/lib/unpoly/rails/version.rb +1 -1
  73. data/package.json +1 -2
  74. data/spec_app/Gemfile +2 -1
  75. data/spec_app/Gemfile.lock +38 -27
  76. data/spec_app/app/assets/javascripts/integration_test.coffee +1 -0
  77. data/spec_app/app/assets/javascripts/jasmine_specs.coffee +1 -2
  78. data/spec_app/app/assets/stylesheets/integration_test.sass +14 -1
  79. data/spec_app/app/controllers/scroll_test_controller.rb +5 -0
  80. data/spec_app/app/views/css_test/modal.erb +6 -6
  81. data/spec_app/app/views/css_test/popup.erb +44 -18
  82. data/spec_app/app/views/css_test/tooltip.erb +23 -4
  83. data/spec_app/app/views/error_test/trigger.erb +1 -1
  84. data/spec_app/app/views/form_test/basics/new.erb +1 -3
  85. data/spec_app/app/views/pages/start.erb +9 -2
  86. data/spec_app/app/views/reveal_test/long1.erb +1 -1
  87. data/spec_app/app/views/reveal_test/long2.erb +1 -1
  88. data/spec_app/app/views/reveal_test/within_document_viewport.erb +24 -0
  89. data/spec_app/app/views/reveal_test/within_overflowing_div_viewport.erb +28 -0
  90. data/spec_app/app/views/scroll_test/long1.erb +30 -0
  91. data/spec_app/config/routes.rb +1 -0
  92. data/spec_app/spec/javascripts/helpers/agent_detector.coffee +3 -0
  93. data/spec_app/spec/javascripts/helpers/async_sequence.js.coffee +1 -0
  94. data/spec_app/spec/javascripts/helpers/browser_switches.js.coffee +17 -5
  95. data/spec_app/spec/javascripts/helpers/enable_logging.js.coffee +1 -1
  96. data/spec_app/spec/javascripts/helpers/fixture.js.coffee +25 -0
  97. data/spec_app/spec/javascripts/helpers/jquery_no_conflict.js +1 -0
  98. data/spec_app/spec/javascripts/helpers/last_request.js.coffee +1 -0
  99. data/spec_app/spec/javascripts/helpers/mock_ajax.js.coffee +1 -1
  100. data/spec_app/spec/javascripts/helpers/parse_form_data.js.coffee +2 -2
  101. data/spec_app/spec/javascripts/helpers/protect_jasmine_runner.coffee +4 -1
  102. data/spec_app/spec/javascripts/helpers/remove_body_margin.js.coffee +3 -0
  103. data/spec_app/spec/javascripts/helpers/reset_history.js.coffee +2 -1
  104. data/spec_app/spec/javascripts/helpers/reset_knife.js.coffee +2 -2
  105. data/spec_app/spec/javascripts/helpers/reset_up.js.coffee +18 -11
  106. data/spec_app/spec/javascripts/helpers/restore_body_scroll.js.coffee +3 -0
  107. data/spec_app/spec/javascripts/helpers/show_lib_versions.coffee +3 -0
  108. data/spec_app/spec/javascripts/helpers/spec_util.coffee +47 -0
  109. data/spec_app/spec/javascripts/helpers/to_be_around.js.coffee +3 -0
  110. data/spec_app/spec/javascripts/helpers/to_be_array.coffee +5 -0
  111. data/spec_app/spec/javascripts/helpers/to_be_attached.coffee +6 -2
  112. data/spec_app/spec/javascripts/helpers/to_be_blank.js.coffee +3 -0
  113. data/spec_app/spec/javascripts/helpers/to_be_detached.coffee +6 -2
  114. data/spec_app/spec/javascripts/helpers/to_be_element.js.coffee +8 -0
  115. data/spec_app/spec/javascripts/helpers/to_be_error.coffee +3 -0
  116. data/spec_app/spec/javascripts/helpers/to_be_given.js.coffee +3 -0
  117. data/spec_app/spec/javascripts/helpers/to_be_hidden.js.coffee +8 -0
  118. data/spec_app/spec/javascripts/helpers/to_be_missing.js.coffee +3 -0
  119. data/spec_app/spec/javascripts/helpers/to_be_present.js.coffee +3 -0
  120. data/spec_app/spec/javascripts/helpers/to_be_scrolled_to.coffee +3 -0
  121. data/spec_app/spec/javascripts/helpers/to_be_visible.js.coffee +9 -0
  122. data/spec_app/spec/javascripts/helpers/to_contain.js.coffee +3 -0
  123. data/spec_app/spec/javascripts/helpers/to_end_with.js.coffee +3 -0
  124. data/spec_app/spec/javascripts/helpers/to_equal_jquery.js.coffee +1 -2
  125. data/spec_app/spec/javascripts/helpers/to_equal_node_list.coffee +7 -0
  126. data/spec_app/spec/javascripts/helpers/to_equal_via_is_equal.js.coffee +7 -0
  127. data/spec_app/spec/javascripts/helpers/to_have_class.js.coffee +10 -0
  128. data/spec_app/spec/javascripts/helpers/to_have_descendant.js.coffee +10 -0
  129. data/spec_app/spec/javascripts/helpers/to_have_length.js.coffee +8 -0
  130. data/spec_app/spec/javascripts/helpers/to_have_opacity.coffee +7 -3
  131. data/spec_app/spec/javascripts/helpers/to_have_own_property.js.coffee +3 -0
  132. data/spec_app/spec/javascripts/helpers/to_have_request_method.js.coffee +1 -0
  133. data/spec_app/spec/javascripts/helpers/to_have_text.js.coffee +9 -0
  134. data/spec_app/spec/javascripts/helpers/to_have_unhandled_rejections.coffee +0 -21
  135. data/spec_app/spec/javascripts/helpers/to_match_list.coffee +14 -0
  136. data/spec_app/spec/javascripts/helpers/to_match_selector.coffee +3 -0
  137. data/spec_app/spec/javascripts/helpers/to_match_text.js.coffee +4 -1
  138. data/spec_app/spec/javascripts/helpers/to_match_url.coffee +1 -0
  139. data/spec_app/spec/javascripts/helpers/trigger.js.coffee +91 -7
  140. data/spec_app/spec/javascripts/helpers/wait_until_dom_ready.js.coffee +3 -0
  141. data/spec_app/spec/javascripts/up/browser_spec.js.coffee +23 -90
  142. data/spec_app/spec/javascripts/up/classes/cache_spec.js.coffee +3 -0
  143. data/spec_app/spec/javascripts/up/classes/config_spec.coffee +24 -0
  144. data/spec_app/spec/javascripts/up/classes/divertible_chain_spec.coffee +45 -0
  145. data/spec_app/spec/javascripts/up/classes/focus_tracker_spec.coffee +5 -2
  146. data/spec_app/spec/javascripts/up/classes/params_spec.coffee +557 -0
  147. data/spec_app/spec/javascripts/up/classes/request_spec.coffee +7 -4
  148. data/spec_app/spec/javascripts/up/classes/scroll_motion_spec.js.coffee +51 -0
  149. data/spec_app/spec/javascripts/up/classes/store/memory_spec.js.coffee +3 -0
  150. data/spec_app/spec/javascripts/up/classes/store/session_spec.js.coffee +3 -2
  151. data/spec_app/spec/javascripts/up/element_spec.coffee +897 -0
  152. data/spec_app/spec/javascripts/up/event_spec.js.coffee +496 -0
  153. data/spec_app/spec/javascripts/up/feedback_spec.js.coffee +69 -48
  154. data/spec_app/spec/javascripts/up/form_spec.js.coffee +252 -194
  155. data/spec_app/spec/javascripts/up/{dom_spec.js.coffee → fragment_spec.js.coffee} +381 -388
  156. data/spec_app/spec/javascripts/up/history_spec.js.coffee +21 -19
  157. data/spec_app/spec/javascripts/up/jquery_spec.js.coffee +4 -0
  158. data/spec_app/spec/javascripts/up/legacy_spec.js.coffee +27 -0
  159. data/spec_app/spec/javascripts/up/link_spec.js.coffee +163 -160
  160. data/spec_app/spec/javascripts/up/log_spec.js.coffee +85 -12
  161. data/spec_app/spec/javascripts/up/modal_spec.js.coffee +141 -123
  162. data/spec_app/spec/javascripts/up/motion_spec.js.coffee +117 -113
  163. data/spec_app/spec/javascripts/up/popup_spec.js.coffee +60 -77
  164. data/spec_app/spec/javascripts/up/protocol_spec.js.coffee +1 -0
  165. data/spec_app/spec/javascripts/up/proxy_spec.js.coffee +85 -78
  166. data/spec_app/spec/javascripts/up/radio_spec.js.coffee +29 -22
  167. data/spec_app/spec/javascripts/up/rails_spec.js.coffee +14 -13
  168. data/spec_app/spec/javascripts/up/spec_spec.js.coffee +9 -0
  169. data/spec_app/spec/javascripts/up/syntax_spec.js.coffee +96 -66
  170. data/spec_app/spec/javascripts/up/toast_spec.js.coffee +37 -0
  171. data/spec_app/spec/javascripts/up/tooltip_spec.js.coffee +31 -47
  172. data/spec_app/spec/javascripts/up/util_spec.js.coffee +725 -562
  173. data/spec_app/spec/javascripts/up/{layout_spec.js.coffee → viewport_spec.js.coffee} +175 -149
  174. metadata +57 -19
  175. data/lib/assets/javascripts/unpoly-bootstrap3/layout-ext.coffee +0 -5
  176. data/lib/assets/javascripts/unpoly/bus.coffee.erb +0 -518
  177. data/lib/assets/javascripts/unpoly/classes/extract_step.coffee +0 -4
  178. data/lib/assets/javascripts/unpoly/classes/motion_tracker.coffee +0 -125
  179. data/lib/assets/javascripts/unpoly/params.coffee.erb +0 -522
  180. data/spec_app/spec/javascripts/helpers/append_fixture.js.coffee +0 -8
  181. data/spec_app/spec/javascripts/up/bus_spec.js.coffee +0 -210
  182. data/spec_app/spec/javascripts/up/namespace_spec.js.coffee +0 -9
  183. data/spec_app/spec/javascripts/up/params_spec.coffee +0 -768
  184. data/spec_app/vendor/asset-libs/jasmine-fixture-1.3.4/jasmine-fixture.js +0 -433
  185. data/spec_app/vendor/asset-libs/jasmine-jquery-2.1.1/.bower.json +0 -26
  186. data/spec_app/vendor/asset-libs/jasmine-jquery-2.1.1/jasmine-jquery.js +0 -838
@@ -1,433 +0,0 @@
1
- /* jasmine-fixture - 1.3.4
2
- * Makes injecting HTML snippets into the DOM easy & clean!
3
- * https://github.com/searls/jasmine-fixture
4
- */
5
- (function() {
6
- var createHTMLBlock,
7
- __slice = [].slice;
8
-
9
- (function($) {
10
- var jasmineFixture, originalAffix, originalJasmineDotFixture, originalJasmineFixture, root, _, _ref;
11
- root = (1, eval)('this');
12
- originalJasmineFixture = root.jasmineFixture;
13
- originalJasmineDotFixture = (_ref = root.jasmine) != null ? _ref.fixture : void 0;
14
- originalAffix = root.affix;
15
- _ = function(list) {
16
- return {
17
- inject: function(iterator, memo) {
18
- var item, _i, _len, _results;
19
- _results = [];
20
- for (_i = 0, _len = list.length; _i < _len; _i++) {
21
- item = list[_i];
22
- _results.push(memo = iterator(memo, item));
23
- }
24
- return _results;
25
- }
26
- };
27
- };
28
- root.jasmineFixture = function($) {
29
- var $whatsTheRootOf, affix, create, ewwSideEffects, jasmineFixture, noConflict;
30
- affix = function(selectorOptions) {
31
- return create.call(this, selectorOptions, true);
32
- };
33
- create = function(selectorOptions, attach) {
34
- var $top;
35
- $top = null;
36
- _(selectorOptions.trim().split(/[ ](?![^\{]*\})(?=[^\]]*?(?:\[|$))/)).inject(function($parent, elementSelector) {
37
- var $el;
38
- if (elementSelector === ">") {
39
- return $parent;
40
- }
41
- $el = createHTMLBlock($, elementSelector);
42
- if (attach || $top) {
43
- $el.appendTo($parent);
44
- }
45
- $top || ($top = $el);
46
- return $el;
47
- }, $whatsTheRootOf(this));
48
- return $top;
49
- };
50
- noConflict = function() {
51
- var currentJasmineFixture, _ref1;
52
- currentJasmineFixture = jasmine.fixture;
53
- root.jasmineFixture = originalJasmineFixture;
54
- if ((_ref1 = root.jasmine) != null) {
55
- _ref1.fixture = originalJasmineDotFixture;
56
- }
57
- root.affix = originalAffix;
58
- return currentJasmineFixture;
59
- };
60
- $whatsTheRootOf = function(that) {
61
- if ((that != null ? that.jquery : void 0) != null) {
62
- return that;
63
- } else if ($('#jasmine_content').length > 0) {
64
- return $('#jasmine_content');
65
- } else {
66
- return $('<div id="jasmine_content"></div>').appendTo('body');
67
- }
68
- };
69
- ewwSideEffects = function(jasmineFixture) {
70
- var _ref1;
71
- if ((_ref1 = root.jasmine) != null) {
72
- _ref1.fixture = jasmineFixture;
73
- }
74
- $.fn.affix = root.affix = jasmineFixture.affix;
75
- return afterEach(function() {
76
- return $('#jasmine_content').remove();
77
- });
78
- };
79
- jasmineFixture = {
80
- affix: affix,
81
- create: create,
82
- noConflict: noConflict
83
- };
84
- ewwSideEffects(jasmineFixture);
85
- return jasmineFixture;
86
- };
87
- if ($) {
88
- return jasmineFixture = root.jasmineFixture($);
89
- } else {
90
- return root.affix = function() {
91
- var nowJQueryExists;
92
- nowJQueryExists = window.jQuery || window.$;
93
- if (nowJQueryExists != null) {
94
- jasmineFixture = root.jasmineFixture(nowJQueryExists);
95
- return affix.call.apply(affix, [this].concat(__slice.call(arguments)));
96
- } else {
97
- throw new Error("jasmine-fixture requires jQuery to be defined at window.jQuery or window.$");
98
- }
99
- };
100
- }
101
- })(window.jQuery || window.$);
102
-
103
- createHTMLBlock = (function() {
104
- var bindData, bindEvents, parseAttributes, parseClasses, parseContents, parseEnclosure, parseReferences, parseVariableScope, regAttr, regAttrDfn, regAttrs, regCBrace, regClass, regClasses, regData, regDatas, regEvent, regEvents, regExclamation, regId, regReference, regTag, regTagNotContent, regZenTagDfn;
105
- createHTMLBlock = function($, ZenObject, data, functions, indexes) {
106
- var ZenCode, arr, block, blockAttrs, blockClasses, blockHTML, blockId, blockTag, blocks, el, el2, els, forScope, indexName, inner, len, obj, origZenCode, paren, result, ret, zc, zo;
107
- if ($.isPlainObject(ZenObject)) {
108
- ZenCode = ZenObject.main;
109
- } else {
110
- ZenCode = ZenObject;
111
- ZenObject = {
112
- main: ZenCode
113
- };
114
- }
115
- origZenCode = ZenCode;
116
- if (indexes === undefined) {
117
- indexes = {};
118
- }
119
- if (ZenCode.charAt(0) === "!" || $.isArray(data)) {
120
- if ($.isArray(data)) {
121
- forScope = ZenCode;
122
- } else {
123
- obj = parseEnclosure(ZenCode, "!");
124
- obj = obj.substring(obj.indexOf(":") + 1, obj.length - 1);
125
- forScope = parseVariableScope(ZenCode);
126
- }
127
- while (forScope.charAt(0) === "@") {
128
- forScope = parseVariableScope("!for:!" + parseReferences(forScope, ZenObject));
129
- }
130
- zo = ZenObject;
131
- zo.main = forScope;
132
- el = $();
133
- if (ZenCode.substring(0, 5) === "!for:" || $.isArray(data)) {
134
- if (!$.isArray(data) && obj.indexOf(":") > 0) {
135
- indexName = obj.substring(0, obj.indexOf(":"));
136
- obj = obj.substr(obj.indexOf(":") + 1);
137
- }
138
- arr = ($.isArray(data) ? data : data[obj]);
139
- zc = zo.main;
140
- if ($.isArray(arr) || $.isPlainObject(arr)) {
141
- $.map(arr, function(value, index) {
142
- var next;
143
- zo.main = zc;
144
- if (indexName !== undefined) {
145
- indexes[indexName] = index;
146
- }
147
- if (!$.isPlainObject(value)) {
148
- value = {
149
- value: value
150
- };
151
- }
152
- next = createHTMLBlock($, zo, value, functions, indexes);
153
- if (el.length !== 0) {
154
- return $.each(next, function(index, value) {
155
- return el.push(value);
156
- });
157
- }
158
- });
159
- }
160
- if (!$.isArray(data)) {
161
- ZenCode = ZenCode.substr(obj.length + 6 + forScope.length);
162
- } else {
163
- ZenCode = "";
164
- }
165
- } else if (ZenCode.substring(0, 4) === "!if:") {
166
- result = parseContents("!" + obj + "!", data, indexes);
167
- if (result !== "undefined" || result !== "false" || result !== "") {
168
- el = createHTMLBlock($, zo, data, functions, indexes);
169
- }
170
- ZenCode = ZenCode.substr(obj.length + 5 + forScope.length);
171
- }
172
- ZenObject.main = ZenCode;
173
- } else if (ZenCode.charAt(0) === "(") {
174
- paren = parseEnclosure(ZenCode, "(", ")");
175
- inner = paren.substring(1, paren.length - 1);
176
- ZenCode = ZenCode.substr(paren.length);
177
- zo = ZenObject;
178
- zo.main = inner;
179
- el = createHTMLBlock($, zo, data, functions, indexes);
180
- } else {
181
- blocks = ZenCode.match(regZenTagDfn);
182
- block = blocks[0];
183
- if (block.length === 0) {
184
- return "";
185
- }
186
- if (block.indexOf("@") >= 0) {
187
- ZenCode = parseReferences(ZenCode, ZenObject);
188
- zo = ZenObject;
189
- zo.main = ZenCode;
190
- return createHTMLBlock($, zo, data, functions, indexes);
191
- }
192
- block = parseContents(block, data, indexes);
193
- blockClasses = parseClasses($, block);
194
- if (regId.test(block)) {
195
- blockId = regId.exec(block)[1];
196
- }
197
- blockAttrs = parseAttributes(block, data);
198
- blockTag = (block.charAt(0) === "{" ? "span" : "div");
199
- if (ZenCode.charAt(0) !== "#" && ZenCode.charAt(0) !== "." && ZenCode.charAt(0) !== "{") {
200
- blockTag = regTag.exec(block)[1];
201
- }
202
- if (block.search(regCBrace) !== -1) {
203
- blockHTML = block.match(regCBrace)[1];
204
- }
205
- blockAttrs = $.extend(blockAttrs, {
206
- id: blockId,
207
- "class": blockClasses,
208
- html: blockHTML
209
- });
210
- el = $("<" + blockTag + ">", blockAttrs);
211
- el.attr(blockAttrs);
212
- el = bindEvents(block, el, functions);
213
- el = bindData(block, el, data);
214
- ZenCode = ZenCode.substr(blocks[0].length);
215
- ZenObject.main = ZenCode;
216
- }
217
- if (ZenCode.length > 0) {
218
- if (ZenCode.charAt(0) === ">") {
219
- if (ZenCode.charAt(1) === "(") {
220
- zc = parseEnclosure(ZenCode.substr(1), "(", ")");
221
- ZenCode = ZenCode.substr(zc.length + 1);
222
- } else if (ZenCode.charAt(1) === "!") {
223
- obj = parseEnclosure(ZenCode.substr(1), "!");
224
- forScope = parseVariableScope(ZenCode.substr(1));
225
- zc = obj + forScope;
226
- ZenCode = ZenCode.substr(zc.length + 1);
227
- } else {
228
- len = Math.max(ZenCode.indexOf("+"), ZenCode.length);
229
- zc = ZenCode.substring(1, len);
230
- ZenCode = ZenCode.substr(len);
231
- }
232
- zo = ZenObject;
233
- zo.main = zc;
234
- els = $(createHTMLBlock($, zo, data, functions, indexes));
235
- els.appendTo(el);
236
- }
237
- if (ZenCode.charAt(0) === "+") {
238
- zo = ZenObject;
239
- zo.main = ZenCode.substr(1);
240
- el2 = createHTMLBlock($, zo, data, functions, indexes);
241
- $.each(el2, function(index, value) {
242
- return el.push(value);
243
- });
244
- }
245
- }
246
- ret = el;
247
- return ret;
248
- };
249
- bindData = function(ZenCode, el, data) {
250
- var datas, i, split;
251
- if (ZenCode.search(regDatas) === 0) {
252
- return el;
253
- }
254
- datas = ZenCode.match(regDatas);
255
- if (datas === null) {
256
- return el;
257
- }
258
- i = 0;
259
- while (i < datas.length) {
260
- split = regData.exec(datas[i]);
261
- if (split[3] === undefined) {
262
- $(el).data(split[1], data[split[1]]);
263
- } else {
264
- $(el).data(split[1], data[split[3]]);
265
- }
266
- i++;
267
- }
268
- return el;
269
- };
270
- bindEvents = function(ZenCode, el, functions) {
271
- var bindings, fn, i, split;
272
- if (ZenCode.search(regEvents) === 0) {
273
- return el;
274
- }
275
- bindings = ZenCode.match(regEvents);
276
- if (bindings === null) {
277
- return el;
278
- }
279
- i = 0;
280
- while (i < bindings.length) {
281
- split = regEvent.exec(bindings[i]);
282
- if (split[2] === undefined) {
283
- fn = functions[split[1]];
284
- } else {
285
- fn = functions[split[2]];
286
- }
287
- $(el).bind(split[1], fn);
288
- i++;
289
- }
290
- return el;
291
- };
292
- parseAttributes = function(ZenBlock, data) {
293
- var attrStrs, attrs, i, parts;
294
- if (ZenBlock.search(regAttrDfn) === -1) {
295
- return undefined;
296
- }
297
- attrStrs = ZenBlock.match(regAttrDfn);
298
- attrs = {};
299
- i = 0;
300
- while (i < attrStrs.length) {
301
- parts = regAttr.exec(attrStrs[i]);
302
- attrs[parts[1]] = "";
303
- if (parts[3] !== undefined) {
304
- attrs[parts[1]] = parseContents(parts[3], data);
305
- }
306
- i++;
307
- }
308
- return attrs;
309
- };
310
- parseClasses = function($, ZenBlock) {
311
- var classes, clsString, i;
312
- ZenBlock = ZenBlock.match(regTagNotContent)[0];
313
- if (ZenBlock.search(regClasses) === -1) {
314
- return undefined;
315
- }
316
- classes = ZenBlock.match(regClasses);
317
- clsString = "";
318
- i = 0;
319
- while (i < classes.length) {
320
- clsString += " " + regClass.exec(classes[i])[1];
321
- i++;
322
- }
323
- return $.trim(clsString);
324
- };
325
- parseContents = function(ZenBlock, data, indexes) {
326
- var html;
327
- if (indexes === undefined) {
328
- indexes = {};
329
- }
330
- html = ZenBlock;
331
- if (data === undefined) {
332
- return html;
333
- }
334
- while (regExclamation.test(html)) {
335
- html = html.replace(regExclamation, function(str, str2) {
336
- var begChar, fn, val;
337
- begChar = "";
338
- if (str.indexOf("!for:") > 0 || str.indexOf("!if:") > 0) {
339
- return str;
340
- }
341
- if (str.charAt(0) !== "!") {
342
- begChar = str.charAt(0);
343
- str = str.substring(2, str.length - 1);
344
- }
345
- fn = new Function("data", "indexes", "var r=undefined;" + "with(data){try{r=" + str + ";}catch(e){}}" + "with(indexes){try{if(r===undefined)r=" + str + ";}catch(e){}}" + "return r;");
346
- val = unescape(fn(data, indexes));
347
- return begChar + val;
348
- });
349
- }
350
- html = html.replace(/\\./g, function(str) {
351
- return str.charAt(1);
352
- });
353
- return unescape(html);
354
- };
355
- parseEnclosure = function(ZenCode, open, close, count) {
356
- var index, ret;
357
- if (close === undefined) {
358
- close = open;
359
- }
360
- index = 1;
361
- if (count === undefined) {
362
- count = (ZenCode.charAt(0) === open ? 1 : 0);
363
- }
364
- if (count === 0) {
365
- return;
366
- }
367
- while (count > 0 && index < ZenCode.length) {
368
- if (ZenCode.charAt(index) === close && ZenCode.charAt(index - 1) !== "\\") {
369
- count--;
370
- } else {
371
- if (ZenCode.charAt(index) === open && ZenCode.charAt(index - 1) !== "\\") {
372
- count++;
373
- }
374
- }
375
- index++;
376
- }
377
- ret = ZenCode.substring(0, index);
378
- return ret;
379
- };
380
- parseReferences = function(ZenCode, ZenObject) {
381
- ZenCode = ZenCode.replace(regReference, function(str) {
382
- var fn;
383
- str = str.substr(1);
384
- fn = new Function("objs", "var r=\"\";" + "with(objs){try{" + "r=" + str + ";" + "}catch(e){}}" + "return r;");
385
- return fn(ZenObject, parseReferences);
386
- });
387
- return ZenCode;
388
- };
389
- parseVariableScope = function(ZenCode) {
390
- var forCode, rest, tag;
391
- if (ZenCode.substring(0, 5) !== "!for:" && ZenCode.substring(0, 4) !== "!if:") {
392
- return undefined;
393
- }
394
- forCode = parseEnclosure(ZenCode, "!");
395
- ZenCode = ZenCode.substr(forCode.length);
396
- if (ZenCode.charAt(0) === "(") {
397
- return parseEnclosure(ZenCode, "(", ")");
398
- }
399
- tag = ZenCode.match(regZenTagDfn)[0];
400
- ZenCode = ZenCode.substr(tag.length);
401
- if (ZenCode.length === 0 || ZenCode.charAt(0) === "+") {
402
- return tag;
403
- } else if (ZenCode.charAt(0) === ">") {
404
- rest = "";
405
- rest = parseEnclosure(ZenCode.substr(1), "(", ")", 1);
406
- return tag + ">" + rest;
407
- }
408
- return undefined;
409
- };
410
- regZenTagDfn = /([#\.\@]?[\w-]+|\[([\w-!?=:"']+(="([^"]|\\")+")? {0,})+\]|\~[\w$]+=[\w$]+|&[\w$]+(=[\w$]+)?|[#\.\@]?!([^!]|\\!)+!){0,}(\{([^\}]|\\\})+\})?/i;
411
- regTag = /(\w+)/i;
412
- regId = /(?:^|\b)#([\w-!]+)/i;
413
- regTagNotContent = /((([#\.]?[\w-]+)?(\[([\w!]+(="([^"]|\\")+")? {0,})+\])?)+)/i;
414
- /*
415
- See lookahead syntax (?!) at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp
416
- */
417
-
418
- regClasses = /(\.[\w-]+)(?!["\w])/g;
419
- regClass = /\.([\w-]+)/i;
420
- regReference = /(@[\w$_][\w$_\d]+)/i;
421
- regAttrDfn = /(\[([\w-!]+(="?([^"]|\\")+"?)? {0,})+\])/ig;
422
- regAttrs = /([\w-!]+(="([^"]|\\")+")?)/g;
423
- regAttr = /([\w-!]+)(="?((([\w]+(\[.*?\])+)|[^"\]]|\\")+)"?)?/i;
424
- regCBrace = /\{(([^\}]|\\\})+)\}/i;
425
- regExclamation = /(?:([^\\]|^))!([^!]|\\!)+!/g;
426
- regEvents = /\~[\w$]+(=[\w$]+)?/g;
427
- regEvent = /\~([\w$]+)=([\w$]+)/i;
428
- regDatas = /&[\w$]+(=[\w$]+)?/g;
429
- regData = /&([\w$]+)(=([\w$]+))?/i;
430
- return createHTMLBlock;
431
- })();
432
-
433
- }).call(this);
@@ -1,26 +0,0 @@
1
- {
2
- "name": "jasmine-jquery",
3
- "main": "lib/jasmine-jquery.js",
4
- "ignore": [
5
- "test",
6
- "vendor",
7
- ".*",
8
- "HISTORY.md",
9
- "SpecRunner.html"
10
- ],
11
- "dependencies": {
12
- "jasmine": ">=2",
13
- "jquery": ">=2"
14
- },
15
- "homepage": "https://github.com/velesin/jasmine-jquery",
16
- "version": "2.1.1",
17
- "_release": "2.1.1",
18
- "_resolution": {
19
- "type": "version",
20
- "tag": "2.1.1",
21
- "commit": "fdd234f58d4997ec13400ba4f070e8a803f6ecbe"
22
- },
23
- "_source": "git://github.com/velesin/jasmine-jquery.git",
24
- "_target": "*",
25
- "_originalSource": "jasmine-jquery"
26
- }