Your IP : 216.73.216.164


Current Path : /var/www/html/soar-backup/wp-content/plugins/gravityforms/js/
Upload File :
Current File : /var/www/html/soar-backup/wp-content/plugins/gravityforms/js/shortcode-ui.min.js

var GformShortcodeUI;!function(a,b){var c=window.GformShortcodeUI={models:{},collections:{},views:{},utils:{},strings:{}};c.models.ShortcodeAttribute=Backbone.Model.extend({defaults:{attr:"",label:"",type:"",section:"",description:"",default:"",value:""}}),c.models.ShortcodeAttributes=Backbone.Collection.extend({model:c.models.ShortcodeAttribute,clone:function(){return new this.constructor(_.map(this.models,function(a){return a.clone()}))}}),c.models.Shortcode=Backbone.Model.extend({defaults:{label:"",shortcode_tag:"",action_tag:"",attrs:c.models.ShortcodeAttributes},set:function(a,b){return void 0===a.attrs||a.attrs instanceof c.models.ShortcodeAttributes||(_.each(a.attrs,function(a){void 0!=a.default&&(a.value=a.default)}),a.attrs=new c.models.ShortcodeAttributes(a.attrs)),Backbone.Model.prototype.set.call(this,a,b)},toJSON:function(a){return a=Backbone.Model.prototype.toJSON.call(this,a),void 0!==a.attrs&&a.attrs instanceof c.models.ShortcodeAttributes&&(a.attrs=a.attrs.toJSON()),a},clone:function(){var a=Backbone.Model.prototype.clone.call(this);return a.set("attrs",a.get("attrs").clone()),a},formatShortcode:function(){var a,b,c=[];return this.get("attrs").each(function(a){var d=a.get("value"),e=a.get("type"),f=a.get("default");(!d||d.length<1)&&"checkbox"!=e||"checkbox"==e&&"true"!=f&&!d||("content"===a.get("attr")?b=a.get("value"):c.push(a.get("attr")+'="'+d+'"'))}),a="[{{ shortcode }} {{ attributes }}]",b&&b.length>0&&(a+="{{ content }}[/{{ shortcode }}]"),a=a.replace(/{{ shortcode }}/g,this.get("shortcode_tag")),a=a.replace(/{{ attributes }}/g,c.join(" ")),a=a.replace(/{{ content }}/g,b)},validate:function(a){var b=[];return a.attrs.findWhere({attr:"id"}).get("value")||b.push({id:c.strings.pleaseSelectAForm}),b.length?b:null}}),c.collections.Shortcodes=Backbone.Collection.extend({model:c.models.Shortcode}),c.views.editShortcodeForm=wp.Backbone.View.extend({el:"#gform-shortcode-ui-container",template:wp.template("gf-shortcode-default-edit-form"),hasAdvancedValue:!1,events:{"click #gform-update-shortcode":"insertShortcode","click #gform-insert-shortcode":"insertShortcode","click #gform-cancel-shortcode":"cancelShortcode"},initialize:function(){_.bindAll(this,"beforeRender","render","afterRender");var a=this;this.render=_.wrap(this.render,function(b){return a.beforeRender(),b(),a.afterRender(),a}),this.model.get("attrs").each(function(b){switch(b.get("section")){case"required":a.views.add(".gf-edit-shortcode-form-required-attrs",new c.views.editAttributeField({model:b,parent:a}));break;case"standard":a.views.add(".gf-edit-shortcode-form-standard-attrs",new c.views.editAttributeField({model:b,parent:a}));break;default:a.views.add(".gf-edit-shortcode-form-advanced-attrs",new c.views.editAttributeField({model:b,parent:a})),a.hasAdvancedVal||(a.hasAdvancedVal=""!==b.get("value"))}}),this.listenTo(this.model,"change",this.render)},beforeRender:function(){},afterRender:function(){gform_initialize_tooltips(),b("#gform-insert-shortcode").toggle("insert"==this.options.viewMode),b("#gform-update-shortcode").toggle("insert"!=this.options.viewMode),b("#gf-edit-shortcode-form-advanced-attrs").toggle(this.hasAdvancedVal)},insertShortcode:function(a){this.model.isValid({validate:!0})?(send_to_editor(this.model.formatShortcode()),tb_remove(),this.dispose()):_.each(this.model.validationError,function(a){_.each(a,function(a,b){alert(a)})})},cancelShortcode:function(a){tb_remove(),this.dispose()},dispose:function(){this.remove(),b("#gform-shortcode-ui-wrap").append('<div id="gform-shortcode-ui-container"></div>')}}),c.views.editAttributeField=Backbone.View.extend({tagName:"div",initialize:function(a){this.parent=a.parent},events:{'keyup  input[type="text"]':"updateValue","keyup  textarea":"updateValue","change select":"updateValue","change #gf-shortcode-attr-action":"updateAction","change input[type=checkbox]":"updateCheckbox","change input[type=radio]":"updateValue","change input[type=email]":"updateValue","change input[type=number]":"updateValue","change input[type=date]":"updateValue","change input[type=url]":"updateValue"},render:function(){return this.template=wp.media.template("gf-shortcode-ui-field-"+this.model.get("type")),this.$el.html(this.template(this.model.toJSON()))},updateValue:function(a){var c=b(a.target);this.model.set("value",c.val())},updateCheckbox:function(a){var c=b(a.target),d=c.prop("checked");this.model.set("value",d)},updateAction:function(a){var d=b(a.target),e=d.val();this.model.set("value",e);var f=this.parent.model,g=c.shortcodes.findWhere({shortcode_tag:"gravityform",action_tag:e}),h=f.get("attrs");g.get("attrs").each(function(a){var b=a.get("attr"),c=h.findWhere({attr:b});if(void 0!==c){if(b==c.get("attr")){var d=c.get("value");a.set("value",String(d))}}}),b(this.parent.el).empty();var i=this.parent.options.viewMode;this.parent.dispose(),this.parent.model.set(g),GformShortcodeUI=new c.views.editShortcodeForm({model:g,viewMode:i}),GformShortcodeUI.render()}}),c.utils.shortcodeViewConstructor={initialize:function(a){this.shortcodeModel=this.getShortcodeModel(this.shortcode)},getShortcodeModel:function(a){var b=void 0!==a.attrs.named.action?a.attrs.named.action:"",d=c.shortcodes.findWhere({action_tag:b});if(d){var e=d.clone();return e.get("attrs").each(function(b){b.get("attr")in a.attrs.named&&b.set("value",a.attrs.named[b.get("attr")]),"content"===b.get("attr")&&"content"in a&&b.set("value",a.content)}),e}},getContent:function(){return this.content||this.fetch(),this.content},fetch:function(){var a=this;if(!this.fetching){this.fetching=!0;var c,d=this.shortcodeModel.get("attrs").findWhere({attr:"id"}),e=d.get("value");c={action:"gf_do_shortcode",post_id:b("#post_ID").val(),form_id:e,shortcode:this.shortcodeModel.formatShortcode(),nonce:gfShortcodeUIData.previewNonce},b.post(ajaxurl,c).done(function(b){a.content=b}).fail(function(){a.content='<span class="gf_shortcode_ui_error">'+gfShortcodeUIData.strings.errorLoadingPreview+"</span>"}).always(function(){delete a.fetching,a.render()})}},setLoader:function(){this.setContent('<div class="loading-placeholder"><div class="dashicons dashicons-feedback"></div><div class="wpview-loading"><ins></ins></div></div>')},View:{overlay:!0,shortcodeHTML:!1,setContent:function(a,c){this.getNodes(function(d,e,f){var g="wrap"===c||"replace"===c?e:f,h=a;_.isString(h)&&(h=d.dom.createFragment(h)),"replace"===c?d.dom.replace(h,g):"remove"===c?(e.parentNode.insertBefore(h,e.nextSibling),b(e).remove()):(g.innerHTML="",g.appendChild(h))})},initialize:function(a){var b=void 0!==a.shortcode.attrs.named.action?a.shortcode.attrs.named.action:"",d=c.shortcodes.findWhere({action_tag:b});if(!d)return this.shortcodeHTML=decodeURIComponent(a.encodedText),void(this.shortcode=!1);var e=d.clone();e.get("attrs").each(function(b){b.get("attr")in a.shortcode.attrs.named&&b.set("value",a.shortcode.attrs.named[b.get("attr")]),"content"===b.get("attr")&&"content"in a.shortcode&&b.set("value",a.shortcode.content)}),this.shortcode=e},loadingPlaceholder:function(){return'<div class="loading-placeholder"><div class="dashicons dashicons-feedback"></div><div class="wpview-loading"><ins></ins></div></div>'},getEditors:function(a){var b=[];return _.each(tinymce.editors,function(c){c.plugins.wpview&&(a&&a(c),b.push(c))},this),b},getNodes:function(a){var c=[],d=this;return this.getEditors(function(e){b(e.getBody()).find('[data-wpview-text="'+d.encodedText+'"]').each(function(d,f){a&&a(e,f,b(f).find(".wpview-content").get(0)),c.push(f)})}),c},setIframes:function(a){var c=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver;if(-1===a.indexOf("<script"))return this.shortcodeHTML=a,void this.render();this.getNodes(function(d,e,f){var g,h,i,j,k=d.dom,l="",m=d.getBody().className||"";f.innerHTML="",wp.mce.views.sandboxStyles?l=wp.mce.views.sandboxStyles:(tinymce.each(k.$('link[rel="stylesheet"]',d.getDoc().head),function(a){a.href&&-1===a.href.indexOf("skins/lightgray/content.min.css")&&-1===a.href.indexOf("skins/wordpress/wp-content.css")&&(l+=k.getOuterHTML(a)+"\n")}),wp.mce.views.sandboxStyles=l),setTimeout(function(){if(g=k.add(f,"iframe",{src:tinymce.Env.ie?'javascript:""':"",frameBorder:"0",id:"gf-shortcode-preview-"+(new Date).getTime(),allowTransparency:"true",scrolling:"no",class:"wpview-sandbox",style:{width:"100%",display:"block"}}),h=g.contentWindow.document,h.open(),h.write('<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'+l+'<style>html {background: transparent;padding: 0;margin: 0;}body#wpview-iframe-sandbox {background: transparent;padding: 1px 0 !important;margin: -1px 0 0 !important;}body#wpview-iframe-sandbox:before,body#wpview-iframe-sandbox:after {display: none;content: "";}</style></head><body id="wpview-iframe-sandbox" class="'+m+'">'+a+"</body></html>"),h.close(),j=function(){g.contentWindow&&b(g).height(b(h.body).height())},c)new c(_.debounce(function(){j()},100)).observe(h.body,{attributes:!0,childList:!0,subtree:!0});else for(i=1;i<6;i++)setTimeout(j,700*i);j(),d.on("wp-body-class-change",function(){h.body.className=d.getBody().className})},50)})},getHtml:function(){if(!this.shortcode)return void this.setContent(this.shortcodeHTML,"remove");var a;if(!1===this.shortcodeHTML){var c=this.shortcode.get("attrs").findWhere({attr:"id"}),d=c.get("value");a={action:"gf_do_shortcode",post_id:b("#post_ID").val(),form_id:d,shortcode:this.shortcode.formatShortcode(),nonce:gfShortcodeUIData.previewNonce},b.post(ajaxurl,a,b.proxy(this.setIframes,this))}return this.shortcodeHTML}},edit:function(a){var d;if("object"==typeof a&&(a=decodeURIComponent(jQuery(a).attr("data-wpview-text"))),d=wp.shortcode.next("gravityform",a)){var e=d.shortcode.attrs.named.action?d.shortcode.attrs.named.action:"",f=c.shortcodes.findWhere({shortcode_tag:d.shortcode.tag,action_tag:e});if(!f)return;var g=f.clone();_.each(d.shortcode.attrs.named,function(a,b){attr=g.get("attrs").findWhere({attr:b}),attr&&attr.set("value",a)});var h=g.get("attrs").findWhere({attr:"id"}),i=h.get("value");b("#add_form_id").val(i),GformShortcodeUI=new c.views.editShortcodeForm({model:g,viewMode:"update"}),GformShortcodeUI.render(),b("#gform-insert-shortcode").hide(),b("#gform-update-shortcode").show(),tb_show("Edit Gravity Form","#TB_inline?inlineId=select_gravity_form&width=753&height=686","")}}},b(document).ready(function(){c.strings=gfShortcodeUIData.strings,c.shortcodes=new c.collections.Shortcodes(gfShortcodeUIData.shortcodes),gfShortcodeUIData.previewDisabled||void 0===wp.mce||wp.mce.views.register("gravityform",b.extend(!0,{},c.utils.shortcodeViewConstructor)),b(document).on("click",".gform_media_link",function(){c.shortcodes=new c.collections.Shortcodes(gfShortcodeUIData.shortcodes);var a=c.shortcodes.findWhere({shortcode_tag:"gravityform",action_tag:""});GformShortcodeUI=new c.views.editShortcodeForm({model:a,viewMode:"insert"}),GformShortcodeUI.render(),tb_show("Insert Gravity Form","#TB_inline?inlineId=select_gravity_form&width=753&height=686","")})})}(window.gfShortcodeUI=window.gfShortcodeUI||{},jQuery);