1function setSelRange(inputEl, selStart, selEnd) { 2 if($(inputEl).attr('contenteditable')){ 3 var range,selection; 4 if(document.createRange)//Firefox, Chrome, Opera, Safari, IE 9+ 5 { 6 range = document.createRange();//Create a range (a range is a like the selection but invisible) 7 range.selectNodeContents(inputEl);//Select the entire contents of the element with the range 8 range.collapse(true);//collapse the range to the end point. false means collapse to end rather than the start 9 selection = window.getSelection();//get the selection object (allows you to change selection) 10 selection.removeAllRanges();//remove any selections already made 11 selection.addRange(range);//make the range you have just created the visible selection 12 } 13 else if(document.selection)//IE 8 and lower 14 { 15 range = document.body.createTextRange();//Create a range (a range is a like the selection but invisible) 16 range.moveToElementText(inputEl);//Select the entire contents of the element with the range 17 range.collapse(true);//collapse the range to the end point. false means collapse to end rather than the start 18 range.select();//Select the range (make it the visible selection 19 } 20 } else { 21 if (inputEl.setSelectionRange) { 22 inputEl.focus(); 23 inputEl.setSelectionRange(selStart, selEnd); 24 } else if (inputEl.createTextRange) { 25 var range = inputEl.createTextRange(); 26 range.collapse(true); 27 range.moveEnd('character', selEnd); 28 range.moveStart('character', selStart); 29 range.select(); 30 } 31 } 32} 33 34onInputFocus=function(e){ 35 var $input=$(this).find('input'); 36 var $this=$(this); 37 if($input.length==0) $input=$this; 38 39 if($input.val().trim()==$this.attr('default').trim()){ 40 $input.val(''); 41 $this.removeClass('idle'); 42 } 43} 44 45onInputBlur=function(e){ 46 var $input=$(this).find('input'); 47 var $this=$(this); 48 if($input.length==0) $input=$(this); 49 50 if($input.val().trim()==''){ 51 $input.val($this.attr('default')); 52 $this.addClass('idle'); 53 } 54} 55 56jQuery.fn.extend({ 57 inpdv:function(options){ 58 return this.each(function(){ 59 $(this).bind('keydown copy paste', onInputFocus).bind('blur change', onInputBlur).bind('focus click', function(){ 60 var $input=$(this).find('input'); 61 var $this=$(this); 62 if($input.length==0) $input=$this; 63 64 if($input.val().trim()==$this.attr('default').trim()){ 65 setSelRange($input.get(0), 0, 0); 66 } 67 }); 68 }); 69 } 70});
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.