opal 0.0.1 → 0.1.0
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.
- data/.gitignore +10 -1
- data/.gitmodules +0 -0
- data/Opalfile +371 -0
- data/README.md +45 -0
- data/Rakefile +237 -34
- data/VERSION +1 -1
- data/bin/opal +13 -0
- data/demos/apps/browser_demo/index.html +11 -0
- data/demos/apps/browser_demo/lib/browser_demo.rb +31 -0
- data/demos/apps/simple_opal/Opalfile +13 -0
- data/demos/apps/simple_opal/index.html +11 -0
- data/demos/apps/simple_opal/lib/app_controller.rb +62 -0
- data/demos/apps/simple_opal/lib/main_window.rb +146 -0
- data/demos/browser/request/index.html +52 -0
- data/demos/browser/request/request.rb +48 -0
- data/gen/browser/__PROJECT_NAME__/index.html +10 -0
- data/gen/browser/__PROJECT_NAME__/lib/__PROJECT_NAME__.rb +1 -0
- data/lib/opal.rb +48 -3
- data/lib/opal/builders/base.rb +50 -0
- data/lib/opal/builders/css.rb +46 -0
- data/lib/opal/builders/javascript.rb +44 -0
- data/lib/opal/builders/opal.rb +79 -0
- data/lib/opal/builders/ruby.rb +50 -0
- data/lib/opal/builders/ruby/generate.rb +1851 -0
- data/lib/opal/builders/ruby/nodes.rb +210 -0
- data/lib/opal/builders/ruby/ruby.rb +916 -0
- data/lib/opal/builders/ruby/ruby_parser.rb +6008 -0
- data/lib/opal/builders/ruby/ruby_parser.rb.y +1451 -0
- data/lib/opal/models/build_item.rb +104 -0
- data/lib/opal/models/hash_struct.rb +40 -0
- data/lib/opal/models/project.rb +215 -0
- data/lib/opal/models/struct_accessors.rb +58 -0
- data/lib/opal/models/target.rb +176 -0
- data/lib/opal/opal/env/console.rb +66 -0
- data/lib/opal/opal/env/fs.rb +98 -0
- data/lib/opal/opal/env/object.rb +48 -0
- data/lib/opal/opal/environment.rb +139 -0
- data/lib/opal/opal/gen.rb +62 -0
- data/lib/opal/opal/opal.rb +68 -0
- data/lib/opal/opal/repl.rb +38 -0
- data/lib/opal/opalfile/dsl.rb +62 -0
- data/lib/opal/opalfile/opalfile.rb +133 -0
- data/lib/opal/opalfile/task.rb +96 -0
- data/lib/opal/opalfile/task_manager.rb +63 -0
- data/lib/opal/opalfile/task_scope.rb +52 -0
- data/lib/opal/rack/app_server.rb +119 -0
- data/opals/aristo/README.md +16 -0
- data/opals/browser/Opalfile +11 -0
- data/opals/browser/README.md +146 -0
- data/opals/browser/SIZZLE_LICESNSE.txt +148 -0
- data/opals/browser/lib/browser.rb +118 -0
- data/opals/browser/lib/browser/builder.rb +41 -0
- data/opals/browser/lib/browser/canvas_context.rb +115 -0
- data/opals/browser/lib/browser/dimensions.rb +50 -0
- data/opals/browser/lib/browser/document.rb +146 -0
- data/opals/browser/lib/browser/element.rb +487 -0
- data/opals/browser/lib/browser/element/attributes.rb +88 -0
- data/opals/browser/lib/browser/element/css.rb +290 -0
- data/opals/browser/lib/browser/element/form.rb +146 -0
- data/opals/browser/lib/browser/event/dom_events.rb +81 -0
- data/opals/browser/lib/browser/event/event.rb +177 -0
- data/opals/browser/lib/browser/event/trigger_events.rb +53 -0
- data/opals/browser/lib/browser/geometry.rb +97 -0
- data/opals/browser/lib/browser/json.rb +32 -0
- data/opals/browser/lib/browser/json_parse.js +321 -0
- data/opals/browser/lib/browser/request/request.rb +201 -0
- data/opals/browser/lib/browser/sizzle.js +1068 -0
- data/opals/browser/lib/browser/string.rb +42 -0
- data/opals/browser/lib/browser/touch.rb +37 -0
- data/{runtime/yaml.js → opals/browser/lib/browser/vml_context.js} +8 -8
- data/opals/browser/lib/browser/window.rb +36 -0
- data/opals/browser/spec/browser/browser_detection_spec.rb +7 -0
- data/opals/browser/spec/document/aref_spec.rb +110 -0
- data/opals/browser/spec/document/ready_spec.rb +16 -0
- data/opals/browser/spec/element/body_spec.rb +11 -0
- data/opals/browser/spec/element/clear_spec.rb +26 -0
- data/opals/browser/spec/element/empty_spec.rb +29 -0
- data/opals/browser/spec/element/has_class_spec.rb +40 -0
- data/opals/browser/spec/element/hidden_spec.rb +23 -0
- data/opals/browser/spec/element/hide_spec.rb +31 -0
- data/opals/browser/spec/element/remove_spec.rb +25 -0
- data/opals/browser/spec/element/show_spec.rb +31 -0
- data/opals/browser/spec/element/style_spec.rb +69 -0
- data/opals/browser/spec/element/toggle_spec.rb +31 -0
- data/opals/browser/spec/element/visible_spec.rb +23 -0
- data/opals/browser/spec/spec_helper.rb +1 -0
- data/opals/cherry_kit/Opalfile +6 -0
- data/opals/cherry_kit/bin/cherry_kit.rb +11 -0
- data/opals/cherry_kit/lib/cherry_kit.rb +29 -0
- data/opals/foundation/Opalfile +11 -0
- data/opals/foundation/bin/foundation.rb +12 -0
- data/opals/foundation/lib/foundation.rb +32 -0
- data/opals/foundation/lib/foundation/__table_view_desktop/outline_view.rb +57 -0
- data/opals/foundation/lib/foundation/__table_view_desktop/table_column.rb +59 -0
- data/opals/foundation/lib/foundation/__table_view_desktop/table_header_view.rb +34 -0
- data/opals/foundation/lib/foundation/__table_view_desktop/table_view.rb +304 -0
- data/opals/foundation/lib/foundation/controllers/array_controller.rb +54 -0
- data/opals/foundation/lib/foundation/controllers/controller.rb +74 -0
- data/opals/foundation/lib/foundation/controllers/controller_selection_proxy.rb +67 -0
- data/opals/foundation/lib/foundation/controllers/object_controller.rb +145 -0
- data/opals/foundation/lib/foundation/controllers/view.rb +40 -0
- data/opals/foundation/lib/foundation/core/application.rb +476 -0
- data/opals/foundation/lib/foundation/core/attributes.rb +146 -0
- data/opals/foundation/lib/foundation/core/bindings.rb +125 -0
- data/opals/foundation/lib/foundation/core/builder.rb +101 -0
- data/opals/foundation/lib/foundation/core/event.rb +112 -0
- data/opals/foundation/lib/foundation/core/index_path.rb +49 -0
- data/opals/foundation/lib/foundation/core/index_set.rb +97 -0
- data/opals/foundation/lib/foundation/core/notification.rb +113 -0
- data/opals/foundation/lib/foundation/core/observable.rb +275 -0
- data/opals/foundation/lib/foundation/core/observable_array.rb +30 -0
- data/opals/foundation/lib/foundation/core/responder.rb +85 -0
- data/opals/foundation/lib/foundation/core/run_loop.rb +89 -0
- data/opals/foundation/lib/foundation/core/touch.rb +95 -0
- data/opals/foundation/lib/foundation/gestures/gesture_recognizer.rb +35 -0
- data/opals/foundation/lib/foundation/rendering/render_context.rb +100 -0
- data/opals/foundation/lib/foundation/rendering/renderer.rb +137 -0
- data/opals/foundation/lib/foundation/rendering/root_theme.rb +77 -0
- data/opals/foundation/lib/foundation/rendering/root_theme/button.rb +62 -0
- data/opals/foundation/lib/foundation/rendering/root_theme/control.rb +72 -0
- data/opals/foundation/lib/foundation/rendering/root_theme/label.rb +54 -0
- data/opals/foundation/lib/foundation/rendering/root_theme/scroller.rb +58 -0
- data/opals/foundation/lib/foundation/rendering/root_theme/slider.rb +72 -0
- data/opals/foundation/lib/foundation/rendering/root_theme/table_view.rb +97 -0
- data/opals/foundation/lib/foundation/rendering/root_theme/text_field.rb +55 -0
- data/opals/foundation/lib/foundation/rendering/root_theme/view.rb +81 -0
- data/opals/foundation/lib/foundation/rendering/theme.rb +38 -0
- data/opals/foundation/lib/foundation/table_view/cell.rb +39 -0
- data/opals/foundation/lib/foundation/table_view/table.rb +171 -0
- data/opals/foundation/lib/foundation/views/button.rb +63 -0
- data/opals/foundation/lib/foundation/views/checkbox.rb +28 -0
- data/opals/foundation/lib/foundation/views/clip.rb +47 -0
- data/opals/foundation/lib/foundation/views/control.rb +199 -0
- data/opals/foundation/lib/foundation/views/label.rb +54 -0
- data/opals/foundation/lib/foundation/views/scroll.rb +294 -0
- data/opals/foundation/lib/foundation/views/scroll_view_desktop.rb +152 -0
- data/opals/foundation/lib/foundation/views/scroller.rb +54 -0
- data/opals/foundation/lib/foundation/views/slider.rb +93 -0
- data/opals/foundation/lib/foundation/views/text_field.rb +83 -0
- data/opals/foundation/lib/foundation/views/view.rb +426 -0
- data/opals/foundation/lib/foundation/windows/window.rb +191 -0
- data/opals/foundation/resources/button/button.css +23 -0
- data/{runtime/init.js → opals/foundation/resources/foundation.css} +27 -33
- data/opals/foundation/resources/scroll/scroll.css +22 -0
- data/opals/foundation/resources/scroll_view/scroll_view.css +3 -0
- data/opals/foundation/resources/scroll_view/scroller.css +3 -0
- data/opals/foundation/resources/slider/regular/slider.css +3 -0
- data/opals/foundation/resources/slider/slider.css +27 -0
- data/opals/foundation/resources/table_view/outline_view.css +3 -0
- data/opals/foundation/resources/table_view/table_view.css +15 -0
- data/opals/foundation/resources/text_field/text_field.css +71 -0
- data/opals/foundation/spec/spec_helper.rb +1 -0
- data/opals/foundation/spec/system/attributes/get_attribute_spec.rb +69 -0
- data/opals/foundation/spec/system/attributes/get_path_spec.rb +44 -0
- data/opals/foundation/spec/system/attributes/set_path_spec.rb +24 -0
- data/opals/foundation/spec/system/attributes/set_spec.rb +58 -0
- data/opals/foundation/spec/system/bindings/bindings.rb +85 -0
- data/opals/foundation/spec/system/key_value_binding/bind_spec.rb +43 -0
- data/opals/foundation/spec/system/observable/dependant_keys_spec.rb +74 -0
- data/opals/foundation/spec/system/observable/observe_spec.rb +292 -0
- data/opals/foundation/spec/system/observable/remove_observer_spec.rb +60 -0
- data/opals/opal/Opalfile +14 -0
- data/opals/opal/spec/core/array/append_spec.rb +30 -0
- data/opals/opal/spec/core/array/assoc_spec.rb +29 -0
- data/opals/opal/spec/core/array/at_spec.rb +37 -0
- data/opals/opal/spec/core/array/clear_spec.rb +22 -0
- data/opals/opal/spec/core/array/collect_bang_spec.rb +27 -0
- data/opals/opal/spec/core/array/collect_spec.rb +27 -0
- data/opals/opal/spec/core/array/compact_spec.rb +15 -0
- data/opals/opal/spec/core/array/concat_spec.rb +15 -0
- data/opals/opal/spec/core/array/constructor_spec.rb +14 -0
- data/opals/opal/spec/core/array/each_spec.rb +9 -0
- data/opals/opal/spec/core/array/element_reference_spec.rb +4 -0
- data/opals/opal/spec/core/array/first_spec.rb +35 -0
- data/opals/opal/spec/core/array/include_spec.rb +9 -0
- data/opals/opal/spec/core/array/map_spec.rb +31 -0
- data/opals/opal/spec/core/builtin_constants/builtin_constants_spec.rb +7 -0
- data/opals/opal/spec/core/false/and_spec.rb +10 -0
- data/opals/opal/spec/core/false/inspect_spec.rb +6 -0
- data/opals/opal/spec/core/false/or_spec.rb +10 -0
- data/opals/opal/spec/core/false/to_s_spec.rb +6 -0
- data/opals/opal/spec/core/false/xor_spec.rb +10 -0
- data/opals/opal/spec/core/file/join_spec.rb +19 -0
- data/opals/opal/spec/core/kernel/instance_eval_spec.rb +0 -0
- data/opals/opal/spec/core/kernel/loop_spec.rb +24 -0
- data/opals/opal/spec/core/kernel/raise_spec.rb +0 -0
- data/opals/opal/spec/core/module/attr_accessor_spec.rb +28 -0
- data/opals/opal/spec/core/number/lt_spec.rb +12 -0
- data/opals/opal/spec/core/true/and_spec.rb +10 -0
- data/opals/opal/spec/core/true/inspect_spec.rb +6 -0
- data/opals/opal/spec/core/true/or_spec.rb +10 -0
- data/opals/opal/spec/core/true/to_s_spec.rb +6 -0
- data/opals/opal/spec/core/true/xor_spec.rb +10 -0
- data/opals/opal/spec/fixtures/super.rb +70 -0
- data/opals/opal/spec/language/____temp_remove_this.rb +12 -0
- data/opals/opal/spec/language/and_spec.rb +62 -0
- data/opals/opal/spec/language/array_spec.rb +52 -0
- data/opals/opal/spec/language/block_spec.rb +18 -0
- data/opals/opal/spec/language/break_spec.rb +36 -0
- data/opals/opal/spec/language/case_spec.rb +103 -0
- data/opals/opal/spec/language/def_spec.rb +11 -0
- data/opals/opal/spec/language/eigenclass_spec.rb +60 -0
- data/opals/opal/spec/language/hash_spec.rb +29 -0
- data/opals/opal/spec/language/if_spec.rb +54 -0
- data/opals/opal/spec/language/loop_spec.rb +11 -0
- data/opals/opal/spec/language/metaclass_spec.rb +21 -0
- data/opals/opal/spec/language/method_spec.rb +64 -0
- data/opals/opal/spec/language/next_spec.rb +25 -0
- data/opals/opal/spec/language/or_spec.rb +34 -0
- data/opals/opal/spec/language/redo_spec.rb +24 -0
- data/opals/opal/spec/language/rescue_spec.rb +20 -0
- data/opals/opal/spec/language/return_spec.rb +47 -0
- data/opals/opal/spec/language/string_spec.rb +25 -0
- data/opals/opal/spec/language/super_spec.rb +26 -0
- data/opals/opal/spec/language/until_spec.rb +157 -0
- data/opals/opal/spec/language/while_spec.rb +163 -0
- data/opals/opal/spec/spec_helper.rb +5 -0
- data/opals/runtime/Opalfile +68 -0
- data/opals/runtime/README.md +12 -0
- data/opals/runtime/docs/debugging.md +51 -0
- data/opals/runtime/lib/array.rb +1516 -0
- data/opals/runtime/lib/basic_object.rb +49 -0
- data/opals/runtime/lib/class.rb +54 -0
- data/opals/runtime/lib/dir.rb +36 -0
- data/opals/runtime/lib/error.rb +49 -0
- data/opals/runtime/lib/false_class.rb +52 -0
- data/opals/runtime/lib/file.rb +79 -0
- data/opals/runtime/lib/hash.rb +791 -0
- data/opals/runtime/lib/io.rb +39 -0
- data/opals/runtime/lib/kernel.rb +288 -0
- data/opals/runtime/lib/match_data.rb +36 -0
- data/opals/runtime/lib/module.rb +109 -0
- data/opals/runtime/lib/nil_class.rb +69 -0
- data/opals/runtime/lib/number.rb +398 -0
- data/opals/runtime/lib/proc.rb +77 -0
- data/opals/runtime/lib/range.rb +63 -0
- data/opals/runtime/lib/regexp.rb +111 -0
- data/opals/runtime/lib/ruby.rb +30 -0
- data/opals/runtime/lib/string.rb +328 -0
- data/opals/runtime/lib/symbol.rb +40 -0
- data/opals/runtime/lib/top_self.rb +33 -0
- data/opals/runtime/lib/true_class.rb +45 -0
- data/opals/runtime/runtime/browser.js +287 -0
- data/opals/runtime/runtime/debug.js +182 -0
- data/opals/runtime/runtime/opal.js +1010 -0
- data/opals/runtime/runtime/post_opal.js +1 -0
- data/opals/runtime/runtime/pre_opal.js +2 -0
- data/opals/runtime/runtime/server_side.js +50 -0
- data/opals/spec/LICENSE.txt +26 -0
- data/opals/spec/Opalfile +5 -0
- data/opals/spec/bin/spec.rb +43 -0
- data/opals/spec/lib/spec.rb +33 -0
- data/opals/spec/lib/spec/dsl.rb +41 -0
- data/opals/spec/lib/spec/example.rb +35 -0
- data/opals/spec/lib/spec/example/before_and_after_hooks.rb +81 -0
- data/opals/spec/lib/spec/example/errors.rb +42 -0
- data/opals/spec/lib/spec/example/example_group.rb +37 -0
- data/opals/spec/lib/spec/example/example_group_factory.rb +43 -0
- data/opals/spec/lib/spec/example/example_group_hierarchy.rb +45 -0
- data/opals/spec/lib/spec/example/example_group_methods.rb +142 -0
- data/opals/spec/lib/spec/example/example_group_proxy.rb +41 -0
- data/opals/spec/lib/spec/example/example_methods.rb +73 -0
- data/opals/spec/lib/spec/example/example_proxy.rb +48 -0
- data/opals/spec/lib/spec/expectations.rb +46 -0
- data/opals/spec/lib/spec/expectations/errors.rb +35 -0
- data/opals/spec/lib/spec/expectations/fail_with.rb +37 -0
- data/opals/spec/lib/spec/expectations/handler.rb +48 -0
- data/opals/spec/lib/spec/matchers.rb +50 -0
- data/opals/spec/lib/spec/matchers/be.rb +26 -0
- data/opals/spec/lib/spec/matchers/generated_descriptions.rb +47 -0
- data/opals/spec/lib/spec/matchers/operator_matcher.rb +66 -0
- data/opals/spec/lib/spec/runner.rb +48 -0
- data/opals/spec/lib/spec/runner/example_group_runner.rb +71 -0
- data/opals/spec/lib/spec/runner/formatter/html_formatter.rb +100 -0
- data/opals/spec/lib/spec/runner/formatter/terminal_formatter.rb +82 -0
- data/opals/spec/lib/spec/runner/options.rb +63 -0
- data/opals/spec/lib/spec/runner/reporter.rb +123 -0
- data/opals/spec/resources/index.html +25 -0
- data/opals/spec/resources/spec.css +132 -0
- data/spec/cherry_kit/iseq_spec.rb +38 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/vienna_spec.rb +7 -0
- data/yard/index.html +43 -0
- data/yard/style.css +765 -0
- metadata +312 -49
- data/docs/jarv.rdoc +0 -27
- data/runtime/array.js +0 -153
- data/runtime/class.js +0 -469
- data/runtime/compar.js +0 -73
- data/runtime/dir.js +0 -115
- data/runtime/enum.js +0 -74
- data/runtime/file.js +0 -165
- data/runtime/gem.js +0 -241
- data/runtime/hash.js +0 -181
- data/runtime/load.js +0 -251
- data/runtime/module.js +0 -98
- data/runtime/number.js +0 -148
- data/runtime/object.js +0 -522
- data/runtime/opal.js +0 -200
- data/runtime/parse.js +0 -2218
- data/runtime/range.js +0 -56
- data/runtime/re.js +0 -91
- data/runtime/string.js +0 -199
- data/runtime/variable.js +0 -184
- data/runtime/vm.js +0 -1150
- data/tasks/build.rb +0 -16
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
#
|
|
2
|
+
# request.rb
|
|
3
|
+
# vienna
|
|
4
|
+
#
|
|
5
|
+
# Created by Adam Beynon.
|
|
6
|
+
# Copyright 2010 Adam Beynon.
|
|
7
|
+
#
|
|
8
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
# in the Software without restriction, including without limitation the rights
|
|
11
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
# furnished to do so, subject to the following conditions:
|
|
14
|
+
#
|
|
15
|
+
# The above copyright notice and this permission notice shall be included in
|
|
16
|
+
# all copies or substantial portions of the Software.
|
|
17
|
+
#
|
|
18
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
24
|
+
# THE SOFTWARE.
|
|
25
|
+
#
|
|
26
|
+
|
|
27
|
+
require 'browser/event/trigger_events'
|
|
28
|
+
|
|
29
|
+
# Request class
|
|
30
|
+
#
|
|
31
|
+
# ## Events
|
|
32
|
+
#
|
|
33
|
+
# ### request
|
|
34
|
+
#
|
|
35
|
+
# Triggered when request is initially sent.
|
|
36
|
+
#
|
|
37
|
+
# ### complete
|
|
38
|
+
#
|
|
39
|
+
# Triggered when the request completes. Last callback to be triggered (it is
|
|
40
|
+
# fired after :success/:failure)
|
|
41
|
+
#
|
|
42
|
+
# ### cancel
|
|
43
|
+
#
|
|
44
|
+
# Triggered if request cancels
|
|
45
|
+
#
|
|
46
|
+
# ### success
|
|
47
|
+
#
|
|
48
|
+
# Triggered if the event completes successfully
|
|
49
|
+
#
|
|
50
|
+
# ### failure
|
|
51
|
+
#
|
|
52
|
+
# Triggered if the request failed (got a response, but it was an error code)
|
|
53
|
+
#
|
|
54
|
+
class Request
|
|
55
|
+
|
|
56
|
+
include Event::TriggerEvents
|
|
57
|
+
|
|
58
|
+
OPTIONS = {
|
|
59
|
+
:url => '',
|
|
60
|
+
:data => {},
|
|
61
|
+
# :headers => {
|
|
62
|
+
# 'X-Requested-With' => 'XMLHttpRequest',
|
|
63
|
+
# 'Accept' =>' text/javascript, text/html, application/xml, text/xml, */*'
|
|
64
|
+
# },
|
|
65
|
+
:async => true,
|
|
66
|
+
:format => nil,
|
|
67
|
+
:method => 'POST',
|
|
68
|
+
:link => 'ignore',
|
|
69
|
+
:is_success => nil,
|
|
70
|
+
:emulation => true,
|
|
71
|
+
:url_encoded => true,
|
|
72
|
+
:encoding => 'utf-8',
|
|
73
|
+
:eval_scripts => false,
|
|
74
|
+
:eval_response => false,
|
|
75
|
+
:timeout => 0,
|
|
76
|
+
:no_cache => false
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
# Get the current status of the request
|
|
80
|
+
attr_reader :status
|
|
81
|
+
|
|
82
|
+
attr_reader :text
|
|
83
|
+
|
|
84
|
+
def initialize(options = {})
|
|
85
|
+
`#{self}.__xhr__ = opal.request();`
|
|
86
|
+
@options = OPTIONS.merge options
|
|
87
|
+
@headers = @options[:headers]
|
|
88
|
+
@running = false
|
|
89
|
+
@status = 0
|
|
90
|
+
@text = ""
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# FIXME: Do we want lowercase? good practice to use uppercase?
|
|
94
|
+
%W{get post put delete GET POST PUT DELETE}.each do |method|
|
|
95
|
+
define_method(method) do |data|
|
|
96
|
+
send :data => data, :method => method
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Sends the request with the given data and options. Can also take a block
|
|
101
|
+
# that acts as the on :complete proc callback handler.
|
|
102
|
+
#
|
|
103
|
+
# @example
|
|
104
|
+
# request = Request.new :url => 'clients.html, :method => 'get'
|
|
105
|
+
#
|
|
106
|
+
# @param [Hash] options to set on receiver before sending
|
|
107
|
+
# @return [Request] returns receiver
|
|
108
|
+
def send(options = {}, &block)
|
|
109
|
+
@running = true
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
method = :post
|
|
113
|
+
|
|
114
|
+
url = options[:url] || ""
|
|
115
|
+
|
|
116
|
+
request = self
|
|
117
|
+
`#{self}.__xhr__.onreadystatechange = function() {
|
|
118
|
+
#{request}.$state_change();
|
|
119
|
+
};`
|
|
120
|
+
|
|
121
|
+
`#{self}.__xhr__.open(#{method.to_s}.toUpperCase(), #{url}, true);`
|
|
122
|
+
|
|
123
|
+
trigger :request, self
|
|
124
|
+
|
|
125
|
+
`#{self}.__xhr__.send(null);`
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# Returns +true+ if the +Request+ is running, +false+ otherwise
|
|
129
|
+
#
|
|
130
|
+
# @example
|
|
131
|
+
# req = Request.new
|
|
132
|
+
# req.running? # => false
|
|
133
|
+
# req.send
|
|
134
|
+
# req.running? # => true
|
|
135
|
+
#
|
|
136
|
+
# @return [true, false]
|
|
137
|
+
def running?
|
|
138
|
+
@running
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
# Returns +true+ if the request succeeded, +false+ otherwise
|
|
142
|
+
#
|
|
143
|
+
# @return [true, false]
|
|
144
|
+
def success?
|
|
145
|
+
`return (#{@status} >= 200 && #{@status} < 300) ? #{true} : #{false};`
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# Returns +true+ if the request failed, +false+ otherwise
|
|
149
|
+
#
|
|
150
|
+
# @return [true, false]
|
|
151
|
+
def failed?
|
|
152
|
+
!success?
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def state_change
|
|
156
|
+
# only handle state change when request is done (state 4)
|
|
157
|
+
`if (#{self}.__xhr__.readyState !== 4 || !#{@running}.r) return;`
|
|
158
|
+
|
|
159
|
+
`#{self}.__xhr__.onreadystatechange = function() { };`
|
|
160
|
+
|
|
161
|
+
@running = false
|
|
162
|
+
@status = 0
|
|
163
|
+
|
|
164
|
+
begin
|
|
165
|
+
@status = `#{self}.__xhr__.status`
|
|
166
|
+
rescue Exception => e
|
|
167
|
+
# warning?
|
|
168
|
+
puts "warning"
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
puts "our status is now #{@status}"
|
|
172
|
+
|
|
173
|
+
# should be:
|
|
174
|
+
# @status = `#{@xhr}.status` rescue nil
|
|
175
|
+
|
|
176
|
+
if success?
|
|
177
|
+
# puts "success #{@status}"
|
|
178
|
+
@text = `#{self}.__xhr__.responseText || ''`
|
|
179
|
+
|
|
180
|
+
trigger :success, self
|
|
181
|
+
trigger :complete, self
|
|
182
|
+
else
|
|
183
|
+
`console.log(#{@status});`
|
|
184
|
+
puts "aww :( #{@status}"
|
|
185
|
+
|
|
186
|
+
trigger :failure, self
|
|
187
|
+
trigger :complete, self
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
def cancel
|
|
192
|
+
return self unless @running
|
|
193
|
+
@running = false
|
|
194
|
+
`#{self}.__xhr__.abort();`
|
|
195
|
+
`#{self}.__xhr__.onreadystatechange = function() {};`
|
|
196
|
+
`#{self}.__xhr__ = opal.request();`
|
|
197
|
+
trigger :cancel
|
|
198
|
+
self
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
end
|
|
@@ -0,0 +1,1068 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Sizzle CSS Selector Engine - v1.0
|
|
3
|
+
* Copyright 2009, The Dojo Foundation
|
|
4
|
+
* Released under the MIT, BSD, and GPL Licenses.
|
|
5
|
+
* More information: http://sizzlejs.com/
|
|
6
|
+
*/
|
|
7
|
+
(function(){
|
|
8
|
+
|
|
9
|
+
var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
|
|
10
|
+
done = 0,
|
|
11
|
+
toString = Object.prototype.toString,
|
|
12
|
+
hasDuplicate = false,
|
|
13
|
+
baseHasDuplicate = true;
|
|
14
|
+
|
|
15
|
+
// Here we check if the JavaScript engine is using some sort of
|
|
16
|
+
// optimization where it does not always call our comparision
|
|
17
|
+
// function. If that is the case, discard the hasDuplicate value.
|
|
18
|
+
// Thus far that includes Google Chrome.
|
|
19
|
+
[0, 0].sort(function(){
|
|
20
|
+
baseHasDuplicate = false;
|
|
21
|
+
return 0;
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
var Sizzle = function(selector, context, results, seed) {
|
|
25
|
+
results = results || [];
|
|
26
|
+
context = context || document;
|
|
27
|
+
|
|
28
|
+
var origContext = context;
|
|
29
|
+
|
|
30
|
+
if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if ( !selector || typeof selector !== "string" ) {
|
|
35
|
+
return results;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
var parts = [], m, set, checkSet, extra, prune = true, contextXML = isXML(context),
|
|
39
|
+
soFar = selector, ret, cur, pop, i;
|
|
40
|
+
|
|
41
|
+
// Reset the position of the chunker regexp (start from head)
|
|
42
|
+
do {
|
|
43
|
+
chunker.exec("");
|
|
44
|
+
m = chunker.exec(soFar);
|
|
45
|
+
|
|
46
|
+
if ( m ) {
|
|
47
|
+
soFar = m[3];
|
|
48
|
+
|
|
49
|
+
parts.push( m[1] );
|
|
50
|
+
|
|
51
|
+
if ( m[2] ) {
|
|
52
|
+
extra = m[3];
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
} while ( m );
|
|
57
|
+
|
|
58
|
+
if ( parts.length > 1 && origPOS.exec( selector ) ) {
|
|
59
|
+
if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
|
|
60
|
+
set = posProcess( parts[0] + parts[1], context );
|
|
61
|
+
} else {
|
|
62
|
+
set = Expr.relative[ parts[0] ] ?
|
|
63
|
+
[ context ] :
|
|
64
|
+
Sizzle( parts.shift(), context );
|
|
65
|
+
|
|
66
|
+
while ( parts.length ) {
|
|
67
|
+
selector = parts.shift();
|
|
68
|
+
|
|
69
|
+
if ( Expr.relative[ selector ] ) {
|
|
70
|
+
selector += parts.shift();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
set = posProcess( selector, set );
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
// Take a shortcut and set the context if the root selector is an ID
|
|
78
|
+
// (but not if it'll be faster if the inner selector is an ID)
|
|
79
|
+
if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
|
|
80
|
+
Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
|
|
81
|
+
ret = Sizzle.find( parts.shift(), context, contextXML );
|
|
82
|
+
context = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if ( context ) {
|
|
86
|
+
ret = seed ?
|
|
87
|
+
{ expr: parts.pop(), set: makeArray(seed) } :
|
|
88
|
+
Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
|
|
89
|
+
set = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : ret.set;
|
|
90
|
+
|
|
91
|
+
if ( parts.length > 0 ) {
|
|
92
|
+
checkSet = makeArray(set);
|
|
93
|
+
} else {
|
|
94
|
+
prune = false;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
while ( parts.length ) {
|
|
98
|
+
cur = parts.pop();
|
|
99
|
+
pop = cur;
|
|
100
|
+
|
|
101
|
+
if ( !Expr.relative[ cur ] ) {
|
|
102
|
+
cur = "";
|
|
103
|
+
} else {
|
|
104
|
+
pop = parts.pop();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if ( pop == null ) {
|
|
108
|
+
pop = context;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
Expr.relative[ cur ]( checkSet, pop, contextXML );
|
|
112
|
+
}
|
|
113
|
+
} else {
|
|
114
|
+
checkSet = parts = [];
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if ( !checkSet ) {
|
|
119
|
+
checkSet = set;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if ( !checkSet ) {
|
|
123
|
+
Sizzle.error( cur || selector );
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if ( toString.call(checkSet) === "[object Array]" ) {
|
|
127
|
+
if ( !prune ) {
|
|
128
|
+
results.push.apply( results, checkSet );
|
|
129
|
+
} else if ( context && context.nodeType === 1 ) {
|
|
130
|
+
for ( i = 0; checkSet[i] != null; i++ ) {
|
|
131
|
+
if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) {
|
|
132
|
+
results.push( set[i] );
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
} else {
|
|
136
|
+
for ( i = 0; checkSet[i] != null; i++ ) {
|
|
137
|
+
if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
|
|
138
|
+
results.push( set[i] );
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
} else {
|
|
143
|
+
makeArray( checkSet, results );
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if ( extra ) {
|
|
147
|
+
Sizzle( extra, origContext, results, seed );
|
|
148
|
+
Sizzle.uniqueSort( results );
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return results;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
Sizzle.uniqueSort = function(results){
|
|
155
|
+
if ( sortOrder ) {
|
|
156
|
+
hasDuplicate = baseHasDuplicate;
|
|
157
|
+
results.sort(sortOrder);
|
|
158
|
+
|
|
159
|
+
if ( hasDuplicate ) {
|
|
160
|
+
for ( var i = 1; i < results.length; i++ ) {
|
|
161
|
+
if ( results[i] === results[i-1] ) {
|
|
162
|
+
results.splice(i--, 1);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return results;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
Sizzle.matches = function(expr, set){
|
|
172
|
+
return Sizzle(expr, null, null, set);
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
Sizzle.find = function(expr, context, isXML){
|
|
176
|
+
var set;
|
|
177
|
+
|
|
178
|
+
if ( !expr ) {
|
|
179
|
+
return [];
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
|
|
183
|
+
var type = Expr.order[i], match;
|
|
184
|
+
|
|
185
|
+
if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
|
|
186
|
+
var left = match[1];
|
|
187
|
+
match.splice(1,1);
|
|
188
|
+
|
|
189
|
+
if ( left.substr( left.length - 1 ) !== "\\" ) {
|
|
190
|
+
match[1] = (match[1] || "").replace(/\\/g, "");
|
|
191
|
+
set = Expr.find[ type ]( match, context, isXML );
|
|
192
|
+
if ( set != null ) {
|
|
193
|
+
expr = expr.replace( Expr.match[ type ], "" );
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if ( !set ) {
|
|
201
|
+
set = context.getElementsByTagName("*");
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return {set: set, expr: expr};
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
Sizzle.filter = function(expr, set, inplace, not){
|
|
208
|
+
var old = expr, result = [], curLoop = set, match, anyFound,
|
|
209
|
+
isXMLFilter = set && set[0] && isXML(set[0]);
|
|
210
|
+
|
|
211
|
+
while ( expr && set.length ) {
|
|
212
|
+
for ( var type in Expr.filter ) {
|
|
213
|
+
if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
|
|
214
|
+
var filter = Expr.filter[ type ], found, item, left = match[1];
|
|
215
|
+
anyFound = false;
|
|
216
|
+
|
|
217
|
+
match.splice(1,1);
|
|
218
|
+
|
|
219
|
+
if ( left.substr( left.length - 1 ) === "\\" ) {
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if ( curLoop === result ) {
|
|
224
|
+
result = [];
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if ( Expr.preFilter[ type ] ) {
|
|
228
|
+
match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
|
|
229
|
+
|
|
230
|
+
if ( !match ) {
|
|
231
|
+
anyFound = found = true;
|
|
232
|
+
} else if ( match === true ) {
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if ( match ) {
|
|
238
|
+
for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
|
|
239
|
+
if ( item ) {
|
|
240
|
+
found = filter( item, match, i, curLoop );
|
|
241
|
+
var pass = not ^ !!found;
|
|
242
|
+
|
|
243
|
+
if ( inplace && found != null ) {
|
|
244
|
+
if ( pass ) {
|
|
245
|
+
anyFound = true;
|
|
246
|
+
} else {
|
|
247
|
+
curLoop[i] = false;
|
|
248
|
+
}
|
|
249
|
+
} else if ( pass ) {
|
|
250
|
+
result.push( item );
|
|
251
|
+
anyFound = true;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if ( found !== undefined ) {
|
|
258
|
+
if ( !inplace ) {
|
|
259
|
+
curLoop = result;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
expr = expr.replace( Expr.match[ type ], "" );
|
|
263
|
+
|
|
264
|
+
if ( !anyFound ) {
|
|
265
|
+
return [];
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// Improper expression
|
|
274
|
+
if ( expr === old ) {
|
|
275
|
+
if ( anyFound == null ) {
|
|
276
|
+
Sizzle.error( expr );
|
|
277
|
+
} else {
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
old = expr;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
return curLoop;
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
Sizzle.error = function( msg ) {
|
|
289
|
+
throw "Syntax error, unrecognized expression: " + msg;
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
var Expr = Sizzle.selectors = {
|
|
293
|
+
order: [ "ID", "NAME", "TAG" ],
|
|
294
|
+
match: {
|
|
295
|
+
ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
|
|
296
|
+
CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
|
|
297
|
+
NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
|
|
298
|
+
ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,
|
|
299
|
+
TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
|
|
300
|
+
CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+\-]*)\))?/,
|
|
301
|
+
POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
|
|
302
|
+
PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
|
|
303
|
+
},
|
|
304
|
+
leftMatch: {},
|
|
305
|
+
attrMap: {
|
|
306
|
+
"class": "className",
|
|
307
|
+
"for": "htmlFor"
|
|
308
|
+
},
|
|
309
|
+
attrHandle: {
|
|
310
|
+
href: function(elem){
|
|
311
|
+
return elem.getAttribute("href");
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
relative: {
|
|
315
|
+
"+": function(checkSet, part){
|
|
316
|
+
var isPartStr = typeof part === "string",
|
|
317
|
+
isTag = isPartStr && !/\W/.test(part),
|
|
318
|
+
isPartStrNotTag = isPartStr && !isTag;
|
|
319
|
+
|
|
320
|
+
if ( isTag ) {
|
|
321
|
+
part = part.toLowerCase();
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
|
|
325
|
+
if ( (elem = checkSet[i]) ) {
|
|
326
|
+
while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
|
|
327
|
+
|
|
328
|
+
checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
|
|
329
|
+
elem || false :
|
|
330
|
+
elem === part;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
if ( isPartStrNotTag ) {
|
|
335
|
+
Sizzle.filter( part, checkSet, true );
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
">": function(checkSet, part){
|
|
339
|
+
var isPartStr = typeof part === "string",
|
|
340
|
+
elem, i = 0, l = checkSet.length;
|
|
341
|
+
|
|
342
|
+
if ( isPartStr && !/\W/.test(part) ) {
|
|
343
|
+
part = part.toLowerCase();
|
|
344
|
+
|
|
345
|
+
for ( ; i < l; i++ ) {
|
|
346
|
+
elem = checkSet[i];
|
|
347
|
+
if ( elem ) {
|
|
348
|
+
var parent = elem.parentNode;
|
|
349
|
+
checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
} else {
|
|
353
|
+
for ( ; i < l; i++ ) {
|
|
354
|
+
elem = checkSet[i];
|
|
355
|
+
if ( elem ) {
|
|
356
|
+
checkSet[i] = isPartStr ?
|
|
357
|
+
elem.parentNode :
|
|
358
|
+
elem.parentNode === part;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
if ( isPartStr ) {
|
|
363
|
+
Sizzle.filter( part, checkSet, true );
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
},
|
|
367
|
+
"": function(checkSet, part, isXML){
|
|
368
|
+
var doneName = done++, checkFn = dirCheck, nodeCheck;
|
|
369
|
+
|
|
370
|
+
if ( typeof part === "string" && !/\W/.test(part) ) {
|
|
371
|
+
part = part.toLowerCase();
|
|
372
|
+
nodeCheck = part;
|
|
373
|
+
checkFn = dirNodeCheck;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML);
|
|
377
|
+
},
|
|
378
|
+
"~": function(checkSet, part, isXML){
|
|
379
|
+
var doneName = done++, checkFn = dirCheck, nodeCheck;
|
|
380
|
+
|
|
381
|
+
if ( typeof part === "string" && !/\W/.test(part) ) {
|
|
382
|
+
part = part.toLowerCase();
|
|
383
|
+
nodeCheck = part;
|
|
384
|
+
checkFn = dirNodeCheck;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML);
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
find: {
|
|
391
|
+
ID: function(match, context, isXML){
|
|
392
|
+
if ( typeof context.getElementById !== "undefined" && !isXML ) {
|
|
393
|
+
var m = context.getElementById(match[1]);
|
|
394
|
+
return m ? [m] : [];
|
|
395
|
+
}
|
|
396
|
+
},
|
|
397
|
+
NAME: function(match, context){
|
|
398
|
+
if ( typeof context.getElementsByName !== "undefined" ) {
|
|
399
|
+
var ret = [], results = context.getElementsByName(match[1]);
|
|
400
|
+
|
|
401
|
+
for ( var i = 0, l = results.length; i < l; i++ ) {
|
|
402
|
+
if ( results[i].getAttribute("name") === match[1] ) {
|
|
403
|
+
ret.push( results[i] );
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
return ret.length === 0 ? null : ret;
|
|
408
|
+
}
|
|
409
|
+
},
|
|
410
|
+
TAG: function(match, context){
|
|
411
|
+
return context.getElementsByTagName(match[1]);
|
|
412
|
+
}
|
|
413
|
+
},
|
|
414
|
+
preFilter: {
|
|
415
|
+
CLASS: function(match, curLoop, inplace, result, not, isXML){
|
|
416
|
+
match = " " + match[1].replace(/\\/g, "") + " ";
|
|
417
|
+
|
|
418
|
+
if ( isXML ) {
|
|
419
|
+
return match;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
|
|
423
|
+
if ( elem ) {
|
|
424
|
+
if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n]/g, " ").indexOf(match) >= 0) ) {
|
|
425
|
+
if ( !inplace ) {
|
|
426
|
+
result.push( elem );
|
|
427
|
+
}
|
|
428
|
+
} else if ( inplace ) {
|
|
429
|
+
curLoop[i] = false;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
return false;
|
|
435
|
+
},
|
|
436
|
+
ID: function(match){
|
|
437
|
+
return match[1].replace(/\\/g, "");
|
|
438
|
+
},
|
|
439
|
+
TAG: function(match, curLoop){
|
|
440
|
+
return match[1].toLowerCase();
|
|
441
|
+
},
|
|
442
|
+
CHILD: function(match){
|
|
443
|
+
if ( match[1] === "nth" ) {
|
|
444
|
+
// parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
|
|
445
|
+
var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
|
|
446
|
+
match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
|
|
447
|
+
!/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
|
|
448
|
+
|
|
449
|
+
// calculate the numbers (first)n+(last) including if they are negative
|
|
450
|
+
match[2] = (test[1] + (test[2] || 1)) - 0;
|
|
451
|
+
match[3] = test[3] - 0;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// TODO: Move to normal caching system
|
|
455
|
+
match[0] = done++;
|
|
456
|
+
|
|
457
|
+
return match;
|
|
458
|
+
},
|
|
459
|
+
ATTR: function(match, curLoop, inplace, result, not, isXML){
|
|
460
|
+
var name = match[1].replace(/\\/g, "");
|
|
461
|
+
|
|
462
|
+
if ( !isXML && Expr.attrMap[name] ) {
|
|
463
|
+
match[1] = Expr.attrMap[name];
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
if ( match[2] === "~=" ) {
|
|
467
|
+
match[4] = " " + match[4] + " ";
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
return match;
|
|
471
|
+
},
|
|
472
|
+
PSEUDO: function(match, curLoop, inplace, result, not){
|
|
473
|
+
if ( match[1] === "not" ) {
|
|
474
|
+
// If we're dealing with a complex expression, or a simple one
|
|
475
|
+
if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
|
|
476
|
+
match[3] = Sizzle(match[3], null, null, curLoop);
|
|
477
|
+
} else {
|
|
478
|
+
var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
|
|
479
|
+
if ( !inplace ) {
|
|
480
|
+
result.push.apply( result, ret );
|
|
481
|
+
}
|
|
482
|
+
return false;
|
|
483
|
+
}
|
|
484
|
+
} else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
|
|
485
|
+
return true;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
return match;
|
|
489
|
+
},
|
|
490
|
+
POS: function(match){
|
|
491
|
+
match.unshift( true );
|
|
492
|
+
return match;
|
|
493
|
+
}
|
|
494
|
+
},
|
|
495
|
+
filters: {
|
|
496
|
+
enabled: function(elem){
|
|
497
|
+
return elem.disabled === false && elem.type !== "hidden";
|
|
498
|
+
},
|
|
499
|
+
disabled: function(elem){
|
|
500
|
+
return elem.disabled === true;
|
|
501
|
+
},
|
|
502
|
+
checked: function(elem){
|
|
503
|
+
return elem.checked === true;
|
|
504
|
+
},
|
|
505
|
+
selected: function(elem){
|
|
506
|
+
// Accessing this property makes selected-by-default
|
|
507
|
+
// options in Safari work properly
|
|
508
|
+
elem.parentNode.selectedIndex;
|
|
509
|
+
return elem.selected === true;
|
|
510
|
+
},
|
|
511
|
+
parent: function(elem){
|
|
512
|
+
return !!elem.firstChild;
|
|
513
|
+
},
|
|
514
|
+
empty: function(elem){
|
|
515
|
+
return !elem.firstChild;
|
|
516
|
+
},
|
|
517
|
+
has: function(elem, i, match){
|
|
518
|
+
return !!Sizzle( match[3], elem ).length;
|
|
519
|
+
},
|
|
520
|
+
header: function(elem){
|
|
521
|
+
return (/h\d/i).test( elem.nodeName );
|
|
522
|
+
},
|
|
523
|
+
text: function(elem){
|
|
524
|
+
return "text" === elem.type;
|
|
525
|
+
},
|
|
526
|
+
radio: function(elem){
|
|
527
|
+
return "radio" === elem.type;
|
|
528
|
+
},
|
|
529
|
+
checkbox: function(elem){
|
|
530
|
+
return "checkbox" === elem.type;
|
|
531
|
+
},
|
|
532
|
+
file: function(elem){
|
|
533
|
+
return "file" === elem.type;
|
|
534
|
+
},
|
|
535
|
+
password: function(elem){
|
|
536
|
+
return "password" === elem.type;
|
|
537
|
+
},
|
|
538
|
+
submit: function(elem){
|
|
539
|
+
return "submit" === elem.type;
|
|
540
|
+
},
|
|
541
|
+
image: function(elem){
|
|
542
|
+
return "image" === elem.type;
|
|
543
|
+
},
|
|
544
|
+
reset: function(elem){
|
|
545
|
+
return "reset" === elem.type;
|
|
546
|
+
},
|
|
547
|
+
button: function(elem){
|
|
548
|
+
return "button" === elem.type || elem.nodeName.toLowerCase() === "button";
|
|
549
|
+
},
|
|
550
|
+
input: function(elem){
|
|
551
|
+
return (/input|select|textarea|button/i).test(elem.nodeName);
|
|
552
|
+
}
|
|
553
|
+
},
|
|
554
|
+
setFilters: {
|
|
555
|
+
first: function(elem, i){
|
|
556
|
+
return i === 0;
|
|
557
|
+
},
|
|
558
|
+
last: function(elem, i, match, array){
|
|
559
|
+
return i === array.length - 1;
|
|
560
|
+
},
|
|
561
|
+
even: function(elem, i){
|
|
562
|
+
return i % 2 === 0;
|
|
563
|
+
},
|
|
564
|
+
odd: function(elem, i){
|
|
565
|
+
return i % 2 === 1;
|
|
566
|
+
},
|
|
567
|
+
lt: function(elem, i, match){
|
|
568
|
+
return i < match[3] - 0;
|
|
569
|
+
},
|
|
570
|
+
gt: function(elem, i, match){
|
|
571
|
+
return i > match[3] - 0;
|
|
572
|
+
},
|
|
573
|
+
nth: function(elem, i, match){
|
|
574
|
+
return match[3] - 0 === i;
|
|
575
|
+
},
|
|
576
|
+
eq: function(elem, i, match){
|
|
577
|
+
return match[3] - 0 === i;
|
|
578
|
+
}
|
|
579
|
+
},
|
|
580
|
+
filter: {
|
|
581
|
+
PSEUDO: function(elem, match, i, array){
|
|
582
|
+
var name = match[1], filter = Expr.filters[ name ];
|
|
583
|
+
|
|
584
|
+
if ( filter ) {
|
|
585
|
+
return filter( elem, i, match, array );
|
|
586
|
+
} else if ( name === "contains" ) {
|
|
587
|
+
return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0;
|
|
588
|
+
} else if ( name === "not" ) {
|
|
589
|
+
var not = match[3];
|
|
590
|
+
|
|
591
|
+
for ( var j = 0, l = not.length; j < l; j++ ) {
|
|
592
|
+
if ( not[j] === elem ) {
|
|
593
|
+
return false;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
return true;
|
|
598
|
+
} else {
|
|
599
|
+
Sizzle.error( "Syntax error, unrecognized expression: " + name );
|
|
600
|
+
}
|
|
601
|
+
},
|
|
602
|
+
CHILD: function(elem, match){
|
|
603
|
+
var type = match[1], node = elem;
|
|
604
|
+
switch (type) {
|
|
605
|
+
case 'only':
|
|
606
|
+
case 'first':
|
|
607
|
+
while ( (node = node.previousSibling) ) {
|
|
608
|
+
if ( node.nodeType === 1 ) {
|
|
609
|
+
return false;
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
if ( type === "first" ) {
|
|
613
|
+
return true;
|
|
614
|
+
}
|
|
615
|
+
node = elem;
|
|
616
|
+
case 'last':
|
|
617
|
+
while ( (node = node.nextSibling) ) {
|
|
618
|
+
if ( node.nodeType === 1 ) {
|
|
619
|
+
return false;
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
return true;
|
|
623
|
+
case 'nth':
|
|
624
|
+
var first = match[2], last = match[3];
|
|
625
|
+
|
|
626
|
+
if ( first === 1 && last === 0 ) {
|
|
627
|
+
return true;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
var doneName = match[0],
|
|
631
|
+
parent = elem.parentNode;
|
|
632
|
+
|
|
633
|
+
if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
|
|
634
|
+
var count = 0;
|
|
635
|
+
for ( node = parent.firstChild; node; node = node.nextSibling ) {
|
|
636
|
+
if ( node.nodeType === 1 ) {
|
|
637
|
+
node.nodeIndex = ++count;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
parent.sizcache = doneName;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
var diff = elem.nodeIndex - last;
|
|
644
|
+
if ( first === 0 ) {
|
|
645
|
+
return diff === 0;
|
|
646
|
+
} else {
|
|
647
|
+
return ( diff % first === 0 && diff / first >= 0 );
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
},
|
|
651
|
+
ID: function(elem, match){
|
|
652
|
+
return elem.nodeType === 1 && elem.getAttribute("id") === match;
|
|
653
|
+
},
|
|
654
|
+
TAG: function(elem, match){
|
|
655
|
+
return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
|
|
656
|
+
},
|
|
657
|
+
CLASS: function(elem, match){
|
|
658
|
+
return (" " + (elem.className || elem.getAttribute("class")) + " ")
|
|
659
|
+
.indexOf( match ) > -1;
|
|
660
|
+
},
|
|
661
|
+
ATTR: function(elem, match){
|
|
662
|
+
var name = match[1],
|
|
663
|
+
result = Expr.attrHandle[ name ] ?
|
|
664
|
+
Expr.attrHandle[ name ]( elem ) :
|
|
665
|
+
elem[ name ] != null ?
|
|
666
|
+
elem[ name ] :
|
|
667
|
+
elem.getAttribute( name ),
|
|
668
|
+
value = result + "",
|
|
669
|
+
type = match[2],
|
|
670
|
+
check = match[4];
|
|
671
|
+
|
|
672
|
+
return result == null ?
|
|
673
|
+
type === "!=" :
|
|
674
|
+
type === "=" ?
|
|
675
|
+
value === check :
|
|
676
|
+
type === "*=" ?
|
|
677
|
+
value.indexOf(check) >= 0 :
|
|
678
|
+
type === "~=" ?
|
|
679
|
+
(" " + value + " ").indexOf(check) >= 0 :
|
|
680
|
+
!check ?
|
|
681
|
+
value && result !== false :
|
|
682
|
+
type === "!=" ?
|
|
683
|
+
value !== check :
|
|
684
|
+
type === "^=" ?
|
|
685
|
+
value.indexOf(check) === 0 :
|
|
686
|
+
type === "$=" ?
|
|
687
|
+
value.substr(value.length - check.length) === check :
|
|
688
|
+
type === "|=" ?
|
|
689
|
+
value === check || value.substr(0, check.length + 1) === check + "-" :
|
|
690
|
+
false;
|
|
691
|
+
},
|
|
692
|
+
POS: function(elem, match, i, array){
|
|
693
|
+
var name = match[2], filter = Expr.setFilters[ name ];
|
|
694
|
+
|
|
695
|
+
if ( filter ) {
|
|
696
|
+
return filter( elem, i, match, array );
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
};
|
|
701
|
+
|
|
702
|
+
var origPOS = Expr.match.POS,
|
|
703
|
+
fescape = function(all, num){
|
|
704
|
+
return "\\" + (num - 0 + 1);
|
|
705
|
+
};
|
|
706
|
+
|
|
707
|
+
for ( var type in Expr.match ) {
|
|
708
|
+
Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
|
|
709
|
+
Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
var makeArray = function(array, results) {
|
|
713
|
+
array = Array.prototype.slice.call( array, 0 );
|
|
714
|
+
|
|
715
|
+
if ( results ) {
|
|
716
|
+
results.push.apply( results, array );
|
|
717
|
+
return results;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
return array;
|
|
721
|
+
};
|
|
722
|
+
|
|
723
|
+
// Perform a simple check to determine if the browser is capable of
|
|
724
|
+
// converting a NodeList to an array using builtin methods.
|
|
725
|
+
// Also verifies that the returned array holds DOM nodes
|
|
726
|
+
// (which is not the case in the Blackberry browser)
|
|
727
|
+
try {
|
|
728
|
+
Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
|
|
729
|
+
|
|
730
|
+
// Provide a fallback method if it does not work
|
|
731
|
+
} catch(e){
|
|
732
|
+
makeArray = function(array, results) {
|
|
733
|
+
var ret = results || [], i = 0;
|
|
734
|
+
|
|
735
|
+
if ( toString.call(array) === "[object Array]" ) {
|
|
736
|
+
Array.prototype.push.apply( ret, array );
|
|
737
|
+
} else {
|
|
738
|
+
if ( typeof array.length === "number" ) {
|
|
739
|
+
for ( var l = array.length; i < l; i++ ) {
|
|
740
|
+
ret.push( array[i] );
|
|
741
|
+
}
|
|
742
|
+
} else {
|
|
743
|
+
for ( ; array[i]; i++ ) {
|
|
744
|
+
ret.push( array[i] );
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
return ret;
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
var sortOrder;
|
|
754
|
+
|
|
755
|
+
if ( document.documentElement.compareDocumentPosition ) {
|
|
756
|
+
sortOrder = function( a, b ) {
|
|
757
|
+
if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
|
|
758
|
+
if ( a == b ) {
|
|
759
|
+
hasDuplicate = true;
|
|
760
|
+
}
|
|
761
|
+
return a.compareDocumentPosition ? -1 : 1;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1;
|
|
765
|
+
if ( ret === 0 ) {
|
|
766
|
+
hasDuplicate = true;
|
|
767
|
+
}
|
|
768
|
+
return ret;
|
|
769
|
+
};
|
|
770
|
+
} else if ( "sourceIndex" in document.documentElement ) {
|
|
771
|
+
sortOrder = function( a, b ) {
|
|
772
|
+
if ( !a.sourceIndex || !b.sourceIndex ) {
|
|
773
|
+
if ( a == b ) {
|
|
774
|
+
hasDuplicate = true;
|
|
775
|
+
}
|
|
776
|
+
return a.sourceIndex ? -1 : 1;
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
var ret = a.sourceIndex - b.sourceIndex;
|
|
780
|
+
if ( ret === 0 ) {
|
|
781
|
+
hasDuplicate = true;
|
|
782
|
+
}
|
|
783
|
+
return ret;
|
|
784
|
+
};
|
|
785
|
+
} else if ( document.createRange ) {
|
|
786
|
+
sortOrder = function( a, b ) {
|
|
787
|
+
if ( !a.ownerDocument || !b.ownerDocument ) {
|
|
788
|
+
if ( a == b ) {
|
|
789
|
+
hasDuplicate = true;
|
|
790
|
+
}
|
|
791
|
+
return a.ownerDocument ? -1 : 1;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange();
|
|
795
|
+
aRange.setStart(a, 0);
|
|
796
|
+
aRange.setEnd(a, 0);
|
|
797
|
+
bRange.setStart(b, 0);
|
|
798
|
+
bRange.setEnd(b, 0);
|
|
799
|
+
var ret = aRange.compareBoundaryPoints(Range.START_TO_END, bRange);
|
|
800
|
+
if ( ret === 0 ) {
|
|
801
|
+
hasDuplicate = true;
|
|
802
|
+
}
|
|
803
|
+
return ret;
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
// Utility function for retreiving the text value of an array of DOM nodes
|
|
808
|
+
function getText( elems ) {
|
|
809
|
+
var ret = "", elem;
|
|
810
|
+
|
|
811
|
+
for ( var i = 0; elems[i]; i++ ) {
|
|
812
|
+
elem = elems[i];
|
|
813
|
+
|
|
814
|
+
// Get the text from text nodes and CDATA nodes
|
|
815
|
+
if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
|
|
816
|
+
ret += elem.nodeValue;
|
|
817
|
+
|
|
818
|
+
// Traverse everything else, except comment nodes
|
|
819
|
+
} else if ( elem.nodeType !== 8 ) {
|
|
820
|
+
ret += getText( elem.childNodes );
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
return ret;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
// Check to see if the browser returns elements by name when
|
|
828
|
+
// querying by getElementById (and provide a workaround)
|
|
829
|
+
(function(){
|
|
830
|
+
// We're going to inject a fake input element with a specified name
|
|
831
|
+
var form = document.createElement("div"),
|
|
832
|
+
id = "script" + (new Date()).getTime();
|
|
833
|
+
form.innerHTML = "<a name='" + id + "'/>";
|
|
834
|
+
|
|
835
|
+
// Inject it into the root element, check its status, and remove it quickly
|
|
836
|
+
var root = document.documentElement;
|
|
837
|
+
root.insertBefore( form, root.firstChild );
|
|
838
|
+
|
|
839
|
+
// The workaround has to do additional checks after a getElementById
|
|
840
|
+
// Which slows things down for other browsers (hence the branching)
|
|
841
|
+
if ( document.getElementById( id ) ) {
|
|
842
|
+
Expr.find.ID = function(match, context, isXML){
|
|
843
|
+
if ( typeof context.getElementById !== "undefined" && !isXML ) {
|
|
844
|
+
var m = context.getElementById(match[1]);
|
|
845
|
+
return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : [];
|
|
846
|
+
}
|
|
847
|
+
};
|
|
848
|
+
|
|
849
|
+
Expr.filter.ID = function(elem, match){
|
|
850
|
+
var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
|
|
851
|
+
return elem.nodeType === 1 && node && node.nodeValue === match;
|
|
852
|
+
};
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
root.removeChild( form );
|
|
856
|
+
root = form = null; // release memory in IE
|
|
857
|
+
})();
|
|
858
|
+
|
|
859
|
+
(function(){
|
|
860
|
+
// Check to see if the browser returns only elements
|
|
861
|
+
// when doing getElementsByTagName("*")
|
|
862
|
+
|
|
863
|
+
// Create a fake element
|
|
864
|
+
var div = document.createElement("div");
|
|
865
|
+
div.appendChild( document.createComment("") );
|
|
866
|
+
|
|
867
|
+
// Make sure no comments are found
|
|
868
|
+
if ( div.getElementsByTagName("*").length > 0 ) {
|
|
869
|
+
Expr.find.TAG = function(match, context){
|
|
870
|
+
var results = context.getElementsByTagName(match[1]);
|
|
871
|
+
|
|
872
|
+
// Filter out possible comments
|
|
873
|
+
if ( match[1] === "*" ) {
|
|
874
|
+
var tmp = [];
|
|
875
|
+
|
|
876
|
+
for ( var i = 0; results[i]; i++ ) {
|
|
877
|
+
if ( results[i].nodeType === 1 ) {
|
|
878
|
+
tmp.push( results[i] );
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
results = tmp;
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
return results;
|
|
886
|
+
};
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
// Check to see if an attribute returns normalized href attributes
|
|
890
|
+
div.innerHTML = "<a href='#'></a>";
|
|
891
|
+
if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
|
|
892
|
+
div.firstChild.getAttribute("href") !== "#" ) {
|
|
893
|
+
Expr.attrHandle.href = function(elem){
|
|
894
|
+
return elem.getAttribute("href", 2);
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
div = null; // release memory in IE
|
|
899
|
+
})();
|
|
900
|
+
|
|
901
|
+
if ( document.querySelectorAll ) {
|
|
902
|
+
(function(){
|
|
903
|
+
var oldSizzle = Sizzle, div = document.createElement("div");
|
|
904
|
+
div.innerHTML = "<p class='TEST'></p>";
|
|
905
|
+
|
|
906
|
+
// Safari can't handle uppercase or unicode characters when
|
|
907
|
+
// in quirks mode.
|
|
908
|
+
if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
|
|
909
|
+
return;
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
Sizzle = function(query, context, extra, seed){
|
|
913
|
+
context = context || document;
|
|
914
|
+
|
|
915
|
+
// Only use querySelectorAll on non-XML documents
|
|
916
|
+
// (ID selectors don't work in non-HTML documents)
|
|
917
|
+
if ( !seed && context.nodeType === 9 && !isXML(context) ) {
|
|
918
|
+
try {
|
|
919
|
+
return makeArray( context.querySelectorAll(query), extra );
|
|
920
|
+
} catch(e){}
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
return oldSizzle(query, context, extra, seed);
|
|
924
|
+
};
|
|
925
|
+
|
|
926
|
+
for ( var prop in oldSizzle ) {
|
|
927
|
+
Sizzle[ prop ] = oldSizzle[ prop ];
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
div = null; // release memory in IE
|
|
931
|
+
})();
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
(function(){
|
|
935
|
+
var div = document.createElement("div");
|
|
936
|
+
|
|
937
|
+
div.innerHTML = "<div class='test e'></div><div class='test'></div>";
|
|
938
|
+
|
|
939
|
+
// Opera can't find a second classname (in 9.6)
|
|
940
|
+
// Also, make sure that getElementsByClassName actually exists
|
|
941
|
+
if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
|
|
942
|
+
return;
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
// Safari caches class attributes, doesn't catch changes (in 3.2)
|
|
946
|
+
div.lastChild.className = "e";
|
|
947
|
+
|
|
948
|
+
if ( div.getElementsByClassName("e").length === 1 ) {
|
|
949
|
+
return;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
Expr.order.splice(1, 0, "CLASS");
|
|
953
|
+
Expr.find.CLASS = function(match, context, isXML) {
|
|
954
|
+
if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
|
|
955
|
+
return context.getElementsByClassName(match[1]);
|
|
956
|
+
}
|
|
957
|
+
};
|
|
958
|
+
|
|
959
|
+
div = null; // release memory in IE
|
|
960
|
+
})();
|
|
961
|
+
|
|
962
|
+
function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
|
|
963
|
+
for ( var i = 0, l = checkSet.length; i < l; i++ ) {
|
|
964
|
+
var elem = checkSet[i];
|
|
965
|
+
if ( elem ) {
|
|
966
|
+
elem = elem[dir];
|
|
967
|
+
var match = false;
|
|
968
|
+
|
|
969
|
+
while ( elem ) {
|
|
970
|
+
if ( elem.sizcache === doneName ) {
|
|
971
|
+
match = checkSet[elem.sizset];
|
|
972
|
+
break;
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
if ( elem.nodeType === 1 && !isXML ){
|
|
976
|
+
elem.sizcache = doneName;
|
|
977
|
+
elem.sizset = i;
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
if ( elem.nodeName.toLowerCase() === cur ) {
|
|
981
|
+
match = elem;
|
|
982
|
+
break;
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
elem = elem[dir];
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
checkSet[i] = match;
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
|
|
994
|
+
for ( var i = 0, l = checkSet.length; i < l; i++ ) {
|
|
995
|
+
var elem = checkSet[i];
|
|
996
|
+
if ( elem ) {
|
|
997
|
+
elem = elem[dir];
|
|
998
|
+
var match = false;
|
|
999
|
+
|
|
1000
|
+
while ( elem ) {
|
|
1001
|
+
if ( elem.sizcache === doneName ) {
|
|
1002
|
+
match = checkSet[elem.sizset];
|
|
1003
|
+
break;
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
if ( elem.nodeType === 1 ) {
|
|
1007
|
+
if ( !isXML ) {
|
|
1008
|
+
elem.sizcache = doneName;
|
|
1009
|
+
elem.sizset = i;
|
|
1010
|
+
}
|
|
1011
|
+
if ( typeof cur !== "string" ) {
|
|
1012
|
+
if ( elem === cur ) {
|
|
1013
|
+
match = true;
|
|
1014
|
+
break;
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
} else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
|
|
1018
|
+
match = elem;
|
|
1019
|
+
break;
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
elem = elem[dir];
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
checkSet[i] = match;
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
var contains = document.compareDocumentPosition ? function(a, b){
|
|
1032
|
+
return !!(a.compareDocumentPosition(b) & 16);
|
|
1033
|
+
} : function(a, b){
|
|
1034
|
+
return a !== b && (a.contains ? a.contains(b) : true);
|
|
1035
|
+
};
|
|
1036
|
+
|
|
1037
|
+
var isXML = function(elem){
|
|
1038
|
+
// documentElement is verified for cases where it doesn't yet exist
|
|
1039
|
+
// (such as loading iframes in IE - #4833)
|
|
1040
|
+
var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
|
|
1041
|
+
return documentElement ? documentElement.nodeName !== "HTML" : false;
|
|
1042
|
+
};
|
|
1043
|
+
|
|
1044
|
+
var posProcess = function(selector, context){
|
|
1045
|
+
var tmpSet = [], later = "", match,
|
|
1046
|
+
root = context.nodeType ? [context] : context;
|
|
1047
|
+
|
|
1048
|
+
// Position selectors must be done after the filter
|
|
1049
|
+
// And so must :not(positional) so we move all PSEUDOs to the end
|
|
1050
|
+
while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
|
|
1051
|
+
later += match[0];
|
|
1052
|
+
selector = selector.replace( Expr.match.PSEUDO, "" );
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
selector = Expr.relative[selector] ? selector + "*" : selector;
|
|
1056
|
+
|
|
1057
|
+
for ( var i = 0, l = root.length; i < l; i++ ) {
|
|
1058
|
+
Sizzle( selector, root[i], tmpSet );
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
return Sizzle.filter( later, tmpSet );
|
|
1062
|
+
};
|
|
1063
|
+
|
|
1064
|
+
// EXPOSE
|
|
1065
|
+
|
|
1066
|
+
window.Sizzle = Sizzle;
|
|
1067
|
+
|
|
1068
|
+
})();
|