1void function ( exports, $, _, Backbone ) { 2 3 $("body").on("click", "[type=toggle]", function ( e ) { 4 e.preventDefault(); 5 $(this).attr('data-on', $(this).attr('data-on') == "true" ? false : true).trigger('change'); 6 }); 7 8 $.fn.getBoundingBox = function () { 9 var top = 0, left = 0, right = 0, bottom = 0, width = 0, height = 0; 10 var rects = this.map(function () { 11 return this.getBoundingClientRect() 12 }).toArray(); 13 if (rects.length) { 14 top = Math.min.apply(null, _.pluck(rects, 'top')); 15 left = Math.min.apply(null, _.pluck(rects, 'left')); 16 right = Math.max.apply(null, _.pluck(rects, 'right')); 17 bottom = Math.max.apply(null, _.pluck(rects, 'bottom')); 18 height = bottom - top; 19 width = right - left; 20 } 21 return { 22 top: top, 23 left: left, 24 width: width, 25 height: height 26 }; 27 }; 28 $.getImageThumb = function( src, width, height, callback ) { 29 if (!src) 30 return; 31 var canvas = document.createElement('canvas'); 32 33 canvas.width = width; 34 canvas.height = height || width; 35 36 var context = ccc=canvas.getContext('2d'); 37 var imageObj = new Image(); 38 39 imageObj.onload = function() { 40 // draw cropped image 41 42 var sourceWidth = this.width; 43 var sourceHeight = this.height; 44 45 var destWidth = canvas.width; 46 var destHeight = canvas.height; 47 48 var destX = 0.5; 49 var destY = 0.5; 50 51 var sourceRatio = sourceWidth / sourceHeight; 52 var destRatio = destWidth / destHeight; 53 54 if (sourceRatio > destRatio) { 55 destWidth *= destRatio; 56 } 57 else { 58 destHeight *= destRatio; 59 } 60 destX = canvas.width/2 - destWidth/2 + 0.5; 61 destY = canvas.height/2 - destHeight/2 + 0.5; 62 63 context.drawImage(imageObj, 0, 0, sourceWidth, sourceHeight, destX, destY, destWidth, destHeight); 64 callback && callback(canvas.toDataURL()); 65 }; 66 imageObj.onerror = function() { 67 //console.log('error', src) 68 } 69 imageObj.crossOrigin = 'anonymous'; 70 imageObj.src = src; 71 } 72 73 $.fn.clickOutside = function ( callback, context ) { 74 return typeof callback != 'function' ? this : this.each(function ( index, element ) { 75 $(window).on('mousedown', function clickHandler ( e ) { 76 if ( !$(element).is(e.target) && !$(e.target).parents('.' + $(element).attr('class').replace(/\s+/g, '.')).length ) 77 $(window).off('mousedown', clickHandler), 78 callback.call(context, e); 79 }); 80 }); 81 } 82 $.fn.selectText = function () { 83 var range, selection; 84 return this.each(function () { 85 if ( document.body.createTextRange ) { 86 range = document.body.createTextRange(); 87 range.moveToElementText(this); 88 range.select(); 89 } else if ( window.getSelection ) { 90 selection = window.getSelection(); 91 range = document.createRange(); 92 range.selectNodeContents(this); 93 selection.removeAllRanges(); 94 selection.addRange(range); 95 } 96 }); 97 }; 98 $.fn.deselectText = function () { 99 var selection; 100 return this.each(function () { 101 if ( window.getSelection ) { 102 if ( window.getSelection().empty ) { // Chrome 103 window.getSelection().empty(); 104 } else if ( window.getSelection().removeAllRanges ) { // Firefox 105 window.getSelection().removeAllRanges(); 106 } 107 } else if ( document.selection ) { // IE? 108 document.selection.empty(); 109 } 110 }); 111 }; 112 $.fn.setCaretPosition = function ( pos ) { 113 var range; 114 return this.each(function () { 115 var elem = this; 116 if ( elem.createTextRange ) { 117 range = elem.createTextRange(); 118 range.move('character', pos); 119 range.select(); 120 } else { 121 elem.focus(); 122 if ( typeof elem.selectionStart !== 'undefined' ) { 123 elem.setSelectionRange(pos, pos); 124 } 125 } 126 }); 127 } 128 $.fn.getCaretPosition = function () { 129 if ( !this.length ) 130 return null; 131 var input = this.get(0); 132 if ( !input ) return; // No (input) element found 133 if ( document.selection ) { 134 // IE 135 input.focus(); 136 } 137 return 'selectionStart' in input ? input.selectionStart : '' || Math.abs(document.selection.createRange().moveStart('character', -input.value.length)); 138 } 139 $.fn.ES_WrapLetters = function( before, after ) { 140 return this.each( function() { 141 $( this ).html( $( this ).text().replace( /(<[^>]*>)?([^<]*)(<[^>
141]*>)?/g, function( string, x, text, y ) { 142 return _(!text.trim() ? '' : (x || '') + text.trim().split( '' )).map( function( letter ) { 143 return before + letter + after; 144 } ).join( '' ) + (y || ''); 145 } ) ); 146 } ); 147 }; 148 $.fn.ES_WrapWords = function( before, after ) { 149 return this.each( function() { 150 $( this ).html( $( this ).text().replace( /(<[^>]*>)?([^<]*)(<[^>]*>)?/g, function( string, x, text, y ) { 151 return _(!text.trim() ? '' : (x || '') + text.trim().split( /\s+/ )).map( function( word ) { 152 return before + word + after; 153 } ).join( ' ' ) + (y || ''); 154 } ) ); 155 } ); 156 }; 157 158}(this, jQuery, _, Backbone); 159 160void function ( exports, $, _, Backbone ) { 161 162 function setCaretPosition ( elem, pos ) { 163 var range; 164 if ( elem.createTextRange ) { 165 range = elem.createTextRange(); 166 range.move('character', pos); 167 range.select(); 168 } else { 169 elem.focus(); 170 if ( typeof elem.selectionStart !== 'undefined' ) { 171 elem.setSelectionRange(pos, pos); 172 } 173 } 174 } 175 176 function getCaretPosition ( input ) { 177 if ( document.selection ) { 178 // IE 179 input.focus(); 180 } 181 return 'selectionStart' in input ? input.selectionStart : '' || Math.abs(document.selection.createRange().moveStart('character', -input.value.length)); 182 } 183 184 function parseNumberUnit ( str ) { 185 str += ''; 186 var match = str.replace(/\s+/, ' ').match(/([-0-9.]+)\s?([^\s]*)?/); 187 return match && { 188 number: parseFloat(match[ 1 ]), 189 unit: match[ 2 ] 190 } 191 } 192 193 function spinValue ( $el, direction, page ) { 194 var value = $el.val(); 195 var min = parseFloat($el.attr('min')); 196 var max = parseFloat($el.attr('max')); 197 var step = Math.abs($el.attr('step') || 1); 198 var decimal = parseInt($el.attr('decimal')); 199 if ( !decimal ) { 200 decimal = step == step.toFixed() ? 0 : step.toString().split('.')[ 1 ].length; 201 } 202 203 var parsedValue = parseNumberUnit(value); 204 if ( !parsedValue ) { 205 parsedValue = { 206 num: 0, unit: '' 207 } 208 } 209 210 var num = parsedValue.number || 0; 211 var unit = parsedValue.unit || $el.attr('unit') || ''; 212 if ( typeof num !== 'number' ) return; 213 214 !page || (step *= 10); 215 216 switch ( direction ) { 217 case 'up': 218 num += step; 219 break; 220 case 'down': 221 num -= step; 222 break; 223 } 224 if ( direction == 'down' && min !== NaN && num < min ) 225 num = min; 226 if ( direction == 'up' && max !== NaN && num > max ) 227 num = max; 228 !decimal || (num = num.toFixed(decimal)) 229 !unit || (num += unit); 230 $el.val(num).trigger('change'); 231 } 232 233 $.fn.ES_NumberInput = function () { 234 return this.each(function () { 235 var $el = $(this); 236 var $parent = $el.parent(); 237 var $stepper = $el.next('.stepper'); 238 239 if ( !$stepper.length ) { 240 $stepper = $('<span class="input-group-addon stepper"><a class="up"></a><a class="down"></a></span>'); 241 } 242 if ( !$parent.is('.input-group') ) { 243 $parent = $('<div class="input-group">'); 244 $el.before($parent); 245 } 246 247 $parent.addClass('input-number-wrapper') 248 .on('mousedown', '.up', function ( e ) { 249 e.preventDefault(); 250 spinValue($el, 'up'); 251 }) 252 .on('mousedown', '.down', function ( e ) { 253 e.preventDefault(); 254 spinValue($el, 'down') 255 }); 256 257 $el.addClass('input-number') 258 .attr('type', 'text') 259 .attr('spellcheck', 'false') 260 .attr('autocomplete', 'off') 261 .on('keydown', function ( e ) { 262 var caretPos = getCaretPosition(this); 263 switch ( e.keyCode ) { 264 case 38: 265 spinValue($el, 'up', e.shiftKey); 266 break; 267 case 40: 268 spinValue($el, 'down', e.shiftKey); 269 break; 270 } 271 if ( e.keyCode == 38 || e.keyCode == 40 ) { 272 e.preventDefault(); 273 setCaretPosition(this, caretPos); 274 } 275 }); 276 277 $el.appendTo($parent); 278 $el.after($stepper); 279 }); 280 }; 281 282 $.fn.ES_ColorInput = function () { 283 return this.each(function () { 284 var $el = $(this); 285 var $parent = $('<div class="input-group input-color-wrapper">'); 286 var $remove = $('<span class="input-group-btn remove-color"><a class="btn btn-default btn-sm"><span class="fa fa-close"></span></a></span>'); 287 288 $remove.on('click', function ( e ) { 289 e.preventDefault(); 290 $el.val('').trigger('change:color'); 291 }); 292 293 $el.before($parent) 294 .appendTo($parent) 295 .after($remove); 296 }); 297 }; 298 299 $.fn.ES_ImageInput = function () { 300 return this.each(function () { 301 var $input = $(this); 302 var $parent = $('<div class="input-group input-image-wrapper">'); 303 var $select = $('<span class="input-group-btn"><a class="btn btn-default btn-sm input-image-select-btn"><span class="fa fa-folder-open"></span></a></span>'); 304 var $upload = $('<span class="input-group-btn"><a class="btn btn-default btn-sm input-image-upload-btn"><span class="fa fa-upload"></span></a></span>'); 305 var $clear = $('<span class="input-group-btn"><a class="btn btn-default btn-sm input-image-clear-btn"><span class="fa fa-close"></span></a></span>'); 306 307 $clear.click(function () { 308 $input.val() && $input.val('').trigger('change'); 309 }); 310 $select.click(function () { 311 $.ES_MediaSelector(function ( url ) { 312 $input.val(url).trigger('change'); 313 }); 314 }); 315 $input 316 .before($parent) 317 .appendTo($parent) 318 .after($clear) 319 //.after($upload) 320 .after($select); 321 }); 322 }; 323 324 $.fn.ES_VideoInput = function () { 325 326 }; 327 328 $.fn.ES_SelectBox = function () { 329 330 }; 331 332 $.ES_Prompt = function ( message, callback ) { 333 var reponse = prompt(message); 334 typeof callback == 'function' && callback(reponse); 335 }; 336 337 $.ES_MediaSelector = function ( callback ) { 338 339 window.jInsertEditorText = function ( value ) { 340 var regex = /<img.*?src="(.*?)"/; 341 var url = regex.exec(value)[ 1 ]; 342 typeof callback == 'function' && callback(url, { value: value }); 343 }; 344 345 window.jModalClose = function () { 346 $('.es-media-selector').addClass('hidden'); 347 } 348 349 var $iframe = $('.es-media-selector iframe'); 350 if ( !$iframe.prop('src') ) 351 $iframe.prop('src', 'index.php?option=com_media&view=images&tmpl=component'); 352 else { 353 $($iframe.get(0).contentDocument) 354 .find('#system-message-container') 355 .remove() 356 .trigger('load'); 357 } 358 $iframe 359 .off('load') 360 .on('load', function () { 361 var frameHeight = Math.min(window.innerHeight, this.contentDocument.body.scrollHeight); 362 var maxHeight = (frameHeight == this.contentDocument.body.scrollHeight); 363 $(this.contentDocument.body) 364 .css({ 365 'margin': '0', 366 'padding': '10px', 367 'overflow': maxHeight ? 'hidden' : 'scroll', 368 'box-sizing': 'border-box' 369 }); 370 $('.es-media-selector') 371 .css('height', frameHeight + 'px') 372 }); 373 374 $('.es-media-selector') 375 .removeClass('hidden') 376 .clickOutside(window.jModalClose); 377 }; 378 379}(this, jQuery, _, Backbone);
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.