Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- document.documentElement.className += " js_active ";
- document.documentElement.className += "ontouchstart" in document.documentElement ? " avia_mobile " : " avia_desktop ";
- (function() {
- var d = ["-webkit-", "-o-", "-moz-", "-ms-", ""], a;
- for(a in d) {
- d[a] + "transform" in document.documentElement.style && (document.documentElement.className += " avia_transform ")
- }
- })();
- function avia_log(d, a) {
- "undefined" !== typeof console && ("undefined" === typeof a && (a = "log"), a = "AVIA-" + a.toUpperCase(), console.log("[" + a + "] " + d))
- }
- function avia_nl2br(d, a) {
- return(d + "").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, "$1" + (a || "undefined" === typeof a ? "<br />" : "<br>") + "$2")
- }
- (function(d) {
- d.AviaBuilder = function() {
- this.canvas = d("#aviaLayoutBuilder");
- this.canvasParent = this.canvas.parents(".postbox:eq(0)");
- this.activeStatus = this.canvasParent.find("#aviaLayoutBuilder_active");
- this.shortcodes = d.AviaBuilder.shortcodes || {};
- this.safemode = avia_globals.builderMode || !1;
- this.tiny_active = "undefined" == typeof window.tinyMCE ? !1 : !0;
- this.classic_editor = d("#postdivrich");
- this.classic_editor_wrap = d("#postdivrich_wrap");
- this.switch_button = this.classic_editor_wrap.find(".avia-builder-button");
- this.classic_textarea = d("#content.wp-editor-area");
- this.secureContent = d("#_aviaLayoutBuilderCleanData");
- this.datastorage = 'textarea[data-name="text-shortcode"]';
- this.shortcode_wrap = d(".shortcode_button_wrap");
- this.update_timout = this.only_one_insert = this.targetInsert = !1;
- this.set_up()
- };
- d.AviaBuilder.prototype = {set_up:function() {
- this.place_top();
- this.convertTextToInterface();
- this.add_behavior()
- }, place_top:function() {
- var a = d("#normal-sortables");
- 0 !== a.find(".postbox").index(this.canvasParent) && (this.canvasParent.prependTo(a), window.postboxes.save_order(pagenow))
- }, add_behavior:function() {
- var a = this, b = d("body");
- this.switch_button.on("click", function(c) {
- c.preventDefault();
- a.switch_layout_mode()
- });
- this.shortcode_wrap.on("click", ".shortcode_insert_button", function() {
- d(this).parents(".shortcode_button_wrap");
- var c = this.hash.replace("#", "");
- this.className.indexOf("avia-active-insert");
- a.shortcodes.fetchShortcodeEditorElement(c, "instant_insert", a);
- return!1
- });
- this.canvas.on("click", "a.avia-delete", function() {
- a.shortcodes.deleteItem(this, a);
- return!1
- });
- this.canvas.on("click", "a.avia-change-col-size", function() {
- a.shortcodes.changeSize(this, a);
- return!1
- });
- b.on("click", ".avia-edit-element", function() {
- var c = d(this).parents(".avia_sortable_element:eq(0)");
- c.length || (c = d(this).parents(".avia_layout_section:eq(0)"));
- var b = c.data();
- b.scope = a;
- b.on_load = c.data("modal_on_load");
- b.before_save = c.data("before_save");
- b.on_save = a.send_to_datastorage;
- b.save_param = c;
- b.ajax_param = {extract:!0, shortcode:c.find(">.avia_inner_shortcode>" + a.datastorage + ":eq(0)").val(), allowed:b.allowedShortcodes};
- new d.AviaModal(b);
- return!1
- });
- b.on("click", ".avia-modal-group-element-inner", function() {
- var c = d(this).parents(".avia-modal-group-element:eq(0)"), b = c.data();
- b.scope = a;
- b.on_load = c.data("modal_on_load");
- b.before_save = c.data("before_save");
- b.on_save = a.send_to_datastorage;
- b.save_param = c;
- b.ajax_param = {subelement:!0, extract:!0, shortcode:c.find(a.datastorage + ":eq(0)").val()};
- new d.AviaModal(b);
- return!1
- });
- b.on("click", ".avia-attach-modal-element-delete", function(c) {
- a.shortcodes.deleteModalSubItem(this, c)
- });
- b.on("click", ".avia-attach-modal-element-add", function(c) {
- a.shortcodes.appendModalSubItem(this, c)
- });
- this.canvas.on("click", "a.avia-clone", function() {
- a.cloneElement(this, a);
- return!1
- });
- this.canvas.on("change", "select.avia-recalc-shortcode", function() {
- var c = d(this).parents(".avia_sortable_element:eq(0)");
- a.recalc_shortcode(c);
- return!1
- });
- this.canvas.on("avia-history-update", function() {
- a.activate_element_dragging(this.canvasParent, "");
- a.activate_element_dropping(this.canvasParent, "")
- })
- }, activate_element_dragging:function(a, b) {
- var c = this, e = a || this.canvasParent, f = {appendTo:"body", handle:">.avia_sorthandle", helper:"clone", scroll:!0, zIndex:1E3, cursorAt:{left:20}, start:function(a) {
- a = d(a.target);
- a.css({opacity:0.4});
- d(".avia-hover-active").removeClass("avia-hover-active");
- c.canvas.addClass("avia-select-target-" + a.data("dragdrop-level"))
- }, stop:function(a) {
- d(a.target).css({opacity:1});
- d(".avia-hover-active").removeClass("avia-hover-active");
- c.canvas.removeClass("avia-select-target-1 avia-select-target-2 avia-select-target-3 avia-select-target-4")
- }};
- "undefined" == typeof b && (b = ":not(.ui-draggable)");
- e.find(".av_drag" + b).draggable(f);
- f.cursorAt = {left:33, top:33};
- f.handle = !1;
- e.find(".shortcode_insert_button").not(".ui-draggable").draggable(f)
- }, activate_element_dropping:function(a, b) {
- var c = this, e = a || this.canvasParent;
- "undefined" == typeof b && (b = ":not(.ui-droppable)");
- "destroy" == b && (e.find(".av_drop").droppable("destroy"), b = "");
- e.find(".av_drop" + b).droppable({tolerance:"pointer", greedy:!0, over:function(a, b) {
- var e = d(this);
- c.droping_allowed(b.helper, e) && e.addClass("avia-hover-active")
- }, out:function() {
- d(this).removeClass("avia-hover-active")
- }, drop:function(a, b) {
- var e = d(this);
- if(!e.is(".avia-hover-active")) {
- return!1
- }
- for(var j = e.find(">.av_drag"), k = {}, m = "after", l = !1, n = [], p, q, r = 0;r < j.length;r++) {
- var s = j.eq(r), k = s.offset();
- if(k.top < b.offset.top) {
- l = s, p = k, n["top_" + k.top] || (q = 0, n["top_" + k.top] = []), q = q > s.outerHeight() + k.top ? q : s.outerHeight() + k.top, n["top_" + k.top].push({left:k.left, top:k.top, index:r, height:s.outerHeight(), maxheight:s.outerHeight() + k.top})
- }else {
- break
- }
- }
- if(p && 1 < n["top_" + p.top].length && q - 40 > b.offset.top) {
- l = !1;
- for(r = 0;r < n["top_" + p.top].length;r++) {
- if(n["top_" + p.top][r].left < b.offset.left) {
- l = n["top_" + p.top][r].index
- }else {
- break
- }
- }
- !1 === l && (l = n["top_" + p.top][0].index, m = "before");
- l = j.eq(l)
- }
- !1 === l && (l = e, m = "prepend");
- if(l[0] != b.draggable[0]) {
- if(b.draggable[0].hash) {
- var t = b.draggable.get(0).hash.replace("#", ""), t = d(d("#avia-tmpl-" + t).html());
- b.draggable = t
- }
- e = b.draggable.parents(".av_drag:last");
- l[m](b.draggable);
- e.length && c.updateInnerTextarea(!1, e);
- if(0 !== ("after" == m ? l.parents(".av_drop") : l).data("dragdrop-level")) {
- c.updateTextarea(), c.updateInnerTextarea(b.draggable)
- }
- c.updateTextarea();
- c.targetInsertInactive();
- "undefined" != typeof t && (c.canvas.removeClass("ui-droppable").droppable("destroy"), c.activate_element_dragging(), c.activate_element_dropping());
- c.do_history_snapshot()
- }
- }})
- }, droping_allowed:function(a, b) {
- return a.data("dragdrop-level") > b.data("dragdrop-level") ? !0 : !1
- }, switch_layout_mode:function() {
- var a = this, b = this.tiny_active ? window.tinyMCE.get("content") : !1;
- "active" != this.activeStatus.val() ? (d("#content-html").trigger("click"), a.classic_editor_wrap.addClass("avia-hidden-editor"), a.switch_button.addClass("avia-builder-active").text(a.switch_button.data("active-button")), a.activeStatus.val("active"), a.canvasParent.removeClass("avia-hidden"), setTimeout(function() {
- d("#content-tmce").trigger("click");
- a.convertTextToInterface()
- }, 10)) : (this.classic_editor_wrap.removeClass("avia-hidden-editor"), this.switch_button.removeClass("avia-builder-active").text(this.switch_button.data("inactive-button")), this.activeStatus.val(""), this.canvasParent.addClass("avia-hidden"), this.canvas.addClass("preloading").find(">*:not(.avia-controll-bar, .avia-insert-area)").remove(), this.safemode && ("safe" == this.safemode && -1 !== this.secureContent.val().indexOf("[")) && (avia_log("Switching to Classic Editor. Template Builder is in safe mode and will empty the textarea so user cant edit shortcode directly"),
- b && b.setContent("", {format:"html"}), this.classic_textarea.val("")));
- return!1
- }, sendToAdvancedEditor:function(a) {
- a = d(a);
- this.canvas.append(a);
- this.activate_element_dragging();
- this.activate_element_dropping()
- }, updateInnerTextarea:function(a, b) {
- "undefined" == typeof b && (b = d(a).parents(".avia_layout_section:eq(0)"));
- b.length || (b = d(a).parents(".avia_layout_column:eq(0)"));
- if(b.length) {
- if(b.is(".avia_layout_section")) {
- for(var c = b.find(".avia_layout_column"), e = 0;e < c.length;e++) {
- this.updateInnerTextarea(!1, d(c[e]))
- }
- for(var c = b.find(">.avia_inner_shortcode >" + this.datastorage), f = b.find(">.avia_inner_shortcode > div " + this.datastorage + ":not(.avia_layout_column .avia_sortable_element " + this.datastorage + ")"), h = "", g = b.data("shortcodehandler"), j = c.val().match(RegExp("\\[" + g + ".*?\\]")), e = 0;e < f.length;e++) {
- h += d(f[e]).val()
- }
- h = j[0] + "\n\n" + h + "[/" + g + "]";
- c.val(h)
- }
- if(b.is(".avia_layout_column")) {
- c = b.find(">.avia_inner_shortcode >" + this.datastorage);
- f = b.find(".avia_sortable_element " + this.datastorage);
- h = "";
- g = b.data("width");
- j = b.is(".avia-first-col") ? " first" : "";
- for(e = 0;e < f.length;e++) {
- h += d(f[e]).val()
- }
- c.val("[" + g + j + "]\n\n" + h + "[/" + g + "]")
- }
- }
- }, updateTextarea:function(a) {
- if(!a) {
- var b = this;
- d(".avia_layout_builder").find(".avia_layout_section").each(function() {
- b.updateTextarea(d(this).find(">.avia_inner_shortcode > div > .avia_inner_shortcode"))
- });
- a = d(".avia_layout_builder > div > .avia_inner_shortcode")
- }
- a = a.find(">" + this.datastorage);
- for(var c = "", e = 0, f, h, g, j, k = {av_one_full:1, av_three_fourth:0.75, av_two_third:0.66, av_one_half:0.5, av_one_third:0.33, av_one_fourth:0.25, av_one_fifth:0.2}, m = 0;m < a.length;m++) {
- f = d(a[m]), g = f.parents(".avia_layout_column:eq(0)"), h = f.val(), g.length ? (j = g.data("width"), e += k[j], 1 < e || 0 == m ? (g.is(".avia-first-col") || (g.addClass("avia-first-col"), h = h.replace(RegExp("^\\[" + j), "[" + j + " first"), f.val(h)), e = k[j]) : g.is(".avia-first-col") && (g.removeClass("avia-first-col"), h = h.replace(" first", ""), f.val(h))) : e = 1, c += h
- }
- var l = this.tiny_active ? window.tinyMCE.get("content") : void 0;
- "undefined" != typeof l && (clearTimeout(this.update_timout), this.update_timout = setTimeout(function() {
- l.setContent(window.switchEditors.wpautop(c), {format:"html"})
- }, 500));
- this.classic_textarea.val(c);
- this.secureContent.val(c)
- }, do_history_snapshot:function(a) {
- var b = this;
- a || (a = 150);
- setTimeout(function() {
- b.canvas.trigger("avia-storage-update")
- }, a)
- }, convertTextToInterface:function(a) {
- if("active" == this.activeStatus.val()) {
- var b = this;
- "undefined" == typeof a && (a = this.secureContent.val(), -1 === a.indexOf("[") && (a = this.classic_textarea.val(), this.secureContent.val(a)));
- this.tiny_active && (a = window.switchEditors._wp_Nop(a));
- d.ajax({type:"POST", url:ajaxurl, data:{action:"avia_ajax_text_to_interface", text:a}, success:function(a) {
- b.sendToAdvancedEditor(a);
- b.canvas.removeClass("preloading");
- b.do_history_snapshot()
- }});
- var c = jQuery;
- c.AviaElementBehavior = c.AviaElementBehavior || {};
- c(document).ready(function() {
- c.AviaElementBehavior.image_radio();
- c.AviaElementBehavior.tabs(".avia-tab-container");
- c.AviaElementBehavior.icon_select();
- c.AviaElementBehavior.expand_metabox();
- c.AviaElementBehavior.check_dependencies();
- c.AviaElementBehavior.set_target_property();
- c.AviaElementBehavior.tmpl_fetcher();
- c.AviaElementBehavior.redo_undo();
- c.AviaElementBehavior.wp_media_advanced();
- new c.AviaElementBehavior.wp_save_template;
- new c.AviaTooltip({attach:"body"});
- new c.AviaTooltip({"class":"avia-help-tooltip", data:"avia-help-tooltip", event:"click", position:"bottom", attach:"body"})
- });
- c.AviaElementBehavior.tabs = function(a, b) {
- c(a).each(function(a) {
- var d = 0, e = "avia_post_" + a + "_" + avia_globals.post_id, k = !1;
- "undefined" !== typeof Storage && (k = !0, d = sessionStorage[e] || 0);
- a = c(this);
- var m = a.find(".avia-tab-title-container a"), l = a.find(".avia-tab"), n;
- m.unbind("click").bind("click", function() {
- m.removeClass("active-tab");
- n = c(this).addClass("active-tab");
- var a = m.index(n);
- l.css({display:"none"}).filter(":eq(" + a + ")").css({display:"block"});
- k && (sessionStorage[e] = a);
- "undefined" != typeof b && b.find(".avia-tab-title-container a").eq(a).trigger("click");
- return!1
- });
- m.filter(".active-tab").length || m.filter(":eq(" + d + ")").addClass("active-tab").trigger("click")
- })
- };
- c.AviaElementBehavior.image_radio = function() {
- c('.avia_scope input[type="radio"]:checked').parents(".avia_radio_wrap:eq(0)").addClass("avia_checked");
- c("body").on("click", ".avia_scope input[type='radio']", function() {
- c(this).parents(".avia_radio_wrap:eq(0)").siblings(".avia_radio_wrap").removeClass("avia_checked").end().addClass("avia_checked")
- })
- };
- c.AviaElementBehavior.icon_select = function() {
- c("body").on("click", ".avia-attach-element-select", function() {
- var a = c(this), b = a.parents(".avia-attach-element-container:eq(0)");
- b.find(".avia-active-element").removeClass("avia-active-element");
- var d = b.find("input[type=hidden]:eq(0)"), b = b.find("input[type=hidden]:eq(1)");
- a.addClass("avia-active-element");
- d.val(a.data("element-nr"));
- b.length && b.val(a.html());
- return!1
- })
- };
- c.AviaElementBehavior.expand_metabox = function() {
- function a() {
- l.addClass("avia-expanded");
- b.addClass("avia-noscroll-box");
- p = l.find(".avia-tab-container").clone(!0);
- p.length && (q = c('<div class="avia-expanded-buttons"></div>').appendTo(p), j.clone(!0).appendTo(q).bind("click", function() {
- setTimeout(function() {
- window.open("", "wp-preview", "").focus()
- }, 10)
- }), g.clone(!0).appendTo(q), m.clone(!0).addClass("wp-core-ui button").appendTo(q), c('<input type="hidden" name="avia-expanded-hidden" value="' + l.attr("id") + '" />').appendTo(q), n = c('<div class="avia-fixed-controls"></div>').appendTo(l), p.appendTo(n), c.AviaElementBehavior.tabs(p, c(".avia-tab-container:not(.avia-fixed-controls .avia-tab-container):first")))
- }
- var b = c("body"), d = c(".avia-expanded").find(".avia-attach-expand"), g = c("input#publish"), j = c("a#post-preview"), k = c('<div class="avia-expand-whitescreen"></div>').appendTo(b), m, l, n, p, q;
- d.length && (m = d, l = m.parents(".postbox:eq(0)"), a());
- b.on("click", ".avia-attach-expand", function() {
- m = c(this);
- l = m.parents(".postbox:eq(0)");
- l.is(".avia-expanded") ? k.css({display:"block", opacity:0}).animate({opacity:1}, function() {
- l.removeClass("avia-expanded");
- b.removeClass("avia-noscroll-box");
- n.length && n.remove();
- k.animate({opacity:0}, function() {
- k.css({display:"none"})
- })
- }) : k.css({display:"block", opacity:0}).animate({opacity:1}, function() {
- a();
- k.animate({opacity:0}, function() {
- k.css({display:"none"})
- })
- });
- return!1
- })
- };
- c.AviaElementBehavior.check_dependencies = function() {
- var a = c("body");
- a.on("change", ".avia-style select, .avia-style radio, .avia-style input[type=checkbox], .avia-style input[type=hidden]", function() {
- var b = c(this), d = b.parents(".avia-modal:eq(0)");
- d.length || (d = a);
- var g = this.id.replace(/aviaTB/g, ""), d = d.find('.avia-form-element-container[data-check-element="' + g + '"]'), j = this.value, k = b.parents(".avia-form-element-container:eq(0)").is(".avia-hidden");
- d.length && d.each(function() {
- var a = c(this), b = a.data(), d = b.checkValue, e = !1;
- if(!k) {
- switch(b.checkComparison) {
- case "equals":
- j == d && (e = !0);
- break;
- case "not":
- j != d && (e = !0);
- break;
- case "is_larger":
- j > d && (e = !0);
- break;
- case "is_smaller":
- j < d && (e = !0);
- break;
- case "contains":
- -1 != j.indexOf(d) && (e = !0);
- break;
- case "doesnt_contain":
- -1 == j.indexOf(d) && (e = !0);
- break;
- case "is_empty_or":
- if("" == j || j == d) {
- e = !0
- }
- break;
- case "not_empty_and":
- "" != j && j != d && (e = !0)
- }
- }
- !0 == e && a.is(".avia-hidden") ? (a.css({display:"none"}).removeClass("avia-hidden").find("select, radio, input[type=checkbox]").trigger("change"), a.slideDown(300)) : !1 == e && !a.is(".avia-hidden") && (a.css({display:"block"}).addClass("avia-hidden").find("select, radio, input[type=checkbox]").trigger("change"), a.slideUp(300))
- })
- })
- };
- c.AviaElementBehavior.set_target_property = function() {
- var a = c("body");
- a.on("change", ".avia-style select, .avia-style radio, .avia-style input[type=checkbox]", function() {
- var b = c(this), d = b.parents(".avia-form-element-container:eq(0)"), g = b.parents(".avia-modal:eq(0)"), j = d.data(), k = "";
- if(j.targetElement) {
- g.length || (g = a);
- b.is("select") && (k = b.find("option").map(function() {
- return this.value
- }).get().join(" "));
- var b = a.find(j.targetElement), m = this.value;
- b.length && b.each(function() {
- var a = c(this);
- switch(j.targetProperty) {
- case "class":
- a.removeClass(k).addClass(m);
- break;
- case "id":
- a.attr({id:m})
- }
- })
- }
- });
- a.on("avia_modal_finished", function(a, b) {
- b.modal.find(".avia-attach-targeting select,.avia-attach-targeting radio,.avia-attach-targeting input[type=checkbox]").trigger("change")
- })
- };
- c.AviaElementBehavior.tmpl_fetcher = function() {
- var a = c("body");
- a.on("change", ".avia-attach-templating select, .avia-attach-templating radio, .avia-attach-templating input[type=checkbox]", function() {
- var a = c(this);
- a.parents(".avia-form-element-container:eq(0)");
- a.parents(".avia-modal:eq(0)");
- a = a.next(".template-container");
- if(a.length) {
- var b = this.value, d = c("#avia-tmpl-" + b);
- d.length || (avia_globals.builderMode && "debug" == avia_globals.builderMode && (avia_log('template snippet "#avia-tmpl-' + b + '" not defined', "error"), avia_log("Make sure that the you have created the template and check the source code if its really available", "help")), d = c("<div />"));
- a.html(d.html())
- }
- });
- a.on("avia_modal_finished", function(a, b) {
- b.modal.find(".avia-attach-templating select,.avia-attach-templating radio,.avia-attach-templating input[type=checkbox]").trigger("change")
- })
- };
- c.AviaElementBehavior.redo_undo = function() {
- new c.AviaElementBehavior.history({monitor:"#aviaLayoutBuilder", editor:"#_aviaLayoutBuilderCleanData", buttons:".layout-builder-wrap .avia-controll-bar"})
- }
- }
- }, targetInsertActive:function(a, b) {
- b || (b = "avia-hover-target avia-select-target-" + d(a).data("dragdrop-level"));
- d(".avia-hover").removeClass("avia-hover");
- this.canvas.addClass(b);
- this.targetInsert = a
- }, targetInsertInactive:function() {
- d(".shortcode_button_wrap").find(".avia-active-insert").removeClass("avia-active-insert");
- this.canvas.removeClass("avia-hover-target avia-select-target-1 avia-select-target-2 avia-select-target-3 avia-select-target-4");
- this.targetInsert = "";
- this.only_one_insert = !1
- }, doTargetInsert:function(a, b, c) {
- var e = d(a), f = "object" == typeof b.targetInsert ? b.targetInsert : d(b.targetInsert);
- b.droping_allowed(f, e) && ("undefined" == typeof c && (c = "append"), "append" == c && e.append(b.targetInsert), "prepend" == c && e.prepend(b.targetInsert), a.length || b.updateInnerTextarea(a), a = e.parents(".avia_layout_section:eq(0)"), a.length && (b.updateTextarea(), b.updateInnerTextarea(!1, a)), !1 != this.only_one_insert && (b.updateInnerTextarea(!1, this.only_one_insert), b.targetInsertInactive()), b.activate_element_dragging(), b.activate_element_dropping(), b.updateTextarea(), b.do_history_snapshot())
- }, changeTargetingShortcode:function(a) {
- var b = 37 == a ? -1 : 1;
- a = d(".shortcode_button_wrap:last");
- var c = a.find(".avia-target-insert"), e = c.filter(".avia-active-insert"), e = c.index(e), e = c.filter(":eq(" + (e + b) + ")");
- e.length || (e = 1 == b ? c.filter(":first") : c.filter(":last"));
- e.trigger("click");
- e.is(":visible") || (b = a.find(".avia-tab"), c = e.parent(), b = b.index(c), a.find(".avia-tab-title-container a:eq(" + b + ")").trigger("click"));
- return!1
- }, cloneElement:function(a, b) {
- var c = d(a), e = c.parents(".avia_sortable_element:eq(0)");
- e.length || (e = c.parents(".avia_layout_column:eq(0)"));
- e.length || (e = c.parents(".avia_layout_section:eq(0)"));
- e.find("textarea").each(function() {
- this.innerHTML = this.value
- });
- c = e.clone();
- c.removeClass("ui-draggable ui-droppable").find(".ui-draggable, .ui-droppable").removeClass("ui-draggable ui-droppable");
- c.insertAfter(e);
- c = e.parents(".avia_layout_section, .avia_layout_column");
- if(e.is(".avia_layout_column") || e.is(".avia_layout_section") || c.length) {
- c.length && b.updateTextarea(), b.updateInnerTextarea(e)
- }
- b.activate_element_dragging();
- b.activate_element_dropping();
- b.updateTextarea();
- b.do_history_snapshot()
- }, recalc_shortcode:function(a) {
- for(var b = a.find("select.avia-recalc-shortcode"), c = !1, e = [], f = 0;f < b.length;f++) {
- c = d(b[f]), e[c.data("attr")] = c.val()
- }
- this.send_to_datastorage(e, a)
- }, send_to_datastorage:function(a, b) {
- var c = b.is(".avia-modal-group-element") ? this.datastorage + ":eq(0)" : ">.avia_inner_shortcode>" + this.datastorage + ":eq(0)", c = b.find(c), d = b.parents(".avia_layout_column:eq(0)"), f = b.parents(".avia_layout_section:eq(0)"), h = b.data("shortcodehandler"), g = "", j = {};
- "string" == typeof a ? g = a : (j = this.update_builder_html(b, a), g = j.output, j = j.tags);
- b.is(".avia_layout_section") ? c.val(c.val().replace(RegExp("^\\[" + h + ".*?\\]"), j.open)) : c.val(g);
- f.length ? this.updateInnerTextarea(!1, f) : d.length && this.updateInnerTextarea(!1, d);
- this.updateTextarea();
- this.do_history_snapshot();
- b.trigger("update")
- }, update_builder_html:function(a, b) {
- var c, e, f;
- for(c in b) {
- b.hasOwnProperty(c) && (f = c.replace(/aviaTB/g, ""), f != c && (b[f] = b[c], delete b[c]))
- }
- for(c in b) {
- if(b.hasOwnProperty(c) && "content" != c) {
- if("string" == typeof b[c]) {
- b[c] = b[c].replace(/'(.+?)'/g, "\u2018$1\u2019").replace(/'/g, "\u2019")
- }else {
- if("object" == typeof b[c]) {
- for(e in b[c]) {
- b[c][e] = b[c][e].replace(/'(.+?)'/g, "\u2018$1\u2019").replace(/'/g, "\u2019")
- }
- }
- }
- }
- }
- e = a.data("shortcodehandler");
- f = a.find("[data-update_with]");
- var h = a.find("[data-update_class_with]").attr("class", ""), g = "", j = "", k = "", m = "", l = "";
- a.is(".avia-no-visual-updates") || (f.each(function() {
- j = d(this);
- g = j.data("update_with");
- k = j.data("update_template");
- if("string" === typeof b[g] || "number" === typeof b[g]) {
- l = b[g], "content" === g && (l = "undefined" != typeof window.switchEditors ? window.switchEditors.wpautop(b[g]) : avia_nl2br(b[g])), m = k ? k.replace("{{" + g + "}}", l) : l, j.html(m)
- }
- }), h.each(function() {
- j = d(this);
- g = j.data("update_class_with").split(",");
- for(var a = 0;a < g.length;a++) {
- "string" === typeof b[g[a]] && (j.get(0).className += " avia-" + g[a] + "-" + b[g[a]])
- }
- }));
- for(c in b) {
- b.hasOwnProperty(c) && -1 !== c.indexOf("_fakeArg") && delete b[c]
- }
- c = {};
- f = {};
- f.output = this.createShortcode(b, e, c);
- f.tags = c;
- return f
- }, createShortcode:function(a, b, c) {
- var e, f = "", h = f = "", g = ",";
- c || (c = {});
- if("undefined" != typeof a.content) {
- if("object" == typeof a.content) {
- -1 != a.content[0].indexOf("[") && (g = "\n");
- for(h = 0;h < a.content.length;h++) {
- a.content[h] = d.trim(a.content[h])
- }
- h = a.content.join(g)
- }else {
- h = a.content
- }
- h = "\n" + h + "\n";
- delete a.content
- }
- for(e in a) {
- a.hasOwnProperty(e) && ("object" === typeof a[e] && (a[e] = a[e].join(",")), f += e + "='" + a[e] + "' ")
- }
- c.open = "[" + b + " " + d.trim(f) + "]";
- f = c.open;
- h && ("" == d.trim(h) && (h = ""), c.close = "[/" + b + "]", f += h + c.close);
- return f + "\n\n"
- }};
- d(document).ready(function() {
- d.avia_builder = new d.AviaBuilder
- })
- })(jQuery);
- (function(d) {
- d.AviaBuilder.shortcodes = d.AviaBuilder.shortcodes || {};
- d.AviaBuilder.shortcodes.fetchShortcodeEditorElement = function(a, b, c) {
- a = d("#avia-tmpl-" + a);
- a.length && ("instant_insert" == b ? (c.sendToAdvancedEditor(a.html()), c.updateTextarea(), c.do_history_snapshot(0)) : c.targetInsertActive(a.html()))
- };
- d.AviaBuilder.shortcodes.deleteItem = function(a, b) {
- var c = d(a), e = c.parents(".avia_sortable_element:eq(0)"), f = !1;
- e.length ? f = c.parents(".avia_inner_shortcode:eq(0)") : (e = c.parents(".avia_layout_column:eq(0)"), f = c.parents(".avia_layout_section:eq(0)>.avia_inner_shortcode"), e.length || (e = c.parents(".avia_layout_section:eq(0)"), f = !1));
- b.targetInsertInactive();
- e.hide(200, function() {
- e.remove();
- f && f.length && b.updateInnerTextarea(f);
- b.updateTextarea();
- "" == b.secureContent.val() && b.activate_element_dropping(b.canvasParent, "destroy");
- b.do_history_snapshot()
- })
- };
- d.AviaBuilder.shortcodes.deleteModalSubItem = function(a, b) {
- b.stopImmediatePropagation();
- var c = d(a).parents(".avia-modal-group-element:eq(0)");
- c.slideUp(200, function() {
- c.remove()
- })
- };
- d.AviaBuilder.shortcodes.appendModalSubItem = function(a, b) {
- b.preventDefault();
- var c = d(a).parents(".avia-modal-group-wrapper:eq(0)"), e = c.find(".avia-modal-group"), c = c.find(".avia-tmpl-modal-element");
- d(c.html()).appendTo(e).css({display:"none"}).slideDown(200)
- };
- d.AviaBuilder.shortcodes.changeSize = function(a, b) {
- for(var c = d(a), e = c.parents(".avia_layout_column:eq(0)"), f = e.parents(".avia_layout_section:eq(0)"), h = e.data("width"), g = [], c = c.is(".avia-bigger") ? 1 : -1, j = e.find(".avia-col-size"), k = e.find("> .avia_inner_shortcode > " + b.datastorage), m = k.val(), l = [["av_one_full", "1/1"], ["av_three_fourth", "3/4"], ["av_two_third", "2/3"], ["av_one_half", "1/2"], ["av_one_third", "1/3"], ["av_one_fourth", "1/4"], ["av_one_fifth", "1/5"]], n = 0;n < l.length;n++) {
- l[n][0] == h && (g = l[n - c])
- }
- "undefined" != typeof g && (m = m.replace(RegExp("^\\[" + h, "g"), "[" + g[0]), m = m.replace(RegExp(h + "\\]", "g"), g[0] + "]"), k.val(m), e.removeClass(h).addClass(g[0]), e.attr("data-width", g[0]).data("width", g[0]), j.text(g[1]), b.updateTextarea(), f.length && (b.updateInnerTextarea(!1, f), b.updateTextarea()), b.do_history_snapshot(0))
- }
- })(jQuery);
- (function(d) {
- d.AviaElementBehavior = d.AviaElementBehavior || {};
- d.AviaElementBehavior.wp_media = d.AviaElementBehavior.wp_media || [];
- d.AviaModal = function(a) {
- var b = {scope:this, modal_title:"", modal_class:"", modal_content:!1, modal_ajax_hook:"", on_save:function() {
- }, on_load:function() {
- }, before_save:"", save_param:{}, ajax_param:"", button:"save"};
- d.AviaModal.openInstance.unshift(this);
- this.instanceNr = d.AviaModal.openInstance.length;
- this.options = d.extend({}, b, a);
- this.namespace = ".AviaModal" + this.instanceNr;
- this.body = d("body").addClass("avia-noscroll");
- this.doc = d(document);
- this.modal = d('<div class="avia-modal avia-style"></div>');
- this.backdrop = d('<div class="avia-modal-backdrop"></div>');
- this.set_up()
- };
- d.AviaModal.openInstance = [];
- d.AviaModal.prototype = {set_up:function() {
- this.create_html();
- this.add_behavior();
- this.modify_binding_order();
- this.propagate_modal_open()
- }, add_behavior:function() {
- var a = this;
- this.modal.on("click", ".avia-modal-save", function() {
- a.execute_callback();
- return!1
- });
- this.backdrop.add(".avia-attach-close-event", this.modal).on("click", function() {
- a.close();
- return!1
- });
- this.doc.bind("keydown" + this.namespace, function(b) {
- a.media_overlay_closed() && (13 == b.keyCode && !(b.target.tagName && "textarea" == b.target.tagName.toLowerCase()) && (setTimeout(function() {
- a.execute_callback()
- }, 100), b.stopImmediatePropagation()), 27 == b.keyCode && (setTimeout(function() {
- a.close()
- }, 100), b.stopImmediatePropagation()))
- })
- }, modify_binding_order:function() {
- var a = jQuery.hasData(document) && jQuery._data(document), b = a.events.keydown.pop();
- a.events.keydown.unshift(b)
- }, create_html:function() {
- var a = this.options.modal_content ? this.options.modal_content : "", b = this.options.modal_content ? "" : " preloading ", c;
- c = '<div class="avia-modal-inner">' + ('<div class="avia-modal-inner-header">' + ('<h3 class="avia-modal-title">' + this.options.modal_title + "</h3>") + '<a href="#close" class="avia-modal-close avia-attach-close-event">X</a></div>');
- c = c + ('<div class="avia-modal-inner-content ' + b + '">' + a + "</div>") + '<div class="avia-modal-inner-footer">';
- c = "save" == this.options.button ? c + ('<a href="#save" class="avia-modal-save button button-primary button-large">' + avia_modal_L10n.save + "</a>") : "close" == this.options.button ? c + ('<a href="#close" class="avia-attach-close-event button button-primary button-large">' + avia_modal_L10n.close + "</a>") : c + this.options.button;
- c += "</div></div>";
- this.options.modal_class && this.modal.addClass(this.options.modal_class);
- this.body.append(this.modal).append(this.backdrop);
- this.modal.html(c);
- a = this.instanceNr - 1;
- b = parseInt(this.modal.css("zIndex"), 10);
- this.modal.css({margin:30 * a, zIndex:b + a + 1});
- this.backdrop.css({zIndex:b + a});
- if(this.options.modal_content) {
- this.on_load_callback()
- }else {
- this.fetch_ajax_content()
- }
- }, set_focus:function() {
- this.modal.find("select, input[type=text], input[type=checkbox], textarea, radio").filter(":eq(0)").focus()
- }, fetch_ajax_content:function() {
- var a = this, b = a.modal.find(".avia-modal-inner-content");
- d.ajax({type:"POST", url:ajaxurl, data:{action:"avia_ajax_" + this.options.modal_ajax_hook, params:this.options.ajax_param, ajax_fetch:!0, instance:this.instanceNr}, error:function() {
- d.AviaModal.openInstance[0].close();
- new d.AviaModalNotification({mode:"error", msg:avia_modal_L10n.ajax_error})
- }, success:function(c) {
- 0 == c ? (d.AviaModal.openInstance[0].close(), new d.AviaModalNotification({mode:"error", msg:avia_modal_L10n.login_error})) : "-1" == c ? (d.AviaModal.openInstance[0].close(), new d.AviaModalNotification({mode:"error", msg:avia_modal_L10n.timeout})) : (b.html(c), a.on_load_callback())
- }, complete:function() {
- b.removeClass("preloading")
- }})
- }, on_load_callback:function() {
- var a = this.options.on_load, b = 0;
- if("string" == typeof a) {
- for(b in a = a.split(", "), a) {
- "undefined" != typeof d.AviaModal.register_callback[a[b]] ? d.AviaModal.register_callback[a[b]].call(this) : (avia_log('modal_on_load function "$.AviaModal.register_callback.' + a[b] + '" not defined', "error"), avia_log("Make sure that the modal_on_load function defined in your Shortcodes config array exists", "help"))
- }
- }else {
- "function" == typeof a && a.call()
- }
- this.set_focus();
- this.propagate_modal_content()
- }, close:function() {
- d.AviaModal.openInstance.shift();
- this.modal.remove();
- this.backdrop.remove();
- this.doc.trigger("avia_modal_close").unbind("keydown" + this.namespace);
- 0 == d.AviaModal.openInstance.length && this.body.removeClass("avia-noscroll")
- }, convert_values:function(a) {
- var b = {};
- d.each(a, function() {
- "undefined" !== typeof b[this.name] ? (b[this.name].push || (b[this.name] = [b[this.name]]), b[this.name].push(this.value || "")) : b[this.name] = this.value || ""
- });
- return b
- }, execute_callback:function() {
- var a = this.modal.find("input, select, radio, textarea").serializeArray(), a = this.convert_values(a);
- "undefined" != typeof d.AviaModal.register_callback[this.options.before_save] && (a = d.AviaModal.register_callback[this.options.before_save].call(this.options.scope, a, this.options.save_param));
- !1 !== this.options.on_save.call(this.options.scope, a, this.options.save_param) && this.close()
- }, media_overlay_closed:function() {
- return d.AviaElementBehavior.wp_media.length ? !1 : !0
- }, propagate_modal_open:function() {
- this.body.trigger("avia_modal_open", this)
- }, propagate_modal_content:function() {
- this.body.trigger("avia_modal_finished", this)
- }};
- d.AviaModalNotification = function(a) {
- this.options = d.extend({}, {modal_content:"<div class='avia-form-element-container'>" + a.msg + "</div>", modal_class:"flexscreen", modal_title:"<span class='avia-msg-" + a.mode + "'>" + avia_modal_L10n[a.mode] + "</span>", button:"close"}, a);
- return new d.AviaModal(this.options)
- };
- d.AviaModal.register_callback = d.AviaModal.register_callback || {};
- d.AviaModal.register_callback.modal_start_sorting = function(a) {
- a = (a || this.modal).find(".avia-modal-group");
- a.find(".avia-modal-group-element, .avia-insert-area").disableSelection();
- a.sortable({handle:".avia-attach-modal-element-move", items:".avia-modal-group-element", placeholder:"avia-modal-group-element-highlight", tolerance:"pointer", forcePlaceholderSize:!0, start:function(a, c) {
- d(".avia-modal-group-element-highlight").height(c.item.outerHeight()).width(c.item.outerWidth())
- }, update:function() {
- }, stop:function() {
- }})
- };
- d.AviaModal.register_callback.modal_load_colorpicker = function() {
- var a = this.modal;
- a.find(".colorpicker").wpColorPicker();
- a.find(".wp-color-result").click(function(b) {
- "undefined" != typeof b.originalEvent && a.find(".wp-picker-open").not(this).trigger("click")
- })
- };
- d.AviaModal.register_callback.modal_load_tiny_mce = function(a) {
- a = a || this.modal.find(".avia-modal-inner-content .avia_tinymce");
- var b = a.parents(".avia-modal:eq(0)").find(".avia-modal-save");
- a.each(function() {
- var a = this.id, e = d(this).parents(".wp-editor-wrap:eq(0)"), f = e.find("textarea.avia_tinymce"), h = e.find(".wp-switch-editor").removeAttr("onclick");
- quicktags({id:this.id, buttons:"strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close"});
- QTags._buttonsInit();
- h.bind("click", function() {
- d(this).is(".switch-tmce") ? (e.removeClass("html-active").addClass("tmce-active"), window.tinyMCE.execCommand("mceAddControl", !0, a), window.tinyMCE.get(a).setContent(window.switchEditors.wpautop(f.val()), {format:"raw"})) : (e.removeClass("tmce-active").addClass("html-active"), window.tinyMCE.execCommand("mceRemoveControl", !0, a))
- }).trigger("click");
- b.bind("click", function() {
- h.filter(".switch-html").trigger("click")
- })
- })
- }
- })(jQuery);
- (function(d) {
- d.AviaElementBehavior = d.AviaElementBehavior || {};
- d.AviaElementBehavior.history = function(a) {
- if("undefined" === typeof Storage) {
- return!1
- }
- this.options = d.extend({}, {steps:40, monitor:"", editor:"", buttons:"", event:"avia-storage-update"}, a);
- this.setUp()
- };
- d.AviaElementBehavior.history.prototype = {setUp:function() {
- this.canvas = d(this.options.monitor);
- this.wrapper = this.canvas.parent();
- this.buttons = d(this.options.buttons);
- this.editor = d(this.options.editor);
- this.key = this.create_array_key();
- this.storage = this.get() || [];
- this.max = this.storage.length - 1;
- this.index = this.get(this.key + "index");
- if("undefined" == typeof this.index || null == this.index) {
- this.index = this.storage.length - 1
- }
- this.undoBtn = d('<a href="#undo" class="avia-undo-button " title="' + avia_history_L10n.undo_label + '"><-</a>').appendTo(this.buttons);
- this.redoBtn = d('<a href="#redo" class="avia-redo-button " title="' + avia_history_L10n.redo_label + '">-></a>').appendTo(this.buttons);
- this.clear();
- this.bindEvents()
- }, create_array_key:function() {
- var a = "avia" + avia_globals.themename + avia_globals.themeversion + avia_globals.post_id + avia_globals.builderversion;
- return a = a.replace(/[^a-zA-Z0-9]/g, "").toLowerCase()
- }, bindEvents:function() {
- var a = this;
- this.canvas.on("avia-storage-update", function() {
- a.do_snapshot()
- });
- this.wrapper.on("click", ".avia-undo-button", function() {
- a.undo()
- });
- this.wrapper.on("click", ".avia-redo-button", function() {
- a.redo()
- })
- }, set:function(a, b) {
- var c = a || this.key, d = b || JSON.stringify(this.storage);
- try {
- sessionStorage.setItem(c, d)
- }catch(f) {
- avia_log("Storage Limit reached. Your Browser does not offer enough session storage to save more steps for the undo/redo history."), avia_log(f), this.clear(), this.redoBtn.addClass("avia-inactive-step"), this.undoBtn.addClass("avia-inactive-step")
- }
- }, get:function(a) {
- return JSON.parse(sessionStorage.getItem(a || this.key))
- }, clear:function() {
- sessionStorage.removeItem(this.key);
- sessionStorage.removeItem(this.key + "index");
- this.storage = [];
- this.index = null
- }, redo:function() {
- this.index + 1 <= this.max && (this.index++, this.update_canvas(this.storage[this.index]));
- return!1
- }, undo:function() {
- 0 <= this.index - 1 && (this.index--, this.update_canvas(this.storage[this.index]));
- return!1
- }, update_canvas:function(a) {
- "undefined" == typeof this.tinyMCE && (this.tinyMCE = "undefined" == typeof window.tinyMCE ? !1 : window.tinyMCE.get(this.options.editor.replace("#", "")));
- this.tinyMCE && this.tinyMCE.setContent(window.switchEditors.wpautop(a[0]), {format:"html"});
- this.editor.val(a[0]);
- this.canvas.html(a[1]);
- sessionStorage.setItem(this.key + "index", this.index);
- this.index + 1 > this.max ? this.redoBtn.addClass("avia-inactive-step") : this.redoBtn.removeClass("avia-inactive-step");
- 0 >= this.index ? this.undoBtn.addClass("avia-inactive-step") : this.undoBtn.removeClass("avia-inactive-step");
- this.canvas.trigger("avia-history-update")
- }, do_snapshot:function() {
- this.canvas.find("textarea").each(function() {
- this.innerHTML = this.value
- });
- this.storage = this.storage || this.get() || [];
- this.index = this.index || this.get(this.key + "index");
- if("undefined" == typeof this.index || null == this.index) {
- this.index = this.storage.length - 1
- }
- var a = [this.editor.val(), this.canvas.html().replace(/avia_pop_class/g, "")], b = this.storage[this.index];
- if("undefined" === typeof b || b[0] !== a[0]) {
- this.index++, this.storage = this.storage.slice(0, this.index), this.storage.push(a), this.options.steps < this.storage.length && this.storage.shift(), this.set()
- }
- this.max = this.storage.length - 1;
- 1 == this.storage.length || 0 == this.index ? this.undoBtn.addClass("avia-inactive-step") : this.undoBtn.removeClass("avia-inactive-step");
- this.storage.length - 1 == this.index ? this.redoBtn.addClass("avia-inactive-step") : this.redoBtn.removeClass("avia-inactive-step")
- }}
- })(jQuery);
- (function(d) {
- d.AviaTooltip = function(a) {
- this.options = d.extend({}, {delay:1500, delayOut:300, "class":"avia-tooltip", scope:"#avia_builder", data:"avia-tooltip", attach:"element", event:"mouseenter", position:"top"}, a);
- this.body = d("body");
- this.scope = d(this.options.scope);
- this.tooltip = d('<div class="' + this.options.className + '"><span class="avia-arrow-wrap"><span class="avia-arrow"></span></span></div>');
- this.inner = d('<div class="inner_tooltip"></div>').prependTo(this.tooltip);
- this.active = this.timer = this.open = !1;
- this.bind_events()
- };
- d.AviaTooltip.openTTs = [];
- d.AviaTooltip.prototype = {bind_events:function() {
- this.scope.on(this.options.event + " mouseleave", "[data-" + this.options.data + "]", d.proxy(this.start_countdown, this));
- if("click" != this.options.event) {
- this.scope.on("mouseleave", "[data-" + this.options.data + "]", d.proxy(this.hide_tooltip, this))
- }else {
- this.body.on("mousedown", d.proxy(this.hide_tooltip, this))
- }
- }, start_countdown:function(a) {
- clearTimeout(this.timer);
- if(a.type == this.options.event) {
- var b = "click" == this.options.event ? 0 : this.open ? 0 : this.options.delay;
- this.timer = setTimeout(d.proxy(this.display_tooltip, this, a), b)
- }else {
- "mouseleave" == a.type && (this.timer = setTimeout(d.proxy(this.stop_instant_open, this, a), this.options.delayOut))
- }
- a.preventDefault()
- }, reset_countdown:function() {
- clearTimeout(this.timer);
- this.timer = !1
- }, display_tooltip:function(a) {
- var b = d(a.currentTarget), c = b.data(this.options.data), e = b.data("avia-created-tooltip"), f = "element" == this.options.attach ? b : this.body, h = "element" == this.options.attach ? b.position() : b.offset();
- this.inner.html(c);
- e = "undefined" != typeof e ? d.AviaTooltip.openTTs[e] : this.tooltip.clone().appendTo(f);
- this.open = !0;
- this.active = e;
- e.is(":animated:visible") && "click" == a.type || (a = h.top - e.outerHeight(), c = h.left + b.outerWidth() / 2 - e.outerWidth() / 2, "bottom" == this.options.position && (a = h.top + b.outerHeight()), e.css({opacity:0, display:"block", top:a - 10, left:c}).stop().animate({top:a, opacity:1}, 200), d.AviaTooltip.openTTs.push(e), b.data("avia-created-tooltip", d.AviaTooltip.openTTs.length - 1))
- }, hide_tooltip:function(a) {
- var b = d(a.currentTarget), c;
- "click" == this.options.event ? (b = d(a.target), !b.is("." + this.options.className) && 0 == b.parents("." + this.options.className).length && this.active.length && (c = this.active, this.active = !1)) : (c = b.data("avia-created-tooltip"), c = "undefined" != typeof c ? d.AviaTooltip.openTTs[c] : !1);
- c && (a = parseInt(c.css("top"), 10) - 10, c.animate({top:a, opacity:0}, 200, function() {
- c.css({display:"none"})
- }))
- }, stop_instant_open:function() {
- this.open = !1
- }}
- })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement