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