1if(typeof(PTS_DATA) == 'undefined') 2 var PTS_DATA = {}; 3if(isFinite(PTS_DATA.animationSpeed)) 4 PTS_DATA.animationSpeed = parseInt(PTS_DATA.animationSpeed); 5else if(jQuery.inArray(PTS_DATA.animationSpeed, ['fast', 'slow']) == -1) 6 PTS_DATA.animationSpeed = 'fast'; 7PTS_DATA.showSubscreenOnCenter = parseInt(PTS_DATA.showSubscreenOnCenter); 8var sdLoaderImgPts = '<img src="'+ PTS_DATA.loader+ '" />'; 9var g_ptsAnimationSpeed = 300; 10 11jQuery.fn.showLoaderPts = function() { 12 return jQuery(this).html( sdLoaderImgPts ); 13}; 14jQuery.fn.appendLoaderPts = function() { 15 jQuery(this).append( sdLoaderImgPts ); 16}; 17jQuery.sendFormPts = function(params) { 18 // Any html element can be used here 19 return jQuery('<br />').sendFormPts(params); 20}; 21jQuery.fn.removeClassWild = function(mask) { 22 return this.removeClass(function(index, cls) { 23 var re = mask.replace(/\*/g, '\\S+'); 24 return (cls.match(new RegExp('\\b' + re + '', 'g')) || []).join(' '); 25 }); 26}; 27/** 28 * Send form or just data to server by ajax and route response 29 * @param string params.fid form element ID, if empty - current element will be used 30 * @param string params.msgElID element ID to store result messages, if empty - element with ID "msg" will be used. Can be "noMessages" to not use this feature 31 * @param function params.onSuccess funstion to do after success receive response. Be advised - "success" means that ajax response will be success 32 * @param array params.data data to send if You don't want to send Your form data, will be set instead of all form data 33 * @param array params.appendData data to append to sending request. In contrast to params.data will not erase form data 34 * @param string params.inputsWraper element ID for inputs wraper, will be used if it is not a form 35 * @param string params.clearMsg clear msg element after receive data, if is number - will use it to set time for clearing, else - if true - will clear msg element after 5 seconds 36 */ 37jQuery.fn.sendFormPts = function(params) { 38 var form = null; 39 if(!params) 40 params = {fid: false, msgElID: false, onSuccess: false}; 41 42 if(params.fid) 43 form = jQuery('#'+ fid); 44 else 45 form = jQuery(this); 46 47 /* This method can be used not only from form data sending, it can be used just to send some data and fill in response msg or errors*/ 48 var sentFromForm = (jQuery(form).tagName() == 'FORM'); 49 var data = new Array(); 50 if(params.data) 51 data = params.data; 52 else if(sentFromForm) 53 data = jQuery(form).serialize(); 54 55 params.errorClass = 'ptsErrorMsg'+ (params.errorClass ? ' '+ params.errorClass : ''); 56 params.successClass = 'ptsSuccessMsg'+ (params.successClass ? ' '+ params.successClass : ''); 57 58 if(params.appendData) { 59 var dataIsString = typeof(data) == 'string'; 60 var addStrData = []; 61 for(var i in params.appendData) { 62 if(dataIsString) { 63 addStrData.push(i+ '='+ params.appendData[i]); 64 } else 65 data[i] = params.appendData[i]; 66 } 67 if(dataIsString) 68 data += '&'+ addStrData.join('&'); 69 } 70 var msgEl = null; 71 if(params.msgElID) { 72 if(params.msgElID == 'noMessages') 73 msgEl = false;
74 else if(typeof(params.msgElID) == 'object') 75 msgEl = params.msgElID; 76 else 77 msgEl = jQuery('#'+ params.msgElID); 78 } 79 if(typeof(params.inputsWraper) == 'string') { 80 form = jQuery('#'+ params.inputsWraper); 81 sentFromForm = true; 82 } 83 if(sentFromForm && form) { 84 jQuery(form).find('*').removeClass('ptsInputError'); 85 } 86 if(msgEl && !params.btn) { 87 jQuery(msgEl) 88 .removeClass( params.errorClass ) 89 .removeClass( params.successClass ); 90 if(params.hideLoader) { 91 jQuery(msgEl).html(''); 92 } else { 93 jQuery(msgEl).showLoaderPts(); 94 } 95 } 96 if(params.btn) { 97 var btnWasDisabled = jQuery(params.btn).attr('disabled') ? true : false; 98 jQuery(params.btn).attr('disabled', 'disabled'); 99 // Font awesome usage 100 params.btnIconElement = jQuery(params.btn).find('.fa').length ? jQuery(params.btn).find('.fa') : jQuery(params.btn); 101 if(jQuery(params.btn).find('.fa').length) { 102 if(!btnWasDisabled) { 103 params.btnIconElement 104 .data('prev-class', params.btnIconElement.attr('class')); 105 } 106 params.btnIconElement 107 .attr('class', 'fa fa-spinner fa-spin'); 108 } 109 } 110 var url = ''; 111 if(typeof(params.url) != 'undefined') 112 url = params.url; 113 else if(typeof(ajaxurl) == 'undefined') 114 url = PTS_DATA.ajaxurl; 115 else 116 url = ajaxurl; 117 118 jQuery('.ptsErrorForField').hide(PTS_DATA.animationSpeed); 119 var dataType = params.dataType ? params.dataType : 'json'; 120 // Set plugin orientation 121 if(typeof(data) == 'string') { 122 data += '&pl='+ PTS_DATA.PTS_CODE; 123 data += '&reqType=ajax'; 124 } else { 125 data['pl'] = PTS_DATA.PTS_CODE; 126 data['reqType'] = 'ajax'; 127 } 128 if(params.onBeforeSend && typeof(params.onBeforeSend) === 'function') { 129 params.onBeforeSend(); 130 } 131 jQuery.ajax({ 132 url: url, 133 data: data, 134 type: 'POST', 135 dataType: dataType, 136 success: function(res) { 137 toeProcessAjaxResponsePts(res, msgEl, form, sentFromForm, params); 138 if(params.clearMsg) { 139 setTimeout(function(){ 140 if(msgEl) 141 jQuery(msgEl).animateClear(); 142 }, typeof(params.clearMsg) == 'boolean' ? 5000 : params.clearMsg); 143 } 144 } 145 }); 146}; 147/** 148 * Hide content in element and then clear it 149 */ 150jQuery.fn.animateClear = function() { 151 var newContent = jQuery('<span>'+ jQuery(this).html()+ '</span>'); 152 jQuery(this).html( newContent ); 153 jQuery(newContent).hide(PTS_DATA.animationSpeed, function(){ 154 jQuery(newContent).remove(); 155 }); 156}; 157/** 158 * Hide content in element and then remove it 159 */ 160jQuery.fn.animateRemovePts = function(animationSpeed, onSuccess) { 161 animationSpeed = animationSpeed == undefined ? PTS_DATA.animationSpeed : animationSpeed; 162 jQuery(this).hide(animationSpeed, function(){ 163 jQuery(this).remove(); 164 if(typeof(onSuccess) === 'function') 165 onSuccess(); 166 }); 167}; 168function toeProcessAjaxResponsePts(res, msgEl, form, sentFromForm, params) { 169 if(typeof(params) == 'undefined') 170 params = {}; 171 if(typeof(msgEl) == 'string') 172 msgEl = jQuery('#'+ msgEl); 173 if(msgEl) 174 jQuery(msgEl).html(''); 175 if(params.btn) { 176 jQuery(params.btn).removeAttr('disabled'); 177 if(params.btnIconElement) { 178 params.btnIconElement.attr('class', params.btnIconElement.data('prev-class')); 179 } 180 } 181 /*if(sentFromForm) { 182 jQuery(form).find('*').removeClass('ptsInputError'); 183 }*/ 184 if(typeof(res) == 'object') { 185 if(msgEl) { 186 msgEl.show(); // Make sure that it is visible 187 } 188 if(msgEl && params.msgCloseBtn) { 189 var closeBtn = jQuery('<button type="button" class="close" aria-label="Close"><span aria-hidden="true">×</span></button>'); 190 msgEl.append( closeBtn ); 191 closeBtn.click(function(){ 192 msgEl.slideUp(g_ptsAnimationSpeed, function(){ 193 msgEl.html(''); 194 }); 195 return false; 196 }); 197 } 198 if(res.error) { 199 if(msgEl) { 200 jQuery(msgEl) 201 .removeClass( params.successClass ) 202 .addClass( params.errorClass ); 203 } 204 var errorsArr = []; 205 for(var name in res.errors) { 206 if(sentFromForm) { 207 var inputError = jQuery(form).find('[name*="'+ name+ '"]'); 208 inputError.addClass('ptsInputError'); 209 if(inputError.attr('placeholder')) { 210 //inputError.attr('placeholder', res.errors[ name ]); 211 } 212 if(!inputError.data('keyup-error-remove-binded')) { 213 inputError.keydown(function(){ 214 jQuery(this).removeClass('ptsInputError'); 215 }).data('keyup-error-remove-binded', 1); 216 } 217 } 218 if(jQuery('.ptsErrorForField.toe_'+ nameToClassId(name)+ '').exists()) 219 jQuery('.ptsErrorForField.toe_'+ nameToClassId(name)+ '').show().html(res.errors[name]); 220 else if(msgEl) 221 jQuery(msgEl).append(res.errors[name]).append('<br />'); 222 else 223 errorsArr.push( res.errors[name] ); 224 } 225 if(errorsArr.length && params.btn && jQuery.fn.dialog) { 226 jQuery('<div title="'+ toeLangPts("Really small warning :)")+ '" />').html( errorsArr.join('<br />') ).appendTo('body').dialog({ 227 modal: true 228 , width: '500px' 229 , classes: { 230 "ui-dialog": "ptsCreateTableModal" 231 } 232 , dialogClass: 'ptsCreateTableModal', 233 }); 234 } 235 } else if(res.messages.length) { 236 if(msgEl) { 237 jQuery(msgEl) 238 .removeClass( params.errorClass ) 239 .addClass( params.successClass ); 240 for(var i = 0; i < res.messages.length; i++) { 241 jQuery(msgEl).append(res.messages[i]).append('<br />'); 242 } 243 } 244 } 245 } 246 if(params.onSuccess && typeof(params.onSuccess) == 'function') { 247 params.onSuccess(res); 248 } 249} 250 251function getDialogElementPts() { 252 return jQuery('<div/>').appendTo(jQuery('body')); 253} 254 255function toeOptionPts(key) { 256 if(PTS_DATA.options && PTS_DATA.options[ key ]) 257 return PTS_DATA.options[ key ]; 258 return false;
259} 260function toeLangPts(key) { 261 if(PTS_DATA.siteLang && PTS_DATA.siteLang[key]) 262 return PTS_DATA.siteLang[key]; 263 return key; 264} 265function toePagesPts(key) { 266 if(typeof(PTS_DATA) != 'undefined' && PTS_DATA[key]) 267 return PTS_DATA[key]; 268 return false;; 269} 270/** 271 * This function will help us not to hide desc right now, but wait - maybe user will want to select some text or click on some link in it. 272 */ 273function toeOptTimeoutHideDescriptionPts() { 274 jQuery('#ptsOptDescription').removeAttr('toeFixTip'); 275 setTimeout(function(){ 276 if(!jQuery('#ptsOptDescription').attr('toeFixTip')) 277 toeOptHideDescriptionPts(); 278 }, 500); 279} 280/** 281 * Show description for options 282 */ 283function toeOptShowDescriptionPts(description, x, y, moveToLeft) { 284 if(typeof(description) != 'undefined' && description != '') { 285 if(!jQuery('#ptsOptDescription').length) { 286 jQuery('body').append('<div id="ptsOptDescription"></div>'); 287 } 288 if(moveToLeft) 289 jQuery('#ptsOptDescription').css('right', jQuery(window).width() - (x - 10)); // Show it on left side of target 290 else 291 jQuery('#ptsOptDescription').css('left', x + 10); 292 jQuery('#ptsOptDescription').css('top', y); 293 jQuery('#ptsOptDescription').show(200); 294 jQuery('#ptsOptDescription').html(description); 295 } 296} 297/** 298 * Hide description for options 299 */ 300function toeOptHideDescriptionPts() { 301 jQuery('#ptsOptDescription').removeAttr('toeFixTip'); 302 jQuery('#ptsOptDescription').hide(200); 303} 304function toeInArrayPts(needle, haystack) { 305 if(haystack) { 306 for(var i in haystack) { 307 if(haystack[i] == needle) 308 return true; 309 } 310 } 311 return false; 312} 313function toeShowDialogCustomized(element, options) { 314 options = jQuery.extend({ 315 resizable: false 316 , width: 500 317 , height: 300 318 , closeOnEscape: true 319 , open: function(event, ui) { 320 jQuery('.ui-dialog-titlebar').css({ 321 'background-color': '#222222' 322 , 'background-image': 'none' 323 , 'border': 'none' 324 , 'margin': '0' 325 , 'padding': '0' 326 , 'border-radius': '0' 327 , 'color': '#CFCFCF' 328 , 'height': '27px' 329 }); 330 jQuery('.ui-dialog-titlebar-close').css({ 331 'background': 'url("'+ PTS_DATA.cssPath+ 'img/tb-close.png") no-repeat scroll 0 0 transparent' 332 , 'border': '0' 333 , 'width': '15px' 334 , 'height': '15px' 335 , 'padding': '0' 336 , 'border-radius': '0' 337 , 'margin': '7px 7px 0' 338 }).html(''); 339 jQuery('.ui-dialog').css({ 340 'border-radius': '3px' 341 , 'background-color': '#FFFFFF' 342 , 'background-image': 'none' 343 , 'padding': '1px' 344 , 'z-index': '300000' 345 , 'position': 'fixed' 346 , 'top': '60px' 347 }); 348 jQuery('.ui-dialog-buttonpane').css({ 349 'background-color': '#FFFFFF' 350 }); 351 jQuery('.ui-dialog-title').css({ 352 'color': '#CFCFCF' 353 , 'font': '12px sans-serif' 354 , 'padding': '6px 10px 0' 355 }); 356 if(options.openCallback && typeof(options.openCallback) == 'function') { 357 options.openCallback(event, ui); 358 } 359 jQuery('.ui-widget-overlay').css({ 360 'z-index': jQuery( event.target ).parents('.ui-dialog:first').css('z-index') - 1 361 , 'background-image': 'none' 362 }); 363 if(options.modal && options.closeOnBg) { 364 jQuery('.ui-widget-overlay').unbind('click').bind('click', function() { 365 jQuery( element ).dialog('close'); 366 }); 367 } 368 } 369 }, options); 370 return jQuery(element).dialog(options); 371} 372/** 373 * @see html::slider(); 374 **/ 375function toeSliderMove(event, ui) { 376 var id = jQuery(event.target).attr('id'); 377 jQuery('#toeSliderDisplay_'+ id).html( ui.value ); 378 jQuery('#toeSliderInput_'+ id).val( ui.value ).change(); 379} 380/** 381 * Javascript extend functionality 382 * @param {function/class} Child child elemnt for exnted 383 * @param {function/class} Parent parent elemnt to extend from 384 */ 385function extendPts(Child, Parent) { 386 var F = function() { }; 387 F.prototype = Parent.prototype; 388 Child.prototype = new F(); 389 Child.prototype.constructor = Child; 390 Child.superclass = Parent.prototype; 391}
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.