From 1ec680b29801e3fcd8c605a47385751574cb0d25 Mon Sep 17 00:00:00 2001 From: Firas Date: Sat, 14 Sep 2013 00:00:30 +0200 Subject: [PATCH] bootstrap3 support * fix modal dialog html * change icons to Glyphicons --- src/bootstrap3-wysihtml5.js | 520 ++++++++++++++++++++++++++++++++++++ 1 file changed, 520 insertions(+) create mode 100644 src/bootstrap3-wysihtml5.js diff --git a/src/bootstrap3-wysihtml5.js b/src/bootstrap3-wysihtml5.js new file mode 100644 index 0000000..f4897c4 --- /dev/null +++ b/src/bootstrap3-wysihtml5.js @@ -0,0 +1,520 @@ +!function($, wysi) { + "use strict"; + + var tpl = { + "font-styles": function(locale, options) { + var size = (options && options.size) ? ' btn-'+options.size : ''; + return ""; + }, + + "emphasis": function(locale, options) { + var size = (options && options.size) ? ' btn-'+options.size : ''; + return "
  • " + + "" + + "
  • "; + }, + + "lists": function(locale, options) { + var size = (options && options.size) ? ' btn-'+options.size : ''; + return "
  • " + + "
    " + + "" + + "" + + "" + + "" + + "
    " + + "
  • "; + }, + + "link": function(locale, options) { + var size = (options && options.size) ? ' btn-'+options.size : ''; + return "
  • " + + "" + + "" + + "
  • "; + }, + + "image": function(locale, options) { + var size = (options && options.size) ? ' btn-'+options.size : ''; + return "
  • " + + "" + + "" + + "
  • "; + }, + + "html": function(locale, options) { + var size = (options && options.size) ? ' btn-'+options.size : ''; + return "
  • " + + "
    " + + "" + + "
    " + + "
  • "; + }, + + "color": function(locale, options) { + var size = (options && options.size) ? ' btn-'+options.size : ''; + return ""; + } + }; + + var templates = function(key, locale, options) { + return tpl[key](locale, options); + }; + + + var Wysihtml5 = function(el, options) { + this.el = el; + var toolbarOpts = options || defaultOptions; + for(var t in toolbarOpts.customTemplates) { + tpl[t] = toolbarOpts.customTemplates[t]; + } + this.toolbar = this.createToolbar(el, toolbarOpts); + this.editor = this.createEditor(options); + + window.editor = this.editor; + + $('iframe.wysihtml5-sandbox').each(function(i, el){ + $(el.contentWindow).off('focus.wysihtml5').on({ + 'focus.wysihtml5' : function(){ + $('li.dropdown').removeClass('open'); + } + }); + }); + }; + + Wysihtml5.prototype = { + + constructor: Wysihtml5, + + createEditor: function(options) { + options = options || {}; + + // Add the toolbar to a clone of the options object so multiple instances + // of the WYISYWG don't break because "toolbar" is already defined + options = $.extend(true, {}, options); + options.toolbar = this.toolbar[0]; + + var editor = new wysi.Editor(this.el[0], options); + + if(options && options.events) { + for(var eventName in options.events) { + editor.on(eventName, options.events[eventName]); + } + } + return editor; + }, + + createToolbar: function(el, options) { + var self = this; + var toolbar = $("