1/** 2 * @project jquery.selection.js 3 * @author Vinicius Stutz <http://www.vinicius-stutz.com/> 4 * @version 1.0 of 29 Sep 2015 5 * @license Under the MIT license <http://opensource.org/licenses/MIT>. 6 * 7 * Description: Disabling or enabling text selection on web pages with jQuery. 8 * 9 * Usage: 10 * $('element').disableSelection(); to disable or 11 * $('element').enableSelection(); to enable 12 * 13 * Work with Firefox, Chrome, IE 8+, Opera and Safari. 14 */ 15 16(function ($) { 17 $.fn.disableSelection = function () { 18 return this 19 .attr('unselectable', 'on') 20 .css('user-select', 'none') 21 .css('-moz-user-select', 'none') 22 .css('-khtml-user-select', 'none') 23 .css('-webkit-user-select', 'none') 24 .on('selectstart', false) 25 .on('contextmenu', false) 26 .on('keydown', false) 27 .on('mousedown', false); 28 }; 29 $.fn.enableSelection = function () { 30 return this 31 .attr('unselectable', '') 32 .css('user-select', '') 33 .css('-moz-user-select', '') 34 .css('-khtml-user-select', '') 35 .css('-webkit-user-select', '') 36 .off('selectstart', false) 37 .off('contextmenu', false) 38 .off('keydown', false) 39 .off('mousedown', false); 40 }; 41})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.