1/******************************************************************************/ 2/** Global fresh library object, used across all our plugins and others. Here we 3 /** assign sub-libraries, important for other our stuff. It also cooperates with 4 /** jquery 5 /******************************************************************************/ 6"use strict"; 7 8// Safari bugfix 9Number.isNaN = Number.isNaN || function(value) { 10 return typeof value === "number" && value !== value; 11 } 12// Safari bugfix end 13 14var frslib = frslib || {}; 15//////////////////////////////////////////////////////////////////////////////// 16// FROM GOOGle CLOSURE 17//////////////////////////////////////////////////////////////////////////////// 18frslib.global = this; 19frslib.isDef = function(val) { 20 return val !== undefined; 21}; 22 23 24frslib.exportPath_ = function(name, opt_object, opt_objectToExportTo) { 25 var parts = name.split('.'); 26 var cur = opt_objectToExportTo || frslib.global; 27 28 // Internet Explorer exhibits strange behavior when throwing errors from 29 // methods externed in this manner. See the testExportSymbolExceptions in 30 // base_test.html for an example. 31 if (!(parts[0] in cur) && cur.execScript) { 32 cur.execScript('var ' + parts[0]); 33 } 34 35 // Certain browsers cannot parse code in the form for((a in b); c;); 36 // This pattern is produced by the JSCompiler when it collapses the 37 // statement above into the conditional loop below. To prevent this from 38 // happening, use a for-loop and reserve the init logic as below. 39 40 // Parentheses added to eliminate strict JS warning in Firefox. 41 for (var part; parts.length && (part = parts.shift());) { 42 if (!parts.length && frslib.isDef(opt_object)) { 43 // last part and we have an object; use it 44 cur[part] = opt_object; 45 } else if (cur[part]) { 46 cur = cur[part]; 47 } else { 48 cur = cur[part] = {}; 49 } 50 } 51}; 52 53frslib.provide = function( name ) { 54 return frslib.exportPath_(name); 55}; 56 57frslib.provide('frslib.identificators'); 58 59frslib.identificators._lastGeneratedId = null; 60frslib.identificators.generateUnique = function () { 61 var number = new Date().getTime() - new Date('2016-01-01').getTime(); 62 63 if( frslib.identificators._lastGeneratedId != null && frslib.identificators._lastGeneratedId >= number ) { 64 number = frslib.identificators._lastGeneratedId + 1; 65 } 66 var newId = number.toString( 32 ); 67 frslib.identificators._lastGeneratedId = number; 68 return newId; 69}; 70 71 72 73//////////////////////////////////////////////////////////////////////////////// 74// HTML FORMS 75//////////////////////////////////////////////////////////////////////////////// 76frslib.provide('frslib.htmlforms'); 77(function($){ 78 frslib.htmlforms.writeValueToCode = function( $selector ) { 79 $selector.find('input').each(function(){ 80 var val = $(this).val(); 81 $(this).attr('value', val); 82 83 if( $(this).attr('type') == 'checkbox' ) { 84 var checked = $(this).is(':checked'); 85 86 if( checked ) { 87 $(this).attr('checked', 'checked'); 88 } 89 else { 90 $(this).prop('checked', false); 91 $(this).removeAttr('checked'); 92 } 93 } 94 }); 95 } 96})(jQuery); 97//////////////////////////////////////////////////////////////////////////////// 98// CALLBACKS 99//////////////////////////////////////////////////////////////////////////////// 100frslib.provide('frslib.callbacks'); 101frslib.clone = function( object ) { 102 return JSON.parse( JSON.stringify( object )); 103}; 104 105frslib.stringToId = function( string ) { 106 return string.replace(/[^A-Za-z0-9]/g, ''); 107}; 108 109(function($){ 110 //console.log(frslib['htmlforms']['writeValueToCode']); 111 frslib.callbacks.functions = new Array(); 112 frslib.callbacks.addCallback = function( eventName, callback ) { 113 frslib.provide('frslib.callbacks.functions.'+eventName); 114 if( !(frslib.callbacks.functions[eventName] instanceof Array) ) { 115 frslib.callbacks.functions[eventName] = new Array(); 116 } 117 frslib.callbacks.functions[eventName].push(callback); 118 } 119 120 frslib.callbacks.doCallback = function( eventName ) { 121 if( !(eventName in frslib.callbacks.functions) ) { 122 return false; 123 } 124 125 var newArguments = new Array(); 126 127 for( var argumentsKey in arguments ) { 128 129 if( !Number.isNaN(argumentsKey) && argumentsKey > 0 ){ 130 newArguments[ argumentsKey-1 ] = arguments[ argumentsKey ]; 131 } 132 } 133 134 var output = {}; 135 136 for( var key in frslib.callbacks.functions[eventName] ) { 137 output[key] = frslib.callbacks.functions[eventName][key].apply( this,newArguments); 138 } 139 140 return output; 141 } 142 143 frslib.callbacks.callAllFunctionsFromArray = function( arrayOfFunctions ) { 144 var newArguments = Array(); 145 146 for( var argumentsKey in arguments ) { 147 if( !Number.isNaN(argumentsKey) && argumentsKey > 0 ){ 148 newArguments[ argumentsKey-1 ] = arguments[ argumentsKey ]; 149 } 150 } 151 152 var oneFunction; 153 if( arrayOfFunctions ){ 154 for( oneFunction in arrayOfFunctions ) { 155 if( arrayOfFunctions[ oneFunction ] ){ 156 arrayOfFunctions[ oneFunction ].apply( this, newArguments ); 157 } 158 } 159 } 160 } 161})(jQuery); 162 163//////////////////////////////////////////////////////////////////////////////// 164//COLORS
165//////////////////////////////////////////////////////////////////////////////// 166frslib.provide('frslib.colors'); 167frslib.provide('frslib.colors.convert'); 168frslib.provide('frslib.colors.type'); 169 170(function($){ 171 frslib.colors.convert.hexToRgb = function(hex) { 172 var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); 173 return result ? { 174 r: parseInt(result[1], 16), 175 g: parseInt(result[2], 16), 176 b: parseInt(result[3], 16) 177 } : null; 178 }; 179 180 frslib.colors.convert.hslToRgb = function(h, s, l){ 181 182 var r, g, b, m, c, x 183 184 if (!isFinite(h)) h = 0 185 if (!isFinite(s)) s = 0 186 if (!isFinite(l)) l = 0 187 188 h /= 60 189 if (h < 0) h = 6 - (-h % 6) 190 h %= 6 191 192 s = Math.max(0, Math.min(1, s / 100)) 193 l = Math.max(0, Math.min(1, l / 100)) 194 195 c = (1 - Math.abs((2 * l) - 1)) * s 196 x = c * (1 - Math.abs((h % 2) - 1)) 197 198 if (h < 1) { 199 r = c 200 g = x 201 b = 0 202 } else if (h < 2) { 203 r = x 204 g = c 205 b = 0 206 } else if (h < 3) { 207 r = 0 208 g = c 209 b = x 210 } else if (h < 4) { 211 r = 0 212 g = x 213 b = c 214 } else if (h < 5) { 215 r = x 216 g = 0 217 b = c 218 } else { 219 r = c 220 g = 0 221 b = x 222 } 223 224 m = l - c / 2 225 r = Math.round((r + m) * 255) 226 g = Math.round((g + m) * 255) 227 b = Math.round((b + m) * 255) 228 229 return { r: r, g: g, b: b } 230 231 }; 232 233 frslib.colors.convert.rgbToHsl = function (r, g, b){ 234 r /= 255, g /= 255, b /= 255; 235 var max = Math.max(r, g, b), min = Math.min(r, g, b); 236 var h, s, l = (max + min) / 2; 237 238 if(max == min){ 239 h = s = 0; // achromatic 240 }else{ 241 var d = max - min; 242 s = l > 0.5 ? d / (2 - max - min) : d / (max + min); 243 switch(max){ 244 case r: h = (g - b) / d + (g < b ? 6 : 0); break; 245 case g: h = (b - r) / d + 2; break; 246 case b: h = (r - g) / d + 4; break; 247 } 248 h /= 6; 249 } 250 251 return { h:Math.floor(h * 360), s:Math.floor(s * 100), b:Math.floor(l * 100) }; 252 }; 253 254 frslib.colors.convert.invalid ='color-is-invalid'; 255 256 frslib.colors.convert.toArray = function(color) { 257 258 var cache 259 , p = parseInt // Use p as a byte saving reference to parseInt 260 , color = color.replace(/\s\s*/g,'') // Remove all spaces 261 ;//var 262 263 var rgbaType = 0; 264 265 // Checks for 6 digit hex and converts string to integer 266 if (cache = /^#([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})/.exec(color)) 267 cache = [p(cache[1], 16), p(cache[2], 16), p(cache[3], 16)]; 268 269 // Checks for 3 digit hex and converts string to integer 270 else if (cache = /^#([\da-fA-F])([\da-fA-F])([\da-fA-F])/.exec(color)) 271 cache = [p(cache[1], 16) * 17, p(cache[2], 16) * 17, p(cache[3], 16) * 17]; 272 273 // Checks for rgba and converts string to 274 // integer/float using unary + operator to save bytes 275 else if (cache = /^rgba\(([\d]+),([\d]+),([\d]+),([\d]+|[\d]*.[\d]+)\)/.exec(color)) { 276 cache = [+cache[1], +cache[2], +cache[3], +cache[4]]; 277 rgbaType = 1; 278 } 279 280 // Checks for rgb and converts string to 281 // integer/float using unary + operator to save bytes 282 else if (cache = /^rgb\(([\d]+),([\d]+),([\d]+)\)/.exec(color)) 283 cache = [+cache[1], +cache[2], +cache[3]]; 284 285 // Otherwise throw an exception to make debugging easier 286 else { 287 return frslib.colors.convert.invalid; 288 } //throw Error(color + ' is not supported by $.parseColor'); 289 290 // Performs RGBA conversion by default 291 isNaN(cache[3]) && (cache[3] = 1); 292 293 // Adds or removes 4th value based on rgba support 294 // Support is flipped twice to prevent erros if 295 // it's not defined 296 var parsedColor = cache.slice(0,3 + rgbaType); 297 298 var toReturn = {}; 299 toReturn.r = parsedColor[0]; 300 toReturn.g = parsedColor[1]; 301 toReturn.b = parsedColor[2]; 302 303 if( rgbaType == 1 ) { 304 toReturn.a = parsedColor[3]; 305 } else { 306 toReturn.a = 1; 307 } 308 309 return toReturn; 310 311 } 312 313 314 frslib.colors.type.rgba = 'rgba'; 315 frslib.colors.type.rgb = 'rgb'; 316 frslib.colors.type.hex = 'hex'; 317 318 319 frslib.colors.type.identify = function( colorValue ) { 320 if( colorValue.toLowerCase().indexOf('rgba') != -1 ) { 321 return frslib.colors.type.rgba; 322 } else if( colorValue.toLowerCase().indexOf('rgb') != -1 ) { 323 return frslib.colors.type.rgb; 324 } else if( colorValue.indexOf('#') != -1 ) { 325 return frslib.colors.type.hex; 326 } 327 }; 328 329 frslib.colors.convert.rgbToHex = function (r,g,b) { 330 var rgb =b | (g << 8) | ( r << 16); 331 return '#' + (0x1000000 + rgb).toString(16).slice(1) 332 }; 333 334 frslib.colors.contrast = function ( colorValue ){ 335 336 if ( frslib.colors.type.hex == frslib.colors.type.identify( colorValue ) ){ 337 colorValue = colorValue.substr(1); 338 var r = parseInt(colorValue.substr(0,2),16); 339 var g = parseInt(colorValue.substr(2,2),16); 340 var b = parseInt(colorValue.substr(4,2),16); 341 var a = 1; 342 } else if ( frslib.colors.type.rgba == frslib.colors.type.identify( colorValue ) ){ 343 var pars = colorValue.indexOf(','); 344 var repars = colorValue.indexOf(',',pars+1); 345 var r = parseInt(colorValue.substr(5,pars)); 346 var g = parseInt(colorValue.substr(pars+1,repars)); 347 var b = parseInt(colorValue.substr(colorValue.indexOf(',',pars+1)+1,colorValue.indexOf(',',repars)
347)); 348 var a = parseFloat(colorValue.substr(colorValue.indexOf(',',repars+1)+1,colorValue.indexOf(')'))); 349 } else { 350 return frslib.colors.convert.invalid; 351 } 352 353 // http://stackoverflow.com/questions/726549/algorithm-for-additive-color-mixing-for-rgb-values 354 355 var bg = { R : 0.9, G : 0.9, B : 0.9, A : 1.00 }; 356 var fg = { R : 1/255*r, G : 1/255*g, B : 1/255*b, A : a }; 357 var r = {}; 358 r.A = 1 - (1 - fg.A) * (1 - bg.A); 359 // console.log('r.A = ' , r.A); 360 // if (r.A < 1.0e-6) return r; // Fully transparent -- R,G,B not important 361 r.R = fg.R * fg.A / r.A + bg.R * bg.A * (1 - fg.A) / r.A; 362 r.G = fg.G * fg.A / r.A + bg.G * bg.A * (1 - fg.A) / r.A; 363 r.B = fg.B * fg.A / r.A + bg.B * bg.A * (1 - fg.A) / r.A; 364 365 var yiq = ((r.R*299)+(r.G*587)+(r.B*114))/1000; 366 return (yiq >= 140/255) ? 'black' : 'white'; 367 368 } 369 370 371 372 373})(jQuery); 374/**********************************************************************************************************************/ 375/* FRSLIB - attr 376 /**********************************************************************************************************************/ 377frslib.provide('frslib.attr'); 378 379frslib.attr.helper = function() { 380 this.attributes = {}; 381}; 382 383frslib.attr.helper.prototype = { 384 /** 385 * Set parameter and overwrite the original content, no matter what 386 */ 387 setParam: function( name, value ) { 388 this.attributes[name] = new Array(); 389 390 if( value instanceof Array ){ 391 this.attributes[ name ] = this.attributes[ name ].concat( value ); 392 } else { 393 this.attributes[ name ].push( value ); 394 } 395 }, 396 397 /** 398 * If param does not exists, set param, if do, add new value to the param 399 */ 400 addParam: function( name, value ) { 401 if( this.isParamSet( name ) ) { 402 if( value instanceof Array ){ 403 this.attributes[ name ] = this.attributes[ name ].concat( value ); 404 } else { 405 this.attributes[ name ].push( value ); 406 } 407 } else { 408 this.setParam( name, value ); 409 } 410 }, 411 412 addParamEsc: function( name, value ) { 413 value = this._escAttr( value ); 414 return this.addParam(name, value); 415 }, 416 417 _escAttr : function(s, preserveCR) { 418 preserveCR = preserveCR ? ' ' : '\n'; 419 return ('' + s) /* Forces the conversion to string. */ 420 .replace(/&/g, '&') /* This MUST be the 1st replacement. */ 421 .replace(/'/g, ''') /* The 4 other predefined entities, required. */ 422 .replace(/"/g, '"') 423 .replace(/</g, '<') 424 .replace(/>/g, '>') 425 /* 426 You may add other replacements here for HTML only 427 (but it's not necessary). 428 Or for XML, only if the named entities are defined in its DTD. 429 */ 430 .replace(/\r\n/g, preserveCR) /* Must be before the next replacement. */ 431 .replace(/[\r\n]/g, preserveCR); 432 ; 433 }, 434 435 isParamSet: function( name ) { 436 return this.attributes.hasOwnProperty( name ) && this.attributes[name] != null; 437 }, 438 439 removeParam: function() { 440 this.attributes[name] = null; 441 }, 442 443 getParamValueAsArray: function(name) { 444 return this.attributes[name]; 445 }, 446 447 getParamValueAsString: function( name, separator) { 448 if( separator == undefined ) { 449 separator = ' '; 450 } 451 452 return this.attributes[ name ].join( separator ); 453 454 }, 455 456 getParamString: function( name, separator ) { 457 return name + '="' + this.getParamValueAsString(name, separator ) + '"'; 458 }, 459 460 getAttrString: function( separator ) { 461 if( separator == undefined ) { 462 separator = ' '; 463 } 464 465 var name; 466 var toReturn = new Array(); 467 for( name in this.attributes ) { 468 toReturn.push( this.getParamString( name, separator ) ); 469 } 470 471 return toReturn.join(' '); 472 }, 473}; 474 475frslib.attr.createHelper = function() { 476 return new frslib.attr.helper(); 477} 478 479frslib.attr.escAttr = function(s, preserveCR) { 480 preserveCR = preserveCR ? ' ' : '\n'; 481 return ('' + s) /* Forces the conversion to string. */ 482 .replace(/&/g, '&') /* This MUST be the 1st replacement. */ 483 .replace(/'/g, ''') /* The 4 other predefined entities, required. */ 484 .replace(/"/g, '"') 485 .replace(/</g, '<') 486 .replace(/>/g, '>') 487 /* 488 You may add other replacements here for HTML only 489 (but it's not necessary). 490 Or for XML, only if the named entities are defined in its DTD. 491 */ 492 .replace(/\r\n/g, preserveCR) /* Must be before the next replacement. */ 493 .replace(/[\r\n]/g, preserveCR); 494 ; 495}; 496 497// var fftmCanvasManager = function() { 498// this.$canvasIframe = null; 499// this.$canvas = null 500//} 501// 502//fftmCanvasManager.prototype = { 503// init : function() { 504// this._initSelectors(); 505// this.$canvasIframe.load( this._initIframe ); 506// }, 507 508
509//////////////////////////////////////////////////////////////////////////////// 510//AJAX 511//////////////////////////////////////////////////////////////////////////////// 512frslib.provide('frslib.ajax'); 513 514(function($){ 515 frslib.ajax.frameworkRequest = function( owner, specification, data, callback, completeCallback ) { 516 var processData = true; 517 518 if( specification != null && specification.processData != undefined ) { 519 processData = specification.processData; 520 } 521 522 $.ajax({ 523 type: 'POST', 524 url: ajaxurl, 525 data: { 526 'action':'ff_ajax', 527 'owner': owner, 528 'specification':specification, 529 'data':data, 530 531 }, 532 processData: processData, 533 success: function(response){ 534 if( response.indexOf('ff_ajax_dispatcher_response') != -1 ) { 535 536 var responseJSON = response.replace('ff_ajax_dispatcher_response', ''); 537 //console.log( responseJSON ); 538 var responseArray = JSON.parse( responseJSON ); 539 callback( responseArray ); 540 } else { 541 callback( response ); 542 } 543 544 }, 545 error: function( response, status, error ) { 546 console.log( response, status, error); 547 }, 548 complete: completeCallback 549 }); 550 551 }; 552 553 frslib.ajax.frameworkAdminScreenRequest = function( data, callback ) { 554 var specification = { 555 adminScreenName : $('.ff-view-identification').find('.admin-screen-name').html(), 556 adminViewName: $('.ff-view-identification').find('.admin-view-name').html(), 557 }; 558 559 560 frslib.ajax.frameworkRequest( 'ffAdminScreenManager', specification, data, function( response ){ 561 callback( response ); 562 }); 563 }; 564 565 frslib.ajax.adminScreenRequest = function( specification, data, callback ) { 566 567 // ff-view-identification admin-screen-name admin-view-name 568 var adminScreenName = $('.ff-view-identification').find('.admin-screen-name').html(); 569 var adminViewName =$('.ff-view-identification').find('.admin-view-name').html(); 570 571 var data = { 572 'adminScreenName' : adminScreenName, 573 'adminViewName' : adminViewName, 574 'specification' : specification, 575 'action' : 'ff_ajax_admin', 576 'data' : data 577 } 578 579 $.post( 580 ajaxurl, 581 data, 582 callback 583 ); 584 } 585 586 587 588})(jQuery); 589//////////////////////////////////////////////////////////////////////////////// 590//CONTACT FORM VALIDATION 591//////////////////////////////////////////////////////////////////////////////// 592frslib.provide('frslib.selectors'); 593 594(function($){ 595 596 frslib.selectors.findButNotInside = function( $element, selector){ 597 var origElement = $element; 598 599 return origElement.find(selector).filter(function() { 600 var nearestMatch = $(this).parent().closest(selector); 601 return nearestMatch.length == 0 || origElement.find(nearestMatch).length == 0; 602 }); 603 }; 604 605})(jQuery); 606 607 608frslib.provide('frslib.array'); 609 610(function($){ 611 612 /*----------------------------------------------------------*/ 613 /* next 614 /*----------------------------------------------------------*/ 615 frslib.array.next = function( items, oneItem ) { 616 var position = items.indexOf( oneItem ); 617 var newPosition = 0; 618 619 if( position + 1 < items.length ) { 620 newPosition = position+1; 621 } 622 623 return items[ newPosition ]; 624 }; 625 626 frslib.array.nextKey = function( items, oneItem ) { 627 var keys = Object.keys(items); 628 return frslib.array.next( keys, oneItem ); 629 }; 630 631 frslib.array.nextKeyValue = function( items, oneItem ) { 632 var nextKey = frslib.array.nextKey( items, oneItem); 633 return items[nextKey]; 634 }; 635 636 637 638 /*----------------------------------------------------------*/ 639 /* prev 640 /*----------------------------------------------------------*/ 641 frslib.array.prev = function( items, oneItem ) { 642 var position = items.indexOf( oneItem ); 643 var newPosition = items.length - 1; 644 645 if( position - 1 >= 0 ) { 646 newPosition = position - 1; 647 } 648 649 return items[ newPosition ]; 650 }; 651 652 frslib.array.prevKey = function( items, oneItem ) { 653 var keys = Object.keys(items); 654 return frslib.array.prev( keys, oneItem ); 655 }; 656 657 frslib.array.prevKeyValue = function( items, oneItem ) { 658 var prevKey = frslib.array.prevKey( items, oneItem); 659 return items[prevKey]; 660 }; 661 662 frslib.array.objectToArray = function( item ) { 663 return Object.keys(item).map(function (key) {return item[key]}).join(''); 664 }; 665 666 667 frslib.array.array_replace_recursive = function(arr) { // eslint-disable-line camelcase 668 // discuss at: http://locutus.io/php/array_replace_recursive/ 669 // original by: Brett Zamir (http://brett-zamir.me) 670 // example 1: array_replace_recursive({'citrus' : ['orange'], 'berries' : ['blackberry', 'raspberry']}, {'citrus' : ['pineapple'], 'berries' : ['blueberry']}) 671 // returns 1: {citrus : ['pineapple'], berries : ['blueberry', 'raspberry']} 672 var i = 0 673 var p = '' 674 var argl = arguments.length 675 var retObj 676 if (argl < 2) { 677 throw new Error('There should be at least 2 arguments passed to array_replace_recursive()') 678 } 679 // Although docs state that the arguments are passed in by reference, 680 // it seems they are not altered, but rather the copy that is returned 681 // So we make a copy here, instead of acting on arr itself 682 if (Object.prototype.toString.call(arr) === '[object Array]') { 683 retObj = [] 684 for (p in arr) { 685 retObj.push(arr[p]) 686 } 687 } else { 688 retObj = {} 689 for (p in arr) {
690 retObj[p] = arr[p] 691 } 692 } 693 for (i = 1; i < argl; i++) { 694 for (p in arguments[i]) { 695 if (retObj[p] && typeof retObj[p] === 'object') { 696 retObj[p] = frslib.array.array_replace_recursive(retObj[p], arguments[i][p]) 697 } else { 698 retObj[p] = arguments[i][p] 699 } 700 } 701 } 702 return retObj 703 }; 704 705 706 707})(jQuery); 708 709 710frslib.provide('frslib.clipboard'); 711 712(function($){ 713 frslib.clipboard.pasteFrom = function(){ 714 var clipboardValue = window.prompt('Paste your value here, from clipboard'); 715 716 return clipboardValue; 717 } 718 719 frslib.clipboard.copyTo = function (elem) { 720 // create hidden text element, if it doesn't already exist 721 var targetId = "_hiddenCopyText_"; 722 var isInput = false;//elem.tagName === "INPUT" || elem.tagName === "TEXTAREA"; 723 var origSelectionStart, origSelectionEnd; 724 //if (isInput) { 725 // can just use the original source element for the selection and copy 726 //target = elem; 727 //origSelectionStart = elem.selectionStart; 728 //origSelectionEnd = elem.selectionEnd; 729 //} else { 730 // must use a temporary form element for the selection and copy 731 target = document.getElementById(targetId); 732 if (!target) { 733 var target = document.createElement("textarea"); 734 // target.style.position = "absolute"; 735 // target.style.left = "-9999px"; 736 // target.style.top = "0"; 737 target.style.width = "0"; 738 target.style.height = "0"; 739 target.style.overflow = "hidden"; 740 target.style.position = "fixed"; 741 target.id = targetId; 742 document.body.appendChild(target); 743 } 744 target.textContent = elem;//elem.textContent; 745 //} 746 // select the content 747 var currentFocus = document.activeElement; 748 target.focus(); 749 target.setSelectionRange(0, target.value.length); 750 751 // copy the selection 752 var succeed; 753 try { 754 succeed = document.execCommand("copy"); 755 } catch(e) { 756 console.log( e ); 757 succeed = false; 758 759 } 760 // restore original focus 761 if (currentFocus && typeof currentFocus.focus === "function") { 762 currentFocus.focus(); 763 } 764 765 console.log( 'xxx' + succeed); 766 767 if( succeed == false || succeed == 'false' ) { 768 769 if (document.createRange) { 770 // IE9 and modern browsers 771 var r = document.createRange(); 772 r.setStartBefore(elem); 773 r.setEndAfter(elem); 774 r.selectNode(elem); 775 var sel = window.getSelection(); 776 sel.addRange(r); 777 document.execCommand('Copy'); // does nothing on FF 778 } else { 779 // IE 8 and earlier. This stuff won't work on IE9. 780 // (unless forced into a backward compatibility mode, 781 // or selecting plain divs, not img or table). 782 var r = document.body.createTextRange(); 783 r.moveToElementText(elem); 784 r.select() 785 r.execCommand('Copy'); 786 } 787 788 } 789 790 //if (isInput) { 791 // restore prior selection 792 //elem.setSelectionRange(origSelectionStart, origSelectionEnd); 793 //} else { 794 // clear temporary content 795 target.textContent = ""; 796 //} 797 return succeed; 798 } 799})(jQuery); 800 801 802frslib.provide('frslib.messages'); 803 804(function($){ 805 806 frslib.messages.broadcast = function( message ) { 807 localStorage.setItem('ff_message',JSON.stringify(message)); 808 localStorage.removeItem('ff_message'); 809 }; 810 811 frslib.messages.listeners = new Array(); 812 813 frslib.messages.addListener = function( listener) { 814 frslib.messages.listeners.push( listener ); 815 }; 816 817 frslib.messages.mainListener = function(event){ 818 if (event.originalEvent.key!='ff_message') return; // ignore other keys 819 var message=JSON.parse(event.originalEvent.newValue); 820 if (!message) return; // ignore empty msg or msg reset 821 822 for( var key in frslib.messages.listeners ) { 823 var oneListener = frslib.messages.listeners[ key ]; 824 oneListener( message ); 825 } 826 }; 827 828 $(window).on('storage', frslib.messages.mainListener ); 829 830})(jQuery); 831 832 833 834frslib.provide('frslib.serialize'); 835 836 837 838(function($){ 839 frslib.serialize.form = function( $form ) { 840 841 var serializedArray = $form.serializeArray(); 842 843 var data = {}; 844 845 var setData = function( route, value ) { 846 847 var pointer = data; 848 849 var routeLength = Object.keys(route).length 850 851 var counter = 0; 852 for( var id in route ) { 853 counter++; 854 855 var key = route[id]; 856 857 if( pointer[key] == undefined ) { 858 pointer[key] = {}; 859 } 860 861 if( counter == routeLength ) { 862 pointer[key] = value; 863 } else { 864 var swap = pointer[key]; 865 pointer = swap; 866 } 867 868 } 869 }; 870 871 for( var key in serializedArray ) { 872 var oneInput = serializedArray[ key ]; 873 var routeNotSplitted = oneInput.name; 874 var value = oneInput.value; 875 876 var find = ']'; 877 var re = new RegExp(find, 'g'); 878 879 880 881 var routeSplitted = ( routeNotSplitted.replace(re, '').split('[') ); 882 883 setData( routeSplitted, value); 884 } 885 886 return data; 887 } 888})(jQuery); 889 890 891frslib.provide('frslib.validator'); 892 893(function($){ 894 frslib.validator.email = function( value ) { 895 var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/; 896 return filter.test( value ); 897 }; 898 899 frslib.validator.isNumber = function( value ) { 900 return /^[0-9]+$/.test(value); 901 }; 902})(jQuery); 903 904 905frslib.provide('frslib.text'); 906 907 908 909(function($){ 910 frslib.text.onlyAlphaNumeric = function( toReplace ) { 911 return toReplace.replace(/[^a-z0-9 ]/gi,''); 912 }; 913 914 frslib.text.replaceAll = function( string, findMe, replace ) { 915 916 }; 917})(jQuery); 918/*! 919 * jquery.base64.js 0.0.3 - https://github.com/yckart/jquery.base64.js 920 * Makes Base64 en & -decoding simpler as it is. 921 * 922 * Based upon: https://gist.github.com/Yaffle/1284012 923 * 924 * Copyright (c) 2012 Yannick Albert (http://yckart.com) 925 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php). 926 * 2013/02/10 927 **/ 928;(function($) { 929 930 var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
930+/", 931 a256 = '', 932 r64 = [256], 933 r256 = [256], 934 i = 0; 935 936 var UTF8 = { 937 938 /** 939 * Encode multi-byte Unicode string into utf-8 multiple single-byte characters 940 * (BMP / basic multilingual plane only) 941 * 942 * Chars in range U+0080 - U+07FF are encoded in 2 chars, U+0800 - U+FFFF in 3 chars 943 * 944 * @param {String} strUni Unicode string to be encoded as UTF-8 945 * @returns {String} encoded string 946 */ 947 encode: function(strUni) { 948 // use regular expressions & String.replace callback function for better efficiency 949 // than procedural approaches 950 var strUtf = strUni.replace(/[\u0080-\u07ff]/g, // U+0080 - U+07FF => 2 bytes 110yyyyy, 10zzzzzz 951 function(c) { 952 var cc = c.charCodeAt(0); 953 return String.fromCharCode(0xc0 | cc >> 6, 0x80 | cc & 0x3f); 954 }) 955 .replace(/[\u0800-\uffff]/g, // U+0800 - U+FFFF => 3 bytes 1110xxxx, 10yyyyyy, 10zzzzzz 956 function(c) { 957 var cc = c.charCodeAt(0); 958 return String.fromCharCode(0xe0 | cc >> 12, 0x80 | cc >> 6 & 0x3F, 0x80 | cc & 0x3f); 959 }); 960 return strUtf; 961 }, 962 963 /** 964 * Decode utf-8 encoded string back into multi-byte Unicode characters 965 * 966 * @param {String} strUtf UTF-8 string to be decoded back to Unicode 967 * @returns {String} decoded string 968 */ 969 decode: function(strUtf) { 970 // note: decode 3-byte chars first as decoded 2-byte strings could appear to be 3-byte char! 971 var strUni = strUtf.replace(/[\u00e0-\u00ef][\u0080-\u00bf][\u0080-\u00bf]/g, // 3-byte chars 972 function(c) { // (note parentheses for precence) 973 var cc = ((c.charCodeAt(0) & 0x0f) << 12) | ((c.charCodeAt(1) & 0x3f) << 6) | (c.charCodeAt(2) & 0x3f); 974 return String.fromCharCode(cc); 975 }) 976 .replace(/[\u00c0-\u00df][\u0080-\u00bf]/g, // 2-byte chars 977 function(c) { // (note parentheses for precence) 978 var cc = (c.charCodeAt(0) & 0x1f) << 6 | c.charCodeAt(1) & 0x3f; 979 return String.fromCharCode(cc); 980 }); 981 return strUni; 982 } 983 }; 984 985 while(i < 256) { 986 var c = String.fromCharCode(i); 987 a256 += c; 988 r256[i] = i; 989 r64[i] = b64.indexOf(c); 990 ++i; 991 } 992 993 function code(s, discard, alpha, beta, w1, w2) { 994 s = String(s); 995 var buffer = 0, 996 i = 0, 997 length = s.length, 998 result = '', 999 bitsInBuffer = 0; 1000 1001 while(i < length) { 1002 var c = s.charCodeAt(i); 1003 c = c < 256 ? alpha[c] : -1; 1004 1005 buffer = (buffer << w1) + c; 1006 bitsInBuffer += w1; 1007 1008 while(bitsInBuffer >= w2) { 1009 bitsInBuffer -= w2; 1010 var tmp = buffer >> bitsInBuffer; 1011 result += beta.charAt(tmp); 1012 buffer ^= tmp << bitsInBuffer; 1013 } 1014 ++i; 1015 } 1016 if(!discard && bitsInBuffer > 0) result += beta.charAt(buffer << (w2 - bitsInBuffer)); 1017 return result; 1018 } 1019 1020 var Plugin = $.base64 = function(dir, input, encode) { 1021 return input ? Plugin[dir](input, encode) : dir ? null : this; 1022 }; 1023 1024 Plugin.btoa = Plugin.encode = function(plain, utf8encode) { 1025 plain = Plugin.raw === false || Plugin.utf8encode || utf8encode ? UTF8.encode(plain) : plain; 1026 plain = code(plain, false, r256, b64, 8, 6); 1027 return plain + '===='.slice((plain.length % 4) || 4); 1028 }; 1029 1030 Plugin.atob = Plugin.decode = function(coded, utf8decode) { 1031 coded = coded.replace(/[^A-Za-z0-9\+\/\=]/g, ""); 1032 coded = String(coded).split('='); 1033 var i = coded.length; 1034 do {--i; 1035 coded[i] = code(coded[i], true, r64, a256, 6, 8); 1036 } while (i > 0); 1037 coded = coded.join(''); 1038 return Plugin.raw === false || Plugin.utf8decode || utf8decode ? UTF8.decode(coded) : coded; 1039 }; 1040}(jQuery)); 1041 1042 1043jQuery.fn.serializeObject = function() { 1044 var json = {}; 1045 jQuery.map(jQuery(this).serializeArray(), function(n, i) { 1046 var _ = n.name.indexOf('['); 1047 if (_ > -1) { 1048 var o = json; 1049 var _name = n.name.replace(/\]/gi, '').split('['); 1050 for (var i=0, len=_name.length; i<len; i++) { 1051 if (i == len-1) { 1052 if (o[_name[i]]) { 1053 if (typeof o[_name[i]] == 'string') { 1054 o[_name[i]] = [o[_name[i]]]; 1055 } 1056 o[_name[i]].push(n.value); 1057 } 1058 else o[_name[i]] = n.value || ''; 1059 } 1060 else o = o[_name[i]] = o[_name[i]] || {}; 1061 } 1062 } 1063 else { 1064 if (json[n.name] !== undefined) { 1065 if (!json[n.name].push) { 1066 json[n.name] = [json[n.name]]; 1067 } 1068 json[n.name].push(n.value || ''); 1069 } 1070 else json[n.name] = n.value || ''; 1071 } 1072 }); 1073 return json; 1074}; 1075 1076/* 1077 * jQuery.bind-first library v0.2.3 1078 * Copyright (c) 2013 Vladimir Zhuravlev 1079 * 1080 * Released under MIT License 1081 * @license 1082 * 1083 * Date: Thu Feb 6 10:13:59 ICT 2014 1084 **/ 1085 1086(function($) { 1087 var splitVersion = $.fn.jquery.split("."); 1088 var major = parseInt(splitVersion[0]); 1089 var minor = parseInt(splitVersion[1]); 1090 1091 var JQ_LT_17 = (major < 1) || (major == 1 && minor < 7); 1092 1093 function eventsData($el) { 1094 return JQ_LT_17 ? $el.data('events') : $._data($el[0]).events; 1095 } 1096 1097 function moveHandlerToTop($el, eventName, isDelegated) { 1098 var data = eventsData($el); 1099 var events = data[eventName]; 1100 1101 if (!JQ_LT_17) { 1102 var handler = isDelegated ? events.splice(events.delegateCount - 1, 1)[0] : events.pop(); 1103 events.splice(isDelegated ? 0 : (events.delegateCount || 0), 0, handler); 1104 1105 return; 1106 } 1107 1108 if (isDelegated) { 1109 data.live.unshift(data.live.pop()); 1110 } else { 1111 events.unshift(events.pop()); 1112 } 1113 } 1114 1115 function moveEventHandlers($elems, eventsString, isDelegate) { 1116 var events = eventsString.split(/\s+/); 1117 $elems.each(function() { 1118 for (var i = 0; i < events.length; ++i) { 1119 var pureEventName = $.trim(events[i]).match(/[^\.]+/i)[0]; 1120 moveHandlerToTop($(this), pureEventName, isDelegate); 1121 } 1122 }); 1123 } 1124 1125 function makeMethod(methodName) { 1126 $.fn[methodName + 'First'] = function() { 1127 var args = $.makeArray(arguments); 1128 var eventsString = args.shift(); 1129 1130 if (eventsString) { 1131 $.fn[methodName].apply(this, arguments); 1132 moveEventHandlers(this, eventsString); 1133 } 1134 1135 return this; 1136 } 1137 } 1138 1139 // bind 1140 makeMethod('bind'); 1141 1142 // one 1143 makeMethod('one'); 1144 1145 // delegate 1146 $.fn.delegateFirst = function() { 1147 var args = $.makeArray(arguments); 1148 var eventsString = args[1]; 1149 1150 if (eventsString) { 1151 args.splice(0, 2); 1152 $.fn.delegate.apply(this, arguments); 1153 moveEventHandlers(this, eventsString, true); 1154 } 1155 1156 return this; 1157 }; 1158 1159 // live 1160 $.fn.liveFirst = function() { 1161 var args = $.makeArray(arguments); 1162 1163 // live = delegate to the document 1164 args.unshift(this.selector); 1165 $.fn.delegateFirst.apply($(document), args); 1166 1167 return this; 1168 }; 1169 1170 // on (jquery >= 1.7) 1171 if (!JQ_LT_17) { 1172 $.fn.onFirst = function(types, selector) { 1173 var $el = $(this); 1174 var isDelegated = typeof selector === 'string'; 1175 1176 $.fn.on.apply($el, arguments); 1177 1178 // events map 1179 if (typeof types === 'object') { 1180 var type; 1181 for (type in types) 1182 if (types.hasOwnProperty(type)) { 1183 moveEventHandlers($el, type, isDelegated); 1184 } 1185 } else if (typeof types === 'string') { 1186 moveEventHandlers($el, types, isDelegated); 1187 } 1188 1189 return $el; 1190 }; 1191 } 1192 1193})(jQuery); 1194 1195(function($){ 1196 1197 1198 jQuery.fn.extend({findButNotInside : function(selector) { 1199 var origElement = $(this); 1200 return origElement.find(selector).filter(function() { 1201 var nearestMatch = $(this).parent().closest(selector); 1202 return nearestMatch.length == 0 || origElement.find(nearestMatch).length == 0; 1203 }); 1204 }}); 1205 1206})(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.