From d1505e3434ef99e0068347a5e8179a0ffd737676 Mon Sep 17 00:00:00 2001 From: Kris Borchers Date: Wed, 30 Jan 2013 12:30:37 -0600 Subject: Dialog: Move call to _focusTabbable and triggering of open and focus events into the _show callback. Fixes #6756 - Dialog: show: "blind" with link in content doesn't animate properly. Fixes #8051 - Dialog: 'Explode' dialog animation causes crash in IE 6, 7 and 8. Fixes #4421 - Dialog: Focus lost from dialog which uses show-effect --- ui/jquery.ui.dialog.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'ui') diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index ec4032ff3..77bf68dd1 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -207,6 +207,7 @@ $.widget( "ui.dialog", { }, open: function() { + var that = this; if ( this._isOpen ) { if ( this._moveToTop() ) { this._focusTabbable(); @@ -220,13 +221,13 @@ $.widget( "ui.dialog", { this._position(); this._createOverlay(); this._moveToTop( null, true ); - this._show( this.uiDialog, this.options.show ); - - this._focusTabbable(); + this._show( this.uiDialog, this.options.show, function() { + that._focusTabbable(); + that._trigger("focus"); + }); this._isOpen = true; this._trigger("open"); - this._trigger("focus"); }, _focusTabbable: function() { -- cgit v1.2.3 From c193a0ce17b30188576fcdb9e4b2222ce7f02f47 Mon Sep 17 00:00:00 2001 From: Scott González Date: Thu, 31 Jan 2013 09:05:04 -0500 Subject: Menu: Escape em and en dashes in regex. Fixes #9016 - Menu: Non-ASCII characters. --- ui/jquery.ui.menu.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui') diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js index 4ffe732d4..1c633786d 100644 --- a/ui/jquery.ui.menu.js +++ b/ui/jquery.ui.menu.js @@ -323,7 +323,7 @@ $.widget( "ui.menu", { menus.children( ":not(.ui-menu-item)" ).each(function() { var item = $( this ); // hyphen, em dash, en dash - if ( !/[^\-—–\s]/.test( item.text() ) ) { + if ( !/[^\-\u2014\u2013\s]/.test( item.text() ) ) { item.addClass( "ui-widget-content ui-menu-divider" ); } }); -- cgit v1.2.3 From 62cda1f95d0e7040153f0b5fe5745d199a0a094e Mon Sep 17 00:00:00 2001 From: Scott González Date: Thu, 31 Jan 2013 17:20:19 -0500 Subject: Dialog: Set the _isOpen flag immediately in open(). Fixes #8958 - Dialog: Double ui-widget-overlay when opening modal dialog triggers an event opening same dialog. --- tests/unit/dialog/dialog_methods.js | 29 +++++++++++++++++++++++++++++ ui/jquery.ui.dialog.js | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) (limited to 'ui') diff --git a/tests/unit/dialog/dialog_methods.js b/tests/unit/dialog/dialog_methods.js index 2c3495ca2..6de185513 100644 --- a/tests/unit/dialog/dialog_methods.js +++ b/tests/unit/dialog/dialog_methods.js @@ -193,6 +193,35 @@ test("#6137: dialog('open') causes form elements to reset on IE7", function() { d1.remove(); }); +asyncTest( "#8958: dialog can be opened while opening", function() { + expect( 1 ); + + var element = $( "
" ).dialog({ + autoOpen: false, + modal: true, + open: function() { + equal( $( ".ui-widget-overlay" ).length, 1 ); + start(); + } + }); + + $( "#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. + .bind( "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. + .bind( "blur", function() { + element.dialog( "open" ); + }) + .focus(); +}); + test("#5531: dialog width should be at least minWidth on creation", function () { expect( 4 ); var element = $("
").dialog({ diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 77bf68dd1..b6ac7aed7 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -215,6 +215,7 @@ $.widget( "ui.dialog", { return; } + this._isOpen = true; this.opener = $( this.document[0].activeElement ); this._size(); @@ -226,7 +227,6 @@ $.widget( "ui.dialog", { that._trigger("focus"); }); - this._isOpen = true; this._trigger("open"); }, -- cgit v1.2.3 From 7bbda71a32cc4953715ed34eab2ab48c5e736154 Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 1 Feb 2013 08:59:55 -0500 Subject: Dialog: Check for empty array in addition to empty object when checking if there are buttons. Fixes #9043 - Dialog: Buttonpane shown with no buttons when modifying native prototypes. --- demos/dialog/default.html | 1 + tests/unit/dialog/dialog_options.js | 10 ++++++++++ ui/jquery.ui.dialog.js | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) (limited to 'ui') diff --git a/demos/dialog/default.html b/demos/dialog/default.html index e781e18f8..98f248b81 100644 --- a/demos/dialog/default.html +++ b/demos/dialog/default.html @@ -16,6 +16,7 @@ diff --git a/tests/unit/dialog/dialog_options.js b/tests/unit/dialog/dialog_options.js index a295b904d..07c2d6860 100644 --- a/tests/unit/dialog/dialog_options.js +++ b/tests/unit/dialog/dialog_options.js @@ -174,6 +174,16 @@ test("buttons - advanced", function() { element.remove(); }); +test("#9043: buttons with Array.prototype modification", function() { + expect( 1 ); + Array.prototype.test = $.noop; + var element = $( "
" ).dialog(); + equal( element.dialog( "widget" ).find( ".ui-dialog-buttonpane" ).length, 0, + "no button pane" ); + element.remove(); + delete Array.prototype.test; +}); + test("closeOnEscape", function() { expect( 6 ); var element = $("
").dialog({ closeOnEscape: false }); diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index b6ac7aed7..cb62155e5 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -396,7 +396,7 @@ $.widget( "ui.dialog", { this.uiDialogButtonPane.remove(); this.uiButtonSet.empty(); - if ( $.isEmptyObject( buttons ) ) { + if ( $.isEmptyObject( buttons ) || ($.isArray( buttons ) && !buttons.length) ) { this.uiDialog.removeClass("ui-dialog-buttons"); return; } -- cgit v1.2.3 From df179542cc6593b1816d487c72c470a73940ff11 Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 1 Feb 2013 16:52:04 -0500 Subject: Datepicker: Escape single quotes in tooltips. Fixes #9049 - Datepicker beforeShowDay tooltip not displayed properly if single quote is used. --- tests/unit/datepicker/datepicker_options.js | 15 +++++++++++++++ ui/jquery.ui.datepicker.js | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'ui') diff --git a/tests/unit/datepicker/datepicker_options.js b/tests/unit/datepicker/datepicker_options.js index dac2262dc..1efd854a9 100644 --- a/tests/unit/datepicker/datepicker_options.js +++ b/tests/unit/datepicker/datepicker_options.js @@ -782,6 +782,21 @@ test("callbacks", function() { inp.datepicker("hide").datepicker("destroy"); }); +test("beforeShowDay - tooltips with quotes", function() { + expect( 1 ); + var inp, dp; + inp = TestHelpers.datepicker.init("#inp", { + beforeShowDay: function() { + return [ true, "", "'" ]; + } + }); + dp = $("#ui-datepicker-div"); + + inp.datepicker("show"); + equal( dp.find( ".ui-datepicker-calendar td:contains('9')").attr( "title" ), "'" ); + inp.datepicker("hide").datepicker("destroy"); +}); + test("localisation", function() { expect( 24 ); var dp, month, day, date, diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js index e93f596fc..b893f582d 100644 --- a/ui/jquery.ui.datepicker.js +++ b/ui/jquery.ui.datepicker.js @@ -1741,7 +1741,7 @@ $.extend(Datepicker.prototype, { (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different) - ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2] + "'" : "") + // cell title + ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "'") + "'" : "") + // cell title (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions (otherMonth && !showOtherMonths ? " " : // display for other months (unselectable ? "" + printDate.getDate() + "" : " Date: Sat, 2 Feb 2013 19:32:42 -0500 Subject: Dialog: Don't use ._on() for modal event handlers. Fixes #9048 - Dialog: broken focusin event handler when beforeclose event of a modal opens another modal. --- tests/unit/dialog/dialog_core.js | 13 +++++++++++++ ui/jquery.ui.dialog.js | 20 +++++++++----------- 2 files changed, 22 insertions(+), 11 deletions(-) (limited to 'ui') diff --git a/tests/unit/dialog/dialog_core.js b/tests/unit/dialog/dialog_core.js index 9292eca9f..e85759dc9 100644 --- a/tests/unit/dialog/dialog_core.js +++ b/tests/unit/dialog/dialog_core.js @@ -147,4 +147,17 @@ asyncTest( "Prevent tabbing out of dialogs", function() { }); }); +asyncTest( "#9048: multiple modal dialogs opened and closed in different order", function() { + expect( 1 ); + $( "#dialog1, #dialog2" ).dialog({ autoOpen: false, modal:true }); + $( "#dialog1" ).dialog( "open" ); + $( "#dialog2" ).dialog( "open" ); + $( "#dialog1" ).dialog( "close" ); + setTimeout(function() { + $( "#dialog2" ).dialog( "close" ); + $( "#favorite-animal" ).focus(); + ok( true, "event handlers cleaned up (no errors thrown)" ); + start(); + }); +}); })(jQuery); diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index cb62155e5..f2bc906fd 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -678,16 +678,14 @@ $.widget( "ui.dialog", { this._delay(function() { // Handle .dialog().dialog("close") (#4065) if ( $.ui.dialog.overlayInstances ) { - this._on( this.document, { - focusin: function( event ) { - if ( !$( event.target ).closest(".ui-dialog").length && - // TODO: Remove hack when datepicker implements - // the .ui-front logic (#8989) - !$( event.target ).closest(".ui-datepicker").length ) { - event.preventDefault(); - $(".ui-dialog:visible:last .ui-dialog-content") - .data("ui-dialog")._focusTabbable(); - } + this.document.bind( "focusin.dialog", function( event ) { + if ( !$( event.target ).closest(".ui-dialog").length && + // TODO: Remove hack when datepicker implements + // the .ui-front logic (#8989) + !$( event.target ).closest(".ui-datepicker").length ) { + event.preventDefault(); + $(".ui-dialog:visible:last .ui-dialog-content") + .data("ui-dialog")._focusTabbable(); } }); } @@ -712,7 +710,7 @@ $.widget( "ui.dialog", { $.ui.dialog.overlayInstances--; if ( !$.ui.dialog.overlayInstances ) { - this._off( this.document, "focusin" ); + this.document.unbind( "focusin.dialog" ); } this.overlay.remove(); this.overlay = null; -- cgit v1.2.3 From a7353e7c9ba18e017813195c885115338800e13d Mon Sep 17 00:00:00 2001 From: Scott González Date: Sun, 3 Feb 2013 08:55:34 -0500 Subject: Dailog: Cover iframes during drag and resize. Fixes #7650 - Dialog cannot be dragged properly with IFRAME. --- ui/jquery.ui.dialog.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'ui') diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index f2bc906fd..85dbddda2 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -444,6 +444,7 @@ $.widget( "ui.dialog", { containment: "document", start: function( event, ui ) { $( this ).addClass("ui-dialog-dragging"); + that._blockFrames(); that._trigger( "dragStart", event, filteredUi( ui ) ); }, drag: function( event, ui ) { @@ -455,6 +456,7 @@ $.widget( "ui.dialog", { ui.position.top - that.document.scrollTop() ]; $( this ).removeClass("ui-dialog-dragging"); + that._unblockFrames(); that._trigger( "dragStop", event, filteredUi( ui ) ); } }); @@ -491,6 +493,7 @@ $.widget( "ui.dialog", { handles: resizeHandles, start: function( event, ui ) { $( this ).addClass("ui-dialog-resizing"); + that._blockFrames(); that._trigger( "resizeStart", event, filteredUi( ui ) ); }, resize: function( event, ui ) { @@ -500,6 +503,7 @@ $.widget( "ui.dialog", { options.height = $( this ).height(); options.width = $( this ).width(); $( this ).removeClass("ui-dialog-resizing"); + that._unblockFrames(); that._trigger( "resizeStop", event, filteredUi( ui ) ); } }) @@ -666,6 +670,28 @@ $.widget( "ui.dialog", { } }, + _blockFrames: function() { + this.iframeBlocks = this.document.find( "iframe" ).map(function() { + var iframe = $( this ); + + return $( "
" ) + .css({ + position: "absolute", + width: iframe.outerWidth(), + height: iframe.outerHeight() + }) + .appendTo( iframe.parent() ) + .offset( iframe.offset() )[0]; + }); + }, + + _unblockFrames: function() { + if ( this.iframeBlocks ) { + this.iframeBlocks.remove(); + delete this.iframeBlocks; + } + }, + _createOverlay: function() { if ( !this.options.modal ) { return; -- cgit v1.2.3 From a129a93a4d3a76e646423b6238459a12c80e22b0 Mon Sep 17 00:00:00 2001 From: David Petersen Date: Thu, 31 Jan 2013 20:19:52 -0600 Subject: Slider: Add disabled tests and remove disabled prop from handles --- tests/unit/slider/slider_options.js | 31 +++++++++++++++++++++++++++++++ ui/jquery.ui.slider.js | 3 --- 2 files changed, 31 insertions(+), 3 deletions(-) (limited to 'ui') diff --git a/tests/unit/slider/slider_options.js b/tests/unit/slider/slider_options.js index d354ef91c..a7bd3ae83 100644 --- a/tests/unit/slider/slider_options.js +++ b/tests/unit/slider/slider_options.js @@ -11,6 +11,37 @@ function handle() { module("slider: options"); +test( "disabled", function(){ + expect( 8 ); + var count = 0; + + el = $( "#slider1" ).slider(); + el.on( "slidestart", function() { + count++; + }); + + // enabled + ok( !el.hasClass( "ui-slider-disabled" ), "no disabled class" ); + equal( el.slider( "option", "disabled" ), false , "is not disabled" ); + + handle().simulate( "drag", { dx: 10 } ); + equal( count, 1, "slider moved"); + + handle().simulate("keydown", { keyCode: $.ui.keyCode.RIGHT }); + equal( count, 2, "slider moved"); + + // disabled + el.slider( "option", "disabled", true ); + ok( el.hasClass( "ui-slider-disabled" ), "has disabled class" ); + equal( el.slider( "option", "disabled" ), true, "is disabled" ); + + handle().simulate( "drag", { dx: 10 } ); + equal( count, 2, "slider did not move"); + + handle().simulate("keydown", { keyCode: $.ui.keyCode.RIGHT }); + equal( count, 2, "slider did not move"); +}); + test("max", function() { expect( 2 ); el = $("
"); diff --git a/ui/jquery.ui.slider.js b/ui/jquery.ui.slider.js index 54024af49..ceb8e1320 100644 --- a/ui/jquery.ui.slider.js +++ b/ui/jquery.ui.slider.js @@ -412,9 +412,6 @@ $.widget( "ui.slider", $.ui.mouse, { if ( value ) { this.handles.filter( ".ui-state-focus" ).blur(); this.handles.removeClass( "ui-state-hover" ); - this.handles.prop( "disabled", true ); - } else { - this.handles.prop( "disabled", false ); } break; case "orientation": -- cgit v1.2.3 From df077abfc2a236a373d2080a9ceae97bb48c2620 Mon Sep 17 00:00:00 2001 From: David Petersen Date: Wed, 30 Jan 2013 13:07:33 -0600 Subject: Slider: allow range option to be changed. Fixed #5602 - Slider Does Not Exhibit Proper Behavior When Switching Range --- tests/unit/slider/slider_options.js | 103 +++++++++++++++++++++++++ ui/jquery.ui.slider.js | 148 +++++++++++++++++++++--------------- 2 files changed, 190 insertions(+), 61 deletions(-) (limited to 'ui') diff --git a/tests/unit/slider/slider_options.js b/tests/unit/slider/slider_options.js index a7bd3ae83..dd213d03b 100644 --- a/tests/unit/slider/slider_options.js +++ b/tests/unit/slider/slider_options.js @@ -203,4 +203,107 @@ test("values", function() { ); }); +test( "range", function() { + expect( 27 ); + var element, range; + + // min + element = $("
").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 = $("
").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 = $("
").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"); + ok( !range.is( ".ui-slider-range-min"), "range true" ); + ok( !range.is( ".ui-slider-range-max"), "range true" ); + element.slider( "destroy" ); + + // Change range from min to max + element = $("
").slider({ + range: "min", + min: 1, + max: 10, + step: 1 + }).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" ); + equal( element.find( ".ui-slider-range-max" ).length, 1, "range switch from min to max" ); + element.slider( "destroy" ); + + // Change range from max to min + element = $("
").slider({ + range: "max", + min: 1, + max: 10, + step: 1 + }).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" ); + equal( element.find( ".ui-slider-range-min" ).length, 1, "range switch from max to min" ); + element.slider( "destroy" ); + + // Change range from max to true + element = $("
").slider({ + range: "max", + min: 1, + max: 10, + step: 1 + }).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" ); + element.slider( "destroy" ); + + // Change range from true to min + element = $("
").slider({ + range: true, + min: 1, + max: 10, + step: 1 + }).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( "option", "values" ), null, "values" ); + deepEqual( element.slider( "values" ), [] , "values" ); + element.slider( "destroy" ); +}); + })(jQuery); diff --git a/ui/jquery.ui.slider.js b/ui/jquery.ui.slider.js index ceb8e1320..b3e609aa2 100644 --- a/ui/jquery.ui.slider.js +++ b/ui/jquery.ui.slider.js @@ -42,12 +42,6 @@ $.widget( "ui.slider", $.ui.mouse, { }, _create: function() { - var i, handleCount, - o = this.options, - existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ), - handle = "
", - handles = []; - this._keySliding = false; this._mouseSliding = false; this._animateOff = true; @@ -62,29 +56,32 @@ $.widget( "ui.slider", $.ui.mouse, { " ui-widget-content" + " ui-corner-all"); - this.range = $([]); + this._refresh(); + this._setOption( "disabled", this.options.disabled ); - if ( o.range ) { - if ( o.range === true ) { - if ( !o.values ) { - o.values = [ this._valueMin(), this._valueMin() ]; - } else if ( o.values.length && o.values.length !== 2 ) { - o.values = [ o.values[0], o.values[0] ]; - } else if ( $.isArray( o.values ) ) { - o.values = o.values.slice(0); - } - } + this._animateOff = false; + }, - this.range = $( "
" ) - .appendTo( this.element ) - .addClass( "ui-slider-range" + - // note: this isn't the most fittingly semantic framework class for this element, - // but worked best visually with a variety of themes - " ui-widget-header ui-corner-all" + - ( ( o.range === "min" || o.range === "max" ) ? " ui-slider-range-" + o.range : "" ) ); - } + _refresh: function() { + this._createRange(); + this._createHandles(); + this._setupEvents(); + this._refreshValue(); + }, + + _createHandles: function() { + var i, handleCount, + options = this.options, + existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ), + handle = "", + handles = []; - handleCount = ( o.values && o.values.length ) || 1; + handleCount = ( options.values && options.values.length ) || 1; + + if ( existingHandles.length > handleCount ) { + existingHandles.slice( handleCount ).remove(); + existingHandles = existingHandles.slice( 0, handleCount ); + } for ( i = existingHandles.length; i < handleCount; i++ ) { handles.push( handle ); @@ -94,41 +91,56 @@ $.widget( "ui.slider", $.ui.mouse, { this.handle = this.handles.eq( 0 ); - this.handles.add( this.range ).filter( "a" ) - .click(function( event ) { - event.preventDefault(); - }) - .mouseenter(function() { - if ( !o.disabled ) { - $( this ).addClass( "ui-state-hover" ); - } - }) - .mouseleave(function() { - $( this ).removeClass( "ui-state-hover" ); - }) - .focus(function() { - if ( !o.disabled ) { - $( ".ui-slider .ui-state-focus" ).removeClass( "ui-state-focus" ); - $( this ).addClass( "ui-state-focus" ); - } else { - $( this ).blur(); - } - }) - .blur(function() { - $( this ).removeClass( "ui-state-focus" ); - }); - this.handles.each(function( i ) { $( this ).data( "ui-slider-handle-index", i ); }); + }, - this._setOption( "disabled", o.disabled ); + _createRange: function() { + var options = this.options, + classes = ""; + + if ( options.range ) { + if ( options.range === true ) { + 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] ]; + } else if ( $.isArray( options.values ) ) { + options.values = options.values.slice(0); + } + } - this._on( this.handles, this._handleEvents ); + if ( !this.range || !this.range.length ) { + this.range = $( "
" ) + .appendTo( this.element ); - this._refreshValue(); + classes = "ui-slider-range" + + // note: this isn't the most fittingly semantic framework class for this element, + // but worked best visually with a variety of themes + " ui-widget-header ui-corner-all"; + } else { + this.range.removeClass( "ui-slider-range-min ui-slider-range-max" ) + // Handle range switching from true to min/max + .css({ + "left": "", + "bottom": "" + }); + } - this._animateOff = false; + this.range.addClass( classes + + ( ( options.range === "min" || options.range === "max" ) ? " ui-slider-range-" + options.range : "" ) ); + } else { + this.range = $([]); + } + }, + + _setupEvents: function() { + var elements = this.handles.add( this.range ).filter( "a" ); + this._off( elements ); + this._on( elements, this._handleEvents ); + this._hoverable( elements ); + this._focusable( elements ); }, _destroy: function() { @@ -401,6 +413,16 @@ $.widget( "ui.slider", $.ui.mouse, { var i, valsLength = 0; + if ( key === "range" && this.options.range === true ) { + if ( value === "min" ) { + this.options.value = this._values( 0 ); + this.options.values = null; + } else if ( value === "max" ) { + this.options.value = this._values( this.options.values.length-1 ); + this.options.values = null; + } + } + if ( $.isArray( this.options.values ) ) { valsLength = this.options.values.length; } @@ -408,12 +430,6 @@ $.widget( "ui.slider", $.ui.mouse, { $.Widget.prototype._setOption.apply( this, arguments ); switch ( key ) { - case "disabled": - if ( value ) { - this.handles.filter( ".ui-state-focus" ).blur(); - this.handles.removeClass( "ui-state-hover" ); - } - break; case "orientation": this._detectOrientation(); this.element @@ -441,6 +457,11 @@ $.widget( "ui.slider", $.ui.mouse, { this._refreshValue(); this._animateOff = false; break; + case "range": + this._animateOff = true; + this._refresh(); + this._animateOff = false; + break; } }, @@ -466,7 +487,7 @@ $.widget( "ui.slider", $.ui.mouse, { val = this._trimAlignValue( val ); return val; - } else { + } else if ( this.options.values && this.options.values.length ) { // .slice() creates a copy of the array // this copy gets trimmed by min and max and then returned vals = this.options.values.slice(); @@ -475,6 +496,8 @@ $.widget( "ui.slider", $.ui.mouse, { } return vals; + } else { + return []; } }, @@ -629,6 +652,9 @@ $.widget( "ui.slider", $.ui.mouse, { this._slide( event, index, newVal ); }, + click: function( event ) { + event.preventDefault(); + }, keyup: function( event ) { var index = $( event.target ).data( "ui-slider-handle-index" ); -- cgit v1.2.3 From 101a09d31f65ab62c7bc68e54aacd68028c1765b Mon Sep 17 00:00:00 2001 From: Scott González Date: Tue, 5 Feb 2013 09:33:48 -0500 Subject: Autocomplete: Optimize element type checks for speed and size. --- ui/jquery.ui.autocomplete.js | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'ui') diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index af1acb02b..f8470a8a1 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -54,10 +54,21 @@ $.widget( "ui.autocomplete", { // so we use the suppressKeyPressRepeat flag to avoid handling keypress // events when we know the keydown event was used to modify the // search term. #7799 - var suppressKeyPress, suppressKeyPressRepeat, suppressInput; - - this.isMultiLine = this._isMultiLine(); - this.valueMethod = this.element[ this.element.is( "input,textarea" ) ? "val" : "text" ]; + var suppressKeyPress, suppressKeyPressRepeat, suppressInput, + nodeName = this.element[0].nodeName.toLowerCase(), + isTextarea = nodeName === "textarea", + isInput = nodeName === "input"; + + this.isMultiLine = + // Textareas are always multi-line + isTextarea ? true : + // Inputs are always single-line, even if inside a contentEditable element + // IE also treats inputs as contentEditable + isInput ? false : + // All other element types are determined by whether or not they're contentEditable + this.element.prop( "isContentEditable" ); + + this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ]; this.isNewMenu = true; this.element @@ -341,20 +352,6 @@ $.widget( "ui.autocomplete", { return element; }, - _isMultiLine: function() { - // Textareas are always multi-line - if ( this.element.is( "textarea" ) ) { - return true; - } - // Inputs are always single-line, even if inside a contentEditable element - // IE also treats inputs as contentEditable - if ( this.element.is( "input" ) ) { - return false; - } - // All other element types are determined by whether or not they're contentEditable - return this.element.prop( "isContentEditable" ); - }, - _initSource: function() { var array, url, that = this; -- cgit v1.2.3 From 7a49ee4cd3a59a11e8c65cb1974481d86e2fd4d7 Mon Sep 17 00:00:00 2001 From: Scott González Date: Tue, 5 Feb 2013 10:13:27 -0500 Subject: Datepicker: Use entity number instead of entity name when escaping single quotes. --- ui/jquery.ui.datepicker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui') diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js index b893f582d..efee7a819 100644 --- a/ui/jquery.ui.datepicker.js +++ b/ui/jquery.ui.datepicker.js @@ -1741,7 +1741,7 @@ $.extend(Datepicker.prototype, { (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different) - ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "'") + "'" : "") + // cell title + ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "'") + "'" : "") + // cell title (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions (otherMonth && !showOtherMonths ? " " : // display for other months (unselectable ? "" + printDate.getDate() + "" : "" ) - .addClass( "ui-autocomplete" ) + .addClass( "ui-autocomplete ui-front" ) .appendTo( this._appendTo() ) .menu({ // custom key handling for now @@ -200,7 +200,6 @@ $.widget( "ui.autocomplete", { // disable ARIA support, the live region takes care of that role: null }) - .zIndex( this.element.zIndex() + 1 ) .hide() .data( "ui-menu" ); @@ -489,9 +488,7 @@ $.widget( "ui.autocomplete", { }, _suggest: function( items ) { - var ul = this.menu.element - .empty() - .zIndex( this.element.zIndex() + 1 ); + var ul = this.menu.element.empty(); this._renderMenu( ul, items ); this.menu.refresh(); -- cgit v1.2.3