1/* 2 * @version 3.4.2 3 * @package PWebContact 4 * @copyright © 2016 Perfect Web sp. z o.o., All rights reserved. http://www.perfect-web.co 5 * @license GNU General Public License http://www.gnu.org/licenses/gpl-3.0.html 6 * @author Piotr MoÄko 7 * 8 * jQuery 1.8+ 9 */ 10var pwebBoxes = pwebBoxes || []; 11(function(a) { 12 pwebContact = function(b) { 13 this.init(b) 14 }; 15 pwebContact.prototype = (function() { 16 var b = {}; 17 return { 18 constructor: pwebContact, 19 defaults: { 20 id: "", 21 selector: "#pwebcontact", 22 selectorClass: ".pwebcontact", 23 debug: false, 24 basePath: "", 25 baseUrl: "", 26 ajaxUrl: "", 27 reloadToken: false, 28 bootstrap: 2, 29 openAuto: false, 30 openDelay: 0, 31 maxAutoOpen: 0, 32 closeAuto: false, 33 closeDelay: 0, 34 closeOther: true, 35 reset: 1, 36 redirectURL: "", 37 redirectDelay: 3, 38 layout: "slidebox", 39 position: "left", 40 offsetPosition: "top", 41 tooltips: 3, 42 msgScroll: true, 43 msgPosition: "after", 44 msgCloseDelay: 10, 45 rulesModal: false, 46 togglerNameOpen: "", 47 togglerNameClose: "", 48 slideWidth: 0, 49 slideDuration: 400, 50 slideTransition: "swing", 51 accordionDuration: 500, 52 accordionEaseIn: "easeInBack", 53 accordionEaseOut: "easeOutBounce", 54 modalBackdrop: true, 55 modalClose: true, 56 modalStyle: "default", 57 modalEffect: "square", 58 modalEffectDuration: 400, 59 modalEaseIn: "easeInCubic", 60 modalEaseOut: "easeOutCubic", 61 cookieLifetime: 30, 62 cookiePath: "/", 63 cookieDomain: "", 64 onLoad: function() {}, 65 onOpen: function() {}, 66 onClose: function() {}, 67 onComplete: function(c) {}, 68 onError: function(c) {}, 69 uploadAcceptFileTypes: /(\.|\/)(gif|jpe?g|png|docx?|odt|txt|pdf|zip)$/i, 70 uploadMaxSize: 1048576, 71 uploadFilesLimit: 5, 72 uploadAutoStart: true, 73 captcha: "", 74 validatorRules: [], 75 calendars: [], 76 calendarFirstDay: 0 77 }, 78 status: 0, 79 hidden: true, 80 timer: false, 81 validator: false, 82 tooltip: false, 83 uploader: false, 84 uploadQueue: 0, 85 init: function(c) { 86 87 var e = this; 88 this.options = a.extend({}, this.defaults, c); 89 this.options.baseUrl = document.location.protocol + "//" + document.location.host + this.options.basePath + "/"; 90 this.options.ajaxUrl = this.options.baseUrl + this.options.ajaxUrl; 91 this.options.selector = this.options.selector + this.options.id; 92 this.options.selectorClass = this.options.selectorClass + this.options.id; 93 this.element = a(this.options.selector); 94 this.Msg = a(this.options.selector + "_msg"); 95 this.Form = a(this.options.selector + "_form"); 96 this.ButtonSend = a(this.options.selector + "_send"); 97 this.Toggler = a(this.options.selector + "_toggler"); 98 this.Box = a(this.options.selector + "_box"); 99 this.Container = a(this.options.selector + "_container"); 100 this.Token = a(this.options.selector + "_token"); 101 this.element.data("pwebcontact", this); 102 if (this.Form.get(0)) { 103 this.Form.get(0).reset() 104 } 105 b[this.options.id] = { 106 enabled: 0, 107 status: -1, 108 plugin: this.options.captcha 109 }; 110 if (b[this.options.id].enabled === 0) { 111 b[this.options.id].enabled = this.Form.find(".pweb-captcha").length > 0 112 } 113 114 a('a[href="' + this.options.selector + '_toggler"]').addClass((this.options.selector.replace("#", "")) + "_toggler"); 115 this.Form.submit(function(g) { 116 g.preventDefault() 117 }); 118 if (this.options.layout == "slidebox") { 119 this.element.appendTo(document.body); 120 this.initSlidebox() 121 } else { 122 if (this.options.layout == "modal") { 123 this.element.appendTo(document.body); 124 if (!this.initModal()) { 125 return false 126 } 127 } else { 128 if (this.options.layout == "accordion") { 129 this.initAccordion() 130 } 131 } 132 } 133 // console.log(['init',c,a,b]); 134 this.options.onLoad.apply(this); 135 this.element.trigger("onLoad"); 136 if (a(this.options.selector + "_form input").css("font-size").slice(0, -2) >= 20) { 137 a(this.options.selector + "_box input, " + this.options.selector + "_box select").css("height", "auto") 138 } 139 var d = false;
140 if (document.location.hash.indexOf(this.options.selector + ":") !== -1) { 141 var f = document.location.hash.replace(this.options.selector + ":", ""); 142 if (f.indexOf("open") === 0 && (typeof f[4] === "undefined" || f[4] == ":")) { 143 f = f.replace(/open(:)?/i, ""); 144 d = true 145 } 146 if (f) { 147 this.preloadFields(f) 148 } 149 } 150 if (this.options.tooltips) { 151 this.initTooltips() 152 } 153 this.initTextareaCounters(); 154 if (this.options.rulesModal) { 155 this.initModalRules() 156 } 157 this.initCalendar(); 158 if (this.Form.find(".pweb-uploader").length) { 159 this.initUploader() 160 } 161 if (this.Box.hasClass("pweb-labels-over")) { 162 this.initLabelsOverFields() 163 } 164 if (this.options.layout != "static") { 165 if (this.options.togglerNameClose) { 166 this.options.togglerNameOpen = this.Toggler.find(".pweb-text").text() 167 } 168 a(this.options.selectorClass + "_toggler").click(function(g) { 169 g.preventDefault(); 170 e.toggleForm(-1, -1, this, g) 171 }); 172 if (this.options.closeOther) { 173 pwebBoxes.push(this) 174 } 175 if (d) { 176 this.autoPopupOnPageLoad() 177 } else { 178 if (this.options.openAuto) { 179 if (this.options.maxAutoOpen > 0) { 180 if (!this.initAutoPopupCookie()) { 181 this.options.openAuto = false 182 } 183 } 184 switch (this.options.openAuto) { 185 case 1: 186 this.autoPopupOnPageLoad(); 187 break; 188 case 2: 189 this.autoPopupOnPageScroll(); 190 break; 191 case 3: 192 this.autoPopupOnPageExit() 193 } 194 } 195 } 196 } 197 this.initHiddenFields(); 198 this.initValidator(); 199 this.ButtonSend.click(function() { 200 e.submitForm() 201 }); 202 if (this.options.reset == 3) { 203 this.ButtonReset = a(this.options.selector + "_reset"); 204 this.ButtonReset.click(function() { 205 a(this).hide(); 206 e.resetForm() 207 }) 208 } 209 if (typeof navigator.cookieEnabled !== "undefined" && navigator.cookieEnabled === false) { 210 this.displayMsg(Joomla.JText._("MOD_PWEBCONTACT_COOKIES_ERR"), "error") 211 } else { 212 this.displayMsg("", "") 213 } 214 return this 215 }, 216 initSlidebox: function() { 217 var c = this; 218 this.options.togglerSlide = this.Box.hasClass("pweb-toggler-slide"); 219 this.options.togglerHidden = this.Box.hasClass("pweb-toggler-hidden"); 220 this.options.slidePos = this.element.css("position"); 221 if (!this.options.slideWidth) { 222 this.options.slideWidth = parseInt(this.Box.css("max-width")) 223 } 224 this.Box.css("width", this.options.slideWidth); 225 if (this.options.position == "left" || this.options.position == "right") { 226 this.Box.css(this.options.position, -this.options.slideWidth); 227 this.options.togglerWidth = this.options.togglerSlide ? this.Toggler.outerWidth() : 0; 228 this.options.togglerHeight = this.options.togglerSlide ? parseInt(this.Box.css("top")) : 0; 229 this.options.slideOffset = parseInt(this.element.css("top")); 230 if (this.options.togglerSlide) { 231 this.Toggler.css(this.options.position == "left" ? "right" : "left", -this.Toggler.outerWidth()) 232 } 233 } else { 234 setTimeout(function() { 235 c.Box.css(c.options.position, -c.Box.height()) 236 }, 100); 237 this.options.togglerWidth = 0; 238 this.options.togglerHeight = this.options.togglerSlide ? this.Toggler.outerHeight() : 0; 239 this.options.slideOffset = 0; 240 if (this.options.togglerSlide) { 241 this.Toggler.css(this.options.position == "top" ? "bottom" : "top", -this.Toggler.outerHeight()) 242 } 243 } 244 this.Box.addClass("pweb-closed"); 245 setTimeout(function() { 246 c.Box.removeClass("pweb-init") 247 }, 100); 248 if (this.options.togglerHidden) { 249 this.Toggler.fadeOut(0).removeClass("pweb-closed").addClass("pweb-opened"); 250 if (this.options.togglerNameClose) { 251 this.Toggler.find(".pweb-text").text(this.options.togglerNameClose) 252 } 253 } 254 this.isFF = navigator.userAgent.indexOf("Gecko") != -1; 255 a(window).scroll(function(d) { 256 if (!c.hidden && c.element.css("position") == "absolute" && c.options.slidePos == "fixed") { 257 var f = a(this).scrollTop(); 258 if (c.options.position == "bottom") { 259 f = f + a(this).height(); 260 if (f > c.element.offset().top) { 261 if (c.isFF) { 262 c.element.css("top", f) 263 } else { 264 c.element.stop().animate({ 265 top: f 266 }, 250, "linear") 267 } 268 } 269 } else { 270 f = f + c.options.slideOffset; 271 if (f < c.element.offset().top) { 272 if (c.isFF) { 273 c.element.css("top", f) 274 } else { 275 c.element.stop().animate({ 276 top: f 277 }, 250, "linear") 278 } 279 } 280 } 281 } 282 }); 283 a(window).resize(function() { 284 if (!c.hidden) { 285 var d = { 286 width: c.options.slideWidth 287 }; 288 var e = a(window).width(); 289 if (c.options.position == "left" || c.options.position == "right") { 290 if (c.options.slideWidth + c.options.togglerWidth > e) { 291 d.width = e - c.options.togglerWidth 292 } 293 } else { 294 var f = c.element.offset().left; 295 if (c.options.offsetPosition == "right") { 296 f = a(document).width() - f 297 } 298 if (c.options.slideWidth + f > e) { 299 d.width = e - f 300 } 301 } 302 c.Box.css(d); 303 if (c.options.slidePos == "fixed") { 304 var d = { 305 position: "absolute" 306 }; 307 if (c.options.position == "left" || c.options.position == "right") { 308 d.top = c.element.offset().top; 309 if (c.Box.height() + c.options.togglerHeight + d.top - a(window).scrollTop() <= a(window).height()) { 310 d.position = "fixed"; 311 d.top = c.options.slideOffset 312 } 313 } else { 314 if (c.Box.height() + c.options.togglerHeight > a(window).height()) { 315 d.top = c.element.offset().top; 316 if (c.options.position == "bottom") { 317 d.bottom = "auto" 318 } 319 } else { 320 d.position = "fixed"; 321 d[c.options.position] = 0; 322 if (c.options.position == "bottom") { 323 d.top = "auto" 324 } 325 } 326 } 327 c.element.css(d) 328 } 329 } 330 }) 331 }, 332 initModal: function() { 333 var c = this; 334 335 console.log(a.fn.modal); 336 if (typeof a.fn.modal === "function") { 337 this.Modal = a(this.options.selector + "_modal"); 338 this.options.modalClass = "pwebcontact" + this.options.id + "_modal-open pweb-modal-open pweb-modal-" + this.options.modalStyle; 339 this.Modal.appendTo(document.body).modal({ 340 show: false, 341 keyboard: false, 342 backdrop: !this.options.modalClose && this.options.modalBackdrop ? "static" : this.options.modalBackdrop 343 }).on(this.options.bootstrap === 2 ? "hidden" : "hidden.bs.modal", function(d) { 344 d.stopPropagation(); 345 if (d.target !== d.currentTarget) { 346 return 347 } 348 c.toggleForm(0); 349 a(document.body).removeClass(c.options.modalClass); 350 c.Box.addClass("pweb-closed") 351 }).on(this.options.bootstrap === 2 ? "show" : "show.bs.modal", function(d) { 352 d.stopPropagation(); 353 if (d.target !== d.currentTarget) { 354 return 355 } 356 a(document.body).addClass(c.options.modalClass); 357 c.Box.removeClass("pweb-closed") 358 }).click(function(d) { 359 if (d.target !== d.currentTarget || !c.options.modalClose) { 360 return 361 } 362 c.toggleForm(0) 363 }); 364 if (this.options.modalEffect !== "default") { 365 this.initGenie() 366 } 367 return true 368 } else { 369 if (this.options.debug) { 370 this.debug("Bootstrap Modal Plugin is not loaded") 371 } 372 } 373 return false 374 }, 375 initModalRules: function() { 376 var d = this, 377 c = this.Form.find(".pweb-modal-url"); 378 if (!c.length) { 379 return 380 } 381 if (typeof a.fn.modal === "function") { 382 if (typeof this.options.modalClass === "undefined") { 383 this.options.modalClass = "pwebcontact" + this.options.id + "_modal-open pweb-modal-open pweb-modal-" + this.options.modalStyle 384 } 385 c.click(function(i) { 386 i.preventDefault(); 387 var f = a(this).attr("href"); 388 if (f.indexOf("#") === 0 && a(f).length === 0) { 389 return 390 } 391 var g = a('<div class="pweb-modal pweb-modal-rules modal fade' + (d.options.bootstrap == 2 ? " hide" : "") + (d.Box.hasClass("pweb-rtl") ? " pweb-rtl" : "") + '"><button type="button" class="pweb-button-close" data-dismiss="modal" aria-hidden="true">×</button><div class="modal-body pweb-progress"></div></div>').appendTo(document.body).modal({ 392 show: false, 393 backdrop: (d.options.layout == "modal" ? 0 : true) 394 }).on(d.options.bootstrap === 2 ? "hidden" : "hidden.bs.modal", function() { 395 i.stopPropagation(); 396 if (f.indexOf("#") === 0) { 397 a(f).append(h) 398 } 399 a(document.body).removeClass(d.options.modalClass); 400 a(this).remove() 401 }); 402 a("body").on(d.options.bootstrap === 2 ? "show" : "show.bs.modal", "div.pweb-modal-rules", function(j) { 403 j.stopPropagation(); 404 if (j.target !== j.currentTarget) { 405 return 406 } 407 a(document.body).addClass(d.options.modalClass) 408 }); 409 if (f.indexOf("#") !== 0) { 410 g.on(d.options.bootstrap === 2 ? "shown" : "shown.bs.modal", function() { 411 a(this).find("iframe").height(a(this).height()) 412 }
412).find(".modal-body").html('<iframe width="100%" height="100%" frameborder="0" scrolling="yes" allowtransparency="true" src="' + f + '"></iframe>').css({ 413 width: "auto", 414 height: "100%", 415 padding: "0", 416 overflow: "hidden" 417 }).find("iframe").on("load", function() { 418 a(this).parent().removeClass("pweb-progress") 419 }) 420 } else { 421 var h = a(f).children(); 422 g.find(".modal-body").append(h).removeClass("pweb-progress") 423 } 424 g.modal("show") 425 }); 426 return true 427 } else { 428 if (this.options.debug) { 429 this.debug("Bootstrap Modal Plugin is not loaded") 430 } 431 } 432 return false 433 }, 434 initGenie: function() { 435 var c = this, 436 d = this.Box.attr("class").match(/pweb-bg-[a-z]+/i); 437 this.options.modalGenieClass = "pweb-genie pweb-" + this.options.modalEffect + "-" + (this.options.position !== "static" ? this.options.position : "bottom") + " pwebcontact" + this.options.id + "-genie" + (this.Box.hasClass("pweb-radius") ? " pweb-radius" : "") + (this.Box.hasClass("pweb-shadow") ? " pweb-shadow" : "") + (d ? " " + d[0] : ""); 438 if (this.options.modalEffect === "smooth") { 439 this.options.modalEaseIn = "easeInQuart"; 440 this.options.modalEaseOut = "easeOutQuart" 441 } else { 442 if (this.options.modalEffect === "rotate") { 443 this.options.modalEaseIn = "easeInQuint"; 444 this.options.modalEaseOut = "easeOutQuint" 445 } 446 } 447 this.Modal.on(this.options.bootstrap === 2 ? "show" : "show.bs.modal", function(f) { 448 f.stopPropagation(); 449 if (f.target !== f.currentTarget) { 450 return 451 } 452 if (typeof c.eventSource !== "undefined" && a(c.eventSource).length) { 453 c.Container.css({ 454 visibility: "hidden" 455 }) 456 } 457 }).on(this.options.bootstrap === 2 ? "shown" : "shown.bs.modal", function(f) { 458 f.stopPropagation(); 459 if (f.target !== f.currentTarget) { 460 return 461 } 462 if (typeof c.eventSource !== "undefined" && a(c.eventSource).length) { 463 a(c.eventSource).trigger("modalOpen") 464 } 465 }); 466 a(this.options.selectorClass + "_toggler").on("modalOpen", function() { 467 a(this).effect({ 468 effect: "transfer", 469 to: c.Container, 470 duration: c.options.modalEffectDuration, 471 easing: c.options.modalEaseIn, 472 className: "pweb-genie-show " + c.options.modalGenieClass, 473 complete: function() { 474 c.Container.css({ 475 visibility: "visible" 476 }) 477 } 478 }) 479 }); 480 this.Container.on("modalClose", function() { 481 a(this).css({ 482 visibility: "hidden" 483 }).effect({ 484 effect: "transfer", 485 to: a(c.eventSource), 486 duration: c.options.modalEffectDuration, 487 easing: c.options.modalEaseOut, 488 className: "pweb-genie-hide " + c.options.modalGenieClass, 489 complete: function() { 490 c.Modal.modal("hide") 491 } 492 }) 493 }) 494 }, 495 initAccordion: function() { 496 var c = this; 497 a(this.options.selectorClass + "_toggler").on("openAccordion", function() { 498 c.Box.removeClass("pweb-closed").slideDown({ 499 duration: c.options.accordionDuration, 500 easing: c.options.accordionEaseOut, 501 complete: function() { 502 var d = a(window).height(), 503 f = c.element.outerHeight(), 504 e = c.element.offset().top; 505 if (e + f > a(window).scrollTop() + d) { 506 if (f < d) { 507 e = e + f - d 508 } 509 a("html,body").animate({ 510 scrollTop: parseInt(e) 511 }, 500) 512 } 513 } 514 }) 515 }); 516 a(this.options.selectorClass + "_toggler").on("closeAccordion", function() { 517 c.Box.slideUp({ 518 duration: c.options.accordionDuration, 519 easing: c.options.accordionEaseIn, 520 complete: function() { 521 c.Box.addClass("pweb-closed") 522 } 523 }) 524 }); 525 this.Box.css("display", "none").removeClass("pweb-init") 526 }, 527 initTooltips: function() { 528 var c = this; 529 if (typeof a.fn.tooltip === "function") { 530 this.tooltip = true; 531 this.Form.find("input.pweb-input.pweb-tooltip,select.pweb-tooltip,textarea.pweb-tooltip").tooltip({ 532 trigger: this.options.tooltips == 2 ? "manual" : "focus", 533 html: false 534 }); 535 this.Form.find("fieldset.pweb-tooltip,.pweb-field-checkbox label.pweb-tooltip,.fileinput-button.pweb-tooltip").tooltip({ 536 trigger: this.options.tooltips == 2 ? "manual" : "hover", 537 html: false 538 }); 539 this.Form.find(".pweb-tooltip").on("show", function(d) { 540 d.stopPropagation(); 541 if (d.target !== d.currentTarget) { 542 return 543 } 544 }).on("shown", function(d) { 545 d.stopPropagation(); 546 if (d.target !== d.currentTarget) { 547 return 548 } 549 }).on(this.options.bootstrap === 2 ? "hide" : "hide.bs.tooltip", function(d) { 550 if (c.options.bootstrap === 3) { 551 d.preventDefault(); 552 a(this).siblings("div.tooltip.in").remove() 553 } 554 d.stopPropagation(); 555 if (d.target !== d.currentTarget) { 556 return 557 } 558 }).on("hidden", function(d) { 559 d.stopPropagation(); 560 if (d.target !== d.currentTarget) { 561 return 562 } 563 }); 564 return true 565 } else { 566 if (this.options.debug) { 567 this.debug("Bootstrap Tooltip Plugin is not loaded") 568 } 569 } 570 return false 571 }, 572 initCalendar: function() { 573 if (typeof Calendar === "undefined") { 574 return false 575 } 576 if (this.options.calendars.length) { 577 var c = this; 578 a.each(this.options.calendars, function(d, e) { 579 var f = "pwebcontact" + c.options.id + "_field-" + e.id; 580 Calendar.setup({ 581 inputField: f, 582 button: f + "_btn", 583 onUpdate: function() { 584 this.inputField.focus() 585 }, 586 ifFormat: typeof e.format !== "undefined" ? e.format : null, 587 firstDay: c.options.calendarFirstDay,
588 electric: false 589 }) 590 }); 591 this.Form.find(".pweb-calendar-btn").click(function() { 592 if (c.element.css("position") == "fixed" || c.options.layout == "modal") { 593 a("div.calendar:last").css("position", "fixed") 594 } 595 a(this).prev().focus() 596 }) 597 } 598 return true 599 }, 600 initLabelsOverFields: function() { 601 this.Form.find("input.pweb-input,textarea").focus(function() { 602 a("#" + a(this).attr("id") + "-lbl").parent().hide() 603 }).blur(function() { 604 if (!this.value) { 605 a("#" + a(this).attr("id") + "-lbl").parent().show() 606 } 607 }).each(function() { 608 var c = a("#" + a(this).attr("id") + "-lbl").parent(); 609 c.parent().addClass("pweb-label-over"); 610 if (this.value) { 611 c.hide() 612 } 613 }); 614 this.Form.find("select").focus(function() { 615 a("#" + a(this).attr("id") + "-lbl").parent().hide(); 616 a(this).removeClass("pweb-blank").children(":first").text(a(this).data("default-option")) 617 }).blur(function() { 618 if (a(this).val() == "" || a(this).val() == null) { 619 a(this).addClass("pweb-blank").children(":first").text(" "); 620 a("#" + a(this).attr("id") + "-lbl").parent().show() 621 } 622 }).each(function() { 623 var c = a("#" + a(this).attr("id") + "-lbl").parent(), 624 d = a(this).children(":first"); 625 c.parent().addClass("pweb-label-over"); 626 a(this).data("default-option", d.text()); 627 if (a(this).val() == "" || a(this).val() == null) { 628 a(this).addClass("pweb-blank"); 629 d.text(" ") 630 } else { 631 c.hide() 632 } 633 }); 634 return true 635 }, 636 initTextareaCounters: function() { 637 this.Form.find("textarea[maxlength]").keyup(function() { 638 var c = parseInt(a(this).attr("maxlength")); 639 var d = a(this).val(); 640 if (d.length >= c) { 641 d = d.substring(0, c); 642 a(this).val(d) 643 } 644 a("#" + a(this).attr("id") + "-limit").text(c - d.length) 645 }).trigger("keyup"); 646 return true 647 }, 648 initHiddenFields: function() { 649 a("<input/>", { 650 type: "hidden", 651 name: "title", 652 value: document.title 653 }).appendTo(this.Form); 654 a("<input/>", { 655 type: "hidden", 656 name: "url", 657 value: document.location.href 658 }).appendTo(this.Form); 659 a("<input/>", { 660 type: "hidden", 661 name: "screen_resolution", 662 value: screen.width + "x" + screen.height 663 }).appendTo(this.Form); 664 if (this.options.debug) { 665 a("<input/>", { 666 type: "hidden", 667 name: "debug", 668 value: 1 669 }).appendTo(this.Form) 670 } 671 return true 672 }, 673 initUploader: function() { 674 var c = this; 675 if (typeof a.fn.fileupload !== "function") { 676 if (this.options.debug) { 677 this.debug("jQuery File Upload Plugin is not loaded") 678 } 679 return false 680 } 681 this.files = []; 682 this.uploader = a(this.options.selector + "_uploader_container").fileupload({ 683 url: this.options.ajaxUrl + "uploader", 684 type: "POST", 685 dataType: "json", 686 dataFilter: this.ajaxResponseDataFilter, 687 accepts: "application/json; charset=utf-8", 688 headers: { 689 Accept: "application/json; charset=utf-8" 690 }, 691 converters: { 692 "text json": function(d) { 693 d = a.parseJSON(d); 694 if (typeof d.data !== "undefined" && d.data) { 695 d = d.data 696 } 697 return d 698 }, 699 "iframe json": function(d) { 700 d = a.parseJSON(d); 701 if (typeof d.data !== "undefined" && d.data) { 702 d = d.data 703 } 704 return d 705 } 706 }, 707 formData: function(d) {
708 return a.merge(d.serializeArray(), [{ 709 name: "format", 710 value: "json" 711 }, { 712 name: "mid", 713 value: c.options.id 714 }, { 715 name: "ignoreMessages", 716 value: true 717 }]) 718 }, 719 autoUpload: this.options.uploadAutoStart === true, 720 acceptFileTypes: this.options.uploadAcceptFileTypes, 721 maxFileSize: this.options.uploadMaxSize, 722 maxNumberOfFiles: this.options.uploadFilesLimit, 723 getNumberOfFiles: function() { 724 return this.filesContainer.children(".pweb-upload-success, .pweb-upload-ready").length 725 }, 726 messages: { 727 uploadedBytes: Joomla.JText._("MOD_PWEBCONTACT_UPLOAD_BYTES_ERR"), 728 maxNumberOfFiles: Joomla.JText._("MOD_PWEBCONTACT_UPLOAD_LIMIT_ERR"), 729 acceptFileTypes: Joomla.JText._("MOD_PWEBCONTACT_UPLOAD_TYPE_ERR"), 730 maxFileSize: Joomla.JText._("MOD_PWEBCONTACT_UPLOAD_SIZE_ERR") 731 }, 732 dropZone: this.Box, 733 pasteZone: null, 734 uploadTemplateId: null, 735 downloadTemplateId: null, 736 uploadTemplate: function(e) { 737 var d = a(); 738 a.each(e.files, function(f, g) { 739 var h = c.uploader.find(".templates .template-upload").clone(); 740 h.find(".name").text(g.name); 741 h.find(".cancel").bind("click", function() { 742 if (h.hasClass("pweb-upload-ready")) { 743 c.uploadQueue-- 744 } 745 if (c.status == 0) { 746 c.displayMsg("", "") 747 } 748 }); 749 d = d.add(h) 750 }); 751 return d 752 }, 753 downloadTemplate: function(e) { 754 var d = a(); 755 a.each(e.files, function(f, h) { 756 var j = c.uploader.find(".templates .template-download").clone(); 757 j.find(".size").text(e.formatFileSize(h.size)); 758 j.find(".name").text(h.name); 759 var g = j.find(".delete").bind("click", function() { 760 var k = a.inArray(h.name, c.files); 761 if (k > -1) { 762 c.files.splice(k, 1) 763 } 764 if (c.status == 0) { 765 c.displayMsg("", "") 766 } 767 }); 768 if (h.name) { 769 var i = { 770 file: h.name, 771 mid: c.options.id, 772 format: "json", 773 ignoreMessages: true 774 }; 775 if (h.deleteType == "POST") { 776 i._method = "DELETE"; 777 g.data("type", "POST") 778 } 779 i[c.Token.attr("name")] = 1; 780 g.data("url", c.options.ajaxUrl + "uploader&" + decodeURIComponent(a.param(i))) 781 } 782 if (h.error) { 783 j.find(".success").remove(); 784 j.find(".error").text(h.error) 785 } else { 786 j.find(".warning, .error").remove(); 787 j.addClass("pweb-upload-success"); 788 c.files.push(h.name) 789 } 790 d = d.add(j) 791 }); 792 return d 793 } 794 }).on("fileuploaddragover", function(d) { 795 c.Box.addClass("pweb-dragged"); 796 c.Box.find(".pweb-dropzone").css({ 797 width: c.Box.width(), 798 height: c.Box.height() 799 }) 800 }).on("fileuploaddrop", function(f, d) { 801 c.Box.removeClass("pweb-dragged") 802 }).on("fileuploadadd", function(f, d) { 803 if (c.options.reloadToken && c.status == 0 && c.options.uploadAutoStart) { 804 c.ajaxCall("getToken", false) 805 } 806 }).on("fileuploadprocessdone", function(f, d) { 807 c.uploadQueue++; 808 d.context.addClass("pweb-upload-ready").find(".warning,.error").remove() 809 }).on("fileuploadprocessfail", function(f, d) { 810 d.context.each(function(e) { 811 a(this).find(".ready,.progress").remove(); 812 var g = a(this).find(".cancel"); 813 setTimeout(function() { 814 g.click() 815 }, 3000) 816 }) 817 }).on("fileuploadstart", function(d) { 818 if (c.options.uploadAutoStart) { 819 if (c.status == 0) { 820 c.displayMsg("", "") 821 } 822 c.status = 2 823 } 824 }).on("fileuploaddone", function(f, d) { 825 c.uploadQueue--; 826 if (!(d.getFilesFromResponse(d)).length) { 827 c.displayMsg(Joomla.JText._("MOD_PWEBCONTACT_UPLOAD_ERR") + (typeof d.result.message !== "undefined" ? ". " + d.result.message : ""), "error"); 828 if (d.autoUpload === false) { 829 c.status = 5 830 } 831 } 832 }).on("fileuploadfail", function(f, d) { 833 c.displayMsg(Joomla.JText._("MOD_PWEBCONTACT_UPLOAD_ERR"), "error"); 834 if (d.autoUpload === false) { 835 c.status = 5 836 } 837 }).on("fileuploadalways", function(f, d) { 838 if (d.textStatus == "parsererror") { 839 c.debug(d.jqXHR.responseText) 840 } else { 841 if (c.options.debug && d.result && typeof d.result.debug !== "undefined" && d.result.debug) { 842 c.debug(d.result.debug, d.result.status) 843 } 844 } 845 }).on("fileuploadfinished", function(f, d) { 846 if (c.uploadQueue == 0) { 847 if (d.autoUpload || c.status == 5) { 848 c.status = 0 849 } else { 850 if (c.status == 1) { 851 c.ajaxCall("sendEmail") 852 } 853 } 854 } 855 }); 856 this.Box.bind("dragleave", function(d) { 857 a(this).removeClass("pweb-dragged") 858 }); 859 if (this.tooltip) { 860 this.uploader.find(".fileinput-button").click(function() { 861 if (a(this).hasClass("pweb-tooltip")) { 862 a(this).tooltip("hide") 863 } 864 }) 865 } 866 a(window).on("unload", function() { 867 if (c.files.length) { 868 c.uploader.find(".files .delete").click() 869 } 870 }); 871 return true 872 }, 873 initValidator: function() { 874 var c = this; 875 if (typeof a.fn.validate === "function") { 876 if (b[this.options.id].enabled === true) { 877 setTimeout(function() { 878 c.Form.find(".pweb-captcha input[type=text]").addClass("pweb-input required") 879 }, 1000) 880 } 881 a.each(this.options.validatorRules, function(d, e) { 882 a.validator.addMethod("pweb" + c.options.id + "-validate-" + e.name, function(g, f) { 883 return this.optional(f) || (e.regexp).test(g) 884 }, "") 885 }); 886 if (this.uploader) { 887 a.validator.addMethod("pweb-validate-uploader", function(e, d) { 888 return a(d).closest(".pweb-uploader").find(".files .pweb-upload-success,.files .pweb-upload-ready").length 889 }, "") 890 } 891 this.validator = this.Form.validate({ 892 debug: this.options.debug, 893 onsubmit: false,
894 errorClass: "invalid", 895 showErrors: function(g, e) { 896 var h, d; 897 for (h = 0; e[h]; h++) { 898 var j = e[h].element; 899 this.settings.highlight.call(this, j, this.settings.errorClass, this.settings.validClass); 900 j = a(j); 901 if (j.hasClass("pweb-fieldset")) { 902 j = j.parents("fieldset") 903 } 904 a("#" + j[0].id + "-lbl").addClass(this.settings.errorClass); 905 if (h == 0 && c.element.css("position") != "fixed") { 906 if (c.options.layout == "modal") { 907 var l = c.Box.outerHeight() - a(window).height(); 908 if (l > 0) { 909 var m = j.parent().parent().offset().top - c.Box.offset().top; 910 if (m > l) { 911 m = l 912 } 913 c.Modal.animate({ 914 scrollTop: parseInt(m) 915 }, 500) 916 } 917 } else { 918 if (c.element.css("position") != "fixed") { 919 var m = j.parent().parent().offset().top - 10, 920 k = a(window).scrollTop(), 921 f = a(window).height(); 922 if (m < k + 50 || m > k + f - 50) { 923 m = m - f / 2; 924 a("html,body").animate({ 925 scrollTop: parseInt(m) 926 }, 500) 927 } 928 } 929 } 930 } 931 if (c.tooltip && c.options.tooltips >= 2) { 932 if (j.hasClass("pweb-single-checkbox")) { 933 if (j.next().hasClass("pweb-tooltip")) { 934 j.next().tooltip("show") 935 } 936 } else { 937 if (j.hasClass("pweb-tooltip")) { 938 j.tooltip("show") 939 } 940 } 941 } 942 } 943 for (h = 0, d = this.validElements(); d[h]; h++) { 944 var j = d[h]; 945 this.settings.unhighlight.call(this, j, this.settings.errorClass, this.settings.validClass); 946 j = a(j); 947 if (j.hasClass("pweb-fieldset")) { 948 j = j.parents("fieldset") 949 } 950 a("#" + j[0].id + "-lbl").removeClass(this.settings.errorClass); 951 if (c.tooltip && c.options.tooltips >= 2) { 952 if (j.hasClass("pweb-single-checkbox")) { 953 if (j.next().hasClass("pweb-tooltip")) { 954 j.next().tooltip("hide") 955 } 956 } else { 957 if (j.hasClass("pweb-tooltip")) { 958 j.tooltip("hide") 959 } 960 } 961 } 962 } 963 } 964 }); 965 return true 966 } else { 967 if (this.options.debug) { 968 this.debug("jQuery Validate Plugin is not loaded") 969 } 970 } 971 return false 972 }, 973 preloadFields: function(f) { 974 var d = this; 975 try { 976 var c = f.split("/"); 977 a.each(c, function(i, j) { 978 j = j.split("="); 979 if (j.length >= 2) { 980 j[1] = unescape(j[1]); 981 var h = a(d.options.selector + "_field-" + j[0]), 982 e = h.prop("tagName").toLowerCase(); 983 if (e == "fieldset") { 984 h.find("input").val(j[1].split(";")) 985 } else { 986 if (e == "select" && h.attr("multiple")) { 987 h.val(j[1].split(";")).trigger("focus").trigger("blur") 988 } else { 989 if (e == "input" && h.attr("type") == "checkbox") { 990 h.attr("checked", j[1] != 0 ? true : false) 991 } else { 992 h.val(j[1]).trigger("focus").trigger("blur"); 993 if (e == "textarea") { 994 h.trigger("keyup") 995 } 996 } 997 } 998 } 999 } 1000 }) 1001 } catch (g) { 1002 console.log(g) 1003 } 1004 }, 1005 close: function() { 1006 this.toggleForm(0) 1007 }, 1008 toggleForm: function(c, i, h, d) { 1009 console.log('tgg'); 1010 var g = this; 1011 if (typeof c === "undefined") { 1012 c = -1 1013 } 1014 if (typeof h === "undefined") { 1015 h = this.Toggler 1016 } 1017 if (!this.hidden && (c === -1 || c === 0)) { 1018 this.hidden = true; 1019 if (this.Toggler.length && !this.options.togglerHidden) { 1020 this.Toggler.removeClass("pweb-opened").addClass("pweb-closed"); 1021 if (this.options.togglerNameClose) { 1022 this.Toggler.find(".pweb-text").text(this.options.togglerNameOpen) 1023 } 1024 } 1025 if (this.options.openAuto === false && this.timer) { 1026 clearTimeout(this.timer) 1027 } 1028 if (this.options.layout == "slidebox") { 1029 var f = {}; 1030 f[this.options.position] = (this.options.position == "left" || this.options.position == "right") ? -this.Box.width() : -this.Box.height(); 1031 this.Box.stop(true, false).animate(f, this.options.slideDuration, this.options.slideTransition, function() { 1032 g.Box.addClass("pweb-closed"); 1033 if (g.element.css("position") == "absolute" && g.options.slidePos == "fixed") { 1034 var l = { 1035 position: "fixed" 1036 }; 1037 if (g.options.position == "left" || g.options.position == "right") { 1038 l.top = g.options.slideOffset 1039 } else { 1040 l[g.options.position] = 0; 1041 if (g.options.position == "bottom") { 1042 l.top = "auto" 1043 } 1044 } 1045 g.element.css(l) 1046 } 1047 }); 1048 if (this.options.togglerHidden) { 1049 this.Toggler.fadeOut(this.options.slideDuration) 1050 } 1051 } else { 1052 if (this.options.layout == "modal") { 1053 if (this.options.modalEffect != "default" && typeof this.eventSource !== "undefined") { 1054 this.Container.trigger("modalClose") 1055 } else { 1056 this.Modal.modal("hide") 1057 } 1058 } else { 1059 if (this.options.layout == "accordion") { 1060 a(h).trigger("closeAccordion") 1061 } 1062 } 1063 } 1064 this.options.onClose.apply(this); 1065 this.element.trigger("onClose"); 1066 if (this.options.reset == 2) { 1067 this.resetForm() 1068 } 1069 } else { 1070 if (this.hidden && (c === -1 || c === 1)) { 1071 if (this.options.closeOther) { 1072 a.each(pwebBoxes, function() { 1073 if (this.options.id != g.options.id && typeof this.close === "function") { 1074 this.close() 1075 } 1076 }) 1077 } 1078 if (this.options.openAuto === 1 || this.options.openAuto === 2) { 1079 this.options.openAuto = false;
1080 if (this.timer) { 1081 clearTimeout(this.timer) 1082 } 1083 } 1084 if (typeof i === "number" && i >= 0) { 1085 var j = a(this.options.selector + "_mailto"); 1086 if (j.length) { 1087 j[0].selectedIndex = parseInt(i); 1088 if (this.Box.hasClass("pweb-labels-over")) { 1089 j.trigger("focus").trigger("blur") 1090 } 1091 } 1092 } 1093 if (a(h).length) { 1094 if (a(h).data("pwebcontact-fields")) { 1095 this.preloadFields(a(h).data("pwebcontact-fields")) 1096 } 1097 if (a(h).data("pwebcontact-fields-once")) { 1098 this.preloadFields(a(h).data("pwebcontact-fields-once")); 1099 a(h).data("pwebcontact-fields-once", "") 1100 } 1101 } 1102 this.hidden = false; 1103 if (this.Toggler.length && !this.options.togglerHidden) { 1104 this.Toggler.removeClass("pweb-closed").addClass("pweb-opened"); 1105 if (this.options.togglerNameClose) { 1106 this.Toggler.find(".pweb-text").text(this.options.togglerNameClose) 1107 } 1108 } 1109 if (this.options.layout == "slidebox") { 1110 var f = { 1111 width: this.options.slideWidth 1112 }; 1113 f[this.options.position] = 0; 1114 var k = a(window).width(); 1115 if (this.options.position == "left" || this.options.position == "right") { 1116 if (this.options.slideWidth + this.options.togglerWidth > k) { 1117 f.width = k - this.options.togglerWidth 1118 } 1119 } else { 1120 var e = this.element.offset().left; 1121 if (this.options.offsetPosition == "right") { 1122 e = a(document).width() - e 1123 } 1124 if (this.options.slideWidth + e > k) { 1125 f.width = k - e 1126 } 1127 } 1128 this.Box.stop(true, false).animate(f, this.options.slideDuration, this.options.slideTransition, function() { 1129 if (g.options.slidePos == "fixed") { 1130 var l = { 1131 position: "absolute" 1132 }; 1133 if (g.options.position == "left" || g.options.position == "right") { 1134 l.top = g.element.offset().top; 1135 if (g.Box.height() + g.options.togglerHeight + l.top - a(window).scrollTop() > a(window).height()) { 1136 l.top = g.element.offset().top; 1137 g.element.css(l) 1138 } 1139 } else { 1140 if (g.Box.height() + g.options.togglerHeight > a(window).height()) { 1141 l.top = g.element.offset().top; 1142 if (g.options.position == "bottom") { 1143 l.bottom = "auto" 1144 } 1145 g.element.css(l) 1146 } 1147 } 1148 } 1149 }).css("overflow", "visible").removeClass("pweb-closed"); 1150 if (this.options.togglerHidden) { 1151 this.Toggler.fadeIn(this.options.slideDuration) 1152 } 1153 } else { 1154 if (this.options.layout == "modal") { 1155 if (this.options.modalEffect != "default" && a(h).length) { 1156 this.eventSource = h 1157 } 1158 this.Modal.modal("show") 1159 } else { 1160 if (this.options.layout == "accordion") { 1161 a(h).trigger("openAccordion") 1162 } 1163 } 1164 } 1165 this.options.onOpen.apply(this); 1166 this.element.trigger("onOpen") 1167 } 1168 } 1169 }, 1170 resetForm: function() { 1171 if (this.status == 3) { 1172 var d = this; 1173 setTimeout(function() { 1174 d.status = 0 1175 }, 5000); 1176 this.status = 4; 1177 this.displayMsg("", ""); 1178 if (!this.options.redirectURL) { 1179 this.ajaxCall("getToken") 1180 } 1181 this.ButtonSend.show(); 1182 this.Form.find("textarea.pweb-charslimit").each(function() { 1183 a("#" + a(this).attr("id") + "-charsleft").text(parseInt(a(this).attr("maxlength"))) 1184 }); 1185 if (this.validator) { 1186 this.validator.resetForm() 1187 } 1188 if (this.Form.get(0)) { 1189 this.Form.get(0).reset() 1190 }
1191 this.Form.find(".invalid").removeClass("invalid"); 1192 if (this.Box.hasClass("pweb-labels-over")) { 1193 this.Form.find("input.pweb-input,textarea,select").trigger("focus").trigger("blur") 1194 } 1195 if (this.uploader) { 1196 var c = this.uploader.find(".files"); 1197 c.find(".cancel,.delete").click(); 1198 c.empty(); 1199 this.files = []; 1200 this.uploadQueue = 0 1201 } 1202 b[this.options.id].status = -1; 1203 if (b[this.options.id].enabled === true && !this.options.redirectURL) { 1204 if (b[this.options.id].plugin === "grecaptcha" && typeof grecaptcha !== "undefined") { 1205 var e = a(this.options.selector + "_captcha").data("grecaptchaId"); 1206 if (typeof e === "number") { 1207 grecaptcha.reset(e) 1208 } 1209 } else { 1210 if (b[this.options.id].plugin === "recaptcha" && typeof Recaptcha !== "undefined") { 1211 Recaptcha.reload() 1212 } 1213 } 1214 } 1215 } 1216 }, 1217 submitForm: function() { 1218 var d = this; 1219 if (this.status == 1 || this.status == 2 || this.status == 3 || this.status == 5) { 1220 return false 1221 } 1222 if (this.validator && !this.validator.form()) { 1223 return false 1224 } 1225 if (this.status == 4) { 1226 var e = Joomla.JText._("MOD_PWEBCONTACT_SEND_ERR"); 1227 if (this.options.msgPosition == "popup") { 1228 this.displayAlert(e, "error") 1229 } else { 1230 this.scrollToMsg(); 1231 this.displayMsg(e, "error") 1232 } 1233 return false 1234 } 1235 this.status = 1; 1236 this.scrollToMsg(); 1237 if (this.options.reloadToken) { 1238 this.ajaxCall("getToken", false) 1239 } 1240 if (b[this.options.id].enabled === true && b[this.options.id].status === -1) { 1241 this.ajaxCall("checkCaptcha", false) 1242 } 1243 if (b[this.options.id].status === false) { 1244 if (b[this.options.id].plugin === "grecaptcha" && typeof grecaptcha !== "undefined") { 1245 var f = a(this.options.selector + "_captcha").data("grecaptchaId"); 1246 if (typeof f === "number") { 1247 grecaptcha.reset(f) 1248 } 1249 } else { 1250 if (b[this.options.id].plugin === "Recaptcha" && typeof Recaptcha !== "undefined") { 1251 Recaptcha.reload() 1252 } 1253 } 1254 b[this.options.id].status = -1; 1255 return false 1256 } 1257 if (this.uploader && !this.options.uploadAutoStart) { 1258 var c = this.uploader.find(".files .pweb-upload-ready"); 1259 if (c.length) { 1260 this.displayMsg(Joomla.JText._("MOD_PWEBCONTACT_UPLOADING"), "progress"); 1261 c.each(function(g) { 1262 var h = a(this).data("data"); 1263 if (typeof h.submit === "function") { 1264 h.submit() 1265 } 1266 }); 1267 return true 1268 } 1269 } 1270 if (this.status == 1) { 1271 this.ajaxCall("sendEmail") 1272 } 1273 }, 1274 ajaxCall: function(f, c) { 1275 var d = this, 1276 e = { 1277 mid: this.options.id, 1278 format: "json", 1279 ignoreMessages: true 1280 }; 1281 if (f == "sendEmail" || f == "checkCaptcha") { 1282 if (this.uploader && this.files.length && f == "sendEmail") { 1283 e.attachments = this.files 1284 } 1285 e = decodeURIComponent(a.param(e)) + "&" + this.Form.serialize() 1286 } 1287 if (typeof c === "undefined") { 1288 c = true 1289 }
1290 a.ajax({ 1291 url: this.options.ajaxUrl + f, 1292 type: "POST", 1293 cache: false, 1294 async: c, 1295 data: e, 1296 dataType: "json", 1297 dataFilter: this.ajaxResponseDataFilter, 1298 beforeSend: function() { 1299 if (f == "sendEmail" || !c) { 1300 d.displayMsg(Joomla.JText._("MOD_PWEBCONTACT_SENDING"), "progress") 1301 } 1302 } 1303 }).done(function(g, j, h) { 1304 if (typeof g.data !== "undefined" && typeof g.data.status !== "undefined") { 1305 var i = g.data; 1306 if (!c) { 1307 d.displayMsg("", "") 1308 } 1309 if (f == "getToken") { 1310 d.options.reloadToken = false; 1311 d.Token.attr("name", i.token) 1312 } else { 1313 if (i.debug) { 1314 d.debug(i.debug, i.status) 1315 } 1316 if (typeof i.deleted !== "undefined" && !d.options.reset && i.deleted && d.uploader) { 1317 d.uploader.find(".files").empty(); 1318 d.files = []; 1319 d.uploadQueue = 0 1320 } 1321 if (i.status >= 1 && i.status <= 199) { 1322 if (f == "sendEmail") { 1323 d.status = 3; 1324 d.options.onComplete.apply(d, [i]); 1325 d.element.trigger("onComplete"); 1326 if (d.uploader) { 1327 d.uploader.find(".files .pweb-upload-success .delete").remove() 1328 } 1329 if (d.options.reset == 1) { 1330 d.resetForm() 1331 } else { 1332 if (d.options.reset == 2) { 1333 d.ButtonSend.hide() 1334 } else { 1335 if (d.options.reset == 3) { 1336 d.ButtonSend.hide(); 1337 d.ButtonReset.show() 1338 } else { 1339 d.status = 4; 1340 setTimeout(function() { 1341 d.status = 0 1342 }, 5000) 1343 } 1344 } 1345 } 1346 if (d.options.msgPosition == "popup") { 1347 d.displayAlert(i.msg, "success"); 1348 i.msg = "" 1349 } 1350 d.displayMsg(i.msg, "success"); 1351 if (d.options.closeAuto) { 1352 d.autoCloseOnSuccess() 1353 } 1354 if (d.options.redirectURL) { 1355 d.redirectOnSuccess() 1356 } 1357 } else { 1358 if (f == "checkCaptcha") { 1359 b[d.options.id].status = true 1360 } 1361 } 1362 } else { 1363 if (f == "checkCaptcha") { 1364 b[d.options.id].status = false; 1365 d.Form.find(".pweb-captcha input").removeClass("val
1365id").addClass("invalid") 1366 } 1367 if (typeof i.invalid !== "undefined") { 1368 d.Form.find(".invalid").removeClass("invalid"); 1369 a.each(i.invalid, function(k, m) { 1370 var l = a(d.options.selector + "_" + m); 1371 if (l.is("input,textarea,select")) { 1372 l.addClass("invalid") 1373 } 1374 a(d.options.selector + "_" + m + "-lbl").addClass("invalid") 1375 }) 1376 } 1377 d.options.onError.apply(d, [i]); 1378 d.element.trigger("onError"); 1379 d.status = 0; 1380 if (i.status >= 300 && !d.options.debug) { 1381 d.status = 5; 1382 d.ButtonSend.hide() 1383 } 1384 if (d.options.msgPosition == "popup") { 1385 d.displayAlert(i.msg, "error"); 1386 i.msg = "" 1387 } 1388 d.displayMsg(i.msg, "error") 1389 } 1390 } 1391 } else { 1392 d.displayError(j, h.responseText.indexOf("<html") === -1 ? h.responseText : "") 1393 } 1394 }).fail(function(g, i, h) { 1395 d.displayError(g.status + " " + h, g.responseText.indexOf("<html") === -1 ? g.responseText : "") 1396 }) 1397 }, 1398 ajaxResponseDataFilter: function(f, e) { 1399 if (e === "iframe json" && f && typeof f === "object") { 1400 f = a(f[0].body).text() 1401 } 1402 if (e.indexOf("json") !== -1 && typeof f === "string" && (f.indexOf("{") !== 0 || f[f.length - 1] !== "}")) { 1403 var d = f.match(/{"success":.+{"status":[0-9]+(,"[a-z]+":.+)+}}/i); 1404 if (d) { 1405 if (typeof JSON.stringify === "function") { 1406 var c = a.parseJSON(d[0]); 1407 if (typeof c.data.debug === "undefined" || !c.data.debug) { 1408 c.data.debug = [] 1409 } 1410 c.data.debug.push(f.replace(d[0], " ")); 1411 f = JSON.stringify(c) 1412 } else { 1413 f = d[0] 1414 } 1415 } 1416 } 1417 return f 1418 }, 1419 captchaExpired: function() { 1420 b[this.options.id].status = -1 1421 }, 1422 scrollToMsg: function() { 1423 if (this.options.msgScroll && (this.options.msgPosition == "before" || this.options.msgPosition == "after")) { 1424 if (this.options.layout == "modal") { 1425 var g = this.options.msgPosition == "after" ? this.Box.outerHeight() - a(window).height() : 0; 1426 if (g >= 0) { 1427 this.Modal.animate({ 1428 scrollTop: g 1429 }, 500) 1430 } 1431 } else { 1432 if (this.element.css("position") != "fixed") { 1433 var f = this.Msg.offset().top, 1434 e = this.Msg.height(), 1435 c = a(window).scrollTop(), 1436 d = a(window).height(); 1437 if (f < c || f + e > c + d) { 1438 if (this.options.msgPosition == "before") { 1439 var g = f - 100 1440 } else { 1441 var g = f + e + 100 - d 1442 } 1443 a("html,body").animate({ 1444 scrollTop: parseInt(g) 1445 }, 500) 1446 } 1447 } 1448 } 1449 } 1450 }, 1451 initAutoPopupCookie: function() { 1452 if (typeof a.cookie === "function") { 1453 var c = parseInt(a.cookie("pwebcontact" + this.options.id + "_openauto")); 1454 c = isNaN(c) ? 1 : c + 1; 1455 if (c <= this.options.maxAutoOpen) { 1456 a.cookie("pwebcontact" + this.options.id + "_openauto", c, { 1457 domain: this.options.cookieDomain, 1458 path: this.options.cookiePath, 1459 expires: this.options.cookieLifetime 1460 }); 1461 return true 1462 } 1463 } else { 1464 if (this.options.debug) { 1465 this.debug("jQuery Cookie Plugin is not loaded") 1466 } 1467 } 1468 return false 1469 }, 1470 autoPopupOnPageLoad: function() { 1471 if (this.options.openDelay) { 1472 this.timer = this.delay(this.toggleForm, this.options.openDelay, this, [1]) 1473 } else { 1474 this.toggleForm(1) 1475 } 1476 }, 1477 autoPopupOnPageScroll: function() { 1478 var c = this; 1479 this.autoOpen = true; 1480 a(window).scroll(function() { 1481 if (c.autoOpen) { 1482 c.autoOpen = false;
1483 if (c.options.openDelay) { 1484 c.timer = c.delay(c.toggleForm, c.options.openDelay, c, [1]) 1485 } else { 1486 c.toggleForm(1) 1487 } 1488 } 1489 }) 1490 }, 1491 autoPopupOnPageExit: function() { 1492 var c = this; 1493 this.autoOpen = -1; 1494 a(window).mousemove(function(d) { 1495 if (c.autoOpen == -1 && d.clientY > 70) { 1496 c.autoOpen = 1 1497 } else { 1498 if (c.autoOpen == 1 && d.clientY < 30) { 1499 c.autoOpen = 0; 1500 if (c.options.openDelay) { 1501 c.timer = c.delay(c.toggleForm, c.options.openDelay, c, [1]) 1502 } else { 1503 c.toggleForm(1) 1504 } 1505 } 1506 } 1507 }) 1508 }, 1509 autoCloseOnSuccess: function() { 1510 if (this.options.closeDelay) { 1511 this.timer = this.delay(this.toggleForm, this.options.closeDelay, this, [0]) 1512 } else { 1513 this.toggleForm(0) 1514 } 1515 }, 1516 redirectOnSuccess: function() { 1517 var c = this; 1518 setTimeout(function() { 1519 document.location = c.options.redirectURL 1520 }, this.options.redirectDelay * 1000) 1521 }, 1522 delay: function(e, d, f, c) { 1523 return setTimeout(function() { 1524 return e.apply(f, c || arguments) 1525 }, d) 1526 }, 1527 displayError: function(e, c) { 1528 if (!this.options.debug) { 1529 this.status = 5; 1530 this.ButtonSend.hide() 1531 } else { 1532 this.status = 0 1533 } 1534 var d = Joomla.JText._("MOD_PWEBCONTACT_REQUEST_ERR") + e; 1535 if (this.options.msgPosition == "popup") { 1536 this.displayAlert(d, "error") 1537 } else { 1538 this.displayMsg(d, "error") 1539 } 1540 if (c) { 1541 this.debug(c) 1542 } 1543 }, 1544 displayMsg: function(c, d) { 1545 this.Msg.html(c ? c : " ").attr("class", d ? "pweb-" + d : "") 1546 }, 1547 displayAlert: function(c, d, f, g) { 1548 if (typeof a.fn.alert === "function") { 1549 var e = a('<div class="pweb-alert alert alert-block ' + (d ? "alert-" + d : "") + ' fade in"><button data-dismiss="alert" class="close" type="button">×</button>' + (typeof f !== "undefined" ? '<h4 class="alert-heading">' + f + "</h4>" : "") + "<p>" + c + "</p></div>").alert().appendTo(document.body); 1550 if ((typeof g === "undefined" || g) && this.options.msgCloseDelay) { 1551 setTimeout(function() { 1552 e.alert("close") 1553 }, this.options.msgCloseDelay * 1000) 1554 } 1555 } else { 1556 alert(c.replace("<br>", "\r\n")) 1557 } 1558 }, 1559 debug: function(c, d) { 1560 if (a.isArray(c)) { 1561 c = c.join("<br>") 1562 } 1563 if (typeof d !== "undefined") { 1564 c = c + "<br>Response code: " + d 1565 } 1566 this.displayAlert(c, "info", "Perfect Ajax Popup Contact Form Debug", false) 1567 } 1568 } 1569 })(); 1570 pwebContact.options = pwebContact.prototype.options; 1571 if (typeof Joomla === "undefined") { 1572 Joomla = {} 1573 } 1574 if (typeof Joomla.JText === "undefined" || typeof Joomla.JText._ !== "function") { 1575 Joomla.JText = { 1576 strings: Joomla.JText || {}, 1577 _: function(b, c) { 1578 return typeof this.strings[b.toUpperCase()] !== "undefined" ? this.strings[b.toUpperCase()] : c 1579 }, 1580 load: function(b) { 1581 for (var c in b) { 1582 this.strings[c.toUpperCase()] = b[c] 1583 } 1584 return this 1585 } 1586 } 1587 } 1588})(window.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.