From 4916487440b0c087e6e5996522cf478af26df591 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Wed, 15 Jul 2015 16:49:34 -0400 Subject: [PATCH] Core: Move disable-selection into its own module Ref #9647 --- ui/core.js | 22 +++----------------- ui/disable-selection.js | 46 +++++++++++++++++++++++++++++++++++++++++ ui/resizable.js | 3 ++- 3 files changed, 51 insertions(+), 20 deletions(-) create mode 100644 ui/disable-selection.js diff --git a/ui/core.js b/ui/core.js index 6cf599964..1072e89f1 100644 --- a/ui/core.js +++ b/ui/core.js @@ -21,7 +21,9 @@ define( [ "jquery", "./data", - "./version" ], factory ); + "./disable-selection", + "./version" + ], factory ); } else { // Browser globals @@ -284,24 +286,6 @@ if ( $.fn.jquery.substring( 0, 3 ) === "1.7" ) { // deprecated $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() ); -$.fn.extend( { - disableSelection: ( function() { - var eventType = "onselectstart" in document.createElement( "div" ) ? - "selectstart" : - "mousedown"; - - return function() { - return this.on( eventType + ".ui-disableSelection", function( event ) { - event.preventDefault(); - } ); - }; - } )(), - - enableSelection: function() { - return this.off( ".ui-disableSelection" ); - } -} ); - // $.ui.plugin is deprecated. Use $.widget() extensions instead. $.ui.plugin = { add: function( module, option, set ) { diff --git a/ui/disable-selection.js b/ui/disable-selection.js new file mode 100644 index 000000000..aa6df0173 --- /dev/null +++ b/ui/disable-selection.js @@ -0,0 +1,46 @@ +/*! + * jQuery UI Disable Selection @VERSION + * http://jqueryui.com + * + * Copyright jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + */ + +//>>label: disableSelection +//>>group: Core +//>>description: Disable selection of text content within the set of matched elements. +//>>docs: http://api.jqueryui.com/disableSelection/ + +// This file is deprecated +( function( factory ) { + if ( typeof define === "function" && define.amd ) { + + // AMD. Register as an anonymous module. + define( [ "jquery", "./version" ], factory ); + } else { + + // Browser globals + factory( jQuery ); + } +} ( function( $ ) { + +return $.fn.extend( { + disableSelection: ( function() { + var eventType = "onselectstart" in document.createElement( "div" ) ? + "selectstart" : + "mousedown"; + + return function() { + return this.on( eventType + ".ui-disableSelection", function( event ) { + event.preventDefault(); + } ); + }; + } )(), + + enableSelection: function() { + return this.off( ".ui-disableSelection" ); + } +} ); + +} ) ); diff --git a/ui/resizable.js b/ui/resizable.js index 6b4fd1013..1c0ad6ff1 100644 --- a/ui/resizable.js +++ b/ui/resizable.js @@ -23,8 +23,9 @@ define([ "jquery", "./core", - "./version", + "./disable-selection", "./mouse", + "./version", "./widget" ], factory ); } else {