# HG changeset patch # User Aurelien Campeas # Date 1389271772 -3600 # Node ID 4c34a63bd113a621dac111577b0c4e8a7c7e089a # Parent f31f0c8bda4fc97f85405190775ce7c5561f16ac update jquery to 1.10 (closes #2786674) Includes: * base jquery * jquery.migrate to help for the transition * jquery.ui The jquery.ui.tabs api has slightly changed hance the change in web/views/tabs. The autocompletion widget is slightly adapted to follow an API change and now extends the base functionality in a simpler way. diff -r f31f0c8bda4f -r 4c34a63bd113 doc/3.18.rst --- a/doc/3.18.rst Mon Dec 16 08:45:06 2013 +0100 +++ b/doc/3.18.rst Thu Jan 09 13:49:32 2014 +0100 @@ -19,6 +19,8 @@ * new method `RequestSessionBase.find` to look for entities (see `#3361290 https://www.cubicweb.org/ticket/3361290`_) +* the embedded jQuery copy has been updated to version 1.10.2, and jQuery UI to + version 1.10.3. API changes ----------- diff -r f31f0c8bda4f -r 4c34a63bd113 web/data/cubicweb.widgets.js --- a/web/data/cubicweb.widgets.js Mon Dec 16 08:45:06 2013 +0100 +++ b/web/data/cubicweb.widgets.js Thu Jan 09 13:49:32 2014 +0100 @@ -92,7 +92,8 @@ if (($(instanceData.userInput).attr('cubicweb:initialvalue') !== undefined) && !instanceData.hiddenInput){ hiHandlers.initializeHiddenInput(instanceData); } - $.ui.autocomplete.prototype._search = methods.search; + $.ui.autocomplete.prototype._value = methods._value; + $.data(this, 'settings', settings); if (settings.multiple) { $.ui.autocomplete.filter = methods.multiple.makeFilter(this); $(this).bind({ @@ -125,6 +126,20 @@ }); }, + _value: function() { + /* We extend the widget with the ability to lookup and + handle several terms at once ('multiple' option). E.g.: + toto, titi, tu.... The autocompletion must be + performed only on the last of such a list of terms. + */ + var settings = $(this.element).data('settings'); + var value = this.valueMethod.apply( this.element, arguments ); + if (settings.multiple & arguments.length === 0) { + return extractLast(value); + } + return value + }, + multiple: { focus: function() { // prevent value inserted on focus @@ -140,7 +155,7 @@ return false; }, keydown: function(evt) { - if ($(this).data('autocomplete').menu.active && evt.keyCode == $.ui.keyCode.TAB) { + if (evt.keyCode == $.ui.keyCode.TAB) { evt.preventDefault(); } }, @@ -161,13 +176,7 @@ methods.resetValues(instanceData); } }, - search: function(value) { - this.element.addClass("ui-autocomplete-loading"); - if (this.options.multiple) { - value = extractLast(value); - } - this.source({term: value}, this.response); - }, + ensureExactMatch: function(evt) { var instanceData = $(this).data('cwautocomplete'); if (evt.keyCode == $.ui.keyCode.ENTER || evt.keyCode == $.ui.keyCode.TAB) { @@ -179,6 +188,7 @@ } } }, + resetValues: function(instanceData){ $(instanceData.userInput).val(''); $(instanceData.hiddenInput).val(''); diff -r f31f0c8bda4f -r 4c34a63bd113 web/data/jquery-migrate.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/data/jquery-migrate.js Thu Jan 09 13:49:32 2014 +0100 @@ -0,0 +1,521 @@ +/*! + * jQuery Migrate - v1.2.1 - 2013-05-08 + * https://github.com/jquery/jquery-migrate + * Copyright 2005, 2013 jQuery Foundation, Inc. and other contributors; Licensed MIT + */ +(function( jQuery, window, undefined ) { +// See http://bugs.jquery.com/ticket/13335 +// "use strict"; + + +var warnedAbout = {}; + +// List of warnings already given; public read only +jQuery.migrateWarnings = []; + +// Set to true to prevent console output; migrateWarnings still maintained +// jQuery.migrateMute = false; + +// Show a message on the console so devs know we're active +if ( !jQuery.migrateMute && window.console && window.console.log ) { + window.console.log("JQMIGRATE: Logging is active"); +} + +// Set to false to disable traces that appear with warnings +if ( jQuery.migrateTrace === undefined ) { + jQuery.migrateTrace = true; +} + +// Forget any warnings we've already given; public +jQuery.migrateReset = function() { + warnedAbout = {}; + jQuery.migrateWarnings.length = 0; +}; + +function migrateWarn( msg) { + var console = window.console; + if ( !warnedAbout[ msg ] ) { + warnedAbout[ msg ] = true; + jQuery.migrateWarnings.push( msg ); + if ( console && console.warn && !jQuery.migrateMute ) { + console.warn( "JQMIGRATE: " + msg ); + if ( jQuery.migrateTrace && console.trace ) { + console.trace(); + } + } + } +} + +function migrateWarnProp( obj, prop, value, msg ) { + if ( Object.defineProperty ) { + // On ES5 browsers (non-oldIE), warn if the code tries to get prop; + // allow property to be overwritten in case some other plugin wants it + try { + Object.defineProperty( obj, prop, { + configurable: true, + enumerable: true, + get: function() { + migrateWarn( msg ); + return value; + }, + set: function( newValue ) { + migrateWarn( msg ); + value = newValue; + } + }); + return; + } catch( err ) { + // IE8 is a dope about Object.defineProperty, can't warn there + } + } + + // Non-ES5 (or broken) browser; just set the property + jQuery._definePropertyBroken = true; + obj[ prop ] = value; +} + +if ( document.compatMode === "BackCompat" ) { + // jQuery has never supported or tested Quirks Mode + migrateWarn( "jQuery is not compatible with Quirks Mode" ); +} + + +var attrFn = jQuery( "", { size: 1 } ).attr("size") && jQuery.attrFn, + oldAttr = jQuery.attr, + valueAttrGet = jQuery.attrHooks.value && jQuery.attrHooks.value.get || + function() { return null; }, + valueAttrSet = jQuery.attrHooks.value && jQuery.attrHooks.value.set || + function() { return undefined; }, + rnoType = /^(?:input|button)$/i, + rnoAttrNodeType = /^[238]$/, + rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, + ruseDefault = /^(?:checked|selected)$/i; + +// jQuery.attrFn +migrateWarnProp( jQuery, "attrFn", attrFn || {}, "jQuery.attrFn is deprecated" ); + +jQuery.attr = function( elem, name, value, pass ) { + var lowerName = name.toLowerCase(), + nType = elem && elem.nodeType; + + if ( pass ) { + // Since pass is used internally, we only warn for new jQuery + // versions where there isn't a pass arg in the formal params + if ( oldAttr.length < 4 ) { + migrateWarn("jQuery.fn.attr( props, pass ) is deprecated"); + } + if ( elem && !rnoAttrNodeType.test( nType ) && + (attrFn ? name in attrFn : jQuery.isFunction(jQuery.fn[name])) ) { + return jQuery( elem )[ name ]( value ); + } + } + + // Warn if user tries to set `type`, since it breaks on IE 6/7/8; by checking + // for disconnected elements we don't warn on $( "