aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Nagel <info@felixnagel.com>2015-10-08 00:38:07 +0200
committerFelix Nagel <info@felixnagel.com>2015-10-08 00:40:37 +0200
commit7e8b7234b214f9ee363f4f85ad4a24c4a269baba (patch)
tree89b64afd5c705bacf60cddbe7336fa822397fd6d
parent66828b1a83675753c9f6f603236f897f62a215e6 (diff)
parent7f3bb4dc4f78178f91642efa48bafd383105dab3 (diff)
downloadjquery-ui-7e8b7234b214f9ee363f4f85ad4a24c4a269baba.tar.gz
jquery-ui-7e8b7234b214f9ee363f4f85ad4a24c4a269baba.zip
Merge branch 'master' into datepicker
-rw-r--r--.jscsrc10
-rw-r--r--Gruntfile.js53
-rw-r--r--README.md15
-rw-r--r--build/release.js1
-rw-r--r--demos/accordion/collapsible.html1
-rw-r--r--demos/accordion/custom-icons.html1
-rw-r--r--demos/accordion/default.html1
-rw-r--r--demos/accordion/fillspace.html1
-rw-r--r--demos/accordion/no-auto-height.html1
-rw-r--r--demos/accordion/sortable.html1
-rw-r--r--demos/autocomplete/categories.html1
-rw-r--r--demos/autocomplete/combobox.html1
-rw-r--r--demos/autocomplete/custom-data.html1
-rw-r--r--demos/autocomplete/default.html1
-rw-r--r--demos/autocomplete/folding.html1
-rw-r--r--demos/autocomplete/maxheight.html1
-rw-r--r--demos/autocomplete/multiple-remote.html1
-rw-r--r--demos/autocomplete/multiple.html1
-rw-r--r--demos/autocomplete/remote-jsonp.html1
-rw-r--r--demos/autocomplete/remote-with-cache.html1
-rw-r--r--demos/autocomplete/remote.html1
-rw-r--r--demos/autocomplete/xml.html1
-rw-r--r--demos/bootstrap.js22
-rw-r--r--demos/button/checkbox.html1
-rw-r--r--demos/button/default.html1
-rw-r--r--demos/button/icons.html1
-rw-r--r--demos/button/radio.html1
-rw-r--r--demos/button/splitbutton.html1
-rw-r--r--demos/button/toolbar.html1
-rw-r--r--demos/calendar/buttonbar.html1
-rw-r--r--demos/calendar/default.html1
-rw-r--r--demos/calendar/dropdown-month-year.html1
-rw-r--r--demos/calendar/localization.html2
-rw-r--r--demos/calendar/min-max.html7
-rw-r--r--demos/calendar/multiple-months.html1
-rw-r--r--demos/calendar/other-months.html1
-rw-r--r--demos/calendar/show-week.html1
-rw-r--r--demos/datepicker/animation.html1
-rw-r--r--demos/datepicker/date-formats.html1
-rw-r--r--demos/datepicker/default.html1
-rw-r--r--demos/datepicker/icon-trigger.html1
-rw-r--r--demos/datepicker/localization.html1
-rw-r--r--demos/dialog/animated.html1
-rw-r--r--demos/dialog/default.html1
-rw-r--r--demos/dialog/modal-confirmation.html1
-rw-r--r--demos/dialog/modal-form.html1
-rw-r--r--demos/dialog/modal-message.html1
-rw-r--r--demos/draggable/constrain-movement.html1
-rw-r--r--demos/draggable/cursor-style.html1
-rw-r--r--demos/draggable/default.html1
-rw-r--r--demos/draggable/events.html1
-rw-r--r--demos/draggable/handle.html3
-rw-r--r--demos/draggable/revert.html1
-rw-r--r--demos/draggable/scroll.html1
-rw-r--r--demos/draggable/snap-to.html1
-rw-r--r--demos/draggable/sortable.html3
-rw-r--r--demos/draggable/visual-feedback.html1
-rw-r--r--demos/droppable/accepted-elements.html1
-rw-r--r--demos/droppable/default.html1
-rw-r--r--demos/droppable/photo-manager.html17
-rw-r--r--demos/droppable/propagation.html1
-rw-r--r--demos/droppable/revert.html1
-rw-r--r--demos/droppable/visual-feedback.html1
-rw-r--r--demos/effect/addClass.html1
-rw-r--r--demos/effect/animate.html1
-rw-r--r--demos/effect/default.html9
-rw-r--r--demos/effect/easing.html11
-rw-r--r--demos/effect/hide.html9
-rw-r--r--demos/effect/removeClass.html1
-rw-r--r--demos/effect/show.html7
-rw-r--r--demos/effect/switchClass.html1
-rw-r--r--demos/effect/toggle.html7
-rw-r--r--demos/effect/toggleClass.html1
-rw-r--r--demos/menu/categories.html3
-rw-r--r--demos/menu/default.html1
-rw-r--r--demos/menu/icons.html1
-rw-r--r--demos/position/cycler.html1
-rw-r--r--demos/position/default.html1
-rw-r--r--demos/progressbar/default.html1
-rw-r--r--demos/progressbar/download.html1
-rw-r--r--demos/progressbar/indeterminate.html1
-rw-r--r--demos/progressbar/label.html1
-rw-r--r--demos/resizable/animate.html1
-rw-r--r--demos/resizable/aspect-ratio.html1
-rw-r--r--demos/resizable/constrain-area.html1
-rw-r--r--demos/resizable/default.html1
-rw-r--r--demos/resizable/helper.html1
-rw-r--r--demos/resizable/max-min.html1
-rw-r--r--demos/resizable/snap-to-grid.html1
-rw-r--r--demos/resizable/synchronous-resize.html1
-rw-r--r--demos/resizable/textarea.html1
-rw-r--r--demos/resizable/visual-feedback.html1
-rw-r--r--demos/selectable/default.html1
-rw-r--r--demos/selectable/display-grid.html1
-rw-r--r--demos/selectable/serialize.html1
-rw-r--r--demos/slider/colorpicker.html1
-rw-r--r--demos/slider/default.html3
-rw-r--r--demos/slider/hotelrooms.html1
-rw-r--r--demos/slider/multiple-vertical.html1
-rw-r--r--demos/slider/range-vertical.html1
-rw-r--r--demos/slider/range.html1
-rw-r--r--demos/slider/rangemax.html1
-rw-r--r--demos/slider/rangemin.html1
-rw-r--r--demos/slider/slider-vertical.html1
-rw-r--r--demos/slider/steps.html1
-rw-r--r--demos/sortable/connect-lists.html3
-rw-r--r--demos/sortable/default.html3
-rw-r--r--demos/sortable/display-grid.html3
-rw-r--r--demos/sortable/empty-lists.html3
-rw-r--r--demos/sortable/items.html3
-rw-r--r--demos/sortable/placeholder.html3
-rw-r--r--demos/sortable/portlets.html1
-rw-r--r--demos/spinner/currency.html1
-rw-r--r--demos/spinner/decimal.html1
-rw-r--r--demos/spinner/default.html1
-rw-r--r--demos/spinner/latlong.html1
-rw-r--r--demos/spinner/overflow.html1
-rw-r--r--demos/spinner/time.html1
-rw-r--r--demos/tabs/ajax.html1
-rw-r--r--demos/tabs/collapsible.html1
-rw-r--r--demos/tabs/default.html1
-rw-r--r--demos/tabs/manipulation.html11
-rw-r--r--demos/tabs/mouseover.html1
-rw-r--r--demos/tabs/sortable.html1
-rw-r--r--demos/tabs/vertical.html1
-rw-r--r--demos/tooltip/custom-animation.html1
-rw-r--r--demos/tooltip/custom-content.html1
-rw-r--r--demos/tooltip/custom-style.html1
-rw-r--r--demos/tooltip/default.html1
-rw-r--r--demos/tooltip/forms.html4
-rw-r--r--demos/tooltip/tracking.html1
-rw-r--r--demos/tooltip/video-player.html1
-rw-r--r--demos/widget/default.html31
-rw-r--r--package.json3
-rw-r--r--tests/index.js4
-rw-r--r--tests/lib/bootstrap.js17
-rw-r--r--tests/lib/common.js28
-rw-r--r--tests/lib/css.js2
-rw-r--r--tests/lib/helper.js8
-rw-r--r--tests/lib/qunit-assert-domequal.js8
-rw-r--r--tests/lib/qunit.js8
-rw-r--r--tests/unit/accordion/common.js4
-rw-r--r--tests/unit/accordion/core.js22
-rw-r--r--tests/unit/accordion/events.js46
-rw-r--r--tests/unit/accordion/helper.js10
-rw-r--r--tests/unit/accordion/methods.js61
-rw-r--r--tests/unit/accordion/options.js222
-rw-r--r--tests/unit/autocomplete/common.js4
-rw-r--r--tests/unit/autocomplete/core.js164
-rw-r--r--tests/unit/autocomplete/events.js73
-rw-r--r--tests/unit/autocomplete/methods.js12
-rw-r--r--tests/unit/autocomplete/options.js144
-rw-r--r--tests/unit/button/common.js4
-rw-r--r--tests/unit/button/core.js163
-rw-r--r--tests/unit/button/events.js22
-rw-r--r--tests/unit/button/methods.js40
-rw-r--r--tests/unit/button/options.js120
-rw-r--r--tests/unit/core/core.html15
-rw-r--r--tests/unit/core/core.js34
-rw-r--r--tests/unit/core/selector.js51
-rw-r--r--tests/unit/dialog/common-deprecated.js4
-rw-r--r--tests/unit/dialog/common.js4
-rw-r--r--tests/unit/dialog/core.js110
-rw-r--r--tests/unit/dialog/deprecated.js6
-rw-r--r--tests/unit/dialog/events.js500
-rw-r--r--tests/unit/dialog/helper.js30
-rw-r--r--tests/unit/dialog/methods.js230
-rw-r--r--tests/unit/dialog/options.js498
-rw-r--r--tests/unit/draggable/common.js4
-rw-r--r--tests/unit/draggable/core.js126
-rw-r--r--tests/unit/draggable/events.js46
-rw-r--r--tests/unit/draggable/helper.js32
-rw-r--r--tests/unit/draggable/methods.js40
-rw-r--r--tests/unit/draggable/options.js523
-rw-r--r--tests/unit/droppable/common-deprecated.js4
-rw-r--r--tests/unit/droppable/common.js4
-rw-r--r--tests/unit/droppable/core.js22
-rw-r--r--tests/unit/droppable/events.js6
-rw-r--r--tests/unit/droppable/helper.js6
-rw-r--r--tests/unit/droppable/methods.js80
-rw-r--r--tests/unit/droppable/options.js62
-rw-r--r--tests/unit/effects/core.js142
-rw-r--r--tests/unit/effects/scale.js10
-rw-r--r--tests/unit/form-reset-mixin/core.js8
-rw-r--r--tests/unit/menu/common.js4
-rw-r--r--tests/unit/menu/core.js16
-rw-r--r--tests/unit/menu/events.js166
-rw-r--r--tests/unit/menu/methods.js24
-rw-r--r--tests/unit/menu/options.js66
-rw-r--r--tests/unit/position/core.js282
-rw-r--r--tests/unit/progressbar/common.js2
-rw-r--r--tests/unit/progressbar/core.js8
-rw-r--r--tests/unit/progressbar/events.js18
-rw-r--r--tests/unit/progressbar/methods.js12
-rw-r--r--tests/unit/progressbar/options.js38
-rw-r--r--tests/unit/resizable/common.js4
-rw-r--r--tests/unit/resizable/core.js188
-rw-r--r--tests/unit/resizable/events.js100
-rw-r--r--tests/unit/resizable/helper.js5
-rw-r--r--tests/unit/resizable/methods.js4
-rw-r--r--tests/unit/resizable/options.js375
-rw-r--r--tests/unit/selectable/common.js4
-rw-r--r--tests/unit/selectable/events.js30
-rw-r--r--tests/unit/selectable/methods.js90
-rw-r--r--tests/unit/selectable/options.js54
-rw-r--r--tests/unit/selectmenu/common.js4
-rw-r--r--tests/unit/selectmenu/core.js74
-rw-r--r--tests/unit/selectmenu/events.js46
-rw-r--r--tests/unit/selectmenu/methods.js26
-rw-r--r--tests/unit/selectmenu/options.js28
-rw-r--r--tests/unit/slider/common.js4
-rw-r--r--tests/unit/slider/core.js82
-rw-r--r--tests/unit/slider/events.js78
-rw-r--r--tests/unit/slider/methods.js48
-rw-r--r--tests/unit/slider/options.js112
-rw-r--r--tests/unit/sortable/common.js4
-rw-r--r--tests/unit/sortable/core.js8
-rw-r--r--tests/unit/sortable/events.js281
-rw-r--r--tests/unit/sortable/helper.js2
-rw-r--r--tests/unit/sortable/methods.js108
-rw-r--r--tests/unit/sortable/options.js114
-rw-r--r--tests/unit/spinner/common-deprecated.js4
-rw-r--r--tests/unit/spinner/common.js4
-rw-r--r--tests/unit/spinner/core.js72
-rw-r--r--tests/unit/spinner/events.js42
-rw-r--r--tests/unit/spinner/methods.js52
-rw-r--r--tests/unit/spinner/options.js100
-rw-r--r--tests/unit/subsuite.js9
-rw-r--r--tests/unit/tabs/common.js4
-rw-r--r--tests/unit/tabs/core.js92
-rw-r--r--tests/unit/tabs/events.js89
-rw-r--r--tests/unit/tabs/helper.js17
-rw-r--r--tests/unit/tabs/methods.js94
-rw-r--r--tests/unit/tabs/options.js134
-rw-r--r--tests/unit/tooltip/common-deprecated.js4
-rw-r--r--tests/unit/tooltip/common.js4
-rw-r--r--tests/unit/tooltip/core.js62
-rw-r--r--tests/unit/tooltip/deprecated.js6
-rw-r--r--tests/unit/tooltip/events.js24
-rw-r--r--tests/unit/tooltip/methods.js29
-rw-r--r--tests/unit/tooltip/options.js102
-rw-r--r--tests/unit/widget/animation.js144
-rw-r--r--tests/unit/widget/classes.js16
-rw-r--r--tests/unit/widget/core.js459
-rw-r--r--tests/unit/widget/extend.js22
-rw-r--r--tests/visual/accordion/icons.html9
-rw-r--r--tests/visual/addClass/queue.html7
-rw-r--r--tests/visual/button/button.html9
-rw-r--r--tests/visual/button/performance.html9
-rw-r--r--tests/visual/compound/accordion_tabs.html10
-rw-r--r--tests/visual/compound/datepicker_dialog.html19
-rw-r--r--tests/visual/compound/dialog_widgets.html29
-rw-r--r--tests/visual/compound/draggable_accordion.html12
-rw-r--r--tests/visual/compound/draggable_accordion_accordion_tabs_draggable.html13
-rw-r--r--tests/visual/compound/draggable_resizable.html12
-rw-r--r--tests/visual/compound/sortable_accordion_sortable_tabs.html13
-rw-r--r--tests/visual/compound/tabs_selectmenu.html12
-rw-r--r--tests/visual/compound/tabs_tabs.html10
-rw-r--r--tests/visual/compound/tabs_tooltips.html11
-rw-r--r--tests/visual/dialog/animated.html17
-rw-r--r--tests/visual/dialog/complex-dialogs.html25
-rw-r--r--tests/visual/dialog/form.html17
-rw-r--r--tests/visual/dialog/performance.html14
-rw-r--r--tests/visual/dialog/stacking.html15
-rw-r--r--tests/visual/draggable/replaced.html10
-rw-r--r--tests/visual/effects/all.html22
-rw-r--r--tests/visual/effects/clip.html9
-rw-r--r--tests/visual/effects/effects.js35
-rw-r--r--tests/visual/effects/scale.html71
-rw-r--r--tests/visual/effects/shake.html23
-rw-r--r--tests/visual/index.html1
-rw-r--r--tests/visual/menu/menu.html24
-rw-r--r--tests/visual/position/position.html11
-rw-r--r--tests/visual/position/position_feedback.html128
-rw-r--r--tests/visual/selectmenu/selectmenu.html31
-rw-r--r--tests/visual/slider/range_slider.html39
-rw-r--r--tests/visual/tooltip/animations.html67
-rw-r--r--tests/visual/tooltip/tooltip.html21
-rw-r--r--themes/base/button.css2
-rw-r--r--ui/.jshintrc1
-rw-r--r--ui/data.js3
-rw-r--r--ui/effect.js363
-rw-r--r--ui/effects/effect-bounce.js13
-rw-r--r--ui/effects/effect-explode.js10
-rw-r--r--ui/focusable.js21
-rw-r--r--ui/jquery-1-7.js2
-rw-r--r--ui/position.js61
-rw-r--r--ui/widget.js212
-rw-r--r--ui/widgets/accordion.js54
-rw-r--r--ui/widgets/autocomplete.js34
-rw-r--r--ui/widgets/button.js86
-rw-r--r--ui/widgets/dialog.js34
-rw-r--r--ui/widgets/draggable.js407
-rw-r--r--ui/widgets/droppable.js53
-rw-r--r--ui/widgets/menu.js21
-rw-r--r--ui/widgets/mouse.js125
-rw-r--r--ui/widgets/progressbar.js15
-rw-r--r--ui/widgets/resizable.js582
-rw-r--r--ui/widgets/selectable.js178
-rw-r--r--ui/widgets/selectmenu.js52
-rw-r--r--ui/widgets/slider.js75
-rw-r--r--ui/widgets/sortable.js749
-rw-r--r--ui/widgets/spinner.js63
-rw-r--r--ui/widgets/tabs.js76
-rw-r--r--ui/widgets/tooltip.js42
305 files changed, 6248 insertions, 6074 deletions
diff --git a/.jscsrc b/.jscsrc
index de0d7420e..5d6dfd77e 100644
--- a/.jscsrc
+++ b/.jscsrc
@@ -1,8 +1,14 @@
{
"preset": "jquery",
- // disabled until `widget_slice` et al are addressed
- "requireCamelCaseOrUpperCaseIdentifiers": null,
+ // This is currently unenforcable see https://github.com/jscs-dev/node-jscs/issues/1686
+ "requireCapitalizedComments": null,
+
+ // Until we drop IE8 this prevents things like warning on float keyword
+ "es3": true,
+
+ // We want to output all errors
+ "maxErrors": 1000000,
// Ref https://github.com/jquery/contribute.jquery.org/issues/80#issuecomment-45253460
"maximumLineLength": null
diff --git a/Gruntfile.js b/Gruntfile.js
index 85dfb42be..86d921a83 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -55,19 +55,6 @@ var
},
component = grunt.option( "component" ) || "**",
- jscsBad = [
- "ui/button.js",
- "ui/datepicker.js",
- "ui/draggable.js",
- "ui/droppable.js",
- "ui/effect.js",
- "ui/mouse.js",
- "ui/resizable.js",
- "ui/selectable.js",
- "ui/slider.js",
- "ui/sortable.js"
- ],
-
htmllintBad = [
"demos/tabs/ajax/content*.html",
"demos/tooltip/ajax/content*.html",
@@ -153,50 +140,24 @@ grunt.initConfig({
}
},
- // Remove the requireSpacesInsideParentheses override once everything is fixed
jscs: {
- "ui-good": [ "ui/*.js" ].concat( jscsBad.map( function( file ) {
- return "!" + file;
- } ) ),
- "ui-bad": {
- options: {
- requireSpacesInsideParentheses: null
- },
- src: jscsBad
- },
- tests: {
- options: {
- requireSpacesInsideParentheses: null
- },
- src: "tests/unit/**/*.js"
- },
- grunt: {
+ all: {
options: {
- requireSpacesInsideParentheses: null
+ config: true
},
- src: [ "Gruntfile.js", "build/tasks/*.js" ]
- },
- demos: {
- options: {
-
- // While the style guide removed onevar upgrading jscs to allow it causes too many
- // errors right now
- disallowMultipleVarDecl: null
- },
- src: "demos/**/*.js"
+ files: {
+ src: [ "demos/**/*.js", "build/**/*.js", "tests/**/*.js", "ui/**/*.js" ]
+ }
}
},
uglify: minify,
htmllint: {
- good: [ "tests/**/*.html" ].concat( htmllintBad.map( function( file ) {
- return "!" + file;
- } ) ),
- demos: {
+ good: {
options: {
ignore: [
/The text content of element “script” was not in the required format: Expected space, tab, newline, or slash but found “.” instead/
] },
- src: [ "demos/**/*.html" ].concat( htmllintBad.map( function( file ) {
+ src: [ "demos/**/*.html", "tests/**/*.html" ].concat( htmllintBad.map( function( file ) {
return "!" + file;
} ) )
},
diff --git a/README.md b/README.md
index a09a065dd..fd04188ab 100644
--- a/README.md
+++ b/README.md
@@ -28,18 +28,3 @@ For more information, see the [contributing page](CONTRIBUTING.md).
Run the unit tests manually with appropriate browsers and any local web server. See our [environment setup](CONTRIBUTING.md#environment-minimum-required) and [information on running tests](CONTRIBUTING.md#running-the-tests).
You can also run the unit tests inside phantomjs by [setting up your environment](CONTRIBUTING.md#user-content-environment-recommended-setup).
-
-## Building jQuery UI
-
-jQuery UI uses the [Grunt](http://gruntjs.com/) build system.
-
-To build jQuery UI, [set up your environment](CONTRIBUTING.md#environment-minimum-required) and then run the following commands:
-
-```sh
-# Run the concat task to concatenate files
-grunt concat
-
-# There are many other tasks that can be run through Grunt.
-# For a list of all tasks:
-grunt --help
-```
diff --git a/build/release.js b/build/release.js
index ce1425bb0..48915b08d 100644
--- a/build/release.js
+++ b/build/release.js
@@ -55,6 +55,7 @@ function buildCDNPackage( callback ) {
}
Release.define( {
+ npmPublish: true,
issueTracker: "trac",
contributorReportId: 22,
changelogShell: function() {
diff --git a/demos/accordion/collapsible.html b/demos/accordion/collapsible.html
index 913e82aa5..8b1a24ccf 100644
--- a/demos/accordion/collapsible.html
+++ b/demos/accordion/collapsible.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Accordion - Collapse content</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/accordion/custom-icons.html b/demos/accordion/custom-icons.html
index 4828ffd45..f7a9862a0 100644
--- a/demos/accordion/custom-icons.html
+++ b/demos/accordion/custom-icons.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Accordion - Customize icons</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/accordion/default.html b/demos/accordion/default.html
index cbe8016b6..7ed676760 100644
--- a/demos/accordion/default.html
+++ b/demos/accordion/default.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Accordion - Default functionality</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/accordion/fillspace.html b/demos/accordion/fillspace.html
index b1d41777b..9bafeaac5 100644
--- a/demos/accordion/fillspace.html
+++ b/demos/accordion/fillspace.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Accordion - Fill space</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/accordion/no-auto-height.html b/demos/accordion/no-auto-height.html
index 48626ead0..b12598553 100644
--- a/demos/accordion/no-auto-height.html
+++ b/demos/accordion/no-auto-height.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Accordion - No auto height</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/accordion/sortable.html b/demos/accordion/sortable.html
index 6e66c2e9c..dfd06c511 100644
--- a/demos/accordion/sortable.html
+++ b/demos/accordion/sortable.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Accordion - Sortable</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/autocomplete/categories.html b/demos/autocomplete/categories.html
index d2a107b53..1046988a9 100644
--- a/demos/autocomplete/categories.html
+++ b/demos/autocomplete/categories.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Autocomplete - Categories</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/autocomplete/combobox.html b/demos/autocomplete/combobox.html
index 409e64d7c..403c48550 100644
--- a/demos/autocomplete/combobox.html
+++ b/demos/autocomplete/combobox.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Autocomplete - Combobox</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/autocomplete/custom-data.html b/demos/autocomplete/custom-data.html
index 06a777440..149d7cbc5 100644
--- a/demos/autocomplete/custom-data.html
+++ b/demos/autocomplete/custom-data.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Autocomplete - Custom data and display</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/autocomplete/default.html b/demos/autocomplete/default.html
index 49e575898..21fd8a268 100644
--- a/demos/autocomplete/default.html
+++ b/demos/autocomplete/default.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Autocomplete - Default functionality</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/autocomplete/folding.html b/demos/autocomplete/folding.html
index 98bc6bbb7..b5833e429 100644
--- a/demos/autocomplete/folding.html
+++ b/demos/autocomplete/folding.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Autocomplete - Accent folding</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/autocomplete/maxheight.html b/demos/autocomplete/maxheight.html
index 8f65169c1..9ebda7938 100644
--- a/demos/autocomplete/maxheight.html
+++ b/demos/autocomplete/maxheight.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Autocomplete - Scrollable results</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/autocomplete/multiple-remote.html b/demos/autocomplete/multiple-remote.html
index f263cf75c..e1babda4a 100644
--- a/demos/autocomplete/multiple-remote.html
+++ b/demos/autocomplete/multiple-remote.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Autocomplete - Multiple, remote</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/autocomplete/multiple.html b/demos/autocomplete/multiple.html
index 5ee4edb0a..829af15ce 100644
--- a/demos/autocomplete/multiple.html
+++ b/demos/autocomplete/multiple.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Autocomplete - Multiple values</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/autocomplete/remote-jsonp.html b/demos/autocomplete/remote-jsonp.html
index 3c2f4921f..d43dbbb75 100644
--- a/demos/autocomplete/remote-jsonp.html
+++ b/demos/autocomplete/remote-jsonp.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Autocomplete - Remote JSONP datasource</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/autocomplete/remote-with-cache.html b/demos/autocomplete/remote-with-cache.html
index 4ab2fdefb..c4dc42b65 100644
--- a/demos/autocomplete/remote-with-cache.html
+++ b/demos/autocomplete/remote-with-cache.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Autocomplete - Remote with caching</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/autocomplete/remote.html b/demos/autocomplete/remote.html
index 1993f8e6d..66c28e365 100644
--- a/demos/autocomplete/remote.html
+++ b/demos/autocomplete/remote.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Autocomplete - Remote datasource</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/autocomplete/xml.html b/demos/autocomplete/xml.html
index 5bdf4d3cc..952357531 100644
--- a/demos/autocomplete/xml.html
+++ b/demos/autocomplete/xml.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Autocomplete - XML data parsed once</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/bootstrap.js b/demos/bootstrap.js
index faffcbdd8..efac1b838 100644
--- a/demos/bootstrap.js
+++ b/demos/bootstrap.js
@@ -1,4 +1,4 @@
-/* globals window:true, document:true */
+/* globals window, document */
( function() {
// Find the script element
@@ -7,6 +7,7 @@ var script = scripts[ scripts.length - 1 ];
// Read the modules
var modules = script.getAttribute( "data-modules" );
+var composite = script.getAttribute( "data-composite" ) || false;
var pathParts = window.location.pathname.split( "/" );
var effectsAll = [
"effects/effect-blind",
@@ -22,7 +23,8 @@ var effectsAll = [
"effects/effect-scale",
"effects/effect-shake",
"effects/effect-size",
- "effects/effect-slide"
+ "effects/effect-slide",
+ "effects/effect-transfer"
];
var widgets = [
"accordion",
@@ -53,8 +55,13 @@ function getPath( module ) {
}
}
for ( var j = 0; j < effectsAll.length; j++ ) {
- if ( module !== "effect" && effectsAll[ j ].indexOf( module ) !== -1 ) {
- return "effects/" + module;
+ if ( module !== "effect" ) {
+ if ( effectsAll[ j ] === module ) {
+ return module;
+ }
+ if ( effectsAll[ j ].indexOf( module ) !== -1 ) {
+ return "effects/" + module;
+ }
}
}
return module;
@@ -70,7 +77,7 @@ function fixPaths( modules ) {
document.documentElement.className = "demo-loading";
require.config( {
- baseUrl: "../../ui",
+ baseUrl: window.location.pathname.indexOf( "demos/" ) !== -1 ? "../../ui" : "../../../ui",
paths: {
cldr: "../external/cldrjs/cldr",
globalize: "../external/globalize/globalize",
@@ -84,14 +91,15 @@ require.config( {
}
} );
-
// Replace effects all shortcut modules with all the effects modules
if ( modules && modules.indexOf( "effects-all" ) !== -1 ) {
modules = modules.replace( /effects-all/, effectsAll.join( " " ) );
}
modules = modules ? modules.replace( /^\s+|\s+$/g, "" ).split( /\s+/ ) : [];
-modules.push( pathParts[ pathParts.length - 2 ] );
+if ( !composite ) {
+ modules.push( pathParts[ pathParts.length - 2 ] );
+}
modules = fixPaths( modules );
require( modules, function() {
diff --git a/demos/button/checkbox.html b/demos/button/checkbox.html
index 6f2c5ec15..87abbf90f 100644
--- a/demos/button/checkbox.html
+++ b/demos/button/checkbox.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Button - Checkboxes</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<script src="../../external/jquery/jquery.js"></script>
diff --git a/demos/button/default.html b/demos/button/default.html
index 1bd4f9191..88c666e9a 100644
--- a/demos/button/default.html
+++ b/demos/button/default.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Button - Default functionality</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<script src="../../external/jquery/jquery.js"></script>
diff --git a/demos/button/icons.html b/demos/button/icons.html
index 76cb11478..0744218b2 100644
--- a/demos/button/icons.html
+++ b/demos/button/icons.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Button - Icons</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<script src="../../external/jquery/jquery.js"></script>
diff --git a/demos/button/radio.html b/demos/button/radio.html
index 5d1fcdce9..86c55a39a 100644
--- a/demos/button/radio.html
+++ b/demos/button/radio.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Button - Radios</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<script src="../../external/jquery/jquery.js"></script>
diff --git a/demos/button/splitbutton.html b/demos/button/splitbutton.html
index 333d54bd7..6b7562d68 100644
--- a/demos/button/splitbutton.html
+++ b/demos/button/splitbutton.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Button - Split button</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<script src="../../external/jquery/jquery.js"></script>
diff --git a/demos/button/toolbar.html b/demos/button/toolbar.html
index e13b4a1d1..f2c242f1f 100644
--- a/demos/button/toolbar.html
+++ b/demos/button/toolbar.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Button - Toolbar</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<script src="../../external/jquery/jquery.js"></script>
diff --git a/demos/calendar/buttonbar.html b/demos/calendar/buttonbar.html
index 9acd89bdd..28ee693cc 100644
--- a/demos/calendar/buttonbar.html
+++ b/demos/calendar/buttonbar.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Calendar - Display button bar</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/calendar/default.html b/demos/calendar/default.html
index 9be0f1988..1a2cfdf77 100644
--- a/demos/calendar/default.html
+++ b/demos/calendar/default.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Calendar - Default functionality</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/calendar/dropdown-month-year.html b/demos/calendar/dropdown-month-year.html
index 3aacaef47..92b7e24fb 100644
--- a/demos/calendar/dropdown-month-year.html
+++ b/demos/calendar/dropdown-month-year.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Calendar - Display month &amp; year menus</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/calendar/localization.html b/demos/calendar/localization.html
index df50ca2c9..dfd8b1f1e 100644
--- a/demos/calendar/localization.html
+++ b/demos/calendar/localization.html
@@ -2,9 +2,9 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Calendar - Localize calendar</title>
<link rel="stylesheet" href="../../themes/base/all.css">
- <link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
<script src="../../external/requirejs/require.js"></script>
<script src="../bootstrap.js" data-modules="external/localization">
diff --git a/demos/calendar/min-max.html b/demos/calendar/min-max.html
index d4b074a5e..b3036b873 100644
--- a/demos/calendar/min-max.html
+++ b/demos/calendar/min-max.html
@@ -11,9 +11,14 @@
dateMin = new Date( now.getFullYear(), now.getMonth(), now.getDate() + 1 ),
dateMax = new Date( now.getFullYear(), now.getMonth(), now.getDate() + 8 );
+ dateMin = new Date( 2008, 2 - 1, 29 );
+ dateMax = new Date( 2008, 12 - 1, 7 );
+
+
$( "#calendar" ).calendar({
min: dateMin,
- max: dateMax
+ max: dateMax,
+ value: new Date( 2008, 1 - 1, 4 )
});
</script>
</head>
diff --git a/demos/calendar/multiple-months.html b/demos/calendar/multiple-months.html
index 3bde416c0..f83da1f82 100644
--- a/demos/calendar/multiple-months.html
+++ b/demos/calendar/multiple-months.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Calendar - Display multiple months</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/calendar/other-months.html b/demos/calendar/other-months.html
index ac8df8d3a..2fb4dacf8 100644
--- a/demos/calendar/other-months.html
+++ b/demos/calendar/other-months.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Calendar - Dates in other months</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/calendar/show-week.html b/demos/calendar/show-week.html
index 96f3c7da2..e148b6570 100644
--- a/demos/calendar/show-week.html
+++ b/demos/calendar/show-week.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Calendar - Show week of the year</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/datepicker/animation.html b/demos/datepicker/animation.html
index 95d18e81b..d493fad53 100644
--- a/demos/datepicker/animation.html
+++ b/demos/datepicker/animation.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Datepicker - Animations</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/datepicker/date-formats.html b/demos/datepicker/date-formats.html
index 87f4b0b44..500c4a7f6 100644
--- a/demos/datepicker/date-formats.html
+++ b/demos/datepicker/date-formats.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Datepicker - Format date</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/datepicker/default.html b/demos/datepicker/default.html
index a0c1e7521..c5d668bda 100644
--- a/demos/datepicker/default.html
+++ b/demos/datepicker/default.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Datepicker - Default functionality</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/datepicker/icon-trigger.html b/demos/datepicker/icon-trigger.html
index 999d09e1d..ef3362a11 100644
--- a/demos/datepicker/icon-trigger.html
+++ b/demos/datepicker/icon-trigger.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Datepicker - Icon trigger</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/datepicker/localization.html b/demos/datepicker/localization.html
index 4bede0e6a..9537567f7 100644
--- a/demos/datepicker/localization.html
+++ b/demos/datepicker/localization.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Datepicker - Localize calendar</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/dialog/animated.html b/demos/dialog/animated.html
index 088ca0ea9..5804610c7 100644
--- a/demos/dialog/animated.html
+++ b/demos/dialog/animated.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Dialog - Animation</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/dialog/default.html b/demos/dialog/default.html
index e86281a47..65b22a51d 100644
--- a/demos/dialog/default.html
+++ b/demos/dialog/default.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Dialog - Default functionality</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/dialog/modal-confirmation.html b/demos/dialog/modal-confirmation.html
index 9ae4b1e98..cd87ef222 100644
--- a/demos/dialog/modal-confirmation.html
+++ b/demos/dialog/modal-confirmation.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Dialog - Modal confirmation</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/dialog/modal-form.html b/demos/dialog/modal-form.html
index 7933c685a..84bf287af 100644
--- a/demos/dialog/modal-form.html
+++ b/demos/dialog/modal-form.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Dialog - Modal form</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/dialog/modal-message.html b/demos/dialog/modal-message.html
index 137884627..891959e9e 100644
--- a/demos/dialog/modal-message.html
+++ b/demos/dialog/modal-message.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Dialog - Modal message</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/draggable/constrain-movement.html b/demos/draggable/constrain-movement.html
index adb2f745f..c6c7c6430 100644
--- a/demos/draggable/constrain-movement.html
+++ b/demos/draggable/constrain-movement.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Draggable - Constrain movement</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/draggable/cursor-style.html b/demos/draggable/cursor-style.html
index 56dd4bb3a..822e0e19b 100644
--- a/demos/draggable/cursor-style.html
+++ b/demos/draggable/cursor-style.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Draggable - Cursor style</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/draggable/default.html b/demos/draggable/default.html
index d164139af..513246ec8 100644
--- a/demos/draggable/default.html
+++ b/demos/draggable/default.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Draggable - Default functionality</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/draggable/events.html b/demos/draggable/events.html
index 5496a9486..9b7656571 100644
--- a/demos/draggable/events.html
+++ b/demos/draggable/events.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Draggable - Events</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/draggable/handle.html b/demos/draggable/handle.html
index ae8983b85..76a2b5314 100644
--- a/demos/draggable/handle.html
+++ b/demos/draggable/handle.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Draggable - Handles</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
@@ -10,7 +11,7 @@
#draggable p { cursor: move; }
</style>
<script src="../../external/requirejs/require.js"></script>
- <script src="../bootstrap.js">
+ <script src="../bootstrap.js" data-modules="disable-selection">
$( "#draggable" ).draggable({ handle: "p" });
$( "#draggable2" ).draggable({ cancel: "p.ui-widget-header" });
$( "div, p" ).disableSelection();
diff --git a/demos/draggable/revert.html b/demos/draggable/revert.html
index 5720dbe88..1ae97c970 100644
--- a/demos/draggable/revert.html
+++ b/demos/draggable/revert.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Draggable - Revert position</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/draggable/scroll.html b/demos/draggable/scroll.html
index 2704842bc..727b226b8 100644
--- a/demos/draggable/scroll.html
+++ b/demos/draggable/scroll.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Draggable - Auto-scroll</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/draggable/snap-to.html b/demos/draggable/snap-to.html
index 28cb9d5a7..38abe5ea3 100644
--- a/demos/draggable/snap-to.html
+++ b/demos/draggable/snap-to.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Draggable - Snap to element or grid</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/draggable/sortable.html b/demos/draggable/sortable.html
index 9f07c4752..ad231642f 100644
--- a/demos/draggable/sortable.html
+++ b/demos/draggable/sortable.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Draggable + Sortable</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
@@ -10,7 +11,7 @@
li { margin: 5px; padding: 5px; width: 150px; }
</style>
<script src="../../external/requirejs/require.js"></script>
- <script src="../bootstrap.js" data-modules="sortable">
+ <script src="../bootstrap.js" data-modules="sortable disable-selection">
$( "#sortable" ).sortable({
revert: true
});
diff --git a/demos/draggable/visual-feedback.html b/demos/draggable/visual-feedback.html
index 65f28bb9e..403a37158 100644
--- a/demos/draggable/visual-feedback.html
+++ b/demos/draggable/visual-feedback.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Draggable - Visual feedback</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/droppable/accepted-elements.html b/demos/droppable/accepted-elements.html
index b073087e2..16f224b7d 100644
--- a/demos/droppable/accepted-elements.html
+++ b/demos/droppable/accepted-elements.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Droppable - Accept</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/droppable/default.html b/demos/droppable/default.html
index 0ed58cae3..4d76ab400 100644
--- a/demos/droppable/default.html
+++ b/demos/droppable/default.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Droppable - Default functionality</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/droppable/photo-manager.html b/demos/droppable/photo-manager.html
index 2b324c1e9..25bf24f3b 100644
--- a/demos/droppable/photo-manager.html
+++ b/demos/droppable/photo-manager.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Droppable - Simple photo manager</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
@@ -22,11 +23,11 @@
<script src="../../external/requirejs/require.js"></script>
<script src="../bootstrap.js" data-modules="dialog">
- // there's the gallery and the trash
+ // There's the gallery and the trash
var $gallery = $( "#gallery" ),
$trash = $( "#trash" );
- // let the gallery items be draggable
+ // Let the gallery items be draggable
$( "li", $gallery ).draggable({
cancel: "a.ui-icon", // clicking an icon won't initiate dragging
revert: "invalid", // when not dropped, the item will revert back to its initial position
@@ -35,7 +36,7 @@
cursor: "move"
});
- // let the trash be droppable, accepting the gallery items
+ // Let the trash be droppable, accepting the gallery items
$trash.droppable({
accept: "#gallery > li",
classes: {
@@ -46,7 +47,7 @@
}
});
- // let the gallery be droppable as well, accepting items from the trash
+ // Let the gallery be droppable as well, accepting items from the trash
$gallery.droppable({
accept: "#trash li",
classes: {
@@ -57,7 +58,7 @@
}
});
- // image deletion function
+ // Image deletion function
var recycle_icon = "<a href='link/to/recycle/script/when/we/have/js/off' title='Recycle this image' class='ui-icon ui-icon-refresh'>Recycle image</a>";
function deleteImage( $item ) {
$item.fadeOut(function() {
@@ -75,7 +76,7 @@
});
}
- // image recycle function
+ // Image recycle function
var trash_icon = "<a href='link/to/trash/script/when/we/have/js/off' title='Delete this image' class='ui-icon ui-icon-trash'>Delete image</a>";
function recycleImage( $item ) {
$item.fadeOut(function() {
@@ -93,7 +94,7 @@
});
}
- // image preview function, demonstrating the ui.dialog used as a modal window
+ // Image preview function, demonstrating the ui.dialog used as a modal window
function viewLargerImage( $link ) {
var src = $link.attr( "href" ),
title = $link.siblings( "img" ).attr( "alt" ),
@@ -114,7 +115,7 @@
}
}
- // resolve the icons behavior with event delegation
+ // Resolve the icons behavior with event delegation
$( "ul.gallery > li" ).on( "click", function( event ) {
var $item = $( this ),
$target = $( event.target );
diff --git a/demos/droppable/propagation.html b/demos/droppable/propagation.html
index 048c847f3..a70c2f076 100644
--- a/demos/droppable/propagation.html
+++ b/demos/droppable/propagation.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Droppable - Prevent propagation</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/droppable/revert.html b/demos/droppable/revert.html
index 2a05f0169..5beacab99 100644
--- a/demos/droppable/revert.html
+++ b/demos/droppable/revert.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Droppable - Revert draggable position</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/droppable/visual-feedback.html b/demos/droppable/visual-feedback.html
index 3ef5cd1e2..a6eb9db58 100644
--- a/demos/droppable/visual-feedback.html
+++ b/demos/droppable/visual-feedback.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Droppable - Visual feedback</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/effect/addClass.html b/demos/effect/addClass.html
index 09de61312..45b6f5f4c 100644
--- a/demos/effect/addClass.html
+++ b/demos/effect/addClass.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Effects - addClass demo</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/effect/animate.html b/demos/effect/animate.html
index 603e93fe9..2ff34399c 100644
--- a/demos/effect/animate.html
+++ b/demos/effect/animate.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Effects - Animate demo</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/effect/default.html b/demos/effect/default.html
index bd28652a6..7d69abb2d 100644
--- a/demos/effect/default.html
+++ b/demos/effect/default.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Effects - Effect demo</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
@@ -19,7 +20,7 @@
// get effect type from
var selectedEffect = $( "#effectTypes" ).val();
- // most effect types need no options passed by default
+ // Most effect types need no options passed by default
var options = {};
// some effects have required parameters
if ( selectedEffect === "scale" ) {
@@ -30,18 +31,18 @@
options = { to: { width: 200, height: 60 } };
}
- // run the effect
+ // Run the effect
$( "#effect" ).effect( selectedEffect, options, 500, callback );
};
- // callback function to bring a hidden box back
+ // Callback function to bring a hidden box back
function callback() {
setTimeout(function() {
$( "#effect" ).removeAttr( "style" ).hide().fadeIn();
}, 1000 );
};
- // set effect from select menu value
+ // Set effect from select menu value
$( "#button" ).on( "click", function() {
runEffect();
return false;
diff --git a/demos/effect/easing.html b/demos/effect/easing.html
index 5985dc699..b22c69580 100644
--- a/demos/effect/easing.html
+++ b/demos/effect/easing.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Effects - Easing demo</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
@@ -37,7 +38,7 @@
ctx = canvas.getContext( "2d" );
ctx.fillStyle = "black";
- // draw background
+ // Draw background
ctx.beginPath();
ctx.moveTo( cradius, 0 );
ctx.quadraticCurveTo( 0, 0, 0, cradius );
@@ -49,21 +50,21 @@
ctx.lineTo( cradius, 0 );
ctx.fill();
- // draw bottom line
+ // Draw bottom line
ctx.strokeStyle = "#555";
ctx.beginPath();
ctx.moveTo( width * 0.1, drawHeight + .5 );
ctx.lineTo( width * 0.9, drawHeight + .5 );
ctx.stroke();
- // draw top line
+ // Draw top line
ctx.strokeStyle = "#555";
ctx.beginPath();
ctx.moveTo( width * 0.1, drawHeight * .3 - .5 );
ctx.lineTo( width * 0.9, drawHeight * .3 - .5 );
ctx.stroke();
- // plot easing
+ // Plot easing
ctx.strokeStyle = "white";
ctx.beginPath();
ctx.lineWidth = 2;
@@ -76,7 +77,7 @@
});
ctx.stroke();
- // animate on click
+ // Animate on click
graph.on( "click", function() {
wrap
.animate( { height: "hide" }, 2000, name )
diff --git a/demos/effect/hide.html b/demos/effect/hide.html
index 1fcd6477e..cbfb47d61 100644
--- a/demos/effect/hide.html
+++ b/demos/effect/hide.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Effects - Hide Demo</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
@@ -18,7 +19,7 @@
// get effect type from
var selectedEffect = $( "#effectTypes" ).val();
- // most effect types need no options passed by default
+ // Most effect types need no options passed by default
var options = {};
// some effects have required parameters
if ( selectedEffect === "scale" ) {
@@ -27,18 +28,18 @@
options = { to: { width: 200, height: 60 } };
}
- // run the effect
+ // Run the effect
$( "#effect" ).hide( selectedEffect, options, 1000, callback );
};
- // callback function to bring a hidden box back
+ // Callback function to bring a hidden box back
function callback() {
setTimeout(function() {
$( "#effect" ).removeAttr( "style" ).hide().fadeIn();
}, 1000 );
};
- // set effect from select menu value
+ // Set effect from select menu value
$( "#button" ).on( "click", function() {
runEffect();
});
diff --git a/demos/effect/removeClass.html b/demos/effect/removeClass.html
index 0980bae83..734a9f600 100644
--- a/demos/effect/removeClass.html
+++ b/demos/effect/removeClass.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Effects - removeClass Demo</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<script src="../../external/jquery/jquery.js"></script>
diff --git a/demos/effect/show.html b/demos/effect/show.html
index 4bb0919e4..8a980711c 100644
--- a/demos/effect/show.html
+++ b/demos/effect/show.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Effects - Show Demo</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
@@ -18,7 +19,7 @@
// get effect type from
var selectedEffect = $( "#effectTypes" ).val();
- // most effect types need no options passed by default
+ // Most effect types need no options passed by default
var options = {};
// some effects have required parameters
if ( selectedEffect === "scale" ) {
@@ -27,7 +28,7 @@
options = { to: { width: 280, height: 185 } };
}
- // run the effect
+ // Run the effect
$( "#effect" ).show( selectedEffect, options, 500, callback );
};
@@ -38,7 +39,7 @@
}, 1000 );
};
- // set effect from select menu value
+ // Set effect from select menu value
$( "#button" ).on( "click", function() {
runEffect();
});
diff --git a/demos/effect/switchClass.html b/demos/effect/switchClass.html
index c02f4420b..ad52854d1 100644
--- a/demos/effect/switchClass.html
+++ b/demos/effect/switchClass.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Effects - switchClass Demo</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/effect/toggle.html b/demos/effect/toggle.html
index 65c4747a9..bf94e82e0 100644
--- a/demos/effect/toggle.html
+++ b/demos/effect/toggle.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Effects - Toggle Demo</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
@@ -33,7 +34,7 @@
// get effect type from
var selectedEffect = $( "#effectTypes" ).val();
- // most effect types need no options passed by default
+ // Most effect types need no options passed by default
var options = {};
// some effects have required parameters
if ( selectedEffect === "scale" ) {
@@ -42,11 +43,11 @@
options = { to: { width: 200, height: 60 } };
}
- // run the effect
+ // Run the effect
$( "#effect" ).toggle( selectedEffect, options, 500 );
};
- // set effect from select menu value
+ // Set effect from select menu value
$( "#button" ).on( "click", function() {
runEffect();
});
diff --git a/demos/effect/toggleClass.html b/demos/effect/toggleClass.html
index e1e3778ce..80ed7f29f 100644
--- a/demos/effect/toggleClass.html
+++ b/demos/effect/toggleClass.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Effects - toggleClass Demo</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/menu/categories.html b/demos/menu/categories.html
index a1526153e..e359292f3 100644
--- a/demos/menu/categories.html
+++ b/demos/menu/categories.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Menu - Categories</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
@@ -23,7 +24,7 @@
<li><div>Option 1</div></li>
<li><div>Option 2</div></li>
<li><div>Option 3</div></li>
- <li class="ui-widget-header"><div>Category 2</div></li>
+ <li class="ui-widget-header"><div>Category 2</div></li>
<li><div>Option 4</div></li>
<li><div>Option 5</div></li>
<li><div>Option 6</div></li>
diff --git a/demos/menu/default.html b/demos/menu/default.html
index 2440ea72e..9b91b1dc7 100644
--- a/demos/menu/default.html
+++ b/demos/menu/default.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Menu - Default functionality</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/menu/icons.html b/demos/menu/icons.html
index c3663179a..5f30b9d99 100644
--- a/demos/menu/icons.html
+++ b/demos/menu/icons.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Menu - Icons</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/position/cycler.html b/demos/position/cycler.html
index af0c00a82..910b0050c 100644
--- a/demos/position/cycler.html
+++ b/demos/position/cycler.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Position - Image Cycler</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/position/default.html b/demos/position/default.html
index 142787980..4f6b807b8 100644
--- a/demos/position/default.html
+++ b/demos/position/default.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Position - Default functionality</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/progressbar/default.html b/demos/progressbar/default.html
index b1ada1a0a..2625b00b1 100644
--- a/demos/progressbar/default.html
+++ b/demos/progressbar/default.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Progressbar - Default functionality</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/progressbar/download.html b/demos/progressbar/download.html
index a7731b387..0528fc63b 100644
--- a/demos/progressbar/download.html
+++ b/demos/progressbar/download.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Progressbar - Download Dialog</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/progressbar/indeterminate.html b/demos/progressbar/indeterminate.html
index d349a7436..816808f82 100644
--- a/demos/progressbar/indeterminate.html
+++ b/demos/progressbar/indeterminate.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Progressbar - Indeterminate Value</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/progressbar/label.html b/demos/progressbar/label.html
index ea4c4ecdb..9ff0a7596 100644
--- a/demos/progressbar/label.html
+++ b/demos/progressbar/label.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Progressbar - Custom Label</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/resizable/animate.html b/demos/resizable/animate.html
index 344bba014..012777ad7 100644
--- a/demos/resizable/animate.html
+++ b/demos/resizable/animate.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Resizable - Animate</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/resizable/aspect-ratio.html b/demos/resizable/aspect-ratio.html
index 3878b18ec..6fe961db4 100644
--- a/demos/resizable/aspect-ratio.html
+++ b/demos/resizable/aspect-ratio.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Resizable - Preserve aspect ratio</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/resizable/constrain-area.html b/demos/resizable/constrain-area.html
index e000fcf07..b2660192e 100644
--- a/demos/resizable/constrain-area.html
+++ b/demos/resizable/constrain-area.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Resizable - Constrain resize area</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/resizable/default.html b/demos/resizable/default.html
index 60b3380ef..ef82efd23 100644
--- a/demos/resizable/default.html
+++ b/demos/resizable/default.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Resizable - Default functionality</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/resizable/helper.html b/demos/resizable/helper.html
index d10e5b523..f68da91b7 100644
--- a/demos/resizable/helper.html
+++ b/demos/resizable/helper.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Resizable - Helper</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/resizable/max-min.html b/demos/resizable/max-min.html
index ed43ec795..69b4b57cb 100644
--- a/demos/resizable/max-min.html
+++ b/demos/resizable/max-min.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Resizable - Maximum / minimum size</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/resizable/snap-to-grid.html b/demos/resizable/snap-to-grid.html
index ce897a98e..172ed724f 100644
--- a/demos/resizable/snap-to-grid.html
+++ b/demos/resizable/snap-to-grid.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Resizable - Snap to grid</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/resizable/synchronous-resize.html b/demos/resizable/synchronous-resize.html
index ddc89cd88..7086c878c 100644
--- a/demos/resizable/synchronous-resize.html
+++ b/demos/resizable/synchronous-resize.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Resizable - Synchronous resize</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/resizable/textarea.html b/demos/resizable/textarea.html
index f3e0fa25e..e752654ef 100644
--- a/demos/resizable/textarea.html
+++ b/demos/resizable/textarea.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Resizable - Textarea</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/resizable/visual-feedback.html b/demos/resizable/visual-feedback.html
index a9a1c3f39..750d4858d 100644
--- a/demos/resizable/visual-feedback.html
+++ b/demos/resizable/visual-feedback.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Resizable - Visual feedback</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/selectable/default.html b/demos/selectable/default.html
index d71b25ff9..2113f33ed 100644
--- a/demos/selectable/default.html
+++ b/demos/selectable/default.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Selectable - Default functionality</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/selectable/display-grid.html b/demos/selectable/display-grid.html
index f561673ed..c4acc429f 100644
--- a/demos/selectable/display-grid.html
+++ b/demos/selectable/display-grid.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Selectable - Display as grid</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/selectable/serialize.html b/demos/selectable/serialize.html
index 9acd37fd5..423703113 100644
--- a/demos/selectable/serialize.html
+++ b/demos/selectable/serialize.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Selectable - Serialize</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/slider/colorpicker.html b/demos/slider/colorpicker.html
index 32ea4f89e..66b6474b2 100644
--- a/demos/slider/colorpicker.html
+++ b/demos/slider/colorpicker.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Slider - Colorpicker</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/slider/default.html b/demos/slider/default.html
index 9fcd6d07d..62789ac48 100644
--- a/demos/slider/default.html
+++ b/demos/slider/default.html
@@ -1,7 +1,8 @@
<!doctype html>
<html lang="en">
<head>
- <meta charset="utf-8" >
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Slider - Default functionality</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/slider/hotelrooms.html b/demos/slider/hotelrooms.html
index 05d16aa52..1eb50470e 100644
--- a/demos/slider/hotelrooms.html
+++ b/demos/slider/hotelrooms.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Slider - Slider bound to select</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/slider/multiple-vertical.html b/demos/slider/multiple-vertical.html
index 97e2349d1..0af65f86b 100644
--- a/demos/slider/multiple-vertical.html
+++ b/demos/slider/multiple-vertical.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Slider - Multiple sliders</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<script src="../../external/jquery/jquery.js"></script>
diff --git a/demos/slider/range-vertical.html b/demos/slider/range-vertical.html
index bed2e8cb2..b8c3b1e24 100644
--- a/demos/slider/range-vertical.html
+++ b/demos/slider/range-vertical.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Slider - Vertical range slider</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/slider/range.html b/demos/slider/range.html
index a660fee55..646b1d903 100644
--- a/demos/slider/range.html
+++ b/demos/slider/range.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Slider - Range slider</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/slider/rangemax.html b/demos/slider/rangemax.html
index 38bcf4016..a98592d31 100644
--- a/demos/slider/rangemax.html
+++ b/demos/slider/rangemax.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Slider - Range with fixed maximum</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/slider/rangemin.html b/demos/slider/rangemin.html
index 1105ff71e..95d7516e5 100644
--- a/demos/slider/rangemin.html
+++ b/demos/slider/rangemin.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Slider - Range with fixed minimum</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/slider/slider-vertical.html b/demos/slider/slider-vertical.html
index f59f08a30..00014f635 100644
--- a/demos/slider/slider-vertical.html
+++ b/demos/slider/slider-vertical.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Slider - Vertical slider</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/slider/steps.html b/demos/slider/steps.html
index deb05bbc0..9f8b68093 100644
--- a/demos/slider/steps.html
+++ b/demos/slider/steps.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Slider - Snap to increments</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/sortable/connect-lists.html b/demos/sortable/connect-lists.html
index 4461e7364..fcf5dcd01 100644
--- a/demos/sortable/connect-lists.html
+++ b/demos/sortable/connect-lists.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Sortable - Connect lists</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
@@ -24,7 +25,7 @@
}
</style>
<script src="../../external/requirejs/require.js"></script>
- <script src="../bootstrap.js">
+ <script src="../bootstrap.js" data-modules="disable-selection">
$( "#sortable1, #sortable2" ).sortable({
connectWith: ".connectedSortable"
}).disableSelection();
diff --git a/demos/sortable/default.html b/demos/sortable/default.html
index 9b225e897..f37a23c44 100644
--- a/demos/sortable/default.html
+++ b/demos/sortable/default.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Sortable - Default functionality</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
@@ -11,7 +12,7 @@
#sortable li span { position: absolute; margin-left: -1.3em; }
</style>
<script src="../../external/requirejs/require.js"></script>
- <script src="../bootstrap.js">
+ <script src="../bootstrap.js" data-modules="disable-selection">
$( "#sortable" ).sortable();
$( "#sortable" ).disableSelection();
</script>
diff --git a/demos/sortable/display-grid.html b/demos/sortable/display-grid.html
index 8f0f6ae35..76f2d7b68 100644
--- a/demos/sortable/display-grid.html
+++ b/demos/sortable/display-grid.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Sortable - Display as grid</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
@@ -10,7 +11,7 @@
#sortable li { margin: 3px 3px 3px 0; padding: 1px; float: left; width: 100px; height: 90px; font-size: 4em; text-align: center; }
</style>
<script src="../../external/requirejs/require.js"></script>
- <script src="../bootstrap.js">
+ <script src="../bootstrap.js" data-modules="disable-selection">
$( "#sortable" ).sortable();
$( "#sortable" ).disableSelection();
</script>
diff --git a/demos/sortable/empty-lists.html b/demos/sortable/empty-lists.html
index fa515b377..a6bc4a7f1 100644
--- a/demos/sortable/empty-lists.html
+++ b/demos/sortable/empty-lists.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Sortable - Handle empty lists</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
@@ -10,7 +11,7 @@
#sortable1 li, #sortable2 li, #sortable3 li { margin: 5px; padding: 5px; font-size: 1.2em; width: 120px; }
</style>
<script src="../../external/requirejs/require.js"></script>
- <script src="../bootstrap.js">
+ <script src="../bootstrap.js" data-modules="disable-selection">
$( "ul.droptrue" ).sortable({
connectWith: "ul"
});
diff --git a/demos/sortable/items.html b/demos/sortable/items.html
index 21a7230d5..a13410d0a 100644
--- a/demos/sortable/items.html
+++ b/demos/sortable/items.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Sortable - Include / exclude items</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
@@ -10,7 +11,7 @@
#sortable1 li, #sortable2 li { margin: 0 5px 5px 5px; padding: 3px; width: 90%; }
</style>
<script src="../../external/requirejs/require.js"></script>
- <script src="../bootstrap.js">
+ <script src="../bootstrap.js" data-modules="disable-selection">
$( "#sortable1" ).sortable({
items: "li:not(.ui-state-disabled)"
});
diff --git a/demos/sortable/placeholder.html b/demos/sortable/placeholder.html
index 7a17e6914..50d83c2a9 100644
--- a/demos/sortable/placeholder.html
+++ b/demos/sortable/placeholder.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Sortable - Drop placeholder</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
@@ -12,7 +13,7 @@
.ui-state-highlight { height: 1.5em; line-height: 1.2em; }
</style>
<script src="../../external/requirejs/require.js"></script>
- <script src="../bootstrap.js">
+ <script src="../bootstrap.js" data-modules="disable-selection">
$( "#sortable" ).sortable({
placeholder: "ui-state-highlight"
});
diff --git a/demos/sortable/portlets.html b/demos/sortable/portlets.html
index a3f42a254..2eab237cd 100644
--- a/demos/sortable/portlets.html
+++ b/demos/sortable/portlets.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Sortable - Portlets</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/spinner/currency.html b/demos/spinner/currency.html
index ecf193b09..ad25359df 100644
--- a/demos/spinner/currency.html
+++ b/demos/spinner/currency.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Spinner - Currency</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/spinner/decimal.html b/demos/spinner/decimal.html
index cb7e2b8a0..68a806a9c 100644
--- a/demos/spinner/decimal.html
+++ b/demos/spinner/decimal.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Spinner - Decimal</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/spinner/default.html b/demos/spinner/default.html
index 3d08a60bb..39684fb5e 100644
--- a/demos/spinner/default.html
+++ b/demos/spinner/default.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Spinner - Default functionality</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/spinner/latlong.html b/demos/spinner/latlong.html
index 9c67de0f9..29fd28ada 100644
--- a/demos/spinner/latlong.html
+++ b/demos/spinner/latlong.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Spinner - Map</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/spinner/overflow.html b/demos/spinner/overflow.html
index 80e3981fc..9908a3442 100644
--- a/demos/spinner/overflow.html
+++ b/demos/spinner/overflow.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Spinner - Overflow</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/spinner/time.html b/demos/spinner/time.html
index 5e8638b1c..6941cd646 100644
--- a/demos/spinner/time.html
+++ b/demos/spinner/time.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Spinner - Time</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/tabs/ajax.html b/demos/tabs/ajax.html
index c8a247e66..f10e6480e 100644
--- a/demos/tabs/ajax.html
+++ b/demos/tabs/ajax.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Tabs - Content via Ajax</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/tabs/collapsible.html b/demos/tabs/collapsible.html
index d1e3861a8..7fcd15bdb 100644
--- a/demos/tabs/collapsible.html
+++ b/demos/tabs/collapsible.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Tabs - Collapse content</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/tabs/default.html b/demos/tabs/default.html
index c68e0afa6..4c2b0fad3 100644
--- a/demos/tabs/default.html
+++ b/demos/tabs/default.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Tabs - Default functionality</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/tabs/manipulation.html b/demos/tabs/manipulation.html
index bb4bb34c7..a9f40b771 100644
--- a/demos/tabs/manipulation.html
+++ b/demos/tabs/manipulation.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Tabs - Simple manipulation</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
@@ -22,7 +23,7 @@
var tabs = $( "#tabs" ).tabs();
- // modal dialog init: custom buttons and a "close" callback resetting the form inside
+ // Modal dialog init: custom buttons and a "close" callback resetting the form inside
var dialog = $( "#dialog" ).dialog({
autoOpen: false,
modal: true,
@@ -40,14 +41,14 @@
}
});
- // addTab form: calls addTab function on submit and closes the dialog
+ // AddTab form: calls addTab function on submit and closes the dialog
var form = dialog.find( "form" ).on( "submit", function( event ) {
addTab();
dialog.dialog( "close" );
event.preventDefault();
});
- // actual addTab function: adds new tab using the input from the form above
+ // Actual addTab function: adds new tab using the input from the form above
function addTab() {
var label = tabTitle.val() || "Tab " + tabCounter,
id = "tabs-" + tabCounter,
@@ -60,14 +61,14 @@
tabCounter++;
}
- // addTab button: just opens the dialog
+ // AddTab button: just opens the dialog
$( "#add_tab" )
.button()
.on( "click", function() {
dialog.dialog( "open" );
});
- // close icon: removing the tab on click
+ // Close icon: removing the tab on click
tabs.on( "click", "span.ui-icon-close", function() {
var panelId = $( this ).closest( "li" ).remove().attr( "aria-controls" );
$( "#" + panelId ).remove();
diff --git a/demos/tabs/mouseover.html b/demos/tabs/mouseover.html
index 2a356d109..edd0943c8 100644
--- a/demos/tabs/mouseover.html
+++ b/demos/tabs/mouseover.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Tabs - Open on mouseover</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/tabs/sortable.html b/demos/tabs/sortable.html
index 7c4a05b60..051663ed4 100644
--- a/demos/tabs/sortable.html
+++ b/demos/tabs/sortable.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Tabs - Sortable</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/tabs/vertical.html b/demos/tabs/vertical.html
index 00e16eafc..8b6aa45a5 100644
--- a/demos/tabs/vertical.html
+++ b/demos/tabs/vertical.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Tabs - Vertical Tabs functionality</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/tooltip/custom-animation.html b/demos/tooltip/custom-animation.html
index 9f09c1353..d4419e6c3 100644
--- a/demos/tooltip/custom-animation.html
+++ b/demos/tooltip/custom-animation.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Tooltip - Custom animation demo</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/tooltip/custom-content.html b/demos/tooltip/custom-content.html
index 66e7e0c01..003bf110d 100644
--- a/demos/tooltip/custom-content.html
+++ b/demos/tooltip/custom-content.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Tooltip - Custom content</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/tooltip/custom-style.html b/demos/tooltip/custom-style.html
index 8e0574f8e..8f1bd51e2 100644
--- a/demos/tooltip/custom-style.html
+++ b/demos/tooltip/custom-style.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Tooltip - Custom Styling</title>
<link rel="stylesheet" href="../../themes/base/tooltip.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/tooltip/default.html b/demos/tooltip/default.html
index c467b1c1a..93a5536cc 100644
--- a/demos/tooltip/default.html
+++ b/demos/tooltip/default.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Tooltip - Default functionality</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/tooltip/forms.html b/demos/tooltip/forms.html
index 37c849a21..7221d38ab 100644
--- a/demos/tooltip/forms.html
+++ b/demos/tooltip/forms.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Tooltip - Forms</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
@@ -24,7 +25,8 @@
var tooltips = $( "[title]" ).tooltip({
position: {
my: "left top",
- at: "right+5 top-5"
+ at: "right+5 top-5",
+ collision: "none"
}
});
$( "<button>" )
diff --git a/demos/tooltip/tracking.html b/demos/tooltip/tracking.html
index 3cca5ec42..390f43b8c 100644
--- a/demos/tooltip/tracking.html
+++ b/demos/tooltip/tracking.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Tooltip - Track the mouse</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/tooltip/video-player.html b/demos/tooltip/video-player.html
index cd667e3db..cbcce3db0 100644
--- a/demos/tooltip/video-player.html
+++ b/demos/tooltip/video-player.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Tooltip - Video Player demo</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
diff --git a/demos/widget/default.html b/demos/widget/default.html
index e545ef6ad..59bc58d12 100644
--- a/demos/widget/default.html
+++ b/demos/widget/default.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Widget - Default functionality</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
@@ -30,18 +31,16 @@
green: 0,
blue: 0,
- // callbacks
+ // Callbacks
change: null,
random: null
},
- // the constructor
+ // The constructor
_create: function() {
this.element
// add a class for theming
- .addClass( "custom-colorize" )
- // prevent double click to select text
- .disableSelection();
+ .addClass( "custom-colorize" );
this.changer = $( "<button>", {
text: "change",
@@ -50,7 +49,7 @@
.appendTo( this.element )
.button();
- // bind click events on the changer button to the random method
+ // Bind click events on the changer button to the random method
this._on( this.changer, {
// _on won't call random when widget is disabled
click: "random"
@@ -58,7 +57,7 @@
this._refresh();
},
- // called when created, and later when changing options
+ // Called when created, and later when changing options
_refresh: function() {
this.element.css( "background-color", "rgb(" +
this.options.red +"," +
@@ -66,11 +65,11 @@
this.options.blue + ")"
);
- // trigger a callback/event
+ // Trigger a callback/event
this._trigger( "change" );
},
- // a public method to change the color to a random value
+ // A public method to change the color to a random value
// can be called directly via .colorize( "random" )
random: function( event ) {
var colors = {
@@ -79,13 +78,13 @@
blue: Math.floor( Math.random() * 256 )
};
- // trigger an event, check if it's canceled
+ // Trigger an event, check if it's canceled
if ( this._trigger( "random", event, colors ) !== false ) {
this.option( colors );
}
},
- // events bound via _on are removed automatically
+ // Events bound via _on are removed automatically
// revert other modifications here
_destroy: function() {
// remove generated elements
@@ -115,16 +114,16 @@
}
});
- // initialize with default options
+ // Initialize with default options
$( "#my-widget1" ).colorize();
- // initialize with two customized options
+ // Initialize with two customized options
$( "#my-widget2" ).colorize({
red: 60,
blue: 60
});
- // initialize with custom green value
+ // Initialize with custom green value
// and a random callback to allow only colors with enough green
$( "#my-widget3" ).colorize( {
green: 128,
@@ -133,7 +132,7 @@
}
});
- // click to toggle enabled/disabled
+ // Click to toggle enabled/disabled
$( "#disable" ).on( "click", function() {
// use the custom selector created for each widget to find all instances
// all instances are toggled together, so we can check the state from the first
@@ -144,7 +143,7 @@
}
});
- // click to set options after initialization
+ // Click to set options after initialization
$( "#green" ).on( "click", function() {
$( ":custom-colorize" ).colorize( "option", {
red: 64,
diff --git a/package.json b/package.json
index 355bb3a5a..599efbb5a 100644
--- a/package.json
+++ b/package.json
@@ -8,6 +8,7 @@
"name": "jQuery Foundation and other contributors",
"url": "https://github.com/jquery/jquery-ui/blob/master/AUTHORS.txt"
},
+ "main": "ui/widget.js",
"maintainers": [
{
"name": "Scott González",
@@ -63,7 +64,7 @@
"grunt-esformatter": "0.2.0",
"grunt-git-authors": "2.0.0",
"grunt-html": "4.0.1",
- "grunt-jscs": "1.5.0",
+ "grunt-jscs": "2.1.0",
"load-grunt-tasks": "0.3.0",
"rimraf": "2.1.4",
"testswarm": "1.1.0"
diff --git a/tests/index.js b/tests/index.js
index 26c07498f..30771f794 100644
--- a/tests/index.js
+++ b/tests/index.js
@@ -1,4 +1,4 @@
-$(function() {
+$( function() {
$( "#main" )
.addClass( "ui-widget" )
@@ -7,4 +7,4 @@ $( "#main" )
.next()
.addClass( "ui-widget-content ui-corner-bottom" );
-});
+} );
diff --git a/tests/lib/bootstrap.js b/tests/lib/bootstrap.js
index 89c4d4893..745ddefb1 100644
--- a/tests/lib/bootstrap.js
+++ b/tests/lib/bootstrap.js
@@ -1,6 +1,6 @@
( function() {
-requirejs.config({
+requirejs.config( {
paths: {
"cldr": "../../../external/cldrjs/cldr",
"globalize": "../../../external/globalize/globalize",
@@ -15,7 +15,7 @@ requirejs.config({
"qunit-assert-classes": "../../../external/qunit-assert-classes/qunit-assert-classes",
"qunit-assert-close": "../../../external/qunit-assert-close/qunit-assert-close",
"qunit": "../../../external/qunit/qunit",
- "testswarm": "http://swarm.jquery.org/js/inject.js?" + (new Date()).getTime(),
+ "testswarm": "http://swarm.jquery.org/js/inject.js?" + ( new Date() ).getTime(),
"ui": "../../../ui"
},
shim: {
@@ -25,7 +25,7 @@ requirejs.config({
"qunit-assert-close": [ "qunit" ],
"testswarm": [ "qunit" ]
}
-});
+} );
// Create a module that disables back compat for UI modules
define( "jquery-no-back-compat", [ "jquery" ], function( $ ) {
@@ -112,7 +112,7 @@ function jqueryUrl() {
// - Automatically loads common, core, events, methods, and options
// - data-deprecated: Loads the deprecated test modules for a widget
// - data-no-back-compat: Set $.uiBackCompat to false
-(function() {
+( function() {
// Find the script element
var scripts = document.getElementsByTagName( "script" );
@@ -132,18 +132,23 @@ function jqueryUrl() {
var noBackCompat = !!script.getAttribute( "data-no-back-compat" );
if ( widget ) {
- modules = modules.concat([
+ modules = modules.concat( [
( deprecated ? "common-deprecated" : "common" ),
"core",
"events",
"methods",
"options"
- ]);
+ ] );
if ( deprecated ) {
modules = modules.concat( "deprecated" );
}
}
+ // Load the jQuery 1.7 fixes, if necessary
+ if ( parseFloat( parseUrl().jquery ) === 1.7 ) {
+ modules.push( "ui/jquery-1-7" );
+ }
+
requireTests( modules, noBackCompat );
} )();
diff --git a/tests/lib/common.js b/tests/lib/common.js
index 8e4acbea8..c3e898535 100644
--- a/tests/lib/common.js
+++ b/tests/lib/common.js
@@ -1,4 +1,4 @@
-define([
+define( [
"jquery"
], function( $ ) {
@@ -17,8 +17,8 @@ function testWidgetDefaults( widget, defaults ) {
return;
}
deepEqual( pluginDefaults[ key ], val, key );
- });
- });
+ } );
+ } );
// Ensure that all defaults were tested
test( "tested defaults", function() {
@@ -26,15 +26,15 @@ function testWidgetDefaults( widget, defaults ) {
$.each( pluginDefaults, function( key ) {
expect( ++count );
ok( key in defaults, key );
- });
- });
+ } );
+ } );
}
function testWidgetOverrides( widget ) {
if ( $.uiBackCompat === false ) {
test( "$.widget overrides", function() {
expect( 4 );
- $.each([
+ $.each( [
"_createWidget",
"destroy",
"option",
@@ -42,8 +42,8 @@ function testWidgetOverrides( widget ) {
], function( i, method ) {
strictEqual( $.ui[ widget ].prototype[ method ],
$.Widget.prototype[ method ], "should not override " + method );
- });
- });
+ } );
+ } );
}
}
@@ -61,7 +61,7 @@ function testBasicUsage( widget ) {
// Ensure manipulating removed elements works (#3664)
$( defaultElement ).appendTo( "body" ).remove()[ widget ]().remove();
ok( true, "initialized on disconnected DOMElement - removed" );
- });
+ } );
}
exports.testWidget = function( widget, settings ) {
@@ -74,7 +74,7 @@ exports.testWidget = function( widget, settings ) {
test( "version", function() {
expect( 1 );
ok( "version" in $.ui[ widget ].prototype, "version property exists" );
- });
+ } );
};
exports.testJshint = function( module ) {
@@ -120,14 +120,14 @@ exports.testJshint = function( module ) {
ok( passed, errors );
start();
} )
- .fail(function( hintError, srcError ) {
+ .fail( function( hintError, srcError ) {
ok( false, "error loading source: " + ( hintError || srcError ).statusText );
start();
} );
- });
- });
+ } );
+ } );
};
return exports;
-});
+} );
diff --git a/tests/lib/css.js b/tests/lib/css.js
index 37353e912..ab707ad2a 100644
--- a/tests/lib/css.js
+++ b/tests/lib/css.js
@@ -1,4 +1,4 @@
-(function() {
+( function() {
function includeStyle( url ) {
document.write( "<link rel='stylesheet' href='../../../" + url + "'>" );
diff --git a/tests/lib/helper.js b/tests/lib/helper.js
index cc7d8c000..400d85489 100644
--- a/tests/lib/helper.js
+++ b/tests/lib/helper.js
@@ -1,4 +1,4 @@
-define([
+define( [
"jquery"
], function( $ ) {
@@ -9,10 +9,10 @@ exports.forceScrollableWindow = function( appendTo ) {
// The main testable area is 10000x10000 so to enforce scrolling,
// this DIV must be greater than 10000 to work
return $( "<div>" )
- .css({
+ .css( {
height: "11000px",
width: "11000px"
- })
+ } )
.appendTo( appendTo || "#qunit-fixture" );
};
@@ -30,4 +30,4 @@ exports.onFocus = function( element, onFocus ) {
return exports;
-});
+} );
diff --git a/tests/lib/qunit-assert-domequal.js b/tests/lib/qunit-assert-domequal.js
index ba516453d..e8083db77 100644
--- a/tests/lib/qunit-assert-domequal.js
+++ b/tests/lib/qunit-assert-domequal.js
@@ -100,20 +100,20 @@ function extract( selector, message ) {
$.each( domEqual.properties, function( index, attr ) {
var value = elem.prop( attr );
result[ attr ] = value != null ? value : "";
- });
+ } );
$.each( domEqual.attributes, function( index, attr ) {
var value = elem.attr( attr );
result[ attr ] = value != null ? value : "";
- });
+ } );
result.style = getElementStyles( elem[ 0 ] );
result.events = $._data( elem[ 0 ], "events" );
result.data = $.extend( {}, elem.data() );
delete result.data[ $.expando ];
children = elem.children();
if ( children.length ) {
- result.children = elem.children().map(function() {
+ result.children = elem.children().map( function() {
return extract( $( this ) );
- }).get();
+ } ).get();
} else {
result.text = elem.text();
}
diff --git a/tests/lib/qunit.js b/tests/lib/qunit.js
index 87ef8b662..b421341ea 100644
--- a/tests/lib/qunit.js
+++ b/tests/lib/qunit.js
@@ -10,13 +10,13 @@ define( [
QUnit.config.autostart = false;
QUnit.config.requireExpects = true;
-QUnit.config.urlConfig.push({
+QUnit.config.urlConfig.push( {
id: "nojshint",
label: "Skip JSHint",
tooltip: "Skip running JSHint, e.g., within TestSwarm, where Jenkins runs it already"
-});
+} );
-QUnit.config.urlConfig.push({
+QUnit.config.urlConfig.push( {
id: "jquery",
label: "jQuery version",
value: [
@@ -30,7 +30,7 @@ QUnit.config.urlConfig.push({
"compat-git", "git", "custom"
],
tooltip: "Which jQuery Core version to test against"
-});
+} );
QUnit.reset = ( function( reset ) {
return function() {
diff --git a/tests/unit/accordion/common.js b/tests/unit/accordion/common.js
index 1a8ce55c4..453506dbd 100644
--- a/tests/unit/accordion/common.js
+++ b/tests/unit/accordion/common.js
@@ -22,11 +22,11 @@ common.testWidget( "accordion", {
"header": "ui-icon-triangle-1-e"
},
- // callbacks
+ // Callbacks
activate: null,
beforeActivate: null,
create: null
}
-});
+} );
} );
diff --git a/tests/unit/accordion/core.js b/tests/unit/accordion/core.js
index ed538c368..75f4b4ee3 100644
--- a/tests/unit/accordion/core.js
+++ b/tests/unit/accordion/core.js
@@ -32,33 +32,33 @@ $.each( { div: "#list1", ul: "#navigation", dl: "#accordion-dl" }, function( typ
deepEqual( element.find( ".ui-accordion-header" ).next().get(),
element.find( ".ui-accordion-content" ).get(),
"content panels come immediately after headers" );
- });
-});
+ } );
+} );
test( "handle click on header-descendant", function() {
expect( 1 );
var element = $( "#navigation" ).accordion();
$( "#navigation h2:eq(1) a" ).trigger( "click" );
state( element, 0, 1, 0 );
-});
+} );
-test( "accessibility", function () {
+test( "accessibility", function() {
expect( 61 );
- var element = $( "#list1" ).accordion({
+ var element = $( "#list1" ).accordion( {
active: 1,
collapsible: true
- }),
+ } ),
headers = element.find( ".ui-accordion-header" );
equal( element.attr( "role" ), "tablist", "element role" );
- headers.each(function( i ) {
+ headers.each( function( i ) {
var header = headers.eq( i ),
panel = header.next();
equal( header.attr( "role" ), "tab", "header " + i + " role" );
equal( header.attr( "aria-controls" ), panel.attr( "id" ), "header " + i + " aria-controls" );
equal( panel.attr( "role" ), "tabpanel", "panel " + i + " role" );
equal( panel.attr( "aria-labelledby" ), header.attr( "id" ), "panel " + i + " aria-labelledby" );
- });
+ } );
equal( headers.eq( 1 ).attr( "tabindex" ), 0, "active header has tabindex=0" );
equal( headers.eq( 1 ).attr( "aria-selected" ), "true", "active tab (1) has aria-selected=true" );
@@ -115,7 +115,7 @@ test( "accessibility", function () {
equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab (2) has aria-expanded=false" );
equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (2) has aria-hidden=true" );
-});
+} );
asyncTest( "keyboard support", function( assert ) {
expect( 13 );
@@ -180,7 +180,7 @@ asyncTest( "keyboard support", function( assert ) {
}
function step9() {
- equal( element.accordion( "option", "active" ) , 2, "ENTER activates panel" );
+ equal( element.accordion( "option", "active" ), 2, "ENTER activates panel" );
headers.eq( 1 ).simulate( "keydown", { keyCode: keyCode.SPACE } );
setTimeout( step10 );
}
@@ -202,6 +202,6 @@ asyncTest( "keyboard support", function( assert ) {
assert.hasClasses( headers.eq( 1 ), "ui-state-focus", "CTRL+UP moves focus to header" );
start();
}
-});
+} );
} );
diff --git a/tests/unit/accordion/events.js b/tests/unit/accordion/events.js
index 03aee3434..1634b402d 100644
--- a/tests/unit/accordion/events.js
+++ b/tests/unit/accordion/events.js
@@ -16,17 +16,17 @@ test( "create", function() {
headers = element.children( "h3" ),
contents = headers.next();
- element.accordion({
+ element.accordion( {
create: function( event, ui ) {
equal( ui.header.length, 1, "header length" );
strictEqual( ui.header[ 0 ], headers[ 0 ], "header" );
equal( ui.panel.length, 1, "panel length" );
strictEqual( ui.panel[ 0 ], contents[ 0 ], "panel" );
}
- });
+ } );
element.accordion( "destroy" );
- element.accordion({
+ element.accordion( {
active: 2,
create: function( event, ui ) {
equal( ui.header.length, 1, "header length" );
@@ -34,26 +34,26 @@ test( "create", function() {
equal( ui.panel.length, 1, "panel length" );
strictEqual( ui.panel[ 0 ], contents[ 2 ], "panel" );
}
- });
+ } );
element.accordion( "destroy" );
- element.accordion({
+ element.accordion( {
active: false,
collapsible: true,
create: function( event, ui ) {
equal( ui.header.length, 0, "header length" );
equal( ui.panel.length, 0, "panel length" );
}
- });
+ } );
element.accordion( "destroy" );
-});
+} );
test( "beforeActivate", function() {
expect( 38 );
- var element = $( "#list1" ).accordion({
+ var element = $( "#list1" ).accordion( {
active: false,
collapsible: true
- }),
+ } ),
headers = element.find( ".ui-accordion-header" ),
content = element.find( ".ui-accordion-content" );
@@ -66,7 +66,7 @@ test( "beforeActivate", function() {
equal( ui.newPanel.length, 1 );
strictEqual( ui.newPanel[ 0 ], content[ 0 ] );
state( element, 0, 0, 0 );
- });
+ } );
element.accordion( "option", "active", 0 );
state( element, 1, 0, 0 );
@@ -81,7 +81,7 @@ test( "beforeActivate", function() {
equal( ui.newPanel.length, 1 );
strictEqual( ui.newPanel[ 0 ], content[ 1 ] );
state( element, 1, 0, 0 );
- });
+ } );
headers.eq( 1 ).trigger( "click" );
state( element, 0, 1, 0 );
@@ -94,7 +94,7 @@ test( "beforeActivate", function() {
equal( ui.newHeader.length, 0 );
equal( ui.newPanel.length, 0 );
state( element, 0, 1, 0 );
- });
+ } );
element.accordion( "option", "active", false );
state( element, 0, 0, 0 );
@@ -108,17 +108,17 @@ test( "beforeActivate", function() {
strictEqual( ui.newPanel[ 0 ], content[ 2 ] );
event.preventDefault();
state( element, 0, 0, 0 );
- });
+ } );
element.accordion( "option", "active", 2 );
state( element, 0, 0, 0 );
-});
+} );
test( "activate", function() {
expect( 21 );
- var element = $( "#list1" ).accordion({
+ var element = $( "#list1" ).accordion( {
active: false,
collapsible: true
- }),
+ } ),
headers = element.find( ".ui-accordion-header" ),
content = element.find( ".ui-accordion-content" );
@@ -129,7 +129,7 @@ test( "activate", function() {
strictEqual( ui.newHeader[ 0 ], headers[ 0 ] );
equal( ui.newPanel.length, 1 );
strictEqual( ui.newPanel[ 0 ], content[ 0 ] );
- });
+ } );
element.accordion( "option", "active", 0 );
element.one( "accordionactivate", function( event, ui ) {
@@ -141,7 +141,7 @@ test( "activate", function() {
strictEqual( ui.newHeader[ 0 ], headers[ 1 ] );
equal( ui.newPanel.length, 1 );
strictEqual( ui.newPanel[ 0 ], content[ 1 ] );
- });
+ } );
headers.eq( 1 ).trigger( "click" );
element.one( "accordionactivate", function( event, ui ) {
@@ -151,18 +151,18 @@ test( "activate", function() {
strictEqual( ui.oldPanel[ 0 ], content[ 1 ] );
equal( ui.newHeader.length, 0 );
equal( ui.newPanel.length, 0 );
- });
+ } );
element.accordion( "option", "active", false );
- // prevent activation
+ // Prevent activation
element.one( "accordionbeforeactivate", function( event ) {
ok( true );
event.preventDefault();
- });
+ } );
element.one( "accordionactivate", function() {
ok( false );
- });
+ } );
element.accordion( "option", "active", 1 );
-});
+} );
} );
diff --git a/tests/unit/accordion/helper.js b/tests/unit/accordion/helper.js
index ec9b7ecb8..b47510733 100644
--- a/tests/unit/accordion/helper.js
+++ b/tests/unit/accordion/helper.js
@@ -6,9 +6,9 @@ define( [
return $.extend( helper, {
equalHeight: function( accordion, height ) {
- accordion.find( ".ui-accordion-content" ).each(function() {
+ accordion.find( ".ui-accordion-content" ).each( function() {
equal( $( this ).outerHeight(), height );
- });
+ } );
},
setupTeardown: function() {
@@ -25,10 +25,10 @@ return $.extend( helper, {
state: function( accordion ) {
var expected = $.makeArray( arguments ).slice( 1 ),
- actual = accordion.find( ".ui-accordion-content" ).map(function() {
+ actual = accordion.find( ".ui-accordion-content" ).map( function() {
return $( this ).css( "display" ) === "none" ? 0 : 1;
- }).get();
- QUnit.push( QUnit.equiv(actual, expected), actual, expected );
+ } ).get();
+ QUnit.push( QUnit.equiv( actual, expected ), actual, expected );
}
} );
diff --git a/tests/unit/accordion/methods.js b/tests/unit/accordion/methods.js
index 455e80c58..3b1696e45 100644
--- a/tests/unit/accordion/methods.js
+++ b/tests/unit/accordion/methods.js
@@ -14,8 +14,8 @@ test( "destroy", function( assert ) {
expect( 1 );
assert.domEqual( "#list1", function() {
$( "#list1" ).accordion().accordion( "destroy" );
- });
-});
+ } );
+} );
test( "enable/disable", function( assert ) {
expect( 7 );
@@ -28,16 +28,17 @@ test( "enable/disable", function( assert ) {
equal( element.attr( "aria-disabled" ), "true", "element gets aria-disabled" );
assert.hasClasses( element, "ui-accordion-disabled" );
- // event does nothing
+ // Event does nothing
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" );
state( element, 1, 0, 0 );
- // option still works
+
+ // Option still works
element.accordion( "option", "active", 1 );
state( element, 0, 1, 0 );
element.accordion( "enable" );
element.accordion( "option", "active", 2 );
state( element, 0, 0, 1 );
-});
+} );
test( "refresh", function() {
expect( 19 );
@@ -45,9 +46,9 @@ test( "refresh", function() {
.parent()
.height( 300 )
.end()
- .accordion({
+ .accordion( {
heightStyle: "fill"
- });
+ } );
equalHeight( element, 255 );
element.parent().height( 500 );
@@ -58,72 +59,72 @@ test( "refresh", function() {
element.accordion();
state( element, 1, 0, 0 );
- // disable panel via markup
+ // Disable panel via markup
element.find( "h3.bar" ).eq( 1 ).addClass( "ui-state-disabled" );
element.accordion( "refresh" );
state( element, 1, 0, 0 );
- // don't add multiple icons
+ // Don't add multiple icons
element.accordion( "refresh" );
equal( element.find( ".ui-accordion-header-icon" ).length, 3 );
- // add a panel
+ // Add a panel
element
- .append("<h3 class='bar' id='new_1'>new 1</h3>")
- .append("<div class='foo' id='new_1_panel'>new 1</div>");
+ .append( "<h3 class='bar' id='new_1'>new 1</h3>" )
+ .append( "<div class='foo' id='new_1_panel'>new 1</div>" );
element.accordion( "refresh" );
state( element, 1, 0, 0, 0 );
- // remove all tabs
+ // Remove all tabs
element.find( "h3.bar, div.foo" ).remove();
element.accordion( "refresh" );
state( element );
equal( element.accordion( "option", "active" ), false, "no active accordion panel" );
- // add panels
+ // Add panels
element
- .append("<h3 class='bar' id='new_2'>new 2</h3>")
- .append("<div class='foo' id='new_2_panel'>new 2</div>")
- .append("<h3 class='bar' id='new_3'>new 3</h3>")
- .append("<div class='foo' id='new_3_panel'>new 3</div>")
- .append("<h3 class='bar' id='new_4'>new 4</h3>")
- .append("<div class='foo' id='new_4_panel'>new 4</div>")
- .append("<h3 class='bar' id='new_5'>new 5</h3>")
- .append("<div class='foo' id='new_5_panel'>new 5</div>");
+ .append( "<h3 class='bar' id='new_2'>new 2</h3>" )
+ .append( "<div class='foo' id='new_2_panel'>new 2</div>" )
+ .append( "<h3 class='bar' id='new_3'>new 3</h3>" )
+ .append( "<div class='foo' id='new_3_panel'>new 3</div>" )
+ .append( "<h3 class='bar' id='new_4'>new 4</h3>" )
+ .append( "<div class='foo' id='new_4_panel'>new 4</div>" )
+ .append( "<h3 class='bar' id='new_5'>new 5</h3>" )
+ .append( "<div class='foo' id='new_5_panel'>new 5</div>" );
element.accordion( "refresh" );
state( element, 1, 0, 0, 0 );
- // activate third tab
+ // Activate third tab
element.accordion( "option", "active", 2 );
state( element, 0, 0, 1, 0 );
- // remove fourth panel, third panel should stay active
+ // Remove fourth panel, third panel should stay active
element.find( "h3.bar" ).eq( 3 ).remove();
element.find( "div.foo" ).eq( 3 ).remove();
element.accordion( "refresh" );
state( element, 0, 0, 1 );
- // remove third (active) panel, second panel should become active
+ // Remove third (active) panel, second panel should become active
element.find( "h3.bar" ).eq( 2 ).remove();
element.find( "div.foo" ).eq( 2 ).remove();
element.accordion( "refresh" );
state( element, 0, 1 );
- // remove first panel, previously active panel (now first) should stay active
+ // Remove first panel, previously active panel (now first) should stay active
element.find( "h3.bar" ).eq( 0 ).remove();
element.find( "div.foo" ).eq( 0 ).remove();
element.accordion( "refresh" );
state( element, 1 );
- // collapse all panels
+ // Collapse all panels
element.accordion( "option", {
collapsible: true,
active: false
- });
+ } );
state( element, 0 );
element.accordion( "refresh" );
state( element, 0 );
-});
+} );
test( "widget", function() {
expect( 2 );
@@ -131,6 +132,6 @@ test( "widget", function() {
widgetElement = element.accordion( "widget" );
equal( widgetElement.length, 1, "one element" );
strictEqual( widgetElement[ 0 ], element[ 0 ], "same element" );
-});
+} );
} );
diff --git a/tests/unit/accordion/options.js b/tests/unit/accordion/options.js
index 06248d6cb..c9b2e3aaf 100644
--- a/tests/unit/accordion/options.js
+++ b/tests/unit/accordion/options.js
@@ -15,23 +15,23 @@ test( "{ active: default }", function() {
var element = $( "#list1" ).accordion();
equal( element.accordion( "option", "active" ), 0 );
state( element, 1, 0, 0 );
-});
+} );
test( "{ active: null }", function() {
expect( 2 );
- var element = $( "#list1" ).accordion({
+ var element = $( "#list1" ).accordion( {
active: null
- });
+ } );
equal( element.accordion( "option", "active" ), 0 );
state( element, 1, 0, 0 );
-});
+} );
test( "{ active: false }", function() {
expect( 7 );
- var element = $( "#list1" ).accordion({
+ var element = $( "#list1" ).accordion( {
active: false,
collapsible: true
- });
+ } );
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 );
@@ -41,18 +41,18 @@ test( "{ active: false }", function() {
equal( element.accordion( "option", "active" ), 0 );
element.accordion( "destroy" );
- element.accordion({
+ element.accordion( {
active: false
- });
+ } );
state( element, 1, 0, 0 );
strictEqual( element.accordion( "option", "active" ), 0 );
-});
+} );
test( "{ active: Number }", function() {
expect( 8 );
- var element = $( "#list1" ).accordion({
+ var element = $( "#list1" ).accordion( {
active: 2
- });
+ } );
equal( element.accordion( "option", "active" ), 2 );
state( element, 0, 0, 1 );
@@ -67,13 +67,13 @@ test( "{ active: Number }", function() {
element.accordion( "option", "active", 10 );
equal( element.accordion( "option", "active" ), 1 );
state( element, 0, 1, 0 );
-});
+} );
test( "{ active: -Number }", function() {
expect( 8 );
- var element = $( "#list1" ).accordion({
+ var element = $( "#list1" ).accordion( {
active: -1
- });
+ } );
equal( element.accordion( "option", "active" ), 2 );
state( element, 0, 0, 1 );
@@ -88,13 +88,13 @@ test( "{ active: -Number }", function() {
element.accordion( "option", "active", -3 );
equal( element.accordion( "option", "active" ), 0 );
state( element, 1, 0, 0 );
-});
+} );
test( "{ animate: false }", function() {
expect( 3 );
- var element = $( "#list1" ).accordion({
+ var element = $( "#list1" ).accordion( {
animate: false
- }),
+ } ),
panels = element.find( ".ui-accordion-content" ),
animate = $.fn.animate;
$.fn.animate = function() {
@@ -106,16 +106,17 @@ test( "{ animate: false }", function() {
ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
$.fn.animate = animate;
-});
+} );
asyncTest( "{ animate: Number }", function() {
expect( 7 );
- var element = $( "#list1" ).accordion({
+ var element = $( "#list1" ).accordion( {
animate: 100
- }),
+ } ),
panels = element.find( ".ui-accordion-content" ),
animate = $.fn.animate;
- // called twice (both panels)
+
+ // Called twice (both panels)
$.fn.animate = function( props, options ) {
equal( options.duration, 100, "correct duration" );
equal( options.easing, undefined, "default easing" );
@@ -124,22 +125,23 @@ asyncTest( "{ animate: Number }", function() {
ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
element.accordion( "option", "active", 1 );
- panels.promise().done(function() {
+ panels.promise().done( function() {
ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
$.fn.animate = animate;
start();
- });
-});
+ } );
+} );
asyncTest( "{ animate: String }", function() {
expect( 7 );
- var element = $( "#list1" ).accordion({
+ var element = $( "#list1" ).accordion( {
animate: "linear"
- }),
+ } ),
panels = element.find( ".ui-accordion-content" ),
animate = $.fn.animate;
- // called twice (both panels)
+
+ // Called twice (both panels)
$.fn.animate = function( props, options ) {
equal( options.duration, undefined, "default duration" );
equal( options.easing, "linear", "correct easing" );
@@ -148,22 +150,23 @@ asyncTest( "{ animate: String }", function() {
ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
element.accordion( "option", "active", 1 );
- panels.promise().done(function() {
+ panels.promise().done( function() {
ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
$.fn.animate = animate;
start();
- });
-});
+ } );
+} );
asyncTest( "{ animate: {} }", function() {
expect( 7 );
- var element = $( "#list1" ).accordion({
+ var element = $( "#list1" ).accordion( {
animate: {}
- }),
+ } ),
panels = element.find( ".ui-accordion-content" ),
animate = $.fn.animate;
- // called twice (both panels)
+
+ // Called twice (both panels)
$.fn.animate = function( props, options ) {
equal( options.duration, undefined, "default duration" );
equal( options.easing, undefined, "default easing" );
@@ -172,22 +175,23 @@ asyncTest( "{ animate: {} }", function() {
ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
element.accordion( "option", "active", 1 );
- panels.promise().done(function() {
+ panels.promise().done( function() {
ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
$.fn.animate = animate;
start();
- });
-});
+ } );
+} );
asyncTest( "{ animate: { duration, easing } }", function() {
expect( 7 );
- var element = $( "#list1" ).accordion({
+ var element = $( "#list1" ).accordion( {
animate: { duration: 100, easing: "linear" }
- }),
+ } ),
panels = element.find( ".ui-accordion-content" ),
animate = $.fn.animate;
- // called twice (both panels)
+
+ // Called twice (both panels)
$.fn.animate = function( props, options ) {
equal( options.duration, 100, "correct duration" );
equal( options.easing, "linear", "correct easing" );
@@ -196,23 +200,24 @@ asyncTest( "{ animate: { duration, easing } }", function() {
ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
element.accordion( "option", "active", 1 );
- panels.promise().done(function() {
+ panels.promise().done( function() {
ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
$.fn.animate = animate;
start();
- });
-});
+ } );
+} );
asyncTest( "{ animate: { duration, easing } }, animate down", function() {
expect( 7 );
- var element = $( "#list1" ).accordion({
+ var element = $( "#list1" ).accordion( {
active: 1,
animate: { duration: 100, easing: "linear" }
- }),
+ } ),
panels = element.find( ".ui-accordion-content" ),
animate = $.fn.animate;
- // called twice (both panels)
+
+ // Called twice (both panels)
$.fn.animate = function( props, options ) {
equal( options.duration, 100, "correct duration" );
equal( options.easing, "linear", "correct easing" );
@@ -221,17 +226,17 @@ asyncTest( "{ animate: { duration, easing } }, animate down", function() {
ok( panels.eq( 1 ).is( ":visible" ), "first panel visible" );
element.accordion( "option", "active", 0 );
- panels.promise().done(function() {
+ panels.promise().done( function() {
ok( panels.eq( 1 ).is( ":hidden" ), "first panel hidden" );
ok( panels.eq( 0 ).is( ":visible" ), "second panel visible" );
$.fn.animate = animate;
start();
- });
-});
+ } );
+} );
asyncTest( "{ animate: { duration, easing, down } }, animate down", function() {
expect( 7 );
- var element = $( "#list1" ).accordion({
+ var element = $( "#list1" ).accordion( {
active: 1,
animate: {
duration: 100,
@@ -240,10 +245,11 @@ asyncTest( "{ animate: { duration, easing, down } }, animate down", function() {
easing: "swing"
}
}
- }),
+ } ),
panels = element.find( ".ui-accordion-content" ),
animate = $.fn.animate;
- // called twice (both panels)
+
+ // Called twice (both panels)
$.fn.animate = function( props, options ) {
equal( options.duration, 100, "correct duration" );
equal( options.easing, "swing", "correct easing" );
@@ -252,19 +258,19 @@ asyncTest( "{ animate: { duration, easing, down } }, animate down", function() {
ok( panels.eq( 1 ).is( ":visible" ), "first panel visible" );
element.accordion( "option", "active", 0 );
- panels.promise().done(function() {
+ panels.promise().done( function() {
ok( panels.eq( 1 ).is( ":hidden" ), "first panel hidden" );
ok( panels.eq( 0 ).is( ":visible" ), "second panel visible" );
$.fn.animate = animate;
start();
- });
-});
+ } );
+} );
test( "{ collapsible: false }", function() {
expect( 4 );
- var element = $( "#list1" ).accordion({
+ var element = $( "#list1" ).accordion( {
active: 1
- });
+ } );
element.accordion( "option", "active", false );
equal( element.accordion( "option", "active" ), 1 );
state( element, 0, 1, 0 );
@@ -272,14 +278,14 @@ test( "{ collapsible: false }", function() {
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" );
equal( element.accordion( "option", "active" ), 1 );
state( element, 0, 1, 0 );
-});
+} );
test( "{ collapsible: true }", function() {
expect( 6 );
- var element = $( "#list1" ).accordion({
+ var element = $( "#list1" ).accordion( {
active: 1,
collapsible: true
- });
+ } );
element.accordion( "option", "active", false );
equal( element.accordion( "option", "active" ), false );
@@ -292,37 +298,37 @@ test( "{ collapsible: true }", function() {
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" );
equal( element.accordion( "option", "active" ), false );
state( element, 0, 0, 0 );
-});
+} );
test( "{ event: null }", function() {
expect( 5 );
- var element = $( "#list1" ).accordion({
+ var element = $( "#list1" ).accordion( {
event: null
- });
+ } );
state( element, 1, 0, 0 );
element.accordion( "option", "active", 1 );
equal( element.accordion( "option", "active" ), 1 );
state( element, 0, 1, 0 );
- // ensure default click handler isn't bound
+ // Ensure default click handler isn't bound
element.find( ".ui-accordion-header" ).eq( 2 ).trigger( "click" );
equal( element.accordion( "option", "active" ), 1 );
state( element, 0, 1, 0 );
-});
+} );
test( "{ event: custom }", function() {
expect( 11 );
- var element = $( "#list1" ).accordion({
+ var element = $( "#list1" ).accordion( {
event: "custom1 custom2"
- });
+ } );
state( element, 1, 0, 0 );
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom1" );
equal( element.accordion( "option", "active" ), 1 );
state( element, 0, 1, 0 );
- // ensure default click handler isn't bound
+ // Ensure default click handler isn't bound
element.find( ".ui-accordion-header" ).eq( 2 ).trigger( "click" );
equal( element.accordion( "option", "active" ), 1 );
state( element, 0, 1, 0 );
@@ -333,7 +339,7 @@ test( "{ event: custom }", function() {
element.accordion( "option", "event", "custom3" );
- // ensure old event handlers are unbound
+ // Ensure old event handlers are unbound
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom1" );
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom2" );
equal( element.accordion( "option", "active" ), 2 );
@@ -342,126 +348,128 @@ test( "{ event: custom }", function() {
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom3" );
equal( element.accordion( "option", "active" ), 1 );
state( element, 0, 1, 0 );
-});
+} );
test( "{ header: default }", function() {
expect( 2 );
- // default: > li > :first-child,> :not(li):even
+
+ // Default: > li > :first-child,> :not(li):even
// > :not(li):even
- state( $( "#list1" ).accordion(), 1, 0, 0);
+ state( $( "#list1" ).accordion(), 1, 0, 0 );
+
// > li > :first-child
- state( $( "#navigation" ).accordion(), 1, 0, 0);
-});
+ state( $( "#navigation" ).accordion(), 1, 0, 0 );
+} );
test( "{ header: custom }", function( assert ) {
expect( 6 );
- var element = $( "#navigationWrapper" ).accordion({
+ var element = $( "#navigationWrapper" ).accordion( {
header: "h2"
- });
- element.find( "h2" ).each(function() {
+ } );
+ element.find( "h2" ).each( function() {
assert.hasClasses( this, "ui-accordion-header" );
- });
+ } );
equal( element.find( ".ui-accordion-header" ).length, 3 );
state( element, 1, 0, 0 );
element.accordion( "option", "active", 2 );
state( element, 0, 0, 1 );
-});
+} );
test( "{ heightStyle: 'auto' }", function() {
expect( 3 );
- var element = $( "#navigation" ).accordion({ heightStyle: "auto" });
+ var element = $( "#navigation" ).accordion( { heightStyle: "auto" } );
equalHeight( element, 105 );
-});
+} );
test( "{ heightStyle: 'content' }", function() {
expect( 3 );
- var element = $( "#navigation" ).accordion({ heightStyle: "content" }),
- sizes = element.find( ".ui-accordion-content" ).map(function() {
+ var element = $( "#navigation" ).accordion( { heightStyle: "content" } ),
+ sizes = element.find( ".ui-accordion-content" ).map( function() {
return $( this ).height();
- }).get();
+ } ).get();
equal( sizes[ 0 ], 75 );
equal( sizes[ 1 ], 105 );
equal( sizes[ 2 ], 45 );
-});
+} );
test( "{ heightStyle: 'fill' }", function() {
expect( 3 );
$( "#navigationWrapper" ).height( 500 );
- var element = $( "#navigation" ).accordion({ heightStyle: "fill" });
+ var element = $( "#navigation" ).accordion( { heightStyle: "fill" } );
equalHeight( element, 455 );
-});
+} );
test( "{ heightStyle: 'fill' } with sibling", function() {
expect( 3 );
$( "#navigationWrapper" ).height( 500 );
$( "<p>Lorem Ipsum</p>" )
- .css({
+ .css( {
height: 50,
marginTop: 20,
marginBottom: 30
- })
+ } )
.prependTo( "#navigationWrapper" );
- var element = $( "#navigation" ).accordion({ heightStyle: "fill" });
- equalHeight( element , 355 );
-});
+ var element = $( "#navigation" ).accordion( { heightStyle: "fill" } );
+ equalHeight( element, 355 );
+} );
test( "{ heightStyle: 'fill' } with multiple siblings", function() {
expect( 3 );
$( "#navigationWrapper" ).height( 500 );
$( "<p>Lorem Ipsum</p>" )
- .css({
+ .css( {
height: 50,
marginTop: 20,
marginBottom: 30
- })
+ } )
.prependTo( "#navigationWrapper" );
$( "<p>Lorem Ipsum</p>" )
- .css({
+ .css( {
height: 50,
marginTop: 20,
marginBottom: 30,
position: "absolute"
- })
+ } )
.prependTo( "#navigationWrapper" );
$( "<p>Lorem Ipsum</p>" )
- .css({
+ .css( {
height: 25,
marginTop: 10,
marginBottom: 15
- })
+ } )
.prependTo( "#navigationWrapper" );
- var element = $( "#navigation" ).accordion({ heightStyle: "fill" });
+ var element = $( "#navigation" ).accordion( { heightStyle: "fill" } );
equalHeight( element, 305 );
-});
+} );
test( "{ icons: false }", function() {
expect( 8 );
var element = $( "#list1" );
function icons( on ) {
- deepEqual( element.find( "span.ui-icon").length, on ? 3 : 0 );
+ deepEqual( element.find( "span.ui-icon" ).length, on ? 3 : 0 );
deepEqual( element.find( ".ui-accordion-header.ui-accordion-icons" ).length, on ? 3 : 0 );
}
element.accordion();
icons( true );
- element.accordion( "destroy" ).accordion({
+ element.accordion( "destroy" ).accordion( {
icons: false
- });
+ } );
icons( false );
element.accordion( "option", "icons", { header: "foo", activeHeader: "bar" } );
icons( true );
element.accordion( "option", "icons", false );
icons( false );
-});
+} );
test( "{ icons: hash }", function( assert ) {
expect( 3 );
- var element = $( "#list1" ).accordion({
+ var element = $( "#list1" ).accordion( {
icons: { activeHeader: "a1", header: "h1" }
- });
+ } );
assert.hasClasses( element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ), "a1" );
element.accordion( "option", "icons", { activeHeader: "a2", header: "h2" } );
- assert.lacksClasses( element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ), "a1");
+ assert.lacksClasses( element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ), "a1" );
assert.hasClasses( element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ), "a2" );
-});
+} );
} );
diff --git a/tests/unit/autocomplete/common.js b/tests/unit/autocomplete/common.js
index 94e98048d..a4d57f95d 100644
--- a/tests/unit/autocomplete/common.js
+++ b/tests/unit/autocomplete/common.js
@@ -22,7 +22,7 @@ common.testWidget( "autocomplete", {
},
source: null,
- // callbacks
+ // Callbacks
change: null,
close: null,
create: null,
@@ -32,6 +32,6 @@ common.testWidget( "autocomplete", {
search: null,
select: null
}
-});
+} );
} );
diff --git a/tests/unit/autocomplete/core.js b/tests/unit/autocomplete/core.js
index d57f2a980..41be5ae6a 100644
--- a/tests/unit/autocomplete/core.js
+++ b/tests/unit/autocomplete/core.js
@@ -12,15 +12,15 @@ test( "markup structure", function( assert ) {
assert.hasClasses( element, "ui-autocomplete-input" );
assert.hasClasses( menu, "ui-autocomplete ui-widget ui-widget-content" );
-});
+} );
test( "prevent form submit on enter when menu is active", function() {
expect( 2 );
var event,
element = $( "#autocomplete" )
- .autocomplete({
+ .autocomplete( {
source: [ "java", "javascript" ]
- })
+ } )
.val( "ja" )
.autocomplete( "search" ),
menu = element.autocomplete( "widget" );
@@ -35,16 +35,16 @@ test( "prevent form submit on enter when menu is active", function() {
event.keyCode = $.ui.keyCode.ENTER;
element.trigger( event );
ok( event.isDefaultPrevented(), "default action is prevented" );
-});
+} );
test( "allow form submit on enter when menu is not active", function() {
expect( 1 );
var event,
element = $( "#autocomplete" )
- .autocomplete({
+ .autocomplete( {
autoFocus: false,
source: [ "java", "javascript" ]
- })
+ } )
.val( "ja" )
.autocomplete( "search" );
@@ -52,90 +52,90 @@ test( "allow form submit on enter when menu is not active", function() {
event.keyCode = $.ui.keyCode.ENTER;
element.trigger( event );
ok( !event.isDefaultPrevented(), "default action is prevented" );
-});
+} );
-(function() {
+( function() {
test( "up arrow invokes search - input", function() {
arrowsInvokeSearch( "#autocomplete", true, true );
- });
+ } );
test( "down arrow invokes search - input", function() {
arrowsInvokeSearch( "#autocomplete", false, true );
- });
+ } );
test( "up arrow invokes search - textarea", function() {
arrowsInvokeSearch( "#autocomplete-textarea", true, false );
- });
+ } );
test( "down arrow invokes search - textarea", function() {
arrowsInvokeSearch( "#autocomplete-textarea", false, false );
- });
+ } );
test( "up arrow invokes search - contenteditable", function() {
arrowsInvokeSearch( "#autocomplete-contenteditable", true, false );
- });
+ } );
test( "down arrow invokes search - contenteditable", function() {
arrowsInvokeSearch( "#autocomplete-contenteditable", false, false );
- });
+ } );
test( "up arrow moves focus - input", function() {
arrowsMoveFocus( "#autocomplete", true );
- });
+ } );
test( "down arrow moves focus - input", function() {
arrowsMoveFocus( "#autocomplete", false );
- });
+ } );
test( "up arrow moves focus - textarea", function() {
arrowsMoveFocus( "#autocomplete-textarea", true );
- });
+ } );
test( "down arrow moves focus - textarea", function() {
arrowsMoveFocus( "#autocomplete-textarea", false );
- });
+ } );
test( "up arrow moves focus - contenteditable", function() {
arrowsMoveFocus( "#autocomplete-contenteditable", true );
- });
+ } );
test( "down arrow moves focus - contenteditable", function() {
arrowsMoveFocus( "#autocomplete-contenteditable", false );
- });
+ } );
test( "up arrow moves cursor - input", function() {
arrowsNavigateElement( "#autocomplete", true, false );
- });
+ } );
test( "down arrow moves cursor - input", function() {
arrowsNavigateElement( "#autocomplete", false, false );
- });
+ } );
test( "up arrow moves cursor - textarea", function() {
arrowsNavigateElement( "#autocomplete-textarea", true, true );
- });
+ } );
test( "down arrow moves cursor - textarea", function() {
arrowsNavigateElement( "#autocomplete-textarea", false, true );
- });
+ } );
test( "up arrow moves cursor - contenteditable", function() {
arrowsNavigateElement( "#autocomplete-contenteditable", true, true );
- });
+ } );
test( "down arrow moves cursor - contenteditable", function() {
arrowsNavigateElement( "#autocomplete-contenteditable", false, true );
- });
+ } );
function arrowsInvokeSearch( id, isKeyUp, shouldMove ) {
expect( 1 );
var didMove = false,
- element = $( id ).autocomplete({
+ element = $( id ).autocomplete( {
source: [ "a" ],
delay: 0,
minLength: 0
- });
+ } );
element.autocomplete( "instance" )._move = function() {
didMove = true;
};
@@ -146,11 +146,11 @@ test( "allow form submit on enter when menu is not active", function() {
function arrowsMoveFocus( id, isKeyUp ) {
expect( 1 );
- var element = $( id ).autocomplete({
+ var element = $( id ).autocomplete( {
source: [ "a" ],
delay: 0,
minLength: 0
- });
+ } );
element.autocomplete( "instance" )._move = function() {
ok( true, "repsond to arrow" );
};
@@ -162,25 +162,25 @@ test( "allow form submit on enter when menu is not active", function() {
expect( 1 );
var didMove = false,
- element = $( id ).autocomplete({
+ element = $( id ).autocomplete( {
source: [ "a" ],
delay: 0,
minLength: 0
- });
+ } );
element.on( "keypress", function( e ) {
didMove = !e.isDefaultPrevented();
- });
+ } );
element.simulate( "keydown", { keyCode: ( isKeyUp ? $.ui.keyCode.UP : $.ui.keyCode.DOWN ) } );
element.simulate( "keypress" );
equal( didMove, shouldMove, "respond to arrow" );
}
-})();
+} )();
asyncTest( "past end of menu in multiline autocomplete", function() {
expect( 2 );
var customVal = "custom value",
- element = $( "#autocomplete-contenteditable" ).autocomplete({
+ element = $( "#autocomplete-contenteditable" ).autocomplete( {
delay: 0,
source: [ "javascript" ],
focus: function( event, ui ) {
@@ -188,25 +188,25 @@ asyncTest( "past end of menu in multiline autocomplete", function() {
$( this ).text( customVal );
event.preventDefault();
}
- });
+ } );
element
.simulate( "focus" )
.autocomplete( "search", "ja" );
- setTimeout(function() {
+ setTimeout( function() {
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
equal( element.text(), customVal );
start();
- });
-});
+ } );
+} );
asyncTest( "ESCAPE in multiline autocomplete", function() {
expect( 2 );
var customVal = "custom value",
- element = $( "#autocomplete-contenteditable" ).autocomplete({
+ element = $( "#autocomplete-contenteditable" ).autocomplete( {
delay: 0,
source: [ "javascript" ],
focus: function( event, ui ) {
@@ -214,38 +214,38 @@ asyncTest( "ESCAPE in multiline autocomplete", function() {
$( this ).text( customVal );
event.preventDefault();
}
- });
+ } );
element
.simulate( "focus" )
.autocomplete( "search", "ja" );
- setTimeout(function() {
+ setTimeout( function() {
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
equal( element.text(), customVal );
start();
- });
-});
+ } );
+} );
asyncTest( "handle race condition", function() {
expect( 3 );
var count = 0,
- element = $( "#autocomplete" ).autocomplete({
+ 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( function() {
+ response( [ "one" ] );
setTimeout( checkResults );
- });
+ } );
return;
}
equal( count, 2, "request with 2 characters is second" );
- response([ "two" ]);
+ response( [ "two" ] );
}
- });
+ } );
element.autocomplete( "search", "a" );
element.autocomplete( "search", "ab" );
@@ -255,41 +255,41 @@ asyncTest( "handle race condition", function() {
"correct results displayed" );
start();
}
-});
+} );
asyncTest( "simultaneous searches (#9334)", function() {
expect( 2 );
- var element = $( "#autocomplete" ).autocomplete({
+ var element = $( "#autocomplete" ).autocomplete( {
source: function( request, response ) {
- setTimeout(function() {
- response([ request.term ]);
- });
+ setTimeout( function() {
+ response( [ request.term ] );
+ } );
},
response: function() {
ok( true, "response from first instance" );
}
- }),
- element2 = $( "#autocomplete-textarea" ).autocomplete({
+ } ),
+ element2 = $( "#autocomplete-textarea" ).autocomplete( {
source: function( request, response ) {
- setTimeout(function() {
- response([ request.term ]);
- });
+ setTimeout( function() {
+ response( [ request.term ] );
+ } );
},
response: function() {
ok( true, "response from second instance" );
start();
}
- });
+ } );
element.autocomplete( "search", "test" );
element2.autocomplete( "search", "test" );
-});
+} );
test( "ARIA", function() {
expect( 13 );
- var element = $( "#autocomplete" ).autocomplete({
+ var element = $( "#autocomplete" ).autocomplete( {
source: [ "java", "javascript" ]
- }),
+ } ),
liveRegion = element.autocomplete( "instance" ).liveRegion;
equal( liveRegion.children().length, 0, "Empty live region on create" );
@@ -311,7 +311,7 @@ test( "ARIA", function() {
element.one( "autocompletefocus", function( event ) {
event.preventDefault();
- });
+ } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
equal( liveRegion.children().filter( ":visible" ).text(), "javascript",
"Live region updated when default focus is prevented" );
@@ -335,7 +335,7 @@ test( "ARIA", function() {
element.autocomplete( "destroy" );
equal( liveRegion.parent().length, 0,
"The liveRegion should be detached after destroy" );
-});
+} );
test( "ARIA, aria-label announcement", function() {
expect( 1 );
@@ -345,27 +345,27 @@ test( "ARIA, aria-label announcement", function() {
$.each( items, function( index, item ) {
that._renderItemData( ul, item )
.attr( "aria-label", item.category + " : " + item.label );
- });
+ } );
}
- });
- var element = $( "#autocomplete" ).catcomplete({
+ } );
+ var element = $( "#autocomplete" ).catcomplete( {
source: [ { label: "anders andersson", category: "People" } ]
- }),
+ } ),
liveRegion = element.catcomplete( "instance" ).liveRegion;
element.catcomplete( "search", "a" );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
equal( liveRegion.children().filter( ":visible" ).text(), "People : anders andersson",
"Live region changed on keydown to announce the highlighted value's aria-label attribute" );
-});
+} );
test( "ARIA, init on detached input", function() {
expect( 1 );
- var element = $( "<input>" ).autocomplete({
+ var element = $( "<input>" ).autocomplete( {
source: [ "java", "javascript" ]
- }),
+ } ),
liveRegion = element.autocomplete( "instance" ).liveRegion;
equal( liveRegion.parent().length, 1, "liveRegion must have a parent" );
-});
+} );
test( ".replaceWith() (#9172)", function() {
expect( 1 );
@@ -375,27 +375,27 @@ test( ".replaceWith() (#9172)", function() {
parent = element.parent();
element.replaceWith( replacement );
equal( parent.html().toLowerCase(), replacement );
-});
+} );
asyncTest( "Search if the user retypes the same value (#7434)", function() {
expect( 3 );
- var element = $( "#autocomplete" ).autocomplete({
+ var element = $( "#autocomplete" ).autocomplete( {
source: [ "java", "javascript" ],
delay: 0
- }),
+ } ),
menu = element.autocomplete( "instance" ).menu.element;
element.val( "j" ).simulate( "keydown" );
- setTimeout(function() {
+ setTimeout( function() {
ok( menu.is( ":visible" ), "menu displays initially" );
element.trigger( "blur" );
ok( !menu.is( ":visible" ), "menu hidden after blur" );
element.val( "j" ).simulate( "keydown" );
- setTimeout(function() {
+ setTimeout( function() {
ok( menu.is( ":visible" ), "menu displays after typing the same value" );
start();
- });
- });
-});
+ } );
+ } );
+} );
} );
diff --git a/tests/unit/autocomplete/events.js b/tests/unit/autocomplete/events.js
index 59d5dd540..688763f7e 100644
--- a/tests/unit/autocomplete/events.js
+++ b/tests/unit/autocomplete/events.js
@@ -7,7 +7,7 @@ module( "autocomplete: events" );
var data = [ "Clojure", "COBOL", "ColdFusion", "Java", "JavaScript", "Scala", "Scheme" ];
-$.each([
+$.each( [
{
type: "input",
selector: "#autocomplete",
@@ -27,7 +27,7 @@ $.each([
asyncTest( "all events - " + settings.type, function() {
expect( 13 );
var element = $( settings.selector )
- .autocomplete({
+ .autocomplete( {
autoFocus: false,
delay: 0,
source: data,
@@ -63,40 +63,41 @@ $.each([
ok( menu.is( ":hidden" ), "menu closed on change" );
start();
}
- }),
+ } ),
menu = element.autocomplete( "widget" );
element.simulate( "focus" )[ settings.valueMethod ]( "j" ).trigger( "keydown" );
- setTimeout(function() {
+ setTimeout( function() {
ok( menu.is( ":visible" ), "menu is visible after delay" );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- // blur must be async for IE to handle it properly
- setTimeout(function() {
+
+ // Blur must be async for IE to handle it properly
+ setTimeout( function() {
element.simulate( "blur" );
- });
- });
- });
-});
+ } );
+ } );
+ } );
+} );
asyncTest( "change without selection", function() {
expect( 1 );
- var element = $( "#autocomplete" ).autocomplete({
+ var element = $( "#autocomplete" ).autocomplete( {
delay: 0,
source: data,
change: function( event, ui ) {
strictEqual( ui.item, null );
start();
}
- });
+ } );
element.triggerHandler( "focus" );
element.val( "ja" ).triggerHandler( "blur" );
-});
+} );
asyncTest( "cancel search", function() {
expect( 6 );
var first = true,
- element = $( "#autocomplete" ).autocomplete({
+ element = $( "#autocomplete" ).autocomplete( {
delay: 0,
source: data,
search: function() {
@@ -110,76 +111,76 @@ asyncTest( "cancel search", function() {
open: function() {
ok( true, "menu opened" );
}
- }),
+ } ),
menu = element.autocomplete( "widget" );
element.val( "ja" ).trigger( "keydown" );
- setTimeout(function() {
+ setTimeout( function() {
ok( menu.is( ":hidden" ), "menu is hidden after first search" );
element.val( "java" ).trigger( "keydown" );
- setTimeout(function() {
+ setTimeout( function() {
ok( menu.is( ":visible" ), "menu is visible after second search" );
equal( menu.find( ".ui-menu-item" ).length, 2, "# of menu items" );
start();
- });
- });
-});
+ } );
+ } );
+} );
asyncTest( "cancel focus", function() {
expect( 1 );
var customVal = "custom value",
- element = $( "#autocomplete" ).autocomplete({
+ element = $( "#autocomplete" ).autocomplete( {
delay: 0,
source: data,
focus: function() {
$( this ).val( customVal );
return false;
}
- });
+ } );
element.val( "ja" ).trigger( "keydown" );
- setTimeout(function() {
+ setTimeout( function() {
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
equal( element.val(), customVal );
start();
- });
-});
+ } );
+} );
asyncTest( "cancel select", function() {
expect( 1 );
var customVal = "custom value",
- element = $( "#autocomplete" ).autocomplete({
+ element = $( "#autocomplete" ).autocomplete( {
delay: 0,
source: data,
select: function() {
$( this ).val( customVal );
return false;
}
- });
+ } );
element.val( "ja" ).trigger( "keydown" );
- setTimeout(function() {
+ setTimeout( function() {
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
equal( element.val(), customVal );
start();
- });
-});
+ } );
+} );
asyncTest( "blur during remote search", function() {
expect( 1 );
- var ac = $( "#autocomplete" ).autocomplete({
+ var ac = $( "#autocomplete" ).autocomplete( {
delay: 0,
source: function( request, response ) {
ok( true, "trigger request" );
ac.simulate( "blur" );
- setTimeout(function() {
- response([ "result" ]);
+ setTimeout( function() {
+ response( [ "result" ] );
start();
- }, 25);
+ }, 25 );
},
open: function() {
ok( false, "opened after a blur" );
}
- });
+ } );
ac.val( "ro" ).trigger( "keydown" );
-});
+} );
} );
diff --git a/tests/unit/autocomplete/methods.js b/tests/unit/autocomplete/methods.js
index f614c13cd..0ebdc0d7e 100644
--- a/tests/unit/autocomplete/methods.js
+++ b/tests/unit/autocomplete/methods.js
@@ -9,16 +9,16 @@ test( "destroy", function( assert ) {
expect( 1 );
assert.domEqual( "#autocomplete", function() {
$( "#autocomplete" ).autocomplete().autocomplete( "destroy" );
- });
-});
+ } );
+} );
test( "search, close", function() {
expect( 6 );
var data = [ "c++", "java", "php", "coldfusion", "javascript", "asp", "ruby", "python", "c", "scala", "groovy", "haskell", "perl" ],
- element = $( "#autocomplete" ).autocomplete({
+ element = $( "#autocomplete" ).autocomplete( {
source: data,
minLength: 0
- }),
+ } ),
menu = element.autocomplete( "widget" );
ok( menu.is( ":hidden" ), "menu is hidden on init" );
@@ -35,7 +35,7 @@ test( "search, close", function() {
element.autocomplete( "close" );
ok( menu.is( ":hidden" ), "menu is hidden after close" );
-});
+} );
test( "widget", function( assert ) {
expect( 2 );
@@ -43,6 +43,6 @@ test( "widget", function( assert ) {
widgetElement = element.autocomplete( "widget" );
equal( widgetElement.length, 1, "one element" );
assert.hasClasses( widgetElement, "ui-menu" );
-});
+} );
} );
diff --git a/tests/unit/autocomplete/options.js b/tests/unit/autocomplete/options.js
index 7d281fb31..76c13e754 100644
--- a/tests/unit/autocomplete/options.js
+++ b/tests/unit/autocomplete/options.js
@@ -14,16 +14,16 @@ test( "appendTo: null", function() {
equal( element.autocomplete( "widget" ).parent()[ 0 ], document.body,
"defaults to body" );
element.autocomplete( "destroy" );
-});
+} );
test( "appendTo: explicit", function() {
expect( 6 );
var detached = $( "<div>" ),
element = $( "#autocomplete" );
- element.autocomplete({
+ element.autocomplete( {
appendTo: ".autocomplete-wrap"
- });
+ } );
equal( element.autocomplete( "widget" ).parent()[ 0 ],
$( "#autocomplete-wrap1" )[ 0 ], "first found element" );
equal( $( "#autocomplete-wrap2 .ui-autocomplete" ).length, 0,
@@ -35,16 +35,16 @@ test( "appendTo: explicit", function() {
$( "#autocomplete-wrap1" )[ 0 ], "modified after init" );
element.autocomplete( "destroy" );
- element.autocomplete({
+ element.autocomplete( {
appendTo: detached
- });
+ } );
equal( element.autocomplete( "widget" ).parent()[ 0 ], detached[ 0 ],
"detached jQuery object" );
element.autocomplete( "destroy" );
- element.autocomplete({
+ element.autocomplete( {
appendTo: detached[ 0 ]
- });
+ } );
equal( element.autocomplete( "widget" ).parent()[ 0 ], detached[ 0 ],
"detached DOM element" );
element.autocomplete( "destroy" );
@@ -53,7 +53,7 @@ test( "appendTo: explicit", function() {
equal( element.autocomplete( "widget" ).parent()[ 0 ], detached[ 0 ],
"detached DOM element via option()" );
element.autocomplete( "destroy" );
-});
+} );
test( "appendTo: ui-front", function() {
expect( 2 );
@@ -65,15 +65,15 @@ test( "appendTo: ui-front", function() {
$( "#autocomplete-wrap2" )[ 0 ], "null, inside .ui-front" );
element.autocomplete( "destroy" );
- element.autocomplete({
+ element.autocomplete( {
appendTo: $()
- });
+ } );
equal( element.autocomplete( "widget" ).parent()[ 0 ],
$( "#autocomplete-wrap2" )[ 0 ], "empty jQuery object, inside .ui-front" );
-});
+} );
function autoFocusTest( afValue, focusedLength ) {
- var element = $( "#autocomplete" ).autocomplete({
+ var element = $( "#autocomplete" ).autocomplete( {
autoFocus: afValue,
delay: 0,
source: data,
@@ -83,10 +83,10 @@ function autoFocusTest( afValue, focusedLength ) {
.find( ".ui-menu-item-wrapper.ui-state-active" )
.length,
focusedLength,
- "first item is " + (afValue ? "" : "not") + " auto focused" );
+ "first item is " + ( afValue ? "" : "not" ) + " auto focused" );
start();
}
- });
+ } );
element.val( "ja" ).trigger( "keydown" );
stop();
}
@@ -94,36 +94,36 @@ function autoFocusTest( afValue, focusedLength ) {
test( "autoFocus: false", function() {
expect( 1 );
autoFocusTest( false, 0 );
-});
+} );
test( "autoFocus: true", function() {
expect( 1 );
autoFocusTest( true, 1 );
-});
+} );
asyncTest( "delay", function() {
expect( 2 );
- var element = $( "#autocomplete" ).autocomplete({
+ var element = $( "#autocomplete" ).autocomplete( {
source: data,
delay: 25
- }),
+ } ),
menu = element.autocomplete( "widget" );
element.val( "ja" ).trigger( "keydown" );
ok( menu.is( ":hidden" ), "menu is closed immediately after search" );
- setTimeout(function() {
+ setTimeout( function() {
ok( menu.is( ":visible" ), "menu is open after delay" );
start();
}, 50 );
-});
+} );
asyncTest( "disabled", function( assert ) {
expect( 5 );
- var element = $( "#autocomplete" ).autocomplete({
+ var element = $( "#autocomplete" ).autocomplete( {
source: data,
delay: 0
- }),
+ } ),
menu = element.autocomplete( "disable" ).autocomplete( "widget" );
element.val( "ja" ).trigger( "keydown" );
@@ -133,17 +133,17 @@ asyncTest( "disabled", function( assert ) {
assert.hasClasses( menu, "ui-autocomplete-disabled" );
ok( !element.attr( "aria-disabled" ), "element doesn't get aria-disabled" );
- setTimeout(function() {
+ setTimeout( function() {
ok( menu.is( ":hidden" ) );
start();
- });
-});
+ } );
+} );
test( "minLength", function() {
expect( 2 );
- var element = $( "#autocomplete" ).autocomplete({
+ var element = $( "#autocomplete" ).autocomplete( {
source: data
- }),
+ } ),
menu = element.autocomplete( "widget" );
element.autocomplete( "search", "" );
ok( menu.is( ":hidden" ), "blank not enough for minLength: 1" );
@@ -151,19 +151,19 @@ test( "minLength", function() {
element.autocomplete( "option", "minLength", 0 );
element.autocomplete( "search", "" );
ok( menu.is( ":visible" ), "blank enough for minLength: 0" );
-});
+} );
asyncTest( "minLength, exceed then drop below", function() {
expect( 4 );
- var element = $( "#autocomplete" ).autocomplete({
+ var element = $( "#autocomplete" ).autocomplete( {
minLength: 2,
source: function( req, res ) {
equal( req.term, "12", "correct search term" );
- setTimeout(function() {
- res([ "item" ]);
- });
+ setTimeout( function() {
+ res( [ "item" ] );
+ } );
}
- }),
+ } ),
menu = element.autocomplete( "widget" );
ok( menu.is( ":hidden" ), "menu is hidden before first search" );
@@ -172,55 +172,57 @@ asyncTest( "minLength, exceed then drop below", function() {
ok( menu.is( ":hidden" ), "menu is hidden before second search" );
element.autocomplete( "search", "1" );
- setTimeout(function() {
+ setTimeout( function() {
ok( menu.is( ":hidden" ), "menu is hidden after searches" );
start();
- });
-});
+ } );
+} );
test( "minLength, exceed then drop below then exceed", function() {
expect( 3 );
var _res = [],
- element = $( "#autocomplete" ).autocomplete({
+ element = $( "#autocomplete" ).autocomplete( {
minLength: 2,
source: function( req, res ) {
_res.push( res );
}
- }),
+ } ),
menu = element.autocomplete( "widget" );
- // trigger a valid search
+ // Trigger a valid search
ok( menu.is( ":hidden" ), "menu is hidden before first search" );
element.autocomplete( "search", "12" );
- // trigger a search below the minLength, to turn on cancelSearch flag
+ // Trigger a search below the minLength, to turn on cancelSearch flag
ok( menu.is( ":hidden" ), "menu is hidden before second search" );
element.autocomplete( "search", "1" );
- // trigger a valid search
+ // Trigger a valid search
element.autocomplete( "search", "13" );
- // react as if the first search was cancelled (default ajax behavior)
- _res[ 0 ]([]);
- // react to second search
- _res[ 1 ]([ "13" ]);
+
+ // React as if the first search was cancelled (default ajax behavior)
+ _res[ 0 ]( [] );
+
+ // React to second search
+ _res[ 1 ]( [ "13" ] );
ok( menu.is( ":visible" ), "menu is visible after searches" );
-});
+} );
test( "source, local string array", function() {
expect( 1 );
- var element = $( "#autocomplete" ).autocomplete({
+ var element = $( "#autocomplete" ).autocomplete( {
source: data
- }),
+ } ),
menu = element.autocomplete( "widget" );
element.val( "ja" ).autocomplete( "search" );
equal( menu.find( ".ui-menu-item" ).text(), "javajavascript" );
-});
+} );
function sourceTest( source, async ) {
- var element = $( "#autocomplete" ).autocomplete({
+ var element = $( "#autocomplete" ).autocomplete( {
source: source
- }),
+ } ),
menu = element.autocomplete( "widget" );
function result() {
var items = menu.find( ".ui-menu-item" );
@@ -228,15 +230,15 @@ function sourceTest( source, async ) {
deepEqual( items.eq( 0 ).data( "ui-autocomplete-item" ), {
label: "java",
value: "java"
- });
+ } );
deepEqual( items.eq( 1 ).data( "ui-autocomplete-item" ), {
label: "javascript",
value: "javascript"
- });
+ } );
deepEqual( items.eq( 2 ).data( "ui-autocomplete-item" ), {
label: "clojure",
value: "clojure"
- });
+ } );
element.autocomplete( "destroy" );
if ( async ) {
start();
@@ -254,64 +256,64 @@ function sourceTest( source, async ) {
test( "source, local object array, only labels", function() {
expect( 4 );
- sourceTest([
+ sourceTest( [
{ label: "java", value: null },
{ label: "php", value: null },
{ label: "coldfusion", value: "" },
{ label: "javascript", value: "" },
{ label: "clojure" }
- ]);
-});
+ ] );
+} );
test( "source, local object array, only values", function() {
expect( 4 );
- sourceTest([
+ sourceTest( [
{ value: "java", label: null },
{ value: "php", label: null },
{ value: "coldfusion", label: "" },
{ value: "javascript", label: "" },
{ value: "clojure" }
- ]);
-});
+ ] );
+} );
test( "source, url string with remote json string array", function() {
expect( 4 );
sourceTest( "remote_string_array.txt", true );
-});
+} );
test( "source, url string with remote json object array, only value properties", function() {
expect( 4 );
sourceTest( "remote_object_array_values.txt", true );
-});
+} );
test( "source, url string with remote json object array, only label properties", function() {
expect( 4 );
sourceTest( "remote_object_array_labels.txt", true );
-});
+} );
test( "source, custom", function() {
expect( 5 );
- sourceTest(function( request, response ) {
+ sourceTest( function( request, response ) {
equal( request.term, "j" );
- response([
+ response( [
"java",
{ label: "javascript", value: null },
{ value: "clojure", label: null }
- ]);
- });
-});
+ ] );
+ } );
+} );
test( "source, update after init", function() {
expect( 2 );
- var element = $( "#autocomplete" ).autocomplete({
+ var element = $( "#autocomplete" ).autocomplete( {
source: [ "java", "javascript", "haskell" ]
- }),
+ } ),
menu = element.autocomplete( "widget" );
element.val( "ja" ).autocomplete( "search" );
equal( menu.find( ".ui-menu-item" ).text(), "javajavascript" );
element.autocomplete( "option", "source", [ "php", "asp" ] );
element.val( "ph" ).autocomplete( "search" );
equal( menu.find( ".ui-menu-item" ).text(), "php" );
-});
+} );
} );
diff --git a/tests/unit/button/common.js b/tests/unit/button/common.js
index 0372cddbf..4ef136fac 100644
--- a/tests/unit/button/common.js
+++ b/tests/unit/button/common.js
@@ -14,9 +14,9 @@ common.testWidget( "button", {
label: null,
text: true,
- // callbacks
+ // Callbacks
create: null
}
-});
+} );
} );
diff --git a/tests/unit/button/core.js b/tests/unit/button/core.js
index f3ae2e583..f4e5d35a7 100644
--- a/tests/unit/button/core.js
+++ b/tests/unit/button/core.js
@@ -3,58 +3,58 @@ define( [
"ui/widgets/button"
], function( $ ) {
-module("button: core");
+module( "button: core" );
-test("checkbox", function( assert ) {
+test( "checkbox", function( assert ) {
expect( 4 );
- var input = $("#check"),
- label = $("label[for=check]");
- ok( input.is(":visible") );
- ok( label.is(":not(.ui-button)") );
+ var input = $( "#check" ),
+ label = $( "label[for=check]" );
+ ok( input.is( ":visible" ) );
+ ok( label.is( ":not(.ui-button)" ) );
input.button();
assert.hasClasses( input, "ui-helper-hidden-accessible" );
assert.hasClasses( label, "ui-button" );
-});
+} );
-test("radios", function( assert ) {
+test( "radios", function( assert ) {
expect( 8 );
- var inputs = $("#radio0 input"),
- labels = $("#radio0 label");
- ok( inputs.is(":visible") );
- ok( labels.is(":not(.ui-button)") );
+ var inputs = $( "#radio0 input" ),
+ labels = $( "#radio0 label" );
+ ok( inputs.is( ":visible" ) );
+ ok( labels.is( ":not(.ui-button)" ) );
inputs.button();
- inputs.each(function() {
+ inputs.each( function() {
assert.hasClasses( this, "ui-helper-hidden-accessible" );
- });
- labels.each(function() {
+ } );
+ labels.each( function() {
assert.hasClasses( this, "ui-button" );
- });
-});
+ } );
+} );
-test("radio groups", function( assert ) {
+test( "radio groups", function( assert ) {
expect( 12 );
- function assertClasses(noForm, form1, form2) {
- assert.hasClasses( $("#radio0 .ui-button" + noForm ), "ui-state-active" );
- assert.hasClasses( $("#radio1 .ui-button" + form1 ), "ui-state-active" );
- assert.hasClasses( $("#radio2 .ui-button" + form2 ), "ui-state-active" );
+ function assertClasses( noForm, form1, form2 ) {
+ assert.hasClasses( $( "#radio0 .ui-button" + noForm ), "ui-state-active" );
+ assert.hasClasses( $( "#radio1 .ui-button" + form1 ), "ui-state-active" );
+ assert.hasClasses( $( "#radio2 .ui-button" + form2 ), "ui-state-active" );
}
- $("input[type=radio]").button();
- assertClasses(":eq(0)", ":eq(1)", ":eq(2)");
+ $( "input[type=radio]" ).button();
+ assertClasses( ":eq(0)", ":eq(1)", ":eq(2)" );
- // click outside of forms
- $("#radio0 .ui-button:eq(1)").trigger( "click" );
- assertClasses(":eq(1)", ":eq(1)", ":eq(2)");
+ // Click outside of forms
+ $( "#radio0 .ui-button:eq(1)" ).trigger( "click" );
+ assertClasses( ":eq(1)", ":eq(1)", ":eq(2)" );
- // click in first form
- $("#radio1 .ui-button:eq(0)").trigger( "click" );
- assertClasses(":eq(1)", ":eq(0)", ":eq(2)");
+ // Click in first form
+ $( "#radio1 .ui-button:eq(0)" ).trigger( "click" );
+ assertClasses( ":eq(1)", ":eq(0)", ":eq(2)" );
- // click in second form
- $("#radio2 .ui-button:eq(0)").trigger( "click" );
- assertClasses(":eq(1)", ":eq(0)", ":eq(0)");
-});
+ // Click in second form
+ $( "#radio2 .ui-button:eq(0)" ).trigger( "click" );
+ assertClasses( ":eq(1)", ":eq(0)", ":eq(0)" );
+} );
test( "radio groups - ignore elements with same name", function() {
expect( 1 );
@@ -63,47 +63,48 @@ test( "radio groups - ignore elements with same name", function() {
checkbox = $( "<input>", {
type: "checkbox",
name: radios.attr( "name" )
- });
+ } );
form.append( checkbox );
radios.button( "refresh" );
ok( true, "no exception from accessing button instance of checkbox" );
-});
+} );
-test("input type submit, don't create child elements", function() {
+test( "input type submit, don't create child elements", function() {
expect( 2 );
- var input = $("#submit");
+ var input = $( "#submit" );
deepEqual( input.children().length, 0 );
input.button();
deepEqual( input.children().length, 0 );
-});
+} );
-test("buttonset", function( assert ) {
+test( "buttonset", function( assert ) {
expect( 6 );
- var set = $("#radio1").buttonset();
+ var set = $( "#radio1" ).buttonset();
assert.hasClasses( set, "ui-buttonset" );
- deepEqual( set.children(".ui-button").length, 3 );
- deepEqual( set.children("input[type=radio].ui-helper-hidden-accessible").length, 3 );
- ok( set.children("label:eq(0)").is(".ui-button.ui-corner-left:not(.ui-corner-all)") );
- ok( set.children("label:eq(1)").is(".ui-button:not(.ui-corner-all)") );
- ok( set.children("label:eq(2)").is(".ui-button.ui-corner-right:not(.ui-corner-all)") );
-});
-
-test("buttonset (rtl)", function( assert ) {
+ deepEqual( set.children( ".ui-button" ).length, 3 );
+ deepEqual( set.children( "input[type=radio].ui-helper-hidden-accessible" ).length, 3 );
+ ok( set.children( "label:eq(0)" ).is( ".ui-button.ui-corner-left:not(.ui-corner-all)" ) );
+ ok( set.children( "label:eq(1)" ).is( ".ui-button:not(.ui-corner-all)" ) );
+ ok( set.children( "label:eq(2)" ).is( ".ui-button.ui-corner-right:not(.ui-corner-all)" ) );
+} );
+
+test( "buttonset (rtl)", function( assert ) {
expect( 6 );
var set,
- parent = $("#radio1").parent();
+ parent = $( "#radio1" ).parent();
+
// Set to rtl
- parent.attr("dir", "rtl");
+ parent.attr( "dir", "rtl" );
- set = $("#radio1").buttonset();
+ set = $( "#radio1" ).buttonset();
assert.hasClasses( set, "ui-buttonset" );
- deepEqual( set.children(".ui-button").length, 3 );
- deepEqual( set.children("input[type=radio].ui-helper-hidden-accessible").length, 3 );
- ok( set.children("label:eq(0)").is(".ui-button.ui-corner-right:not(.ui-corner-all)") );
- ok( set.children("label:eq(1)").is(".ui-button:not(.ui-corner-all)") );
- ok( set.children("label:eq(2)").is(".ui-button.ui-corner-left:not(.ui-corner-all)") );
-});
+ deepEqual( set.children( ".ui-button" ).length, 3 );
+ deepEqual( set.children( "input[type=radio].ui-helper-hidden-accessible" ).length, 3 );
+ ok( set.children( "label:eq(0)" ).is( ".ui-button.ui-corner-right:not(.ui-corner-all)" ) );
+ ok( set.children( "label:eq(1)" ).is( ".ui-button:not(.ui-corner-all)" ) );
+ ok( set.children( "label:eq(2)" ).is( ".ui-button.ui-corner-left:not(.ui-corner-all)" ) );
+} );
// TODO: simulated click events don't behave like real click events in IE
// remove this when simulate properly simulates this
@@ -112,22 +113,22 @@ if ( !$.ui.ie || ( document.documentMode && document.documentMode > 8 ) ) {
asyncTest( "ensure checked and aria after single click on checkbox label button, see #5518", function( assert ) {
expect( 3 );
- $("#check2").button().on( "change", function() {
- var lbl = $( this ).button("widget");
+ $( "#check2" ).button().on( "change", function() {
+ var lbl = $( this ).button( "widget" );
ok( this.checked, "checked ok" );
- ok( lbl.attr("aria-pressed") === "true", "aria ok" );
+ ok( lbl.attr( "aria-pressed" ) === "true", "aria ok" );
assert.hasClasses( lbl, "ui-state-active" );
- });
+ } );
- // support: Opera
+ // Support: Opera
// Opera doesn't trigger a change event when this is done synchronously.
// This seems to be a side effect of another test, but until that can be
// tracked down, this delay will have to do.
- setTimeout(function() {
- $("#check2").button("widget").simulate("click");
+ setTimeout( function() {
+ $( "#check2" ).button( "widget" ).simulate( "click" );
start();
}, 1 );
- });
+ } );
}
test( "#7092 - button creation that requires a matching label does not find label in all cases", function( assert ) {
@@ -151,15 +152,15 @@ test( "#7092 - button creation that requires a matching label does not find labe
group = $( "<input type='checkbox' id='t7092e'><span><label for='t7092e'></label></span>" );
group.filter( "input[type=checkbox]" ).button();
assert.hasClasses( group.find( "label" ), "ui-button" );
-});
+} );
test( "#5946 - buttonset should ignore buttons that are not :visible", function( assert ) {
expect( 2 );
$( "#radio01" ).next().addBack().hide();
- var set = $( "#radio0" ).buttonset({ items: "input[type=radio]:visible" });
+ var set = $( "#radio0" ).buttonset( { items: "input[type=radio]:visible" } );
ok( set.find( "label:eq(0)" ).is( ":not(.ui-button):not(.ui-corner-left)" ) );
assert.hasClasses( set.find( "label:eq(1)" ), "ui-button ui-corner-left" );
-});
+} );
test( "#6262 - buttonset not applying ui-corner to invisible elements", function( assert ) {
expect( 3 );
@@ -169,7 +170,7 @@ test( "#6262 - buttonset not applying ui-corner to invisible elements", function
assert.hasClasses( set.find( "label:eq(1)" ), "ui-button" );
assert.hasClasses( set.find( "label:eq(2)" ), "ui-button ui-corner-right" );
-});
+} );
asyncTest( "Resetting a button's form should refresh the visual state of the button widget to match.", function( assert ) {
expect( 2 );
@@ -185,15 +186,15 @@ asyncTest( "Resetting a button's form should refresh the visual state of the but
form.get( 0 ).reset();
- // #9213: If a button has been removed, refresh should not be called on it when
+ // If a button has been removed, refresh should not be called on it when
// its corresponding form is reset.
button.remove();
- setTimeout(function() {
+ setTimeout( function() {
assert.hasClasses( checkbox.button( "widget" ), "ui-state-active" );
start();
}, 1 );
-});
+} );
asyncTest( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyboard Navigation", function( assert ) {
expect( 2 );
@@ -201,30 +202,30 @@ asyncTest( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyb
label = $( "label[for='check']" );
assert.lacksClasses( label, "ui-state-focus" );
check.trigger( "focus" );
- setTimeout(function() {
+ setTimeout( function() {
assert.hasClasses( label, "ui-state-focus" );
start();
- });
-});
+ } );
+} );
test( "#7534 - Button label selector works for ids with \":\"", function( assert ) {
expect( 1 );
var group = $( "<span><input type='checkbox' id='check:7534'><label for='check:7534'>Label</label></span>" );
group.find( "input" ).button();
- assert.hasClasses( group.find( "label" ), "ui-button" , "Found an id with a :" );
-});
+ assert.hasClasses( group.find( "label" ), "ui-button", "Found an id with a :" );
+} );
asyncTest( "#9169 - Disabled button maintains ui-state-focus", function( assert ) {
expect( 2 );
var element = $( "#button1" ).button();
element[ 0 ].focus();
- setTimeout(function() {
+ setTimeout( function() {
assert.hasClasses( element, "ui-state-focus" );
element.button( "disable" );
assert.lacksClasses( element, "ui-state-focus",
"button does not have ui-state-focus when disabled" );
start();
- });
-});
+ } );
+} );
} );
diff --git a/tests/unit/button/events.js b/tests/unit/button/events.js
index d778b4a2b..15a285046 100644
--- a/tests/unit/button/events.js
+++ b/tests/unit/button/events.js
@@ -3,15 +3,15 @@ define( [
"ui/widgets/button"
], function( $ ) {
-module("button: events");
+module( "button: events" );
-test("buttonset works with single-quote named elements (#7505)", function() {
+test( "buttonset works with single-quote named elements (#7505)", function() {
expect( 1 );
- $("#radio3").buttonset();
- $("#radio33").on( "click", function(){
+ $( "#radio3" ).buttonset();
+ $( "#radio33" ).on( "click", function() {
ok( true, "button clicks work with single-quote named elements" );
- }).trigger( "click" );
-});
+ } ).trigger( "click" );
+} );
asyncTest( "when button loses focus, ensure active state is removed (#8559)", function( assert ) {
expect( 1 );
@@ -22,15 +22,15 @@ asyncTest( "when button loses focus, ensure active state is removed (#8559)", fu
element.one( "blur", function() {
assert.lacksClasses( element, "ui-state-active", "button loses active state appropriately" );
start();
- }).trigger( "blur" );
- });
+ } ).trigger( "blur" );
+ } );
element.trigger( "focus" );
- setTimeout(function() {
+ setTimeout( function() {
element
.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } )
.simulate( "keypress", { keyCode: $.ui.keyCode.ENTER } );
- });
-});
+ } );
+} );
} );
diff --git a/tests/unit/button/methods.js b/tests/unit/button/methods.js
index 29e917022..0bafd90f9 100644
--- a/tests/unit/button/methods.js
+++ b/tests/unit/button/methods.js
@@ -3,50 +3,50 @@ define( [
"ui/widgets/button"
], function( $ ) {
-module("button: methods");
+module( "button: methods" );
-test("destroy", function( assert ) {
+test( "destroy", function( assert ) {
expect( 1 );
assert.domEqual( "#button", function() {
$( "#button" ).button().button( "destroy" );
- });
-});
+ } );
+} );
test( "refresh: Ensure disabled state is preserved correctly.", function() {
expect( 8 );
var element = $( "<a href='#'></a>" );
- element.button({ disabled: true }).button( "refresh" );
+ element.button( { disabled: true } ).button( "refresh" );
ok( element.button( "option", "disabled" ), "Anchor button should remain disabled after refresh" ); //See #8237
element = $( "<div></div>" );
- element.button({ disabled: true }).button( "refresh" );
+ element.button( { disabled: true } ).button( "refresh" );
ok( element.button( "option", "disabled" ), "<div> buttons should remain disabled after refresh" );
element = $( "<button></button>" );
- element.button( { disabled: true} ).button( "refresh" );
- ok( element.button( "option", "disabled" ), "<button> should remain disabled after refresh");
+ element.button( { disabled: true } ).button( "refresh" );
+ ok( element.button( "option", "disabled" ), "<button> should remain disabled after refresh" );
element = $( "<input type='checkbox'>" );
- element.button( { disabled: true} ).button( "refresh" );
- ok( element.button( "option", "disabled" ), "Checkboxes should remain disabled after refresh");
+ element.button( { disabled: true } ).button( "refresh" );
+ ok( element.button( "option", "disabled" ), "Checkboxes should remain disabled after refresh" );
element = $( "<input type='radio'>" );
- element.button( { disabled: true} ).button( "refresh" );
- ok( element.button( "option", "disabled" ), "Radio buttons should remain disabled after refresh");
+ element.button( { disabled: true } ).button( "refresh" );
+ ok( element.button( "option", "disabled" ), "Radio buttons should remain disabled after refresh" );
element = $( "<button></button>" );
- element.button( { disabled: true} ).prop( "disabled", false ).button( "refresh" );
- ok( !element.button( "option", "disabled" ), "Changing a <button>'s disabled property should update the state after refresh."); //See #8828
+ element.button( { disabled: true } ).prop( "disabled", false ).button( "refresh" );
+ ok( !element.button( "option", "disabled" ), "Changing a <button>'s disabled property should update the state after refresh." ); //See #8828
element = $( "<input type='checkbox'>" );
- element.button( { disabled: true} ).prop( "disabled", false ).button( "refresh" );
- ok( !element.button( "option", "disabled" ), "Changing a checkbox's disabled property should update the state after refresh.");
+ element.button( { disabled: true } ).prop( "disabled", false ).button( "refresh" );
+ ok( !element.button( "option", "disabled" ), "Changing a checkbox's disabled property should update the state after refresh." );
element = $( "<input type='radio'>" );
- element.button( { disabled: true} ).prop( "disabled", false ).button( "refresh" );
- ok( !element.button( "option", "disabled" ), "Changing a radio button's disabled property should update the state after refresh.");
-});
+ element.button( { disabled: true } ).prop( "disabled", false ).button( "refresh" );
+ ok( !element.button( "option", "disabled" ), "Changing a radio button's disabled property should update the state after refresh." );
+} );
// #8975
test( "refresh: buttonset should turn added elements into button widgets", function() {
@@ -68,6 +68,6 @@ test( "refresh: buttonset should turn added elements into button widgets", funct
equal( radioButtonset.find( ":ui-button" ).length, 4, "radio" );
equal( checkboxButtonset.find( ":ui-button" ).length, 4, "checkbox" );
-});
+} );
} );
diff --git a/tests/unit/button/options.js b/tests/unit/button/options.js
index ad4169e14..31542427c 100644
--- a/tests/unit/button/options.js
+++ b/tests/unit/button/options.js
@@ -8,33 +8,33 @@ module( "button: options" );
test( "disabled, explicit value", function( assert ) {
expect( 7 );
- var element = $( "#radio01" ).button({ disabled: false });
+ var element = $( "#radio01" ).button( { disabled: false } );
deepEqual( element.button( "option", "disabled" ), false, "disabled option set to false" );
deepEqual( element.prop( "disabled" ), false, "element is disabled" );
assert.lacksClasses( element.button( "widget" ), "ui-state-disabled ui-button-disabled" );
- element = $( "#radio02" ).button({ disabled: true });
+ element = $( "#radio02" ).button( { disabled: true } );
ok( !element.button( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" );
assert.hasClasses( element.button( "widget" ), "ui-button-disabled ui-state-disabled" );
deepEqual( element.button( "option", "disabled" ), true, "disabled option set to true" );
deepEqual( element.prop( "disabled" ), true, "element is not disabled" );
-});
+} );
-test("disabled, null", function() {
+test( "disabled, null", function() {
expect( 4 );
- $("#radio01").button({ disabled: null });
- deepEqual(false, $("#radio01").button("option", "disabled"),
- "disabled option set to false");
- deepEqual(false, $("#radio01").prop("disabled"), "element is disabled");
-
- $("#radio02").prop("disabled", true).button({ disabled: null });
- deepEqual(true, $("#radio02").button("option", "disabled"),
- "disabled option set to true");
- deepEqual(true, $("#radio02").prop("disabled"), "element is not disabled");
-});
+ $( "#radio01" ).button( { disabled: null } );
+ deepEqual( false, $( "#radio01" ).button( "option", "disabled" ),
+ "disabled option set to false" );
+ deepEqual( false, $( "#radio01" ).prop( "disabled" ), "element is disabled" );
+
+ $( "#radio02" ).prop( "disabled", true ).button( { disabled: null } );
+ deepEqual( true, $( "#radio02" ).button( "option", "disabled" ),
+ "disabled option set to true" );
+ deepEqual( true, $( "#radio02" ).prop( "disabled" ), "element is not disabled" );
+} );
test( "disabled, ui-state-active is removed unless checkbox or radio", function( assert ) {
expect( 12 );
@@ -68,90 +68,90 @@ test( "disabled, ui-state-active is removed unless checkbox or radio", function(
assert.lacksClasses( buttonElement, "ui-state-active",
"Disabled [" + elementType + "] does not have ui-state-active class." );
}
- });
-});
+ } );
+} );
-test("text false without icon", function() {
+test( "text false without icon", function() {
expect( 1 );
- $("#button").button({
+ $( "#button" ).button( {
text: false
- });
- ok( $("#button").is(".ui-button-text-only:not(.ui-button-icon-only)") );
+ } );
+ ok( $( "#button" ).is( ".ui-button-text-only:not(.ui-button-icon-only)" ) );
- $("#button").button("destroy");
-});
+ $( "#button" ).button( "destroy" );
+} );
-test("text false with icon", function() {
+test( "text false with icon", function() {
expect( 1 );
- $("#button").button({
+ $( "#button" ).button( {
text: false,
icons: {
primary: "iconclass"
}
- });
- ok( $("#button").is(".ui-button-icon-only:not(.ui-button-text):has(span.ui-icon.iconclass)") );
+ } );
+ ok( $( "#button" ).is( ".ui-button-icon-only:not(.ui-button-text):has(span.ui-icon.iconclass)" ) );
- $("#button").button("destroy");
-});
+ $( "#button" ).button( "destroy" );
+} );
-test("label, default", function() {
+test( "label, default", function() {
expect( 2 );
- $("#button").button();
- deepEqual( $("#button").text(), "Label" );
- deepEqual( $( "#button").button( "option", "label" ), "Label" );
+ $( "#button" ).button();
+ deepEqual( $( "#button" ).text(), "Label" );
+ deepEqual( $( "#button" ).button( "option", "label" ), "Label" );
- $("#button").button("destroy");
-});
+ $( "#button" ).button( "destroy" );
+} );
-test("label", function() {
+test( "label", function() {
expect( 2 );
- $("#button").button({
+ $( "#button" ).button( {
label: "xxx"
- });
- deepEqual( $("#button").text(), "xxx" );
- deepEqual( $("#button").button( "option", "label" ), "xxx" );
+ } );
+ deepEqual( $( "#button" ).text(), "xxx" );
+ deepEqual( $( "#button" ).button( "option", "label" ), "xxx" );
- $("#button").button("destroy");
-});
+ $( "#button" ).button( "destroy" );
+} );
-test("label default with input type submit", function() {
+test( "label default with input type submit", function() {
expect( 2 );
- deepEqual( $("#submit").button().val(), "Label" );
- deepEqual( $("#submit").button( "option", "label" ), "Label" );
-});
+ deepEqual( $( "#submit" ).button().val(), "Label" );
+ deepEqual( $( "#submit" ).button( "option", "label" ), "Label" );
+} );
-test("label with input type submit", function() {
+test( "label with input type submit", function() {
expect( 2 );
- var label = $("#submit").button({
+ var label = $( "#submit" ).button( {
label: "xxx"
- }).val();
+ } ).val();
deepEqual( label, "xxx" );
- deepEqual( $("#submit").button( "option", "label" ), "xxx" );
-});
+ deepEqual( $( "#submit" ).button( "option", "label" ), "xxx" );
+} );
-test("icons", function() {
+test( "icons", function() {
expect( 1 );
- $("#button").button({
+ $( "#button" ).button( {
text: false,
icons: {
primary: "iconclass",
secondary: "iconclass2"
}
- });
- ok( $("#button").is(":has(span.ui-icon.ui-button-icon-primary.iconclass):has(span.ui-icon.ui-button-icon-secondary.iconclass2)") );
+ } );
+ ok( $( "#button" ).is( ":has(span.ui-icon.ui-button-icon-primary.iconclass):has(span.ui-icon.ui-button-icon-secondary.iconclass2)" ) );
- $("#button").button("destroy");
-});
+ $( "#button" ).button( "destroy" );
+} );
-test( "#5295 - button does not remove hoverstate if disabled" , function( assert ) {
+test( "#5295 - button does not remove hoverstate if disabled", function( assert ) {
expect( 1 );
- var btn = $("#button").button();
+ var btn = $( "#button" ).button();
btn.on( "hover", function() {
btn.button( "disable" );
- });
+ } );
btn.trigger( "mouseenter" );
btn.trigger( "mouseleave" );
assert.lacksClasses( btn, "ui-state-hover" );
-});
+} );
} );
diff --git a/tests/unit/core/core.html b/tests/unit/core/core.html
index 366eecebe..93f0156fd 100644
--- a/tests/unit/core/core.html
+++ b/tests/unit/core/core.html
@@ -80,6 +80,21 @@
<div id="visibilityHiddenAncestor" style="visibility: hidden;">
<input id="visibilityHiddenAncestor-input">
<span tabindex="1" id="visibilityHiddenAncestor-span">.</span>
+
+ <span id="nestedVisibilityOverrideAncestor" style="visibility: visible;">
+ <input id="nestedVisibilityOverrideAncestor-input">
+ <span tabindex="1" id="nestedVisibilityOverrideAncestor-span">.</span>
+ </span>
+
+ <span tabIndex="1" id="nestedVisibilityInheritWithHiddenAncestor"
+ style="visibility: inherit;">.</span>
+ <input id="nestedVisibilityInheritWithHiddenAncestor-input" style="visibility: inherit;">
+ </div>
+
+ <div id="visibilityVisibleAncestor" style="visibility: visible;">
+ <span tabIndex="1" id="nestedVisibilityInheritWithVisibleAncestor"
+ style="visibility: inherit;">.</span>
+ <input id="nestedVisibilityInheritWithVisibleAncestor-input" style="visibility: inherit;">
</div>
<span tabindex="1" id="displayNone-span" style="display: none;">.</span>
diff --git a/tests/unit/core/core.js b/tests/unit/core/core.js
index d1b65403e..c21a4e050 100644
--- a/tests/unit/core/core.js
+++ b/tests/unit/core/core.js
@@ -17,7 +17,7 @@ test( "innerWidth - getter", function() {
equal( el.innerWidth(), 122, "getter passthru" );
el.hide();
equal( el.innerWidth(), 122, "getter passthru when hidden" );
-});
+} );
test( "innerWidth - setter", function() {
expect( 2 );
@@ -28,7 +28,7 @@ test( "innerWidth - setter", function() {
el.hide();
el.innerWidth( 100 );
equal( el.width(), 78, "width set properly when hidden" );
-});
+} );
test( "innerHeight - getter", function() {
expect( 2 );
@@ -37,7 +37,7 @@ test( "innerHeight - getter", function() {
equal( el.innerHeight(), 70, "getter passthru" );
el.hide();
equal( el.innerHeight(), 70, "getter passthru when hidden" );
-});
+} );
test( "innerHeight - setter", function() {
expect( 2 );
@@ -48,7 +48,7 @@ test( "innerHeight - setter", function() {
el.hide();
el.innerHeight( 50 );
equal( el.height(), 30, "height set properly when hidden" );
-});
+} );
test( "outerWidth - getter", function() {
expect( 2 );
@@ -57,7 +57,7 @@ test( "outerWidth - getter", function() {
equal( el.outerWidth(), 140, "getter passthru" );
el.hide();
equal( el.outerWidth(), 140, "getter passthru when hidden" );
-});
+} );
test( "outerWidth - setter", function() {
expect( 2 );
@@ -68,16 +68,16 @@ test( "outerWidth - setter", function() {
el.hide();
el.outerWidth( 120 );
equal( el.width(), 80, "width set properly when hidden" );
-});
+} );
test( "outerWidth(true) - getter", function() {
expect( 2 );
var el = $( "#dimensions" );
- equal( el.outerWidth(true), 154, "getter passthru w/ margin" );
+ equal( el.outerWidth( true ), 154, "getter passthru w/ margin" );
el.hide();
- equal( el.outerWidth(true), 154, "getter passthru w/ margin when hidden" );
-});
+ equal( el.outerWidth( true ), 154, "getter passthru w/ margin when hidden" );
+} );
test( "outerWidth(true) - setter", function() {
expect( 2 );
@@ -88,7 +88,7 @@ test( "outerWidth(true) - setter", function() {
el.hide();
el.outerWidth( 120, true );
equal( el.width(), 66, "width set properly when hidden" );
-});
+} );
test( "outerHeight - getter", function() {
expect( 2 );
@@ -97,7 +97,7 @@ test( "outerHeight - getter", function() {
equal( el.outerHeight(), 86, "getter passthru" );
el.hide();
equal( el.outerHeight(), 86, "getter passthru when hidden" );
-});
+} );
test( "outerHeight - setter", function() {
expect( 2 );
@@ -108,16 +108,16 @@ test( "outerHeight - setter", function() {
el.hide();
el.outerHeight( 70 );
equal( el.height(), 34, "height set properly when hidden" );
-});
+} );
test( "outerHeight(true) - getter", function() {
expect( 2 );
var el = $( "#dimensions" );
- equal( el.outerHeight(true), 98, "getter passthru w/ margin" );
+ equal( el.outerHeight( true ), 98, "getter passthru w/ margin" );
el.hide();
- equal( el.outerHeight(true), 98, "getter passthru w/ margin when hidden" );
-});
+ equal( el.outerHeight( true ), 98, "getter passthru w/ margin when hidden" );
+} );
test( "outerHeight(true) - setter", function() {
expect( 2 );
@@ -128,7 +128,7 @@ test( "outerHeight(true) - setter", function() {
el.hide();
el.outerHeight( 80, true );
equal( el.height(), 32, "height set properly when hidden" );
-});
+} );
test( "uniqueId / removeUniqueId", function() {
expect( 3 );
@@ -138,7 +138,7 @@ test( "uniqueId / removeUniqueId", function() {
ok( /ui-id-\d+$/.test( el.attr( "id" ) ), "element has generated id" );
el.removeUniqueId();
equal( el.attr( "id" ), null, "unique id has been removed from element" );
-});
+} );
test( "Labels", function() {
expect( 2 );
diff --git a/tests/unit/core/selector.js b/tests/unit/core/selector.js
index e553e769d..52d1902ff 100644
--- a/tests/unit/core/selector.js
+++ b/tests/unit/core/selector.js
@@ -14,7 +14,7 @@ function isFocusable( selector, msg ) {
}
function isNotFocusable( selector, msg ) {
- QUnit.push( $( selector ).length && !$( selector ).is(":focusable"), null, null,
+ QUnit.push( $( selector ).length && !$( selector ).is( ":focusable" ), null, null,
msg + " - selector " + selector + " is not focusable" );
}
@@ -85,10 +85,10 @@ test( "data", function() {
element = $( "<div>" ).data( "test", function() {} );
shouldHaveData( "data set to function" );
-});
+} );
test( "focusable - visible, enabled elements", function() {
- expect( 18 );
+ expect( 20 );
isNotFocusable( "#formNoTabindex", "form" );
isFocusable( "#formTabindex", "form with tabindex" );
@@ -108,7 +108,11 @@ test( "focusable - visible, enabled elements", function() {
isNotFocusable( "#visibleAncestor-div", "div" );
isFocusable( "#visibleAncestor-spanWithTabindex", "span with tabindex" );
isFocusable( "#visibleAncestor-divWithNegativeTabindex", "div with tabindex" );
-});
+ isFocusable( "#nestedVisibilityInheritWithVisibleAncestor",
+ "span, visibility: inherit inside visibility: visible parent" );
+ isFocusable( "#nestedVisibilityInheritWithVisibleAncestor-input",
+ "input, visibility: inherit inside visibility: visible parent" );
+} );
test( "focusable - disabled elements", function() {
expect( 9 );
@@ -122,10 +126,10 @@ test( "focusable - disabled elements", function() {
isNotFocusable( "#disabledElement-button", "button" );
isNotFocusable( "#disabledElement-select", "select" );
isNotFocusable( "#disabledElement-textarea", "textarea" );
-});
+} );
test( "focusable - hidden styles", function() {
- expect( 8 );
+ expect( 12 );
isNotFocusable( "#displayNoneAncestor-input", "input, display: none parent" );
isNotFocusable( "#displayNoneAncestor-span", "span with tabindex, display: none parent" );
@@ -133,12 +137,18 @@ test( "focusable - hidden styles", function() {
isNotFocusable( "#visibilityHiddenAncestor-input", "input, visibility: hidden parent" );
isNotFocusable( "#visibilityHiddenAncestor-span", "span with tabindex, visibility: hidden parent" );
+ isFocusable( "#nestedVisibilityOverrideAncestor-input", "input, visibility: visible parent but visibility: hidden grandparent" );
+ isFocusable( "#nestedVisibilityOverrideAncestor-span", "span with tabindex, visibility: visible parent but visibility: hidden grandparent " );
+
+ isNotFocusable( "#nestedVisibilityInheritWithHiddenAncestor", "span, visibility: inherit inside visibility: hidden parent" );
+ isNotFocusable( "#nestedVisibilityInheritWithHiddenAncestor-input", "input, visibility: inherit inside 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 );
@@ -147,7 +157,7 @@ test( "focusable - natively focusable with various tabindex", function() {
isFocusable( "#inputTabindex10", "input, tabindex 10" );
isFocusable( "#inputTabindex-1", "input, tabindex -1" );
isFocusable( "#inputTabindex-50", "input, tabindex -50" );
-});
+} );
test( "focusable - not natively focusable with various tabindex", function() {
expect( 4 );
@@ -156,7 +166,7 @@ test( "focusable - not natively focusable with various tabindex", function() {
isFocusable( "#spanTabindex10", "span, tabindex 10" );
isFocusable( "#spanTabindex-1", "span, tabindex -1" );
isFocusable( "#spanTabindex-50", "span, tabindex -50" );
-});
+} );
test( "focusable - area elements", function() {
expect( 3 );
@@ -164,13 +174,13 @@ test( "focusable - area elements", function() {
isFocusable( "#areaCoordsHref", "coords and href" );
isFocusable( "#areaNoCoordsHref", "href but no coords" );
isNotFocusable( "#areaNoImg", "not associated with an image" );
-});
+} );
test( "focusable - dimensionless parent with overflow", function() {
expect( 1 );
isFocusable( "#dimensionlessParent", "input" );
-});
+} );
test( "tabbable - visible, enabled elements", function() {
expect( 18 );
@@ -193,7 +203,7 @@ test( "tabbable - visible, enabled elements", function() {
isNotTabbable( "#visibleAncestor-div", "div" );
isTabbable( "#visibleAncestor-spanWithTabindex", "span with tabindex" );
isNotTabbable( "#visibleAncestor-divWithNegativeTabindex", "div with tabindex" );
-});
+} );
test( "tabbable - disabled elements", function() {
expect( 9 );
@@ -207,10 +217,10 @@ test( "tabbable - disabled elements", function() {
isNotTabbable( "#disabledElement-button", "button" );
isNotTabbable( "#disabledElement-select", "select" );
isNotTabbable( "#disabledElement-textarea", "textarea" );
-});
+} );
test( "tabbable - hidden styles", function() {
- expect( 8 );
+ expect( 10 );
isNotTabbable( "#displayNoneAncestor-input", "input, display: none parent" );
isNotTabbable( "#displayNoneAncestor-span", "span with tabindex, display: none parent" );
@@ -218,12 +228,15 @@ test( "tabbable - hidden styles", function() {
isNotTabbable( "#visibilityHiddenAncestor-input", "input, visibility: hidden parent" );
isNotTabbable( "#visibilityHiddenAncestor-span", "span with tabindex, visibility: hidden parent" );
+ isTabbable( "#nestedVisibilityOverrideAncestor-input", "input, visibility: visible parent but visibility: hidden grandparent" );
+ isTabbable( "#nestedVisibilityOverrideAncestor-span", "span with tabindex, visibility: visible parent but visibility: hidden grandparent " );
+
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 );
@@ -232,7 +245,7 @@ test( "tabbable - natively tabbable with various tabindex", function() {
isTabbable( "#inputTabindex10", "input, tabindex 10" );
isNotTabbable( "#inputTabindex-1", "input, tabindex -1" );
isNotTabbable( "#inputTabindex-50", "input, tabindex -50" );
-});
+} );
test( "tabbable - not natively tabbable with various tabindex", function() {
expect( 4 );
@@ -241,7 +254,7 @@ test( "tabbable - not natively tabbable with various tabindex", function() {
isTabbable( "#spanTabindex10", "span, tabindex 10" );
isNotTabbable( "#spanTabindex-1", "span, tabindex -1" );
isNotTabbable( "#spanTabindex-50", "span, tabindex -50" );
-});
+} );
test( "tabbable - area elements", function() {
expect( 3 );
@@ -249,13 +262,13 @@ test( "tabbable - area elements", function() {
isTabbable( "#areaCoordsHref", "coords and href" );
isTabbable( "#areaNoCoordsHref", "href but no coords" );
isNotTabbable( "#areaNoImg", "not associated with an image" );
-});
+} );
test( "tabbable - dimensionless parent with overflow", function() {
expect( 1 );
isTabbable( "#dimensionlessParent", "input" );
-});
+} );
test( "escapeSelector", function() {
expect( 1 );
diff --git a/tests/unit/dialog/common-deprecated.js b/tests/unit/dialog/common-deprecated.js
index 69153039c..1efdcb030 100644
--- a/tests/unit/dialog/common-deprecated.js
+++ b/tests/unit/dialog/common-deprecated.js
@@ -36,7 +36,7 @@ common.testWidget( "dialog", {
title: null,
width: 300,
- // callbacks
+ // Callbacks
beforeClose: null,
close: null,
create: null,
@@ -49,6 +49,6 @@ common.testWidget( "dialog", {
resizeStart: null,
resizeStop: null
}
-});
+} );
} );
diff --git a/tests/unit/dialog/common.js b/tests/unit/dialog/common.js
index 8722d1753..c8d885ad0 100644
--- a/tests/unit/dialog/common.js
+++ b/tests/unit/dialog/common.js
@@ -35,7 +35,7 @@ common.testWidget( "dialog", {
title: null,
width: 300,
- // callbacks
+ // Callbacks
beforeClose: null,
close: null,
create: null,
@@ -48,6 +48,6 @@ common.testWidget( "dialog", {
resizeStart: null,
resizeStop: null
}
-});
+} );
} );
diff --git a/tests/unit/dialog/core.js b/tests/unit/dialog/core.js
index 1560c34ac..7008a832d 100644
--- a/tests/unit/dialog/core.js
+++ b/tests/unit/dialog/core.js
@@ -4,17 +4,17 @@ define( [
], function( $ ) {
// TODO add teardown callback to remove dialogs
-module("dialog: core");
+module( "dialog: core" );
test( "markup structure", function( assert ) {
expect( 11 );
- var element = $( "<div>" ).dialog({
+ var element = $( "<div>" ).dialog( {
buttons: [ {
text: "Ok",
click: $.noop
} ]
- }),
+ } ),
widget = element.dialog( "widget" ),
titlebar = widget.find( ".ui-dialog-titlebar" ),
title = titlebar.find( ".ui-dialog-title" ),
@@ -35,7 +35,7 @@ test( "markup structure", function( assert ) {
equal( buttonset.length, 1, "Buttonpane has exactly one buttonset" );
equal( buttons.length, 1, "Buttonset contains exactly 1 button when created with 1" );
-});
+} );
test( "markup structure - no buttons", function( assert ) {
expect( 7 );
@@ -53,18 +53,18 @@ test( "markup structure - no buttons", function( assert ) {
equal( close.length, 1, "Titlebar has exactly one close button" );
equal( title.length, 1, "Titlebar has exactly one title" );
assert.hasClasses( element, "ui-dialog-content ui-widget-content" );
-});
+} );
-test("title id", function() {
- expect(1);
+test( "title id", function() {
+ expect( 1 );
var titleId,
- element = $("<div>").dialog();
+ element = $( "<div>" ).dialog();
- titleId = element.dialog("widget").find(".ui-dialog-title").attr("id");
- ok( /ui-id-\d+$/.test( titleId ), "auto-numbered title id");
+ titleId = element.dialog( "widget" ).find( ".ui-dialog-title" ).attr( "id" );
+ ok( /ui-id-\d+$/.test( titleId ), "auto-numbered title id" );
element.remove();
-});
+} );
test( "ARIA", function() {
expect( 4 );
@@ -76,26 +76,26 @@ test( "ARIA", function() {
equal( wrapper.attr( "aria-describedby" ), element.attr( "id" ), "aria-describedby added" );
element.remove();
- element = $("<div><div aria-describedby='section2'><p id='section2'>descriotion</p></div></div>").dialog();
+ element = $( "<div><div aria-describedby='section2'><p id='section2'>descriotion</p></div></div>" ).dialog();
equal( element.dialog( "widget" ).attr( "aria-describedby" ), null, "no aria-describedby added, as already present in markup" );
element.remove();
-});
+} );
-test("widget method", function() {
+test( "widget method", function() {
expect( 1 );
- var dialog = $("<div>").appendTo("#qunit-fixture").dialog();
- deepEqual(dialog.parent()[0], dialog.dialog("widget")[0]);
+ var dialog = $( "<div>" ).appendTo( "#qunit-fixture" ).dialog();
+ deepEqual( dialog.parent()[ 0 ], dialog.dialog( "widget" )[ 0 ] );
dialog.remove();
-});
+} );
asyncTest( "focus tabbable", function() {
expect( 8 );
var element,
options = {
- buttons: [{
+ buttons: [ {
text: "Ok",
click: $.noop
- }]
+ } ]
};
function checkFocus( markup, options, testFn, next ) {
@@ -106,23 +106,23 @@ asyncTest( "focus tabbable", function() {
$( "body" ).trigger( "focus" );
element = $( markup ).dialog( options );
- setTimeout(function() {
- testFn(function done() {
+ setTimeout( function() {
+ testFn( function done() {
element.remove();
setTimeout( next );
- });
- });
+ } );
+ } );
}
function step1() {
checkFocus( "<div><input><input></div>", options, function( done ) {
var input = element.find( "input:last" ).trigger( "focus" ).trigger( "blur" );
element.dialog( "instance" )._focusTabbable();
- setTimeout(function() {
+ setTimeout( function() {
equal( document.activeElement, input[ 0 ],
"1. an element that was focused previously." );
done();
- });
+ } );
}, step2 );
}
@@ -164,10 +164,10 @@ asyncTest( "focus tabbable", function() {
checkFocus( "<div>text</div>", { autoOpen: false }, function( done ) {
element.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).hide();
element.dialog( "open" );
- setTimeout(function() {
+ setTimeout( function() {
equal( document.activeElement, element.parent()[ 0 ], "6. the dialog itself" );
done();
- });
+ } );
}, step7 );
}
@@ -177,17 +177,17 @@ asyncTest( "focus tabbable", function() {
{
open: function() {
var inputs = $( this ).find( "input" );
- inputs.last().on( "keydown",function( event ) {
+ inputs.last().on( "keydown", function( event ) {
event.preventDefault();
inputs.first().trigger( "focus" );
- });
+ } );
}
},
function( done ) {
var inputs = element.find( "input" );
equal( document.activeElement, inputs[ 1 ], "Focus starts on second input" );
- inputs.last().simulate( "keydown", { keyCode: $.ui.keyCode.TAB });
- setTimeout(function() {
+ inputs.last().simulate( "keydown", { keyCode: $.ui.keyCode.TAB } );
+ setTimeout( function() {
equal( document.activeElement, inputs[ 0 ],
"Honor preventDefault, allowing custom focus management" );
done();
@@ -198,19 +198,19 @@ asyncTest( "focus tabbable", function() {
}
step1();
-});
+} );
test( "#7960: resizable handles below modal overlays", function() {
expect( 1 );
var resizable = $( "<div>" ).resizable(),
- dialog = $( "<div>" ).dialog({ modal: true }),
+ dialog = $( "<div>" ).dialog( { modal: true } ),
resizableZindex = parseInt( resizable.find( ".ui-resizable-handle" ).css( "zIndex" ), 10 ),
overlayZindex = parseInt( $( ".ui-widget-overlay" ).css( "zIndex" ), 10 );
ok( resizableZindex < overlayZindex, "Resizable handles have lower z-index than modal overlay" );
dialog.dialog( "destroy" );
-});
+} );
asyncTest( "Prevent tabbing out of dialogs", function() {
expect( 3 );
@@ -219,13 +219,13 @@ asyncTest( "Prevent tabbing out of dialogs", function() {
inputs = element.find( "input" );
// Remove close button to test focus on just the two buttons
- element.dialog( "widget" ).find( ".ui-button").remove();
+ element.dialog( "widget" ).find( ".ui-button" ).remove();
function checkTab() {
equal( document.activeElement, inputs[ 0 ], "Tab key event moved focus within the modal" );
- // check shift tab
- $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB, shiftKey: true });
+ // Check shift tab
+ $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB, shiftKey: true } );
setTimeout( checkShiftTab );
}
@@ -237,27 +237,27 @@ asyncTest( "Prevent tabbing out of dialogs", function() {
}
inputs[ 1 ].focus();
- setTimeout(function() {
+ setTimeout( function() {
equal( document.activeElement, inputs[ 1 ], "Focus set on second input" );
- inputs.eq( 1 ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB });
+ inputs.eq( 1 ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB } );
setTimeout( checkTab );
- });
-});
+ } );
+} );
asyncTest( "#9048: multiple modal dialogs opened and closed in different order", function() {
expect( 1 );
- $( "#dialog1, #dialog2" ).dialog({ autoOpen: false, modal:true });
+ $( "#dialog1, #dialog2" ).dialog( { autoOpen: false, modal:true } );
$( "#dialog1" ).dialog( "open" );
$( "#dialog2" ).dialog( "open" );
$( "#dialog1" ).dialog( "close" );
- setTimeout(function() {
+ setTimeout( function() {
$( "#dialog2" ).dialog( "close" );
$( "#favorite-animal" ).trigger( "focus" );
ok( true, "event handlers cleaned up (no errors thrown)" );
start();
- });
-});
+ } );
+} );
asyncTest( "interaction between overlay and other dialogs", function() {
$.widget( "ui.testWidget", $.ui.dialog, {
@@ -265,11 +265,11 @@ asyncTest( "interaction between overlay and other dialogs", function() {
modal: true,
autoOpen: false
}
- });
+ } );
expect( 2 );
- var first = $( "<div><input id='input-1'></div>" ).dialog({
+ var first = $( "<div><input id='input-1'></div>" ).dialog( {
modal: true
- }),
+ } ),
firstInput = first.find( "input" ),
second = $( "<div><input id='input-2'></div>" ).testWidget(),
secondInput = second.find( "input" );
@@ -280,18 +280,18 @@ asyncTest( "interaction between overlay and other dialogs", function() {
$( "body" ).trigger( "focus" );
// Wait for the modal to init
- setTimeout(function() {
+ setTimeout( function() {
second.testWidget( "open" );
// Simulate user tabbing from address bar to an element outside the dialog
$( "#favorite-animal" ).trigger( "focus" );
- setTimeout(function() {
+ setTimeout( function() {
equal( document.activeElement, secondInput[ 0 ] );
// Last active dialog must receive focus
firstInput.trigger( "focus" );
$( "#favorite-animal" ).trigger( "focus" );
- setTimeout(function() {
+ setTimeout( function() {
equal( document.activeElement, firstInput[ 0 ] );
// Cleanup
@@ -300,9 +300,9 @@ asyncTest( "interaction between overlay and other dialogs", function() {
delete $.ui.testWidget;
delete $.fn.testWidget;
start();
- });
- });
- });
-});
+ } );
+ } );
+ } );
+} );
} );
diff --git a/tests/unit/dialog/deprecated.js b/tests/unit/dialog/deprecated.js
index 2d75cad0d..1a6794338 100644
--- a/tests/unit/dialog/deprecated.js
+++ b/tests/unit/dialog/deprecated.js
@@ -13,7 +13,7 @@ test( "dialogClass", function( assert ) {
assert.lacksClasses( widget, "foo", "dialogClass not specified. class not added" );
element.remove();
- element = $( "<div>" ).dialog({ dialogClass: "foo" });
+ element = $( "<div>" ).dialog( { dialogClass: "foo" } );
widget = element.dialog( "widget" );
assert.hasClasses( widget, "foo", "dialogClass in init, foo class added" );
element.dialog( "option", "dialogClass", "foobar" );
@@ -21,10 +21,10 @@ test( "dialogClass", function( assert ) {
assert.hasClasses( widget, "foobar", "dialogClass changed, new one was added" );
element.remove();
- element = $( "<div>" ).dialog({ dialogClass: "foo bar" });
+ element = $( "<div>" ).dialog( { dialogClass: "foo bar" } );
widget = element.dialog( "widget" );
assert.hasClasses( widget, "foo bar", "dialogClass in init, two classes." );
element.remove();
-});
+} );
} );
diff --git a/tests/unit/dialog/events.js b/tests/unit/dialog/events.js
index 13c452501..dd1f4055a 100644
--- a/tests/unit/dialog/events.js
+++ b/tests/unit/dialog/events.js
@@ -4,367 +4,367 @@ define( [
"ui/widgets/dialog"
], function( $, testHelper ) {
-module("dialog: events");
-
-test("open", function() {
- expect(13);
-
- var element = $("<div></div>");
- element.dialog({
- open: function(ev, ui) {
- ok(element.dialog( "instance" )._isOpen, "interal _isOpen flag is set");
- ok(true, "autoOpen: true fires open callback");
- equal(this, element[0], "context of callback");
- equal(ev.type, "dialogopen", "event type in callback");
- deepEqual(ui, {}, "ui hash in callback");
+module( "dialog: events" );
+
+test( "open", function() {
+ expect( 13 );
+
+ var element = $( "<div></div>" );
+ element.dialog( {
+ open: function( ev, ui ) {
+ ok( element.dialog( "instance" )._isOpen, "interal _isOpen flag is set" );
+ ok( true, "autoOpen: true fires open callback" );
+ equal( this, element[ 0 ], "context of callback" );
+ equal( ev.type, "dialogopen", "event type in callback" );
+ deepEqual( ui, {}, "ui hash in callback" );
}
- });
+ } );
element.remove();
- element = $("<div></div>");
- element.dialog({
+ element = $( "<div></div>" );
+ element.dialog( {
autoOpen: false,
- open: function(ev, ui) {
- ok(true, ".dialog('open') fires open callback");
- equal(this, element[0], "context of callback");
- equal(ev.type, "dialogopen", "event type in callback");
- deepEqual(ui, {}, "ui hash in callback");
+ open: function( ev, ui ) {
+ ok( true, ".dialog('open') fires open callback" );
+ equal( this, element[ 0 ], "context of callback" );
+ equal( ev.type, "dialogopen", "event type in callback" );
+ deepEqual( ui, {}, "ui hash in callback" );
}
- }).on("dialogopen", function(ev, ui) {
- ok(element.dialog( "instance" )._isOpen, "interal _isOpen flag is set");
- ok(true, "dialog('open') fires open event");
- equal(this, element[0], "context of event");
- deepEqual(ui, {}, "ui hash in event");
- });
- element.dialog("open");
+ } ).on( "dialogopen", function( ev, ui ) {
+ ok( element.dialog( "instance" )._isOpen, "interal _isOpen flag is set" );
+ ok( true, "dialog('open') fires open event" );
+ equal( this, element[ 0 ], "context of event" );
+ deepEqual( ui, {}, "ui hash in event" );
+ } );
+ element.dialog( "open" );
element.remove();
-});
+} );
test( "focus", function() {
expect( 5 );
var element, other;
- element = $("#dialog1").dialog({
+ element = $( "#dialog1" ).dialog( {
autoOpen: false
- });
- other = $("#dialog2").dialog({
+ } );
+ other = $( "#dialog2" ).dialog( {
autoOpen: false
- });
+ } );
element.one( "dialogopen", function() {
ok( true, "open, just once" );
- });
+ } );
element.one( "dialogfocus", function() {
ok( true, "focus on open" );
- });
+ } );
other.dialog( "open" );
element.one( "dialogfocus", function() {
ok( true, "when opening and already open and wasn't on top" );
- });
+ } );
other.dialog( "open" );
element.dialog( "open" );
element.one( "dialogfocus", function() {
ok( true, "when calling moveToTop and wasn't on top" );
- });
+ } );
other.dialog( "moveToTop" );
element.dialog( "moveToTop" );
element.on( "dialogfocus", function() {
ok( true, "when mousedown anywhere on the dialog and it wasn't on top" );
- });
+ } );
other.dialog( "moveToTop" );
element.trigger( "mousedown" );
- // triggers just once when already on top
+ // Triggers just once when already on top
element.dialog( "open" );
element.dialog( "moveToTop" );
element.trigger( "mousedown" );
element.add( other ).remove();
-});
+} );
-test("dragStart", function() {
- expect(9);
+test( "dragStart", function() {
+ expect( 9 );
var handle,
- element = $("<div></div>").dialog({
- dragStart: function(ev, ui) {
- ok(true, "dragging fires dragStart callback");
- equal(this, element[0], "context of callback");
- equal(ev.type, "dialogdragstart", "event type in callback");
- ok(ui.position !== undefined, "ui.position in callback");
- ok(ui.offset !== undefined, "ui.offset in callback");
+ element = $( "<div></div>" ).dialog( {
+ dragStart: function( ev, ui ) {
+ ok( true, "dragging fires dragStart callback" );
+ equal( this, element[ 0 ], "context of callback" );
+ equal( ev.type, "dialogdragstart", "event type in callback" );
+ ok( ui.position !== undefined, "ui.position in callback" );
+ ok( ui.offset !== undefined, "ui.offset in callback" );
}
- }).on("dialogdragstart", function(ev, ui) {
- ok(true, "dragging fires dialogdragstart event");
- equal(this, element[0], "context of event");
- ok(ui.position !== undefined, "ui.position in callback");
- ok(ui.offset !== undefined, "ui.offset in callback");
- });
-
- handle = $(".ui-dialog-titlebar", element.dialog("widget"));
- testHelper.drag(element, handle, 50, 50);
+ } ).on( "dialogdragstart", function( ev, ui ) {
+ ok( true, "dragging fires dialogdragstart event" );
+ equal( this, element[ 0 ], "context of event" );
+ ok( ui.position !== undefined, "ui.position in callback" );
+ ok( ui.offset !== undefined, "ui.offset in callback" );
+ } );
+
+ handle = $( ".ui-dialog-titlebar", element.dialog( "widget" ) );
+ testHelper.drag( element, handle, 50, 50 );
element.remove();
-});
+} );
-test("drag", function() {
- expect(9);
+test( "drag", function() {
+ expect( 9 );
var handle,
hasDragged = false,
- element = $("<div></div>").dialog({
- drag: function(ev, ui) {
- if (!hasDragged) {
- ok(true, "dragging fires drag callback");
- equal(this, element[0], "context of callback");
- equal(ev.type, "dialogdrag", "event type in callback");
- ok(ui.position !== undefined, "ui.position in callback");
- ok(ui.offset !== undefined, "ui.offset in callback");
+ element = $( "<div></div>" ).dialog( {
+ drag: function( ev, ui ) {
+ if ( !hasDragged ) {
+ ok( true, "dragging fires drag callback" );
+ equal( this, element[ 0 ], "context of callback" );
+ equal( ev.type, "dialogdrag", "event type in callback" );
+ ok( ui.position !== undefined, "ui.position in callback" );
+ ok( ui.offset !== undefined, "ui.offset in callback" );
hasDragged = true;
}
}
- }).one("dialogdrag", function(ev, ui) {
- ok(true, "dragging fires dialogdrag event");
- equal(this, element[0], "context of event");
- ok(ui.position !== undefined, "ui.position in callback");
- ok(ui.offset !== undefined, "ui.offset in callback");
- });
-
- handle = $(".ui-dialog-titlebar", element.dialog("widget"));
- testHelper.drag(element, handle, 50, 50);
+ } ).one( "dialogdrag", function( ev, ui ) {
+ ok( true, "dragging fires dialogdrag event" );
+ equal( this, element[ 0 ], "context of event" );
+ ok( ui.position !== undefined, "ui.position in callback" );
+ ok( ui.offset !== undefined, "ui.offset in callback" );
+ } );
+
+ handle = $( ".ui-dialog-titlebar", element.dialog( "widget" ) );
+ testHelper.drag( element, handle, 50, 50 );
element.remove();
-});
+} );
-test("dragStop", function() {
- expect(9);
+test( "dragStop", function() {
+ expect( 9 );
var handle,
- element = $("<div></div>").dialog({
- dragStop: function(ev, ui) {
- ok(true, "dragging fires dragStop callback");
- equal(this, element[0], "context of callback");
- equal(ev.type, "dialogdragstop", "event type in callback");
- ok(ui.position !== undefined, "ui.position in callback");
- ok(ui.offset !== undefined, "ui.offset in callback");
+ element = $( "<div></div>" ).dialog( {
+ dragStop: function( ev, ui ) {
+ ok( true, "dragging fires dragStop callback" );
+ equal( this, element[ 0 ], "context of callback" );
+ equal( ev.type, "dialogdragstop", "event type in callback" );
+ ok( ui.position !== undefined, "ui.position in callback" );
+ ok( ui.offset !== undefined, "ui.offset in callback" );
}
- }).on("dialogdragstop", function(ev, ui) {
- ok(true, "dragging fires dialogdragstop event");
- equal(this, element[0], "context of event");
- ok(ui.position !== undefined, "ui.position in callback");
- ok(ui.offset !== undefined, "ui.offset in callback");
- });
-
- handle = $(".ui-dialog-titlebar", element.dialog("widget"));
- testHelper.drag(element, handle, 50, 50);
+ } ).on( "dialogdragstop", function( ev, ui ) {
+ ok( true, "dragging fires dialogdragstop event" );
+ equal( this, element[ 0 ], "context of event" );
+ ok( ui.position !== undefined, "ui.position in callback" );
+ ok( ui.offset !== undefined, "ui.offset in callback" );
+ } );
+
+ handle = $( ".ui-dialog-titlebar", element.dialog( "widget" ) );
+ testHelper.drag( element, handle, 50, 50 );
element.remove();
-});
+} );
-test("resizeStart", function() {
- expect(13);
+test( "resizeStart", function() {
+ expect( 13 );
var handle,
- element = $("<div></div>").dialog({
- resizeStart: function(ev, ui) {
- ok(true, "resizing fires resizeStart callback");
- equal(this, element[0], "context of callback");
- equal(ev.type, "dialogresizestart", "event type in callback");
- ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
- ok(ui.originalSize !== undefined, "ui.originalSize in callback");
- ok(ui.position !== undefined, "ui.position in callback");
- ok(ui.size !== undefined, "ui.size in callback");
+ element = $( "<div></div>" ).dialog( {
+ resizeStart: function( ev, ui ) {
+ ok( true, "resizing fires resizeStart callback" );
+ equal( this, element[ 0 ], "context of callback" );
+ equal( ev.type, "dialogresizestart", "event type in callback" );
+ ok( ui.originalPosition !== undefined, "ui.originalPosition in callback" );
+ ok( ui.originalSize !== undefined, "ui.originalSize in callback" );
+ ok( ui.position !== undefined, "ui.position in callback" );
+ ok( ui.size !== undefined, "ui.size in callback" );
}
- }).on("dialogresizestart", function(ev, ui) {
- ok(true, "resizing fires dialogresizestart event");
- equal(this, element[0], "context of event");
- ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
- ok(ui.originalSize !== undefined, "ui.originalSize in callback");
- ok(ui.position !== undefined, "ui.position in callback");
- ok(ui.size !== undefined, "ui.size in callback");
- });
-
- handle = $(".ui-resizable-se", element.dialog("widget"));
- testHelper.drag(element, handle, 50, 50);
+ } ).on( "dialogresizestart", function( ev, ui ) {
+ ok( true, "resizing fires dialogresizestart event" );
+ equal( this, element[ 0 ], "context of event" );
+ ok( ui.originalPosition !== undefined, "ui.originalPosition in callback" );
+ ok( ui.originalSize !== undefined, "ui.originalSize in callback" );
+ ok( ui.position !== undefined, "ui.position in callback" );
+ ok( ui.size !== undefined, "ui.size in callback" );
+ } );
+
+ handle = $( ".ui-resizable-se", element.dialog( "widget" ) );
+ testHelper.drag( element, handle, 50, 50 );
element.remove();
-});
+} );
-test("resize", function() {
- expect(13);
+test( "resize", function() {
+ expect( 13 );
var handle,
hasResized = false,
- element = $("<div></div>").dialog({
- resize: function(ev, ui) {
- if (!hasResized) {
- ok(true, "resizing fires resize callback");
- equal(this, element[0], "context of callback");
- equal(ev.type, "dialogresize", "event type in callback");
- ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
- ok(ui.originalSize !== undefined, "ui.originalSize in callback");
- ok(ui.position !== undefined, "ui.position in callback");
- ok(ui.size !== undefined, "ui.size in callback");
+ element = $( "<div></div>" ).dialog( {
+ resize: function( ev, ui ) {
+ if ( !hasResized ) {
+ ok( true, "resizing fires resize callback" );
+ equal( this, element[ 0 ], "context of callback" );
+ equal( ev.type, "dialogresize", "event type in callback" );
+ ok( ui.originalPosition !== undefined, "ui.originalPosition in callback" );
+ ok( ui.originalSize !== undefined, "ui.originalSize in callback" );
+ ok( ui.position !== undefined, "ui.position in callback" );
+ ok( ui.size !== undefined, "ui.size in callback" );
hasResized = true;
}
}
- }).one("dialogresize", function(ev, ui) {
- ok(true, "resizing fires dialogresize event");
- equal(this, element[0], "context of event");
- ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
- ok(ui.originalSize !== undefined, "ui.originalSize in callback");
- ok(ui.position !== undefined, "ui.position in callback");
- ok(ui.size !== undefined, "ui.size in callback");
- });
-
- handle = $(".ui-resizable-se", element.dialog("widget"));
- testHelper.drag(element, handle, 50, 50);
+ } ).one( "dialogresize", function( ev, ui ) {
+ ok( true, "resizing fires dialogresize event" );
+ equal( this, element[ 0 ], "context of event" );
+ ok( ui.originalPosition !== undefined, "ui.originalPosition in callback" );
+ ok( ui.originalSize !== undefined, "ui.originalSize in callback" );
+ ok( ui.position !== undefined, "ui.position in callback" );
+ ok( ui.size !== undefined, "ui.size in callback" );
+ } );
+
+ handle = $( ".ui-resizable-se", element.dialog( "widget" ) );
+ testHelper.drag( element, handle, 50, 50 );
element.remove();
-});
+} );
-test("resizeStop", function() {
- expect(13);
+test( "resizeStop", function() {
+ expect( 13 );
var handle,
- element = $("<div></div>").dialog({
- resizeStop: function(ev, ui) {
- ok(true, "resizing fires resizeStop callback");
- equal(this, element[0], "context of callback");
- equal(ev.type, "dialogresizestop", "event type in callback");
- ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
- ok(ui.originalSize !== undefined, "ui.originalSize in callback");
- ok(ui.position !== undefined, "ui.position in callback");
- ok(ui.size !== undefined, "ui.size in callback");
+ element = $( "<div></div>" ).dialog( {
+ resizeStop: function( ev, ui ) {
+ ok( true, "resizing fires resizeStop callback" );
+ equal( this, element[ 0 ], "context of callback" );
+ equal( ev.type, "dialogresizestop", "event type in callback" );
+ ok( ui.originalPosition !== undefined, "ui.originalPosition in callback" );
+ ok( ui.originalSize !== undefined, "ui.originalSize in callback" );
+ ok( ui.position !== undefined, "ui.position in callback" );
+ ok( ui.size !== undefined, "ui.size in callback" );
}
- }).on("dialogresizestop", function(ev, ui) {
- ok(true, "resizing fires dialogresizestop event");
- equal(this, element[0], "context of event");
- ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
- ok(ui.originalSize !== undefined, "ui.originalSize in callback");
- ok(ui.position !== undefined, "ui.position in callback");
- ok(ui.size !== undefined, "ui.size in callback");
- });
-
- handle = $(".ui-resizable-se", element.dialog("widget"));
- testHelper.drag(element, handle, 50, 50);
+ } ).on( "dialogresizestop", function( ev, ui ) {
+ ok( true, "resizing fires dialogresizestop event" );
+ equal( this, element[ 0 ], "context of event" );
+ ok( ui.originalPosition !== undefined, "ui.originalPosition in callback" );
+ ok( ui.originalSize !== undefined, "ui.originalSize in callback" );
+ ok( ui.position !== undefined, "ui.position in callback" );
+ ok( ui.size !== undefined, "ui.size in callback" );
+ } );
+
+ handle = $( ".ui-resizable-se", element.dialog( "widget" ) );
+ testHelper.drag( element, handle, 50, 50 );
element.remove();
-});
+} );
-asyncTest("close", function() {
- expect(14);
+asyncTest( "close", function() {
+ expect( 14 );
- var element = $("<div></div>").dialog({
- close: function(ev, ui) {
- ok(true, ".dialog('close') fires close callback");
- equal(this, element[0], "context of callback");
- equal(ev.type, "dialogclose", "event type in callback");
- deepEqual(ui, {}, "ui hash in callback");
+ var element = $( "<div></div>" ).dialog( {
+ close: function( ev, ui ) {
+ ok( true, ".dialog('close') fires close callback" );
+ equal( this, element[ 0 ], "context of callback" );
+ equal( ev.type, "dialogclose", "event type in callback" );
+ deepEqual( ui, {}, "ui hash in callback" );
}
- }).on("dialogclose", function(ev, ui) {
- ok(true, ".dialog('close') fires dialogclose event");
- equal(this, element[0], "context of event");
- deepEqual(ui, {}, "ui hash in event");
- });
- element.dialog("close");
+ } ).on( "dialogclose", function( ev, ui ) {
+ ok( true, ".dialog('close') fires dialogclose event" );
+ equal( this, element[ 0 ], "context of event" );
+ deepEqual( ui, {}, "ui hash in event" );
+ } );
+ element.dialog( "close" );
element.remove();
// Close event with an effect
- element = $("<div></div>").dialog({
+ element = $( "<div></div>" ).dialog( {
hide: 10,
- close: function(ev, ui) {
- ok(true, ".dialog('close') fires close callback");
- equal(this, element[0], "context of callback");
- equal(ev.type, "dialogclose", "event type in callback");
- deepEqual(ui, {}, "ui hash in callback");
+ close: function( ev, ui ) {
+ ok( true, ".dialog('close') fires close callback" );
+ equal( this, element[ 0 ], "context of callback" );
+ equal( ev.type, "dialogclose", "event type in callback" );
+ deepEqual( ui, {}, "ui hash in callback" );
start();
}
- }).on("dialogclose", function(ev, ui) {
- ok(true, ".dialog('close') fires dialogclose event");
- equal(this, element[0], "context of event");
- deepEqual(ui, {}, "ui hash in event");
- });
- element.dialog("close");
-});
-
-test("beforeClose", function() {
- expect(14);
-
- var element = $("<div></div>").dialog({
- beforeClose: function(ev, ui) {
- ok(true, ".dialog('close') fires beforeClose callback");
- equal(this, element[0], "context of callback");
- equal(ev.type, "dialogbeforeclose", "event type in callback");
- deepEqual(ui, {}, "ui hash in callback");
+ } ).on( "dialogclose", function( ev, ui ) {
+ ok( true, ".dialog('close') fires dialogclose event" );
+ equal( this, element[ 0 ], "context of event" );
+ deepEqual( ui, {}, "ui hash in event" );
+ } );
+ element.dialog( "close" );
+} );
+
+test( "beforeClose", function() {
+ expect( 14 );
+
+ var element = $( "<div></div>" ).dialog( {
+ beforeClose: function( ev, ui ) {
+ ok( true, ".dialog('close') fires beforeClose callback" );
+ equal( this, element[ 0 ], "context of callback" );
+ equal( ev.type, "dialogbeforeclose", "event type in callback" );
+ deepEqual( ui, {}, "ui hash in callback" );
return false;
}
- });
+ } );
- element.dialog("close");
- ok( element.dialog("widget").is(":visible"), "beforeClose callback should prevent dialog from closing");
+ element.dialog( "close" );
+ ok( element.dialog( "widget" ).is( ":visible" ), "beforeClose callback should prevent dialog from closing" );
element.remove();
- element = $("<div></div>").dialog();
- element.dialog("option", "beforeClose", function(ev, ui) {
- ok(true, ".dialog('close') fires beforeClose callback");
- equal(this, element[0], "context of callback");
- equal(ev.type, "dialogbeforeclose", "event type in callback");
- deepEqual(ui, {}, "ui hash in callback");
+ element = $( "<div></div>" ).dialog();
+ element.dialog( "option", "beforeClose", function( ev, ui ) {
+ ok( true, ".dialog('close') fires beforeClose callback" );
+ equal( this, element[ 0 ], "context of callback" );
+ equal( ev.type, "dialogbeforeclose", "event type in callback" );
+ deepEqual( ui, {}, "ui hash in callback" );
return false;
- });
- element.dialog("close");
+ } );
+ element.dialog( "close" );
- ok( element.dialog("widget").is(":visible"), "beforeClose callback should prevent dialog from closing");
+ ok( element.dialog( "widget" ).is( ":visible" ), "beforeClose callback should prevent dialog from closing" );
element.remove();
- element = $("<div></div>").dialog().on("dialogbeforeclose", function(ev, ui) {
- ok(true, ".dialog('close') triggers dialogbeforeclose event");
- equal(this, element[0], "context of event");
- deepEqual(ui, {}, "ui hash in event");
+ element = $( "<div></div>" ).dialog().on( "dialogbeforeclose", function( ev, ui ) {
+ ok( true, ".dialog('close') triggers dialogbeforeclose event" );
+ equal( this, element[ 0 ], "context of event" );
+ deepEqual( ui, {}, "ui hash in event" );
return false;
- });
- element.dialog("close");
- ok( element.dialog("widget").is(":visible"), "dialogbeforeclose event should prevent dialog from closing");
+ } );
+ element.dialog( "close" );
+ ok( element.dialog( "widget" ).is( ":visible" ), "dialogbeforeclose event should prevent dialog from closing" );
element.remove();
-});
+} );
// #8789 and #8838
-asyncTest("ensure dialog's container doesn't scroll on resize and focus", function() {
- expect(2);
-
- var element = $("#dialog1").dialog(),
- initialScroll = $(window).scrollTop();
- element.dialog("option", "height", 600);
- equal($(window).scrollTop(), initialScroll, "scroll hasn't moved after height change");
- setTimeout( function(){
- $(".ui-dialog-titlebar-close").simulate("mousedown");
- equal($(window).scrollTop(), initialScroll, "scroll hasn't moved after focus moved to dialog");
- element.dialog("destroy");
+asyncTest( "ensure dialog's container doesn't scroll on resize and focus", function() {
+ expect( 2 );
+
+ var element = $( "#dialog1" ).dialog(),
+ initialScroll = $( window ).scrollTop();
+ element.dialog( "option", "height", 600 );
+ equal( $( window ).scrollTop(), initialScroll, "scroll hasn't moved after height change" );
+ setTimeout( function() {
+ $( ".ui-dialog-titlebar-close" ).simulate( "mousedown" );
+ equal( $( window ).scrollTop(), initialScroll, "scroll hasn't moved after focus moved to dialog" );
+ element.dialog( "destroy" );
start();
- });
-});
+ } );
+} );
-test("#5184: isOpen in dialogclose event is true", function() {
+test( "#5184: isOpen in dialogclose event is true", function() {
expect( 3 );
- var element = $( "<div></div>" ).dialog({
+ var element = $( "<div></div>" ).dialog( {
close: function() {
- ok( !element.dialog("isOpen"), "dialog is not open during close" );
+ ok( !element.dialog( "isOpen" ), "dialog is not open during close" );
}
- });
- ok( element.dialog("isOpen"), "dialog is open after init" );
+ } );
+ ok( element.dialog( "isOpen" ), "dialog is open after init" );
element.dialog( "close" );
- ok( !element.dialog("isOpen"), "dialog is not open after close" );
+ ok( !element.dialog( "isOpen" ), "dialog is not open after close" );
element.remove();
-});
+} );
-test("ensure dialog keeps focus when clicking modal overlay", function() {
+test( "ensure dialog keeps focus when clicking modal overlay", function() {
expect( 2 );
- var element = $( "<div></div>" ).dialog({
+ var element = $( "<div></div>" ).dialog( {
modal: true
- });
+ } );
equal( $( document.activeElement ).closest( ".ui-dialog" ).length, 1, "focus is in dialog" );
- $(".ui-widget-overlay").simulate("mousedown");
+ $( ".ui-widget-overlay" ).simulate( "mousedown" );
equal( $( document.activeElement ).closest( ".ui-dialog" ).length, 1, "focus is still in dialog" );
element.remove();
-});
+} );
} );
diff --git a/tests/unit/dialog/helper.js b/tests/unit/dialog/helper.js
index 87ca9c172..9db5b5613 100644
--- a/tests/unit/dialog/helper.js
+++ b/tests/unit/dialog/helper.js
@@ -5,22 +5,23 @@ define( [
], function( $, helper ) {
return $.extend( helper, {
- drag: function(element, handle, dx, dy) {
- var d = element.dialog("widget");
+ drag: function( element, handle, dx, dy ) {
+ var d = element.dialog( "widget" );
+
//this mouseover is to work around a limitation in resizable
//TODO: fix resizable so handle doesn't require mouseover in order to be used
- $( handle, d ).simulate("mouseover").simulate( "drag", {
+ $( handle, d ).simulate( "mouseover" ).simulate( "drag", {
dx: dx,
dy: dy
- });
+ } );
},
- testDrag: function(element, dx, dy, expectedDX, expectedDY, msg) {
+ testDrag: function( element, dx, dy, expectedDX, expectedDY, msg ) {
var actualDX, actualDY, offsetAfter,
- d = element.dialog("widget"),
- handle = $(".ui-dialog-titlebar", d),
+ d = element.dialog( "widget" ),
+ handle = $( ".ui-dialog-titlebar", d ),
offsetBefore = d.offset();
- this.drag(element, handle, dx, dy);
+ this.drag( element, handle, dx, dy );
offsetAfter = d.offset();
@@ -28,19 +29,20 @@ return $.extend( helper, {
actualDX = offsetAfter.left - offsetBefore.left;
actualDY = offsetAfter.top - offsetBefore.top;
- ok( expectedDX - actualDX <= 1 && expectedDY - actualDY <= 1, "dragged[" + expectedDX + ", " + expectedDY + "] " + msg);
+ ok( expectedDX - actualDX <= 1 && expectedDY - actualDY <= 1, "dragged[" + expectedDX + ", " + expectedDY + "] " + msg );
},
+
// TODO switch back to checking the size of the .ui-dialog element (var d)
// once we switch to using box-sizing: border-box (#9845) that should work fine
// using the element's dimensions to avoid subpixel errors
- shouldResize: function(element, dw, dh, msg) {
+ shouldResize: function( element, dw, dh, msg ) {
var heightAfter, widthAfter, actual, expected,
- d = element.dialog("widget"),
- handle = $(".ui-resizable-se", d),
+ d = element.dialog( "widget" ),
+ handle = $( ".ui-resizable-se", d ),
heightBefore = element.height(),
widthBefore = element.width();
- this.drag(element, handle, 50, 50);
+ this.drag( element, handle, 50, 50 );
heightAfter = element.height();
widthAfter = element.width();
@@ -48,7 +50,7 @@ return $.extend( helper, {
msg = msg ? msg + "." : "";
actual = { width: widthAfter, height: heightAfter },
expected = { width: widthBefore + dw, height: heightBefore + dh };
- deepEqual(actual, expected, "resized[" + 50 + ", " + 50 + "] " + msg);
+ deepEqual( actual, expected, "resized[" + 50 + ", " + 50 + "] " + msg );
}
} );
diff --git a/tests/unit/dialog/methods.js b/tests/unit/dialog/methods.js
index a730350b1..acb0f885a 100644
--- a/tests/unit/dialog/methods.js
+++ b/tests/unit/dialog/methods.js
@@ -3,37 +3,37 @@ define( [
"ui/widgets/dialog"
], function( $ ) {
-module("dialog: methods", {
+module( "dialog: methods", {
teardown: function() {
- $("body>.ui-dialog").remove();
+ $( "body>.ui-dialog" ).remove();
}
-});
+} );
-test("init", function() {
- expect(6);
+test( "init", function() {
+ expect( 6 );
- $("<div></div>").appendTo("body").dialog().remove();
- ok(true, ".dialog() called on element");
+ $( "<div></div>" ).appendTo( "body" ).dialog().remove();
+ ok( true, ".dialog() called on element" );
- $([]).dialog().remove();
- ok(true, ".dialog() called on empty collection");
+ $( [] ).dialog().remove();
+ ok( true, ".dialog() called on empty collection" );
- $("<div></div>").dialog().remove();
- ok(true, ".dialog() called on disconnected DOMElement - never connected");
+ $( "<div></div>" ).dialog().remove();
+ ok( true, ".dialog() called on disconnected DOMElement - never connected" );
- $("<div></div>").appendTo("body").remove().dialog().remove();
- ok(true, ".dialog() called on disconnected DOMElement - removed");
+ $( "<div></div>" ).appendTo( "body" ).remove().dialog().remove();
+ ok( true, ".dialog() called on disconnected DOMElement - removed" );
- var element = $("<div></div>").dialog();
- element.dialog("option", "foo");
+ var element = $( "<div></div>" ).dialog();
+ element.dialog( "option", "foo" );
element.remove();
- ok(true, "arbitrary option getter after init");
+ ok( true, "arbitrary option getter after init" );
- $("<div></div>").dialog().dialog("option", "foo", "bar").remove();
- ok(true, "arbitrary option setter after init");
-});
+ $( "<div></div>" ).dialog().dialog( "option", "foo", "bar" ).remove();
+ ok( true, "arbitrary option setter after init" );
+} );
-test("destroy", function( assert ) {
+test( "destroy", function( assert ) {
expect( 17 );
var element, element2;
@@ -43,30 +43,30 @@ test("destroy", function( assert ) {
var dialog = $( "#dialog1" ).dialog().dialog( "destroy" );
equal( dialog.parent()[ 0 ], $( "#qunit-fixture" )[ 0 ] );
equal( dialog.index(), 0 );
- });
+ } );
assert.domEqual( "#form-dialog", function() {
var dialog = $( "#form-dialog" ).dialog().dialog( "destroy" );
equal( dialog.parent()[ 0 ], $( "#qunit-fixture" )[ 0 ] );
equal( dialog.index(), 2 );
- });
+ } );
// Ensure dimensions are restored (#8119)
- $( "#dialog1" ).show().css({
+ $( "#dialog1" ).show().css( {
width: "400px",
minHeight: "100px",
height: "200px"
- });
+ } );
assert.domEqual( "#dialog1", function() {
$( "#dialog1" ).dialog().dialog( "destroy" );
- });
+ } );
// Don't throw errors when destroying a never opened modal dialog (#9004)
- $( "#dialog1" ).dialog({ autoOpen: false, modal: true }).dialog( "destroy" );
+ $( "#dialog1" ).dialog( { autoOpen: false, modal: true } ).dialog( "destroy" );
equal( $( ".ui-widget-overlay" ).length, 0, "overlay does not exist" );
- equal( $( document ).data( "ui-dialog-overlays" ), undefined, "ui-dialog-overlays equals the number of open overlays");
+ equal( $( document ).data( "ui-dialog-overlays" ), undefined, "ui-dialog-overlays equals the number of open overlays" );
- element = $( "#dialog1" ).dialog({ modal: true }),
- element2 = $( "#dialog2" ).dialog({ modal: true });
+ element = $( "#dialog1" ).dialog( { modal: true } ),
+ element2 = $( "#dialog2" ).dialog( { modal: true } );
equal( $( ".ui-widget-overlay" ).length, 2, "overlays created when dialogs are open" );
equal( $( document ).data( "ui-dialog-overlays" ), 2, "ui-dialog-overlays equals the number of open overlays" );
element.dialog( "close" );
@@ -78,147 +78,147 @@ test("destroy", function( assert ) {
element2.dialog( "destroy" );
equal( $( ".ui-widget-overlay" ).length, 0, "overlays removed when all dialogs are destoryed" );
equal( $( document ).data( "ui-dialog-overlays" ), undefined, "ui-dialog-overlays equals the number of open overlays" );
-});
+} );
-asyncTest("#9000: Dialog leaves broken event handler after close/destroy in certain cases", function() {
+asyncTest( "#9000: Dialog leaves broken event handler after close/destroy in certain cases", function() {
expect( 1 );
- $( "#dialog1" ).dialog({ modal:true }).dialog( "close" ).dialog( "destroy" );
- setTimeout(function() {
+ $( "#dialog1" ).dialog( { modal:true } ).dialog( "close" ).dialog( "destroy" );
+ setTimeout( function() {
$( "#favorite-animal" ).trigger( "focus" );
ok( true, "close and destroy modal dialog before its really opened" );
start();
- });
-});
+ } );
+} );
-test("#4980: Destroy should place element back in original DOM position", function(){
+test( "#4980: Destroy should place element back in original DOM position", function() {
expect( 2 );
- var container = $("<div id='container'><div id='modal'>Content</div></div>"),
- modal = container.find("#modal");
+ var container = $( "<div id='container'><div id='modal'>Content</div></div>" ),
+ modal = container.find( "#modal" );
modal.dialog();
- ok(!$.contains(container[0], modal[0]), "dialog should move modal element to outside container element");
- modal.dialog("destroy");
- ok($.contains(container[0], modal[0]), "dialog(destroy) should place element back in original DOM position");
-});
+ ok( !$.contains( container[ 0 ], modal[ 0 ] ), "dialog should move modal element to outside container element" );
+ modal.dialog( "destroy" );
+ ok( $.contains( container[ 0 ], modal[ 0 ] ), "dialog(destroy) should place element back in original DOM position" );
+} );
test( "enable/disable disabled", function( assert ) {
expect( 3 );
var element = $( "<div></div>" ).dialog();
element.dialog( "disable" );
- equal(element.dialog( "option", "disabled" ), false, "disable method doesn't do anything" );
+ equal( element.dialog( "option", "disabled" ), false, "disable method doesn't do anything" );
assert.lacksClasses( element, "ui-dialog-disabled ui-state-disabled", "disable method doesn't add classes" );
ok( !element.dialog( "widget" ).attr( "aria-disabled" ), "disable method doesn't add aria-disabled" );
-});
+} );
-test("close", function() {
+test( "close", function() {
expect( 3 );
var element,
- expected = $("<div></div>").dialog(),
- actual = expected.dialog("close");
- equal(actual, expected, "close is chainable");
-
- element = $("<div></div>").dialog();
- ok(element.dialog("widget").is(":visible") && !element.dialog("widget").is(":hidden"), "dialog visible before close method called");
- element.dialog("close");
- ok(element.dialog("widget").is(":hidden") && !element.dialog("widget").is(":visible"), "dialog hidden after close method called");
-});
-
-test("isOpen", function() {
- expect(4);
-
- var element = $("<div></div>").dialog();
- equal(element.dialog("isOpen"), true, "dialog is open after init");
- element.dialog("close");
- equal(element.dialog("isOpen"), false, "dialog is closed");
+ expected = $( "<div></div>" ).dialog(),
+ actual = expected.dialog( "close" );
+ equal( actual, expected, "close is chainable" );
+
+ element = $( "<div></div>" ).dialog();
+ ok( element.dialog( "widget" ).is( ":visible" ) && !element.dialog( "widget" ).is( ":hidden" ), "dialog visible before close method called" );
+ element.dialog( "close" );
+ ok( element.dialog( "widget" ).is( ":hidden" ) && !element.dialog( "widget" ).is( ":visible" ), "dialog hidden after close method called" );
+} );
+
+test( "isOpen", function() {
+ expect( 4 );
+
+ var element = $( "<div></div>" ).dialog();
+ equal( element.dialog( "isOpen" ), true, "dialog is open after init" );
+ element.dialog( "close" );
+ equal( element.dialog( "isOpen" ), false, "dialog is closed" );
element.remove();
- element = $("<div></div>").dialog({autoOpen: false});
- equal(element.dialog("isOpen"), false, "dialog is closed after init");
- element.dialog("open");
- equal(element.dialog("isOpen"), true, "dialog is open");
+ element = $( "<div></div>" ).dialog( { autoOpen: false } );
+ equal( element.dialog( "isOpen" ), false, "dialog is closed after init" );
+ element.dialog( "open" );
+ equal( element.dialog( "isOpen" ), true, "dialog is open" );
element.remove();
-});
+} );
-test("moveToTop", function() {
+test( "moveToTop", function() {
expect( 5 );
function order() {
- var actual = $( ".ui-dialog" ).map(function() {
+ var actual = $( ".ui-dialog" ).map( function() {
return +$( this ).css( "z-index" );
- }).get();
+ } ).get();
deepEqual( actual, $.makeArray( arguments ) );
}
var dialog1, dialog2,
focusOn = "dialog1";
- dialog1 = $( "#dialog1" ).dialog({
+ dialog1 = $( "#dialog1" ).dialog( {
focus: function() {
equal( focusOn, "dialog1" );
}
- });
+ } );
focusOn = "dialog2";
- dialog2 = $( "#dialog2" ).dialog({
+ dialog2 = $( "#dialog2" ).dialog( {
focus: function() {
equal( focusOn, "dialog2" );
}
- });
+ } );
order( 100, 101 );
focusOn = "dialog1";
dialog1.dialog( "moveToTop" );
order( 102, 101 );
-});
+} );
test( "moveToTop: content scroll stays intact", function() {
expect( 2 );
var otherDialog = $( "#dialog1" ).dialog(),
- scrollDialog = $( "#form-dialog" ).dialog({
+ scrollDialog = $( "#form-dialog" ).dialog( {
height: 200
- });
+ } );
scrollDialog.scrollTop( 50 );
equal( scrollDialog.scrollTop(), 50 );
otherDialog.dialog( "moveToTop" );
equal( scrollDialog.scrollTop(), 50 );
-});
+} );
-test("open", function() {
+test( "open", function() {
expect( 3 );
var element,
- expected = $("<div></div>").dialog(),
- actual = expected.dialog("open");
- equal(actual, expected, "open is chainable");
-
- element = $("<div></div>").dialog({ autoOpen: false });
- ok(element.dialog("widget").is(":hidden") && !element.dialog("widget").is(":visible"), "dialog hidden before open method called");
- element.dialog("open");
- ok(element.dialog("widget").is(":visible") && !element.dialog("widget").is(":hidden"), "dialog visible after open method called");
-});
+ expected = $( "<div></div>" ).dialog(),
+ actual = expected.dialog( "open" );
+ equal( actual, expected, "open is chainable" );
+
+ element = $( "<div></div>" ).dialog( { autoOpen: false } );
+ ok( element.dialog( "widget" ).is( ":hidden" ) && !element.dialog( "widget" ).is( ":visible" ), "dialog hidden before open method called" );
+ element.dialog( "open" );
+ ok( element.dialog( "widget" ).is( ":visible" ) && !element.dialog( "widget" ).is( ":hidden" ), "dialog visible after open method called" );
+} );
// http://bugs.jqueryui.com/ticket/6137
-test("Ensure form elements don't reset when opening a dialog", function() {
- expect(2);
+test( "Ensure form elements don't reset when opening a dialog", function() {
+ expect( 2 );
- var d1 = $("<form><input type='radio' name='radio' id='a' value='a' checked='checked'></input>" +
- "<input type='radio' name='radio' id='b' value='b'>b</input></form>").appendTo( "body" ).dialog({autoOpen: false});
+ var d1 = $( "<form><input type='radio' name='radio' id='a' value='a' checked='checked'></input>" +
+ "<input type='radio' name='radio' id='b' value='b'>b</input></form>" ).appendTo( "body" ).dialog( { autoOpen: false } );
- d1.find("#b").prop( "checked", true );
- equal(d1.find("input:checked").val(), "b", "checkbox b is checked");
+ d1.find( "#b" ).prop( "checked", true );
+ equal( d1.find( "input:checked" ).val(), "b", "checkbox b is checked" );
- d1.dialog("open");
- equal(d1.find("input:checked").val(), "b", "checkbox b is checked");
+ d1.dialog( "open" );
+ equal( d1.find( "input:checked" ).val(), "b", "checkbox b is checked" );
d1.remove();
-});
+} );
asyncTest( "#8958: dialog can be opened while opening", function() {
expect( 1 );
- var element = $( "<div>" ).dialog({
+ var element = $( "<div>" ).dialog( {
autoOpen: false,
modal: true,
open: function() {
equal( $( ".ui-widget-overlay" ).length, 1 );
start();
}
- });
+ } );
// Support: IE8
// For some reason the #favorite-color input doesn't get focus if we don't
@@ -226,42 +226,44 @@ asyncTest( "#8958: dialog can be opened while opening", function() {
$( "body" ).trigger( "focus" );
$( "#favorite-animal" )
+
// We focus the input to start the test. Once it receives focus, the
// dialog will open. Opening the dialog, will cause an element inside
// the dialog to gain focus, thus blurring the input.
.on( "focus", function() {
element.dialog( "open" );
- })
+ } )
+
// When the input blurs, the dialog is in the process of opening. We
// try to open the dialog again, to make sure that dialogs properly
// handle a call to the open() method during the process of the dialog
// being opened.
.on( "blur", function() {
element.dialog( "open" );
- })
+ } )
.trigger( "focus" );
-});
+} );
-test("#5531: dialog width should be at least minWidth on creation", function () {
+test( "#5531: dialog width should be at least minWidth on creation", function() {
expect( 4 );
- var element = $("<div></div>").dialog({
+ var element = $( "<div></div>" ).dialog( {
width: 200,
minWidth: 300
- });
+ } );
- equal(element.dialog("option", "width"), 300, "width is minWidth");
- element.dialog("option", "width", 200);
- equal(element.dialog("option", "width"), 300, "width unchanged when set to < minWidth");
- element.dialog("option", "width", 320);
- equal(element.dialog("option", "width"), 320, "width changed if set to > minWidth");
+ equal( element.dialog( "option", "width" ), 300, "width is minWidth" );
+ element.dialog( "option", "width", 200 );
+ equal( element.dialog( "option", "width" ), 300, "width unchanged when set to < minWidth" );
+ element.dialog( "option", "width", 320 );
+ equal( element.dialog( "option", "width" ), 320, "width changed if set to > minWidth" );
element.remove();
- element = $("<div></div>").dialog({
+ element = $( "<div></div>" ).dialog( {
minWidth: 300
- });
- ok(element.dialog("option", "width") >= 300, "width is at least 300");
+ } );
+ ok( element.dialog( "option", "width" ) >= 300, "width is at least 300" );
element.remove();
-});
+} );
} );
diff --git a/tests/unit/dialog/options.js b/tests/unit/dialog/options.js
index c4f1b3e15..7565799c4 100644
--- a/tests/unit/dialog/options.js
+++ b/tests/unit/dialog/options.js
@@ -6,155 +6,155 @@ define( [
"ui/effects/effect-explode"
], function( $, testHelper ) {
-module("dialog: options");
+module( "dialog: options" );
test( "appendTo", function() {
expect( 16 );
var detached = $( "<div>" ),
- element = $( "#dialog1" ).dialog({
+ element = $( "#dialog1" ).dialog( {
modal: true
- });
- equal( element.dialog( "widget" ).parent()[0], document.body, "defaults to body" );
- equal( $( ".ui-widget-overlay" ).parent()[0], document.body, "overlay defaults to body" );
+ } );
+ equal( element.dialog( "widget" ).parent()[ 0 ], document.body, "defaults to body" );
+ equal( $( ".ui-widget-overlay" ).parent()[ 0 ], document.body, "overlay defaults to body" );
element.dialog( "destroy" );
- element.dialog({
+ element.dialog( {
appendTo: ".wrap",
modal: true
- });
- equal( element.dialog( "widget" ).parent()[0], $( "#wrap1" )[0], "first found element" );
- equal( $( ".ui-widget-overlay" ).parent()[0], $( "#wrap1" )[0], "overlay first found element" );
+ } );
+ equal( element.dialog( "widget" ).parent()[ 0 ], $( "#wrap1" )[ 0 ], "first found element" );
+ equal( $( ".ui-widget-overlay" ).parent()[ 0 ], $( "#wrap1" )[ 0 ], "overlay first found element" );
equal( $( "#wrap2 .ui-dialog" ).length, 0, "only appends to one element" );
equal( $( "#wrap2 .ui-widget-overlay" ).length, 0, "overlay only appends to one element" );
element.dialog( "destroy" );
- element.dialog({
+ element.dialog( {
appendTo: null,
modal: true
- });
- equal( element.dialog( "widget" ).parent()[0], document.body, "null" );
- equal( $( ".ui-widget-overlay" ).parent()[0], document.body, "overlay null" );
+ } );
+ equal( element.dialog( "widget" ).parent()[ 0 ], document.body, "null" );
+ equal( $( ".ui-widget-overlay" ).parent()[ 0 ], document.body, "overlay null" );
element.dialog( "destroy" );
- element.dialog({
+ element.dialog( {
autoOpen: false,
modal: true
- }).dialog( "option", "appendTo", "#wrap1" ).dialog( "open" );
- equal( element.dialog( "widget" ).parent()[0], $( "#wrap1" )[0], "modified after init" );
- equal( $( ".ui-widget-overlay" ).parent()[0], $( "#wrap1" )[0], "overlay modified after init" );
+ } ).dialog( "option", "appendTo", "#wrap1" ).dialog( "open" );
+ equal( element.dialog( "widget" ).parent()[ 0 ], $( "#wrap1" )[ 0 ], "modified after init" );
+ equal( $( ".ui-widget-overlay" ).parent()[ 0 ], $( "#wrap1" )[ 0 ], "overlay modified after init" );
element.dialog( "destroy" );
- element.dialog({
+ element.dialog( {
appendTo: detached,
modal: true
- });
- equal( element.dialog( "widget" ).parent()[0], detached[0], "detached jQuery object" );
- equal( detached.find( ".ui-widget-overlay" ).parent()[0], detached[0], "overlay detached jQuery object" );
+ } );
+ equal( element.dialog( "widget" ).parent()[ 0 ], detached[ 0 ], "detached jQuery object" );
+ equal( detached.find( ".ui-widget-overlay" ).parent()[ 0 ], detached[ 0 ], "overlay detached jQuery object" );
element.dialog( "destroy" );
- element.dialog({
- appendTo: detached[0],
+ element.dialog( {
+ appendTo: detached[ 0 ],
modal: true
- });
- equal( element.dialog( "widget" ).parent()[0], detached[0], "detached DOM element" );
- equal( detached.find( ".ui-widget-overlay" ).parent()[0], detached[0], "overlay detached DOM element" );
+ } );
+ equal( element.dialog( "widget" ).parent()[ 0 ], detached[ 0 ], "detached DOM element" );
+ equal( detached.find( ".ui-widget-overlay" ).parent()[ 0 ], detached[ 0 ], "overlay detached DOM element" );
element.dialog( "destroy" );
- element.dialog({
+ element.dialog( {
autoOpen: false,
modal: true
- }).dialog( "option", "appendTo", detached );
- equal( element.dialog( "widget" ).parent()[0], detached[0], "detached DOM element via option()" );
+ } ).dialog( "option", "appendTo", detached );
+ equal( element.dialog( "widget" ).parent()[ 0 ], detached[ 0 ], "detached DOM element via option()" );
equal( detached.find( ".ui-widget-overlay" ).length, 0, "overlay detached DOM element via option()" );
element.dialog( "destroy" );
-});
+} );
-test("autoOpen", function() {
- expect(2);
+test( "autoOpen", function() {
+ expect( 2 );
- var element = $("<div></div>").dialog({ autoOpen: false });
- ok( !element.dialog("widget").is(":visible"), ".dialog({ autoOpen: false })");
+ var element = $( "<div></div>" ).dialog( { autoOpen: false } );
+ ok( !element.dialog( "widget" ).is( ":visible" ), ".dialog({ autoOpen: false })" );
element.remove();
- element = $("<div></div>").dialog({ autoOpen: true });
- ok( element.dialog("widget").is(":visible"), ".dialog({ autoOpen: true })");
+ element = $( "<div></div>" ).dialog( { autoOpen: true } );
+ ok( element.dialog( "widget" ).is( ":visible" ), ".dialog({ autoOpen: true })" );
element.remove();
-});
+} );
-test("buttons", function( assert ) {
- expect(21);
+test( "buttons", function( assert ) {
+ expect( 21 );
var btn, i, newButtons,
buttons = {
"Ok": function( ev ) {
- ok(true, "button click fires callback");
- equal(this, element[0], "context of callback");
- equal(ev.target, btn[0], "event target");
+ ok( true, "button click fires callback" );
+ equal( this, element[ 0 ], "context of callback" );
+ equal( ev.target, btn[ 0 ], "event target" );
},
"Cancel": function( ev ) {
- ok(true, "button click fires callback");
- equal(this, element[0], "context of callback");
- equal(ev.target, btn[1], "event target");
+ ok( true, "button click fires callback" );
+ equal( this, element[ 0 ], "context of callback" );
+ equal( ev.target, btn[ 1 ], "event target" );
}
},
- element = $("<div></div>").dialog({ buttons: buttons });
+ element = $( "<div></div>" ).dialog( { buttons: buttons } );
btn = element.dialog( "widget" ).find( ".ui-dialog-buttonpane button" );
- equal(btn.length, 2, "number of buttons");
+ equal( btn.length, 2, "number of buttons" );
i = 0;
- $.each(buttons, function( key ) {
- equal(btn.eq(i).text(), key, "text of button " + (i+1));
+ $.each( buttons, function( key ) {
+ equal( btn.eq( i ).text(), key, "text of button " + ( i + 1 ) );
i++;
- });
+ } );
assert.hasClasses( btn.parent(), "ui-dialog-buttonset" );
assert.hasClasses( element.parent(), "ui-dialog-buttons" );
- btn.trigger("click");
+ btn.trigger( "click" );
newButtons = {
"Close": function( ev ) {
- ok(true, "button click fires callback");
- equal(this, element[0], "context of callback");
- equal(ev.target, btn[0], "event target");
+ ok( true, "button click fires callback" );
+ equal( this, element[ 0 ], "context of callback" );
+ equal( ev.target, btn[ 0 ], "event target" );
}
};
- deepEqual(element.dialog("option", "buttons"), buttons, ".dialog('option', 'buttons') getter");
- element.dialog("option", "buttons", newButtons);
- deepEqual(element.dialog("option", "buttons"), newButtons, ".dialog('option', 'buttons', ...) setter");
+ deepEqual( element.dialog( "option", "buttons" ), buttons, ".dialog('option', 'buttons') getter" );
+ element.dialog( "option", "buttons", newButtons );
+ deepEqual( element.dialog( "option", "buttons" ), newButtons, ".dialog('option', 'buttons', ...) setter" );
btn = element.dialog( "widget" ).find( ".ui-dialog-buttonpane button" );
- equal(btn.length, 1, "number of buttons after setter");
- btn.trigger("click");
+ equal( btn.length, 1, "number of buttons after setter" );
+ btn.trigger( "click" );
i = 0;
- $.each(newButtons, function( key ) {
- equal(btn.eq(i).text(), key, "text of button " + (i+1));
+ $.each( newButtons, function( key ) {
+ equal( btn.eq( i ).text(), key, "text of button " + ( i + 1 ) );
i += 1;
- });
+ } );
- element.dialog("option", "buttons", null);
+ element.dialog( "option", "buttons", null );
btn = element.dialog( "widget" ).find( ".ui-dialog-buttonpane button" );
- equal(btn.length, 0, "all buttons have been removed");
- equal(element.find(".ui-dialog-buttonset").length, 0, "buttonset has been removed");
+ equal( btn.length, 0, "all buttons have been removed" );
+ equal( element.find( ".ui-dialog-buttonset" ).length, 0, "buttonset has been removed" );
assert.lacksClasses( element.parent(), "ui-dialog-buttons" );
element.remove();
-});
+} );
-test("buttons - advanced", function( assert ) {
+test( "buttons - advanced", function( assert ) {
expect( 7 );
var buttons,
- element = $("<div></div>").dialog({
+ element = $( "<div></div>" ).dialog( {
buttons: [
{
text: "a button",
"class": "additional-class",
id: "my-button-id",
click: function() {
- equal(this, element[0], "correct context");
+ equal( this, element[ 0 ], "correct context" );
},
icons: {
primary: "ui-icon-cancel"
@@ -162,21 +162,21 @@ test("buttons - advanced", function( assert ) {
showText: false
}
]
- });
+ } );
buttons = element.dialog( "widget" ).find( ".ui-dialog-buttonpane button" );
- equal(buttons.length, 1, "correct number of buttons");
- equal(buttons.attr("id"), "my-button-id", "correct id");
- equal(buttons.text(), "a button", "correct label");
+ equal( buttons.length, 1, "correct number of buttons" );
+ equal( buttons.attr( "id" ), "my-button-id", "correct id" );
+ equal( buttons.text(), "a button", "correct label" );
assert.hasClasses( buttons, "additional-class" );
- deepEqual( buttons.button("option", "icons"), { primary: "ui-icon-cancel", secondary: null } );
+ deepEqual( buttons.button( "option", "icons" ), { primary: "ui-icon-cancel", secondary: null } );
equal( buttons.button( "option", "text" ), false );
buttons.trigger( "click" );
element.remove();
-});
+} );
-test("#9043: buttons with Array.prototype modification", function() {
+test( "#9043: buttons with Array.prototype modification", function() {
expect( 1 );
Array.prototype.test = $.noop;
var element = $( "<div></div>" ).dialog();
@@ -184,232 +184,232 @@ test("#9043: buttons with Array.prototype modification", function() {
"no button pane" );
element.remove();
delete Array.prototype.test;
-});
+} );
-test("closeOnEscape", function() {
+test( "closeOnEscape", function() {
expect( 6 );
- var element = $("<div></div>").dialog({ closeOnEscape: false });
- ok(true, "closeOnEscape: false");
- ok(element.dialog("widget").is(":visible") && !element.dialog("widget").is(":hidden"), "dialog is open before ESC");
- element.simulate("keydown", { keyCode: $.ui.keyCode.ESCAPE })
- .simulate("keypress", { keyCode: $.ui.keyCode.ESCAPE })
- .simulate("keyup", { keyCode: $.ui.keyCode.ESCAPE });
- ok(element.dialog("widget").is(":visible") && !element.dialog("widget").is(":hidden"), "dialog is open after ESC");
-
- element.remove();
-
- element = $("<div></div>").dialog({ closeOnEscape: true });
- ok(true, "closeOnEscape: true");
- ok(element.dialog("widget").is(":visible") && !element.dialog("widget").is(":hidden"), "dialog is open before ESC");
- element.simulate("keydown", { keyCode: $.ui.keyCode.ESCAPE })
- .simulate("keypress", { keyCode: $.ui.keyCode.ESCAPE })
- .simulate("keyup", { keyCode: $.ui.keyCode.ESCAPE });
- ok(element.dialog("widget").is(":hidden") && !element.dialog("widget").is(":visible"), "dialog is closed after ESC");
-});
+ var element = $( "<div></div>" ).dialog( { closeOnEscape: false } );
+ ok( true, "closeOnEscape: false" );
+ ok( element.dialog( "widget" ).is( ":visible" ) && !element.dialog( "widget" ).is( ":hidden" ), "dialog is open before ESC" );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } )
+ .simulate( "keypress", { keyCode: $.ui.keyCode.ESCAPE } )
+ .simulate( "keyup", { keyCode: $.ui.keyCode.ESCAPE } );
+ ok( element.dialog( "widget" ).is( ":visible" ) && !element.dialog( "widget" ).is( ":hidden" ), "dialog is open after ESC" );
+
+ element.remove();
+
+ element = $( "<div></div>" ).dialog( { closeOnEscape: true } );
+ ok( true, "closeOnEscape: true" );
+ ok( element.dialog( "widget" ).is( ":visible" ) && !element.dialog( "widget" ).is( ":hidden" ), "dialog is open before ESC" );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } )
+ .simulate( "keypress", { keyCode: $.ui.keyCode.ESCAPE } )
+ .simulate( "keyup", { keyCode: $.ui.keyCode.ESCAPE } );
+ ok( element.dialog( "widget" ).is( ":hidden" ) && !element.dialog( "widget" ).is( ":visible" ), "dialog is closed after ESC" );
+} );
-test("closeText", function() {
- expect(3);
+test( "closeText", function() {
+ expect( 3 );
- var element = $("<div></div>").dialog();
- equal(element.dialog("widget").find(".ui-dialog-titlebar-close span").text(), "Close",
- "default close text");
+ var element = $( "<div></div>" ).dialog();
+ equal( element.dialog( "widget" ).find( ".ui-dialog-titlebar-close span" ).text(), "Close",
+ "default close text" );
element.remove();
- element = $("<div></div>").dialog({ closeText: "foo" });
- equal(element.dialog("widget").find(".ui-dialog-titlebar-close span").text(), "foo",
- "closeText on init");
+ element = $( "<div></div>" ).dialog( { closeText: "foo" } );
+ equal( element.dialog( "widget" ).find( ".ui-dialog-titlebar-close span" ).text(), "foo",
+ "closeText on init" );
element.remove();
- element = $("<div></div>").dialog().dialog("option", "closeText", "bar");
- equal(element.dialog("widget").find(".ui-dialog-titlebar-close span").text(), "bar",
- "closeText via option method");
+ element = $( "<div></div>" ).dialog().dialog( "option", "closeText", "bar" );
+ equal( element.dialog( "widget" ).find( ".ui-dialog-titlebar-close span" ).text(), "bar",
+ "closeText via option method" );
element.remove();
-});
+} );
-test("draggable", function() {
- expect(4);
+test( "draggable", function() {
+ expect( 4 );
- var element = $("<div></div>").dialog({ draggable: false });
+ var element = $( "<div></div>" ).dialog( { draggable: false } );
- testHelper.testDrag(element, 50, -50, 0, 0);
- element.dialog("option", "draggable", true);
- testHelper.testDrag(element, 50, -50, 50, -50);
+ testHelper.testDrag( element, 50, -50, 0, 0 );
+ element.dialog( "option", "draggable", true );
+ testHelper.testDrag( element, 50, -50, 50, -50 );
element.remove();
- element = $("<div></div>").dialog({ draggable: true });
- testHelper.testDrag(element, 50, -50, 50, -50);
- element.dialog("option", "draggable", false);
- testHelper.testDrag(element, 50, -50, 0, 0);
+ element = $( "<div></div>" ).dialog( { draggable: true } );
+ testHelper.testDrag( element, 50, -50, 50, -50 );
+ element.dialog( "option", "draggable", false );
+ testHelper.testDrag( element, 50, -50, 0, 0 );
element.remove();
-});
+} );
-test("height", function() {
- expect(4);
+test( "height", function() {
+ expect( 4 );
- var element = $("<div></div>").dialog();
- equal(element.dialog("widget").outerHeight(), 150, "default height");
+ var element = $( "<div></div>" ).dialog();
+ equal( element.dialog( "widget" ).outerHeight(), 150, "default height" );
element.remove();
- element = $("<div></div>").dialog({ height: 237 });
- equal(element.dialog("widget").outerHeight(), 237, "explicit height");
+ element = $( "<div></div>" ).dialog( { height: 237 } );
+ equal( element.dialog( "widget" ).outerHeight(), 237, "explicit height" );
element.remove();
- element = $("<div></div>").dialog();
- element.dialog("option", "height", 238);
- equal(element.dialog("widget").outerHeight(), 238, "explicit height set after init");
+ element = $( "<div></div>" ).dialog();
+ element.dialog( "option", "height", 238 );
+ equal( element.dialog( "widget" ).outerHeight(), 238, "explicit height set after init" );
element.remove();
- element = $("<div></div>").css("padding", "20px")
- .dialog({ height: 240 });
- equal(element.dialog("widget").outerHeight(), 240, "explicit height with padding");
+ element = $( "<div></div>" ).css( "padding", "20px" )
+ .dialog( { height: 240 } );
+ equal( element.dialog( "widget" ).outerHeight(), 240, "explicit height with padding" );
element.remove();
-});
+} );
-test("maxHeight", function( assert ) {
- expect(3);
+test( "maxHeight", function( assert ) {
+ expect( 3 );
- var element = $("<div></div>").dialog({ maxHeight: 200 });
- testHelper.drag(element, ".ui-resizable-s", 1000, 1000);
- assert.close(element.dialog("widget").height(), 200, 1, "maxHeight");
+ var element = $( "<div></div>" ).dialog( { maxHeight: 200 } );
+ testHelper.drag( element, ".ui-resizable-s", 1000, 1000 );
+ assert.close( element.dialog( "widget" ).height(), 200, 1, "maxHeight" );
element.remove();
- element = $("<div></div>").dialog({ maxHeight: 200 });
- testHelper.drag(element, ".ui-resizable-n", -1000, -1000);
- assert.close(element.dialog("widget").height(), 200, 1, "maxHeight");
+ element = $( "<div></div>" ).dialog( { maxHeight: 200 } );
+ testHelper.drag( element, ".ui-resizable-n", -1000, -1000 );
+ assert.close( element.dialog( "widget" ).height(), 200, 1, "maxHeight" );
element.remove();
- element = $("<div></div>").dialog({ maxHeight: 200 }).dialog("option", "maxHeight", 300);
- testHelper.drag(element, ".ui-resizable-s", 1000, 1000);
- assert.close(element.dialog("widget").height(), 300, 1, "maxHeight");
+ element = $( "<div></div>" ).dialog( { maxHeight: 200 } ).dialog( "option", "maxHeight", 300 );
+ testHelper.drag( element, ".ui-resizable-s", 1000, 1000 );
+ assert.close( element.dialog( "widget" ).height(), 300, 1, "maxHeight" );
element.remove();
-});
+} );
-test("maxWidth", function( assert ) {
- expect(3);
+test( "maxWidth", function( assert ) {
+ expect( 3 );
- var element = $("<div></div>").dialog({ maxWidth: 200 });
- testHelper.drag(element, ".ui-resizable-e", 1000, 1000);
- assert.close(element.dialog("widget").width(), 200, 1, "maxWidth");
+ var element = $( "<div></div>" ).dialog( { maxWidth: 200 } );
+ testHelper.drag( element, ".ui-resizable-e", 1000, 1000 );
+ assert.close( element.dialog( "widget" ).width(), 200, 1, "maxWidth" );
element.remove();
- element = $("<div></div>").dialog({ maxWidth: 200 });
- testHelper.drag(element, ".ui-resizable-w", -1000, -1000);
- assert.close(element.dialog("widget").width(), 200, 1, "maxWidth");
+ element = $( "<div></div>" ).dialog( { maxWidth: 200 } );
+ testHelper.drag( element, ".ui-resizable-w", -1000, -1000 );
+ assert.close( element.dialog( "widget" ).width(), 200, 1, "maxWidth" );
element.remove();
- element = $("<div></div>").dialog({ maxWidth: 200 }).dialog("option", "maxWidth", 300);
- testHelper.drag(element, ".ui-resizable-w", -1000, -1000);
- assert.close(element.dialog("widget").width(), 300, 1, "maxWidth");
+ element = $( "<div></div>" ).dialog( { maxWidth: 200 } ).dialog( "option", "maxWidth", 300 );
+ testHelper.drag( element, ".ui-resizable-w", -1000, -1000 );
+ assert.close( element.dialog( "widget" ).width(), 300, 1, "maxWidth" );
element.remove();
-});
+} );
-test("minHeight", function( assert ) {
- expect(3);
+test( "minHeight", function( assert ) {
+ expect( 3 );
- var element = $("<div></div>").dialog({ minHeight: 10 });
- testHelper.drag(element, ".ui-resizable-s", -1000, -1000);
- assert.close(element.dialog("widget").height(), 10, 1, "minHeight");
+ var element = $( "<div></div>" ).dialog( { minHeight: 10 } );
+ testHelper.drag( element, ".ui-resizable-s", -1000, -1000 );
+ assert.close( element.dialog( "widget" ).height(), 10, 1, "minHeight" );
element.remove();
- element = $("<div></div>").dialog({ minHeight: 10 });
- testHelper.drag(element, ".ui-resizable-n", 1000, 1000);
- assert.close(element.dialog("widget").height(), 10, 1, "minHeight");
+ element = $( "<div></div>" ).dialog( { minHeight: 10 } );
+ testHelper.drag( element, ".ui-resizable-n", 1000, 1000 );
+ assert.close( element.dialog( "widget" ).height(), 10, 1, "minHeight" );
element.remove();
- element = $("<div></div>").dialog({ minHeight: 10 }).dialog("option", "minHeight", 30);
- testHelper.drag(element, ".ui-resizable-n", 1000, 1000);
- assert.close(element.dialog("widget").height(), 30, 1, "minHeight");
+ element = $( "<div></div>" ).dialog( { minHeight: 10 } ).dialog( "option", "minHeight", 30 );
+ testHelper.drag( element, ".ui-resizable-n", 1000, 1000 );
+ assert.close( element.dialog( "widget" ).height(), 30, 1, "minHeight" );
element.remove();
-});
+} );
-test("minWidth", function( assert ) {
- expect(3);
+test( "minWidth", function( assert ) {
+ expect( 3 );
- var element = $("<div></div>").dialog({ minWidth: 10 });
- testHelper.drag(element, ".ui-resizable-e", -1000, -1000);
- assert.close(element.dialog("widget").width(), 10, 1, "minWidth");
+ var element = $( "<div></div>" ).dialog( { minWidth: 10 } );
+ testHelper.drag( element, ".ui-resizable-e", -1000, -1000 );
+ assert.close( element.dialog( "widget" ).width(), 10, 1, "minWidth" );
element.remove();
- element = $("<div></div>").dialog({ minWidth: 10 });
- testHelper.drag(element, ".ui-resizable-w", 1000, 1000);
- assert.close(element.dialog("widget").width(), 10, 1, "minWidth");
+ element = $( "<div></div>" ).dialog( { minWidth: 10 } );
+ testHelper.drag( element, ".ui-resizable-w", 1000, 1000 );
+ assert.close( element.dialog( "widget" ).width(), 10, 1, "minWidth" );
element.remove();
- element = $("<div></div>").dialog({ minWidth: 30 }).dialog("option", "minWidth", 30);
- testHelper.drag(element, ".ui-resizable-w", 1000, 1000);
- assert.close(element.dialog("widget").width(), 30, 1, "minWidth");
+ element = $( "<div></div>" ).dialog( { minWidth: 30 } ).dialog( "option", "minWidth", 30 );
+ testHelper.drag( element, ".ui-resizable-w", 1000, 1000 );
+ assert.close( element.dialog( "widget" ).width(), 30, 1, "minWidth" );
element.remove();
-});
+} );
test( "position, default center on window", function( assert ) {
expect( 2 );
- // dialogs alter the window width and height in Firefox
+ // Dialogs alter the window width and height in Firefox
// so we collect that information before creating the dialog
// Support: Firefox
var winWidth = $( window ).width(),
winHeight = $( window ).height(),
- element = $("<div></div>").dialog(),
- dialog = element.dialog("widget"),
+ element = $( "<div></div>" ).dialog(),
+ dialog = element.dialog( "widget" ),
offset = dialog.offset();
assert.close( offset.left, Math.round( winWidth / 2 - dialog.outerWidth() / 2 ) + $( window ).scrollLeft(), 1, "dialog left position of center on window on initilization" );
assert.close( offset.top, Math.round( winHeight / 2 - dialog.outerHeight() / 2 ) + $( window ).scrollTop(), 1, "dialog top position of center on window on initilization" );
element.remove();
-});
+} );
test( "position, right bottom at right bottom via ui.position args", function( assert ) {
expect( 2 );
- // dialogs alter the window width and height in Firefox
+ // Dialogs alter the window width and height in Firefox
// so we collect that information before creating the dialog
// Support: Firefox
var winWidth = $( window ).width(),
winHeight = $( window ).height(),
- element = $("<div></div>").dialog({
+ element = $( "<div></div>" ).dialog( {
position: {
my: "right bottom",
at: "right bottom"
}
- }),
- dialog = element.dialog("widget"),
+ } ),
+ dialog = element.dialog( "widget" ),
offset = dialog.offset();
assert.close( offset.left, winWidth - dialog.outerWidth() + $( window ).scrollLeft(), 1, "dialog left position of right bottom at right bottom on initilization" );
assert.close( offset.top, winHeight - dialog.outerHeight() + $( window ).scrollTop(), 1, "dialog top position of right bottom at right bottom on initilization" );
element.remove();
-});
+} );
test( "position, at another element", function( assert ) {
expect( 4 );
- var parent = $("<div></div>").css({
+ var parent = $( "<div></div>" ).css( {
position: "absolute",
top: 400,
left: 600,
height: 10,
width: 10
- }).appendTo("body"),
+ } ).appendTo( "body" ),
- element = $("<div></div>").dialog({
+ element = $( "<div></div>" ).dialog( {
position: {
my: "left top",
at: "left top",
of: parent,
collision: "none"
}
- }),
+ } ),
- dialog = element.dialog("widget"),
+ dialog = element.dialog( "widget" ),
offset = dialog.offset();
assert.close( offset.left, 600, 1, "dialog left position at another element on initilization" );
assert.close( offset.top, 400, 1, "dialog top position at another element on initilization" );
- element.dialog("option", "position", {
+ element.dialog( "option", "position", {
my: "left top",
at: "right bottom",
of: parent,
collision: "none"
- });
+ } );
offset = dialog.offset();
@@ -418,32 +418,33 @@ test( "position, at another element", function( assert ) {
element.remove();
parent.remove();
-});
+} );
-test("resizable", function() {
- expect(4);
+test( "resizable", function() {
+ expect( 4 );
- var element = $("<div></div>").dialog();
- testHelper.shouldResize(element, 50, 50, "[default]");
- element.dialog("option", "resizable", false);
- testHelper.shouldResize(element, 0, 0, "disabled after init");
+ var element = $( "<div></div>" ).dialog();
+ testHelper.shouldResize( element, 50, 50, "[default]" );
+ element.dialog( "option", "resizable", false );
+ testHelper.shouldResize( element, 0, 0, "disabled after init" );
element.remove();
- element = $("<div></div>").dialog({ resizable: false });
- testHelper.shouldResize(element, 0, 0, "disabled in init options");
- element.dialog("option", "resizable", true);
- testHelper.shouldResize(element, 50, 50, "enabled after init");
+ element = $( "<div></div>" ).dialog( { resizable: false } );
+ testHelper.shouldResize( element, 0, 0, "disabled in init options" );
+ element.dialog( "option", "resizable", true );
+ testHelper.shouldResize( element, 50, 50, "enabled after init" );
element.remove();
-});
+} );
test( "title", function() {
expect( 11 );
function titleText() {
- return element.dialog("widget").find( ".ui-dialog-title" ).html();
+ return element.dialog( "widget" ).find( ".ui-dialog-title" ).html();
}
var element = $( "<div></div>" ).dialog();
+
// some browsers return a non-breaking space and some return "&nbsp;"
// so we generate a non-breaking space for comparison
equal( titleText(), $( "<span>&#160;</span>" ).html(), "[default]" );
@@ -452,106 +453,107 @@ test( "title", function() {
element = $( "<div title='foo'>" ).dialog();
equal( titleText(), "foo", "title in element attribute" );
- equal( element.dialog( "option", "title"), "foo", "option updated from attribute" );
+ equal( element.dialog( "option", "title" ), "foo", "option updated from attribute" );
element.remove();
- element = $( "<div></div>" ).dialog({ title: "foo" });
+ element = $( "<div></div>" ).dialog( { title: "foo" } );
equal( titleText(), "foo", "title in init options" );
- equal( element.dialog("option", "title"), "foo", "opiton set from options hash" );
+ equal( element.dialog( "option", "title" ), "foo", "opiton set from options hash" );
element.remove();
- element = $( "<div title='foo'>" ).dialog({ title: "bar" });
+ element = $( "<div title='foo'>" ).dialog( { title: "bar" } );
equal( titleText(), "bar", "title in init options should override title in element attribute" );
- equal( element.dialog("option", "title"), "bar", "opiton set from options hash" );
+ equal( element.dialog( "option", "title" ), "bar", "opiton set from options hash" );
element.remove();
element = $( "<div></div>" ).dialog().dialog( "option", "title", "foo" );
equal( titleText(), "foo", "title after init" );
element.remove();
- // make sure attroperties are properly ignored - #5742 - .attr() might return a DOMElement
+ // Make sure attroperties are properly ignored - #5742 - .attr() might return a DOMElement
element = $( "<form><input name='title'></form>" ).dialog();
+
// some browsers return a non-breaking space and some return "&nbsp;"
// so we get the text to normalize to the actual non-breaking space
equal( titleText(), $( "<span>&#160;</span>" ).html(), "[default]" );
equal( element.dialog( "option", "title" ), null, "option not changed" );
element.remove();
-});
+} );
-test("width", function( assert ) {
- expect(3);
+test( "width", function( assert ) {
+ expect( 3 );
- var element = $("<div></div>").dialog();
- assert.close(element.dialog("widget").width(), 300, 1, "default width");
+ var element = $( "<div></div>" ).dialog();
+ assert.close( element.dialog( "widget" ).width(), 300, 1, "default width" );
element.remove();
- element = $("<div></div>").dialog({width: 437 });
- assert.close(element.dialog("widget").width(), 437, 1, "explicit width");
- element.dialog("option", "width", 438);
- assert.close(element.dialog("widget").width(), 438, 1, "explicit width after init");
+ element = $( "<div></div>" ).dialog( { width: 437 } );
+ assert.close( element.dialog( "widget" ).width(), 437, 1, "explicit width" );
+ element.dialog( "option", "width", 438 );
+ assert.close( element.dialog( "widget" ).width(), 438, 1, "explicit width after init" );
element.remove();
-});
+} );
-test("#4826: setting resizable false toggles resizable on dialog", function() {
- expect(6);
+test( "#4826: setting resizable false toggles resizable on dialog", function() {
+ expect( 6 );
var i,
- element = $("<div></div>").dialog({ resizable: false });
+ element = $( "<div></div>" ).dialog( { resizable: false } );
- testHelper.shouldResize(element, 0, 0, "[default]");
- for (i=0; i<2; i++) {
- element.dialog("close").dialog("open");
- testHelper.shouldResize(element, 0, 0, "initialized with resizable false toggle ("+ (i+1) +")");
+ testHelper.shouldResize( element, 0, 0, "[default]" );
+ for ( i = 0; i < 2; i++ ) {
+ element.dialog( "close" ).dialog( "open" );
+ testHelper.shouldResize( element, 0, 0, "initialized with resizable false toggle (" + ( i + 1 ) + ")" );
}
element.remove();
- element = $("<div></div>").dialog({ resizable: true });
- testHelper.shouldResize(element, 50, 50, "[default]");
- for (i=0; i<2; i++) {
- element.dialog("close").dialog("option", "resizable", false).dialog("open");
- testHelper.shouldResize(element, 0, 0, "set option resizable false toggle ("+ (i+1) +")");
+ element = $( "<div></div>" ).dialog( { resizable: true } );
+ testHelper.shouldResize( element, 50, 50, "[default]" );
+ for ( i = 0; i < 2; i++ ) {
+ element.dialog( "close" ).dialog( "option", "resizable", false ).dialog( "open" );
+ testHelper.shouldResize( element, 0, 0, "set option resizable false toggle (" + ( i + 1 ) + ")" );
}
element.remove();
-});
+} );
asyncTest( "#8051 - 'Explode' dialog animation causes crash in IE 6, 7 and 8", function() {
expect( 1 );
- var element = $( "<div></div>" ).dialog({
+ var element = $( "<div></div>" ).dialog( {
show: "explode",
focus: function() {
ok( true, "dialog opened with animation" );
element.remove();
start();
}
- });
-});
+ } );
+} );
asyncTest( "#4421 - Focus lost from dialog which uses show-effect", function() {
expect( 1 );
- var element = $( "<div></div>" ).dialog({
+ var element = $( "<div></div>" ).dialog( {
show: "blind",
focus: function() {
equal( element.dialog( "widget" ).find( document.activeElement ).length, 1, "dialog maintains focus" );
element.remove();
start();
}
- });
-});
+ } );
+} );
asyncTest( "Open followed by close during show effect", function() {
expect( 1 );
- var element = $( "<div></div>" ).dialog({
+ var element = $( "<div></div>" ).dialog( {
show: "blind",
close: function() {
ok( true, "dialog closed properly during animation" );
element.remove();
start();
}
- });
+ } );
setTimeout( function() {
- element.dialog("close");
+ element.dialog( "close" );
}, 100 );
-});
+} );
} );
diff --git a/tests/unit/draggable/common.js b/tests/unit/draggable/common.js
index d09e6b7b7..228bba5dc 100644
--- a/tests/unit/draggable/common.js
+++ b/tests/unit/draggable/common.js
@@ -37,12 +37,12 @@ common.testWidget( "draggable", {
distance: 1,
iframeFix: false,
- // callbacks
+ // Callbacks
create: null,
drag: null,
start: null,
stop: null
}
-});
+} );
} );
diff --git a/tests/unit/draggable/core.js b/tests/unit/draggable/core.js
index 30563b622..8bc751e0e 100644
--- a/tests/unit/draggable/core.js
+++ b/tests/unit/draggable/core.js
@@ -14,84 +14,84 @@ test( "element types", function( assert ) {
",table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr" +
",acronym,code,samp,kbd,var,img,hr" +
",input,button,label,select,iframe"
- ).split(",");
+ ).split( "," );
expect( typeNames.length * 2 );
$.each( typeNames, function( i ) {
var offsetBefore, offsetAfter,
typeName = typeNames[ i ],
- el = $( document.createElement( typeName ) ).appendTo("#qunit-fixture");
+ el = $( document.createElement( typeName ) ).appendTo( "#qunit-fixture" );
if ( typeName === "table" ) {
- el.append("<tr><td>content</td></tr>");
+ el.append( "<tr><td>content</td></tr>" );
}
- el.draggable({ cancel: "" });
+ el.draggable( { cancel: "" } );
offsetBefore = el.offset();
el.simulate( "drag", {
dx: 50,
dy: 50
- });
+ } );
offsetAfter = el.offset();
// Support: FF, Chrome, and IE9,
// there are some rounding errors in so we can't say equal, we have to settle for close enough
assert.close( offsetBefore.left, offsetAfter.left - 50, 1, "dragged[50, 50] " + "<" + typeName + "> left" );
assert.close( offsetBefore.top, offsetAfter.top - 50, 1, "dragged[50, 50] " + "<" + typeName + "> top" );
- el.draggable("destroy");
+ el.draggable( "destroy" );
el.remove();
- });
-});
+ } );
+} );
test( "No options, relative", function() {
expect( 2 );
testHelper.shouldMove( $( "#draggable1" ).draggable(), "no options, relative" );
-});
+} );
test( "No options, absolute", function() {
expect( 2 );
testHelper.shouldMove( $( "#draggable2" ).draggable(), "no options, absolute" );
-});
+} );
test( "resizable handle with complex markup (#8756 / #8757)", function() {
expect( 2 );
$( "#draggable1" )
.append(
- $("<div>")
- .addClass("ui-resizable-handle ui-resizable-w")
- .append( $("<div>") )
+ $( "<div>" )
+ .addClass( "ui-resizable-handle ui-resizable-w" )
+ .append( $( "<div>" ) )
);
- var handle = $(".ui-resizable-w div"),
- target = $( "#draggable1" ).draggable().resizable({ handles: "all" });
+ var handle = $( ".ui-resizable-w div" ),
+ target = $( "#draggable1" ).draggable().resizable( { handles: "all" } );
- // todo: fix resizable so it doesn't require a mouseover
- handle.simulate("mouseover").simulate( "drag", { dx: -50 } );
+ // Todo: fix resizable so it doesn't require a mouseover
+ handle.simulate( "mouseover" ).simulate( "drag", { dx: -50 } );
equal( target.width(), 250, "compare width" );
- // todo: fix resizable so it doesn't require a mouseover
- handle.simulate("mouseover").simulate( "drag", { dx: 50 } );
+ // Todo: fix resizable so it doesn't require a mouseover
+ handle.simulate( "mouseover" ).simulate( "drag", { dx: 50 } );
equal( target.width(), 200, "compare width" );
-});
+} );
test( "#8269: Removing draggable element on drop", function() {
expect( 2 );
- var element = $( "#draggable1" ).wrap( "<div id='wrapper' />" ).draggable({
+ var element = $( "#draggable1" ).wrap( "<div id='wrapper' />" ).draggable( {
stop: function() {
ok( true, "stop still called despite element being removed from DOM on drop" );
}
- }),
+ } ),
dropOffset = $( "#droppable" ).offset();
- $( "#droppable" ).droppable({
+ $( "#droppable" ).droppable( {
drop: function() {
$( "#wrapper" ).remove();
ok( true, "element removed from DOM on drop" );
}
- });
+ } );
// Support: Opera 12.10, Safari 5.1, jQuery <1.8
if ( testHelper.unreliableContains ) {
@@ -102,31 +102,31 @@ test( "#8269: Removing draggable element on drop", function() {
handle: "corner",
x: dropOffset.left,
y: dropOffset.top
- });
+ } );
}
-});
+} );
// http://bugs.jqueryui.com/ticket/7778
// drag element breaks in IE8 when its content is replaced onmousedown
test( "Stray mousemove after mousedown still drags", function() {
expect( 2 );
- var element = $( "#draggable1" ).draggable({ scroll: false });
+ var element = $( "#draggable1" ).draggable( { scroll: false } );
// In IE8, when content is placed under the mouse (e.g. when draggable content is replaced
// on mousedown), mousemove is triggered on those elements even though the mouse hasn't moved.
// Support: IE <9
element.on( "mousedown", function() {
- $( document ).simulate( "mousemove", { button: -1 });
- });
+ $( document ).simulate( "mousemove", { button: -1 } );
+ } );
testHelper.shouldMove( element, "element is draggable" );
-});
+} );
test( "#6258: not following mouse when scrolled and using overflow-y: scroll", function() {
expect( 2 );
- var element = $( "#draggable1" ).draggable({
+ var element = $( "#draggable1" ).draggable( {
stop: function( event, ui ) {
equal( ui.position.left, 1, "left position is correct despite overflow on HTML" );
equal( ui.position.top, 1, "top position is correct despite overflow on HTML" );
@@ -136,7 +136,7 @@ test( "#6258: not following mouse when scrolled and using overflow-y: scroll", f
.scrollTop( 0 )
.scrollLeft( 0 );
}
- }),
+ } ),
oldOverflowY = $( "html" ).css( "overflow-y" ),
oldOverflowX = $( "html" ).css( "overflow-x" );
@@ -152,19 +152,19 @@ test( "#6258: not following mouse when scrolled and using overflow-y: scroll", f
dx: 1,
dy: 1,
moves: 1
- });
-});
+ } );
+} );
test( "#9315: jumps down with offset of scrollbar", function() {
expect( 2 );
- var element = $( "#draggable2" ).draggable({
+ var element = $( "#draggable2" ).draggable( {
stop: function( event, ui ) {
equal( ui.position.left, 11, "left position is correct when position is absolute" );
equal( ui.position.top, 11, "top position is correct when position is absolute" );
$( "html" ).scrollTop( 0 ).scrollLeft( 0 );
}
- });
+ } );
testHelper.forceScrollableWindow();
@@ -174,21 +174,23 @@ test( "#9315: jumps down with offset of scrollbar", function() {
dx: 1,
dy: 1,
moves: 1
- });
-});
+ } );
+} );
test( "scroll offset with fixed ancestors", function() {
expect( 2 );
var startValue = 300,
element = $( "#draggable1" )
+
// http://bugs.jqueryui.com/ticket/5009
// scroll not working with parent's position fixed
.wrap( "<div id='wrapper' />" )
+
// http://bugs.jqueryui.com/ticket/9612
// abspos elements inside of fixed elements moving away from the mouse when scrolling
.wrap( "<div id='wrapper2' />" )
- .draggable({
+ .draggable( {
drag: function() {
startValue += 100;
$( document ).scrollTop( startValue ).scrollLeft( startValue );
@@ -198,7 +200,7 @@ test( "scroll offset with fixed ancestors", function() {
equal( ui.position.top, 10, "top position is correct when parent position is fixed" );
$( document ).scrollTop( 0 ).scrollLeft( 0 );
}
- });
+ } );
testHelper.forceScrollableWindow();
@@ -209,30 +211,30 @@ test( "scroll offset with fixed ancestors", function() {
dx: 10,
dy: 10,
moves: 3
- });
-});
+ } );
+} );
-$( [ "hidden", "auto", "scroll" ] ).each(function() {
+$( [ "hidden", "auto", "scroll" ] ).each( function() {
var overflow = this;
- // http://bugs.jqueryui.com/ticket/9379 - position bug in scrollable div
+ // Http://bugs.jqueryui.com/ticket/9379 - position bug in scrollable div
// http://bugs.jqueryui.com/ticket/10147 - Wrong position in a parent with "overflow: hidden"
test( "position in scrollable parent with overflow: " + overflow, function() {
expect( 2 );
$( "#qunit-fixture" ).html( "<div id='outer'><div id='inner'></div><div id='dragged'>a</div></div>" );
- $( "#inner" ).css({ position: "absolute", width: "500px", height: "500px" });
- $( "#outer" ).css({ position: "absolute", width: "300px", height: "300px" });
- $( "#dragged" ).css({ width: "10px", height: "10px" });
+ $( "#inner" ).css( { position: "absolute", width: "500px", height: "500px" } );
+ $( "#outer" ).css( { position: "absolute", width: "300px", height: "300px" } );
+ $( "#dragged" ).css( { width: "10px", height: "10px" } );
var moves = 3,
startValue = 0,
dragDelta = 20,
delta = 100,
- // we scroll after each drag event, so subtract 1 from number of moves for expected
+ // We scroll after each drag event, so subtract 1 from number of moves for expected
expected = delta + ( ( moves - 1 ) * dragDelta ),
- element = $( "#dragged" ).draggable({
+ element = $( "#dragged" ).draggable( {
drag: function() {
startValue += dragDelta;
$( "#outer" ).scrollTop( startValue ).scrollLeft( startValue );
@@ -241,7 +243,7 @@ $( [ "hidden", "auto", "scroll" ] ).each(function() {
equal( ui.position.left, expected, "left position is correct when grandparent is scrolled" );
equal( ui.position.top, expected, "top position is correct when grandparent is scrolled" );
}
- });
+ } );
$( "#outer" ).css( "overflow", overflow );
@@ -249,9 +251,9 @@ $( [ "hidden", "auto", "scroll" ] ).each(function() {
dy: delta,
dx: delta,
moves: moves
- });
- });
-});
+ } );
+ } );
+} );
test( "#5727: draggable from iframe", function() {
expect( 1 );
@@ -273,7 +275,7 @@ test( "#5727: draggable from iframe", function() {
// TODO: fix draggable within an IFRAME to fire events on the element properly
// and these testHelper.shouldMove relies on events for testing
//testHelper.shouldMove( draggable1, "draggable from an iframe" );
-});
+} );
test( "#8399: A draggable should become the active element after you are finished interacting with it, but not before.", function() {
expect( 2 );
@@ -282,12 +284,12 @@ test( "#8399: A draggable should become the active element after you are finishe
$( document ).one( "mousemove", function() {
notStrictEqual( document.activeElement, element.get( 0 ), "moving a draggable anchor did not make it the active element" );
- });
+ } );
testHelper.move( element, 50, 50 );
strictEqual( document.activeElement, element.get( 0 ), "finishing moving a draggable anchor made it the active element" );
-});
+} );
asyncTest( "blur behavior", function() {
expect( 3 );
@@ -300,18 +302,18 @@ asyncTest( "blur behavior", function() {
testHelper.move( focusElement, 1, 1 );
- // http://bugs.jqueryui.com/ticket/10527
+ // Http://bugs.jqueryui.com/ticket/10527
// Draggable: Can't select option in modal dialog (IE8)
strictEqual( document.activeElement, focusElement.get( 0 ), "test element is focused after mousing down on itself" );
testHelper.move( element, 50, 50 );
- // http://bugs.jqueryui.com/ticket/4261
+ // Http://bugs.jqueryui.com/ticket/4261
// active element should blur when mousing down on a draggable
notStrictEqual( document.activeElement, focusElement.get( 0 ), "test element is no longer focused after mousing down on a draggable" );
start();
- });
-});
+ } );
+} );
test( "ui-draggable-handle assigned to appropriate element", function( assert ) {
expect( 5 );
@@ -328,7 +330,7 @@ test( "ui-draggable-handle assigned to appropriate element", function( assert )
element.draggable( "destroy" );
assert.lacksClasses( element.find( "p" ), "ui-draggable-handle" );
-});
+} );
test( "ui-draggable-handle managed correctly in nested draggables", function( assert ) {
expect( 4 );
@@ -341,6 +343,6 @@ test( "ui-draggable-handle managed correctly in nested draggables", function( as
parent.draggable( "destroy" );
assert.lacksClasses( parent, "ui-draggable-handle", "parent loses class name on destroy" );
assert.hasClasses( child, "ui-draggable-handle", "child retains class name on destroy" );
-});
+} );
} );
diff --git a/tests/unit/draggable/events.js b/tests/unit/draggable/events.js
index 7e276092b..36a5a8705 100644
--- a/tests/unit/draggable/events.js
+++ b/tests/unit/draggable/events.js
@@ -7,12 +7,12 @@ var element;
module( "draggable: events", {
setup: function() {
- element = $("<div>").appendTo("#qunit-fixture");
+ element = $( "<div>" ).appendTo( "#qunit-fixture" );
},
teardown: function() {
- element.draggable("destroy");
+ element.draggable( "destroy" );
}
-});
+} );
test( "callbacks occurrence count", function() {
expect( 3 );
@@ -21,7 +21,7 @@ test( "callbacks occurrence count", function() {
stop = 0,
dragc = 0;
- element.draggable({
+ element.draggable( {
start: function() {
start++;
},
@@ -31,17 +31,17 @@ test( "callbacks occurrence count", function() {
stop: function() {
stop++;
}
- });
+ } );
element.simulate( "drag", {
dx: 10,
dy: 10
- });
+ } );
equal( start, 1, "start callback should happen exactly once" );
equal( dragc, 3, "drag callback should happen exactly once per mousemove" );
equal( stop, 1, "stop callback should happen exactly once" );
-});
+} );
test( "stopping the start callback", function() {
expect( 3 );
@@ -50,7 +50,7 @@ test( "stopping the start callback", function() {
stop = 0,
dragc = 0;
- element.draggable({
+ element.draggable( {
start: function() {
start++;
return false;
@@ -61,17 +61,17 @@ test( "stopping the start callback", function() {
stop: function() {
stop++;
}
- });
+ } );
element.simulate( "drag", {
dx: 10,
dy: 10
- });
+ } );
equal( start, 1, "start callback should happen exactly once" );
equal( dragc, 0, "drag callback should not happen at all" );
equal( stop, 0, "stop callback should not happen if there wasnt even a start" );
-});
+} );
test( "stopping the drag callback", function() {
expect( 2 );
@@ -80,7 +80,7 @@ test( "stopping the drag callback", function() {
stop = 0,
dragc = 0;
- element.draggable({
+ element.draggable( {
start: function() {
start++;
},
@@ -91,34 +91,34 @@ test( "stopping the drag callback", function() {
stop: function() {
stop++;
}
- });
+ } );
element.simulate( "drag", {
dx: 10,
dy: 10
- });
+ } );
equal( start, 1, "start callback should happen exactly once" );
equal( stop, 1, "stop callback should happen, as we need to actively stop the drag" );
-});
+} );
test( "stopping the stop callback", function() {
expect( 1 );
- element.draggable({
+ element.draggable( {
helper: "clone",
stop: function() {
return false;
}
- });
+ } );
element.simulate( "drag", {
dx: 10,
dy: 10
- });
+ } );
ok( element.draggable( "instance" ).helper, "the clone should not be deleted if the stop callback is stopped" );
-});
+} );
// http://bugs.jqueryui.com/ticket/6884
// Draggable: ui.offset.left differs between the "start" and "drag" hooks
@@ -129,7 +129,7 @@ test( "position and offset in hash is consistent between start, drag, and stop",
element = $( "<div style='margin: 2px;'></div>" ).appendTo( "#qunit-fixture" );
- element.draggable({
+ element.draggable( {
start: function( event, ui ) {
startPos = ui.position;
startOffset = ui.offset;
@@ -142,13 +142,13 @@ test( "position and offset in hash is consistent between start, drag, and stop",
stopPos = ui.position;
stopOffset = ui.offset;
}
- });
+ } );
element.simulate( "drag", {
dx: 10,
dy: 10,
moves: 1
- });
+ } );
startPos.left += 10;
startPos.top += 10;
@@ -159,6 +159,6 @@ test( "position and offset in hash is consistent between start, drag, and stop",
deepEqual( dragPos, stopPos, "drag position equals stop position" );
deepEqual( startOffset, dragOffset, "start offset equals drag offset plus distance" );
deepEqual( dragOffset, stopOffset, "drag offset equals stop offset" );
-});
+} );
} );
diff --git a/tests/unit/draggable/helper.js b/tests/unit/draggable/helper.js
index 7aabe2a00..02a6ddaf5 100644
--- a/tests/unit/draggable/helper.js
+++ b/tests/unit/draggable/helper.js
@@ -8,12 +8,13 @@ return $.extend( helper, {
// TODO: remove the unreliable offset hacks
unreliableOffset: $.ui.ie && ( !document.documentMode || document.documentMode < 8 ) ? 2 : 0,
+
// Support: Opera 12.10, Safari 5.1, jQuery <1.8
- unreliableContains: (function() {
+ unreliableContains: ( function() {
var element = $( "<div>" );
return $.contains( element[ 0 ].ownerDocument, element[ 0 ] );
- })(),
+ } )(),
testDragPosition: function( el, dx, dy, expectedDX, expectedDY, msg ) {
msg = msg ? msg + "." : "";
@@ -21,7 +22,7 @@ return $.extend( helper, {
$( el ).one( "dragstop", function( event, ui ) {
var positionExpected = { left: ui.originalPosition.left + expectedDX, top: ui.originalPosition.top + expectedDY };
deepEqual( ui.position, positionExpected, "position dragged[" + dx + ", " + dy + "] " + msg );
- });
+ } );
},
testDragOffset: function( el, dx, dy, expectedDX, expectedDY, msg ) {
@@ -32,7 +33,7 @@ return $.extend( helper, {
$( el ).one( "dragstop", function( event, ui ) {
deepEqual( ui.offset, offsetExpected, "offset dragged[" + dx + ", " + dy + "] " + msg );
- });
+ } );
},
testDragHelperOffset: function( el, dx, dy, expectedDX, expectedDY, msg ) {
@@ -43,7 +44,7 @@ return $.extend( helper, {
$( el ).one( "dragstop", function( event, ui ) {
deepEqual( ui.helper.offset(), offsetExpected, "offset dragged[" + dx + ", " + dy + "] " + msg );
- });
+ } );
},
testDrag: function( el, handle, dx, dy, expectedDX, expectedDY, msg ) {
@@ -53,7 +54,7 @@ return $.extend( helper, {
$( handle ).simulate( "drag", {
dx: dx,
dy: dy
- });
+ } );
},
shouldMovePositionButNotOffset: function( el, msg, handle ) {
@@ -64,7 +65,7 @@ return $.extend( helper, {
$( handle ).simulate( "drag", {
dx: 100,
dy: 100
- });
+ } );
},
shouldMove: function( el, msg, handle ) {
@@ -86,12 +87,12 @@ return $.extend( helper, {
element.on( "dragstop", function() {
ok( false, "should not drag " + msg );
- });
+ } );
$( handle ).simulate( "drag", {
dx: 100,
dy: 100
- });
+ } );
newOffset = element.offset();
@@ -105,12 +106,12 @@ return $.extend( helper, {
setScrollable: function( what, isScrollable ) {
var overflow = isScrollable ? "scroll" : "hidden";
- $( what ).css({ overflow: overflow, overflowX: overflow, overflowY: overflow });
+ $( what ).css( { overflow: overflow, overflowX: overflow, overflowY: overflow } );
},
testScroll: function( el, position ) {
var oldPosition = $( "#main" ).css( "position" );
- $( "#main" ).css({ position: position, top: "0px", left: "0px" });
+ $( "#main" ).css( { position: position, top: "0px", left: "0px" } );
this.shouldMove( el, position + " parent" );
$( "#main" ).css( "position", oldPosition );
},
@@ -135,23 +136,24 @@ return $.extend( helper, {
$( el ).simulate( "drag", {
dx: x,
dy: y
- });
+ } );
},
trackMouseCss: function( el ) {
el.on( "drag", function() {
el.data( "last_dragged_cursor", $( "body" ).css( "cursor" ) );
- });
+ } );
},
trackAppendedParent: function( el ) {
+
// TODO: appendTo is currently ignored if helper is original (see #7044)
el.draggable( "option", "helper", "clone" );
// Get what parent is at time of drag
- el.on( "drag", function(e, ui) {
+ el.on( "drag", function( e, ui ) {
el.data( "last_dragged_parent", ui.helper.parent()[ 0 ] );
- });
+ } );
}
} );
diff --git a/tests/unit/draggable/methods.js b/tests/unit/draggable/methods.js
index 10a17efdb..77ba2434f 100644
--- a/tests/unit/draggable/methods.js
+++ b/tests/unit/draggable/methods.js
@@ -8,12 +8,12 @@ var element;
module( "draggable: methods", {
setup: function() {
- element = $("<div style='background: green; width: 200px; height: 100px; position: absolute; top: 10px; left: 10px;'><span>Absolute</span></div>").appendTo("#qunit-fixture");
+ element = $( "<div style='background: green; width: 200px; height: 100px; position: absolute; top: 10px; left: 10px;'><span>Absolute</span></div>" ).appendTo( "#qunit-fixture" );
},
teardown: function() {
element.remove();
}
-});
+} );
test( "init", function() {
expect( 5 );
@@ -21,10 +21,10 @@ test( "init", function() {
element.draggable();
ok( true, ".draggable() called on element" );
- $([]).draggable();
+ $( [] ).draggable();
ok( true, ".draggable() called on empty collection" );
- $("<div></div>").draggable();
+ $( "<div></div>" ).draggable();
ok( true, ".draggable() called on disconnected DOMElement" );
element.draggable( "option", "foo" );
@@ -32,52 +32,52 @@ test( "init", function() {
element.draggable( "option", "foo", "bar" );
ok( true, "arbitrary option setter after init" );
-});
+} );
test( "destroy", function() {
expect( 4 );
- element.draggable().draggable("destroy");
+ element.draggable().draggable( "destroy" );
ok( true, ".draggable('destroy') called on element" );
- $([]).draggable().draggable("destroy");
+ $( [] ).draggable().draggable( "destroy" );
ok( true, ".draggable('destroy') called on empty collection" );
- element.draggable().draggable("destroy");
+ element.draggable().draggable( "destroy" );
ok( true, ".draggable('destroy') called on disconnected DOMElement" );
var expected = element.draggable(),
- actual = expected.draggable("destroy");
+ actual = expected.draggable( "destroy" );
equal( actual, expected, "destroy is chainable" );
-});
+} );
test( "enable", function() {
expect( 11 );
- element.draggable({ disabled: true });
+ element.draggable( { disabled: true } );
testHelper.shouldNotDrag( element, ".draggable({ disabled: true })" );
- element.draggable("enable");
+ element.draggable( "enable" );
testHelper.shouldMove( element, ".draggable('enable')" );
equal( element.draggable( "option", "disabled" ), false, "disabled option getter" );
- element.draggable("destroy");
- element.draggable({ disabled: true });
+ element.draggable( "destroy" );
+ element.draggable( { disabled: true } );
testHelper.shouldNotDrag( element, ".draggable({ disabled: true })" );
element.draggable( "option", "disabled", false );
- equal(element.draggable( "option", "disabled" ), false, "disabled option setter" );
+ equal( element.draggable( "option", "disabled" ), false, "disabled option setter" );
testHelper.shouldMove( element, ".draggable('option', 'disabled', false)" );
var expected = element.draggable(),
- actual = expected.draggable("enable");
+ actual = expected.draggable( "enable" );
equal( actual, expected, "enable is chainable" );
-});
+} );
test( "disable", function( assert ) {
expect( 14 );
- element = $( "#draggable2" ).draggable({ disabled: false });
+ element = $( "#draggable2" ).draggable( { disabled: false } );
testHelper.shouldMove( element, ".draggable({ disabled: false })" );
element.draggable( "disable" );
@@ -85,7 +85,7 @@ test( "disable", function( assert ) {
equal( element.draggable( "option", "disabled" ), true, "disabled option getter" );
element.draggable( "destroy" );
- element.draggable({ disabled: false });
+ element.draggable( { disabled: false } );
testHelper.shouldMove( element, ".draggable({ disabled: false })" );
element.draggable( "option", "disabled", true );
@@ -99,6 +99,6 @@ test( "disable", function( assert ) {
var expected = element.draggable(),
actual = expected.draggable( "disable" );
equal( actual, expected, "disable is chainable" );
-});
+} );
} );
diff --git a/tests/unit/draggable/options.js b/tests/unit/draggable/options.js
index e1fd8288a..2c8de5a0a 100644
--- a/tests/unit/draggable/options.js
+++ b/tests/unit/draggable/options.js
@@ -9,33 +9,33 @@ define( [
// TODO: This doesn't actually test whether append happened, possibly remove
test( "{ appendTo: 'parent' }, default, no clone", function() {
expect( 4 );
- var element = $( "#draggable2" ).draggable({ appendTo: "parent" });
+ var element = $( "#draggable2" ).draggable( { appendTo: "parent" } );
testHelper.shouldMove( element, "absolute appendTo: parent" );
- element = $( "#draggable1" ).draggable({ appendTo: "parent" });
+ element = $( "#draggable1" ).draggable( { appendTo: "parent" } );
testHelper.shouldMove( element, "relative appendTo: parent" );
-});
+} );
// TODO: This doesn't actually test whether append happened, possibly remove
test( "{ appendTo: Element }, no clone", function() {
expect( 4 );
- var element = $( "#draggable2" ).draggable({ appendTo: $( "#draggable2" ).parent()[ 0 ] });
+ var element = $( "#draggable2" ).draggable( { appendTo: $( "#draggable2" ).parent()[ 0 ] } );
testHelper.shouldMove( element, "absolute appendTo: Element" );
- element = $( "#draggable1" ).draggable({ appendTo: $( "#draggable2" ).parent()[ 0 ] });
+ element = $( "#draggable1" ).draggable( { appendTo: $( "#draggable2" ).parent()[ 0 ] } );
testHelper.shouldMove( element, "relative appendTo: Element" );
-});
+} );
// TODO: This doesn't actually test whether append happened, possibly remove
test( "{ appendTo: Selector }, no clone", function() {
expect( 4 );
- var element = $( "#draggable2" ).draggable({ appendTo: "#main" });
+ var element = $( "#draggable2" ).draggable( { appendTo: "#main" } );
testHelper.shouldMove( element, "absolute appendTo: Selector" );
- element = $( "#draggable1" ).draggable({ appendTo: "#main" });
+ element = $( "#draggable1" ).draggable( { appendTo: "#main" } );
testHelper.shouldMove( element, "relative appendTo: Selector" );
-});
+} );
test( "{ appendTo: 'parent' }, default", function() {
expect( 2 );
@@ -48,48 +48,48 @@ test( "{ appendTo: 'parent' }, default", function() {
testHelper.move( element, 1, 1 );
equal( element.data( "last_dragged_parent" ), $( "#main" )[ 0 ] );
-});
+} );
test( "{ appendTo: Element }", function() {
expect( 1 );
var appendTo = $( "#draggable2" ).parent()[ 0 ],
- element = $( "#draggable1" ).draggable({ appendTo: appendTo });
+ element = $( "#draggable1" ).draggable( { appendTo: appendTo } );
testHelper.trackAppendedParent( element );
testHelper.move( element, 1, 1 );
equal( element.data( "last_dragged_parent" ), appendTo );
-});
+} );
test( "{ appendTo: jQuery }", function() {
expect( 1 );
var appendTo = $( "#draggable2" ).parent(),
- element = $( "#draggable1" ).draggable({ appendTo: appendTo });
+ element = $( "#draggable1" ).draggable( { appendTo: appendTo } );
testHelper.trackAppendedParent( element );
testHelper.move( element, 1, 1 );
equal( element.data( "last_dragged_parent" ), appendTo[ 0 ] );
-});
+} );
test( "{ appendTo: Selector }", function() {
expect( 1 );
var appendTo = "#main",
- element = $( "#draggable1" ).draggable({ appendTo: appendTo });
+ element = $( "#draggable1" ).draggable( { appendTo: appendTo } );
testHelper.trackAppendedParent( element );
testHelper.move( element, 1, 1 );
- equal( element.data( "last_dragged_parent" ), $(appendTo)[ 0 ] );
-});
+ equal( element.data( "last_dragged_parent" ), $( appendTo )[ 0 ] );
+} );
test( "appendTo, default, switching after initialization", function() {
expect( 2 );
- var element = $( "#draggable1" ).draggable({ helper: "clone" });
+ var element = $( "#draggable1" ).draggable( { helper: "clone" } );
testHelper.trackAppendedParent( element );
@@ -101,25 +101,25 @@ test( "appendTo, default, switching after initialization", function() {
element.draggable( "option", "appendTo", $( "#qunit-fixture" ) );
testHelper.move( element, 2, 2 );
equal( element.data( "last_dragged_parent" ), $( "#qunit-fixture" )[ 0 ] );
-});
+} );
test( "{ axis: false }, default", function() {
expect( 2 );
- var element = $( "#draggable2" ).draggable({ axis: false });
+ var element = $( "#draggable2" ).draggable( { axis: false } );
testHelper.shouldMove( element, "axis: false" );
-});
+} );
test( "{ axis: 'x' }", function() {
expect( 2 );
- var element = $( "#draggable2" ).draggable({ axis: "x" });
+ var element = $( "#draggable2" ).draggable( { axis: "x" } );
testHelper.testDrag( element, element, 50, 50, 50, 0, "axis: x" );
-});
+} );
test( "{ axis: 'y' }", function() {
expect( 2 );
- var element = $( "#draggable2" ).draggable({ axis: "y" });
+ var element = $( "#draggable2" ).draggable( { axis: "y" } );
testHelper.testDrag( element, element, 50, 50, 0, 50, "axis: y" );
-});
+} );
test( "{ axis: ? }, unexpected", function() {
var element,
@@ -134,17 +134,17 @@ test( "{ axis: ? }, unexpected", function() {
expect( 12 );
- $.each(unexpected, function(key, val) {
- element = $( "#draggable2" ).draggable({ axis: val });
+ $.each( unexpected, function( key, val ) {
+ element = $( "#draggable2" ).draggable( { axis: val } );
testHelper.shouldMove( element, "axis: " + key );
element.draggable( "destroy" );
- });
-});
+ } );
+} );
test( "axis, default, switching after initialization", function() {
expect( 6 );
- var element = $( "#draggable1" ).draggable({ axis: false });
+ var element = $( "#draggable1" ).draggable( { axis: false } );
// Any Direction
testHelper.shouldMove( element, "axis: default" );
@@ -157,22 +157,22 @@ test( "axis, default, switching after initialization", function() {
element.draggable( "option", "axis", "y" );
testHelper.testDrag( element, element, 50, 50, 0, 50, "axis: y as option" );
-});
+} );
test( "{ cancel: 'input,textarea,button,select,option' }, default", function() {
expect( 4 );
$( "<div id='draggable-option-cancel-default'><input type='text'></div>" ).appendTo( "#qunit-fixture" );
- var element = $( "#draggable-option-cancel-default" ).draggable({ cancel: "input,textarea,button,select,option" });
+ var element = $( "#draggable-option-cancel-default" ).draggable( { cancel: "input,textarea,button,select,option" } );
testHelper.shouldMove( element, "cancel: default, element dragged" );
element.draggable( "destroy" );
- element = $( "#draggable-option-cancel-default" ).draggable({ cancel: "input,textarea,button,select,option" });
+ element = $( "#draggable-option-cancel-default" ).draggable( { cancel: "input,textarea,button,select,option" } );
testHelper.shouldNotDrag( element, "cancel: default, input dragged", "#draggable-option-cancel-default input" );
element.draggable( "destroy" );
-});
+} );
test( "{ cancel: 'span' }", function() {
expect( 4 );
@@ -182,9 +182,9 @@ test( "{ cancel: 'span' }", function() {
element.draggable( "destroy" );
- element = $( "#draggable2" ).draggable({ cancel: "span" });
+ element = $( "#draggable2" ).draggable( { cancel: "span" } );
testHelper.shouldNotDrag( element, "cancel: span, span dragged", "#draggable2 span" );
-});
+} );
test( "{ cancel: ? }, unexpected", function() {
expect( 12 );
@@ -200,11 +200,11 @@ test( "{ cancel: ? }, unexpected", function() {
};
$.each( unexpected, function( key, val ) {
- element = $( "#draggable2" ).draggable({ cancel: val });
+ element = $( "#draggable2" ).draggable( { cancel: val } );
testHelper.shouldMove( element, "cancel: " + key );
element.draggable( "destroy" );
- });
-});
+ } );
+} );
/*
test( "{ cancel: Selectors }, matching parent selector", function() {
@@ -246,17 +246,17 @@ test( "cancelement, default, switching after initialization", function() {
element.draggable( "option", "cancel", "input" );
testHelper.shouldNotDrag( element, "cancel: input, input dragged", input );
-});
+} );
test( "connectToSortable, dragging out of a sortable", function() {
expect( 4 );
var sortItem, dragHelper,
- element = $( "#draggableSortable" ).draggable({
+ element = $( "#draggableSortable" ).draggable( {
scroll: false,
connectToSortable: "#sortable"
- }),
- sortable = $( "#sortable" ).sortable({ revert: 100 }),
+ } ),
+ sortable = $( "#sortable" ).sortable( { revert: 100 } ),
dx = 50,
dy = 50,
offsetBefore = element.offset(),
@@ -267,80 +267,83 @@ test( "connectToSortable, dragging out of a sortable", function() {
$( sortable ).one( "sortstart", function( event, ui ) {
sortItem = ui.item;
- });
+ } );
$( element ).one( "drag", function( event, ui ) {
dragHelper = ui.helper;
- });
+ } );
$( element ).one( "dragstop", function( event, ui ) {
+
// http://bugs.jqueryui.com/ticket/8809
// Position issue when connected to sortable
deepEqual( ui.helper.offset(), offsetExpected, "draggable offset is correct" );
- // http://bugs.jqueryui.com/ticket/7734
+ // Http://bugs.jqueryui.com/ticket/7734
// HTML IDs are removed when dragging to a Sortable
equal( sortItem[ 0 ], dragHelper[ 0 ], "both have the same helper" );
equal( sortItem.attr( "id" ), dragHelper.attr( "id" ), "both have the same id" );
- // http://bugs.jqueryui.com/ticket/9481
+ // Http://bugs.jqueryui.com/ticket/9481
// connectToSortable causes sortable revert to fail on second attempt
equal( sortable.sortable( "option", "revert" ), 100, "sortable revert behavior is preserved" );
- });
+ } );
element.simulate( "drag", {
dx: dx,
dy: dy
- });
-});
+ } );
+} );
asyncTest( "connectToSortable, dragging clone into sortable", function() {
expect( 3 );
var offsetPlaceholder,
- element = $( "#draggableSortableClone" ).draggable({
+ element = $( "#draggableSortableClone" ).draggable( {
scroll: false,
connectToSortable: "#sortable",
helper: "clone"
- }),
- sortable = $( "#sortable" ).sortable({ revert: 100 }),
+ } ),
+ sortable = $( "#sortable" ).sortable( { revert: 100 } ),
offsetSortable = sortable.offset();
$( sortable ).one( "sort", function( event, ui ) {
offsetPlaceholder = ui.placeholder.offset();
+
// http://bugs.jqueryui.com/ticket/8809
// Position issue when connected to sortable
deepEqual( ui.helper.offset(), offsetSortable, "sortable offset is correct" );
notDeepEqual( ui.helper.offset(), offsetPlaceholder, "offset not equal to placeholder" );
- });
+ } );
$( sortable ).one( "sortstop", function( event, ui ) {
+
// http://bugs.jqueryui.com/ticket/9675
// Animation issue with revert and connectToSortable
deepEqual( ui.item.offset(), offsetPlaceholder, "offset eventually equals placeholder" );
start();
- });
+ } );
element.simulate( "drag", {
x: offsetSortable.left + 1,
y: offsetSortable.top + 1,
moves: 1
- });
-});
+ } );
+} );
test( "connectToSortable, dragging multiple elements in and out of sortable", function() {
expect( 1 );
- var element = $( "#draggableSortableClone" ).draggable({
+ var element = $( "#draggableSortableClone" ).draggable( {
scroll: false,
connectToSortable: "#sortable",
helper: "clone"
- }),
- element2 = $( "#draggableSortable" ).draggable({
+ } ),
+ element2 = $( "#draggableSortable" ).draggable( {
scroll: false,
connectToSortable: "#sortable"
- }),
- sortable = $( "#sortable" ).sortable({ revert: false }),
+ } ),
+ sortable = $( "#sortable" ).sortable( { revert: false } ),
sortableOffset = sortable.offset();
// Move element into sortable
@@ -348,40 +351,40 @@ test( "connectToSortable, dragging multiple elements in and out of sortable", fu
x: sortableOffset.left + 1,
y: sortableOffset.top + 1,
moves: 10
- });
+ } );
// Move element in sortable out
element2.simulate( "drag", {
dx: 200,
dy: 200,
moves: 10
- });
+ } );
- // http://bugs.jqueryui.com/ticket/9675
+ // Http://bugs.jqueryui.com/ticket/9675
// Animation issue with revert and connectToSortable
sortable.one( "sortstop", function( event, ui ) {
ok( !$.contains( document, ui.placeholder[ 0 ] ), "placeholder was removed" );
- });
+ } );
// Move the clone of the first element back out
$( "#sortable .sortable2Item" ).simulate( "drag", {
dx: 200,
dy: 200,
moves: 10
- });
-});
+ } );
+} );
test( "connectToSortable, dragging through one sortable to a second", function() {
expect( 2 );
var overCount = 0,
- element = $( "#draggableSortable" ).draggable({
+ element = $( "#draggableSortable" ).draggable( {
scroll: false,
connectToSortable: ".sortable"
- }),
+ } ),
delta = 200,
- sortable = $( "#sortable" ).sortable({ revert: false }),
- sortable2 = $( "#sortable2" ).sortable({ revert: false }),
+ sortable = $( "#sortable" ).sortable( { revert: false } ),
+ sortable2 = $( "#sortable2" ).sortable( { revert: false } ),
sortable2Offset = sortable2.offset(),
dragParams = {
x: sortable2Offset.left + 25,
@@ -392,51 +395,51 @@ test( "connectToSortable, dragging through one sortable to a second", function()
$( sortable ).one( "sortover", function() {
overCount++;
sortable2.css( "top", "+=" + delta );
- });
+ } );
$( sortable2 ).on( "sortupdate", function() {
ok( true, "second sortable is updated" );
- });
+ } );
$( sortable2 ).one( "sortover", function() {
overCount++;
- });
+ } );
$( sortable2 ).one( "sortstop", function() {
equal( overCount, 2, "went over both sortables" );
- });
+ } );
element.simulate( "drag", dragParams );
-});
+} );
test( "connectToSortable, dragging through a sortable", function() {
expect( 1 );
- var draggable = $( "#draggableSortable" ).draggable({
+ var draggable = $( "#draggableSortable" ).draggable( {
scroll: false,
connectToSortable: "#sortable2"
- }),
+ } ),
sortable = $( "#sortable2" ).sortable(),
sortableOffset = sortable.offset();
- // http://bugs.jqueryui.com/ticket/10669
+ // Http://bugs.jqueryui.com/ticket/10669
// Draggable: Position issue with connectToSortable
draggable.one( "dragstop", function() {
equal( draggable.parent().attr( "id" ), "sortable", "restored draggable to original parent" );
- });
+ } );
draggable.simulate( "drag", {
x: sortableOffset.left + 25,
y: sortableOffset.top + sortable.outerHeight() + 400,
moves: 20
- });
-});
+ } );
+} );
test( "{ containment: Element }", function() {
expect( 1 );
var offsetAfter,
- element = $( "#draggable1" ).draggable({ containment: $( "#draggable1" ).parent()[ 0 ] }),
+ element = $( "#draggable1" ).draggable( { containment: $( "#draggable1" ).parent()[ 0 ] } ),
p = element.parent(),
po = p.offset(),
expected = {
@@ -447,16 +450,16 @@ test( "{ containment: Element }", function() {
element.simulate( "drag", {
dx: -100,
dy: -100
- });
+ } );
offsetAfter = element.offset();
deepEqual( offsetAfter, expected, "compare offset to parent" );
-});
+} );
test( "{ containment: Selector }", function() {
expect( 1 );
var offsetAfter,
- element = $( "#draggable1" ).draggable({ containment: $( "#qunit-fixture" ) }),
+ element = $( "#draggable1" ).draggable( { containment: $( "#qunit-fixture" ) } ),
p = element.parent(),
po = p.offset(),
expected = {
@@ -467,10 +470,10 @@ test( "{ containment: Selector }", function() {
element.simulate( "drag", {
dx: -100,
dy: -100
- });
+ } );
offsetAfter = element.offset();
deepEqual( offsetAfter, expected, "compare offset to parent" );
-});
+} );
test( "{ containment: [x1, y1, x2, y2] }", function() {
expect( 2 );
@@ -481,13 +484,13 @@ test( "{ containment: [x1, y1, x2, y2] }", function() {
element.draggable( "option", "containment", [ eo.left, eo.top, eo.left + element.width() + 5, eo.top + element.height() + 5 ] );
testHelper.testDrag( element, element, -100, -100, 0, 0, "containment: [x1, y1, x2, y2]" );
-});
+} );
test( "{ containment: 'parent' }, relative", function() {
expect( 1 );
var offsetAfter,
- element = $( "#draggable1" ).draggable({ containment: "parent" }),
+ element = $( "#draggable1" ).draggable( { containment: "parent" } ),
p = element.parent(),
po = p.offset(),
expected = {
@@ -498,16 +501,16 @@ test( "{ containment: 'parent' }, relative", function() {
element.simulate( "drag", {
dx: -100,
dy: -100
- });
+ } );
offsetAfter = element.offset();
deepEqual( offsetAfter, expected, "compare offset to parent" );
-});
+} );
test( "{ containment: 'parent' }, absolute", function() {
expect( 1 );
var offsetAfter,
- element = $( "#draggable2" ).draggable({ containment: "parent" }),
+ element = $( "#draggable2" ).draggable( { containment: "parent" } ),
p = element.parent(),
po = p.offset(),
expected = {
@@ -518,41 +521,41 @@ test( "{ containment: 'parent' }, absolute", function() {
element.simulate( "drag", {
dx: -100,
dy: -100
- });
+ } );
offsetAfter = element.offset();
deepEqual( offsetAfter, expected, "compare offset to parent" );
-});
+} );
test( "containment, account for border", function( assert ) {
expect( 2 );
var el = $( "#draggable1" ).appendTo( "#scrollParent" ),
- parent = el.parent().css({
+ parent = el.parent().css( {
height: "100px",
width: "100px",
borderStyle: "solid",
borderWidth: "5px 10px 15px 20px"
- }),
+ } ),
parentBottom = parent.offset().top + parent.outerHeight(),
parentRight = parent.offset().left + parent.outerWidth(),
parentBorderBottom = testHelper.border( parent, "bottom" ),
parentBorderRight = testHelper.border( parent, "right" );
- el.css({
+ el.css( {
height: "5px",
width: "5px"
- }).draggable({ containment: "parent", scroll: false });
+ } ).draggable( { containment: "parent", scroll: false } );
el.simulate( "drag", {
dx: 100,
dy: 100
- });
+ } );
assert.close( el.offset().top, parentBottom - parentBorderBottom - el.height(), 1,
"The draggable should be on top of its parent's bottom border" );
assert.close( el.offset().left, parentRight - parentBorderRight - el.width(), 1,
"The draggable should be to the right of its parent's right border" );
-});
+} );
// http://bugs.jqueryui.com/ticket/7016
// draggable can be pulled out of containment in Chrome and IE8
@@ -560,48 +563,48 @@ test( "containment, element cant be pulled out of container", function() {
expect( 1 );
var offsetBefore,
- parent = $( "<div>").css({ width: 200, height: 200 }).appendTo( "#qunit-fixture" ),
+ parent = $( "<div>" ).css( { width: 200, height: 200 } ).appendTo( "#qunit-fixture" ),
element = $( "#draggable1" ).appendTo( parent );
element
- .css({
+ .css( {
height: "5px",
width: "5px"
- })
- .draggable({ containment: "parent" })
+ } )
+ .draggable( { containment: "parent" } )
.simulate( "drag", {
dx: 500,
dy: 500
- });
+ } );
offsetBefore = element.offset();
element.simulate( "drag", {
dx: 200,
dy: 200
- });
+ } );
deepEqual( element.offset(), offsetBefore, "The draggable should not move past bottom right edge" );
-});
+} );
test( "containment, default, switching after initialization", function() {
expect( 8 );
- var element = $( "#draggable1" ).draggable({ containment: false, scroll: false }),
+ var element = $( "#draggable1" ).draggable( { containment: false, scroll: false } ),
po = element.parent().offset(),
containment = [ po.left - 100, po.top - 100, po.left + 500, po.top + 500 ];
testHelper.testDrag( element, element, -100, -100, -100, -100, "containment: default" );
- element.draggable( "option", "containment", "parent" ).css({ top: 0, left: 0 });
+ element.draggable( "option", "containment", "parent" ).css( { top: 0, left: 0 } );
testHelper.testDrag( element, element, -100, -100, 0, 0, "containment: parent as option" );
- element.draggable( "option", "containment", containment ).css({ top: 0, left: 0 });
+ element.draggable( "option", "containment", containment ).css( { top: 0, left: 0 } );
testHelper.testDrag( element, element, -100, -100, -100, -100, "containment: array as option" );
element.draggable( "option", "containment", false );
testHelper.testDrag( element, element, -100, -100, -100, -100, "containment: false as option" );
-});
+} );
test( "{ cursor: 'auto' }, default", function() {
function getCursor() {
@@ -612,23 +615,23 @@ test( "{ cursor: 'auto' }, default", function() {
var actual, after,
expected = "auto",
- element = $( "#draggable2" ).draggable({
+ element = $( "#draggable2" ).draggable( {
cursor: expected,
start: function() {
actual = getCursor();
}
- }),
+ } ),
before = getCursor();
element.simulate( "drag", {
dx: -1,
dy: -1
- });
+ } );
after = getCursor();
equal( actual, expected, "start callback: cursor '" + expected + "'" );
equal( after, before, "after drag: cursor restored" );
-});
+} );
test( "{ cursor: 'move' }", function() {
function getCursor() {
@@ -639,23 +642,23 @@ test( "{ cursor: 'move' }", function() {
var actual, after,
expected = "move",
- element = $( "#draggable2" ).draggable({
+ element = $( "#draggable2" ).draggable( {
cursor: expected,
start: function() {
actual = getCursor();
}
- }),
+ } ),
before = getCursor();
element.simulate( "drag", {
dx: -1,
dy: -1
- });
+ } );
after = getCursor();
equal( actual, expected, "start callback: cursor '" + expected + "'" );
equal( after, before, "after drag: cursor restored" );
-});
+} );
test( "#6889: Cursor doesn't revert to pre-dragging state after revert action when original element is removed", function() {
function getCursor() {
@@ -664,7 +667,7 @@ test( "#6889: Cursor doesn't revert to pre-dragging state after revert action wh
expect( 2 );
- var element = $( "#draggable1" ).wrap( "<div id='wrapper' />" ).draggable({
+ var element = $( "#draggable1" ).wrap( "<div id='wrapper' />" ).draggable( {
cursor: "move",
revert: true,
revertDuration: 0,
@@ -675,7 +678,7 @@ test( "#6889: Cursor doesn't revert to pre-dragging state after revert action wh
stop: function() {
equal( getCursor(), expected, "after drag: cursor restored" );
}
- }),
+ } ),
expected = getCursor();
if ( testHelper.unreliableContains ) {
@@ -685,9 +688,9 @@ test( "#6889: Cursor doesn't revert to pre-dragging state after revert action wh
element.simulate( "drag", {
dx: -1,
dy: -1
- });
+ } );
}
-});
+} );
test( "cursor, default, switching after initialization", function() {
expect( 3 );
@@ -706,7 +709,7 @@ test( "cursor, default, switching after initialization", function() {
element.draggable( "option", "cursor", "ns-resize" );
testHelper.move( element, 1, 1 );
equal( element.data( "last_dragged_cursor" ), "ns-resize" );
-});
+} );
test( "cursorAt", function() {
expect( 24 );
@@ -724,7 +727,7 @@ test( "cursorAt", function() {
$.each( tests, function( testName, testData ) {
$.each( [ "relative", "absolute" ], function( i, position ) {
- var element = $( "#draggable" + ( i + 1 ) ).draggable({
+ var element = $( "#draggable" + ( i + 1 ) ).draggable( {
cursorAt: testData.cursorAt,
drag: function( event, ui ) {
if ( !testData.cursorAt ) {
@@ -738,16 +741,16 @@ test( "cursorAt", function() {
equal( event.clientY - ui.offset.top, testData.y + testHelper.unreliableOffset, testName + " " + position + " top" );
}
}
- });
+ } );
element.simulate( "drag", {
moves: 1,
dx: deltaX,
dy: deltaY
- });
- });
- });
-});
+ } );
+ } );
+ } );
+} );
test( "cursorAt, switching after initialization", function() {
expect( 24 );
@@ -767,7 +770,7 @@ test( "cursorAt, switching after initialization", function() {
$.each( [ "relative", "absolute" ], function( i, position ) {
var element = $( "#draggable" + ( i + 1 ) );
- element.draggable({
+ element.draggable( {
drag: function( event, ui ) {
if ( !testData.cursorAt ) {
equal( ui.position.left - ui.originalPosition.left, deltaX, testName + " " + position + " left" );
@@ -780,7 +783,7 @@ test( "cursorAt, switching after initialization", function() {
equal( event.clientY - ui.offset.top, testData.y + testHelper.unreliableOffset, testName + " " + position + " top" );
}
}
- });
+ } );
element.draggable( "option", "cursorAt", false );
element.draggable( "option", "cursorAt", testData.cursorAt );
@@ -789,10 +792,10 @@ test( "cursorAt, switching after initialization", function() {
moves: 1,
dx: deltaX,
dy: deltaY
- });
- });
- });
-});
+ } );
+ } );
+ } );
+} );
test( "disabled", function() {
expect( 6 );
@@ -806,23 +809,23 @@ test( "disabled", function() {
element.draggable( "option", "disabled", false );
testHelper.shouldMove( element, "option: disabled false" );
-});
+} );
test( "{ grid: [50, 50] }, relative", function() {
expect( 4 );
- var element = $( "#draggable1" ).draggable({ grid: [ 50, 50 ] });
+ var element = $( "#draggable1" ).draggable( { grid: [ 50, 50 ] } );
testHelper.testDrag( element, element, 24, 24, 0, 0, "grid: [50, 50] relative" );
testHelper.testDrag( element, element, 26, 25, 50, 50, "grid: [50, 50] relative" );
-});
+} );
test( "{ grid: [50, 50] }, absolute", function() {
expect( 4 );
- var element = $( "#draggable2" ).draggable({ grid: [ 50, 50 ] });
+ var element = $( "#draggable2" ).draggable( { grid: [ 50, 50 ] } );
testHelper.testDrag( element, element, 24, 24, 0, 0, "grid: [50, 50] absolute" );
testHelper.testDrag( element, element, 26, 25, 50, 50, "grid: [50, 50] absolute" );
-});
+} );
test( "grid, switching after initialization", function() {
expect( 8 );
@@ -837,17 +840,17 @@ test( "grid, switching after initialization", function() {
testHelper.testDrag( element, element, 24, 24, 0, 0, "grid: [50, 50] as option" );
testHelper.testDrag( element, element, 26, 25, 50, 50, "grid: [50, 50] as option" );
-});
+} );
test( "{ handle: 'span' }", function() {
expect( 6 );
- var element = $( "#draggable2" ).draggable({ handle: "span" });
+ var element = $( "#draggable2" ).draggable( { handle: "span" } );
- testHelper.shouldMove( element, "handle: span", "#draggable2 span");
+ testHelper.shouldMove( element, "handle: span", "#draggable2 span" );
testHelper.shouldMove( element, "handle: span child", "#draggable2 span em" );
testHelper.shouldNotDrag( element, "handle: span element" );
-});
+} );
test( "handle, default, switching after initialization", function() {
expect( 12 );
@@ -866,7 +869,7 @@ test( "handle, default, switching after initialization", function() {
element.draggable( "option", "handle", false );
testHelper.shouldMove( element, "handle: false as option, element dragged" );
testHelper.shouldMove( element, "handle: false as option, span dragged", "#draggable2 span" );
-});
+} );
test( "helper, default, switching after initialization", function() {
expect( 6 );
@@ -879,36 +882,36 @@ test( "helper, default, switching after initialization", function() {
element.draggable( "option", "helper", "original" );
testHelper.shouldMove( element, "helper: original" );
-});
+} );
// http://bugs.jqueryui.com/ticket/9446
// Draggable: helper function cannot emulate default behavior
test( "helper, function returning original element", function() {
expect( 1 );
- var element = $( "#draggable1" ).css( "position", "static" ).draggable({
+ var element = $( "#draggable1" ).css( "position", "static" ).draggable( {
helper: function() {
return this;
}
- });
+ } );
testHelper.testDragHelperOffset( element, 100, 100, 100, 100, "original element is draggable" );
element.simulate( "drag", {
dx: 100,
dy: 100
- });
-});
+ } );
+} );
function testHelperPosition( scrollPositions, position, helper, scrollElements, scrollElementsTitle ) {
test( "{ helper: '" + helper + "' }, " + position + ", with scroll offset on " + scrollElementsTitle, function() {
expect( scrollPositions.length * 2 );
var i, j,
- element = $( "#draggable1" ).css({ position: position, top: 0, left: 0 }).draggable({
+ element = $( "#draggable1" ).css( { position: position, top: 0, left: 0 } ).draggable( {
helper: helper,
scroll: false
- });
+ } );
if ( scrollElements.length === 1 && scrollElements[ 0 ] === "#scrollParent" ) {
testHelper.setScrollable( "#main", false );
@@ -931,10 +934,10 @@ function testHelperPosition( scrollPositions, position, helper, scrollElements,
testHelper.setScrollable( "#main", true );
testHelper.setScrollable( "#scrollParent", false );
}
- });
+ } );
}
-(function() {
+( function() {
var scrollElementsMap = {
"no elements": [],
"parent": [ "#main" ],
@@ -944,6 +947,7 @@ function testHelperPosition( scrollPositions, position, helper, scrollElements,
},
positions = [ "absolute", "fixed", "relative", "static" ],
helpers = [ "original", "clone" ],
+
// static is not an option here since the fixture is in an absolute container
scrollPositions = [ "relative", "absolute", "fixed" ];
@@ -953,39 +957,39 @@ function testHelperPosition( scrollPositions, position, helper, scrollElements,
var position = this;
$.each( scrollElementsMap, function( scrollElementsTitle, scrollElements ) {
testHelperPosition( scrollPositions, position, helper, scrollElements, scrollElementsTitle );
- });
- });
- });
-})();
+ } );
+ } );
+ } );
+} )();
test( "{ opacity: 0.5 }", function() {
expect( 1 );
var opacity = null,
- element = $( "#draggable2" ).draggable({
+ element = $( "#draggable2" ).draggable( {
opacity: 0.5,
start: function() {
- opacity = $(this).css( "opacity" );
+ opacity = $( this ).css( "opacity" );
}
- });
+ } );
element.simulate( "drag", {
dx: -1,
dy: -1
- });
+ } );
equal( opacity, 0.5, "start callback: opacity is" );
-});
+} );
test( "opacity, default, switching after initialization", function() {
expect( 3 );
var opacity = null,
- element = $( "#draggable2" ).draggable({
+ element = $( "#draggable2" ).draggable( {
start: function() {
- opacity = $(this).css( "opacity" );
+ opacity = $( this ).css( "opacity" );
}
- });
+ } );
testHelper.move( element, 1, 1 );
equal( opacity, 1 );
@@ -997,15 +1001,15 @@ test( "opacity, default, switching after initialization", function() {
element.draggable( "option", "opacity", false );
testHelper.move( element, 3, 1 );
equal( opacity, 1 );
-});
+} );
asyncTest( "revert and revertDuration", function() {
expect( 7 );
- var element = $( "#draggable2" ).draggable({
+ var element = $( "#draggable2" ).draggable( {
revert: true,
revertDuration: 0
- });
+ } );
testHelper.shouldMovePositionButNotOffset( element, "revert: true, revertDuration: 0 should revert immediately" );
$( "#draggable2" ).draggable( "option", "revert", "invalid" );
@@ -1020,45 +1024,45 @@ asyncTest( "revert and revertDuration", function() {
stop: function() {
start();
}
- });
+ } );
- // animation are async, so test for it asynchronously
+ // Animation are async, so test for it asynchronously
testHelper.move( element, 50, 50 );
setTimeout( function() {
ok( $( "#draggable2" ).is( ":animated" ), "revert: true with revertDuration should animate" );
- });
-});
+ } );
+} );
test( "revert: valid", function() {
expect( 2 );
- var element = $( "#draggable2" ).draggable({
+ var element = $( "#draggable2" ).draggable( {
revert: "valid",
revertDuration: 0
- });
+ } );
$( "#droppable" ).droppable();
testHelper.shouldMovePositionButNotOffset( element, "revert: valid reverts when dropped on a droppable" );
-});
+} );
test( "scope", function() {
expect( 4 );
- var element = $( "#draggable2" ).draggable({
+ var element = $( "#draggable2" ).draggable( {
scope: "tasks",
revert: "valid",
revertDuration: 0
- });
+ } );
- $( "#droppable" ).droppable({ scope: "tasks" });
+ $( "#droppable" ).droppable( { scope: "tasks" } );
testHelper.shouldMovePositionButNotOffset( element, "revert: valid reverts when dropped on a droppable in scope" );
- $( "#droppable" ).droppable( "destroy" ).droppable({ scope: "nottasks" });
+ $( "#droppable" ).droppable( "destroy" ).droppable( { scope: "nottasks" } );
testHelper.shouldMove( element, "revert: valid reverts when dropped on a droppable out of scope" );
-});
+} );
test( "scroll, scrollSensitivity, and scrollSpeed", function() {
expect( 2 );
@@ -1067,46 +1071,46 @@ test( "scroll, scrollSensitivity, and scrollSpeed", function() {
var currentScrollTop,
viewportHeight = $( window ).height(),
- element = $( "#draggable1" ).draggable({ scroll: true }).appendTo( "#qunit-fixture" ),
+ element = $( "#draggable1" ).draggable( { scroll: true } ).appendTo( "#qunit-fixture" ),
scrollSensitivity = element.draggable( "option", "scrollSensitivity" ),
scrollSpeed = element.draggable( "option", "scrollSpeed" );
- element.offset({
+ element.offset( {
top: viewportHeight - scrollSensitivity - 1,
left: 1
- });
+ } );
$( element ).one( "drag", function() {
equal( $( window ).scrollTop(), 0, "scroll: true doesn't scroll when the element is dragged outside of scrollSensitivity" );
- });
+ } );
element.simulate( "drag", {
dx: 1,
y: viewportHeight - scrollSensitivity - 1,
moves: 1
- });
+ } );
element.draggable( "option", "scrollSensitivity", scrollSensitivity + 10 );
- element.offset({
+ element.offset( {
top: viewportHeight - scrollSensitivity - 1,
left: 1
- });
+ } );
currentScrollTop = $( window ).scrollTop();
$( element ).one( "drag", function() {
ok( $( window ).scrollTop() - currentScrollTop, scrollSpeed, "scroll: true scrolls when the element is dragged within scrollSensitivity" );
- });
+ } );
element.simulate( "drag", {
dx: 1,
y: viewportHeight - scrollSensitivity - 1,
moves: 1
- });
+ } );
testHelper.restoreScroll( document );
-});
+} );
test( "scroll ignores containers that are overflow: hidden", function() {
expect( 2 );
@@ -1119,7 +1123,7 @@ test( "scroll ignores containers that are overflow: hidden", function() {
element.simulate( "drag", {
dx: 1300,
dy: 1300
- });
+ } );
// IE8 natively scrolls when dragging an element inside a overflow:hidden
// container, so skip this test if native scroll occurs.
@@ -1130,16 +1134,16 @@ test( "scroll ignores containers that are overflow: hidden", function() {
return;
}
- element.css({ top: 0, left: 0 }).draggable( "option", "scroll", true );
+ element.css( { top: 0, left: 0 } ).draggable( "option", "scroll", true );
element.simulate( "drag", {
dx: 1300,
dy: 1300
- });
+ } );
equal( scrollParent.scrollTop(), 0, "container doesn't scroll vertically" );
equal( scrollParent.scrollLeft(), 0, "container doesn't scroll horizontally" );
-});
+} );
test( "#6817: auto scroll goes double distance when dragging", function( assert ) {
expect( 2 );
@@ -1149,22 +1153,23 @@ test( "#6817: auto scroll goes double distance when dragging", function( assert
var offsetBefore,
distance = 10,
viewportHeight = $( window ).height(),
- element = $( "#draggable1" ).draggable({
+ element = $( "#draggable1" ).draggable( {
scroll: true,
stop: function( e, ui ) {
equal( ui.offset.top, newY, "offset of item matches pointer position after scroll" );
+
// TODO: fix IE8 testswarm IFRAME positioning bug so assert.close can be turned back to equal
assert.close( ui.offset.top - offsetBefore.top, distance, 1, "offset of item only moves expected distance after scroll" );
}
- }),
+ } ),
scrollSensitivity = element.draggable( "option", "scrollSensitivity" ),
oldY = viewportHeight - scrollSensitivity,
newY = oldY + distance;
- element.offset({
+ element.offset( {
top: oldY,
left: 1
- });
+ } );
offsetBefore = element.offset();
@@ -1173,32 +1178,32 @@ test( "#6817: auto scroll goes double distance when dragging", function( assert
dx: 1,
y: newY,
moves: 1
- });
+ } );
testHelper.restoreScroll( document );
-});
+} );
test( "snap, snapMode, and snapTolerance", function( assert ) {
expect( 10 );
var newX, newY,
snapTolerance = 15,
- element = $( "#draggable1" ).draggable({
+ element = $( "#draggable1" ).draggable( {
snap: true,
scroll: false,
snapMode: "both",
snapTolerance: snapTolerance
- }),
+ } ),
element2 = $( "#draggable2" ).draggable();
- // http://bugs.jqueryui.com/ticket/9724
+ // Http://bugs.jqueryui.com/ticket/9724
// Draggable: Snapping coordinates thrown off by margin on draggable
element.css( "margin", "3px" );
- element.offset({
+ element.offset( {
top: 1,
left: 1
- });
+ } );
newX = element2.offset().left - element.outerWidth() - snapTolerance - 2;
newY = element2.offset().top;
@@ -1208,7 +1213,7 @@ test( "snap, snapMode, and snapTolerance", function( assert ) {
x: newX,
y: newY,
moves: 1
- });
+ } );
// TODO: fix IE8 testswarm IFRAME positioning bug so assert.close can be turned back to equal
assert.close( element.offset().left, newX, 1, "doesn't snap outside the snapTolerance" );
@@ -1221,7 +1226,7 @@ test( "snap, snapMode, and snapTolerance", function( assert ) {
x: newX,
y: newY,
moves: 1
- });
+ } );
notDeepEqual( element.offset(), { top: newY, left: newX }, "snaps inside the snapTolerance" );
@@ -1232,7 +1237,7 @@ test( "snap, snapMode, and snapTolerance", function( assert ) {
x: newX,
y: newY,
moves: 1
- });
+ } );
notDeepEqual( element.offset(), { top: newY, left: newX }, "snaps based on selector" );
@@ -1243,7 +1248,7 @@ test( "snap, snapMode, and snapTolerance", function( assert ) {
x: newX,
y: newY,
moves: 1
- });
+ } );
deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap based on invalid selector" );
@@ -1254,7 +1259,7 @@ test( "snap, snapMode, and snapTolerance", function( assert ) {
x: newX,
y: newY,
moves: 1
- });
+ } );
deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap outside the modified snapTolerance" );
@@ -1266,7 +1271,7 @@ test( "snap, snapMode, and snapTolerance", function( assert ) {
x: newX,
y: newY,
moves: 1
- });
+ } );
deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap inside the outer snapTolerance area when snapMode is inner" );
@@ -1278,7 +1283,7 @@ test( "snap, snapMode, and snapTolerance", function( assert ) {
x: newX,
y: newY,
moves: 1
- });
+ } );
deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap inside the outer snapTolerance area when snapMode is inner" );
@@ -1289,7 +1294,7 @@ test( "snap, snapMode, and snapTolerance", function( assert ) {
x: newX,
y: newY,
moves: 1
- });
+ } );
notDeepEqual( element.offset(), { top: newY, left: newX }, "snaps inside the inner snapTolerance area when snapMode is inner" );
@@ -1300,17 +1305,17 @@ test( "snap, snapMode, and snapTolerance", function( assert ) {
x: newX,
y: newY,
moves: 1
- });
+ } );
deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap on the inner snapTolerance area when snapMode is outer" );
-});
+} );
test( "#8459: element can snap to an element that was removed during drag", function( assert ) {
expect( 2 );
var newX, newY,
snapTolerance = 15,
- element = $( "#draggable1" ).draggable({
+ element = $( "#draggable1" ).draggable( {
snap: true,
scroll: false,
snapMode: "both",
@@ -1318,13 +1323,13 @@ test( "#8459: element can snap to an element that was removed during drag", func
start: function() {
element2.remove();
}
- }),
+ } ),
element2 = $( "#draggable2" ).draggable();
- element.offset({
+ element.offset( {
top: 1,
left: 1
- });
+ } );
newX = element2.offset().left - element.outerWidth() - snapTolerance + 1;
newY = element2.offset().top;
@@ -1334,18 +1339,19 @@ test( "#8459: element can snap to an element that was removed during drag", func
x: newX,
y: newY,
moves: 1
- });
+ } );
// Support: Opera 12.10, Safari 5.1, jQuery <1.8
if ( testHelper.unreliableContains ) {
ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
} else {
+
// TODO: fix IE8 testswarm IFRAME positioning bug so assert.close can be turned back to equal
assert.close( element.offset().left, newX, 1, "doesn't snap to a removed element" );
assert.close( element.offset().top, newY, 1, "doesn't snap to a removed element" );
}
-});
+} );
test( "#8165: Snapping large rectangles to small rectangles doesn't snap properly", function() {
expect( 1 );
@@ -1353,85 +1359,85 @@ test( "#8165: Snapping large rectangles to small rectangles doesn't snap properl
var snapTolerance = 20,
y = 1,
element = $( "#draggable1" )
- .css({
+ .css( {
width: "50px",
height: "200px"
- }).offset({
+ } ).offset( {
top: y,
left: 1
- }),
+ } ),
element2 = $( "#draggable2" )
- .css({
+ .css( {
width: "50px",
height: "50px"
- }).offset({
+ } ).offset( {
top: y + snapTolerance + 1,
left: 200
- }),
+ } ),
newX = element2.offset().left - element.outerWidth() - snapTolerance + 1;
- $( "#draggable1, #draggable2" ).draggable({
+ $( "#draggable1, #draggable2" ).draggable( {
snap: true,
snapTolerance: snapTolerance
- });
+ } );
element.simulate( "drag", {
handle: "corner",
x: newX,
moves: 1
- });
+ } );
notDeepEqual( element.offset(), { top: y, left: newX }, "snaps even if only a side (not a corner) is inside the snapTolerance" );
-});
+} );
test( "stack", function() {
expect( 2 );
- var element = $( "#draggable1" ).draggable({
+ var element = $( "#draggable1" ).draggable( {
stack: "#draggable1, #draggable2"
- }),
- element2 = $( "#draggable2" ).draggable({
+ } ),
+ element2 = $( "#draggable2" ).draggable( {
stack: "#draggable1, #draggable2"
- });
+ } );
testHelper.move( element, 1, 1 );
equal( element.css( "zIndex" ), "2", "stack increments zIndex correctly" );
testHelper.move( element2, 1, 1 );
equal( element2.css( "zIndex" ), "3", "stack increments zIndex correctly" );
-});
+} );
test( "{ zIndex: 10 }", function() {
expect( 1 );
var actual,
expected = 10,
- element = $( "#draggable2" ).draggable({
+ element = $( "#draggable2" ).draggable( {
zIndex: expected,
start: function() {
- actual = $(this).css( "zIndex" );
+ actual = $( this ).css( "zIndex" );
}
- });
+ } );
element.simulate( "drag", {
dx: -1,
dy: -1
- });
+ } );
equal( actual, expected, "start callback: zIndex is" );
-});
+} );
test( "zIndex, default, switching after initialization", function() {
expect( 3 );
var zindex = null,
- element = $( "#draggable2" ).draggable({
+ element = $( "#draggable2" ).draggable( {
start: function() {
- zindex = $(this).css( "z-index" );
+ zindex = $( this ).css( "z-index" );
}
- });
+ } );
element.css( "z-index", 1 );
@@ -1446,48 +1452,49 @@ test( "zIndex, default, switching after initialization", function() {
testHelper.move( element, 3, 1 );
equal( zindex, 1 );
-});
+} );
test( "iframeFix", function() {
expect( 5 );
- var element = $( "<div>" ).appendTo( "#qunit-fixture" ).draggable({ iframeFix: true }),
- element2 = $( "<div>" ).appendTo( "#qunit-fixture" ).draggable({ iframeFix: ".iframe" }),
+ var element = $( "<div>" ).appendTo( "#qunit-fixture" ).draggable( { iframeFix: true } ),
+ element2 = $( "<div>" ).appendTo( "#qunit-fixture" ).draggable( { iframeFix: ".iframe" } ),
iframe = $( "<iframe>" ).appendTo( element );
element2
.append( "<iframe class='iframe'></iframe>" )
.append( "<iframe>" );
- iframe.css({
+ iframe.css( {
width: 1,
height: 1
- });
+ } );
element.one( "drag", function() {
var div = $( this ).children().not( "iframe" );
+
// http://bugs.jqueryui.com/ticket/9671
// iframeFix doesn't handle iframes that move
equal( div.length, 1, "blocking div added as sibling" );
equal( div.outerWidth(), iframe.outerWidth(), "blocking div is wide enough" );
equal( div.outerHeight(), iframe.outerHeight(), "blocking div is tall enough" );
deepEqual( div.offset(), iframe.offset(), "blocking div is tall enough" );
- });
+ } );
element.simulate( "drag", {
dx: 1,
dy: 1
- });
+ } );
element2.one( "drag", function() {
var div = $( this ).children().not( "iframe" );
equal( div.length, 1, "blocking div added as sibling only to matching selector" );
- });
+ } );
element2.simulate( "drag", {
dx: 1,
dy: 1
- });
-});
+ } );
+} );
} );
diff --git a/tests/unit/droppable/common-deprecated.js b/tests/unit/droppable/common-deprecated.js
index e9fdc69cc..fc086757f 100644
--- a/tests/unit/droppable/common-deprecated.js
+++ b/tests/unit/droppable/common-deprecated.js
@@ -15,7 +15,7 @@ common.testWidget( "droppable", {
scope: "default",
tolerance: "intersect",
- // callbacks
+ // Callbacks
activate: null,
create: null,
deactivate: null,
@@ -23,6 +23,6 @@ common.testWidget( "droppable", {
out: null,
over: null
}
-});
+} );
} );
diff --git a/tests/unit/droppable/common.js b/tests/unit/droppable/common.js
index d3bffc67b..d4bdb9dc0 100644
--- a/tests/unit/droppable/common.js
+++ b/tests/unit/droppable/common.js
@@ -13,7 +13,7 @@ common.testWidget( "droppable", {
scope: "default",
tolerance: "intersect",
- // callbacks
+ // Callbacks
activate: null,
create: null,
deactivate: null,
@@ -21,6 +21,6 @@ common.testWidget( "droppable", {
out: null,
over: null
}
-});
+} );
} );
diff --git a/tests/unit/droppable/core.js b/tests/unit/droppable/core.js
index 75951c1bc..c4ce0378c 100644
--- a/tests/unit/droppable/core.js
+++ b/tests/unit/droppable/core.js
@@ -4,26 +4,26 @@ define( [
"ui/widgets/droppable"
], function( $, testHelper ) {
-module("droppable: core");
+module( "droppable: core" );
-test("element types", function() {
- var typeNames = ("p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form" +
+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,hr" +
- ",input,button,label,select,iframe").split(",");
+ ",input,button,label,select,iframe" ).split( "," );
expect( typeNames.length );
- $.each(typeNames, function(i) {
- var typeName = typeNames[i],
- el = $(document.createElement(typeName)).appendTo("body");
+ $.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();
testHelper.shouldDrop();
- el.droppable("destroy");
+ el.droppable( "destroy" );
el.remove();
- });
-});
+ } );
+} );
} );
diff --git a/tests/unit/droppable/events.js b/tests/unit/droppable/events.js
index 9c84b099f..68df6e506 100644
--- a/tests/unit/droppable/events.js
+++ b/tests/unit/droppable/events.js
@@ -13,7 +13,7 @@ test( "droppable destruction/recreation on drop event", function( assert ) {
drop: function() {
var element = $( this ),
newDroppable = $( "<div>" )
- .css({ width: 100, height: 100 })
+ .css( { width: 100, height: 100 } )
.text( "Droppable" );
element.after( newDroppable );
element.remove();
@@ -33,10 +33,10 @@ test( "droppable destruction/recreation on drop event", function( assert ) {
draggable.simulate( "drag", {
dx: dx,
dy: dy
- });
+ } );
assert.lacksClasses( droppable2, "active", "subsequent droppable no longer active" );
-});
+} );
// todo: comment the following in when ready to actually test
/*
diff --git a/tests/unit/droppable/helper.js b/tests/unit/droppable/helper.js
index 460fa1aa6..b9bc5d6fb 100644
--- a/tests/unit/droppable/helper.js
+++ b/tests/unit/droppable/helper.js
@@ -5,13 +5,15 @@ define( [
return $.extend( helper, {
shouldDrop: function() {
+
// todo: actually implement this
- ok(true, "missing test - untested code is broken code");
+ ok( true, "missing test - untested code is broken code" );
},
shouldNotDrop: function() {
+
// todo: actually implement this
- ok(true, "missing test - untested code is broken code");
+ ok( true, "missing test - untested code is broken code" );
}
} );
diff --git a/tests/unit/droppable/methods.js b/tests/unit/droppable/methods.js
index 10ac48499..c159be56f 100644
--- a/tests/unit/droppable/methods.js
+++ b/tests/unit/droppable/methods.js
@@ -4,78 +4,78 @@ define( [
"ui/widgets/droppable"
], function( $, testHelper ) {
-module("droppable: methods");
+module( "droppable: methods" );
-test("init", function() {
+test( "init", function() {
expect( 5 );
- $("<div></div>").appendTo("body").droppable().remove();
- ok(true, ".droppable() called on element");
+ $( "<div></div>" ).appendTo( "body" ).droppable().remove();
+ ok( true, ".droppable() called on element" );
- $([]).droppable();
- ok(true, ".droppable() called on empty collection");
+ $( [] ).droppable();
+ ok( true, ".droppable() called on empty collection" );
- $("<div></div>").droppable();
- ok(true, ".droppable() called on disconnected DOMElement");
+ $( "<div></div>" ).droppable();
+ ok( true, ".droppable() called on disconnected DOMElement" );
- $("<div></div>").droppable().droppable("option", "foo");
- ok(true, "arbitrary option getter after init");
+ $( "<div></div>" ).droppable().droppable( "option", "foo" );
+ ok( true, "arbitrary option getter after init" );
- $("<div></div>").droppable().droppable("option", "foo", "bar");
- ok(true, "arbitrary option setter after init");
-});
+ $( "<div></div>" ).droppable().droppable( "option", "foo", "bar" );
+ ok( true, "arbitrary option setter after init" );
+} );
-test("destroy", function() {
+test( "destroy", function() {
expect( 4 );
- $("<div></div>").appendTo("body").droppable().droppable("destroy").remove();
- ok(true, ".droppable('destroy') called on element");
+ $( "<div></div>" ).appendTo( "body" ).droppable().droppable( "destroy" ).remove();
+ ok( true, ".droppable('destroy') called on element" );
- $([]).droppable().droppable("destroy");
- ok(true, ".droppable('destroy') called on empty collection");
+ $( [] ).droppable().droppable( "destroy" );
+ ok( true, ".droppable('destroy') called on empty collection" );
- $("<div></div>").droppable().droppable("destroy");
- ok(true, ".droppable('destroy') called on disconnected DOMElement");
+ $( "<div></div>" ).droppable().droppable( "destroy" );
+ ok( true, ".droppable('destroy') called on disconnected DOMElement" );
- var expected = $("<div></div>").droppable(),
- actual = expected.droppable("destroy");
- equal(actual, expected, "destroy is chainable");
-});
+ var expected = $( "<div></div>" ).droppable(),
+ actual = expected.droppable( "destroy" );
+ equal( actual, expected, "destroy is chainable" );
+} );
-test("enable", function() {
- expect(7);
+test( "enable", function() {
+ expect( 7 );
var el, expected, actual;
- el = $("#droppable1").droppable({ disabled: true });
+ el = $( "#droppable1" ).droppable( { disabled: true } );
testHelper.shouldNotDrop();
- el.droppable("enable");
+ el.droppable( "enable" );
testHelper.shouldDrop();
- equal(el.droppable("option", "disabled"), false, "disabled option getter");
- el.droppable("destroy");
- el.droppable({ disabled: true });
+ equal( el.droppable( "option", "disabled" ), false, "disabled option getter" );
+ el.droppable( "destroy" );
+ el.droppable( { disabled: true } );
testHelper.shouldNotDrop();
- el.droppable("option", "disabled", false);
- equal(el.droppable("option", "disabled"), false, "disabled option setter");
+ el.droppable( "option", "disabled", false );
+ equal( el.droppable( "option", "disabled" ), false, "disabled option setter" );
testHelper.shouldDrop();
- expected = $("<div></div>").droppable(),
- actual = expected.droppable("enable");
- equal(actual, expected, "enable is chainable");
-});
+ expected = $( "<div></div>" ).droppable(),
+ actual = expected.droppable( "enable" );
+ equal( actual, expected, "enable is chainable" );
+} );
test( "disable", function( assert ) {
expect( 10 );
var actual, expected,
- element = $( "#droppable1" ).droppable({ disabled: false });
+ element = $( "#droppable1" ).droppable( { disabled: false } );
testHelper.shouldDrop();
element.droppable( "disable" );
testHelper.shouldNotDrop();
equal( element.droppable( "option", "disabled" ), true, "disabled option getter" );
element.droppable( "destroy" );
- element.droppable({ disabled: false });
+ element.droppable( { disabled: false } );
testHelper.shouldDrop();
element.droppable( "option", "disabled", true );
assert.lacksClasses( element.droppable( "widget" ), "ui-state-disabled" );
@@ -87,6 +87,6 @@ test( "disable", function( assert ) {
expected = $( "<div></div>" ).droppable();
actual = expected.droppable( "disable" );
equal( actual, expected, "disable is chainable" );
-});
+} );
} );
diff --git a/tests/unit/droppable/options.js b/tests/unit/droppable/options.js
index 2fdf483d2..856c2d215 100644
--- a/tests/unit/droppable/options.js
+++ b/tests/unit/droppable/options.js
@@ -24,23 +24,23 @@ test( "activeClass", function() {
*/
test( "{ addClasses: true }, default", function( assert ) {
expect( 1 );
- var el = $( "<div />" ).droppable({ addClasses: true });
+ var el = $( "<div />" ).droppable( { addClasses: true } );
assert.hasClasses( el, "ui-droppable" );
el.droppable( "destroy" );
-});
+} );
test( "{ addClasses: false }", function( assert ) {
expect( 1 );
- var el = $( "<div />" ).droppable({ addClasses: false });
+ var el = $( "<div />" ).droppable( { addClasses: false } );
assert.lacksClasses( el, "ui-droppable" );
el.droppable( "destroy" );
-});
+} );
test( "scope", function() {
expect( 4 );
var droppableOffset, draggableOffset, oldDraggableOffset, dx, dy,
- draggable1 = $( "<div />" ).appendTo( "#qunit-fixture" ).draggable({ revert: "invalid" }),
+ draggable1 = $( "<div />" ).appendTo( "#qunit-fixture" ).draggable( { revert: "invalid" } ),
draggable2 = $( "<div />" ).appendTo( "#qunit-fixture" ).droppable(),
droppable = $( "<div />" ).appendTo( "#qunit-fixture" ).droppable(),
newScope = "test";
@@ -57,7 +57,7 @@ test( "scope", function() {
draggable1.simulate( "drag", {
dx: dx,
dy: dy
- });
+ } );
draggableOffset = draggable1.offset();
equal( draggableOffset.left, droppableOffset.left );
@@ -72,12 +72,12 @@ test( "scope", function() {
draggable2.simulate( "drag", {
dx: dx,
dy: dy
- });
+ } );
draggableOffset = draggable2.offset();
equal( draggableOffset.left, oldDraggableOffset.left );
equal( draggableOffset.top, oldDraggableOffset.top );
-});
+} );
/*
test( "greedy", function() {
ok(false, 'missing test - untested code is broken code');
@@ -109,41 +109,41 @@ test( "tolerance, intersect", function() {
draggable = $( "<div />" )
.appendTo( "#qunit-fixture" )
- .css({
+ .css( {
width: 10,
height: 10,
position: "absolute",
- // http://bugs.jqueryui.com/ticket/6876
+ // Http://bugs.jqueryui.com/ticket/6876
// Droppable: droppable region is offset by draggables margin
marginTop: 3,
marginLeft: 3
- })
+ } )
.draggable();
droppable = $( "<div />" )
.appendTo( "#qunit-fixture" )
- .css({ width: 10, height: 10, position: "absolute", top: 13, left: 13 })
- .droppable({ tolerance: "intersect" });
+ .css( { width: 10, height: 10, position: "absolute", top: 13, left: 13 } )
+ .droppable( { tolerance: "intersect" } );
$.each( dataset, function() {
var data = this;
- draggable.css({
+ draggable.css( {
top: 0,
left: 0
- });
+ } );
droppable.off( "drop" ).on( "drop", function() {
equal( true, data[ 2 ], data[ 3 ] );
- });
+ } );
$( draggable ).simulate( "drag", {
dx: data[ 0 ],
dy: data[ 1 ]
- });
- });
-});
+ } );
+ } );
+} );
test( "tolerance, pointer", function() {
expect( 3 );
@@ -162,40 +162,40 @@ test( "tolerance, pointer", function() {
draggable = $( "<div />" )
.appendTo( "#qunit-fixture" )
- .css({ width: 10, height: 10, position: "absolute" })
+ .css( { width: 10, height: 10, position: "absolute" } )
.draggable();
droppable = $( "<div />" )
.appendTo( "#qunit-fixture" )
- .css({ width: 10, height: 10, position: "absolute", top: 5, left: 5 })
- .droppable({ tolerance: "pointer" });
+ .css( { width: 10, height: 10, position: "absolute", top: 5, left: 5 } )
+ .droppable( { tolerance: "pointer" } );
$.each( dataset, function() {
var data = this;
droppable.off( "drop" ).on( "drop", function() {
equal( true, data[ 2 ], data[ 3 ] );
- });
+ } );
$( draggable ).simulate( "drag", {
dx: ( data[ 0 ] - $( draggable ).position().left ),
dy: ( data[ 1 ] - $( draggable ).position().top )
- });
- });
+ } );
+ } );
- // http://bugs.jqueryui.com/ticket/4977 - tolerance, pointer - bug when pointer outside draggable
- draggable.css({ top: 0, left: 0 }).draggable( "option", "axis", "x" );
- droppable.css({ top: 15, left: 15 });
+ // Http://bugs.jqueryui.com/ticket/4977 - tolerance, pointer - bug when pointer outside draggable
+ draggable.css( { top: 0, left: 0 } ).draggable( "option", "axis", "x" );
+ droppable.css( { top: 15, left: 15 } );
droppable.off( "drop" ).on( "drop", function() {
ok( true, "drop fires as long as pointer is within droppable" );
- });
+ } );
$( draggable ).simulate( "drag", {
dx: 10,
dy: 10
- });
-});
+ } );
+} );
/*
test( "tolerance, touch", function() {
diff --git a/tests/unit/effects/core.js b/tests/unit/effects/core.js
index c8e7c2632..f8a13f415 100644
--- a/tests/unit/effects/core.js
+++ b/tests/unit/effects/core.js
@@ -30,7 +30,7 @@ function notPresent( value, array, message ) {
// minDuration is used for "short" animate tests where we are only concerned about the final
var minDuration = 15,
- // duration is used for "long" animates where we plan on testing properties during animation
+ // Duration is used for "long" animates where we plan on testing properties during animation
duration = 200;
module( "effects.core" );
@@ -45,13 +45,13 @@ asyncTest( ".hide() with step", function() {
step = $.noop;
};
- element.hide({
+ element.hide( {
step: function() {
step();
},
complete: start
- });
-});
+ } );
+} );
test( "Immediate Return Conditions", function() {
var hidden = $( "div.hidden" ),
@@ -59,19 +59,19 @@ test( "Immediate Return Conditions", function() {
expect( 3 );
hidden.hide( "blind", function() {
equal( ++count, 1, "Hide on hidden returned immediately" );
- }).show().show( "blind", function() {
+ } ).show().show( "blind", function() {
equal( ++count, 2, "Show on shown returned immediately" );
- });
+ } );
equal( ++count, 3, "Both Functions worked properly" );
-});
+} );
test( ".hide() with hidden parent", function() {
expect( 1 );
var element = $( "div.hidden" ).children();
element.hide( "blind", function() {
equal( element.css( "display" ), "none", "display: none" );
- });
-});
+ } );
+} );
asyncTest( "Parse of null for options", function() {
var hidden = $( "div.hidden" ),
@@ -80,8 +80,8 @@ asyncTest( "Parse of null for options", function() {
hidden.show( "blind", null, 1, function() {
equal( ++count, 1, "null for options still works" );
start();
- });
-});
+ } );
+} );
test( "removeClass", function() {
expect( 3 );
@@ -92,51 +92,51 @@ test( "removeClass", function() {
equal( "destroyed", element[ 0 ].className );
element.removeClass();
equal( "", element[ 0 ].className );
-});
+} );
module( "effects.core: animateClass" );
asyncTest( "animateClass works with borderStyle", function() {
- var test = $("div.animateClass");
- expect(3);
- test.toggleClass("testAddBorder", minDuration, function() {
- test.toggleClass("testAddBorder", minDuration, function() {
- equal( test.css("borderLeftStyle"), "none", "None border set" );
+ var test = $( "div.animateClass" );
+ expect( 3 );
+ test.toggleClass( "testAddBorder", minDuration, function() {
+ test.toggleClass( "testAddBorder", minDuration, function() {
+ equal( test.css( "borderLeftStyle" ), "none", "None border set" );
start();
- });
- equal( test.css("borderLeftStyle"), "solid", "None border not immedately set" );
- });
- equal( test.css("borderLeftStyle"), "solid", "Solid border immedately set" );
-});
+ } );
+ equal( test.css( "borderLeftStyle" ), "solid", "None border not immedately set" );
+ } );
+ equal( test.css( "borderLeftStyle" ), "solid", "Solid border immedately set" );
+} );
asyncTest( "animateClass works with colors", function() {
- var test = $("div.animateClass"),
+ var test = $( "div.animateClass" ),
oldStep = jQuery.fx.step.backgroundColor;
- expect(2);
+ expect( 2 );
- // we want to catch the first frame of animation
+ // 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
+ // Make sure it has animated somewhere we can detect
if ( fx.pos > 255 / 2000 ) {
jQuery.fx.step.backgroundColor = oldStep;
- notPresent( test.css("backgroundColor"),
+ 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", {
+ test.toggleClass( "testChangeBackground", {
duration: 2000,
complete: function() {
- present( test.css("backgroundColor"), [ "#ffffff", "#fff", "rgb(255, 255, 255)" ], "Color is final" );
+ present( test.css( "backgroundColor" ), [ "#ffffff", "#fff", "rgb(255, 255, 255)" ], "Color is final" );
start();
}
- });
-});
+ } );
+} );
asyncTest( "animateClass calls step option", 1, function() {
var test = jQuery( "div.animateClass" ),
@@ -150,23 +150,23 @@ asyncTest( "animateClass calls step option", 1, function() {
step: function() {
step();
}
- });
-});
+ } );
+} );
asyncTest( "animateClass works with children", 3, function() {
var animatedChild,
- test = $("div.animateClass"),
- h2 = test.find("h2");
+ test = $( "div.animateClass" ),
+ h2 = test.find( "h2" );
- test.toggleClass("testChildren", {
+ test.toggleClass( "testChildren", {
children: true,
duration: duration,
complete: function() {
- equal( h2.css("fontSize"), "20px", "Text size is final during complete");
- test.toggleClass("testChildren", {
+ 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");
+ equal( h2.css( "fontSize" ), "10px", "Text size revertted after class removed" );
start();
},
@@ -175,7 +175,7 @@ asyncTest( "animateClass works with children", 3, function() {
ok( false, "Error - Animating property on h2" );
}
}
- });
+ } );
},
step: function( val, fx ) {
if ( fx.prop === "fontSize" && fx.elem === h2[ 0 ] && !animatedChild ) {
@@ -183,12 +183,12 @@ asyncTest( "animateClass works with children", 3, function() {
animatedChild = true;
}
}
- });
-});
+ } );
+} );
asyncTest( "animateClass clears style properties when stopped", function() {
- var test = $("div.animateClass"),
- style = test[0].style,
+ var test = $( "div.animateClass" ),
+ style = test[ 0 ].style,
orig = style.cssText;
expect( 2 );
@@ -199,25 +199,25 @@ asyncTest( "animateClass clears style properties when stopped", function() {
test.stop( true, true );
equal( orig, $.trim( style.cssText ), "cssText is the same after stopping animation midway" );
start();
-});
+} );
asyncTest( "animateClass: css and class changes during animation are not lost (#7106)",
function( assert ) {
expect( 2 );
var test = $( "div.ticket7106" );
- // ensure the class stays and that the css property stays
+ // Ensure the class stays and that the css property stays
function animationComplete() {
assert.hasClasses( test, "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
+ // Add a class and change a style property after starting an animated class
test.addClass( "animate", minDuration, animationComplete )
.addClass( "testClass" )
.height( 100 );
-});
+} );
test( "createPlaceholder: only created for static or relative elements", function() {
expect( 4 );
@@ -226,16 +226,16 @@ test( "createPlaceholder: only created for static or relative elements", functio
ok( $.effects.createPlaceholder( $( ".static" ) ).length, "placeholder created for static element" );
ok( !$.effects.createPlaceholder( $( ".absolute" ) ), "placeholder not created for absolute element" );
ok( !$.effects.createPlaceholder( $( ".fixed" ) ), "placeholder not created for fixed element" );
-});
+} );
test( "createPlaceholder: preserves layout affecting properties", function() {
expect( 7 );
var position = 5,
- element = $( ".relative" ).css({
+ element = $( ".relative" ).css( {
top: position,
left: position
- }),
+ } ),
before = {
offset: element.offset(),
outerWidth: element.outerWidth( true ),
@@ -256,7 +256,7 @@ test( "createPlaceholder: preserves layout affecting properties", function() {
deepEqual( before[ "float" ], placeholder.css( "float" ), "float preserved" );
deepEqual( before.outerWidth, placeholder.outerWidth( true ), "width preserved" );
deepEqual( before.outerHeight, placeholder.outerHeight( true ), "height preserved" );
-});
+} );
module( "transfer" );
@@ -287,7 +287,7 @@ asyncTest( "transfer() with callback", function() {
$.each( $.effects.effect, function( effect ) {
module( "effects." + effect );
- common.testJshint( "effect-" + effect );
+ common.testJshint( "effects/effect-" + effect );
if ( effect === "transfer" ) {
return;
@@ -321,47 +321,47 @@ $.each( $.effects.effect, function( effect ) {
hidden
.queue( queueTest() )
- .queue( duringTest(function() {
+ .queue( duringTest( function() {
ok( hidden.is( ":animated" ),
"Hidden is seen as animated during .show(\"" + effect + "\", time)" );
- }) )
- .show( effect, minDuration, queueTest(function() {
+ } ) )
+ .show( effect, minDuration, queueTest( function() {
equal( hidden.css( "display" ), "block",
"Hidden is shown after .show(\"" + effect + "\", time)" );
ok( !$( ".ui-effects-placeholder" ).length,
"No placeholder remains after .show(\"" + effect + "\", time)" );
- }) )
+ } ) )
.queue( queueTest() )
- .queue( duringTest(function() {
+ .queue( duringTest( function() {
ok( hidden.is( ":animated" ),
"Hidden is seen as animated during .hide(\"" + effect + "\", time)" );
- }) )
- .hide( effect, minDuration, queueTest(function() {
+ } ) )
+ .hide( effect, minDuration, queueTest( function() {
equal( hidden.css( "display" ), "none",
"Back to hidden after .hide(\"" + effect + "\", time)" );
ok( !$( ".ui-effects-placeholder" ).length,
"No placeholder remains after .hide(\"" + effect + "\", time)" );
- }) )
- .queue( queueTest(function() {
+ } ) )
+ .queue( queueTest( function() {
deepEqual( hidden.queue(), [ "inprogress" ], "Only the inprogress sentinel remains" );
start();
- }) );
- });
+ } ) );
+ } );
asyncTest( "relative width & height - properties are preserved", function() {
- var test = $("div.relWidth.relHeight"),
+ var test = $( "div.relWidth.relHeight" ),
width = test.width(), height = test.height(),
- cssWidth = test[0].style.width, cssHeight = test[0].style.height;
+ cssWidth = test[ 0 ].style.width, cssHeight = test[ 0 ].style.height;
expect( 4 );
test.toggle( effect, minDuration, function() {
- equal( test[0].style.width, cssWidth, "Inline CSS Width has been reset after animation ended" );
- equal( test[0].style.height, cssHeight, "Inline CSS Height has been rest after animation ended" );
+ equal( test[ 0 ].style.width, cssWidth, "Inline CSS Width has been reset after animation ended" );
+ equal( test[ 0 ].style.height, cssHeight, "Inline CSS Height has been rest after animation ended" );
start();
- });
+ } );
equal( test.width(), width, "Width is the same px after animation started" );
equal( test.height(), height, "Height is the same px after animation started" );
- });
-});
+ } );
+} );
} );
diff --git a/tests/unit/effects/scale.js b/tests/unit/effects/scale.js
index 0558810c8..dc8e9ba71 100644
--- a/tests/unit/effects/scale.js
+++ b/tests/unit/effects/scale.js
@@ -41,7 +41,7 @@ function run( position, v, h, vo, ho ) {
}
test.css( css );
test.effect( effect );
- });
+ } );
}
function suite( position ) {
@@ -55,18 +55,18 @@ function suite( position ) {
*/
}
-$(function() {
+$( function() {
suite( "absolute" );
suite( "relative" );
var fixedElem = $( "<div>" )
- .css({
+ .css( {
position: "fixed",
top: 10
- })
+ } )
.appendTo( "body" );
if ( fixedElem.offset().top === 10 ) {
suite( "fixed" );
}
-});
+} );
} );
diff --git a/tests/unit/form-reset-mixin/core.js b/tests/unit/form-reset-mixin/core.js
index 14e804643..4dbd7ac42 100644
--- a/tests/unit/form-reset-mixin/core.js
+++ b/tests/unit/form-reset-mixin/core.js
@@ -26,7 +26,7 @@ module( "widget factory", {
delete $.ui.testWidget;
delete $.fn.testWidget;
}
-});
+} );
common.testJshint( "form-reset-mixin" );
@@ -38,7 +38,7 @@ asyncTest( "form reset", function() {
inputs.testWidget();
form.on( "reset", function() {
- setTimeout(function() {
+ setTimeout( function() {
deepEqual( $.ui.testWidget.refreshed, [ "input1", "input2", "input3", "input4" ],
"All widgets are refreshed on form reset" );
equal( form.data( "ui-form-reset-instances" ).length, 4,
@@ -61,7 +61,7 @@ asyncTest( "destroy", function() {
.testWidget( "destroy" );
form.on( "reset", function() {
- setTimeout(function() {
+ setTimeout( function() {
deepEqual( $.ui.testWidget.refreshed, [ "input1", "input3", "input4" ],
"All widgets are refreshed on form reset" );
deepEqual( form.data( "ui-form-reset-instances" ).length, 3,
@@ -82,7 +82,7 @@ asyncTest( "destroy all", function() {
.testWidget( "destroy" );
form.on( "reset", function() {
- setTimeout(function() {
+ setTimeout( function() {
deepEqual( $.ui.testWidget.refreshed, [], "No widgets are refreshed after destroy" );
strictEqual( form.data( "ui-form-reset-instances" ), undefined,
"Form data is removed when the last widget instance is destroyed" );
diff --git a/tests/unit/menu/common.js b/tests/unit/menu/common.js
index 81674be35..96815c6b2 100644
--- a/tests/unit/menu/common.js
+++ b/tests/unit/menu/common.js
@@ -18,12 +18,12 @@ common.testWidget( "menu", {
},
role: "menu",
- // callbacks
+ // Callbacks
blur: null,
create: null,
focus: null,
select: null
}
-});
+} );
} );
diff --git a/tests/unit/menu/core.js b/tests/unit/menu/core.js
index 68f613ee1..a8e0ece00 100644
--- a/tests/unit/menu/core.js
+++ b/tests/unit/menu/core.js
@@ -23,9 +23,9 @@ test( "markup structure", function( assert ) {
equal( items.eq( 1 ).children().length, 1, "Item has exactly 1 child when it does not have a sub menu" );
assert.hasClasses( items[ 2 ], "ui-menu-item" );
equal( items.eq( 2 ).children().length, 1, "Item has exactly 1 child when it does not have a sub menu" );
-});
+} );
-test( "accessibility", function () {
+test( "accessibility", function() {
expect( 4 );
var element = $( "#menu1" ).menu();
@@ -39,7 +39,7 @@ test( "accessibility", function () {
ok( /^ui-id-\d+$/.test( element.attr( "aria-activedescendant" ) ), "aria-activedescendant from generated id" );
// Item roles are tested in the role option tests
-});
+} );
asyncTest( "#9044: Autofocus issue with dialog opened from menu widget", function() {
expect( 1 );
@@ -49,15 +49,15 @@ asyncTest( "#9044: Autofocus issue with dialog opened from menu widget", functio
$( "#testID1" ).on( "click", function() {
$( "#test9044" ).trigger( "focus" );
- });
+ } );
testHelper.click( element, "3" );
setTimeout( function() {
equal( document.activeElement.id, "test9044", "Focus was swallowed by menu" );
$( "#test9044" ).remove();
start();
- });
-});
+ } );
+} );
asyncTest( "#9532: Need a way in Menu to keep ui-state-active class on selected item for Selectmenu", function( assert ) {
expect( 1 );
@@ -70,7 +70,7 @@ asyncTest( "#9532: Need a way in Menu to keep ui-state-active class on selected
setTimeout( function() {
assert.hasClasses( wrapper, "ui-state-active" );
start();
- });
-});
+ } );
+} );
} );
diff --git a/tests/unit/menu/events.js b/tests/unit/menu/events.js
index 8a4b92fff..1500c3478 100644
--- a/tests/unit/menu/events.js
+++ b/tests/unit/menu/events.js
@@ -12,15 +12,15 @@ module( "menu: events", {
setup: function() {
testHelper.clearLog();
}
-});
+} );
test( "handle click on menu", function() {
expect( 1 );
- var element = $( "#menu1" ).menu({
+ var element = $( "#menu1" ).menu( {
select: function() {
log();
}
- });
+ } );
log( "click", true );
click( element, "1" );
log( "afterclick" );
@@ -28,16 +28,16 @@ test( "handle click on menu", function() {
click( element, "3" );
click( element, "1" );
equal( logOutput(), "click,1,afterclick,2,3,1", "Click order not valid." );
-});
+} );
test( "handle click on custom item menu", function() {
expect( 1 );
- var element = $( "#menu5" ).menu({
+ var element = $( "#menu5" ).menu( {
select: function() {
log();
},
menus: ".menu"
- });
+ } );
log( "click", true );
click( element, "1" );
log( "afterclick" );
@@ -45,75 +45,77 @@ test( "handle click on custom item menu", function() {
click( element, "3" );
click( element, "1" );
equal( logOutput(), "click,1,afterclick,2,3,1", "Click order not valid." );
-});
+} );
asyncTest( "handle blur", function() {
expect( 1 );
var blurHandled = false,
- element = $( "#menu1" ).menu({
+ element = $( "#menu1" ).menu( {
blur: function( event ) {
+
// Ignore duplicate blur event fired by IE
if ( !blurHandled ) {
blurHandled = true;
equal( event.type, "menublur", "blur event.type is 'menublur'" );
}
}
- });
+ } );
click( element, "1" );
- setTimeout(function() {
+ setTimeout( function() {
element.trigger( "blur" );
- setTimeout(function() {
+ setTimeout( function() {
start();
}, 350 );
- });
-});
+ } );
+} );
asyncTest( "handle blur via click outside", function() {
expect( 1 );
var blurHandled = false,
- element = $( "#menu1" ).menu({
+ element = $( "#menu1" ).menu( {
blur: function( event ) {
+
// Ignore duplicate blur event fired by IE
if ( !blurHandled ) {
blurHandled = true;
equal( event.type, "menublur", "blur event.type is 'menublur'" );
}
}
- });
+ } );
click( element, "1" );
- setTimeout(function() {
- $( "<a>", { id: "remove"} ).appendTo( "body" ).trigger( "click" );
- setTimeout(function() {
+ setTimeout( function() {
+ $( "<a>", { id: "remove" } ).appendTo( "body" ).trigger( "click" );
+ setTimeout( function() {
start();
}, 350 );
- });
-});
+ } );
+} );
asyncTest( "handle focus of menu with active item", function() {
expect( 1 );
- var element = $( "#menu1" ).menu({
+ var element = $( "#menu1" ).menu( {
focus: function( event ) {
log( $( event.target ).find( ".ui-menu-item-wrapper.ui-state-active" ).parent().index() );
}
- });
+ } );
log( "focus", true );
element[ 0 ].focus();
- setTimeout(function() {
+ setTimeout( function() {
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element[ 0 ].blur();
- setTimeout(function() {
+ setTimeout( function() {
element[ 0 ].focus();
- setTimeout(function() {
+ setTimeout( function() {
equal( logOutput(), "focus,0,1,2,2", "current active item remains active" );
start();
- });
- });
- });
-});
+ } );
+ } );
+ } );
+} );
test( "handle mouseenter on nested menu item", function( assert ) {
assert.expect( 8 );
@@ -186,12 +188,12 @@ asyncTest( "handle submenu auto collapse: mouseleave, default markup", function(
element.find( "li:nth-child(7)" ).trigger( "mouseenter" );
setTimeout( menumouseleave1, 25 );
-});
+} );
asyncTest( "handle submenu auto collapse: mouseleave, custom markup", function() {
expect( 4 );
$.ui.menu.prototype.delay = 1;
- var element = $( "#menu5" ).menu({ menus: ".menu" }),
+ var element = $( "#menu5" ).menu( { menus: ".menu" } ),
event = $.Event( "mouseenter" );
function menumouseleave1() {
@@ -217,22 +219,22 @@ asyncTest( "handle submenu auto collapse: mouseleave, custom markup", function()
element.find( ":nth-child(7)" ).trigger( "mouseenter" );
setTimeout( menumouseleave1, 25 );
-});
+} );
asyncTest( "handle keyboard navigation on menu without scroll and without submenus", function() {
expect( 12 );
- var element = $( "#menu1" ).menu({
+ var element = $( "#menu1" ).menu( {
select: function( event, ui ) {
log( $( ui.item[ 0 ] ).text() );
},
focus: function( event ) {
log( $( event.target ).find( ".ui-menu-item-wrapper.ui-state-active" ).parent().index() );
}
- });
+ } );
log( "keydown", true );
element[ 0 ].focus();
- setTimeout(function() {
+ setTimeout( function() {
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
equal( logOutput(), "keydown,0,1,2", "Keydown DOWN" );
@@ -282,19 +284,19 @@ asyncTest( "handle keyboard navigation on menu without scroll and without submen
equal( logOutput(), "keydown,Aberdeen", "Keydown ENTER" );
start();
- });
-});
+ } );
+} );
asyncTest( "handle keyboard navigation on menu without scroll and with submenus", function() {
expect( 16 );
- var element = $( "#menu2" ).menu({
+ var element = $( "#menu2" ).menu( {
select: function( event, ui ) {
- log( $( ui.item[0] ).text() );
+ log( $( ui.item[ 0 ] ).text() );
},
focus: function( event ) {
log( $( event.target ).find( ".ui-menu-item-wrapper.ui-state-active:last" ).parent().index() );
}
- });
+ } );
log( "keydown", true );
element.one( "menufocus", function() {
@@ -302,7 +304,7 @@ asyncTest( "handle keyboard navigation on menu without scroll and with submenus"
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
equal( logOutput(), "keydown,1,2", "Keydown DOWN" );
setTimeout( menukeyboard1 );
- });
+ } );
element.trigger( "focus" );
function menukeyboard1() {
@@ -322,7 +324,7 @@ asyncTest( "handle keyboard navigation on menu without scroll and with submenus"
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
- setTimeout(function() {
+ setTimeout( function() {
equal( logOutput(), "keydown,1,2,3,4,0", "Keydown RIGHT (open submenu)" );
setTimeout( menukeyboard2 );
} );
@@ -333,7 +335,7 @@ asyncTest( "handle keyboard navigation on menu without scroll and with submenus"
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
equal( logOutput(), "keydown,4", "Keydown LEFT (close submenu)" );
- // re-open submenu
+ // Re-open submenu
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
setTimeout( menukeyboard3 );
}
@@ -403,22 +405,22 @@ asyncTest( "handle keyboard navigation on menu without scroll and with submenus"
equal( logOutput(), "keydown,Ada", "Keydown ENTER (open submenu)" );
start();
}
-});
+} );
asyncTest( "handle keyboard navigation on menu with scroll and without submenus", function() {
expect( 14 );
- var element = $( "#menu3" ).menu({
+ var element = $( "#menu3" ).menu( {
select: function( event, ui ) {
log( $( ui.item[ 0 ] ).text() );
},
focus: function( event ) {
log( $( event.target ).find( ".ui-menu-item-wrapper.ui-state-active:last" ).parent().index() );
}
- });
+ } );
log( "keydown", true );
element[ 0 ].focus();
- setTimeout(function() {
+ setTimeout( function() {
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
equal( logOutput(), "keydown,0,1,2", "Keydown DOWN" );
@@ -477,19 +479,19 @@ asyncTest( "handle keyboard navigation on menu with scroll and without submenus"
equal( logOutput(), "keydown,Aberdeen", "Keydown ENTER" );
start();
- });
-});
+ } );
+} );
asyncTest( "handle keyboard navigation on menu with scroll and with submenus", function() {
expect( 14 );
- var element = $( "#menu4" ).menu({
+ var element = $( "#menu4" ).menu( {
select: function( event, ui ) {
log( $( ui.item[ 0 ] ).text() );
},
focus: function( event ) {
- log( $( event.target ).find( ".ui-menu-item-wrapper.ui-state-active:last" ).parent().index());
+ log( $( event.target ).find( ".ui-menu-item-wrapper.ui-state-active:last" ).parent().index() );
}
- });
+ } );
log( "keydown", true );
element.one( "menufocus", function() {
@@ -497,7 +499,7 @@ asyncTest( "handle keyboard navigation on menu with scroll and with submenus", f
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
equal( logOutput(), "keydown,1,2", "Keydown DOWN" );
setTimeout( menukeyboard1 );
- });
+ } );
element.trigger( "focus" );
function menukeyboard1() {
@@ -525,7 +527,7 @@ asyncTest( "handle keyboard navigation on menu with scroll and with submenus", f
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
equal( logOutput(), "keydown,1", "Keydown LEFT (close submenu)" );
- // re-open submenu
+ // Re-open submenu
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
setTimeout( menukeyboard3, 50 );
}
@@ -573,18 +575,18 @@ asyncTest( "handle keyboard navigation on menu with scroll and with submenus", f
start();
}
-});
+} );
asyncTest( "handle keyboard navigation and mouse click on menu with disabled items", function() {
expect( 6 );
- var element = $( "#menu6" ).menu({
+ var element = $( "#menu6" ).menu( {
select: function( event, ui ) {
- log( $( ui.item[0] ).text() );
+ log( $( ui.item[ 0 ] ).text() );
},
focus: function( event ) {
- log( $( event.target ).find( ".ui-menu-item-wrapper.ui-state-active" ).parent().index());
+ log( $( event.target ).find( ".ui-menu-item-wrapper.ui-state-active" ).parent().index() );
}
- });
+ } );
log( "keydown", true );
element.one( "menufocus", function() {
@@ -592,7 +594,7 @@ asyncTest( "handle keyboard navigation and mouse click on menu with disabled ite
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
equal( logOutput(), "keydown,1", "Keydown focus but not select disabled item" );
setTimeout( menukeyboard1, 50 );
- });
+ } );
element.trigger( "focus" );
function menukeyboard1() {
@@ -624,19 +626,19 @@ asyncTest( "handle keyboard navigation and mouse click on menu with disabled ite
}, 50 );
}, 50 );
}
-});
+} );
asyncTest( "handle keyboard navigation and mouse click on menu with dividers and group labels", function() {
expect( 2 );
- var element = $( "#menu7" ).menu({
+ var element = $( "#menu7" ).menu( {
items: "> :not('.ui-menu-group')",
select: function( event, ui ) {
- log( $( ui.item[0] ).text() );
+ log( $( ui.item[ 0 ] ).text() );
},
focus: function( event ) {
log( $( event.target ).find( ".ui-menu-item-wrapper.ui-state-active" ).parent().index() );
}
- });
+ } );
log( "keydown", true );
element.one( "menufocus", function() {
@@ -644,7 +646,7 @@ asyncTest( "handle keyboard navigation and mouse click on menu with dividers and
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
equal( logOutput(), "keydown,2,Ada", "Keydown skips initial group label" );
setTimeout( menukeyboard1, 50 );
- });
+ } );
element.trigger( "focus" );
function menukeyboard1() {
@@ -655,15 +657,15 @@ asyncTest( "handle keyboard navigation and mouse click on menu with dividers and
equal( logOutput(), "keydown,3,4,7", "Keydown focus skips divider and group label" );
start();
}
-});
+} );
asyncTest( "handle keyboard navigation with spelling of menu items", function() {
expect( 3 );
- var element = $( "#menu2" ).menu({
+ var element = $( "#menu2" ).menu( {
focus: function( event ) {
log( $( event.target ).find( ".ui-menu-item-wrapper.ui-state-active" ).parent().index() );
}
- });
+ } );
log( "keydown", true );
element.one( "menufocus", function() {
@@ -676,17 +678,17 @@ asyncTest( "handle keyboard navigation with spelling of menu items", function()
element.simulate( "keydown", { keyCode: 83 } );
equal( logOutput(), "keydown,0,1,3,4,5", "Keydown focus Saarland ignoring leading space" );
start();
- });
+ } );
element[ 0 ].focus();
-});
+} );
asyncTest( "Keep focus on selected item (see #10644)", function() {
expect( 1 );
- var element = $( "#menu2" ).menu({
+ var element = $( "#menu2" ).menu( {
focus: function( event ) {
log( $( event.target ).find( ".ui-menu-item-wrapper.ui-state-active" ).parent().index() );
}
- });
+ } );
log( "keydown", true );
element.one( "menufocus", function() {
@@ -698,40 +700,40 @@ asyncTest( "Keep focus on selected item (see #10644)", function() {
equal( logOutput(), "keydown,0,1,3,3,3",
"Focus stays on 'Addyston', even after other options are eliminated" );
start();
- });
+ } );
element[ 0 ].focus();
-});
+} );
test( "#9469: Stopping propagation in a select event should not suppress subsequent select events.", function() {
expect( 1 );
- var element = $( "#menu1" ).menu({
+ var element = $( "#menu1" ).menu( {
select: function( event ) {
log();
event.stopPropagation();
}
- });
+ } );
click( element, "1" );
click( element, "2" );
equal( logOutput(), "1,2", "Both select events were not triggered." );
-});
+} );
asyncTest( "#10571: When typing in a menu, only menu-items should be focused", function( assert ) {
expect( 3 );
- var element = $( "#menu8" ).menu({
+ var element = $( "#menu8" ).menu( {
focus: function( event, ui ) {
equal( ui.item.length, 1, "There should only be one match when filtering" );
assert.hasClasses( ui.item, "ui-menu-item" );
equal( ui.item.text(), "-Saarland", "element has correct text" );
}
- });
+ } );
- setTimeout(function() {
+ setTimeout( function() {
element.menu( "widget" ).simulate( "keydown", { keyCode: "-".charCodeAt( 0 ) } );
start();
- });
-});
+ } );
+} );
} );
diff --git a/tests/unit/menu/methods.js b/tests/unit/menu/methods.js
index 28482d65d..dc857cc42 100644
--- a/tests/unit/menu/methods.js
+++ b/tests/unit/menu/methods.js
@@ -12,25 +12,25 @@ module( "menu: methods", {
setup: function() {
testHelper.clearLog();
}
-});
+} );
test( "destroy", function( assert ) {
expect( 2 );
assert.domEqual( "#menu2", function() {
$( "#menu2" ).menu().menu( "destroy" );
- });
+ } );
assert.domEqual( "#menu5", function() {
- $( "#menu5").menu().menu( "destroy" );
- });
-});
+ $( "#menu5" ).menu().menu( "destroy" );
+ } );
+} );
test( "enable/disable", function( assert ) {
expect( 3 );
- var element = $( "#menu1" ).menu({
+ var element = $( "#menu1" ).menu( {
select: function() {
log();
}
- });
+ } );
element.menu( "disable" );
assert.hasClasses( element, "ui-state-disabled" );
log( "click", true );
@@ -42,7 +42,7 @@ test( "enable/disable", function( assert ) {
click( element, "1" );
log( "afterclick" );
equal( logOutput(), "click,afterclick,click,1,afterclick", "Click order not valid." );
-});
+} );
test( "refresh", function() {
expect( 5 );
@@ -56,7 +56,7 @@ test( "refresh", function() {
equal( element.find( ".ui-menu-item" ).length, 5, "Incorrect number of menu items" );
element.children( ":last" ).remove().end().menu( "refresh" );
equal( element.find( ".ui-menu-item" ).length, 5, "Incorrect number of menu items" );
-});
+} );
test( "refresh submenu", function() {
expect( 2 );
@@ -65,7 +65,7 @@ test( "refresh submenu", function() {
element.find( "ul" ).addBack().append( "<li><a href=\"#\">New Item</a></li>" );
element.menu( "refresh" );
equal( element.find( "ul:first .ui-menu-item" ).length, 4 );
-});
+} );
test( "refresh icons (see #9377)", function( assert ) {
expect( 3 );
@@ -79,7 +79,7 @@ test( "refresh icons (see #9377)", function( assert ) {
element.find( "li:first .ui-menu-item-wrapper" ).html( "Save" );
element.menu( "refresh" );
assert.lacksClasses( element, "ui-menu-icons" );
-});
+} );
test( "widget", function() {
expect( 2 );
@@ -87,7 +87,7 @@ test( "widget", function() {
widgetElement = element.menu( "widget" );
equal( widgetElement.length, 1, "one element" );
strictEqual( widgetElement[ 0 ], element[ 0 ], "same element" );
-});
+} );
// TODO: test focus method
diff --git a/tests/unit/menu/options.js b/tests/unit/menu/options.js
index e22adccf6..dd27ec5c2 100644
--- a/tests/unit/menu/options.js
+++ b/tests/unit/menu/options.js
@@ -12,62 +12,62 @@ module( "menu: options", {
setup: function() {
testHelper.clearLog();
}
-});
+} );
test( "{ disabled: true }", function( assert ) {
expect( 2 );
- var element = $( "#menu1" ).menu({
+ var element = $( "#menu1" ).menu( {
disabled: true,
select: function() {
log();
}
- });
+ } );
assert.hasClasses( element, "ui-state-disabled" );
log( "click", true );
click( element, "1" );
log( "afterclick" );
equal( logOutput(), "click,afterclick", "Click order not valid." );
-});
+} );
test( "{ disabled: false }", function( assert ) {
expect( 2 );
- var element = $( "#menu1" ).menu({
+ var element = $( "#menu1" ).menu( {
disabled: false,
select: function() {
log();
}
- });
+ } );
assert.lacksClasses( element, "ui-state-disabled" );
log( "click", true );
click( element, "1" );
log( "afterclick" );
equal( logOutput(), "click,1,afterclick", "Click order not valid." );
-});
+} );
test( "{ icons: default }", function( assert ) {
expect( 8 );
var element = $( "#menu2" ).menu();
element.find( ".ui-menu-icon" ).each( function() {
assert.hasClasses( this, "ui-menu-icon ui-icon ui-icon-caret-1-e" );
- });
+ } );
element.menu( "option", "icons.submenu", "ui-icon-triangle-1-e" );
element.find( ".ui-menu-icon" ).each( function() {
assert.hasClasses( this, "ui-menu-icon ui-icon ui-icon-triangle-1-e" );
- });
-});
+ } );
+} );
test( "{ icons: { submenu: 'custom' } }", function( assert ) {
expect( 4 );
- var element = $( "#menu2" ).menu({
+ var element = $( "#menu2" ).menu( {
icons: {
submenu: "custom-class"
}
- });
+ } );
element.find( ".ui-menu-icon" ).each( function() {
assert.hasClasses( this, "ui-menu-icon ui-icon custom-class" );
- });
-});
+ } );
+} );
// TODO: test menus option
@@ -79,47 +79,47 @@ test( "{ role: 'menu' } ", function( assert ) {
expect( 2 + 3 * items.length );
equal( element.attr( "role" ), "menu" );
ok( items.length > 0, "number of menu items" );
- items.each(function( item ) {
+ items.each( function( item ) {
assert.hasClasses( $( this ), "ui-menu-item" );
equal( $( this ).find( ".ui-menu-item-wrapper" ).attr( "role" ),
- "menuitem", "menu item ("+ item + ") role" );
+ "menuitem", "menu item (" + item + ") role" );
equal( $( this ).find( ".ui-menu-item-wrapper" ).attr( "tabindex" ), "-1",
- "tabindex for menu item ("+ item + ")" );
- });
-});
+ "tabindex for menu item (" + item + ")" );
+ } );
+} );
test( "{ role: 'listbox' } ", function( assert ) {
- var element = $( "#menu1" ).menu({
+ var element = $( "#menu1" ).menu( {
role: "listbox"
- }),
+ } ),
items = element.find( "li" );
expect( 2 + 3 * items.length );
equal( element.attr( "role" ), "listbox" );
ok( items.length > 0, "number of menu items" );
- items.each(function( item ) {
+ items.each( function( item ) {
assert.hasClasses( $( this ), "ui-menu-item" );
equal( $( this ).find( ".ui-menu-item-wrapper" ).attr( "role" ), "option",
- "menu item ("+ item + ") role" );
+ "menu item (" + item + ") role" );
equal( $( this ).find( ".ui-menu-item-wrapper" ).attr( "tabindex" ), "-1",
- "tabindex for menu item ("+ item + ")" );
- });
-});
+ "tabindex for menu item (" + item + ")" );
+ } );
+} );
test( "{ role: null }", function( assert ) {
- var element = $( "#menu1" ).menu({
+ var element = $( "#menu1" ).menu( {
role: null
- }),
+ } ),
items = element.find( "li" );
expect( 2 + 3 * items.length );
equal( element.attr( "role" ), null );
ok( items.length > 0, "number of menu items" );
- items.each(function( item ) {
+ items.each( function( item ) {
assert.hasClasses( $( this ), "ui-menu-item" );
equal( $( this ).find( ".ui-menu-item-wrapper" ).attr( "role" ), null,
- "menu item ("+ item + ") role" );
+ "menu item (" + item + ") role" );
equal( $( this ).find( ".ui-menu-item-wrapper" ).attr( "tabindex" ), "-1",
- "tabindex for menu item ("+ item + ")" );
- });
-});
+ "tabindex for menu item (" + item + ")" );
+ } );
+} );
} );
diff --git a/tests/unit/position/core.js b/tests/unit/position/core.js
index c480e2178..79aac76c4 100644
--- a/tests/unit/position/core.js
+++ b/tests/unit/position/core.js
@@ -18,63 +18,63 @@ module( "position", {
setup: function() {
win.scrollTop( 0 ).scrollLeft( 0 );
}
-});
+} );
common.testJshint( "position" );
test( "my, at, of", function() {
expect( 4 );
- $( "#elx" ).position({
+ $( "#elx" ).position( {
my: "left top",
at: "left top",
of: "#parentx",
collision: "none"
- });
+ } );
deepEqual( $( "#elx" ).offset(), { top: 40, left: 40 }, "left top, left top" );
- $( "#elx" ).position({
+ $( "#elx" ).position( {
my: "left top",
at: "left bottom",
of: "#parentx",
collision: "none"
- });
+ } );
deepEqual( $( "#elx" ).offset(), { top: 60, left: 40 }, "left top, left bottom" );
- $( "#elx" ).position({
+ $( "#elx" ).position( {
my: "left",
at: "bottom",
of: "#parentx",
collision: "none"
- });
+ } );
deepEqual( $( "#elx" ).offset(), { top: 55, left: 50 }, "left, bottom" );
- $( "#elx" ).position({
+ $( "#elx" ).position( {
my: "left foo",
at: "bar baz",
of: "#parentx",
collision: "none"
- });
+ } );
deepEqual( $( "#elx" ).offset(), { top: 45, left: 50 }, "left foo, bar baz" );
-});
+} );
test( "multiple elements", function() {
expect( 3 );
var elements = $( "#el1, #el2" ),
- result = elements.position({
+ result = elements.position( {
my: "left top",
at: "left bottom",
of: "#parent",
collision: "none"
- }),
+ } ),
expected = { top: 10, left: 4 };
deepEqual( result, elements );
- elements.each(function() {
+ elements.each( function() {
deepEqual( $( this ).offset(), expected );
- });
-});
+ } );
+} );
test( "positions", function() {
expect( 18 );
@@ -94,67 +94,67 @@ test( "positions", function() {
$.each( [ "left", "center", "right" ], function( hindex, horizontal ) {
var _my = my ? horizontal + " " + vertical : "left top",
_at = !my ? horizontal + " " + vertical : "left top";
- el.position({
+ 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 }) );
- });
- });
- });
-});
+ 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 } ) );
+ } );
+ } );
+ } );
+} );
test( "of", function() {
- expect( 9 + (scrollTopSupport() ? 1 : 0) );
+ expect( 9 + ( scrollTopSupport() ? 1 : 0 ) );
var event;
- $( "#elx" ).position({
+ $( "#elx" ).position( {
my: "left top",
at: "left top",
of: "#parentx",
collision: "none"
- });
+ } );
deepEqual( $( "#elx" ).offset(), { top: 40, left: 40 }, "selector" );
- $( "#elx" ).position({
+ $( "#elx" ).position( {
my: "left top",
at: "left bottom",
- of: $( "#parentx"),
+ of: $( "#parentx" ),
collision: "none"
- });
+ } );
deepEqual( $( "#elx" ).offset(), { top: 60, left: 40 }, "jQuery object" );
- $( "#elx" ).position({
+ $( "#elx" ).position( {
my: "left top",
at: "left top",
of: $( "#parentx" )[ 0 ],
collision: "none"
- });
+ } );
deepEqual( $( "#elx" ).offset(), { top: 40, left: 40 }, "DOM element" );
- $( "#elx" ).position({
+ $( "#elx" ).position( {
my: "right bottom",
at: "right bottom",
of: document,
collision: "none"
- });
+ } );
deepEqual( $( "#elx" ).offset(), {
top: $( document ).height() - 10,
left: $( document ).width() - 10
}, "document" );
- $( "#elx" ).position({
+ $( "#elx" ).position( {
my: "right bottom",
at: "right bottom",
of: $( document ),
collision: "none"
- });
+ } );
deepEqual( $( "#elx" ).offset(), {
top: $( document ).height() - 10,
left: $( document ).width() - 10
@@ -162,23 +162,23 @@ test( "of", function() {
win.scrollTop( 0 );
- $( "#elx" ).position({
+ $( "#elx" ).position( {
my: "right bottom",
at: "right bottom",
of: window,
collision: "none"
- });
+ } );
deepEqual( $( "#elx" ).offset(), {
top: win.height() - 10,
left: win.width() - 10
}, "window" );
- $( "#elx" ).position({
+ $( "#elx" ).position( {
my: "right bottom",
at: "right bottom",
of: win,
collision: "none"
- });
+ } );
deepEqual( $( "#elx" ).offset(), {
top: win.height() - 10,
left: win.width() - 10
@@ -186,12 +186,12 @@ test( "of", function() {
if ( scrollTopSupport() ) {
win.scrollTop( 500 ).scrollLeft( 200 );
- $( "#elx" ).position({
+ $( "#elx" ).position( {
my: "right bottom",
at: "right bottom",
of: window,
collision: "none"
- });
+ } );
deepEqual( $( "#elx" ).offset(), {
top: win.height() + 500 - 10,
left: win.width() + 200 - 10
@@ -200,95 +200,95 @@ test( "of", function() {
}
event = $.extend( $.Event( "someEvent" ), { pageX: 200, pageY: 300 } );
- $( "#elx" ).position({
+ $( "#elx" ).position( {
my: "left top",
at: "left top",
of: event,
collision: "none"
- });
+ } );
deepEqual( $( "#elx" ).offset(), {
top: 300,
left: 200
}, "event - left top, left top" );
event = $.extend( $.Event( "someEvent" ), { pageX: 400, pageY: 600 } );
- $( "#elx" ).position({
+ $( "#elx" ).position( {
my: "left top",
at: "right bottom",
of: event,
collision: "none"
- });
+ } );
deepEqual( $( "#elx" ).offset(), {
top: 600,
left: 400
}, "event - left top, right bottom" );
-});
+} );
test( "offsets", function() {
expect( 9 );
var offset;
- $( "#elx" ).position({
+ $( "#elx" ).position( {
my: "left top",
at: "left+10 bottom+10",
of: "#parentx",
collision: "none"
- });
+ } );
deepEqual( $( "#elx" ).offset(), { top: 70, left: 50 }, "offsets in at" );
- $( "#elx" ).position({
+ $( "#elx" ).position( {
my: "left+10 top-10",
at: "left bottom",
of: "#parentx",
collision: "none"
- });
+ } );
deepEqual( $( "#elx" ).offset(), { top: 50, left: 50 }, "offsets in my" );
- $( "#elx" ).position({
+ $( "#elx" ).position( {
my: "left top",
at: "left+50% bottom-10%",
of: "#parentx",
collision: "none"
- });
+ } );
deepEqual( $( "#elx" ).offset(), { top: 58, left: 50 }, "percentage offsets in at" );
- $( "#elx" ).position({
+ $( "#elx" ).position( {
my: "left-30% top+50%",
at: "left bottom",
of: "#parentx",
collision: "none"
- });
+ } );
deepEqual( $( "#elx" ).offset(), { top: 65, left: 37 }, "percentage offsets in my" );
- $( "#elx" ).position({
+ $( "#elx" ).position( {
my: "left-30.001% top+50.0%",
at: "left bottom",
of: "#parentx",
collision: "none"
- });
+ } );
offset = $( "#elx" ).offset();
equal( Math.round( offset.top ), 65, "decimal percentage offsets in my" );
equal( Math.round( offset.left ), 37, "decimal percentage offsets in my" );
- $( "#elx" ).position({
+ $( "#elx" ).position( {
my: "left+10.4 top-10.6",
at: "left bottom",
of: "#parentx",
collision: "none"
- });
+ } );
offset = $( "#elx" ).offset();
equal( Math.round( offset.top ), 49, "decimal offsets in my" );
equal( Math.round( offset.left ), 50, "decimal offsets in my" );
- $( "#elx" ).position({
+ $( "#elx" ).position( {
my: "left+right top-left",
at: "left-top bottom-bottom",
of: "#parentx",
collision: "none"
- });
+ } );
deepEqual( $( "#elx" ).offset(), { top: 60, left: 40 }, "invalid offsets" );
-});
+} );
test( "using", function() {
expect( 10 );
@@ -315,14 +315,14 @@ test( "using", function() {
vertical: "top",
important: "vertical"
},
- originalPosition = elems.position({
+ originalPosition = elems.position( {
my: "right bottom",
at: "rigt bottom",
of: "#parentx",
collision: "none"
- }).offset();
+ } ).offset();
- elems.position({
+ elems.position( {
my: "left top",
at: "center+10 bottom",
of: "#parentx",
@@ -334,15 +334,15 @@ test( "using", function() {
deepEqual( feedback, expectedFeedback );
count++;
}
- });
+ } );
- elems.each(function() {
+ elems.each( function() {
deepEqual( $( this ).offset(), originalPosition, "elements not moved" );
- });
-});
+ } );
+} );
function collisionTest( config, result, msg ) {
- var elem = $( "#elx" ).position( $.extend({
+ var elem = $( "#elx" ).position( $.extend( {
my: "left top",
at: "right bottom",
of: "#parent"
@@ -351,7 +351,7 @@ function collisionTest( config, result, msg ) {
}
function collisionTest2( config, result, msg ) {
- collisionTest( $.extend({
+ collisionTest( $.extend( {
my: "right bottom",
at: "left top"
}, config ), result, msg );
@@ -360,35 +360,35 @@ function collisionTest2( config, result, msg ) {
test( "collision: fit, no collision", function() {
expect( 2 );
- collisionTest({
+ collisionTest( {
collision: "fit"
}, {
top: 10,
left: 10
}, "no offset" );
- collisionTest({
+ collisionTest( {
collision: "fit",
at: "right+2 bottom+3"
}, {
top: 13,
left: 12
}, "with offset" );
-});
+} );
// Currently failing in IE8 due to the iframe used by TestSwarm
if ( !/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() ) ) {
test( "collision: fit, collision", function() {
- expect( 2 + (scrollTopSupport() ? 1 : 0) );
+ expect( 2 + ( scrollTopSupport() ? 1 : 0 ) );
- collisionTest2({
+ collisionTest2( {
collision: "fit"
}, {
top: 0,
left: 0
}, "no offset" );
- collisionTest2({
+ collisionTest2( {
collision: "fit",
at: "left+2 top+3"
}, {
@@ -398,7 +398,7 @@ test( "collision: fit, collision", function() {
if ( scrollTopSupport() ) {
win.scrollTop( 300 ).scrollLeft( 200 );
- collisionTest({
+ collisionTest( {
collision: "fit"
}, {
top: 300,
@@ -407,188 +407,188 @@ test( "collision: fit, collision", function() {
win.scrollTop( 0 ).scrollLeft( 0 );
}
-});
+} );
}
test( "collision: flip, no collision", function() {
expect( 2 );
- collisionTest({
+ collisionTest( {
collision: "flip"
}, {
top: 10,
left: 10
}, "no offset" );
- collisionTest({
+ collisionTest( {
collision: "flip",
at: "right+2 bottom+3"
}, {
top: 13,
left: 12
}, "with offset" );
-});
+} );
test( "collision: flip, collision", function() {
expect( 2 );
- collisionTest2({
+ collisionTest2( {
collision: "flip"
}, {
top: 10,
left: 10
}, "no offset" );
- collisionTest2({
+ collisionTest2( {
collision: "flip",
at: "left+2 top+3"
}, {
top: 7,
left: 8
}, "with offset" );
-});
+} );
test( "collision: flipfit, no collision", function() {
expect( 2 );
- collisionTest({
+ collisionTest( {
collision: "flipfit"
}, {
top: 10,
left: 10
}, "no offset" );
- collisionTest({
+ collisionTest( {
collision: "flipfit",
at: "right+2 bottom+3"
}, {
top: 13,
left: 12
}, "with offset" );
-});
+} );
test( "collision: flipfit, collision", function() {
expect( 2 );
- collisionTest2({
+ collisionTest2( {
collision: "flipfit"
}, {
top: 10,
left: 10
}, "no offset" );
- collisionTest2({
+ collisionTest2( {
collision: "flipfit",
at: "left+2 top+3"
}, {
top: 7,
left: 8
}, "with offset" );
-});
+} );
test( "collision: none, no collision", function() {
expect( 2 );
- collisionTest({
+ collisionTest( {
collision: "none"
}, {
top: 10,
left: 10
}, "no offset" );
- collisionTest({
+ collisionTest( {
collision: "none",
at: "right+2 bottom+3"
}, {
top: 13,
left: 12
}, "with offset" );
-});
+} );
test( "collision: none, collision", function() {
expect( 2 );
- collisionTest2({
+ collisionTest2( {
collision: "none"
}, {
top: -6,
left: -6
}, "no offset" );
- collisionTest2({
+ collisionTest2( {
collision: "none",
at: "left+2 top+3"
}, {
top: -3,
left: -4
}, "with offset" );
-});
+} );
test( "collision: fit, with margin", function() {
expect( 2 );
- $( "#elx" ).css({
+ $( "#elx" ).css( {
marginTop: 6,
marginLeft: 4
- });
+ } );
- collisionTest({
+ collisionTest( {
collision: "fit"
}, {
top: 10,
left: 10
}, "right bottom" );
- collisionTest2({
+ collisionTest2( {
collision: "fit"
}, {
top: 6,
left: 4
}, "left top" );
-});
+} );
test( "collision: flip, with margin", function() {
expect( 3 );
- $( "#elx" ).css({
+ $( "#elx" ).css( {
marginTop: 6,
marginLeft: 4
- });
+ } );
- collisionTest({
+ collisionTest( {
collision: "flip"
}, {
top: 10,
left: 10
}, "left top" );
- collisionTest2({
+ collisionTest2( {
collision: "flip"
}, {
top: 10,
left: 10
}, "right bottom" );
- collisionTest2({
+ collisionTest2( {
collision: "flip",
my: "left top"
}, {
top: 0,
left: 4
}, "right bottom" );
-});
+} );
test( "within", function() {
expect( 7 );
- collisionTest({
+ collisionTest( {
within: document
}, {
top: 10,
left: 10
}, "within document" );
- collisionTest({
+ collisionTest( {
within: "#within",
collision: "fit"
}, {
@@ -596,7 +596,7 @@ test( "within", function() {
left: 2
}, "fit - right bottom" );
- collisionTest2({
+ collisionTest2( {
within: "#within",
collision: "fit"
}, {
@@ -604,7 +604,7 @@ test( "within", function() {
left: 0
}, "fit - left top" );
- collisionTest({
+ collisionTest( {
within: "#within",
collision: "flip"
}, {
@@ -612,7 +612,7 @@ test( "within", function() {
left: -6
}, "flip - right bottom" );
- collisionTest2({
+ collisionTest2( {
within: "#within",
collision: "flip"
}, {
@@ -620,7 +620,7 @@ test( "within", function() {
left: -6
}, "flip - left top" );
- collisionTest({
+ collisionTest( {
within: "#within",
collision: "flipfit"
}, {
@@ -628,26 +628,26 @@ test( "within", function() {
left: 0
}, "flipfit - right bottom" );
- collisionTest2({
+ collisionTest2( {
within: "#within",
collision: "flipfit"
}, {
top: 4,
left: 0
}, "flipfit - left top" );
-});
+} );
test( "with scrollbars", function() {
expect( 4 );
- $( "#scrollx" ).css({
+ $( "#scrollx" ).css( {
width: 100,
height: 100,
left: 0,
top: 0
- });
+ } );
- collisionTest({
+ collisionTest( {
of: "#scrollx",
collision: "fit",
within: "#scrollx"
@@ -656,13 +656,13 @@ test( "with scrollbars", function() {
left: 90
}, "visible" );
- $( "#scrollx" ).css({
+ $( "#scrollx" ).css( {
overflow: "scroll"
- });
+ } );
var scrollbarInfo = $.position.getScrollInfo( $.position.getWithinInfo( $( "#scrollx" ) ) );
- collisionTest({
+ collisionTest( {
of: "#scrollx",
collision: "fit",
within: "#scrollx"
@@ -671,11 +671,11 @@ test( "with scrollbars", function() {
left: 90 - scrollbarInfo.width
}, "scroll" );
- $( "#scrollx" ).css({
+ $( "#scrollx" ).css( {
overflow: "auto"
- });
+ } );
- collisionTest({
+ collisionTest( {
of: "#scrollx",
collision: "fit",
within: "#scrollx"
@@ -684,11 +684,11 @@ test( "with scrollbars", function() {
left: 90
}, "auto, no scroll" );
- $( "#scrollx" ).css({
+ $( "#scrollx" ).css( {
overflow: "auto"
- }).append( $("<div>").height(300).width(300) );
+ } ).append( $( "<div>" ).height( 300 ).width( 300 ) );
- collisionTest({
+ collisionTest( {
of: "#scrollx",
collision: "fit",
within: "#scrollx"
@@ -696,45 +696,45 @@ test( "with scrollbars", function() {
top: 90 - scrollbarInfo.height,
left: 90 - scrollbarInfo.width
}, "auto, with scroll" );
-});
+} );
test( "fractions", function() {
expect( 1 );
- $( "#fractions-element" ).position({
+ $( "#fractions-element" ).position( {
my: "left top",
at: "left top",
of: "#fractions-parent",
collision: "none"
- });
+ } );
deepEqual( $( "#fractions-element" ).offset(), $( "#fractions-parent" ).offset(), "left top, left top" );
-});
+} );
test( "bug #5280: consistent results (avoid fractional values)", function() {
expect( 1 );
var wrapper = $( "#bug-5280" ),
elem = wrapper.children(),
- offset1 = elem.position({
+ offset1 = elem.position( {
my: "center",
at: "center",
of: wrapper,
collision: "none"
- }).offset(),
- offset2 = elem.position({
+ } ).offset(),
+ offset2 = elem.position( {
my: "center",
at: "center",
of: wrapper,
collision: "none"
- }).offset();
+ } ).offset();
deepEqual( offset1, offset2 );
-});
+} );
test( "bug #8710: flip if flipped position fits more", function() {
expect( 3 );
// Positions a 10px tall element within 99px height at top 90px.
- collisionTest({
+ collisionTest( {
within: "#bug-8710-within-smaller",
of: "#parentx",
collision: "flip",
@@ -745,7 +745,7 @@ test( "bug #8710: flip if flipped position fits more", function() {
}, "flip - top fits all" );
// Positions a 10px tall element within 99px height at top 92px.
- collisionTest({
+ collisionTest( {
within: "#bug-8710-within-smaller",
of: "#parentx",
collision: "flip",
@@ -756,7 +756,7 @@ test( "bug #8710: flip if flipped position fits more", function() {
}, "flip - top fits more" );
// Positions a 10px tall element within 101px height at top 92px.
- collisionTest({
+ collisionTest( {
within: "#bug-8710-within-bigger",
of: "#parentx",
collision: "flip",
@@ -765,6 +765,6 @@ test( "bug #8710: flip if flipped position fits more", function() {
top: 92,
left: 60
}, "no flip - top fits less" );
-});
+} );
} );
diff --git a/tests/unit/progressbar/common.js b/tests/unit/progressbar/common.js
index baadb6d53..566b96465 100644
--- a/tests/unit/progressbar/common.js
+++ b/tests/unit/progressbar/common.js
@@ -19,6 +19,6 @@ common.testWidget( "progressbar", {
complete: null,
create: null
}
-});
+} );
} );
diff --git a/tests/unit/progressbar/core.js b/tests/unit/progressbar/core.js
index 8c09f67ae..3c5ad9e68 100644
--- a/tests/unit/progressbar/core.js
+++ b/tests/unit/progressbar/core.js
@@ -19,11 +19,11 @@ test( "markup structure", function( assert ) {
element.progressbar( "option", "value", 100 );
assert.hasClasses( value, "ui-progressbar-complete ui-widget-header ui-progressbar-value" );
equal( element.children().children().length, 0, "no overlay div" );
-});
+} );
test( "markup structure - indeterminate", function( assert ) {
expect( 5 );
- var element = $( "#progressbar" ).progressbar({ value: false }),
+ var element = $( "#progressbar" ).progressbar( { value: false } ),
children = element.children();
assert.hasClasses( element, "ui-progressbar ui-progressbar-indeterminate ui-widget ui-widget-content" );
@@ -32,7 +32,7 @@ test( "markup structure - indeterminate", function( assert ) {
assert.hasClasses( children[ 0 ], "ui-progressbar-value" );
equal( children.children( ".ui-progressbar-overlay" ).length, 1,
"Value has class ui-progressbar-overlay" );
-});
+} );
test( "accessibility", function() {
expect( 11 );
@@ -59,6 +59,6 @@ test( "accessibility", function() {
equal( element.attr( "aria-valuemin" ), 0, "aria-valuemin" );
equal( element.attr( "aria-valuemax" ), 150, "aria-valuemax" );
equal( element.attr( "aria-valuenow" ), null, "aria-valuenow" );
-});
+} );
} );
diff --git a/tests/unit/progressbar/events.js b/tests/unit/progressbar/events.js
index 7f4926466..b767e1395 100644
--- a/tests/unit/progressbar/events.js
+++ b/tests/unit/progressbar/events.js
@@ -7,7 +7,7 @@ module( "progressbar: events" );
test( "create", function() {
expect( 1 );
- $( "#progressbar" ).progressbar({
+ $( "#progressbar" ).progressbar( {
value: 5,
create: function() {
equal( $( this ).progressbar( "value" ), 5, "Correct value at create" );
@@ -15,8 +15,8 @@ test( "create", function() {
change: function() {
ok( false, "create has triggered change()" );
}
- });
-});
+ } );
+} );
test( "change", function() {
expect( 2 );
@@ -24,19 +24,19 @@ test( "change", function() {
element.one( "progressbarchange", function() {
equal( element.progressbar( "value" ), 5, "change triggered for middle value" );
- });
+ } );
element.progressbar( "value", 5 );
element.one( "progressbarchange", function() {
equal( element.progressbar( "value" ), 100, "change triggered for final value" );
- });
+ } );
element.progressbar( "value", 100 );
-});
+} );
test( "complete", function() {
expect( 5 );
var value,
changes = 0,
- element = $( "#progressbar" ).progressbar({
+ element = $( "#progressbar" ).progressbar( {
change: function() {
changes++;
equal( element.progressbar( "value" ), value, "change at " + value );
@@ -45,7 +45,7 @@ test( "complete", function() {
equal( changes, 3, "complete triggered after change and not on indeterminate" );
equal( element.progressbar( "value" ), 100, "value is 100" );
}
- });
+ } );
value = 5;
element.progressbar( "value", value );
@@ -53,6 +53,6 @@ test( "complete", function() {
element.progressbar( "value", value );
value = 100;
element.progressbar( "value", value );
-});
+} );
} );
diff --git a/tests/unit/progressbar/methods.js b/tests/unit/progressbar/methods.js
index 00de2f46e..4bc4fa65e 100644
--- a/tests/unit/progressbar/methods.js
+++ b/tests/unit/progressbar/methods.js
@@ -9,8 +9,8 @@ test( "destroy", function( assert ) {
expect( 1 );
assert.domEqual( "#progressbar", function() {
$( "#progressbar" ).progressbar().progressbar( "destroy" );
- });
-});
+ } );
+} );
test( "disable", function( assert ) {
expect( 3 );
@@ -20,16 +20,16 @@ test( "disable", function( assert ) {
assert.hasClasses( element.progressbar( "widget" ), "ui-state-disabled" );
ok( element.progressbar( "widget" ).attr( "aria-disabled" ), "element gets aria-disabled" );
assert.hasClasses( element.progressbar( "widget" ), "ui-progressbar-disabled" );
-});
+} );
test( "value", function() {
expect( 3 );
- var element = $( "<div>" ).progressbar({ value: 20 });
+ var element = $( "<div>" ).progressbar( { value: 20 } );
equal( element.progressbar( "value" ), 20, "correct value as getter" );
strictEqual( element.progressbar( "value", 30 ), element, "chainable as setter" );
equal( element.progressbar( "option", "value" ), 30, "correct value after setter" );
-});
+} );
test( "widget", function() {
expect( 2 );
@@ -37,6 +37,6 @@ test( "widget", function() {
widgetElement = element.progressbar( "widget" );
equal( widgetElement.length, 1, "one element" );
strictEqual( widgetElement[ 0 ], element[ 0 ], "same element" );
-});
+} );
} );
diff --git a/tests/unit/progressbar/options.js b/tests/unit/progressbar/options.js
index 533c15351..fb6faac9a 100644
--- a/tests/unit/progressbar/options.js
+++ b/tests/unit/progressbar/options.js
@@ -9,14 +9,14 @@ test( "{ value: 0 }, default", function() {
expect( 1 );
$( "#progressbar" ).progressbar();
equal( $( "#progressbar" ).progressbar( "value" ), 0 );
-});
+} );
// Ticket #7231 - valueDiv should be hidden when value is at 0%
test( "value: visibility of valueDiv", function() {
expect( 4 );
- var element = $( "#progressbar" ).progressbar({
+ var element = $( "#progressbar" ).progressbar( {
value: 0
- });
+ } );
ok( element.children( ".ui-progressbar-value" ).is( ":hidden" ),
"valueDiv hidden when value is initialized at 0" );
element.progressbar( "value", 1 );
@@ -28,52 +28,52 @@ test( "value: visibility of valueDiv", function() {
element.progressbar( "value", 0 );
ok( element.children( ".ui-progressbar-value" ).is( ":hidden" ),
"valueDiv hidden when value is set to 0" );
-});
+} );
test( "{ value: 5 }", function() {
expect( 1 );
- $( "#progressbar" ).progressbar({
+ $( "#progressbar" ).progressbar( {
value: 5
- });
+ } );
equal( $( "#progressbar" ).progressbar( "value" ), 5 );
-});
+} );
test( "{ value: -5 }", function() {
expect( 1 );
- $( "#progressbar" ).progressbar({
+ $( "#progressbar" ).progressbar( {
value: -5
- });
+ } );
equal( $( "#progressbar" ).progressbar( "value" ), 0,
"value constrained at min" );
-});
+} );
test( "{ value: 105 }", function() {
expect( 1 );
- $( "#progressbar" ).progressbar({
+ $( "#progressbar" ).progressbar( {
value: 105
- });
+ } );
equal( $( "#progressbar" ).progressbar( "value" ), 100,
"value constrained at max" );
-});
+} );
test( "{ value: 10, max: 5 }", function() {
expect( 1 );
- $("#progressbar").progressbar({
+ $( "#progressbar" ).progressbar( {
max: 5,
value: 10
- });
+ } );
equal( $( "#progressbar" ).progressbar( "value" ), 5,
"value constrained at max" );
-});
+} );
test( "change max below value", function() {
expect( 1 );
- $("#progressbar").progressbar({
+ $( "#progressbar" ).progressbar( {
max: 10,
value: 10
- }).progressbar( "option", "max", 5 );
+ } ).progressbar( "option", "max", 5 );
equal( $( "#progressbar" ).progressbar( "value" ), 5,
"value constrained at max" );
-});
+} );
} );
diff --git a/tests/unit/resizable/common.js b/tests/unit/resizable/common.js
index 6096446f3..8d98096a4 100644
--- a/tests/unit/resizable/common.js
+++ b/tests/unit/resizable/common.js
@@ -29,12 +29,12 @@ common.testWidget( "resizable", {
minWidth: 10,
zIndex: 90,
- // callbacks
+ // Callbacks
create: null,
resize: null,
start: null,
stop: null
}
-});
+} );
} );
diff --git a/tests/unit/resizable/core.js b/tests/unit/resizable/core.js
index 450fd6ef8..8c942e62f 100644
--- a/tests/unit/resizable/core.js
+++ b/tests/unit/resizable/core.js
@@ -4,7 +4,7 @@ define( [
"ui/widgets/resizable"
], function( $, testHelper ) {
-module("resizable: core");
+module( "resizable: core" );
/*
test("element types", function() {
@@ -25,188 +25,188 @@ test("element types", function() {
});
*/
-test("n", function() {
- expect(4);
+test( "n", function() {
+ expect( 4 );
- var handle = ".ui-resizable-n", target = $("#resizable1").resizable({ handles: "all" });
+ var handle = ".ui-resizable-n", target = $( "#resizable1" ).resizable( { handles: "all" } );
- testHelper.drag(handle, 0, -50);
+ testHelper.drag( handle, 0, -50 );
equal( target.height(), 150, "compare height" );
- testHelper.drag(handle, 0, 50);
+ testHelper.drag( handle, 0, 50 );
equal( target.height(), 100, "compare height" );
- equal( target[0].style.left, "", "left should not be modified" );
- equal( target[0].style.width, "", "width should not be modified" );
-});
+ equal( target[ 0 ].style.left, "", "left should not be modified" );
+ equal( target[ 0 ].style.width, "", "width should not be modified" );
+} );
-test("s", function() {
- expect(5);
+test( "s", function() {
+ expect( 5 );
- var handle = ".ui-resizable-s", target = $("#resizable1").resizable({ handles: "all" });
+ var handle = ".ui-resizable-s", target = $( "#resizable1" ).resizable( { handles: "all" } );
- testHelper.drag(handle, 0, 50);
+ testHelper.drag( handle, 0, 50 );
equal( target.height(), 150, "compare height" );
- testHelper.drag(handle, 0, -50);
+ testHelper.drag( handle, 0, -50 );
equal( target.height(), 100, "compare height" );
- equal( target[0].style.top, "", "top should not be modified" );
- equal( target[0].style.left, "", "left should not be modified" );
- equal( target[0].style.width, "", "width should not be modified" );
-});
+ equal( target[ 0 ].style.top, "", "top should not be modified" );
+ equal( target[ 0 ].style.left, "", "left should not be modified" );
+ equal( target[ 0 ].style.width, "", "width should not be modified" );
+} );
-test("e", function() {
- expect(5);
+test( "e", function() {
+ expect( 5 );
- var handle = ".ui-resizable-e", target = $("#resizable1").resizable({ handles: "all" });
+ var handle = ".ui-resizable-e", target = $( "#resizable1" ).resizable( { handles: "all" } );
- testHelper.drag(handle, 50);
- equal( target.width(), 150, "compare width");
+ testHelper.drag( handle, 50 );
+ equal( target.width(), 150, "compare width" );
- testHelper.drag(handle, -50);
+ testHelper.drag( handle, -50 );
equal( target.width(), 100, "compare width" );
- equal( target[0].style.height, "", "height should not be modified" );
- equal( target[0].style.top, "", "top should not be modified" );
- equal( target[0].style.left, "", "left should not be modified" );
-});
+ equal( target[ 0 ].style.height, "", "height should not be modified" );
+ equal( target[ 0 ].style.top, "", "top should not be modified" );
+ equal( target[ 0 ].style.left, "", "left should not be modified" );
+} );
-test("w", function() {
- expect(4);
+test( "w", function() {
+ expect( 4 );
- var handle = ".ui-resizable-w", target = $("#resizable1").resizable({ handles: "all" });
+ var handle = ".ui-resizable-w", target = $( "#resizable1" ).resizable( { handles: "all" } );
- testHelper.drag(handle, -50);
+ testHelper.drag( handle, -50 );
equal( target.width(), 150, "compare width" );
- testHelper.drag(handle, 50);
+ testHelper.drag( handle, 50 );
equal( target.width(), 100, "compare width" );
- equal( target[0].style.height, "", "height should not be modified" );
- equal( target[0].style.top, "", "top should not be modified" );
-});
+ equal( target[ 0 ].style.height, "", "height should not be modified" );
+ equal( target[ 0 ].style.top, "", "top should not be modified" );
+} );
-test("ne", function() {
- expect(5);
+test( "ne", function() {
+ expect( 5 );
- var handle = ".ui-resizable-ne", target = $("#resizable1").css({ overflow: "hidden" }).resizable({ handles: "all" });
+ var handle = ".ui-resizable-ne", target = $( "#resizable1" ).css( { overflow: "hidden" } ).resizable( { handles: "all" } );
- testHelper.drag(handle, -50, -50);
+ testHelper.drag( handle, -50, -50 );
equal( target.width(), 50, "compare width" );
equal( target.height(), 150, "compare height" );
- testHelper.drag(handle, 50, 50);
+ testHelper.drag( handle, 50, 50 );
equal( target.width(), 100, "compare width" );
equal( target.height(), 100, "compare height" );
- equal( target[0].style.left, "", "left should not be modified" );
-});
+ equal( target[ 0 ].style.left, "", "left should not be modified" );
+} );
-test("se", function() {
- expect(6);
+test( "se", function() {
+ expect( 6 );
- var handle = ".ui-resizable-se", target = $("#resizable1").resizable({ handles: "all" });
+ var handle = ".ui-resizable-se", target = $( "#resizable1" ).resizable( { handles: "all" } );
- testHelper.drag(handle, 50, 50);
+ testHelper.drag( handle, 50, 50 );
equal( target.width(), 150, "compare width" );
equal( target.height(), 150, "compare height" );
- testHelper.drag(handle, -50, -50);
+ testHelper.drag( handle, -50, -50 );
equal( target.width(), 100, "compare width" );
equal( target.height(), 100, "compare height" );
- equal( target[0].style.top, "", "top should not be modified" );
- equal( target[0].style.left, "", "left should not be modified" );
-});
+ equal( target[ 0 ].style.top, "", "top should not be modified" );
+ equal( target[ 0 ].style.left, "", "left should not be modified" );
+} );
-test("sw", function() {
- expect(5);
+test( "sw", function() {
+ expect( 5 );
- var handle = ".ui-resizable-sw", target = $("#resizable1").resizable({ handles: "all" });
+ var handle = ".ui-resizable-sw", target = $( "#resizable1" ).resizable( { handles: "all" } );
- testHelper.drag(handle, -50, -50);
+ testHelper.drag( handle, -50, -50 );
equal( target.width(), 150, "compare width" );
equal( target.height(), 50, "compare height" );
- testHelper.drag(handle, 50, 50);
+ testHelper.drag( handle, 50, 50 );
equal( target.width(), 100, "compare width" );
equal( target.height(), 100, "compare height" );
- equal( target[0].style.top, "", "top should not be modified" );
-});
+ equal( target[ 0 ].style.top, "", "top should not be modified" );
+} );
-test("nw", function() {
- expect(4);
+test( "nw", function() {
+ expect( 4 );
- var handle = ".ui-resizable-nw", target = $("#resizable1").resizable({ handles: "all" });
+ var handle = ".ui-resizable-nw", target = $( "#resizable1" ).resizable( { handles: "all" } );
- testHelper.drag(handle, -50, -50);
+ testHelper.drag( handle, -50, -50 );
equal( target.width(), 150, "compare width" );
equal( target.height(), 150, "compare height" );
- testHelper.drag(handle, 50, 50);
+ testHelper.drag( handle, 50, 50 );
equal( target.width(), 100, "compare width" );
equal( target.height(), 100, "compare height" );
-});
+} );
-test("handle with complex markup (#8756)", function() {
- expect(2);
+test( "handle with complex markup (#8756)", function() {
+ expect( 2 );
- $("#resizable1")
+ $( "#resizable1" )
.append(
- $("<div>")
- .addClass("ui-resizable-handle")
- .addClass("ui-resizable-w")
- .append($("<div>"))
+ $( "<div>" )
+ .addClass( "ui-resizable-handle" )
+ .addClass( "ui-resizable-w" )
+ .append( $( "<div>" ) )
);
- var handle = ".ui-resizable-w div", target = $("#resizable1").resizable({ handles: "all" });
+ var handle = ".ui-resizable-w div", target = $( "#resizable1" ).resizable( { handles: "all" } );
- testHelper.drag(handle, -50);
+ testHelper.drag( handle, -50 );
equal( target.width(), 150, "compare width" );
- testHelper.drag(handle, 50);
+ testHelper.drag( handle, 50 );
equal( target.width(), 100, "compare width" );
-});
+} );
-test("resizable accounts for scroll position correctly (#3815)", function() {
+test( "resizable accounts for scroll position correctly (#3815)", function() {
expect( 4 );
var position, top, left,
- container = $("<div style='overflow:scroll;height:300px;width:300px;position:relative;'></div>").appendTo("#qunit-fixture"),
- overflowed = $("<div style='width: 1000px; height: 1000px;'></div>").appendTo( container ),
- el = $("<div style='height:100px;width:100px;position:absolute;top:10px;left:10px;'></div>").appendTo( overflowed ).resizable({ handles: "all" }),
+ container = $( "<div style='overflow:scroll;height:300px;width:300px;position:relative;'></div>" ).appendTo( "#qunit-fixture" ),
+ overflowed = $( "<div style='width: 1000px; height: 1000px;'></div>" ).appendTo( container ),
+ el = $( "<div style='height:100px;width:100px;position:absolute;top:10px;left:10px;'></div>" ).appendTo( overflowed ).resizable( { handles: "all" } ),
handle = ".ui-resizable-e",
- handlePosition = $(handle).position().left;
+ handlePosition = $( handle ).position().left;
container.scrollLeft( 100 ).scrollTop( 100 );
position = el.position();
- left = el.css("left");
- top = el.css("top");
+ left = el.css( "left" );
+ top = el.css( "top" );
- testHelper.drag(handle, 50, 50);
+ testHelper.drag( handle, 50, 50 );
deepEqual( el.position(), position, "position stays the same when resized" );
- equal( el.css("left"), left, "css('left') stays the same when resized" );
- equal( el.css("top"), top, "css('top') stays the same when resized" );
- equal( $(handle).position().left, handlePosition + 50, "handle also moved" );
-});
+ equal( el.css( "left" ), left, "css('left') stays the same when resized" );
+ equal( el.css( "top" ), top, "css('top') stays the same when resized" );
+ equal( $( handle ).position().left, handlePosition + 50, "handle also moved" );
+} );
test( "resizable stores correct size when using helper and grid (#9547)", function() {
expect( 2 );
var handle = ".ui-resizable-se",
- target = $( "#resizable1" ).resizable({
+ target = $( "#resizable1" ).resizable( {
handles: "all",
helper: "ui-resizable-helper",
grid: [ 10, 10 ]
- });
+ } );
testHelper.drag( handle, 1, 1 );
equal( target.width(), 100, "compare width" );
equal( target.height(), 100, "compare height" );
-});
+} );
test( "nested resizable", function() {
expect( 4 );
@@ -220,9 +220,9 @@ test( "nested resizable", function() {
outer.appendTo( target );
inner.appendTo( outer );
- inner.resizable( { handles : "e" } );
- outer.resizable( { handles : "e" } );
- target.resizable( { handles : "e" } );
+ inner.resizable( { handles: "e" } );
+ outer.resizable( { handles: "e" } );
+ target.resizable( { handles: "e" } );
innerHandle = $( "#inner > .ui-resizable-e" );
outerHandle = $( "#outer > .ui-resizable-e" );
@@ -239,6 +239,6 @@ test( "nested resizable", function() {
inner.remove();
outer.remove();
-});
+} );
} );
diff --git a/tests/unit/resizable/events.js b/tests/unit/resizable/events.js
index eb64400c6..b12cfa8d5 100644
--- a/tests/unit/resizable/events.js
+++ b/tests/unit/resizable/events.js
@@ -4,31 +4,31 @@ define( [
"ui/widgets/resizable"
], function( $, testHelper ) {
-module("resizable: events");
+module( "resizable: events" );
-test("start", function() {
+test( "start", function() {
- expect(5);
+ expect( 5 );
var count = 0,
handle = ".ui-resizable-se";
- $("#resizable1").resizable({
+ $( "#resizable1" ).resizable( {
handles: "all",
- start: function(event, ui) {
+ start: function( event, ui ) {
equal( ui.size.width, 100, "compare width" );
equal( ui.size.height, 100, "compare height" );
equal( ui.originalSize.width, 100, "compare original width" );
equal( ui.originalSize.height, 100, "compare original height" );
count++;
}
- });
+ } );
- testHelper.drag(handle, 50, 50);
+ testHelper.drag( handle, 50, 50 );
- equal(count, 1, "start callback should happen exactly once");
+ equal( count, 1, "start callback should happen exactly once" );
-});
+} );
test( "resize", function() {
@@ -37,7 +37,7 @@ test( "resize", function() {
var count = 0,
handle = ".ui-resizable-se";
- $("#resizable1").resizable({
+ $( "#resizable1" ).resizable( {
handles: "all",
resize: function( event, ui ) {
if ( count === 0 ) {
@@ -53,13 +53,13 @@ test( "resize", function() {
}
count++;
}
- });
+ } );
testHelper.drag( handle, 50, 50 );
equal( count, 2, "resize callback should happen exactly once per size adjustment" );
-});
+} );
test( "resize (min/max dimensions)", function() {
@@ -68,7 +68,7 @@ test( "resize (min/max dimensions)", function() {
var count = 0,
handle = ".ui-resizable-se";
- $("#resizable1").resizable({
+ $( "#resizable1" ).resizable( {
handles: "all",
minWidth: 60,
minHeight: 60,
@@ -81,13 +81,13 @@ test( "resize (min/max dimensions)", function() {
equal( ui.originalSize.height, 100, "compare original height" );
count++;
}
- });
+ } );
testHelper.drag( handle, -200, -200 );
equal( count, 1, "resize callback should happen exactly once per size adjustment" );
-});
+} );
test( "resize (containment)", function() {
@@ -95,12 +95,12 @@ test( "resize (containment)", function() {
var count = 0,
handle = ".ui-resizable-se",
- container = $("#resizable1").wrap("<div>").parent().css({
+ container = $( "#resizable1" ).wrap( "<div>" ).parent().css( {
height: "100px",
width: "100px"
- });
+ } );
- $("#resizable1").resizable({
+ $( "#resizable1" ).resizable( {
handles: "all",
containment: container,
resize: function( event, ui ) {
@@ -110,7 +110,7 @@ test( "resize (containment)", function() {
equal( ui.originalSize.height, 100, "compare original height" );
count++;
}
- });
+ } );
// Prove you can't resize outside containment by dragging southeast corner southeast
testHelper.drag( handle, 100, 100 );
@@ -120,45 +120,45 @@ test( "resize (containment)", function() {
equal( count, 1, "resize callback should happen exactly once per size adjustment" );
-});
+} );
-test("resize (grid)", function() {
+test( "resize (grid)", function() {
- expect(5);
+ expect( 5 );
var count = 0,
handle = ".ui-resizable-se";
- $("#resizable1").resizable({
+ $( "#resizable1" ).resizable( {
handles: "all",
grid: 50,
- resize: function(event, ui) {
+ resize: function( event, ui ) {
equal( ui.size.width, 150, "compare width" );
equal( ui.size.height, 150, "compare height" );
equal( ui.originalSize.width, 100, "compare original width" );
equal( ui.originalSize.height, 100, "compare original height" );
count++;
}
- });
+ } );
- testHelper.drag(handle, 50, 50);
+ testHelper.drag( handle, 50, 50 );
- equal(count, 1, "resize callback should happen exactly once per grid-unit size adjustment");
+ equal( count, 1, "resize callback should happen exactly once per grid-unit size adjustment" );
-});
+} );
test( "resize, custom adjustment", function() {
expect( 4 );
var handle = ".ui-resizable-se",
- element = $( "#resizable1" ).resizable({
+ element = $( "#resizable1" ).resizable( {
resize: function( event, ui ) {
ui.size.width = 100;
ui.size.height = 200;
ui.position.left = 300;
ui.position.top = 400;
}
- });
+ } );
testHelper.drag( handle, 50, 50 );
@@ -166,31 +166,31 @@ test( "resize, custom adjustment", function() {
equal( element.height(), 200, "resize event can control height" );
equal( element.position().left, 300, "resize event can control left" );
equal( element.position().top, 400, "resize event can control top" );
-});
+} );
-test("stop", function() {
+test( "stop", function() {
- expect(5);
+ expect( 5 );
var count = 0,
handle = ".ui-resizable-se";
- $("#resizable1").resizable({
+ $( "#resizable1" ).resizable( {
handles: "all",
- stop: function(event, ui) {
+ stop: function( event, ui ) {
equal( ui.size.width, 150, "compare width" );
equal( ui.size.height, 150, "compare height" );
equal( ui.originalSize.width, 100, "compare original width" );
equal( ui.originalSize.height, 100, "compare original height" );
count++;
}
- });
+ } );
- testHelper.drag(handle, 50, 50);
+ testHelper.drag( handle, 50, 50 );
- equal(count, 1, "stop callback should happen exactly once");
+ equal( count, 1, "stop callback should happen exactly once" );
-});
+} );
test( "resize (containment) works with parent with negative offset", function() {
@@ -203,31 +203,31 @@ test( "resize (containment) works with parent with negative offset", function()
fixedContainer = absoluteContainer.wrap( "<div />" ).parent(),
increaseWidthBy = 50;
- // position fixed container in window top left
- fixedContainer.css({
+ // Position fixed container in window top left
+ fixedContainer.css( {
width: 400,
height: 100,
position: "fixed",
top: 0,
left: 0
- });
+ } );
- // position absolute container within fixed on slightly outside window
- absoluteContainer.css({
+ // Position absolute container within fixed on slightly outside window
+ absoluteContainer.css( {
width: 400,
height: 100,
position: "absolute",
top: 0,
left: -50
- });
+ } );
- // set up resizable to be contained within absolute container
- target.resizable({
+ // Set up resizable to be contained within absolute container
+ target.resizable( {
handles: "all",
containment: "parent"
- }).css({
+ } ).css( {
width: 300
- });
+ } );
widthBefore = target.width();
@@ -237,6 +237,6 @@ test( "resize (containment) works with parent with negative offset", function()
equal( widthAfter, ( widthBefore + increaseWidthBy ), "resizable width should be increased by the value dragged" );
-});
+} );
} );
diff --git a/tests/unit/resizable/helper.js b/tests/unit/resizable/helper.js
index 494c1a073..f541d69c7 100644
--- a/tests/unit/resizable/helper.js
+++ b/tests/unit/resizable/helper.js
@@ -5,13 +5,14 @@ define( [
return $.extend( helper, {
drag: function( el, dx, dy ) {
+
// this mouseover is to work around a limitation in resizable
// TODO: fix resizable so handle doesn't require mouseover in order to be used
- $( el ).simulate("mouseover").simulate( "drag", {
+ $( el ).simulate( "mouseover" ).simulate( "drag", {
moves: 2,
dx: dx,
dy: dy
- });
+ } );
}
} );
diff --git a/tests/unit/resizable/methods.js b/tests/unit/resizable/methods.js
index ed79ef621..eea42a682 100644
--- a/tests/unit/resizable/methods.js
+++ b/tests/unit/resizable/methods.js
@@ -8,7 +8,7 @@ module( "resizable: methods" );
test( "disable", function( assert ) {
expect( 5 );
- var element = $( "#resizable1" ).resizable({ disabled: false }),
+ var element = $( "#resizable1" ).resizable( { disabled: false } ),
chainable = element.resizable( "disable" );
assert.lacksClasses( element.resizable( "widget" ), "ui-state-disabled" );
@@ -16,6 +16,6 @@ test( "disable", function( assert ) {
assert.hasClasses( element.resizable( "widget" ), "ui-resizable-disabled" );
equal( element.resizable( "option", "disabled" ), true, "disabled option setter" );
equal( chainable, element, "disable is chainable" );
-});
+} );
} );
diff --git a/tests/unit/resizable/options.js b/tests/unit/resizable/options.js
index 1e643a576..2d44eb8ee 100644
--- a/tests/unit/resizable/options.js
+++ b/tests/unit/resizable/options.js
@@ -4,162 +4,162 @@ define( [
"ui/widgets/resizable"
], function( $, testHelper ) {
-module("resizable: options");
+module( "resizable: options" );
test( "alsoResize", function() {
expect( 2 );
var other = $( "<div>" )
- .css({
+ .css( {
width: 50,
height: 50
- })
+ } )
.appendTo( "body" ),
- element = $( "#resizable1" ).resizable({
+ element = $( "#resizable1" ).resizable( {
alsoResize: other
- }),
+ } ),
handle = ".ui-resizable-e";
testHelper.drag( handle, 80 );
equal( element.width(), 180, "resizable width" );
equal( other.width(), 130, "alsoResize width" );
-});
+} );
-test("aspectRatio: 'preserve' (e)", function() {
- expect(4);
+test( "aspectRatio: 'preserve' (e)", function() {
+ expect( 4 );
- var handle = ".ui-resizable-e", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
+ var handle = ".ui-resizable-e", target = $( "#resizable1" ).resizable( { aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 } );
- testHelper.drag(handle, 80);
- equal( target.width(), 130, "compare maxWidth");
- equal( target.height(), 130, "compare maxHeight");
+ testHelper.drag( handle, 80 );
+ equal( target.width(), 130, "compare maxWidth" );
+ equal( target.height(), 130, "compare maxHeight" );
- testHelper.drag(handle, -130);
- equal( target.width(), 70, "compare minWidth");
- equal( target.height(), 70, "compare minHeight");
-});
+ testHelper.drag( handle, -130 );
+ equal( target.width(), 70, "compare minWidth" );
+ equal( target.height(), 70, "compare minHeight" );
+} );
-test("aspectRatio: 'preserve' (w)", function() {
- expect(4);
+test( "aspectRatio: 'preserve' (w)", function() {
+ expect( 4 );
- var handle = ".ui-resizable-w", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
+ var handle = ".ui-resizable-w", target = $( "#resizable1" ).resizable( { aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 } );
- testHelper.drag(handle, -80);
- equal( target.width(), 130, "compare maxWidth");
- equal( target.height(), 130, "compare maxHeight");
+ testHelper.drag( handle, -80 );
+ equal( target.width(), 130, "compare maxWidth" );
+ equal( target.height(), 130, "compare maxHeight" );
- testHelper.drag(handle, 130);
- equal( target.width(), 70, "compare minWidth");
- equal( target.height(), 70, "compare minHeight");
-});
+ testHelper.drag( handle, 130 );
+ equal( target.width(), 70, "compare minWidth" );
+ equal( target.height(), 70, "compare minHeight" );
+} );
-test("aspectRatio: 'preserve' (n)", function() {
- expect(4);
+test( "aspectRatio: 'preserve' (n)", function() {
+ expect( 4 );
- var handle = ".ui-resizable-n", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
+ var handle = ".ui-resizable-n", target = $( "#resizable1" ).resizable( { aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 } );
- testHelper.drag(handle, 0, -80);
- equal( target.width(), 130, "compare maxWidth");
- equal( target.height(), 130, "compare maxHeight");
+ testHelper.drag( handle, 0, -80 );
+ equal( target.width(), 130, "compare maxWidth" );
+ equal( target.height(), 130, "compare maxHeight" );
- testHelper.drag(handle, 0, 80);
- equal( target.width(), 70, "compare minWidth");
- equal( target.height(), 70, "compare minHeight");
-});
+ testHelper.drag( handle, 0, 80 );
+ equal( target.width(), 70, "compare minWidth" );
+ equal( target.height(), 70, "compare minHeight" );
+} );
-test("aspectRatio: 'preserve' (s)", function() {
- expect(4);
+test( "aspectRatio: 'preserve' (s)", function() {
+ expect( 4 );
- var handle = ".ui-resizable-s", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
+ var handle = ".ui-resizable-s", target = $( "#resizable1" ).resizable( { aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 } );
- testHelper.drag(handle, 0, 80);
- equal( target.width(), 130, "compare maxWidth");
- equal( target.height(), 130, "compare maxHeight");
+ testHelper.drag( handle, 0, 80 );
+ equal( target.width(), 130, "compare maxWidth" );
+ equal( target.height(), 130, "compare maxHeight" );
- testHelper.drag(handle, 0, -80);
- equal( target.width(), 70, "compare minWidth");
- equal( target.height(), 70, "compare minHeight");
-});
+ testHelper.drag( handle, 0, -80 );
+ equal( target.width(), 70, "compare minWidth" );
+ equal( target.height(), 70, "compare minHeight" );
+} );
-test("aspectRatio: 'preserve' (se)", function() {
- expect(4);
+test( "aspectRatio: 'preserve' (se)", function() {
+ expect( 4 );
- var handle = ".ui-resizable-se", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
+ var handle = ".ui-resizable-se", target = $( "#resizable1" ).resizable( { aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 } );
- testHelper.drag(handle, 80, 80);
- equal( target.width(), 130, "compare maxWidth");
- equal( target.height(), 130, "compare maxHeight");
+ testHelper.drag( handle, 80, 80 );
+ equal( target.width(), 130, "compare maxWidth" );
+ equal( target.height(), 130, "compare maxHeight" );
- testHelper.drag(handle, -80, -80);
- equal( target.width(), 70, "compare minWidth");
- equal( target.height(), 70, "compare minHeight");
-});
+ testHelper.drag( handle, -80, -80 );
+ equal( target.width(), 70, "compare minWidth" );
+ equal( target.height(), 70, "compare minHeight" );
+} );
-test("aspectRatio: 'preserve' (sw)", function() {
- expect(4);
+test( "aspectRatio: 'preserve' (sw)", function() {
+ expect( 4 );
- var handle = ".ui-resizable-sw", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
+ var handle = ".ui-resizable-sw", target = $( "#resizable1" ).resizable( { aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 } );
- testHelper.drag(handle, -80, 80);
- equal( target.width(), 130, "compare maxWidth");
- equal( target.height(), 130, "compare maxHeight");
+ testHelper.drag( handle, -80, 80 );
+ equal( target.width(), 130, "compare maxWidth" );
+ equal( target.height(), 130, "compare maxHeight" );
- testHelper.drag(handle, 80, -80);
- equal( target.width(), 70, "compare minWidth");
- equal( target.height(), 70, "compare minHeight");
-});
+ testHelper.drag( handle, 80, -80 );
+ equal( target.width(), 70, "compare minWidth" );
+ equal( target.height(), 70, "compare minHeight" );
+} );
-test("aspectRatio: 'preserve' (ne)", function() {
- expect(4);
+test( "aspectRatio: 'preserve' (ne)", function() {
+ expect( 4 );
- var handle = ".ui-resizable-ne", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
+ var handle = ".ui-resizable-ne", target = $( "#resizable1" ).resizable( { aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 } );
- testHelper.drag(handle, 80, -80);
- equal( target.width(), 130, "compare maxWidth");
- equal( target.height(), 130, "compare maxHeight");
+ testHelper.drag( handle, 80, -80 );
+ equal( target.width(), 130, "compare maxWidth" );
+ equal( target.height(), 130, "compare maxHeight" );
- testHelper.drag(handle, -80, 80);
- equal( target.width(), 70, "compare minWidth");
- equal( target.height(), 70, "compare minHeight");
-});
+ testHelper.drag( handle, -80, 80 );
+ equal( target.width(), 70, "compare minWidth" );
+ equal( target.height(), 70, "compare minHeight" );
+} );
test( "aspectRatio: Resizing can move objects", function() {
expect( 7 );
- // http://bugs.jqueryui.com/ticket/7018 - Resizing can move objects
+ // Http://bugs.jqueryui.com/ticket/7018 - Resizing can move objects
var handleW = ".ui-resizable-w",
handleNW = ".ui-resizable-nw",
- target = $( "#resizable1" ).resizable({
+ target = $( "#resizable1" ).resizable( {
aspectRatio: true,
handles: "all",
containment: "parent"
- });
+ } );
- $( "#container" ).css({ width: 200, height: 300 });
- $( "#resizable1" ).css({ width: 100, height: 100, left: 75, top: 200 });
+ $( "#container" ).css( { width: 200, height: 300 } );
+ $( "#resizable1" ).css( { width: 100, height: 100, left: 75, top: 200 } );
testHelper.drag( handleW, -20 );
equal( target.width(), 100, "compare width - no size change" );
equal( target.height(), 100, "compare height - no size change" );
equal( target.position().left, 75, "compare left - no movement" );
- // http://bugs.jqueryui.com/ticket/9107 - aspectRatio and containment not handled correctly
- $( "#container" ).css({ width: 200, height: 300, position: "absolute", left: 100, top: 100 });
- $( "#resizable1" ).css({ width: 100, height: 100, left: 0, top: 0 });
+ // Http://bugs.jqueryui.com/ticket/9107 - aspectRatio and containment not handled correctly
+ $( "#container" ).css( { width: 200, height: 300, position: "absolute", left: 100, top: 100 } );
+ $( "#resizable1" ).css( { width: 100, height: 100, left: 0, top: 0 } );
testHelper.drag( handleNW, -20, -20 );
equal( target.width(), 100, "compare width - no size change" );
equal( target.height(), 100, "compare height - no size change" );
equal( target.position().left, 0, "compare left - no movement" );
equal( target.position().top, 0, "compare top - no movement" );
-});
+} );
test( "containment", function() {
expect( 4 );
- var element = $( "#resizable1" ).resizable({
+ var element = $( "#resizable1" ).resizable( {
containment: "#container"
- });
+ } );
testHelper.drag( ".ui-resizable-se", 20, 30 );
equal( element.width(), 120, "unconstrained width within container" );
@@ -168,17 +168,17 @@ test( "containment", function() {
testHelper.drag( ".ui-resizable-se", 400, 400 );
equal( element.width(), 300, "constrained width at containment edge" );
equal( element.height(), 200, "constrained height at containment edge" );
-});
+} );
test( "containment - not immediate parent", function() {
expect( 4 );
- // http://bugs.jqueryui.com/ticket/7485 - Resizable: Containment calculation is wrong
+ // Http://bugs.jqueryui.com/ticket/7485 - Resizable: Containment calculation is wrong
// when containment element is not the immediate parent
- var element = $( "#child" ).resizable({
+ var element = $( "#child" ).resizable( {
containment: "#container2",
handles: "all"
- });
+ } );
testHelper.drag( ".ui-resizable-e", 300, 0 );
equal( element.width(), 400, "Relative, contained within container width" );
@@ -190,27 +190,27 @@ test( "containment - not immediate parent", function() {
$( "#parent" ).css( { left: 50, top: 50 } );
$( "#container2" ).css( { left: 50, top: 50 } );
- element = $( "#child" ).resizable({
+ element = $( "#child" ).resizable( {
containment: "#container2",
handles: "all"
- });
+ } );
testHelper.drag( ".ui-resizable-e", 400, 0 );
equal( element.width(), 300, "Relative with Left, contained within container width" );
testHelper.drag( ".ui-resizable-s", 0, 400 );
equal( element.height(), 300, "Relative with Top, contained within container height" );
-});
+} );
test( "containment - immediate parent", function() {
expect( 4 );
- // http://bugs.jqueryui.com/ticket/10140 - Resizable: Width calculation is wrong when containment element is "position: relative"
+ // Http://bugs.jqueryui.com/ticket/10140 - Resizable: Width calculation is wrong when containment element is "position: relative"
// when containment element is immediate parent
- var element = $( "#child" ).resizable({
+ var element = $( "#child" ).resizable( {
containment: "parent",
handles: "all"
- });
+ } );
testHelper.drag( ".ui-resizable-e", 400, 0 );
equal( element.width(), 300, "Relative, contained within container width" );
@@ -222,69 +222,69 @@ test( "containment - immediate parent", function() {
$( "#parent" ).css( { left: 50, top: 50 } );
$( "#container2" ).css( { left: 50, top: 50 } );
- element = $( "#child" ).resizable({
+ element = $( "#child" ).resizable( {
containment: "parent",
handles: "all"
- });
+ } );
testHelper.drag( ".ui-resizable-e", 400, 0 );
equal( element.width(), 250, "Relative with Left, contained within container width" );
testHelper.drag( ".ui-resizable-s", 0, 400 );
equal( element.height(), 250, "Relative with Top, contained within container height" );
-});
+} );
-test("grid", function() {
- expect(4);
+test( "grid", function() {
+ expect( 4 );
- var handle = ".ui-resizable-se", target = $("#resizable1").resizable({ handles: "all", grid: [ 0, 20 ] });
+ var handle = ".ui-resizable-se", target = $( "#resizable1" ).resizable( { handles: "all", grid: [ 0, 20 ] } );
- testHelper.drag(handle, 3, 9);
- equal( target.width(), 103, "compare width");
- equal( target.height(), 100, "compare height");
+ testHelper.drag( handle, 3, 9 );
+ equal( target.width(), 103, "compare width" );
+ equal( target.height(), 100, "compare height" );
- testHelper.drag(handle, 15, 11);
- equal( target.width(), 118, "compare width");
- equal( target.height(), 120, "compare height");
-});
+ testHelper.drag( handle, 15, 11 );
+ equal( target.width(), 118, "compare width" );
+ equal( target.height(), 120, "compare height" );
+} );
-test("grid (min/max dimensions)", function() {
- expect(4);
+test( "grid (min/max dimensions)", function() {
+ expect( 4 );
- var handle = ".ui-resizable-se", target = $("#resizable1").resizable({ handles: "all", grid: 20, minWidth: 65, minHeight: 65, maxWidth: 135, maxHeight: 135 });
+ var handle = ".ui-resizable-se", target = $( "#resizable1" ).resizable( { handles: "all", grid: 20, minWidth: 65, minHeight: 65, maxWidth: 135, maxHeight: 135 } );
- testHelper.drag(handle, 50, 50);
- equal( target.width(), 120, "grid should respect maxWidth");
- equal( target.height(), 120, "grid should respect maxHeight");
+ testHelper.drag( handle, 50, 50 );
+ equal( target.width(), 120, "grid should respect maxWidth" );
+ equal( target.height(), 120, "grid should respect maxHeight" );
- testHelper.drag(handle, -100, -100);
- equal( target.width(), 80, "grid should respect minWidth");
- equal( target.height(), 80, "grid should respect minHeight");
-});
+ testHelper.drag( handle, -100, -100 );
+ equal( target.width(), 80, "grid should respect minWidth" );
+ equal( target.height(), 80, "grid should respect minHeight" );
+} );
-test("grid (wrapped)", function() {
- expect(4);
+test( "grid (wrapped)", function() {
+ expect( 4 );
- var handle = ".ui-resizable-se", target = $("#resizable2").resizable({ handles: "all", grid: [ 0, 20 ] });
+ var handle = ".ui-resizable-se", target = $( "#resizable2" ).resizable( { handles: "all", grid: [ 0, 20 ] } );
- testHelper.drag(handle, 3, 9);
- equal( target.width(), 103, "compare width");
- equal( target.height(), 100, "compare height");
+ testHelper.drag( handle, 3, 9 );
+ equal( target.width(), 103, "compare width" );
+ equal( target.height(), 100, "compare height" );
- testHelper.drag(handle, 15, 11);
- equal( target.width(), 118, "compare width");
- equal( target.height(), 120, "compare height");
-});
+ testHelper.drag( handle, 15, 11 );
+ equal( target.width(), 118, "compare width" );
+ equal( target.height(), 120, "compare height" );
+} );
test( "grid - Resizable: can be moved when grid option is set (#9611)", function() {
expect( 6 );
var oldPosition,
handle = ".ui-resizable-nw",
- target = $( "#resizable1" ).resizable({
+ target = $( "#resizable1" ).resizable( {
handles: "all",
grid: 50
- });
+ } );
testHelper.drag( handle, 50, 50 );
equal( target.width(), 50, "compare width" );
@@ -297,162 +297,159 @@ test( "grid - Resizable: can be moved when grid option is set (#9611)", function
equal( target.height(), 50, "compare height" );
equal( target.position().top, oldPosition.top, "compare top" );
equal( target.position().left, oldPosition.left, "compare left" );
-});
+} );
test( "grid - maintains grid with padding and border when approaching no dimensions", function() {
expect( 2 );
- // http://bugs.jqueryui.com/ticket/10437 - Resizable: border with grid option working wrong
+ // Http://bugs.jqueryui.com/ticket/10437 - Resizable: border with grid option working wrong
var handle = ".ui-resizable-nw",
- target = $( "#resizable1" ).css({
+ target = $( "#resizable1" ).css( {
padding: 5,
border: "5px solid black",
width: 80,
height: 80
- }).resizable({
+ } ).resizable( {
handles: "all",
grid: [ 50, 12 ]
- });
+ } );
testHelper.drag( handle, 50, 50 );
equal( target.outerWidth(), 50, "compare width" );
equal( target.outerHeight(), 52, "compare height" );
-});
+} );
-test("ui-resizable-se { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
- expect(4);
+test( "ui-resizable-se { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
+ expect( 4 );
- var handle = ".ui-resizable-se", target = $("#resizable1").resizable({ handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 });
+ var handle = ".ui-resizable-se", target = $( "#resizable1" ).resizable( { handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 } );
- testHelper.drag(handle, -50, -50);
+ testHelper.drag( handle, -50, -50 );
equal( target.width(), 60, "compare minWidth" );
equal( target.height(), 60, "compare minHeight" );
- testHelper.drag(handle, 70, 70);
+ testHelper.drag( handle, 70, 70 );
equal( target.width(), 100, "compare maxWidth" );
equal( target.height(), 100, "compare maxHeight" );
-});
+} );
-test("ui-resizable-sw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
- expect(4);
+test( "ui-resizable-sw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
+ expect( 4 );
- var handle = ".ui-resizable-sw", target = $("#resizable1").resizable({ handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 });
+ var handle = ".ui-resizable-sw", target = $( "#resizable1" ).resizable( { handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 } );
- testHelper.drag(handle, 50, -50);
+ testHelper.drag( handle, 50, -50 );
equal( target.width(), 60, "compare minWidth" );
equal( target.height(), 60, "compare minHeight" );
- testHelper.drag(handle, -70, 70);
+ testHelper.drag( handle, -70, 70 );
equal( target.width(), 100, "compare maxWidth" );
equal( target.height(), 100, "compare maxHeight" );
-});
+} );
-test("ui-resizable-ne { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
- expect(4);
+test( "ui-resizable-ne { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
+ expect( 4 );
- var handle = ".ui-resizable-ne", target = $("#resizable1").resizable({ handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 });
+ var handle = ".ui-resizable-ne", target = $( "#resizable1" ).resizable( { handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 } );
- testHelper.drag(handle, -50, 50);
+ testHelper.drag( handle, -50, 50 );
equal( target.width(), 60, "compare minWidth" );
equal( target.height(), 60, "compare minHeight" );
- testHelper.drag(handle, 70, -70);
+ testHelper.drag( handle, 70, -70 );
equal( target.width(), 100, "compare maxWidth" );
equal( target.height(), 100, "compare maxHeight" );
-});
+} );
-test("ui-resizable-nw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
- expect(4);
+test( "ui-resizable-nw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
+ expect( 4 );
- var handle = ".ui-resizable-nw", target = $("#resizable1").resizable({ handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 });
+ var handle = ".ui-resizable-nw", target = $( "#resizable1" ).resizable( { handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 } );
- testHelper.drag(handle, 70, 70);
+ testHelper.drag( handle, 70, 70 );
equal( target.width(), 60, "compare minWidth" );
equal( target.height(), 60, "compare minHeight" );
- testHelper.drag(handle, -70, -70);
+ testHelper.drag( handle, -70, -70 );
equal( target.width(), 100, "compare maxWidth" );
equal( target.height(), 100, "compare maxHeight" );
-});
-
+} );
-test( "custom handles { handles: { 's': $('#resizer1'), containment: 'parent' }", function () {
+test( "custom handles { handles: { 's': $('#resizer1'), containment: 'parent' }", function() {
expect( 2 );
var handle = "#resizer1",
- target = $( "#resizable1" ).resizable({ handles: { "s": $( "#resizer1" ) }, containment: "parent" });
+ target = $( "#resizable1" ).resizable( { handles: { "s": $( "#resizer1" ) }, containment: "parent" } );
testHelper.drag( handle, 0, 70 );
equal( target.height(), 170, "compare height" );
testHelper.drag( handle, 0, -70 );
equal( target.height(), 100, "compare height" );
-});
-
+} );
-test( "custom handles { handles: { 's': $('#resizer1')[0], containment: 'parent' }", function () {
+test( "custom handles { handles: { 's': $('#resizer1')[0], containment: 'parent' }", function() {
expect( 2 );
var handle = "#resizer1",
- target = $( "#resizable1" ).resizable({ handles: { "s": $( "#resizer1" )[ 0 ] }, containment: "parent" });
+ target = $( "#resizable1" ).resizable( { handles: { "s": $( "#resizer1" )[ 0 ] }, containment: "parent" } );
testHelper.drag( handle, 0, 70 );
equal( target.height(), 170, "compare height" );
testHelper.drag( handle, 0, -70 );
equal( target.height(), 100, "compare height" );
-});
-
+} );
-test("zIndex, applied to all handles", function() {
- expect(8);
+test( "zIndex, applied to all handles", function() {
+ expect( 8 );
- var target = $("<div></div>").resizable({ handles: "all", zIndex: 100 });
+ 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" );
- });
-});
+ } );
+} );
test( "alsoResize + containment", function() {
expect( 4 );
var other = $( "<div>" )
- .css({
+ .css( {
width: 50,
height: 50
- })
+ } )
.appendTo( "body" ),
- element = $( "#resizable1" ).resizable({
+ element = $( "#resizable1" ).resizable( {
alsoResize: other,
containment: "#container"
- });
+ } );
testHelper.drag( ".ui-resizable-se", 400, 400 );
equal( element.width(), 300, "resizable constrained width at containment edge" );
equal( element.height(), 200, "resizable constrained height at containment edge" );
equal( other.width(), 250, "alsoResize constrained width at containment edge" );
equal( other.height(), 150, "alsoResize constrained height at containment edge" );
-});
+} );
test( "alsoResize + multiple selection", function() {
expect( 6 );
var other1 = $( "<div>" )
.addClass( "other" )
- .css({
+ .css( {
width: 50,
height: 50
- })
+ } )
.appendTo( "body" ),
other2 = $( "<div>" )
.addClass( "other" )
- .css({
+ .css( {
width: 50,
height: 50
- })
- .appendTo( "body"),
- element = $( "#resizable1" ).resizable({
+ } )
+ .appendTo( "body" ),
+ element = $( "#resizable1" ).resizable( {
alsoResize: other1.add( other2 ),
containment: "#container"
- });
+ } );
testHelper.drag( ".ui-resizable-se", 400, 400 );
equal( element.width(), 300, "resizable constrained width at containment edge" );
@@ -461,6 +458,6 @@ test( "alsoResize + multiple selection", function() {
equal( other1.height(), 150, "alsoResize o1 constrained height at containment edge" );
equal( other2.width(), 250, "alsoResize o2 constrained width at containment edge" );
equal( other2.height(), 150, "alsoResize o2 constrained height at containment edge" );
-});
+} );
} );
diff --git a/tests/unit/selectable/common.js b/tests/unit/selectable/common.js
index 317fde562..70b94bbb9 100644
--- a/tests/unit/selectable/common.js
+++ b/tests/unit/selectable/common.js
@@ -15,7 +15,7 @@ common.testWidget( "selectable", {
filter: "*",
tolerance: "touch",
- // callbacks
+ // Callbacks
create: null,
selected: null,
selecting: null,
@@ -24,6 +24,6 @@ common.testWidget( "selectable", {
unselected: null,
unselecting: null
}
-});
+} );
} );
diff --git a/tests/unit/selectable/events.js b/tests/unit/selectable/events.js
index 5d4e48996..0e2e1384d 100644
--- a/tests/unit/selectable/events.js
+++ b/tests/unit/selectable/events.js
@@ -4,37 +4,37 @@ define( [
"ui/widgets/selectable"
], function( $, testHelpers ) {
-module("selectable: events");
+module( "selectable: events" );
test( "start", function() {
expect( 2 );
- var el = $("#selectable1");
- el.selectable({
+ var el = $( "#selectable1" );
+ el.selectable( {
start: function() {
ok( true, "drag fired start callback" );
- equal( this, el[0], "context of callback" );
+ equal( this, el[ 0 ], "context of callback" );
}
- });
+ } );
el.simulate( "drag", {
dx: 20,
dy: 20
- });
-});
+ } );
+} );
test( "stop", function() {
expect( 2 );
- var el = $("#selectable1");
- el.selectable({
+ var el = $( "#selectable1" );
+ el.selectable( {
start: function() {
ok( true, "drag fired stop callback" );
- equal( this, el[0], "context of callback" );
+ equal( this, el[ 0 ], "context of callback" );
}
- });
+ } );
el.simulate( "drag", {
dx: 20,
dy: 20
- });
-});
+ } );
+} );
test( "mousedown: initial position of helper", function() {
expect( 2 );
@@ -48,7 +48,7 @@ test( "mousedown: initial position of helper", function() {
element.simulate( "mousedown", {
clientX: 10,
clientY: 10
- });
+ } );
helperOffset = $( ".ui-selectable-helper" ).offset();
ok( helperOffset.top, 110, "Scroll top should be accounted for." );
@@ -58,6 +58,6 @@ test( "mousedown: initial position of helper", function() {
element.simulate( "mouseup" );
contentToForceScroll.remove();
$( window ).scrollTop( 0 ).scrollLeft( 0 );
-});
+} );
} );
diff --git a/tests/unit/selectable/methods.js b/tests/unit/selectable/methods.js
index ee60e4ebf..30160e975 100644
--- a/tests/unit/selectable/methods.js
+++ b/tests/unit/selectable/methods.js
@@ -3,73 +3,73 @@ define( [
"ui/widgets/selectable"
], function( $ ) {
-module("selectable: methods");
+module( "selectable: methods" );
-test("init", function() {
+test( "init", function() {
expect( 5 );
- $("<div></div>").appendTo("body").selectable().remove();
- ok(true, ".selectable() called on element");
+ $( "<div></div>" ).appendTo( "body" ).selectable().remove();
+ ok( true, ".selectable() called on element" );
- $([]).selectable().remove();
- ok(true, ".selectable() called on empty collection");
+ $( [] ).selectable().remove();
+ ok( true, ".selectable() called on empty collection" );
- $("<div></div>").selectable().remove();
- ok(true, ".selectable() called on disconnected DOMElement");
+ $( "<div></div>" ).selectable().remove();
+ ok( true, ".selectable() called on disconnected DOMElement" );
- var el = $("<div></div>").selectable();
- el.selectable("option", "foo");
+ var el = $( "<div></div>" ).selectable();
+ el.selectable( "option", "foo" );
el.remove();
- ok(true, "arbitrary option getter after init");
+ ok( true, "arbitrary option getter after init" );
- $("<div></div>").selectable().selectable("option", "foo", "bar").remove();
- ok(true, "arbitrary option setter after init");
-});
+ $( "<div></div>" ).selectable().selectable( "option", "foo", "bar" ).remove();
+ ok( true, "arbitrary option setter after init" );
+} );
-test("destroy", function() {
+test( "destroy", function() {
expect( 4 );
- $("<div></div>").appendTo("body").selectable().selectable("destroy").remove();
- ok(true, ".selectable('destroy') called on element");
+ $( "<div></div>" ).appendTo( "body" ).selectable().selectable( "destroy" ).remove();
+ ok( true, ".selectable('destroy') called on element" );
- $([]).selectable().selectable("destroy").remove();
- ok(true, ".selectable('destroy') called on empty collection");
+ $( [] ).selectable().selectable( "destroy" ).remove();
+ ok( true, ".selectable('destroy') called on empty collection" );
- $("<div></div>").selectable().selectable("destroy").remove();
- ok(true, ".selectable('destroy') called on disconnected DOMElement");
+ $( "<div></div>" ).selectable().selectable( "destroy" ).remove();
+ ok( true, ".selectable('destroy') called on disconnected DOMElement" );
- var expected = $("<div></div>").selectable(),
- actual = expected.selectable("destroy");
- equal(actual, expected, "destroy is chainable");
-});
+ var expected = $( "<div></div>" ).selectable(),
+ actual = expected.selectable( "destroy" );
+ equal( actual, expected, "destroy is chainable" );
+} );
-test("enable", function() {
- expect(3);
+test( "enable", function() {
+ expect( 3 );
var expected, actual,
fired = false,
- el = $("#selectable1");
+ el = $( "#selectable1" );
- el.selectable({
+ el.selectable( {
disabled: true,
start: function() { fired = true; }
- });
+ } );
el.simulate( "drag", {
dx: 20,
dy: 20
- });
- equal(fired, false, "start fired");
- el.selectable("enable");
+ } );
+ equal( fired, false, "start fired" );
+ el.selectable( "enable" );
el.simulate( "drag", {
dx: 20,
dy: 20
- });
- equal(fired, true, "start fired");
- el.selectable("destroy");
+ } );
+ equal( fired, true, "start fired" );
+ el.selectable( "destroy" );
- expected = $("<div></div>").selectable();
- actual = expected.selectable("enable");
- equal(actual, expected, "enable is chainable");
-});
+ expected = $( "<div></div>" ).selectable();
+ actual = expected.selectable( "enable" );
+ equal( actual, expected, "enable is chainable" );
+} );
test( "disable", function( assert ) {
expect( 6 );
@@ -77,16 +77,16 @@ test( "disable", function( assert ) {
fired = false,
element = $( "#selectable1" );
- element.selectable({
+ element.selectable( {
disabled: false,
start: function() {
fired = true;
}
- });
+ } );
element.simulate( "drag", {
dx: 20,
dy: 20
- });
+ } );
equal( fired, true, "start fired" );
chainable = element.selectable( "disable" );
@@ -95,7 +95,7 @@ test( "disable", function( assert ) {
element.simulate( "drag", {
dx: 20,
dy: 20
- });
+ } );
equal( fired, false, "start fired" );
assert.lacksClasses( element.selectable( "widget" ), "ui-state-disabled" );
@@ -106,6 +106,6 @@ test( "disable", function( assert ) {
element.selectable( "destroy" );
equal( chainable, element, "disable is chainable" );
-});
+} );
} );
diff --git a/tests/unit/selectable/options.js b/tests/unit/selectable/options.js
index 6bb898d26..df2f54f3e 100644
--- a/tests/unit/selectable/options.js
+++ b/tests/unit/selectable/options.js
@@ -3,62 +3,62 @@ define( [
"ui/widgets/selectable"
], function( $ ) {
-module("selectable: options");
+module( "selectable: options" );
-test("autoRefresh", function() {
- expect(3);
+test( "autoRefresh", function() {
+ expect( 3 );
var actual = 0,
- el = $("#selectable1"),
- sel = $("*", el),
+ el = $( "#selectable1" ),
+ sel = $( "*", el ),
selected = function() { actual += 1; };
- el = $("#selectable1").selectable({ autoRefresh: false, selected: selected });
+ el = $( "#selectable1" ).selectable( { autoRefresh: false, selected: selected } );
sel.hide();
el.simulate( "drag", {
dx: 1000,
dy: 1000
- });
- equal(actual, sel.length);
- el.selectable("destroy");
+ } );
+ equal( actual, sel.length );
+ el.selectable( "destroy" );
actual = 0;
sel.show();
- el = $("#selectable1").selectable({ autoRefresh: true, selected: selected });
+ el = $( "#selectable1" ).selectable( { autoRefresh: true, selected: selected } );
sel.hide();
el.simulate( "drag", {
dx: 1000,
dy: 1000
- });
- equal(actual, 0);
+ } );
+ equal( actual, 0 );
sel.show();
$( sel[ 0 ] ).simulate( "drag", {
dx: 1000,
dy: 1000
- });
- equal(actual, sel.length);
+ } );
+ equal( actual, sel.length );
- el.selectable("destroy");
+ el.selectable( "destroy" );
sel.show();
-});
+} );
-test("filter", function() {
- expect(2);
+test( "filter", function() {
+ expect( 2 );
- var actual =0,
- el = $("#selectable1"),
- sel = $("*", el),
+ var actual = 0,
+ el = $( "#selectable1" ),
+ sel = $( "*", el ),
selected = function() { actual += 1; };
- el = $("#selectable1").selectable({ filter: ".special", selected: selected });
+ el = $( "#selectable1" ).selectable( { filter: ".special", selected: selected } );
el.simulate( "drag", {
dx: 1000,
dy: 1000
- });
- ok(sel.length !== 1, "this test assumes more than 1 selectee");
- equal(actual, 1);
- el.selectable("destroy");
-});
+ } );
+ ok( sel.length !== 1, "this test assumes more than 1 selectee" );
+ equal( actual, 1 );
+ el.selectable( "destroy" );
+} );
} );
diff --git a/tests/unit/selectmenu/common.js b/tests/unit/selectmenu/common.js
index 758e004ba..97a47f2a6 100644
--- a/tests/unit/selectmenu/common.js
+++ b/tests/unit/selectmenu/common.js
@@ -21,7 +21,7 @@ common.testWidget( "selectmenu", {
},
width: false,
- // callbacks
+ // Callbacks
change: null,
close: null,
create: null,
@@ -29,6 +29,6 @@ common.testWidget( "selectmenu", {
open: null,
select: null
}
-});
+} );
} );
diff --git a/tests/unit/selectmenu/core.js b/tests/unit/selectmenu/core.js
index 96e83f69b..5431d689d 100644
--- a/tests/unit/selectmenu/core.js
+++ b/tests/unit/selectmenu/core.js
@@ -18,15 +18,15 @@ test( "markup structure", function( assert ) {
assert.lacksClasses( button, "ui-selectmenu-button-open" );
assert.hasClasses( menuWrap, "ui-selectmenu-menu" );
assert.lacksClasses( menuWrap, "ui-selectmenu-menu-open" );
-});
+} );
asyncTest( "accessibility", function() {
var wrappers, button, menu,
element = $( "#speed" ).attr( "title", "A demo title" );
- element.find( "option" ).each(function( index ) {
+ element.find( "option" ).each( function( index ) {
$( this ).attr( "title", "A demo title #" + index );
- });
+ } );
element.selectmenu();
button = element.selectmenu( "widget" );
@@ -37,7 +37,7 @@ asyncTest( "accessibility", function() {
expect( 13 + wrappers.length * 3 );
- setTimeout(function() {
+ setTimeout( function() {
equal( button.attr( "role" ), "combobox", "button role" );
equal( button.attr( "aria-haspopup" ), "true", "button aria-haspopup" );
equal( button.attr( "aria-expanded" ), "false", "button aria-expanded" );
@@ -62,13 +62,13 @@ asyncTest( "accessibility", function() {
);
$.each( wrappers, function( index ) {
var item = $( this );
- equal( item.attr( "role" ), "option", "menu item #" + index +" role" );
- equal( item.attr( "tabindex" ), -1, "menu item #" + index +" tabindex" );
+ equal( item.attr( "role" ), "option", "menu item #" + index + " role" );
+ equal( item.attr( "tabindex" ), -1, "menu item #" + index + " tabindex" );
equal( item.attr( "title" ), "A demo title #" + index, "menu item #" + index + " title" );
- });
+ } );
start();
- });
-});
+ } );
+} );
test( "_renderButtonItem()", function() {
expect( 2 );
@@ -102,9 +102,9 @@ test( "_renderButtonItem()", function() {
button.text(),
"click: button item text"
);
-});
+} );
-$.each([
+$.each( [
{
type: "default",
selector: "#speed"
@@ -127,7 +127,7 @@ $.each([
selected = element.find( "option:selected" ).next();
button.simulate( "focus" );
- setTimeout(function() {
+ setTimeout( function() {
wrappers = menu.find( "li.ui-menu-item .ui-menu-item-wrapper" );
button.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
@@ -143,13 +143,13 @@ $.each([
);
equal(
element.find( "option:selected" ).val(),
- selected.val() ,
+ selected.val(),
"original select state"
);
equal( button.text(), selected.text(), "button text" );
start();
- });
- });
+ } );
+ } );
asyncTest( "state synchronization - after click on item - " + settings.type, function() {
expect( 4 );
@@ -161,7 +161,7 @@ $.each([
selected = element.find( "option" ).last();
button.simulate( "focus" );
- setTimeout(function() {
+ setTimeout( function() {
wrappers = menu.find( "li.ui-menu-item .ui-menu-item-wrapper" );
button.trigger( "click" );
@@ -184,7 +184,7 @@ $.each([
equal( button.text(), selected.text(), "button text" );
start();
}, 1 );
- });
+ } );
asyncTest( "state synchronization - " +
"after focus item and keydown on button - " + settings.type, function() {
@@ -199,7 +199,7 @@ $.each([
// Init menu
button.simulate( "focus" );
- setTimeout(function() {
+ setTimeout( function() {
wrappers = menu.find( "li.ui-menu-item .ui-menu-item-wrapper" );
// Open menu and click first item
@@ -213,20 +213,20 @@ $.each([
// Close and use keyboard control on button
button.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
button.simulate( "focus" );
- setTimeout(function() {
+ setTimeout( function() {
button.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
equal( menu.attr( "aria-activedescendant" ), wrappers.eq( 1 ).attr( "id" ),
"menu aria-activedescendant" );
equal( button.attr( "aria-activedescendant" ), wrappers.eq( 1 ).attr( "id" ),
"button aria-activedescendant" );
- equal( element.find( "option:selected" ).val(), options.eq( 1 ).val() ,
+ equal( element.find( "option:selected" ).val(), options.eq( 1 ).val(),
"original select state" );
equal( button.text(), options.eq( 1 ).text(), "button text" );
start();
- });
- });
- });
+ } );
+ } );
+ } );
asyncTest( "item looping - " + settings.type, function() {
expect( 4 );
@@ -237,7 +237,7 @@ $.each([
menu = element.selectmenu( "menuWidget" );
button.simulate( "focus" );
- setTimeout(function() {
+ setTimeout( function() {
wrappers = menu.find( "li.ui-menu-item .ui-menu-item-wrapper" );
button.trigger( "click" );
@@ -252,8 +252,8 @@ $.each([
button.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
equal( element[ 0 ].selectedIndex, wrappers.length - 1, "No looping behind last item" );
start();
- });
- });
+ } );
+ } );
asyncTest( "item focus and active state - " + settings.type, function() {
expect( 4 );
@@ -264,11 +264,11 @@ $.each([
menu = element.selectmenu( "menuWidget" );
button.simulate( "focus" );
- setTimeout(function() {
+ setTimeout( function() {
wrappers = menu.find( "li.ui-menu-item .ui-menu-item-wrapper" );
button.trigger( "click" );
- setTimeout(function() {
+ setTimeout( function() {
checkItemClasses();
wrappers.eq( 3 ).simulate( "mouseover" ).trigger( "click" );
@@ -282,12 +282,12 @@ $.each([
$( document ).trigger( "click" );
button.trigger( "click" );
- setTimeout(function() {
+ setTimeout( function() {
checkItemClasses();
start();
- });
- });
- });
+ } );
+ } );
+ } );
function checkItemClasses() {
focusedItem = menu.find( ".ui-menu-item-wrapper.ui-state-active" );
@@ -295,7 +295,7 @@ $.each([
equal( focusedItem.attr( "id" ), wrappers.eq( element[ 0 ].selectedIndex ).attr( "id" ),
"selected item has ui-state-focus class" );
}
- });
+ } );
asyncTest( "empty option - " + settings.type, function( assert ) {
expect( 7 );
@@ -309,7 +309,7 @@ $.each([
menu = element.selectmenu( "menuWidget" );
button.simulate( "focus" );
- setTimeout(function() {
+ setTimeout( function() {
wrappers = menu.find( "li:not(.ui-selectmenu-optgroup) .ui-menu-item-wrapper" );
wrapper = wrappers.first();
@@ -325,8 +325,8 @@ $.each([
equal( wrapper.attr( "role" ), "option", "empty item has role option" );
start();
- });
- });
-});
+ } );
+ } );
+} );
} );
diff --git a/tests/unit/selectmenu/events.js b/tests/unit/selectmenu/events.js
index 2ab20c46c..2d4a3f7fc 100644
--- a/tests/unit/selectmenu/events.js
+++ b/tests/unit/selectmenu/events.js
@@ -7,7 +7,7 @@ module( "selectmenu: events", {
setup: function() {
this.element = $( "#speed" );
}
-});
+} );
asyncTest( "change", function() {
expect( 3 );
@@ -15,15 +15,15 @@ asyncTest( "change", function() {
var button, menu, options,
optionIndex = 1;
- this.element.selectmenu({
- change: function ( event, ui ) {
+ this.element.selectmenu( {
+ change: function( event, ui ) {
equal( ui.item.index, optionIndex, "ui.item.index contains correct option index" );
equal( ui.item.element[ 0 ], options.eq( optionIndex )[ 0 ],
"ui.item.element contains original option element" );
equal( ui.item.value, options.eq( optionIndex ).text(),
"ui.item.value property updated correctly" );
}
- });
+ } );
button = this.element.selectmenu( "widget" );
menu = this.element.selectmenu( "menuWidget" );
@@ -31,23 +31,23 @@ asyncTest( "change", function() {
button.simulate( "focus" );
- setTimeout(function() {
+ setTimeout( function() {
button.trigger( "click" );
menu.find( "li" ).eq( optionIndex ).simulate( "mouseover" ).trigger( "click" );
start();
- });
-});
+ } );
+} );
test( "close", function() {
expect( 2 );
var shouldFire;
- this.element.selectmenu({
+ this.element.selectmenu( {
close: function() {
ok( shouldFire, "close event fired on close" );
}
- });
+ } );
shouldFire = false;
this.element.selectmenu( "open" );
@@ -57,7 +57,7 @@ test( "close", function() {
this.element.selectmenu( "open" );
shouldFire = true;
$( "body" ).trigger( "mousedown" );
-});
+} );
asyncTest( "focus", function() {
expect( 9 );
@@ -67,20 +67,20 @@ asyncTest( "focus", function() {
optionIndex = this.element[ 0 ].selectedIndex + 1,
options = this.element.find( "option" );
- this.element.selectmenu({
+ this.element.selectmenu( {
focus: function( event, ui ) {
ok( true, "focus event fired on element #" + optionIndex + " mouseover" );
equal( ui.item.index, optionIndex, "ui.item.index contains correct option index" );
equal( ui.item.element[ 0 ], options.eq( optionIndex )[ 0 ],
"ui.item.element contains original option element" );
}
- });
+ } );
button = this.element.selectmenu( "widget" );
menu = this.element.selectmenu( "menuWidget" );
button.simulate( "focus" );
- setTimeout(function() {
+ setTimeout( function() {
button.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
button.trigger( "click" );
@@ -93,32 +93,32 @@ asyncTest( "focus", function() {
// This tests for unwanted, additional focus event on close
that.element.selectmenu( "close" );
start();
- });
-});
+ } );
+} );
test( "open", function() {
expect( 1 );
- this.element.selectmenu({
+ this.element.selectmenu( {
open: function() {
ok( true, "open event fired on open" );
}
- });
+ } );
this.element.selectmenu( "open" );
-});
+} );
asyncTest( "select", function() {
expect( 3 );
- this.element.selectmenu({
+ this.element.selectmenu( {
select: function( event, ui ) {
ok( true, "select event fired on item select" );
equal( ui.item.index, optionIndex, "ui.item.index contains correct option index" );
equal( ui.item.element[ 0 ], options.eq( optionIndex )[ 0 ],
"ui.item.element contains original option element" );
}
- });
+ } );
var button = this.element.selectmenu( "widget" ),
menu = this.element.selectmenu( "menuWidget" ),
@@ -126,11 +126,11 @@ asyncTest( "select", function() {
optionIndex = 1;
button.simulate( "focus" );
- setTimeout(function() {
+ setTimeout( function() {
button.trigger( "click" );
menu.find( "li" ).eq( optionIndex ).simulate( "mouseover" ).trigger( "click" );
start();
- });
-});
+ } );
+} );
} );
diff --git a/tests/unit/selectmenu/methods.js b/tests/unit/selectmenu/methods.js
index a386655ce..e49da50f5 100644
--- a/tests/unit/selectmenu/methods.js
+++ b/tests/unit/selectmenu/methods.js
@@ -9,8 +9,8 @@ test( "destroy", function( assert ) {
expect( 1 );
assert.domEqual( "#speed", function() {
$( "#speed" ).selectmenu().selectmenu( "destroy" );
- });
-});
+ } );
+} );
test( "open / close", function() {
expect( 5 );
@@ -27,7 +27,7 @@ test( "open / close", function() {
element.selectmenu( "close" );
ok( menu.is( ":hidden" ), "close: menu hidden" );
equal( menu.attr( "aria-hidden" ), "true", "close: menu aria-disabled" );
-});
+} );
test( "enable / disable", function() {
expect( 10 );
@@ -49,7 +49,7 @@ test( "enable / disable", function() {
equal( button.attr( "aria-disabled" ), "false", "enable: button ARIA" );
equal( button.attr( "tabindex" ), 0, "enable: button tabindex" );
equal( menu.attr( "aria-disabled" ), "false", "enable: menu ARIA" );
-});
+} );
test( "refresh - structure", function() {
expect( 3 );
@@ -73,7 +73,7 @@ test( "refresh - structure", function() {
equal( options.length, menuItems.length, "menu item length" );
equal( "Added option", menuItems.last().text(), "added item" );
equal( "Changed value", menuItems.eq( 0 ).text(), "changed item" );
-});
+} );
asyncTest( "refresh - change selected option", function() {
expect( 4 );
@@ -84,7 +84,7 @@ asyncTest( "refresh - change selected option", function() {
equal( element.find( "option:selected" ).text(), button.text(), "button text after init" );
button.simulate( "focus" );
- setTimeout(function() {
+ setTimeout( function() {
equal( element.find( "option:selected" ).text(), button.text(), "button text after focus" );
element[ 0 ].selectedIndex = 0;
@@ -98,8 +98,8 @@ asyncTest( "refresh - change selected option", function() {
equal( "Selected option", button.text(), "button text after adding selected option" );
start();
- });
-});
+ } );
+} );
test( "refresh - disabled select", function() {
expect( 4 );
@@ -115,7 +115,7 @@ test( "refresh - disabled select", function() {
equal( button.attr( "aria-disabled" ), "true", "button ARIA" );
equal( button.attr( "tabindex" ), -1, "button tabindex" );
equal( menu.attr( "aria-disabled" ), "true", "menu ARIA" );
-});
+} );
test( "refresh - disabled option", function( assert ) {
expect( 1 );
@@ -129,7 +129,7 @@ test( "refresh - disabled option", function( assert ) {
disabledItem = menu.find( "li" ).not( ".ui-selectmenu-optgroup" ).eq( 2 );
assert.hasClasses( disabledItem, "ui-state-disabled" );
-});
+} );
test( "refresh - disabled optgroup", function( assert ) {
var i, item,
@@ -156,7 +156,7 @@ test( "refresh - disabled optgroup", function( assert ) {
item = item.next( "li" );
assert.hasClasses( item, "ui-state-disabled" );
}
-});
+} );
test( "refresh - remove all options", function() {
expect( 2 );
@@ -170,7 +170,7 @@ test( "refresh - remove all options", function() {
equal( button.find( ".ui-selectmenu-text" ).html(), $( "<span>&#160;</span>" ).html(),
"Empty button text" );
equal( menu.children().length, 0, "Empty menu" );
-});
+} );
test( "widget and menuWidget", function( assert ) {
expect( 4 );
@@ -184,6 +184,6 @@ test( "widget and menuWidget", function( assert ) {
equal( menu.length, 1, "Menu Widget: one element" );
ok( menu.is( "ul.ui-menu" ), "Menu Widget: element and class" );
-});
+} );
} );
diff --git a/tests/unit/selectmenu/options.js b/tests/unit/selectmenu/options.js
index be2565e37..0ac13ed6d 100644
--- a/tests/unit/selectmenu/options.js
+++ b/tests/unit/selectmenu/options.js
@@ -11,7 +11,7 @@ test( "appendTo: null", function() {
var element = $( "#speed" ).selectmenu();
equal( element.selectmenu( "menuWidget" ).parent().parent()[ 0 ], document.body,
"defaults to body" );
-});
+} );
test( "appendTo: explicit", function() {
expect( 6 );
@@ -19,9 +19,9 @@ test( "appendTo: explicit", function() {
var detached = $( "<div>" ),
element = $( "#speed" );
- element.selectmenu({
+ element.selectmenu( {
appendTo: ".selectmenu-wrap"
- });
+ } );
equal( element.selectmenu( "menuWidget" ).parent().parent()[ 0 ],
$( "#selectmenu-wrap1" )[ 0 ], "first found element" );
equal( $( "#selectmenu-wrap2 .ui-selectmenu" ).length, 0, "only appends to one element" );
@@ -32,16 +32,16 @@ test( "appendTo: explicit", function() {
$( "#selectmenu-wrap1" )[ 0 ], "modified after init" );
element.selectmenu( "destroy" );
- element.selectmenu({
+ element.selectmenu( {
appendTo: detached
- });
+ } );
equal( element.selectmenu( "menuWidget" ).parent().parent()[ 0 ], detached[ 0 ],
"detached jQuery object" );
element.selectmenu( "destroy" );
- element.selectmenu({
+ element.selectmenu( {
appendTo: detached[ 0 ]
- });
+ } );
equal( element.selectmenu( "menuWidget" ).parent().parent()[ 0 ], detached[ 0 ],
"detached DOM element" );
element.selectmenu( "destroy" );
@@ -50,7 +50,7 @@ test( "appendTo: explicit", function() {
equal( element.selectmenu( "menuWidget" ).parent().parent()[ 0 ], detached[ 0 ],
"detached DOM element via option()" );
element.selectmenu( "destroy" );
-});
+} );
test( "appendTo: ui-front", function() {
expect( 2 );
@@ -63,12 +63,12 @@ test( "appendTo: ui-front", function() {
$( "#selectmenu-wrap2" )[ 0 ], "null, inside .ui-front" );
element.selectmenu( "destroy" );
- element.selectmenu({
+ element.selectmenu( {
appendTo: $()
- });
+ } );
equal( element.selectmenu( "menuWidget" ).parent().parent()[ 0 ],
$( "#selectmenu-wrap2" )[ 0 ], "empty jQuery object, inside .ui-front" );
-});
+} );
test( "CSS styles", function( assert ) {
expect( 5 );
@@ -84,7 +84,7 @@ test( "CSS styles", function( assert ) {
assert.hasClasses( button.find( "span.ui-icon" ), "ui-icon-triangle-1-s" );
assert.hasClasses( menu, "ui-corner-bottom" );
assert.lacksClasses( button, "ui-corner-all" );
-});
+} );
test( "width", function() {
expect( 6 );
@@ -120,9 +120,9 @@ test( "width", function() {
element
.selectmenu( "destroy" )
.css( "width", "100%" )
- .selectmenu({ width: null });
+ .selectmenu( { width: null } );
button = element.selectmenu( "widget" );
equal( button.outerWidth(), 300, "button width fills container" );
-});
+} );
} );
diff --git a/tests/unit/slider/common.js b/tests/unit/slider/common.js
index e623a7402..df53cda4f 100644
--- a/tests/unit/slider/common.js
+++ b/tests/unit/slider/common.js
@@ -23,13 +23,13 @@ common.testWidget( "slider", {
value: 0,
values: null,
- // callbacks
+ // Callbacks
create: null,
change: null,
slide: null,
start: null,
stop: null
}
-});
+} );
} );
diff --git a/tests/unit/slider/core.js b/tests/unit/slider/core.js
index 7fdb8c68c..109c9e01a 100644
--- a/tests/unit/slider/core.js
+++ b/tests/unit/slider/core.js
@@ -14,7 +14,7 @@ module( "slider: core" );
test( "markup structure", function( assert ) {
expect( 4 );
- var element = $( "<div>" ).slider({ range: true }),
+ var element = $( "<div>" ).slider( { range: true } ),
handle = element.find( "span" ),
range = element.find( "div" );
@@ -22,7 +22,7 @@ test( "markup structure", function( assert ) {
assert.hasClasses( range, "ui-slider-range ui-widget-header" );
assert.hasClasses( handle[ 0 ], "ui-slider-handle" );
assert.hasClasses( handle[ 1 ], "ui-slider-handle" );
-});
+} );
test( "keydown HOME on handle sets value to min", function() {
expect( 2 );
@@ -38,7 +38,7 @@ test( "keydown HOME on handle sets value to min", function() {
element.slider( "value", 0 );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.HOME } );
- equal(element.slider( "value" ), options.min );
+ equal( element.slider( "value" ), options.min );
element.slider( "destroy" );
@@ -54,10 +54,10 @@ test( "keydown HOME on handle sets value to min", function() {
element.slider( "value", 0 );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.HOME } );
- equal(element.slider( "value" ), options.min) ;
+ equal( element.slider( "value" ), options.min ) ;
element.slider( "destroy" );
-});
+} );
test( "keydown END on handle sets value to max", function() {
expect( 2 );
@@ -73,7 +73,7 @@ test( "keydown END on handle sets value to max", function() {
element.slider( "value", 0 );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.END } );
- equal(element.slider( "value" ), options.max) ;
+ equal( element.slider( "value" ), options.max ) ;
element.slider( "destroy" );
@@ -89,10 +89,10 @@ test( "keydown END on handle sets value to max", function() {
element.slider( "value", 0 );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.END } );
- equal(element.slider( "value" ), options.max );
+ equal( element.slider( "value" ), options.max );
element.slider( "destroy" );
-});
+} );
test( "keydown PAGE_UP on handle increases value by 1/5 range, not greater than max", function() {
expect( 4 );
@@ -106,17 +106,17 @@ test( "keydown PAGE_UP on handle increases value by 1/5 range, not greater than
};
element.slider( options );
- element.slider( "value", 70);
+ element.slider( "value", 70 );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
- equal(element.slider( "value" ), 90);
+ equal( element.slider( "value" ), 90 );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
- equal(element.slider( "value" ), 100);
+ equal( element.slider( "value" ), 100 );
element.slider( "destroy" );
- });
-});
+ } );
+} );
test( "keydown PAGE_DOWN on handle decreases value by 1/5 range, not less than min", function() {
expect( 4 );
@@ -130,17 +130,17 @@ test( "keydown PAGE_DOWN on handle decreases value by 1/5 range, not less than m
};
element.slider( options );
- element.slider( "value", 30);
+ element.slider( "value", 30 );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
- equal(element.slider( "value" ), 10);
+ equal( element.slider( "value" ), 10 );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
- equal(element.slider( "value" ), 0 );
+ equal( element.slider( "value" ), 0 );
element.slider( "destroy" );
- });
-});
+ } );
+} );
test( "keydown UP on handle increases value by step, not greater than max", function() {
expect( 4 );
@@ -151,15 +151,15 @@ test( "keydown UP on handle increases value by step, not greater than max", func
orientation: "horizontal",
step: 1
};
- element.slider(options);
+ element.slider( options );
element.slider( "value", options.max - options.step );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
- equal(element.slider( "value" ), options.max );
+ equal( element.slider( "value" ), options.max );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
- equal(element.slider( "value" ), options.max );
+ equal( element.slider( "value" ), options.max );
element.slider( "destroy" );
@@ -175,13 +175,13 @@ test( "keydown UP on handle increases value by step, not greater than max", func
element.slider( "value", options.max - options.step );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
- equal(element.slider( "value" ), options.max );
+ equal( element.slider( "value" ), options.max );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
- equal(element.slider( "value" ), options.max );
+ equal( element.slider( "value" ), options.max );
element.slider( "destroy" );
-});
+} );
test( "keydown RIGHT on handle increases value by step, not greater than max", function() {
expect( 4 );
@@ -192,15 +192,15 @@ test( "keydown RIGHT on handle increases value by step, not greater than max", f
orientation: "horizontal",
step: 1
};
- element.slider(options);
+ element.slider( options );
element.slider( "value", options.max - options.step );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
- equal(element.slider( "value" ), options.max);
+ equal( element.slider( "value" ), options.max );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
- equal(element.slider( "value" ), options.max );
+ equal( element.slider( "value" ), options.max );
element.slider( "destroy" );
@@ -216,13 +216,13 @@ test( "keydown RIGHT on handle increases value by step, not greater than max", f
element.slider( "value", options.max - options.step );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
- equal(element.slider( "value" ), options.max );
+ equal( element.slider( "value" ), options.max );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
- equal(element.slider( "value" ), options.max );
+ equal( element.slider( "value" ), options.max );
element.slider( "destroy" );
-});
+} );
test( "keydown DOWN on handle decreases value by step, not less than min", function() {
expect( 4 );
@@ -238,10 +238,10 @@ test( "keydown DOWN on handle decreases value by step, not less than min", funct
element.slider( "value", options.min + options.step );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
- equal(element.slider( "value" ), options.min);
+ equal( element.slider( "value" ), options.min );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
- equal(element.slider( "value" ), options.min );
+ equal( element.slider( "value" ), options.min );
element.slider( "destroy" );
@@ -257,13 +257,13 @@ test( "keydown DOWN on handle decreases value by step, not less than min", funct
element.slider( "value", options.min + options.step );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
- equal(element.slider( "value" ), options.min);
+ equal( element.slider( "value" ), options.min );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
- equal(element.slider( "value" ), options.min );
+ equal( element.slider( "value" ), options.min );
element.slider( "destroy" );
-});
+} );
test( "keydown LEFT on handle decreases value by step, not less than min", function() {
expect( 4 );
@@ -274,15 +274,15 @@ test( "keydown LEFT on handle decreases value by step, not less than min", funct
orientation: "horizontal",
step: 1
};
- element.slider(options);
+ element.slider( options );
element.slider( "value", options.min + options.step );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
- equal(element.slider( "value" ), options.min );
+ equal( element.slider( "value" ), options.min );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
- equal(element.slider( "value" ), options.min );
+ equal( element.slider( "value" ), options.min );
element.slider( "destroy" );
@@ -298,12 +298,12 @@ test( "keydown LEFT on handle decreases value by step, not less than min", funct
element.slider( "value", options.min + options.step );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
- equal(element.slider( "value" ), options.min );
+ equal( element.slider( "value" ), options.min );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
- equal(element.slider( "value" ), options.min );
+ equal( element.slider( "value" ), options.min );
element.slider( "destroy" );
-});
+} );
} );
diff --git a/tests/unit/slider/events.js b/tests/unit/slider/events.js
index 0256a2093..2cf67b5fe 100644
--- a/tests/unit/slider/events.js
+++ b/tests/unit/slider/events.js
@@ -13,11 +13,11 @@ test( "mouse based interaction", function() {
expect( 4 );
var element = $( "#slider1" )
- .slider({
+ .slider( {
start: function( event ) {
equal( event.originalEvent.type, "mousedown", "start triggered by mousedown" );
},
- slide: function( event) {
+ slide: function( event ) {
equal( event.originalEvent.type, "mousemove", "slider triggered by mousemove" );
},
stop: function( event ) {
@@ -26,18 +26,18 @@ test( "mouse based interaction", function() {
change: function( event ) {
equal( event.originalEvent.type, "mouseup", "change triggered by mouseup" );
}
- });
+ } );
element.find( ".ui-slider-handle" ).eq( 0 )
.simulate( "drag", { dx: 10, dy: 10 } );
-});
+} );
test( "keyboard based interaction", function() {
expect( 3 );
// Test keyup at end of handle slide (keyboard)
var element = $( "#slider1" )
- .slider({
+ .slider( {
start: function( event ) {
equal( event.originalEvent.type, "keydown", "start triggered by keydown" );
},
@@ -50,113 +50,113 @@ test( "keyboard based interaction", function() {
change: function( event ) {
equal( event.originalEvent.type, "keyup", "change triggered by keyup" );
}
- });
+ } );
element.find( ".ui-slider-handle" ).eq( 0 )
.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } )
.simulate( "keypress", { keyCode: $.ui.keyCode.LEFT } )
.simulate( "keyup", { keyCode: $.ui.keyCode.LEFT } );
-});
+} );
test( "programmatic event triggers", function() {
expect( 6 );
// Test value method
var element = $( "<div></div>" )
- .slider({
+ .slider( {
change: function() {
ok( true, "change triggered by value method" );
}
- })
+ } )
.slider( "value", 0 );
// Test values method
element = $( "<div></div>" )
- .slider({
+ .slider( {
values: [ 10, 20 ],
change: function() {
ok( true, "change triggered by values method" );
}
- })
+ } )
.slider( "values", [ 80, 90 ] );
// Test value option
element = $( "<div></div>" )
- .slider({
+ .slider( {
change: function() {
ok( true, "change triggered by value option" );
}
- })
+ } )
.slider( "option", "value", 0 );
// Test values option
element = $( "<div></div>" )
- .slider({
+ .slider( {
values: [ 10, 20 ],
change: function() {
ok( true, "change triggered by values option" );
}
- })
+ } )
.slider( "option", "values", [ 80, 90 ] );
-});
+} );
test( "mouse based interaction part two: when handles overlap", function() {
expect( 6 );
var element = $( "#slider1" )
- .slider({
+ .slider( {
values: [ 0, 0, 0 ],
start: function( event, ui ) {
equal( handles.index( ui.handle ), 2, "rightmost handle activated when overlapping at minimum (#3736)" );
}
- }),
+ } ),
handles = element.find( ".ui-slider-handle" );
handles.eq( 0 ).simulate( "drag", { dx: 10 } );
element.slider( "destroy" );
element = $( "#slider1" )
- .slider({
+ .slider( {
values: [ 10, 10, 10 ],
max: 10,
start: function( event, ui ) {
equal( handles.index( ui.handle ), 0, "leftmost handle activated when overlapping at maximum" );
}
- }),
+ } ),
handles = element.find( ".ui-slider-handle" );
handles.eq( 0 ).simulate( "drag", { dx: -10 } );
element.slider( "destroy" );
element = $( "#slider1" )
- .slider({
+ .slider( {
values: [ 19, 20 ]
- }),
+ } ),
handles = element.find( ".ui-slider-handle" );
handles.eq( 0 ).simulate( "drag", { dx: 10 } );
element.one( "slidestart", function( event, ui ) {
equal( handles.index( ui.handle ), 0, "left handle activated if left was moved last" );
- });
+ } );
handles.eq( 0 ).simulate( "drag", { dx: 10 } );
element.slider( "destroy" );
element = $( "#slider1" )
- .slider({
+ .slider( {
values: [ 19, 20 ]
- }),
+ } ),
handles = element.find( ".ui-slider-handle" );
handles.eq( 1 ).simulate( "drag", { dx: -10 } );
element.one( "slidestart", function( event, ui ) {
equal( handles.index( ui.handle ), 1, "right handle activated if right was moved last (#3467)" );
- });
+ } );
handles.eq( 0 ).simulate( "drag", { dx: 10 } );
element = $( "#slider1" )
- .slider({
+ .slider( {
range: true,
min: 0,
max: 100,
values: [ 0, 50 ]
- }),
+ } ),
handles = element.find( ".ui-slider-handle" );
element.slider( "option", { values: [ 100, 100 ] } );
@@ -166,7 +166,7 @@ test( "mouse based interaction part two: when handles overlap", function() {
element.slider( "option", { values: [ 0, 0 ] } );
handles.eq( 1 ).simulate( "drag", { dx: 10 } );
equal( element.slider( "values" )[ 1 ], 1, "setting both values of range slider to the minimum doesn't lock slider" );
-});
+} );
test( "event data", function() {
expect( 6 );
@@ -175,7 +175,7 @@ test( "event data", function() {
values = [ 8, 9, 7, 4 ],
newValues = [ 8, 9, 7, 5 ],
element = $( "#slider1" )
- .slider({
+ .slider( {
values: values,
start: function( event, ui ) {
deepEqual( ui, expectedUiHash, "passing ui to start event" );
@@ -189,7 +189,7 @@ test( "event data", function() {
change: function( event, ui ) {
deepEqual( ui, expectedChangedUiHash, "passing ui to change event" );
}
- }),
+ } ),
handles = element.find( ".ui-slider-handle" ),
expectedUiHash = {
handle: handles.eq( slideHandleIndex )[ 0 ],
@@ -200,33 +200,33 @@ test( "event data", function() {
expectedChangedUiHash = $.extend( {}, expectedUiHash, {
values: newValues,
value: newValues[ slideHandleIndex ]
- });
+ } );
handles.eq( slideHandleIndex ).simulate( "drag", { dx: 10 } );
element.slider( "destroy" );
- element = $( "#slider1" ).slider({
+ element = $( "#slider1" ).slider( {
min: 0,
max: 100,
value: 1,
- slide: function ( event, ui ) {
+ slide: function( event, ui ) {
equal( ui.value, 0, "should pass 0 value if slider reaches it" );
}
- });
+ } );
handles = element.find( ".ui-slider-handle" );
handles.eq( 0 ).simulate( "drag", { dx: -10 } );
element.slider( "destroy" );
- element = $( "#slider1" ).slider({
+ element = $( "#slider1" ).slider( {
min: 0,
max: 100,
values: [ 1, 2 ],
- slide: function ( event, ui ) {
+ slide: function( event, ui ) {
equal( ui.value, 0, "should pass 0 value if one of handles reaches it" );
}
- });
+ } );
handles = element.find( ".ui-slider-handle" );
handles.eq( 0 ).simulate( "drag", { dx: -10 } );
-});
+} );
} );
diff --git a/tests/unit/slider/methods.js b/tests/unit/slider/methods.js
index 5a87edfda..15b2e8726 100644
--- a/tests/unit/slider/methods.js
+++ b/tests/unit/slider/methods.js
@@ -6,7 +6,7 @@ define( [
module( "slider: methods" );
test( "init", function() {
- expect(5);
+ expect( 5 );
$( "<div></div>" ).appendTo( "body" ).slider().remove();
ok( true, ".slider() called on element" );
@@ -24,90 +24,92 @@ test( "init", function() {
$( "<div></div>" ).slider().slider( "option", "foo", "bar" ).remove();
ok( true, "arbitrary option setter after init" );
-});
+} );
test( "destroy", function( assert ) {
expect( 1 );
assert.domEqual( "#slider1", function() {
$( "#slider1" ).slider().slider( "destroy" );
- });
-});
+ } );
+} );
test( "enable", function( assert ) {
expect( 3 );
var element,
expected = $( "<div></div>" ).slider(),
actual = expected.slider( "enable" );
- equal(actual, expected, "enable is chainable" );
+ equal( actual, expected, "enable is chainable" );
- element = $( "<div></div>" ).slider({ disabled: true });
+ element = $( "<div></div>" ).slider( { disabled: true } );
assert.hasClasses( element, "ui-state-disabled ui-slider-disabled" );
element.slider( "enable" );
assert.lacksClasses( element, "ui-state-disabled ui-slider-disabled" );
-});
+} );
test( "disable", function( assert ) {
expect( 4 );
var element,
expected = $( "<div></div>" ).slider(),
actual = expected.slider( "disable" );
- equal(actual, expected, "disable is chainable" );
+ equal( actual, expected, "disable is chainable" );
- element = $( "<div></div>" ).slider({ disabled: false });
+ element = $( "<div></div>" ).slider( { disabled: false } );
assert.lacksClasses( element, "ui-state-disabled ui-slider-disabled" );
element.slider( "disable" );
assert.hasClasses( element, "ui-state-disabled ui-slider-disabled" );
ok( !element.attr( "aria-disabled" ), "slider does not have aria-disabled attr after disable method call" );
-});
+} );
test( "value", function() {
expect( 19 );
- $( [ false, "min", "max" ] ).each(function() {
- var element = $( "<div></div>" ).slider({
+ $( [ false, "min", "max" ] ).each( function() {
+ var element = $( "<div></div>" ).slider( {
range: this,
value: 5
- });
+ } );
equal( element.slider( "value" ), 5, "range: " + this + " slider method get" );
- equal( element.slider( "value", 10), element, "value method is chainable" );
+ equal( element.slider( "value", 10 ), element, "value method is chainable" );
equal( element.slider( "value" ), 10, "range: " + this + " slider method set" );
element.remove();
- });
- var element = $( "<div></div>" ).slider({
+ } );
+ var element = $( "<div></div>" ).slider( {
min: -1, value: 0, max: 1
- });
+ } );
+
// min with value option vs value method
element.slider( "option", "value", -2 );
equal( element.slider( "option", "value" ), -2, "value option does not respect min" );
equal( element.slider( "value" ), -1, "value method get respects min" );
equal( element.slider( "value", -2 ), element, "value method is chainable" );
equal( element.slider( "option", "value" ), -1, "value method set respects min" );
+
// max with value option vs value method
- element.slider( "option", "value", 2);
+ element.slider( "option", "value", 2 );
equal( element.slider( "option", "value" ), 2, "value option does not respect max" );
equal( element.slider( "value" ), 1, "value method get respects max" );
equal( element.slider( "value", 2 ), element, "value method is chainable" );
equal( element.slider( "option", "value" ), 1, "value method set respects max" );
- // set max value with step 0.01
+ // Set max value with step 0.01
element.slider( "option", {
min: 2,
value: 2,
max: 2.4,
step: 0.01
- });
+ } );
element.slider( "option", "value", 2.4 );
equal( element.slider( "value" ), 2.4, "value is set to max with 0.01 step" );
- element = $( "<div></div>" ).slider({
+ element = $( "<div></div>" ).slider( {
value: 100,
min: 10,
max: 500,
step: 50
- });
+ } );
element.slider( "option", "value", 510 );
equal( element.slider( "value" ), 460, "value is restricted to maximum valid step" );
-});
+} );
//test( "values", function() {
// ok(false, "missing test - untested code is broken code." );
diff --git a/tests/unit/slider/options.js b/tests/unit/slider/options.js
index 3853c4c5d..031031cdc 100644
--- a/tests/unit/slider/options.js
+++ b/tests/unit/slider/options.js
@@ -11,18 +11,18 @@ function handle() {
module( "slider: options" );
-test( "disabled", function( assert ){
+test( "disabled", function( assert ) {
expect( 8 );
var count = 0;
element = $( "#slider1" ).slider();
element.on( "slidestart", function() {
count++;
- });
+ } );
- // enabled
+ // Enabled
assert.lacksClasses( element, "ui-slider-disabled" );
- equal( element.slider( "option", "disabled" ), false , "is not disabled" );
+ equal( element.slider( "option", "disabled" ), false, "is not disabled" );
handle().simulate( "drag", { dx: 10 } );
equal( count, 1, "slider moved" );
@@ -30,7 +30,7 @@ test( "disabled", function( assert ){
handle().simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
equal( count, 2, "slider moved" );
- // disabled
+ // Disabled
element.slider( "option", "disabled", true );
assert.hasClasses( element, "ui-slider-disabled" );
equal( element.slider( "option", "disabled" ), true, "is disabled" );
@@ -40,7 +40,7 @@ test( "disabled", function( assert ){
handle().simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
equal( count, 2, "slider did not move" );
-});
+} );
test( "max", function() {
expect( 5 );
@@ -87,7 +87,7 @@ test( "max", function() {
ok( element.slider( "value" ) === options.max, "value method will max, step is changed and step is float" );
element.slider( "destroy" );
-});
+} );
test( "min", function() {
expect( 2 );
@@ -106,7 +106,7 @@ test( "min", function() {
ok( element.slider( "value" ) === options.min, "value method is contained by min" );
element.slider( "destroy" );
-});
+} );
test( "orientation", function( assert ) {
expect( 14 );
@@ -126,7 +126,7 @@ test( "orientation", function( assert ) {
assert.hasClasses( element, "ui-slider-horizontal" );
assert.lacksClasses( element, "ui-slider-vertical" );
equal( element.find( ".ui-slider-handle" )[ 0 ].style.bottom, "", "CSS bottom reset" );
- equal( handle()[0].style.left, percentVal + "%", "horizontal slider handle is positioned with left: %" );
+ equal( handle()[ 0 ].style.left, percentVal + "%", "horizontal slider handle is positioned with left: %" );
element.slider( "destroy" ) ;
@@ -143,17 +143,17 @@ test( "orientation", function( assert ) {
assert.hasClasses( element, "ui-slider-vertical" );
assert.lacksClasses( element, "ui-slider-horizontal" );
equal( element.find( ".ui-slider-handle" )[ 0 ].style.left, "", "CSS left reset" );
- equal( handle()[0].style.bottom, percentVal + "%", "vertical slider handle is positioned with bottom: %" );
+ equal( handle()[ 0 ].style.bottom, percentVal + "%", "vertical slider handle is positioned with bottom: %" );
element.slider( "destroy" );
newValue = 7;
- rangeSize = 500 - (500 * newValue / 10);
- element = $( "#slider2" ).slider({
+ rangeSize = 500 - ( 500 * newValue / 10 );
+ element = $( "#slider2" ).slider( {
range: "max",
min: 0,
max: 10
- });
+ } );
element.slider( "option", "value", newValue );
element.slider( "option", "orientation", "vertical" );
@@ -170,11 +170,11 @@ test( "orientation", function( assert ) {
element.slider( "destroy" );
- element = $( "#slider2" ).slider({
+ element = $( "#slider2" ).slider( {
range: true,
min: 0,
max: 100
- });
+ } );
element.slider( "option", { values: [ 60, 70 ] } );
notEqual( element.find( ".ui-slider-range " ).position().left, 0,
"range should not pull over to the track's border" );
@@ -183,19 +183,19 @@ test( "orientation", function( assert ) {
"range should pull over to the track's border" );
element.slider( "destroy" );
-});
+} );
//spec: http://wiki.jqueryui.com/Slider#specs
// value option/method: the value option is not restricted by min/max/step.
// What is returned by the value method is restricted by min (>=), max (<=), and step (even multiple)
test( "step", function() {
expect( 9 );
- element = $( "<div></div>" ).slider({
+ element = $( "<div></div>" ).slider( {
min: 0,
value: 0,
step: 10,
max: 100
- });
+ } );
equal( element.slider( "value" ), 0 );
element.slider( "value", 1 );
@@ -210,12 +210,12 @@ test( "step", function() {
element.slider( "value", 19 );
equal( element.slider( "value" ), 20 );
- element = $( "<div></div>" ).slider({
+ element = $( "<div></div>" ).slider( {
min: 0,
value: 0,
step: 20,
max: 100
- });
+ } );
element.slider( "value", 0 );
element.slider( "option", "value", 1 );
@@ -231,7 +231,7 @@ test( "step", function() {
equal( element.slider( "value" ), 20 );
element.slider( "destroy" );
-});
+} );
//test( "value", function() {
// ok(false, "missing test - untested code is broken code." );
@@ -240,16 +240,16 @@ test( "step", function() {
test( "values", function() {
expect( 2 );
- // testing multiple ranges on the same page, the object reference to the values
+ // Testing multiple ranges on the same page, the object reference to the values
// property is preserved via multiple range elements, so updating options.values
// of 1 slider updates options.values of all the others
- var ranges = $([
+ var ranges = $( [
document.createElement( "div" ),
document.createElement( "div" )
- ]).slider({
+ ] ).slider( {
range: true,
values: [ 25, 75 ]
- });
+ } );
notStrictEqual(
ranges.eq( 0 ).slider( "instance" ).options.values,
@@ -264,43 +264,43 @@ test( "values", function() {
ranges.eq( 1 ).slider( "values", 0 ),
"the values for multiple sliders should be different"
);
-});
+} );
test( "range", function( assert ) {
expect( 32 );
var range;
- // min
- element = $( "<div></div>" ).slider({
+ // Min
+ element = $( "<div></div>" ).slider( {
range: "min",
min: 1,
max: 10,
step: 1
- });
+ } );
equal( element.find( ".ui-slider-handle" ).length, 1, "range min, one handle" );
equal( element.find( ".ui-slider-range-min" ).length, 1, "range min" );
element.slider( "destroy" );
- // max
- element = $( "<div></div>" ).slider({
+ // Max
+ element = $( "<div></div>" ).slider( {
range: "max",
min: 1,
max: 10,
step: 1
- });
+ } );
equal( element.find( ".ui-slider-handle" ).length, 1, "range max, one handle" );
equal( element.find( ".ui-slider-range-max" ).length, 1, "range max" );
element.slider( "destroy" );
- // true
- element = $( "<div></div>" ).slider({
+ // True
+ element = $( "<div></div>" ).slider( {
range: true,
min: 1,
max: 10,
step: 1
- });
+ } );
range = element.find( ".ui-slider-range" );
equal( element.find( ".ui-slider-handle" ).length, 2, "range true, two handles" );
@@ -308,12 +308,12 @@ test( "range", function( assert ) {
element.slider( "destroy" );
// Change range from min to max
- element = $( "<div></div>" ).slider({
+ element = $( "<div></div>" ).slider( {
range: "min",
min: 1,
max: 10,
step: 1
- }).slider( "option", "range", "max" );
+ } ).slider( "option", "range", "max" );
equal( element.find( ".ui-slider-handle" ).length, 1, "range switch from min to max, one handle" );
equal( element.find( ".ui-slider-range-min" ).length, 0, "range switch from min to max" );
@@ -321,12 +321,12 @@ test( "range", function( assert ) {
element.slider( "destroy" );
// Change range from max to min
- element = $( "<div></div>" ).slider({
+ element = $( "<div></div>" ).slider( {
range: "max",
min: 1,
max: 10,
step: 1
- }).slider( "option", "range", "min" );
+ } ).slider( "option", "range", "min" );
equal( element.find( ".ui-slider-handle" ).length, 1, "range switch from max to min, one handle" );
equal( element.find( ".ui-slider-range-max" ).length, 0, "range switch from max to min" );
@@ -334,53 +334,53 @@ test( "range", function( assert ) {
element.slider( "destroy" );
// Change range from max to true
- element = $( "<div></div>" ).slider({
+ element = $( "<div></div>" ).slider( {
range: "max",
min: 1,
max: 10,
step: 1
- }).slider( "option", "range", true );
+ } ).slider( "option", "range", true );
equal( element.find( ".ui-slider-handle" ).length, 2, "range switch from max to true, two handles" );
equal( element.find( ".ui-slider-range-max" ).length, 0, "range switch from max to true" );
equal( element.find( ".ui-slider-range-min" ).length, 0, "range switch from max to true" );
- equal( element.slider( "option", "value" ), 0 , "option value" );
- equal( element.slider( "value" ), 1 , "value" );
- deepEqual( element.slider( "option", "values" ), [1, 1], "option values" );
- deepEqual( element.slider( "values" ), [1, 1], "values" );
+ equal( element.slider( "option", "value" ), 0, "option value" );
+ equal( element.slider( "value" ), 1, "value" );
+ deepEqual( element.slider( "option", "values" ), [ 1, 1 ], "option values" );
+ deepEqual( element.slider( "values" ), [ 1, 1 ], "values" );
element.slider( "destroy" );
// Change range from true to min
- element = $( "<div></div>" ).slider({
+ element = $( "<div></div>" ).slider( {
range: true,
min: 1,
max: 10,
step: 1
- }).slider( "option", "range", "min" );
+ } ).slider( "option", "range", "min" );
equal( element.find( ".ui-slider-handle" ).length, 1, "range switch from true to min, one handle" );
equal( element.find( ".ui-slider-range-max" ).length, 0, "range switch from true to min" );
equal( element.find( ".ui-slider-range-min" ).length, 1, "range switch from true to min" );
equal( element.slider( "option", "value" ), 1, "value" );
- equal( element.slider( "value" ), 1 , "value" );
+ equal( element.slider( "value" ), 1, "value" );
equal( element.slider( "option", "values" ), null, "values" );
- deepEqual( element.slider( "values" ), [] , "values" );
+ deepEqual( element.slider( "values" ), [], "values" );
element.slider( "destroy" );
// Change range from true to false
- element = $( "<div></div>" ).slider({
+ element = $( "<div></div>" ).slider( {
range: true,
min: 1,
max: 10,
step: 1
- }).slider( "option", "range", false );
+ } ).slider( "option", "range", false );
equal( element.find( ".ui-slider-handle" ).length, 2, "range switch from true to false, both handles remain" );
equal( element.find( ".ui-slider-range" ).length, 0, "range switch from true to false" );
- equal( element.slider( "option", "value" ), 0 , "option value" );
- equal( element.slider( "value" ), 1 , "value" );
- deepEqual( element.slider( "option", "values" ), [1, 1], "option values" );
- deepEqual( element.slider( "values" ), [1, 1], "values" );
+ equal( element.slider( "option", "value" ), 0, "option value" );
+ equal( element.slider( "value" ), 1, "value" );
+ deepEqual( element.slider( "option", "values" ), [ 1, 1 ], "option values" );
+ deepEqual( element.slider( "values" ), [ 1, 1 ], "values" );
element.slider( "destroy" );
-});
+} );
} );
diff --git a/tests/unit/sortable/common.js b/tests/unit/sortable/common.js
index aefb28b70..dd22c0433 100644
--- a/tests/unit/sortable/common.js
+++ b/tests/unit/sortable/common.js
@@ -33,7 +33,7 @@ common.testWidget( "sortable", {
tolerance: "intersect",
zIndex: 1000,
- // callbacks
+ // Callbacks
activate: null,
beforeStop: null,
change: null,
@@ -48,6 +48,6 @@ common.testWidget( "sortable", {
stop: null,
update: null
}
-});
+} );
} );
diff --git a/tests/unit/sortable/core.js b/tests/unit/sortable/core.js
index 68f275604..d12416f09 100644
--- a/tests/unit/sortable/core.js
+++ b/tests/unit/sortable/core.js
@@ -9,12 +9,12 @@ module( "sortable: core" );
test( "#9314: Sortable: Items cannot be dragged directly into bottom position", function() {
expect( 1 );
- var el = $( ".connectWith" ).sortable({
+ var el = $( ".connectWith" ).sortable( {
connectWith: ".connectWith"
- });
+ } );
testHelper.sort( $( "li", el[ 1 ] )[ 0 ], 0, -12, 5, "Dragging the sortable into connected sortable" );
-});
+} );
test( "ui-sortable-handle applied to appropriate element", function( assert ) {
expect( 8 );
@@ -37,6 +37,6 @@ test( "ui-sortable-handle applied to appropriate element", function( assert ) {
el.sortable( "destroy" );
equal( el.find( ".ui-sortable-handle" ).length, 0, "class name removed on destroy" );
-});
+} );
} );
diff --git a/tests/unit/sortable/events.js b/tests/unit/sortable/events.js
index bf5579fde..d2416fbc4 100644
--- a/tests/unit/sortable/events.js
+++ b/tests/unit/sortable/events.js
@@ -5,223 +5,223 @@ define( [
"ui/widgets/draggable"
], function( $, testHelper ) {
-module("sortable: events");
+module( "sortable: events" );
-test("start", function() {
+test( "start", function() {
expect( 7 );
var hash;
- $("#sortable").sortable({
+ $( "#sortable" ).sortable( {
start: function( e, ui ) {
hash = ui;
}
- }).find("li:eq(0)").simulate( "drag", {
+ } ).find( "li:eq(0)" ).simulate( "drag", {
dy: 10
- });
+ } );
- ok(hash, "start event triggered");
- ok(hash.helper, "UI hash includes: helper");
- ok(hash.placeholder, "UI hash includes: placeholder");
- ok(hash.item, "UI hash includes: item");
- ok(!hash.sender, "UI hash does not include: sender");
+ ok( hash, "start event triggered" );
+ ok( hash.helper, "UI hash includes: helper" );
+ ok( hash.placeholder, "UI hash includes: placeholder" );
+ ok( hash.item, "UI hash includes: item" );
+ ok( !hash.sender, "UI hash does not include: sender" );
- // todo: see if these events should actually have sane values in them
- ok("position" in hash, "UI hash includes: position");
- ok("offset" in hash, "UI hash includes: offset");
-});
+ // Todo: see if these events should actually have sane values in them
+ ok( "position" in hash, "UI hash includes: position" );
+ ok( "offset" in hash, "UI hash includes: offset" );
+} );
-test("sort", function() {
+test( "sort", function() {
expect( 7 );
var hash;
- $("#sortable").sortable({
+ $( "#sortable" ).sortable( {
sort: function( e, ui ) {
hash = ui;
}
- }).find("li:eq(0)").simulate( "drag", {
+ } ).find( "li:eq(0)" ).simulate( "drag", {
dy: 10
- });
+ } );
- ok(hash, "sort event triggered");
- ok(hash.helper, "UI hash includes: helper");
- ok(hash.placeholder, "UI hash includes: placeholder");
- ok(hash.position && ("top" in hash.position && "left" in hash.position), "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");
+ ok( hash, "sort event triggered" );
+ ok( hash.helper, "UI hash includes: helper" );
+ ok( hash.placeholder, "UI hash includes: placeholder" );
+ ok( hash.position && ( "top" in hash.position && "left" in hash.position ), "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() {
+test( "change", function() {
expect( 8 );
var hash;
- $("#sortable").sortable({
+ $( "#sortable" ).sortable( {
change: function( e, ui ) {
hash = ui;
}
- }).find("li:eq(0)").simulate( "drag", {
+ } ).find( "li:eq(0)" ).simulate( "drag", {
dx: 1,
dy: 1
- });
+ } );
- ok(!hash, "1px drag, change event should not be triggered");
+ ok( !hash, "1px drag, change event should not be triggered" );
- $("#sortable").sortable({
+ $( "#sortable" ).sortable( {
change: function( e, ui ) {
hash = ui;
}
- }).find("li:eq(0)").simulate( "drag", {
+ } ).find( "li:eq(0)" ).simulate( "drag", {
dy: 22
- });
+ } );
- ok(hash, "change event triggered");
- ok(hash.helper, "UI hash includes: helper");
- ok(hash.placeholder, "UI hash includes: placeholder");
- ok(hash.position && ("top" in hash.position && "left" in hash.position), "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");
+ ok( hash, "change event triggered" );
+ ok( hash.helper, "UI hash includes: helper" );
+ ok( hash.placeholder, "UI hash includes: placeholder" );
+ ok( hash.position && ( "top" in hash.position && "left" in hash.position ), "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() {
+test( "beforeStop", function() {
expect( 7 );
var hash;
- $("#sortable").sortable({
+ $( "#sortable" ).sortable( {
beforeStop: function( e, ui ) {
hash = ui;
}
- }).find("li:eq(0)").simulate( "drag", {
+ } ).find( "li:eq(0)" ).simulate( "drag", {
dy: 20
- });
+ } );
- ok(hash, "beforeStop event triggered");
- ok(hash.helper, "UI hash includes: helper");
- ok(hash.placeholder, "UI hash includes: placeholder");
- ok(hash.position && ("top" in hash.position && "left" in hash.position), "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");
+ ok( hash, "beforeStop event triggered" );
+ ok( hash.helper, "UI hash includes: helper" );
+ ok( hash.placeholder, "UI hash includes: placeholder" );
+ ok( hash.position && ( "top" in hash.position && "left" in hash.position ), "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() {
+test( "stop", function() {
expect( 7 );
var hash;
- $("#sortable").sortable({
+ $( "#sortable" ).sortable( {
stop: function( e, ui ) {
hash = ui;
}
- }).find("li:eq(0)").simulate( "drag", {
+ } ).find( "li:eq(0)" ).simulate( "drag", {
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 && ("top" in hash.position && "left" in hash.position), "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");
+ ok( hash, "stop event triggered" );
+ ok( !hash.helper, "UI should not include: helper" );
+ ok( hash.placeholder, "UI hash includes: placeholder" );
+ ok( hash.position && ( "top" in hash.position && "left" in hash.position ), "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() {
+test( "update", function() {
expect( 8 );
var hash;
- $("#sortable").sortable({
+ $( "#sortable" ).sortable( {
update: function( e, ui ) {
hash = ui;
}
- }).find("li:eq(0)").simulate( "drag", {
+ } ).find( "li:eq(0)" ).simulate( "drag", {
dx: 1,
dy: 1
- });
+ } );
- ok(!hash, "1px drag, update event should not be triggered");
+ ok( !hash, "1px drag, update event should not be triggered" );
- $("#sortable").sortable({
+ $( "#sortable" ).sortable( {
update: function( e, ui ) {
hash = ui;
}
- }).find("li:eq(0)").simulate( "drag", {
+ } ).find( "li:eq(0)" ).simulate( "drag", {
dy: 22
- });
+ } );
- ok(hash, "update event triggered");
- ok(!hash.helper, "UI hash should not include: helper");
- ok(hash.placeholder, "UI hash includes: placeholder");
- ok(hash.position && ("top" in hash.position && "left" in hash.position), "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");
+ ok( hash, "update event triggered" );
+ ok( !hash.helper, "UI hash should not include: helper" );
+ ok( hash.placeholder, "UI hash includes: placeholder" );
+ ok( hash.position && ( "top" in hash.position && "left" in hash.position ), "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("#3019: Stop fires too early", function() {
- expect(2);
+test( "#3019: Stop fires too early", function() {
+ expect( 2 );
var helper = null,
- el = $("#sortable").sortable({
- stop: function(event, ui) {
+ el = $( "#sortable" ).sortable( {
+ stop: function( event, ui ) {
helper = ui.helper;
}
- });
+ } );
- testHelper.sort($("li", el)[0], 0, 44, 2, "Dragging the sortable");
- equal(helper, null, "helper should be false");
+ testHelper.sort( $( "li", el )[ 0 ], 0, 44, 2, "Dragging the sortable" );
+ equal( helper, null, "helper should be false" );
-});
+} );
-test("#4752: link event firing on sortable with connect list", function () {
+test( "#4752: link event firing on sortable with connect list", function() {
expect( 10 );
var fired = {},
- hasFired = function (type) { return (type in fired) && (true === fired[type]); };
+ hasFired = function( type ) { return ( type in fired ) && ( true === fired[ type ] ); };
- $("#sortable").clone().attr("id", "sortable2").insertAfter("#sortable");
+ $( "#sortable" ).clone().attr( "id", "sortable2" ).insertAfter( "#sortable" );
- $("#qunit-fixture ul").sortable({
+ $( "#qunit-fixture ul" ).sortable( {
connectWith: "#qunit-fixture ul",
- change: function () {
+ change: function() {
fired.change = true;
},
- receive: function () {
+ receive: function() {
fired.receive = true;
},
- remove: function () {
+ remove: function() {
fired.remove = true;
}
- });
+ } );
- $("#qunit-fixture ul").on("click.ui-sortable-test", function () {
+ $( "#qunit-fixture ul" ).on( "click.ui-sortable-test", function() {
fired.click = true;
- });
+ } );
- $("#sortable li:eq(0)").simulate("click");
- ok(!hasFired("change"), "Click only, change event should not have fired");
- ok(hasFired("click"), "Click event should have fired");
+ $( "#sortable li:eq(0)" ).simulate( "click" );
+ ok( !hasFired( "change" ), "Click only, change event should not have fired" );
+ ok( hasFired( "click" ), "Click event should have fired" );
// Drag an item within the first list
fired = {};
- $("#sortable li:eq(0)").simulate("drag", { dx: 0, dy: 40 });
- ok(hasFired("change"), "40px drag, change event should have fired");
- ok(!hasFired("receive"), "Receive event should not have fired");
- ok(!hasFired("remove"), "Remove event should not have fired");
- ok(!hasFired("click"), "Click event should not have fired");
+ $( "#sortable li:eq(0)" ).simulate( "drag", { dx: 0, dy: 40 } );
+ ok( hasFired( "change" ), "40px drag, change event should have fired" );
+ ok( !hasFired( "receive" ), "Receive event should not have fired" );
+ ok( !hasFired( "remove" ), "Remove event should not have fired" );
+ ok( !hasFired( "click" ), "Click event should not have fired" );
// Drag an item from the first list to the second, connected list
fired = {};
- $("#sortable li:eq(0)").simulate("drag", { dx: 0, dy: 150 });
- ok(hasFired("change"), "150px drag, change event should have fired");
- ok(hasFired("receive"), "Receive event should have fired");
- ok(hasFired("remove"), "Remove event should have fired");
- ok(!hasFired("click"), "Click event should not have fired");
-});
+ $( "#sortable li:eq(0)" ).simulate( "drag", { dx: 0, dy: 150 } );
+ ok( hasFired( "change" ), "150px drag, change event should have fired" );
+ ok( hasFired( "receive" ), "Receive event should have fired" );
+ ok( hasFired( "remove" ), "Remove event should have fired" );
+ ok( !hasFired( "click" ), "Click event should not have fired" );
+} );
/*
test("receive", function() {
@@ -239,14 +239,14 @@ test( "over", function() {
var hash,
overCount = 0;
- $( "#sortable" ).sortable({
+ $( "#sortable" ).sortable( {
over: function( e, ui ) {
hash = ui;
overCount++;
}
- }).find( "li:eq(0)" ).simulate( "drag", {
+ } ).find( "li:eq(0)" ).simulate( "drag", {
dy: 20
- });
+ } );
ok( hash, "over event triggered" );
ok( hash.helper, "UI includes: helper" );
@@ -256,7 +256,7 @@ test( "over", function() {
ok( hash.item, "UI hash includes: item" );
ok( hash.sender, "UI hash includes: sender" );
equal( overCount, 1, "over fires only once" );
-});
+} );
// http://bugs.jqueryui.com/ticket/9335
// Sortable: over & out events does not consistently fire
@@ -267,25 +267,25 @@ test( "over, fires with draggable connected to sortable", function() {
overCount = 0,
item = $( "<div></div>" ).text( "6" ).insertAfter( "#sortable" );
- item.draggable({
+ item.draggable( {
connectToSortable: "#sortable"
- });
- $( ".connectWith" ).sortable({
+ } );
+ $( ".connectWith" ).sortable( {
connectWith: ".connectWith",
over: function( event, ui ) {
hash = ui;
overCount++;
}
- });
+ } );
item.simulate( "drag", {
dy: -20
- });
+ } );
ok( hash, "over event triggered" );
ok( !hash.sender, "UI should not include: sender" );
equal( overCount, 1, "over fires only once" );
-});
+} );
test( "over, with connected sortable", function() {
expect( 3 );
@@ -293,21 +293,21 @@ test( "over, with connected sortable", function() {
var hash,
overCount = 0;
- $( ".connectWith" ).sortable({
+ $( ".connectWith" ).sortable( {
connectWith: ".connectWith"
- });
+ } );
$( "#sortable2" ).on( "sortover", function( event, ui ) {
hash = ui;
overCount++;
- });
+ } );
$( "#sortable" ).find( "li:eq(0)" ).simulate( "drag", {
dy: 102
- });
+ } );
ok( hash, "over event triggered" );
- equal( hash.sender[ 0 ], $(" #sortable" )[ 0 ], "UI includes: sender" );
+ equal( hash.sender[ 0 ], $( " #sortable" )[ 0 ], "UI includes: sender" );
equal( overCount, 1, "over fires only once" );
-});
+} );
/*
test("out", function() {
@@ -321,20 +321,20 @@ test( "out, with connected sortable", function() {
var hash,
outCount = 0;
- $( ".connectWith" ).sortable({
+ $( ".connectWith" ).sortable( {
connectWith: ".connectWith"
- });
+ } );
$( "#sortable" ).on( "sortout", function( event, ui ) {
hash = ui;
outCount++;
- });
+ } );
$( "#sortable" ).find( "li:last" ).simulate( "drag", {
dy: 40
- });
+ } );
ok( hash, "out event triggered" );
equal( outCount, 1, "out fires only once" );
-});
+} );
test( "repeated out & over between connected sortables", function() {
expect( 2 );
@@ -342,28 +342,29 @@ test( "repeated out & over between connected sortables", function() {
var outCount = 0,
overCount = 0;
- $( ".connectWith" ).sortable({
+ $( ".connectWith" ).sortable( {
connectWith: ".connectWith",
over: function() {
overCount++;
},
out: function( event, ui ) {
+
// Ignore events that trigger when an item has dropped
// checking for the presence of the helper.
if ( !ui.helper ) {
outCount++;
}
}
- });
+ } );
$( "#sortable" ).find( "li:last" ).simulate( "drag", {
dy: 40
- }).simulate( "drag", {
+ } ).simulate( "drag", {
dy: -40
- });
+ } );
equal( outCount, 2, "out fires twice" );
equal( overCount, 4, "over fires four times" );
-});
+} );
/*
test("activate", function() {
diff --git a/tests/unit/sortable/helper.js b/tests/unit/sortable/helper.js
index 76545022e..c1c0b6e74 100644
--- a/tests/unit/sortable/helper.js
+++ b/tests/unit/sortable/helper.js
@@ -8,7 +8,7 @@ return $.extend( helper, {
$( handle ).simulate( "drag", {
dx: dx,
dy: dy
- });
+ } );
equal( $( handle ).parent().children().index( handle ), index, msg );
}
} );
diff --git a/tests/unit/sortable/methods.js b/tests/unit/sortable/methods.js
index f58ac052d..1d2fda8ff 100644
--- a/tests/unit/sortable/methods.js
+++ b/tests/unit/sortable/methods.js
@@ -4,72 +4,72 @@ define( [
"ui/widgets/sortable"
], function( $, testHelper ) {
-module("sortable: methods");
+module( "sortable: methods" );
-test("init", function() {
- expect(5);
+test( "init", function() {
+ expect( 5 );
- $("<div></div>").appendTo("body").sortable().remove();
- ok(true, ".sortable() called on element");
+ $( "<div></div>" ).appendTo( "body" ).sortable().remove();
+ ok( true, ".sortable() called on element" );
- $([]).sortable();
- ok(true, ".sortable() called on empty collection");
+ $( [] ).sortable();
+ ok( true, ".sortable() called on empty collection" );
- $("<div></div>").sortable();
- ok(true, ".sortable() called on disconnected DOMElement");
+ $( "<div></div>" ).sortable();
+ ok( true, ".sortable() called on disconnected DOMElement" );
- $("<div></div>").sortable().sortable("option", "foo");
- ok(true, "arbitrary option getter after init");
+ $( "<div></div>" ).sortable().sortable( "option", "foo" );
+ ok( true, "arbitrary option getter after init" );
- $("<div></div>").sortable().sortable("option", "foo", "bar");
- ok(true, "arbitrary option setter after init");
-});
+ $( "<div></div>" ).sortable().sortable( "option", "foo", "bar" );
+ ok( true, "arbitrary option setter after init" );
+} );
-test("destroy", function() {
- expect(4);
- $("<div></div>").appendTo("body").sortable().sortable("destroy").remove();
- ok(true, ".sortable('destroy') called on element");
+test( "destroy", function() {
+ expect( 4 );
+ $( "<div></div>" ).appendTo( "body" ).sortable().sortable( "destroy" ).remove();
+ ok( true, ".sortable('destroy') called on element" );
- $([]).sortable().sortable("destroy");
- ok(true, ".sortable('destroy') called on empty collection");
+ $( [] ).sortable().sortable( "destroy" );
+ ok( true, ".sortable('destroy') called on empty collection" );
- $("<div></div>").sortable().sortable("destroy");
- ok(true, ".sortable('destroy') called on disconnected DOMElement");
+ $( "<div></div>" ).sortable().sortable( "destroy" );
+ ok( true, ".sortable('destroy') called on disconnected DOMElement" );
- var expected = $("<div></div>").sortable(),
- actual = expected.sortable("destroy");
- equal(actual, expected, "destroy is chainable");
-});
+ var expected = $( "<div></div>" ).sortable(),
+ actual = expected.sortable( "destroy" );
+ equal( actual, expected, "destroy is chainable" );
+} );
-test("enable", function() {
- expect(5);
+test( "enable", function() {
+ expect( 5 );
var el, actual, expected;
- el = $("#sortable").sortable({ disabled: true });
+ el = $( "#sortable" ).sortable( { disabled: true } );
- testHelper.sort($("li", el)[0], 0, 44, 0, ".sortable({ disabled: true })");
+ testHelper.sort( $( "li", el )[ 0 ], 0, 44, 0, ".sortable({ disabled: true })" );
- el.sortable("enable");
- equal(el.sortable("option", "disabled"), false, "disabled option getter");
+ el.sortable( "enable" );
+ equal( el.sortable( "option", "disabled" ), false, "disabled option getter" );
- el.sortable("destroy");
- el.sortable({ disabled: true });
- el.sortable("option", "disabled", false);
- equal(el.sortable("option", "disabled"), false, "disabled option setter");
+ el.sortable( "destroy" );
+ el.sortable( { disabled: true } );
+ el.sortable( "option", "disabled", false );
+ equal( el.sortable( "option", "disabled" ), false, "disabled option setter" );
- testHelper.sort($("li", el)[0], 0, 44, 2, ".sortable('option', 'disabled', false)");
+ testHelper.sort( $( "li", el )[ 0 ], 0, 44, 2, ".sortable('option', 'disabled', false)" );
- expected = $("<div></div>").sortable(),
- actual = expected.sortable("enable");
- equal(actual, expected, "enable is chainable");
-});
+ expected = $( "<div></div>" ).sortable(),
+ actual = expected.sortable( "enable" );
+ equal( actual, expected, "enable is chainable" );
+} );
test( "disable", function( assert ) {
expect( 9 );
var chainable,
- element = $( "#sortable" ).sortable({ disabled: false });
+ element = $( "#sortable" ).sortable( { disabled: false } );
testHelper.sort( $( "li", element )[ 0 ], 0, 44, 2, ".sortable({ disabled: false })" );
@@ -78,18 +78,18 @@ test( "disable", function( assert ) {
element.sortable( "destroy" );
- element.sortable({ disabled: false });
+ element.sortable( { disabled: false } );
testHelper.sort( $( "li", element )[ 0 ], 0, 44, 2, ".sortable({ disabled: false })" );
- element.sortable( "option", "disabled", true);
+ element.sortable( "option", "disabled", true );
equal( element.sortable( "option", "disabled" ), true, "disabled option setter" );
assert.lacksClasses( element.sortable( "widget" ), "ui-state-disabled" );
ok( !element.sortable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" );
assert.hasClasses( element.sortable( "widget" ), "ui-sortable-disabled" );
- testHelper.sort($( "li", element )[ 0 ], 0, 44, 0, ".sortable('option', 'disabled', true)" );
+ testHelper.sort( $( "li", element )[ 0 ], 0, 44, 0, ".sortable('option', 'disabled', true)" );
equal( chainable, element, "disable is chainable" );
-});
+} );
test( "refresh() should update the positions of initially empty lists (see #7498)", function() {
expect( 1 );
@@ -98,22 +98,22 @@ test( "refresh() should update the positions of initially empty lists (see #7498
element = $( "#qunit-fixture" ).html( "<ul></ul>" ).find( "ul" );
element
- .css({
+ .css( {
"float": "left",
width: "100px"
- })
- .sortable({
+ } )
+ .sortable( {
change: function() {
changeCount++;
}
- })
+ } )
.append( "<li>a</li><li>a</li>" )
.find( "li" )
- .css({
+ .css( {
"float": "left",
width: "50px",
height: "50px"
- });
+ } );
element.sortable( "refresh" );
@@ -121,9 +121,9 @@ test( "refresh() should update the positions of initially empty lists (see #7498
element.find( "li" ).eq( 0 ).simulate( "drag", {
dx: 55,
moves: 15
- });
+ } );
equal( changeCount, 1 );
-});
+} );
} );
diff --git a/tests/unit/sortable/options.js b/tests/unit/sortable/options.js
index 744839096..cdb932af3 100644
--- a/tests/unit/sortable/options.js
+++ b/tests/unit/sortable/options.js
@@ -3,7 +3,7 @@ define( [
"ui/widgets/sortable"
], function( $ ) {
-module("sortable: options");
+module( "sortable: options" );
/*
test("{ appendTo: 'parent' }, default", function() {
@@ -19,14 +19,14 @@ test( "{ axis: false }, default", function() {
expect( 2 );
var offsetAfter,
- element = $( "#sortable" ).sortable({
+ element = $( "#sortable" ).sortable( {
axis: false,
change: function() {
offsetAfter = item.offset();
notEqual( offsetAfter.left, offsetBefore.left, "x axis not constrained when axis: false" );
notEqual( offsetAfter.top, offsetBefore.top, "y axis not constrained when axis: false" );
}
- }),
+ } ),
item = element.find( "li" ).eq( 0 ),
offsetBefore = item.offset();
@@ -34,21 +34,21 @@ test( "{ axis: false }, default", function() {
dx: 50,
dy: 25,
moves: 1
- });
-});
+ } );
+} );
test( "{ axis: 'x' }", function() {
expect( 2 );
var offsetAfter,
- element = $( "#sortable" ).sortable({
+ element = $( "#sortable" ).sortable( {
axis: "x",
change: function() {
offsetAfter = item.offset();
notEqual( offsetAfter.left, offsetBefore.left, "x axis not constrained when axis: x" );
equal( offsetAfter.top, offsetBefore.top, "y axis constrained when axis: x" );
}
- }),
+ } ),
item = element.find( "li" ).eq( 0 ),
offsetBefore = item.offset();
@@ -56,21 +56,21 @@ test( "{ axis: 'x' }", function() {
dx: 50,
dy: 25,
moves: 1
- });
-});
+ } );
+} );
test( "{ axis: 'y' }", function() {
expect( 2 );
var offsetAfter,
- element = $( "#sortable" ).sortable({
+ element = $( "#sortable" ).sortable( {
axis: "y",
change: function() {
offsetAfter = item.offset();
equal( offsetAfter.left, offsetBefore.left, "x axis constrained when axis: y" );
notEqual( offsetAfter.top, offsetBefore.top, "y axis not constrained when axis: y" );
}
- }),
+ } ),
item = element.find( "li" ).eq( 0 ),
offsetBefore = item.offset();
@@ -78,33 +78,33 @@ test( "{ axis: 'y' }", function() {
dx: 50,
dy: 25,
moves: 1
- });
-});
+ } );
+} );
asyncTest( "#7415: Incorrect revert animation with axis: 'y'", function() {
expect( 2 );
var expectedLeft,
- element = $( "#sortable" ).sortable({
+ element = $( "#sortable" ).sortable( {
axis: "y",
revert: true,
stop: start,
sort: function() {
expectedLeft = item.css( "left" );
}
- }),
+ } ),
item = element.find( "li" ).eq( 0 );
item.simulate( "drag", {
dy: 300,
dx: 50
- });
+ } );
- setTimeout(function() {
+ setTimeout( function() {
var top = parseFloat( item.css( "top" ) );
equal( item.css( "left" ), expectedLeft, "left not animated" );
ok( top > 0 && top < 300, "top is animated" );
}, 100 );
-});
+} );
/*
test("{ cancel: 'input,textarea,button,select,option' }, default", function() {
@@ -124,62 +124,62 @@ test( "#8792: issues with floated items in connected lists", function() {
$( "#qunit-fixture" )
.html( "<ul class='c'><li>a</li><li>a</li></ul><ul class='c'><li>a</li><li>a</li></ul>" )
- .find( "ul" ).css({ "float": "left", width: "100px" }).end()
- .find( "li" ).css({ "float": "left", width: "50px", height: "50px" });
+ .find( "ul" ).css( { "float": "left", width: "100px" } ).end()
+ .find( "li" ).css( { "float": "left", width: "50px", height: "50px" } );
- $( "#qunit-fixture .c" ).sortable({
+ $( "#qunit-fixture .c" ).sortable( {
connectWith: "#qunit-fixture .c",
change: function() {
changeCount++;
}
- });
+ } );
element = $( "#qunit-fixture li:eq(0)" );
- // move the first li to the right of the second li in the first ul
+ // Move the first li to the right of the second li in the first ul
element.simulate( "drag", {
dx: 55,
moves: 15
- });
+ } );
equal( changeCount, 1, "change fired only once (no jitters) when dragging a floated sortable in it's own container" );
- // move the first li ( which is now in the second spot )
+ // Move the first li ( which is now in the second spot )
// through the first spot in the second ul to the second spot in the second ul
element.simulate( "drag", {
dx: 100,
moves: 15
- });
+ } );
equal( changeCount, 3, "change fired once for each expected change when dragging a floated sortable to a connected container" );
-});
+} );
test( "#8301: single axis with connected list", function() {
expect( 1 );
- var element = $( "#sortable" ).sortable({
+ var element = $( "#sortable" ).sortable( {
axis: "y",
tolerance: "pointer",
connectWith: ".connected"
- });
+ } );
$( "<ul class='connected'><li>Item 7</li><li>Item 8</li></ul>" )
- .sortable({
+ .sortable( {
axis: "y",
tolerance: "pointer",
connectWith: "#sortable",
receive: function() {
ok( true, "connected list received item" );
}
- })
+ } )
.insertAfter( element );
element.find( "li" ).eq( 0 ).simulate( "drag", {
handle: "corner",
dy: 120,
moves: 1
- });
-});
+ } );
+} );
/*
test("{ connectWith: false }, default", function() {
@@ -330,44 +330,44 @@ test("{ placeholder: false }, default", function() {
test( "{ placeholder: false } img", function() {
expect( 3 );
- var element = $( "#sortable-images" ).sortable({
+ var element = $( "#sortable-images" ).sortable( {
start: function( event, ui ) {
ok( ui.placeholder.attr( "src" ).indexOf( "images/jqueryui_32x32.png" ) > 0, "placeholder img has correct src" );
equal( ui.placeholder.height(), 32, "placeholder has correct height" );
equal( ui.placeholder.width(), 32, "placeholder has correct width" );
}
- });
+ } );
element.find( "img" ).eq( 0 ).simulate( "drag", {
dy: 1
- });
-});
+ } );
+} );
test( "{ placeholder: String }", function( assert ) {
expect( 1 );
- var element = $( "#sortable" ).sortable({
+ var element = $( "#sortable" ).sortable( {
placeholder: "test",
start: function( event, ui ) {
assert.hasClasses( ui.placeholder, "test" );
}
- });
+ } );
element.find( "li" ).eq( 0 ).simulate( "drag", {
dy: 1
- });
-});
+ } );
+} );
test( "{ placholder: String } tr", function( assert ) {
expect( 4 );
var originalWidths,
- element = $( "#sortable-table tbody" ).sortable({
+ element = $( "#sortable-table tbody" ).sortable( {
placeholder: "test",
start: function( event, ui ) {
- var currentWidths = otherRow.children().map(function() {
+ var currentWidths = otherRow.children().map( function() {
return $( this ).width();
- }).get();
+ } ).get();
assert.hasClasses( ui.placeholder, "test" );
deepEqual( currentWidths, originalWidths, "table cells maintian size" );
equal( ui.placeholder.children().length, dragRow.children().length,
@@ -375,29 +375,29 @@ test( "{ placholder: String } tr", function( assert ) {
equal( ui.placeholder.children().html(), $( "<span>&#160;</span>" ).html(),
"placeholder td has content for forced dimensions" );
}
- }),
+ } ),
rows = element.children( "tr" ),
dragRow = rows.eq( 0 ),
otherRow = rows.eq( 1 );
- originalWidths = otherRow.children().map(function() {
+ originalWidths = otherRow.children().map( function() {
return $( this ).width();
- }).get();
+ } ).get();
dragRow.simulate( "drag", {
dy: 1
- });
-});
+ } );
+} );
test( "{ placholder: String } tbody", function() {
expect( 6 );
var originalWidths,
- element = $( "#sortable-table" ).sortable({
+ element = $( "#sortable-table" ).sortable( {
placeholder: "test",
start: function( event, ui ) {
- var currentWidths = otherBody.children().map(function() {
+ var currentWidths = otherBody.children().map( function() {
return $( this ).width();
- }).get();
+ } ).get();
ok( ui.placeholder.hasClass( "test" ), "placeholder has class" );
deepEqual( currentWidths, originalWidths, "table cells maintain size" );
equal( ui.placeholder.children().length, 1,
@@ -411,18 +411,18 @@ test( "{ placholder: String } tbody", function() {
$( "<span>&#160;</span>" ).html(),
"placeholder td has content for forced dimensions" );
}
- }),
+ } ),
bodies = element.children( "tbody" ),
dragBody = bodies.eq( 0 ),
otherBody = bodies.eq( 1 );
- originalWidths = otherBody.children().map(function() {
+ originalWidths = otherBody.children().map( function() {
return $( this ).width();
- }).get();
+ } ).get();
dragBody.simulate( "drag", {
dy: 1
- });
-});
+ } );
+} );
/*
test("{ revert: false }, default", function() {
diff --git a/tests/unit/spinner/common-deprecated.js b/tests/unit/spinner/common-deprecated.js
index 8ff50fa25..9ffc473af 100644
--- a/tests/unit/spinner/common-deprecated.js
+++ b/tests/unit/spinner/common-deprecated.js
@@ -23,13 +23,13 @@ common.testWidget( "spinner", {
page: 10,
step: 1,
- // callbacks
+ // Callbacks
change: null,
create: null,
spin: null,
start: null,
stop: null
}
-});
+} );
} );
diff --git a/tests/unit/spinner/common.js b/tests/unit/spinner/common.js
index 8ff50fa25..9ffc473af 100644
--- a/tests/unit/spinner/common.js
+++ b/tests/unit/spinner/common.js
@@ -23,13 +23,13 @@ common.testWidget( "spinner", {
page: 10,
step: 1,
- // callbacks
+ // Callbacks
change: null,
create: null,
spin: null,
start: null,
stop: null
}
-});
+} );
} );
diff --git a/tests/unit/spinner/core.js b/tests/unit/spinner/core.js
index 64824e128..23df35da4 100644
--- a/tests/unit/spinner/core.js
+++ b/tests/unit/spinner/core.js
@@ -21,14 +21,14 @@ test( "markup structure", function( assert ) {
equal( up.length, 1, "Spinner contains exactly one up button" );
assert.hasClasses( down, "ui-spinner-button ui-spinner-down ui-widget" );
equal( down.length, 1, "Spinner contains exactly one down button" );
-});
+} );
test( "keydown UP on input, increases value not greater than max", function() {
expect( 5 );
- var element = $( "#spin" ).val( 70 ).spinner({
+ var element = $( "#spin" ).val( 70 ).spinner( {
max: 100,
step: 10
- });
+ } );
simulateKeyDownUp( element, $.ui.keyCode.UP );
equal( element.val(), 80 );
@@ -40,14 +40,14 @@ test( "keydown UP on input, increases value not greater than max", function() {
equal( element.val(), 100 );
simulateKeyDownUp( element, $.ui.keyCode.UP );
equal( element.val(), 100 );
-});
+} );
test( "keydown DOWN on input, decreases value not less than min", function() {
expect( 5 );
- var element = $( "#spin" ).val( 50 ).spinner({
+ var element = $( "#spin" ).val( 50 ).spinner( {
min: 20,
step: 10
- });
+ } );
simulateKeyDownUp( element, $.ui.keyCode.DOWN );
equal( element.val(), 40 );
@@ -59,14 +59,14 @@ test( "keydown DOWN on input, decreases value not less than min", function() {
equal( element.val(), 20 );
simulateKeyDownUp( element, $.ui.keyCode.DOWN );
equal( element.val(), 20 );
-});
+} );
test( "keydown PAGE_UP on input, increases value not greater than max", function() {
expect( 5 );
- var element = $( "#spin" ).val( 70 ).spinner({
+ var element = $( "#spin" ).val( 70 ).spinner( {
max: 100,
page: 10
- });
+ } );
simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
equal( element.val(), 80 );
@@ -78,14 +78,14 @@ test( "keydown PAGE_UP on input, increases value not greater than max", function
equal( element.val(), 100 );
simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
equal( element.val(), 100 );
-});
+} );
test( "keydown PAGE_DOWN on input, decreases value not less than min", function() {
expect( 5 );
- var element = $( "#spin" ).val( 50 ).spinner({
+ var element = $( "#spin" ).val( 50 ).spinner( {
min: 20,
page: 10
- });
+ } );
simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
equal( element.val(), 40 );
@@ -97,7 +97,7 @@ test( "keydown PAGE_DOWN on input, decreases value not less than min", function(
equal( element.val(), 20 );
simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
equal( element.val(), 20 );
-});
+} );
asyncTest( "blur input while spinning with UP", function() {
expect( 3 );
@@ -117,7 +117,7 @@ asyncTest( "blur input while spinning with UP", function() {
element.on( "blur", function() {
value = element.val();
setTimeout( step3, 750 );
- })[ 0 ].blur();
+ } )[ 0 ].blur();
}
function step3() {
@@ -127,13 +127,13 @@ asyncTest( "blur input while spinning with UP", function() {
element[ 0 ].focus();
setTimeout( step1 );
-});
+} );
test( "mouse click on up button, increases value not greater than max", function() {
expect( 3 );
- var element = $( "#spin" ).val( 18 ).spinner({
+ var element = $( "#spin" ).val( 18 ).spinner( {
max: 20
- }),
+ } ),
button = element.spinner( "widget" ).find( ".ui-spinner-up" );
button.trigger( "mousedown" ).trigger( "mouseup" );
@@ -142,13 +142,13 @@ test( "mouse click on up button, increases value not greater than max", function
equal( element.val(), 20 );
button.trigger( "mousedown" ).trigger( "mouseup" );
equal( element.val(), 20 );
-});
+} );
test( "mouse click on up button, increases value not greater than max", function() {
expect( 3 );
- var element = $( "#spin" ).val( 2 ).spinner({
+ var element = $( "#spin" ).val( 2 ).spinner( {
min: 0
- }),
+ } ),
button = element.spinner( "widget" ).find( ".ui-spinner-down" );
button.trigger( "mousedown" ).trigger( "mouseup" );
@@ -157,14 +157,14 @@ test( "mouse click on up button, increases value not greater than max", function
equal( element.val(), 0 );
button.trigger( "mousedown" ).trigger( "mouseup" );
equal( element.val(), 0 );
-});
+} );
test( "mousewheel on input", function() {
expect( 4 );
- var element = $( "#spin" ).val( 0 ).spinner({
+ var element = $( "#spin" ).val( 0 ).spinner( {
step: 2
- });
+ } );
element.trigger( "mousewheel" );
equal( element.val(), 0, "mousewheel event without delta does not change value" );
@@ -176,8 +176,8 @@ test( "mousewheel on input", function() {
equal( element.val(), 0 );
element.trigger( "mousewheel", -15 );
- equal(element.val(), -2 );
-});
+ equal( element.val(), -2 );
+} );
test( "reading HTML5 attributes", function() {
expect( 6 );
@@ -187,19 +187,19 @@ test( "reading HTML5 attributes", function() {
equal( element.spinner( "option", "max" ), 100, "max from markup" );
equal( element.spinner( "option", "step" ), 2, "step from markup" );
- element = $( markup ).spinner({
+ element = $( markup ).spinner( {
min: -200,
max: 200,
step: 5
- });
+ } );
equal( element.spinner( "option", "min" ), -200, "min from options" );
equal( element.spinner( "option", "max" ), 200, "max from options" );
equal( element.spinner( "option", "step" ), 5, "stop from options" );
-});
+} );
test( "ARIA attributes", function() {
expect( 9 );
- var element = $( "#spin" ).val( 2 ).spinner({ min: -5, max: 5 });
+ var element = $( "#spin" ).val( 2 ).spinner( { min: -5, max: 5 } );
equal( element.attr( "role" ), "spinbutton", "role" );
equal( element.attr( "aria-valuemin" ), "-5", "aria-valuemin" );
@@ -220,7 +220,7 @@ test( "ARIA attributes", function() {
element.spinner( "option", "max", null );
equal( element.attr( "aria-valuemax" ), undefined, "aria-valuemax not set when no max" );
-});
+} );
test( "focus text field when pressing button", function() {
expect( 2 );
@@ -229,29 +229,29 @@ test( "focus text field when pressing button", function() {
ok( element[ 0 ] !== document.activeElement, "not focused before" );
element.spinner( "widget" ).find( ".ui-spinner-up" ).trigger( "mousedown" );
ok( element[ 0 ] === document.activeElement, "focused after" );
-});
+} );
test( "don't clear invalid value on blur", function() {
expect( 1 );
var element = $( "#spin" ).spinner();
element.trigger( "focus" ).val( "a" ).trigger( "blur" );
equal( element.val(), "a" );
-});
+} );
test( "precision", function() {
expect( 2 );
- var element = $( "#spin" ).val( 0.05 ).spinner({
+ var element = $( "#spin" ).val( 0.05 ).spinner( {
step: 0.0001
- });
+ } );
element.spinner( "stepUp" );
equal( element.val(), "0.0501", "precision from step" );
element.val( 1.05 ).spinner( "option", {
step: 1,
min: -9.95
- });
+ } );
element.spinner( "stepDown" );
equal( element.val(), "0.05", "precision from min" );
-});
+} );
} );
diff --git a/tests/unit/spinner/events.js b/tests/unit/spinner/events.js
index 8fa409b99..7f88d063a 100644
--- a/tests/unit/spinner/events.js
+++ b/tests/unit/spinner/events.js
@@ -15,7 +15,7 @@ test( "start", function() {
function shouldStart( expectation, msg ) {
element.spinner( "option", "start", function() {
ok( expectation, msg );
- });
+ } );
}
shouldStart( true, "key UP" );
@@ -45,7 +45,7 @@ test( "start", function() {
shouldStart( false, "value" );
element.spinner( "value", 999 );
-});
+} );
test( "spin", function() {
expect( 10 );
@@ -54,7 +54,7 @@ test( "spin", function() {
function shouldSpin( expectation, msg ) {
element.spinner( "option", "spin", function() {
ok( expectation, msg );
- });
+ } );
}
shouldSpin( true, "key UP" );
@@ -84,7 +84,7 @@ test( "spin", function() {
shouldSpin( false, "value" );
element.spinner( "value", 999 );
-});
+} );
test( "stop", function() {
expect( 10 );
@@ -93,7 +93,7 @@ test( "stop", function() {
function shouldStop( expectation, msg ) {
element.spinner( "option", "stop", function() {
ok( expectation, msg );
- });
+ } );
}
shouldStop( true, "key UP" );
@@ -123,7 +123,7 @@ test( "stop", function() {
shouldStop( false, "value" );
element.spinner( "value", 999 );
-});
+} );
asyncTest( "change", function() {
expect( 12 );
@@ -132,22 +132,22 @@ asyncTest( "change", function() {
function shouldChange( expectation, msg ) {
element.spinner( "option", "change", function() {
ok( expectation, msg );
- });
+ } );
}
function focusWrap( fn, next ) {
- element[0].focus();
+ element[ 0 ].focus();
setTimeout( function() {
fn();
- setTimeout(function() {
- element[0].blur();
+ setTimeout( function() {
+ element[ 0 ].blur();
setTimeout( next );
- });
- });
+ } );
+ } );
}
function step1() {
- focusWrap(function() {
+ focusWrap( function() {
shouldChange( false, "key UP, before blur" );
simulateKeyDownUp( element, $.ui.keyCode.UP );
shouldChange( true, "blur after key UP" );
@@ -155,7 +155,7 @@ asyncTest( "change", function() {
}
function step2() {
- focusWrap(function() {
+ focusWrap( function() {
shouldChange( false, "key DOWN, before blur" );
simulateKeyDownUp( element, $.ui.keyCode.DOWN );
shouldChange( true, "blur after key DOWN" );
@@ -163,7 +163,7 @@ asyncTest( "change", function() {
}
function step3() {
- focusWrap(function() {
+ focusWrap( function() {
shouldChange( false, "key PAGE_UP, before blur" );
simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
shouldChange( true, "blur after key PAGE_UP" );
@@ -171,7 +171,7 @@ asyncTest( "change", function() {
}
function step4() {
- focusWrap(function() {
+ focusWrap( function() {
shouldChange( false, "key PAGE_DOWN, before blur" );
simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
shouldChange( true, "blur after key PAGE_DOWN" );
@@ -179,7 +179,7 @@ asyncTest( "change", function() {
}
function step5() {
- focusWrap(function() {
+ focusWrap( function() {
shouldChange( false, "many keys, before blur" );
simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
simulateKeyDownUp( element, $.ui.keyCode.UP );
@@ -191,7 +191,7 @@ asyncTest( "change", function() {
}
function step6() {
- focusWrap(function() {
+ focusWrap( function() {
shouldChange( false, "many keys, same final value, before blur" );
simulateKeyDownUp( element, $.ui.keyCode.UP );
simulateKeyDownUp( element, $.ui.keyCode.UP );
@@ -206,7 +206,7 @@ asyncTest( "change", function() {
}
function step7() {
- focusWrap(function() {
+ focusWrap( function() {
shouldChange( false, "button down, before blur" );
element.spinner( "widget" ).find( ".ui-spinner-down" ).trigger( "mousedown" ).trigger( "mouseup" );
shouldChange( true, "blur after button down" );
@@ -214,7 +214,7 @@ asyncTest( "change", function() {
}
function step8() {
- focusWrap(function() {
+ focusWrap( function() {
shouldChange( false, "many buttons, same final value, before blur" );
element.spinner( "widget" ).find( ".ui-spinner-up" ).trigger( "mousedown" ).trigger( "mouseup" );
element.spinner( "widget" ).find( ".ui-spinner-up" ).trigger( "mousedown" ).trigger( "mouseup" );
@@ -258,6 +258,6 @@ asyncTest( "change", function() {
}
setTimeout( step1 );
-});
+} );
} );
diff --git a/tests/unit/spinner/methods.js b/tests/unit/spinner/methods.js
index 6f165b936..3b039ff39 100644
--- a/tests/unit/spinner/methods.js
+++ b/tests/unit/spinner/methods.js
@@ -12,8 +12,8 @@ test( "destroy", function( assert ) {
expect( 1 );
assert.domEqual( "#spin", function() {
$( "#spin" ).spinner().spinner( "destroy" );
- });
-});
+ } );
+} );
test( "disable", function( assert ) {
expect( 15 );
@@ -26,7 +26,7 @@ test( "disable", function( assert ) {
element.spinner( "disable" );
assert.hasClasses( wrapper, "ui-state-disabled ui-spinner-disabled" );
ok( !wrapper.attr( "aria-disabled" ), "after: wrapper does not have aria-disabled attr" );
- ok( element.is( ":disabled"), "after: input has disabled attribute" );
+ ok( element.is( ":disabled" ), "after: input has disabled attribute" );
simulateKeyDownUp( element, $.ui.keyCode.UP );
equal( 2, element.val(), "keyboard - value does not change on key UP" );
@@ -47,7 +47,7 @@ test( "disable", function( assert ) {
equal( 2, element.val(), "mouse - value does not change on clicking down button" );
element.spinner( "stepUp", 6 );
- equal( 8, element.val(), "script - stepUp 6 steps changes value");
+ equal( 8, element.val(), "script - stepUp 6 steps changes value" );
element.spinner( "stepDown" );
equal( 7, element.val(), "script - stepDown 1 step changes value" );
@@ -57,11 +57,11 @@ test( "disable", function( assert ) {
element.spinner( "pageDown" );
equal( 7, element.val(), "script - pageDown 1 page changes value" );
-});
+} );
test( "enable", function( assert ) {
expect( 5 );
- var element = $( "#spin" ).val( 1 ).spinner({ disabled: true }),
+ var element = $( "#spin" ).val( 1 ).spinner( { disabled: true } ),
wrapper = element.spinner( "widget" );
assert.hasClasses( wrapper, "ui-spinner-disabled" );
@@ -74,15 +74,15 @@ test( "enable", function( assert ) {
simulateKeyDownUp( element, $.ui.keyCode.UP );
equal( 2, element.val(), "keyboard - value changes on key UP" );
-});
+} );
test( "isValid", function() {
expect( 8 );
- var element = $( "#spin" ).spinner({
+ var element = $( "#spin" ).spinner( {
min: 0,
max: 10,
step: 2
- }),
+ } ),
spinner = element.spinner( "instance" );
ok( !spinner.isValid(), "initial state is invalid" );
@@ -106,14 +106,14 @@ test( "isValid", function() {
element.val( "1" );
ok( !spinner.isValid(), "step mismatch is invalid" );
-});
+} );
test( "pageDown", function() {
expect( 4 );
- var element = $( "#spin" ).val( -12 ).spinner({
+ var element = $( "#spin" ).val( -12 ).spinner( {
page: 20,
min: -100
- });
+ } );
element.spinner( "pageDown" );
equal( element.val(), -32, "pageDown 1 page" );
@@ -126,14 +126,14 @@ test( "pageDown", function() {
element.spinner( "pageDown", 10 );
equal( element.val(), -100, "value at min and pageDown 10 pages" );
-});
+} );
test( "pageUp", function() {
expect( 4 );
- var element = $( "#spin" ).val( 12 ).spinner({
+ var element = $( "#spin" ).val( 12 ).spinner( {
page: 20,
max: 100
- });
+ } );
element.spinner( "pageUp" );
equal( element.val(), 32, "pageUp 1 page" );
@@ -146,14 +146,14 @@ test( "pageUp", function() {
element.spinner( "pageUp", 10 );
equal( element.val(), 100, "value at max and pageUp 10 pages" );
-});
+} );
test( "stepDown", function() {
expect( 4 );
- var element = $( "#spin" ).val( 0 ).spinner({
+ var element = $( "#spin" ).val( 0 ).spinner( {
step: 2,
min: -15
- });
+ } );
element.spinner( "stepDown" );
equal( element.val(), "-1", "stepDown 1 step" );
@@ -166,14 +166,14 @@ test( "stepDown", function() {
element.spinner( "stepDown" );
equal( element.val(), "-15", "at min and stepDown 1 step" );
-});
+} );
test( "stepUp", function() {
expect( 4 );
- var element = $( "#spin" ).val( 0 ).spinner({
+ var element = $( "#spin" ).val( 0 ).spinner( {
step: 2,
max: 16
- });
+ } );
element.spinner( "stepUp" );
equal( element.val(), 2, "stepUp 1 step" );
@@ -186,19 +186,19 @@ test( "stepUp", function() {
element.spinner( "stepUp" );
equal( element.val(), 16, "at max and stepUp 1 step" );
-});
+} );
test( "value", function() {
expect( 2 );
- var element = $( "#spin" ).val( 0 ).spinner({
+ var element = $( "#spin" ).val( 0 ).spinner( {
step: 3
- });
+ } );
element.spinner( "value", 10 );
equal( element.val(), 9, "change value via value method" );
equal( element.spinner( "value" ), 9, "get value via value method" );
-});
+} );
test( "widget", function() {
expect( 2 );
@@ -206,6 +206,6 @@ test( "widget", function() {
widgetElement = element.spinner( "widget" );
equal( widgetElement.length, 1, "one element" );
strictEqual( widgetElement[ 0 ], element.parent()[ 0 ], "parent element" );
-});
+} );
} );
diff --git a/tests/unit/spinner/options.js b/tests/unit/spinner/options.js
index 6a9d3e9b7..61d609bc7 100644
--- a/tests/unit/spinner/options.js
+++ b/tests/unit/spinner/options.js
@@ -20,43 +20,43 @@ test( "icons: default ", function( assert ) {
element.spinner( "option", "icons", {
up: "ui-icon-caret-1-n",
down: "ui-icon-caret-1-s"
- });
+ } );
assert.hasClasses( element.spinner( "widget" ).find( ".ui-icon:first" ),
"ui-icon ui-icon-caret-1-n" );
assert.hasClasses( element.spinner( "widget" ).find( ".ui-icon:last" ),
"ui-icon ui-icon-caret-1-s" );
-});
+} );
test( "icons: custom ", function( assert ) {
expect( 2 );
- var element = $( "#spin" ).val( 0 ).spinner({
+ var element = $( "#spin" ).val( 0 ).spinner( {
icons: {
down: "custom-down",
up: "custom-up"
}
- }).spinner( "widget" );
+ } ).spinner( "widget" );
assert.hasClasses( element.find( ".ui-icon:first" ), "ui-icon custom-up" );
assert.hasClasses( element.find( ".ui-icon:last" ), "ui-icon custom-down" );
-});
+} );
test( "incremental, false", function() {
expect( 100 );
var i,
prev = 0,
- element = $( "#spin" ).val( prev ).spinner({
+ element = $( "#spin" ).val( prev ).spinner( {
incremental: false,
spin: function( event, ui ) {
equal( ui.value - prev, 1 );
prev = ui.value;
}
- });
+ } );
for ( i = 0; i < 100; i++ ) {
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
}
element.simulate( "keyup", { keyCode: $.ui.keyCode.UP } );
-});
+} );
test( "incremental, true", function() {
expect( 100 );
@@ -64,7 +64,7 @@ test( "incremental, true", function() {
function fill( num, val ) {
return $.map( new Array( num ), function() {
return val;
- });
+ } );
}
var i,
@@ -72,26 +72,26 @@ test( "incremental, true", function() {
expected = [].concat( fill( 18, 1 ), fill( 37, 2 ), fill( 14, 3 ),
fill( 9, 4 ), fill( 6, 5 ), fill( 5, 6 ), fill ( 5, 7 ),
fill( 4, 8 ), fill( 2, 9 ) ),
- element = $( "#spin" ).val( prev ).spinner({
+ element = $( "#spin" ).val( prev ).spinner( {
incremental: true,
spin: function( event, ui ) {
equal( ui.value - prev, expected[ i ] );
prev = ui.value;
}
- });
+ } );
for ( i = 0; i < 100; i++ ) {
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
}
element.simulate( "keyup", { keyCode: $.ui.keyCode.UP } );
-});
+} );
test( "incremental, function", function() {
expect( 100 );
var i,
prev = 0,
- element = $( "#spin" ).val( prev ).spinner({
+ element = $( "#spin" ).val( prev ).spinner( {
incremental: function( i ) {
return i;
},
@@ -99,83 +99,83 @@ test( "incremental, function", function() {
equal( ui.value - prev, i + 1 );
prev = ui.value;
}
- });
+ } );
for ( i = 0; i < 100; i++ ) {
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
}
element.simulate( "keyup", { keyCode: $.ui.keyCode.UP } );
-});
+} );
test( "numberFormat, number", function() {
expect( 2 );
- var element = $( "#spin" ).val( 0 ).spinner({ numberFormat: "n" });
+ var element = $( "#spin" ).val( 0 ).spinner( { numberFormat: "n" } );
equal( element.val(), "0.00", "formatted on init" );
element.spinner( "stepUp" );
equal( element.val(), "1.00", "formatted after step" );
-});
+} );
test( "numberFormat, number, simple", function() {
expect( 2 );
- var element = $( "#spin" ).val( 0 ).spinner({ numberFormat: "n0" });
+ var element = $( "#spin" ).val( 0 ).spinner( { numberFormat: "n0" } );
equal( element.val(), "0", "formatted on init" );
element.spinner( "stepUp" );
equal( element.val(), "1", "formatted after step" );
-});
+} );
test( "numberFormat, currency", function() {
expect( 2 );
- var element = $( "#spin" ).val( 0 ).spinner({ numberFormat: "C" });
+ var element = $( "#spin" ).val( 0 ).spinner( { numberFormat: "C" } );
equal( element.val(), "$0.00", "formatted on init" );
element.spinner( "stepUp" );
equal( element.val(), "$1.00", "formatted after step" );
-});
+} );
test( "numberFormat, change", function() {
expect( 2 );
- var element = $( "#spin" ).val( 5 ).spinner({ numberFormat: "n1" });
+ var element = $( "#spin" ).val( 5 ).spinner( { numberFormat: "n1" } );
equal( element.val(), "5.0", "formatted on init" );
element.spinner( "option", "numberFormat", "c" );
equal( element.val(), "$5.00", "formatted after change" );
-});
+} );
test( "culture, null", function() {
expect( 2 );
Globalize.culture( "ja-JP" );
- var element = $( "#spin" ).val( 0 ).spinner({ numberFormat: "C" });
+ var element = $( "#spin" ).val( 0 ).spinner( { numberFormat: "C" } );
equal( element.val(), "¥0", "formatted on init" );
element.spinner( "stepUp" );
equal( element.val(), "¥1", "formatted after step" );
- // reset culture
+ // Reset culture
Globalize.culture( "default" );
-});
+} );
test( "currency, ja-JP", function() {
expect( 2 );
- var element = $( "#spin" ).val( 0 ).spinner({
+ var element = $( "#spin" ).val( 0 ).spinner( {
numberFormat: "C",
culture: "ja-JP"
- });
+ } );
equal( element.val(), "¥0", "formatted on init" );
element.spinner( "stepUp" );
equal( element.val(), "¥1", "formatted after step" );
-});
+} );
test( "currency, change", function() {
expect( 2 );
- var element = $( "#spin" ).val( 5 ).spinner({
+ var element = $( "#spin" ).val( 5 ).spinner( {
numberFormat: "C",
culture: "ja-JP"
- });
+ } );
equal( element.val(), "¥5", "formatted on init" );
element.spinner( "option", "culture", "en" );
equal( element.val(), "$5.00", "formatted after change" );
-});
+} );
test( "max", function() {
expect( 3 );
- var element = $( "#spin" ).val( 1000 ).spinner({ max: 100 });
+ var element = $( "#spin" ).val( 1000 ).spinner( { max: 100 } );
equal( element.val(), 1000, "value not constrained on init" );
element.spinner( "value", 1000 );
@@ -183,27 +183,27 @@ test( "max", function() {
element.val( 1000 ).trigger( "blur" );
equal( element.val(), 1000, "max not constrained if manual entry" );
-});
+} );
test( "max, string", function() {
expect( 3 );
var element = $( "#spin" )
.val( 1000 )
- .spinner({
+ .spinner( {
max: "$100.00",
numberFormat: "C",
culture: "en"
- });
+ } );
equal( element.val(), "$1,000.00", "value not constrained on init" );
equal( element.spinner( "option", "max" ), 100, "option converted to number" );
element.spinner( "value", 1000 );
equal( element.val(), "$100.00", "max constrained in value method" );
-});
+} );
test( "min", function() {
expect( 3 );
- var element = $( "#spin" ).val( -1000 ).spinner({ min: -100 });
+ var element = $( "#spin" ).val( -1000 ).spinner( { min: -100 } );
equal( element.val(), -1000, "value not constrained on init" );
element.spinner( "value", -1000 );
@@ -211,27 +211,27 @@ test( "min", function() {
element.val( -1000 ).trigger( "blur" );
equal( element.val(), -1000, "min not constrained if manual entry" );
-});
+} );
test( "min, string", function() {
expect( 3 );
var element = $( "#spin" )
.val( -1000 )
- .spinner({
+ .spinner( {
min: "-$100.00",
numberFormat: "C",
culture: "en"
- });
+ } );
equal( element.val(), "($1,000.00)", "value not constrained on init" );
equal( element.spinner( "option", "min" ), -100, "option converted to number" );
element.spinner( "value", -1000 );
equal( element.val(), "($100.00)", "min constrained in value method" );
-});
+} );
test( "step, 2", function() {
expect( 3 );
- var element = $( "#spin" ).val( 0 ).spinner({ step: 2 });
+ var element = $( "#spin" ).val( 0 ).spinner( { step: 2 } );
element.spinner( "stepUp" );
equal( element.val(), "2", "stepUp" );
@@ -242,30 +242,30 @@ test( "step, 2", function() {
element.val( "4.5" );
element.spinner( "stepUp" );
equal( element.val(), "6", "stepUp" );
-});
+} );
test( "step, 0.7", function() {
expect( 1 );
- var element = $("#spin").val( 0 ).spinner({
+ var element = $( "#spin" ).val( 0 ).spinner( {
step: 0.7
- });
+ } );
element.spinner( "stepUp" );
equal( element.val(), "0.7", "stepUp" );
-});
+} );
test( "step, string", function() {
expect( 2 );
- var element = $("#spin").val( 0 ).spinner({
+ var element = $( "#spin" ).val( 0 ).spinner( {
step: "$0.70",
numberFormat: "C",
culture: "en"
- });
+ } );
equal( element.spinner( "option", "step" ), 0.7, "option converted to number" );
element.spinner( "stepUp" );
equal( element.val(), "$0.70", "stepUp" );
-});
+} );
} );
diff --git a/tests/unit/subsuite.js b/tests/unit/subsuite.js
index a591ae711..31a279c28 100644
--- a/tests/unit/subsuite.js
+++ b/tests/unit/subsuite.js
@@ -1,4 +1,4 @@
-(function() {
+( function() {
var versions = [
"1.7.0", "1.7.1", "1.7.2",
@@ -9,6 +9,7 @@ var versions = [
"compat-git"
],
additionalTests = {
+
// component: [ "other_test.html" ]
};
@@ -18,8 +19,8 @@ window.testAllVersions = function( widget ) {
function( test ) {
return $.map( versions, function( version ) {
return test + "?jquery=" + version;
- });
- }));
+ } );
+ } ) );
};
-}());
+}() );
diff --git a/tests/unit/tabs/common.js b/tests/unit/tabs/common.js
index 42dd0c2fc..ae4adde5a 100644
--- a/tests/unit/tabs/common.js
+++ b/tests/unit/tabs/common.js
@@ -19,13 +19,13 @@ common.testWidget( "tabs", {
hide: null,
show: null,
- // callbacks
+ // Callbacks
activate: null,
beforeActivate: null,
beforeLoad: null,
create: null,
load: null
}
-});
+} );
} );
diff --git a/tests/unit/tabs/core.js b/tests/unit/tabs/core.js
index b64f1d8f3..a2b41e24c 100644
--- a/tests/unit/tabs/core.js
+++ b/tests/unit/tabs/core.js
@@ -40,9 +40,9 @@ test( "markup structure", function( assert ) {
assert.hasClasses( panels[ 1 ], "ui-tabs-panel ui-widget-content" );
assert.hasClasses( panels[ 2 ], "ui-tabs-panel ui-widget-content" );
equal( panels.length, 3, "There are exactly 3 tab panels" );
-});
+} );
-$.each({
+$.each( {
"deep ul": "#tabs3",
"multiple lists, ul first": "#tabs4",
"multiple lists, ol first": "#tabs5",
@@ -53,8 +53,8 @@ $.each({
var element = $( selector ).tabs();
assert.hasClasses( element, "ui-tabs" );
assert.hasClasses( $( selector + "-list" ), "ui-tabs-nav" );
- });
-});
+ } );
+} );
// #5893 - Sublist in the tab list are considered as tab
test( "nested list", function() {
@@ -62,7 +62,7 @@ test( "nested list", function() {
var element = $( "#tabs6" ).tabs();
equal( element.tabs( "instance" ).anchors.length, 2, "should contain 2 tab" );
-});
+} );
test( "disconnected from DOM", function() {
expect( 2 );
@@ -70,7 +70,7 @@ test( "disconnected from DOM", function() {
var element = $( "#tabs1" ).remove().tabs();
equal( element.find( ".ui-tabs-nav" ).length, 1, "should initialize nav" );
equal( element.find( ".ui-tabs-panel" ).length, 3, "should initialize panels" );
-});
+} );
test( "non-tab list items", function() {
expect( 2 );
@@ -79,17 +79,17 @@ test( "non-tab list items", function() {
equal( element.tabs( "option", "active" ), 0, "defaults to first tab" );
equal( element.find( ".ui-tabs-nav li.ui-state-active" ).index(), 1,
"first actual tab is active" );
-});
+} );
test( "aria-controls", function() {
expect( 7 );
var element = $( "#tabs1" ).tabs(),
tabs = element.find( ".ui-tabs-nav li" );
- tabs.each(function() {
+ tabs.each( function() {
var tab = $( this ),
anchor = tab.find( ".ui-tabs-anchor" );
equal( anchor.prop( "hash" ).substring( 1 ), tab.attr( "aria-controls" ) );
- });
+ } );
element = $( "#tabs2" ).tabs();
tabs = element.find( ".ui-tabs-nav li" );
@@ -97,20 +97,20 @@ test( "aria-controls", function() {
equal( tabs.eq( 1 ).attr( "aria-controls" ), "inline-style" );
ok( /^ui-id-\d+$/.test( tabs.eq( 2 ).attr( "aria-controls" ) ), "generated id" );
equal( tabs.eq( 3 ).attr( "aria-controls" ), "custom-id" );
-});
+} );
test( "accessibility", function() {
expect( 49 );
- var element = $( "#tabs1" ).tabs({
+ var element = $( "#tabs1" ).tabs( {
active: 1,
disabled: [ 2 ]
- }),
+ } ),
tabs = element.find( ".ui-tabs-nav li" ),
anchors = tabs.find( ".ui-tabs-anchor" ),
panels = element.find( ".ui-tabs-panel" );
equal( element.find( ".ui-tabs-nav" ).attr( "role" ), "tablist", "tablist role" );
- tabs.each(function( index ) {
+ tabs.each( function( index ) {
var tab = tabs.eq( index ),
anchor = anchors.eq( index ),
anchorId = anchor.attr( "id" ),
@@ -121,7 +121,7 @@ test( "accessibility", function() {
equal( anchor.attr( "tabindex" ), -1, "anchor " + index + " tabindex" );
equal( panel.attr( "role" ), "tabpanel", "panel " + index + " role" );
equal( panel.attr( "aria-labelledby" ), anchorId, "panel " + index + " aria-labelledby" );
- });
+ } );
equal( tabs.eq( 1 ).attr( "aria-selected" ), "true", "active tab has aria-selected=true" );
equal( tabs.eq( 1 ).attr( "tabindex" ), 0, "active tab has tabindex=0" );
@@ -155,7 +155,7 @@ test( "accessibility", function() {
equal( tabs.eq( 2 ).attr( "aria-disabled" ), "true", "disabled tab has aria-disabled=true" );
equal( tabs.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded=false" );
equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "inactive panel has aria-hidden=true" );
-});
+} );
asyncTest( "accessibility - ajax", function( assert ) {
expect( 6 );
@@ -169,19 +169,19 @@ asyncTest( "accessibility - ajax", function( assert ) {
assert.hasClasses( tab, "ui-tabs-loading" );
equal( panel.attr( "aria-busy" ), "true", "panel has aria-busy during load" );
element.one( "tabsload", function() {
- setTimeout(function() {
+ setTimeout( function() {
equal( panel.attr( "aria-busy" ), null, "panel does not have aria-busy after load" );
assert.lacksClasses( tab, "ui-tabs-loading" );
start();
}, 1 );
- });
-});
+ } );
+} );
asyncTest( "keyboard support - LEFT, RIGHT, UP, DOWN, HOME, END, SPACE, ENTER", function( assert ) {
expect( 92 );
- var element = $( "#tabs1" ).tabs({
+ var element = $( "#tabs1" ).tabs( {
collapsible: true
- }),
+ } ),
tabs = element.find( ".ui-tabs-nav li" ),
panels = element.find( ".ui-tabs-panel" ),
keyCode = $.ui.keyCode;
@@ -191,7 +191,7 @@ asyncTest( "keyboard support - LEFT, RIGHT, UP, DOWN, HOME, END, SPACE, ENTER",
equal( tabs.filter( ".ui-state-focus" ).length, 0, "no tabs focused on init" );
tabs.eq( 0 ).simulate( "focus" );
- // down, right, down (wrap), up (wrap)
+ // Down, right, down (wrap), up (wrap)
function step1() {
assert.hasClasses( tabs.eq( 0 ), "ui-state-focus", "first tab has focus" );
equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
@@ -242,7 +242,7 @@ asyncTest( "keyboard support - LEFT, RIGHT, UP, DOWN, HOME, END, SPACE, ENTER",
setTimeout( step2, 25 );
}
- // left, home, space
+ // Left, home, space
function step2() {
equal( tabs.eq( 2 ).attr( "aria-selected" ), "true", "third tab has aria-selected=true" );
equal( tabs.eq( 0 ).attr( "aria-selected" ), "false", "first tab has aria-selected=false" );
@@ -280,7 +280,7 @@ asyncTest( "keyboard support - LEFT, RIGHT, UP, DOWN, HOME, END, SPACE, ENTER",
setTimeout( step3 );
}
- // end, enter
+ // End, enter
function step3() {
equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
equal( tabs.eq( 2 ).attr( "aria-selected" ), "false", "third tab has aria-selected=false" );
@@ -307,7 +307,7 @@ asyncTest( "keyboard support - LEFT, RIGHT, UP, DOWN, HOME, END, SPACE, ENTER",
setTimeout( step4 );
}
- // enter (collapse)
+ // Enter (collapse)
function step4() {
equal( tabs.eq( 2 ).attr( "aria-selected" ), "true", "third tab has aria-selected=true" );
ok( panels.eq( 2 ).is( ":visible" ), "third panel is visible" );
@@ -328,10 +328,10 @@ asyncTest( "keyboard support - LEFT, RIGHT, UP, DOWN, HOME, END, SPACE, ENTER",
}
setTimeout( step1 );
-});
+} );
// Navigation with CTRL and COMMAND (both behave the same)
-$.each({
+$.each( {
ctrl: "CTRL",
meta: "COMMAND"
}, function( modifier, label ) {
@@ -347,7 +347,7 @@ $.each({
equal( tabs.filter( ".ui-state-focus" ).length, 0, "no tabs focused on init" );
tabs.eq( 0 ).simulate( "focus" );
- // down
+ // Down
function step1() {
var eventProperties = { keyCode: keyCode.DOWN };
eventProperties[ modifier + "Key" ] = true;
@@ -371,7 +371,7 @@ $.each({
setTimeout( step2, 25 );
}
- // right
+ // Right
function step2() {
var eventProperties = { keyCode: keyCode.RIGHT };
eventProperties[ modifier + "Key" ] = true;
@@ -398,7 +398,7 @@ $.each({
setTimeout( step3, 25 );
}
- // down (wrap)
+ // Down (wrap)
function step3() {
var eventProperties = { keyCode: keyCode.DOWN };
eventProperties[ modifier + "Key" ] = true;
@@ -421,7 +421,7 @@ $.each({
setTimeout( step4, 25 );
}
- // up (wrap)
+ // Up (wrap)
function step4() {
var eventProperties = { keyCode: keyCode.UP };
eventProperties[ modifier + "Key" ] = true;
@@ -445,7 +445,7 @@ $.each({
setTimeout( step5, 25 );
}
- // left
+ // Left
function step5() {
var eventProperties = { keyCode: keyCode.LEFT };
eventProperties[ modifier + "Key" ] = true;
@@ -472,7 +472,7 @@ $.each({
setTimeout( step6, 25 );
}
- // home
+ // Home
function step6() {
var eventProperties = { keyCode: keyCode.HOME };
eventProperties[ modifier + "Key" ] = true;
@@ -499,7 +499,7 @@ $.each({
setTimeout( step7, 25 );
}
- // end
+ // End
function step7() {
var eventProperties = { keyCode: keyCode.END };
eventProperties[ modifier + "Key" ] = true;
@@ -523,7 +523,7 @@ $.each({
setTimeout( step8, 25 );
}
- // space
+ // Space
function step8() {
equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
@@ -547,8 +547,8 @@ $.each({
}
setTimeout( step1 );
- });
-});
+ } );
+} );
asyncTest( "keyboard support - CTRL+UP, ALT+PAGE_DOWN, ALT+PAGE_UP", function( assert ) {
expect( 50 );
@@ -640,34 +640,34 @@ asyncTest( "keyboard support - CTRL+UP, ALT+PAGE_DOWN, ALT+PAGE_UP", function( a
}
setTimeout( step1 );
-});
+} );
test( "#3627 - Ajax tab with url containing a fragment identifier fails to load", function() {
expect( 1 );
- $( "#tabs2" ).tabs({
+ $( "#tabs2" ).tabs( {
active: 2,
beforeLoad: function( event, ui ) {
event.preventDefault();
ok( /test.html$/.test( ui.ajaxSettings.url ), "should ignore fragment identifier" );
}
- });
-});
+ } );
+} );
test( "#4033 - IE expands hash to full url and misinterprets tab as ajax", function() {
expect( 2 );
- var element = $("<div><ul><li><a href='#tab'>Tab</a></li></ul><div id='tab'></div></div>");
- element.appendTo("#qunit-fixture");
- element.tabs({
+ var element = $( "<div><ul><li><a href='#tab'>Tab</a></li></ul><div id='tab'></div></div>" );
+ element.appendTo( "#qunit-fixture" );
+ element.tabs( {
beforeLoad: function() {
event.preventDefault();
ok( false, "should not be an ajax tab" );
}
- });
+ } );
- equal( element.find(".ui-tabs-nav li").attr("aria-controls"), "tab", "aria-contorls attribute is correct" );
+ equal( element.find( ".ui-tabs-nav li" ).attr( "aria-controls" ), "tab", "aria-contorls attribute is correct" );
state( element, 1 );
-});
+} );
} );
diff --git a/tests/unit/tabs/events.js b/tests/unit/tabs/events.js
index 7e3d27fda..736fda503 100644
--- a/tests/unit/tabs/events.js
+++ b/tests/unit/tabs/events.js
@@ -15,17 +15,17 @@ test( "create", function() {
tabs = element.find( "ul li" ),
panels = element.children( "div" );
- element.tabs({
+ element.tabs( {
create: function( event, ui ) {
equal( ui.tab.length, 1, "tab length" );
strictEqual( ui.tab[ 0 ], tabs[ 0 ], "tab" );
equal( ui.panel.length, 1, "panel length" );
strictEqual( ui.panel[ 0 ], panels[ 0 ], "panel" );
}
- });
+ } );
element.tabs( "destroy" );
- element.tabs({
+ element.tabs( {
active: 2,
create: function( event, ui ) {
equal( ui.tab.length, 1, "tab length" );
@@ -33,32 +33,32 @@ test( "create", function() {
equal( ui.panel.length, 1, "panel length" );
strictEqual( ui.panel[ 0 ], panels[ 2 ], "panel" );
}
- });
+ } );
element.tabs( "destroy" );
- element.tabs({
+ element.tabs( {
active: false,
collapsible: true,
create: function( event, ui ) {
equal( ui.tab.length, 0, "tab length" );
equal( ui.panel.length, 0, "panel length" );
}
- });
+ } );
element.tabs( "destroy" );
-});
+} );
test( "beforeActivate", function() {
expect( 38 );
- var element = $( "#tabs1" ).tabs({
+ var element = $( "#tabs1" ).tabs( {
active: false,
collapsible: true
- }),
+ } ),
tabs = element.find( ".ui-tabs-nav li" ),
anchors = tabs.find( ".ui-tabs-anchor" ),
panels = element.find( ".ui-tabs-panel" );
- // from collapsed
+ // From collapsed
element.one( "tabsbeforeactivate", function( event, ui ) {
ok( !( "originalEvent" in event ), "originalEvent" );
equal( ui.oldTab.length, 0, "oldTab length" );
@@ -68,11 +68,11 @@ test( "beforeActivate", function() {
equal( ui.newPanel.length, 1, "newPanel length" );
strictEqual( ui.newPanel[ 0 ], panels[ 0 ], "newPanel" );
state( element, 0, 0, 0 );
- });
+ } );
element.tabs( "option", "active", 0 );
state( element, 1, 0, 0 );
- // switching tabs
+ // Switching tabs
element.one( "tabsbeforeactivate", function( event, ui ) {
equal( event.originalEvent.type, "click", "originalEvent" );
equal( ui.oldTab.length, 1, "oldTab length" );
@@ -84,11 +84,11 @@ test( "beforeActivate", function() {
equal( ui.newPanel.length, 1, "newPanel length" );
strictEqual( ui.newPanel[ 0 ], panels[ 1 ], "newPanel" );
state( element, 1, 0, 0 );
- });
+ } );
anchors.eq( 1 ).trigger( "click" );
state( element, 0, 1, 0 );
- // collapsing
+ // Collapsing
element.one( "tabsbeforeactivate", function( event, ui ) {
ok( !( "originalEvent" in event ), "originalEvent" );
equal( ui.oldTab.length, 1, "oldTab length" );
@@ -98,11 +98,11 @@ test( "beforeActivate", function() {
equal( ui.newTab.length, 0, "newTab length" );
equal( ui.newPanel.length, 0, "newPanel length" );
state( element, 0, 1, 0 );
- });
+ } );
element.tabs( "option", "active", false );
state( element, 0, 0, 0 );
- // prevent activation
+ // Prevent activation
element.one( "tabsbeforeactivate", function( event, ui ) {
ok( !( "originalEvent" in event ), "originalEvent" );
equal( ui.oldTab.length, 0, "oldTab length" );
@@ -113,23 +113,23 @@ test( "beforeActivate", function() {
strictEqual( ui.newPanel[ 0 ], panels[ 1 ], "newPanel" );
event.preventDefault();
state( element, 0, 0, 0 );
- });
+ } );
element.tabs( "option", "active", 1 );
state( element, 0, 0, 0 );
-});
+} );
test( "activate", function() {
expect( 30 );
- var element = $( "#tabs1" ).tabs({
+ var element = $( "#tabs1" ).tabs( {
active: false,
collapsible: true
- }),
+ } ),
tabs = element.find( ".ui-tabs-nav li" ),
anchors = element.find( ".ui-tabs-anchor" ),
panels = element.find( ".ui-tabs-panel" );
- // from collapsed
+ // From collapsed
element.one( "tabsactivate", function( event, ui ) {
ok( !( "originalEvent" in event ), "originalEvent" );
equal( ui.oldTab.length, 0, "oldTab length" );
@@ -139,11 +139,11 @@ test( "activate", function() {
equal( ui.newPanel.length, 1, "newPanel length" );
strictEqual( ui.newPanel[ 0 ], panels[ 0 ], "newPanel" );
state( element, 1, 0, 0 );
- });
+ } );
element.tabs( "option", "active", 0 );
state( element, 1, 0, 0 );
- // switching tabs
+ // Switching tabs
element.one( "tabsactivate", function( event, ui ) {
equal( event.originalEvent.type, "click", "originalEvent" );
equal( ui.oldTab.length, 1, "oldTab length" );
@@ -155,11 +155,11 @@ test( "activate", function() {
equal( ui.newPanel.length, 1, "newPanel length" );
strictEqual( ui.newPanel[ 0 ], panels[ 1 ], "newPanel" );
state( element, 0, 1, 0 );
- });
+ } );
anchors.eq( 1 ).trigger( "click" );
state( element, 0, 1, 0 );
- // collapsing
+ // Collapsing
element.one( "tabsactivate", function( event, ui ) {
ok( !( "originalEvent" in event ), "originalEvent" );
equal( ui.oldTab.length, 1, "oldTab length" );
@@ -169,20 +169,20 @@ test( "activate", function() {
equal( ui.newTab.length, 0, "newTab length" );
equal( ui.newPanel.length, 0, "newPanel length" );
state( element, 0, 0, 0 );
- });
+ } );
element.tabs( "option", "active", false );
state( element, 0, 0, 0 );
- // prevent activation
+ // Prevent activation
element.one( "tabsbeforeactivate", function( event ) {
ok( true, "tabsbeforeactivate" );
event.preventDefault();
- });
+ } );
element.one( "tabsactivate", function() {
ok( false, "tabsactivate" );
- });
+ } );
element.tabs( "option", "active", 1 );
-});
+} );
test( "beforeLoad", function() {
expect( 32 );
@@ -190,7 +190,7 @@ test( "beforeLoad", function() {
var tab, panelId, panel,
element = $( "#tabs2" );
- // init
+ // Init
element.one( "tabsbeforeload", function( event, ui ) {
tab = element.find( ".ui-tabs-nav li" ).eq( 2 );
panelId = tab.attr( "aria-controls" );
@@ -206,8 +206,8 @@ test( "beforeLoad", function() {
equal( ui.panel.html(), "", "panel html" );
event.preventDefault();
state( element, 0, 0, 1, 0, 0 );
- });
- element.tabs({ active: 2 });
+ } );
+ element.tabs( { active: 2 } );
state( element, 0, 0, 1, 0, 0 );
equal( panel.html(), "", "panel html after" );
element.tabs( "destroy" );
@@ -228,13 +228,13 @@ test( "beforeLoad", function() {
equal( ui.panel.html(), "", "panel html" );
event.preventDefault();
state( element, 1, 0, 0, 0, 0 );
- });
+ } );
element.tabs();
element.tabs( "option", "active", 2 );
state( element, 0, 0, 1, 0, 0 );
equal( panel.html(), "", "panel html after" );
- // click, change panel content
+ // Click, change panel content
element.one( "tabsbeforeload", function( event, ui ) {
tab = element.find( ".ui-tabs-nav li" ).eq( 3 );
panelId = tab.attr( "aria-controls" );
@@ -250,12 +250,13 @@ test( "beforeLoad", function() {
ui.panel.html( "<p>testing</p>" );
event.preventDefault();
state( element, 0, 0, 1, 0, 0 );
- });
+ } );
element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 3 ).trigger( "click" );
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" );
-});
+} );
asyncTest( "load", function() {
expect( 21 );
@@ -263,7 +264,7 @@ asyncTest( "load", function() {
var tab, panelId, panel,
element = $( "#tabs2" );
- // init
+ // Init
element.one( "tabsload", function( event, ui ) {
tab = element.find( ".ui-tabs-nav li" ).eq( 2 );
panelId = tab.attr( "aria-controls" );
@@ -277,10 +278,11 @@ asyncTest( "load", function() {
equal( ui.panel.find( "p" ).length, 1, "panel html" );
state( element, 0, 0, 1, 0, 0 );
tabsload1();
- });
- element.tabs({ active: 2 });
+ } );
+ element.tabs( { active: 2 } );
function tabsload1() {
+
// .option()
element.one( "tabsload", function( event, ui ) {
tab = element.find( ".ui-tabs-nav li" ).eq( 3 );
@@ -295,11 +297,12 @@ asyncTest( "load", function() {
equal( ui.panel.find( "p" ).length, 1, "panel html" );
state( element, 0, 0, 0, 1, 0 );
tabsload2();
- });
+ } );
element.tabs( "option", "active", 3 );
}
function tabsload2() {
+
// click, change panel content
element.one( "tabsload", function( event, ui ) {
tab = element.find( ".ui-tabs-nav li" ).eq( 4 );
@@ -314,9 +317,9 @@ asyncTest( "load", function() {
equal( ui.panel.find( "p" ).length, 1, "panel html" );
state( element, 0, 0, 0, 0, 1 );
start();
- });
+ } );
element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 4 ).trigger( "click" );
}
-});
+} );
} );
diff --git a/tests/unit/tabs/helper.js b/tests/unit/tabs/helper.js
index 132061753..073895f5f 100644
--- a/tests/unit/tabs/helper.js
+++ b/tests/unit/tabs/helper.js
@@ -15,7 +15,7 @@ return $.extend( helper, {
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 ) {
@@ -24,9 +24,9 @@ return $.extend( helper, {
} else {
return $.inArray( index, state ) !== -1 ? 1 : 0;
}
- });
+ } );
- actual = tabs.find( ".ui-tabs-nav li" ).map(function( index ) {
+ actual = tabs.find( ".ui-tabs-nav li" ).map( function( index ) {
var tab = $( this ),
tabIsDisabled = tab.hasClass( "ui-state-disabled" );
@@ -36,23 +36,24 @@ return $.extend( helper, {
if ( !tabIsDisabled && $.inArray( index, internalState ) === -1 ) {
return 0;
}
+
// mixed state - invalid
return -1;
- }).get();
+ } ).get();
deepEqual( tabs.tabs( "option", "disabled" ), state );
deepEqual( actual, expected );
},
equalHeight: function( tabs, height ) {
- tabs.find( ".ui-tabs-panel" ).each(function() {
+ tabs.find( ".ui-tabs-panel" ).each( function() {
equal( $( this ).outerHeight(), height );
- });
+ } );
},
state: function( tabs ) {
var expected = $.makeArray( arguments ).slice( 1 ),
- actual = tabs.find( ".ui-tabs-nav li" ).map(function() {
+ actual = tabs.find( ".ui-tabs-nav li" ).map( function() {
var tab = $( this ),
panel = $( $.ui.tabs.prototype._sanitizeSelector(
"#" + tab.attr( "aria-controls" ) ) ),
@@ -66,7 +67,7 @@ return $.extend( helper, {
return 0;
}
return -1; // mixed state - invalid
- }).get();
+ } ).get();
deepEqual( actual, expected );
}
} );
diff --git a/tests/unit/tabs/methods.js b/tests/unit/tabs/methods.js
index 3be31c5f8..ef7c09ba7 100644
--- a/tests/unit/tabs/methods.js
+++ b/tests/unit/tabs/methods.js
@@ -13,95 +13,103 @@ test( "destroy", function( assert ) {
expect( 2 );
assert.domEqual( "#tabs1", function() {
$( "#tabs1" ).tabs().tabs( "destroy" );
- });
+ } );
assert.domEqual( "#tabs2", function() {
$( "#tabs2" ).tabs().tabs( "destroy" );
- });
-});
+ } );
+} );
asyncTest( "destroy - ajax", function( assert ) {
expect( 1 );
assert.domEqual( "#tabs2", function( done ) {
- var element = $( "#tabs2" ).tabs({
+ var element = $( "#tabs2" ).tabs( {
load: function() {
- setTimeout(function() {
+ setTimeout( function() {
element.tabs( "destroy" );
done();
start();
- });
+ } );
}
- });
+ } );
element.tabs( "option", "active", 2 );
- });
-});
+ } );
+} );
test( "enable", function() {
expect( 8 );
- var element = $( "#tabs1" ).tabs({ disabled: true });
+ var element = $( "#tabs1" ).tabs( { disabled: true } );
disabled( element, true );
element.tabs( "enable" );
disabled( element, false );
element.tabs( "destroy" );
- element.tabs({ disabled: [ 0, 1 ] });
+ element.tabs( { disabled: [ 0, 1 ] } );
disabled( element, [ 0, 1 ] );
element.tabs( "enable" );
disabled( element, false );
-});
+} );
test( "enable( index )", function() {
expect( 10 );
- var element = $( "#tabs1" ).tabs({ disabled: true });
+ var element = $( "#tabs1" ).tabs( { disabled: true } );
disabled( element, true );
+
// fully disabled -> partially disabled
element.tabs( "enable", 1 );
disabled( element, [ 0, 2 ] );
+
// partially disabled -> partially disabled
element.tabs( "enable", 2 );
disabled( element, [ 0 ] );
+
// already enabled tab, no change
element.tabs( "enable", 2 );
disabled( element, [ 0 ] );
+
// partially disabled -> fully enabled
element.tabs( "enable", 0 );
disabled( element, false );
-});
+} );
test( "disable", function() {
expect( 8 );
- var element = $( "#tabs1" ).tabs({ disabled: false });
+ var element = $( "#tabs1" ).tabs( { disabled: false } );
disabled( element, false );
element.tabs( "disable" );
disabled( element, true );
element.tabs( "destroy" );
- element.tabs({ disabled: [ 0, 1 ] });
+ element.tabs( { disabled: [ 0, 1 ] } );
disabled( element, [ 0, 1 ] );
element.tabs( "disable" );
disabled( element, true );
-});
+} );
test( "disable( index )", function() {
expect( 10 );
- var element = $( "#tabs1" ).tabs({ disabled: false });
+ var element = $( "#tabs1" ).tabs( { disabled: false } );
disabled( element, false );
+
// fully enabled -> partially disabled
element.tabs( "disable", 1 );
disabled( element, [ 1 ] );
+
// partially disabled -> partially disabled
element.tabs( "disable", 2 );
disabled( element, [ 1, 2 ] );
+
// already disabled tab, no change
element.tabs( "disable", 2 );
disabled( element, [ 1, 2 ] );
+
// partially disabled -> fully disabled
element.tabs( "disable", 0 );
disabled( element, true );
-});
+} );
test( "refresh", function() {
expect( 27 );
@@ -110,13 +118,13 @@ test( "refresh", function() {
state( element, 1, 0, 0 );
disabled( element, false );
- // disable tab via markup
+ // Disable tab via markup
element.find( ".ui-tabs-nav li" ).eq( 1 ).addClass( "ui-state-disabled" );
element.tabs( "refresh" );
state( element, 1, 0, 0 );
disabled( element, [ 1 ] );
- // add remote tab
+ // Add remote tab
element.find( ".ui-tabs-nav" ).append( "<li id='newTab'><a href='data/test.html'>new</a></li>" );
element.tabs( "refresh" );
state( element, 1, 0, 0, 0 );
@@ -124,13 +132,13 @@ test( "refresh", function() {
equal( element.find( "#" + $( "#newTab" ).attr( "aria-controls" ) ).length, 1,
"panel added for remote tab" );
- // remove all tabs
+ // Remove all tabs
element.find( ".ui-tabs-nav li, .ui-tabs-panel" ).remove();
element.tabs( "refresh" );
state( element );
equal( element.tabs( "option", "active" ), false, "no active tab" );
- // add tabs
+ // Add tabs
element.find( ".ui-tabs-nav" )
.append( "<li class='ui-state-disabled'><a href='#newTab2'>new 2</a></li>" )
.append( "<li><a href='#newTab3'>new 3</a></li>" )
@@ -145,44 +153,44 @@ test( "refresh", function() {
state( element, 0, 0, 0, 0 );
disabled( element, [ 0 ] );
- // activate third tab
+ // Activate third tab
element.tabs( "option", "active", 2 );
state( element, 0, 0, 1, 0 );
disabled( element, [ 0 ] );
- // remove fourth tab, third tab should stay active
+ // 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" );
state( element, 0, 0, 1 );
disabled( element, [ 0 ] );
- // remove third (active) tab, second tab should become active
+ // 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" );
state( element, 0, 1 );
disabled( element, [ 0 ] );
- // remove first tab, previously active tab (now first) should stay active
+ // 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" );
state( element, 1 );
disabled( element, false );
-});
+} );
test( "refresh - looping", function() {
expect( 6 );
- var element = $( "#tabs1" ).tabs({
+ var element = $( "#tabs1" ).tabs( {
disabled: [ 0 ],
active: 1
- });
+ } );
state( element, 0, 1, 0 );
disabled( element, [ 0 ] );
- // remove active, jump to previous
+ // Remove active, jump to previous
// previous is disabled, just back one more
// reached first tab, move to end
// activate last tab
@@ -190,14 +198,14 @@ test( "refresh - looping", function() {
element.tabs( "refresh" );
state( element, 0, 1 );
disabled( element, [ 0 ] );
-});
+} );
asyncTest( "load", function() {
expect( 30 );
var element = $( "#tabs2" ).tabs();
- // load content of inactive tab
+ // Load content of inactive tab
// useful for preloading content with custom caching
element.one( "tabsbeforeload", function( event, ui ) {
var tab = element.find( ".ui-tabs-nav li" ).eq( 3 ),
@@ -210,8 +218,9 @@ asyncTest( "load", function() {
equal( ui.panel.length, 1, "panel length" );
strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
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 ),
@@ -227,24 +236,26 @@ asyncTest( "load", function() {
equal( uiPanel.find( "p" ).length, 1, "panel html" );
state( element, 1, 0, 0, 0, 0 );
setTimeout( tabsload1 );
- });
+ } );
element.tabs( "load", 3 );
state( element, 1, 0, 0, 0, 0 );
function tabsload1() {
+
// no need to test details of event (tested in events tests)
element.one( "tabsbeforeload", function() {
ok( true, "tabsbeforeload invoked" );
- });
+ } );
element.one( "tabsload", function() {
ok( true, "tabsload invoked" );
setTimeout( tabsload2 );
- });
+ } );
element.tabs( "option", "active", 3 );
state( element, 0, 0, 0, 1, 0 );
}
function tabsload2() {
+
// reload content of active tab
element.one( "tabsbeforeload", function( event, ui ) {
var tab = element.find( ".ui-tabs-nav li" ).eq( 3 ),
@@ -257,8 +268,9 @@ asyncTest( "load", function() {
equal( ui.panel.length, 1, "panel length" );
strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
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 ),
@@ -273,11 +285,11 @@ asyncTest( "load", function() {
strictEqual( uiPanel[ 0 ], panel[ 0 ], "panel" );
state( element, 0, 0, 0, 1, 0 );
start();
- });
+ } );
element.tabs( "load", 3 );
state( element, 0, 0, 0, 1, 0 );
}
-});
+} );
test( "widget", function() {
expect( 2 );
@@ -285,6 +297,6 @@ test( "widget", function() {
widgetElement = element.tabs( "widget" );
equal( widgetElement.length, 1, "one element" );
strictEqual( widgetElement[ 0 ], element[ 0 ], "same element" );
-});
+} );
} );
diff --git a/tests/unit/tabs/options.js b/tests/unit/tabs/options.js
index 39771efe6..4092cfcf8 100644
--- a/tests/unit/tabs/options.js
+++ b/tests/unit/tabs/options.js
@@ -30,15 +30,15 @@ test( "{ active: default }", function() {
state( element, 0, 0, 0, 1, 0 );
element.tabs( "destroy" );
location.hash = "#";
-});
+} );
test( "{ active: false }", function() {
expect( 7 );
- var element = $( "#tabs1" ).tabs({
+ var element = $( "#tabs1" ).tabs( {
active: false,
collapsible: true
- });
+ } );
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 );
@@ -48,19 +48,19 @@ test( "{ active: false }", function() {
equal( element.tabs( "option", "active" ), 0 );
element.tabs( "destroy" );
- element.tabs({
+ element.tabs( {
active: false
- });
+ } );
state( element, 1, 0, 0 );
strictEqual( element.tabs( "option", "active" ), 0 );
-});
+} );
test( "{ active: Number }", function() {
expect( 8 );
- var element = $( "#tabs1" ).tabs({
+ var element = $( "#tabs1" ).tabs( {
active: 2
- });
+ } );
equal( element.tabs( "option", "active" ), 2 );
state( element, 0, 0, 1 );
@@ -75,14 +75,14 @@ test( "{ active: Number }", function() {
element.tabs( "option", "active", 10 );
equal( element.tabs( "option", "active" ), 1 );
state( element, 0, 1, 0 );
-});
+} );
test( "{ active: -Number }", function() {
expect( 8 );
- var element = $( "#tabs1" ).tabs({
+ var element = $( "#tabs1" ).tabs( {
active: -1
- });
+ } );
equal( element.tabs( "option", "active" ), 2 );
state( element, 0, 0, 1 );
@@ -97,7 +97,7 @@ test( "{ active: -Number }", function() {
element.tabs( "option", "active", -3 );
equal( element.tabs( "option", "active" ), 0 );
state( element, 1, 0, 0 );
-});
+} );
test( "active - mismatched tab/panel order", function() {
expect( 3 );
@@ -109,15 +109,15 @@ test( "active - mismatched tab/panel order", function() {
element.tabs( "option", "active", 0 );
state( element, 1, 0 );
location.hash = "#";
-});
+} );
test( "collapsible", function( assert ) {
expect( 13 );
- var element = $( "#tabs1" ).tabs({
+ var element = $( "#tabs1" ).tabs( {
active: 1,
collapsible: true
- });
+ } );
assert.hasClasses( element, "ui-tabs-collapsible" );
element.tabs( "option", "active", false );
equal( element.tabs( "option", "active" ), false );
@@ -138,10 +138,10 @@ test( "collapsible", function( assert ) {
assert.hasClasses( element, "ui-tabs-collapsible" );
- element.tabs({
+ element.tabs( {
active: 1,
collapsible: false
- });
+ } );
element.tabs( "option", "active", false );
equal( element.tabs( "option", "active" ), 1 );
state( element, 0, 1, 0 );
@@ -150,12 +150,12 @@ test( "collapsible", function( assert ) {
equal( element.tabs( "option", "active" ), 1 );
state( element, 0, 1, 0 );
-});
+} );
test( "disabled", function( assert ) {
expect( 23 );
- // fully enabled by default
+ // Fully enabled by default
var event,
element = $( "#tabs1" ).tabs();
disabled( element, false );
@@ -164,7 +164,7 @@ test( "disabled", function( assert ) {
assert.lacksClasses( element.tabs( "widget" ), "ui-tabs-disabled" );
ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" );
- // disable single tab
+ // Disable single tab
element.tabs( "option", "disabled", [ 1 ] );
disabled( element, [ 1 ] );
@@ -172,7 +172,7 @@ test( "disabled", function( assert ) {
assert.lacksClasses( element.tabs( "widget" ), "ui-tabs-disabled" );
ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" );
- // disabled active tab
+ // Disabled active tab
element.tabs( "option", "disabled", [ 0, 1 ] );
disabled( element, [ 0, 1 ] );
@@ -180,54 +180,54 @@ test( "disabled", function( assert ) {
assert.lacksClasses( element.tabs( "widget" ), "ui-tabs-disabled" );
ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" );
- // disable all tabs
+ // Disable all tabs
element.tabs( "option", "disabled", [ 0, 1, 2 ] );
disabled( element, true );
assert.lacksClasses( element.tabs( "widget" ), "ui-state-disabled" );
- assert.lacksClasses( element.tabs( "widget" ), "ui-tabs-disabled" );
+ assert.hasClasses( element.tabs( "widget" ), "ui-tabs-disabled" );
ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" );
event = $.Event( "click" );
element.find( ".ui-tabs-anchor" ).eq( 0 ).trigger( event );
ok( event.isDefaultPrevented(), "click is prevented for disabled tab" );
- // enable all tabs
+ // Enable all tabs
element.tabs( "option", "disabled", [] );
disabled( element, false );
-});
+} );
test( "{ event: null }", function() {
expect( 5 );
- var element = $( "#tabs1" ).tabs({
+ var element = $( "#tabs1" ).tabs( {
event: null
- });
+ } );
state( element, 1, 0, 0 );
element.tabs( "option", "active", 1 );
equal( element.tabs( "option", "active" ), 1 );
state( element, 0, 1, 0 );
- // ensure default click handler isn't bound
+ // Ensure default click handler isn't bound
element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 2 ).trigger( "click" );
equal( element.tabs( "option", "active" ), 1 );
state( element, 0, 1, 0 );
-});
+} );
test( "{ event: custom }", function() {
expect( 11 );
- var element = $( "#tabs1" ).tabs({
+ var element = $( "#tabs1" ).tabs( {
event: "custom1 custom2"
- });
+ } );
state( element, 1, 0, 0 );
element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 1 ).trigger( "custom1" );
equal( element.tabs( "option", "active" ), 1 );
state( element, 0, 1, 0 );
- // ensure default click handler isn't bound
+ // Ensure default click handler isn't bound
element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 2 ).trigger( "click" );
equal( element.tabs( "option", "active" ), 1 );
state( element, 0, 1, 0 );
@@ -238,7 +238,7 @@ test( "{ event: custom }", function() {
element.tabs( "option", "event", "custom3" );
- // ensure old event handlers are unbound
+ // Ensure old event handlers are unbound
element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 1 ).trigger( "custom1" );
equal( element.tabs( "option", "active" ), 2 );
state( element, 0, 0, 1 );
@@ -246,88 +246,88 @@ test( "{ event: custom }", function() {
element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 1 ).trigger( "custom3" );
equal( element.tabs( "option", "active" ), 1 );
state( element, 0, 1, 0 );
-});
+} );
test( "{ heightStyle: 'auto' }", function() {
expect( 2 );
- var element = $( "#tabs8" ).tabs({ heightStyle: "auto" });
+ var element = $( "#tabs8" ).tabs( { heightStyle: "auto" } );
equalHeight( element, 45 );
-});
+} );
test( "{ heightStyle: 'content' }", function() {
expect( 2 );
- var element = $( "#tabs8" ).tabs({ heightStyle: "content" }),
- sizes = element.find( ".ui-tabs-panel" ).map(function() {
+ var element = $( "#tabs8" ).tabs( { heightStyle: "content" } ),
+ sizes = element.find( ".ui-tabs-panel" ).map( function() {
return $( this ).height();
- }).get();
+ } ).get();
equal( sizes[ 0 ], 45 );
equal( sizes[ 1 ], 15 );
-});
+} );
test( "{ heightStyle: 'fill' }", function() {
expect( 4 );
$( "#tabs8Wrapper" ).height( 500 );
- var element = $( "#tabs8" ).tabs({ heightStyle: "fill" });
+ var element = $( "#tabs8" ).tabs( { heightStyle: "fill" } );
equalHeight( element, 485 );
element.tabs( "destroy" );
- element = $( "#tabs8" ).css({
+ element = $( "#tabs8" ).css( {
"border": "1px solid black",
"padding": "1px 0"
- });
- element.tabs({ heightStyle: "fill" });
+ } );
+ element.tabs( { heightStyle: "fill" } );
equalHeight( element, 481 );
-});
+} );
test( "{ heightStyle: 'fill' } with sibling", function() {
expect( 2 );
$( "#tabs8Wrapper" ).height( 500 );
$( "<p>Lorem Ipsum</p>" )
- .css({
+ .css( {
height: 50,
marginTop: 20,
marginBottom: 30
- })
+ } )
.prependTo( "#tabs8Wrapper" );
- var element = $( "#tabs8" ).tabs({ heightStyle: "fill" });
+ var element = $( "#tabs8" ).tabs( { heightStyle: "fill" } );
equalHeight( element, 385 );
-});
+} );
test( "{ heightStyle: 'fill' } with multiple siblings", function() {
expect( 2 );
$( "#tabs8Wrapper" ).height( 500 );
$( "<p>Lorem Ipsum</p>" )
- .css({
+ .css( {
height: 50,
marginTop: 20,
marginBottom: 30
- })
+ } )
.prependTo( "#tabs8Wrapper" );
$( "<p>Lorem Ipsum</p>" )
- .css({
+ .css( {
height: 50,
marginTop: 20,
marginBottom: 30,
position: "absolute"
- })
+ } )
.prependTo( "#tabs8Wrapper" );
$( "<p>Lorem Ipsum</p>" )
- .css({
+ .css( {
height: 25,
marginTop: 10,
marginBottom: 15
- })
+ } )
.prependTo( "#tabs8Wrapper" );
- var element = $( "#tabs8" ).tabs({ heightStyle: "fill" });
+ var element = $( "#tabs8" ).tabs( { heightStyle: "fill" } );
equalHeight( element, 335 );
-});
+} );
test( "hide and show: false", function() {
expect( 3 );
- var element = $( "#tabs1" ).tabs({
+ var element = $( "#tabs1" ).tabs( {
show: false,
hide: false
- }),
+ } ),
widget = element.tabs( "instance" ),
panels = element.find( ".ui-tabs-panel" );
widget._show = function() {
@@ -341,34 +341,34 @@ test( "hide and show: false", function() {
element.tabs( "option", "active", 1 );
ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
-});
+} );
asyncTest( "hide and show - animation", function() {
expect( 5 );
- var element = $( "#tabs1" ).tabs({
+ var element = $( "#tabs1" ).tabs( {
show: "drop",
hide: 2000
- }),
+ } ),
widget = element.tabs( "instance" ),
panels = element.find( ".ui-tabs-panel" );
widget._show = function( element, options, callback ) {
strictEqual( element[ 0 ], panels[ 1 ], "correct element in _show()" );
equal( options, "drop", "correct options in _show()" );
- setTimeout(function() {
+ setTimeout( function() {
callback();
- });
+ } );
};
widget._hide = function( element, options, callback ) {
strictEqual( element[ 0 ], panels[ 0 ], "correct element in _hide()" );
equal( options, 2000, "correct options in _hide()" );
- setTimeout(function() {
+ setTimeout( function() {
callback();
start();
- });
+ } );
};
ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
element.tabs( "option", "active", 1 );
-});
+} );
} );
diff --git a/tests/unit/tooltip/common-deprecated.js b/tests/unit/tooltip/common-deprecated.js
index 9e3c5ef59..2a5437335 100644
--- a/tests/unit/tooltip/common-deprecated.js
+++ b/tests/unit/tooltip/common-deprecated.js
@@ -21,11 +21,11 @@ common.testWidget( "tooltip", {
tooltipClass: null,
track: false,
- // callbacks
+ // Callbacks
close: null,
create: null,
open: null
}
-});
+} );
} );
diff --git a/tests/unit/tooltip/common.js b/tests/unit/tooltip/common.js
index 77e3f02b8..73797fe49 100644
--- a/tests/unit/tooltip/common.js
+++ b/tests/unit/tooltip/common.js
@@ -20,11 +20,11 @@ common.testWidget( "tooltip", {
show: true,
track: false,
- // callbacks
+ // Callbacks
close: null,
create: null,
open: null
}
-});
+} );
} );
diff --git a/tests/unit/tooltip/core.js b/tests/unit/tooltip/core.js
index e7e22b0e6..0dfdc5825 100644
--- a/tests/unit/tooltip/core.js
+++ b/tests/unit/tooltip/core.js
@@ -21,7 +21,7 @@ test( "markup structure", function( assert ) {
equal( tooltip.length, 1, ".ui-tooltip exists" );
equal( tooltip.find( ".ui-tooltip-content" ).length, 1,
".ui-tooltip-content exists" );
-});
+} );
test( "accessibility", function() {
expect( 15 );
@@ -61,7 +61,7 @@ test( "accessibility", function() {
element.tooltip( "destroy" );
equal( liveRegion.parent().length, 0,
"Tooltip liveregion element should be removed" );
-});
+} );
test( "delegated removal", function() {
expect( 2 );
@@ -74,32 +74,32 @@ test( "delegated removal", function() {
container.empty();
equal( $( ".ui-tooltip" ).length, 0 );
-});
+} );
test( "nested tooltips", function() {
expect( 2 );
var child = $( "#contained-tooltipped" ),
- parent = $( "#contains-tooltipped" ).tooltip({
+ parent = $( "#contains-tooltipped" ).tooltip( {
show: null,
hide: null
- });
+ } );
parent.trigger( "mouseover" );
equal( $( ".ui-tooltip:visible" ).text(), "parent" );
child.trigger( "mouseover" );
equal( $( ".ui-tooltip" ).text(), "child" );
-});
+} );
// #8742
test( "form containing an input with name title", function() {
expect( 4 );
- var form = $( "#tooltip-form" ).tooltip({
+ var form = $( "#tooltip-form" ).tooltip( {
show: null,
hide: null
- }),
+ } ),
input = form.find( "[name=title]" );
equal( $( ".ui-tooltip" ).length, 0, "no tooltips on init" );
@@ -111,7 +111,7 @@ test( "form containing an input with name title", function() {
form.trigger( "mouseover" );
equal( $( ".ui-tooltip" ).length, 0, "no tooltip for form" );
-});
+} );
test( "tooltip on .ui-state-disabled element", function() {
expect( 2 );
@@ -124,18 +124,18 @@ test( "tooltip on .ui-state-disabled element", function() {
container.empty();
equal( $( ".ui-tooltip" ).length, 0 );
-});
+} );
// http://bugs.jqueryui.com/ticket/8740
asyncTest( "programmatic focus with async content", function() {
expect( 2 );
- var element = $( "#tooltipped1" ).tooltip({
+ var element = $( "#tooltipped1" ).tooltip( {
content: function( response ) {
- setTimeout(function() {
+ setTimeout( function() {
response( "test" );
- });
+ } );
}
- });
+ } );
element.on( "tooltipopen", function( event ) {
deepEqual( event.originalEvent.type, "focusin" );
@@ -143,35 +143,35 @@ asyncTest( "programmatic focus with async content", function() {
element.on( "tooltipclose", function( event ) {
deepEqual( event.originalEvent.type, "focusout" );
start();
- });
+ } );
- setTimeout(function() {
+ setTimeout( function() {
element.trigger( "blur" );
- });
- });
+ } );
+ } );
element.trigger( "focus" );
-});
+} );
asyncTest( "destroy during hide animation; only one close event", function() {
expect( 1 );
- var element = $( "#tooltipped1" ).tooltip({
+ var element = $( "#tooltipped1" ).tooltip( {
show: false,
hide: true
- });
+ } );
element.on( "tooltipclose", function() {
ok( true, "tooltip closed" );
- });
+ } );
element.tooltip( "open" );
element.tooltip( "close" );
- setTimeout(function() {
+ setTimeout( function() {
element.tooltip( "destroy" );
start();
- });
-});
+ } );
+} );
// http://bugs.jqueryui.com/ticket/10602
asyncTest( "multiple active delegated tooltips", function() {
@@ -181,7 +181,7 @@ asyncTest( "multiple active delegated tooltips", function() {
input = anchor.next(),
actions = [];
- $( document ).tooltip({
+ $( document ).tooltip( {
show: false,
hide: false,
open: function( event, ui ) {
@@ -190,7 +190,7 @@ asyncTest( "multiple active delegated tooltips", function() {
close: function( event, ui ) {
actions.push( "close:" + ui.tooltip.text() );
}
- });
+ } );
function step1() {
anchor.simulate( "mouseover" );
@@ -219,7 +219,7 @@ asyncTest( "multiple active delegated tooltips", function() {
}
step1();
-});
+} );
// http://bugs.jqueryui.com/ticket/11272
test( "remove conflicting attributes from live region", function() {
@@ -234,7 +234,7 @@ test( "remove conflicting attributes from live region", function() {
"</div>" );
$( "#tooltipped1" )
- .tooltip({
+ .tooltip( {
content: element,
open: function() {
equal( $( ".ui-helper-hidden-accessible [name]" ).length, 0,
@@ -242,8 +242,8 @@ test( "remove conflicting attributes from live region", function() {
equal( $( ".ui-helper-hidden-accessible [id]" ).length, 0,
"no id attributes within live region" );
}
- })
+ } )
.tooltip( "open" );
-});
+} );
} );
diff --git a/tests/unit/tooltip/deprecated.js b/tests/unit/tooltip/deprecated.js
index b1325057b..7fc7d91a4 100644
--- a/tests/unit/tooltip/deprecated.js
+++ b/tests/unit/tooltip/deprecated.js
@@ -7,10 +7,10 @@ module( "tooltip: (deprecated) options" );
test( "tooltipClass", function( assert ) {
expect( 1 );
- var element = $( "#tooltipped1" ).tooltip({
+ var element = $( "#tooltipped1" ).tooltip( {
tooltipClass: "custom"
- }).tooltip( "open" );
+ } ).tooltip( "open" );
assert.hasClasses( $( "#" + element.data( "ui-tooltip-id" ) ), "custom" );
-});
+} );
} );
diff --git a/tests/unit/tooltip/events.js b/tests/unit/tooltip/events.js
index 7ad36dc08..3cf65fc4e 100644
--- a/tests/unit/tooltip/events.js
+++ b/tests/unit/tooltip/events.js
@@ -13,17 +13,17 @@ test( "programmatic triggers", function() {
element.one( "tooltipopen", function( event, ui ) {
tooltip = ui.tooltip;
ok( !( "originalEvent" in event ), "open" );
- strictEqual( ui.tooltip[0],
- $( "#" + element.data( "ui-tooltip-id" ) )[0], "ui.tooltip" );
- });
+ strictEqual( ui.tooltip[ 0 ],
+ $( "#" + element.data( "ui-tooltip-id" ) )[ 0 ], "ui.tooltip" );
+ } );
element.tooltip( "open" );
element.one( "tooltipclose", function( event, ui ) {
ok( !( "originalEvent" in event ), "close" );
- strictEqual( ui.tooltip[0], tooltip[0], "ui.tooltip" );
- });
+ strictEqual( ui.tooltip[ 0 ], tooltip[ 0 ], "ui.tooltip" );
+ } );
element.tooltip( "close" );
-});
+} );
test( "mouse events", function() {
expect( 2 );
@@ -31,15 +31,15 @@ test( "mouse events", function() {
element.on( "tooltipopen", function( event ) {
deepEqual( event.originalEvent.type, "mouseover" );
- });
+ } );
element.trigger( "mouseover" );
element.on( "tooltipclose", function( event ) {
deepEqual( event.originalEvent.type, "mouseleave" );
- });
+ } );
element.trigger( "focusout" );
element.trigger( "mouseleave" );
-});
+} );
test( "focus events", function() {
expect( 2 );
@@ -47,14 +47,14 @@ test( "focus events", function() {
element.on( "tooltipopen", function( event ) {
deepEqual( event.originalEvent.type, "focusin" );
- });
+ } );
element.trigger( "focusin" );
element.on( "tooltipclose", function( event ) {
deepEqual( event.originalEvent.type, "focusout" );
- });
+ } );
element.trigger( "mouseleave" );
element.trigger( "focusout" );
-});
+} );
} );
diff --git a/tests/unit/tooltip/methods.js b/tests/unit/tooltip/methods.js
index b5b6ca6e9..31fe86532 100644
--- a/tests/unit/tooltip/methods.js
+++ b/tests/unit/tooltip/methods.js
@@ -11,17 +11,17 @@ test( "destroy", function( assert ) {
assert.domEqual( "#tooltipped1", function() {
element.tooltip().tooltip( "destroy" );
- });
+ } );
- // make sure that open tooltips are removed on destroy
+ // Make sure that open tooltips are removed on destroy
assert.domEqual( "#tooltipped1", function() {
element
.tooltip()
- .tooltip( "open", $.Event( "mouseover", { target: element[0] }) )
+ .tooltip( "open", $.Event( "mouseover", { target: element[ 0 ] } ) )
.tooltip( "destroy" );
- });
+ } );
equal( $( ".ui-tooltip" ).length, 0 );
-});
+} );
test( "open/close", function() {
expect( 3 );
@@ -37,14 +37,14 @@ test( "open/close", function() {
element.tooltip( "close" );
ok( tooltip.is( ":hidden" ) );
$.fx.off = false;
-});
+} );
// #8626 - Calling open() without an event
test( "open/close with tracking", function() {
expect( 3 );
$.fx.off = true;
var tooltip,
- element = $( "#tooltipped1" ).tooltip({ track: true });
+ element = $( "#tooltipped1" ).tooltip( { track: true } );
equal( $( ".ui-tooltip" ).length, 0, "no tooltip on init" );
element.tooltip( "open" );
@@ -54,7 +54,7 @@ test( "open/close with tracking", function() {
element.tooltip( "close" );
ok( tooltip.is( ":hidden" ) );
$.fx.off = false;
-});
+} );
test( "enable/disable", function( assert ) {
expect( 11 );
@@ -91,7 +91,7 @@ test( "enable/disable", function( assert ) {
tooltip = $( "#" + element.data( "ui-tooltip-id" ) );
ok( tooltip.is( ":visible" ) );
$.fx.off = false;
-});
+} );
test( "widget", function() {
expect( 2 );
@@ -99,7 +99,7 @@ test( "widget", function() {
widgetElement = element.tooltip( "widget" );
equal( widgetElement.length, 1, "one element" );
strictEqual( widgetElement[ 0 ], element[ 0 ], "same element" );
-});
+} );
test( "preserve changes to title attributes on close and destroy", function() {
expect( 6 );
@@ -110,14 +110,19 @@ test( "preserve changes to title attributes on close and destroy", function() {
// 1. Changes to title attribute are preserved on close()
tests[ 0 ] = { title: changed, expected: changed, method: "close" };
+
// 2. Changes to title attribute are preserved on destroy()
- tests[ 1 ] = { title: changed, expected: changed , method: "destroy" };
+ tests[ 1 ] = { title: changed, expected: changed, method: "destroy" };
+
// 3. Changes to title attribute are NOT preserved when set to empty string on close()
tests[ 2 ] = { title: "", expected: original, method: "close" };
+
// 4. Changes to title attribute are NOT preserved when set to empty string on destroy()
tests[ 3 ] = { title: "", expected: original, method: "destroy" };
+
// 5. Changes to title attribute NOT preserved when attribute has been removed on close()
tests[ 4 ] = { expected: original, method: "close" };
+
// 6. Changes to title attribute NOT preserved when attribute has been removed on destroy()
tests[ 5 ] = { expected: original, method: "destroy" };
@@ -134,6 +139,6 @@ test( "preserve changes to title attributes on close and destroy", function() {
equal( $( "#tooltipped1" ).attr( "title" ), test.expected );
} );
-});
+} );
} );
diff --git a/tests/unit/tooltip/options.js b/tests/unit/tooltip/options.js
index 6aa576583..a35d140fb 100644
--- a/tests/unit/tooltip/options.js
+++ b/tests/unit/tooltip/options.js
@@ -7,17 +7,17 @@ module( "tooltip: options" );
test( "disabled: true", function() {
expect( 1 );
- $( "#tooltipped1" ).tooltip({
+ $( "#tooltipped1" ).tooltip( {
disabled: true
- }).tooltip( "open" );
+ } ).tooltip( "open" );
equal( $( ".ui-tooltip" ).length, 0 );
-});
+} );
test( "content: default", function() {
expect( 1 );
var element = $( "#tooltipped1" ).tooltip().tooltip( "open" );
deepEqual( $( "#" + element.data( "ui-tooltip-id" ) ).text(), "anchortitle" );
-});
+} );
test( "content: default; HTML escaping", function() {
expect( 2 );
@@ -31,143 +31,143 @@ test( "content: default; HTML escaping", function() {
equal( $.ui.tooltip.hacked, false, "script did not execute" );
deepEqual( $( "#" + element.data( "ui-tooltip-id" ) ).text(), scriptText,
"correct tooltip text" );
-});
+} );
test( "content: return string", function() {
expect( 1 );
- var element = $( "#tooltipped1" ).tooltip({
+ var element = $( "#tooltipped1" ).tooltip( {
content: function() {
return "customstring";
}
- }).tooltip( "open" );
+ } ).tooltip( "open" );
deepEqual( $( "#" + element.data( "ui-tooltip-id" ) ).text(), "customstring" );
-});
+} );
test( "content: return jQuery", function() {
expect( 2 );
- var element = $( "#tooltipped1" ).tooltip({
+ var element = $( "#tooltipped1" ).tooltip( {
content: function() {
return $( "<div id='unique'>" ).html( "cu<b id='bold'>s</b>tomstring" );
}
- }).tooltip( "open" ),
+ } ).tooltip( "open" ),
liveRegion = element.tooltip( "instance" ).liveRegion;
deepEqual( $( "#" + element.data( "ui-tooltip-id" ) ).text(), "customstring" );
equal( liveRegion.children().last().html().toLowerCase(), "<div>cu<b>s</b>tomstring</div>",
"The accessibility live region will strip the ids but keep the structure" );
-});
+} );
asyncTest( "content: sync + async callback", function() {
expect( 2 );
- var element = $( "#tooltipped1" ).tooltip({
+ var element = $( "#tooltipped1" ).tooltip( {
content: function( response ) {
- setTimeout(function() {
- deepEqual( $( "#" + element.data("ui-tooltip-id") ).text(), "loading..." );
+ setTimeout( function() {
+ deepEqual( $( "#" + element.data( "ui-tooltip-id" ) ).text(), "loading..." );
response( "customstring2" );
- setTimeout(function() {
- deepEqual( $( "#" + element.data("ui-tooltip-id") ).text(), "customstring2" );
+ setTimeout( function() {
+ deepEqual( $( "#" + element.data( "ui-tooltip-id" ) ).text(), "customstring2" );
start();
}, 13 );
}, 13 );
return "loading...";
}
- }).tooltip( "open" );
-});
+ } ).tooltip( "open" );
+} );
// http://bugs.jqueryui.com/ticket/8740
asyncTest( "content: async callback loses focus before load", function() {
expect( 1 );
- var element = $( "#tooltipped1" ).tooltip({
+ var element = $( "#tooltipped1" ).tooltip( {
content: function( response ) {
- setTimeout(function() {
+ setTimeout( function() {
element.trigger( "mouseleave" );
- setTimeout(function() {
+ setTimeout( function() {
response( "sometext" );
- setTimeout(function() {
+ setTimeout( function() {
ok( !$( "#" + element.data( "ui-tooltip-id" ) ).is( ":visible" ),
"Tooltip should not display" );
start();
- });
- });
- });
+ } );
+ } );
+ } );
}
- });
+ } );
element.trigger( "mouseover" );
-});
+} );
test( "content: change while open", function() {
expect( 2 ) ;
- var element = $( "#tooltipped1" ).tooltip({
+ var element = $( "#tooltipped1" ).tooltip( {
content: function() {
return "old";
}
- });
+ } );
element.one( "tooltipopen", function( event, ui ) {
equal( ui.tooltip.text(), "old", "original content" );
element.tooltip( "option", "content", function() {
return "new";
- });
+ } );
equal( ui.tooltip.text(), "new", "updated content" );
- });
+ } );
element.tooltip( "open" );
-});
+} );
test( "content: string", function() {
expect( 1 );
- $( "#tooltipped1" ).tooltip({
+ $( "#tooltipped1" ).tooltip( {
content: "just a string",
open: function( event, ui ) {
equal( ui.tooltip.text(), "just a string" );
}
- }).tooltip( "open" );
-});
+ } ).tooltip( "open" );
+} );
test( "content: element", function() {
expect( 1 );
var content = "<p>this is a <i>test</i> of the emergency broadcast system.</p>",
element = $( content )[ 0 ];
- $( "#tooltipped1" ).tooltip({
+ $( "#tooltipped1" ).tooltip( {
content: element,
open: function( event, ui ) {
equal( ui.tooltip.children().html().toLowerCase(), content );
}
- }).tooltip( "open" );
-});
+ } ).tooltip( "open" );
+} );
test( "content: jQuery", function() {
expect( 1 );
var content = "<p>this is a <i>test</i> of the emergency broadcast system.</p>",
element = $( content );
- $( "#tooltipped1" ).tooltip({
+ $( "#tooltipped1" ).tooltip( {
content: element,
open: function( event, ui ) {
equal( ui.tooltip.children().html().toLowerCase(), content );
}
- }).tooltip( "open" );
-});
+ } ).tooltip( "open" );
+} );
test( "items", function() {
expect( 2 );
var event,
- element = $( "#qunit-fixture" ).tooltip({
+ element = $( "#qunit-fixture" ).tooltip( {
items: "#fixture-span"
- });
+ } );
event = $.Event( "mouseenter" );
event.target = $( "#fixture-span" )[ 0 ];
element.tooltip( "open", event );
deepEqual( $( "#" + $( "#fixture-span" ).data( "ui-tooltip-id" ) ).text(), "title-text" );
- // make sure default [title] doesn't get used
+ // Make sure default [title] doesn't get used
event.target = $( "#tooltipped1" )[ 0 ];
element.tooltip( "open", event );
deepEqual( $( "#tooltipped1" ).data( "ui-tooltip-id" ), undefined );
element.tooltip( "destroy" );
-});
+} );
test( "track + show delay", function() {
expect( 2 );
@@ -175,7 +175,7 @@ test( "track + show delay", function() {
leftVal = 314,
topVal = 159,
offsetVal = 26,
- element = $( "#tooltipped1" ).tooltip({
+ element = $( "#tooltipped1" ).tooltip( {
track: true,
show: {
delay: 1
@@ -184,7 +184,7 @@ test( "track + show delay", function() {
my: "left+" + offsetVal + " top+" + offsetVal,
at: "right bottom"
}
- });
+ } );
event = $.Event( "mouseover" );
event.target = $( "#tooltipped1" )[ 0 ];
@@ -202,14 +202,14 @@ test( "track + show delay", function() {
equal( $( ".ui-tooltip" ).css( "left" ), leftVal + offsetVal + "px" );
equal( $( ".ui-tooltip" ).css( "top" ), topVal + offsetVal + "px" );
-});
+} );
test( "track and programmatic focus", function() {
expect( 1 );
- $( "#qunit-fixture div input" ).tooltip({
+ $( "#qunit-fixture div input" ).tooltip( {
track: true
- }).trigger( "focus" );
+ } ).trigger( "focus" );
equal( "inputtitle", $( ".ui-tooltip" ).text() );
-});
+} );
} );
diff --git a/tests/unit/widget/animation.js b/tests/unit/widget/animation.js
index 4e9d93ccf..9f9f92710 100644
--- a/tests/unit/widget/animation.js
+++ b/tests/unit/widget/animation.js
@@ -3,7 +3,7 @@ define( [
"ui/widget"
], function( $ ) {
-module( "widget animation", (function() {
+module( "widget animation", ( function() {
var show = $.fn.show,
fadeIn = $.fn.fadeIn,
slideDown = $.fn.slideDown;
@@ -16,7 +16,7 @@ module( "widget animation", (function() {
show: function( fn ) {
this._show( this.element, this.options.show, fn );
}
- });
+ } );
$.effects = { effect: { testEffect: $.noop } };
},
teardown: function() {
@@ -27,7 +27,7 @@ module( "widget animation", (function() {
$.fn.slideDown = slideDown;
}
};
-}()));
+}() ) );
asyncTest( "show: null", function() {
expect( 4 );
@@ -41,223 +41,223 @@ asyncTest( "show: null", function() {
element
.delay( 50 )
- .queue(function( next ) {
+ .queue( function( next ) {
ok( !hasRun, "queue before show" );
next();
- })
+ } )
.testWidget( "show", function() {
hasRun = true;
- })
- .queue(function( next ) {
+ } )
+ .queue( function( next ) {
ok( hasRun, "queue after show" );
start();
next();
- });
-});
+ } );
+} );
asyncTest( "show: true", function() {
expect( 4 );
- var element = $( "#widget" ).testWidget({
+ var element = $( "#widget" ).testWidget( {
show: true
- }),
+ } ),
hasRun = false;
$.fn.fadeIn = function( duration, easing, complete ) {
- return this.queue(function( next ) {
+ return this.queue( function( next ) {
strictEqual( duration, undefined, "duration" );
strictEqual( easing, undefined, "easing" );
complete();
next();
- });
+ } );
};
element
.delay( 50 )
- .queue(function( next ) {
+ .queue( function( next ) {
ok( !hasRun, "queue before show" );
next();
- })
+ } )
.testWidget( "show", function() {
hasRun = true;
- })
- .queue(function( next ) {
+ } )
+ .queue( function( next ) {
ok( hasRun, "queue after show" );
start();
next();
- });
-});
+ } );
+} );
asyncTest( "show: number", function() {
expect( 4 );
- var element = $( "#widget" ).testWidget({
+ var element = $( "#widget" ).testWidget( {
show: 123
- }),
+ } ),
hasRun = false;
$.fn.fadeIn = function( duration, easing, complete ) {
- return this.queue(function( next ) {
+ return this.queue( function( next ) {
strictEqual( duration, 123, "duration" );
strictEqual( easing, undefined, "easing" );
complete();
next();
- });
+ } );
};
element
.delay( 50 )
- .queue(function( next ) {
+ .queue( function( next ) {
ok( !hasRun, "queue before show" );
next();
- })
+ } )
.testWidget( "show", function() {
hasRun = true;
- })
- .queue(function( next ) {
+ } )
+ .queue( function( next ) {
ok( hasRun, "queue after show" );
start();
next();
- });
-});
+ } );
+} );
asyncTest( "show: core animation", function() {
expect( 4 );
- var element = $( "#widget" ).testWidget({
+ var element = $( "#widget" ).testWidget( {
show: "slideDown"
- }),
+ } ),
hasRun = false;
$.fn.slideDown = function( duration, easing, complete ) {
- return this.queue(function( next ) {
+ return this.queue( function( next ) {
strictEqual( duration, undefined, "duration" );
strictEqual( easing, undefined, "easing" );
complete();
next();
- });
+ } );
};
element
.delay( 50 )
- .queue(function( next ) {
+ .queue( function( next ) {
ok( !hasRun, "queue before show" );
next();
- })
+ } )
.testWidget( "show", function() {
hasRun = true;
- })
- .queue(function( next ) {
+ } )
+ .queue( function( next ) {
ok( hasRun, "queue after show" );
start();
next();
- });
-});
+ } );
+} );
asyncTest( "show: effect", function() {
expect( 5 );
- var element = $( "#widget" ).testWidget({
+ var element = $( "#widget" ).testWidget( {
show: "testEffect"
- }),
+ } ),
hasRun = false;
$.fn.show = function( options ) {
- return this.queue(function( next ) {
+ return this.queue( function( next ) {
equal( options.effect, "testEffect", "effect" );
- ok( !("duration" in options), "duration" );
- ok( !("easing" in options), "easing" );
+ ok( !( "duration" in options ), "duration" );
+ ok( !( "easing" in options ), "easing" );
options.complete();
next();
- });
+ } );
};
element
.delay( 50 )
- .queue(function( next ) {
+ .queue( function( next ) {
ok( !hasRun, "queue before show" );
next();
- })
+ } )
.testWidget( "show", function() {
hasRun = true;
- })
- .queue(function( next ) {
+ } )
+ .queue( function( next ) {
ok( hasRun, "queue after show" );
start();
next();
- });
-});
+ } );
+} );
asyncTest( "show: object(core animation)", function() {
expect( 4 );
- var element = $( "#widget" ).testWidget({
+ var element = $( "#widget" ).testWidget( {
show: {
effect: "slideDown",
duration: 123,
easing: "testEasing"
}
- }),
+ } ),
hasRun = false;
$.fn.slideDown = function( duration, easing, complete ) {
- return this.queue(function( next ) {
+ return this.queue( function( next ) {
equal( duration, 123, "duration" );
equal( easing, "testEasing", "easing" );
complete();
next();
- });
+ } );
};
element
.delay( 50 )
- .queue(function( next ) {
+ .queue( function( next ) {
ok( !hasRun, "queue before show" );
next();
- })
+ } )
.testWidget( "show", function() {
hasRun = true;
- })
- .queue(function( next ) {
+ } )
+ .queue( function( next ) {
ok( hasRun, "queue after show" );
start();
next();
- });
-});
+ } );
+} );
asyncTest( "show: object(effect)", function() {
expect( 3 );
- var element = $( "#widget" ).testWidget({
+ var element = $( "#widget" ).testWidget( {
show: {
effect: "testEffect",
duration: 123,
easing: "testEasing"
}
- }),
+ } ),
hasRun = false;
$.fn.show = function( options ) {
- return this.queue(function( next ) {
+ return this.queue( function( next ) {
deepEqual( options, {
effect: "testEffect",
duration: 123,
easing: "testEasing",
complete: options.complete
- });
+ } );
options.complete();
next();
- });
+ } );
};
element
.delay( 50 )
- .queue(function( next ) {
+ .queue( function( next ) {
ok( !hasRun, "queue before show" );
next();
- })
+ } )
.testWidget( "show", function() {
hasRun = true;
- })
- .queue(function( next ) {
+ } )
+ .queue( function( next ) {
ok( hasRun, "queue after show" );
start();
next();
- });
-});
+ } );
+} );
} );
diff --git a/tests/unit/widget/classes.js b/tests/unit/widget/classes.js
index 1b4a45120..b837aac34 100644
--- a/tests/unit/widget/classes.js
+++ b/tests/unit/widget/classes.js
@@ -48,13 +48,13 @@ module( "widget factory classes", {
this.span.remove();
this.element.unwrap();
}
- });
+ } );
},
teardown: function() {
delete $.ui.classesWidget;
delete $.fn.classesWidget;
}
-});
+} );
function elementHasClasses( widget, method, assert ) {
var toggle = method === "toggle" ? ( ", true" ) : "";
@@ -96,13 +96,13 @@ test( ".option() - classes setter", function( assert ) {
elementHasClasses( testWidget.element, "add", assert );
- testWidget.option({
+ testWidget.option( {
classes: {
"ui-classes-span": "custom-theme-span",
"ui-classes-widget": "ui-theme-widget custom-theme-widget",
"ui-classes-element": "ui-theme-element-2"
}
- });
+ } );
assert.lacksClasses( testWidget.element, "ui-theme-element",
"Removing a class from the value removes the class" );
@@ -116,15 +116,15 @@ test( ".option() - classes setter", function( assert ) {
"Adding a class to an empty value works as expected" );
assert.hasClasses( testWidget.wrapper, "ui-classes-widget custom-theme-widget",
"Appending a class to the current value works as expected" );
-});
+} );
test( ".destroy() - class removal", function( assert ) {
expect( 1 );
assert.domEqual( "#widget", function() {
$( "#widget" ).classesWidget().classesWidget( "destroy" );
- });
-});
+ } );
+} );
test( "._add/_remove/_toggleClass()", function( assert ) {
expect( 24 );
@@ -141,6 +141,6 @@ test( "._add/_remove/_toggleClass()", function( assert ) {
widget.classesWidget( "removeClasses" );
elementLacksClasses( widget, "remove", assert );
-});
+} );
} );
diff --git a/tests/unit/widget/core.js b/tests/unit/widget/core.js
index 235bc6bb6..93bfe875a 100644
--- a/tests/unit/widget/core.js
+++ b/tests/unit/widget/core.js
@@ -11,7 +11,7 @@ module( "widget factory", {
delete $.fn.testWidget;
}
}
-});
+} );
common.testJshint( "widget" );
@@ -36,7 +36,7 @@ test( "widget creation", function() {
$.ui.testWidget.prototype.creationTest();
equal( $.ui.testWidget.prototype.option, $.Widget.prototype.option,
"option method copied over from base widget" );
-});
+} );
test( "element normalization", function() {
expect( 11 );
@@ -44,6 +44,7 @@ test( "element normalization", function() {
$.widget( "ui.testWidget", {} );
$.ui.testWidget.prototype._create = function() {
+
// workaround for core ticket #8381
this.element.appendTo( "#qunit-fixture" );
ok( this.element.is( "div" ), "generated div" );
@@ -82,20 +83,21 @@ test( "element normalization", function() {
$.ui.testWidget.prototype.defaultElement = null;
$.ui.testWidget.prototype._create = function() {
+
// using strictEqual throws an error (Maximum call stack size exceeded)
ok( this.element[ 0 ] === this, "instance as element" );
};
$.ui.testWidget();
-});
+} );
test( "custom selector expression", function() {
expect( 1 );
var elem = $( "<div>" ).appendTo( "#qunit-fixture" );
$.widget( "ui.testWidget", {} );
elem.testWidget();
- deepEqual( $( ":ui-testwidget" )[0], elem[0] );
+ deepEqual( $( ":ui-testwidget" )[ 0 ], elem[ 0 ] );
elem.testWidget( "destroy" );
-});
+} );
test( "jQuery usage", function() {
expect( 14 );
@@ -127,19 +129,19 @@ test( "jQuery usage", function() {
jQueryObject: function() {
return $( "body" );
}
- });
+ } );
shouldCreate = true;
elem = $( "<div>" )
.on( "testwidgetcreate", function() {
ok( shouldCreate, "create event triggered on instantiation" );
- })
+ } )
.testWidget();
shouldCreate = false;
instance = elem.testWidget( "instance" );
equal( typeof instance, "object", "instance stored in .data(pluginName)" );
- equal( instance.element[0], elem[0], "element stored on widget" );
+ equal( instance.element[ 0 ], elem[ 0 ], "element stored on widget" );
ret = elem.testWidget( "methodWithParams", "value1", "value2" );
equal( ret, elem, "jQuery object returned from method call" );
@@ -154,7 +156,7 @@ test( "jQuery usage", function() {
elem.testWidget( "destroy" );
equal( elem.testWidget( "instance" ), null );
-});
+} );
test( "direct usage", function() {
expect( 9 );
@@ -181,7 +183,7 @@ test( "direct usage", function() {
return this.getterSetterVal;
}
}
- });
+ } );
elem = $( "<div>" )[ 0 ];
@@ -200,14 +202,14 @@ test( "direct usage", function() {
equal( ret, 5, "getter/setter can act as getter" );
instance.getterSetterMethod( 30 );
equal( instance.getterSetterVal, 30, "getter/setter can act as setter" );
-});
+} );
test( "error handling", function() {
expect( 3 );
var error = $.error;
$.widget( "ui.testWidget", {
- _privateMethod: function () {}
- });
+ _privateMethod: function() {}
+ } );
$.error = function( msg ) {
equal( msg, "cannot call methods on testWidget prior to initialization; " +
"attempted to call method 'missing'", "method call before init" );
@@ -218,13 +220,13 @@ test( "error handling", function() {
"invalid method call on widget instance" );
};
$( "<div>" ).testWidget().testWidget( "missing" );
- $.error = function ( msg ) {
+ $.error = function( msg ) {
equal( msg, "no such method '_privateMethod' for testWidget widget instance",
"invalid method call on widget instance" );
};
$( "<div>" ).testWidget().testWidget( "_privateMethod" );
$.error = error;
-});
+} );
test( "merge multiple option arguments", function() {
expect( 1 );
@@ -241,10 +243,10 @@ test( "merge multiple option arguments", function() {
option4a: "valuea",
option4b: "valueb"
}
- });
+ } );
}
- });
- $( "<div>" ).testWidget({
+ } );
+ $( "<div>" ).testWidget( {
option1: "valuex",
option2: "valuex",
option3: "value3",
@@ -261,11 +263,11 @@ test( "merge multiple option arguments", function() {
option4: {
option4a: "valuea"
}
- });
-});
+ } );
+} );
test( "._getCreateOptions()", function() {
- expect( 3 );
+ expect( 4 );
$.widget( "ui.testWidget", {
options: {
option1: "valuex",
@@ -273,6 +275,9 @@ test( "._getCreateOptions()", function() {
option3: "value3"
},
_getCreateOptions: function() {
+ var superOptions = this._super();
+
+ deepEqual( superOptions, {}, "Base implementation returns empty object" );
// Support: IE8
// Strict equality fails when comparing this.window in ie8
@@ -292,11 +297,11 @@ test( "._getCreateOptions()", function() {
option1: "override1",
option2: "value2",
option3: "value3"
- });
+ } );
}
- });
- $( "<div>" ).testWidget({ option2: "value2" });
-});
+ } );
+ $( "<div>" ).testWidget( { option2: "value2" } );
+} );
test( "._getCreateEventData()", function() {
expect( 1 );
@@ -305,13 +310,13 @@ test( "._getCreateEventData()", function() {
_getCreateEventData: function() {
return data;
}
- });
- $( "<div>" ).testWidget({
+ } );
+ $( "<div>" ).testWidget( {
create: function( event, ui ) {
strictEqual( ui, data, "event data" );
}
- });
-});
+ } );
+} );
test( "re-init", function() {
expect( 3 );
@@ -328,10 +333,10 @@ test( "re-init", function() {
_setOption: function( key ) {
actions.push( "option" + key );
}
- });
+ } );
actions = [];
- div.testWidget({ foo: "bar" });
+ div.testWidget( { foo: "bar" } );
deepEqual( actions, [ "create", "init" ], "correct methods called on init" );
actions = [];
@@ -339,9 +344,9 @@ test( "re-init", function() {
deepEqual( actions, [ "init" ], "correct methods call on re-init" );
actions = [];
- div.testWidget({ foo: "bar" });
+ div.testWidget( { foo: "bar" } );
deepEqual( actions, [ "optionfoo", "init" ], "correct methods called on re-init with options" );
-});
+} );
test( "redeclare", function() {
expect( 2 );
@@ -351,10 +356,11 @@ test( "redeclare", function() {
$.widget( "ui.testWidget", {} );
equal( $.ui.testWidget.prototype.widgetEventPrefix, "testWidget" );
-});
+} );
test( "inheritance", function() {
expect( 6 );
+
// #5830 - Widget: Using inheritance overwrites the base classes options
$.widget( "ui.testWidgetBase", {
options: {
@@ -364,7 +370,7 @@ test( "inheritance", function() {
},
arr: [ "testing" ]
}
- });
+ } );
$.widget( "ui.testWidgetExtension", $.ui.testWidgetBase, {
options: {
@@ -373,31 +379,31 @@ test( "inheritance", function() {
},
arr: [ "alpha", "beta" ]
}
- });
+ } );
equal( $.ui.testWidgetBase.prototype.widgetEventPrefix, "testWidgetBase",
"base class event prefix" );
deepEqual( $.ui.testWidgetBase.prototype.options.obj, {
key1: "foo",
key2: "bar"
- }, "base class option object not overridden");
+ }, "base class option object not overridden" );
deepEqual( $.ui.testWidgetBase.prototype.options.arr, [ "testing" ],
- "base class option array not overridden");
+ "base class option array not overridden" );
equal( $.ui.testWidgetExtension.prototype.widgetEventPrefix, "testWidgetExtension",
"extension class event prefix" );
deepEqual( $.ui.testWidgetExtension.prototype.options.obj, {
key1: "baz",
key2: "bar"
- }, "extension class option object extends base");
+ }, "extension class option object extends base" );
deepEqual( $.ui.testWidgetExtension.prototype.options.arr, [ "alpha", "beta" ],
- "extension class option array overwrites base");
+ "extension class option array overwrites base" );
delete $.ui.testWidgetBase;
delete $.fn.testWidgetBase;
delete $.ui.testWidgetExtension;
delete $.fn.testWidgetExtension;
-});
+} );
test( "._super()", function() {
expect( 9 );
@@ -409,25 +415,25 @@ test( "._super()", function() {
deepEqual( b, 20, "second parameter passed to testWidget" );
return a + b;
}
- });
+ } );
$.widget( "ui.testWidget2", $.ui.testWidget, {
method: function( a, b ) {
deepEqual( this, instance, "this is correct in testWidget2" );
deepEqual( a, 5, "parameter passed to testWidget2" );
deepEqual( b, 10, "parameter passed to testWidget2" );
- return this._super( a, b*2 );
+ return this._super( a, b * 2 );
}
- });
+ } );
$.widget( "ui.testWidget3", $.ui.testWidget2, {
method: function( a ) {
deepEqual( this, instance, "this is correct in testWidget3" );
deepEqual( a, 5, "parameter passed to testWidget3" );
- var ret = this._super( a, a*2 );
+ var ret = this._super( a, a * 2 );
deepEqual( ret, 25, "super returned value" );
}
- });
+ } );
instance = $( "<div>" ).testWidget3().testWidget3( "instance" );
instance.method( 5 );
@@ -435,7 +441,7 @@ test( "._super()", function() {
delete $.fn.testWidget3;
delete $.ui.testWidget2;
delete $.fn.testWidget2;
-});
+} );
test( "._superApply()", function() {
expect( 10 );
@@ -447,7 +453,7 @@ test( "._superApply()", function() {
deepEqual( b, 10, "second parameter passed to testWidget" );
return a + b;
}
- });
+ } );
$.widget( "ui.testWidget2", $.ui.testWidget, {
method: function( a, b ) {
@@ -456,7 +462,7 @@ test( "._superApply()", function() {
deepEqual( b, 10, "second parameter passed to testWidget2" );
return this._superApply( arguments );
}
- });
+ } );
$.widget( "ui.testWidget3", $.ui.testWidget2, {
method: function( a, b ) {
@@ -466,7 +472,7 @@ test( "._superApply()", function() {
var ret = this._superApply( arguments );
deepEqual( ret, 15, "super returned value" );
}
- });
+ } );
instance = $( "<div>" ).testWidget3().testWidget3( "instance" );
instance.method( 5, 10 );
@@ -474,7 +480,7 @@ test( "._superApply()", function() {
delete $.fn.testWidget3;
delete $.ui.testWidget2;
delete $.fn.testWidget2;
-});
+} );
test( "mixins", function() {
expect( 5 );
@@ -513,7 +519,7 @@ test( "mixins", function() {
$.ui.testWidget.prototype.bar = function() {};
strictEqual( mixin2.bar, existingBar, "Changes to a prototype don't change the mixin" );
-});
+} );
test( "mixins with inheritance", function() {
expect( 4 );
@@ -553,25 +559,25 @@ test( "mixins with inheritance", function() {
delete $.ui.testWidget2;
delete $.fn.testWidget2;
-});
+} );
test( ".option() - getter", function() {
expect( 6 );
$.widget( "ui.testWidget", {
_create: function() {}
- });
+ } );
var options,
- div = $( "<div>" ).testWidget({
+ 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" );
- deepEqual( div.testWidget( "option", "baz"), 5, "single option - number" );
- deepEqual( div.testWidget( "option", "qux"), [ "quux", "quuux" ],
+ deepEqual( div.testWidget( "option", "foo" ), "bar", "single option - string" );
+ deepEqual( div.testWidget( "option", "baz" ), 5, "single option - number" );
+ deepEqual( div.testWidget( "option", "qux" ), [ "quux", "quuux" ],
"single option - array" );
options = div.testWidget( "option" );
@@ -584,28 +590,28 @@ test( ".option() - getter", function() {
qux: [ "quux", "quuux" ]
}, "full options hash returned" );
options.foo = "notbar";
- deepEqual( div.testWidget( "option", "foo"), "bar",
+ deepEqual( div.testWidget( "option", "foo" ), "bar",
"modifying returned options hash does not modify plugin instance" );
-});
+} );
test( ".option() - deep option getter", function() {
expect( 5 );
$.widget( "ui.testWidget", {} );
- var div = $( "<div>" ).testWidget({
+ var div = $( "<div>" ).testWidget( {
foo: {
bar: "baz",
qux: {
quux: "xyzzy"
}
}
- });
+ } );
equal( div.testWidget( "option", "foo.bar" ), "baz", "one level deep - string" );
deepEqual( div.testWidget( "option", "foo.qux" ), { quux: "xyzzy" },
"one level deep - object" );
equal( div.testWidget( "option", "foo.qux.quux" ), "xyzzy", "two levels deep - string" );
equal( div.testWidget( "option", "x.y" ), null, "top level non-existent" );
equal( div.testWidget( "option", "foo.x.y" ), null, "one level deep - non-existent" );
-});
+} );
test( ".option() - delegate to ._setOptions()", function() {
expect( 2 );
@@ -616,21 +622,21 @@ test( ".option() - delegate to ._setOptions()", function() {
_setOptions: function( options ) {
calls.push( options );
}
- });
+ } );
div = $( "<div>" ).testWidget();
calls = [];
div.testWidget( "option", "foo", "bar" );
- deepEqual( calls, [{ foo: "bar" }], "_setOptions called for single option" );
+ deepEqual( calls, [ { foo: "bar" } ], "_setOptions called for single option" );
calls = [];
div.testWidget( "option", {
bar: "qux",
quux: "quuux"
- });
- deepEqual( calls, [{ bar: "qux", quux: "quuux" }],
+ } );
+ deepEqual( calls, [ { bar: "qux", quux: "quuux" } ],
"_setOptions called with multiple options" );
-});
+} );
test( ".option() - delegate to ._setOption()", function() {
expect( 3 );
@@ -639,34 +645,34 @@ test( ".option() - delegate to ._setOption()", function() {
$.widget( "ui.testWidget", {
_create: function() {},
_setOption: function( key, val ) {
- calls.push({
+ calls.push( {
key: key,
val: val
- });
+ } );
}
- });
+ } );
div = $( "<div>" ).testWidget();
calls = [];
div.testWidget( "option", "foo", "bar" );
- deepEqual( calls, [{ key: "foo", val: "bar" }],
+ deepEqual( calls, [ { key: "foo", val: "bar" } ],
"_setOption called for single option" );
calls = [];
div.testWidget( "option", "foo", undefined );
- deepEqual( calls, [{ key: "foo", val: undefined }],
+ deepEqual( calls, [ { key: "foo", val: undefined } ],
"_setOption called for single option where value is undefined" );
calls = [];
div.testWidget( "option", {
bar: "qux",
quux: "quuux"
- });
+ } );
deepEqual( calls, [
{ key: "bar", val: "qux" },
{ key: "quux", val: "quuux" }
], "_setOption called with multiple options" );
-});
+} );
test( ".option() - deep option setter", function() {
expect( 9 );
@@ -697,7 +703,7 @@ test( ".option() - deep option setter", function() {
{ bar: "baz", qux: { quux: "quuux", newOpt: "newVal" } },
"add property" );
div.testWidget( "option", "foo.qux.newOpt", "newVal" );
-});
+} );
test( ".enable()", function() {
expect( 2 );
@@ -707,9 +713,9 @@ test( ".enable()", function() {
deepEqual( key, "disabled", "_setOption called with disabled option" );
deepEqual( val, false, "disabled set to false" );
}
- });
+ } );
$( "<div>" ).testWidget().testWidget( "enable" );
-});
+} );
test( ".disable()", function() {
expect( 2 );
@@ -719,19 +725,52 @@ test( ".disable()", function() {
deepEqual( key, "disabled", "_setOption called with disabled option" );
deepEqual( val, true, "disabled set to true" );
}
- });
+ } );
$( "<div>" ).testWidget().testWidget( "disable" );
-});
+} );
+
+test( "._setOptionDisabled()", function() {
+ expect( 3 );
+
+ var method;
+ var widget;
+
+ $.widget( "ui.testWidget", {
+ _setOptionDisabled: function( value ) {
+ method( value );
+ }
+ } );
+
+ method = function() {
+ ok( false, "._setOptionDisabled() called on init when not disabled" );
+ };
+ $( "<div>" ).testWidget();
+
+ method = function( value ) {
+ strictEqual( value, true, "._setOptionDisabled called on init when disabled" );
+ };
+ widget = $( "<div>" ).testWidget( { disabled: true } );
+
+ method = function( value ) {
+ strictEqual( value, false, "._setOptionDisabled called when enabling" );
+ };
+ widget.testWidget( "enable" );
+
+ method = function( value ) {
+ strictEqual( value, true, "._setOptionDisabled called when disabling" );
+ };
+ widget.testWidget( "option", "disabled", true );
+} );
test( ".widget() - base", function() {
expect( 2 );
var constructor = $.widget( "ui.testWidget", {
_create: function() {}
- }),
+ } ),
div = $( "<div>" ).testWidget();
- deepEqual( div[0], div.testWidget( "widget" )[0]);
+ deepEqual( div[ 0 ], div.testWidget( "widget" )[ 0 ] );
deepEqual( constructor, $.ui.testWidget, "$.widget returns the constructor" );
-});
+} );
test( ".widget() - overriden", function() {
expect( 1 );
@@ -741,9 +780,9 @@ test( ".widget() - overriden", function() {
widget: function() {
return wrapper;
}
- });
- deepEqual( wrapper[0], $( "<div>" ).testWidget().testWidget( "widget" )[0] );
-});
+ } );
+ deepEqual( wrapper[ 0 ], $( "<div>" ).testWidget().testWidget( "widget" )[ 0 ] );
+} );
test( ".instance()", function() {
expect( 2 );
@@ -751,13 +790,13 @@ test( ".instance()", function() {
$.widget( "ui.testWidget", {
_create: function() {}
- });
+ } );
div = $( "<div>" );
equal( div.testWidget( "instance" ), undefined );
div.testWidget();
equal( div.testWidget( "instance" ), div.testWidget( "instance" ) );
-});
+} );
test( "._on() to element (default)", function() {
expect( 12 );
@@ -765,22 +804,22 @@ test( "._on() to element (default)", function() {
$.widget( "ui.testWidget", {
_create: function() {
that = this;
- this._on({
+ this._on( {
keyup: this.keyup,
keydown: "keydown"
- });
+ } );
},
keyup: function( event ) {
equal( that, this );
- equal( that.element[0], event.currentTarget );
+ equal( that.element[ 0 ], event.currentTarget );
equal( "keyup", event.type );
},
keydown: function( event ) {
equal( that, this );
- equal( that.element[0], event.currentTarget );
+ equal( that.element[ 0 ], event.currentTarget );
equal( "keydown", event.type );
}
- });
+ } );
widget = $( "<div></div>" )
.testWidget()
.trigger( "keyup" )
@@ -797,7 +836,7 @@ test( "._on() to element (default)", function() {
.testWidget( "destroy" )
.trigger( "keyup" )
.trigger( "keydown" );
-});
+} );
test( "._on() to element with suppressDisabledCheck", function() {
expect( 18 );
@@ -808,19 +847,19 @@ test( "._on() to element with suppressDisabledCheck", function() {
this._on( true, {
keyup: this.keyup,
keydown: "keydown"
- });
+ } );
},
keyup: function( event ) {
equal( that, this );
- equal( that.element[0], event.currentTarget );
+ equal( that.element[ 0 ], event.currentTarget );
equal( "keyup", event.type );
},
keydown: function( event ) {
equal( that, this );
- equal( that.element[0], event.currentTarget );
+ equal( that.element[ 0 ], event.currentTarget );
equal( "keydown", event.type );
}
- });
+ } );
widget = $( "<div></div>" )
.testWidget()
.trigger( "keyup" )
@@ -837,7 +876,7 @@ test( "._on() to element with suppressDisabledCheck", function() {
.testWidget( "destroy" )
.trigger( "keyup" )
.trigger( "keydown" );
-});
+} );
test( "._on() to descendent", function() {
expect( 12 );
@@ -848,19 +887,20 @@ test( "._on() to descendent", function() {
this._on( this.element.find( "strong" ), {
keyup: this.keyup,
keydown: "keydown"
- });
+ } );
},
keyup: function( event ) {
equal( that, this );
- equal( that.element.find( "strong" )[0], event.currentTarget );
+ equal( that.element.find( "strong" )[ 0 ], event.currentTarget );
equal( "keyup", event.type );
},
- keydown: function(event) {
+ keydown: function( event ) {
equal( that, this );
- equal( that.element.find( "strong" )[0], event.currentTarget );
+ equal( that.element.find( "strong" )[ 0 ], event.currentTarget );
equal( "keydown", event.type );
}
- });
+ } );
+
// trigger events on both widget and descendent to ensure that only descendent receives them
widget = $( "<div><p><strong>hello</strong> world</p></div>" )
.testWidget()
@@ -894,7 +934,7 @@ test( "._on() to descendent", function() {
descendant
.trigger( "keyup" )
.trigger( "keydown" );
-});
+} );
test( "_on() with delegate", function() {
expect( 8 );
@@ -904,7 +944,7 @@ test( "_on() with delegate", function() {
this.element = {
on: function( event, handler ) {
equal( event, "click.testWidget" + uuid );
- ok( $.isFunction(handler) );
+ ok( $.isFunction( handler ) );
},
trigger: $.noop
};
@@ -913,30 +953,30 @@ test( "_on() with delegate", function() {
on: function( event, selector, handler ) {
equal( selector, "a" );
equal( event, "click.testWidget" + uuid );
- ok( $.isFunction(handler) );
+ ok( $.isFunction( handler ) );
}
};
};
- this._on({
+ this._on( {
"click": "handler",
"click a": "handler"
- });
+ } );
this.widget = function() {
return {
on: function( event, selector, handler ) {
equal( selector, "form fieldset > input" );
equal( event, "change.testWidget" + uuid );
- ok( $.isFunction(handler) );
+ ok( $.isFunction( handler ) );
}
};
};
- this._on({
+ this._on( {
"change form fieldset > input": "handler"
- });
+ } );
}
- });
+ } );
$.ui.testWidget();
-});
+} );
test( "_on() with delegate to descendent", function() {
expect( 4 );
@@ -947,7 +987,7 @@ test( "_on() with delegate to descendent", function() {
this._on( this.target, {
"keyup": "handlerDirect",
"keyup strong": "handlerDelegated"
- });
+ } );
this.child.trigger( "keyup" );
},
handlerDirect: function( event ) {
@@ -958,9 +998,9 @@ test( "_on() with delegate to descendent", function() {
deepEqual( event.currentTarget, this.child[ 0 ] );
deepEqual( event.target, this.child[ 0 ] );
}
- });
+ } );
$.ui.testWidget();
-});
+} );
test( "_on() to common element", function() {
expect( 4 );
@@ -971,7 +1011,7 @@ test( "_on() to common element", function() {
"with:colons": "_colonHandler",
"with-dashes": "_dashHandler",
"with-dashes:and-colons": "_commbinedHandler"
- });
+ } );
},
_handler: function() {
ok( true, "handler triggered" );
@@ -985,7 +1025,7 @@ test( "_on() to common element", function() {
_commbinedHandler: function() {
ok( true, "combined handler triggered" );
}
- });
+ } );
var widget = $( "#widget" ).testWidget().testWidget( "instance" );
$( "#widget-wrapper" ).testWidget();
widget.destroy();
@@ -993,7 +1033,7 @@ test( "_on() to common element", function() {
$( document ).trigger( "with:colons" );
$( document ).trigger( "with-dashes" );
$( document ).trigger( "with-dashes:and-colons" );
-});
+} );
test( "_off() - single event", function() {
expect( 3 );
@@ -1004,17 +1044,17 @@ test( "_off() - single event", function() {
widget = element.testWidget().testWidget( "instance" );
widget._on( element, { foo: function() {
ok( shouldTriggerWidget, "foo called from _on" );
- }});
+ } } );
element.on( "foo", function() {
ok( shouldTriggerOther, "foo called from bind" );
- });
+ } );
shouldTriggerWidget = true;
shouldTriggerOther = true;
element.trigger( "foo" );
shouldTriggerWidget = false;
widget._off( element, "foo" );
element.trigger( "foo" );
-});
+} );
test( "_off() - multiple events", function() {
expect( 6 );
@@ -1030,10 +1070,10 @@ test( "_off() - multiple events", function() {
bar: function() {
ok( shouldTriggerWidget, "bar called from _on" );
}
- });
+ } );
element.on( "foo bar", function( event ) {
ok( shouldTriggerOther, event.type + " called from bind" );
- });
+ } );
shouldTriggerWidget = true;
shouldTriggerOther = true;
element.trigger( "foo" );
@@ -1042,7 +1082,7 @@ test( "_off() - multiple events", function() {
widget._off( element, "foo bar" );
element.trigger( "foo" );
element.trigger( "bar" );
-});
+} );
test( "_off() - all events", function() {
expect( 6 );
@@ -1058,10 +1098,10 @@ test( "_off() - all events", function() {
bar: function() {
ok( shouldTriggerWidget, "bar called from _on" );
}
- });
+ } );
element.on( "foo bar", function( event ) {
ok( shouldTriggerOther, event.type + " called from bind" );
- });
+ } );
shouldTriggerWidget = true;
shouldTriggerOther = true;
element.trigger( "foo" );
@@ -1070,7 +1110,7 @@ test( "_off() - all events", function() {
widget._off( element );
element.trigger( "foo" );
element.trigger( "bar" );
-});
+} );
test( "._hoverable()", function( assert ) {
expect( 10 );
@@ -1078,7 +1118,7 @@ test( "._hoverable()", function( assert ) {
_create: function() {
this._hoverable( this.element.children() );
}
- });
+ } );
var div = $( "#widget" ).testWidget().children();
assert.lacksClasses( div, "ui-state-hover", "not hovered on init" );
@@ -1102,7 +1142,7 @@ test( "._hoverable()", function( assert ) {
assert.lacksClasses( div, "ui-state-hover", "not hovered after destroy" );
div.trigger( "mouseenter" );
assert.lacksClasses( div, "ui-state-hover", "event handler removed on destroy" );
-});
+} );
test( "._focusable()", function( assert ) {
expect( 10 );
@@ -1110,7 +1150,7 @@ test( "._focusable()", function( assert ) {
_create: function() {
this._focusable( this.element.children() );
}
- });
+ } );
var div = $( "#widget" ).testWidget().children();
assert.lacksClasses( div, "ui-state-focus", "not focused on init" );
@@ -1134,7 +1174,7 @@ test( "._focusable()", function( assert ) {
assert.lacksClasses( div, "ui-state-focus", "not focused after destroy" );
div.trigger( "focusin" );
assert.lacksClasses( div, "ui-state-focus", "event handler removed on destroy" );
-});
+} );
test( "._trigger() - no event, no ui", function() {
expect( 7 );
@@ -1142,20 +1182,20 @@ test( "._trigger() - no event, no ui", function() {
$.widget( "ui.testWidget", {
_create: function() {}
- });
+ } );
- $( "#widget" ).testWidget({
+ $( "#widget" ).testWidget( {
foo: function( event, ui ) {
deepEqual( event.type, "testwidgetfoo", "correct event type in callback" );
deepEqual( ui, {}, "empty ui hash passed" );
handlers.push( "callback" );
}
- });
+ } );
$( document ).add( "#widget-wrapper" ).add( "#widget" )
.on( "testwidgetfoo", function( event, ui ) {
deepEqual( ui, {}, "empty ui hash passed" );
handlers.push( this );
- });
+ } );
deepEqual( $( "#widget" ).testWidget( "instance" )._trigger( "foo" ), true,
"_trigger returns true when event is not cancelled" );
deepEqual( handlers, [
@@ -1166,42 +1206,42 @@ test( "._trigger() - no event, no ui", function() {
], "event bubbles and then invokes callback" );
$( document ).off( "testwidgetfoo" );
-});
+} );
test( "._trigger() - cancelled event", function() {
expect( 3 );
$.widget( "ui.testWidget", {
_create: function() {}
- });
+ } );
- $( "#widget" ).testWidget({
+ $( "#widget" ).testWidget( {
foo: function() {
ok( true, "callback invoked even if event is cancelled" );
}
- })
+ } )
.on( "testwidgetfoo", function() {
ok( true, "event was triggered" );
return false;
- });
+ } );
deepEqual( $( "#widget" ).testWidget( "instance" )._trigger( "foo" ), false,
"_trigger returns false when event is cancelled" );
-});
+} );
test( "._trigger() - cancelled callback", function() {
expect( 1 );
$.widget( "ui.testWidget", {
_create: function() {}
- });
+ } );
- $( "#widget" ).testWidget({
+ $( "#widget" ).testWidget( {
foo: function() {
return false;
}
- });
+ } );
deepEqual( $( "#widget" ).testWidget( "instance" )._trigger( "foo" ), false,
"_trigger returns false when callback returns false" );
-});
+} );
test( "._trigger() - provide event and ui", function() {
expect( 7 );
@@ -1226,7 +1266,7 @@ test( "._trigger() - provide event and ui", function() {
}
}, "ui object modified" );
}
- });
+ } );
$( "#widget" ).on( "testwidgetfoo", function( event, ui ) {
equal( event.originalEvent, originalEvent, "original event object passed" );
deepEqual( ui, {
@@ -1237,7 +1277,7 @@ test( "._trigger() - provide event and ui", function() {
}
}, "ui hash passed" );
ui.foo = "notbar";
- });
+ } );
$( "#widget-wrapper" ).on( "testwidgetfoo", function( event, ui ) {
equal( event.originalEvent, originalEvent, "original event object passed" );
deepEqual( ui, {
@@ -1248,8 +1288,8 @@ test( "._trigger() - provide event and ui", function() {
}
}, "modified ui hash passed" );
ui.baz.qux = 10;
- });
- $( "#widget" ).testWidget({
+ } );
+ $( "#widget" ).testWidget( {
foo: function( event, ui ) {
equal( event.originalEvent, originalEvent, "original event object passed" );
deepEqual( ui, {
@@ -1261,11 +1301,12 @@ test( "._trigger() - provide event and ui", function() {
}, "modified ui hash passed" );
ui.baz.quux = "jQuery";
}
- })
+ } )
.testWidget( "testEvent" );
-});
+} );
test( "._trigger() - array as ui", function() {
+
// #6795 - Widget: handle array arguments to _trigger consistently
expect( 4 );
@@ -1284,7 +1325,7 @@ test( "._trigger() - array as ui", function() {
};
this._trigger( "foo", null, [ ui, extra ] );
}
- });
+ } );
$( "#widget" ).on( "testwidgetfoo", function( event, ui, extra ) {
deepEqual( ui, {
foo: "bar",
@@ -1296,8 +1337,8 @@ test( "._trigger() - array as ui", function() {
deepEqual( extra, {
bar: 5
}, "event: extra argument passed" );
- });
- $( "#widget" ).testWidget({
+ } );
+ $( "#widget" ).testWidget( {
foo: function( event, ui, extra ) {
deepEqual( ui, {
foo: "bar",
@@ -1310,9 +1351,9 @@ test( "._trigger() - array as ui", function() {
bar: 5
}, "callback: extra argument passed" );
}
- })
+ } )
.testWidget( "testEvent" );
-});
+} );
test( "._trigger() - instance as element", function() {
expect( 4 );
@@ -1321,21 +1362,21 @@ test( "._trigger() - instance as element", function() {
testEvent: function() {
this._trigger( "foo", null, { foo: "bar" } );
}
- });
- var instance = $.ui.testWidget({
+ } );
+ var instance = $.ui.testWidget( {
foo: function( event, ui ) {
equal( event.type, "testwidgetfoo", "event object passed to callback" );
deepEqual( ui, { foo: "bar" }, "ui object passed to callback" );
}
- });
+ } );
$( instance ).on( "testwidgetfoo", function( event, ui ) {
equal( event.type, "testwidgetfoo", "event object passed to event handler" );
deepEqual( ui, { foo: "bar" }, "ui object passed to event handler" );
- });
+ } );
instance.testEvent();
-});
+} );
-(function() {
+( function() {
function shouldDestroy( expected, callback ) {
expect( 1 );
var destroyed = false;
@@ -1344,7 +1385,7 @@ test( "._trigger() - instance as element", function() {
destroy: function() {
destroyed = true;
}
- });
+ } );
callback();
equal( destroyed, expected );
}
@@ -1352,52 +1393,52 @@ test( "._trigger() - instance as element", function() {
test( "auto-destroy - .remove()", function() {
shouldDestroy( true, function() {
$( "#widget" ).testWidget().remove();
- });
- });
+ } );
+ } );
test( "auto-destroy - .remove() when disabled", function() {
shouldDestroy( true, function() {
- $( "#widget" ).testWidget({ disabled: true }).remove();
- });
- });
+ $( "#widget" ).testWidget( { disabled: true } ).remove();
+ } );
+ } );
test( "auto-destroy - .remove() on parent", function() {
shouldDestroy( true, function() {
$( "#widget" ).testWidget().parent().remove();
- });
- });
+ } );
+ } );
test( "auto-destroy - .remove() on child", function() {
shouldDestroy( false, function() {
$( "#widget" ).testWidget().children().remove();
- });
- });
+ } );
+ } );
test( "auto-destroy - .empty()", function() {
shouldDestroy( false, function() {
$( "#widget" ).testWidget().empty();
- });
- });
+ } );
+ } );
test( "auto-destroy - .empty() on parent", function() {
shouldDestroy( true, function() {
$( "#widget" ).testWidget().parent().empty();
- });
- });
+ } );
+ } );
test( "auto-destroy - .detach()", function() {
shouldDestroy( false, function() {
$( "#widget" ).testWidget().detach();
- });
- });
+ } );
+ } );
test( "destroy - remove event bubbling", function() {
shouldDestroy( false, function() {
$( "<div>child</div>" ).appendTo( $( "#widget" ).testWidget() )
.trigger( "remove" );
- });
- });
-}());
+ } );
+ } );
+}() );
test( "redefine", function() {
expect( 4 );
@@ -1406,19 +1447,19 @@ test( "redefine", function() {
strictEqual( this, instance, "original invoked with correct this" );
equal( str, "bar", "original invoked with correct parameter" );
}
- });
+ } );
$.ui.testWidget.foo = "bar";
$.widget( "ui.testWidget", $.ui.testWidget, {
method: function( str ) {
equal( str, "foo", "new invoked with correct parameter" );
this._super( "bar" );
}
- });
+ } );
- var instance = new $.ui.testWidget({});
+ var instance = new $.ui.testWidget( {} );
instance.method( "foo" );
equal( $.ui.testWidget.foo, "bar", "static properties remain" );
-});
+} );
test( "redefine deep prototype chain", function() {
expect( 8 );
@@ -1427,21 +1468,22 @@ test( "redefine deep prototype chain", function() {
strictEqual( this, instance, "original invoked with correct this" );
equal( str, "level 4", "original invoked with correct parameter" );
}
- });
+ } );
$.widget( "ui.testWidget2", $.ui.testWidget, {
method: function( str ) {
strictEqual( this, instance, "testWidget2 invoked with correct this" );
equal( str, "level 2", "testWidget2 invoked with correct parameter" );
this._super( "level 3" );
}
- });
+ } );
$.widget( "ui.testWidget3", $.ui.testWidget2, {
method: function( str ) {
strictEqual( this, instance, "testWidget3 invoked with correct this" );
equal( str, "level 1", "testWidget3 invoked with correct parameter" );
this._super( "level 2" );
}
- });
+ } );
+
// redefine testWidget after other widgets have inherited from it
// this tests whether the inheriting widgets get updated prototype chains
$.widget( "ui.testWidget", $.ui.testWidget, {
@@ -1450,27 +1492,28 @@ test( "redefine deep prototype chain", function() {
equal( str, "level 3", "new invoked with correct parameter" );
this._super( "level 4" );
}
- });
+ } );
+
// redefine testWidget3 after it has been automatically redefined
// this tests whether we properly handle _super() when the topmost prototype
// doesn't have the method defined
$.widget( "ui.testWidget3", $.ui.testWidget3, {} );
- var instance = new $.ui.testWidget3({});
+ var instance = new $.ui.testWidget3( {} );
instance.method( "level 1" );
delete $.ui.testWidget3;
delete $.fn.testWidget3;
delete $.ui.testWidget2;
delete $.fn.testWidget2;
-});
+} );
test( "redefine - widgetEventPrefix", function() {
expect( 2 );
$.widget( "ui.testWidget", {
widgetEventPrefix: "test"
- });
+ } );
equal( $.ui.testWidget.prototype.widgetEventPrefix, "test",
"cusotm prefix in original" );
@@ -1478,7 +1521,7 @@ test( "redefine - widgetEventPrefix", function() {
equal( $.ui.testWidget.prototype.widgetEventPrefix, "test",
"cusotm prefix in extension" );
-});
+} );
test( "mixins", function() {
expect( 2 );
@@ -1493,12 +1536,12 @@ test( "mixins", function() {
method: function() {
return "testWidget1";
}
- });
+ } );
$.widget( "ui.testWidget2", {
method: function() {
return "testWidget2";
}
- });
+ } );
$.widget( "ui.testWidget1", $.ui.testWidget1, mixin );
$.widget( "ui.testWidget2", $.ui.testWidget2, mixin );
@@ -1506,7 +1549,7 @@ test( "mixins", function() {
"mixed testWidget1", "testWidget1 mixin successful" );
equal( $( "<div>" ).testWidget2().testWidget2( "method" ),
"mixed testWidget2", "testWidget2 mixin successful" );
-});
+} );
asyncTest( "_delay", function() {
expect( 6 );
@@ -1516,13 +1559,13 @@ asyncTest( "_delay", function() {
defaultElement: null,
_create: function() {
that = this;
- var timer = this._delay(function() {
+ var timer = this._delay( function() {
strictEqual( this, that );
equal( order, 1 );
start();
- }, 500);
+ }, 500 );
ok( timer !== undefined );
- timer = this._delay("callback");
+ timer = this._delay( "callback" );
ok( timer !== undefined );
},
callback: function() {
@@ -1530,9 +1573,9 @@ asyncTest( "_delay", function() {
equal( order, 0 );
order += 1;
}
- });
+ } );
$( "#widget" ).testWidget();
-});
+} );
test( "$.widget.bridge()", function() {
expect( 14 );
@@ -1557,13 +1600,13 @@ test( "$.widget.bridge()", function() {
option: function( options ) {
deepEqual( options, {} );
}
- });
+ } );
$.widget.bridge( "testWidget", TestWidget );
ok( $.isFunction( $.fn.testWidget ), "jQuery plugin was created" );
- strictEqual( elem.testWidget({ foo: "bar" }), elem, "plugin returns original jQuery object" );
+ strictEqual( elem.testWidget( { foo: "bar" } ), elem, "plugin returns original jQuery object" );
instance = elem.data( "testWidget" );
equal( typeof instance, "object", "instance stored in .data(pluginName)" );
equal( typeof elem.testWidget( "instance" ), "object", "also retrievable via instance method" );
@@ -1581,7 +1624,7 @@ test( "$.widget.bridge()", function() {
ok( "_init", "_init now exists, so its called" );
};
elem.testWidget();
-});
+} );
test( "$.widget.bridge() - widgetFullName", function() {
expect( 1 );
@@ -1596,6 +1639,6 @@ test( "$.widget.bridge() - widgetFullName", function() {
elem.testWidget();
instance = elem.data( "custom-widget" );
equal( typeof instance, "object", "instance stored in .data(widgetFullName)" );
-});
+} );
} );
diff --git a/tests/unit/widget/extend.js b/tests/unit/widget/extend.js
index a5a8cccaa..93afd731a 100644
--- a/tests/unit/widget/extend.js
+++ b/tests/unit/widget/extend.js
@@ -16,7 +16,7 @@ test( "$.widget.extend()", function() {
deep2 = { foo: { baz: true }, foo2: document },
deep2copy = { foo: { baz: true }, foo2: document },
deepmerged = { foo: { bar: true, baz: true }, foo2: document },
- arr = [1, 2, 3],
+ arr = [ 1, 2, 3 ],
nestedarray = { arr: arr },
defaults = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
defaultsCopy = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
@@ -35,8 +35,8 @@ test( "$.widget.extend()", function() {
deepEqual( deep2.foo, deep2copy.foo, "Check if not deep2: options must not be modified" );
equal( deep1.foo2, document, "Make sure that a deep clone was not attempted on the document" );
- 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" );
+ 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" );
empty = {};
optionsWithLength = { foo: { length: -1 } };
@@ -56,29 +56,29 @@ test( "$.widget.extend()", function() {
strictEqual( empty.foo.date, customObject, "Custom objects copy correctly (no methods)" );
// Makes the class a little more realistic
- myKlass.prototype = { someMethod: function(){} };
+ myKlass.prototype = { someMethod: function() {} };
empty = {};
$.widget.extend( empty, optionsWithCustomObject );
strictEqual( empty.foo.date, customObject, "Custom objects copy correctly" );
- ret = $.widget.extend({ foo: 4 }, { foo: Number(5) } );
+ ret = $.widget.extend( { foo: 4 }, { foo: Number( 5 ) } );
equal( ret.foo, 5, "Wrapped numbers copy correctly" );
nullUndef = $.widget.extend( {}, options, { xnumber2: null } );
- strictEqual( nullUndef.xnumber2, null, "Check to make sure null values are copied");
+ strictEqual( nullUndef.xnumber2, null, "Check to make sure null values are copied" );
nullUndef = $.widget.extend( {}, options, { xnumber2: undefined } );
- strictEqual( nullUndef.xnumber2, options.xnumber2, "Check to make sure undefined values are not copied");
+ strictEqual( nullUndef.xnumber2, options.xnumber2, "Check to make sure undefined values are not copied" );
nullUndef = $.widget.extend( {}, options, { xnumber0: null } );
- strictEqual( nullUndef.xnumber0, null, "Check to make sure null values are inserted");
+ strictEqual( nullUndef.xnumber0, null, "Check to make sure null values are inserted" );
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" );
- ret = $.widget.extend( { foo: [] }, { foo: [0] } ); // 1907
+ ret = $.widget.extend( { foo: [] }, { foo: [ 0 ] } ); // 1907
equal( ret.foo.length, 1, "Check to make sure a value with coersion 'false' copies over when necessary to fix #1907" );
ret = $.widget.extend( { foo: "1,2,3" }, { foo: [ 1, 2, 3 ] } );
@@ -105,8 +105,8 @@ test( "$.widget.extend()", function() {
};
output = $.widget.extend( {}, input );
deepEqual( input, output, "don't clone arrays" );
- input.key[0] = 10;
+ input.key[ 0 ] = 10;
deepEqual( input, output, "don't clone arrays" );
-});
+} );
} );
diff --git a/tests/visual/accordion/icons.html b/tests/visual/accordion/icons.html
index a8723a859..b0ae18c65 100644
--- a/tests/visual/accordion/icons.html
+++ b/tests/visual/accordion/icons.html
@@ -4,12 +4,8 @@
<meta charset="utf-8">
<title>Accordion Visual Test</title>
<link rel="stylesheet" href="../../../themes/base/all.css">
- <script src="../../../external/jquery/jquery.js"></script>
- <script src="../../../ui/core.js"></script>
- <script src="../../../ui/widget.js"></script>
- <script src="../../../ui/accordion.js"></script>
- <script>
- $(function() {
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../demos/bootstrap.js">
$( "#accordion-ynynyn" ).accordion({ icons: null });
$( "#accordion-ynyny" ).accordion();
$( "#accordion-ynyn" ).accordion({ icons: null });
@@ -23,7 +19,6 @@
$( "#accordion-nyn" ).accordion({ icons: null });
$( "#accordion-ny" ).accordion();
$( "#accordion-n" ).accordion({ icons: null });
- });
</script>
</head>
<body>
diff --git a/tests/visual/addClass/queue.html b/tests/visual/addClass/queue.html
index 88611ddc4..c939dce91 100644
--- a/tests/visual/addClass/queue.html
+++ b/tests/visual/addClass/queue.html
@@ -4,8 +4,6 @@
<meta charset="utf-8">
<title>addClass Visual Test : Queue</title>
<link rel="stylesheet" href="../../../themes/base/all.css">
- <script src="../../../external/jquery/jquery.js"></script>
- <script src="../../../ui/effect.js"></script>
<style>
.box {
width: 100px;
@@ -22,8 +20,8 @@
background-color: #00f;
}
</style>
- <script>
- $(function() {
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../demos/bootstrap.js" data-modules="effect" data-composite="true">
$( "#box1" )
.delay( 500 )
.addClass( "red", 2000 )
@@ -37,7 +35,6 @@
.addClass( "green", 2000 )
.delay( 500 )
.addClass( "blue", 2000 );
- });
</script>
</head>
<body>
diff --git a/tests/visual/button/button.html b/tests/visual/button/button.html
index 3ac055b91..1d82cf665 100644
--- a/tests/visual/button/button.html
+++ b/tests/visual/button/button.html
@@ -4,12 +4,8 @@
<meta charset="utf-8">
<title>Button Visual Test</title>
<link rel="stylesheet" href="../../../themes/base/all.css">
- <script src="../../../external/jquery/jquery.js"></script>
- <script src="../../../ui/core.js"></script>
- <script src="../../../ui/widget.js"></script>
- <script src="../../../ui/button.js"></script>
- <script>
- $(function() {
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../demos/bootstrap.js">
$( ".buttons" ).each(function() {
$( this ).children()
.eq( 0 )
@@ -31,7 +27,6 @@
.eq( 2 )
.button();
});
- });
</script>
</head>
<body>
diff --git a/tests/visual/button/performance.html b/tests/visual/button/performance.html
index ba90965a9..0d807d167 100644
--- a/tests/visual/button/performance.html
+++ b/tests/visual/button/performance.html
@@ -4,12 +4,8 @@
<meta charset="utf-8">
<title>Button Visual Test: Initialization Performance</title>
<link rel="stylesheet" href="../../../themes/base/all.css">
- <script src="../../../external/jquery/jquery.js"></script>
- <script src="../../../ui/core.js"></script>
- <script src="../../../ui/widget.js"></script>
- <script src="../../../ui/button.js"></script>
- <script>
- $(function() {
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../demos/bootstrap.js">
var start,
html = new Array( 500 ).join( "<button>button</button>" );
$( html ).appendTo( "body" );
@@ -17,7 +13,6 @@
start = $.now();
$( "button" ).button();
$( "<p>" ).text( "Time to initialize: " + ($.now() - start) + "ms" ).prependTo( "body" );
- });
</script>
</head>
<body>
diff --git a/tests/visual/compound/accordion_tabs.html b/tests/visual/compound/accordion_tabs.html
index 68207d151..3f2f93712 100644
--- a/tests/visual/compound/accordion_tabs.html
+++ b/tests/visual/compound/accordion_tabs.html
@@ -5,16 +5,10 @@
<title>Compound Visual Test : Accordion in Tabs</title>
<link rel="stylesheet" href="../visual.css">
<link rel="stylesheet" href="../../../themes/base/all.css">
- <script src="../../../external/jquery/jquery.js"></script>
- <script src="../../../ui/core.js"></script>
- <script src="../../../ui/widget.js"></script>
- <script src="../../../ui/accordion.js"></script>
- <script src="../../../ui/tabs.js"></script>
- <script>
- $(function() {
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../demos/bootstrap.js" data-modules="tabs accordion" data-composite="true">
$( "#accordion-1, #accordion-2" ).accordion();
$( "#tabs" ).tabs();
- });
</script>
</head>
<body>
diff --git a/tests/visual/compound/datepicker_dialog.html b/tests/visual/compound/datepicker_dialog.html
index 374b2aeb5..ba1a1de7e 100644
--- a/tests/visual/compound/datepicker_dialog.html
+++ b/tests/visual/compound/datepicker_dialog.html
@@ -5,25 +5,10 @@
<title>Compound Visual Test : Datepicker in Dialog</title>
<link rel="stylesheet" href="../visual.css">
<link rel="stylesheet" href="../../../themes/base/all.css">
- <script src="../../../external/jquery/jquery.js"></script>
- <script src="../../../external/globalize/globalize.js"></script>
- <script src="../../../external/date.js"></script>
- <script src="../../../external/localization.js"></script>
- <script src="../../../ui/core.js"></script>
- <script src="../../../ui/widget.js"></script>
- <script src="../../../ui/mouse.js"></script>
- <script src="../../../ui/position.js"></script>
- <script src="../../../ui/resizable.js"></script>
- <script src="../../../ui/draggable.js"></script>
- <script src="../../../ui/button.js"></script>
- <script src="../../../ui/calendar.js"></script>
- <script src="../../../ui/datepicker.js"></script>
- <script src="../../../ui/dialog.js"></script>
- <script>
- $(function() {
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../demos/bootstrap.js" data-modules="datepicker dialog" data-composite="true">
$( "#datepicker" ).datepicker();
$( "#dialog" ).dialog();
- });
</script>
</head>
<body>
diff --git a/tests/visual/compound/dialog_widgets.html b/tests/visual/compound/dialog_widgets.html
index 0f6396d9d..f84ef0123 100644
--- a/tests/visual/compound/dialog_widgets.html
+++ b/tests/visual/compound/dialog_widgets.html
@@ -5,30 +5,10 @@
<title>Compound Visual Test : All Widgets in Dialog</title>
<link rel="stylesheet" href="../visual.css">
<link rel="stylesheet" href="../../../themes/base/all.css">
- <script src="../../../external/jquery/jquery.js"></script>
- <script src="../../../external/globalize/globalize.js"></script>
- <script src="../../../external/date.js"></script>
- <script src="../../../external/localization.js"></script>
- <script src="../../../ui/core.js"></script>
- <script src="../../../ui/widget.js"></script>
- <script src="../../../ui/mouse.js"></script>
- <script src="../../../ui/position.js"></script>
- <script src="../../../ui/menu.js"></script>
- <script src="../../../ui/resizable.js"></script>
- <script src="../../../ui/draggable.js"></script>
- <script src="../../../ui/accordion.js"></script>
- <script src="../../../ui/autocomplete.js"></script>
- <script src="../../../ui/button.js"></script>
- <script src="../../../ui/calendar.js"></script>
- <script src="../../../ui/datepicker.js"></script>
- <script src="../../../ui/dialog.js"></script>
- <script src="../../../ui/progressbar.js"></script>
- <script src="../../../ui/slider.js"></script>
- <script src="../../../ui/tabs.js"></script>
- <script src="../../../ui/tooltip.js"></script>
- <script src="../../../ui/selectmenu.js"></script>
- <script>
- $(function() {
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../demos/bootstrap.js"
+ data-modules="accordion autocomplete button datepicker dialog progressbar slider tabs tooltip selectmenu"
+ data-composite="true">
$( "#dialog" ).dialog();
$( "[title]" ).tooltip();
$( "#accordion" ).accordion();
@@ -58,7 +38,6 @@
height: 75,
modal: true
});
- });
</script>
</head>
<body>
diff --git a/tests/visual/compound/draggable_accordion.html b/tests/visual/compound/draggable_accordion.html
index 528cdc321..345c0b038 100644
--- a/tests/visual/compound/draggable_accordion.html
+++ b/tests/visual/compound/draggable_accordion.html
@@ -5,20 +5,15 @@
<title>Compound Visual Test : Draggable in Accordion</title>
<link rel="stylesheet" href="../visual.css">
<link rel="stylesheet" href="../../../themes/base/all.css">
- <script src="../../../external/jquery/jquery.js"></script>
- <script src="../../../ui/core.js"></script>
- <script src="../../../ui/widget.js"></script>
- <script src="../../../ui/mouse.js"></script>
- <script src="../../../ui/accordion.js"></script>
- <script src="../../../ui/draggable.js"></script>
<style>
.draggable {
width: 10em;
margin: 0.5em;
}
</style>
- <script>
- $(function() {
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../demos/bootstrap.js" data-modules="accordion draggable"
+ data-composite="true">
$( ".draggable" ).addClass( "ui-widget ui-widget-content ui-corner-all" )
$( "#first .draggable" ).draggable();
$( "#second .draggable" ).draggable({
@@ -29,7 +24,6 @@
appendTo: "body"
});
$( "#accordion" ).accordion();
- });
</script>
</head>
<body>
diff --git a/tests/visual/compound/draggable_accordion_accordion_tabs_draggable.html b/tests/visual/compound/draggable_accordion_accordion_tabs_draggable.html
index 302a2e910..bfc5f81e6 100644
--- a/tests/visual/compound/draggable_accordion_accordion_tabs_draggable.html
+++ b/tests/visual/compound/draggable_accordion_accordion_tabs_draggable.html
@@ -5,13 +5,6 @@
<title>Compound Visual Test : Draggable in Accordion</title>
<link rel="stylesheet" href="../visual.css">
<link rel="stylesheet" href="../../../themes/base/all.css">
- <script src="../../../external/jquery/jquery.js"></script>
- <script src="../../../ui/core.js"></script>
- <script src="../../../ui/widget.js"></script>
- <script src="../../../ui/mouse.js"></script>
- <script src="../../../ui/accordion.js"></script>
- <script src="../../../ui/draggable.js"></script>
- <script src="../../../ui/tabs.js"></script>
<style>
#main-draggable {
width: 300px;
@@ -27,8 +20,9 @@
margin: 0.5em;
}
</style>
- <script>
- $(function() {
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../demos/bootstrap.js" data-modules="accordion draggable tabs"
+ data-composite="true">
$( ".draggable" )
.addClass( "ui-widget ui-widget-content ui-corner-all" )
.draggable({
@@ -44,7 +38,6 @@
$( "#main-draggable" ).draggable({
handle: "#main-draggable-handle"
});
- });
</script>
</head>
<body>
diff --git a/tests/visual/compound/draggable_resizable.html b/tests/visual/compound/draggable_resizable.html
index d07c8bdc4..539091b7f 100644
--- a/tests/visual/compound/draggable_resizable.html
+++ b/tests/visual/compound/draggable_resizable.html
@@ -5,12 +5,6 @@
<title>Compound Visual Test: Draggable and Resizable block element</title>
<link rel="stylesheet" href="../visual.css">
<link rel="stylesheet" href="../../../themes/base/all.css">
- <script src="../../../external/jquery/jquery.js"></script>
- <script src="../../../ui/core.js"></script>
- <script src="../../../ui/widget.js"></script>
- <script src="../../../ui/mouse.js"></script>
- <script src="../../../ui/draggable.js"></script>
- <script src="../../../ui/resizable.js"></script>
<style>
.draggable {
margin: 0.5em;
@@ -21,8 +15,9 @@
position: absolute !important;
}
</style>
- <script>
- $(function() {
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../demos/bootstrap.js" data-modules="draggable resizable"
+ data-composite="true">
$( ".draggable" )
.addClass( "ui-widget ui-widget-header ui-corner-all" )
.draggable({
@@ -33,7 +28,6 @@
handles: "s"
});
$( ".draggable:last" ).addClass( "absolute" );
- });
</script>
</head>
<body>
diff --git a/tests/visual/compound/sortable_accordion_sortable_tabs.html b/tests/visual/compound/sortable_accordion_sortable_tabs.html
index f44f2b929..9ccc36751 100644
--- a/tests/visual/compound/sortable_accordion_sortable_tabs.html
+++ b/tests/visual/compound/sortable_accordion_sortable_tabs.html
@@ -5,15 +5,9 @@
<title>Compound Visual Test : Accordion in Tabs</title>
<link rel="stylesheet" href="../visual.css">
<link rel="stylesheet" href="../../../themes/base/all.css">
- <script src="../../../external/jquery/jquery.js"></script>
- <script src="../../../ui/core.js"></script>
- <script src="../../../ui/widget.js"></script>
- <script src="../../../ui/mouse.js"></script>
- <script src="../../../ui/sortable.js"></script>
- <script src="../../../ui/accordion.js"></script>
- <script src="../../../ui/tabs.js"></script>
- <script>
- $(function() {
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../demos/bootstrap.js" data-modules="accordion tabs sortable"
+ data-composite="true">
$( "#accordion-1, #accordion-2" )
.accordion({
header: "> div > h3"
@@ -24,7 +18,6 @@
.tabs()
.find( ".ui-tabs-nav" )
.sortable();
- });
</script>
</head>
<body>
diff --git a/tests/visual/compound/tabs_selectmenu.html b/tests/visual/compound/tabs_selectmenu.html
index ca2020b71..ddd72c75f 100644
--- a/tests/visual/compound/tabs_selectmenu.html
+++ b/tests/visual/compound/tabs_selectmenu.html
@@ -5,18 +5,10 @@
<title>Compound Visual Test : Selectmenu in Tabs</title>
<link rel="stylesheet" href="../visual.css">
<link rel="stylesheet" href="../../../themes/base/all.css">
- <script src="../../../external/jquery/jquery.js"></script>
- <script src="../../../ui/core.js"></script>
- <script src="../../../ui/widget.js"></script>
- <script src="../../../ui/position.js"></script>
- <script src="../../../ui/menu.js"></script>
- <script src="../../../ui/selectmenu.js"></script>
- <script src="../../../ui/tabs.js"></script>
- <script>
- $(function() {
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../demos/bootstrap.js" data-modules="tabs selectmenu" data-composite="true">
$( "#tabs" ).tabs();
$( "select" ).selectmenu();
- });
</script>
<style>
select { width: 200px; }
diff --git a/tests/visual/compound/tabs_tabs.html b/tests/visual/compound/tabs_tabs.html
index bf5cf4ead..54c2d48a1 100644
--- a/tests/visual/compound/tabs_tabs.html
+++ b/tests/visual/compound/tabs_tabs.html
@@ -5,15 +5,9 @@
<title>Compound Visual Test : Tabs in Tabs</title>
<link rel="stylesheet" href="../visual.css">
<link rel="stylesheet" href="../../../themes/base/all.css">
- <script src="../../../external/jquery/jquery.js"></script>
- <script src="../../../ui/core.js"></script>
- <script src="../../../ui/widget.js"></script>
- <script src="../../../ui/accordion.js"></script>
- <script src="../../../ui/tabs.js"></script>
- <script>
- $(function() {
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../demos/bootstrap.js" data-modules="tabs" data-composite="true">
$( "#tabs, #tabs-a, #tabs-b" ).tabs();
- });
</script>
</head>
<body>
diff --git a/tests/visual/compound/tabs_tooltips.html b/tests/visual/compound/tabs_tooltips.html
index bb8f2d11d..8ee625e1e 100644
--- a/tests/visual/compound/tabs_tooltips.html
+++ b/tests/visual/compound/tabs_tooltips.html
@@ -5,17 +5,10 @@
<title>Compound Visual Test : Tabs in Tabs</title>
<link rel="stylesheet" href="../visual.css">
<link rel="stylesheet" href="../../../themes/base/all.css">
- <script src="../../../external/jquery/jquery.js"></script>
- <script src="../../../ui/core.js"></script>
- <script src="../../../ui/widget.js"></script>
- <script src="../../../ui/position.js"></script>
- <script src="../../../ui/tooltip.js"></script>
- <script src="../../../ui/tabs.js"></script>
- <script>
- $(function() {
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../demos/bootstrap.js" data-modules="tabs tooltip" data-composite="true">
$( "#tabs" ).tabs();
$( "a" ).tooltip();
- });
</script>
</head>
<body>
diff --git a/tests/visual/dialog/animated.html b/tests/visual/dialog/animated.html
index 2bb0b398b..2fd1d04a6 100644
--- a/tests/visual/dialog/animated.html
+++ b/tests/visual/dialog/animated.html
@@ -4,20 +4,8 @@
<meta charset="utf-8">
<title>Dialog Visual Test</title>
<link rel="stylesheet" href="../../../themes/base/all.css">
- <script src="../../../external/jquery/jquery.js"></script>
- <script src="../../../ui/core.js"></script>
- <script src="../../../ui/widget.js"></script>
- <script src="../../../ui/mouse.js"></script>
- <script src="../../../ui/draggable.js"></script>
- <script src="../../../ui/position.js"></script>
- <script src="../../../ui/resizable.js"></script>
- <script src="../../../ui/button.js"></script>
- <script src="../../../ui/dialog.js"></script>
- <script src="../../../ui/effect.js"></script>
- <script src="../../../ui/effect-blind.js"></script>
- <script src="../../../ui/effect-explode.js"></script>
- <script>
- $(function() {
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../demos/bootstrap.js" data-modules="effect-blind effect-explode">
$( "#dialog" ).dialog({
autoOpen: false,
show: {
@@ -34,7 +22,6 @@
$( "#opener" ).on( "click", function() {
$( "#dialog" ).dialog( "open" );
});
- });
</script>
</head>
<body>
diff --git a/tests/visual/dialog/complex-dialogs.html b/tests/visual/dialog/complex-dialogs.html
index 59844c6a9..0bea3414e 100644
--- a/tests/visual/dialog/complex-dialogs.html
+++ b/tests/visual/dialog/complex-dialogs.html
@@ -4,28 +4,8 @@
<meta charset="utf-8">
<title>Dialog Visual Test</title>
<link rel="stylesheet" href="../../../themes/base/all.css">
- <script src="../../../external/jquery/jquery.js"></script>
- <script src="../../../ui/core.js"></script>
- <script src="../../../ui/widget.js"></script>
- <script src="../../../ui/mouse.js"></script>
- <script src="../../../ui/draggable.js"></script>
- <script src="../../../ui/position.js"></script>
- <script src="../../../ui/resizable.js"></script>
- <script src="../../../ui/button.js"></script>
- <script src="../../../ui/dialog.js"></script>
-
- <!-- stuff needed to make things complex -->
- <script src="../../../external/globalize/globalize.js"></script>
- <script src="../../../external/date.js"></script>
- <script src="../../../external/localization.js"></script>
- <script src="../../../ui/calendar.js"></script>
- <script src="../../../ui/datepicker.js"></script>
- <script src="../../../ui/menu.js"></script>
- <script src="../../../ui/autocomplete.js"></script>
- <script src="../../../ui/tooltip.js"></script>
-
- <script>
- $(function() {
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../demos/bootstrap.js" data-modules="datepicker autocomplete tooltip">
var dialog = $( "#dialog" ).dialog({
modal: true,
width: 500,
@@ -91,7 +71,6 @@
});
$( document ).tooltip();
- });
</script>
</head>
<body>
diff --git a/tests/visual/dialog/form.html b/tests/visual/dialog/form.html
index 42d40f1f4..b1cdaa54a 100644
--- a/tests/visual/dialog/form.html
+++ b/tests/visual/dialog/form.html
@@ -4,20 +4,8 @@
<meta charset="utf-8">
<title>Dialog Visual Test</title>
<link rel="stylesheet" href="../../../themes/base/all.css">
- <script src="../../../external/jquery/jquery.js"></script>
- <script src="../../../ui/core.js"></script>
- <script src="../../../ui/widget.js"></script>
- <script src="../../../ui/mouse.js"></script>
- <script src="../../../ui/draggable.js"></script>
- <script src="../../../ui/position.js"></script>
- <script src="../../../ui/resizable.js"></script>
- <script src="../../../ui/button.js"></script>
- <script src="../../../ui/dialog.js"></script>
- <script src="../../../ui/effect.js"></script>
- <script src="../../../ui/effect-blind.js"></script>
- <script src="../../../ui/effect-explode.js"></script>
- <script>
- $(function() {
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../demos/bootstrap.js">
$( "#form-dialog, #prompt-dialog" ).dialog({
autoOpen: false,
modal: true
@@ -30,7 +18,6 @@
$( "#open-prompt" ).on( "click", function() {
$( "#prompt-dialog" ).dialog( "open" );
});
- });
</script>
<style>
label {
diff --git a/tests/visual/dialog/performance.html b/tests/visual/dialog/performance.html
index e01098ad1..20adbfa6b 100644
--- a/tests/visual/dialog/performance.html
+++ b/tests/visual/dialog/performance.html
@@ -4,17 +4,8 @@
<meta charset="utf-8">
<title>Dialog Visual Test - Modal Dialog in Large DOM</title>
<link rel="stylesheet" href="../../../themes/base/all.css">
- <script src="../../../external/jquery/jquery.js"></script>
- <script src="../../../ui/core.js"></script>
- <script src="../../../ui/position.js"></script>
- <script src="../../../ui/widget.js"></script>
- <script src="../../../ui/mouse.js"></script>
- <script src="../../../ui/draggable.js"></script>
- <script src="../../../ui/resizable.js"></script>
- <script src="../../../ui/button.js"></script>
- <script src="../../../ui/dialog.js"></script>
- <script>
- $(function() {
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../demos/bootstrap.js">
var start,
html = new Array( 500 ).join( $.trim( $( "#template" ).html() ) );
$( html ).appendTo( "body" );
@@ -31,7 +22,6 @@
$( "#dialog" ).dialog( "open" );
$( "<li>Open: " + ($.now() - start) + "ms</li>" ).appendTo( "#log" );
});
- });
</script>
</head>
<body>
diff --git a/tests/visual/dialog/stacking.html b/tests/visual/dialog/stacking.html
index 221498a55..e2e23e58a 100644
--- a/tests/visual/dialog/stacking.html
+++ b/tests/visual/dialog/stacking.html
@@ -4,18 +4,8 @@
<meta charset="utf-8">
<title>Dialog Visual Test</title>
<link rel="stylesheet" href="../../../themes/base/all.css">
- <script src="../../../external/jquery/jquery.js"></script>
- <script src="../../../ui/core.js"></script>
- <script src="../../../ui/widget.js"></script>
- <script src="../../../ui/mouse.js"></script>
- <script src="../../../ui/draggable.js"></script>
- <script src="../../../ui/position.js"></script>
- <script src="../../../ui/resizable.js"></script>
- <script src="../../../ui/button.js"></script>
- <script src="../../../ui/dialog.js"></script>
-
- <script>
- $(function() {
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../demos/bootstrap.js">
var iframeDialog = $( "#dialog-iframe" ).dialog({
position: {
my: "right-90 center"
@@ -34,7 +24,6 @@
width: 200,
height: 150
});
- });
</script>
</head>
<body>
diff --git a/tests/visual/draggable/replaced.html b/tests/visual/draggable/replaced.html
index f343eea28..38931f345 100644
--- a/tests/visual/draggable/replaced.html
+++ b/tests/visual/draggable/replaced.html
@@ -4,19 +4,13 @@
<meta charset="utf-8">
<title>Draggable Visual Test</title>
<link rel="stylesheet" href="../../../themes/base/all.css">
- <script src="../../../external/jquery/jquery.js"></script>
- <script src="../../../ui/core.js"></script>
- <script src="../../../ui/widget.js"></script>
- <script src="../../../ui/mouse.js"></script>
- <script src="../../../ui/draggable.js"></script>
- <script>
- $(function() {
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../demos/bootstrap.js">
$( "#draggable" )
.draggable()
.on( "mousedown", function() {
$( this ).html( "<div>replaced</div>" );
});
- });
</script>
<style>
diff --git a/tests/visual/effects/all.html b/tests/visual/effects/all.html
index c1bdd9fa3..e3fa3ee48 100644
--- a/tests/visual/effects/all.html
+++ b/tests/visual/effects/all.html
@@ -4,24 +4,10 @@
<meta charset="utf-8">
<title>jQuery UI Effects Test Suite</title>
<link rel="stylesheet" href="effects.css">
- <script src="../../../external/jquery/jquery.js"></script>
- <script src="../../../ui/effect.js"></script>
- <script src="../../../ui/effect-blind.js"></script>
- <script src="../../../ui/effect-bounce.js"></script>
- <script src="../../../ui/effect-clip.js"></script>
- <script src="../../../ui/effect-drop.js"></script>
- <script src="../../../ui/effect-explode.js"></script>
- <script src="../../../ui/effect-fade.js"></script>
- <script src="../../../ui/effect-fold.js"></script>
- <script src="../../../ui/effect-highlight.js"></script>
- <script src="../../../ui/effect-puff.js"></script>
- <script src="../../../ui/effect-pulsate.js"></script>
- <script src="../../../ui/effect-scale.js"></script>
- <script src="../../../ui/effect-size.js"></script>
- <script src="../../../ui/effect-shake.js"></script>
- <script src="../../../ui/effect-slide.js"></script>
- <script src="../../../ui/effect-transfer.js"></script>
- <script src="effects.js"></script>
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../demos/bootstrap.js" data-modules="effects-all" data-composite="true">
+ require( ["./effects.js"] );
+ </script>
</head>
<body>
diff --git a/tests/visual/effects/clip.html b/tests/visual/effects/clip.html
index b8ede414b..c20e6506a 100644
--- a/tests/visual/effects/clip.html
+++ b/tests/visual/effects/clip.html
@@ -4,11 +4,9 @@
<meta charset="utf-8">
<title>jQuery UI Effects Test Suite</title>
<link rel="stylesheet" href="effects.css">
- <script src="../../../external/jquery/jquery.js"></script>
- <script src="../../../ui/effect.js"></script>
- <script src="../../../ui/effect-clip.js"></script>
- <script>
- $(function() {
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../demos/bootstrap.js" data-modules="effect effect-clip"
+ data-composite="true">
var target = $( ".target" ),
duration = 2000;
@@ -33,7 +31,6 @@
direction: "vertical"
}, duration );
});
- });
</script>
<style>
.clipped {
diff --git a/tests/visual/effects/effects.js b/tests/visual/effects/effects.js
index 114dcc2a6..6d36a55ea 100644
--- a/tests/visual/effects/effects.js
+++ b/tests/visual/effects/effects.js
@@ -1,24 +1,23 @@
-$(function() {
-
var duration = 1000,
wait = 500;
function effect( elem, name, options ) {
$.extend( options, {
easing: "easeOutQuint"
- });
+ } );
$( elem ).on( "click", function() {
$( this )
.addClass( "current" )
+
// delaying the initial animation makes sure that the queue stays in tact
.delay( 10 )
.hide( name, options, duration )
.delay( wait )
.show( name, options, duration, function() {
$( this ).removeClass( "current" );
- });
- });
+ } );
+ } );
}
$( "#hide" ).on( "click", function() {
@@ -28,8 +27,8 @@ $( "#hide" ).on( "click", function() {
.delay( wait )
.show( duration, function() {
$( this ).removeClass( "current" );
- });
-});
+ } );
+} );
effect( "#blindLeft", "blind", { direction: "left" } );
effect( "#blindUp", "blind", { direction: "up" } );
@@ -68,16 +67,16 @@ $( "#sizeToggle" ).on( "click", function() {
.delay( wait )
.toggle( "size", options, duration, function() {
$( this ).removeClass( "current" );
- });
-});
+ } );
+} );
$( "#shake" ).on( "click", function() {
$( this )
.addClass( "current" )
.effect( "shake", {}, 100, function() {
$( this ).removeClass( "current" );
- });
-});
+ } );
+} );
effect( "#slideDown", "slide", { direction: "down" } );
effect( "#slideUp", "slide", { direction: "up" } );
@@ -89,19 +88,17 @@ $( "#transfer" ).on( "click", function() {
.addClass( "current" )
.effect( "transfer", { to: "div:eq(0)" }, 1000, function() {
$( this ).removeClass( "current" );
- });
-});
+ } );
+} );
$( "#addClass" ).on( "click", function() {
$( this ).addClass( "current", duration, function() {
$( this ).removeClass( "current" );
- });
-});
+ } );
+} );
$( "#removeClass" ).on( "click", function() {
$( this ).addClass( "current" ).removeClass( "current", duration );
-});
+} );
$( "#toggleClass" ).on( "click", function() {
$( this ).toggleClass( "current", duration );
-});
-
-});
+} );
diff --git a/tests/visual/effects/scale.html b/tests/visual/effects/scale.html
index 0723d9458..b032ac896 100644
--- a/tests/visual/effects/scale.html
+++ b/tests/visual/effects/scale.html
@@ -4,12 +4,39 @@
<meta charset="utf-8">
<title>jQuery UI Effects Test Suite</title>
<link rel="stylesheet" href="effects.css">
- <script src="../../../external/jquery/jquery.js"></script>
- <script src="../../../ui/effect.js"></script>
- <script src="../../../ui/effect-scale.js"></script>
- <script src="../../../ui/effect-size.js"></script>
- <script>
- $(function() {
+ <style>
+ #testArea {
+ width: 200px;
+ height: 200px;
+ position: relative;
+ }
+ #testBox {
+ width: 50px;
+ height: 50px;
+ background-color: #bada55;
+ color: black;
+ border: 10px solid #fff;
+ margin: 10px;
+ padding: 10px;
+ position: absolute;
+ left: 5px;
+ top: 5px;
+ }
+ label {
+ display: block;
+ }
+ #controls {
+ position: absolute;
+ z-index: 300;
+ left: 50%;
+ top: 50%;
+ margin-left: -200px;
+ width: 400px;
+ opacity: 0.8;
+ }
+ </style>
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../demos/bootstrap.js" data-modules="effect-scale" data-composite="true">
var test = $( "#testBox" ),
opts = $( ".arg" ),
optsRev = $( opts.get().reverse() ),
@@ -84,39 +111,7 @@
.delay( 100 )
.effect( effect );
}
- });
</script>
- <style>
- #testArea {
- width: 200px;
- height: 200px;
- position: relative;
- }
- #testBox {
- width: 50px;
- height: 50px;
- background-color: #bada55;
- color: black;
- border: 10px solid #fff;
- margin: 10px;
- padding: 10px;
- position: absolute;
- left: 5px;
- top: 5px;
- }
- label {
- display: block;
- }
- #controls {
- position: absolute;
- z-index: 300;
- left: 50%;
- top: 50%;
- margin-left: -200px;
- width: 400px;
- opacity: 0.8;
- }
- </style>
</head>
<body>
diff --git a/tests/visual/effects/shake.html b/tests/visual/effects/shake.html
index 29159e39d..c93f0eb57 100644
--- a/tests/visual/effects/shake.html
+++ b/tests/visual/effects/shake.html
@@ -4,20 +4,6 @@
<meta charset="utf-8">
<title>jQuery UI Effects Test Suite</title>
<link rel="stylesheet" href="effects.css">
- <script src="../../../external/jquery/jquery.js"></script>
- <script src="../../../ui/effect.js"></script>
- <script src="../../../ui/effect-scale.js"></script>
- <script src="../../../ui/effect-shake.js"></script>
- <script>
- $(function() {
- $( "#btn" ).on( "click", function() {
- $( ".shake" ).effect( "shake", {
- duration: +$( "#duration" ).val(),
- mode: "toggle"
- });
- });
- });
- </script>
<style>
#inputbox {
background: green;
@@ -54,6 +40,15 @@
padding: 10px;
}
</style>
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../demos/bootstrap.js" data-modules="effect-shake" data-composite="true">
+ $( "#btn" ).on( "click", function() {
+ $( ".shake" ).effect( "shake", {
+ duration: +$( "#duration" ).val(),
+ mode: "toggle"
+ });
+ });
+ </script>
</head>
<body>
diff --git a/tests/visual/index.html b/tests/visual/index.html
index 4979921a4..98753c827 100644
--- a/tests/visual/index.html
+++ b/tests/visual/index.html
@@ -89,6 +89,7 @@
<li><a href="compound/draggable_accordion_accordion_tabs_draggable.html">Nested Widgets</a></li>
<li><a href="compound/draggable_resizable.html">Draggable Resizable</a></li>
<li><a href="compound/sortable_accordion_sortable_tabs.html">Sortable Tabs in Sortable Accordion</a></li>
+ <li><a href="compound/tabs_selectmenu.html">Selectmenu in Tabs</a></li>
<li><a href="compound/tabs_tabs.html">Nested Tabs</a></li>
<li><a href="compound/tabs_tooltips.html">Tabs with Tooltips</a></li>
</ul>
diff --git a/tests/visual/menu/menu.html b/tests/visual/menu/menu.html
index c71f50ff4..9bbaa95e1 100644
--- a/tests/visual/menu/menu.html
+++ b/tests/visual/menu/menu.html
@@ -4,13 +4,15 @@
<meta charset="utf-8">
<title>Menu Visual Test: Default</title>
<link rel="stylesheet" href="../../../themes/base/all.css">
- <script src="../../../external/jquery/jquery.js"></script>
- <script src="../../../ui/core.js"></script>
- <script src="../../../ui/widget.js"></script>
- <script src="../../../ui/position.js"></script>
- <script src="../../../ui/menu.js"></script>
- <script>
- $(function() {
+ <style>
+ .ui-menu { width: 250px; margin-bottom: 2em; }
+ .menu4 { height: 225px; overflow-y: auto; overflow-x: hidden; }
+ .address-item { border-bottom: 1px solid #999; }
+ .address-header { display: block; margin-bottom: .2em; font-weight: bold; }
+ .address-content { display: block; margin-bottom: .2em; padding-left: 10px; }
+ </style>
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../demos/bootstrap.js">
function logger( event, ui ) {
$( "<p>" ).text( "Selected: " + ui.item.text() ).appendTo( "#log" );
}
@@ -42,15 +44,7 @@
items: "> :not('.ui-menu-group')",
select: logger
});
- });
</script>
- <style>
- .ui-menu { width: 250px; margin-bottom: 2em; }
- .menu4 { height: 225px; overflow-y: auto; overflow-x: hidden; }
- .address-item { border-bottom: 1px solid #999; }
- .address-header { display: block; margin-bottom: .2em; font-weight: bold; }
- .address-content { display: block; margin-bottom: .2em; padding-left: 10px; }
- </style>
</head>
<body>
diff --git a/tests/visual/position/position.html b/tests/visual/position/position.html
index 70a9c40e5..d5c19fd32 100644
--- a/tests/visual/position/position.html
+++ b/tests/visual/position/position.html
@@ -3,12 +3,6 @@
<head>
<meta charset="utf-8">
<title>Position Visual Test</title>
- <script src="../../../external/jquery/jquery.js"></script>
- <script src="../../../ui/core.js"></script>
- <script src="../../../ui/widget.js"></script>
- <script src="../../../ui/mouse.js"></script>
- <script src="../../../ui/draggable.js"></script>
- <script src="../../../ui/position.js"></script>
<style>
.demo {
position: relative;
@@ -34,8 +28,8 @@
margin: 0 15px 15px 0;
}
</style>
- <script>
- $(function() {
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../demos/bootstrap.js" data-modules="draggable">
var within = $( ".demo" ),
positionable = $( ".positionable" );
function position() {
@@ -67,7 +61,6 @@
$( "select, input" ).on( "click keyup change", function() { position(); } );
position();
- });
</script>
</head>
<body>
diff --git a/tests/visual/position/position_feedback.html b/tests/visual/position/position_feedback.html
index 988451026..f094b5148 100644
--- a/tests/visual/position/position_feedback.html
+++ b/tests/visual/position/position_feedback.html
@@ -4,13 +4,67 @@
<meta charset="utf-8">
<title>Position Visual Test: Feedback</title>
<link rel="stylesheet" href="../../../themes/base/all.css">
- <script src="../../../external/jquery/jquery.js"></script>
- <script src="../../../ui/core.js"></script>
- <script src="../../../ui/widget.js"></script>
- <script src="../../../ui/position.js"></script>
- <script src="../../../ui/menu.js"></script>
- <script>
- $(function() {
+ <style>
+ #target, .element {
+ position: absolute;
+ border: 1px solid black;
+ border-radius: 5px;
+ width: 75px;
+ height: 25px;
+ padding: 5px;
+ font-size: 62.5%;
+ }
+ #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>
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../demos/bootstrap.js">
function using( position, feedback ) {
$( this )
.css( position )
@@ -74,67 +128,7 @@
rightElement.position( positionWithOffset(
0.9 * (event.pageX - targetOffset.left), -0.9 * (event.pageY - targetOffset.top) ) );
});
- });
</script>
- <style>
- #target, .element {
- position: absolute;
- border: 1px solid black;
- border-radius: 5px;
- width: 75px;
- height: 25px;
- padding: 5px;
- font-size: 62.5%;
- }
- #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>
diff --git a/tests/visual/selectmenu/selectmenu.html b/tests/visual/selectmenu/selectmenu.html
index f91894710..693885d25 100644
--- a/tests/visual/selectmenu/selectmenu.html
+++ b/tests/visual/selectmenu/selectmenu.html
@@ -4,14 +4,18 @@
<meta charset="utf-8">
<title>Selectmenu Visual Test: Default</title>
<link rel="stylesheet" href="../../../themes/base/all.css">
- <script src="../../../external/jquery/jquery.js"></script>
- <script src="../../../ui/core.js"></script>
- <script src="../../../ui/widget.js"></script>
- <script src="../../../ui/position.js"></script>
- <script src="../../../ui/menu.js"></script>
- <script src="../../../ui/selectmenu.js"></script>
- <script>
- $(function() {
+ <style>
+ fieldset { border: 0; }
+ label { display: block; }
+ select { width: 200px; }
+
+ .ui-selectmenu-button { display: block; margin-bottom: 1em;}
+
+ /* width */
+ .width-menu { width: 196px; }
+ </style>
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../demos/bootstrap.js">
var log = $("#log"),
index = 0,
text;
@@ -119,18 +123,7 @@
var widthMenu = $("#width_menu").selectmenu();
widthMenu.selectmenu("menuWidget").addClass("width-menu");
- });
</script>
- <style>
- fieldset { border: 0; }
- label { display: block; }
- select { width: 200px; }
-
- .ui-selectmenu-button { display: block; margin-bottom: 1em;}
-
- /* width */
- .width-menu { width: 196px; }
- </style>
</head>
<body>
diff --git a/tests/visual/slider/range_slider.html b/tests/visual/slider/range_slider.html
index 2b041f377..64152a9ff 100644
--- a/tests/visual/slider/range_slider.html
+++ b/tests/visual/slider/range_slider.html
@@ -11,11 +11,23 @@
margin: 20px auto;
}
</style>
- <script src="../../../external/jquery/jquery.js"></script>
- <script src="../../../ui/core.js"></script>
- <script src="../../../ui/widget.js"></script>
- <script src="../../../ui/mouse.js"></script>
- <script src="../../../ui/slider.js"></script>
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../demos/bootstrap.js">
+ var el = $( "#slider" ).slider({
+ range: true,
+ min: 0,
+ max: 100,
+ values: [ 0, 50 ]
+ });
+
+ $( "#set-max-values" ).on( "click", function() {
+ el.slider( "option", { values: [ 100, 100 ] } );
+ });
+
+ $( "#set-min-values" ).on( "click", function() {
+ el.slider( "option", { values: [ 0, 0 ] } );
+ });
+ </script>
</head>
<body>
<div id="wrapper">
@@ -26,22 +38,5 @@
<button id="set-max-values">set values to max</button>
<button id="set-min-values">set values to min</button>
</div>
-
-<script>
- var el = $( "#slider" ).slider({
- range: true,
- min: 0,
- max: 100,
- values: [ 0, 50 ]
- });
-
- $( "#set-max-values" ).on( "click", function() {
- el.slider( "option", { values: [ 100, 100 ] } );
- });
-
- $( "#set-min-values" ).on( "click", function() {
- el.slider( "option", { values: [ 0, 0 ] } );
- });
-</script>
</body>
</html>
diff --git a/tests/visual/tooltip/animations.html b/tests/visual/tooltip/animations.html
index 6131db436..7427d7ebd 100644
--- a/tests/visual/tooltip/animations.html
+++ b/tests/visual/tooltip/animations.html
@@ -4,16 +4,6 @@
<meta charset="utf-8">
<title>Tooltip Visual Test: Animations</title>
<link rel="stylesheet" href="../../../themes/base/all.css">
- <script src="../../../external/jquery/jquery.js"></script>
- <script src="../../../ui/core.js"></script>
- <script src="../../../ui/widget.js"></script>
- <script src="../../../ui/position.js"></script>
- <script src="../../../ui/tooltip.js"></script>
- <script src="../../../ui/effect.js"></script>
- <script src="../../../ui/effect-blind.js"></script>
- <script src="../../../ui/effect-bounce.js"></script>
- <script src="../../../ui/effect-drop.js"></script>
- <script src="../../../ui/effect-explode.js"></script>
<style>
pre {
width: 250px;
@@ -21,52 +11,51 @@
padding: .5em;
}
</style>
- <script>
- $(function() {
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../demos/bootstrap.js">
$( "pre" ).each(function( index, elem ) {
$( elem )
.attr( "title", "animated tooltips" )
.tooltip( $.parseJSON( $( elem ).text() ) );
});
- });
</script>
</head>
<body>
<pre>{}</pre>
<pre>{
- "show": {
- "effect": "slideDown"
- },
- "hide": {
- "effect": "slideUp"
- }
+ "show": {
+ "effect": "slideDown"
+ },
+ "hide": {
+ "effect": "slideUp"
+ }
}</pre>
<pre>{
- "show": {
- "effect": "explode"
- },
- "hide": {
- "effect": "explode"
- }
+ "show": {
+ "effect": "explode"
+ },
+ "hide": {
+ "effect": "explode"
+ }
}</pre>
<pre>{
- "show": {
- "effect": "bounce"
- },
- "hide": {
- "effect": "blind"
- }
+ "show": {
+ "effect": "bounce"
+ },
+ "hide": {
+ "effect": "blind"
+ }
}</pre>
<pre>{
- "show": {
- "effect": "drop",
- "direction": "right"
- },
- "hide": {
- "effect": "drop",
- "direction": "right"
- }
+ "show": {
+ "effect": "drop",
+ "direction": "right"
+ },
+ "hide": {
+ "effect": "drop",
+ "direction": "right"
+ }
}</pre>
</body>
diff --git a/tests/visual/tooltip/tooltip.html b/tests/visual/tooltip/tooltip.html
index c0ba7a11c..9453190d7 100644
--- a/tests/visual/tooltip/tooltip.html
+++ b/tests/visual/tooltip/tooltip.html
@@ -4,23 +4,17 @@
<meta charset="utf-8">
<title>Tooltip Visual Test: Default</title>
<link rel="stylesheet" href="../../../themes/base/all.css">
- <script src="../../../external/jquery/jquery.js"></script>
- <script src="../../../ui/core.js"></script>
- <script src="../../../ui/widget.js"></script>
- <script src="../../../ui/position.js"></script>
- <script src="../../../ui/button.js"></script>
- <script src="../../../ui/tooltip.js"></script>
<style>
.group {
margin-top: 2em;
}
</style>
- <script>
- $(function() {
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../demos/bootstrap.js" data-modules="button">
// default
$( "#context1, form, #childish, #nested-input" ).tooltip();
- // custom class, replaces ui-widget-content
+ // Custom class, replaces ui-widget-content
$( "#context2" ).tooltip({
classes: {
"ui-tooltip": "ui-corner-all ui-widget-header"
@@ -32,7 +26,7 @@
}
});
- // synchronous content
+ // Synchronous content
$( "#footnotes" ).tooltip({
items: "[href^='#']",
content: function() {
@@ -40,7 +34,7 @@
}
});
- // asynchronous content
+ // Asynchronous content
$( "#async" ).tooltip({
content: function( response ) {
setTimeout(function() {
@@ -50,7 +44,7 @@
}
});
- // asynchronous content with caching
+ // Asynchronous content with caching
var content;
$( "#async2" ).tooltip({
content: function( response ) {
@@ -65,7 +59,7 @@
}
});
- // custom position
+ // Custom position
$( "#right2" ).tooltip({
classes: {
"ui-tooltip": "ui-corner-all ui-state-highlight"
@@ -103,7 +97,6 @@
}).on( "click", function() {
$( "#focus-on-me" ).trigger( "focus" );
});
- });
</script>
</head>
<body>
diff --git a/themes/base/button.css b/themes/base/button.css
index 70caf10ed..17dea198f 100644
--- a/themes/base/button.css
+++ b/themes/base/button.css
@@ -51,7 +51,7 @@ button.ui-button-icons-only {
}
.ui-button-icon-only .ui-button-text,
.ui-button-icons-only .ui-button-text {
- padding: .4em;
+ padding: 0;
text-indent: -9999999px;
}
.ui-button-text-icon-primary .ui-button-text,
diff --git a/ui/.jshintrc b/ui/.jshintrc
index 98a79b5db..7bb17b5f9 100644
--- a/ui/.jshintrc
+++ b/ui/.jshintrc
@@ -6,7 +6,6 @@
"expr": true,
"immed": true,
"noarg": true,
- "onevar": true,
"quotmark": "double",
"smarttabs": true,
"trailing": true,
diff --git a/ui/data.js b/ui/data.js
index e989902da..f76098d8c 100644
--- a/ui/data.js
+++ b/ui/data.js
@@ -30,7 +30,8 @@ return $.extend( $.expr[ ":" ], {
return !!$.data( elem, dataName );
};
} ) :
- // support: jQuery <1.8
+
+ // Support: jQuery <1.8
function( elem, i, match ) {
return !!$.data( elem, match[ 3 ] );
}
diff --git a/ui/effect.js b/ui/effect.js
index 7fa45cfc0..1a660fa49 100644
--- a/ui/effect.js
+++ b/ui/effect.js
@@ -13,7 +13,7 @@
//>>docs: http://api.jqueryui.com/category/effects-core/
//>>demos: http://jqueryui.com/effect/
-(function( factory ) {
+( function( factory ) {
if ( typeof define === "function" && define.amd ) {
// AMD. Register as an anonymous module.
@@ -23,7 +23,7 @@
// Browser globals
factory( jQuery );
}
-}(function( $ ) {
+}( function( $ ) {
var dataSpace = "ui-effects-",
dataSpaceStyle = "ui-effects-style",
@@ -47,13 +47,14 @@ $.effects = {
*
* Date: Wed Jan 16 08:47:09 2013 -0600
*/
-(function( jQuery, undefined ) {
+( function( jQuery, undefined ) {
var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
- // plusequals test for += 100 -= 100
+ // Plusequals test for += 100 -= 100
rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
- // a set of RE's that can match strings and generate color tuples.
+
+ // A set of RE's that can match strings and generate color tuples.
stringParsers = [ {
re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
parse: function( execResult ) {
@@ -75,7 +76,8 @@ $.effects = {
];
}
}, {
- // this regex ignores A-F because it's compared against an already lowercased string
+
+ // This regex ignores A-F because it's compared against an already lowercased string
re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
parse: function( execResult ) {
return [
@@ -85,7 +87,8 @@ $.effects = {
];
}
}, {
- // this regex ignores A-F because it's compared against an already lowercased string
+
+ // This regex ignores A-F because it's compared against an already lowercased string
re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
parse: function( execResult ) {
return [
@@ -107,7 +110,7 @@ $.effects = {
}
} ],
- // jQuery.Color( )
+ // JQuery.Color( )
color = jQuery.Color = function( color, green, blue, alpha ) {
return new jQuery.Color.fn.parse( color, green, blue, alpha );
},
@@ -161,20 +164,20 @@ $.effects = {
},
support = color.support = {},
- // element for support tests
+ // Element for support tests
supportElem = jQuery( "<p>" )[ 0 ],
- // colors = jQuery.Color.names
+ // Colors = jQuery.Color.names
colors,
- // local aliases of functions called often
+ // Local aliases of functions called often
each = jQuery.each;
-// determine rgba support immediately
+// Determine rgba support immediately
supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
-// define cache name and alpha properties
+// Define cache name and alpha properties
// for rgba and hsla spaces
each( spaces, function( spaceName, space ) {
space.cache = "_" + spaceName;
@@ -183,13 +186,13 @@ each( spaces, function( spaceName, space ) {
type: "percent",
def: 1
};
-});
+} );
function clamp( value, prop, allowEmpty ) {
var type = propTypes[ prop.type ] || {};
if ( value == null ) {
- return (allowEmpty || !prop.def) ? null : prop.def;
+ return ( allowEmpty || !prop.def ) ? null : prop.def;
}
// ~~ is an short way of doing floor for positive numbers
@@ -202,12 +205,13 @@ function clamp( value, prop, allowEmpty ) {
}
if ( type.mod ) {
- // we add mod before modding to make sure that negatives values
+
+ // We add mod before modding to make sure that negatives values
// get converted properly: -10 -> 350
- return (value + type.mod) % type.mod;
+ return ( value + type.mod ) % type.mod;
}
- // for now all property types without mod have min and max
+ // For now all property types without mod have min and max
return 0 > value ? 0 : type.max < value ? type.max : value;
}
@@ -226,20 +230,20 @@ function stringParse( string ) {
if ( values ) {
parsed = inst[ spaceName ]( values );
- // if this was an rgba parse the assignment might happen twice
+ // If this was an rgba parse the assignment might happen twice
// oh well....
inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
rgba = inst._rgba = parsed._rgba;
- // exit each( stringParsers ) here because we matched
+ // Exit each( stringParsers ) here because we matched
return false;
}
- });
+ } );
// Found a stringParser that handled it
if ( rgba.length ) {
- // if this came from a parsed string, force "transparent" when alpha is 0
+ // If this came from a parsed string, force "transparent" when alpha is 0
// chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
if ( rgba.join() === "0,0,0,0" ) {
jQuery.extend( rgba, colors.transparent );
@@ -247,7 +251,7 @@ function stringParse( string ) {
return inst;
}
- // named colors
+ // Named colors
return colors[ string ];
}
@@ -266,7 +270,7 @@ color.fn = jQuery.extend( color.prototype, {
type = jQuery.type( red ),
rgba = this._rgba = [];
- // more than 1 argument specified - assume ( red, green, blue, alpha )
+ // More than 1 argument specified - assume ( red, green, blue, alpha )
if ( green !== undefined ) {
red = [ red, green, blue, alpha ];
type = "array";
@@ -279,7 +283,7 @@ color.fn = jQuery.extend( color.prototype, {
if ( type === "array" ) {
each( spaces.rgba.props, function( key, prop ) {
rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
- });
+ } );
return this;
}
@@ -289,16 +293,16 @@ color.fn = jQuery.extend( color.prototype, {
if ( red[ space.cache ] ) {
inst[ space.cache ] = red[ space.cache ].slice();
}
- });
+ } );
} else {
each( spaces, function( spaceName, space ) {
var cache = space.cache;
each( space.props, function( key, prop ) {
- // if the cache doesn't exist, and we know how to convert
+ // If the cache doesn't exist, and we know how to convert
if ( !inst[ cache ] && space.to ) {
- // if the value was null, we don't need to copy it
+ // If the value was null, we don't need to copy it
// if the key was alpha, we don't need to copy it either
if ( key === "alpha" || red[ key ] == null ) {
return;
@@ -306,20 +310,21 @@ color.fn = jQuery.extend( color.prototype, {
inst[ cache ] = space.to( inst._rgba );
}
- // this is the only case where we allow nulls for ALL properties.
+ // This is the only case where we allow nulls for ALL properties.
// call clamp with alwaysAllowEmpty
inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
- });
+ } );
- // everything defined but alpha?
+ // Everything defined but alpha?
if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
- // use the default of 1
+
+ // Use the default of 1
inst[ cache ][ 3 ] = 1;
if ( space.from ) {
inst._rgba = space.from( inst[ cache ] );
}
}
- });
+ } );
}
return this;
}
@@ -332,17 +337,17 @@ color.fn = jQuery.extend( color.prototype, {
each( spaces, function( _, space ) {
var localCache,
isCache = is[ space.cache ];
- if (isCache) {
+ if ( isCache ) {
localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
each( space.props, function( _, prop ) {
if ( isCache[ prop.idx ] != null ) {
same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
return same;
}
- });
+ } );
}
return same;
- });
+ } );
return same;
},
_space: function() {
@@ -352,7 +357,7 @@ color.fn = jQuery.extend( color.prototype, {
if ( inst[ space.cache ] ) {
used.push( spaceName );
}
- });
+ } );
return used.pop();
},
transition: function( other, distance ) {
@@ -370,11 +375,12 @@ color.fn = jQuery.extend( color.prototype, {
endValue = end[ index ],
type = propTypes[ prop.type ] || {};
- // if null, don't override start value
+ // If null, don't override start value
if ( endValue === null ) {
return;
}
- // if null - use end
+
+ // If null - use end
if ( startValue === null ) {
result[ index ] = endValue;
} else {
@@ -387,11 +393,12 @@ color.fn = jQuery.extend( color.prototype, {
}
result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
}
- });
+ } );
return this[ spaceName ]( result );
},
blend: function( opaque ) {
- // if we are already opaque - return ourself
+
+ // If we are already opaque - return ourself
if ( this._rgba[ 3 ] === 1 ) {
return this;
}
@@ -402,13 +409,13 @@ color.fn = jQuery.extend( color.prototype, {
return color( jQuery.map( rgb, function( v, i ) {
return ( 1 - a ) * blend[ i ] + a * v;
- }));
+ } ) );
},
toRgbaString: function() {
var prefix = "rgba(",
rgba = jQuery.map( this._rgba, function( v, i ) {
return v == null ? ( i > 2 ? 1 : 0 ) : v;
- });
+ } );
if ( rgba[ 3 ] === 1 ) {
rgba.pop();
@@ -424,12 +431,12 @@ color.fn = jQuery.extend( color.prototype, {
v = i > 2 ? 1 : 0;
}
- // catch 1 and 2
+ // Catch 1 and 2
if ( i && i < 3 ) {
v = Math.round( v * 100 ) + "%";
}
return v;
- });
+ } );
if ( hsla[ 3 ] === 1 ) {
hsla.pop();
@@ -447,18 +454,18 @@ color.fn = jQuery.extend( color.prototype, {
return "#" + jQuery.map( rgba, function( v ) {
- // default to 0 when nulls exist
+ // Default to 0 when nulls exist
v = ( v || 0 ).toString( 16 );
return v.length === 1 ? "0" + v : v;
- }).join("");
+ } ).join( "" );
},
toString: function() {
return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
}
-});
+} );
color.fn.parse.prototype = color.fn;
-// hsla conversions adapted from:
+// Hsla conversions adapted from:
// https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
function hue2rgb( p, q, h ) {
@@ -466,7 +473,7 @@ function hue2rgb( p, q, h ) {
if ( h * 6 < 1 ) {
return p + ( q - p ) * h * 6;
}
- if ( h * 2 < 1) {
+ if ( h * 2 < 1 ) {
return q;
}
if ( h * 3 < 2 ) {
@@ -500,7 +507,7 @@ spaces.hsla.to = function( rgba ) {
h = ( 60 * ( r - g ) / diff ) + 240;
}
- // chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
+ // Chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
// otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
if ( diff === 0 ) {
s = 0;
@@ -509,7 +516,7 @@ spaces.hsla.to = function( rgba ) {
} else {
s = diff / ( 2 - add );
}
- return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
+ return [ Math.round( h ) % 360, s, l, a == null ? 1 : a ];
};
spaces.hsla.from = function( hsla ) {
@@ -537,10 +544,10 @@ each( spaces, function( spaceName, space ) {
to = space.to,
from = space.from;
- // makes rgba() and hsla()
+ // Makes rgba() and hsla()
color.fn[ spaceName ] = function( value ) {
- // generate a cache for this space if it doesn't exist
+ // Generate a cache for this space if it doesn't exist
if ( to && !this[ cache ] ) {
this[ cache ] = to( this._rgba );
}
@@ -559,7 +566,7 @@ each( spaces, function( spaceName, space ) {
val = local[ prop.idx ];
}
local[ prop.idx ] = clamp( val, prop );
- });
+ } );
if ( from ) {
ret = color( from( local ) );
@@ -570,9 +577,10 @@ each( spaces, function( spaceName, space ) {
}
};
- // makes red() green() blue() alpha() hue() saturation() lightness()
+ // Makes red() green() blue() alpha() hue() saturation() lightness()
each( props, function( key, prop ) {
- // alpha is included in more than one space
+
+ // Alpha is included in more than one space
if ( color.fn[ key ] ) {
return;
}
@@ -603,10 +611,10 @@ each( spaces, function( spaceName, space ) {
local[ prop.idx ] = value;
return this[ fn ]( local );
};
- });
-});
+ } );
+} );
-// add cssHook and .fx.step function for each named hook.
+// Add cssHook and .fx.step function for each named hook.
// accept a space separated string of properties
color.hook = function( hook ) {
var hooks = hook.split( " " );
@@ -621,7 +629,7 @@ color.hook = function( hook ) {
if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
curElem = hook === "backgroundColor" ? elem.parentNode : elem;
while (
- (backgroundColor === "" || backgroundColor === "transparent") &&
+ ( backgroundColor === "" || backgroundColor === "transparent" ) &&
curElem && curElem.style
) {
try {
@@ -641,7 +649,8 @@ color.hook = function( hook ) {
try {
elem.style[ hook ] = value;
} catch ( e ) {
- // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
+
+ // Wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
}
}
};
@@ -653,7 +662,7 @@ color.hook = function( hook ) {
}
jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
};
- });
+ } );
};
@@ -665,7 +674,7 @@ jQuery.cssHooks.borderColor = {
each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
expanded[ "border" + part + "Color" ] = value;
- });
+ } );
return expanded;
}
};
@@ -674,6 +683,7 @@ jQuery.cssHooks.borderColor = {
// Usage of any of the other color names requires adding yourself or including
// jquery.color.svg-names.js.
colors = jQuery.Color.names = {
+
// 4.1. Basic color keywords
aqua: "#00ffff",
black: "#000000",
@@ -698,12 +708,12 @@ colors = jQuery.Color.names = {
_default: "#ffffff"
};
-})( jQuery );
+} )( jQuery );
/******************************************************************************/
/****************************** CLASS ANIMATIONS ******************************/
/******************************************************************************/
-(function() {
+( function() {
var classAnimationActions = [ "add", "remove", "toggle" ],
shorthandStyles = {
@@ -718,14 +728,14 @@ var classAnimationActions = [ "add", "remove", "toggle" ],
padding: 1
};
-$.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
+$.each( [ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
$.fx.step[ prop ] = function( fx ) {
if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
jQuery.style( fx.elem, prop, fx.end );
fx.setAttr = true;
}
};
-});
+} );
function getElementStyles( elem ) {
var key, len,
@@ -742,7 +752,8 @@ function getElementStyles( elem ) {
styles[ $.camelCase( key ) ] = style[ key ];
}
}
- // support: Opera, IE <9
+
+ // Support: Opera, IE <9
} else {
for ( key in style ) {
if ( typeof style[ key ] === "string" ) {
@@ -772,7 +783,7 @@ function styleDifference( oldStyle, newStyle ) {
return diff;
}
-// support: jQuery <1.8
+// Support: jQuery <1.8
if ( !$.fn.addBack ) {
$.fn.addBack = function( selector ) {
return this.add( selector == null ?
@@ -790,136 +801,139 @@ $.effects.animateClass = function( value, duration, easing, callback ) {
applyClassChange,
allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
- // map the animated objects to store the original styles.
- allAnimations = allAnimations.map(function() {
+ // Map the animated objects to store the original styles.
+ allAnimations = allAnimations.map( function() {
var el = $( this );
return {
el: el,
start: getElementStyles( this )
};
- });
+ } );
- // apply class change
+ // Apply class change
applyClassChange = function() {
- $.each( classAnimationActions, function(i, action) {
+ $.each( classAnimationActions, function( i, action ) {
if ( value[ action ] ) {
animated[ action + "Class" ]( value[ action ] );
}
- });
+ } );
};
applyClassChange();
- // map all animated objects again - calculate new styles and diff
- allAnimations = allAnimations.map(function() {
+ // Map all animated objects again - calculate new styles and diff
+ allAnimations = allAnimations.map( function() {
this.end = getElementStyles( this.el[ 0 ] );
this.diff = styleDifference( this.start, this.end );
return this;
- });
+ } );
- // apply original class
+ // Apply original class
animated.attr( "class", baseClass );
- // map all animated objects again - this time collecting a promise
- allAnimations = allAnimations.map(function() {
+ // Map all animated objects again - this time collecting a promise
+ allAnimations = allAnimations.map( function() {
var styleInfo = this,
dfd = $.Deferred(),
- opts = $.extend({}, o, {
+ opts = $.extend( {}, o, {
queue: false,
complete: function() {
dfd.resolve( styleInfo );
}
- });
+ } );
this.el.animate( this.diff, opts );
return dfd.promise();
- });
+ } );
- // once all animations have completed:
- $.when.apply( $, allAnimations.get() ).done(function() {
+ // Once all animations have completed:
+ $.when.apply( $, allAnimations.get() ).done( function() {
- // set the final class
+ // Set the final class
applyClassChange();
- // for each animated element,
+ // For each animated element,
// clear all css properties that were animated
$.each( arguments, function() {
var el = this.el;
- $.each( this.diff, function(key) {
+ $.each( this.diff, function( key ) {
el.css( key, "" );
- });
- });
+ } );
+ } );
- // this is guarnteed to be there if you use jQuery.speed()
+ // This is guarnteed to be there if you use jQuery.speed()
// it also handles dequeuing the next anim...
o.complete.call( animated[ 0 ] );
- });
- });
+ } );
+ } );
};
-$.fn.extend({
- addClass: (function( orig ) {
+$.fn.extend( {
+ addClass: ( function( orig ) {
return function( classNames, speed, easing, callback ) {
return speed ?
$.effects.animateClass.call( this,
{ add: classNames }, speed, easing, callback ) :
orig.apply( this, arguments );
};
- })( $.fn.addClass ),
+ } )( $.fn.addClass ),
- removeClass: (function( orig ) {
+ removeClass: ( function( orig ) {
return function( classNames, speed, easing, callback ) {
return arguments.length > 1 ?
$.effects.animateClass.call( this,
{ remove: classNames }, speed, easing, callback ) :
orig.apply( this, arguments );
};
- })( $.fn.removeClass ),
+ } )( $.fn.removeClass ),
- toggleClass: (function( orig ) {
+ toggleClass: ( function( orig ) {
return function( classNames, force, speed, easing, callback ) {
if ( typeof force === "boolean" || force === undefined ) {
if ( !speed ) {
- // without speed parameter
+
+ // Without speed parameter
return orig.apply( this, arguments );
} else {
return $.effects.animateClass.call( this,
- (force ? { add: classNames } : { remove: classNames }),
+ ( force ? { add: classNames } : { remove: classNames } ),
speed, easing, callback );
}
} else {
- // without force parameter
+
+ // Without force parameter
return $.effects.animateClass.call( this,
{ toggle: classNames }, force, speed, easing );
}
};
- })( $.fn.toggleClass ),
+ } )( $.fn.toggleClass ),
- switchClass: function( remove, add, speed, easing, callback) {
+ switchClass: function( remove, add, speed, easing, callback ) {
return $.effects.animateClass.call( this, {
add: add,
remove: remove
}, speed, easing, callback );
}
-});
+} );
-})();
+} )();
/******************************************************************************/
/*********************************** EFFECTS **********************************/
/******************************************************************************/
-(function() {
+( function() {
if ( $.expr && $.expr.filters && $.expr.filters.animated ) {
- $.expr.filters.animated = (function( orig ) {
+ $.expr.filters.animated = ( function( orig ) {
return function( elem ) {
return !!$( elem ).data( dataSpaceAnimated ) || orig( elem );
};
- })( $.expr.filters.animated );
+ } )( $.expr.filters.animated );
}
if ( $.uiBackCompat !== false ) {
$.extend( $.effects, {
+
// Saves a set of properties in a data storage
save: function( element, set ) {
var i = 0, length = set.length;
@@ -951,12 +965,12 @@ if ( $.uiBackCompat !== false ) {
// Wraps the element around a wrapper that copies position properties
createWrapper: function( element ) {
- // if the element is already wrapped, return it
+ // If the element is already wrapped, return it
if ( element.parent().is( ".ui-effects-wrapper" ) ) {
return element.parent();
}
- // wrap the element
+ // Wrap the element
var props = {
width: element.outerWidth( true ),
height: element.outerHeight( true ),
@@ -964,13 +978,14 @@ if ( $.uiBackCompat !== false ) {
},
wrapper = $( "<div></div>" )
.addClass( "ui-effects-wrapper" )
- .css({
+ .css( {
fontSize: "100%",
background: "transparent",
border: "none",
margin: 0,
padding: 0
- }),
+ } ),
+
// Store the size in case width/height are defined in % - Fixes #5245
size = {
width: element.width(),
@@ -978,7 +993,7 @@ if ( $.uiBackCompat !== false ) {
},
active = document.activeElement;
- // support: Firefox
+ // Support: Firefox
// Firefox incorrectly exposes anonymous content
// https://bugzilla.mozilla.org/show_bug.cgi?id=561664
try {
@@ -996,30 +1011,30 @@ if ( $.uiBackCompat !== false ) {
wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
- // transfer positioning properties to the wrapper
+ // Transfer positioning properties to the wrapper
if ( element.css( "position" ) === "static" ) {
- wrapper.css({ position: "relative" });
- element.css({ position: "relative" });
+ wrapper.css( { position: "relative" } );
+ element.css( { position: "relative" } );
} else {
$.extend( props, {
position: element.css( "position" ),
zIndex: element.css( "z-index" )
- });
- $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
+ } );
+ $.each( [ "top", "left", "bottom", "right" ], function( i, pos ) {
props[ pos ] = element.css( pos );
if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
props[ pos ] = "auto";
}
- });
- element.css({
+ } );
+ element.css( {
position: "relative",
top: 0,
left: 0,
right: "auto",
bottom: "auto"
- });
+ } );
}
- element.css(size);
+ element.css( size );
return wrapper.css( props ).show();
},
@@ -1038,7 +1053,7 @@ if ( $.uiBackCompat !== false ) {
return element;
}
- });
+ } );
}
$.extend( $.effects, {
@@ -1167,19 +1182,19 @@ $.extend( $.effects, {
// will change margin if you explicitly set height
// see: http://jsfiddle.net/JZSMt/3/ https://bugs.webkit.org/show_bug.cgi?id=107380
// Support: Safari
- element.css({
+ element.css( {
marginTop: element.css( "marginTop" ),
marginBottom: element.css( "marginBottom" ),
marginLeft: element.css( "marginLeft" ),
marginRight: element.css( "marginRight" )
- })
+ } )
.outerWidth( element.outerWidth() )
.outerHeight( element.outerHeight() );
if ( /^(static|relative)/.test( cssPosition ) ) {
cssPosition = "absolute";
- placeholder = $( "<" + element[ 0 ].nodeName + ">" ).insertAfter( element ).css({
+ placeholder = $( "<" + element[ 0 ].nodeName + ">" ).insertAfter( element ).css( {
// Convert inline to inline block to account for inline elements
// that turn to inline block based on content (like img)
@@ -1192,7 +1207,7 @@ $.extend( $.effects, {
marginLeft: element.css( "marginLeft" ),
marginRight: element.css( "marginRight" ),
"float": element.css( "float" )
- })
+ } )
.outerWidth( element.outerWidth() )
.outerHeight( element.outerHeight() )
.addClass( "ui-effects-placeholder" );
@@ -1200,11 +1215,11 @@ $.extend( $.effects, {
element.data( dataSpace + "placeholder", placeholder );
}
- element.css({
+ element.css( {
position: cssPosition,
left: position.left,
top: position.top
- });
+ } );
return placeholder;
},
@@ -1233,49 +1248,49 @@ $.extend( $.effects, {
if ( unit[ 0 ] > 0 ) {
value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
}
- });
+ } );
return value;
}
-});
+} );
-// return an effect options object for the given parameters:
+// Return an effect options object for the given parameters:
function _normalizeArguments( effect, options, speed, callback ) {
- // allow passing all options as the first parameter
+ // Allow passing all options as the first parameter
if ( $.isPlainObject( effect ) ) {
options = effect;
effect = effect.effect;
}
- // convert to an object
+ // Convert to an object
effect = { effect: effect };
- // catch (effect, null, ...)
+ // Catch (effect, null, ...)
if ( options == null ) {
options = {};
}
- // catch (effect, callback)
+ // Catch (effect, callback)
if ( $.isFunction( options ) ) {
callback = options;
speed = null;
options = {};
}
- // catch (effect, speed, ?)
+ // Catch (effect, speed, ?)
if ( typeof options === "number" || $.fx.speeds[ options ] ) {
callback = speed;
speed = options;
options = {};
}
- // catch (effect, options, callback)
+ // Catch (effect, options, callback)
if ( $.isFunction( speed ) ) {
callback = speed;
speed = null;
}
- // add options to effect
+ // Add options to effect
if ( options ) {
$.extend( effect, options );
}
@@ -1292,6 +1307,7 @@ function _normalizeArguments( effect, options, speed, callback ) {
}
function standardAnimationOption( option ) {
+
// Valid standard speeds (nothing, number, named speed)
if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
return true;
@@ -1316,7 +1332,7 @@ function standardAnimationOption( option ) {
return false;
}
-$.fn.extend({
+$.fn.extend( {
effect: function( /* effect, options, speed, callback */ ) {
var args = _normalizeArguments.apply( this, arguments ),
effectMethod = $.effects.effect[ args.effect ],
@@ -1354,7 +1370,8 @@ $.fn.extend({
};
if ( $.fx.off || !effectMethod ) {
- // delegate to the original method (e.g., .show()) if possible
+
+ // Delegate to the original method (e.g., .show()) if possible
if ( mode ) {
return this[ mode ]( args.duration, complete );
} else {
@@ -1362,7 +1379,7 @@ $.fn.extend({
if ( complete ) {
complete.call( this );
}
- });
+ } );
}
}
@@ -1424,7 +1441,7 @@ $.fn.extend({
this.queue( queueName, prefilter ).queue( queueName, run );
},
- show: (function( orig ) {
+ show: ( function( orig ) {
return function( option ) {
if ( standardAnimationOption( option ) ) {
return orig.apply( this, arguments );
@@ -1434,9 +1451,9 @@ $.fn.extend({
return this.effect.call( this, args );
}
};
- })( $.fn.show ),
+ } )( $.fn.show ),
- hide: (function( orig ) {
+ hide: ( function( orig ) {
return function( option ) {
if ( standardAnimationOption( option ) ) {
return orig.apply( this, arguments );
@@ -1446,9 +1463,9 @@ $.fn.extend({
return this.effect.call( this, args );
}
};
- })( $.fn.hide ),
+ } )( $.fn.hide ),
- toggle: (function( orig ) {
+ toggle: ( function( orig ) {
return function( option ) {
if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
return orig.apply( this, arguments );
@@ -1458,9 +1475,9 @@ $.fn.extend({
return this.effect.call( this, args );
}
};
- })( $.fn.toggle ),
+ } )( $.fn.toggle ),
- cssUnit: function(key) {
+ cssUnit: function( key ) {
var style = this.css( key ),
val = [];
@@ -1468,14 +1485,14 @@ $.fn.extend({
if ( style.indexOf( unit ) > 0 ) {
val = [ parseFloat( style ), unit ];
}
- });
+ } );
return val;
},
cssClip: function( clipObj ) {
return clipObj ?
this.css( "clip", "rect(" + clipObj.top + "px " + clipObj.right + "px " + clipObj.bottom + "px " + clipObj.left + "px)" ) :
- parseClip( this.css("clip"), this );
+ parseClip( this.css( "clip" ), this );
},
transfer: function( options, done ) {
@@ -1496,21 +1513,21 @@ $.fn.extend({
transfer = $( "<div class='ui-effects-transfer'></div>" )
.appendTo( "body" )
.addClass( options.className )
- .css({
+ .css( {
top: startPosition.top - fixTop,
left: startPosition.left - fixLeft,
height: element.innerHeight(),
width: element.innerWidth(),
position: targetFixed ? "fixed" : "absolute"
- })
+ } )
.animate( animation, options.duration, options.easing, function() {
transfer.remove();
if ( $.isFunction( done ) ) {
done();
}
- });
+ } );
}
-});
+} );
function parseClip( str, element ) {
var outerWidth = element.outerWidth(),
@@ -1535,23 +1552,23 @@ $.fx.step.clip = function( fx ) {
fx.clipInit = true;
}
- $( fx.elem ).cssClip({
- top: fx.pos * (fx.end.top - fx.start.top) + fx.start.top,
- right: fx.pos * (fx.end.right - fx.start.right) + fx.start.right,
- bottom: fx.pos * (fx.end.bottom - fx.start.bottom) + fx.start.bottom,
- left: fx.pos * (fx.end.left - fx.start.left) + fx.start.left
- });
+ $( fx.elem ).cssClip( {
+ top: fx.pos * ( fx.end.top - fx.start.top ) + fx.start.top,
+ right: fx.pos * ( fx.end.right - fx.start.right ) + fx.start.right,
+ bottom: fx.pos * ( fx.end.bottom - fx.start.bottom ) + fx.start.bottom,
+ left: fx.pos * ( fx.end.left - fx.start.left ) + fx.start.left
+ } );
};
-})();
+} )();
/******************************************************************************/
/*********************************** EASING ***********************************/
/******************************************************************************/
-(function() {
+( function() {
-// based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
+// Based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
var baseEasings = {};
@@ -1559,7 +1576,7 @@ $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
baseEasings[ name ] = function( p ) {
return Math.pow( p, i + 2 );
};
-});
+} );
$.extend( baseEasings, {
Sine: function( p ) {
@@ -1570,7 +1587,7 @@ $.extend( baseEasings, {
},
Elastic: function( p ) {
return p === 0 || p === 1 ? p :
- -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
+ -Math.pow( 2, 8 * ( p - 1 ) ) * Math.sin( ( ( p - 1 ) * 80 - 7.5 ) * Math.PI / 15 );
},
Back: function( p ) {
return p * p * ( 3 * p - 2 );
@@ -1582,7 +1599,7 @@ $.extend( baseEasings, {
while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
}
-});
+} );
$.each( baseEasings, function( name, easeIn ) {
$.easing[ "easeIn" + name ] = easeIn;
@@ -1594,10 +1611,10 @@ $.each( baseEasings, function( name, easeIn ) {
easeIn( p * 2 ) / 2 :
1 - easeIn( p * -2 + 2 ) / 2;
};
-});
+} );
-})();
+} )();
return $.effects;
-}));
+} ) );
diff --git a/ui/effects/effect-bounce.js b/ui/effects/effect-bounce.js
index 06bc84426..1743ef503 100644
--- a/ui/effects/effect-bounce.js
+++ b/ui/effects/effect-bounce.js
@@ -33,7 +33,7 @@ return $.effects.define( "bounce", function( options, done ) {
var upAnim, downAnim, refValue,
element = $( this ),
- // defaults:
+ // Defaults:
mode = options.mode,
hide = mode === "hide",
show = mode === "show",
@@ -41,12 +41,12 @@ return $.effects.define( "bounce", function( options, done ) {
distance = options.distance,
times = options.times || 5,
- // number of internal animations
+ // Number of internal animations
anims = times * 2 + ( show || hide ? 1 : 0 ),
speed = options.duration / anims,
easing = options.easing,
- // utility:
+ // Utility:
ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
motion = ( direction === "up" || direction === "left" ),
i = 0,
@@ -57,7 +57,7 @@ return $.effects.define( "bounce", function( options, done ) {
refValue = element.css( ref );
- // default distance for the BIGGEST bounce is the outer Distance / 3
+ // Default distance for the BIGGEST bounce is the outer Distance / 3
if ( !distance ) {
distance = element[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
}
@@ -66,7 +66,7 @@ return $.effects.define( "bounce", function( options, done ) {
downAnim = { opacity: 1 };
downAnim[ ref ] = refValue;
- // if we are showing, force opacity 0 and set the initial position
+ // If we are showing, force opacity 0 and set the initial position
// then do the "first" animation
element
.css( "opacity", 0 )
@@ -74,13 +74,14 @@ return $.effects.define( "bounce", function( options, done ) {
.animate( downAnim, speed, easing );
}
- // start at the smallest distance if we are hiding
+ // Start at the smallest distance if we are hiding
if ( hide ) {
distance = distance / Math.pow( 2, times - 1 );
}
downAnim = {};
downAnim[ ref ] = refValue;
+
// Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
for ( ; i < times; i++ ) {
upAnim = {};
diff --git a/ui/effects/effect-explode.js b/ui/effects/effect-explode.js
index 55c247d3e..92b83f545 100644
--- a/ui/effects/effect-explode.js
+++ b/ui/effects/effect-explode.js
@@ -38,15 +38,15 @@ return $.effects.define( "explode", "hide", function( options, done ) {
mode = options.mode,
show = mode === "show",
- // show and then visibility:hidden the element before calculating offset
+ // Show and then visibility:hidden the element before calculating offset
offset = element.show().css( "visibility", "hidden" ).offset(),
- // width and height of a piece
+ // Width and height of a piece
width = Math.ceil( element.outerWidth() / cells ),
height = Math.ceil( element.outerHeight() / rows ),
pieces = [];
- // children animate complete:
+ // Children animate complete:
function childComplete() {
pieces.push( this );
if ( pieces.length === rows * cells ) {
@@ -54,7 +54,7 @@ return $.effects.define( "explode", "hide", function( options, done ) {
}
}
- // clone the element for each row and cell.
+ // Clone the element for each row and cell.
for ( i = 0; i < rows; i++ ) { // ===>
top = offset.top + i * height;
my = i - ( rows - 1 ) / 2;
@@ -76,7 +76,7 @@ return $.effects.define( "explode", "hide", function( options, done ) {
top: -i * height
} )
- // select the wrapper - make it overflow: hidden and absolute positioned based on
+ // Select the wrapper - make it overflow: hidden and absolute positioned based on
// where the original was located +left and +top equal to the size of pieces
.parent()
.addClass( "ui-effects-explode" )
diff --git a/ui/focusable.js b/ui/focusable.js
index b6e86e062..6b7a0b1f1 100644
--- a/ui/focusable.js
+++ b/ui/focusable.js
@@ -24,7 +24,7 @@
}
} ( function( $ ) {
-// selectors
+// Selectors
$.ui.focusable = function( element, hasTabindex ) {
var map, mapName, img,
nodeName = element.nodeName.toLowerCase();
@@ -34,23 +34,26 @@ $.ui.focusable = function( element, hasTabindex ) {
if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
return false;
}
- img = $( "img[usemap='#" + mapName + "']" )[ 0 ];
- return !!img && visible( img );
+ img = $( "img[usemap='#" + mapName + "']" );
+ return img.length > 0 && img.is( ":visible" );
}
return ( /^(input|select|textarea|button|object)$/.test( nodeName ) ?
!element.disabled :
"a" === nodeName ?
element.href || hasTabindex :
hasTabindex ) &&
- // the element and all of its ancestors must be visible
- visible( element );
+ $( element ).is( ":visible" ) && visible( $( element ) );
};
+// Support: IE 8 only
+// IE 8 doesn't resolve inherit to visible/hidden for computed values
function visible( element ) {
- return $.expr.filters.visible( element ) &&
- !$( element ).parents().addBack().filter( function() {
- return $.css( this, "visibility" ) === "hidden";
- } ).length;
+ var visibility = element.css( "visibility" );
+ while ( visibility === "inherit" ) {
+ element = element.parent();
+ visibility = element.css( "visibility" );
+ }
+ return visibility !== "hidden";
}
$.extend( $.expr[ ":" ], {
diff --git a/ui/jquery-1-7.js b/ui/jquery-1-7.js
index 29e008e8a..8d25f8807 100644
--- a/ui/jquery-1-7.js
+++ b/ui/jquery-1-7.js
@@ -24,7 +24,7 @@
}
}( function( $ ) {
-// support: jQuery 1.7 only
+// Support: jQuery 1.7 only
// Not a great way to check versions, but since we only support 1.7+ and only
// need to detect <1.8, this is a simple check that should suffice. Checking
// for "1.7." would be a bit safer, but the version string is 1.7, not 1.7.0
diff --git a/ui/position.js b/ui/position.js
index e9e805bb6..64f86173e 100644
--- a/ui/position.js
+++ b/ui/position.js
@@ -159,7 +159,7 @@ $.fn.position = function( options ) {
return _position.apply( this, arguments );
}
- // make a copy, we don't want to modify arguments
+ // Make a copy, we don't want to modify arguments
options = $.extend( {}, options );
var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
@@ -171,16 +171,18 @@ $.fn.position = function( options ) {
dimensions = getDimensions( target );
if ( target[ 0 ].preventDefault ) {
- // force left top to allow flipping
+
+ // Force left top to allow flipping
options.at = "left top";
}
targetWidth = dimensions.width;
targetHeight = dimensions.height;
targetOffset = dimensions.offset;
- // clone to reuse original targetOffset later
+
+ // Clone to reuse original targetOffset later
basePosition = $.extend( {}, targetOffset );
- // force my and at to have valid horizontal and vertical positions
+ // Force my and at to have valid horizontal and vertical positions
// if a value is missing or invalid, it will be converted to center
$.each( [ "my", "at" ], function() {
var pos = ( options[ this ] || "" ).split( " " ),
@@ -197,7 +199,7 @@ $.fn.position = function( options ) {
pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
- // calculate offsets
+ // Calculate offsets
horizontalOffset = roffset.exec( pos[ 0 ] );
verticalOffset = roffset.exec( pos[ 1 ] );
offsets[ this ] = [
@@ -205,14 +207,14 @@ $.fn.position = function( options ) {
verticalOffset ? verticalOffset[ 0 ] : 0
];
- // reduce to just the positions without the offsets
+ // Reduce to just the positions without the offsets
options[ this ] = [
rposition.exec( pos[ 0 ] )[ 0 ],
rposition.exec( pos[ 1 ] )[ 0 ]
];
} );
- // normalize collision option
+ // Normalize collision option
if ( collision.length === 1 ) {
collision[ 1 ] = collision[ 0 ];
}
@@ -260,7 +262,7 @@ $.fn.position = function( options ) {
position.left += myOffset[ 0 ];
position.top += myOffset[ 1 ];
- // if the browser doesn't support fractions, then round for consistent results
+ // If the browser doesn't support fractions, then round for consistent results
if ( !supportsOffsetFractions() ) {
position.left = round( position.left );
position.top = round( position.top );
@@ -291,7 +293,8 @@ $.fn.position = function( options ) {
} );
if ( options.using ) {
- // adds feedback as second argument to using callback, if present
+
+ // Adds feedback as second argument to using callback, if present
using = function( props ) {
var left = targetOffset.left - position.left,
right = left + targetWidth - elemWidth,
@@ -345,16 +348,19 @@ $.ui.position = {
overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
newOverRight;
- // element is wider than within
+ // Element is wider than within
if ( data.collisionWidth > outerWidth ) {
- // element is initially over the left side of within
+
+ // Element is initially over the left side of within
if ( overLeft > 0 && overRight <= 0 ) {
newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
position.left += overLeft - newOverRight;
- // element is initially over right side of within
+
+ // Element is initially over right side of within
} else if ( overRight > 0 && overLeft <= 0 ) {
position.left = withinOffset;
- // element is initially over both left and right sides of within
+
+ // Element is initially over both left and right sides of within
} else {
if ( overLeft > overRight ) {
position.left = withinOffset + outerWidth - data.collisionWidth;
@@ -362,13 +368,16 @@ $.ui.position = {
position.left = withinOffset;
}
}
- // too far left -> align with left edge
+
+ // Too far left -> align with left edge
} else if ( overLeft > 0 ) {
position.left += overLeft;
- // too far right -> align with right edge
+
+ // Too far right -> align with right edge
} else if ( overRight > 0 ) {
position.left -= overRight;
- // adjust based on position and margin
+
+ // Adjust based on position and margin
} else {
position.left = max( position.left - collisionPosLeft, position.left );
}
@@ -382,16 +391,19 @@ $.ui.position = {
overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
newOverBottom;
- // element is taller than within
+ // Element is taller than within
if ( data.collisionHeight > outerHeight ) {
- // element is initially over the top of within
+
+ // Element is initially over the top of within
if ( overTop > 0 && overBottom <= 0 ) {
newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
position.top += overTop - newOverBottom;
- // element is initially over bottom of within
+
+ // Element is initially over bottom of within
} else if ( overBottom > 0 && overTop <= 0 ) {
position.top = withinOffset;
- // element is initially over both top and bottom of within
+
+ // Element is initially over both top and bottom of within
} else {
if ( overTop > overBottom ) {
position.top = withinOffset + outerHeight - data.collisionHeight;
@@ -399,13 +411,16 @@ $.ui.position = {
position.top = withinOffset;
}
}
- // too far up -> align with top
+
+ // Too far up -> align with top
} else if ( overTop > 0 ) {
position.top += overTop;
- // too far down -> align with bottom edge
+
+ // Too far down -> align with bottom edge
} else if ( overBottom > 0 ) {
position.top -= overBottom;
- // adjust based on position and margin
+
+ // Adjust based on position and margin
} else {
position.top = max( position.top - collisionPosTop, position.top );
}
diff --git a/ui/widget.js b/ui/widget.js
index c6f228efd..1542cc88b 100644
--- a/ui/widget.js
+++ b/ui/widget.js
@@ -25,8 +25,8 @@
}
}( function( $ ) {
-var widget_uuid = 0,
- widget_slice = Array.prototype.slice;
+var widgetUuid = 0;
+var widgetSlice = Array.prototype.slice;
$.cleanData = ( function( orig ) {
return function( elems ) {
@@ -40,7 +40,7 @@ $.cleanData = ( function( orig ) {
$( elem ).triggerHandler( "remove" );
}
- // http://bugs.jquery.com/ticket/8235
+ // Http://bugs.jquery.com/ticket/8235
} catch ( e ) {}
}
orig( elems );
@@ -48,14 +48,15 @@ $.cleanData = ( function( orig ) {
} )( $.cleanData );
$.widget = function( name, base, prototype ) {
- var fullName, existingConstructor, constructor, basePrototype,
- // proxiedPrototype allows the provided prototype to remain unmodified
- // so that it can be used as a mixin for multiple widgets (#8876)
- proxiedPrototype = {},
- namespace = name.split( "." )[ 0 ];
+ var existingConstructor, constructor, basePrototype;
+ // ProxiedPrototype allows the provided prototype to remain unmodified
+ // so that it can be used as a mixin for multiple widgets (#8876)
+ var proxiedPrototype = {};
+
+ var namespace = name.split( "." )[ 0 ];
name = name.split( "." )[ 1 ];
- fullName = namespace + "-" + name;
+ var fullName = namespace + "-" + name;
if ( !prototype ) {
prototype = base;
@@ -66,7 +67,7 @@ $.widget = function( name, base, prototype ) {
prototype = $.extend.apply( null, [ {} ].concat( prototype ) );
}
- // create selector for plugin
+ // Create selector for plugin
$.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
return !!$.data( elem, fullName );
};
@@ -74,30 +75,35 @@ $.widget = function( name, base, prototype ) {
$[ namespace ] = $[ namespace ] || {};
existingConstructor = $[ namespace ][ name ];
constructor = $[ namespace ][ name ] = function( options, element ) {
- // allow instantiation without "new" keyword
+
+ // Allow instantiation without "new" keyword
if ( !this._createWidget ) {
return new constructor( options, element );
}
- // allow instantiation without initializing for simple inheritance
+ // Allow instantiation without initializing for simple inheritance
// must use "new" keyword (the code above always passes args)
if ( arguments.length ) {
this._createWidget( options, element );
}
};
- // extend with the existing constructor to carry over any static properties
+
+ // Extend with the existing constructor to carry over any static properties
$.extend( constructor, existingConstructor, {
version: prototype.version,
- // copy the object used to create the prototype in case we need to
+
+ // Copy the object used to create the prototype in case we need to
// redefine the widget later
_proto: $.extend( {}, prototype ),
- // track widgets that inherit from this widget in case this widget is
+
+ // Track widgets that inherit from this widget in case this widget is
// redefined after a widget inherits from it
_childConstructors: []
} );
basePrototype = new base();
- // we need to make the options hash a property directly on the new instance
+
+ // We need to make the options hash a property directly on the new instance
// otherwise we'll modify the options hash on the prototype that we're
// inheriting from
basePrototype.options = $.widget.extend( {}, basePrototype.options );
@@ -107,16 +113,18 @@ $.widget = function( name, base, prototype ) {
return;
}
proxiedPrototype[ prop ] = ( function() {
- var _super = function() {
- return base.prototype[ prop ].apply( this, arguments );
- },
- _superApply = function( args ) {
- return base.prototype[ prop ].apply( this, args );
- };
+ function _super() {
+ return base.prototype[ prop ].apply( this, arguments );
+ }
+
+ function _superApply( args ) {
+ return base.prototype[ prop ].apply( this, args );
+ }
+
return function() {
- var __super = this._super,
- __superApply = this._superApply,
- returnValue;
+ var __super = this._super;
+ var __superApply = this._superApply;
+ var returnValue;
this._super = _super;
this._superApply = _superApply;
@@ -131,6 +139,7 @@ $.widget = function( name, base, prototype ) {
} )();
} );
constructor.prototype = $.widget.extend( basePrototype, {
+
// TODO: remove support for widgetEventPrefix
// always use the name + a colon as the prefix, e.g., draggable:start
// don't prefix for widgets that aren't DOM-based
@@ -150,11 +159,13 @@ $.widget = function( name, base, prototype ) {
$.each( existingConstructor._childConstructors, function( i, child ) {
var childPrototype = child.prototype;
- // redefine the child widget using the same prototype that was
+ // Redefine the child widget using the same prototype that was
// originally used, but inherit from the new version of the base
- $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
+ $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor,
+ child._proto );
} );
- // remove the list of existing child constructors from the old constructor
+
+ // Remove the list of existing child constructors from the old constructor
// so the old child constructors can be garbage collected
delete existingConstructor._childConstructors;
} else {
@@ -167,21 +178,25 @@ $.widget = function( name, base, prototype ) {
};
$.widget.extend = function( target ) {
- var input = widget_slice.call( arguments, 1 ),
- inputIndex = 0,
- inputLength = input.length,
- key,
- value;
+ var input = widgetSlice.call( arguments, 1 );
+ var inputIndex = 0;
+ var inputLength = input.length;
+ var key;
+ var value;
+
for ( ; inputIndex < inputLength; inputIndex++ ) {
for ( key in input[ inputIndex ] ) {
value = input[ inputIndex ][ key ];
if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
+
// Clone objects
if ( $.isPlainObject( value ) ) {
target[ key ] = $.isPlainObject( target[ key ] ) ?
$.widget.extend( {}, target[ key ], value ) :
+
// Don't extend strings, arrays, etc. with objects
$.widget.extend( {}, value );
+
// Copy everything else by reference
} else {
target[ key ] = value;
@@ -195,26 +210,31 @@ $.widget.extend = function( target ) {
$.widget.bridge = function( name, object ) {
var fullName = object.prototype.widgetFullName || name;
$.fn[ name ] = function( options ) {
- var isMethodCall = typeof options === "string",
- args = widget_slice.call( arguments, 1 ),
- returnValue = this;
+ var isMethodCall = typeof options === "string";
+ var args = widgetSlice.call( arguments, 1 );
+ var returnValue = this;
if ( isMethodCall ) {
this.each( function() {
- var methodValue,
- instance = $.data( this, fullName );
+ var methodValue;
+ var instance = $.data( this, fullName );
+
if ( options === "instance" ) {
returnValue = instance;
return false;
}
+
if ( !instance ) {
return $.error( "cannot call methods on " + name + " prior to initialization; " +
"attempted to call method '" + options + "'" );
}
+
if ( !$.isFunction( instance[ options ] ) || options.charAt( 0 ) === "_" ) {
return $.error( "no such method '" + options + "' for " + name + " widget instance" );
}
+
methodValue = instance[ options ].apply( instance, args );
+
if ( methodValue !== instance && methodValue !== undefined ) {
returnValue = methodValue && methodValue.jquery ?
returnValue.pushStack( methodValue.get() ) :
@@ -253,17 +273,19 @@ $.Widget.prototype = {
widgetName: "widget",
widgetEventPrefix: "",
defaultElement: "<div>",
+
options: {
classes: {},
disabled: false,
- // callbacks
+ // Callbacks
create: null
},
+
_createWidget: function( options, element ) {
element = $( element || this.defaultElement || this )[ 0 ];
this.element = $( element );
- this.uuid = widget_uuid++;
+ this.uuid = widgetUuid++;
this.eventNamespace = "." + this.widgetName + this.uuid;
this.bindings = $();
@@ -281,9 +303,11 @@ $.Widget.prototype = {
}
} );
this.document = $( element.style ?
- // element within the document
+
+ // Element within the document
element.ownerDocument :
- // element is window or document
+
+ // Element is window or document
element.document || element );
this.window = $( this.document[ 0 ].defaultView || this.document[ 0 ].parentWindow );
}
@@ -294,12 +318,23 @@ $.Widget.prototype = {
options );
this._create();
+
+ if ( this.options.disabled ) {
+ this._setOptionDisabled( this.options.disabled );
+ }
+
this._trigger( "create", null, this._getCreateEventData() );
this._init();
},
- _getCreateOptions: $.noop,
+
+ _getCreateOptions: function() {
+ return {};
+ },
+
_getCreateEventData: $.noop,
+
_create: $.noop,
+
_init: $.noop,
destroy: function() {
@@ -310,7 +345,7 @@ $.Widget.prototype = {
that._removeClass( value, key );
} );
- // we can probably remove the unbind calls in 2.0
+ // We can probably remove the unbind calls in 2.0
// all event bindings should go through this._on()
this.element
.off( this.eventNamespace )
@@ -319,9 +354,10 @@ $.Widget.prototype = {
.off( this.eventNamespace )
.removeAttr( "aria-disabled" );
- // clean up events and states
+ // Clean up events and states
this.bindings.off( this.eventNamespace );
},
+
_destroy: $.noop,
widget: function() {
@@ -329,18 +365,20 @@ $.Widget.prototype = {
},
option: function( key, value ) {
- var options = key,
- parts,
- curOption,
- i;
+ var options = key;
+ var parts;
+ var curOption;
+ var i;
if ( arguments.length === 0 ) {
- // don't return a reference to the internal hash
+
+ // Don't return a reference to the internal hash
return $.widget.extend( {}, this.options );
}
if ( typeof key === "string" ) {
- // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
+
+ // Handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
options = {};
parts = key.split( "." );
key = parts.shift();
@@ -367,6 +405,7 @@ $.Widget.prototype = {
return this;
},
+
_setOptions: function( options ) {
var key;
@@ -376,6 +415,7 @@ $.Widget.prototype = {
return this;
},
+
_setOption: function( key, value ) {
if ( key === "classes" ) {
this._setOptionClasses( value );
@@ -384,17 +424,12 @@ $.Widget.prototype = {
this.options[ key ] = value;
if ( key === "disabled" ) {
- this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null, !!value );
-
- // If the widget is becoming disabled, then nothing is interactive
- if ( value ) {
- this._removeClass( this.hoverable, null, "ui-state-hover" );
- this._removeClass( this.focusable, null, "ui-state-focus" );
- }
+ this._setOptionDisabled( value );
}
return this;
},
+
_setOptionClasses: function( value ) {
var classKey, elements, currentElements;
@@ -426,16 +461,27 @@ $.Widget.prototype = {
}
},
+ _setOptionDisabled: function( value ) {
+ this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null, !!value );
+
+ // If the widget is becoming disabled, then nothing is interactive
+ if ( value ) {
+ this._removeClass( this.hoverable, null, "ui-state-hover" );
+ this._removeClass( this.focusable, null, "ui-state-focus" );
+ }
+ },
+
enable: function() {
return this._setOptions( { disabled: false } );
},
+
disable: function() {
return this._setOptions( { disabled: true } );
},
_classes: function( options ) {
- var full = [],
- that = this;
+ var full = [];
+ var that = this;
options = $.extend( {
element: this.element,
@@ -491,17 +537,17 @@ $.Widget.prototype = {
},
_on: function( suppressDisabledCheck, element, handlers ) {
- var delegateElement,
- instance = this;
+ var delegateElement;
+ var instance = this;
- // no suppressDisabledCheck flag, shuffle arguments
+ // No suppressDisabledCheck flag, shuffle arguments
if ( typeof suppressDisabledCheck !== "boolean" ) {
handlers = element;
element = suppressDisabledCheck;
suppressDisabledCheck = false;
}
- // no element argument, shuffle and use this.element
+ // No element argument, shuffle and use this.element
if ( !handlers ) {
handlers = element;
element = this.element;
@@ -513,7 +559,8 @@ $.Widget.prototype = {
$.each( handlers, function( event, handler ) {
function handlerProxy() {
- // allow widgets to customize the disabled handling
+
+ // Allow widgets to customize the disabled handling
// - disabled as an array instead of boolean
// - disabled class as method for disabling individual parts
if ( !suppressDisabledCheck &&
@@ -525,15 +572,16 @@ $.Widget.prototype = {
.apply( instance, arguments );
}
- // copy the guid so direct unbinding works
+ // Copy the guid so direct unbinding works
if ( typeof handler !== "string" ) {
handlerProxy.guid = handler.guid =
handler.guid || handlerProxy.guid || $.guid++;
}
- var match = event.match( /^([\w:-]*)\s*(.*)$/ ),
- eventName = match[ 1 ] + instance.eventNamespace,
- selector = match[ 2 ];
+ var match = event.match( /^([\w:-]*)\s*(.*)$/ );
+ var eventName = match[ 1 ] + instance.eventNamespace;
+ var selector = match[ 2 ];
+
if ( selector ) {
delegateElement.on( eventName, selector, handlerProxy );
} else {
@@ -587,19 +635,20 @@ $.Widget.prototype = {
},
_trigger: function( type, event, data ) {
- var prop, orig,
- callback = this.options[ type ];
+ var prop, orig;
+ var callback = this.options[ type ];
data = data || {};
event = $.Event( event );
event.type = ( type === this.widgetEventPrefix ?
type :
this.widgetEventPrefix + type ).toLowerCase();
- // the original event may come from any element
+
+ // The original event may come from any element
// so we need to reset the target on the new event
event.target = this.element[ 0 ];
- // copy original event properties over to the new event
+ // Copy original event properties over to the new event
orig = event.originalEvent;
if ( orig ) {
for ( prop in orig ) {
@@ -621,21 +670,26 @@ $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
if ( typeof options === "string" ) {
options = { effect: options };
}
- var hasOptions,
- effectName = !options ?
- method :
- options === true || typeof options === "number" ?
- defaultEffect :
- options.effect || defaultEffect;
+
+ var hasOptions;
+ var effectName = !options ?
+ method :
+ options === true || typeof options === "number" ?
+ defaultEffect :
+ options.effect || defaultEffect;
+
options = options || {};
if ( typeof options === "number" ) {
options = { duration: options };
}
+
hasOptions = !$.isEmptyObject( options );
options.complete = callback;
+
if ( options.delay ) {
element.delay( options.delay );
}
+
if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
element[ method ]( options );
} else if ( effectName !== method && element[ effectName ] ) {
diff --git a/ui/widgets/accordion.js b/ui/widgets/accordion.js
index 88e9bdb6f..360ac1700 100644
--- a/ui/widgets/accordion.js
+++ b/ui/widgets/accordion.js
@@ -53,7 +53,7 @@ return $.widget( "ui.accordion", {
header: "ui-icon-triangle-1-e"
},
- // callbacks
+ // Callbacks
activate: null,
beforeActivate: null
},
@@ -81,12 +81,13 @@ return $.widget( "ui.accordion", {
this._addClass( "ui-accordion", "ui-widget ui-helper-reset" );
this.element.attr( "role", "tablist" );
- // don't allow collapsible: false and active: false / null
+ // Don't allow collapsible: false and active: false / null
if ( !options.collapsible && ( options.active === false || options.active == null ) ) {
options.active = 0;
}
this._processPanels();
+
// handle negative values
if ( options.active < 0 ) {
options.active += this.headers.length;
@@ -124,17 +125,17 @@ return $.widget( "ui.accordion", {
_destroy: function() {
var contents;
- // clean up main element
+ // Clean up main element
this.element.removeAttr( "role" );
- // clean up headers
+ // Clean up headers
this.headers
.removeAttr( "role aria-expanded aria-selected aria-controls tabIndex" )
.removeUniqueId();
this._destroyIcons();
- // clean up content panels
+ // Clean up content panels
contents = this.headers.next()
.css( "display", "" )
.removeAttr( "role aria-hidden aria-labelledby" )
@@ -147,6 +148,7 @@ return $.widget( "ui.accordion", {
_setOption: function( key, value ) {
if ( key === "active" ) {
+
// _activate() will handle invalid values and update this.options
this._activate( value );
return;
@@ -161,7 +163,7 @@ return $.widget( "ui.accordion", {
this._super( key, value );
- // setting collapsible: false while collapsed; open first panel
+ // Setting collapsible: false while collapsed; open first panel
if ( key === "collapsible" && !value && this.options.active === false ) {
this._activate( 0 );
}
@@ -172,17 +174,19 @@ return $.widget( "ui.accordion", {
this._createIcons();
}
}
+ },
+
+ _setOptionDisabled: function( value ) {
+ this._super( value );
+
+ this.element.attr( "aria-disabled", value );
// Support: IE8 Only
// #5332 / #6059 - opacity doesn't cascade to positioned elements in IE
// so we need to add the disabled class to the headers and panels
- if ( key === "disabled" ) {
- this.element.attr( "aria-disabled", value );
-
- this._toggleClass( null, "ui-state-disabled", !!value );
- this._toggleClass( this.headers.add( this.headers.next() ), null, "ui-state-disabled",
- !!value );
- }
+ this._toggleClass( null, "ui-state-disabled", !!value );
+ this._toggleClass( this.headers.add( this.headers.next() ), null, "ui-state-disabled",
+ !!value );
},
_keydown: function( event ) {
@@ -234,25 +238,31 @@ return $.widget( "ui.accordion", {
var options = this.options;
this._processPanels();
- // was collapsed or no panel
+ // Was collapsed or no panel
if ( ( options.active === false && options.collapsible === true ) || !this.headers.length ) {
options.active = false;
this.active = $();
+
// active false only when collapsible is true
} else if ( options.active === false ) {
this._activate( 0 );
+
// was active, but active panel is gone
} else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
+
// all remaining panel are disabled
if ( this.headers.length === this.headers.find( ".ui-state-disabled" ).length ) {
options.active = false;
this.active = $();
+
// activate previous panel
} else {
this._activate( Math.max( 0, options.active - 1 ) );
}
+
// was active, active panel still exists
} else {
+
// make sure active index is correct
options.active = this.headers.index( this.active );
}
@@ -318,7 +328,7 @@ return $.widget( "ui.accordion", {
} )
.hide();
- // make sure at least one header is in the tab order
+ // Make sure at least one header is in the tab order
if ( !this.active.length ) {
this.headers.eq( 0 ).attr( "tabIndex", 0 );
} else {
@@ -372,12 +382,12 @@ return $.widget( "ui.accordion", {
_activate: function( index ) {
var active = this._findActive( index )[ 0 ];
- // trying to activate the already active panel
+ // Trying to activate the already active panel
if ( active === this.active[ 0 ] ) {
return;
}
- // trying to collapse, simulate a click on the currently active header
+ // Trying to collapse, simulate a click on the currently active header
active = active || this.active[ 0 ];
this._eventHandler( {
@@ -427,8 +437,10 @@ return $.widget( "ui.accordion", {
event.preventDefault();
if (
+
// click on active header, but not collapsible
( clickedIsActive && !options.collapsible ) ||
+
// allow canceling activation
( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
return;
@@ -436,12 +448,12 @@ return $.widget( "ui.accordion", {
options.active = collapsing ? false : this.headers.index( clicked );
- // when the call to ._toggle() comes after the class changes
+ // When the call to ._toggle() comes after the class changes
// it causes a very odd bug in IE 8 (see #6720)
this.active = clickedIsActive ? $() : clicked;
this._toggle( eventData );
- // switch classes
+ // Switch classes
// corner classes on the previously active header stay after the animation
this._removeClass( active, "ui-accordion-header-active", "ui-state-active" );
if ( options.icons ) {
@@ -467,7 +479,7 @@ return $.widget( "ui.accordion", {
var toShow = data.newPanel,
toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
- // handle activating a panel during the animation for another activation
+ // Handle activating a panel during the animation for another activation
this.prevShow.add( this.prevHide ).stop( true, true );
this.prevShow = toShow;
this.prevHide = toHide;
@@ -487,6 +499,7 @@ return $.widget( "ui.accordion", {
"aria-selected": "false",
"aria-expanded": "false"
} );
+
// if we're switching panels, remove the old header from the tab order
// if we're opening from collapsed state, remove the previous header from the tab order
// if we're collapsing, then keep the collapsing header in the tab order
@@ -531,6 +544,7 @@ return $.widget( "ui.accordion", {
if ( typeof options === "string" ) {
easing = options;
}
+
// fall back from options to animation in case of partial down settings
easing = easing || options.easing || animate.easing;
duration = duration || options.duration || animate.duration;
diff --git a/ui/widgets/autocomplete.js b/ui/widgets/autocomplete.js
index a36282dd5..4067f871f 100644
--- a/ui/widgets/autocomplete.js
+++ b/ui/widgets/autocomplete.js
@@ -51,7 +51,7 @@ $.widget( "ui.autocomplete", {
},
source: null,
- // callbacks
+ // Callbacks
change: null,
close: null,
focus: null,
@@ -65,6 +65,7 @@ $.widget( "ui.autocomplete", {
pending: 0,
_create: function() {
+
// 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
@@ -120,8 +121,10 @@ $.widget( "ui.autocomplete", {
this._keyEvent( "next", event );
break;
case keyCode.ENTER:
+
// when menu is open and has focus
if ( this.menu.active ) {
+
// #6055 - Opera still allows the keypress to occur
// which causes forms to submit
suppressKeyPress = true;
@@ -140,6 +143,7 @@ $.widget( "ui.autocomplete", {
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
@@ -148,6 +152,7 @@ $.widget( "ui.autocomplete", {
break;
default:
suppressKeyPressRepeat = true;
+
// search timeout should be triggered before the input value is changed
this._searchTimeout( event );
break;
@@ -165,7 +170,7 @@ $.widget( "ui.autocomplete", {
return;
}
- // replicate some key handlers to allow them to repeat in Firefox and Opera
+ // Replicate some key handlers to allow them to repeat in Firefox and Opera
var keyCode = $.ui.keyCode;
switch ( event.keyCode ) {
case keyCode.PAGE_UP:
@@ -210,6 +215,7 @@ $.widget( "ui.autocomplete", {
this.menu = $( "<ul>" )
.appendTo( this._appendTo() )
.menu( {
+
// disable ARIA support, the live region takes care of that
role: null
} )
@@ -219,6 +225,7 @@ $.widget( "ui.autocomplete", {
this._addClass( this.menu.element, "ui-autocomplete", "ui-front" );
this._on( this.menu.element, {
mousedown: function( event ) {
+
// prevent moving focus out of the text field
event.preventDefault();
@@ -239,7 +246,7 @@ $.widget( "ui.autocomplete", {
}
} );
- // clicking on the scrollbar causes focus to shift to the body
+ // 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
@@ -259,6 +266,7 @@ $.widget( "ui.autocomplete", {
},
menufocus: function( event, ui ) {
var label, item;
+
// support: Firefox
// Prevent accidental activation of menu items in Firefox (#7024 #9118)
if ( this.isNewMenu ) {
@@ -276,6 +284,7 @@ $.widget( "ui.autocomplete", {
item = ui.item.data( "ui-autocomplete-item" );
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 ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
this._value( item.value );
@@ -293,10 +302,11 @@ $.widget( "ui.autocomplete", {
var item = ui.item.data( "ui-autocomplete-item" ),
previous = this.previous;
- // only trigger when focus was lost (click on menu)
+ // Only trigger when focus was lost (click on menu)
if ( this.element[ 0 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) {
this.element.trigger( "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 :-(
@@ -309,6 +319,7 @@ $.widget( "ui.autocomplete", {
if ( false !== this._trigger( "select", event, { item: item } ) ) {
this._value( item.value );
}
+
// reset the term after the select event
// this allows custom select handling to work properly
this.term = this._value();
@@ -318,7 +329,7 @@ $.widget( "ui.autocomplete", {
}
} );
- this.liveRegion = $( "<span>", {
+ this.liveRegion = $( "<div>", {
role: "status",
"aria-live": "assertive",
"aria-relevant": "additions"
@@ -327,7 +338,7 @@ $.widget( "ui.autocomplete", {
this._addClass( this.liveRegion, null, "ui-helper-hidden-accessible" );
- // turning off autocomplete prevents the browser from remembering the
+ // Turning off autocomplete prevents the browser from remembering the
// value when navigating through history, so we re-enable autocomplete
// if the page is unloaded before the widget is destroyed. #7790
this._on( this.window, {
@@ -427,7 +438,7 @@ $.widget( "ui.autocomplete", {
search: function( value, event ) {
value = value != null ? value : this._value();
- // always save the actual value, not the one passed as an argument
+ // Always save the actual value, not the one passed as an argument
this.term = this._value();
if ( value.length < this.options.minLength ) {
@@ -473,6 +484,7 @@ $.widget( "ui.autocomplete", {
this._suggest( content );
this._trigger( "open" );
} else {
+
// use ._close() instead of .close() so we don't cancel future searches
this._close();
}
@@ -499,6 +511,7 @@ $.widget( "ui.autocomplete", {
},
_normalize: function( items ) {
+
// assume all items have the right format when the first item is complete
if ( items.length && items[ 0 ].label && items[ 0 ].value ) {
return items;
@@ -523,7 +536,7 @@ $.widget( "ui.autocomplete", {
this.isNewMenu = true;
this.menu.refresh();
- // size and position menu
+ // Size and position menu
ul.show();
this._resizeMenu();
ul.position( $.extend( {
@@ -538,6 +551,7 @@ $.widget( "ui.autocomplete", {
_resizeMenu: function() {
var ul = this.menu.element;
ul.outerWidth( Math.max(
+
// Firefox wraps long text (possibly a rounding bug)
// so we add 1px to avoid the wrapping (#7513)
ul.width( "" ).outerWidth() + 1,
@@ -592,7 +606,7 @@ $.widget( "ui.autocomplete", {
if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
this._move( keyEvent, event );
- // prevents moving cursor to beginning/end of the text field in some browsers
+ // Prevents moving cursor to beginning/end of the text field in some browsers
event.preventDefault();
}
}
@@ -610,7 +624,7 @@ $.extend( $.ui.autocomplete, {
}
} );
-// live region extension, adding a `messages` option
+// Live region extension, adding a `messages` option
// NOTE: This is an experimental API. We are still investigating
// a full solution for string manipulation and internationalization.
$.widget( "ui.autocomplete", $.ui.autocomplete, {
diff --git a/ui/widgets/button.js b/ui/widgets/button.js
index f5509b520..94fc75331 100644
--- a/ui/widgets/button.js
+++ b/ui/widgets/button.js
@@ -16,11 +16,11 @@
//>>css.structure: ../themes/base/button.css
//>>css.theme: ../themes/base/theme.css
-(function( factory ) {
+( function( factory ) {
if ( typeof define === "function" && define.amd ) {
// AMD. Register as an anonymous module.
- define([
+ define( [
"jquery",
"../data",
"../keycode",
@@ -33,14 +33,14 @@
// Browser globals
factory( jQuery );
}
-}(function( $ ) {
+}( function( $ ) {
var lastActive,
baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",
formResetHandler = function() {
var form = $( this );
- setTimeout(function() {
+ setTimeout( function() {
form.find( ":ui-button" ).button( "refresh" );
}, 1 );
},
@@ -54,9 +54,9 @@ var lastActive,
radios = $( form ).find( "[name='" + name + "'][type=radio]" );
} else {
radios = $( "[name='" + name + "'][type=radio]", radio.ownerDocument )
- .filter(function() {
+ .filter( function() {
return !this.form;
- });
+ } );
}
}
return radios;
@@ -94,7 +94,7 @@ $.widget( "ui.button", {
activeClass = !toggleButton ? "ui-state-active" : "";
if ( options.label === null ) {
- options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
+ options.label = ( this.type === "input" ? this.buttonElement.val() : this.buttonElement.html() );
}
this._hoverable( this.buttonElement );
@@ -109,35 +109,35 @@ $.widget( "ui.button", {
if ( this === lastActive ) {
$( this ).addClass( "ui-state-active" );
}
- })
+ } )
.on( "mouseleave" + this.eventNamespace, function() {
if ( options.disabled ) {
return;
}
$( this ).removeClass( activeClass );
- })
+ } )
.on( "click" + this.eventNamespace, function( event ) {
if ( options.disabled ) {
event.preventDefault();
event.stopImmediatePropagation();
}
- });
+ } );
// Can't use _focusable() because the element that receives focus
// and the element that gets the ui-state-focus class are different
- this._on({
+ this._on( {
focus: function() {
this.buttonElement.addClass( "ui-state-focus" );
},
blur: function() {
this.buttonElement.removeClass( "ui-state-focus" );
}
- });
+ } );
if ( toggleButton ) {
this.element.on( "change" + this.eventNamespace, function() {
that.refresh();
- });
+ } );
}
if ( this.type === "checkbox" ) {
@@ -145,7 +145,7 @@ $.widget( "ui.button", {
if ( options.disabled ) {
return false;
}
- });
+ } );
} else if ( this.type === "radio" ) {
this.buttonElement.on( "click" + this.eventNamespace, function() {
if ( options.disabled ) {
@@ -157,12 +157,12 @@ $.widget( "ui.button", {
var radio = that.element[ 0 ];
radioGroup( radio )
.not( radio )
- .map(function() {
+ .map( function() {
return $( this ).button( "widget" )[ 0 ];
- })
+ } )
.removeClass( "ui-state-active" )
.attr( "aria-pressed", "false" );
- });
+ } );
} else {
this.buttonElement
.on( "mousedown" + this.eventNamespace, function() {
@@ -173,35 +173,37 @@ $.widget( "ui.button", {
lastActive = this;
that.document.one( "mouseup", function() {
lastActive = null;
- });
- })
+ } );
+ } )
.on( "mouseup" + this.eventNamespace, function() {
if ( options.disabled ) {
return false;
}
$( this ).removeClass( "ui-state-active" );
- })
- .on( "keydown" + this.eventNamespace, function(event) {
+ } )
+ .on( "keydown" + this.eventNamespace, function( event ) {
if ( options.disabled ) {
return false;
}
if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
$( this ).addClass( "ui-state-active" );
}
- })
+ } )
+
// see #8559, we bind to blur here in case the button element loses
// focus between keydown and keyup, it would be left in an "active" state
.on( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
$( this ).removeClass( "ui-state-active" );
- });
+ } );
- if ( this.buttonElement.is("a") ) {
- this.buttonElement.on( "keyup", function(event) {
+ if ( this.buttonElement.is( "a" ) ) {
+ this.buttonElement.on( "keyup", function( event ) {
if ( event.keyCode === $.ui.keyCode.SPACE ) {
+
// TODO pass through original event correctly (just as 2nd argument doesn't work)
$( this ).trigger( "click" );
}
- });
+ } );
}
}
@@ -212,21 +214,22 @@ $.widget( "ui.button", {
_determineButtonType: function() {
var ancestor, labelSelector, checked;
- if ( this.element.is("[type=checkbox]") ) {
+ if ( this.element.is( "[type=checkbox]" ) ) {
this.type = "checkbox";
- } else if ( this.element.is("[type=radio]") ) {
+ } else if ( this.element.is( "[type=radio]" ) ) {
this.type = "radio";
- } else if ( this.element.is("input") ) {
+ } else if ( this.element.is( "input" ) ) {
this.type = "input";
} else {
this.type = "button";
}
if ( this.type === "checkbox" || this.type === "radio" ) {
+
// we don't search against the document in case the element
// is disconnected from the DOM
ancestor = this.element.parents().last();
- labelSelector = "label[for='" + this.element.attr("id") + "']";
+ labelSelector = "label[for='" + this.element.attr( "id" ) + "']";
this.buttonElement = ancestor.find( labelSelector );
if ( !this.buttonElement.length ) {
ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
@@ -257,7 +260,7 @@ $.widget( "ui.button", {
this.buttonElement
.removeClass( baseClasses + " ui-state-active " + typeClasses )
.removeAttr( "role aria-pressed" )
- .html( this.buttonElement.find(".ui-button-text").html() );
+ .html( this.buttonElement.find( ".ui-button-text" ).html() );
if ( !this.hasTitle ) {
this.buttonElement.removeAttr( "title" );
@@ -282,6 +285,7 @@ $.widget( "ui.button", {
},
refresh: function() {
+
//See #8237 & #8828
var isDisabled = this.element.is( "input, button" ) ? this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" );
@@ -289,7 +293,7 @@ $.widget( "ui.button", {
this._setOption( "disabled", isDisabled );
}
if ( this.type === "radio" ) {
- radioGroup( this.element[0] ).each(function() {
+ radioGroup( this.element[ 0 ] ).each( function() {
if ( $( this ).is( ":checked" ) ) {
$( this ).button( "widget" )
.addClass( "ui-state-active" )
@@ -299,7 +303,7 @@ $.widget( "ui.button", {
.removeClass( "ui-state-active" )
.attr( "aria-pressed", "false" );
}
- });
+ } );
} else if ( this.type === "checkbox" ) {
if ( this.element.is( ":checked" ) ) {
this.buttonElement
@@ -321,7 +325,7 @@ $.widget( "ui.button", {
return;
}
var buttonElement = this.buttonElement.removeClass( typeClasses ),
- buttonText = $( "<span></span>", this.document[0] )
+ buttonText = $( "<span></span>", this.document[ 0 ] )
.addClass( "ui-button-text" )
.html( this.options.label )
.appendTo( buttonElement.empty() )
@@ -355,7 +359,7 @@ $.widget( "ui.button", {
}
buttonElement.addClass( buttonClasses.join( " " ) );
}
-});
+} );
$.widget( "ui.buttonset", {
version: "@VERSION",
@@ -391,9 +395,9 @@ $.widget( "ui.buttonset", {
existingButtons.button( "refresh" );
this.buttons = allButtons
- .map(function() {
+ .map( function() {
return $( this ).button( "widget" )[ 0 ];
- })
+ } )
.removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
.filter( ":first" )
.addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
@@ -407,15 +411,15 @@ $.widget( "ui.buttonset", {
_destroy: function() {
this.element.removeClass( "ui-buttonset" );
this.buttons
- .map(function() {
+ .map( function() {
return $( this ).button( "widget" )[ 0 ];
- })
+ } )
.removeClass( "ui-corner-left ui-corner-right" )
.end()
.button( "destroy" );
}
-});
+} );
return $.ui.button;
-}));
+} ) );
diff --git a/ui/widgets/dialog.js b/ui/widgets/dialog.js
index 40f6c614f..6070014c9 100644
--- a/ui/widgets/dialog.js
+++ b/ui/widgets/dialog.js
@@ -68,6 +68,7 @@ $.widget( "ui.dialog", {
at: "center",
of: window,
collision: "fit",
+
// Ensure the titlebar is always visible
using: function( pos ) {
var topOffset = $( this ).css( pos ).offset().top;
@@ -81,7 +82,7 @@ $.widget( "ui.dialog", {
title: null,
width: 300,
- // callbacks
+ // Callbacks
beforeClose: null,
close: null,
drag: null,
@@ -128,6 +129,11 @@ $.widget( "ui.dialog", {
this.options.title = this.originalTitle;
}
+ // Dialogs can't be disabled
+ if ( this.options.disabled ) {
+ this.options.disabled = false;
+ }
+
this._createWrapper();
this.element
@@ -176,6 +182,7 @@ $.widget( "ui.dialog", {
this.element
.removeUniqueId()
.css( this.originalCss )
+
// Without detaching first, the following becomes really slow
.detach();
@@ -186,6 +193,7 @@ $.widget( "ui.dialog", {
}
next = originalPosition.parent.children().eq( originalPosition.index );
+
// Don't try to place the dialog next to itself (#8613)
if ( next.length && next[ 0 ] !== this.element[ 0 ] ) {
next.before( this.element );
@@ -290,6 +298,7 @@ $.widget( "ui.dialog", {
},
_focusTabbable: function() {
+
// Set focus to the first match:
// 1. An element that was focused previously
// 2. First element inside the dialog matching [autofocus]
@@ -327,6 +336,7 @@ $.widget( "ui.dialog", {
}
event.preventDefault();
checkFocus.call( this );
+
// support: IE
// IE <= 8 doesn't prevent moving focus even with event.preventDefault()
// so we check again later
@@ -337,6 +347,7 @@ $.widget( "ui.dialog", {
this.uiDialog = $( "<div>" )
.hide()
.attr( {
+
// Setting tabIndex makes the div focusable
tabIndex: -1,
role: "dialog"
@@ -353,7 +364,7 @@ $.widget( "ui.dialog", {
return;
}
- // prevent tabbing out of dialogs
+ // Prevent tabbing out of dialogs
if ( event.keyCode !== $.ui.keyCode.TAB || event.isDefaultPrevented() ) {
return;
}
@@ -398,17 +409,19 @@ $.widget( "ui.dialog", {
"ui-dialog-titlebar", "ui-widget-header ui-helper-clearfix" );
this._on( this.uiDialogTitlebar, {
mousedown: function( event ) {
+
// Don't prevent click on close button (#8838)
// Focusing a dialog that is partially scrolled out of view
// causes the browser to scroll it into view, preventing the click event
if ( !$( event.target ).closest( ".ui-dialog-titlebar-close" ) ) {
+
// Dialog isn't getting focus when dragging (#8063)
this.uiDialog.trigger( "focus" );
}
}
} );
- // support: IE
+ // Support: IE
// Use type="button" to prevent enter keypresses in textboxes from closing the
// dialog in IE (#9312)
this.uiDialogTitlebarClose = $( "<button type='button'></button>" )
@@ -464,7 +477,7 @@ $.widget( "ui.dialog", {
var that = this,
buttons = this.options.buttons;
- // if we already have a button pane, remove it
+ // If we already have a button pane, remove it
this.uiDialogButtonPane.remove();
this.uiButtonSet.empty();
@@ -478,8 +491,10 @@ $.widget( "ui.dialog", {
props = $.isFunction( props ) ?
{ click: props, text: name } :
props;
+
// Default to a non-submitting button
props = $.extend( { type: "button" }, props );
+
// Change the context for the click callback to be the main element
click = props.click;
buttonOptions = {
@@ -545,6 +560,7 @@ $.widget( "ui.dialog", {
var that = this,
options = this.options,
handles = options.resizable,
+
// .ui-resizable has position: relative defined in the stylesheet
// but dialogs have to use absolute or fixed positioning
position = this.uiDialog.css( "position" ),
@@ -639,6 +655,7 @@ $.widget( "ui.dialog", {
},
_position: function() {
+
// Need to show the dialog to get the actual offset in the position plugin
var isVisible = this.uiDialog.is( ":visible" );
if ( !isVisible ) {
@@ -695,6 +712,7 @@ $.widget( "ui.dialog", {
if ( key === "closeText" ) {
this.uiDialogTitlebarClose.button( {
+
// Ensure that we always pass a string
label: "" + value
} );
@@ -716,18 +734,19 @@ $.widget( "ui.dialog", {
}
if ( key === "resizable" ) {
+
// currently resizable, becoming non-resizable
isResizable = uiDialog.is( ":data(ui-resizable)" );
if ( isResizable && !value ) {
uiDialog.resizable( "destroy" );
}
- // currently resizable, changing handles
+ // Currently resizable, changing handles
if ( isResizable && typeof value === "string" ) {
uiDialog.resizable( "option", "handles", value );
}
- // currently non-resizable, becoming resizable
+ // Currently non-resizable, becoming resizable
if ( !isResizable && value !== false ) {
this._makeResizable();
}
@@ -739,6 +758,7 @@ $.widget( "ui.dialog", {
},
_size: function() {
+
// If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
// divs will both have width and height set, so we need to reset them
var nonContentHeight, minContentHeight, maxContentHeight,
@@ -756,7 +776,7 @@ $.widget( "ui.dialog", {
options.width = options.minWidth;
}
- // reset wrapper sizing
+ // Reset wrapper sizing
// determine the height of all the non-content elements
nonContentHeight = this.uiDialog.css( {
height: "auto",
diff --git a/ui/widgets/draggable.js b/ui/widgets/draggable.js
index ab9d24667..f61c38ce0 100644
--- a/ui/widgets/draggable.js
+++ b/ui/widgets/draggable.js
@@ -14,11 +14,11 @@
//>>demos: http://jqueryui.com/draggable/
//>>css.structure: ../themes/base/draggable.css
-(function( factory ) {
+( function( factory ) {
if ( typeof define === "function" && define.amd ) {
// AMD. Register as an anonymous module.
- define([
+ define( [
"jquery",
"./mouse",
"../data",
@@ -34,9 +34,9 @@
// Browser globals
factory( jQuery );
}
-}(function( $ ) {
+}( function( $ ) {
-$.widget("ui.draggable", $.ui.mouse, {
+$.widget( "ui.draggable", $.ui.mouse, {
version: "@VERSION",
widgetEventPrefix: "drag",
options: {
@@ -65,7 +65,7 @@ $.widget("ui.draggable", $.ui.mouse, {
stack: false,
zIndex: false,
- // callbacks
+ // Callbacks
drag: null,
start: null,
stop: null
@@ -75,12 +75,9 @@ $.widget("ui.draggable", $.ui.mouse, {
if ( this.options.helper === "original" ) {
this._setPositionRelative();
}
- if (this.options.addClasses){
+ if ( this.options.addClasses ) {
this._addClass( "ui-draggable" );
}
- if (this.options.disabled){
- this._addClass( "ui-draggable-disabled" );
- }
this._setHandleClassName();
this._mouseInit();
@@ -103,19 +100,19 @@ $.widget("ui.draggable", $.ui.mouse, {
this._mouseDestroy();
},
- _mouseCapture: function(event) {
+ _mouseCapture: function( event ) {
var o = this.options;
this._blurActiveElement( event );
- // among others, prevent a drag on a resizable-handle
- if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
+ // Among others, prevent a drag on a resizable-handle
+ if ( this.helper || o.disabled || $( event.target ).closest( ".ui-resizable-handle" ).length > 0 ) {
return false;
}
//Quit if we're not on a valid handle
- this.handle = this._getHandle(event);
- if (!this.handle) {
+ this.handle = this._getHandle( event );
+ if ( !this.handle ) {
return false;
}
@@ -126,7 +123,7 @@ $.widget("ui.draggable", $.ui.mouse, {
},
_blockFrames: function( selector ) {
- this.iframeBlocks = this.document.find( selector ).map(function() {
+ this.iframeBlocks = this.document.find( selector ).map( function() {
var iframe = $( this );
return $( "<div>" )
@@ -135,7 +132,7 @@ $.widget("ui.draggable", $.ui.mouse, {
.outerWidth( iframe.outerWidth() )
.outerHeight( iframe.outerHeight() )
.offset( iframe.offset() )[ 0 ];
- });
+ } );
},
_unblockFrames: function() {
@@ -156,12 +153,12 @@ $.widget("ui.draggable", $.ui.mouse, {
$.ui.safeBlur( $.ui.safeActiveElement( this.document[ 0 ] ) );
},
- _mouseStart: function(event) {
+ _mouseStart: function( event ) {
var o = this.options;
//Create and append the visible helper
- this.helper = this._createHelper(event);
+ this.helper = this._createHelper( event );
this._addClass( this.helper, "ui-draggable-dragging" );
@@ -169,7 +166,7 @@ $.widget("ui.draggable", $.ui.mouse, {
this._cacheHelperProportions();
//If ddmanager is used for droppables, set the global draggable
- if ($.ui.ddmanager) {
+ if ( $.ui.ddmanager ) {
$.ui.ddmanager.current = this;
}
@@ -185,9 +182,9 @@ $.widget("ui.draggable", $.ui.mouse, {
this.cssPosition = this.helper.css( "position" );
this.scrollParent = this.helper.scrollParent( true );
this.offsetParent = this.helper.offsetParent();
- this.hasFixedAncestor = this.helper.parents().filter(function() {
+ this.hasFixedAncestor = this.helper.parents().filter( function() {
return $( this ).css( "position" ) === "fixed";
- }).length > 0;
+ } ).length > 0;
//The element's absolute position on the page minus margins
this.positionAbs = this.element.offset();
@@ -199,13 +196,13 @@ $.widget("ui.draggable", $.ui.mouse, {
this.originalPageY = event.pageY;
//Adjust the mouse offset relative to the helper if "cursorAt" is supplied
- (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
+ ( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) );
//Set a containment if given in the options
this._setContainment();
//Trigger event + callbacks
- if (this._trigger("start", event) === false) {
+ if ( this._trigger( "start", event ) === false ) {
this._clear();
return false;
}
@@ -214,15 +211,15 @@ $.widget("ui.draggable", $.ui.mouse, {
this._cacheHelperProportions();
//Prepare the droppable offsets
- if ($.ui.ddmanager && !o.dropBehaviour) {
- $.ui.ddmanager.prepareOffsets(this, event);
+ if ( $.ui.ddmanager && !o.dropBehaviour ) {
+ $.ui.ddmanager.prepareOffsets( this, event );
}
- this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
+ this._mouseDrag( event, true ); //Execute the drag once - this causes the helper not to be visible before getting its correct position
//If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
if ( $.ui.ddmanager ) {
- $.ui.ddmanager.dragStart(this, event);
+ $.ui.ddmanager.dragStart( this, event );
}
return true;
@@ -243,7 +240,8 @@ $.widget("ui.draggable", $.ui.mouse, {
};
},
- _mouseDrag: function(event, noPropagation) {
+ _mouseDrag: function( event, noPropagation ) {
+
// reset any necessary cached properties (see #5009)
if ( this.hasFixedAncestor ) {
this.offset.parent = this._getParentOffset();
@@ -251,13 +249,13 @@ $.widget("ui.draggable", $.ui.mouse, {
//Compute the helpers position
this.position = this._generatePosition( event, true );
- this.positionAbs = this._convertPositionTo("absolute");
+ this.positionAbs = this._convertPositionTo( "absolute" );
//Call plugins and callbacks and use the resulting position if something is returned
- if (!noPropagation) {
+ if ( !noPropagation ) {
var ui = this._uiHash();
- if (this._trigger("drag", event, ui) === false) {
- this._mouseUp({});
+ if ( this._trigger( "drag", event, ui ) === false ) {
+ this._mouseUp( {} );
return false;
}
this.position = ui.position;
@@ -266,36 +264,36 @@ $.widget("ui.draggable", $.ui.mouse, {
this.helper[ 0 ].style.left = this.position.left + "px";
this.helper[ 0 ].style.top = this.position.top + "px";
- if ($.ui.ddmanager) {
- $.ui.ddmanager.drag(this, event);
+ if ( $.ui.ddmanager ) {
+ $.ui.ddmanager.drag( this, event );
}
return false;
},
- _mouseStop: function(event) {
+ _mouseStop: function( event ) {
//If we are using droppables, inform the manager about the drop
var that = this,
dropped = false;
- if ($.ui.ddmanager && !this.options.dropBehaviour) {
- dropped = $.ui.ddmanager.drop(this, event);
+ if ( $.ui.ddmanager && !this.options.dropBehaviour ) {
+ dropped = $.ui.ddmanager.drop( this, event );
}
//if a drop comes from outside (a sortable)
- if (this.dropped) {
+ if ( this.dropped ) {
dropped = this.dropped;
this.dropped = 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))) {
- $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
- if (that._trigger("stop", event) !== 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 ) ) ) {
+ $( this.helper ).animate( this.originalPosition, parseInt( this.options.revertDuration, 10 ), function() {
+ if ( that._trigger( "stop", event ) !== false ) {
that._clear();
}
- });
+ } );
} else {
- if (this._trigger("stop", event) !== false) {
+ if ( this._trigger( "stop", event ) !== false ) {
this._clear();
}
}
@@ -308,22 +306,23 @@ $.widget("ui.draggable", $.ui.mouse, {
//If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
if ( $.ui.ddmanager ) {
- $.ui.ddmanager.dragStop(this, event);
+ $.ui.ddmanager.dragStop( this, event );
}
// Only need to focus if the event occurred on the draggable itself, see #10527
if ( this.handleElement.is( event.target ) ) {
+
// The interaction is over; whether or not the click resulted in a drag, focus the element
this.element.trigger( "focus" );
}
- return $.ui.mouse.prototype._mouseUp.call(this, event);
+ return $.ui.mouse.prototype._mouseUp.call( this, event );
},
cancel: function() {
- if (this.helper.is(".ui-draggable-dragging")) {
- this._mouseUp({});
+ if ( this.helper.is( ".ui-draggable-dragging" ) ) {
+ this._mouseUp( {} );
} else {
this._clear();
}
@@ -332,7 +331,7 @@ $.widget("ui.draggable", $.ui.mouse, {
},
- _getHandle: function(event) {
+ _getHandle: function( event ) {
return this.options.handle ?
!!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
true;
@@ -348,7 +347,7 @@ $.widget("ui.draggable", $.ui.mouse, {
this._removeClass( this.handleElement, "ui-draggable-handle" );
},
- _createHelper: function(event) {
+ _createHelper: function( event ) {
var o = this.options,
helperIsFunction = $.isFunction( o.helper ),
@@ -358,19 +357,19 @@ $.widget("ui.draggable", $.ui.mouse, {
this.element.clone().removeAttr( "id" ) :
this.element );
- if (!helper.parents("body").length) {
- helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo));
+ if ( !helper.parents( "body" ).length ) {
+ helper.appendTo( ( o.appendTo === "parent" ? this.element[ 0 ].parentNode : o.appendTo ) );
}
- // http://bugs.jqueryui.com/ticket/9446
+ // Http://bugs.jqueryui.com/ticket/9446
// a helper function can return the original element
// which wouldn't have been set to relative in _create
if ( helperIsFunction && helper[ 0 ] === this.element[ 0 ] ) {
this._setPositionRelative();
}
- if (helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
- helper.css("position", "absolute");
+ if ( helper[ 0 ] !== this.element[ 0 ] && !( /(fixed|absolute)/ ).test( helper.css( "position" ) ) ) {
+ helper.css( "position", "absolute" );
}
return helper;
@@ -383,23 +382,23 @@ $.widget("ui.draggable", $.ui.mouse, {
}
},
- _adjustOffsetFromHelper: function(obj) {
- if (typeof obj === "string") {
- obj = obj.split(" ");
+ _adjustOffsetFromHelper: function( obj ) {
+ if ( typeof obj === "string" ) {
+ obj = obj.split( " " );
}
- if ($.isArray(obj)) {
- obj = { left: +obj[0], top: +obj[1] || 0 };
+ if ( $.isArray( obj ) ) {
+ obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 };
}
- if ("left" in obj) {
+ if ( "left" in obj ) {
this.offset.click.left = obj.left + this.margins.left;
}
- if ("right" in obj) {
+ if ( "right" in obj ) {
this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
}
- if ("top" in obj) {
+ if ( "top" in obj ) {
this.offset.click.top = obj.top + this.margins.top;
}
- if ("bottom" in obj) {
+ if ( "bottom" in obj ) {
this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
}
},
@@ -418,7 +417,7 @@ $.widget("ui.draggable", $.ui.mouse, {
// 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
// the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
- if (this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
+ if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) {
po.left += this.scrollParent.scrollLeft();
po.top += this.scrollParent.scrollTop();
}
@@ -428,8 +427,8 @@ $.widget("ui.draggable", $.ui.mouse, {
}
return {
- top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"), 10) || 0),
- left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"), 10) || 0)
+ top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ),
+ left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 )
};
},
@@ -443,18 +442,18 @@ $.widget("ui.draggable", $.ui.mouse, {
scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
return {
- top: p.top - ( parseInt(this.helper.css( "top" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ),
- left: p.left - ( parseInt(this.helper.css( "left" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 )
+ top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ),
+ left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 )
};
},
_cacheMargins: function() {
this.margins = {
- left: (parseInt(this.element.css("marginLeft"), 10) || 0),
- top: (parseInt(this.element.css("marginTop"), 10) || 0),
- right: (parseInt(this.element.css("marginRight"), 10) || 0),
- bottom: (parseInt(this.element.css("marginBottom"), 10) || 0)
+ left: ( parseInt( this.element.css( "marginLeft" ), 10 ) || 0 ),
+ top: ( parseInt( this.element.css( "marginTop" ), 10 ) || 0 ),
+ right: ( parseInt( this.element.css( "marginRight" ), 10 ) || 0 ),
+ bottom: ( parseInt( this.element.css( "marginBottom" ), 10 ) || 0 )
};
},
@@ -488,7 +487,7 @@ $.widget("ui.draggable", $.ui.mouse, {
return;
}
- if ( o.containment === "document") {
+ if ( o.containment === "document" ) {
this.containment = [
0,
0,
@@ -535,9 +534,9 @@ $.widget("ui.draggable", $.ui.mouse, {
this.relativeContainer = c;
},
- _convertPositionTo: function(d, pos) {
+ _convertPositionTo: function( d, pos ) {
- if (!pos) {
+ if ( !pos ) {
pos = this.position;
}
@@ -549,13 +548,13 @@ $.widget("ui.draggable", $.ui.mouse, {
pos.top + // The absolute mouse position
this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
- ( ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod)
+ ( ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod )
),
left: (
pos.left + // The absolute mouse position
this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
- ( ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod)
+ ( ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod )
)
};
@@ -585,7 +584,7 @@ $.widget("ui.draggable", $.ui.mouse, {
// If we are not dragging yet, we won't check for options
if ( constrainPosition ) {
if ( this.containment ) {
- if ( this.relativeContainer ){
+ if ( this.relativeContainer ) {
co = this.relativeContainer.offset();
containment = [
this.containment[ 0 ] + co.left,
@@ -597,27 +596,28 @@ $.widget("ui.draggable", $.ui.mouse, {
containment = this.containment;
}
- if (event.pageX - this.offset.click.left < containment[0]) {
- pageX = containment[0] + this.offset.click.left;
+ if ( event.pageX - this.offset.click.left < containment[ 0 ] ) {
+ pageX = containment[ 0 ] + this.offset.click.left;
}
- if (event.pageY - this.offset.click.top < containment[1]) {
- pageY = containment[1] + this.offset.click.top;
+ if ( event.pageY - this.offset.click.top < containment[ 1 ] ) {
+ pageY = containment[ 1 ] + this.offset.click.top;
}
- if (event.pageX - this.offset.click.left > containment[2]) {
- pageX = containment[2] + this.offset.click.left;
+ if ( event.pageX - this.offset.click.left > containment[ 2 ] ) {
+ pageX = containment[ 2 ] + this.offset.click.left;
}
- if (event.pageY - this.offset.click.top > containment[3]) {
- pageY = containment[3] + this.offset.click.top;
+ if ( event.pageY - this.offset.click.top > containment[ 3 ] ) {
+ pageY = containment[ 3 ] + this.offset.click.top;
}
}
- if (o.grid) {
+ if ( o.grid ) {
+
//Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
- top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
- pageY = containment ? ((top - this.offset.click.top >= containment[1] || top - this.offset.click.top > containment[3]) ? top : ((top - this.offset.click.top >= containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
+ top = o.grid[ 1 ] ? this.originalPageY + Math.round( ( pageY - this.originalPageY ) / o.grid[ 1 ] ) * o.grid[ 1 ] : this.originalPageY;
+ pageY = containment ? ( ( top - this.offset.click.top >= containment[ 1 ] || top - this.offset.click.top > containment[ 3 ] ) ? top : ( ( top - this.offset.click.top >= containment[ 1 ] ) ? top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) : top;
- left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
- pageX = containment ? ((left - this.offset.click.left >= containment[0] || left - this.offset.click.left > containment[2]) ? left : ((left - this.offset.click.left >= containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
+ left = o.grid[ 0 ] ? this.originalPageX + Math.round( ( pageX - this.originalPageX ) / o.grid[ 0 ] ) * o.grid[ 0 ] : this.originalPageX;
+ pageX = containment ? ( ( left - this.offset.click.left >= containment[ 0 ] || left - this.offset.click.left > containment[ 2 ] ) ? left : ( ( left - this.offset.click.left >= containment[ 0 ] ) ? left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) : left;
}
if ( o.axis === "y" ) {
@@ -650,7 +650,7 @@ $.widget("ui.draggable", $.ui.mouse, {
_clear: function() {
this._removeClass( this.helper, "ui-draggable-dragging" );
- if (this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {
+ if ( this.helper[ 0 ] !== this.element[ 0 ] && !this.cancelHelperRemoval ) {
this.helper.remove();
}
this.helper = null;
@@ -685,33 +685,33 @@ $.widget("ui.draggable", $.ui.mouse, {
};
}
-});
+} );
$.ui.plugin.add( "draggable", "connectToSortable", {
start: function( event, ui, draggable ) {
var uiSortable = $.extend( {}, ui, {
item: draggable.element
- });
+ } );
draggable.sortables = [];
- $( draggable.options.connectToSortable ).each(function() {
+ $( draggable.options.connectToSortable ).each( function() {
var sortable = $( this ).sortable( "instance" );
if ( sortable && !sortable.options.disabled ) {
draggable.sortables.push( sortable );
- // refreshPositions is called at drag start to refresh the containerCache
+ // RefreshPositions is called at drag start to refresh the containerCache
// which is used in drag. This ensures it's initialized and synchronized
// with any changes that might have happened on the page since initialization.
sortable.refreshPositions();
- sortable._trigger("activate", event, uiSortable);
+ sortable._trigger( "activate", event, uiSortable );
}
- });
+ } );
},
stop: function( event, ui, draggable ) {
var uiSortable = $.extend( {}, ui, {
item: draggable.element
- });
+ } );
draggable.cancelHelperRemoval = false;
@@ -734,12 +734,13 @@ $.ui.plugin.add( "draggable", "connectToSortable", {
left: sortable.placeholder.css( "left" )
};
- sortable._mouseStop(event);
+ sortable._mouseStop( event );
// Once drag has ended, the sortable should return to using
// its original helper, not the shared helper from draggable
sortable.options.helper = sortable.options._helper;
} else {
+
// Prevent this Sortable from removing the helper.
// However, don't set the draggable to remove the helper
// either as another connected Sortable may yet handle the removal.
@@ -747,7 +748,7 @@ $.ui.plugin.add( "draggable", "connectToSortable", {
sortable._trigger( "deactivate", event, uiSortable );
}
- });
+ } );
},
drag: function( event, ui, draggable ) {
$.each( draggable.sortables, function() {
@@ -763,6 +764,7 @@ $.ui.plugin.add( "draggable", "connectToSortable", {
innermostIntersecting = true;
$.each( draggable.sortables, function() {
+
// Copy over variables that sortable's _intersectsWith uses
this.positionAbs = draggable.positionAbs;
this.helperProportions = draggable.helperProportions;
@@ -775,10 +777,11 @@ $.ui.plugin.add( "draggable", "connectToSortable", {
}
return innermostIntersecting;
- });
+ } );
}
if ( innermostIntersecting ) {
+
// If it intersects, we use a little isOver variable and set it once,
// so that the move-in stuff gets fired only once.
if ( !sortable.isOver ) {
@@ -823,21 +826,23 @@ $.ui.plugin.add( "draggable", "connectToSortable", {
// adding to one sortable changes the location of the other sortables (#9675)
$.each( draggable.sortables, function() {
this.refreshPositions();
- });
+ } );
- // hack so receive/update callbacks work (mostly)
+ // Hack so receive/update callbacks work (mostly)
draggable.currentItem = draggable.element;
sortable.fromOutside = draggable;
}
if ( sortable.currentItem ) {
sortable._mouseDrag( event );
+
// Copy the sortable's position because the draggable's can potentially reflect
// a relative position, while sortable is always absolute, which the dragged
// element has now become. (#8809)
ui.position = sortable.position;
}
} else {
+
// If it doesn't intersect with the sortable, and it intersected before,
// we fake the drag stop of the sortable, but make sure it doesn't remove
// the helper by using cancelHelperRemoval.
@@ -854,7 +859,7 @@ $.ui.plugin.add( "draggable", "connectToSortable", {
sortable._trigger( "out", event, sortable._uiHash( sortable ) );
sortable._mouseStop( event, true );
- // restore sortable behaviors that were modfied
+ // Restore sortable behaviors that were modfied
// when the draggable entered the sortable area (#9481)
sortable.options.revert = sortable.options._revert;
sortable.options.helper = sortable.options._helper;
@@ -878,49 +883,49 @@ $.ui.plugin.add( "draggable", "connectToSortable", {
// from one sortable changes the location of other sortables (#9675)
$.each( draggable.sortables, function() {
this.refreshPositions();
- });
+ } );
}
}
- });
+ } );
}
-});
+} );
-$.ui.plugin.add("draggable", "cursor", {
+$.ui.plugin.add( "draggable", "cursor", {
start: function( event, ui, instance ) {
var t = $( "body" ),
o = instance.options;
- if (t.css("cursor")) {
- o._cursor = t.css("cursor");
+ if ( t.css( "cursor" ) ) {
+ o._cursor = t.css( "cursor" );
}
- t.css("cursor", o.cursor);
+ t.css( "cursor", o.cursor );
},
stop: function( event, ui, instance ) {
var o = instance.options;
- if (o._cursor) {
- $("body").css("cursor", o._cursor);
+ if ( o._cursor ) {
+ $( "body" ).css( "cursor", o._cursor );
}
}
-});
+} );
-$.ui.plugin.add("draggable", "opacity", {
+$.ui.plugin.add( "draggable", "opacity", {
start: function( event, ui, instance ) {
var t = $( ui.helper ),
o = instance.options;
- if (t.css("opacity")) {
- o._opacity = t.css("opacity");
+ if ( t.css( "opacity" ) ) {
+ o._opacity = t.css( "opacity" );
}
- t.css("opacity", o.opacity);
+ t.css( "opacity", o.opacity );
},
stop: function( event, ui, instance ) {
var o = instance.options;
- if (o._opacity) {
- $(ui.helper).css("opacity", o._opacity);
+ if ( o._opacity ) {
+ $( ui.helper ).css( "opacity", o._opacity );
}
}
-});
+} );
-$.ui.plugin.add("draggable", "scroll", {
+$.ui.plugin.add( "draggable", "scroll", {
start: function( event, ui, i ) {
if ( !i.scrollParentNotHidden ) {
i.scrollParentNotHidden = i.helper.scrollParent( false );
@@ -956,49 +961,49 @@ $.ui.plugin.add("draggable", "scroll", {
} else {
- if (!o.axis || o.axis !== "x") {
- if (event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
- scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
- } else if ($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
- scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
+ if ( !o.axis || o.axis !== "x" ) {
+ if ( event.pageY - $( document ).scrollTop() < o.scrollSensitivity ) {
+ scrolled = $( document ).scrollTop( $( document ).scrollTop() - o.scrollSpeed );
+ } else if ( $( window ).height() - ( event.pageY - $( document ).scrollTop() ) < o.scrollSensitivity ) {
+ scrolled = $( document ).scrollTop( $( document ).scrollTop() + o.scrollSpeed );
}
}
- if (!o.axis || o.axis !== "y") {
- if (event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
- scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
- } else if ($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
- scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
+ if ( !o.axis || o.axis !== "y" ) {
+ if ( event.pageX - $( document ).scrollLeft() < o.scrollSensitivity ) {
+ scrolled = $( document ).scrollLeft( $( document ).scrollLeft() - o.scrollSpeed );
+ } else if ( $( window ).width() - ( event.pageX - $( document ).scrollLeft() ) < o.scrollSensitivity ) {
+ scrolled = $( document ).scrollLeft( $( document ).scrollLeft() + o.scrollSpeed );
}
}
}
- if (scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
- $.ui.ddmanager.prepareOffsets(i, event);
+ if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) {
+ $.ui.ddmanager.prepareOffsets( i, event );
}
}
-});
+} );
-$.ui.plugin.add("draggable", "snap", {
+$.ui.plugin.add( "draggable", "snap", {
start: function( event, ui, i ) {
var o = i.options;
i.snapElements = [];
- $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() {
- var $t = $(this),
+ $( o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap ).each( function() {
+ var $t = $( this ),
$o = $t.offset();
- if (this !== i.element[0]) {
- i.snapElements.push({
+ if ( this !== i.element[ 0 ] ) {
+ i.snapElements.push( {
item: this,
width: $t.outerWidth(), height: $t.outerHeight(),
top: $o.top, left: $o.left
- });
+ } );
}
- });
+ } );
},
drag: function( event, ui, inst ) {
@@ -1009,108 +1014,108 @@ $.ui.plugin.add("draggable", "snap", {
x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
- for (i = inst.snapElements.length - 1; i >= 0; i--){
+ for ( i = inst.snapElements.length - 1; i >= 0; i-- ) {
- l = inst.snapElements[i].left - inst.margins.left;
- r = l + inst.snapElements[i].width;
- t = inst.snapElements[i].top - inst.margins.top;
- b = t + inst.snapElements[i].height;
+ l = inst.snapElements[ i ].left - inst.margins.left;
+ r = l + inst.snapElements[ i ].width;
+ t = inst.snapElements[ i ].top - inst.margins.top;
+ b = t + inst.snapElements[ i ].height;
if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
- if (inst.snapElements[i].snapping) {
- (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
+ if ( inst.snapElements[ i ].snapping ) {
+ ( inst.options.snap.release && inst.options.snap.release.call( inst.element, event, $.extend( inst._uiHash(), { snapItem: inst.snapElements[ i ].item } ) ) );
}
- inst.snapElements[i].snapping = false;
+ inst.snapElements[ i ].snapping = false;
continue;
}
- if (o.snapMode !== "inner") {
- ts = Math.abs(t - y2) <= d;
- bs = Math.abs(b - y1) <= d;
- ls = Math.abs(l - x2) <= d;
- rs = Math.abs(r - x1) <= d;
- if (ts) {
- ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top;
+ if ( o.snapMode !== "inner" ) {
+ ts = Math.abs( t - y2 ) <= d;
+ bs = Math.abs( b - y1 ) <= d;
+ ls = Math.abs( l - x2 ) <= d;
+ rs = Math.abs( r - x1 ) <= d;
+ if ( ts ) {
+ ui.position.top = inst._convertPositionTo( "relative", { top: t - inst.helperProportions.height, left: 0 } ).top;
}
- if (bs) {
- ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top;
+ if ( bs ) {
+ ui.position.top = inst._convertPositionTo( "relative", { top: b, left: 0 } ).top;
}
- if (ls) {
- ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left;
+ if ( ls ) {
+ ui.position.left = inst._convertPositionTo( "relative", { top: 0, left: l - inst.helperProportions.width } ).left;
}
- if (rs) {
- ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left;
+ if ( rs ) {
+ ui.position.left = inst._convertPositionTo( "relative", { top: 0, left: r } ).left;
}
}
- first = (ts || bs || ls || rs);
+ first = ( ts || bs || ls || rs );
- if (o.snapMode !== "outer") {
- ts = Math.abs(t - y1) <= d;
- bs = Math.abs(b - y2) <= d;
- ls = Math.abs(l - x1) <= d;
- rs = Math.abs(r - x2) <= d;
- if (ts) {
- ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top;
+ if ( o.snapMode !== "outer" ) {
+ ts = Math.abs( t - y1 ) <= d;
+ bs = Math.abs( b - y2 ) <= d;
+ ls = Math.abs( l - x1 ) <= d;
+ rs = Math.abs( r - x2 ) <= d;
+ if ( ts ) {
+ ui.position.top = inst._convertPositionTo( "relative", { top: t, left: 0 } ).top;
}
- if (bs) {
- ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top;
+ if ( bs ) {
+ ui.position.top = inst._convertPositionTo( "relative", { top: b - inst.helperProportions.height, left: 0 } ).top;
}
- if (ls) {
- ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left;
+ if ( ls ) {
+ ui.position.left = inst._convertPositionTo( "relative", { top: 0, left: l } ).left;
}
- if (rs) {
- ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left;
+ if ( rs ) {
+ ui.position.left = inst._convertPositionTo( "relative", { top: 0, left: r - inst.helperProportions.width } ).left;
}
}
- if (!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
- (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
+ if ( !inst.snapElements[ i ].snapping && ( ts || bs || ls || rs || first ) ) {
+ ( inst.options.snap.snap && inst.options.snap.snap.call( inst.element, event, $.extend( inst._uiHash(), { snapItem: inst.snapElements[ i ].item } ) ) );
}
- inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
+ inst.snapElements[ i ].snapping = ( ts || bs || ls || rs || first );
}
}
-});
+} );
-$.ui.plugin.add("draggable", "stack", {
+$.ui.plugin.add( "draggable", "stack", {
start: function( event, ui, instance ) {
var min,
o = instance.options,
- group = $.makeArray($(o.stack)).sort(function(a, b) {
- return (parseInt($(a).css("zIndex"), 10) || 0) - (parseInt($(b).css("zIndex"), 10) || 0);
- });
+ group = $.makeArray( $( o.stack ) ).sort( function( a, b ) {
+ return ( parseInt( $( a ).css( "zIndex" ), 10 ) || 0 ) - ( parseInt( $( b ).css( "zIndex" ), 10 ) || 0 );
+ } );
- if (!group.length) { return; }
+ if ( !group.length ) { return; }
- min = parseInt($(group[0]).css("zIndex"), 10) || 0;
- $(group).each(function(i) {
- $(this).css("zIndex", min + i);
- });
- this.css("zIndex", (min + group.length));
+ min = parseInt( $( group[ 0 ] ).css( "zIndex" ), 10 ) || 0;
+ $( group ).each( function( i ) {
+ $( this ).css( "zIndex", min + i );
+ } );
+ this.css( "zIndex", ( min + group.length ) );
}
-});
+} );
-$.ui.plugin.add("draggable", "zIndex", {
+$.ui.plugin.add( "draggable", "zIndex", {
start: function( event, ui, instance ) {
var t = $( ui.helper ),
o = instance.options;
- if (t.css("zIndex")) {
- o._zIndex = t.css("zIndex");
+ if ( t.css( "zIndex" ) ) {
+ o._zIndex = t.css( "zIndex" );
}
- t.css("zIndex", o.zIndex);
+ t.css( "zIndex", o.zIndex );
},
stop: function( event, ui, instance ) {
var o = instance.options;
- if (o._zIndex) {
- $(ui.helper).css("zIndex", o._zIndex);
+ if ( o._zIndex ) {
+ $( ui.helper ).css( "zIndex", o._zIndex );
}
}
-});
+} );
return $.ui.draggable;
-}));
+} ) );
diff --git a/ui/widgets/droppable.js b/ui/widgets/droppable.js
index 3a8bd7109..136a32b80 100644
--- a/ui/widgets/droppable.js
+++ b/ui/widgets/droppable.js
@@ -13,11 +13,11 @@
//>>docs: http://api.jqueryui.com/droppable/
//>>demos: http://jqueryui.com/droppable/
-(function( factory ) {
+( function( factory ) {
if ( typeof define === "function" && define.amd ) {
// AMD. Register as an anonymous module.
- define([
+ define( [
"jquery",
"./draggable",
"./mouse",
@@ -29,7 +29,7 @@
// Browser globals
factory( jQuery );
}
-}(function( $ ) {
+}( function( $ ) {
$.widget( "ui.droppable", {
version: "@VERSION",
@@ -41,7 +41,7 @@ $.widget( "ui.droppable", {
scope: "default",
tolerance: "intersect",
- // callbacks
+ // Callbacks
activate: null,
deactivate: null,
drop: null,
@@ -63,9 +63,11 @@ $.widget( "ui.droppable", {
this.proportions = function( /* valueToWrite */ ) {
if ( arguments.length ) {
+
// Store the droppable's proportions
proportions = arguments[ 0 ];
} else {
+
// Retrieve or derive the droppable's proportions
return proportions ?
proportions :
@@ -83,6 +85,7 @@ $.widget( "ui.droppable", {
},
_addToManager: function( scope ) {
+
// Add the reference and positions to the manager
$.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || [];
$.ui.ddmanager.droppables[ scope ].push( this );
@@ -123,7 +126,7 @@ $.widget( "ui.droppable", {
var draggable = $.ui.ddmanager.current;
this._addActiveClass();
- if ( draggable ){
+ if ( draggable ) {
this._trigger( "activate", event, this.ui( draggable ) );
}
},
@@ -132,7 +135,7 @@ $.widget( "ui.droppable", {
var draggable = $.ui.ddmanager.current;
this._removeActiveClass();
- if ( draggable ){
+ if ( draggable ) {
this._trigger( "deactivate", event, this.ui( draggable ) );
}
},
@@ -179,7 +182,7 @@ $.widget( "ui.droppable", {
return false;
}
- this.element.find( ":data(ui-droppable)" ).not( ".ui-draggable-dragging" ).each(function() {
+ this.element.find( ":data(ui-droppable)" ).not( ".ui-draggable-dragging" ).each( function() {
var inst = $( this ).droppable( "instance" );
if (
inst.options.greedy &&
@@ -188,7 +191,7 @@ $.widget( "ui.droppable", {
inst.accept.call( inst.element[ 0 ], ( draggable.currentItem || draggable.element ) ) &&
intersect( draggable, $.extend( inst, { offset: inst.element.offset() } ), inst.options.tolerance, event )
) { childrenIntersection = true; return false; }
- });
+ } );
if ( childrenIntersection ) {
return false;
}
@@ -231,9 +234,9 @@ $.widget( "ui.droppable", {
_removeActiveClass: function() {
this._removeClass( "ui-droppable-active" );
}
-});
+} );
-var intersect = (function() {
+var intersect = ( function() {
function isOverAxis( x, reference, size ) {
return ( x >= reference ) && ( x < ( reference + size ) );
}
@@ -277,7 +280,7 @@ var intersect = (function() {
return false;
}
};
-})();
+} )();
/*
This manager tracks offsets of draggables and droppables
@@ -318,7 +321,7 @@ $.ui.ddmanager = {
}
m[ i ].offset = m[ i ].element.offset();
- m[ i ].proportions({ width: m[ i ].element[ 0 ].offsetWidth, height: m[ i ].element[ 0 ].offsetHeight });
+ m[ i ].proportions( { width: m[ i ].element[ 0 ].offsetWidth, height: m[ i ].element[ 0 ].offsetHeight } );
}
@@ -326,6 +329,7 @@ $.ui.ddmanager = {
drop: function( draggable, event ) {
var dropped = false;
+
// Create a copy of the droppables in case the list changes during the drop (#9116)
$.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(), function() {
@@ -342,17 +346,18 @@ $.ui.ddmanager = {
this._deactivate.call( this, event );
}
- });
+ } );
return dropped;
},
dragStart: function( draggable, event ) {
+
// Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
draggable.element.parentsUntil( "body" ).on( "scroll.droppable", function() {
if ( !draggable.options.refreshPositions ) {
$.ui.ddmanager.prepareOffsets( draggable, event );
}
- });
+ } );
},
drag: function( draggable, event ) {
@@ -376,11 +381,12 @@ $.ui.ddmanager = {
}
if ( this.options.greedy ) {
+
// find droppable parents with same scope
scope = this.options.scope;
- parent = this.element.parents( ":data(ui-droppable)" ).filter(function() {
+ parent = this.element.parents( ":data(ui-droppable)" ).filter( function() {
return $( this ).droppable( "instance" ).options.scope === scope;
- });
+ } );
if ( parent.length ) {
parentInstance = $( parent[ 0 ] ).droppable( "instance" );
@@ -388,7 +394,7 @@ $.ui.ddmanager = {
}
}
- // we just moved into a greedy child
+ // We just moved into a greedy child
if ( parentInstance && c === "isover" ) {
parentInstance.isover = false;
parentInstance.isout = true;
@@ -396,20 +402,21 @@ $.ui.ddmanager = {
}
this[ c ] = true;
- this[c === "isout" ? "isover" : "isout"] = false;
- this[c === "isover" ? "_over" : "_out"].call( this, event );
+ this[ c === "isout" ? "isover" : "isout" ] = false;
+ this[ c === "isover" ? "_over" : "_out" ].call( this, event );
- // we just moved out of a greedy child
+ // We just moved out of a greedy child
if ( parentInstance && c === "isout" ) {
parentInstance.isout = false;
parentInstance.isover = true;
parentInstance._over.call( parentInstance, event );
}
- });
+ } );
},
dragStop: function( draggable, event ) {
draggable.element.parentsUntil( "body" ).off( "scroll.droppable" );
+
// Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
if ( !draggable.options.refreshPositions ) {
$.ui.ddmanager.prepareOffsets( draggable, event );
@@ -451,9 +458,9 @@ if ( $.uiBackCompat !== false ) {
this.element.removeClass( this.options.hoverClass );
}
}
- });
+ } );
}
return $.ui.droppable;
-}));
+} ) );
diff --git a/ui/widgets/menu.js b/ui/widgets/menu.js
index 3e1f71a3b..d42d65bac 100644
--- a/ui/widgets/menu.js
+++ b/ui/widgets/menu.js
@@ -52,7 +52,7 @@ return $.widget( "ui.menu", {
},
role: "menu",
- // callbacks
+ // Callbacks
blur: null,
focus: null,
select: null
@@ -71,11 +71,6 @@ return $.widget( "ui.menu", {
tabIndex: 0
} );
- if ( this.options.disabled ) {
- this._addClass( null, "ui-state-disabled" );
- this.element.attr( "aria-disabled", "true" );
- }
-
this._addClass( "ui-menu", "ui-widget ui-widget-content" );
this._on( {
@@ -136,6 +131,7 @@ return $.widget( "ui.menu", {
mouseleave: "collapseAll",
"mouseleave .ui-menu": "collapseAll",
focus: function( event, keepActiveItem ) {
+
// If there's already an active item, keep it active
// If not, activate the first item
var item = this.active || this.element.find( this.options.items ).eq( 0 );
@@ -358,13 +354,16 @@ return $.widget( "ui.menu", {
this._removeClass( icons, null, this.options.icons.submenu )
._addClass( icons, null, value.submenu );
}
- if ( key === "disabled" ) {
- this.element.attr( "aria-disabled", value );
- this._toggleClass( null, "ui-state-disabled", !!value );
- }
this._super( key, value );
},
+ _setOptionDisabled: function( value ) {
+ this._super( value );
+
+ this.element.attr( "aria-disabled", String( value ) );
+ this._toggleClass( null, "ui-state-disabled", !!value );
+ },
+
focus: function( event, item ) {
var nested, focused, activeParent;
this.blur( event, event && event.type === "focus" );
@@ -475,6 +474,7 @@ return $.widget( "ui.menu", {
collapseAll: function( event, all ) {
clearTimeout( this.timer );
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" ) );
@@ -633,6 +633,7 @@ return $.widget( "ui.menu", {
},
select: function( event ) {
+
// TODO: It should never be possible to not have an active item at this
// point, but the tests don't trigger mouseenter before click.
this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
diff --git a/ui/widgets/mouse.js b/ui/widgets/mouse.js
index 80242c0b7..938d0f4b7 100644
--- a/ui/widgets/mouse.js
+++ b/ui/widgets/mouse.js
@@ -12,11 +12,11 @@
//>>description: Abstracts mouse-based interactions to assist in creating certain widgets.
//>>docs: http://api.jqueryui.com/mouse/
-(function( factory ) {
+( function( factory ) {
if ( typeof define === "function" && define.amd ) {
// AMD. Register as an anonymous module.
- define([
+ define( [
"jquery",
"../ie",
"../version",
@@ -27,14 +27,14 @@
// Browser globals
factory( jQuery );
}
-}(function( $ ) {
+}( function( $ ) {
var mouseHandled = false;
$( document ).on( "mouseup", function() {
mouseHandled = false;
-});
+} );
-return $.widget("ui.mouse", {
+return $.widget( "ui.mouse", {
version: "@VERSION",
options: {
cancel: "input, textarea, button, select, option",
@@ -45,16 +45,16 @@ return $.widget("ui.mouse", {
var that = this;
this.element
- .on("mousedown." + this.widgetName, function(event) {
- return that._mouseDown(event);
- })
- .on("click." + this.widgetName, function(event) {
- if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) {
- $.removeData(event.target, that.widgetName + ".preventClickEvent");
+ .on( "mousedown." + this.widgetName, function( event ) {
+ return that._mouseDown( event );
+ } )
+ .on( "click." + this.widgetName, function( event ) {
+ if ( true === $.data( event.target, that.widgetName + ".preventClickEvent" ) ) {
+ $.removeData( event.target, that.widgetName + ".preventClickEvent" );
event.stopImmediatePropagation();
return false;
}
- });
+ } );
this.started = false;
},
@@ -62,15 +62,16 @@ return $.widget("ui.mouse", {
// TODO: make sure destroying one instance of mouse doesn't mess with
// other instances of mouse
_mouseDestroy: function() {
- this.element.off("." + this.widgetName);
+ this.element.off( "." + this.widgetName );
if ( this._mouseMoveDelegate ) {
this.document
- .off("mousemove." + this.widgetName, this._mouseMoveDelegate)
- .off("mouseup." + this.widgetName, this._mouseUpDelegate);
+ .off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
+ .off( "mouseup." + this.widgetName, this._mouseUpDelegate );
}
},
- _mouseDown: function(event) {
+ _mouseDown: function( event ) {
+
// don't let more than one widget handle mouseStart
if ( mouseHandled ) {
return;
@@ -78,46 +79,47 @@ return $.widget("ui.mouse", {
this._mouseMoved = false;
- // we may have missed mouseup (out of window)
- (this._mouseStarted && this._mouseUp(event));
+ // We may have missed mouseup (out of window)
+ ( this._mouseStarted && this._mouseUp( event ) );
this._mouseDownEvent = event;
var that = this,
- btnIsLeft = (event.which === 1),
+ btnIsLeft = ( event.which === 1 ),
+
// event.target.nodeName works around a bug in IE 8 with
// disabled inputs (#7620)
- elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
- if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
+ elIsCancel = ( typeof this.options.cancel === "string" && event.target.nodeName ? $( event.target ).closest( this.options.cancel ).length : false );
+ if ( !btnIsLeft || elIsCancel || !this._mouseCapture( event ) ) {
return true;
}
this.mouseDelayMet = !this.options.delay;
- if (!this.mouseDelayMet) {
- this._mouseDelayTimer = setTimeout(function() {
+ if ( !this.mouseDelayMet ) {
+ this._mouseDelayTimer = setTimeout( function() {
that.mouseDelayMet = true;
- }, this.options.delay);
+ }, this.options.delay );
}
- if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
- this._mouseStarted = (this._mouseStart(event) !== false);
- if (!this._mouseStarted) {
+ if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
+ this._mouseStarted = ( this._mouseStart( event ) !== false );
+ if ( !this._mouseStarted ) {
event.preventDefault();
return true;
}
}
// Click event may never have fired (Gecko & Opera)
- if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
- $.removeData(event.target, this.widgetName + ".preventClickEvent");
+ if ( true === $.data( event.target, this.widgetName + ".preventClickEvent" ) ) {
+ $.removeData( event.target, this.widgetName + ".preventClickEvent" );
}
- // these delegates are required to keep context
- this._mouseMoveDelegate = function(event) {
- return that._mouseMove(event);
+ // These delegates are required to keep context
+ this._mouseMoveDelegate = function( event ) {
+ return that._mouseMove( event );
};
- this._mouseUpDelegate = function(event) {
- return that._mouseUp(event);
+ this._mouseUpDelegate = function( event ) {
+ return that._mouseUp( event );
};
this.document
@@ -130,15 +132,17 @@ return $.widget("ui.mouse", {
return true;
},
- _mouseMove: function(event) {
+ _mouseMove: function( event ) {
+
// Only check for mouseups outside the document if you've moved inside the document
// at least once. This prevents the firing of mouseup in the case of IE<9, which will
// fire a mousemove event if content is placed under the cursor. See #7778
// Support: IE <9
if ( this._mouseMoved ) {
+
// IE mouseup check - mouseup happened when mouse was out of window
- if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) {
- return this._mouseUp(event);
+ if ( $.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button ) {
+ return this._mouseUp( event );
// Iframe mouseup check - mouseup occurred in another document
} else if ( !event.which ) {
@@ -150,56 +154,61 @@ return $.widget("ui.mouse", {
this._mouseMoved = true;
}
- if (this._mouseStarted) {
- this._mouseDrag(event);
+ if ( this._mouseStarted ) {
+ this._mouseDrag( event );
return event.preventDefault();
}
- if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
+ if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
this._mouseStarted =
- (this._mouseStart(this._mouseDownEvent, event) !== false);
- (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
+ ( this._mouseStart( this._mouseDownEvent, event ) !== false );
+ ( this._mouseStarted ? this._mouseDrag( event ) : this._mouseUp( event ) );
}
return !this._mouseStarted;
},
- _mouseUp: function(event) {
+ _mouseUp: function( event ) {
this.document
.off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
.off( "mouseup." + this.widgetName, this._mouseUpDelegate );
- if (this._mouseStarted) {
+ if ( this._mouseStarted ) {
this._mouseStarted = false;
- if (event.target === this._mouseDownEvent.target) {
- $.data(event.target, this.widgetName + ".preventClickEvent", true);
+ if ( event.target === this._mouseDownEvent.target ) {
+ $.data( event.target, this.widgetName + ".preventClickEvent", true );
}
- this._mouseStop(event);
+ this._mouseStop( event );
+ }
+
+ if ( this._mouseDelayTimer ) {
+ clearTimeout( this._mouseDelayTimer );
+ delete this._mouseDelayTimer;
}
mouseHandled = false;
return false;
},
- _mouseDistanceMet: function(event) {
- return (Math.max(
- Math.abs(this._mouseDownEvent.pageX - event.pageX),
- Math.abs(this._mouseDownEvent.pageY - event.pageY)
+ _mouseDistanceMet: function( event ) {
+ return ( Math.max(
+ Math.abs( this._mouseDownEvent.pageX - event.pageX ),
+ Math.abs( this._mouseDownEvent.pageY - event.pageY )
) >= this.options.distance
);
},
- _mouseDelayMet: function(/* event */) {
+ _mouseDelayMet: function( /* event */ ) {
return this.mouseDelayMet;
},
// These are placeholder methods, to be overriden by extending plugin
- _mouseStart: function(/* event */) {},
- _mouseDrag: function(/* event */) {},
- _mouseStop: function(/* event */) {},
- _mouseCapture: function(/* event */) { return true; }
-});
+ _mouseStart: function( /* event */ ) {},
+ _mouseDrag: function( /* event */ ) {},
+ _mouseStop: function( /* event */ ) {},
+ _mouseCapture: function( /* event */ ) { return true; }
+} );
-}));
+} ) );
diff --git a/ui/widgets/progressbar.js b/ui/widgets/progressbar.js
index a52cbb713..7e2695994 100644
--- a/ui/widgets/progressbar.js
+++ b/ui/widgets/progressbar.js
@@ -90,7 +90,7 @@ return $.widget( "ui.progressbar", {
this.indeterminate = newValue === false;
- // sanitize value
+ // Sanitize value
if ( typeof newValue !== "number" ) {
newValue = 0;
}
@@ -100,6 +100,7 @@ return $.widget( "ui.progressbar", {
},
_setOptions: function( options ) {
+
// Ensure "value" option is set after other values (like max)
var value = options.value;
delete options.value;
@@ -112,16 +113,20 @@ return $.widget( "ui.progressbar", {
_setOption: function( key, value ) {
if ( key === "max" ) {
+
// Don't allow a max less than min
value = Math.max( this.min, value );
}
- if ( key === "disabled" ) {
- this.element.attr( "aria-disabled", value );
- this._toggleClass( null, "ui-state-disabled", !!value );
- }
this._super( key, value );
},
+ _setOptionDisabled: function( value ) {
+ this._super( value );
+
+ this.element.attr( "aria-disabled", value );
+ this._toggleClass( null, "ui-state-disabled", !!value );
+ },
+
_percentage: function() {
return this.indeterminate ? 100 : 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
},
diff --git a/ui/widgets/resizable.js b/ui/widgets/resizable.js
index 95cf918d9..74e664c43 100644
--- a/ui/widgets/resizable.js
+++ b/ui/widgets/resizable.js
@@ -16,11 +16,11 @@
//>>css.structure: ../themes/base/resizable.css
//>>css.theme: ../themes/base/theme.css
-(function( factory ) {
+( function( factory ) {
if ( typeof define === "function" && define.amd ) {
// AMD. Register as an anonymous module.
- define([
+ define( [
"jquery",
"./mouse",
"../disable-selection",
@@ -33,9 +33,9 @@
// Browser globals
factory( jQuery );
}
-}(function( $ ) {
+}( function( $ ) {
-$.widget("ui.resizable", $.ui.mouse, {
+$.widget( "ui.resizable", $.ui.mouse, {
version: "@VERSION",
widgetEventPrefix: "resize",
options: {
@@ -57,26 +57,27 @@ $.widget("ui.resizable", $.ui.mouse, {
maxWidth: null,
minHeight: 10,
minWidth: 10,
+
// See #7960
zIndex: 90,
- // callbacks
+ // Callbacks
resize: null,
start: null,
stop: null
},
_num: function( value ) {
- return parseInt( value, 10 ) || 0;
+ return parseFloat( value ) || 0;
},
_isNumber: function( value ) {
- return !isNaN( parseInt( value, 10 ) );
+ return !isNaN( parseFloat( value ) );
},
_hasScroll: function( el, a ) {
- if ( $( el ).css( "overflow" ) === "hidden") {
+ if ( $( el ).css( "overflow" ) === "hidden" ) {
return false;
}
@@ -103,25 +104,25 @@ $.widget("ui.resizable", $.ui.mouse, {
o = this.options;
this._addClass( "ui-resizable" );
- $.extend(this, {
- _aspectRatio: !!(o.aspectRatio),
+ $.extend( this, {
+ _aspectRatio: !!( o.aspectRatio ),
aspectRatio: o.aspectRatio,
originalElement: this.element,
_proportionallyResizeElements: [],
_helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
- });
+ } );
// Wrap the element if it cannot hold child nodes
- if (this.element[0].nodeName.match(/^(canvas|textarea|input|select|button|img)$/i)) {
+ if ( this.element[ 0 ].nodeName.match( /^(canvas|textarea|input|select|button|img)$/i ) ) {
this.element.wrap(
- $("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({
- position: this.element.css("position"),
+ $( "<div class='ui-wrapper' style='overflow: hidden;'></div>" ).css( {
+ position: this.element.css( "position" ),
width: this.element.outerWidth(),
height: this.element.outerHeight(),
- top: this.element.css("top"),
- left: this.element.css("left")
- })
+ top: this.element.css( "top" ),
+ left: this.element.css( "left" )
+ } )
);
this.element = this.element.parent().data(
@@ -130,38 +131,39 @@ $.widget("ui.resizable", $.ui.mouse, {
this.elementIsWrapper = true;
- this.element.css({
- marginLeft: this.originalElement.css("marginLeft"),
- marginTop: this.originalElement.css("marginTop"),
- marginRight: this.originalElement.css("marginRight"),
- marginBottom: this.originalElement.css("marginBottom")
- });
- this.originalElement.css({
+ this.element.css( {
+ marginLeft: this.originalElement.css( "marginLeft" ),
+ marginTop: this.originalElement.css( "marginTop" ),
+ marginRight: this.originalElement.css( "marginRight" ),
+ marginBottom: this.originalElement.css( "marginBottom" )
+ } );
+ this.originalElement.css( {
marginLeft: 0,
marginTop: 0,
marginRight: 0,
marginBottom: 0
- });
+ } );
+
// support: Safari
// Prevent Safari textarea resize
- this.originalResizeStyle = this.originalElement.css("resize");
- this.originalElement.css("resize", "none");
+ this.originalResizeStyle = this.originalElement.css( "resize" );
+ this.originalElement.css( "resize", "none" );
- this._proportionallyResizeElements.push( this.originalElement.css({
+ this._proportionallyResizeElements.push( this.originalElement.css( {
position: "static",
zoom: 1,
display: "block"
- }) );
+ } ) );
- // support: IE9
+ // Support: IE9
// avoid IE jump (hard set the margin)
- this.originalElement.css({ margin: this.originalElement.css("margin") });
+ this.originalElement.css( { margin: this.originalElement.css( "margin" ) } );
this._proportionallyResize();
}
this.handles = o.handles ||
- ( !$(".ui-resizable-handle", this.element).length ?
+ ( !$( ".ui-resizable-handle", this.element ).length ?
"e,s,se" : {
n: ".ui-resizable-n",
e: ".ui-resizable-e",
@@ -176,55 +178,55 @@ $.widget("ui.resizable", $.ui.mouse, {
this._handles = $();
if ( this.handles.constructor === String ) {
- if ( this.handles === "all") {
+ if ( this.handles === "all" ) {
this.handles = "n,e,s,w,se,sw,ne,nw";
}
- n = this.handles.split(",");
+ n = this.handles.split( "," );
this.handles = {};
- for (i = 0; i < n.length; i++) {
+ for ( i = 0; i < n.length; i++ ) {
- handle = $.trim(n[i]);
+ handle = $.trim( n[ i ] );
hname = "ui-resizable-" + handle;
- axis = $("<div>");
+ axis = $( "<div>" );
this._addClass( axis, "ui-resizable-handle " + hname );
- axis.css({ zIndex: o.zIndex });
+ axis.css( { zIndex: o.zIndex } );
- this.handles[handle] = ".ui-resizable-" + handle;
- this.element.append(axis);
+ this.handles[ handle ] = ".ui-resizable-" + handle;
+ this.element.append( axis );
}
}
- this._renderAxis = function(target) {
+ this._renderAxis = function( target ) {
var i, axis, padPos, padWrapper;
target = target || this.element;
- for (i in this.handles) {
+ for ( i in this.handles ) {
- if (this.handles[i].constructor === String) {
- this.handles[i] = this.element.children( this.handles[ i ] ).first().show();
+ if ( this.handles[ i ].constructor === String ) {
+ this.handles[ i ] = this.element.children( this.handles[ i ] ).first().show();
} else if ( this.handles[ i ].jquery || this.handles[ i ].nodeType ) {
this.handles[ i ] = $( this.handles[ i ] );
- this._on( this.handles[ i ], { "mousedown": that._mouseDown });
+ this._on( this.handles[ i ], { "mousedown": that._mouseDown } );
}
- if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/^(textarea|input|select|button)$/i)) {
+ if ( this.elementIsWrapper && this.originalElement[ 0 ].nodeName.match( /^(textarea|input|select|button)$/i ) ) {
- axis = $(this.handles[i], this.element);
+ axis = $( this.handles[ i ], this.element );
- padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
+ padWrapper = /sw|ne|nw|se|n|s/.test( i ) ? axis.outerHeight() : axis.outerWidth();
padPos = [ "padding",
- /ne|nw|n/.test(i) ? "Top" :
- /se|sw|s/.test(i) ? "Bottom" :
- /^e$/.test(i) ? "Right" : "Left" ].join("");
+ /ne|nw|n/.test( i ) ? "Top" :
+ /se|sw|s/.test( i ) ? "Bottom" :
+ /^e$/.test( i ) ? "Right" : "Left" ].join( "" );
- target.css(padPos, padWrapper);
+ target.css( padPos, padWrapper );
this._proportionallyResize();
}
@@ -234,40 +236,40 @@ $.widget("ui.resizable", $.ui.mouse, {
};
// TODO: make renderAxis a prototype function
- this._renderAxis(this.element);
+ this._renderAxis( this.element );
this._handles = this._handles.add( this.element.find( ".ui-resizable-handle" ) );
this._handles.disableSelection();
this._handles.on( "mouseover", function() {
- if (!that.resizing) {
- if (this.className) {
- axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
+ if ( !that.resizing ) {
+ if ( this.className ) {
+ axis = this.className.match( /ui-resizable-(se|sw|ne|nw|n|e|s|w)/i );
}
- that.axis = axis && axis[1] ? axis[1] : "se";
+ that.axis = axis && axis[ 1 ] ? axis[ 1 ] : "se";
}
- });
+ } );
- if (o.autoHide) {
+ if ( o.autoHide ) {
this._handles.hide();
this._addClass( "ui-resizable-autohide" );
- $(this.element)
+ $( this.element )
.on( "mouseenter", function() {
- if (o.disabled) {
+ if ( o.disabled ) {
return;
}
that._removeClass( "ui-resizable-autohide" );
that._handles.show();
- })
+ } )
.on( "mouseleave", function() {
- if (o.disabled) {
+ if ( o.disabled ) {
return;
}
- if (!that.resizing) {
+ if ( !that.resizing ) {
that._addClass( "ui-resizable-autohide" );
that._handles.hide();
}
- });
+ } );
}
this._mouseInit();
@@ -278,42 +280,42 @@ $.widget("ui.resizable", $.ui.mouse, {
this._mouseDestroy();
var wrapper,
- _destroy = function(exp) {
- $(exp)
- .removeData("resizable")
- .removeData("ui-resizable")
- .off(".resizable")
- .find(".ui-resizable-handle")
+ _destroy = function( exp ) {
+ $( exp )
+ .removeData( "resizable" )
+ .removeData( "ui-resizable" )
+ .off( ".resizable" )
+ .find( ".ui-resizable-handle" )
.remove();
};
// TODO: Unwrap at same DOM position
- if (this.elementIsWrapper) {
- _destroy(this.element);
+ if ( this.elementIsWrapper ) {
+ _destroy( this.element );
wrapper = this.element;
- this.originalElement.css({
- position: wrapper.css("position"),
+ this.originalElement.css( {
+ position: wrapper.css( "position" ),
width: wrapper.outerWidth(),
height: wrapper.outerHeight(),
- top: wrapper.css("top"),
- left: wrapper.css("left")
- }).insertAfter( wrapper );
+ top: wrapper.css( "top" ),
+ left: wrapper.css( "left" )
+ } ).insertAfter( wrapper );
wrapper.remove();
}
- this.originalElement.css("resize", this.originalResizeStyle);
- _destroy(this.originalElement);
+ this.originalElement.css( "resize", this.originalResizeStyle );
+ _destroy( this.originalElement );
return this;
},
- _mouseCapture: function(event) {
+ _mouseCapture: function( event ) {
var i, handle,
capture = false;
- for (i in this.handles) {
- handle = $(this.handles[i])[0];
- if (handle === event.target || $.contains(handle, event.target)) {
+ for ( i in this.handles ) {
+ handle = $( this.handles[ i ] )[ 0 ];
+ if ( handle === event.target || $.contains( handle, event.target ) ) {
capture = true;
}
}
@@ -321,7 +323,7 @@ $.widget("ui.resizable", $.ui.mouse, {
return !this.options.disabled && capture;
},
- _mouseStart: function(event) {
+ _mouseStart: function( event ) {
var curleft, curtop, cursor,
o = this.options,
@@ -331,12 +333,12 @@ $.widget("ui.resizable", $.ui.mouse, {
this._renderProxy();
- curleft = this._num(this.helper.css("left"));
- curtop = this._num(this.helper.css("top"));
+ curleft = this._num( this.helper.css( "left" ) );
+ curtop = this._num( this.helper.css( "top" ) );
- if (o.containment) {
- curleft += $(o.containment).scrollLeft() || 0;
- curtop += $(o.containment).scrollTop() || 0;
+ if ( o.containment ) {
+ curleft += $( o.containment ).scrollLeft() || 0;
+ curtop += $( o.containment ).scrollTop() || 0;
}
this.offset = this.helper.offset();
@@ -366,45 +368,45 @@ $.widget("ui.resizable", $.ui.mouse, {
this.originalPosition = { left: curleft, top: curtop };
this.originalMousePosition = { left: event.pageX, top: event.pageY };
- this.aspectRatio = (typeof o.aspectRatio === "number") ?
+ this.aspectRatio = ( typeof o.aspectRatio === "number" ) ?
o.aspectRatio :
- ((this.originalSize.width / this.originalSize.height) || 1);
+ ( ( this.originalSize.width / this.originalSize.height ) || 1 );
- cursor = $(".ui-resizable-" + this.axis).css("cursor");
- $("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
+ cursor = $( ".ui-resizable-" + this.axis ).css( "cursor" );
+ $( "body" ).css( "cursor", cursor === "auto" ? this.axis + "-resize" : cursor );
this._addClass( "ui-resizable-resizing" );
- this._propagate("start", event);
+ this._propagate( "start", event );
return true;
},
- _mouseDrag: function(event) {
+ _mouseDrag: function( event ) {
var data, props,
smp = this.originalMousePosition,
a = this.axis,
- dx = (event.pageX - smp.left) || 0,
- dy = (event.pageY - smp.top) || 0,
- trigger = this._change[a];
+ dx = ( event.pageX - smp.left ) || 0,
+ dy = ( event.pageY - smp.top ) || 0,
+ trigger = this._change[ a ];
this._updatePrevProperties();
- if (!trigger) {
+ if ( !trigger ) {
return false;
}
- data = trigger.apply(this, [ event, dx, dy ]);
+ data = trigger.apply( this, [ event, dx, dy ] );
- this._updateVirtualBoundaries(event.shiftKey);
- if (this._aspectRatio || event.shiftKey) {
- data = this._updateRatio(data, event);
+ this._updateVirtualBoundaries( event.shiftKey );
+ if ( this._aspectRatio || event.shiftKey ) {
+ data = this._updateRatio( data, event );
}
- data = this._respectSize(data, event);
+ data = this._respectSize( data, event );
- this._updateCache(data);
+ this._updateCache( data );
- this._propagate("resize", event);
+ this._propagate( "resize", event );
props = this._applyChanges();
@@ -421,47 +423,47 @@ $.widget("ui.resizable", $.ui.mouse, {
return false;
},
- _mouseStop: function(event) {
+ _mouseStop: function( event ) {
this.resizing = false;
var pr, ista, soffseth, soffsetw, s, left, top,
o = this.options, that = this;
- if (this._helper) {
+ if ( this._helper ) {
pr = this._proportionallyResizeElements;
- ista = pr.length && (/textarea/i).test(pr[0].nodeName);
- soffseth = ista && this._hasScroll(pr[0], "left") ? 0 : that.sizeDiff.height;
+ ista = pr.length && ( /textarea/i ).test( pr[ 0 ].nodeName );
+ soffseth = ista && this._hasScroll( pr[ 0 ], "left" ) ? 0 : that.sizeDiff.height;
soffsetw = ista ? 0 : that.sizeDiff.width;
s = {
- width: (that.helper.width() - soffsetw),
- height: (that.helper.height() - soffseth)
+ 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;
+ left = ( parseFloat( that.element.css( "left" ) ) +
+ ( that.position.left - that.originalPosition.left ) ) || null;
+ top = ( parseFloat( that.element.css( "top" ) ) +
+ ( that.position.top - that.originalPosition.top ) ) || null;
- if (!o.animate) {
- this.element.css($.extend(s, { top: top, left: left }));
+ if ( !o.animate ) {
+ this.element.css( $.extend( s, { top: top, left: left } ) );
}
- that.helper.height(that.size.height);
- that.helper.width(that.size.width);
+ that.helper.height( that.size.height );
+ that.helper.width( that.size.width );
- if (this._helper && !o.animate) {
+ if ( this._helper && !o.animate ) {
this._proportionallyResize();
}
}
- $("body").css("cursor", "auto");
+ $( "body" ).css( "cursor", "auto" );
this._removeClass( "ui-resizable-resizing" );
- this._propagate("stop", event);
+ this._propagate( "stop", event );
- if (this._helper) {
+ if ( this._helper ) {
this.helper.remove();
}
@@ -501,51 +503,51 @@ $.widget("ui.resizable", $.ui.mouse, {
return props;
},
- _updateVirtualBoundaries: function(forceAspectRatio) {
+ _updateVirtualBoundaries: function( forceAspectRatio ) {
var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
o = this.options;
b = {
- minWidth: this._isNumber(o.minWidth) ? o.minWidth : 0,
- maxWidth: this._isNumber(o.maxWidth) ? o.maxWidth : Infinity,
- minHeight: this._isNumber(o.minHeight) ? o.minHeight : 0,
- maxHeight: this._isNumber(o.maxHeight) ? o.maxHeight : Infinity
+ minWidth: this._isNumber( o.minWidth ) ? o.minWidth : 0,
+ maxWidth: this._isNumber( o.maxWidth ) ? o.maxWidth : Infinity,
+ minHeight: this._isNumber( o.minHeight ) ? o.minHeight : 0,
+ maxHeight: this._isNumber( o.maxHeight ) ? o.maxHeight : Infinity
};
- if (this._aspectRatio || forceAspectRatio) {
+ if ( this._aspectRatio || forceAspectRatio ) {
pMinWidth = b.minHeight * this.aspectRatio;
pMinHeight = b.minWidth / this.aspectRatio;
pMaxWidth = b.maxHeight * this.aspectRatio;
pMaxHeight = b.maxWidth / this.aspectRatio;
- if (pMinWidth > b.minWidth) {
+ if ( pMinWidth > b.minWidth ) {
b.minWidth = pMinWidth;
}
- if (pMinHeight > b.minHeight) {
+ if ( pMinHeight > b.minHeight ) {
b.minHeight = pMinHeight;
}
- if (pMaxWidth < b.maxWidth) {
+ if ( pMaxWidth < b.maxWidth ) {
b.maxWidth = pMaxWidth;
}
- if (pMaxHeight < b.maxHeight) {
+ if ( pMaxHeight < b.maxHeight ) {
b.maxHeight = pMaxHeight;
}
}
this._vBoundaries = b;
},
- _updateCache: function(data) {
+ _updateCache: function( data ) {
this.offset = this.helper.offset();
- if (this._isNumber(data.left)) {
+ if ( this._isNumber( data.left ) ) {
this.position.left = data.left;
}
- if (this._isNumber(data.top)) {
+ if ( this._isNumber( data.top ) ) {
this.position.top = data.top;
}
- if (this._isNumber(data.height)) {
+ if ( this._isNumber( data.height ) ) {
this.size.height = data.height;
}
- if (this._isNumber(data.width)) {
+ if ( this._isNumber( data.width ) ) {
this.size.width = data.width;
}
},
@@ -556,19 +558,19 @@ $.widget("ui.resizable", $.ui.mouse, {
csize = this.size,
a = this.axis;
- if (this._isNumber(data.height)) {
- data.width = (data.height * this.aspectRatio);
- } else if (this._isNumber(data.width)) {
- data.height = (data.width / this.aspectRatio);
+ if ( this._isNumber( data.height ) ) {
+ data.width = ( data.height * this.aspectRatio );
+ } else if ( this._isNumber( data.width ) ) {
+ data.height = ( data.width / this.aspectRatio );
}
- if (a === "sw") {
- data.left = cpos.left + (csize.width - data.width);
+ if ( a === "sw" ) {
+ data.left = cpos.left + ( csize.width - data.width );
data.top = null;
}
- if (a === "nw") {
- data.top = cpos.top + (csize.height - data.height);
- data.left = cpos.left + (csize.width - data.width);
+ if ( a === "nw" ) {
+ data.top = cpos.top + ( csize.height - data.height );
+ data.left = cpos.left + ( csize.width - data.width );
}
return data;
@@ -578,43 +580,43 @@ $.widget("ui.resizable", $.ui.mouse, {
var o = this._vBoundaries,
a = this.axis,
- ismaxw = this._isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width),
- ismaxh = this._isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
- isminw = this._isNumber(data.width) && o.minWidth && (o.minWidth > data.width),
- isminh = this._isNumber(data.height) && o.minHeight && (o.minHeight > data.height),
+ ismaxw = this._isNumber( data.width ) && o.maxWidth && ( o.maxWidth < data.width ),
+ ismaxh = this._isNumber( data.height ) && o.maxHeight && ( o.maxHeight < data.height ),
+ isminw = this._isNumber( data.width ) && o.minWidth && ( o.minWidth > data.width ),
+ isminh = this._isNumber( data.height ) && o.minHeight && ( o.minHeight > data.height ),
dw = this.originalPosition.left + this.originalSize.width,
dh = this.position.top + this.size.height,
- cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
- if (isminw) {
+ cw = /sw|nw|w/.test( a ), ch = /nw|ne|n/.test( a );
+ if ( isminw ) {
data.width = o.minWidth;
}
- if (isminh) {
+ if ( isminh ) {
data.height = o.minHeight;
}
- if (ismaxw) {
+ if ( ismaxw ) {
data.width = o.maxWidth;
}
- if (ismaxh) {
+ if ( ismaxh ) {
data.height = o.maxHeight;
}
- if (isminw && cw) {
+ if ( isminw && cw ) {
data.left = dw - o.minWidth;
}
- if (ismaxw && cw) {
+ if ( ismaxw && cw ) {
data.left = dw - o.maxWidth;
}
- if (isminh && ch) {
+ if ( isminh && ch ) {
data.top = dh - o.minHeight;
}
- if (ismaxh && ch) {
+ if ( ismaxh && ch ) {
data.top = dh - o.maxHeight;
}
// Fixing jump error on top/left - bug #2330
- if (!data.width && !data.height && !data.left && data.top) {
+ if ( !data.width && !data.height && !data.left && data.top ) {
data.top = null;
- } else if (!data.width && !data.height && !data.top && data.left) {
+ } else if ( !data.width && !data.height && !data.top && data.left ) {
data.left = null;
}
@@ -638,8 +640,8 @@ $.widget("ui.resizable", $.ui.mouse, {
];
for ( ; i < 4; i++ ) {
- widths[ i ] = ( parseInt( borders[ i ], 10 ) || 0 );
- widths[ i ] += ( parseInt( paddings[ i ], 10 ) || 0 );
+ widths[ i ] = ( parseFloat( borders[ i ] ) || 0 );
+ widths[ i ] += ( parseFloat( paddings[ i ] ) || 0 );
}
return {
@@ -650,7 +652,7 @@ $.widget("ui.resizable", $.ui.mouse, {
_proportionallyResize: function() {
- if (!this._proportionallyResizeElements.length) {
+ if ( !this._proportionallyResizeElements.length ) {
return;
}
@@ -658,20 +660,20 @@ $.widget("ui.resizable", $.ui.mouse, {
i = 0,
element = this.helper || this.element;
- for ( ; i < this._proportionallyResizeElements.length; i++) {
+ for ( ; i < this._proportionallyResizeElements.length; i++ ) {
- prel = this._proportionallyResizeElements[i];
+ prel = this._proportionallyResizeElements[ i ];
// TODO: Seems like a bug to cache this.outerDimensions
// considering that we are in a loop.
- if (!this.outerDimensions) {
+ if ( !this.outerDimensions ) {
this.outerDimensions = this._getPaddingPlusBorderDimensions( prel );
}
- prel.css({
- height: (element.height() - this.outerDimensions.height) || 0,
- width: (element.width() - this.outerDimensions.width) || 0
- });
+ prel.css( {
+ height: ( element.height() - this.outerDimensions.height ) || 0,
+ width: ( element.width() - this.outerDimensions.width ) || 0
+ } );
}
@@ -682,22 +684,22 @@ $.widget("ui.resizable", $.ui.mouse, {
var el = this.element, o = this.options;
this.elementOffset = el.offset();
- if (this._helper) {
+ if ( this._helper ) {
- this.helper = this.helper || $("<div style='overflow:hidden;'></div>");
+ this.helper = this.helper || $( "<div style='overflow:hidden;'></div>" );
this._addClass( this.helper, this._helper );
- this.helper.css({
+ this.helper.css( {
width: this.element.outerWidth() - 1,
height: this.element.outerHeight() - 1,
position: "absolute",
left: this.elementOffset.left + "px",
top: this.elementOffset.top + "px",
zIndex: ++o.zIndex //TODO: Don't modify option
- });
+ } );
this.helper
- .appendTo("body")
+ .appendTo( "body" )
.disableSelection();
} else {
@@ -707,41 +709,41 @@ $.widget("ui.resizable", $.ui.mouse, {
},
_change: {
- e: function(event, dx) {
+ e: function( event, dx ) {
return { width: this.originalSize.width + dx };
},
- w: function(event, dx) {
+ w: function( event, dx ) {
var cs = this.originalSize, sp = this.originalPosition;
return { left: sp.left + dx, width: cs.width - dx };
},
- n: function(event, dx, dy) {
+ n: function( event, dx, dy ) {
var cs = this.originalSize, sp = this.originalPosition;
return { top: sp.top + dy, height: cs.height - dy };
},
- s: function(event, dx, dy) {
+ s: function( event, dx, dy ) {
return { height: this.originalSize.height + dy };
},
- se: function(event, dx, dy) {
- return $.extend(this._change.s.apply(this, arguments),
- this._change.e.apply(this, [ event, dx, dy ]));
+ se: function( event, dx, dy ) {
+ return $.extend( this._change.s.apply( this, arguments ),
+ this._change.e.apply( this, [ event, dx, dy ] ) );
},
- sw: function(event, dx, dy) {
- return $.extend(this._change.s.apply(this, arguments),
- this._change.w.apply(this, [ event, dx, dy ]));
+ sw: function( event, dx, dy ) {
+ return $.extend( this._change.s.apply( this, arguments ),
+ this._change.w.apply( this, [ event, dx, dy ] ) );
},
- ne: function(event, dx, dy) {
- return $.extend(this._change.n.apply(this, arguments),
- this._change.e.apply(this, [ event, dx, dy ]));
+ ne: function( event, dx, dy ) {
+ return $.extend( this._change.n.apply( this, arguments ),
+ this._change.e.apply( this, [ event, dx, dy ] ) );
},
- nw: function(event, dx, dy) {
- return $.extend(this._change.n.apply(this, arguments),
- this._change.w.apply(this, [ event, dx, dy ]));
+ nw: function( event, dx, dy ) {
+ return $.extend( this._change.n.apply( this, arguments ),
+ this._change.w.apply( this, [ event, dx, dy ] ) );
}
},
- _propagate: function(n, event) {
- $.ui.plugin.call(this, n, [ event, this.ui() ]);
- (n !== "resize" && this._trigger(n, event, this.ui()));
+ _propagate: function( n, event ) {
+ $.ui.plugin.call( this, n, [ event, this.ui() ] );
+ ( n !== "resize" && this._trigger( n, event, this.ui() ) );
},
plugins: {},
@@ -758,54 +760,54 @@ $.widget("ui.resizable", $.ui.mouse, {
};
}
-});
+} );
/*
* Resizable Extensions
*/
-$.ui.plugin.add("resizable", "animate", {
+$.ui.plugin.add( "resizable", "animate", {
stop: function( event ) {
- var that = $(this).resizable( "instance" ),
+ var that = $( this ).resizable( "instance" ),
o = that.options,
pr = that._proportionallyResizeElements,
- ista = pr.length && (/textarea/i).test(pr[0].nodeName),
- soffseth = ista && that._hasScroll(pr[0], "left") ? 0 : that.sizeDiff.height,
+ ista = pr.length && ( /textarea/i ).test( pr[ 0 ].nodeName ),
+ soffseth = ista && that._hasScroll( pr[ 0 ], "left" ) ? 0 : that.sizeDiff.height,
soffsetw = ista ? 0 : that.sizeDiff.width,
- 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;
+ style = { width: ( that.size.width - soffsetw ), height: ( that.size.height - soffseth ) },
+ left = ( parseFloat( that.element.css( "left" ) ) +
+ ( that.position.left - that.originalPosition.left ) ) || null,
+ top = ( parseFloat( that.element.css( "top" ) ) +
+ ( that.position.top - that.originalPosition.top ) ) || null;
that.element.animate(
- $.extend(style, top && left ? { top: top, left: left } : {}), {
+ $.extend( style, top && left ? { top: top, left: left } : {} ), {
duration: o.animateDuration,
easing: o.animateEasing,
step: function() {
var data = {
- 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)
+ width: parseFloat( that.element.css( "width" ) ),
+ height: parseFloat( that.element.css( "height" ) ),
+ top: parseFloat( that.element.css( "top" ) ),
+ left: parseFloat( that.element.css( "left" ) )
};
- if (pr && pr.length) {
- $(pr[0]).css({ width: data.width, height: data.height });
+ if ( pr && pr.length ) {
+ $( pr[ 0 ] ).css( { width: data.width, height: data.height } );
}
- // propagating resize, and updating values for each animation step
- that._updateCache(data);
- that._propagate("resize", event);
+ // Propagating resize, and updating values for each animation step
+ that._updateCache( data );
+ that._propagate( "resize", event );
}
}
);
}
-});
+} );
$.ui.plugin.add( "resizable", "containment", {
@@ -843,9 +845,9 @@ $.ui.plugin.add( "resizable", "containment", {
} else {
element = $( ce );
p = [];
- $([ "Top", "Right", "Left", "Bottom" ]).each(function( i, name ) {
+ $( [ "Top", "Right", "Left", "Bottom" ] ).each( function( i, name ) {
p[ i ] = that._num( element.css( "padding" + name ) );
- });
+ } );
that.containerOffset = element.offset();
that.containerPosition = element.position();
@@ -926,14 +928,14 @@ $.ui.plugin.add( "resizable", "containment", {
}
woset = Math.abs( that.sizeDiff.width +
- (that._helper ?
+ ( that._helper ?
that.offset.left - cop.left :
- (that.offset.left - co.left)) );
+ ( that.offset.left - co.left ) ) );
hoset = Math.abs( that.sizeDiff.height +
- (that._helper ?
+ ( that._helper ?
that.offset.top - cop.top :
- (that.offset.top - co.top)) );
+ ( that.offset.top - co.top ) ) );
if ( woset + that.size.width >= that.parentData.width ) {
that.size.width = that.parentData.width - woset;
@@ -971,80 +973,80 @@ $.ui.plugin.add( "resizable", "containment", {
h = helper.outerHeight() - that.sizeDiff.height;
if ( that._helper && !o.animate && ( /relative/ ).test( ce.css( "position" ) ) ) {
- $( this ).css({
+ $( this ).css( {
left: ho.left - cop.left - co.left,
width: w,
height: h
- });
+ } );
}
if ( that._helper && !o.animate && ( /static/ ).test( ce.css( "position" ) ) ) {
- $( this ).css({
+ $( this ).css( {
left: ho.left - cop.left - co.left,
width: w,
height: h
- });
+ } );
}
}
-});
+} );
-$.ui.plugin.add("resizable", "alsoResize", {
+$.ui.plugin.add( "resizable", "alsoResize", {
start: function() {
- var that = $(this).resizable( "instance" ),
+ var that = $( this ).resizable( "instance" ),
o = that.options;
- $(o.alsoResize).each(function() {
- var el = $(this);
- el.data("ui-resizable-alsoresize", {
- width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
- left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10)
- });
- });
+ $( o.alsoResize ).each( function() {
+ var el = $( this );
+ el.data( "ui-resizable-alsoresize", {
+ width: parseFloat( el.width() ), height: parseFloat( el.height() ),
+ left: parseFloat( el.css( "left" ) ), top: parseFloat( el.css( "top" ) )
+ } );
+ } );
},
- resize: function(event, ui) {
- var that = $(this).resizable( "instance" ),
+ resize: function( event, ui ) {
+ var that = $( this ).resizable( "instance" ),
o = that.options,
os = that.originalSize,
op = that.originalPosition,
delta = {
- 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
+ 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
};
- $(o.alsoResize).each(function() {
- var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
- css = el.parents(ui.originalElement[0]).length ?
+ $( o.alsoResize ).each( function() {
+ var el = $( this ), start = $( this ).data( "ui-resizable-alsoresize" ), style = {},
+ css = el.parents( ui.originalElement[ 0 ] ).length ?
[ "width", "height" ] :
[ "width", "height", "top", "left" ];
- $.each(css, function(i, prop) {
- var sum = (start[prop] || 0) + (delta[prop] || 0);
- if (sum && sum >= 0) {
- style[prop] = sum || null;
+ $.each( css, function( i, prop ) {
+ var sum = ( start[ prop ] || 0 ) + ( delta[ prop ] || 0 );
+ if ( sum && sum >= 0 ) {
+ style[ prop ] = sum || null;
}
- });
+ } );
- el.css(style);
- });
+ el.css( style );
+ } );
},
stop: function() {
- $(this).removeData("resizable-alsoresize");
+ $( this ).removeData( "resizable-alsoresize" );
}
-});
+} );
-$.ui.plugin.add("resizable", "ghost", {
+$.ui.plugin.add( "resizable", "ghost", {
start: function() {
- var that = $(this).resizable( "instance" ), cs = that.size;
+ var that = $( this ).resizable( "instance" ), cs = that.size;
that.ghost = that.originalElement.clone();
- that.ghost.css({
+ that.ghost.css( {
opacity: 0.25,
display: "block",
position: "relative",
@@ -1053,7 +1055,7 @@ $.ui.plugin.add("resizable", "ghost", {
margin: 0,
left: 0,
top: 0
- });
+ } );
that._addClass( that.ghost, "ui-resizable-ghost" );
@@ -1065,80 +1067,80 @@ $.ui.plugin.add("resizable", "ghost", {
that.ghost.addClass( this.options.ghost );
}
- that.ghost.appendTo(that.helper);
+ that.ghost.appendTo( that.helper );
},
resize: function() {
- var that = $(this).resizable( "instance" );
- if (that.ghost) {
- that.ghost.css({
+ var that = $( this ).resizable( "instance" );
+ if ( that.ghost ) {
+ that.ghost.css( {
position: "relative",
height: that.size.height,
width: that.size.width
- });
+ } );
}
},
stop: function() {
- var that = $(this).resizable( "instance" );
- if (that.ghost && that.helper) {
- that.helper.get(0).removeChild(that.ghost.get(0));
+ var that = $( this ).resizable( "instance" );
+ if ( that.ghost && that.helper ) {
+ that.helper.get( 0 ).removeChild( that.ghost.get( 0 ) );
}
}
-});
+} );
-$.ui.plugin.add("resizable", "grid", {
+$.ui.plugin.add( "resizable", "grid", {
resize: function() {
var outerDimensions,
- that = $(this).resizable( "instance" ),
+ that = $( this ).resizable( "instance" ),
o = that.options,
cs = that.size,
os = that.originalSize,
op = that.originalPosition,
a = that.axis,
grid = typeof o.grid === "number" ? [ o.grid, o.grid ] : o.grid,
- gridX = (grid[0] || 1),
- gridY = (grid[1] || 1),
- ox = Math.round((cs.width - os.width) / gridX) * gridX,
- oy = Math.round((cs.height - os.height) / gridY) * gridY,
+ gridX = ( grid[ 0 ] || 1 ),
+ gridY = ( grid[ 1 ] || 1 ),
+ ox = Math.round( ( cs.width - os.width ) / gridX ) * gridX,
+ oy = Math.round( ( cs.height - os.height ) / gridY ) * gridY,
newWidth = os.width + ox,
newHeight = os.height + oy,
- isMaxWidth = o.maxWidth && (o.maxWidth < newWidth),
- isMaxHeight = o.maxHeight && (o.maxHeight < newHeight),
- isMinWidth = o.minWidth && (o.minWidth > newWidth),
- isMinHeight = o.minHeight && (o.minHeight > newHeight);
+ isMaxWidth = o.maxWidth && ( o.maxWidth < newWidth ),
+ isMaxHeight = o.maxHeight && ( o.maxHeight < newHeight ),
+ isMinWidth = o.minWidth && ( o.minWidth > newWidth ),
+ isMinHeight = o.minHeight && ( o.minHeight > newHeight );
o.grid = grid;
- if (isMinWidth) {
+ if ( isMinWidth ) {
newWidth += gridX;
}
- if (isMinHeight) {
+ if ( isMinHeight ) {
newHeight += gridY;
}
- if (isMaxWidth) {
+ if ( isMaxWidth ) {
newWidth -= gridX;
}
- if (isMaxHeight) {
+ if ( isMaxHeight ) {
newHeight -= gridY;
}
- if (/^(se|s|e)$/.test(a)) {
+ if ( /^(se|s|e)$/.test( a ) ) {
that.size.width = newWidth;
that.size.height = newHeight;
- } else if (/^(ne)$/.test(a)) {
+ } else if ( /^(ne)$/.test( a ) ) {
that.size.width = newWidth;
that.size.height = newHeight;
that.position.top = op.top - oy;
- } else if (/^(sw)$/.test(a)) {
+ } else if ( /^(sw)$/.test( a ) ) {
that.size.width = newWidth;
that.size.height = newHeight;
that.position.left = op.left - ox;
} else {
- if ( newHeight - gridY <= 0 || newWidth - gridX <= 0) {
+ if ( newHeight - gridY <= 0 || newWidth - gridX <= 0 ) {
outerDimensions = that._getPaddingPlusBorderDimensions( this );
}
@@ -1161,8 +1163,8 @@ $.ui.plugin.add("resizable", "grid", {
}
}
-});
+} );
return $.ui.resizable;
-}));
+} ) );
diff --git a/ui/widgets/selectable.js b/ui/widgets/selectable.js
index 4edf46ad6..152729d7c 100644
--- a/ui/widgets/selectable.js
+++ b/ui/widgets/selectable.js
@@ -14,11 +14,11 @@
//>>demos: http://jqueryui.com/selectable/
//>>css.structure: ../themes/base/selectable.css
-(function( factory ) {
+( function( factory ) {
if ( typeof define === "function" && define.amd ) {
// AMD. Register as an anonymous module.
- define([
+ define( [
"jquery",
"./mouse",
"../version",
@@ -29,9 +29,9 @@
// Browser globals
factory( jQuery );
}
-}(function( $ ) {
+}( function( $ ) {
-return $.widget("ui.selectable", $.ui.mouse, {
+return $.widget( "ui.selectable", $.ui.mouse, {
version: "@VERSION",
options: {
appendTo: "body",
@@ -40,7 +40,7 @@ return $.widget("ui.selectable", $.ui.mouse, {
filter: "*",
tolerance: "touch",
- // callbacks
+ // Callbacks
selected: null,
selecting: null,
start: null,
@@ -55,14 +55,14 @@ return $.widget("ui.selectable", $.ui.mouse, {
this.dragged = false;
- // cache selectee children based on filter
+ // Cache selectee children based on filter
this.refresh = function() {
- that.selectees = $(that.options.filter, that.element[0]);
+ that.selectees = $( that.options.filter, that.element[ 0 ] );
that._addClass( that.selectees, "ui-selectee" );
- that.selectees.each(function() {
- var $this = $(this),
+ that.selectees.each( function() {
+ var $this = $( this ),
pos = $this.offset();
- $.data(this, "selectable-item", {
+ $.data( this, "selectable-item", {
element: this,
$element: $this,
left: pos.left,
@@ -70,150 +70,156 @@ return $.widget("ui.selectable", $.ui.mouse, {
right: pos.left + $this.outerWidth(),
bottom: pos.top + $this.outerHeight(),
startselected: false,
- selected: $this.hasClass("ui-selected"),
- selecting: $this.hasClass("ui-selecting"),
- unselecting: $this.hasClass("ui-unselecting")
- });
- });
+ selected: $this.hasClass( "ui-selected" ),
+ selecting: $this.hasClass( "ui-selecting" ),
+ unselecting: $this.hasClass( "ui-unselecting" )
+ } );
+ } );
};
this.refresh();
this._mouseInit();
- this.helper = $("<div>");
+ this.helper = $( "<div>" );
this._addClass( this.helper, "ui-selectable-helper" );
},
_destroy: function() {
- this.selectees.removeData("selectable-item");
+ this.selectees.removeData( "selectable-item" );
this._mouseDestroy();
},
- _mouseStart: function(event) {
+ _mouseStart: function( event ) {
var that = this,
options = this.options;
this.opos = [ event.pageX, event.pageY ];
- if (this.options.disabled) {
+ if ( this.options.disabled ) {
return;
}
- this.selectees = $(options.filter, this.element[0]);
+ this.selectees = $( options.filter, this.element[ 0 ] );
- this._trigger("start", event);
+ this._trigger( "start", event );
+
+ $( options.appendTo ).append( this.helper );
- $(options.appendTo).append(this.helper);
// position helper (lasso)
- this.helper.css({
+ this.helper.css( {
"left": event.pageX,
"top": event.pageY,
"width": 0,
"height": 0
- });
+ } );
- if (options.autoRefresh) {
+ if ( options.autoRefresh ) {
this.refresh();
}
- this.selectees.filter(".ui-selected").each(function() {
- var selectee = $.data(this, "selectable-item");
+ this.selectees.filter( ".ui-selected" ).each( function() {
+ var selectee = $.data( this, "selectable-item" );
selectee.startselected = true;
- if (!event.metaKey && !event.ctrlKey) {
+ if ( !event.metaKey && !event.ctrlKey ) {
that._removeClass( selectee.$element, "ui-selected" );
selectee.selected = false;
that._addClass( selectee.$element, "ui-unselecting" );
selectee.unselecting = true;
+
// selectable UNSELECTING callback
- that._trigger("unselecting", event, {
+ that._trigger( "unselecting", event, {
unselecting: selectee.element
- });
+ } );
}
- });
+ } );
- $(event.target).parents().addBack().each(function() {
+ $( event.target ).parents().addBack().each( function() {
var doSelect,
- selectee = $.data(this, "selectable-item");
- if (selectee) {
- doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass("ui-selected");
+ selectee = $.data( this, "selectable-item" );
+ if ( selectee ) {
+ doSelect = ( !event.metaKey && !event.ctrlKey ) || !selectee.$element.hasClass( "ui-selected" );
that._removeClass( selectee.$element, doSelect ? "ui-unselecting" : "ui-selected" )
._addClass( selectee.$element, doSelect ? "ui-selecting" : "ui-unselecting" );
selectee.unselecting = !doSelect;
selectee.selecting = doSelect;
selectee.selected = doSelect;
+
// selectable (UN)SELECTING callback
- if (doSelect) {
- that._trigger("selecting", event, {
+ if ( doSelect ) {
+ that._trigger( "selecting", event, {
selecting: selectee.element
- });
+ } );
} else {
- that._trigger("unselecting", event, {
+ that._trigger( "unselecting", event, {
unselecting: selectee.element
- });
+ } );
}
return false;
}
- });
+ } );
},
- _mouseDrag: function(event) {
+ _mouseDrag: function( event ) {
this.dragged = true;
- if (this.options.disabled) {
+ if ( this.options.disabled ) {
return;
}
var tmp,
that = this,
options = this.options,
- x1 = this.opos[0],
- y1 = this.opos[1],
+ x1 = this.opos[ 0 ],
+ y1 = this.opos[ 1 ],
x2 = event.pageX,
y2 = event.pageY;
- if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; }
- if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; }
- this.helper.css({ left: x1, top: y1, width: x2 - x1, height: y2 - y1 });
+ if ( x1 > x2 ) { tmp = x2; x2 = x1; x1 = tmp; }
+ if ( y1 > y2 ) { tmp = y2; y2 = y1; y1 = tmp; }
+ this.helper.css( { left: x1, top: y1, width: x2 - x1, height: y2 - y1 } );
- this.selectees.each(function() {
- var selectee = $.data(this, "selectable-item"),
+ this.selectees.each( function() {
+ var selectee = $.data( this, "selectable-item" ),
hit = false;
//prevent helper from being selected if appendTo: selectable
- if (!selectee || selectee.element === that.element[0]) {
+ if ( !selectee || selectee.element === that.element[ 0 ] ) {
return;
}
- if (options.tolerance === "touch") {
- hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
- } else if (options.tolerance === "fit") {
- hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
+ if ( options.tolerance === "touch" ) {
+ hit = ( !( selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1 ) );
+ } else if ( options.tolerance === "fit" ) {
+ hit = ( selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2 );
}
- if (hit) {
+ if ( hit ) {
+
// SELECT
- if (selectee.selected) {
+ if ( selectee.selected ) {
that._removeClass( selectee.$element, "ui-selected" );
selectee.selected = false;
}
- if (selectee.unselecting) {
+ if ( selectee.unselecting ) {
that._removeClass( selectee.$element, "ui-unselecting" );
selectee.unselecting = false;
}
- if (!selectee.selecting) {
+ if ( !selectee.selecting ) {
that._addClass( selectee.$element, "ui-selecting" );
selectee.selecting = true;
+
// selectable SELECTING callback
- that._trigger("selecting", event, {
+ that._trigger( "selecting", event, {
selecting: selectee.element
- });
+ } );
}
} else {
+
// UNSELECT
- if (selectee.selecting) {
- if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
+ if ( selectee.selecting ) {
+ if ( ( event.metaKey || event.ctrlKey ) && selectee.startselected ) {
that._removeClass( selectee.$element, "ui-selecting" );
selectee.selecting = false;
that._addClass( selectee.$element, "ui-selected" );
@@ -221,67 +227,69 @@ return $.widget("ui.selectable", $.ui.mouse, {
} else {
that._removeClass( selectee.$element, "ui-selecting" );
selectee.selecting = false;
- if (selectee.startselected) {
+ if ( selectee.startselected ) {
that._addClass( selectee.$element, "ui-unselecting" );
selectee.unselecting = true;
}
+
// selectable UNSELECTING callback
- that._trigger("unselecting", event, {
+ that._trigger( "unselecting", event, {
unselecting: selectee.element
- });
+ } );
}
}
- if (selectee.selected) {
- if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
+ if ( selectee.selected ) {
+ if ( !event.metaKey && !event.ctrlKey && !selectee.startselected ) {
that._removeClass( selectee.$element, "ui-selected" );
selectee.selected = false;
that._addClass( selectee.$element, "ui-unselecting" );
selectee.unselecting = true;
+
// selectable UNSELECTING callback
- that._trigger("unselecting", event, {
+ that._trigger( "unselecting", event, {
unselecting: selectee.element
- });
+ } );
}
}
}
- });
+ } );
return false;
},
- _mouseStop: function(event) {
+ _mouseStop: function( event ) {
var that = this;
this.dragged = false;
- $(".ui-unselecting", this.element[0]).each(function() {
- var selectee = $.data(this, "selectable-item");
+ $( ".ui-unselecting", this.element[ 0 ] ).each( function() {
+ var selectee = $.data( this, "selectable-item" );
that._removeClass( selectee.$element, "ui-unselecting" );
selectee.unselecting = false;
selectee.startselected = false;
- that._trigger("unselected", event, {
+ that._trigger( "unselected", event, {
unselected: selectee.element
- });
- });
- $(".ui-selecting", this.element[0]).each(function() {
- var selectee = $.data(this, "selectable-item");
+ } );
+ } );
+ $( ".ui-selecting", this.element[ 0 ] ).each( function() {
+ var selectee = $.data( this, "selectable-item" );
that._removeClass( selectee.$element, "ui-selecting" )
._addClass( selectee.$element, "ui-selected" );
selectee.selecting = false;
selectee.selected = true;
selectee.startselected = true;
- that._trigger("selected", event, {
+ that._trigger( "selected", event, {
selected: selectee.element
- });
- });
- this._trigger("stop", event);
+ } );
+ } );
+ this._trigger( "stop", event );
this.helper.remove();
return false;
}
-});
+} );
-}));
+} ) );
diff --git a/ui/widgets/selectmenu.js b/ui/widgets/selectmenu.js
index bf415a826..30d8c71af 100644
--- a/ui/widgets/selectmenu.js
+++ b/ui/widgets/selectmenu.js
@@ -58,7 +58,7 @@ return $.widget( "ui.selectmenu", {
},
width: false,
- // callbacks
+ // Callbacks
change: null,
close: null,
focus: null,
@@ -79,10 +79,6 @@ return $.widget( "ui.selectmenu", {
this._rendered = false;
this.menuItems = $();
-
- if ( this.options.disabled ) {
- this.disable();
- }
},
_drawButton: function() {
@@ -169,7 +165,7 @@ return $.widget( "ui.selectmenu", {
select: function( event, ui ) {
event.preventDefault();
- // support: IE8
+ // Support: IE8
// If the item was selected via a click, the text selection
// will be destroyed in IE
that._setSelection();
@@ -410,12 +406,12 @@ return $.widget( "ui.selectmenu", {
selection.removeAllRanges();
selection.addRange( this.range );
- // support: IE8
+ // Support: IE8
} else {
this.range.select();
}
- // support: IE
+ // Support: IE
// Setting the text selection kills the button focus in IE, but
// restoring the focus doesn't kill the selection.
this.button.focus();
@@ -446,7 +442,7 @@ return $.widget( "ui.selectmenu", {
this.range = selection.getRangeAt( 0 );
}
- // support: IE8
+ // Support: IE8
} else {
this.range = document.selection.createRange();
}
@@ -562,25 +558,27 @@ return $.widget( "ui.selectmenu", {
this.menuWrap.appendTo( this._appendTo() );
}
- if ( key === "disabled" ) {
- this.menuInstance.option( "disabled", value );
- this.button.attr( "aria-disabled", value );
- this._toggleClass( this.button, null, "ui-state-disabled", value );
-
- this.element.prop( "disabled", value );
- if ( value ) {
- this.button.attr( "tabindex", -1 );
- this.close();
- } else {
- this.button.attr( "tabindex", 0 );
- }
- }
-
if ( key === "width" ) {
this._resizeButton();
}
},
+ _setOptionDisabled: function( value ) {
+ this._super( value );
+
+ this.menuInstance.option( "disabled", value );
+ this.button.attr( "aria-disabled", value );
+ this._toggleClass( this.button, null, "ui-state-disabled", value );
+
+ this.element.prop( "disabled", value );
+ if ( value ) {
+ this.button.attr( "tabindex", -1 );
+ this.close();
+ } else {
+ this.button.attr( "tabindex", 0 );
+ }
+ },
+
_appendTo: function() {
var element = this.options.appendTo;
@@ -638,7 +636,7 @@ return $.widget( "ui.selectmenu", {
this.menu.outerWidth( Math.max(
this.button.outerWidth(),
- // support: IE10
+ // Support: IE10
// IE10 wraps long text (possibly a rounding bug)
// so we add 1px to avoid the wrapping
this.menu.width( "" ).outerWidth() + 1
@@ -646,7 +644,11 @@ return $.widget( "ui.selectmenu", {
},
_getCreateOptions: function() {
- return { disabled: this.element.prop( "disabled" ) };
+ var options = this._super();
+
+ options.disabled = this.element.prop( "disabled" );
+
+ return options;
},
_parseOptions: function( options ) {
diff --git a/ui/widgets/slider.js b/ui/widgets/slider.js
index 1ab319ebb..8b8a7292a 100644
--- a/ui/widgets/slider.js
+++ b/ui/widgets/slider.js
@@ -16,11 +16,11 @@
//>>css.structure: ../themes/base/slider.css
//>>css.theme: ../themes/base/theme.css
-(function( factory ) {
+( function( factory ) {
if ( typeof define === "function" && define.amd ) {
// AMD. Register as an anonymous module.
- define([
+ define( [
"jquery",
"./mouse",
"../keycode",
@@ -32,7 +32,7 @@
// Browser globals
factory( jQuery );
}
-}(function( $ ) {
+}( function( $ ) {
return $.widget( "ui.slider", $.ui.mouse, {
version: "@VERSION",
@@ -57,14 +57,14 @@ return $.widget( "ui.slider", $.ui.mouse, {
value: 0,
values: null,
- // callbacks
+ // Callbacks
change: null,
slide: null,
start: null,
stop: null
},
- // number of pages in a slider
+ // Number of pages in a slider
// (how many times can you page up/down to go through the whole range)
numPages: 5,
@@ -81,7 +81,6 @@ return $.widget( "ui.slider", $.ui.mouse, {
"ui-widget ui-widget-content" );
this._refresh();
- this._setOption( "disabled", this.options.disabled );
this._animateOff = false;
},
@@ -117,9 +116,9 @@ return $.widget( "ui.slider", $.ui.mouse, {
this.handle = this.handles.eq( 0 );
- this.handles.each(function( i ) {
+ this.handles.each( function( i ) {
$( this ).data( "ui-slider-handle-index", i );
- });
+ } );
},
_createRange: function() {
@@ -130,9 +129,9 @@ return $.widget( "ui.slider", $.ui.mouse, {
if ( !options.values ) {
options.values = [ this._valueMin(), this._valueMin() ];
} else if ( options.values.length && options.values.length !== 2 ) {
- options.values = [ options.values[0], options.values[0] ];
+ options.values = [ options.values[ 0 ], options.values[ 0 ] ];
} else if ( $.isArray( options.values ) ) {
- options.values = options.values.slice(0);
+ options.values = options.values.slice( 0 );
}
}
@@ -145,10 +144,10 @@ return $.widget( "ui.slider", $.ui.mouse, {
this._removeClass( this.range, "ui-slider-range-min ui-slider-range-max" );
// Handle range switching from true to min/max
- this.range.css({
+ this.range.css( {
"left": "",
"bottom": ""
- });
+ } );
}
if ( options.range === "min" || options.range === "max" ) {
this._addClass( this.range, "ui-slider-range-" + options.range );
@@ -195,16 +194,16 @@ return $.widget( "ui.slider", $.ui.mouse, {
position = { x: event.pageX, y: event.pageY };
normValue = this._normValueFromMouse( position );
distance = this._valueMax() - this._valueMin() + 1;
- this.handles.each(function( i ) {
- var thisDistance = Math.abs( normValue - that.values(i) );
- if (( distance > thisDistance ) ||
+ this.handles.each( function( i ) {
+ var thisDistance = Math.abs( normValue - that.values( i ) );
+ if ( ( distance > thisDistance ) ||
( distance === thisDistance &&
- (i === that._lastChangedValue || that.values(i) === o.min ))) {
+ ( i === that._lastChangedValue || that.values( i ) === o.min ) ) ) {
distance = thisDistance;
closestHandle = $( this );
index = i;
}
- });
+ } );
allowed = this._start( event, index );
if ( allowed === false ) {
@@ -223,9 +222,9 @@ return $.widget( "ui.slider", $.ui.mouse, {
left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
top: event.pageY - offset.top -
( closestHandle.height() / 2 ) -
- ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
- ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
- ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
+ ( parseInt( closestHandle.css( "borderTopWidth" ), 10 ) || 0 ) -
+ ( parseInt( closestHandle.css( "borderBottomWidth" ), 10 ) || 0 ) +
+ ( parseInt( closestHandle.css( "marginTop" ), 10 ) || 0 )
};
if ( !this.handles.hasClass( "ui-state-hover" ) ) {
@@ -361,6 +360,7 @@ return $.widget( "ui.slider", $.ui.mouse, {
_change: function( event, index ) {
if ( !this._keySliding && !this._mouseSliding ) {
+
//store the last changed value index for reference when handles overlap
this._lastChangedValue = index;
this._trigger( "change", event, this._uiHash( index ) );
@@ -429,10 +429,6 @@ return $.widget( "ui.slider", $.ui.mouse, {
valsLength = this.options.values.length;
}
- if ( key === "disabled" ) {
- this._toggleClass( null, "ui-state-disabled", !!value );
- }
-
this._super( key, value );
switch ( key ) {
@@ -480,6 +476,12 @@ return $.widget( "ui.slider", $.ui.mouse, {
}
},
+ _setOptionDisabled: function( value ) {
+ this._super( value );
+
+ this._toggleClass( null, "ui-state-disabled", !!value );
+ },
+
//internal value getter
// _value() returns value trimmed by min and max, aligned by step
_value: function() {
@@ -503,10 +505,11 @@ return $.widget( "ui.slider", $.ui.mouse, {
return val;
} else if ( this._hasMultipleValues() ) {
+
// .slice() creates a copy of the array
// this copy gets trimmed by min and max and then returned
vals = this.options.values.slice();
- for ( i = 0; i < vals.length; i += 1) {
+ for ( i = 0; i < vals.length; i += 1 ) {
vals[ i ] = this._trimAlignValue( vals[ i ] );
}
@@ -516,7 +519,7 @@ return $.widget( "ui.slider", $.ui.mouse, {
}
},
- // returns the step-aligned value that val is closest to, between (inclusive) min and max
+ // Returns the step-aligned value that val is closest to, between (inclusive) min and max
_trimAlignValue: function( val ) {
if ( val <= this._valueMin() ) {
return this._valueMin();
@@ -525,16 +528,16 @@ return $.widget( "ui.slider", $.ui.mouse, {
return this._valueMax();
}
var step = ( this.options.step > 0 ) ? this.options.step : 1,
- valModStep = (val - this._valueMin()) % step,
+ valModStep = ( val - this._valueMin() ) % step,
alignValue = val - valModStep;
- if ( Math.abs(valModStep) * 2 >= step ) {
+ if ( Math.abs( valModStep ) * 2 >= step ) {
alignValue += ( valModStep > 0 ) ? step : ( -step );
}
// Since JavaScript has problems with large floats, round
// the final value to 5 digits after the decimal point (see #4124)
- return parseFloat( alignValue.toFixed(5) );
+ return parseFloat( alignValue.toFixed( 5 ) );
},
_calculateNewMax: function() {
@@ -568,7 +571,7 @@ return $.widget( "ui.slider", $.ui.mouse, {
return this.max;
},
- _refreshRange: function ( orientation ) {
+ _refreshRange: function( orientation ) {
if ( orientation === "vertical" ) {
this.range.css( { "width": "", "left": "" } );
}
@@ -586,8 +589,8 @@ return $.widget( "ui.slider", $.ui.mouse, {
_set = {};
if ( this._hasMultipleValues() ) {
- this.handles.each(function( i ) {
- valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
+ this.handles.each( function( i ) {
+ 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 ( that.options.range === true ) {
@@ -608,7 +611,7 @@ return $.widget( "ui.slider", $.ui.mouse, {
}
}
lastValPercent = valPercent;
- });
+ } );
} else {
value = this.value();
valueMin = this._valueMin();
@@ -681,7 +684,7 @@ return $.widget( "ui.slider", $.ui.mouse, {
break;
case $.ui.keyCode.PAGE_DOWN:
newVal = this._trimAlignValue(
- curVal - ( (this._valueMax() - this._valueMin()) / this.numPages ) );
+ curVal - ( ( this._valueMax() - this._valueMin() ) / this.numPages ) );
break;
case $.ui.keyCode.UP:
case $.ui.keyCode.RIGHT:
@@ -712,6 +715,6 @@ return $.widget( "ui.slider", $.ui.mouse, {
}
}
}
-});
+} );
-}));
+} ) );
diff --git a/ui/widgets/sortable.js b/ui/widgets/sortable.js
index 1d384a80e..423bb81f8 100644
--- a/ui/widgets/sortable.js
+++ b/ui/widgets/sortable.js
@@ -14,11 +14,11 @@
//>>demos: http://jqueryui.com/sortable/
//>>css.structure: ../themes/base/sortable.css
-(function( factory ) {
+( function( factory ) {
if ( typeof define === "function" && define.amd ) {
// AMD. Register as an anonymous module.
- define([
+ define( [
"jquery",
"./mouse",
"../data",
@@ -32,9 +32,9 @@
// Browser globals
factory( jQuery );
}
-}(function( $ ) {
+}( function( $ ) {
-return $.widget("ui.sortable", $.ui.mouse, {
+return $.widget( "ui.sortable", $.ui.mouse, {
version: "@VERSION",
widgetEventPrefix: "sort",
ready: false,
@@ -62,7 +62,7 @@ return $.widget("ui.sortable", $.ui.mouse, {
tolerance: "intersect",
zIndex: 1000,
- // callbacks
+ // Callbacks
activate: null,
beforeStop: null,
change: null,
@@ -82,7 +82,7 @@ return $.widget("ui.sortable", $.ui.mouse, {
},
_isFloating: function( item ) {
- return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
+ return ( /left|right/ ).test( item.css( "float" ) ) || ( /inline|table-cell/ ).test( item.css( "display" ) );
},
_create: function() {
@@ -123,56 +123,56 @@ return $.widget("ui.sortable", $.ui.mouse, {
this.item,
"ui-sortable-handle"
);
- });
+ } );
},
_destroy: function() {
this._mouseDestroy();
for ( var i = this.items.length - 1; i >= 0; i-- ) {
- this.items[i].item.removeData(this.widgetName + "-item");
+ this.items[ i ].item.removeData( this.widgetName + "-item" );
}
return this;
},
- _mouseCapture: function(event, overrideHandle) {
+ _mouseCapture: function( event, overrideHandle ) {
var currentItem = null,
validHandle = false,
that = this;
- if (this.reverting) {
+ if ( this.reverting ) {
return false;
}
- if(this.options.disabled || this.options.type === "static") {
+ if ( this.options.disabled || this.options.type === "static" ) {
return false;
}
//We have to refresh the items data once first
- this._refreshItems(event);
+ this._refreshItems( event );
//Find out if the clicked node (or one of its parents) is a actual item in this.items
- $(event.target).parents().each(function() {
- if($.data(this, that.widgetName + "-item") === that) {
- currentItem = $(this);
+ $( event.target ).parents().each( function() {
+ if ( $.data( this, that.widgetName + "-item" ) === that ) {
+ currentItem = $( this );
return false;
}
- });
- if($.data(event.target, that.widgetName + "-item") === that) {
- currentItem = $(event.target);
+ } );
+ if ( $.data( event.target, that.widgetName + "-item" ) === that ) {
+ currentItem = $( event.target );
}
- if(!currentItem) {
+ if ( !currentItem ) {
return false;
}
- if(this.options.handle && !overrideHandle) {
- $(this.options.handle, currentItem).find("*").addBack().each(function() {
- if(this === event.target) {
+ if ( this.options.handle && !overrideHandle ) {
+ $( this.options.handle, currentItem ).find( "*" ).addBack().each( function() {
+ if ( this === event.target ) {
validHandle = true;
}
- });
- if(!validHandle) {
+ } );
+ if ( !validHandle ) {
return false;
}
}
@@ -183,7 +183,7 @@ return $.widget("ui.sortable", $.ui.mouse, {
},
- _mouseStart: function(event, overrideHandle, noActivation) {
+ _mouseStart: function( event, overrideHandle, noActivation ) {
var i, body,
o = this.options;
@@ -194,7 +194,7 @@ return $.widget("ui.sortable", $.ui.mouse, {
this.refreshPositions();
//Create and append the visible helper
- this.helper = this._createHelper(event);
+ this.helper = this._createHelper( event );
//Cache the helper size
this._cacheHelperProportions();
@@ -217,33 +217,33 @@ return $.widget("ui.sortable", $.ui.mouse, {
left: this.offset.left - this.margins.left
};
- $.extend(this.offset, {
+ $.extend( this.offset, {
click: { //Where the click happened, relative to the element
left: event.pageX - this.offset.left,
top: event.pageY - this.offset.top
},
parent: this._getParentOffset(),
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");
+ this.helper.css( "position", "absolute" );
+ this.cssPosition = this.helper.css( "position" );
//Generate the original position
- this.originalPosition = this._generatePosition(event);
+ this.originalPosition = this._generatePosition( event );
this.originalPageX = event.pageX;
this.originalPageY = event.pageY;
//Adjust the mouse offset relative to the helper if "cursorAt" is supplied
- (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
+ ( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) );
//Cache the former DOM position
- this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
+ this.domPosition = { prev: this.currentItem.prev()[ 0 ], parent: this.currentItem.parent()[ 0 ] };
//If the helper is not the original, hide the original so it's not playing any role during the drag, won't cause anything bad this way
- if(this.helper[0] !== this.currentItem[0]) {
+ if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
this.currentItem.hide();
}
@@ -251,141 +251,140 @@ return $.widget("ui.sortable", $.ui.mouse, {
this._createPlaceholder();
//Set a containment if given in the options
- if(o.containment) {
+ if ( o.containment ) {
this._setContainment();
}
- if( o.cursor && o.cursor !== "auto" ) { // cursor option
+ if ( o.cursor && o.cursor !== "auto" ) { // cursor option
body = this.document.find( "body" );
- // support: IE
+ // Support: IE
this.storedCursor = body.css( "cursor" );
body.css( "cursor", o.cursor );
- this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body );
+ this.storedStylesheet = $( "<style>*{ cursor: " + o.cursor + " !important; }</style>" ).appendTo( body );
}
- if(o.opacity) { // opacity option
- if (this.helper.css("opacity")) {
- this._storedOpacity = this.helper.css("opacity");
+ if ( o.opacity ) { // opacity option
+ if ( this.helper.css( "opacity" ) ) {
+ this._storedOpacity = this.helper.css( "opacity" );
}
- this.helper.css("opacity", o.opacity);
+ this.helper.css( "opacity", o.opacity );
}
- if(o.zIndex) { // zIndex option
- if (this.helper.css("zIndex")) {
- this._storedZIndex = this.helper.css("zIndex");
+ if ( o.zIndex ) { // zIndex option
+ if ( this.helper.css( "zIndex" ) ) {
+ this._storedZIndex = this.helper.css( "zIndex" );
}
- this.helper.css("zIndex", o.zIndex);
+ this.helper.css( "zIndex", o.zIndex );
}
//Prepare scrolling
- if(this.scrollParent[0] !== this.document[0] && this.scrollParent[0].tagName !== "HTML") {
+ if ( this.scrollParent[ 0 ] !== this.document[ 0 ] && this.scrollParent[ 0 ].tagName !== "HTML" ) {
this.overflowOffset = this.scrollParent.offset();
}
//Call callbacks
- this._trigger("start", event, this._uiHash());
+ this._trigger( "start", event, this._uiHash() );
//Recache the helper size
- if(!this._preserveHelperProportions) {
+ if ( !this._preserveHelperProportions ) {
this._cacheHelperProportions();
}
-
//Post "activate" events to possible containers
- if( !noActivation ) {
+ if ( !noActivation ) {
for ( i = this.containers.length - 1; i >= 0; i-- ) {
this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
}
}
//Prepare possible droppables
- if($.ui.ddmanager) {
+ if ( $.ui.ddmanager ) {
$.ui.ddmanager.current = this;
}
- if ($.ui.ddmanager && !o.dropBehaviour) {
- $.ui.ddmanager.prepareOffsets(this, event);
+ if ( $.ui.ddmanager && !o.dropBehaviour ) {
+ $.ui.ddmanager.prepareOffsets( this, event );
}
this.dragging = true;
this._addClass( this.helper, "ui-sortable-helper" );
- this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
+ this._mouseDrag( event ); //Execute the drag once - this causes the helper not to be visible before getting its correct position
return true;
},
- _mouseDrag: function(event) {
+ _mouseDrag: function( event ) {
var i, item, itemElement, intersection,
o = this.options,
scrolled = false;
//Compute the helpers position
- this.position = this._generatePosition(event);
- this.positionAbs = this._convertPositionTo("absolute");
+ this.position = this._generatePosition( event );
+ this.positionAbs = this._convertPositionTo( "absolute" );
- if (!this.lastPositionAbs) {
+ if ( !this.lastPositionAbs ) {
this.lastPositionAbs = this.positionAbs;
}
//Do scrolling
- if(this.options.scroll) {
- if(this.scrollParent[0] !== this.document[0] && this.scrollParent[0].tagName !== "HTML") {
+ if ( this.options.scroll ) {
+ if ( this.scrollParent[ 0 ] !== this.document[ 0 ] && this.scrollParent[ 0 ].tagName !== "HTML" ) {
- if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
- this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
- } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
- this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
+ if ( ( this.overflowOffset.top + this.scrollParent[ 0 ].offsetHeight ) - event.pageY < o.scrollSensitivity ) {
+ this.scrollParent[ 0 ].scrollTop = scrolled = this.scrollParent[ 0 ].scrollTop + o.scrollSpeed;
+ } else if ( event.pageY - this.overflowOffset.top < o.scrollSensitivity ) {
+ this.scrollParent[ 0 ].scrollTop = scrolled = this.scrollParent[ 0 ].scrollTop - o.scrollSpeed;
}
- if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
- this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
- } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
- this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
+ if ( ( this.overflowOffset.left + this.scrollParent[ 0 ].offsetWidth ) - event.pageX < o.scrollSensitivity ) {
+ this.scrollParent[ 0 ].scrollLeft = scrolled = this.scrollParent[ 0 ].scrollLeft + o.scrollSpeed;
+ } else if ( event.pageX - this.overflowOffset.left < o.scrollSensitivity ) {
+ this.scrollParent[ 0 ].scrollLeft = scrolled = this.scrollParent[ 0 ].scrollLeft - o.scrollSpeed;
}
} else {
- if(event.pageY - this.document.scrollTop() < o.scrollSensitivity) {
- scrolled = this.document.scrollTop(this.document.scrollTop() - o.scrollSpeed);
- } else if(this.window.height() - (event.pageY - this.document.scrollTop()) < o.scrollSensitivity) {
- scrolled = this.document.scrollTop(this.document.scrollTop() + o.scrollSpeed);
+ if ( event.pageY - this.document.scrollTop() < o.scrollSensitivity ) {
+ scrolled = this.document.scrollTop( this.document.scrollTop() - o.scrollSpeed );
+ } else if ( this.window.height() - ( event.pageY - this.document.scrollTop() ) < o.scrollSensitivity ) {
+ scrolled = this.document.scrollTop( this.document.scrollTop() + o.scrollSpeed );
}
- if(event.pageX - this.document.scrollLeft() < o.scrollSensitivity) {
- scrolled = this.document.scrollLeft(this.document.scrollLeft() - o.scrollSpeed);
- } else if(this.window.width() - (event.pageX - this.document.scrollLeft()) < o.scrollSensitivity) {
- scrolled = this.document.scrollLeft(this.document.scrollLeft() + o.scrollSpeed);
+ if ( event.pageX - this.document.scrollLeft() < o.scrollSensitivity ) {
+ scrolled = this.document.scrollLeft( this.document.scrollLeft() - o.scrollSpeed );
+ } else if ( this.window.width() - ( event.pageX - this.document.scrollLeft() ) < o.scrollSensitivity ) {
+ scrolled = this.document.scrollLeft( this.document.scrollLeft() + o.scrollSpeed );
}
}
- if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
- $.ui.ddmanager.prepareOffsets(this, event);
+ if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) {
+ $.ui.ddmanager.prepareOffsets( this, event );
}
}
//Regenerate the absolute position used for position checks
- this.positionAbs = this._convertPositionTo("absolute");
+ this.positionAbs = this._convertPositionTo( "absolute" );
//Set the helper position
- if(!this.options.axis || this.options.axis !== "y") {
- this.helper[0].style.left = this.position.left+"px";
+ if ( !this.options.axis || this.options.axis !== "y" ) {
+ this.helper[ 0 ].style.left = this.position.left + "px";
}
- if(!this.options.axis || this.options.axis !== "x") {
- this.helper[0].style.top = this.position.top+"px";
+ if ( !this.options.axis || this.options.axis !== "x" ) {
+ this.helper[ 0 ].style.top = this.position.top + "px";
}
//Rearrange
- for (i = this.items.length - 1; i >= 0; i--) {
+ for ( i = this.items.length - 1; i >= 0; i-- ) {
//Cache variables and intersection, continue if no intersection
- item = this.items[i];
- itemElement = item.item[0];
- intersection = this._intersectsWithPointer(item);
- if (!intersection) {
+ item = this.items[ i ];
+ itemElement = item.item[ 0 ];
+ intersection = this._intersectsWithPointer( item );
+ if ( !intersection ) {
continue;
}
@@ -396,77 +395,77 @@ return $.widget("ui.sortable", $.ui.mouse, {
//
// Without this, moving items in "sub-sortables" can cause
// the placeholder to jitter between the outer and inner container.
- if (item.instance !== this.currentContainer) {
+ if ( item.instance !== this.currentContainer ) {
continue;
}
- // cannot intersect with itself
+ // Cannot intersect with itself
// no useless actions that have been done before
// no action if the item moved is the parent of the item checked
- if (itemElement !== this.currentItem[0] &&
- this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
- !$.contains(this.placeholder[0], itemElement) &&
- (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
+ if ( itemElement !== this.currentItem[ 0 ] &&
+ this.placeholder[ intersection === 1 ? "next" : "prev" ]()[ 0 ] !== itemElement &&
+ !$.contains( this.placeholder[ 0 ], itemElement ) &&
+ ( this.options.type === "semi-dynamic" ? !$.contains( this.element[ 0 ], itemElement ) : true )
) {
this.direction = intersection === 1 ? "down" : "up";
- if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
- this._rearrange(event, item);
+ if ( this.options.tolerance === "pointer" || this._intersectsWithSides( item ) ) {
+ this._rearrange( event, item );
} else {
break;
}
- this._trigger("change", event, this._uiHash());
+ this._trigger( "change", event, this._uiHash() );
break;
}
}
//Post events to containers
- this._contactContainers(event);
+ this._contactContainers( event );
//Interconnect with droppables
- if($.ui.ddmanager) {
- $.ui.ddmanager.drag(this, event);
+ if ( $.ui.ddmanager ) {
+ $.ui.ddmanager.drag( this, event );
}
//Call callbacks
- this._trigger("sort", event, this._uiHash());
+ this._trigger( "sort", event, this._uiHash() );
this.lastPositionAbs = this.positionAbs;
return false;
},
- _mouseStop: function(event, noPropagation) {
+ _mouseStop: function( event, noPropagation ) {
- if(!event) {
+ if ( !event ) {
return;
}
//If we are using droppables, inform the manager about the drop
- if ($.ui.ddmanager && !this.options.dropBehaviour) {
- $.ui.ddmanager.drop(this, event);
+ if ( $.ui.ddmanager && !this.options.dropBehaviour ) {
+ $.ui.ddmanager.drop( this, event );
}
- if(this.options.revert) {
+ if ( this.options.revert ) {
var that = this,
cur = this.placeholder.offset(),
axis = this.options.axis,
animation = {};
if ( !axis || axis === "x" ) {
- animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === this.document[0].body ? 0 : this.offsetParent[0].scrollLeft);
+ animation.left = cur.left - this.offset.parent.left - this.margins.left + ( this.offsetParent[ 0 ] === this.document[ 0 ].body ? 0 : this.offsetParent[ 0 ].scrollLeft );
}
if ( !axis || axis === "y" ) {
- animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === this.document[0].body ? 0 : this.offsetParent[0].scrollTop);
+ animation.top = cur.top - this.offset.parent.top - this.margins.top + ( this.offsetParent[ 0 ] === this.document[ 0 ].body ? 0 : this.offsetParent[ 0 ].scrollTop );
}
this.reverting = true;
- $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
- that._clear(event);
- });
+ $( this.helper ).animate( animation, parseInt( this.options.revert, 10 ) || 500, function() {
+ that._clear( event );
+ } );
} else {
- this._clear(event, noPropagation);
+ this._clear( event, noPropagation );
}
return false;
@@ -475,11 +474,11 @@ return $.widget("ui.sortable", $.ui.mouse, {
cancel: function() {
- if(this.dragging) {
+ if ( this.dragging ) {
- this._mouseUp({ target: null });
+ this._mouseUp( { target: null } );
- if(this.options.helper === "original") {
+ if ( this.options.helper === "original" ) {
this.currentItem.css( this._storedCSS );
this._removeClass( this.currentItem, "ui-sortable-helper" );
} else {
@@ -487,36 +486,37 @@ return $.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, this._uiHash(this));
- if(this.containers[i].containerCache.over) {
- this.containers[i]._trigger("out", null, this._uiHash(this));
- this.containers[i].containerCache.over = 0;
+ for ( var i = this.containers.length - 1; i >= 0; i-- ) {
+ this.containers[ i ]._trigger( "deactivate", null, this._uiHash( this ) );
+ if ( this.containers[ i ].containerCache.over ) {
+ this.containers[ i ]._trigger( "out", null, this._uiHash( this ) );
+ this.containers[ i ].containerCache.over = 0;
}
}
}
- if (this.placeholder) {
+ if ( this.placeholder ) {
+
//$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
- if(this.placeholder[0].parentNode) {
- this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
+ if ( this.placeholder[ 0 ].parentNode ) {
+ this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] );
}
- if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
+ if ( this.options.helper !== "original" && this.helper && this.helper[ 0 ].parentNode ) {
this.helper.remove();
}
- $.extend(this, {
+ $.extend( this, {
helper: null,
dragging: false,
reverting: false,
_noFinalSort: null
- });
+ } );
- if(this.domPosition.prev) {
- $(this.domPosition.prev).after(this.currentItem);
+ if ( this.domPosition.prev ) {
+ $( this.domPosition.prev ).after( this.currentItem );
} else {
- $(this.domPosition.parent).prepend(this.currentItem);
+ $( this.domPosition.parent ).prepend( this.currentItem );
}
}
@@ -524,41 +524,41 @@ return $.widget("ui.sortable", $.ui.mouse, {
},
- serialize: function(o) {
+ serialize: function( o ) {
- var items = this._getItemsAsjQuery(o && o.connected),
+ var items = this._getItemsAsjQuery( o && o.connected ),
str = [];
o = o || {};
- $(items).each(function() {
- var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/));
- if (res) {
- str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2]));
+ $( items ).each( function() {
+ var res = ( $( o.item || this ).attr( o.attribute || "id" ) || "" ).match( o.expression || ( /(.+)[\-=_](.+)/ ) );
+ if ( res ) {
+ str.push( ( o.key || res[ 1 ] + "[]" ) + "=" + ( o.key && o.expression ? res[ 1 ] : res[ 2 ] ) );
}
- });
+ } );
- if(!str.length && o.key) {
- str.push(o.key + "=");
+ if ( !str.length && o.key ) {
+ str.push( o.key + "=" );
}
- return str.join("&");
+ return str.join( "&" );
},
- toArray: function(o) {
+ toArray: function( o ) {
- var items = this._getItemsAsjQuery(o && o.connected),
+ var items = this._getItemsAsjQuery( o && o.connected ),
ret = [];
o = o || {};
- items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); });
+ items.each( function() { ret.push( $( o.item || this ).attr( o.attribute || "id" ) || "" ); } );
return ret;
},
/* Be careful with the following core functions */
- _intersectsWith: function(item) {
+ _intersectsWith: function( item ) {
var x1 = this.positionAbs.left,
x2 = x1 + this.helperProportions.width,
@@ -576,27 +576,27 @@ return $.widget("ui.sortable", $.ui.mouse, {
if ( this.options.tolerance === "pointer" ||
this.options.forcePointerForContainers ||
- (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"])
+ ( this.options.tolerance !== "pointer" && this.helperProportions[ this.floating ? "width" : "height" ] > item[ this.floating ? "width" : "height" ] )
) {
return isOverElement;
} else {
- return (l < x1 + (this.helperProportions.width / 2) && // Right Half
- x2 - (this.helperProportions.width / 2) < r && // Left Half
- t < y1 + (this.helperProportions.height / 2) && // Bottom Half
- y2 - (this.helperProportions.height / 2) < b ); // Top Half
+ return ( l < x1 + ( this.helperProportions.width / 2 ) && // Right Half
+ x2 - ( this.helperProportions.width / 2 ) < r && // Left Half
+ t < y1 + ( this.helperProportions.height / 2 ) && // Bottom Half
+ y2 - ( this.helperProportions.height / 2 ) < b ); // Top Half
}
},
- _intersectsWithPointer: function(item) {
+ _intersectsWithPointer: function( item ) {
var verticalDirection, horizontalDirection,
- isOverElementHeight = (this.options.axis === "x") || this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
- isOverElementWidth = (this.options.axis === "y") || this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
+ isOverElementHeight = ( this.options.axis === "x" ) || this._isOverAxis( this.positionAbs.top + this.offset.click.top, item.top, item.height ),
+ isOverElementWidth = ( this.options.axis === "y" ) || this._isOverAxis( this.positionAbs.left + this.offset.click.left, item.left, item.width ),
isOverElement = isOverElementHeight && isOverElementWidth;
- if (!isOverElement) {
+ if ( !isOverElement ) {
return false;
}
@@ -604,38 +604,38 @@ return $.widget("ui.sortable", $.ui.mouse, {
horizontalDirection = this._getDragHorizontalDirection();
return this.floating ?
- ( (horizontalDirection === "right" || verticalDirection === "down") ? 2 : 1 )
- : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
+ ( ( horizontalDirection === "right" || verticalDirection === "down" ) ? 2 : 1 )
+ : ( verticalDirection && ( verticalDirection === "down" ? 2 : 1 ) );
},
- _intersectsWithSides: function(item) {
+ _intersectsWithSides: function( item ) {
- var isOverBottomHalf = this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
- isOverRightHalf = this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
+ var isOverBottomHalf = this._isOverAxis( this.positionAbs.top + this.offset.click.top, item.top + ( item.height / 2 ), item.height ),
+ isOverRightHalf = this._isOverAxis( this.positionAbs.left + this.offset.click.left, item.left + ( item.width / 2 ), item.width ),
verticalDirection = this._getDragVerticalDirection(),
horizontalDirection = this._getDragHorizontalDirection();
- if (this.floating && horizontalDirection) {
- return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf));
+ if ( this.floating && horizontalDirection ) {
+ return ( ( horizontalDirection === "right" && isOverRightHalf ) || ( horizontalDirection === "left" && !isOverRightHalf ) );
} else {
- return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf));
+ return verticalDirection && ( ( verticalDirection === "down" && isOverBottomHalf ) || ( verticalDirection === "up" && !isOverBottomHalf ) );
}
},
_getDragVerticalDirection: function() {
var delta = this.positionAbs.top - this.lastPositionAbs.top;
- return delta !== 0 && (delta > 0 ? "down" : "up");
+ return delta !== 0 && ( delta > 0 ? "down" : "up" );
},
_getDragHorizontalDirection: function() {
var delta = this.positionAbs.left - this.lastPositionAbs.left;
- return delta !== 0 && (delta > 0 ? "right" : "left");
+ return delta !== 0 && ( delta > 0 ? "right" : "left" );
},
- refresh: function(event) {
- this._refreshItems(event);
+ refresh: function( event ) {
+ this._refreshItems( event );
this._setHandleClassName();
this.refreshPositions();
return this;
@@ -643,100 +643,100 @@ return $.widget("ui.sortable", $.ui.mouse, {
_connectWith: function() {
var options = this.options;
- return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
+ return options.connectWith.constructor === String ? [ options.connectWith ] : options.connectWith;
},
- _getItemsAsjQuery: function(connected) {
+ _getItemsAsjQuery: function( connected ) {
var i, j, cur, inst,
items = [],
queries = [],
connectWith = this._connectWith();
- if(connectWith && connected) {
- for (i = connectWith.length - 1; i >= 0; i--){
- cur = $(connectWith[i], this.document[0]);
- for ( j = cur.length - 1; j >= 0; j--){
- inst = $.data(cur[j], this.widgetFullName);
- if(inst && inst !== this && !inst.options.disabled) {
- queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), inst]);
+ if ( connectWith && connected ) {
+ for ( i = connectWith.length - 1; i >= 0; i-- ) {
+ cur = $( connectWith[ i ], this.document[ 0 ] );
+ for ( j = cur.length - 1; j >= 0; j-- ) {
+ inst = $.data( cur[ j ], this.widgetFullName );
+ if ( inst && inst !== this && !inst.options.disabled ) {
+ queries.push( [ $.isFunction( inst.options.items ) ? inst.options.items.call( inst.element ) : $( inst.options.items, inst.element ).not( ".ui-sortable-helper" ).not( ".ui-sortable-placeholder" ), inst ] );
}
}
}
}
- queries.push([$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), this]);
+ queries.push( [ $.isFunction( this.options.items ) ? this.options.items.call( this.element, null, { options: this.options, item: this.currentItem } ) : $( this.options.items, this.element ).not( ".ui-sortable-helper" ).not( ".ui-sortable-placeholder" ), this ] );
function addItems() {
items.push( this );
}
- for (i = queries.length - 1; i >= 0; i--){
- queries[i][0].each( addItems );
+ for ( i = queries.length - 1; i >= 0; i-- ) {
+ queries[ i ][ 0 ].each( addItems );
}
- return $(items);
+ return $( items );
},
_removeCurrentsFromItems: function() {
- var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
+ var list = this.currentItem.find( ":data(" + this.widgetName + "-item)" );
- this.items = $.grep(this.items, function (item) {
- for (var j=0; j < list.length; j++) {
- if(list[j] === item.item[0]) {
+ this.items = $.grep( this.items, function( item ) {
+ for ( var j = 0; j < list.length; j++ ) {
+ if ( list[ j ] === item.item[ 0 ] ) {
return false;
}
}
return true;
- });
+ } );
},
- _refreshItems: function(event) {
+ _refreshItems: function( event ) {
this.items = [];
- this.containers = [this];
+ this.containers = [ this ];
var i, j, cur, inst, targetData, _queries, item, queriesLength,
items = this.items,
- queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],
+ queries = [ [ $.isFunction( this.options.items ) ? this.options.items.call( this.element[ 0 ], event, { item: this.currentItem } ) : $( this.options.items, this.element ), this ] ],
connectWith = this._connectWith();
- if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
- for (i = connectWith.length - 1; i >= 0; i--){
- cur = $(connectWith[i], this.document[0]);
- for (j = cur.length - 1; j >= 0; j--){
- inst = $.data(cur[j], this.widgetFullName);
- if(inst && inst !== this && !inst.options.disabled) {
- queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
- this.containers.push(inst);
+ if ( connectWith && this.ready ) { //Shouldn't be run the first time through due to massive slow-down
+ for ( i = connectWith.length - 1; i >= 0; i-- ) {
+ cur = $( connectWith[ i ], this.document[ 0 ] );
+ for ( j = cur.length - 1; j >= 0; j-- ) {
+ inst = $.data( cur[ j ], this.widgetFullName );
+ if ( inst && inst !== this && !inst.options.disabled ) {
+ queries.push( [ $.isFunction( inst.options.items ) ? inst.options.items.call( inst.element[ 0 ], event, { item: this.currentItem } ) : $( inst.options.items, inst.element ), inst ] );
+ this.containers.push( inst );
}
}
}
}
- for (i = queries.length - 1; i >= 0; i--) {
- targetData = queries[i][1];
- _queries = queries[i][0];
+ for ( i = queries.length - 1; i >= 0; i-- ) {
+ targetData = queries[ i ][ 1 ];
+ _queries = queries[ i ][ 0 ];
- for (j=0, queriesLength = _queries.length; j < queriesLength; j++) {
- item = $(_queries[j]);
+ for ( j = 0, queriesLength = _queries.length; j < queriesLength; j++ ) {
+ item = $( _queries[ j ] );
- item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager)
+ item.data( this.widgetName + "-item", targetData ); // Data for target checking (mouse manager)
- items.push({
+ items.push( {
item: item,
instance: targetData,
width: 0, height: 0,
left: 0, top: 0
- });
+ } );
}
}
},
- refreshPositions: function(fast) {
+ refreshPositions: function( fast ) {
// Determine whether items are being displayed horizontally
this.floating = this.items.length ?
@@ -744,23 +744,23 @@ return $.widget("ui.sortable", $.ui.mouse, {
false;
//This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
- if(this.offsetParent && this.helper) {
+ if ( this.offsetParent && this.helper ) {
this.offset.parent = this._getParentOffset();
}
var i, item, t, p;
- for (i = this.items.length - 1; i >= 0; i--){
- item = this.items[i];
+ for ( i = this.items.length - 1; i >= 0; i-- ) {
+ item = this.items[ i ];
//We ignore calculating positions of all connected containers when we're not over them
- if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) {
+ if ( item.instance !== this.currentContainer && this.currentContainer && item.item[ 0 ] !== this.currentItem[ 0 ] ) {
continue;
}
- t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
+ t = this.options.toleranceElement ? $( this.options.toleranceElement, item.item ) : item.item;
- if (!fast) {
+ if ( !fast ) {
item.width = t.outerWidth();
item.height = t.outerHeight();
}
@@ -770,33 +770,33 @@ return $.widget("ui.sortable", $.ui.mouse, {
item.top = p.top;
}
- if(this.options.custom && this.options.custom.refreshContainers) {
- this.options.custom.refreshContainers.call(this);
+ if ( this.options.custom && this.options.custom.refreshContainers ) {
+ this.options.custom.refreshContainers.call( this );
} else {
- for (i = this.containers.length - 1; i >= 0; i--){
- p = this.containers[i].element.offset();
- this.containers[i].containerCache.left = p.left;
- this.containers[i].containerCache.top = p.top;
- this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
- this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
+ for ( i = this.containers.length - 1; i >= 0; i-- ) {
+ p = this.containers[ i ].element.offset();
+ this.containers[ i ].containerCache.left = p.left;
+ this.containers[ i ].containerCache.top = p.top;
+ this.containers[ i ].containerCache.width = this.containers[ i ].element.outerWidth();
+ this.containers[ i ].containerCache.height = this.containers[ i ].element.outerHeight();
}
}
return this;
},
- _createPlaceholder: function(that) {
+ _createPlaceholder: function( that ) {
that = that || this;
var className,
o = that.options;
- if(!o.placeholder || o.placeholder.constructor === String) {
+ if ( !o.placeholder || o.placeholder.constructor === String ) {
className = o.placeholder;
o.placeholder = {
element: function() {
- var nodeName = that.currentItem[0].nodeName.toLowerCase(),
- element = $( "<" + nodeName + ">", that.document[0] );
+ var nodeName = that.currentItem[ 0 ].nodeName.toLowerCase(),
+ element = $( "<" + nodeName + ">", that.document[ 0 ] );
that._addClass( element, "ui-sortable-placeholder",
className || that.currentItem[ 0 ].className )
@@ -819,105 +819,106 @@ return $.widget("ui.sortable", $.ui.mouse, {
return element;
},
- update: function(container, p) {
+ update: function( container, p ) {
// 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
// 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
- if(className && !o.forcePlaceholderSize) {
+ 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(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)); }
+ 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
- that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
+ that.placeholder = $( o.placeholder.element.call( that.element, that.currentItem ) );
//Append it after the actual current item
- that.currentItem.after(that.placeholder);
+ that.currentItem.after( that.placeholder );
//Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
- o.placeholder.update(that, that.placeholder);
+ o.placeholder.update( that, that.placeholder );
},
_createTrPlaceholder: function( sourceTr, targetTr ) {
var that = this;
- sourceTr.children().each(function() {
+ sourceTr.children().each( function() {
$( "<td>&#160;</td>", that.document[ 0 ] )
.attr( "colspan", $( this ).attr( "colspan" ) || 1 )
.appendTo( targetTr );
- });
+ } );
},
- _contactContainers: function(event) {
+ _contactContainers: function( event ) {
var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom, floating, axis,
innermostContainer = null,
innermostIndex = null;
- // get innermost container that intersects with item
- for (i = this.containers.length - 1; i >= 0; i--) {
+ // Get innermost container that intersects with item
+ for ( i = this.containers.length - 1; i >= 0; i-- ) {
- // never consider a container that's located within the item itself
- if($.contains(this.currentItem[0], this.containers[i].element[0])) {
+ // 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 ( this._intersectsWith( this.containers[ i ].containerCache ) ) {
- // 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])) {
+ // 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
- if(this.containers[i].containerCache.over) {
- this.containers[i]._trigger("out", event, this._uiHash(this));
- this.containers[i].containerCache.over = 0;
+ if ( this.containers[ i ].containerCache.over ) {
+ this.containers[ i ]._trigger( "out", event, this._uiHash( this ) );
+ this.containers[ i ].containerCache.over = 0;
}
}
}
- // if no intersecting containers found, return
- if(!innermostContainer) {
+ // 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) {
- if (!this.containers[innermostIndex].containerCache.over) {
- this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
- this.containers[innermostIndex].containerCache.over = 1;
+ // Move the item into the container if it's not there already
+ if ( this.containers.length === 1 ) {
+ if ( !this.containers[ innermostIndex ].containerCache.over ) {
+ this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) );
+ this.containers[ innermostIndex ].containerCache.over = 1;
}
} else {
//When entering a new container, we will find the item with the least distance and append our item near it
dist = 10000;
itemWithLeastDistance = null;
- floating = innermostContainer.floating || this._isFloating(this.currentItem);
+ floating = innermostContainer.floating || this._isFloating( this.currentItem );
posProperty = floating ? "left" : "top";
sizeProperty = floating ? "width" : "height";
axis = floating ? "clientX" : "clientY";
- for (j = this.items.length - 1; j >= 0; j--) {
- if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
+ for ( j = this.items.length - 1; j >= 0; j-- ) {
+ if ( !$.contains( this.containers[ innermostIndex ].element[ 0 ], this.items[ j ].item[ 0 ] ) ) {
continue;
}
- if(this.items[j].item[0] === this.currentItem[0]) {
+ if ( this.items[ j ].item[ 0 ] === this.currentItem[ 0 ] ) {
continue;
}
- cur = this.items[j].item.offset()[posProperty];
+ cur = this.items[ j ].item.offset()[ posProperty ];
nearBottom = false;
if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) {
nearBottom = true;
@@ -926,16 +927,16 @@ return $.widget("ui.sortable", $.ui.mouse, {
if ( Math.abs( event[ axis ] - cur ) < dist ) {
dist = Math.abs( event[ axis ] - cur );
itemWithLeastDistance = this.items[ j ];
- this.direction = nearBottom ? "up": "down";
+ this.direction = nearBottom ? "up" : "down";
}
}
//Check if dropOnEmpty is enabled
- if(!itemWithLeastDistance && !this.options.dropOnEmpty) {
+ if ( !itemWithLeastDistance && !this.options.dropOnEmpty ) {
return;
}
- if(this.currentContainer === this.containers[innermostIndex]) {
+ if ( this.currentContainer === this.containers[ innermostIndex ] ) {
if ( !this.currentContainer.containerCache.over ) {
this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash() );
this.currentContainer.containerCache.over = 1;
@@ -943,70 +944,68 @@ return $.widget("ui.sortable", $.ui.mouse, {
return;
}
- 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));
- 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 ) );
+ this.currentContainer = this.containers[ innermostIndex ];
//Update the placeholder
- this.options.placeholder.update(this.currentContainer, this.placeholder);
+ this.options.placeholder.update( this.currentContainer, this.placeholder );
- this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
- this.containers[innermostIndex].containerCache.over = 1;
+ this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) );
+ this.containers[ innermostIndex ].containerCache.over = 1;
}
-
},
- _createHelper: function(event) {
+ _createHelper: function( event ) {
var o = this.options,
- helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem);
+ helper = $.isFunction( o.helper ) ? $( o.helper.apply( this.element[ 0 ], [ event, this.currentItem ] ) ) : ( o.helper === "clone" ? this.currentItem.clone() : this.currentItem );
//Add the helper to the DOM if that didn't happen already
- if(!helper.parents("body").length) {
- $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
+ if ( !helper.parents( "body" ).length ) {
+ $( o.appendTo !== "parent" ? o.appendTo : this.currentItem[ 0 ].parentNode )[ 0 ].appendChild( helper[ 0 ] );
}
- if(helper[0] === this.currentItem[0]) {
- this._storedCSS = { width: this.currentItem[0].style.width, height: this.currentItem[0].style.height, position: this.currentItem.css("position"), top: this.currentItem.css("top"), left: this.currentItem.css("left") };
+ if ( helper[ 0 ] === this.currentItem[ 0 ] ) {
+ this._storedCSS = { width: this.currentItem[ 0 ].style.width, height: this.currentItem[ 0 ].style.height, position: this.currentItem.css( "position" ), top: this.currentItem.css( "top" ), left: this.currentItem.css( "left" ) };
}
- if(!helper[0].style.width || o.forceHelperSize) {
- helper.width(this.currentItem.width());
+ if ( !helper[ 0 ].style.width || o.forceHelperSize ) {
+ helper.width( this.currentItem.width() );
}
- if(!helper[0].style.height || o.forceHelperSize) {
- helper.height(this.currentItem.height());
+ if ( !helper[ 0 ].style.height || o.forceHelperSize ) {
+ helper.height( this.currentItem.height() );
}
return helper;
},
- _adjustOffsetFromHelper: function(obj) {
- if (typeof obj === "string") {
- obj = obj.split(" ");
+ _adjustOffsetFromHelper: function( obj ) {
+ if ( typeof obj === "string" ) {
+ obj = obj.split( " " );
}
- if ($.isArray(obj)) {
- obj = {left: +obj[0], top: +obj[1] || 0};
+ if ( $.isArray( obj ) ) {
+ obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 };
}
- if ("left" in obj) {
+ if ( "left" in obj ) {
this.offset.click.left = obj.left + this.margins.left;
}
- if ("right" in obj) {
+ if ( "right" in obj ) {
this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
}
- if ("top" in obj) {
+ if ( "top" in obj ) {
this.offset.click.top = obj.top + this.margins.top;
}
- if ("bottom" in obj) {
+ if ( "bottom" in obj ) {
this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
}
},
_getParentOffset: function() {
-
//Get the offsetParent and cache its position
this.offsetParent = this.helper.offsetParent();
var po = this.offsetParent.offset();
@@ -1015,31 +1014,31 @@ return $.widget("ui.sortable", $.ui.mouse, {
// 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
// the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
- if(this.cssPosition === "absolute" && this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) {
+ if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== this.document[ 0 ] && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) {
po.left += this.scrollParent.scrollLeft();
po.top += this.scrollParent.scrollTop();
}
// This needs to be actually done for all browsers, since pageX/pageY includes this information
// with an ugly IE fix
- if( this.offsetParent[0] === this.document[0].body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
+ if ( this.offsetParent[ 0 ] === this.document[ 0 ].body || ( this.offsetParent[ 0 ].tagName && this.offsetParent[ 0 ].tagName.toLowerCase() === "html" && $.ui.ie ) ) {
po = { top: 0, left: 0 };
}
return {
- top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
- left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
+ top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ),
+ left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 )
};
},
_getRelativeOffset: function() {
- if(this.cssPosition === "relative") {
+ if ( this.cssPosition === "relative" ) {
var p = this.currentItem.position();
return {
- top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
- left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
+ top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) + this.scrollParent.scrollTop(),
+ left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) + this.scrollParent.scrollLeft()
};
} else {
return { top: 0, left: 0 };
@@ -1049,8 +1048,8 @@ return $.widget("ui.sortable", $.ui.mouse, {
_cacheMargins: function() {
this.margins = {
- left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
- top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
+ left: ( parseInt( this.currentItem.css( "marginLeft" ), 10 ) || 0 ),
+ top: ( parseInt( this.currentItem.css( "marginTop" ), 10 ) || 0 )
};
},
@@ -1065,72 +1064,72 @@ return $.widget("ui.sortable", $.ui.mouse, {
var ce, co, over,
o = this.options;
- if(o.containment === "parent") {
- o.containment = this.helper[0].parentNode;
+ if ( o.containment === "parent" ) {
+ o.containment = this.helper[ 0 ].parentNode;
}
- if(o.containment === "document" || o.containment === "window") {
+ if ( o.containment === "document" || o.containment === "window" ) {
this.containment = [
0 - this.offset.relative.left - this.offset.parent.left,
0 - this.offset.relative.top - this.offset.parent.top,
o.containment === "document" ? this.document.width() : this.window.width() - this.helperProportions.width - this.margins.left,
- (o.containment === "document" ? this.document.width() : this.window.height() || this.document[0].body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
+ ( o.containment === "document" ? this.document.width() : this.window.height() || this.document[ 0 ].body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
];
}
- if(!(/^(document|window|parent)$/).test(o.containment)) {
- ce = $(o.containment)[0];
- co = $(o.containment).offset();
- over = ($(ce).css("overflow") !== "hidden");
+ if ( !( /^(document|window|parent)$/ ).test( o.containment ) ) {
+ ce = $( o.containment )[ 0 ];
+ co = $( o.containment ).offset();
+ over = ( $( ce ).css( "overflow" ) !== "hidden" );
this.containment = [
- co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
- co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
- co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left,
- co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top
+ co.left + ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( $( ce ).css( "paddingLeft" ), 10 ) || 0 ) - this.margins.left,
+ co.top + ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( $( ce ).css( "paddingTop" ), 10 ) || 0 ) - this.margins.top,
+ co.left + ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) - ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) - ( parseInt( $( ce ).css( "paddingRight" ), 10 ) || 0 ) - this.helperProportions.width - this.margins.left,
+ co.top + ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) - ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) - ( parseInt( $( ce ).css( "paddingBottom" ), 10 ) || 0 ) - this.helperProportions.height - this.margins.top
];
}
},
- _convertPositionTo: function(d, pos) {
+ _convertPositionTo: function( d, pos ) {
- if(!pos) {
+ if ( !pos ) {
pos = this.position;
}
var mod = d === "absolute" ? 1 : -1,
- scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
- scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
+ scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== this.document[ 0 ] && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent,
+ scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );
return {
top: (
pos.top + // The absolute mouse position
this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
- ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
+ ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod )
),
left: (
pos.left + // The absolute mouse position
this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
- ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
+ ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod )
)
};
},
- _generatePosition: function(event) {
+ _generatePosition: function( event ) {
var top, left,
o = this.options,
pageX = event.pageX,
pageY = event.pageY,
- scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
+ scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== this.document[ 0 ] && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent, scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );
// This is another very weird special case that only happens for relative elements:
// 1. If the css position is relative
// 2. and the scroll parent is the document or similar to the offset parent
// we have to refresh the relative offset during the scroll so there are no jumps
- if(this.cssPosition === "relative" && !(this.scrollParent[0] !== this.document[0] && this.scrollParent[0] !== this.offsetParent[0])) {
+ if ( this.cssPosition === "relative" && !( this.scrollParent[ 0 ] !== this.document[ 0 ] && this.scrollParent[ 0 ] !== this.offsetParent[ 0 ] ) ) {
this.offset.relative = this._getRelativeOffset();
}
@@ -1139,29 +1138,29 @@ return $.widget("ui.sortable", $.ui.mouse, {
* Constrain the position to a mix of grid, containment.
*/
- if(this.originalPosition) { //If we are not dragging yet, we won't check for options
+ if ( this.originalPosition ) { //If we are not dragging yet, we won't check for options
- if(this.containment) {
- if(event.pageX - this.offset.click.left < this.containment[0]) {
- pageX = this.containment[0] + this.offset.click.left;
+ if ( this.containment ) {
+ if ( event.pageX - this.offset.click.left < this.containment[ 0 ] ) {
+ pageX = this.containment[ 0 ] + this.offset.click.left;
}
- if(event.pageY - this.offset.click.top < this.containment[1]) {
- pageY = this.containment[1] + this.offset.click.top;
+ if ( event.pageY - this.offset.click.top < this.containment[ 1 ] ) {
+ pageY = this.containment[ 1 ] + this.offset.click.top;
}
- if(event.pageX - this.offset.click.left > this.containment[2]) {
- pageX = this.containment[2] + this.offset.click.left;
+ if ( event.pageX - this.offset.click.left > this.containment[ 2 ] ) {
+ pageX = this.containment[ 2 ] + this.offset.click.left;
}
- if(event.pageY - this.offset.click.top > this.containment[3]) {
- pageY = this.containment[3] + this.offset.click.top;
+ if ( event.pageY - this.offset.click.top > this.containment[ 3 ] ) {
+ pageY = this.containment[ 3 ] + this.offset.click.top;
}
}
- if(o.grid) {
- top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
- pageY = this.containment ? ( (top - this.offset.click.top >= this.containment[1] && top - this.offset.click.top <= this.containment[3]) ? top : ((top - this.offset.click.top >= this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
+ if ( o.grid ) {
+ top = this.originalPageY + Math.round( ( pageY - this.originalPageY ) / o.grid[ 1 ] ) * o.grid[ 1 ];
+ pageY = this.containment ? ( ( top - this.offset.click.top >= this.containment[ 1 ] && top - this.offset.click.top <= this.containment[ 3 ] ) ? top : ( ( top - this.offset.click.top >= this.containment[ 1 ] ) ? top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) : top;
- left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
- pageX = this.containment ? ( (left - this.offset.click.left >= this.containment[0] && left - this.offset.click.left <= this.containment[2]) ? left : ((left - this.offset.click.left >= this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
+ left = this.originalPageX + Math.round( ( pageX - this.originalPageX ) / o.grid[ 0 ] ) * o.grid[ 0 ];
+ pageX = this.containment ? ( ( left - this.offset.click.left >= this.containment[ 0 ] && left - this.offset.click.left <= this.containment[ 2 ] ) ? left : ( ( left - this.offset.click.left >= this.containment[ 0 ] ) ? left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) : left;
}
}
@@ -1172,22 +1171,22 @@ return $.widget("ui.sortable", $.ui.mouse, {
this.offset.click.top - // Click offset (relative to the element)
this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
- ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
+ ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) )
),
left: (
pageX - // The absolute mouse position
this.offset.click.left - // Click offset (relative to the element)
this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
- ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
+ ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) )
)
};
},
- _rearrange: function(event, i, a, hardRefresh) {
+ _rearrange: function( event, i, a, hardRefresh ) {
- a ? a[0].appendChild(this.placeholder[0]) : i.item[0].parentNode.insertBefore(this.placeholder[0], (this.direction === "down" ? i.item[0] : i.item[0].nextSibling));
+ a ? a[ 0 ].appendChild( this.placeholder[ 0 ] ) : i.item[ 0 ].parentNode.insertBefore( this.placeholder[ 0 ], ( this.direction === "down" ? i.item[ 0 ] : i.item[ 0 ].nextSibling ) );
//Various things done here to improve the performance:
// 1. we create a setTimeout, that calls refreshPositions
@@ -1197,17 +1196,18 @@ return $.widget("ui.sortable", $.ui.mouse, {
this.counter = this.counter ? ++this.counter : 1;
var counter = this.counter;
- this._delay(function() {
- if(counter === this.counter) {
- this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
+ this._delay( function() {
+ if ( counter === this.counter ) {
+ this.refreshPositions( !hardRefresh ); //Precompute after each DOM insertion, NOT on mousemove
}
- });
+ } );
},
- _clear: function(event, noPropagation) {
+ _clear: function( event, noPropagation ) {
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 i,
@@ -1215,15 +1215,15 @@ return $.widget("ui.sortable", $.ui.mouse, {
// 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)
- if(!this._noFinalSort && this.currentItem.parent().length) {
- this.placeholder.before(this.currentItem);
+ if ( !this._noFinalSort && this.currentItem.parent().length ) {
+ this.placeholder.before( this.currentItem );
}
this._noFinalSort = null;
- if(this.helper[0] === this.currentItem[0]) {
- for(i in this._storedCSS) {
- if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
- this._storedCSS[i] = "";
+ if ( this.helper[ 0 ] === this.currentItem[ 0 ] ) {
+ for ( i in this._storedCSS ) {
+ if ( this._storedCSS[ i ] === "auto" || this._storedCSS[ i ] === "static" ) {
+ this._storedCSS[ i ] = "";
}
}
this.currentItem.css( this._storedCSS );
@@ -1232,37 +1232,36 @@ return $.widget("ui.sortable", $.ui.mouse, {
this.currentItem.show();
}
- if(this.fromOutside && !noPropagation) {
- delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
+ if ( this.fromOutside && !noPropagation ) {
+ delayedTriggers.push( function( event ) { this._trigger( "receive", event, this._uiHash( this.fromOutside ) ); } );
}
- if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
- delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
+ if ( ( this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not( ".ui-sortable-helper" )[ 0 ] || this.domPosition.parent !== this.currentItem.parent()[ 0 ] ) && !noPropagation ) {
+ delayedTriggers.push( function( event ) { this._trigger( "update", event, this._uiHash() ); } ); //Trigger update callback if the DOM position has changed
}
// Check if the items Container has Changed and trigger appropriate
// events.
- if (this !== this.currentContainer) {
- if(!noPropagation) {
- delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
- delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
- delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
+ if ( this !== this.currentContainer ) {
+ if ( !noPropagation ) {
+ delayedTriggers.push( function( event ) { this._trigger( "remove", event, this._uiHash() ); } );
+ delayedTriggers.push( ( function( c ) { return function( event ) { c._trigger( "receive", event, this._uiHash( this ) ); }; } ).call( this, this.currentContainer ) );
+ delayedTriggers.push( ( function( c ) { return function( event ) { c._trigger( "update", event, this._uiHash( this ) ); }; } ).call( this, this.currentContainer ) );
}
}
-
//Post events to containers
function delayEvent( type, instance, container ) {
return function( event ) {
container._trigger( type, event, instance._uiHash( instance ) );
};
}
- for (i = this.containers.length - 1; i >= 0; i--){
- if (!noPropagation) {
+ for ( i = this.containers.length - 1; i >= 0; i-- ) {
+ if ( !noPropagation ) {
delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
}
- if(this.containers[i].containerCache.over) {
+ if ( this.containers[ i ].containerCache.over ) {
delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
- this.containers[i].containerCache.over = 0;
+ this.containers[ i ].containerCache.over = 0;
}
}
@@ -1271,21 +1270,21 @@ return $.widget("ui.sortable", $.ui.mouse, {
this.document.find( "body" ).css( "cursor", this.storedCursor );
this.storedStylesheet.remove();
}
- if(this._storedOpacity) {
- this.helper.css("opacity", this._storedOpacity);
+ if ( this._storedOpacity ) {
+ this.helper.css( "opacity", this._storedOpacity );
}
- if(this._storedZIndex) {
- this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
+ if ( this._storedZIndex ) {
+ this.helper.css( "zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex );
}
this.dragging = false;
- if(!noPropagation) {
- this._trigger("beforeStop", event, this._uiHash());
+ if ( !noPropagation ) {
+ this._trigger( "beforeStop", event, this._uiHash() );
}
//$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
- this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
+ this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] );
if ( !this.cancelHelperRemoval ) {
if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
@@ -1294,11 +1293,11 @@ return $.widget("ui.sortable", $.ui.mouse, {
this.helper = null;
}
- if(!noPropagation) {
- for (i=0; i < delayedTriggers.length; i++) {
- delayedTriggers[i].call(this, event);
+ if ( !noPropagation ) {
+ for ( i = 0; i < delayedTriggers.length; i++ ) {
+ delayedTriggers[ i ].call( this, event );
} //Trigger all delayed events
- this._trigger("stop", event, this._uiHash());
+ this._trigger( "stop", event, this._uiHash() );
}
this.fromOutside = false;
@@ -1307,16 +1306,16 @@ return $.widget("ui.sortable", $.ui.mouse, {
},
_trigger: function() {
- if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
+ if ( $.Widget.prototype._trigger.apply( this, arguments ) === false ) {
this.cancel();
}
},
- _uiHash: function(_inst) {
+ _uiHash: function( _inst ) {
var inst = _inst || this;
return {
helper: inst.helper,
- placeholder: inst.placeholder || $([]),
+ placeholder: inst.placeholder || $( [] ),
position: inst.position,
originalPosition: inst.originalPosition,
offset: inst.positionAbs,
@@ -1325,6 +1324,6 @@ return $.widget("ui.sortable", $.ui.mouse, {
};
}
-});
+} );
-}));
+} ) );
diff --git a/ui/widgets/spinner.js b/ui/widgets/spinner.js
index bc0535700..f79b2baed 100644
--- a/ui/widgets/spinner.js
+++ b/ui/widgets/spinner.js
@@ -35,7 +35,7 @@
}
}( function( $ ) {
-function spinner_modifier( fn ) {
+function spinnerModifer( fn ) {
return function() {
var previous = this.element.val();
fn.apply( this, arguments );
@@ -75,6 +75,7 @@ $.widget( "ui.spinner", {
},
_create: function() {
+
// handle string values that need to be parsed
this._setOption( "max", this.options.max );
this._setOption( "min", this.options.min );
@@ -83,6 +84,7 @@ $.widget( "ui.spinner", {
// Only format if there is a value, prevents the field from being marked
// as invalid in Firefox, see #9573.
if ( this.value() !== "" ) {
+
// Format the value, but don't constrain.
this._value( this.element.val(), true );
}
@@ -91,7 +93,7 @@ $.widget( "ui.spinner", {
this._on( this._events );
this._refresh();
- // turning off autocomplete prevents the browser from remembering the
+ // Turning off autocomplete prevents the browser from remembering the
// value when navigating through history, so we re-enable autocomplete
// if the page is unloaded before the widget is destroyed. #7790
this._on( this.window, {
@@ -102,8 +104,8 @@ $.widget( "ui.spinner", {
},
_getCreateOptions: function() {
- var options = {},
- element = this.element;
+ var options = this._super();
+ var element = this.element;
$.each( [ "min", "max", "step" ], function( i, option ) {
var value = element.attr( option );
@@ -169,6 +171,7 @@ $.widget( "ui.spinner", {
if ( !isActive ) {
this.element.trigger( "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.
@@ -178,11 +181,11 @@ $.widget( "ui.spinner", {
}
}
- // ensure focus is on (or stays on) the text field
+ // Ensure focus is on (or stays on) the text field
event.preventDefault();
checkFocus.call( this );
- // support: IE
+ // 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.
@@ -200,6 +203,7 @@ $.widget( "ui.spinner", {
},
"mouseup .ui-spinner-button": "_stop",
"mouseenter .ui-spinner-button": function( event ) {
+
// button will add ui-state-active if mouse was down while mouseleave and kept down
if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
return;
@@ -210,6 +214,7 @@ $.widget( "ui.spinner", {
}
this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
},
+
// TODO: do we really want to consider this a stop?
// shouldn't we just stop the repeater and wait until mouseup before
// we trigger the stop event?
@@ -242,7 +247,7 @@ $.widget( "ui.spinner", {
this.element.attr( "role", "spinbutton" );
- // button bindings
+ // Button bindings
this.buttons = this.uiSpinner.children( "a" )
.attr( "tabIndex", -1 )
.button();
@@ -263,11 +268,6 @@ $.widget( "ui.spinner", {
this.uiSpinner.height() > 0 ) {
this.uiSpinner.height( this.uiSpinner.height() );
}
-
- // disable spinner if element was already disabled
- if ( this.options.disabled ) {
- this.disable();
- }
},
_keydown: function( event ) {
@@ -360,19 +360,21 @@ $.widget( "ui.spinner", {
var base, aboveMin,
options = this.options;
- // make sure we're at a valid step
+ // Make sure we're at a valid step
// - find out where we are relative to the base (min or 0)
base = options.min !== null ? options.min : 0;
aboveMin = value - base;
+
// - round to the nearest step
aboveMin = Math.round( aboveMin / options.step ) * options.step;
+
// - rounding is based on 0, so adjust back to our base
value = base + aboveMin;
- // fix precision from bad JS floating point math
+ // Fix precision from bad JS floating point math
value = parseFloat( value.toFixed( this._precision() ) );
- // clamp the value
+ // Clamp the value
if ( options.max !== null && value > options.max ) {
return options.max;
}
@@ -420,15 +422,17 @@ $.widget( "ui.spinner", {
}
this._super( key, value );
+ },
- if ( key === "disabled" ) {
- this._toggleClass( this.uiSpinner, null, "ui-state-disabled", !!value );
- this.element.prop( "disabled", !!value );
- this.buttons.button( value ? "disable" : "enable" );
- }
+ _setOptionDisabled: function( value ) {
+ this._super( value );
+
+ this._toggleClass( this.uiSpinner, null, "ui-state-disabled", !!value );
+ this.element.prop( "disabled", !!value );
+ this.buttons.button( value ? "disable" : "enable" );
},
- _setOptions: spinner_modifier( function( options ) {
+ _setOptions: spinnerModifer( function( options ) {
this._super( options );
} ),
@@ -453,6 +457,7 @@ $.widget( "ui.spinner", {
this.element.attr( {
"aria-valuemin": this.options.min,
"aria-valuemax": this.options.max,
+
// TODO: what should we do with values that can't be parsed?
"aria-valuenow": this._parse( this.element.val() )
} );
@@ -461,16 +466,16 @@ $.widget( "ui.spinner", {
isValid: function() {
var value = this.value();
- // null is invalid
+ // Null is invalid
if ( value === null ) {
return false;
}
- // if value gets adjusted, it's invalid
+ // If value gets adjusted, it's invalid
return value === this._adjustValue( value );
},
- // update the value without triggering change
+ // Update the value without triggering change
_value: function( value, allowAny ) {
var parsed;
if ( value !== "" ) {
@@ -494,7 +499,7 @@ $.widget( "ui.spinner", {
this.uiSpinner.replaceWith( this.element );
},
- stepUp: spinner_modifier( function( steps ) {
+ stepUp: spinnerModifer( function( steps ) {
this._stepUp( steps );
} ),
_stepUp: function( steps ) {
@@ -504,7 +509,7 @@ $.widget( "ui.spinner", {
}
},
- stepDown: spinner_modifier( function( steps ) {
+ stepDown: spinnerModifer( function( steps ) {
this._stepDown( steps );
} ),
_stepDown: function( steps ) {
@@ -514,11 +519,11 @@ $.widget( "ui.spinner", {
}
},
- pageUp: spinner_modifier( function( pages ) {
+ pageUp: spinnerModifer( function( pages ) {
this._stepUp( ( pages || 1 ) * this.options.page );
} ),
- pageDown: spinner_modifier( function( pages ) {
+ pageDown: spinnerModifer( function( pages ) {
this._stepDown( ( pages || 1 ) * this.options.page );
} ),
@@ -526,7 +531,7 @@ $.widget( "ui.spinner", {
if ( !arguments.length ) {
return this._parse( this.element.val() );
}
- spinner_modifier( this._value ).call( this, newVal );
+ spinnerModifer( this._value ).call( this, newVal );
},
widget: function() {
diff --git a/ui/widgets/tabs.js b/ui/widgets/tabs.js
index 0b7bf5850..baece431d 100644
--- a/ui/widgets/tabs.js
+++ b/ui/widgets/tabs.js
@@ -53,7 +53,7 @@ $.widget( "ui.tabs", {
hide: null,
show: null,
- // callbacks
+ // Callbacks
activate: null,
beforeActivate: null,
beforeLoad: null,
@@ -69,7 +69,7 @@ $.widget( "ui.tabs", {
anchorUrl = anchor.href.replace( rhash, "" );
locationUrl = location.href.replace( rhash, "" );
- // decoding may throw an error if the URL isn't UTF-8 (#9518)
+ // Decoding may throw an error if the URL isn't UTF-8 (#9518)
try {
anchorUrl = decodeURIComponent( anchorUrl );
} catch ( error ) {}
@@ -103,7 +103,7 @@ $.widget( "ui.tabs", {
) ).sort();
}
- // check for length avoids error when initializing empty list
+ // Check for length avoids error when initializing empty list
if ( this.options.active !== false && this.anchors.length ) {
this.active = this._findActive( options.active );
} else {
@@ -123,6 +123,7 @@ $.widget( "ui.tabs", {
locationHash = location.hash.substring( 1 );
if ( active === null ) {
+
// check the fragment identifier in the URL
if ( locationHash ) {
this.tabs.each( function( i, tab ) {
@@ -133,18 +134,18 @@ $.widget( "ui.tabs", {
} );
}
- // check for a tab marked active via a class
+ // Check for a tab marked active via a class
if ( active === null ) {
active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
}
- // no active tab, set to false
+ // No active tab, set to false
if ( active === null || active === -1 ) {
active = this.tabs.length ? 0 : false;
}
}
- // handle numbers: negative, out of range
+ // Handle numbers: negative, out of range
if ( active !== false ) {
active = this.tabs.index( this.tabs.eq( active ) );
if ( active === -1 ) {
@@ -152,7 +153,7 @@ $.widget( "ui.tabs", {
}
}
- // don't allow collapsible: false and active: false
+ // Don't allow collapsible: false and active: false
if ( !collapsible && active === false && this.anchors.length ) {
active = 0;
}
@@ -193,15 +194,18 @@ $.widget( "ui.tabs", {
selectedIndex = 0;
break;
case $.ui.keyCode.SPACE:
+
// Activate only, no collapsing
event.preventDefault();
clearTimeout( this.activating );
this._activate( selectedIndex );
return;
case $.ui.keyCode.ENTER:
+
// Toggle (cancel delayed activation, allow collapsing)
event.preventDefault();
clearTimeout( this.activating );
+
// Determine if we should collapse or activate
this._activate( selectedIndex === this.options.active ? false : selectedIndex );
return;
@@ -281,17 +285,12 @@ $.widget( "ui.tabs", {
_setOption: function( key, value ) {
if ( key === "active" ) {
+
// _activate() will handle invalid values and update this.options
this._activate( value );
return;
}
- if ( key === "disabled" ) {
- // don't use the widget factory's disabled handling
- this._setupDisabled( value );
- return;
- }
-
this._super( key, value );
if ( key === "collapsible" ) {
@@ -320,7 +319,7 @@ $.widget( "ui.tabs", {
var options = this.options,
lis = this.tablist.children( ":has(a[href])" );
- // get disabled tabs from class attribute from HTML
+ // Get disabled tabs from class attribute from HTML
// this will get converted to a boolean if needed in _refresh()
options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
return lis.index( tab );
@@ -328,22 +327,27 @@ $.widget( "ui.tabs", {
this._processTabs();
- // was collapsed or no tabs
+ // Was collapsed or no tabs
if ( options.active === false || !this.anchors.length ) {
options.active = false;
this.active = $();
+
// was active, but active tab is gone
} else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
+
// all remaining tabs are disabled
if ( this.tabs.length === options.disabled.length ) {
options.active = false;
this.active = $();
+
// activate previous tab
} else {
this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
}
+
// was active, active tab still exists
} else {
+
// make sure active index is correct
options.active = this.tabs.index( this.active );
}
@@ -352,7 +356,7 @@ $.widget( "ui.tabs", {
},
_refresh: function() {
- this._setupDisabled( this.options.disabled );
+ this._setOptionDisabled( this.options.disabled );
this._setupEvents( this.options.event );
this._setupHeightStyle( this.options.heightStyle );
@@ -404,7 +408,7 @@ $.widget( "ui.tabs", {
}
} )
- // support: IE <9
+ // Support: IE <9
// Preventing the default action in mousedown doesn't prevent IE
// from focusing the element, so if the anchor gets focused, blur.
// We don't have to worry about focusing the previously focused
@@ -440,13 +444,15 @@ $.widget( "ui.tabs", {
tab = $( anchor ).closest( "li" ),
originalAriaControls = tab.attr( "aria-controls" );
- // inline tab
+ // Inline tab
if ( that._isLocal( anchor ) ) {
selector = anchor.hash;
panelId = selector.substring( 1 );
panel = that.element.find( that._sanitizeSelector( selector ) );
+
// remote tab
} else {
+
// If the tab doesn't already have aria-controls,
// generate an id by using a throw-away element
panelId = tab.attr( "aria-controls" ) || $( {} ).uniqueId()[ 0 ].id;
@@ -483,7 +489,7 @@ $.widget( "ui.tabs", {
}
},
- // allow overriding how to find the list for rare usage scenarios (#7715)
+ // Allow overriding how to find the list for rare usage scenarios (#7715)
_getList: function() {
return this.tablist || this.element.find( "ol, ul" ).eq( 0 );
},
@@ -494,7 +500,7 @@ $.widget( "ui.tabs", {
.data( "ui-tabs-destroy", true );
},
- _setupDisabled: function( disabled ) {
+ _setOptionDisabled: function( disabled ) {
var currentItem, li, i;
if ( $.isArray( disabled ) ) {
@@ -505,7 +511,7 @@ $.widget( "ui.tabs", {
}
}
- // disable tabs
+ // Disable tabs
for ( i = 0; ( li = this.tabs[ i ] ); i++ ) {
currentItem = $( li );
if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
@@ -518,6 +524,9 @@ $.widget( "ui.tabs", {
}
this.options.disabled = disabled;
+
+ this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null,
+ disabled === true );
},
_setupEvents: function( event ) {
@@ -529,6 +538,7 @@ $.widget( "ui.tabs", {
}
this._off( this.anchors.add( this.tabs ).add( this.panels ) );
+
// Always prevent the default action, even when disabled
this._on( true, this.anchors, {
click: function( event ) {
@@ -597,12 +607,16 @@ $.widget( "ui.tabs", {
event.preventDefault();
if ( tab.hasClass( "ui-state-disabled" ) ||
+
// tab is already loading
tab.hasClass( "ui-tabs-loading" ) ||
+
// can't switch durning an animation
this.running ||
+
// click on active header, but not collapsible
( clickedIsActive && !options.collapsible ) ||
+
// allow canceling activation
( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
return;
@@ -625,7 +639,7 @@ $.widget( "ui.tabs", {
this._toggle( event, eventData );
},
- // handles show/hide for selecting tabs
+ // Handles show/hide for selecting tabs
_toggle: function( event, eventData ) {
var that = this,
toShow = eventData.newPanel,
@@ -649,7 +663,7 @@ $.widget( "ui.tabs", {
}
}
- // start out by hiding, then showing, then completing
+ // Start out by hiding, then showing, then completing
if ( toHide.length && this.options.hide ) {
this._hide( toHide, this.options.hide, function() {
that._removeClass( eventData.oldTab.closest( "li" ),
@@ -668,6 +682,7 @@ $.widget( "ui.tabs", {
"aria-selected": "false",
"aria-expanded": "false"
} );
+
// If we're switching tabs, remove the old tab from the tab order.
// If we're opening from collapsed state, remove the previous tab from the tab order.
// If we're collapsing, then keep the collapsing tab in the tab order.
@@ -692,12 +707,12 @@ $.widget( "ui.tabs", {
var anchor,
active = this._findActive( index );
- // trying to activate the already active panel
+ // Trying to activate the already active panel
if ( active[ 0 ] === this.active[ 0 ] ) {
return;
}
- // trying to collapse, simulate a click on the current active header
+ // Trying to collapse, simulate a click on the current active header
if ( !active.length ) {
active = this.active;
}
@@ -715,6 +730,7 @@ $.widget( "ui.tabs", {
},
_getIndex: function( index ) {
+
// meta-function to give users option to provide a href string instead of a numerical index.
if ( typeof index === "string" ) {
index = this.anchors.index( this.anchors.filter( "[href$='" + $.ui.escapeSelector( index ) + "']" ) );
@@ -784,7 +800,7 @@ $.widget( "ui.tabs", {
} );
}
}
- this._setupDisabled( disabled );
+ this._setOptionDisabled( disabled );
},
disable: function( index ) {
@@ -806,7 +822,7 @@ $.widget( "ui.tabs", {
disabled = [ index ];
}
}
- this._setupDisabled( disabled );
+ this._setOptionDisabled( disabled );
},
load: function( index, event ) {
@@ -832,14 +848,14 @@ $.widget( "ui.tabs", {
}
};
- // not remote
+ // Not remote
if ( this._isLocal( anchor[ 0 ] ) ) {
return;
}
this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
- // support: jQuery <1.8
+ // Support: jQuery <1.8
// jQuery <1.8 returns false if the request is canceled in beforeSend,
// but as of 1.8, $.ajax() always returns a jqXHR object.
if ( this.xhr && this.xhr.statusText !== "canceled" ) {
@@ -848,6 +864,7 @@ $.widget( "ui.tabs", {
this.xhr
.done( function( response, status, jqXHR ) {
+
// support: jQuery <1.8
// http://bugs.jquery.com/ticket/11778
setTimeout( function() {
@@ -858,6 +875,7 @@ $.widget( "ui.tabs", {
}, 1 );
} )
.fail( function( jqXHR, status ) {
+
// support: jQuery <1.8
// http://bugs.jquery.com/ticket/11778
setTimeout( function() {
diff --git a/ui/widgets/tooltip.js b/ui/widgets/tooltip.js
index 1c919582e..daf783a98 100644
--- a/ui/widgets/tooltip.js
+++ b/ui/widgets/tooltip.js
@@ -42,13 +42,16 @@ $.widget( "ui.tooltip", {
"ui-tooltip": "ui-corner-all ui-widget-shadow"
},
content: function() {
+
// support: IE<9, Opera in jQuery <1.7
// .text() can't accept undefined, so coerce to a string
var title = $( this ).attr( "title" ) || "";
+
// Escape title, since we're going from an attribute to raw HTML
return $( "<a>" ).text( title ).html();
},
hide: true,
+
// Disabled elements have inconsistent behavior across browsers (#8661)
items: "[title]:not([disabled])",
position: {
@@ -59,7 +62,7 @@ $.widget( "ui.tooltip", {
show: true,
track: false,
- // callbacks
+ // Callbacks
close: null,
open: null
},
@@ -102,10 +105,6 @@ $.widget( "ui.tooltip", {
// IDs of parent tooltips where we removed the title attribute
this.parents = {};
- if ( this.options.disabled ) {
- this._disable();
- }
-
// Append the aria-live region so tooltips announce correctly
this.liveRegion = $( "<div>" )
.attr( {
@@ -120,13 +119,6 @@ $.widget( "ui.tooltip", {
_setOption: function( key, value ) {
var that = this;
- if ( key === "disabled" ) {
- this[ value ? "_disable" : "_enable" ]();
- this.options[ key ] = value;
- // disable element style changes
- return;
- }
-
this._super( key, value );
if ( key === "content" ) {
@@ -136,17 +128,21 @@ $.widget( "ui.tooltip", {
}
},
+ _setOptionDisabled: function( value ) {
+ this[ value ? "_disable" : "_enable" ]();
+ },
+
_disable: function() {
var that = this;
- // close open tooltips
+ // Close open tooltips
$.each( this.tooltips, function( id, tooltipData ) {
var event = $.Event( "blur" );
event.target = event.currentTarget = tooltipData.element[ 0 ];
that.close( event, true );
} );
- // remove title attributes to prevent native tooltips
+ // Remove title attributes to prevent native tooltips
this.element.find( this.options.items ).addBack().each( function() {
var element = $( this );
if ( element.is( "[title]" ) ) {
@@ -158,6 +154,7 @@ $.widget( "ui.tooltip", {
},
_enable: function() {
+
// restore title attributes
this.element.find( this.options.items ).addBack().each( function() {
var element = $( this );
@@ -170,6 +167,7 @@ $.widget( "ui.tooltip", {
open: function( event ) {
var that = this,
target = $( event ? event.target : this.element )
+
// we need closest here due to mouseover bubbling,
// but always pointing at the same event target
.closest( this.options.items );
@@ -185,7 +183,7 @@ $.widget( "ui.tooltip", {
target.data( "ui-tooltip-open", true );
- // kill parent tooltips, custom or native, for hover
+ // Kill parent tooltips, custom or native, for hover
if ( event && event.type === "mouseover" ) {
target.parents().each( function() {
var parent = $( this ),
@@ -232,7 +230,7 @@ $.widget( "ui.tooltip", {
return;
}
- // jQuery creates a special event for focusin when it doesn't
+ // JQuery creates a special event for focusin when it doesn't
// exist natively. To improve performance, the native event
// object is reused and the type is changed. Therefore, we can't
// rely on the type being correct after the event finished
@@ -264,7 +262,7 @@ $.widget( "ui.tooltip", {
return;
}
- // if we have a title, clear it to prevent the native tooltip
+ // If we have a title, clear it to prevent the native 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])
//
@@ -304,6 +302,7 @@ $.widget( "ui.tooltip", {
this._on( this.document, {
mousemove: position
} );
+
// trigger once to override element-relative positioning
position( event );
} else {
@@ -315,6 +314,7 @@ $.widget( "ui.tooltip", {
tooltip.hide();
this._show( tooltip, this.options.show );
+
// Handle tracking tooltips that are shown with a delay (#8644). As soon
// as the tooltip is visible, position the tooltip using the most recent
// event.
@@ -377,7 +377,7 @@ $.widget( "ui.tooltip", {
tooltip = tooltipData.tooltip;
- // disabling closes the tooltip, so we need to track when we're closing
+ // Disabling closes the tooltip, so we need to track when we're closing
// to avoid an infinite loop in case the tooltip becomes disabled on close
if ( tooltipData.closing ) {
return;
@@ -386,7 +386,7 @@ $.widget( "ui.tooltip", {
// Clear the interval for delayed tracking tooltips
clearInterval( this.delayedShow );
- // only set title if we had one before (see comment in _open())
+ // Only set title if we had one before (see comment in _open())
// If the title attribute has changed since open(), don't restore
if ( target.data( "ui-tooltip-title" ) && !target.attr( "title" ) ) {
target.attr( "title", target.data( "ui-tooltip-title" ) );
@@ -462,8 +462,9 @@ $.widget( "ui.tooltip", {
_destroy: function() {
var that = this;
- // close open tooltips
+ // Close open tooltips
$.each( this.tooltips, function( id, tooltipData ) {
+
// Delegate to close method to handle common cleanup
var event = $.Event( "blur" ),
element = tooltipData.element;
@@ -476,6 +477,7 @@ $.widget( "ui.tooltip", {
// Restore the title
if ( element.data( "ui-tooltip-title" ) ) {
+
// If the title attribute has changed since open(), don't restore
if ( !element.attr( "title" ) ) {
element.attr( "title", element.data( "ui-tooltip-title" ) );