Commit cf43d943 authored by Kevin Stover's avatar Kevin Stover

Merge branch 'issue#3772' into 'develop'

Changes DELETE and CANCEL divs to buttons

Closes #3772

See merge request ninja-forms/ninja-forms!3710
parents 0a3f151b 1ea9f3bf
Pipeline #582 passed with stage
in 1 minute and 39 seconds
......@@ -19,6 +19,7 @@ deploy-old.sh
tests/
vendor/
composer.lock
package-lock.json
*.sass-cache
*.scssc
!function(){var e,t,n;!function(i){function o(e,t){return y.call(e,t)}function s(e,t){var n,i,o,s,r,a,l,c,d,u,h,m=t&&t.split("/"),f=v.map,p=f&&f["*"]||{};if(e&&"."===e.charAt(0))if(t){for(e=e.split("/"),r=e.length-1,v.nodeIdCompat&&j.test(e[r])&&(e[r]=e[r].replace(j,"")),e=m.slice(0,m.length-1).concat(e),d=0;d<e.length;d+=1)if("."===(h=e[d]))e.splice(d,1),d-=1;else if(".."===h){if(1===d&&(".."===e[2]||".."===e[0]))break;d>0&&(e.splice(d-1,2),d-=2)}e=e.join("/")}else 0===e.indexOf("./")&&(e=e.substring(2));if((m||p)&&f){for(n=e.split("/"),d=n.length;d>0;d-=1){if(i=n.slice(0,d).join("/"),m)for(u=m.length;u>0;u-=1)if((o=f[m.slice(0,u).join("/")])&&(o=o[i])){s=o,a=d;break}if(s)break;!l&&p&&p[i]&&(l=p[i],c=d)}!s&&l&&(s=l,a=c),s&&(n.splice(0,a,s),e=n.join("/"))}return e}function r(e,t){return function(){var n=C.call(arguments,0);return"string"!=typeof n[0]&&1===n.length&&n.push(null),m.apply(i,n.concat([e,t]))}}function a(e){return function(t){return s(t,e)}}function l(e){return function(t){w[e]=t}}function c(e){if(o(g,e)){var t=g[e];delete g[e],b[e]=!0,h.apply(i,t)}if(!o(w,e)&&!o(b,e))throw new Error("No "+e);return w[e]}function d(e){var t,n=e?e.indexOf("!"):-1;return n>-1&&(t=e.substring(0,n),e=e.substring(n+1,e.length)),[t,e]}function u(e){return function(){return v&&v.config&&v.config[e]||{}}}var h,m,f,p,w={},g={},v={},b={},y=Object.prototype.hasOwnProperty,C=[].slice,j=/\.js$/;f=function(e,t){var n,i=d(e),o=i[0];return e=i[1],o&&(o=s(o,t),n=c(o)),o?e=n&&n.normalize?n.normalize(e,a(t)):s(e,t):(e=s(e,t),i=d(e),o=i[0],e=i[1],o&&(n=c(o))),{f:o?o+"!"+e:e,n:e,pr:o,p:n}},p={require:function(e){return r(e)},exports:function(e){var t=w[e];return void 0!==t?t:w[e]={}},module:function(e){return{id:e,uri:"",exports:w[e],config:u(e)}}},h=function(e,t,n,s){var a,d,u,h,m,v,y=[],C=typeof n;if(s=s||e,"undefined"===C||"function"===C){for(t=!t.length&&n.length?["require","exports","module"]:t,m=0;m<t.length;m+=1)if(h=f(t[m],s),"require"===(d=h.f))y[m]=p.require(e);else if("exports"===d)y[m]=p.exports(e),v=!0;else if("module"===d)a=y[m]=p.module(e);else if(o(w,d)||o(g,d)||o(b,d))y[m]=c(d);else{if(!h.p)throw new Error(e+" missing "+d);h.p.load(h.n,r(s,!0),l(d),{}),y[m]=w[d]}u=n?n.apply(w[e],y):void 0,e&&(a&&a.exports!==i&&a.exports!==w[e]?w[e]=a.exports:u===i&&v||(w[e]=u))}else e&&(w[e]=n)},e=t=m=function(e,t,n,o,s){if("string"==typeof e)return p[e]?p[e](t):c(f(e,t).f);if(!e.splice){if(v=e,v.deps&&m(v.deps,v.callback),!t)return;t.splice?(e=t,t=n,n=null):e=i}return t=t||function(){},"function"==typeof n&&(n=o,o=s),o?h(i,e,t,n):setTimeout(function(){h(i,e,t,n)},4),m},m.config=function(e){return m(e)},e._defined=w,n=function(e,t,n){if("string"!=typeof e)throw new Error("See almond README: incorrect module build, no module name");t.splice||(n=t,t=[]),o(w,e)||o(g,e)||(g[e]=[e,t,n])},n.amd={jQuery:!0}}(),n("../../assets/js/lib/almond",function(){}),n("models/formModel",[],function(){return Backbone.Model.extend({defaults:{objectType:"form",id:0,title:"unknown",created_at:"unknown"},url:function(){return ajaxurl+"?action=nf_forms&form_id="+this.get("id")},initialize:function(){this.set("id",Number(this.get("id"))),this.get("id")&&this.initShortcode(this.get("id")),this.get("title")&&this.set("title",this.get("title").replace(/<\/?[^>]+(>|$)/g,""))},initShortcode:function(e){var t="[ninja_form id="+e+"]";this.set("shortcode",t)},destroy:function(){var e=this;jQuery.ajax({type:"POST",url:ajaxurl+"?action=nf_forms&method_override=delete&form_id="+this.get("id"),success:function(t){var t=JSON.parse(t);e.collection.remove(e)}})}})}),n("models/formCollection",["models/formModel"],function(e){return Backbone.Collection.extend({model:e,comparator:"title",tmpNum:1,url:function(){return ajaxurl+"?action=nf_forms"},initialize:function(){this.newIDs=[],this.baseUrl=window.location.href.split("?")[0],this.listenTo(i.channel("dashboard"),"forms:delete",this.modalConfirm),this.listenTo(i.channel("dashboard"),"forms:duplicate",this.duplicate),this.modal=new jBox("Modal",{width:400,addClass:"dashboard-modal",overlay:!0,closeOnClick:"body"})},parse:function(e,t){return e.data},modalConfirm:function(e){var t,n,i,o,s,r,a,l=e.model.get("id"),c=e.model.get("title");n=document.createElement("div"),n.style.paddingRight="20px",n.style.paddingLeft="20px",n.style.paddingBottom="20px",i=document.createElement("p"),o=document.createElement("em"),s=document.createElement("div"),r=document.createElement("div"),a=document.createElement("div"),n.classList.add("message"),o.innerHTML=c,i.innerHTML+=nfi18n.deleteWarningA+" (<strong>"+c+"</strong>). "+nfi18n.deleteWarningB,i.appendChild(document.createElement("br")),i.appendChild(document.createElement("br"));var d=document.createElement("a");d.href=this.baseUrl+"?page=nf-import-export&exportFormId="+l,d.innerHTML='<i class="fa fa-download" style="padding:5px;"></i>'+nfi18n.deleteXForm,d.target="_blank",i.appendChild(d),i.appendChild(document.createElement("br"));var u=document.createElement("a");u.href=this.baseUrl+"?page=nf-processing&action=download_all_subs&form_id="+l+"&redirect="+encodeURIComponent(this.baseUrl.replace("admin.php","edit.php")+"?post_status=all&post_type=nf_sub&form_id="+l),u.target="_blank",u.innerHTML='<i class="fa fa-download" style="padding:5px;"></i>'+nfi18n.deleteXSubs,i.appendChild(u),i.appendChild(document.createElement("br")),n.appendChild(i);var h=document.createElement("label");h.for="confirmDeleteFormInput",h.innerHTML=nfi18n.deleteConfirmA+' <span style="color:red;">DELETE</span> '+nfi18n.deleteConfirmB;var m=document.createElement("input");m.type="text",m.id="confirmDeleteFormInput",m.style.marginTop="10px",m.style.width="100%",m.style.height="2.5em",m.style.fontSize="1em",n.appendChild(h),n.appendChild(document.createElement("br")),n.appendChild(m),n.appendChild(document.createElement("br")),n.appendChild(document.createElement("br")),r.innerHTML=nfi18n.delete,r.classList.add("confirm","nf-button","primary","pull-right"),a.innerHTML=nfi18n.cancel,a.classList.add("cancel","nf-button","secondary"),s.appendChild(a),s.appendChild(r),s.classList.add("buttons"),n.appendChild(s),t=document.createElement("div"),t.appendChild(n),this.modal.setContent(t.innerHTML),this.modal.setTitle(nfi18n.deleteTitle),this.modal.open();var f=this;this.modal.container[0].getElementsByClassName("cancel")[0].addEventListener("click",function(){f.modalClose()}),this.modal.container[0].getElementsByClassName("confirm")[0].addEventListener("click",function(){"DELETE"===document.getElementById("confirmDeleteFormInput").value?f.confirmDelete(e):f.modalClose()})},modalClose:function(){this.modal.close()},confirmDelete:function(e){jQuery(e.el).removeClass("show-actions"),jQuery(e.el).addClass("deleting"),jQuery(e.el).animate({opacity:0,"line-height":0,display:"none"},500),console.log(e),e.model.destroy(),this.modalClose()},duplicate:function(e){var t='<div class="message">Duplicating <em>'+e.model.get("title")+'</em>...<div class="nf-loading-spinner"></div></div>';this.modal.setContent(t),this.modal.setTitle("Please Wait"),this.modal.open();var n=this;jQuery.ajax({type:"POST",url:ajaxurl+"?action=nf_forms&clone_id="+e.model.get("id"),success:function(t){var t=JSON.parse(t),i=t.data.new_form_id,o=e.model.clone();o.set({id:i,title:o.get("title")+" - copy",created_at:new Date}),o.initShortcode(i),e.model.collection.add(o),n.modalClose()}})}})}),n("controllers/formsController",["models/formModel","models/formCollection"],function(e,t){return Marionette.Object.extend({initialize:function(){this.forms=new t,i.channel("dashboard").reply("get:forms",this.getForms,this),this.forms.fetch({success:function(e){i.channel("dashboard").trigger("fetch:forms",e)}})},getForms:function(){return this.forms}})}),n("models/oauthModel",[],function(){return Backbone.Model.extend({defaults:{connected:null,connect_url:""},url:function(){return ajaxurl+"?action=nf_oauth"},initialize:function(){},parse:function(e,t){return e.data}})}),n("controllers/oauthController",["models/oauthModel"],function(e){return Marionette.Object.extend({initialize:function(){this.oauth=new e,i.channel("dashboard").reply("get:oauth",this.getOAuth,this),i.channel("dashboard").reply("disconnect:oauth",this.disconnect,this),i.channel("dashboard").reply("oauth:learn-more",this.learnMoreModal,this),this.initOAuth()},getOAuth:function(){return this.oauth},initOAuth:function(){this.oauth.fetch({success:function(e){i.channel("dashboard").trigger("fetch:oauth")}})},disconnect:function(){var e=this;new jBox("Confirm",{width:750,content:nfi18n.oauthDisconnectContent,confirmButton:nfi18n.oauthDisconnectConfirm,cancelButton:nfi18n.oauthDisconnectCancel,closeOnConfirm:!0,confirm:function(){jQuery.ajax({type:"POST",url:ajaxurl+"?action=nf_oauth_disconnect",success:function(t){console.log(t),e.initOAuth()}})}}).open()},learnMoreModal:function(){new jBox("Modal",{width:500,content:nfi18n.oauthLearnMoreContent}).open()}})}),n("models/serviceModel",[],function(){return Backbone.Model.extend({defaults:{objectType:"service",name:"",slug:"",installPath:"",description:"",enabled:null,infoLink:null,serviceLink:null,is_installing:!1,classes:""},url:function(){return ajaxurl+"?action=nf_service_"+this.get("slug")},initialize:function(){this.get("slug")==serviceSuccess&&this.get("successMessage")&&new jBox("Modal",{width:300,addClass:"dashboard-modal",overlay:!0,closeOnClick:!0,content:this.get("successMessage"),title:this.get("successMessageTitle"),closeButton:"box"}).open();var e=this;i.channel("dashboard").reply("install:service:"+this.get("slug"),function(){if(e.get("serviceLink")&&e.get("serviceLink").href){var t=e.get("serviceLink").href;new jBox("Modal",{width:300,addClass:"dashboard-modal",overlay:!0,closeOnClick:"body",content:nfi18n.serviceRedirect}).open();var n=i.channel("dashboard").request("get:oauth");if(n.get("connected"))window.location=t;else{if(e.get("connect_url"))return window.location=e.get("connect_url")+"&redirect="+t;window.location=n.get("connect_url")+"&redirect="+t}}})},save:function(){var e=this;jQuery.ajax({type:"POST",url:this.url(),data:this.toJSON()}).done(function(t){var n=JSON.parse(t);void 0!==n.error&&(alert(nfi18n.serviceUpdateError+" "+n.error),e.set("enabled",!e.get("enabled"))),i.channel("dashboard").trigger("save:service-"+e.get("slug"))})}})}),n("models/serviceCollection",["models/serviceModel"],function(e){return Backbone.Collection.extend({model:e,comparator:"name",url:function(){return ajaxurl+"?action=nf_services"},initialize:function(){},parse:function(e,t){return e.data}})}),n("controllers/servicesController",["models/serviceCollection"],function(e){return Marionette.Object.extend({initialize:function(){this.services=new e,i.channel("dashboard").reply("install:service",this.installService,this),i.channel("dashboard").reply("get:services",this.getServices,this),this.fetchServices()},getServices:function(){return this.services},fetchServices:function(e){this.services.fetch({success:function(t){e&&e(t),i.channel("dashboard").trigger("fetch:services")}})},installService:function(e){var t=this;if(!(e instanceof Backbone.Model))var e=this.services.find(function(t){return e==t.get("slug")});e.set("is_installing",!0);var n=e.get("slug"),o=e.get("installPath");jQuery.post(ajaxurl,{action:"nf_services_install",plugin:n,install_path:o},function(e){t.fetchServices(function(){i.channel("dashboard").request("install:service:"+n)})})}})}),n("views/widgets/forms/formsFilter",[],function(){return Marionette.View.extend({template:"#tmpl-nf-widget-forms-filter",ui:{input:"input"},events:{"keyup @ui.input":"updateFilter"},initialize:function(){this.listenTo(i.channel("widget-forms"),"change:content",this.clearFilter)},updateFilter:function(){var e=this.getUI("input").val();i.channel("widget-forms").trigger("update:filter",e)},clearFilter:function(){this.getUI("input").val("")},updatePlaceholder:function(e){this.getUI("input").attr("placeholder",e)}})}),n("views/widgets/forms/formsTableRow",[],function(){return Marionette.View.extend({template:"#tmpl-nf-widget-forms-table-row",tagName:"tr",replaceElement:!0,ui:{delete:".delete",duplicate:".duplicate",edit:".nf-item-edit"},events:{"click @ui.delete":function(){i.channel("dashboard").trigger("forms:delete",this)},"click @ui.duplicate":function(){i.channel("dashboard").trigger("forms:duplicate",this)},"click @ui.edit":function(e){this.$el.toggleClass("show-actions").siblings().removeClass("show-actions")}},templateContext:function(){var e=this.model;return{created_at:moment(e.get("created_at")).format("MM/DD/YY h:mm A")}}})}),n("views/widgets/forms/formsTableEmpty",[],function(){return Marionette.View.extend({template:"#tmpl-nf-widget-forms-table-empty",tagName:"tr"})}),n("views/widgets/forms/formsTableBody",["views/widgets/forms/formsTableRow","views/widgets/forms/formsTableEmpty"],function(e,t){return Marionette.CollectionView.extend({childView:e,emptyView:t,className:"forms-collection",tagName:"tbody",initialize:function(){this.listenTo(i.channel("widget-forms"),"update:filter",this.updateFilter)},updateFilter:function(e){this.setFilter(function(t,n,i){return 0<=t.get("title").toLowerCase().indexOf(e.toLowerCase())})}})}),n("views/widgets/forms/formsTableLoading",[],function(){return Marionette.View.extend({template:"#tmpl-nf-widget-forms-table-loading",tagName:"tr"})}),n("views/widgets/forms/formsTable",["views/widgets/forms/formsTableBody","views/widgets/forms/formsTableLoading","models/formCollection"],function(e,t,n){return Marionette.View.extend({template:"#tmpl-nf-widget-forms-table",className:"nf-table-display",tagName:"table",initialize:function(){var t=this;this.listenTo(i.channel("dashboard"),"fetch:forms",function(n){t.showChildView("body",new e({collection:n}))})},regions:{body:{el:"tbody",replaceElement:!0}},ui:{sortable:".sortable",body:"tbody",action2:".action2",more:".more",less:".less"},onRender:function(){this.getUI("less").hide();var n=i.channel("dashboard").request("get:forms");void 0===n?this.showChildView("body",new t):this.showChildView("body",new e({collection:n})),this.maybeHideMoreButton()},events:{"click @ui.sortable":"sortFormsTable","click @ui.more":"showMore","click @ui.less":"showLess"},sortFormsTable:function(e){this.getUI("sortable").removeClass("sorted-asc"),this.getUI("sortable").removeClass("sorted-desc");var t=jQuery(e.target).data("sort"),n=jQuery(e.target).data("reverse")||0;n?(jQuery(e.target).addClass("sorted-desc"),jQuery(e.target).removeClass("sorted-asc")):(jQuery(e.target).addClass("sorted-asc"),jQuery(e.target).removeClass("sorted-desc"));var i=this.getChildView("body").collection;i.comparator=function(e,i){return name1=e.get(t).toLowerCase(),name2=i.get(t).toLowerCase(),name1<name2?ret=-1:name1>name2?ret=1:ret=0,n&&(ret=-ret),ret},i.sort(),n?(i.models.reverse(),jQuery(e.target).data("reverse",0)):jQuery(e.target).data("reverse",1)},showMore:function(){this.getUI("more").hide(),this.getUI("less").show(),this.getUI("body").addClass("more")},showLess:function(){this.getUI("less").hide(),this.getUI("more").show(),this.getUI("body").removeClass("more")},maybeHideMoreButton:function(){void 0!==this.collection&&10<this.collection.length||this.getUI("action2").hide()}})}),n("models/formTemplateModel",[],function(){return Backbone.Model.extend({defaults:{objectType:"template",id:"none",title:"unknown",type:""},initialize:function(){this.set("desc",this.get("template-desc")),this.set("modal-content",this.get("modal-content")),this.set("modal-title",this.get("modal-title"))}})}),n("models/formTemplateCollection",["models/formTemplateModel"],function(e){return Backbone.Collection.extend({model:e,tmpNum:1,url:function(){return ajaxurl+"?action=nf_new_form_templates"},parse:function(e,t){return e.data},initialize:function(){this.fetch({success:function(e){},error:function(e){}})}})}),n("views/widgets/forms/newFormTemplate",[],function(){return Marionette.View.extend({template:"#tmpl-nf-widget-forms-template",events:{click:"maybeOpenModal"},maybeOpenModal:function(e){if("ad"!=this.model.get("type"))return!0;e.preventDefault(),new jBox("Modal",{width:450,title:this.model.get("modal-title"),content:this.model.get("modal-content"),closeButton:"box",blockScroll:!0}).open()}})}),n("views/widgets/forms/newFormGrid",["models/formTemplateCollection","views/widgets/forms/newFormTemplate"],function(e,t){return Marionette.CollectionView.extend({tagName:"div",className:"template-list",collection:new e,childView:t,initialize:function(){this.listenTo(i.channel("widget-forms"),"update:filter",this.updateFilter)},updateFilter:function(e){this.setFilter(function(t,n,i){return 0<=t.get("title").toLowerCase().indexOf(e.toLowerCase())})}})}),n("views/widgets/forms/forms",["views/widgets/forms/formsFilter","views/widgets/forms/formsTable","views/widgets/forms/newFormGrid"],function(e,t,n){return Marionette.View.extend({template:"#tmpl-nf-widget-forms",regions:{filter:".filter",content:".content"},ui:{add:".add",cancel:".cancel"},initialize:function(){i.channel("widget-forms").reply("show:newFormsGrid",this.showNewFormGrid,this),i.channel("widget-forms").reply("show:formsTable",this.showFormsTable,this)},onRender:function(){this.getUI("cancel").hide(),this.showChildView("filter",new e),"#new-form"==window.location.hash?(this.getUI("add").hide(),this.getUI("cancel").show(),this.showChildView("content",new n)):this.showChildView("content",new t)},events:{"click @ui.add":"showNewFormGrid","click @ui.cancel":"showFormsTable"},showNewFormGrid:function(){window.location.hash="new-form",this.showChildView("content",new n),i.channel("widget-forms").trigger("change:content"),this.getUI("add").hide(),this.getUI("cancel").show(),this.getChildView("filter").updatePlaceholder("Search Templates")},showFormsTable:function(){console.log(this),window.location.hash="forms",this.showChildView("content",new t),i.channel("widget-forms").trigger("change:content"),this.getUI("cancel").hide(),this.getUI("add").show(),this.getChildView("filter").updatePlaceholder("Search Forms")}})}),n("views/sections/widgets.js",["views/widgets/forms/forms"],function(e){return Marionette.View.extend({template:"#tmpl-nf-widgets",regions:{forms:".widget-forms"},onRender:function(){this.showChildView("forms",new e)}})}),n("views/services/service",[],function(){return Marionette.View.extend({template:"#tmpl-nf-service",className:function(){return"nf-extend nf-box "+this.model.get("classes")},ui:{install:".js--install",learnMore:".js--learn-more",enabled:".nf-toggle.setting",toggleEnable:".nf-toggle + label"},events:{"click @ui.install":function(){i.channel("dashboard").request("install:service",this.model)},"click @ui.learnMore":function(){this.showLearnMore()},"click @ui.toggleEnable":function(){if(null==this.model.get("enabled")&&this.model.get("link"))return window.location=this.model.get("link"),this.render();this.model.set("enabled",!this.model.get("enabled")),this.model.save("enabled"),this.render()}},initialize:function(e){this.updateOAuth(),this.listenTo(this.model,"change",this.render),i.channel("dashboard").reply("more:service:"+this.model.get("slug"),this.showLearnMore,this),this.listenTo(i.channel("dashboard"),"fetch:oauth",this.updateOAuth),this.listenTo(i.channel("dashboard"),"save:service-"+this.model.get("slug"),this.render)},showLearnMore:function(){var e=new jBox("Modal",{width:750,title:this.model.get("learnMoreTitle")||this.model.get("name"),content:this.model.get("learnMore"),closeButton:"box",blockScroll:!0});e.open(),i.channel("dashboard").reply("service:"+this.model.get("slug")+":modal",function(){return e})},updateOAuth:function(){var e=i.channel("dashboard").request("get:oauth");this.connected=e.get("connected"),this.render()},templateContext:function(){return{is_connected:this.connected}}})}),n("views/services/services",["views/services/service","models/serviceCollection"],function(e,t){return Marionette.CollectionView.extend({collection:new t,className:"wrap apps-container",childView:e,initialize:function(){this.updateCollection(),this.listenTo(i.channel("dashboard"),"fetch:services",this.updateCollection)},updateCollection:function(){this.collection=i.channel("dashboard").request("get:services"),this.render()}})}),n("views/sections/services.js",["views/services/services"],function(e){return Marionette.View.extend({template:"#tmpl-nf-services",regions:{services:".services"},onRender:function(){this.showChildView("services",new e)}})}),n("views/sections/apps.js",[],function(){return Marionette.View.extend({template:"#tmpl-nf-apps"})}),n("views/sections/memberships.js",[],function(){return Marionette.View.extend({template:"#tmpl-nf-memberships"})}),n("views/oauth.js",["models/oauthModel"],function(e){return Marionette.View.extend({model:new e,template:"#tmpl-nf-notices-oauth",className:"nf-notices--oauth",ui:{disconnect:".js--disconnect"},initialize:function(e){this.listenTo(i.channel("dashboard"),"fetch:oauth",this.updateModel)},updateModel:function(){this.model=i.channel("dashboard").request("get:oauth"),this.render()},events:{"click @ui.disconnect":function(){i.channel("dashboard").request("disconnect:oauth")}}})}),n("models/promotionModel",[],function(){return Backbone.Model.extend({defaults:{id:"",content:""},initialize:function(){}})}),n("views/promotion.js",["models/promotionModel"],function(e){return Marionette.View.extend({model:null,template:"#tmpl-nf-promotion",className:"nf-promotion",initialize:function(){var t=nfPromotions[Math.floor(Math.random()*nfPromotions.length)];this.model=new e(t)}})}),n("views/dashboardView",["views/sections/widgets.js","views/sections/services.js","views/sections/apps.js","views/sections/memberships.js","views/oauth.js","views/promotion.js"],function(e,t,n,o,s,r){return Marionette.View.extend({template:"#tmpl-nf-dashboard",currentView:"widgets",regions:{notices:".notices",promotions:".promotions",content:".content"},events:{"click .widgets a":function(t){this.showChildView("content",new e),jQuery("."+this.currentView).find("a").removeClass("active"),t.target.classList.add("active"),this.currentView="widgets"},"click .services a":function(e){this.showChildView("content",new t),jQuery("."+this.currentView).find("a").removeClass("active"),e.target.classList.add("active"),this.currentView="services"},"click .apps a":function(e){this.showChildView("content",new n),jQuery("."+this.currentView).find("a").removeClass("active"),e.target.classList.add("active"),this.currentView="apps"},"click .memberships a":function(e){this.showChildView("content",new o),jQuery("."+this.currentView).find("a").removeClass("active"),e.target.classList.add("active"),this.currentView="memberships"}},initialize:function(){switch(window.location.hash){case"#apps":this.currentView="apps";break;case"#services":this.currentView="services";break;case"#memberships":this.currentView="memberships";break;case"#widgets":default:this.currentView="widgets"}i.channel("dashboard").reply("show:widgets",function(){this.showChildView("content",new e),jQuery("nav.sections a.active").removeClass("active"),jQuery("nav.sections .widgets a").addClass("active"),this.currentView="widgets"},this),i.channel("dashboard").reply("show:services",function(){this.showChildView("content",new t),jQuery("nav.sections a.active").removeClass("active"),jQuery("nav.sections .services a").addClass("active"),this.currentView="services"},this),i.channel("dashboard").reply("show:apps",function(){this.showChildView("content",new n),jQuery("nav.sections a.active").removeClass("active"),jQuery("nav.sections .apps a").addClass("active"),this.currentView="apps"},this)},onRender:function(){switch(useServices&&this.showChildView("notices",new s),useServices&&this.showChildView("promotions",new r),window.location.hash){case"#apps":var i=new n;break;case"#memberships":var i=new o;break;case"#services":var i=new t;break;case"#widgets":default:var i=new e}if(this.showChildView("content",i),"1"==nfAdmin.showOptin){var a=new jBox("Modal",{closeOnEsc:!1,closeOnClick:!1,width:400}),l=document.createElement("div");l.id="optin-modal-title";var c=document.createElement("h2");c.innerHTML="Help make Ninja Forms better!",l.appendChild(c);var d=document.createElement("div");d.classList.add("message"),d.style.padding="0px 20px 20px 20px",d.innerHTML=nfi18n.optinContent;var u=document.createElement("p");u.style.paddingBottom="10px";var h=document.createElement("input");h.id="optin-send-email",h.setAttribute("type","checkbox"),h.style.margin="7px";var m=document.createElement("label");m.setAttribute("for","optin-send-email"),m.innerHTML=nfi18n.optinYesplease,u.appendChild(h),u.appendChild(m),d.appendChild(u),u=document.createElement("p"),u.id="optin-block",u.style.padding="0px 5px 20px 5px",u.style.display="none";var f=document.createElement("input");f.id="optin-email-address",f.setAttribute("type","text"),f.setAttribute("value",nfAdmin.currentUserEmail),f.style.width="100%",f.style.fontSize="16px",u.appendChild(f),d.appendChild(u);var p=document.createElement("span");p.id="optin-spinner",p.classList.add("spinner"),p.style.display="none",d.appendChild(p);var w=document.createElement("div");w.id="optin-buttons",w.classList.add("buttons");var g=document.createElement("div");g.id="optout",g.classList.add("nf-button","secondary"),g.innerHTML=nfi18n.optinSecondary,w.appendChild(g);var v=document.createElement("div");v.id="optin",v.classList.add("nf-button","primary","pull-right"),v.innerHTML=nfi18n.optinPrimary,w.appendChild(v),d.appendChild(w);var b=document.createElement("h2");b.innerHTML=nfi18n.optinAwesome;var y=document.createElement("div");y.id="optin-thankyou",y.classList.add("message"),y.style.padding="20px",y.innerHTML=nfi18n.optinThanks,a.setContent(document.createElement("div").appendChild(d).innerHTML),a.setTitle(document.createElement("div").appendChild(l).innerHTML),a.open(),jQuery("#optin-send-email").click(function(e){jQuery(this).is(":checked")?jQuery("#optin-block").show():jQuery("#optin-block").hide()}),jQuery("#optin").click(function(e){var t;jQuery("#optin-send-email").attr("checked")?(t=1,userEmail=jQuery("#optin-email-address").val()):(t=0,userEmail=""),jQuery("#optin").unbind("click"),jQuery("#optout").unbind("click");var n=jQuery("#optin").width();jQuery("#optin").html('<span class="dashicons dashicons-update dashicons-update-spin"></span>'),jQuery("#optin").width(n),jQuery.post(ajaxurl,{action:"nf_optin",ninja_forms_opt_in:1,send_email:t,user_email:userEmail},function(e){a.setTitle(document.createElement("div").appendChild(b).innerHTML),a.setContent(document.createElement("div").appendChild(y).innerHTML),setTimeout(function(){a.close()},2e3)})}),jQuery("#optout").click(function(e){jQuery("#optin").unbind("click"),jQuery("#optout").unbind("click");var t=jQuery("#optout").width();jQuery("#optout").html('<span class="dashicons dashicons-update dashicons-update-spin"></span>'),jQuery("#optout").width(t),jQuery.post(ajaxurl,{action:"nf_optin",ninja_forms_opt_in:0},function(e){a.close()})})}else if("1"==nfAdmin.doingCleanup)var C=this,j={width:450,closeOnClick:!1,closeOnEsc:!1,content:nfi18n.cleanupContent,useProgressBar:!0,loadingText:nfi18n.cleanupLoading,btnSecondary:{text:nfi18n.cleanupSecondary,callback:function(){x.toggleModal(!1)}},btnPrimary:{text:nfi18n.cleanupPrimary,callback:function(){jQuery(window).bind("beforeunload",function(){return"Are you sure? Leaving before the process completes could cause damage to your data."}),x.maybeShowActions(!1),x.maybeShowProgress(!0),C.cleanupProcess(C,-1,x)}}},x=new NinjaModal(j);if(void 0!==nfAdmin.formTelemetry&&1==nfAdmin.formTelemetry){var M={action:"nf_form_telemetry",security:nfAdmin.ajaxNonce};jQuery.post(ajaxurl,M)}},templateContext:function(){var e=this;return{renderNav:function(){var t=document.createElement("div");return _.each(nfDashItems,function(n){var i=document.createElement("li"),o=document.createElement("a");o.href="#"+n.slug,e.currentView==n.slug&&o.classList.add("active"),o.innerHTML=n.niceName,i.classList.add(n.slug),i.appendChild(o),t.appendChild(i)}),t.innerHTML}}},cleanupProcess:function(e,t,n){var i={action:"nf_batch_process",batch_type:"data_cleanup",security:nfAdmin.batchNonce};jQuery.post(ajaxurl,i,function(i){if(i=JSON.parse(i),i.batch_complete)return n.setProgress(100),jQuery(window).unbind("beforeunload"),n.toggleModal(!1),!1;-1==t&&(t=void 0!==i.step_total?i.step_total:i.step_remaining);var o=t-i.step_remaining,s=Math.round(o/t*100);n.incrementProgress(s),e.cleanupProcess(e,t,n)})}})});var i=Backbone.Radio;useServices||(nfDashItems=nfDashItems.filter(function(e){return"services"!==e.slug})),jQuery(document).ready(function(e){t(["controllers/formsController","controllers/oauthController","controllers/servicesController","views/dashboardView"],function(t,n,i,o){(new(Marionette.Application.extend({region:"#ninja-forms-dashboard",controllers:{},initialize:function(e){var t=this;Marionette.Renderer.render=function(e,n){var e=t.template(e);return e(n)}},onStart:function(){this.showView(new o),this.controllers.forms=new t,useServices&&(this.controllers.oauth=new n),useServices&&(this.controllers.services=new i)},template:function(t){return _.template(e(t).html(),{evaluate:/<#([\s\S]+?)#>/g,interpolate:/\{\{\{([\s\S]+?)\}\}\}/g,escape:/\{\{([^\}]+?)\}\}(?!\})/g,variable:"data"})}}))).start()})}),jQuery('a[href="admin.php?page=ninja-forms#new-form"]').on("click",function(e){e.preventDefault(),window.location.hash="new-form",i.channel("dashboard").request("show:widgets"),i.channel("widget-forms").request("show:newFormsGrid")}),jQuery('a[href="admin.php?page=ninja-forms#apps"]').on("click",function(e){e.preventDefault(),window.location.hash="apps",i.channel("dashboard").request("show:apps")}),jQuery('a[href="admin.php?page=ninja-forms"]').on("click",function(e){e.preventDefault(),window.location.hash="forms",i.channel("dashboard").request("show:widgets"),i.channel("widget-forms").request("show:formsTable")}),jQuery(window).on("hashchange",function(){var e=window.location.hash.substr(1);i.channel("dashboard").request("show:"+e)}),n("main",function(){})}();
!function(){var e,t,n;!function(i){function o(e,t){return y.call(e,t)}function s(e,t){var n,i,o,s,r,a,l,c,d,u,h,m=t&&t.split("/"),f=v.map,p=f&&f["*"]||{};if(e&&"."===e.charAt(0))if(t){for(e=e.split("/"),r=e.length-1,v.nodeIdCompat&&j.test(e[r])&&(e[r]=e[r].replace(j,"")),e=m.slice(0,m.length-1).concat(e),d=0;d<e.length;d+=1)if("."===(h=e[d]))e.splice(d,1),d-=1;else if(".."===h){if(1===d&&(".."===e[2]||".."===e[0]))break;d>0&&(e.splice(d-1,2),d-=2)}e=e.join("/")}else 0===e.indexOf("./")&&(e=e.substring(2));if((m||p)&&f){for(n=e.split("/"),d=n.length;d>0;d-=1){if(i=n.slice(0,d).join("/"),m)for(u=m.length;u>0;u-=1)if((o=f[m.slice(0,u).join("/")])&&(o=o[i])){s=o,a=d;break}if(s)break;!l&&p&&p[i]&&(l=p[i],c=d)}!s&&l&&(s=l,a=c),s&&(n.splice(0,a,s),e=n.join("/"))}return e}function r(e,t){return function(){var n=C.call(arguments,0);return"string"!=typeof n[0]&&1===n.length&&n.push(null),m.apply(i,n.concat([e,t]))}}function a(e){return function(t){return s(t,e)}}function l(e){return function(t){w[e]=t}}function c(e){if(o(g,e)){var t=g[e];delete g[e],b[e]=!0,h.apply(i,t)}if(!o(w,e)&&!o(b,e))throw new Error("No "+e);return w[e]}function d(e){var t,n=e?e.indexOf("!"):-1;return n>-1&&(t=e.substring(0,n),e=e.substring(n+1,e.length)),[t,e]}function u(e){return function(){return v&&v.config&&v.config[e]||{}}}var h,m,f,p,w={},g={},v={},b={},y=Object.prototype.hasOwnProperty,C=[].slice,j=/\.js$/;f=function(e,t){var n,i=d(e),o=i[0];return e=i[1],o&&(o=s(o,t),n=c(o)),o?e=n&&n.normalize?n.normalize(e,a(t)):s(e,t):(e=s(e,t),i=d(e),o=i[0],e=i[1],o&&(n=c(o))),{f:o?o+"!"+e:e,n:e,pr:o,p:n}},p={require:function(e){return r(e)},exports:function(e){var t=w[e];return void 0!==t?t:w[e]={}},module:function(e){return{id:e,uri:"",exports:w[e],config:u(e)}}},h=function(e,t,n,s){var a,d,u,h,m,v,y=[],C=typeof n;if(s=s||e,"undefined"===C||"function"===C){for(t=!t.length&&n.length?["require","exports","module"]:t,m=0;m<t.length;m+=1)if(h=f(t[m],s),"require"===(d=h.f))y[m]=p.require(e);else if("exports"===d)y[m]=p.exports(e),v=!0;else if("module"===d)a=y[m]=p.module(e);else if(o(w,d)||o(g,d)||o(b,d))y[m]=c(d);else{if(!h.p)throw new Error(e+" missing "+d);h.p.load(h.n,r(s,!0),l(d),{}),y[m]=w[d]}u=n?n.apply(w[e],y):void 0,e&&(a&&a.exports!==i&&a.exports!==w[e]?w[e]=a.exports:u===i&&v||(w[e]=u))}else e&&(w[e]=n)},e=t=m=function(e,t,n,o,s){if("string"==typeof e)return p[e]?p[e](t):c(f(e,t).f);if(!e.splice){if(v=e,v.deps&&m(v.deps,v.callback),!t)return;t.splice?(e=t,t=n,n=null):e=i}return t=t||function(){},"function"==typeof n&&(n=o,o=s),o?h(i,e,t,n):setTimeout(function(){h(i,e,t,n)},4),m},m.config=function(e){return m(e)},e._defined=w,n=function(e,t,n){if("string"!=typeof e)throw new Error("See almond README: incorrect module build, no module name");t.splice||(n=t,t=[]),o(w,e)||o(g,e)||(g[e]=[e,t,n])},n.amd={jQuery:!0}}(),n("../../assets/js/lib/almond",function(){}),n("models/formModel",[],function(){return Backbone.Model.extend({defaults:{objectType:"form",id:0,title:"unknown",created_at:"unknown"},url:function(){return ajaxurl+"?action=nf_forms&form_id="+this.get("id")},initialize:function(){this.set("id",Number(this.get("id"))),this.get("id")&&this.initShortcode(this.get("id")),this.get("title")&&this.set("title",this.get("title").replace(/<\/?[^>]+(>|$)/g,""))},initShortcode:function(e){var t="[ninja_form id="+e+"]";this.set("shortcode",t)},destroy:function(){var e=this;jQuery.ajax({type:"POST",url:ajaxurl+"?action=nf_forms&method_override=delete&form_id="+this.get("id"),success:function(t){var t=JSON.parse(t);e.collection.remove(e)}})}})}),n("models/formCollection",["models/formModel"],function(e){return Backbone.Collection.extend({model:e,comparator:"title",tmpNum:1,url:function(){return ajaxurl+"?action=nf_forms"},initialize:function(){this.newIDs=[],this.baseUrl=window.location.href.split("?")[0],this.listenTo(i.channel("dashboard"),"forms:delete",this.modalConfirm),this.listenTo(i.channel("dashboard"),"forms:duplicate",this.duplicate),this.modal=new jBox("Modal",{width:400,addClass:"dashboard-modal",overlay:!0,closeOnClick:"body"})},parse:function(e,t){return e.data},modalConfirm:function(e){var t,n,i,o,s,r,a,l=e.model.get("id"),c=e.model.get("title");n=document.createElement("div"),n.style.paddingRight="20px",n.style.paddingLeft="20px",n.style.paddingBottom="20px",i=document.createElement("p"),o=document.createElement("em"),s=document.createElement("div"),r=document.createElement("button"),a=document.createElement("div"),n.classList.add("message"),o.innerHTML=c,i.innerHTML+=nfi18n.deleteWarningA+" (<strong>"+c+"</strong>). "+nfi18n.deleteWarningB,i.appendChild(document.createElement("br")),i.appendChild(document.createElement("br"));var d=document.createElement("a");d.href=this.baseUrl+"?page=nf-import-export&exportFormId="+l,d.innerHTML='<i class="fa fa-download" style="padding:5px;"></i>'+nfi18n.deleteXForm,d.target="_blank",i.appendChild(d),i.appendChild(document.createElement("br"));var u=document.createElement("a");u.href=this.baseUrl+"?page=nf-processing&action=download_all_subs&form_id="+l+"&redirect="+encodeURIComponent(this.baseUrl.replace("admin.php","edit.php")+"?post_status=all&post_type=nf_sub&form_id="+l),u.target="_blank",u.innerHTML='<i class="fa fa-download" style="padding:5px;"></i>'+nfi18n.deleteXSubs,i.appendChild(u),i.appendChild(document.createElement("br")),n.appendChild(i);var h=document.createElement("label");h.for="confirmDeleteFormInput",h.innerHTML=nfi18n.deleteConfirmA+' <span style="color:red;">DELETE</span> '+nfi18n.deleteConfirmB;var m=document.createElement("input");m.type="text",m.id="confirmDeleteFormInput",m.style.marginTop="10px",m.style.width="100%",m.style.height="2.5em",m.style.fontSize="1em",n.appendChild(h),n.appendChild(document.createElement("br")),n.appendChild(m),n.appendChild(document.createElement("br")),n.appendChild(document.createElement("br")),r.innerHTML=nfi18n.delete,r.classList.add("confirm","nf-button","primary","pull-right"),a.innerHTML=nfi18n.cancel,a.classList.add("cancel","nf-button","secondary"),s.appendChild(a),s.appendChild(r),s.classList.add("buttons"),n.appendChild(s),t=document.createElement("div"),t.appendChild(n),this.modal.setContent(t.innerHTML),this.modal.setTitle(nfi18n.deleteTitle),this.modal.open();var f=this;this.modal.container[0].getElementsByClassName("cancel")[0].addEventListener("click",function(){f.modalClose()}),this.modal.container[0].getElementsByClassName("confirm")[0].addEventListener("click",function(t){t.preventDefault(),"DELETE"===document.getElementById("confirmDeleteFormInput").value?f.confirmDelete(e):f.modalClose()})},modalClose:function(){this.modal.close()},confirmDelete:function(e){jQuery(e.el).removeClass("show-actions"),jQuery(e.el).addClass("deleting"),jQuery(e.el).animate({opacity:0,"line-height":0,display:"none"},500),console.log(e),e.model.destroy(),this.modalClose()},duplicate:function(e){var t='<div class="message">Duplicating <em>'+e.model.get("title")+'</em>...<div class="nf-loading-spinner"></div></div>';this.modal.setContent(t),this.modal.setTitle("Please Wait"),this.modal.open();var n=this;jQuery.ajax({type:"POST",url:ajaxurl+"?action=nf_forms&clone_id="+e.model.get("id"),success:function(t){var t=JSON.parse(t),i=t.data.new_form_id,o=e.model.clone();o.set({id:i,title:o.get("title")+" - copy",created_at:new Date}),o.initShortcode(i),e.model.collection.add(o),n.modalClose()}})}})}),n("controllers/formsController",["models/formModel","models/formCollection"],function(e,t){return Marionette.Object.extend({initialize:function(){this.forms=new t,i.channel("dashboard").reply("get:forms",this.getForms,this),this.forms.fetch({success:function(e){i.channel("dashboard").trigger("fetch:forms",e)}})},getForms:function(){return this.forms}})}),n("models/oauthModel",[],function(){return Backbone.Model.extend({defaults:{connected:null,connect_url:""},url:function(){return ajaxurl+"?action=nf_oauth"},initialize:function(){},parse:function(e,t){return e.data}})}),n("controllers/oauthController",["models/oauthModel"],function(e){return Marionette.Object.extend({initialize:function(){this.oauth=new e,i.channel("dashboard").reply("get:oauth",this.getOAuth,this),i.channel("dashboard").reply("disconnect:oauth",this.disconnect,this),i.channel("dashboard").reply("oauth:learn-more",this.learnMoreModal,this),this.initOAuth()},getOAuth:function(){return this.oauth},initOAuth:function(){this.oauth.fetch({success:function(e){i.channel("dashboard").trigger("fetch:oauth")}})},disconnect:function(){var e=this;new jBox("Confirm",{width:750,content:nfi18n.oauthDisconnectContent,confirmButton:nfi18n.oauthDisconnectConfirm,cancelButton:nfi18n.oauthDisconnectCancel,closeOnConfirm:!0,confirm:function(){jQuery.ajax({type:"POST",url:ajaxurl+"?action=nf_oauth_disconnect",success:function(t){console.log(t),e.initOAuth()}})}}).open()},learnMoreModal:function(){new jBox("Modal",{width:500,content:nfi18n.oauthLearnMoreContent}).open()}})}),n("models/serviceModel",[],function(){return Backbone.Model.extend({defaults:{objectType:"service",name:"",slug:"",installPath:"",description:"",enabled:null,infoLink:null,serviceLink:null,is_installing:!1,classes:""},url:function(){return ajaxurl+"?action=nf_service_"+this.get("slug")},initialize:function(){this.get("slug")==serviceSuccess&&this.get("successMessage")&&new jBox("Modal",{width:300,addClass:"dashboard-modal",overlay:!0,closeOnClick:!0,content:this.get("successMessage"),title:this.get("successMessageTitle"),closeButton:"box"}).open();var e=this;i.channel("dashboard").reply("install:service:"+this.get("slug"),function(){if(e.get("serviceLink")&&e.get("serviceLink").href){var t=e.get("serviceLink").href;new jBox("Modal",{width:300,addClass:"dashboard-modal",overlay:!0,closeOnClick:"body",content:nfi18n.serviceRedirect}).open();var n=i.channel("dashboard").request("get:oauth");if(n.get("connected"))window.location=t;else{if(e.get("connect_url"))return window.location=e.get("connect_url")+"&redirect="+t;window.location=n.get("connect_url")+"&redirect="+t}}})},save:function(){var e=this;jQuery.ajax({type:"POST",url:this.url(),data:this.toJSON()}).done(function(t){var n=JSON.parse(t);void 0!==n.error&&(alert(nfi18n.serviceUpdateError+" "+n.error),e.set("enabled",!e.get("enabled"))),i.channel("dashboard").trigger("save:service-"+e.get("slug"))})}})}),n("models/serviceCollection",["models/serviceModel"],function(e){return Backbone.Collection.extend({model:e,comparator:"name",url:function(){return ajaxurl+"?action=nf_services"},initialize:function(){},parse:function(e,t){return e.data}})}),n("controllers/servicesController",["models/serviceCollection"],function(e){return Marionette.Object.extend({initialize:function(){this.services=new e,i.channel("dashboard").reply("install:service",this.installService,this),i.channel("dashboard").reply("get:services",this.getServices,this),this.fetchServices()},getServices:function(){return this.services},fetchServices:function(e){this.services.fetch({success:function(t){e&&e(t),i.channel("dashboard").trigger("fetch:services")}})},installService:function(e){var t=this;if(!(e instanceof Backbone.Model))var e=this.services.find(function(t){return e==t.get("slug")});e.set("is_installing",!0);var n=e.get("slug"),o=e.get("installPath");jQuery.post(ajaxurl,{action:"nf_services_install",plugin:n,install_path:o},function(e){t.fetchServices(function(){i.channel("dashboard").request("install:service:"+n)})})}})}),n("views/widgets/forms/formsFilter",[],function(){return Marionette.View.extend({template:"#tmpl-nf-widget-forms-filter",ui:{input:"input"},events:{"keyup @ui.input":"updateFilter"},initialize:function(){this.listenTo(i.channel("widget-forms"),"change:content",this.clearFilter)},updateFilter:function(){var e=this.getUI("input").val();i.channel("widget-forms").trigger("update:filter",e)},clearFilter:function(){this.getUI("input").val("")},updatePlaceholder:function(e){this.getUI("input").attr("placeholder",e)}})}),n("views/widgets/forms/formsTableRow",[],function(){return Marionette.View.extend({template:"#tmpl-nf-widget-forms-table-row",tagName:"tr",replaceElement:!0,ui:{delete:".delete",duplicate:".duplicate",edit:".nf-item-edit"},events:{"click @ui.delete":function(){i.channel("dashboard").trigger("forms:delete",this)},"click @ui.duplicate":function(){i.channel("dashboard").trigger("forms:duplicate",this)},"click @ui.edit":function(e){this.$el.toggleClass("show-actions").siblings().removeClass("show-actions")}},templateContext:function(){var e=this.model;return{created_at:moment(e.get("created_at")).format("MM/DD/YY h:mm A")}}})}),n("views/widgets/forms/formsTableEmpty",[],function(){return Marionette.View.extend({template:"#tmpl-nf-widget-forms-table-empty",tagName:"tr"})}),n("views/widgets/forms/formsTableBody",["views/widgets/forms/formsTableRow","views/widgets/forms/formsTableEmpty"],function(e,t){return Marionette.CollectionView.extend({childView:e,emptyView:t,className:"forms-collection",tagName:"tbody",initialize:function(){this.listenTo(i.channel("widget-forms"),"update:filter",this.updateFilter)},updateFilter:function(e){this.setFilter(function(t,n,i){return 0<=t.get("title").toLowerCase().indexOf(e.toLowerCase())})}})}),n("views/widgets/forms/formsTableLoading",[],function(){return Marionette.View.extend({template:"#tmpl-nf-widget-forms-table-loading",tagName:"tr"})}),n("views/widgets/forms/formsTable",["views/widgets/forms/formsTableBody","views/widgets/forms/formsTableLoading","models/formCollection"],function(e,t,n){return Marionette.View.extend({template:"#tmpl-nf-widget-forms-table",className:"nf-table-display",tagName:"table",initialize:function(){var t=this;this.listenTo(i.channel("dashboard"),"fetch:forms",function(n){t.showChildView("body",new e({collection:n}))})},regions:{body:{el:"tbody",replaceElement:!0}},ui:{sortable:".sortable",body:"tbody",action2:".action2",more:".more",less:".less"},onRender:function(){this.getUI("less").hide();var n=i.channel("dashboard").request("get:forms");void 0===n?this.showChildView("body",new t):this.showChildView("body",new e({collection:n})),this.maybeHideMoreButton()},events:{"click @ui.sortable":"sortFormsTable","click @ui.more":"showMore","click @ui.less":"showLess"},sortFormsTable:function(e){this.getUI("sortable").removeClass("sorted-asc"),this.getUI("sortable").removeClass("sorted-desc");var t=jQuery(e.target).data("sort"),n=jQuery(e.target).data("reverse")||0;n?(jQuery(e.target).addClass("sorted-desc"),jQuery(e.target).removeClass("sorted-asc")):(jQuery(e.target).addClass("sorted-asc"),jQuery(e.target).removeClass("sorted-desc"));var i=this.getChildView("body").collection;i.comparator=function(e,i){return name1=e.get(t).toLowerCase(),name2=i.get(t).toLowerCase(),name1<name2?ret=-1:name1>name2?ret=1:ret=0,n&&(ret=-ret),ret},i.sort(),n?(i.models.reverse(),jQuery(e.target).data("reverse",0)):jQuery(e.target).data("reverse",1)},showMore:function(){this.getUI("more").hide(),this.getUI("less").show(),this.getUI("body").addClass("more")},showLess:function(){this.getUI("less").hide(),this.getUI("more").show(),this.getUI("body").removeClass("more")},maybeHideMoreButton:function(){void 0!==this.collection&&10<this.collection.length||this.getUI("action2").hide()}})}),n("models/formTemplateModel",[],function(){return Backbone.Model.extend({defaults:{objectType:"template",id:"none",title:"unknown",type:""},initialize:function(){this.set("desc",this.get("template-desc")),this.set("modal-content",this.get("modal-content")),this.set("modal-title",this.get("modal-title"))}})}),n("models/formTemplateCollection",["models/formTemplateModel"],function(e){return Backbone.Collection.extend({model:e,tmpNum:1,url:function(){return ajaxurl+"?action=nf_new_form_templates"},parse:function(e,t){return e.data},initialize:function(){this.fetch({success:function(e){},error:function(e){}})}})}),n("views/widgets/forms/newFormTemplate",[],function(){return Marionette.View.extend({template:"#tmpl-nf-widget-forms-template",events:{click:"maybeOpenModal"},maybeOpenModal:function(e){if("ad"!=this.model.get("type"))return!0;e.preventDefault(),new jBox("Modal",{width:450,title:this.model.get("modal-title"),content:this.model.get("modal-content"),closeButton:"box",blockScroll:!0}).open()}})}),n("views/widgets/forms/newFormGrid",["models/formTemplateCollection","views/widgets/forms/newFormTemplate"],function(e,t){return Marionette.CollectionView.extend({tagName:"div",className:"template-list",collection:new e,childView:t,initialize:function(){this.listenTo(i.channel("widget-forms"),"update:filter",this.updateFilter)},updateFilter:function(e){this.setFilter(function(t,n,i){return 0<=t.get("title").toLowerCase().indexOf(e.toLowerCase())})}})}),n("views/widgets/forms/forms",["views/widgets/forms/formsFilter","views/widgets/forms/formsTable","views/widgets/forms/newFormGrid"],function(e,t,n){return Marionette.View.extend({template:"#tmpl-nf-widget-forms",regions:{filter:".filter",content:".content"},ui:{add:".add",cancel:".cancel"},initialize:function(){i.channel("widget-forms").reply("show:newFormsGrid",this.showNewFormGrid,this),i.channel("widget-forms").reply("show:formsTable",this.showFormsTable,this)},onRender:function(){this.getUI("cancel").hide(),this.showChildView("filter",new e),"#new-form"==window.location.hash?(this.getUI("add").hide(),this.getUI("cancel").show(),this.showChildView("content",new n)):this.showChildView("content",new t)},events:{"click @ui.add":"showNewFormGrid","click @ui.cancel":"showFormsTable"},showNewFormGrid:function(){window.location.hash="new-form",this.showChildView("content",new n),i.channel("widget-forms").trigger("change:content"),this.getUI("add").hide(),this.getUI("cancel").show(),this.getChildView("filter").updatePlaceholder("Search Templates")},showFormsTable:function(){console.log(this),window.location.hash="forms",this.showChildView("content",new t),i.channel("widget-forms").trigger("change:content"),this.getUI("cancel").hide(),this.getUI("add").show(),this.getChildView("filter").updatePlaceholder("Search Forms")}})}),n("views/sections/widgets.js",["views/widgets/forms/forms"],function(e){return Marionette.View.extend({template:"#tmpl-nf-widgets",regions:{forms:".widget-forms"},onRender:function(){this.showChildView("forms",new e)}})}),n("views/services/service",[],function(){return Marionette.View.extend({template:"#tmpl-nf-service",className:function(){return"nf-extend nf-box "+this.model.get("classes")},ui:{install:".js--install",learnMore:".js--learn-more",enabled:".nf-toggle.setting",toggleEnable:".nf-toggle + label"},events:{"click @ui.install":function(){i.channel("dashboard").request("install:service",this.model)},"click @ui.learnMore":function(){this.showLearnMore()},"click @ui.toggleEnable":function(){if(null==this.model.get("enabled")&&this.model.get("link"))return window.location=this.model.get("link"),this.render();this.model.set("enabled",!this.model.get("enabled")),this.model.save("enabled"),this.render()}},initialize:function(e){this.updateOAuth(),this.listenTo(this.model,"change",this.render),i.channel("dashboard").reply("more:service:"+this.model.get("slug"),this.showLearnMore,this),this.listenTo(i.channel("dashboard"),"fetch:oauth",this.updateOAuth),this.listenTo(i.channel("dashboard"),"save:service-"+this.model.get("slug"),this.render)},showLearnMore:function(){var e=new jBox("Modal",{width:750,title:this.model.get("learnMoreTitle")||this.model.get("name"),content:this.model.get("learnMore"),closeButton:"box",blockScroll:!0});e.open(),i.channel("dashboard").reply("service:"+this.model.get("slug")+":modal",function(){return e})},updateOAuth:function(){var e=i.channel("dashboard").request("get:oauth");this.connected=e.get("connected"),this.render()},templateContext:function(){return{is_connected:this.connected}}})}),n("views/services/services",["views/services/service","models/serviceCollection"],function(e,t){return Marionette.CollectionView.extend({collection:new t,className:"wrap apps-container",childView:e,initialize:function(){this.updateCollection(),this.listenTo(i.channel("dashboard"),"fetch:services",this.updateCollection)},updateCollection:function(){this.collection=i.channel("dashboard").request("get:services"),this.render()}})}),n("views/sections/services.js",["views/services/services"],function(e){return Marionette.View.extend({template:"#tmpl-nf-services",regions:{services:".services"},onRender:function(){this.showChildView("services",new e)}})}),n("views/sections/apps.js",[],function(){return Marionette.View.extend({template:"#tmpl-nf-apps"})}),n("views/sections/memberships.js",[],function(){return Marionette.View.extend({template:"#tmpl-nf-memberships"})}),n("views/oauth.js",["models/oauthModel"],function(e){return Marionette.View.extend({model:new e,template:"#tmpl-nf-notices-oauth",className:"nf-notices--oauth",ui:{disconnect:".js--disconnect"},initialize:function(e){this.listenTo(i.channel("dashboard"),"fetch:oauth",this.updateModel)},updateModel:function(){this.model=i.channel("dashboard").request("get:oauth"),this.render()},events:{"click @ui.disconnect":function(){i.channel("dashboard").request("disconnect:oauth")}}})}),n("models/promotionModel",[],function(){return Backbone.Model.extend({defaults:{id:"",content:""},initialize:function(){}})}),n("views/promotion.js",["models/promotionModel"],function(e){return Marionette.View.extend({model:null,template:"#tmpl-nf-promotion",className:"nf-promotion",initialize:function(){var t=nfPromotions[Math.floor(Math.random()*nfPromotions.length)];this.model=new e(t)}})}),n("views/dashboardView",["views/sections/widgets.js","views/sections/services.js","views/sections/apps.js","views/sections/memberships.js","views/oauth.js","views/promotion.js"],function(e,t,n,o,s,r){return Marionette.View.extend({template:"#tmpl-nf-dashboard",currentView:"widgets",regions:{notices:".notices",promotions:".promotions",content:".content"},events:{"click .widgets a":function(t){this.showChildView("content",new e),jQuery("."+this.currentView).find("a").removeClass("active"),t.target.classList.add("active"),this.currentView="widgets"},"click .services a":function(e){this.showChildView("content",new t),jQuery("."+this.currentView).find("a").removeClass("active"),e.target.classList.add("active"),this.currentView="services"},"click .apps a":function(e){this.showChildView("content",new n),jQuery("."+this.currentView).find("a").removeClass("active"),e.target.classList.add("active"),this.currentView="apps"},"click .memberships a":function(e){this.showChildView("content",new o),jQuery("."+this.currentView).find("a").removeClass("active"),e.target.classList.add("active"),this.currentView="memberships"}},initialize:function(){switch(window.location.hash){case"#apps":this.currentView="apps";break;case"#services":this.currentView="services";break;case"#memberships":this.currentView="memberships";break;case"#widgets":default:this.currentView="widgets"}i.channel("dashboard").reply("show:widgets",function(){this.showChildView("content",new e),jQuery("nav.sections a.active").removeClass("active"),jQuery("nav.sections .widgets a").addClass("active"),this.currentView="widgets"},this),i.channel("dashboard").reply("show:services",function(){this.showChildView("content",new t),jQuery("nav.sections a.active").removeClass("active"),jQuery("nav.sections .services a").addClass("active"),this.currentView="services"},this),i.channel("dashboard").reply("show:apps",function(){this.showChildView("content",new n),jQuery("nav.sections a.active").removeClass("active"),jQuery("nav.sections .apps a").addClass("active"),this.currentView="apps"},this)},onRender:function(){switch(useServices&&this.showChildView("notices",new s),useServices&&this.showChildView("promotions",new r),window.location.hash){case"#apps":var i=new n;break;case"#memberships":var i=new o;break;case"#services":var i=new t;break;case"#widgets":default:var i=new e}if(this.showChildView("content",i),"1"==nfAdmin.showOptin){var a=new jBox("Modal",{closeOnEsc:!1,closeOnClick:!1,width:400}),l=document.createElement("div");l.id="optin-modal-title";var c=document.createElement("h2");c.innerHTML="Help make Ninja Forms better!",l.appendChild(c);var d=document.createElement("div");d.classList.add("message"),d.style.padding="0px 20px 20px 20px",d.innerHTML=nfi18n.optinContent;var u=document.createElement("p");u.style.paddingBottom="10px";var h=document.createElement("input");h.id="optin-send-email",h.setAttribute("type","checkbox"),h.style.margin="7px";var m=document.createElement("label");m.setAttribute("for","optin-send-email"),m.innerHTML=nfi18n.optinYesplease,u.appendChild(h),u.appendChild(m),d.appendChild(u),u=document.createElement("p"),u.id="optin-block",u.style.padding="0px 5px 20px 5px",u.style.display="none";var f=document.createElement("input");f.id="optin-email-address",f.setAttribute("type","text"),f.setAttribute("value",nfAdmin.currentUserEmail),f.style.width="100%",f.style.fontSize="16px",u.appendChild(f),d.appendChild(u);var p=document.createElement("span");p.id="optin-spinner",p.classList.add("spinner"),p.style.display="none",d.appendChild(p);var w=document.createElement("div");w.id="optin-buttons",w.classList.add("buttons");var g=document.createElement("div");g.id="optout",g.classList.add("nf-button","secondary"),g.innerHTML=nfi18n.optinSecondary,w.appendChild(g);var v=document.createElement("div");v.id="optin",v.classList.add("nf-button","primary","pull-right"),v.innerHTML=nfi18n.optinPrimary,w.appendChild(v),d.appendChild(w);var b=document.createElement("h2");b.innerHTML=nfi18n.optinAwesome;var y=document.createElement("div");y.id="optin-thankyou",y.classList.add("message"),y.style.padding="20px",y.innerHTML=nfi18n.optinThanks,a.setContent(document.createElement("div").appendChild(d).innerHTML),a.setTitle(document.createElement("div").appendChild(l).innerHTML),a.open(),jQuery("#optin-send-email").click(function(e){jQuery(this).is(":checked")?jQuery("#optin-block").show():jQuery("#optin-block").hide()}),jQuery("#optin").click(function(e){var t;jQuery("#optin-send-email").attr("checked")?(t=1,userEmail=jQuery("#optin-email-address").val()):(t=0,userEmail=""),jQuery("#optin").unbind("click"),jQuery("#optout").unbind("click");var n=jQuery("#optin").width();jQuery("#optin").html('<span class="dashicons dashicons-update dashicons-update-spin"></span>'),jQuery("#optin").width(n),jQuery.post(ajaxurl,{action:"nf_optin",ninja_forms_opt_in:1,send_email:t,user_email:userEmail},function(e){a.setTitle(document.createElement("div").appendChild(b).innerHTML),a.setContent(document.createElement("div").appendChild(y).innerHTML),setTimeout(function(){a.close()},2e3)})}),jQuery("#optout").click(function(e){jQuery("#optin").unbind("click"),jQuery("#optout").unbind("click");var t=jQuery("#optout").width();jQuery("#optout").html('<span class="dashicons dashicons-update dashicons-update-spin"></span>'),jQuery("#optout").width(t),jQuery.post(ajaxurl,{action:"nf_optin",ninja_forms_opt_in:0},function(e){a.close()})})}else if("1"==nfAdmin.doingCleanup)var C=this,j={width:450,closeOnClick:!1,closeOnEsc:!1,content:nfi18n.cleanupContent,useProgressBar:!0,loadingText:nfi18n.cleanupLoading,btnSecondary:{text:nfi18n.cleanupSecondary,callback:function(){x.toggleModal(!1)}},btnPrimary:{text:nfi18n.cleanupPrimary,callback:function(){jQuery(window).bind("beforeunload",function(){return"Are you sure? Leaving before the process completes could cause damage to your data."}),x.maybeShowActions(!1),x.maybeShowProgress(!0),C.cleanupProcess(C,-1,x)}}},x=new NinjaModal(j);if(void 0!==nfAdmin.formTelemetry&&1==nfAdmin.formTelemetry){var M={action:"nf_form_telemetry",security:nfAdmin.ajaxNonce};jQuery.post(ajaxurl,M)}},templateContext:function(){var e=this;return{renderNav:function(){var t=document.createElement("div");return _.each(nfDashItems,function(n){var i=document.createElement("li"),o=document.createElement("a");o.href="#"+n.slug,e.currentView==n.slug&&o.classList.add("active"),o.innerHTML=n.niceName,i.classList.add(n.slug),i.appendChild(o),t.appendChild(i)}),t.innerHTML}}},cleanupProcess:function(e,t,n){var i={action:"nf_batch_process",batch_type:"data_cleanup",security:nfAdmin.batchNonce};jQuery.post(ajaxurl,i,function(i){if(i=JSON.parse(i),i.batch_complete)return n.setProgress(100),jQuery(window).unbind("beforeunload"),n.toggleModal(!1),!1;-1==t&&(t=void 0!==i.step_total?i.step_total:i.step_remaining);var o=t-i.step_remaining,s=Math.round(o/t*100);n.incrementProgress(s),e.cleanupProcess(e,t,n)})}})});var i=Backbone.Radio;useServices||(nfDashItems=nfDashItems.filter(function(e){return"services"!==e.slug})),jQuery(document).ready(function(e){t(["controllers/formsController","controllers/oauthController","controllers/servicesController","views/dashboardView"],function(t,n,i,o){(new(Marionette.Application.extend({region:"#ninja-forms-dashboard",controllers:{},initialize:function(e){var t=this;Marionette.Renderer.render=function(e,n){var e=t.template(e);return e(n)}},onStart:function(){this.showView(new o),this.controllers.forms=new t,useServices&&(this.controllers.oauth=new n),useServices&&(this.controllers.services=new i)},template:function(t){return _.template(e(t).html(),{evaluate:/<#([\s\S]+?)#>/g,interpolate:/\{\{\{([\s\S]+?)\}\}\}/g,escape:/\{\{([^\}]+?)\}\}(?!\})/g,variable:"data"})}}))).start()})}),jQuery('a[href="admin.php?page=ninja-forms#new-form"]').on("click",function(e){e.preventDefault(),window.location.hash="new-form",i.channel("dashboard").request("show:widgets"),i.channel("widget-forms").request("show:newFormsGrid")}),jQuery('a[href="admin.php?page=ninja-forms#apps"]').on("click",function(e){e.preventDefault(),window.location.hash="apps",i.channel("dashboard").request("show:apps")}),jQuery('a[href="admin.php?page=ninja-forms"]').on("click",function(e){e.preventDefault(),window.location.hash="forms",i.channel("dashboard").request("show:widgets"),i.channel("widget-forms").request("show:formsTable")}),jQuery(window).on("hashchange",function(){var e=window.location.hash.substr(1);i.channel("dashboard").request("show:"+e)}),n("main",function(){})}();
//# sourceMappingURL=dashboard.min.js.map
{"version":3,"names":[],"mappings":"","sources":["views/widgets/forms/newFormTemplate.js"],"sourcesContent":["!function(){var e,t,n;!function(i){function o(e,t){return y.call(e,t)}function s(e,t){var n,i,o,s,r,a,l,c,d,u,h,m=t&&t.split(\"/\"),f=v.map,p=f&&f[\"*\"]||{};if(e&&\".\"===e.charAt(0))if(t){for(e=e.split(\"/\"),r=e.length-1,v.nodeIdCompat&&j.test(e[r])&&(e[r]=e[r].replace(j,\"\")),e=m.slice(0,m.length-1).concat(e),d=0;d<e.length;d+=1)if(\".\"===(h=e[d]))e.splice(d,1),d-=1;else if(\"..\"===h){if(1===d&&(\"..\"===e[2]||\"..\"===e[0]))break;d>0&&(e.splice(d-1,2),d-=2)}e=e.join(\"/\")}else 0===e.indexOf(\"./\")&&(e=e.substring(2));if((m||p)&&f){for(n=e.split(\"/\"),d=n.length;d>0;d-=1){if(i=n.slice(0,d).join(\"/\"),m)for(u=m.length;u>0;u-=1)if((o=f[m.slice(0,u).join(\"/\")])&&(o=o[i])){s=o,a=d;break}if(s)break;!l&&p&&p[i]&&(l=p[i],c=d)}!s&&l&&(s=l,a=c),s&&(n.splice(0,a,s),e=n.join(\"/\"))}return e}function r(e,t){return function(){var n=C.call(arguments,0);return\"string\"!=typeof n[0]&&1===n.length&&n.push(null),m.apply(i,n.concat([e,t]))}}function a(e){return function(t){return s(t,e)}}function l(e){return function(t){w[e]=t}}function c(e){if(o(g,e)){var t=g[e];delete g[e],b[e]=!0,h.apply(i,t)}if(!o(w,e)&&!o(b,e))throw new Error(\"No \"+e);return w[e]}function d(e){var t,n=e?e.indexOf(\"!\"):-1;return n>-1&&(t=e.substring(0,n),e=e.substring(n+1,e.length)),[t,e]}function u(e){return function(){return v&&v.config&&v.config[e]||{}}}var h,m,f,p,w={},g={},v={},b={},y=Object.prototype.hasOwnProperty,C=[].slice,j=/\\.js$/;f=function(e,t){var n,i=d(e),o=i[0];return e=i[1],o&&(o=s(o,t),n=c(o)),o?e=n&&n.normalize?n.normalize(e,a(t)):s(e,t):(e=s(e,t),i=d(e),o=i[0],e=i[1],o&&(n=c(o))),{f:o?o+\"!\"+e:e,n:e,pr:o,p:n}},p={require:function(e){return r(e)},exports:function(e){var t=w[e];return void 0!==t?t:w[e]={}},module:function(e){return{id:e,uri:\"\",exports:w[e],config:u(e)}}},h=function(e,t,n,s){var a,d,u,h,m,v,y=[],C=typeof n;if(s=s||e,\"undefined\"===C||\"function\"===C){for(t=!t.length&&n.length?[\"require\",\"exports\",\"module\"]:t,m=0;m<t.length;m+=1)if(h=f(t[m],s),\"require\"===(d=h.f))y[m]=p.require(e);else if(\"exports\"===d)y[m]=p.exports(e),v=!0;else if(\"module\"===d)a=y[m]=p.module(e);else if(o(w,d)||o(g,d)||o(b,d))y[m]=c(d);else{if(!h.p)throw new Error(e+\" missing \"+d);h.p.load(h.n,r(s,!0),l(d),{}),y[m]=w[d]}u=n?n.apply(w[e],y):void 0,e&&(a&&a.exports!==i&&a.exports!==w[e]?w[e]=a.exports:u===i&&v||(w[e]=u))}else e&&(w[e]=n)},e=t=m=function(e,t,n,o,s){if(\"string\"==typeof e)return p[e]?p[e](t):c(f(e,t).f);if(!e.splice){if(v=e,v.deps&&m(v.deps,v.callback),!t)return;t.splice?(e=t,t=n,n=null):e=i}return t=t||function(){},\"function\"==typeof n&&(n=o,o=s),o?h(i,e,t,n):setTimeout(function(){h(i,e,t,n)},4),m},m.config=function(e){return m(e)},e._defined=w,n=function(e,t,n){if(\"string\"!=typeof e)throw new Error(\"See almond README: incorrect module build, no module name\");t.splice||(n=t,t=[]),o(w,e)||o(g,e)||(g[e]=[e,t,n])},n.amd={jQuery:!0}}(),n(\"../../assets/js/lib/almond\",function(){}),n(\"models/formModel\",[],function(){return Backbone.Model.extend({defaults:{objectType:\"form\",id:0,title:\"unknown\",created_at:\"unknown\"},url:function(){return ajaxurl+\"?action=nf_forms&form_id=\"+this.get(\"id\")},initialize:function(){this.set(\"id\",Number(this.get(\"id\"))),this.get(\"id\")&&this.initShortcode(this.get(\"id\")),this.get(\"title\")&&this.set(\"title\",this.get(\"title\").replace(/<\\/?[^>]+(>|$)/g,\"\"))},initShortcode:function(e){var t=\"[ninja_form id=\"+e+\"]\";this.set(\"shortcode\",t)},destroy:function(){var e=this;jQuery.ajax({type:\"POST\",url:ajaxurl+\"?action=nf_forms&method_override=delete&form_id=\"+this.get(\"id\"),success:function(t){var t=JSON.parse(t);e.collection.remove(e)}})}})}),n(\"models/formCollection\",[\"models/formModel\"],function(e){return Backbone.Collection.extend({model:e,comparator:\"title\",tmpNum:1,url:function(){return ajaxurl+\"?action=nf_forms\"},initialize:function(){this.newIDs=[],this.baseUrl=window.location.href.split(\"?\")[0],this.listenTo(i.channel(\"dashboard\"),\"forms:delete\",this.modalConfirm),this.listenTo(i.channel(\"dashboard\"),\"forms:duplicate\",this.duplicate),this.modal=new jBox(\"Modal\",{width:400,addClass:\"dashboard-modal\",overlay:!0,closeOnClick:\"body\"})},parse:function(e,t){return e.data},modalConfirm:function(e){var t,n,i,o,s,r,a,l=e.model.get(\"id\"),c=e.model.get(\"title\");n=document.createElement(\"div\"),n.style.paddingRight=\"20px\",n.style.paddingLeft=\"20px\",n.style.paddingBottom=\"20px\",i=document.createElement(\"p\"),o=document.createElement(\"em\"),s=document.createElement(\"div\"),r=document.createElement(\"div\"),a=document.createElement(\"div\"),n.classList.add(\"message\"),o.innerHTML=c,i.innerHTML+=nfi18n.deleteWarningA+\" (<strong>\"+c+\"</strong>). \"+nfi18n.deleteWarningB,i.appendChild(document.createElement(\"br\")),i.appendChild(document.createElement(\"br\"));var d=document.createElement(\"a\");d.href=this.baseUrl+\"?page=nf-import-export&exportFormId=\"+l,d.innerHTML='<i class=\"fa fa-download\" style=\"padding:5px;\"></i>'+nfi18n.deleteXForm,d.target=\"_blank\",i.appendChild(d),i.appendChild(document.createElement(\"br\"));var u=document.createElement(\"a\");u.href=this.baseUrl+\"?page=nf-processing&action=download_all_subs&form_id=\"+l+\"&redirect=\"+encodeURIComponent(this.baseUrl.replace(\"admin.php\",\"edit.php\")+\"?post_status=all&post_type=nf_sub&form_id=\"+l),u.target=\"_blank\",u.innerHTML='<i class=\"fa fa-download\" style=\"padding:5px;\"></i>'+nfi18n.deleteXSubs,i.appendChild(u),i.appendChild(document.createElement(\"br\")),n.appendChild(i);var h=document.createElement(\"label\");h.for=\"confirmDeleteFormInput\",h.innerHTML=nfi18n.deleteConfirmA+' <span style=\"color:red;\">DELETE</span> '+nfi18n.deleteConfirmB;var m=document.createElement(\"input\");m.type=\"text\",m.id=\"confirmDeleteFormInput\",m.style.marginTop=\"10px\",m.style.width=\"100%\",m.style.height=\"2.5em\",m.style.fontSize=\"1em\",n.appendChild(h),n.appendChild(document.createElement(\"br\")),n.appendChild(m),n.appendChild(document.createElement(\"br\")),n.appendChild(document.createElement(\"br\")),r.innerHTML=nfi18n.delete,r.classList.add(\"confirm\",\"nf-button\",\"primary\",\"pull-right\"),a.innerHTML=nfi18n.cancel,a.classList.add(\"cancel\",\"nf-button\",\"secondary\"),s.appendChild(a),s.appendChild(r),s.classList.add(\"buttons\"),n.appendChild(s),t=document.createElement(\"div\"),t.appendChild(n),this.modal.setContent(t.innerHTML),this.modal.setTitle(nfi18n.deleteTitle),this.modal.open();var f=this;this.modal.container[0].getElementsByClassName(\"cancel\")[0].addEventListener(\"click\",function(){f.modalClose()}),this.modal.container[0].getElementsByClassName(\"confirm\")[0].addEventListener(\"click\",function(){\"DELETE\"===document.getElementById(\"confirmDeleteFormInput\").value?f.confirmDelete(e):f.modalClose()})},modalClose:function(){this.modal.close()},confirmDelete:function(e){jQuery(e.el).removeClass(\"show-actions\"),jQuery(e.el).addClass(\"deleting\"),jQuery(e.el).animate({opacity:0,\"line-height\":0,display:\"none\"},500),console.log(e),e.model.destroy(),this.modalClose()},duplicate:function(e){var t='<div class=\"message\">Duplicating <em>'+e.model.get(\"title\")+'</em>...<div class=\"nf-loading-spinner\"></div></div>';this.modal.setContent(t),this.modal.setTitle(\"Please Wait\"),this.modal.open();var n=this;jQuery.ajax({type:\"POST\",url:ajaxurl+\"?action=nf_forms&clone_id=\"+e.model.get(\"id\"),success:function(t){var t=JSON.parse(t),i=t.data.new_form_id,o=e.model.clone();o.set({id:i,title:o.get(\"title\")+\" - copy\",created_at:new Date}),o.initShortcode(i),e.model.collection.add(o),n.modalClose()}})}})}),n(\"controllers/formsController\",[\"models/formModel\",\"models/formCollection\"],function(e,t){return Marionette.Object.extend({initialize:function(){this.forms=new t,i.channel(\"dashboard\").reply(\"get:forms\",this.getForms,this),this.forms.fetch({success:function(e){i.channel(\"dashboard\").trigger(\"fetch:forms\",e)}})},getForms:function(){return this.forms}})}),n(\"models/oauthModel\",[],function(){return Backbone.Model.extend({defaults:{connected:null,connect_url:\"\"},url:function(){return ajaxurl+\"?action=nf_oauth\"},initialize:function(){},parse:function(e,t){return e.data}})}),n(\"controllers/oauthController\",[\"models/oauthModel\"],function(e){return Marionette.Object.extend({initialize:function(){this.oauth=new e,i.channel(\"dashboard\").reply(\"get:oauth\",this.getOAuth,this),i.channel(\"dashboard\").reply(\"disconnect:oauth\",this.disconnect,this),i.channel(\"dashboard\").reply(\"oauth:learn-more\",this.learnMoreModal,this),this.initOAuth()},getOAuth:function(){return this.oauth},initOAuth:function(){this.oauth.fetch({success:function(e){i.channel(\"dashboard\").trigger(\"fetch:oauth\")}})},disconnect:function(){var e=this;new jBox(\"Confirm\",{width:750,content:nfi18n.oauthDisconnectContent,confirmButton:nfi18n.oauthDisconnectConfirm,cancelButton:nfi18n.oauthDisconnectCancel,closeOnConfirm:!0,confirm:function(){jQuery.ajax({type:\"POST\",url:ajaxurl+\"?action=nf_oauth_disconnect\",success:function(t){console.log(t),e.initOAuth()}})}}).open()},learnMoreModal:function(){new jBox(\"Modal\",{width:500,content:nfi18n.oauthLearnMoreContent}).open()}})}),n(\"models/serviceModel\",[],function(){return Backbone.Model.extend({defaults:{objectType:\"service\",name:\"\",slug:\"\",installPath:\"\",description:\"\",enabled:null,infoLink:null,serviceLink:null,is_installing:!1,classes:\"\"},url:function(){return ajaxurl+\"?action=nf_service_\"+this.get(\"slug\")},initialize:function(){this.get(\"slug\")==serviceSuccess&&this.get(\"successMessage\")&&new jBox(\"Modal\",{width:300,addClass:\"dashboard-modal\",overlay:!0,closeOnClick:!0,content:this.get(\"successMessage\"),title:this.get(\"successMessageTitle\"),closeButton:\"box\"}).open();var e=this;i.channel(\"dashboard\").reply(\"install:service:\"+this.get(\"slug\"),function(){if(e.get(\"serviceLink\")&&e.get(\"serviceLink\").href){var t=e.get(\"serviceLink\").href;new jBox(\"Modal\",{width:300,addClass:\"dashboard-modal\",overlay:!0,closeOnClick:\"body\",content:nfi18n.serviceRedirect}).open();var n=i.channel(\"dashboard\").request(\"get:oauth\");if(n.get(\"connected\"))window.location=t;else{if(e.get(\"connect_url\"))return window.location=e.get(\"connect_url\")+\"&redirect=\"+t;window.location=n.get(\"connect_url\")+\"&redirect=\"+t}}})},save:function(){var e=this;jQuery.ajax({type:\"POST\",url:this.url(),data:this.toJSON()}).done(function(t){var n=JSON.parse(t);void 0!==n.error&&(alert(nfi18n.serviceUpdateError+\" \"+n.error),e.set(\"enabled\",!e.get(\"enabled\"))),i.channel(\"dashboard\").trigger(\"save:service-\"+e.get(\"slug\"))})}})}),n(\"models/serviceCollection\",[\"models/serviceModel\"],function(e){return Backbone.Collection.extend({model:e,comparator:\"name\",url:function(){return ajaxurl+\"?action=nf_services\"},initialize:function(){},parse:function(e,t){return e.data}})}),n(\"controllers/servicesController\",[\"models/serviceCollection\"],function(e){return Marionette.Object.extend({initialize:function(){this.services=new e,i.channel(\"dashboard\").reply(\"install:service\",this.installService,this),i.channel(\"dashboard\").reply(\"get:services\",this.getServices,this),this.fetchServices()},getServices:function(){return this.services},fetchServices:function(e){this.services.fetch({success:function(t){e&&e(t),i.channel(\"dashboard\").trigger(\"fetch:services\")}})},installService:function(e){var t=this;if(!(e instanceof Backbone.Model))var e=this.services.find(function(t){return e==t.get(\"slug\")});e.set(\"is_installing\",!0);var n=e.get(\"slug\"),o=e.get(\"installPath\");jQuery.post(ajaxurl,{action:\"nf_services_install\",plugin:n,install_path:o},function(e){t.fetchServices(function(){i.channel(\"dashboard\").request(\"install:service:\"+n)})})}})}),n(\"views/widgets/forms/formsFilter\",[],function(){return Marionette.View.extend({template:\"#tmpl-nf-widget-forms-filter\",ui:{input:\"input\"},events:{\"keyup @ui.input\":\"updateFilter\"},initialize:function(){this.listenTo(i.channel(\"widget-forms\"),\"change:content\",this.clearFilter)},updateFilter:function(){var e=this.getUI(\"input\").val();i.channel(\"widget-forms\").trigger(\"update:filter\",e)},clearFilter:function(){this.getUI(\"input\").val(\"\")},updatePlaceholder:function(e){this.getUI(\"input\").attr(\"placeholder\",e)}})}),n(\"views/widgets/forms/formsTableRow\",[],function(){return Marionette.View.extend({template:\"#tmpl-nf-widget-forms-table-row\",tagName:\"tr\",replaceElement:!0,ui:{delete:\".delete\",duplicate:\".duplicate\",edit:\".nf-item-edit\"},events:{\"click @ui.delete\":function(){i.channel(\"dashboard\").trigger(\"forms:delete\",this)},\"click @ui.duplicate\":function(){i.channel(\"dashboard\").trigger(\"forms:duplicate\",this)},\"click @ui.edit\":function(e){this.$el.toggleClass(\"show-actions\").siblings().removeClass(\"show-actions\")}},templateContext:function(){var e=this.model;return{created_at:moment(e.get(\"created_at\")).format(\"MM/DD/YY h:mm A\")}}})}),n(\"views/widgets/forms/formsTableEmpty\",[],function(){return Marionette.View.extend({template:\"#tmpl-nf-widget-forms-table-empty\",tagName:\"tr\"})}),n(\"views/widgets/forms/formsTableBody\",[\"views/widgets/forms/formsTableRow\",\"views/widgets/forms/formsTableEmpty\"],function(e,t){return Marionette.CollectionView.extend({childView:e,emptyView:t,className:\"forms-collection\",tagName:\"tbody\",initialize:function(){this.listenTo(i.channel(\"widget-forms\"),\"update:filter\",this.updateFilter)},updateFilter:function(e){this.setFilter(function(t,n,i){return 0<=t.get(\"title\").toLowerCase().indexOf(e.toLowerCase())})}})}),n(\"views/widgets/forms/formsTableLoading\",[],function(){return Marionette.View.extend({template:\"#tmpl-nf-widget-forms-table-loading\",tagName:\"tr\"})}),n(\"views/widgets/forms/formsTable\",[\"views/widgets/forms/formsTableBody\",\"views/widgets/forms/formsTableLoading\",\"models/formCollection\"],function(e,t,n){return Marionette.View.extend({template:\"#tmpl-nf-widget-forms-table\",className:\"nf-table-display\",tagName:\"table\",initialize:function(){var t=this;this.listenTo(i.channel(\"dashboard\"),\"fetch:forms\",function(n){t.showChildView(\"body\",new e({collection:n}))})},regions:{body:{el:\"tbody\",replaceElement:!0}},ui:{sortable:\".sortable\",body:\"tbody\",action2:\".action2\",more:\".more\",less:\".less\"},onRender:function(){this.getUI(\"less\").hide();var n=i.channel(\"dashboard\").request(\"get:forms\");void 0===n?this.showChildView(\"body\",new t):this.showChildView(\"body\",new e({collection:n})),this.maybeHideMoreButton()},events:{\"click @ui.sortable\":\"sortFormsTable\",\"click @ui.more\":\"showMore\",\"click @ui.less\":\"showLess\"},sortFormsTable:function(e){this.getUI(\"sortable\").removeClass(\"sorted-asc\"),this.getUI(\"sortable\").removeClass(\"sorted-desc\");var t=jQuery(e.target).data(\"sort\"),n=jQuery(e.target).data(\"reverse\")||0;n?(jQuery(e.target).addClass(\"sorted-desc\"),jQuery(e.target).removeClass(\"sorted-asc\")):(jQuery(e.target).addClass(\"sorted-asc\"),jQuery(e.target).removeClass(\"sorted-desc\"));var i=this.getChildView(\"body\").collection;i.comparator=function(e,i){return name1=e.get(t).toLowerCase(),name2=i.get(t).toLowerCase(),name1<name2?ret=-1:name1>name2?ret=1:ret=0,n&&(ret=-ret),ret},i.sort(),n?(i.models.reverse(),jQuery(e.target).data(\"reverse\",0)):jQuery(e.target).data(\"reverse\",1)},showMore:function(){this.getUI(\"more\").hide(),this.getUI(\"less\").show(),this.getUI(\"body\").addClass(\"more\")},showLess:function(){this.getUI(\"less\").hide(),this.getUI(\"more\").show(),this.getUI(\"body\").removeClass(\"more\")},maybeHideMoreButton:function(){void 0!==this.collection&&10<this.collection.length||this.getUI(\"action2\").hide()}})}),n(\"models/formTemplateModel\",[],function(){return Backbone.Model.extend({defaults:{objectType:\"template\",id:\"none\",title:\"unknown\",type:\"\"},initialize:function(){this.set(\"desc\",this.get(\"template-desc\")),this.set(\"modal-content\",this.get(\"modal-content\")),this.set(\"modal-title\",this.get(\"modal-title\"))}})}),n(\"models/formTemplateCollection\",[\"models/formTemplateModel\"],function(e){return Backbone.Collection.extend({model:e,tmpNum:1,url:function(){return ajaxurl+\"?action=nf_new_form_templates\"},parse:function(e,t){return e.data},initialize:function(){this.fetch({success:function(e){},error:function(e){}})}})}),n(\"views/widgets/forms/newFormTemplate\",[],function(){return Marionette.View.extend({template:\"#tmpl-nf-widget-forms-template\",events:{click:\"maybeOpenModal\"},maybeOpenModal:function(e){if(\"ad\"!=this.model.get(\"type\"))return!0;e.preventDefault(),new jBox(\"Modal\",{width:450,title:this.model.get(\"modal-title\"),content:this.model.get(\"modal-content\"),closeButton:\"box\",blockScroll:!0}).open()}})}),n(\"views/widgets/forms/newFormGrid\",[\"models/formTemplateCollection\",\"views/widgets/forms/newFormTemplate\"],function(e,t){return Marionette.CollectionView.extend({tagName:\"div\",className:\"template-list\",collection:new e,childView:t,initialize:function(){this.listenTo(i.channel(\"widget-forms\"),\"update:filter\",this.updateFilter)},updateFilter:function(e){this.setFilter(function(t,n,i){return 0<=t.get(\"title\").toLowerCase().indexOf(e.toLowerCase())})}})}),n(\"views/widgets/forms/forms\",[\"views/widgets/forms/formsFilter\",\"views/widgets/forms/formsTable\",\"views/widgets/forms/newFormGrid\"],function(e,t,n){return Marionette.View.extend({template:\"#tmpl-nf-widget-forms\",regions:{filter:\".filter\",content:\".content\"},ui:{add:\".add\",cancel:\".cancel\"},initialize:function(){i.channel(\"widget-forms\").reply(\"show:newFormsGrid\",this.showNewFormGrid,this),i.channel(\"widget-forms\").reply(\"show:formsTable\",this.showFormsTable,this)},onRender:function(){this.getUI(\"cancel\").hide(),this.showChildView(\"filter\",new e),\"#new-form\"==window.location.hash?(this.getUI(\"add\").hide(),this.getUI(\"cancel\").show(),this.showChildView(\"content\",new n)):this.showChildView(\"content\",new t)},events:{\"click @ui.add\":\"showNewFormGrid\",\"click @ui.cancel\":\"showFormsTable\"},showNewFormGrid:function(){window.location.hash=\"new-form\",this.showChildView(\"content\",new n),i.channel(\"widget-forms\").trigger(\"change:content\"),this.getUI(\"add\").hide(),this.getUI(\"cancel\").show(),this.getChildView(\"filter\").updatePlaceholder(\"Search Templates\")},showFormsTable:function(){console.log(this),window.location.hash=\"forms\",this.showChildView(\"content\",new t),i.channel(\"widget-forms\").trigger(\"change:content\"),this.getUI(\"cancel\").hide(),this.getUI(\"add\").show(),this.getChildView(\"filter\").updatePlaceholder(\"Search Forms\")}})}),n(\"views/sections/widgets.js\",[\"views/widgets/forms/forms\"],function(e){return Marionette.View.extend({template:\"#tmpl-nf-widgets\",regions:{forms:\".widget-forms\"},onRender:function(){this.showChildView(\"forms\",new e)}})}),n(\"views/services/service\",[],function(){return Marionette.View.extend({template:\"#tmpl-nf-service\",className:function(){return\"nf-extend nf-box \"+this.model.get(\"classes\")},ui:{install:\".js--install\",learnMore:\".js--learn-more\",enabled:\".nf-toggle.setting\",toggleEnable:\".nf-toggle + label\"},events:{\"click @ui.install\":function(){i.channel(\"dashboard\").request(\"install:service\",this.model)},\"click @ui.learnMore\":function(){this.showLearnMore()},\"click @ui.toggleEnable\":function(){if(null==this.model.get(\"enabled\")&&this.model.get(\"link\"))return window.location=this.model.get(\"link\"),this.render();this.model.set(\"enabled\",!this.model.get(\"enabled\")),this.model.save(\"enabled\"),this.render()}},initialize:function(e){this.updateOAuth(),this.listenTo(this.model,\"change\",this.render),i.channel(\"dashboard\").reply(\"more:service:\"+this.model.get(\"slug\"),this.showLearnMore,this),this.listenTo(i.channel(\"dashboard\"),\"fetch:oauth\",this.updateOAuth),this.listenTo(i.channel(\"dashboard\"),\"save:service-\"+this.model.get(\"slug\"),this.render)},showLearnMore:function(){var e=new jBox(\"Modal\",{width:750,title:this.model.get(\"learnMoreTitle\")||this.model.get(\"name\"),content:this.model.get(\"learnMore\"),closeButton:\"box\",blockScroll:!0});e.open(),i.channel(\"dashboard\").reply(\"service:\"+this.model.get(\"slug\")+\":modal\",function(){return e})},updateOAuth:function(){var e=i.channel(\"dashboard\").request(\"get:oauth\");this.connected=e.get(\"connected\"),this.render()},templateContext:function(){return{is_connected:this.connected}}})}),n(\"views/services/services\",[\"views/services/service\",\"models/serviceCollection\"],function(e,t){return Marionette.CollectionView.extend({collection:new t,className:\"wrap apps-container\",childView:e,initialize:function(){this.updateCollection(),this.listenTo(i.channel(\"dashboard\"),\"fetch:services\",this.updateCollection)},updateCollection:function(){this.collection=i.channel(\"dashboard\").request(\"get:services\"),this.render()}})}),n(\"views/sections/services.js\",[\"views/services/services\"],function(e){return Marionette.View.extend({template:\"#tmpl-nf-services\",regions:{services:\".services\"},onRender:function(){this.showChildView(\"services\",new e)}})}),n(\"views/sections/apps.js\",[],function(){return Marionette.View.extend({template:\"#tmpl-nf-apps\"})}),n(\"views/sections/memberships.js\",[],function(){return Marionette.View.extend({template:\"#tmpl-nf-memberships\"})}),n(\"views/oauth.js\",[\"models/oauthModel\"],function(e){return Marionette.View.extend({model:new e,template:\"#tmpl-nf-notices-oauth\",className:\"nf-notices--oauth\",ui:{disconnect:\".js--disconnect\"},initialize:function(e){this.listenTo(i.channel(\"dashboard\"),\"fetch:oauth\",this.updateModel)},updateModel:function(){this.model=i.channel(\"dashboard\").request(\"get:oauth\"),this.render()},events:{\"click @ui.disconnect\":function(){i.channel(\"dashboard\").request(\"disconnect:oauth\")}}})}),n(\"models/promotionModel\",[],function(){return Backbone.Model.extend({defaults:{id:\"\",content:\"\"},initialize:function(){}})}),n(\"views/promotion.js\",[\"models/promotionModel\"],function(e){return Marionette.View.extend({model:null,template:\"#tmpl-nf-promotion\",className:\"nf-promotion\",initialize:function(){var t=nfPromotions[Math.floor(Math.random()*nfPromotions.length)];this.model=new e(t)}})}),n(\"views/dashboardView\",[\"views/sections/widgets.js\",\"views/sections/services.js\",\"views/sections/apps.js\",\"views/sections/memberships.js\",\"views/oauth.js\",\"views/promotion.js\"],function(e,t,n,o,s,r){return Marionette.View.extend({template:\"#tmpl-nf-dashboard\",currentView:\"widgets\",regions:{notices:\".notices\",promotions:\".promotions\",content:\".content\"},events:{\"click .widgets a\":function(t){this.showChildView(\"content\",new e),jQuery(\".\"+this.currentView).find(\"a\").removeClass(\"active\"),t.target.classList.add(\"active\"),this.currentView=\"widgets\"},\"click .services a\":function(e){this.showChildView(\"content\",new t),jQuery(\".\"+this.currentView).find(\"a\").removeClass(\"active\"),e.target.classList.add(\"active\"),this.currentView=\"services\"},\"click .apps a\":function(e){this.showChildView(\"content\",new n),jQuery(\".\"+this.currentView).find(\"a\").removeClass(\"active\"),e.target.classList.add(\"active\"),this.currentView=\"apps\"},\"click .memberships a\":function(e){this.showChildView(\"content\",new o),jQuery(\".\"+this.currentView).find(\"a\").removeClass(\"active\"),e.target.classList.add(\"active\"),this.currentView=\"memberships\"}},initialize:function(){switch(window.location.hash){case\"#apps\":this.currentView=\"apps\";break;case\"#services\":this.currentView=\"services\";break;case\"#memberships\":this.currentView=\"memberships\";break;case\"#widgets\":default:this.currentView=\"widgets\"}i.channel(\"dashboard\").reply(\"show:widgets\",function(){this.showChildView(\"content\",new e),jQuery(\"nav.sections a.active\").removeClass(\"active\"),jQuery(\"nav.sections .widgets a\").addClass(\"active\"),this.currentView=\"widgets\"},this),i.channel(\"dashboard\").reply(\"show:services\",function(){this.showChildView(\"content\",new t),jQuery(\"nav.sections a.active\").removeClass(\"active\"),jQuery(\"nav.sections .services a\").addClass(\"active\"),this.currentView=\"services\"},this),i.channel(\"dashboard\").reply(\"show:apps\",function(){this.showChildView(\"content\",new n),jQuery(\"nav.sections a.active\").removeClass(\"active\"),jQuery(\"nav.sections .apps a\").addClass(\"active\"),this.currentView=\"apps\"},this)},onRender:function(){switch(useServices&&this.showChildView(\"notices\",new s),useServices&&this.showChildView(\"promotions\",new r),window.location.hash){case\"#apps\":var i=new n;break;case\"#memberships\":var i=new o;break;case\"#services\":var i=new t;break;case\"#widgets\":default:var i=new e}if(this.showChildView(\"content\",i),\"1\"==nfAdmin.showOptin){var a=new jBox(\"Modal\",{closeOnEsc:!1,closeOnClick:!1,width:400}),l=document.createElement(\"div\");l.id=\"optin-modal-title\";var c=document.createElement(\"h2\");c.innerHTML=\"Help make Ninja Forms better!\",l.appendChild(c);var d=document.createElement(\"div\");d.classList.add(\"message\"),d.style.padding=\"0px 20px 20px 20px\",d.innerHTML=nfi18n.optinContent;var u=document.createElement(\"p\");u.style.paddingBottom=\"10px\";var h=document.createElement(\"input\");h.id=\"optin-send-email\",h.setAttribute(\"type\",\"checkbox\"),h.style.margin=\"7px\";var m=document.createElement(\"label\");m.setAttribute(\"for\",\"optin-send-email\"),m.innerHTML=nfi18n.optinYesplease,u.appendChild(h),u.appendChild(m),d.appendChild(u),u=document.createElement(\"p\"),u.id=\"optin-block\",u.style.padding=\"0px 5px 20px 5px\",u.style.display=\"none\";var f=document.createElement(\"input\");f.id=\"optin-email-address\",f.setAttribute(\"type\",\"text\"),f.setAttribute(\"value\",nfAdmin.currentUserEmail),f.style.width=\"100%\",f.style.fontSize=\"16px\",u.appendChild(f),d.appendChild(u);var p=document.createElement(\"span\");p.id=\"optin-spinner\",p.classList.add(\"spinner\"),p.style.display=\"none\",d.appendChild(p);var w=document.createElement(\"div\");w.id=\"optin-buttons\",w.classList.add(\"buttons\");var g=document.createElement(\"div\");g.id=\"optout\",g.classList.add(\"nf-button\",\"secondary\"),g.innerHTML=nfi18n.optinSecondary,w.appendChild(g);var v=document.createElement(\"div\");v.id=\"optin\",v.classList.add(\"nf-button\",\"primary\",\"pull-right\"),v.innerHTML=nfi18n.optinPrimary,w.appendChild(v),d.appendChild(w);var b=document.createElement(\"h2\");b.innerHTML=nfi18n.optinAwesome;var y=document.createElement(\"div\");y.id=\"optin-thankyou\",y.classList.add(\"message\"),y.style.padding=\"20px\",y.innerHTML=nfi18n.optinThanks,a.setContent(document.createElement(\"div\").appendChild(d).innerHTML),a.setTitle(document.createElement(\"div\").appendChild(l).innerHTML),a.open(),jQuery(\"#optin-send-email\").click(function(e){jQuery(this).is(\":checked\")?jQuery(\"#optin-block\").show():jQuery(\"#optin-block\").hide()}),jQuery(\"#optin\").click(function(e){var t;jQuery(\"#optin-send-email\").attr(\"checked\")?(t=1,userEmail=jQuery(\"#optin-email-address\").val()):(t=0,userEmail=\"\"),jQuery(\"#optin\").unbind(\"click\"),jQuery(\"#optout\").unbind(\"click\");var n=jQuery(\"#optin\").width();jQuery(\"#optin\").html('<span class=\"dashicons dashicons-update dashicons-update-spin\"></span>'),jQuery(\"#optin\").width(n),jQuery.post(ajaxurl,{action:\"nf_optin\",ninja_forms_opt_in:1,send_email:t,user_email:userEmail},function(e){a.setTitle(document.createElement(\"div\").appendChild(b).innerHTML),a.setContent(document.createElement(\"div\").appendChild(y).innerHTML),setTimeout(function(){a.close()},2e3)})}),jQuery(\"#optout\").click(function(e){jQuery(\"#optin\").unbind(\"click\"),jQuery(\"#optout\").unbind(\"click\");var t=jQuery(\"#optout\").width();jQuery(\"#optout\").html('<span class=\"dashicons dashicons-update dashicons-update-spin\"></span>'),jQuery(\"#optout\").width(t),jQuery.post(ajaxurl,{action:\"nf_optin\",ninja_forms_opt_in:0},function(e){a.close()})})}else if(\"1\"==nfAdmin.doingCleanup)var C=this,j={width:450,closeOnClick:!1,closeOnEsc:!1,content:nfi18n.cleanupContent,useProgressBar:!0,loadingText:nfi18n.cleanupLoading,btnSecondary:{text:nfi18n.cleanupSecondary,callback:function(){x.toggleModal(!1)}},btnPrimary:{text:nfi18n.cleanupPrimary,callback:function(){jQuery(window).bind(\"beforeunload\",function(){return\"Are you sure? Leaving before the process completes could cause damage to your data.\"}),x.maybeShowActions(!1),x.maybeShowProgress(!0),C.cleanupProcess(C,-1,x)}}},x=new NinjaModal(j);if(void 0!==nfAdmin.formTelemetry&&1==nfAdmin.formTelemetry){var M={action:\"nf_form_telemetry\",security:nfAdmin.ajaxNonce};jQuery.post(ajaxurl,M)}},templateContext:function(){var e=this;return{renderNav:function(){var t=document.createElement(\"div\");return _.each(nfDashItems,function(n){var i=document.createElement(\"li\"),o=document.createElement(\"a\");o.href=\"#\"+n.slug,e.currentView==n.slug&&o.classList.add(\"active\"),o.innerHTML=n.niceName,i.classList.add(n.slug),i.appendChild(o),t.appendChild(i)}),t.innerHTML}}},cleanupProcess:function(e,t,n){var i={action:\"nf_batch_process\",batch_type:\"data_cleanup\",security:nfAdmin.batchNonce};jQuery.post(ajaxurl,i,function(i){if(i=JSON.parse(i),i.batch_complete)return n.setProgress(100),jQuery(window).unbind(\"beforeunload\"),n.toggleModal(!1),!1;-1==t&&(t=void 0!==i.step_total?i.step_total:i.step_remaining);var o=t-i.step_remaining,s=Math.round(o/t*100);n.incrementProgress(s),e.cleanupProcess(e,t,n)})}})});var i=Backbone.Radio;useServices||(nfDashItems=nfDashItems.filter(function(e){return\"services\"!==e.slug})),jQuery(document).ready(function(e){t([\"controllers/formsController\",\"controllers/oauthController\",\"controllers/servicesController\",\"views/dashboardView\"],function(t,n,i,o){(new(Marionette.Application.extend({region:\"#ninja-forms-dashboard\",controllers:{},initialize:function(e){var t=this;Marionette.Renderer.render=function(e,n){var e=t.template(e);return e(n)}},onStart:function(){this.showView(new o),this.controllers.forms=new t,useServices&&(this.controllers.oauth=new n),useServices&&(this.controllers.services=new i)},template:function(t){return _.template(e(t).html(),{evaluate:/<#([\\s\\S]+?)#>/g,interpolate:/\\{\\{\\{([\\s\\S]+?)\\}\\}\\}/g,escape:/\\{\\{([^\\}]+?)\\}\\}(?!\\})/g,variable:\"data\"})}}))).start()})}),jQuery('a[href=\"admin.php?page=ninja-forms#new-form\"]').on(\"click\",function(e){e.preventDefault(),window.location.hash=\"new-form\",i.channel(\"dashboard\").request(\"show:widgets\"),i.channel(\"widget-forms\").request(\"show:newFormsGrid\")}),jQuery('a[href=\"admin.php?page=ninja-forms#apps\"]').on(\"click\",function(e){e.preventDefault(),window.location.hash=\"apps\",i.channel(\"dashboard\").request(\"show:apps\")}),jQuery('a[href=\"admin.php?page=ninja-forms\"]').on(\"click\",function(e){e.preventDefault(),window.location.hash=\"forms\",i.channel(\"dashboard\").request(\"show:widgets\"),i.channel(\"widget-forms\").request(\"show:formsTable\")}),jQuery(window).on(\"hashchange\",function(){var e=window.location.hash.substr(1);i.channel(\"dashboard\").request(\"show:\"+e)}),n(\"main\",function(){})}();"],"file":"dashboard.min.js"}
\ No newline at end of file
{"version":3,"names":[],"mappings":"","sources":["views/widgets/forms/newFormTemplate.js"],"sourcesContent":["!function(){var e,t,n;!function(i){function o(e,t){return y.call(e,t)}function s(e,t){var n,i,o,s,r,a,l,c,d,u,h,m=t&&t.split(\"/\"),f=v.map,p=f&&f[\"*\"]||{};if(e&&\".\"===e.charAt(0))if(t){for(e=e.split(\"/\"),r=e.length-1,v.nodeIdCompat&&j.test(e[r])&&(e[r]=e[r].replace(j,\"\")),e=m.slice(0,m.length-1).concat(e),d=0;d<e.length;d+=1)if(\".\"===(h=e[d]))e.splice(d,1),d-=1;else if(\"..\"===h){if(1===d&&(\"..\"===e[2]||\"..\"===e[0]))break;d>0&&(e.splice(d-1,2),d-=2)}e=e.join(\"/\")}else 0===e.indexOf(\"./\")&&(e=e.substring(2));if((m||p)&&f){for(n=e.split(\"/\"),d=n.length;d>0;d-=1){if(i=n.slice(0,d).join(\"/\"),m)for(u=m.length;u>0;u-=1)if((o=f[m.slice(0,u).join(\"/\")])&&(o=o[i])){s=o,a=d;break}if(s)break;!l&&p&&p[i]&&(l=p[i],c=d)}!s&&l&&(s=l,a=c),s&&(n.splice(0,a,s),e=n.join(\"/\"))}return e}function r(e,t){return function(){var n=C.call(arguments,0);return\"string\"!=typeof n[0]&&1===n.length&&n.push(null),m.apply(i,n.concat([e,t]))}}function a(e){return function(t){return s(t,e)}}function l(e){return function(t){w[e]=t}}function c(e){if(o(g,e)){var t=g[e];delete g[e],b[e]=!0,h.apply(i,t)}if(!o(w,e)&&!o(b,e))throw new Error(\"No \"+e);return w[e]}function d(e){var t,n=e?e.indexOf(\"!\"):-1;return n>-1&&(t=e.substring(0,n),e=e.substring(n+1,e.length)),[t,e]}function u(e){return function(){return v&&v.config&&v.config[e]||{}}}var h,m,f,p,w={},g={},v={},b={},y=Object.prototype.hasOwnProperty,C=[].slice,j=/\\.js$/;f=function(e,t){var n,i=d(e),o=i[0];return e=i[1],o&&(o=s(o,t),n=c(o)),o?e=n&&n.normalize?n.normalize(e,a(t)):s(e,t):(e=s(e,t),i=d(e),o=i[0],e=i[1],o&&(n=c(o))),{f:o?o+\"!\"+e:e,n:e,pr:o,p:n}},p={require:function(e){return r(e)},exports:function(e){var t=w[e];return void 0!==t?t:w[e]={}},module:function(e){return{id:e,uri:\"\",exports:w[e],config:u(e)}}},h=function(e,t,n,s){var a,d,u,h,m,v,y=[],C=typeof n;if(s=s||e,\"undefined\"===C||\"function\"===C){for(t=!t.length&&n.length?[\"require\",\"exports\",\"module\"]:t,m=0;m<t.length;m+=1)if(h=f(t[m],s),\"require\"===(d=h.f))y[m]=p.require(e);else if(\"exports\"===d)y[m]=p.exports(e),v=!0;else if(\"module\"===d)a=y[m]=p.module(e);else if(o(w,d)||o(g,d)||o(b,d))y[m]=c(d);else{if(!h.p)throw new Error(e+\" missing \"+d);h.p.load(h.n,r(s,!0),l(d),{}),y[m]=w[d]}u=n?n.apply(w[e],y):void 0,e&&(a&&a.exports!==i&&a.exports!==w[e]?w[e]=a.exports:u===i&&v||(w[e]=u))}else e&&(w[e]=n)},e=t=m=function(e,t,n,o,s){if(\"string\"==typeof e)return p[e]?p[e](t):c(f(e,t).f);if(!e.splice){if(v=e,v.deps&&m(v.deps,v.callback),!t)return;t.splice?(e=t,t=n,n=null):e=i}return t=t||function(){},\"function\"==typeof n&&(n=o,o=s),o?h(i,e,t,n):setTimeout(function(){h(i,e,t,n)},4),m},m.config=function(e){return m(e)},e._defined=w,n=function(e,t,n){if(\"string\"!=typeof e)throw new Error(\"See almond README: incorrect module build, no module name\");t.splice||(n=t,t=[]),o(w,e)||o(g,e)||(g[e]=[e,t,n])},n.amd={jQuery:!0}}(),n(\"../../assets/js/lib/almond\",function(){}),n(\"models/formModel\",[],function(){return Backbone.Model.extend({defaults:{objectType:\"form\",id:0,title:\"unknown\",created_at:\"unknown\"},url:function(){return ajaxurl+\"?action=nf_forms&form_id=\"+this.get(\"id\")},initialize:function(){this.set(\"id\",Number(this.get(\"id\"))),this.get(\"id\")&&this.initShortcode(this.get(\"id\")),this.get(\"title\")&&this.set(\"title\",this.get(\"title\").replace(/<\\/?[^>]+(>|$)/g,\"\"))},initShortcode:function(e){var t=\"[ninja_form id=\"+e+\"]\";this.set(\"shortcode\",t)},destroy:function(){var e=this;jQuery.ajax({type:\"POST\",url:ajaxurl+\"?action=nf_forms&method_override=delete&form_id=\"+this.get(\"id\"),success:function(t){var t=JSON.parse(t);e.collection.remove(e)}})}})}),n(\"models/formCollection\",[\"models/formModel\"],function(e){return Backbone.Collection.extend({model:e,comparator:\"title\",tmpNum:1,url:function(){return ajaxurl+\"?action=nf_forms\"},initialize:function(){this.newIDs=[],this.baseUrl=window.location.href.split(\"?\")[0],this.listenTo(i.channel(\"dashboard\"),\"forms:delete\",this.modalConfirm),this.listenTo(i.channel(\"dashboard\"),\"forms:duplicate\",this.duplicate),this.modal=new jBox(\"Modal\",{width:400,addClass:\"dashboard-modal\",overlay:!0,closeOnClick:\"body\"})},parse:function(e,t){return e.data},modalConfirm:function(e){var t,n,i,o,s,r,a,l=e.model.get(\"id\"),c=e.model.get(\"title\");n=document.createElement(\"div\"),n.style.paddingRight=\"20px\",n.style.paddingLeft=\"20px\",n.style.paddingBottom=\"20px\",i=document.createElement(\"p\"),o=document.createElement(\"em\"),s=document.createElement(\"div\"),r=document.createElement(\"button\"),a=document.createElement(\"div\"),n.classList.add(\"message\"),o.innerHTML=c,i.innerHTML+=nfi18n.deleteWarningA+\" (<strong>\"+c+\"</strong>). \"+nfi18n.deleteWarningB,i.appendChild(document.createElement(\"br\")),i.appendChild(document.createElement(\"br\"));var d=document.createElement(\"a\");d.href=this.baseUrl+\"?page=nf-import-export&exportFormId=\"+l,d.innerHTML='<i class=\"fa fa-download\" style=\"padding:5px;\"></i>'+nfi18n.deleteXForm,d.target=\"_blank\",i.appendChild(d),i.appendChild(document.createElement(\"br\"));var u=document.createElement(\"a\");u.href=this.baseUrl+\"?page=nf-processing&action=download_all_subs&form_id=\"+l+\"&redirect=\"+encodeURIComponent(this.baseUrl.replace(\"admin.php\",\"edit.php\")+\"?post_status=all&post_type=nf_sub&form_id=\"+l),u.target=\"_blank\",u.innerHTML='<i class=\"fa fa-download\" style=\"padding:5px;\"></i>'+nfi18n.deleteXSubs,i.appendChild(u),i.appendChild(document.createElement(\"br\")),n.appendChild(i);var h=document.createElement(\"label\");h.for=\"confirmDeleteFormInput\",h.innerHTML=nfi18n.deleteConfirmA+' <span style=\"color:red;\">DELETE</span> '+nfi18n.deleteConfirmB;var m=document.createElement(\"input\");m.type=\"text\",m.id=\"confirmDeleteFormInput\",m.style.marginTop=\"10px\",m.style.width=\"100%\",m.style.height=\"2.5em\",m.style.fontSize=\"1em\",n.appendChild(h),n.appendChild(document.createElement(\"br\")),n.appendChild(m),n.appendChild(document.createElement(\"br\")),n.appendChild(document.createElement(\"br\")),r.innerHTML=nfi18n.delete,r.classList.add(\"confirm\",\"nf-button\",\"primary\",\"pull-right\"),a.innerHTML=nfi18n.cancel,a.classList.add(\"cancel\",\"nf-button\",\"secondary\"),s.appendChild(a),s.appendChild(r),s.classList.add(\"buttons\"),n.appendChild(s),t=document.createElement(\"div\"),t.appendChild(n),this.modal.setContent(t.innerHTML),this.modal.setTitle(nfi18n.deleteTitle),this.modal.open();var f=this;this.modal.container[0].getElementsByClassName(\"cancel\")[0].addEventListener(\"click\",function(){f.modalClose()}),this.modal.container[0].getElementsByClassName(\"confirm\")[0].addEventListener(\"click\",function(t){t.preventDefault(),\"DELETE\"===document.getElementById(\"confirmDeleteFormInput\").value?f.confirmDelete(e):f.modalClose()})},modalClose:function(){this.modal.close()},confirmDelete:function(e){jQuery(e.el).removeClass(\"show-actions\"),jQuery(e.el).addClass(\"deleting\"),jQuery(e.el).animate({opacity:0,\"line-height\":0,display:\"none\"},500),console.log(e),e.model.destroy(),this.modalClose()},duplicate:function(e){var t='<div class=\"message\">Duplicating <em>'+e.model.get(\"title\")+'</em>...<div class=\"nf-loading-spinner\"></div></div>';this.modal.setContent(t),this.modal.setTitle(\"Please Wait\"),this.modal.open();var n=this;jQuery.ajax({type:\"POST\",url:ajaxurl+\"?action=nf_forms&clone_id=\"+e.model.get(\"id\"),success:function(t){var t=JSON.parse(t),i=t.data.new_form_id,o=e.model.clone();o.set({id:i,title:o.get(\"title\")+\" - copy\",created_at:new Date}),o.initShortcode(i),e.model.collection.add(o),n.modalClose()}})}})}),n(\"controllers/formsController\",[\"models/formModel\",\"models/formCollection\"],function(e,t){return Marionette.Object.extend({initialize:function(){this.forms=new t,i.channel(\"dashboard\").reply(\"get:forms\",this.getForms,this),this.forms.fetch({success:function(e){i.channel(\"dashboard\").trigger(\"fetch:forms\",e)}})},getForms:function(){return this.forms}})}),n(\"models/oauthModel\",[],function(){return Backbone.Model.extend({defaults:{connected:null,connect_url:\"\"},url:function(){return ajaxurl+\"?action=nf_oauth\"},initialize:function(){},parse:function(e,t){return e.data}})}),n(\"controllers/oauthController\",[\"models/oauthModel\"],function(e){return Marionette.Object.extend({initialize:function(){this.oauth=new e,i.channel(\"dashboard\").reply(\"get:oauth\",this.getOAuth,this),i.channel(\"dashboard\").reply(\"disconnect:oauth\",this.disconnect,this),i.channel(\"dashboard\").reply(\"oauth:learn-more\",this.learnMoreModal,this),this.initOAuth()},getOAuth:function(){return this.oauth},initOAuth:function(){this.oauth.fetch({success:function(e){i.channel(\"dashboard\").trigger(\"fetch:oauth\")}})},disconnect:function(){var e=this;new jBox(\"Confirm\",{width:750,content:nfi18n.oauthDisconnectContent,confirmButton:nfi18n.oauthDisconnectConfirm,cancelButton:nfi18n.oauthDisconnectCancel,closeOnConfirm:!0,confirm:function(){jQuery.ajax({type:\"POST\",url:ajaxurl+\"?action=nf_oauth_disconnect\",success:function(t){console.log(t),e.initOAuth()}})}}).open()},learnMoreModal:function(){new jBox(\"Modal\",{width:500,content:nfi18n.oauthLearnMoreContent}).open()}})}),n(\"models/serviceModel\",[],function(){return Backbone.Model.extend({defaults:{objectType:\"service\",name:\"\",slug:\"\",installPath:\"\",description:\"\",enabled:null,infoLink:null,serviceLink:null,is_installing:!1,classes:\"\"},url:function(){return ajaxurl+\"?action=nf_service_\"+this.get(\"slug\")},initialize:function(){this.get(\"slug\")==serviceSuccess&&this.get(\"successMessage\")&&new jBox(\"Modal\",{width:300,addClass:\"dashboard-modal\",overlay:!0,closeOnClick:!0,content:this.get(\"successMessage\"),title:this.get(\"successMessageTitle\"),closeButton:\"box\"}).open();var e=this;i.channel(\"dashboard\").reply(\"install:service:\"+this.get(\"slug\"),function(){if(e.get(\"serviceLink\")&&e.get(\"serviceLink\").href){var t=e.get(\"serviceLink\").href;new jBox(\"Modal\",{width:300,addClass:\"dashboard-modal\",overlay:!0,closeOnClick:\"body\",content:nfi18n.serviceRedirect}).open();var n=i.channel(\"dashboard\").request(\"get:oauth\");if(n.get(\"connected\"))window.location=t;else{if(e.get(\"connect_url\"))return window.location=e.get(\"connect_url\")+\"&redirect=\"+t;window.location=n.get(\"connect_url\")+\"&redirect=\"+t}}})},save:function(){var e=this;jQuery.ajax({type:\"POST\",url:this.url(),data:this.toJSON()}).done(function(t){var n=JSON.parse(t);void 0!==n.error&&(alert(nfi18n.serviceUpdateError+\" \"+n.error),e.set(\"enabled\",!e.get(\"enabled\"))),i.channel(\"dashboard\").trigger(\"save:service-\"+e.get(\"slug\"))})}})}),n(\"models/serviceCollection\",[\"models/serviceModel\"],function(e){return Backbone.Collection.extend({model:e,comparator:\"name\",url:function(){return ajaxurl+\"?action=nf_services\"},initialize:function(){},parse:function(e,t){return e.data}})}),n(\"controllers/servicesController\",[\"models/serviceCollection\"],function(e){return Marionette.Object.extend({initialize:function(){this.services=new e,i.channel(\"dashboard\").reply(\"install:service\",this.installService,this),i.channel(\"dashboard\").reply(\"get:services\",this.getServices,this),this.fetchServices()},getServices:function(){return this.services},fetchServices:function(e){this.services.fetch({success:function(t){e&&e(t),i.channel(\"dashboard\").trigger(\"fetch:services\")}})},installService:function(e){var t=this;if(!(e instanceof Backbone.Model))var e=this.services.find(function(t){return e==t.get(\"slug\")});e.set(\"is_installing\",!0);var n=e.get(\"slug\"),o=e.get(\"installPath\");jQuery.post(ajaxurl,{action:\"nf_services_install\",plugin:n,install_path:o},function(e){t.fetchServices(function(){i.channel(\"dashboard\").request(\"install:service:\"+n)})})}})}),n(\"views/widgets/forms/formsFilter\",[],function(){return Marionette.View.extend({template:\"#tmpl-nf-widget-forms-filter\",ui:{input:\"input\"},events:{\"keyup @ui.input\":\"updateFilter\"},initialize:function(){this.listenTo(i.channel(\"widget-forms\"),\"change:content\",this.clearFilter)},updateFilter:function(){var e=this.getUI(\"input\").val();i.channel(\"widget-forms\").trigger(\"update:filter\",e)},clearFilter:function(){this.getUI(\"input\").val(\"\")},updatePlaceholder:function(e){this.getUI(\"input\").attr(\"placeholder\",e)}})}),n(\"views/widgets/forms/formsTableRow\",[],function(){return Marionette.View.extend({template:\"#tmpl-nf-widget-forms-table-row\",tagName:\"tr\",replaceElement:!0,ui:{delete:\".delete\",duplicate:\".duplicate\",edit:\".nf-item-edit\"},events:{\"click @ui.delete\":function(){i.channel(\"dashboard\").trigger(\"forms:delete\",this)},\"click @ui.duplicate\":function(){i.channel(\"dashboard\").trigger(\"forms:duplicate\",this)},\"click @ui.edit\":function(e){this.$el.toggleClass(\"show-actions\").siblings().removeClass(\"show-actions\")}},templateContext:function(){var e=this.model;return{created_at:moment(e.get(\"created_at\")).format(\"MM/DD/YY h:mm A\")}}})}),n(\"views/widgets/forms/formsTableEmpty\",[],function(){return Marionette.View.extend({template:\"#tmpl-nf-widget-forms-table-empty\",tagName:\"tr\"})}),n(\"views/widgets/forms/formsTableBody\",[\"views/widgets/forms/formsTableRow\",\"views/widgets/forms/formsTableEmpty\"],function(e,t){return Marionette.CollectionView.extend({childView:e,emptyView:t,className:\"forms-collection\",tagName:\"tbody\",initialize:function(){this.listenTo(i.channel(\"widget-forms\"),\"update:filter\",this.updateFilter)},updateFilter:function(e){this.setFilter(function(t,n,i){return 0<=t.get(\"title\").toLowerCase().indexOf(e.toLowerCase())})}})}),n(\"views/widgets/forms/formsTableLoading\",[],function(){return Marionette.View.extend({template:\"#tmpl-nf-widget-forms-table-loading\",tagName:\"tr\"})}),n(\"views/widgets/forms/formsTable\",[\"views/widgets/forms/formsTableBody\",\"views/widgets/forms/formsTableLoading\",\"models/formCollection\"],function(e,t,n){return Marionette.View.extend({template:\"#tmpl-nf-widget-forms-table\",className:\"nf-table-display\",tagName:\"table\",initialize:function(){var t=this;this.listenTo(i.channel(\"dashboard\"),\"fetch:forms\",function(n){t.showChildView(\"body\",new e({collection:n}))})},regions:{body:{el:\"tbody\",replaceElement:!0}},ui:{sortable:\".sortable\",body:\"tbody\",action2:\".action2\",more:\".more\",less:\".less\"},onRender:function(){this.getUI(\"less\").hide();var n=i.channel(\"dashboard\").request(\"get:forms\");void 0===n?this.showChildView(\"body\",new t):this.showChildView(\"body\",new e({collection:n})),this.maybeHideMoreButton()},events:{\"click @ui.sortable\":\"sortFormsTable\",\"click @ui.more\":\"showMore\",\"click @ui.less\":\"showLess\"},sortFormsTable:function(e){this.getUI(\"sortable\").removeClass(\"sorted-asc\"),this.getUI(\"sortable\").removeClass(\"sorted-desc\");var t=jQuery(e.target).data(\"sort\"),n=jQuery(e.target).data(\"reverse\")||0;n?(jQuery(e.target).addClass(\"sorted-desc\"),jQuery(e.target).removeClass(\"sorted-asc\")):(jQuery(e.target).addClass(\"sorted-asc\"),jQuery(e.target).removeClass(\"sorted-desc\"));var i=this.getChildView(\"body\").collection;i.comparator=function(e,i){return name1=e.get(t).toLowerCase(),name2=i.get(t).toLowerCase(),name1<name2?ret=-1:name1>name2?ret=1:ret=0,n&&(ret=-ret),ret},i.sort(),n?(i.models.reverse(),jQuery(e.target).data(\"reverse\",0)):jQuery(e.target).data(\"reverse\",1)},showMore:function(){this.getUI(\"more\").hide(),this.getUI(\"less\").show(),this.getUI(\"body\").addClass(\"more\")},showLess:function(){this.getUI(\"less\").hide(),this.getUI(\"more\").show(),this.getUI(\"body\").removeClass(\"more\")},maybeHideMoreButton:function(){void 0!==this.collection&&10<this.collection.length||this.getUI(\"action2\").hide()}})}),n(\"models/formTemplateModel\",[],function(){return Backbone.Model.extend({defaults:{objectType:\"template\",id:\"none\",title:\"unknown\",type:\"\"},initialize:function(){this.set(\"desc\",this.get(\"template-desc\")),this.set(\"modal-content\",this.get(\"modal-content\")),this.set(\"modal-title\",this.get(\"modal-title\"))}})}),n(\"models/formTemplateCollection\",[\"models/formTemplateModel\"],function(e){return Backbone.Collection.extend({model:e,tmpNum:1,url:function(){return ajaxurl+\"?action=nf_new_form_templates\"},parse:function(e,t){return e.data},initialize:function(){this.fetch({success:function(e){},error:function(e){}})}})}),n(\"views/widgets/forms/newFormTemplate\",[],function(){return Marionette.View.extend({template:\"#tmpl-nf-widget-forms-template\",events:{click:\"maybeOpenModal\"},maybeOpenModal:function(e){if(\"ad\"!=this.model.get(\"type\"))return!0;e.preventDefault(),new jBox(\"Modal\",{width:450,title:this.model.get(\"modal-title\"),content:this.model.get(\"modal-content\"),closeButton:\"box\",blockScroll:!0}).open()}})}),n(\"views/widgets/forms/newFormGrid\",[\"models/formTemplateCollection\",\"views/widgets/forms/newFormTemplate\"],function(e,t){return Marionette.CollectionView.extend({tagName:\"div\",className:\"template-list\",collection:new e,childView:t,initialize:function(){this.listenTo(i.channel(\"widget-forms\"),\"update:filter\",this.updateFilter)},updateFilter:function(e){this.setFilter(function(t,n,i){return 0<=t.get(\"title\").toLowerCase().indexOf(e.toLowerCase())})}})}),n(\"views/widgets/forms/forms\",[\"views/widgets/forms/formsFilter\",\"views/widgets/forms/formsTable\",\"views/widgets/forms/newFormGrid\"],function(e,t,n){return Marionette.View.extend({template:\"#tmpl-nf-widget-forms\",regions:{filter:\".filter\",content:\".content\"},ui:{add:\".add\",cancel:\".cancel\"},initialize:function(){i.channel(\"widget-forms\").reply(\"show:newFormsGrid\",this.showNewFormGrid,this),i.channel(\"widget-forms\").reply(\"show:formsTable\",this.showFormsTable,this)},onRender:function(){this.getUI(\"cancel\").hide(),this.showChildView(\"filter\",new e),\"#new-form\"==window.location.hash?(this.getUI(\"add\").hide(),this.getUI(\"cancel\").show(),this.showChildView(\"content\",new n)):this.showChildView(\"content\",new t)},events:{\"click @ui.add\":\"showNewFormGrid\",\"click @ui.cancel\":\"showFormsTable\"},showNewFormGrid:function(){window.location.hash=\"new-form\",this.showChildView(\"content\",new n),i.channel(\"widget-forms\").trigger(\"change:content\"),this.getUI(\"add\").hide(),this.getUI(\"cancel\").show(),this.getChildView(\"filter\").updatePlaceholder(\"Search Templates\")},showFormsTable:function(){console.log(this),window.location.hash=\"forms\",this.showChildView(\"content\",new t),i.channel(\"widget-forms\").trigger(\"change:content\"),this.getUI(\"cancel\").hide(),this.getUI(\"add\").show(),this.getChildView(\"filter\").updatePlaceholder(\"Search Forms\")}})}),n(\"views/sections/widgets.js\",[\"views/widgets/forms/forms\"],function(e){return Marionette.View.extend({template:\"#tmpl-nf-widgets\",regions:{forms:\".widget-forms\"},onRender:function(){this.showChildView(\"forms\",new e)}})}),n(\"views/services/service\",[],function(){return Marionette.View.extend({template:\"#tmpl-nf-service\",className:function(){return\"nf-extend nf-box \"+this.model.get(\"classes\")},ui:{install:\".js--install\",learnMore:\".js--learn-more\",enabled:\".nf-toggle.setting\",toggleEnable:\".nf-toggle + label\"},events:{\"click @ui.install\":function(){i.channel(\"dashboard\").request(\"install:service\",this.model)},\"click @ui.learnMore\":function(){this.showLearnMore()},\"click @ui.toggleEnable\":function(){if(null==this.model.get(\"enabled\")&&this.model.get(\"link\"))return window.location=this.model.get(\"link\"),this.render();this.model.set(\"enabled\",!this.model.get(\"enabled\")),this.model.save(\"enabled\"),this.render()}},initialize:function(e){this.updateOAuth(),this.listenTo(this.model,\"change\",this.render),i.channel(\"dashboard\").reply(\"more:service:\"+this.model.get(\"slug\"),this.showLearnMore,this),this.listenTo(i.channel(\"dashboard\"),\"fetch:oauth\",this.updateOAuth),this.listenTo(i.channel(\"dashboard\"),\"save:service-\"+this.model.get(\"slug\"),this.render)},showLearnMore:function(){var e=new jBox(\"Modal\",{width:750,title:this.model.get(\"learnMoreTitle\")||this.model.get(\"name\"),content:this.model.get(\"learnMore\"),closeButton:\"box\",blockScroll:!0});e.open(),i.channel(\"dashboard\").reply(\"service:\"+this.model.get(\"slug\")+\":modal\",function(){return e})},updateOAuth:function(){var e=i.channel(\"dashboard\").request(\"get:oauth\");this.connected=e.get(\"connected\"),this.render()},templateContext:function(){return{is_connected:this.connected}}})}),n(\"views/services/services\",[\"views/services/service\",\"models/serviceCollection\"],function(e,t){return Marionette.CollectionView.extend({collection:new t,className:\"wrap apps-container\",childView:e,initialize:function(){this.updateCollection(),this.listenTo(i.channel(\"dashboard\"),\"fetch:services\",this.updateCollection)},updateCollection:function(){this.collection=i.channel(\"dashboard\").request(\"get:services\"),this.render()}})}),n(\"views/sections/services.js\",[\"views/services/services\"],function(e){return Marionette.View.extend({template:\"#tmpl-nf-services\",regions:{services:\".services\"},onRender:function(){this.showChildView(\"services\",new e)}})}),n(\"views/sections/apps.js\",[],function(){return Marionette.View.extend({template:\"#tmpl-nf-apps\"})}),n(\"views/sections/memberships.js\",[],function(){return Marionette.View.extend({template:\"#tmpl-nf-memberships\"})}),n(\"views/oauth.js\",[\"models/oauthModel\"],function(e){return Marionette.View.extend({model:new e,template:\"#tmpl-nf-notices-oauth\",className:\"nf-notices--oauth\",ui:{disconnect:\".js--disconnect\"},initialize:function(e){this.listenTo(i.channel(\"dashboard\"),\"fetch:oauth\",this.updateModel)},updateModel:function(){this.model=i.channel(\"dashboard\").request(\"get:oauth\"),this.render()},events:{\"click @ui.disconnect\":function(){i.channel(\"dashboard\").request(\"disconnect:oauth\")}}})}),n(\"models/promotionModel\",[],function(){return Backbone.Model.extend({defaults:{id:\"\",content:\"\"},initialize:function(){}})}),n(\"views/promotion.js\",[\"models/promotionModel\"],function(e){return Marionette.View.extend({model:null,template:\"#tmpl-nf-promotion\",className:\"nf-promotion\",initialize:function(){var t=nfPromotions[Math.floor(Math.random()*nfPromotions.length)];this.model=new e(t)}})}),n(\"views/dashboardView\",[\"views/sections/widgets.js\",\"views/sections/services.js\",\"views/sections/apps.js\",\"views/sections/memberships.js\",\"views/oauth.js\",\"views/promotion.js\"],function(e,t,n,o,s,r){return Marionette.View.extend({template:\"#tmpl-nf-dashboard\",currentView:\"widgets\",regions:{notices:\".notices\",promotions:\".promotions\",content:\".content\"},events:{\"click .widgets a\":function(t){this.showChildView(\"content\",new e),jQuery(\".\"+this.currentView).find(\"a\").removeClass(\"active\"),t.target.classList.add(\"active\"),this.currentView=\"widgets\"},\"click .services a\":function(e){this.showChildView(\"content\",new t),jQuery(\".\"+this.currentView).find(\"a\").removeClass(\"active\"),e.target.classList.add(\"active\"),this.currentView=\"services\"},\"click .apps a\":function(e){this.showChildView(\"content\",new n),jQuery(\".\"+this.currentView).find(\"a\").removeClass(\"active\"),e.target.classList.add(\"active\"),this.currentView=\"apps\"},\"click .memberships a\":function(e){this.showChildView(\"content\",new o),jQuery(\".\"+this.currentView).find(\"a\").removeClass(\"active\"),e.target.classList.add(\"active\"),this.currentView=\"memberships\"}},initialize:function(){switch(window.location.hash){case\"#apps\":this.currentView=\"apps\";break;case\"#services\":this.currentView=\"services\";break;case\"#memberships\":this.currentView=\"memberships\";break;case\"#widgets\":default:this.currentView=\"widgets\"}i.channel(\"dashboard\").reply(\"show:widgets\",function(){this.showChildView(\"content\",new e),jQuery(\"nav.sections a.active\").removeClass(\"active\"),jQuery(\"nav.sections .widgets a\").addClass(\"active\"),this.currentView=\"widgets\"},this),i.channel(\"dashboard\").reply(\"show:services\",function(){this.showChildView(\"content\",new t),jQuery(\"nav.sections a.active\").removeClass(\"active\"),jQuery(\"nav.sections .services a\").addClass(\"active\"),this.currentView=\"services\"},this),i.channel(\"dashboard\").reply(\"show:apps\",function(){this.showChildView(\"content\",new n),jQuery(\"nav.sections a.active\").removeClass(\"active\"),jQuery(\"nav.sections .apps a\").addClass(\"active\"),this.currentView=\"apps\"},this)},onRender:function(){switch(useServices&&this.showChildView(\"notices\",new s),useServices&&this.showChildView(\"promotions\",new r),window.location.hash){case\"#apps\":var i=new n;break;case\"#memberships\":var i=new o;break;case\"#services\":var i=new t;break;case\"#widgets\":default:var i=new e}if(this.showChildView(\"content\",i),\"1\"==nfAdmin.showOptin){var a=new jBox(\"Modal\",{closeOnEsc:!1,closeOnClick:!1,width:400}),l=document.createElement(\"div\");l.id=\"optin-modal-title\";var c=document.createElement(\"h2\");c.innerHTML=\"Help make Ninja Forms better!\",l.appendChild(c);var d=document.createElement(\"div\");d.classList.add(\"message\"),d.style.padding=\"0px 20px 20px 20px\",d.innerHTML=nfi18n.optinContent;var u=document.createElement(\"p\");u.style.paddingBottom=\"10px\";var h=document.createElement(\"input\");h.id=\"optin-send-email\",h.setAttribute(\"type\",\"checkbox\"),h.style.margin=\"7px\";var m=document.createElement(\"label\");m.setAttribute(\"for\",\"optin-send-email\"),m.innerHTML=nfi18n.optinYesplease,u.appendChild(h),u.appendChild(m),d.appendChild(u),u=document.createElement(\"p\"),u.id=\"optin-block\",u.style.padding=\"0px 5px 20px 5px\",u.style.display=\"none\";var f=document.createElement(\"input\");f.id=\"optin-email-address\",f.setAttribute(\"type\",\"text\"),f.setAttribute(\"value\",nfAdmin.currentUserEmail),f.style.width=\"100%\",f.style.fontSize=\"16px\",u.appendChild(f),d.appendChild(u);var p=document.createElement(\"span\");p.id=\"optin-spinner\",p.classList.add(\"spinner\"),p.style.display=\"none\",d.appendChild(p);var w=document.createElement(\"div\");w.id=\"optin-buttons\",w.classList.add(\"buttons\");var g=document.createElement(\"div\");g.id=\"optout\",g.classList.add(\"nf-button\",\"secondary\"),g.innerHTML=nfi18n.optinSecondary,w.appendChild(g);var v=document.createElement(\"div\");v.id=\"optin\",v.classList.add(\"nf-button\",\"primary\",\"pull-right\"),v.innerHTML=nfi18n.optinPrimary,w.appendChild(v),d.appendChild(w);var b=document.createElement(\"h2\");b.innerHTML=nfi18n.optinAwesome;var y=document.createElement(\"div\");y.id=\"optin-thankyou\",y.classList.add(\"message\"),y.style.padding=\"20px\",y.innerHTML=nfi18n.optinThanks,a.setContent(document.createElement(\"div\").appendChild(d).innerHTML),a.setTitle(document.createElement(\"div\").appendChild(l).innerHTML),a.open(),jQuery(\"#optin-send-email\").click(function(e){jQuery(this).is(\":checked\")?jQuery(\"#optin-block\").show():jQuery(\"#optin-block\").hide()}),jQuery(\"#optin\").click(function(e){var t;jQuery(\"#optin-send-email\").attr(\"checked\")?(t=1,userEmail=jQuery(\"#optin-email-address\").val()):(t=0,userEmail=\"\"),jQuery(\"#optin\").unbind(\"click\"),jQuery(\"#optout\").unbind(\"click\");var n=jQuery(\"#optin\").width();jQuery(\"#optin\").html('<span class=\"dashicons dashicons-update dashicons-update-spin\"></span>'),jQuery(\"#optin\").width(n),jQuery.post(ajaxurl,{action:\"nf_optin\",ninja_forms_opt_in:1,send_email:t,user_email:userEmail},function(e){a.setTitle(document.createElement(\"div\").appendChild(b).innerHTML),a.setContent(document.createElement(\"div\").appendChild(y).innerHTML),setTimeout(function(){a.close()},2e3)})}),jQuery(\"#optout\").click(function(e){jQuery(\"#optin\").unbind(\"click\"),jQuery(\"#optout\").unbind(\"click\");var t=jQuery(\"#optout\").width();jQuery(\"#optout\").html('<span class=\"dashicons dashicons-update dashicons-update-spin\"></span>'),jQuery(\"#optout\").width(t),jQuery.post(ajaxurl,{action:\"nf_optin\",ninja_forms_opt_in:0},function(e){a.close()})})}else if(\"1\"==nfAdmin.doingCleanup)var C=this,j={width:450,closeOnClick:!1,closeOnEsc:!1,content:nfi18n.cleanupContent,useProgressBar:!0,loadingText:nfi18n.cleanupLoading,btnSecondary:{text:nfi18n.cleanupSecondary,callback:function(){x.toggleModal(!1)}},btnPrimary:{text:nfi18n.cleanupPrimary,callback:function(){jQuery(window).bind(\"beforeunload\",function(){return\"Are you sure? Leaving before the process completes could cause damage to your data.\"}),x.maybeShowActions(!1),x.maybeShowProgress(!0),C.cleanupProcess(C,-1,x)}}},x=new NinjaModal(j);if(void 0!==nfAdmin.formTelemetry&&1==nfAdmin.formTelemetry){var M={action:\"nf_form_telemetry\",security:nfAdmin.ajaxNonce};jQuery.post(ajaxurl,M)}},templateContext:function(){var e=this;return{renderNav:function(){var t=document.createElement(\"div\");return _.each(nfDashItems,function(n){var i=document.createElement(\"li\"),o=document.createElement(\"a\");o.href=\"#\"+n.slug,e.currentView==n.slug&&o.classList.add(\"active\"),o.innerHTML=n.niceName,i.classList.add(n.slug),i.appendChild(o),t.appendChild(i)}),t.innerHTML}}},cleanupProcess:function(e,t,n){var i={action:\"nf_batch_process\",batch_type:\"data_cleanup\",security:nfAdmin.batchNonce};jQuery.post(ajaxurl,i,function(i){if(i=JSON.parse(i),i.batch_complete)return n.setProgress(100),jQuery(window).unbind(\"beforeunload\"),n.toggleModal(!1),!1;-1==t&&(t=void 0!==i.step_total?i.step_total:i.step_remaining);var o=t-i.step_remaining,s=Math.round(o/t*100);n.incrementProgress(s),e.cleanupProcess(e,t,n)})}})});var i=Backbone.Radio;useServices||(nfDashItems=nfDashItems.filter(function(e){return\"services\"!==e.slug})),jQuery(document).ready(function(e){t([\"controllers/formsController\",\"controllers/oauthController\",\"controllers/servicesController\",\"views/dashboardView\"],function(t,n,i,o){(new(Marionette.Application.extend({region:\"#ninja-forms-dashboard\",controllers:{},initialize:function(e){var t=this;Marionette.Renderer.render=function(e,n){var e=t.template(e);return e(n)}},onStart:function(){this.showView(new o),this.controllers.forms=new t,useServices&&(this.controllers.oauth=new n),useServices&&(this.controllers.services=new i)},template:function(t){return _.template(e(t).html(),{evaluate:/<#([\\s\\S]+?)#>/g,interpolate:/\\{\\{\\{([\\s\\S]+?)\\}\\}\\}/g,escape:/\\{\\{([^\\}]+?)\\}\\}(?!\\})/g,variable:\"data\"})}}))).start()})}),jQuery('a[href=\"admin.php?page=ninja-forms#new-form\"]').on(\"click\",function(e){e.preventDefault(),window.location.hash=\"new-form\",i.channel(\"dashboard\").request(\"show:widgets\"),i.channel(\"widget-forms\").request(\"show:newFormsGrid\")}),jQuery('a[href=\"admin.php?page=ninja-forms#apps\"]').on(\"click\",function(e){e.preventDefault(),window.location.hash=\"apps\",i.channel(\"dashboard\").request(\"show:apps\")}),jQuery('a[href=\"admin.php?page=ninja-forms\"]').on(\"click\",function(e){e.preventDefault(),window.location.hash=\"forms\",i.channel(\"dashboard\").request(\"show:widgets\"),i.channel(\"widget-forms\").request(\"show:formsTable\")}),jQuery(window).on(\"hashchange\",function(){var e=window.location.hash.substr(1);i.channel(\"dashboard\").request(\"show:\"+e)}),n(\"main\",function(){})}();"],"file":"dashboard.min.js"}
\ No newline at end of file
File mode changed from 100644 to 100755
File mode changed from 100755 to 100644
File mode changed from 100644 to 100755
......@@ -44,7 +44,7 @@ define( ['models/formModel'], function( FormModel ) {
messageBox = document.createElement( 'p' );
title = document.createElement( 'em' );
buttons = document.createElement( 'div' );
confirm = document.createElement( 'div' );
confirm = document.createElement( 'button' );
cancel = document.createElement( 'div' );
container.classList.add( 'message' );
......@@ -121,9 +121,10 @@ define( ['models/formModel'], function( FormModel ) {
} );
var btnConfirm = this.modal.container[0].getElementsByClassName('confirm')[0];
btnConfirm.addEventListener('click', function() {
btnConfirm.addEventListener('click', function( e ) {
e.preventDefault();
var deleteInputVal = document.getElementById( 'confirmDeleteFormInput' ).value;
if( 'DELETE' === deleteInputVal ) {
that.confirmDelete(view);
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment