1// JavaScript Document 2jQuery(document).ready(function () { 3 clearInterval(documentLoaded); 4 // if there's no "draggable" then something's wrong so load provided jquery ui 5 initializeFontPlugin(); 6}); 7// this won't run unless jquery is completely overwritten by some plugin 8var documentLoaded = setInterval(function () { 9 if(document.readyState === "complete") { 10 alert('Conflict with another plugin which overwrites jQuery'); 11 // stop checking if the document is laoded 12 clearInterval(documentLoaded); 13 } 14}, 100); 15 16function initializeFontPlugin () { 17 /* 18 show font plugin browser BUTTON 19 */ 20 jQuery('#FFW_chooseFontButton, #content_FFWButton, #wp-admin-bar-font_settings > a').bind('click', function (e) { 21 e.preventDefault(); 22 23 //if initialized already just toggle 24 if (jQuery('#fontplugin')[0] && jQuery('#fontplugin').data('fontPlugin') && jQuery('#fontplugin').data('fontPlugin').$presets) { 25 jQuery('#fontplugin').data('fontPlugin').$presets.fadeToggle(500); 26 } else { 27 window.onbeforeunload = function () { 28 return 'Have you saved the changes?'; 29 }; 30 31 //open jquery plugin 32 var fontPluginWrapper = jQuery('<div id="fontplugin" class="draggableModal"></div>'), 33 settings; 34 fontPluginWrapper.appendTo('body'); 35 settings = { 36 "settingFields": [ 37 { 38 "type": "text", 39 "label": "Selector", 40 "name": "selector", 41 "settingType": "general", 42 "settingName": "selector", 43 "extendWith": "selectorPicker" 44 }, 45 { 46 "type": "text", 47 "label": "Font size", 48 "name": "font-size", 49 "settingType": "css", 50 "settingName": "fontSize", 51 "extendWith": "slider", 52 "unit": "px" 53 }, 54 { 55 "type": "text", 56 "label": "Color", 57 "name": "color", 58 "settingType": "css", 59 "settingName": "color", 60 "extendWith": "colorPicker" 61 }] 62 }; 63 if(!jQuery.fontPlugin) { 64 jQuery.fn.fontPlugin = fontPlugin; 65 } 66 67 try { 68 fontPluginWrapper.fontPlugin(settings); 69 } catch (e) { 70 console.dir(e);
71 alert('The plugin cannot start because of an error. This is usually caused by a conflict with a poorly written plugin or a theme overwriting jQuery. Try disabling all other plugins and then see if the "Font" plugin works. If that works, enable them one by one to find the one, which is causing the conflict. If nothing helps copy this error and send to the plugin author: ' + e); 72 } 73 } 74 return false; 75 }); 76 77 // extend with object size 78 if(!Object.size) { 79 Object.size = function(obj) { 80 var size = 0, key; 81 for (key in obj) { 82 if (obj.hasOwnProperty(key)) size++; 83 } 84 return size; 85 }; 86 } 87 //make image colorpickable 88 /*function makeImagesColorpickable() { 89 var image = jQuery("#header1preview").contents().find('img'); 90 jQuery("#header1preview").contents().find('a').click(function () { 91 return false; 92 }); 93 image.click(function (e) { 94 var img = new Image(), 95 canvas, 96 context, 97 posX, 98 posY, 99 x, 100 y, 101 data, 102 color; 103 img.src = jQuery(this).attr('src'); 104 canvas = jQuery('<canvas id="canvas" style="display:none"></canvas>'); 105 canvas[0].setAttribute('width', jQuery(this).width()); 106 canvas[0].setAttribute('height', jQuery(this).height()); 107 jQuery('body').append(canvas); 108 context = document.getElementById('canvas').getContext('2d'); 109 context.drawImage(img, 0, 0); 110 posX = jQuery(this).offset().left; 111 posY = jQuery(this).offset().top; 112 x = Math.round(e.pageX - posX); 113 y = Math.round(e.pageY - posY); 114 data = context.getImageData(x, y, 1, 1).data; 115 color = dec2html(data[0]) + dec2html(data[1]) + dec2html(data[2]); 116 ffwSetFontColor('#' + color); 117 return false; 118 }); 119 //calculating functions 120 function dec2html(d) { 121 // Converts from decimal color value (0-255) to HTML-style (00-FF) 122 var hch = "0123456789ABCDEF", 123 a = d % 16, 124 b = (d - a) / 16; 125 return hch.charAt(b) + hch.charAt(a); 126 } 127 }*/ 128 // Escape regex chars with \ 129 RegExp.escapeX = function (text) { 130 return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); 131 }; 132 // The style function 133 jQuery.fn.style = function (styleName, value, priority) { 134 //console.log(styleName + ' - ' + value + ' - ' + priority); 135 var node, 136 style; 137 // For those who need them (< IE 9), add support for CSS functions 138 if (!CSSStyleDeclaration.prototype.getPropertyValue || !CSSStyleDeclaration.prototype.setProperty) { 139 CSSStyleDeclaration.prototype.getPropertyValue = function (a) { 140 return this.getAttribute(a); 141 }; 142 CSSStyleDeclaration.prototype.setProperty = function (styleName, value, priority) { 143 var rule; 144 priority = typeof priority !== undefined ? priority : ''; 145 this.setAttribute(styleName, value); 146 if (priority !== '') { 147 // Add priority manually 148 rule = new RegExp(RegExp.escapeX(styleName) + '\\s*:\\s*' + RegExp.escapeX(value) + '(\\s*;)?', 'gmi'); 149 this.cssText = this.cssText.replace(rule, styleName + ': ' + value + ' !' + priority + ';'); 150 } 151 }; 152 CSSStyleDeclaration.prototype.removeProperty = function (a) { 153 return this.removeAttribute(a); 154 }; 155 CSSStyleDeclaration.prototype.getPropertyPriority = function (styleName) { 156 var rule = new RegExp(RegExp.escapeX(styleName) + '\\s*:\\s*[^\\s]*\\s*!important(\\s*;)?', 'gmi'); 157 return rule.test(this.cssText) ? 'important' : ''; 158 }; 159 } 160 function camelToDash(str) { 161 return str.replace(/\W+/g, '-') 162 .replace(/([a-z\d])([A-Z])/g, '$1-$2'); 163 } 164 styleName = camelToDash(styleName); 165 // DOM node 166 node = this.get(0); 167 // Ensure we have a DOM node 168 if (typeof node === 'undefined') { 169 return; 170 } 171 // CSSStyleDeclaration 172 style = this.get(0).style; 173 // Getter/Setter 174 if (styleName !== undefined) { 175 if (value !== undefined) { 176 // Set style property 177 priority = priority !== undefined ? priority : ''; 178 //console.log(styleName + ', ' + value + ', ' + priority) 179 style.setProperty(styleName, value, priority); 180 } else { 181 // Get style property 182 return style.getPropertyValue(styleName); 183 } 184 } else { 185 // Get CSSStyleDeclaration 186 return style; 187 } 188 }; 189 if(!jQuery.fn.inlineStyle) { 190 jQuery.fn.inlineStyle = function (prop) { 191 return this.prop("style")[jQuery.camelCase(prop)]; 192 }; 193 } 194 (function ($) {
195 $.fn.removePrefixedClasses = function (prefix) { 196 if(!$(this).attr('class')) return; 197 var classNames = $(this).attr('class').split(' '), 198 className, 199 newClassNames = [], 200 i; 201 //loop class names 202 for(i = 0; i < classNames.length; i++) { 203 className = classNames[i]; 204 // if prefix not found at the beggining of class name 205 if(className.indexOf(prefix) !== 0) { 206 newClassNames.push(className); 207 continue; 208 } 209 } 210 // write new list excluding filtered classNames 211 $(this).attr('class', newClassNames.join(' ')); 212 }; 213 }(jQuery)); 214 215 if(!jQuery.fn.animateRotate) { 216 jQuery.fn.animateRotate = function(angle, duration, easing, complete) { 217 return this.each(function() { 218 var $elem = jQuery(this); 219 var currentRotationAngle = $elem.data('rotation'); 220 if(currentRotationAngle === undefined) { 221 currentRotationAngle = 0; 222 } 223 $elem.data('rotation', angle); 224 225 jQuery({deg: currentRotationAngle}).animate({deg: angle}, { 226 duration: duration, 227 easing: easing, 228 step: function(now) { 229 230 $elem.css({ 231 transform: 'rotate(' + now + 'deg)' 232 }); 233 }, 234 complete: complete || jQuery.noop 235 }); 236 }); 237 }; 238 } 239}
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.