MDL-44511 import latest jQuery and add tests

This commit is contained in:
Petr Škoda
2014-03-20 17:31:34 +08:00
parent 9b8555fbea
commit fa71f84fc8
28 changed files with 4837 additions and 4087 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
+3 -3
View File
@@ -37,8 +37,8 @@
*/
$plugins = array(
'jquery' => array('files' => array('jquery-1.10.2.min.js')),
'jquery' => array('files' => array('jquery-1.11.0.min.js')),
'migrate' => array('files' => array('jquery-migrate-1.2.1.min.js')),
'ui' => array('files' => array('ui-1.10.3/jquery-ui.min.js')),
'ui-css' => array('files' => array('ui-1.10.3/css/base/jquery-ui.min.css')),
'ui' => array('files' => array('ui-1.10.4/jquery-ui.min.js')),
'ui-css' => array('files' => array('ui-1.10.4/css/base/jquery-ui.min.css')),
);
+6
View File
@@ -5,3 +5,9 @@ Description of import of various jQuery libraries into Moodle:
2/ download jQuery UI files from http://jqueryui.com/download/all/,
delete old files and edit plugins.php
3/ run phpunit tests
4/ open http://127.0.0.1/lib/tests/other/jquerypage.php
Petr Skoda
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Before

Width:  |  Height:  |  Size: 180 B

After

Width:  |  Height:  |  Size: 180 B

Before

Width:  |  Height:  |  Size: 178 B

After

Width:  |  Height:  |  Size: 178 B

Before

Width:  |  Height:  |  Size: 120 B

After

Width:  |  Height:  |  Size: 120 B

Before

Width:  |  Height:  |  Size: 105 B

After

Width:  |  Height:  |  Size: 105 B

Before

Width:  |  Height:  |  Size: 111 B

After

Width:  |  Height:  |  Size: 111 B

Before

Width:  |  Height:  |  Size: 110 B

After

Width:  |  Height:  |  Size: 110 B

Before

Width:  |  Height:  |  Size: 119 B

After

Width:  |  Height:  |  Size: 119 B

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

@@ -1,7 +1,7 @@
/*! jQuery UI - v1.10.3 - 2013-05-03
/*! jQuery UI - v1.10.4 - 2014-01-17
* http://jqueryui.com
* Includes: jquery.ui.core.css, jquery.ui.accordion.css, jquery.ui.autocomplete.css, jquery.ui.button.css, jquery.ui.datepicker.css, jquery.ui.dialog.css, jquery.ui.menu.css, jquery.ui.progressbar.css, jquery.ui.resizable.css, jquery.ui.selectable.css, jquery.ui.slider.css, jquery.ui.spinner.css, jquery.ui.tabs.css, jquery.ui.tooltip.css, jquery.ui.theme.css
* Copyright 2013 jQuery Foundation and other contributors; Licensed MIT */
* Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
/* Layout helpers
----------------------------------*/
.ui-helper-hidden {
@@ -276,9 +276,6 @@ button.ui-button::-moz-focus-inner {
font-size: 1em;
margin: 1px 0;
}
.ui-datepicker select.ui-datepicker-month-year {
width: 100%;
}
.ui-datepicker select.ui-datepicker-month,
.ui-datepicker select.ui-datepicker-year {
width: 49%;
@@ -396,6 +393,7 @@ button.ui-button::-moz-focus-inner {
}
.ui-dialog {
overflow: hidden;
position: absolute;
top: 0;
left: 0;
@@ -418,7 +416,7 @@ button.ui-button::-moz-focus-inner {
position: absolute;
right: .3em;
top: 50%;
width: 21px;
width: 20px;
margin: -10px 0 0 0;
padding: 1px;
height: 20px;
@@ -713,13 +711,13 @@ button.ui-button::-moz-focus-inner {
overflow: hidden;
right: 0;
}
/* more specificity required here to overide default borders */
/* more specificity required here to override default borders */
.ui-spinner a.ui-spinner-button {
border-top: none;
border-bottom: none;
border-right: none;
}
/* vertical centre icon */
/* vertically center icon */
.ui-spinner .ui-icon {
position: absolute;
margin-top: -8px;
@@ -757,7 +755,7 @@ button.ui-button::-moz-focus-inner {
padding: 0;
white-space: nowrap;
}
.ui-tabs .ui-tabs-nav li a {
.ui-tabs .ui-tabs-nav .ui-tabs-anchor {
float: left;
padding: .5em 1em;
text-decoration: none;
@@ -766,13 +764,12 @@ button.ui-button::-moz-focus-inner {
margin-bottom: -1px;
padding-bottom: 1px;
}
.ui-tabs .ui-tabs-nav li.ui-tabs-active a,
.ui-tabs .ui-tabs-nav li.ui-state-disabled a,
.ui-tabs .ui-tabs-nav li.ui-tabs-loading a {
.ui-tabs .ui-tabs-nav li.ui-tabs-active .ui-tabs-anchor,
.ui-tabs .ui-tabs-nav li.ui-state-disabled .ui-tabs-anchor,
.ui-tabs .ui-tabs-nav li.ui-tabs-loading .ui-tabs-anchor {
cursor: text;
}
.ui-tabs .ui-tabs-nav li a, /* first selector in group seems obsolete, but required to overcome bug in Opera applying cursor: text overall if defined elsewhere... */
.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-active a {
.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-active .ui-tabs-anchor {
cursor: pointer;
}
.ui-tabs .ui-tabs-panel {
@@ -858,7 +855,11 @@ body .ui-tooltip {
.ui-state-hover a,
.ui-state-hover a:hover,
.ui-state-hover a:link,
.ui-state-hover a:visited {
.ui-state-hover a:visited,
.ui-state-focus a,
.ui-state-focus a:hover,
.ui-state-focus a:link,
.ui-state-focus a:visited {
color: #212121/*{fcHover}*/;
text-decoration: none;
}
File diff suppressed because one or more lines are too long
@@ -1,7 +1,7 @@
/*! jQuery UI - v1.10.3 - 2013-05-03
/*! jQuery UI - v1.10.4 - 2014-01-17
* http://jqueryui.com
* Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.ui.effect.js, jquery.ui.accordion.js, jquery.ui.autocomplete.js, jquery.ui.button.js, jquery.ui.datepicker.js, jquery.ui.dialog.js, jquery.ui.effect-blind.js, jquery.ui.effect-bounce.js, jquery.ui.effect-clip.js, jquery.ui.effect-drop.js, jquery.ui.effect-explode.js, jquery.ui.effect-fade.js, jquery.ui.effect-fold.js, jquery.ui.effect-highlight.js, jquery.ui.effect-pulsate.js, jquery.ui.effect-scale.js, jquery.ui.effect-shake.js, jquery.ui.effect-slide.js, jquery.ui.effect-transfer.js, jquery.ui.menu.js, jquery.ui.position.js, jquery.ui.progressbar.js, jquery.ui.slider.js, jquery.ui.spinner.js, jquery.ui.tabs.js, jquery.ui.tooltip.js
* Copyright 2013 jQuery Foundation and other contributors; Licensed MIT */
* Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
(function( $, undefined ) {
var uuid = 0,
@@ -11,7 +11,7 @@ var uuid = 0,
$.ui = $.ui || {};
$.extend( $.ui, {
version: "1.10.3",
version: "1.10.4",
keyCode: {
BACKSPACE: 8,
@@ -411,7 +411,7 @@ $.widget = function( name, base, prototype ) {
// 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
widgetEventPrefix: existingConstructor ? basePrototype.widgetEventPrefix : name
widgetEventPrefix: existingConstructor ? (basePrototype.widgetEventPrefix || name) : name
}, proxiedPrototype, {
constructor: constructor,
namespace: namespace,
@@ -620,12 +620,12 @@ $.Widget.prototype = {
curOption = curOption[ parts[ i ] ];
}
key = parts.pop();
if ( value === undefined ) {
if ( arguments.length === 1 ) {
return curOption[ key ] === undefined ? null : curOption[ key ];
}
curOption[ key ] = value;
} else {
if ( value === undefined ) {
if ( arguments.length === 1 ) {
return this.options[ key ] === undefined ? null : this.options[ key ];
}
options[ key ] = value;
@@ -833,7 +833,7 @@ $( document ).mouseup( function() {
});
$.widget("ui.mouse", {
version: "1.10.3",
version: "1.10.4",
options: {
cancel: "input,textarea,button,select,option",
distance: 1,
@@ -985,7 +985,7 @@ $.widget("ui.mouse", {
(function( $, undefined ) {
$.widget("ui.draggable", $.ui.mouse, {
version: "1.10.3",
version: "1.10.4",
widgetEventPrefix: "drag",
options: {
addClasses: true,
@@ -1933,7 +1933,7 @@ function isOverAxis( x, reference, size ) {
}
$.widget("ui.droppable", {
version: "1.10.3",
version: "1.10.4",
widgetEventPrefix: "drop",
options: {
accept: "*",
@@ -1953,7 +1953,8 @@ $.widget("ui.droppable", {
},
_create: function() {
var o = this.options,
var proportions,
o = this.options,
accept = o.accept;
this.isover = false;
@@ -1963,8 +1964,20 @@ $.widget("ui.droppable", {
return d.is(accept);
};
//Store the droppable's proportions
this.proportions = { width: this.element[0].offsetWidth, height: this.element[0].offsetHeight };
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 :
proportions = {
width: this.element[ 0 ].offsetWidth,
height: this.element[ 0 ].offsetHeight
};
}
};
// Add the reference and positions to the manager
$.ui.ddmanager.droppables[o.scope] = $.ui.ddmanager.droppables[o.scope] || [];
@@ -2110,10 +2123,14 @@ $.ui.intersect = function(draggable, droppable, toleranceMode) {
}
var draggableLeft, draggableTop,
x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width,
y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height,
l = droppable.offset.left, r = l + droppable.proportions.width,
t = droppable.offset.top, b = t + droppable.proportions.height;
x1 = (draggable.positionAbs || draggable.position.absolute).left,
y1 = (draggable.positionAbs || draggable.position.absolute).top,
x2 = x1 + draggable.helperProportions.width,
y2 = y1 + draggable.helperProportions.height,
l = droppable.offset.left,
t = droppable.offset.top,
r = l + droppable.proportions().width,
b = t + droppable.proportions().height;
switch (toleranceMode) {
case "fit":
@@ -2126,7 +2143,7 @@ $.ui.intersect = function(draggable, droppable, toleranceMode) {
case "pointer":
draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left);
draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top);
return isOverAxis( draggableTop, t, droppable.proportions.height ) && isOverAxis( draggableLeft, l, droppable.proportions.width );
return isOverAxis( draggableTop, t, droppable.proportions().height ) && isOverAxis( draggableLeft, l, droppable.proportions().width );
case "touch":
return (
(y1 >= t && y1 <= b) || // Top edge touching
@@ -2166,7 +2183,7 @@ $.ui.ddmanager = {
// Filter out elements in the current dragged item
for (j=0; j < list.length; j++) {
if(list[j] === m[i].element[0]) {
m[i].proportions.height = 0;
m[i].proportions().height = 0;
continue droppablesLoop;
}
}
@@ -2181,8 +2198,8 @@ $.ui.ddmanager = {
m[i]._activate.call(m[i], event);
}
m[i].offset = m[i].element.offset();
m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight };
m[ i ].offset = m[ i ].element.offset();
m[ i ].proportions({ width: m[ i ].element[ 0 ].offsetWidth, height: m[ i ].element[ 0 ].offsetHeight });
}
@@ -2294,7 +2311,7 @@ function isNumber(value) {
}
$.widget("ui.resizable", $.ui.mouse, {
version: "1.10.3",
version: "1.10.4",
widgetEventPrefix: "resize",
options: {
alsoResize: false,
@@ -2563,7 +2580,7 @@ $.widget("ui.resizable", $.ui.mouse, {
//Store needed variables
this.offset = this.helper.offset();
this.position = { left: curleft, top: curtop };
this.size = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
this.size = this._helper ? { width: this.helper.width(), height: this.helper.height() } : { width: el.width(), height: el.height() };
this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
this.originalPosition = { left: curleft, top: curtop };
this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
@@ -3044,8 +3061,8 @@ $.ui.plugin.add("resizable", "containment", {
isParent = that.containerElement.get(0) === that.element.parent().get(0);
isOffsetRelative = /relative|absolute/.test(that.containerElement.css("position"));
if(isParent && isOffsetRelative) {
woset -= that.parentData.left;
if ( isParent && isOffsetRelative ) {
woset -= Math.abs( that.parentData.left );
}
if (woset + that.size.width >= that.parentData.width) {
@@ -3226,10 +3243,20 @@ $.ui.plugin.add("resizable", "grid", {
that.size.height = newHeight;
that.position.left = op.left - ox;
} else {
that.size.width = newWidth;
that.size.height = newHeight;
that.position.top = op.top - oy;
that.position.left = op.left - ox;
if ( newHeight - gridY > 0 ) {
that.size.height = newHeight;
that.position.top = op.top - oy;
} else {
that.size.height = gridY;
that.position.top = op.top + os.height - gridY;
}
if ( newWidth - gridX > 0 ) {
that.size.width = newWidth;
that.position.left = op.left - ox;
} else {
that.size.width = gridX;
that.position.left = op.left + os.width - gridX;
}
}
}
@@ -3240,7 +3267,7 @@ $.ui.plugin.add("resizable", "grid", {
(function( $, undefined ) {
$.widget("ui.selectable", $.ui.mouse, {
version: "1.10.3",
version: "1.10.4",
options: {
appendTo: "body",
autoRefresh: true,
@@ -3502,8 +3529,6 @@ $.widget("ui.selectable", $.ui.mouse, {
(function( $, undefined ) {
/*jshint loopfunc: true */
function isOverAxis( x, reference, size ) {
return ( x > reference ) && ( x < ( reference + size ) );
}
@@ -3513,7 +3538,7 @@ function isFloating(item) {
}
$.widget("ui.sortable", $.ui.mouse, {
version: "1.10.3",
version: "1.10.4",
widgetEventPrefix: "sort",
ready: false,
options: {
@@ -3854,12 +3879,12 @@ $.widget("ui.sortable", $.ui.mouse, {
}
// Only put the placeholder inside the current Container, skip all
// items form other containers. This works because when moving
// items from other containers. This works because when moving
// an item from one container to another the
// currentContainer is switched before the placeholder is moved.
//
// Without this moving items in "sub-sortables" can cause the placeholder to jitter
// beetween the outer and inner container.
// Without this, moving items in "sub-sortables" can cause
// the placeholder to jitter beetween the outer and inner container.
if (item.instance !== this.currentContainer) {
continue;
}
@@ -4127,10 +4152,11 @@ $.widget("ui.sortable", $.ui.mouse, {
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(function() {
items.push(this);
});
queries[i][0].each( addItems );
}
return $(items);
@@ -4688,12 +4714,17 @@ $.widget("ui.sortable", $.ui.mouse, {
//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) {
delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
if (!noPropagation) {
delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
}
if(this.containers[i].containerCache.over) {
delayedTriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
this.containers[i].containerCache.over = 0;
}
}
@@ -5656,7 +5687,7 @@ $.fn.extend({
(function() {
$.extend( $.effects, {
version: "1.10.3",
version: "1.10.4",
// Saves a set of properties in a data storage
save: function( element, set ) {
@@ -6063,7 +6094,7 @@ showProps.height = showProps.paddingTop = showProps.paddingBottom =
showProps.borderTopWidth = showProps.borderBottomWidth = "show";
$.widget( "ui.accordion", {
version: "1.10.3",
version: "1.10.4",
options: {
active: 0,
animate: {},
@@ -6141,6 +6172,7 @@ $.widget( "ui.accordion", {
this.headers
.removeClass( "ui-accordion-header ui-accordion-header-active ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
.removeAttr( "role" )
.removeAttr( "aria-expanded" )
.removeAttr( "aria-selected" )
.removeAttr( "aria-controls" )
.removeAttr( "tabIndex" )
@@ -6155,7 +6187,6 @@ $.widget( "ui.accordion", {
contents = this.headers.next()
.css( "display", "" )
.removeAttr( "role" )
.removeAttr( "aria-expanded" )
.removeAttr( "aria-hidden" )
.removeAttr( "aria-labelledby" )
.removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled" )
@@ -6206,7 +6237,6 @@ $.widget( "ui.accordion", {
},
_keydown: function( event ) {
/*jshint maxcomplexity:15*/
if ( event.altKey || event.ctrlKey ) {
return;
}
@@ -6333,11 +6363,11 @@ $.widget( "ui.accordion", {
.not( this.active )
.attr({
"aria-selected": "false",
"aria-expanded": "false",
tabIndex: -1
})
.next()
.attr({
"aria-expanded": "false",
"aria-hidden": "true"
})
.hide();
@@ -6348,11 +6378,11 @@ $.widget( "ui.accordion", {
} else {
this.active.attr({
"aria-selected": "true",
"aria-expanded": "true",
tabIndex: 0
})
.next()
.attr({
"aria-expanded": "true",
"aria-hidden": "false"
});
}
@@ -6507,7 +6537,6 @@ $.widget( "ui.accordion", {
}
toHide.attr({
"aria-expanded": "false",
"aria-hidden": "true"
});
toHide.prev().attr( "aria-selected", "false" );
@@ -6515,7 +6544,10 @@ $.widget( "ui.accordion", {
// 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
if ( toShow.length && toHide.length ) {
toHide.prev().attr( "tabIndex", -1 );
toHide.prev().attr({
"tabIndex": -1,
"aria-expanded": "false"
});
} else if ( toShow.length ) {
this.headers.filter(function() {
return $( this ).attr( "tabIndex" ) === 0;
@@ -6524,14 +6556,12 @@ $.widget( "ui.accordion", {
}
toShow
.attr({
"aria-expanded": "true",
"aria-hidden": "false"
})
.attr( "aria-hidden", "false" )
.prev()
.attr({
"aria-selected": "true",
tabIndex: 0
tabIndex: 0,
"aria-expanded": "true"
});
},
@@ -6603,7 +6633,6 @@ $.widget( "ui.accordion", {
if ( toHide.length ) {
toHide.parent()[0].className = toHide.parent()[0].className;
}
this._trigger( "activate", null, data );
}
});
@@ -6612,11 +6641,8 @@ $.widget( "ui.accordion", {
(function( $, undefined ) {
// used to prevent race conditions with remote data sources
var requestIndex = 0;
$.widget( "ui.autocomplete", {
version: "1.10.3",
version: "1.10.4",
defaultElement: "<input>",
options: {
appendTo: null,
@@ -6640,6 +6666,7 @@ $.widget( "ui.autocomplete", {
select: null
},
requestIndex: 0,
pending: 0,
_create: function() {
@@ -6673,7 +6700,6 @@ $.widget( "ui.autocomplete", {
this._on( this.element, {
keydown: function( event ) {
/*jshint maxcomplexity:15*/
if ( this.element.prop( "readOnly" ) ) {
suppressKeyPress = true;
suppressInput = true;
@@ -7016,19 +7042,18 @@ $.widget( "ui.autocomplete", {
},
_response: function() {
var that = this,
index = ++requestIndex;
var index = ++this.requestIndex;
return function( content ) {
if ( index === requestIndex ) {
that.__response( content );
return $.proxy(function( content ) {
if ( index === this.requestIndex ) {
this.__response( content );
}
that.pending--;
if ( !that.pending ) {
that.element.removeClass( "ui-autocomplete-loading" );
this.pending--;
if ( !this.pending ) {
this.element.removeClass( "ui-autocomplete-loading" );
}
};
}, this );
},
__response: function( content ) {
@@ -7207,9 +7232,8 @@ $.widget( "ui.autocomplete", $.ui.autocomplete, {
(function( $, undefined ) {
var lastActive, startXPos, startYPos, clickDragged,
var lastActive,
baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
stateClasses = "ui-state-hover ui-state-active ",
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 );
@@ -7236,7 +7260,7 @@ var lastActive, startXPos, startYPos, clickDragged,
};
$.widget( "ui.button", {
version: "1.10.3",
version: "1.10.4",
defaultElement: "<button>",
options: {
disabled: null,
@@ -7264,8 +7288,7 @@ $.widget( "ui.button", {
var that = this,
options = this.options,
toggleButton = this.type === "checkbox" || this.type === "radio",
activeClass = !toggleButton ? "ui-state-active" : "",
focusClass = "ui-state-focus";
activeClass = !toggleButton ? "ui-state-active" : "";
if ( options.label === null ) {
options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
@@ -7297,53 +7320,32 @@ $.widget( "ui.button", {
}
});
this.element
.bind( "focus" + this.eventNamespace, function() {
// no need to check disabled, focus won't be triggered anyway
that.buttonElement.addClass( focusClass );
})
.bind( "blur" + this.eventNamespace, function() {
that.buttonElement.removeClass( focusClass );
});
// Can't use _focusable() because the element that receives focus
// and the element that gets the ui-state-focus class are different
this._on({
focus: function() {
this.buttonElement.addClass( "ui-state-focus" );
},
blur: function() {
this.buttonElement.removeClass( "ui-state-focus" );
}
});
if ( toggleButton ) {
this.element.bind( "change" + this.eventNamespace, function() {
if ( clickDragged ) {
return;
}
that.refresh();
});
// if mouse moves between mousedown and mouseup (drag) set clickDragged flag
// prevents issue where button state changes but checkbox/radio checked state
// does not in Firefox (see ticket #6970)
this.buttonElement
.bind( "mousedown" + this.eventNamespace, function( event ) {
if ( options.disabled ) {
return;
}
clickDragged = false;
startXPos = event.pageX;
startYPos = event.pageY;
})
.bind( "mouseup" + this.eventNamespace, function( event ) {
if ( options.disabled ) {
return;
}
if ( startXPos !== event.pageX || startYPos !== event.pageY ) {
clickDragged = true;
}
});
}
if ( this.type === "checkbox" ) {
this.buttonElement.bind( "click" + this.eventNamespace, function() {
if ( options.disabled || clickDragged ) {
if ( options.disabled ) {
return false;
}
});
} else if ( this.type === "radio" ) {
this.buttonElement.bind( "click" + this.eventNamespace, function() {
if ( options.disabled || clickDragged ) {
if ( options.disabled ) {
return false;
}
$( this ).addClass( "ui-state-active" );
@@ -7453,7 +7455,7 @@ $.widget( "ui.button", {
this.element
.removeClass( "ui-helper-hidden-accessible" );
this.buttonElement
.removeClass( baseClasses + " " + stateClasses + " " + typeClasses )
.removeClass( baseClasses + " ui-state-active " + typeClasses )
.removeAttr( "role" )
.removeAttr( "aria-pressed" )
.html( this.buttonElement.find(".ui-button-text").html() );
@@ -7466,10 +7468,9 @@ $.widget( "ui.button", {
_setOption: function( key, value ) {
this._super( key, value );
if ( key === "disabled" ) {
this.element.prop( "disabled", !!value );
if ( value ) {
this.element.prop( "disabled", true );
} else {
this.element.prop( "disabled", false );
this.buttonElement.removeClass( "ui-state-focus" );
}
return;
}
@@ -7553,7 +7554,7 @@ $.widget( "ui.button", {
});
$.widget( "ui.buttonset", {
version: "1.10.3",
version: "1.10.4",
options: {
items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"
},
@@ -7613,7 +7614,7 @@ $.widget( "ui.buttonset", {
(function( $, undefined ) {
$.extend($.ui, { datepicker: { version: "1.10.3" } });
$.extend($.ui, { datepicker: { version: "1.10.4" } });
var PROP_NAME = "datepicker",
instActive;
@@ -9633,7 +9634,7 @@ $.fn.datepicker = function(options){
$.datepicker = new Datepicker(); // singleton instance
$.datepicker.initialized = false;
$.datepicker.uuid = new Date().getTime();
$.datepicker.version = "1.10.3";
$.datepicker.version = "1.10.4";
})(jQuery);
@@ -9656,7 +9657,7 @@ var sizeRelatedOptions = {
};
$.widget( "ui.dialog", {
version: "1.10.3",
version: "1.10.4",
options: {
appendTo: "body",
autoOpen: true,
@@ -9789,7 +9790,8 @@ $.widget( "ui.dialog", {
enable: $.noop,
close: function( event ) {
var that = this;
var activeElement,
that = this;
if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
return;
@@ -9799,10 +9801,22 @@ $.widget( "ui.dialog", {
this._destroyOverlay();
if ( !this.opener.filter(":focusable").focus().length ) {
// Hiding a focused element doesn't trigger blur in WebKit
// so in case we have nothing to focus on, explicitly blur the active element
// https://bugs.webkit.org/show_bug.cgi?id=47182
$( this.document[0].activeElement ).blur();
// support: IE9
// IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
try {
activeElement = this.document[ 0 ].activeElement;
// Support: IE9, IE10
// If the <body> is blurred, IE will switch windows, see #4520
if ( activeElement && activeElement.nodeName.toLowerCase() !== "body" ) {
// Hiding a focused element doesn't trigger blur in WebKit
// so in case we have nothing to focus on, explicitly blur the active element
// https://bugs.webkit.org/show_bug.cgi?id=47182
$( activeElement ).blur();
}
} catch ( error ) {}
}
this._hide( this.uiDialog, this.options.hide, function() {
@@ -9962,7 +9976,10 @@ $.widget( "ui.dialog", {
}
});
this.uiDialogTitlebarClose = $("<button></button>")
// support: IE
// Use type="button" to prevent enter keypresses in textboxes from closing the
// dialog in IE (#9312)
this.uiDialogTitlebarClose = $( "<button type='button'></button>" )
.button({
label: this.options.closeText,
icons: {
@@ -10176,7 +10193,6 @@ $.widget( "ui.dialog", {
},
_setOption: function( key, value ) {
/*jshint maxcomplexity:15*/
var isDraggable, isResizable,
uiDialog = this.uiDialog;
@@ -11420,7 +11436,7 @@ $.effects.effect.transfer = function( o, done ) {
(function( $, undefined ) {
$.widget( "ui.menu", {
version: "1.10.3",
version: "1.10.4",
defaultElement: "<ul>",
delay: 300,
options: {
@@ -11479,13 +11495,18 @@ $.widget( "ui.menu", {
"click .ui-menu-item:has(a)": function( event ) {
var target = $( event.target ).closest( ".ui-menu-item" );
if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
this.mouseHandled = true;
this.select( event );
// Only set the mouseHandled flag if the event will bubble, see #9469.
if ( !event.isPropagationStopped() ) {
this.mouseHandled = true;
}
// Open submenu on click
if ( target.has( ".ui-menu" ).length ) {
this.expand( event );
} else if ( !this.element.is( ":focus" ) ) {
} else if ( !this.element.is( ":focus" ) && $( this.document[ 0 ].activeElement ).closest( ".ui-menu" ).length ) {
// Redirect focus to the menu
this.element.trigger( "focus", [ true ] );
@@ -11578,7 +11599,6 @@ $.widget( "ui.menu", {
},
_keydown: function( event ) {
/*jshint maxcomplexity:20*/
var match, prev, character, skip, regex,
preventDefault = true;
@@ -11687,6 +11707,8 @@ $.widget( "ui.menu", {
icon = this.options.icons.submenu,
submenus = this.element.find( this.options.menus );
this.element.toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length );
// Initialize nested menus
submenus.filter( ":not(.ui-menu)" )
.addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
@@ -11787,7 +11809,7 @@ $.widget( "ui.menu", {
}
nested = item.children( ".ui-menu" );
if ( nested.length && ( /^mouse/.test( event.type ) ) ) {
if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
this._startOpening(nested);
}
this.activeMenu = item.parent();
@@ -12086,7 +12108,7 @@ $.position = {
return cachedScrollbarWidth;
}
var w1, w2,
div = $( "<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
div = $( "<div style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
innerDiv = div.children()[0];
$( "body" ).append( div );
@@ -12104,8 +12126,10 @@ $.position = {
return (cachedScrollbarWidth = w1 - w2);
},
getScrollInfo: function( within ) {
var overflowX = within.isWindow ? "" : within.element.css( "overflow-x" ),
overflowY = within.isWindow ? "" : within.element.css( "overflow-y" ),
var overflowX = within.isWindow || within.isDocument ? "" :
within.element.css( "overflow-x" ),
overflowY = within.isWindow || within.isDocument ? "" :
within.element.css( "overflow-y" ),
hasOverflowX = overflowX === "scroll" ||
( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
hasOverflowY = overflowY === "scroll" ||
@@ -12117,10 +12141,12 @@ $.position = {
},
getWithinInfo: function( element ) {
var withinElement = $( element || window ),
isWindow = $.isWindow( withinElement[0] );
isWindow = $.isWindow( withinElement[0] ),
isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9;
return {
element: withinElement,
isWindow: isWindow,
isDocument: isDocument,
offset: withinElement.offset() || { left: 0, top: 0 },
scrollLeft: withinElement.scrollLeft(),
scrollTop: withinElement.scrollTop(),
@@ -12452,7 +12478,7 @@ $.ui.position = {
}
}
else if ( overBottom > 0 ) {
newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || abs( newOverTop ) < overBottom ) ) {
position.top += myOffset + atOffset + offset;
}
@@ -12515,7 +12541,7 @@ $.ui.position = {
(function( $, undefined ) {
$.widget( "ui.progressbar", {
version: "1.10.3",
version: "1.10.4",
options: {
max: 100,
value: 0,
@@ -12651,7 +12677,7 @@ $.widget( "ui.progressbar", {
var numPages = 5;
$.widget( "ui.slider", $.ui.mouse, {
version: "1.10.3",
version: "1.10.4",
widgetEventPrefix: "slide",
options: {
@@ -12762,7 +12788,10 @@ $.widget( "ui.slider", $.ui.mouse, {
this.range.addClass( classes +
( ( options.range === "min" || options.range === "max" ) ? " ui-slider-range-" + options.range : "" ) );
} else {
this.range = $([]);
if ( this.range ) {
this.range.remove();
}
this.range = null;
}
},
@@ -12776,7 +12805,9 @@ $.widget( "ui.slider", $.ui.mouse, {
_destroy: function() {
this.handles.remove();
this.range.remove();
if ( this.range ) {
this.range.remove();
}
this.element
.removeClass( "ui-slider" +
@@ -12948,7 +12979,7 @@ $.widget( "ui.slider", $.ui.mouse, {
} );
otherVal = this.values( index ? 0 : 1 );
if ( allowed !== false ) {
this.values( index, newVal, true );
this.values( index, newVal );
}
}
} else {
@@ -13220,7 +13251,6 @@ $.widget( "ui.slider", $.ui.mouse, {
_handleEvents: {
keydown: function( event ) {
/*jshint maxcomplexity:25*/
var allowed, curVal, newVal, step,
index = $( event.target ).data( "ui-slider-handle-index" );
@@ -13316,7 +13346,7 @@ function modifier( fn ) {
}
$.widget( "ui.spinner", {
version: "1.10.3",
version: "1.10.4",
defaultElement: "<input>",
widgetEventPrefix: "spin",
options: {
@@ -13344,8 +13374,12 @@ $.widget( "ui.spinner", {
this._setOption( "min", this.options.min );
this._setOption( "step", this.options.step );
// format the value, but don't constrain
this._value( this.element.val(), true );
// 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 );
}
this._draw();
this._on( this._events );
@@ -13791,13 +13825,17 @@ function getNextTabId() {
}
function isLocal( anchor ) {
// support: IE7
// IE7 doesn't normalize the href property when set via script (#9317)
anchor = anchor.cloneNode( false );
return anchor.hash.length > 1 &&
decodeURIComponent( anchor.href.replace( rhash, "" ) ) ===
decodeURIComponent( location.href.replace( rhash, "" ) );
}
$.widget( "ui.tabs", {
version: "1.10.3",
version: "1.10.4",
delay: 300,
options: {
active: null,
@@ -13919,7 +13957,6 @@ $.widget( "ui.tabs", {
},
_tabKeydown: function( event ) {
/*jshint maxcomplexity:15*/
var focusedTab = $( this.document[0].activeElement ).closest( "li" ),
selectedIndex = this.tabs.index( focusedTab ),
goingForward = true;
@@ -14207,7 +14244,7 @@ $.widget( "ui.tabs", {
// allow overriding how to find the list for rare usage scenarios (#7715)
_getList: function() {
return this.element.find( "ol,ul" ).eq( 0 );
return this.tablist || this.element.find( "ol,ul" ).eq( 0 );
},
_createPanel: function( id ) {
@@ -14644,7 +14681,7 @@ function removeDescribedBy( elem ) {
}
$.widget( "ui.tooltip", {
version: "1.10.3",
version: "1.10.4",
options: {
content: function() {
// support: IE<9, Opera in jQuery <1.7
File diff suppressed because one or more lines are too long
+57
View File
@@ -0,0 +1,57 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Test jQuery integration.
*
* @package core
* @category phpunit
* @copyright 2014 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* This is not a complete jquery test, it just validates
* Moodle integration is set up properly.
*
* Launch http://127.0.0.1/lib/tests/other/jquerypage.php to
* verify it actually works in browser.
*
* @package core
* @category phpunit
* @copyright 2014 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class core_jquery_testcase extends basic_testcase {
public function test_plugins_file() {
global $CFG;
$plugins = null;
require($CFG->libdir . '/jquery/plugins.php');
$this->assertInternalType('array', $plugins);
$this->assertEquals(array('jquery', 'migrate', 'ui', 'ui-css'), array_keys($plugins));
foreach ($plugins as $type => $files) {
foreach ($files['files'] as $file) {
$this->assertFileExists($CFG->libdir . '/jquery/' . $file);
}
}
}
}
+103
View File
@@ -0,0 +1,103 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Produces a sample page using JQuery.
*
* @package core
* @copyright 20014 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require(dirname(__FILE__) . '/../../../config.php');
require_login();
$context = context_system::instance();
require_capability('moodle/site:config', $context);
$PAGE->set_url('/lib/tests/other/jquerypage.php');
$PAGE->set_context($context);
$PAGE->set_title('jQuery library test');
$PAGE->set_heading('jQuery library test');
$PAGE->requires->jquery();
$PAGE->requires->jquery_plugin('ui');
$PAGE->requires->jquery_plugin('ui-css');
$PAGE->requires->jquery_plugin('migrate');
echo $OUTPUT->header();
// Note: the example was copied from http://jqueryui.com/accordion/ page.
?>
<script>
$(function() {
$( "#accordion" ).accordion();
});
</script>
<div id="accordion">
<h3>Section 1</h3>
<div>
<p>
Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer
ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit
amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut
odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.
</p>
</div>
<h3>Section 2</h3>
<div>
<p>
Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet
purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor
velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In
suscipit faucibus urna.
</p>
</div>
<h3>Section 3</h3>
<div>
<p>
Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis.
Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero
ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis
lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui.
</p>
<ul>
<li>List item one</li>
<li>List item two</li>
<li>List item three</li>
</ul>
</div>
<h3>Section 4</h3>
<div>
<p>
Cras dictum. Pellentesque habitant morbi tristique senectus et netus
et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in
faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia
mauris vel est.
</p>
<p>
Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus.
Class aptent taciti sociosqu ad litora torquent per conubia nostra, per
inceptos himenaeos.
</p>
</div>
</div>
<?php
echo $OUTPUT->footer();
+2 -2
View File
@@ -193,7 +193,7 @@
<location>jquery</location>
<name>jQuery</name>
<license>MIT</license>
<version>1.10.2</version>
<version>1.11.0</version>
<licenseversion></licenseversion>
</library>
<library>
@@ -207,7 +207,7 @@
<location>jquery</location>
<name>jQuery UI</name>
<license>MIT</license>
<version>1.10.3</version>
<version>1.10.4</version>
<licenseversion></licenseversion>
</library>
<library>