aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Nagel <info@felixnagel.com>2012-05-14 11:52:47 +0200
committerFelix Nagel <info@felixnagel.com>2012-05-14 11:52:47 +0200
commitc6a8d7ee3c9803d9944db6f55778810592a36452 (patch)
treeabb3df79a0eb6d9bb4713ab73da8ddc60d8a7674
parent41dfb09aeb5df7d53089b58959d21207de63edbe (diff)
parentd393c8b4cb26ec34878c22202da6ba9393e0094d (diff)
downloadjquery-ui-c6a8d7ee3c9803d9944db6f55778810592a36452.tar.gz
jquery-ui-c6a8d7ee3c9803d9944db6f55778810592a36452.zip
Merge branch 'master' into selectmenu
-rw-r--r--.gitignore3
-rw-r--r--.jshintrc12
-rw-r--r--build/build.xml373
-rw-r--r--build/build/ant-contrib-0.6.jarbin119512 -> 0 bytes
-rw-r--r--build/build/lib/jslint.js5504
-rw-r--r--build/build/lib/parse-js.js1315
-rw-r--r--build/build/lib/process.js1666
-rw-r--r--build/build/lib/squeeze-more.js22
-rwxr-xr-xbuild/build/minify-js.sh3
-rw-r--r--build/build/sizer.js41
-rw-r--r--build/build/style.xsl211
-rw-r--r--build/build/uglify.js285
-rw-r--r--build/build/yuicompressor-2.4.2.jarbin851219 -> 0 bytes
-rw-r--r--demos/autocomplete/combobox.html38
-rw-r--r--demos/autocomplete/custom-data.html2
-rw-r--r--demos/autocomplete/maxheight.html2
-rw-r--r--demos/datepicker/date-range.html18
-rw-r--r--demos/demos.css2
-rw-r--r--demos/draggable/snap-to.html4
-rw-r--r--demos/index.html2
-rw-r--r--demos/menu/default.html4
-rw-r--r--demos/menu/index.html1
-rw-r--r--demos/menu/navigationmenu.html2
-rw-r--r--demos/menu/topalignmenu.html17
-rw-r--r--demos/position/cycler.html6
-rw-r--r--demos/position/default.html37
-rw-r--r--demos/sortable/empty-lists.html2
-rw-r--r--demos/tooltip/custom-content.html10
-rw-r--r--demos/tooltip/custom-style.html101
-rw-r--r--demos/tooltip/forms.html33
-rw-r--r--external/jshint.js4390
-rw-r--r--external/qunit.css6
-rw-r--r--external/qunit.js1411
-rw-r--r--grunt.js352
-rw-r--r--package.json11
-rw-r--r--tests/.jshintrc59
-rw-r--r--tests/jquery.simulate.js1
-rw-r--r--tests/resource_loader.js39
-rw-r--r--tests/static/datepicker/datepicker.html26
-rw-r--r--tests/static/icons.html74
-rw-r--r--tests/unit/accordion/accordion.html20
-rw-r--r--tests/unit/accordion/accordion_common.js (renamed from tests/unit/accordion/accordion_defaults.js)2
-rw-r--r--tests/unit/accordion/accordion_common_deprecated.js (renamed from tests/unit/accordion/accordion_defaults_deprecated.js)2
-rw-r--r--tests/unit/accordion/accordion_core.js21
-rw-r--r--tests/unit/accordion/accordion_deprecated.html20
-rw-r--r--tests/unit/accordion/accordion_deprecated.js170
-rw-r--r--tests/unit/accordion/accordion_events.js109
-rw-r--r--tests/unit/accordion/accordion_methods.js18
-rw-r--r--tests/unit/accordion/accordion_options.js142
-rw-r--r--tests/unit/accordion/accordion_test_helpers.js58
-rw-r--r--tests/unit/accordion/all.html4
-rw-r--r--tests/unit/all-active.html4
-rw-r--r--tests/unit/all.html4
-rw-r--r--tests/unit/autocomplete/all.html4
-rw-r--r--tests/unit/autocomplete/autocomplete.html14
-rw-r--r--tests/unit/autocomplete/autocomplete_common.js (renamed from tests/unit/autocomplete/autocomplete_defaults.js)2
-rw-r--r--tests/unit/autocomplete/autocomplete_core.js29
-rw-r--r--tests/unit/autocomplete/autocomplete_events.js2
-rw-r--r--tests/unit/button/all.html4
-rw-r--r--tests/unit/button/button.html14
-rw-r--r--tests/unit/button/button_common.js (renamed from tests/unit/button/button_defaults.js)2
-rw-r--r--tests/unit/button/button_core.js11
-rw-r--r--tests/unit/button/button_methods.js4
-rw-r--r--tests/unit/core/all.html4
-rw-r--r--tests/unit/core/core.html26
-rw-r--r--tests/unit/core/core.js57
-rw-r--r--tests/unit/core/selector.js76
-rw-r--r--tests/unit/datepicker/all.html4
-rw-r--r--tests/unit/datepicker/datepicker.html12
-rw-r--r--tests/unit/datepicker/datepicker_core.js80
-rw-r--r--tests/unit/datepicker/datepicker_defaults.js2
-rw-r--r--tests/unit/datepicker/datepicker_events.js17
-rw-r--r--tests/unit/datepicker/datepicker_methods.js34
-rw-r--r--tests/unit/datepicker/datepicker_options.js231
-rw-r--r--tests/unit/datepicker/datepicker_tickets.js14
-rw-r--r--tests/unit/dialog/all.html4
-rw-r--r--tests/unit/dialog/dialog.html14
-rw-r--r--tests/unit/dialog/dialog_common.js (renamed from tests/unit/dialog/dialog_defaults.js)2
-rw-r--r--tests/unit/dialog/dialog_core.js8
-rw-r--r--tests/unit/dialog/dialog_events.js10
-rw-r--r--tests/unit/dialog/dialog_methods.js9
-rw-r--r--tests/unit/dialog/dialog_options.js94
-rw-r--r--tests/unit/dialog/dialog_tickets.js81
-rw-r--r--tests/unit/draggable/all.html4
-rw-r--r--tests/unit/draggable/draggable.html14
-rw-r--r--tests/unit/draggable/draggable_common.js32
-rw-r--r--tests/unit/draggable/draggable_core.js18
-rw-r--r--tests/unit/draggable/draggable_defaults.js36
-rw-r--r--tests/unit/draggable/draggable_options.js79
-rw-r--r--tests/unit/droppable/all.html4
-rw-r--r--tests/unit/droppable/droppable.html14
-rw-r--r--tests/unit/droppable/droppable_common.js12
-rw-r--r--tests/unit/droppable/droppable_core.js10
-rw-r--r--tests/unit/droppable/droppable_defaults.js16
-rw-r--r--tests/unit/droppable/droppable_options.js4
-rw-r--r--tests/unit/effects/all.html4
-rw-r--r--tests/unit/effects/effects.html11
-rw-r--r--tests/unit/effects/effects_core.js121
-rw-r--r--tests/unit/effects/effects_scale.js19
-rw-r--r--tests/unit/menu/all.html4
-rw-r--r--tests/unit/menu/menu.html30
-rw-r--r--tests/unit/menu/menu_common.js (renamed from tests/unit/menu/menu_defaults.js)2
-rw-r--r--tests/unit/menu/menu_core.js9
-rw-r--r--tests/unit/menu/menu_events.js232
-rw-r--r--tests/unit/menu/menu_methods.js17
-rw-r--r--tests/unit/menu/menu_options.js19
-rw-r--r--tests/unit/menu/menu_test_helpers.js28
-rw-r--r--tests/unit/position/all.html4
-rw-r--r--tests/unit/position/position.html57
-rw-r--r--tests/unit/position/position_core.js534
-rw-r--r--tests/unit/position/position_core_within.js545
-rw-r--r--tests/unit/position/position_deprecated.html54
-rw-r--r--tests/unit/progressbar/all.html4
-rw-r--r--tests/unit/progressbar/progressbar.html14
-rw-r--r--tests/unit/progressbar/progressbar_common.js (renamed from tests/unit/progressbar/progressbar_defaults.js)2
-rw-r--r--tests/unit/progressbar/progressbar_events.js2
-rw-r--r--tests/unit/qunit-composite.css13
-rw-r--r--tests/unit/qunit-composite.js102
-rw-r--r--tests/unit/resizable/all.html4
-rw-r--r--tests/unit/resizable/resizable.html16
-rw-r--r--tests/unit/resizable/resizable_common.js27
-rw-r--r--tests/unit/resizable/resizable_defaults.js28
-rw-r--r--tests/unit/resizable/resizable_events.js12
-rw-r--r--tests/unit/resizable/resizable_methods.js55
-rw-r--r--tests/unit/resizable/resizable_options.js9
-rw-r--r--tests/unit/selectable/all.html4
-rw-r--r--tests/unit/selectable/selectable.html14
-rw-r--r--tests/unit/selectable/selectable_common.js12
-rw-r--r--tests/unit/selectable/selectable_defaults.js16
-rw-r--r--tests/unit/selectable/selectable_methods.js16
-rw-r--r--tests/unit/selectable/selectable_options.js6
-rw-r--r--tests/unit/slider/all.html4
-rw-r--r--tests/unit/slider/slider.html14
-rw-r--r--tests/unit/slider/slider_common.js (renamed from tests/unit/slider/slider_defaults.js)2
-rw-r--r--tests/unit/slider/slider_methods.js14
-rw-r--r--tests/unit/slider/slider_options.js10
-rw-r--r--tests/unit/sortable/all.html4
-rw-r--r--tests/unit/sortable/sortable.html14
-rw-r--r--tests/unit/sortable/sortable_common.js30
-rw-r--r--tests/unit/sortable/sortable_defaults.js34
-rw-r--r--tests/unit/sortable/sortable_events.js64
-rw-r--r--tests/unit/sortable/sortable_methods.js4
-rw-r--r--tests/unit/sortable/sortable_tickets.js4
-rw-r--r--tests/unit/spinner/all.html4
-rw-r--r--tests/unit/spinner/spinner.html16
-rw-r--r--tests/unit/spinner/spinner_common.js (renamed from tests/unit/spinner/spinner_defaults.js)2
-rw-r--r--tests/unit/spinner/spinner_core.js48
-rw-r--r--tests/unit/spinner/spinner_events.js148
-rw-r--r--tests/unit/spinner/spinner_methods.js14
-rw-r--r--tests/unit/spinner/spinner_options.js4
-rw-r--r--tests/unit/spinner/spinner_test_helpers.js11
-rw-r--r--tests/unit/subsuite.js13
-rw-r--r--tests/unit/subsuiteRunner.css8
-rw-r--r--tests/unit/subsuiteRunner.js82
-rw-r--r--tests/unit/swarminject.js2
-rw-r--r--tests/unit/tabs/all.html4
-rw-r--r--tests/unit/tabs/tabs.html72
-rw-r--r--tests/unit/tabs/tabs_common.js (renamed from tests/unit/tabs/tabs_defaults.js)2
-rw-r--r--tests/unit/tabs/tabs_common_deprecated.js (renamed from tests/unit/tabs/tabs_defaults_deprecated.js)2
-rw-r--r--tests/unit/tabs/tabs_core.js4
-rw-r--r--tests/unit/tabs/tabs_deprecated.html72
-rw-r--r--tests/unit/tabs/tabs_deprecated.js130
-rw-r--r--tests/unit/tabs/tabs_events.js140
-rw-r--r--tests/unit/tabs/tabs_methods.js113
-rw-r--r--tests/unit/tabs/tabs_options.js73
-rw-r--r--tests/unit/tabs/tabs_test_helpers.js61
-rw-r--r--tests/unit/testsuite.js110
-rw-r--r--tests/unit/tooltip/all.html4
-rw-r--r--tests/unit/tooltip/tooltip.html14
-rw-r--r--tests/unit/tooltip/tooltip_common.js (renamed from tests/unit/tooltip/tooltip_defaults.js)2
-rw-r--r--tests/unit/tooltip/tooltip_methods.js10
-rw-r--r--tests/unit/tooltip/tooltip_options.js11
-rw-r--r--tests/unit/widget/all.html4
-rw-r--r--tests/unit/widget/widget.html12
-rw-r--r--tests/unit/widget/widget_core.js76
-rw-r--r--tests/unit/widget/widget_extend.js47
-rw-r--r--tests/visual/addClass/addClass_queue.html6
-rw-r--r--tests/visual/button/button_disabled_true.html2
-rw-r--r--tests/visual/button/button_ticket_5254.html55
-rw-r--r--tests/visual/compound/accordion_dialog.html202
-rw-r--r--tests/visual/compound/accordion_tabs.html36
-rw-r--r--tests/visual/compound/datepicker_dialog.html158
-rw-r--r--tests/visual/compound/dialog_widgets.html101
-rw-r--r--tests/visual/compound/draggable_accordion.html32
-rw-r--r--tests/visual/compound/draggable_accordion_accordion_tabs_draggable.html58
-rw-r--r--tests/visual/compound/sortable_accordion_sortable_tabs.html50
-rw-r--r--tests/visual/compound/tabs_tabs.html22
-rw-r--r--tests/visual/compound/tabs_tooltips.html26
-rw-r--r--tests/visual/compound/widgets_in_dialog.html229
-rw-r--r--tests/visual/effects/effects.scale.html6
-rw-r--r--tests/visual/menu/drilldown.html31
-rw-r--r--tests/visual/menu/menu.html6
-rw-r--r--tests/visual/menu/tablemenu.html7
-rw-r--r--tests/visual/position/position.html20
-rw-r--r--tests/visual/position/position_feedback.html146
-rw-r--r--tests/visual/position/position_feedback_rotate.html109
-rw-r--r--tests/visual/position/position_fit.html41
-rw-r--r--tests/visual/position/position_flip.html23
-rw-r--r--tests/visual/position/position_flipfit.html29
-rw-r--r--tests/visual/position/position_margin.html1
-rw-r--r--tests/visual/position/position_within.html2
-rw-r--r--tests/visual/theme.html152
-rw-r--r--tests/visual/tooltip/animations.html1
-rw-r--r--tests/visual/tooltip/tooltip.html1
-rw-r--r--themes/base/jquery.ui.menu.css1
-rw-r--r--themes/base/jquery.ui.resizable.css2
-rw-r--r--themes/base/jquery.ui.spinner.css2
-rw-r--r--themes/base/jquery.ui.tabs.css2
-rw-r--r--themes/base/jquery.ui.tooltip.css2
-rw-r--r--ui/.jshintrc17
-rw-r--r--ui/i18n/jquery.ui.datepicker-hi.js18
-rw-r--r--ui/jquery.effects.bounce.js16
-rw-r--r--ui/jquery.effects.core.js30
-rw-r--r--ui/jquery.effects.drop.js24
-rw-r--r--ui/jquery.effects.fade.js2
-rw-r--r--ui/jquery.effects.scale.js73
-rw-r--r--ui/jquery.effects.slide.js23
-rw-r--r--ui/jquery.ui.accordion.js32
-rw-r--r--ui/jquery.ui.autocomplete.js294
-rw-r--r--ui/jquery.ui.datepicker.js2
-rw-r--r--ui/jquery.ui.dialog.js221
-rw-r--r--ui/jquery.ui.draggable.js10
-rw-r--r--ui/jquery.ui.menu.js395
-rw-r--r--ui/jquery.ui.position.js260
-rw-r--r--ui/jquery.ui.resizable.js191
-rw-r--r--ui/jquery.ui.selectable.js28
-rw-r--r--ui/jquery.ui.slider.js130
-rw-r--r--ui/jquery.ui.sortable.js178
-rw-r--r--ui/jquery.ui.spinner.js42
-rw-r--r--ui/jquery.ui.tabs.js86
-rw-r--r--ui/jquery.ui.tooltip.js19
-rw-r--r--version.txt1
232 files changed, 9845 insertions, 15134 deletions
diff --git a/.gitignore b/.gitignore
index dc1bdf6c1..23d9dd000 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,3 @@
-build/dist
-build/size
-build/build/.sizecache.json
dist
node_modules
docs
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 000000000..99161bd4e
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,12 @@
+{
+ "curly": true,
+ "eqnull": true,
+ "eqeqeq": true,
+ "expr": true,
+ "latedef": true,
+ "noarg": true,
+ "onevar": true,
+ "smarttabs": true,
+ "trailing": true,
+ "undef": true
+}
diff --git a/build/build.xml b/build/build.xml
deleted file mode 100644
index ddaa5b86d..000000000
--- a/build/build.xml
+++ /dev/null
@@ -1,373 +0,0 @@
-<?xml version="1.0" encoding="iso-8859-1"?>
-
-<!--
- jQuery UI Release!
-
- Call task called 'deploy-release' to build a full release.
- The release built will be stored on 'dist' dir.
-
--->
-
-<project name="jquery-ui" default="deploy-release" basedir=".">
-
- <taskdef resource="net/sf/antcontrib/antcontrib.properties">
- <classpath>
- <pathelement location="build/ant-contrib-0.6.jar"/>
- </classpath>
- </taskdef>
-
- <property file="ant.properties" />
-
- <loadfile failonerror="no" srcFile="../version.txt" property="release.version">
- <filterchain><striplinebreaks/></filterchain>
- </loadfile>
- <property name="release.filename" value="jquery-ui-${release.version}" />
-
- <property name="dist.dir" value="dist/${release.filename}/" />
- <property name="cdndist.dir" value="dist/${release.filename}-cdn" />
- <property name="build.dir" value="build" />
- <property name="ui.dir" value="../" />
- <property name="src.dir" value="${ui.dir}/ui/" />
- <property name="theme.dir" value="${ui.dir}/themes/base/" />
- <property name="docs.dir" value="${dist.dir}/docs/" />
- <property name="min.dir" value="${dist.dir}/ui/minified" />
- <property name="size.dir" value="size" />
-
- <property name="concatenated" value="jquery-ui" />
- <property name="concatenated.i18n" value="jquery-ui-i18n" />
-
- <property name="core.files" value="jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.effects.core.js" />
- <property name="core.files.min" value="jquery.ui.core.min.js, jquery.ui.widget.min.js, jquery.ui.mouse.min.js, jquery.ui.draggable.min.js, jquery.ui.droppable.min.js, jquery.ui.resizable.min.js, jquery.ui.selectable.min.js, jquery.ui.sortable.min.js, jquery.effects.core.min.js" />
-
- <property description="YUI Compressor" name="yuicompressor-jar" value="${build.dir}/yuicompressor-2.4.2.jar" />
-
- <target name="deploy-release" depends="clean, docs-download, copy, minify, replace-version, prepend-header, zip" description="Release builder">
- </target>
-
- <target name="replace-version">
- <replaceregexp match="@VERSION" replace="${release.version}" flags="g" byline="true">
- <fileset dir="${dist.dir}/ui/" includes="*.js"/>
- <fileset dir="${dist.dir}/ui/minified/" includes="*.js"/>
- <fileset dir="${dist.dir}/themes/" includes="**/*.css"/>
- </replaceregexp>
- <echo message="Replaced all @VERSION to ${release.version}." />
- </target>
-
- <target name="prepend-header">
- <copy todir="${dist.dir}/headers/">
- <fileset dir="${dist.dir}/themes/base" includes="*.css" />
- </copy>
- <replaceregexp match="^(\/\*.*?\*\/\s).+" replace="\1" flags="s">
- <fileset dir="${dist.dir}/headers/" includes="*.css"/>
- </replaceregexp>
- <for param="file">
- <path><fileset dir="${dist.dir}/themes/base/minified" includes="*.css" /></path>
- <sequential>
- <propertyregex override="yes" property="target" input="@{file}" regexp=".*[\\/](.+)\.min\.css$" replace="\1"/>
- <concat destfile="${dist.dir}/ui-headered/${target}.min.css">
- <header file="${dist.dir}/headers/${target}.css" />
- <fileset file="@{file}" />
- </concat>
- </sequential>
- </for>
- <copy todir="${dist.dir}/themes/base/minified" overwrite="true">
- <fileset dir="${dist.dir}/ui-headered/" includes="*.css" />
- </copy>
-
- <delete dir="${dist.dir}/headers/" />
- <delete dir="${dist.dir}/ui-headered/" />
- </target>
-
- <target description="Zip the package" name="zip">
- <zip destfile="${dist.dir}/../${release.filename}.zip">
- <zipfileset dir="dist/" />
- </zip>
- </target>
-
- <target name="concatenate">
- <echo message="Building concatenated" />
- <mkdir dir="${dist.dir}/ui/" />
- <delete file="${dist.dir}/ui/${concatenated}.js" />
-
- <concat destfile="${dist.dir}/ui/${concatenated}.js">
- <filelist dir="${src.dir}/" files="${core.files}" />
- <fileset dir="${src.dir}/" includes="jquery.ui.*.js, jquery.effects.*.js" excludes="${core.files}" />
- </concat>
- <echo message="Concatenated built." />
-
- <concat destfile="${dist.dir}/themes/base/${concatenated}.css">
- <fileset dir="${theme.dir}/" includes="jquery.ui.core.css" />
- <fileset dir="${theme.dir}/" includes="jquery.ui.*.css" excludes="jquery.ui.all.css, jquery.ui.core.css, jquery.ui.base.css, jquery.ui.theme.css" />
- <fileset dir="${theme.dir}/" includes="jquery.ui.theme.css" />
- </concat>
- <echo message="Concatenated theme." />
-
- <mkdir dir="${dist.dir}/ui/i18n/" />
- <delete file="${dist.dir}/ui/i18n/${concatenated.i18n}.js" />
-
- <concat destfile="${dist.dir}/ui/i18n/${concatenated.i18n}.js" encoding="utf-8">
- <fileset dir="${src.dir}/i18n/" includes="jquery.ui.*.js" />
- </concat>
- <echo message="Concatenated i18n built." />
- </target>
-
- <target name="minify" depends="concatenate" description="Remove all comments and whitespace, no compression, great in combination with GZip">
- <echo message="Building minified" />
- <mkdir dir="${min.dir}" />
- <mkdir dir="${min.dir}/i18n/" />
- <mkdir dir="${dist.dir}/themes/base/minified" />
- <parallel threadsperprocessor="1">
- <apply executable="build/minify-js.sh">
- <fileset dir="${dist.dir}/ui" includes="**.js" />
- <srcfile />
- <mapper type="glob" from="*.js" to="${min.dir}/*.min.js" />
- <targetfile/>
- </apply>
- <apply executable="build/minify-js.sh">
- <fileset dir="${dist.dir}/ui/i18n" includes="**.js" />
- <srcfile />
- <mapper type="glob" from="*.js" to="${min.dir}/i18n/*.min.js" />
- <targetfile/>
- </apply>
- <apply executable="java" parallel="false">
- <fileset dir="${dist.dir}/themes/base" includes="*.css" />
- <arg line="-jar" />
- <arg path="${yuicompressor-jar}" />
- <arg line="--charset utf-8" />
- <arg line="-v" />
- <srcfile />
- <arg line="-o" />
- <mapper type="glob" from="*.css" to="${dist.dir}/themes/base/minified/*.min.css" />
- <targetfile/>
- </apply>
- </parallel>
-
- <replaceregexp match=".css" replace=".min.css" flags="g">
- <fileset dir="${dist.dir}/themes/base/minified/">
- <include name="*.base.min.css"/>
- <include name="*.all.min.css"/>
- </fileset>
- </replaceregexp>
-
- <!-- make a copy of all theme images to ensure that relative paths in minified css files work -->
- <copy todir="${dist.dir}/themes/base/minified/images" >
- <fileset dir="${ui.dir}/themes/base/images" />
- </copy>
-
- <!-- make a copy of the minified files for use in tests -->
- <copy todir="dist" file="${min.dir}/jquery-ui.min.js" />
- <copy todir="dist/theme" file="${dist.dir}/themes/base/minified/jquery-ui.min.css" />
- <copy todir="dist/theme/images" >
- <fileset dir="${ui.dir}/themes/base/images" />
- </copy>
-
- <echo message="Minified ui/ built." />
- </target>
-
- <target description="Copy needed folders" name="copy">
- <echo message="Copying files" />
- <mkdir dir="${dist.dir}" />
-
- <copy overwrite="true" todir="${dist.dir}/">
- <fileset dir="${ui.dir}/" includes="jquery-*.js" />
- </copy>
-
- <copy overwrite="true" todir="${dist.dir}/ui/">
- <fileset dir="${src.dir}/" includes="jquery.ui.*.js, jquery.effects.*.js" />
- </copy>
-
- <copy overwrite="true" todir="${dist.dir}/ui/i18n/" >
- <fileset dir="${src.dir}/i18n/" />
- </copy>
-
- <copy overwrite="true" todir="${dist.dir}/">
- <fileset dir="${ui.dir}/" includes="*.txt" />
- </copy>
-
- <copy overwrite="true" todir="${dist.dir}/demos/" >
- <fileset dir="${ui.dir}/demos/" />
- </copy>
-
- <copy overwrite="true" todir="${dist.dir}/external/" >
- <fileset dir="${ui.dir}/external/" />
- </copy>
-
- <copy overwrite="true" todir="${dist.dir}/tests/" >
- <fileset dir="${ui.dir}/tests/" />
- </copy>
-
- <copy overwrite="true" todir="${dist.dir}/themes/" >
- <fileset dir="${ui.dir}/themes/" />
- </copy>
- <echo message="Files copied." />
- </target>
-
- <target name="clean">
- <delete dir="dist" />
- </target>
-
- <target name="docs-download">
- <mkdir dir="${docs.dir}" />
- <property name="url" value="http://docs.jquery.com/action/render/UI/API/${release.version}/" />
- <parallel threadcount="8">
- <get src="${url}Draggable" dest="${docs.dir}draggable.html" />
- <get src="${url}Droppable" dest="${docs.dir}droppable.html" />
- <get src="${url}Resizable" dest="${docs.dir}resizable.html" />
- <get src="${url}Selectable" dest="${docs.dir}selectable.html" />
- <get src="${url}Sortable" dest="${docs.dir}sortable.html" />
-
- <get src="${url}Accordion" dest="${docs.dir}accordion.html" />
- <get src="${url}Autocomplete" dest="${docs.dir}autocomplete.html" />
- <get src="${url}Button" dest="${docs.dir}button.html" />
- <get src="${url}Datepicker" dest="${docs.dir}datepicker.html" />
- <get src="${url}Dialog" dest="${docs.dir}dialog.html" />
- <get src="${url}Menu" dest="${docs.dir}menu.html" />
- <get src="${url}Progressbar" dest="${docs.dir}progressbar.html" />
- <get src="${url}Slider" dest="${docs.dir}slider.html" />
- <get src="${url}Spinner" dest="${docs.dir}spinner.html" />
- <get src="${url}Tooltip" dest="${docs.dir}tooltip.html" />
- <get src="${url}Tabs" dest="${docs.dir}tabs.html" />
-
- <get src="${url}Position" dest="${docs.dir}position.html" />
-
- <get src="http://docs.jquery.com/action/render/UI/Effects/animate" dest="${docs.dir}animate.html" />
- <get src="http://docs.jquery.com/action/render/UI/Effects/addClass" dest="${docs.dir}addClass.html" />
- <get src="http://docs.jquery.com/action/render/UI/Effects/effect" dest="${docs.dir}effect.html" />
- <get src="http://docs.jquery.com/action/render/UI/Effects/hide" dest="${docs.dir}hide.html" />
- <get src="http://docs.jquery.com/action/render/UI/Effects/removeClass" dest="${docs.dir}removeClass.html" />
- <get src="http://docs.jquery.com/action/render/UI/Effects/show" dest="${docs.dir}show.html" />
- <get src="http://docs.jquery.com/action/render/UI/Effects/switchClass" dest="${docs.dir}switchClass.html" />
- <get src="http://docs.jquery.com/action/render/UI/Effects/toggle" dest="${docs.dir}toggle.html" />
- <get src="http://docs.jquery.com/action/render/UI/Effects/toggleClass" dest="${docs.dir}toggleClass.html" />
-
-
- <get src="http://docs.jquery.com/action/render/UI/Effects/Blind" dest="${docs.dir}effect-blind.html" />
- <get src="http://docs.jquery.com/action/render/UI/Effects/Clip" dest="${docs.dir}effect-clip.html" />
- <get src="http://docs.jquery.com/action/render/UI/Effects/Drop" dest="${docs.dir}effect-drop.html" />
- <get src="http://docs.jquery.com/action/render/UI/Effects/Explode" dest="${docs.dir}effect-explode.html" />
- <get src="http://docs.jquery.com/action/render/UI/Effects/Fade" dest="${docs.dir}effect-fade.html" />
- <get src="http://docs.jquery.com/action/render/UI/Effects/Fold" dest="${docs.dir}effect-fold.html" />
- <get src="http://docs.jquery.com/action/render/UI/Effects/Puff" dest="${docs.dir}effect-puff.html" />
- <get src="http://docs.jquery.com/action/render/UI/Effects/Slide" dest="${docs.dir}effect-slide.html" />
- <get src="http://docs.jquery.com/action/render/UI/Effects/Scale" dest="${docs.dir}effect-scale.html" />
-
- <get src="http://docs.jquery.com/action/render/UI/Effects/Bounce" dest="${docs.dir}effect-bounce.html" />
- <get src="http://docs.jquery.com/action/render/UI/Effects/Highlight" dest="${docs.dir}effect-highlight.html" />
- <get src="http://docs.jquery.com/action/render/UI/Effects/Pulsate" dest="${docs.dir}effect-pulsate.html" />
- <get src="http://docs.jquery.com/action/render/UI/Effects/Shake" dest="${docs.dir}effect-shake.html" />
- <get src="http://docs.jquery.com/action/render/UI/Effects/Size" dest="${docs.dir}effect-size.html" />
- <get src="http://docs.jquery.com/action/render/UI/Effects/Transfer" dest="${docs.dir}effect-transfer.html" />
- </parallel>
- </target>
-
- <target name="themes-download">
- <!-- to create/update query strings for the theme-file, execute this in Firebug on /download page:
- $("select option[value!=none]").map(function() { $(this).parent().val(this.value).change(); return $(this).parents("form").serialize(); }).get().join(",");
- -->
- <loadfile srcFile="themes" property="urls" />
- <property name="zip" value="${dist.dir}themes/tmp.zip" />
- <mkdir dir="${dist.dir}themes" />
- <for list="${urls}" param="url">
- <sequential>
- <get src="http://ui-dev.jquery.com/download/?@{url}" dest="${zip}" />
- <unzip src="${zip}" dest="${dist.dir}themes/">
- <patternset>
- <include name="development-bundle/themes/**"/>
- <exclude name="development-bundle/themes/base/**"/>
- </patternset>
- <mapper type="glob" from="development-bundle/themes/*" to="*" />
- </unzip>
- <delete file="${zip}" />
- </sequential>
- </for>
- <move todir="${dist.dir}themes/">
- <fileset dir="${dist.dir}themes/" />
- <mapper>
- <mapper type="regexp" from="(.*)jquery-ui-.*custom.css" to="\1jquery-ui.css" />
- </mapper>
- </move>
- <copy todir="dist/jquery-ui-themes-${release.version}">
- <fileset dir="${dist.dir}/" includes="AUTHORS.txt,GPL-LICENSE.txt,MIT-LICENSE.txt,version.txt,themes/**" />
- </copy>
- <zip destfile="${dist.dir}/../jquery-ui-themes-${release.version}.zip">
- <zipfileset dir="dist/" includes="jquery-ui-themes-${release.version}/" />
- </zip>
- </target>
-
- <target name="whitespace">
- <replaceregexp match="[\t ]+$" replace="" flags="g" byline="true">
- <fileset dir="${src.dir}" includes="*.js"/>
- <fileset dir="${src.dir}/i18n/" includes="*.js"/>
- </replaceregexp>
- <echo message="All trailing spaces removed." />
- </target>
-
- <target name="size" depends="copy, minify, replace-version, prepend-header" description="Report sizes of files">
- <echo message="Collecting files to size" />
- <mkdir dir="${size.dir}" />
- <copy todir="${size.dir}">
- <fileset dir="${dist.dir}/ui" includes="*.js" />
- <fileset dir="${dist.dir}/ui/i18n" includes="*.js" />
- <fileset dir="${dist.dir}/ui/minified" includes="*.js" />
- <fileset dir="${dist.dir}/ui/minified/i18n" includes="*.js" />
- <fileset dir="${dist.dir}/themes/base" includes="*.css" />
- <fileset dir="${dist.dir}/themes/base/minified" includes="*.css" />
- </copy>
- <echo message="GZipping Minified" />
- <apply executable="gzip">
- <fileset dir="${size.dir}" includes="*.min.js" />
- <fileset dir="${size.dir}" includes="*.min.css" />
- <arg value="-c" />
- <srcfile />
- <redirector>
- <outputmapper id="out" type="glob" from="*" to="${size.dir}/*.gz"/>
- </redirector>
- </apply>
- <echo message="Comparing file size with previous build" />
- <exec executable="bash">
- <arg value="-c" />
- <arg value="wc -c ${size.dir}/* | `which node nodejs 2>/dev/null` build/sizer.js" />
- </exec>
- <delete dir="${size.dir}" />
- </target>
-
- <target name="cdn">
- <delete dir="${cdndist.dir}" />
- <mkdir dir="${cdndist.dir}" />
- <copy todir="${cdndist.dir}">
- <fileset dir=".." includes="AUTHORS.txt, GPL-LICENSE.txt, MIT-LICENSE.txt, version.txt" />
- </copy>
- <copy todir="${cdndist.dir}">
- <fileset dir="${dist.dir}ui" includes="jquery-ui.js" />
- <fileset dir="${dist.dir}ui/minified" includes="jquery-ui.min.js" />
- </copy>
- <copy todir="${cdndist.dir}/i18n">
- <fileset dir="${dist.dir}ui/i18n" />
- <fileset dir="${dist.dir}ui/minified/i18n" />
- </copy>
- <copy todir="${cdndist.dir}/themes">
- <fileset dir="${dist.dir}themes" />
- </copy>
- <checksum>
- <fileset dir="${cdndist.dir}" />
- </checksum>
- <for param="file">
- <path><fileset dir="${cdndist.dir}" includes="**/" excludes="**/*.MD5" /></path>
- <sequential>
- <!-- @{file} is an absolute path, use that ugly regexes to make it relative -->
- <propertyregex override="yes" property="relativepath" input="@{file}" regexp=".+?cdn[\\/](.+)$" replace="\1"/>
- <propertyregex override="yes" property="relativepath" input="${relativepath}" regexp="\\" replace="/" global="true" />
- <concat destfile="${cdndist.dir}/MANIFEST" append="yes">${relativepath} </concat>
- <concat destfile="${cdndist.dir}/MANIFEST" append="yes"><file file="@{file}.MD5" /></concat>
- </sequential>
- </for>
- <delete dir="${cdndist.dir}" includes="**/*.MD5" />
- <zip destfile="${dist.dir}/../${release.filename}-googlecdn.zip">
- <zipfileset dir="dist/" includes="${release.filename}-cdn/" />
- </zip>
- <zip destfile="${dist.dir}/../${release.filename}-mscdn.zip">
- <zipfileset dir="dist/${release.filename}-cdn/" />
- </zip>
- </target>
-
-</project>
diff --git a/build/build/ant-contrib-0.6.jar b/build/build/ant-contrib-0.6.jar
deleted file mode 100644
index db90b0aae..000000000
--- a/build/build/ant-contrib-0.6.jar
+++ /dev/null
Binary files differ
diff --git a/build/build/lib/jslint.js b/build/build/lib/jslint.js
deleted file mode 100644
index f563292bf..000000000
--- a/build/build/lib/jslint.js
+++ /dev/null
@@ -1,5504 +0,0 @@
-// jslint.js
-// 2010-02-20
-
-/*
-Copyright (c) 2002 Douglas Crockford (www.JSLint.com)
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-The Software shall be used for Good, not Evil.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
-
-/*
- JSLINT is a global function. It takes two parameters.
-
- var myResult = JSLINT(source, option);
-
- The first parameter is either a string or an array of strings. If it is a
- string, it will be split on '\n' or '\r'. If it is an array of strings, it
- is assumed that each string represents one line. The source can be a
- JavaScript text, or HTML text, or a Konfabulator text.
-
- The second parameter is an optional object of options which control the
- operation of JSLINT. Most of the options are booleans: They are all are
- optional and have a default value of false.
-
- If it checks out, JSLINT returns true. Otherwise, it returns false.
-
- If false, you can inspect JSLINT.errors to find out the problems.
- JSLINT.errors is an array of objects containing these members:
-
- {
- line : The line (relative to 0) at which the lint was found
- character : The character (relative to 0) at which the lint was found
- reason : The problem
- evidence : The text line in which the problem occurred
- raw : The raw message before the details were inserted
- a : The first detail
- b : The second detail
- c : The third detail
- d : The fourth detail
- }
-
- If a fatal error was found, a null will be the last element of the
- JSLINT.errors array.
-
- You can request a Function Report, which shows all of the functions
- and the parameters and vars that they use. This can be used to find
- implied global variables and other problems. The report is in HTML and
- can be inserted in an HTML <body>.
-
- var myReport = JSLINT.report(limited);
-
- If limited is true, then the report will be limited to only errors.
-
- You can request a data structure which contains JSLint's results.
-
- var myData = JSLINT.data();
-
- It returns a structure with this form:
-
- {
- errors: [
- {
- line: NUMBER,
- character: NUMBER,
- reason: STRING,
- evidence: STRING
- }
- ],
- functions: [
- name: STRING,
- line: NUMBER,
- last: NUMBER,
- param: [
- STRING
- ],
- closure: [
- STRING
- ],
- var: [
- STRING
- ],
- exception: [
- STRING
- ],
- outer: [
- STRING
- ],
- unused: [
- STRING
- ],
- global: [
- STRING
- ],
- label: [
- STRING
- ]
- ],
- globals: [
- STRING
- ],
- member: {
- STRING: NUMBER
- },
- unuseds: [
- {
- name: STRING,
- line: NUMBER
- }
- ],
- implieds: [
- {
- name: STRING,
- line: NUMBER
- }
- ],
- urls: [
- STRING
- ],
- json: BOOLEAN
- }
-
- Empty arrays will not be included.
-
-*/
-
-/*jslint
- evil: true, nomen: false, onevar: false, regexp: false, strict: true
-*/
-
-/*members "\b", "\t", "\n", "\f", "\r", "!=", "!==", "\"", "%",
- "(begin)", "(breakage)", "(context)", "(error)", "(global)",
- "(identifier)", "(last)", "(line)", "(loopage)", "(name)", "(onevar)",
- "(params)", "(scope)", "(verb)", "*", "+", "++", "-", "--", "\/",
- "<", "<=", "==", "===", ">", ">=", ADSAFE, Array, Boolean,
- COM, Canvas, CustomAnimation, Date, Debug, E, Error, EvalError,
- FadeAnimation, Flash, FormField, Frame, Function, HotKey, Image, JSON,
- LN10, LN2, LOG10E, LOG2E, MAX_VALUE, MIN_VALUE, Math, MenuItem,
- MoveAnimation, NEGATIVE_INFINITY, Number, Object, Option, PI,
- POSITIVE_INFINITY, Point, RangeError, Rectangle, ReferenceError, RegExp,
- ResizeAnimation, RotateAnimation, SQRT1_2, SQRT2, ScrollBar, String,
- Style, SyntaxError, System, Text, TextArea, Timer, TypeError, URIError,
- URL, Web, Window, XMLDOM, XMLHttpRequest, "\\", a, abbr, acronym,
- addEventListener, address, adsafe, alert, aliceblue, animator,
- antiquewhite, appleScript, applet, apply, approved, aqua, aquamarine,
- area, arguments, arity, autocomplete, azure, b, background,
- "background-attachment", "background-color", "background-image",
- "background-position", "background-repeat", base, bdo, beep, beige, big,
- bisque, bitwise, black, blanchedalmond, block, blockquote, blue,
- blueviolet, blur, body, border, "border-bottom", "border-bottom-color",
- "border-bottom-style", "border-bottom-width", "border-collapse",
- "border-color", "border-left", "border-left-color", "border-left-style",
- "border-left-width", "border-right", "border-right-color",
- "border-right-style", "border-right-width", "border-spacing",
- "border-style", "border-top", "border-top-color", "border-top-style",
- "border-top-width", "border-width", bottom, br, brown, browser,
- burlywood, button, bytesToUIString, c, cadetblue, call, callee, caller,
- canvas, cap, caption, "caption-side", cases, center, charAt, charCodeAt,
- character, chartreuse, chocolate, chooseColor, chooseFile, chooseFolder,
- cite, clear, clearInterval, clearTimeout, clip, close, closeWidget,
- closed, closure, cm, code, col, colgroup, color, comment, condition,
- confirm, console, constructor, content, convertPathToHFS,
- convertPathToPlatform, coral, cornflowerblue, cornsilk,
- "counter-increment", "counter-reset", create, crimson, css, cursor,
- cyan, d, darkblue, darkcyan, darkgoldenrod, darkgray, darkgreen,
- darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred,
- darksalmon, darkseagreen, darkslateblue, darkslategray, darkturquoise,
- darkviolet, data, dd, debug, decodeURI, decodeURIComponent, deeppink,
- deepskyblue, defaultStatus, defineClass, del, deserialize, devel, dfn,
- dimension, dimgray, dir, direction, display, div, dl, document,
- dodgerblue, dt, edition, else, em, embed, empty, "empty-cells",
- encodeURI, encodeURIComponent, entityify, eqeqeq, errors, escape, eval,
- event, evidence, evil, ex, exception, exec, exps, fieldset, filesystem,
- firebrick, first, float, floor, floralwhite, focus, focusWidget, font,
- "font-face", "font-family", "font-size", "font-size-adjust",
- "font-stretch", "font-style", "font-variant", "font-weight",
- forestgreen, forin, form, fragment, frame, frames, frameset, from,
- fromCharCode, fuchsia, fud, funct, function, functions, g, gainsboro,
- gc, getComputedStyle, ghostwhite, global, globals, gold, goldenrod,
- gray, green, greenyellow, h1, h2, h3, h4, h5, h6, hasOwnProperty, head,
- height, help, history, honeydew, hotpink, hr, html, i, iTunes, id,
- identifier, iframe, img, immed, implieds, in, include, indent, indexOf,
- indianred, indigo, init, input, ins, isAlpha, isApplicationRunning,
- isDigit, isFinite, isNaN, ivory, join, jslint, json, kbd, khaki,
- konfabulatorVersion, label, labelled, lang, last, lavender,
- lavenderblush, lawngreen, laxbreak, lbp, led, left, legend,
- lemonchiffon, length, "letter-spacing", li, lib, lightblue, lightcoral,
- lightcyan, lightgoldenrodyellow, lightgreen, lightpink, lightsalmon,
- lightseagreen, lightskyblue, lightslategray, lightsteelblue,
- lightyellow, lime, limegreen, line, "line-height", linen, link,
- "list-style", "list-style-image", "list-style-position",
- "list-style-type", load, loadClass, location, log, m, magenta, map,
- margin, "margin-bottom", "margin-left", "margin-right", "margin-top",
- "marker-offset", maroon, match, "max-height", "max-width", maxerr, maxlen,
- md5, media, mediumaquamarine, mediumblue, mediumorchid, mediumpurple,
- mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise,
- mediumvioletred, member, menu, message, meta, midnightblue,
- "min-height", "min-width", mintcream, mistyrose, mm, moccasin, moveBy,
- moveTo, name, navajowhite, navigator, navy, new, newcap, noframes,
- nomen, noscript, nud, object, ol, oldlace, olive, olivedrab, on,
- onbeforeunload, onblur, onerror, onevar, onfocus, onload, onresize,
- onunload, opacity, open, openURL, opener, opera, optgroup, option,
- orange, orangered, orchid, outer, outline, "outline-color",
- "outline-style", "outline-width", overflow, "overflow-x", "overflow-y",
- p, padding, "padding-bottom", "padding-left", "padding-right",
- "padding-top", page, "page-break-after", "page-break-before",
- palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip,
- param, parent, parseFloat, parseInt, passfail, pc, peachpuff, peru,
- pink, play, plum, plusplus, pop, popupMenu, position, powderblue, pre,
- predef, preferenceGroups, preferences, print, prompt, prototype, pt,
- purple, push, px, q, quit, quotes, random, range, raw, reach, readFile,
- readUrl, reason, red, regexp, reloadWidget, removeEventListener,
- replace, report, reserved, resizeBy, resizeTo, resolvePath,
- resumeUpdates, rhino, right, rosybrown, royalblue, runCommand,
- runCommandInBg, saddlebrown, safe, salmon, samp, sandybrown, saveAs,
- savePreferences, screen, script, scroll, scrollBy, scrollTo, seagreen,
- seal, search, seashell, select, serialize, setInterval, setTimeout,
- shift, showWidgetPreferences, sidebar, sienna, silver, skyblue,
- slateblue, slategray, sleep, slice, small, snow, sort, span, spawn,
- speak, split, springgreen, src, status, steelblue, strict, strong,
- style, styleproperty, sub, substr, sup, supplant, suppressUpdates, sync,
- system, table, "table-layout", tan, tbody, td, teal, tellWidget, test,
- "text-align", "text-decoration", "text-indent", "text-shadow",
- "text-transform", textarea, tfoot, th, thead, thistle, title,
- toLowerCase, toString, toUpperCase, toint32, token, tomato, top, tr, tt,
- turquoise, type, u, ul, undef, unescape, "unicode-bidi", unused,
- unwatch, updateNow, urls, value, valueOf, var, version,
- "vertical-align", violet, visibility, watch, wheat, white,
- "white-space", whitesmoke, widget, width, "word-spacing", "word-wrap",
- yahooCheckLogin, yahooLogin, yahooLogout, yellow, yellowgreen,
- "z-index"
-*/
-
-
-// We build the application inside a function so that we produce only a single
-// global variable. The function will be invoked, its return value is the JSLINT
-// application itself.
-
-"use strict";
-
-var JSLINT = (function () {
- var adsafe_id, // The widget's ADsafe id.
- adsafe_may, // The widget may load approved scripts.
- adsafe_went, // ADSAFE.go has been called.
- anonname, // The guessed name for anonymous functions.
- approved, // ADsafe approved urls.
-
- atrule = {
- media : true,
- 'font-face': true,
- page : true
- },
-
-// These are operators that should not be used with the ! operator.
-
- bang = {
- '<': true,
- '<=': true,
- '==': true,
- '===': true,
- '!==': true,
- '!=': true,
- '>': true,
- '>=': true,
- '+': true,
- '-': true,
- '*': true,
- '/': true,
- '%': true
- },
-
-// These are members that should not be permitted in the safe subset.
-
- banned = { // the member names that ADsafe prohibits.
- 'arguments' : true,
- callee : true,
- caller : true,
- constructor : true,
- 'eval' : true,
- prototype : true,
- unwatch : true,
- valueOf : true,
- watch : true
- },
-
-
-// These are the JSLint boolean options.
-
- boolOptions = {
- adsafe : true, // if ADsafe should be enforced
- bitwise : true, // if bitwise operators should not be allowed
- browser : true, // if the standard browser globals should be predefined
- cap : true, // if upper case HTML should be allowed
- css : true, // if CSS workarounds should be tolerated
- debug : true, // if debugger statements should be allowed
- devel : true, // if logging should be allowed (console, alert, etc.)
- eqeqeq : true, // if === should be required
- evil : true, // if eval should be allowed
- forin : true, // if for in statements must filter
- fragment : true, // if HTML fragments should be allowed
- immed : true, // if immediate invocations must be wrapped in parens
- laxbreak : true, // if line breaks should not be checked
- newcap : true, // if constructor names must be capitalized
- nomen : true, // if names should be checked
- on : true, // if HTML event handlers should be allowed
- onevar : true, // if only one var statement per function should be allowed
- passfail : true, // if the scan should stop on first error
- plusplus : true, // if increment/decrement should not be allowed
- regexp : true, // if the . should not be allowed in regexp literals
- rhino : true, // if the Rhino environment globals should be predefined
- undef : true, // if variables should be declared before used
- safe : true, // if use of some browser features should be restricted
- sidebar : true, // if the System object should be predefined
- strict : true, // require the "use strict"; pragma
- sub : true, // if all forms of subscript notation are tolerated
- white : true, // if strict whitespace rules apply
- widget : true // if the Yahoo Widgets globals should be predefined
- },
-
-// browser contains a set of global names which are commonly provided by a
-// web browser environment.
-
- browser = {
- addEventListener: false,
- blur : false,
- clearInterval : false,
- clearTimeout : false,
- close : false,
- closed : false,
- defaultStatus : false,
- document : false,
- event : false,
- focus : false,
- frames : false,
- getComputedStyle: false,
- history : false,
- Image : false,
- length : false,
- location : false,
- moveBy : false,
- moveTo : false,
- name : false,
- navigator : false,
- onbeforeunload : true,
- onblur : true,
- onerror : true,
- onfocus : true,
- onload : true,
- onresize : true,
- onunload : true,
- open : false,
- opener : false,
- Option : false,
- parent : false,
- print : false,
- removeEventListener: false,
- resizeBy : false,
- resizeTo : false,
- screen : false,
- scroll : false,
- scrollBy : false,
- scrollTo : false,
- setInterval : false,
- setTimeout : false,
- status : false,
- top : false,
- XMLHttpRequest : false
- },
-
- cssAttributeData,
- cssAny,
-
- cssColorData = {
- "aliceblue" : true,
- "antiquewhite" : true,
- "aqua" : true,
- "aquamarine" : true,
- "azure" : true,
- "beige" : true,
- "bisque" : true,
- "black" : true,
- "blanchedalmond" : true,
- "blue" : true,
- "blueviolet" : true,
- "brown" : true,
- "burlywood" : true,
- "cadetblue" : true,
- "chartreuse" : true,
- "chocolate" : true,
- "coral" : true,
- "cornflowerblue" : true,
- "cornsilk" : true,
- "crimson" : true,
- "cyan" : true,
- "darkblue" : true,
- "darkcyan" : true,
- "darkgoldenrod" : true,
- "darkgray" : true,
- "darkgreen" : true,
- "darkkhaki" : true,
- "darkmagenta" : true,
- "darkolivegreen" : true,
- "darkorange" : true,
- "darkorchid" : true,
- "darkred" : true,
- "darksalmon" : true,
- "darkseagreen" : true,
- "darkslateblue" : true,
- "darkslategray" : true,
- "darkturquoise" : true,
- "darkviolet" : true,
- "deeppink" : true,
- "deepskyblue" : true,
- "dimgray" : true,
- "dodgerblue" : true,
- "firebrick" : true,
- "floralwhite" : true,
- "forestgreen" : true,
- "fuchsia" : true,
- "gainsboro" : true,
- "ghostwhite" : true,
- "gold" : true,
- "goldenrod" : true,
- "gray" : true,
- "green" : true,
- "greenyellow" : true,
- "honeydew" : true,
- "hotpink" : true,
- "indianred" : true,
- "indigo" : true,
- "ivory" : true,
- "khaki" : true,
- "lavender" : true,
- "lavenderblush" : true,
- "lawngreen" : true,
- "lemonchiffon" : true,
- "lightblue" : true,
- "lightcoral" : true,
- "lightcyan" : true,
- "lightgoldenrodyellow" : true,
- "lightgreen" : true,
- "lightpink" : true,
- "lightsalmon" : true,
- "lightseagreen" : true,
- "lightskyblue" : true,
- "lightslategray" : true,
- "lightsteelblue" : true,
- "lightyellow" : true,
- "lime" : true,
- "limegreen" : true,
- "linen" : true,
- "magenta" : true,
- "maroon" : true,
- "mediumaquamarine" : true,
- "mediumblue" : true,
- "mediumorchid" : true,
- "mediumpurple" : true,
- "mediumseagreen" : true,
- "mediumslateblue" : true,
- "mediumspringgreen" : true,
- "mediumturquoise" : true,
- "mediumvioletred" : true,
- "midnightblue" : true,
- "mintcream" : true,
- "mistyrose" : true,
- "moccasin" : true,
- "navajowhite" : true,
- "navy" : true,
- "oldlace" : true,
- "olive" : true,
- "olivedrab" : true,
- "orange" : true,
- "orangered" : true,
- "orchid" : true,
- "palegoldenrod" : true,
- "palegreen" : true,
- "paleturquoise" : true,
- "palevioletred" : true,
- "papayawhip" : true,
- "peachpuff" : true,
- "peru" : true,
- "pink" : true,
- "plum" : true,
- "powderblue" : true,
- "purple" : true,
- "red" : true,
- "rosybrown" : true,
- "royalblue" : true,
- "saddlebrown" : true,
- "salmon" : true,
- "sandybrown" : true,
- "seagreen" : true,
- "seashell" : true,
- "sienna" : true,
- "silver" : true,
- "skyblue" : true,
- "slateblue" : true,
- "slategray" : true,
- "snow" : true,
- "springgreen" : true,
- "steelblue" : true,
- "tan" : true,
- "teal" : true,
- "thistle" : true,
- "tomato" : true,
- "turquoise" : true,
- "violet" : true,
- "wheat" : true,
- "white" : true,
- "whitesmoke" : true,
- "yellow" : true,
- "yellowgreen" : true
- },
-
- cssBorderStyle,
- cssBreak,
-
- cssLengthData = {
- '%': true,
- 'cm': true,
- 'em': true,
- 'ex': true,
- 'in': true,
- 'mm': true,
- 'pc': true,
- 'pt': true,
- 'px': true
- },
-
- cssOverflow,
-
- devel = {
- alert : false,
- confirm : false,
- console : false,
- Debug : false,
- opera : false,
- prompt : false
- },
-
- escapes = {
- '\b': '\\b',
- '\t': '\\t',
- '\n': '\\n',
- '\f': '\\f',
- '\r': '\\r',
- '"' : '\\"',
- '/' : '\\/',
- '\\': '\\\\'
- },
-
- funct, // The current function
-
- functionicity = [
- 'closure', 'exception', 'global', 'label',
- 'outer', 'unused', 'var'
- ],
-
- functions, // All of the functions
-
- global, // The global scope
- htmltag = {
- a: {},
- abbr: {},
- acronym: {},
- address: {},
- applet: {},
- area: {empty: true, parent: ' map '},
- b: {},
- base: {empty: true, parent: ' head '},
- bdo: {},
- big: {},
- blockquote: {},
- body: {parent: ' html noframes '},
- br: {empty: true},
- button: {},
- canvas: {parent: ' body p div th td '},
- caption: {parent: ' table '},
- center: {},
- cite: {},
- code: {},
- col: {empty: true, parent: ' table colgroup '},
- colgroup: {parent: ' table '},
- dd: {parent: ' dl '},
- del: {},
- dfn: {},
- dir: {},
- div: {},
- dl: {},
- dt: {parent: ' dl '},
- em: {},
- embed: {},
- fieldset: {},
- font: {},
- form: {},
- frame: {empty: true, parent: ' frameset '},
- frameset: {parent: ' html frameset '},
- h1: {},
- h2: {},
- h3: {},
- h4: {},
- h5: {},
- h6: {},
- head: {parent: ' html '},
- html: {parent: '*'},
- hr: {empty: true},
- i: {},
- iframe: {},
- img: {empty: true},
- input: {empty: true},
- ins: {},
- kbd: {},
- label: {},
- legend: {parent: ' fieldset '},
- li: {parent: ' dir menu ol ul '},
- link: {empty: true, parent: ' head '},
- map: {},
- menu: {},
- meta: {empty: true, parent: ' head noframes noscript '},
- noframes: {parent: ' html body '},
- noscript: {parent: ' body head noframes '},
- object: {},
- ol: {},
- optgroup: {parent: ' select '},
- option: {parent: ' optgroup select '},
- p: {},
- param: {empty: true, parent: ' applet object '},
- pre: {},
- q: {},
- samp: {},
- script: {empty: true, parent: ' body div frame head iframe p pre span '},
- select: {},
- small: {},
- span: {},
- strong: {},
- style: {parent: ' head ', empty: true},
- sub: {},
- sup: {},
- table: {},
- tbody: {parent: ' table '},
- td: {parent: ' tr '},
- textarea: {},
- tfoot: {parent: ' table '},
- th: {parent: ' tr '},
- thead: {parent: ' table '},
- title: {parent: ' head '},
- tr: {parent: ' table tbody thead tfoot '},
- tt: {},
- u: {},
- ul: {},
- 'var': {}
- },
-
- ids, // HTML ids
- implied, // Implied globals
- inblock,
- indent,
- jsonmode,
- lines,
- lookahead,
- member,
- membersOnly,
- nexttoken,
- noreach,
- option,
- predefined, // Global variables defined by option
- prereg,
- prevtoken,
-
- rhino = {
- defineClass : false,
- deserialize : false,
- gc : false,
- help : false,
- load : false,
- loadClass : false,
- print : false,
- quit : false,
- readFile : false,
- readUrl : false,
- runCommand : false,
- seal : false,
- serialize : false,
- spawn : false,
- sync : false,
- toint32 : false,
- version : false
- },
-
- scope, // The current scope
-
- sidebar = {
- System : false
- },
-
- src,
- stack,
-
-// standard contains the global names that are provided by the
-// ECMAScript standard.
-
- standard = {
- Array : false,
- Boolean : false,
- Date : false,
- decodeURI : false,
- decodeURIComponent : false,
- encodeURI : false,
- encodeURIComponent : false,
- Error : false,
- 'eval' : false,
- EvalError : false,
- Function : false,
- hasOwnProperty : false,
- isFinite : false,
- isNaN : false,
- JSON : false,
- Math : false,
- Number : false,
- Object : false,
- parseInt : false,
- parseFloat : false,
- RangeError : false,
- ReferenceError : false,
- RegExp : false,
- String : false,
- SyntaxError : false,
- TypeError : false,
- URIError : false
- },
-
- standard_member = {
- E : true,
- LN2 : true,
- LN10 : true,
- LOG2E : true,
- LOG10E : true,
- PI : true,
- SQRT1_2 : true,
- SQRT2 : true,
- MAX_VALUE : true,
- MIN_VALUE : true,
- NEGATIVE_INFINITY : true,
- POSITIVE_INFINITY : true
- },
-
- strict_mode,
- syntax = {},
- tab,
- token,
- urls,
- warnings,
-
-// widget contains the global names which are provided to a Yahoo
-// (fna Konfabulator) widget.
-
- widget = {
- alert : true,
- animator : true,
- appleScript : true,
- beep : true,
- bytesToUIString : true,
- Canvas : true,
- chooseColor : true,
- chooseFile : true,
- chooseFolder : true,
- closeWidget : true,
- COM : true,
- convertPathToHFS : true,
- convertPathToPlatform : true,
- CustomAnimation : true,
- escape : true,
- FadeAnimation : true,
- filesystem : true,
- Flash : true,
- focusWidget : true,
- form : true,
- FormField : true,
- Frame : true,
- HotKey : true,
- Image : true,
- include : true,
- isApplicationRunning : true,
- iTunes : true,
- konfabulatorVersion : true,
- log : true,
- md5 : true,
- MenuItem : true,
- MoveAnimation : true,
- openURL : true,
- play : true,
- Point : true,
- popupMenu : true,
- preferenceGroups : true,
- preferences : true,
- print : true,
- prompt : true,
- random : true,
- Rectangle : true,
- reloadWidget : true,
- ResizeAnimation : true,
- resolvePath : true,
- resumeUpdates : true,
- RotateAnimation : true,
- runCommand : true,
- runCommandInBg : true,
- saveAs : true,
- savePreferences : true,
- screen : true,
- ScrollBar : true,
- showWidgetPreferences : true,
- sleep : true,
- speak : true,
- Style : true,
- suppressUpdates : true,
- system : true,
- tellWidget : true,
- Text : true,
- TextArea : true,
- Timer : true,
- unescape : true,
- updateNow : true,
- URL : true,
- Web : true,
- widget : true,
- Window : true,
- XMLDOM : true,
- XMLHttpRequest : true,
- yahooCheckLogin : true,
- yahooLogin : true,
- yahooLogout : true
- },
-
-// xmode is used to adapt to the exceptions in html parsing.
-// It can have these states:
-// false .js script file
-// html
-// outer
-// script
-// style
-// scriptstring
-// styleproperty
-
- xmode,
- xquote,
-
-// unsafe comment or string
- ax = /@cc|<\/?|script|\]*s\]|<\s*!|&lt/i,
-// unsafe characters that are silently deleted by one or more browsers
- cx = /[\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/,
-// token
- tx = /^\s*([(){}\[.,:;'"~\?\]#@]|==?=?|\/(\*(jslint|members?|global)?|=|\/)?|\*[\/=]?|\+[+=]?|-[\-=]?|%=?|&[&=]?|\|[|=]?|>>?>?=?|<([\/=!]|\!(\[|--)?|<=?)?|\^=?|\!=?=?|[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+([xX][0-9a-fA-F]+|\.[0-9]*)?([eE][+\-]?[0-9]+)?)/,
-// html token
-//////// hx = /^\s*(['"=>\/&#]|<(?:\/|\!(?:--)?)?|[a-zA-Z][a-zA-Z0-9_\-]*|[0-9]+|--|.)/,
- hx = /^\s*(['"=>\/&#]|<(?:\/|\!(?:--)?)?|[a-zA-Z][a-zA-Z0-9_\-]*|[0-9]+|--)/,
-// characters in strings that need escapement
- nx = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/,
- nxg = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
-// outer html token
- ox = /[>&]|<[\/!]?|--/,
-// star slash
- lx = /\*\/|\/\*/,
-// identifier
- ix = /^([a-zA-Z_$][a-zA-Z0-9_$]*)$/,
-// javascript url
- jx = /^(?:javascript|jscript|ecmascript|vbscript|mocha|livescript)\s*:/i,
-// url badness
- ux = /&|\+|\u00AD|\.\.|\/\*|%[^;]|base64|url|expression|data|mailto/i,
-// style
- sx = /^\s*([{:#%.=,>+\[\]@()"';]|\*=?|\$=|\|=|\^=|~=|[a-zA-Z_][a-zA-Z0-9_\-]*|[0-9]+|<\/|\/\*)/,
- ssx = /^\s*([@#!"'};:\-%.=,+\[\]()*_]|[a-zA-Z][a-zA-Z0-9._\-]*|\/\*?|\d+(?:\.\d+)?|<\/)/,
-// attributes characters
- qx = /[^a-zA-Z0-9-_\/ ]/,
-// query characters for ids
- dx = /[\[\]\/\\"'*<>.&:(){}+=#]/,
-
- rx = {
- outer: hx,
- html: hx,
- style: sx,
- styleproperty: ssx
- };
-
- function F() {}
-
- if (typeof Object.create !== 'function') {
- Object.create = function (o) {
- F.prototype = o;
- return new F();
- };
- }
-
-
- function is_own(object, name) {
- return Object.prototype.hasOwnProperty.call(object, name);
- }
-
-
- function combine(t, o) {
- var n;
- for (n in o) {
- if (is_own(o, n)) {
- t[n] = o[n];
- }
- }
- }
-
- String.prototype.entityify = function () {
- return this.
- replace(/&/g, '&amp;').
- replace(/</g, '&lt;').
- replace(/>/g, '&gt;');
- };
-
- String.prototype.isAlpha = function () {
- return (this >= 'a' && this <= 'z\uffff') ||
- (this >= 'A' && this <= 'Z\uffff');
- };
-
-
- String.prototype.isDigit = function () {
- return (this >= '0' && this <= '9');
- };
-
-
- String.prototype.supplant = function (o) {
- return this.replace(/\{([^{}]*)\}/g, function (a, b) {
- var r = o[b];
- return typeof r === 'string' || typeof r === 'number' ? r : a;
- });
- };
-
- String.prototype.name = function () {
-
-// If the string looks like an identifier, then we can return it as is.
-// If the string contains no control characters, no quote characters, and no
-// backslash characters, then we can simply slap some quotes around it.
-// Otherwise we must also replace the offending characters with safe
-// sequences.
-
- if (ix.test(this)) {
- return this;
- }
- if (nx.test(this)) {
- return '"' + this.replace(nxg, function (a) {
- var c = escapes[a];
- if (c) {
- return c;
- }
- return '\\u' + ('0000' + a.charCodeAt().toString(16)).slice(-4);
- }) + '"';
- }
- return '"' + this + '"';
- };
-
-
- function assume() {
- if (!option.safe) {
- if (option.rhino) {
- combine(predefined, rhino);
- }
- if (option.devel) {
- combine(predefined, devel);
- }
- if (option.browser || option.sidebar) {
- combine(predefined, browser);
- }
- if (option.sidebar) {
- combine(predefined, sidebar);
- }
- if (option.widget) {
- combine(predefined, widget);
- }
- }
- }
-
-
-// Produce an error warning.
-
- function quit(m, l, ch) {
- throw {
- name: 'JSLintError',
- line: l,
- character: ch,
- message: m + " (" + Math.floor((l / lines.length) * 100) +
- "% scanned)."
- };
- }
-
- function warning(m, t, a, b, c, d) {
- var ch, l, w;
- t = t || nexttoken;
- if (t.id === '(end)') { // `~
- t = token;
- }
- l = t.line || 0;
- ch = t.from || 0;
- w = {
- id: '(error)',
- raw: m,
- evidence: lines[l - 1] || '',
- line: l,
- character: ch,
- a: a,
- b: b,
- c: c,
- d: d
- };
- w.reason = m.supplant(w);
- JSLINT.errors.push(w);
- if (option.passfail) {
- quit('Stopping. ', l, ch);
- }
- warnings += 1;
- if (warnings >= option.maxerr) {
- quit("Too many errors.", l, ch);
- }
- return w;
- }
-
- function warningAt(m, l, ch, a, b, c, d) {
- return warning(m, {
- line: l,
- from: ch
- }, a, b, c, d);
- }
-
- function error(m, t, a, b, c, d) {
- var w = warning(m, t, a, b, c, d);
- quit("Stopping, unable to continue.", w.line, w.character);
- }
-
- function errorAt(m, l, ch, a, b, c, d) {
- return error(m, {
- line: l,
- from: ch
- }, a, b, c, d);
- }
-
-
-
-// lexical analysis
-
- var lex = (function lex() {
- var character, from, line, s;
-
-// Private lex methods
-
- function nextLine() {
- var at;
- if (line >= lines.length) {
- return false;
- }
- character = 1;
- s = lines[line];
- line += 1;
- at = s.search(/ \t/);
- if (at >= 0) {
- warningAt("Mixed spaces and tabs.", line, at + 1);
- }
- s = s.replace(/\t/g, tab);
- at = s.search(cx);
- if (at >= 0) {
- warningAt("Unsafe character.", line, at);
- }
- if (option.maxlen && option.maxlen < s.length) {
- warningAt("Line too long.", line, s.length);
- }
- return true;
- }
-
-// Produce a token object. The token inherits from a syntax symbol.
-
- function it(type, value) {
- var i, t;
- if (type === '(color)') {
- t = {type: type};
- } else if (type === '(punctuator)' ||
- (type === '(identifier)' && is_own(syntax, value))) {
- t = syntax[value] || syntax['(error)'];
- } else {
- t = syntax[type];
- }
- t = Object.create(t);
- if (type === '(string)' || type === '(range)') {
- if (jx.test(value)) {
- warningAt("Script URL.", line, from);
- }
- }
- if (type === '(identifier)') {
- t.identifier = true;
- if (value === '__iterator__' || value === '__proto__') {
- errorAt("Reserved name '{a}'.",
- line, from, value);
- } else if (option.nomen &&
- (value.charAt(0) === '_' ||
- value.charAt(value.length - 1) === '_')) {
- warningAt("Unexpected {a} in '{b}'.", line, from,
- "dangling '_'", value);
- }
- }
- t.value = value;
- t.line = line;
- t.character = character;
- t.from = from;
- i = t.id;
- if (i !== '(endline)') {
- prereg = i &&
- (('(,=:[!&|?{};'.indexOf(i.charAt(i.length - 1)) >= 0) ||
- i === 'return');
- }
- return t;
- }
-
-// Public lex methods
-
- return {
- init: function (source) {
- if (typeof source === 'string') {
- lines = source.
- replace(/\r\n/g, '\n').
- replace(/\r/g, '\n').
- split('\n');
- } else {
- lines = source;
- }
- line = 0;
- nextLine();
- from = 1;
- },
-
- range: function (begin, end) {
- var c, value = '';
- from = character;
- if (s.charAt(0) !== begin) {
- errorAt("Expected '{a}' and instead saw '{b}'.",
- line, character, begin, s.charAt(0));
- }
- for (;;) {
- s = s.slice(1);
- character += 1;
- c = s.charAt(0);
- switch (c) {
- case '':
- errorAt("Missing '{a}'.", line, character, c);
- break;
- case end:
- s = s.slice(1);
- character += 1;
- return it('(range)', value);
- case xquote:
- case '\\':
- warningAt("Unexpected '{a}'.", line, character, c);
- }
- value += c;
- }
-
- },
-
-// token -- this is called by advance to get the next token.
-
- token: function () {
- var b, c, captures, d, depth, high, i, l, low, q, t;
-
- function match(x) {
- var r = x.exec(s), r1;
- if (r) {
- l = r[0].length;
- r1 = r[1];
- c = r1.charAt(0);
- s = s.substr(l);
- from = character + l - r1.length;
- character += l;
- return r1;
- }
- }
-
- function string(x) {
- var c, j, r = '';
-
- if (jsonmode && x !== '"') {
- warningAt("Strings must use doublequote.",
- line, character);
- }
-
- if (xquote === x || (xmode === 'scriptstring' && !xquote)) {
- return it('(punctuator)', x);
- }
-
- function esc(n) {
- var i = parseInt(s.substr(j + 1, n), 16);
- j += n;
- if (i >= 32 && i <= 126 &&
- i !== 34 && i !== 92 && i !== 39) {
- warningAt("Unnecessary escapement.", line, character);
- }
- character += n;
- c = String.fromCharCode(i);
- }
- j = 0;
- for (;;) {
- while (j >= s.length) {
- j = 0;
- if (xmode !== 'html' || !nextLine()) {
- errorAt("Unclosed string.", line, from);
- }
- }
- c = s.charAt(j);
- if (c === x) {
- character += 1;
- s = s.substr(j + 1);
- return it('(string)', r, x);
- }
- if (c < ' ') {
- if (c === '\n' || c === '\r') {
- break;
- }
- warningAt("Control character in string: {a}.",
- line, character + j, s.slice(0, j));
- } else if (c === xquote) {
- warningAt("Bad HTML string", line, character + j);
- } else if (c === '<') {
- if (option.safe && xmode === 'html') {
- warningAt("ADsafe string violation.",
- line, character + j);
- } else if (s.charAt(j + 1) === '/' && (xmode || option.safe)) {
- warningAt("Expected '<\\/' and instead saw '</'.", line, character);
- } else if (s.charAt(j + 1) === '!' && (xmode || option.safe)) {
- warningAt("Unexpected '<!' in a string.", line, character);
- }
- } else if (c === '\\') {
- if (xmode === 'html') {
- if (option.safe) {
- warningAt("ADsafe string violation.",
- line, character + j);
- }
- } else if (xmode === 'styleproperty') {
- j += 1;
- character += 1;
- c = s.charAt(j);
- if (c !== x) {
- warningAt("Escapement in style string.",
- line, character + j);
- }
- } else {
- j += 1;
- character += 1;
- c = s.charAt(j);
- switch (c) {
- case xquote:
- warningAt("Bad HTML string", line,
- character + j);
- break;
- case '\\':
- case '\'':
- case '"':
- case '/':
- break;
- case 'b':
- c = '\b';
- break;
- case 'f':
- c = '\f';
- break;
- case 'n':
- c = '\n';
- break;
- case 'r':
- c = '\r';
- break;
- case 't':
- c = '\t';
- break;
- case 'u':
- esc(4);
- break;
- case 'v':
- c = '\v';
- break;
- case 'x':
- if (jsonmode) {
- warningAt("Avoid \\x-.", line, character);
- }
- esc(2);
- break;
- default:
- warningAt("Bad escapement.", line, character);
- }
- }
- }
- r += c;
- character += 1;
- j += 1;
- }
- }
-
- for (;;) {
- if (!s) {
- return it(nextLine() ? '(endline)' : '(end)', '');
- }
- while (xmode === 'outer') {
- i = s.search(ox);
- if (i === 0) {
- break;
- } else if (i > 0) {
- character += 1;
- s = s.slice(i);
- break;
- } else {
- if (!nextLine()) {
- return it('(end)', '');
- }
- }
- }
-// t = match(rx[xmode] || tx);
-// if (!t) {
-// if (xmode === 'html') {
-// return it('(error)', s.charAt(0));
-// } else {
-// t = '';
-// c = '';
-// while (s && s < '!') {
-// s = s.substr(1);
-// }
-// if (s) {
-// errorAt("Unexpected '{a}'.",
-// line, character, s.substr(0, 1));
-// }
-// }
- t = match(rx[xmode] || tx);
- if (!t) {
- t = '';
- c = '';
- while (s && s < '!') {
- s = s.substr(1);
- }
- if (s) {
- if (xmode === 'html') {
- return it('(error)', s.charAt(0));
- } else {
- errorAt("Unexpected '{a}'.",
- line, character, s.substr(0, 1));
- }
- }
- } else {
-
- // identifier
-
- if (c.isAlpha() || c === '_' || c === '$') {
- return it('(identifier)', t);
- }
-
- // number
-
- if (c.isDigit()) {
- if (xmode !== 'style' && !isFinite(Number(t))) {
- warningAt("Bad number '{a}'.",
- line, character, t);
- }
- if (xmode !== 'style' &&
- xmode !== 'styleproperty' &&
- s.substr(0, 1).isAlpha()) {
- warningAt("Missing space after '{a}'.",
- line, character, t);
- }
- if (c === '0') {
- d = t.substr(1, 1);
- if (d.isDigit()) {
- if (token.id !== '.' && xmode !== 'styleproperty') {
- warningAt("Don't use extra leading zeros '{a}'.",
- line, character, t);
- }
- } else if (jsonmode && (d === 'x' || d === 'X')) {
- warningAt("Avoid 0x-. '{a}'.",
- line, character, t);
- }
- }
- if (t.substr(t.length - 1) === '.') {
- warningAt(
- "A trailing decimal point can be confused with a dot '{a}'.",
- line, character, t);
- }
- return it('(number)', t);
- }
- switch (t) {
-
- // string
-
- case '"':
- case "'":
- return string(t);
-
- // // comment
-
- case '//':
- if (src || (xmode && xmode !== 'script')) {
- warningAt("Unexpected comment.", line, character);
- } else if (xmode === 'script' && /<\s*\//i.test(s)) {
- warningAt("Unexpected <\/ in comment.", line, character);
- } else if ((option.safe || xmode === 'script') && ax.test(s)) {
- warningAt("Dangerous comment.", line, character);
- }
- s = '';
- token.comment = true;
- break;
-
- // /* comment
-
- case '/*':
- if (src || (xmode && xmode !== 'script' && xmode !== 'style' && xmode !== 'styleproperty')) {
- warningAt("Unexpected comment.", line, character);
- }
- if (option.safe && ax.test(s)) {
- warningAt("ADsafe comment violation.", line, character);
- }
- for (;;) {
- i = s.search(lx);
- if (i >= 0) {
- break;
- }
- if (!nextLine()) {
- errorAt("Unclosed comment.", line, character);
- } else {
- if (option.safe && ax.test(s)) {
- warningAt("ADsafe comment violation.", line, character);
- }
- }
- }
- character += i + 2;
- if (s.substr(i, 1) === '/') {
- errorAt("Nested comment.", line, character);
- }
- s = s.substr(i + 2);
- token.comment = true;
- break;
-
- // /*members /*jslint /*global
-
- case '/*members':
- case '/*member':
- case '/*jslint':
- case '/*global':
- case '*/':
- return {
- value: t,
- type: 'special',
- line: line,
- character: character,
- from: from
- };
-
- case '':
- break;
- // /
- case '/':
- if (token.id === '/=') {
- errorAt(
-"A regular expression literal can be confused with '/='.", line, from);
- }
- if (prereg) {
- depth = 0;
- captures = 0;
- l = 0;
- for (;;) {
- b = true;
- c = s.charAt(l);
- l += 1;
- switch (c) {
- case '':
- errorAt("Unclosed regular expression.", line, from);
- return;
- case '/':
- if (depth > 0) {
- warningAt("Unescaped '{a}'.", line, from + l, '/');
- }
- c = s.substr(0, l - 1);
- q = {
- g: true,
- i: true,
- m: true
- };
- while (q[s.charAt(l)] === true) {
- q[s.charAt(l)] = false;
- l += 1;
- }
- character += l;
- s = s.substr(l);
- q = s.charAt(0);
- if (q === '/' || q === '*') {
- errorAt("Confusing regular expression.", line, from);
- }
- return it('(regexp)', c);
- case '\\':
- c = s.charAt(l);
- if (c < ' ') {
- warningAt("Unexpected control character in regular expression.", line, from + l);
- } else if (c === '<') {
- warningAt("Unexpected escaped character '{a}' in regular expression.", line, from + l, c);
- }
- l += 1;
- break;
- case '(':
- depth += 1;
- b = false;
- if (s.charAt(l) === '?') {
- l += 1;
- switch (s.charAt(l)) {
- case ':':
- case '=':
- case '!':
- l += 1;
- break;
- default:
- warningAt("Expected '{a}' and instead saw '{b}'.", line, from + l, ':', s.charAt(l));
- }
- } else {
- captures += 1;
- }
- break;
- case '|':
- b = false;
- break;
- case ')':
- if (depth === 0) {
- warningAt("Unescaped '{a}'.", line, from + l, ')');
- } else {
- depth -= 1;
- }
- break;
- case ' ':
- q = 1;
- while (s.charAt(l) === ' ') {
- l += 1;
- q += 1;
- }
- if (q > 1) {
- warningAt("Spaces are hard to count. Use {{a}}.", line, from + l, q);
- }
- break;
- case '[':
- c = s.charAt(l);
- if (c === '^') {
- l += 1;
- if (option.regexp) {
- warningAt("Insecure '{a}'.", line, from + l, c);
- }
- }
- q = false;
- if (c === ']') {
- warningAt("Empty class.", line, from + l - 1);
- q = true;
- }
- klass: do {
- c = s.charAt(l);
- l += 1;
- switch (c) {
- case '[':
- case '^':
- warningAt("Unescaped '{a}'.", line, from + l, c);
- q = true;
- break;
- case '-':
- if (q) {
- q = false;
- } else {
- warningAt("Unescaped '{a}'.", line, from + l, '-');
- q = true;
- }
- break;
- case ']':
- if (!q) {
- warningAt("Unescaped '{a}'.", line, from + l - 1, '-');
- }
- break klass;
- case '\\':
- c = s.charAt(l);
- if (c < ' ') {
- warningAt("Unexpected control character in regular expression.", line, from + l);
- } else if (c === '<') {
- warningAt("Unexpected escaped character '{a}' in regular expression.", line, from + l, c);
- }
- l += 1;
- q = true;
- break;
- case '/':
- warningAt("Unescaped '{a}'.", line, from + l - 1, '/');
- q = true;
- break;
- case '<':
- if (xmode === 'script') {
- c = s.charAt(l);
- if (c === '!' || c === '/') {
- warningAt("HTML confusion in regular expression '<{a}'.", line, from + l, c);
- }
- }
- q = true;
- break;
- default:
- q = true;
- }
- } while (c);
- break;
- case '.':
- if (option.regexp) {
- warningAt("Insecure '{a}'.", line, from + l, c);
- }
- break;
- case ']':
- case '?':
- case '{':
- case '}':
- case '+':
- case '*':
- warningAt("Unescaped '{a}'.", line, from + l, c);
- break;
- case '<':
- if (xmode === 'script') {
- c = s.charAt(l);
- if (c === '!' || c === '/') {
- warningAt("HTML confusion in regular expression '<{a}'.", line, from + l, c);
- }
- }
- }
- if (b) {
- switch (s.charAt(l)) {
- case '?':
- case '+':
- case '*':
- l += 1;
- if (s.charAt(l) === '?') {
- l += 1;
- }
- break;
- case '{':
- l += 1;
- c = s.charAt(l);
- if (c < '0' || c > '9') {
- warningAt("Expected a number and instead saw '{a}'.", line, from + l, c);
- }
- l += 1;
- low = +c;
- for (;;) {
- c = s.charAt(l);
- if (c < '0' || c > '9') {
- break;
- }
- l += 1;
- low = +c + (low * 10);
- }
- high = low;
- if (c === ',') {
- l += 1;
- high = Infinity;
- c = s.charAt(l);
- if (c >= '0' && c <= '9') {
- l += 1;
- high = +c;
- for (;;) {
- c = s.charAt(l);
- if (c < '0' || c > '9') {
- break;
- }
- l += 1;
- high = +c + (high * 10);
- }
- }
- }
- if (s.charAt(l) !== '}') {
- warningAt("Expected '{a}' and instead saw '{b}'.", line, from + l, '}', c);
- } else {
- l += 1;
- }
- if (s.charAt(l) === '?') {
- l += 1;
- }
- if (low > high) {
- warningAt("'{a}' should not be greater than '{b}'.", line, from + l, low, high);
- }
- }
- }
- }
- c = s.substr(0, l - 1);
- character += l;
- s = s.substr(l);
- return it('(regexp)', c);
- }
- return it('(punctuator)', t);
-
- // punctuator
-
- case '<!--':
- l = line;
- c = character;
- for (;;) {
- i = s.indexOf('--');
- if (i >= 0) {
- break;
- }
- i = s.indexOf('<!');
- if (i >= 0) {
- errorAt("Nested HTML comment.",
- line, character + i);
- }
- if (!nextLine()) {
- errorAt("Unclosed HTML comment.", l, c);
- }
- }
- l = s.indexOf('<!');
- if (l >= 0 && l < i) {
- errorAt("Nested HTML comment.",
- line, character + l);
- }
- character += i;
- if (s[i + 2] !== '>') {
- errorAt("Expected -->.", line, character);
- }
- character += 3;
- s = s.slice(i + 3);
- break;
- case '#':
- if (xmode === 'html' || xmode === 'styleproperty') {
- for (;;) {
- c = s.charAt(0);
- if ((c < '0' || c > '9') &&
- (c < 'a' || c > 'f') &&
- (c < 'A' || c > 'F')) {
- break;
- }
- character += 1;
- s = s.substr(1);
- t += c;
- }
- if (t.length !== 4 && t.length !== 7) {
- warningAt("Bad hex color '{a}'.", line,
- from + l, t);
- }
- return it('(color)', t);
- }
- return it('(punctuator)', t);
- default:
- if (xmode === 'outer' && c === '&') {
- character += 1;
- s = s.substr(1);
- for (;;) {
- c = s.charAt(0);
- character += 1;
- s = s.substr(1);
- if (c === ';') {
- break;
- }
- if (!((c >= '0' && c <= '9') ||
- (c >= 'a' && c <= 'z') ||
- c === '#')) {
- errorAt("Bad entity", line, from + l,
- character);
- }
- }
- break;
- }
- return it('(punctuator)', t);
- }
- }
- }
- }
- };
- }());
-
-
- function addlabel(t, type) {
-
- if (option.safe && funct['(global)'] && typeof predefined[t] !== 'boolean') {
- warning('ADsafe global: ' + t + '.', token);
- } else if (t === 'hasOwnProperty') {
- warning("'hasOwnProperty' is a really bad name.");
- }
-
-// Define t in the current function in the current scope.
-
- if (is_own(funct, t) && !funct['(global)']) {
- warning(funct[t] === true ?
- "'{a}' was used before it was defined." :
- "'{a}' is already defined.",
- nexttoken, t);
- }
- funct[t] = type;
- if (funct['(global)']) {
- global[t] = funct;
- if (is_own(implied, t)) {
- warning("'{a}' was used before it was defined.", nexttoken, t);
- delete implied[t];
- }
- } else {
- scope[t] = funct;
- }
- }
-
-
- function doOption() {
- var b, obj, filter, o = nexttoken.value, t, v;
- switch (o) {
- case '*/':
- error("Unbegun comment.");
- break;
- case '/*members':
- case '/*member':
- o = '/*members';
- if (!membersOnly) {
- membersOnly = {};
- }
- obj = membersOnly;
- break;
- case '/*jslint':
- if (option.safe) {
- warning("ADsafe restriction.");
- }
- obj = option;
- filter = boolOptions;
- break;
- case '/*global':
- if (option.safe) {
- warning("ADsafe restriction.");
- }
- obj = predefined;
- break;
- default:
- }
- t = lex.token();
-loop: for (;;) {
- for (;;) {
- if (t.type === 'special' && t.value === '*/') {
- break loop;
- }
- if (t.id !== '(endline)' && t.id !== ',') {
- break;
- }
- t = lex.token();
- }
- if (t.type !== '(string)' && t.type !== '(identifier)' &&
- o !== '/*members') {
- error("Bad option.", t);
- }
- v = lex.token();
- if (v.id === ':') {
- v = lex.token();
- if (obj === membersOnly) {
- error("Expected '{a}' and instead saw '{b}'.",
- t, '*/', ':');
- }
- if (t.value === 'indent' && o === '/*jslint') {
- b = +v.value;
- if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
- Math.floor(b) !== b) {
- error("Expected a small integer and instead saw '{a}'.",
- v, v.value);
- }
- obj.white = true;
- obj.indent = b;
- } else if (t.value === 'maxerr' && o === '/*jslint') {
- b = +v.value;
- if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
- Math.floor(b) !== b) {
- error("Expected a small integer and instead saw '{a}'.",
- v, v.value);
- }
- obj.maxerr = b;
- } else if (t.value === 'maxlen' && o === '/*jslint') {
- b = +v.value;
- if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
- Math.floor(b) !== b) {
- error("Expected a small integer and instead saw '{a}'.",
- v, v.value);
- }
- obj.maxlen = b;
- } else if (v.value === 'true') {
- obj[t.value] = true;
- } else if (v.value === 'false') {
- obj[t.value] = false;
- } else {
- error("Bad option value.", v);
- }
- t = lex.token();
- } else {
- if (o === '/*jslint') {
- error("Missing option value.", t);
- }
- obj[t.value] = false;
- t = v;
- }
- }
- if (filter) {
- assume();
- }
- }
-
-
-// We need a peek function. If it has an argument, it peeks that much farther
-// ahead. It is used to distinguish
-// for ( var i in ...
-// from
-// for ( var i = ...
-
- function peek(p) {
- var i = p || 0, j = 0, t;
-
- while (j <= i) {
- t = lookahead[j];
- if (!t) {
- t = lookahead[j] = lex.token();
- }
- j += 1;
- }
- return t;
- }
-
-
-
-// Produce the next token. It looks for programming errors.
-
- function advance(id, t) {
- switch (token.id) {
- case '(number)':
- if (nexttoken.id === '.') {
- warning(
-"A dot following a number can be confused with a decimal point.", token);
- }
- break;
- case '-':
- if (nexttoken.id === '-' || nexttoken.id === '--') {
- warning("Confusing minusses.");
- }
- break;
- case '+':
- if (nexttoken.id === '+' || nexttoken.id === '++') {
- warning("Confusing plusses.");
- }
- break;
- }
- if (token.type === '(string)' || token.identifier) {
- anonname = token.value;
- }
-
- if (id && nexttoken.id !== id) {
- if (t) {
- if (nexttoken.id === '(end)') {
- warning("Unmatched '{a}'.", t, t.id);
- } else {
- warning("Expected '{a}' to match '{b}' from line {c} and instead saw '{d}'.",
- nexttoken, id, t.id, t.line, nexttoken.value);
- }
- } else if (nexttoken.type !== '(identifier)' ||
- nexttoken.value !== id) {
- warning("Expected '{a}' and instead saw '{b}'.",
- nexttoken, id, nexttoken.value);
- }
- }
- prevtoken = token;
- token = nexttoken;
- for (;;) {
- nexttoken = lookahead.shift() || lex.token();
- if (nexttoken.id === '(end)' || nexttoken.id === '(error)') {
- return;
- }
- if (nexttoken.type === 'special') {
- doOption();
- } else {
- if (nexttoken.id !== '(endline)') {
- break;
- }
- }
- }
- }
-
-
-// This is the heart of JSLINT, the Pratt parser. In addition to parsing, it
-// is looking for ad hoc lint patterns. We add to Pratt's model .fud, which is
-// like nud except that it is only used on the first token of a statement.
-// Having .fud makes it much easier to define JavaScript. I retained Pratt's
-// nomenclature.
-
-// .nud Null denotation
-// .fud First null denotation
-// .led Left denotation
-// lbp Left binding power
-// rbp Right binding power
-
-// They are key to the parsing method called Top Down Operator Precedence.
-
- function parse(rbp, initial) {
- var left;
- if (nexttoken.id === '(end)') {
- error("Unexpected early end of program.", token);
- }
- advance();
- if (option.safe && typeof predefined[token.value] === 'boolean' &&
- (nexttoken.id !== '(' && nexttoken.id !== '.')) {
- warning('ADsafe violation.', token);
- }
- if (initial) {
- anonname = 'anonymous';
- funct['(verb)'] = token.value;
- }
- if (initial === true && token.fud) {
- left = token.fud();
- } else {
- if (token.nud) {
- left = token.nud();
- } else {
- if (nexttoken.type === '(number)' && token.id === '.') {
- warning(
-"A leading decimal point can be confused with a dot: '.{a}'.",
- token, nexttoken.value);
- advance();
- return token;
- } else {
- error("Expected an identifier and instead saw '{a}'.",
- token, token.id);
- }
- }
- while (rbp < nexttoken.lbp) {
- advance();
- if (token.led) {
- left = token.led(left);
- } else {
- error("Expected an operator and instead saw '{a}'.",
- token, token.id);
- }
- }
- }
- return left;
- }
-
-
-// Functions for conformance of style.
-
- function adjacent(left, right) {
- left = left || token;
- right = right || nexttoken;
- if (option.white || xmode === 'styleproperty' || xmode === 'style') {
- if (left.character !== right.from && left.line === right.line) {
- warning("Unexpected space after '{a}'.", right, left.value);
- }
- }
- }
-
- function nospace(left, right) {
- left = left || token;
- right = right || nexttoken;
- if (option.white && !left.comment) {
- if (left.line === right.line) {
- adjacent(left, right);
- }
- }
- }
-
-
- function nonadjacent(left, right) {
- if (option.white) {
- left = left || token;
- right = right || nexttoken;
- if (left.line === right.line && left.character === right.from) {
- warning("Missing space after '{a}'.",
- nexttoken, left.value);
- }
- }
- }
-
- function nobreaknonadjacent(left, right) {
- left = left || token;
- right = right || nexttoken;
- if (!option.laxbreak && left.line !== right.line) {
- warning("Bad line breaking before '{a}'.", right, right.id);
- } else if (option.white) {
- left = left || token;
- right = right || nexttoken;
- if (left.character === right.from) {
- warning("Missing space after '{a}'.",
- nexttoken, left.value);
- }
- }
- }
-
- function indentation(bias) {
- var i;
- if (option.white && nexttoken.id !== '(end)') {
- i = indent + (bias || 0);
- if (nexttoken.from !== i) {
- warning("Expected '{a}' to have an indentation at {b} instead at {c}.",
- nexttoken, nexttoken.value, i, nexttoken.from);
- }
- }
- }
-
- function nolinebreak(t) {
- t = t || token;
- if (t.line !== nexttoken.line) {
- warning("Line breaking error '{a}'.", t, t.value);
- }
- }
-
-
- function comma() {
- if (token.line !== nexttoken.line) {
- if (!option.laxbreak) {
- warning("Bad line breaking before '{a}'.", token, nexttoken.id);
- }
- } else if (token.character !== nexttoken.from && option.white) {
- warning("Unexpected space after '{a}'.", nexttoken, token.value);
- }
- advance(',');
- nonadjacent(token, nexttoken);
- }
-
-
-// Functional constructors for making the symbols that will be inherited by
-// tokens.
-
- function symbol(s, p) {
- var x = syntax[s];
- if (!x || typeof x !== 'object') {
- syntax[s] = x = {
- id: s,
- lbp: p,
- value: s
- };
- }
- return x;
- }
-
-
- function delim(s) {
- return symbol(s, 0);
- }
-
-
- function stmt(s, f) {
- var x = delim(s);
- x.identifier = x.reserved = true;
- x.fud = f;
- return x;
- }
-
-
- function blockstmt(s, f) {
- var x = stmt(s, f);
- x.block = true;
- return x;
- }
-
-
- function reserveName(x) {
- var c = x.id.charAt(0);
- if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
- x.identifier = x.reserved = true;
- }
- return x;
- }
-
-
- function prefix(s, f) {
- var x = symbol(s, 150);
- reserveName(x);
- x.nud = (typeof f === 'function') ? f : function () {
- this.right = parse(150);
- this.arity = 'unary';
- if (this.id === '++' || this.id === '--') {
- if (option.plusplus) {
- warning("Unexpected use of '{a}'.", this, this.id);
- } else if ((!this.right.identifier || this.right.reserved) &&
- this.right.id !== '.' && this.right.id !== '[') {
- warning("Bad operand.", this);
- }
- }
- return this;
- };
- return x;
- }
-
-
- function type(s, f) {
- var x = delim(s);
- x.type = s;
- x.nud = f;
- return x;
- }
-
-
- function reserve(s, f) {
- var x = type(s, f);
- x.identifier = x.reserved = true;
- return x;
- }
-
-
- function reservevar(s, v) {
- return reserve(s, function () {
- if (this.id === 'this' || this.id === 'arguments') {
- if (strict_mode && funct['(global)']) {
- warning("Strict violation.", this);
- } else if (option.safe) {
- warning("ADsafe violation.", this);
- }
- }
- return this;
- });
- }
-
-
- function infix(s, f, p, w) {
- var x = symbol(s, p);
- reserveName(x);
- x.led = function (left) {
- if (!w) {
- nobreaknonadjacent(prevtoken, token);
- nonadjacent(token, nexttoken);
- }
- if (typeof f === 'function') {
- return f(left, this);
- } else {
- this.left = left;
- this.right = parse(p);
- return this;
- }
- };
- return x;
- }
-
-
- function relation(s, f) {
- var x = symbol(s, 100);
- x.led = function (left) {
- nobreaknonadjacent(prevtoken, token);
- nonadjacent(token, nexttoken);
- var right = parse(100);
- if ((left && left.id === 'NaN') || (right && right.id === 'NaN')) {
- warning("Use the isNaN function to compare with NaN.", this);
- } else if (f) {
- f.apply(this, [left, right]);
- }
- if (left.id === '!') {
- warning("Confusing use of '{a}'.", left, '!');
- }
- if (right.id === '!') {
- warning("Confusing use of '{a}'.", left, '!');
- }
- this.left = left;
- this.right = right;
- return this;
- };
- return x;
- }
-
-
- function isPoorRelation(node) {
- return node &&
- ((node.type === '(number)' && +node.value === 0) ||
- (node.type === '(string)' && node.value === ' ') ||
- node.type === 'true' ||
- node.type === 'false' ||
- node.type === 'undefined' ||
- node.type === 'null');
- }
-
-
- function assignop(s, f) {
- symbol(s, 20).exps = true;
- return infix(s, function (left, that) {
- var l;
- that.left = left;
- if (predefined[left.value] === false &&
- scope[left.value]['(global)'] === true) {
- warning('Read only.', left);
- }
- if (option.safe) {
- l = left;
- do {
- if (typeof predefined[l.value] === 'boolean') {
- warning('ADsafe violation.', l);
- }
- l = l.left;
- } while (l);
- }
- if (left) {
- if (left.id === '.' || left.id === '[') {
- if (!left.left || left.left.value === 'arguments') {
- warning('Bad assignment.', that);
- }
- that.right = parse(19);
- return that;
- } else if (left.identifier && !left.reserved) {
- if (funct[left.value] === 'exception') {
- warning("Do not assign to the exception parameter.", left);
- }
- that.right = parse(19);
- return that;
- }
- if (left === syntax['function']) {
- warning(
-"Expected an identifier in an assignment and instead saw a function invocation.",
- token);
- }
- }
- error("Bad assignment.", that);
- }, 20);
- }
-
- function bitwise(s, f, p) {
- var x = symbol(s, p);
- reserveName(x);
- x.led = (typeof f === 'function') ? f : function (left) {
- if (option.bitwise) {
- warning("Unexpected use of '{a}'.", this, this.id);
- }
- this.left = left;
- this.right = parse(p);
- return this;
- };
- return x;
- }
-
- function bitwiseassignop(s) {
- symbol(s, 20).exps = true;
- return infix(s, function (left, that) {
- if (option.bitwise) {
- warning("Unexpected use of '{a}'.", that, that.id);
- }
- nonadjacent(prevtoken, token);
- nonadjacent(token, nexttoken);
- if (left) {
- if (left.id === '.' || left.id === '[' ||
- (left.identifier && !left.reserved)) {
- parse(19);
- return that;
- }
- if (left === syntax['function']) {
- warning(
-"Expected an identifier in an assignment, and instead saw a function invocation.",
- token);
- }
- return that;
- }
- error("Bad assignment.", that);
- }, 20);
- }
-
-
- function suffix(s, f) {
- var x = symbol(s, 150);
- x.led = function (left) {
- if (option.plusplus) {
- warning("Unexpected use of '{a}'.", this, this.id);
- } else if ((!left.identifier || left.reserved) && left.id !== '.' && left.id !== '[') {
- warning("Bad operand.", this);
- }
- this.left = left;
- return this;
- };
- return x;
- }
-
-
- function optionalidentifier() {
- if (nexttoken.reserved) {
- warning("Expected an identifier and instead saw '{a}' (a reserved word).",
- nexttoken, nexttoken.id);
- }
- if (nexttoken.identifier) {
- advance();
- return token.value;
- }
- }
-
-
- function identifier() {
- var i = optionalidentifier();
- if (i) {
- return i;
- }
- if (token.id === 'function' && nexttoken.id === '(') {
- warning("Missing name in function statement.");
- } else {
- error("Expected an identifier and instead saw '{a}'.",
- nexttoken, nexttoken.value);
- }
- }
-
- function reachable(s) {
- var i = 0, t;
- if (nexttoken.id !== ';' || noreach) {
- return;
- }
- for (;;) {
- t = peek(i);
- if (t.reach) {
- return;
- }
- if (t.id !== '(endline)') {
- if (t.id === 'function') {
- warning(
-"Inner functions should be listed at the top of the outer function.", t);
- break;
- }
- warning("Unreachable '{a}' after '{b}'.", t, t.value, s);
- break;
- }
- i += 1;
- }
- }
-
-
- function statement(noindent) {
- var i = indent, r, s = scope, t = nexttoken;
-
-// We don't like the empty statement.
-
- if (t.id === ';') {
- warning("Unnecessary semicolon.", t);
- advance(';');
- return;
- }
-
-// Is this a labelled statement?
-
- if (t.identifier && !t.reserved && peek().id === ':') {
- advance();
- advance(':');
- scope = Object.create(s);
- addlabel(t.value, 'label');
- if (!nexttoken.labelled) {
- warning("Label '{a}' on {b} statement.",
- nexttoken, t.value, nexttoken.value);
- }
- if (jx.test(t.value + ':')) {
- warning("Label '{a}' looks like a javascript url.",
- t, t.value);
- }
- nexttoken.label = t.value;
- t = nexttoken;
- }
-
-// Parse the statement.
-
- if (!noindent) {
- indentation();
- }
- r = parse(0, true);
-
-// Look for the final semicolon.
-
- if (!t.block) {
- if (!r || !r.exps) {
- warning(
-"Expected an assignment or function call and instead saw an expression.",
- token);
- } else if (r.id === '(' && r.left.id === 'new') {
- warning("Do not use 'new' for side effects.");
- }
- if (nexttoken.id !== ';') {
- warningAt("Missing semicolon.", token.line,
- token.from + token.value.length);
- } else {
- adjacent(token, nexttoken);
- advance(';');
- nonadjacent(token, nexttoken);
- }
- }
-
-// Restore the indentation.
-
- indent = i;
- scope = s;
- return r;
- }
-
-
- function use_strict() {
- if (nexttoken.value === 'use strict') {
- advance();
- advance(';');
- strict_mode = true;
- return true;
- } else {
- return false;
- }
- }
-
-
- function statements(begin) {
- var a = [], f, p;
- if (begin && !use_strict() && option.strict) {
- warning('Missing "use strict" statement.', nexttoken);
- }
- if (option.adsafe) {
- switch (begin) {
- case 'script':
- if (!adsafe_may) {
- if (nexttoken.value !== 'ADSAFE' ||
- peek(0).id !== '.' ||
- (peek(1).value !== 'id' &&
- peek(1).value !== 'go')) {
- error('ADsafe violation: Missing ADSAFE.id or ADSAFE.go.',
- nexttoken);
- }
- }
- if (nexttoken.value === 'ADSAFE' &&
- peek(0).id === '.' &&
- peek(1).value === 'id') {
- if (adsafe_may) {
- error('ADsafe violation.', nexttoken);
- }
- advance('ADSAFE');
- advance('.');
- advance('id');
- advance('(');
- if (nexttoken.value !== adsafe_id) {
- error('ADsafe violation: id does not match.', nexttoken);
- }
- advance('(string)');
- advance(')');
- advance(';');
- adsafe_may = true;
- }
- break;
- case 'lib':
- if (nexttoken.value === 'ADSAFE') {
- advance('ADSAFE');
- advance('.');
- advance('lib');
- advance('(');
- advance('(string)');
- comma();
- f = parse(0);
- if (f.id !== 'function') {
- error('The second argument to lib must be a function.', f);
- }
- p = f.funct['(params)'];
- p = p && p.join(', ');
- if (p && p !== 'lib') {
- error("Expected '{a}' and instead saw '{b}'.",
- f, '(lib)', '(' + p + ')');
- }
- advance(')');
- advance(';');
- return a;
- } else {
- error("ADsafe lib violation.");
- }
- }
- }
- while (!nexttoken.reach && nexttoken.id !== '(end)') {
- if (nexttoken.id === ';') {
- warning("Unnecessary semicolon.");
- advance(';');
- } else {
- a.push(statement());
- }
- }
- return a;
- }
-
-
- function block(f) {
- var a, b = inblock, old_indent = indent, s = scope, t;
- inblock = f;
- scope = Object.create(scope);
- nonadjacent(token, nexttoken);
- t = nexttoken;
- if (nexttoken.id === '{') {
- advance('{');
- if (nexttoken.id !== '}' || token.line !== nexttoken.line) {
- indent += option.indent;
- while (!f && nexttoken.from > indent) {
- indent += option.indent;
- }
- if (!f) {
- use_strict();
- }
- a = statements();
- indent -= option.indent;
- indentation();
- }
- advance('}', t);
- indent = old_indent;
- } else {
- warning("Expected '{a}' and instead saw '{b}'.",
- nexttoken, '{', nexttoken.value);
- noreach = true;
- a = [statement()];
- noreach = false;
- }
- funct['(verb)'] = null;
- scope = s;
- inblock = b;
- return a;
- }
-
-
-// An identity function, used by string and number tokens.
-
- function idValue() {
- return this;
- }
-
-
- function countMember(m) {
- if (membersOnly && typeof membersOnly[m] !== 'boolean') {
- warning("Unexpected /*member '{a}'.", token, m);
- }
- if (typeof member[m] === 'number') {
- member[m] += 1;
- } else {
- member[m] = 1;
- }
- }
-
-
- function note_implied(token) {
- var name = token.value, line = token.line, a = implied[name];
- if (typeof a === 'function') {
- a = false;
- }
- if (!a) {
- a = [line];
- implied[name] = a;
- } else if (a[a.length - 1] !== line) {
- a.push(line);
- }
- }
-
-// CSS parsing.
-
-
- function cssName() {
- if (nexttoken.identifier) {
- advance();
- return true;
- }
- }
-
- function cssNumber() {
- if (nexttoken.id === '-') {
- advance('-');
- adjacent();
- nolinebreak();
- }
- if (nexttoken.type === '(number)') {
- advance('(number)');
- return true;
- }
- }
-
- function cssString() {
- if (nexttoken.type === '(string)') {
- advance();
- return true;
- }
- }
-
- function cssColor() {
- var i, number, value;
- if (nexttoken.identifier) {
- value = nexttoken.value;
- if (value === 'rgb' || value === 'rgba') {
- advance();
- advance('(');
- for (i = 0; i < 3; i += 1) {
- if (i) {
- advance(',');
- }
- number = nexttoken.value;
- if (nexttoken.type !== '(number)' || number < 0) {
- warning("Expected a positive number and instead saw '{a}'",
- nexttoken, number);
- advance();
- } else {
- advance();
- if (nexttoken.id === '%') {
- advance('%');
- if (number > 100) {
- warning("Expected a percentage and instead saw '{a}'",
- token, number);
- }
- } else {
- if (number > 255) {
- warning("Expected a small number and instead saw '{a}'",
- token, number);
- }
- }
- }
- }
- if (value === 'rgba') {
- advance(',');
- number = +nexttoken.value;
- if (nexttoken.type !== '(number)' || number < 0 || number > 1) {
- warning("Expected a number between 0 and 1 and instead saw '{a}'",
- nexttoken, number);
- }
- advance();
- if (nexttoken.id === '%') {
- warning("Unexpected '%'.");
- advance('%');
- }
- }
- advance(')');
- return true;
- } else if (cssColorData[nexttoken.value] === true) {
- advance();
- return true;
- }
- } else if (nexttoken.type === '(color)') {
- advance();
- return true;
- }
- return false;
- }
-
- function cssLength() {
- if (nexttoken.id === '-') {
- advance('-');
- adjacent();
- nolinebreak();
- }
- if (nexttoken.type === '(number)') {
- advance();
- if (nexttoken.type !== '(string)' &&
- cssLengthData[nexttoken.value] === true) {
- adjacent();
- advance();
- } else if (+token.value !== 0) {
- warning("Expected a linear unit and instead saw '{a}'.",
- nexttoken, nexttoken.value);
- }
- return true;
- }
- return false;
- }
-
- function cssLineHeight() {
- if (nexttoken.id === '-') {
- advance('-');
- adjacent();
- }
- if (nexttoken.type === '(number)') {
- advance();
- if (nexttoken.type !== '(string)' &&
- cssLengthData[nexttoken.value] === true) {
- adjacent();
- advance();
- }
- return true;
- }
- return false;
- }
-
- function cssWidth() {
- if (nexttoken.identifier) {
- switch (nexttoken.value) {
- case 'thin':
- case 'medium':
- case 'thick':
- advance();
- return true;
- }
- } else {
- return cssLength();
- }
- }
-
- function cssMargin() {
- if (nexttoken.identifier) {
- if (nexttoken.value === 'auto') {
- advance();
- return true;
- }
- } else {
- return cssLength();
- }
- }
-
- function cssAttr() {
- if (nexttoken.identifier && nexttoken.value === 'attr') {
- advance();
- advance('(');
- if (!nexttoken.identifier) {
- warning("Expected a name and instead saw '{a}'.",
- nexttoken, nexttoken.value);
- }
- advance();
- advance(')');
- return true;
- }
- return false;
- }
-
- function cssCommaList() {
- while (nexttoken.id !== ';') {
- if (!cssName() && !cssString()) {
- warning("Expected a name and instead saw '{a}'.",
- nexttoken, nexttoken.value);
- }
- if (nexttoken.id !== ',') {
- return true;
- }
- comma();
- }
- }
-
- function cssCounter() {
- if (nexttoken.identifier && nexttoken.value === 'counter') {
- advance();
- advance('(');
- if (!nexttoken.identifier) {
- }
- advance();
- if (nexttoken.id === ',') {
- comma();
- if (nexttoken.type !== '(string)') {
- warning("Expected a string and instead saw '{a}'.",
- nexttoken, nexttoken.value);
- }
- advance();
- }
- advance(')');
- return true;
- }
- if (nexttoken.identifier && nexttoken.value === 'counters') {
- advance();
- advance('(');
- if (!nexttoken.identifier) {
- warning("Expected a name and instead saw '{a}'.",
- nexttoken, nexttoken.value);
- }
- advance();
- if (nexttoken.id === ',') {
- comma();
- if (nexttoken.type !== '(string)') {
- warning("Expected a string and instead saw '{a}'.",
- nexttoken, nexttoken.value);
- }
- advance();
- }
- if (nexttoken.id === ',') {
- comma();
- if (nexttoken.type !== '(string)') {
- warning("Expected a string and instead saw '{a}'.",
- nexttoken, nexttoken.value);
- }
- advance();
- }
- advance(')');
- return true;
- }
- return false;
- }
-
-
- function cssShape() {
- var i;
- if (nexttoken.identifier && nexttoken.value === 'rect') {
- advance();
- advance('(');
- for (i = 0; i < 4; i += 1) {
- if (!cssLength()) {
- warning("Expected a number and instead saw '{a}'.",
- nexttoken, nexttoken.value);
- break;
- }
- }
- advance(')');
- return true;
- }
- return false;
- }
-
- function cssUrl() {
- var c, url;
- if (nexttoken.identifier && nexttoken.value === 'url') {
- nexttoken = lex.range('(', ')');
- url = nexttoken.value;
- c = url.charAt(0);
- if (c === '"' || c === '\'') {
- if (url.slice(-1) !== c) {
- warning("Bad url string.");
- } else {
- url = url.slice(1, -1);
- if (url.indexOf(c) >= 0) {
- warning("Bad url string.");
- }
- }
- }
- if (!url) {
- warning("Missing url.");
- }
- advance();
- if (option.safe && ux.test(url)) {
- error("ADsafe URL violation.");
- }
- urls.push(url);
- return true;
- }
- return false;
- }
-
- cssAny = [cssUrl, function () {
- for (;;) {
- if (nexttoken.identifier) {
- switch (nexttoken.value.toLowerCase()) {
- case 'url':
- cssUrl();
- break;
- case 'expression':
- warning("Unexpected expression '{a}'.",
- nexttoken, nexttoken.value);
- advance();
- break;
- default:
- advance();
- }
- } else {
- if (nexttoken.id === ';' || nexttoken.id === '!' ||
- nexttoken.id === '(end)' || nexttoken.id === '}') {
- return true;
- }
- advance();
- }
- }
- }];
-
- cssBorderStyle = [
- 'none', 'hidden', 'dotted', 'dashed', 'solid', 'double', 'ridge',
- 'inset', 'outset'
- ];
-
- cssBreak = [
- 'auto', 'always', 'avoid', 'left', 'right'
- ];
-
- cssOverflow = [
- 'auto', 'hidden', 'scroll', 'visible'
- ];
-
- cssAttributeData = {
- background: [
- true, 'background-attachment', 'background-color',
- 'background-image', 'background-position', 'background-repeat'
- ],
- 'background-attachment': ['scroll', 'fixed'],
- 'background-color': ['transparent', cssColor],
- 'background-image': ['none', cssUrl],
- 'background-position': [
- 2, [cssLength, 'top', 'bottom', 'left', 'right', 'center']
- ],
- 'background-repeat': [
- 'repeat', 'repeat-x', 'repeat-y', 'no-repeat'
- ],
- 'border': [true, 'border-color', 'border-style', 'border-width'],
- 'border-bottom': [
- true, 'border-bottom-color', 'border-bottom-style',
- 'border-bottom-width'
- ],
- 'border-bottom-color': cssColor,
- 'border-bottom-style': cssBorderStyle,
- 'border-bottom-width': cssWidth,
- 'border-collapse': ['collapse', 'separate'],
- 'border-color': ['transparent', 4, cssColor],
- 'border-left': [
- true, 'border-left-color', 'border-left-style', 'border-left-width'
- ],
- 'border-left-color': cssColor,
- 'border-left-style': cssBorderStyle,
- 'border-left-width': cssWidth,
- 'border-right': [
- true, 'border-right-color', 'border-right-style',
- 'border-right-width'
- ],
- 'border-right-color': cssColor,
- 'border-right-style': cssBorderStyle,
- 'border-right-width': cssWidth,
- 'border-spacing': [2, cssLength],
- 'border-style': [4, cssBorderStyle],
- 'border-top': [
- true, 'border-top-color', 'border-top-style', 'border-top-width'
- ],
- 'border-top-color': cssColor,
- 'border-top-style': cssBorderStyle,
- 'border-top-width': cssWidth,
- 'border-width': [4, cssWidth],
- bottom: [cssLength, 'auto'],
- 'caption-side' : ['bottom', 'left', 'right', 'top'],
- clear: ['both', 'left', 'none', 'right'],
- clip: [cssShape, 'auto'],
- color: cssColor,
- content: [
- 'open-quote', 'close-quote', 'no-open-quote', 'no-close-quote',
- cssString, cssUrl, cssCounter, cssAttr
- ],
- 'counter-increment': [
- cssName, 'none'
- ],
- 'counter-reset': [
- cssName, 'none'
- ],
- cursor: [
- cssUrl, 'auto', 'crosshair', 'default', 'e-resize', 'help', 'move',
- 'n-resize', 'ne-resize', 'nw-resize', 'pointer', 's-resize',
- 'se-resize', 'sw-resize', 'w-resize', 'text', 'wait'
- ],
- direction: ['ltr', 'rtl'],
- display: [
- 'block', 'compact', 'inline', 'inline-block', 'inline-table',
- 'list-item', 'marker', 'none', 'run-in', 'table', 'table-caption',
- 'table-cell', 'table-column', 'table-column-group',
- 'table-footer-group', 'table-header-group', 'table-row',
- 'table-row-group'
- ],
- 'empty-cells': ['show', 'hide'],
- 'float': ['left', 'none', 'right'],
- font: [
- 'caption', 'icon', 'menu', 'message-box', 'small-caption',
- 'status-bar', true, 'font-size', 'font-style', 'font-weight',
- 'font-family'
- ],
- 'font-family': cssCommaList,
- 'font-size': [
- 'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large',
- 'xx-large', 'larger', 'smaller', cssLength
- ],
- 'font-size-adjust': ['none', cssNumber],
- 'font-stretch': [
- 'normal', 'wider', 'narrower', 'ultra-condensed',
- 'extra-condensed', 'condensed', 'semi-condensed',
- 'semi-expanded', 'expanded', 'extra-expanded'
- ],
- 'font-style': [
- 'normal', 'italic', 'oblique'
- ],
- 'font-variant': [
- 'normal', 'small-caps'
- ],
- 'font-weight': [
- 'normal', 'bold', 'bolder', 'lighter', cssNumber
- ],
- height: [cssLength, 'auto'],
- left: [cssLength, 'auto'],
- 'letter-spacing': ['normal', cssLength],
- 'line-height': ['normal', cssLineHeight],
- 'list-style': [
- true, 'list-style-image', 'list-style-position', 'list-style-type'
- ],
- 'list-style-image': ['none', cssUrl],
- 'list-style-position': ['inside', 'outside'],
- 'list-style-type': [
- 'circle', 'disc', 'square', 'decimal', 'decimal-leading-zero',
- 'lower-roman', 'upper-roman', 'lower-greek', 'lower-alpha',
- 'lower-latin', 'upper-alpha', 'upper-latin', 'hebrew', 'katakana',
- 'hiragana-iroha', 'katakana-oroha', 'none'
- ],
- margin: [4, cssMargin],
- 'margin-bottom': cssMargin,
- 'margin-left': cssMargin,
- 'margin-right': cssMargin,
- 'margin-top': cssMargin,
- 'marker-offset': [cssLength, 'auto'],
- 'max-height': [cssLength, 'none'],
- 'max-width': [cssLength, 'none'],
- 'min-height': cssLength,
- 'min-width': cssLength,
- opacity: cssNumber,
- outline: [true, 'outline-color', 'outline-style', 'outline-width'],
- 'outline-color': ['invert', cssColor],
- 'outline-style': [
- 'dashed', 'dotted', 'double', 'groove', 'inset', 'none',
- 'outset', 'ridge', 'solid'
- ],
- 'outline-width': cssWidth,
- overflow: cssOverflow,
- 'overflow-x': cssOverflow,
- 'overflow-y': cssOverflow,
- padding: [4, cssLength],
- 'padding-bottom': cssLength,
- 'padding-left': cssLength,
- 'padding-right': cssLength,
- 'padding-top': cssLength,
- 'page-break-after': cssBreak,
- 'page-break-before': cssBreak,
- position: ['absolute', 'fixed', 'relative', 'static'],
- quotes: [8, cssString],
- right: [cssLength, 'auto'],
- 'table-layout': ['auto', 'fixed'],
- 'text-align': ['center', 'justify', 'left', 'right'],
- 'text-decoration': [
- 'none', 'underline', 'overline', 'line-through', 'blink'
- ],
- 'text-indent': cssLength,
- 'text-shadow': ['none', 4, [cssColor, cssLength]],
- 'text-transform': ['capitalize', 'uppercase', 'lowercase', 'none'],
- top: [cssLength, 'auto'],
- 'unicode-bidi': ['normal', 'embed', 'bidi-override'],
- 'vertical-align': [
- 'baseline', 'bottom', 'sub', 'super', 'top', 'text-top', 'middle',
- 'text-bottom', cssLength
- ],
- visibility: ['visible', 'hidden', 'collapse'],
- 'white-space': [
- 'normal', 'nowrap', 'pre', 'pre-line', 'pre-wrap', 'inherit'
- ],
- width: [cssLength, 'auto'],
- 'word-spacing': ['normal', cssLength],
- 'word-wrap': ['break-word', 'normal'],
- 'z-index': ['auto', cssNumber]
- };
-
- function styleAttribute() {
- var v;
- while (nexttoken.id === '*' || nexttoken.id === '#' ||
- nexttoken.value === '_') {
- if (!option.css) {
- warning("Unexpected '{a}'.", nexttoken, nexttoken.value);
- }
- advance();
- }
- if (nexttoken.id === '-') {
- if (!option.css) {
- warning("Unexpected '{a}'.", nexttoken, nexttoken.value);
- }
- advance('-');
- if (!nexttoken.identifier) {
- warning(
-"Expected a non-standard style attribute and instead saw '{a}'.",
- nexttoken, nexttoken.value);
- }
- advance();
- return cssAny;
- } else {
- if (!nexttoken.identifier) {
- warning("Excepted a style attribute, and instead saw '{a}'.",
- nexttoken, nexttoken.value);
- } else {
- if (is_own(cssAttributeData, nexttoken.value)) {
- v = cssAttributeData[nexttoken.value];
- } else {
- v = cssAny;
- if (!option.css) {
- warning("Unrecognized style attribute '{a}'.",
- nexttoken, nexttoken.value);
- }
- }
- }
- advance();
- return v;
- }
- }
-
- function styleValue(v) {
- var i = 0,
- n,
- once,
- match,
- round,
- start = 0,
- vi;
- switch (typeof v) {
- case 'function':
- return v();
- case 'string':
- if (nexttoken.identifier && nexttoken.value === v) {
- advance();
- return true;
- }
- return false;
- }
- for (;;) {
- if (i >= v.length) {
- return false;
- }
- vi = v[i];
- i += 1;
- if (vi === true) {
- break;
- } else if (typeof vi === 'number') {
- n = vi;
- vi = v[i];
- i += 1;
- } else {
- n = 1;
- }
- match = false;
- while (n > 0) {
- if (styleValue(vi)) {
- match = true;
- n -= 1;
- } else {
- break;
- }
- }
- if (match) {
- return true;
- }
- }
- start = i;
- once = [];
- for (;;) {
- round = false;
- for (i = start; i < v.length; i += 1) {
- if (!once[i]) {
- if (styleValue(cssAttributeData[v[i]])) {
- match = true;
- round = true;
- once[i] = true;
- break;
- }
- }
- }
- if (!round) {
- return match;
- }
- }
- }
-
- function styleChild() {
- if (nexttoken.id === '(number)') {
- advance();
- if (nexttoken.value === 'n' && nexttoken.identifier) {
- adjacent();
- advance();
- if (nexttoken.id === '+') {
- adjacent();
- advance('+');
- adjacent();
- advance('(number)');
- }
- }
- return;
- } else {
- switch (nexttoken.value) {
- case 'odd':
- case 'even':
- if (nexttoken.identifier) {
- advance();
- return;
- }
- }
- }
- warning("Unexpected token '{a}'.", nexttoken, nexttoken.value);
- }
-
- function substyle() {
- var v;
- for (;;) {
- if (nexttoken.id === '}' || nexttoken.id === '(end)' ||
- xquote && nexttoken.id === xquote) {
- return;
- }
- while (nexttoken.id === ';') {
- warning("Misplaced ';'.");
- advance(';');
- }
- v = styleAttribute();
- advance(':');
- if (nexttoken.identifier && nexttoken.value === 'inherit') {
- advance();
- } else {
- if (!styleValue(v)) {
- warning("Unexpected token '{a}'.", nexttoken,
- nexttoken.value);
- advance();
- }
- }
- if (nexttoken.id === '!') {
- advance('!');
- adjacent();
- if (nexttoken.identifier && nexttoken.value === 'important') {
- advance();
- } else {
- warning("Expected '{a}' and instead saw '{b}'.",
- nexttoken, 'important', nexttoken.value);
- }
- }
- if (nexttoken.id === '}' || nexttoken.id === xquote) {
- warning("Missing '{a}'.", nexttoken, ';');
- } else {
- advance(';');
- }
- }
- }
-
- function styleSelector() {
- if (nexttoken.identifier) {
- if (!is_own(htmltag, nexttoken.value)) {
- warning("Expected a tagName, and instead saw {a}.",
- nexttoken, nexttoken.value);
- }
- advance();
- } else {
- switch (nexttoken.id) {
- case '>':
- case '+':
- advance();
- styleSelector();
- break;
- case ':':
- advance(':');
- switch (nexttoken.value) {
- case 'active':
- case 'after':
- case 'before':
- case 'checked':
- case 'disabled':
- case 'empty':
- case 'enabled':
- case 'first-child':
- case 'first-letter':
- case 'first-line':
- case 'first-of-type':
- case 'focus':
- case 'hover':
- case 'last-of-type':
- case 'link':
- case 'only-of-type':
- case 'root':
- case 'target':
- case 'visited':
- advance();
- break;
- case 'lang':
- advance();
- advance('(');
- if (!nexttoken.identifier) {
- warning("Expected a lang code, and instead saw :{a}.",
- nexttoken, nexttoken.value);
- }
- advance(')');
- break;
- case 'nth-child':
- case 'nth-last-child':
- case 'nth-last-of-type':
- case 'nth-of-type':
- advance();
- advance('(');
- styleChild();
- advance(')');
- break;
- case 'not':
- advance();
- advance('(');
- if (nexttoken.id === ':' && peek(0).value === 'not') {
- warning("Nested not.");
- }
- styleSelector();
- advance(')');
- break;
- default:
- warning("Expected a pseudo, and instead saw :{a}.",
- nexttoken, nexttoken.value);
- }
- break;
- case '#':
- advance('#');
- if (!nexttoken.identifier) {
- warning("Expected an id, and instead saw #{a}.",
- nexttoken, nexttoken.value);
- }
- advance();
- break;
- case '*':
- advance('*');
- break;
- case '.':
- advance('.');
- if (!nexttoken.identifier) {
- warning("Expected a class, and instead saw #.{a}.",
- nexttoken, nexttoken.value);
- }
- advance();
- break;
- case '[':
- advance('[');
- if (!nexttoken.identifier) {
- warning("Expected an attribute, and instead saw [{a}].",
- nexttoken, nexttoken.value);
- }
- advance();
- if (nexttoken.id === '=' || nexttoken.value === '~=' ||
- nexttoken.value === '$=' ||
- nexttoken.value === '|=' ||
- nexttoken.id === '*=' ||
- nexttoken.id === '^=') {
- advance();
- if (nexttoken.type !== '(string)') {
- warning("Expected a string, and instead saw {a}.",
- nexttoken, nexttoken.value);
- }
- advance();
- }
- advance(']');
- break;
- default:
- error("Expected a CSS selector, and instead saw {a}.",
- nexttoken, nexttoken.value);
- }
- }
- }
-
- function stylePattern() {
- var name;
- if (nexttoken.id === '{') {
- warning("Expected a style pattern, and instead saw '{a}'.", nexttoken,
- nexttoken.id);
- } else if (nexttoken.id === '@') {
- advance('@');
- name = nexttoken.value;
- if (nexttoken.identifier && atrule[name] === true) {
- advance();
- return name;
- }
- warning("Expected an at-rule, and instead saw @{a}.", nexttoken, name);
- }
- for (;;) {
- styleSelector();
- if (nexttoken.id === '</' || nexttoken.id === '{' ||
- nexttoken.id === '(end)') {
- return '';
- }
- if (nexttoken.id === ',') {
- comma();
- }
- }
- }
-
- function styles() {
- var i;
- while (nexttoken.id === '@') {
- i = peek();
- if (i.identifier && i.value === 'import') {
- advance('@');
- advance();
- if (!cssUrl()) {
- warning("Expected '{a}' and instead saw '{b}'.", nexttoken,
- 'url', nexttoken.value);
- advance();
- }
- advance(';');
- } else {
- break;
- }
- }
- while (nexttoken.id !== '</' && nexttoken.id !== '(end)') {
- stylePattern();
- xmode = 'styleproperty';
- if (nexttoken.id === ';') {
- advance(';');
- } else {
- advance('{');
- substyle();
- xmode = 'style';
- advance('}');
- }
- }
- }
-
-
-// HTML parsing.
-
- function doBegin(n) {
- if (n !== 'html' && !option.fragment) {
- if (n === 'div' && option.adsafe) {
- error("ADSAFE: Use the fragment option.");
- } else {
- error("Expected '{a}' and instead saw '{b}'.",
- token, 'html', n);
- }
- }
- if (option.adsafe) {
- if (n === 'html') {
- error(
-"Currently, ADsafe does not operate on whole HTML documents. It operates on <div> fragments and .js files.", token);
- }
- if (option.fragment) {
- if (n !== 'div') {
- error("ADsafe violation: Wrap the widget in a div.", token);
- }
- } else {
- error("Use the fragment option.", token);
- }
- }
- option.browser = true;
- assume();
- }
-
- function doAttribute(n, a, v) {
- var u, x;
- if (a === 'id') {
- u = typeof v === 'string' ? v.toUpperCase() : '';
- if (ids[u] === true) {
- warning("Duplicate id='{a}'.", nexttoken, v);
- }
- if (!/^[A-Za-z][A-Za-z0-9._:\-]*$/.test(v)) {
- warning("Bad id: '{a}'.", nexttoken, v);
- } else if (option.adsafe) {
- if (adsafe_id) {
- if (v.slice(0, adsafe_id.length) !== adsafe_id) {
- warning("ADsafe violation: An id must have a '{a}' prefix",
- nexttoken, adsafe_id);
- } else if (!/^[A-Z]+_[A-Z]+$/.test(v)) {
- warning("ADSAFE violation: bad id.");
- }
- } else {
- adsafe_id = v;
- if (!/^[A-Z]+_$/.test(v)) {
- warning("ADSAFE violation: bad id.");
- }
- }
- }
- x = v.search(dx);
- if (x >= 0) {
- warning("Unexpected character '{a}' in {b}.", token, v.charAt(x), a);
- }
- ids[u] = true;
- } else if (a === 'class' || a === 'type' || a === 'name') {
- x = v.search(qx);
- if (x >= 0) {
- warning("Unexpected character '{a}' in {b}.", token, v.charAt(x), a);
- }
- ids[u] = true;
- } else if (a === 'href' || a === 'background' ||
- a === 'content' || a === 'data' ||
- a.indexOf('src') >= 0 || a.indexOf('url') >= 0) {
- if (option.safe && ux.test(v)) {
- error("ADsafe URL violation.");
- }
- urls.push(v);
- } else if (a === 'for') {
- if (option.adsafe) {
- if (adsafe_id) {
- if (v.slice(0, adsafe_id.length) !== adsafe_id) {
- warning("ADsafe violation: An id must have a '{a}' prefix",
- nexttoken, adsafe_id);
- } else if (!/^[A-Z]+_[A-Z]+$/.test(v)) {
- warning("ADSAFE violation: bad id.");
- }
- } else {
- warning("ADSAFE violation: bad id.");
- }
- }
- } else if (a === 'name') {
- if (option.adsafe && v.indexOf('_') >= 0) {
- warning("ADsafe name violation.");
- }
- }
- }
-
- function doTag(n, a) {
- var i, t = htmltag[n], x;
- src = false;
- if (!t) {
- error("Unrecognized tag '<{a}>'.",
- nexttoken,
- n === n.toLowerCase() ? n :
- n + ' (capitalization error)');
- }
- if (stack.length > 0) {
- if (n === 'html') {
- error("Too many <html> tags.", token);
- }
- x = t.parent;
- if (x) {
- if (x.indexOf(' ' + stack[stack.length - 1].name + ' ') < 0) {
- error("A '<{a}>' must be within '<{b}>'.",
- token, n, x);
- }
- } else if (!option.adsafe && !option.fragment) {
- i = stack.length;
- do {
- if (i <= 0) {
- error("A '<{a}>' must be within '<{b}>'.",
- token, n, 'body');
- }
- i -= 1;
- } while (stack[i].name !== 'body');
- }
- }
- switch (n) {
- case 'div':
- if (option.adsafe && stack.length === 1 && !adsafe_id) {
- warning("ADSAFE violation: missing ID_.");
- }
- break;
- case 'script':
- xmode = 'script';
- advance('>');
- indent = nexttoken.from;
- if (a.lang) {
- warning("lang is deprecated.", token);
- }
- if (option.adsafe && stack.length !== 1) {
- warning("ADsafe script placement violation.", token);
- }
- if (a.src) {
- if (option.adsafe && (!adsafe_may || !approved[a.src])) {
- warning("ADsafe unapproved script source.", token);
- }
- if (a.type) {
- warning("type is unnecessary.", token);
- }
- } else {
- if (adsafe_went) {
- error("ADsafe script violation.", token);
- }
- statements('script');
- }
- xmode = 'html';
- advance('</');
- if (!nexttoken.identifier && nexttoken.value !== 'script') {
- warning("Expected '{a}' and instead saw '{b}'.",
- nexttoken, 'script', nexttoken.value);
- }
- advance();
- xmode = 'outer';
- break;
- case 'style':
- xmode = 'style';
- advance('>');
- styles();
- xmode = 'html';
- advance('</');
- if (!nexttoken.identifier && nexttoken.value !== 'style') {
- warning("Expected '{a}' and instead saw '{b}'.",
- nexttoken, 'style', nexttoken.value);
- }
- advance();
- xmode = 'outer';
- break;
- case 'input':
- switch (a.type) {
- case 'radio':
- case 'checkbox':
- case 'button':
- case 'reset':
- case 'submit':
- break;
- case 'text':
- case 'file':
- case 'password':
- case 'file':
- case 'hidden':
- case 'image':
- if (option.adsafe && a.autocomplete !== 'off') {
- warning("ADsafe autocomplete violation.");
- }
- break;
- default:
- warning("Bad input type.");
- }
- break;
- case 'applet':
- case 'body':
- case 'embed':
- case 'frame':
- case 'frameset':
- case 'head':
- case 'iframe':
- case 'noembed':
- case 'noframes':
- case 'object':
- case 'param':
- if (option.adsafe) {
- warning("ADsafe violation: Disallowed tag: " + n);
- }
- break;
- }
- }
-
-
- function closetag(n) {
- return '</' + n + '>';
- }
-
- function html() {
- var a, attributes, e, n, q, t, v, w = option.white, wmode;
- xmode = 'html';
- xquote = '';
- stack = null;
- for (;;) {
- switch (nexttoken.value) {
- case '<':
- xmode = 'html';
- advance('<');
- attributes = {};
- t = nexttoken;
- if (!t.identifier) {
- warning("Bad identifier {a}.", t, t.value);
- }
- n = t.value;
- if (option.cap) {
- n = n.toLowerCase();
- }
- t.name = n;
- advance();
- if (!stack) {
- stack = [];
- doBegin(n);
- }
- v = htmltag[n];
- if (typeof v !== 'object') {
- error("Unrecognized tag '<{a}>'.", t, n);
- }
- e = v.empty;
- t.type = n;
- for (;;) {
- if (nexttoken.id === '/') {
- advance('/');
- if (nexttoken.id !== '>') {
- warning("Expected '{a}' and instead saw '{b}'.",
- nexttoken, '>', nexttoken.value);
- }
- break;
- }
- if (nexttoken.id && nexttoken.id.substr(0, 1) === '>') {
- break;
- }
- if (!nexttoken.identifier) {
- if (nexttoken.id === '(end)' || nexttoken.id === '(error)') {
- error("Missing '>'.", nexttoken);
- }
- warning("Bad identifier.");
- }
- option.white = true;
- nonadjacent(token, nexttoken);
- a = nexttoken.value;
- option.white = w;
- advance();
- if (!option.cap && a !== a.toLowerCase()) {
- warning("Attribute '{a}' not all lower case.", nexttoken, a);
- }
- a = a.toLowerCase();
- xquote = '';
- if (is_own(attributes, a)) {
- warning("Attribute '{a}' repeated.", nexttoken, a);
- }
- if (a.slice(0, 2) === 'on') {
- if (!option.on) {
- warning("Avoid HTML event handlers.");
- }
- xmode = 'scriptstring';
- advance('=');
- q = nexttoken.id;
- if (q !== '"' && q !== "'") {
- error("Missing quote.");
- }
- xquote = q;
- wmode = option.white;
- option.white = false;
- advance(q);
- statements('on');
- option.white = wmode;
- if (nexttoken.id !== q) {
- error("Missing close quote on script attribute.");
- }
- xmode = 'html';
- xquote = '';
- advance(q);
- v = false;
- } else if (a === 'style') {
- xmode = 'scriptstring';
- advance('=');
- q = nexttoken.id;
- if (q !== '"' && q !== "'") {
- error("Missing quote.");
- }
- xmode = 'styleproperty';
- xquote = q;
- advance(q);
- substyle();
- xmode = 'html';
- xquote = '';
- advance(q);
- v = false;
- } else {
- if (nexttoken.id === '=') {
- advance('=');
- v = nexttoken.value;
- if (!nexttoken.identifier &&
- nexttoken.id !== '"' &&
- nexttoken.id !== '\'' &&
- nexttoken.type !== '(string)' &&
- nexttoken.type !== '(number)' &&
- nexttoken.type !== '(color)') {
- warning("Expected an attribute value and instead saw '{a}'.", token, a);
- }
- advance();
- } else {
- v = true;
- }
- }
- attributes[a] = v;
- doAttribute(n, a, v);
- }
- doTag(n, attributes);
- if (!e) {
- stack.push(t);
- }
- xmode = 'outer';
- advance('>');
- break;
- case '</':
- xmode = 'html';
- advance('</');
- if (!nexttoken.identifier) {
- warning("Bad identifier.");
- }
- n = nexttoken.value;
- if (option.cap) {
- n = n.toLowerCase();
- }
- advance();
- if (!stack) {
- error("Unexpected '{a}'.", nexttoken, closetag(n));
- }
- t = stack.pop();
- if (!t) {
- error("Unexpected '{a}'.", nexttoken, closetag(n));
- }
- if (t.name !== n) {
- error("Expected '{a}' and instead saw '{b}'.",
- nexttoken, closetag(t.name), closetag(n));
- }
- if (nexttoken.id !== '>') {
- error("Missing '{a}'.", nexttoken, '>');
- }
- xmode = 'outer';
- advance('>');
- break;
- case '<!':
- if (option.safe) {
- warning("ADsafe HTML violation.");
- }
- xmode = 'html';
- for (;;) {
- advance();
- if (nexttoken.id === '>' || nexttoken.id === '(end)') {
- break;
- }
- if (nexttoken.value.indexOf('--') >= 0) {
- warning("Unexpected --.");
- }
- if (nexttoken.value.indexOf('<') >= 0) {
- warning("Unexpected <.");
- }
- if (nexttoken.value.indexOf('>') >= 0) {
- warning("Unexpected >.");
- }
- }
- xmode = 'outer';
- advance('>');
- break;
- case '(end)':
- return;
- default:
- if (nexttoken.id === '(end)') {
- error("Missing '{a}'.", nexttoken,
- '</' + stack[stack.length - 1].value + '>');
- } else {
- advance();
- }
- }
- if (stack && stack.length === 0 && (option.adsafe ||
- !option.fragment || nexttoken.id === '(end)')) {
- break;
- }
- }
- if (nexttoken.id !== '(end)') {
- error("Unexpected material after the end.");
- }
- }
-
-
-// Build the syntax table by declaring the syntactic elements of the language.
-
- type('(number)', idValue);
- type('(string)', idValue);
-
- syntax['(identifier)'] = {
- type: '(identifier)',
- lbp: 0,
- identifier: true,
- nud: function () {
- var v = this.value,
- s = scope[v],
- f;
- if (typeof s === 'function') {
- s = undefined;
- } else if (typeof s === 'boolean') {
- f = funct;
- funct = functions[0];
- addlabel(v, 'var');
- s = funct;
- funct = f;
- }
-
-// The name is in scope and defined in the current function.
-
- if (funct === s) {
-
-// Change 'unused' to 'var', and reject labels.
-
- switch (funct[v]) {
- case 'unused':
- funct[v] = 'var';
- break;
- case 'label':
- warning("'{a}' is a statement label.", token, v);
- break;
- }
-
-// The name is not defined in the function. If we are in the global scope,
-// then we have an undefined variable.
-
- } else if (funct['(global)']) {
- if (option.undef && predefined[v] !== 'boolean') {
- warning("'{a}' is not defined.", token, v);
- }
- note_implied(token);
-
-// If the name is already defined in the current
-// function, but not as outer, then there is a scope error.
-
- } else {
- switch (funct[v]) {
- case 'closure':
- case 'function':
- case 'var':
- case 'unused':
- warning("'{a}' used out of scope.", token, v);
- break;
- case 'label':
- warning("'{a}' is a statement label.", token, v);
- break;
- case 'outer':
- case 'global':
- break;
- default:
-
-// If the name is defined in an outer function, make an outer entry, and if
-// it was unused, make it var.
-
- if (s === true) {
- funct[v] = true;
- } else if (s === null) {
- warning("'{a}' is not allowed.", token, v);
- note_implied(token);
- } else if (typeof s !== 'object') {
- if (option.undef) {
- warning("'{a}' is not defined.", token, v);
- } else {
- funct[v] = true;
- }
- note_implied(token);
- } else {
- switch (s[v]) {
- case 'function':
- case 'var':
- case 'unused':
- s[v] = 'closure';
- funct[v] = s['(global)'] ? 'global' : 'outer';
- break;
- case 'closure':
- case 'parameter':
- funct[v] = s['(global)'] ? 'global' : 'outer';
- break;
- case 'label':
- warning("'{a}' is a statement label.", token, v);
- }
- }
- }
- }
- return this;
- },
- led: function () {
- error("Expected an operator and instead saw '{a}'.",
- nexttoken, nexttoken.value);
- }
- };
-
- type('(regexp)', function () {
- return this;
- });
-
- delim('(endline)');
- delim('(begin)');
- delim('(end)').reach = true;
- delim('</').reach = true;
- delim('<!');
- delim('<!--');
- delim('-->');
- delim('(error)').reach = true;
- delim('}').reach = true;
- delim(')');
- delim(']');
- delim('"').reach = true;
- delim("'").reach = true;
- delim(';');
- delim(':').reach = true;
- delim(',');
- delim('#');
- delim('@');
- reserve('else');
- reserve('case').reach = true;
- reserve('catch');
- reserve('default').reach = true;
- reserve('finally');
- reservevar('arguments');
- reservevar('eval');
- reservevar('false');
- reservevar('Infinity');
- reservevar('NaN');
- reservevar('null');
- reservevar('this');
- reservevar('true');
- reservevar('undefined');
- assignop('=', 'assign', 20);
- assignop('+=', 'assignadd', 20);
- assignop('-=', 'assignsub', 20);
- assignop('*=', 'assignmult', 20);
- assignop('/=', 'assigndiv', 20).nud = function () {
- error("A regular expression literal can be confused with '/='.");
- };
- assignop('%=', 'assignmod', 20);
- bitwiseassignop('&=', 'assignbitand', 20);
- bitwiseassignop('|=', 'assignbitor', 20);
- bitwiseassignop('^=', 'assignbitxor', 20);
- bitwiseassignop('<<=', 'assignshiftleft', 20);
- bitwiseassignop('>>=', 'assignshiftright', 20);
- bitwiseassignop('>>>=', 'assignshiftrightunsigned', 20);
- infix('?', function (left, that) {
- that.left = left;
- that.right = parse(10);
- advance(':');
- that['else'] = parse(10);
- return that;
- }, 30);
-
- infix('||', 'or', 40);
- infix('&&', 'and', 50);
- bitwise('|', 'bitor', 70);
- bitwise('^', 'bitxor', 80);
- bitwise('&', 'bitand', 90);
- relation('==', function (left, right) {
- if (option.eqeqeq) {
- warning("Expected '{a}' and instead saw '{b}'.",
- this, '===', '==');
- } else if (isPoorRelation(left)) {
- warning("Use '{a}' to compare with '{b}'.",
- this, '===', left.value);
- } else if (isPoorRelation(right)) {
- warning("Use '{a}' to compare with '{b}'.",
- this, '===', right.value);
- }
- return this;
- });
- relation('===');
- relation('!=', function (left, right) {
- if (option.eqeqeq) {
- warning("Expected '{a}' and instead saw '{b}'.",
- this, '!==', '!=');
- } else if (isPoorRelation(left)) {
- warning("Use '{a}' to compare with '{b}'.",
- this, '!==', left.value);
- } else if (isPoorRelation(right)) {
- warning("Use '{a}' to compare with '{b}'.",
- this, '!==', right.value);
- }
- return this;
- });
- relation('!==');
- relation('<');
- relation('>');
- relation('<=');
- relation('>=');
- bitwise('<<', 'shiftleft', 120);
- bitwise('>>', 'shiftright', 120);
- bitwise('>>>', 'shiftrightunsigned', 120);
- infix('in', 'in', 120);
- infix('instanceof', 'instanceof', 120);
- infix('+', function (left, that) {
- var right = parse(130);
- if (left && right && left.id === '(string)' && right.id === '(string)') {
- left.value += right.value;
- left.character = right.character;
- if (jx.test(left.value)) {
- warning("JavaScript URL.", left);
- }
- return left;
- }
- that.left = left;
- that.right = right;
- return that;
- }, 130);
- prefix('+', 'num');
- infix('-', 'sub', 130);
- prefix('-', 'neg');
- infix('*', 'mult', 140);
- infix('/', 'div', 140);
- infix('%', 'mod', 140);
-
- suffix('++', 'postinc');
- prefix('++', 'preinc');
- syntax['++'].exps = true;
-
- suffix('--', 'postdec');
- prefix('--', 'predec');
- syntax['--'].exps = true;
- prefix('delete', function () {
- var p = parse(0);
- if (!p || (p.id !== '.' && p.id !== '[')) {
- warning("Expected '{a}' and instead saw '{b}'.",
- nexttoken, '.', nexttoken.value);
- }
- this.first = p;
- return this;
- }).exps = true;
-
-
- prefix('~', function () {
- if (option.bitwise) {
- warning("Unexpected '{a}'.", this, '~');
- }
- parse(150);
- return this;
- });
- prefix('!', function () {
- this.right = parse(150);
- this.arity = 'unary';
- if (bang[this.right.id] === true) {
- warning("Confusing use of '{a}'.", this, '!');
- }
- return this;
- });
- prefix('typeof', 'typeof');
- prefix('new', function () {
- var c = parse(155), i;
- if (c && c.id !== 'function') {
- if (c.identifier) {
- c['new'] = true;
- switch (c.value) {
- case 'Object':
- warning("Use the object literal notation {}.", token);
- break;
- case 'Array':
- if (nexttoken.id !== '(') {
- warning("Use the array literal notation [].", token);
- } else {
- advance('(');
- if (nexttoken.id === ')') {
- warning("Use the array literal notation [].", token);
- } else {
- i = parse(0);
- c.dimension = i;
- if ((i.id === '(number)' && /[.+\-Ee]/.test(i.value)) ||
- (i.id === '-' && !i.right) ||
- i.id === '(string)' || i.id === '[' ||
- i.id === '{' || i.id === 'true' ||
- i.id === 'false' ||
- i.id === 'null' || i.id === 'undefined' ||
- i.id === 'Infinity') {
- warning("Use the array literal notation [].", token);
- }
- if (nexttoken.id !== ')') {
- error("Use the array literal notation [].", token);
- }
- }
- advance(')');
- }
- this.first = c;
- return this;
- case 'Number':
- case 'String':
- case 'Boolean':
- case 'Math':
- case 'JSON':
- warning("Do not use {a} as a constructor.", token, c.value);
- break;
- case 'Function':
- if (!option.evil) {
- warning("The Function constructor is eval.");
- }
- break;
- case 'Date':
- case 'RegExp':
- break;
- default:
- if (c.id !== 'function') {
- i = c.value.substr(0, 1);
- if (option.newcap && (i < 'A' || i > 'Z')) {
- warning(
- "A constructor name should start with an uppercase letter.",
- token);
- }
- }
- }
- } else {
- if (c.id !== '.' && c.id !== '[' && c.id !== '(') {
- warning("Bad constructor.", token);
- }
- }
- } else {
- warning("Weird construction. Delete 'new'.", this);
- }
- adjacent(token, nexttoken);
- if (nexttoken.id !== '(') {
- warning("Missing '()' invoking a constructor.");
- }
- this.first = c;
- return this;
- });
- syntax['new'].exps = true;
-
- infix('.', function (left, that) {
- adjacent(prevtoken, token);
- var m = identifier();
- if (typeof m === 'string') {
- countMember(m);
- }
- that.left = left;
- that.right = m;
- if (!option.evil && left && left.value === 'document' &&
- (m === 'write' || m === 'writeln')) {
- warning("document.write can be a form of eval.", left);
- } else if (option.adsafe) {
- if (left && left.value === 'ADSAFE') {
- if (m === 'id' || m === 'lib') {
- warning("ADsafe violation.", that);
- } else if (m === 'go') {
- if (xmode !== 'script') {
- warning("ADsafe violation.", that);
- } else if (adsafe_went || nexttoken.id !== '(' ||
- peek(0).id !== '(string)' ||
- peek(0).value !== adsafe_id ||
- peek(1).id !== ',') {
- error("ADsafe violation: go.", that);
- }
- adsafe_went = true;
- adsafe_may = false;
- }
- }
- }
- if (!option.evil && (m === 'eval' || m === 'execScript')) {
- warning('eval is evil.');
- } else if (option.safe) {
- for (;;) {
- if (banned[m] === true) {
- warning("ADsafe restricted word '{a}'.", token, m);
- }
- if (typeof predefined[left.value] !== 'boolean' ||
- nexttoken.id === '(') {
- break;
- }
- if (standard_member[m] === true) {
- if (nexttoken.id === '.') {
- warning("ADsafe violation.", that);
- }
- break;
- }
- if (nexttoken.id !== '.') {
- warning("ADsafe violation.", that);
- break;
- }
- advance('.');
- token.left = that;
- token.right = m;
- that = token;
- m = identifier();
- if (typeof m === 'string') {
- countMember(m);
- }
- }
- }
- return that;
- }, 160, true);
-
- infix('(', function (left, that) {
- adjacent(prevtoken, token);
- nospace();
- var n = 0,
- p = [];
- if (left) {
- if (left.type === '(identifier)') {
- if (left.value.match(/^[A-Z]([A-Z0-9_$]*[a-z][A-Za-z0-9_$]*)?$/)) {
- if (left.value !== 'Number' && left.value !== 'String' &&
- left.value !== 'Boolean' &&
- left.value !== 'Date') {
- if (left.value === 'Math') {
- warning("Math is not a function.", left);
- } else if (option.newcap) {
- warning(
-"Missing 'new' prefix when invoking a constructor.", left);
- }
- }
- }
- } else if (left.id === '.') {
- if (option.safe && left.left.value === 'Math' &&
- left.right === 'random') {
- warning("ADsafe violation.", left);
- }
- }
- }
- if (nexttoken.id !== ')') {
- for (;;) {
- p[p.length] = parse(10);
- n += 1;
- if (nexttoken.id !== ',') {
- break;
- }
- comma();
- }
- }
- advance(')');
- if (option.immed && left.id === 'function' && nexttoken.id !== ')') {
- warning("Wrap the entire immediate function invocation in parens.",
- that);
- }
- nospace(prevtoken, token);
- if (typeof left === 'object') {
- if (left.value === 'parseInt' && n === 1) {
- warning("Missing radix parameter.", left);
- }
- if (!option.evil) {
- if (left.value === 'eval' || left.value === 'Function' ||
- left.value === 'execScript') {
- warning("eval is evil.", left);
- } else if (p[0] && p[0].id === '(string)' &&
- (left.value === 'setTimeout' ||
- left.value === 'setInterval')) {
- warning(
- "Implied eval is evil. Pass a function instead of a string.", left);
- }
- }
- if (!left.identifier && left.id !== '.' && left.id !== '[' &&
- left.id !== '(' && left.id !== '&&' && left.id !== '||' &&
- left.id !== '?') {
- warning("Bad invocation.", left);
- }
- }
- that.left = left;
- return that;
- }, 155, true).exps = true;
-
- prefix('(', function () {
- nospace();
- var v = parse(0);
- advance(')', this);
- nospace(prevtoken, token);
- if (option.immed && v.id === 'function') {
- if (nexttoken.id === '(') {
- warning(
-"Move the invocation into the parens that contain the function.", nexttoken);
- } else {
- warning(
-"Do not wrap function literals in parens unless they are to be immediately invoked.",
- this);
- }
- }
- return v;
- });
-
- infix('[', function (left, that) {
- nospace();
- var e = parse(0), s;
- if (e && e.type === '(string)') {
- if (option.safe && banned[e.value] === true) {
- warning("ADsafe restricted word '{a}'.", that, e.value);
- } else if (!option.evil &&
- (e.value === 'eval' || e.value === 'execScript')) {
- warning("eval is evil.", that);
- } else if (option.safe &&
- (e.value.charAt(0) === '_' || e.value.charAt(0) === '-')) {
- warning("ADsafe restricted subscript '{a}'.", that, e.value);
- }
- countMember(e.value);
- if (!option.sub && ix.test(e.value)) {
- s = syntax[e.value];
- if (!s || !s.reserved) {
- warning("['{a}'] is better written in dot notation.",
- e, e.value);
- }
- }
- } else if (!e || e.type !== '(number)' || e.value < 0) {
- if (option.safe) {
- warning('ADsafe subscripting.');
- }
- }
- advance(']', that);
- nospace(prevtoken, token);
- that.left = left;
- that.right = e;
- return that;
- }, 160, true);
-
- prefix('[', function () {
- var b = token.line !== nexttoken.line;
- this.first = [];
- if (b) {
- indent += option.indent;
- if (nexttoken.from === indent + option.indent) {
- indent += option.indent;
- }
- }
- while (nexttoken.id !== '(end)') {
- while (nexttoken.id === ',') {
- warning("Extra comma.");
- advance(',');
- }
- if (nexttoken.id === ']') {
- break;
- }
- if (b && token.line !== nexttoken.line) {
- indentation();
- }
- this.first.push(parse(10));
- if (nexttoken.id === ',') {
- comma();
- if (nexttoken.id === ']') {
- warning("Extra comma.", token);
- break;
- }
- } else {
- break;
- }
- }
- if (b) {
- indent -= option.indent;
- indentation();
- }
- advance(']', this);
- return this;
- }, 160);
-
- (function (x) {
- x.nud = function () {
- var b, i, s, seen = {};
- b = token.line !== nexttoken.line;
- if (b) {
- indent += option.indent;
- if (nexttoken.from === indent + option.indent) {
- indent += option.indent;
- }
- }
- for (;;) {
- if (nexttoken.id === '}') {
- break;
- }
- if (b) {
- indentation();
- }
- i = optionalidentifier(true);
- if (!i) {
- if (nexttoken.id === '(string)') {
- i = nexttoken.value;
- if (ix.test(i)) {
- s = syntax[i];
- }
- advance();
- } else if (nexttoken.id === '(number)') {
- i = nexttoken.value.toString();
- advance();
- } else {
- error("Expected '{a}' and instead saw '{b}'.",
- nexttoken, '}', nexttoken.value);
- }
- }
- if (seen[i] === true) {
- warning("Duplicate member '{a}'.", nexttoken, i);
- }
- seen[i] = true;
- countMember(i);
- advance(':');
- nonadjacent(token, nexttoken);
- parse(10);
- if (nexttoken.id === ',') {
- comma();
- if (nexttoken.id === ',' || nexttoken.id === '}') {
- warning("Extra comma.", token);
- }
- } else {
- break;
- }
- }
- if (b) {
- indent -= option.indent;
- indentation();
- }
- advance('}', this);
- return this;
- };
- x.fud = function () {
- error("Expected to see a statement and instead saw a block.", token);
- };
- }(delim('{')));
-
-
- function varstatement(prefix) {
-
-// JavaScript does not have block scope. It only has function scope. So,
-// declaring a variable in a block can have unexpected consequences.
-
- var id, name, value;
-
- if (funct['(onevar)'] && option.onevar) {
- warning("Too many var statements.");
- } else if (!funct['(global)']) {
- funct['(onevar)'] = true;
- }
- this.first = [];
- for (;;) {
- nonadjacent(token, nexttoken);
- id = identifier();
- if (funct['(global)'] && predefined[id] === false) {
- warning("Redefinition of '{a}'.", token, id);
- }
- addlabel(id, 'unused');
- if (prefix) {
- break;
- }
- name = token;
- this.first.push(token);
- if (nexttoken.id === '=') {
- nonadjacent(token, nexttoken);
- advance('=');
- nonadjacent(token, nexttoken);
- if (nexttoken.id === 'undefined') {
- warning("It is not necessary to initialize '{a}' to 'undefined'.", token, id);
- }
- if (peek(0).id === '=' && nexttoken.identifier) {
- error("Variable {a} was not declared correctly.",
- nexttoken, nexttoken.value);
- }
- value = parse(0);
- name.first = value;
- }
- if (nexttoken.id !== ',') {
- break;
- }
- comma();
- }
- return this;
- }
-
-
- stmt('var', varstatement).exps = true;
-
-
- function functionparams() {
- var i, t = nexttoken, p = [];
- advance('(');
- nospace();
- if (nexttoken.id === ')') {
- advance(')');
- nospace(prevtoken, token);
- return;
- }
- for (;;) {
- i = identifier();
- p.push(i);
- addlabel(i, 'parameter');
- if (nexttoken.id === ',') {
- comma();
- } else {
- advance(')', t);
- nospace(prevtoken, token);
- return p;
- }
- }
- }
-
- function doFunction(i) {
- var s = scope;
- scope = Object.create(s);
- funct = {
- '(name)' : i || '"' + anonname + '"',
- '(line)' : nexttoken.line,
- '(context)' : funct,
- '(breakage)': 0,
- '(loopage)' : 0,
- '(scope)' : scope
- };
- token.funct = funct;
- functions.push(funct);
- if (i) {
- addlabel(i, 'function');
- }
- funct['(params)'] = functionparams();
-
- block(false);
- scope = s;
- funct['(last)'] = token.line;
- funct = funct['(context)'];
- }
-
-
- blockstmt('function', function () {
- if (inblock) {
- warning(
-"Function statements cannot be placed in blocks. Use a function expression or move the statement to the top of the outer function.", token);
-
- }
- var i = identifier();
- adjacent(token, nexttoken);
- addlabel(i, 'unused');
- doFunction(i);
- if (nexttoken.id === '(' && nexttoken.line === token.line) {
- error(
-"Function statements are not invocable. Wrap the whole function invocation in parens.");
- }
- return this;
- });
-
- prefix('function', function () {
- var i = optionalidentifier();
- if (i) {
- adjacent(token, nexttoken);
- } else {
- nonadjacent(token, nexttoken);
- }
- doFunction(i);
- if (funct['(loopage)']) {
- warning("Don't make functions within a loop.");
- }
- return this;
- });
-
- blockstmt('if', function () {
- var t = nexttoken;
- advance('(');
- nonadjacent(this, t);
- nospace();
- parse(20);
- if (nexttoken.id === '=') {
- warning("Expected a conditional expression and instead saw an assignment.");
- advance('=');
- parse(20);
- }
- advance(')', t);
- nospace(prevtoken, token);
- block(true);
- if (nexttoken.id === 'else') {
- nonadjacent(token, nexttoken);
- advance('else');
- if (nexttoken.id === 'if' || nexttoken.id === 'switch') {
- statement(true);
- } else {
- block(true);
- }
- }
- return this;
- });
-
- blockstmt('try', function () {
- var b, e, s;
- if (option.adsafe) {
- warning("ADsafe try violation.", this);
- }
- block(false);
- if (nexttoken.id === 'catch') {
- advance('catch');
- nonadjacent(token, nexttoken);
- advance('(');
- s = scope;
- scope = Object.create(s);
- e = nexttoken.value;
- if (nexttoken.type !== '(identifier)') {
- warning("Expected an identifier and instead saw '{a}'.",
- nexttoken, e);
- } else {
- addlabel(e, 'exception');
- }
- advance();
- advance(')');
- block(false);
- b = true;
- scope = s;
- }
- if (nexttoken.id === 'finally') {
- advance('finally');
- block(false);
- return;
- } else if (!b) {
- error("Expected '{a}' and instead saw '{b}'.",
- nexttoken, 'catch', nexttoken.value);
- }
- return this;
- });
-
- blockstmt('while', function () {
- var t = nexttoken;
- funct['(breakage)'] += 1;
- funct['(loopage)'] += 1;
- advance('(');
- nonadjacent(this, t);
- nospace();
- parse(20);
- if (nexttoken.id === '=') {
- warning("Expected a conditional expression and instead saw an assignment.");
- advance('=');
- parse(20);
- }
- advance(')', t);
- nospace(prevtoken, token);
- block(true);
- funct['(breakage)'] -= 1;
- funct['(loopage)'] -= 1;
- return this;
- }).labelled = true;
-
- reserve('with');
-
- blockstmt('switch', function () {
- var t = nexttoken,
- g = false;
- funct['(breakage)'] += 1;
- advance('(');
- nonadjacent(this, t);
- nospace();
- this.condition = parse(20);
- advance(')', t);
- nospace(prevtoken, token);
- nonadjacent(token, nexttoken);
- t = nexttoken;
- advance('{');
- nonadjacent(token, nexttoken);
- indent += option.indent;
- this.cases = [];
- for (;;) {
- switch (nexttoken.id) {
- case 'case':
- switch (funct['(verb)']) {
- case 'break':
- case 'case':
- case 'continue':
- case 'return':
- case 'switch':
- case 'throw':
- break;
- default:
- warning(
- "Expected a 'break' statement before 'case'.",
- token);
- }
- indentation(-option.indent);
- advance('case');
- this.cases.push(parse(20));
- g = true;
- advance(':');
- funct['(verb)'] = 'case';
- break;
- case 'default':
- switch (funct['(verb)']) {
- case 'break':
- case 'continue':
- case 'return':
- case 'throw':
- break;
- default:
- warning(
- "Expected a 'break' statement before 'default'.",
- token);
- }
- indentation(-option.indent);
- advance('default');
- g = true;
- advance(':');
- break;
- case '}':
- indent -= option.indent;
- indentation();
- advance('}', t);
- if (this.cases.length === 1 || this.condition.id === 'true' ||
- this.condition.id === 'false') {
- warning("This 'switch' should be an 'if'.", this);
- }
- funct['(breakage)'] -= 1;
- funct['(verb)'] = undefined;
- return;
- case '(end)':
- error("Missing '{a}'.", nexttoken, '}');
- return;
- default:
- if (g) {
- switch (token.id) {
- case ',':
- error("Each value should have its own case label.");
- return;
- case ':':
- statements();
- break;
- default:
- error("Missing ':' on a case clause.", token);
- }
- } else {
- error("Expected '{a}' and instead saw '{b}'.",
- nexttoken, 'case', nexttoken.value);
- }
- }
- }
- }).labelled = true;
-
- stmt('debugger', function () {
- if (!option.debug) {
- warning("All 'debugger' statements should be removed.");
- }
- return this;
- }).exps = true;
-
- (function () {
- var x = stmt('do', function () {
- funct['(breakage)'] += 1;
- funct['(loopage)'] += 1;
- this.first = block(true);
- advance('while');
- var t = nexttoken;
- nonadjacent(token, t);
- advance('(');
- nospace();
- parse(20);
- if (nexttoken.id === '=') {
- warning("Expected a conditional expression and instead saw an assignment.");
- advance('=');
- parse(20);
- }
- advance(')', t);
- nospace(prevtoken, token);
- funct['(breakage)'] -= 1;
- funct['(loopage)'] -= 1;
- return this;
- });
- x.labelled = true;
- x.exps = true;
- }());
-
- blockstmt('for', function () {
- var f = option.forin, s, t = nexttoken;
- funct['(breakage)'] += 1;
- funct['(loopage)'] += 1;
- advance('(');
- nonadjacent(this, t);
- nospace();
- if (peek(nexttoken.id === 'var' ? 1 : 0).id === 'in') {
- if (nexttoken.id === 'var') {
- advance('var');
- varstatement(true);
- } else {
- switch (funct[nexttoken.value]) {
- case 'unused':
- funct[nexttoken.value] = 'var';
- break;
- case 'var':
- break;
- default:
- warning("Bad for in variable '{a}'.",
- nexttoken, nexttoken.value);
- }
- advance();
- }
- advance('in');
- parse(20);
- advance(')', t);
- s = block(true);
- if (!f && (s.length > 1 || typeof s[0] !== 'object' ||
- s[0].value !== 'if')) {
- warning("The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype.", this);
- }
- funct['(breakage)'] -= 1;
- funct['(loopage)'] -= 1;
- return this;
- } else {
- if (nexttoken.id !== ';') {
- if (nexttoken.id === 'var') {
- advance('var');
- varstatement();
- } else {
- for (;;) {
- parse(0, 'for');
- if (nexttoken.id !== ',') {
- break;
- }
- comma();
- }
- }
- }
- nolinebreak(token);
- advance(';');
- if (nexttoken.id !== ';') {
- parse(20);
- if (nexttoken.id === '=') {
- warning("Expected a conditional expression and instead saw an assignment.");
- advance('=');
- parse(20);
- }
- }
- nolinebreak(token);
- advance(';');
- if (nexttoken.id === ';') {
- error("Expected '{a}' and instead saw '{b}'.",
- nexttoken, ')', ';');
- }
- if (nexttoken.id !== ')') {
- for (;;) {
- parse(0, 'for');
- if (nexttoken.id !== ',') {
- break;
- }
- comma();
- }
- }
- advance(')', t);
- nospace(prevtoken, token);
- block(true);
- funct['(breakage)'] -= 1;
- funct['(loopage)'] -= 1;
- return this;
- }
- }).labelled = true;
-
-
- stmt('break', function () {
- var v = nexttoken.value;
- if (funct['(breakage)'] === 0) {
- warning("Unexpected '{a}'.", nexttoken, this.value);
- }
- nolinebreak(this);
- if (nexttoken.id !== ';') {
- if (token.line === nexttoken.line) {
- if (funct[v] !== 'label') {
- warning("'{a}' is not a statement label.", nexttoken, v);
- } else if (scope[v] !== funct) {
- warning("'{a}' is out of scope.", nexttoken, v);
- }
- this.first = nexttoken;
- advance();
- }
- }
- reachable('break');
- return this;
- }).exps = true;
-
-
- stmt('continue', function () {
- var v = nexttoken.value;
- if (funct['(breakage)'] === 0) {
- warning("Unexpected '{a}'.", nexttoken, this.value);
- }
- nolinebreak(this);
- if (nexttoken.id !== ';') {
- if (token.line === nexttoken.line) {
- if (funct[v] !== 'label') {
- warning("'{a}' is not a statement label.", nexttoken, v);
- } else if (scope[v] !== funct) {
- warning("'{a}' is out of scope.", nexttoken, v);
- }
- this.first = nexttoken;
- advance();
- }
- } else if (!funct['(loopage)']) {
- warning("Unexpected '{a}'.", nexttoken, this.value);
- }
- reachable('continue');
- return this;
- }).exps = true;
-
-
- stmt('return', function () {
- nolinebreak(this);
- if (nexttoken.id === '(regexp)') {
- warning("Wrap the /regexp/ literal in parens to disambiguate the slash operator.");
- }
- if (nexttoken.id !== ';' && !nexttoken.reach) {
- nonadjacent(token, nexttoken);
- this.first = parse(20);
- }
- reachable('return');
- return this;
- }).exps = true;
-
-
- stmt('throw', function () {
- nolinebreak(this);
- nonadjacent(token, nexttoken);
- this.first = parse(20);
- reachable('throw');
- return this;
- }).exps = true;
-
- reserve('void');
-
-// Superfluous reserved words
-
- reserve('class');
- reserve('const');
- reserve('enum');
- reserve('export');
- reserve('extends');
- reserve('import');
- reserve('super');
-
- reserve('let');
- reserve('yield');
- reserve('implements');
- reserve('interface');
- reserve('package');
- reserve('private');
- reserve('protected');
- reserve('public');
- reserve('static');
-
- function jsonValue() {
-
- function jsonObject() {
- var o = {}, t = nexttoken;
- advance('{');
- if (nexttoken.id !== '}') {
- for (;;) {
- if (nexttoken.id === '(end)') {
- error("Missing '}' to match '{' from line {a}.",
- nexttoken, t.line);
- } else if (nexttoken.id === '}') {
- warning("Unexpected comma.", token);
- break;
- } else if (nexttoken.id === ',') {
- error("Unexpected comma.", nexttoken);
- } else if (nexttoken.id !== '(string)') {
- warning("Expected a string and instead saw {a}.",
- nexttoken, nexttoken.value);
- }
- if (o[nexttoken.value] === true) {
- warning("Duplicate key '{a}'.",
- nexttoken, nexttoken.value);
- } else if (nexttoken.value === '__proto__') {
- warning("Stupid key '{a}'.",
- nexttoken, nexttoken.value);
- } else {
- o[nexttoken.value] = true;
- }
- advance();
- advance(':');
- jsonValue();
- if (nexttoken.id !== ',') {
- break;
- }
- advance(',');
- }
- }
- advance('}');
- }
-
- function jsonArray() {
- var t = nexttoken;
- advance('[');
- if (nexttoken.id !== ']') {
- for (;;) {
- if (nexttoken.id === '(end)') {
- error("Missing ']' to match '[' from line {a}.",
- nexttoken, t.line);
- } else if (nexttoken.id === ']') {
- warning("Unexpected comma.", token);
- break;
- } else if (nexttoken.id === ',') {
- error("Unexpected comma.", nexttoken);
- }
- jsonValue();
- if (nexttoken.id !== ',') {
- break;
- }
- advance(',');
- }
- }
- advance(']');
- }
-
- switch (nexttoken.id) {
- case '{':
- jsonObject();
- break;
- case '[':
- jsonArray();
- break;
- case 'true':
- case 'false':
- case 'null':
- case '(number)':
- case '(string)':
- advance();
- break;
- case '-':
- advance('-');
- if (token.character !== nexttoken.from) {
- warning("Unexpected space after '-'.", token);
- }
- adjacent(token, nexttoken);
- advance('(number)');
- break;
- default:
- error("Expected a JSON value.", nexttoken);
- }
- }
-
-
-// The actual JSLINT function itself.
-
- var itself = function (s, o) {
- var a, i;
- JSLINT.errors = [];
- predefined = Object.create(standard);
- if (o) {
- a = o.predef;
- if (a instanceof Array) {
- for (i = 0; i < a.length; i += 1) {
- predefined[a[i]] = true;
- }
- }
- if (o.adsafe) {
- o.safe = true;
- }
- if (o.safe) {
- o.browser = false;
- o.css = false;
- o.debug = false;
- o.devel = false;
- o.eqeqeq = true;
- o.evil = false;
- o.forin = false;
- o.nomen = true;
- o.on = false;
- o.rhino = false;
- o.safe = true;
- o.sidebar = false;
- o.strict = true;
- o.sub = false;
- o.undef = true;
- o.widget = false;
- predefined.Date = null;
- predefined['eval'] = null;
- predefined.Function = null;
- predefined.Object = null;
- predefined.ADSAFE = false;
- predefined.lib = false;
- }
- option = o;
- } else {
- option = {};
- }
- option.indent = option.indent || 4;
- option.maxerr = option.maxerr || 50;
- adsafe_id = '';
- adsafe_may = false;
- adsafe_went = false;
- approved = {};
- if (option.approved) {
- for (i = 0; i < option.approved.length; i += 1) {
- approved[option.approved[i]] = option.approved[i];
- }
- } else {
- approved.test = 'test';
- }
- tab = '';
- for (i = 0; i < option.indent; i += 1) {
- tab += ' ';
- }
- indent = 1;
- global = Object.create(predefined);
- scope = global;
- funct = {
- '(global)': true,
- '(name)': '(global)',
- '(scope)': scope,
- '(breakage)': 0,
- '(loopage)': 0
- };
- functions = [funct];
- ids = {};
- urls = [];
- src = false;
- xmode = false;
- stack = null;
- member = {};
- membersOnly = null;
- implied = {};
- inblock = false;
- lookahead = [];
- jsonmode = false;
- warnings = 0;
- lex.init(s);
- prereg = true;
- strict_mode = false;
-
- prevtoken = token = nexttoken = syntax['(begin)'];
- assume();
-
- try {
- advance();
- if (nexttoken.value.charAt(0) === '<') {
- html();
- if (option.adsafe && !adsafe_went) {
- warning("ADsafe violation: Missing ADSAFE.go.", this);
- }
- } else {
- switch (nexttoken.id) {
- case '{':
- case '[':
- option.laxbreak = true;
- jsonmode = true;
- jsonValue();
- break;
- case '@':
- case '*':
- case '#':
- case '.':
- case ':':
- xmode = 'style';
- advance();
- if (token.id !== '@' || !nexttoken.identifier ||
- nexttoken.value !== 'charset' || token.line !== 1 ||
- token.from !== 1) {
- error('A css file should begin with @charset "UTF-8";');
- }
- advance();
- if (nexttoken.type !== '(string)' &&
- nexttoken.value !== 'UTF-8') {
- error('A css file should begin with @charset "UTF-8";');
- }
- advance();
- advance(';');
- styles();
- break;
-
- default:
- if (option.adsafe && option.fragment) {
- error("Expected '{a}' and instead saw '{b}'.",
- nexttoken, '<div>', nexttoken.value);
- }
- statements('lib');
- }
- }
- advance('(end)');
- } catch (e) {
- if (e) {
- JSLINT.errors.push({
- reason : e.message,
- line : e.line || nexttoken.line,
- character : e.character || nexttoken.from
- }, null);
- }
- }
- return JSLINT.errors.length === 0;
- };
-
- function is_array(o) {
- return Object.prototype.toString.apply(o) === '[object Array]';
- }
-
- function to_array(o) {
- var a = [], k;
- for (k in o) {
- if (is_own(o, k)) {
- a.push(k);
- }
- }
- return a;
- }
-
-// Data summary.
-
- itself.data = function () {
-
- var data = {functions: []}, fu, globals, implieds = [], f, i, j,
- members = [], n, unused = [], v;
- if (itself.errors.length) {
- data.errors = itself.errors;
- }
-
- if (jsonmode) {
- data.json = true;
- }
-
- for (n in implied) {
- if (is_own(implied, n)) {
- implieds.push({
- name: n,
- line: implied[n]
- });
- }
- }
- if (implieds.length > 0) {
- data.implieds = implieds;
- }
-
- if (urls.length > 0) {
- data.urls = urls;
- }
-
- globals = to_array(scope);
- if (globals.length > 0) {
- data.globals = globals;
- }
-
- for (i = 1; i < functions.length; i += 1) {
- f = functions[i];
- fu = {};
- for (j = 0; j < functionicity.length; j += 1) {
- fu[functionicity[j]] = [];
- }
- for (n in f) {
- if (is_own(f, n) && n.charAt(0) !== '(') {
- v = f[n];
- if (is_array(fu[v])) {
- fu[v].push(n);
- if (v === 'unused') {
- unused.push({
- name: n,
- line: f['(line)'],
- 'function': f['(name)']
- });
- }
- }
- }
- }
- for (j = 0; j < functionicity.length; j += 1) {
- if (fu[functionicity[j]].length === 0) {
- delete fu[functionicity[j]];
- }
- }
- fu.name = f['(name)'];
- fu.param = f['(params)'];
- fu.line = f['(line)'];
- fu.last = f['(last)'];
- data.functions.push(fu);
- }
-
- if (unused.length > 0) {
- data.unused = unused;
- }
-
- members = [];
- for (n in member) {
- if (typeof member[n] === 'number') {
- data.member = member;
- break;
- }
- }
-
- return data;
- };
-
- itself.report = function (option) {
- var data = itself.data();
-
- var a = [], c, e, err, f, i, k, l, m = '', n, o = [], s;
-
- function detail(h, array) {
- var b, i, singularity;
- if (array) {
- o.push('<div><i>' + h + '</i> ');
- array = array.sort();
- for (i = 0; i < array.length; i += 1) {
- if (array[i] !== singularity) {
- singularity = array[i];
- o.push((b ? ', ' : '') + singularity);
- b = true;
- }
- }
- o.push('</div>');
- }
- }
-
-
- if (data.errors || data.implieds || data.unused) {
- err = true;
- o.push('<div id=errors><i>Error:</i>');
- if (data.errors) {
- for (i = 0; i < data.errors.length; i += 1) {
- c = data.errors[i];
- if (c) {
- e = c.evidence || '';
- o.push('<p>Problem' + (isFinite(c.line) ? ' at line ' +
- c.line + ' character ' + c.character : '') +
- ': ' + c.reason.entityify() +
- '</p><p class=evidence>' +
- (e && (e.length > 80 ? e.slice(0, 77) + '...' :
- e).entityify()) + '</p>');
- }
- }
- }
-
- if (data.implieds) {
- s = [];
- for (i = 0; i < data.implieds.length; i += 1) {
- s[i] = '<code>' + data.implieds[i].name + '</code>&nbsp;<i>' +
- data.implieds[i].line + '</i>';
- }
- o.push('<p><i>Implied global:</i> ' + s.join(', ') + '</p>');
- }
-
- if (data.unused) {
- s = [];
- for (i = 0; i < data.unused.length; i += 1) {
- s[i] = '<code><u>' + data.unused[i].name + '</u></code>&nbsp;<i>' +
- data.unused[i].line + '</i> <code>' +
- data.unused[i]['function'] + '</code>';
- }
- o.push('<p><i>Unused variable:</i> ' + s.join(', ') + '</p>');
- }
- if (data.json) {
- o.push('<p>JSON: bad.</p>');
- }
- o.push('</div>');
- }
-
- if (!option) {
-
- o.push('<br><div id=functions>');
-
- if (data.urls) {
- detail("URLs<br>", data.urls, '<br>');
- }
-
- if (xmode === 'style') {
- o.push('<p>CSS.</p>');
- } else if (data.json && !err) {
- o.push('<p>JSON: good.</p>');
- } else if (data.globals) {
- o.push('<div><i>Global</i> ' +
- data.globals.sort().join(', ') + '</div>');
- } else {
- o.push('<div><i>No new global variables introduced.</i></div>');
- }
-
- for (i = 0; i < data.functions.length; i += 1) {
- f = data.functions[i];
-
- o.push('<br><div class=function><i>' + f.line + '-' +
- f.last + '</i> ' + (f.name || '') + '(' +
- (f.param ? f.param.join(', ') : '') + ')</div>');
- detail('<big><b>Unused</b></big>', f.unused);
- detail('Closure', f.closure);
- detail('Variable', f['var']);
- detail('Exception', f.exception);
- detail('Outer', f.outer);
- detail('Global', f.global);
- detail('Label', f.label);
- }
-
- if (data.member) {
- a = to_array(data.member);
- if (a.length) {
- a = a.sort();
- m = '<br><pre id=members>/*members ';
- l = 10;
- for (i = 0; i < a.length; i += 1) {
- k = a[i];
- n = k.name();
- if (l + n.length > 72) {
- o.push(m + '<br>');
- m = ' ';
- l = 1;
- }
- l += n.length + 2;
- if (data.member[k] === 1) {
- n = '<i>' + n + '</i>';
- }
- if (i < a.length - 1) {
- n += ', ';
- }
- m += n;
- }
- o.push(m + '<br>*/</pre>');
- }
- o.push('</div>');
- }
- }
- return o.join('');
- };
- itself.jslint = itself;
-
- itself.edition = '2010-02-20';
-
- if (typeof exports !== "undefined") {
- exports.JSLINT = itself;
- }
-
- return itself;
-
-}());
diff --git a/build/build/lib/parse-js.js b/build/build/lib/parse-js.js
deleted file mode 100644
index 8edecb733..000000000
--- a/build/build/lib/parse-js.js
+++ /dev/null
@@ -1,1315 +0,0 @@
-/***********************************************************************
-
- A JavaScript tokenizer / parser / beautifier / compressor.
-
- This version is suitable for Node.js. With minimal changes (the
- exports stuff) it should work on any JS platform.
-
- This file contains the tokenizer/parser. It is a port to JavaScript
- of parse-js [1], a JavaScript parser library written in Common Lisp
- by Marijn Haverbeke. Thank you Marijn!
-
- [1] http://marijn.haverbeke.nl/parse-js/
-
- Exported functions:
-
- - tokenizer(code) -- returns a function. Call the returned
- function to fetch the next token.
-
- - parse(code) -- returns an AST of the given JavaScript code.
-
- -------------------------------- (C) ---------------------------------
-
- Author: Mihai Bazon
- <mihai.bazon@gmail.com>
- http://mihai.bazon.net/blog
-
- Distributed under the BSD license:
-
- Copyright 2010 (c) Mihai Bazon <mihai.bazon@gmail.com>
- Based on parse-js (http://marijn.haverbeke.nl/parse-js/).
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- * Redistributions of source code must retain the above
- copyright notice, this list of conditions and the following
- disclaimer.
-
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- SUCH DAMAGE.
-
- ***********************************************************************/
-
-/* -----[ Tokenizer (constants) ]----- */
-
-var KEYWORDS = array_to_hash([
- "break",
- "case",
- "catch",
- "const",
- "continue",
- "default",
- "delete",
- "do",
- "else",
- "finally",
- "for",
- "function",
- "if",
- "in",
- "instanceof",
- "new",
- "return",
- "switch",
- "throw",
- "try",
- "typeof",
- "var",
- "void",
- "while",
- "with"
-]);
-
-var RESERVED_WORDS = array_to_hash([
- "abstract",
- "boolean",
- "byte",
- "char",
- "class",
- "debugger",
- "double",
- "enum",
- "export",
- "extends",
- "final",
- "float",
- "goto",
- "implements",
- "import",
- "int",
- "interface",
- "long",
- "native",
- "package",
- "private",
- "protected",
- "public",
- "short",
- "static",
- "super",
- "synchronized",
- "throws",
- "transient",
- "volatile"
-]);
-
-var KEYWORDS_BEFORE_EXPRESSION = array_to_hash([
- "return",
- "new",
- "delete",
- "throw",
- "else",
- "case"
-]);
-
-var KEYWORDS_ATOM = array_to_hash([
- "false",
- "null",
- "true",
- "undefined"
-]);
-
-var OPERATOR_CHARS = array_to_hash(characters("+-*&%=<>!?|~^"));
-
-var RE_HEX_NUMBER = /^0x[0-9a-f]+$/i;
-var RE_OCT_NUMBER = /^0[0-7]+$/;
-var RE_DEC_NUMBER = /^\d*\.?\d*(?:e[+-]?\d*(?:\d\.?|\.?\d)\d*)?$/i;
-
-var OPERATORS = array_to_hash([
- "in",
- "instanceof",
- "typeof",
- "new",
- "void",
- "delete",
- "++",
- "--",
- "+",
- "-",
- "!",
- "~",
- "&",
- "|",
- "^",
- "*",
- "/",
- "%",
- ">>",
- "<<",
- ">>>",
- "<",
- ">",
- "<=",
- ">=",
- "==",
- "===",
- "!=",
- "!==",
- "?",
- "=",
- "+=",
- "-=",
- "/=",
- "*=",
- "%=",
- ">>=",
- "<<=",
- ">>>=",
- "|=",
- "^=",
- "&=",
- "&&",
- "||"
-]);
-
-var WHITESPACE_CHARS = array_to_hash(characters(" \n\r\t\u200b"));
-
-var PUNC_BEFORE_EXPRESSION = array_to_hash(characters("[{}(,.;:"));
-
-var PUNC_CHARS = array_to_hash(characters("[]{}(),;:"));
-
-var REGEXP_MODIFIERS = array_to_hash(characters("gmsiy"));
-
-/* -----[ Tokenizer ]----- */
-
-// regexps adapted from http://xregexp.com/plugins/#unicode
-var UNICODE = {
- letter: new RegExp("[\\u0041-\\u005A\\u0061-\\u007A\\u00AA\\u00B5\\u00BA\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u0523\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0621-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971\\u0972\\u097B-\\u097F\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C33\\u0C35-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D28\\u0D2A-\\u0D39\\u0D3D\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC\\u0EDD\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8B\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10D0-\\u10FA\\u10FC\\u1100-\\u1159\\u115F-\\u11A2\\u11A8-\\u11F9\\u1200-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u1676\\u1681-\\u169A\\u16A0-\\u16EA\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u1900-\\u191C\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19A9\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u2094\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2183\\u2184\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2C6F\\u2C71-\\u2C7D\\u2C80-\\u2CE4\\u2D00-\\u2D25\\u2D30-\\u2D65\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005\\u3006\\u3031-\\u3035\\u303B\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31B7\\u31F0-\\u31FF\\u3400\\u4DB5\\u4E00\\u9FC3\\uA000-\\uA48C\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA65F\\uA662-\\uA66E\\uA67F-\\uA697\\uA717-\\uA71F\\uA722-\\uA788\\uA78B\\uA78C\\uA7FB-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA90A-\\uA925\\uA930-\\uA946\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAC00\\uD7A3\\uF900-\\uFA2D\\uFA30-\\uFA6A\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]"),
- non_spacing_mark: new RegExp("[\\u0300-\\u036F\\u0483-\\u0487\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u0610-\\u061A\\u064B-\\u065E\\u0670\\u06D6-\\u06DC\\u06DF-\\u06E4\\u06E7\\u06E8\\u06EA-\\u06ED\\u0711\\u0730-\\u074A\\u07A6-\\u07B0\\u07EB-\\u07F3\\u0816-\\u0819\\u081B-\\u0823\\u0825-\\u0827\\u0829-\\u082D\\u0900-\\u0902\\u093C\\u0941-\\u0948\\u094D\\u0951-\\u0955\\u0962\\u0963\\u0981\\u09BC\\u09C1-\\u09C4\\u09CD\\u09E2\\u09E3\\u0A01\\u0A02\\u0A3C\\u0A41\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A70\\u0A71\\u0A75\\u0A81\\u0A82\\u0ABC\\u0AC1-\\u0AC5\\u0AC7\\u0AC8\\u0ACD\\u0AE2\\u0AE3\\u0B01\\u0B3C\\u0B3F\\u0B41-\\u0B44\\u0B4D\\u0B56\\u0B62\\u0B63\\u0B82\\u0BC0\\u0BCD\\u0C3E-\\u0C40\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C62\\u0C63\\u0CBC\\u0CBF\\u0CC6\\u0CCC\\u0CCD\\u0CE2\\u0CE3\\u0D41-\\u0D44\\u0D4D\\u0D62\\u0D63\\u0DCA\\u0DD2-\\u0DD4\\u0DD6\\u0E31\\u0E34-\\u0E3A\\u0E47-\\u0E4E\\u0EB1\\u0EB4-\\u0EB9\\u0EBB\\u0EBC\\u0EC8-\\u0ECD\\u0F18\\u0F19\\u0F35\\u0F37\\u0F39\\u0F71-\\u0F7E\\u0F80-\\u0F84\\u0F86\\u0F87\\u0F90-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u102D-\\u1030\\u1032-\\u1037\\u1039\\u103A\\u103D\\u103E\\u1058\\u1059\\u105E-\\u1060\\u1071-\\u1074\\u1082\\u1085\\u1086\\u108D\\u109D\\u135F\\u1712-\\u1714\\u1732-\\u1734\\u1752\\u1753\\u1772\\u1773\\u17B7-\\u17BD\\u17C6\\u17C9-\\u17D3\\u17DD\\u180B-\\u180D\\u18A9\\u1920-\\u1922\\u1927\\u1928\\u1932\\u1939-\\u193B\\u1A17\\u1A18\\u1A56\\u1A58-\\u1A5E\\u1A60\\u1A62\\u1A65-\\u1A6C\\u1A73-\\u1A7C\\u1A7F\\u1B00-\\u1B03\\u1B34\\u1B36-\\u1B3A\\u1B3C\\u1B42\\u1B6B-\\u1B73\\u1B80\\u1B81\\u1BA2-\\u1BA5\\u1BA8\\u1BA9\\u1C2C-\\u1C33\\u1C36\\u1C37\\u1CD0-\\u1CD2\\u1CD4-\\u1CE0\\u1CE2-\\u1CE8\\u1CED\\u1DC0-\\u1DE6\\u1DFD-\\u1DFF\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2CEF-\\u2CF1\\u2DE0-\\u2DFF\\u302A-\\u302F\\u3099\\u309A\\uA66F\\uA67C\\uA67D\\uA6F0\\uA6F1\\uA802\\uA806\\uA80B\\uA825\\uA826\\uA8C4\\uA8E0-\\uA8F1\\uA926-\\uA92D\\uA947-\\uA951\\uA980-\\uA982\\uA9B3\\uA9B6-\\uA9B9\\uA9BC\\uAA29-\\uAA2E\\uAA31\\uAA32\\uAA35\\uAA36\\uAA43\\uAA4C\\uAAB0\\uAAB2-\\uAAB4\\uAAB7\\uAAB8\\uAABE\\uAABF\\uAAC1\\uABE5\\uABE8\\uABED\\uFB1E\\uFE00-\\uFE0F\\uFE20-\\uFE26]"),
- space_combining_mark: new RegExp("[\\u0903\\u093E-\\u0940\\u0949-\\u094C\\u094E\\u0982\\u0983\\u09BE-\\u09C0\\u09C7\\u09C8\\u09CB\\u09CC\\u09D7\\u0A03\\u0A3E-\\u0A40\\u0A83\\u0ABE-\\u0AC0\\u0AC9\\u0ACB\\u0ACC\\u0B02\\u0B03\\u0B3E\\u0B40\\u0B47\\u0B48\\u0B4B\\u0B4C\\u0B57\\u0BBE\\u0BBF\\u0BC1\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCC\\u0BD7\\u0C01-\\u0C03\\u0C41-\\u0C44\\u0C82\\u0C83\\u0CBE\\u0CC0-\\u0CC4\\u0CC7\\u0CC8\\u0CCA\\u0CCB\\u0CD5\\u0CD6\\u0D02\\u0D03\\u0D3E-\\u0D40\\u0D46-\\u0D48\\u0D4A-\\u0D4C\\u0D57\\u0D82\\u0D83\\u0DCF-\\u0DD1\\u0DD8-\\u0DDF\\u0DF2\\u0DF3\\u0F3E\\u0F3F\\u0F7F\\u102B\\u102C\\u1031\\u1038\\u103B\\u103C\\u1056\\u1057\\u1062-\\u1064\\u1067-\\u106D\\u1083\\u1084\\u1087-\\u108C\\u108F\\u109A-\\u109C\\u17B6\\u17BE-\\u17C5\\u17C7\\u17C8\\u1923-\\u1926\\u1929-\\u192B\\u1930\\u1931\\u1933-\\u1938\\u19B0-\\u19C0\\u19C8\\u19C9\\u1A19-\\u1A1B\\u1A55\\u1A57\\u1A61\\u1A63\\u1A64\\u1A6D-\\u1A72\\u1B04\\u1B35\\u1B3B\\u1B3D-\\u1B41\\u1B43\\u1B44\\u1B82\\u1BA1\\u1BA6\\u1BA7\\u1BAA\\u1C24-\\u1C2B\\u1C34\\u1C35\\u1CE1\\u1CF2\\uA823\\uA824\\uA827\\uA880\\uA881\\uA8B4-\\uA8C3\\uA952\\uA953\\uA983\\uA9B4\\uA9B5\\uA9BA\\uA9BB\\uA9BD-\\uA9C0\\uAA2F\\uAA30\\uAA33\\uAA34\\uAA4D\\uAA7B\\uABE3\\uABE4\\uABE6\\uABE7\\uABE9\\uABEA\\uABEC]"),
- connector_punctuation: new RegExp("[\\u005F\\u203F\\u2040\\u2054\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFF3F]")
-};
-
-function is_letter(ch) {
- return UNICODE.letter.test(ch);
-};
-
-function is_digit(ch) {
- ch = ch.charCodeAt(0);
- return ch >= 48 && ch <= 57; //XXX: find out if "UnicodeDigit" means something else than 0..9
-};
-
-function is_alphanumeric_char(ch) {
- return is_digit(ch) || is_letter(ch);
-};
-
-function is_unicode_combining_mark(ch) {
- return UNICODE.non_spacing_mark.test(ch) || UNICODE.space_combining_mark.test(ch);
-};
-
-function is_unicode_connector_punctuation(ch) {
- return UNICODE.connector_punctuation.test(ch);
-};
-
-function is_identifier_start(ch) {
- return ch == "$" || ch == "_" || is_letter(ch);
-};
-
-function is_identifier_char(ch) {
- return is_identifier_start(ch)
- || is_unicode_combining_mark(ch)
- || is_digit(ch)
- || is_unicode_connector_punctuation(ch)
- || ch == "\u200c" // zero-width non-joiner <ZWNJ>
- || ch == "\u200d" // zero-width joiner <ZWJ> (in my ECMA-262 PDF, this is also 200c)
- ;
-};
-
-function parse_js_number(num) {
- if (RE_HEX_NUMBER.test(num)) {
- return parseInt(num.substr(2), 16);
- } else if (RE_OCT_NUMBER.test(num)) {
- return parseInt(num.substr(1), 8);
- } else if (RE_DEC_NUMBER.test(num)) {
- return parseFloat(num);
- }
-};
-
-function JS_Parse_Error(message, line, col, pos) {
- this.message = message;
- this.line = line;
- this.col = col;
- this.pos = pos;
- try {
- ({})();
- } catch(ex) {
- this.stack = ex.stack;
- };
-};
-
-JS_Parse_Error.prototype.toString = function() {
- return this.message + " (line: " + this.line + ", col: " + this.col + ", pos: " + this.pos + ")" + "\n\n" + this.stack;
-};
-
-function js_error(message, line, col, pos) {
- throw new JS_Parse_Error(message, line, col, pos);
-};
-
-function is_token(token, type, val) {
- return token.type == type && (val == null || token.value == val);
-};
-
-var EX_EOF = {};
-
-function tokenizer($TEXT) {
-
- var S = {
- text : $TEXT.replace(/\r\n?|[\n\u2028\u2029]/g, "\n").replace(/^\uFEFF/, ''),
- pos : 0,
- tokpos : 0,
- line : 0,
- tokline : 0,
- col : 0,
- tokcol : 0,
- newline_before : false,
- regex_allowed : false,
- comments_before : []
- };
-
- function peek() { return S.text.charAt(S.pos); };
-
- function next(signal_eof) {
- var ch = S.text.charAt(S.pos++);
- if (signal_eof && !ch)
- throw EX_EOF;
- if (ch == "\n") {
- S.newline_before = true;
- ++S.line;
- S.col = 0;
- } else {
- ++S.col;
- }
- return ch;
- };
-
- function eof() {
- return !S.peek();
- };
-
- function find(what, signal_eof) {
- var pos = S.text.indexOf(what, S.pos);
- if (signal_eof && pos == -1) throw EX_EOF;
- return pos;
- };
-
- function start_token() {
- S.tokline = S.line;
- S.tokcol = S.col;
- S.tokpos = S.pos;
- };
-
- function token(type, value, is_comment) {
- S.regex_allowed = ((type == "operator" && !HOP(UNARY_POSTFIX, value)) ||
- (type == "keyword" && HOP(KEYWORDS_BEFORE_EXPRESSION, value)) ||
- (type == "punc" && HOP(PUNC_BEFORE_EXPRESSION, value)));
- var ret = {
- type : type,
- value : value,
- line : S.tokline,
- col : S.tokcol,
- pos : S.tokpos,
- nlb : S.newline_before
- };
- if (!is_comment) {
- ret.comments_before = S.comments_before;
- S.comments_before = [];
- }
- S.newline_before = false;
- return ret;
- };
-
- function skip_whitespace() {
- while (HOP(WHITESPACE_CHARS, peek()))
- next();
- };
-
- function read_while(pred) {
- var ret = "", ch = peek(), i = 0;
- while (ch && pred(ch, i++)) {
- ret += next();
- ch = peek();
- }
- return ret;
- };
-
- function parse_error(err) {
- js_error(err, S.tokline, S.tokcol, S.tokpos);
- };
-
- function read_num(prefix) {
- var has_e = false, after_e = false, has_x = false, has_dot = prefix == ".";
- var num = read_while(function(ch, i){
- if (ch == "x" || ch == "X") {
- if (has_x) return false;
- return has_x = true;
- }
- if (!has_x && (ch == "E" || ch == "e")) {
- if (has_e) return false;
- return has_e = after_e = true;
- }
- if (ch == "-") {
- if (after_e || (i == 0 && !prefix)) return true;
- return false;
- }
- if (ch == "+") return after_e;
- after_e = false;
- if (ch == ".") {
- if (!has_dot && !has_x)
- return has_dot = true;
- return false;
- }
- return is_alphanumeric_char(ch);
- });
- if (prefix)
- num = prefix + num;
- var valid = parse_js_number(num);
- if (!isNaN(valid)) {
- return token("num", valid);
- } else {
- parse_error("Invalid syntax: " + num);
- }
- };
-
- function read_escaped_char() {
- var ch = next(true);
- switch (ch) {
- case "n" : return "\n";
- case "r" : return "\r";
- case "t" : return "\t";
- case "b" : return "\b";
- case "v" : return "\v";
- case "f" : return "\f";
- case "0" : return "\0";
- case "x" : return String.fromCharCode(hex_bytes(2));
- case "u" : return String.fromCharCode(hex_bytes(4));
- default : return ch;
- }
- };
-
- function hex_bytes(n) {
- var num = 0;
- for (; n > 0; --n) {
- var digit = parseInt(next(true), 16);
- if (isNaN(digit))
- parse_error("Invalid hex-character pattern in string");
- num = (num << 4) | digit;
- }
- return num;
- };
-
- function read_string() {
- return with_eof_error("Unterminated string constant", function(){
- var quote = next(), ret = "";
- for (;;) {
- var ch = next(true);
- if (ch == "\\") ch = read_escaped_char();
- else if (ch == quote) break;
- ret += ch;
- }
- return token("string", ret);
- });
- };
-
- function read_line_comment() {
- next();
- var i = find("\n"), ret;
- if (i == -1) {
- ret = S.text.substr(S.pos);
- S.pos = S.text.length;
- } else {
- ret = S.text.substring(S.pos, i);
- S.pos = i;
- }
- return token("comment1", ret, true);
- };
-
- function read_multiline_comment() {
- next();
- return with_eof_error("Unterminated multiline comment", function(){
- var i = find("*/", true),
- text = S.text.substring(S.pos, i),
- tok = token("comment2", text, true);
- S.pos = i + 2;
- S.line += text.split("\n").length - 1;
- S.newline_before = text.indexOf("\n") >= 0;
-
- // https://github.com/mishoo/UglifyJS/issues/#issue/100
- if (/^@cc_on/i.test(text)) {
- warn("WARNING: at line " + S.line);
- warn("*** Found \"conditional comment\": " + text);
- warn("*** UglifyJS DISCARDS ALL COMMENTS. This means your code might no longer work properly in Internet Explorer.");
- }
-
- return tok;
- });
- };
-
- function read_name() {
- var backslash = false, name = "", ch;
- while ((ch = peek()) != null) {
- if (!backslash) {
- if (ch == "\\") backslash = true, next();
- else if (is_identifier_char(ch)) name += next();
- else break;
- }
- else {
- if (ch != "u") parse_error("Expecting UnicodeEscapeSequence -- uXXXX");
- ch = read_escaped_char();
- if (!is_identifier_char(ch)) parse_error("Unicode char: " + ch.charCodeAt(0) + " is not valid in identifier");
- name += ch;
- backslash = false;
- }
- }
- return name;
- };
-
- function read_regexp() {
- return with_eof_error("Unterminated regular expression", function(){
- var prev_backslash = false, regexp = "", ch, in_class = false;
- while ((ch = next(true))) if (prev_backslash) {
- regexp += "\\" + ch;
- prev_backslash = false;
- } else if (ch == "[") {
- in_class = true;
- regexp += ch;
- } else if (ch == "]" && in_class) {
- in_class = false;
- regexp += ch;
- } else if (ch == "/" && !in_class) {
- break;
- } else if (ch == "\\") {
- prev_backslash = true;
- } else {
- regexp += ch;
- }
- var mods = read_name();
- return token("regexp", [ regexp, mods ]);
- });
- };
-
- function read_operator(prefix) {
- function grow(op) {
- if (!peek()) return op;
- var bigger = op + peek();
- if (HOP(OPERATORS, bigger)) {
- next();
- return grow(bigger);
- } else {
- return op;
- }
- };
- return token("operator", grow(prefix || next()));
- };
-
- function handle_slash() {
- next();
- var regex_allowed = S.regex_allowed;
- switch (peek()) {
- case "/":
- S.comments_before.push(read_line_comment());
- S.regex_allowed = regex_allowed;
- return next_token();
- case "*":
- S.comments_before.push(read_multiline_comment());
- S.regex_allowed = regex_allowed;
- return next_token();
- }
- return S.regex_allowed ? read_regexp() : read_operator("/");
- };
-
- function handle_dot() {
- next();
- return is_digit(peek())
- ? read_num(".")
- : token("punc", ".");
- };
-
- function read_word() {
- var word = read_name();
- return !HOP(KEYWORDS, word)
- ? token("name", word)
- : HOP(OPERATORS, word)
- ? token("operator", word)
- : HOP(KEYWORDS_ATOM, word)
- ? token("atom", word)
- : token("keyword", word);
- };
-
- function with_eof_error(eof_error, cont) {
- try {
- return cont();
- } catch(ex) {
- if (ex === EX_EOF) parse_error(eof_error);
- else throw ex;
- }
- };
-
- function next_token(force_regexp) {
- if (force_regexp)
- return read_regexp();
- skip_whitespace();
- start_token();
- var ch = peek();
- if (!ch) return token("eof");
- if (is_digit(ch)) return read_num();
- if (ch == '"' || ch == "'") return read_string();
- if (HOP(PUNC_CHARS, ch)) return token("punc", next());
- if (ch == ".") return handle_dot();
- if (ch == "/") return handle_slash();
- if (HOP(OPERATOR_CHARS, ch)) return read_operator();
- if (ch == "\\" || is_identifier_start(ch)) return read_word();
- parse_error("Unexpected character '" + ch + "'");
- };
-
- next_token.context = function(nc) {
- if (nc) S = nc;
- return S;
- };
-
- return next_token;
-
-};
-
-/* -----[ Parser (constants) ]----- */
-
-var UNARY_PREFIX = array_to_hash([
- "typeof",
- "void",
- "delete",
- "--",
- "++",
- "!",
- "~",
- "-",
- "+"
-]);
-
-var UNARY_POSTFIX = array_to_hash([ "--", "++" ]);
-
-var ASSIGNMENT = (function(a, ret, i){
- while (i < a.length) {
- ret[a[i]] = a[i].substr(0, a[i].length - 1);
- i++;
- }
- return ret;
-})(
- ["+=", "-=", "/=", "*=", "%=", ">>=", "<<=", ">>>=", "|=", "^=", "&="],
- { "=": true },
- 0
-);
-
-var PRECEDENCE = (function(a, ret){
- for (var i = 0, n = 1; i < a.length; ++i, ++n) {
- var b = a[i];
- for (var j = 0; j < b.length; ++j) {
- ret[b[j]] = n;
- }
- }
- return ret;
-})(
- [
- ["||"],
- ["&&"],
- ["|"],
- ["^"],
- ["&"],
- ["==", "===", "!=", "!=="],
- ["<", ">", "<=", ">=", "in", "instanceof"],
- [">>", "<<", ">>>"],
- ["+", "-"],
- ["*", "/", "%"]
- ],
- {}
-);
-
-var STATEMENTS_WITH_LABELS = array_to_hash([ "for", "do", "while", "switch" ]);
-
-var ATOMIC_START_TOKEN = array_to_hash([ "atom", "num", "string", "regexp", "name" ]);
-
-/* -----[ Parser ]----- */
-
-function NodeWithToken(str, start, end) {
- this.name = str;
- this.start = start;
- this.end = end;
-};
-
-NodeWithToken.prototype.toString = function() { return this.name; };
-
-function parse($TEXT, exigent_mode, embed_tokens) {
-
- var S = {
- input : typeof $TEXT == "string" ? tokenizer($TEXT, true) : $TEXT,
- token : null,
- prev : null,
- peeked : null,
- in_function : 0,
- in_loop : 0,
- labels : []
- };
-
- S.token = next();
-
- function is(type, value) {
- return is_token(S.token, type, value);
- };
-
- function peek() { return S.peeked || (S.peeked = S.input()); };
-
- function next() {
- S.prev = S.token;
- if (S.peeked) {
- S.token = S.peeked;
- S.peeked = null;
- } else {
- S.token = S.input();
- }
- return S.token;
- };
-
- function prev() {
- return S.prev;
- };
-
- function croak(msg, line, col, pos) {
- var ctx = S.input.context();
- js_error(msg,
- line != null ? line : ctx.tokline,
- col != null ? col : ctx.tokcol,
- pos != null ? pos : ctx.tokpos);
- };
-
- function token_error(token, msg) {
- croak(msg, token.line, token.col);
- };
-
- function unexpected(token) {
- if (token == null)
- token = S.token;
- token_error(token, "Unexpected token: " + token.type + " (" + token.value + ")");
- };
-
- function expect_token(type, val) {
- if (is(type, val)) {
- return next();
- }
- token_error(S.token, "Unexpected token " + S.token.type + ", expected " + type);
- };
-
- function expect(punc) { return expect_token("punc", punc); };
-
- function can_insert_semicolon() {
- return !exigent_mode && (
- S.token.nlb || is("eof") || is("punc", "}")
- );
- };
-
- function semicolon() {
- if (is("punc", ";")) next();
- else if (!can_insert_semicolon()) unexpected();
- };
-
- function as() {
- return slice(arguments);
- };
-
- function parenthesised() {
- expect("(");
- var ex = expression();
- expect(")");
- return ex;
- };
-
- function add_tokens(str, start, end) {
- return str instanceof NodeWithToken ? str : new NodeWithToken(str, start, end);
- };
-
- function maybe_embed_tokens(parser) {
- if (embed_tokens) return function() {
- var start = S.token;
- var ast = parser.apply(this, arguments);
- ast[0] = add_tokens(ast[0], start, prev());
- return ast;
- };
- else return parser;
- };
-
- var statement = maybe_embed_tokens(function() {
- if (is("operator", "/")) {
- S.peeked = null;
- S.token = S.input(true); // force regexp
- }
- switch (S.token.type) {
- case "num":
- case "string":
- case "regexp":
- case "operator":
- case "atom":
- return simple_statement();
-
- case "name":
- return is_token(peek(), "punc", ":")
- ? labeled_statement(prog1(S.token.value, next, next))
- : simple_statement();
-
- case "punc":
- switch (S.token.value) {
- case "{":
- return as("block", block_());
- case "[":
- case "(":
- return simple_statement();
- case ";":
- next();
- return as("block");
- default:
- unexpected();
- }
-
- case "keyword":
- switch (prog1(S.token.value, next)) {
- case "break":
- return break_cont("break");
-
- case "continue":
- return break_cont("continue");
-
- case "debugger":
- semicolon();
- return as("debugger");
-
- case "do":
- return (function(body){
- expect_token("keyword", "while");
- return as("do", prog1(parenthesised, semicolon), body);
- })(in_loop(statement));
-
- case "for":
- return for_();
-
- case "function":
- return function_(true);
-
- case "if":
- return if_();
-
- case "return":
- if (S.in_function == 0)
- croak("'return' outside of function");
- return as("return",
- is("punc", ";")
- ? (next(), null)
- : can_insert_semicolon()
- ? null
- : prog1(expression, semicolon));
-
- case "switch":
- return as("switch", parenthesised(), switch_block_());
-
- case "throw":
- return as("throw", prog1(expression, semicolon));
-
- case "try":
- return try_();
-
- case "var":
- return prog1(var_, semicolon);
-
- case "const":
- return prog1(const_, semicolon);
-
- case "while":
- return as("while", parenthesised(), in_loop(statement));
-
- case "with":
- return as("with", parenthesised(), statement());
-
- default:
- unexpected();
- }
- }
- });
-
- function labeled_statement(label) {
- S.labels.push(label);
- var start = S.token, stat = statement();
- if (exigent_mode && !HOP(STATEMENTS_WITH_LABELS, stat[0]))
- unexpected(start);
- S.labels.pop();
- return as("label", label, stat);
- };
-
- function simple_statement() {
- return as("stat", prog1(expression, semicolon));
- };
-
- function break_cont(type) {
- var name = is("name") ? S.token.value : null;
- if (name != null) {
- next();
- if (!member(name, S.labels))
- croak("Label " + name + " without matching loop or statement");
- }
- else if (S.in_loop == 0)
- croak(type + " not inside a loop or switch");
- semicolon();
- return as(type, name);
- };
-
- function for_() {
- expect("(");
- var init = null;
- if (!is("punc", ";")) {
- init = is("keyword", "var")
- ? (next(), var_(true))
- : expression(true, true);
- if (is("operator", "in"))
- return for_in(init);
- }
- return regular_for(init);
- };
-
- function regular_for(init) {
- expect(";");
- var test = is("punc", ";") ? null : expression();
- expect(";");
- var step = is("punc", ")") ? null : expression();
- expect(")");
- return as("for", init, test, step, in_loop(statement));
- };
-
- function for_in(init) {
- var lhs = init[0] == "var" ? as("name", init[1][0]) : init;
- next();
- var obj = expression();
- expect(")");
- return as("for-in", init, lhs, obj, in_loop(statement));
- };
-
- var function_ = maybe_embed_tokens(function(in_statement) {
- var name = is("name") ? prog1(S.token.value, next) : null;
- if (in_statement && !name)
- unexpected();
- expect("(");
- return as(in_statement ? "defun" : "function",
- name,
- // arguments
- (function(first, a){
- while (!is("punc", ")")) {
- if (first) first = false; else expect(",");
- if (!is("name")) unexpected();
- a.push(S.token.value);
- next();
- }
- next();
- return a;
- })(true, []),
- // body
- (function(){
- ++S.in_function;
- var loop = S.in_loop;
- S.in_loop = 0;
- var a = block_();
- --S.in_function;
- S.in_loop = loop;
- return a;
- })());
- });
-
- function if_() {
- var cond = parenthesised(), body = statement(), belse;
- if (is("keyword", "else")) {
- next();
- belse = statement();
- }
- return as("if", cond, body, belse);
- };
-
- function block_() {
- expect("{");
- var a = [];
- while (!is("punc", "}")) {
- if (is("eof")) unexpected();
- a.push(statement());
- }
- next();
- return a;
- };
-
- var switch_block_ = curry(in_loop, function(){
- expect("{");
- var a = [], cur = null;
- while (!is("punc", "}")) {
- if (is("eof")) unexpected();
- if (is("keyword", "case")) {
- next();
- cur = [];
- a.push([ expression(), cur ]);
- expect(":");
- }
- else if (is("keyword", "default")) {
- next();
- expect(":");
- cur = [];
- a.push([ null, cur ]);
- }
- else {
- if (!cur) unexpected();
- cur.push(statement());
- }
- }
- next();
- return a;
- });
-
- function try_() {
- var body = block_(), bcatch, bfinally;
- if (is("keyword", "catch")) {
- next();
- expect("(");
- if (!is("name"))
- croak("Name expected");
- var name = S.token.value;
- next();
- expect(")");
- bcatch = [ name, block_() ];
- }
- if (is("keyword", "finally")) {
- next();
- bfinally = block_();
- }
- if (!bcatch && !bfinally)
- croak("Missing catch/finally blocks");
- return as("try", body, bcatch, bfinally);
- };
-
- function vardefs(no_in) {
- var a = [];
- for (;;) {
- if (!is("name"))
- unexpected();
- var name = S.token.value;
- next();
- if (is("operator", "=")) {
- next();
- a.push([ name, expression(false, no_in) ]);
- } else {
- a.push([ name ]);
- }
- if (!is("punc", ","))
- break;
- next();
- }
- return a;
- };
-
- function var_(no_in) {
- return as("var", vardefs(no_in));
- };
-
- function const_() {
- return as("const", vardefs());
- };
-
- function new_() {
- var newexp = expr_atom(false), args;
- if (is("punc", "(")) {
- next();
- args = expr_list(")");
- } else {
- args = [];
- }
- return subscripts(as("new", newexp, args), true);
- };
-
- var expr_atom = maybe_embed_tokens(function(allow_calls) {
- if (is("operator", "new")) {
- next();
- return new_();
- }
- if (is("operator") && HOP(UNARY_PREFIX, S.token.value)) {
- return make_unary("unary-prefix",
- prog1(S.token.value, next),
- expr_atom(allow_calls));
- }
- if (is("punc")) {
- switch (S.token.value) {
- case "(":
- next();
- return subscripts(prog1(expression, curry(expect, ")")), allow_calls);
- case "[":
- next();
- return subscripts(array_(), allow_calls);
- case "{":
- next();
- return subscripts(object_(), allow_calls);
- }
- unexpected();
- }
- if (is("keyword", "function")) {
- next();
- return subscripts(function_(false), allow_calls);
- }
- if (HOP(ATOMIC_START_TOKEN, S.token.type)) {
- var atom = S.token.type == "regexp"
- ? as("regexp", S.token.value[0], S.token.value[1])
- : as(S.token.type, S.token.value);
- return subscripts(prog1(atom, next), allow_calls);
- }
- unexpected();
- });
-
- function expr_list(closing, allow_trailing_comma, allow_empty) {
- var first = true, a = [];
- while (!is("punc", closing)) {
- if (first) first = false; else expect(",");
- if (allow_trailing_comma && is("punc", closing)) break;
- if (is("punc", ",") && allow_empty) {
- a.push([ "atom", "undefined" ]);
- } else {
- a.push(expression(false));
- }
- }
- next();
- return a;
- };
-
- function array_() {
- return as("array", expr_list("]", !exigent_mode, true));
- };
-
- function object_() {
- var first = true, a = [];
- while (!is("punc", "}")) {
- if (first) first = false; else expect(",");
- if (!exigent_mode && is("punc", "}"))
- // allow trailing comma
- break;
- var type = S.token.type;
- var name = as_property_name();
- if (type == "name" && (name == "get" || name == "set") && !is("punc", ":")) {
- a.push([ as_name(), function_(false), name ]);
- } else {
- expect(":");
- a.push([ name, expression(false) ]);
- }
- }
- next();
- return as("object", a);
- };
-
- function as_property_name() {
- switch (S.token.type) {
- case "num":
- case "string":
- return prog1(S.token.value, next);
- }
- return as_name();
- };
-
- function as_name() {
- switch (S.token.type) {
- case "name":
- case "operator":
- case "keyword":
- case "atom":
- return prog1(S.token.value, next);
- default:
- unexpected();
- }
- };
-
- function subscripts(expr, allow_calls) {
- if (is("punc", ".")) {
- next();
- return subscripts(as("dot", expr, as_name()), allow_calls);
- }
- if (is("punc", "[")) {
- next();
- return subscripts(as("sub", expr, prog1(expression, curry(expect, "]"))), allow_calls);
- }
- if (allow_calls && is("punc", "(")) {
- next();
- return subscripts(as("call", expr, expr_list(")")), true);
- }
- if (allow_calls && is("operator") && HOP(UNARY_POSTFIX, S.token.value)) {
- return prog1(curry(make_unary, "unary-postfix", S.token.value, expr),
- next);
- }
- return expr;
- };
-
- function make_unary(tag, op, expr) {
- if ((op == "++" || op == "--") && !is_assignable(expr))
- croak("Invalid use of " + op + " operator");
- return as(tag, op, expr);
- };
-
- function expr_op(left, min_prec, no_in) {
- var op = is("operator") ? S.token.value : null;
- if (op && op == "in" && no_in) op = null;
- var prec = op != null ? PRECEDENCE[op] : null;
- if (prec != null && prec > min_prec) {
- next();
- var right = expr_op(expr_atom(true), prec, no_in);
- return expr_op(as("binary", op, left, right), min_prec, no_in);
- }
- return left;
- };
-
- function expr_ops(no_in) {
- return expr_op(expr_atom(true), 0, no_in);
- };
-
- function maybe_conditional(no_in) {
- var expr = expr_ops(no_in);
- if (is("operator", "?")) {
- next();
- var yes = expression(false);
- expect(":");
- return as("conditional", expr, yes, expression(false, no_in));
- }
- return expr;
- };
-
- function is_assignable(expr) {
- if (!exigent_mode) return true;
- switch (expr[0]) {
- case "dot":
- case "sub":
- case "new":
- case "call":
- return true;
- case "name":
- return expr[1] != "this";
- }
- };
-
- function maybe_assign(no_in) {
- var left = maybe_conditional(no_in), val = S.token.value;
- if (is("operator") && HOP(ASSIGNMENT, val)) {
- if (is_assignable(left)) {
- next();
- return as("assign", ASSIGNMENT[val], left, maybe_assign(no_in));
- }
- croak("Invalid assignment");
- }
- return left;
- };
-
- var expression = maybe_embed_tokens(function(commas, no_in) {
- if (arguments.length == 0)
- commas = true;
- var expr = maybe_assign(no_in);
- if (commas && is("punc", ",")) {
- next();
- return as("seq", expr, expression(true, no_in));
- }
- return expr;
- });
-
- function in_loop(cont) {
- try {
- ++S.in_loop;
- return cont();
- } finally {
- --S.in_loop;
- }
- };
-
- return as("toplevel", (function(a){
- while (!is("eof"))
- a.push(statement());
- return a;
- })([]));
-
-};
-
-/* -----[ Utilities ]----- */
-
-function curry(f) {
- var args = slice(arguments, 1);
- return function() { return f.apply(this, args.concat(slice(arguments))); };
-};
-
-function prog1(ret) {
- if (ret instanceof Function)
- ret = ret();
- for (var i = 1, n = arguments.length; --n > 0; ++i)
- arguments[i]();
- return ret;
-};
-
-function array_to_hash(a) {
- var ret = {};
- for (var i = 0; i < a.length; ++i)
- ret[a[i]] = true;
- return ret;
-};
-
-function slice(a, start) {
- return Array.prototype.slice.call(a, start == null ? 0 : start);
-};
-
-function characters(str) {
- return str.split("");
-};
-
-function member(name, array) {
- for (var i = array.length; --i >= 0;)
- if (array[i] === name)
- return true;
- return false;
-};
-
-function HOP(obj, prop) {
- return Object.prototype.hasOwnProperty.call(obj, prop);
-};
-
-var warn = function() {};
-
-/* -----[ Exports ]----- */
-
-exports.tokenizer = tokenizer;
-exports.parse = parse;
-exports.slice = slice;
-exports.curry = curry;
-exports.member = member;
-exports.array_to_hash = array_to_hash;
-exports.PRECEDENCE = PRECEDENCE;
-exports.KEYWORDS_ATOM = KEYWORDS_ATOM;
-exports.RESERVED_WORDS = RESERVED_WORDS;
-exports.KEYWORDS = KEYWORDS;
-exports.ATOMIC_START_TOKEN = ATOMIC_START_TOKEN;
-exports.OPERATORS = OPERATORS;
-exports.is_alphanumeric_char = is_alphanumeric_char;
-exports.set_logger = function(logger) {
- warn = logger;
-};
diff --git a/build/build/lib/process.js b/build/build/lib/process.js
deleted file mode 100644
index 3878c8d62..000000000
--- a/build/build/lib/process.js
+++ /dev/null
@@ -1,1666 +0,0 @@
-/***********************************************************************
-
- A JavaScript tokenizer / parser / beautifier / compressor.
-
- This version is suitable for Node.js. With minimal changes (the
- exports stuff) it should work on any JS platform.
-
- This file implements some AST processors. They work on data built
- by parse-js.
-
- Exported functions:
-
- - ast_mangle(ast, options) -- mangles the variable/function names
- in the AST. Returns an AST.
-
- - ast_squeeze(ast) -- employs various optimizations to make the
- final generated code even smaller. Returns an AST.
-
- - gen_code(ast, options) -- generates JS code from the AST. Pass
- true (or an object, see the code for some options) as second
- argument to get "pretty" (indented) code.
-
- -------------------------------- (C) ---------------------------------
-
- Author: Mihai Bazon
- <mihai.bazon@gmail.com>
- http://mihai.bazon.net/blog
-
- Distributed under the BSD license:
-
- Copyright 2010 (c) Mihai Bazon <mihai.bazon@gmail.com>
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- * Redistributions of source code must retain the above
- copyright notice, this list of conditions and the following
- disclaimer.
-
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- SUCH DAMAGE.
-
- ***********************************************************************/
-
-var jsp = require("./parse-js"),
- slice = jsp.slice,
- member = jsp.member,
- PRECEDENCE = jsp.PRECEDENCE,
- OPERATORS = jsp.OPERATORS;
-
-/* -----[ helper for AST traversal ]----- */
-
-function ast_walker(ast) {
- function _vardefs(defs) {
- return [ this[0], MAP(defs, function(def){
- var a = [ def[0] ];
- if (def.length > 1)
- a[1] = walk(def[1]);
- return a;
- }) ];
- };
- function _block(statements) {
- var out = [ this[0] ];
- if (statements != null)
- out.push(MAP(statements, walk));
- return out;
- };
- var walkers = {
- "string": function(str) {
- return [ this[0], str ];
- },
- "num": function(num) {
- return [ this[0], num ];
- },
- "name": function(name) {
- return [ this[0], name ];
- },
- "toplevel": function(statements) {
- return [ this[0], MAP(statements, walk) ];
- },
- "block": _block,
- "splice": _block,
- "var": _vardefs,
- "const": _vardefs,
- "try": function(t, c, f) {
- return [
- this[0],
- MAP(t, walk),
- c != null ? [ c[0], MAP(c[1], walk) ] : null,
- f != null ? MAP(f, walk) : null
- ];
- },
- "throw": function(expr) {
- return [ this[0], walk(expr) ];
- },
- "new": function(ctor, args) {
- return [ this[0], walk(ctor), MAP(args, walk) ];
- },
- "switch": function(expr, body) {
- return [ this[0], walk(expr), MAP(body, function(branch){
- return [ branch[0] ? walk(branch[0]) : null,
- MAP(branch[1], walk) ];
- }) ];
- },
- "break": function(label) {
- return [ this[0], label ];
- },
- "continue": function(label) {
- return [ this[0], label ];
- },
- "conditional": function(cond, t, e) {
- return [ this[0], walk(cond), walk(t), walk(e) ];
- },
- "assign": function(op, lvalue, rvalue) {
- return [ this[0], op, walk(lvalue), walk(rvalue) ];
- },
- "dot": function(expr) {
- return [ this[0], walk(expr) ].concat(slice(arguments, 1));
- },
- "call": function(expr, args) {
- return [ this[0], walk(expr), MAP(args, walk) ];
- },
- "function": function(name, args, body) {
- return [ this[0], name, args.slice(), MAP(body, walk) ];
- },
- "defun": function(name, args, body) {
- return [ this[0], name, args.slice(), MAP(body, walk) ];
- },
- "if": function(conditional, t, e) {
- return [ this[0], walk(conditional), walk(t), walk(e) ];
- },
- "for": function(init, cond, step, block) {
- return [ this[0], walk(init), walk(cond), walk(step), walk(block) ];
- },
- "for-in": function(vvar, key, hash, block) {
- return [ this[0], walk(vvar), walk(key), walk(hash), walk(block) ];
- },
- "while": function(cond, block) {
- return [ this[0], walk(cond), walk(block) ];
- },
- "do": function(cond, block) {
- return [ this[0], walk(cond), walk(block) ];
- },
- "return": function(expr) {
- return [ this[0], walk(expr) ];
- },
- "binary": function(op, left, right) {
- return [ this[0], op, walk(left), walk(right) ];
- },
- "unary-prefix": function(op, expr) {
- return [ this[0], op, walk(expr) ];
- },
- "unary-postfix": function(op, expr) {
- return [ this[0], op, walk(expr) ];
- },
- "sub": function(expr, subscript) {
- return [ this[0], walk(expr), walk(subscript) ];
- },
- "object": function(props) {
- return [ this[0], MAP(props, function(p){
- return p.length == 2
- ? [ p[0], walk(p[1]) ]
- : [ p[0], walk(p[1]), p[2] ]; // get/set-ter
- }) ];
- },
- "regexp": function(rx, mods) {
- return [ this[0], rx, mods ];
- },
- "array": function(elements) {
- return [ this[0], MAP(elements, walk) ];
- },
- "stat": function(stat) {
- return [ this[0], walk(stat) ];
- },
- "seq": function() {
- return [ this[0] ].concat(MAP(slice(arguments), walk));
- },
- "label": function(name, block) {
- return [ this[0], name, walk(block) ];
- },
- "with": function(expr, block) {
- return [ this[0], walk(expr), walk(block) ];
- },
- "atom": function(name) {
- return [ this[0], name ];
- }
- };
-
- var user = {};
- var stack = [];
- function walk(ast) {
- if (ast == null)
- return null;
- try {
- stack.push(ast);
- var type = ast[0];
- var gen = user[type];
- if (gen) {
- var ret = gen.apply(ast, ast.slice(1));
- if (ret != null)
- return ret;
- }
- gen = walkers[type];
- return gen.apply(ast, ast.slice(1));
- } finally {
- stack.pop();
- }
- };
-
- function with_walkers(walkers, cont){
- var save = {}, i;
- for (i in walkers) if (HOP(walkers, i)) {
- save[i] = user[i];
- user[i] = walkers[i];
- }
- var ret = cont();
- for (i in save) if (HOP(save, i)) {
- if (!save[i]) delete user[i];
- else user[i] = save[i];
- }
- return ret;
- };
-
- return {
- walk: walk,
- with_walkers: with_walkers,
- parent: function() {
- return stack[stack.length - 2]; // last one is current node
- },
- stack: function() {
- return stack;
- }
- };
-};
-
-/* -----[ Scope and mangling ]----- */
-
-function Scope(parent) {
- this.names = {}; // names defined in this scope
- this.mangled = {}; // mangled names (orig.name => mangled)
- this.rev_mangled = {}; // reverse lookup (mangled => orig.name)
- this.cname = -1; // current mangled name
- this.refs = {}; // names referenced from this scope
- this.uses_with = false; // will become TRUE if with() is detected in this or any subscopes
- this.uses_eval = false; // will become TRUE if eval() is detected in this or any subscopes
- this.parent = parent; // parent scope
- this.children = []; // sub-scopes
- if (parent) {
- this.level = parent.level + 1;
- parent.children.push(this);
- } else {
- this.level = 0;
- }
-};
-
-var base54 = (function(){
- var DIGITS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_";
- return function(num) {
- var ret = "";
- do {
- ret = DIGITS.charAt(num % 54) + ret;
- num = Math.floor(num / 54);
- } while (num > 0);
- return ret;
- };
-})();
-
-Scope.prototype = {
- has: function(name) {
- for (var s = this; s; s = s.parent)
- if (HOP(s.names, name))
- return s;
- },
- has_mangled: function(mname) {
- for (var s = this; s; s = s.parent)
- if (HOP(s.rev_mangled, mname))
- return s;
- },
- toJSON: function() {
- return {
- names: this.names,
- uses_eval: this.uses_eval,
- uses_with: this.uses_with
- };
- },
-
- next_mangled: function() {
- // we must be careful that the new mangled name:
- //
- // 1. doesn't shadow a mangled name from a parent
- // scope, unless we don't reference the original
- // name from this scope OR from any sub-scopes!
- // This will get slow.
- //
- // 2. doesn't shadow an original name from a parent
- // scope, in the event that the name is not mangled
- // in the parent scope and we reference that name
- // here OR IN ANY SUBSCOPES!
- //
- // 3. doesn't shadow a name that is referenced but not
- // defined (possibly global defined elsewhere).
- for (;;) {
- var m = base54(++this.cname), prior;
-
- // case 1.
- prior = this.has_mangled(m);
- if (prior && this.refs[prior.rev_mangled[m]] === prior)
- continue;
-
- // case 2.
- prior = this.has(m);
- if (prior && prior !== this && this.refs[m] === prior && !prior.has_mangled(m))
- continue;
-
- // case 3.
- if (HOP(this.refs, m) && this.refs[m] == null)
- continue;
-
- // I got "do" once. :-/
- if (!is_identifier(m))
- continue;
-
- return m;
- }
- },
- get_mangled: function(name, newMangle) {
- if (this.uses_eval || this.uses_with) return name; // no mangle if eval or with is in use
- var s = this.has(name);
- if (!s) return name; // not in visible scope, no mangle
- if (HOP(s.mangled, name)) return s.mangled[name]; // already mangled in this scope
- if (!newMangle) return name; // not found and no mangling requested
-
- var m = s.next_mangled();
- s.rev_mangled[m] = name;
- return s.mangled[name] = m;
- },
- define: function(name) {
- if (name != null)
- return this.names[name] = name;
- }
-};
-
-function ast_add_scope(ast) {
-
- var current_scope = null;
- var w = ast_walker(), walk = w.walk;
- var having_eval = [];
-
- function with_new_scope(cont) {
- current_scope = new Scope(current_scope);
- var ret = current_scope.body = cont();
- ret.scope = current_scope;
- current_scope = current_scope.parent;
- return ret;
- };
-
- function define(name) {
- return current_scope.define(name);
- };
-
- function reference(name) {
- current_scope.refs[name] = true;
- };
-
- function _lambda(name, args, body) {
- var is_defun = this[0] == "defun";
- return [ this[0], is_defun ? define(name) : name, args, with_new_scope(function(){
- if (!is_defun) define(name);
- MAP(args, define);
- return MAP(body, walk);
- })];
- };
-
- return with_new_scope(function(){
- // process AST
- var ret = w.with_walkers({
- "function": _lambda,
- "defun": _lambda,
- "with": function(expr, block) {
- for (var s = current_scope; s; s = s.parent)
- s.uses_with = true;
- },
- "var": function(defs) {
- MAP(defs, function(d){ define(d[0]) });
- },
- "const": function(defs) {
- MAP(defs, function(d){ define(d[0]) });
- },
- "try": function(t, c, f) {
- if (c != null) return [
- this[0],
- MAP(t, walk),
- [ define(c[0]), MAP(c[1], walk) ],
- f != null ? MAP(f, walk) : null
- ];
- },
- "name": function(name) {
- if (name == "eval")
- having_eval.push(current_scope);
- reference(name);
- }
- }, function(){
- return walk(ast);
- });
-
- // the reason why we need an additional pass here is
- // that names can be used prior to their definition.
-
- // scopes where eval was detected and their parents
- // are marked with uses_eval, unless they define the
- // "eval" name.
- MAP(having_eval, function(scope){
- if (!scope.has("eval")) while (scope) {
- scope.uses_eval = true;
- scope = scope.parent;
- }
- });
-
- // for referenced names it might be useful to know
- // their origin scope. current_scope here is the
- // toplevel one.
- function fixrefs(scope, i) {
- // do children first; order shouldn't matter
- for (i = scope.children.length; --i >= 0;)
- fixrefs(scope.children[i]);
- for (i in scope.refs) if (HOP(scope.refs, i)) {
- // find origin scope and propagate the reference to origin
- for (var origin = scope.has(i), s = scope; s; s = s.parent) {
- s.refs[i] = origin;
- if (s === origin) break;
- }
- }
- };
- fixrefs(current_scope);
-
- return ret;
- });
-
-};
-
-/* -----[ mangle names ]----- */
-
-function ast_mangle(ast, options) {
- var w = ast_walker(), walk = w.walk, scope;
- options = options || {};
-
- function get_mangled(name, newMangle) {
- if (!options.toplevel && !scope.parent) return name; // don't mangle toplevel
- if (options.except && member(name, options.except))
- return name;
- return scope.get_mangled(name, newMangle);
- };
-
- function get_define(name) {
- // we always lookup a defined symbol for the current scope FIRST, so declared
- // vars trump a DEFINE symbol, but if no such var is found, then match a DEFINE value
- if (!scope.has(name)) {
- if (HOP(options.defines, name)) {
- return options.defines[name];
- }
- }
- return null;
- };
-
- function _lambda(name, args, body) {
- var is_defun = this[0] == "defun";
- if (is_defun && name) name = get_mangled(name);
- body = with_scope(body.scope, function(){
- if (!is_defun && name) name = get_mangled(name);
- args = MAP(args, function(name){ return get_mangled(name) });
- return MAP(body, walk);
- });
- return [ this[0], name, args, body ];
- };
-
- function with_scope(s, cont) {
- var _scope = scope;
- scope = s;
- for (var i in s.names) if (HOP(s.names, i)) {
- get_mangled(i, true);
- }
- var ret = cont();
- ret.scope = s;
- scope = _scope;
- return ret;
- };
-
- function _vardefs(defs) {
- return [ this[0], MAP(defs, function(d){
- return [ get_mangled(d[0]), walk(d[1]) ];
- }) ];
- };
-
- return w.with_walkers({
- "function": _lambda,
- "defun": function() {
- // move function declarations to the top when
- // they are not in some block.
- var ast = _lambda.apply(this, arguments);
- switch (w.parent()[0]) {
- case "toplevel":
- case "function":
- case "defun":
- return MAP.at_top(ast);
- }
- return ast;
- },
- "var": _vardefs,
- "const": _vardefs,
- "name": function(name) {
- return get_define(name) || [ this[0], get_mangled(name) ];
- },
- "try": function(t, c, f) {
- return [ this[0],
- MAP(t, walk),
- c != null ? [ get_mangled(c[0]), MAP(c[1], walk) ] : null,
- f != null ? MAP(f, walk) : null ];
- },
- "toplevel": function(body) {
- var self = this;
- return with_scope(self.scope, function(){
- return [ self[0], MAP(body, walk) ];
- });
- }
- }, function() {
- return walk(ast_add_scope(ast));
- });
-};
-
-/* -----[
- - compress foo["bar"] into foo.bar,
- - remove block brackets {} where possible
- - join consecutive var declarations
- - various optimizations for IFs:
- - if (cond) foo(); else bar(); ==> cond?foo():bar();
- - if (cond) foo(); ==> cond&&foo();
- - if (foo) return bar(); else return baz(); ==> return foo?bar():baz(); // also for throw
- - if (foo) return bar(); else something(); ==> {if(foo)return bar();something()}
- ]----- */
-
-var warn = function(){};
-
-function best_of(ast1, ast2) {
- return gen_code(ast1).length > gen_code(ast2[0] == "stat" ? ast2[1] : ast2).length ? ast2 : ast1;
-};
-
-function last_stat(b) {
- if (b[0] == "block" && b[1] && b[1].length > 0)
- return b[1][b[1].length - 1];
- return b;
-}
-
-function aborts(t) {
- if (t) {
- t = last_stat(t);
- if (t[0] == "return" || t[0] == "break" || t[0] == "continue" || t[0] == "throw")
- return true;
- }
-};
-
-function boolean_expr(expr) {
- return ( (expr[0] == "unary-prefix"
- && member(expr[1], [ "!", "delete" ])) ||
-
- (expr[0] == "binary"
- && member(expr[1], [ "in", "instanceof", "==", "!=", "===", "!==", "<", "<=", ">=", ">" ])) ||
-
- (expr[0] == "binary"
- && member(expr[1], [ "&&", "||" ])
- && boolean_expr(expr[2])
- && boolean_expr(expr[3])) ||
-
- (expr[0] == "conditional"
- && boolean_expr(expr[2])
- && boolean_expr(expr[3])) ||
-
- (expr[0] == "assign"
- && expr[1] === true
- && boolean_expr(expr[3])) ||
-
- (expr[0] == "seq"
- && boolean_expr(expr[expr.length - 1]))
- );
-};
-
-function make_conditional(c, t, e) {
- var make_real_conditional = function() {
- if (c[0] == "unary-prefix" && c[1] == "!") {
- return e ? [ "conditional", c[2], e, t ] : [ "binary", "||", c[2], t ];
- } else {
- return e ? [ "conditional", c, t, e ] : [ "binary", "&&", c, t ];
- }
- };
- // shortcut the conditional if the expression has a constant value
- return when_constant(c, function(ast, val){
- warn_unreachable(val ? e : t);
- return (val ? t : e);
- }, make_real_conditional);
-};
-
-function empty(b) {
- return !b || (b[0] == "block" && (!b[1] || b[1].length == 0));
-};
-
-function is_string(node) {
- return (node[0] == "string" ||
- node[0] == "unary-prefix" && node[1] == "typeof" ||
- node[0] == "binary" && node[1] == "+" &&
- (is_string(node[2]) || is_string(node[3])));
-};
-
-var when_constant = (function(){
-
- var $NOT_CONSTANT = {};
-
- // this can only evaluate constant expressions. If it finds anything
- // not constant, it throws $NOT_CONSTANT.
- function evaluate(expr) {
- switch (expr[0]) {
- case "string":
- case "num":
- return expr[1];
- case "name":
- case "atom":
- switch (expr[1]) {
- case "true": return true;
- case "false": return false;
- }
- break;
- case "unary-prefix":
- switch (expr[1]) {
- case "!": return !evaluate(expr[2]);
- case "typeof": return typeof evaluate(expr[2]);
- case "~": return ~evaluate(expr[2]);
- case "-": return -evaluate(expr[2]);
- case "+": return +evaluate(expr[2]);
- }
- break;
- case "binary":
- var left = expr[2], right = expr[3];
- switch (expr[1]) {
- case "&&" : return evaluate(left) && evaluate(right);
- case "||" : return evaluate(left) || evaluate(right);
- case "|" : return evaluate(left) | evaluate(right);
- case "&" : return evaluate(left) & evaluate(right);
- case "^" : return evaluate(left) ^ evaluate(right);
- case "+" : return evaluate(left) + evaluate(right);
- case "*" : return evaluate(left) * evaluate(right);
- case "/" : return evaluate(left) / evaluate(right);
- case "-" : return evaluate(left) - evaluate(right);
- case "<<" : return evaluate(left) << evaluate(right);
- case ">>" : return evaluate(left) >> evaluate(right);
- case ">>>" : return evaluate(left) >>> evaluate(right);
- case "==" : return evaluate(left) == evaluate(right);
- case "===" : return evaluate(left) === evaluate(right);
- case "!=" : return evaluate(left) != evaluate(right);
- case "!==" : return evaluate(left) !== evaluate(right);
- case "<" : return evaluate(left) < evaluate(right);
- case "<=" : return evaluate(left) <= evaluate(right);
- case ">" : return evaluate(left) > evaluate(right);
- case ">=" : return evaluate(left) >= evaluate(right);
- case "in" : return evaluate(left) in evaluate(right);
- case "instanceof" : return evaluate(left) instanceof evaluate(right);
- }
- }
- throw $NOT_CONSTANT;
- };
-
- return function(expr, yes, no) {
- try {
- var val = evaluate(expr), ast;
- switch (typeof val) {
- case "string": ast = [ "string", val ]; break;
- case "number": ast = [ "num", val ]; break;
- case "boolean": ast = [ "name", String(val) ]; break;
- default: throw new Error("Can't handle constant of type: " + (typeof val));
- }
- return yes.call(expr, ast, val);
- } catch(ex) {
- if (ex === $NOT_CONSTANT) {
- if (expr[0] == "binary"
- && (expr[1] == "===" || expr[1] == "!==")
- && ((is_string(expr[2]) && is_string(expr[3]))
- || (boolean_expr(expr[2]) && boolean_expr(expr[3])))) {
- expr[1] = expr[1].substr(0, 2);
- }
- else if (no && expr[0] == "binary"
- && (expr[1] == "||" || expr[1] == "&&")) {
- // the whole expression is not constant but the lval may be...
- try {
- var lval = evaluate(expr[2]);
- expr = ((expr[1] == "&&" && (lval ? expr[3] : lval)) ||
- (expr[1] == "||" && (lval ? lval : expr[3])) ||
- expr);
- } catch(ex2) {
- // IGNORE... lval is not constant
- }
- }
- return no ? no.call(expr, expr) : null;
- }
- else throw ex;
- }
- };
-
-})();
-
-function warn_unreachable(ast) {
- if (!empty(ast))
- warn("Dropping unreachable code: " + gen_code(ast, true));
-};
-
-function ast_squeeze(ast, options) {
- options = defaults(options, {
- make_seqs : true,
- dead_code : true,
- keep_comps : true,
- no_warnings : false
- });
-
- var w = ast_walker(), walk = w.walk, scope;
-
- function negate(c) {
- var not_c = [ "unary-prefix", "!", c ];
- switch (c[0]) {
- case "unary-prefix":
- return c[1] == "!" && boolean_expr(c[2]) ? c[2] : not_c;
- case "seq":
- c = slice(c);
- c[c.length - 1] = negate(c[c.length - 1]);
- return c;
- case "conditional":
- return best_of(not_c, [ "conditional", c[1], negate(c[2]), negate(c[3]) ]);
- case "binary":
- var op = c[1], left = c[2], right = c[3];
- if (!options.keep_comps) switch (op) {
- case "<=" : return [ "binary", ">", left, right ];
- case "<" : return [ "binary", ">=", left, right ];
- case ">=" : return [ "binary", "<", left, right ];
- case ">" : return [ "binary", "<=", left, right ];
- }
- switch (op) {
- case "==" : return [ "binary", "!=", left, right ];
- case "!=" : return [ "binary", "==", left, right ];
- case "===" : return [ "binary", "!==", left, right ];
- case "!==" : return [ "binary", "===", left, right ];
- case "&&" : return best_of(not_c, [ "binary", "||", negate(left), negate(right) ]);
- case "||" : return best_of(not_c, [ "binary", "&&", negate(left), negate(right) ]);
- }
- break;
- }
- return not_c;
- };
-
- function with_scope(s, cont) {
- var _scope = scope;
- scope = s;
- var ret = cont();
- ret.scope = s;
- scope = _scope;
- return ret;
- };
-
- function rmblock(block) {
- if (block != null && block[0] == "block" && block[1]) {
- if (block[1].length == 1)
- block = block[1][0];
- else if (block[1].length == 0)
- block = [ "block" ];
- }
- return block;
- };
-
- function _lambda(name, args, body) {
- var is_defun = this[0] == "defun";
- body = with_scope(body.scope, function(){
- var ret = tighten(MAP(body, walk), "lambda");
- if (!is_defun && name && !HOP(scope.refs, name))
- name = null;
- return ret;
- });
- return [ this[0], name, args, body ];
- };
-
- // we get here for blocks that have been already transformed.
- // this function does a few things:
- // 1. discard useless blocks
- // 2. join consecutive var declarations
- // 3. remove obviously dead code
- // 4. transform consecutive statements using the comma operator
- // 5. if block_type == "lambda" and it detects constructs like if(foo) return ... - rewrite like if (!foo) { ... }
- function tighten(statements, block_type) {
- statements = statements.reduce(function(a, stat){
- if (stat[0] == "block") {
- if (stat[1]) {
- a.push.apply(a, stat[1]);
- }
- } else {
- a.push(stat);
- }
- return a;
- }, []);
-
- statements = (function(a, prev){
- statements.forEach(function(cur){
- if (prev && ((cur[0] == "var" && prev[0] == "var") ||
- (cur[0] == "const" && prev[0] == "const"))) {
- prev[1] = prev[1].concat(cur[1]);
- } else {
- a.push(cur);
- prev = cur;
- }
- });
- return a;
- })([]);
-
- if (options.dead_code) statements = (function(a, has_quit){
- statements.forEach(function(st){
- if (has_quit) {
- if (member(st[0], [ "function", "defun" , "var", "const" ])) {
- a.push(st);
- }
- else if (!options.no_warnings)
- warn_unreachable(st);
- }
- else {
- a.push(st);
- if (member(st[0], [ "return", "throw", "break", "continue" ]))
- has_quit = true;
- }
- });
- return a;
- })([]);
-
- if (options.make_seqs) statements = (function(a, prev) {
- statements.forEach(function(cur){
- if (prev && prev[0] == "stat" && cur[0] == "stat") {
- prev[1] = [ "seq", prev[1], cur[1] ];
- } else {
- a.push(cur);
- prev = cur;
- }
- });
- return a;
- })([]);
-
- if (block_type == "lambda") statements = (function(i, a, stat){
- while (i < statements.length) {
- stat = statements[i++];
- if (stat[0] == "if" && !stat[3]) {
- if (stat[2][0] == "return" && stat[2][1] == null) {
- a.push(make_if(negate(stat[1]), [ "block", statements.slice(i) ]));
- break;
- }
- var last = last_stat(stat[2]);
- if (last[0] == "return" && last[1] == null) {
- a.push(make_if(stat[1], [ "block", stat[2][1].slice(0, -1) ], [ "block", statements.slice(i) ]));
- break;
- }
- }
- a.push(stat);
- }
- return a;
- })(0, []);
-
- return statements;
- };
-
- function make_if(c, t, e) {
- return when_constant(c, function(ast, val){
- if (val) {
- warn_unreachable(e);
- return t;
- } else {
- warn_unreachable(t);
- return e;
- }
- }, function() {
- return make_real_if(c, t, e);
- });
- };
-
- function make_real_if(c, t, e) {
- c = walk(c);
- t = walk(t);
- e = walk(e);
-
- if (empty(t)) {
- c = negate(c);
- t = e;
- e = null;
- } else if (empty(e)) {
- e = null;
- } else {
- // if we have both else and then, maybe it makes sense to switch them?
- (function(){
- var a = gen_code(c);
- var n = negate(c);
- var b = gen_code(n);
- if (b.length < a.length) {
- var tmp = t;
- t = e;
- e = tmp;
- c = n;
- }
- })();
- }
- if (empty(e) && empty(t))
- return [ "stat", c ];
- var ret = [ "if", c, t, e ];
- if (t[0] == "if" && empty(t[3]) && empty(e)) {
- ret = best_of(ret, walk([ "if", [ "binary", "&&", c, t[1] ], t[2] ]));
- }
- else if (t[0] == "stat") {
- if (e) {
- if (e[0] == "stat") {
- ret = best_of(ret, [ "stat", make_conditional(c, t[1], e[1]) ]);
- }
- }
- else {
- ret = best_of(ret, [ "stat", make_conditional(c, t[1]) ]);
- }
- }
- else if (e && t[0] == e[0] && (t[0] == "return" || t[0] == "throw") && t[1] && e[1]) {
- ret = best_of(ret, [ t[0], make_conditional(c, t[1], e[1] ) ]);
- }
- else if (e && aborts(t)) {
- ret = [ [ "if", c, t ] ];
- if (e[0] == "block") {
- if (e[1]) ret = ret.concat(e[1]);
- }
- else {
- ret.push(e);
- }
- ret = walk([ "block", ret ]);
- }
- else if (t && aborts(e)) {
- ret = [ [ "if", negate(c), e ] ];
- if (t[0] == "block") {
- if (t[1]) ret = ret.concat(t[1]);
- } else {
- ret.push(t);
- }
- ret = walk([ "block", ret ]);
- }
- return ret;
- };
-
- function _do_while(cond, body) {
- return when_constant(cond, function(cond, val){
- if (!val) {
- warn_unreachable(body);
- return [ "block" ];
- } else {
- return [ "for", null, null, null, walk(body) ];
- }
- });
- };
-
- return w.with_walkers({
- "sub": function(expr, subscript) {
- if (subscript[0] == "string") {
- var name = subscript[1];
- if (is_identifier(name))
- return [ "dot", walk(expr), name ];
- else if (/^[1-9][0-9]*$/.test(name) || name === "0")
- return [ "sub", walk(expr), [ "num", parseInt(name, 10) ] ];
- }
- },
- "if": make_if,
- "toplevel": function(body) {
- return [ "toplevel", with_scope(this.scope, function(){
- return tighten(MAP(body, walk));
- }) ];
- },
- "switch": function(expr, body) {
- var last = body.length - 1;
- return [ "switch", walk(expr), MAP(body, function(branch, i){
- var block = tighten(MAP(branch[1], walk));
- if (i == last && block.length > 0) {
- var node = block[block.length - 1];
- if (node[0] == "break" && !node[1])
- block.pop();
- }
- return [ branch[0] ? walk(branch[0]) : null, block ];
- }) ];
- },
- "function": _lambda,
- "defun": _lambda,
- "block": function(body) {
- if (body) return rmblock([ "block", tighten(MAP(body, walk)) ]);
- },
- "binary": function(op, left, right) {
- return when_constant([ "binary", op, walk(left), walk(right) ], function yes(c){
- return best_of(walk(c), this);
- }, function no() {
- return this;
- });
- },
- "conditional": function(c, t, e) {
- return make_conditional(walk(c), walk(t), walk(e));
- },
- "try": function(t, c, f) {
- return [
- "try",
- tighten(MAP(t, walk)),
- c != null ? [ c[0], tighten(MAP(c[1], walk)) ] : null,
- f != null ? tighten(MAP(f, walk)) : null
- ];
- },
- "unary-prefix": function(op, expr) {
- expr = walk(expr);
- var ret = [ "unary-prefix", op, expr ];
- if (op == "!")
- ret = best_of(ret, negate(expr));
- return when_constant(ret, function(ast, val){
- return walk(ast); // it's either true or false, so minifies to !0 or !1
- }, function() { return ret });
- },
- "name": function(name) {
- switch (name) {
- case "true": return [ "unary-prefix", "!", [ "num", 0 ]];
- case "false": return [ "unary-prefix", "!", [ "num", 1 ]];
- }
- },
- "new": function(ctor, args) {
- if (ctor[0] == "name" && ctor[1] == "Array" && !scope.has("Array")) {
- if (args.length != 1) {
- return [ "array", args ];
- } else {
- return [ "call", [ "name", "Array" ], args ];
- }
- }
- },
- "call": function(expr, args) {
- if (expr[0] == "name" && expr[1] == "Array" && args.length != 1 && !scope.has("Array")) {
- return [ "array", args ];
- }
- },
- "while": _do_while,
- "do": _do_while
- }, function() {
- return walk(ast_add_scope(ast));
- });
-};
-
-/* -----[ re-generate code from the AST ]----- */
-
-var DOT_CALL_NO_PARENS = jsp.array_to_hash([
- "name",
- "array",
- "object",
- "string",
- "dot",
- "sub",
- "call",
- "regexp"
-]);
-
-function make_string(str, ascii_only) {
- var dq = 0, sq = 0;
- str = str.replace(/[\\\b\f\n\r\t\x22\x27\u2028\u2029]/g, function(s){
- switch (s) {
- case "\\": return "\\\\";
- case "\b": return "\\b";
- case "\f": return "\\f";
- case "\n": return "\\n";
- case "\r": return "\\r";
- case "\t": return "\\t";
- case "\u2028": return "\\u2028";
- case "\u2029": return "\\u2029";
- case '"': ++dq; return '"';
- case "'": ++sq; return "'";
- }
- return s;
- });
- if (ascii_only) str = to_ascii(str);
- if (dq > sq) return "'" + str.replace(/\x27/g, "\\'") + "'";
- else return '"' + str.replace(/\x22/g, '\\"') + '"';
-};
-
-function to_ascii(str) {
- return str.replace(/[\u0080-\uffff]/g, function(ch) {
- var code = ch.charCodeAt(0).toString(16);
- while (code.length < 4) code = "0" + code;
- return "\\u" + code;
- });
-};
-
-var SPLICE_NEEDS_BRACKETS = jsp.array_to_hash([ "if", "while", "do", "for", "for-in", "with" ]);
-
-function gen_code(ast, options) {
- options = defaults(options, {
- indent_start : 0,
- indent_level : 4,
- quote_keys : false,
- space_colon : false,
- beautify : false,
- ascii_only : false
- });
- var beautify = !!options.beautify;
- var indentation = 0,
- newline = beautify ? "\n" : "",
- space = beautify ? " " : "";
-
- function encode_string(str) {
- return make_string(str, options.ascii_only);
- };
-
- function make_name(name) {
- name = name.toString();
- if (options.ascii_only)
- name = to_ascii(name);
- return name;
- };
-
- function indent(line) {
- if (line == null)
- line = "";
- if (beautify)
- line = repeat_string(" ", options.indent_start + indentation * options.indent_level) + line;
- return line;
- };
-
- function with_indent(cont, incr) {
- if (incr == null) incr = 1;
- indentation += incr;
- try { return cont.apply(null, slice(arguments, 1)); }
- finally { indentation -= incr; }
- };
-
- function add_spaces(a) {
- if (beautify)
- return a.join(" ");
- var b = [];
- for (var i = 0; i < a.length; ++i) {
- var next = a[i + 1];
- b.push(a[i]);
- if (next &&
- ((/[a-z0-9_\x24]$/i.test(a[i].toString()) && /^[a-z0-9_\x24]/i.test(next.toString())) ||
- (/[\+\-]$/.test(a[i].toString()) && /^[\+\-]/.test(next.toString())))) {
- b.push(" ");
- }
- }
- return b.join("");
- };
-
- function add_commas(a) {
- return a.join("," + space);
- };
-
- function parenthesize(expr) {
- var gen = make(expr);
- for (var i = 1; i < arguments.length; ++i) {
- var el = arguments[i];
- if ((el instanceof Function && el(expr)) || expr[0] == el)
- return "(" + gen + ")";
- }
- return gen;
- };
-
- function best_of(a) {
- if (a.length == 1) {
- return a[0];
- }
- if (a.length == 2) {
- var b = a[1];
- a = a[0];
- return a.length <= b.length ? a : b;
- }
- return best_of([ a[0], best_of(a.slice(1)) ]);
- };
-
- function needs_parens(expr) {
- if (expr[0] == "function" || expr[0] == "object") {
- // dot/call on a literal function requires the
- // function literal itself to be parenthesized
- // only if it's the first "thing" in a
- // statement. This means that the parent is
- // "stat", but it could also be a "seq" and
- // we're the first in this "seq" and the
- // parent is "stat", and so on. Messy stuff,
- // but it worths the trouble.
- var a = slice($stack), self = a.pop(), p = a.pop();
- while (p) {
- if (p[0] == "stat") return true;
- if (((p[0] == "seq" || p[0] == "call" || p[0] == "dot" || p[0] == "sub" || p[0] == "conditional") && p[1] === self) ||
- ((p[0] == "binary" || p[0] == "assign" || p[0] == "unary-postfix") && p[2] === self)) {
- self = p;
- p = a.pop();
- } else {
- return false;
- }
- }
- }
- return !HOP(DOT_CALL_NO_PARENS, expr[0]);
- };
-
- function make_num(num) {
- var str = num.toString(10), a = [ str.replace(/^0\./, ".") ], m;
- if (Math.floor(num) === num) {
- a.push("0x" + num.toString(16).toLowerCase(), // probably pointless
- "0" + num.toString(8)); // same.
- if ((m = /^(.*?)(0+)$/.exec(num))) {
- a.push(m[1] + "e" + m[2].length);
- }
- } else if ((m = /^0?\.(0+)(.*)$/.exec(num))) {
- a.push(m[2] + "e-" + (m[1].length + m[2].length),
- str.substr(str.indexOf(".")));
- }
- return best_of(a);
- };
-
- var generators = {
- "string": encode_string,
- "num": make_num,
- "name": make_name,
- "toplevel": function(statements) {
- return make_block_statements(statements)
- .join(newline + newline);
- },
- "splice": function(statements) {
- var parent = $stack[$stack.length - 2][0];
- if (HOP(SPLICE_NEEDS_BRACKETS, parent)) {
- // we need block brackets in this case
- return make_block.apply(this, arguments);
- } else {
- return MAP(make_block_statements(statements, true),
- function(line, i) {
- // the first line is already indented
- return i > 0 ? indent(line) : line;
- }).join(newline);
- }
- },
- "block": make_block,
- "var": function(defs) {
- return "var " + add_commas(MAP(defs, make_1vardef)) + ";";
- },
- "const": function(defs) {
- return "const " + add_commas(MAP(defs, make_1vardef)) + ";";
- },
- "try": function(tr, ca, fi) {
- var out = [ "try", make_block(tr) ];
- if (ca) out.push("catch", "(" + ca[0] + ")", make_block(ca[1]));
- if (fi) out.push("finally", make_block(fi));
- return add_spaces(out);
- },
- "throw": function(expr) {
- return add_spaces([ "throw", make(expr) ]) + ";";
- },
- "new": function(ctor, args) {
- args = args.length > 0 ? "(" + add_commas(MAP(args, make)) + ")" : "";
- return add_spaces([ "new", parenthesize(ctor, "seq", "binary", "conditional", "assign", function(expr){
- var w = ast_walker(), has_call = {};
- try {
- w.with_walkers({
- "call": function() { throw has_call },
- "function": function() { return this }
- }, function(){
- w.walk(expr);
- });
- } catch(ex) {
- if (ex === has_call)
- return true;
- throw ex;
- }
- }) + args ]);
- },
- "switch": function(expr, body) {
- return add_spaces([ "switch", "(" + make(expr) + ")", make_switch_block(body) ]);
- },
- "break": function(label) {
- var out = "break";
- if (label != null)
- out += " " + make_name(label);
- return out + ";";
- },
- "continue": function(label) {
- var out = "continue";
- if (label != null)
- out += " " + make_name(label);
- return out + ";";
- },
- "conditional": function(co, th, el) {
- return add_spaces([ parenthesize(co, "assign", "seq", "conditional"), "?",
- parenthesize(th, "seq"), ":",
- parenthesize(el, "seq") ]);
- },
- "assign": function(op, lvalue, rvalue) {
- if (op && op !== true) op += "=";
- else op = "=";
- return add_spaces([ make(lvalue), op, parenthesize(rvalue, "seq") ]);
- },
- "dot": function(expr) {
- var out = make(expr), i = 1;
- if (expr[0] == "num") {
- if (!/\./.test(expr[1]))
- out += ".";
- } else if (needs_parens(expr))
- out = "(" + out + ")";
- while (i < arguments.length)
- out += "." + make_name(arguments[i++]);
- return out;
- },
- "call": function(func, args) {
- var f = make(func);
- if (needs_parens(func))
- f = "(" + f + ")";
- return f + "(" + add_commas(MAP(args, function(expr){
- return parenthesize(expr, "seq");
- })) + ")";
- },
- "function": make_function,
- "defun": make_function,
- "if": function(co, th, el) {
- var out = [ "if", "(" + make(co) + ")", el ? make_then(th) : make(th) ];
- if (el) {
- out.push("else", make(el));
- }
- return add_spaces(out);
- },
- "for": function(init, cond, step, block) {
- var out = [ "for" ];
- init = (init != null ? make(init) : "").replace(/;*\s*$/, ";" + space);
- cond = (cond != null ? make(cond) : "").replace(/;*\s*$/, ";" + space);
- step = (step != null ? make(step) : "").replace(/;*\s*$/, "");
- var args = init + cond + step;
- if (args == "; ; ") args = ";;";
- out.push("(" + args + ")", make(block));
- return add_spaces(out);
- },
- "for-in": function(vvar, key, hash, block) {
- return add_spaces([ "for", "(" +
- (vvar ? make(vvar).replace(/;+$/, "") : make(key)),
- "in",
- make(hash) + ")", make(block) ]);
- },
- "while": function(condition, block) {
- return add_spaces([ "while", "(" + make(condition) + ")", make(block) ]);
- },
- "do": function(condition, block) {
- return add_spaces([ "do", make(block), "while", "(" + make(condition) + ")" ]) + ";";
- },
- "return": function(expr) {
- var out = [ "return" ];
- if (expr != null) out.push(make(expr));
- return add_spaces(out) + ";";
- },
- "binary": function(operator, lvalue, rvalue) {
- var left = make(lvalue), right = make(rvalue);
- // XXX: I'm pretty sure other cases will bite here.
- // we need to be smarter.
- // adding parens all the time is the safest bet.
- if (member(lvalue[0], [ "assign", "conditional", "seq" ]) ||
- lvalue[0] == "binary" && PRECEDENCE[operator] > PRECEDENCE[lvalue[1]]) {
- left = "(" + left + ")";
- }
- if (member(rvalue[0], [ "assign", "conditional", "seq" ]) ||
- rvalue[0] == "binary" && PRECEDENCE[operator] >= PRECEDENCE[rvalue[1]] &&
- !(rvalue[1] == operator && member(operator, [ "&&", "||", "*" ]))) {
- right = "(" + right + ")";
- }
- return add_spaces([ left, operator, right ]);
- },
- "unary-prefix": function(operator, expr) {
- var val = make(expr);
- if (!(expr[0] == "num" || (expr[0] == "unary-prefix" && !HOP(OPERATORS, operator + expr[1])) || !needs_parens(expr)))
- val = "(" + val + ")";
- return operator + (jsp.is_alphanumeric_char(operator.charAt(0)) ? " " : "") + val;
- },
- "unary-postfix": function(operator, expr) {
- var val = make(expr);
- if (!(expr[0] == "num" || (expr[0] == "unary-postfix" && !HOP(OPERATORS, operator + expr[1])) || !needs_parens(expr)))
- val = "(" + val + ")";
- return val + operator;
- },
- "sub": function(expr, subscript) {
- var hash = make(expr);
- if (needs_parens(expr))
- hash = "(" + hash + ")";
- return hash + "[" + make(subscript) + "]";
- },
- "object": function(props) {
- if (props.length == 0)
- return "{}";
- return "{" + newline + with_indent(function(){
- return MAP(props, function(p){
- if (p.length == 3) {
- // getter/setter. The name is in p[0], the arg.list in p[1][2], the
- // body in p[1][3] and type ("get" / "set") in p[2].
- return indent(make_function(p[0], p[1][2], p[1][3], p[2]));
- }
- var key = p[0], val = make(p[1]);
- if (options.quote_keys) {
- key = encode_string(key);
- } else if ((typeof key == "number" || !beautify && +key + "" == key)
- && parseFloat(key) >= 0) {
- key = make_num(+key);
- } else if (!is_identifier(key)) {
- key = encode_string(key);
- }
- return indent(add_spaces(beautify && options.space_colon
- ? [ key, ":", val ]
- : [ key + ":", val ]));
- }).join("," + newline);
- }) + newline + indent("}");
- },
- "regexp": function(rx, mods) {
- return "/" + rx + "/" + mods;
- },
- "array": function(elements) {
- if (elements.length == 0) return "[]";
- return add_spaces([ "[", add_commas(MAP(elements, function(el){
- if (!beautify && el[0] == "atom" && el[1] == "undefined") return "";
- return parenthesize(el, "seq");
- })), "]" ]);
- },
- "stat": function(stmt) {
- return make(stmt).replace(/;*\s*$/, ";");
- },
- "seq": function() {
- return add_commas(MAP(slice(arguments), make));
- },
- "label": function(name, block) {
- return add_spaces([ make_name(name), ":", make(block) ]);
- },
- "with": function(expr, block) {
- return add_spaces([ "with", "(" + make(expr) + ")", make(block) ]);
- },
- "atom": function(name) {
- return make_name(name);
- }
- };
-
- // The squeezer replaces "block"-s that contain only a single
- // statement with the statement itself; technically, the AST
- // is correct, but this can create problems when we output an
- // IF having an ELSE clause where the THEN clause ends in an
- // IF *without* an ELSE block (then the outer ELSE would refer
- // to the inner IF). This function checks for this case and
- // adds the block brackets if needed.
- function make_then(th) {
- if (th[0] == "do") {
- // https://github.com/mishoo/UglifyJS/issues/#issue/57
- // IE croaks with "syntax error" on code like this:
- // if (foo) do ... while(cond); else ...
- // we need block brackets around do/while
- return make([ "block", [ th ]]);
- }
- var b = th;
- while (true) {
- var type = b[0];
- if (type == "if") {
- if (!b[3])
- // no else, we must add the block
- return make([ "block", [ th ]]);
- b = b[3];
- }
- else if (type == "while" || type == "do") b = b[2];
- else if (type == "for" || type == "for-in") b = b[4];
- else break;
- }
- return make(th);
- };
-
- function make_function(name, args, body, keyword) {
- var out = keyword || "function";
- if (name) {
- out += " " + make_name(name);
- }
- out += "(" + add_commas(MAP(args, make_name)) + ")";
- return add_spaces([ out, make_block(body) ]);
- };
-
- function make_block_statements(statements, noindent) {
- for (var a = [], last = statements.length - 1, i = 0; i <= last; ++i) {
- var stat = statements[i];
- var code = make(stat);
- if (code != ";") {
- if (!beautify && i == last) {
- if ((stat[0] == "while" && empty(stat[2])) ||
- (member(stat[0], [ "for", "for-in"] ) && empty(stat[4])) ||
- (stat[0] == "if" && empty(stat[2]) && !stat[3]) ||
- (stat[0] == "if" && stat[3] && empty(stat[3]))) {
- code = code.replace(/;*\s*$/, ";");
- } else {
- code = code.replace(/;+\s*$/, "");
- }
- }
- a.push(code);
- }
- }
- return noindent ? a : MAP(a, indent);
- };
-
- function make_switch_block(body) {
- var n = body.length;
- if (n == 0) return "{}";
- return "{" + newline + MAP(body, function(branch, i){
- var has_body = branch[1].length > 0, code = with_indent(function(){
- return indent(branch[0]
- ? add_spaces([ "case", make(branch[0]) + ":" ])
- : "default:");
- }, 0.5) + (has_body ? newline + with_indent(function(){
- return make_block_statements(branch[1]).join(newline);
- }) : "");
- if (!beautify && has_body && i < n - 1)
- code += ";";
- return code;
- }).join(newline) + newline + indent("}");
- };
-
- function make_block(statements) {
- if (!statements) return ";";
- if (statements.length == 0) return "{}";
- return "{" + newline + with_indent(function(){
- return make_block_statements(statements).join(newline);
- }) + newline + indent("}");
- };
-
- function make_1vardef(def) {
- var name = def[0], val = def[1];
- if (val != null)
- name = add_spaces([ make_name(name), "=", parenthesize(val, "seq") ]);
- return name;
- };
-
- var $stack = [];
-
- function make(node) {
- var type = node[0];
- var gen = generators[type];
- if (!gen)
- throw new Error("Can't find generator for \"" + type + "\"");
- $stack.push(node);
- var ret = gen.apply(type, node.slice(1));
- $stack.pop();
- return ret;
- };
-
- return make(ast);
-};
-
-function split_lines(code, max_line_length) {
- var splits = [ 0 ];
- jsp.parse(function(){
- var next_token = jsp.tokenizer(code);
- var last_split = 0;
- var prev_token;
- function current_length(tok) {
- return tok.pos - last_split;
- };
- function split_here(tok) {
- last_split = tok.pos;
- splits.push(last_split);
- };
- function custom(){
- var tok = next_token.apply(this, arguments);
- out: {
- if (prev_token) {
- if (prev_token.type == "keyword") break out;
- }
- if (current_length(tok) > max_line_length) {
- switch (tok.type) {
- case "keyword":
- case "atom":
- case "name":
- case "punc":
- split_here(tok);
- break out;
- }
- }
- }
- prev_token = tok;
- return tok;
- };
- custom.context = function() {
- return next_token.context.apply(this, arguments);
- };
- return custom;
- }());
- return splits.map(function(pos, i){
- return code.substring(pos, splits[i + 1] || code.length);
- }).join("\n");
-};
-
-/* -----[ Utilities ]----- */
-
-function repeat_string(str, i) {
- if (i <= 0) return "";
- if (i == 1) return str;
- var d = repeat_string(str, i >> 1);
- d += d;
- if (i & 1) d += str;
- return d;
-};
-
-function defaults(args, defs) {
- var ret = {};
- if (args === true)
- args = {};
- for (var i in defs) if (HOP(defs, i)) {
- ret[i] = (args && HOP(args, i)) ? args[i] : defs[i];
- }
- return ret;
-};
-
-function is_identifier(name) {
- return /^[a-z_$][a-z0-9_$]*$/i.test(name)
- && name != "this"
- && !HOP(jsp.KEYWORDS_ATOM, name)
- && !HOP(jsp.RESERVED_WORDS, name)
- && !HOP(jsp.KEYWORDS, name);
-};
-
-function HOP(obj, prop) {
- return Object.prototype.hasOwnProperty.call(obj, prop);
-};
-
-// some utilities
-
-var MAP;
-
-(function(){
- MAP = function(a, f, o) {
- var ret = [];
- for (var i = 0; i < a.length; ++i) {
- var val = f.call(o, a[i], i);
- if (val instanceof AtTop) ret.unshift(val.v);
- else ret.push(val);
- }
- return ret;
- };
- MAP.at_top = function(val) { return new AtTop(val) };
- function AtTop(val) { this.v = val };
-})();
-
-/* -----[ Exports ]----- */
-
-exports.ast_walker = ast_walker;
-exports.ast_mangle = ast_mangle;
-exports.ast_squeeze = ast_squeeze;
-exports.gen_code = gen_code;
-exports.ast_add_scope = ast_add_scope;
-exports.set_logger = function(logger) { warn = logger };
-exports.make_string = make_string;
-exports.split_lines = split_lines;
-exports.MAP = MAP;
-
-// keep this last!
-exports.ast_squeeze_more = require("./squeeze-more").ast_squeeze_more;
diff --git a/build/build/lib/squeeze-more.js b/build/build/lib/squeeze-more.js
deleted file mode 100644
index 12380af82..000000000
--- a/build/build/lib/squeeze-more.js
+++ /dev/null
@@ -1,22 +0,0 @@
-var jsp = require("./parse-js"),
- pro = require("./process"),
- slice = jsp.slice,
- member = jsp.member,
- PRECEDENCE = jsp.PRECEDENCE,
- OPERATORS = jsp.OPERATORS;
-
-function ast_squeeze_more(ast) {
- var w = pro.ast_walker(), walk = w.walk;
- return w.with_walkers({
- "call": function(expr, args) {
- if (expr[0] == "dot" && expr[2] == "toString" && args.length == 0) {
- // foo.toString() ==> foo+""
- return [ "binary", "+", expr[1], [ "string", "" ]];
- }
- }
- }, function() {
- return walk(ast);
- });
-};
-
-exports.ast_squeeze_more = ast_squeeze_more;
diff --git a/build/build/minify-js.sh b/build/build/minify-js.sh
deleted file mode 100755
index 2633a2f57..000000000
--- a/build/build/minify-js.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-dir=$(dirname $0)
-`which node nodejs 2> /dev/null` $dir/uglify.js $1 > $2
diff --git a/build/build/sizer.js b/build/build/sizer.js
deleted file mode 100644
index bdd27c6c4..000000000
--- a/build/build/sizer.js
+++ /dev/null
@@ -1,41 +0,0 @@
-var fs = require( "fs" ),
- stdin = process.openStdin(),
- rsize = /(\d+).*?(jquery\S+)/g,
- oldsizes = {},
- sizes = {},
- input = "";
-
-stdin.setEncoding( "utf8" );
-
-try {
- oldsizes = JSON.parse( fs.readFileSync( __dirname + "/.sizecache.json", "utf8" ) );
-} catch(e) {
- oldsizes = {};
-};
-
-function lpad( str, len, chr ) {
- return ( Array(len+1).join( chr || " ") + str ).substr( -len );
-}
-
-stdin.on( "data" , function( chunk ) {
- input += chunk;
-});
-stdin.on( "end", function() {
- var match;
-
- while ( match = rsize.exec( input ) ) {
- sizes[ match[2] ] = parseInt( match[1], 10 );
- }
-
- fs.writeFileSync( __dirname + "/.sizecache.json", JSON.stringify( sizes, true ), "utf8" );
- for ( var key in sizes ) {
- var diff = oldsizes[ key ] && ( sizes[ key ] - oldsizes[ key ] );
- if ( diff > 0 ) {
- diff = "+" + diff;
- }
- console.log( "%s %s %s", lpad( sizes[ key ], 8 ), lpad( oldsizes[key] ? "(" + diff + ")" : "(-)", 8 ), key );
- }
- process.nextTick(function() {
- process.exit();
- });
-}); \ No newline at end of file
diff --git a/build/build/style.xsl b/build/build/style.xsl
deleted file mode 100644
index 32daeed94..000000000
--- a/build/build/style.xsl
+++ /dev/null
@@ -1,211 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" />
-
- <xsl:template name="ref">
- <xsl:text>link-</xsl:text>
- <xsl:value-of select="translate(@name, '$.|', '')"/>
- <xsl:text>-</xsl:text>
- <xsl:for-each select="params">
- <xsl:value-of select="translate(@name, '&lt;&gt;|$.', '')" />
- </xsl:for-each>
- </xsl:template>
-
- <xsl:template name="href">
- <xsl:attribute name="href">
- <xsl:text>#</xsl:text>
- <xsl:call-template name="ref" />
- </xsl:attribute>
- </xsl:template>
-
- <xsl:template name="id">
- <xsl:attribute name="id">
- <xsl:call-template name="ref" />
- </xsl:attribute>
- </xsl:template>
-
- <xsl:template name="return">
- <xsl:attribute name="title">
- <xsl:choose>
- <xsl:when test="@return='jQuery'">A jQuery object.</xsl:when>
- <xsl:when test="@return='Boolean'">true or false.</xsl:when>
- <xsl:when test="@return='Object'">A simple Javascript object..</xsl:when>
- <xsl:when test="@return='String'">A string of characters.</xsl:when>
- <xsl:when test="@return='Number'">A valid numeric.</xsl:when>
- <xsl:when test="@return='String|Number'">A string of characters or a number.</xsl:when>
- <xsl:when test="@return='Element'">The Javascript object representation of a DOM Element.</xsl:when>
- <xsl:when test="@return='Element|Array&lt;Element&gt;'">One or more DOM Elements (a single one or an array).</xsl:when>
- <xsl:when test="@return='Map'">A Javascript object that contains key/value pairs in the form of properties and values.</xsl:when>
- <xsl:when test="@return='Array&lt;Element&gt;'">An Array of DOM Elements.</xsl:when>
- <xsl:when test="@return='Array&lt;String&gt;'">An Array of strings.</xsl:when>
- <xsl:when test="@return='Function'">A reference to a Javascript function.</xsl:when>
- <xsl:when test="@return='XMLHttpRequest'">An XMLHttpRequest object (referencing a HTTP request).</xsl:when>
- </xsl:choose>
- </xsl:attribute>
- <xsl:value-of select="@return"/>
- </xsl:template>
-
- <xsl:template name="type">
- <xsl:attribute name="title">
- <xsl:choose>
- <xsl:when test="@type='jQuery'">A jQuery object.</xsl:when>
- <xsl:when test="@type='Boolean'">true or false.</xsl:when>
- <xsl:when test="@type='Object'">A simple Javascript object..</xsl:when>
- <xsl:when test="@type='String'">A string of characters.</xsl:when>
- <xsl:when test="@type='Number'">A valid numeric.</xsl:when>
- <xsl:when test="@type='String|Number'">A string of characters or a number.</xsl:when>
- <xsl:when test="@type='Element'">The Javascript object representation of a DOM Element.</xsl:when>
- <xsl:when test="@type='Element|Array&lt;Element&gt;'">One or more DOM Elements (a single one or an array).</xsl:when>
- <xsl:when test="@type='Map'">A Javascript object that contains key/value pairs in the form of properties and values.</xsl:when>
- <xsl:when test="@type='Array&lt;Element&gt;'">An Array of DOM Elements.</xsl:when>
- <xsl:when test="@type='Array&lt;String&gt;'">An Array of strings.</xsl:when>
- <xsl:when test="@type='Function'">A reference to a Javascript function.</xsl:when>
- <xsl:when test="@type='XMLHttpRequest'">An XMLHttpRequest object (referencing a HTTP request).</xsl:when>
- </xsl:choose>
- </xsl:attribute>
- <xsl:value-of select="@type"/>
- </xsl:template>
-
- <xsl:template name="break">
- <xsl:value-of select="." disable-output-escaping="yes" />
- </xsl:template>
-
- <xsl:template name="option">
- <div class="param">
- <div class="param-header">
- <h3><span><xsl:value-of select="@name"/></span></h3>
- <p class="param-type"><span><xsl:call-template name="type" /></span></p>
- <p class="param-default">Default: <xsl:value-of select="@default"/></p>
- </div>
- <div class="param-details">
- <p><xsl:value-of select="desc"/></p>
- <!-- TODO select all examples -->
- <xsl:for-each select="following-sibling::example[1]">
- <h4>Code sample:</h4>
- <p><xsl:value-of select="desc" disable-output-escaping="yes"/></p>
- <code>
- <xsl:value-of select="code"/>
- </code>
- </xsl:for-each>
- </div>
- </div>
- </xsl:template>
-
- <xsl:template match="/*">
- <div id="widget-docs">
- <ul>
- <li><a href="#docs-overview"><span>Overview</span></a></li>
- <li><a href="#docs-options"><span>Options</span></a></li>
- <li><a href="#docs-methods"><span>Methods</span></a></li>
- <li><a href="#docs-theming"><span>Theming</span></a></li>
- </ul>
-
- <!-- TAB 1 -->
- <div id="docs-overview">
- <div id="docs-overview-sidebar">
- <h4>Dependencies:</h4>
- <ul>
- <li><a href="#">jquery.ui.core.js</a></li>
- <li><a href="#">jquery.ui.draggable.js <span>(Optional)</span></a></li>
- <li><a href="#">jquery.ui.resizable.js <span>(Optional)</span></a></li>
- </ul>
- </div>
- <div id="docs-overview-main">
- <p>
- <xsl:for-each select="//function[1]/desc">
- <xsl:call-template name="break" />
- </xsl:for-each>
- </p>
- <p>
- <xsl:for-each select="//function[1]/longdesc">
- <xsl:call-template name="break" />
- </xsl:for-each>
- </p>
- </div>
- </div>
-
- <!-- TAB 2 -->
- <div id="docs-options">
- <p class="intro"><xsl:value-of select="//function[1]/params/desc"/></p>
-
- <div class="docs-list-header clearfix">
- <h2>Property options</h2>
- <p><a href="#">Show details</a> | <a href="#">Hide details</a></p>
- </div>
-
- <div class="docs-list clearfix">
- <xsl:for-each select="//function[1]/option[not(starts-with(@type, 'function'))]">
- <xsl:call-template name="option"/>
- </xsl:for-each>
- </div><!-- /property options -->
-
- <div class="docs-list-header clearfix">
- <h2>Event options</h2>
- <p><a href="#">Show details</a> | <a href="#">Hide details</a></p>
- </div>
-
- <div class="docs-list clearfix">
- <xsl:for-each select="//function[1]/option[starts-with(@type, 'function')]">
- <xsl:call-template name="option"/>
- </xsl:for-each>
- </div><!-- /event options -->
- </div>
-
- <!-- TAB 3 -->
- <div id="docs-methods">
- <p class="intro">A brief description of methods and their uses goes here so their use is clearly explained and any caveats can be mentioned up front.</p>
-
- <div class="docs-list-header clearfix">
- <h2>Methods</h2>
- <p><a href="#">Show details</a> | <a href="#">Hide details</a></p>
- </div>
-
- <div class="docs-list clearfix">
- <xsl:for-each select="//function[position() != 1]">
- <div class="param">
- <div class="param-header">
- <h3><span><xsl:value-of select="//function[1]/@name"/>( <xsl:value-of select="params[1]/@name"/>
- <xsl:for-each select="params[position() != 1]">
- <xsl:text>, </xsl:text><xsl:value-of select="@name"/>
- </xsl:for-each>
- )</span></h3>
- <p class="param-type">Returns: <span><xsl:call-template name="return" /></span></p>
- </div>
- <div class="param-details">
- <p><xsl:value-of select="desc"/></p>
- <p><xsl:value-of select="longdesc"/></p>
- <h4>Arguments:</h4>
- <table class="param-args" summary="Arguments for this method" cellspacing="0">
- <tbody>
- <xsl:for-each select="params[position() != 1]">
- <tr>
- <td><xsl:value-of select="@name"/></td>
- <td><xsl:value-of select="@type"/></td>
- <td><xsl:value-of select="."/></td>
- </tr>
- </xsl:for-each>
- </tbody>
- </table>
-
- <h4>Code sample:</h4>
- <xsl:for-each select="example">
- <h5><xsl:value-of select="desc"/></h5>
- <code>
- <xsl:value-of select="code"/>
- </code>
- </xsl:for-each>
- </div>
- </div>
- </xsl:for-each>
-
- </div><!-- /methods -->
- </div>
-
- <!-- TAB 4 -->
- <div id="docs-theming">
- %%THEMING%%
- </div>
- </div>
- </xsl:template>
-
-</xsl:stylesheet>
diff --git a/build/build/uglify.js b/build/build/uglify.js
deleted file mode 100644
index 5b3fad4da..000000000
--- a/build/build/uglify.js
+++ /dev/null
@@ -1,285 +0,0 @@
-#! /usr/bin/env node
-// -*- js -*-
-
-global.sys = require(/^v0\.[012]/.test(process.version) ? "sys" : "util");
-var fs = require("fs");
-var jsp = require("./lib/parse-js"),
- pro = require("./lib/process");
-
-var options = {
- ast: false,
- mangle: true,
- mangle_toplevel: false,
- squeeze: true,
- make_seqs: true,
- dead_code: true,
- verbose: false,
- show_copyright: true,
- out_same_file: false,
- max_line_length: 32 * 1024,
- unsafe: false,
- reserved_names: null,
- defines: { },
- codegen_options: {
- ascii_only: false,
- beautify: false,
- indent_level: 4,
- indent_start: 0,
- quote_keys: false,
- space_colon: false
- },
- output: true // stdout
-};
-
-var args = jsp.slice(process.argv, 2);
-var filename;
-
-out: while (args.length > 0) {
- var v = args.shift();
- switch (v) {
- case "-b":
- case "--beautify":
- options.codegen_options.beautify = true;
- break;
- case "-i":
- case "--indent":
- options.codegen_options.indent_level = args.shift();
- break;
- case "-q":
- case "--quote-keys":
- options.codegen_options.quote_keys = true;
- break;
- case "-mt":
- case "--mangle-toplevel":
- options.mangle_toplevel = true;
- break;
- case "--no-mangle":
- case "-nm":
- options.mangle = false;
- break;
- case "--no-squeeze":
- case "-ns":
- options.squeeze = false;
- break;
- case "--no-seqs":
- options.make_seqs = false;
- break;
- case "--no-dead-code":
- options.dead_code = false;
- break;
- case "--no-copyright":
- case "-nc":
- options.show_copyright = false;
- break;
- case "-o":
- case "--output":
- options.output = args.shift();
- break;
- case "--overwrite":
- options.out_same_file = true;
- break;
- case "-v":
- case "--verbose":
- options.verbose = true;
- break;
- case "--ast":
- options.ast = true;
- break;
- case "--unsafe":
- options.unsafe = true;
- break;
- case "--max-line-len":
- options.max_line_length = parseInt(args.shift(), 10);
- break;
- case "--reserved-names":
- options.reserved_names = args.shift().split(",");
- break;
- case "-d":
- case "--define":
- var defarg = args.shift();
- try {
- var defsym = function(sym) {
- // KEYWORDS_ATOM doesn't include NaN or Infinity - should we check
- // for them too ?? We don't check reserved words and the like as the
- // define values are only substituted AFTER parsing
- if (jsp.KEYWORDS_ATOM.hasOwnProperty(sym)) {
- throw "Don't define values for inbuilt constant '"+sym+"'";
- }
- return sym;
- },
- defval = function(v) {
- if (v.match(/^"(.*)"$/) || v.match(/^'(.*)'$/)) {
- return [ "string", RegExp.$1 ];
- }
- else if (!isNaN(parseFloat(v))) {
- return [ "num", parseFloat(v) ];
- }
- else if (v.match(/^[a-z\$_][a-z\$_0-9]*$/i)) {
- return [ "name", v ];
- }
- else if (!v.match(/"/)) {
- return [ "string", v ];
- }
- else if (!v.match(/'/)) {
- return [ "string", v ];
- }
- throw "Can't understand the specified value: "+v;
- };
- if (defarg.match(/^([a-z_\$][a-z_\$0-9]*)(=(.*))?$/i)) {
- var sym = defsym(RegExp.$1),
- val = RegExp.$2 ? defval(RegExp.$2.substr(1)) : [ 'name', 'true' ];
- options.defines[sym] = val;
- }
- else {
- throw "The --define option expects SYMBOL[=value]";
- }
- } catch(ex) {
- sys.print("ERROR: In option --define "+defarg+"\n"+ex+"\n");
- process.exit(1);
- }
- break;
- case "--define-from-module":
- var defmodarg = args.shift(),
- defmodule = require(defmodarg),
- sym,
- val;
- for (sym in defmodule) {
- if (defmodule.hasOwnProperty(sym)) {
- options.defines[sym] = function(val) {
- if (typeof val == "string")
- return [ "string", val ];
- if (typeof val == "number")
- return [ "num", val ];
- if (val === true)
- return [ 'name', 'true' ];
- if (val === false)
- return [ 'name', 'false' ];
- if (val === null)
- return [ 'name', 'null' ];
- if (val === undefined)
- return [ 'name', 'undefined' ];
- sys.print("ERROR: In option --define-from-module "+defmodarg+"\n");
- sys.print("ERROR: Unknown object type for: "+sym+"="+val+"\n");
- process.exit(1);
- return null;
- }(defmodule[sym]);
- }
- }
- break;
- case "--ascii":
- options.codegen_options.ascii_only = true;
- break;
- default:
- filename = v;
- break out;
- }
-}
-
-if (options.verbose) {
- pro.set_logger(function(msg){
- sys.debug(msg);
- });
-}
-
-jsp.set_logger(function(msg){
- sys.debug(msg);
-});
-
-if (filename) {
- fs.readFile(filename, "utf8", function(err, text){
- if (err) throw err;
- output(squeeze_it(text));
- });
-} else {
- var stdin = process.openStdin();
- stdin.setEncoding("utf8");
- var text = "";
- stdin.on("data", function(chunk){
- text += chunk;
- });
- stdin.on("end", function() {
- output(squeeze_it(text));
- });
-}
-
-function output(text) {
- var out;
- if (options.out_same_file && filename)
- options.output = filename;
- if (options.output === true) {
- out = process.stdout;
- } else {
- out = fs.createWriteStream(options.output, {
- flags: "w",
- encoding: "utf8",
- mode: 0644
- });
- }
- out.write(text);
- if (options.output !== true) {
- out.end();
- }
-};
-
-// --------- main ends here.
-
-function show_copyright(comments) {
- var ret = "";
- for (var i = 0; i < comments.length; ++i) {
- var c = comments[i];
- if (c.type == "comment1") {
- ret += "//" + c.value + "\n";
- } else {
- ret += "/*" + c.value + "*/\n";
- }
- }
- return ret;
-};
-
-function squeeze_it(code) {
- var result = "";
- if (options.show_copyright) {
- var tok = jsp.tokenizer(code), c;
- c = tok();
- result += show_copyright(c.comments_before);
- }
- try {
- var ast = time_it("parse", function(){ return jsp.parse(code); });
- if (options.mangle) ast = time_it("mangle", function(){
- return pro.ast_mangle(ast, {
- toplevel: options.mangle_toplevel,
- defines: options.defines,
- except: options.reserved_names
- });
- });
- if (options.squeeze) ast = time_it("squeeze", function(){
- ast = pro.ast_squeeze(ast, {
- make_seqs : options.make_seqs,
- dead_code : options.dead_code,
- keep_comps : !options.unsafe
- });
- if (options.unsafe)
- ast = pro.ast_squeeze_more(ast);
- return ast;
- });
- if (options.ast)
- return sys.inspect(ast, null, null);
- result += time_it("generate", function(){ return pro.gen_code(ast, options.codegen_options) });
- if (!options.codegen_options.beautify && options.max_line_length) {
- result = time_it("split", function(){ return pro.split_lines(result, options.max_line_length) });
- }
- return result;
- } catch(ex) {
- sys.debug(ex.stack);
- sys.debug(sys.inspect(ex));
- sys.debug(JSON.stringify(ex));
- }
-};
-
-function time_it(name, cont) {
- if (!options.verbose)
- return cont();
- var t1 = new Date().getTime();
- try { return cont(); }
- finally { sys.debug("// " + name + ": " + ((new Date().getTime() - t1) / 1000).toFixed(3) + " sec."); }
-};
diff --git a/build/build/yuicompressor-2.4.2.jar b/build/build/yuicompressor-2.4.2.jar
deleted file mode 100644
index c29470bd0..000000000
--- a/build/build/yuicompressor-2.4.2.jar
+++ /dev/null
Binary files differ
diff --git a/demos/autocomplete/combobox.html b/demos/autocomplete/combobox.html
index ed457b206..e2ef40dd9 100644
--- a/demos/autocomplete/combobox.html
+++ b/demos/autocomplete/combobox.html
@@ -14,25 +14,37 @@
<script src="../../ui/jquery.ui.tooltip.js"></script>
<link rel="stylesheet" href="../demos.css">
<style>
+ .ui-combobox {
+ position: relative;
+ display: inline-block;
+ }
.ui-button {
+ position: absolute;
+ top: 0;
+ bottom: 0;
margin-left: -1px;
+ padding: 0;
+ /* adjust styles for IE 6/7 */
+ *height: 1.7em;
+ *top: 0.1em;
}
- .ui-button-icon-only .ui-button-text {
- padding: 0.35em;
- }
.ui-autocomplete-input {
margin: 0;
- padding: 0.4em 0 0.4em 0.45em;
+ padding: 0.3em;
}
</style>
<script>
(function( $ ) {
$.widget( "ui.combobox", {
_create: function() {
- var that = this,
+ var input,
+ that = this,
select = this.element.hide(),
selected = select.children( ":selected" ),
- value = selected.val() ? selected.text() : "";
+ value = selected.val() ? selected.text() : "",
+ wrapper = this.wrapper = $( "<span>" )
+ .addClass( "ui-combobox" )
+ .insertAfter( select );
function removeIfInvalid(element) {
var value = $( element ).val(),
@@ -59,10 +71,11 @@
}
}
- var input = this.input = $( "<input>" )
- .insertAfter( select )
+ input = $( "<input>" )
+ .appendTo( wrapper )
.val( value )
.attr( "title", "" )
+ .addClass( "ui-state-default" )
.autocomplete({
delay: 0,
minLength: 0,
@@ -103,11 +116,11 @@
.appendTo( ul );
};
- this.button = $( "<button type='button'>&nbsp;</button>" )
+ $( "<a>" )
.attr( "tabIndex", -1 )
.attr( "title", "Show All Items" )
.tooltip()
- .insertAfter( input )
+ .appendTo( wrapper )
.button({
icons: {
primary: "ui-icon-triangle-1-s"
@@ -142,8 +155,7 @@
},
destroy: function() {
- this.input.remove();
- this.button.remove();
+ this.wrapper.remove();
this.element.show();
$.Widget.prototype.destroy.call( this );
}
@@ -159,7 +171,7 @@
</script>
</head>
<body>
-
+
<div class="demo">
<div class="ui-widget">
diff --git a/demos/autocomplete/custom-data.html b/demos/autocomplete/custom-data.html
index c04c6905a..8f6eaa633 100644
--- a/demos/autocomplete/custom-data.html
+++ b/demos/autocomplete/custom-data.html
@@ -79,7 +79,7 @@
<div class="demo">
<div id="project-label">Select a project (type "j" for a start):</div>
- <img id="project-icon" src="images/transparent_1x1.png" class="ui-state-default">
+ <img id="project-icon" src="images/transparent_1x1.png" class="ui-state-default" alt="">
<input id="project">
<input type="hidden" id="project-id">
<p id="project-description"></p>
diff --git a/demos/autocomplete/maxheight.html b/demos/autocomplete/maxheight.html
index 9a2cc96a5..3804249dc 100644
--- a/demos/autocomplete/maxheight.html
+++ b/demos/autocomplete/maxheight.html
@@ -17,8 +17,6 @@
overflow-y: auto;
/* prevent horizontal scrollbar */
overflow-x: hidden;
- /* add padding to account for vertical scrollbar */
- padding-right: 20px;
}
/* IE 6 doesn't support max-height
* we use height instead, but this forces the menu to always be this tall
diff --git a/demos/datepicker/date-range.html b/demos/datepicker/date-range.html
index f939e8e93..09ebba842 100644
--- a/demos/datepicker/date-range.html
+++ b/demos/datepicker/date-range.html
@@ -11,18 +11,20 @@
<link rel="stylesheet" href="../demos.css">
<script>
$(function() {
- var dates = $( "#from, #to" ).datepicker({
+ $( "#from" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 3,
onSelect: function( selectedDate ) {
- var option = this.id == "from" ? "minDate" : "maxDate",
- instance = $( this ).data( "datepicker" ),
- date = $.datepicker.parseDate(
- instance.settings.dateFormat ||
- $.datepicker._defaults.dateFormat,
- selectedDate, instance.settings );
- dates.not( this ).datepicker( "option", option, date );
+ $( "#to" ).datepicker( "option", "minDate", selectedDate );
+ }
+ });
+ $( "#to" ).datepicker({
+ defaultDate: "+1w",
+ changeMonth: true,
+ numberOfMonths: 3,
+ onSelect: function( selectedDate ) {
+ $( "#from" ).datepicker( "option", "maxDate", selectedDate );
}
});
});
diff --git a/demos/demos.css b/demos/demos.css
index cf6da8bd1..807d025b5 100644
--- a/demos/demos.css
+++ b/demos/demos.css
@@ -18,6 +18,8 @@ body {
.layout-grid {
width: 960px;
+ border-spacing: 0;
+ border-collapse: collapse;
}
.layout-grid td {
diff --git a/demos/draggable/snap-to.html b/demos/draggable/snap-to.html
index 320cb7947..a0f38f866 100644
--- a/demos/draggable/snap-to.html
+++ b/demos/draggable/snap-to.html
@@ -28,12 +28,12 @@
<body>
<div class="demo">
-
+
<div id="snaptarget" class="ui-widget-header">
<p>I'm a snap target</p>
</div>
-<br clear="both" />
+<br style="clear:both" />
<div id="draggable" class="draggable ui-widget-content">
<p>Default (snap: true), snaps to all other draggable elements</p>
diff --git a/demos/index.html b/demos/index.html
index f96753d37..678c9961f 100644
--- a/demos/index.html
+++ b/demos/index.html
@@ -269,7 +269,7 @@
</head>
<body>
-<table class="layout-grid" cellspacing="0" cellpadding="0">
+<table class="layout-grid">
<tr>
<td class="left-nav">
<dl class="demos-nav">
diff --git a/demos/menu/default.html b/demos/menu/default.html
index 9f2e21622..b1c0b9fbb 100644
--- a/demos/menu/default.html
+++ b/demos/menu/default.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
- <meta charset="UTF-8" />
+ <meta charset="utf-8">
<title>jQuery UI Menu - Default demo</title>
<link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" />
<script src="../../jquery-1.7.2.js"></script>
@@ -15,7 +15,7 @@
});
</script>
<style>
-
+
</style>
</head>
<body>
diff --git a/demos/menu/index.html b/demos/menu/index.html
index f55d16514..b5bdb43fd 100644
--- a/demos/menu/index.html
+++ b/demos/menu/index.html
@@ -10,7 +10,6 @@
<h4>Examples</h4>
<ul>
<li class="demo-config-on"><a href="default.html">Default functionality</a></li>
- <li><a href="contextmenu.html">Contextmenu</a></li>
<li><a href="topalignmenu.html">Top-aligned sub menus</a></li>
<li><a href="navigationmenu.html">Navigation menu</a></li>
</ul>
diff --git a/demos/menu/navigationmenu.html b/demos/menu/navigationmenu.html
index 970b20890..8c7b2b993 100644
--- a/demos/menu/navigationmenu.html
+++ b/demos/menu/navigationmenu.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
- <meta charset="UTF-8" />
+ <meta charset="utf-8">
<title>jQuery UI Menu - Navigation Menu demo</title>
<link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" />
<script src="../../jquery-1.7.2.js"></script>
diff --git a/demos/menu/topalignmenu.html b/demos/menu/topalignmenu.html
index deb8fbb6f..7b7e052e4 100644
--- a/demos/menu/topalignmenu.html
+++ b/demos/menu/topalignmenu.html
@@ -1,15 +1,16 @@
<!doctype html>
<html>
<head>
+ <meta charset="utf-8">
<title>Menu Demo: Top-aligned Menu</title>
- <link rel="stylesheet" href="../demos.css" type="text/css" />
- <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css" type="text/css" title="ui-theme" />
- <script type="text/javascript" src="../../jquery-1.7.2.js"></script>
- <script type="text/javascript" src="../../ui/jquery.ui.core.js"></script>
- <script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script>
- <script type="text/javascript" src="../../ui/jquery.ui.position.js"></script>
- <script type="text/javascript" src="../../ui/jquery.ui.menu.js"></script>
- <script type="text/javascript">
+ <link type="text/css" href="../demos.css" rel="stylesheet" />
+ <link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" />
+ <script src="../../jquery-1.7.2.js"></script>
+ <script src="../../ui/jquery.ui.core.js"></script>
+ <script src="../../ui/jquery.ui.widget.js"></script>
+ <script src="../../ui/jquery.ui.position.js"></script>
+ <script src="../../ui/jquery.ui.menu.js"></script>
+ <script>
$(function() {
$("#topMenu").menu({
position: { of: "ul:has(a.ui-state-focus):last" }
diff --git a/demos/position/cycler.html b/demos/position/cycler.html
index 084b10fc1..490d88fcb 100644
--- a/demos/position/cycler.html
+++ b/demos/position/cycler.html
@@ -101,9 +101,9 @@
<div class="demo">
-<img src="images/earth.jpg" width="458" height="308" />
-<img src="images/flight.jpg" width="512" height="307" />
-<img src="images/rocket.jpg" width="300" height="353" />
+<img src="images/earth.jpg" width="458" height="308" alt="earth" />
+<img src="images/flight.jpg" width="512" height="307" alt="flight" />
+<img src="images/rocket.jpg" width="300" height="353" alt="rocket" />
<a id="previous" href="#">Previous</a>
<a id="next" href="#">Next</a>
diff --git a/demos/position/default.html b/demos/position/default.html
index 202417348..01137be62 100644
--- a/demos/position/default.html
+++ b/demos/position/default.html
@@ -1,4 +1,4 @@
-<!DOCTYPE html>
+<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
@@ -37,53 +37,28 @@
width: 120px;
height: 40px;
}
- .ui-flipped-top {
- border-top: 3px solid #000000;
- }
- .ui-flipped-bottom {
- border-bottom: 3px solid #000000;
- }
- .ui-flipped-left {
- border-left: 3px solid #000000;
- }
- .ui-flipped-right {
- border-right: 3px solid #000000;
- }
select, input {
margin-left: 15px;
}
</style>
<script>
$(function() {
- function position( using ) {
+ function position() {
$( ".positionable" ).position({
of: $( "#parent" ),
my: $( "#my_horizontal" ).val() + " " + $( "#my_vertical" ).val(),
at: $( "#at_horizontal" ).val() + " " + $( "#at_vertical" ).val(),
offset: $( "#offset" ).val(),
- using: using,
- collision: $( "#collision_horizontal" ).val() + ' ' + $( "#collision_vertical" ).val()
+ collision: $( "#collision_horizontal" ).val() + " " + $( "#collision_vertical" ).val()
});
}
$( ".positionable" ).css( "opacity", 0.5 );
- $( ":input" ).bind( "click keyup change", function() { position(); });
+ $( ":input" ).bind( "click keyup change", position );
$( "#parent" ).draggable({
- drag: function() { position(); }
- });
-
- $( ".positionable" ).draggable({
- drag: function( event, ui ) {
- // reset offset before calculating it
- $( "#offset" ).val( "0" );
- position(function( result ) {
- $( "#offset" ).val( "" + ( ui.offset.left - result.left ) +
- " " + ( ui.offset.top - result.top ) );
- position();
- });
- }
+ drag: position
});
position();
@@ -142,7 +117,7 @@
</div>
<div style="padding-bottom: 20px;">
<b>offset:</b>
- <input id="offset" type="text" size="15"/>
+ <input id="offset">
</div>
<div style="padding-bottom: 20px;">
<b>collision:</b>
diff --git a/demos/sortable/empty-lists.html b/demos/sortable/empty-lists.html
index f49b1072f..87b581844 100644
--- a/demos/sortable/empty-lists.html
+++ b/demos/sortable/empty-lists.html
@@ -51,7 +51,7 @@
<ul id="sortable3" class='droptrue'>
</ul>
-<br clear="both" />
+<br style="clear:both" />
</div><!-- End demo -->
diff --git a/demos/tooltip/custom-content.html b/demos/tooltip/custom-content.html
index 41739cfa7..3b3308153 100644
--- a/demos/tooltip/custom-content.html
+++ b/demos/tooltip/custom-content.html
@@ -30,9 +30,11 @@
content: function() {
var element = $( this );
if ( element.is( "[data-geo]" ) ) {
- return "<img class='map' src='http://maps.google.com/maps/api/staticmap?" +
+ var text = element.text();
+ return "<img class='map' alt='" + text +
+ "' src='http://maps.google.com/maps/api/staticmap?" +
"zoom=11&size=350x350&maptype=terrain&sensor=false&center=" +
- element.text() + "'>";
+ text + "'>";
}
if ( element.is( "[title]" ) ) {
return element.attr( "title" );
@@ -52,7 +54,7 @@
<div class="ui-widget photo">
<div class="ui-widget-header ui-corner-all">
<h2>St. Stephen's Cathedral</h2>
- <h3><a href="http://maps.google.com/maps?q=vienna,+austria&z=11" data-geo>Vienna, Austria</a></h3>
+ <h3><a href="http://maps.google.com/maps?q=vienna,+austria&amp;z=11" data-geo>Vienna, Austria</a></h3>
</div>
<a href="http://en.wikipedia.org/wiki/File:Wien_Stefansdom_DSC02656.JPG">
<img src="images/st-stephens.jpg" alt="St. Stephen's Cathedral" class="ui-corner-all">
@@ -62,7 +64,7 @@
<div class="ui-widget photo">
<div class="ui-widget-header ui-corner-all">
<h2>Tower Bridge</h2>
- <h3><a href="http://maps.google.com/maps?q=london,+england&z=11" data-geo>London, England</a></h3>
+ <h3><a href="http://maps.google.com/maps?q=london,+england&amp;z=11" data-geo>London, England</a></h3>
</div>
<a href="http://en.wikipedia.org/wiki/File:Tower_bridge_London_Twilight_-_November_2006.jpg">
<img src="images/tower-bridge.jpg" alt="Tower Bridge" class="ui-corner-all">
diff --git a/demos/tooltip/custom-style.html b/demos/tooltip/custom-style.html
index 4d48616cb..633da3d95 100644
--- a/demos/tooltip/custom-style.html
+++ b/demos/tooltip/custom-style.html
@@ -13,76 +13,67 @@
<script>
$(function() {
$( ".demo" ).tooltip({
- open: function(event, ui) {
- $("<div>").addClass("arrow").appendTo(ui.tooltip);
- },
position: {
- my: "center bottom",
+ my: "center bottom-20",
at: "center top",
- offset: "0 -20px"
+ using: function( position, feedback ) {
+ $( this ).css( position );
+ $( "<div>" )
+ .addClass( "arrow" )
+ .addClass( feedback.vertical )
+ .addClass( feedback.horizontal )
+ .appendTo( this );
+ }
}
});
});
</script>
<style>
- label {
- display: inline-block;
- width: 5em;
- }
- .demo {
- margin: 10em 0 0 10em;
- }
.ui-tooltip, .arrow:after {
- background: black;
- border: 2px solid white;
+ background: black;
+ border: 2px solid white;
}
.ui-tooltip {
- display: inline-block;
- position: relative;
- padding: 10px 20px;
- color: white;
- border-radius: 20px;
- text-align: center;
- font: bold 14px "Helvetica Neue", Sans-Serif;
- font-stretch: condensed;
- text-decoration: none;
- text-transform: uppercase;
- box-shadow: 0 0 7px black;
+ padding: 10px 20px;
+ color: white;
+ border-radius: 20px;
+ font: bold 14px "Helvetica Neue", Sans-Serif;
+ text-transform: uppercase;
+ box-shadow: 0 0 7px black;
}
.arrow {
- width: 70px;
- height: 16px;
- overflow: hidden;
- position: absolute;
- left: 50%;
- margin-left: -35px;
- bottom: -16px;
+ width: 70px;
+ height: 16px;
+ overflow: hidden;
+ position: absolute;
+ left: 50%;
+ margin-left: -35px;
+ bottom: -16px;
}
- .arrow:after {
- content: "";
- position: absolute;
- left: 20px;
- top: -20px;
- width: 25px;
- height: 25px;
- -webkit-box-shadow: 6px 5px 9px -9px black,
- 5px 6px 9px -9px black;
- -moz-box-shadow: 6px 5px 9px -9px black,
- 5px 6px 9px -9px black;
- box-shadow: 6px 5px 9px -9px black,
- 5px 6px 9px -9px black;
- -webkit-transform: rotate(45deg);
- -moz-transform: rotate(45deg);
- -ms-transform: rotate(45deg);
- -o-transform: rotate(45deg);
+ .arrow.top {
+ top: -16px;
+ bottom: auto;
}
- div[data-tooltip].active {
- opacity: 1;
- margin-top: 6px;
+ .arrow.left {
+ left: 20%;
+ }
+ .arrow:after {
+ content: "";
+ position: absolute;
+ left: 20px;
+ top: -20px;
+ width: 25px;
+ height: 25px;
+ box-shadow: 6px 5px 9px -9px black;
+ -webkit-transform: rotate(45deg);
+ -moz-transform: rotate(45deg);
+ -ms-transform: rotate(45deg);
+ -o-transform: rotate(45deg);
+ tranform: rotate(45deg);
}
- div[data-tooltip].out {
- opacity: 0;
- margin-top: -20px;
+ .arrow.top:after {
+ bottom: -20px;
+ top: auto;
}
</style>
</head>
diff --git a/demos/tooltip/forms.html b/demos/tooltip/forms.html
index ec01396a7..6440bf89e 100644
--- a/demos/tooltip/forms.html
+++ b/demos/tooltip/forms.html
@@ -27,26 +27,14 @@
</style>
<script>
$(function() {
- var tooltips = $( "[title]" )
- .click(function() {
- $( this ).tooltip( $( this ).attr( "title" ) ? "open" : "close" );
- })
- .bind( "mouseover focusin mouseleave blur click", function( event ) {
- event.stopImmediatePropagation();
- })
- .tooltip();
+ var tooltips = $( "[title]" ).tooltip();
$( "<button>" )
.text( "Show help" )
.button()
- .toggle(
- function() {
- tooltips.tooltip( "open" );
- },
- function() {
- tooltips.tooltip( "close" );
- }
- )
- .appendTo( "form" );
+ .click(function() {
+ tooltips.tooltip( "open" );
+ })
+ .insertAfter( "form" );
});
</script>
</head>
@@ -58,18 +46,15 @@
<fieldset>
<div>
<label for="firstname">Firstname</label>
- <input id="firstname" name="firstname">
- <span title="Please provide your firstname." class="help ui-state-default ui-corner-all ui-icon ui-icon-help">?</span>
+ <input id="firstname" name="firstname" title="Please provide your firstname.">
</div>
<div>
<label for="lastname">Lastname</label>
- <input id="lastname" name="lastname">
- <span title="Please provide also your lastname." class="help ui-state-default ui-corner-all ui-icon ui-icon-help">?</span>
+ <input id="lastname" name="lastname" title="Please provide also your lastname.">
</div>
<div>
<label for="address">Address</label>
- <input id="address" name="address">
- <span title="Your home or work address." class="help ui-state-default ui-corner-all ui-icon ui-icon-help">?</span>
+ <input id="address" name="address" title="Your home or work address.">
</div>
</fieldset>
</form>
@@ -79,7 +64,7 @@
<div class="demo-description">
-<p>Use the button below to display the help texts. Click again to hide them. Default hover and focus events are removed to show tooltip only programmatically.</p>
+<p>Use the button below to display the help texts, or just focus or mouseover the indivdual inputs.</p>
<p>A fixed width is defined in CSS to make the tooltips look consistent when displayed all at once.</p>
</div><!-- End demo-description -->
diff --git a/external/jshint.js b/external/jshint.js
new file mode 100644
index 000000000..5bf937c4b
--- /dev/null
+++ b/external/jshint.js
@@ -0,0 +1,4390 @@
+/*!
+ * JSHint, by JSHint Community.
+ *
+ * Licensed under the same slightly modified MIT license that JSLint is.
+ * It stops evil-doers everywhere.
+ *
+ * JSHint is a derivative work of JSLint:
+ *
+ * Copyright (c) 2002 Douglas Crockford (www.JSLint.com)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * The Software shall be used for Good, not Evil.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * JSHint was forked from 2010-12-16 edition of JSLint.
+ *
+ */
+
+/*
+ JSHINT is a global function. It takes two parameters.
+
+ var myResult = JSHINT(source, option);
+
+ The first parameter is either a string or an array of strings. If it is a
+ string, it will be split on '\n' or '\r'. If it is an array of strings, it
+ is assumed that each string represents one line. The source can be a
+ JavaScript text or a JSON text.
+
+ The second parameter is an optional object of options which control the
+ operation of JSHINT. Most of the options are booleans: They are all
+ optional and have a default value of false. One of the options, predef,
+ can be an array of names, which will be used to declare global variables,
+ or an object whose keys are used as global names, with a boolean value
+ that determines if they are assignable.
+
+ If it checks out, JSHINT returns true. Otherwise, it returns false.
+
+ If false, you can inspect JSHINT.errors to find out the problems.
+ JSHINT.errors is an array of objects containing these members:
+
+ {
+ line : The line (relative to 0) at which the lint was found
+ character : The character (relative to 0) at which the lint was found
+ reason : The problem
+ evidence : The text line in which the problem occurred
+ raw : The raw message before the details were inserted
+ a : The first detail
+ b : The second detail
+ c : The third detail
+ d : The fourth detail
+ }
+
+ If a fatal error was found, a null will be the last element of the
+ JSHINT.errors array.
+
+ You can request a Function Report, which shows all of the functions
+ and the parameters and vars that they use. This can be used to find
+ implied global variables and other problems. The report is in HTML and
+ can be inserted in an HTML <body>.
+
+ var myReport = JSHINT.report(limited);
+
+ If limited is true, then the report will be limited to only errors.
+
+ You can request a data structure which contains JSHint's results.
+
+ var myData = JSHINT.data();
+
+ It returns a structure with this form:
+
+ {
+ errors: [
+ {
+ line: NUMBER,
+ character: NUMBER,
+ reason: STRING,
+ evidence: STRING
+ }
+ ],
+ functions: [
+ name: STRING,
+ line: NUMBER,
+ last: NUMBER,
+ param: [
+ STRING
+ ],
+ closure: [
+ STRING
+ ],
+ var: [
+ STRING
+ ],
+ exception: [
+ STRING
+ ],
+ outer: [
+ STRING
+ ],
+ unused: [
+ STRING
+ ],
+ global: [
+ STRING
+ ],
+ label: [
+ STRING
+ ]
+ ],
+ globals: [
+ STRING
+ ],
+ member: {
+ STRING: NUMBER
+ },
+ unused: [
+ {
+ name: STRING,
+ line: NUMBER
+ }
+ ],
+ implieds: [
+ {
+ name: STRING,
+ line: NUMBER
+ }
+ ],
+ urls: [
+ STRING
+ ],
+ json: BOOLEAN
+ }
+
+ Empty arrays will not be included.
+
+*/
+
+/*jshint
+ evil: true, nomen: false, onevar: false, regexp: false, strict: true, boss: true,
+ undef: true, maxlen: 100, indent:4
+*/
+
+/*members "\b", "\t", "\n", "\f", "\r", "!=", "!==", "\"", "%", "(begin)",
+ "(breakage)", "(context)", "(error)", "(global)", "(identifier)", "(last)",
+ "(line)", "(loopage)", "(name)", "(onevar)", "(params)", "(scope)",
+ "(statement)", "(verb)", "*", "+", "++", "-", "--", "\/", "<", "<=", "==",
+ "===", ">", ">=", $, $$, $A, $F, $H, $R, $break, $continue, $w, Abstract, Ajax,
+ __filename, __dirname, ActiveXObject, Array, ArrayBuffer, ArrayBufferView, Audio,
+ Autocompleter, Assets, Boolean, Builder, Buffer, Browser, COM, CScript, Canvas,
+ CustomAnimation, Class, Control, Chain, Color, Cookie, Core, DataView, Date,
+ Debug, Draggable, Draggables, Droppables, Document, DomReady, DOMReady, Drag,
+ E, Enumerator, Enumerable, Element, Elements, Error, Effect, EvalError, Event,
+ Events, FadeAnimation, Field, Flash, Float32Array, Float64Array, Form,
+ FormField, Frame, FormData, Function, Fx, GetObject, Group, Hash, HotKey,
+ HTMLElement, HTMLAnchorElement, HTMLBaseElement, HTMLBlockquoteElement,
+ HTMLBodyElement, HTMLBRElement, HTMLButtonElement, HTMLCanvasElement, HTMLDirectoryElement,
+ HTMLDivElement, HTMLDListElement, HTMLFieldSetElement,
+ HTMLFontElement, HTMLFormElement, HTMLFrameElement, HTMLFrameSetElement,
+ HTMLHeadElement, HTMLHeadingElement, HTMLHRElement, HTMLHtmlElement,
+ HTMLIFrameElement, HTMLImageElement, HTMLInputElement, HTMLIsIndexElement,
+ HTMLLabelElement, HTMLLayerElement, HTMLLegendElement, HTMLLIElement,
+ HTMLLinkElement, HTMLMapElement, HTMLMenuElement, HTMLMetaElement,
+ HTMLModElement, HTMLObjectElement, HTMLOListElement, HTMLOptGroupElement,
+ HTMLOptionElement, HTMLParagraphElement, HTMLParamElement, HTMLPreElement,
+ HTMLQuoteElement, HTMLScriptElement, HTMLSelectElement, HTMLStyleElement,
+ HtmlTable, HTMLTableCaptionElement, HTMLTableCellElement, HTMLTableColElement,
+ HTMLTableElement, HTMLTableRowElement, HTMLTableSectionElement,
+ HTMLTextAreaElement, HTMLTitleElement, HTMLUListElement, HTMLVideoElement,
+ Iframe, IframeShim, Image, Int16Array, Int32Array, Int8Array,
+ Insertion, InputValidator, JSON, Keyboard, Locale, LN10, LN2, LOG10E, LOG2E,
+ MAX_VALUE, MIN_VALUE, Mask, Math, MenuItem, MoveAnimation, MooTools, Native,
+ NEGATIVE_INFINITY, Number, Object, ObjectRange, Option, Options, OverText, PI,
+ POSITIVE_INFINITY, PeriodicalExecuter, Point, Position, Prototype, RangeError,
+ Rectangle, ReferenceError, RegExp, ResizeAnimation, Request, RotateAnimation,
+ SQRT1_2, SQRT2, ScrollBar, ScriptEngine, ScriptEngineBuildVersion,
+ ScriptEngineMajorVersion, ScriptEngineMinorVersion, Scriptaculous, Scroller,
+ Slick, Slider, Selector, SharedWorker, String, Style, SyntaxError, Sortable, Sortables,
+ SortableObserver, Sound, Spinner, System, Swiff, Text, TextArea, Template,
+ Timer, Tips, Type, TypeError, Toggle, Try, "use strict", unescape, URI, URIError, URL,
+ VBArray, WSH, WScript, XDomainRequest, Web, Window, XMLDOM, XMLHttpRequest, XPathEvaluator,
+ XPathException, XPathExpression, XPathNamespace, XPathNSResolver, XPathResult, "\\", a,
+ addEventListener, address, alert, apply, applicationCache, arguments, arity,
+ asi, b, basic, basicToken, bitwise, block, blur, boolOptions, boss, browser, c, call, callee,
+ caller, cases, charAt, charCodeAt, character, clearInterval, clearTimeout,
+ close, closed, closure, comment, condition, confirm, console, constructor,
+ content, couch, create, css, curly, d, data, datalist, dd, debug, decodeURI,
+ decodeURIComponent, defaultStatus, defineClass, deserialize, devel, document,
+ dojo, dijit, dojox, define, else, emit, encodeURI, encodeURIComponent,
+ entityify, eqeqeq, eqnull, errors, es5, escape, esnext, eval, event, evidence, evil,
+ ex, exception, exec, exps, expr, exports, FileReader, first, floor, focus,
+ forin, fragment, frames, from, fromCharCode, fud, funcscope, funct, function, functions,
+ g, gc, getComputedStyle, getRow, getter, getterToken, GLOBAL, global, globals, globalstrict,
+ hasOwnProperty, help, history, i, id, identifier, immed, implieds, importPackage, include,
+ indent, indexOf, init, ins, instanceOf, isAlpha, isApplicationRunning, isArray,
+ isDigit, isFinite, isNaN, iterator, java, join, jshint,
+ JSHINT, json, jquery, jQuery, keys, label, labelled, last, lastsemic, laxbreak, laxcomma,
+ latedef, lbp, led, left, length, line, load, loadClass, localStorage, location,
+ log, loopfunc, m, match, maxerr, maxlen, member,message, meta, module, moveBy,
+ moveTo, mootools, multistr, name, navigator, new, newcap, noarg, node, noempty, nomen,
+ nonew, nonstandard, nud, onbeforeunload, onblur, onerror, onevar, onecase, onfocus,
+ onload, onresize, onunload, open, openDatabase, openURL, opener, opera, options, outer, param,
+ parent, parseFloat, parseInt, passfail, plusplus, predef, print, process, prompt,
+ proto, prototype, prototypejs, provides, push, quit, range, raw, reach, reason, regexp,
+ readFile, readUrl, regexdash, removeEventListener, replace, report, require,
+ reserved, resizeBy, resizeTo, resolvePath, resumeUpdates, respond, rhino, right,
+ runCommand, scroll, screen, scripturl, scrollBy, scrollTo, scrollbar, search, seal,
+ send, serialize, sessionStorage, setInterval, setTimeout, setter, setterToken, shift, slice,
+ smarttabs, sort, spawn, split, stack, status, start, strict, sub, substr, supernew, shadow,
+ supplant, sum, sync, test, toLowerCase, toString, toUpperCase, toint32, token, top, trailing,
+ type, typeOf, Uint16Array, Uint32Array, Uint8Array, undef, undefs, unused, urls, validthis,
+ value, valueOf, var, version, WebSocket, white, window, Worker, wsh*/
+
+/*global exports: false */
+
+// We build the application inside a function so that we produce only a single
+// global variable. That function will be invoked immediately, and its return
+// value is the JSHINT function itself.
+
+var JSHINT = (function () {
+ "use strict";
+
+ var anonname, // The guessed name for anonymous functions.
+
+// These are operators that should not be used with the ! operator.
+
+ bang = {
+ '<' : true,
+ '<=' : true,
+ '==' : true,
+ '===': true,
+ '!==': true,
+ '!=' : true,
+ '>' : true,
+ '>=' : true,
+ '+' : true,
+ '-' : true,
+ '*' : true,
+ '/' : true,
+ '%' : true
+ },
+
+ // These are the JSHint boolean options.
+ boolOptions = {
+ asi : true, // if automatic semicolon insertion should be tolerated
+ bitwise : true, // if bitwise operators should not be allowed
+ boss : true, // if advanced usage of assignments should be allowed
+ browser : true, // if the standard browser globals should be predefined
+ couch : true, // if CouchDB globals should be predefined
+ curly : true, // if curly braces around all blocks should be required
+ debug : true, // if debugger statements should be allowed
+ devel : true, // if logging globals should be predefined (console,
+ // alert, etc.)
+ dojo : true, // if Dojo Toolkit globals should be predefined
+ eqeqeq : true, // if === should be required
+ eqnull : true, // if == null comparisons should be tolerated
+ es5 : true, // if ES5 syntax should be allowed
+ esnext : true, // if es.next specific syntax should be allowed
+ evil : true, // if eval should be allowed
+ expr : true, // if ExpressionStatement should be allowed as Programs
+ forin : true, // if for in statements must filter
+ funcscope : true, // if only function scope should be used for scope tests
+ globalstrict: true, // if global "use strict"; should be allowed (also
+ // enables 'strict')
+ immed : true, // if immediate invocations must be wrapped in parens
+ iterator : true, // if the `__iterator__` property should be allowed
+ jquery : true, // if jQuery globals should be predefined
+ lastsemic : true, // if semicolons may be ommitted for the trailing
+ // statements inside of a one-line blocks.
+ latedef : true, // if the use before definition should not be tolerated
+ laxbreak : true, // if line breaks should not be checked
+ laxcomma : true, // if line breaks should not be checked around commas
+ loopfunc : true, // if functions should be allowed to be defined within
+ // loops
+ mootools : true, // if MooTools globals should be predefined
+ multistr : true, // allow multiline strings
+ newcap : true, // if constructor names must be capitalized
+ noarg : true, // if arguments.caller and arguments.callee should be
+ // disallowed
+ node : true, // if the Node.js environment globals should be
+ // predefined
+ noempty : true, // if empty blocks should be disallowed
+ nonew : true, // if using `new` for side-effects should be disallowed
+ nonstandard : true, // if non-standard (but widely adopted) globals should
+ // be predefined
+ nomen : true, // if names should be checked
+ onevar : true, // if only one var statement per function should be
+ // allowed
+ onecase : true, // if one case switch statements should be allowed
+ passfail : true, // if the scan should stop on first error
+ plusplus : true, // if increment/decrement should not be allowed
+ proto : true, // if the `__proto__` property should be allowed
+ prototypejs : true, // if Prototype and Scriptaculous globals should be
+ // predefined
+ regexdash : true, // if unescaped first/last dash (-) inside brackets
+ // should be tolerated
+ regexp : true, // if the . should not be allowed in regexp literals
+ rhino : true, // if the Rhino environment globals should be predefined
+ undef : true, // if variables should be declared before used
+ scripturl : true, // if script-targeted URLs should be tolerated
+ shadow : true, // if variable shadowing should be tolerated
+ smarttabs : true, // if smarttabs should be tolerated
+ // (http://www.emacswiki.org/emacs/SmartTabs)
+ strict : true, // require the "use strict"; pragma
+ sub : true, // if all forms of subscript notation are tolerated
+ supernew : true, // if `new function () { ... };` and `new Object;`
+ // should be tolerated
+ trailing : true, // if trailing whitespace rules apply
+ validthis : true, // if 'this' inside a non-constructor function is valid.
+ // This is a function scoped option only.
+ white : true, // if strict whitespace rules apply
+ wsh : true // if the Windows Scripting Host environment globals
+ // should be predefined
+ },
+
+ // browser contains a set of global names which are commonly provided by a
+ // web browser environment.
+ browser = {
+ ArrayBuffer : false,
+ ArrayBufferView : false,
+ Audio : false,
+ addEventListener : false,
+ applicationCache : false,
+ blur : false,
+ clearInterval : false,
+ clearTimeout : false,
+ close : false,
+ closed : false,
+ DataView : false,
+ defaultStatus : false,
+ document : false,
+ event : false,
+ FileReader : false,
+ Float32Array : false,
+ Float64Array : false,
+ FormData : false,
+ focus : false,
+ frames : false,
+ getComputedStyle : false,
+ HTMLElement : false,
+ HTMLAnchorElement : false,
+ HTMLBaseElement : false,
+ HTMLBlockquoteElement : false,
+ HTMLBodyElement : false,
+ HTMLBRElement : false,
+ HTMLButtonElement : false,
+ HTMLCanvasElement : false,
+ HTMLDirectoryElement : false,
+ HTMLDivElement : false,
+ HTMLDListElement : false,
+ HTMLFieldSetElement : false,
+ HTMLFontElement : false,
+ HTMLFormElement : false,
+ HTMLFrameElement : false,
+ HTMLFrameSetElement : false,
+ HTMLHeadElement : false,
+ HTMLHeadingElement : false,
+ HTMLHRElement : false,
+ HTMLHtmlElement : false,
+ HTMLIFrameElement : false,
+ HTMLImageElement : false,
+ HTMLInputElement : false,
+ HTMLIsIndexElement : false,
+ HTMLLabelElement : false,
+ HTMLLayerElement : false,
+ HTMLLegendElement : false,
+ HTMLLIElement : false,
+ HTMLLinkElement : false,
+ HTMLMapElement : false,
+ HTMLMenuElement : false,
+ HTMLMetaElement : false,
+ HTMLModElement : false,
+ HTMLObjectElement : false,
+ HTMLOListElement : false,
+ HTMLOptGroupElement : false,
+ HTMLOptionElement : false,
+ HTMLParagraphElement : false,
+ HTMLParamElement : false,
+ HTMLPreElement : false,
+ HTMLQuoteElement : false,
+ HTMLScriptElement : false,
+ HTMLSelectElement : false,
+ HTMLStyleElement : false,
+ HTMLTableCaptionElement : false,
+ HTMLTableCellElement : false,
+ HTMLTableColElement : false,
+ HTMLTableElement : false,
+ HTMLTableRowElement : false,
+ HTMLTableSectionElement : false,
+ HTMLTextAreaElement : false,
+ HTMLTitleElement : false,
+ HTMLUListElement : false,
+ HTMLVideoElement : false,
+ history : false,
+ Int16Array : false,
+ Int32Array : false,
+ Int8Array : false,
+ Image : false,
+ length : false,
+ localStorage : false,
+ location : false,
+ moveBy : false,
+ moveTo : false,
+ name : false,
+ navigator : false,
+ onbeforeunload : true,
+ onblur : true,
+ onerror : true,
+ onfocus : true,
+ onload : true,
+ onresize : true,
+ onunload : true,
+ open : false,
+ openDatabase : false,
+ opener : false,
+ Option : false,
+ parent : false,
+ print : false,
+ removeEventListener : false,
+ resizeBy : false,
+ resizeTo : false,
+ screen : false,
+ scroll : false,
+ scrollBy : false,
+ scrollTo : false,
+ sessionStorage : false,
+ setInterval : false,
+ setTimeout : false,
+ SharedWorker : false,
+ status : false,
+ top : false,
+ Uint16Array : false,
+ Uint32Array : false,
+ Uint8Array : false,
+ WebSocket : false,
+ window : false,
+ Worker : false,
+ XMLHttpRequest : false,
+ XPathEvaluator : false,
+ XPathException : false,
+ XPathExpression : false,
+ XPathNamespace : false,
+ XPathNSResolver : false,
+ XPathResult : false
+ },
+
+ couch = {
+ "require" : false,
+ respond : false,
+ getRow : false,
+ emit : false,
+ send : false,
+ start : false,
+ sum : false,
+ log : false,
+ exports : false,
+ module : false,
+ provides : false
+ },
+
+ devel = {
+ alert : false,
+ confirm : false,
+ console : false,
+ Debug : false,
+ opera : false,
+ prompt : false
+ },
+
+ dojo = {
+ dojo : false,
+ dijit : false,
+ dojox : false,
+ define : false,
+ "require" : false
+ },
+
+ escapes = {
+ '\b': '\\b',
+ '\t': '\\t',
+ '\n': '\\n',
+ '\f': '\\f',
+ '\r': '\\r',
+ '"' : '\\"',
+ '/' : '\\/',
+ '\\': '\\\\'
+ },
+
+ funct, // The current function
+
+ functionicity = [
+ 'closure', 'exception', 'global', 'label',
+ 'outer', 'unused', 'var'
+ ],
+
+ functions, // All of the functions
+
+ global, // The global scope
+ implied, // Implied globals
+ inblock,
+ indent,
+ jsonmode,
+
+ jquery = {
+ '$' : false,
+ jQuery : false
+ },
+
+ lines,
+ lookahead,
+ member,
+ membersOnly,
+
+ mootools = {
+ '$' : false,
+ '$$' : false,
+ Assets : false,
+ Browser : false,
+ Chain : false,
+ Class : false,
+ Color : false,
+ Cookie : false,
+ Core : false,
+ Document : false,
+ DomReady : false,
+ DOMReady : false,
+ Drag : false,
+ Element : false,
+ Elements : false,
+ Event : false,
+ Events : false,
+ Fx : false,
+ Group : false,
+ Hash : false,
+ HtmlTable : false,
+ Iframe : false,
+ IframeShim : false,
+ InputValidator : false,
+ instanceOf : false,
+ Keyboard : false,
+ Locale : false,
+ Mask : false,
+ MooTools : false,
+ Native : false,
+ Options : false,
+ OverText : false,
+ Request : false,
+ Scroller : false,
+ Slick : false,
+ Slider : false,
+ Sortables : false,
+ Spinner : false,
+ Swiff : false,
+ Tips : false,
+ Type : false,
+ typeOf : false,
+ URI : false,
+ Window : false
+ },
+
+ nexttoken,
+
+ node = {
+ __filename : false,
+ __dirname : false,
+ Buffer : false,
+ console : false,
+ exports : false,
+ GLOBAL : false,
+ global : false,
+ module : false,
+ process : false,
+ require : false,
+ setTimeout : false,
+ clearTimeout : false,
+ setInterval : false,
+ clearInterval : false
+ },
+
+ noreach,
+ option,
+ predefined, // Global variables defined by option
+ prereg,
+ prevtoken,
+
+ prototypejs = {
+ '$' : false,
+ '$$' : false,
+ '$A' : false,
+ '$F' : false,
+ '$H' : false,
+ '$R' : false,
+ '$break' : false,
+ '$continue' : false,
+ '$w' : false,
+ Abstract : false,
+ Ajax : false,
+ Class : false,
+ Enumerable : false,
+ Element : false,
+ Event : false,
+ Field : false,
+ Form : false,
+ Hash : false,
+ Insertion : false,
+ ObjectRange : false,
+ PeriodicalExecuter: false,
+ Position : false,
+ Prototype : false,
+ Selector : false,
+ Template : false,
+ Toggle : false,
+ Try : false,
+ Autocompleter : false,
+ Builder : false,
+ Control : false,
+ Draggable : false,
+ Draggables : false,
+ Droppables : false,
+ Effect : false,
+ Sortable : false,
+ SortableObserver : false,
+ Sound : false,
+ Scriptaculous : false
+ },
+
+ rhino = {
+ defineClass : false,
+ deserialize : false,
+ gc : false,
+ help : false,
+ importPackage: false,
+ "java" : false,
+ load : false,
+ loadClass : false,
+ print : false,
+ quit : false,
+ readFile : false,
+ readUrl : false,
+ runCommand : false,
+ seal : false,
+ serialize : false,
+ spawn : false,
+ sync : false,
+ toint32 : false,
+ version : false
+ },
+
+ scope, // The current scope
+ stack,
+
+ // standard contains the global names that are provided by the
+ // ECMAScript standard.
+ standard = {
+ Array : false,
+ Boolean : false,
+ Date : false,
+ decodeURI : false,
+ decodeURIComponent : false,
+ encodeURI : false,
+ encodeURIComponent : false,
+ Error : false,
+ 'eval' : false,
+ EvalError : false,
+ Function : false,
+ hasOwnProperty : false,
+ isFinite : false,
+ isNaN : false,
+ JSON : false,
+ Math : false,
+ Number : false,
+ Object : false,
+ parseInt : false,
+ parseFloat : false,
+ RangeError : false,
+ ReferenceError : false,
+ RegExp : false,
+ String : false,
+ SyntaxError : false,
+ TypeError : false,
+ URIError : false
+ },
+
+ // widely adopted global names that are not part of ECMAScript standard
+ nonstandard = {
+ escape : false,
+ unescape : false
+ },
+
+ standard_member = {
+ E : true,
+ LN2 : true,
+ LN10 : true,
+ LOG2E : true,
+ LOG10E : true,
+ MAX_VALUE : true,
+ MIN_VALUE : true,
+ NEGATIVE_INFINITY : true,
+ PI : true,
+ POSITIVE_INFINITY : true,
+ SQRT1_2 : true,
+ SQRT2 : true
+ },
+
+ directive,
+ syntax = {},
+ tab,
+ token,
+ urls,
+ useESNextSyntax,
+ warnings,
+
+ wsh = {
+ ActiveXObject : true,
+ Enumerator : true,
+ GetObject : true,
+ ScriptEngine : true,
+ ScriptEngineBuildVersion : true,
+ ScriptEngineMajorVersion : true,
+ ScriptEngineMinorVersion : true,
+ VBArray : true,
+ WSH : true,
+ WScript : true,
+ XDomainRequest : true
+ };
+
+ // Regular expressions. Some of these are stupidly long.
+ var ax, cx, tx, nx, nxg, lx, ix, jx, ft;
+ (function () {
+ /*jshint maxlen:300 */
+
+ // unsafe comment or string
+ ax = /@cc|<\/?|script|\]\s*\]|<\s*!|&lt/i;
+
+ // unsafe characters that are silently deleted by one or more browsers
+ cx = /[\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/;
+
+ // token
+ tx = /^\s*([(){}\[.,:;'"~\?\]#@]|==?=?|\/(\*(jshint|jslint|members?|global)?|=|\/)?|\*[\/=]?|\+(?:=|\++)?|-(?:=|-+)?|%=?|&[&=]?|\|[|=]?|>>?>?=?|<([\/=!]|\!(\[|--)?|<=?)?|\^=?|\!=?=?|[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+([xX][0-9a-fA-F]+|\.[0-9]*)?([eE][+\-]?[0-9]+)?)/;
+
+ // characters in strings that need escapement
+ nx = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/;
+ nxg = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
+
+ // star slash
+ lx = /\*\/|\/\*/;
+
+ // identifier
+ ix = /^([a-zA-Z_$][a-zA-Z0-9_$]*)$/;
+
+ // javascript url
+ jx = /^(?:javascript|jscript|ecmascript|vbscript|mocha|livescript)\s*:/i;
+
+ // catches /* falls through */ comments
+ ft = /^\s*\/\*\s*falls\sthrough\s*\*\/\s*$/;
+ }());
+
+ function F() {} // Used by Object.create
+
+ function is_own(object, name) {
+
+// The object.hasOwnProperty method fails when the property under consideration
+// is named 'hasOwnProperty'. So we have to use this more convoluted form.
+
+ return Object.prototype.hasOwnProperty.call(object, name);
+ }
+
+// Provide critical ES5 functions to ES3.
+
+ if (typeof Array.isArray !== 'function') {
+ Array.isArray = function (o) {
+ return Object.prototype.toString.apply(o) === '[object Array]';
+ };
+ }
+
+ if (typeof Object.create !== 'function') {
+ Object.create = function (o) {
+ F.prototype = o;
+ return new F();
+ };
+ }
+
+ if (typeof Object.keys !== 'function') {
+ Object.keys = function (o) {
+ var a = [], k;
+ for (k in o) {
+ if (is_own(o, k)) {
+ a.push(k);
+ }
+ }
+ return a;
+ };
+ }
+
+// Non standard methods
+
+ if (typeof String.prototype.entityify !== 'function') {
+ String.prototype.entityify = function () {
+ return this
+ .replace(/&/g, '&amp;')
+ .replace(/</g, '&lt;')
+ .replace(/>/g, '&gt;');
+ };
+ }
+
+ if (typeof String.prototype.isAlpha !== 'function') {
+ String.prototype.isAlpha = function () {
+ return (this >= 'a' && this <= 'z\uffff') ||
+ (this >= 'A' && this <= 'Z\uffff');
+ };
+ }
+
+ if (typeof String.prototype.isDigit !== 'function') {
+ String.prototype.isDigit = function () {
+ return (this >= '0' && this <= '9');
+ };
+ }
+
+ if (typeof String.prototype.supplant !== 'function') {
+ String.prototype.supplant = function (o) {
+ return this.replace(/\{([^{}]*)\}/g, function (a, b) {
+ var r = o[b];
+ return typeof r === 'string' || typeof r === 'number' ? r : a;
+ });
+ };
+ }
+
+ if (typeof String.prototype.name !== 'function') {
+ String.prototype.name = function () {
+
+// If the string looks like an identifier, then we can return it as is.
+// If the string contains no control characters, no quote characters, and no
+// backslash characters, then we can simply slap some quotes around it.
+// Otherwise we must also replace the offending characters with safe
+// sequences.
+
+ if (ix.test(this)) {
+ return this;
+ }
+ if (nx.test(this)) {
+ return '"' + this.replace(nxg, function (a) {
+ var c = escapes[a];
+ if (c) {
+ return c;
+ }
+ return '\\u' + ('0000' + a.charCodeAt().toString(16)).slice(-4);
+ }) + '"';
+ }
+ return '"' + this + '"';
+ };
+ }
+
+
+ function combine(t, o) {
+ var n;
+ for (n in o) {
+ if (is_own(o, n)) {
+ t[n] = o[n];
+ }
+ }
+ }
+
+ function assume() {
+ if (option.couch) {
+ combine(predefined, couch);
+ }
+
+ if (option.rhino) {
+ combine(predefined, rhino);
+ }
+
+ if (option.prototypejs) {
+ combine(predefined, prototypejs);
+ }
+
+ if (option.node) {
+ combine(predefined, node);
+ }
+
+ if (option.devel) {
+ combine(predefined, devel);
+ }
+
+ if (option.dojo) {
+ combine(predefined, dojo);
+ }
+
+ if (option.browser) {
+ combine(predefined, browser);
+ }
+
+ if (option.nonstandard) {
+ combine(predefined, nonstandard);
+ }
+
+ if (option.jquery) {
+ combine(predefined, jquery);
+ }
+
+ if (option.mootools) {
+ combine(predefined, mootools);
+ }
+
+ if (option.wsh) {
+ combine(predefined, wsh);
+ }
+
+ if (option.esnext) {
+ useESNextSyntax();
+ }
+
+ if (option.globalstrict && option.strict !== false) {
+ option.strict = true;
+ }
+ }
+
+
+ // Produce an error warning.
+ function quit(message, line, chr) {
+ var percentage = Math.floor((line / lines.length) * 100);
+
+ throw {
+ name: 'JSHintError',
+ line: line,
+ character: chr,
+ message: message + " (" + percentage + "% scanned).",
+ raw: message
+ };
+ }
+
+ function isundef(scope, m, t, a) {
+ return JSHINT.undefs.push([scope, m, t, a]);
+ }
+
+ function warning(m, t, a, b, c, d) {
+ var ch, l, w;
+ t = t || nexttoken;
+ if (t.id === '(end)') { // `~
+ t = token;
+ }
+ l = t.line || 0;
+ ch = t.from || 0;
+ w = {
+ id: '(error)',
+ raw: m,
+ evidence: lines[l - 1] || '',
+ line: l,
+ character: ch,
+ a: a,
+ b: b,
+ c: c,
+ d: d
+ };
+ w.reason = m.supplant(w);
+ JSHINT.errors.push(w);
+ if (option.passfail) {
+ quit('Stopping. ', l, ch);
+ }
+ warnings += 1;
+ if (warnings >= option.maxerr) {
+ quit("Too many errors.", l, ch);
+ }
+ return w;
+ }
+
+ function warningAt(m, l, ch, a, b, c, d) {
+ return warning(m, {
+ line: l,
+ from: ch
+ }, a, b, c, d);
+ }
+
+ function error(m, t, a, b, c, d) {
+ var w = warning(m, t, a, b, c, d);
+ }
+
+ function errorAt(m, l, ch, a, b, c, d) {
+ return error(m, {
+ line: l,
+ from: ch
+ }, a, b, c, d);
+ }
+
+
+
+// lexical analysis and token construction
+
+ var lex = (function lex() {
+ var character, from, line, s;
+
+// Private lex methods
+
+ function nextLine() {
+ var at,
+ tw; // trailing whitespace check
+
+ if (line >= lines.length)
+ return false;
+
+ character = 1;
+ s = lines[line];
+ line += 1;
+
+ // If smarttabs option is used check for spaces followed by tabs only.
+ // Otherwise check for any occurence of mixed tabs and spaces.
+ if (option.smarttabs)
+ at = s.search(/ \t/);
+ else
+ at = s.search(/ \t|\t /);
+
+ if (at >= 0)
+ warningAt("Mixed spaces and tabs.", line, at + 1);
+
+ s = s.replace(/\t/g, tab);
+ at = s.search(cx);
+
+ if (at >= 0)
+ warningAt("Unsafe character.", line, at);
+
+ if (option.maxlen && option.maxlen < s.length)
+ warningAt("Line too long.", line, s.length);
+
+ // Check for trailing whitespaces
+ tw = /\s+$/.test(s);
+ if (option.trailing && tw && !/^\s+$/.test(s)) {
+ warningAt("Trailing whitespace.", line, tw);
+ }
+ return true;
+ }
+
+// Produce a token object. The token inherits from a syntax symbol.
+
+ function it(type, value) {
+ var i, t;
+ if (type === '(color)' || type === '(range)') {
+ t = {type: type};
+ } else if (type === '(punctuator)' ||
+ (type === '(identifier)' && is_own(syntax, value))) {
+ t = syntax[value] || syntax['(error)'];
+ } else {
+ t = syntax[type];
+ }
+ t = Object.create(t);
+ if (type === '(string)' || type === '(range)') {
+ if (!option.scripturl && jx.test(value)) {
+ warningAt("Script URL.", line, from);
+ }
+ }
+ if (type === '(identifier)') {
+ t.identifier = true;
+ if (value === '__proto__' && !option.proto) {
+ warningAt("The '{a}' property is deprecated.",
+ line, from, value);
+ } else if (value === '__iterator__' && !option.iterator) {
+ warningAt("'{a}' is only available in JavaScript 1.7.",
+ line, from, value);
+ } else if (option.nomen && (value.charAt(0) === '_' ||
+ value.charAt(value.length - 1) === '_')) {
+ if (!option.node || token.id === '.' ||
+ (value !== '__dirname' && value !== '__filename')) {
+ warningAt("Unexpected {a} in '{b}'.", line, from, "dangling '_'", value);
+ }
+ }
+ }
+ t.value = value;
+ t.line = line;
+ t.character = character;
+ t.from = from;
+ i = t.id;
+ if (i !== '(endline)') {
+ prereg = i &&
+ (('(,=:[!&|?{};'.indexOf(i.charAt(i.length - 1)) >= 0) ||
+ i === 'return' ||
+ i === 'case');
+ }
+ return t;
+ }
+
+ // Public lex methods
+ return {
+ init: function (source) {
+ if (typeof source === 'string') {
+ lines = source
+ .replace(/\r\n/g, '\n')
+ .replace(/\r/g, '\n')
+ .split('\n');
+ } else {
+ lines = source;
+ }
+
+ // If the first line is a shebang (#!), make it a blank and move on.
+ // Shebangs are used by Node scripts.
+ if (lines[0] && lines[0].substr(0, 2) === '#!')
+ lines[0] = '';
+
+ line = 0;
+ nextLine();
+ from = 1;
+ },
+
+ range: function (begin, end) {
+ var c, value = '';
+ from = character;
+ if (s.charAt(0) !== begin) {
+ errorAt("Expected '{a}' and instead saw '{b}'.",
+ line, character, begin, s.charAt(0));
+ }
+ for (;;) {
+ s = s.slice(1);
+ character += 1;
+ c = s.charAt(0);
+ switch (c) {
+ case '':
+ errorAt("Missing '{a}'.", line, character, c);
+ break;
+ case end:
+ s = s.slice(1);
+ character += 1;
+ return it('(range)', value);
+ case '\\':
+ warningAt("Unexpected '{a}'.", line, character, c);
+ }
+ value += c;
+ }
+
+ },
+
+
+ // token -- this is called by advance to get the next token
+ token: function () {
+ var b, c, captures, d, depth, high, i, l, low, q, t, isLiteral, isInRange;
+
+ function match(x) {
+ var r = x.exec(s), r1;
+ if (r) {
+ l = r[0].length;
+ r1 = r[1];
+ c = r1.charAt(0);
+ s = s.substr(l);
+ from = character + l - r1.length;
+ character += l;
+ return r1;
+ }
+ }
+
+ function string(x) {
+ var c, j, r = '', allowNewLine = false;
+
+ if (jsonmode && x !== '"') {
+ warningAt("Strings must use doublequote.",
+ line, character);
+ }
+
+ function esc(n) {
+ var i = parseInt(s.substr(j + 1, n), 16);
+ j += n;
+ if (i >= 32 && i <= 126 &&
+ i !== 34 && i !== 92 && i !== 39) {
+ warningAt("Unnecessary escapement.", line, character);
+ }
+ character += n;
+ c = String.fromCharCode(i);
+ }
+ j = 0;
+unclosedString: for (;;) {
+ while (j >= s.length) {
+ j = 0;
+
+ var cl = line, cf = from;
+ if (!nextLine()) {
+ errorAt("Unclosed string.", cl, cf);
+ break unclosedString;
+ }
+
+ if (allowNewLine) {
+ allowNewLine = false;
+ } else {
+ warningAt("Unclosed string.", cl, cf);
+ }
+ }
+ c = s.charAt(j);
+ if (c === x) {
+ character += 1;
+ s = s.substr(j + 1);
+ return it('(string)', r, x);
+ }
+ if (c < ' ') {
+ if (c === '\n' || c === '\r') {
+ break;
+ }
+ warningAt("Control character in string: {a}.",
+ line, character + j, s.slice(0, j));
+ } else if (c === '\\') {
+ j += 1;
+ character += 1;
+ c = s.charAt(j);
+ switch (c) {
+ case '\\':
+ case '"':
+ case '/':
+ break;
+ case '\'':
+ if (jsonmode) {
+ warningAt("Avoid \\'.", line, character);
+ }
+ break;
+ case 'b':
+ c = '\b';
+ break;
+ case 'f':
+ c = '\f';
+ break;
+ case 'n':
+ c = '\n';
+ break;
+ case 'r':
+ c = '\r';
+ break;
+ case 't':
+ c = '\t';
+ break;
+ case 'u':
+ esc(4);
+ break;
+ case 'v':
+ if (jsonmode) {
+ warningAt("Avoid \\v.", line, character);
+ }
+ c = '\v';
+ break;
+ case 'x':
+ if (jsonmode) {
+ warningAt("Avoid \\x-.", line, character);
+ }
+ esc(2);
+ break;
+ case '':
+ // last character is escape character
+ // always allow new line if escaped, but show
+ // warning if option is not set
+ allowNewLine = true;
+ if (option.multistr) {
+ if (jsonmode) {
+ warningAt("Avoid EOL escapement.", line, character);
+ }
+ c = '';
+ character -= 1;
+ break;
+ }
+ warningAt("Bad escapement of EOL. Use option multistr if needed.",
+ line, character);
+ break;
+ default:
+ warningAt("Bad escapement.", line, character);
+ }
+ }
+ r += c;
+ character += 1;
+ j += 1;
+ }
+ }
+
+ for (;;) {
+ if (!s) {
+ return it(nextLine() ? '(endline)' : '(end)', '');
+ }
+ t = match(tx);
+ if (!t) {
+ t = '';
+ c = '';
+ while (s && s < '!') {
+ s = s.substr(1);
+ }
+ if (s) {
+ errorAt("Unexpected '{a}'.", line, character, s.substr(0, 1));
+ s = '';
+ }
+ } else {
+
+ // identifier
+
+ if (c.isAlpha() || c === '_' || c === '$') {
+ return it('(identifier)', t);
+ }
+
+ // number
+
+ if (c.isDigit()) {
+ if (!isFinite(Number(t))) {
+ warningAt("Bad number '{a}'.",
+ line, character, t);
+ }
+ if (s.substr(0, 1).isAlpha()) {
+ warningAt("Missing space after '{a}'.",
+ line, character, t);
+ }
+ if (c === '0') {
+ d = t.substr(1, 1);
+ if (d.isDigit()) {
+ if (token.id !== '.') {
+ warningAt("Don't use extra leading zeros '{a}'.",
+ line, character, t);
+ }
+ } else if (jsonmode && (d === 'x' || d === 'X')) {
+ warningAt("Avoid 0x-. '{a}'.",
+ line, character, t);
+ }
+ }
+ if (t.substr(t.length - 1) === '.') {
+ warningAt(
+"A trailing decimal point can be confused with a dot '{a}'.", line, character, t);
+ }
+ return it('(number)', t);
+ }
+ switch (t) {
+
+ // string
+
+ case '"':
+ case "'":
+ return string(t);
+
+ // // comment
+
+ case '//':
+ s = '';
+ token.comment = true;
+ break;
+
+ // /* comment
+
+ case '/*':
+ for (;;) {
+ i = s.search(lx);
+ if (i >= 0) {
+ break;
+ }
+ if (!nextLine()) {
+ errorAt("Unclosed comment.", line, character);
+ }
+ }
+ character += i + 2;
+ if (s.substr(i, 1) === '/') {
+ errorAt("Nested comment.", line, character);
+ }
+ s = s.substr(i + 2);
+ token.comment = true;
+ break;
+
+ // /*members /*jshint /*global
+
+ case '/*members':
+ case '/*member':
+ case '/*jshint':
+ case '/*jslint':
+ case '/*global':
+ case '*/':
+ return {
+ value: t,
+ type: 'special',
+ line: line,
+ character: character,
+ from: from
+ };
+
+ case '':
+ break;
+ // /
+ case '/':
+ if (token.id === '/=') {
+ errorAt("A regular expression literal can be confused with '/='.",
+ line, from);
+ }
+ if (prereg) {
+ depth = 0;
+ captures = 0;
+ l = 0;
+ for (;;) {
+ b = true;
+ c = s.charAt(l);
+ l += 1;
+ switch (c) {
+ case '':
+ errorAt("Unclosed regular expression.", line, from);
+ return quit('Stopping.', line, from);
+ case '/':
+ if (depth > 0) {
+ warningAt("{a} unterminated regular expression " +
+ "group(s).", line, from + l, depth);
+ }
+ c = s.substr(0, l - 1);
+ q = {
+ g: true,
+ i: true,
+ m: true
+ };
+ while (q[s.charAt(l)] === true) {
+ q[s.charAt(l)] = false;
+ l += 1;
+ }
+ character += l;
+ s = s.substr(l);
+ q = s.charAt(0);
+ if (q === '/' || q === '*') {
+ errorAt("Confusing regular expression.",
+ line, from);
+ }
+ return it('(regexp)', c);
+ case '\\':
+ c = s.charAt(l);
+ if (c < ' ') {
+ warningAt(
+"Unexpected control character in regular expression.", line, from + l);
+ } else if (c === '<') {
+ warningAt(
+"Unexpected escaped character '{a}' in regular expression.", line, from + l, c);
+ }
+ l += 1;
+ break;
+ case '(':
+ depth += 1;
+ b = false;
+ if (s.charAt(l) === '?') {
+ l += 1;
+ switch (s.charAt(l)) {
+ case ':':
+ case '=':
+ case '!':
+ l += 1;
+ break;
+ default:
+ warningAt(
+"Expected '{a}' and instead saw '{b}'.", line, from + l, ':', s.charAt(l));
+ }
+ } else {
+ captures += 1;
+ }
+ break;
+ case '|':
+ b = false;
+ break;
+ case ')':
+ if (depth === 0) {
+ warningAt("Unescaped '{a}'.",
+ line, from + l, ')');
+ } else {
+ depth -= 1;
+ }
+ break;
+ case ' ':
+ q = 1;
+ while (s.charAt(l) === ' ') {
+ l += 1;
+ q += 1;
+ }
+ if (q > 1) {
+ warningAt(
+"Spaces are hard to count. Use {{a}}.", line, from + l, q);
+ }
+ break;
+ case '[':
+ c = s.charAt(l);
+ if (c === '^') {
+ l += 1;
+ if (option.regexp) {
+ warningAt("Insecure '{a}'.",
+ line, from + l, c);
+ } else if (s.charAt(l) === ']') {
+ errorAt("Unescaped '{a}'.",
+ line, from + l, '^');
+ }
+ }
+ if (c === ']') {
+ warningAt("Empty class.", line,
+ from + l - 1);
+ }
+ isLiteral = false;
+ isInRange = false;
+klass: do {
+ c = s.charAt(l);
+ l += 1;
+ switch (c) {
+ case '[':
+ case '^':
+ warningAt("Unescaped '{a}'.",
+ line, from + l, c);
+ if (isInRange) {
+ isInRange = false;
+ } else {
+ isLiteral = true;
+ }
+ break;
+ case '-':
+ if (isLiteral && !isInRange) {
+ isLiteral = false;
+ isInRange = true;
+ } else if (isInRange) {
+ isInRange = false;
+ } else if (s.charAt(l) === ']') {
+ isInRange = true;
+ } else {
+ if (option.regexdash !== (l === 2 || (l === 3 &&
+ s.charAt(1) === '^'))) {
+ warningAt("Unescaped '{a}'.",
+ line, from + l - 1, '-');
+ }
+ isLiteral = true;
+ }
+ break;
+ case ']':
+ if (isInRange && !option.regexdash) {
+ warningAt("Unescaped '{a}'.",
+ line, from + l - 1, '-');
+ }
+ break klass;
+ case '\\':
+ c = s.charAt(l);
+ if (c < ' ') {
+ warningAt(
+"Unexpected control character in regular expression.", line, from + l);
+ } else if (c === '<') {
+ warningAt(
+"Unexpected escaped character '{a}' in regular expression.", line, from + l, c);
+ }
+ l += 1;
+
+ // \w, \s and \d are never part of a character range
+ if (/[wsd]/i.test(c)) {
+ if (isInRange) {
+ warningAt("Unescaped '{a}'.",
+ line, from + l, '-');
+ isInRange = false;
+ }
+ isLiteral = false;
+ } else if (isInRange) {
+ isInRange = false;
+ } else {
+ isLiteral = true;
+ }
+ break;
+ case '/':
+ warningAt("Unescaped '{a}'.",
+ line, from + l - 1, '/');
+
+ if (isInRange) {
+ isInRange = false;
+ } else {
+ isLiteral = true;
+ }
+ break;
+ case '<':
+ if (isInRange) {
+ isInRange = false;
+ } else {
+ isLiteral = true;
+ }
+ break;
+ default:
+ if (isInRange) {
+ isInRange = false;
+ } else {
+ isLiteral = true;
+ }
+ }
+ } while (c);
+ break;
+ case '.':
+ if (option.regexp) {
+ warningAt("Insecure '{a}'.", line,
+ from + l, c);
+ }
+ break;
+ case ']':
+ case '?':
+ case '{':
+ case '}':
+ case '+':
+ case '*':
+ warningAt("Unescaped '{a}'.", line,
+ from + l, c);
+ }
+ if (b) {
+ switch (s.charAt(l)) {
+ case '?':
+ case '+':
+ case '*':
+ l += 1;
+ if (s.charAt(l) === '?') {
+ l += 1;
+ }
+ break;
+ case '{':
+ l += 1;
+ c = s.charAt(l);
+ if (c < '0' || c > '9') {
+ warningAt(
+"Expected a number and instead saw '{a}'.", line, from + l, c);
+ }
+ l += 1;
+ low = +c;
+ for (;;) {
+ c = s.charAt(l);
+ if (c < '0' || c > '9') {
+ break;
+ }
+ l += 1;
+ low = +c + (low * 10);
+ }
+ high = low;
+ if (c === ',') {
+ l += 1;
+ high = Infinity;
+ c = s.charAt(l);
+ if (c >= '0' && c <= '9') {
+ l += 1;
+ high = +c;
+ for (;;) {
+ c = s.charAt(l);
+ if (c < '0' || c > '9') {
+ break;
+ }
+ l += 1;
+ high = +c + (high * 10);
+ }
+ }
+ }
+ if (s.charAt(l) !== '}') {
+ warningAt(
+"Expected '{a}' and instead saw '{b}'.", line, from + l, '}', c);
+ } else {
+ l += 1;
+ }
+ if (s.charAt(l) === '?') {
+ l += 1;
+ }
+ if (low > high) {
+ warningAt(
+"'{a}' should not be greater than '{b}'.", line, from + l, low, high);
+ }
+ }
+ }
+ }
+ c = s.substr(0, l - 1);
+ character += l;
+ s = s.substr(l);
+ return it('(regexp)', c);
+ }
+ return it('(punctuator)', t);
+
+ // punctuator
+
+ case '#':
+ return it('(punctuator)', t);
+ default:
+ return it('(punctuator)', t);
+ }
+ }
+ }
+ }
+ };
+ }());
+
+
+ function addlabel(t, type) {
+
+ if (t === 'hasOwnProperty') {
+ warning("'hasOwnProperty' is a really bad name.");
+ }
+
+// Define t in the current function in the current scope.
+ if (is_own(funct, t) && !funct['(global)']) {
+ if (funct[t] === true) {
+ if (option.latedef)
+ warning("'{a}' was used before it was defined.", nexttoken, t);
+ } else {
+ if (!option.shadow && type !== "exception")
+ warning("'{a}' is already defined.", nexttoken, t);
+ }
+ }
+
+ funct[t] = type;
+ if (funct['(global)']) {
+ global[t] = funct;
+ if (is_own(implied, t)) {
+ if (option.latedef)
+ warning("'{a}' was used before it was defined.", nexttoken, t);
+ delete implied[t];
+ }
+ } else {
+ scope[t] = funct;
+ }
+ }
+
+
+ function doOption() {
+ var b, obj, filter, o = nexttoken.value, t, v;
+ switch (o) {
+ case '*/':
+ error("Unbegun comment.");
+ break;
+ case '/*members':
+ case '/*member':
+ o = '/*members';
+ if (!membersOnly) {
+ membersOnly = {};
+ }
+ obj = membersOnly;
+ break;
+ case '/*jshint':
+ case '/*jslint':
+ obj = option;
+ filter = boolOptions;
+ break;
+ case '/*global':
+ obj = predefined;
+ break;
+ default:
+ error("What?");
+ }
+ t = lex.token();
+loop: for (;;) {
+ for (;;) {
+ if (t.type === 'special' && t.value === '*/') {
+ break loop;
+ }
+ if (t.id !== '(endline)' && t.id !== ',') {
+ break;
+ }
+ t = lex.token();
+ }
+ if (t.type !== '(string)' && t.type !== '(identifier)' &&
+ o !== '/*members') {
+ error("Bad option.", t);
+ }
+ v = lex.token();
+ if (v.id === ':') {
+ v = lex.token();
+ if (obj === membersOnly) {
+ error("Expected '{a}' and instead saw '{b}'.",
+ t, '*/', ':');
+ }
+ if (t.value === 'indent' && (o === '/*jshint' || o === '/*jslint')) {
+ b = +v.value;
+ if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
+ Math.floor(b) !== b) {
+ error("Expected a small integer and instead saw '{a}'.",
+ v, v.value);
+ }
+ obj.white = true;
+ obj.indent = b;
+ } else if (t.value === 'maxerr' && (o === '/*jshint' || o === '/*jslint')) {
+ b = +v.value;
+ if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
+ Math.floor(b) !== b) {
+ error("Expected a small integer and instead saw '{a}'.",
+ v, v.value);
+ }
+ obj.maxerr = b;
+ } else if (t.value === 'maxlen' && (o === '/*jshint' || o === '/*jslint')) {
+ b = +v.value;
+ if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
+ Math.floor(b) !== b) {
+ error("Expected a small integer and instead saw '{a}'.",
+ v, v.value);
+ }
+ obj.maxlen = b;
+ } else if (t.value === 'validthis') {
+ if (funct['(global)']) {
+ error("Option 'validthis' can't be used in a global scope.");
+ } else {
+ if (v.value === 'true' || v.value === 'false')
+ obj[t.value] = v.value === 'true';
+ else
+ error("Bad option value.", v);
+ }
+ } else if (v.value === 'true') {
+ obj[t.value] = true;
+ } else if (v.value === 'false') {
+ obj[t.value] = false;
+ } else {
+ error("Bad option value.", v);
+ }
+ t = lex.token();
+ } else {
+ if (o === '/*jshint' || o === '/*jslint') {
+ error("Missing option value.", t);
+ }
+ obj[t.value] = false;
+ t = v;
+ }
+ }
+ if (filter) {
+ assume();
+ }
+ }
+
+
+// We need a peek function. If it has an argument, it peeks that much farther
+// ahead. It is used to distinguish
+// for ( var i in ...
+// from
+// for ( var i = ...
+
+ function peek(p) {
+ var i = p || 0, j = 0, t;
+
+ while (j <= i) {
+ t = lookahead[j];
+ if (!t) {
+ t = lookahead[j] = lex.token();
+ }
+ j += 1;
+ }
+ return t;
+ }
+
+
+
+// Produce the next token. It looks for programming errors.
+
+ function advance(id, t) {
+ switch (token.id) {
+ case '(number)':
+ if (nexttoken.id === '.') {
+ warning("A dot following a number can be confused with a decimal point.", token);
+ }
+ break;
+ case '-':
+ if (nexttoken.id === '-' || nexttoken.id === '--') {
+ warning("Confusing minusses.");
+ }
+ break;
+ case '+':
+ if (nexttoken.id === '+' || nexttoken.id === '++') {
+ warning("Confusing plusses.");
+ }
+ break;
+ }
+
+ if (token.type === '(string)' || token.identifier) {
+ anonname = token.value;
+ }
+
+ if (id && nexttoken.id !== id) {
+ if (t) {
+ if (nexttoken.id === '(end)') {
+ warning("Unmatched '{a}'.", t, t.id);
+ } else {
+ warning("Expected '{a}' to match '{b}' from line {c} and instead saw '{d}'.",
+ nexttoken, id, t.id, t.line, nexttoken.value);
+ }
+ } else if (nexttoken.type !== '(identifier)' ||
+ nexttoken.value !== id) {
+ warning("Expected '{a}' and instead saw '{b}'.",
+ nexttoken, id, nexttoken.value);
+ }
+ }
+
+ prevtoken = token;
+ token = nexttoken;
+ for (;;) {
+ nexttoken = lookahead.shift() || lex.token();
+ if (nexttoken.id === '(end)' || nexttoken.id === '(error)') {
+ return;
+ }
+ if (nexttoken.type === 'special') {
+ doOption();
+ } else {
+ if (nexttoken.id !== '(endline)') {
+ break;
+ }
+ }
+ }
+ }
+
+
+// This is the heart of JSHINT, the Pratt parser. In addition to parsing, it
+// is looking for ad hoc lint patterns. We add .fud to Pratt's model, which is
+// like .nud except that it is only used on the first token of a statement.
+// Having .fud makes it much easier to define statement-oriented languages like
+// JavaScript. I retained Pratt's nomenclature.
+
+// .nud Null denotation
+// .fud First null denotation
+// .led Left denotation
+// lbp Left binding power
+// rbp Right binding power
+
+// They are elements of the parsing method called Top Down Operator Precedence.
+
+ function expression(rbp, initial) {
+ var left, isArray = false;
+
+ if (nexttoken.id === '(end)')
+ error("Unexpected early end of program.", token);
+
+ advance();
+ if (initial) {
+ anonname = 'anonymous';
+ funct['(verb)'] = token.value;
+ }
+ if (initial === true && token.fud) {
+ left = token.fud();
+ } else {
+ if (token.nud) {
+ left = token.nud();
+ } else {
+ if (nexttoken.type === '(number)' && token.id === '.') {
+ warning("A leading decimal point can be confused with a dot: '.{a}'.",
+ token, nexttoken.value);
+ advance();
+ return token;
+ } else {
+ error("Expected an identifier and instead saw '{a}'.",
+ token, token.id);
+ }
+ }
+ while (rbp < nexttoken.lbp) {
+ isArray = token.value === 'Array';
+ advance();
+ if (isArray && token.id === '(' && nexttoken.id === ')')
+ warning("Use the array literal notation [].", token);
+ if (token.led) {
+ left = token.led(left);
+ } else {
+ error("Expected an operator and instead saw '{a}'.",
+ token, token.id);
+ }
+ }
+ }
+ return left;
+ }
+
+
+// Functions for conformance of style.
+
+ function adjacent(left, right) {
+ left = left || token;
+ right = right || nexttoken;
+ if (option.white) {
+ if (left.character !== right.from && left.line === right.line) {
+ left.from += (left.character - left.from);
+ warning("Unexpected space after '{a}'.", left, left.value);
+ }
+ }
+ }
+
+ function nobreak(left, right) {
+ left = left || token;
+ right = right || nexttoken;
+ if (option.white && (left.character !== right.from || left.line !== right.line)) {
+ warning("Unexpected space before '{a}'.", right, right.value);
+ }
+ }
+
+ function nospace(left, right) {
+ left = left || token;
+ right = right || nexttoken;
+ if (option.white && !left.comment) {
+ if (left.line === right.line) {
+ adjacent(left, right);
+ }
+ }
+ }
+
+ function nonadjacent(left, right) {
+ if (option.white) {
+ left = left || token;
+ right = right || nexttoken;
+ if (left.line === right.line && left.character === right.from) {
+ left.from += (left.character - left.from);
+ warning("Missing space after '{a}'.",
+ left, left.value);
+ }
+ }
+ }
+
+ function nobreaknonadjacent(left, right) {
+ left = left || token;
+ right = right || nexttoken;
+ if (!option.laxbreak && left.line !== right.line) {
+ warning("Bad line breaking before '{a}'.", right, right.id);
+ } else if (option.white) {
+ left = left || token;
+ right = right || nexttoken;
+ if (left.character === right.from) {
+ left.from += (left.character - left.from);
+ warning("Missing space after '{a}'.",
+ left, left.value);
+ }
+ }
+ }
+
+ function indentation(bias) {
+ var i;
+ if (option.white && nexttoken.id !== '(end)') {
+ i = indent + (bias || 0);
+ if (nexttoken.from !== i) {
+ warning(
+"Expected '{a}' to have an indentation at {b} instead at {c}.",
+ nexttoken, nexttoken.value, i, nexttoken.from);
+ }
+ }
+ }
+
+ function nolinebreak(t) {
+ t = t || token;
+ if (t.line !== nexttoken.line) {
+ warning("Line breaking error '{a}'.", t, t.value);
+ }
+ }
+
+
+ function comma() {
+ if (token.line !== nexttoken.line) {
+ if (!option.laxcomma) {
+ if (comma.first) {
+ warning("Comma warnings can be turned off with 'laxcomma'");
+ comma.first = false;
+ }
+ warning("Bad line breaking before '{a}'.", token, nexttoken.id);
+ }
+ } else if (!token.comment && token.character !== nexttoken.from && option.white) {
+ token.from += (token.character - token.from);
+ warning("Unexpected space after '{a}'.", token, token.value);
+ }
+ advance(',');
+ nonadjacent(token, nexttoken);
+ }
+
+ comma.first = true;
+
+
+// Functional constructors for making the symbols that will be inherited by
+// tokens.
+
+ function symbol(s, p) {
+ var x = syntax[s];
+ if (!x || typeof x !== 'object') {
+ syntax[s] = x = {
+ id: s,
+ lbp: p,
+ value: s
+ };
+ }
+ return x;
+ }
+
+
+ function delim(s) {
+ return symbol(s, 0);
+ }
+
+
+ function stmt(s, f) {
+ var x = delim(s);
+ x.identifier = x.reserved = true;
+ x.fud = f;
+ return x;
+ }
+
+
+ function blockstmt(s, f) {
+ var x = stmt(s, f);
+ x.block = true;
+ return x;
+ }
+
+
+ function reserveName(x) {
+ var c = x.id.charAt(0);
+ if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
+ x.identifier = x.reserved = true;
+ }
+ return x;
+ }
+
+
+ function prefix(s, f) {
+ var x = symbol(s, 150);
+ reserveName(x);
+ x.nud = (typeof f === 'function') ? f : function () {
+ this.right = expression(150);
+ this.arity = 'unary';
+ if (this.id === '++' || this.id === '--') {
+ if (option.plusplus) {
+ warning("Unexpected use of '{a}'.", this, this.id);
+ } else if ((!this.right.identifier || this.right.reserved) &&
+ this.right.id !== '.' && this.right.id !== '[') {
+ warning("Bad operand.", this);
+ }
+ }
+ return this;
+ };
+ return x;
+ }
+
+
+ function type(s, f) {
+ var x = delim(s);
+ x.type = s;
+ x.nud = f;
+ return x;
+ }
+
+
+ function reserve(s, f) {
+ var x = type(s, f);
+ x.identifier = x.reserved = true;
+ return x;
+ }
+
+
+ function reservevar(s, v) {
+ return reserve(s, function () {
+ if (typeof v === 'function') {
+ v(this);
+ }
+ return this;
+ });
+ }
+
+
+ function infix(s, f, p, w) {
+ var x = symbol(s, p);
+ reserveName(x);
+ x.led = function (left) {
+ if (!w) {
+ nobreaknonadjacent(prevtoken, token);
+ nonadjacent(token, nexttoken);
+ }
+ if (s === "in" && left.id === "!") {
+ warning("Confusing use of '{a}'.", left, '!');
+ }
+ if (typeof f === 'function') {
+ return f(left, this);
+ } else {
+ this.left = left;
+ this.right = expression(p);
+ return this;
+ }
+ };
+ return x;
+ }
+
+
+ function relation(s, f) {
+ var x = symbol(s, 100);
+ x.led = function (left) {
+ nobreaknonadjacent(prevtoken, token);
+ nonadjacent(token, nexttoken);
+ var right = expression(100);
+ if ((left && left.id === 'NaN') || (right && right.id === 'NaN')) {
+ warning("Use the isNaN function to compare with NaN.", this);
+ } else if (f) {
+ f.apply(this, [left, right]);
+ }
+ if (left.id === '!') {
+ warning("Confusing use of '{a}'.", left, '!');
+ }
+ if (right.id === '!') {
+ warning("Confusing use of '{a}'.", right, '!');
+ }
+ this.left = left;
+ this.right = right;
+ return this;
+ };
+ return x;
+ }
+
+
+ function isPoorRelation(node) {
+ return node &&
+ ((node.type === '(number)' && +node.value === 0) ||
+ (node.type === '(string)' && node.value === '') ||
+ (node.type === 'null' && !option.eqnull) ||
+ node.type === 'true' ||
+ node.type === 'false' ||
+ node.type === 'undefined');
+ }
+
+
+ function assignop(s, f) {
+ symbol(s, 20).exps = true;
+ return infix(s, function (left, that) {
+ var l;
+ that.left = left;
+ if (predefined[left.value] === false &&
+ scope[left.value]['(global)'] === true) {
+ warning("Read only.", left);
+ } else if (left['function']) {
+ warning("'{a}' is a function.", left, left.value);
+ }
+ if (left) {
+ if (option.esnext && funct[left.value] === 'const') {
+ warning("Attempting to override '{a}' which is a constant", left, left.value);
+ }
+ if (left.id === '.' || left.id === '[') {
+ if (!left.left || left.left.value === 'arguments') {
+ warning('Bad assignment.', that);
+ }
+ that.right = expression(19);
+ return that;
+ } else if (left.identifier && !left.reserved) {
+ if (funct[left.value] === 'exception') {
+ warning("Do not assign to the exception parameter.", left);
+ }
+ that.right = expression(19);
+ return that;
+ }
+ if (left === syntax['function']) {
+ warning(
+"Expected an identifier in an assignment and instead saw a function invocation.",
+ token);
+ }
+ }
+ error("Bad assignment.", that);
+ }, 20);
+ }
+
+
+ function bitwise(s, f, p) {
+ var x = symbol(s, p);
+ reserveName(x);
+ x.led = (typeof f === 'function') ? f : function (left) {
+ if (option.bitwise) {
+ warning("Unexpected use of '{a}'.", this, this.id);
+ }
+ this.left = left;
+ this.right = expression(p);
+ return this;
+ };
+ return x;
+ }
+
+
+ function bitwiseassignop(s) {
+ symbol(s, 20).exps = true;
+ return infix(s, function (left, that) {
+ if (option.bitwise) {
+ warning("Unexpected use of '{a}'.", that, that.id);
+ }
+ nonadjacent(prevtoken, token);
+ nonadjacent(token, nexttoken);
+ if (left) {
+ if (left.id === '.' || left.id === '[' ||
+ (left.identifier && !left.reserved)) {
+ expression(19);
+ return that;
+ }
+ if (left === syntax['function']) {
+ warning(
+"Expected an identifier in an assignment, and instead saw a function invocation.",
+ token);
+ }
+ return that;
+ }
+ error("Bad assignment.", that);
+ }, 20);
+ }
+
+
+ function suffix(s, f) {
+ var x = symbol(s, 150);
+ x.led = function (left) {
+ if (option.plusplus) {
+ warning("Unexpected use of '{a}'.", this, this.id);
+ } else if ((!left.identifier || left.reserved) &&
+ left.id !== '.' && left.id !== '[') {
+ warning("Bad operand.", this);
+ }
+ this.left = left;
+ return this;
+ };
+ return x;
+ }
+
+
+ // fnparam means that this identifier is being defined as a function
+ // argument (see identifier())
+ function optionalidentifier(fnparam) {
+ if (nexttoken.identifier) {
+ advance();
+ if (token.reserved && !option.es5) {
+ // `undefined` as a function param is a common pattern to protect
+ // against the case when somebody does `undefined = true` and
+ // help with minification. More info: https://gist.github.com/315916
+ if (!fnparam || token.value !== 'undefined') {
+ warning("Expected an identifier and instead saw '{a}' (a reserved word).",
+ token, token.id);
+ }
+ }
+ return token.value;
+ }
+ }
+
+ // fnparam means that this identifier is being defined as a function
+ // argument
+ function identifier(fnparam) {
+ var i = optionalidentifier(fnparam);
+ if (i) {
+ return i;
+ }
+ if (token.id === 'function' && nexttoken.id === '(') {
+ warning("Missing name in function declaration.");
+ } else {
+ error("Expected an identifier and instead saw '{a}'.",
+ nexttoken, nexttoken.value);
+ }
+ }
+
+
+ function reachable(s) {
+ var i = 0, t;
+ if (nexttoken.id !== ';' || noreach) {
+ return;
+ }
+ for (;;) {
+ t = peek(i);
+ if (t.reach) {
+ return;
+ }
+ if (t.id !== '(endline)') {
+ if (t.id === 'function') {
+ if (!option.latedef) {
+ break;
+ }
+ warning(
+"Inner functions should be listed at the top of the outer function.", t);
+ break;
+ }
+ warning("Unreachable '{a}' after '{b}'.", t, t.value, s);
+ break;
+ }
+ i += 1;
+ }
+ }
+
+
+ function statement(noindent) {
+ var i = indent, r, s = scope, t = nexttoken;
+
+ if (t.id === ";") {
+ advance(";");
+ return;
+ }
+
+// Is this a labelled statement?
+
+ if (t.identifier && !t.reserved && peek().id === ':') {
+ advance();
+ advance(':');
+ scope = Object.create(s);
+ addlabel(t.value, 'label');
+ if (!nexttoken.labelled) {
+ warning("Label '{a}' on {b} statement.",
+ nexttoken, t.value, nexttoken.value);
+ }
+ if (jx.test(t.value + ':')) {
+ warning("Label '{a}' looks like a javascript url.",
+ t, t.value);
+ }
+ nexttoken.label = t.value;
+ t = nexttoken;
+ }
+
+// Parse the statement.
+
+ if (!noindent) {
+ indentation();
+ }
+ r = expression(0, true);
+
+ // Look for the final semicolon.
+ if (!t.block) {
+ if (!option.expr && (!r || !r.exps)) {
+ warning("Expected an assignment or function call and instead saw an expression.",
+ token);
+ } else if (option.nonew && r.id === '(' && r.left.id === 'new') {
+ warning("Do not use 'new' for side effects.");
+ }
+
+ if (nexttoken.id !== ';') {
+ if (!option.asi) {
+ // If this is the last statement in a block that ends on
+ // the same line *and* option lastsemic is on, ignore the warning.
+ // Otherwise, complain about missing semicolon.
+ if (!option.lastsemic || nexttoken.id !== '}' ||
+ nexttoken.line !== token.line) {
+ warningAt("Missing semicolon.", token.line, token.character);
+ }
+ }
+ } else {
+ adjacent(token, nexttoken);
+ advance(';');
+ nonadjacent(token, nexttoken);
+ }
+ }
+
+// Restore the indentation.
+
+ indent = i;
+ scope = s;
+ return r;
+ }
+
+
+ function statements(startLine) {
+ var a = [], f, p;
+
+ while (!nexttoken.reach && nexttoken.id !== '(end)') {
+ if (nexttoken.id === ';') {
+ p = peek();
+ if (!p || p.id !== "(") {
+ warning("Unnecessary semicolon.");
+ }
+ advance(';');
+ } else {
+ a.push(statement(startLine === nexttoken.line));
+ }
+ }
+ return a;
+ }
+
+
+ /*
+ * read all directives
+ * recognizes a simple form of asi, but always
+ * warns, if it is used
+ */
+ function directives() {
+ var i, p, pn;
+
+ for (;;) {
+ if (nexttoken.id === "(string)") {
+ p = peek(0);
+ if (p.id === "(endline)") {
+ i = 1;
+ do {
+ pn = peek(i);
+ i = i + 1;
+ } while (pn.id === "(endline)");
+
+ if (pn.id !== ";") {
+ if (pn.id !== "(string)" && pn.id !== "(number)" &&
+ pn.id !== "(regexp)" && pn.identifier !== true &&
+ pn.id !== "}") {
+ break;
+ }
+ warning("Missing semicolon.", nexttoken);
+ } else {
+ p = pn;
+ }
+ } else if (p.id === "}") {
+ // directive with no other statements, warn about missing semicolon
+ warning("Missing semicolon.", p);
+ } else if (p.id !== ";") {
+ break;
+ }
+
+ indentation();
+ advance();
+ if (directive[token.value]) {
+ warning("Unnecessary directive \"{a}\".", token, token.value);
+ }
+
+ if (token.value === "use strict") {
+ option.newcap = true;
+ option.undef = true;
+ }
+
+ // there's no directive negation, so always set to true
+ directive[token.value] = true;
+
+ if (p.id === ";") {
+ advance(";");
+ }
+ continue;
+ }
+ break;
+ }
+ }
+
+
+ /*
+ * Parses a single block. A block is a sequence of statements wrapped in
+ * braces.
+ *
+ * ordinary - true for everything but function bodies and try blocks.
+ * stmt - true if block can be a single statement (e.g. in if/for/while).
+ * isfunc - true if block is a function body
+ */
+ function block(ordinary, stmt, isfunc) {
+ var a,
+ b = inblock,
+ old_indent = indent,
+ m,
+ s = scope,
+ t,
+ line,
+ d;
+
+ inblock = ordinary;
+ if (!ordinary || !option.funcscope) scope = Object.create(scope);
+ nonadjacent(token, nexttoken);
+ t = nexttoken;
+
+ if (nexttoken.id === '{') {
+ advance('{');
+ line = token.line;
+ if (nexttoken.id !== '}') {
+ indent += option.indent;
+ while (!ordinary && nexttoken.from > indent) {
+ indent += option.indent;
+ }
+
+ if (isfunc) {
+ m = {};
+ for (d in directive) {
+ if (is_own(directive, d)) {
+ m[d] = directive[d];
+ }
+ }
+ directives();
+
+ if (option.strict && funct['(context)']['(global)']) {
+ if (!m["use strict"] && !directive["use strict"]) {
+ warning("Missing \"use strict\" statement.");
+ }
+ }
+ }
+
+ a = statements(line);
+
+ if (isfunc) {
+ directive = m;
+ }
+
+ indent -= option.indent;
+ if (line !== nexttoken.line) {
+ indentation();
+ }
+ } else if (line !== nexttoken.line) {
+ indentation();
+ }
+ advance('}', t);
+ indent = old_indent;
+ } else if (!ordinary) {
+ error("Expected '{a}' and instead saw '{b}'.",
+ nexttoken, '{', nexttoken.value);
+ } else {
+ if (!stmt || option.curly)
+ warning("Expected '{a}' and instead saw '{b}'.",
+ nexttoken, '{', nexttoken.value);
+
+ noreach = true;
+ indent += option.indent;
+ // test indentation only if statement is in new line
+ a = [statement(nexttoken.line === token.line)];
+ indent -= option.indent;
+ noreach = false;
+ }
+ funct['(verb)'] = null;
+ if (!ordinary || !option.funcscope) scope = s;
+ inblock = b;
+ if (ordinary && option.noempty && (!a || a.length === 0)) {
+ warning("Empty block.");
+ }
+ return a;
+ }
+
+
+ function countMember(m) {
+ if (membersOnly && typeof membersOnly[m] !== 'boolean') {
+ warning("Unexpected /*member '{a}'.", token, m);
+ }
+ if (typeof member[m] === 'number') {
+ member[m] += 1;
+ } else {
+ member[m] = 1;
+ }
+ }
+
+
+ function note_implied(token) {
+ var name = token.value, line = token.line, a = implied[name];
+ if (typeof a === 'function') {
+ a = false;
+ }
+
+ if (!a) {
+ a = [line];
+ implied[name] = a;
+ } else if (a[a.length - 1] !== line) {
+ a.push(line);
+ }
+ }
+
+
+ // Build the syntax table by declaring the syntactic elements of the language.
+
+ type('(number)', function () {
+ return this;
+ });
+
+ type('(string)', function () {
+ return this;
+ });
+
+ syntax['(identifier)'] = {
+ type: '(identifier)',
+ lbp: 0,
+ identifier: true,
+ nud: function () {
+ var v = this.value,
+ s = scope[v],
+ f;
+
+ if (typeof s === 'function') {
+ // Protection against accidental inheritance.
+ s = undefined;
+ } else if (typeof s === 'boolean') {
+ f = funct;
+ funct = functions[0];
+ addlabel(v, 'var');
+ s = funct;
+ funct = f;
+ }
+
+ // The name is in scope and defined in the current function.
+ if (funct === s) {
+ // Change 'unused' to 'var', and reject labels.
+ switch (funct[v]) {
+ case 'unused':
+ funct[v] = 'var';
+ break;
+ case 'unction':
+ funct[v] = 'function';
+ this['function'] = true;
+ break;
+ case 'function':
+ this['function'] = true;
+ break;
+ case 'label':
+ warning("'{a}' is a statement label.", token, v);
+ break;
+ }
+ } else if (funct['(global)']) {
+ // The name is not defined in the function. If we are in the global
+ // scope, then we have an undefined variable.
+ //
+ // Operators typeof and delete do not raise runtime errors even if
+ // the base object of a reference is null so no need to display warning
+ // if we're inside of typeof or delete.
+
+ if (option.undef && typeof predefined[v] !== 'boolean') {
+ // Attempting to subscript a null reference will throw an
+ // error, even within the typeof and delete operators
+ if (!(anonname === 'typeof' || anonname === 'delete') ||
+ (nexttoken && (nexttoken.value === '.' || nexttoken.value === '['))) {
+
+ isundef(funct, "'{a}' is not defined.", token, v);
+ }
+ }
+ note_implied(token);
+ } else {
+ // If the name is already defined in the current
+ // function, but not as outer, then there is a scope error.
+
+ switch (funct[v]) {
+ case 'closure':
+ case 'function':
+ case 'var':
+ case 'unused':
+ warning("'{a}' used out of scope.", token, v);
+ break;
+ case 'label':
+ warning("'{a}' is a statement label.", token, v);
+ break;
+ case 'outer':
+ case 'global':
+ break;
+ default:
+ // If the name is defined in an outer function, make an outer entry,
+ // and if it was unused, make it var.
+ if (s === true) {
+ funct[v] = true;
+ } else if (s === null) {
+ warning("'{a}' is not allowed.", token, v);
+ note_implied(token);
+ } else if (typeof s !== 'object') {
+ // Operators typeof and delete do not raise runtime errors even
+ // if the base object of a reference is null so no need to
+ // display warning if we're inside of typeof or delete.
+ if (option.undef) {
+ // Attempting to subscript a null reference will throw an
+ // error, even within the typeof and delete operators
+ if (!(anonname === 'typeof' || anonname === 'delete') ||
+ (nexttoken &&
+ (nexttoken.value === '.' || nexttoken.value === '['))) {
+
+ isundef(funct, "'{a}' is not defined.", token, v);
+ }
+ }
+ funct[v] = true;
+ note_implied(token);
+ } else {
+ switch (s[v]) {
+ case 'function':
+ case 'unction':
+ this['function'] = true;
+ s[v] = 'closure';
+ funct[v] = s['(global)'] ? 'global' : 'outer';
+ break;
+ case 'var':
+ case 'unused':
+ s[v] = 'closure';
+ funct[v] = s['(global)'] ? 'global' : 'outer';
+ break;
+ case 'closure':
+ case 'parameter':
+ funct[v] = s['(global)'] ? 'global' : 'outer';
+ break;
+ case 'label':
+ warning("'{a}' is a statement label.", token, v);
+ }
+ }
+ }
+ }
+ return this;
+ },
+ led: function () {
+ error("Expected an operator and instead saw '{a}'.",
+ nexttoken, nexttoken.value);
+ }
+ };
+
+ type('(regexp)', function () {
+ return this;
+ });
+
+
+// ECMAScript parser
+
+ delim('(endline)');
+ delim('(begin)');
+ delim('(end)').reach = true;
+ delim('</').reach = true;
+ delim('<!');
+ delim('<!--');
+ delim('-->');
+ delim('(error)').reach = true;
+ delim('}').reach = true;
+ delim(')');
+ delim(']');
+ delim('"').reach = true;
+ delim("'").reach = true;
+ delim(';');
+ delim(':').reach = true;
+ delim(',');
+ delim('#');
+ delim('@');
+ reserve('else');
+ reserve('case').reach = true;
+ reserve('catch');
+ reserve('default').reach = true;
+ reserve('finally');
+ reservevar('arguments', function (x) {
+ if (directive['use strict'] && funct['(global)']) {
+ warning("Strict violation.", x);
+ }
+ });
+ reservevar('eval');
+ reservevar('false');
+ reservevar('Infinity');
+ reservevar('NaN');
+ reservevar('null');
+ reservevar('this', function (x) {
+ if (directive['use strict'] && !option.validthis && ((funct['(statement)'] &&
+ funct['(name)'].charAt(0) > 'Z') || funct['(global)'])) {
+ warning("Possible strict violation.", x);
+ }
+ });
+ reservevar('true');
+ reservevar('undefined');
+ assignop('=', 'assign', 20);
+ assignop('+=', 'assignadd', 20);
+ assignop('-=', 'assignsub', 20);
+ assignop('*=', 'assignmult', 20);
+ assignop('/=', 'assigndiv', 20).nud = function () {
+ error("A regular expression literal can be confused with '/='.");
+ };
+ assignop('%=', 'assignmod', 20);
+ bitwiseassignop('&=', 'assignbitand', 20);
+ bitwiseassignop('|=', 'assignbitor', 20);
+ bitwiseassignop('^=', 'assignbitxor', 20);
+ bitwiseassignop('<<=', 'assignshiftleft', 20);
+ bitwiseassignop('>>=', 'assignshiftright', 20);
+ bitwiseassignop('>>>=', 'assignshiftrightunsigned', 20);
+ infix('?', function (left, that) {
+ that.left = left;
+ that.right = expression(10);
+ advance(':');
+ that['else'] = expression(10);
+ return that;
+ }, 30);
+
+ infix('||', 'or', 40);
+ infix('&&', 'and', 50);
+ bitwise('|', 'bitor', 70);
+ bitwise('^', 'bitxor', 80);
+ bitwise('&', 'bitand', 90);
+ relation('==', function (left, right) {
+ var eqnull = option.eqnull && (left.value === 'null' || right.value === 'null');
+
+ if (!eqnull && option.eqeqeq)
+ warning("Expected '{a}' and instead saw '{b}'.", this, '===', '==');
+ else if (isPoorRelation(left))
+ warning("Use '{a}' to compare with '{b}'.", this, '===', left.value);
+ else if (isPoorRelation(right))
+ warning("Use '{a}' to compare with '{b}'.", this, '===', right.value);
+
+ return this;
+ });
+ relation('===');
+ relation('!=', function (left, right) {
+ var eqnull = option.eqnull &&
+ (left.value === 'null' || right.value === 'null');
+
+ if (!eqnull && option.eqeqeq) {
+ warning("Expected '{a}' and instead saw '{b}'.",
+ this, '!==', '!=');
+ } else if (isPoorRelation(left)) {
+ warning("Use '{a}' to compare with '{b}'.",
+ this, '!==', left.value);
+ } else if (isPoorRelation(right)) {
+ warning("Use '{a}' to compare with '{b}'.",
+ this, '!==', right.value);
+ }
+ return this;
+ });
+ relation('!==');
+ relation('<');
+ relation('>');
+ relation('<=');
+ relation('>=');
+ bitwise('<<', 'shiftleft', 120);
+ bitwise('>>', 'shiftright', 120);
+ bitwise('>>>', 'shiftrightunsigned', 120);
+ infix('in', 'in', 120);
+ infix('instanceof', 'instanceof', 120);
+ infix('+', function (left, that) {
+ var right = expression(130);
+ if (left && right && left.id === '(string)' && right.id === '(string)') {
+ left.value += right.value;
+ left.character = right.character;
+ if (!option.scripturl && jx.test(left.value)) {
+ warning("JavaScript URL.", left);
+ }
+ return left;
+ }
+ that.left = left;
+ that.right = right;
+ return that;
+ }, 130);
+ prefix('+', 'num');
+ prefix('+++', function () {
+ warning("Confusing pluses.");
+ this.right = expression(150);
+ this.arity = 'unary';
+ return this;
+ });
+ infix('+++', function (left) {
+ warning("Confusing pluses.");
+ this.left = left;
+ this.right = expression(130);
+ return this;
+ }, 130);
+ infix('-', 'sub', 130);
+ prefix('-', 'neg');
+ prefix('---', function () {
+ warning("Confusing minuses.");
+ this.right = expression(150);
+ this.arity = 'unary';
+ return this;
+ });
+ infix('---', function (left) {
+ warning("Confusing minuses.");
+ this.left = left;
+ this.right = expression(130);
+ return this;
+ }, 130);
+ infix('*', 'mult', 140);
+ infix('/', 'div', 140);
+ infix('%', 'mod', 140);
+
+ suffix('++', 'postinc');
+ prefix('++', 'preinc');
+ syntax['++'].exps = true;
+
+ suffix('--', 'postdec');
+ prefix('--', 'predec');
+ syntax['--'].exps = true;
+ prefix('delete', function () {
+ var p = expression(0);
+ if (!p || (p.id !== '.' && p.id !== '[')) {
+ warning("Variables should not be deleted.");
+ }
+ this.first = p;
+ return this;
+ }).exps = true;
+
+ prefix('~', function () {
+ if (option.bitwise) {
+ warning("Unexpected '{a}'.", this, '~');
+ }
+ expression(150);
+ return this;
+ });
+
+ prefix('!', function () {
+ this.right = expression(150);
+ this.arity = 'unary';
+ if (bang[this.right.id] === true) {
+ warning("Confusing use of '{a}'.", this, '!');
+ }
+ return this;
+ });
+ prefix('typeof', 'typeof');
+ prefix('new', function () {
+ var c = expression(155), i;
+ if (c && c.id !== 'function') {
+ if (c.identifier) {
+ c['new'] = true;
+ switch (c.value) {
+ case 'Object':
+ warning("Use the object literal notation {}.", token);
+ break;
+ case 'Number':
+ case 'String':
+ case 'Boolean':
+ case 'Math':
+ case 'JSON':
+ warning("Do not use {a} as a constructor.", token, c.value);
+ break;
+ case 'Function':
+ if (!option.evil) {
+ warning("The Function constructor is eval.");
+ }
+ break;
+ case 'Date':
+ case 'RegExp':
+ break;
+ default:
+ if (c.id !== 'function') {
+ i = c.value.substr(0, 1);
+ if (option.newcap && (i < 'A' || i > 'Z')) {
+ warning("A constructor name should start with an uppercase letter.",
+ token);
+ }
+ }
+ }
+ } else {
+ if (c.id !== '.' && c.id !== '[' && c.id !== '(') {
+ warning("Bad constructor.", token);
+ }
+ }
+ } else {
+ if (!option.supernew)
+ warning("Weird construction. Delete 'new'.", this);
+ }
+ adjacent(token, nexttoken);
+ if (nexttoken.id !== '(' && !option.supernew) {
+ warning("Missing '()' invoking a constructor.");
+ }
+ this.first = c;
+ return this;
+ });
+ syntax['new'].exps = true;
+
+ prefix('void').exps = true;
+
+ infix('.', function (left, that) {
+ adjacent(prevtoken, token);
+ nobreak();
+ var m = identifier();
+ if (typeof m === 'string') {
+ countMember(m);
+ }
+ that.left = left;
+ that.right = m;
+ if (left && left.value === 'arguments' && (m === 'callee' || m === 'caller')) {
+ if (option.noarg)
+ warning("Avoid arguments.{a}.", left, m);
+ else if (directive['use strict'])
+ error('Strict violation.');
+ } else if (!option.evil && left && left.value === 'document' &&
+ (m === 'write' || m === 'writeln')) {
+ warning("document.write can be a form of eval.", left);
+ }
+ if (!option.evil && (m === 'eval' || m === 'execScript')) {
+ warning('eval is evil.');
+ }
+ return that;
+ }, 160, true);
+
+ infix('(', function (left, that) {
+ if (prevtoken.id !== '}' && prevtoken.id !== ')') {
+ nobreak(prevtoken, token);
+ }
+ nospace();
+ if (option.immed && !left.immed && left.id === 'function') {
+ warning("Wrap an immediate function invocation in parentheses " +
+ "to assist the reader in understanding that the expression " +
+ "is the result of a function, and not the function itself.");
+ }
+ var n = 0,
+ p = [];
+ if (left) {
+ if (left.type === '(identifier)') {
+ if (left.value.match(/^[A-Z]([A-Z0-9_$]*[a-z][A-Za-z0-9_$]*)?$/)) {
+ if (left.value !== 'Number' && left.value !== 'String' &&
+ left.value !== 'Boolean' &&
+ left.value !== 'Date') {
+ if (left.value === 'Math') {
+ warning("Math is not a function.", left);
+ } else if (option.newcap) {
+ warning(
+"Missing 'new' prefix when invoking a constructor.", left);
+ }
+ }
+ }
+ }
+ }
+ if (nexttoken.id !== ')') {
+ for (;;) {
+ p[p.length] = expression(10);
+ n += 1;
+ if (nexttoken.id !== ',') {
+ break;
+ }
+ comma();
+ }
+ }
+ advance(')');
+ nospace(prevtoken, token);
+ if (typeof left === 'object') {
+ if (left.value === 'parseInt' && n === 1) {
+ warning("Missing radix parameter.", left);
+ }
+ if (!option.evil) {
+ if (left.value === 'eval' || left.value === 'Function' ||
+ left.value === 'execScript') {
+ warning("eval is evil.", left);
+ } else if (p[0] && p[0].id === '(string)' &&
+ (left.value === 'setTimeout' ||
+ left.value === 'setInterval')) {
+ warning(
+ "Implied eval is evil. Pass a function instead of a string.", left);
+ }
+ }
+ if (!left.identifier && left.id !== '.' && left.id !== '[' &&
+ left.id !== '(' && left.id !== '&&' && left.id !== '||' &&
+ left.id !== '?') {
+ warning("Bad invocation.", left);
+ }
+ }
+ that.left = left;
+ return that;
+ }, 155, true).exps = true;
+
+ prefix('(', function () {
+ nospace();
+ if (nexttoken.id === 'function') {
+ nexttoken.immed = true;
+ }
+ var v = expression(0);
+ advance(')', this);
+ nospace(prevtoken, token);
+ if (option.immed && v.id === 'function') {
+ if (nexttoken.id === '(' ||
+ (nexttoken.id === '.' && (peek().value === 'call' || peek().value === 'apply'))) {
+ warning(
+"Move the invocation into the parens that contain the function.", nexttoken);
+ } else {
+ warning(
+"Do not wrap function literals in parens unless they are to be immediately invoked.",
+ this);
+ }
+ }
+ return v;
+ });
+
+ infix('[', function (left, that) {
+ nobreak(prevtoken, token);
+ nospace();
+ var e = expression(0), s;
+ if (e && e.type === '(string)') {
+ if (!option.evil && (e.value === 'eval' || e.value === 'execScript')) {
+ warning("eval is evil.", that);
+ }
+ countMember(e.value);
+ if (!option.sub && ix.test(e.value)) {
+ s = syntax[e.value];
+ if (!s || !s.reserved) {
+ warning("['{a}'] is better written in dot notation.",
+ e, e.value);
+ }
+ }
+ }
+ advance(']', that);
+ nospace(prevtoken, token);
+ that.left = left;
+ that.right = e;
+ return that;
+ }, 160, true);
+
+ prefix('[', function () {
+ var b = token.line !== nexttoken.line;
+ this.first = [];
+ if (b) {
+ indent += option.indent;
+ if (nexttoken.from === indent + option.indent) {
+ indent += option.indent;
+ }
+ }
+ while (nexttoken.id !== '(end)') {
+ while (nexttoken.id === ',') {
+ warning("Extra comma.");
+ advance(',');
+ }
+ if (nexttoken.id === ']') {
+ break;
+ }
+ if (b && token.line !== nexttoken.line) {
+ indentation();
+ }
+ this.first.push(expression(10));
+ if (nexttoken.id === ',') {
+ comma();
+ if (nexttoken.id === ']' && !option.es5) {
+ warning("Extra comma.", token);
+ break;
+ }
+ } else {
+ break;
+ }
+ }
+ if (b) {
+ indent -= option.indent;
+ indentation();
+ }
+ advance(']', this);
+ return this;
+ }, 160);
+
+
+ function property_name() {
+ var id = optionalidentifier(true);
+ if (!id) {
+ if (nexttoken.id === '(string)') {
+ id = nexttoken.value;
+ advance();
+ } else if (nexttoken.id === '(number)') {
+ id = nexttoken.value.toString();
+ advance();
+ }
+ }
+ return id;
+ }
+
+
+ function functionparams() {
+ var i, t = nexttoken, p = [];
+ advance('(');
+ nospace();
+ if (nexttoken.id === ')') {
+ advance(')');
+ return;
+ }
+ for (;;) {
+ i = identifier(true);
+ p.push(i);
+ addlabel(i, 'parameter');
+ if (nexttoken.id === ',') {
+ comma();
+ } else {
+ advance(')', t);
+ nospace(prevtoken, token);
+ return p;
+ }
+ }
+ }
+
+
+ function doFunction(i, statement) {
+ var f,
+ oldOption = option,
+ oldScope = scope;
+
+ option = Object.create(option);
+ scope = Object.create(scope);
+
+ funct = {
+ '(name)' : i || '"' + anonname + '"',
+ '(line)' : nexttoken.line,
+ '(context)' : funct,
+ '(breakage)' : 0,
+ '(loopage)' : 0,
+ '(scope)' : scope,
+ '(statement)': statement
+ };
+ f = funct;
+ token.funct = funct;
+ functions.push(funct);
+ if (i) {
+ addlabel(i, 'function');
+ }
+ funct['(params)'] = functionparams();
+
+ block(false, false, true);
+ scope = oldScope;
+ option = oldOption;
+ funct['(last)'] = token.line;
+ funct = funct['(context)'];
+ return f;
+ }
+
+
+ (function (x) {
+ x.nud = function () {
+ var b, f, i, j, p, t;
+ var props = {}; // All properties, including accessors
+
+ function saveProperty(name, token) {
+ if (props[name] && is_own(props, name))
+ warning("Duplicate member '{a}'.", nexttoken, i);
+ else
+ props[name] = {};
+
+ props[name].basic = true;
+ props[name].basicToken = token;
+ }
+
+ function saveSetter(name, token) {
+ if (props[name] && is_own(props, name)) {
+ if (props[name].basic || props[name].setter)
+ warning("Duplicate member '{a}'.", nexttoken, i);
+ } else {
+ props[name] = {};
+ }
+
+ props[name].setter = true;
+ props[name].setterToken = token;
+ }
+
+ function saveGetter(name) {
+ if (props[name] && is_own(props, name)) {
+ if (props[name].basic || props[name].getter)
+ warning("Duplicate member '{a}'.", nexttoken, i);
+ } else {
+ props[name] = {};
+ }
+
+ props[name].getter = true;
+ props[name].getterToken = token;
+ }
+
+ b = token.line !== nexttoken.line;
+ if (b) {
+ indent += option.indent;
+ if (nexttoken.from === indent + option.indent) {
+ indent += option.indent;
+ }
+ }
+ for (;;) {
+ if (nexttoken.id === '}') {
+ break;
+ }
+ if (b) {
+ indentation();
+ }
+ if (nexttoken.value === 'get' && peek().id !== ':') {
+ advance('get');
+ if (!option.es5) {
+ error("get/set are ES5 features.");
+ }
+ i = property_name();
+ if (!i) {
+ error("Missing property name.");
+ }
+ saveGetter(i);
+ t = nexttoken;
+ adjacent(token, nexttoken);
+ f = doFunction();
+ p = f['(params)'];
+ if (p) {
+ warning("Unexpected parameter '{a}' in get {b} function.", t, p[0], i);
+ }
+ adjacent(token, nexttoken);
+ } else if (nexttoken.value === 'set' && peek().id !== ':') {
+ advance('set');
+ if (!option.es5) {
+ error("get/set are ES5 features.");
+ }
+ i = property_name();
+ if (!i) {
+ error("Missing property name.");
+ }
+ saveSetter(i, nexttoken);
+ t = nexttoken;
+ adjacent(token, nexttoken);
+ f = doFunction();
+ p = f['(params)'];
+ if (!p || p.length !== 1) {
+ warning("Expected a single parameter in set {a} function.", t, i);
+ }
+ } else {
+ i = property_name();
+ saveProperty(i, nexttoken);
+ if (typeof i !== 'string') {
+ break;
+ }
+ advance(':');
+ nonadjacent(token, nexttoken);
+ expression(10);
+ }
+
+ countMember(i);
+ if (nexttoken.id === ',') {
+ comma();
+ if (nexttoken.id === ',') {
+ warning("Extra comma.", token);
+ } else if (nexttoken.id === '}' && !option.es5) {
+ warning("Extra comma.", token);
+ }
+ } else {
+ break;
+ }
+ }
+ if (b) {
+ indent -= option.indent;
+ indentation();
+ }
+ advance('}', this);
+
+ // Check for lonely setters if in the ES5 mode.
+ if (option.es5) {
+ for (var name in props) {
+ if (is_own(props, name) && props[name].setter && !props[name].getter) {
+ warning("Setter is defined without getter.", props[name].setterToken);
+ }
+ }
+ }
+ return this;
+ };
+ x.fud = function () {
+ error("Expected to see a statement and instead saw a block.", token);
+ };
+ }(delim('{')));
+
+// This Function is called when esnext option is set to true
+// it adds the `const` statement to JSHINT
+
+ useESNextSyntax = function () {
+ var conststatement = stmt('const', function (prefix) {
+ var id, name, value;
+
+ this.first = [];
+ for (;;) {
+ nonadjacent(token, nexttoken);
+ id = identifier();
+ if (funct[id] === "const") {
+ warning("const '" + id + "' has already been declared");
+ }
+ if (funct['(global)'] && predefined[id] === false) {
+ warning("Redefinition of '{a}'.", token, id);
+ }
+ addlabel(id, 'const');
+ if (prefix) {
+ break;
+ }
+ name = token;
+ this.first.push(token);
+
+ if (nexttoken.id !== "=") {
+ warning("const " +
+ "'{a}' is initialized to 'undefined'.", token, id);
+ }
+
+ if (nexttoken.id === '=') {
+ nonadjacent(token, nexttoken);
+ advance('=');
+ nonadjacent(token, nexttoken);
+ if (nexttoken.id === 'undefined') {
+ warning("It is not necessary to initialize " +
+ "'{a}' to 'undefined'.", token, id);
+ }
+ if (peek(0).id === '=' && nexttoken.identifier) {
+ error("Constant {a} was not declared correctly.",
+ nexttoken, nexttoken.value);
+ }
+ value = expression(0);
+ name.first = value;
+ }
+
+ if (nexttoken.id !== ',') {
+ break;
+ }
+ comma();
+ }
+ return this;
+ });
+ conststatement.exps = true;
+ };
+
+ var varstatement = stmt('var', function (prefix) {
+ // JavaScript does not have block scope. It only has function scope. So,
+ // declaring a variable in a block can have unexpected consequences.
+ var id, name, value;
+
+ if (funct['(onevar)'] && option.onevar) {
+ warning("Too many var statements.");
+ } else if (!funct['(global)']) {
+ funct['(onevar)'] = true;
+ }
+ this.first = [];
+ for (;;) {
+ nonadjacent(token, nexttoken);
+ id = identifier();
+ if (option.esnext && funct[id] === "const") {
+ warning("const '" + id + "' has already been declared");
+ }
+ if (funct['(global)'] && predefined[id] === false) {
+ warning("Redefinition of '{a}'.", token, id);
+ }
+ addlabel(id, 'unused');
+ if (prefix) {
+ break;
+ }
+ name = token;
+ this.first.push(token);
+ if (nexttoken.id === '=') {
+ nonadjacent(token, nexttoken);
+ advance('=');
+ nonadjacent(token, nexttoken);
+ if (nexttoken.id === 'undefined') {
+ warning("It is not necessary to initialize '{a}' to 'undefined'.", token, id);
+ }
+ if (peek(0).id === '=' && nexttoken.identifier) {
+ error("Variable {a} was not declared correctly.",
+ nexttoken, nexttoken.value);
+ }
+ value = expression(0);
+ name.first = value;
+ }
+ if (nexttoken.id !== ',') {
+ break;
+ }
+ comma();
+ }
+ return this;
+ });
+ varstatement.exps = true;
+
+ blockstmt('function', function () {
+ if (inblock) {
+ warning("Function declarations should not be placed in blocks. " +
+ "Use a function expression or move the statement to the top of " +
+ "the outer function.", token);
+
+ }
+ var i = identifier();
+ if (option.esnext && funct[i] === "const") {
+ warning("const '" + i + "' has already been declared");
+ }
+ adjacent(token, nexttoken);
+ addlabel(i, 'unction');
+ doFunction(i, true);
+ if (nexttoken.id === '(' && nexttoken.line === token.line) {
+ error(
+"Function declarations are not invocable. Wrap the whole function invocation in parens.");
+ }
+ return this;
+ });
+
+ prefix('function', function () {
+ var i = optionalidentifier();
+ if (i) {
+ adjacent(token, nexttoken);
+ } else {
+ nonadjacent(token, nexttoken);
+ }
+ doFunction(i);
+ if (!option.loopfunc && funct['(loopage)']) {
+ warning("Don't make functions within a loop.");
+ }
+ return this;
+ });
+
+ blockstmt('if', function () {
+ var t = nexttoken;
+ advance('(');
+ nonadjacent(this, t);
+ nospace();
+ expression(20);
+ if (nexttoken.id === '=') {
+ if (!option.boss)
+ warning("Expected a conditional expression and instead saw an assignment.");
+ advance('=');
+ expression(20);
+ }
+ advance(')', t);
+ nospace(prevtoken, token);
+ block(true, true);
+ if (nexttoken.id === 'else') {
+ nonadjacent(token, nexttoken);
+ advance('else');
+ if (nexttoken.id === 'if' || nexttoken.id === 'switch') {
+ statement(true);
+ } else {
+ block(true, true);
+ }
+ }
+ return this;
+ });
+
+ blockstmt('try', function () {
+ var b, e, s;
+
+ block(false);
+ if (nexttoken.id === 'catch') {
+ advance('catch');
+ nonadjacent(token, nexttoken);
+ advance('(');
+ s = scope;
+ scope = Object.create(s);
+ e = nexttoken.value;
+ if (nexttoken.type !== '(identifier)') {
+ warning("Expected an identifier and instead saw '{a}'.",
+ nexttoken, e);
+ } else {
+ addlabel(e, 'exception');
+ }
+ advance();
+ advance(')');
+ block(false);
+ b = true;
+ scope = s;
+ }
+ if (nexttoken.id === 'finally') {
+ advance('finally');
+ block(false);
+ return;
+ } else if (!b) {
+ error("Expected '{a}' and instead saw '{b}'.",
+ nexttoken, 'catch', nexttoken.value);
+ }
+ return this;
+ });
+
+ blockstmt('while', function () {
+ var t = nexttoken;
+ funct['(breakage)'] += 1;
+ funct['(loopage)'] += 1;
+ advance('(');
+ nonadjacent(this, t);
+ nospace();
+ expression(20);
+ if (nexttoken.id === '=') {
+ if (!option.boss)
+ warning("Expected a conditional expression and instead saw an assignment.");
+ advance('=');
+ expression(20);
+ }
+ advance(')', t);
+ nospace(prevtoken, token);
+ block(true, true);
+ funct['(breakage)'] -= 1;
+ funct['(loopage)'] -= 1;
+ return this;
+ }).labelled = true;
+
+ reserve('with');
+
+ blockstmt('switch', function () {
+ var t = nexttoken,
+ g = false;
+ funct['(breakage)'] += 1;
+ advance('(');
+ nonadjacent(this, t);
+ nospace();
+ this.condition = expression(20);
+ advance(')', t);
+ nospace(prevtoken, token);
+ nonadjacent(token, nexttoken);
+ t = nexttoken;
+ advance('{');
+ nonadjacent(token, nexttoken);
+ indent += option.indent;
+ this.cases = [];
+ for (;;) {
+ switch (nexttoken.id) {
+ case 'case':
+ switch (funct['(verb)']) {
+ case 'break':
+ case 'case':
+ case 'continue':
+ case 'return':
+ case 'switch':
+ case 'throw':
+ break;
+ default:
+ // You can tell JSHint that you don't use break intentionally by
+ // adding a comment /* falls through */ on a line just before
+ // the next `case`.
+ if (!ft.test(lines[nexttoken.line - 2])) {
+ warning(
+ "Expected a 'break' statement before 'case'.",
+ token);
+ }
+ }
+ indentation(-option.indent);
+ advance('case');
+ this.cases.push(expression(20));
+ g = true;
+ advance(':');
+ funct['(verb)'] = 'case';
+ break;
+ case 'default':
+ switch (funct['(verb)']) {
+ case 'break':
+ case 'continue':
+ case 'return':
+ case 'throw':
+ break;
+ default:
+ if (!ft.test(lines[nexttoken.line - 2])) {
+ warning(
+ "Expected a 'break' statement before 'default'.",
+ token);
+ }
+ }
+ indentation(-option.indent);
+ advance('default');
+ g = true;
+ advance(':');
+ break;
+ case '}':
+ indent -= option.indent;
+ indentation();
+ advance('}', t);
+ if (this.cases.length === 1 || this.condition.id === 'true' ||
+ this.condition.id === 'false') {
+ if (!option.onecase)
+ warning("This 'switch' should be an 'if'.", this);
+ }
+ funct['(breakage)'] -= 1;
+ funct['(verb)'] = undefined;
+ return;
+ case '(end)':
+ error("Missing '{a}'.", nexttoken, '}');
+ return;
+ default:
+ if (g) {
+ switch (token.id) {
+ case ',':
+ error("Each value should have its own case label.");
+ return;
+ case ':':
+ g = false;
+ statements();
+ break;
+ default:
+ error("Missing ':' on a case clause.", token);
+ return;
+ }
+ } else {
+ if (token.id === ':') {
+ advance(':');
+ error("Unexpected '{a}'.", token, ':');
+ statements();
+ } else {
+ error("Expected '{a}' and instead saw '{b}'.",
+ nexttoken, 'case', nexttoken.value);
+ return;
+ }
+ }
+ }
+ }
+ }).labelled = true;
+
+ stmt('debugger', function () {
+ if (!option.debug) {
+ warning("All 'debugger' statements should be removed.");
+ }
+ return this;
+ }).exps = true;
+
+ (function () {
+ var x = stmt('do', function () {
+ funct['(breakage)'] += 1;
+ funct['(loopage)'] += 1;
+ this.first = block(true);
+ advance('while');
+ var t = nexttoken;
+ nonadjacent(token, t);
+ advance('(');
+ nospace();
+ expression(20);
+ if (nexttoken.id === '=') {
+ if (!option.boss)
+ warning("Expected a conditional expression and instead saw an assignment.");
+ advance('=');
+ expression(20);
+ }
+ advance(')', t);
+ nospace(prevtoken, token);
+ funct['(breakage)'] -= 1;
+ funct['(loopage)'] -= 1;
+ return this;
+ });
+ x.labelled = true;
+ x.exps = true;
+ }());
+
+ blockstmt('for', function () {
+ var s, t = nexttoken;
+ funct['(breakage)'] += 1;
+ funct['(loopage)'] += 1;
+ advance('(');
+ nonadjacent(this, t);
+ nospace();
+ if (peek(nexttoken.id === 'var' ? 1 : 0).id === 'in') {
+ if (nexttoken.id === 'var') {
+ advance('var');
+ varstatement.fud.call(varstatement, true);
+ } else {
+ switch (funct[nexttoken.value]) {
+ case 'unused':
+ funct[nexttoken.value] = 'var';
+ break;
+ case 'var':
+ break;
+ default:
+ warning("Bad for in variable '{a}'.",
+ nexttoken, nexttoken.value);
+ }
+ advance();
+ }
+ advance('in');
+ expression(20);
+ advance(')', t);
+ s = block(true, true);
+ if (option.forin && s && (s.length > 1 || typeof s[0] !== 'object' ||
+ s[0].value !== 'if')) {
+ warning("The body of a for in should be wrapped in an if statement to filter " +
+ "unwanted properties from the prototype.", this);
+ }
+ funct['(breakage)'] -= 1;
+ funct['(loopage)'] -= 1;
+ return this;
+ } else {
+ if (nexttoken.id !== ';') {
+ if (nexttoken.id === 'var') {
+ advance('var');
+ varstatement.fud.call(varstatement);
+ } else {
+ for (;;) {
+ expression(0, 'for');
+ if (nexttoken.id !== ',') {
+ break;
+ }
+ comma();
+ }
+ }
+ }
+ nolinebreak(token);
+ advance(';');
+ if (nexttoken.id !== ';') {
+ expression(20);
+ if (nexttoken.id === '=') {
+ if (!option.boss)
+ warning("Expected a conditional expression and instead saw an assignment.");
+ advance('=');
+ expression(20);
+ }
+ }
+ nolinebreak(token);
+ advance(';');
+ if (nexttoken.id === ';') {
+ error("Expected '{a}' and instead saw '{b}'.",
+ nexttoken, ')', ';');
+ }
+ if (nexttoken.id !== ')') {
+ for (;;) {
+ expression(0, 'for');
+ if (nexttoken.id !== ',') {
+ break;
+ }
+ comma();
+ }
+ }
+ advance(')', t);
+ nospace(prevtoken, token);
+ block(true, true);
+ funct['(breakage)'] -= 1;
+ funct['(loopage)'] -= 1;
+ return this;
+ }
+ }).labelled = true;
+
+
+ stmt('break', function () {
+ var v = nexttoken.value;
+
+ if (funct['(breakage)'] === 0)
+ warning("Unexpected '{a}'.", nexttoken, this.value);
+
+ if (!option.asi)
+ nolinebreak(this);
+
+ if (nexttoken.id !== ';') {
+ if (token.line === nexttoken.line) {
+ if (funct[v] !== 'label') {
+ warning("'{a}' is not a statement label.", nexttoken, v);
+ } else if (scope[v] !== funct) {
+ warning("'{a}' is out of scope.", nexttoken, v);
+ }
+ this.first = nexttoken;
+ advance();
+ }
+ }
+ reachable('break');
+ return this;
+ }).exps = true;
+
+
+ stmt('continue', function () {
+ var v = nexttoken.value;
+
+ if (funct['(breakage)'] === 0)
+ warning("Unexpected '{a}'.", nexttoken, this.value);
+
+ if (!option.asi)
+ nolinebreak(this);
+
+ if (nexttoken.id !== ';') {
+ if (token.line === nexttoken.line) {
+ if (funct[v] !== 'label') {
+ warning("'{a}' is not a statement label.", nexttoken, v);
+ } else if (scope[v] !== funct) {
+ warning("'{a}' is out of scope.", nexttoken, v);
+ }
+ this.first = nexttoken;
+ advance();
+ }
+ } else if (!funct['(loopage)']) {
+ warning("Unexpected '{a}'.", nexttoken, this.value);
+ }
+ reachable('continue');
+ return this;
+ }).exps = true;
+
+
+ stmt('return', function () {
+ if (this.line === nexttoken.line) {
+ if (nexttoken.id === '(regexp)')
+ warning("Wrap the /regexp/ literal in parens to disambiguate the slash operator.");
+
+ if (nexttoken.id !== ';' && !nexttoken.reach) {
+ nonadjacent(token, nexttoken);
+ if (peek().value === "=" && !option.boss) {
+ warningAt("Did you mean to return a conditional instead of an assignment?",
+ token.line, token.character + 1);
+ }
+ this.first = expression(0);
+ }
+ } else if (!option.asi) {
+ nolinebreak(this); // always warn (Line breaking error)
+ }
+ reachable('return');
+ return this;
+ }).exps = true;
+
+
+ stmt('throw', function () {
+ nolinebreak(this);
+ nonadjacent(token, nexttoken);
+ this.first = expression(20);
+ reachable('throw');
+ return this;
+ }).exps = true;
+
+// Superfluous reserved words
+
+ reserve('class');
+ reserve('const');
+ reserve('enum');
+ reserve('export');
+ reserve('extends');
+ reserve('import');
+ reserve('super');
+
+ reserve('let');
+ reserve('yield');
+ reserve('implements');
+ reserve('interface');
+ reserve('package');
+ reserve('private');
+ reserve('protected');
+ reserve('public');
+ reserve('static');
+
+
+// Parse JSON
+
+ function jsonValue() {
+
+ function jsonObject() {
+ var o = {}, t = nexttoken;
+ advance('{');
+ if (nexttoken.id !== '}') {
+ for (;;) {
+ if (nexttoken.id === '(end)') {
+ error("Missing '}' to match '{' from line {a}.",
+ nexttoken, t.line);
+ } else if (nexttoken.id === '}') {
+ warning("Unexpected comma.", token);
+ break;
+ } else if (nexttoken.id === ',') {
+ error("Unexpected comma.", nexttoken);
+ } else if (nexttoken.id !== '(string)') {
+ warning("Expected a string and instead saw {a}.",
+ nexttoken, nexttoken.value);
+ }
+ if (o[nexttoken.value] === true) {
+ warning("Duplicate key '{a}'.",
+ nexttoken, nexttoken.value);
+ } else if ((nexttoken.value === '__proto__' &&
+ !option.proto) || (nexttoken.value === '__iterator__' &&
+ !option.iterator)) {
+ warning("The '{a}' key may produce unexpected results.",
+ nexttoken, nexttoken.value);
+ } else {
+ o[nexttoken.value] = true;
+ }
+ advance();
+ advance(':');
+ jsonValue();
+ if (nexttoken.id !== ',') {
+ break;
+ }
+ advance(',');
+ }
+ }
+ advance('}');
+ }
+
+ function jsonArray() {
+ var t = nexttoken;
+ advance('[');
+ if (nexttoken.id !== ']') {
+ for (;;) {
+ if (nexttoken.id === '(end)') {
+ error("Missing ']' to match '[' from line {a}.",
+ nexttoken, t.line);
+ } else if (nexttoken.id === ']') {
+ warning("Unexpected comma.", token);
+ break;
+ } else if (nexttoken.id === ',') {
+ error("Unexpected comma.", nexttoken);
+ }
+ jsonValue();
+ if (nexttoken.id !== ',') {
+ break;
+ }
+ advance(',');
+ }
+ }
+ advance(']');
+ }
+
+ switch (nexttoken.id) {
+ case '{':
+ jsonObject();
+ break;
+ case '[':
+ jsonArray();
+ break;
+ case 'true':
+ case 'false':
+ case 'null':
+ case '(number)':
+ case '(string)':
+ advance();
+ break;
+ case '-':
+ advance('-');
+ if (token.character !== nexttoken.from) {
+ warning("Unexpected space after '-'.", token);
+ }
+ adjacent(token, nexttoken);
+ advance('(number)');
+ break;
+ default:
+ error("Expected a JSON value.", nexttoken);
+ }
+ }
+
+
+// The actual JSHINT function itself.
+
+ var itself = function (s, o, g) {
+ var a, i, k;
+ JSHINT.errors = [];
+ JSHINT.undefs = [];
+ predefined = Object.create(standard);
+ combine(predefined, g || {});
+ if (o) {
+ a = o.predef;
+ if (a) {
+ if (Array.isArray(a)) {
+ for (i = 0; i < a.length; i += 1) {
+ predefined[a[i]] = true;
+ }
+ } else if (typeof a === 'object') {
+ k = Object.keys(a);
+ for (i = 0; i < k.length; i += 1) {
+ predefined[k[i]] = !!a[k[i]];
+ }
+ }
+ }
+ option = o;
+ } else {
+ option = {};
+ }
+ option.indent = option.indent || 4;
+ option.maxerr = option.maxerr || 50;
+
+ tab = '';
+ for (i = 0; i < option.indent; i += 1) {
+ tab += ' ';
+ }
+ indent = 1;
+ global = Object.create(predefined);
+ scope = global;
+ funct = {
+ '(global)': true,
+ '(name)': '(global)',
+ '(scope)': scope,
+ '(breakage)': 0,
+ '(loopage)': 0
+ };
+ functions = [funct];
+ urls = [];
+ stack = null;
+ member = {};
+ membersOnly = null;
+ implied = {};
+ inblock = false;
+ lookahead = [];
+ jsonmode = false;
+ warnings = 0;
+ lex.init(s);
+ prereg = true;
+ directive = {};
+
+ prevtoken = token = nexttoken = syntax['(begin)'];
+ assume();
+
+ // combine the passed globals after we've assumed all our options
+ combine(predefined, g || {});
+
+ try {
+ advance();
+ switch (nexttoken.id) {
+ case '{':
+ case '[':
+ option.laxbreak = true;
+ jsonmode = true;
+ jsonValue();
+ break;
+ default:
+ directives();
+ if (directive["use strict"] && !option.globalstrict) {
+ warning("Use the function form of \"use strict\".", prevtoken);
+ }
+
+ statements();
+ }
+ advance('(end)');
+
+ var markDefined = function (name, context) {
+ do {
+ if (typeof context[name] === 'string') {
+ // JSHINT marks unused variables as 'unused' and
+ // unused function declaration as 'unction'. This
+ // code changes such instances back 'var' and
+ // 'closure' so that the code in JSHINT.data()
+ // doesn't think they're unused.
+
+ if (context[name] === 'unused')
+ context[name] = 'var';
+ else if (context[name] === 'unction')
+ context[name] = 'closure';
+
+ return true;
+ }
+
+ context = context['(context)'];
+ } while (context);
+
+ return false;
+ };
+
+ var clearImplied = function (name, line) {
+ if (!implied[name])
+ return;
+
+ var newImplied = [];
+ for (var i = 0; i < implied[name].length; i += 1) {
+ if (implied[name][i] !== line)
+ newImplied.push(implied[name][i]);
+ }
+
+ if (newImplied.length === 0)
+ delete implied[name];
+ else
+ implied[name] = newImplied;
+ };
+
+ // Check queued 'x is not defined' instances to see if they're still undefined.
+ for (i = 0; i < JSHINT.undefs.length; i += 1) {
+ k = JSHINT.undefs[i].slice(0);
+
+ if (markDefined(k[2].value, k[0])) {
+ clearImplied(k[2].value, k[2].line);
+ } else {
+ warning.apply(warning, k.slice(1));
+ }
+ }
+ } catch (e) {
+ if (e) {
+ var nt = nexttoken || {};
+ JSHINT.errors.push({
+ raw : e.raw,
+ reason : e.message,
+ line : e.line || nt.line,
+ character : e.character || nt.from
+ }, null);
+ }
+ }
+
+ return JSHINT.errors.length === 0;
+ };
+
+ // Data summary.
+ itself.data = function () {
+
+ var data = { functions: [], options: option }, fu, globals, implieds = [], f, i, j,
+ members = [], n, unused = [], v;
+ if (itself.errors.length) {
+ data.errors = itself.errors;
+ }
+
+ if (jsonmode) {
+ data.json = true;
+ }
+
+ for (n in implied) {
+ if (is_own(implied, n)) {
+ implieds.push({
+ name: n,
+ line: implied[n]
+ });
+ }
+ }
+ if (implieds.length > 0) {
+ data.implieds = implieds;
+ }
+
+ if (urls.length > 0) {
+ data.urls = urls;
+ }
+
+ globals = Object.keys(scope);
+ if (globals.length > 0) {
+ data.globals = globals;
+ }
+ for (i = 1; i < functions.length; i += 1) {
+ f = functions[i];
+ fu = {};
+ for (j = 0; j < functionicity.length; j += 1) {
+ fu[functionicity[j]] = [];
+ }
+ for (n in f) {
+ if (is_own(f, n) && n.charAt(0) !== '(') {
+ v = f[n];
+ if (v === 'unction') {
+ v = 'unused';
+ }
+ if (Array.isArray(fu[v])) {
+ fu[v].push(n);
+ if (v === 'unused') {
+ unused.push({
+ name: n,
+ line: f['(line)'],
+ 'function': f['(name)']
+ });
+ }
+ }
+ }
+ }
+ for (j = 0; j < functionicity.length; j += 1) {
+ if (fu[functionicity[j]].length === 0) {
+ delete fu[functionicity[j]];
+ }
+ }
+ fu.name = f['(name)'];
+ fu.param = f['(params)'];
+ fu.line = f['(line)'];
+ fu.last = f['(last)'];
+ data.functions.push(fu);
+ }
+
+ if (unused.length > 0) {
+ data.unused = unused;
+ }
+
+ members = [];
+ for (n in member) {
+ if (typeof member[n] === 'number') {
+ data.member = member;
+ break;
+ }
+ }
+
+ return data;
+ };
+
+ itself.report = function (option) {
+ var data = itself.data();
+
+ var a = [], c, e, err, f, i, k, l, m = '', n, o = [], s;
+
+ function detail(h, array) {
+ var b, i, singularity;
+ if (array) {
+ o.push('<div><i>' + h + '</i> ');
+ array = array.sort();
+ for (i = 0; i < array.length; i += 1) {
+ if (array[i] !== singularity) {
+ singularity = array[i];
+ o.push((b ? ', ' : '') + singularity);
+ b = true;
+ }
+ }
+ o.push('</div>');
+ }
+ }
+
+
+ if (data.errors || data.implieds || data.unused) {
+ err = true;
+ o.push('<div id=errors><i>Error:</i>');
+ if (data.errors) {
+ for (i = 0; i < data.errors.length; i += 1) {
+ c = data.errors[i];
+ if (c) {
+ e = c.evidence || '';
+ o.push('<p>Problem' + (isFinite(c.line) ? ' at line ' +
+ c.line + ' character ' + c.character : '') +
+ ': ' + c.reason.entityify() +
+ '</p><p class=evidence>' +
+ (e && (e.length > 80 ? e.slice(0, 77) + '...' :
+ e).entityify()) + '</p>');
+ }
+ }
+ }
+
+ if (data.implieds) {
+ s = [];
+ for (i = 0; i < data.implieds.length; i += 1) {
+ s[i] = '<code>' + data.implieds[i].name + '</code>&nbsp;<i>' +
+ data.implieds[i].line + '</i>';
+ }
+ o.push('<p><i>Implied global:</i> ' + s.join(', ') + '</p>');
+ }
+
+ if (data.unused) {
+ s = [];
+ for (i = 0; i < data.unused.length; i += 1) {
+ s[i] = '<code><u>' + data.unused[i].name + '</u></code>&nbsp;<i>' +
+ data.unused[i].line + '</i> <code>' +
+ data.unused[i]['function'] + '</code>';
+ }
+ o.push('<p><i>Unused variable:</i> ' + s.join(', ') + '</p>');
+ }
+ if (data.json) {
+ o.push('<p>JSON: bad.</p>');
+ }
+ o.push('</div>');
+ }
+
+ if (!option) {
+
+ o.push('<br><div id=functions>');
+
+ if (data.urls) {
+ detail("URLs<br>", data.urls, '<br>');
+ }
+
+ if (data.json && !err) {
+ o.push('<p>JSON: good.</p>');
+ } else if (data.globals) {
+ o.push('<div><i>Global</i> ' +
+ data.globals.sort().join(', ') + '</div>');
+ } else {
+ o.push('<div><i>No new global variables introduced.</i></div>');
+ }
+
+ for (i = 0; i < data.functions.length; i += 1) {
+ f = data.functions[i];
+
+ o.push('<br><div class=function><i>' + f.line + '-' +
+ f.last + '</i> ' + (f.name || '') + '(' +
+ (f.param ? f.param.join(', ') : '') + ')</div>');
+ detail('<big><b>Unused</b></big>', f.unused);
+ detail('Closure', f.closure);
+ detail('Variable', f['var']);
+ detail('Exception', f.exception);
+ detail('Outer', f.outer);
+ detail('Global', f.global);
+ detail('Label', f.label);
+ }
+
+ if (data.member) {
+ a = Object.keys(data.member);
+ if (a.length) {
+ a = a.sort();
+ m = '<br><pre id=members>/*members ';
+ l = 10;
+ for (i = 0; i < a.length; i += 1) {
+ k = a[i];
+ n = k.name();
+ if (l + n.length > 72) {
+ o.push(m + '<br>');
+ m = ' ';
+ l = 1;
+ }
+ l += n.length + 2;
+ if (data.member[k] === 1) {
+ n = '<i>' + n + '</i>';
+ }
+ if (i < a.length - 1) {
+ n += ', ';
+ }
+ m += n;
+ }
+ o.push(m + '<br>*/</pre>');
+ }
+ o.push('</div>');
+ }
+ }
+ return o.join('');
+ };
+
+ itself.jshint = itself;
+
+ return itself;
+}());
+
+// Make JSHINT a Node module, if possible.
+if (typeof exports === 'object' && exports)
+ exports.JSHINT = JSHINT;
diff --git a/external/qunit.css b/external/qunit.css
index e3e10f9f9..23235ec84 100644
--- a/external/qunit.css
+++ b/external/qunit.css
@@ -1,5 +1,5 @@
/**
- * QUnit v1.5.0pre - A JavaScript Unit Testing Framework
+ * QUnit v1.6.0 - A JavaScript Unit Testing Framework
*
* http://docs.jquery.com/QUnit
*
@@ -56,6 +56,7 @@
#qunit-header label {
display: inline-block;
+ padding-left: 0.5em;
}
#qunit-banner {
@@ -220,6 +221,9 @@
border-bottom: 1px solid white;
}
+#qunit-testresult .module-name {
+ font-weight: bold;
+}
/** Fixture */
diff --git a/external/qunit.js b/external/qunit.js
index 71aac0efa..2c277fab5 100644
--- a/external/qunit.js
+++ b/external/qunit.js
@@ -1,5 +1,5 @@
/**
- * QUnit v1.5.0pre - A JavaScript Unit Testing Framework
+ * QUnit v1.6.0 - A JavaScript Unit Testing Framework
*
* http://docs.jquery.com/QUnit
*
@@ -8,75 +8,82 @@
* or GPL (GPL-LICENSE.txt) licenses.
*/
-(function(window) {
+(function( window ) {
-var defined = {
+var QUnit,
+ config,
+ testId = 0,
+ toString = Object.prototype.toString,
+ hasOwn = Object.prototype.hasOwnProperty,
+ defined = {
setTimeout: typeof window.setTimeout !== "undefined",
sessionStorage: (function() {
var x = "qunit-test-string";
try {
- sessionStorage.setItem(x, x);
- sessionStorage.removeItem(x);
+ sessionStorage.setItem( x, x );
+ sessionStorage.removeItem( x );
return true;
- } catch(e) {
+ } catch( e ) {
return false;
}
}())
};
-var testId = 0,
- toString = Object.prototype.toString,
- hasOwn = Object.prototype.hasOwnProperty;
-
-var Test = function(name, testName, expected, async, callback) {
+function Test( name, testName, expected, async, callback ) {
this.name = name;
this.testName = testName;
this.expected = expected;
this.async = async;
this.callback = callback;
this.assertions = [];
-};
+}
+
Test.prototype = {
init: function() {
- var tests = id("qunit-tests");
- if (tests) {
- var b = document.createElement("strong");
- b.innerHTML = "Running " + this.name;
- var li = document.createElement("li");
- li.appendChild( b );
- li.className = "running";
- li.id = this.id = "test-output" + testId++;
+ var b, li,
+ tests = id( "qunit-tests" );
+
+ if ( tests ) {
+ b = document.createElement( "strong" );
+ b.innerHTML = "Running " + this.name;
+
+ li = document.createElement( "li" );
+ li.appendChild( b );
+ li.className = "running";
+ li.id = this.id = "qunit-test-output" + testId++;
+
tests.appendChild( li );
}
},
setup: function() {
- if (this.module != config.previousModule) {
+ if ( this.module !== config.previousModule ) {
if ( config.previousModule ) {
- runLoggingCallbacks('moduleDone', QUnit, {
+ runLoggingCallbacks( "moduleDone", QUnit, {
name: config.previousModule,
failed: config.moduleStats.bad,
passed: config.moduleStats.all - config.moduleStats.bad,
total: config.moduleStats.all
- } );
+ });
}
config.previousModule = this.module;
config.moduleStats = { all: 0, bad: 0 };
- runLoggingCallbacks( 'moduleStart', QUnit, {
+ runLoggingCallbacks( "moduleStart", QUnit, {
name: this.module
- } );
- } else if (config.autorun) {
- runLoggingCallbacks( 'moduleStart', QUnit, {
+ });
+ } else if ( config.autorun ) {
+ runLoggingCallbacks( "moduleStart", QUnit, {
name: this.module
- } );
+ });
}
config.current = this;
+
this.testEnvironment = extend({
setup: function() {},
teardown: function() {}
- }, this.moduleTestEnvironment);
+ }, this.moduleTestEnvironment );
- runLoggingCallbacks( 'testStart', QUnit, {
+ runLoggingCallbacks( "testStart", QUnit, {
name: this.testName,
module: this.module
});
@@ -89,28 +96,36 @@ Test.prototype = {
saveGlobal();
}
if ( config.notrycatch ) {
- this.testEnvironment.setup.call(this.testEnvironment);
+ this.testEnvironment.setup.call( this.testEnvironment );
return;
}
try {
- this.testEnvironment.setup.call(this.testEnvironment);
- } catch(e) {
+ this.testEnvironment.setup.call( this.testEnvironment );
+ } catch( e ) {
QUnit.pushFailure( "Setup failed on " + this.testName + ": " + e.message, extractStacktrace( e, 1 ) );
}
},
run: function() {
config.current = this;
+
+ var running = id( "qunit-testresult" );
+
+ if ( running ) {
+ running.innerHTML = "Running: <br/>" + this.name;
+ }
+
if ( this.async ) {
QUnit.stop();
}
if ( config.notrycatch ) {
- this.callback.call(this.testEnvironment);
+ this.callback.call( this.testEnvironment );
return;
}
+
try {
- this.callback.call(this.testEnvironment);
- } catch(e) {
+ this.callback.call( this.testEnvironment );
+ } catch( e ) {
QUnit.pushFailure( "Died on test #" + (this.assertions.length + 1) + ": " + e.message, extractStacktrace( e, 1 ) );
// else next test will carry the responsibility
saveGlobal();
@@ -124,12 +139,12 @@ Test.prototype = {
teardown: function() {
config.current = this;
if ( config.notrycatch ) {
- this.testEnvironment.teardown.call(this.testEnvironment);
+ this.testEnvironment.teardown.call( this.testEnvironment );
return;
} else {
try {
- this.testEnvironment.teardown.call(this.testEnvironment);
- } catch(e) {
+ this.testEnvironment.teardown.call( this.testEnvironment );
+ } catch( e ) {
QUnit.pushFailure( "Teardown failed on " + this.testName + ": " + e.message, extractStacktrace( e, 1 ) );
}
}
@@ -138,27 +153,28 @@ Test.prototype = {
finish: function() {
config.current = this;
if ( this.expected != null && this.expected != this.assertions.length ) {
- QUnit.pushFailure( "Expected " + this.expected + " assertions, but " + this.assertions.length + " were run" );
+ QUnit.pushFailure( "Expected " + this.expected + " assertions, but " + this.assertions.length + " were run", this.stack );
} else if ( this.expected == null && !this.assertions.length ) {
- QUnit.pushFailure( "Expected at least one assertion, but none were run - call expect(0) to accept zero assertions." );
+ QUnit.pushFailure( "Expected at least one assertion, but none were run - call expect(0) to accept zero assertions.", this.stack );
}
- var good = 0, bad = 0,
- li, i,
- tests = id("qunit-tests");
+ var assertion, a, b, i, li, ol,
+ good = 0,
+ bad = 0,
+ tests = id( "qunit-tests" );
config.stats.all += this.assertions.length;
config.moduleStats.all += this.assertions.length;
if ( tests ) {
- var ol = document.createElement("ol");
+ ol = document.createElement( "ol" );
for ( i = 0; i < this.assertions.length; i++ ) {
- var assertion = this.assertions[i];
+ assertion = this.assertions[i];
- li = document.createElement("li");
+ li = document.createElement( "li" );
li.className = assertion.result ? "pass" : "fail";
- li.innerHTML = assertion.message || (assertion.result ? "okay" : "failed");
+ li.innerHTML = assertion.message || ( assertion.result ? "okay" : "failed" );
ol.appendChild( li );
if ( assertion.result ) {
@@ -172,23 +188,25 @@ Test.prototype = {
// store result when possible
if ( QUnit.config.reorder && defined.sessionStorage ) {
- if (bad) {
- sessionStorage.setItem("qunit-test-" + this.module + "-" + this.testName, bad);
+ if ( bad ) {
+ sessionStorage.setItem( "qunit-test-" + this.module + "-" + this.testName, bad );
} else {
- sessionStorage.removeItem("qunit-test-" + this.module + "-" + this.testName);
+ sessionStorage.removeItem( "qunit-test-" + this.module + "-" + this.testName );
}
}
- if (bad === 0) {
+ if ( bad === 0 ) {
ol.style.display = "none";
}
- var b = document.createElement("strong");
+ // `b` initialized at top of scope
+ b = document.createElement( "strong" );
b.innerHTML = this.name + " <b class='counts'>(<b class='failed'>" + bad + "</b>, <b class='passed'>" + good + "</b>, " + this.assertions.length + ")</b>";
- var a = document.createElement("a");
+ // `a` initialized at top of scope
+ a = document.createElement( "a" );
a.innerHTML = "Rerun";
- a.href = QUnit.url({ filter: getText([b]).replace(/\([^)]+\)$/, "").replace(/(^\s*|\s*$)/g, "") });
+ a.href = QUnit.url({ filter: getText([b]).replace( /\([^)]+\)$/, "" ).replace( /(^\s*|\s*$)/g, "" ) });
addEvent(b, "click", function() {
var next = b.nextSibling.nextSibling,
@@ -196,17 +214,20 @@ Test.prototype = {
next.style.display = display === "none" ? "block" : "none";
});
- addEvent(b, "dblclick", function(e) {
+ addEvent(b, "dblclick", function( e ) {
var target = e && e.target ? e.target : window.event.srcElement;
if ( target.nodeName.toLowerCase() == "span" || target.nodeName.toLowerCase() == "b" ) {
target = target.parentNode;
}
if ( window.location && target.nodeName.toLowerCase() === "strong" ) {
- window.location = QUnit.url({ filter: getText([target]).replace(/\([^)]+\)$/, "").replace(/(^\s*|\s*$)/g, "") });
+ window.location = QUnit.url({
+ filter: getText([target]).replace( /\([^)]+\)$/, "" ).replace( /(^\s*|\s*$)/g, "" )
+ });
}
});
- li = id(this.id);
+ // `li` initialized at top of scope
+ li = id( this.id );
li.className = bad ? "fail" : "pass";
li.removeChild( li.firstChild );
li.appendChild( b );
@@ -223,19 +244,21 @@ Test.prototype = {
}
}
- QUnit.reset();
-
- runLoggingCallbacks( 'testDone', QUnit, {
+ runLoggingCallbacks( "testDone", QUnit, {
name: this.testName,
module: this.module,
failed: bad,
passed: this.assertions.length - bad,
total: this.assertions.length
- } );
+ });
+
+ QUnit.reset();
},
queue: function() {
- var test = this;
+ var bad,
+ test = this;
+
synchronize(function() {
test.init();
});
@@ -254,36 +277,41 @@ Test.prototype = {
test.finish();
});
}
+
+ // `bad` initialized at top of scope
// defer when previous test run passed, if storage is available
- var bad = QUnit.config.reorder && defined.sessionStorage && +sessionStorage.getItem("qunit-test-" + this.module + "-" + this.testName);
- if (bad) {
+ bad = QUnit.config.reorder && defined.sessionStorage &&
+ +sessionStorage.getItem( "qunit-test-" + this.module + "-" + this.testName );
+
+ if ( bad ) {
run();
} else {
- synchronize(run, true);
+ synchronize( run, true );
}
}
-
};
-var QUnit = {
+// `QUnit` initialized at top of scope
+QUnit = {
// call on start of module test to prepend name to all tests
- module: function(name, testEnvironment) {
+ module: function( name, testEnvironment ) {
config.currentModule = name;
config.currentModuleTestEnviroment = testEnvironment;
},
- asyncTest: function(testName, expected, callback) {
+ asyncTest: function( testName, expected, callback ) {
if ( arguments.length === 2 ) {
callback = expected;
expected = null;
}
- QUnit.test(testName, expected, callback, true);
+ QUnit.test( testName, expected, callback, true );
},
- test: function(testName, expected, callback, async) {
- var name = '<span class="test-name">' + escapeInnerText(testName) + '</span>';
+ test: function( testName, expected, callback, async ) {
+ var test,
+ name = "<span class='test-name'>" + escapeInnerText( testName ) + "</span>";
if ( arguments.length === 2 ) {
callback = expected;
@@ -291,44 +319,50 @@ var QUnit = {
}
if ( config.currentModule ) {
- name = '<span class="module-name">' + config.currentModule + "</span>: " + name;
+ name = "<span class='module-name'>" + config.currentModule + "</span>: " + name;
}
if ( !validTest(config.currentModule + ": " + testName) ) {
return;
}
- var test = new Test(name, testName, expected, async, callback);
+ test = new Test( name, testName, expected, async, callback );
test.module = config.currentModule;
test.moduleTestEnvironment = config.currentModuleTestEnviroment;
+ test.stack = sourceFromStacktrace( 2 );
test.queue();
},
// Specify the number of expected assertions to gurantee that failed test (no assertions are run at all) don't slip through.
- expect: function(asserts) {
+ expect: function( asserts ) {
config.current.expected = asserts;
},
// Asserts true.
// @example ok( "asdfasdf".length > 5, "There must be at least 5 chars" );
- ok: function(result, msg) {
- if (!config.current) {
- throw new Error("ok() assertion outside test context, was " + sourceFromStacktrace(2));
+ ok: function( result, msg ) {
+ if ( !config.current ) {
+ throw new Error( "ok() assertion outside test context, was " + sourceFromStacktrace(2) );
}
result = !!result;
- var details = {
- result: result,
- message: msg
- };
- msg = escapeInnerText(msg || (result ? "okay" : "failed"));
+
+ var source,
+ details = {
+ result: result,
+ message: msg
+ };
+
+ msg = escapeInnerText( msg || (result ? "okay" : "failed" ) );
+ msg = "<span class='test-message'>" + msg + "</span>";
+
if ( !result ) {
- var source = sourceFromStacktrace(2);
- if (source) {
+ source = sourceFromStacktrace( 2 );
+ if ( source ) {
details.source = source;
- msg += '<table><tr class="test-source"><th>Source: </th><td><pre>' + escapeInnerText(source) + '</pre></td></tr></table>';
+ msg += "<table><tr class='test-source'><th>Source: </th><td><pre>" + escapeInnerText( source ) + "</pre></td></tr></table>";
}
}
- runLoggingCallbacks( 'log', QUnit, details );
+ runLoggingCallbacks( "log", QUnit, details );
config.current.assertions.push({
result: result,
message: msg
@@ -336,128 +370,130 @@ var QUnit = {
},
// Checks that the first two arguments are equal, with an optional message. Prints out both actual and expected values.
- // @example equal( format("Received {0} bytes.", 2), "Received 2 bytes." );
- equal: function(actual, expected, message) {
- QUnit.push(expected == actual, actual, expected, message);
+ // @example equal( format( "Received {0} bytes.", 2), "Received 2 bytes." );
+ equal: function( actual, expected, message ) {
+ QUnit.push( expected == actual, actual, expected, message );
},
- notEqual: function(actual, expected, message) {
- QUnit.push(expected != actual, actual, expected, message);
+ notEqual: function( actual, expected, message ) {
+ QUnit.push( expected != actual, actual, expected, message );
},
- deepEqual: function(actual, expected, message) {
- QUnit.push(QUnit.equiv(actual, expected), actual, expected, message);
+ deepEqual: function( actual, expected, message ) {
+ QUnit.push( QUnit.equiv(actual, expected), actual, expected, message );
},
- notDeepEqual: function(actual, expected, message) {
- QUnit.push(!QUnit.equiv(actual, expected), actual, expected, message);
+ notDeepEqual: function( actual, expected, message ) {
+ QUnit.push( !QUnit.equiv(actual, expected), actual, expected, message );
},
- strictEqual: function(actual, expected, message) {
- QUnit.push(expected === actual, actual, expected, message);
+ strictEqual: function( actual, expected, message ) {
+ QUnit.push( expected === actual, actual, expected, message );
},
- notStrictEqual: function(actual, expected, message) {
- QUnit.push(expected !== actual, actual, expected, message);
+ notStrictEqual: function( actual, expected, message ) {
+ QUnit.push( expected !== actual, actual, expected, message );
},
- raises: function(block, expected, message) {
- var actual, ok = false;
+ raises: function( block, expected, message ) {
+ var actual,
+ ok = false;
- if (typeof expected === 'string') {
+ if ( typeof expected === "string" ) {
message = expected;
expected = null;
}
try {
- block.call(config.current.testEnvironment);
+ block.call( config.current.testEnvironment );
} catch (e) {
actual = e;
}
- if (actual) {
+ if ( actual ) {
// we don't want to validate thrown error
- if (!expected) {
+ if ( !expected ) {
ok = true;
// expected is a regexp
- } else if (QUnit.objectType(expected) === "regexp") {
- ok = expected.test(actual);
+ } else if ( QUnit.objectType( expected ) === "regexp" ) {
+ ok = expected.test( actual );
// expected is a constructor
- } else if (actual instanceof expected) {
+ } else if ( actual instanceof expected ) {
ok = true;
// expected is a validation function which returns true is validation passed
- } else if (expected.call({}, actual) === true) {
+ } else if ( expected.call( {}, actual ) === true ) {
ok = true;
}
}
- QUnit.ok(ok, message);
+ QUnit.ok( ok, message );
},
- start: function(count) {
+ start: function( count ) {
config.semaphore -= count || 1;
- if (config.semaphore > 0) {
- // don't start until equal number of stop-calls
+ // don't start until equal number of stop-calls
+ if ( config.semaphore > 0 ) {
return;
}
- if (config.semaphore < 0) {
- // ignore if start is called more often then stop
+ // ignore if start is called more often then stop
+ if ( config.semaphore < 0 ) {
config.semaphore = 0;
}
// A slight delay, to avoid any current callbacks
if ( defined.setTimeout ) {
window.setTimeout(function() {
- if (config.semaphore > 0) {
+ if ( config.semaphore > 0 ) {
return;
}
if ( config.timeout ) {
- clearTimeout(config.timeout);
+ clearTimeout( config.timeout );
}
config.blocking = false;
- process(true);
+ process( true );
}, 13);
} else {
config.blocking = false;
- process(true);
+ process( true );
}
},
- stop: function(count) {
+ stop: function( count ) {
config.semaphore += count || 1;
config.blocking = true;
if ( config.testTimeout && defined.setTimeout ) {
- clearTimeout(config.timeout);
+ clearTimeout( config.timeout );
config.timeout = window.setTimeout(function() {
QUnit.ok( false, "Test timed out" );
config.semaphore = 1;
QUnit.start();
- }, config.testTimeout);
+ }, config.testTimeout );
}
}
};
-//We want access to the constructor's prototype
+// We want access to the constructor's prototype
(function() {
- function F(){}
+ function F() {}
F.prototype = QUnit;
QUnit = new F();
- //Make F QUnit's constructor so that we can add to the prototype later
+ // Make F QUnit's constructor so that we can add to the prototype later
QUnit.constructor = F;
}());
// deprecated; still export them to window to provide clear error messages
// next step: remove entirely
QUnit.equals = function() {
- QUnit.push(false, false, false, "QUnit.equals has been deprecated since 2009 (e88049a0), use QUnit.equal instead");
+ QUnit.push( false, false, false, "QUnit.equals has been deprecated since 2009 (e88049a0), use QUnit.equal instead" );
};
QUnit.same = function() {
- QUnit.push(false, false, false, "QUnit.same has been deprecated since 2009 (e88049a0), use QUnit.deepEqual instead");
+ QUnit.push( false, false, false, "QUnit.same has been deprecated since 2009 (e88049a0), use QUnit.deepEqual instead" );
};
// Maintain internal state
-var config = {
+// `config` initialized at top of scope
+config = {
// The queue of tests to run
queue: [],
@@ -475,9 +511,9 @@ var config = {
// by default, modify document.title when suite is done
altertitle: true,
- urlConfig: ['noglobals', 'notrycatch'],
+ urlConfig: [ "noglobals", "notrycatch" ],
- //logging callback queues
+ // logging callback queues
begin: [],
done: [],
log: [],
@@ -489,14 +525,15 @@ var config = {
// Load paramaters
(function() {
- var location = window.location || { search: "", protocol: "file:" },
+ var i,
+ location = window.location || { search: "", protocol: "file:" },
params = location.search.slice( 1 ).split( "&" ),
length = params.length,
urlParams = {},
current;
if ( params[ 0 ] ) {
- for ( var i = 0; i < length; i++ ) {
+ for ( i = 0; i < length; i++ ) {
current = params[ i ].split( "=" );
current[ 0 ] = decodeURIComponent( current[ 0 ] );
// allow just a key to turn on a flag, e.g., test.html?noglobals
@@ -509,23 +546,23 @@ var config = {
config.filter = urlParams.filter;
// Figure out if we're running the tests from a server or not
- QUnit.isLocal = location.protocol === 'file:';
+ QUnit.isLocal = location.protocol === "file:";
}());
-// Expose the API as global variables, unless an 'exports'
-// object exists, in that case we assume we're in CommonJS - export everything at the end
-if ( typeof exports === "undefined" || typeof require === "undefined" ) {
- extend(window, QUnit);
+// Expose the API as global variables, unless an 'exports' object exists,
+// in that case we assume we're in CommonJS - export everything at the end
+if ( typeof exports === "undefined" ) {
+ extend( window, QUnit );
window.QUnit = QUnit;
}
// define these after exposing globals to keep them in these QUnit namespace only
-extend(QUnit, {
+extend( QUnit, {
config: config,
// Initialize the configuration options
init: function() {
- extend(config, {
+ extend( config, {
stats: { all: 0, bad: 0 },
moduleStats: { all: 0, bad: 0 },
started: +new Date(),
@@ -538,19 +575,21 @@ extend(QUnit, {
semaphore: 0
});
- var qunit = id( "qunit" );
+ var tests, banner, result,
+ qunit = id( "qunit" );
+
if ( qunit ) {
qunit.innerHTML =
- '<h1 id="qunit-header">' + escapeInnerText( document.title ) + '</h1>' +
- '<h2 id="qunit-banner"></h2>' +
- '<div id="qunit-testrunner-toolbar"></div>' +
- '<h2 id="qunit-userAgent"></h2>' +
- '<ol id="qunit-tests"></ol>';
+ "<h1 id='qunit-header'>" + escapeInnerText( document.title ) + "</h1>" +
+ "<h2 id='qunit-banner'></h2>" +
+ "<div id='qunit-testrunner-toolbar'></div>" +
+ "<h2 id='qunit-userAgent'></h2>" +
+ "<ol id='qunit-tests'></ol>";
}
- var tests = id( "qunit-tests" ),
- banner = id( "qunit-banner" ),
- result = id( "qunit-testresult" );
+ tests = id( "qunit-tests" );
+ banner = id( "qunit-banner" );
+ result = id( "qunit-testresult" );
if ( tests ) {
tests.innerHTML = "";
@@ -569,19 +608,21 @@ extend(QUnit, {
result.id = "qunit-testresult";
result.className = "result";
tests.parentNode.insertBefore( result, tests );
- result.innerHTML = 'Running...<br/>&nbsp;';
+ result.innerHTML = "Running...<br/>&nbsp;";
}
},
// Resets the test setup. Useful for tests that modify the DOM.
// If jQuery is available, uses jQuery's html(), otherwise just innerHTML.
reset: function() {
+ var fixture;
+
if ( window.jQuery ) {
jQuery( "#qunit-fixture" ).html( config.fixture );
} else {
- var main = id( 'qunit-fixture' );
- if ( main ) {
- main.innerHTML = config.fixture;
+ fixture = id( "qunit-fixture" );
+ if ( fixture ) {
+ fixture.innerHTML = config.fixture;
}
}
},
@@ -590,13 +631,13 @@ extend(QUnit, {
// @example triggerEvent( document.body, "click" );
triggerEvent: function( elem, type, event ) {
if ( document.createEvent ) {
- event = document.createEvent("MouseEvents");
+ event = document.createEvent( "MouseEvents" );
event.initMouseEvent(type, true, true, elem.ownerDocument.defaultView,
0, 0, 0, 0, 0, false, false, false, false, 0, null);
- elem.dispatchEvent( event );
+ elem.dispatchEvent( event );
} else if ( elem.fireEvent ) {
- elem.fireEvent("on"+type);
+ elem.fireEvent( "on" + type );
}
},
@@ -606,68 +647,74 @@ extend(QUnit, {
},
objectType: function( obj ) {
- if (typeof obj === "undefined") {
+ if ( typeof obj === "undefined" ) {
return "undefined";
-
// consider: typeof null === object
}
- if (obj === null) {
+ if ( obj === null ) {
return "null";
}
- var type = toString.call( obj ).match(/^\[object\s(.*)\]$/)[1] || '';
+ var type = toString.call( obj ).match(/^\[object\s(.*)\]$/)[1] || "";
- switch (type) {
- case 'Number':
- if (isNaN(obj)) {
+ switch ( type ) {
+ case "Number":
+ if ( isNaN(obj) ) {
return "nan";
}
return "number";
- case 'String':
- case 'Boolean':
- case 'Array':
- case 'Date':
- case 'RegExp':
- case 'Function':
- return type.toLowerCase();
+ case "String":
+ case "Boolean":
+ case "Array":
+ case "Date":
+ case "RegExp":
+ case "Function":
+ return type.toLowerCase();
}
- if (typeof obj === "object") {
- return "object";
+ if ( typeof obj === "object" ) {
+ return "object";
}
return undefined;
},
- push: function(result, actual, expected, message) {
- if (!config.current) {
- throw new Error("assertion outside test context, was " + sourceFromStacktrace());
+ push: function( result, actual, expected, message ) {
+ if ( !config.current ) {
+ throw new Error( "assertion outside test context, was " + sourceFromStacktrace() );
}
- var details = {
- result: result,
- message: message,
- actual: actual,
- expected: expected
- };
- message = escapeInnerText(message) || (result ? "okay" : "failed");
- message = '<span class="test-message">' + message + "</span>";
- var output = message;
- if (!result) {
- expected = escapeInnerText(QUnit.jsDump.parse(expected));
- actual = escapeInnerText(QUnit.jsDump.parse(actual));
- output += '<table><tr class="test-expected"><th>Expected: </th><td><pre>' + expected + '</pre></td></tr>';
- if (actual != expected) {
- output += '<tr class="test-actual"><th>Result: </th><td><pre>' + actual + '</pre></td></tr>';
- output += '<tr class="test-diff"><th>Diff: </th><td><pre>' + QUnit.diff(expected, actual) +'</pre></td></tr>';
+ var output, source,
+ details = {
+ result: result,
+ message: message,
+ actual: actual,
+ expected: expected
+ };
+
+ message = escapeInnerText( message ) || ( result ? "okay" : "failed" );
+ message = "<span class='test-message'>" + message + "</span>";
+ output = message;
+
+ if ( !result ) {
+ expected = escapeInnerText( QUnit.jsDump.parse(expected) );
+ actual = escapeInnerText( QUnit.jsDump.parse(actual) );
+ output += "<table><tr class='test-expected'><th>Expected: </th><td><pre>" + expected + "</pre></td></tr>";
+
+ if ( actual != expected ) {
+ output += "<tr class='test-actual'><th>Result: </th><td><pre>" + actual + "</pre></td></tr>";
+ output += "<tr class='test-diff'><th>Diff: </th><td><pre>" + QUnit.diff( expected, actual ) + "</pre></td></tr>";
}
- var source = sourceFromStacktrace();
- if (source) {
+
+ source = sourceFromStacktrace();
+
+ if ( source ) {
details.source = source;
- output += '<tr class="test-source"><th>Source: </th><td><pre>' + escapeInnerText(source) + '</pre></td></tr>';
+ output += "<tr class='test-source'><th>Source: </th><td><pre>" + escapeInnerText( source ) + "</pre></td></tr>";
}
+
output += "</table>";
}
- runLoggingCallbacks( 'log', QUnit, details );
+ runLoggingCallbacks( "log", QUnit, details );
config.current.assertions.push({
result: !!result,
@@ -675,17 +722,24 @@ extend(QUnit, {
});
},
- pushFailure: function(message, source) {
- var details = {
- result: false,
- message: message
- };
- var output = escapeInnerText(message);
- if (source) {
+ pushFailure: function( message, source ) {
+ var output,
+ details = {
+ result: false,
+ message: message
+ };
+
+ message = escapeInnerText(message ) || "error";
+ message = "<span class='test-message'>" + message + "</span>";
+ output = message;
+
+ if ( source ) {
details.source = source;
- output += '<table><tr class="test-source"><th>Source: </th><td><pre>' + escapeInnerText(source) + '</pre></td></tr></table>';
+ output += "<table><tr class='test-source'><th>Source: </th><td><pre>" + escapeInnerText( source ) + "</pre></td></tr></table>";
}
- runLoggingCallbacks( 'log', QUnit, details );
+
+ runLoggingCallbacks( "log", QUnit, details );
+
config.current.assertions.push({
result: false,
message: output
@@ -694,8 +748,9 @@ extend(QUnit, {
url: function( params ) {
params = extend( extend( {}, QUnit.urlParams ), params );
- var querystring = "?",
- key;
+ var key,
+ querystring = "?";
+
for ( key in params ) {
if ( !hasOwn.call( params, key ) ) {
continue;
@@ -711,25 +766,25 @@ extend(QUnit, {
addEvent: addEvent
});
-//QUnit.constructor is set to the empty F() above so that we can add to it's prototype later
-//Doing this allows us to tell if the following methods have been overwritten on the actual
-//QUnit object, which is a deprecated way of using the callbacks.
-extend(QUnit.constructor.prototype, {
+// QUnit.constructor is set to the empty F() above so that we can add to it's prototype later
+// Doing this allows us to tell if the following methods have been overwritten on the actual
+// QUnit object, which is a deprecated way of using the callbacks.
+extend( QUnit.constructor.prototype, {
// Logging callbacks; all receive a single argument with the listed properties
// run test/logs.html for any related changes
- begin: registerLoggingCallback('begin'),
+ begin: registerLoggingCallback( "begin" ),
// done: { failed, passed, total, runtime }
- done: registerLoggingCallback('done'),
+ done: registerLoggingCallback( "done" ),
// log: { result, actual, expected, message }
- log: registerLoggingCallback('log'),
+ log: registerLoggingCallback( "log" ),
// testStart: { name }
- testStart: registerLoggingCallback('testStart'),
+ testStart: registerLoggingCallback( "testStart" ),
// testDone: { name, failed, passed, total }
- testDone: registerLoggingCallback('testDone'),
+ testDone: registerLoggingCallback( "testDone" ),
// moduleStart: { name }
- moduleStart: registerLoggingCallback('moduleStart'),
+ moduleStart: registerLoggingCallback( "moduleStart" ),
// moduleDone: { name, failed, passed, total }
- moduleDone: registerLoggingCallback('moduleDone')
+ moduleDone: registerLoggingCallback( "moduleDone" )
});
if ( typeof document === "undefined" || document.readyState === "complete" ) {
@@ -737,29 +792,36 @@ if ( typeof document === "undefined" || document.readyState === "complete" ) {
}
QUnit.load = function() {
- runLoggingCallbacks( 'begin', QUnit, {} );
+ runLoggingCallbacks( "begin", QUnit, {} );
// Initialize the config, saving the execution queue
- var oldconfig = extend({}, config);
+ var banner, filter, i, label, len, main, ol, toolbar, userAgent, val,
+ urlConfigHtml = "",
+ oldconfig = extend( {}, config );
+
QUnit.init();
extend(config, oldconfig);
config.blocking = false;
- var urlConfigHtml = '', len = config.urlConfig.length;
- for ( var i = 0, val; i < len; i++ ) {
+ len = config.urlConfig.length;
+
+ for ( i = 0; i < len; i++ ) {
val = config.urlConfig[i];
config[val] = QUnit.urlParams[val];
- urlConfigHtml += '<label><input name="' + val + '" type="checkbox"' + ( config[val] ? ' checked="checked"' : '' ) + '>' + val + '</label>';
+ urlConfigHtml += "<label><input name='" + val + "' type='checkbox'" + ( config[val] ? " checked='checked'" : "" ) + ">" + val + "</label>";
}
- var userAgent = id("qunit-userAgent");
+ // `userAgent` initialized at top of scope
+ userAgent = id( "qunit-userAgent" );
if ( userAgent ) {
userAgent.innerHTML = navigator.userAgent;
}
- var banner = id("qunit-header");
+
+ // `banner` initialized at top of scope
+ banner = id( "qunit-header" );
if ( banner ) {
- banner.innerHTML = '<a href="' + QUnit.url({ filter: undefined }) + '"> ' + banner.innerHTML + '</a> ' + urlConfigHtml;
+ banner.innerHTML = "<a href='" + QUnit.url({ filter: undefined }) + "'>" + banner.innerHTML + "</a> " + urlConfigHtml;
addEvent( banner, "change", function( event ) {
var params = {};
params[ event.target.name ] = event.target.checked ? true : undefined;
@@ -767,53 +829,62 @@ QUnit.load = function() {
});
}
- var toolbar = id("qunit-testrunner-toolbar");
+ // `toolbar` initialized at top of scope
+ toolbar = id( "qunit-testrunner-toolbar" );
if ( toolbar ) {
- var filter = document.createElement("input");
+ // `filter` initialized at top of scope
+ filter = document.createElement( "input" );
filter.type = "checkbox";
filter.id = "qunit-filter-pass";
+
addEvent( filter, "click", function() {
- var ol = document.getElementById("qunit-tests");
+ var tmp,
+ ol = document.getElementById( "qunit-tests" );
+
if ( filter.checked ) {
ol.className = ol.className + " hidepass";
} else {
- var tmp = " " + ol.className.replace( /[\n\t\r]/g, " " ) + " ";
- ol.className = tmp.replace(/ hidepass /, " ");
+ tmp = " " + ol.className.replace( /[\n\t\r]/g, " " ) + " ";
+ ol.className = tmp.replace( / hidepass /, " " );
}
if ( defined.sessionStorage ) {
if (filter.checked) {
- sessionStorage.setItem("qunit-filter-passed-tests", "true");
+ sessionStorage.setItem( "qunit-filter-passed-tests", "true" );
} else {
- sessionStorage.removeItem("qunit-filter-passed-tests");
+ sessionStorage.removeItem( "qunit-filter-passed-tests" );
}
}
});
- if ( config.hidepassed || defined.sessionStorage && sessionStorage.getItem("qunit-filter-passed-tests") ) {
+
+ if ( config.hidepassed || defined.sessionStorage && sessionStorage.getItem( "qunit-filter-passed-tests" ) ) {
filter.checked = true;
- var ol = document.getElementById("qunit-tests");
+ // `ol` initialized at top of scope
+ ol = document.getElementById( "qunit-tests" );
ol.className = ol.className + " hidepass";
}
toolbar.appendChild( filter );
- var label = document.createElement("label");
- label.setAttribute("for", "qunit-filter-pass");
+ // `label` initialized at top of scope
+ label = document.createElement( "label" );
+ label.setAttribute( "for", "qunit-filter-pass" );
label.innerHTML = "Hide passed tests";
toolbar.appendChild( label );
}
- var main = id('qunit-fixture');
+ // `main` initialized at top of scope
+ main = id( "qunit-fixture" );
if ( main ) {
config.fixture = main.innerHTML;
}
- if (config.autostart) {
+ if ( config.autostart ) {
QUnit.start();
}
};
-addEvent(window, "load", QUnit.load);
+addEvent( window, "load", QUnit.load );
-// addEvent(window, "error") gives us a useless event object
+// addEvent(window, "error" ) gives us a useless event object
window.onerror = function( message, file, line ) {
if ( QUnit.config.current ) {
QUnit.pushFailure( message, file + ":" + line );
@@ -829,33 +900,34 @@ function done() {
// Log the last module results
if ( config.currentModule ) {
- runLoggingCallbacks( 'moduleDone', QUnit, {
+ runLoggingCallbacks( "moduleDone", QUnit, {
name: config.currentModule,
failed: config.moduleStats.bad,
passed: config.moduleStats.all - config.moduleStats.bad,
total: config.moduleStats.all
- } );
+ });
}
- var banner = id("qunit-banner"),
- tests = id("qunit-tests"),
+ var i, key,
+ banner = id( "qunit-banner" ),
+ tests = id( "qunit-tests" ),
runtime = +new Date() - config.started,
passed = config.stats.all - config.stats.bad,
html = [
- 'Tests completed in ',
+ "Tests completed in ",
runtime,
- ' milliseconds.<br/>',
- '<span class="passed">',
+ " milliseconds.<br/>",
+ "<span class='passed'>",
passed,
- '</span> tests of <span class="total">',
+ "</span> tests of <span class='total'>",
config.stats.all,
- '</span> passed, <span class="failed">',
+ "</span> passed, <span class='failed'>",
config.stats.bad,
- '</span> failed.'
- ].join('');
+ "</span> failed."
+ ].join( "" );
if ( banner ) {
- banner.className = (config.stats.bad ? "qunit-fail" : "qunit-pass");
+ banner.className = ( config.stats.bad ? "qunit-fail" : "qunit-pass" );
}
if ( tests ) {
@@ -866,39 +938,41 @@ function done() {
// show ✖ for good, ✔ for bad suite result in title
// use escape sequences in case file gets loaded with non-utf-8-charset
document.title = [
- (config.stats.bad ? "\u2716" : "\u2714"),
- document.title.replace(/^[\u2714\u2716] /i, "")
- ].join(" ");
+ ( config.stats.bad ? "\u2716" : "\u2714" ),
+ document.title.replace( /^[\u2714\u2716] /i, "" )
+ ].join( " " );
}
// clear own sessionStorage items if all tests passed
if ( config.reorder && defined.sessionStorage && config.stats.bad === 0 ) {
- var key;
- for ( var i = 0; i < sessionStorage.length; i++ ) {
+ // `key` & `i` initialized at top of scope
+ for ( i = 0; i < sessionStorage.length; i++ ) {
key = sessionStorage.key( i++ );
- if ( key.indexOf("qunit-test-") === 0 ) {
+ if ( key.indexOf( "qunit-test-" ) === 0 ) {
sessionStorage.removeItem( key );
}
}
}
- runLoggingCallbacks( 'done', QUnit, {
+ runLoggingCallbacks( "done", QUnit, {
failed: config.stats.bad,
passed: passed,
total: config.stats.all,
runtime: runtime
- } );
+ });
}
function validTest( name ) {
- var filter = config.filter,
+ var not,
+ filter = config.filter,
run = false;
if ( !filter ) {
return true;
}
- var not = filter.charAt( 0 ) === "!";
+ not = filter.charAt( 0 ) === "!";
+
if ( not ) {
filter = filter.slice( 1 );
}
@@ -919,17 +993,20 @@ function validTest( name ) {
// See also https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error/Stack
function extractStacktrace( e, offset ) {
offset = offset || 3;
- if (e.stacktrace) {
+
+ var stack;
+
+ if ( e.stacktrace ) {
// Opera
- return e.stacktrace.split("\n")[offset + 3];
- } else if (e.stack) {
+ return e.stacktrace.split( "\n" )[ offset + 3 ];
+ } else if ( e.stack ) {
// Firefox, Chrome
- var stack = e.stack.split("\n");
- if (/^error$/i.test(stack[0])) {
+ stack = e.stack.split( "\n" );
+ if (/^error$/i.test( stack[0] ) ) {
stack.shift();
}
- return stack[offset];
- } else if (e.sourceURL) {
+ return stack[ offset ];
+ } else if ( e.sourceURL ) {
// Safari, PhantomJS
// hopefully one day Safari provides actual stacktraces
// exclude useless self-reference for generated Error objects
@@ -940,7 +1017,7 @@ function extractStacktrace( e, offset ) {
return e.sourceURL + ":" + e.line;
}
}
-function sourceFromStacktrace(offset) {
+function sourceFromStacktrace( offset ) {
try {
throw new Error();
} catch ( e ) {
@@ -948,13 +1025,13 @@ function sourceFromStacktrace(offset) {
}
}
-function escapeInnerText(s) {
- if (!s) {
+function escapeInnerText( s ) {
+ if ( !s ) {
return "";
}
s = s + "";
- return s.replace(/[\&<>]/g, function(s) {
- switch(s) {
+ return s.replace( /[\&<>]/g, function( s ) {
+ switch( s ) {
case "&": return "&amp;";
case "<": return "&lt;";
case ">": return "&gt;";
@@ -967,7 +1044,7 @@ function synchronize( callback, last ) {
config.queue.push( callback );
if ( config.autorun && !config.blocking ) {
- process(last);
+ process( last );
}
}
@@ -997,7 +1074,8 @@ function saveGlobal() {
if ( config.noglobals ) {
for ( var key in window ) {
- if ( !hasOwn.call( window, key ) ) {
+ // in Opera sometimes DOM element ids show up here, ignore them
+ if ( !hasOwn.call( window, key ) || /^qunit-test-output/.test( key ) ) {
continue;
}
config.pollution.push( key );
@@ -1006,15 +1084,18 @@ function saveGlobal() {
}
function checkPollution( name ) {
- var old = config.pollution;
+ var newGlobals,
+ deletedGlobals,
+ old = config.pollution;
+
saveGlobal();
- var newGlobals = diff( config.pollution, old );
+ newGlobals = diff( config.pollution, old );
if ( newGlobals.length > 0 ) {
QUnit.pushFailure( "Introduced global variable(s): " + newGlobals.join(", ") );
}
- var deletedGlobals = diff( old, config.pollution );
+ deletedGlobals = diff( old, config.pollution );
if ( deletedGlobals.length > 0 ) {
QUnit.pushFailure( "Deleted global variable(s): " + deletedGlobals.join(", ") );
}
@@ -1022,11 +1103,13 @@ function checkPollution( name ) {
// returns a new Array with the elements that are in a but not in b
function diff( a, b ) {
- var result = a.slice();
- for ( var i = 0; i < result.length; i++ ) {
- for ( var j = 0; j < b.length; j++ ) {
+ var i, j,
+ result = a.slice();
+
+ for ( i = 0; i < result.length; i++ ) {
+ for ( j = 0; j < b.length; j++ ) {
if ( result[i] === b[j] ) {
- result.splice(i, 1);
+ result.splice( i, 1 );
i--;
break;
}
@@ -1035,21 +1118,21 @@ function diff( a, b ) {
return result;
}
-function extend(a, b) {
+function extend( a, b ) {
for ( var prop in b ) {
- if ( b[prop] === undefined ) {
- delete a[prop];
+ if ( b[ prop ] === undefined ) {
+ delete a[ prop ];
// Avoid "Member not found" error in IE8 caused by setting window.constructor
} else if ( prop !== "constructor" || a !== window ) {
- a[prop] = b[prop];
+ a[ prop ] = b[ prop ];
}
}
return a;
}
-function addEvent(elem, type, fn) {
+function addEvent( elem, type, fn ) {
if ( elem.addEventListener ) {
elem.addEventListener( type, fn, false );
} else if ( elem.attachEvent ) {
@@ -1059,27 +1142,27 @@ function addEvent(elem, type, fn) {
}
}
-function id(name) {
- return !!(typeof document !== "undefined" && document && document.getElementById) &&
+function id( name ) {
+ return !!( typeof document !== "undefined" && document && document.getElementById ) &&
document.getElementById( name );
}
-function registerLoggingCallback(key){
- return function(callback){
+function registerLoggingCallback( key ) {
+ return function( callback ) {
config[key].push( callback );
};
}
// Supports deprecated method of completely overwriting logging callbacks
-function runLoggingCallbacks(key, scope, args) {
+function runLoggingCallbacks( key, scope, args ) {
//debugger;
- var callbacks;
- if ( QUnit.hasOwnProperty(key) ) {
- QUnit[key].call(scope, args);
+ var i, callbacks;
+ if ( QUnit.hasOwnProperty( key ) ) {
+ QUnit[ key ].call(scope, args );
} else {
- callbacks = config[key];
- for( var i = 0; i < callbacks.length; i++ ) {
- callbacks[i].call( scope, args );
+ callbacks = config[ key ];
+ for ( i = 0; i < callbacks.length; i++ ) {
+ callbacks[ i ].call( scope, args );
}
}
}
@@ -1088,183 +1171,184 @@ function runLoggingCallbacks(key, scope, args) {
// Author: Philippe Rathé <prathe@gmail.com>
QUnit.equiv = (function() {
- var innerEquiv; // the real equiv function
- var callers = []; // stack to decide between skip/abort functions
- var parents = []; // stack to avoiding loops from circular referencing
-
// Call the o related callback with the given arguments.
- function bindCallbacks(o, callbacks, args) {
- var prop = QUnit.objectType(o);
- if (prop) {
- if (QUnit.objectType(callbacks[prop]) === "function") {
- return callbacks[prop].apply(callbacks, args);
+ function bindCallbacks( o, callbacks, args ) {
+ var prop = QUnit.objectType( o );
+ if ( prop ) {
+ if ( QUnit.objectType( callbacks[ prop ] ) === "function" ) {
+ return callbacks[ prop ].apply( callbacks, args );
} else {
- return callbacks[prop]; // or undefined
+ return callbacks[ prop ]; // or undefined
}
}
}
- var getProto = Object.getPrototypeOf || function (obj) {
- return obj.__proto__;
- };
-
- var callbacks = (function () {
-
- // for string, boolean, number and null
- function useStrictEquality(b, a) {
- if (b instanceof a.constructor || a instanceof b.constructor) {
- // to catch short annotaion VS 'new' annotation of a
- // declaration
- // e.g. var i = 1;
- // var j = new Number(1);
- return a == b;
- } else {
- return a === b;
- }
- }
-
- return {
- "string" : useStrictEquality,
- "boolean" : useStrictEquality,
- "number" : useStrictEquality,
- "null" : useStrictEquality,
- "undefined" : useStrictEquality,
-
- "nan" : function(b) {
- return isNaN(b);
- },
-
- "date" : function(b, a) {
- return QUnit.objectType(b) === "date" && a.valueOf() === b.valueOf();
- },
-
- "regexp" : function(b, a) {
- return QUnit.objectType(b) === "regexp" &&
- // the regex itself
- a.source === b.source &&
- // and its modifers
- a.global === b.global &&
- // (gmi) ...
- a.ignoreCase === b.ignoreCase &&
- a.multiline === b.multiline;
- },
-
- // - skip when the property is a method of an instance (OOP)
- // - abort otherwise,
- // initial === would have catch identical references anyway
- "function" : function() {
- var caller = callers[callers.length - 1];
- return caller !== Object && typeof caller !== "undefined";
- },
+ // the real equiv function
+ var innerEquiv,
+ // stack to decide between skip/abort functions
+ callers = [],
+ // stack to avoiding loops from circular referencing
+ parents = [],
- "array" : function(b, a) {
- var i, j, loop;
- var len;
-
- // b could be an object literal here
- if (QUnit.objectType(b) !== "array") {
- return false;
- }
-
- len = a.length;
- if (len !== b.length) { // safe and faster
- return false;
+ getProto = Object.getPrototypeOf || function ( obj ) {
+ return obj.__proto__;
+ },
+ callbacks = (function () {
+
+ // for string, boolean, number and null
+ function useStrictEquality( b, a ) {
+ if ( b instanceof a.constructor || a instanceof b.constructor ) {
+ // to catch short annotaion VS 'new' annotation of a
+ // declaration
+ // e.g. var i = 1;
+ // var j = new Number(1);
+ return a == b;
+ } else {
+ return a === b;
}
+ }
- // track reference to avoid circular references
- parents.push(a);
- for (i = 0; i < len; i++) {
- loop = false;
- for (j = 0; j < parents.length; j++) {
- if (parents[j] === a[i]) {
- loop = true;// dont rewalk array
- }
- }
- if (!loop && !innerEquiv(a[i], b[i])) {
- parents.pop();
+ return {
+ "string": useStrictEquality,
+ "boolean": useStrictEquality,
+ "number": useStrictEquality,
+ "null": useStrictEquality,
+ "undefined": useStrictEquality,
+
+ "nan": function( b ) {
+ return isNaN( b );
+ },
+
+ "date": function( b, a ) {
+ return QUnit.objectType( b ) === "date" && a.valueOf() === b.valueOf();
+ },
+
+ "regexp": function( b, a ) {
+ return QUnit.objectType( b ) === "regexp" &&
+ // the regex itself
+ a.source === b.source &&
+ // and its modifers
+ a.global === b.global &&
+ // (gmi) ...
+ a.ignoreCase === b.ignoreCase &&
+ a.multiline === b.multiline;
+ },
+
+ // - skip when the property is a method of an instance (OOP)
+ // - abort otherwise,
+ // initial === would have catch identical references anyway
+ "function": function() {
+ var caller = callers[callers.length - 1];
+ return caller !== Object && typeof caller !== "undefined";
+ },
+
+ "array": function( b, a ) {
+ var i, j, len, loop;
+
+ // b could be an object literal here
+ if ( QUnit.objectType( b ) !== "array" ) {
return false;
}
- }
- parents.pop();
- return true;
- },
- "object" : function(b, a) {
- var i, j, loop;
- var eq = true; // unless we can proove it
- var aProperties = [], bProperties = []; // collection of
- // strings
-
- // comparing constructors is more strict than using
- // instanceof
- if (a.constructor !== b.constructor) {
- // Allow objects with no prototype to be equivalent to
- // objects with Object as their constructor.
- if (!((getProto(a) === null && getProto(b) === Object.prototype) ||
- (getProto(b) === null && getProto(a) === Object.prototype)))
- {
+ len = a.length;
+ if ( len !== b.length ) {
+ // safe and faster
return false;
}
- }
- // stack constructor before traversing properties
- callers.push(a.constructor);
- // track reference to avoid circular references
- parents.push(a);
-
- for (i in a) { // be strict: don't ensures hasOwnProperty
- // and go deep
- loop = false;
- for (j = 0; j < parents.length; j++) {
- if (parents[j] === a[i]) {
- // don't go down the same path twice
- loop = true;
+ // track reference to avoid circular references
+ parents.push( a );
+ for ( i = 0; i < len; i++ ) {
+ loop = false;
+ for ( j = 0; j < parents.length; j++ ) {
+ if ( parents[j] === a[i] ) {
+ loop = true;// dont rewalk array
+ }
+ }
+ if ( !loop && !innerEquiv(a[i], b[i]) ) {
+ parents.pop();
+ return false;
+ }
+ }
+ parents.pop();
+ return true;
+ },
+
+ "object": function( b, a ) {
+ var i, j, loop,
+ // Default to true
+ eq = true,
+ aProperties = [],
+ bProperties = [];
+
+ // comparing constructors is more strict than using
+ // instanceof
+ if ( a.constructor !== b.constructor ) {
+ // Allow objects with no prototype to be equivalent to
+ // objects with Object as their constructor.
+ if ( !(( getProto(a) === null && getProto(b) === Object.prototype ) ||
+ ( getProto(b) === null && getProto(a) === Object.prototype ) ) ) {
+ return false;
}
}
- aProperties.push(i); // collect a's properties
- if (!loop && !innerEquiv(a[i], b[i])) {
- eq = false;
- break;
+ // stack constructor before traversing properties
+ callers.push( a.constructor );
+ // track reference to avoid circular references
+ parents.push( a );
+
+ for ( i in a ) { // be strict: don't ensures hasOwnProperty
+ // and go deep
+ loop = false;
+ for ( j = 0; j < parents.length; j++ ) {
+ if ( parents[j] === a[i] ) {
+ // don't go down the same path twice
+ loop = true;
+ }
+ }
+ aProperties.push(i); // collect a's properties
+
+ if (!loop && !innerEquiv( a[i], b[i] ) ) {
+ eq = false;
+ break;
+ }
}
- }
- callers.pop(); // unstack, we are done
- parents.pop();
+ callers.pop(); // unstack, we are done
+ parents.pop();
- for (i in b) {
- bProperties.push(i); // collect b's properties
- }
+ for ( i in b ) {
+ bProperties.push( i ); // collect b's properties
+ }
- // Ensures identical properties name
- return eq && innerEquiv(aProperties.sort(), bProperties.sort());
- }
- };
- }());
+ // Ensures identical properties name
+ return eq && innerEquiv( aProperties.sort(), bProperties.sort() );
+ }
+ };
+ }());
innerEquiv = function() { // can take multiple arguments
- var args = Array.prototype.slice.apply(arguments);
- if (args.length < 2) {
+ var args = [].slice.apply( arguments );
+ if ( args.length < 2 ) {
return true; // end transition
}
- return (function(a, b) {
- if (a === b) {
+ return (function( a, b ) {
+ if ( a === b ) {
return true; // catch the most you can
- } else if (a === null || b === null || typeof a === "undefined" ||
+ } else if ( a === null || b === null || typeof a === "undefined" ||
typeof b === "undefined" ||
- QUnit.objectType(a) !== QUnit.objectType(b)) {
+ QUnit.objectType(a) !== QUnit.objectType(b) ) {
return false; // don't lose time with error prone cases
} else {
return bindCallbacks(a, callbacks, [ b, a ]);
}
// apply transition with (1..n) arguments
- }(args[0], args[1]) && arguments.callee.apply(this, args.splice(1, args.length - 1)));
+ }( args[0], args[1] ) && arguments.callee.apply( this, args.splice(1, args.length - 1 )) );
};
return innerEquiv;
-
}());
/**
@@ -1279,17 +1363,17 @@ QUnit.equiv = (function() {
*/
QUnit.jsDump = (function() {
function quote( str ) {
- return '"' + str.toString().replace(/"/g, '\\"') + '"';
+ return '"' + str.toString().replace( /"/g, '\\"' ) + '"';
}
function literal( o ) {
- return o + '';
+ return o + "";
}
function join( pre, arr, post ) {
var s = jsDump.separator(),
base = jsDump.indent(),
inner = jsDump.indent(1);
if ( arr.join ) {
- arr = arr.join( ',' + s + inner );
+ arr = arr.join( "," + s + inner );
}
if ( !arr ) {
return pre + post;
@@ -1303,182 +1387,191 @@ QUnit.jsDump = (function() {
ret[i] = this.parse( arr[i] , undefined , stack);
}
this.down();
- return join( '[', ret, ']' );
+ return join( "[", ret, "]" );
}
- var reName = /^function (\w+)/;
+ var reName = /^function (\w+)/,
+ jsDump = {
+ parse: function( obj, type, stack ) { //type is used mostly internally, you can fix a (custom)type in advance
+ stack = stack || [ ];
+ var inStack, res,
+ parser = this.parsers[ type || this.typeOf(obj) ];
- var jsDump = {
- parse: function( obj, type, stack ) { //type is used mostly internally, you can fix a (custom)type in advance
- stack = stack || [ ];
- var parser = this.parsers[ type || this.typeOf(obj) ];
- type = typeof parser;
- var inStack = inArray(obj, stack);
- if (inStack != -1) {
- return 'recursion('+(inStack - stack.length)+')';
- }
- //else
- if (type == 'function') {
- stack.push(obj);
- var res = parser.call( this, obj, stack );
+ type = typeof parser;
+ inStack = inArray( obj, stack );
+
+ if ( inStack != -1 ) {
+ return "recursion(" + (inStack - stack.length) + ")";
+ }
+ //else
+ if ( type == "function" ) {
+ stack.push( obj );
+ res = parser.call( this, obj, stack );
stack.pop();
return res;
- }
- // else
- return (type == 'string') ? parser : this.parsers.error;
- },
- typeOf: function( obj ) {
- var type;
- if ( obj === null ) {
- type = "null";
- } else if (typeof obj === "undefined") {
- type = "undefined";
- } else if (QUnit.is("RegExp", obj)) {
- type = "regexp";
- } else if (QUnit.is("Date", obj)) {
- type = "date";
- } else if (QUnit.is("Function", obj)) {
- type = "function";
- } else if (typeof obj.setInterval !== undefined && typeof obj.document !== "undefined" && typeof obj.nodeType === "undefined") {
- type = "window";
- } else if (obj.nodeType === 9) {
- type = "document";
- } else if (obj.nodeType) {
- type = "node";
- } else if (
- // native arrays
- toString.call( obj ) === "[object Array]" ||
- // NodeList objects
- ( typeof obj.length === "number" && typeof obj.item !== "undefined" && ( obj.length ? obj.item(0) === obj[0] : ( obj.item( 0 ) === null && typeof obj[0] === "undefined" ) ) )
- ) {
- type = "array";
- } else {
- type = typeof obj;
- }
- return type;
- },
- separator: function() {
- return this.multiline ? this.HTML ? '<br />' : '\n' : this.HTML ? '&nbsp;' : ' ';
- },
- indent: function( extra ) {// extra can be a number, shortcut for increasing-calling-decreasing
- if ( !this.multiline ) {
- return '';
- }
- var chr = this.indentChar;
- if ( this.HTML ) {
- chr = chr.replace(/\t/g,' ').replace(/ /g,'&nbsp;');
- }
- return new Array( this._depth_ + (extra||0) ).join(chr);
- },
- up: function( a ) {
- this._depth_ += a || 1;
- },
- down: function( a ) {
- this._depth_ -= a || 1;
- },
- setParser: function( name, parser ) {
- this.parsers[name] = parser;
- },
- // The next 3 are exposed so you can use them
- quote: quote,
- literal: literal,
- join: join,
- //
- _depth_: 1,
- // This is the list of parsers, to modify them, use jsDump.setParser
- parsers: {
- window: '[Window]',
- document: '[Document]',
- error: '[ERROR]', //when no parser is found, shouldn't happen
- unknown: '[Unknown]',
- 'null': 'null',
- 'undefined': 'undefined',
- 'function': function( fn ) {
- var ret = 'function',
- name = 'name' in fn ? fn.name : (reName.exec(fn)||[])[1];//functions never have name in IE
- if ( name ) {
- ret += ' ' + name;
}
- ret += '(';
-
- ret = [ ret, QUnit.jsDump.parse( fn, 'functionArgs' ), '){'].join('');
- return join( ret, QUnit.jsDump.parse(fn,'functionCode'), '}' );
+ // else
+ return ( type == "string" ) ? parser : this.parsers.error;
},
- array: array,
- nodelist: array,
- 'arguments': array,
- object: function( map, stack ) {
- var ret = [ ], keys, key, val, i;
- QUnit.jsDump.up();
- if (Object.keys) {
- keys = Object.keys( map );
+ typeOf: function( obj ) {
+ var type;
+ if ( obj === null ) {
+ type = "null";
+ } else if ( typeof obj === "undefined" ) {
+ type = "undefined";
+ } else if ( QUnit.is( "RegExp", obj) ) {
+ type = "regexp";
+ } else if ( QUnit.is( "Date", obj) ) {
+ type = "date";
+ } else if ( QUnit.is( "Function", obj) ) {
+ type = "function";
+ } else if ( typeof obj.setInterval !== undefined && typeof obj.document !== "undefined" && typeof obj.nodeType === "undefined" ) {
+ type = "window";
+ } else if ( obj.nodeType === 9 ) {
+ type = "document";
+ } else if ( obj.nodeType ) {
+ type = "node";
+ } else if (
+ // native arrays
+ toString.call( obj ) === "[object Array]" ||
+ // NodeList objects
+ ( typeof obj.length === "number" && typeof obj.item !== "undefined" && ( obj.length ? obj.item(0) === obj[0] : ( obj.item( 0 ) === null && typeof obj[0] === "undefined" ) ) )
+ ) {
+ type = "array";
} else {
- keys = [];
- for (key in map) { keys.push( key ); }
+ type = typeof obj;
+ }
+ return type;
+ },
+ separator: function() {
+ return this.multiline ? this.HTML ? "<br />" : "\n" : this.HTML ? "&nbsp;" : " ";
+ },
+ indent: function( extra ) {// extra can be a number, shortcut for increasing-calling-decreasing
+ if ( !this.multiline ) {
+ return "";
}
- keys.sort();
- for (i = 0; i < keys.length; i++) {
- key = keys[ i ];
- val = map[ key ];
- ret.push( QUnit.jsDump.parse( key, 'key' ) + ': ' + QUnit.jsDump.parse( val, undefined, stack ) );
+ var chr = this.indentChar;
+ if ( this.HTML ) {
+ chr = chr.replace( /\t/g, " " ).replace( / /g, "&nbsp;" );
}
- QUnit.jsDump.down();
- return join( '{', ret, '}' );
+ return new Array( this._depth_ + (extra||0) ).join(chr);
},
- node: function( node ) {
- var open = QUnit.jsDump.HTML ? '&lt;' : '<',
- close = QUnit.jsDump.HTML ? '&gt;' : '>';
-
- var tag = node.nodeName.toLowerCase(),
- ret = open + tag;
+ up: function( a ) {
+ this._depth_ += a || 1;
+ },
+ down: function( a ) {
+ this._depth_ -= a || 1;
+ },
+ setParser: function( name, parser ) {
+ this.parsers[name] = parser;
+ },
+ // The next 3 are exposed so you can use them
+ quote: quote,
+ literal: literal,
+ join: join,
+ //
+ _depth_: 1,
+ // This is the list of parsers, to modify them, use jsDump.setParser
+ parsers: {
+ window: "[Window]",
+ document: "[Document]",
+ error: "[ERROR]", //when no parser is found, shouldn"t happen
+ unknown: "[Unknown]",
+ "null": "null",
+ "undefined": "undefined",
+ "function": function( fn ) {
+ var ret = "function",
+ name = "name" in fn ? fn.name : (reName.exec(fn) || [])[1];//functions never have name in IE
+
+ if ( name ) {
+ ret += " " + name;
+ }
+ ret += "( ";
+
+ ret = [ ret, QUnit.jsDump.parse( fn, "functionArgs" ), "){" ].join( "" );
+ return join( ret, QUnit.jsDump.parse(fn,"functionCode" ), "}" );
+ },
+ array: array,
+ nodelist: array,
+ "arguments": array,
+ object: function( map, stack ) {
+ var ret = [ ], keys, key, val, i;
+ QUnit.jsDump.up();
+ if ( Object.keys ) {
+ keys = Object.keys( map );
+ } else {
+ keys = [];
+ for ( key in map ) {
+ keys.push( key );
+ }
+ }
+ keys.sort();
+ for ( i = 0; i < keys.length; i++ ) {
+ key = keys[ i ];
+ val = map[ key ];
+ ret.push( QUnit.jsDump.parse( key, "key" ) + ": " + QUnit.jsDump.parse( val, undefined, stack ) );
+ }
+ QUnit.jsDump.down();
+ return join( "{", ret, "}" );
+ },
+ node: function( node ) {
+ var a, val,
+ open = QUnit.jsDump.HTML ? "&lt;" : "<",
+ close = QUnit.jsDump.HTML ? "&gt;" : ">",
+ tag = node.nodeName.toLowerCase(),
+ ret = open + tag;
+
+ for ( a in QUnit.jsDump.DOMAttrs ) {
+ val = node[ QUnit.jsDump.DOMAttrs[a] ];
+ if ( val ) {
+ ret += " " + a + "=" + QUnit.jsDump.parse( val, "attribute" );
+ }
+ }
+ return ret + close + open + "/" + tag + close;
+ },
+ functionArgs: function( fn ) {//function calls it internally, it's the arguments part of the function
+ var args,
+ l = fn.length;
+
+ if ( !l ) {
+ return "";
+ }
- for ( var a in QUnit.jsDump.DOMAttrs ) {
- var val = node[QUnit.jsDump.DOMAttrs[a]];
- if ( val ) {
- ret += ' ' + a + '=' + QUnit.jsDump.parse( val, 'attribute' );
+ args = new Array(l);
+ while ( l-- ) {
+ args[l] = String.fromCharCode(97+l);//97 is 'a'
}
- }
- return ret + close + open + '/' + tag + close;
+ return " " + args.join( ", " ) + " ";
+ },
+ key: quote, //object calls it internally, the key part of an item in a map
+ functionCode: "[code]", //function calls it internally, it's the content of the function
+ attribute: quote, //node calls it internally, it's an html attribute value
+ string: quote,
+ date: quote,
+ regexp: literal, //regex
+ number: literal,
+ "boolean": literal
},
- functionArgs: function( fn ) {//function calls it internally, it's the arguments part of the function
- var l = fn.length;
- if ( !l ) {
- return '';
- }
-
- var args = new Array(l);
- while ( l-- ) {
- args[l] = String.fromCharCode(97+l);//97 is 'a'
- }
- return ' ' + args.join(', ') + ' ';
+ DOMAttrs: {
+ //attributes to dump from nodes, name=>realName
+ id: "id",
+ name: "name",
+ "class": "className"
},
- key: quote, //object calls it internally, the key part of an item in a map
- functionCode: '[code]', //function calls it internally, it's the content of the function
- attribute: quote, //node calls it internally, it's an html attribute value
- string: quote,
- date: quote,
- regexp: literal, //regex
- number: literal,
- 'boolean': literal
- },
- DOMAttrs:{//attributes to dump from nodes, name=>realName
- id:'id',
- name:'name',
- 'class':'className'
- },
- HTML:false,//if true, entities are escaped ( <, >, \t, space and \n )
- indentChar:' ',//indentation unit
- multiline:true //if true, items in a collection, are separated by a \n, else just a space.
- };
+ HTML: false,//if true, entities are escaped ( <, >, \t, space and \n )
+ indentChar: " ",//indentation unit
+ multiline: true //if true, items in a collection, are separated by a \n, else just a space.
+ };
return jsDump;
}());
// from Sizzle.js
function getText( elems ) {
- var ret = "", elem;
+ var i, elem,
+ ret = "";
- for ( var i = 0; elems[i]; i++ ) {
+ for ( i = 0; elems[i]; i++ ) {
elem = elems[i];
// Get the text from text nodes and CDATA nodes
@@ -1494,7 +1587,7 @@ function getText( elems ) {
return ret;
}
-//from jquery.js
+// from jquery.js
function inArray( elem, array ) {
if ( array.indexOf ) {
return array.indexOf( elem );
@@ -1521,73 +1614,75 @@ function inArray( elem, array ) {
*
* Usage: QUnit.diff(expected, actual)
*
- * QUnit.diff("the quick brown fox jumped over", "the quick fox jumps over") == "the quick <del>brown </del> fox <del>jumped </del><ins>jumps </ins> over"
+ * QUnit.diff( "the quick brown fox jumped over", "the quick fox jumps over" ) == "the quick <del>brown </del> fox <del>jumped </del><ins>jumps </ins> over"
*/
QUnit.diff = (function() {
- function diff(o, n) {
- var ns = {};
- var os = {};
- var i;
-
- for (i = 0; i < n.length; i++) {
- if (ns[n[i]] == null) {
- ns[n[i]] = {
+ function diff( o, n ) {
+ var i,
+ ns = {},
+ os = {};
+
+ for ( i = 0; i < n.length; i++ ) {
+ if ( ns[ n[i] ] == null ) {
+ ns[ n[i] ] = {
rows: [],
o: null
};
}
- ns[n[i]].rows.push(i);
+ ns[ n[i] ].rows.push( i );
}
- for (i = 0; i < o.length; i++) {
- if (os[o[i]] == null) {
- os[o[i]] = {
+ for ( i = 0; i < o.length; i++ ) {
+ if ( os[ o[i] ] == null ) {
+ os[ o[i] ] = {
rows: [],
n: null
};
}
- os[o[i]].rows.push(i);
+ os[ o[i] ].rows.push( i );
}
- for (i in ns) {
+ for ( i in ns ) {
if ( !hasOwn.call( ns, i ) ) {
continue;
}
- if (ns[i].rows.length == 1 && typeof(os[i]) != "undefined" && os[i].rows.length == 1) {
- n[ns[i].rows[0]] = {
- text: n[ns[i].rows[0]],
+ if ( ns[i].rows.length == 1 && typeof os[i] != "undefined" && os[i].rows.length == 1 ) {
+ n[ ns[i].rows[0] ] = {
+ text: n[ ns[i].rows[0] ],
row: os[i].rows[0]
};
- o[os[i].rows[0]] = {
- text: o[os[i].rows[0]],
+ o[ os[i].rows[0] ] = {
+ text: o[ os[i].rows[0] ],
row: ns[i].rows[0]
};
}
}
- for (i = 0; i < n.length - 1; i++) {
- if (n[i].text != null && n[i + 1].text == null && n[i].row + 1 < o.length && o[n[i].row + 1].text == null &&
- n[i + 1] == o[n[i].row + 1]) {
- n[i + 1] = {
- text: n[i + 1],
+ for ( i = 0; i < n.length - 1; i++ ) {
+ if ( n[i].text != null && n[ i + 1 ].text == null && n[i].row + 1 < o.length && o[ n[i].row + 1 ].text == null &&
+ n[ i + 1 ] == o[ n[i].row + 1 ] ) {
+
+ n[ i + 1 ] = {
+ text: n[ i + 1 ],
row: n[i].row + 1
};
- o[n[i].row + 1] = {
- text: o[n[i].row + 1],
+ o[ n[i].row + 1 ] = {
+ text: o[ n[i].row + 1 ],
row: i + 1
};
}
}
- for (i = n.length - 1; i > 0; i--) {
- if (n[i].text != null && n[i - 1].text == null && n[i].row > 0 && o[n[i].row - 1].text == null &&
- n[i - 1] == o[n[i].row - 1]) {
- n[i - 1] = {
- text: n[i - 1],
+ for ( i = n.length - 1; i > 0; i-- ) {
+ if ( n[i].text != null && n[ i - 1 ].text == null && n[i].row > 0 && o[ n[i].row - 1 ].text == null &&
+ n[ i - 1 ] == o[ n[i].row - 1 ]) {
+
+ n[ i - 1 ] = {
+ text: n[ i - 1 ],
row: n[i].row - 1
};
- o[n[i].row - 1] = {
- text: o[n[i].row - 1],
+ o[ n[i].row - 1 ] = {
+ text: o[ n[i].row - 1 ],
row: i - 1
};
}
@@ -1599,50 +1694,52 @@ QUnit.diff = (function() {
};
}
- return function(o, n) {
- o = o.replace(/\s+$/, '');
- n = n.replace(/\s+$/, '');
- var out = diff(o === "" ? [] : o.split(/\s+/), n === "" ? [] : n.split(/\s+/));
+ return function( o, n ) {
+ o = o.replace( /\s+$/, "" );
+ n = n.replace( /\s+$/, "" );
- var str = "";
- var i;
+ var i, pre,
+ str = "",
+ out = diff( o === "" ? [] : o.split(/\s+/), n === "" ? [] : n.split(/\s+/) ),
+ oSpace = o.match(/\s+/g),
+ nSpace = n.match(/\s+/g);
- var oSpace = o.match(/\s+/g);
- if (oSpace == null) {
- oSpace = [" "];
+ if ( oSpace == null ) {
+ oSpace = [ " " ];
}
else {
- oSpace.push(" ");
+ oSpace.push( " " );
}
- var nSpace = n.match(/\s+/g);
- if (nSpace == null) {
- nSpace = [" "];
+
+ if ( nSpace == null ) {
+ nSpace = [ " " ];
}
else {
- nSpace.push(" ");
+ nSpace.push( " " );
}
- if (out.n.length === 0) {
- for (i = 0; i < out.o.length; i++) {
- str += '<del>' + out.o[i] + oSpace[i] + "</del>";
+ if ( out.n.length === 0 ) {
+ for ( i = 0; i < out.o.length; i++ ) {
+ str += "<del>" + out.o[i] + oSpace[i] + "</del>";
}
}
else {
- if (out.n[0].text == null) {
- for (n = 0; n < out.o.length && out.o[n].text == null; n++) {
- str += '<del>' + out.o[n] + oSpace[n] + "</del>";
+ if ( out.n[0].text == null ) {
+ for ( n = 0; n < out.o.length && out.o[n].text == null; n++ ) {
+ str += "<del>" + out.o[n] + oSpace[n] + "</del>";
}
}
- for (i = 0; i < out.n.length; i++) {
+ for ( i = 0; i < out.n.length; i++ ) {
if (out.n[i].text == null) {
- str += '<ins>' + out.n[i] + nSpace[i] + "</ins>";
+ str += "<ins>" + out.n[i] + nSpace[i] + "</ins>";
}
else {
- var pre = "";
+ // `pre` initialized at top of scope
+ pre = "";
- for (n = out.n[i].row + 1; n < out.o.length && out.o[n].text == null; n++) {
- pre += '<del>' + out.o[n] + oSpace[n] + "</del>";
+ for ( n = out.n[i].row + 1; n < out.o.length && out.o[n].text == null; n++ ) {
+ pre += "<del>" + out.o[n] + oSpace[n] + "</del>";
}
str += " " + out.n[i].text + nSpace[i] + pre;
}
@@ -1654,7 +1751,7 @@ QUnit.diff = (function() {
}());
// for CommonJS enviroments, export everything
-if ( typeof exports !== "undefined" || typeof require !== "undefined" ) {
+if ( typeof exports !== "undefined" ) {
extend(exports, QUnit);
}
diff --git a/grunt.js b/grunt.js
index 74713be5d..202779e0b 100644
--- a/grunt.js
+++ b/grunt.js
@@ -1,11 +1,10 @@
+/*jshint node: true */
module.exports = function( grunt ) {
var // modules
fs = require( "fs" ),
path = require( "path" ),
request = require( "request" ),
- util = require( "util" ),
- inspect = util.inspect,
// files
coreFiles = [
@@ -56,20 +55,37 @@ var // modules
minifyCSS = {
"dist/jquery-ui.min.css": "dist/jquery-ui.css"
+ },
+
+ compareFiles = {
+ all: [
+ "dist/jquery-ui.js",
+ "dist/jquery-ui.min.js"
+ ]
};
+function mapMinFile( file ) {
+ return "dist/" + file.replace( /\.js$/, ".min.js" ).replace( /ui\//, "minified/" );
+}
uiFiles.concat( allI18nFiles ).forEach(function( file ) {
- minify[ "dist/" + file.replace( /\.js$/, ".min.js" ).replace( /ui\//, "minified/" ) ] = [ "<banner>", file ];
+ minify[ mapMinFile( file ) ] = [ "<banner>", file ];
});
cssFiles.forEach(function( file ) {
minifyCSS[ "dist/" + file.replace( /\.css$/, ".min.css" ).replace( /themes\/base\//, "themes/base/minified/" ) ] = [ "<banner>", "<strip_all_banners:" + file + ">" ];
});
+uiFiles.forEach(function( file ) {
+ compareFiles[ file ] = [ file, mapMinFile( file ) ];
+});
// csslint and cssmin tasks
grunt.loadNpmTasks( "grunt-css" );
+// file size comparison tasks
+grunt.loadNpmTasks( "grunt-compare-size" );
+// html validation task
+grunt.loadNpmTasks( "grunt-html" );
grunt.registerHelper( "strip_all_banners", function( filepath ) {
return grunt.file.read( filepath ).replace( /^\s*\/\*[\s\S]*?\*\/\s*/g, "" );
@@ -113,12 +129,7 @@ grunt.initConfig({
bannerI18n: createBanner( allI18nFiles ),
bannerCSS: createBanner( cssFiles )
},
- compare_size: {
- files: [
- "dist/jquery-ui.js",
- "dist/jquery-ui.min.js"
- ]
- },
+ compare_size: compareFiles,
concat: {
ui: {
src: [ "<banner:meta.bannerAll>", stripBanner( uiFiles ) ],
@@ -135,6 +146,12 @@ grunt.initConfig({
},
min: minify,
cssmin: minifyCSS,
+ htmllint: {
+ // ignore files that contain invalid html, used only for ajax content testing
+ all: grunt.file.expand( [ "demos/**/*.html", "tests/**/*.html" ] ).filter(function( file ) {
+ return !/(?:ajax\/content\d\.html|tabs\/data\/test\.html|tests\/unit\/core\/core\.html)/.test( file );
+ })
+ },
copy: {
dist: {
src: [
@@ -171,6 +188,11 @@ grunt.initConfig({
strip: /^dist/,
dest: "dist/<%= files.dist %>"
},
+ dist_units_images: {
+ src: "themes/base/images/*",
+ strip: /^themes\/base\//,
+ dest: "dist/"
+ },
dist_min_images: {
src: "themes/base/images/*",
strip: /^themes\/base\//,
@@ -260,115 +282,142 @@ grunt.initConfig({
qunit: {
files: grunt.file.expandFiles( "tests/unit/**/*.html" ).filter(function( file ) {
// disabling everything that doesn't (quite) work with PhantomJS for now
- // except for all|index|test, try to include more as we go
- return !( /(all|index|test|draggable|droppable|selectable|resizable|sortable|dialog|slider|datepicker|tabs|tabs_deprecated)\.html/ ).test( file );
+ // TODO except for all|index|test, try to include more as we go
+ return !( /(all|all-active|index|test|draggable|droppable|selectable|resizable|sortable|dialog|slider|datepicker|tabs|tabs_deprecated)\.html$/ ).test( file );
})
},
lint: {
- ui: "ui/*",
+ ui: grunt.file.expandFiles( "ui/*.js" ).filter(function( file ) {
+ // TODO remove items from this list once rewritten
+ return !( /(effects.core|mouse|datepicker|draggable|droppable|resizable|selectable|sortable)\.js$/ ).test( file );
+ }),
grunt: "grunt.js",
tests: "tests/unit/**/*.js"
},
csslint: {
+ // nothing: []
+ // TODO figure out what to check for, then fix and enable
base_theme: {
- src: "themes/base/*.css",
+ src: grunt.file.expandFiles( "themes/base/*.css" ).filter(function( file ) {
+ // TODO remove items from this list once rewritten
+ return !( /(button|datepicker|core|dialog|theme)\.css$/ ).test( file );
+ }),
+ // TODO consider reenabling some of these rules
rules: {
"import": false,
- "overqualified-elements": 2
+ "important": false,
+ "outline-none": false,
+ // especially this one
+ "overqualified-elements": false
}
}
},
jshint: (function() {
- var defaults = {
- curly: true,
- eqnull: true,
- eqeqeq: true,
- expr: true,
- latedef: true,
- noarg: true,
- onevar: true,
- // TODO: limit to multi-line comments https://github.com/jshint/jshint/issues/503
- smarttabs: true,
- // TODO: use "faux strict mode" https://github.com/jshint/jshint/issues/504
- // strict: true,
- // TODO: enable trailing
- // trailing: true,
- undef: true
- };
+ function parserc( path ) {
+ var rc = grunt.file.readJSON( (path || "") + ".jshintrc" ),
+ settings = {
+ options: rc,
+ globals: {}
+ };
+
+ (rc.predef || []).forEach(function( prop ) {
+ settings.globals[ prop ] = true;
+ });
+ delete rc.predef;
- function extend( a, b ) {
- for ( var prop in b ) {
- a[ prop ] = b[ prop ];
- }
- return a;
+ return settings;
}
return {
- options: defaults,
- grunt: {
- options: extend({
- node: true
- }, defaults ),
- globals: {
- task: true,
- config: true,
- file: true,
- log: true,
- template: true
- }
- },
- ui: {
- options: extend({
- browser: true,
- jquery: true
- }, defaults ),
- globals: {
- Globalize: true
- }
- },
- tests: {
- options: extend({
- browser: true,
- jquery: true
- }, defaults ),
- globals: {
- module: true,
- test: true,
- ok: true,
- equal: true,
- deepEqual: true,
- QUnit: true
- }
- }
+ // TODO: use "faux strict mode" https://github.com/jshint/jshint/issues/504
+ // TODO: limit `smarttabs` to multi-line comments https://github.com/jshint/jshint/issues/503
+ options: parserc(),
+ ui: parserc( "ui/" ),
+ // TODO: `evil: true` is only for document.write() https://github.com/jshint/jshint/issues/519
+ // TODO: don't create so many globals in tests
+ tests: parserc( "tests/" )
};
})()
});
+grunt.registerTask( "testswarm", function( commit, configFile ) {
+ var test,
+ testswarm = require( "testswarm" ),
+ testBase = "http://swarm.jquery.org/git/jquery-ui/" + commit + "/tests/unit/",
+ testUrls = [],
+ tests = {
+ "Accordion": "accordion/accordion.html",
+ "Accordion_deprecated": "accordion/accordion_deprecated.html",
+ "Autocomplete": "autocomplete/autocomplete.html",
+ "Button": "button/button.html",
+ "Core": "core/core.html",
+ //"datepicker/datepicker.html",
+ //"dialog/dialog.html",
+ //"draggable/draggable.html",
+ //"droppable/droppable.html",
+ "Effects": "effects/effects.html",
+ "Menu": "menu/menu.html",
+ "Position": "position/position.html",
+ "Position_deprecated": "position/position_deprecated.html",
+ "Progressbar": "progressbar/progressbar.html",
+ //"resizable/resizable.html",
+ //"selectable/selectable.html",
+ //"slider/slider.html",
+ //"sortable/sortable.html",
+ "Spinner": "spinner/spinner.html",
+ "Tabs": "tabs/tabs.html",
+ "Tabs_deprecated": "tabs/tabs_deprecated.html",
+ "Tooltip": "tooltip/tooltip.html",
+ "Widget": "widget/widget.html"
+ };
+ for ( test in tests ) {
+ testUrls.push( testBase + tests[ test ] + "?nojshint=true" );
+ }
+ testswarm({
+ url: "http://swarm.jquery.org/",
+ pollInterval: 10000,
+ timeout: 1000 * 60 * 20,
+ done: this.async()
+ }, {
+ authUsername: "jqueryui",
+ authToken: grunt.file.readJSON( configFile ).jqueryui.authToken,
+ jobName: 'jQuery UI commit #<a href="https://github.com/jquery/jquery-ui/commit/' + commit + '">' + commit.substr( 0, 10 ) + '</a>',
+ runMax: 3,
+ "runNames[]": Object.keys(tests),
+ "runUrls[]": testUrls,
+ "browserSets[]": ["popular"]
+ });
+});
+
grunt.registerMultiTask( "copy", "Copy files to destination folder and replace @VERSION with pkg.version", function() {
function replaceVersion( source ) {
- return source.replace( "@VERSION", grunt.config( "pkg.version" ) );
+ return source.replace( /@VERSION/g, grunt.config( "pkg.version" ) );
+ }
+ function copyFile( src, dest ) {
+ if ( /(js|css)$/.test( src ) ) {
+ grunt.file.copy( src, dest, {
+ process: replaceVersion
+ });
+ } else {
+ grunt.file.copy( src, dest );
+ }
}
- var files = grunt.file.expandFiles( this.file.src );
- var target = this.file.dest + "/";
- var strip = this.data.strip;
+ var files = grunt.file.expandFiles( this.file.src ),
+ target = this.file.dest + "/",
+ strip = this.data.strip,
+ renameCount = 0,
+ fileName;
if ( typeof strip === "string" ) {
strip = new RegExp( "^" + grunt.template.process( strip, grunt.config() ).replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ) );
}
files.forEach(function( fileName ) {
var targetFile = strip ? fileName.replace( strip, "" ) : fileName;
- if ( /(js|css)$/.test( fileName ) ) {
- grunt.file.copy( fileName, target + targetFile, {
- process: replaceVersion
- });
- } else {
- grunt.file.copy( fileName, target + targetFile );
- }
+ copyFile( fileName, target + targetFile );
});
grunt.log.writeln( "Copied " + files.length + " files." );
- var renameCount = 0;
- for ( var fileName in this.data.renames ) {
+ for ( fileName in this.data.renames ) {
renameCount += 1;
- grunt.file.copy( fileName, target + grunt.template.process( this.data.renames[ fileName ], grunt.config() ) );
+ copyFile( fileName, target + grunt.template.process( this.data.renames[ fileName ], grunt.config() ) );
}
if ( renameCount ) {
grunt.log.writeln( "Renamed " + renameCount + " files." );
@@ -393,9 +442,9 @@ grunt.registerMultiTask( "zip", "Create a zip file for release", function() {
//zip.writeZip( "dist/" + this.file.dest );
//grunt.log.writeln( "Wrote " + files.length + " files to " + this.file.dest );
- var done = this.async();
- var dest = this.file.dest;
- var src = grunt.template.process( this.file.src, grunt.config() );
+ var done = this.async(),
+ dest = this.file.dest,
+ src = grunt.template.process( this.file.src, grunt.config() );
grunt.utils.spawn({
cmd: "zip",
args: [ "-r", dest, src ],
@@ -418,9 +467,9 @@ grunt.registerMultiTask( "md5", "Create list of md5 hashes for CDN uploads", fun
if ( path.existsSync( this.file.dest ) ) {
fs.unlinkSync( this.file.dest );
}
- var crypto = require( "crypto" );
- var dir = this.file.src + "/";
- var hashes = [];
+ var crypto = require( "crypto" ),
+ dir = this.file.src + "/",
+ hashes = [];
grunt.file.expandFiles( dir + "**/*" ).forEach(function( fileName ) {
var hash = crypto.createHash( "md5" );
hash.update( grunt.file.read( fileName, "ascii" ) );
@@ -436,15 +485,15 @@ grunt.registerTask( "download_docs", function() {
return value[0].toUpperCase() + value.slice(1);
}
// should be grunt.config("pkg.version")?
- var version = "1.8";
- var docsDir = "dist/docs";
- var files = "draggable droppable resizable selectable sortable accordion autocomplete button datepicker dialog progressbar slider tabs position"
- .split(" ").map(function(widget) {
- return {
- url: "http://docs.jquery.com/action/render/UI/API/" + version + "/" + capitalize(widget),
- dest: docsDir + '/' + widget + '.html'
- };
- });
+ var version = "1.8",
+ docsDir = "dist/docs",
+ files = "draggable droppable resizable selectable sortable accordion autocomplete button datepicker dialog progressbar slider tabs position"
+ .split(" ").map(function(widget) {
+ return {
+ url: "http://docs.jquery.com/action/render/UI/API/" + version + "/" + capitalize(widget),
+ dest: docsDir + '/' + widget + '.html'
+ };
+ });
files = files.concat("animate addClass effect hide removeClass show switchClass toggle toggleClass".split(" ").map(function(widget) {
return {
url: "http://docs.jquery.com/action/render/UI/Effects/" + widget,
@@ -467,15 +516,15 @@ grunt.registerTask( "download_docs", function() {
grunt.registerTask( "download_themes", function() {
// var AdmZip = require('adm-zip');
- var done = this.async();
- var themes = grunt.file.read( "build/themes" ).split(",");
- var requests = 0;
+ var done = this.async(),
+ themes = grunt.file.read( "build/themes" ).split(","),
+ requests = 0;
grunt.file.mkdir( "dist/tmp" );
themes.forEach(function( theme, index ) {
requests += 1;
grunt.file.mkdir( "dist/tmp/" + index );
- var zipFileName = "dist/tmp/" + index + ".zip";
- var out = fs.createWriteStream( zipFileName );
+ var zipFileName = "dist/tmp/" + index + ".zip",
+ out = fs.createWriteStream( zipFileName );
out.on( "close", function() {
grunt.log.writeln( "done downloading " + zipFileName );
// TODO AdmZip produces "crc32 checksum failed", need to figure out why
@@ -500,20 +549,19 @@ grunt.registerTask( "download_themes", function() {
grunt.registerTask( "copy_themes", function() {
// each package includes the base theme, ignore that
- var filter = /themes\/base/;
- var files = grunt.file.expandFiles( "dist/tmp/*/development-bundle/themes/**/*" ).filter(function( file ) {
- return !filter.test( file );
- });
- // TODO the grunt.template.process call shouldn't be necessary
- var target = "dist/" + grunt.template.process( grunt.config( "files.themes" ), grunt.config() ) + "/";
+ var filter = /themes\/base/,
+ files = grunt.file.expandFiles( "dist/tmp/*/development-bundle/themes/**/*" ).filter(function( file ) {
+ return !filter.test( file );
+ }),
+ // TODO the grunt.template.process call shouldn't be necessary
+ target = "dist/" + grunt.template.process( grunt.config( "files.themes" ), grunt.config() ) + "/",
+ distFolder = "dist/" + grunt.template.process( grunt.config( "files.dist" ), grunt.config() );
files.forEach(function( fileName ) {
var targetFile = fileName.replace( /dist\/tmp\/\d+\/development-bundle\//, "" ).replace( "jquery-ui-.custom", "jquery-ui" );
grunt.file.copy( fileName, target + targetFile );
});
// copy minified base theme from regular release
- // TODO same as the one above
- var distFolder = "dist/" + grunt.template.process( grunt.config( "files.dist" ), grunt.config() );
files = grunt.file.expandFiles( distFolder + "/themes/base/**/*" );
files.forEach(function( fileName ) {
grunt.file.copy( fileName, target + fileName.replace( distFolder, "" ) );
@@ -524,80 +572,10 @@ grunt.registerTask( "clean", function() {
require( "rimraf" ).sync( "dist" );
});
-// TODO merge with code in jQuery Core, share as grunt plugin/npm
-// this here actually uses the provided filenames in the output
-// the helpers should just be regular functions, no need to share those with the world
-grunt.registerMultiTask( "compare_size", "Compare size of this branch to master", function() {
- var files = grunt.file.expandFiles( this.file.src ),
- done = this.async(),
- sizecache = __dirname + "/dist/.sizecache.json",
- sources = {
- min: grunt.file.read( files[1] ),
- max: grunt.file.read( files[0] )
- },
- oldsizes = {},
- sizes = {};
-
- try {
- oldsizes = JSON.parse( grunt.file.read( sizecache ) );
- } catch( e ) {
- oldsizes = {};
- }
-
- // Obtain the current branch and continue...
- grunt.helper( "git_current_branch", function( err, branch ) {
- var key, diff;
-
- // Derived and adapted from Corey Frang's original `sizer`
- grunt.log.writeln( "sizes - compared to master" );
-
- sizes[ files[0] ] = sources.max.length;
- sizes[ files[1] ] = sources.min.length;
- sizes[ files[1] + ".gz" ] = grunt.helper( "gzip", sources.min ).length;
-
- for ( key in sizes ) {
- diff = oldsizes[ key ] && ( sizes[ key ] - oldsizes[ key ] );
- if ( diff > 0 ) {
- diff = "+" + diff;
- }
- console.log( "%s %s %s",
- grunt.helper("lpad", sizes[ key ], 8 ),
- grunt.helper("lpad", diff ? "(" + diff + ")" : "(-)", 8 ),
- key
- );
- }
-
- if ( branch === "master" ) {
- // If master, write to file - this makes it easier to compare
- // the size of your current code state to the master branch,
- // without returning to the master to reset the cache
- grunt.file.write( sizecache, JSON.stringify(sizes) );
- }
- done();
- });
-});
-grunt.registerHelper( "git_current_branch", function( done ) {
- grunt.utils.spawn({
- cmd: "git",
- args: [ "branch", "--no-color" ]
- }, function( err, result ) {
- var branch;
-
- result.split( "\n" ).forEach(function( branch ) {
- var matches = /^\* (.*)/.exec( branch );
- if ( matches !== null && matches.length && matches[ 1 ] ) {
- done( null, matches[ 1 ] );
- }
- });
- });
-});
-grunt.registerHelper( "lpad", function( str, len, chr ) {
- return ( Array( len + 1 ).join( chr || " " ) + str ).substr( -len );
-});
-
-grunt.registerTask( "default", "lint csslint qunit build compare_size" );
-grunt.registerTask( "sizer", "concat:ui min:dist/jquery-ui.min.js compare_size" );
-grunt.registerTask( "build", "concat min cssmin" );
+grunt.registerTask( "default", "lint csslint htmllint qunit" );
+grunt.registerTask( "sizer", "concat:ui min:dist/jquery-ui.min.js compare_size:all" );
+grunt.registerTask( "sizer_all", "concat:ui min compare_size" );
+grunt.registerTask( "build", "concat min cssmin copy:dist_units_images" );
grunt.registerTask( "release", "clean build copy:dist copy:dist_min copy:dist_min_images copy:dist_css_min md5:dist zip:dist" );
grunt.registerTask( "release_themes", "release download_themes copy_themes copy:themes md5:themes zip:themes" );
grunt.registerTask( "release_cdn", "release_themes copy:cdn copy:cdn_min copy:cdn_i18n copy:cdn_i18n_min copy:cdn_min_images copy:cdn_themes md5:cdn zip:cdn" );
diff --git a/package.json b/package.json
index 30e2b4898..8a83f3f94 100644
--- a/package.json
+++ b/package.json
@@ -26,10 +26,13 @@
],
"dependencies": {},
"devDependencies": {
- "grunt": "0.3.7",
- "grunt-css": "0.1.1",
+ "grunt": "0.3.9",
+ "grunt-css": "0.2.0",
+ "grunt-compare-size": "0.1.4",
+ "grunt-html": "0.1.1",
"request": "2.9.153",
- "rimraf": "2.0.1"
+ "rimraf": "2.0.1",
+ "testswarm": "0.2.2"
},
"keywords": []
-} \ No newline at end of file
+}
diff --git a/tests/.jshintrc b/tests/.jshintrc
new file mode 100644
index 000000000..783237218
--- /dev/null
+++ b/tests/.jshintrc
@@ -0,0 +1,59 @@
+{
+ "browser": true,
+ "curly": true,
+ "eqnull": true,
+ "eqeqeq": true,
+ "expr": true,
+ "evil": true,
+ "jquery": true,
+ "latedef": true,
+ "noarg": true,
+ "onevar": true,
+ "smarttabs": true,
+ "trailing": true,
+ "undef": true,
+ "predef": [
+ "addMonths",
+ "asyncTest",
+ "container",
+ "deepEqual",
+ "d1",
+ "d2",
+ "dlg",
+ "domEqual",
+ "drag",
+ "dragged",
+ "el",
+ "equal",
+ "equalsDate",
+ "expect",
+ "Globalize",
+ "heightAfter",
+ "init",
+ "isNotOpen",
+ "isOpen",
+ "modal",
+ "module",
+ "moved",
+ "notEqual",
+ "offsetAfter",
+ "offsetBefore",
+ "ok",
+ "PROP_NAME",
+ "QUnit",
+ "restoreScroll",
+ "shouldBeDroppable",
+ "shouldmove",
+ "shouldNotBeDroppable",
+ "shouldnotmove",
+ "shouldnotresize",
+ "shouldresize",
+ "start",
+ "strictEqual",
+ "stop",
+ "test",
+ "TestHelpers",
+ "widthAfter",
+ "JSHINT"
+ ]
+} \ No newline at end of file
diff --git a/tests/jquery.simulate.js b/tests/jquery.simulate.js
index a85ca6ef3..2dae34c28 100644
--- a/tests/jquery.simulate.js
+++ b/tests/jquery.simulate.js
@@ -243,7 +243,6 @@ $.extend( $.simulate.prototype, {
y = Math.floor( center.y ),
dx = options.dx || 0,
dy = options.dy || 0,
- target = this.target,
coord = { clientX: x, clientY: y };
this.simulateEvent( target, "mousedown", coord );
coord = { clientX: x + 1, clientY: y + 1 };
diff --git a/tests/resource_loader.js b/tests/resource_loader.js
deleted file mode 100644
index c8dec4881..000000000
--- a/tests/resource_loader.js
+++ /dev/null
@@ -1,39 +0,0 @@
-(function( $ ) {
-
-var parts = document.location.search.slice( 1 ).split( "&" ),
- length = parts.length,
- i = 0,
- current,
- min;
-
-for ( ; i < length; i++ ) {
- current = parts[ i ].split( "=" );
- if ( current[ 0 ] === "min" ) {
- min = current[ 1 ];
- break;
- }
-}
-
-function includeStyle( url ) {
- document.write( "<link rel='stylesheet' href='../../../" + url + "'>" );
-}
-
-function includeScript( url ) {
- document.write( "<script src='../../../" + url + "'></script>" );
-}
-
-window.loadResources = min ?
- function() {
- includeStyle( "build/dist/theme/jquery-ui.min.css" );
- includeScript( "build/dist/jquery-ui.min.js" );
- } :
- function( resources ) {
- $.each( resources.css || [], function( i, resource ) {
- includeStyle( "themes/base/jquery." + resource + ".css" );
- });
- $.each( resources.js || [], function( i, resource ) {
- includeScript( resource );
- });
- };
-
-})( jQuery );
diff --git a/tests/static/datepicker/datepicker.html b/tests/static/datepicker/datepicker.html
index 89be6b1eb..857677cfd 100644
--- a/tests/static/datepicker/datepicker.html
+++ b/tests/static/datepicker/datepicker.html
@@ -90,7 +90,7 @@
</tbody>
</table>
</div>
-
+
<!-- Datepicker with 1 combined select -->
<div class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all">
<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix ui-corner-all">
@@ -98,7 +98,7 @@
<a title="Next" class="ui-datepicker-next ui-corner-all" href="#"><span class="ui-icon ui-icon-circle-triangle-e">Next</span></a>
<div class="ui-datepicker-title">
<select class="ui-datepicker-month-year">
- <optgroup name="2007">
+ <optgroup label="2007">
<option value="2007_0">January 2007</option>
<option value="2007_1">February 2007</option>
<option value="2007_2">March 2007</option>
@@ -112,7 +112,7 @@
<option value="2007_10">November 2007</option>
<option value="2007_11">December 2007</option>
</optgroup>
- <optgroup name="2008">
+ <optgroup label="2008">
<option value="2008_0">January 2008</option>
<option value="2008_1">February 2008</option>
<option value="2008_2">March 2008</option>
@@ -126,7 +126,7 @@
<option value="2008_10">November 2008</option>
<option selected="selected" value="2008_11">December 2008</option>
</optgroup>
- <optgroup name="2009">
+ <optgroup label="2009">
<option value="2009_0">January 2009</option>
<option value="2009_1">February 2009</option>
<option value="2009_2">March 2009</option>
@@ -140,7 +140,7 @@
<option value="2009_10">November 2009</option>
<option value="2009_11">December 2009</option>
</optgroup>
- <optgroup name="2010">
+ <optgroup label="2010">
<option value="2010_0">January 2010</option>
<option value="2010_1">February 2010</option>
<option value="2010_2">March 2010</option>
@@ -430,11 +430,11 @@
<td class="ui-datepicker-week-end ui-datepicker-other-month ui-datepicker-unselectable ui-state-disabled"></td>
</tr>
</tbody>
- </table>
+ </table>
<div class="ui-datepicker-buttonpane ui-widget-content">
<button class="ui-state-default ui-priority-primary ui-corner-all">Done</button>
<button class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all">Today</button>
- </div>
+ </div>
</div>
<!-- Multiple Datepickers with read only month/year -->
@@ -649,7 +649,7 @@
</td></tr>
</tbody>
</table>
- </div>
+ </div>
<div class="ui-datepicker-group ui-datepicker-group-middle">
<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix">
<div class="ui-datepicker-title">
@@ -863,7 +863,7 @@
</td></tr>
</tbody>
</table>
- </div>
+ </div>
<div class="ui-datepicker-group ui-datepicker-group-middle">
<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix">
<div class="ui-datepicker-title">
@@ -924,7 +924,7 @@
<td class="ui-datepicker-week-end"><a href="#" class="ui-state-default">23</a></td>
<td class=""><a href="#" class="ui-state-default">24</a></td>
<td class=""><a href="#" class="ui-state-default">25</a></td>
- <td class=""><a href="#" class="ui-state-default">26</a></td>
+ <td class=""><a href="#" class="ui-state-default">26</a></td>
<td class=""><a href="#" class="ui-state-default">27</a></td>
<td class=""><a href="#" class="ui-state-default">28</a></td>
<td class="ui-datepicker-week-end"><a href="#" class="ui-state-default">29</a></td>
@@ -1077,8 +1077,8 @@
</td></tr>
</tbody>
</table>
- </div>
-
+ </div>
+
<div class="ui-datepicker-row-break"></div>
<div class="ui-datepicker-group ui-datepicker-group-first">
<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix">
@@ -1344,7 +1344,7 @@
<td class="ui-datepicker-week-end"><a href="#" class="ui-state-default">23</a></td>
<td class=""><a href="#" class="ui-state-default">24</a></td>
<td class=""><a href="#" class="ui-state-default">25</a></td>
- <td class=""><a href="#" class="ui-state-default">26</a></td>
+ <td class=""><a href="#" class="ui-state-default">26</a></td>
<td class=""><a href="#" class="ui-state-default">27</a></td>
<td class=""><a href="#" class="ui-state-default">28</a></td>
<td class="ui-datepicker-week-end"><a href="#" class="ui-state-default">29</a></td>
diff --git a/tests/static/icons.html b/tests/static/icons.html
index af2833442..d3ae3e348 100644
--- a/tests/static/icons.html
+++ b/tests/static/icons.html
@@ -16,12 +16,13 @@
ul {margin: 0; padding: 0;}
td div {margin: 2px; position: relative; padding: 4px 0; cursor: pointer; float: left; list-style: none;}
span.ui-icon { float: left; margin: 0 4px;}
+ .icon-collection { border-spacing: 0; border-collapse: collapse; }
</style>
<script type="text/javascript">
$(function(){
$('.ui-state-default').hover(
- function(){ $(this).addClass('ui-state-hover'); },
+ function(){ $(this).addClass('ui-state-hover'); },
function(){ $(this).removeClass('ui-state-hover'); }
);
@@ -36,7 +37,7 @@
<p class="icons"></p>
-<table class="ui-widget icon-collection" cellpaddding="0" cellspacing="0">
+<table class="ui-widget icon-collection">
<tr>
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-carat-1-n"><span class="ui-icon ui-icon-carat-1-n"></span></div></td>
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-carat-1-ne"><span class="ui-icon ui-icon-carat-1-ne"></span></div></td>
@@ -48,6 +49,12 @@
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-carat-1-nw"><span class="ui-icon ui-icon-carat-1-nw"></span></div></td>
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-carat-2-n-s"><span class="ui-icon ui-icon-carat-2-n-s"></span></div></td>
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-carat-2-e-w"><span class="ui-icon ui-icon-carat-2-e-w"></span></div></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
</tr>
<tr>
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-triangle-1-n"><span class="ui-icon ui-icon-triangle-1-n"></span></div></td>
@@ -60,6 +67,12 @@
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-triangle-1-nw"><span class="ui-icon ui-icon-triangle-1-nw"></span></div></td>
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-triangle-2-n-s"><span class="ui-icon ui-icon-triangle-2-n-s"></span></div></td>
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-triangle-2-e-w"><span class="ui-icon ui-icon-triangle-2-e-w"></span></div></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
</tr>
<tr>
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-arrow-1-n"><span class="ui-icon ui-icon-arrow-1-n"></span></div></td>
@@ -110,6 +123,10 @@
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-arrowrefresh-1-n"><span class="ui-icon ui-icon-arrowrefresh-1-n"></span></div></td>
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-arrowrefresh-1-e"><span class="ui-icon ui-icon-arrowrefresh-1-e"></span></div></td>
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-arrowrefresh-1-s"><span class="ui-icon ui-icon-arrowrefresh-1-s"></span></div></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
</tr>
<tr>
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-arrow-4"><span class="ui-icon ui-icon-arrow-4"></span></div></td>
@@ -120,6 +137,14 @@
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-shuffle"><span class="ui-icon ui-icon-shuffle"></span></div></td>
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-transfer-e-w"><span class="ui-icon ui-icon-transfer-e-w"></span></div></td>
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-transferthick-e-w"><span class="ui-icon ui-icon-transferthick-e-w"></span></div></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
</tr>
<tr>
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-folder-collapsed"><span class="ui-icon ui-icon-folder-collapsed"></span></div></td>
@@ -186,6 +211,12 @@
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-radio-on"><span class="ui-icon ui-icon-radio-on"></span></div></td>
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-pin-w"><span class="ui-icon ui-icon-pin-w"></span></div></td>
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-pin-s"><span class="ui-icon ui-icon-pin-s"></span></div></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
</tr>
<tr>
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-play"><span class="ui-icon ui-icon-play"></span></div></td>
@@ -198,6 +229,12 @@
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-eject"><span class="ui-icon ui-icon-eject"></span></div></td>
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-volume-off"><span class="ui-icon ui-icon-volume-off"></span></div></td>
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-volume-on"><span class="ui-icon ui-icon-volume-on"></span></div></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
</tr>
<tr>
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-power"><span class="ui-icon ui-icon-power"></span></div></td>
@@ -207,6 +244,15 @@
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-battery-1"><span class="ui-icon ui-icon-battery-1"></span></div></td>
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-battery-2"><span class="ui-icon ui-icon-battery-2"></span></div></td>
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-battery-3"><span class="ui-icon ui-icon-battery-3"></span></div></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
</tr>
<tr>
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-circle-plus"><span class="ui-icon ui-icon-circle-plus"></span></div></td>
@@ -223,6 +269,8 @@
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-circle-zoomin"><span class="ui-icon ui-icon-circle-zoomin"></span></div></td>
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-circle-zoomout"><span class="ui-icon ui-icon-circle-zoomout"></span></div></td>
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-circle-check"><span class="ui-icon ui-icon-circle-check"></span></div></td>
+ <td></td>
+ <td></td>
</tr>
<tr>
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-circlesmall-plus"><span class="ui-icon ui-icon-circlesmall-plus"></span></div></td>
@@ -231,6 +279,16 @@
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-squaresmall-plus"><span class="ui-icon ui-icon-squaresmall-plus"></span></div></td>
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-squaresmall-minus"><span class="ui-icon ui-icon-squaresmall-minus"></span></div></td>
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-squaresmall-close"><span class="ui-icon ui-icon-squaresmall-close"></span></div></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
</tr>
<tr>
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-grip-dotted-vertical"><span class="ui-icon ui-icon-grip-dotted-vertical"></span></div></td>
@@ -238,7 +296,17 @@
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-grip-solid-vertical"><span class="ui-icon ui-icon-grip-solid-vertical"></span></div></td>
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-grip-solid-horizontal"><span class="ui-icon ui-icon-grip-solid-horizontal"></span></div></td>
<td><div class="ui-state-default ui-corner-all" title=".ui-icon-gripsmall-diagonal-se"><span class="ui-icon ui-icon-gripsmall-diagonal-se"></span></div></td>
- <td><div class="ui-state-default ui-corner-all" title=".ui-icon-grip-diagonal-se"><span class="ui-icon ui-icon-grip-diagonal-se"></span></div></td></ul>
+ <td><div class="ui-state-default ui-corner-all" title=".ui-icon-grip-diagonal-se"><span class="ui-icon ui-icon-grip-diagonal-se"></span></div></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
</tr>
</table>
diff --git a/tests/unit/accordion/accordion.html b/tests/unit/accordion/accordion.html
index 5c9169ea3..b3b7caeae 100644
--- a/tests/unit/accordion/accordion.html
+++ b/tests/unit/accordion/accordion.html
@@ -8,9 +8,12 @@
<script>
$.uiBackCompat = false;
</script>
- <script src="../../resource_loader.js"></script>
+ <link rel="stylesheet" href="../../../external/qunit.css">
+ <script src="../../../external/qunit.js"></script>
+ <script src="../../jquery.simulate.js"></script>
+ <script src="../testsuite.js"></script>
<script>
- loadResources({
+ TestHelpers.loadResources({
css: [ "ui.core", "ui.accordion" ],
js: [
"ui/jquery.ui.core.js",
@@ -20,13 +23,8 @@
});
</script>
- <link rel="stylesheet" href="../../../external/qunit.css">
- <script src="../../../external/qunit.js"></script>
- <script src="../../jquery.simulate.js"></script>
- <script src="../testsuite.js"></script>
-
<script src="accordion_test_helpers.js"></script>
- <script src="accordion_defaults.js"></script>
+ <script src="accordion_common.js"></script>
<script src="accordion_core.js"></script>
<script src="accordion_events.js"></script>
<script src="accordion_methods.js"></script>
@@ -93,7 +91,7 @@
<li><a href="?p=1.1.1.3">Amps</a></li>
<li><a href="?p=1.1.1.4">Effects</a></li>
<li><a href="?p=1.1.1.5">Accessories</a></li>
- </ul>
+ </ul>
</li>
<li>
<h2><a href="?p=1.1.2"><span>Bass</span></a></h2>
@@ -105,7 +103,7 @@
<li><a href="?p=1.1.2.5">Accessories</a></li>
<li><a href="?p=1.1.2.5">Accessories</a></li>
<li><a href="?p=1.1.2.5">Accessories</a></li>
- </ul>
+ </ul>
</li>
<li>
<h2><a href="?p=1.1.3">Drums</a></h2>
@@ -113,7 +111,7 @@
<li><a href="?p=1.1.3.2">Acoustic</a></li>
<li><a href="?p=1.1.3.3">Electronic</a></li>
<li><a href="?p=1.1.3.6">Accessories</a></li>
- </ul>
+ </ul>
</li>
</ul>
</div>
diff --git a/tests/unit/accordion/accordion_defaults.js b/tests/unit/accordion/accordion_common.js
index 9ad85bbce..ef24cf25e 100644
--- a/tests/unit/accordion/accordion_defaults.js
+++ b/tests/unit/accordion/accordion_common.js
@@ -1,4 +1,4 @@
-commonWidgetTests( "accordion", {
+TestHelpers.commonWidgetTests( "accordion", {
defaults: {
active: 0,
animate: {},
diff --git a/tests/unit/accordion/accordion_defaults_deprecated.js b/tests/unit/accordion/accordion_common_deprecated.js
index 99f5ac827..22d5e1289 100644
--- a/tests/unit/accordion/accordion_defaults_deprecated.js
+++ b/tests/unit/accordion/accordion_common_deprecated.js
@@ -1,4 +1,4 @@
-commonWidgetTests( "accordion", {
+TestHelpers.commonWidgetTests( "accordion", {
defaults: {
active: 0,
animate: null,
diff --git a/tests/unit/accordion/accordion_core.js b/tests/unit/accordion/accordion_core.js
index 92d79c121..7a1d56c18 100644
--- a/tests/unit/accordion/accordion_core.js
+++ b/tests/unit/accordion/accordion_core.js
@@ -1,6 +1,9 @@
(function( $ ) {
-module( "accordion: core", accordion_setupTeardown() );
+var setupTeardown = TestHelpers.accordion.setupTeardown,
+ state = TestHelpers.accordion.state;
+
+module( "accordion: core", setupTeardown() );
$.each( { div: "#list1", ul: "#navigation", dl: "#accordion-dl" }, function( type, selector ) {
test( "markup structure: " + type, function() {
@@ -21,15 +24,15 @@ test( "handle click on header-descendant", function() {
expect( 1 );
var element = $( "#navigation" ).accordion();
$( "#navigation h2:eq(1) a" ).click();
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
});
test( "accessibility", function () {
expect( 37 );
var element = $( "#list1" ).accordion({
- active: 1
- });
- var headers = element.find( ".ui-accordion-header" );
+ active: 1
+ }),
+ headers = element.find( ".ui-accordion-header" );
equal( element.attr( "role" ), "tablist", "element role" );
headers.each(function( i ) {
@@ -85,22 +88,22 @@ asyncTest( "keybaord support", function() {
ok( headers.eq( 2 ).is( ".ui-state-focus" ), "RIGHT moves focus to next header" );
headers.eq( 2 ).simulate( "keydown", { keyCode: keyCode.DOWN } );
ok( headers.eq( 0 ).is( ".ui-state-focus" ), "DOWN wraps focus to first header" );
-
+
headers.eq( 0 ).simulate( "keydown", { keyCode: keyCode.UP } );
ok( headers.eq( 2 ).is( ".ui-state-focus" ), "UP wraps focus to last header" );
headers.eq( 2 ).simulate( "keydown", { keyCode: keyCode.LEFT } );
ok( headers.eq( 1 ).is( ".ui-state-focus" ), "LEFT moves focus to previous header" );
-
+
headers.eq( 1 ).simulate( "keydown", { keyCode: keyCode.HOME } );
ok( headers.eq( 0 ).is( ".ui-state-focus" ), "HOME moves focus to first header" );
headers.eq( 0 ).simulate( "keydown", { keyCode: keyCode.END } );
ok( headers.eq( 2 ).is( ".ui-state-focus" ), "END moves focus to last header" );
-
+
headers.eq( 2 ).simulate( "keydown", { keyCode: keyCode.ENTER } );
equal( element.accordion( "option", "active" ) , 2, "ENTER activates panel" );
headers.eq( 1 ).simulate( "keydown", { keyCode: keyCode.SPACE } );
equal( element.accordion( "option", "active" ), 1, "SPACE activates panel" );
-
+
anchor.simulate( "focus" );
setTimeout(function() {
ok( !headers.eq( 1 ).is( ".ui-state-focus" ), "header loses focus when focusing inside the panel" );
diff --git a/tests/unit/accordion/accordion_deprecated.html b/tests/unit/accordion/accordion_deprecated.html
index 116eb43b5..dfb9fa90e 100644
--- a/tests/unit/accordion/accordion_deprecated.html
+++ b/tests/unit/accordion/accordion_deprecated.html
@@ -5,9 +5,12 @@
<title>jQuery UI Accordion Test Suite</title>
<script src="../../jquery.js"></script>
- <script src="../../resource_loader.js"></script>
+ <link rel="stylesheet" href="../../../external/qunit.css">
+ <script src="../../../external/qunit.js"></script>
+ <script src="../../jquery.simulate.js"></script>
+ <script src="../testsuite.js"></script>
<script>
- loadResources({
+ TestHelpers.loadResources({
css: [ "ui.core", "ui.accordion" ],
js: [
"ui/jquery.ui.core.js",
@@ -17,13 +20,8 @@
});
</script>
- <link rel="stylesheet" href="../../../external/qunit.css">
- <script src="../../../external/qunit.js"></script>
- <script src="../../jquery.simulate.js"></script>
- <script src="../testsuite.js"></script>
-
<script src="accordion_test_helpers.js"></script>
- <script src="accordion_defaults_deprecated.js"></script>
+ <script src="accordion_common_deprecated.js"></script>
<script src="accordion_core.js"></script>
<script src="accordion_events.js"></script>
<script src="accordion_methods.js"></script>
@@ -91,7 +89,7 @@
<li><a href="?p=1.1.1.3">Amps</a></li>
<li><a href="?p=1.1.1.4">Effects</a></li>
<li><a href="?p=1.1.1.5">Accessories</a></li>
- </ul>
+ </ul>
</li>
<li>
<h2><a href="?p=1.1.2"><span>Bass</span></a></h2>
@@ -103,7 +101,7 @@
<li><a href="?p=1.1.2.5">Accessories</a></li>
<li><a href="?p=1.1.2.5">Accessories</a></li>
<li><a href="?p=1.1.2.5">Accessories</a></li>
- </ul>
+ </ul>
</li>
<li>
<h2><a href="?p=1.1.3">Drums</a></h2>
@@ -111,7 +109,7 @@
<li><a href="?p=1.1.3.2">Acoustic</a></li>
<li><a href="?p=1.1.3.3">Electronic</a></li>
<li><a href="?p=1.1.3.6">Accessories</a></li>
- </ul>
+ </ul>
</li>
</ul>
</div>
diff --git a/tests/unit/accordion/accordion_deprecated.js b/tests/unit/accordion/accordion_deprecated.js
index eec034e18..7f033a340 100644
--- a/tests/unit/accordion/accordion_deprecated.js
+++ b/tests/unit/accordion/accordion_deprecated.js
@@ -1,70 +1,74 @@
(function( $ ) {
-module( "accordion (deprecated): expanded active option, activate method", accordion_setupTeardown() );
+var equalHeights = TestHelpers.accordion.equalHeights,
+ setupTeardown = TestHelpers.accordion.setupTeardown,
+ state = TestHelpers.accordion.state;
+
+module( "accordion (deprecated): expanded active option, activate method", setupTeardown() );
test( "activate, numeric", function() {
expect( 5 );
var element = $( "#list1" ).accordion({ active: 1 });
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.accordion( "activate", 2 );
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.accordion( "activate", 0 );
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.accordion( "activate", 1 );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.accordion( "activate", 2 );
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
});
test( "activate, numeric, collapsible:true", function() {
expect( 3 );
var element = $( "#list1" ).accordion({ collapsible: true });
element.accordion( "activate", 2 );
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.accordion( "activate", 0 );
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.accordion( "activate", -1 );
- accordion_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
});
test( "activate, boolean, collapsible: true", function() {
expect( 2 );
var element = $( "#list1" ).accordion({ collapsible: true });
element.accordion( "activate", 2 );
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.accordion( "activate", false );
- accordion_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
});
test( "activate, boolean, collapsible: false", function() {
expect( 2 );
var element = $( "#list1" ).accordion();
element.accordion( "activate", 2 );
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.accordion( "activate", false );
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
});
test( "activate, string expression", function() {
expect( 4 );
var element = $( "#list1" ).accordion({ active: "h3:last" });
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.accordion( "activate", ":first" );
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.accordion( "activate", ":eq(1)" );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.accordion( "activate", ":last" );
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
});
test( "activate, jQuery or DOM element", function() {
expect( 3 );
var element = $( "#list1" ).accordion({ active: $( "#list1 h3:last" ) });
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.accordion( "activate", $( "#list1 h3:first" ) );
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.accordion( "activate", $( "#list1 h3" )[ 1 ] );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
});
test( "{ active: Selector }", function() {
@@ -72,9 +76,9 @@ test( "{ active: Selector }", function() {
var element = $("#list1").accordion({
active: "h3:last"
});
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.accordion( "option", "active", "h3:eq(1)" );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
});
test( "{ active: Element }", function() {
@@ -82,9 +86,9 @@ test( "{ active: Element }", function() {
var element = $( "#list1" ).accordion({
active: $( "#list1 h3:last" )[ 0 ]
});
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.accordion( "option", "active", $( "#list1 h3:eq(1)" )[ 0 ] );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
});
test( "{ active: jQuery Object }", function() {
@@ -92,26 +96,26 @@ test( "{ active: jQuery Object }", function() {
var element = $( "#list1" ).accordion({
active: $( "#list1 h3:last" )
});
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.accordion( "option", "active", $( "#list1 h3:eq(1)" ) );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
});
-module( "accordion (deprecated) - height options", accordion_setupTeardown() );
+module( "accordion (deprecated) - height options", setupTeardown() );
test( "{ autoHeight: true }, default", function() {
expect( 3 );
- accordion_equalHeights( $( "#navigation" ).accordion({ autoHeight: true }), 95, 130 );
+ equalHeights( $( "#navigation" ).accordion({ autoHeight: true }), 95, 130 );
});
test( "{ autoHeight: false }", function() {
expect( 3 );
- var element = $( "#navigation" ).accordion({ autoHeight: false });
- var sizes = [];
+ var element = $( "#navigation" ).accordion({ autoHeight: false }),
+ sizes = [];
element.find( ".ui-accordion-content" ).each(function() {
sizes.push( $(this).height() );
});
@@ -124,7 +128,7 @@ test( "{ fillSpace: true }", function() {
expect( 3 );
$( "#navigationWrapper" ).height( 500 );
var element = $( "#navigation" ).accordion({ fillSpace: true });
- accordion_equalHeights( element, 446, 458 );
+ equalHeights( element, 446, 458 );
});
test( "{ fillSapce: true } with sibling", function() {
@@ -138,7 +142,7 @@ test( "{ fillSapce: true } with sibling", function() {
})
.prependTo( "#navigationWrapper" );
var element = $( "#navigation" ).accordion({ fillSpace: true });
- accordion_equalHeights( element , 346, 358);
+ equalHeights( element , 346, 358);
});
test( "{ fillSpace: true } with multiple siblings", function() {
@@ -167,14 +171,14 @@ test( "{ fillSpace: true } with multiple siblings", function() {
})
.prependTo( "#navigationWrapper" );
var element = $( "#navigation" ).accordion({ fillSpace: true });
- accordion_equalHeights( element, 296, 308 );
+ equalHeights( element, 296, 308 );
});
-module( "accordion (deprecated) - icons", accordion_setupTeardown() );
+module( "accordion (deprecated) - icons", setupTeardown() );
test( "icons, headerSelected", function() {
expect( 3 );
@@ -191,7 +195,7 @@ test( "icons, headerSelected", function() {
-module( "accordion (deprecated) - resize", accordion_setupTeardown() );
+module( "accordion (deprecated) - resize", setupTeardown() );
test( "resize", function() {
expect( 6 );
@@ -202,29 +206,29 @@ test( "resize", function() {
.accordion({
heightStyle: "fill"
});
- accordion_equalHeights( element, 246, 258 );
+ equalHeights( element, 246, 258 );
element.parent().height( 500 );
element.accordion( "resize" );
- accordion_equalHeights( element, 446, 458 );
+ equalHeights( element, 446, 458 );
});
-module( "accordion (deprecated) - navigation", accordion_setupTeardown() );
+module( "accordion (deprecated) - navigation", setupTeardown() );
test( "{ navigation: true, navigationFilter: header }", function() {
expect( 2 );
var element = $( "#navigation" ).accordion({
navigation: true,
navigationFilter: function() {
- return /\?p=1\.1\.3$/.test( this.href );
+ return (/\?p=1\.1\.3$/).test( this.href );
}
});
equal( element.accordion( "option", "active" ), 2 );
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
});
test( "{ navigation: true, navigationFilter: content }", function() {
@@ -232,105 +236,105 @@ test( "{ navigation: true, navigationFilter: content }", function() {
var element = $( "#navigation" ).accordion({
navigation: true,
navigationFilter: function() {
- return /\?p=1\.1\.3\.2$/.test( this.href );
+ return (/\?p=1\.1\.3\.2$/).test( this.href );
}
});
equal( element.accordion( "option", "active" ), 2 );
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
});
-module( "accordion (deprecated) - changestart/change events", accordion_setupTeardown() );
+module( "accordion (deprecated) - changestart/change events", setupTeardown() );
test( "changestart", function() {
expect( 26 );
var element = $( "#list1" ).accordion({
- active: false,
- collapsible: true
- });
- var headers = element.find( ".ui-accordion-header" );
- var content = element.find( ".ui-accordion-content" );
+ active: false,
+ collapsible: true
+ }),
+ headers = element.find( ".ui-accordion-header" ),
+ content = element.find( ".ui-accordion-content" );
element.one( "accordionchangestart", function( event, ui ) {
- equal( ui.oldHeader.size(), 0 );
- equal( ui.oldContent.size(), 0 );
- equal( ui.newHeader.size(), 1 );
+ equal( ui.oldHeader.length, 0 );
+ equal( ui.oldContent.length, 0 );
+ equal( ui.newHeader.length, 1 );
strictEqual( ui.newHeader[ 0 ], headers[ 0 ] );
- equal( ui.newContent.size(), 1 );
+ equal( ui.newContent.length, 1 );
strictEqual( ui.newContent[ 0 ], content[ 0 ] );
- accordion_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
});
element.accordion( "option", "active", 0 );
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.one( "accordionchangestart", function( event, ui ) {
- equal( ui.oldHeader.size(), 1 );
+ equal( ui.oldHeader.length, 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] );
- equal( ui.oldContent.size(), 1 );
+ equal( ui.oldContent.length, 1 );
strictEqual( ui.oldContent[ 0 ], content[ 0 ] );
- equal( ui.newHeader.size(), 1 );
+ equal( ui.newHeader.length, 1 );
strictEqual( ui.newHeader[ 0 ], headers[ 1 ] );
- equal( ui.newContent.size(), 1 );
+ equal( ui.newContent.length, 1 );
strictEqual( ui.newContent[ 0 ], content[ 1 ] );
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
});
headers.eq( 1 ).click();
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.one( "accordionchangestart", function( event, ui ) {
- equal( ui.oldHeader.size(), 1 );
+ equal( ui.oldHeader.length, 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] );
- equal( ui.oldContent.size(), 1 );
+ equal( ui.oldContent.length, 1 );
strictEqual( ui.oldContent[ 0 ], content[ 1 ] );
- equal( ui.newHeader.size(), 0 );
- equal( ui.newContent.size(), 0 );
- accordion_state( element, 0, 1, 0 );
+ equal( ui.newHeader.length, 0 );
+ equal( ui.newContent.length, 0 );
+ state( element, 0, 1, 0 );
});
element.accordion( "option", "active", false );
- accordion_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
});
test( "change", function() {
expect( 20 );
var element = $( "#list1" ).accordion({
- active: false,
- collapsible: true
- });
- var headers = element.find( ".ui-accordion-header" );
- var content = element.find( ".ui-accordion-content" );
+ active: false,
+ collapsible: true
+ }),
+ headers = element.find( ".ui-accordion-header" ),
+ content = element.find( ".ui-accordion-content" );
element.one( "accordionchange", function( event, ui ) {
- equal( ui.oldHeader.size(), 0 );
- equal( ui.oldContent.size(), 0 );
- equal( ui.newHeader.size(), 1 );
+ equal( ui.oldHeader.length, 0 );
+ equal( ui.oldContent.length, 0 );
+ equal( ui.newHeader.length, 1 );
strictEqual( ui.newHeader[ 0 ], headers[ 0 ] );
- equal( ui.newContent.size(), 1 );
+ equal( ui.newContent.length, 1 );
strictEqual( ui.newContent[ 0 ], content[ 0 ] );
});
element.accordion( "option", "active", 0 );
element.one( "accordionchange", function( event, ui ) {
- equal( ui.oldHeader.size(), 1 );
+ equal( ui.oldHeader.length, 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] );
- equal( ui.oldContent.size(), 1 );
+ equal( ui.oldContent.length, 1 );
strictEqual( ui.oldContent[ 0 ], content[ 0 ] );
- equal( ui.newHeader.size(), 1 );
+ equal( ui.newHeader.length, 1 );
strictEqual( ui.newHeader[ 0 ], headers[ 1 ] );
- equal( ui.newContent.size(), 1 );
+ equal( ui.newContent.length, 1 );
strictEqual( ui.newContent[ 0 ], content[ 1 ] );
});
headers.eq( 1 ).click();
element.one( "accordionchange", function( event, ui ) {
- equal( ui.oldHeader.size(), 1 );
+ equal( ui.oldHeader.length, 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] );
- equal( ui.oldContent.size(), 1 );
+ equal( ui.oldContent.length, 1 );
strictEqual( ui.oldContent[ 0 ], content[ 1 ] );
- equal( ui.newHeader.size(), 0 );
- equal( ui.newContent.size(), 0 );
+ equal( ui.newHeader.length, 0 );
+ equal( ui.newContent.length, 0 );
});
element.accordion( "option", "active", false );
});
diff --git a/tests/unit/accordion/accordion_events.js b/tests/unit/accordion/accordion_events.js
index dbb3e37df..079c71a62 100644
--- a/tests/unit/accordion/accordion_events.js
+++ b/tests/unit/accordion/accordion_events.js
@@ -1,6 +1,9 @@
(function( $ ) {
-module( "accordion: events", accordion_setupTeardown() );
+var setupTeardown = TestHelpers.accordion.setupTeardown,
+ state = TestHelpers.accordion.state;
+
+module( "accordion: events", setupTeardown() );
test( "create", function() {
expect( 10 );
@@ -11,9 +14,9 @@ test( "create", function() {
element.accordion({
create: function( event, ui ) {
- equal( ui.header.size(), 1, "header size" );
+ equal( ui.header.length, 1, "header length" );
strictEqual( ui.header[ 0 ], headers[ 0 ], "header" );
- equal( ui.content.size(), 1, "content size" );
+ equal( ui.content.length, 1, "content length" );
strictEqual( ui.content[ 0 ], contents[ 0 ], "content" );
}
});
@@ -22,9 +25,9 @@ test( "create", function() {
element.accordion({
active: 2,
create: function( event, ui ) {
- equal( ui.header.size(), 1, "header size" );
+ equal( ui.header.length, 1, "header length" );
strictEqual( ui.header[ 0 ], headers[ 2 ], "header" );
- equal( ui.content.size(), 1, "content size" );
+ equal( ui.content.length, 1, "content length" );
strictEqual( ui.content[ 0 ], contents[ 2 ], "content" );
}
});
@@ -34,8 +37,8 @@ test( "create", function() {
active: false,
collapsible: true,
create: function( event, ui ) {
- equal( ui.header.size(), 0, "header size" );
- equal( ui.content.size(), 0, "content size" );
+ equal( ui.header.length, 0, "header length" );
+ equal( ui.content.length, 0, "content length" );
}
});
element.accordion( "destroy" );
@@ -44,106 +47,106 @@ test( "create", function() {
test( "beforeActivate", function() {
expect( 38 );
var element = $( "#list1" ).accordion({
- active: false,
- collapsible: true
- });
- var headers = element.find( ".ui-accordion-header" );
- var content = element.find( ".ui-accordion-content" );
+ active: false,
+ collapsible: true
+ }),
+ headers = element.find( ".ui-accordion-header" ),
+ content = element.find( ".ui-accordion-content" );
element.one( "accordionbeforeactivate", function( event, ui ) {
ok( !( "originalEvent" in event ) );
- equal( ui.oldHeader.size(), 0 );
- equal( ui.oldContent.size(), 0 );
- equal( ui.newHeader.size(), 1 );
+ equal( ui.oldHeader.length, 0 );
+ equal( ui.oldContent.length, 0 );
+ equal( ui.newHeader.length, 1 );
strictEqual( ui.newHeader[ 0 ], headers[ 0 ] );
- equal( ui.newContent.size(), 1 );
+ equal( ui.newContent.length, 1 );
strictEqual( ui.newContent[ 0 ], content[ 0 ] );
- accordion_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
});
element.accordion( "option", "active", 0 );
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.one( "accordionbeforeactivate", function( event, ui ) {
equal( event.originalEvent.type, "click" );
- equal( ui.oldHeader.size(), 1 );
+ equal( ui.oldHeader.length, 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] );
- equal( ui.oldContent.size(), 1 );
+ equal( ui.oldContent.length, 1 );
strictEqual( ui.oldContent[ 0 ], content[ 0 ] );
- equal( ui.newHeader.size(), 1 );
+ equal( ui.newHeader.length, 1 );
strictEqual( ui.newHeader[ 0 ], headers[ 1 ] );
- equal( ui.newContent.size(), 1 );
+ equal( ui.newContent.length, 1 );
strictEqual( ui.newContent[ 0 ], content[ 1 ] );
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
});
headers.eq( 1 ).click();
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.one( "accordionbeforeactivate", function( event, ui ) {
ok( !( "originalEvent" in event ) );
- equal( ui.oldHeader.size(), 1 );
+ equal( ui.oldHeader.length, 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] );
- equal( ui.oldContent.size(), 1 );
+ equal( ui.oldContent.length, 1 );
strictEqual( ui.oldContent[ 0 ], content[ 1 ] );
- equal( ui.newHeader.size(), 0 );
- equal( ui.newContent.size(), 0 );
- accordion_state( element, 0, 1, 0 );
+ equal( ui.newHeader.length, 0 );
+ equal( ui.newContent.length, 0 );
+ state( element, 0, 1, 0 );
});
element.accordion( "option", "active", false );
- accordion_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
element.one( "accordionbeforeactivate", function( event, ui ) {
ok( !( "originalEvent" in event ) );
- equal( ui.oldHeader.size(), 0 );
- equal( ui.oldContent.size(), 0 );
- equal( ui.newHeader.size(), 1 );
+ equal( ui.oldHeader.length, 0 );
+ equal( ui.oldContent.length, 0 );
+ equal( ui.newHeader.length, 1 );
strictEqual( ui.newHeader[ 0 ], headers[ 2 ] );
- equal( ui.newContent.size(), 1 );
+ equal( ui.newContent.length, 1 );
strictEqual( ui.newContent[ 0 ], content[ 2 ] );
event.preventDefault();
- accordion_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
});
element.accordion( "option", "active", 2 );
- accordion_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
});
test( "activate", function() {
expect( 21 );
var element = $( "#list1" ).accordion({
- active: false,
- collapsible: true
- });
- var headers = element.find( ".ui-accordion-header" );
- var content = element.find( ".ui-accordion-content" );
+ active: false,
+ collapsible: true
+ }),
+ headers = element.find( ".ui-accordion-header" ),
+ content = element.find( ".ui-accordion-content" );
element.one( "accordionactivate", function( event, ui ) {
- equal( ui.oldHeader.size(), 0 );
- equal( ui.oldContent.size(), 0 );
- equal( ui.newHeader.size(), 1 );
+ equal( ui.oldHeader.length, 0 );
+ equal( ui.oldContent.length, 0 );
+ equal( ui.newHeader.length, 1 );
strictEqual( ui.newHeader[ 0 ], headers[ 0 ] );
- equal( ui.newContent.size(), 1 );
+ equal( ui.newContent.length, 1 );
strictEqual( ui.newContent[ 0 ], content[ 0 ] );
});
element.accordion( "option", "active", 0 );
element.one( "accordionactivate", function( event, ui ) {
- equal( ui.oldHeader.size(), 1 );
+ equal( ui.oldHeader.length, 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] );
- equal( ui.oldContent.size(), 1 );
+ equal( ui.oldContent.length, 1 );
strictEqual( ui.oldContent[ 0 ], content[ 0 ] );
- equal( ui.newHeader.size(), 1 );
+ equal( ui.newHeader.length, 1 );
strictEqual( ui.newHeader[ 0 ], headers[ 1 ] );
- equal( ui.newContent.size(), 1 );
+ equal( ui.newContent.length, 1 );
strictEqual( ui.newContent[ 0 ], content[ 1 ] );
});
headers.eq( 1 ).click();
element.one( "accordionactivate", function( event, ui ) {
- equal( ui.oldHeader.size(), 1 );
+ equal( ui.oldHeader.length, 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] );
- equal( ui.oldContent.size(), 1 );
+ equal( ui.oldContent.length, 1 );
strictEqual( ui.oldContent[ 0 ], content[ 1 ] );
- equal( ui.newHeader.size(), 0 );
- equal( ui.newContent.size(), 0 );
+ equal( ui.newHeader.length, 0 );
+ equal( ui.newContent.length, 0 );
});
element.accordion( "option", "active", false );
diff --git a/tests/unit/accordion/accordion_methods.js b/tests/unit/accordion/accordion_methods.js
index 2f4722070..2c5b36632 100644
--- a/tests/unit/accordion/accordion_methods.js
+++ b/tests/unit/accordion/accordion_methods.js
@@ -1,6 +1,10 @@
(function( $ ) {
-module( "accordion: methods", accordion_setupTeardown() );
+var equalHeights = TestHelpers.accordion.equalHeights,
+ setupTeardown = TestHelpers.accordion.setupTeardown,
+ state = TestHelpers.accordion.state;
+
+module( "accordion: methods", setupTeardown() );
test( "destroy", function() {
expect( 1 );
@@ -12,17 +16,17 @@ test( "destroy", function() {
test( "enable/disable", function() {
expect( 4 );
var element = $( "#list1" ).accordion();
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.accordion( "disable" );
// event does nothing
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" );
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
// option still works
element.accordion( "option", "active", 1 );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.accordion( "enable" );
element.accordion( "option", "active", 2 );
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
});
test( "refresh", function() {
@@ -34,11 +38,11 @@ test( "refresh", function() {
.accordion({
heightStyle: "fill"
});
- accordion_equalHeights( element, 246, 258 );
+ equalHeights( element, 246, 258 );
element.parent().height( 500 );
element.accordion( "refresh" );
- accordion_equalHeights( element, 446, 458 );
+ equalHeights( element, 446, 458 );
});
}( jQuery ) );
diff --git a/tests/unit/accordion/accordion_options.js b/tests/unit/accordion/accordion_options.js
index 2b7176394..3c7863520 100644
--- a/tests/unit/accordion/accordion_options.js
+++ b/tests/unit/accordion/accordion_options.js
@@ -1,12 +1,16 @@
(function( $ ) {
-module( "accordion: options", accordion_setupTeardown() );
+var equalHeights = TestHelpers.accordion.equalHeights,
+ setupTeardown = TestHelpers.accordion.setupTeardown,
+ state = TestHelpers.accordion.state;
+
+module( "accordion: options", setupTeardown() );
test( "{ active: default }", function() {
expect( 2 );
var element = $( "#list1" ).accordion();
equal( element.accordion( "option", "active" ), 0 );
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
});
test( "{ active: false }", function() {
@@ -15,19 +19,19 @@ test( "{ active: false }", function() {
active: false,
collapsible: true
});
- accordion_state( element, 0, 0, 0 );
- equal( element.find( ".ui-accordion-header.ui-state-active" ).size(), 0, "no headers selected" );
+ state( element, 0, 0, 0 );
+ equal( element.find( ".ui-accordion-header.ui-state-active" ).length, 0, "no headers selected" );
equal( element.accordion( "option", "active" ), false );
element.accordion( "option", "collapsible", false );
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
equal( element.accordion( "option", "active" ), 0 );
element.accordion( "destroy" );
element.accordion({
active: false
});
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
strictEqual( element.accordion( "option", "active" ), 0 );
});
@@ -37,19 +41,19 @@ test( "{ active: Number }", function() {
active: 2
});
equal( element.accordion( "option", "active" ), 2 );
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.accordion( "option", "active", 0 );
equal( element.accordion( "option", "active" ), 0 );
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.find( ".ui-accordion-header" ).eq( 1 ).click();
equal( element.accordion( "option", "active" ), 1 );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.accordion( "option", "active", 10 );
equal( element.accordion( "option", "active" ), 1 );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
});
if ( $.uiBackCompat === false ) {
@@ -59,19 +63,19 @@ if ( $.uiBackCompat === false ) {
active: -1
});
equal( element.accordion( "option", "active" ), 2 );
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.accordion( "option", "active", -2 );
equal( element.accordion( "option", "active" ), 1 );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.accordion( "option", "active", -10 );
equal( element.accordion( "option", "active" ), 1 );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.accordion( "option", "active", -3 );
equal( element.accordion( "option", "active" ), 0 );
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
});
}
@@ -80,7 +84,7 @@ test( "{ animate: false }", function() {
var element = $( "#list1" ).accordion({
animate: false
}),
- panels = element.find( ".ui-accordion-content" );
+ panels = element.find( ".ui-accordion-content" ),
animate = $.fn.animate;
$.fn.animate = function() {
ok( false, ".animate() called" );
@@ -98,7 +102,7 @@ asyncTest( "{ animate: Number }", function() {
var element = $( "#list1" ).accordion({
animate: 100
}),
- panels = element.find( ".ui-accordion-content" );
+ panels = element.find( ".ui-accordion-content" ),
animate = $.fn.animate;
// called twice (both panels)
$.fn.animate = function( props, duration, easing ) {
@@ -120,10 +124,10 @@ asyncTest( "{ animate: Number }", function() {
asyncTest( "{ animate: String }", function() {
expect( 7 );
var element = $( "#list1" ).accordion({
- animate: "linear"
- }),
- panels = element.find( ".ui-accordion-content" );
- animate = $.fn.animate;
+ animate: "linear"
+ }),
+ panels = element.find( ".ui-accordion-content" ),
+ animate = $.fn.animate;
// called twice (both panels)
$.fn.animate = function( props, duration, easing ) {
equal( duration, undefined, "default duration" );
@@ -144,10 +148,10 @@ asyncTest( "{ animate: String }", function() {
asyncTest( "{ animate: {} }", function() {
expect( 7 );
var element = $( "#list1" ).accordion({
- animate: {}
- }),
- panels = element.find( ".ui-accordion-content" );
- animate = $.fn.animate;
+ animate: {}
+ }),
+ panels = element.find( ".ui-accordion-content" ),
+ animate = $.fn.animate;
// called twice (both panels)
$.fn.animate = function( props, duration, easing ) {
equal( duration, undefined, "default duration" );
@@ -168,10 +172,10 @@ asyncTest( "{ animate: {} }", function() {
asyncTest( "{ animate: { duration, easing } }", function() {
expect( 7 );
var element = $( "#list1" ).accordion({
- animate: { duration: 100, easing: "linear" }
- }),
- panels = element.find( ".ui-accordion-content" );
- animate = $.fn.animate;
+ animate: { duration: 100, easing: "linear" }
+ }),
+ panels = element.find( ".ui-accordion-content" ),
+ animate = $.fn.animate;
// called twice (both panels)
$.fn.animate = function( props, duration, easing ) {
equal( duration, 100, "correct duration" );
@@ -192,11 +196,11 @@ asyncTest( "{ animate: { duration, easing } }", function() {
asyncTest( "{ animate: { duration, easing } }, animate down", function() {
expect( 7 );
var element = $( "#list1" ).accordion({
- active: 1,
- animate: { duration: 100, easing: "linear" }
- }),
- panels = element.find( ".ui-accordion-content" );
- animate = $.fn.animate;
+ active: 1,
+ animate: { duration: 100, easing: "linear" }
+ }),
+ panels = element.find( ".ui-accordion-content" ),
+ animate = $.fn.animate;
// called twice (both panels)
$.fn.animate = function( props, duration, easing ) {
equal( duration, 100, "correct duration" );
@@ -217,17 +221,17 @@ asyncTest( "{ animate: { duration, easing } }, animate down", function() {
asyncTest( "{ animate: { duration, easing, down } }, animate down", function() {
expect( 7 );
var element = $( "#list1" ).accordion({
- active: 1,
- animate: {
- duration: 100,
- easing: "linear",
- down: {
- easing: "swing"
+ active: 1,
+ animate: {
+ duration: 100,
+ easing: "linear",
+ down: {
+ easing: "swing"
+ }
}
- }
- }),
- panels = element.find( ".ui-accordion-content" );
- animate = $.fn.animate;
+ }),
+ panels = element.find( ".ui-accordion-content" ),
+ animate = $.fn.animate;
// called twice (both panels)
$.fn.animate = function( props, duration, easing ) {
equal( duration, 100, "correct duration" );
@@ -252,11 +256,11 @@ test( "{ collapsible: false }", function() {
});
element.accordion( "option", "active", false );
equal( element.accordion( "option", "active" ), 1 );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.find( ".ui-accordion-header" ).eq( 1 ).click();
equal( element.accordion( "option", "active" ), 1 );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
});
test( "{ collapsible: true }", function() {
@@ -268,15 +272,15 @@ test( "{ collapsible: true }", function() {
element.accordion( "option", "active", false );
equal( element.accordion( "option", "active" ), false );
- accordion_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
element.accordion( "option", "active", 1 );
equal( element.accordion( "option", "active" ), 1 );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.find( ".ui-accordion-header" ).eq( 1 ).click();
equal( element.accordion( "option", "active" ), false );
- accordion_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
});
test( "{ event: null }", function() {
@@ -284,16 +288,16 @@ test( "{ event: null }", function() {
var element = $( "#list1" ).accordion({
event: null
});
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.accordion( "option", "active", 1 );
equal( element.accordion( "option", "active" ), 1 );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
// ensure default click handler isn't bound
element.find( ".ui-accordion-header" ).eq( 2 ).click();
equal( element.accordion( "option", "active" ), 1 );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
});
test( "{ event: custom }", function() {
@@ -301,20 +305,20 @@ test( "{ event: custom }", function() {
var element = $( "#list1" ).accordion({
event: "custom1 custom2"
});
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom1" );
equal( element.accordion( "option", "active" ), 1 );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
// ensure default click handler isn't bound
element.find( ".ui-accordion-header" ).eq( 2 ).trigger( "click" );
equal( element.accordion( "option", "active" ), 1 );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.find( ".ui-accordion-header" ).eq( 2 ).trigger( "custom2" );
equal( element.accordion( "option", "active" ), 2 );
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.accordion( "option", "event", "custom3" );
@@ -322,20 +326,20 @@ test( "{ event: custom }", function() {
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom1" );
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom2" );
equal( element.accordion( "option", "active" ), 2 );
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom3" );
equal( element.accordion( "option", "active" ), 1 );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
});
test( "{ header: default }", function() {
expect( 2 );
// default: > li > :first-child,> :not(li):even
// > :not(li):even
- accordion_state( $( "#list1" ).accordion(), 1, 0, 0);
+ state( $( "#list1" ).accordion(), 1, 0, 0);
// > li > :first-child
- accordion_state( $( "#navigation" ).accordion(), 1, 0, 0);
+ state( $( "#navigation" ).accordion(), 1, 0, 0);
});
test( "{ header: custom }", function() {
@@ -347,23 +351,23 @@ test( "{ header: custom }", function() {
ok( $( this ).hasClass( "ui-accordion-header" ) );
});
equal( element.find( ".ui-accordion-header" ).length, 3 );
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.accordion( "option", "active", 2 );
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
});
test( "{ heightStyle: 'auto' }", function() {
expect( 3 );
var element = $( "#navigation" ).accordion({ heightStyle: "auto" });
- accordion_equalHeights( element, 95, 130 );
+ equalHeights( element, 95, 130 );
});
test( "{ heightStyle: 'content' }", function() {
expect( 3 );
- var element = $( "#navigation" ).accordion({ heightStyle: "content" });
- var sizes = element.find( ".ui-accordion-content" ).map(function() {
- return $( this ).height();
- }).get();
+ var element = $( "#navigation" ).accordion({ heightStyle: "content" }),
+ sizes = element.find( ".ui-accordion-content" ).map(function() {
+ return $( this ).height();
+ }).get();
ok( sizes[ 0 ] >= 70 && sizes[ 0 ] <= 105, "was " + sizes[ 0 ] );
ok( sizes[ 1 ] >= 98 && sizes[ 1 ] <= 126, "was " + sizes[ 1 ] );
ok( sizes[ 2 ] >= 42 && sizes[ 2 ] <= 54, "was " + sizes[ 2 ] );
@@ -373,7 +377,7 @@ test( "{ heightStyle: 'fill' }", function() {
expect( 3 );
$( "#navigationWrapper" ).height( 500 );
var element = $( "#navigation" ).accordion({ heightStyle: "fill" });
- accordion_equalHeights( element, 446, 458 );
+ equalHeights( element, 446, 458 );
});
test( "{ heightStyle: 'fill' } with sibling", function() {
@@ -387,7 +391,7 @@ test( "{ heightStyle: 'fill' } with sibling", function() {
})
.prependTo( "#navigationWrapper" );
var element = $( "#navigation" ).accordion({ heightStyle: "fill" });
- accordion_equalHeights( element , 346, 358);
+ equalHeights( element , 346, 358);
});
test( "{ heightStyle: 'fill' } with multiple siblings", function() {
@@ -416,7 +420,7 @@ test( "{ heightStyle: 'fill' } with multiple siblings", function() {
})
.prependTo( "#navigationWrapper" );
var element = $( "#navigation" ).accordion({ heightStyle: "fill" });
- accordion_equalHeights( element, 296, 308 );
+ equalHeights( element, 296, 308 );
});
test( "{ icons: false }", function() {
diff --git a/tests/unit/accordion/accordion_test_helpers.js b/tests/unit/accordion/accordion_test_helpers.js
index 542809ea0..56967793d 100644
--- a/tests/unit/accordion/accordion_test_helpers.js
+++ b/tests/unit/accordion/accordion_test_helpers.js
@@ -1,30 +1,32 @@
-function accordion_state( accordion ) {
- var expected = $.makeArray( arguments ).slice( 1 );
- var actual = accordion.find( ".ui-accordion-content" ).map(function() {
- return $( this ).css( "display" ) === "none" ? 0 : 1;
- }).get();
- QUnit.push( QUnit.equiv(actual, expected), actual, expected );
-}
+TestHelpers.accordion = {
+ equalHeights: function( accordion, min, max ) {
+ var sizes = [];
+ accordion.find( ".ui-accordion-content" ).each(function() {
+ sizes.push( $( this ).outerHeight() );
+ });
+ ok( sizes[ 0 ] >= min && sizes[ 0 ] <= max,
+ "must be within " + min + " and " + max + ", was " + sizes[ 0 ] );
+ deepEqual( sizes[ 0 ], sizes[ 1 ] );
+ deepEqual( sizes[ 0 ], sizes[ 2 ] );
+ },
-function accordion_equalHeights( accordion, min, max ) {
- var sizes = [];
- accordion.find( ".ui-accordion-content" ).each(function() {
- sizes.push( $( this ).outerHeight() );
- });
- ok( sizes[ 0 ] >= min && sizes[ 0 ] <= max,
- "must be within " + min + " and " + max + ", was " + sizes[ 0 ] );
- deepEqual( sizes[ 0 ], sizes[ 1 ] );
- deepEqual( sizes[ 0 ], sizes[ 2 ] );
-}
+ setupTeardown: function() {
+ var animate = $.ui.accordion.prototype.options.animate;
+ return {
+ setup: function() {
+ $.ui.accordion.prototype.options.animate = false;
+ },
+ teardown: function() {
+ $.ui.accordion.prototype.options.animate = animate;
+ }
+ };
+ },
-function accordion_setupTeardown() {
- var animate = $.ui.accordion.prototype.options.animate;
- return {
- setup: function() {
- $.ui.accordion.prototype.options.animate = false;
- },
- teardown: function() {
- $.ui.accordion.prototype.options.animate = animate;
- }
- };
-}
+ state: function( accordion ) {
+ var expected = $.makeArray( arguments ).slice( 1 ),
+ actual = accordion.find( ".ui-accordion-content" ).map(function() {
+ return $( this ).css( "display" ) === "none" ? 0 : 1;
+ }).get();
+ QUnit.push( QUnit.equiv(actual, expected), actual, expected );
+ }
+};
diff --git a/tests/unit/accordion/all.html b/tests/unit/accordion/all.html
index ec9c003d9..2fb783c1c 100644
--- a/tests/unit/accordion/all.html
+++ b/tests/unit/accordion/all.html
@@ -7,9 +7,9 @@
<script src="../../../jquery-1.7.2.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
- <link rel="stylesheet" href="../subsuiteRunner.css">
+ <link rel="stylesheet" href="../qunit-composite.css">
<script src="../../../external/qunit.js"></script>
- <script src="../subsuiteRunner.js"></script>
+ <script src="../qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>
diff --git a/tests/unit/all-active.html b/tests/unit/all-active.html
index 89c10441d..b3e2fbcba 100644
--- a/tests/unit/all-active.html
+++ b/tests/unit/all-active.html
@@ -7,9 +7,9 @@
<script src="../../jquery-1.7.2.js"></script>
<link rel="stylesheet" href="../../external/qunit.css">
- <link rel="stylesheet" href="subsuiteRunner.css">
+ <link rel="stylesheet" href="qunit-composite.css">
<script src="../../external/qunit.js"></script>
- <script src="subsuiteRunner.js"></script>
+ <script src="qunit-composite.js"></script>
<script>
(function() {
diff --git a/tests/unit/all.html b/tests/unit/all.html
index e48b1ac0e..6d98df0f9 100644
--- a/tests/unit/all.html
+++ b/tests/unit/all.html
@@ -7,9 +7,9 @@
<script src="../../jquery-1.7.2.js"></script>
<link rel="stylesheet" href="../../external/qunit.css">
- <link rel="stylesheet" href="subsuiteRunner.css">
+ <link rel="stylesheet" href="qunit-composite.css">
<script src="../../external/qunit.js"></script>
- <script src="subsuiteRunner.js"></script>
+ <script src="qunit-composite.js"></script>
<script>
(function() {
diff --git a/tests/unit/autocomplete/all.html b/tests/unit/autocomplete/all.html
index 87cde75fb..e35777f65 100644
--- a/tests/unit/autocomplete/all.html
+++ b/tests/unit/autocomplete/all.html
@@ -7,9 +7,9 @@
<script src="../../../jquery-1.7.2.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
- <link rel="stylesheet" href="../subsuiteRunner.css">
+ <link rel="stylesheet" href="../qunit-composite.css">
<script src="../../../external/qunit.js"></script>
- <script src="../subsuiteRunner.js"></script>
+ <script src="../qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>
diff --git a/tests/unit/autocomplete/autocomplete.html b/tests/unit/autocomplete/autocomplete.html
index 70d2ecfd1..571c62033 100644
--- a/tests/unit/autocomplete/autocomplete.html
+++ b/tests/unit/autocomplete/autocomplete.html
@@ -5,9 +5,12 @@
<title>jQuery UI Autocomplete Test Suite</title>
<script src="../../jquery.js"></script>
- <script src="../../resource_loader.js"></script>
+ <link rel="stylesheet" href="../../../external/qunit.css">
+ <script src="../../../external/qunit.js"></script>
+ <script src="../../jquery.simulate.js"></script>
+ <script src="../testsuite.js"></script>
<script>
- loadResources({
+ TestHelpers.loadResources({
css: [ "ui.core", "ui.menu", "ui.autocomplete" ],
js: [
"ui/jquery.ui.core.js",
@@ -19,12 +22,7 @@
});
</script>
- <link rel="stylesheet" href="../../../external/qunit.css">
- <script src="../../../external/qunit.js"></script>
- <script src="../../jquery.simulate.js"></script>
- <script src="../testsuite.js"></script>
-
- <script src="autocomplete_defaults.js"></script>
+ <script src="autocomplete_common.js"></script>
<script src="autocomplete_core.js"></script>
<script src="autocomplete_events.js"></script>
<script src="autocomplete_methods.js"></script>
diff --git a/tests/unit/autocomplete/autocomplete_defaults.js b/tests/unit/autocomplete/autocomplete_common.js
index ac83eaea4..c090ce4df 100644
--- a/tests/unit/autocomplete/autocomplete_defaults.js
+++ b/tests/unit/autocomplete/autocomplete_common.js
@@ -1,4 +1,4 @@
-commonWidgetTests( "autocomplete", {
+TestHelpers.commonWidgetTests( "autocomplete", {
defaults: {
appendTo: "body",
autoFocus: false,
diff --git a/tests/unit/autocomplete/autocomplete_core.js b/tests/unit/autocomplete/autocomplete_core.js
index ef6ea58af..daeea0972 100644
--- a/tests/unit/autocomplete/autocomplete_core.js
+++ b/tests/unit/autocomplete/autocomplete_core.js
@@ -123,4 +123,33 @@ test( "allow form submit on enter when menu is not active", function() {
}
})();
+asyncTest( "handle race condition", function() {
+ expect( 3 );
+ var count = 0,
+ element = $( "#autocomplete" ).autocomplete({
+ source: function( request, response ) {
+ count++;
+ if ( request.term.length === 1 ) {
+ equal( count, 1, "request with 1 character is first" );
+ setTimeout(function() {
+ response([ "one" ]);
+ setTimeout( checkResults, 1 );
+ }, 1 );
+ return;
+ }
+ equal( count, 2, "request with 2 characters is second" );
+ response([ "two" ]);
+ }
+ });
+
+ element.autocomplete( "search", "a" );
+ element.autocomplete( "search", "ab" );
+
+ function checkResults() {
+ equal( element.autocomplete( "widget" ).find( ".ui-menu-item" ).text(), "two",
+ "correct results displayed" );
+ start();
+ }
+});
+
}( jQuery ) );
diff --git a/tests/unit/autocomplete/autocomplete_events.js b/tests/unit/autocomplete/autocomplete_events.js
index 1c7ff7462..082263a35 100644
--- a/tests/unit/autocomplete/autocomplete_events.js
+++ b/tests/unit/autocomplete/autocomplete_events.js
@@ -123,7 +123,7 @@ asyncTest( "cancel search", function() {
asyncTest( "cancel focus", function() {
expect( 1 );
- var customVal = "custom value";
+ var customVal = "custom value",
element = $( "#autocomplete" ).autocomplete({
delay: 0,
source: data,
diff --git a/tests/unit/button/all.html b/tests/unit/button/all.html
index 115743e94..6c46c9650 100644
--- a/tests/unit/button/all.html
+++ b/tests/unit/button/all.html
@@ -7,9 +7,9 @@
<script src="../../../jquery-1.7.2.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
- <link rel="stylesheet" href="../subsuiteRunner.css">
+ <link rel="stylesheet" href="../qunit-composite.css">
<script src="../../../external/qunit.js"></script>
- <script src="../subsuiteRunner.js"></script>
+ <script src="../qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>
diff --git a/tests/unit/button/button.html b/tests/unit/button/button.html
index 5ec7e316a..b79ca1dc6 100644
--- a/tests/unit/button/button.html
+++ b/tests/unit/button/button.html
@@ -5,9 +5,12 @@
<title>jQuery UI Button Test Suite</title>
<script src="../../jquery.js"></script>
- <script src="../../resource_loader.js"></script>
+ <link rel="stylesheet" href="../../../external/qunit.css">
+ <script src="../../../external/qunit.js"></script>
+ <script src="../../jquery.simulate.js"></script>
+ <script src="../testsuite.js"></script>
<script>
- loadResources({
+ TestHelpers.loadResources({
css: [ "ui.core", "ui.button" ],
js: [
"ui/jquery.ui.core.js",
@@ -17,13 +20,8 @@
});
</script>
- <link rel="stylesheet" href="../../../external/qunit.css">
- <script src="../../../external/qunit.js"></script>
- <script src="../../jquery.simulate.js"></script>
- <script src="../testsuite.js"></script>
-
+ <script src="button_common.js"></script>
<script src="button_core.js"></script>
- <script src="button_defaults.js"></script>
<script src="button_events.js"></script>
<script src="button_methods.js"></script>
<script src="button_options.js"></script>
diff --git a/tests/unit/button/button_defaults.js b/tests/unit/button/button_common.js
index 96c7e5bfa..ef22d3011 100644
--- a/tests/unit/button/button_defaults.js
+++ b/tests/unit/button/button_common.js
@@ -1,4 +1,4 @@
-commonWidgetTests( "button", {
+TestHelpers.commonWidgetTests( "button", {
defaults: {
disabled: null,
icons: {
diff --git a/tests/unit/button/button_core.js b/tests/unit/button/button_core.js
index c110b4311..0d93ecedf 100644
--- a/tests/unit/button/button_core.js
+++ b/tests/unit/button/button_core.js
@@ -8,7 +8,7 @@
module("button: core");
test("checkbox", function() {
- var input = $("#check");
+ var input = $("#check"),
label = $("label[for=check]");
ok( input.is(":visible") );
ok( label.is(":not(.ui-button)") );
@@ -18,7 +18,7 @@ test("checkbox", function() {
});
test("radios", function() {
- var inputs = $("#radio0 input");
+ var inputs = $("#radio0 input"),
labels = $("#radio0 label");
ok( inputs.is(":visible") );
ok( labels.is(":not(.ui-button)") );
@@ -51,7 +51,7 @@ test("radio groups", function() {
});
test("input type submit, don't create child elements", function() {
- var input = $("#submit")
+ var input = $("#submit");
deepEqual( input.children().length, 0 );
input.button();
deepEqual( input.children().length, 0 );
@@ -68,11 +68,12 @@ test("buttonset", function() {
});
test("buttonset (rtl)", function() {
- var parent = $("#radio1").parent();
+ var set,
+ parent = $("#radio1").parent();
// Set to rtl
parent.attr("dir", "rtl");
- var set = $("#radio1").buttonset();
+ set = $("#radio1").buttonset();
ok( set.is(".ui-buttonset") );
deepEqual( set.children(".ui-button").length, 3 );
deepEqual( set.children("input:radio.ui-helper-hidden-accessible").length, 3 );
diff --git a/tests/unit/button/button_methods.js b/tests/unit/button/button_methods.js
index a83a73ba4..347806d4e 100644
--- a/tests/unit/button/button_methods.js
+++ b/tests/unit/button/button_methods.js
@@ -7,8 +7,8 @@
module("button: methods");
test("destroy", function() {
- var beforeHtml = $("#button").parent().html();
- var afterHtml = $("#button").button().button("destroy").parent().html();
+ var beforeHtml = $("#button").parent().html(),
+ afterHtml = $("#button").button().button("destroy").parent().html();
// Opera 9 outputs role="" instead of removing the attribute like everyone else
if ($.browser.opera) {
afterHtml = afterHtml.replace(/ role=""/g, "");
diff --git a/tests/unit/core/all.html b/tests/unit/core/all.html
index 78bbe9aef..e31d6905c 100644
--- a/tests/unit/core/all.html
+++ b/tests/unit/core/all.html
@@ -7,9 +7,9 @@
<script src="../../../jquery-1.7.2.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
- <link rel="stylesheet" href="../subsuiteRunner.css">
+ <link rel="stylesheet" href="../qunit-composite.css">
<script src="../../../external/qunit.js"></script>
- <script src="../subsuiteRunner.js"></script>
+ <script src="../qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>
diff --git a/tests/unit/core/core.html b/tests/unit/core/core.html
index 3b1dc1fc8..e259f3270 100644
--- a/tests/unit/core/core.html
+++ b/tests/unit/core/core.html
@@ -5,17 +5,15 @@
<title>jQuery UI Core Test Suite</title>
<script src="../../jquery.js"></script>
- <script src="../../resource_loader.js"></script>
- <script>
- loadResources({
- js: [ "ui/jquery.ui.core.js" ]
- });
- </script>
-
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
+ <script>
+ TestHelpers.loadResources({
+ js: [ "ui/jquery.ui.core.js" ]
+ });
+ </script>
<script src="core.js"></script>
<script src="selector.js"></script>
@@ -39,15 +37,13 @@
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">
-<img src="../images/jqueryui_32x32.png" usemap="#mymap" width="10", height="10">
+<img src="../images/jqueryui_32x32.png" usemap="#mymap" width="10" height="10" alt="">
<map name="mymap">
- <area shape="rect" coords="0,0,1,1" id="areaCoordsNoHref">
- <area shape="rect" coords="1,1,2,2" href="foo.html" id="areaCoordsHref">
- <area shape="rect" coords="0,0,0,0" href="foo.html" id="areaCoordsNoSizeHref">
- <area href="foo.html" id="areaNoCoordsHref">
+ <area shape="rect" coords="1,1,2,2" href="foo.html" id="areaCoordsHref" alt="">
+ <area href="foo.html" id="areaNoCoordsHref" alt="">
</map>
<map name="mymap2">
- <area shape="rect" coords="1,1,2,2" href="foo.html" id="areaNoImg">
+ <area shape="rect" coords="1,1,2,2" href="foo.html" id="areaNoImg" alt="">
</map>
<form id="formNoTabindex"></form>
@@ -58,7 +54,7 @@
<input type="text" id="visibleAncestor-inputTypeText">
<input type="checkbox" id="visibleAncestor-inputTypeCheckbox">
<input type="radio" id="visibleAncestor-inputTypeRadio">
- <input type="button" id="visibleAncestor-inputTypeButton">
+ <input type="button" id="visibleAncestor-inputTypeButton" value="visibleAncestor-inputTypeButton">
<input type="hidden" id="visibleAncestor-inputTypeHidden">
<button id="visibleAncestor-button">x</button>
<select id="visibleAncestor-select">
@@ -79,7 +75,7 @@
<input type="text" id="disabledElement-inputTypeText" disabled="disabled">
<input type="checkbox" id="disabledElement-inputTypeCheckbox" disabled="disabled">
<input type="radio" id="disabledElement-inputTypeRadio" disabled="disabled">
- <input type="button" id="disabledElement-inputTypeButton" disabled="disabled">
+ <input type="button" id="disabledElement-inputTypeButton" disabled="disabled" value="disabledElement-inputTypeButton">
<input type="hidden" id="disabledElement-inputTypeHidden" disabled="disabled">
<button id="disabledElement-button" disabled="disabled"></button>
<select id="disabledElement-select" disabled="disabled"></select>
diff --git a/tests/unit/core/core.js b/tests/unit/core/core.js
index 53415584f..7a78ae34d 100644
--- a/tests/unit/core/core.js
+++ b/tests/unit/core/core.js
@@ -1,49 +1,48 @@
-/*
- * core unit tests
- */
-(function($) {
+(function( $ ) {
-module('core - jQuery extensions');
+module( "core - jQuery extensions" );
-test('focus - original functionality', function() {
- expect(1);
+TestHelpers.testJshint( "ui.core" );
- $('#inputTabindex0')
+test( "focus - original functionality", function() {
+ expect( 1 );
+ $( "#inputTabindex0" )
.focus(function() {
- ok(true, 'event triggered');
+ ok( true, "event triggered" );
})
.focus();
});
-asyncTest('focus', function() {
- expect(2);
- $('#inputTabindex0')
+asyncTest( "focus", function() {
+ expect( 2 );
+ $( "#inputTabindex0" )
.focus(function() {
- ok(true, 'event triggered');
+ ok( true, "event triggered" );
})
- .focus(500, function() {
- ok(true, 'callback triggered');
- $(this).unbind('focus');
+ .focus( 500, function() {
+ // prevent double focus event in IE
+ $( this ).unbind( "focus" );
+ ok( true, "callback triggered" );
start();
});
});
-test('zIndex', function() {
- var el = $('#zIndexAutoWithParent'),
+test( "zIndex", function() {
+ var el = $( "#zIndexAutoWithParent" ),
parent = el.parent();
- equal(el.zIndex(), 100, 'zIndex traverses up to find value');
- equal(parent.zIndex(200), parent, 'zIndex setter is chainable');
- equal(el.zIndex(), 200, 'zIndex setter changed zIndex');
+ equal( el.zIndex(), 100, "zIndex traverses up to find value" );
+ equal( parent.zIndex(200 ), parent, "zIndex setter is chainable" );
+ equal( el.zIndex(), 200, "zIndex setter changed zIndex" );
- el = $('#zIndexAutoWithParentViaCSS');
- equal(el.zIndex(), 0, 'zIndex traverses up to find CSS value, not found because not positioned');
+ el = $( "#zIndexAutoWithParentViaCSS" );
+ equal( el.zIndex(), 0, "zIndex traverses up to find CSS value, not found because not positioned" );
- el = $('#zIndexAutoWithParentViaCSSPositioned');
- equal(el.zIndex(), 100, 'zIndex traverses up to find CSS value');
- el.parent().zIndex(200);
- equal(el.zIndex(), 200, 'zIndex setter changed zIndex, overriding CSS');
+ el = $( "#zIndexAutoWithParentViaCSSPositioned" );
+ equal( el.zIndex(), 100, "zIndex traverses up to find CSS value" );
+ el.parent().zIndex( 200 );
+ equal( el.zIndex(), 200, "zIndex setter changed zIndex, overriding CSS" );
- equal($('#zIndexAutoNoParent').zIndex(), 0, 'zIndex never explicitly set in hierarchy');
+ equal( $( "#zIndexAutoNoParent" ).zIndex(), 0, "zIndex never explicitly set in hierarchy" );
});
test( "innerWidth - getter", function() {
@@ -154,4 +153,4 @@ test( "outerHeight(true) - setter", function() {
equal( el.height(), 32, "height set properly when hidden" );
});
-})(jQuery);
+})( jQuery );
diff --git a/tests/unit/core/selector.js b/tests/unit/core/selector.js
index 2fb78025c..4309289c9 100644
--- a/tests/unit/core/selector.js
+++ b/tests/unit/core/selector.js
@@ -6,24 +6,24 @@
module("core - selectors");
function isFocusable(selector, msg) {
- ok($(selector).is(':focusable'), msg + " - selector " + selector + " is focusable");
+ QUnit.push($(selector).is(':focusable'), null, null, msg + " - selector " + selector + " is focusable");
}
function isNotFocusable(selector, msg) {
- ok($(selector).length && !$(selector).is(':focusable'), msg + " - selector " + selector + " is not focusable");
+ QUnit.push($(selector).length && !$(selector).is(':focusable'), null, null, msg + " - selector " + selector + " is not focusable");
}
function isTabbable(selector, msg) {
- ok($(selector).is(':tabbable'), msg + " - selector " + selector + " is tabbable");
+ QUnit.push($(selector).is(':tabbable'), null, null, msg + " - selector " + selector + " is tabbable");
}
function isNotTabbable(selector, msg) {
- ok($(selector).length && !$(selector).is(':tabbable'), msg + " - selector " + selector + " is not tabbable");
+ QUnit.push($(selector).length && !$(selector).is(':tabbable'), null, null, msg + " - selector " + selector + " is not tabbable");
}
test("data", function() {
expect(15);
-
+
var el;
function shouldHaveData(msg) {
ok(el.is(':data(test)'), msg);
@@ -31,56 +31,56 @@ test("data", function() {
function shouldNotHaveData(msg) {
ok(!el.is(':data(test)'), msg);
}
-
+
el = $('<div>');
shouldNotHaveData('data never set');
-
+
el = $('<div>').data('test', null);
shouldNotHaveData('data is null');
-
+
el = $('<div>').data('test', true);
shouldHaveData('data set to true');
-
+
el = $('<div>').data('test', false);
shouldNotHaveData('data set to false');
-
+
el = $('<div>').data('test', 0);
shouldNotHaveData('data set to 0');
-
+
el = $('<div>').data('test', 1);
shouldHaveData('data set to 1');
-
+
el = $('<div>').data('test', '');
shouldNotHaveData('data set to empty string');
-
+
el = $('<div>').data('test', 'foo');
shouldHaveData('data set to string');
-
+
el = $('<div>').data('test', []);
shouldHaveData('data set to empty array');
-
+
el = $('<div>').data('test', [1]);
shouldHaveData('data set to array');
-
+
el = $('<div>').data('test', {});
shouldHaveData('data set to empty object');
-
+
el = $('<div>').data('test', {foo: 'bar'});
shouldHaveData('data set to object');
-
+
el = $('<div>').data('test', new Date());
shouldHaveData('data set to date');
-
+
el = $('<div>').data('test', /test/);
shouldHaveData('data set to regexp');
-
+
el = $('<div>').data('test', function() {});
shouldHaveData('data set to function');
});
test("focusable - visible, enabled elements", function() {
expect(18);
-
+
isNotFocusable('#formNoTabindex', 'form');
isFocusable('#formTabindex', 'form with tabindex');
isFocusable('#visibleAncestor-inputTypeNone', 'input, no type');
@@ -103,7 +103,7 @@ test("focusable - visible, enabled elements", function() {
test("focusable - disabled elements", function() {
expect(9);
-
+
isNotFocusable('#disabledElement-inputTypeNone', 'input, no type');
isNotFocusable('#disabledElement-inputTypeText', 'input, type text');
isNotFocusable('#disabledElement-inputTypeCheckbox', 'input, type checkbox');
@@ -117,23 +117,23 @@ test("focusable - disabled elements", function() {
test("focusable - hidden styles", function() {
expect(8);
-
+
isNotFocusable('#displayNoneAncestor-input', 'input, display: none parent');
isNotFocusable('#displayNoneAncestor-span', 'span with tabindex, display: none parent');
-
+
isNotFocusable('#visibilityHiddenAncestor-input', 'input, visibility: hidden parent');
isNotFocusable('#visibilityHiddenAncestor-span', 'span with tabindex, visibility: hidden parent');
-
+
isNotFocusable('#displayNone-input', 'input, display: none');
isNotFocusable('#visibilityHidden-input', 'input, visibility: hidden');
-
+
isNotFocusable('#displayNone-span', 'span with tabindex, display: none');
isNotFocusable('#visibilityHidden-span', 'span with tabindex, visibility: hidden');
});
test("focusable - natively focusable with various tabindex", function() {
expect(4);
-
+
isFocusable('#inputTabindex0', 'input, tabindex 0');
isFocusable('#inputTabindex10', 'input, tabindex 10');
isFocusable('#inputTabindex-1', 'input, tabindex -1');
@@ -142,7 +142,7 @@ test("focusable - natively focusable with various tabindex", function() {
test("focusable - not natively focusable with various tabindex", function() {
expect(4);
-
+
isFocusable('#spanTabindex0', 'span, tabindex 0');
isFocusable('#spanTabindex10', 'span, tabindex 10');
isFocusable('#spanTabindex-1', 'span, tabindex -1');
@@ -150,16 +150,14 @@ test("focusable - not natively focusable with various tabindex", function() {
});
test("focusable - area elements", function() {
- isNotFocusable('#areaCoordsNoHref', 'coords but no href');
isFocusable('#areaCoordsHref', 'coords and href');
- isFocusable('#areaCoordsNoSizeHref', 'coords of zero px and href');
isFocusable('#areaNoCoordsHref', 'href but no coords');
isNotFocusable('#areaNoImg', 'not associated with an image');
});
test("tabbable - visible, enabled elements", function() {
expect(18);
-
+
isNotTabbable('#formNoTabindex', 'form');
isTabbable('#formTabindex', 'form with tabindex');
isTabbable('#visibleAncestor-inputTypeNone', 'input, no type');
@@ -182,7 +180,7 @@ test("tabbable - visible, enabled elements", function() {
test("tabbable - disabled elements", function() {
expect(9);
-
+
isNotTabbable('#disabledElement-inputTypeNone', 'input, no type');
isNotTabbable('#disabledElement-inputTypeText', 'input, type text');
isNotTabbable('#disabledElement-inputTypeCheckbox', 'input, type checkbox');
@@ -196,23 +194,23 @@ test("tabbable - disabled elements", function() {
test("tabbable - hidden styles", function() {
expect(8);
-
+
isNotTabbable('#displayNoneAncestor-input', 'input, display: none parent');
isNotTabbable('#displayNoneAncestor-span', 'span with tabindex, display: none parent');
-
+
isNotTabbable('#visibilityHiddenAncestor-input', 'input, visibility: hidden parent');
isNotTabbable('#visibilityHiddenAncestor-span', 'span with tabindex, visibility: hidden parent');
-
+
isNotTabbable('#displayNone-input', 'input, display: none');
isNotTabbable('#visibilityHidden-input', 'input, visibility: hidden');
-
+
isNotTabbable('#displayNone-span', 'span with tabindex, display: none');
isNotTabbable('#visibilityHidden-span', 'span with tabindex, visibility: hidden');
});
test("tabbable - natively tabbable with various tabindex", function() {
expect(4);
-
+
isTabbable('#inputTabindex0', 'input, tabindex 0');
isTabbable('#inputTabindex10', 'input, tabindex 10');
isNotTabbable('#inputTabindex-1', 'input, tabindex -1');
@@ -221,7 +219,7 @@ test("tabbable - natively tabbable with various tabindex", function() {
test("tabbable - not natively tabbable with various tabindex", function() {
expect(4);
-
+
isTabbable('#spanTabindex0', 'span, tabindex 0');
isTabbable('#spanTabindex10', 'span, tabindex 10');
isNotTabbable('#spanTabindex-1', 'span, tabindex -1');
@@ -229,9 +227,7 @@ test("tabbable - not natively tabbable with various tabindex", function() {
});
test("tabbable - area elements", function() {
- isNotTabbable('#areaCoordsNoHref', 'coords but no href');
isTabbable('#areaCoordsHref', 'coords and href');
- isTabbable('#areaCoordsNoSizeHref', 'coords of zero px and href');
isTabbable('#areaNoCoordsHref', 'href but no coords');
isNotTabbable('#areaNoImg', 'not associated with an image');
});
diff --git a/tests/unit/datepicker/all.html b/tests/unit/datepicker/all.html
index 1540705f8..c62c7c07d 100644
--- a/tests/unit/datepicker/all.html
+++ b/tests/unit/datepicker/all.html
@@ -7,9 +7,9 @@
<script src="../../../jquery-1.7.2.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
- <link rel="stylesheet" href="../subsuiteRunner.css">
+ <link rel="stylesheet" href="../qunit-composite.css">
<script src="../../../external/qunit.js"></script>
- <script src="../subsuiteRunner.js"></script>
+ <script src="../qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>
diff --git a/tests/unit/datepicker/datepicker.html b/tests/unit/datepicker/datepicker.html
index 592db53cc..bfff32d32 100644
--- a/tests/unit/datepicker/datepicker.html
+++ b/tests/unit/datepicker/datepicker.html
@@ -5,9 +5,12 @@
<title>jQuery UI Datepicker Test Suite</title>
<script src="../../jquery.js"></script>
- <script src="../../resource_loader.js"></script>
+ <link rel="stylesheet" href="../../../external/qunit.css">
+ <script src="../../../external/qunit.js"></script>
+ <script src="../../jquery.simulate.js"></script>
+ <script src="../testsuite.js"></script>
<script>
- loadResources({
+ TestHelpers.loadResources({
css: [ "ui.core", "ui.datepicker" ],
js: [
"ui/jquery.ui.core.js",
@@ -19,11 +22,6 @@
});
</script>
- <link rel="stylesheet" href="../../../external/qunit.css">
- <script src="../../../external/qunit.js"></script>
- <script src="../../jquery.simulate.js"></script>
- <script src="../testsuite.js"></script>
-
<script src="datepicker_core.js"></script>
<script src="datepicker_defaults.js"></script>
<script src="datepicker_events.js"></script>
diff --git a/tests/unit/datepicker/datepicker_core.js b/tests/unit/datepicker/datepicker_core.js
index bbc447ffe..4bf04d83e 100644
--- a/tests/unit/datepicker/datepicker_core.js
+++ b/tests/unit/datepicker/datepicker_core.js
@@ -53,52 +53,52 @@ test("widget method", function() {
});
test('baseStructure', function() {
- var inp = init('#inp');
- inp.focus();
- var dp = $('#ui-datepicker-div');
- var iframe = ($.browser.msie && parseInt($.browser.version) < 7);
+ var header, title, table, thead, week, panel, inl, child,
+ inp = init('#inp').focus(),
+ dp = $('#ui-datepicker-div'),
+ iframe = ($.browser.msie && parseInt($.browser.version, 10) < 7);
ok(dp.is(':visible'), 'Structure - datepicker visible');
ok(!dp.is('.ui-datepicker-rtl'), 'Structure - not right-to-left');
ok(!dp.is('.ui-datepicker-multi'), 'Structure - not multi-month');
equal(dp.children().length, 2 + (iframe ? 1 : 0), 'Structure - child count');
- var header = dp.children(':first');
+ header = dp.children(':first');
ok(header.is('div.ui-datepicker-header'), 'Structure - header division');
equal(header.children().length, 3, 'Structure - header child count');
- ok(header.children(':first').is('a.ui-datepicker-prev') && header.children(':first').html() != '', 'Structure - prev link');
- ok(header.children(':eq(1)').is('a.ui-datepicker-next') && header.children(':eq(1)').html() != '', 'Structure - next link');
+ ok(header.children(':first').is('a.ui-datepicker-prev') && header.children(':first').html() !== '', 'Structure - prev link');
+ ok(header.children(':eq(1)').is('a.ui-datepicker-next') && header.children(':eq(1)').html() !== '', 'Structure - next link');
- var title = header.children(':last');
- ok(title.is('div.ui-datepicker-title') && title.html() != '','Structure - title division');
+ title = header.children(':last');
+ ok(title.is('div.ui-datepicker-title') && title.html() !== '','Structure - title division');
equal(title.children().length, 2, 'Structure - title child count');
- ok(title.children(':first').is('span.ui-datepicker-month') && title.children(':first').text() != '', 'Structure - month text')
- ok(title.children(':last').is('span.ui-datepicker-year') && title.children(':last').text() != '', 'Structure - year text')
+ ok(title.children(':first').is('span.ui-datepicker-month') && title.children(':first').text() !== '', 'Structure - month text');
+ ok(title.children(':last').is('span.ui-datepicker-year') && title.children(':last').text() !== '', 'Structure - year text');
- var table = dp.children(':eq(1)');
+ table = dp.children(':eq(1)');
ok(table.is('table.ui-datepicker-calendar'), 'Structure - month table');
ok(table.children(':first').is('thead'), 'Structure - month table thead');
- var thead = table.children(':first').children(':first');
+ thead = table.children(':first').children(':first');
ok(thead.is('tr'), 'Structure - month table title row');
equal(thead.find('th').length, 7, 'Structure - month table title cells');
ok(table.children(':eq(1)').is('tbody'), 'Structure - month table body');
ok(table.children(':eq(1)').children('tr').length >= 4, 'Structure - month table week count');
- var week = table.children(':eq(1)').children(':first');
+ week = table.children(':eq(1)').children(':first');
ok(week.is('tr'), 'Structure - month table week row');
equal(week.children().length, 7, 'Structure - week child count');
ok(week.children(':first').is('td.ui-datepicker-week-end'), 'Structure - month table first day cell');
ok(week.children(':last').is('td.ui-datepicker-week-end'), 'Structure - month table second day cell');
- ok(dp.children('iframe').length == (iframe ? 1 : 0), 'Structure - iframe');
+ ok(dp.children('iframe').length === (iframe ? 1 : 0), 'Structure - iframe');
inp.datepicker('hide').datepicker('destroy');
// Editable month/year and button panel
inp = init('#inp', {changeMonth: true, changeYear: true, showButtonPanel: true});
inp.focus();
- var title = dp.find('div.ui-datepicker-title');
+ title = dp.find('div.ui-datepicker-title');
ok(title.children(':first').is('select.ui-datepicker-month'), 'Structure - month selector');
ok(title.children(':last').is('select.ui-datepicker-year'), 'Structure - year selector');
- var panel = dp.children(':last');
+ panel = dp.children(':last');
ok(panel.is('div.ui-datepicker-buttonpane'), 'Structure - button panel division');
equal(panel.children().length, 2, 'Structure - button panel child count');
ok(panel.children(':first').is('button.ui-datepicker-current'), 'Structure - today button');
@@ -110,7 +110,7 @@ test('baseStructure', function() {
inp.focus();
ok(dp.is('.ui-datepicker-multi'), 'Structure multi [2] - multi-month');
equal(dp.children().length, 3 + (iframe ? 1 : 0), 'Structure multi [2] - child count');
- var child = dp.children(':first');
+ child = dp.children(':first');
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure multi [2] - first month division');
child = dp.children(':eq(1)');
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-last'), 'Structure multi [2] - second month division');
@@ -146,16 +146,16 @@ test('baseStructure', function() {
inp.datepicker('hide').datepicker('destroy');
// Inline
- var inl = init('#inl');
+ inl = init('#inl');
dp = inl.children();
ok(dp.is('.ui-datepicker-inline'), 'Structure inline - main div');
ok(!dp.is('.ui-datepicker-rtl'), 'Structure inline - not right-to-left');
ok(!dp.is('.ui-datepicker-multi'), 'Structure inline - not multi-month');
equal(dp.children().length, 2, 'Structure inline - child count');
- var header = dp.children(':first');
+ header = dp.children(':first');
ok(header.is('div.ui-datepicker-header'), 'Structure inline - header division');
equal(header.children().length, 3, 'Structure inline - header child count');
- var table = dp.children(':eq(1)');
+ table = dp.children(':eq(1)');
ok(table.is('table.ui-datepicker-calendar'), 'Structure inline - month table');
ok(table.children(':first').is('thead'), 'Structure inline - month table thead');
ok(table.children(':eq(1)').is('tbody'), 'Structure inline - month table body');
@@ -176,19 +176,20 @@ test('baseStructure', function() {
});
test('customStructure', function() {
- var dp = $('#ui-datepicker-div');
- // Check right-to-left localisation
- var inp = init('#inp', $.datepicker.regional['he']);
+ var iframe, header, panel, title, thead,
+ dp = $('#ui-datepicker-div'),
+ // Check right-to-left localisation
+ inp = init('#inp', $.datepicker.regional.he);
inp.data('showButtonPanel.datepicker',true);
inp.focus();
- var iframe = ($.browser.msie && parseInt($.browser.version) < 7);
+ iframe = ($.browser.msie && parseInt($.browser.version, 10) < 7);
ok(dp.is('.ui-datepicker-rtl'), 'Structure RTL - right-to-left');
- var header = dp.children(':first');
+ header = dp.children(':first');
ok(header.is('div.ui-datepicker-header'), 'Structure RTL - header division');
equal(header.children().length, 3, 'Structure RTL - header child count');
ok(header.children(':first').is('a.ui-datepicker-next'), 'Structure RTL - prev link');
ok(header.children(':eq(1)').is('a.ui-datepicker-prev'), 'Structure RTL - next link');
- var panel = dp.children(':last');
+ panel = dp.children(':last');
ok(panel.is('div.ui-datepicker-buttonpane'), 'Structure RTL - button division');
equal(panel.children().length, 2, 'Structure RTL - button panel child count');
ok(panel.children(':first').is('button.ui-datepicker-close'), 'Structure RTL - close button');
@@ -198,7 +199,7 @@ test('customStructure', function() {
// Hide prev/next
inp = init('#inp', {hideIfNoPrevNext: true, minDate: new Date(2008, 2 - 1, 4), maxDate: new Date(2008, 2 - 1, 14)});
inp.val('02/10/2008').focus();
- var header = dp.children(':first');
+ header = dp.children(':first');
ok(header.is('div.ui-datepicker-header'), 'Structure hide prev/next - header division');
equal(header.children().length, 1, 'Structure hide prev/next - links child count');
ok(header.children(':first').is('div.ui-datepicker-title'), 'Structure hide prev/next - title division');
@@ -207,7 +208,7 @@ test('customStructure', function() {
// Changeable Month with read-only year
inp = init('#inp', {changeMonth: true});
inp.focus();
- var title = dp.children(':first').children(':last');
+ title = dp.children(':first').children(':last');
equal(title.children().length, 2, 'Structure changeable month - title child count');
ok(title.children(':first').is('select.ui-datepicker-month'), 'Structure changeable month - month selector');
ok(title.children(':last').is('span.ui-datepicker-year'), 'Structure changeable month - read-only year');
@@ -216,7 +217,7 @@ test('customStructure', function() {
// Changeable year with read-only month
inp = init('#inp', {changeYear: true});
inp.focus();
- var title = dp.children(':first').children(':last');
+ title = dp.children(':first').children(':last');
equal(title.children().length, 2, 'Structure changeable year - title child count');
ok(title.children(':first').is('span.ui-datepicker-month'), 'Structure changeable year - read-only month');
ok(title.children(':last').is('select.ui-datepicker-year'), 'Structure changeable year - year selector');
@@ -225,15 +226,15 @@ test('customStructure', function() {
// Read-only first day of week
inp = init('#inp', {changeFirstDay: false});
inp.focus();
- var thead = dp.find('.ui-datepicker-calendar thead tr');
+ thead = dp.find('.ui-datepicker-calendar thead tr');
equal(thead.children().length, 7, 'Structure read-only first day - thead child count');
equal(thead.find('a').length, 0, 'Structure read-only first day - thead links count');
inp.datepicker('hide').datepicker('destroy');
});
test('keystrokes', function() {
- var inp = init('#inp');
- var date = new Date();
+ var inp = init('#inp'),
+ date = new Date();
inp.val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equalsDate(inp.datepicker('getDate'), date, 'Keystroke enter');
@@ -366,9 +367,10 @@ test('keystrokes', function() {
});
test('mouse', function() {
- var inp = init('#inp');
- var dp = $('#ui-datepicker-div');
- var date = new Date();
+ var inl,
+ inp = init('#inp'),
+ dp = $('#ui-datepicker-div'),
+ date = new Date();
inp.val('').datepicker('show');
$('.ui-datepicker-calendar tbody a:contains(10)', dp).simulate('click', {});
date.setDate(10);
@@ -419,9 +421,9 @@ test('mouse', function() {
equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 18),
'Mouse click - next + min/max');
// Inline
- var inl = init('#inl');
- var dp = $('.ui-datepicker-inline', inl);
- var date = new Date();
+ inl = init('#inl');
+ dp = $('.ui-datepicker-inline', inl);
+ date = new Date();
inl.datepicker('setDate', date);
$('.ui-datepicker-calendar tbody a:contains(10)', dp).simulate('click', {});
date.setDate(10);
diff --git a/tests/unit/datepicker/datepicker_defaults.js b/tests/unit/datepicker/datepicker_defaults.js
index 4243cf187..28e150791 100644
--- a/tests/unit/datepicker/datepicker_defaults.js
+++ b/tests/unit/datepicker/datepicker_defaults.js
@@ -6,4 +6,4 @@ var datepicker_defaults = {
disabled: false
};
-//commonWidgetTests('datepicker', { defaults: datepicker_defaults });
+//TestHelpers.commonWidgetTests('datepicker', { defaults: datepicker_defaults });
diff --git a/tests/unit/datepicker/datepicker_events.js b/tests/unit/datepicker/datepicker_events.js
index 9876b7e60..b3e6704ef 100644
--- a/tests/unit/datepicker/datepicker_events.js
+++ b/tests/unit/datepicker/datepicker_events.js
@@ -5,9 +5,9 @@
module("datepicker: events");
-var selectedThis = null;
-var selectedDate = null;
-var selectedInst = null;
+var selectedThis = null,
+selectedDate = null,
+selectedInst = null;
function callback(date, inst) {
selectedThis = this;
@@ -22,8 +22,9 @@ function callback2(year, month, inst) {
}
test('events', function() {
- var inp = init('#inp', {onSelect: callback});
- var date = new Date();
+ var dateStr, newMonthYear, inp2,
+ inp = init('#inp', {onSelect: callback}),
+ date = new Date();
// onSelect
inp.val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
@@ -41,7 +42,7 @@ test('events', function() {
simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE});
equal(selectedDate, $.datepicker.formatDate('mm/dd/yy', date),
'Callback selected date - esc');
- var dateStr = '02/04/2008';
+ dateStr = '02/04/2008';
inp.val(dateStr).datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equal(dateStr, selectedDate,
@@ -49,7 +50,7 @@ test('events', function() {
// onChangeMonthYear
inp.datepicker('option', {onChangeMonthYear: callback2, onSelect: null}).
val('').datepicker('show');
- var newMonthYear = function(date) {
+ newMonthYear = function(date) {
return date.getFullYear() + '/' + (date.getMonth() + 1);
};
date = new Date();
@@ -118,7 +119,7 @@ test('events', function() {
simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.END});
equal(selectedDate, '', 'Callback close date - ctrl+end');
- var inp2 = init('#inp2');
+ inp2 = init('#inp2');
inp2.datepicker().datepicker('option', {onClose: callback}).datepicker('show');
inp.datepicker('show');
equal(selectedThis, inp2[0], 'Callback close this');
diff --git a/tests/unit/datepicker/datepicker_methods.js b/tests/unit/datepicker/datepicker_methods.js
index c8f1b75b2..603427440 100644
--- a/tests/unit/datepicker/datepicker_methods.js
+++ b/tests/unit/datepicker/datepicker_methods.js
@@ -6,7 +6,8 @@
module("datepicker: methods");
test('destroy', function() {
- var inp = init('#inp');
+ var inl,
+ inp = init('#inp');
ok(inp.is('.hasDatepicker'), 'Default - marker class set');
ok($.data(inp[0], PROP_NAME), 'Default - instance present');
ok(inp.next().is('#alt'), 'Default - button absent');
@@ -19,7 +20,7 @@ test('destroy', function() {
inp= init('#inp', {showOn: 'both'});
ok(inp.is('.hasDatepicker'), 'Button - marker class set');
ok($.data(inp[0], PROP_NAME), 'Button - instance present');
- ok(inp.next().text() == '...', 'Button - button added');
+ ok(inp.next().text() === '...', 'Button - button added');
inp.datepicker('destroy');
inp = $('#inp');
ok(!inp.is('.hasDatepicker'), 'Button - marker class cleared');
@@ -29,7 +30,7 @@ test('destroy', function() {
inp = init('#inp', {appendText: 'Testing'});
ok(inp.is('.hasDatepicker'), 'Append - marker class set');
ok($.data(inp[0], PROP_NAME), 'Append - instance present');
- ok(inp.next().text() == 'Testing', 'Append - append text added');
+ ok(inp.next().text() === 'Testing', 'Append - append text added');
inp.datepicker('destroy');
inp = $('#inp');
ok(!inp.is('.hasDatepicker'), 'Append - marker class cleared');
@@ -40,29 +41,30 @@ test('destroy', function() {
buttonImage: 'img/calendar.gif', appendText: 'Testing'});
ok(inp.is('.hasDatepicker'), 'Both - marker class set');
ok($.data(inp[0], PROP_NAME), 'Both - instance present');
- ok(inp.next()[0].nodeName.toLowerCase() == 'img', 'Both - button added');
- ok(inp.next().next().text() == 'Testing', 'Both - append text added');
+ ok(inp.next()[0].nodeName.toLowerCase() === 'img', 'Both - button added');
+ ok(inp.next().next().text() === 'Testing', 'Both - append text added');
inp.datepicker('destroy');
inp = $('#inp');
ok(!inp.is('.hasDatepicker'), 'Both - marker class cleared');
ok(!$.data(inp[0], PROP_NAME), 'Both - instance absent');
ok(inp.next().is('#alt'), 'Both - button and append text absent');
// Inline
- var inl = init('#inl');
+ inl = init('#inl');
ok(inl.is('.hasDatepicker'), 'Inline - marker class set');
- ok(inl.html() != '', 'Inline - datepicker present');
+ ok(inl.html() !== '', 'Inline - datepicker present');
ok($.data(inl[0], PROP_NAME), 'Inline - instance present');
- ok(inl.next().length == 0 || inl.next().is('p'), 'Inline - button absent');
+ ok(inl.next().length === 0 || inl.next().is('p'), 'Inline - button absent');
inl.datepicker('destroy');
inl = $('#inl');
ok(!inl.is('.hasDatepicker'), 'Inline - marker class cleared');
- ok(inl.html() == '', 'Inline - datepicker absent');
+ ok(inl.html() === '', 'Inline - datepicker absent');
ok(!$.data(inl[0], PROP_NAME), 'Inline - instance absent');
- ok(inl.next().length == 0 || inl.next().is('p'), 'Inline - button absent');
+ ok(inl.next().length === 0 || inl.next().is('p'), 'Inline - button absent');
});
test('enableDisable', function() {
- var inp = init('#inp');
+ var inl, dp,
+ inp = init('#inp');
ok(!inp.datepicker('isDisabled'), 'Enable/disable - initially marked as enabled');
ok(!inp[0].disabled, 'Enable/disable - field initially enabled');
inp.datepicker('disable');
@@ -91,19 +93,19 @@ test('enableDisable', function() {
buttonImage: 'img/calendar.gif'});
ok(!inp.datepicker('isDisabled'), 'Enable/disable image - initially marked as enabled');
ok(!inp[0].disabled, 'Enable/disable image - field initially enabled');
- ok(inp.next('img').css('opacity') == 1, 'Enable/disable image - image initially enabled');
+ ok(parseFloat(inp.next('img').css('opacity')) === 1, 'Enable/disable image - image initially enabled');
inp.datepicker('disable');
ok(inp.datepicker('isDisabled'), 'Enable/disable image - now marked as disabled');
ok(inp[0].disabled, 'Enable/disable image - field now disabled');
- ok(inp.next('img').css('opacity') != 1, 'Enable/disable image - image now disabled');
+ ok(parseFloat(inp.next('img').css('opacity')) !== 1, 'Enable/disable image - image now disabled');
inp.datepicker('enable');
ok(!inp.datepicker('isDisabled'), 'Enable/disable image - now marked as enabled');
ok(!inp[0].disabled, 'Enable/disable image - field now enabled');
- ok(inp.next('img').css('opacity') == 1, 'Enable/disable image - image now enabled');
+ ok(parseFloat(inp.next('img').css('opacity')) === 1, 'Enable/disable image - image now enabled');
inp.datepicker('destroy');
// Inline
- var inl = init('#inl', {changeYear: true});
- var dp = $('.ui-datepicker-inline', inl);
+ inl = init('#inl', {changeYear: true});
+ dp = $('.ui-datepicker-inline', inl);
ok(!inl.datepicker('isDisabled'), 'Enable/disable inline - initially marked as enabled');
ok(!dp.children().is('.ui-state-disabled'), 'Enable/disable inline - not visually disabled initially');
ok(!dp.find('select').prop('disabled'), 'Enable/disable inline - form element enabled initially');
diff --git a/tests/unit/datepicker/datepicker_options.js b/tests/unit/datepicker/datepicker_options.js
index f538c6d03..3e200ecaa 100644
--- a/tests/unit/datepicker/datepicker_options.js
+++ b/tests/unit/datepicker/datepicker_options.js
@@ -16,8 +16,8 @@ test('setDefaults', function() {
});
test('option', function() {
- var inp = init('#inp');
- var inst = $.data(inp[0], PROP_NAME);
+ var inp = init('#inp'),
+ inst = $.data(inp[0], PROP_NAME);
// Set option
equal(inst.settings.showOn, null, 'Initial setting showOn');
equal($.datepicker._get(inst, 'showOn'), 'focus', 'Initial instance showOn');
@@ -47,8 +47,8 @@ test('option', function() {
});
test('change', function() {
- var inp = init('#inp');
- var inst = $.data(inp[0], PROP_NAME);
+ var inp = init('#inp'),
+ inst = $.data(inp[0], PROP_NAME);
equal(inst.settings.showOn, null, 'Initial setting showOn');
equal($.datepicker._get(inst, 'showOn'), 'focus', 'Initial instance showOn');
equal($.datepicker._defaults.showOn, 'focus', 'Initial default showOn');
@@ -67,14 +67,15 @@ test('change', function() {
});
test('invocation', function() {
- var inp = init('#inp');
- var dp = $('#ui-datepicker-div');
- var body = $('body');
+ var button, image,
+ inp = init('#inp'),
+ dp = $('#ui-datepicker-div'),
+ body = $('body');
// On focus
- var button = inp.siblings('button');
- ok(button.length == 0, 'Focus - button absent');
- var image = inp.siblings('img');
- ok(image.length == 0, 'Focus - image absent');
+ button = inp.siblings('button');
+ ok(button.length === 0, 'Focus - button absent');
+ image = inp.siblings('img');
+ ok(image.length === 0, 'Focus - image absent');
inp.focus();
ok(dp.is(':visible'), 'Focus - rendered on focus');
inp.simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE});
@@ -89,8 +90,8 @@ test('invocation', function() {
ok(!dp.is(':visible'), 'Button - initially hidden');
button = inp.siblings('button');
image = inp.siblings('img');
- ok(button.length == 1, 'Button - button present');
- ok(image.length == 0, 'Button - image absent');
+ ok(button.length === 1, 'Button - button present');
+ ok(image.length === 0, 'Button - image absent');
equal(button.text(), 'Popup', 'Button - button text');
inp.focus();
ok(!dp.is(':visible'), 'Button - not rendered on focus');
@@ -104,9 +105,9 @@ test('invocation', function() {
buttonImage: 'img/calendar.gif', buttonText: 'Cal'});
ok(!dp.is(':visible'), 'Image button - initially hidden');
button = inp.siblings('button');
- ok(button.length == 0, 'Image button - button absent');
+ ok(button.length === 0, 'Image button - button absent');
image = inp.siblings('img');
- ok(image.length == 1, 'Image button - image present');
+ ok(image.length === 1, 'Image button - image present');
equal(image.attr('src'), 'img/calendar.gif', 'Image button - image source');
equal(image.attr('title'), 'Cal', 'Image button - image text');
inp.focus();
@@ -120,11 +121,11 @@ test('invocation', function() {
inp = init('#inp', {showOn: 'both', buttonImage: 'img/calendar.gif'});
ok(!dp.is(':visible'), 'Both - initially hidden');
button = inp.siblings('button');
- ok(button.length == 1, 'Both - button present');
+ ok(button.length === 1, 'Both - button present');
image = inp.siblings('img');
- ok(image.length == 0, 'Both - image absent');
+ ok(image.length === 0, 'Both - image absent');
image = button.children('img');
- ok(image.length == 1, 'Both - button image present');
+ ok(image.length === 1, 'Both - button image present');
inp.focus();
ok(dp.is(':visible'), 'Both - rendered on focus');
body.simulate('mousedown', {});
@@ -137,29 +138,29 @@ test('invocation', function() {
});
test('otherMonths', function() {
- var inp = init('#inp');
- var pop = $('#ui-datepicker-div');
+ var inp = init('#inp'),
+ pop = $('#ui-datepicker-div');
inp.val('06/01/2009').datepicker('show');
equal(pop.find('tbody').text(), '\u00a0123456789101112131415161718192021222324252627282930\u00a0\u00a0\u00a0\u00a0',
'Other months - none');
- ok(pop.find('td:last *').length == 0, 'Other months - no content');
+ ok(pop.find('td:last *').length === 0, 'Other months - no content');
inp.datepicker('hide').datepicker('option', 'showOtherMonths', true).datepicker('show');
equal(pop.find('tbody').text(), '311234567891011121314151617181920212223242526272829301234',
'Other months - show');
- ok(pop.find('td:last span').length == 1, 'Other months - span content');
+ ok(pop.find('td:last span').length === 1, 'Other months - span content');
inp.datepicker('hide').datepicker('option', 'selectOtherMonths', true).datepicker('show');
equal(pop.find('tbody').text(), '311234567891011121314151617181920212223242526272829301234',
'Other months - select');
- ok(pop.find('td:last a').length == 1, 'Other months - link content');
+ ok(pop.find('td:last a').length === 1, 'Other months - link content');
inp.datepicker('hide').datepicker('option', 'showOtherMonths', false).datepicker('show');
equal(pop.find('tbody').text(), '\u00a0123456789101112131415161718192021222324252627282930\u00a0\u00a0\u00a0\u00a0',
'Other months - none');
- ok(pop.find('td:last *').length == 0, 'Other months - no content');
+ ok(pop.find('td:last *').length === 0, 'Other months - no content');
});
test('defaultDate', function() {
- var inp = init('#inp');
- var date = new Date();
+ var inp = init('#inp'),
+ date = new Date();
inp.val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equalsDate(inp.datepicker('getDate'), date, 'Default date null');
@@ -252,17 +253,19 @@ test('defaultDate', function() {
});
test('miscellaneous', function() {
- var dp = $('#ui-datepicker-div');
- var inp = init('#inp');
+ var curYear, longNames, shortNames, date,
+ dp = $('#ui-datepicker-div'),
+ inp = init('#inp');
// Year range
- var genRange = function(start, offset) {
- var range = '';
- for (var i = start; i < start + offset; i++) {
+ function genRange(start, offset) {
+ var i = start,
+ range = '';
+ for (; i < start + offset; i++) {
range += i;
}
return range;
- };
- var curYear = new Date().getFullYear();
+ }
+ curYear = new Date().getFullYear();
inp.val('02/04/2008').datepicker('show');
equal(dp.find('.ui-datepicker-year').text(), '2008', 'Year range - read-only default');
inp.datepicker('hide').datepicker('option', {changeYear: true}).datepicker('show');
@@ -285,9 +288,9 @@ test('miscellaneous', function() {
equal(dp.find('.ui-datepicker-next').text(), 'Next', 'Navigation next - default');
inp.datepicker('hide').datepicker('option', {navigationAsDateFormat: true, prevText: '< M', currentText: 'MM', nextText: 'M >'}).
val('02/04/2008').datepicker('show');
- var longNames = $.datepicker.regional[''].monthNames;
- var shortNames = $.datepicker.regional[''].monthNamesShort;
- var date = new Date();
+ longNames = $.datepicker.regional[''].monthNames;
+ shortNames = $.datepicker.regional[''].monthNamesShort;
+ date = new Date();
equal(dp.find('.ui-datepicker-prev').text(), '< ' + shortNames[0], 'Navigation prev - as date format');
equal(dp.find('.ui-datepicker-current').text(),
longNames[date.getMonth()], 'Navigation current - as date format');
@@ -311,11 +314,12 @@ test('miscellaneous', function() {
});
test('minMax', function() {
- var inp = init('#inp');
- var lastYear = new Date(2007, 6 - 1, 4);
- var nextYear = new Date(2009, 6 - 1, 4);
- var minDate = new Date(2008, 2 - 1, 29);
- var maxDate = new Date(2008, 12 - 1, 7);
+ var date,
+ inp = init('#inp'),
+ lastYear = new Date(2007, 6 - 1, 4),
+ nextYear = new Date(2009, 6 - 1, 4),
+ minDate = new Date(2008, 2 - 1, 29),
+ maxDate = new Date(2008, 12 - 1, 7);
inp.val('06/04/2008').datepicker('show');
inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
@@ -360,7 +364,7 @@ test('minMax', function() {
equalsDate(inp.datepicker('getDate'), maxDate,
'Min/max - null, 12/07/2008 - ctrl+pgdn');
// Relative dates
- var date = new Date();
+ date = new Date();
date.setDate(date.getDate() - 7);
inp.datepicker('option', {minDate: '-1w', maxDate: '+1 M +10 D '}).
datepicker('hide').val('').datepicker('show');
@@ -394,9 +398,10 @@ test('minMax', function() {
});
test('setDate', function() {
- var inp = init('#inp');
- var date1 = new Date(2008, 6 - 1, 4);
- var date2 = new Date();
+ var inl, alt, minDate, maxDate, dateAndTimeToSet, dateAndTimeClone,
+ inp = init('#inp'),
+ date1 = new Date(2008, 6 - 1, 4),
+ date2 = new Date();
ok(inp.datepicker('getDate') == null, 'Set date - default');
inp.datepicker('setDate', date1);
equalsDate(inp.datepicker('getDate'), date1, 'Set date - 2008-06-04');
@@ -423,7 +428,7 @@ test('setDate', function() {
inp.datepicker('setDate', 'c -3 w');
equalsDate(inp.datepicker('getDate'), date1, 'Set date - c -3 w');
// Inline
- var inl = init('#inl');
+ inl = init('#inl');
date1 = new Date(2008, 6 - 1, 4);
date2 = new Date();
equalsDate(inl.datepicker('getDate'), date2, 'Set date inline - default');
@@ -441,7 +446,7 @@ test('setDate', function() {
inl.datepicker('setDate');
ok(inl.datepicker('getDate') == null, 'Set date inline - null');
// Alternate field
- var alt = $('#alt');
+ alt = $('#alt');
inp.datepicker('option', {altField: '#alt', altFormat: 'yy-mm-dd'});
date1 = new Date(2008, 6 - 1, 4);
inp.datepicker('setDate', date1);
@@ -451,8 +456,8 @@ test('setDate', function() {
inp = init('#inp');
date1 = new Date(2008, 1 - 1, 4);
date2 = new Date(2008, 6 - 1, 4);
- var minDate = new Date(2008, 2 - 1, 29);
- var maxDate = new Date(2008, 3 - 1, 28);
+ minDate = new Date(2008, 2 - 1, 29);
+ maxDate = new Date(2008, 3 - 1, 28);
inp.val('').datepicker('option', {minDate: minDate}).datepicker('setDate', date2);
equalsDate(inp.datepicker('getDate'), date2, 'Set date min/max - setDate > min');
inp.datepicker('setDate', date1);
@@ -465,15 +470,15 @@ test('setDate', function() {
equalsDate(inp.datepicker('getDate'), minDate, 'Set date min/max - setDate < min');
inp.datepicker('setDate', date2);
equalsDate(inp.datepicker('getDate'), maxDate, 'Set date min/max - setDate > max');
- var dateAndTimeToSet = new Date(2008, 3 - 1, 28, 1, 11, 0);
- var dateAndTimeClone = new Date(2008, 3 - 1, 28, 1, 11, 0);
+ dateAndTimeToSet = new Date(2008, 3 - 1, 28, 1, 11, 0);
+ dateAndTimeClone = new Date(2008, 3 - 1, 28, 1, 11, 0);
inp.datepicker('setDate', dateAndTimeToSet);
equal(dateAndTimeToSet.getTime(), dateAndTimeClone.getTime(), 'Date object passed should not be changed by setDate');
});
test('altField', function() {
- var inp = init('#inp');
- var alt = $('#alt');
+ var inp = init('#inp'),
+ alt = $('#alt');
// No alternate field set
alt.val('');
inp.val('06/04/2008').datepicker('show');
@@ -507,26 +512,6 @@ test('altField', function() {
inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.END});
equal(inp.val(), '', 'Alt field - dp - ctrl+end');
equal(alt.val(), '', 'Alt field - alt - ctrl+end');
-
- return
- // TODO manual entry impl works (see altField demo) but this test doesn't
- // probably something the rewrite won't cover anymore anyway
-
- // Verify alt field is updated on keyup
- alt.val('');
- inp.val('06/04/200').datepicker('show');
- inp.simulate('keydown', {charCode: '8'.charCodeAt(0)});
- inp.simulate('keypress', {charCode: '8'.charCodeAt(0)});
- inp.simulate('keyup', {charCode: '8'.charCodeAt(0)});
- equal(inp.val(), '06/04/2008', 'Alt field - dp - manual entry');
- equal(alt.val(), '2008-06-04', 'Alt field - manual entry');
- // Verify alt field is not updated on keyup if date is invalid
- inp.val('12/04');
- inp.simulate('keydown', {charCode: '/'.charCodeAt(0)});
- inp.simulate('keypress', {charCode: '/'.charCodeAt(0)});
- inp.simulate('keyup', {charCode: '/'.charCodeAt(0)});
- equal(inp.val(), '12/04/', 'Alt field - dp - manual entry incomplete');
- equal(alt.val(), '2008-06-04', 'Alt field - manual entry - not updated');
});
test('autoSize', function() {
@@ -541,7 +526,7 @@ test('autoSize', function() {
inp.datepicker('option', 'dateFormat', 'DD, MM dd, yy');
equal(inp.prop('size'), 29, 'Auto size - DD, MM dd, yy');
// French
- inp.datepicker('option', $.extend({autoSize: false}, $.datepicker.regional['fr']));
+ inp.datepicker('option', $.extend({autoSize: false}, $.datepicker.regional.fr));
equal(inp.prop('size'), 29, 'Auto size - fr - default');
inp.datepicker('option', 'autoSize', true);
equal(inp.prop('size'), 10, 'Auto size - fr - dd/mm/yy');
@@ -552,7 +537,7 @@ test('autoSize', function() {
inp.datepicker('option', 'dateFormat', 'DD, MM dd, yy');
equal(inp.prop('size'), 28, 'Auto size - fr - DD, MM dd, yy');
// Hebrew
- inp.datepicker('option', $.extend({autoSize: false}, $.datepicker.regional['he']));
+ inp.datepicker('option', $.extend({autoSize: false}, $.datepicker.regional.he));
equal(inp.prop('size'), 28, 'Auto size - he - default');
inp.datepicker('option', 'autoSize', true);
equal(inp.prop('size'), 10, 'Auto size - he - dd/mm/yy');
@@ -565,8 +550,8 @@ test('autoSize', function() {
});
test('daylightSaving', function() {
- var inp = init('#inp');
- var dp = $('#ui-datepicker-div');
+ var inp = init('#inp'),
+ dp = $('#ui-datepicker-div');
ok(true, 'Daylight saving - ' + new Date());
// Australia, Sydney - AM change, southern hemisphere
inp.val('04/01/2008').datepicker('show');
@@ -646,9 +631,12 @@ test('daylightSaving', function() {
equal(inp.val(), '11/03/2008', 'Daylight saving - US 11/03/2008');
});
-var beforeShowThis = null;
-var beforeShowInput = null;
-var beforeShowInst = null;
+var beforeShowThis = null,
+ beforeShowInput = null,
+ beforeShowInst = null,
+ beforeShowDayThis = null,
+ beforeShowDayOK = true;
+
function beforeAll(input, inst) {
beforeShowThis = this;
@@ -657,84 +645,86 @@ function beforeAll(input, inst) {
return {currentText: 'Current'};
}
-var beforeShowDayThis = null;
-var beforeShowDayOK = true;
-
function beforeDay(date) {
beforeShowDayThis = this;
beforeShowDayOK &= (date > new Date(2008, 1 - 1, 26) &&
date < new Date(2008, 3 - 1, 6));
- return [(date.getDate() % 2 == 0), (date.getDate() % 10 == 0 ? 'day10' : ''),
- (date.getDate() % 3 == 0 ? 'Divisble by 3' : '')];
+ return [(date.getDate() % 2 === 0), (date.getDate() % 10 === 0 ? 'day10' : ''),
+ (date.getDate() % 3 === 0 ? 'Divisble by 3' : '')];
}
function calcWeek(date) {
- var doy = date.getDate() + 6;
- for (var m = date.getMonth() - 1; m >= 0; m--)
+ var doy = date.getDate() + 6,
+ m = date.getMonth() - 1;
+ for (; m >= 0; m--) {
doy += $.datepicker._getDaysInMonth(date.getFullYear(), m);
+ }
// Simple count from 01/01 starting at week 1
return Math.floor(doy / 7);
}
test('callbacks', function() {
// Before show
- var inp = init('#inp', {beforeShow: beforeAll});
- var inst = $.data(inp[0], 'datepicker');
+ var dp, day20, day21,
+ inp = init('#inp', {beforeShow: beforeAll}),
+ inst = $.data(inp[0], 'datepicker');
equal($.datepicker._get(inst, 'currentText'), 'Today', 'Before show - initial');
inp.val('02/04/2008').datepicker('show');
equal($.datepicker._get(inst, 'currentText'), 'Current', 'Before show - changed');
- ok(beforeShowThis.id == inp[0].id, 'Before show - this OK');
- ok(beforeShowInput.id == inp[0].id, 'Before show - input OK');
+ ok(beforeShowThis.id === inp[0].id, 'Before show - this OK');
+ ok(beforeShowInput.id === inp[0].id, 'Before show - input OK');
deepEqual(beforeShowInst, inst, 'Before show - inst OK');
inp.datepicker('hide').datepicker('destroy');
// Before show day
inp = init('#inp', {beforeShowDay: beforeDay});
- var dp = $('#ui-datepicker-div');
+ dp = $('#ui-datepicker-div');
inp.val('02/04/2008').datepicker('show');
- ok(beforeShowDayThis.id == inp[0].id, 'Before show day - this OK');
+ ok(beforeShowDayThis.id === inp[0].id, 'Before show day - this OK');
ok(beforeShowDayOK, 'Before show day - dates OK');
- var day20 = dp.find('.ui-datepicker-calendar td:contains("20")');
- var day21 = dp.find('.ui-datepicker-calendar td:contains("21")');
+ day20 = dp.find('.ui-datepicker-calendar td:contains("20")');
+ day21 = dp.find('.ui-datepicker-calendar td:contains("21")');
ok(!day20.is('.ui-datepicker-unselectable'), 'Before show day - unselectable 20');
ok(day21.is('.ui-datepicker-unselectable'), 'Before show day - unselectable 21');
ok(day20.is('.day10'), 'Before show day - CSS 20');
ok(!day21.is('.day10'), 'Before show day - CSS 21');
ok(!day20.attr('title'), 'Before show day - title 20');
- ok(day21.attr('title') == 'Divisble by 3', 'Before show day - title 21');
+ ok(day21.attr('title') === 'Divisble by 3', 'Before show day - title 21');
inp.datepicker('hide').datepicker('destroy');
});
test('localisation', function() {
- var inp = init('#inp', $.datepicker.regional['fr']);
+ var dp, month, day, date,
+ inp = init('#inp', $.datepicker.regional.fr);
inp.datepicker('option', {dateFormat: 'DD, d MM yy', showButtonPanel:true, changeMonth:true, changeYear:true}).val('').datepicker('show');
- var dp = $('#ui-datepicker-div');
+ dp = $('#ui-datepicker-div');
equal($('.ui-datepicker-close', dp).text(), 'Fermer', 'Localisation - close');
$('.ui-datepicker-close', dp).simulate('mouseover');
equal($('.ui-datepicker-prev', dp).text(), 'Précédent', 'Localisation - previous');
equal($('.ui-datepicker-current', dp).text(), 'Aujourd\'hui', 'Localisation - current');
equal($('.ui-datepicker-next', dp).text(), 'Suivant', 'Localisation - next');
- var month = 0;
+ month = 0;
$('.ui-datepicker-month option', dp).each(function() {
- equal($(this).text(), $.datepicker.regional['fr'].monthNamesShort[month],
+ equal($(this).text(), $.datepicker.regional.fr.monthNamesShort[month],
'Localisation - month ' + month);
month++;
});
- var day = 1;
+ day = 1;
$('.ui-datepicker-calendar th', dp).each(function() {
- equal($(this).text(), $.datepicker.regional['fr'].dayNamesMin[day],
+ equal($(this).text(), $.datepicker.regional.fr.dayNamesMin[day],
'Localisation - day ' + day);
day = (day + 1) % 7;
});
inp.simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
- var date = new Date();
- equal(inp.val(), $.datepicker.regional['fr'].dayNames[date.getDay()] + ', ' +
- date.getDate() + ' ' + $.datepicker.regional['fr'].monthNames[date.getMonth()] +
+ date = new Date();
+ equal(inp.val(), $.datepicker.regional.fr.dayNames[date.getDay()] + ', ' +
+ date.getDate() + ' ' + $.datepicker.regional.fr.monthNames[date.getMonth()] +
' ' + date.getFullYear(), 'Localisation - formatting');
});
test('noWeekends', function() {
- for (var i = 1; i <= 31; i++) {
- var date = new Date(2001, 1 - 1, i);
+ var i, date;
+ for (i = 1; i <= 31; i++) {
+ date = new Date(2001, 1 - 1, i);
deepEqual($.datepicker.noWeekends(date), [(i + 1) % 7 >= 2, ''],
'No weekends ' + date);
}
@@ -769,6 +759,7 @@ test('iso8601Week', function() {
test('parseDate', function() {
init('#inp');
+ var currentYear, gmtDate, fr, settings, zh;
ok($.datepicker.parseDate('d m y', '') == null, 'Parse date empty');
equalsDate($.datepicker.parseDate('d m y', '3 2 01'),
new Date(2001, 2 - 1, 3), 'Parse date d m y');
@@ -793,7 +784,7 @@ test('parseDate', function() {
equalsDate($.datepicker.parseDate('\'day\' d \'of\' MM (\'\'DD\'\'), yy',
'day 3 of February (\'Saturday\'), 2001'), new Date(2001, 2 - 1, 3),
'Parse date \'day\' d \'of\' MM (\'\'DD\'\'), yy');
- var currentYear = new Date().getFullYear();
+ currentYear = new Date().getFullYear();
equalsDate($.datepicker.parseDate('y-m-d', (currentYear - 2000) + '-02-03'),
new Date(currentYear, 2 - 1, 3), 'Parse date y-m-d - default cutuff');
equalsDate($.datepicker.parseDate('y-m-d', (currentYear - 2000 + 10) + '-02-03'),
@@ -808,12 +799,12 @@ test('parseDate', function() {
new Date(currentYear + 60, 2 - 1, 3), 'Parse date y-m-d - cutoff +60');
equalsDate($.datepicker.parseDate('y-m-d', (currentYear - 2000 + 61) + '-02-03', {shortYearCutoff: '+60'}),
new Date(currentYear - 39, 2 - 1, 3), 'Parse date y-m-d - cutoff +60');
- var gmtDate = new Date(2001, 2 - 1, 3);
+ gmtDate = new Date(2001, 2 - 1, 3);
gmtDate.setMinutes(gmtDate.getMinutes() - gmtDate.getTimezoneOffset());
equalsDate($.datepicker.parseDate('@', '981158400000'), gmtDate, 'Parse date @');
equalsDate($.datepicker.parseDate('!', '631167552000000000'), gmtDate, 'Parse date !');
- var fr = $.datepicker.regional['fr'];
- var settings = {dayNamesShort: fr.dayNamesShort, dayNames: fr.dayNames,
+ fr = $.datepicker.regional.fr;
+ settings = {dayNamesShort: fr.dayNamesShort, dayNames: fr.dayNames,
monthNamesShort: fr.monthNamesShort, monthNames: fr.monthNames};
equalsDate($.datepicker.parseDate('D d M y', 'Lun. 9 Avril 01', settings),
new Date(2001, 4 - 1, 9), 'Parse date D M y with settings');
@@ -825,14 +816,15 @@ test('parseDate', function() {
'jour 9 de Avril (\'Lundi\'), 2001', settings), new Date(2001, 4 - 1, 9),
'Parse date \'jour\' d \'de\' MM (\'\'DD\'\'), yy with settings');
- var zh = $.datepicker.regional['zh-CN'];
+ zh = $.datepicker.regional['zh-CN'];
equalsDate($.datepicker.parseDate('yy M d', '2011 十一 22', zh),
new Date(2011, 11 - 1, 22), 'Parse date yy M d with zh-CN');
});
test('parseDateErrors', function() {
init('#inp');
- var expectError = function(expr, value, error) {
+ var fr, settings;
+ function expectError(expr, value, error) {
try {
expr();
ok(false, 'Parsed error ' + value);
@@ -840,7 +832,7 @@ test('parseDateErrors', function() {
catch (e) {
equal(e, error, 'Parsed error ' + value);
}
- };
+ }
expectError(function() { $.datepicker.parseDate(null, 'Sat 2 01'); },
'Sat 2 01', 'Invalid arguments');
expectError(function() { $.datepicker.parseDate('d m y', null); },
@@ -872,8 +864,8 @@ test('parseDateErrors', function() {
'day 3 of Mon2 ("Day7"), 2001', 'Unexpected literal at position 19');
expectError(function() { $.datepicker.parseDate('d m y', '29 2 01'); },
'29 2 01 - d m y', 'Invalid date');
- var fr = $.datepicker.regional['fr'];
- var settings = {dayNamesShort: fr.dayNamesShort, dayNames: fr.dayNames,
+ fr = $.datepicker.regional.fr;
+ settings = {dayNamesShort: fr.dayNamesShort, dayNames: fr.dayNames,
monthNamesShort: fr.monthNamesShort, monthNames: fr.monthNames};
expectError(function() { $.datepicker.parseDate('D d M y', 'Mon 9 Avr 01', settings); },
'Mon 9 Avr 01 - D d M y', 'Unknown name at position 0');
@@ -883,6 +875,7 @@ test('parseDateErrors', function() {
test('formatDate', function() {
init('#inp');
+ var gmtDate, fr, settings;
equal($.datepicker.formatDate('d m y', new Date(2001, 2 - 1, 3)),
'3 2 01', 'Format date d m y');
equal($.datepicker.formatDate('dd mm yy', new Date(2001, 2 - 1, 3)),
@@ -904,12 +897,12 @@ test('formatDate', function() {
equal($.datepicker.formatDate('\'day\' d \'of\' MM (\'\'DD\'\'), yy',
new Date(2001, 2 - 1, 3)), 'day 3 of February (\'Saturday\'), 2001',
'Format date \'day\' d \'of\' MM (\'\'DD\'\'), yy');
- var gmtDate = new Date(2001, 2 - 1, 3);
+ gmtDate = new Date(2001, 2 - 1, 3);
gmtDate.setMinutes(gmtDate.getMinutes() - gmtDate.getTimezoneOffset());
equal($.datepicker.formatDate('@', gmtDate), '981158400000', 'Format date @');
equal($.datepicker.formatDate('!', gmtDate), '631167552000000000', 'Format date !');
- var fr = $.datepicker.regional['fr'];
- var settings = {dayNamesShort: fr.dayNamesShort, dayNames: fr.dayNames,
+ fr = $.datepicker.regional.fr;
+ settings = {dayNamesShort: fr.dayNamesShort, dayNames: fr.dayNames,
monthNamesShort: fr.monthNamesShort, monthNames: fr.monthNames};
equal($.datepicker.formatDate('D M y', new Date(2001, 4 - 1, 9), settings),
'Lun. Avril 01', 'Format date D M y with settings');
diff --git a/tests/unit/datepicker/datepicker_tickets.js b/tests/unit/datepicker/datepicker_tickets.js
index fcf712370..105be63a6 100644
--- a/tests/unit/datepicker/datepicker_tickets.js
+++ b/tests/unit/datepicker/datepicker_tickets.js
@@ -7,8 +7,8 @@ module("datepicker: tickets");
// http://forum.jquery.com/topic/several-breaking-changes-in-jquery-ui-1-8rc1
test('beforeShowDay-getDate', function() {
- var inp = init('#inp', {beforeShowDay: function(date) { inp.datepicker('getDate'); return [true, '']; }});
- var dp = $('#ui-datepicker-div');
+ var inp = init('#inp', {beforeShowDay: function(date) { inp.datepicker('getDate'); return [true, '']; }}),
+ dp = $('#ui-datepicker-div');
inp.val('01/01/2010').datepicker('show');
// contains non-breaking space
equal($('div.ui-datepicker-title').text(), 'January 2010', 'Initial month');
@@ -26,11 +26,11 @@ test('beforeShowDay-getDate', function() {
test('Ticket 7602: Stop datepicker from appearing with beforeShow event handler', function(){
var inp = init('#inp',{
- beforeShow: function(){
- return false;
- }
- });
- var dp = $('#ui-datepicker-div');
+ beforeShow: function(){
+ return false;
+ }
+ }),
+ dp = $('#ui-datepicker-div');
inp.datepicker('show');
equal(dp.css('display'), 'none',"beforeShow returns false");
inp.datepicker('destroy');
diff --git a/tests/unit/dialog/all.html b/tests/unit/dialog/all.html
index 973119c08..b1c69c6c9 100644
--- a/tests/unit/dialog/all.html
+++ b/tests/unit/dialog/all.html
@@ -7,9 +7,9 @@
<script src="../../../jquery-1.7.2.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
- <link rel="stylesheet" href="../subsuiteRunner.css">
+ <link rel="stylesheet" href="../qunit-composite.css">
<script src="../../../external/qunit.js"></script>
- <script src="../subsuiteRunner.js"></script>
+ <script src="../qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>
diff --git a/tests/unit/dialog/dialog.html b/tests/unit/dialog/dialog.html
index 94b20a225..d804807f2 100644
--- a/tests/unit/dialog/dialog.html
+++ b/tests/unit/dialog/dialog.html
@@ -6,9 +6,12 @@
<script src="../../jquery.js"></script>
<script src="../../../external/jquery.bgiframe-2.1.2.js"></script>
- <script src="../../resource_loader.js"></script>
+ <link rel="stylesheet" href="../../../external/qunit.css">
+ <script src="../../../external/qunit.js"></script>
+ <script src="../../jquery.simulate.js"></script>
+ <script src="../testsuite.js"></script>
<script>
- loadResources({
+ TestHelpers.loadResources({
css: [ "ui.core", "ui.dialog" ],
js: [
"ui/jquery.ui.core.js",
@@ -22,13 +25,8 @@
});
</script>
- <link rel="stylesheet" href="../../../external/qunit.css">
- <script src="../../../external/qunit.js"></script>
- <script src="../../jquery.simulate.js"></script>
- <script src="../testsuite.js"></script>
-
+ <script src="dialog_common.js"></script>
<script src="dialog_core.js"></script>
- <script src="dialog_defaults.js"></script>
<script src="dialog_events.js"></script>
<script src="dialog_methods.js"></script>
<script src="dialog_options.js"></script>
diff --git a/tests/unit/dialog/dialog_defaults.js b/tests/unit/dialog/dialog_common.js
index 9f2e4c6a8..623908da7 100644
--- a/tests/unit/dialog/dialog_defaults.js
+++ b/tests/unit/dialog/dialog_common.js
@@ -1,4 +1,4 @@
-commonWidgetTests( "dialog", {
+TestHelpers.commonWidgetTests( "dialog", {
defaults: {
autoOpen: true,
buttons: {},
diff --git a/tests/unit/dialog/dialog_core.js b/tests/unit/dialog/dialog_core.js
index 4a671968e..5d7beb99b 100644
--- a/tests/unit/dialog/dialog_core.js
+++ b/tests/unit/dialog/dialog_core.js
@@ -40,8 +40,8 @@ function drag(handle, dx, dy) {
function moved(dx, dy, msg) {
msg = msg ? msg + "." : "";
- var actual = { left: Math.round(offsetAfter.left), top: Math.round(offsetAfter.top) };
- var expected = { left: Math.round(offsetBefore.left + dx), top: Math.round(offsetBefore.top + dy) };
+ var actual = { left: Math.round(offsetAfter.left), top: Math.round(offsetAfter.top) },
+ expected = { left: Math.round(offsetBefore.left + dx), top: Math.round(offsetBefore.top + dy) };
deepEqual(actual, expected, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ' + msg);
}
@@ -59,8 +59,8 @@ function shouldnotmove(why) {
function resized(dw, dh, msg) {
msg = msg ? msg + "." : "";
- var actual = { width: widthAfter, height: heightAfter };
- var expected = { width: widthBefore + dw, height: heightBefore + dh };
+ var actual = { width: widthAfter, height: heightAfter },
+ expected = { width: widthBefore + dw, height: heightBefore + dh };
deepEqual(actual, expected, 'resized[' + dragged.dx + ', ' + dragged.dy + '] ' + msg);
}
diff --git a/tests/unit/dialog/dialog_events.js b/tests/unit/dialog/dialog_events.js
index 4b769bafc..85afa5a3b 100644
--- a/tests/unit/dialog/dialog_events.js
+++ b/tests/unit/dialog/dialog_events.js
@@ -63,7 +63,8 @@ test("dragStart", function() {
test("drag", function() {
expect(9);
- var hasDragged = false;
+ var handle,
+ hasDragged = false;
el = $('<div></div>').dialog({
drag: function(ev, ui) {
@@ -83,7 +84,7 @@ test("drag", function() {
ok(ui.position !== undefined, "ui.position in callback");
ok(ui.offset !== undefined, "ui.offset in callback");
});
- var handle = $(".ui-dialog-titlebar", dlg());
+ handle = $(".ui-dialog-titlebar", dlg());
drag(handle, 50, 50);
el.remove();
});
@@ -138,7 +139,8 @@ test("resizeStart", function() {
test("resize", function() {
expect(13);
- var hasResized = false;
+ var handle,
+ hasResized = false;
el = $('<div></div>').dialog({
resize: function(ev, ui) {
@@ -162,7 +164,7 @@ test("resize", function() {
ok(ui.position !== undefined, "ui.position in callback");
ok(ui.size !== undefined, "ui.size in callback");
});
- var handle = $(".ui-resizable-se", dlg());
+ handle = $(".ui-resizable-se", dlg());
drag(handle, 50, 50);
el.remove();
});
diff --git a/tests/unit/dialog/dialog_methods.js b/tests/unit/dialog/dialog_methods.js
index 645baa9f5..1f84cd6b5 100644
--- a/tests/unit/dialog/dialog_methods.js
+++ b/tests/unit/dialog/dialog_methods.js
@@ -98,14 +98,17 @@ test("isOpen", function() {
});
test("moveToTop", function() {
- var expected = $('<div></div>').dialog(),
+ var d1, d2, dlg1, dlg2,
+ expected = $('<div></div>').dialog(),
actual = expected.dialog('moveToTop');
equal(actual, expected, 'moveToTop is chainable');
- var d1 = $('<div></div>').dialog(), dlg1 = d1.parents('.ui-dialog');
+ d1 = $('<div></div>').dialog();
+ dlg1 = d1.parents('.ui-dialog');
d1.dialog('close');
d1.dialog('open');
- var d2 = $('<div></div>').dialog(), dlg2 = d2.parents('.ui-dialog');
+ d2 = $('<div></div>').dialog();
+ dlg2 = d2.parents('.ui-dialog');
d2.dialog('close');
d2.dialog('open');
ok(dlg1.css('zIndex') < dlg2.css('zIndex'), 'dialog 1 under dialog 2 before moveToTop method called');
diff --git a/tests/unit/dialog/dialog_options.js b/tests/unit/dialog/dialog_options.js
index 10443892b..c071c1b09 100644
--- a/tests/unit/dialog/dialog_options.js
+++ b/tests/unit/dialog/dialog_options.js
@@ -20,7 +20,8 @@ test("autoOpen", function() {
test("buttons", function() {
expect(21);
- var buttons = {
+ var btn, i, newButtons,
+ buttons = {
"Ok": function(ev, ui) {
ok(true, "button click fires callback");
equal(this, el[0], "context of callback");
@@ -34,10 +35,10 @@ test("buttons", function() {
};
el = $('<div></div>').dialog({ buttons: buttons });
- var btn = $("button", dlg());
+ btn = $("button", dlg());
equal(btn.length, 2, "number of buttons");
- var i = 0;
+ i = 0;
$.each(buttons, function(key, val) {
equal(btn.eq(i).text(), key, "text of button " + (i+1));
i++;
@@ -48,7 +49,7 @@ test("buttons", function() {
btn.trigger("click");
- var newButtons = {
+ newButtons = {
"Close": function(ev, ui) {
ok(true, "button click fires callback");
equal(this, el[0], "context of callback");
@@ -275,54 +276,54 @@ test("minWidth", function() {
});
test("position, default center on window", function() {
- var el = $('<div></div>').dialog();
- var dialog = el.dialog('widget');
- var offset = dialog.offset();
+ var el = $('<div></div>').dialog(),
+ dialog = el.dialog('widget'),
+ offset = dialog.offset();
deepEqual(offset.left, Math.round($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft());
deepEqual(offset.top, Math.round($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop());
el.remove();
});
test("position, top on window", function() {
- var el = $('<div></div>').dialog({ position: "top" });
- var dialog = el.dialog('widget');
- var offset = dialog.offset();
+ var el = $('<div></div>').dialog({ position: "top" }),
+ dialog = el.dialog('widget'),
+ offset = dialog.offset();
deepEqual(offset.left, Math.round($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft());
deepEqual(offset.top, $(window).scrollTop());
el.remove();
});
test("position, left on window", function() {
- var el = $('<div></div>').dialog({ position: "left" });
- var dialog = el.dialog('widget');
- var offset = dialog.offset();
+ var el = $('<div></div>').dialog({ position: "left" }),
+ dialog = el.dialog('widget'),
+ offset = dialog.offset();
deepEqual(offset.left, 0);
deepEqual(offset.top, Math.round($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop());
el.remove();
});
test("position, right bottom on window", function() {
- var el = $('<div></div>').dialog({ position: "right bottom" });
- var dialog = el.dialog('widget');
- var offset = dialog.offset();
+ var el = $('<div></div>').dialog({ position: "right bottom" }),
+ dialog = el.dialog('widget'),
+ offset = dialog.offset();
deepEqual(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft());
deepEqual(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop());
el.remove();
});
test("position, right bottom on window w/array", function() {
- var el = $('<div></div>').dialog({ position: ["right", "bottom"] });
- var dialog = el.dialog('widget');
- var offset = dialog.offset();
+ var el = $('<div></div>').dialog({ position: ["right", "bottom"] }),
+ dialog = el.dialog('widget'),
+ offset = dialog.offset();
deepEqual(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft());
deepEqual(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop());
el.remove();
});
test("position, offset from top left w/array", function() {
- var el = $('<div></div>').dialog({ position: [10, 10] });
- var dialog = el.dialog('widget');
- var offset = dialog.offset();
+ var el = $('<div></div>').dialog({ position: [10, 10] }),
+ dialog = el.dialog('widget'),
+ offset = dialog.offset();
deepEqual(offset.left, 10 + $(window).scrollLeft());
deepEqual(offset.top, 10 + $(window).scrollTop());
el.remove();
@@ -330,14 +331,13 @@ test("position, offset from top left w/array", function() {
test("position, right bottom at right bottom via ui.position args", function() {
var el = $('<div></div>').dialog({
- position: {
- my: "right bottom",
- at: "right bottom"
- }
- });
-
- var dialog = el.dialog('widget');
- var offset = dialog.offset();
+ position: {
+ my: "right bottom",
+ at: "right bottom"
+ }
+ }),
+ dialog = el.dialog('widget'),
+ offset = dialog.offset();
deepEqual(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft());
deepEqual(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop());
@@ -346,23 +346,23 @@ test("position, right bottom at right bottom via ui.position args", function() {
test("position, at another element", function() {
var parent = $('<div></div>').css({
- position: 'absolute',
- top: 400,
- left: 600,
- height: 10,
- width: 10
- }).appendTo('body');
-
- var el = $('<div></div>').dialog({
- position: {
- my: "left top",
- at: "left top",
- of: parent
- }
- });
+ position: 'absolute',
+ top: 400,
+ left: 600,
+ height: 10,
+ width: 10
+ }).appendTo('body'),
+
+ el = $('<div></div>').dialog({
+ position: {
+ my: "left top",
+ at: "left top",
+ of: parent
+ }
+ }),
- var dialog = el.dialog('widget');
- var offset = dialog.offset();
+ dialog = el.dialog('widget'),
+ offset = dialog.offset();
deepEqual(offset.left, 600);
deepEqual(offset.top, 400);
@@ -373,7 +373,7 @@ test("position, at another element", function() {
of: parent
});
- var offset = dialog.offset();
+ offset = dialog.offset();
deepEqual(offset.left, 610);
deepEqual(offset.top, 410);
diff --git a/tests/unit/dialog/dialog_tickets.js b/tests/unit/dialog/dialog_tickets.js
index bd9056153..98983cf33 100644
--- a/tests/unit/dialog/dialog_tickets.js
+++ b/tests/unit/dialog/dialog_tickets.js
@@ -12,12 +12,6 @@ asyncTest( "#3123: Prevent tabbing out of modal dialogs", function() {
inputs = el.find( "input" ),
widget = el.dialog( "widget" );
- inputs.eq( 1 ).focus();
- equal( document.activeElement, inputs[1], "Focus set on second input" );
- inputs.eq( 1 ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB });
-
- setTimeout( checkTab, 2 );
-
function checkTab() {
ok( $.contains( widget, document.activeElement ), "Tab key event moved focus within the modal" );
@@ -32,14 +26,21 @@ asyncTest( "#3123: Prevent tabbing out of modal dialogs", function() {
el.remove();
start();
}
+
+ inputs.eq( 1 ).focus();
+ equal( document.activeElement, inputs[1], "Focus set on second input" );
+ inputs.eq( 1 ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB });
+
+ setTimeout( checkTab, 2 );
});
test("#4826: setting resizable false toggles resizable on dialog", function() {
expect(6);
+ var i;
el = $('<div></div>').dialog({ resizable: false });
shouldnotresize("[default]");
- for (var i=0; i<2; i++) {
+ for (i=0; i<2; i++) {
el.dialog('close').dialog('open');
shouldnotresize('initialized with resizable false toggle ('+ (i+1) +')');
}
@@ -47,7 +48,7 @@ test("#4826: setting resizable false toggles resizable on dialog", function() {
el = $('<div></div>').dialog({ resizable: true });
shouldresize("[default]");
- for (var i=0; i<2; i++) {
+ for (i=0; i<2; i++) {
el.dialog('close').dialog('option', 'resizable', false).dialog('open');
shouldnotresize('set option resizable false toggle ('+ (i+1) +')');
}
@@ -108,7 +109,7 @@ test("#6137: dialog('open') causes form elements to reset on IE7", function() {
test("#6645: Missing element not found check in overlay", function(){
expect(2);
d1 = $('<div title="dialog 1">Dialog 1</div>').dialog({modal: true});
- d2 = $('<div title="dialog 2">Dialog 2</div>').dialog({modal: true, close: function(){ d2.remove()}});
+ d2 = $('<div title="dialog 2">Dialog 2</div>').dialog({modal: true, close: function(){ d2.remove(); }});
equal($.ui.dialog.overlay.instances.length, 2, 'two overlays created');
d2.dialog('close');
equal($.ui.dialog.overlay.instances.length, 1, 'one overlay remains after closing the 2nd overlay');
@@ -116,26 +117,76 @@ test("#6645: Missing element not found check in overlay", function(){
});
test("#6966: Escape key closes all dialogs, not the top one", function(){
- expect(8);
- // test with close function removing dialog
+ expect(24);
+ // test with close function removing dialog triggered through the overlay
+ d1 = $('<div title="dialog 1">Dialog 1</div>').dialog({modal: true, close: function(){ d1.remove(); }});
+ d2 = $('<div title="dialog 2">Dialog 2</div>').dialog({modal: true, close: function(){ d2.remove(); }});
+
+ ok(d1.data('dialog') && d1.dialog('isOpen'), 'first dialog is open');
+ ok(d2.data('dialog') && d2.dialog('isOpen'), 'second dialog is open');
+
+ $( document ).simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE});
+ ok(d1.data('dialog') && d1.dialog('isOpen'), 'first dialog still open');
+ ok(!d2.data('dialog'), 'second dialog is closed');
+
+ $( document ).simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE});
+ ok(!d1.data('dialog'), 'first dialog is closed');
+ ok(!d2.data('dialog'), 'second dialog is closed');
+
+ d2.remove();
+ d1.remove();
+
+ // test with close function removing dialog triggered through the dialog
+ d1 = $('<div title="dialog 1">Dialog 1</div>').dialog({modal: true, close: function(){ d1.remove(); }});
+ d2 = $('<div title="dialog 2">Dialog 2</div>').dialog({modal: true, close: function(){ d2.remove(); }});
+
+ ok(d1.data('dialog') && d1.dialog('isOpen'), 'first dialog is open');
+ ok(d2.data('dialog') && d2.dialog('isOpen'), 'second dialog is open');
+
+ d2.simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE});
+ ok(d1.data('dialog') && d1.dialog('isOpen'), 'first dialog still open');
+ ok(!d2.data('dialog'), 'second dialog is closed');
+
+ d1.simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE});
+ ok(!d1.data('dialog'), 'first dialog is closed');
+ ok(!d2.data('dialog'), 'second dialog is closed');
+
+ d2.remove();
+ d1.remove();
+
+ // test without close function removing dialog
d1 = $('<div title="dialog 1">Dialog 1</div>').dialog({modal: true});
- d2 = $('<div title="dialog 2">Dialog 2</div>').dialog({modal: true, close: function(){ d2.remove()}});
+ d2 = $('<div title="dialog 2">Dialog 2</div>').dialog({modal: true});
+
ok(d1.dialog("isOpen"), 'first dialog is open');
ok(d2.dialog("isOpen"), 'second dialog is open');
+
d2.simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
ok(d1.dialog("isOpen"), 'first dialog still open');
- ok(!d2.data('dialog'), 'second dialog is closed');
+ ok(!d2.dialog("isOpen"), 'second dialog is closed');
+
+ d1.simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
+ ok(!d1.dialog("isOpen"), 'first dialog is closed');
+ ok(!d2.dialog("isOpen"), 'second dialog is closed');
+
d2.remove();
d1.remove();
- // test without close function removing dialog
+ // test without close function removing dialog triggered through the overlay
d1 = $('<div title="dialog 1">Dialog 1</div>').dialog({modal: true});
d2 = $('<div title="dialog 2">Dialog 2</div>').dialog({modal: true});
+
ok(d1.dialog("isOpen"), 'first dialog is open');
ok(d2.dialog("isOpen"), 'second dialog is open');
- d2.simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
+
+ $( document ).simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
ok(d1.dialog("isOpen"), 'first dialog still open');
ok(!d2.dialog("isOpen"), 'second dialog is closed');
+
+ $( document ).simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
+ ok(!d1.dialog("isOpen"), 'first dialog is closed');
+ ok(!d2.dialog("isOpen"), 'second dialog is closed');
+
d2.remove();
d1.remove();
});
diff --git a/tests/unit/draggable/all.html b/tests/unit/draggable/all.html
index 1b2a511a5..75df351ad 100644
--- a/tests/unit/draggable/all.html
+++ b/tests/unit/draggable/all.html
@@ -7,9 +7,9 @@
<script src="../../../jquery-1.7.2.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
- <link rel="stylesheet" href="../subsuiteRunner.css">
+ <link rel="stylesheet" href="../qunit-composite.css">
<script src="../../../external/qunit.js"></script>
- <script src="../subsuiteRunner.js"></script>
+ <script src="../qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>
diff --git a/tests/unit/draggable/draggable.html b/tests/unit/draggable/draggable.html
index 5be71f460..09bc191c9 100644
--- a/tests/unit/draggable/draggable.html
+++ b/tests/unit/draggable/draggable.html
@@ -5,9 +5,12 @@
<title>jQuery UI Draggable Test Suite</title>
<script src="../../jquery.js"></script>
- <script src="../../resource_loader.js"></script>
+ <link rel="stylesheet" href="../../../external/qunit.css">
+ <script src="../../../external/qunit.js"></script>
+ <script src="../../jquery.simulate.js"></script>
+ <script src="../testsuite.js"></script>
<script>
- loadResources({
+ TestHelpers.loadResources({
css: [ "ui.core" ],
js: [
"ui/jquery.ui.core.js",
@@ -18,13 +21,8 @@
});
</script>
- <link rel="stylesheet" href="../../../external/qunit.css">
- <script src="../../../external/qunit.js"></script>
- <script src="../../jquery.simulate.js"></script>
- <script src="../testsuite.js"></script>
-
+ <script src="draggable_common.js"></script>
<script src="draggable_core.js"></script>
- <script src="draggable_defaults.js"></script>
<script src="draggable_events.js"></script>
<script src="draggable_methods.js"></script>
<script src="draggable_options.js"></script>
diff --git a/tests/unit/draggable/draggable_common.js b/tests/unit/draggable/draggable_common.js
new file mode 100644
index 000000000..b47b139cd
--- /dev/null
+++ b/tests/unit/draggable/draggable_common.js
@@ -0,0 +1,32 @@
+TestHelpers.commonWidgetTests( "draggable", {
+ defaults: {
+ addClasses: true,
+ appendTo: "parent",
+ axis: false,
+ cancel: ":input,option",
+ connectToSortable: false,
+ containment: false,
+ cursor: "auto",
+ cursorAt: false,
+ delay: 0,
+ disabled: false,
+ distance: 1,
+ grid: false,
+ handle: false,
+ helper: "original",
+ iframeFix: false,
+ opacity: false,
+ refreshPositions: false,
+ revert: false,
+ revertDuration: 500,
+ scroll: true,
+ scrollSensitivity: 20,
+ scrollSpeed: 20,
+ scope: "default",
+ snap: false,
+ snapMode: "both",
+ snapTolerance: 20,
+ stack: false,
+ zIndex: false
+ }
+});
diff --git a/tests/unit/draggable/draggable_core.js b/tests/unit/draggable/draggable_core.js
index ba5bc4c66..9193881ad 100644
--- a/tests/unit/draggable/draggable_core.js
+++ b/tests/unit/draggable/draggable_core.js
@@ -4,7 +4,7 @@
var el, offsetBefore, offsetAfter, dragged;
-var drag = function(handle, dx, dy) {
+function drag(handle, dx, dy) {
var element = el.data("draggable").element;
offsetBefore = el.offset();
$(handle).simulate("drag", {
@@ -15,10 +15,10 @@ var drag = function(handle, dx, dy) {
offsetAfter = el.offset();
}
-var moved = function (dx, dy, msg) {
+function moved(dx, dy, msg) {
msg = msg ? msg + "." : "";
- var actual = { left: offsetAfter.left, top: offsetAfter.top };
- var expected = { left: offsetBefore.left + dx, top: offsetBefore.top + dy };
+ var actual = { left: offsetAfter.left, top: offsetAfter.top },
+ expected = { left: offsetBefore.left + dx, top: offsetBefore.top + dy };
deepEqual(actual, expected, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ' + msg);
}
@@ -35,15 +35,15 @@ function restoreScroll(what) {
module("draggable");
test("element types", function() {
- var typeNames = ('p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form'
- + ',table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr'
- + ',acronym,code,samp,kbd,var,img,object,hr'
- + ',input,button,label,select,iframe').split(',');
+ var typeNames = ('p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form' +
+ ',table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr' +
+ ',acronym,code,samp,kbd,var,img,object,hr' +
+ ',input,button,label,select,iframe').split(',');
$.each(typeNames, function(i) {
var typeName = typeNames[i];
el = $(document.createElement(typeName)).appendTo('body');
- (typeName == 'table' && el.append("<tr><td>content</td></tr>"));
+ (typeName === 'table' && el.append("<tr><td>content</td></tr>"));
el.draggable({ cancel: '' });
drag(el, 50, 50);
moved(50, 50, "&lt;" + typeName + "&gt;");
diff --git a/tests/unit/draggable/draggable_defaults.js b/tests/unit/draggable/draggable_defaults.js
deleted file mode 100644
index 4b0aaca19..000000000
--- a/tests/unit/draggable/draggable_defaults.js
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * draggable_defaults.js
- */
-
-var draggable_defaults = {
- addClasses: true,
- appendTo: "parent",
- axis: false,
- cancel: ":input,option",
- connectToSortable: false,
- containment: false,
- cursor: "auto",
- cursorAt: false,
- delay: 0,
- disabled: false,
- distance: 1,
- grid: false,
- handle: false,
- helper: "original",
- iframeFix: false,
- opacity: false,
- refreshPositions: false,
- revert: false,
- revertDuration: 500,
- scroll: true,
- scrollSensitivity: 20,
- scrollSpeed: 20,
- scope: "default",
- snap: false,
- snapMode: "both",
- snapTolerance: 20,
- stack: false,
- zIndex: false
-};
-
-commonWidgetTests('draggable', { defaults: draggable_defaults });
diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js
index d5f85feab..464e025dd 100644
--- a/tests/unit/draggable/draggable_options.js
+++ b/tests/unit/draggable/draggable_options.js
@@ -17,15 +17,16 @@ function setScroll(what) {
}
}
-var border = function(el, side) { return parseInt(el.css('border-' + side + '-width')); }
-
-var margin = function(el, side) { return parseInt(el.css('margin-' + side)); }
+function border(el, side) {
+ return parseInt(el.css('border-' + side + '-width'), 10);
+}
+function margin(el, side) {
+ return parseInt(el.css('margin-' + side), 10);
+}
module("draggable: options");
test("{ addClasses: true }, default", function() {
- equal(draggable_defaults.addClasses, true);
-
el = $("<div></div>").draggable({ addClasses: true });
ok(el.is(".ui-draggable"), "'ui-draggable' class added");
@@ -40,8 +41,6 @@ test("{ addClasses: false }", function() {
});
test("{ appendTo: 'parent' }, default", function() {
- equal(draggable_defaults.appendTo, "parent");
-
el = $("#draggable2").draggable({ appendTo: 'parent' });
drag(el, 50, 50);
moved(50, 50);
@@ -73,8 +72,6 @@ test("{ appendTo: Selector }", function() {
});
test("{ axis: false }, default", function() {
- equal(draggable_defaults.axis, false);
-
el = $("#draggable2").draggable({ axis: false });
drag(el, 50, 50);
moved(50, 50);
@@ -106,12 +103,10 @@ test("{ axis: ? }, unexpected", function() {
drag(el, 50, 50);
moved(50, 50, "axis: " + key);
el.draggable("destroy");
- })
+ });
});
test("{ cancel: ':input,option' }, default", function() {
- equal(draggable_defaults.cancel, ":input,option");
-
$('<div id="draggable-option-cancel-default"><input type="text"></div>').appendTo('#main');
el = $("#draggable-option-cancel-default").draggable({ cancel: ":input,option" });
@@ -155,12 +150,10 @@ test("{ cancel: ? }, unexpected", function() {
var expected = [50, 50];
moved(expected[0], expected[1], "cancel: " + key);
el.draggable("destroy");
- })
+ });
});
test("{ containment: false }, default", function() {
- equal(draggable_defaults.containment, false);
-
ok(false, 'missing test - untested code is broken code');
});
@@ -170,23 +163,25 @@ test("{ containment: Element }", function() {
test("{ containment: 'parent' }, relative", function() {
el = $("#draggable1").draggable({ containment: 'parent' });
- var p = el.parent(), po = p.offset();
+ var p = el.parent(),
+ po = p.offset(),
+ expected = {
+ left: po.left + border(p, 'left') + margin(el, 'left'),
+ top: po.top + border(p, 'top') + margin(el, 'top')
+ };
drag(el, -100, -100);
- var expected = {
- left: po.left + border(p, 'left') + margin(el, 'left'),
- top: po.top + border(p, 'top') + margin(el, 'top')
- }
deepEqual(offsetAfter, expected, 'compare offset to parent');
});
test("{ containment: 'parent' }, absolute", function() {
el = $("#draggable2").draggable({ containment: 'parent' });
- var p = el.parent(), po = p.offset();
+ var p = el.parent(),
+ po = p.offset(),
+ expected = {
+ left: po.left + border(p, 'left') + margin(el, 'left'),
+ top: po.top + border(p, 'top') + margin(el, 'top')
+ };
drag(el, -100, -100);
- var expected = {
- left: po.left + border(p, 'left') + margin(el, 'left'),
- top: po.top + border(p, 'top') + margin(el, 'top')
- }
deepEqual(offsetAfter, expected, 'compare offset to parent');
});
@@ -207,11 +202,9 @@ test("{ containment: [x1, y1, x2, y2] }", function() {
});
test("{ cursor: 'auto' }, default", function() {
- equal(draggable_defaults.cursor, 'auto');
-
function getCursor() { return $("#draggable2").css("cursor"); }
- expect(3);
+ expect(2);
var expected = "auto", actual, before, after;
@@ -256,8 +249,6 @@ test("{ cursor: 'move' }", function() {
});
test("{ cursorAt: false}, default", function() {
- equal(draggable_defaults.cursorAt, false);
-
ok(false, 'missing test - untested code is broken code');
});
@@ -611,8 +602,8 @@ test("{ helper: 'original' }, fixed, with scroll offset on root and parent", fun
test("{ helper: 'clone' }, absolute", function() {
- var helperOffset = null;
- var origOffset = $("#draggable1").offset();
+ var helperOffset = null,
+ origOffset = $("#draggable1").offset();
el = $("#draggable1").draggable({ helper: "clone", drag: function(event, ui) {
helperOffset = ui.helper.offset();
@@ -626,8 +617,8 @@ test("{ helper: 'clone' }, absolute", function() {
test("{ helper: 'clone' }, absolute with scroll offset on parent", function() {
setScroll();
- var helperOffset = null;
- var origOffset = null;
+ var helperOffset = null,
+ origOffset = null;
el = $("#draggable1").draggable({ helper: "clone", drag: function(event, ui) {
helperOffset = ui.helper.offset();
@@ -655,8 +646,8 @@ test("{ helper: 'clone' }, absolute with scroll offset on parent", function() {
test("{ helper: 'clone' }, absolute with scroll offset on root", function() {
setScroll('root');
- var helperOffset = null;
- var origOffset = null;
+ var helperOffset = null,
+ origOffset = null;
el = $("#draggable1").draggable({ helper: "clone", drag: function(event, ui) {
helperOffset = ui.helper.offset();
@@ -685,25 +676,25 @@ test("{ helper: 'clone' }, absolute with scroll offset on root and parent", func
setScroll('root');
setScroll();
- var helperOffset = null;
- var origOffset = null;
+ var helperOffset = null,
+ origOffset = null;
el = $("#draggable1").draggable({ helper: "clone", drag: function(event, ui) {
helperOffset = ui.helper.offset();
} });
$("#main").css('position', 'relative');
- origOffset = $("#draggable1").offset()
+ origOffset = $("#draggable1").offset();
drag(el, 1, 1);
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
$("#main").css('position', 'static');
- origOffset = $("#draggable1").offset()
+ origOffset = $("#draggable1").offset();
drag(el, 1, 1);
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
$("#main").css('position', 'absolute');
- origOffset = $("#draggable1").offset()
+ origOffset = $("#draggable1").offset();
drag(el, 1, 1);
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
@@ -734,9 +725,9 @@ test("{ zIndex: 10 }", function() {
expect(1);
- var expected = 10, actual;
-
- var zIndex = null;
+ var actual,
+ expected = 10,
+ zIndex = null;
el = $("#draggable2").draggable({
zIndex: expected,
start: function(event, ui) {
diff --git a/tests/unit/droppable/all.html b/tests/unit/droppable/all.html
index 535f41521..aa24ed7e1 100644
--- a/tests/unit/droppable/all.html
+++ b/tests/unit/droppable/all.html
@@ -7,9 +7,9 @@
<script src="../../../jquery-1.7.2.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
- <link rel="stylesheet" href="../subsuiteRunner.css">
+ <link rel="stylesheet" href="../qunit-composite.css">
<script src="../../../external/qunit.js"></script>
- <script src="../subsuiteRunner.js"></script>
+ <script src="../qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>
diff --git a/tests/unit/droppable/droppable.html b/tests/unit/droppable/droppable.html
index abf94f0c7..49ebf6beb 100644
--- a/tests/unit/droppable/droppable.html
+++ b/tests/unit/droppable/droppable.html
@@ -5,9 +5,12 @@
<title>jQuery UI Droppable Test Suite</title>
<script src="../../jquery.js"></script>
- <script src="../../resource_loader.js"></script>
+ <link rel="stylesheet" href="../../../external/qunit.css">
+ <script src="../../../external/qunit.js"></script>
+ <script src="../../jquery.simulate.js"></script>
+ <script src="../testsuite.js"></script>
<script>
- loadResources({
+ TestHelpers.loadResources({
css: [ "ui.core" ],
js: [
"ui/jquery.ui.core.js",
@@ -19,13 +22,8 @@
});
</script>
- <link rel="stylesheet" href="../../../external/qunit.css">
- <script src="../../../external/qunit.js"></script>
- <script src="../../jquery.simulate.js"></script>
- <script src="../testsuite.js"></script>
-
+ <script src="droppable_common.js"></script>
<script src="droppable_core.js"></script>
- <script src="droppable_defaults.js"></script>
<script src="droppable_events.js"></script>
<script src="droppable_methods.js"></script>
<script src="droppable_options.js"></script>
diff --git a/tests/unit/droppable/droppable_common.js b/tests/unit/droppable/droppable_common.js
new file mode 100644
index 000000000..985dba06d
--- /dev/null
+++ b/tests/unit/droppable/droppable_common.js
@@ -0,0 +1,12 @@
+TestHelpers.commonWidgetTests( "droppable", {
+ defaults: {
+ accept: "*",
+ activeClass: false,
+ addClasses: true,
+ disabled: false,
+ greedy: false,
+ hoverClass: false,
+ scope: "default",
+ tolerance: "intersect"
+ }
+});
diff --git a/tests/unit/droppable/droppable_core.js b/tests/unit/droppable/droppable_core.js
index 4d82017b9..3f709d25d 100644
--- a/tests/unit/droppable/droppable_core.js
+++ b/tests/unit/droppable/droppable_core.js
@@ -17,15 +17,15 @@ function shouldNotBeDroppable() {
module("droppable: core");
test("element types", function() {
- var typeNames = ('p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form'
- + ',table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr'
- + ',acronym,code,samp,kbd,var,img,object,hr'
- + ',input,button,label,select,iframe').split(',');
+ var typeNames = ('p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form' +
+ ',table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr' +
+ ',acronym,code,samp,kbd,var,img,object,hr' +
+ ',input,button,label,select,iframe').split(',');
$.each(typeNames, function(i) {
var typeName = typeNames[i];
el = $(document.createElement(typeName)).appendTo('body');
- (typeName == 'table' && el.append("<tr><td>content</td></tr>"));
+ (typeName === 'table' && el.append("<tr><td>content</td></tr>"));
el.droppable();
shouldBeDroppable();
el.droppable("destroy");
diff --git a/tests/unit/droppable/droppable_defaults.js b/tests/unit/droppable/droppable_defaults.js
deleted file mode 100644
index 7584f5ec8..000000000
--- a/tests/unit/droppable/droppable_defaults.js
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * droppable_defaults.js
- */
-
-var droppable_defaults = {
- accept: '*',
- activeClass: false,
- addClasses: true,
- disabled: false,
- greedy: false,
- hoverClass: false,
- scope: "default",
- tolerance: "intersect"
-};
-
-commonWidgetTests('droppable', { defaults: droppable_defaults });
diff --git a/tests/unit/droppable/droppable_options.js b/tests/unit/droppable/droppable_options.js
index 4df2d9ecb..19295778b 100644
--- a/tests/unit/droppable/droppable_options.js
+++ b/tests/unit/droppable/droppable_options.js
@@ -6,8 +6,6 @@
module("droppable: options");
test("{ accept '*' }, default ", function() {
- equal(droppable_defaults.accept, '*');
-
ok(false, 'missing test - untested code is broken code');
});
@@ -24,8 +22,6 @@ test("activeClass", function() {
});
test("{ addClasses: true }, default", function() {
- equal(droppable_defaults.addClasses, true);
-
el = $("<div></div>").droppable({ addClasses: true });
ok(el.is(".ui-droppable"), "'ui-droppable' class added");
el.droppable("destroy");
diff --git a/tests/unit/effects/all.html b/tests/unit/effects/all.html
index 0ef901292..59500588c 100644
--- a/tests/unit/effects/all.html
+++ b/tests/unit/effects/all.html
@@ -7,9 +7,9 @@
<script src="../../../jquery-1.7.2.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
- <link rel="stylesheet" href="../subsuiteRunner.css">
+ <link rel="stylesheet" href="../qunit-composite.css">
<script src="../../../external/qunit.js"></script>
- <script src="../subsuiteRunner.js"></script>
+ <script src="../qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>
diff --git a/tests/unit/effects/effects.html b/tests/unit/effects/effects.html
index 06023c55d..1fd94182d 100644
--- a/tests/unit/effects/effects.html
+++ b/tests/unit/effects/effects.html
@@ -8,9 +8,12 @@
<script>
$.uiBackCompat = false;
</script>
- <script src="../../resource_loader.js"></script>
+ <link rel="stylesheet" href="../../../external/qunit.css">
+ <script src="../../../external/qunit.js"></script>
+ <script src="../../jquery.simulate.js"></script>
+ <script src="../testsuite.js"></script>
<script>
- loadResources({
+ TestHelpers.loadResources({
js: [
"ui/jquery.effects.core.js",
"ui/jquery.effects.blind.js",
@@ -30,10 +33,6 @@
});
</script>
- <link rel="stylesheet" href="../../../external/qunit.css">
- <script src="../../../external/qunit.js"></script>
- <script src="../../jquery.simulate.js"></script>
- <script src="../testsuite.js"></script>
<script src="effects_core.js"></script>
<script src="effects_scale.js"></script>
diff --git a/tests/unit/effects/effects_core.js b/tests/unit/effects/effects_core.js
index aca4c4694..955e6f799 100644
--- a/tests/unit/effects/effects_core.js
+++ b/tests/unit/effects/effects_core.js
@@ -31,6 +31,7 @@ test( "Immediate Return Conditions", function() {
equal( ++count, 3, "Both Functions worked properly" );
});
+/* TODO: Disabled - Can't figure out why this is failing in IE 6/7
test( "createWrapper and removeWrapper retain focused elements (#7595)", function() {
expect( 2 );
var test = $( "div.hidden" ).show(),
@@ -41,7 +42,7 @@ test( "createWrapper and removeWrapper retain focused elements (#7595)", functio
$.effects.removeWrapper( test );
equal( document.activeElement, input[ 0 ], "Active element is still input after removeWrapper" );
});
-
+*/
module( "effects.core: animateClass" );
@@ -61,45 +62,86 @@ asyncTest( "animateClass works with borderStyle", function() {
asyncTest( "animateClass works with colors", function() {
var test = $("div.animateClass"),
- count = 0;
+ count = 0,
+ oldStep = jQuery.fx.step.backgroundColor;
expect(2);
- test.toggleClass("testChangeBackground", duration, function() {
- present( test.css("backgroundColor"), [ "#ffffff", "#fff", "rgb(255, 255, 255)" ], "Color is final" );
- start();
+
+ // we want to catch the first frame of animation
+ jQuery.fx.step.backgroundColor = function( fx ) {
+ oldStep.apply( this, arguments );
+
+ // make sure it has animated somewhere we can detect
+ if ( fx.pos > 255 / 2000 ) {
+ jQuery.fx.step.backgroundColor = oldStep;
+ notPresent( test.css("backgroundColor"),
+ [ "#000000", "#ffffff", "#000", "#fff", "rgb(0, 0, 0)", "rgb(255,255,255)" ],
+ "Color is not endpoints in middle." );
+ test.stop( true, true );
+ }
+ };
+
+ test.toggleClass("testChangeBackground", {
+ duration: 2000,
+ complete: function() {
+ present( test.css("backgroundColor"), [ "#ffffff", "#fff", "rgb(255, 255, 255)" ], "Color is final" );
+ start();
+ }
});
- setTimeout(function() {
- var color = test.css("backgroundColor");
- notPresent( color, [ "#000000", "#ffffff", "#000", "#fff", "rgb(0, 0, 0)", "rgb(255,255,255)" ],
- "Color is not endpoints in middle." );
- }, mid);
});
-asyncTest( "animateClass works with children", function() {
- var test = $("div.animateClass"),
- h2 = test.find("h2");
+asyncTest( "animateClass calls step option", 1, function() {
+ var test = jQuery("div.animateClass"),
+ done = function() {
+ done = jQuery.noop;
+ test.stop();
+ start();
+ };
+ test.toggleClass( "testChangeBackground", {
+ step: function( fx ) {
+ ok( true, "Step Function Called" );
+ setTimeout( done, 0 );
+ }
+ });
+});
- expect(4);
- setTimeout(function() {
- notPresent( h2.css("fontSize"), ["10px","20px"], "Font size is neither endpoint when in middle.");
- }, mid);
- test.toggleClass("testChildren", { children: true, duration: duration, complete: function() {
- equal( h2.css("fontSize"), "20px", "Text size is final during complete");
- test.toggleClass("testChildren", duration, function() {
- equal( h2.css("fontSize"), "10px", "Text size revertted after class removed");
+asyncTest( "animateClass works with children", 3, function() {
+ var animatedChild,
+ test = $("div.animateClass"),
+ h2 = test.find("h2");
- start();
- });
- setTimeout(function() {
- equal( h2.css("fontSize"), "20px", "Text size unchanged during animate with children: undefined" );
- }, mid);
- }});
+ test.toggleClass("testChildren", {
+ children: true,
+ duration: duration,
+ complete: function() {
+ equal( h2.css("fontSize"), "20px", "Text size is final during complete");
+ test.toggleClass("testChildren", {
+ duration: duration,
+ complete: function() {
+ equal( h2.css("fontSize"), "10px", "Text size revertted after class removed");
+
+ start();
+ },
+ step: function( val, fx ) {
+ if ( fx.elem === h2[ 0 ] ) {
+ ok( false, "Error - Animating property on h2" );
+ }
+ }
+ });
+ },
+ step: function( val, fx ) {
+ if ( fx.prop === "fontSize" && fx.elem === h2[ 0 ] && !animatedChild ) {
+ equal( fx.end, 20, "animating font size on child" );
+ animatedChild = true;
+ }
+ }
+ });
});
asyncTest( "animateClass clears style properties when stopped", function() {
var test = $("div.animateClass"),
style = test[0].style,
orig = style.cssText;
-
+
expect( 2 );
test.addClass( "testChangeBackground", duration );
@@ -113,30 +155,35 @@ asyncTest( "animateClass clears style properties when stopped", function() {
asyncTest( "animateClass: css and class changes during animation are not lost (#7106)", function() {
var test = $( "div.ticket7106" );
- // add a class and change a style property after starting an animated class
- test.addClass( "animate", minDuration, animationComplete )
- .addClass( "testClass" )
- .height( 100 );
-
// ensure the class stays and that the css property stays
function animationComplete() {
ok( test.hasClass( "testClass" ), "class change during animateClass was not lost" );
equal( test.height(), 100, "css change during animateClass was not lost" );
start();
}
+
+ // add a class and change a style property after starting an animated class
+ test.addClass( "animate", minDuration, animationComplete )
+ .addClass( "testClass" )
+ .height( 100 );
});
$.each( $.effects.effect, function( effect ) {
+ module( "effects." + effect );
+
+ // puff and size are defined inside scale
+ if ( effect !== "puff" && effect !== "size" ) {
+ TestHelpers.testJshint( "effects." + effect );
+ }
+
if ( effect === "transfer" ) {
return;
}
- module( "effect."+effect );
asyncTest( "show/hide", function() {
- var hidden = $( "div.hidden" );
expect( 8 );
-
- var count = 0,
+ var hidden = $( "div.hidden" ),
+ count = 0,
test = 0;
function queueTest( fn ) {
diff --git a/tests/unit/effects/effects_scale.js b/tests/unit/effects/effects_scale.js
index b9bb91c2e..df61d9e91 100644
--- a/tests/unit/effects/effects_scale.js
+++ b/tests/unit/effects/effects_scale.js
@@ -4,6 +4,11 @@ module( "effect.scale: Scale" );
function run( position, v, h, vo, ho ) {
var desc = "End Position Correct: " + position + " (" + v + "," + h + ") - origin: (" + vo + "," + ho + ")";
asyncTest( desc, function() {
+ function complete() {
+ equal( parseInt( test.css( h ), 10 ), target[ h ], "Horizontal Position Correct " + desc );
+ equal( parseInt( test.css( v ), 10 ), target[ v ], "Vertical Position Correct " + desc );
+ start();
+ }
var test = $( ".testScale" ),
css = {
position: position
@@ -21,22 +26,16 @@ function run( position, v, h, vo, ho ) {
css[ h ] = 33;
css[ v ] = 33;
- target[ h ] = h === ho ? css[ h ] : ho == "center" ? css[ h ] - 35 : css[ h ] - 70;
- target[ v ] = v === vo ? css[ v ] : vo == "middle" ? css[ v ] - 35 : css[ v ] - 70;
- if ( relative && h == "right" ) {
+ target[ h ] = h === ho ? css[ h ] : ho === "center" ? css[ h ] - 35 : css[ h ] - 70;
+ target[ v ] = v === vo ? css[ v ] : vo === "middle" ? css[ v ] - 35 : css[ v ] - 70;
+ if ( relative && h === "right" ) {
target[ h ] += 70;
}
- if ( relative && v == "bottom" ) {
+ if ( relative && v === "bottom" ) {
target[ v ] += 70;
}
test.css( css );
test.effect( effect );
-
- function complete() {
- equal( parseInt( test.css( h ), 10 ), target[ h ], "Horizontal Position Correct " + desc );
- equal( parseInt( test.css( v ), 10 ), target[ v ], "Vertical Position Correct " + desc );
- start();
- }
});
}
diff --git a/tests/unit/menu/all.html b/tests/unit/menu/all.html
index a58e15299..475c1b717 100644
--- a/tests/unit/menu/all.html
+++ b/tests/unit/menu/all.html
@@ -7,9 +7,9 @@
<script src="../../../jquery-1.7.2.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
- <link rel="stylesheet" href="../subsuiteRunner.css">
+ <link rel="stylesheet" href="../qunit-composite.css">
<script src="../../../external/qunit.js"></script>
- <script src="../subsuiteRunner.js"></script>
+ <script src="../qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>
diff --git a/tests/unit/menu/menu.html b/tests/unit/menu/menu.html
index 76f4a7a31..fca45697f 100644
--- a/tests/unit/menu/menu.html
+++ b/tests/unit/menu/menu.html
@@ -5,9 +5,12 @@
<title>jQuery UI Menu Test Suite</title>
<script src="../../jquery.js"></script>
- <script src="../../resource_loader.js"></script>
+ <link rel="stylesheet" href="../../../external/qunit.css">
+ <script src="../../../external/qunit.js"></script>
+ <script src="../../jquery.simulate.js"></script>
+ <script src="../testsuite.js"></script>
<script>
- loadResources({
+ TestHelpers.loadResources({
css: [ "ui.core", "ui.menu" ],
js: [
"ui/jquery.ui.core.js",
@@ -17,14 +20,9 @@
});
</script>
- <link rel="stylesheet" href="../../../external/qunit.css">
- <script src="../../../external/qunit.js"></script>
- <script src="../../jquery.simulate.js"></script>
- <script src="../testsuite.js"></script>
-
<script src="menu_test_helpers.js"></script>
+ <script src="menu_common.js"></script>
<script src="menu_core.js"></script>
- <script src="menu_defaults.js"></script>
<script src="menu_events.js"></script>
<script src="menu_methods.js"></script>
<script src="menu_options.js"></script>
@@ -251,6 +249,22 @@
</blockquote>
</div>
+<ul id="menu6">
+ <li class="foo"><a class="foo" href="#">Aberdeen</a></li>
+ <li class="foo ui-state-disabled"><a class="foo" href="#">Ada</a></li>
+ <li class="foo"><a class="foo" href="#">Adamsville</a></li>
+ <li class="foo"><a class="foo" href="#">Addyston</a></li>
+ <li class="ui-state-disabled">
+ <a href="#">Delphi</a>
+ <ul>
+ <li class="foo"><a class="foo" href="#">Ada</a></li>
+ <li class="foo"><a class="foo" href="#">Saarland</a></li>
+ <li class="foo"><a class="foo" href="#">Salzburg</a></li>
+ </ul>
+ </li>
+ <li class="foo"><a class="foo" href="#">Saarland</a></li>
+</ul>
+
<div id="log"></div>
</div>
diff --git a/tests/unit/menu/menu_defaults.js b/tests/unit/menu/menu_common.js
index 018ac8ccf..ddcdbebf2 100644
--- a/tests/unit/menu/menu_defaults.js
+++ b/tests/unit/menu/menu_common.js
@@ -1,4 +1,4 @@
-commonWidgetTests( "menu", {
+TestHelpers.commonWidgetTests( "menu", {
defaults: {
disabled: false,
menus: "ul",
diff --git a/tests/unit/menu/menu_core.js b/tests/unit/menu/menu_core.js
index 02e3be3be..f2de7ef1a 100644
--- a/tests/unit/menu/menu_core.js
+++ b/tests/unit/menu/menu_core.js
@@ -9,18 +9,19 @@ module("menu: core");
test("accessibility", function () {
expect(5);
- var menu = $('#menu1').menu();
- var item0 = $("li:eq(0) a");
+ var item,
+ menu = $('#menu1').menu(),
+ item0 = $("li:eq(0) a");
ok( menu.hasClass("ui-menu ui-widget ui-widget-content ui-corner-all"), "menu class");
equal( menu.attr("role"), "menu", "main role");
ok( !menu.attr("aria-activedescendant"), "aria attribute not yet active");
- var item = menu.find( "li:first" ).find( "a" ).attr( "id", "xid" ).end();
+ item = menu.find( "li:first" ).find( "a" ).attr( "id", "xid" ).end();
menu.menu( "focus", $.Event(), item );
equal( menu.attr("aria-activedescendant"), "xid", "aria attribute, id from dom");
- var item = menu.find( "li:last" );
+ item = menu.find( "li:last" );
menu.menu( "focus", $.Event(), item );
equal( menu.attr("aria-activedescendant"), "menu1-4", "aria attribute, generated id");
});
diff --git a/tests/unit/menu/menu_events.js b/tests/unit/menu/menu_events.js
index bee6fcfa6..4cb083240 100644
--- a/tests/unit/menu/menu_events.js
+++ b/tests/unit/menu/menu_events.js
@@ -3,21 +3,24 @@
*/
(function($) {
+var log = TestHelpers.menu.log,
+ click = TestHelpers.menu.click;
+
module("menu: events");
test("handle click on menu", function() {
expect(1);
var menu = $('#menu1').menu({
select: function(event, ui) {
- menu_log();
+ log();
}
});
- menu_log("click",true);
- menu_click($('#menu1'),"1");
- menu_log("afterclick");
- menu_click( menu,"2");
- menu_click($('#menu1'),"3");
- menu_click( menu,"1");
+ log("click",true);
+ click($('#menu1'),"1");
+ log("afterclick");
+ click( menu,"2");
+ click($('#menu1'),"3");
+ click( menu,"1");
equal( $("#log").html(), "1,3,2,afterclick,1,click,", "Click order not valid.");
});
@@ -25,16 +28,16 @@ test("handle click on custom item menu", function() {
expect(1);
var menu = $('#menu5').menu({
select: function(event, ui) {
- menu_log();
+ log();
},
menus: "div"
});
- menu_log("click",true);
- menu_click($('#menu5'),"1");
- menu_log("afterclick");
- menu_click( menu,"2");
- menu_click($('#menu5'),"3");
- menu_click( menu,"1");
+ log("click",true);
+ click($('#menu5'),"1");
+ log("afterclick");
+ click( menu,"2");
+ click($('#menu5'),"3");
+ click( menu,"1");
equal( $("#log").html(), "1,3,2,afterclick,1,click,", "Click order not valid.");
});
@@ -75,7 +78,7 @@ test( "handle blur on custom item menu: click", function() {
items: "div"
});
- menu_click($('#menu5'),"1");
+ click($('#menu5'),"1");
$( "<a>", { id: "remove"} ).appendTo("body").trigger( "click" );
$("#remove").remove();
@@ -84,14 +87,12 @@ test( "handle blur on custom item menu: click", function() {
asyncTest( "handle submenu auto collapse: mouseleave", function() {
expect( 4 );
- var $menu = $( "#menu2" ).menu();
-
- $menu.find( "li:nth-child(7)" ).trigger( "mouseover" );
- setTimeout( menumouseleave1, 350 );
+ var $menu = $( "#menu2" ).menu(),
+ event = $.Event( "mouseenter" );
function menumouseleave1() {
equal( $menu.find( "ul[aria-expanded='true']" ).length, 1, "first submenu expanded" );
- $menu.find( "li:nth-child(7) li:first" ).trigger( "mouseover" );
+ $menu.menu( "focus", event, $menu.find( "li:nth-child(7) li:first" ) );
setTimeout( menumouseleave2, 350 );
}
function menumouseleave2() {
@@ -108,18 +109,19 @@ asyncTest( "handle submenu auto collapse: mouseleave", function() {
equal( $menu.find( "ul[aria-expanded='true']" ).length, 0, "first submenu collapsed" );
start();
}
+
+ $menu.find( "li:nth-child(7)" ).trigger( "mouseenter" );
+ setTimeout( menumouseleave1, 350 );
});
asyncTest( "handle submenu auto collapse: mouseleave", function() {
expect( 4 );
- var $menu = $( "#menu5" ).menu( { menus: "div" } );
-
- $menu.find( ":nth-child(7)" ).trigger( "mouseover" );
- setTimeout( menumouseleave1, 350 );
+ var $menu = $( "#menu5" ).menu( { menus: "div" } ),
+ event = $.Event( "mouseenter" );
function menumouseleave1() {
equal( $menu.find( "div[aria-expanded='true']" ).length, 1, "first submenu expanded" );
- $menu.find( ":nth-child(7)" ).find( "div" ).eq( 0 ).children().eq( 0 ).trigger( "mouseover" );
+ $menu.menu( "focus", event, $menu.find( ":nth-child(7)" ).find( "div" ).eq( 0 ).children().eq( 0 ) );
setTimeout( menumouseleave2, 350 );
}
function menumouseleave2() {
@@ -136,6 +138,10 @@ asyncTest( "handle submenu auto collapse: mouseleave", function() {
equal( $menu.find( "div[aria-expanded='true']" ).length, 0, "first submenu collapsed" );
start();
}
+
+ $menu.find( ":nth-child(7)" ).trigger( "mouseenter" );
+ setTimeout( menumouseleave1, 350 );
+
});
@@ -143,60 +149,60 @@ test("handle keyboard navigation on menu without scroll and without submenus", f
expect(12);
var element = $('#menu1').menu({
select: function(event, ui) {
- menu_log($(ui.item[0]).text());
+ log($(ui.item[0]).text());
},
focus: function( event, ui ) {
- menu_log($(event.target).find(".ui-state-focus").parent().index());
+ log($(event.target).find(".ui-state-focus").parent().index());
}
});
- menu_log("keydown",true);
+ log("keydown",true);
element.focus();
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
equal( $("#log").html(), "2,1,0,keydown,", "Keydown DOWN");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
equal( $("#log").html(), "1,keydown,", "Keydown UP");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
equal( $("#log").html(), "keydown,", "Keydown LEFT (no effect)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
equal( $("#log").html(), "keydown,", "Keydown RIGHT (no effect)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
equal( $("#log").html(), "4,keydown,", "Keydown PAGE_DOWN");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
equal( $("#log").html(), "keydown,", "Keydown PAGE_DOWN (no effect)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
equal( $("#log").html(), "0,keydown,", "Keydown PAGE_UP");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
equal( $("#log").html(), "keydown,", "Keydown PAGE_UP (no effect)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.END } );
equal( $("#log").html(), "4,keydown,", "Keydown END");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } );
equal( $("#log").html(), "0,keydown,", "Keydown HOME");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
equal( $("#log").html(), "keydown,", "Keydown ESCAPE (no effect)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
equal( $("#log").html(), "Aberdeen,keydown,", "Keydown ENTER");
});
@@ -205,14 +211,14 @@ asyncTest("handle keyboard navigation on menu without scroll and with submenus",
expect(14);
var element = $('#menu2').menu({
select: function(event, ui) {
- menu_log($(ui.item[0]).text());
+ log($(ui.item[0]).text());
},
focus: function( event, ui ) {
- menu_log($(event.target).find(".ui-state-focus").parent().index());
+ log($(event.target).find(".ui-state-focus").parent().index());
}
});
- menu_log("keydown",true);
+ log("keydown",true);
element.one( "menufocus", function( event, ui ) {
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
@@ -222,16 +228,16 @@ asyncTest("handle keyboard navigation on menu without scroll and with submenus",
element.focus();
function menukeyboard1() {
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
equal( $("#log").html(), "0,1,keydown,", "Keydown UP");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
equal( $("#log").html(), "keydown,", "Keydown LEFT (no effect)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
@@ -245,7 +251,7 @@ asyncTest("handle keyboard navigation on menu without scroll and with submenus",
}
function menukeyboard2() {
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
equal( $("#log").html(), "4,keydown,", "Keydown LEFT (close submenu)");
@@ -255,35 +261,35 @@ asyncTest("handle keyboard navigation on menu without scroll and with submenus",
}
function menukeyboard3() {
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
equal( $("#log").html(), "2,keydown,", "Keydown PAGE_DOWN");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
equal( $("#log").html(), "keydown,", "Keydown PAGE_DOWN (no effect)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
equal( $("#log").html(), "0,keydown,", "Keydown PAGE_UP");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
equal( $("#log").html(), "keydown,", "Keydown PAGE_UP (no effect)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.END } );
equal( $("#log").html(), "2,keydown,", "Keydown END");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } );
equal( $("#log").html(), "0,keydown,", "Keydown HOME");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
equal( $("#log").html(), "4,keydown,", "Keydown ESCAPE (close submenu)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
setTimeout( menukeyboard4, 50 );
}
@@ -291,7 +297,7 @@ asyncTest("handle keyboard navigation on menu without scroll and with submenus",
function menukeyboard4() {
equal( $("#log").html(), "0,keydown,", "Keydown ENTER (open submenu)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
equal( $("#log").html(), "Ada,keydown,", "Keydown ENTER (select item)");
@@ -303,69 +309,69 @@ test("handle keyboard navigation on menu with scroll and without submenus", func
expect(14);
var element = $('#menu3').menu({
select: function(event, ui) {
- menu_log($(ui.item[0]).text());
+ log($(ui.item[0]).text());
},
focus: function( event, ui ) {
- menu_log($(event.target).find(".ui-state-focus").parent().index());
+ log($(event.target).find(".ui-state-focus").parent().index());
}
});
- menu_log("keydown",true);
+ log("keydown",true);
element.focus();
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
equal( $("#log").html(), "2,1,0,keydown,", "Keydown DOWN");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
equal( $("#log").html(), "0,1,keydown,", "Keydown UP");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
equal( $("#log").html(), "keydown,", "Keydown LEFT (no effect)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
equal( $("#log").html(), "keydown,", "Keydown RIGHT (no effect)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
equal( $("#log").html(), "10,keydown,", "Keydown PAGE_DOWN");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
equal( $("#log").html(), "20,keydown,", "Keydown PAGE_DOWN");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
equal( $("#log").html(), "10,keydown,", "Keydown PAGE_UP");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
equal( $("#log").html(), "0,keydown,", "Keydown PAGE_UP");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
equal( $("#log").html(), "keydown,", "Keydown PAGE_UP (no effect)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.END } );
equal( $("#log").html(), "37,keydown,", "Keydown END");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
equal( $("#log").html(), "keydown,", "Keydown PAGE_DOWN (no effect)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } );
equal( $("#log").html(), "0,keydown,", "Keydown HOME");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
equal( $("#log").html(), "keydown,", "Keydown ESCAPE (no effect)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
equal( $("#log").html(), "Aberdeen,keydown,", "Keydown ENTER");
});
@@ -374,14 +380,14 @@ asyncTest("handle keyboard navigation on menu with scroll and with submenus", fu
expect(14);
var element = $('#menu4').menu({
select: function(event, ui) {
- menu_log($(ui.item[0]).text());
+ log($(ui.item[0]).text());
},
focus: function( event, ui ) {
- menu_log($(event.target).find(".ui-state-focus").parent().index());
+ log($(event.target).find(".ui-state-focus").parent().index());
}
});
- menu_log("keydown",true);
+ log("keydown",true);
element.one( "menufocus", function( event, ui ) {
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
@@ -392,16 +398,16 @@ asyncTest("handle keyboard navigation on menu with scroll and with submenus", fu
function menukeyboard1() {
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
equal( $("#log").html(), "0,1,keydown,", "Keydown UP");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
equal( $("#log").html(), "keydown,", "Keydown LEFT (no effect)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
@@ -412,7 +418,7 @@ asyncTest("handle keyboard navigation on menu with scroll and with submenus", fu
}
function menukeyboard2() {
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
equal( $("#log").html(), "1,keydown,", "Keydown LEFT (close submenu)");
@@ -422,35 +428,35 @@ asyncTest("handle keyboard navigation on menu with scroll and with submenus", fu
}
function menukeyboard3() {
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
equal( $("#log").html(), "10,keydown,", "Keydown PAGE_DOWN");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
equal( $("#log").html(), "20,keydown,", "Keydown PAGE_DOWN");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
equal( $("#log").html(), "10,keydown,", "Keydown PAGE_UP");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
equal( $("#log").html(), "0,keydown,", "Keydown PAGE_UP");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.END } );
equal( $("#log").html(), "27,keydown,", "Keydown END");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } );
equal( $("#log").html(), "0,keydown,", "Keydown HOME");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
equal( $("#log").html(), "1,keydown,", "Keydown ESCAPE (close submenu)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
setTimeout( menukeyboard4, 50 );
}
@@ -458,7 +464,7 @@ asyncTest("handle keyboard navigation on menu with scroll and with submenus", fu
function menukeyboard4() {
equal( $("#log").html(), "0,keydown,", "Keydown ENTER (open submenu)");
- menu_log("keydown",true);
+ log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
equal( $("#log").html(), "Aberdeen,keydown,", "Keydown ENTER (select item)");
@@ -466,4 +472,56 @@ asyncTest("handle keyboard navigation on menu with scroll and with submenus", fu
}
});
+asyncTest("handle keyboard navigation and mouse click on menu with disabled items", function() {
+ expect(6);
+ var element = $('#menu6').menu({
+ select: function(event, ui) {
+ log($(ui.item[0]).text());
+ },
+ focus: function( event, ui ) {
+ log($(event.target).find(".ui-state-focus").parent().index());
+ }
+ });
+
+ log("keydown",true);
+ element.one( "menufocus", function( event, ui ) {
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
+ equal( $("#log").html(), "1,keydown,", "Keydown focus but not select disabled item");
+ setTimeout( menukeyboard1, 50 );
+ });
+ element.focus();
+
+
+ function menukeyboard1() {
+ log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ equal( $("#log").html(), "4,3,2,keydown,", "Keydown focus disabled item with submenu");
+
+ log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
+ equal( $("#log").html(), "keydown,", "Keydown LEFT (no effect)");
+
+ log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
+
+ setTimeout( function() {
+ equal( $("#log").html(), "keydown,", "Keydown RIGHT (no effect on disabled sub-menu)");
+
+ log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
+
+ setTimeout( function() {
+ equal( $("#log").html(), "keydown,", "Keydown ENTER (no effect on disabled sub-menu)");
+ log("click",true);
+ click( element, "1" );
+ equal( $("#log").html(), "click,", "Click disabled item (no effect)");
+ start();
+ }, 50);
+ }, 50);
+ }
+});
+
})(jQuery);
diff --git a/tests/unit/menu/menu_methods.js b/tests/unit/menu/menu_methods.js
index 200ea4427..6ad7bc134 100644
--- a/tests/unit/menu/menu_methods.js
+++ b/tests/unit/menu/menu_methods.js
@@ -3,25 +3,28 @@
*/
(function($) {
+var log = TestHelpers.menu.log,
+ click = TestHelpers.menu.click;
+
module("menu: methods");
test( "enable/disable", function() {
expect( 3 );
var menu = $( "#menu1" ).menu({
select: function(event, ui) {
- menu_log();
+ log();
}
});
menu.menu("disable");
ok(menu.is(".ui-state-disabled"),"Missing ui-state-disabled class");
- menu_log("click",true);
- menu_click(menu,"1");
- menu_log("afterclick");
+ log("click",true);
+ click(menu,"1");
+ log("afterclick");
menu.menu("enable");
ok(menu.not(".ui-state-disabled"),"Has ui-state-disabled class");
- menu_log("click");
- menu_click(menu,"1");
- menu_log("afterclick");
+ log("click");
+ click(menu,"1");
+ log("afterclick");
equal( $("#log").html(), "afterclick,1,click,afterclick,click,", "Click order not valid.");
});
diff --git a/tests/unit/menu/menu_options.js b/tests/unit/menu/menu_options.js
index cda52d88d..e651fd2d1 100644
--- a/tests/unit/menu/menu_options.js
+++ b/tests/unit/menu/menu_options.js
@@ -3,6 +3,9 @@
*/
(function($) {
+var log = TestHelpers.menu.log,
+ click = TestHelpers.menu.click;
+
module("menu: options");
test( "{ disabled: true }", function() {
@@ -10,13 +13,13 @@ test( "{ disabled: true }", function() {
var menu = $( "#menu1" ).menu({
disabled: true,
select: function(event, ui) {
- menu_log();
+ log();
}
});
ok(menu.is(".ui-state-disabled"),"Missing ui-state-disabled class");
- menu_log("click",true);
- menu_click(menu,"1");
- menu_log("afterclick");
+ log("click",true);
+ click(menu,"1");
+ log("afterclick");
equal( $("#log").html(), "afterclick,click,", "Click order not valid.");
});
@@ -25,13 +28,13 @@ test( "{ disabled: false }", function() {
var menu = $( "#menu1" ).menu({
disabled: false,
select: function(event, ui) {
- menu_log();
+ log();
}
});
ok(menu.not(".ui-state-disabled"),"Has ui-state-disabled class");
- menu_log("click",true);
- menu_click(menu,"1");
- menu_log("afterclick");
+ log("click",true);
+ click(menu,"1");
+ log("afterclick");
equal( $("#log").html(), "afterclick,1,click,", "Click order not valid.");
});
diff --git a/tests/unit/menu/menu_test_helpers.js b/tests/unit/menu/menu_test_helpers.js
index e83795e5a..a576af19a 100644
--- a/tests/unit/menu/menu_test_helpers.js
+++ b/tests/unit/menu/menu_test_helpers.js
@@ -1,14 +1,16 @@
-function menu_log( message, clear ) {
- if ( clear ) {
- $( "#log" ).empty();
- }
- if ( message === undefined ) {
- message = $( "#log" ).data( "lastItem" );
- }
- $( "#log" ).prepend( $.trim( message ) + "," );
-}
+TestHelpers.menu = {
+ log: function( message, clear ) {
+ if ( clear ) {
+ $( "#log" ).empty();
+ }
+ if ( message === undefined ) {
+ message = $( "#log" ).data( "lastItem" );
+ }
+ $( "#log" ).prepend( $.trim( message ) + "," );
+ },
-function menu_click( menu, item ) {
- $( "#log" ).data( "lastItem", item );
- menu.children( ":eq(" + item + ")" ).find( "a:first" ).trigger( "click" );
-} \ No newline at end of file
+ click: function( menu, item ) {
+ $( "#log" ).data( "lastItem", item );
+ menu.children( ":eq(" + item + ")" ).find( "a:first" ).trigger( "click" );
+ }
+}; \ No newline at end of file
diff --git a/tests/unit/position/all.html b/tests/unit/position/all.html
index fa3ecf23d..d76f9bbd8 100644
--- a/tests/unit/position/all.html
+++ b/tests/unit/position/all.html
@@ -7,9 +7,9 @@
<script src="../../../jquery-1.7.2.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
- <link rel="stylesheet" href="../subsuiteRunner.css">
+ <link rel="stylesheet" href="../qunit-composite.css">
<script src="../../../external/qunit.js"></script>
- <script src="../subsuiteRunner.js"></script>
+ <script src="../qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>
diff --git a/tests/unit/position/position.html b/tests/unit/position/position.html
index 115adc3e9..8738ae667 100644
--- a/tests/unit/position/position.html
+++ b/tests/unit/position/position.html
@@ -8,62 +8,43 @@
<script>
$.uiBackCompat = false;
</script>
- <script src="../../resource_loader.js"></script>
- <script>
- loadResources({
- js: [ "ui/jquery.ui.position.js" ]
- });
- </script>
-
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
+ <script>
+ TestHelpers.loadResources({
+ js: [ "ui/jquery.ui.position.js" ]
+ });
+ </script>
<script src="position_core.js"></script>
- <script src="position_core_within.js"></script>
<script src="../swarminject.js"></script>
</head>
<body>
-<div style="position:relative; z-index:2;">
- <h1 id="qunit-header">jQuery UI Position Test Suite</h1>
- <h2 id="qunit-banner"></h2>
- <div id="qunit-testrunner-toolbar"></div>
- <h2 id="qunit-userAgent"></h2>
- <ol id="qunit-tests">
- </ol>
-</div>
+<div id="qunit" style="position:relative; z-index:2;"></div>
<!--
-elements smaller than 10px have a line-height set on them to avoid a bug in IE6
+elements smaller than 20px have a line-height set on them to avoid a bug in IE6
.height() returns the greater of the height and line-height
-->
<div id="qunit-fixture" style="top: 0; left: 0; z-index:1">
- <div id="within-container">
- <div id="el1" style="position: absolute; width: 6px; height: 6px; line-height: 6px;"></div>
- <div id="el2" style="position: absolute; width: 6px; height: 6px; line-height: 6px;"></div>
- <div id="parent" style="position: absolute; width: 6px; height: 6px; top: 4px; left: 4px; line-height: 6px;"></div>
-
- <div style="position: absolute; top: 0px; left: 0px">
- <div id="elx" style="position: absolute; width: 10px; height: 10px; line-height: 10px;"></div>
- <div id="parentx" style="position: absolute; width: 20px; height: 20px; top: 40px; left: 40px;"></div>
- </div>
-
- <div style="position: absolute; top: 200px; left: 100px;">
- <div id="el-offset-100-200" style="position: absolute; width: 10px; height: 10px; line-height: 10px;"></div>
- <div style="position: absolute; top: 100px; left: 50px;">
- <div id="el-two-offset-150-300" style="position: absolute; width: 10px; height: 10px; line-height: 10px;"></div>
- <div id="el-fixed" style="position: fixed; top: 200px; left: 200px;"></div>
- </div>
- </div>
+ <div id="el1" style="position: absolute; width: 6px; height: 6px; line-height: 6px;"></div>
+ <div id="el2" style="position: absolute; width: 6px; height: 6px; line-height: 6px;"></div>
+ <div id="parent" style="position: absolute; width: 6px; height: 6px; top: 4px; left: 4px; line-height: 6px;"></div>
+ <div id="within" style="position: absolute; width: 12px; height: 12px; top: 2px; left: 0px; line-height: 12px;"></div>
+
+ <div id="scrollx" style="position: absolute; top: 0px; left: 0px">
+ <div id="elx" style="position: absolute; width: 10px; height: 10px; line-height: 10px;"></div>
+ <div id="parentx" style="position: absolute; width: 20px; height: 20px; top: 40px; left: 40px;"></div>
+ </div>
- <div style="position: absolute; height: 5000px; width: 5000px;"></div>
+ <div style="position: absolute; height: 5000px; width: 5000px;"></div>
- <div id="fractions-parent" style="position: absolute; left: 10.7432222px; top: 10.532325px; height: 30px; width: 201px;">
- <div id="fractions-element"></div>
- </div>
+ <div id="fractions-parent" style="position: absolute; left: 10.7432222px; top: 10.532325px; height: 30px; width: 201px;">
+ <div id="fractions-element"></div>
</div>
<div id="bug-5280" style="height: 30px; width: 201px;">
diff --git a/tests/unit/position/position_core.js b/tests/unit/position/position_core.js
index fbcac4b7f..4a2240311 100644
--- a/tests/unit/position/position_core.js
+++ b/tests/unit/position/position_core.js
@@ -1,13 +1,26 @@
(function( $ ) {
-function scrollTopSupport() {
- $( window ).scrollTop( 1 );
- return $( window ).scrollTop() === 1;
-}
+var win = $( window ),
+ scrollTopSupport = function() {
+ var support = win.scrollTop( 1 ).scrollTop() === 1;
+ win.scrollTop( 0 );
+ scrollTopSupport = function() {
+ return support;
+ };
+ return support;
+ };
+
+module( "position", {
+ setup: function() {
+ win.scrollTop( 0 ).scrollLeft( 0 );
+ }
+});
-module( "position" );
+TestHelpers.testJshint( "ui.position" );
test( "my, at, of", function() {
+ expect( 4 );
+
$( "#elx" ).position({
my: "left top",
at: "left top",
@@ -42,59 +55,61 @@ test( "my, at, of", function() {
});
test( "multiple elements", function() {
- var elements = $( "#el1, #el2" );
- var result = elements.position({
- my: "left top",
- at: "left bottom",
- of: "#parent",
- collision: "none"
- });
+ expect( 3 );
+
+ var elements = $( "#el1, #el2" ),
+ result = elements.position({
+ my: "left top",
+ at: "left bottom",
+ of: "#parent",
+ collision: "none"
+ }),
+ expected = { top: 10, left: 4 };
deepEqual( result, elements );
- var expected = { top: 10, left: 4 };
elements.each(function() {
deepEqual( $( this ).offset(), expected );
});
});
test( "positions", function() {
- var definitions = [];
+ expect( 18 );
+
var offsets = {
- left: 0,
- center: 3,
- right: 6,
- top: 0,
- bottom: 6
- };
- var start = { left: 4, top: 4 };
+ left: 0,
+ center: 3,
+ right: 6,
+ top: 0,
+ bottom: 6
+ },
+ start = { left: 4, top: 4 },
+ el = $( "#el1" );
+
$.each( [ 0, 1 ], function( my ) {
$.each( [ "top", "center", "bottom" ], function( vindex, vertical ) {
$.each( [ "left", "center", "right" ], function( hindex, horizontal ) {
- definitions.push({
- my: my ? horizontal + " " + vertical : "left top",
- at: !my ? horizontal + " " + vertical : "left top",
- result: {
- top: my ? start.top - offsets[ vertical ] : start.top + offsets[ vertical ],
- left: my ? start.left - offsets[ horizontal ] : start.left + offsets[ horizontal ]
- }
+ var _my = my ? horizontal + " " + vertical : "left top",
+ _at = !my ? horizontal + " " + vertical : "left top";
+ el.position({
+ my: _my,
+ at: _at,
+ of: "#parent",
+ collision: "none"
});
+ deepEqual( el.offset(), {
+ top: start.top + offsets[ vertical ] * (my ? -1 : 1),
+ left: start.left + offsets[ horizontal ] * (my ? -1 : 1)
+ }, "Position via " + QUnit.jsDump.parse({ my: _my, at: _at }) );
});
});
});
- var el = $( "#el1" );
- $.each( definitions, function( index, definition ) {
- el.position({
- my: definition.my,
- at: definition.at,
- of: "#parent",
- collision: "none"
- });
- deepEqual( el.offset(), definition.result,
- "Position via " + QUnit.jsDump.parse({ my:definition.my, at:definition.at }) );
- });
});
test( "of", function() {
+ expect( 9 + (scrollTopSupport() ? 1 : 0) );
+
+ var event;
+
$( "#elx" ).position({
my: "left top",
at: "left top",
@@ -141,7 +156,7 @@ test( "of", function() {
left: $( document ).width() - 10
}, "document as jQuery object" );
- $( window ).scrollTop( 0 );
+ win.scrollTop( 0 );
$( "#elx" ).position({
my: "right bottom",
@@ -150,23 +165,23 @@ test( "of", function() {
collision: "none"
});
deepEqual( $( "#elx" ).offset(), {
- top: $( window ).height() - 10,
- left: $( window ).width() - 10
+ top: win.height() - 10,
+ left: win.width() - 10
}, "window" );
$( "#elx" ).position({
my: "right bottom",
at: "right bottom",
- of: $( window ),
+ of: win,
collision: "none"
});
deepEqual( $( "#elx" ).offset(), {
- top: $( window ).height() - 10,
- left: $( window ).width() - 10
+ top: win.height() - 10,
+ left: win.width() - 10
}, "window as jQuery object" );
if ( scrollTopSupport() ) {
- $( window ).scrollTop( 500 ).scrollLeft( 200 );
+ win.scrollTop( 500 ).scrollLeft( 200 );
$( "#elx" ).position({
my: "right bottom",
at: "right bottom",
@@ -174,13 +189,13 @@ test( "of", function() {
collision: "none"
});
deepEqual( $( "#elx" ).offset(), {
- top: $( window ).height() + 500 - 10,
- left: $( window ).width() + 200 - 10
+ top: win.height() + 500 - 10,
+ left: win.width() + 200 - 10
}, "window, scrolled" );
- $( window ).scrollTop( 0 ).scrollLeft( 0 );
+ win.scrollTop( 0 ).scrollLeft( 0 );
}
- var event = $.extend( $.Event( "someEvent" ), { pageX: 200, pageY: 300 } );
+ event = $.extend( $.Event( "someEvent" ), { pageX: 200, pageY: 300 } );
$( "#elx" ).position({
my: "left top",
at: "left top",
@@ -206,6 +221,8 @@ test( "of", function() {
});
test( "offsets", function() {
+ expect( 4 );
+
$( "#elx" ).position({
my: "left top",
at: "left+10 bottom+10",
@@ -240,11 +257,30 @@ test( "offsets", function() {
});
test( "using", function() {
- expect( 6 );
+ expect( 10 );
var count = 0,
elems = $( "#el1, #el2" ),
- expectedPosition = { top: 40, left: 40 },
+ of = $( "#parentx" ),
+ expectedPosition = { top: 60, left: 60 },
+ expectedFeedback = {
+ target: {
+ element: of,
+ width: 20,
+ height: 20,
+ left: 40,
+ top: 40
+ },
+ element: {
+ width: 6,
+ height: 6,
+ left: 60,
+ top: 60
+ },
+ horizontal: "left",
+ vertical: "top",
+ important: "vertical"
+ },
originalPosition = elems.position({
my: "right bottom",
at: "rigt bottom",
@@ -254,11 +290,14 @@ test( "using", function() {
elems.position({
my: "left top",
- at: "left top",
+ at: "center+10 bottom",
of: "#parentx",
- using: function( position ) {
+ using: function( position, feedback ) {
deepEqual( this, elems[ count ], "correct context for call #" + count );
deepEqual( position, expectedPosition, "correct position for call #" + count );
+ deepEqual( feedback.element.element[ 0 ], elems[ count ] );
+ delete feedback.element.element;
+ deepEqual( feedback, expectedFeedback );
count++;
}
});
@@ -272,7 +311,7 @@ function collisionTest( config, result, msg ) {
var elem = $( "#elx" ).position( $.extend({
my: "left top",
at: "right bottom",
- of: window
+ of: "#parent"
}, config ) );
deepEqual( elem.offset(), result, msg );
}
@@ -284,239 +323,340 @@ function collisionTest2( config, result, msg ) {
}, config ), result, msg );
}
-test( "collision: fit, no offset", function() {
+test( "collision: fit, no collision", function() {
+ expect( 2 );
+
collisionTest({
collision: "fit"
- }, { top: $( window ).height() - 10, left: $( window ).width() - 10 }, "right bottom" );
+ }, {
+ top: 10,
+ left: 10
+ }, "no offset" );
- collisionTest2({
- collision: "fit"
- }, { top: 0, left: 0 }, "left top" );
-});
-
-test( "collision: fit, with offset", function() {
collisionTest({
collision: "fit",
at: "right+2 bottom+3"
- }, { top: $(window).height() - 10, left: $(window).width() - 10 }, "right bottom");
+ }, {
+ top: 13,
+ left: 12
+ }, "with offset" );
+});
+
+test( "collision: fit, collision", function() {
+ expect( 2 + (scrollTopSupport() ? 1 : 0) );
collisionTest2({
- collision: "fit",
- at: "left+2 top+3"
- }, { top: 0, left: 0 }, "left top, positive offset" );
+ collision: "fit"
+ }, {
+ top: 0,
+ left: 0
+ }, "no offset" );
collisionTest2({
collision: "fit",
- at: "left-2 top-3"
- }, { top: 0, left: 0 }, "left top, negative offset" );
-});
+ at: "left+2 top+3"
+ }, {
+ top: 0,
+ left: 0
+ }, "with offset" );
-test( "collision: fit, window scrolled", function() {
if ( scrollTopSupport() ) {
- var win = $( window );
win.scrollTop( 300 ).scrollLeft( 200 );
-
collisionTest({
- collision: "fit",
- at: "left-100 top-100"
- }, { top: 300, left: 200 }, "top left" );
- collisionTest2({
- collision: "fit",
- at: "right+100 bottom+100"
- }, { top: 300 + win.height() - 10, left: 200 + win.width() - 10 }, "right bottom" );
+ collision: "fit"
+ }, {
+ top: 300,
+ left: 200
+ }, "window scrolled" );
win.scrollTop( 0 ).scrollLeft( 0 );
}
});
-test( "collision: flip, no offset", function() {
- collisionTest({
- collision: "flip"
- }, { top: $( window ).height(), left: $( window ).width() }, "left top" );
+test( "collision: flip, no collision", function() {
+ expect( 2 );
- collisionTest2({
+ collisionTest({
collision: "flip"
- }, { top: -10, left: -10 }, "right bottom" );
-});
+ }, {
+ top: 10,
+ left: 10
+ }, "no offset" );
-test( "collision: flip, with offset", function() {
collisionTest({
collision: "flip",
at: "right+2 bottom+3"
- }, { top: $( window ).height() + 3, left: $( window ).width() + 2 }, "left top, with offset added" );
+ }, {
+ top: 13,
+ left: 12
+ }, "with offset" );
+});
+
+test( "collision: flip, collision", function() {
+ expect( 2 );
collisionTest2({
- collision: "flip",
- at: "left+2 top+3"
- }, { top: -7, left: -8 }, "bottom, positive offset" );
+ collision: "flip"
+ }, {
+ top: 10,
+ left: 10
+ }, "no offset" );
collisionTest2({
collision: "flip",
- at: "left-2 top-3"
- }, { top: -13, left: -12 }, "right bottom, negative offset" );
+ at: "left+2 top+3"
+ }, {
+ top: 7,
+ left: 8
+ }, "with offset" );
});
-test( "collision: none, no offset", function() {
+test( "collision: flipfit, no collision", function() {
+ expect( 2 );
+
collisionTest({
- collision: "none"
- }, { top: $( window ).height(), left: $( window ).width() }, "left top" );
+ collision: "flipfit"
+ }, {
+ top: 10,
+ left: 10
+ }, "no offset" );
+
+ collisionTest({
+ collision: "flipfit",
+ at: "right+2 bottom+3"
+ }, {
+ top: 13,
+ left: 12
+ }, "with offset" );
+});
+
+test( "collision: flipfit, collision", function() {
+ expect( 2 );
collisionTest2({
- collision: "none"
- }, { top: -10, left: -10 }, "moved to the right bottom" );
+ collision: "flipfit"
+ }, {
+ top: 10,
+ left: 10
+ }, "no offset" );
+
+ collisionTest2({
+ collision: "flipfit",
+ at: "left+2 top+3"
+ }, {
+ top: 7,
+ left: 8
+ }, "with offset" );
});
-test( "collision: none, with offset", function() {
+test( "collision: none, no collision", function() {
+ expect( 2 );
+
+ collisionTest({
+ collision: "none"
+ }, {
+ top: 10,
+ left: 10
+ }, "no offset" );
+
collisionTest({
collision: "none",
at: "right+2 bottom+3"
- }, { top: $( window ).height() + 3, left: $( window ).width() + 2 }, "right bottom, with offset added" );
+ }, {
+ top: 13,
+ left: 12
+ }, "with offset" );
+});
+
+test( "collision: none, collision", function() {
+ expect( 2 );
collisionTest2({
- collision: "none",
- at: "left+2 top+3"
- }, { top: -7, left: -8 }, "left top, positive offset" );
+ collision: "none"
+ }, {
+ top: -6,
+ left: -6
+ }, "no offset" );
collisionTest2({
collision: "none",
- at: "left-2 top-3"
- }, { top: -13, left: -12 }, "left top, negative offset" );
+ at: "left+2 top+3"
+ }, {
+ top: -3,
+ left: -4
+ }, "with offset" );
});
test( "collision: fit, with margin", function() {
- $( "#elx" ).css( "margin", 10 );
-
- collisionTest({
- collision: "fit"
- }, { top: $( window ).height() - 20, left: $( window ).width() - 20 }, "right bottom" );
-
- collisionTest2({
- collision: "fit"
- }, { top: 10, left: 10 }, "left top" );
+ expect( 2 );
$( "#elx" ).css({
- "margin-left": 5,
- "margin-top": 5
+ marginTop: 6,
+ marginLeft: 4
});
collisionTest({
collision: "fit"
- }, { top: $( window ).height() - 20, left: $( window ).width() - 20 }, "right bottom" );
+ }, {
+ top: 10,
+ left: 10
+ }, "right bottom" );
collisionTest2({
collision: "fit"
- }, { top: 5, left: 5 }, "left top" );
+ }, {
+ top: 6,
+ left: 4
+ }, "left top" );
+});
+
+test( "collision: flip, with margin", function() {
+ expect( 3 );
$( "#elx" ).css({
- "margin-right": 15,
- "margin-bottom": 15
+ marginTop: 6,
+ marginLeft: 4
});
collisionTest({
- collision: "fit"
- }, { top: $( window ).height() - 25, left: $( window ).width() - 25 }, "right bottom" );
+ collision: "flip"
+ }, {
+ top: 10,
+ left: 10
+ }, "left top" );
collisionTest2({
- collision: "fit"
- }, { top: 5, left: 5 }, "left top" );
-});
-
-test( "collision: flip, with margin", function() {
- $( "#elx" ).css( "margin", 10 );
-
- collisionTest({
- collision: "flip",
- at: "left top"
- }, { top: 0, left: 0 }, "left top" );
+ collision: "flip"
+ }, {
+ top: 10,
+ left: 10
+ }, "right bottom" );
collisionTest2({
collision: "flip",
- at: "right bottom"
- }, { top: $( window ).height() - 10, left: $( window ).width() - 10 }, "right bottom" );
+ my: "left top"
+ }, {
+ top: 0,
+ left: 4
+ }, "right bottom" );
});
-test( "addClass: flipped left", function() {
- var elem = $( "#elx" ).position( {
- my: "left center",
- of: window,
- collision: "flip",
- at: "right center"
- });
-
- deepEqual( elem.hasClass( 'ui-flipped-left' ), false, 'Has ui-flipped-left class' );
+test( "within", function() {
+ expect( 6 );
- elem.position( {
- my: "right center",
- of: window,
- collision: "flip",
- at: "left center"
- })
+ collisionTest({
+ within: "#within",
+ collision: "fit"
+ }, {
+ top: 4,
+ left: 2
+ }, "fit - right bottom" );
- deepEqual( elem.hasClass( 'ui-flipped-left' ), false, 'Removed ui-flipped-left class' );
-});
+ collisionTest2({
+ within: "#within",
+ collision: "fit"
+ }, {
+ top: 2,
+ left: 0
+ }, "fit - left top" );
-test( "addClass: flipped top", function() {
- var elem = $( "#elx" ).position( {
- my: "left top",
- of: window,
- collision: "flip",
- at: "right bottom"
- });
+ collisionTest({
+ within: "#within",
+ collision: "flip"
+ }, {
+ top: 10,
+ left: -6
+ }, "flip - right bottom" );
- deepEqual( elem.hasClass( 'ui-flipped-top' ), false, 'Has ui-flipped-top class' );
+ collisionTest2({
+ within: "#within",
+ collision: "flip"
+ }, {
+ top: 10,
+ left: -6
+ }, "flip - left top" );
- elem.position( {
- my: "left bottom",
- of: window,
- collision: "flip",
- at: "right top"
- });
+ collisionTest({
+ within: "#within",
+ collision: "flipfit"
+ }, {
+ top: 4,
+ left: 0
+ }, "flipfit - right bottom" );
- deepEqual( elem.hasClass( 'ui-flipped-top' ), false, 'Removed ui-flipped-top class' );
+ collisionTest2({
+ within: "#within",
+ collision: "flipfit"
+ }, {
+ top: 4,
+ left: 0
+ }, "flipfit - left top" );
});
-test( "addClass: flipped right", function() {
- var elem = $( "#elx" ).position( {
- my: "right center",
- of: window,
- collision: "flip",
- at: "left center"
+test( "with scrollbars", function() {
+ expect( 4 );
+
+ $( "#scrollx" ).css({
+ width: 100,
+ height: 100,
+ left: 0,
+ top: 0
});
- deepEqual( elem.hasClass( 'ui-flipped-right' ), false, 'Has ui-flipped-right class' );
+ collisionTest({
+ of: "#scrollx",
+ collision: "fit",
+ within: "#scrollx"
+ }, {
+ top: 90,
+ left: 90
+ }, "visible" );
- elem.position( {
- my: "left center",
- of: window,
- collision: "flip",
- at: "right center"
+ $( "#scrollx" ).css({
+ overflow: "scroll"
});
- deepEqual( elem.hasClass( 'ui-flipped-right' ), false, 'Removed ui-flipped-right class' );
+ var scrollbarInfo = $.position.getScrollInfo( $.position.getWithinInfo( $( "#scrollx" ) ) );
-});
+ collisionTest({
+ of: "#scrollx",
+ collision: "fit",
+ within: "#scrollx"
+ }, {
+ top: 90 - scrollbarInfo.height,
+ left: 90 - scrollbarInfo.width
+ }, "scroll" );
-test( "addClass: flipped bottom", function() {
- var elem = $( "#elx" ).position( {
- my: "left bottom",
- of: window,
- collision: "flip",
- at: "right top"
+ $( "#scrollx" ).css({
+ overflow: "auto"
});
- deepEqual( elem.hasClass( 'ui-flipped-bottom' ), false, 'Has ui-flipped-bottom class' );
+ collisionTest({
+ of: "#scrollx",
+ collision: "fit",
+ within: "#scrollx"
+ }, {
+ top: 90,
+ left: 90
+ }, "auto, no scroll" );
- elem.position( {
- my: "left top",
- of: window,
- collision: "flip",
- at: "right bottom"
- });
+ $( "#scrollx" ).css({
+ overflow: "auto"
+ }).append( $("<div>").height(300).width(300) );
- deepEqual( elem.hasClass( 'ui-flipped-bottom' ), false, 'Removed ui-flipped-bottom class' );
+ collisionTest({
+ of: "#scrollx",
+ collision: "fit",
+ within: "#scrollx"
+ }, {
+ top: 90 - scrollbarInfo.height,
+ left: 90 - scrollbarInfo.width
+ }, "auto, with scroll" );
});
test( "fractions", function() {
+ expect( 1 );
+
$( "#fractions-element" ).position({
my: "left top",
at: "left top",
@@ -527,6 +667,8 @@ test( "fractions", function() {
});
test( "bug #5280: consistent results (avoid fractional values)", function() {
+ expect( 1 );
+
var wrapper = $( "#bug-5280" ),
elem = wrapper.children(),
offset1 = elem.position({
diff --git a/tests/unit/position/position_core_within.js b/tests/unit/position/position_core_within.js
deleted file mode 100644
index 9dc91238f..000000000
--- a/tests/unit/position/position_core_within.js
+++ /dev/null
@@ -1,545 +0,0 @@
-(function( $ ) {
-
-function scrollTopSupport() {
- $( window ).scrollTop( 1 );
- return $( window ).scrollTop() === 1;
-}
-
-module( "position - within", {
- setup: function(){
- $("#within-container").css({"width": "70px", "height": "70px", "top": "20px", "left": "20px", "position": "relative"}).show();
- }
-});
-
-var addTop = -20,
- addLeft = -20;
-
-$.fn.addOffsets = function() {
- var elOffset = this.offset(),
- offset = $("#within-container").offset();
-
- elOffset.top -= offset.top;
- elOffset.left -= offset.left;
-
- return {top: elOffset.top - offset.top, left: elOffset.left - offset.left };
-};
-
-test( "my, at, of", function() {
- var within = $("#within-container");
-
- $( "#elx" ).position({
- my: "left top",
- at: "left top",
- of: "#parentx",
- collision: "none",
- within: within
- });
- deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 40, left: addLeft + 40 }, "left top, left top" );
-
- $( "#elx" ).position({
- my: "left top",
- at: "left bottom",
- of: "#parentx",
- collision: "none",
- within: within
- });
- deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 60, left: addLeft + 40 }, "left top, left bottom" );
-
- $( "#elx" ).position({
- my: "left",
- at: "bottom",
- of: "#parentx",
- collision: "none",
- within: within
- });
- deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 55, left: addLeft + 50 }, "left, bottom" );
-
- $( "#elx" ).position({
- my: "left foo",
- at: "bar baz",
- of: "#parentx",
- collision: "none",
- within: within
- });
- deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 45, left: addLeft +50 }, "left foo, bar baz" );
-});
-
-test( "multiple elements", function() {
- var elements = $( "#el1, #el2" );
- var result = elements.position({
- my: "left top",
- at: "left bottom",
- of: "#parent",
- collision: "none",
- within: $("#within-container")
- });
-
- deepEqual( result, elements );
- var expected = { top: addTop + 10, left: addLeft + 4 };
- elements.each(function() {
- deepEqual( $( this ).addOffsets(), expected );
- });
-});
-
-test( "positions", function() {
- var definitions = [];
- var offsets = {
- left: 0,
- center: 3,
- right: 6,
- top: 0,
- bottom: 6
- };
- var start = { left: 4, top: 4 };
- $.each( [ 0, 1 ], function( my ) {
- $.each( [ "top", "center", "bottom" ], function( vindex, vertical ) {
- $.each( [ "left", "center", "right" ], function( hindex, horizontal ) {
- definitions.push({
- my: my ? horizontal + " " + vertical : "left top",
- at: !my ? horizontal + " " + vertical : "left top",
- result: {
- top: addTop + (my ? start.top - offsets[ vertical ] : start.top + offsets[ vertical ]),
- left: addLeft + (my ? start.left - offsets[ horizontal ] : start.left + offsets[ horizontal ])
- }
- });
- });
- });
- });
- var el = $( "#el1" );
- $.each( definitions, function( index, definition ) {
- el.position({
- my: definition.my,
- at: definition.at,
- of: "#parent",
- collision: "none",
- within: $("#within-container")
- });
- deepEqual( el.addOffsets(), definition.result,
- "Position via " + QUnit.jsDump.parse({ my:definition.my, at:definition.at }) );
- });
-});
-
-test( "of", function() {
- var within = $("#within-container");
-
- $( "#elx" ).position({
- my: "left top",
- at: "left top",
- of: "#parentx",
- collision: "none",
- within: within
- });
- deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 40, left: addLeft + 40 }, "selector" );
-
- $( "#elx" ).position({
- my: "left top",
- at: "left bottom",
- of: $( "#parentx"),
- collision: "none",
- within: within
- });
- deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 60, left: addLeft + 40 }, "jQuery object" );
-
- $( "#elx" ).position({
- my: "left top",
- at: "left top",
- of: $( "#parentx" )[ 0 ],
- collision: "none",
- within: within
- });
- deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 40, left: addLeft + 40 }, "DOM element" );
-
- var event = $.extend( $.Event( "someEvent" ), { pageX: 200, pageY: 300 } );
- $( "#elx" ).position({
- my: "left top",
- at: "left top",
- of: event,
- collision: "none",
- within: within
- });
- deepEqual( $( "#elx" ).offset(), {
- top: 300,
- left: 200
- }, "event - left top, left top" );
-
- event = $.extend( $.Event( "someEvent" ), { pageX: 400, pageY: 600 } );
- $( "#elx" ).position({
- my: "left top",
- at: "right bottom",
- of: event,
- collision: "none",
- within: within
- });
- deepEqual( $( "#elx" ).offset(), {
- top: 600,
- left: 400
- }, "event - left top, right bottom" );
-});
-
-test( "within:offsets", function() {
- var within = $("#within-container");
-
- $( "#elx" ).position({
- my: "left top",
- at: "left+10 bottom+10",
- of: "#parentx",
- collision: "none",
- within: within
- });
- deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 70, left: addLeft + 50 }, "offsets in at" );
-
- $( "#elx" ).position({
- my: "left+10 top-10",
- at: "left bottom",
- of: "#parentx",
- collision: "none",
- within: within
- });
- deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 50, left: addLeft + 50 }, "offsets in my" );
-
- $( "#elx" ).position({
- my: "left top",
- at: "left+50% bottom-10%",
- of: "#parentx",
- collision: "none",
- within: within
- });
- deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 58, left: addLeft + 50 }, "percentage offsets in at" );
-
- $( "#elx" ).position({
- my: "left-30% top+50%",
- at: "left bottom",
- of: "#parentx",
- collision: "none",
- within: within
- });
- deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 65, left: addLeft + 37 }, "percentage offsets in my" );
-});
-
-test( "using", function() {
- expect( 6 );
-
- var within = $("#within-container");
-
- var count = 0,
- elems = $( "#el1, #el2" ),
- expectedPosition = { top: addTop + 40, left: addLeft + 40 },
- originalPosition = elems.position({
- my: "right bottom",
- at: "right bottom",
- of: "#parentx",
- collision: "none",
- within: within
- }).addOffsets();
-
- elems.position({
- my: "left top",
- at: "left top",
- of: "#parentx",
- using: function( position ) {
- position.top -= within.offset().top;
- position.left -= within.offset().left;
- deepEqual( this, elems[ count ], "correct context for call #" + count );
- deepEqual( position, expectedPosition, "correct position for call #" + count );
- count++;
- },
- within: within
- });
-
- elems.each(function() {
- deepEqual( $( this ).addOffsets(), originalPosition, "elements not moved" );
- });
-});
-
-function collisionTest( config, result, msg ) {
- var within = $("#within-container");
-
- var elem = $( "#elx" ).position( $.extend({
- my: "left top",
- at: "right bottom",
- of: "#parentx",
- within: within
- }, config ) );
-
- deepEqual( elem.addOffsets(), result, msg );
-}
-
-function collisionTest2( config, result, msg ) {
- collisionTest( $.extend({
- my: "right bottom",
- at: "left top"
- }, config ), result, msg );
-}
-
-test( "collision: fit, no offset", function() {
- var within = $("#within-container"),
- of = $("#parentx");
-
- collisionTest({
- collision: "fit"
- }, { top: addTop + of.position().top + of.height() - $.position.getScrollInfo( within ).height, left: addLeft + of.position().left + of.width() - $.position.getScrollInfo( within ).width }, "right bottom" );
-
- collisionTest2({
- collision: "fit"
- }, { top: addTop + of.position().top - 10, left: addLeft + of.position().left - 10 }, "left top" );
-});
-
-
-test( "collision: fit, with offset", function() {
- var within = $("#within-container"),
- of = $("#parentx");
-
- collisionTest({
- collision: "fit",
- at: "right+2 bottom+3"
- }, { top: addTop + of.position().top + of.height() - $.position.getScrollInfo( within ).height, left: addLeft + of.position().left + of.width() - $.position.getScrollInfo( within ).width }, "right bottom");
-
- collisionTest2({
- collision: "fit",
- at: "left+2 top+3"
- }, { top: addTop + of.position().top - 7, left: addLeft + of.position().left - 8 }, "left top, positive offset" );
-
- collisionTest2({
- collision: "fit",
- at: "left-2 top-3"
- }, { top: addTop + of.position().top - 13, left: addLeft + of.position().left - 12 }, "left top, negative offset" );
-});
-
-test( "collision: none, within scrolled", function() {
- if ( scrollTopSupport() ) {
- var within = $("#within-container").css({"width": "1000px", "height": "800px", "overflow": "auto"}),
- of = $("#parentx");
- within.scrollTop( 300 ).scrollLeft( 150 );
-
- collisionTest({
- collision: "none",
- at: "left-100 top-100"
- }, { top: of.offset().top + addTop - 100 - of.height(), left: of.offset().left + addLeft - 100 - of.width() }, "top left" );
- collisionTest2({
- collision: "none",
- at: "right+100 bottom+100"
- }, { top: of.offset().top + addTop + 100 - 10, left: of.offset().left + addLeft + 100 - 10 }, "right bottom" );
- within.scrollTop( 0 ).scrollLeft( 0 );
- }
-});
-
-test( "collision: flip, no offset", function() {
- var within = $("#within-container"),
- of = $("#parentx");
-
- collisionTest({
- collision: "flip"
- }, { top: addTop + of.position().top + of.height(), left: addLeft + of.position().left + of.width() }, "left top" );
-
- collisionTest2({
- collision: "flip"
- }, { top: addTop + of.position().top - 10, left: addTop + of.position().top - 10 }, "right bottom" );
-});
-
-test( "collision: flip, with offset", function() {
- var within = $("#within-container"),
- of = $("#parentx");
-
- collisionTest({
- collision: "flip",
- at: "right+2 bottom+3"
- }, { top: addTop + of.position().top - 13, left: addLeft + of.position().left - 12 }, "left top, with offset added" );
-
- collisionTest2({
- collision: "flip",
- at: "left+2 top+3"
- }, { top: addTop + of.position().top - 10 + 3, left: addLeft + of.position().left - 10 + 2 }, "right bottom, positive offset" );
-
- collisionTest2({
- collision: "flip",
- at: "left-2 top-3"
- }, { top: addTop + of.position().top - 13, left: addLeft + of.position().left - 12 }, "right bottom, negative offset" );
-});
-
-test( "collision: none, no offset", function() {
- var within = $("#within-container"),
- of = $("#parentx");
-
- collisionTest({
- collision: "none"
- }, { top: addTop + of.position().top + of.height(), left: addLeft + of.position().left + of.width() }, "left top" );
-
- collisionTest2({
- collision: "none"
- }, { top: addTop + of.position().top - 10, left: addLeft + of.position().left - 10 }, "right bottom" );
-});
-
-test( "collision: none, with offset", function() {
- var within = $("#within-container"),
- of = $("#parentx");
-
- collisionTest({
- collision: "none",
- at: "right+2 bottom+3"
- }, { top: addTop + of.position().top + of.height() + 3, left: addLeft + of.position().left + of.width() + 2 }, "right bottom, with offset added" );
-
- collisionTest2({
- collision: "none",
- at: "left+2 top+3"
- }, { top: addTop + of.position().top - 7, left: addTop + of.position().top - 8 }, "left top, positive offset" );
-
- collisionTest2({
- collision: "none",
- at: "left-2 top-3"
- }, { top: addTop + of.position().top - 13, left: addTop + of.position().top - 12 }, "left top, negative offset" );
-});
-
-test( "collision: fit, with margin", function() {
- var within = $("#within-container"),
- of = $("#parentx");
-
- $( "#elx" ).css( "margin", 10 );
-
- collisionTest({
- collision: "fit"
- }, { top: addTop + of.position().top + of.height() - 10 - $.position.getScrollInfo( within ).height, left: addLeft + of.position().left + of.width() - 10 - $.position.getScrollInfo( within ).width }, "right bottom" );
-
- collisionTest2({
- collision: "fit"
- }, { top: addTop + of.position().top - 10, left: addLeft + of.position().left - 10 }, "left top" );
-
- $( "#elx" ).css({
- "margin-left": 5,
- "margin-top": 5
- });
-
- collisionTest({
- collision: "fit"
- }, { top: addTop + of.position().top + of.height() - 10 - $.position.getScrollInfo( within ).height, left: addLeft + of.position().left + of.width() - 10 - $.position.getScrollInfo( within ).width }, "right bottom" );
-
- collisionTest2({
- collision: "fit"
- }, { top: addTop + of.position().top - 10, left: addLeft + of.position().left - 10 }, "left top" );
-
- $( "#elx" ).css({
- "margin-right": 15,
- "margin-bottom": 15
- });
-
- collisionTest({
- collision: "fit"
- }, { top: addTop + of.position().top + of.height() - 15 - $.position.getScrollInfo( within ).height, left: addLeft + of.position().left + of.width() - 15 - $.position.getScrollInfo( within ).width }, "right bottom" );
-
- collisionTest2({
- collision: "fit"
- }, { top: addTop + of.position().top - 10, left: addLeft + of.position().left - 10 }, "left top" );
-});
-
-test( "collision: flip, with margin", function() {
- var within = $("#within-container"),
- of = $("#parentx");
-
- $( "#elx" ).css( "margin", 10 );
-
- collisionTest({
- collision: "flip"
- }, { top: addTop + of.position().top - 10, left: addLeft + of.position().left - 10 }, "left top" );
-
- collisionTest2({
- collision: "flip"
- }, { top: addTop + of.position().top - 10, left: addLeft + of.position().left - 10 }, "right bottom" );
-
- $( "#elx" ).css( "margin", 0 );
-});
-
-test( "addClass: flipped left", function() {
- var within = $("#within-container");
-
- var elem = $( "#elx" ).position( {
- my: "left center",
- of: within[0],
- within: within,
- collision: "flip",
- at: "right center"
- });
-
- deepEqual( elem.hasClass( 'ui-flipped-left' ), false, 'Has ui-flipped-left class' );
-
- elem.position( {
- my: "right center",
- of: within[0],
- within: within,
- collision: "flip",
- at: "left center"
- })
-
- deepEqual( elem.hasClass( 'ui-flipped-left' ), false, 'Removed ui-flipped-left class' );
-});
-
-test( "addClass: flipped top", function() {
- var within = $("#within-container");
-
- var elem = $( "#elx" ).position( {
- my: "left top",
- of: within[0],
- within: within,
- collision: "flip",
- at: "right bottom"
- });
-
- deepEqual( elem.hasClass( 'ui-flipped-top' ), false, 'Has ui-flipped-top class' );
-
- elem.position( {
- my: "left bottom",
- of: within[0],
- within: within,
- collision: "flip",
- at: "right top"
- });
-
- deepEqual( elem.hasClass( 'ui-flipped-top' ), false, 'Removed ui-flipped-top class' );
-});
-
-test( "addClass: flipped right", function() {
- var within = $("#within-container");
-
- var elem = $( "#elx" ).position( {
- my: "right center",
- of: within[0],
- within: within,
- collision: "flip",
- at: "left center"
- });
-
- deepEqual( elem.hasClass( 'ui-flipped-right' ), false, 'Has ui-flipped-right class' );
-
- elem.position( {
- my: "left center",
- of: within[0],
- within: within,
- collision: "flip",
- at: "right center"
- });
-
- deepEqual( elem.hasClass( 'ui-flipped-right' ), false, 'Removed ui-flipped-right class' );
-
-});
-
-test( "addClass: flipped bottom", function() {
- var within = $("#within-container");
-
- var elem = $( "#elx" ).position( {
- my: "left bottom",
- of: window,
- collision: "flip",
- at: "right top"
- });
-
- deepEqual( elem.hasClass( 'ui-flipped-bottom' ), false, 'Has ui-flipped-bottom class' );
-
- elem.position( {
- my: "left top",
- of: window,
- collision: "flip",
- at: "right bottom"
- });
-
- deepEqual( elem.hasClass( 'ui-flipped-bottom' ), false, 'Removed ui-flipped-bottom class' );
-});
-
-}( jQuery ) );
diff --git a/tests/unit/position/position_deprecated.html b/tests/unit/position/position_deprecated.html
index ee9be189d..84aae61f8 100644
--- a/tests/unit/position/position_deprecated.html
+++ b/tests/unit/position/position_deprecated.html
@@ -5,63 +5,51 @@
<title>jQuery UI Position Test Suite</title>
<script src="../../jquery.js"></script>
- <script src="../../resource_loader.js"></script>
- <script>
- loadResources({
- js: [ "ui/jquery.ui.position.js" ]
- });
- </script>
+
+
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
+ <script>
+ TestHelpers.loadResources({
+ js: [ "ui/jquery.ui.position.js" ]
+ });
+ </script>
<script src="position_core.js"></script>
<script src="position_deprecated.js"></script>
-
<script src="../swarminject.js"></script>
</head>
<body>
-
-<h1 id="qunit-header">jQuery UI Position Test Suite</h1>
-<h2 id="qunit-banner"></h2>
-<div id="qunit-testrunner-toolbar"></div>
-<h2 id="qunit-userAgent"></h2>
-<ol id="qunit-tests"></ol>
+<div id="qunit" style="position:relative; z-index:2;"></div>
<!--
-elements smaller than 10px have a line-height set on them to avoid a bug in IE6
+elements smaller than 20px have a line-height set on them to avoid a bug in IE6
.height() returns the greater of the height and line-height
-->
-<div id="qunit-fixture" style="top: 0; left: 0;">
+<div id="qunit-fixture" style="top: 0; left: 0; z-index:1">
<div id="el1" style="position: absolute; width: 6px; height: 6px; line-height: 6px;"></div>
<div id="el2" style="position: absolute; width: 6px; height: 6px; line-height: 6px;"></div>
<div id="parent" style="position: absolute; width: 6px; height: 6px; top: 4px; left: 4px; line-height: 6px;"></div>
-</div>
-
-<div style="position: absolute; top: 0px; left: 0px">
- <div id="elx" style="position: absolute; width: 10px; height: 10px; line-height: 10px;"></div>
- <div id="parentx" style="position: absolute; width: 20px; height: 20px; top: 40px; left: 40px;"></div>
-</div>
+ <div id="within" style="position: absolute; width: 12px; height: 12px; top: 2px; left: 0px; line-height: 12px;"></div>
-<div style="position: absolute; top: 200px; left: 100px;">
- <div id="el-offset-100-200" style="position: absolute; width: 10px; height: 10px; line-height: 10px;"></div>
- <div style="position: absolute; top: 100px; left: 50px;">
- <div id="el-two-offset-150-300" style="position: absolute; width: 10px; height: 10px; line-height: 10px;"></div>
- <div id="el-fixed" style="position: fixed; top: 200px; left: 200px;"></div>
+ <div id="scrollx" style="position: absolute; top: 0px; left: 0px">
+ <div id="elx" style="position: absolute; width: 10px; height: 10px; line-height: 10px;"></div>
+ <div id="parentx" style="position: absolute; width: 20px; height: 20px; top: 40px; left: 40px;"></div>
</div>
-</div>
-<div style="position: absolute; height: 5000px; width: 5000px;"></div>
+ <div style="position: absolute; height: 5000px; width: 5000px;"></div>
-<div id="bug-5280" style="height: 30px; width: 201px;">
- <div style="width: 50px; height: 10px;"></div>
-</div>
+ <div id="fractions-parent" style="position: absolute; left: 10.7432222px; top: 10.532325px; height: 30px; width: 201px;">
+ <div id="fractions-element"></div>
+ </div>
-<div id="fractions-parent" style="position: absolute; left: 10.7432222px; top: 10.532325px; height: 30px; width: 201px;">
- <div id="fractions-element"></div>
+ <div id="bug-5280" style="height: 30px; width: 201px;">
+ <div style="width: 50px; height: 10px;"></div>
+ </div>
</div>
</body>
diff --git a/tests/unit/progressbar/all.html b/tests/unit/progressbar/all.html
index eefb9c135..16b9e0ace 100644
--- a/tests/unit/progressbar/all.html
+++ b/tests/unit/progressbar/all.html
@@ -7,9 +7,9 @@
<script src="../../../jquery-1.7.2.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
- <link rel="stylesheet" href="../subsuiteRunner.css">
+ <link rel="stylesheet" href="../qunit-composite.css">
<script src="../../../external/qunit.js"></script>
- <script src="../subsuiteRunner.js"></script>
+ <script src="../qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>
diff --git a/tests/unit/progressbar/progressbar.html b/tests/unit/progressbar/progressbar.html
index 8b55f5a89..70a4abe56 100644
--- a/tests/unit/progressbar/progressbar.html
+++ b/tests/unit/progressbar/progressbar.html
@@ -5,9 +5,12 @@
<title>jQuery UI Progressbar Test Suite</title>
<script src="../../jquery.js"></script>
- <script src="../../resource_loader.js"></script>
+ <link rel="stylesheet" href="../../../external/qunit.css">
+ <script src="../../../external/qunit.js"></script>
+ <script src="../../jquery.simulate.js"></script>
+ <script src="../testsuite.js"></script>
<script>
- loadResources({
+ TestHelpers.loadResources({
css: [ "ui.core", "ui.progressbar" ],
js: [
"ui/jquery.ui.core.js",
@@ -17,13 +20,8 @@
});
</script>
- <link rel="stylesheet" href="../../../external/qunit.css">
- <script src="../../../external/qunit.js"></script>
- <script src="../../jquery.simulate.js"></script>
- <script src="../testsuite.js"></script>
-
+ <script src="progressbar_common.js"></script>
<script src="progressbar_core.js"></script>
- <script src="progressbar_defaults.js"></script>
<script src="progressbar_events.js"></script>
<script src="progressbar_methods.js"></script>
<script src="progressbar_options.js"></script>
diff --git a/tests/unit/progressbar/progressbar_defaults.js b/tests/unit/progressbar/progressbar_common.js
index 3856e31a0..2f97a78bb 100644
--- a/tests/unit/progressbar/progressbar_defaults.js
+++ b/tests/unit/progressbar/progressbar_common.js
@@ -1,4 +1,4 @@
-commonWidgetTests( "progressbar", {
+TestHelpers.commonWidgetTests( "progressbar", {
defaults: {
disabled: false,
value: 0,
diff --git a/tests/unit/progressbar/progressbar_events.js b/tests/unit/progressbar/progressbar_events.js
index 8d7b8868d..f3713171b 100644
--- a/tests/unit/progressbar/progressbar_events.js
+++ b/tests/unit/progressbar/progressbar_events.js
@@ -15,7 +15,7 @@ test("create", function() {
change: function() {
ok(false, 'create() has triggered change()');
}
- })
+ });
});
test("change", function() {
diff --git a/tests/unit/qunit-composite.css b/tests/unit/qunit-composite.css
new file mode 100644
index 000000000..df47362db
--- /dev/null
+++ b/tests/unit/qunit-composite.css
@@ -0,0 +1,13 @@
+iframe.qunit-subsuite{
+ position: fixed;
+ bottom: 0;
+ left: 0;
+
+ margin: 0;
+ padding: 0;
+ border-width: 1px 0 0;
+ height: 45%;
+ width: 100%;
+
+ background: #fff;
+} \ No newline at end of file
diff --git a/tests/unit/qunit-composite.js b/tests/unit/qunit-composite.js
new file mode 100644
index 000000000..89c47eb29
--- /dev/null
+++ b/tests/unit/qunit-composite.js
@@ -0,0 +1,102 @@
+(function( QUnit ) {
+
+QUnit.extend( QUnit, {
+ testSuites: function( suites ) {
+ QUnit.begin(function() {
+ QUnit.initIframe();
+ });
+
+ for ( var i = 0; i < suites.length; i++ ) {
+ QUnit.runSuite( suites[i] );
+ }
+
+ QUnit.done(function() {
+ this.iframe.style.display = "none";
+ });
+ },
+
+ runSuite: function( suite ) {
+ asyncTest( suite, function() {
+ QUnit.iframe.setAttribute( "src", suite );
+ });
+ },
+
+ initIframe: function() {
+ var body = document.body,
+ iframe = this.iframe = document.createElement( "iframe" ),
+ iframeWin;
+
+ iframe.className = "qunit-subsuite";
+ body.appendChild( iframe );
+
+ function onIframeLoad() {
+ var module, test,
+ count = 0;
+
+
+ iframeWin.QUnit.moduleStart(function( data ) {
+ // capture module name for messages
+ module = data.name;
+ });
+
+ iframeWin.QUnit.testStart(function( data ) {
+ // capture test name for messages
+ test = data.name;
+ });
+ iframeWin.QUnit.testDone(function() {
+ test = null;
+ });
+
+ iframeWin.QUnit.log(function( data ) {
+ if (test === null) {
+ return;
+ }
+ // pass all test details through to the main page
+ var message = module + ": " + test + ": " + data.message;
+ expect( ++count );
+ QUnit.push( data.result, data.actual, data.expected, message );
+ });
+
+ iframeWin.QUnit.done(function() {
+ // start the wrapper test from the main page
+ start();
+ });
+ }
+ QUnit.addEvent( iframe, "load", onIframeLoad );
+
+ iframeWin = iframe.contentWindow;
+ }
+});
+
+QUnit.testStart(function( data ) {
+ // update the test status to show which test suite is running
+ QUnit.id( "qunit-testresult" ).innerHTML = "Running " + data.name + "...<br>&nbsp;";
+});
+
+QUnit.testDone(function() {
+ var i,
+ current = QUnit.id( this.config.current.id ),
+ children = current.children,
+ src = this.iframe.src;
+
+ // undo the auto-expansion of failed tests
+ for ( i = 0; i < children.length; i++ ) {
+ if ( children[i].nodeName === "OL" ) {
+ children[i].style.display = "none";
+ }
+ }
+
+ QUnit.addEvent(current, "dblclick", function( e ) {
+ var target = e && e.target ? e.target : window.event.srcElement;
+ if ( target.nodeName.toLowerCase() === "span" || target.nodeName.toLowerCase() === "b" ) {
+ target = target.parentNode;
+ }
+ if ( window.location && target.nodeName.toLowerCase() === "strong" ) {
+ window.location = src;
+ }
+ });
+
+ current.getElementsByTagName('a')[0].href = src;
+});
+
+}( QUnit ) );
diff --git a/tests/unit/resizable/all.html b/tests/unit/resizable/all.html
index 1c6811282..bef29ff6e 100644
--- a/tests/unit/resizable/all.html
+++ b/tests/unit/resizable/all.html
@@ -7,9 +7,9 @@
<script src="../../../jquery-1.7.2.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
- <link rel="stylesheet" href="../subsuiteRunner.css">
+ <link rel="stylesheet" href="../qunit-composite.css">
<script src="../../../external/qunit.js"></script>
- <script src="../subsuiteRunner.js"></script>
+ <script src="../qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>
diff --git a/tests/unit/resizable/resizable.html b/tests/unit/resizable/resizable.html
index 4e886d2fd..558574c5f 100644
--- a/tests/unit/resizable/resizable.html
+++ b/tests/unit/resizable/resizable.html
@@ -5,9 +5,12 @@
<title>jQuery UI Resizable Test Suite</title>
<script src="../../jquery.js"></script>
- <script src="../../resource_loader.js"></script>
+ <link rel="stylesheet" href="../../../external/qunit.css">
+ <script src="../../../external/qunit.js"></script>
+ <script src="../../jquery.simulate.js"></script>
+ <script src="../testsuite.js"></script>
<script>
- loadResources({
+ TestHelpers.loadResources({
css: [ "ui.core", "ui.resizable" ],
js: [
"ui/jquery.ui.core.js",
@@ -18,13 +21,8 @@
});
</script>
- <link rel="stylesheet" href="../../../external/qunit.css">
- <script src="../../../external/qunit.js"></script>
- <script src="../../jquery.simulate.js"></script>
- <script src="../testsuite.js"></script>
-
+ <script src="resizable_common.js"></script>
<script src="resizable_core.js"></script>
- <script src="resizable_defaults.js"></script>
<script src="resizable_events.js"></script>
<script src="resizable_methods.js"></script>
<script src="resizable_options.js"></script>
@@ -51,7 +49,7 @@
<div id="qunit-fixture">
<div id="resizable1" style="background: green; width: 100px; height: 100px;">I'm a resizable.</div>
-<img src="images/test.jpg" id="resizable2" style="width: 100px; height: 100px;">
+<img src="images/test.jpg" id="resizable2" style="width: 100px; height: 100px;" alt="solid gray">
</div>
</body>
diff --git a/tests/unit/resizable/resizable_common.js b/tests/unit/resizable/resizable_common.js
new file mode 100644
index 000000000..617cdd2ad
--- /dev/null
+++ b/tests/unit/resizable/resizable_common.js
@@ -0,0 +1,27 @@
+TestHelpers.commonWidgetTests('resizable', {
+ defaults: {
+ alsoResize: false,
+ animate: false,
+ animateDuration: 'slow',
+ animateEasing: 'swing',
+ aspectRatio: false,
+ autoHide: false,
+ cancel: ':input,option',
+ containment: false,
+ delay: 0,
+ disabled: false,
+ distance: 1,
+ ghost: false,
+ grid: false,
+ handles: 'e,s,se',
+ helper: false,
+ maxHeight: null,
+ maxWidth: null,
+ minHeight: 10,
+ minWidth: 10,
+ zIndex: 1000,
+
+ // callbacks
+ create: null
+ }
+});
diff --git a/tests/unit/resizable/resizable_defaults.js b/tests/unit/resizable/resizable_defaults.js
deleted file mode 100644
index f69e5217c..000000000
--- a/tests/unit/resizable/resizable_defaults.js
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * resizable_defaults.js
- */
-
-var resizable_defaults = {
- alsoResize: false,
- animate: false,
- animateDuration: 'slow',
- animateEasing: 'swing',
- aspectRatio: false,
- autoHide: false,
- cancel: ':input,option',
- containment: false,
- delay: 0,
- disabled: false,
- distance: 1,
- ghost: false,
- grid: false,
- handles: 'e,s,se',
- helper: false,
- maxHeight: null,
- maxWidth: null,
- minHeight: 10,
- minWidth: 10,
- zIndex: 1000
-};
-
-commonWidgetTests('resizable', { defaults: resizable_defaults });
diff --git a/tests/unit/resizable/resizable_events.js b/tests/unit/resizable/resizable_events.js
index e8041f064..52d55731c 100644
--- a/tests/unit/resizable/resizable_events.js
+++ b/tests/unit/resizable/resizable_events.js
@@ -5,16 +5,4 @@
module("resizable: events");
-test("start", function() {
- ok(false, "missing test - untested code is broken code.");
-});
-
-test("resize", function() {
- ok(false, "missing test - untested code is broken code.");
-});
-
-test("stop", function() {
- ok(false, "missing test - untested code is broken code.");
-});
-
})(jQuery);
diff --git a/tests/unit/resizable/resizable_methods.js b/tests/unit/resizable/resizable_methods.js
index 03e91d440..87859acf7 100644
--- a/tests/unit/resizable/resizable_methods.js
+++ b/tests/unit/resizable/resizable_methods.js
@@ -5,60 +5,5 @@
module("resizable: methods");
-test("init", function() {
- expect(6);
-
- $("<div></div>").appendTo('body').resizable().remove();
- ok(true, '.resizable() called on element');
-
- $([]).resizable().remove();
- ok(true, '.resizable() called on empty collection');
-
- $('<div></div>').resizable().remove();
- ok(true, '.resizable() called on disconnected DOMElement');
-
- $('<div></div>').resizable().resizable("foo").remove();
- ok(true, 'arbitrary method called after init');
-
- el = $('<div></div>').resizable()
- var foo = el.resizable("option", "foo");
- el.remove();
- ok(true, 'arbitrary option getter after init');
-
- $('<div></div>').resizable().resizable("option", "foo", "bar").remove();
- ok(true, 'arbitrary option setter after init');
-});
-
-test("destroy", function() {
- $("<div></div>").appendTo('body').resizable().resizable("destroy").remove();
- ok(true, '.resizable("destroy") called on element');
-
- $([]).resizable().resizable("destroy").remove();
- ok(true, '.resizable("destroy") called on empty collection');
-
- $('<div></div>').resizable().resizable("destroy").remove();
- ok(true, '.resizable("destroy") called on disconnected DOMElement');
-
- $('<div></div>').resizable().resizable("destroy").resizable("foo").remove();
- ok(true, 'arbitrary method called after destroy');
-
- var expected = $('<div></div>').resizable(),
- actual = expected.resizable('destroy');
- equal(actual, expected, 'destroy is chainable');
-});
-
-test("enable", function() {
- var expected = $('<div></div>').resizable(),
- actual = expected.resizable('enable');
- equal(actual, expected, 'enable is chainable');
- ok(false, "missing test - untested code is broken code.");
-});
-
-test("disable", function() {
- var expected = $('<div></div>').resizable(),
- actual = expected.resizable('disable');
- equal(actual, expected, 'disable is chainable');
- ok(false, "missing test - untested code is broken code.");
-});
})(jQuery);
diff --git a/tests/unit/resizable/resizable_options.js b/tests/unit/resizable/resizable_options.js
index 76cca560a..e10a55a31 100644
--- a/tests/unit/resizable/resizable_options.js
+++ b/tests/unit/resizable/resizable_options.js
@@ -187,4 +187,13 @@ test("ui-resizable-nw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 1
equal( target.height(), 100, "compare maxHeight" );
});
+test("zIndex, applied to all handles", function() {
+ expect(8);
+
+ var target = $('<div></div>').resizable({ handles: 'all', zIndex: 100 });
+ target.children( '.ui-resizable-handle' ).each( function( index, handle ) {
+ equal( $( handle ).css( 'zIndex' ), 100, 'compare zIndex' );
+ });
+});
+
})(jQuery);
diff --git a/tests/unit/selectable/all.html b/tests/unit/selectable/all.html
index bfebf46c2..51778e771 100644
--- a/tests/unit/selectable/all.html
+++ b/tests/unit/selectable/all.html
@@ -7,9 +7,9 @@
<script src="../../../jquery-1.7.2.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
- <link rel="stylesheet" href="../subsuiteRunner.css">
+ <link rel="stylesheet" href="../qunit-composite.css">
<script src="../../../external/qunit.js"></script>
- <script src="../subsuiteRunner.js"></script>
+ <script src="../qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>
diff --git a/tests/unit/selectable/selectable.html b/tests/unit/selectable/selectable.html
index 4f70e8dd4..7b0ca6ffe 100644
--- a/tests/unit/selectable/selectable.html
+++ b/tests/unit/selectable/selectable.html
@@ -5,9 +5,12 @@
<title>jQuery UI Selectable Test Suite</title>
<script src="../../jquery.js"></script>
- <script src="../../resource_loader.js"></script>
+ <link rel="stylesheet" href="../../../external/qunit.css">
+ <script src="../../../external/qunit.js"></script>
+ <script src="../../jquery.simulate.js"></script>
+ <script src="../testsuite.js"></script>
<script>
- loadResources({
+ TestHelpers.loadResources({
css: [ "ui.core", "ui.selectable" ],
js: [
"ui/jquery.ui.core.js",
@@ -18,13 +21,8 @@
});
</script>
- <link rel="stylesheet" href="../../../external/qunit.css">
- <script src="../../../external/qunit.js"></script>
- <script src="../../jquery.simulate.js"></script>
- <script src="../testsuite.js"></script>
-
+ <script src="selectable_common.js"></script>
<script src="selectable_core.js"></script>
- <script src="selectable_defaults.js"></script>
<script src="selectable_events.js"></script>
<script src="selectable_methods.js"></script>
<script src="selectable_options.js"></script>
diff --git a/tests/unit/selectable/selectable_common.js b/tests/unit/selectable/selectable_common.js
new file mode 100644
index 000000000..27714d0ae
--- /dev/null
+++ b/tests/unit/selectable/selectable_common.js
@@ -0,0 +1,12 @@
+TestHelpers.commonWidgetTests('selectable', {
+ defaults: {
+ appendTo: 'body',
+ autoRefresh: true,
+ cancel: ':input,option',
+ delay: 0,
+ disabled: false,
+ distance: 0,
+ filter: '*',
+ tolerance: 'touch'
+ }
+});
diff --git a/tests/unit/selectable/selectable_defaults.js b/tests/unit/selectable/selectable_defaults.js
deleted file mode 100644
index dbf799a43..000000000
--- a/tests/unit/selectable/selectable_defaults.js
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * selectable_defaults.js
- */
-
-var selectable_defaults = {
- appendTo: 'body',
- autoRefresh: true,
- cancel: ':input,option',
- delay: 0,
- disabled: false,
- distance: 0,
- filter: '*',
- tolerance: 'touch'
-};
-
-commonWidgetTests('selectable', { defaults: selectable_defaults });
diff --git a/tests/unit/selectable/selectable_methods.js b/tests/unit/selectable/selectable_methods.js
index 32dfe00ed..dbc88f269 100644
--- a/tests/unit/selectable/selectable_methods.js
+++ b/tests/unit/selectable/selectable_methods.js
@@ -20,7 +20,7 @@ test("init", function() {
$("<div></div>").selectable().selectable("foo").remove();
ok(true, 'arbitrary method called after init');
- el = $("<div></div>").selectable()
+ el = $("<div></div>").selectable();
var foo = el.selectable("option", "foo");
el.remove();
ok(true, 'arbitrary option getter after init');
@@ -49,7 +49,8 @@ test("destroy", function() {
test("enable", function() {
expect(3);
- var fired = false;
+ var expected, actual,
+ fired = false;
el = $("#selectable1");
el.selectable({
@@ -63,14 +64,15 @@ test("enable", function() {
equal(fired, true, "start fired");
el.selectable("destroy");
- var expected = $('<div></div>').selectable(),
- actual = expected.selectable('enable');
+ expected = $('<div></div>').selectable();
+ actual = expected.selectable('enable');
equal(actual, expected, 'enable is chainable');
});
test("disable", function() {
expect(3);
- var fired = false;
+ var expected, actual,
+ fired = false;
el = $("#selectable1");
el.selectable({
@@ -85,8 +87,8 @@ test("disable", function() {
equal(fired, false, "start fired");
el.selectable("destroy");
- var expected = $('<div></div>').selectable(),
- actual = expected.selectable('disable');
+ expected = $('<div></div>').selectable();
+ actual = expected.selectable('disable');
equal(actual, expected, 'disable is chainable');
});
diff --git a/tests/unit/selectable/selectable_options.js b/tests/unit/selectable/selectable_options.js
index 2bc44e6e0..be9fdf5fe 100644
--- a/tests/unit/selectable/selectable_options.js
+++ b/tests/unit/selectable/selectable_options.js
@@ -8,7 +8,7 @@ module("selectable: options");
test("autoRefresh", function() {
expect(3);
el = $("#selectable1");
- var actual, sel = $("*", el), selected = function() { actual += 1 };
+ var actual, sel = $("*", el), selected = function() { actual += 1; };
actual = 0;
el = $("#selectable1").selectable({ autoRefresh: false, selected: selected });
@@ -33,12 +33,12 @@ test("autoRefresh", function() {
test("filter", function() {
expect(2);
el = $("#selectable1");
- var actual, sel = $("*", el), selected = function() { actual += 1 };
+ var actual, sel = $("*", el), selected = function() { actual += 1; };
actual = 0;
el = $("#selectable1").selectable({ filter: '.special', selected: selected });
drag(1000, 1000);
- ok(sel.length != 1, "this test assumes more than 1 selectee");
+ ok(sel.length !== 1, "this test assumes more than 1 selectee");
equal(actual, 1);
el.selectable("destroy");
});
diff --git a/tests/unit/slider/all.html b/tests/unit/slider/all.html
index 5aac26ced..bfadc0380 100644
--- a/tests/unit/slider/all.html
+++ b/tests/unit/slider/all.html
@@ -7,9 +7,9 @@
<script src="../../../jquery-1.7.2.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
- <link rel="stylesheet" href="../subsuiteRunner.css">
+ <link rel="stylesheet" href="../qunit-composite.css">
<script src="../../../external/qunit.js"></script>
- <script src="../subsuiteRunner.js"></script>
+ <script src="../qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>
diff --git a/tests/unit/slider/slider.html b/tests/unit/slider/slider.html
index 60d124b7a..3aec78b4b 100644
--- a/tests/unit/slider/slider.html
+++ b/tests/unit/slider/slider.html
@@ -5,9 +5,12 @@
<title>jQuery UI Slider Test Suite</title>
<script src="../../jquery.js"></script>
- <script src="../../resource_loader.js"></script>
+ <link rel="stylesheet" href="../../../external/qunit.css">
+ <script src="../../../external/qunit.js"></script>
+ <script src="../../jquery.simulate.js"></script>
+ <script src="../testsuite.js"></script>
<script>
- loadResources({
+ TestHelpers.loadResources({
css: [ "ui.core", "ui.slider" ],
js: [
"ui/jquery.ui.core.js",
@@ -18,13 +21,8 @@
});
</script>
- <link rel="stylesheet" href="../../../external/qunit.css">
- <script src="../../../external/qunit.js"></script>
- <script src="../../jquery.simulate.js"></script>
- <script src="../testsuite.js"></script>
-
+ <script src="slider_common.js"></script>
<script src="slider_core.js"></script>
- <script src="slider_defaults.js"></script>
<script src="slider_events.js"></script>
<script src="slider_methods.js"></script>
<script src="slider_options.js"></script>
diff --git a/tests/unit/slider/slider_defaults.js b/tests/unit/slider/slider_common.js
index 8049fe969..8a0b347f3 100644
--- a/tests/unit/slider/slider_defaults.js
+++ b/tests/unit/slider/slider_common.js
@@ -1,4 +1,4 @@
-commonWidgetTests( "slider", {
+TestHelpers.commonWidgetTests( "slider", {
defaults: {
animate: false,
cancel: ':input,option',
diff --git a/tests/unit/slider/slider_methods.js b/tests/unit/slider/slider_methods.js
index b46222002..79f80e868 100644
--- a/tests/unit/slider/slider_methods.js
+++ b/tests/unit/slider/slider_methods.js
@@ -17,8 +17,8 @@ test("init", function() {
$('<div></div>').slider().remove();
ok(true, '.slider() called on disconnected DOMElement');
- var el = $('<div></div>').slider();
- var foo = el.slider("option", "foo");
+ var el = $('<div></div>').slider(),
+ foo = el.slider("option", "foo");
el.remove();
ok(true, 'arbitrary option getter after init');
@@ -42,11 +42,12 @@ test("destroy", function() {
});
test("enable", function() {
- var expected = $('<div></div>').slider(),
+ var el,
+ expected = $('<div></div>').slider(),
actual = expected.slider('enable');
equal(actual, expected, 'enable is chainable');
- var el = $('<div></div>').slider({ disabled: true });
+ el = $('<div></div>').slider({ disabled: true });
ok(el.hasClass('ui-disabled'), 'slider has ui-disabled class before enable method call');
ok(el.hasClass('ui-slider-disabled'), 'slider has ui-slider-disabled class before enable method call');
el.slider('enable');
@@ -55,11 +56,12 @@ test("enable", function() {
});
test("disable", function() {
- var expected = $('<div></div>').slider(),
+ var el,
+ expected = $('<div></div>').slider(),
actual = expected.slider('disable');
equal(actual, expected, 'disable is chainable');
- var el = $('<div></div>').slider({ disabled: false });
+ el = $('<div></div>').slider({ disabled: false });
ok(!el.hasClass('ui-disabled'), 'slider does not have ui-disabled class before disabled method call');
ok(!el.hasClass('ui-slider-disabled'), 'slider does not have ui-slider-disabled class before disable method call');
el.slider('disable');
diff --git a/tests/unit/slider/slider_options.js b/tests/unit/slider/slider_options.js
index 7d9899284..09067a3e9 100644
--- a/tests/unit/slider/slider_options.js
+++ b/tests/unit/slider/slider_options.js
@@ -23,8 +23,8 @@ test("max", function() {
};
el.slider(options);
- ok(el.slider("option", "value") == options.value, "value option is not contained by max");
- ok(el.slider("value") == options.max, "value method is contained by max");
+ ok(el.slider("option", "value") === options.value, "value option is not contained by max");
+ ok(el.slider("value") === options.max, "value method is contained by max");
el.slider('destroy');
});
@@ -41,8 +41,8 @@ test("min", function() {
};
el.slider(options);
- ok(el.slider("option", "value") == options.value, "value option is not contained by min");
- ok(el.slider("value") == options.min, "value method is contained by min");
+ ok(el.slider("option", "value") === options.value, "value option is not contained by min");
+ ok(el.slider("value") === options.min, "value method is contained by min");
el.slider('destroy');
});
@@ -73,7 +73,7 @@ test("orientation", function() {
value: -1
};
- var percentVal = (options.value - options.min) / (options.max - options.min) * 100;
+ percentVal = (options.value - options.min) / (options.max - options.min) * 100;
el.slider(options).slider("option", "orientation", "vertical");
ok(el.is('.ui-slider-vertical'), "vertical slider has class .ui-slider-vertical");
diff --git a/tests/unit/sortable/all.html b/tests/unit/sortable/all.html
index 89e239250..f9d63d62e 100644
--- a/tests/unit/sortable/all.html
+++ b/tests/unit/sortable/all.html
@@ -7,9 +7,9 @@
<script src="../../../jquery-1.7.2.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
- <link rel="stylesheet" href="../subsuiteRunner.css">
+ <link rel="stylesheet" href="../qunit-composite.css">
<script src="../../../external/qunit.js"></script>
- <script src="../subsuiteRunner.js"></script>
+ <script src="../qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>
diff --git a/tests/unit/sortable/sortable.html b/tests/unit/sortable/sortable.html
index a20eb7109..c84c62197 100644
--- a/tests/unit/sortable/sortable.html
+++ b/tests/unit/sortable/sortable.html
@@ -5,9 +5,12 @@
<title>jQuery UI Sortable Test Suite</title>
<script src="../../jquery.js"></script>
- <script src="../../resource_loader.js"></script>
+ <link rel="stylesheet" href="../../../external/qunit.css">
+ <script src="../../../external/qunit.js"></script>
+ <script src="../../jquery.simulate.js"></script>
+ <script src="../testsuite.js"></script>
<script>
- loadResources({
+ TestHelpers.loadResources({
css: [ "ui.core", "ui.sortable" ],
js: [
"ui/jquery.ui.core.js",
@@ -18,13 +21,8 @@
});
</script>
- <link rel="stylesheet" href="../../../external/qunit.css">
- <script src="../../../external/qunit.js"></script>
- <script src="../../jquery.simulate.js"></script>
- <script src="../testsuite.js"></script>
-
+ <script src="sortable_common.js"></script>
<script src="sortable_core.js"></script>
- <script src="sortable_defaults.js"></script>
<script src="sortable_events.js"></script>
<script src="sortable_methods.js"></script>
<script src="sortable_options.js"></script>
diff --git a/tests/unit/sortable/sortable_common.js b/tests/unit/sortable/sortable_common.js
new file mode 100644
index 000000000..b5fc05a5d
--- /dev/null
+++ b/tests/unit/sortable/sortable_common.js
@@ -0,0 +1,30 @@
+TestHelpers.commonWidgetTests( "sortable", {
+ defaults: {
+ appendTo: "parent",
+ axis: false,
+ cancel: ":input,option",
+ connectWith: false,
+ containment: false,
+ cursor: "auto",
+ cursorAt: false,
+ delay: 0,
+ disabled: false,
+ distance: 1,
+ dropOnEmpty: true,
+ forcePlaceholderSize: false,
+ forceHelperSize: false,
+ grid: false,
+ handle: false,
+ helper: "original",
+ items: "> *",
+ opacity: false,
+ placeholder: false,
+ revert: false,
+ scroll: true,
+ scrollSensitivity: 20,
+ scrollSpeed: 20,
+ scope: "default",
+ tolerance: "intersect",
+ zIndex: 1000
+ }
+});
diff --git a/tests/unit/sortable/sortable_defaults.js b/tests/unit/sortable/sortable_defaults.js
deleted file mode 100644
index 7681addad..000000000
--- a/tests/unit/sortable/sortable_defaults.js
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * sortable_defaults.js
- */
-
-var sortable_defaults = {
- appendTo: "parent",
- axis: false,
- cancel: ":input,option",
- connectWith: false,
- containment: false,
- cursor: 'auto',
- cursorAt: false,
- delay: 0,
- disabled: false,
- distance: 1,
- dropOnEmpty: true,
- forcePlaceholderSize: false,
- forceHelperSize: false,
- grid: false,
- handle: false,
- helper: "original",
- items: "> *",
- opacity: false,
- placeholder: false,
- revert: false,
- scroll: true,
- scrollSensitivity: 20,
- scrollSpeed: 20,
- scope: "default",
- tolerance: "intersect",
- zIndex: 1000
-};
-
-commonWidgetTests('sortable', { defaults: sortable_defaults });
diff --git a/tests/unit/sortable/sortable_events.js b/tests/unit/sortable/sortable_events.js
index cb4ff4ff3..6ed54e1b6 100644
--- a/tests/unit/sortable/sortable_events.js
+++ b/tests/unit/sortable/sortable_events.js
@@ -6,13 +6,13 @@
module("sortable: events");
test("start", function() {
-
+
var hash;
$("#sortable")
.sortable({ start: function(e, ui) { hash = ui; } })
.find('li:eq(0)').simulate("drag", { dx: 0, dy: 10 });
-
- ok(hash, 'start event triggered');
+
+ ok(hash, 'start event triggered');
ok(hash.helper, 'UI hash includes: helper');
ok(hash.placeholder, 'UI hash includes: placeholder');
ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position');
@@ -20,104 +20,104 @@ test("start", function() {
ok(hash.item, 'UI hash includes: item');
ok(!hash.sender, 'UI hash does not include: sender');
-
+
});
test("sort", function() {
-
+
var hash;
$("#sortable")
.sortable({ sort: function(e, ui) { hash = ui; } })
.find('li:eq(0)').simulate("drag", { dx: 0, dy: 10 });
-
- ok(hash, 'sort event triggered');
+
+ ok(hash, 'sort event triggered');
ok(hash.helper, 'UI hash includes: helper');
ok(hash.placeholder, 'UI hash includes: placeholder');
ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position');
ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset');
ok(hash.item, 'UI hash includes: item');
ok(!hash.sender, 'UI hash does not include: sender');
-
+
});
test("change", function() {
-
+
var hash;
$("#sortable")
.sortable({ change: function(e, ui) { hash = ui; } })
.find('li:eq(0)').simulate("drag", { dx: 1, dy: 1 });
-
+
ok(!hash, '1px drag, change event should not be triggered');
-
+
$("#sortable")
.sortable({ change: function(e, ui) { hash = ui; } })
- .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 });
-
- ok(hash, 'change event triggered');
+ .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 });
+
+ ok(hash, 'change event triggered');
ok(hash.helper, 'UI hash includes: helper');
ok(hash.placeholder, 'UI hash includes: placeholder');
ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position');
ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset');
ok(hash.item, 'UI hash includes: item');
ok(!hash.sender, 'UI hash does not include: sender');
-
+
});
test("beforeStop", function() {
-
+
var hash;
$("#sortable")
.sortable({ beforeStop: function(e, ui) { hash = ui; } })
- .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 });
-
- ok(hash, 'beforeStop event triggered');
+ .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 });
+
+ ok(hash, 'beforeStop event triggered');
ok(hash.helper, 'UI hash includes: helper');
ok(hash.placeholder, 'UI hash includes: placeholder');
ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position');
ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset');
ok(hash.item, 'UI hash includes: item');
ok(!hash.sender, 'UI hash does not include: sender');
-
+
});
test("stop", function() {
-
+
var hash;
$("#sortable")
.sortable({ stop: function(e, ui) { hash = ui; } })
- .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 });
-
- ok(hash, 'stop event triggered');
+ .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 });
+
+ ok(hash, 'stop event triggered');
ok(!hash.helper, 'UI should not include: helper');
ok(hash.placeholder, 'UI hash includes: placeholder');
ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position');
ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset');
ok(hash.item, 'UI hash includes: item');
ok(!hash.sender, 'UI hash does not include: sender');
-
+
});
test("update", function() {
-
+
var hash;
$("#sortable")
.sortable({ update: function(e, ui) { hash = ui; } })
.find('li:eq(0)').simulate("drag", { dx: 1, dy: 1 });
-
+
ok(!hash, '1px drag, update event should not be triggered');
-
+
$("#sortable")
.sortable({ update: function(e, ui) { hash = ui; } })
- .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 });
-
- ok(hash, 'update event triggered');
+ .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 });
+
+ ok(hash, 'update event triggered');
ok(!hash.helper, 'UI hash should not include: helper');
ok(hash.placeholder, 'UI hash includes: placeholder');
ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position');
ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset');
ok(hash.item, 'UI hash includes: item');
ok(!hash.sender, 'UI hash does not include: sender');
-
+
});
test("receive", function() {
diff --git a/tests/unit/sortable/sortable_methods.js b/tests/unit/sortable/sortable_methods.js
index 2446d2755..c2a0b9548 100644
--- a/tests/unit/sortable/sortable_methods.js
+++ b/tests/unit/sortable/sortable_methods.js
@@ -5,7 +5,7 @@
var el, offsetBefore, offsetAfter, dragged;
-var drag = function(handle, dx, dy) {
+function drag(handle, dx, dy) {
offsetBefore = $(handle).offset();
$(handle).simulate("drag", {
dx: dx || 0,
@@ -15,7 +15,7 @@ var drag = function(handle, dx, dy) {
offsetAfter = $(handle).offset();
}
-var sort = function(handle, dx, dy, index, msg) {
+function sort(handle, dx, dy, index, msg) {
drag(handle, dx, dy);
equal($(handle).parent().children().index(handle), index, msg);
}
diff --git a/tests/unit/sortable/sortable_tickets.js b/tests/unit/sortable/sortable_tickets.js
index 6ee503a58..22ad61baf 100644
--- a/tests/unit/sortable/sortable_tickets.js
+++ b/tests/unit/sortable/sortable_tickets.js
@@ -5,7 +5,7 @@
var el, offsetBefore, offsetAfter, dragged;
-var drag = function(handle, dx, dy) {
+function drag(handle, dx, dy) {
offsetBefore = $(handle).offset();
$(handle).simulate("drag", {
dx: dx || 0,
@@ -15,7 +15,7 @@ var drag = function(handle, dx, dy) {
offsetAfter = $(handle).offset();
}
-var sort = function(handle, dx, dy, index, msg) {
+function sort(handle, dx, dy, index, msg) {
drag(handle, dx, dy);
equal($(handle).parent().children().index(handle), index, msg);
}
diff --git a/tests/unit/spinner/all.html b/tests/unit/spinner/all.html
index e41e088c4..72a2dd77a 100644
--- a/tests/unit/spinner/all.html
+++ b/tests/unit/spinner/all.html
@@ -7,9 +7,9 @@
<script src="../../../jquery-1.7.2.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
- <link rel="stylesheet" href="../subsuiteRunner.css">
+ <link rel="stylesheet" href="../qunit-composite.css">
<script src="../../../external/qunit.js"></script>
- <script src="../subsuiteRunner.js"></script>
+ <script src="../qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>
diff --git a/tests/unit/spinner/spinner.html b/tests/unit/spinner/spinner.html
index 0c01a5f48..b7f4a532a 100644
--- a/tests/unit/spinner/spinner.html
+++ b/tests/unit/spinner/spinner.html
@@ -3,14 +3,17 @@
<head>
<meta charset="utf-8">
<title>jQuery UI Spinner Test Suite</title>
-
+
<script src="../../jquery.js"></script>
<script src="../../../external/jquery.mousewheel-3.0.4.js"></script>
<script src="../../../external/globalize.js"></script>
<script src="../../../external/globalize.culture.ja-JP.js"></script>
- <script src="../../resource_loader.js"></script>
+ <link rel="stylesheet" href="../../../external/qunit.css">
+ <script src="../../../external/qunit.js"></script>
+ <script src="../../jquery.simulate.js"></script>
+ <script src="../testsuite.js"></script>
<script>
- loadResources({
+ TestHelpers.loadResources({
css: [ "ui.core", "ui.button", "ui.spinner" ],
js: [
"ui/jquery.ui.core.js",
@@ -21,14 +24,9 @@
});
</script>
- <link rel="stylesheet" href="../../../external/qunit.css">
- <script src="../../../external/qunit.js"></script>
- <script src="../../jquery.simulate.js"></script>
- <script src="../testsuite.js"></script>
-
<script src="spinner_test_helpers.js"></script>
+ <script src="spinner_common.js"></script>
<script src="spinner_core.js"></script>
- <script src="spinner_defaults.js"></script>
<script src="spinner_events.js"></script>
<script src="spinner_methods.js"></script>
<script src="spinner_options.js"></script>
diff --git a/tests/unit/spinner/spinner_defaults.js b/tests/unit/spinner/spinner_common.js
index 0a4e7c236..4f05b1e63 100644
--- a/tests/unit/spinner/spinner_defaults.js
+++ b/tests/unit/spinner/spinner_common.js
@@ -1,4 +1,4 @@
-commonWidgetTests( "spinner", {
+TestHelpers.commonWidgetTests( "spinner", {
defaults: {
culture: null,
disabled: false,
diff --git a/tests/unit/spinner/spinner_core.js b/tests/unit/spinner/spinner_core.js
index e12d1af2f..a1179bb35 100644
--- a/tests/unit/spinner/spinner_core.js
+++ b/tests/unit/spinner/spinner_core.js
@@ -1,5 +1,7 @@
(function( $ ) {
+var simulateKeyDownUp = TestHelpers.spinner.simulateKeyDownUp;
+
module( "spinner: core" );
test( "keydown UP on input, increases value not greater than max", function() {
@@ -9,15 +11,15 @@ test( "keydown UP on input, increases value not greater than max", function() {
step: 10
});
- spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
+ simulateKeyDownUp( element, $.ui.keyCode.UP );
equal( element.val(), 80 );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
+ simulateKeyDownUp( element, $.ui.keyCode.UP );
equal( element.val(), 90 );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
+ simulateKeyDownUp( element, $.ui.keyCode.UP );
equal( element.val(), 100 );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
+ simulateKeyDownUp( element, $.ui.keyCode.UP );
equal( element.val(), 100 );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
+ simulateKeyDownUp( element, $.ui.keyCode.UP );
equal( element.val(), 100 );
});
@@ -28,15 +30,15 @@ test( "keydown DOWN on input, decreases value not less than min", function() {
step: 10
});
- spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
+ simulateKeyDownUp( element, $.ui.keyCode.DOWN );
equal( element.val(), 40 );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
+ simulateKeyDownUp( element, $.ui.keyCode.DOWN );
equal( element.val(), 30 );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
+ simulateKeyDownUp( element, $.ui.keyCode.DOWN );
equal( element.val(), 20 );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
+ simulateKeyDownUp( element, $.ui.keyCode.DOWN );
equal( element.val(), 20 );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
+ simulateKeyDownUp( element, $.ui.keyCode.DOWN );
equal( element.val(), 20 );
});
@@ -47,15 +49,15 @@ test( "keydown PAGE_UP on input, increases value not greater than max", function
page: 10
});
- spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
+ simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
equal( element.val(), 80 );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
+ simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
equal( element.val(), 90 );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
+ simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
equal( element.val(), 100 );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
+ simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
equal( element.val(), 100 );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
+ simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
equal( element.val(), 100 );
});
@@ -66,15 +68,15 @@ test( "keydown PAGE_DOWN on input, decreases value not less than min", function(
page: 10
});
- spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
+ simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
equal( element.val(), 40 );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
+ simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
equal( element.val(), 30 );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
+ simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
equal( element.val(), 20 );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
+ simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
equal( element.val(), 20 );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
+ simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
equal( element.val(), 20 );
});
@@ -99,7 +101,7 @@ test( "mouse click on up button, increases value not greater than max", function
min: 0
}),
button = element.spinner( "widget" ).find( ".ui-spinner-down" );
-
+
button.trigger( "mousedown" ).trigger( "mouseup" );
equal( element.val(), 1 );
button.trigger( "mousedown" ).trigger( "mouseup" );
@@ -189,8 +191,8 @@ test( "don't clear invalid value on blur", function() {
test( "precision", function() {
expect( 2 );
- var element = $( "#spin" ).val( .05 ).spinner({
- step: .0001
+ var element = $( "#spin" ).val( 0.05 ).spinner({
+ step: 0.0001
});
element.spinner( "stepUp" );
equal( element.val(), "0.0501", "precision from step" );
diff --git a/tests/unit/spinner/spinner_events.js b/tests/unit/spinner/spinner_events.js
index e43ba3365..72b185528 100644
--- a/tests/unit/spinner/spinner_events.js
+++ b/tests/unit/spinner/spinner_events.js
@@ -1,5 +1,7 @@
(function( $ ) {
+var simulateKeyDownUp = TestHelpers.spinner.simulateKeyDownUp;
+
module( "spinner: events" );
test( "start", function() {
@@ -13,14 +15,14 @@ test( "start", function() {
}
shouldStart( true, "key UP" );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
+ simulateKeyDownUp( element, $.ui.keyCode.UP );
shouldStart( true, "key DOWN" );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
+ simulateKeyDownUp( element, $.ui.keyCode.DOWN );
shouldStart( true, "key PAGE_UP" );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
+ simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
shouldStart( true, "key PAGE_DOWN" );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
+ simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
shouldStart( true, "button up" );
element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup();
@@ -52,14 +54,14 @@ test( "spin", function() {
}
shouldSpin( true, "key UP" );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
+ simulateKeyDownUp( element, $.ui.keyCode.UP );
shouldSpin( true, "key DOWN" );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
+ simulateKeyDownUp( element, $.ui.keyCode.DOWN );
shouldSpin( true, "key PAGE_UP" );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
+ simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
shouldSpin( true, "key PAGE_DOWN" );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
+ simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
shouldSpin( true, "button up" );
element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup();
@@ -91,14 +93,14 @@ test( "stop", function() {
}
shouldStop( true, "key UP" );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
+ simulateKeyDownUp( element, $.ui.keyCode.UP );
shouldStop( true, "key DOWN" );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
+ simulateKeyDownUp( element, $.ui.keyCode.DOWN );
shouldStop( true, "key PAGE_UP" );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
+ simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
shouldStop( true, "key PAGE_DOWN" );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
+ simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
shouldStop( true, "button up" );
element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup();
@@ -119,7 +121,7 @@ test( "stop", function() {
element.spinner( "value", 999 );
});
-test( "change", function() {
+asyncTest( "change", function() {
expect( 14 );
var element = $( "#spin" ).spinner();
@@ -131,91 +133,97 @@ test( "change", function() {
element.focus();
shouldChange( false, "key UP, before blur" );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
+ simulateKeyDownUp( element, $.ui.keyCode.UP );
shouldChange( true, "blur after key UP" );
element.blur();
element.focus();
shouldChange( false, "key DOWN, before blur" );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
+ simulateKeyDownUp( element, $.ui.keyCode.DOWN );
shouldChange( true, "blur after key DOWN" );
element.blur();
element.focus();
shouldChange( false, "key PAGE_UP, before blur" );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
+ simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
shouldChange( true, "blur after key PAGE_UP" );
element.blur();
element.focus();
shouldChange( false, "key PAGE_DOWN, before blur" );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
+ simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
shouldChange( true, "blur after key PAGE_DOWN" );
element.blur();
shouldChange( false, "many keys, before blur" );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
+ simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
+ simulateKeyDownUp( element, $.ui.keyCode.UP );
+ simulateKeyDownUp( element, $.ui.keyCode.UP );
+ simulateKeyDownUp( element, $.ui.keyCode.UP );
+ simulateKeyDownUp( element, $.ui.keyCode.DOWN );
shouldChange( true, "blur after many keys" );
element.blur();
shouldChange( false, "many keys, same final value, before blur" );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
+ simulateKeyDownUp( element, $.ui.keyCode.UP );
+ simulateKeyDownUp( element, $.ui.keyCode.UP );
+ simulateKeyDownUp( element, $.ui.keyCode.DOWN );
+ simulateKeyDownUp( element, $.ui.keyCode.DOWN );
shouldChange( false, "blur after many keys, same final value" );
shouldChange( false, "button up, before blur" );
element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup();
shouldChange( true, "blur after button up" );
- element.blur();
-
- shouldChange( false, "button down, before blur" );
- element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
- shouldChange( true, "blur after button down" );
- element.blur();
-
- shouldChange( false, "many buttons, same final value, before blur" );
- element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup();
- element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup();
- element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
- element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
- shouldChange( false, "blur after many buttons, same final value" );
- element.blur();
-
- shouldChange( true, "stepUp" );
- element.spinner( "stepUp" );
-
- shouldChange( true, "stepDown" );
- element.spinner( "stepDown" );
-
- shouldChange( true, "pageUp" );
- element.spinner( "pageUp" );
-
- shouldChange( true, "pageDown" );
- element.spinner( "pageDown" );
-
- shouldChange( true, "value" );
- element.spinner( "value", 999 );
-
- shouldChange( false, "value, same value" );
- element.spinner( "value", 999 );
-
- shouldChange( true, "max, value changed" );
- element.spinner( "option", "max", 900 );
-
- shouldChange( false, "max, value not changed" );
- element.spinner( "option", "max", 1000 );
-
- shouldChange( true, "min, value changed" );
- element.spinner( "option", "min", 950 );
-
- shouldChange( false, "min, value not changed" );
- element.spinner( "option", "min", 200 );
+ setTimeout(function() {
+ element.blur();
+
+ shouldChange( false, "button down, before blur" );
+ element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
+ shouldChange( true, "blur after button down" );
+ setTimeout(function() {
+ element.blur();
+
+ shouldChange( false, "many buttons, same final value, before blur" );
+ element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup();
+ element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup();
+ element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
+ element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
+ shouldChange( false, "blur after many buttons, same final value" );
+ element.blur();
+ setTimeout(function() {
+ shouldChange( true, "stepUp" );
+ element.spinner( "stepUp" );
+
+ shouldChange( true, "stepDown" );
+ element.spinner( "stepDown" );
+
+ shouldChange( true, "pageUp" );
+ element.spinner( "pageUp" );
+
+ shouldChange( true, "pageDown" );
+ element.spinner( "pageDown" );
+
+ shouldChange( true, "value" );
+ element.spinner( "value", 999 );
+
+ shouldChange( false, "value, same value" );
+ element.spinner( "value", 999 );
+
+ shouldChange( true, "max, value changed" );
+ element.spinner( "option", "max", 900 );
+
+ shouldChange( false, "max, value not changed" );
+ element.spinner( "option", "max", 1000 );
+
+ shouldChange( true, "min, value changed" );
+ element.spinner( "option", "min", 950 );
+
+ shouldChange( false, "min, value not changed" );
+ element.spinner( "option", "min", 200 );
+ start();
+ });
+ });
+ });
});
})( jQuery );
diff --git a/tests/unit/spinner/spinner_methods.js b/tests/unit/spinner/spinner_methods.js
index 9c82218e1..bafd949a7 100644
--- a/tests/unit/spinner/spinner_methods.js
+++ b/tests/unit/spinner/spinner_methods.js
@@ -1,5 +1,7 @@
(function( $ ) {
+var simulateKeyDownUp = TestHelpers.spinner.simulateKeyDownUp;
+
module( "spinner: methods" );
test( "destroy", function() {
@@ -21,16 +23,16 @@ test( "disable", function() {
ok( wrapper.hasClass( "ui-spinner-disabled" ), "after: wrapper has ui-spinner-disabled class" );
ok( element.is( ":disabled"), "after: input has disabled attribute" );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
+ simulateKeyDownUp( element, $.ui.keyCode.UP );
equal( 2, element.val(), "keyboard - value does not change on key UP" );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
+ simulateKeyDownUp( element, $.ui.keyCode.DOWN );
equal( 2, element.val(), "keyboard - value does not change on key DOWN" );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
+ simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
equal( 2, element.val(), "keyboard - value does not change on key PGUP" );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
+ simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
equal( 2, element.val(), "keyboard - value does not change on key PGDN" );
wrapper.find( ".ui-spinner-up" ).trigger( "mousedown" ).trigger( "mouseup" );
@@ -54,7 +56,7 @@ test( "disable", function() {
test( "enable", function() {
expect( 5 );
- var element = $( "#spin" ).val( 1 ).spinner({ disabled: true })
+ var element = $( "#spin" ).val( 1 ).spinner({ disabled: true }),
wrapper = element.spinner( "widget" );
ok( wrapper.hasClass( "ui-spinner-disabled" ), "before: wrapper has ui-spinner-disabled class" );
@@ -65,7 +67,7 @@ test( "enable", function() {
ok( !wrapper.hasClass( ".ui-spinner-disabled" ), "after: wrapper does not have ui-spinner-disabled class" );
ok( !element.is( ":disabled" ), "after: input does not have disabled attribute" );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
+ simulateKeyDownUp( element, $.ui.keyCode.UP );
equal( 2, element.val(), "keyboard - value changes on key UP" );
});
diff --git a/tests/unit/spinner/spinner_options.js b/tests/unit/spinner/spinner_options.js
index cbad3f870..e21852630 100644
--- a/tests/unit/spinner/spinner_options.js
+++ b/tests/unit/spinner/spinner_options.js
@@ -1,5 +1,7 @@
(function( $ ) {
+var simulateKeyDownUp = TestHelpers.spinner.simulateKeyDownUp;
+
module( "spinner: options" );
// culture is tested after numberFormat, since it depends on numberFormat
@@ -191,7 +193,7 @@ test( "min, string", function() {
equal( element.spinner( "option", "min" ), -100, "option converted to number" );
element.spinner( "value", -1000 );
- equal( element.val(), "($100.00)", "min constrained in value method")
+ equal( element.val(), "($100.00)", "min constrained in value method" );
});
test( "step, 2", function() {
diff --git a/tests/unit/spinner/spinner_test_helpers.js b/tests/unit/spinner/spinner_test_helpers.js
index af555dbf2..2021e8f7a 100644
--- a/tests/unit/spinner/spinner_test_helpers.js
+++ b/tests/unit/spinner/spinner_test_helpers.js
@@ -1,5 +1,8 @@
-var spinner_simulateKeyDownUp = function( element, keyCode, shift ) {
- element
- .simulate( "keydown", { keyCode: keyCode, shiftKey: shift || false } )
- .simulate( "keyup", { keyCode: keyCode, shiftKey: shift || false } );
+TestHelpers.spinner = {
+ simulateKeyDownUp: function( element, keyCode, shift ) {
+ element
+ .simulate( "keydown", { keyCode: keyCode, shiftKey: shift || false } )
+ .simulate( "keyup", { keyCode: keyCode, shiftKey: shift || false } );
+ }
};
+
diff --git a/tests/unit/subsuite.js b/tests/unit/subsuite.js
index 03e8c9706..6f966590b 100644
--- a/tests/unit/subsuite.js
+++ b/tests/unit/subsuite.js
@@ -1,12 +1,11 @@
(function() {
-var versions = [ "1.6", "1.6.1", "1.6.2", "1.6.3", "1.6.4", "1.7", "1.7.1", "1.7.2", "git" ];
-
-var additionalTests = {
- accordion: [ "accordion_deprecated.html" ],
- position: [ "position_deprecated.html" ],
- tabs: [ "tabs_deprecated.html" ]
-};
+var versions = [ "1.6", "1.6.1", "1.6.2", "1.6.3", "1.6.4", "1.7", "1.7.1", "1.7.2", "git" ],
+ additionalTests = {
+ accordion: [ "accordion_deprecated.html" ],
+ position: [ "position_deprecated.html" ],
+ tabs: [ "tabs_deprecated.html" ]
+ };
window.testAllVersions = function( widget ) {
QUnit.testSuites( $.map(
diff --git a/tests/unit/subsuiteRunner.css b/tests/unit/subsuiteRunner.css
deleted file mode 100644
index bca30a75e..000000000
--- a/tests/unit/subsuiteRunner.css
+++ /dev/null
@@ -1,8 +0,0 @@
-iframe.qunit-subsuite {
- margin: 0;
- padding: 0;
- border-width: 1px 0 0;
- height: 600px;
- width: 100%;
- background: #fff;
-} \ No newline at end of file
diff --git a/tests/unit/subsuiteRunner.js b/tests/unit/subsuiteRunner.js
deleted file mode 100644
index ddfccc7c1..000000000
--- a/tests/unit/subsuiteRunner.js
+++ /dev/null
@@ -1,82 +0,0 @@
-(function( QUnit ) {
-
-var subsuiteFrame;
-
-QUnit.extend( QUnit, {
- testSuites: function( suites ) {
- for ( var i = 0; i < suites.length; i++ ) {
- (function( suite ) {
- asyncTest( suite, function() {
- QUnit.runSuite( suite );
- });
- }( suites[i] ) );
- }
- QUnit.done = function() {
- subsuiteFrame.style.display = "none";
- };
- },
-
- testStart: function( data ) {
- // update the test status to show which test suite is running
- QUnit.id( "qunit-testresult" ).innerHTML = "Running " + data.name + "...<br>&nbsp;";
- },
-
- testDone: function() {
- var current = QUnit.id( this.config.current.id ),
- children = current.children;
-
- // undo the auto-expansion of failed tests
- for ( var i = 0; i < children.length; i++ ) {
- if ( children[i].nodeName === "OL" ) {
- children[i].style.display = "none";
- }
- }
- },
-
- runSuite: function( suite ) {
- var body = document.getElementsByTagName( "body" )[0],
- iframe = subsuiteFrame = document.createElement( "iframe" ),
- iframeWin;
-
- iframe.className = "qunit-subsuite";
- body.appendChild( iframe );
-
- function onIframeLoad() {
- var module, test,
- count = 0;
-
- QUnit.extend( iframeWin.QUnit, {
- moduleStart: function( data ) {
- // capture module name for messages
- module = data.name;
- },
-
- testStart: function( data ) {
- // capture test name for messages
- test = data.name;
- },
-
- log: function( data ) {
- // pass all test details through to the main page
- var message = module + ": " + test + ": " + data.message;
- expect( ++count );
- QUnit.push( data.result, data.actual, data.expected, message );
- },
-
- done: function() {
- // start the wrapper test from the main page
- start();
- }
- });
- }
- QUnit.addEvent( iframe, "load", onIframeLoad );
-
- iframeWin = iframe.contentWindow;
- iframe.setAttribute( "src", suite );
-
- this.runSuite = function( suite ) {
- iframe.setAttribute( "src", suite );
- };
- }
-});
-}( QUnit ) );
diff --git a/tests/unit/swarminject.js b/tests/unit/swarminject.js
index db69326ab..78d37ef46 100644
--- a/tests/unit/swarminject.js
+++ b/tests/unit/swarminject.js
@@ -5,5 +5,5 @@
if ( !url || url.indexOf("http") !== 0 ) {
return;
}
- document.write("<scr" + "ipt src='http://swarm.jquery.org/js/inject.js?" + (new Date).getTime() + "'></scr" + "ipt>");
+ document.write( "<scr" + "ipt src='http://swarm.jquery.org/js/inject.js?" + (new Date()).getTime() + "'></scr" + "ipt>" );
})();
diff --git a/tests/unit/tabs/all.html b/tests/unit/tabs/all.html
index 1da3ecad2..41bf965f2 100644
--- a/tests/unit/tabs/all.html
+++ b/tests/unit/tabs/all.html
@@ -7,9 +7,9 @@
<script src="../../../jquery-1.7.2.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
- <link rel="stylesheet" href="../subsuiteRunner.css">
+ <link rel="stylesheet" href="../qunit-composite.css">
<script src="../../../external/qunit.js"></script>
- <script src="../subsuiteRunner.js"></script>
+ <script src="../qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>
diff --git a/tests/unit/tabs/tabs.html b/tests/unit/tabs/tabs.html
index fc494e013..b961c60f3 100644
--- a/tests/unit/tabs/tabs.html
+++ b/tests/unit/tabs/tabs.html
@@ -8,9 +8,12 @@
<script>
$.uiBackCompat = false;
</script>
- <script src="../../resource_loader.js"></script>
+ <link rel="stylesheet" href="../../../external/qunit.css">
+ <script src="../../../external/qunit.js"></script>
+ <script src="../../jquery.simulate.js"></script>
+ <script src="../testsuite.js"></script>
<script>
- loadResources({
+ TestHelpers.loadResources({
css: [ "ui.core", "ui.tabs" ],
js: [
"ui/jquery.ui.core.js",
@@ -20,73 +23,13 @@
});
</script>
- <link rel="stylesheet" href="../../../external/qunit.css">
- <script src="../../../external/qunit.js"></script>
- <script src="../../jquery.simulate.js"></script>
- <script src="../testsuite.js"></script>
-
- <script src="tabs_defaults.js"></script>
+ <script src="tabs_test_helpers.js"></script>
+ <script src="tabs_common.js"></script>
<script src="tabs_core.js"></script>
<script src="tabs_events.js"></script>
<script src="tabs_methods.js"></script>
<script src="tabs_options.js"></script>
- <script>
- function tabs_state( tabs ) {
- var expected = $.makeArray( arguments ).slice( 1 );
- var actual = tabs.find( ".ui-tabs-nav li" ).map(function() {
- var tab = $( this ),
- panel = $( $.ui.tabs.prototype._sanitizeSelector(
- "#" + tab.find( "a" ).attr( "aria-controls" ) ) ),
- tabIsActive = tab.hasClass( "ui-state-active" ),
- panelIsActive = panel.css( "display" ) !== "none";
-
- if ( tabIsActive && panelIsActive ) {
- return 1;
- }
- if ( !tabIsActive && !panelIsActive ) {
- return 0;
- }
- return -1; // mixed state - invalid
- }).get();
- deepEqual( actual, expected );
- }
-
- function tabs_disabled( tabs, state ) {
- var expected = $.map( new Array( tabs.find ( ".ui-tabs-nav li" ).length ), function( _, index ) {
- if ( typeof state === "boolean" ) {
- return state ? 1 : 0;
- } else {
- return $.inArray( index, state ) !== -1 ? 1 : 0;
- }
- });
-
- var internalState = tabs.tabs( "option", "disabled" );
- if ( internalState === false ) {
- internalState = [];
- }
- if ( internalState === true ) {
- internalState = $.map( new Array( tabs.find( ".ui-tabs-nav li" ).length ), function( _, index ) {
- return index;
- });
- }
-
- var actual = tabs.find( ".ui-tabs-nav li" ).map(function( index ) {
- var tab = $( this ),
- tabIsDisabled = tab.hasClass( "ui-state-disabled" );
-
- if ( tabIsDisabled && $.inArray( index, internalState ) !== -1 ) {
- return 1;
- }
- if ( !tabIsDisabled && $.inArray( index, internalState ) === -1 ) {
- return 0;
- }
- return -1; // mixed state - invalid
- }).get();
- deepEqual( tabs.tabs( "option", "disabled" ), state );
- deepEqual( actual, expected );
- }
- </script>
<script src="../swarminject.js"></script>
</head>
<body>
@@ -119,6 +62,7 @@
</ul>
<div id="colon:test"></div>
<div style="height: 300px;" id="inline-style"></div>
+ <div id="custom-id"></div>
</div>
<div id="tabs3">
diff --git a/tests/unit/tabs/tabs_defaults.js b/tests/unit/tabs/tabs_common.js
index 52b6f8a71..7ffb05da4 100644
--- a/tests/unit/tabs/tabs_defaults.js
+++ b/tests/unit/tabs/tabs_common.js
@@ -1,4 +1,4 @@
-commonWidgetTests( "tabs", {
+TestHelpers.commonWidgetTests( "tabs", {
defaults: {
active: null,
collapsible: false,
diff --git a/tests/unit/tabs/tabs_defaults_deprecated.js b/tests/unit/tabs/tabs_common_deprecated.js
index 1a56297e9..fdcff21b3 100644
--- a/tests/unit/tabs/tabs_defaults_deprecated.js
+++ b/tests/unit/tabs/tabs_common_deprecated.js
@@ -1,4 +1,4 @@
-commonWidgetTests( "tabs", {
+TestHelpers.commonWidgetTests( "tabs", {
defaults: {
active: null,
ajaxOptions: null,
diff --git a/tests/unit/tabs/tabs_core.js b/tests/unit/tabs/tabs_core.js
index 21250fb33..b9bd81987 100644
--- a/tests/unit/tabs/tabs_core.js
+++ b/tests/unit/tabs/tabs_core.js
@@ -1,5 +1,7 @@
(function( $ ) {
+var state = TestHelpers.tabs.state;
+
module( "tabs: core" );
test( "markup structure", function() {
@@ -89,7 +91,7 @@ test( "#4033 - IE expands hash to full url and misinterprets tab as ajax", funct
});
equal( element.find( ".ui-tabs-nav a" ).attr( "aria-controls" ), "tab", "aria-contorls attribute is correct" );
- tabs_state( element, 1 );
+ state( element, 1 );
});
}( jQuery ) );
diff --git a/tests/unit/tabs/tabs_deprecated.html b/tests/unit/tabs/tabs_deprecated.html
index 410aebc40..09afc91b4 100644
--- a/tests/unit/tabs/tabs_deprecated.html
+++ b/tests/unit/tabs/tabs_deprecated.html
@@ -6,9 +6,12 @@
<script src="../../jquery.js"></script>
<script src="../../../external/jquery.cookie.js"></script>
- <script src="../../resource_loader.js"></script>
+ <link rel="stylesheet" href="../../../external/qunit.css">
+ <script src="../../../external/qunit.js"></script>
+ <script src="../../jquery.simulate.js"></script>
+ <script src="../testsuite.js"></script>
<script>
- loadResources({
+ TestHelpers.loadResources({
css: [ "ui.core", "ui.tabs" ],
js: [
"ui/jquery.ui.core.js",
@@ -18,74 +21,14 @@
});
</script>
- <link rel="stylesheet" href="../../../external/qunit.css">
- <script src="../../../external/qunit.js"></script>
- <script src="../../jquery.simulate.js"></script>
- <script src="../testsuite.js"></script>
-
- <script src="tabs_defaults_deprecated.js"></script>
+ <script src="tabs_test_helpers.js"></script>
+ <script src="tabs_common_deprecated.js"></script>
<script src="tabs_core.js"></script>
<script src="tabs_events.js"></script>
<script src="tabs_methods.js"></script>
<script src="tabs_options.js"></script>
<script src="tabs_deprecated.js"></script>
- <script>
- function tabs_state( tabs ) {
- var expected = $.makeArray( arguments ).slice( 1 );
- var actual = tabs.find( ".ui-tabs-nav li" ).map(function() {
- var tab = $( this ),
- panel = $( $.ui.tabs.prototype._sanitizeSelector(
- "#" + tab.find( "a" ).attr( "aria-controls" ) ) ),
- tabIsActive = tab.hasClass( "ui-state-active" ),
- panelIsActive = panel.css( "display" ) !== "none";
-
- if ( tabIsActive && panelIsActive ) {
- return 1;
- }
- if ( !tabIsActive && !panelIsActive ) {
- return 0;
- }
- return -1; // mixed state - invalid
- }).get();
- deepEqual( actual, expected );
- }
-
- function tabs_disabled( tabs, state ) {
- var expected = $.map( new Array( tabs.find ( ".ui-tabs-nav li" ).length ), function( _, index ) {
- if ( typeof state === "boolean" ) {
- return state ? 1 : 0;
- } else {
- return $.inArray( index, state ) !== -1 ? 1 : 0;
- }
- });
-
- var internalState = tabs.tabs( "option", "disabled" );
- if ( internalState === false ) {
- internalState = [];
- }
- if ( internalState === true ) {
- internalState = $.map( new Array( tabs.find( ".ui-tabs-nav li" ).length ), function( _, index ) {
- return index;
- });
- }
-
- var actual = tabs.find( ".ui-tabs-nav li" ).map(function( index ) {
- var tab = $( this ),
- tabIsDisabled = tab.hasClass( "ui-state-disabled" );
-
- if ( tabIsDisabled && $.inArray( index, internalState ) !== -1 ) {
- return 1;
- }
- if ( !tabIsDisabled && $.inArray( index, internalState ) === -1 ) {
- return 0;
- }
- return -1; // mixed state - invalid
- }).get();
- deepEqual( tabs.tabs( "option", "disabled" ), state );
- deepEqual( actual, expected );
- }
- </script>
<script src="../swarminject.js"></script>
</head>
<body>
@@ -118,6 +61,7 @@
</ul>
<div id="colon:test"></div>
<div style="height: 300px;" id="inline-style"></div>
+ <div id="custom-id"></div>
</div>
<div id="tabs3">
diff --git a/tests/unit/tabs/tabs_deprecated.js b/tests/unit/tabs/tabs_deprecated.js
index 80bc4a326..66768b866 100644
--- a/tests/unit/tabs/tabs_deprecated.js
+++ b/tests/unit/tabs/tabs_deprecated.js
@@ -1,5 +1,7 @@
(function( $ ) {
+var state = TestHelpers.tabs.state;
+
module( "tabs (deprecated): core" );
test( "panel ids", function() {
@@ -48,17 +50,17 @@ asyncTest( "cache", function() {
cache: true
});
element.one( "tabsshow", function( event, ui ) {
- tabs_state( element, 0, 0, 1, 0, 0 );
+ state( element, 0, 0, 1, 0, 0 );
});
element.one( "tabsload", function( event, ui ) {
ok( true, "tabsload" );
setTimeout(function() {
element.tabs( "option", "active", 0 );
- tabs_state( element, 1, 0, 0, 0, 0 );
+ state( element, 1, 0, 0, 0, 0 );
element.one( "tabsshow", function( event, ui ) {
- tabs_state( element, 0, 0, 1, 0, 0 );
+ state( element, 0, 0, 1, 0, 0 );
});
element.one( "tabsload", function( event, ui ) {
ok( false, "should be cached" );
@@ -68,7 +70,7 @@ asyncTest( "cache", function() {
}, 1 );
});
element.tabs( "option", "active", 2 );
- tabs_state( element, 0, 0, 1, 0, 0 );
+ state( element, 0, 0, 1, 0, 0 );
});
test( "idPrefix", function() {
@@ -89,10 +91,11 @@ test( "tabTemplate + panelTemplate", function() {
// defaults are tested in the add method test
expect( 11 );
- var element = $( "#tabs2" ).tabs({
- tabTemplate: "<li class='customTab'><a href='http://example.com/#{href}'>#{label}</a></li>",
- panelTemplate: "<div class='customPanel'></div>"
- });
+ var tab, anchor,
+ element = $( "#tabs2" ).tabs({
+ tabTemplate: "<li class='customTab'><a href='http://example.com/#{href}'>#{label}</a></li>",
+ panelTemplate: "<div class='customPanel'></div>"
+ });
element.one( "tabsadd", function( event, ui ) {
var anchor = $( ui.tab );
equal( ui.index, 5, "ui.index" );
@@ -103,8 +106,8 @@ test( "tabTemplate + panelTemplate", function() {
ok( $( ui.panel ).hasClass( "customPanel" ), "panel custom class" );
});
element.tabs( "add", "#new", "New" );
- var tab = element.find( ".ui-tabs-nav li" ).last(),
- anchor = tab.find( "a" );
+ tab = element.find( ".ui-tabs-nav li" ).last();
+ anchor = tab.find( "a" );
equal( tab.text(), "New", "label" );
ok( tab.hasClass( "customTab" ), "tab custom class" );
equal( anchor.attr( "href" ), "http://example.com/#new", "href" );
@@ -170,50 +173,50 @@ test( "selected", function() {
var element = $( "#tabs1" ).tabs();
equal( element.tabs( "option", "selected" ), 0, "should be 0 by default" );
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.tabs( "destroy" );
location.hash = "#fragment-3";
element = $( "#tabs1" ).tabs();
equal( element.tabs( "option", "selected" ), 2, "should be 2 based on URL" );
- tabs_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.tabs( "destroy" );
el = $('#tabs1').tabs({
selected: -1,
collapsible: true
});
- tabs_state( element, 0, 0, 0 );
- equal( element.find( ".ui-tabs-nav .ui-state-active" ).size(), 0, "no tabs selected" );
+ state( element, 0, 0, 0 );
+ equal( element.find( ".ui-tabs-nav .ui-state-active" ).length, 0, "no tabs selected" );
strictEqual( element.tabs( "option", "selected" ), -1 );
element.tabs( "option", "collapsible", false );
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
equal( element.tabs( "option", "selected" ), 0 );
element.tabs( "destroy" );
element.tabs({
selected: -1
});
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
strictEqual( element.tabs( "option", "selected" ), 0 );
element.tabs( "destroy" );
element.tabs({ selected: 2 });
equal( element.tabs( "option", "selected" ), 2 );
- tabs_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.tabs( "option", "selected", 0 );
equal( element.tabs( "option", "selected" ), 0 );
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.find( ".ui-tabs-nav a" ).eq( 1 ).click();
equal( element.tabs( "option", "selected" ), 1 );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.tabs( "option", "selected", 10 );
equal( element.tabs( "option", "selected" ), 1 );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
location.hash = "#";
});
@@ -236,7 +239,7 @@ asyncTest( "load", function() {
strictEqual( ui.tab, tab[ 0 ], "tab" );
strictEqual( ui.panel, panel[ 0 ], "panel" );
equal( $( ui.panel ).find( "p" ).length, 1, "panel html" );
- tabs_state( element, 0, 0, 1, 0, 0 );
+ state( element, 0, 0, 1, 0, 0 );
tabsload1();
});
element.tabs({ active: 2 });
@@ -252,7 +255,7 @@ asyncTest( "load", function() {
strictEqual( ui.tab, tab[ 0 ], "tab" );
strictEqual( ui.panel, panel[ 0 ], "panel" );
equal( $( ui.panel ).find( "p" ).length, 1, "panel html" );
- tabs_state( element, 0, 0, 0, 1, 0 );
+ state( element, 0, 0, 0, 1, 0 );
tabsload2();
});
element.tabs( "option", "active", 3 );
@@ -269,7 +272,7 @@ asyncTest( "load", function() {
strictEqual( ui.tab, tab[ 0 ], "tab" );
strictEqual( ui.panel, panel[ 0 ], "panel" );
equal( $( ui.panel ).find( "p" ).length, 1, "panel html" );
- tabs_state( element, 0, 0, 0, 0, 1 );
+ state( element, 0, 0, 0, 0, 1 );
start();
});
element.find( ".ui-tabs-nav a" ).eq( 4 ).click();
@@ -324,10 +327,10 @@ test( "show", function() {
strictEqual( ui.tab, tabs[ 0 ], "ui.tab" );
strictEqual( ui.panel, panels[ 0 ], "ui.panel" );
equal( ui.index, 0, "ui.index" );
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
});
element.tabs( "option", "active", 0 );
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
// switching tabs
element.one( "tabsshow", function( event, ui ) {
@@ -335,17 +338,17 @@ test( "show", function() {
strictEqual( ui.tab, tabs[ 1 ], "ui.tab" );
strictEqual( ui.panel, panels[ 1 ], "ui.panel" );
equal( ui.index, 1, "ui.index" );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
});
tabs.eq( 1 ).click();
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
// collapsing
element.one( "tabsshow", function( event, ui ) {
ok( false, "collapsing" );
});
element.tabs( "option", "active", false );
- tabs_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
});
test( "select", function() {
@@ -364,10 +367,10 @@ test( "select", function() {
strictEqual( ui.tab, tabs[ 0 ], "ui.tab" );
strictEqual( ui.panel, panels[ 0 ], "ui.panel" );
equal( ui.index, 0, "ui.index" );
- tabs_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
});
element.tabs( "option", "active", 0 );
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
// switching tabs
element.one( "tabsselect", function( event, ui ) {
@@ -375,26 +378,32 @@ test( "select", function() {
strictEqual( ui.tab, tabs[ 1 ], "ui.tab" );
strictEqual( ui.panel, panels[ 1 ], "ui.panel" );
equal( ui.index, 1, "ui.index" );
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
});
tabs.eq( 1 ).click();
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
// collapsing
element.one( "tabsselect", function( event, ui ) {
ok( false, "collapsing" );
});
element.tabs( "option", "active", false );
- tabs_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
});
module( "tabs (deprecated): methods" );
test( "add", function() {
- expect( 27 );
+ expect( 28 );
- var element = $( "#tabs1" ).tabs();
- tabs_state( element, 1, 0, 0 );
+ var tab, anchor,
+ element = $( "#tabs1" ).tabs();
+
+ function stripLeadingSlash( str ) {
+ return str.substr( str.charAt( 0 ) === "/" ? 1 : 0 );
+ }
+
+ state( element, 1, 0, 0 );
// add without index
element.one( "tabsadd", function( event, ui ) {
@@ -403,17 +412,18 @@ test( "add", function() {
equal( ui.panel.id, "new", "ui.panel" );
});
element.tabs( "add", "#new", "New" );
- tabs_state( element, 1, 0, 0, 0 );
- var tab = element.find( ".ui-tabs-nav li" ).last(),
- anchor = tab.find( "a" );
+ state( element, 1, 0, 0, 0 );
+ tab = element.find( ".ui-tabs-nav li" ).last();
+ anchor = tab.find( "a" );
equal( tab.text(), "New", "label" );
- equal( anchor.attr( "href" ), "#new", "href" );
+ equal( stripLeadingSlash( anchor[0].pathname ), stripLeadingSlash( location.pathname ), "href pathname" );
+ equal( anchor[0].hash, "#new", "href hash" );
equal( anchor.attr( "aria-controls" ), "new", "aria-controls" );
ok( !tab.hasClass( "ui-state-hover" ), "not hovered" );
anchor.simulate( "mouseover" );
ok( tab.hasClass( "ui-state-hover" ), "hovered" );
anchor.simulate( "click" );
- tabs_state( element, 0, 0, 0, 1 );
+ state( element, 0, 0, 0, 1 );
// add remote tab with index
element.one( "tabsadd", function( event, ui ) {
@@ -422,17 +432,19 @@ test( "add", function() {
equal( ui.panel.id, $( ui.tab ).attr( "aria-controls" ), "ui.panel" );
});
element.tabs( "add", "data/test.html", "New Remote", 1 );
- tabs_state( element, 0, 0, 0, 0, 1 );
+ state( element, 0, 0, 0, 0, 1 );
tab = element.find( ".ui-tabs-nav li" ).eq( 1 );
anchor = tab.find( "a" );
equal( tab.text(), "New Remote", "label" );
- equal( anchor.attr( "href" ), "data/test.html", "href" );
+ equal( stripLeadingSlash( stripLeadingSlash(
+ anchor[0].pathname.replace( stripLeadingSlash( location.pathname ).split( "/" ).slice( 0, -1 ).join( "/" ), "" )
+ ) ), "data/test.html", "href" );
ok( /^ui-tabs-\d+$/.test( anchor.attr( "aria-controls" ) ), "aria controls" );
ok( !tab.hasClass( "ui-state-hover" ), "not hovered" );
anchor.simulate( "mouseover" );
ok( tab.hasClass( "ui-state-hover" ), "hovered" );
anchor.simulate( "click" );
- tabs_state( element, 0, 1, 0, 0, 0 );
+ state( element, 0, 1, 0, 0, 0 );
// add to empty tab set
element = $( "<div><ul></ul></div>" ).tabs();
@@ -443,7 +455,7 @@ test( "add", function() {
equal( ui.panel.id, "first", "ui.panel" );
});
element.tabs( "add", "#first", "First" );
- tabs_state( element, 1 );
+ state( element, 1 );
equal( element.tabs( "option", "active" ), 0, "active: 0 after add" );
});
@@ -460,7 +472,7 @@ test( "remove", function() {
expect( 17 );
var element = $( "#tabs1" ).tabs({ active: 1 });
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.one( "tabsremove", function( event, ui ) {
equal( ui.index, -1, "ui.index" );
@@ -468,7 +480,7 @@ test( "remove", function() {
equal( ui.panel.id, "fragment-2", "ui.panel" );
});
element.tabs( "remove", 1 );
- tabs_state( element, 0, 1 );
+ state( element, 0, 1 );
equal( element.tabs( "option", "active" ), 1 );
equal( element.find( ".ui-tabs-nav li a[href$='fragment-2']" ).length, 0,
"remove correct list item" );
@@ -480,7 +492,7 @@ test( "remove", function() {
equal( ui.panel.id, "fragment-3", "ui.panel" );
});
element.tabs( "remove", 1 );
- tabs_state( element, 1 );
+ state( element, 1 );
equal( element.tabs( "option", "active"), 0 );
element.one( "tabsremove", function( event, ui ) {
@@ -496,43 +508,43 @@ test( "select", function() {
expect( 23 );
var element = $( "#tabs1" ).tabs();
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.tabs( "select", 1 );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
equal( element.tabs( "option", "active" ), 1, "active" );
equal( element.tabs( "option", "selected" ), 1, "selected" );
element.tabs( "destroy" );
element.tabs({ collapsible: true });
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.tabs( "select", 0 );
- tabs_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
equal( element.tabs( "option", "active" ), false, "active" );
equal( element.tabs( "option", "selected" ), -1, "selected" );
element.tabs( "destroy" );
element.tabs({ collapsible: true });
element.tabs( "select", -1 );
- tabs_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
equal( element.tabs( "option", "active" ), false, "active" );
equal( element.tabs( "option", "selected" ), -1, "selected" );
element.tabs( "destroy" );
element.tabs();
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
equal( element.tabs( "option", "active" ), 0, "active" );
equal( element.tabs( "option", "selected" ), 0, "selected" );
element.tabs( "select", 0 );
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
equal( element.tabs( "option", "active" ), 0, "active" );
equal( element.tabs( "option", "selected" ), 0, "selected" );
element.tabs( "select", -1 );
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
equal( element.tabs( "option", "active" ), 0, "active" );
equal( element.tabs( "option", "selected" ), 0, "selected" );
element.tabs( "select", "#fragment-2" );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
equal( element.tabs( "option", "active" ), 1, "active" );
equal( element.tabs( "option", "selected" ), 1, "selected" );
});
@@ -569,6 +581,10 @@ asyncTest( "abort", function() {
start();
});
});
+ // prevent IE from caching the request, so that it won't resolve before we call abort
+ element.find( ".ui-tabs-nav li:eq(2) a" ).attr( "href", function( href ) {
+ return href + "?" + (+ new Date());
+ });
element.tabs( "option", "active", 2 );
element.tabs( "abort" );
});
diff --git a/tests/unit/tabs/tabs_events.js b/tests/unit/tabs/tabs_events.js
index 4f9269b62..f33686581 100644
--- a/tests/unit/tabs/tabs_events.js
+++ b/tests/unit/tabs/tabs_events.js
@@ -1,5 +1,7 @@
(function( $ ) {
+var state = TestHelpers.tabs.state;
+
module( "tabs: events" );
test( "create", function() {
@@ -11,9 +13,9 @@ test( "create", function() {
element.tabs({
create: function( event, ui ) {
- equal( ui.tab.size(), 1, "tab size" );
+ equal( ui.tab.length, 1, "tab length" );
strictEqual( ui.tab[ 0 ], tabs[ 0 ], "tab" );
- equal( ui.panel.size(), 1, "panel size" );
+ equal( ui.panel.length, 1, "panel length" );
strictEqual( ui.panel[ 0 ], panels[ 0 ], "panel" );
}
});
@@ -22,9 +24,9 @@ test( "create", function() {
element.tabs({
active: 2,
create: function( event, ui ) {
- equal( ui.tab.size(), 1, "tab size" );
+ equal( ui.tab.length, 1, "tab length" );
strictEqual( ui.tab[ 0 ], tabs[ 2 ], "tab" );
- equal( ui.panel.size(), 1, "panel size" );
+ equal( ui.panel.length, 1, "panel length" );
strictEqual( ui.panel[ 0 ], panels[ 2 ], "panel" );
}
});
@@ -34,8 +36,8 @@ test( "create", function() {
active: false,
collapsible: true,
create: function( event, ui ) {
- equal( ui.tab.size(), 0, "tab size" );
- equal( ui.panel.size(), 0, "panel size" );
+ equal( ui.tab.length, 0, "tab length" );
+ equal( ui.panel.length, 0, "panel length" );
}
});
element.tabs( "destroy" );
@@ -54,61 +56,61 @@ test( "beforeActivate", function() {
// from collapsed
element.one( "tabsbeforeactivate", function( event, ui ) {
ok( !( "originalEvent" in event ), "originalEvent" );
- equal( ui.oldTab.size(), 0, "oldTab size" );
- equal( ui.oldPanel.size(), 0, "oldPanel size" );
- equal( ui.newTab.size(), 1, "newTab size" );
+ equal( ui.oldTab.length, 0, "oldTab length" );
+ equal( ui.oldPanel.length, 0, "oldPanel length" );
+ equal( ui.newTab.length, 1, "newTab length" );
strictEqual( ui.newTab[ 0 ], tabs[ 0 ], "newTab" );
- equal( ui.newPanel.size(), 1, "newPanel size" );
+ equal( ui.newPanel.length, 1, "newPanel length" );
strictEqual( ui.newPanel[ 0 ], panels[ 0 ], "newPanel" );
- tabs_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
});
element.tabs( "option", "active", 0 );
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
// switching tabs
element.one( "tabsbeforeactivate", function( event, ui ) {
equal( event.originalEvent.type, "click", "originalEvent" );
- equal( ui.oldTab.size(), 1, "oldTab size" );
+ equal( ui.oldTab.length, 1, "oldTab length" );
strictEqual( ui.oldTab[ 0 ], tabs[ 0 ], "oldTab" );
- equal( ui.oldPanel.size(), 1, "oldPanel size" );
+ equal( ui.oldPanel.length, 1, "oldPanel length" );
strictEqual( ui.oldPanel[ 0 ], panels[ 0 ], "oldPanel" );
- equal( ui.newTab.size(), 1, "newTab size" );
+ equal( ui.newTab.length, 1, "newTab length" );
strictEqual( ui.newTab[ 0 ], tabs[ 1 ], "newTab" );
- equal( ui.newPanel.size(), 1, "newPanel size" );
+ equal( ui.newPanel.length, 1, "newPanel length" );
strictEqual( ui.newPanel[ 0 ], panels[ 1 ], "newPanel" );
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
});
tabs.eq( 1 ).click();
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
// collapsing
element.one( "tabsbeforeactivate", function( event, ui ) {
ok( !( "originalEvent" in event ), "originalEvent" );
- equal( ui.oldTab.size(), 1, "oldTab size" );
+ equal( ui.oldTab.length, 1, "oldTab length" );
strictEqual( ui.oldTab[ 0 ], tabs[ 1 ], "oldTab" );
- equal( ui.oldPanel.size(), 1, "oldPanel size" );
+ equal( ui.oldPanel.length, 1, "oldPanel length" );
strictEqual( ui.oldPanel[ 0 ], panels[ 1 ], "oldPanel" );
- equal( ui.newTab.size(), 0, "newTab size" );
- equal( ui.newPanel.size(), 0, "newPanel size" );
- tabs_state( element, 0, 1, 0 );
+ equal( ui.newTab.length, 0, "newTab length" );
+ equal( ui.newPanel.length, 0, "newPanel length" );
+ state( element, 0, 1, 0 );
});
element.tabs( "option", "active", false );
- tabs_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
// prevent activation
element.one( "tabsbeforeactivate", function( event, ui ) {
ok( !( "originalEvent" in event ), "originalEvent" );
- equal( ui.oldTab.size(), 0, "oldTab size" );
- equal( ui.oldPanel.size(), 0, "oldTab" );
- equal( ui.newTab.size(), 1, "newTab size" );
+ equal( ui.oldTab.length, 0, "oldTab length" );
+ equal( ui.oldPanel.length, 0, "oldTab" );
+ equal( ui.newTab.length, 1, "newTab length" );
strictEqual( ui.newTab[ 0 ], tabs[ 1 ], "newTab" );
- equal( ui.newPanel.size(), 1, "newPanel size" );
+ equal( ui.newPanel.length, 1, "newPanel length" );
strictEqual( ui.newPanel[ 0 ], panels[ 1 ], "newPanel" );
event.preventDefault();
- tabs_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
});
element.tabs( "option", "active", 1 );
- tabs_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
});
test( "activate", function() {
@@ -124,46 +126,46 @@ test( "activate", function() {
// from collapsed
element.one( "tabsactivate", function( event, ui ) {
ok( !( "originalEvent" in event ), "originalEvent" );
- equal( ui.oldTab.size(), 0, "oldTab size" );
- equal( ui.oldPanel.size(), 0, "oldPanel size" );
- equal( ui.newTab.size(), 1, "newTab size" );
+ equal( ui.oldTab.length, 0, "oldTab length" );
+ equal( ui.oldPanel.length, 0, "oldPanel length" );
+ equal( ui.newTab.length, 1, "newTab length" );
strictEqual( ui.newTab[ 0 ], tabs[ 0 ], "newTab" );
- equal( ui.newPanel.size(), 1, "newPanel size" );
+ equal( ui.newPanel.length, 1, "newPanel length" );
strictEqual( ui.newPanel[ 0 ], panels[ 0 ], "newPanel" );
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
});
element.tabs( "option", "active", 0 );
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
// switching tabs
element.one( "tabsactivate", function( event, ui ) {
equal( event.originalEvent.type, "click", "originalEvent" );
- equal( ui.oldTab.size(), 1, "oldTab size" );
+ equal( ui.oldTab.length, 1, "oldTab length" );
strictEqual( ui.oldTab[ 0 ], tabs[ 0 ], "oldTab" );
- equal( ui.oldPanel.size(), 1, "oldPanel size" );
+ equal( ui.oldPanel.length, 1, "oldPanel length" );
strictEqual( ui.oldPanel[ 0 ], panels[ 0 ], "oldPanel" );
- equal( ui.newTab.size(), 1, "newTab size" );
+ equal( ui.newTab.length, 1, "newTab length" );
strictEqual( ui.newTab[ 0 ], tabs[ 1 ], "newTab" );
- equal( ui.newPanel.size(), 1, "newPanel size" );
+ equal( ui.newPanel.length, 1, "newPanel length" );
strictEqual( ui.newPanel[ 0 ], panels[ 1 ], "newPanel" );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
});
tabs.eq( 1 ).click();
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
// collapsing
element.one( "tabsactivate", function( event, ui ) {
ok( !( "originalEvent" in event ), "originalEvent" );
- equal( ui.oldTab.size(), 1, "oldTab size" );
+ equal( ui.oldTab.length, 1, "oldTab length" );
strictEqual( ui.oldTab[ 0 ], tabs[ 1 ], "oldTab" );
- equal( ui.oldPanel.size(), 1, "oldPanel size" );
+ equal( ui.oldPanel.length, 1, "oldPanel length" );
strictEqual( ui.oldPanel[ 0 ], panels[ 1 ], "oldPanel" );
- equal( ui.newTab.size(), 0, "newTab size" );
- equal( ui.newPanel.size(), 0, "newPanel size" );
- tabs_state( element, 0, 0, 0 );
+ equal( ui.newTab.length, 0, "newTab length" );
+ equal( ui.newPanel.length, 0, "newPanel length" );
+ state( element, 0, 0, 0 );
});
element.tabs( "option", "active", false );
- tabs_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
// prevent activation
element.one( "tabsbeforeactivate", function( event ) {
@@ -191,16 +193,16 @@ test( "beforeLoad", function() {
ok( !( "originalEvent" in event ), "originalEvent" );
ok( "abort" in ui.jqXHR, "jqXHR" );
ok( ui.ajaxSettings.url, "data/test.html", "ajaxSettings.url" );
- equal( ui.tab.size(), 1, "tab size" );
+ equal( ui.tab.length, 1, "tab length" );
strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
- equal( ui.panel.size(), 1, "panel size" );
+ equal( ui.panel.length, 1, "panel length" );
strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
equal( ui.panel.html(), "", "panel html" );
event.preventDefault();
- tabs_state( element, 0, 0, 1, 0, 0 );
+ state( element, 0, 0, 1, 0, 0 );
});
element.tabs({ active: 2 });
- tabs_state( element, 0, 0, 1, 0, 0 );
+ state( element, 0, 0, 1, 0, 0 );
equal( panel.html(), "", "panel html after" );
element.tabs( "destroy" );
@@ -213,17 +215,17 @@ test( "beforeLoad", function() {
ok( !( "originalEvent" in event ), "originalEvent" );
ok( "abort" in ui.jqXHR, "jqXHR" );
ok( ui.ajaxSettings.url, "data/test.html", "ajaxSettings.url" );
- equal( ui.tab.size(), 1, "tab size" );
+ equal( ui.tab.length, 1, "tab length" );
strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
- equal( ui.panel.size(), 1, "panel size" );
+ equal( ui.panel.length, 1, "panel length" );
strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
equal( ui.panel.html(), "", "panel html" );
event.preventDefault();
- tabs_state( element, 1, 0, 0, 0, 0 );
+ state( element, 1, 0, 0, 0, 0 );
});
element.tabs();
element.tabs( "option", "active", 2 );
- tabs_state( element, 0, 0, 1, 0, 0 );
+ state( element, 0, 0, 1, 0, 0 );
equal( panel.html(), "", "panel html after" );
// click, change panel content
@@ -235,16 +237,16 @@ test( "beforeLoad", function() {
equal( event.originalEvent.type, "click", "originalEvent" );
ok( "abort" in ui.jqXHR, "jqXHR" );
ok( ui.ajaxSettings.url, "data/test.html", "ajaxSettings.url" );
- equal( ui.tab.size(), 1, "tab size" );
+ equal( ui.tab.length, 1, "tab length" );
strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
- equal( ui.panel.size(), 1, "panel size" );
+ equal( ui.panel.length, 1, "panel length" );
strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
ui.panel.html( "<p>testing</p>" );
event.preventDefault();
- tabs_state( element, 0, 0, 1, 0, 0 );
+ state( element, 0, 0, 1, 0, 0 );
});
element.find( ".ui-tabs-nav a" ).eq( 3 ).click();
- tabs_state( element, 0, 0, 0, 1, 0 );
+ state( element, 0, 0, 0, 1, 0 );
// .toLowerCase() is needed to convert <P> to <p> in old IEs
equal( panel.html().toLowerCase(), "<p>testing</p>", "panel html after" );
});
@@ -263,12 +265,12 @@ if ( $.uiBackCompat === false ) {
panel = $( "#" + panelId );
ok( !( "originalEvent" in event ), "originalEvent" );
- equal( ui.tab.size(), 1, "tab size" );
+ equal( ui.tab.length, 1, "tab length" );
strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
- equal( ui.panel.size(), 1, "panel size" );
+ equal( ui.panel.length, 1, "panel length" );
strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
equal( ui.panel.find( "p" ).length, 1, "panel html" );
- tabs_state( element, 0, 0, 1, 0, 0 );
+ state( element, 0, 0, 1, 0, 0 );
tabsload1();
});
element.tabs({ active: 2 });
@@ -281,12 +283,12 @@ if ( $.uiBackCompat === false ) {
panel = $( "#" + panelId );
ok( !( "originalEvent" in event ), "originalEvent" );
- equal( ui.tab.size(), 1, "tab size" );
+ equal( ui.tab.length, 1, "tab length" );
strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
- equal( ui.panel.size(), 1, "panel size" );
+ equal( ui.panel.length, 1, "panel length" );
strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
equal( ui.panel.find( "p" ).length, 1, "panel html" );
- tabs_state( element, 0, 0, 0, 1, 0 );
+ state( element, 0, 0, 0, 1, 0 );
tabsload2();
});
element.tabs( "option", "active", 3 );
@@ -300,12 +302,12 @@ if ( $.uiBackCompat === false ) {
panel = $( "#" + panelId );
equal( event.originalEvent.type, "click", "originalEvent" );
- equal( ui.tab.size(), 1, "tab size" );
+ equal( ui.tab.length, 1, "tab length" );
strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
- equal( ui.panel.size(), 1, "panel size" );
+ equal( ui.panel.length, 1, "panel length" );
strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
equal( ui.panel.find( "p" ).length, 1, "panel html" );
- tabs_state( element, 0, 0, 0, 0, 1 );
+ state( element, 0, 0, 0, 0, 1 );
start();
});
element.find( ".ui-tabs-nav a" ).eq( 4 ).click();
diff --git a/tests/unit/tabs/tabs_methods.js b/tests/unit/tabs/tabs_methods.js
index fee87db96..0837995e6 100644
--- a/tests/unit/tabs/tabs_methods.js
+++ b/tests/unit/tabs/tabs_methods.js
@@ -1,5 +1,8 @@
(function( $ ) {
+var disabled = TestHelpers.tabs.disabled,
+ state = TestHelpers.tabs.state;
+
module( "tabs: methods" );
test( "destroy", function() {
@@ -12,95 +15,95 @@ test( "enable", function() {
expect( 8 );
var element = $( "#tabs1" ).tabs({ disabled: true });
- tabs_disabled( element, true );
+ disabled( element, true );
element.tabs( "enable" );
- tabs_disabled( element, false );
+ disabled( element, false );
element.tabs( "destroy" );
element.tabs({ disabled: [ 0, 1 ] });
- tabs_disabled( element, [ 0, 1 ] );
+ disabled( element, [ 0, 1 ] );
element.tabs( "enable" );
- tabs_disabled( element, false );
+ disabled( element, false );
});
test( "enable( index )", function() {
expect( 10 );
var element = $( "#tabs1" ).tabs({ disabled: true });
- tabs_disabled( element, true );
+ disabled( element, true );
// fully disabled -> partially disabled
element.tabs( "enable", 1 );
- tabs_disabled( element, [ 0, 2 ] );
+ disabled( element, [ 0, 2 ] );
// partially disabled -> partially disabled
element.tabs( "enable", 2 );
- tabs_disabled( element, [ 0 ] );
+ disabled( element, [ 0 ] );
// already enabled tab, no change
element.tabs( "enable", 2 );
- tabs_disabled( element, [ 0 ] );
+ disabled( element, [ 0 ] );
// partially disabled -> fully enabled
element.tabs( "enable", 0 );
- tabs_disabled( element, false );
+ disabled( element, false );
});
test( "disable", function() {
expect( 8 );
var element = $( "#tabs1" ).tabs({ disabled: false });
- tabs_disabled( element, false );
+ disabled( element, false );
element.tabs( "disable" );
- tabs_disabled( element, true );
+ disabled( element, true );
element.tabs( "destroy" );
element.tabs({ disabled: [ 0, 1 ] });
- tabs_disabled( element, [ 0, 1 ] );
+ disabled( element, [ 0, 1 ] );
element.tabs( "disable" );
- tabs_disabled( element, true );
+ disabled( element, true );
});
test( "disable( index )", function() {
expect( 10 );
var element = $( "#tabs1" ).tabs({ disabled: false });
- tabs_disabled( element, false );
+ disabled( element, false );
// fully enabled -> partially disabled
element.tabs( "disable", 1 );
- tabs_disabled( element, [ 1 ] );
+ disabled( element, [ 1 ] );
// partially disabled -> partially disabled
element.tabs( "disable", 2 );
- tabs_disabled( element, [ 1, 2 ] );
+ disabled( element, [ 1, 2 ] );
// already disabled tab, no change
element.tabs( "disable", 2 );
- tabs_disabled( element, [ 1, 2 ] );
+ disabled( element, [ 1, 2 ] );
// partially disabled -> fully disabled
element.tabs( "disable", 0 );
- tabs_disabled( element, true );
+ disabled( element, true );
});
test( "refresh", function() {
expect( 27 );
var element = $( "#tabs1" ).tabs();
- tabs_state( element, 1, 0, 0 );
- tabs_disabled( element, false );
+ state( element, 1, 0, 0 );
+ disabled( element, false );
// disable tab via markup
element.find( ".ui-tabs-nav li" ).eq( 1 ).addClass( "ui-state-disabled" );
element.tabs( "refresh" );
- tabs_state( element, 1, 0, 0 );
- tabs_disabled( element, [ 1 ] );
+ state( element, 1, 0, 0 );
+ disabled( element, [ 1 ] );
// add remote tab
element.find( ".ui-tabs-nav" ).append( "<li id='newTab'><a href='data/test.html'>new</a></li>" );
element.tabs( "refresh" );
- tabs_state( element, 1, 0, 0, 0 );
- tabs_disabled( element, [ 1 ] );
+ state( element, 1, 0, 0, 0 );
+ disabled( element, [ 1 ] );
equal( element.find( "#" + $( "#newTab a" ).attr( "aria-controls" ) ).length, 1,
"panel added for remote tab" );
// remove all tabs
element.find( ".ui-tabs-nav li, .ui-tabs-panel" ).remove();
element.tabs( "refresh" );
- tabs_state( element );
+ state( element );
equal( element.tabs( "option", "active" ), false, "no active tab" );
// add tabs
@@ -115,34 +118,34 @@ test( "refresh", function() {
.append( "<div id='newTab4'>new 4</div>" )
.append( "<div id='newTab5'>new 5</div>" );
element.tabs( "refresh" );
- tabs_state( element, 0, 0, 0, 0 );
- tabs_disabled( element, [ 0 ] );
+ state( element, 0, 0, 0, 0 );
+ disabled( element, [ 0 ] );
// activate third tab
element.tabs( "option", "active", 2 );
- tabs_state( element, 0, 0, 1, 0 );
- tabs_disabled( element, [ 0 ] );
+ state( element, 0, 0, 1, 0 );
+ disabled( element, [ 0 ] );
// remove fourth tab, third tab should stay active
element.find( ".ui-tabs-nav li" ).eq( 3 ).remove();
element.find( ".ui-tabs-panel" ).eq( 3 ).remove();
element.tabs( "refresh" );
- tabs_state( element, 0, 0, 1 );
- tabs_disabled( element, [ 0 ] );
+ state( element, 0, 0, 1 );
+ disabled( element, [ 0 ] );
// remove third (active) tab, second tab should become active
element.find( ".ui-tabs-nav li" ).eq( 2 ).remove();
element.find( ".ui-tabs-panel" ).eq( 2 ).remove();
element.tabs( "refresh" );
- tabs_state( element, 0, 1 );
- tabs_disabled( element, [ 0 ] );
+ state( element, 0, 1 );
+ disabled( element, [ 0 ] );
// remove first tab, previously active tab (now first) should stay active
element.find( ".ui-tabs-nav li" ).eq( 0 ).remove();
element.find( ".ui-tabs-panel" ).eq( 0 ).remove();
element.tabs( "refresh" );
- tabs_state( element, 1 );
- tabs_disabled( element, false );
+ state( element, 1 );
+ disabled( element, false );
});
asyncTest( "load", function() {
@@ -158,32 +161,31 @@ asyncTest( "load", function() {
panel = $( "#" + panelId );
ok( !( "originalEvent" in event ), "originalEvent" );
- equal( ui.tab.size(), 1, "tab size" );
+ equal( ui.tab.length, 1, "tab length" );
strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
- equal( ui.panel.size(), 1, "panel size" );
+ equal( ui.panel.length, 1, "panel length" );
strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
- tabs_state( element, 1, 0, 0, 0, 0 );
+ state( element, 1, 0, 0, 0, 0 );
});
element.one( "tabsload", function( event, ui ) {
// TODO: remove wrapping in 2.0
var uiTab = $( ui.tab ),
- uiPanel = $( ui.panel );
-
- var tab = element.find( ".ui-tabs-nav a" ).eq( 3 ),
+ uiPanel = $( ui.panel ),
+ tab = element.find( ".ui-tabs-nav a" ).eq( 3 ),
panelId = tab.attr( "aria-controls" ),
panel = $( "#" + panelId );
ok( !( "originalEvent" in event ), "originalEvent" );
- equal( uiTab.size(), 1, "tab size" );
+ equal( uiTab.length, 1, "tab length" );
strictEqual( uiTab[ 0 ], tab[ 0 ], "tab" );
- equal( uiPanel.size(), 1, "panel size" );
+ equal( uiPanel.length, 1, "panel length" );
strictEqual( uiPanel[ 0 ], panel[ 0 ], "panel" );
equal( uiPanel.find( "p" ).length, 1, "panel html" );
- tabs_state( element, 1, 0, 0, 0, 0 );
+ state( element, 1, 0, 0, 0, 0 );
setTimeout( tabsload1, 100 );
});
element.tabs( "load", 3 );
- tabs_state( element, 1, 0, 0, 0, 0 );
+ state( element, 1, 0, 0, 0, 0 );
function tabsload1() {
// no need to test details of event (tested in events tests)
@@ -195,7 +197,7 @@ asyncTest( "load", function() {
setTimeout( tabsload2, 100 );
});
element.tabs( "option", "active", 3 );
- tabs_state( element, 0, 0, 0, 1, 0 );
+ state( element, 0, 0, 0, 1, 0 );
}
function tabsload2() {
@@ -206,31 +208,30 @@ asyncTest( "load", function() {
panel = $( "#" + panelId );
ok( !( "originalEvent" in event ), "originalEvent" );
- equal( ui.tab.size(), 1, "tab size" );
+ equal( ui.tab.length, 1, "tab length" );
strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
- equal( ui.panel.size(), 1, "panel size" );
+ equal( ui.panel.length, 1, "panel length" );
strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
- tabs_state( element, 0, 0, 0, 1, 0 );
+ state( element, 0, 0, 0, 1, 0 );
});
element.one( "tabsload", function( event, ui ) {
// TODO: remove wrapping in 2.0
var uiTab = $( ui.tab ),
- uiPanel = $( ui.panel );
-
- var tab = element.find( ".ui-tabs-nav a" ).eq( 3 ),
+ uiPanel = $( ui.panel ),
+ tab = element.find( ".ui-tabs-nav a" ).eq( 3 ),
panelId = tab.attr( "aria-controls" ),
panel = $( "#" + panelId );
ok( !( "originalEvent" in event ), "originalEvent" );
- equal( uiTab.size(), 1, "tab size" );
+ equal( uiTab.length, 1, "tab length" );
strictEqual( uiTab[ 0 ], tab[ 0 ], "tab" );
- equal( uiPanel.size(), 1, "panel size" );
+ equal( uiPanel.length, 1, "panel length" );
strictEqual( uiPanel[ 0 ], panel[ 0 ], "panel" );
- tabs_state( element, 0, 0, 0, 1, 0 );
+ state( element, 0, 0, 0, 1, 0 );
start();
});
element.tabs( "load", 3 );
- tabs_state( element, 0, 0, 0, 1, 0 );
+ state( element, 0, 0, 0, 1, 0 );
}
});
diff --git a/tests/unit/tabs/tabs_options.js b/tests/unit/tabs/tabs_options.js
index e1ebf5efa..ae9e7bdc6 100644
--- a/tests/unit/tabs/tabs_options.js
+++ b/tests/unit/tabs/tabs_options.js
@@ -1,5 +1,8 @@
(function( $ ) {
+var disabled = TestHelpers.tabs.disabled,
+ state = TestHelpers.tabs.state;
+
module( "tabs: options" );
test( "{ active: default }", function() {
@@ -7,13 +10,13 @@ test( "{ active: default }", function() {
var element = $( "#tabs1" ).tabs();
equal( element.tabs( "option", "active" ), 0, "should be 0 by default" );
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.tabs( "destroy" );
location.hash = "#fragment-3";
element = $( "#tabs1" ).tabs();
equal( element.tabs( "option", "active" ), 2, "should be 2 based on URL" );
- tabs_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.tabs( "destroy" );
location.hash = "#";
});
@@ -25,19 +28,19 @@ test( "{ active: false }", function() {
active: false,
collapsible: true
});
- tabs_state( element, 0, 0, 0 );
- equal( element.find( ".ui-tabs-nav .ui-state-active" ).size(), 0, "no tabs selected" );
+ state( element, 0, 0, 0 );
+ equal( element.find( ".ui-tabs-nav .ui-state-active" ).length, 0, "no tabs selected" );
strictEqual( element.tabs( "option", "active" ), false );
element.tabs( "option", "collapsible", false );
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
equal( element.tabs( "option", "active" ), 0 );
element.tabs( "destroy" );
element.tabs({
active: false
});
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
strictEqual( element.tabs( "option", "active" ), 0 );
});
@@ -48,19 +51,19 @@ test( "{ active: Number }", function() {
active: 2
});
equal( element.tabs( "option", "active" ), 2 );
- tabs_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.tabs( "option", "active", 0 );
equal( element.tabs( "option", "active" ), 0 );
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.find( ".ui-tabs-nav a" ).eq( 1 ).click();
equal( element.tabs( "option", "active" ), 1 );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.tabs( "option", "active", 10 );
equal( element.tabs( "option", "active" ), 1 );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
});
if ( $.uiBackCompat === false ) {
@@ -69,19 +72,19 @@ if ( $.uiBackCompat === false ) {
active: -1
});
equal( element.tabs( "option", "active" ), 2 );
- tabs_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.tabs( "option", "active", -2 );
equal( element.tabs( "option", "active" ), 1 );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.tabs( "option", "active", -10 );
equal( element.tabs( "option", "active" ), 1 );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.tabs( "option", "active", -3 );
equal( element.tabs( "option", "active" ), 0 );
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
});
}
@@ -91,9 +94,9 @@ test( "active - mismatched tab/panel order", function() {
location.hash = "#tabs7-2";
var element = $( "#tabs7" ).tabs();
equal( element.tabs( "option", "active" ), 1, "should be 1 based on URL" );
- tabs_state( element, 0, 1 );
+ state( element, 0, 1 );
element.tabs( "option", "active", 0 );
- tabs_state( element, 1, 0 );
+ state( element, 1, 0 );
location.hash = "#";
});
@@ -105,11 +108,11 @@ test( "{ collapsible: false }", function() {
});
element.tabs( "option", "active", false );
equal( element.tabs( "option", "active" ), 1 );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.find( ".ui-state-active a" ).eq( 1 ).click();
equal( element.tabs( "option", "active" ), 1 );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
});
test( "{ collapsible: true }", function() {
@@ -122,15 +125,15 @@ test( "{ collapsible: true }", function() {
element.tabs( "option", "active", false );
equal( element.tabs( "option", "active" ), false );
- tabs_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
element.tabs( "option", "active", 1 );
equal( element.tabs( "option", "active" ), 1 );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.find( ".ui-state-active a" ).click();
equal( element.tabs( "option", "active" ), false );
- tabs_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
});
test( "disabled", function() {
@@ -138,23 +141,23 @@ test( "disabled", function() {
// fully enabled by default
var element = $( "#tabs1" ).tabs();
- tabs_disabled( element, false );
+ disabled( element, false );
// disable single tab
element.tabs( "option", "disabled", [ 1 ] );
- tabs_disabled( element, [ 1 ] );
+ disabled( element, [ 1 ] );
// disabled active tab
element.tabs( "option", "disabled", [ 0, 1 ] );
- tabs_disabled( element, [ 0, 1 ] );
+ disabled( element, [ 0, 1 ] );
// disable all tabs
element.tabs( "option", "disabled", [ 0, 1, 2 ] );
- tabs_disabled( element, true );
+ disabled( element, true );
// enable all tabs
element.tabs( "option", "disabled", [] );
- tabs_disabled( element, false );
+ disabled( element, false );
});
test( "{ event: null }", function() {
@@ -163,16 +166,16 @@ test( "{ event: null }", function() {
var element = $( "#tabs1" ).tabs({
event: null
});
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.tabs( "option", "active", 1 );
equal( element.tabs( "option", "active" ), 1 );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
// ensure default click handler isn't bound
element.find( ".ui-tabs-nav a" ).eq( 2 ).click();
equal( element.tabs( "option", "active" ), 1 );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
});
test( "{ event: custom }", function() {
@@ -181,31 +184,31 @@ test( "{ event: custom }", function() {
var element = $( "#tabs1" ).tabs({
event: "custom1 custom2"
});
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.find( ".ui-tabs-nav a" ).eq( 1 ).trigger( "custom1" );
equal( element.tabs( "option", "active" ), 1 );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
// ensure default click handler isn't bound
element.find( ".ui-tabs-nav a" ).eq( 2 ).trigger( "click" );
equal( element.tabs( "option", "active" ), 1 );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.find( ".ui-tabs-nav a" ).eq( 2 ).trigger( "custom2" );
equal( element.tabs( "option", "active" ), 2 );
- tabs_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.tabs( "option", "event", "custom3" );
// ensure old event handlers are unbound
element.find( ".ui-tabs-nav a" ).eq( 1 ).trigger( "custom1" );
equal( element.tabs( "option", "active" ), 2 );
- tabs_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.find( ".ui-tabs-nav a" ).eq( 1 ).trigger( "custom3" );
equal( element.tabs( "option", "active" ), 1 );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
});
// TODO: add animation tests
diff --git a/tests/unit/tabs/tabs_test_helpers.js b/tests/unit/tabs/tabs_test_helpers.js
new file mode 100644
index 000000000..9f592c074
--- /dev/null
+++ b/tests/unit/tabs/tabs_test_helpers.js
@@ -0,0 +1,61 @@
+TestHelpers.tabs = {
+ disabled: function( tabs, state ) {
+ var expected, actual,
+ internalState = tabs.tabs( "option", "disabled" );
+
+ if ( internalState === false ) {
+ internalState = [];
+ }
+ if ( internalState === true ) {
+ internalState = $.map( new Array( tabs.find( ".ui-tabs-nav li" ).length ), function( _, index ) {
+ return index;
+ });
+ }
+
+ expected = $.map( new Array( tabs.find ( ".ui-tabs-nav li" ).length ), function( _, index ) {
+ if ( typeof state === "boolean" ) {
+ return state ? 1 : 0;
+ } else {
+ return $.inArray( index, state ) !== -1 ? 1 : 0;
+ }
+ });
+
+ actual = tabs.find( ".ui-tabs-nav li" ).map(function( index ) {
+ var tab = $( this ),
+ tabIsDisabled = tab.hasClass( "ui-state-disabled" );
+
+ if ( tabIsDisabled && $.inArray( index, internalState ) !== -1 ) {
+ return 1;
+ }
+ if ( !tabIsDisabled && $.inArray( index, internalState ) === -1 ) {
+ return 0;
+ }
+ // mixed state - invalid
+ return -1;
+ }).get();
+
+ deepEqual( tabs.tabs( "option", "disabled" ), state );
+ deepEqual( actual, expected );
+ },
+
+ state: function( tabs ) {
+ var expected = $.makeArray( arguments ).slice( 1 ),
+ actual = tabs.find( ".ui-tabs-nav li" ).map(function() {
+ var tab = $( this ),
+ panel = $( $.ui.tabs.prototype._sanitizeSelector(
+ "#" + tab.find( "a" ).attr( "aria-controls" ) ) ),
+ tabIsActive = tab.hasClass( "ui-state-active" ),
+ panelIsActive = panel.css( "display" ) !== "none";
+
+ if ( tabIsActive && panelIsActive ) {
+ return 1;
+ }
+ if ( !tabIsActive && !panelIsActive ) {
+ return 0;
+ }
+ return -1; // mixed state - invalid
+ }).get();
+ deepEqual( actual, expected );
+ }
+};
+
diff --git a/tests/unit/testsuite.js b/tests/unit/testsuite.js
index d37e27f7b..33a9a2c99 100644
--- a/tests/unit/testsuite.js
+++ b/tests/unit/testsuite.js
@@ -1,4 +1,75 @@
-(function() {
+(function( $ ) {
+
+window.TestHelpers = {};
+
+function includeStyle( url ) {
+ document.write( "<link rel='stylesheet' href='../../../" + url + "'>" );
+}
+
+function includeScript( url ) {
+ document.write( "<script src='../../../" + url + "'></script>" );
+}
+
+QUnit.config.urlConfig.push( "min" );
+TestHelpers.loadResources = QUnit.urlParams.min ?
+ function() {
+ // TODO: proper include with theme images
+ includeStyle( "dist/jquery-ui.min.css" );
+ includeScript( "dist/jquery-ui.min.js" );
+ } :
+ function( resources ) {
+ $.each( resources.css || [], function( i, resource ) {
+ includeStyle( "themes/base/jquery." + resource + ".css" );
+ });
+ $.each( resources.js || [], function( i, resource ) {
+ includeScript( resource );
+ });
+ };
+
+QUnit.config.urlConfig.push( "nojshint" );
+var jshintLoaded = false;
+TestHelpers.testJshint = function( module ) {
+ if ( QUnit.urlParams.nojshint ) {
+ return;
+ }
+
+ if ( !jshintLoaded ) {
+ includeScript( "external/jshint.js" );
+ jshintLoaded = true;
+ }
+
+ asyncTest( "JSHint", function() {
+ expect( 1 );
+
+ $.when(
+ $.ajax({
+ url: "../../../ui/.jshintrc",
+ dataType: "json"
+ }),
+ $.ajax({
+ url: "../../../ui/jquery." + module + ".js",
+ dataType: "text"
+ })
+ ).done(function( hintArgs, srcArgs ) {
+ var passed = JSHINT( srcArgs[ 0 ], hintArgs[ 0 ] ),
+ errors = $.map( JSHINT.errors, function( error ) {
+ // JSHINT may report null if there are too many errors
+ if ( !error ) {
+ return;
+ }
+
+ return "[L" + error.line + ":C" + error.character + "] " +
+ error.reason + "\n" + error.evidence + "\n";
+ }).join( "\n" );
+ ok( passed, errors );
+ start();
+ })
+ .fail(function() {
+ ok( false, "error loading source" );
+ start();
+ });
+ });
+};
function testWidgetDefaults( widget, defaults ) {
var pluginDefaults = $.ui[ widget ].prototype.options;
@@ -22,17 +93,15 @@ function testWidgetDefaults( widget, defaults ) {
});
}
-var privateMethods = [
- "_createWidget",
- "destroy",
- "option",
- "_trigger"
-];
-
function testWidgetOverrides( widget ) {
if ( $.uiBackCompat === false ) {
test( "$.widget overrides", function() {
- $.each( privateMethods, function( i, method ) {
+ $.each([
+ "_createWidget",
+ "destroy",
+ "option",
+ "_trigger"
+ ], function( i, method ) {
strictEqual( $.ui[ widget ].prototype[ method ],
$.Widget.prototype[ method ], "should not override " + method );
});
@@ -54,16 +123,17 @@ function testBasicUsage( widget ) {
});
}
-window.commonWidgetTests = function( widget, settings ) {
+TestHelpers.commonWidgetTests = function( widget, settings ) {
module( widget + ": common widget" );
+ TestHelpers.testJshint( "ui." + widget );
testWidgetDefaults( widget, settings.defaults );
testWidgetOverrides( widget );
testBasicUsage( widget );
test( "version", function() {
ok( "version" in $.ui[ widget ].prototype, "version property exists" );
});
-}
+};
/*
* Experimental assertion for comparing DOM objects.
@@ -72,20 +142,22 @@ window.commonWidgetTests = function( widget, settings ) {
* Then compares the result using deepEqual.
*/
window.domEqual = function( selector, modifier, message ) {
- var attributes = ["class", "role", "id", "tabIndex", "aria-activedescendant"];
+ var expected, actual,
+ attributes = ["class", "role", "id", "tabIndex", "aria-activedescendant"];
function extract(value) {
if (!value || !value.length) {
QUnit.push( false, actual, expected, "domEqual failed, can't extract " + selector + ", message was: " + message );
return;
}
- var result = {};
+ var children,
+ result = {};
result.nodeName = value[0].nodeName;
$.each(attributes, function(index, attr) {
result[attr] = value.prop(attr);
});
result.children = [];
- var children = value.children();
+ children = value.children();
if (children.length) {
children.each(function() {
result.children.push(extract($(this)));
@@ -95,11 +167,11 @@ window.domEqual = function( selector, modifier, message ) {
}
return result;
}
- var expected = extract($(selector));
- modifier($(selector));
+ expected = extract( $( selector ) );
+ modifier( $( selector ) );
- var actual = extract($(selector));
+ actual = extract( $( selector ) );
QUnit.push( QUnit.equiv(actual, expected), actual, expected, message );
-}
+};
-}());
+}( jQuery ));
diff --git a/tests/unit/tooltip/all.html b/tests/unit/tooltip/all.html
index deb628e2f..c1aa35acf 100644
--- a/tests/unit/tooltip/all.html
+++ b/tests/unit/tooltip/all.html
@@ -7,9 +7,9 @@
<script src="../../../jquery-1.7.2.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
- <link rel="stylesheet" href="../subsuiteRunner.css">
+ <link rel="stylesheet" href="../qunit-composite.css">
<script src="../../../external/qunit.js"></script>
- <script src="../subsuiteRunner.js"></script>
+ <script src="../qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>
diff --git a/tests/unit/tooltip/tooltip.html b/tests/unit/tooltip/tooltip.html
index b5e8558e5..d20ba8578 100644
--- a/tests/unit/tooltip/tooltip.html
+++ b/tests/unit/tooltip/tooltip.html
@@ -5,9 +5,12 @@
<title>jQuery UI Tooltip Test Suite</title>
<script src="../../jquery.js"></script>
- <script src="../../resource_loader.js"></script>
+ <link rel="stylesheet" href="../../../external/qunit.css">
+ <script src="../../../external/qunit.js"></script>
+ <script src="../../jquery.simulate.js"></script>
+ <script src="../testsuite.js"></script>
<script>
- loadResources({
+ TestHelpers.loadResources({
css: [ "ui.core", "ui.tooltip" ],
js: [
"ui/jquery.ui.core.js",
@@ -18,12 +21,7 @@
});
</script>
- <link rel="stylesheet" href="../../../external/qunit.css">
- <script src="../../../external/qunit.js"></script>
- <script src="../../jquery.simulate.js"></script>
- <script src="../testsuite.js"></script>
-
- <script src="tooltip_defaults.js"></script>
+ <script src="tooltip_common.js"></script>
<script src="tooltip_core.js"></script>
<script src="tooltip_events.js"></script>
<script src="tooltip_methods.js"></script>
diff --git a/tests/unit/tooltip/tooltip_defaults.js b/tests/unit/tooltip/tooltip_common.js
index b8b41bf47..d12ee9519 100644
--- a/tests/unit/tooltip/tooltip_defaults.js
+++ b/tests/unit/tooltip/tooltip_common.js
@@ -1,4 +1,4 @@
-commonWidgetTests( "tooltip", {
+TestHelpers.commonWidgetTests( "tooltip", {
defaults: {
content: function() {},
disabled: false,
diff --git a/tests/unit/tooltip/tooltip_methods.js b/tests/unit/tooltip/tooltip_methods.js
index 3e8256c50..eaab1c0d1 100644
--- a/tests/unit/tooltip/tooltip_methods.js
+++ b/tests/unit/tooltip/tooltip_methods.js
@@ -16,11 +16,12 @@ test( "destroy", function() {
test( "open/close", function() {
expect( 3 );
$.fx.off = true;
- var element = $( "#tooltipped1" ).tooltip();
+ var tooltip,
+ element = $( "#tooltipped1" ).tooltip();
equal( $( ".ui-tooltip" ).length, 0, "no tooltip on init" );
element.tooltip( "open" );
- var tooltip = $( "#" + element.attr( "aria-describedby" ) );
+ tooltip = $( "#" + element.attr( "aria-describedby" ) );
ok( tooltip.is( ":visible" ) );
element.tooltip( "close" );
@@ -31,11 +32,12 @@ test( "open/close", function() {
test( "enable/disable", function() {
expect( 7 );
$.fx.off = true;
- var element = $( "#tooltipped1" ).tooltip();
+ var tooltip,
+ element = $( "#tooltipped1" ).tooltip();
equal( $( ".ui-tooltip" ).length, 0, "no tooltip on init" );
element.tooltip( "open" );
- var tooltip = $( "#" + element.attr( "aria-describedby" ) );
+ tooltip = $( "#" + element.attr( "aria-describedby" ) );
ok( tooltip.is( ":visible" ) );
element.tooltip( "disable" );
diff --git a/tests/unit/tooltip/tooltip_options.js b/tests/unit/tooltip/tooltip_options.js
index 42529e087..4f994f8de 100644
--- a/tests/unit/tooltip/tooltip_options.js
+++ b/tests/unit/tooltip/tooltip_options.js
@@ -45,11 +45,12 @@ asyncTest( "content: sync + async callback", function() {
test( "items", function() {
expect( 2 );
- var element = $( "#qunit-fixture" ).tooltip({
- items: "#fixture-span"
- });
+ var event,
+ element = $( "#qunit-fixture" ).tooltip({
+ items: "#fixture-span"
+ });
- var event = $.Event( "mouseenter" );
+ event = $.Event( "mouseenter" );
event.target = $( "#fixture-span" )[ 0 ];
element.tooltip( "open", event );
deepEqual( $( "#" + $( "#fixture-span" ).attr( "aria-describedby" ) ).text(), "title-text" );
@@ -63,7 +64,7 @@ test( "items", function() {
});
test( "tooltipClass", function() {
- expect( 1 )
+ expect( 1 );
var element = $( "#tooltipped1" ).tooltip({
tooltipClass: "custom"
}).tooltip( "open" );
diff --git a/tests/unit/widget/all.html b/tests/unit/widget/all.html
index cad4bdd72..e5b16c8d7 100644
--- a/tests/unit/widget/all.html
+++ b/tests/unit/widget/all.html
@@ -7,9 +7,9 @@
<script src="../../../jquery-1.7.2.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
- <link rel="stylesheet" href="../subsuiteRunner.css">
+ <link rel="stylesheet" href="../qunit-composite.css">
<script src="../../../external/qunit.js"></script>
- <script src="../subsuiteRunner.js"></script>
+ <script src="../qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>
diff --git a/tests/unit/widget/widget.html b/tests/unit/widget/widget.html
index 6f4caaa6c..15eaee6aa 100644
--- a/tests/unit/widget/widget.html
+++ b/tests/unit/widget/widget.html
@@ -5,9 +5,12 @@
<title>jQuery UI Widget Test Suite</title>
<script src="../../jquery.js"></script>
- <script src="../../resource_loader.js"></script>
+ <link rel="stylesheet" href="../../../external/qunit.css">
+ <script src="../../../external/qunit.js"></script>
+ <script src="../../jquery.simulate.js"></script>
+ <script src="../testsuite.js"></script>
<script>
- loadResources({
+ TestHelpers.loadResources({
css: [ "ui.core" ],
js: [
"ui/jquery.ui.widget.js"
@@ -15,11 +18,6 @@
});
</script>
- <link rel="stylesheet" href="../../../external/qunit.css">
- <script src="../../../external/qunit.js"></script>
- <script src="../../jquery.simulate.js"></script>
- <script src="../testsuite.js"></script>
-
<script src="widget_core.js"></script>
<script src="widget_extend.js"></script>
<script src="widget_animation.js"></script>
diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js
index e104d4ae9..aa70e2425 100644
--- a/tests/unit/widget/widget_core.js
+++ b/tests/unit/widget/widget_core.js
@@ -2,10 +2,14 @@
module( "widget factory", {
teardown: function() {
- delete $.ui.testWidget;
+ if ( $.ui ) {
+ delete $.ui.testWidget;
+ }
}
});
+TestHelpers.testJshint( "ui.widget" );
+
test( "widget creation", function() {
var myPrototype = {
_create: function() {},
@@ -84,7 +88,8 @@ test( "custom selector expression", function() {
test( "jQuery usage", function() {
expect( 16 );
- var shouldCreate = false;
+ var elem, instance, ret, bcInstance,
+ shouldCreate = false;
$.widget( "ui.testWidget", {
getterSetterVal: 5,
@@ -113,22 +118,22 @@ test( "jQuery usage", function() {
});
shouldCreate = true;
- var elem = $( "<div>" )
+ elem = $( "<div>" )
.bind( "testwidgetcreate", function() {
ok( shouldCreate, "create event triggered on instantiation" );
})
.testWidget();
shouldCreate = false;
- var instance = elem.data( "ui-testWidget" );
+ instance = elem.data( "ui-testWidget" );
equal( typeof instance, "object", "instance stored in .data(pluginName)" );
equal( instance.element[0], elem[0], "element stored on widget" );
- var ret = elem.testWidget( "methodWithParams", "value1", "value2" );
+ ret = elem.testWidget( "methodWithParams", "value1", "value2" );
equal( ret, elem, "jQuery object returned from method call" );
// 1.9 BC for #7810
// TODO remove
- var bcInstance = elem.data("testWidget");
+ bcInstance = elem.data("testWidget");
equal( typeof bcInstance, "object", "instance stored in .data(pluginName)" );
equal( bcInstance.element[0], elem[0], "element stored on widget" );
@@ -148,7 +153,8 @@ test( "jQuery usage", function() {
test( "direct usage", function() {
expect( 9 );
- var shouldCreate = false;
+ var elem, instance, ret,
+ shouldCreate = false;
$.widget( "ui.testWidget", {
getterSetterVal: 5,
@@ -171,17 +177,17 @@ test( "direct usage", function() {
}
});
- var elem = $( "<div>" )[ 0 ];
+ elem = $( "<div>" )[ 0 ];
shouldCreate = true;
- var instance = new $.ui.testWidget( {}, elem );
+ instance = new $.ui.testWidget( {}, elem );
shouldCreate = false;
equal( $( elem ).data( "ui-testWidget" ), instance,
"instance stored in .data(pluginName)" );
equal( instance.element[ 0 ], elem, "element stored on widget" );
- var ret = instance.methodWithParams( "value1", "value2" );
+ ret = instance.methodWithParams( "value1", "value2" );
equal( ret, instance, "plugin returned from method call" );
ret = instance.getterSetterMethod();
@@ -439,11 +445,12 @@ test( ".option() - getter", function() {
_create: function() {}
});
- var div = $( "<div>" ).testWidget({
- foo: "bar",
- baz: 5,
- qux: [ "quux", "quuux" ]
- });
+ var options,
+ div = $( "<div>" ).testWidget({
+ foo: "bar",
+ baz: 5,
+ qux: [ "quux", "quuux" ]
+ });
deepEqual( div.testWidget( "option", "x" ), null, "non-existent option" );
deepEqual( div.testWidget( "option", "foo"), "bar", "single option - string" );
@@ -451,7 +458,7 @@ test( ".option() - getter", function() {
deepEqual( div.testWidget( "option", "qux"), [ "quux", "quuux" ],
"single option - array" );
- var options = div.testWidget( "option" );
+ options = div.testWidget( "option" );
deepEqual( options, {
create: null,
disabled: false,
@@ -483,14 +490,15 @@ test( ".option() - deep option getter", function() {
});
test( ".option() - delegate to ._setOptions()", function() {
- var calls = [];
+ var div,
+ calls = [];
$.widget( "ui.testWidget", {
_create: function() {},
_setOptions: function( options ) {
calls.push( options );
}
});
- var div = $( "<div>" ).testWidget();
+ div = $( "<div>" ).testWidget();
calls = [];
div.testWidget( "option", "foo", "bar" );
@@ -506,7 +514,8 @@ test( ".option() - delegate to ._setOptions()", function() {
});
test( ".option() - delegate to ._setOption()", function() {
- var calls = [];
+ var div,
+ calls = [];
$.widget( "ui.testWidget", {
_create: function() {},
_setOption: function( key, val ) {
@@ -516,7 +525,7 @@ test( ".option() - delegate to ._setOption()", function() {
});
}
});
- var div = $( "<div>" ).testWidget();
+ div = $( "<div>" ).testWidget();
calls = [];
div.testWidget( "option", "foo", "bar" );
@@ -603,7 +612,7 @@ test( ".widget() - overriden", function() {
test( "._bind() to element (default)", function() {
expect( 12 );
- var that;
+ var that, widget;
$.widget( "ui.testWidget", {
_create: function() {
that = this;
@@ -623,7 +632,7 @@ test( "._bind() to element (default)", function() {
equal( "keydown", event.type );
}
});
- var widget = $( "<div></div>" )
+ widget = $( "<div></div>" )
.testWidget()
.trigger( "keyup" )
.trigger( "keydown" );
@@ -643,7 +652,7 @@ test( "._bind() to element (default)", function() {
test( "._bind() to descendent", function() {
expect( 12 );
- var that;
+ var that, widget, descendant;
$.widget( "ui.testWidget", {
_create: function() {
that = this;
@@ -664,28 +673,28 @@ test( "._bind() to descendent", function() {
}
});
// trigger events on both widget and descendent to ensure that only descendent receives them
- var widget = $( "<div><p><strong>hello</strong> world</p></div>" )
+ widget = $( "<div><p><strong>hello</strong> world</p></div>" )
.testWidget()
.trigger( "keyup" )
.trigger( "keydown" );
- var descendent = widget.find( "strong" )
+ descendant = widget.find( "strong" )
.trigger( "keyup" )
.trigger( "keydown" );
widget
.testWidget( "disable" )
.trigger( "keyup" )
.trigger( "keydown" );
- descendent
+ descendant
.trigger( "keyup" )
.trigger( "keydown" );
widget
.testWidget( "enable" )
.trigger( "keyup" )
.trigger( "keydown" );
- descendent
+ descendant
.trigger( "keyup" )
.trigger( "keydown" );
- descendent
+ descendant
.addClass( "ui-state-disabled" )
.trigger( "keyup" )
.trigger( "keydown" );
@@ -693,7 +702,7 @@ test( "._bind() to descendent", function() {
.testWidget( "destroy" )
.trigger( "keyup" )
.trigger( "keydown" );
- descendent
+ descendant
.trigger( "keyup" )
.trigger( "keydown" );
});
@@ -942,10 +951,10 @@ test( "._trigger() - array as ui", function() {
qux: 5,
quux: 20
}
+ },
+ extra = {
+ bar: 5
};
- var extra = {
- bar: 5
- };
this._trigger( "foo", null, [ ui, extra ] );
}
});
@@ -983,8 +992,7 @@ test( "._trigger() - instance as element", function() {
$.widget( "ui.testWidget", {
defaultElement: null,
testEvent: function() {
- var ui = { foo: "bar" };
- this._trigger( "foo", null, ui );
+ this._trigger( "foo", null, { foo: "bar" } );
}
});
var instance = $.ui.testWidget({
diff --git a/tests/unit/widget/widget_extend.js b/tests/unit/widget/widget_extend.js
index 90e686e18..ae9855929 100644
--- a/tests/unit/widget/widget_extend.js
+++ b/tests/unit/widget/widget_extend.js
@@ -1,7 +1,9 @@
test( "$.widget.extend()", function() {
expect( 26 );
- var settings = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
+ var ret, empty, optionsWithLength, optionsWithDate, myKlass, customObject, optionsWithCustomObject, nullUndef,
+ target, recursive, obj, input, output,
+ settings = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
options = { xnumber2: 1, xstring2: "x", xxx: "newstring" },
optionsCopy = { xnumber2: 1, xstring2: "x", xxx: "newstring" },
merged = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "x", xxx: "newstring" },
@@ -11,7 +13,13 @@ test( "$.widget.extend()", function() {
deepmerged = { foo: { bar: true, baz: true }, foo2: document },
arr = [1, 2, 3],
nestedarray = { arr: arr },
- ret;
+ defaults = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
+ defaultsCopy = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
+ options1 = { xnumber2: 1, xstring2: "x" },
+ options1Copy = { xnumber2: 1, xstring2: "x" },
+ options2 = { xstring2: "xx", xxx: "newstringx" },
+ options2Copy = { xstring2: "xx", xxx: "newstringx" },
+ merged2 = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "xx", xxx: "newstringx" };
$.widget.extend( settings, options );
deepEqual( settings, merged, "Check if extended: settings must be extended" );
@@ -25,19 +33,19 @@ test( "$.widget.extend()", function() {
strictEqual( $.widget.extend({}, nestedarray).arr, arr, "Don't clone arrays" );
ok( $.isPlainObject( $.widget.extend({ arr: arr }, { arr: {} }).arr ), "Cloned object heve to be an plain object" );
- var empty = {};
- var optionsWithLength = { foo: { length: -1 } };
+ empty = {};
+ optionsWithLength = { foo: { length: -1 } };
$.widget.extend( empty, optionsWithLength );
deepEqual( empty.foo, optionsWithLength.foo, "The length property must copy correctly" );
empty = {};
- var optionsWithDate = { foo: { date: new Date } };
+ optionsWithDate = { foo: { date: new Date() } };
$.widget.extend( empty, optionsWithDate );
deepEqual( empty.foo, optionsWithDate.foo, "Dates copy correctly" );
- var myKlass = function() {};
- var customObject = new myKlass();
- var optionsWithCustomObject = { foo: { date: customObject } };
+ myKlass = function() {};
+ customObject = new myKlass();
+ optionsWithCustomObject = { foo: { date: customObject } };
empty = {};
$.widget.extend( empty, optionsWithCustomObject );
strictEqual( empty.foo.date, customObject, "Custom objects copy correctly (no methods)" );
@@ -48,10 +56,9 @@ test( "$.widget.extend()", function() {
$.widget.extend( empty, optionsWithCustomObject );
strictEqual( empty.foo.date, customObject, "Custom objects copy correctly" );
- ret = $.widget.extend({ foo: 4 }, { foo: new Number(5) } );
+ ret = $.widget.extend({ foo: 4 }, { foo: Number(5) } );
equal( ret.foo, 5, "Wrapped numbers copy correctly" );
- var nullUndef;
nullUndef = $.widget.extend( {}, options, { xnumber2: null } );
strictEqual( nullUndef.xnumber2, null, "Check to make sure null values are copied");
@@ -61,8 +68,8 @@ test( "$.widget.extend()", function() {
nullUndef = $.widget.extend( {}, options, { xnumber0: null } );
strictEqual( nullUndef.xnumber0, null, "Check to make sure null values are inserted");
- var target = {};
- var recursive = { foo:target, bar:5 };
+ target = {};
+ recursive = { foo:target, bar:5 };
$.widget.extend( target, recursive );
deepEqual( target, { foo: {}, bar: 5 }, "Check to make sure a recursive obj doesn't go never-ending loop by not copying it over" );
@@ -75,28 +82,20 @@ test( "$.widget.extend()", function() {
ret = $.widget.extend( { foo:"bar" }, { foo:null } );
strictEqual( typeof ret.foo, "object", "Make sure a null value doesn't crash with deep extend, for #1908" );
- var obj = { foo:null };
+ obj = { foo:null };
$.widget.extend( obj, { foo:"notnull" } );
equal( obj.foo, "notnull", "Make sure a null value can be overwritten" );
- var defaults = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
- defaultsCopy = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
- options1 = { xnumber2: 1, xstring2: "x" },
- options1Copy = { xnumber2: 1, xstring2: "x" },
- options2 = { xstring2: "xx", xxx: "newstringx" },
- options2Copy = { xstring2: "xx", xxx: "newstringx" },
- merged2 = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "xx", xxx: "newstringx" };
-
- var settings = $.widget.extend( {}, defaults, options1, options2 );
+ settings = $.widget.extend( {}, defaults, options1, options2 );
deepEqual( settings, merged2, "Check if extended: settings must be extended" );
deepEqual( defaults, defaultsCopy, "Check if not modified: options1 must not be modified" );
deepEqual( options1, options1Copy, "Check if not modified: options1 must not be modified" );
deepEqual( options2, options2Copy, "Check if not modified: options2 must not be modified" );
- var input = {
+ input = {
key: [ 1, 2, 3 ]
};
- var output = $.widget.extend( {}, input );
+ output = $.widget.extend( {}, input );
deepEqual( input, output, "don't clone arrays" );
input.key[0] = 10;
deepEqual( input, output, "don't clone arrays" );
diff --git a/tests/visual/addClass/addClass_queue.html b/tests/visual/addClass/addClass_queue.html
index 9cc2ec4fc..616f2c7f9 100644
--- a/tests/visual/addClass/addClass_queue.html
+++ b/tests/visual/addClass/addClass_queue.html
@@ -1,9 +1,8 @@
-<!DOCTYPE html>
+<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>addClass Visual Test : Queue</title>
- <link rel="stylesheet" href="../visual.css">
<link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css">
<script src="../../../jquery-1.7.2.js"></script>
<script src="../../../ui/jquery.effects.core.js"></script>
@@ -43,6 +42,9 @@
</head>
<body>
+<p>WHAT: The two boxes animate from black to red to green to blue.</p>
+<p>The first box should start with a delay, the second box should start immediately.</p>
+
<div id="box1" class="box"></div>
<div id="box2" class="box"></div>
diff --git a/tests/visual/button/button_disabled_true.html b/tests/visual/button/button_disabled_true.html
index 25388a484..83a3e9cd6 100644
--- a/tests/visual/button/button_disabled_true.html
+++ b/tests/visual/button/button_disabled_true.html
@@ -46,7 +46,7 @@
<fieldset>
<legend>anchor</legend>
- <a href="javascript:void(0)" disabled="disabled">anchor 1</a>
+ <a href="javascript:void(0)">anchor 1</a> # Attribute "disabled" not allowed on element "a" at this point.
<hr />
<a href="javascript:void(0)" id="anchor1">anchor 1</a>
</fieldset>
diff --git a/tests/visual/button/button_ticket_5254.html b/tests/visual/button/button_ticket_5254.html
deleted file mode 100644
index c46e094ab..000000000
--- a/tests/visual/button/button_ticket_5254.html
+++ /dev/null
@@ -1,55 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
- <meta charset="UTF-8" />
- <title>Button Visual Test : Button ticket #5254</title>
- <link rel="stylesheet" href="../visual.css" type="text/css" />
- <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css">
- <script type="text/javascript" src="../../../jquery-1.7.2.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.button.js"></script>
- <script type="text/javascript">
- $(function() {
-
- $('#b1').button();
-
- $('#b2').button();
-
- $('#b3').button().click(function() {
- return false;
- });
-
- $('#ua').text(navigator.userAgent);
-
- });
- </script>
-</head>
-<body>
-
-<h1 class="ui-widget-header"><a href="http://dev.jqueryui.com/ticket/5254">#5254 - Input, button and anchor buttons aren't consistent in IE7</a></h1>
-
-<dl>
-<dt><h2>Screenshot from ticket:</h2></dt>
-<dd><img src="http://dev.jqueryui.com/raw-attachment/ticket/5254/button.png"></dd>
-</dl>
-
-<hr>
-
-<dl>
-<dt><h2>Visual test:</h2></dt>
-<dd>
- <div id="vt">
- <input id="b1" type="button" value="Input" style="" />
- <button id="b2">Button</button>
- <a id="b3" href="#">Anchor</a>
- </div>
-</dd>
-<dt><h2>User agent:</h2></dt>
-<dd>
- <h3 id="ua"></h3>
-</dd>
-</dl>
-
-</body>
-</html>
diff --git a/tests/visual/compound/accordion_dialog.html b/tests/visual/compound/accordion_dialog.html
deleted file mode 100644
index df179ff6a..000000000
--- a/tests/visual/compound/accordion_dialog.html
+++ /dev/null
@@ -1,202 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
- <meta charset="UTF-8" />
- <title>Compound Visual Test : Accordion in Dialog</title>
- <link rel="stylesheet" href="../visual.css" type="text/css" />
- <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css">
- <script type="text/javascript" src="../../../jquery-1.7.2.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.position.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.accordion.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.resizable.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.draggable.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.dialog.js"></script>
- <script type="text/javascript">
- $(function() {
- $('#accordion').accordion({
- collapsible: true,
- active: false
- });
- $('#dialog').dialog({
- buttons: {
- Test: $.noop
- }
- });
- });
- </script>
-</head>
-<body>
-
-<div id="dialog">
- <div id="accordion">
- <h3><a href="#">Section 1</a></h3>
- <div>
- <p>
- Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer
- ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit
- amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut
- odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.
- </p>
- </div>
- <h3><a href="#">Section 2</a></h3>
- <div>
- <p>
- Cras dictum. Pellentesque habitant morbi tristique senectus et netus
- et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in
- faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia
- mauris vel est.
- </p>
- <p>
- Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus.
- Class aptent taciti sociosqu ad litora torquent per conubia nostra, per
- inceptos himenaeos.
- </p>
- </div>
- <h3><a href="#">Section 3</a></h3>
- <div>
- <p>
- Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis.
- Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero
- ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis
- lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui.
- </p>
- <ul>
- <li>List item one</li>
- <li>List item two</li>
- <li>List item three</li>
- </ul>
- </div>
- </div>
-</div>
-
-<p>
-Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam vitae urna quam. Fusce adipiscing erat eget magna malesuada vel mollis ligula ullamcorper. Donec pulvinar, libero et vehicula facilisis, odio orci fringilla magna, non ultricies ipsum justo a tellus. Proin facilisis magna vitae quam vestibulum tempor. Aenean semper placerat posuere. In nisi diam, ullamcorper sit amet viverra sed, pretium sed neque. Sed posuere vulputate mauris vitae placerat. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nam in odio elit, non tempor felis. Integer non iaculis ante. Sed erat mauris, aliquam nec consequat id, congue id libero. Maecenas elementum gravida tincidunt. Suspendisse lacinia enim sit amet nulla cursus pulvinar.
-</p>
-<p>
-Proin ut sem nulla, at cursus sapien. Duis sagittis lacus vitae justo mattis in sagittis ligula eleifend. Curabitur sit amet felis pharetra justo facilisis mollis eget nec massa. Sed nisi urna, semper lobortis pretium ac, interdum nec lacus. In gravida, leo sit amet vehicula malesuada, augue nunc consectetur nulla, vel tincidunt est nunc aliquet neque. Maecenas imperdiet eros id ligula tempor dapibus. Integer commodo metus sit amet quam vestibulum volutpat. In et lorem ac leo rhoncus auctor sit amet ut urna. Nulla sed nisl quis turpis vestibulum accumsan. Duis mollis aliquam sollicitudin. Pellentesque porta semper interdum. Sed eros orci, congue quis sollicitudin ut, rutrum vitae nibh. Nunc et leo non ligula interdum imperdiet. Integer tincidunt rhoncus ullamcorper. Curabitur et ullamcorper lorem. Ut at tellus eu metus congue sollicitudin eget at orci.
-</p>
-<p>
-Duis sem mauris, pulvinar quis placerat vel, aliquet non leo. Cras eros arcu, ullamcorper sit amet imperdiet at, blandit interdum augue. Phasellus non nunc ac ante condimentum tristique vitae sed urna. Integer nec sapien et dolor volutpat bibendum ac vitae justo. Aliquam gravida fermentum felis, nec dictum dui dictum ac. Maecenas eget magna leo. Phasellus ac nulla risus, dapibus ornare turpis. Morbi a massa tortor. Duis ac turpis lacus. Duis nibh metus, euismod quis ultrices vitae, sollicitudin vel leo. Nullam volutpat odio ac elit imperdiet gravida.
-</p>
-<p>
-Donec luctus magna id ipsum aliquam eget convallis tortor tristique. Etiam est quam, aliquam ac rutrum quis, pretium sed tortor. Aliquam lacus diam, rhoncus molestie convallis ut, luctus ac lacus. Nunc porttitor ante a ligula rutrum elementum. Cras dui tellus, pulvinar vel convallis sit amet, facilisis nec ipsum. Donec fermentum lectus lorem, id accumsan eros. Nunc semper laoreet lacus quis ullamcorper. Nunc luctus erat vitae orci sodales facilisis non ut felis. Aliquam pretium sapien sed enim adipiscing in feugiat est ornare. Aenean ultricies convallis tortor sit amet ullamcorper.
-</p>
-<p>
-Etiam ultricies elit non enim elementum aliquet. Vivamus quis fringilla mauris. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nunc blandit felis at massa interdum ac molestie lectus volutpat. Mauris commodo nibh id sem porta id feugiat ante euismod. Nullam fermentum libero varius turpis pharetra cursus ut sed lacus. Mauris molestie egestas augue eu bibendum. Quisque pulvinar, leo luctus vehicula faucibus, quam mi ornare dui, a rhoncus nisi eros nec dolor. Sed dictum ultricies ipsum eu ultrices. Etiam semper condimentum nibh in tempor.
-</p>
-<p>
-
-Vivamus interdum ligula nec neque sollicitudin ornare. Vestibulum a eros eget nisi accumsan hendrerit quis sit amet ipsum. Phasellus condimentum vestibulum felis eu hendrerit. Suspendisse in est tellus, et consequat ante. Nam at sapien lobortis risus dignissim malesuada. In dapibus lectus sed nibh adipiscing dictum. Nulla pellentesque convallis auctor. Suspendisse ut purus et nibh pulvinar tincidunt. Maecenas dapibus purus at odio commodo ac cursus risus luctus. Ut quis libero justo. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nullam vestibulum ipsum quis ante porttitor porta. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Ut in ante neque. Donec ante ante, porttitor non egestas a, pulvinar sed sem. Nam augue quam, fringilla sed egestas et, vulputate non nisi.
-</p>
-<p>
-Nunc sit amet arcu ac nulla bibendum sollicitudin. Pellentesque sed ligula urna. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Quisque egestas, tortor a vestibulum malesuada, ante dui condimentum massa, ac rutrum massa mauris non mi. Praesent in nisi leo. Sed ac augue nisl. Donec eget enim ut arcu posuere condimentum vel id magna. Vestibulum laoreet imperdiet massa, ut venenatis ante dapibus eu. Phasellus faucibus vestibulum eros mollis adipiscing. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque aliquet lectus at enim gravida tempus tincidunt mi porta. Sed vehicula molestie ligula, sed tincidunt diam suscipit vitae.
-</p>
-<p>
-Nullam euismod tempus ante, vel semper turpis pharetra eget. Nulla pretium ante et ipsum dapibus imperdiet. Praesent ipsum velit, gravida sed adipiscing id, condimentum in odio. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Fusce blandit vehicula felis, pretium ullamcorper leo tempor non. Nunc eget nisi nunc, posuere pellentesque enim. Nunc gravida orci quis odio semper ultricies. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque eu neque a sapien commodo placerat. Aenean non eros semper metus viverra porttitor. Integer vel tortor eu neque commodo ultrices eu quis tellus. Nam commodo sagittis dolor in consequat. Fusce hendrerit turpis eget leo rutrum ut scelerisque nibh condimentum. Fusce sit amet feugiat mauris. Maecenas elementum tellus nec augue rutrum mattis. Sed viverra tempor blandit. Pellentesque adipiscing tincidunt est sit amet tincidunt. Proin suscipit suscipit odio, eu pellentesque dolor pharetra non. Aliquam erat volutpat.
-</p>
-<p>
-Duis pellentesque, enim sed mollis congue, ante mauris feugiat nisi, bibendum euismod erat enim ac magna. Mauris risus nisl, sodales vel viverra ut, interdum sed neque. Nunc ac dignissim felis. Proin tincidunt orci elementum erat molestie suscipit. Cras suscipit, sem ac vehicula vehicula, lorem orci dictum nibh, ut bibendum odio sem non erat. Maecenas quis metus eget mauris feugiat porta a eu ipsum. Vivamus tortor purus, posuere ut luctus sed, ullamcorper feugiat neque. In hac habitasse platea dictumst. Vivamus nec justo vel lacus mattis pellentesque. Nunc vel gravida quam. Etiam at aliquam magna.
-</p>
-<p>
-Sed ac lacus ac felis auctor suscipit. Aliquam lacinia lectus ac nunc placerat aliquam accumsan neque interdum. Aenean in sapien sem. Suspendisse potenti. Aenean congue vulputate scelerisque. Proin eget eros tortor. Morbi rhoncus, mi vitae sollicitudin luctus, est orci porttitor turpis, vitae cursus est dui sed leo. Curabitur erat nunc, placerat bibendum tempus in, blandit eget ipsum. Cras in feugiat ipsum. Vestibulum dapibus quam nec odio pretium non dapibus purus dapibus. Pellentesque vehicula metus bibendum orci ultrices tincidunt. Sed fermentum, neque eget porta tempor, sem neque pulvinar ligula, vitae elementum massa metus eget nunc. Nunc sed orci eu purus sodales fringilla. Quisque aliquet arcu ac dolor ultrices fringilla. Nullam ornare tempus lorem, in mattis magna mollis laoreet. Vestibulum convallis arcu in purus lobortis et sollicitudin ipsum aliquet. Quisque risus est, sagittis eu aliquam ac, condimentum at massa. Fusce consectetur dignissim sem vel ornare. Maecenas posuere ultricies sollicitudin. Duis luctus, purus quis auctor egestas, diam felis scelerisque diam, a varius tellus erat a nunc.
-</p>
-<p>
-Phasellus id ante neque, eget volutpat risus. Vivamus scelerisque, nisi rutrum ultrices varius, sem quam suscipit purus, in elementum nibh nulla nec nisi. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Phasellus interdum hendrerit mi, nec cursus nisi tempor ac. Phasellus luctus ligula bibendum mauris iaculis id tempor odio volutpat. Nunc in augue metus. Suspendisse at libero at libero lacinia convallis eu vitae metus. Duis eget risus odio. Nam id mi tellus, non vulputate libero. In placerat dictum orci eu pellentesque. Etiam sed varius felis. Phasellus ut adipiscing leo. Morbi ante eros, interdum eget dapibus ac, varius congue nunc. Donec vulputate sapien id risus sodales sit amet pretium velit iaculis. Etiam ultrices tempor euismod.
-</p>
-
-<p>
-Praesent in turpis ut mauris cursus commodo. Mauris lectus tellus, congue sit amet dictum id, convallis ac nisi. Curabitur ante dolor, sagittis ac auctor ac, aliquet vel nisl. Nulla non porta sapien. Nunc non aliquet erat. Vestibulum euismod auctor volutpat. Mauris libero tellus, pharetra eget lacinia sit amet, viverra eget velit. Sed viverra varius velit at pharetra. Sed pharetra dolor sed erat interdum in placerat magna lacinia. Cras venenatis tellus non sapien egestas sollicitudin. Duis congue pharetra lacinia. Curabitur eu diam vel tortor rhoncus dignissim vel sed enim. Proin ut congue mi. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce viverra elit eu dolor tincidunt tempor vel nec magna. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;
-</p>
-<p>
-Sed ligula purus, tristique nec condimentum sed, facilisis ac augue. Integer volutpat velit urna, et posuere ligula. In tempus luctus dignissim. Duis augue neque, egestas ut tincidunt in, congue a enim. Aliquam ut odio dui, id congue tortor. Nullam venenatis erat non nulla tincidunt scelerisque. Morbi in urna ac nulla molestie scelerisque eu a nulla. Aliquam erat volutpat. Praesent dictum scelerisque lorem mattis vehicula. Quisque ut rutrum metus. Mauris pharetra ante vitae nunc mattis vulputate. Mauris molestie volutpat mauris, ut iaculis dui bibendum ac. Ut egestas laoreet est, eget mollis libero laoreet at. In sagittis vestibulum accumsan. Nam dapibus ultrices urna sit amet accumsan. Pellentesque id ultrices elit. Aliquam quis magna ut leo sagittis posuere sit amet id enim. Etiam congue eros sit amet nulla aliquam gravida. In accumsan lectus nibh. Proin volutpat pretium facilisis.
-</p>
-<p>
-Mauris pulvinar erat at quam egestas ac aliquet mi gravida. Integer pellentesque quam vel massa commodo vitae sollicitudin eros volutpat. Aenean mollis felis molestie quam placerat et elementum eros gravida. In hac habitasse platea dictumst. Mauris ullamcorper facilisis eros, nec rutrum mi auctor sed. Ut viverra, orci a viverra ultricies, turpis enim pellentesque urna, sit amet viverra metus enim ut justo. Donec aliquam, urna id condimentum rutrum, nibh nunc tristique magna, at luctus quam enim at turpis. Maecenas dapibus dui ac velit adipiscing fringilla. Nullam malesuada nunc vel lorem cursus sed congue felis lacinia. Pellentesque vehicula gravida est nec facilisis. Nullam imperdiet fringilla orci in dignissim. Praesent orci dolor, vestibulum eu auctor quis, tristique auctor mi. Nunc euismod dui sit amet metus malesuada feugiat. Fusce iaculis neque in velit interdum rhoncus. Aenean at risus ut arcu dapibus congue a tincidunt dolor. Donec porttitor lacus et urna vestibulum a sagittis nunc mollis.
-</p>
-<p>
-In metus tellus, eleifend id aliquet at, pulvinar ut tortor. Aliquam erat volutpat. Vivamus lacus magna, consequat vel euismod sed, viverra a ipsum. Praesent dapibus laoreet nisi, nec posuere massa commodo vel. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ullamcorper adipiscing ante, dapibus molestie velit cursus id. Nam cursus arcu consectetur lectus sollicitudin gravida. Maecenas urna sapien, fermentum sit amet consectetur at, feugiat ut massa. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer sit amet ante nec arcu bibendum bibendum ut ut justo. Nulla ut libero est.
-</p>
-<p>
-Aenean sem augue, malesuada quis elementum id, aliquet at turpis. Nam volutpat interdum purus, at dictum risus posuere rhoncus. Praesent metus diam, egestas in lacinia eu, tincidunt in nibh. Phasellus sollicitudin volutpat erat, sit amet mattis sapien fringilla in. Quisque rhoncus, felis a pellentesque dictum, arcu urna molestie sem, ut tincidunt nulla magna in enim. Vestibulum erat nulla, sollicitudin quis faucibus et, blandit quis est. Nam vehicula justo augue. Vivamus elementum sodales aliquet. Donec convallis neque sed dui euismod aliquet. Morbi elementum hendrerit odio, vel mollis felis dignissim vitae. Phasellus a diam lacus. Integer congue, mi vehicula egestas imperdiet, nulla mi commodo tortor, sit amet fermentum urna leo non dolor. Donec elementum elementum urna at sollicitudin. Vestibulum placerat tortor in nibh lobortis ac consectetur felis interdum. Integer faucibus diam nec magna porttitor sit amet dictum elit consectetur. Suspendisse risus velit, pellentesque eget viverra in, porta eget metus. Sed porta elit erat.
-</p>
-<p>
-Nulla facilisi. Aliquam vulputate dolor quis nisi auctor luctus. Fusce vitae scelerisque velit. Sed sit amet tortor a nisi convallis pulvinar et eget sapien. Nulla condimentum auctor velit, a viverra nibh pellentesque eget. Aenean at lacus quam, lobortis posuere justo. Duis et diam in ligula rhoncus pellentesque. Morbi massa tellus, mattis nec condimentum ut, tempus eu lectus. In mi orci, luctus at pulvinar vel, scelerisque nec enim. Vestibulum vehicula odio in augue dignissim tincidunt. Integer ac velit ligula. Integer elit turpis, mattis eget ornare ut, eleifend in magna. Curabitur sagittis dui in felis ultricies gravida.
-
-</p>
-<p>
-Praesent adipiscing rhoncus rutrum. Aenean ultricies auctor risus at fringilla. Mauris quam lectus, ullamcorper sed ultricies at, interdum eget tellus. Vestibulum ac mi erat. Sed ac tellus erat, sed laoreet arcu. Fusce eget ipsum ac sem volutpat viverra. Suspendisse ac felis sit amet purus viverra luctus non eget ipsum. Praesent eleifend euismod tortor, vel malesuada felis consectetur ac. Nunc a mi sit amet nulla venenatis tincidunt. Morbi vitae nisl nulla, nec adipiscing sem. Nullam porttitor scelerisque urna, id dapibus diam malesuada vitae. Duis auctor eleifend lectus, a tempor odio aliquet quis. Nam eu est urna, nec ultricies lectus. Ut egestas aliquet nunc, et hendrerit erat vehicula non. Aliquam tempus faucibus arcu, at vulputate erat tempor eu. Quisque tempus, lectus adipiscing blandit scelerisque, magna felis eleifend odio, non volutpat felis enim sit amet leo. Mauris augue tortor, ultrices ac sagittis non, vulputate quis nisl.
-</p>
-<p>
-Fusce erat sem, dictum in bibendum ac, feugiat ut odio. Duis aliquam felis sit amet diam egestas consectetur. Phasellus consequat, mauris eget venenatis porta, velit sapien malesuada nibh, id dignissim ante tellus vitae lacus. Duis non nisl sit amet nunc euismod posuere. Donec eros erat, fringilla vel iaculis condimentum, vestibulum at neque. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aliquam lorem sapien, bibendum eu mollis nec, gravida dapibus lectus. Aenean pretium volutpat nunc a placerat. Nullam eget tellus quis ipsum ultrices ullamcorper non eu mauris. Donec volutpat tincidunt elit, sit amet cursus justo elementum quis. Mauris volutpat, enim sit amet tempor commodo, purus lacus luctus dui, sed aliquet ligula nisi vel diam. Donec est elit, lobortis at eleifend id, feugiat egestas massa. Fusce elementum sollicitudin adipiscing. Vivamus et dapibus ipsum. Morbi interdum libero a nisl dignissim sed facilisis ipsum lacinia.
-</p>
-<p>
-Cras a augue dui, vitae tincidunt enim. In hac habitasse platea dictumst. Proin nec magna sed nulla mollis tempus id ut lectus. Morbi volutpat ultricies ipsum, quis imperdiet libero tempor nec. Donec bibendum ornare blandit. Aliquam rutrum risus non turpis commodo non commodo erat molestie. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut fermentum, magna vel euismod convallis, mi magna vehicula velit, aliquet rhoncus ipsum massa et nunc. Nullam blandit purus non neque ullamcorper a aliquet nisl tristique. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed sit amet velit magna, sit amet rutrum dui. Donec elementum mi sed velit consectetur vulputate. Sed interdum adipiscing mattis.
-</p>
-Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam vitae urna quam. Fusce adipiscing erat eget magna malesuada vel mollis ligula ullamcorper. Donec pulvinar, libero et vehicula facilisis, odio orci fringilla magna, non ultricies ipsum justo a tellus. Proin facilisis magna vitae quam vestibulum tempor. Aenean semper placerat posuere. In nisi diam, ullamcorper sit amet viverra sed, pretium sed neque. Sed posuere vulputate mauris vitae placerat. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nam in odio elit, non tempor felis. Integer non iaculis ante. Sed erat mauris, aliquam nec consequat id, congue id libero. Maecenas elementum gravida tincidunt. Suspendisse lacinia enim sit amet nulla cursus pulvinar.
-</p>
-<p>
-Proin ut sem nulla, at cursus sapien. Duis sagittis lacus vitae justo mattis in sagittis ligula eleifend. Curabitur sit amet felis pharetra justo facilisis mollis eget nec massa. Sed nisi urna, semper lobortis pretium ac, interdum nec lacus. In gravida, leo sit amet vehicula malesuada, augue nunc consectetur nulla, vel tincidunt est nunc aliquet neque. Maecenas imperdiet eros id ligula tempor dapibus. Integer commodo metus sit amet quam vestibulum volutpat. In et lorem ac leo rhoncus auctor sit amet ut urna. Nulla sed nisl quis turpis vestibulum accumsan. Duis mollis aliquam sollicitudin. Pellentesque porta semper interdum. Sed eros orci, congue quis sollicitudin ut, rutrum vitae nibh. Nunc et leo non ligula interdum imperdiet. Integer tincidunt rhoncus ullamcorper. Curabitur et ullamcorper lorem. Ut at tellus eu metus congue sollicitudin eget at orci.
-</p>
-<p>
-Duis sem mauris, pulvinar quis placerat vel, aliquet non leo. Cras eros arcu, ullamcorper sit amet imperdiet at, blandit interdum augue. Phasellus non nunc ac ante condimentum tristique vitae sed urna. Integer nec sapien et dolor volutpat bibendum ac vitae justo. Aliquam gravida fermentum felis, nec dictum dui dictum ac. Maecenas eget magna leo. Phasellus ac nulla risus, dapibus ornare turpis. Morbi a massa tortor. Duis ac turpis lacus. Duis nibh metus, euismod quis ultrices vitae, sollicitudin vel leo. Nullam volutpat odio ac elit imperdiet gravida.
-</p>
-<p>
-Donec luctus magna id ipsum aliquam eget convallis tortor tristique. Etiam est quam, aliquam ac rutrum quis, pretium sed tortor. Aliquam lacus diam, rhoncus molestie convallis ut, luctus ac lacus. Nunc porttitor ante a ligula rutrum elementum. Cras dui tellus, pulvinar vel convallis sit amet, facilisis nec ipsum. Donec fermentum lectus lorem, id accumsan eros. Nunc semper laoreet lacus quis ullamcorper. Nunc luctus erat vitae orci sodales facilisis non ut felis. Aliquam pretium sapien sed enim adipiscing in feugiat est ornare. Aenean ultricies convallis tortor sit amet ullamcorper.
-</p>
-<p>
-Etiam ultricies elit non enim elementum aliquet. Vivamus quis fringilla mauris. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nunc blandit felis at massa interdum ac molestie lectus volutpat. Mauris commodo nibh id sem porta id feugiat ante euismod. Nullam fermentum libero varius turpis pharetra cursus ut sed lacus. Mauris molestie egestas augue eu bibendum. Quisque pulvinar, leo luctus vehicula faucibus, quam mi ornare dui, a rhoncus nisi eros nec dolor. Sed dictum ultricies ipsum eu ultrices. Etiam semper condimentum nibh in tempor.
-</p>
-<p>
-
-Vivamus interdum ligula nec neque sollicitudin ornare. Vestibulum a eros eget nisi accumsan hendrerit quis sit amet ipsum. Phasellus condimentum vestibulum felis eu hendrerit. Suspendisse in est tellus, et consequat ante. Nam at sapien lobortis risus dignissim malesuada. In dapibus lectus sed nibh adipiscing dictum. Nulla pellentesque convallis auctor. Suspendisse ut purus et nibh pulvinar tincidunt. Maecenas dapibus purus at odio commodo ac cursus risus luctus. Ut quis libero justo. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nullam vestibulum ipsum quis ante porttitor porta. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Ut in ante neque. Donec ante ante, porttitor non egestas a, pulvinar sed sem. Nam augue quam, fringilla sed egestas et, vulputate non nisi.
-</p>
-<p>
-Nunc sit amet arcu ac nulla bibendum sollicitudin. Pellentesque sed ligula urna. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Quisque egestas, tortor a vestibulum malesuada, ante dui condimentum massa, ac rutrum massa mauris non mi. Praesent in nisi leo. Sed ac augue nisl. Donec eget enim ut arcu posuere condimentum vel id magna. Vestibulum laoreet imperdiet massa, ut venenatis ante dapibus eu. Phasellus faucibus vestibulum eros mollis adipiscing. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque aliquet lectus at enim gravida tempus tincidunt mi porta. Sed vehicula molestie ligula, sed tincidunt diam suscipit vitae.
-</p>
-<p>
-Nullam euismod tempus ante, vel semper turpis pharetra eget. Nulla pretium ante et ipsum dapibus imperdiet. Praesent ipsum velit, gravida sed adipiscing id, condimentum in odio. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Fusce blandit vehicula felis, pretium ullamcorper leo tempor non. Nunc eget nisi nunc, posuere pellentesque enim. Nunc gravida orci quis odio semper ultricies. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque eu neque a sapien commodo placerat. Aenean non eros semper metus viverra porttitor. Integer vel tortor eu neque commodo ultrices eu quis tellus. Nam commodo sagittis dolor in consequat. Fusce hendrerit turpis eget leo rutrum ut scelerisque nibh condimentum. Fusce sit amet feugiat mauris. Maecenas elementum tellus nec augue rutrum mattis. Sed viverra tempor blandit. Pellentesque adipiscing tincidunt est sit amet tincidunt. Proin suscipit suscipit odio, eu pellentesque dolor pharetra non. Aliquam erat volutpat.
-</p>
-<p>
-Duis pellentesque, enim sed mollis congue, ante mauris feugiat nisi, bibendum euismod erat enim ac magna. Mauris risus nisl, sodales vel viverra ut, interdum sed neque. Nunc ac dignissim felis. Proin tincidunt orci elementum erat molestie suscipit. Cras suscipit, sem ac vehicula vehicula, lorem orci dictum nibh, ut bibendum odio sem non erat. Maecenas quis metus eget mauris feugiat porta a eu ipsum. Vivamus tortor purus, posuere ut luctus sed, ullamcorper feugiat neque. In hac habitasse platea dictumst. Vivamus nec justo vel lacus mattis pellentesque. Nunc vel gravida quam. Etiam at aliquam magna.
-</p>
-<p>
-Sed ac lacus ac felis auctor suscipit. Aliquam lacinia lectus ac nunc placerat aliquam accumsan neque interdum. Aenean in sapien sem. Suspendisse potenti. Aenean congue vulputate scelerisque. Proin eget eros tortor. Morbi rhoncus, mi vitae sollicitudin luctus, est orci porttitor turpis, vitae cursus est dui sed leo. Curabitur erat nunc, placerat bibendum tempus in, blandit eget ipsum. Cras in feugiat ipsum. Vestibulum dapibus quam nec odio pretium non dapibus purus dapibus. Pellentesque vehicula metus bibendum orci ultrices tincidunt. Sed fermentum, neque eget porta tempor, sem neque pulvinar ligula, vitae elementum massa metus eget nunc. Nunc sed orci eu purus sodales fringilla. Quisque aliquet arcu ac dolor ultrices fringilla. Nullam ornare tempus lorem, in mattis magna mollis laoreet. Vestibulum convallis arcu in purus lobortis et sollicitudin ipsum aliquet. Quisque risus est, sagittis eu aliquam ac, condimentum at massa. Fusce consectetur dignissim sem vel ornare. Maecenas posuere ultricies sollicitudin. Duis luctus, purus quis auctor egestas, diam felis scelerisque diam, a varius tellus erat a nunc.
-</p>
-<p>
-Phasellus id ante neque, eget volutpat risus. Vivamus scelerisque, nisi rutrum ultrices varius, sem quam suscipit purus, in elementum nibh nulla nec nisi. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Phasellus interdum hendrerit mi, nec cursus nisi tempor ac. Phasellus luctus ligula bibendum mauris iaculis id tempor odio volutpat. Nunc in augue metus. Suspendisse at libero at libero lacinia convallis eu vitae metus. Duis eget risus odio. Nam id mi tellus, non vulputate libero. In placerat dictum orci eu pellentesque. Etiam sed varius felis. Phasellus ut adipiscing leo. Morbi ante eros, interdum eget dapibus ac, varius congue nunc. Donec vulputate sapien id risus sodales sit amet pretium velit iaculis. Etiam ultrices tempor euismod.
-</p>
-
-<p>
-Praesent in turpis ut mauris cursus commodo. Mauris lectus tellus, congue sit amet dictum id, convallis ac nisi. Curabitur ante dolor, sagittis ac auctor ac, aliquet vel nisl. Nulla non porta sapien. Nunc non aliquet erat. Vestibulum euismod auctor volutpat. Mauris libero tellus, pharetra eget lacinia sit amet, viverra eget velit. Sed viverra varius velit at pharetra. Sed pharetra dolor sed erat interdum in placerat magna lacinia. Cras venenatis tellus non sapien egestas sollicitudin. Duis congue pharetra lacinia. Curabitur eu diam vel tortor rhoncus dignissim vel sed enim. Proin ut congue mi. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce viverra elit eu dolor tincidunt tempor vel nec magna. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;
-</p>
-<p>
-Sed ligula purus, tristique nec condimentum sed, facilisis ac augue. Integer volutpat velit urna, et posuere ligula. In tempus luctus dignissim. Duis augue neque, egestas ut tincidunt in, congue a enim. Aliquam ut odio dui, id congue tortor. Nullam venenatis erat non nulla tincidunt scelerisque. Morbi in urna ac nulla molestie scelerisque eu a nulla. Aliquam erat volutpat. Praesent dictum scelerisque lorem mattis vehicula. Quisque ut rutrum metus. Mauris pharetra ante vitae nunc mattis vulputate. Mauris molestie volutpat mauris, ut iaculis dui bibendum ac. Ut egestas laoreet est, eget mollis libero laoreet at. In sagittis vestibulum accumsan. Nam dapibus ultrices urna sit amet accumsan. Pellentesque id ultrices elit. Aliquam quis magna ut leo sagittis posuere sit amet id enim. Etiam congue eros sit amet nulla aliquam gravida. In accumsan lectus nibh. Proin volutpat pretium facilisis.
-</p>
-<p>
-Mauris pulvinar erat at quam egestas ac aliquet mi gravida. Integer pellentesque quam vel massa commodo vitae sollicitudin eros volutpat. Aenean mollis felis molestie quam placerat et elementum eros gravida. In hac habitasse platea dictumst. Mauris ullamcorper facilisis eros, nec rutrum mi auctor sed. Ut viverra, orci a viverra ultricies, turpis enim pellentesque urna, sit amet viverra metus enim ut justo. Donec aliquam, urna id condimentum rutrum, nibh nunc tristique magna, at luctus quam enim at turpis. Maecenas dapibus dui ac velit adipiscing fringilla. Nullam malesuada nunc vel lorem cursus sed congue felis lacinia. Pellentesque vehicula gravida est nec facilisis. Nullam imperdiet fringilla orci in dignissim. Praesent orci dolor, vestibulum eu auctor quis, tristique auctor mi. Nunc euismod dui sit amet metus malesuada feugiat. Fusce iaculis neque in velit interdum rhoncus. Aenean at risus ut arcu dapibus congue a tincidunt dolor. Donec porttitor lacus et urna vestibulum a sagittis nunc mollis.
-</p>
-<p>
-In metus tellus, eleifend id aliquet at, pulvinar ut tortor. Aliquam erat volutpat. Vivamus lacus magna, consequat vel euismod sed, viverra a ipsum. Praesent dapibus laoreet nisi, nec posuere massa commodo vel. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ullamcorper adipiscing ante, dapibus molestie velit cursus id. Nam cursus arcu consectetur lectus sollicitudin gravida. Maecenas urna sapien, fermentum sit amet consectetur at, feugiat ut massa. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer sit amet ante nec arcu bibendum bibendum ut ut justo. Nulla ut libero est.
-</p>
-<p>
-Aenean sem augue, malesuada quis elementum id, aliquet at turpis. Nam volutpat interdum purus, at dictum risus posuere rhoncus. Praesent metus diam, egestas in lacinia eu, tincidunt in nibh. Phasellus sollicitudin volutpat erat, sit amet mattis sapien fringilla in. Quisque rhoncus, felis a pellentesque dictum, arcu urna molestie sem, ut tincidunt nulla magna in enim. Vestibulum erat nulla, sollicitudin quis faucibus et, blandit quis est. Nam vehicula justo augue. Vivamus elementum sodales aliquet. Donec convallis neque sed dui euismod aliquet. Morbi elementum hendrerit odio, vel mollis felis dignissim vitae. Phasellus a diam lacus. Integer congue, mi vehicula egestas imperdiet, nulla mi commodo tortor, sit amet fermentum urna leo non dolor. Donec elementum elementum urna at sollicitudin. Vestibulum placerat tortor in nibh lobortis ac consectetur felis interdum. Integer faucibus diam nec magna porttitor sit amet dictum elit consectetur. Suspendisse risus velit, pellentesque eget viverra in, porta eget metus. Sed porta elit erat.
-</p>
-<p>
-Nulla facilisi. Aliquam vulputate dolor quis nisi auctor luctus. Fusce vitae scelerisque velit. Sed sit amet tortor a nisi convallis pulvinar et eget sapien. Nulla condimentum auctor velit, a viverra nibh pellentesque eget. Aenean at lacus quam, lobortis posuere justo. Duis et diam in ligula rhoncus pellentesque. Morbi massa tellus, mattis nec condimentum ut, tempus eu lectus. In mi orci, luctus at pulvinar vel, scelerisque nec enim. Vestibulum vehicula odio in augue dignissim tincidunt. Integer ac velit ligula. Integer elit turpis, mattis eget ornare ut, eleifend in magna. Curabitur sagittis dui in felis ultricies gravida.
-
-</p>
-<p>
-Praesent adipiscing rhoncus rutrum. Aenean ultricies auctor risus at fringilla. Mauris quam lectus, ullamcorper sed ultricies at, interdum eget tellus. Vestibulum ac mi erat. Sed ac tellus erat, sed laoreet arcu. Fusce eget ipsum ac sem volutpat viverra. Suspendisse ac felis sit amet purus viverra luctus non eget ipsum. Praesent eleifend euismod tortor, vel malesuada felis consectetur ac. Nunc a mi sit amet nulla venenatis tincidunt. Morbi vitae nisl nulla, nec adipiscing sem. Nullam porttitor scelerisque urna, id dapibus diam malesuada vitae. Duis auctor eleifend lectus, a tempor odio aliquet quis. Nam eu est urna, nec ultricies lectus. Ut egestas aliquet nunc, et hendrerit erat vehicula non. Aliquam tempus faucibus arcu, at vulputate erat tempor eu. Quisque tempus, lectus adipiscing blandit scelerisque, magna felis eleifend odio, non volutpat felis enim sit amet leo. Mauris augue tortor, ultrices ac sagittis non, vulputate quis nisl.
-</p>
-<p>
-Fusce erat sem, dictum in bibendum ac, feugiat ut odio. Duis aliquam felis sit amet diam egestas consectetur. Phasellus consequat, mauris eget venenatis porta, velit sapien malesuada nibh, id dignissim ante tellus vitae lacus. Duis non nisl sit amet nunc euismod posuere. Donec eros erat, fringilla vel iaculis condimentum, vestibulum at neque. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aliquam lorem sapien, bibendum eu mollis nec, gravida dapibus lectus. Aenean pretium volutpat nunc a placerat. Nullam eget tellus quis ipsum ultrices ullamcorper non eu mauris. Donec volutpat tincidunt elit, sit amet cursus justo elementum quis. Mauris volutpat, enim sit amet tempor commodo, purus lacus luctus dui, sed aliquet ligula nisi vel diam. Donec est elit, lobortis at eleifend id, feugiat egestas massa. Fusce elementum sollicitudin adipiscing. Vivamus et dapibus ipsum. Morbi interdum libero a nisl dignissim sed facilisis ipsum lacinia.
-</p>
-<p>
-Cras a augue dui, vitae tincidunt enim. In hac habitasse platea dictumst. Proin nec magna sed nulla mollis tempus id ut lectus. Morbi volutpat ultricies ipsum, quis imperdiet libero tempor nec. Donec bibendum ornare blandit. Aliquam rutrum risus non turpis commodo non commodo erat molestie. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut fermentum, magna vel euismod convallis, mi magna vehicula velit, aliquet rhoncus ipsum massa et nunc. Nullam blandit purus non neque ullamcorper a aliquet nisl tristique. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed sit amet velit magna, sit amet rutrum dui. Donec elementum mi sed velit consectetur vulputate. Sed interdum adipiscing mattis.
-</p>
-
-</body>
-</html>
diff --git a/tests/visual/compound/accordion_tabs.html b/tests/visual/compound/accordion_tabs.html
index ada8e84a7..2bb33238f 100644
--- a/tests/visual/compound/accordion_tabs.html
+++ b/tests/visual/compound/accordion_tabs.html
@@ -1,19 +1,19 @@
-<!DOCTYPE html>
+<!doctype html>
<html lang="en">
<head>
- <meta charset="UTF-8" />
+ <meta charset="utf-8">
<title>Compound Visual Test : Accordion in Tabs</title>
- <link rel="stylesheet" href="../visual.css" type="text/css" />
- <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css">
- <script type="text/javascript" src="../../../jquery-1.7.2.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.accordion.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.tabs.js"></script>
- <script type="text/javascript">
+ <link rel="stylesheet" href="../visual.css">
+ <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css">
+ <script src="../../../jquery-1.7.2.js"></script>
+ <script src="../../../ui/jquery.ui.core.js"></script>
+ <script src="../../../ui/jquery.ui.widget.js"></script>
+ <script src="../../../ui/jquery.ui.accordion.js"></script>
+ <script src="../../../ui/jquery.ui.tabs.js"></script>
+ <script>
$(function() {
- $('#tabs').tabs();
- $('#accordion-1, #accordion-2').accordion();
+ $( "#accordion-1, #accordion-2" ).accordion();
+ $( "#tabs" ).tabs();
});
</script>
</head>
@@ -26,7 +26,7 @@
</ul>
<div id="tabs-1">
<div id="accordion-1">
- <h3><a href="#">Accordion Header 1</a></h3>
+ <h3>Accordion Header 1</h3>
<div>
<p>Accordion Content 1</p>
<p>Accordion Content 1</p>
@@ -34,7 +34,7 @@
<p>Accordion Content 1</p>
<p>Accordion Content 1</p>
</div>
- <h3><a href="#">Accordion Header 2</a></h3>
+ <h3>Accordion Header 2</h3>
<div>
<p>Accordion Content 2</p>
<p>Accordion Content 2</p>
@@ -42,7 +42,7 @@
<p>Accordion Content 2</p>
<p>Accordion Content 2</p>
</div>
- <h3><a href="#">Accordion Header 3</a></h3>
+ <h3>Accordion Header 3</h3>
<div>
<p>Accordion Content 3</p>
<p>Accordion Content 3</p>
@@ -54,7 +54,7 @@
</div>
<div id="tabs-2">
<div id="accordion-2">
- <h3><a href="#">Accordion Header 1</a></h3>
+ <h3>Accordion Header 1</h3>
<div>
<p>Accordion Content 1</p>
<p>Accordion Content 1</p>
@@ -62,7 +62,7 @@
<p>Accordion Content 1</p>
<p>Accordion Content 1</p>
</div>
- <h3><a href="#">Accordion Header 2</a></h3>
+ <h3>Accordion Header 2</h3>
<div>
<p>Accordion Content 2</p>
<p>Accordion Content 2</p>
@@ -70,7 +70,7 @@
<p>Accordion Content 2</p>
<p>Accordion Content 2</p>
</div>
- <h3><a href="#">Accordion Header 3</a></h3>
+ <h3>Accordion Header 3</h3>
<div>
<p>Accordion Content 3</p>
<p>Accordion Content 3</p>
diff --git a/tests/visual/compound/datepicker_dialog.html b/tests/visual/compound/datepicker_dialog.html
index 885edb4a6..7a11880b1 100644
--- a/tests/visual/compound/datepicker_dialog.html
+++ b/tests/visual/compound/datepicker_dialog.html
@@ -1,23 +1,23 @@
-<!DOCTYPE html>
+<!doctype html>
<html lang="en">
<head>
- <meta charset="UTF-8" />
+ <meta charset="utf-8">
<title>Compound Visual Test : Datepicker in Dialog</title>
- <link rel="stylesheet" href="../visual.css" type="text/css" />
- <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css">
- <script type="text/javascript" src="../../../jquery-1.7.2.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.position.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.resizable.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.draggable.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.datepicker.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.dialog.js"></script>
- <script type="text/javascript">
+ <link rel="stylesheet" href="../visual.css">
+ <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css">
+ <script src="../../../jquery-1.7.2.js"></script>
+ <script src="../../../ui/jquery.ui.core.js"></script>
+ <script src="../../../ui/jquery.ui.widget.js"></script>
+ <script src="../../../ui/jquery.ui.mouse.js"></script>
+ <script src="../../../ui/jquery.ui.position.js"></script>
+ <script src="../../../ui/jquery.ui.resizable.js"></script>
+ <script src="../../../ui/jquery.ui.draggable.js"></script>
+ <script src="../../../ui/jquery.ui.datepicker.js"></script>
+ <script src="../../../ui/jquery.ui.dialog.js"></script>
+ <script>
$(function() {
- $('#datepicker').datepicker();
- $('#dialog').dialog();
+ $( "#datepicker" ).datepicker();
+ $( "#dialog" ).dialog();
});
</script>
</head>
@@ -27,131 +27,5 @@
<input id="datepicker">
</div>
-<p>
-Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam vitae urna quam. Fusce adipiscing erat eget magna malesuada vel mollis ligula ullamcorper. Donec pulvinar, libero et vehicula facilisis, odio orci fringilla magna, non ultricies ipsum justo a tellus. Proin facilisis magna vitae quam vestibulum tempor. Aenean semper placerat posuere. In nisi diam, ullamcorper sit amet viverra sed, pretium sed neque. Sed posuere vulputate mauris vitae placerat. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nam in odio elit, non tempor felis. Integer non iaculis ante. Sed erat mauris, aliquam nec consequat id, congue id libero. Maecenas elementum gravida tincidunt. Suspendisse lacinia enim sit amet nulla cursus pulvinar.
-</p>
-<p>
-Proin ut sem nulla, at cursus sapien. Duis sagittis lacus vitae justo mattis in sagittis ligula eleifend. Curabitur sit amet felis pharetra justo facilisis mollis eget nec massa. Sed nisi urna, semper lobortis pretium ac, interdum nec lacus. In gravida, leo sit amet vehicula malesuada, augue nunc consectetur nulla, vel tincidunt est nunc aliquet neque. Maecenas imperdiet eros id ligula tempor dapibus. Integer commodo metus sit amet quam vestibulum volutpat. In et lorem ac leo rhoncus auctor sit amet ut urna. Nulla sed nisl quis turpis vestibulum accumsan. Duis mollis aliquam sollicitudin. Pellentesque porta semper interdum. Sed eros orci, congue quis sollicitudin ut, rutrum vitae nibh. Nunc et leo non ligula interdum imperdiet. Integer tincidunt rhoncus ullamcorper. Curabitur et ullamcorper lorem. Ut at tellus eu metus congue sollicitudin eget at orci.
-</p>
-<p>
-Duis sem mauris, pulvinar quis placerat vel, aliquet non leo. Cras eros arcu, ullamcorper sit amet imperdiet at, blandit interdum augue. Phasellus non nunc ac ante condimentum tristique vitae sed urna. Integer nec sapien et dolor volutpat bibendum ac vitae justo. Aliquam gravida fermentum felis, nec dictum dui dictum ac. Maecenas eget magna leo. Phasellus ac nulla risus, dapibus ornare turpis. Morbi a massa tortor. Duis ac turpis lacus. Duis nibh metus, euismod quis ultrices vitae, sollicitudin vel leo. Nullam volutpat odio ac elit imperdiet gravida.
-</p>
-<p>
-Donec luctus magna id ipsum aliquam eget convallis tortor tristique. Etiam est quam, aliquam ac rutrum quis, pretium sed tortor. Aliquam lacus diam, rhoncus molestie convallis ut, luctus ac lacus. Nunc porttitor ante a ligula rutrum elementum. Cras dui tellus, pulvinar vel convallis sit amet, facilisis nec ipsum. Donec fermentum lectus lorem, id accumsan eros. Nunc semper laoreet lacus quis ullamcorper. Nunc luctus erat vitae orci sodales facilisis non ut felis. Aliquam pretium sapien sed enim adipiscing in feugiat est ornare. Aenean ultricies convallis tortor sit amet ullamcorper.
-</p>
-<p>
-Etiam ultricies elit non enim elementum aliquet. Vivamus quis fringilla mauris. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nunc blandit felis at massa interdum ac molestie lectus volutpat. Mauris commodo nibh id sem porta id feugiat ante euismod. Nullam fermentum libero varius turpis pharetra cursus ut sed lacus. Mauris molestie egestas augue eu bibendum. Quisque pulvinar, leo luctus vehicula faucibus, quam mi ornare dui, a rhoncus nisi eros nec dolor. Sed dictum ultricies ipsum eu ultrices. Etiam semper condimentum nibh in tempor.
-</p>
-<p>
-
-Vivamus interdum ligula nec neque sollicitudin ornare. Vestibulum a eros eget nisi accumsan hendrerit quis sit amet ipsum. Phasellus condimentum vestibulum felis eu hendrerit. Suspendisse in est tellus, et consequat ante. Nam at sapien lobortis risus dignissim malesuada. In dapibus lectus sed nibh adipiscing dictum. Nulla pellentesque convallis auctor. Suspendisse ut purus et nibh pulvinar tincidunt. Maecenas dapibus purus at odio commodo ac cursus risus luctus. Ut quis libero justo. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nullam vestibulum ipsum quis ante porttitor porta. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Ut in ante neque. Donec ante ante, porttitor non egestas a, pulvinar sed sem. Nam augue quam, fringilla sed egestas et, vulputate non nisi.
-</p>
-<p>
-Nunc sit amet arcu ac nulla bibendum sollicitudin. Pellentesque sed ligula urna. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Quisque egestas, tortor a vestibulum malesuada, ante dui condimentum massa, ac rutrum massa mauris non mi. Praesent in nisi leo. Sed ac augue nisl. Donec eget enim ut arcu posuere condimentum vel id magna. Vestibulum laoreet imperdiet massa, ut venenatis ante dapibus eu. Phasellus faucibus vestibulum eros mollis adipiscing. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque aliquet lectus at enim gravida tempus tincidunt mi porta. Sed vehicula molestie ligula, sed tincidunt diam suscipit vitae.
-</p>
-<p>
-Nullam euismod tempus ante, vel semper turpis pharetra eget. Nulla pretium ante et ipsum dapibus imperdiet. Praesent ipsum velit, gravida sed adipiscing id, condimentum in odio. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Fusce blandit vehicula felis, pretium ullamcorper leo tempor non. Nunc eget nisi nunc, posuere pellentesque enim. Nunc gravida orci quis odio semper ultricies. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque eu neque a sapien commodo placerat. Aenean non eros semper metus viverra porttitor. Integer vel tortor eu neque commodo ultrices eu quis tellus. Nam commodo sagittis dolor in consequat. Fusce hendrerit turpis eget leo rutrum ut scelerisque nibh condimentum. Fusce sit amet feugiat mauris. Maecenas elementum tellus nec augue rutrum mattis. Sed viverra tempor blandit. Pellentesque adipiscing tincidunt est sit amet tincidunt. Proin suscipit suscipit odio, eu pellentesque dolor pharetra non. Aliquam erat volutpat.
-</p>
-<p>
-Duis pellentesque, enim sed mollis congue, ante mauris feugiat nisi, bibendum euismod erat enim ac magna. Mauris risus nisl, sodales vel viverra ut, interdum sed neque. Nunc ac dignissim felis. Proin tincidunt orci elementum erat molestie suscipit. Cras suscipit, sem ac vehicula vehicula, lorem orci dictum nibh, ut bibendum odio sem non erat. Maecenas quis metus eget mauris feugiat porta a eu ipsum. Vivamus tortor purus, posuere ut luctus sed, ullamcorper feugiat neque. In hac habitasse platea dictumst. Vivamus nec justo vel lacus mattis pellentesque. Nunc vel gravida quam. Etiam at aliquam magna.
-</p>
-<p>
-Sed ac lacus ac felis auctor suscipit. Aliquam lacinia lectus ac nunc placerat aliquam accumsan neque interdum. Aenean in sapien sem. Suspendisse potenti. Aenean congue vulputate scelerisque. Proin eget eros tortor. Morbi rhoncus, mi vitae sollicitudin luctus, est orci porttitor turpis, vitae cursus est dui sed leo. Curabitur erat nunc, placerat bibendum tempus in, blandit eget ipsum. Cras in feugiat ipsum. Vestibulum dapibus quam nec odio pretium non dapibus purus dapibus. Pellentesque vehicula metus bibendum orci ultrices tincidunt. Sed fermentum, neque eget porta tempor, sem neque pulvinar ligula, vitae elementum massa metus eget nunc. Nunc sed orci eu purus sodales fringilla. Quisque aliquet arcu ac dolor ultrices fringilla. Nullam ornare tempus lorem, in mattis magna mollis laoreet. Vestibulum convallis arcu in purus lobortis et sollicitudin ipsum aliquet. Quisque risus est, sagittis eu aliquam ac, condimentum at massa. Fusce consectetur dignissim sem vel ornare. Maecenas posuere ultricies sollicitudin. Duis luctus, purus quis auctor egestas, diam felis scelerisque diam, a varius tellus erat a nunc.
-</p>
-<p>
-Phasellus id ante neque, eget volutpat risus. Vivamus scelerisque, nisi rutrum ultrices varius, sem quam suscipit purus, in elementum nibh nulla nec nisi. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Phasellus interdum hendrerit mi, nec cursus nisi tempor ac. Phasellus luctus ligula bibendum mauris iaculis id tempor odio volutpat. Nunc in augue metus. Suspendisse at libero at libero lacinia convallis eu vitae metus. Duis eget risus odio. Nam id mi tellus, non vulputate libero. In placerat dictum orci eu pellentesque. Etiam sed varius felis. Phasellus ut adipiscing leo. Morbi ante eros, interdum eget dapibus ac, varius congue nunc. Donec vulputate sapien id risus sodales sit amet pretium velit iaculis. Etiam ultrices tempor euismod.
-</p>
-
-<p>
-Praesent in turpis ut mauris cursus commodo. Mauris lectus tellus, congue sit amet dictum id, convallis ac nisi. Curabitur ante dolor, sagittis ac auctor ac, aliquet vel nisl. Nulla non porta sapien. Nunc non aliquet erat. Vestibulum euismod auctor volutpat. Mauris libero tellus, pharetra eget lacinia sit amet, viverra eget velit. Sed viverra varius velit at pharetra. Sed pharetra dolor sed erat interdum in placerat magna lacinia. Cras venenatis tellus non sapien egestas sollicitudin. Duis congue pharetra lacinia. Curabitur eu diam vel tortor rhoncus dignissim vel sed enim. Proin ut congue mi. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce viverra elit eu dolor tincidunt tempor vel nec magna. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;
-</p>
-<p>
-Sed ligula purus, tristique nec condimentum sed, facilisis ac augue. Integer volutpat velit urna, et posuere ligula. In tempus luctus dignissim. Duis augue neque, egestas ut tincidunt in, congue a enim. Aliquam ut odio dui, id congue tortor. Nullam venenatis erat non nulla tincidunt scelerisque. Morbi in urna ac nulla molestie scelerisque eu a nulla. Aliquam erat volutpat. Praesent dictum scelerisque lorem mattis vehicula. Quisque ut rutrum metus. Mauris pharetra ante vitae nunc mattis vulputate. Mauris molestie volutpat mauris, ut iaculis dui bibendum ac. Ut egestas laoreet est, eget mollis libero laoreet at. In sagittis vestibulum accumsan. Nam dapibus ultrices urna sit amet accumsan. Pellentesque id ultrices elit. Aliquam quis magna ut leo sagittis posuere sit amet id enim. Etiam congue eros sit amet nulla aliquam gravida. In accumsan lectus nibh. Proin volutpat pretium facilisis.
-</p>
-<p>
-Mauris pulvinar erat at quam egestas ac aliquet mi gravida. Integer pellentesque quam vel massa commodo vitae sollicitudin eros volutpat. Aenean mollis felis molestie quam placerat et elementum eros gravida. In hac habitasse platea dictumst. Mauris ullamcorper facilisis eros, nec rutrum mi auctor sed. Ut viverra, orci a viverra ultricies, turpis enim pellentesque urna, sit amet viverra metus enim ut justo. Donec aliquam, urna id condimentum rutrum, nibh nunc tristique magna, at luctus quam enim at turpis. Maecenas dapibus dui ac velit adipiscing fringilla. Nullam malesuada nunc vel lorem cursus sed congue felis lacinia. Pellentesque vehicula gravida est nec facilisis. Nullam imperdiet fringilla orci in dignissim. Praesent orci dolor, vestibulum eu auctor quis, tristique auctor mi. Nunc euismod dui sit amet metus malesuada feugiat. Fusce iaculis neque in velit interdum rhoncus. Aenean at risus ut arcu dapibus congue a tincidunt dolor. Donec porttitor lacus et urna vestibulum a sagittis nunc mollis.
-</p>
-<p>
-In metus tellus, eleifend id aliquet at, pulvinar ut tortor. Aliquam erat volutpat. Vivamus lacus magna, consequat vel euismod sed, viverra a ipsum. Praesent dapibus laoreet nisi, nec posuere massa commodo vel. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ullamcorper adipiscing ante, dapibus molestie velit cursus id. Nam cursus arcu consectetur lectus sollicitudin gravida. Maecenas urna sapien, fermentum sit amet consectetur at, feugiat ut massa. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer sit amet ante nec arcu bibendum bibendum ut ut justo. Nulla ut libero est.
-</p>
-<p>
-Aenean sem augue, malesuada quis elementum id, aliquet at turpis. Nam volutpat interdum purus, at dictum risus posuere rhoncus. Praesent metus diam, egestas in lacinia eu, tincidunt in nibh. Phasellus sollicitudin volutpat erat, sit amet mattis sapien fringilla in. Quisque rhoncus, felis a pellentesque dictum, arcu urna molestie sem, ut tincidunt nulla magna in enim. Vestibulum erat nulla, sollicitudin quis faucibus et, blandit quis est. Nam vehicula justo augue. Vivamus elementum sodales aliquet. Donec convallis neque sed dui euismod aliquet. Morbi elementum hendrerit odio, vel mollis felis dignissim vitae. Phasellus a diam lacus. Integer congue, mi vehicula egestas imperdiet, nulla mi commodo tortor, sit amet fermentum urna leo non dolor. Donec elementum elementum urna at sollicitudin. Vestibulum placerat tortor in nibh lobortis ac consectetur felis interdum. Integer faucibus diam nec magna porttitor sit amet dictum elit consectetur. Suspendisse risus velit, pellentesque eget viverra in, porta eget metus. Sed porta elit erat.
-</p>
-<p>
-Nulla facilisi. Aliquam vulputate dolor quis nisi auctor luctus. Fusce vitae scelerisque velit. Sed sit amet tortor a nisi convallis pulvinar et eget sapien. Nulla condimentum auctor velit, a viverra nibh pellentesque eget. Aenean at lacus quam, lobortis posuere justo. Duis et diam in ligula rhoncus pellentesque. Morbi massa tellus, mattis nec condimentum ut, tempus eu lectus. In mi orci, luctus at pulvinar vel, scelerisque nec enim. Vestibulum vehicula odio in augue dignissim tincidunt. Integer ac velit ligula. Integer elit turpis, mattis eget ornare ut, eleifend in magna. Curabitur sagittis dui in felis ultricies gravida.
-
-</p>
-<p>
-Praesent adipiscing rhoncus rutrum. Aenean ultricies auctor risus at fringilla. Mauris quam lectus, ullamcorper sed ultricies at, interdum eget tellus. Vestibulum ac mi erat. Sed ac tellus erat, sed laoreet arcu. Fusce eget ipsum ac sem volutpat viverra. Suspendisse ac felis sit amet purus viverra luctus non eget ipsum. Praesent eleifend euismod tortor, vel malesuada felis consectetur ac. Nunc a mi sit amet nulla venenatis tincidunt. Morbi vitae nisl nulla, nec adipiscing sem. Nullam porttitor scelerisque urna, id dapibus diam malesuada vitae. Duis auctor eleifend lectus, a tempor odio aliquet quis. Nam eu est urna, nec ultricies lectus. Ut egestas aliquet nunc, et hendrerit erat vehicula non. Aliquam tempus faucibus arcu, at vulputate erat tempor eu. Quisque tempus, lectus adipiscing blandit scelerisque, magna felis eleifend odio, non volutpat felis enim sit amet leo. Mauris augue tortor, ultrices ac sagittis non, vulputate quis nisl.
-</p>
-<p>
-Fusce erat sem, dictum in bibendum ac, feugiat ut odio. Duis aliquam felis sit amet diam egestas consectetur. Phasellus consequat, mauris eget venenatis porta, velit sapien malesuada nibh, id dignissim ante tellus vitae lacus. Duis non nisl sit amet nunc euismod posuere. Donec eros erat, fringilla vel iaculis condimentum, vestibulum at neque. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aliquam lorem sapien, bibendum eu mollis nec, gravida dapibus lectus. Aenean pretium volutpat nunc a placerat. Nullam eget tellus quis ipsum ultrices ullamcorper non eu mauris. Donec volutpat tincidunt elit, sit amet cursus justo elementum quis. Mauris volutpat, enim sit amet tempor commodo, purus lacus luctus dui, sed aliquet ligula nisi vel diam. Donec est elit, lobortis at eleifend id, feugiat egestas massa. Fusce elementum sollicitudin adipiscing. Vivamus et dapibus ipsum. Morbi interdum libero a nisl dignissim sed facilisis ipsum lacinia.
-</p>
-<p>
-Cras a augue dui, vitae tincidunt enim. In hac habitasse platea dictumst. Proin nec magna sed nulla mollis tempus id ut lectus. Morbi volutpat ultricies ipsum, quis imperdiet libero tempor nec. Donec bibendum ornare blandit. Aliquam rutrum risus non turpis commodo non commodo erat molestie. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut fermentum, magna vel euismod convallis, mi magna vehicula velit, aliquet rhoncus ipsum massa et nunc. Nullam blandit purus non neque ullamcorper a aliquet nisl tristique. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed sit amet velit magna, sit amet rutrum dui. Donec elementum mi sed velit consectetur vulputate. Sed interdum adipiscing mattis.
-</p>
-Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam vitae urna quam. Fusce adipiscing erat eget magna malesuada vel mollis ligula ullamcorper. Donec pulvinar, libero et vehicula facilisis, odio orci fringilla magna, non ultricies ipsum justo a tellus. Proin facilisis magna vitae quam vestibulum tempor. Aenean semper placerat posuere. In nisi diam, ullamcorper sit amet viverra sed, pretium sed neque. Sed posuere vulputate mauris vitae placerat. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nam in odio elit, non tempor felis. Integer non iaculis ante. Sed erat mauris, aliquam nec consequat id, congue id libero. Maecenas elementum gravida tincidunt. Suspendisse lacinia enim sit amet nulla cursus pulvinar.
-</p>
-<p>
-Proin ut sem nulla, at cursus sapien. Duis sagittis lacus vitae justo mattis in sagittis ligula eleifend. Curabitur sit amet felis pharetra justo facilisis mollis eget nec massa. Sed nisi urna, semper lobortis pretium ac, interdum nec lacus. In gravida, leo sit amet vehicula malesuada, augue nunc consectetur nulla, vel tincidunt est nunc aliquet neque. Maecenas imperdiet eros id ligula tempor dapibus. Integer commodo metus sit amet quam vestibulum volutpat. In et lorem ac leo rhoncus auctor sit amet ut urna. Nulla sed nisl quis turpis vestibulum accumsan. Duis mollis aliquam sollicitudin. Pellentesque porta semper interdum. Sed eros orci, congue quis sollicitudin ut, rutrum vitae nibh. Nunc et leo non ligula interdum imperdiet. Integer tincidunt rhoncus ullamcorper. Curabitur et ullamcorper lorem. Ut at tellus eu metus congue sollicitudin eget at orci.
-</p>
-<p>
-Duis sem mauris, pulvinar quis placerat vel, aliquet non leo. Cras eros arcu, ullamcorper sit amet imperdiet at, blandit interdum augue. Phasellus non nunc ac ante condimentum tristique vitae sed urna. Integer nec sapien et dolor volutpat bibendum ac vitae justo. Aliquam gravida fermentum felis, nec dictum dui dictum ac. Maecenas eget magna leo. Phasellus ac nulla risus, dapibus ornare turpis. Morbi a massa tortor. Duis ac turpis lacus. Duis nibh metus, euismod quis ultrices vitae, sollicitudin vel leo. Nullam volutpat odio ac elit imperdiet gravida.
-</p>
-<p>
-Donec luctus magna id ipsum aliquam eget convallis tortor tristique. Etiam est quam, aliquam ac rutrum quis, pretium sed tortor. Aliquam lacus diam, rhoncus molestie convallis ut, luctus ac lacus. Nunc porttitor ante a ligula rutrum elementum. Cras dui tellus, pulvinar vel convallis sit amet, facilisis nec ipsum. Donec fermentum lectus lorem, id accumsan eros. Nunc semper laoreet lacus quis ullamcorper. Nunc luctus erat vitae orci sodales facilisis non ut felis. Aliquam pretium sapien sed enim adipiscing in feugiat est ornare. Aenean ultricies convallis tortor sit amet ullamcorper.
-</p>
-<p>
-Etiam ultricies elit non enim elementum aliquet. Vivamus quis fringilla mauris. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nunc blandit felis at massa interdum ac molestie lectus volutpat. Mauris commodo nibh id sem porta id feugiat ante euismod. Nullam fermentum libero varius turpis pharetra cursus ut sed lacus. Mauris molestie egestas augue eu bibendum. Quisque pulvinar, leo luctus vehicula faucibus, quam mi ornare dui, a rhoncus nisi eros nec dolor. Sed dictum ultricies ipsum eu ultrices. Etiam semper condimentum nibh in tempor.
-</p>
-<p>
-
-Vivamus interdum ligula nec neque sollicitudin ornare. Vestibulum a eros eget nisi accumsan hendrerit quis sit amet ipsum. Phasellus condimentum vestibulum felis eu hendrerit. Suspendisse in est tellus, et consequat ante. Nam at sapien lobortis risus dignissim malesuada. In dapibus lectus sed nibh adipiscing dictum. Nulla pellentesque convallis auctor. Suspendisse ut purus et nibh pulvinar tincidunt. Maecenas dapibus purus at odio commodo ac cursus risus luctus. Ut quis libero justo. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nullam vestibulum ipsum quis ante porttitor porta. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Ut in ante neque. Donec ante ante, porttitor non egestas a, pulvinar sed sem. Nam augue quam, fringilla sed egestas et, vulputate non nisi.
-</p>
-<p>
-Nunc sit amet arcu ac nulla bibendum sollicitudin. Pellentesque sed ligula urna. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Quisque egestas, tortor a vestibulum malesuada, ante dui condimentum massa, ac rutrum massa mauris non mi. Praesent in nisi leo. Sed ac augue nisl. Donec eget enim ut arcu posuere condimentum vel id magna. Vestibulum laoreet imperdiet massa, ut venenatis ante dapibus eu. Phasellus faucibus vestibulum eros mollis adipiscing. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque aliquet lectus at enim gravida tempus tincidunt mi porta. Sed vehicula molestie ligula, sed tincidunt diam suscipit vitae.
-</p>
-<p>
-Nullam euismod tempus ante, vel semper turpis pharetra eget. Nulla pretium ante et ipsum dapibus imperdiet. Praesent ipsum velit, gravida sed adipiscing id, condimentum in odio. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Fusce blandit vehicula felis, pretium ullamcorper leo tempor non. Nunc eget nisi nunc, posuere pellentesque enim. Nunc gravida orci quis odio semper ultricies. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque eu neque a sapien commodo placerat. Aenean non eros semper metus viverra porttitor. Integer vel tortor eu neque commodo ultrices eu quis tellus. Nam commodo sagittis dolor in consequat. Fusce hendrerit turpis eget leo rutrum ut scelerisque nibh condimentum. Fusce sit amet feugiat mauris. Maecenas elementum tellus nec augue rutrum mattis. Sed viverra tempor blandit. Pellentesque adipiscing tincidunt est sit amet tincidunt. Proin suscipit suscipit odio, eu pellentesque dolor pharetra non. Aliquam erat volutpat.
-</p>
-<p>
-Duis pellentesque, enim sed mollis congue, ante mauris feugiat nisi, bibendum euismod erat enim ac magna. Mauris risus nisl, sodales vel viverra ut, interdum sed neque. Nunc ac dignissim felis. Proin tincidunt orci elementum erat molestie suscipit. Cras suscipit, sem ac vehicula vehicula, lorem orci dictum nibh, ut bibendum odio sem non erat. Maecenas quis metus eget mauris feugiat porta a eu ipsum. Vivamus tortor purus, posuere ut luctus sed, ullamcorper feugiat neque. In hac habitasse platea dictumst. Vivamus nec justo vel lacus mattis pellentesque. Nunc vel gravida quam. Etiam at aliquam magna.
-</p>
-<p>
-Sed ac lacus ac felis auctor suscipit. Aliquam lacinia lectus ac nunc placerat aliquam accumsan neque interdum. Aenean in sapien sem. Suspendisse potenti. Aenean congue vulputate scelerisque. Proin eget eros tortor. Morbi rhoncus, mi vitae sollicitudin luctus, est orci porttitor turpis, vitae cursus est dui sed leo. Curabitur erat nunc, placerat bibendum tempus in, blandit eget ipsum. Cras in feugiat ipsum. Vestibulum dapibus quam nec odio pretium non dapibus purus dapibus. Pellentesque vehicula metus bibendum orci ultrices tincidunt. Sed fermentum, neque eget porta tempor, sem neque pulvinar ligula, vitae elementum massa metus eget nunc. Nunc sed orci eu purus sodales fringilla. Quisque aliquet arcu ac dolor ultrices fringilla. Nullam ornare tempus lorem, in mattis magna mollis laoreet. Vestibulum convallis arcu in purus lobortis et sollicitudin ipsum aliquet. Quisque risus est, sagittis eu aliquam ac, condimentum at massa. Fusce consectetur dignissim sem vel ornare. Maecenas posuere ultricies sollicitudin. Duis luctus, purus quis auctor egestas, diam felis scelerisque diam, a varius tellus erat a nunc.
-</p>
-<p>
-Phasellus id ante neque, eget volutpat risus. Vivamus scelerisque, nisi rutrum ultrices varius, sem quam suscipit purus, in elementum nibh nulla nec nisi. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Phasellus interdum hendrerit mi, nec cursus nisi tempor ac. Phasellus luctus ligula bibendum mauris iaculis id tempor odio volutpat. Nunc in augue metus. Suspendisse at libero at libero lacinia convallis eu vitae metus. Duis eget risus odio. Nam id mi tellus, non vulputate libero. In placerat dictum orci eu pellentesque. Etiam sed varius felis. Phasellus ut adipiscing leo. Morbi ante eros, interdum eget dapibus ac, varius congue nunc. Donec vulputate sapien id risus sodales sit amet pretium velit iaculis. Etiam ultrices tempor euismod.
-</p>
-
-<p>
-Praesent in turpis ut mauris cursus commodo. Mauris lectus tellus, congue sit amet dictum id, convallis ac nisi. Curabitur ante dolor, sagittis ac auctor ac, aliquet vel nisl. Nulla non porta sapien. Nunc non aliquet erat. Vestibulum euismod auctor volutpat. Mauris libero tellus, pharetra eget lacinia sit amet, viverra eget velit. Sed viverra varius velit at pharetra. Sed pharetra dolor sed erat interdum in placerat magna lacinia. Cras venenatis tellus non sapien egestas sollicitudin. Duis congue pharetra lacinia. Curabitur eu diam vel tortor rhoncus dignissim vel sed enim. Proin ut congue mi. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce viverra elit eu dolor tincidunt tempor vel nec magna. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;
-</p>
-<p>
-Sed ligula purus, tristique nec condimentum sed, facilisis ac augue. Integer volutpat velit urna, et posuere ligula. In tempus luctus dignissim. Duis augue neque, egestas ut tincidunt in, congue a enim. Aliquam ut odio dui, id congue tortor. Nullam venenatis erat non nulla tincidunt scelerisque. Morbi in urna ac nulla molestie scelerisque eu a nulla. Aliquam erat volutpat. Praesent dictum scelerisque lorem mattis vehicula. Quisque ut rutrum metus. Mauris pharetra ante vitae nunc mattis vulputate. Mauris molestie volutpat mauris, ut iaculis dui bibendum ac. Ut egestas laoreet est, eget mollis libero laoreet at. In sagittis vestibulum accumsan. Nam dapibus ultrices urna sit amet accumsan. Pellentesque id ultrices elit. Aliquam quis magna ut leo sagittis posuere sit amet id enim. Etiam congue eros sit amet nulla aliquam gravida. In accumsan lectus nibh. Proin volutpat pretium facilisis.
-</p>
-<p>
-Mauris pulvinar erat at quam egestas ac aliquet mi gravida. Integer pellentesque quam vel massa commodo vitae sollicitudin eros volutpat. Aenean mollis felis molestie quam placerat et elementum eros gravida. In hac habitasse platea dictumst. Mauris ullamcorper facilisis eros, nec rutrum mi auctor sed. Ut viverra, orci a viverra ultricies, turpis enim pellentesque urna, sit amet viverra metus enim ut justo. Donec aliquam, urna id condimentum rutrum, nibh nunc tristique magna, at luctus quam enim at turpis. Maecenas dapibus dui ac velit adipiscing fringilla. Nullam malesuada nunc vel lorem cursus sed congue felis lacinia. Pellentesque vehicula gravida est nec facilisis. Nullam imperdiet fringilla orci in dignissim. Praesent orci dolor, vestibulum eu auctor quis, tristique auctor mi. Nunc euismod dui sit amet metus malesuada feugiat. Fusce iaculis neque in velit interdum rhoncus. Aenean at risus ut arcu dapibus congue a tincidunt dolor. Donec porttitor lacus et urna vestibulum a sagittis nunc mollis.
-</p>
-<p>
-In metus tellus, eleifend id aliquet at, pulvinar ut tortor. Aliquam erat volutpat. Vivamus lacus magna, consequat vel euismod sed, viverra a ipsum. Praesent dapibus laoreet nisi, nec posuere massa commodo vel. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ullamcorper adipiscing ante, dapibus molestie velit cursus id. Nam cursus arcu consectetur lectus sollicitudin gravida. Maecenas urna sapien, fermentum sit amet consectetur at, feugiat ut massa. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer sit amet ante nec arcu bibendum bibendum ut ut justo. Nulla ut libero est.
-</p>
-<p>
-Aenean sem augue, malesuada quis elementum id, aliquet at turpis. Nam volutpat interdum purus, at dictum risus posuere rhoncus. Praesent metus diam, egestas in lacinia eu, tincidunt in nibh. Phasellus sollicitudin volutpat erat, sit amet mattis sapien fringilla in. Quisque rhoncus, felis a pellentesque dictum, arcu urna molestie sem, ut tincidunt nulla magna in enim. Vestibulum erat nulla, sollicitudin quis faucibus et, blandit quis est. Nam vehicula justo augue. Vivamus elementum sodales aliquet. Donec convallis neque sed dui euismod aliquet. Morbi elementum hendrerit odio, vel mollis felis dignissim vitae. Phasellus a diam lacus. Integer congue, mi vehicula egestas imperdiet, nulla mi commodo tortor, sit amet fermentum urna leo non dolor. Donec elementum elementum urna at sollicitudin. Vestibulum placerat tortor in nibh lobortis ac consectetur felis interdum. Integer faucibus diam nec magna porttitor sit amet dictum elit consectetur. Suspendisse risus velit, pellentesque eget viverra in, porta eget metus. Sed porta elit erat.
-</p>
-<p>
-Nulla facilisi. Aliquam vulputate dolor quis nisi auctor luctus. Fusce vitae scelerisque velit. Sed sit amet tortor a nisi convallis pulvinar et eget sapien. Nulla condimentum auctor velit, a viverra nibh pellentesque eget. Aenean at lacus quam, lobortis posuere justo. Duis et diam in ligula rhoncus pellentesque. Morbi massa tellus, mattis nec condimentum ut, tempus eu lectus. In mi orci, luctus at pulvinar vel, scelerisque nec enim. Vestibulum vehicula odio in augue dignissim tincidunt. Integer ac velit ligula. Integer elit turpis, mattis eget ornare ut, eleifend in magna. Curabitur sagittis dui in felis ultricies gravida.
-
-</p>
-<p>
-Praesent adipiscing rhoncus rutrum. Aenean ultricies auctor risus at fringilla. Mauris quam lectus, ullamcorper sed ultricies at, interdum eget tellus. Vestibulum ac mi erat. Sed ac tellus erat, sed laoreet arcu. Fusce eget ipsum ac sem volutpat viverra. Suspendisse ac felis sit amet purus viverra luctus non eget ipsum. Praesent eleifend euismod tortor, vel malesuada felis consectetur ac. Nunc a mi sit amet nulla venenatis tincidunt. Morbi vitae nisl nulla, nec adipiscing sem. Nullam porttitor scelerisque urna, id dapibus diam malesuada vitae. Duis auctor eleifend lectus, a tempor odio aliquet quis. Nam eu est urna, nec ultricies lectus. Ut egestas aliquet nunc, et hendrerit erat vehicula non. Aliquam tempus faucibus arcu, at vulputate erat tempor eu. Quisque tempus, lectus adipiscing blandit scelerisque, magna felis eleifend odio, non volutpat felis enim sit amet leo. Mauris augue tortor, ultrices ac sagittis non, vulputate quis nisl.
-</p>
-<p>
-Fusce erat sem, dictum in bibendum ac, feugiat ut odio. Duis aliquam felis sit amet diam egestas consectetur. Phasellus consequat, mauris eget venenatis porta, velit sapien malesuada nibh, id dignissim ante tellus vitae lacus. Duis non nisl sit amet nunc euismod posuere. Donec eros erat, fringilla vel iaculis condimentum, vestibulum at neque. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aliquam lorem sapien, bibendum eu mollis nec, gravida dapibus lectus. Aenean pretium volutpat nunc a placerat. Nullam eget tellus quis ipsum ultrices ullamcorper non eu mauris. Donec volutpat tincidunt elit, sit amet cursus justo elementum quis. Mauris volutpat, enim sit amet tempor commodo, purus lacus luctus dui, sed aliquet ligula nisi vel diam. Donec est elit, lobortis at eleifend id, feugiat egestas massa. Fusce elementum sollicitudin adipiscing. Vivamus et dapibus ipsum. Morbi interdum libero a nisl dignissim sed facilisis ipsum lacinia.
-</p>
-<p>
-Cras a augue dui, vitae tincidunt enim. In hac habitasse platea dictumst. Proin nec magna sed nulla mollis tempus id ut lectus. Morbi volutpat ultricies ipsum, quis imperdiet libero tempor nec. Donec bibendum ornare blandit. Aliquam rutrum risus non turpis commodo non commodo erat molestie. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut fermentum, magna vel euismod convallis, mi magna vehicula velit, aliquet rhoncus ipsum massa et nunc. Nullam blandit purus non neque ullamcorper a aliquet nisl tristique. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed sit amet velit magna, sit amet rutrum dui. Donec elementum mi sed velit consectetur vulputate. Sed interdum adipiscing mattis.
-</p>
-
</body>
</html>
diff --git a/tests/visual/compound/dialog_widgets.html b/tests/visual/compound/dialog_widgets.html
new file mode 100644
index 000000000..bd8c237fc
--- /dev/null
+++ b/tests/visual/compound/dialog_widgets.html
@@ -0,0 +1,101 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>Compound Visual Test : All Widgets in Dialog</title>
+ <link rel="stylesheet" href="../visual.css">
+ <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css">
+ <script src="../../../jquery-1.7.2.js"></script>
+ <script src="../../../ui/jquery.ui.core.js"></script>
+ <script src="../../../ui/jquery.ui.widget.js"></script>
+ <script src="../../../ui/jquery.ui.mouse.js"></script>
+ <script src="../../../ui/jquery.ui.position.js"></script>
+ <script src="../../../ui/jquery.ui.menu.js"></script>
+ <script src="../../../ui/jquery.ui.resizable.js"></script>
+ <script src="../../../ui/jquery.ui.draggable.js"></script>
+ <script src="../../../ui/jquery.ui.accordion.js"></script>
+ <script src="../../../ui/jquery.ui.autocomplete.js"></script>
+ <script src="../../../ui/jquery.ui.button.js"></script>
+ <script src="../../../ui/jquery.ui.datepicker.js"></script>
+ <script src="../../../ui/jquery.ui.dialog.js"></script>
+ <script src="../../../ui/jquery.ui.progressbar.js"></script>
+ <script src="../../../ui/jquery.ui.slider.js"></script>
+ <script src="../../../ui/jquery.ui.tabs.js"></script>
+ <script src="../../../ui/jquery.ui.tooltip.js"></script>
+ <script>
+ $(function() {
+ $( "[title]" ).tooltip();
+ $( "#accordion" ).accordion();
+ $( "#autocomplete" ).autocomplete({
+ source: [ "c++", "java", "php", "coldfusion", "javascript", "asp", "ruby", "python", "c", "scala", "groovy", "haskell", "perl" ]
+ });
+ $( "button" ).button().click(function() {
+ $( "#dialog2" ).dialog( "open" );
+ });
+ $( "#datepicker" ).datepicker();
+ $( "#progressbar" ).progressbar({
+ value: 30
+ });
+ $( "#slider" ).slider({
+ animate: true,
+ value: 30,
+ slide: function(event, ui) {
+ $( "#progress" ).val( ui.value );
+ $( "#progressbar" ).progressbar( "option", "value", ui.value );
+ }
+ });
+ $( "#tabs" ).tabs();
+ $( "#dialog" ).dialog();
+ $( "#dialog2" ).dialog({
+ autoOpen: false,
+ width: 100,
+ height: 75,
+ modal: true
+ });
+ });
+ </script>
+</head>
+<body>
+
+<div id="dialog">
+ <div id="accordion">
+ <h3>Accordion Header 1</h3>
+ <div>
+ Accordion Content 1
+ </div>
+ <h3>Accordion Header 2</h3>
+ <div>
+ Accordion Content 2
+ </div>
+ <h3>Accordion Header 3</h3>
+ <div>
+ Accordion Content 3
+ </div>
+ </div>
+ <input id="autocomplete">
+ <button>A Button</button>
+ <input id="datepicker">
+ <button>Another button</button>
+ <div>
+ <label for="progress">Progress: <input title="The progress we made so far" id="progress"></label>
+ </div>
+ <div id="progressbar">
+ </div>
+ <div id="slider" title="Sliding progress..."></div>
+ <div id="tabs">
+ <ul>
+ <li><a href="#tabs-1">First</a></li>
+ <li><a href="#tabs-2">Second</a></li>
+ <li><a href="#tabs-3">Third</a></li>
+ </ul>
+ <div id="tabs-1">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
+ <div id="tabs-2">Phasellus mattis tincidunt nibh.</div>
+ <div id="tabs-3">Nam dui erat, auctor a, dignissim quis, sollicitudin eu, felis. Pellentesque nisi urna, interdum eget, sagittis et, consequat vestibulum, lacus. Mauris porttitor ullamcorper augue.</div>
+ </div>
+</div>
+<div id="dialog2">
+ Yay, another dialog.
+</div>
+
+</body>
+</html>
diff --git a/tests/visual/compound/draggable_accordion.html b/tests/visual/compound/draggable_accordion.html
index a78221142..65534112f 100644
--- a/tests/visual/compound/draggable_accordion.html
+++ b/tests/visual/compound/draggable_accordion.html
@@ -1,25 +1,24 @@
-<!DOCTYPE html>
+<!doctype html>
<html lang="en">
<head>
- <meta charset="UTF-8" />
+ <meta charset="utf-8">
<title>Compound Visual Test : Draggable in Accordion</title>
- <link rel="stylesheet" href="../visual.css" type="text/css" />
- <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css">
- <script type="text/javascript" src="../../../jquery-1.7.2.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.accordion.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.draggable.js"></script>
- <style type="text/css">
+ <link rel="stylesheet" href="../visual.css">
+ <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css">
+ <script src="../../../jquery-1.7.2.js"></script>
+ <script src="../../../ui/jquery.ui.core.js"></script>
+ <script src="../../../ui/jquery.ui.widget.js"></script>
+ <script src="../../../ui/jquery.ui.mouse.js"></script>
+ <script src="../../../ui/jquery.ui.accordion.js"></script>
+ <script src="../../../ui/jquery.ui.draggable.js"></script>
+ <style>
.draggable {
width: 10em;
margin: 0.5em;
}
</style>
- <script type="text/javascript">
+ <script>
$(function() {
- $( "#accordion" ).accordion();
$( ".draggable" ).addClass( "ui-widget ui-widget-content ui-corner-all" )
$( "#first .draggable" ).draggable();
$( "#second .draggable" ).draggable({
@@ -29,13 +28,14 @@
helper: "clone",
appendTo: "body"
});
+ $( "#accordion" ).accordion();
});
</script>
</head>
<body>
<div id="accordion">
- <h3><a href="#">.draggable()</a></h3>
+ <h3>.draggable()</h3>
<div id="first">
<div class="draggable">Draggable 1-1</div>
<div class="draggable">Draggable 1-2</div>
@@ -43,7 +43,7 @@
<div class="draggable">Draggable 1-4</div>
<div class="draggable">Draggable 1-5</div>
</div>
- <h3><a href="#">.draggable({ appendTo: "body" })</a></h3>
+ <h3>.draggable({ appendTo: "body" })</h3>
<div id="second">
<div class="draggable">Draggable 2-1</div>
<div class="draggable">Draggable 2-2</div>
@@ -51,7 +51,7 @@
<div class="draggable">Draggable 2-4</div>
<div class="draggable">Draggable 2-5</div>
</div>
- <h3><a href="#">.draggable({ helper: "clone", appendTo: "body" })</a></h3>
+ <h3>.draggable({ helper: "clone", appendTo: "body" })</h3>
<div id="third">
<div class="draggable">Draggable 3-1</div>
<div class="draggable">Draggable 3-2</div>
diff --git a/tests/visual/compound/draggable_accordion_accordion_tabs_draggable.html b/tests/visual/compound/draggable_accordion_accordion_tabs_draggable.html
index cced484ef..a73b890ec 100644
--- a/tests/visual/compound/draggable_accordion_accordion_tabs_draggable.html
+++ b/tests/visual/compound/draggable_accordion_accordion_tabs_draggable.html
@@ -1,18 +1,18 @@
-<!DOCTYPE html>
+<!doctype html>
<html lang="en">
<head>
- <meta charset="UTF-8" />
+ <meta charset="utf-8">
<title>Compound Visual Test : Draggable in Accordion</title>
- <link rel="stylesheet" href="../visual.css" type="text/css" />
- <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css">
- <script type="text/javascript" src="../../../jquery-1.7.2.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.accordion.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.draggable.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.tabs.js"></script>
- <style type="text/css">
+ <link rel="stylesheet" href="../visual.css">
+ <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css">
+ <script src="../../../jquery-1.7.2.js"></script>
+ <script src="../../../ui/jquery.ui.core.js"></script>
+ <script src="../../../ui/jquery.ui.widget.js"></script>
+ <script src="../../../ui/jquery.ui.mouse.js"></script>
+ <script src="../../../ui/jquery.ui.accordion.js"></script>
+ <script src="../../../ui/jquery.ui.draggable.js"></script>
+ <script src="../../../ui/jquery.ui.tabs.js"></script>
+ <style>
#main-draggable {
width: 300px;
position: absolute;
@@ -27,22 +27,20 @@
margin: 0.5em;
}
</style>
- <script type="text/javascript">
+ <script>
$(function() {
- $( ".draggable" ).addClass( "ui-widget ui-widget-content ui-corner-all" )
- $( ".draggable" ).draggable({
- helper: "clone",
- appendTo: "body"
- });
-
- // PROBLEM: nested accordions must be initialized before outer accordion
+ $( ".draggable" )
+ .addClass( "ui-widget ui-widget-content ui-corner-all" )
+ .draggable({
+ helper: "clone",
+ appendTo: "body"
+ });
+
$( "#accordion > div" ).accordion();
$( "#accordion" ).accordion();
-
-
- // PROBLEM: nested widgets must be initialized before tabs
+
$( "#tabs" ).tabs();
-
+
$( "#main-draggable" ).draggable({
handle: "#main-draggable-handle"
});
@@ -62,9 +60,9 @@
</div>
<div id="tabs-2">
<div id="accordion">
- <h3><a>Accordion Group 1</a></h3>
+ <h3>Accordion Group 1</h3>
<div id="accordion-1-1">
- <h3><a href="#">Header 1-1</a></h3>
+ <h3>Header 1-1</h3>
<div>
<div class="draggable">Draggable 1-1</div>
<div class="draggable">Draggable 1-2</div>
@@ -72,7 +70,7 @@
<div class="draggable">Draggable 1-4</div>
<div class="draggable">Draggable 1-5</div>
</div>
- <h3><a href="#">Header 1-2</a></h3>
+ <h3>Header 1-2</h3>
<div>
<div class="draggable">Draggable 2-1</div>
<div class="draggable">Draggable 2-2</div>
@@ -81,9 +79,9 @@
<div class="draggable">Draggable 2-5</div>
</div>
</div>
- <h3><a>Accordion Group 2</a></h3>
+ <h3>Accordion Group 2</h3>
<div id="accordion-1-2">
- <h3><a href="#">Header 2-1</a></h3>
+ <h3>Header 2-1</h3>
<div>
<div class="draggable">Draggable 1-1</div>
<div class="draggable">Draggable 1-2</div>
@@ -91,7 +89,7 @@
<div class="draggable">Draggable 1-4</div>
<div class="draggable">Draggable 1-5</div>
</div>
- <h3><a href="#">Header 2-2</a></h3>
+ <h3>Header 2-2</h3>
<div>
<div class="draggable">Draggable 2-1</div>
<div class="draggable">Draggable 2-2</div>
diff --git a/tests/visual/compound/sortable_accordion_sortable_tabs.html b/tests/visual/compound/sortable_accordion_sortable_tabs.html
index ac90f1a09..60990bce7 100644
--- a/tests/visual/compound/sortable_accordion_sortable_tabs.html
+++ b/tests/visual/compound/sortable_accordion_sortable_tabs.html
@@ -1,18 +1,18 @@
-<!DOCTYPE html>
+<!doctype html>
<html lang="en">
<head>
- <meta charset="UTF-8" />
+ <meta charset="utf-8">
<title>Compound Visual Test : Accordion in Tabs</title>
- <link rel="stylesheet" href="../visual.css" type="text/css" />
- <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css">
- <script type="text/javascript" src="../../../jquery-1.7.2.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.sortable.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.accordion.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.tabs.js"></script>
- <script type="text/javascript">
+ <link rel="stylesheet" href="../visual.css">
+ <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css">
+ <script src="../../../jquery-1.7.2.js"></script>
+ <script src="../../../ui/jquery.ui.core.js"></script>
+ <script src="../../../ui/jquery.ui.widget.js"></script>
+ <script src="../../../ui/jquery.ui.mouse.js"></script>
+ <script src="../../../ui/jquery.ui.sortable.js"></script>
+ <script src="../../../ui/jquery.ui.accordion.js"></script>
+ <script src="../../../ui/jquery.ui.tabs.js"></script>
+ <script>
$(function() {
$( "#accordion-1, #accordion-2" )
.accordion({
@@ -31,13 +31,15 @@
<div id="tabs">
<ul>
- <li><a href="#tabs-1">First</a></li>
- <li><a href="#tabs-2">Second</a></li>
+ <li><a href="#tabs-1">1 - Accordion</a></li>
+ <li><a href="#tabs-2">2 - Empty</a></li>
+ <li><a href="#tabs-3">3 - Empty</a></li>
+ <li><a href="#tabs-4">4 - Accordion</a></li>
</ul>
<div id="tabs-1">
<div id="accordion-1">
<div>
- <h3><a href="#">Accordion Header 1</a></h3>
+ <h3>Accordion Header 1</h3>
<div>
<p>Accordion Content 1</p>
<p>Accordion Content 1</p>
@@ -47,7 +49,7 @@
</div>
</div>
<div>
- <h3><a href="#">Accordion Header 2</a></h3>
+ <h3>Accordion Header 2</h3>
<div>
<p>Accordion Content 2</p>
<p>Accordion Content 2</p>
@@ -57,7 +59,7 @@
</div>
</div>
<div>
- <h3><a href="#">Accordion Header 3</a></h3>
+ <h3>Accordion Header 3</h3>
<div>
<p>Accordion Content 3</p>
<p>Accordion Content 3</p>
@@ -69,9 +71,15 @@
</div>
</div>
<div id="tabs-2">
- <div id="accordion-1">
+ <p>Nothing to look at here...</p>
+ </div>
+ <div id="tabs-3">
+ <p>Nothing to look at here...</p>
+ </div>
+ <div id="tabs-4">
+ <div id="accordion-2">
<div>
- <h3><a href="#">Accordion Header 1</a></h3>
+ <h3>Accordion Header 1</h3>
<div>
<p>Accordion Content 1</p>
<p>Accordion Content 1</p>
@@ -81,7 +89,7 @@
</div>
</div>
<div>
- <h3><a href="#">Accordion Header 2</a></h3>
+ <h3>Accordion Header 2</h3>
<div>
<p>Accordion Content 2</p>
<p>Accordion Content 2</p>
@@ -91,7 +99,7 @@
</div>
</div>
<div>
- <h3><a href="#">Accordion Header 3</a></h3>
+ <h3>Accordion Header 3</h3>
<div>
<p>Accordion Content 3</p>
<p>Accordion Content 3</p>
diff --git a/tests/visual/compound/tabs_tabs.html b/tests/visual/compound/tabs_tabs.html
index a18ef62ce..e40ed0742 100644
--- a/tests/visual/compound/tabs_tabs.html
+++ b/tests/visual/compound/tabs_tabs.html
@@ -1,18 +1,18 @@
-<!DOCTYPE html>
+<!doctype html>
<html lang="en">
<head>
- <meta charset="UTF-8" />
+ <meta charset="utf-8">
<title>Compound Visual Test : Tabs in Tabs</title>
- <link rel="stylesheet" href="../visual.css" type="text/css" />
- <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css">
- <script type="text/javascript" src="../../../jquery-1.7.2.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.accordion.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.tabs.js"></script>
- <script type="text/javascript">
+ <link rel="stylesheet" href="../visual.css">
+ <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css">
+ <script src="../../../jquery-1.7.2.js"></script>
+ <script src="../../../ui/jquery.ui.core.js"></script>
+ <script src="../../../ui/jquery.ui.widget.js"></script>
+ <script src="../../../ui/jquery.ui.accordion.js"></script>
+ <script src="../../../ui/jquery.ui.tabs.js"></script>
+ <script>
$(function() {
- $('#tabs, #tabs-a, #tabs-b').tabs();
+ $( "#tabs, #tabs-a, #tabs-b" ).tabs();
});
</script>
</head>
diff --git a/tests/visual/compound/tabs_tooltips.html b/tests/visual/compound/tabs_tooltips.html
index ad3822be9..f8cdef8b5 100644
--- a/tests/visual/compound/tabs_tooltips.html
+++ b/tests/visual/compound/tabs_tooltips.html
@@ -1,20 +1,20 @@
-<!DOCTYPE html>
+<!doctype html>
<html lang="en">
<head>
- <meta charset="UTF-8" />
+ <meta charset="utf-8">
<title>Compound Visual Test : Tabs in Tabs</title>
- <link rel="stylesheet" href="../visual.css" type="text/css" />
- <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css">
- <script type="text/javascript" src="../../../jquery-1.7.2.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.position.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.tooltip.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.tabs.js"></script>
- <script type="text/javascript">
+ <link rel="stylesheet" href="../visual.css">
+ <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css">
+ <script src="../../../jquery-1.7.2.js"></script>
+ <script src="../../../ui/jquery.ui.core.js"></script>
+ <script src="../../../ui/jquery.ui.widget.js"></script>
+ <script src="../../../ui/jquery.ui.position.js"></script>
+ <script src="../../../ui/jquery.ui.tooltip.js"></script>
+ <script src="../../../ui/jquery.ui.tabs.js"></script>
+ <script>
$(function() {
- $("#tabs").tabs();
- $("a").tooltip();
+ $( "#tabs" ).tabs();
+ $( "a" ).tooltip();
});
</script>
</head>
diff --git a/tests/visual/compound/widgets_in_dialog.html b/tests/visual/compound/widgets_in_dialog.html
deleted file mode 100644
index 89ea875d1..000000000
--- a/tests/visual/compound/widgets_in_dialog.html
+++ /dev/null
@@ -1,229 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
- <meta charset="UTF-8" />
- <title>Compound Visual Test : All Widgets in Dialog</title>
- <link rel="stylesheet" href="../visual.css" type="text/css" />
- <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css">
- <script type="text/javascript" src="../../../jquery-1.7.2.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.position.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.menu.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.resizable.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.draggable.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.accordion.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.autocomplete.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.button.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.datepicker.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.dialog.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.progressbar.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.tabs.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.tooltip.js"></script>
- <script type="text/javascript">
- $(function() {
- $("[title]").tooltip();
-
- $("#accordion").accordion();
- $("#autocomplete").autocomplete({
- source: ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby", "python", "c", "scala", "groovy", "haskell", "perl"]
- });
- $("button").button().click(function() {
- $("#dialog2").dialog("open");
- });
- $("#datepicker").datepicker();
- $("#progressbar").progressbar({
- value: 30
- });
- $("#slider").slider({
- // should be animated
- animate: true,
- value: 30,
- slide: function(event, ui) {
- $("#progress").val(ui.value);
- $("#progressbar").progressbar("option", "value", ui.value);
- }
- });
- $("#tabs").tabs();
-
- $("#dialog").dialog();
- $("#dialog2").dialog({
- autoOpen: false,
- width: 100,
- height: 75,
- modal: true
- });
- });
- </script>
-</head>
-<body>
-
-<div id="dialog">
- <div id="accordion">
- <h3><a href="#">Accordion Header 1</a></h3>
- <div>
- Accordion Content 1
- </div>
- <h3><a href="#">Accordion Header 2</a></h3>
- <div>
- Accordion Content 2
- </div>
- <h3><a href="#">Accordion Header 3</a></h3>
- <div>
- Accordion Content 3
- </div>
- </div>
- <input id="autocomplete">
- <button>A Button</button>
- <input id="datepicker">
- <button>Another button</button>
- <div>
- <label for="progress">Progress: <input title="The progress we made so far" id="progress" /></label>
- </div>
- <div id="progressbar">
- </div>
- <div id="slider" title="Sliding progress..."></div>
- <div id="tabs">
- <ul>
- <li><a href="#tabs-1">First</a></li>
- <li><a href="#tabs-2">Second</a></li>
- <li><a href="#tabs-3">Third</a></li>
- </ul>
- <div id="tabs-1">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
- <div id="tabs-2">Phasellus mattis tincidunt nibh. Cras orci urna, blandit id, pretium vel, aliquet ornare, felis. Maecenas scelerisque sem non nisl. Fusce sed lorem in enim dictum bibendum.</div>
- <div id="tabs-3">Nam dui erat, auctor a, dignissim quis, sollicitudin eu, felis. Pellentesque nisi urna, interdum eget, sagittis et, consequat vestibulum, lacus. Mauris porttitor ullamcorper augue.</div>
- </div>
-</div>
-<div id="dialog2">
- Yay, another dialog.
-</div>
-
-Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam vitae urna quam. Fusce adipiscing erat eget magna malesuada vel mollis ligula ullamcorper. Donec pulvinar, libero et vehicula facilisis, odio orci fringilla magna, non ultricies ipsum justo a tellus. Proin facilisis magna vitae quam vestibulum tempor. Aenean semper placerat posuere. In nisi diam, ullamcorper sit amet viverra sed, pretium sed neque. Sed posuere vulputate mauris vitae placerat. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nam in odio elit, non tempor felis. Integer non iaculis ante. Sed erat mauris, aliquam nec consequat id, congue id libero. Maecenas elementum gravida tincidunt. Suspendisse lacinia enim sit amet nulla cursus pulvinar.
-</p>
-<p>
-Proin ut sem nulla, at cursus sapien. Duis sagittis lacus vitae justo mattis in sagittis ligula eleifend. Curabitur sit amet felis pharetra justo facilisis mollis eget nec massa. Sed nisi urna, semper lobortis pretium ac, interdum nec lacus. In gravida, leo sit amet vehicula malesuada, augue nunc consectetur nulla, vel tincidunt est nunc aliquet neque. Maecenas imperdiet eros id ligula tempor dapibus. Integer commodo metus sit amet quam vestibulum volutpat. In et lorem ac leo rhoncus auctor sit amet ut urna. Nulla sed nisl quis turpis vestibulum accumsan. Duis mollis aliquam sollicitudin. Pellentesque porta semper interdum. Sed eros orci, congue quis sollicitudin ut, rutrum vitae nibh. Nunc et leo non ligula interdum imperdiet. Integer tincidunt rhoncus ullamcorper. Curabitur et ullamcorper lorem. Ut at tellus eu metus congue sollicitudin eget at orci.
-</p>
-<p>
-Duis sem mauris, pulvinar quis placerat vel, aliquet non leo. Cras eros arcu, ullamcorper sit amet imperdiet at, blandit interdum augue. Phasellus non nunc ac ante condimentum tristique vitae sed urna. Integer nec sapien et dolor volutpat bibendum ac vitae justo. Aliquam gravida fermentum felis, nec dictum dui dictum ac. Maecenas eget magna leo. Phasellus ac nulla risus, dapibus ornare turpis. Morbi a massa tortor. Duis ac turpis lacus. Duis nibh metus, euismod quis ultrices vitae, sollicitudin vel leo. Nullam volutpat odio ac elit imperdiet gravida.
-</p>
-<p>
-Donec luctus magna id ipsum aliquam eget convallis tortor tristique. Etiam est quam, aliquam ac rutrum quis, pretium sed tortor. Aliquam lacus diam, rhoncus molestie convallis ut, luctus ac lacus. Nunc porttitor ante a ligula rutrum elementum. Cras dui tellus, pulvinar vel convallis sit amet, facilisis nec ipsum. Donec fermentum lectus lorem, id accumsan eros. Nunc semper laoreet lacus quis ullamcorper. Nunc luctus erat vitae orci sodales facilisis non ut felis. Aliquam pretium sapien sed enim adipiscing in feugiat est ornare. Aenean ultricies convallis tortor sit amet ullamcorper.
-</p>
-<p>
-Etiam ultricies elit non enim elementum aliquet. Vivamus quis fringilla mauris. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nunc blandit felis at massa interdum ac molestie lectus volutpat. Mauris commodo nibh id sem porta id feugiat ante euismod. Nullam fermentum libero varius turpis pharetra cursus ut sed lacus. Mauris molestie egestas augue eu bibendum. Quisque pulvinar, leo luctus vehicula faucibus, quam mi ornare dui, a rhoncus nisi eros nec dolor. Sed dictum ultricies ipsum eu ultrices. Etiam semper condimentum nibh in tempor.
-</p>
-<p>
-
-Vivamus interdum ligula nec neque sollicitudin ornare. Vestibulum a eros eget nisi accumsan hendrerit quis sit amet ipsum. Phasellus condimentum vestibulum felis eu hendrerit. Suspendisse in est tellus, et consequat ante. Nam at sapien lobortis risus dignissim malesuada. In dapibus lectus sed nibh adipiscing dictum. Nulla pellentesque convallis auctor. Suspendisse ut purus et nibh pulvinar tincidunt. Maecenas dapibus purus at odio commodo ac cursus risus luctus. Ut quis libero justo. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nullam vestibulum ipsum quis ante porttitor porta. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Ut in ante neque. Donec ante ante, porttitor non egestas a, pulvinar sed sem. Nam augue quam, fringilla sed egestas et, vulputate non nisi.
-</p>
-<p>
-Nunc sit amet arcu ac nulla bibendum sollicitudin. Pellentesque sed ligula urna. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Quisque egestas, tortor a vestibulum malesuada, ante dui condimentum massa, ac rutrum massa mauris non mi. Praesent in nisi leo. Sed ac augue nisl. Donec eget enim ut arcu posuere condimentum vel id magna. Vestibulum laoreet imperdiet massa, ut venenatis ante dapibus eu. Phasellus faucibus vestibulum eros mollis adipiscing. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque aliquet lectus at enim gravida tempus tincidunt mi porta. Sed vehicula molestie ligula, sed tincidunt diam suscipit vitae.
-</p>
-<p>
-Nullam euismod tempus ante, vel semper turpis pharetra eget. Nulla pretium ante et ipsum dapibus imperdiet. Praesent ipsum velit, gravida sed adipiscing id, condimentum in odio. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Fusce blandit vehicula felis, pretium ullamcorper leo tempor non. Nunc eget nisi nunc, posuere pellentesque enim. Nunc gravida orci quis odio semper ultricies. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque eu neque a sapien commodo placerat. Aenean non eros semper metus viverra porttitor. Integer vel tortor eu neque commodo ultrices eu quis tellus. Nam commodo sagittis dolor in consequat. Fusce hendrerit turpis eget leo rutrum ut scelerisque nibh condimentum. Fusce sit amet feugiat mauris. Maecenas elementum tellus nec augue rutrum mattis. Sed viverra tempor blandit. Pellentesque adipiscing tincidunt est sit amet tincidunt. Proin suscipit suscipit odio, eu pellentesque dolor pharetra non. Aliquam erat volutpat.
-</p>
-<p>
-Duis pellentesque, enim sed mollis congue, ante mauris feugiat nisi, bibendum euismod erat enim ac magna. Mauris risus nisl, sodales vel viverra ut, interdum sed neque. Nunc ac dignissim felis. Proin tincidunt orci elementum erat molestie suscipit. Cras suscipit, sem ac vehicula vehicula, lorem orci dictum nibh, ut bibendum odio sem non erat. Maecenas quis metus eget mauris feugiat porta a eu ipsum. Vivamus tortor purus, posuere ut luctus sed, ullamcorper feugiat neque. In hac habitasse platea dictumst. Vivamus nec justo vel lacus mattis pellentesque. Nunc vel gravida quam. Etiam at aliquam magna.
-</p>
-<p>
-Sed ac lacus ac felis auctor suscipit. Aliquam lacinia lectus ac nunc placerat aliquam accumsan neque interdum. Aenean in sapien sem. Suspendisse potenti. Aenean congue vulputate scelerisque. Proin eget eros tortor. Morbi rhoncus, mi vitae sollicitudin luctus, est orci porttitor turpis, vitae cursus est dui sed leo. Curabitur erat nunc, placerat bibendum tempus in, blandit eget ipsum. Cras in feugiat ipsum. Vestibulum dapibus quam nec odio pretium non dapibus purus dapibus. Pellentesque vehicula metus bibendum orci ultrices tincidunt. Sed fermentum, neque eget porta tempor, sem neque pulvinar ligula, vitae elementum massa metus eget nunc. Nunc sed orci eu purus sodales fringilla. Quisque aliquet arcu ac dolor ultrices fringilla. Nullam ornare tempus lorem, in mattis magna mollis laoreet. Vestibulum convallis arcu in purus lobortis et sollicitudin ipsum aliquet. Quisque risus est, sagittis eu aliquam ac, condimentum at massa. Fusce consectetur dignissim sem vel ornare. Maecenas posuere ultricies sollicitudin. Duis luctus, purus quis auctor egestas, diam felis scelerisque diam, a varius tellus erat a nunc.
-</p>
-<p>
-Phasellus id ante neque, eget volutpat risus. Vivamus scelerisque, nisi rutrum ultrices varius, sem quam suscipit purus, in elementum nibh nulla nec nisi. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Phasellus interdum hendrerit mi, nec cursus nisi tempor ac. Phasellus luctus ligula bibendum mauris iaculis id tempor odio volutpat. Nunc in augue metus. Suspendisse at libero at libero lacinia convallis eu vitae metus. Duis eget risus odio. Nam id mi tellus, non vulputate libero. In placerat dictum orci eu pellentesque. Etiam sed varius felis. Phasellus ut adipiscing leo. Morbi ante eros, interdum eget dapibus ac, varius congue nunc. Donec vulputate sapien id risus sodales sit amet pretium velit iaculis. Etiam ultrices tempor euismod.
-</p>
-
-<p>
-Praesent in turpis ut mauris cursus commodo. Mauris lectus tellus, congue sit amet dictum id, convallis ac nisi. Curabitur ante dolor, sagittis ac auctor ac, aliquet vel nisl. Nulla non porta sapien. Nunc non aliquet erat. Vestibulum euismod auctor volutpat. Mauris libero tellus, pharetra eget lacinia sit amet, viverra eget velit. Sed viverra varius velit at pharetra. Sed pharetra dolor sed erat interdum in placerat magna lacinia. Cras venenatis tellus non sapien egestas sollicitudin. Duis congue pharetra lacinia. Curabitur eu diam vel tortor rhoncus dignissim vel sed enim. Proin ut congue mi. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce viverra elit eu dolor tincidunt tempor vel nec magna. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;
-</p>
-<p>
-Sed ligula purus, tristique nec condimentum sed, facilisis ac augue. Integer volutpat velit urna, et posuere ligula. In tempus luctus dignissim. Duis augue neque, egestas ut tincidunt in, congue a enim. Aliquam ut odio dui, id congue tortor. Nullam venenatis erat non nulla tincidunt scelerisque. Morbi in urna ac nulla molestie scelerisque eu a nulla. Aliquam erat volutpat. Praesent dictum scelerisque lorem mattis vehicula. Quisque ut rutrum metus. Mauris pharetra ante vitae nunc mattis vulputate. Mauris molestie volutpat mauris, ut iaculis dui bibendum ac. Ut egestas laoreet est, eget mollis libero laoreet at. In sagittis vestibulum accumsan. Nam dapibus ultrices urna sit amet accumsan. Pellentesque id ultrices elit. Aliquam quis magna ut leo sagittis posuere sit amet id enim. Etiam congue eros sit amet nulla aliquam gravida. In accumsan lectus nibh. Proin volutpat pretium facilisis.
-</p>
-<p>
-Mauris pulvinar erat at quam egestas ac aliquet mi gravida. Integer pellentesque quam vel massa commodo vitae sollicitudin eros volutpat. Aenean mollis felis molestie quam placerat et elementum eros gravida. In hac habitasse platea dictumst. Mauris ullamcorper facilisis eros, nec rutrum mi auctor sed. Ut viverra, orci a viverra ultricies, turpis enim pellentesque urna, sit amet viverra metus enim ut justo. Donec aliquam, urna id condimentum rutrum, nibh nunc tristique magna, at luctus quam enim at turpis. Maecenas dapibus dui ac velit adipiscing fringilla. Nullam malesuada nunc vel lorem cursus sed congue felis lacinia. Pellentesque vehicula gravida est nec facilisis. Nullam imperdiet fringilla orci in dignissim. Praesent orci dolor, vestibulum eu auctor quis, tristique auctor mi. Nunc euismod dui sit amet metus malesuada feugiat. Fusce iaculis neque in velit interdum rhoncus. Aenean at risus ut arcu dapibus congue a tincidunt dolor. Donec porttitor lacus et urna vestibulum a sagittis nunc mollis.
-</p>
-<p>
-In metus tellus, eleifend id aliquet at, pulvinar ut tortor. Aliquam erat volutpat. Vivamus lacus magna, consequat vel euismod sed, viverra a ipsum. Praesent dapibus laoreet nisi, nec posuere massa commodo vel. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ullamcorper adipiscing ante, dapibus molestie velit cursus id. Nam cursus arcu consectetur lectus sollicitudin gravida. Maecenas urna sapien, fermentum sit amet consectetur at, feugiat ut massa. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer sit amet ante nec arcu bibendum bibendum ut ut justo. Nulla ut libero est.
-</p>
-<p>
-Aenean sem augue, malesuada quis elementum id, aliquet at turpis. Nam volutpat interdum purus, at dictum risus posuere rhoncus. Praesent metus diam, egestas in lacinia eu, tincidunt in nibh. Phasellus sollicitudin volutpat erat, sit amet mattis sapien fringilla in. Quisque rhoncus, felis a pellentesque dictum, arcu urna molestie sem, ut tincidunt nulla magna in enim. Vestibulum erat nulla, sollicitudin quis faucibus et, blandit quis est. Nam vehicula justo augue. Vivamus elementum sodales aliquet. Donec convallis neque sed dui euismod aliquet. Morbi elementum hendrerit odio, vel mollis felis dignissim vitae. Phasellus a diam lacus. Integer congue, mi vehicula egestas imperdiet, nulla mi commodo tortor, sit amet fermentum urna leo non dolor. Donec elementum elementum urna at sollicitudin. Vestibulum placerat tortor in nibh lobortis ac consectetur felis interdum. Integer faucibus diam nec magna porttitor sit amet dictum elit consectetur. Suspendisse risus velit, pellentesque eget viverra in, porta eget metus. Sed porta elit erat.
-</p>
-<p>
-Nulla facilisi. Aliquam vulputate dolor quis nisi auctor luctus. Fusce vitae scelerisque velit. Sed sit amet tortor a nisi convallis pulvinar et eget sapien. Nulla condimentum auctor velit, a viverra nibh pellentesque eget. Aenean at lacus quam, lobortis posuere justo. Duis et diam in ligula rhoncus pellentesque. Morbi massa tellus, mattis nec condimentum ut, tempus eu lectus. In mi orci, luctus at pulvinar vel, scelerisque nec enim. Vestibulum vehicula odio in augue dignissim tincidunt. Integer ac velit ligula. Integer elit turpis, mattis eget ornare ut, eleifend in magna. Curabitur sagittis dui in felis ultricies gravida.
-
-</p>
-<p>
-Praesent adipiscing rhoncus rutrum. Aenean ultricies auctor risus at fringilla. Mauris quam lectus, ullamcorper sed ultricies at, interdum eget tellus. Vestibulum ac mi erat. Sed ac tellus erat, sed laoreet arcu. Fusce eget ipsum ac sem volutpat viverra. Suspendisse ac felis sit amet purus viverra luctus non eget ipsum. Praesent eleifend euismod tortor, vel malesuada felis consectetur ac. Nunc a mi sit amet nulla venenatis tincidunt. Morbi vitae nisl nulla, nec adipiscing sem. Nullam porttitor scelerisque urna, id dapibus diam malesuada vitae. Duis auctor eleifend lectus, a tempor odio aliquet quis. Nam eu est urna, nec ultricies lectus. Ut egestas aliquet nunc, et hendrerit erat vehicula non. Aliquam tempus faucibus arcu, at vulputate erat tempor eu. Quisque tempus, lectus adipiscing blandit scelerisque, magna felis eleifend odio, non volutpat felis enim sit amet leo. Mauris augue tortor, ultrices ac sagittis non, vulputate quis nisl.
-</p>
-<p>
-Fusce erat sem, dictum in bibendum ac, feugiat ut odio. Duis aliquam felis sit amet diam egestas consectetur. Phasellus consequat, mauris eget venenatis porta, velit sapien malesuada nibh, id dignissim ante tellus vitae lacus. Duis non nisl sit amet nunc euismod posuere. Donec eros erat, fringilla vel iaculis condimentum, vestibulum at neque. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aliquam lorem sapien, bibendum eu mollis nec, gravida dapibus lectus. Aenean pretium volutpat nunc a placerat. Nullam eget tellus quis ipsum ultrices ullamcorper non eu mauris. Donec volutpat tincidunt elit, sit amet cursus justo elementum quis. Mauris volutpat, enim sit amet tempor commodo, purus lacus luctus dui, sed aliquet ligula nisi vel diam. Donec est elit, lobortis at eleifend id, feugiat egestas massa. Fusce elementum sollicitudin adipiscing. Vivamus et dapibus ipsum. Morbi interdum libero a nisl dignissim sed facilisis ipsum lacinia.
-</p>
-<p>
-Cras a augue dui, vitae tincidunt enim. In hac habitasse platea dictumst. Proin nec magna sed nulla mollis tempus id ut lectus. Morbi volutpat ultricies ipsum, quis imperdiet libero tempor nec. Donec bibendum ornare blandit. Aliquam rutrum risus non turpis commodo non commodo erat molestie. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut fermentum, magna vel euismod convallis, mi magna vehicula velit, aliquet rhoncus ipsum massa et nunc. Nullam blandit purus non neque ullamcorper a aliquet nisl tristique. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed sit amet velit magna, sit amet rutrum dui. Donec elementum mi sed velit consectetur vulputate. Sed interdum adipiscing mattis.
-</p>
-Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam vitae urna quam. Fusce adipiscing erat eget magna malesuada vel mollis ligula ullamcorper. Donec pulvinar, libero et vehicula facilisis, odio orci fringilla magna, non ultricies ipsum justo a tellus. Proin facilisis magna vitae quam vestibulum tempor. Aenean semper placerat posuere. In nisi diam, ullamcorper sit amet viverra sed, pretium sed neque. Sed posuere vulputate mauris vitae placerat. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nam in odio elit, non tempor felis. Integer non iaculis ante. Sed erat mauris, aliquam nec consequat id, congue id libero. Maecenas elementum gravida tincidunt. Suspendisse lacinia enim sit amet nulla cursus pulvinar.
-</p>
-<p>
-Proin ut sem nulla, at cursus sapien. Duis sagittis lacus vitae justo mattis in sagittis ligula eleifend. Curabitur sit amet felis pharetra justo facilisis mollis eget nec massa. Sed nisi urna, semper lobortis pretium ac, interdum nec lacus. In gravida, leo sit amet vehicula malesuada, augue nunc consectetur nulla, vel tincidunt est nunc aliquet neque. Maecenas imperdiet eros id ligula tempor dapibus. Integer commodo metus sit amet quam vestibulum volutpat. In et lorem ac leo rhoncus auctor sit amet ut urna. Nulla sed nisl quis turpis vestibulum accumsan. Duis mollis aliquam sollicitudin. Pellentesque porta semper interdum. Sed eros orci, congue quis sollicitudin ut, rutrum vitae nibh. Nunc et leo non ligula interdum imperdiet. Integer tincidunt rhoncus ullamcorper. Curabitur et ullamcorper lorem. Ut at tellus eu metus congue sollicitudin eget at orci.
-</p>
-<p>
-Duis sem mauris, pulvinar quis placerat vel, aliquet non leo. Cras eros arcu, ullamcorper sit amet imperdiet at, blandit interdum augue. Phasellus non nunc ac ante condimentum tristique vitae sed urna. Integer nec sapien et dolor volutpat bibendum ac vitae justo. Aliquam gravida fermentum felis, nec dictum dui dictum ac. Maecenas eget magna leo. Phasellus ac nulla risus, dapibus ornare turpis. Morbi a massa tortor. Duis ac turpis lacus. Duis nibh metus, euismod quis ultrices vitae, sollicitudin vel leo. Nullam volutpat odio ac elit imperdiet gravida.
-</p>
-<p>
-Donec luctus magna id ipsum aliquam eget convallis tortor tristique. Etiam est quam, aliquam ac rutrum quis, pretium sed tortor. Aliquam lacus diam, rhoncus molestie convallis ut, luctus ac lacus. Nunc porttitor ante a ligula rutrum elementum. Cras dui tellus, pulvinar vel convallis sit amet, facilisis nec ipsum. Donec fermentum lectus lorem, id accumsan eros. Nunc semper laoreet lacus quis ullamcorper. Nunc luctus erat vitae orci sodales facilisis non ut felis. Aliquam pretium sapien sed enim adipiscing in feugiat est ornare. Aenean ultricies convallis tortor sit amet ullamcorper.
-</p>
-<p>
-Etiam ultricies elit non enim elementum aliquet. Vivamus quis fringilla mauris. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nunc blandit felis at massa interdum ac molestie lectus volutpat. Mauris commodo nibh id sem porta id feugiat ante euismod. Nullam fermentum libero varius turpis pharetra cursus ut sed lacus. Mauris molestie egestas augue eu bibendum. Quisque pulvinar, leo luctus vehicula faucibus, quam mi ornare dui, a rhoncus nisi eros nec dolor. Sed dictum ultricies ipsum eu ultrices. Etiam semper condimentum nibh in tempor.
-</p>
-<p>
-
-Vivamus interdum ligula nec neque sollicitudin ornare. Vestibulum a eros eget nisi accumsan hendrerit quis sit amet ipsum. Phasellus condimentum vestibulum felis eu hendrerit. Suspendisse in est tellus, et consequat ante. Nam at sapien lobortis risus dignissim malesuada. In dapibus lectus sed nibh adipiscing dictum. Nulla pellentesque convallis auctor. Suspendisse ut purus et nibh pulvinar tincidunt. Maecenas dapibus purus at odio commodo ac cursus risus luctus. Ut quis libero justo. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nullam vestibulum ipsum quis ante porttitor porta. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Ut in ante neque. Donec ante ante, porttitor non egestas a, pulvinar sed sem. Nam augue quam, fringilla sed egestas et, vulputate non nisi.
-</p>
-<p>
-Nunc sit amet arcu ac nulla bibendum sollicitudin. Pellentesque sed ligula urna. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Quisque egestas, tortor a vestibulum malesuada, ante dui condimentum massa, ac rutrum massa mauris non mi. Praesent in nisi leo. Sed ac augue nisl. Donec eget enim ut arcu posuere condimentum vel id magna. Vestibulum laoreet imperdiet massa, ut venenatis ante dapibus eu. Phasellus faucibus vestibulum eros mollis adipiscing. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque aliquet lectus at enim gravida tempus tincidunt mi porta. Sed vehicula molestie ligula, sed tincidunt diam suscipit vitae.
-</p>
-<p>
-Nullam euismod tempus ante, vel semper turpis pharetra eget. Nulla pretium ante et ipsum dapibus imperdiet. Praesent ipsum velit, gravida sed adipiscing id, condimentum in odio. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Fusce blandit vehicula felis, pretium ullamcorper leo tempor non. Nunc eget nisi nunc, posuere pellentesque enim. Nunc gravida orci quis odio semper ultricies. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque eu neque a sapien commodo placerat. Aenean non eros semper metus viverra porttitor. Integer vel tortor eu neque commodo ultrices eu quis tellus. Nam commodo sagittis dolor in consequat. Fusce hendrerit turpis eget leo rutrum ut scelerisque nibh condimentum. Fusce sit amet feugiat mauris. Maecenas elementum tellus nec augue rutrum mattis. Sed viverra tempor blandit. Pellentesque adipiscing tincidunt est sit amet tincidunt. Proin suscipit suscipit odio, eu pellentesque dolor pharetra non. Aliquam erat volutpat.
-</p>
-<p>
-Duis pellentesque, enim sed mollis congue, ante mauris feugiat nisi, bibendum euismod erat enim ac magna. Mauris risus nisl, sodales vel viverra ut, interdum sed neque. Nunc ac dignissim felis. Proin tincidunt orci elementum erat molestie suscipit. Cras suscipit, sem ac vehicula vehicula, lorem orci dictum nibh, ut bibendum odio sem non erat. Maecenas quis metus eget mauris feugiat porta a eu ipsum. Vivamus tortor purus, posuere ut luctus sed, ullamcorper feugiat neque. In hac habitasse platea dictumst. Vivamus nec justo vel lacus mattis pellentesque. Nunc vel gravida quam. Etiam at aliquam magna.
-</p>
-<p>
-Sed ac lacus ac felis auctor suscipit. Aliquam lacinia lectus ac nunc placerat aliquam accumsan neque interdum. Aenean in sapien sem. Suspendisse potenti. Aenean congue vulputate scelerisque. Proin eget eros tortor. Morbi rhoncus, mi vitae sollicitudin luctus, est orci porttitor turpis, vitae cursus est dui sed leo. Curabitur erat nunc, placerat bibendum tempus in, blandit eget ipsum. Cras in feugiat ipsum. Vestibulum dapibus quam nec odio pretium non dapibus purus dapibus. Pellentesque vehicula metus bibendum orci ultrices tincidunt. Sed fermentum, neque eget porta tempor, sem neque pulvinar ligula, vitae elementum massa metus eget nunc. Nunc sed orci eu purus sodales fringilla. Quisque aliquet arcu ac dolor ultrices fringilla. Nullam ornare tempus lorem, in mattis magna mollis laoreet. Vestibulum convallis arcu in purus lobortis et sollicitudin ipsum aliquet. Quisque risus est, sagittis eu aliquam ac, condimentum at massa. Fusce consectetur dignissim sem vel ornare. Maecenas posuere ultricies sollicitudin. Duis luctus, purus quis auctor egestas, diam felis scelerisque diam, a varius tellus erat a nunc.
-</p>
-<p>
-Phasellus id ante neque, eget volutpat risus. Vivamus scelerisque, nisi rutrum ultrices varius, sem quam suscipit purus, in elementum nibh nulla nec nisi. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Phasellus interdum hendrerit mi, nec cursus nisi tempor ac. Phasellus luctus ligula bibendum mauris iaculis id tempor odio volutpat. Nunc in augue metus. Suspendisse at libero at libero lacinia convallis eu vitae metus. Duis eget risus odio. Nam id mi tellus, non vulputate libero. In placerat dictum orci eu pellentesque. Etiam sed varius felis. Phasellus ut adipiscing leo. Morbi ante eros, interdum eget dapibus ac, varius congue nunc. Donec vulputate sapien id risus sodales sit amet pretium velit iaculis. Etiam ultrices tempor euismod.
-</p>
-
-<p>
-Praesent in turpis ut mauris cursus commodo. Mauris lectus tellus, congue sit amet dictum id, convallis ac nisi. Curabitur ante dolor, sagittis ac auctor ac, aliquet vel nisl. Nulla non porta sapien. Nunc non aliquet erat. Vestibulum euismod auctor volutpat. Mauris libero tellus, pharetra eget lacinia sit amet, viverra eget velit. Sed viverra varius velit at pharetra. Sed pharetra dolor sed erat interdum in placerat magna lacinia. Cras venenatis tellus non sapien egestas sollicitudin. Duis congue pharetra lacinia. Curabitur eu diam vel tortor rhoncus dignissim vel sed enim. Proin ut congue mi. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce viverra elit eu dolor tincidunt tempor vel nec magna. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;
-</p>
-<p>
-Sed ligula purus, tristique nec condimentum sed, facilisis ac augue. Integer volutpat velit urna, et posuere ligula. In tempus luctus dignissim. Duis augue neque, egestas ut tincidunt in, congue a enim. Aliquam ut odio dui, id congue tortor. Nullam venenatis erat non nulla tincidunt scelerisque. Morbi in urna ac nulla molestie scelerisque eu a nulla. Aliquam erat volutpat. Praesent dictum scelerisque lorem mattis vehicula. Quisque ut rutrum metus. Mauris pharetra ante vitae nunc mattis vulputate. Mauris molestie volutpat mauris, ut iaculis dui bibendum ac. Ut egestas laoreet est, eget mollis libero laoreet at. In sagittis vestibulum accumsan. Nam dapibus ultrices urna sit amet accumsan. Pellentesque id ultrices elit. Aliquam quis magna ut leo sagittis posuere sit amet id enim. Etiam congue eros sit amet nulla aliquam gravida. In accumsan lectus nibh. Proin volutpat pretium facilisis.
-</p>
-<p>
-Mauris pulvinar erat at quam egestas ac aliquet mi gravida. Integer pellentesque quam vel massa commodo vitae sollicitudin eros volutpat. Aenean mollis felis molestie quam placerat et elementum eros gravida. In hac habitasse platea dictumst. Mauris ullamcorper facilisis eros, nec rutrum mi auctor sed. Ut viverra, orci a viverra ultricies, turpis enim pellentesque urna, sit amet viverra metus enim ut justo. Donec aliquam, urna id condimentum rutrum, nibh nunc tristique magna, at luctus quam enim at turpis. Maecenas dapibus dui ac velit adipiscing fringilla. Nullam malesuada nunc vel lorem cursus sed congue felis lacinia. Pellentesque vehicula gravida est nec facilisis. Nullam imperdiet fringilla orci in dignissim. Praesent orci dolor, vestibulum eu auctor quis, tristique auctor mi. Nunc euismod dui sit amet metus malesuada feugiat. Fusce iaculis neque in velit interdum rhoncus. Aenean at risus ut arcu dapibus congue a tincidunt dolor. Donec porttitor lacus et urna vestibulum a sagittis nunc mollis.
-</p>
-<p>
-In metus tellus, eleifend id aliquet at, pulvinar ut tortor. Aliquam erat volutpat. Vivamus lacus magna, consequat vel euismod sed, viverra a ipsum. Praesent dapibus laoreet nisi, nec posuere massa commodo vel. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ullamcorper adipiscing ante, dapibus molestie velit cursus id. Nam cursus arcu consectetur lectus sollicitudin gravida. Maecenas urna sapien, fermentum sit amet consectetur at, feugiat ut massa. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer sit amet ante nec arcu bibendum bibendum ut ut justo. Nulla ut libero est.
-</p>
-<p>
-Aenean sem augue, malesuada quis elementum id, aliquet at turpis. Nam volutpat interdum purus, at dictum risus posuere rhoncus. Praesent metus diam, egestas in lacinia eu, tincidunt in nibh. Phasellus sollicitudin volutpat erat, sit amet mattis sapien fringilla in. Quisque rhoncus, felis a pellentesque dictum, arcu urna molestie sem, ut tincidunt nulla magna in enim. Vestibulum erat nulla, sollicitudin quis faucibus et, blandit quis est. Nam vehicula justo augue. Vivamus elementum sodales aliquet. Donec convallis neque sed dui euismod aliquet. Morbi elementum hendrerit odio, vel mollis felis dignissim vitae. Phasellus a diam lacus. Integer congue, mi vehicula egestas imperdiet, nulla mi commodo tortor, sit amet fermentum urna leo non dolor. Donec elementum elementum urna at sollicitudin. Vestibulum placerat tortor in nibh lobortis ac consectetur felis interdum. Integer faucibus diam nec magna porttitor sit amet dictum elit consectetur. Suspendisse risus velit, pellentesque eget viverra in, porta eget metus. Sed porta elit erat.
-</p>
-<p>
-Nulla facilisi. Aliquam vulputate dolor quis nisi auctor luctus. Fusce vitae scelerisque velit. Sed sit amet tortor a nisi convallis pulvinar et eget sapien. Nulla condimentum auctor velit, a viverra nibh pellentesque eget. Aenean at lacus quam, lobortis posuere justo. Duis et diam in ligula rhoncus pellentesque. Morbi massa tellus, mattis nec condimentum ut, tempus eu lectus. In mi orci, luctus at pulvinar vel, scelerisque nec enim. Vestibulum vehicula odio in augue dignissim tincidunt. Integer ac velit ligula. Integer elit turpis, mattis eget ornare ut, eleifend in magna. Curabitur sagittis dui in felis ultricies gravida.
-
-</p>
-<p>
-Praesent adipiscing rhoncus rutrum. Aenean ultricies auctor risus at fringilla. Mauris quam lectus, ullamcorper sed ultricies at, interdum eget tellus. Vestibulum ac mi erat. Sed ac tellus erat, sed laoreet arcu. Fusce eget ipsum ac sem volutpat viverra. Suspendisse ac felis sit amet purus viverra luctus non eget ipsum. Praesent eleifend euismod tortor, vel malesuada felis consectetur ac. Nunc a mi sit amet nulla venenatis tincidunt. Morbi vitae nisl nulla, nec adipiscing sem. Nullam porttitor scelerisque urna, id dapibus diam malesuada vitae. Duis auctor eleifend lectus, a tempor odio aliquet quis. Nam eu est urna, nec ultricies lectus. Ut egestas aliquet nunc, et hendrerit erat vehicula non. Aliquam tempus faucibus arcu, at vulputate erat tempor eu. Quisque tempus, lectus adipiscing blandit scelerisque, magna felis eleifend odio, non volutpat felis enim sit amet leo. Mauris augue tortor, ultrices ac sagittis non, vulputate quis nisl.
-</p>
-<p>
-Fusce erat sem, dictum in bibendum ac, feugiat ut odio. Duis aliquam felis sit amet diam egestas consectetur. Phasellus consequat, mauris eget venenatis porta, velit sapien malesuada nibh, id dignissim ante tellus vitae lacus. Duis non nisl sit amet nunc euismod posuere. Donec eros erat, fringilla vel iaculis condimentum, vestibulum at neque. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aliquam lorem sapien, bibendum eu mollis nec, gravida dapibus lectus. Aenean pretium volutpat nunc a placerat. Nullam eget tellus quis ipsum ultrices ullamcorper non eu mauris. Donec volutpat tincidunt elit, sit amet cursus justo elementum quis. Mauris volutpat, enim sit amet tempor commodo, purus lacus luctus dui, sed aliquet ligula nisi vel diam. Donec est elit, lobortis at eleifend id, feugiat egestas massa. Fusce elementum sollicitudin adipiscing. Vivamus et dapibus ipsum. Morbi interdum libero a nisl dignissim sed facilisis ipsum lacinia.
-</p>
-<p>
-Cras a augue dui, vitae tincidunt enim. In hac habitasse platea dictumst. Proin nec magna sed nulla mollis tempus id ut lectus. Morbi volutpat ultricies ipsum, quis imperdiet libero tempor nec. Donec bibendum ornare blandit. Aliquam rutrum risus non turpis commodo non commodo erat molestie. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut fermentum, magna vel euismod convallis, mi magna vehicula velit, aliquet rhoncus ipsum massa et nunc. Nullam blandit purus non neque ullamcorper a aliquet nisl tristique. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed sit amet velit magna, sit amet rutrum dui. Donec elementum mi sed velit consectetur vulputate. Sed interdum adipiscing mattis.
-</p>
-
-</body>
-</html>
diff --git a/tests/visual/effects/effects.scale.html b/tests/visual/effects/effects.scale.html
index f86c36b6e..708543257 100644
--- a/tests/visual/effects/effects.scale.html
+++ b/tests/visual/effects/effects.scale.html
@@ -8,7 +8,7 @@
<script src="../../../ui/jquery.effects.core.js"></script>
<script src="../../../ui/jquery.effects.scale.js"></script>
<script src="effects.all.js"></script>
- <script type="text/javascript" charset="utf-8">
+ <script>
jQuery(function( $ ) {
var test = $( "#testBox" ),
opts = $( ".arg" ),
@@ -36,9 +36,9 @@
var cur = this.selectedIndex,
next = cur + direction,
len = this.options.length;
-
+
this.selectedIndex = ( next + len ) % len;
-
+
if ( ( next+len ) % len === next ) return false;
});
doAnim();
diff --git a/tests/visual/menu/drilldown.html b/tests/visual/menu/drilldown.html
index 8bc30a793..7b40fc62f 100644
--- a/tests/visual/menu/drilldown.html
+++ b/tests/visual/menu/drilldown.html
@@ -1,6 +1,7 @@
<!doctype html>
<html>
<head>
+ <meta charset="utf-8">
<title>Menu Visual Test: Default</title>
<link rel="stylesheet" href="../visual.css" type="text/css" />
<link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css" title="ui-theme" />
@@ -18,15 +19,15 @@
right: 10,
top: 10
}).appendTo(document.body).themeswitcher();
-
+
$.widget("ui.drilldown", {
_init: function() {
var that = this;
this.active = this.element.find(">ul").attr("tabindex", 0);
-
+
// hide submenus and create indicator icons
- this.element.find("ul").hide().prev("a").prepend('<span class="ui-icon ui-icon-carat-1-e"></span>').end().filter(":first").show();
-
+ this.element.find("ul").hide().prev("a").prepend('<span class="ui-icon ui-icon-carat-1-e"></span>').end().filter(":first").show();
+
this.element.find("ul").menu({
// disable built-in key handling
input: $(),
@@ -46,7 +47,7 @@
}
}
});
-
+
this.back = this.element.children(":last").button({
icons: {
primary: "ui-icon-carat-1-w"
@@ -56,7 +57,7 @@
return false;
}).hide();
},
-
+
_open: function(submenu) {
this.active = submenu.show().css({
opacity: 0
@@ -78,7 +79,7 @@
});
this.back.show();
},
-
+
up: function() {
if (this.active.parent()[0] == this.element[0]) {
return;
@@ -101,7 +102,7 @@
this.back.hide();
}
},
-
+
down: function(event) {
var nested = this.activeItem.find(">ul");
if (nested.length) {
@@ -109,24 +110,24 @@
nested.menu("focus", event, nested.children(":first"))
}
},
-
+
show: function() {
},
-
+
hide: function() {
},
-
+
widget: function() {
return this.element.find(">ul");
}
});
-
+
var drilldown = $("#drilldown").drilldown({
select: function(event, ui) {
$("#log").append("<div>Selected " + ui.item.text() + "</div>");
}
});
-
+
drilldown.drilldown("widget").keydown(function(event) {
var menu = drilldown.data("drilldown").active.data("menu");
if (menu.widget().is(":hidden"))
@@ -171,7 +172,7 @@
} else {
character = prev + character;
}
-
+
var match = menu.widget().children("li").filter(function() {
return new RegExp("^" + character, "i").test($("a", this).text());
});
@@ -207,7 +208,7 @@
</style>
</head>
<body>
-
+
<div id="drilldown">
<h3>Make a selection...</h3>
<ul>
diff --git a/tests/visual/menu/menu.html b/tests/visual/menu/menu.html
index f88d1d542..548f25db4 100644
--- a/tests/visual/menu/menu.html
+++ b/tests/visual/menu/menu.html
@@ -1,6 +1,7 @@
<!doctype html>
<html>
<head>
+ <meta charset="utf-8">
<title>Menu Visual Test: Default</title>
<link rel="stylesheet" href="../visual.css" type="text/css" />
<link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css" title="ui-theme" />
@@ -38,7 +39,7 @@
menus: ".menuElement"
});
}
-
+
var menus = $("#menu1, #menu2, #menu3, .menu4");
create();
@@ -78,6 +79,7 @@
<li><a href="#">Ada</a></li>
<li><a href="#">Adamsville</a></li>
<li><a href="#">Addyston</a></li>
+ <li></li>
<li>
<a href="#">Delphi</a>
<ul>
@@ -117,7 +119,7 @@
<li class="ui-state-disabled"><a href="#"><span class="ui-icon ui-icon-scissors"></span>Ada</a></li>
<li><a href="#">Adamsville</a></li>
<li><a href="#"><span class="ui-icon ui-icon-wrench"></span>Addyston</a></li>
- <li>
+ <li class="ui-state-disabled">
<a href="#">Delphi</a>
<ul>
<li><a href="#">Ada</a></li>
diff --git a/tests/visual/menu/tablemenu.html b/tests/visual/menu/tablemenu.html
index 19691c614..ca4345aed 100644
--- a/tests/visual/menu/tablemenu.html
+++ b/tests/visual/menu/tablemenu.html
@@ -1,6 +1,7 @@
<!doctype html>
<html>
<head>
+ <meta charset="utf-8">
<title>Menu Visual Test: Default</title>
<link rel="stylesheet" href="../visual.css" type="text/css" />
<link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css" title="ui-theme" />
@@ -20,7 +21,7 @@
rows.each(function() {
$("<table>").width("100%").append(colgroup.clone()).append(this).wrap("<li><a></a></li>").parent().parent().appendTo(menu);
});
-
+
menu.menu({
select: function(event, ui) {
$("<div/>").text("Selected: " + ui.item.text()).appendTo("#log");
@@ -34,7 +35,7 @@
</style>
</head>
<body>
-
+
<table>
<colgroup><col style="width: 50%"><col style="width: 50%"></colgroup>
<thead>
@@ -54,7 +55,7 @@
</tr>
</tbody>
</table>
-
+
<div class="ui-widget" style="clear: left; margin-top:2em; font-family:Arial">
Log:
<div id="log" style="height: 400px; width: 300px; overflow: auto;" class="ui-widget-content"></div>
diff --git a/tests/visual/position/position.html b/tests/visual/position/position.html
index b9b769d9b..64c5d2300 100644
--- a/tests/visual/position/position.html
+++ b/tests/visual/position/position.html
@@ -10,23 +10,31 @@
<script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="../../../ui/jquery.ui.position.js"></script>
<script type="text/javascript" src="../../../ui/jquery.ui.menu.js"></script>
- <script type="text/javascript" src="http://jqueryui.com/themeroller/themeswitchertool/"></script>
<script type="text/javascript">
$(function() {
var inputs = $("input");
$("ul").insertAfter(inputs);
$(window).resize(function() {
inputs.each(function() {
- $(this).position({
+ var input = $(this).position({
my: this.id.replace(/-/, " "),
at: this.id.replace(/-/, " "),
of: "#container",
collision: "none"
});
- $(this).next().menu().position({
- my: "left top+20",
+ var menu = $(this).next().menu()
+ menu.position({
+ my: "left+30 top+20",
at: "left bottom",
of: this,
+ using: function( position, feedback ) {
+ input.val(feedback.horizontal + " " + feedback.vertical)
+ $(this).offset( position );
+ $(this)
+ .removeClass("left right top bottom center middle")
+ .addClass(feedback.horizontal)
+ .addClass(feedback.vertical);
+ }
});
});
}).resize();
@@ -44,11 +52,11 @@
top: -22px;
left: 5px;
}
- .ui-flipped-left:before {
+ .right:before {
left: auto;
right: 5px;
}
- .ui-flipped-top:before {
+ .bottom:before {
content: "↓";
top: auto;
bottom: -19px;
diff --git a/tests/visual/position/position_feedback.html b/tests/visual/position/position_feedback.html
new file mode 100644
index 000000000..006a1be02
--- /dev/null
+++ b/tests/visual/position/position_feedback.html
@@ -0,0 +1,146 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>Position Visual Test: Default</title>
+ <link rel="stylesheet" href="../visual.css">
+ <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css">
+ <script src="../../../jquery-1.7.2.js"></script>
+ <script src="../../../ui/jquery.ui.core.js"></script>
+ <script src="../../../ui/jquery.ui.widget.js"></script>
+ <script src="../../../ui/jquery.ui.position.js"></script>
+ <script src="../../../ui/jquery.ui.menu.js"></script>
+ <script>
+ $(function() {
+ function using( position, feedback ) {
+ $( this )
+ .css( position )
+ .text( feedback.horizontal + " " + feedback.vertical + " " + feedback.important )
+ .removeClass( "left right top bottom center middle vertical horizontal" )
+ .addClass( feedback.horizontal )
+ .addClass( feedback.vertical )
+ .addClass( feedback.important );
+ }
+
+ var element = $( ".element" ),
+ target = $( "#target" ).position({
+ my: "center",
+ at: "center",
+ of: window
+ }),
+ targetOffset = target.offset(),
+ oppositeElement = element.clone().width( 50 ).appendTo( "body" ),
+ leftElement = element.clone().width( 50 ).height( 150 ).appendTo( "body" ),
+ rightElement = element.clone().height( 150 ).width( 150 ).appendTo( "body" );
+
+ $.each([
+ "center top-100",
+ "right+25 top-50",
+ "right+75 top",
+ "right+75 center",
+ "right+75 bottom",
+ "right+25 bottom+50",
+ "center bottom+100",
+ "left-25 bottom+50",
+ "left-75 bottom",
+ "left-75 center",
+ "left-75 top",
+ "left-25 top-50"
+ ], function( index, direction ) {
+ element.clone().insertAfter( target ).position({
+ my: "center",
+ at: direction,
+ of: target,
+ using: using
+ });
+ });
+
+ element.width( 150 );
+ $( document ).on( "mousemove", function( event ) {
+ var base = {
+ my: "left top",
+ at: "left top",
+ of: target,
+ using: using
+ };
+ element.position( $.extend({
+ offset: (event.pageX - targetOffset.left) + " " + (event.pageY - targetOffset.top)
+ }, base ));
+ oppositeElement.position( $.extend({
+ offset: (-1 * (event.pageX - targetOffset.left)) + " " + (-1 * (event.pageY - targetOffset.top))
+ }, base ));
+ leftElement.position( $.extend({
+ offset: (-0.9 * (event.pageX - targetOffset.left)) + " " + (0.9 * (event.pageY - targetOffset.top))
+ }, base ));
+ rightElement.position( $.extend({
+ offset: (0.9 * (event.pageX - targetOffset.left)) + " " + (-0.9 * (event.pageY - targetOffset.top))
+ }, base) );
+ });
+ });
+ </script>
+ <style>
+ #target, .element {
+ position: absolute;
+ border: 1px solid black;
+ border-radius: 5px;
+ width: 75px;
+ height: 25px;
+ padding: 5px;
+ }
+ #target {
+ height: 75px;
+ }
+ .element:before {
+ font-size: 12pt;
+ content: "↑";
+ position: absolute;
+ top: -19px;
+ left: 5px;
+ }
+ .right:before {
+ left: auto;
+ right: 5px;
+ }
+ .bottom:before {
+ content: "↓";
+ top: auto;
+ bottom: -19px;
+ }
+ .center:before {
+ left: 50%;
+ right: auto;
+ }
+ .middle:before {
+ top: 50%;
+ bottom: auto;
+ }
+ .horizontal:before {
+ height: 10px;
+ top: 50%;
+ margin-top: -8px;
+ bottom: auto;
+ left: -18px;
+ right: auto;
+ content: "←";
+ }
+ .right.horizontal:before {
+ left: auto;
+ right: -18px;
+ content: "→";
+ }
+ .bottom.horizontal:before {
+ top: auto;
+ bottom: 5px;
+ }
+ .top.horizontal:before {
+ top: 5px;
+ }
+ </style>
+</head>
+<body>
+
+<div id="target">all around me</div>
+<div class="element"></div>
+
+</body>
+</html>
diff --git a/tests/visual/position/position_feedback_rotate.html b/tests/visual/position/position_feedback_rotate.html
new file mode 100644
index 000000000..11138b112
--- /dev/null
+++ b/tests/visual/position/position_feedback_rotate.html
@@ -0,0 +1,109 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>Position Visual Test: Default</title>
+ <link rel="stylesheet" href="../visual.css">
+ <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css">
+ <script src="../../../jquery-1.7.2.js"></script>
+ <script src="../../../ui/jquery.ui.core.js"></script>
+ <script src="../../../ui/jquery.ui.widget.js"></script>
+ <script src="../../../ui/jquery.ui.position.js"></script>
+ <script src="../../../ui/jquery.ui.menu.js"></script>
+ <script>
+ $(function() {
+ function using( position, feedback ) {
+ var angleRad = Math.atan2(
+ feedback.target.top + feedback.target.height / 2 - feedback.element.top - feedback.element.height / 2,
+ feedback.target.left + feedback.target.width / 2 - feedback.element.left - feedback.element.width / 2
+ ) * 180 / Math.PI,
+ angle = Math.round( angleRad * 100) / 100;
+ $( this )
+ .css( position )
+ .text( feedback.horizontal + " " + feedback.vertical + " " + feedback.important + " " + angle + "°" )
+ .css({
+ "-webkit-transform": "rotate(" + angle + "deg)",
+ "-moz-transform": "rotate(" + angle + "deg)",
+ "-ms-transform": "rotate(" + angle + "deg)",
+ "-o-transform": "rotate(" + angle + "deg)",
+ "transform": "rotate(" + angle + "deg)"
+ });
+ }
+
+ var element = $( ".element" ),
+ target = $( "#target" ).position({
+ my: "center",
+ at: "center",
+ of: window
+ }),
+ targetOffset = target.offset();
+ oppositeElement = element.clone().width( 50 ).appendTo( "body" ),
+ leftElement = element.clone().width( 50 ).height( 150 ).appendTo( "body" ),
+ rightElement = element.clone().height( 150 ).width( 150 ).appendTo( "body" );
+
+ $.each([
+ "center top-100",
+ "right+25 top-50",
+ "right+75 top",
+ "right+75 center",
+ "right+75 bottom",
+ "right+25 bottom+50",
+ "center bottom+100",
+ "left-25 bottom+50",
+ "left-75 bottom",
+ "left-75 center",
+ "left-75 top",
+ "left-25 top-50"
+ ], function( index, direction ) {
+ element.clone().insertAfter( target ).position({
+ my: "center",
+ at: direction,
+ of: target,
+ using: using
+ });
+ });
+
+ element.width( 150 );
+ $( document ).on( "mousemove", function( event ) {
+ var base = {
+ my: "left top",
+ at: "left top",
+ of: target,
+ using: using
+ };
+ element.position( $.extend({
+ offset: (event.pageX - targetOffset.left) + " " + (event.pageY - targetOffset.top)
+ }, base ));
+ oppositeElement.position( $.extend({
+ offset: (-1 * (event.pageX - targetOffset.left)) + " " + (-1 * (event.pageY - targetOffset.top))
+ }, base ));
+ leftElement.position( $.extend({
+ offset: (-0.9 * (event.pageX - targetOffset.left)) + " " + (0.9 * (event.pageY - targetOffset.top))
+ }, base ));
+ rightElement.position( $.extend({
+ offset: (0.9 * (event.pageX - targetOffset.left)) + " " + (-0.9 * (event.pageY - targetOffset.top))
+ }, base ));
+ });
+ });
+ </script>
+ <style>
+ #target, .element {
+ position: absolute;
+ border: 1px solid black;
+ border-radius: 5px;
+ width: 75px;
+ height: 25px;
+ padding: 5px;
+ }
+ #target {
+ height: 75px;
+ }
+ </style>
+</head>
+<body>
+
+<div id="target">all around me</div>
+<div class="element"></div>
+
+</body>
+</html>
diff --git a/tests/visual/position/position_fit.html b/tests/visual/position/position_fit.html
index 9c60b78f6..a70423c79 100644
--- a/tests/visual/position/position_fit.html
+++ b/tests/visual/position/position_fit.html
@@ -10,15 +10,14 @@
<script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="../../../ui/jquery.ui.position.js"></script>
<script type="text/javascript" src="../../../ui/jquery.ui.menu.js"></script>
- <script type="text/javascript" src="http://jqueryui.com/themeroller/themeswitchertool/"></script>
<script type="text/javascript">
$(function() {
var inputs = $("input");
$("ul").insertAfter(inputs);
inputs.each(function(index) {
$(this).position({
- my: this.id.replace(/-/, " "),
- at: this.id.replace(/-/, " "),
+ my: $(this).data("position"),
+ at: $(this).data("position"),
of: "#container"+index,
collision: "none"
});
@@ -114,25 +113,25 @@
<div id="container16" class="container2"></div>
<div id="container17" class="container2"></div>
-<input id="left-top" />
-<input id="center-top" />
-<input id="right-top" />
-<input id="left-top" />
-<input id="center-top" />
-<input id="right-top" />
-<input id="left-top" />
-<input id="center-top" />
-<input id="right-top" />
+<input data-position="left top" />
+<input data-position="center top" />
+<input data-position="right top" />
+<input data-position="left top" />
+<input data-position="center top" />
+<input data-position="right top" />
+<input data-position="left top" />
+<input data-position="center top" />
+<input data-position="right top" />
-<input id="left-top" />
-<input id="center-center" />
-<input id="right-bottom" />
-<input id="left-top" />
-<input id="center-center" />
-<input id="right-bottom" />
-<input id="left-top" />
-<input id="center-center" />
-<input id="right-bottom" />
+<input data-position="left top" />
+<input data-position="center center" />
+<input data-position="right bottom" />
+<input data-position="left top" />
+<input data-position="center center" />
+<input data-position="right bottom" />
+<input data-position="left top" />
+<input data-position="center center" />
+<input data-position="right bottom" />
<ul>
<li><a href="#">Java</a></li>
diff --git a/tests/visual/position/position_flip.html b/tests/visual/position/position_flip.html
index bae3c649b..b67c76fb3 100644
--- a/tests/visual/position/position_flip.html
+++ b/tests/visual/position/position_flip.html
@@ -10,15 +10,14 @@
<script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="../../../ui/jquery.ui.position.js"></script>
<script type="text/javascript" src="../../../ui/jquery.ui.menu.js"></script>
- <script type="text/javascript" src="http://jqueryui.com/themeroller/themeswitchertool/"></script>
<script type="text/javascript">
$(function() {
var inputs = $("input");
$("ul").insertAfter(inputs);
inputs.each(function(index) {
$(this).position({
- my: this.id.replace(/-/, " "),
- at: this.id.replace(/-/, " "),
+ my: $(this).data("position"),
+ at: $(this).data("position"),
of: "#container"+index,
collision: "none"
});
@@ -53,15 +52,15 @@
<div id="container7" class="container" style="height:100px; margin-bottom: 500px;"></div>
<div id="container8" class="container" style="height:100px; margin-bottom: 500px;"></div>
-<input id="left-top" />
-<input id="center-top" />
-<input id="right-top" />
-<input id="left-center" />
-<input id="center-center" />
-<input id="right-center" />
-<input id="left-bottom" />
-<input id="center-center" />
-<input id="right-bottom" />
+<input data-position="left top" />
+<input data-position="center top" />
+<input data-position="right top" />
+<input data-position="left center" />
+<input data-position="center center" />
+<input data-position="right center" />
+<input data-position="left bottom" />
+<input data-position="center center" />
+<input data-position="right bottom" />
<ul>
<li><a href="#">Java</a></li>
diff --git a/tests/visual/position/position_flipfit.html b/tests/visual/position/position_flipfit.html
index fcfb75b6b..840dd5868 100644
--- a/tests/visual/position/position_flipfit.html
+++ b/tests/visual/position/position_flipfit.html
@@ -10,15 +10,14 @@
<script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="../../../ui/jquery.ui.position.js"></script>
<script type="text/javascript" src="../../../ui/jquery.ui.menu.js"></script>
- <script type="text/javascript" src="http://jqueryui.com/themeroller/themeswitchertool/"></script>
<script type="text/javascript">
$(function() {
var inputs = $("input");
$("ul").insertAfter(inputs);
inputs.each(function(index) {
$(this).position({
- my: this.id.replace(/-/, " "),
- at: this.id.replace(/-/, " "),
+ my: $(this).data("position"),
+ at: $(this).data("position"),
of: "#container"+index,
collision: "none"
});
@@ -59,18 +58,18 @@
<div id="container10" class="container" style="height:100px; margin-bottom: 500px;"></div>
<div id="container11" class="container" style="height:100px; margin-bottom: 500px;"></div>
-<input id="left-top" />
-<input id="center-top" />
-<input id="right-top" />
-<input id="left-top" />
-<input id="center-top" />
-<input id="right-top" />
-<input id="left-center" />
-<input id="center-center" />
-<input id="right-center" />
-<input id="left-bottom" />
-<input id="center-center" />
-<input id="right-bottom" />
+<input data-position="left top" />
+<input data-position="center top" />
+<input data-position="right top" />
+<input data-position="left top" />
+<input data-position="center top" />
+<input data-position="right top" />
+<input data-position="left center" />
+<input data-position="center center" />
+<input data-position="right center" />
+<input data-position="left bottom" />
+<input data-position="center center" />
+<input data-position="right bottom" />
<ul>
<li><a href="#">Java</a></li>
diff --git a/tests/visual/position/position_margin.html b/tests/visual/position/position_margin.html
index 71d8f0a3c..2e3b63266 100644
--- a/tests/visual/position/position_margin.html
+++ b/tests/visual/position/position_margin.html
@@ -9,7 +9,6 @@
<script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script>
<script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="../../../ui/jquery.ui.position.js"></script>
- <script type="text/javascript" src="http://jqueryui.com/themeroller/themeswitchertool/"></script>
<script type="text/javascript">
$(function() {
$( "#elem" ).position({
diff --git a/tests/visual/position/position_within.html b/tests/visual/position/position_within.html
index 7d8813582..692cb1067 100644
--- a/tests/visual/position/position_within.html
+++ b/tests/visual/position/position_within.html
@@ -97,7 +97,7 @@
collision: $( "#collision_horizontal" ).val() + " " + $( "#collision_vertical" ).val()
});
}
- $( ".demo" ).append("<div style='width:5000px;height:5000px;' />").css("overflow","auto");
+ $( ".demo" ).css("overflow","scroll");
$( ".positionable" ).css( "opacity", 0.5 );
diff --git a/tests/visual/theme.html b/tests/visual/theme.html
index fe9146169..83e46d97c 100644
--- a/tests/visual/theme.html
+++ b/tests/visual/theme.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+ <meta charset="utf-8">
<title>jQuery UI Example Page</title>
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css" type="text/css">
<script type="text/javascript" src="../../jquery-1.7.2.js"></script>
@@ -28,26 +28,26 @@
// Accordion
$(".accordion").accordion({ header: "h3" });
$(".accordion").last().accordion("option", "icons", false);
-
-
+
+
// Tabs
$('#tabs').tabs();
-
- // Dialog
+
+ // Dialog
$('#dialog').dialog({
autoOpen: false,
width: 600,
buttons: {
- "Ok": function() {
- $(this).dialog("close");
- },
- "Cancel": function() {
- $(this).dialog("close");
- }
+ "Ok": function() {
+ $(this).dialog("close");
+ },
+ "Cancel": function() {
+ $(this).dialog("close");
+ }
}
});
-
+
// Dialog Link
$('#dialog_link').click(function(){
$('#dialog').dialog('open');
@@ -59,19 +59,19 @@
inline: true,
showWeek: true
});
-
+
$('#multidatepicker').datepicker({
numberOfMonths: 3,
showButtonPanel: true,
inline: true
});
-
+
// Slider
$('.slider').slider({
range: true,
values: [17, 67]
});
-
+
$("#eq > span").each(function() {
var value = parseInt($(this).text());
$(this).empty().slider({
@@ -81,19 +81,19 @@
orientation: "vertical"
});
});
-
-
+
+
// Progressbar
$("#progressbar").progressbar({
- value: 20
+ value: 20
});
-
+
//hover states on the static widgets
$('#dialog_link, ul#icons li').hover(
- function() { $(this).addClass('ui-state-hover'); },
+ function() { $(this).addClass('ui-state-hover'); },
function() { $(this).removeClass('ui-state-hover'); }
);
-
+
$(".buttonset > button").button()
.next()
.button({
@@ -104,8 +104,8 @@
})
.parent()
.buttonset();
-
-
+
+
$('#beginning').button({
text: false,
icons: {
@@ -144,7 +144,7 @@
});
$("#shuffle").button();
$("#repeat").buttonset();
-
+
});
</script>
<style type="text/css">
@@ -160,13 +160,13 @@
#eq span { height:120px; float:left; margin:15px }
.buttonset {margin-bottom: 5px; }
#toolbar { padding: 10px 4px; }
- </style>
+ </style>
</head>
<body>
<!-- <p style="font-size: 1.3em; line-height: 1.5; margin: 1em 0; width: 50%;">This page demonstrates the widgets using a theme.</p> -->
<div id="switcher" style="position:absolute; right: 20px; top: 20px;"></div>
-
+
<!-- Accordion -->
<h2 class="demoHeaders">Accordion</h2>
<div class="columnbox">
@@ -201,8 +201,8 @@
</div>
</div>
</div>
-
-
+
+
<!-- Tabs -->
<h2 class="demoHeaders">Tabs</h2>
<div id="tabs">
@@ -215,20 +215,20 @@
<div id="tabs-2">Phasellus mattis tincidunt nibh. Cras orci urna, blandit id, pretium vel, aliquet ornare, felis. Maecenas scelerisque sem non nisl. Fusce sed lorem in enim dictum bibendum.</div>
<div id="tabs-3">Nam dui erat, auctor a, dignissim quis, sollicitudin eu, felis. Pellentesque nisi urna, interdum eget, sagittis et, consequat vestibulum, lacus. Mauris porttitor ullamcorper augue.</div>
</div>
-
+
<!-- Dialog NOTE: Dialog is not generated by UI in this demo so it can be visually styled in themeroller-->
<h2 class="demoHeaders">Dialog</h2>
<p><a href="#" id="dialog_link" class="ui-state-default ui-corner-all"><span class="ui-icon ui-icon-newwin"></span>Open Dialog</a></p>
-
+
<div class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-draggable ui-resizable" ><div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix"><span class="ui-dialog-title">Inline Dialog</span><a href="#" class="ui-dialog-titlebar-close ui-corner-all" ><span class="ui-icon ui-icon-closethick" >close</span></a></div><div class="ui-dialog-content ui-widget-content" >
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div><div class="ui-resizable-handle ui-resizable-n" ></div><div class="ui-resizable-handle ui-resizable-e" ></div><div class="ui-resizable-handle ui-resizable-s" ></div><div class="ui-resizable-handle ui-resizable-w" ></div><div class="ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se ui-icon-grip-diagonal-se" ></div><div class="ui-resizable-handle ui-resizable-sw" ></div><div class="ui-resizable-handle ui-resizable-ne" ></div><div class="ui-resizable-handle ui-resizable-nw" ></div><div class="ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"><button type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false"><span class="ui-button-text">Ok</span></button><button type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false"><span class="ui-button-text">Cancel</span></button></div></div>
-
-
+
+
<h2 class="demoHeaders">Overlay and Shadow Classes <em>(not currently used in UI widgets)</em></h2>
<div style="position: relative; width: 96%; height: 200px; padding:1% 4%; overflow:hidden;" class="fakewindowcontain">
<p>Lorem ipsum dolor sit amet, Nulla nec tortor. Donec id elit quis purus consectetur consequat. </p><p>Nam congue semper tellus. Sed erat dolor, dapibus sit amet, venenatis ornare, ultrices ut, nisi. Aliquam ante. Suspendisse scelerisque dui nec velit. Duis augue augue, gravida euismod, vulputate ac, facilisis id, sem. Morbi in orci. </p><p>Nulla purus lacus, pulvinar vel, malesuada ac, mattis nec, quam. Nam molestie scelerisque quam. Nullam feugiat cursus lacus.orem ipsum dolor sit amet, consectetur adipiscing elit. Donec libero risus, commodo vitae, pharetra mollis, posuere eu, pede. Nulla nec tortor. Donec id elit quis purus consectetur consequat. </p><p>Nam congue semper tellus. Sed erat dolor, dapibus sit amet, venenatis ornare, ultrices ut, nisi. Aliquam ante. Suspendisse scelerisque dui nec velit. Duis augue augue, gravida euismod, vulputate ac, facilisis id, sem. Morbi in orci. Nulla purus lacus, pulvinar vel, malesuada ac, mattis nec, quam. Nam molestie scelerisque quam. </p><p>Nullam feugiat cursus lacus.orem ipsum dolor sit amet, consectetur adipiscing elit. Donec libero risus, commodo vitae, pharetra mollis, posuere eu, pede. Nulla nec tortor. Donec id elit quis purus consectetur consequat. Nam congue semper tellus. Sed erat dolor, dapibus sit amet, venenatis ornare, ultrices ut, nisi. Aliquam ante. </p><p>Suspendisse scelerisque dui nec velit. Duis augue augue, gravida euismod, vulputate ac, facilisis id, sem. Morbi in orci. Nulla purus lacus, pulvinar vel, malesuada ac, mattis nec, quam. Nam molestie scelerisque quam. Nullam feugiat cursus lacus.orem ipsum dolor sit amet, consectetur adipiscing elit. Donec libero risus, commodo vitae, pharetra mollis, posuere eu, pede. Nulla nec tortor. Donec id elit quis purus consectetur consequat. Nam congue semper tellus. Sed erat dolor, dapibus sit amet, venenatis ornare, ultrices ut, nisi. </p>
-
+
<!-- ui-dialog -->
<div class="ui-overlay"><div class="ui-widget-overlay"></div><div class="ui-widget-shadow ui-corner-all" style="width: 302px; height: 152px; position: absolute; left: 50px; top: 30px;"></div></div>
<div style="position: absolute; width: 280px; height: 130px;left: 50px; top: 30px; padding: 10px;" class="ui-widget ui-widget-content ui-corner-all">
@@ -236,24 +236,24 @@
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
</div>
-
+
</div>
-
+
<!-- ui-dialog -->
<div id="dialog" title="Dialog Title">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
-
-
-
+
+
+
<h2 class="demoHeaders">Framework Icons (content color preview)</h2>
<ul id="icons" class="ui-widget ui-helper-clearfix">
-
+
<li class="ui-state-default ui-corner-all" title=".ui-icon-carat-1-n"><span class="ui-icon ui-icon-carat-1-n"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-carat-1-ne"><span class="ui-icon ui-icon-carat-1-ne"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-carat-1-e"><span class="ui-icon ui-icon-carat-1-e"></span></li>
-
+
<li class="ui-state-default ui-corner-all" title=".ui-icon-carat-1-se"><span class="ui-icon ui-icon-carat-1-se"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-carat-1-s"><span class="ui-icon ui-icon-carat-1-s"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-carat-1-sw"><span class="ui-icon ui-icon-carat-1-sw"></span></li>
@@ -263,7 +263,7 @@
<li class="ui-state-default ui-corner-all" title=".ui-icon-carat-2-e-w"><span class="ui-icon ui-icon-carat-2-e-w"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-triangle-1-n"><span class="ui-icon ui-icon-triangle-1-n"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-triangle-1-ne"><span class="ui-icon ui-icon-triangle-1-ne"></span></li>
-
+
<li class="ui-state-default ui-corner-all" title=".ui-icon-triangle-1-e"><span class="ui-icon ui-icon-triangle-1-e"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-triangle-1-se"><span class="ui-icon ui-icon-triangle-1-se"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-triangle-1-s"><span class="ui-icon ui-icon-triangle-1-s"></span></li>
@@ -273,7 +273,7 @@
<li class="ui-state-default ui-corner-all" title=".ui-icon-triangle-2-n-s"><span class="ui-icon ui-icon-triangle-2-n-s"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-triangle-2-e-w"><span class="ui-icon ui-icon-triangle-2-e-w"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrow-1-n"><span class="ui-icon ui-icon-arrow-1-n"></span></li>
-
+
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrow-1-ne"><span class="ui-icon ui-icon-arrow-1-ne"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrow-1-e"><span class="ui-icon ui-icon-arrow-1-e"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrow-1-se"><span class="ui-icon ui-icon-arrow-1-se"></span></li>
@@ -283,7 +283,7 @@
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrow-1-nw"><span class="ui-icon ui-icon-arrow-1-nw"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrow-2-n-s"><span class="ui-icon ui-icon-arrow-2-n-s"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrow-2-ne-sw"><span class="ui-icon ui-icon-arrow-2-ne-sw"></span></li>
-
+
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrow-2-e-w"><span class="ui-icon ui-icon-arrow-2-e-w"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrow-2-se-nw"><span class="ui-icon ui-icon-arrow-2-se-nw"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowstop-1-n"><span class="ui-icon ui-icon-arrowstop-1-n"></span></li>
@@ -293,7 +293,7 @@
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowthick-1-n"><span class="ui-icon ui-icon-arrowthick-1-n"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowthick-1-ne"><span class="ui-icon ui-icon-arrowthick-1-ne"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowthick-1-e"><span class="ui-icon ui-icon-arrowthick-1-e"></span></li>
-
+
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowthick-1-se"><span class="ui-icon ui-icon-arrowthick-1-se"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowthick-1-s"><span class="ui-icon ui-icon-arrowthick-1-s"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowthick-1-sw"><span class="ui-icon ui-icon-arrowthick-1-sw"></span></li>
@@ -303,7 +303,7 @@
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowthick-2-ne-sw"><span class="ui-icon ui-icon-arrowthick-2-ne-sw"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowthick-2-e-w"><span class="ui-icon ui-icon-arrowthick-2-e-w"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowthick-2-se-nw"><span class="ui-icon ui-icon-arrowthick-2-se-nw"></span></li>
-
+
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowthickstop-1-n"><span class="ui-icon ui-icon-arrowthickstop-1-n"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowthickstop-1-e"><span class="ui-icon ui-icon-arrowthickstop-1-e"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowthickstop-1-s"><span class="ui-icon ui-icon-arrowthickstop-1-s"></span></li>
@@ -313,7 +313,7 @@
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowreturnthick-1-e"><span class="ui-icon ui-icon-arrowreturnthick-1-e"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowreturnthick-1-s"><span class="ui-icon ui-icon-arrowreturnthick-1-s"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowreturn-1-w"><span class="ui-icon ui-icon-arrowreturn-1-w"></span></li>
-
+
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowreturn-1-n"><span class="ui-icon ui-icon-arrowreturn-1-n"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowreturn-1-e"><span class="ui-icon ui-icon-arrowreturn-1-e"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowreturn-1-s"><span class="ui-icon ui-icon-arrowreturn-1-s"></span></li>
@@ -323,7 +323,7 @@
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowrefresh-1-s"><span class="ui-icon ui-icon-arrowrefresh-1-s"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrow-4"><span class="ui-icon ui-icon-arrow-4"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrow-4-diag"><span class="ui-icon ui-icon-arrow-4-diag"></span></li>
-
+
<li class="ui-state-default ui-corner-all" title=".ui-icon-extlink"><span class="ui-icon ui-icon-extlink"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-newwin"><span class="ui-icon ui-icon-newwin"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-refresh"><span class="ui-icon ui-icon-refresh"></span></li>
@@ -333,7 +333,7 @@
<li class="ui-state-default ui-corner-all" title=".ui-icon-folder-collapsed"><span class="ui-icon ui-icon-folder-collapsed"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-folder-open"><span class="ui-icon ui-icon-folder-open"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-document"><span class="ui-icon ui-icon-document"></span></li>
-
+
<li class="ui-state-default ui-corner-all" title=".ui-icon-document-b"><span class="ui-icon ui-icon-document-b"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-note"><span class="ui-icon ui-icon-note"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-mail-closed"><span class="ui-icon ui-icon-mail-closed"></span></li>
@@ -343,7 +343,7 @@
<li class="ui-state-default ui-corner-all" title=".ui-icon-person"><span class="ui-icon ui-icon-person"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-print"><span class="ui-icon ui-icon-print"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-trash"><span class="ui-icon ui-icon-trash"></span></li>
-
+
<li class="ui-state-default ui-corner-all" title=".ui-icon-locked"><span class="ui-icon ui-icon-locked"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-unlocked"><span class="ui-icon ui-icon-unlocked"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-bookmark"><span class="ui-icon ui-icon-bookmark"></span></li>
@@ -353,7 +353,7 @@
<li class="ui-state-default ui-corner-all" title=".ui-icon-calculator"><span class="ui-icon ui-icon-calculator"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-cart"><span class="ui-icon ui-icon-cart"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-pencil"><span class="ui-icon ui-icon-pencil"></span></li>
-
+
<li class="ui-state-default ui-corner-all" title=".ui-icon-clock"><span class="ui-icon ui-icon-clock"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-disk"><span class="ui-icon ui-icon-disk"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-calendar"><span class="ui-icon ui-icon-calendar"></span></li>
@@ -363,7 +363,7 @@
<li class="ui-state-default ui-corner-all" title=".ui-icon-wrench"><span class="ui-icon ui-icon-wrench"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-gear"><span class="ui-icon ui-icon-gear"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-heart"><span class="ui-icon ui-icon-heart"></span></li>
-
+
<li class="ui-state-default ui-corner-all" title=".ui-icon-star"><span class="ui-icon ui-icon-star"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-link"><span class="ui-icon ui-icon-link"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-cancel"><span class="ui-icon ui-icon-cancel"></span></li>
@@ -373,7 +373,7 @@
<li class="ui-state-default ui-corner-all" title=".ui-icon-minusthick"><span class="ui-icon ui-icon-minusthick"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-close"><span class="ui-icon ui-icon-close"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-closethick"><span class="ui-icon ui-icon-closethick"></span></li>
-
+
<li class="ui-state-default ui-corner-all" title=".ui-icon-key"><span class="ui-icon ui-icon-key"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-lightbulb"><span class="ui-icon ui-icon-lightbulb"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-scissors"><span class="ui-icon ui-icon-scissors"></span></li>
@@ -384,7 +384,7 @@
<li class="ui-state-default ui-corner-all" title=".ui-icon-video"><span class="ui-icon ui-icon-video"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-script"><span class="ui-icon ui-icon-script"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-alert"><span class="ui-icon ui-icon-alert"></span></li>
-
+
<li class="ui-state-default ui-corner-all" title=".ui-icon-info"><span class="ui-icon ui-icon-info"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-notice"><span class="ui-icon ui-icon-notice"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-help"><span class="ui-icon ui-icon-help"></span></li>
@@ -396,7 +396,7 @@
<li class="ui-state-default ui-corner-all" title=".ui-icon-pin-s"><span class="ui-icon ui-icon-pin-s"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-play"><span class="ui-icon ui-icon-play"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-pause"><span class="ui-icon ui-icon-pause"></span></li>
-
+
<li class="ui-state-default ui-corner-all" title=".ui-icon-seek-next"><span class="ui-icon ui-icon-seek-next"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-seek-prev"><span class="ui-icon ui-icon-seek-prev"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-seek-end"><span class="ui-icon ui-icon-seek-end"></span></li>
@@ -406,7 +406,7 @@
<li class="ui-state-default ui-corner-all" title=".ui-icon-volume-off"><span class="ui-icon ui-icon-volume-off"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-volume-on"><span class="ui-icon ui-icon-volume-on"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-power"><span class="ui-icon ui-icon-power"></span></li>
-
+
<li class="ui-state-default ui-corner-all" title=".ui-icon-signal-diag"><span class="ui-icon ui-icon-signal-diag"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-signal"><span class="ui-icon ui-icon-signal"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-battery-0"><span class="ui-icon ui-icon-battery-0"></span></li>
@@ -416,7 +416,7 @@
<li class="ui-state-default ui-corner-all" title=".ui-icon-circle-plus"><span class="ui-icon ui-icon-circle-plus"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-circle-minus"><span class="ui-icon ui-icon-circle-minus"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-circle-close"><span class="ui-icon ui-icon-circle-close"></span></li>
-
+
<li class="ui-state-default ui-corner-all" title=".ui-icon-circle-triangle-e"><span class="ui-icon ui-icon-circle-triangle-e"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-circle-triangle-s"><span class="ui-icon ui-icon-circle-triangle-s"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-circle-triangle-w"><span class="ui-icon ui-icon-circle-triangle-w"></span></li>
@@ -426,7 +426,7 @@
<li class="ui-state-default ui-corner-all" title=".ui-icon-circle-arrow-w"><span class="ui-icon ui-icon-circle-arrow-w"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-circle-arrow-n"><span class="ui-icon ui-icon-circle-arrow-n"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-circle-zoomin"><span class="ui-icon ui-icon-circle-zoomin"></span></li>
-
+
<li class="ui-state-default ui-corner-all" title=".ui-icon-circle-zoomout"><span class="ui-icon ui-icon-circle-zoomout"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-circle-check"><span class="ui-icon ui-icon-circle-check"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-circlesmall-plus"><span class="ui-icon ui-icon-circlesmall-plus"></span></li>
@@ -436,7 +436,7 @@
<li class="ui-state-default ui-corner-all" title=".ui-icon-squaresmall-minus"><span class="ui-icon ui-icon-squaresmall-minus"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-squaresmall-close"><span class="ui-icon ui-icon-squaresmall-close"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-grip-dotted-vertical"><span class="ui-icon ui-icon-grip-dotted-vertical"></span></li>
-
+
<li class="ui-state-default ui-corner-all" title=".ui-icon-grip-dotted-horizontal"><span class="ui-icon ui-icon-grip-dotted-horizontal"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-grip-solid-vertical"><span class="ui-icon ui-icon-grip-solid-vertical"></span></li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-grip-solid-horizontal"><span class="ui-icon ui-icon-grip-solid-horizontal"></span></li>
@@ -444,7 +444,7 @@
<li class="ui-state-default ui-corner-all" title=".ui-icon-grip-diagonal-se"><span class="ui-icon ui-icon-grip-diagonal-se"></span></li>
</ul>
-
+
<!-- Slider -->
<h2 class="demoHeaders">Slider</h2>
<div class="columnbox">
@@ -461,8 +461,8 @@
<span>70</span>
</div>
</div>
-
-
+
+
<!-- Datepicker -->
<h2 class="demoHeaders">Datepicker</h2>
<div class="columnbox" style="width: 32%">
@@ -471,35 +471,35 @@
<div class="columnbox" style="width: 66%; height: 220px;">
<div id="multidatepicker"></div>
</div>
-
-
+
+
<!-- Progressbar -->
- <h2 class="demoHeaders">Progressbar</h2>
+ <h2 class="demoHeaders">Progressbar</h2>
<div id="progressbar"></div>
-
+
<!-- Highlight / Error -->
<h2 class="demoHeaders">Highlight / Error</h2>
<div class="ui-widget">
- <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
+ <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
<p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
<strong>Hey!</strong> Sample ui-state-highlight style.</p>
</div>
</div>
<br/>
<div class="ui-widget">
- <div class="ui-state-error ui-corner-all" style="padding: 0 .7em;">
- <p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
+ <div class="ui-state-error ui-corner-all" style="padding: 0 .7em;">
+ <p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
<strong>Alert:</strong> Sample ui-state-error style.</p>
</div>
</div>
-
+
<h2 class="demoHeaders">Button</h2>
-
+
<div class="buttonset">
<button id="rerun">Run last action</button>
<button id="select">Select an action</button>
</div>
-
+
<span id="toolbar" class="ui-widget-header ui-corner-all">
<button id="beginning">go to beginning</button>
<button id="rewind">rewind</button>
@@ -507,18 +507,18 @@
<button id="stop">stop</button>
<button id="forward">fast forward</button>
<button id="end">go to end</button>
-
+
<input type="checkbox" id="shuffle" /><label for="shuffle">Shuffle</label>
-
+
<span id="repeat">
<input type="radio" id="repeat0" name="repeat" checked="checked" /><label for="repeat0">No Repeat</label>
<input type="radio" id="repeat1" name="repeat" /><label for="repeat1">Once</label>
<input type="radio" id="repeatall" name="repeat" /><label for="repeatall">All</label>
</span>
- </span>
-
+ </span>
+
<!-- theme switcher -->
-
+
<script src="http://jqueryui.com/themeroller/themeswitchertool/"></script>
<script>
$('#switcher').themeswitcher();
diff --git a/tests/visual/tooltip/animations.html b/tests/visual/tooltip/animations.html
index 10235b2f9..38ee28f1d 100644
--- a/tests/visual/tooltip/animations.html
+++ b/tests/visual/tooltip/animations.html
@@ -1,6 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
+ <meta charset="utf-8">
<title>Tooltip Visual Test: Default</title>
<link rel="stylesheet" href="../visual.css" type="text/css" />
<link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css">
diff --git a/tests/visual/tooltip/tooltip.html b/tests/visual/tooltip/tooltip.html
index 63c756ce0..da811645c 100644
--- a/tests/visual/tooltip/tooltip.html
+++ b/tests/visual/tooltip/tooltip.html
@@ -1,6 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
+ <meta charset="utf-8">
<title>Tooltip Visual Test: Default</title>
<link rel="stylesheet" href="../visual.css" type="text/css" />
<link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css">
diff --git a/themes/base/jquery.ui.menu.css b/themes/base/jquery.ui.menu.css
index 4469e74d3..b96d439ab 100644
--- a/themes/base/jquery.ui.menu.css
+++ b/themes/base/jquery.ui.menu.css
@@ -10,6 +10,7 @@
.ui-menu { list-style:none; padding: 2px; margin: 0; display:block; outline: none; }
.ui-menu .ui-menu { margin-top: -3px; position: absolute; }
.ui-menu .ui-menu-item { margin: 0; padding: 0; zoom: 1; width: 100%; }
+.ui-menu .ui-menu-divider { margin: 5px -2px 5px -2px; height: 0; font-size: 0; line-height: 0; border-width: 1px 0 0 0; }
.ui-menu .ui-menu-item a { text-decoration: none; display: block; padding: 2px .4em; line-height: 1.5; zoom: 1; font-weight: normal; }
.ui-menu .ui-menu-item a.ui-state-focus,
.ui-menu .ui-menu-item a.ui-state-active { font-weight: normal; margin: -1px; }
diff --git a/themes/base/jquery.ui.resizable.css b/themes/base/jquery.ui.resizable.css
index 0bf680482..0bb688d5b 100644
--- a/themes/base/jquery.ui.resizable.css
+++ b/themes/base/jquery.ui.resizable.css
@@ -8,7 +8,7 @@
* http://docs.jquery.com/UI/Resizable#theming
*/
.ui-resizable { position: relative;}
-.ui-resizable-handle { position: absolute;font-size: 0.1px;z-index: 99999; display: block; }
+.ui-resizable-handle { position: absolute;font-size: 0.1px; display: block; }
.ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle { display: none; }
.ui-resizable-n { cursor: n-resize; height: 7px; width: 100%; top: -5px; left: 0; }
.ui-resizable-s { cursor: s-resize; height: 7px; width: 100%; bottom: -5px; left: 0; }
diff --git a/themes/base/jquery.ui.spinner.css b/themes/base/jquery.ui.spinner.css
index 7c0737c31..50d8e19b7 100644
--- a/themes/base/jquery.ui.spinner.css
+++ b/themes/base/jquery.ui.spinner.css
@@ -9,7 +9,7 @@
*/
.ui-spinner { position:relative; display: inline-block; overflow: hidden; padding: 0; vertical-align: middle; }
.ui-spinner-input { border: none; background: none; padding: 0; margin: .2em 0; vertical-align: middle; margin-left: .4em; margin-right: 22px; }
-.ui-spinner-button { width: 16px; height: 50%; font-size: .5em; padding: 0; margin: 0; z-index: 100; text-align: center; vertical-align: middle; position: absolute; cursor: default; display: block; overflow: hidden; right: 0; }
+.ui-spinner-button { width: 16px; height: 50%; font-size: .5em; padding: 0; margin: 0; z-index: 100; text-align: center; position: absolute; cursor: default; display: block; overflow: hidden; right: 0; }
.ui-spinner a.ui-spinner-button { border-top: none; border-bottom: none; border-right: none; } /* more specificity required here to overide default borders */
.ui-spinner .ui-icon { position: absolute; margin-top: -8px; top: 50%; left: 0; } /* vertical centre icon */
.ui-spinner-up { top: 0; }
diff --git a/themes/base/jquery.ui.tabs.css b/themes/base/jquery.ui.tabs.css
index 5282817c2..6a5c455f9 100644
--- a/themes/base/jquery.ui.tabs.css
+++ b/themes/base/jquery.ui.tabs.css
@@ -13,5 +13,5 @@
.ui-tabs .ui-tabs-nav li a { float: left; padding: .5em 1em; text-decoration: none; }
.ui-tabs .ui-tabs-nav li.ui-tabs-active { margin-bottom: -1px; padding-bottom: 1px; }
.ui-tabs .ui-tabs-nav li.ui-tabs-active a, .ui-tabs .ui-tabs-nav li.ui-state-disabled a, .ui-tabs .ui-tabs-nav li.ui-tabs-loading a { cursor: text; }
-.ui-tabs .ui-tabs-nav li a, .ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-active a { cursor: pointer; } /* first selector in group seems obsolete, but required to overcome bug in Opera applying cursor: text overall if defined elsewhere... */
+.ui-tabs .ui-tabs-nav li a, .ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-active a { cursor: pointer; } /* first selector in group seems obsolete, but required to overcome bug in Opera applying cursor: text overall if defined elsewhere... */
.ui-tabs .ui-tabs-panel { display: block; border-width: 0; padding: 1em 1.4em; background: none; }
diff --git a/themes/base/jquery.ui.tooltip.css b/themes/base/jquery.ui.tooltip.css
index f1fa50cc6..d144b0a7f 100644
--- a/themes/base/jquery.ui.tooltip.css
+++ b/themes/base/jquery.ui.tooltip.css
@@ -4,8 +4,6 @@
* Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
- *
- * http://docs.jquery.com/UI/Tooltip#theming
*/
.ui-tooltip {
padding:8px;
diff --git a/ui/.jshintrc b/ui/.jshintrc
new file mode 100644
index 000000000..415d69e90
--- /dev/null
+++ b/ui/.jshintrc
@@ -0,0 +1,17 @@
+{
+ "browser": true,
+ "curly": true,
+ "eqnull": true,
+ "eqeqeq": true,
+ "expr": true,
+ "jquery": true,
+ "latedef": true,
+ "noarg": true,
+ "onevar": true,
+ "smarttabs": true,
+ "trailing": true,
+ "undef": true,
+ "predef": [
+ "Globalize"
+ ]
+}
diff --git a/ui/i18n/jquery.ui.datepicker-hi.js b/ui/i18n/jquery.ui.datepicker-hi.js
index d75e98ead..6c563b997 100644
--- a/ui/i18n/jquery.ui.datepicker-hi.js
+++ b/ui/i18n/jquery.ui.datepicker-hi.js
@@ -2,19 +2,19 @@
/* Written by Michael Dawart. */
jQuery(function($){
$.datepicker.regional['hi'] = {
- closeText: 'होकर',
- prevText: 'अगला',
- nextText: 'नेक्स्ट',
+ closeText: 'बंद',
+ prevText: 'पिछला',
+ nextText: 'अगला',
currentText: 'आज',
- monthNames: ['जनवरी ','फरवरी','मार्च','अप्रेल','मै','जून',
- 'जूलाई','अगस्त ','सितम्बर','आक्टोबर','नवम्बर','दिसम्बर'],
- monthNamesShort: ['जन', 'फर', 'मार्च', 'अप्रेल', 'मै', 'जून',
- 'जूलाई', 'अग', 'सित', 'आक्ट', 'नव', 'िद'],
- dayNames: ['रविवासर', 'सोमवासर', 'मंगलवासर', 'बुधवासर', 'गुरुवासर', 'शुक्रवासर', 'शनिवासर'],
+ monthNames: ['जनवरी ','फरवरी','मार्च','अप्रेल','मई','जून',
+ 'जूलाई','अगस्त ','सितम्बर','अक्टूबर','नवम्बर','दिसम्बर'],
+ monthNamesShort: ['जन', 'फर', 'मार्च', 'अप्रेल', 'मई', 'जून',
+ 'जूलाई', 'अग', 'सित', 'अक्ट', 'नव', 'दि'],
+ dayNames: ['रविवार', 'सोमवार', 'मंगलवार', 'बुधवार', 'गुरुवार', 'शुक्रवार', 'शनिवार'],
dayNamesShort: ['रवि', 'सोम', 'मंगल', 'बुध', 'गुरु', 'शुक्र', 'शनि'],
dayNamesMin: ['रवि', 'सोम', 'मंगल', 'बुध', 'गुरु', 'शुक्र', 'शनि'],
weekHeader: 'हफ्ता',
- dateFormat: 'mm/dd/yy',
+ dateFormat: 'dd/mm/yy',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
diff --git a/ui/jquery.effects.bounce.js b/ui/jquery.effects.bounce.js
index 94d73644e..934fb16ef 100644
--- a/ui/jquery.effects.bounce.js
+++ b/ui/jquery.effects.bounce.js
@@ -13,14 +13,14 @@
(function( $, undefined ) {
$.effects.effect.bounce = function( o, done ) {
- var el = $( this ),
+ var el = $( this ),
props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
// defaults:
mode = $.effects.setMode( el, o.mode || "effect" ),
hide = mode === "hide",
show = mode === "show",
- direction = o.direction || "up",
+ direction = o.direction || "up",
distance = o.distance,
times = o.times || 5,
@@ -31,7 +31,7 @@ $.effects.effect.bounce = function( o, done ) {
// utility:
ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
- motion = ( direction === "up" || direction === "left" ),
+ motion = ( direction === "up" || direction === "left" ),
i,
upAnim,
downAnim,
@@ -40,13 +40,13 @@ $.effects.effect.bounce = function( o, done ) {
queue = el.queue(),
queuelen = queue.length;
- // Avoid touching opacity to prevent clearType and PNG issues in IE
+ // Avoid touching opacity to prevent clearType and PNG issues in IE
if ( show || hide ) {
props.push( "opacity" );
- }
+ }
- $.effects.save( el, props );
- el.show();
+ $.effects.save( el, props );
+ el.show();
$.effects.createWrapper( el ); // Create Wrapper
// default distance for the BIGGEST bounce is the outer Distance / 3
@@ -90,7 +90,7 @@ $.effects.effect.bounce = function( o, done ) {
el.animate( upAnim, speed, easing );
}
-
+
el.queue(function() {
if ( hide ) {
el.hide();
diff --git a/ui/jquery.effects.core.js b/ui/jquery.effects.core.js
index 626ab1a89..fe2bf298d 100644
--- a/ui/jquery.effects.core.js
+++ b/ui/jquery.effects.core.js
@@ -268,16 +268,15 @@ $.effects.animateClass = function( value, duration, easing, callback ) {
// map all animated objects again - this time collecting a promise
allAnimations = allAnimations.map(function() {
var styleInfo = this,
- dfd = $.Deferred();
-
- this.el.animate( this.diff, {
- duration: o.duration,
- easing: o.easing,
- queue: false,
- complete: function() {
- dfd.resolve( styleInfo );
- }
- });
+ dfd = $.Deferred(),
+ opts = jQuery.extend({}, o, {
+ queue: false,
+ complete: function() {
+ dfd.resolve( styleInfo );
+ }
+ });
+
+ this.el.animate( this.diff, opts );
return dfd.promise();
});
@@ -429,6 +428,15 @@ $.extend( $.effects, {
},
active = document.activeElement;
+ // support: Firefox
+ // Firefox incorrectly exposes anonymous content
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
+ try {
+ active.id;
+ } catch( e ) {
+ active = document.body;
+ }
+
element.wrap( wrapper );
// Fixes #7595 - Elements lose focus when wrapped.
@@ -722,7 +730,7 @@ $.each( baseEasings, function( name, easeIn ) {
$.easing[ "easeInOut" + name ] = function( p ) {
return p < 0.5 ?
easeIn( p * 2 ) / 2 :
- easeIn( p * -2 + 2 ) / -2 + 1;
+ 1 - easeIn( p * -2 + 2 ) / 2;
};
});
diff --git a/ui/jquery.effects.drop.js b/ui/jquery.effects.drop.js
index 6c72be9e5..ea8d242d5 100644
--- a/ui/jquery.effects.drop.js
+++ b/ui/jquery.effects.drop.js
@@ -14,7 +14,7 @@
$.effects.effect.drop = function( o, done ) {
- var el = $( this ),
+ var el = $( this ),
props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
mode = $.effects.setMode( el, o.mode || "hide" ),
show = mode === "show",
@@ -27,9 +27,9 @@ $.effects.effect.drop = function( o, done ) {
distance;
// Adjust
- $.effects.save( el, props );
- el.show();
- $.effects.createWrapper( el );
+ $.effects.save( el, props );
+ el.show();
+ $.effects.createWrapper( el );
distance = o.distance || el[ ref === "top" ? "outerHeight": "outerWidth" ]({ margin: true }) / 2;
@@ -40,22 +40,22 @@ $.effects.effect.drop = function( o, done ) {
}
// Animation
- animation[ ref ] = ( show ?
- ( motion === "pos" ? "+=" : "-=" ) :
+ animation[ ref ] = ( show ?
+ ( motion === "pos" ? "+=" : "-=" ) :
( motion === "pos" ? "-=" : "+=" ) ) +
distance;
// Animate
- el.animate( animation, {
- queue: false,
- duration: o.duration,
- easing: o.easing,
+ el.animate( animation, {
+ queue: false,
+ duration: o.duration,
+ easing: o.easing,
complete: function() {
if ( mode === "hide" ) {
el.hide();
}
- $.effects.restore( el, props );
- $.effects.removeWrapper( el );
+ $.effects.restore( el, props );
+ $.effects.removeWrapper( el );
done();
}
});
diff --git a/ui/jquery.effects.fade.js b/ui/jquery.effects.fade.js
index 89784bd08..66029b51c 100644
--- a/ui/jquery.effects.fade.js
+++ b/ui/jquery.effects.fade.js
@@ -18,7 +18,7 @@ $.effects.effect.fade = function( o, done ) {
hide = mode === "hide";
el.show();
- el.animate({
+ el.animate({
opacity: hide ? 0 : 1
}, {
queue: false,
diff --git a/ui/jquery.effects.scale.js b/ui/jquery.effects.scale.js
index 83b41d3c2..5352bde77 100644
--- a/ui/jquery.effects.scale.js
+++ b/ui/jquery.effects.scale.js
@@ -18,9 +18,9 @@ $.effects.effect.puff = function( o, done ) {
hide = mode === "hide",
percent = parseInt( o.percent, 10 ) || 150,
factor = percent / 100,
- original = {
- height: elem.height(),
- width: elem.width()
+ original = {
+ height: elem.height(),
+ width: elem.width()
};
$.extend( o, {
@@ -51,8 +51,8 @@ $.effects.effect.scale = function( o, done ) {
( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
direction = o.direction || "both",
origin = o.origin,
- original = {
- height: el.height(),
+ original = {
+ height: el.height(),
width: el.width(),
outerHeight: el.outerHeight(),
outerWidth: el.outerWidth()
@@ -60,7 +60,7 @@ $.effects.effect.scale = function( o, done ) {
factor = {
y: direction !== "horizontal" ? (percent / 100) : 1,
x: direction !== "vertical" ? (percent / 100) : 1
- };
+ };
// We are going to pass this effect to the size effect:
options.effect = "size";
@@ -68,27 +68,27 @@ $.effects.effect.scale = function( o, done ) {
options.complete = done;
// Set default origin and restore for show/hide
- if ( mode !== "effect" ) {
+ if ( mode !== "effect" ) {
options.origin = origin || ["middle","center"];
options.restore = true;
}
- options.from = o.from || ( mode === "show" ? { height: 0, width: 0 } : original );
+ options.from = o.from || ( mode === "show" ? { height: 0, width: 0 } : original );
options.to = {
- height: original.height * factor.y,
+ height: original.height * factor.y,
width: original.width * factor.x,
- outerHeight: original.outerHeight * factor.y,
+ outerHeight: original.outerHeight * factor.y,
outerWidth: original.outerWidth * factor.x
- };
+ };
// Fade option to support puff
if ( options.fade ) {
if ( mode === "show" ) {
- options.from.opacity = 0;
+ options.from.opacity = 0;
options.to.opacity = 1;
}
if ( mode === "hide" ) {
- options.from.opacity = 1;
+ options.from.opacity = 1;
options.to.opacity = 0;
}
}
@@ -101,7 +101,7 @@ $.effects.effect.scale = function( o, done ) {
$.effects.effect.size = function( o, done ) {
// Create element
- var el = $( this ),
+ var el = $( this ),
props = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
// Always restore
@@ -125,7 +125,7 @@ $.effects.effect.size = function( o, done ) {
el.show();
}
original = {
- height: el.height(),
+ height: el.height(),
width: el.width(),
outerHeight: el.outerHeight(),
outerWidth: el.outerWidth()
@@ -137,11 +137,11 @@ $.effects.effect.size = function( o, done ) {
// Set scaling factor
factor = {
from: {
- y: el.from.height / original.height,
+ y: el.from.height / original.height,
x: el.from.width / original.width
},
to: {
- y: el.to.height / original.height,
+ y: el.to.height / original.height,
x: el.to.width / original.width
}
};
@@ -150,14 +150,14 @@ $.effects.effect.size = function( o, done ) {
if ( scale === "box" || scale === "both" ) {
// Vertical props scaling
- if ( factor.from.y !== factor.to.y ) {
+ if ( factor.from.y !== factor.to.y ) {
props = props.concat( vProps );
el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from );
el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to );
}
// Horizontal props scaling
- if ( factor.from.x !== factor.to.x ) {
+ if ( factor.from.x !== factor.to.x ) {
props = props.concat( hProps );
el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from );
el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to );
@@ -165,20 +165,20 @@ $.effects.effect.size = function( o, done ) {
}
// Scale the content
- if ( scale === "content" || scale === "both" ) {
+ if ( scale === "content" || scale === "both" ) {
// Vertical props scaling
- if ( factor.from.y !== factor.to.y ) {
+ if ( factor.from.y !== factor.to.y ) {
props = props.concat( cProps );
el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );
}
}
- $.effects.save( el, restore ? props : props1 );
- el.show();
+ $.effects.save( el, restore ? props : props1 );
+ el.show();
$.effects.createWrapper( el );
- el.css( "overflow", "hidden" ).css( el.from );
+ el.css( "overflow", "hidden" ).css( el.from );
// Adjust
if (origin) { // Calculate baseline shifts
@@ -200,8 +200,8 @@ $.effects.effect.size = function( o, done ) {
el.find( "*[width]" ).each( function(){
var child = $( this ),
- c_original = {
- height: child.height(),
+ c_original = {
+ height: child.height(),
width: child.width()
};
if (restore) {
@@ -209,16 +209,16 @@ $.effects.effect.size = function( o, done ) {
}
child.from = {
- height: c_original.height * factor.from.y,
+ height: c_original.height * factor.from.y,
width: c_original.width * factor.from.x
};
child.to = {
- height: c_original.height * factor.to.y,
+ height: c_original.height * factor.to.y,
width: c_original.width * factor.to.x
};
// Vertical props scaling
- if ( factor.from.y !== factor.to.y ) {
+ if ( factor.from.y !== factor.to.y ) {
child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from );
child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to );
}
@@ -242,10 +242,10 @@ $.effects.effect.size = function( o, done ) {
}
// Animate
- el.animate( el.to, {
- queue: false,
- duration: o.duration,
- easing: o.easing,
+ el.animate( el.to, {
+ queue: false,
+ duration: o.duration,
+ easing: o.easing,
complete: function() {
if ( el.to.opacity === 0 ) {
el.css( "opacity", el.from.opacity );
@@ -267,17 +267,14 @@ $.effects.effect.size = function( o, done ) {
$.each([ "top", "left" ], function( idx, pos ) {
el.css( pos, function( _, str ) {
var val = parseInt( str, 10 ),
- toRef = idx ? el.to.left : el.to.top,
- delta = idx ? el.to.outerWidth - el.from.outerWidth: el.to.outerHeight - el.from.outerHeight,
- same = origin[ idx ] === pos,
- mid = origin[ idx ] === "middle" || origin[ idx ] === "center";
+ toRef = idx ? el.to.left : el.to.top;
// if original was "auto", recalculate the new value from wrapper
if ( str === "auto" ) {
return toRef + "px";
}
- return val + toRef + "px";
+ return val + toRef + "px";
});
});
}
diff --git a/ui/jquery.effects.slide.js b/ui/jquery.effects.slide.js
index 77d540a9c..ae25a187e 100644
--- a/ui/jquery.effects.slide.js
+++ b/ui/jquery.effects.slide.js
@@ -23,38 +23,37 @@ $.effects.effect.slide = function( o, done ) {
ref = (direction === "up" || direction === "down") ? "top" : "left",
positiveMotion = (direction === "up" || direction === "left"),
distance,
- animation = {},
- size;
+ animation = {};
// Adjust
$.effects.save( el, props );
el.show();
- distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]({
+ distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]({
margin: true
});
-
+
$.effects.createWrapper( el ).css({
overflow: "hidden"
});
-
+
if ( show ) {
el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
}
// Animation
- animation[ ref ] = ( show ?
- ( positiveMotion ? "+=" : "-=") :
+ animation[ ref ] = ( show ?
+ ( positiveMotion ? "+=" : "-=") :
( positiveMotion ? "-=" : "+=")) +
distance;
// Animate
- el.animate( animation, {
- queue: false,
- duration: o.duration,
- easing: o.easing,
+ el.animate( animation, {
+ queue: false,
+ duration: o.duration,
+ easing: o.easing,
complete: function() {
if ( mode === "hide" ) {
- el.hide();
+ el.hide();
}
$.effects.restore( el, props );
$.effects.removeWrapper( el );
diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js
index 00ecd1b64..fe1771bc8 100644
--- a/ui/jquery.ui.accordion.js
+++ b/ui/jquery.ui.accordion.js
@@ -12,10 +12,11 @@
* jquery.ui.widget.js
*/
(function( $, undefined ) {
- var uid = 0,
- hideProps = {},
- showProps = {},
- showPropsAdjust = {};
+
+var uid = 0,
+ hideProps = {},
+ showProps = {},
+ showPropsAdjust = {};
hideProps.height = hideProps.paddingTop = hideProps.paddingBottom =
hideProps.borderTopWidth = hideProps.borderBottomWidth = "hide";
@@ -166,8 +167,7 @@ $.widget( "ui.accordion", {
},
_destroy: function() {
- var contents,
- accordionId = this.accordionId;
+ var contents;
// clean up main element
this.element
@@ -410,9 +410,8 @@ $.widget( "ui.accordion", {
this._toggle( eventData );
// switch classes
- active
- .removeClass( "ui-accordion-header-active ui-state-active ui-corner-top" )
- .addClass( "ui-corner-all" );
+ // corner classes on the previously active header stay after the animation
+ active.removeClass( "ui-accordion-header-active ui-state-active" );
if ( options.icons ) {
active.children( ".ui-accordion-header-icon" )
.removeClass( options.icons.activeHeader )
@@ -496,10 +495,10 @@ $.widget( "ui.accordion", {
easing = easing || options.easing || animate.easing;
duration = duration || options.duration || animate.duration;
- if ( !toHide.size() ) {
+ if ( !toHide.length ) {
return toShow.animate( showProps, duration, easing, complete );
}
- if ( !toShow.size() ) {
+ if ( !toShow.length ) {
return toHide.animate( hideProps, duration, easing, complete );
}
@@ -516,11 +515,14 @@ $.widget( "ui.accordion", {
},
_toggleComplete: function( data ) {
- var toShow = data.newContent,
- toHide = data.oldContent;
+ var toHide = data.oldContent;
+
+ toHide
+ .removeClass( "ui-accordion-content-active" )
+ .prev()
+ .removeClass( "ui-corner-top" )
+ .addClass( "ui-corner-all" );
- // other classes are removed before the animation; this one needs to stay until completed
- toHide.removeClass( "ui-accordion-content-active" );
// Work around for rendering bug in IE (#5421)
if ( toHide.length ) {
toHide.parent()[0].className = toHide.parent()[0].className;
diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js
index 5ec5790ed..fab9691a3 100644
--- a/ui/jquery.ui.autocomplete.js
+++ b/ui/jquery.ui.autocomplete.js
@@ -1,4 +1,4 @@
-/*
+/*!
* jQuery UI Autocomplete @VERSION
*
* Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
@@ -46,17 +46,14 @@ $.widget( "ui.autocomplete", {
pending: 0,
_create: function() {
- var self = this,
- // Some browsers only repeat keydown events, not keypress events,
- // so we use the suppressKeyPress flag to determine if we've already
- // handled the keydown event. #7269
- // Unfortunately the code for & in keypress is the same as the up arrow,
- // so we use the suppressKeyPressRepeat flag to avoid handling keypress
- // events when we know the keydown event was used to modify the
- // search term. #7799
- suppressKeyPress,
- suppressKeyPressRepeat,
- suppressInput;
+ // Some browsers only repeat keydown events, not keypress events,
+ // so we use the suppressKeyPress flag to determine if we've already
+ // handled the keydown event. #7269
+ // Unfortunately the code for & in keypress is the same as the up arrow,
+ // so we use the suppressKeyPressRepeat flag to avoid handling keypress
+ // events when we know the keydown event was used to modify the
+ // search term. #7799
+ var suppressKeyPress, suppressKeyPressRepeat, suppressInput;
this.isMultiLine = this.element.is( "textarea,[contenteditable]" );
this.valueMethod = this.element[ this.element.is( "input,textarea" ) ? "val" : "text" ];
@@ -69,9 +66,11 @@ $.widget( "ui.autocomplete", {
role: "textbox",
"aria-autocomplete": "list",
"aria-haspopup": "true"
- })
- .bind( "keydown.autocomplete", function( event ) {
- if ( self.options.disabled || self.element.prop( "readOnly" ) ) {
+ });
+
+ this._bind({
+ keydown: function( event ) {
+ if ( this.element.prop( "readOnly" ) ) {
suppressKeyPress = true;
suppressInput = true;
suppressKeyPressRepeat = true;
@@ -85,50 +84,54 @@ $.widget( "ui.autocomplete", {
switch( event.keyCode ) {
case keyCode.PAGE_UP:
suppressKeyPress = true;
- self._move( "previousPage", event );
+ this._move( "previousPage", event );
break;
case keyCode.PAGE_DOWN:
suppressKeyPress = true;
- self._move( "nextPage", event );
+ this._move( "nextPage", event );
break;
case keyCode.UP:
suppressKeyPress = true;
- self._keyEvent( "previous", event );
+ this._keyEvent( "previous", event );
break;
case keyCode.DOWN:
suppressKeyPress = true;
- self._keyEvent( "next", event );
+ this._keyEvent( "next", event );
break;
case keyCode.ENTER:
case keyCode.NUMPAD_ENTER:
// when menu is open and has focus
- if ( self.menu.active ) {
+ if ( this.menu.active ) {
// #6055 - Opera still allows the keypress to occur
// which causes forms to submit
suppressKeyPress = true;
event.preventDefault();
+ this.menu.select( event );
}
- //passthrough - ENTER and TAB both select the current element
+ break;
case keyCode.TAB:
- if ( !self.menu.active ) {
- return;
+ if ( this.menu.active ) {
+ this.menu.select( event );
}
- self.menu.select( event );
break;
case keyCode.ESCAPE:
- if ( self.menu.element.is(":visible") ) {
- self._value( self.term );
- self.close( event );
+ if ( this.menu.element.is(":visible") ) {
+ this._value( this.term );
+ this.close( event );
+ // Different browsers have different default behavior for escape
+ // Single press can mean undo or clear
+ // Double press in IE means clear the whole form
+ event.preventDefault();
}
break;
default:
suppressKeyPressRepeat = true;
// search timeout should be triggered before the input value is changed
- self._searchTimeout( event );
+ this._searchTimeout( event );
break;
}
- })
- .bind( "keypress.autocomplete", function( event ) {
+ },
+ keypress: function( event ) {
if ( suppressKeyPress ) {
suppressKeyPress = false;
event.preventDefault();
@@ -142,132 +145,125 @@ $.widget( "ui.autocomplete", {
var keyCode = $.ui.keyCode;
switch( event.keyCode ) {
case keyCode.PAGE_UP:
- self._move( "previousPage", event );
+ this._move( "previousPage", event );
break;
case keyCode.PAGE_DOWN:
- self._move( "nextPage", event );
+ this._move( "nextPage", event );
break;
case keyCode.UP:
- self._keyEvent( "previous", event );
+ this._keyEvent( "previous", event );
break;
case keyCode.DOWN:
- self._keyEvent( "next", event );
+ this._keyEvent( "next", event );
break;
}
- })
- .bind( "input.autocomplete", function(event) {
+ },
+ input: function( event ) {
if ( suppressInput ) {
suppressInput = false;
event.preventDefault();
return;
}
- self._searchTimeout( event );
- })
- .bind( "focus.autocomplete", function() {
- if ( self.options.disabled ) {
- return;
- }
-
- self.selectedItem = null;
- self.previous = self._value();
- })
- .bind( "blur.autocomplete", function( event ) {
- if ( self.options.disabled ) {
+ this._searchTimeout( event );
+ },
+ focus: function() {
+ this.selectedItem = null;
+ this.previous = this._value();
+ },
+ blur: function( event ) {
+ if ( this.cancelBlur ) {
+ delete this.cancelBlur;
return;
}
- if ( self.cancelBlur ) {
- delete self.cancelBlur;
- return;
- }
+ clearTimeout( this.searching );
+ this.close( event );
+ this._change( event );
+ }
+ });
- clearTimeout( self.searching );
- self.close( event );
- self._change( event );
- });
this._initSource();
- this.response = function() {
- return self._response.apply( self, arguments );
- };
this.menu = $( "<ul></ul>" )
.addClass( "ui-autocomplete" )
.appendTo( this.document.find( this.options.appendTo || "body" )[0] )
- // prevent the close-on-blur in case of a "slow" click on the menu (long mousedown)
- .mousedown(function( event ) {
+ .menu({
+ // custom key handling for now
+ input: $()
+ })
+ .zIndex( this.element.zIndex() + 1 )
+ .hide()
+ .data( "menu" );
+ this._bind( this.menu.element, {
+ mousedown: function( event ) {
// prevent moving focus out of the text field
event.preventDefault();
// IE doesn't prevent moving focus even with event.preventDefault()
// so we set a flag to know when we should ignore the blur event
- self.cancelBlur = true;
- setTimeout(function() {
- delete self.cancelBlur;
- }, 1 );
+ this.cancelBlur = true;
+ this._delay(function() {
+ delete this.cancelBlur;
+ });
// clicking on the scrollbar causes focus to shift to the body
// but we can't detect a mouseup or a click immediately afterward
// so we have to track the next mousedown and close the menu if
// the user clicks somewhere outside of the autocomplete
- var menuElement = self.menu.element[ 0 ];
+ var menuElement = this.menu.element[ 0 ];
if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
- setTimeout(function() {
- self.document.one( 'mousedown', function( event ) {
- if ( event.target !== self.element[ 0 ] &&
- event.target !== menuElement &&
- !$.contains( menuElement, event.target ) ) {
- self.close();
+ this._delay(function() {
+ var that = this;
+ this.document.one( 'mousedown', function( event ) {
+ if ( event.target !== that.element[ 0 ] &&
+ event.target !== menuElement &&
+ !$.contains( menuElement, event.target ) ) {
+ that.close();
}
});
- }, 1 );
+ });
}
- })
- .menu({
- // custom key handling for now
- input: $(),
- focus: function( event, ui ) {
- // back compat for _renderItem using item.autocomplete, via #7810
- // TODO remove the fallback, see #8156
- var item = ui.item.data( "ui-autocomplete-item" ) || ui.item.data( "item.autocomplete" );
- if ( false !== self._trigger( "focus", event, { item: item } ) ) {
- // use value to match what will end up in the input, if it was a key event
- if ( /^key/.test(event.originalEvent.type) ) {
- self._value( item.value );
- }
- }
- },
- select: function( event, ui ) {
- // back compat for _renderItem using item.autocomplete, via #7810
- // TODO remove the fallback, see #8156
- var item = ui.item.data( "ui-autocomplete-item" ) || ui.item.data( "item.autocomplete" ),
- previous = self.previous;
-
- // only trigger when focus was lost (click on menu)
- if ( self.element[0] !== self.document[0].activeElement ) {
- self.element.focus();
- self.previous = previous;
- // #6109 - IE triggers two focus events and the second
- // is asynchronous, so we need to reset the previous
- // term synchronously and asynchronously :-(
- setTimeout(function() {
- self.previous = previous;
- self.selectedItem = item;
- }, 1);
+ },
+ menufocus: function( event, ui ) {
+ // back compat for _renderItem using item.autocomplete, via #7810
+ // TODO remove the fallback, see #8156
+ var item = ui.item.data( "ui-autocomplete-item" ) || ui.item.data( "item.autocomplete" );
+ if ( false !== this._trigger( "focus", event, { item: item } ) ) {
+ // use value to match what will end up in the input, if it was a key event
+ if ( /^key/.test(event.originalEvent.type) ) {
+ this._value( item.value );
}
+ }
+ },
+ menuselect: function( event, ui ) {
+ // back compat for _renderItem using item.autocomplete, via #7810
+ // TODO remove the fallback, see #8156
+ var item = ui.item.data( "ui-autocomplete-item" ) || ui.item.data( "item.autocomplete" ),
+ previous = this.previous;
+
+ // only trigger when focus was lost (click on menu)
+ if ( this.element[0] !== this.document[0].activeElement ) {
+ this.element.focus();
+ this.previous = previous;
+ // #6109 - IE triggers two focus events and the second
+ // is asynchronous, so we need to reset the previous
+ // term synchronously and asynchronously :-(
+ this._delay(function() {
+ this.previous = previous;
+ this.selectedItem = item;
+ });
+ }
- if ( false !== self._trigger( "select", event, { item: item } ) ) {
- self._value( item.value );
- }
- // reset the term after the select event
- // this allows custom select handling to work properly
- self.term = self._value();
-
- self.close( event );
- self.selectedItem = item;
+ if ( false !== this._trigger( "select", event, { item: item } ) ) {
+ this._value( item.value );
}
- })
- .zIndex( this.element.zIndex() + 1 )
- .hide()
- .data( "menu" );
+ // reset the term after the select event
+ // this allows custom select handling to work properly
+ this.term = this._value();
+
+ this.close( event );
+ this.selectedItem = item;
+ }
+ });
if ( $.fn.bgiframe ) {
this.menu.element.bgiframe();
@@ -308,7 +304,7 @@ $.widget( "ui.autocomplete", {
},
_initSource: function() {
- var self = this,
+ var that = this,
array,
url;
if ( $.isArray(this.options.source) ) {
@@ -319,25 +315,18 @@ $.widget( "ui.autocomplete", {
} else if ( typeof this.options.source === "string" ) {
url = this.options.source;
this.source = function( request, response ) {
- if ( self.xhr ) {
- self.xhr.abort();
+ if ( that.xhr ) {
+ that.xhr.abort();
}
- self.xhr = $.ajax({
+ that.xhr = $.ajax({
url: url,
data: request,
dataType: "json",
- context: {
- autocompleteRequest: ++requestIndex
- },
success: function( data, status ) {
- if ( this.autocompleteRequest === requestIndex ) {
- response( data );
- }
+ response( data );
},
error: function() {
- if ( this.autocompleteRequest === requestIndex ) {
- response( [] );
- }
+ response( [] );
}
});
};
@@ -347,15 +336,14 @@ $.widget( "ui.autocomplete", {
},
_searchTimeout: function( event ) {
- var self = this;
- clearTimeout( self.searching );
- self.searching = setTimeout(function() {
+ clearTimeout( this.searching );
+ this.searching = this._delay(function() {
// only search if the value has changed
- if ( self.term !== self._value() ) {
- self.selectedItem = null;
- self.search( null, event );
+ if ( this.term !== this._value() ) {
+ this.selectedItem = null;
+ this.search( null, event );
}
- }, self.options.delay );
+ }, this.options.delay );
},
search: function( value, event ) {
@@ -380,10 +368,26 @@ $.widget( "ui.autocomplete", {
this.element.addClass( "ui-autocomplete-loading" );
this.cancelSearch = false;
- this.source( { term: value }, this.response );
+ this.source( { term: value }, this._response() );
+ },
+
+ _response: function() {
+ var that = this,
+ index = ++requestIndex;
+
+ return function( content ) {
+ if ( index === requestIndex ) {
+ that.__response( content );
+ }
+
+ that.pending--;
+ if ( !that.pending ) {
+ that.element.removeClass( "ui-autocomplete-loading" );
+ }
+ };
},
- _response: function( content ) {
+ __response: function( content ) {
if ( content ) {
content = this._normalize( content );
}
@@ -395,10 +399,6 @@ $.widget( "ui.autocomplete", {
// use ._close() instead of .close() so we don't cancel future searches
this._close();
}
- this.pending--;
- if ( !this.pending ) {
- this.element.removeClass( "ui-autocomplete-loading" );
- }
},
close: function( event ) {
@@ -472,9 +472,9 @@ $.widget( "ui.autocomplete", {
},
_renderMenu: function( ul, items ) {
- var self = this;
+ var that = this;
$.each( items, function( index, item ) {
- self._renderItemData( ul, item );
+ that._renderItemData( ul, item );
});
},
@@ -522,7 +522,7 @@ $.widget( "ui.autocomplete", {
$.extend( $.ui.autocomplete, {
escapeRegex: function( value ) {
- return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
+ return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
},
filter: function(array, term) {
var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js
index c0de503f5..a92c9fafa 100644
--- a/ui/jquery.ui.datepicker.js
+++ b/ui/jquery.ui.datepicker.js
@@ -801,10 +801,8 @@ $.extend(Datepicker.prototype, {
if (this._datepickerShowing) {
var showAnim = this._get(inst, 'showAnim');
var duration = this._get(inst, 'duration');
- var that = this;
var postProcess = function() {
$.datepicker._tidyDialog(inst);
- that._curInst = null;
};
// DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js
index 3a9bd5dc6..f60a1f78d 100644
--- a/ui/jquery.ui.dialog.js
+++ b/ui/jquery.ui.dialog.js
@@ -77,19 +77,19 @@ $.widget("ui.dialog", {
// #5742 - .attr() might return a DOMElement
if ( typeof this.originalTitle !== "string" ) {
this.originalTitle = "";
- }
- this.oldPosition = {
- parent: this.element.parent(),
- index: this.element.parent().children().index( this.element )
+ }
+ this.oldPosition = {
+ parent: this.element.parent(),
+ index: this.element.parent().children().index( this.element )
};
this.options.title = this.options.title || this.originalTitle;
- var self = this,
- options = self.options,
+ var that = this,
+ options = this.options,
title = options.title || "&#160;",
- titleId = $.ui.dialog.getTitleId( self.element ),
+ titleId = $.ui.dialog.getTitleId( this.element ),
- uiDialog = ( self.uiDialog = $( "<div>" ) )
+ uiDialog = ( this.uiDialog = $( "<div>" ) )
.addClass( uiDialogClasses + options.dialogClass )
.css({
display: "none",
@@ -101,7 +101,7 @@ $.widget("ui.dialog", {
.keydown(function( event ) {
if ( options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
event.keyCode === $.ui.keyCode.ESCAPE ) {
- self.close( event );
+ that.close( event );
event.preventDefault();
}
})
@@ -110,17 +110,17 @@ $.widget("ui.dialog", {
"aria-labelledby": titleId
})
.mousedown(function( event ) {
- self.moveToTop( false, event );
+ that.moveToTop( false, event );
})
.appendTo( "body" ),
- uiDialogContent = self.element
+ uiDialogContent = this.element
.show()
.removeAttr( "title" )
.addClass( "ui-dialog-content ui-widget-content" )
.appendTo( uiDialog ),
- uiDialogTitlebar = ( self.uiDialogTitlebar = $( "<div>" ) )
+ uiDialogTitlebar = ( this.uiDialogTitlebar = $( "<div>" ) )
.addClass( "ui-dialog-titlebar ui-widget-header " +
"ui-corner-all ui-helper-clearfix" )
.prependTo( uiDialog ),
@@ -130,11 +130,11 @@ $.widget("ui.dialog", {
.attr( "role", "button" )
.click(function( event ) {
event.preventDefault();
- self.close( event );
+ that.close( event );
})
.appendTo( uiDialogTitlebar ),
- uiDialogTitlebarCloseText = ( self.uiDialogTitlebarCloseText = $( "<span>" ) )
+ uiDialogTitlebarCloseText = ( this.uiDialogTitlebarCloseText = $( "<span>" ) )
.addClass( "ui-icon ui-icon-closethick" )
.text( options.closeText )
.appendTo( uiDialogTitlebarClose ),
@@ -150,14 +150,14 @@ $.widget("ui.dialog", {
this._focusable( uiDialogTitlebarClose );
if ( options.draggable && $.fn.draggable ) {
- self._makeDraggable();
+ this._makeDraggable();
}
if ( options.resizable && $.fn.resizable ) {
- self._makeResizable();
+ this._makeResizable();
}
- self._createButtons( options.buttons );
- self._isOpen = false;
+ this._createButtons( options.buttons );
+ this._isOpen = false;
if ( $.fn.bgiframe ) {
uiDialog.bgiframe();
@@ -171,29 +171,29 @@ $.widget("ui.dialog", {
},
_destroy: function() {
- var self = this, next,
+ var next,
oldPosition = this.oldPosition;
- if ( self.overlay ) {
- self.overlay.destroy();
+ if ( this.overlay ) {
+ this.overlay.destroy();
}
- self.uiDialog.hide();
- self.element
+ this.uiDialog.hide();
+ this.element
.removeClass( "ui-dialog-content ui-widget-content" )
.hide()
.appendTo( "body" );
- self.uiDialog.remove();
+ this.uiDialog.remove();
- if ( self.originalTitle ) {
- self.element.attr( "title", self.originalTitle );
+ if ( this.originalTitle ) {
+ this.element.attr( "title", this.originalTitle );
}
-
+
next = oldPosition.parent.children().eq( oldPosition.index );
if ( next.length ) {
- next.before( self.element );
+ next.before( this.element );
} else {
- oldPosition.parent.append( self.element );
- }
+ oldPosition.parent.append( this.element );
+ }
},
widget: function() {
@@ -201,40 +201,40 @@ $.widget("ui.dialog", {
},
close: function( event ) {
- var self = this,
+ var that = this,
maxZ, thisZ;
if ( !this._isOpen ) {
return;
}
- if ( false === self._trigger( "beforeClose", event ) ) {
+ if ( false === this._trigger( "beforeClose", event ) ) {
return;
}
- self._isOpen = false;
+ this._isOpen = false;
- if ( self.overlay ) {
- self.overlay.destroy();
+ if ( this.overlay ) {
+ this.overlay.destroy();
}
- self.uiDialog.unbind( "keypress.ui-dialog" );
+ this.uiDialog.unbind( "keypress.ui-dialog" );
- if ( self.options.hide ) {
- self.uiDialog.hide( self.options.hide, function() {
- self._trigger( "close", event );
+ if ( this.options.hide ) {
+ this.uiDialog.hide( this.options.hide, function() {
+ that._trigger( "close", event );
});
} else {
- self.uiDialog.hide();
- self._trigger( "close", event );
+ this.uiDialog.hide();
+ this._trigger( "close", event );
}
$.ui.dialog.overlay.resize();
// adjust the maxZ to allow other modal dialogs to continue to work (see #4309)
- if ( self.options.modal ) {
+ if ( this.options.modal ) {
maxZ = 0;
$( ".ui-dialog" ).each(function() {
- if ( this !== self.uiDialog[0] ) {
+ if ( this !== that.uiDialog[0] ) {
thisZ = $( this ).css( "z-index" );
if ( !isNaN( thisZ ) ) {
maxZ = Math.max( maxZ, thisZ );
@@ -244,7 +244,7 @@ $.widget("ui.dialog", {
$.ui.dialog.maxZ = maxZ;
}
- return self;
+ return this;
},
isOpen: function() {
@@ -254,37 +254,36 @@ $.widget("ui.dialog", {
// the force parameter allows us to move modal dialogs to their correct
// position on open
moveToTop: function( force, event ) {
- var self = this,
- options = self.options,
+ var options = this.options,
saveScroll;
if ( ( options.modal && !force ) ||
( !options.stack && !options.modal ) ) {
- return self._trigger( "focus", event );
+ return this._trigger( "focus", event );
}
if ( options.zIndex > $.ui.dialog.maxZ ) {
$.ui.dialog.maxZ = options.zIndex;
}
- if ( self.overlay ) {
+ if ( this.overlay ) {
$.ui.dialog.maxZ += 1;
$.ui.dialog.overlay.maxZ = $.ui.dialog.maxZ;
- self.overlay.$el.css( "z-index", $.ui.dialog.overlay.maxZ );
+ this.overlay.$el.css( "z-index", $.ui.dialog.overlay.maxZ );
}
// Save and then restore scroll
// Opera 9.5+ resets when parent z-index is changed.
// http://bugs.jqueryui.com/ticket/3193
saveScroll = {
- scrollTop: self.element.scrollTop(),
- scrollLeft: self.element.scrollLeft()
+ scrollTop: this.element.scrollTop(),
+ scrollLeft: this.element.scrollLeft()
};
$.ui.dialog.maxZ += 1;
- self.uiDialog.css( "z-index", $.ui.dialog.maxZ );
- self.element.attr( saveScroll );
- self._trigger( "focus", event );
+ this.uiDialog.css( "z-index", $.ui.dialog.maxZ );
+ this.element.attr( saveScroll );
+ this._trigger( "focus", event );
- return self;
+ return this;
},
open: function() {
@@ -293,15 +292,14 @@ $.widget("ui.dialog", {
}
var hasFocus,
- self = this,
- options = self.options,
- uiDialog = self.uiDialog;
+ options = this.options,
+ uiDialog = this.uiDialog;
- self._size();
- self._position( options.position );
+ this._size();
+ this._position( options.position );
uiDialog.show( options.show );
- self.overlay = options.modal ? new $.ui.dialog.overlay( self ) : null;
- self.moveToTop( true );
+ this.overlay = options.modal ? new $.ui.dialog.overlay( this ) : null;
+ this.moveToTop( true );
// prevent tabbing out of modal dialogs
if ( options.modal ) {
@@ -326,7 +324,7 @@ $.widget("ui.dialog", {
// set focus to the first tabbable element in the content area or the first button
// if there are no tabbable elements, set focus on the dialog itself
- hasFocus = self.element.find( ":tabbable" );
+ hasFocus = this.element.find( ":tabbable" );
if ( !hasFocus.length ) {
hasFocus = uiDialog.find( ".ui-dialog-buttonpane :tabbable" );
if ( !hasFocus.length ) {
@@ -335,19 +333,19 @@ $.widget("ui.dialog", {
}
hasFocus.eq( 0 ).focus();
- self._isOpen = true;
- self._trigger( "open" );
+ this._isOpen = true;
+ this._trigger( "open" );
- return self;
+ return this;
},
_createButtons: function( buttons ) {
var uiDialogButtonPane, uiButtonSet,
- self = this,
+ that = this,
hasButtons = false;
// if we already have a button pane, remove it
- self.uiDialog.find( ".ui-dialog-buttonpane" ).remove();
+ this.uiDialog.find( ".ui-dialog-buttonpane" ).remove();
if ( typeof buttons === "object" && buttons !== null ) {
$.each( buttons, function() {
@@ -369,23 +367,23 @@ $.widget("ui.dialog", {
.attr( props, true )
.unbind( "click" )
.click(function() {
- props.click.apply( self.element[0], arguments );
+ props.click.apply( that.element[0], arguments );
})
.appendTo( uiButtonSet );
if ( $.fn.button ) {
button.button();
}
});
- self.uiDialog.addClass( "ui-dialog-buttons" );
- uiDialogButtonPane.appendTo( self.uiDialog );
+ this.uiDialog.addClass( "ui-dialog-buttons" );
+ uiDialogButtonPane.appendTo( this.uiDialog );
} else {
- self.uiDialog.removeClass( "ui-dialog-buttons" );
+ this.uiDialog.removeClass( "ui-dialog-buttons" );
}
},
_makeDraggable: function() {
- var self = this,
- options = self.options;
+ var that = this,
+ options = this.options;
function filteredUi( ui ) {
return {
@@ -394,26 +392,26 @@ $.widget("ui.dialog", {
};
}
- self.uiDialog.draggable({
+ this.uiDialog.draggable({
cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
handle: ".ui-dialog-titlebar",
containment: "document",
start: function( event, ui ) {
$( this )
.addClass( "ui-dialog-dragging" );
- self._trigger( "dragStart", event, filteredUi( ui ) );
+ that._trigger( "dragStart", event, filteredUi( ui ) );
},
drag: function( event, ui ) {
- self._trigger( "drag", event, filteredUi( ui ) );
+ that._trigger( "drag", event, filteredUi( ui ) );
},
stop: function( event, ui ) {
options.position = [
- ui.position.left - self.document.scrollLeft(),
- ui.position.top - self.document.scrollTop()
+ ui.position.left - that.document.scrollLeft(),
+ ui.position.top - that.document.scrollTop()
];
$( this )
.removeClass( "ui-dialog-dragging" );
- self._trigger( "dragStop", event, filteredUi( ui ) );
+ that._trigger( "dragStop", event, filteredUi( ui ) );
$.ui.dialog.overlay.resize();
}
});
@@ -421,11 +419,11 @@ $.widget("ui.dialog", {
_makeResizable: function( handles ) {
handles = (handles === undefined ? this.options.resizable : handles);
- var self = this,
- options = self.options,
+ var that = this,
+ options = this.options,
// .ui-resizable has position: relative defined in the stylesheet
// but dialogs have to use absolute or fixed positioning
- position = self.uiDialog.css( "position" ),
+ position = this.uiDialog.css( "position" ),
resizeHandles = typeof handles === 'string' ?
handles :
"n,e,s,w,se,sw,ne,nw";
@@ -439,27 +437,27 @@ $.widget("ui.dialog", {
};
}
- self.uiDialog.resizable({
+ this.uiDialog.resizable({
cancel: ".ui-dialog-content",
containment: "document",
- alsoResize: self.element,
+ alsoResize: this.element,
maxWidth: options.maxWidth,
maxHeight: options.maxHeight,
minWidth: options.minWidth,
- minHeight: self._minHeight(),
+ minHeight: this._minHeight(),
handles: resizeHandles,
start: function( event, ui ) {
$( this ).addClass( "ui-dialog-resizing" );
- self._trigger( "resizeStart", event, filteredUi( ui ) );
+ that._trigger( "resizeStart", event, filteredUi( ui ) );
},
resize: function( event, ui ) {
- self._trigger( "resize", event, filteredUi( ui ) );
+ that._trigger( "resize", event, filteredUi( ui ) );
},
stop: function( event, ui ) {
$( this ).removeClass( "ui-dialog-resizing" );
options.height = $( this ).height();
options.width = $( this ).width();
- self._trigger( "resizeStop", event, filteredUi( ui ) );
+ that._trigger( "resizeStop", event, filteredUi( ui ) );
$.ui.dialog.overlay.resize();
}
})
@@ -525,12 +523,12 @@ $.widget("ui.dialog", {
},
_setOptions: function( options ) {
- var self = this,
+ var that = this,
resizableOptions = {},
resize = false;
$.each( options, function( key, value ) {
- self._setOption( key, value );
+ that._setOption( key, value );
if ( key in sizeRelatedOptions ) {
resize = true;
@@ -550,20 +548,19 @@ $.widget("ui.dialog", {
_setOption: function( key, value ) {
var isDraggable, isResizable,
- self = this,
- uiDialog = self.uiDialog;
+ uiDialog = this.uiDialog;
switch ( key ) {
case "buttons":
- self._createButtons( value );
+ this._createButtons( value );
break;
case "closeText":
// ensure that we always pass a string
- self.uiDialogTitlebarCloseText.text( "" + value );
+ this.uiDialogTitlebarCloseText.text( "" + value );
break;
case "dialogClass":
uiDialog
- .removeClass( self.options.dialogClass )
+ .removeClass( this.options.dialogClass )
.addClass( uiDialogClasses + value );
break;
case "disabled":
@@ -580,11 +577,11 @@ $.widget("ui.dialog", {
}
if ( !isDraggable && value ) {
- self._makeDraggable();
+ this._makeDraggable();
}
break;
case "position":
- self._position( value );
+ this._position( value );
break;
case "resizable":
// currently resizable, becoming non-resizable
@@ -600,12 +597,12 @@ $.widget("ui.dialog", {
// currently non-resizable, becoming resizable
if ( !isResizable && value !== false ) {
- self._makeResizable( value );
+ this._makeResizable( value );
}
break;
case "title":
// convert whatever was passed in o a string, for html() to not throw up
- $( ".ui-dialog-title", self.uiDialogTitlebar )
+ $( ".ui-dialog-title", this.uiDialogTitlebar )
.html( "" + ( value || "&#160;" ) );
break;
}
@@ -713,21 +710,25 @@ $.extend( $.ui.dialog.overlay, {
}
}, 1 );
- // allow closing by pressing the escape key
- $( document ).bind( "keydown.dialog-overlay", function( event ) {
- if ( dialog.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
- event.keyCode === $.ui.keyCode.ESCAPE ) {
-
- dialog.close( event );
- event.preventDefault();
- }
- });
-
// handle window resize
$( window ).bind( "resize.dialog-overlay", $.ui.dialog.overlay.resize );
}
var $el = ( this.oldInstances.pop() || $( "<div>" ).addClass( "ui-widget-overlay" ) );
+
+ // allow closing by pressing the escape key
+ $( document ).bind( "keydown.dialog-overlay", function( event ) {
+ var instances = $.ui.dialog.overlay.instances;
+ // only react to the event if we're the top overlay
+ if ( instances.length !== 0 && instances[ instances.length - 1 ] === $el &&
+ dialog.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
+ event.keyCode === $.ui.keyCode.ESCAPE ) {
+
+ dialog.close( event );
+ event.preventDefault();
+ }
+ });
+
$el.appendTo( document.body ).css({
width: this.width(),
height: this.height()
diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js
index 25b256710..84077ed29 100644
--- a/ui/jquery.ui.draggable.js
+++ b/ui/jquery.ui.draggable.js
@@ -207,8 +207,14 @@ $.widget("ui.draggable", $.ui.mouse, {
this.dropped = false;
}
- //if the original element is removed, don't bother to continue
- if((!this.element[0] || !this.element[0].parentNode) && this.options.helper === "original")
+ //if the original element is no longer in the DOM don't bother to continue (see #8269)
+ var element = this.element[0], elementInDom = false;
+ while ( element && (element = element.parentNode) ) {
+ if (element == document ) {
+ elementInDom = true;
+ }
+ }
+ if ( !elementInDom && this.options.helper === "original" )
return false;
if((this.options.revert == "invalid" && !dropped) || (this.options.revert == "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) {
diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js
index af22c19b0..7704521fb 100644
--- a/ui/jquery.ui.menu.js
+++ b/ui/jquery.ui.menu.js
@@ -13,7 +13,8 @@
*/
(function($) {
-var idIncrement = 0;
+var idIncrement = 0,
+ currentEventTarget = null;
$.widget( "ui.menu", {
version: "@VERSION",
@@ -41,18 +42,23 @@ $.widget( "ui.menu", {
.addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
.attr({
id: this.menuId,
- role: "menu"
+ role: "menu",
+ tabIndex: 0
})
// need to catch all clicks on disabled menu
// not possible through _bind
- .bind( "click.menu", $.proxy( function( event ) {
+ .bind( "click.menu", $.proxy(function( event ) {
if ( this.options.disabled ) {
event.preventDefault();
}
- }, this));
+ }, this ));
+
if ( this.options.disabled ) {
- this.element.addClass( "ui-state-disabled" );
+ this.element
+ .addClass( "ui-state-disabled" )
+ .attr( "aria-disabled", "true" );
}
+
this._bind({
// Prevent focus from sticking to links inside menu after clicking
// them (focus should always stay on UL during navigation).
@@ -63,22 +69,28 @@ $.widget( "ui.menu", {
event.preventDefault();
},
"click .ui-menu-item:has(a)": function( event ) {
- event.stopImmediatePropagation();
- //Don't select disabled menu items
- if ( !$( event.target ).closest( ".ui-menu-item" ).is( ".ui-state-disabled" ) ) {
- this.select( event );
- // Redirect focus to the menu with a delay for firefox
- this._delay( function() {
- if ( !this.element.is(":focus") ) {
- this.element.focus();
- }
- }, 20);
+ var target = $( event.target );
+ if ( target[0] !== currentEventTarget ) {
+ currentEventTarget = target[0];
+ target.one( "click.menu", function( event ) {
+ currentEventTarget = null;
+ });
+ // Don't select disabled menu items
+ if ( !target.closest( ".ui-menu-item" ).is( ".ui-state-disabled" ) ) {
+ this.select( event );
+ // Redirect focus to the menu with a delay for firefox
+ this._delay(function() {
+ if ( !this.element.is(":focus") ) {
+ this.element.focus();
+ }
+ }, 20 );
+ }
}
},
- "mouseover .ui-menu-item": function( event ) {
- event.stopImmediatePropagation();
+ "mouseenter .ui-menu-item": function( event ) {
var target = $( event.currentTarget );
- // Remove ui-state-active class from siblings of the newly focused menu item to avoid a jump caused by adjacent elements both having a class with a border
+ // Remove ui-state-active class from siblings of the newly focused menu item
+ // to avoid a jump caused by adjacent elements both having a class with a border
target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
this.focus( event, target );
},
@@ -86,9 +98,9 @@ $.widget( "ui.menu", {
"mouseleave .ui-menu": "collapseAll",
"focus": function( event ) {
var menu = this.element,
- firstItem = menu.children( ".ui-menu-item" ).not( ".ui-state-disabled" ).eq( 0 );
+ firstItem = menu.children( ".ui-menu-item" ).eq( 0 );
if ( this._hasScroll() && !this.active ) {
- menu.children().each( function() {
+ menu.children().each(function() {
var currentItem = $( this );
if ( currentItem.offset().top - menu.offset().top >= 0 ) {
firstItem = currentItem;
@@ -101,125 +113,17 @@ $.widget( "ui.menu", {
this.focus( event, firstItem );
},
blur: function( event ) {
- this._delay( function() {
- if ( ! $.contains( this.element[0], this.document[0].activeElement ) ) {
+ this._delay(function() {
+ if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
this.collapseAll( event );
}
- }, 0);
- }
+ });
+ },
+ "keydown": "_keydown"
});
this.refresh();
- this.element.attr( "tabIndex", 0 );
- this._bind({
- "keydown": function( event ) {
- switch ( event.keyCode ) {
- case $.ui.keyCode.PAGE_UP:
- this.previousPage( event );
- event.preventDefault();
- event.stopImmediatePropagation();
- break;
- case $.ui.keyCode.PAGE_DOWN:
- this.nextPage( event );
- event.preventDefault();
- event.stopImmediatePropagation();
- break;
- case $.ui.keyCode.HOME:
- this._move( "first", "first", event );
- event.preventDefault();
- event.stopImmediatePropagation();
- break;
- case $.ui.keyCode.END:
- this._move( "last", "last", event );
- event.preventDefault();
- event.stopImmediatePropagation();
- break;
- case $.ui.keyCode.UP:
- this.previous( event );
- event.preventDefault();
- event.stopImmediatePropagation();
- break;
- case $.ui.keyCode.DOWN:
- this.next( event );
- event.preventDefault();
- event.stopImmediatePropagation();
- break;
- case $.ui.keyCode.LEFT:
- if (this.collapse( event )) {
- event.stopImmediatePropagation();
- }
- event.preventDefault();
- break;
- case $.ui.keyCode.RIGHT:
- if (this.expand( event )) {
- event.stopImmediatePropagation();
- }
- event.preventDefault();
- break;
- case $.ui.keyCode.ENTER:
- if ( this.active.children( "a[aria-haspopup='true']" ).length ) {
- if ( this.expand( event ) ) {
- event.stopImmediatePropagation();
- }
- }
- else {
- this.select( event );
- event.stopImmediatePropagation();
- }
- event.preventDefault();
- break;
- case $.ui.keyCode.ESCAPE:
- if ( this.collapse( event ) ) {
- event.stopImmediatePropagation();
- }
- event.preventDefault();
- break;
- default:
- event.stopPropagation();
- clearTimeout( this.filterTimer );
- var match,
- prev = this.previousFilter || "",
- character = String.fromCharCode( event.keyCode ),
- skip = false;
-
- if (character === prev) {
- skip = true;
- } else {
- character = prev + character;
- }
- function escape( value ) {
- return value.replace( /[-[\]{}()*+?.,\\^$|#\s]/g , "\\$&" );
- }
- match = this.activeMenu.children( ".ui-menu-item" ).filter( function() {
- return new RegExp("^" + escape(character), "i")
- .test( $( this ).children( "a" ).text() );
- });
- match = skip && match.index(this.active.next()) !== -1 ? this.active.nextAll(".ui-menu-item") : match;
- if ( !match.length ) {
- character = String.fromCharCode(event.keyCode);
- match = this.activeMenu.children(".ui-menu-item").filter( function() {
- return new RegExp("^" + escape(character), "i")
- .test( $( this ).children( "a" ).text() );
- });
- }
- if ( match.length ) {
- this.focus( event, match );
- if (match.length > 1) {
- this.previousFilter = character;
- this.filterTimer = this._delay( function() {
- delete this.previousFilter;
- }, 1000 );
- } else {
- delete this.previousFilter;
- }
- } else {
- delete this.previousFilter;
- }
- }
- }
- });
-
this._bind( this.document, {
click: function( event ) {
if ( !$( event.target ).closest( ".ui-menu" ).length ) {
@@ -230,38 +134,136 @@ $.widget( "ui.menu", {
},
_destroy: function() {
- //destroy (sub)menus
+ // destroy (sub)menus
this.element
.removeAttr( "aria-activedescendant" )
- .find( ".ui-menu" )
- .andSelf()
- .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
- .removeAttr( "role" )
- .removeAttr( "tabIndex" )
- .removeAttr( "aria-labelledby" )
- .removeAttr( "aria-expanded" )
- .removeAttr( "aria-hidden" )
- .show();
-
- //destroy menu items
+ .find( ".ui-menu" ).andSelf()
+ .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
+ .removeAttr( "role" )
+ .removeAttr( "tabIndex" )
+ .removeAttr( "aria-labelledby" )
+ .removeAttr( "aria-expanded" )
+ .removeAttr( "aria-hidden" )
+ .show();
+
+ // destroy menu items
this.element.find( ".ui-menu-item" )
.unbind( ".menu" )
.removeClass( "ui-menu-item" )
.removeAttr( "role" )
.children( "a" )
- .removeClass( "ui-corner-all ui-state-hover" )
- .removeAttr( "tabIndex" )
- .removeAttr( "role" )
- .removeAttr( "aria-haspopup" )
- .removeAttr( "id" )
- .children( ".ui-icon" )
- .remove();
+ .removeClass( "ui-corner-all ui-state-hover" )
+ .removeAttr( "tabIndex" )
+ .removeAttr( "role" )
+ .removeAttr( "aria-haspopup" )
+ .removeAttr( "id" )
+ .children( ".ui-icon" )
+ .remove();
+
+ // unbind currentEventTarget click event handler
+ $( currentEventTarget ).unbind( "click.menu" );
+ },
+
+ _keydown: function( event ) {
+ switch ( event.keyCode ) {
+ case $.ui.keyCode.PAGE_UP:
+ this.previousPage( event );
+ event.preventDefault();
+ break;
+ case $.ui.keyCode.PAGE_DOWN:
+ this.nextPage( event );
+ event.preventDefault();
+ break;
+ case $.ui.keyCode.HOME:
+ this._move( "first", "first", event );
+ event.preventDefault();
+ break;
+ case $.ui.keyCode.END:
+ this._move( "last", "last", event );
+ event.preventDefault();
+ break;
+ case $.ui.keyCode.UP:
+ this.previous( event );
+ event.preventDefault();
+ break;
+ case $.ui.keyCode.DOWN:
+ this.next( event );
+ event.preventDefault();
+ break;
+ case $.ui.keyCode.LEFT:
+ this.collapse( event );
+ event.preventDefault();
+ break;
+ case $.ui.keyCode.RIGHT:
+ if ( !this.active.is( ".ui-state-disabled" ) ) {
+ this.expand( event );
+ }
+ event.preventDefault();
+ break;
+ case $.ui.keyCode.ENTER:
+ if ( !this.active.is( ".ui-state-disabled" ) ) {
+ if ( this.active.children( "a[aria-haspopup='true']" ).length ) {
+ this.expand( event );
+ } else {
+ this.select( event );
+ }
+ }
+ event.preventDefault();
+ break;
+ case $.ui.keyCode.ESCAPE:
+ this.collapse( event );
+ event.preventDefault();
+ break;
+ default:
+ clearTimeout( this.filterTimer );
+ var match,
+ prev = this.previousFilter || "",
+ character = String.fromCharCode( event.keyCode ),
+ skip = false;
+
+ if ( character === prev ) {
+ skip = true;
+ } else {
+ character = prev + character;
+ }
+ function escape( value ) {
+ return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
+ }
+ match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
+ return new RegExp( "^" + escape( character ), "i" )
+ .test( $( this ).children( "a" ).text() );
+ });
+ match = skip && match.index(this.active.next()) !== -1 ?
+ this.active.nextAll(".ui-menu-item") :
+ match;
+ if ( !match.length ) {
+ character = String.fromCharCode(event.keyCode);
+ match = this.activeMenu.children(".ui-menu-item").filter(function() {
+ return new RegExp( "^" + escape(character), "i" )
+ .test( $( this ).children( "a" ).text() );
+ });
+ }
+ if ( match.length ) {
+ this.focus( event, match );
+ if ( match.length > 1 ) {
+ this.previousFilter = character;
+ this.filterTimer = this._delay(function() {
+ delete this.previousFilter;
+ }, 1000 );
+ } else {
+ delete this.previousFilter;
+ }
+ } else {
+ delete this.previousFilter;
+ }
+ }
},
refresh: function() {
// initialize nested menus
- var menuId,
- submenus = this.element.find( this.options.menus + ":not( .ui-menu )" )
+ var menus,
+ menuId = this.menuId,
+ submenus = this.element.find( this.options.menus + ":not(.ui-menu)" )
.addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
.hide()
.attr({
@@ -271,8 +273,9 @@ $.widget( "ui.menu", {
});
// don't refresh list items that are already adapted
- menuId = this.menuId;
- submenus.add( this.element ).children( ":not( .ui-menu-item ):has( a )" )
+ menus = submenus.add( this.element );
+
+ menus.children( ":not( .ui-menu-item ):has( a )" )
.addClass( "ui-menu-item" )
.attr( "role", "presentation" )
.children( "a" )
@@ -283,7 +286,13 @@ $.widget( "ui.menu", {
return menuId + "-" + i;
});
- submenus.each( function() {
+ // initialize unlinked menu-items as dividers
+ menus.children( ":not(.ui-menu-item)" ).addClass( "ui-widget-content ui-menu-divider" );
+
+ // add aria-disabled attribute to any disabled menu item
+ menus.children( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
+
+ submenus.each(function() {
var menu = $( this ),
item = menu.prev( "a" );
@@ -295,7 +304,7 @@ $.widget( "ui.menu", {
focus: function( event, item ) {
var nested, borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
- this.blur( event );
+ this.blur( event, event && event.type === "focus" );
if ( this._hasScroll() ) {
borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
@@ -312,18 +321,22 @@ $.widget( "ui.menu", {
}
}
- this.active = item.first()
- .children( "a" )
+ this.active = item.first();
+ this.element.attr( "aria-activedescendant",
+ this.active.children( "a" )
.addClass( "ui-state-focus" )
- .end();
- this.element.attr( "aria-activedescendant", this.active.children( "a" ).attr( "id" ) );
+ .attr( "id" ) );
// highlight active parent menu item, if any
this.active.parent().closest( ".ui-menu-item" ).children( "a:first" ).addClass( "ui-state-active" );
- this.timer = this._delay( function() {
+ if ( event.type === "keydown" ) {
this._close();
- }, this.delay );
+ } else {
+ this.timer = this._delay(function() {
+ this._close();
+ }, this.delay );
+ }
nested = $( "> .ui-menu", item );
if ( nested.length && ( /^mouse/.test( event.type ) ) ) {
@@ -334,8 +347,10 @@ $.widget( "ui.menu", {
this._trigger( "focus", event, { item: item } );
},
- blur: function( event ) {
- clearTimeout( this.timer );
+ blur: function( event, fromFocus ) {
+ if ( !fromFocus ) {
+ clearTimeout( this.timer );
+ }
if ( !this.active ) {
return;
@@ -356,7 +371,7 @@ $.widget( "ui.menu", {
return;
}
- this.timer = this._delay( function() {
+ this.timer = this._delay(function() {
this._close();
this._open( submenu );
}, this.delay );
@@ -364,20 +379,19 @@ $.widget( "ui.menu", {
_open: function( submenu ) {
clearTimeout( this.timer );
- this.element
- .find( ".ui-menu" )
- .not( submenu.parents() )
+ this.element.find( ".ui-menu" ).not( submenu.parents() )
.hide()
.attr( "aria-hidden", "true" );
- var position = $.extend({}, {
+ var position = $.extend( {}, {
of: this.active
}, $.type(this.options.position) === "function" ?
this.options.position(this.active) :
this.options.position
);
- submenu.show()
+ submenu
+ .show()
.removeAttr( "aria-hidden" )
.attr( "aria-expanded", "true" )
.position( position );
@@ -385,7 +399,7 @@ $.widget( "ui.menu", {
collapseAll: function( event, all ) {
clearTimeout( this.timer );
- this.timer = this._delay( function() {
+ this.timer = this._delay(function() {
// if we were passed an event, look for the submenu that contains the event
var currentMenu = all ? this.element :
$( event && event.target ).closest( this.element.find( ".ui-menu" ) );
@@ -399,7 +413,7 @@ $.widget( "ui.menu", {
this.blur( event );
this.activeMenu = currentMenu;
- }, this.delay);
+ }, this.delay );
},
// With no arguments, closes the currently active menu - if nothing is active
@@ -416,11 +430,12 @@ $.widget( "ui.menu", {
.attr( "aria-expanded", "false" )
.end()
.find( "a.ui-state-active" )
- .removeClass( "ui-state-active" );
+ .removeClass( "ui-state-active" );
},
collapse: function( event ) {
- var newItem = this.active && this.active.parent().closest( ".ui-menu-item", this.element );
+ var newItem = this.active &&
+ this.active.parent().closest( ".ui-menu-item", this.element );
if ( newItem && newItem.length ) {
this._close();
this.focus( event, newItem );
@@ -429,13 +444,17 @@ $.widget( "ui.menu", {
},
expand: function( event ) {
- var newItem = this.active && this.active.children( ".ui-menu " ).children( ".ui-menu-item" ).not( ".ui-state-disabled" ).first();
+ var newItem = this.active &&
+ this.active
+ .children( ".ui-menu " )
+ .children( ".ui-menu-item" )
+ .first();
if ( newItem && newItem.length ) {
this._open( newItem.parent() );
//timeout so Firefox will not hide activedescendant change in expanding submenu from AT
- this._delay( function() {
+ this._delay(function() {
this.focus( event, newItem );
}, 20 );
return true;
@@ -462,9 +481,13 @@ $.widget( "ui.menu", {
var next;
if ( this.active ) {
if ( direction === "first" || direction === "last" ) {
- next = this.active[ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" ).not( ".ui-state-disabled" ).eq( -1 );
+ next = this.active
+ [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
+ .eq( -1 );
} else {
- next = this.active[ direction + "All" ]( ".ui-menu-item" ).not( ".ui-state-disabled" ).eq( 0 );
+ next = this.active
+ [ direction + "All" ]( ".ui-menu-item" )
+ .eq( 0 );
}
}
if ( !next || !next.length || !this.active ) {
@@ -472,9 +495,6 @@ $.widget( "ui.menu", {
}
this.focus( event, next );
- if ( next.is( ".ui-state-disabled" ) ) {
- this._move( direction, filter, event );
- }
},
nextPage: function( event ) {
@@ -489,14 +509,14 @@ $.widget( "ui.menu", {
var base = this.active.offset().top,
height = this.element.height(),
result;
- this.active.nextAll( ".ui-menu-item" ).not( ".ui-state-disabled" ).each( function() {
+ this.active.nextAll( ".ui-menu-item" ).each(function() {
result = $( this );
return $( this ).offset().top - base - height < 0;
});
this.focus( event, result );
} else {
- this.focus( event, this.activeMenu.children( ".ui-menu-item" ).not( ".ui-state-disabled" )
+ this.focus( event, this.activeMenu.children( ".ui-menu-item" )
[ !this.active ? "first" : "last" ]() );
}
},
@@ -513,14 +533,14 @@ $.widget( "ui.menu", {
var base = this.active.offset().top,
height = this.element.height(),
result;
- this.active.prevAll( ".ui-menu-item" ).not( ".ui-state-disabled" ).each( function() {
+ this.active.prevAll( ".ui-menu-item" ).each(function() {
result = $( this );
return $(this).offset().top - base + height > 0;
});
this.focus( event, result );
} else {
- this.focus( event, this.activeMenu.children( ".ui-menu-item" ).not( ".ui-state-disabled" ).first() );
+ this.focus( event, this.activeMenu.children( ".ui-menu-item" ).first() );
}
},
@@ -529,7 +549,6 @@ $.widget( "ui.menu", {
},
select: function( event ) {
-
// save active reference before collapseAll triggers blur
var ui = {
item: this.active
diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js
index 7fe31626d..bd7bfb015 100644
--- a/ui/jquery.ui.position.js
+++ b/ui/jquery.ui.position.js
@@ -11,16 +11,32 @@
$.ui = $.ui || {};
-var rhorizontal = /left|center|right/,
+var cachedScrollbarWidth,
+ max = Math.max,
+ abs = Math.abs,
+ round = Math.round,
+ rhorizontal = /left|center|right/,
rvertical = /top|center|bottom/,
- roffset = /[+-]\d+%?/,
+ roffset = /[\+\-]\d+%?/,
rposition = /^\w+/,
rpercent = /%$/,
- center = "center",
_position = $.fn.position;
+function getOffsets( offsets, width, height ) {
+ return [
+ parseInt( offsets[ 0 ], 10 ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
+ parseInt( offsets[ 1 ], 10 ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
+ ];
+}
+function parseCss( element, property ) {
+ return parseInt( $.css( element, property ), 10 ) || 0;
+}
+
$.position = {
scrollbarWidth: function() {
+ if ( cachedScrollbarWidth !== undefined ) {
+ return cachedScrollbarWidth;
+ }
var w1, w2,
div = $( "<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
innerDiv = div.children()[0];
@@ -37,18 +53,31 @@ $.position = {
div.remove();
- return w1 - w2;
+ return (cachedScrollbarWidth = w1 - w2);
},
- getScrollInfo: function(within) {
- var notWindow = within[0] !== window,
- overflowX = notWindow ? within.css( "overflow-x" ) : "",
- overflowY = notWindow ? within.css( "overflow-y" ) : "",
- scrollbarWidth = overflowX === "auto" || overflowX === "scroll" ? $.position.scrollbarWidth() : 0,
- scrollbarHeight = overflowY === "auto" || overflowY === "scroll" ? $.position.scrollbarWidth() : 0;
-
+ getScrollInfo: function( within ) {
+ var overflowX = within.isWindow ? "" : within.element.css( "overflow-x" ),
+ overflowY = within.isWindow ? "" : within.element.css( "overflow-y" ),
+ hasOverflowX = overflowX === "scroll" ||
+ ( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
+ hasOverflowY = overflowY === "scroll" ||
+ ( overflowY === "auto" && within.height < within.element[0].scrollHeight );
+ return {
+ width: hasOverflowX ? $.position.scrollbarWidth() : 0,
+ height: hasOverflowY ? $.position.scrollbarWidth() : 0
+ };
+ },
+ getWithinInfo: function( element ) {
+ var withinElement = $( element || window ),
+ isWindow = $.isWindow( withinElement[0] );
return {
- height: within.height() < within[0].scrollHeight ? scrollbarHeight : 0,
- width: within.width() < within[0].scrollWidth ? scrollbarWidth : 0
+ element: withinElement,
+ isWindow: isWindow,
+ offset: withinElement.offset() || { left: 0, top: 0 },
+ scrollLeft: withinElement.scrollLeft(),
+ scrollTop: withinElement.scrollTop(),
+ width: isWindow ? withinElement.width() : withinElement.outerWidth(),
+ height: isWindow ? withinElement.height() : withinElement.outerHeight()
};
}
};
@@ -61,34 +90,34 @@ $.fn.position = function( options ) {
// make a copy, we don't want to modify arguments
options = $.extend( {}, options );
- var target = $( options.of ),
- within = $( options.within || window ),
+ var atOffset, targetWidth, targetHeight, targetOffset, basePosition,
+ target = $( options.of ),
+ within = $.position.getWithinInfo( options.within ),
+ scrollInfo = $.position.getScrollInfo( within ),
targetElem = target[0],
collision = ( options.collision || "flip" ).split( " " ),
- offsets = {},
- atOffset,
- targetWidth,
- targetHeight,
- basePosition;
+ offsets = {};
if ( targetElem.nodeType === 9 ) {
targetWidth = target.width();
targetHeight = target.height();
- basePosition = { top: 0, left: 0 };
+ targetOffset = { top: 0, left: 0 };
} else if ( $.isWindow( targetElem ) ) {
targetWidth = target.width();
targetHeight = target.height();
- basePosition = { top: target.scrollTop(), left: target.scrollLeft() };
+ targetOffset = { top: target.scrollTop(), left: target.scrollLeft() };
} else if ( targetElem.preventDefault ) {
// force left top to allow flipping
options.at = "left top";
targetWidth = targetHeight = 0;
- basePosition = { top: options.of.pageY, left: options.of.pageX };
+ targetOffset = { top: targetElem.pageY, left: targetElem.pageX };
} else {
targetWidth = target.outerWidth();
targetHeight = target.outerHeight();
- basePosition = target.offset();
+ targetOffset = target.offset();
}
+ // clone to reuse original targetOffset later
+ basePosition = $.extend( {}, targetOffset );
// force my and at to have valid horizontal and vertical positions
// if a value is missing or invalid, it will be converted to center
@@ -99,13 +128,13 @@ $.fn.position = function( options ) {
if ( pos.length === 1) {
pos = rhorizontal.test( pos[ 0 ] ) ?
- pos.concat( [ center ] ) :
+ pos.concat( [ "center" ] ) :
rvertical.test( pos[ 0 ] ) ?
- [ center ].concat( pos ) :
- [ center, center ];
+ [ "center" ].concat( pos ) :
+ [ "center", "center" ];
}
- pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : center;
- pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : center;
+ pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
+ pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
// calculate offsets
horizontalOffset = roffset.exec( pos[ 0 ] );
@@ -129,54 +158,41 @@ $.fn.position = function( options ) {
if ( options.at[ 0 ] === "right" ) {
basePosition.left += targetWidth;
- } else if ( options.at[ 0 ] === center ) {
+ } else if ( options.at[ 0 ] === "center" ) {
basePosition.left += targetWidth / 2;
}
if ( options.at[ 1 ] === "bottom" ) {
basePosition.top += targetHeight;
- } else if ( options.at[ 1 ] === center ) {
+ } else if ( options.at[ 1 ] === "center" ) {
basePosition.top += targetHeight / 2;
}
- atOffset = [
- parseInt( offsets.at[ 0 ], 10 ) *
- ( rpercent.test( offsets.at[ 0 ] ) ? targetWidth / 100 : 1 ),
- parseInt( offsets.at[ 1 ], 10 ) *
- ( rpercent.test( offsets.at[ 1 ] ) ? targetHeight / 100 : 1 )
- ];
+ atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
basePosition.left += atOffset[ 0 ];
basePosition.top += atOffset[ 1 ];
return this.each(function() {
- var elem = $( this ),
+ var collisionPosition, using,
+ elem = $( this ),
elemWidth = elem.outerWidth(),
elemHeight = elem.outerHeight(),
- marginLeft = parseInt( $.css( this, "marginLeft" ), 10 ) || 0,
- marginTop = parseInt( $.css( this, "marginTop" ), 10 ) || 0,
- scrollInfo = $.position.getScrollInfo( within ),
- collisionWidth = elemWidth + marginLeft +
- ( parseInt( $.css( this, "marginRight" ), 10 ) || 0 ) + scrollInfo.width,
- collisionHeight = elemHeight + marginTop +
- ( parseInt( $.css( this, "marginBottom" ), 10 ) || 0 ) + scrollInfo.height,
+ marginLeft = parseCss( this, "marginLeft" ),
+ marginTop = parseCss( this, "marginTop" ),
+ collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width,
+ collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height,
position = $.extend( {}, basePosition ),
- myOffset = [
- parseInt( offsets.my[ 0 ], 10 ) *
- ( rpercent.test( offsets.my[ 0 ] ) ? elem.outerWidth() / 100 : 1 ),
- parseInt( offsets.my[ 1 ], 10 ) *
- ( rpercent.test( offsets.my[ 1 ] ) ? elem.outerHeight() / 100 : 1 )
- ],
- collisionPosition;
+ myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
if ( options.my[ 0 ] === "right" ) {
position.left -= elemWidth;
- } else if ( options.my[ 0 ] === center ) {
+ } else if ( options.my[ 0 ] === "center" ) {
position.left -= elemWidth / 2;
}
if ( options.my[ 1 ] === "bottom" ) {
position.top -= elemHeight;
- } else if ( options.my[ 1 ] === center ) {
+ } else if ( options.my[ 1 ] === "center" ) {
position.top -= elemHeight / 2;
}
@@ -185,8 +201,8 @@ $.fn.position = function( options ) {
// if the browser doesn't support fractions, then round for consistent results
if ( !$.support.offsetFractions ) {
- position.left = Math.round( position.left );
- position.top = Math.round( position.top );
+ position.left = round( position.left );
+ position.top = round( position.top );
}
collisionPosition = {
@@ -216,7 +232,48 @@ $.fn.position = function( options ) {
if ( $.fn.bgiframe ) {
elem.bgiframe();
}
- elem.offset( $.extend( position, { using: options.using } ) );
+
+ if ( options.using ) {
+ // adds feedback as second argument to using callback, if present
+ using = function( props ) {
+ var left = targetOffset.left - position.left,
+ right = left + targetWidth - elemWidth,
+ top = targetOffset.top - position.top,
+ bottom = top + targetHeight - elemHeight,
+ feedback = {
+ target: {
+ element: target,
+ left: targetOffset.left,
+ top: targetOffset.top,
+ width: targetWidth,
+ height: targetHeight
+ },
+ element: {
+ element: elem,
+ left: position.left,
+ top: position.top,
+ width: elemWidth,
+ height: elemHeight
+ },
+ horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
+ vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
+ };
+ if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
+ feedback.horizontal = "center";
+ }
+ if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
+ feedback.vertical = "middle";
+ }
+ if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
+ feedback.important = "horizontal";
+ } else {
+ feedback.important = "vertical";
+ }
+ options.using.call( this, props, feedback );
+ };
+ }
+
+ elem.offset( $.extend( position, { using: using } ) );
});
};
@@ -224,15 +281,12 @@ $.ui.position = {
fit: {
left: function( position, data ) {
var within = data.within,
- win = $( window ),
- isWindow = $.isWindow( data.within[0] ),
- withinOffset = isWindow ? win.scrollLeft() : within.offset().left,
- outerWidth = isWindow ? win.width() : within.outerWidth(),
+ withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
+ outerWidth = within.width,
collisionPosLeft = position.left - data.collisionPosition.marginLeft,
overLeft = withinOffset - collisionPosLeft,
overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
- newOverRight,
- newOverLeft;
+ newOverRight;
// element is wider than within
if ( data.collisionWidth > outerWidth ) {
@@ -259,19 +313,16 @@ $.ui.position = {
position.left -= overRight;
// adjust based on position and margin
} else {
- position.left = Math.max( position.left - collisionPosLeft, position.left );
+ position.left = max( position.left - collisionPosLeft, position.left );
}
},
top: function( position, data ) {
var within = data.within,
- win = $( window ),
- isWindow = $.isWindow( data.within[0] ),
- withinOffset = isWindow ? win.scrollTop() : within.offset().top,
- outerHeight = isWindow ? win.height() : within.outerHeight(),
+ withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
+ outerHeight = data.within.height,
collisionPosTop = position.top - data.collisionPosition.marginTop,
overTop = withinOffset - collisionPosTop,
overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
- newOverTop,
newOverBottom;
// element is taller than within
@@ -299,28 +350,19 @@ $.ui.position = {
position.top -= overBottom;
// adjust based on position and margin
} else {
- position.top = Math.max( position.top - collisionPosTop, position.top );
+ position.top = max( position.top - collisionPosTop, position.top );
}
}
},
flip: {
left: function( position, data ) {
- if ( data.at[ 0 ] === center ) {
- return;
- }
-
- data.elem
- .removeClass( "ui-flipped-left ui-flipped-right" );
-
var within = data.within,
- win = $( window ),
- isWindow = $.isWindow( data.within[0] ),
- withinOffset = ( isWindow ? 0 : within.offset().left ) + within.scrollLeft(),
- outerWidth = isWindow ? within.width() : within.outerWidth(),
+ withinOffset = within.offset.left + within.scrollLeft,
+ outerWidth = within.width,
+ offsetLeft = within.isWindow ? 0 : within.offset.left,
collisionPosLeft = position.left - data.collisionPosition.marginLeft,
- overLeft = collisionPosLeft - withinOffset,
- overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
- left = data.my[ 0 ] === "left",
+ overLeft = collisionPosLeft - offsetLeft,
+ overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
myOffset = data.my[ 0 ] === "left" ?
-data.elemWidth :
data.my[ 0 ] === "right" ?
@@ -328,46 +370,34 @@ $.ui.position = {
0,
atOffset = data.at[ 0 ] === "left" ?
data.targetWidth :
- -data.targetWidth,
+ data.at[ 0 ] === "right" ?
+ -data.targetWidth :
+ 0,
offset = -2 * data.offset[ 0 ],
newOverRight,
newOverLeft;
if ( overLeft < 0 ) {
newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
- if ( newOverRight < 0 || newOverRight < Math.abs( overLeft ) ) {
- data.elem
- .addClass( "ui-flipped-right" );
-
+ if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
position.left += myOffset + atOffset + offset;
}
}
else if ( overRight > 0 ) {
- newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - withinOffset;
- if ( newOverLeft > 0 || Math.abs( newOverLeft ) < overRight ) {
- data.elem
- .addClass( "ui-flipped-left" );
-
+ newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
+ if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
position.left += myOffset + atOffset + offset;
}
}
},
top: function( position, data ) {
- if ( data.at[ 1 ] === center ) {
- return;
- }
-
- data.elem
- .removeClass( "ui-flipped-top ui-flipped-bottom" );
-
var within = data.within,
- win = $( window ),
- isWindow = $.isWindow( data.within[0] ),
- withinOffset = ( isWindow ? 0 : within.offset().top ) + within.scrollTop(),
- outerHeight = isWindow ? within.height() : within.outerHeight(),
+ withinOffset = within.offset.top + within.scrollTop,
+ outerHeight = within.height,
+ offsetTop = within.isWindow ? 0 : within.offset.top,
collisionPosTop = position.top - data.collisionPosition.marginTop,
- overTop = collisionPosTop - withinOffset,
- overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
+ overTop = collisionPosTop - offsetTop,
+ overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
top = data.my[ 1 ] === "top",
myOffset = top ?
-data.elemHeight :
@@ -376,25 +406,21 @@ $.ui.position = {
0,
atOffset = data.at[ 1 ] === "top" ?
data.targetHeight :
- -data.targetHeight,
+ data.at[ 1 ] === "bottom" ?
+ -data.targetHeight :
+ 0,
offset = -2 * data.offset[ 1 ],
newOverTop,
newOverBottom;
if ( overTop < 0 ) {
newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
- if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < Math.abs( overTop ) ) ) {
- data.elem
- .addClass( "ui-flipped-bottom" );
-
+ if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) ) {
position.top += myOffset + atOffset + offset;
}
}
else if ( overBottom > 0 ) {
- newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - withinOffset;
- if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || Math.abs( newOverTop ) < overBottom ) ) {
- data.elem
- .addClass( "ui-flipped-top" );
-
+ newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
+ if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || abs( newOverTop ) < overBottom ) ) {
position.top += myOffset + atOffset + offset;
}
}
diff --git a/ui/jquery.ui.resizable.js b/ui/jquery.ui.resizable.js
index 9be33927e..b4433b618 100644
--- a/ui/jquery.ui.resizable.js
+++ b/ui/jquery.ui.resizable.js
@@ -37,7 +37,7 @@ $.widget("ui.resizable", $.ui.mouse, {
},
_create: function() {
- var self = this, o = this.options;
+ var that = this, o = this.options;
this.element.addClass("ui-resizable");
$.extend(this, {
@@ -99,9 +99,8 @@ $.widget("ui.resizable", $.ui.mouse, {
var handle = $.trim(n[i]), hname = 'ui-resizable-'+handle;
var axis = $('<div class="ui-resizable-handle ' + hname + '"></div>');
- // increase zIndex of sw, se, ne, nw axis
- //TODO : this modifies original option
- if(/sw|se|ne|nw/.test(handle)) axis.css({ zIndex: ++o.zIndex });
+ // Apply zIndex to all handles - see #7960
+ axis.css({ zIndex: o.zIndex });
//TODO : What's going on here?
if ('se' == handle) {
@@ -159,11 +158,11 @@ $.widget("ui.resizable", $.ui.mouse, {
//Matching axis name
this._handles.mouseover(function() {
- if (!self.resizing) {
+ if (!that.resizing) {
if (this.className)
var axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
//Axis, default = se
- self.axis = axis && axis[1] ? axis[1] : 'se';
+ that.axis = axis && axis[1] ? axis[1] : 'se';
}
});
@@ -175,13 +174,13 @@ $.widget("ui.resizable", $.ui.mouse, {
.hover(function() {
if (o.disabled) return;
$(this).removeClass("ui-resizable-autohide");
- self._handles.show();
+ that._handles.show();
},
function(){
if (o.disabled) return;
- if (!self.resizing) {
+ if (!that.resizing) {
$(this).addClass("ui-resizable-autohide");
- self._handles.hide();
+ that._handles.hide();
}
});
}
@@ -277,7 +276,7 @@ $.widget("ui.resizable", $.ui.mouse, {
//Increase performance, avoid regex
var el = this.helper, o = this.options, props = {},
- self = this, smp = this.originalMousePosition, a = this.axis;
+ that = this, smp = this.originalMousePosition, a = this.axis;
var dx = (event.pageX-smp.left)||0, dy = (event.pageY-smp.top)||0;
var trigger = this._change[a];
@@ -315,22 +314,22 @@ $.widget("ui.resizable", $.ui.mouse, {
_mouseStop: function(event) {
this.resizing = false;
- var o = this.options, self = this;
+ var o = this.options, that = this;
if(this._helper) {
var pr = this._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
- soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,
- soffsetw = ista ? 0 : self.sizeDiff.width;
+ soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : that.sizeDiff.height,
+ soffsetw = ista ? 0 : that.sizeDiff.width;
- var s = { width: (self.helper.width() - soffsetw), height: (self.helper.height() - soffseth) },
- left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null,
- top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null;
+ var s = { width: (that.helper.width() - soffsetw), height: (that.helper.height() - soffseth) },
+ left = (parseInt(that.element.css('left'), 10) + (that.position.left - that.originalPosition.left)) || null,
+ top = (parseInt(that.element.css('top'), 10) + (that.position.top - that.originalPosition.top)) || null;
if (!o.animate)
this.element.css($.extend(s, { top: top, left: left }));
- self.helper.height(self.size.height);
- self.helper.width(self.size.width);
+ that.helper.height(that.size.height);
+ that.helper.width(that.size.width);
if (this._helper && !o.animate) this._proportionallyResize();
}
@@ -548,7 +547,7 @@ $.widget("ui.resizable", $.ui.mouse, {
$.ui.plugin.add("resizable", "alsoResize", {
start: function (event, ui) {
- var self = $(this).data("resizable"), o = self.options;
+ var that = $(this).data("resizable"), o = that.options;
var _store = function (exp) {
$(exp).each(function() {
@@ -569,11 +568,11 @@ $.ui.plugin.add("resizable", "alsoResize", {
},
resize: function (event, ui) {
- var self = $(this).data("resizable"), o = self.options, os = self.originalSize, op = self.originalPosition;
+ var that = $(this).data("resizable"), o = that.options, os = that.originalSize, op = that.originalPosition;
var delta = {
- height: (self.size.height - os.height) || 0, width: (self.size.width - os.width) || 0,
- top: (self.position.top - op.top) || 0, left: (self.position.left - op.left) || 0
+ height: (that.size.height - os.height) || 0, width: (that.size.width - os.width) || 0,
+ top: (that.position.top - op.top) || 0, left: (that.position.left - op.left) || 0
},
_alsoResize = function (exp, c) {
@@ -606,34 +605,34 @@ $.ui.plugin.add("resizable", "alsoResize", {
$.ui.plugin.add("resizable", "animate", {
stop: function(event, ui) {
- var self = $(this).data("resizable"), o = self.options;
+ var that = $(this).data("resizable"), o = that.options;
- var pr = self._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
- soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,
- soffsetw = ista ? 0 : self.sizeDiff.width;
+ var pr = that._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
+ soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : that.sizeDiff.height,
+ soffsetw = ista ? 0 : that.sizeDiff.width;
- var style = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) },
- left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null,
- top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null;
+ var style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
+ left = (parseInt(that.element.css('left'), 10) + (that.position.left - that.originalPosition.left)) || null,
+ top = (parseInt(that.element.css('top'), 10) + (that.position.top - that.originalPosition.top)) || null;
- self.element.animate(
+ that.element.animate(
$.extend(style, top && left ? { top: top, left: left } : {}), {
duration: o.animateDuration,
easing: o.animateEasing,
step: function() {
var data = {
- width: parseInt(self.element.css('width'), 10),
- height: parseInt(self.element.css('height'), 10),
- top: parseInt(self.element.css('top'), 10),
- left: parseInt(self.element.css('left'), 10)
+ width: parseInt(that.element.css('width'), 10),
+ height: parseInt(that.element.css('height'), 10),
+ top: parseInt(that.element.css('top'), 10),
+ left: parseInt(that.element.css('left'), 10)
};
if (pr && pr.length) $(pr[0]).css({ width: data.width, height: data.height });
// propagating resize, and updating values for each animation step
- self._updateCache(data);
- self._propagate("resize", event);
+ that._updateCache(data);
+ that._propagate("resize", event);
}
}
@@ -645,17 +644,17 @@ $.ui.plugin.add("resizable", "animate", {
$.ui.plugin.add("resizable", "containment", {
start: function(event, ui) {
- var self = $(this).data("resizable"), o = self.options, el = self.element;
+ var that = $(this).data("resizable"), o = that.options, el = that.element;
var oc = o.containment, ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
if (!ce) return;
- self.containerElement = $(ce);
+ that.containerElement = $(ce);
if (/document/.test(oc) || oc == document) {
- self.containerOffset = { left: 0, top: 0 };
- self.containerPosition = { left: 0, top: 0 };
+ that.containerOffset = { left: 0, top: 0 };
+ that.containerPosition = { left: 0, top: 0 };
- self.parentData = {
+ that.parentData = {
element: $(document), left: 0, top: 0,
width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
};
@@ -666,70 +665,70 @@ $.ui.plugin.add("resizable", "containment", {
var element = $(ce), p = [];
$([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); });
- self.containerOffset = element.offset();
- self.containerPosition = element.position();
- self.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
+ that.containerOffset = element.offset();
+ that.containerPosition = element.position();
+ that.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
- var co = self.containerOffset, ch = self.containerSize.height, cw = self.containerSize.width,
+ var co = that.containerOffset, ch = that.containerSize.height, cw = that.containerSize.width,
width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw ), height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
- self.parentData = {
+ that.parentData = {
element: ce, left: co.left, top: co.top, width: width, height: height
};
}
},
resize: function(event, ui) {
- var self = $(this).data("resizable"), o = self.options,
- ps = self.containerSize, co = self.containerOffset, cs = self.size, cp = self.position,
- pRatio = self._aspectRatio || event.shiftKey, cop = { top:0, left:0 }, ce = self.containerElement;
+ var that = $(this).data("resizable"), o = that.options,
+ ps = that.containerSize, co = that.containerOffset, cs = that.size, cp = that.position,
+ pRatio = that._aspectRatio || event.shiftKey, cop = { top:0, left:0 }, ce = that.containerElement;
if (ce[0] != document && (/static/).test(ce.css('position'))) cop = co;
- if (cp.left < (self._helper ? co.left : 0)) {
- self.size.width = self.size.width + (self._helper ? (self.position.left - co.left) : (self.position.left - cop.left));
- if (pRatio) self.size.height = self.size.width / self.aspectRatio;
- self.position.left = o.helper ? co.left : 0;
+ if (cp.left < (that._helper ? co.left : 0)) {
+ that.size.width = that.size.width + (that._helper ? (that.position.left - co.left) : (that.position.left - cop.left));
+ if (pRatio) that.size.height = that.size.width / that.aspectRatio;
+ that.position.left = o.helper ? co.left : 0;
}
- if (cp.top < (self._helper ? co.top : 0)) {
- self.size.height = self.size.height + (self._helper ? (self.position.top - co.top) : self.position.top);
- if (pRatio) self.size.width = self.size.height * self.aspectRatio;
- self.position.top = self._helper ? co.top : 0;
+ if (cp.top < (that._helper ? co.top : 0)) {
+ that.size.height = that.size.height + (that._helper ? (that.position.top - co.top) : that.position.top);
+ if (pRatio) that.size.width = that.size.height * that.aspectRatio;
+ that.position.top = that._helper ? co.top : 0;
}
- self.offset.left = self.parentData.left+self.position.left;
- self.offset.top = self.parentData.top+self.position.top;
+ that.offset.left = that.parentData.left+that.position.left;
+ that.offset.top = that.parentData.top+that.position.top;
- var woset = Math.abs( (self._helper ? self.offset.left - cop.left : (self.offset.left - cop.left)) + self.sizeDiff.width ),
- hoset = Math.abs( (self._helper ? self.offset.top - cop.top : (self.offset.top - co.top)) + self.sizeDiff.height );
+ var woset = Math.abs( (that._helper ? that.offset.left - cop.left : (that.offset.left - cop.left)) + that.sizeDiff.width ),
+ hoset = Math.abs( (that._helper ? that.offset.top - cop.top : (that.offset.top - co.top)) + that.sizeDiff.height );
- var isParent = self.containerElement.get(0) == self.element.parent().get(0),
- isOffsetRelative = /relative|absolute/.test(self.containerElement.css('position'));
+ var isParent = that.containerElement.get(0) == that.element.parent().get(0),
+ isOffsetRelative = /relative|absolute/.test(that.containerElement.css('position'));
- if(isParent && isOffsetRelative) woset -= self.parentData.left;
+ if(isParent && isOffsetRelative) woset -= that.parentData.left;
- if (woset + self.size.width >= self.parentData.width) {
- self.size.width = self.parentData.width - woset;
- if (pRatio) self.size.height = self.size.width / self.aspectRatio;
+ if (woset + that.size.width >= that.parentData.width) {
+ that.size.width = that.parentData.width - woset;
+ if (pRatio) that.size.height = that.size.width / that.aspectRatio;
}
- if (hoset + self.size.height >= self.parentData.height) {
- self.size.height = self.parentData.height - hoset;
- if (pRatio) self.size.width = self.size.height * self.aspectRatio;
+ if (hoset + that.size.height >= that.parentData.height) {
+ that.size.height = that.parentData.height - hoset;
+ if (pRatio) that.size.width = that.size.height * that.aspectRatio;
}
},
stop: function(event, ui){
- var self = $(this).data("resizable"), o = self.options, cp = self.position,
- co = self.containerOffset, cop = self.containerPosition, ce = self.containerElement;
+ var that = $(this).data("resizable"), o = that.options, cp = that.position,
+ co = that.containerOffset, cop = that.containerPosition, ce = that.containerElement;
- var helper = $(self.helper), ho = helper.offset(), w = helper.outerWidth() - self.sizeDiff.width, h = helper.outerHeight() - self.sizeDiff.height;
+ var helper = $(that.helper), ho = helper.offset(), w = helper.outerWidth() - that.sizeDiff.width, h = helper.outerHeight() - that.sizeDiff.height;
- if (self._helper && !o.animate && (/relative/).test(ce.css('position')))
+ if (that._helper && !o.animate && (/relative/).test(ce.css('position')))
$(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
- if (self._helper && !o.animate && (/static/).test(ce.css('position')))
+ if (that._helper && !o.animate && (/static/).test(ce.css('position')))
$(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
}
@@ -739,26 +738,26 @@ $.ui.plugin.add("resizable", "ghost", {
start: function(event, ui) {
- var self = $(this).data("resizable"), o = self.options, cs = self.size;
+ var that = $(this).data("resizable"), o = that.options, cs = that.size;
- self.ghost = self.originalElement.clone();
- self.ghost
+ that.ghost = that.originalElement.clone();
+ that.ghost
.css({ opacity: .25, display: 'block', position: 'relative', height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
.addClass('ui-resizable-ghost')
.addClass(typeof o.ghost == 'string' ? o.ghost : '');
- self.ghost.appendTo(self.helper);
+ that.ghost.appendTo(that.helper);
},
resize: function(event, ui){
- var self = $(this).data("resizable"), o = self.options;
- if (self.ghost) self.ghost.css({ position: 'relative', height: self.size.height, width: self.size.width });
+ var that = $(this).data("resizable"), o = that.options;
+ if (that.ghost) that.ghost.css({ position: 'relative', height: that.size.height, width: that.size.width });
},
stop: function(event, ui){
- var self = $(this).data("resizable"), o = self.options;
- if (self.ghost && self.helper) self.helper.get(0).removeChild(self.ghost.get(0));
+ var that = $(this).data("resizable"), o = that.options;
+ if (that.ghost && that.helper) that.helper.get(0).removeChild(that.ghost.get(0));
}
});
@@ -766,29 +765,29 @@ $.ui.plugin.add("resizable", "ghost", {
$.ui.plugin.add("resizable", "grid", {
resize: function(event, ui) {
- var self = $(this).data("resizable"), o = self.options, cs = self.size, os = self.originalSize, op = self.originalPosition, a = self.axis, ratio = o._aspectRatio || event.shiftKey;
+ var that = $(this).data("resizable"), o = that.options, cs = that.size, os = that.originalSize, op = that.originalPosition, a = that.axis, ratio = o._aspectRatio || event.shiftKey;
o.grid = typeof o.grid == "number" ? [o.grid, o.grid] : o.grid;
var ox = Math.round((cs.width - os.width) / (o.grid[0]||1)) * (o.grid[0]||1), oy = Math.round((cs.height - os.height) / (o.grid[1]||1)) * (o.grid[1]||1);
if (/^(se|s|e)$/.test(a)) {
- self.size.width = os.width + ox;
- self.size.height = os.height + oy;
+ that.size.width = os.width + ox;
+ that.size.height = os.height + oy;
}
else if (/^(ne)$/.test(a)) {
- self.size.width = os.width + ox;
- self.size.height = os.height + oy;
- self.position.top = op.top - oy;
+ that.size.width = os.width + ox;
+ that.size.height = os.height + oy;
+ that.position.top = op.top - oy;
}
else if (/^(sw)$/.test(a)) {
- self.size.width = os.width + ox;
- self.size.height = os.height + oy;
- self.position.left = op.left - ox;
+ that.size.width = os.width + ox;
+ that.size.height = os.height + oy;
+ that.position.left = op.left - ox;
}
else {
- self.size.width = os.width + ox;
- self.size.height = os.height + oy;
- self.position.top = op.top - oy;
- self.position.left = op.left - ox;
+ that.size.width = os.width + ox;
+ that.size.height = os.height + oy;
+ that.position.top = op.top - oy;
+ that.position.left = op.left - ox;
}
}
diff --git a/ui/jquery.ui.selectable.js b/ui/jquery.ui.selectable.js
index 3244e654e..f8a0134f8 100644
--- a/ui/jquery.ui.selectable.js
+++ b/ui/jquery.ui.selectable.js
@@ -24,7 +24,7 @@ $.widget("ui.selectable", $.ui.mouse, {
tolerance: 'touch'
},
_create: function() {
- var self = this;
+ var that = this;
this.element.addClass("ui-selectable");
@@ -33,7 +33,7 @@ $.widget("ui.selectable", $.ui.mouse, {
// cache selectee children based on filter
var selectees;
this.refresh = function() {
- selectees = $(self.options.filter, self.element[0]);
+ selectees = $(that.options.filter, that.element[0]);
selectees.addClass("ui-selectee");
selectees.each(function() {
var $this = $(this);
@@ -75,7 +75,7 @@ $.widget("ui.selectable", $.ui.mouse, {
},
_mouseStart: function(event) {
- var self = this;
+ var that = this;
this.opos = [event.pageX, event.pageY];
@@ -110,7 +110,7 @@ $.widget("ui.selectable", $.ui.mouse, {
selectee.$element.addClass('ui-unselecting');
selectee.unselecting = true;
// selectable UNSELECTING callback
- self._trigger("unselecting", event, {
+ that._trigger("unselecting", event, {
unselecting: selectee.element
});
}
@@ -128,11 +128,11 @@ $.widget("ui.selectable", $.ui.mouse, {
selectee.selected = doSelect;
// selectable (UN)SELECTING callback
if (doSelect) {
- self._trigger("selecting", event, {
+ that._trigger("selecting", event, {
selecting: selectee.element
});
} else {
- self._trigger("unselecting", event, {
+ that._trigger("unselecting", event, {
unselecting: selectee.element
});
}
@@ -143,7 +143,7 @@ $.widget("ui.selectable", $.ui.mouse, {
},
_mouseDrag: function(event) {
- var self = this;
+ var that = this;
this.dragged = true;
if (this.options.disabled)
@@ -159,7 +159,7 @@ $.widget("ui.selectable", $.ui.mouse, {
this.selectees.each(function() {
var selectee = $.data(this, "selectable-item");
//prevent helper from being selected if appendTo: selectable
- if (!selectee || selectee.element == self.element[0])
+ if (!selectee || selectee.element == that.element[0])
return;
var hit = false;
if (options.tolerance == 'touch') {
@@ -182,7 +182,7 @@ $.widget("ui.selectable", $.ui.mouse, {
selectee.$element.addClass('ui-selecting');
selectee.selecting = true;
// selectable SELECTING callback
- self._trigger("selecting", event, {
+ that._trigger("selecting", event, {
selecting: selectee.element
});
}
@@ -202,7 +202,7 @@ $.widget("ui.selectable", $.ui.mouse, {
selectee.unselecting = true;
}
// selectable UNSELECTING callback
- self._trigger("unselecting", event, {
+ that._trigger("unselecting", event, {
unselecting: selectee.element
});
}
@@ -215,7 +215,7 @@ $.widget("ui.selectable", $.ui.mouse, {
selectee.$element.addClass('ui-unselecting');
selectee.unselecting = true;
// selectable UNSELECTING callback
- self._trigger("unselecting", event, {
+ that._trigger("unselecting", event, {
unselecting: selectee.element
});
}
@@ -227,7 +227,7 @@ $.widget("ui.selectable", $.ui.mouse, {
},
_mouseStop: function(event) {
- var self = this;
+ var that = this;
this.dragged = false;
@@ -238,7 +238,7 @@ $.widget("ui.selectable", $.ui.mouse, {
selectee.$element.removeClass('ui-unselecting');
selectee.unselecting = false;
selectee.startselected = false;
- self._trigger("unselected", event, {
+ that._trigger("unselected", event, {
unselected: selectee.element
});
});
@@ -248,7 +248,7 @@ $.widget("ui.selectable", $.ui.mouse, {
selectee.selecting = false;
selectee.selected = true;
selectee.startselected = true;
- self._trigger("selected", event, {
+ that._trigger("selected", event, {
selected: selectee.element
});
});
diff --git a/ui/jquery.ui.slider.js b/ui/jquery.ui.slider.js
index b355f8c7e..accd3e189 100644
--- a/ui/jquery.ui.slider.js
+++ b/ui/jquery.ui.slider.js
@@ -36,7 +36,6 @@ $.widget( "ui.slider", $.ui.mouse, {
_create: function() {
var i,
- self = this,
o = this.options,
existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
handle = "<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",
@@ -83,7 +82,7 @@ $.widget( "ui.slider", $.ui.mouse, {
handles.push( handle );
}
- this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( self.element ) );
+ this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
this.handle = this.handles.eq( 0 );
@@ -114,17 +113,10 @@ $.widget( "ui.slider", $.ui.mouse, {
$( this ).data( "ui-slider-handle-index", i );
});
- this.handles
- .keydown(function( event ) {
- var index = $( this ).data( "ui-slider-handle-index" ),
- allowed,
- curVal,
- newVal,
- step;
-
- if ( self.options.disabled ) {
- return;
- }
+ this._bind( this.handles, {
+ keydown: function( event ) {
+ var allowed, curVal, newVal, step,
+ index = $( event.target ).data( "ui-slider-handle-index" );
switch ( event.keyCode ) {
case $.ui.keyCode.HOME:
@@ -136,10 +128,10 @@ $.widget( "ui.slider", $.ui.mouse, {
case $.ui.keyCode.DOWN:
case $.ui.keyCode.LEFT:
event.preventDefault();
- if ( !self._keySliding ) {
- self._keySliding = true;
- $( this ).addClass( "ui-state-active" );
- allowed = self._start( event, index );
+ if ( !this._keySliding ) {
+ this._keySliding = true;
+ $( event.target ).addClass( "ui-state-active" );
+ allowed = this._start( event, index );
if ( allowed === false ) {
return;
}
@@ -147,62 +139,62 @@ $.widget( "ui.slider", $.ui.mouse, {
break;
}
- step = self.options.step;
- if ( self.options.values && self.options.values.length ) {
- curVal = newVal = self.values( index );
+ step = this.options.step;
+ if ( this.options.values && this.options.values.length ) {
+ curVal = newVal = this.values( index );
} else {
- curVal = newVal = self.value();
+ curVal = newVal = this.value();
}
switch ( event.keyCode ) {
case $.ui.keyCode.HOME:
- newVal = self._valueMin();
+ newVal = this._valueMin();
break;
case $.ui.keyCode.END:
- newVal = self._valueMax();
+ newVal = this._valueMax();
break;
case $.ui.keyCode.PAGE_UP:
- newVal = self._trimAlignValue( curVal + ( (self._valueMax() - self._valueMin()) / numPages ) );
+ newVal = this._trimAlignValue( curVal + ( (this._valueMax() - this._valueMin()) / numPages ) );
break;
case $.ui.keyCode.PAGE_DOWN:
- newVal = self._trimAlignValue( curVal - ( (self._valueMax() - self._valueMin()) / numPages ) );
+ newVal = this._trimAlignValue( curVal - ( (this._valueMax() - this._valueMin()) / numPages ) );
break;
case $.ui.keyCode.UP:
case $.ui.keyCode.RIGHT:
- if ( curVal === self._valueMax() ) {
+ if ( curVal === this._valueMax() ) {
return;
}
- newVal = self._trimAlignValue( curVal + step );
+ newVal = this._trimAlignValue( curVal + step );
break;
case $.ui.keyCode.DOWN:
case $.ui.keyCode.LEFT:
- if ( curVal === self._valueMin() ) {
+ if ( curVal === this._valueMin() ) {
return;
}
- newVal = self._trimAlignValue( curVal - step );
+ newVal = this._trimAlignValue( curVal - step );
break;
}
- self._slide( event, index, newVal );
- })
- .keyup(function( event ) {
- var index = $( this ).data( "ui-slider-handle-index" );
-
- if ( self._keySliding ) {
- self._keySliding = false;
- self._stop( event, index );
- self._change( event, index );
- $( this ).removeClass( "ui-state-active" );
- }
+ this._slide( event, index, newVal );
+ },
+ keyup: function( event ) {
+ var index = $( event.target ).data( "ui-slider-handle-index" );
- });
+ if ( this._keySliding ) {
+ this._keySliding = false;
+ this._stop( event, index );
+ this._change( event, index );
+ $( event.target ).removeClass( "ui-state-active" );
+ }
+ }
+ });
this._refreshValue();
this._animateOff = false;
},
- destroy: function() {
+ _destroy: function() {
this.handles.remove();
this.range.remove();
@@ -213,26 +205,15 @@ $.widget( "ui.slider", $.ui.mouse, {
" ui-slider-disabled" +
" ui-widget" +
" ui-widget-content" +
- " ui-corner-all" )
- .removeData( "slider" )
- .unbind( ".slider" );
+ " ui-corner-all" );
this._mouseDestroy();
-
- return this;
},
_mouseCapture: function( event ) {
- var o = this.options,
- position,
- normValue,
- distance,
- closestHandle,
- self,
- index,
- allowed,
- offset,
- mouseOverHandle;
+ var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
+ that = this,
+ o = this.options;
if ( o.disabled ) {
return false;
@@ -247,9 +228,8 @@ $.widget( "ui.slider", $.ui.mouse, {
position = { x: event.pageX, y: event.pageY };
normValue = this._normValueFromMouse( position );
distance = this._valueMax() - this._valueMin() + 1;
- self = this;
this.handles.each(function( i ) {
- var thisDistance = Math.abs( normValue - self.values(i) );
+ var thisDistance = Math.abs( normValue - that.values(i) );
if ( distance > thisDistance ) {
distance = thisDistance;
closestHandle = $( this );
@@ -271,7 +251,7 @@ $.widget( "ui.slider", $.ui.mouse, {
}
this._mouseSliding = true;
- self._handleIndex = index;
+ this._handleIndex = index;
closestHandle
.addClass( "ui-state-active" )
@@ -594,36 +574,32 @@ $.widget( "ui.slider", $.ui.mouse, {
},
_refreshValue: function() {
- var oRange = this.options.range,
+ var lastValPercent, valPercent, value, valueMin, valueMax,
+ oRange = this.options.range,
o = this.options,
- self = this,
+ that = this,
animate = ( !this._animateOff ) ? o.animate : false,
- valPercent,
- _set = {},
- lastValPercent,
- value,
- valueMin,
- valueMax;
+ _set = {};
if ( this.options.values && this.options.values.length ) {
this.handles.each(function( i, j ) {
- valPercent = ( self.values(i) - self._valueMin() ) / ( self._valueMax() - self._valueMin() ) * 100;
- _set[ self.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
+ valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
+ _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
$( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
- if ( self.options.range === true ) {
- if ( self.orientation === "horizontal" ) {
+ if ( that.options.range === true ) {
+ if ( that.orientation === "horizontal" ) {
if ( i === 0 ) {
- self.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
+ that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
}
if ( i === 1 ) {
- self.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
+ that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
}
} else {
if ( i === 0 ) {
- self.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
+ that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
}
if ( i === 1 ) {
- self.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
+ that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
}
}
}
@@ -636,7 +612,7 @@ $.widget( "ui.slider", $.ui.mouse, {
valPercent = ( valueMax !== valueMin ) ?
( value - valueMin ) / ( valueMax - valueMin ) * 100 :
0;
- _set[ self.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
+ _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
if ( oRange === "min" && this.orientation === "horizontal" ) {
diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js
index 4093be245..55a64590b 100644
--- a/ui/jquery.ui.sortable.js
+++ b/ui/jquery.ui.sortable.js
@@ -59,7 +59,7 @@ $.widget("ui.sortable", $.ui.mouse, {
//Initialize mouse events for interaction
this._mouseInit();
-
+
//We're ready to go
this.ready = true
@@ -79,7 +79,7 @@ $.widget("ui.sortable", $.ui.mouse, {
_setOption: function(key, value){
if ( key === "disabled" ) {
this.options[ key ] = value;
-
+
this.widget().toggleClass( "ui-sortable-disabled", !!value );
} else {
// Don't call widget base _setOption for disable as it adds ui-state-disabled class
@@ -100,13 +100,13 @@ $.widget("ui.sortable", $.ui.mouse, {
this._refreshItems(event);
//Find out if the clicked node (or one of its parents) is a actual item in this.items
- var currentItem = null, self = this, nodes = $(event.target).parents().each(function() {
- if($.data(this, that.widgetName + '-item') == self) {
+ var currentItem = null, nodes = $(event.target).parents().each(function() {
+ if($.data(this, that.widgetName + '-item') == that) {
currentItem = $(this);
return false;
}
});
- if($.data(event.target, that.widgetName + '-item') == self) currentItem = $(event.target);
+ if($.data(event.target, that.widgetName + '-item') == that) currentItem = $(event.target);
if(!currentItem) return false;
if(this.options.handle && !overrideHandle) {
@@ -124,7 +124,7 @@ $.widget("ui.sortable", $.ui.mouse, {
_mouseStart: function(event, overrideHandle, noActivation) {
- var o = this.options, self = this;
+ var o = this.options;
this.currentContainer = this;
//We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
@@ -154,11 +154,6 @@ $.widget("ui.sortable", $.ui.mouse, {
left: this.offset.left - this.margins.left
};
- // Only after we got the offset, we can change the helper's position to absolute
- // TODO: Still need to figure out a way to make relative sorting possible
- this.helper.css("position", "absolute");
- this.cssPosition = this.helper.css("position");
-
$.extend(this.offset, {
click: { //Where the click happened, relative to the element
left: event.pageX - this.offset.left,
@@ -168,6 +163,11 @@ $.widget("ui.sortable", $.ui.mouse, {
relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
});
+ // Only after we got the offset, we can change the helper's position to absolute
+ // TODO: Still need to figure out a way to make relative sorting possible
+ this.helper.css("position", "absolute");
+ this.cssPosition = this.helper.css("position");
+
//Generate the original position
this.originalPosition = this._generatePosition(event);
this.originalPageX = event.pageX;
@@ -220,7 +220,7 @@ $.widget("ui.sortable", $.ui.mouse, {
//Post 'activate' events to possible containers
if(!noActivation) {
- for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i]._trigger("activate", event, self._uiHash(this)); }
+ for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i]._trigger("activate", event, this._uiHash(this)); }
}
//Prepare possible droppables
@@ -338,16 +338,16 @@ $.widget("ui.sortable", $.ui.mouse, {
$.ui.ddmanager.drop(this, event);
if(this.options.revert) {
- var self = this;
- var cur = self.placeholder.offset();
+ var that = this;
+ var cur = this.placeholder.offset();
- self.reverting = true;
+ this.reverting = true;
$(this.helper).animate({
- left: cur.left - this.offset.parent.left - self.margins.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft),
- top: cur.top - this.offset.parent.top - self.margins.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop)
+ left: cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft),
+ top: cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop)
}, parseInt(this.options.revert, 10) || 500, function() {
- self._clear(event);
+ that._clear(event);
});
} else {
this._clear(event, noPropagation);
@@ -359,8 +359,6 @@ $.widget("ui.sortable", $.ui.mouse, {
cancel: function() {
- var self = this;
-
if(this.dragging) {
this._mouseUp({ target: null });
@@ -372,9 +370,9 @@ $.widget("ui.sortable", $.ui.mouse, {
//Post deactivating events to containers
for (var i = this.containers.length - 1; i >= 0; i--){
- this.containers[i]._trigger("deactivate", null, self._uiHash(this));
+ this.containers[i]._trigger("deactivate", null, this._uiHash(this));
if(this.containers[i].containerCache.over) {
- this.containers[i]._trigger("out", null, self._uiHash(this));
+ this.containers[i]._trigger("out", null, this._uiHash(this));
this.containers[i].containerCache.over = 0;
}
}
@@ -467,8 +465,8 @@ $.widget("ui.sortable", $.ui.mouse, {
_intersectsWithPointer: function(item) {
- var isOverElementHeight = $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
- isOverElementWidth = $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
+ var isOverElementHeight = (this.options.axis === 'x') || $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
+ isOverElementWidth = (this.options.axis === 'y') || $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
isOverElement = isOverElementHeight && isOverElementWidth,
verticalDirection = this._getDragVerticalDirection(),
horizontalDirection = this._getDragHorizontalDirection();
@@ -519,10 +517,9 @@ $.widget("ui.sortable", $.ui.mouse, {
? [options.connectWith]
: options.connectWith;
},
-
+
_getItemsAsjQuery: function(connected) {
- var self = this;
var items = [];
var queries = [];
var connectWith = this._connectWith();
@@ -571,7 +568,6 @@ $.widget("ui.sortable", $.ui.mouse, {
this.items = [];
this.containers = [this];
var items = this.items;
- var self = this;
var queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]];
var connectWith = this._connectWith();
@@ -650,17 +646,17 @@ $.widget("ui.sortable", $.ui.mouse, {
},
_createPlaceholder: function(that) {
-
- var self = that || this, o = self.options;
+ that = that || this;
+ var o = that.options;
if(!o.placeholder || o.placeholder.constructor == String) {
var className = o.placeholder;
o.placeholder = {
element: function() {
- var el = $(document.createElement(self.currentItem[0].nodeName))
- .addClass(className || self.currentItem[0].className+" ui-sortable-placeholder")
- .removeClass("ui-sortable-helper").html("&nbsp;")[0];
+ var el = $(document.createElement(that.currentItem[0].nodeName))
+ .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
+ .removeClass("ui-sortable-helper")[0];
if(!className)
el.style.visibility = "hidden";
@@ -674,46 +670,46 @@ $.widget("ui.sortable", $.ui.mouse, {
if(className && !o.forcePlaceholderSize) return;
//If the element doesn't have a actual height by itself (without styles coming from a stylesheet), it receives the inline height from the dragged item
- if(!p.height()) { p.height(self.currentItem.innerHeight() - parseInt(self.currentItem.css('paddingTop')||0, 10) - parseInt(self.currentItem.css('paddingBottom')||0, 10)); };
- if(!p.width()) { p.width(self.currentItem.innerWidth() - parseInt(self.currentItem.css('paddingLeft')||0, 10) - parseInt(self.currentItem.css('paddingRight')||0, 10)); };
+ if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css('paddingTop')||0, 10) - parseInt(that.currentItem.css('paddingBottom')||0, 10)); };
+ if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css('paddingLeft')||0, 10) - parseInt(that.currentItem.css('paddingRight')||0, 10)); };
}
};
}
//Create the placeholder
- self.placeholder = $(o.placeholder.element.call(self.element, self.currentItem));
+ that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
//Append it after the actual current item
- self.currentItem.after(self.placeholder);
+ that.currentItem.after(that.placeholder);
//Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
- o.placeholder.update(self, self.placeholder);
+ o.placeholder.update(that, that.placeholder);
},
_contactContainers: function(event) {
-
- // get innermost container that intersects with item
- var innermostContainer = null, innermostIndex = null;
-
-
+
+ // get innermost container that intersects with item
+ var innermostContainer = null, innermostIndex = null;
+
+
for (var i = this.containers.length - 1; i >= 0; i--){
- // never consider a container that's located within the item itself
+ // never consider a container that's located within the item itself
if($.contains(this.currentItem[0], this.containers[i].element[0]))
continue;
if(this._intersectsWith(this.containers[i].containerCache)) {
- // if we've already found a container and it's more "inner" than this, then continue
+ // if we've already found a container and it's more "inner" than this, then continue
if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0]))
continue;
- innermostContainer = this.containers[i];
+ innermostContainer = this.containers[i];
innermostIndex = i;
-
+
} else {
- // container doesn't intersect. trigger "out" event if necessary
+ // container doesn't intersect. trigger "out" event if necessary
if(this.containers[i].containerCache.over) {
this.containers[i]._trigger("out", event, this._uiHash(this));
this.containers[i].containerCache.over = 0;
@@ -721,42 +717,42 @@ $.widget("ui.sortable", $.ui.mouse, {
}
}
-
- // if no intersecting containers found, return
- if(!innermostContainer) return;
+
+ // if no intersecting containers found, return
+ if(!innermostContainer) return;
// move the item into the container if it's not there already
if(this.containers.length === 1) {
this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
this.containers[innermostIndex].containerCache.over = 1;
- } else if(this.currentContainer != this.containers[innermostIndex]) {
-
- //When entering a new container, we will find the item with the least distance and append our item near it
- var dist = 10000; var itemWithLeastDistance = null; var base = this.positionAbs[this.containers[innermostIndex].floating ? 'left' : 'top'];
- for (var j = this.items.length - 1; j >= 0; j--) {
- if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) continue;
- var cur = this.items[j][this.containers[innermostIndex].floating ? 'left' : 'top'];
- if(Math.abs(cur - base) < dist) {
- dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
- }
- }
-
- if(!itemWithLeastDistance && !this.options.dropOnEmpty) //Check if dropOnEmpty is enabled
- return;
-
- this.currentContainer = this.containers[innermostIndex];
- itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
- this._trigger("change", event, this._uiHash());
- this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
-
- //Update the placeholder
- this.options.placeholder.update(this.currentContainer, this.placeholder);
-
- this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
+ } else if(this.currentContainer != this.containers[innermostIndex]) {
+
+ //When entering a new container, we will find the item with the least distance and append our item near it
+ var dist = 10000; var itemWithLeastDistance = null; var base = this.positionAbs[this.containers[innermostIndex].floating ? 'left' : 'top'];
+ for (var j = this.items.length - 1; j >= 0; j--) {
+ if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) continue;
+ var cur = this.items[j][this.containers[innermostIndex].floating ? 'left' : 'top'];
+ if(Math.abs(cur - base) < dist) {
+ dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
+ }
+ }
+
+ if(!itemWithLeastDistance && !this.options.dropOnEmpty) //Check if dropOnEmpty is enabled
+ return;
+
+ this.currentContainer = this.containers[innermostIndex];
+ itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
+ this._trigger("change", event, this._uiHash());
+ this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
+
+ //Update the placeholder
+ this.options.placeholder.update(this.currentContainer, this.placeholder);
+
+ this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
this.containers[innermostIndex].containerCache.over = 1;
- }
-
-
+ }
+
+
},
_createHelper: function(event) {
@@ -970,11 +966,11 @@ $.widget("ui.sortable", $.ui.mouse, {
// 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
// 4. this lets only the last addition to the timeout stack through
this.counter = this.counter ? ++this.counter : 1;
- var self = this, counter = this.counter;
+ var counter = this.counter;
- window.setTimeout(function() {
- if(counter == self.counter) self.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
- },0);
+ this._delay(function() {
+ if(counter == this.counter) this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
+ });
},
@@ -983,7 +979,7 @@ $.widget("ui.sortable", $.ui.mouse, {
this.reverting = false;
// We delay all events that have to be triggered to after the point where the placeholder has been removed and
// everything else normalized again
- var delayedTriggers = [], self = this;
+ var delayedTriggers = [];
// We first have to update the dom position of the actual currentItem
// Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
@@ -1058,16 +1054,16 @@ $.widget("ui.sortable", $.ui.mouse, {
}
},
- _uiHash: function(inst) {
- var self = inst || this;
+ _uiHash: function(_inst) {
+ var inst = _inst || this;
return {
- helper: self.helper,
- placeholder: self.placeholder || $([]),
- position: self.position,
- originalPosition: self.originalPosition,
- offset: self.positionAbs,
- item: self.currentItem,
- sender: inst ? inst.element : null
+ helper: inst.helper,
+ placeholder: inst.placeholder || $([]),
+ position: inst.position,
+ originalPosition: inst.originalPosition,
+ offset: inst.positionAbs,
+ item: inst.currentItem,
+ sender: _inst ? _inst.element : null
};
}
diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js
index bd55a09ea..1e4204a0c 100644
--- a/ui/jquery.ui.spinner.js
+++ b/ui/jquery.ui.spinner.js
@@ -93,6 +93,11 @@ $.widget( "ui.spinner", {
this.previous = this.element.val();
},
blur: function( event ) {
+ if ( this.cancelBlur ) {
+ delete this.cancelBlur;
+ return;
+ }
+
this._refresh();
this.uiSpinner.removeClass( "ui-state-active" );
if ( this.previous !== this.element.val() ) {
@@ -117,11 +122,42 @@ $.widget( "ui.spinner", {
event.preventDefault();
},
"mousedown .ui-spinner-button": function( event ) {
+ var previous;
+
+ // We never want the buttons to have focus; whenever the user is
+ // interacting with the spinner, the focus should be on the input.
+ // If the input is focused then this.previous is properly set from
+ // when the input first received focus. If the input is not focused
+ // then we need to set this.previous based on the value before spinning.
+ previous = this.element[0] === this.document[0].activeElement ?
+ this.previous : this.element.val();
+ function checkFocus() {
+ var isActive = this.element[0] === this.document[0].activeElement;
+ if ( !isActive ) {
+ this.element.focus();
+ this.previous = previous;
+ // support: IE
+ // IE sets focus asynchronously, so we need to check if focus
+ // moved off of the input because the user clicked on the button.
+ this._delay(function() {
+ this.previous = previous;
+ });
+ }
+ }
+
// ensure focus is on (or stays on) the text field
event.preventDefault();
- if ( this.document[0].activeElement !== this.element[ 0 ] ) {
- this.element.focus();
- }
+ checkFocus.call( this );
+
+ // support: IE
+ // IE doesn't prevent moving focus even with event.preventDefault()
+ // so we set a flag to know when we should ignore the blur event
+ // and check (again) if focus moved off of the input.
+ this.cancelBlur = true;
+ this._delay(function() {
+ delete this.cancelBlur;
+ checkFocus.call( this );
+ });
if ( this._start( event ) === false ) {
return;
diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js
index 68c182c31..026c50993 100644
--- a/ui/jquery.ui.tabs.js
+++ b/ui/jquery.ui.tabs.js
@@ -95,8 +95,8 @@ $.widget( "ui.tabs", {
// into account and update option properly.
if ( $.isArray( options.disabled ) ) {
options.disabled = $.unique( options.disabled.concat(
- $.map( this.lis.filter( ".ui-state-disabled" ), function( n, i ) {
- return that.lis.index( n );
+ $.map( this.lis.filter( ".ui-state-disabled" ), function( li ) {
+ return that.lis.index( li );
})
) ).sort();
}
@@ -162,13 +162,11 @@ $.widget( "ui.tabs", {
},
_sanitizeSelector: function( hash ) {
- // we need this because an id may contain a ":"
- return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@[\]^`{|}~]/g, "\\$&" ) : "";
+ return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
},
refresh: function() {
var next,
- self = this,
options = this.options,
lis = this.list.children( ":has(a[href])" );
@@ -216,14 +214,14 @@ $.widget( "ui.tabs", {
},
_processTabs: function() {
- var self = this;
+ var that = this;
this.list = this._getList();
- this.lis = $( " > li:has(a[href])", this.list );
+ this.lis = this.list.find( "> li:has(a[href])" );
this.anchors = this.lis.map(function() {
return $( "a", this )[ 0 ];
});
- this.panels = $( [] );
+ this.panels = $();
this.anchors.each(function( i, a ) {
var selector, panel, id;
@@ -231,20 +229,20 @@ $.widget( "ui.tabs", {
// inline tab
if ( isLocal( a ) ) {
selector = a.hash;
- panel = self.element.find( self._sanitizeSelector( selector ) );
+ panel = that.element.find( that._sanitizeSelector( selector ) );
// remote tab
} else {
- id = self._tabId( a );
+ id = that._tabId( a );
selector = "#" + id;
- panel = self.element.find( selector );
+ panel = that.element.find( selector );
if ( !panel.length ) {
- panel = self._createPanel( id );
- panel.insertAfter( self.panels[ i - 1 ] || self.list );
+ panel = that._createPanel( id );
+ panel.insertAfter( that.panels[ i - 1 ] || that.list );
}
}
if ( panel.length) {
- self.panels = self.panels.add( panel );
+ that.panels = that.panels.add( panel );
}
$( a ).attr( "aria-controls", selector.substring( 1 ) );
});
@@ -256,10 +254,10 @@ $.widget( "ui.tabs", {
},
_createPanel: function( id ) {
- return $( "<div></div>" )
- .attr( "id", id )
- .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
- .data( "ui-tabs-destroy", true );
+ return $( "<div>" )
+ .attr( "id", id )
+ .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
+ .data( "ui-tabs-destroy", true );
},
_setupDisabled: function( disabled ) {
@@ -273,7 +271,8 @@ $.widget( "ui.tabs", {
// disable tabs
for ( var i = 0, li; ( li = this.lis[ i ] ); i++ ) {
- $( li ).toggleClass( "ui-state-disabled", ( disabled === true || $.inArray( i, disabled ) !== -1 ) );
+ $( li ).toggleClass( "ui-state-disabled",
+ ( disabled === true || $.inArray( i, disabled ) !== -1 ) );
}
this.options.disabled = disabled;
@@ -291,22 +290,17 @@ $.widget( "ui.tabs", {
}
},
- // TODO: remove once jQuery core properly removes filters - see #4621
- _resetStyle: function ( $el, fx ) {
- if ( !$.support.opacity && fx.opacity ) {
- $el[ 0 ].style.removeAttribute( "filter" );
- }
- },
-
_setupEvents: function( event ) {
// attach tab event handler, unbind to avoid duplicates from former tabifying...
this.anchors.unbind( ".tabs" );
+ // TODO: use event delegation via _bind()
if ( event ) {
this.anchors.bind( event.split( " " ).join( ".tabs " ) + ".tabs",
$.proxy( this, "_eventHandler" ) );
}
+ // TODO: use event delegation via _bind()
// disable click in any case
this.anchors.bind( "click.tabs", function( event ){
event.preventDefault();
@@ -353,14 +347,12 @@ $.widget( "ui.tabs", {
}
if ( !toHide.length && !toShow.length ) {
- throw "jQuery UI Tabs: Mismatching fragment identifier.";
+ jQuery.error( "jQuery UI Tabs: Mismatching fragment identifier." );
}
if ( toShow.length ) {
-
// TODO make passing in node possible
that.load( that.anchors.index( clicked ), event );
-
clicked[ 0 ].blur();
}
that._toggle( event, eventData );
@@ -369,7 +361,6 @@ $.widget( "ui.tabs", {
// handles show/hide for selecting tabs
_toggle: function( event, eventData ) {
var that = this,
- options = that.options,
toShow = eventData.newPanel,
toHide = eventData.oldPanel;
@@ -386,7 +377,6 @@ $.widget( "ui.tabs", {
if ( toShow.length && that.showFx ) {
toShow
.animate( that.showFx, that.showFx.duration || "normal", function() {
- that._resetStyle( $( this ), that.showFx );
complete();
});
} else {
@@ -399,7 +389,6 @@ $.widget( "ui.tabs", {
if ( toHide.length && that.hideFx ) {
toHide.animate( that.hideFx, that.hideFx.duration || "normal", function() {
eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
- that._resetStyle( $( this ), that.hideFx );
show();
});
} else {
@@ -429,7 +418,7 @@ $.widget( "ui.tabs", {
_findActive: function( selector ) {
return typeof selector === "number" ? this.anchors.eq( selector ) :
- typeof selector === "string" ? this.anchors.filter( "[href$='" + selector + "']" ) : $();
+ typeof selector === "string" ? this.anchors.filter( "[href$='" + selector + "']" ) : $();
},
_getIndex: function( index ) {
@@ -443,8 +432,6 @@ $.widget( "ui.tabs", {
},
_destroy: function() {
- var o = this.options;
-
if ( this.xhr ) {
this.xhr.abort();
}
@@ -525,10 +512,9 @@ $.widget( "ui.tabs", {
load: function( index, event ) {
index = this._getIndex( index );
- var self = this,
- options = this.options,
+ var that = this,
anchor = this.anchors.eq( index ),
- panel = self._getPanelForTab( anchor ),
+ panel = that._getPanelForTab( anchor ),
eventData = {
tab: anchor,
panel: panel
@@ -542,7 +528,7 @@ $.widget( "ui.tabs", {
this.xhr = $.ajax({
url: anchor.attr( "href" ),
beforeSend: function( jqXHR, settings ) {
- return self._trigger( "beforeLoad", event,
+ return that._trigger( "beforeLoad", event,
$.extend( { jqXHR : jqXHR, ajaxSettings: settings }, eventData ) );
}
});
@@ -556,7 +542,7 @@ $.widget( "ui.tabs", {
// remove when core #10467 is fixed
setTimeout(function() {
panel.html( response );
- self._trigger( "load", event, eventData );
+ that._trigger( "load", event, eventData );
}, 1 );
})
.complete(function( jqXHR, status ) {
@@ -564,19 +550,17 @@ $.widget( "ui.tabs", {
// remove when core #10467 is fixed
setTimeout(function() {
if ( status === "abort" ) {
- self.panels.stop( false, true );
+ that.panels.stop( false, true );
}
- self.lis.eq( index ).removeClass( "ui-tabs-loading" );
+ that.lis.eq( index ).removeClass( "ui-tabs-loading" );
- if ( jqXHR === self.xhr ) {
- delete self.xhr;
+ if ( jqXHR === that.xhr ) {
+ delete that.xhr;
}
}, 1 );
});
}
-
- return this;
},
_getPanelForTab: function( tab ) {
@@ -614,7 +598,7 @@ if ( $.uiBackCompat !== false ) {
_create: function() {
this._super();
- var self = this;
+ var that = this;
this.element.bind( "tabsbeforeload.tabs", function( event, ui ) {
// tab is already cached
@@ -623,21 +607,21 @@ if ( $.uiBackCompat !== false ) {
return;
}
- $.extend( ui.ajaxSettings, self.options.ajaxOptions, {
+ $.extend( ui.ajaxSettings, that.options.ajaxOptions, {
error: function( xhr, s, e ) {
try {
// Passing index avoid a race condition when this method is
// called after the user has selected another tab.
// Pass the anchor that initiated this request allows
// loadError to manipulate the tab content panel via $(a.hash)
- self.options.ajaxOptions.error( xhr, s, ui.tab.closest( "li" ).index(), ui.tab[ 0 ] );
+ that.options.ajaxOptions.error( xhr, s, ui.tab.closest( "li" ).index(), ui.tab[ 0 ] );
}
catch ( e ) {}
}
});
ui.jqXHR.success(function() {
- if ( self.options.cache ) {
+ if ( that.options.cache ) {
$.data( ui.tab[ 0 ], "cache.tabs", true );
}
});
@@ -843,7 +827,7 @@ if ( $.uiBackCompat !== false ) {
_tabId: function( a ) {
return $( a ).attr( "aria-controls" ) ||
- a.title && a.title.replace( /\s/g, "_" ).replace( /[^\w\u00c0-\uFFFF-]/g, "" ) ||
+ a.title && a.title.replace( /\s/g, "_" ).replace( /[^\w\u00c0-\uFFFF\-]/g, "" ) ||
this.options.idPrefix + getNextTabId();
}
});
diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js
index 97895a6a8..47a377bfd 100644
--- a/ui/jquery.ui.tooltip.js
+++ b/ui/jquery.ui.tooltip.js
@@ -5,8 +5,6 @@
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
- * http://docs.jquery.com/UI/Tooltip
- *
* Depends:
* jquery.ui.core.js
* jquery.ui.widget.js
@@ -130,11 +128,15 @@ $.widget( "ui.tooltip", {
// we have to check first to avoid defining a title if none exists
// (we don't want to cause an element to start matching [title])
- // We don't use removeAttr as that causes the native tooltip to show
- // up in IE (9 and below, didn't yet test 10). Happens only when removing
- // inside the mouseover handler.
+ // We use removeAttr only for key events, to allow IE to export the correct
+ // accessible attributes. For mouse events, set to empty string to avoid
+ // native tooltip showing up (happens only when removing inside mouseover).
if ( target.is( "[title]" ) ) {
- target.attr( "title", "" );
+ if ( event && event.type === "mouseover" ) {
+ target.attr( "title", "" );
+ } else {
+ target.removeAttr( "title" );
+ }
}
// ajaxy tooltip can update an existing one
@@ -181,7 +183,10 @@ $.widget( "ui.tooltip", {
// don't close if the element has focus
// this prevents the tooltip from closing if you hover while focused
- if ( !force && this.document[0].activeElement === target[0] ) {
+ // we have to check the event type because tabbing out of the document
+ // may leave the element as the activeElement
+ if ( !force && event && event.type !== "focusout" &&
+ this.document[0].activeElement === target[0] ) {
return;
}
diff --git a/version.txt b/version.txt
deleted file mode 100644
index c70a1dfdc..000000000
--- a/version.txt
+++ /dev/null
@@ -1 +0,0 @@
-1.9.0pre \ No newline at end of file