From 8adb5b06b26fe2c6d4c27fd553d1cc596f5f5062 Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Tue, 12 Jun 2012 19:34:15 +0200 Subject: [PATCH 1/2] jshint cleanup --- src/bootstrap-wysihtml5.js | 599 ++++++++++++++++++------------------- 1 file changed, 295 insertions(+), 304 deletions(-) diff --git a/src/bootstrap-wysihtml5.js b/src/bootstrap-wysihtml5.js index 2a7cd4b..849d42f 100644 --- a/src/bootstrap-wysihtml5.js +++ b/src/bootstrap-wysihtml5.js @@ -1,308 +1,299 @@ !function($, wysi) { - "use strict" - - var templates = { - "font-styles": "", - "emphasis": "
  • " + - "
    " - + "Bold" - + "Italic" - + "Underline" - + "
    " - + "
  • ", - "lists": "
  • " - + "
    " - + "" - + "" - + "" - + "" - + "
    " - + "
  • ", - - "link": "
  • " - - + "" - - + "" - - + "
  • ", - - "image": "
  • " - - + "" - - + "" - - + "
  • ", - - "html": - "
  • " - + "
    " - + "" - + "
    " - + "
  • " - }; - - var defaultOptions = { - "font-styles": true, - "emphasis": true, - "lists": true, - "html": false, - "link": true, - "image": true, - events: {}, - parserRules: { - tags: { - "b": {}, - "i": {}, - "br": {}, - "ol": {}, - "ul": {}, - "li": {}, - "h1": {}, - "h2": {}, - "u": 1, - "img": { - "check_attributes": { - "width": "numbers", - "alt": "alt", - "src": "url", - "height": "numbers" - } - }, - "a": { - set_attributes: { - target: "_blank", - rel: "nofollow" - }, - check_attributes: { - href: "url" // important to avoid XSS - } - } - } - }, - stylesheets: [] - }; - - var Wysihtml5 = function(el, options) { - this.el = el; - this.toolbar = this.createToolbar(el, options || defaultOptions); - 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) { - var parserRules = defaultOptions.parserRules; - var stylesheets = defaultOptions.stylesheets; - - if(options && options.parserRules) { - parserRules = options.parserRules; - } - - if (options && options.stylesheets) { - stylesheets = options.stylesheets; - } - - var editor = new wysi.Editor(this.el.attr('id'), { - toolbar: this.toolbar.attr('id'), - parserRules: parserRules, - stylesheets: stylesheets - }); - - if(options && options.events) { - for(var eventName in options.events) { - editor.on(eventName, options.events[eventName]); + "use strict"; + + var templates = { + "font-styles": "", + "emphasis": "
  • " + + "
    " + + "Bold" + + "Italic" + + "Underline" + + "
    " + + "
  • ", + "lists": "
  • " + + "
    " + + "" + + "" + + "" + + "" + + "
    " + + "
  • ", + "link": "
  • " + + "" + + "" + + "
  • ", + "image": "
  • " + + "" + + "" + + "
  • ", + + "html": + "
  • " + + "
    " + + "" + + "
    " + + "
  • " + }; + + var defaultOptions = { + "font-styles": true, + "emphasis": true, + "lists": true, + "html": false, + "link": true, + "image": true, + events: {}, + parserRules: { + tags: { + "b": {}, + "i": {}, + "br": {}, + "ol": {}, + "ul": {}, + "li": {}, + "h1": {}, + "h2": {}, + "u": 1, + "img": { + "check_attributes": { + "width": "numbers", + "alt": "alt", + "src": "url", + "height": "numbers" + } + }, + "a": { + set_attributes: { + target: "_blank", + rel: "nofollow" + }, + check_attributes: { + href: "url" // important to avoid XSS + } + } + } + }, + stylesheets: [] + }; + + var Wysihtml5 = function(el, options) { + this.el = el; + this.toolbar = this.createToolbar(el, options || defaultOptions); + 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) { + var parserRules = defaultOptions.parserRules; + var stylesheets = defaultOptions.stylesheets; + + if(options && options.parserRules) { + parserRules = options.parserRules; + } + + if (options && options.stylesheets) { + stylesheets = options.stylesheets; + } + + var editor = new wysi.Editor(this.el.attr('id'), { + toolbar: this.toolbar.attr('id'), + parserRules: parserRules, + stylesheets: stylesheets + }); + + 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 = $("