!function(t){function e(t,i){if(null==t)return t;var a=t;if(null==t.length)for(var n in a=[],t)a.push(t[n]);for(var o=0;o').data("prefix",i),s=t('
'),l=t("").html(n.title+" : ("+n.dest+")"),d=t("').val(n.title),p=t("').val(n.dest),r=t('
'),c=t('
'),h=t('
    '),f=t('
  • '),u=t('
  • ');return s.append(l).append(d).append(p).appendTo(o),o.append(s).append(r).append(c).appendTo(e),h.append(f).append(u).appendTo(s),void 0!==n.items&&(o.addClass("outline-haschild"),a(r,n.items,i+"[items]")),o}function a(t,e,a){if(void 0!==e&&e.length>0)for(var n=0;n=0&&(t("."+f).find('a[href="'+window.location.hash.replace("!","")+'"]').trigger("click"),u(window.location.hash)),r.length>0&&r.sortable){r.sortable({containment:c,items:"> ."+n});var v=r.find("."+n).length;r.find("."+n).each((function(e){t(this).attr("index",e)})),r.append(m({},v))}function g(t){var e=t.title||"Select File",i=t.text||"Send to dFlip",a=t.target,n=1==t.multiple&&"add",o=wp.media({multiple:n,title:e,button:{text:i},library:{type:t.type}}).on("select",(function(){var e=o.state().get("selection");if(0==n){var i=e.models[0].attributes.url;a.val(i),t.callback&&t.callback(i)}else t.callback&&t.callback(e)})).open()}function m(e,i){e.src,e.title,e.content,e.hotspot;var a=t('
  • '),n=(e=t('
    '),t('')),o=t('');return a.append(n).append(e),e.append(o),_(a),a}function _(e){var i=t('
      '),a=t('
    • '),n=t('
    • '),o=t('
    • ');i.append(a).append(n).append(o).appendTo(e)}function b(){t('.dflip-box[id^="dflip_"][data-condition]').each((function(){var e,i=function(t){for(var e,i=/(.+?):(is|not|contains|less_than|less_than_or_equal_to|greater_than|greater_than_or_equal_to)\((.*?)\),?/g,a=[];e=i.exec(t);)a.push({check:e[1],rule:e[2],value:e[3]||""});return a}(t(this).data("condition")),a=(t(this).data("operator")||"and").toLowerCase();i.length>0&&(t.each(i,(function(i,n){var o=t("#"+n.check);if(o.length){var s,l=o.length?o.val().toString():"",d=n.value.toString();switch(n.rule){case"less_than":s=parseInt(l)parseInt(d);break;case"greater_than_or_equal_to":s=parseInt(l)>=parseInt(d);break;case"contains":s=-1!==l.indexOf(d);break;case"is":s=l==d;break;case"not":s=l!=d}switch(void 0===e&&(e=s),a){case"or":e=e||s;break;case"and":default:e=e&&s}}})),e?t(this).animate({opacity:"show",height:"show"},200):t(this).animate({opacity:"hide",height:"hide"},200)),delete e}))}function w(t){var e=t.data("global"),i=t.val().trim();i==e||null==e&&""==i?t.addClass("dflip-global-active").removeClass("dflip-global-inactive"):t.addClass("dflip-global-inactive").removeClass("dflip-global-active")}if(v++,t(document).on("click","#dflip_upload_pdf_source",(function(e){e.preventDefault(),g({target:t(this).parent().find("input"),type:"application/pdf"})})),t(document).on("click","#dflip_upload_pdf_thumb,#dflip_upload_bg_image",(function(e){e.preventDefault(),g({target:t(this).parent().find("input"),type:"image"})})),t(document).on("click",".dflip-page-list-add",(function(t){t.preventDefault();var e=r.find(".dflip-empty-page");g({target:e.find("input"),type:"image",multiple:!0,callback:function(t){for(var i=0;i.outline-nodes"),o=a.data("prefix")+"[items]["+n.find(".outline-node").length+"]";i(n,o,{title:"",dest:""}),a.addClass("outline-haschild"),e.stopPropagation()})),t(document).on("click",".outline-wrapper",(function(){var e=t(".outline-active"),i=e.find(">.outline-wrapper > input[dtype='title']").val(),a=e.find(">.outline-wrapper > input[dtype='dest']").val();e.find(">.outline-wrapper > label").html(i+" : ("+a+")");e.removeClass("outline-active"),t(this).closest(".outline-node").addClass("outline-active")})),t(document).on("click",".outline-collapse",(function(){t(this).closest(".outline-node").toggleClass("outline-collapsed")})),t(document).on("click",".dflip-page-image-action",(function(){var e=t(this).closest("."+n);g({target:e.find("input"),type:"image",callback:function(t){e.find("."+d).attr("src",t)}})})),t(".dflip-box .dflip-option >:input").on("change",(function(){b(),w(t(this))})),_(t("."+n)),b(),t('.dflip-box .dflip-option >:input[id^="dflip_"][data-global]').each((function(){w(t(this))})),t("#dflip_outline").length>0){var y=JSON.parse(t("#dflip_outline").val());null!=(y=e(y,"items")).length&&0!=y.length||(y=[]),s=y.length;t('
      Add New Outline
      ').appendTo(h).on("click",(function(){i(h,"_dflip[outline]["+s+"]",{title:"",dest:""}),s++}));a(h,y,"_dflip[outline]"),function(e,i){var a,n,o,l,d,p,r,c,h=t('
      ').appendTo(e).hide(),f="",u=!1,v=!1;function g(t){if(null!=r){var e=t.pageY-r.offset().top;document.title=e.toString();var i=e<5?"before":e>27?"after":"over";i!==f&&(f=i,r.removeClass("has-drag-over has-drag-before has-drag-after").addClass("has-drag-"+f)),h.html("Insert "+f+" "+r.find("label").html())}}function m(t){t.find(".outline-node").length>0?t.addClass("outline-haschild"):t.removeClass("outline-haschild")}function _(e,i){var a;null==i?0==(a=e.parents(".outline-node").first()).length?(s++,i="_dflip[outline]["+s+"]",(a=e).data("prefix",i)):i=a.data("prefix"):(a=e).data("prefix",i),a.find(" >.outline-wrapper >input").each((function(){var e=t(this),a=(e.attr("name"),e.attr("dtype"));e.attr("name",i+"["+a+"]")}));var n=0;a.find(" >.outline-nodes > .outline-node").each((function(){_(t(this),i+"[items]["+n+"]"),n++}))}function b(){if(void 0!==c&&void 0!==r&&""!==f){var t=c.closest(".outline-node"),e=r.closest(".outline-node"),i=t.parents(".outline-node");if(t.has(e).length>0||t.is(e))return void alert("Can't drop into child");"before"==f?t.insertBefore(e):"over"==f?r.siblings(".outline-nodes").append(t):"after"==f&&t.insertAfter(e),m(i),m(t),m(e),_(t)}}e.on("mousedown",(function(e){"INPUT"!=e.target.nodeName&&(c=t(e.target).closest(i),0===e.button&&0!=c.length&&(d=e.pageX-t(this).offset().left,p=e.pageY-t(this).offset().top,u=!0))})).on("mousemove",(function(i){v||1!=u||(o=i.pageX-t(this).offset().left-d,l=i.pageY-t(this).offset().top-p,(Math.abs(o)>5||Math.abs(l)>5)&&(v=!0,h.show(),e.addClass("has-dragging"),c.addClass("is-drag-source"))),v&&(a=i.pageX-t(this).offset().left,n=i.pageY-t(this).offset().top,h.css({left:a-20,top:n+15}),g(i))})),t(window).on("mouseup",(function(t){e.removeClass("has-dragging"),c&&c.removeClass("is-drag-source"),r&&1==v&&(r.removeClass("has-drag-over has-drag-before has-drag-after"),b()),v=!1,u=!1,h.hide(),r=null,c=null})),e.on("mouseover",i,(function(e){1==u&&(r&&r.removeClass("has-drag-over has-drag-before has-drag-after"),r=t(this)),1==v&&r&&(g(e),r.addClass("has-drag-over"))}))}(h,".outline-wrapper")}}));var n,o,s=0;function l(e){if(null==n){n=t('
      ');var i=t('
      '),a=t('
      '),s=t('
      '),p=t('
      '),c=t('
      '),h=t('
      '),f=t('
      '),u=t('
      Add Hot-Spot
      '),v=t('
      Remove Hot-Spot
      '),g=t('
      '),m=t('
      '),_=t(''),b=t('');n.divImage=m,n.image=_,n.content=b,n.dest=g,p.on("click",(function(){var t=o.next();t.length>0&&t.hasClass("dflip-page-item")&&l(t)})),c.on("click",(function(){var t=o.prev();t.length>0&&t.hasClass("dflip-page-item")&&l(t)})),h.on("click",(function(){n.hide()})),g.on("change",(function(){void 0!==r._hotspot&&(r._hotspot.dest=t(this).val(),r._hotspot.update())})),v.on("click",(function(){1==confirm("Delete hotspot?")&&(r._hotspot.dispose(!0),r.detach()),g.val("")})),u.on("click",(function(){o.find(".dflip-hotspot-input");var e=o.attr("hotspots");null==e&&(e=o.find(".dflip-hotspot-input").length);var i,a,s=(i=e,(a=t('')).val("[30,30,30,30,]"),a);e++,o.attr("hotspots",e),o.find(".dflip-page-options").append(s);var l=new d([40,40,20,20,""],n.divImage);l.activate(r),l.target=s})),m.append(_),f.append(u).append(g).append(v),a.append(f).append(m),s.append(c).append(p),i.append(s).append(a),n.append(h).append(i).appendTo(t("#dflip_pages_box"))}n.show(),n.dest.val("");var w=e.find(".dflip-page-thumb").attr("src");if(n.image.attr("src",w),null!=o&&null!=o.hotspots)for(var y=0;y'),i.append(a._el),a.update(),a._el.on("click",(function(){a.activate(r)}))};d.prototype.activate=function(t){t.attach(this),n.dest.val(this.dest)},d.prototype.deactivate=function(t){},d.prototype.dispose=function(t){this._el.off(),this._el.remove(),1==t&&void 0!==this.target&&this.target.remove()},d.prototype.updateSize=function(t){this.width=Math.round(1e4*t.width/this.ref.width())/100,this.height=Math.round(1e4*t.height/this.ref.height())/100},d.prototype.updatePosition=function(t){this.left=Math.round(1e4*t.left/this.ref.width())/100,this.top=Math.round(1e4*t.top/this.ref.height())/100,this.update()},d.prototype.update=function(){this._el.css({left:this.left+"%",top:this.top+"%",width:this.width+"%",height:this.height+"%"}),void 0!==this.target&&this.target.val("["+this.left+","+this.top+","+this.width+","+this.height+","+this.dest+"]")};var p=function(){var e=this;e.initialized=!1,e._hotspot=void 0,t.fn.draggable?e._el=t('
      ').draggable({containment:"parent",drag:function(t,i){e._hotspot.updatePosition(i.position)}}):e._el=void 0};p.prototype.attach=function(t){var e=this;void 0!==e._hotspot&&e._hotspot.deactivate(),e._hotspot=t,e.container=t._el.parent(),e.container.append(e._el),1!=e.initialized&&(e._el.resizable({handles:"ne, se, sw, nw",resize:function(t,i){e._hotspot.updateSize(i.size),e._hotspot.updatePosition(i.position)}}),e.initialized=!0),e._el.css({left:t._el[0].style.left,top:t._el[0].style.top,width:t._el[0].style.width,height:t._el[0].style.height,display:"block"})},p.prototype.detach=function(t){void 0!==this._hotspot&&this._hotspot.deactivate(),this._el.hide()};var r=new p}(jQuery);