You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

10 lines
33 KiB

  1. /*!
  2. * medium-editor-insert-plugin v2.0.1 - jQuery insert plugin for MediumEditor
  3. *
  4. * https://github.com/orthes/medium-editor-insert-plugin
  5. *
  6. * Copyright (c) 2014 Pavel Linkesch (http://linkesch.sk)
  7. * Released under the MIT license
  8. */
  9. 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
  10. g=!0)}),g===!1&&b.find("button").first().addClass("medium-editor-button-active")},f.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.core.hideButtons(),this.$el.trigger("input")},f.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.core.hideButtons(),this.$el.trigger("input")},f.prototype.sorting=function(){this.options.sorting()},a.fn[g+h]=function(b){return this.each(function(){a.data(this,"plugin_"+g+h)||a.data(this,"plugin_"+g+h,new f(this,b))})}}(jQuery,window,document,MediumEditor.util);