Advertisement
Guest User

ik

a guest
May 22nd, 2013
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. document.documentElement.className += " js_active ";
  2. document.documentElement.className += "ontouchstart" in document.documentElement ? " avia_mobile " : " avia_desktop ";
  3. (function() {
  4.   var d = ["-webkit-", "-o-", "-moz-", "-ms-", ""], a;
  5.   for(a in d) {
  6.     d[a] + "transform" in document.documentElement.style && (document.documentElement.className += " avia_transform ")
  7.   }
  8. })();
  9. function avia_log(d, a) {
  10.   "undefined" !== typeof console && ("undefined" === typeof a && (a = "log"), a = "AVIA-" + a.toUpperCase(), console.log("[" + a + "] " + d))
  11. }
  12. function avia_nl2br(d, a) {
  13.   return(d + "").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, "$1" + (a || "undefined" === typeof a ? "<br />" : "<br>") + "$2")
  14. }
  15. (function(d) {
  16.   d.AviaBuilder = function() {
  17.     this.canvas = d("#aviaLayoutBuilder");
  18.     this.canvasParent = this.canvas.parents(".postbox:eq(0)");
  19.     this.activeStatus = this.canvasParent.find("#aviaLayoutBuilder_active");
  20.     this.shortcodes = d.AviaBuilder.shortcodes || {};
  21.     this.safemode = avia_globals.builderMode || !1;
  22.     this.tiny_active = "undefined" == typeof window.tinyMCE ? !1 : !0;
  23.     this.classic_editor = d("#postdivrich");
  24.     this.classic_editor_wrap = d("#postdivrich_wrap");
  25.     this.switch_button = this.classic_editor_wrap.find(".avia-builder-button");
  26.     this.classic_textarea = d("#content.wp-editor-area");
  27.     this.secureContent = d("#_aviaLayoutBuilderCleanData");
  28.     this.datastorage = 'textarea[data-name="text-shortcode"]';
  29.     this.shortcode_wrap = d(".shortcode_button_wrap");
  30.     this.update_timout = this.only_one_insert = this.targetInsert = !1;
  31.     this.set_up()
  32.   };
  33.   d.AviaBuilder.prototype = {set_up:function() {
  34.     this.place_top();
  35.     this.convertTextToInterface();
  36.     this.add_behavior()
  37.   }, place_top:function() {
  38.     var a = d("#normal-sortables");
  39.     0 !== a.find(".postbox").index(this.canvasParent) && (this.canvasParent.prependTo(a), window.postboxes.save_order(pagenow))
  40.   }, add_behavior:function() {
  41.     var a = this, b = d("body");
  42.     this.switch_button.on("click", function(c) {
  43.       c.preventDefault();
  44.       a.switch_layout_mode()
  45.     });
  46.     this.shortcode_wrap.on("click", ".shortcode_insert_button", function() {
  47.       d(this).parents(".shortcode_button_wrap");
  48.       var c = this.hash.replace("#", "");
  49.       this.className.indexOf("avia-active-insert");
  50.       a.shortcodes.fetchShortcodeEditorElement(c, "instant_insert", a);
  51.       return!1
  52.     });
  53.     this.canvas.on("click", "a.avia-delete", function() {
  54.       a.shortcodes.deleteItem(this, a);
  55.       return!1
  56.     });
  57.     this.canvas.on("click", "a.avia-change-col-size", function() {
  58.       a.shortcodes.changeSize(this, a);
  59.       return!1
  60.     });
  61.     b.on("click", ".avia-edit-element", function() {
  62.       var c = d(this).parents(".avia_sortable_element:eq(0)");
  63.       c.length || (c = d(this).parents(".avia_layout_section:eq(0)"));
  64.       var b = c.data();
  65.       b.scope = a;
  66.       b.on_load = c.data("modal_on_load");
  67.       b.before_save = c.data("before_save");
  68.       b.on_save = a.send_to_datastorage;
  69.       b.save_param = c;
  70.       b.ajax_param = {extract:!0, shortcode:c.find(">.avia_inner_shortcode>" + a.datastorage + ":eq(0)").val(), allowed:b.allowedShortcodes};
  71.       new d.AviaModal(b);
  72.       return!1
  73.     });
  74.     b.on("click", ".avia-modal-group-element-inner", function() {
  75.       var c = d(this).parents(".avia-modal-group-element:eq(0)"), b = c.data();
  76.       b.scope = a;
  77.       b.on_load = c.data("modal_on_load");
  78.       b.before_save = c.data("before_save");
  79.       b.on_save = a.send_to_datastorage;
  80.       b.save_param = c;
  81.       b.ajax_param = {subelement:!0, extract:!0, shortcode:c.find(a.datastorage + ":eq(0)").val()};
  82.       new d.AviaModal(b);
  83.       return!1
  84.     });
  85.     b.on("click", ".avia-attach-modal-element-delete", function(c) {
  86.       a.shortcodes.deleteModalSubItem(this, c)
  87.     });
  88.     b.on("click", ".avia-attach-modal-element-add", function(c) {
  89.       a.shortcodes.appendModalSubItem(this, c)
  90.     });
  91.     this.canvas.on("click", "a.avia-clone", function() {
  92.       a.cloneElement(this, a);
  93.       return!1
  94.     });
  95.     this.canvas.on("change", "select.avia-recalc-shortcode", function() {
  96.       var c = d(this).parents(".avia_sortable_element:eq(0)");
  97.       a.recalc_shortcode(c);
  98.       return!1
  99.     });
  100.     this.canvas.on("avia-history-update", function() {
  101.       a.activate_element_dragging(this.canvasParent, "");
  102.       a.activate_element_dropping(this.canvasParent, "")
  103.     })
  104.   }, activate_element_dragging:function(a, b) {
  105.     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) {
  106.       a = d(a.target);
  107.       a.css({opacity:0.4});
  108.       d(".avia-hover-active").removeClass("avia-hover-active");
  109.       c.canvas.addClass("avia-select-target-" + a.data("dragdrop-level"))
  110.     }, stop:function(a) {
  111.       d(a.target).css({opacity:1});
  112.       d(".avia-hover-active").removeClass("avia-hover-active");
  113.       c.canvas.removeClass("avia-select-target-1 avia-select-target-2 avia-select-target-3 avia-select-target-4")
  114.     }};
  115.     "undefined" == typeof b && (b = ":not(.ui-draggable)");
  116.     e.find(".av_drag" + b).draggable(f);
  117.     f.cursorAt = {left:33, top:33};
  118.     f.handle = !1;
  119.     e.find(".shortcode_insert_button").not(".ui-draggable").draggable(f)
  120.   }, activate_element_dropping:function(a, b) {
  121.     var c = this, e = a || this.canvasParent;
  122.     "undefined" == typeof b && (b = ":not(.ui-droppable)");
  123.     "destroy" == b && (e.find(".av_drop").droppable("destroy"), b = "");
  124.     e.find(".av_drop" + b).droppable({tolerance:"pointer", greedy:!0, over:function(a, b) {
  125.       var e = d(this);
  126.       c.droping_allowed(b.helper, e) && e.addClass("avia-hover-active")
  127.     }, out:function() {
  128.       d(this).removeClass("avia-hover-active")
  129.     }, drop:function(a, b) {
  130.       var e = d(this);
  131.       if(!e.is(".avia-hover-active")) {
  132.         return!1
  133.       }
  134.       for(var j = e.find(">.av_drag"), k = {}, m = "after", l = !1, n = [], p, q, r = 0;r < j.length;r++) {
  135.         var s = j.eq(r), k = s.offset();
  136.         if(k.top < b.offset.top) {
  137.           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})
  138.         }else {
  139.           break
  140.         }
  141.       }
  142.       if(p && 1 < n["top_" + p.top].length && q - 40 > b.offset.top) {
  143.         l = !1;
  144.         for(r = 0;r < n["top_" + p.top].length;r++) {
  145.           if(n["top_" + p.top][r].left < b.offset.left) {
  146.             l = n["top_" + p.top][r].index
  147.           }else {
  148.             break
  149.           }
  150.         }
  151.         !1 === l && (l = n["top_" + p.top][0].index, m = "before");
  152.         l = j.eq(l)
  153.       }
  154.       !1 === l && (l = e, m = "prepend");
  155.       if(l[0] != b.draggable[0]) {
  156.         if(b.draggable[0].hash) {
  157.           var t = b.draggable.get(0).hash.replace("#", ""), t = d(d("#avia-tmpl-" + t).html());
  158.           b.draggable = t
  159.         }
  160.         e = b.draggable.parents(".av_drag:last");
  161.         l[m](b.draggable);
  162.         e.length && c.updateInnerTextarea(!1, e);
  163.         if(0 !== ("after" == m ? l.parents(".av_drop") : l).data("dragdrop-level")) {
  164.           c.updateTextarea(), c.updateInnerTextarea(b.draggable)
  165.         }
  166.         c.updateTextarea();
  167.         c.targetInsertInactive();
  168.         "undefined" != typeof t && (c.canvas.removeClass("ui-droppable").droppable("destroy"), c.activate_element_dragging(), c.activate_element_dropping());
  169.         c.do_history_snapshot()
  170.       }
  171.     }})
  172.   }, droping_allowed:function(a, b) {
  173.     return a.data("dragdrop-level") > b.data("dragdrop-level") ? !0 : !1
  174.   }, switch_layout_mode:function() {
  175.     var a = this, b = this.tiny_active ? window.tinyMCE.get("content") : !1;
  176.     "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() {
  177.       d("#content-tmce").trigger("click");
  178.       a.convertTextToInterface()
  179.     }, 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"),
  180.     b && b.setContent("", {format:"html"}), this.classic_textarea.val("")));
  181.     return!1
  182.   }, sendToAdvancedEditor:function(a) {
  183.     a = d(a);
  184.     this.canvas.append(a);
  185.     this.activate_element_dragging();
  186.     this.activate_element_dropping()
  187.   }, updateInnerTextarea:function(a, b) {
  188.     "undefined" == typeof b && (b = d(a).parents(".avia_layout_section:eq(0)"));
  189.     b.length || (b = d(a).parents(".avia_layout_column:eq(0)"));
  190.     if(b.length) {
  191.       if(b.is(".avia_layout_section")) {
  192.         for(var c = b.find(".avia_layout_column"), e = 0;e < c.length;e++) {
  193.           this.updateInnerTextarea(!1, d(c[e]))
  194.         }
  195.         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++) {
  196.           h += d(f[e]).val()
  197.         }
  198.         h = j[0] + "\n\n" + h + "[/" + g + "]";
  199.         c.val(h)
  200.       }
  201.       if(b.is(".avia_layout_column")) {
  202.         c = b.find(">.avia_inner_shortcode >" + this.datastorage);
  203.         f = b.find(".avia_sortable_element " + this.datastorage);
  204.         h = "";
  205.         g = b.data("width");
  206.         j = b.is(".avia-first-col") ? " first" : "";
  207.         for(e = 0;e < f.length;e++) {
  208.           h += d(f[e]).val()
  209.         }
  210.         c.val("[" + g + j + "]\n\n" + h + "[/" + g + "]")
  211.       }
  212.     }
  213.   }, updateTextarea:function(a) {
  214.     if(!a) {
  215.       var b = this;
  216.       d(".avia_layout_builder").find(".avia_layout_section").each(function() {
  217.         b.updateTextarea(d(this).find(">.avia_inner_shortcode > div > .avia_inner_shortcode"))
  218.       });
  219.       a = d(".avia_layout_builder > div > .avia_inner_shortcode")
  220.     }
  221.     a = a.find(">" + this.datastorage);
  222.     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++) {
  223.       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
  224.     }
  225.     var l = this.tiny_active ? window.tinyMCE.get("content") : void 0;
  226.     "undefined" != typeof l && (clearTimeout(this.update_timout), this.update_timout = setTimeout(function() {
  227.       l.setContent(window.switchEditors.wpautop(c), {format:"html"})
  228.     }, 500));
  229.     this.classic_textarea.val(c);
  230.     this.secureContent.val(c)
  231.   }, do_history_snapshot:function(a) {
  232.     var b = this;
  233.     a || (a = 150);
  234.     setTimeout(function() {
  235.       b.canvas.trigger("avia-storage-update")
  236.     }, a)
  237.   }, convertTextToInterface:function(a) {
  238.     if("active" == this.activeStatus.val()) {
  239.       var b = this;
  240.       "undefined" == typeof a && (a = this.secureContent.val(), -1 === a.indexOf("[") && (a = this.classic_textarea.val(), this.secureContent.val(a)));
  241.       this.tiny_active && (a = window.switchEditors._wp_Nop(a));
  242.       d.ajax({type:"POST", url:ajaxurl, data:{action:"avia_ajax_text_to_interface", text:a}, success:function(a) {
  243.         b.sendToAdvancedEditor(a);
  244.         b.canvas.removeClass("preloading");
  245.         b.do_history_snapshot()
  246.       }});
  247.       var c = jQuery;
  248.       c.AviaElementBehavior = c.AviaElementBehavior || {};
  249.       c(document).ready(function() {
  250.         c.AviaElementBehavior.image_radio();
  251.         c.AviaElementBehavior.tabs(".avia-tab-container");
  252.         c.AviaElementBehavior.icon_select();
  253.         c.AviaElementBehavior.expand_metabox();
  254.         c.AviaElementBehavior.check_dependencies();
  255.         c.AviaElementBehavior.set_target_property();
  256.         c.AviaElementBehavior.tmpl_fetcher();
  257.         c.AviaElementBehavior.redo_undo();
  258.         c.AviaElementBehavior.wp_media_advanced();
  259.         new c.AviaElementBehavior.wp_save_template;
  260.         new c.AviaTooltip({attach:"body"});
  261.         new c.AviaTooltip({"class":"avia-help-tooltip", data:"avia-help-tooltip", event:"click", position:"bottom", attach:"body"})
  262.       });
  263.       c.AviaElementBehavior.tabs = function(a, b) {
  264.         c(a).each(function(a) {
  265.           var d = 0, e = "avia_post_" + a + "_" + avia_globals.post_id, k = !1;
  266.           "undefined" !== typeof Storage && (k = !0, d = sessionStorage[e] || 0);
  267.           a = c(this);
  268.           var m = a.find(".avia-tab-title-container a"), l = a.find(".avia-tab"), n;
  269.           m.unbind("click").bind("click", function() {
  270.             m.removeClass("active-tab");
  271.             n = c(this).addClass("active-tab");
  272.             var a = m.index(n);
  273.             l.css({display:"none"}).filter(":eq(" + a + ")").css({display:"block"});
  274.             k && (sessionStorage[e] = a);
  275.             "undefined" != typeof b && b.find(".avia-tab-title-container a").eq(a).trigger("click");
  276.             return!1
  277.           });
  278.           m.filter(".active-tab").length || m.filter(":eq(" + d + ")").addClass("active-tab").trigger("click")
  279.         })
  280.       };
  281.       c.AviaElementBehavior.image_radio = function() {
  282.         c('.avia_scope input[type="radio"]:checked').parents(".avia_radio_wrap:eq(0)").addClass("avia_checked");
  283.         c("body").on("click", ".avia_scope input[type='radio']", function() {
  284.           c(this).parents(".avia_radio_wrap:eq(0)").siblings(".avia_radio_wrap").removeClass("avia_checked").end().addClass("avia_checked")
  285.         })
  286.       };
  287.       c.AviaElementBehavior.icon_select = function() {
  288.         c("body").on("click", ".avia-attach-element-select", function() {
  289.           var a = c(this), b = a.parents(".avia-attach-element-container:eq(0)");
  290.           b.find(".avia-active-element").removeClass("avia-active-element");
  291.           var d = b.find("input[type=hidden]:eq(0)"), b = b.find("input[type=hidden]:eq(1)");
  292.           a.addClass("avia-active-element");
  293.           d.val(a.data("element-nr"));
  294.           b.length && b.val(a.html());
  295.           return!1
  296.         })
  297.       };
  298.       c.AviaElementBehavior.expand_metabox = function() {
  299.         function a() {
  300.           l.addClass("avia-expanded");
  301.           b.addClass("avia-noscroll-box");
  302.           p = l.find(".avia-tab-container").clone(!0);
  303.           p.length && (q = c('<div class="avia-expanded-buttons"></div>').appendTo(p), j.clone(!0).appendTo(q).bind("click", function() {
  304.             setTimeout(function() {
  305.               window.open("", "wp-preview", "").focus()
  306.             }, 10)
  307.           }), 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")))
  308.         }
  309.         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;
  310.         d.length && (m = d, l = m.parents(".postbox:eq(0)"), a());
  311.         b.on("click", ".avia-attach-expand", function() {
  312.           m = c(this);
  313.           l = m.parents(".postbox:eq(0)");
  314.           l.is(".avia-expanded") ? k.css({display:"block", opacity:0}).animate({opacity:1}, function() {
  315.             l.removeClass("avia-expanded");
  316.             b.removeClass("avia-noscroll-box");
  317.             n.length && n.remove();
  318.             k.animate({opacity:0}, function() {
  319.               k.css({display:"none"})
  320.             })
  321.           }) : k.css({display:"block", opacity:0}).animate({opacity:1}, function() {
  322.             a();
  323.             k.animate({opacity:0}, function() {
  324.               k.css({display:"none"})
  325.             })
  326.           });
  327.           return!1
  328.         })
  329.       };
  330.       c.AviaElementBehavior.check_dependencies = function() {
  331.         var a = c("body");
  332.         a.on("change", ".avia-style select, .avia-style radio, .avia-style input[type=checkbox], .avia-style input[type=hidden]", function() {
  333.           var b = c(this), d = b.parents(".avia-modal:eq(0)");
  334.           d.length || (d = a);
  335.           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");
  336.           d.length && d.each(function() {
  337.             var a = c(this), b = a.data(), d = b.checkValue, e = !1;
  338.             if(!k) {
  339.               switch(b.checkComparison) {
  340.                 case "equals":
  341.                   j == d && (e = !0);
  342.                   break;
  343.                 case "not":
  344.                   j != d && (e = !0);
  345.                   break;
  346.                 case "is_larger":
  347.                   j > d && (e = !0);
  348.                   break;
  349.                 case "is_smaller":
  350.                   j < d && (e = !0);
  351.                   break;
  352.                 case "contains":
  353.                   -1 != j.indexOf(d) && (e = !0);
  354.                   break;
  355.                 case "doesnt_contain":
  356.                   -1 == j.indexOf(d) && (e = !0);
  357.                   break;
  358.                 case "is_empty_or":
  359.                   if("" == j || j == d) {
  360.                     e = !0
  361.                   }
  362.                   break;
  363.                 case "not_empty_and":
  364.                   "" != j && j != d && (e = !0)
  365.               }
  366.             }
  367.             !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))
  368.           })
  369.         })
  370.       };
  371.       c.AviaElementBehavior.set_target_property = function() {
  372.         var a = c("body");
  373.         a.on("change", ".avia-style select, .avia-style radio, .avia-style input[type=checkbox]", function() {
  374.           var b = c(this), d = b.parents(".avia-form-element-container:eq(0)"), g = b.parents(".avia-modal:eq(0)"), j = d.data(), k = "";
  375.           if(j.targetElement) {
  376.             g.length || (g = a);
  377.             b.is("select") && (k = b.find("option").map(function() {
  378.               return this.value
  379.             }).get().join(" "));
  380.             var b = a.find(j.targetElement), m = this.value;
  381.             b.length && b.each(function() {
  382.               var a = c(this);
  383.               switch(j.targetProperty) {
  384.                 case "class":
  385.                   a.removeClass(k).addClass(m);
  386.                   break;
  387.                 case "id":
  388.                   a.attr({id:m})
  389.               }
  390.             })
  391.           }
  392.         });
  393.         a.on("avia_modal_finished", function(a, b) {
  394.           b.modal.find(".avia-attach-targeting select,.avia-attach-targeting radio,.avia-attach-targeting input[type=checkbox]").trigger("change")
  395.         })
  396.       };
  397.       c.AviaElementBehavior.tmpl_fetcher = function() {
  398.         var a = c("body");
  399.         a.on("change", ".avia-attach-templating select, .avia-attach-templating radio, .avia-attach-templating input[type=checkbox]", function() {
  400.           var a = c(this);
  401.           a.parents(".avia-form-element-container:eq(0)");
  402.           a.parents(".avia-modal:eq(0)");
  403.           a = a.next(".template-container");
  404.           if(a.length) {
  405.             var b = this.value, d = c("#avia-tmpl-" + b);
  406.             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 />"));
  407.             a.html(d.html())
  408.           }
  409.         });
  410.         a.on("avia_modal_finished", function(a, b) {
  411.           b.modal.find(".avia-attach-templating select,.avia-attach-templating radio,.avia-attach-templating input[type=checkbox]").trigger("change")
  412.         })
  413.       };
  414.       c.AviaElementBehavior.redo_undo = function() {
  415.         new c.AviaElementBehavior.history({monitor:"#aviaLayoutBuilder", editor:"#_aviaLayoutBuilderCleanData", buttons:".layout-builder-wrap .avia-controll-bar"})
  416.       }
  417.     }
  418.   }, targetInsertActive:function(a, b) {
  419.     b || (b = "avia-hover-target avia-select-target-" + d(a).data("dragdrop-level"));
  420.     d(".avia-hover").removeClass("avia-hover");
  421.     this.canvas.addClass(b);
  422.     this.targetInsert = a
  423.   }, targetInsertInactive:function() {
  424.     d(".shortcode_button_wrap").find(".avia-active-insert").removeClass("avia-active-insert");
  425.     this.canvas.removeClass("avia-hover-target avia-select-target-1 avia-select-target-2 avia-select-target-3 avia-select-target-4");
  426.     this.targetInsert = "";
  427.     this.only_one_insert = !1
  428.   }, doTargetInsert:function(a, b, c) {
  429.     var e = d(a), f = "object" == typeof b.targetInsert ? b.targetInsert : d(b.targetInsert);
  430.     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())
  431.   }, changeTargetingShortcode:function(a) {
  432.     var b = 37 == a ? -1 : 1;
  433.     a = d(".shortcode_button_wrap:last");
  434.     var c = a.find(".avia-target-insert"), e = c.filter(".avia-active-insert"), e = c.index(e), e = c.filter(":eq(" + (e + b) + ")");
  435.     e.length || (e = 1 == b ? c.filter(":first") : c.filter(":last"));
  436.     e.trigger("click");
  437.     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"));
  438.     return!1
  439.   }, cloneElement:function(a, b) {
  440.     var c = d(a), e = c.parents(".avia_sortable_element:eq(0)");
  441.     e.length || (e = c.parents(".avia_layout_column:eq(0)"));
  442.     e.length || (e = c.parents(".avia_layout_section:eq(0)"));
  443.     e.find("textarea").each(function() {
  444.       this.innerHTML = this.value
  445.     });
  446.     c = e.clone();
  447.     c.removeClass("ui-draggable ui-droppable").find(".ui-draggable, .ui-droppable").removeClass("ui-draggable ui-droppable");
  448.     c.insertAfter(e);
  449.     c = e.parents(".avia_layout_section, .avia_layout_column");
  450.     if(e.is(".avia_layout_column") || e.is(".avia_layout_section") || c.length) {
  451.       c.length && b.updateTextarea(), b.updateInnerTextarea(e)
  452.     }
  453.     b.activate_element_dragging();
  454.     b.activate_element_dropping();
  455.     b.updateTextarea();
  456.     b.do_history_snapshot()
  457.   }, recalc_shortcode:function(a) {
  458.     for(var b = a.find("select.avia-recalc-shortcode"), c = !1, e = [], f = 0;f < b.length;f++) {
  459.       c = d(b[f]), e[c.data("attr")] = c.val()
  460.     }
  461.     this.send_to_datastorage(e, a)
  462.   }, send_to_datastorage:function(a, b) {
  463.     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 = {};
  464.     "string" == typeof a ? g = a : (j = this.update_builder_html(b, a), g = j.output, j = j.tags);
  465.     b.is(".avia_layout_section") ? c.val(c.val().replace(RegExp("^\\[" + h + ".*?\\]"), j.open)) : c.val(g);
  466.     f.length ? this.updateInnerTextarea(!1, f) : d.length && this.updateInnerTextarea(!1, d);
  467.     this.updateTextarea();
  468.     this.do_history_snapshot();
  469.     b.trigger("update")
  470.   }, update_builder_html:function(a, b) {
  471.     var c, e, f;
  472.     for(c in b) {
  473.       b.hasOwnProperty(c) && (f = c.replace(/aviaTB/g, ""), f != c && (b[f] = b[c], delete b[c]))
  474.     }
  475.     for(c in b) {
  476.       if(b.hasOwnProperty(c) && "content" != c) {
  477.         if("string" == typeof b[c]) {
  478.           b[c] = b[c].replace(/'(.+?)'/g, "\u2018$1\u2019").replace(/'/g, "\u2019")
  479.         }else {
  480.           if("object" == typeof b[c]) {
  481.             for(e in b[c]) {
  482.               b[c][e] = b[c][e].replace(/'(.+?)'/g, "\u2018$1\u2019").replace(/'/g, "\u2019")
  483.             }
  484.           }
  485.         }
  486.       }
  487.     }
  488.     e = a.data("shortcodehandler");
  489.     f = a.find("[data-update_with]");
  490.     var h = a.find("[data-update_class_with]").attr("class", ""), g = "", j = "", k = "", m = "", l = "";
  491.     a.is(".avia-no-visual-updates") || (f.each(function() {
  492.       j = d(this);
  493.       g = j.data("update_with");
  494.       k = j.data("update_template");
  495.       if("string" === typeof b[g] || "number" === typeof b[g]) {
  496.         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)
  497.       }
  498.     }), h.each(function() {
  499.       j = d(this);
  500.       g = j.data("update_class_with").split(",");
  501.       for(var a = 0;a < g.length;a++) {
  502.         "string" === typeof b[g[a]] && (j.get(0).className += " avia-" + g[a] + "-" + b[g[a]])
  503.       }
  504.     }));
  505.     for(c in b) {
  506.       b.hasOwnProperty(c) && -1 !== c.indexOf("_fakeArg") && delete b[c]
  507.     }
  508.     c = {};
  509.     f = {};
  510.     f.output = this.createShortcode(b, e, c);
  511.     f.tags = c;
  512.     return f
  513.   }, createShortcode:function(a, b, c) {
  514.     var e, f = "", h = f = "", g = ",";
  515.     c || (c = {});
  516.     if("undefined" != typeof a.content) {
  517.       if("object" == typeof a.content) {
  518.         -1 != a.content[0].indexOf("[") && (g = "\n");
  519.         for(h = 0;h < a.content.length;h++) {
  520.           a.content[h] = d.trim(a.content[h])
  521.         }
  522.         h = a.content.join(g)
  523.       }else {
  524.         h = a.content
  525.       }
  526.       h = "\n" + h + "\n";
  527.       delete a.content
  528.     }
  529.     for(e in a) {
  530.       a.hasOwnProperty(e) && ("object" === typeof a[e] && (a[e] = a[e].join(",")), f += e + "='" + a[e] + "' ")
  531.     }
  532.     c.open = "[" + b + " " + d.trim(f) + "]";
  533.     f = c.open;
  534.     h && ("" == d.trim(h) && (h = ""), c.close = "[/" + b + "]", f += h + c.close);
  535.     return f + "\n\n"
  536.   }};
  537.   d(document).ready(function() {
  538.     d.avia_builder = new d.AviaBuilder
  539.   })
  540. })(jQuery);
  541. (function(d) {
  542.   d.AviaBuilder.shortcodes = d.AviaBuilder.shortcodes || {};
  543.   d.AviaBuilder.shortcodes.fetchShortcodeEditorElement = function(a, b, c) {
  544.     a = d("#avia-tmpl-" + a);
  545.     a.length && ("instant_insert" == b ? (c.sendToAdvancedEditor(a.html()), c.updateTextarea(), c.do_history_snapshot(0)) : c.targetInsertActive(a.html()))
  546.   };
  547.   d.AviaBuilder.shortcodes.deleteItem = function(a, b) {
  548.     var c = d(a), e = c.parents(".avia_sortable_element:eq(0)"), f = !1;
  549.     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));
  550.     b.targetInsertInactive();
  551.     e.hide(200, function() {
  552.       e.remove();
  553.       f && f.length && b.updateInnerTextarea(f);
  554.       b.updateTextarea();
  555.       "" == b.secureContent.val() && b.activate_element_dropping(b.canvasParent, "destroy");
  556.       b.do_history_snapshot()
  557.     })
  558.   };
  559.   d.AviaBuilder.shortcodes.deleteModalSubItem = function(a, b) {
  560.     b.stopImmediatePropagation();
  561.     var c = d(a).parents(".avia-modal-group-element:eq(0)");
  562.     c.slideUp(200, function() {
  563.       c.remove()
  564.     })
  565.   };
  566.   d.AviaBuilder.shortcodes.appendModalSubItem = function(a, b) {
  567.     b.preventDefault();
  568.     var c = d(a).parents(".avia-modal-group-wrapper:eq(0)"), e = c.find(".avia-modal-group"), c = c.find(".avia-tmpl-modal-element");
  569.     d(c.html()).appendTo(e).css({display:"none"}).slideDown(200)
  570.   };
  571.   d.AviaBuilder.shortcodes.changeSize = function(a, b) {
  572.     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++) {
  573.       l[n][0] == h && (g = l[n - c])
  574.     }
  575.     "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))
  576.   }
  577. })(jQuery);
  578. (function(d) {
  579.   d.AviaElementBehavior = d.AviaElementBehavior || {};
  580.   d.AviaElementBehavior.wp_media = d.AviaElementBehavior.wp_media || [];
  581.   d.AviaModal = function(a) {
  582.     var b = {scope:this, modal_title:"", modal_class:"", modal_content:!1, modal_ajax_hook:"", on_save:function() {
  583.     }, on_load:function() {
  584.     }, before_save:"", save_param:{}, ajax_param:"", button:"save"};
  585.     d.AviaModal.openInstance.unshift(this);
  586.     this.instanceNr = d.AviaModal.openInstance.length;
  587.     this.options = d.extend({}, b, a);
  588.     this.namespace = ".AviaModal" + this.instanceNr;
  589.     this.body = d("body").addClass("avia-noscroll");
  590.     this.doc = d(document);
  591.     this.modal = d('<div class="avia-modal avia-style"></div>');
  592.     this.backdrop = d('<div class="avia-modal-backdrop"></div>');
  593.     this.set_up()
  594.   };
  595.   d.AviaModal.openInstance = [];
  596.   d.AviaModal.prototype = {set_up:function() {
  597.     this.create_html();
  598.     this.add_behavior();
  599.     this.modify_binding_order();
  600.     this.propagate_modal_open()
  601.   }, add_behavior:function() {
  602.     var a = this;
  603.     this.modal.on("click", ".avia-modal-save", function() {
  604.       a.execute_callback();
  605.       return!1
  606.     });
  607.     this.backdrop.add(".avia-attach-close-event", this.modal).on("click", function() {
  608.       a.close();
  609.       return!1
  610.     });
  611.     this.doc.bind("keydown" + this.namespace, function(b) {
  612.       a.media_overlay_closed() && (13 == b.keyCode && !(b.target.tagName && "textarea" == b.target.tagName.toLowerCase()) && (setTimeout(function() {
  613.         a.execute_callback()
  614.       }, 100), b.stopImmediatePropagation()), 27 == b.keyCode && (setTimeout(function() {
  615.         a.close()
  616.       }, 100), b.stopImmediatePropagation()))
  617.     })
  618.   }, modify_binding_order:function() {
  619.     var a = jQuery.hasData(document) && jQuery._data(document), b = a.events.keydown.pop();
  620.     a.events.keydown.unshift(b)
  621.   }, create_html:function() {
  622.     var a = this.options.modal_content ? this.options.modal_content : "", b = this.options.modal_content ? "" : " preloading ", c;
  623.     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>');
  624.     c = c + ('<div class="avia-modal-inner-content ' + b + '">' + a + "</div>") + '<div class="avia-modal-inner-footer">';
  625.     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;
  626.     c += "</div></div>";
  627.     this.options.modal_class && this.modal.addClass(this.options.modal_class);
  628.     this.body.append(this.modal).append(this.backdrop);
  629.     this.modal.html(c);
  630.     a = this.instanceNr - 1;
  631.     b = parseInt(this.modal.css("zIndex"), 10);
  632.     this.modal.css({margin:30 * a, zIndex:b + a + 1});
  633.     this.backdrop.css({zIndex:b + a});
  634.     if(this.options.modal_content) {
  635.       this.on_load_callback()
  636.     }else {
  637.       this.fetch_ajax_content()
  638.     }
  639.   }, set_focus:function() {
  640.     this.modal.find("select, input[type=text], input[type=checkbox], textarea, radio").filter(":eq(0)").focus()
  641.   }, fetch_ajax_content:function() {
  642.     var a = this, b = a.modal.find(".avia-modal-inner-content");
  643.     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() {
  644.       d.AviaModal.openInstance[0].close();
  645.       new d.AviaModalNotification({mode:"error", msg:avia_modal_L10n.ajax_error})
  646.     }, success:function(c) {
  647.       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())
  648.     }, complete:function() {
  649.       b.removeClass("preloading")
  650.     }})
  651.   }, on_load_callback:function() {
  652.     var a = this.options.on_load, b = 0;
  653.     if("string" == typeof a) {
  654.       for(b in a = a.split(", "), a) {
  655.         "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"))
  656.       }
  657.     }else {
  658.       "function" == typeof a && a.call()
  659.     }
  660.     this.set_focus();
  661.     this.propagate_modal_content()
  662.   }, close:function() {
  663.     d.AviaModal.openInstance.shift();
  664.     this.modal.remove();
  665.     this.backdrop.remove();
  666.     this.doc.trigger("avia_modal_close").unbind("keydown" + this.namespace);
  667.     0 == d.AviaModal.openInstance.length && this.body.removeClass("avia-noscroll")
  668.   }, convert_values:function(a) {
  669.     var b = {};
  670.     d.each(a, function() {
  671.       "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 || ""
  672.     });
  673.     return b
  674.   }, execute_callback:function() {
  675.     var a = this.modal.find("input, select, radio, textarea").serializeArray(), a = this.convert_values(a);
  676.     "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));
  677.     !1 !== this.options.on_save.call(this.options.scope, a, this.options.save_param) && this.close()
  678.   }, media_overlay_closed:function() {
  679.     return d.AviaElementBehavior.wp_media.length ? !1 : !0
  680.   }, propagate_modal_open:function() {
  681.     this.body.trigger("avia_modal_open", this)
  682.   }, propagate_modal_content:function() {
  683.     this.body.trigger("avia_modal_finished", this)
  684.   }};
  685.   d.AviaModalNotification = function(a) {
  686.     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);
  687.     return new d.AviaModal(this.options)
  688.   };
  689.   d.AviaModal.register_callback = d.AviaModal.register_callback || {};
  690.   d.AviaModal.register_callback.modal_start_sorting = function(a) {
  691.     a = (a || this.modal).find(".avia-modal-group");
  692.     a.find(".avia-modal-group-element, .avia-insert-area").disableSelection();
  693.     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) {
  694.       d(".avia-modal-group-element-highlight").height(c.item.outerHeight()).width(c.item.outerWidth())
  695.     }, update:function() {
  696.     }, stop:function() {
  697.     }})
  698.   };
  699.   d.AviaModal.register_callback.modal_load_colorpicker = function() {
  700.     var a = this.modal;
  701.     a.find(".colorpicker").wpColorPicker();
  702.     a.find(".wp-color-result").click(function(b) {
  703.       "undefined" != typeof b.originalEvent && a.find(".wp-picker-open").not(this).trigger("click")
  704.     })
  705.   };
  706.   d.AviaModal.register_callback.modal_load_tiny_mce = function(a) {
  707.     a = a || this.modal.find(".avia-modal-inner-content .avia_tinymce");
  708.     var b = a.parents(".avia-modal:eq(0)").find(".avia-modal-save");
  709.     a.each(function() {
  710.       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");
  711.       quicktags({id:this.id, buttons:"strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close"});
  712.       QTags._buttonsInit();
  713.       h.bind("click", function() {
  714.         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))
  715.       }).trigger("click");
  716.       b.bind("click", function() {
  717.         h.filter(".switch-html").trigger("click")
  718.       })
  719.     })
  720.   }
  721. })(jQuery);
  722. (function(d) {
  723.   d.AviaElementBehavior = d.AviaElementBehavior || {};
  724.   d.AviaElementBehavior.history = function(a) {
  725.     if("undefined" === typeof Storage) {
  726.       return!1
  727.     }
  728.     this.options = d.extend({}, {steps:40, monitor:"", editor:"", buttons:"", event:"avia-storage-update"}, a);
  729.     this.setUp()
  730.   };
  731.   d.AviaElementBehavior.history.prototype = {setUp:function() {
  732.     this.canvas = d(this.options.monitor);
  733.     this.wrapper = this.canvas.parent();
  734.     this.buttons = d(this.options.buttons);
  735.     this.editor = d(this.options.editor);
  736.     this.key = this.create_array_key();
  737.     this.storage = this.get() || [];
  738.     this.max = this.storage.length - 1;
  739.     this.index = this.get(this.key + "index");
  740.     if("undefined" == typeof this.index || null == this.index) {
  741.       this.index = this.storage.length - 1
  742.     }
  743.     this.undoBtn = d('<a href="#undo" class="avia-undo-button " title="' + avia_history_L10n.undo_label + '"><-</a>').appendTo(this.buttons);
  744.     this.redoBtn = d('<a href="#redo" class="avia-redo-button " title="' + avia_history_L10n.redo_label + '">-></a>').appendTo(this.buttons);
  745.     this.clear();
  746.     this.bindEvents()
  747.   }, create_array_key:function() {
  748.     var a = "avia" + avia_globals.themename + avia_globals.themeversion + avia_globals.post_id + avia_globals.builderversion;
  749.     return a = a.replace(/[^a-zA-Z0-9]/g, "").toLowerCase()
  750.   }, bindEvents:function() {
  751.     var a = this;
  752.     this.canvas.on("avia-storage-update", function() {
  753.       a.do_snapshot()
  754.     });
  755.     this.wrapper.on("click", ".avia-undo-button", function() {
  756.       a.undo()
  757.     });
  758.     this.wrapper.on("click", ".avia-redo-button", function() {
  759.       a.redo()
  760.     })
  761.   }, set:function(a, b) {
  762.     var c = a || this.key, d = b || JSON.stringify(this.storage);
  763.     try {
  764.       sessionStorage.setItem(c, d)
  765.     }catch(f) {
  766.       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")
  767.     }
  768.   }, get:function(a) {
  769.     return JSON.parse(sessionStorage.getItem(a || this.key))
  770.   }, clear:function() {
  771.     sessionStorage.removeItem(this.key);
  772.     sessionStorage.removeItem(this.key + "index");
  773.     this.storage = [];
  774.     this.index = null
  775.   }, redo:function() {
  776.     this.index + 1 <= this.max && (this.index++, this.update_canvas(this.storage[this.index]));
  777.     return!1
  778.   }, undo:function() {
  779.     0 <= this.index - 1 && (this.index--, this.update_canvas(this.storage[this.index]));
  780.     return!1
  781.   }, update_canvas:function(a) {
  782.     "undefined" == typeof this.tinyMCE && (this.tinyMCE = "undefined" == typeof window.tinyMCE ? !1 : window.tinyMCE.get(this.options.editor.replace("#", "")));
  783.     this.tinyMCE && this.tinyMCE.setContent(window.switchEditors.wpautop(a[0]), {format:"html"});
  784.     this.editor.val(a[0]);
  785.     this.canvas.html(a[1]);
  786.     sessionStorage.setItem(this.key + "index", this.index);
  787.     this.index + 1 > this.max ? this.redoBtn.addClass("avia-inactive-step") : this.redoBtn.removeClass("avia-inactive-step");
  788.     0 >= this.index ? this.undoBtn.addClass("avia-inactive-step") : this.undoBtn.removeClass("avia-inactive-step");
  789.     this.canvas.trigger("avia-history-update")
  790.   }, do_snapshot:function() {
  791.     this.canvas.find("textarea").each(function() {
  792.       this.innerHTML = this.value
  793.     });
  794.     this.storage = this.storage || this.get() || [];
  795.     this.index = this.index || this.get(this.key + "index");
  796.     if("undefined" == typeof this.index || null == this.index) {
  797.       this.index = this.storage.length - 1
  798.     }
  799.     var a = [this.editor.val(), this.canvas.html().replace(/avia_pop_class/g, "")], b = this.storage[this.index];
  800.     if("undefined" === typeof b || b[0] !== a[0]) {
  801.       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()
  802.     }
  803.     this.max = this.storage.length - 1;
  804.     1 == this.storage.length || 0 == this.index ? this.undoBtn.addClass("avia-inactive-step") : this.undoBtn.removeClass("avia-inactive-step");
  805.     this.storage.length - 1 == this.index ? this.redoBtn.addClass("avia-inactive-step") : this.redoBtn.removeClass("avia-inactive-step")
  806.   }}
  807. })(jQuery);
  808. (function(d) {
  809.   d.AviaTooltip = function(a) {
  810.     this.options = d.extend({}, {delay:1500, delayOut:300, "class":"avia-tooltip", scope:"#avia_builder", data:"avia-tooltip", attach:"element", event:"mouseenter", position:"top"}, a);
  811.     this.body = d("body");
  812.     this.scope = d(this.options.scope);
  813.     this.tooltip = d('<div class="' + this.options.className + '"><span class="avia-arrow-wrap"><span class="avia-arrow"></span></span></div>');
  814.     this.inner = d('<div class="inner_tooltip"></div>').prependTo(this.tooltip);
  815.     this.active = this.timer = this.open = !1;
  816.     this.bind_events()
  817.   };
  818.   d.AviaTooltip.openTTs = [];
  819.   d.AviaTooltip.prototype = {bind_events:function() {
  820.     this.scope.on(this.options.event + " mouseleave", "[data-" + this.options.data + "]", d.proxy(this.start_countdown, this));
  821.     if("click" != this.options.event) {
  822.       this.scope.on("mouseleave", "[data-" + this.options.data + "]", d.proxy(this.hide_tooltip, this))
  823.     }else {
  824.       this.body.on("mousedown", d.proxy(this.hide_tooltip, this))
  825.     }
  826.   }, start_countdown:function(a) {
  827.     clearTimeout(this.timer);
  828.     if(a.type == this.options.event) {
  829.       var b = "click" == this.options.event ? 0 : this.open ? 0 : this.options.delay;
  830.       this.timer = setTimeout(d.proxy(this.display_tooltip, this, a), b)
  831.     }else {
  832.       "mouseleave" == a.type && (this.timer = setTimeout(d.proxy(this.stop_instant_open, this, a), this.options.delayOut))
  833.     }
  834.     a.preventDefault()
  835.   }, reset_countdown:function() {
  836.     clearTimeout(this.timer);
  837.     this.timer = !1
  838.   }, display_tooltip:function(a) {
  839.     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();
  840.     this.inner.html(c);
  841.     e = "undefined" != typeof e ? d.AviaTooltip.openTTs[e] : this.tooltip.clone().appendTo(f);
  842.     this.open = !0;
  843.     this.active = e;
  844.     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))
  845.   }, hide_tooltip:function(a) {
  846.     var b = d(a.currentTarget), c;
  847.     "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);
  848.     c && (a = parseInt(c.css("top"), 10) - 10, c.animate({top:a, opacity:0}, 200, function() {
  849.       c.css({display:"none"})
  850.     }))
  851.   }, stop_instant_open:function() {
  852.     this.open = !1
  853.   }}
  854. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement