Core: Move plugin into its own module

Ref #9647
This commit is contained in:
Alexander Schmitz 2015-07-15 18:31:39 -04:00
parent 2d03e1280a
commit 0a9df3af52
4 changed files with 46 additions and 31 deletions

View File

@ -28,6 +28,7 @@
"./keycode",
"./labels",
"./jquery-1-7",
"./plugin",
"./version"
], factory );
} else {
@ -125,34 +126,4 @@ $.extend( $.expr[ ":" ], {
}
} );
// $.ui.plugin is deprecated. Use $.widget() extensions instead.
$.ui.plugin = {
add: function( module, option, set ) {
var i,
proto = $.ui[ module ].prototype;
for ( i in set ) {
proto.plugins[ i ] = proto.plugins[ i ] || [];
proto.plugins[ i ].push( [ option, set[ i ] ] );
}
},
call: function( instance, name, args, allowDisconnected ) {
var i,
set = instance.plugins[ name ];
if ( !set ) {
return;
}
if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
return;
}
for ( i = 0; i < set.length; i++ ) {
if ( instance.options[ set[ i ][ 0 ] ] ) {
set[ i ][ 1 ].apply( instance.element, args );
}
}
}
};
} ) );

View File

@ -23,6 +23,7 @@
"./core",
"./data",
"./mouse",
"./plugin",
"./version",
"./widget"
], factory );

43
ui/plugin.js Normal file
View File

@ -0,0 +1,43 @@
( function( factory ) {
if ( typeof define === "function" && define.amd ) {
// AMD. Register as an anonymous module.
define( [ "jquery", "./version" ], factory );
} else {
// Browser globals
factory( jQuery );
}
} ( function( $ ) {
// $.ui.plugin is deprecated. Use $.widget() extensions instead.
return $.ui.plugin = {
add: function( module, option, set ) {
var i,
proto = $.ui[ module ].prototype;
for ( i in set ) {
proto.plugins[ i ] = proto.plugins[ i ] || [];
proto.plugins[ i ].push( [ option, set[ i ] ] );
}
},
call: function( instance, name, args, allowDisconnected ) {
var i,
set = instance.plugins[ name ];
if ( !set ) {
return;
}
if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
return;
}
for ( i = 0; i < set.length; i++ ) {
if ( instance.options[ set[ i ][ 0 ] ] ) {
set[ i ][ 1 ].apply( instance.element, args );
}
}
}
};
} ) );

View File

@ -22,9 +22,9 @@
// AMD. Register as an anonymous module.
define([
"jquery",
"./core",
"./disable-selection",
"./mouse",
"./plugin",
"./version",
"./widget"
], factory );