From 26b397735a2a61254d5aca0d70a4332ff73f13f4 Mon Sep 17 00:00:00 2001 From: pepperpepperpepper Date: Sun, 6 Mar 2016 19:07:51 -0800 Subject: added basic js --- .../imconcat/deps/opt/bootstrap-wysihtml5.js | 301 +++++++++++++++++++++ 1 file changed, 301 insertions(+) create mode 100644 share/frontend/imconcat/deps/opt/bootstrap-wysihtml5.js (limited to 'share/frontend/imconcat/deps/opt/bootstrap-wysihtml5.js') diff --git a/share/frontend/imconcat/deps/opt/bootstrap-wysihtml5.js b/share/frontend/imconcat/deps/opt/bootstrap-wysihtml5.js new file mode 100644 index 0000000..a43cc56 --- /dev/null +++ b/share/frontend/imconcat/deps/opt/bootstrap-wysihtml5.js @@ -0,0 +1,301 @@ +!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 + } + } + } + } + }; + + 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; + + if(options && options.parserRules) { + parserRules = options.parserRules; + } + + var editor = new wysi.Editor(this.el.attr('id'), { + toolbar: this.toolbar.attr('id'), + parserRules: parserRules + }); + + 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 = $("