/* jshint expr: true */ !(function ($, wysi) { 'use strict'; var templates = function (key, locale, options) { return wysi.tpl[key]({locale: locale, options: options}); }; var Wysihtml5 = function (el, options) { this.el = el; var toolbarOpts = options || defaultOptions; for (var t in toolbarOpts.customTemplates) { wysi.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 = $('