1if (typeof UMS_DATA == 'undefined') var UMS_DATA = {}; 2if (isNumber(UMS_DATA.animationSpeed)) UMS_DATA.animationSpeed = parseInt(UMS_DATA.animationSpeed); 3else if (jQuery.inArray(UMS_DATA.animationSpeed, ['fast', 'slow']) == -1) UMS_DATA.animationSpeed = 'fast'; 4UMS_DATA.showSubscreenOnCenter = parseInt(UMS_DATA.showSubscreenOnCenter); 5var sdLoaderImgUms = '<img src="' + UMS_DATA.loader + '" />'; 6var g_umsAnimationSpeed = 300; 7 8jQuery.fn.showLoaderUms = function () { 9 return jQuery(this).html(sdLoaderImgUms); 10}; 11jQuery.fn.appendLoaderUms = function () { 12 jQuery(this).append(sdLoaderImgUms); 13}; 14jQuery.sendFormUms = function (params) { 15 // Any html element can be used here 16 return jQuery('<br />').sendFormUms(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.sendFormUms = 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('umsInputError'); 69 } 70 if (msgEl && !params.btn) { 71 jQuery(msgEl).removeClass('umsSuccessMsg').removeClass('umsErrorMsg').showLoaderUms(); 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 = UMS_DATA.ajaxurl; 84 else url = ajaxurl; 85 86 jQuery('.umsErrorForField').hide(UMS_DATA.animationSpeed); 87 var dataType = params.dataType ? params.dataType : 'json'; 88 // Set plugin orientation 89 if (typeof data == 'string') { 90 data += '&pl=' + UMS_DATA.UMS_CODE; 91 data += '&reqType=ajax'; 92 } else { 93 data['pl'] = UMS_DATA.UMS_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 toeProcessAjaxResponseUms(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(UMS_DATA.animationSpeed, function () { 122 jQuery(newContent).remove(); 123 }); 124}; 125/** 126 * Hide content in element and then remove it 127 */ 128jQuery.fn.animateRemoveUms = function (animationSpeed, onSuccess) { 129 animationSpeed = animationSpeed == undefined ? UMS_DATA.animationSpeed : animationSpeed; 130 jQuery(this).hide(animationSpeed, function () { 131 jQuery(this).remove(); 132 if (typeof onSuccess === 'function') onSuccess(); 133 }); 134}; 135function toeProcessAjaxResponseUms(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('umsInputError'); 147 }*/ 148 if (typeof res == 'object') { 149 if (res.error) { 150 if (msgEl) { 151 jQuery(msgEl).removeClass('umsSuccessMsg').addClass('umsErrorMsg'); 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('umsInputError'); 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('umsInputError'); 165 }) 166 .data('keyup-error-remove-binded', 1); 167 } 168 } 169 if (jQuery('.umsErrorForField.toe_' + nameToClassId(name) + '').exists()) 170 jQuery('.umsErrorForField.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('umsErrorMsg').addClass('umsSuccessMsg'); 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 getDialogElementUms() { 197 return jQuery('<div/>').appendTo(jQuery('body')); 198} 199 200function toeOptionUms(key) { 201 if (UMS_DATA.options && UMS_DATA.options[key] && UMS_DATA.options[key].value) return UMS_DATA.options[key].value; 202 return false; 203} 204function toeLangUms(key) { 205 if (UMS_DATA.siteLang && UMS_DATA.siteLang[key]) return UMS_DATA.siteLang[key]; 206 return key; 207} 208function toePagesUms(key) { 209 if (typeof UMS_DATA != 'undefined' && UMS_DATA[key]) return UMS_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 toeOptTimeoutHideDescriptionUms() { 216 jQuery('#umsOptDescription').removeAttr('toeFixTip'); 217 setTimeout(function () { 218 if (!jQuery('#umsOptDescription').attr('toeFixTip')) toeOptHideDescriptionUms(); 219 }, 500); 220} 221/** 222 * Show description for options 223 */ 224function toeOptShowDescriptionUms(description, x, y, moveToLeft) { 225 if (typeof description != 'undefined' && description != '') { 226 if (!jQuery('#umsOptDescription').length) { 227 jQuery('body').append('<div id="umsOptDescription"></div>'); 228 } 229 if (moveToLeft) jQuery('#umsOptDescription').css('right', jQuery(window).width() - (x - 10)); 230 // Show it on left side of target 231 else jQuery('#umsOptDescription').css('left', x + 10);
232 jQuery('#umsOptDescription').css('top', y); 233 jQuery('#umsOptDescription').show(200); 234 jQuery('#umsOptDescription').html(description); 235 } 236} 237/** 238 * Hide description for options 239 */ 240function toeOptHideDescriptionUms() { 241 jQuery('#umsOptDescription').removeAttr('toeFixTip'); 242 jQuery('#umsOptDescription').hide(200); 243} 244function toeInArrayUms(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("' + UMS_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 // TODO: Make it int values show on create 324 var value = typeof ui.value === 'undefined' ? jQuery('#toeSliderInput_' + id).val() : ui.value; 325 var units = value == 1 ? jQuery('#toeSliderDisplay_' + id).data('units') : jQuery('#toeSliderDisplay_' + id).data('units-plur'); 326 jQuery('#toeSliderDisplay_' + id).html(value + ' ' + units); 327 jQuery('#toeSliderInput_' + id) 328 .val(value) 329 .change(); 330} 331function setBrowserUrl(url) { 332 if (typeof history.pushState != 'undefined') { 333 var obj = { Title: document.title, Url: url }; 334 history.pushState(obj, obj.Title, obj.Url); 335 } 336} 337function createAjaxLinkUms(param) { 338 return UMS_DATA.ajaxurl + '?' + paramUms(param); 339} 340function paramUms(param) { 341 var param = jQuery.extend({}, param); 342 param['pl'] = UMS_DATA.UMS_CODE; 343 return jQuery.param(param); 344} 345/* TinyMCE Editor */ 346function umsGetTxtEditorVal(id) { 347 var elem = jQuery('#' + id), 348 content = typeof tinyMCE !== 'undefined' && tinyMCE.get(id) && !elem.is(':visible') ? tinyMCE.get(id).getContent() : elem.val(); 349 return content; 350} 351function umsSetTxtEditorVal(id, content) { 352 var elem = jQuery('#' + id); 353 354 if (typeof tinyMCE !== 'undefined' && tinyMCE && tinyMCE.get(id) && !elem.is(':visible')) { 355 tinyMCE.get(id).setContent(content); 356 } else { 357 elem.val(content); 358 } 359}
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.