disable-selection.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*!
  2. * jQuery UI Disable Selection 1.12.1
  3. * http://jqueryui.com
  4. *
  5. * Copyright jQuery Foundation and other contributors
  6. * Released under the MIT license.
  7. * http://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: http://api.jqueryui.com/disableSelection/
  13. // This file is deprecated
  14. ( function( factory ) {
  15. if ( typeof define === "function" && define.amd ) {
  16. // AMD. Register as an anonymous module.
  17. define( [ "jquery", "./version" ], factory );
  18. } else {
  19. // Browser globals
  20. factory( jQuery );
  21. }
  22. } ( function( $ ) {
  23. return $.fn.extend( {
  24. disableSelection: ( function() {
  25. var eventType = "onselectstart" in document.createElement( "div" ) ?
  26. "selectstart" :
  27. "mousedown";
  28. return function() {
  29. return this.on( eventType + ".ui-disableSelection", function( event ) {
  30. event.preventDefault();
  31. } );
  32. };
  33. } )(),
  34. enableSelection: function() {
  35. return this.off( ".ui-disableSelection" );
  36. }
  37. } );
  38. } ) );