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