|
|
/*! * medium-editor-insert-plugin v1.6.1 - jQuery insert plugin for MediumEditor * * https://github.com/orthes/medium-editor-insert-plugin
* * Copyright (c) 2014 Pavel Linkesch (http://linkesch.sk)
* Released under the MIT license */
this.MediumInsert=this.MediumInsert||{},this.MediumInsert.Templates=this.MediumInsert.Templates||{},this.MediumInsert.Templates["src/js/templates/core-buttons.hbs"]=Handlebars.template({1:function(a,b,c,d){var e,f,g=this.lambda,h=this.escapeExpression,i="function",j=b.helperMissing,k=' <li><a data-addon="'+h(g(d&&d.key,a))+'" data-action="add" class="medium-insert-action">';return f=null!=(f=b.label||(null!=a?a.label:a))?f:j,e=typeof f===i?f.call(a,{name:"label",hash:{},data:d}):f,null!=e&&(k+=e),k+"</a></li>\n"},compiler:[6,">= 2.0.0-beta.1"],main:function(a,b,c,d){var e,f='<div class="medium-insert-buttons" contenteditable="false" style="display: none">\n <a class="medium-insert-buttons-show">+</a>\n <ul class="medium-insert-buttons-addons" style="display: none">\n';return e=b.each.call(a,null!=a?a.addons:a,{name:"each",hash:{},fn:this.program(1,d),inverse:this.noop,data:d}),null!=e&&(f+=e),f+" </ul>\n</div>\n"},useData:!0}),this.MediumInsert.Templates["src/js/templates/core-caption.hbs"]=Handlebars.template({compiler:[6,">= 2.0.0-beta.1"],main:function(a,b,c,d){var e,f="function",g=b.helperMissing,h=this.escapeExpression;return'<figcaption contenteditable="true" class="medium-insert-caption-placeholder" data-placeholder="'+h((e=null!=(e=b.placeholder||(null!=a?a.placeholder:a))?e:g,typeof e===f?e.call(a,{name:"placeholder",hash:{},data:d}):e))+'"></figcaption>'},useData:!0}),this.MediumInsert.Templates["src/js/templates/core-empty-line.hbs"]=Handlebars.template({compiler:[6,">= 2.0.0-beta.1"],main:function(a,b,c,d){return"<p><br></p>\n"},useData:!0}),this.MediumInsert.Templates["src/js/templates/embeds-toolbar.hbs"]=Handlebars.template({1:function(a,b,c,d){var e,f=' <div class="medium-insert-embeds-toolbar medium-editor-toolbar medium-toolbar-arrow-under medium-editor-toolbar-active">\n <ul class="medium-editor-toolbar-actions clearfix">\n';return e=b.each.call(a,null!=a?a.styles:a,{name:"each",hash:{},fn:this.program(2,d),inverse:this.noop,data:d}),null!=e&&(f+=e),f+" </ul>\n </div>\n"},2:function(a,b,c,d){var e,f="";return e=b["if"].call(a,null!=a?a.label:a,{name:"if",hash:{},fn:this.program(3,d),inverse:this.noop,data:d}),null!=e&&(f+=e),f},3:function(a,b,c,d){var e,f,g=this.lambda,h=this.escapeExpression,i="function",j=b.helperMissing,k=' <li>\n <button class="medium-editor-action" data-action="'+h(g(d&&d.key,a))+'">';return f=null!=(f=b.label||(null!=a?a.label:a))?f:j,e=typeof f===i?f.call(a,{name:"label",hash:{},data:d}):f,null!=e&&(k+=e),k+"</button>\n </li>\n"},5:function(a,b,c,d){var e,f=' <div class="medium-insert-embeds-toolbar2 medium-editor-toolbar medium-editor-toolbar-active">\n <ul class="medium-editor-toolbar-actions clearfix">\n';return e=b.each.call(a,null!=a?a.actions:a,{name:"each",hash:{},fn:this.program(2,d),inverse:this.noop,data:d}),null!=e&&(f+=e),f+" </ul>\n </div>\n"},compiler:[6,">= 2.0.0-beta.1"],main:function(a,b,c,d){var e,f="";return e=b["if"].call(a,null!=a?a.styles:a,{name:"if",hash:{},fn:this.program(1,d),inverse:this.noop,data:d}),null!=e&&(f+=e),f+="\n",e=b["if"].call(a,null!=a?a.actions:a,{name:"if",hash:{},fn:this.program(5,d),inverse:this.noop,data:d}),null!=e&&(f+=e),f},useData:!0}),this.MediumInsert.Templates["src/js/templates/embeds-wrapper.hbs"]=Handlebars.template({compiler:[6,">= 2.0.0-beta.1"],main:function(a,b,c,d){var e,f,g="function",h=b.helperMissing,i='<div class="medium-insert-embeds" contenteditable="false">\n <figure>\n <div class="medium-insert-embed">\n ';return f=null!=(f=b.html||(null!=a?a.html:a))?f:h,e=typeof f===g?f.call(a,{name:"html",hash:{},data:d}):f,null!=e&&(i+=e),i+'\n </div>\n </figure>\n <div class="medium-insert-embeds-overlay"></div>\n</div>'},useData:!0}),this.MediumInsert.Templates["src/js/templates/images-fileupload.hbs"]=Handlebars.template({compiler:[6,">= 2.0.0-beta.1"],main:function(a,b,c,d){return'<input type="file" multiple>'},useData:!0}),this.MediumInsert.Templates["src/js/templates/images-image.hbs"]=Handlebar }).trim()),b=a(".medium-insert-images-toolbar"),c=a(".medium-insert-images-toolbar2"),d=e.offset().top-b.height()-8-2-5,0>d&&(d=0),b.css({top:d,left:e.offset().left+e.width()/2-b.width()/2}).show(),c.css({top:e.offset().top+2,left:e.offset().left+e.width()-c.width()-4}).show(),b.find("button").each(function(){f.hasClass("medium-insert-images-"+a(this).data("action"))&&(a(this).addClass("medium-editor-button-active"),g=!0)}),g===!1&&b.find("button").first().addClass("medium-editor-button-active")},e.prototype.toolbarAction=function(b){var c=a(b.target).is("button")?a(b.target):a(b.target).closest("button"),d=c.closest("li"),e=d.closest("ul"),f=e.find("li"),g=this.$el.find(".medium-insert-active"),h=this;c.addClass("medium-editor-button-active"),d.siblings().find(".medium-editor-button-active").removeClass("medium-editor-button-active"),f.find("button").each(function(){var b="medium-insert-images-"+a(this).data("action");a(this).hasClass("medium-editor-button-active")?(g.addClass(b),h.options.styles[a(this).data("action")].added&&h.options.styles[a(this).data("action")].added(g)):(g.removeClass(b),h.options.styles[a(this).data("action")].removed&&h.options.styles[a(this).data("action")].removed(g))}),this.getCore().hideButtons(),this.$el.trigger("input")},e.prototype.toolbar2Action=function(b){var c=a(b.target).is("button")?a(b.target):a(b.target).closest("button"),d=this.options.actions[c.data("action")].clicked;d&&d(this.$el.find(".medium-insert-image-active")),this.getCore().hideButtons(),this.$el.trigger("input")},e.prototype.sorting=function(){this.options.sorting()},a.fn[f+g]=function(b){return this.each(function(){a.data(this,"plugin_"+f+g)||a.data(this,"plugin_"+f+g,new e(this,b))})}}(jQuery,window,document);
|