disable-selection.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*!
  2. * jQuery UI Disable Selection 1.14.1
  3. * https://jqueryui.com
  4. *
  5. * Copyright OpenJS Foundation and other contributors
  6. * Released under the MIT license.
  7. * https://jquery.org/license
  8. */
  9. //>>label: disableSelection
  10. //>>group: Core
  11. //>>description: Disable selection of text content within the set of matched elements.
  12. //>>docs: https://api.jqueryui.com/disableSelection/
  13. // This file is deprecated
  14. ( function( factory ) {
  15. "use strict";
  16. if ( typeof define === "function" && define.amd ) {
  17. // AMD. Register as an anonymous module.
  18. define( [ "jquery", "./version" ], factory );
  19. } else {
  20. // Browser globals
  21. factory( jQuery );
  22. }
  23. } )( function( $ ) {
  24. "use strict";
  25. return $.fn.extend( {
  26. disableSelection: ( function() {
  27. var eventType = "onselectstart" in document.createElement( "div" ) ?
  28. "selectstart" :
  29. "mousedown";
  30. return function() {
  31. return this.on( eventType + ".ui-disableSelection", function( event ) {
  32. event.preventDefault();
  33. } );
  34. };
  35. } )(),
  36. enableSelection: function() {
  37. return this.off( ".ui-disableSelection" );
  38. }
  39. } );
  40. } );