1;(function($, undefined) { 2 3$.extend( $.createOOPlugin = function(plgName, extend, proto) { 4 var Class = $.createOOPlugin.Class, Super = $.createOOPlugin.Super; 5 if ($.fn[plgName]) return console.error(plgName+" plugin already exists!"); 6 if (Class[extend]) { // extend class 7 var sup = Class[Super[plgName] = extend].prototype; 8 extend = $.extend(true, {_stack: {}}, sup); 9 for (var prop in sup) if (typeof sup[prop] === "function") 10 extend[prop] = new Function("return this.Super('"+prop+"', arguments)"); 11 extend.Super = function(fn, args) { 12 var ret, stack = this._stack[fn] = this._stack[fn] || [], 13 parent = Super[stack[stack.length-1] || this.plugin]; 14 stack.push(parent); 15 if (Class[parent].prototype[fn]) 16 ret = Class[parent].prototype[fn].apply(this, args); 17 else console.error(fn, " method not exists!"); 18 stack.pop(); 19 return ret; 20 }; 21 } 22 Class[plgName] = function() {this.Constructor.apply(this, arguments)}; 23 Class[plgName].prototype = $.extend(extend, proto, {plugin: plgName}); 24 $.fn[plgName] = function() { // create plugin 25 var args = arguments, arg0 = Array.prototype.shift.call(args) || {}; 26 return this.length == 1? iterator.call(this) : this.each(iterator); 27 function iterator() { 28 var $this = $(this), instance = $this.data(plgName); 29 if (instance) // call method 30 if (instance[arg0] && instance[arg0].apply) 31 return instance[arg0].apply(instance, args); 32 else return console.error(arg0, " method not exists!"); 33 if (typeof arg0 === "object") { // create instance 34 arg0.id = plgName + $.createOOPlugin.Id++; 35 arg0.$node = $this; 36 var plg = plgName, obj = new Class[plg](arg0); 37 do $this.data(plg, obj); 38 while (plg = Super[plg]); 39 } 40 return $this; 41 } 42 }; 43}, {Class: {}, Super: {}, Id: 0}); 44 45window.isMobileOrTablet = function() { 46 var check = false; 47 (function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))) check = true;})(navigator.userAgent||navigator.vendor||window.opera); 48 return check; 49}(); 50 51$.fn.absolute = function() { 52 var pos = this.offset(); 53 if ($().jquery.split(".")[1] < 10) { 54 if ($.fn.absolute.bt === undefined) { 55 var $body = $(document.body); 56 $.fn.absolute.bt = parseInt($body.css("borderTopWidth")) || 0; 57 $.fn.absolute.bl = parseInt($body.css("borderLeftWidth")) || 0; 58 } 59 pos.top += $.fn.absolute.bt; 60 pos.left += $.fn.absolute.bl; 61 } 62 return pos; 63}; 64 65if (window.___grecaptcha_cfg) { 66 if (___grecaptcha_cfg.onload) { 67 window[___grecaptcha_cfg.onload] = (function(parent) { 68 return function() { 69 parent.apply(this, arguments); 70 $(___grecaptcha_cfg).trigger('load'); 71 }; 72 })(window[___grecaptcha_cfg.onload]); 73 } else { 74 window.ialInitReCaptcha2 = function() { 75 $(___grecaptcha_cfg).trigger('load'); 76 }; 77 ___grecaptcha_cfg.onload = 'ialInitReCaptcha2'; 78 } 79} 80 81$.fn.ialReCaptcha = function(method) { 82 var that = this; 83 $(window.___grecaptcha_cfg).one('load.ial', function() { 84 that.each(function() { 85 if (method == 'reset') { 86 grecaptcha.reset($(this).data('clientId')); 87 } else { 88 var clientId = grecaptcha.render(this, { sitekey: this.getAttribute('data-sitekey') }); 89 $(this).data('clientId', clientId); 90 } 91 });
92 }); 93 window.grecaptcha && grecaptcha.render && $(___grecaptcha_cfg).trigger('load.ial'); 94 return this; 95}; 96 97$.createOOPlugin("ialCheckBox", { 98 activeClass: "ial-active", 99 100 Constructor: function(params) { 101 $.extend(this, params); 102 this.$box = $('<div class="ial-checkbox">').insertBefore(this.$node); 103 if (this.$node.prop("checked")) this.$box.addClass(this.activeClass); 104 var css = isIE && isIE[1] < 9? 105 {position: "absolute", top: "-1000px"} : {display: "none"}; 106 this.$node.css(css) 107 .on("change", $.proxy(this, "onChange")); 108 }, 109 110 onChange: function(e) { 111 if (window.JBackend && e.originalEvent) return; 112 this.$box[this.$node.prop("checked")? 113 "addClass" : "removeClass"](this.activeClass); 114 } 115}); 116 117$.createOOPlugin("ialMsg", { 118 activeClass: "ial-active", 119 margin: 10, 120 timeout: 0, 121 dur: 300, 122 pos: "", // "r" - right, "l" - left 123 msg: "", 124 125 create: function() { 126 if (this.$msg) return; 127 // fix for select field 128 if (this.$node[0].tagName == "SELECT") this.$node = this.$node.parent(); 129 var abs = this.$node.absolute(), 130 pos = this.pos || 131 this.$node.offset().left > $(window).width()/2 ? "l" : "r"; 132 this.$msg = $( 133 '<div class="ial-msg '+this.ico+'">'+ 134 '<span class="ial-'+this.ico+'">'+ 135 '<div class="ial-arrow-'+pos+'" />'+ 136 '<div class="ial-icon-'+this.ico+'"> </div> '+this.msg+ 137 '</span>'+ 138 '</div>') 139 .appendTo(document.body) 140 .addClass("ial-trans-gpu ial-trans-"+pos); 141 var msgW = this.$msg.outerWidth(); 142 if (abs.left - msgW - this.margin < 0) { // if there is no place 143 this.$msg.find(".ial-arrow-r").attr("class", "ial-arrow-"+(pos = "b")); 144 abs.top += this.$node.outerHeight() + this.margin; 145 } 146 if (pos == "r") abs.left -= msgW + this.margin; 147 if (pos == "l") abs.left += this.$node.outerWidth() + this.margin; 148 this.$msg.css(abs); 149 $(window) 150 .on("resize."+this.id, $.proxy(this, "hide")) 151 .on("scroll."+this.id, $.proxy(this, "onScroll")); 152 }, 153 154 onScroll: function() { 155 var abs = this.$node.absolute(); 156 if (this.$msg.find(".ial-arrow-b").length) { 157 abs.top += this.$node.outerHeight() + this.margin; 158 } 159 this.$msg.css("top", abs.top); 160 }, 161 162 show: function() { 163 if (this.timeout) this.timeout = clearTimeout(this.timeout); 164 else this.create(); 165 this.$msg.addClass(this.activeClass); 166 }, 167 168 hide: function() { 169 if (this.timeout || !this.$msg) return; 170 this.$msg.removeClass(this.activeClass); 171 this.timeout = setTimeout($.proxy(this, "destroy"), this.dur); 172 }, 173 174 destroy: function() { 175 $(window).off("."+this.id); 176 this.$msg.off("."+this.id).remove(); 177 delete this.$msg; 178 delete this.timeout; 179 } 180}); 181 182$.createOOPlugin("ialInfoMsg", "ialMsg", { 183 ico: "inf", 184 185 Constructor: function(params) { 186 $.extend(this, params); 187 this.msg = this.$node.prop("title").replace(/([\-\.] )/, "$1<br />"); 188 this.$node 189 .removeAttr("title") 190 .on("focus."+this.id, $.proxy(this, "show")) 191 .on("blur."+this.id, $.proxy(this, "hide")); 192 } 193}); 194 195$.createOOPlugin("ialErrorMsg", "ialMsg", { 196 ico: "err", 197 198 Constructor: function(params) { 199 $.extend(this, params); 200 this.$node.attr("data-"+this.plugin, "on"); 201 this.msg = this.msg.replace(/:( | )*(%s)?$/, ""); 202 this.show(); 203 this.$node.on("focus."+this.id+" click."+this.id, $.proxy(this, "hide")); 204 this.$msg.on("click."+this.id, $.proxy(this, "hide")); 205 }, 206 207 destroy: function() { 208 this.Super("destroy", arguments); 209 this.$node 210 .off("."+this.id) 211 .removeAttr("data-"+this.plugin) 212 .removeData(this.plugin); 213 } 214}); 215 216$.createOOPlugin("ialElem", { 217 nodeClass: "gi-elem", 218 validClass: "ial-correct", 219 reqClass: "req", 220 $input: undefined, 221 $error: undefined, 222 223 Constructor: function(params) { 224 $.extend(this, params); 225 this.$node.addClass(this.nodeClass); 226 $(this.tmpl).appendTo(this.$node); 227 this.init();
228 this.$error = this.$node.find("[data-attr=error]"); 229 this.$input = this.$node.find("[name]").prop("id", this.id); 230 this.$node.find("label").prop("for", this.id); 231 if (ologin.showHint && this.$input.prop("title")) 232 this.$input.ialInfoMsg(); 233 }, 234 235 init: function() { 236 var name, obj; 237 for (name in this.jfo) { 238 obj = this.jfo[name]; 239 if (typeof obj === "object") 240 this.setAttr(name, obj.checked || obj.value, obj.placeholder || ""); 241 } 242 }, 243 244 setAttr: function(name, value, placeholder) { 245 var attr = name.match(/_(.*)]/)[1], 246 $node = this.$node.find("[data-attr*="+attr+"]"); 247 this.jfo[name][placeholder == "CHK"? "checked" : "value"] = value; 248 switch (attr) { 249 case "prefix": 250 attr = "name"; 251 $node = this.$node.find("[name]"); 252 value = this.jfo["jform[elem_name]"].value; 253 case "name": 254 var prefix = this.jfo["jform[elem_prefix]"]; 255 if (prefix) prefix = prefix.value || prefix.placeholder; 256 else if (this.jfo[name].prefix) // compatibility fix for old versions 257 prefix = this.jfo[name].prefix.replace(/\[$/, ""); 258 if (prefix) value = prefix + "["+value+"]"; 259 case "value": 260 case "title": 261 case "placeholder": 262 case "accept": 263 case "size": 264 return $node.prop(attr, value || placeholder); 265 case "class": 266 if (this.jfo["jform[elem_wide]"].checked) value += " gi-wide"; 267 return this.$node.prop("class", this.nodeClass).addClass(value); 268 case "subtitle": 269 case "label": 270 $node[(value || placeholder).match(/\S/)? 271 "removeClass" : "addClass"]("hidden"); 272 case "error": 273 return $node.html(value || placeholder); 274 case "select": 275 return value && $node.html(value); 276 case "required": 277 return $node[value? "addClass" : "removeClass"](this.reqClass); 278 case "wide": 279 this.$node[value? "addClass" : "removeClass"]("gi-"+attr); 280 return $node; 281 case "checked": 282 return $node.attr("checked", value).trigger("change"); 283 case "article": 284 var $article = $("input[id$=article_name]"); 285 if ($article.val()) 286 this.jfo["jform[elem_article_name]"].value = $article.val(); 287 if (value) $node.attr("href", ologin.base+"index.php?option=com_content&view=article&tmpl=component&id="+value); 288 return $node.html(this.jfo["jform[elem_article_name]"].value 289 || $article.attr("placeholder")); 290 } 291 } 292}); 293 294$.createOOPlugin("ialHidden", "ialElem", { 295 tmpl: '<input data-attr="name value" type="hidden" />' 296}); 297 298$.createOOPlugin("ialTextfieldBase", "ialElem", { 299 $load: undefined, 300 301 Constructor: function(params) { 302 this.Super("Constructor", arguments); 303 if (this.jfo["jform[elem_type]"].defaultValue == 'hidden') { 304 this.tmpl = '<input data-attr="name value" type="hidden" />'; 305 } 306 if (this.jfo["jform[elem_autoCompOff]"]) 307 this.$input.attr("autocomplete", "off"); 308 if (this.jfo["jform[elem_pattern]"]) 309 this.$input.on("blur", $.proxy(this, "onBlur")); 310 if (this.jfo["jform[elem_ajax]"]) 311 this.$load = $('<i class="ial-load" />') 312 .insertBefore(this.$input) 313 .ialLoad(); 314 }, 315 316 onBlur: function() { 317 var value = this.$input.val(); 318 this.$input.removeClass(this.validClass); 319 if (!value) return; 320 var rege = new RegExp(this.jfo["jform[elem_pattern]"].value), 321 result = rege.test(value); 322 if (result && this.$load) { 323 if (this.$load.ialLoad("playing")) return; 324 this.$input 325 .prop("disabled", true) 326 .css("background", "none"); 327 this.$load.ialLoad("play"); 328 $.ajax({
329 type: "POST", 330 dataType: "json", 331 url: ologin.base + "index.php", 332 data: { 333 ialCheck: this.$input.attr("name"), 334 value: value, 335 lang: (document.ialLogin || document.ialRegister).lang.value 336 }, 337 success: $.proxy(this, "onLoadSuccess"), 338 error: $.proxy(this, "onLoadError"), 339 timeout: ologin.timeout, 340 cache: false 341 }); 342 } else this.onLoadSuccess({ 343 error: !result, 344 msg: this.$error.html() 345 }); 346 }, 347 348 onLoadSuccess: function(resp) { 349 if (resp.error) { 350 if (!this.$input.data("ialErrorMsg")) 351 this.$input.ialErrorMsg({msg: resp.msg}); 352 } else this.$input.addClass(this.validClass); 353 if (this.$load) { 354 this.$load.ialLoad("stop"); 355 this.$input 356 .prop("disabled", false) 357 .removeAttr("style"); 358 } 359 }, 360 361 onLoadError: function(error) { 362 this.$load.ialLoad("stop"); 363 this.$input 364 .prop("disabled", false) 365 .removeAttr("style"); 366 console.log(error); 367 } 368}); 369 370$.createOOPlugin("ialPassword1Base", "ialElem", { 371 min: 4, 372 passCat: ['', 373 'IAL_VERY_WEAK', 374 'IAL_WEAK', 375 'IAL_REASONABLE', 376 'IAL_STRONG', 377 'IAL_VERY_STRONG'], 378 $strong: undefined, 379 $sfs: undefined, 380 381 Constructor: function(params) { 382 this.Super("Constructor", arguments); 383 this.$strong = this.$node.children(".passStrongness"); 384 this.$sfs = this.$node.find(".strongField"); 385 this.$input 386 .attr("autocomplete", "new-password") 387 .on("keyup", $.proxy(this, "onKeyUp")) 388 .on("blur", $.proxy(this, "onBlur")); 389 }, 390 391 onKeyUp: function(e) { 392 var pass = this.$input.val(), 393 strong = 0; 394 if (pass.length >= this.min) { 395 strong++; 396 if (pass.length >= 2*this.min) strong++; 397 if (pass.match(/\d/)) strong++; 398 if (pass.match(/[A-Z]/)) strong++; 399 if (pass.match(/\W/)) strong++; 400 } 401 this.$strong.html(this.passCat[strong] 402 && ialText[this.passCat[strong]]); 403 this.$sfs.parent().attr("data-level", strong); 404 for (var i=0; i<this.$sfs.length; i++) 405 $(this.$sfs[i])[strong > i? "removeClass" : "addClass"]("empty"); 406 }, 407 408 onBlur: function() { 409 var value = this.$input.val(); 410 this.$input.removeClass(this.validClass); 411 if (!value) return; 412 if (value.length < this.min) 413 this.$input.ialErrorMsg({msg: this.$error.html()}); 414 else this.$input.addClass(this.validClass); 415 } 416}); 417 418$.createOOPlugin("ialCaptcha", "ialElem", { 419 Constructor: function(params) { 420 this.Super("Constructor", arguments); 421 if (!ologin.captcha) alert("Captcha - ReCaptcha plugin isn't enabled!"); 422 else if (ologin.captchaVer == '1.0') alert("Google reCaptcha version 1.0 isn't supported anymore!"); 423 else if (ologin.captcha == 'empty') alert("Captcha - ReCaptcha plugin:\n"+ 424 "Public / Private key is empty at the reCaptcha plugin option!"); 425 else this.initCaptcha2(); 426 }, 427 428 initCaptcha2: function() { 429 if (window.JBackend) { 430 this.$node.html('<img class="grecaptcha-img" src="components/com_improved_ajax_login/assets/img/notrobot.png">'); 431 } else { 432 this.$node.html('<div id="registerCaptcha" class="ial-recaptcha" data-sitekey="'+ologin.captcha+'"></div>'); 433 } 434 } 435}); 436 437$.createOOPlugin("ialFileBase", "ialElem", { 438 Constructor: function(params){ 439 this.Super("Constructor", arguments); 440 $.extend(this, params); 441 this.$input.on('change', $.proxy(this, "onChange")); 442 }, 443 onChange: function(){ 444 $(this.$input).next().val(this.$input.val().substring(this.$input.val().lastIndexOf("\\") + 1)); 445 this.validateSize(); 446 }, 447 validateSize: function(){ 448 var fileSize = this.$input[0].files[0].size; 449 var fieldMaxSize = this.$input[0].attributes.size.value * 1024 * 1024; 450 if(ologin.maxfilesize < fieldMaxSize ){ 451 fieldMaxSize = ologin.maxfilesize; 452 } 453 if (fileSize > fieldMaxSize) { 454 alert(ialText.COM_MEDIA_ERROR_WARNFILETOOLARGE + ialText.COM_MEDIA_FIELD_MAXIMUM_SIZE_LABEL + ': '+ fieldMaxSize / 1024 / 1024); 455 this.$input.val(''); 456 this.$input.next().val(''); 457 } 458 } 459 460}); 461 462$.createOOPlugin("ialTosBase", "ialElem", { 463 Constructor: function(params) { 464 this.Super("Constructor", arguments);
465 this.$link = this.$node.find("a"); 466 var art = this.jfo["jform[elem_article_name]"]; 467 if (art) this.$link.html(art.value || art.placeholder) 468 if (window.JBackend) return this.$modal = $(); 469 this.$modal = this.$node.find(".ial-modal").ialWindow({ 470 $bg: ologin.$bg, 471 popupCenter: true, 472 border: parseInt(ologin.border) 473 }); 474 this.$frame = this.$modal.find('.ial-frame').on('load', function() { 475 $(this.parentNode).addClass('ial-loaded'); 476 }); 477 this.$link.on('click', $.proxy(this, 'open')); 478 this.$modal.find('.ial-close').on('click', $.proxy(this, 'close')); 479 }, 480 481 open: function() { 482 if (this.$frame.contents()[0].location.href != this.$link.prop('href')) { 483 this.$frame.prop('src', this.$link.prop('href')); 484 } 485 ologin.$bg.on('click.ialModal', $.proxy(this, 'close')); 486 }, 487 488 close: function() { 489 this.$node.closest('.ial-window').ialWindow('open'); 490 ologin.$bg.off('click.ialModal'); 491 } 492}); 493 494$.createOOPlugin("ialConfirm", { 495 validClass: "ial-correct", 496 $orig: undefined, 497 498 Constructor: function(params) { 499 $.extend(this, params); 500 var name = this.$node.prop("name"), 501 elem = this.$node.prop("form").elements, 502 m = name.match(/2|_confirm/)[0]; 503 this.$orig = $(elem[name.replace(m, "1")] || elem[name.replace(m, "")]) 504 .on("focus", $.proxy(this.$node, "removeClass", this.validClass)) 505 .on("blur", $.proxy(this, "onBlurOrig")); 506 this.$node 507 .on("focus", $.proxy(this, "onFocus")) 508 .on("blur", $.proxy(this, "onBlur")); 509 this.$error = this.$node.next(); 510 }, 511 512 onFocus: function() { 513 if (!this.$orig.val()) this.$orig.focus(); 514 else this.$node.removeClass(this.validClass); 515 }, 516 517 onBlur: function() { 518 var nodeVal = this.$node.val(); 519 if (!nodeVal) return; 520 if (nodeVal == this.$orig.val()) { 521 if (this.$orig.hasClass(this.validClass)) 522 this.$node.addClass(this.validClass); 523 } else this.$node.ialErrorMsg({msg: this.$error.html()}); 524 }, 525 526 onBlurOrig: function() { 527 var nodeVal = this.$node.val(), 528 origVal = this.$orig.val(); 529 if (!nodeVal || !origVal) return; 530 if (nodeVal == origVal) { 531 if (this.$orig.hasClass(this.validClass)) 532 this.$node.addClass(this.validClass); 533 } else this.$node.ialErrorMsg({msg: this.$error.html()}) 534 } 535}); 536 537$.createOOPlugin("ialSubmit", { 538 validClass: "ial-correct", 539 reloadDelay: 2000, 540 $form: undefined, 541 $load: undefined, 542 543 Constructor: function(params) { 544 $.extend(this, params); 545 var form = this.$node.prop("form"), url = form.action; 546 if (form.ctrl) url += (url.indexOf('?') < 0 ? '?' : '&') + 'ctrl=' + form.ctrl.value; 547 if (form.task) url += (url.indexOf('?') < 0 ? '?' : '&') + 'task=' + form.task.value; 548 this.$load = this.$node.find(".ial-load").ialLoad(); 549 this.$form = $(form).attr("action", url) 550 .on("submit", $.proxy(this, "onSubmit")); 551 if (isIE && isIE[1] < 8) { 552 this.$node.wrapInner('<div class="loginBtn ial-submit">') 553 .children().unwrap(); 554 $('.loginBtn', form).on("click", function() {form.submit()}); 555 } 556 }, 557 558 onSubmit: function(e) { 559 function required($input) { 560 if (!$input.data("ialErrorMsg")) 561 $input.ialErrorMsg({msg: ialText.COM_USERS_REGISTER_REQUIRED}); 562 } 563 564 if (e) $(document.activeElement).blur(); 565 if (this.$load.ialLoad("playing")) return; 566 var $input, $elem, $elems = this.$form.children(".gi-elem"); 567 for (var i = 0; i < $elems.length; i++) { 568 $elem = $($elems[i]); 569 if ($elem.find(".req").length) { 570 var $load = $elem.find(".ial-load"); 571 if ($load.ialLoad("playing") === true) { 572 if (e) e.preventDefault(); 573 return $load.ialLoad("onEnd", $.proxy(this, "onSubmit")); 574 } 575 // check required elems 576 $input = $elem.find(":input[type!=hidden]"); 577 if (!$input.hasClass(this.validClass)) { 578 if ($input.prop("tagName") == "SELECT" && $input.val()) continue; 579 if ($input.prop("type") == "checkbox") 580 if ($input.prop("checked")) continue; 581 else return required($input.parent(), e && e.preventDefault()); 582 if ($input.val()) $input.blur(); 583 return required($input, e && e.preventDefault()); 584 } 585 } 586 } 587 this.$load.ialLoad("play"); 588 if (~this.$form.attr("name").indexOf("ialLogin") || ologin.regPage == 'joomla' || ologin.regPage == 'jomsocial') { 589 e && e.preventDefault(); 590 var data, lang = (document.ialLogin || document.ialRegister).lang.value; 591 if (window.FormData) { 592 data = new FormData(this.$form[0]); 593 data.append('ialCheck', this.$form.attr("name"));
594 data.append('lang', lang); 595 } else { 596 data = this.$form.serialize()+"&ialCheck="+this.$form.attr("name")+"&lang="+lang; 597 } 598 $.ajax({ 599 type: "POST", 600 dataType: "json", 601 url: this.$form.prop("action"), 602 data: data, 603 contentType: false, 604 processData: false, 605 beforeSend: $.proxy(this, "onBeforeSend"), 606 success: $.proxy(this, "onSubmitSuccess"), 607 error: $.proxy(this, "onSubmitError"), 608 timeout: ologin.timeout, 609 cache: false 610 }); 611 } 612 }, 613 614 onBeforeSend: function(xhr) {}, 615 616 onSubmitSuccess: function(resp) { 617 if (resp.error) { 618 var $wrong = $(this.$form.prop("elements")[resp.field]); 619 if (!$wrong.length) $wrong = this.$form.find('#'+resp.field); 620 if (!$wrong.length) $wrong = this.$node; 621 this.$load.ialLoad("stop"); 622 if (!$wrong.data("ialErrorMsg")) $wrong.ialErrorMsg({ 623 msg: resp.msg 624 }); 625 // if token error, reload page 626 if (resp.error == "JINVALID_TOKEN") { 627 if (window.sessionStorage) sessionStorage[this.$form.prop('name')] = JSON.stringify( 628 this.$form.find(':input:not(.g-recaptcha-response,input[type=hidden])').serializeArray() 629 ); 630 this.$load.ialLoad("play"); 631 setTimeout(function() { 632 location.href = location.href; 633 }, this.reloadDelay); 634 } else if (this.$form.find('.g-recaptcha-response').val()) { 635 this.$form.find('.ial-recaptcha').ialReCaptcha("reset"); 636 } 637 } 638 if (resp.redirect) location.href = resp.redirect; 639 }, 640 641 onSubmitError: function(error) { 642 var base, json; 643 if (error.responseText.match(/<html\b/i)) { 644 if (base = error.responseText.match(/<base\b.*?>/i)) { 645 history.replaceState(null, null, $(base[0]).attr("href")); 646 } 647 document.open(); 648 document.write(error.responseText); 649 document.close(); 650 } else if (json = error.responseText.match(/\{"\w+":.*\}$/)) { 651 var res = JSON.parse(json[0]); 652 res.redirect ? location.href = res.redirect : this.onSubmitSuccess(res); 653 } else { 654 this.$load.ialLoad("stop"); 655 console.log(error); 656 } 657 } 658}); 659 660$.createOOPlugin("ialSubmitLogin", "ialSubmit", { 661 onBeforeSend: function(xhr) { 662 xhr.setRequestHeader('X-IAL-Login', 1); 663 } 664}); 665 666$.createOOPlugin("ialSubmitRegister", "ialSubmit", { 667 onBeforeSend: function(xhr) { 668 xhr.setRequestHeader('X-IAL-Register', 1); 669 }, 670 671 onSubmitSuccess: function(resp) { 672 this.Super("onSubmitSuccess", arguments); 673 if (resp.error) { 674 if (resp.field == "recaptcha_response_field") { 675 this.$form.find('[name=recaptcha_challenge_field]').parent() 676 .ialCaptcha("reLoad"); 677 } 678 } else { 679 if (resp.autologin) { 680 this.$load.ialLoad("play"); 681 var $login = $('<form>').attr({ 682 style: "display:none", 683 method: "post", 684 action: "?option=com_users&task=user.login" 685 }).appendTo(document.body); 686 var pass = this.$form.find("[name*=password]").val(); 687 $('<input name="option" value="com_users">').appendTo($login); 688 $('<input name="task" value="user.login">').appendTo($login); 689 $('<input name="username">').val(resp.username).appendTo($login); 690 $('<input name="password">').val(pass).appendTo($login); 691 $('.ial-login [name=return]').clone().appendTo($login); 692 $(resp.autologin).appendTo($login); 693 $login.submit(); 694 return; 695 } 696 this.$form.children().remove(); 697 this.$form.siblings(".ial-socials, .loginBrd").remove(); 698 $('<div>').ialHeader({ 699 jfo: { 700 "jform[elem_label]": {value: '<i class="ial-correct"/>'+ialText.COM_USERS_REGISTRATION}, 701 "jform[elem_wide]": {checked: true} 702 } 703 }).appendTo(this.$form); 704 $('<div>').ialLabel({ 705 jfo: { 706 "jform[elem_label]": {value: resp.msg}, 707 "jform[elem_wide]": {checked: true} 708 } 709 }).appendTo(this.$form);
710 if (ologin.regPopup) $('<div>').ialButton({ 711 jfo: { 712 "jform[elem_label]": {value: "OK"}, 713 "jform[elem_subtitle]": {value: " "}, 714 "jform[elem_wide]": {checked: true} 715 } 716 }).appendTo(this.$form) 717 .on("click", $.proxy(this.$form.closest(".ial-window"), "ialWindow", "close")) 718 .find('button').prop("type", "button"); 719 this.$form.ialForm("initCSS"); 720 $(window).trigger("resize"); 721 } 722 }, 723 724 onSubmitError: function() { 725 this.Super("onSubmitError", arguments); 726 } 727}); 728 729$.createOOPlugin("ialSubmitReset", "ialSubmit", { 730 onBeforeSend: function(xhr) { 731 xhr.setRequestHeader('X-IAL-Reset', 1); 732 } 733}); 734 735$.createOOPlugin("ialSubmitRemind", "ialSubmit", { 736 onBeforeSend: function(xhr) { 737 xhr.setRequestHeader('X-IAL-Remind', 1); 738 }, 739 740 onSubmitSuccess: function(resp) { 741 this.Super("onSubmitSuccess", arguments); 742 if (!resp.error) { 743 this.$form.children(":not(:first)").remove(); 744 $('<div>').ialLabel({ 745 jfo: { 746 "jform[elem_label]": {value: resp.msg}, 747 "jform[elem_wide]": {checked: true} 748 } 749 }).appendTo(this.$form); 750 $('<div>').ialButton({ 751 jfo: { 752 "jform[elem_label]": {value: "OK"}, 753 "jform[elem_subtitle]": {value: " "}, 754 "jform[elem_wide]": {checked: true} 755 } 756 }).appendTo(this.$form) 757 .on("click", $.proxy(this.$form.closest(".ial-window"), "ialWindow", "close")) 758 .find('button').prop("type", "button"); 759 this.$form.ialForm("initCSS"); 760 $(window).trigger("resize"); 761 } 762 } 763}); 764 765$.createOOPlugin("ialForm", { 766 layout: {}, 767 768 Constructor: function(params) { 769 $.extend(this, params); 770 this.initElems(); 771 this.initProps(); 772 this.initCSS(); 773 var form = this.$node[0]; 774 if (window.sessionStorage && sessionStorage[form.name]) $(window).on('load', function() { 775 $(form).closest('.ial-window').ialWindow("open"); 776 var input = JSON.parse(sessionStorage[form.name]) || []; 777 for (var i = 0; i < input.length; i++) { 778 $(form.elements[input[i].name]).val(input[i].value).blur(); 779 } 780 delete sessionStorage[form.name]; 781 }); 782 this.$node.closest('.ial-window').length || this.$node.find('.ial-recaptcha').ialReCaptcha(); 783 }, 784 785 initElems: function() { 786 var elems = ialFields.page[0].elem; 787 $.fn.ialSelection = $.fn.ialSelect; // hikashop fix o_O? 788 for (var i in elems) { 789 // get plugin name (question marks removed for language debug) 790 var plg = elems[i]["jform[elem_type]"].value.replace(/\?/g, ''); 791 plg = "ial" + plg.charAt(0).toUpperCase() + plg.slice(1); 792 $('<div>')[plg]({ jfo: elems[i] }).appendTo(this.$node); 793 } 794 this.$node.find('[name*=password2], [name*=email2], [name*=_confirm]') 795 .ialConfirm(); 796 this.$node.find("button.ial-submit").ialSubmitRegister(); 797 // virtuemart state field 798 this.$node.find("select[name=virtuemart_country_id]") 799 .on("change", function(e) { 800 var id = e.currentTarget.options[e.currentTarget.selectedIndex].value; 801 $.ajax({
802 type: "GET", 803 url: ologin.base + "index.php?option=com_virtuemart&view=state" + 804 "&format=json&virtuemart_country_id=" + id, 805 dataType: "json", 806 success: function(data) { 807 var i, opt, opts = ""; 808 if (data[id]) for (i = 0; i < data[id].length; i++) { 809 otp = data[id][i]; 810 opts += '<option value="' + otp.virtuemart_state_id + '">' + 811 otp.state_name + '</option>'; 812 } 813 if (!opts) opts = '<option value="0"> </option>'; 814 $(".loginTxt[name=virtuemart_state_id]").html(opts); 815 } 816 }); 817 }).trigger("change"); 818 // hikashop state field 819 this.$node.find('select[name="data[address][address_country]"]') 820 .on("change", function(e) { 821 var val = e.currentTarget.options[e.currentTarget.selectedIndex].value; 822 $.ajax({ 823 type: "GET", 824 url: ologin.base + "index.php?option=com_hikashop&ctrl=checkout" + 825 "&task=state&tmpl=component&field_id=data_address_address_state" + 826 "&field_type=address&field_namekey=address_state&namekey=" + val, 827 success: function(html) { 828 var $res = $(html), 829 $state = $('.loginTxt[name="data[address][address_state]"]'); 830 if ($res.hasClass("state_no_country")) 831 $state.html('<option value="">'+$res.html()+'<option>'); 832 else $state.html($res.html()); 833 } 834 }); 835 }).trigger("change"); 836 if (navigator.geolocation && ologin.geolocation) 837 $(".regBtn").one(ologin.openEvent == "onclick"? "click" : "mouseenter", 838 $.proxy(this, "getLocation")).length || this.getLocation(); 839 }, 840 841 initProps: function() { 842 var props = ialProps; 843 for (var prop in props.layout) { 844 this.layout[ prop.match(/_(.*)]/)[1] ] = parseInt(props.layout[prop]); 845 } 846 if (ologin.theme == "flat") { 847 if (this.layout.width < 230) this.layout.width = 230; 848 if (this.layout.margin < 25) this.layout.margin = 25; 849 } 850 }, 851 852 initCSS: function() { 853 this.$node.css("width", 854 this.layout.columns * (2*this.layout.margin + this.layout.width)); 855 this.$node.children(":not(.gi-wide)").css({ 856 width: this.layout.width, 857 margin: "0 "+this.layout.margin+"px" 858 }); 859 this.$node.children(".gi-wide") 860 .css("padding", "0 "+this.layout.margin+"px"); 861 this.$node.siblings(":not(form, button, br)").css({ 862 marginLeft: this.layout.margin, 863 marginRight: this.layout.margin 864 }); 865 this.$oauths = this.$node.siblings(".ial-oauths").css("margin", "0 0 10px"); 866 this.$oauths.children().css({ 867 width: this.layout.width, 868 margin: "5px "+this.layout.margin+"px", 869 float: "left" 870 }); 871 this.$oauths.children(":nth-child("+this.layout.columns+"n+1)").css("clear", "both"); 872 $('<br style="clear:both" />').appendTo(this.$oauths); 873 }, 874 875 getLocation: function() { 876 var $input = this.$node.find("input[name*=address],"+ 877 "input[name*=city], input[name*=region],"+ 878 "input[name*=postal_code], input[name*=country]"); 879 if (!$input.length) return; 880 navigator.geolocation.getCurrentPosition(function(pos) { 881 var latlng = pos.coords.latitude+','+pos.coords.longitude; 882 $.getJSON('//maps.googleapis.com/maps/api/geocode/json?sensor=true&latlng='+latlng, function(data) { 883 if (data.status != "OK") return; 884 var i, j, type, address, $addr, name = { 885 administrative_area_level_1: "region", 886 administrative_area_level_2: "city", 887 locality: "city", 888 route: "address1" 889 }; 890 for (j = data.results.length; j--;) { 891 address = data.results[j].address_components; 892 for (i = address.length; i--;) { 893 type = address[i].types[0]; 894 if (type == 'street_number') { 895 $addr = $input.filter("[name*=address]"); 896 if (!$addr.length) break; 897 if ($addr.length > 1) $addr[1].value = address[i].long_name; 898 else $addr[0].value += " "+address[i].long_name; 899 $addr.blur(); 900 } else { 901 $input.filter("[name*="+(name[type] || type)+"]").val(address[i].long_name).blur(); 902 } 903 } 904 } 905 }); 906 });
907 } 908}); 909 910 911$.createOOPlugin("ialWindowBase", { 912 nodeClass: "ial-window", 913 activeClass: "ial-active", 914 popupCenter: false, 915 border: 3, 916 $bg: $(), 917 $btn: undefined, 918 $close: undefined, 919 $arrow: undefined, 920 921 Constructor: function(params) { 922 $.extend(this, params); 923 if (!this.$node.find('form, iframe').length) return; 924 this.$node.addClass(this.nodeClass+" mod-"+ologin.id); 925 this.$btn = this.$node.prev(); 926 this.$arrow = this.$node.find(".ial-arrow-up"); 927 this.$close = this.$node.find(".ial-close"); 928 if (!this.$btn.hasClass("selectBtn")) { 929 this.$arrow.css("display", "none"); 930 this.$close.css("display", "none"); 931 return; 932 } 933 // init events 934 this.$btn.on("click", $.proxy(this, "onClickBtn")); 935 if (ologin.openEvent != "onclick") 936 this.$btn.on("mouseenter", $.proxy(this, "onClickBtn")); 937 this.$close.on("click", $.proxy(this, "close")); 938 this.$bg.on("click", $.proxy(this, "close")); 939 // init node 940 if (!this.popupCenter) this.$node.children() 941 .css("minWidth", this.$btn.outerWidth() - 2*this.border); 942 if (!this.$arrow.length && !this.$btn.hasClass('userBtn')) this.popupCenter = true; 943 this.$node.appendTo(document.body); 944 }, 945 946 initPosition: function(e) { 947 // resize only on orientation change on mobile 948 if (e && e.timeStamp - this.lastScroll < 100) return; 949 var $form = this.$node.find("form").css({maxWidth: "", boxSizing: ""}), 950 pos = {}, 951 $win = $(window), 952 wndW = this.$node.outerWidth(), 953 wndH = this.$node.outerHeight(), 954 winW = $win.width(), 955 winH = $win.height(); 956 if (this.popupCenter || wndW > winW || wndH > winH) { 957 // popup center 958 pos.marginTop = 0; 959 this.$arrow.css("display", "none"); 960 if (wndW <= winW) { 961 pos.left = (winW - wndW) / 2; 962 } else { 963 pos.left = 0; 964 var side = ologin.theme != "elegant" ? 0 : 965 parseInt(this.$node.css('paddingLeft')) + parseInt(this.$node.children().css('paddingLeft')) + 2; 966 $form.css({ 967 maxWidth: winW - side*2, 968 boxSizing: "border-box" 969 }).find(".gi-elem") 970 .attr("style", "padding:0px "+$form.data("ialForm").layout.margin+"px") 971 .addClass("gi-wide"); 972 wndH = this.$node.outerHeight(); 973 } 974 if (wndH <= winH && navigator.userAgent.indexOf('iPhone OS 11') < 0) { 975 this.$node.css("position", "fixed"); 976 pos.top = (winH - wndH) / 2; 977 } else { 978 this.$node.css("position", "absolute"); 979 pos.top = $(document).scrollTop(); 980 } 981 } else { 982 // popup under button 983 var btnW = this.$btn.outerWidth(), 984 btnH = this.$btn.outerHeight(), 985 btnP = this.$btn.absolute(); 986 pos.top = btnP.top + btnH; 987 this.leftSide = btnP.left + btnW/2 < $win.width()/2; 988 if (this.leftSide) { 989 // float left 990 pos.left = btnP.left - this.border; 991 this.$arrow.css("left", btnW/2 - 20); 992 } else { 993 // float right 994 pos.left = btnP.left + this.border + btnW - wndW; 995 this.$arrow.css("left", wndW - 3*this.border - btnW/2 - 20); 996 } 997 } 998 this.$node.css(pos); 999 }, 1000 1001 onKeyPress: function(e) { 1002 if (e.keyCode == 27) this.close(); 1003 }, 1004 1005 onClickBtn: function(e) { 1006 e.preventDefault(); 1007 if (this.$node.hasClass(this.activeClass)) { 1008 this.close(); 1009 } else { 1010 this.open(); 1011 var firstInput = this.$node.find('input[type!=hidden]:first')[0]; 1012 firstInput && !firstInput.value && !isMobileOrTablet && setTimeout(function() { 1013 firstInput.focus(); 1014 }, 300); 1015 } 1016 }, 1017 1018 onScroll: function(e) { 1019 this.lastScroll = e.timeStamp; 1020 }, 1021 1022 open: function() { 1023 var $openWnd = $('.'+this.nodeClass+'.'+this.activeClass); 1024 // close other window 1025 if ($openWnd.length && $openWnd[0] != this.$node[0]) 1026 $openWnd.ialWindow("close"); 1027 // add event 1028 $(document).on("keypress."+this.id, $.proxy(this, "onKeyPress")); 1029 $(window).on("resize."+this.id, $.proxy(this, "initPosition")) 1030 .on("scroll."+this.id, $.proxy(this, "onScroll")); 1031 // open window 1032 this.initPosition(); 1033 $('.selectBtn').css("position", "relative"); 1034 if (ologin.windowAnim > 16) this.$bg.css("height", $(document).height()); 1035 else this.$bg.css("position", 'fixed'); 1036 this.$bg.addClass(this.activeClass); 1037 this.$btn.addClass(this.activeClass); 1038 this.$node.addClass(this.activeClass); 1039 if (!this.recaptcha) { 1040 this.recaptcha = true; 1041 this.$node.find('.ial-recaptcha').ialReCaptcha(); 1042 } 1043 }, 1044 1045 close: function(e) { 1046 if (!this.$node.hasClass(this.activeClass)) return; 1047 // remove event 1048 if($("#tosModal").hasClass("in")) $(".tosClose").click();
1049 $(document).off("keypress."+this.id); 1050 $(window).off("resize."+this.id+" scroll."+this.id); 1051 this.$node.find("[data-ialErrorMsg]").ialErrorMsg("hide"); 1052 // close window 1053 $('.selectBtn').css("position", "static"); 1054 this.$bg.removeClass(this.activeClass); 1055 this.$btn.removeClass(this.activeClass); 1056 this.$node.removeClass(this.activeClass); 1057 } 1058}); 1059 1060$.createOOPlugin("ialOAuth", { 1061 alias: "", 1062 url: "", 1063 delay: 300, 1064 1065 Constructor: function(params) { 1066 $.extend(this, params); 1067 this.alias = this.$node.data("oauth"); 1068 this.url = ologin.oauth[this.alias]; 1069 this.$node.on("click", $.proxy(this, "open")); 1070 }, 1071 1072 open: function() { 1073 // OAuth fix for Microsoft redirect URI 1074 document.cookie = "oauth_task=" + this.url.match(/task(=|%3D)(.*)$/)[2]; 1075 this.url = this.url.replace(/%3Foption%3Dcom_improved_ajax_login%26task%3D(windows|twitter|vk)/, ""); 1076 var sw = window.open(this.url, "Login", "width=450,height=500,"+ 1077 "screenX="+(screen.width/2 - 225)+","+ 1078 "screenY="+(screen.height/2 - (this.alias == "twitter"? 450 : 250))); 1079 sw.focus(); 1080 ologin.$oauthBtn = this.$node; 1081 } 1082}); 1083 1084ImprovedAJAXLogin = function(params) { 1085 $.extend(this, params); 1086 window.ologin = this; 1087 isIE = navigator.userAgent.match(/MSIE (\d+)/) || 1088 navigator.userAgent.match(/\.NET.*rv:(\d+)/); 1089 if (isIE) $(document.body).addClass('gi-ie-'+isIE[1]); 1090 this.$bg = $('<div class="ial-bg ial-trans-gpu" />').appendTo(document.body); 1091 $(".ial-window").ialWindow({ 1092 $bg: isIE && isIE[1] < 9? $() : this.$bg, 1093 popupCenter: params.wndCenter, 1094 border: parseInt(params.border) 1095 }); 1096 $(".ial-form").ialForm(); 1097 $(".ial-login").ialLoginForm(); 1098 $(".ial-usermenu").ialUsermenu({ 1099 $bg: isIE && isIE[1] < 9? $() : this.$bg, 1100 popupCenter: false, 1101 border: parseInt(params.border) 1102 }); 1103 $(".ial-login .ial-submit").ialSubmitLogin(); 1104 //reset password 1105 $(".ial-reset").ialSubmitReset(); 1106 $(".ial-remind").ialSubmitRemind(); 1107 $("[data-oauth]").ialOAuth(); 1108 //disable chosen js 1109 $(function($) { 1110 $(".ial-form select.chzn-done") 1111 .removeClass("chzn-done") 1112 .removeAttr("style") 1113 .removeData("chosen") 1114 .next().remove(); 1115 }); 1116}; 1117 1118// trigger popups & logout 1119$(function() { 1120 $(".log-popup").click(function(e) { 1121 e.preventDefault(); 1122 $(this).parents(".log-popup").length || $(".logBtn").click(); 1123 }); 1124 $(".reg-popup").click(function(e) { 1125 e.preventDefault(); 1126 $(this).parents(".reg-popup").length || $(".regBtn").click(); 1127 }); 1128 $(".logout-link").click(function(e) { 1129 e.preventDefault(); 1130 $(this).parents(".logout-link").length || $(".logout").click(); 1131 }); 1132 $(".frg_reset").on("click", function(e) { 1133 e.preventDefault(); 1134 $(this).parents(".frg_reset").length || $(".resetBtn").click(); 1135 }); 1136 $(".frg_remind").on("click", function(e) { 1137 e.preventDefault(); 1138 $(this).parents(".frg_remind").length || $(".remindBtn").click(); 1139 }); 1140}); 1141 1142if (window.Calendar) { 1143 Calendar.setup = (function(setup) { 1144 return function patch(args) { 1145 return $('#'+args.inputField).length ? setup.apply(this, arguments) : null; 1146 }; 1147 })(Calendar.setup); 1148} 1149 1150})(window.jq183 || jQuery);
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.