/** @preserve CLEditor BBCode Plugin v1.0.0 http://premiumsoftware.net/cleditor requires CLEditor v1.3.0 or later Copyright 2010, Chris Landowski, Premium Software, LLC Dual licensed under the MIT or GPL Version 2 licenses. */ // ==ClosureCompiler== // @compilation_level SIMPLE_OPTIMIZATIONS // @output_file_name jquery.cleditor.bbcode.min.js // ==/ClosureCompiler== /* The CLEditor useCSS optional parameter should be set to false for this plugin to function properly. Supported HTML and BBCode Tags: Bold Hello [b]Hello[/b] Italics Hello [i]Hello[/i] Underlined Hello [u]Hello[/u] Strikethrough Hello [s]Hello[/s] Unordered Lists [list][*]Red[/*][*]Green[/*][*]Blue[/*][/list] Ordered Lists
  1. Red
  2. Blue
  3. Green
[list=1][*]Red[/*][*]Green[/*][*]Blue[/*][/list] Images [img]http://premiumsoftware.net/image.jpg[/img] Links Premium Software [url=http://premiumsoftware.net]Premium Software[/url] */ (function($) { // BBCode only supports a small subset of HTML, so remove // any toolbar buttons that are not currently supported. $.cleditor.defaultOptions.controls = "bold italic underline strikethrough removeformat | bullets numbering | " + "undo redo | image link unlink | cut copy paste pastetext | print source"; // Save the previously assigned callback handlers var oldAreaCallback = $.cleditor.defaultOptions.updateTextArea; var oldFrameCallback = $.cleditor.defaultOptions.updateFrame; // Wireup the updateTextArea callback handler $.cleditor.defaultOptions.updateTextArea = function(html) { // Fire the previously assigned callback handler if (oldAreaCallback) html = oldAreaCallback(html); // Convert the HTML to BBCode return $.cleditor.convertHTMLtoBBCode(html); } // Wireup the updateFrame callback handler $.cleditor.defaultOptions.updateFrame = function(code) { // Fire the previously assigned callback handler if (oldFrameCallback) code = oldFrameCallback(code); // Convert the BBCode to HTML return $.cleditor.convertBBCodeToHTML(code); } // Expose the convertHTMLtoBBCode method $.cleditor.convertHTMLtoBBCode = function(html) { $.each([ [/[\r|\n]/g, ""], [//gi, "\n"], [/(.*?)<\/b>/gi, "[b]$1[/b]"], [/(.*?)<\/strong>/gi, "[b]$1[/b]"], [/(.*?)<\/i>/gi, "[i]$1[/i]"], [/(.*?)<\/em>/gi, "[i]$1[/i]"], [/(.*?)<\/u>/gi, "[u]$1[/u]"], [/(.*?)<\/ins>/gi, "[u]$1[/u]"], [/(.*?)<\/strike>/gi, "[s]$1[/s]"], [/(.*?)<\/del>/gi, "[s]$1[/s]"], [/(.*?)<\/a>/gi, "[url=$1]$2[/url]"], [//gi, "[img]$1[/img]"], [/
    /gi, "[list]"], [/<\/ul>/gi, "[/list]"], [/
      /gi, "[list=1]"], [/<\/ol>/gi, "[/list]"], [/
    1. /gi, "[*]"], [/<\/li>/gi, "[/*]"], [/<.*?>(.*?)<\/.*?>/g, "$1"] ], function(index, item) { html = html.replace(item[0], item[1]); }); return html; } // Expose the convertBBCodeToHTML method $.cleditor.convertBBCodeToHTML = function(code) { $.each([ [/\r/g, ""], [/\n/g, "
      "], [/\[b\](.*?)\[\/b\]/gi, "$1"], [/\[i\](.*?)\[\/i\]/gi, "$1"], [/\[u\](.*?)\[\/u\]/gi, "$1"], [/\[s\](.*?)\[\/s\]/gi, "$1"], [/\[url=(.*?)\](.*?)\[\/url\]/gi, "$2"], [/\[img\](.*?)\[\/img\]/gi, ""], [/\[list\](.*?)\[\/list\]/gi, "
        $1
      "], [/\[list=1\](.*?)\[\/list\]/gi, "
        $1
      "], [/\[list\]/gi, "
        "], [/\[list=1\]/gi, "
          "], [/\[\*\](.*?)\[\/\*\]/g, "
        1. $1
        2. "], [/\[\*\]/g, "
        3. "] ], function(index, item) { code = code.replace(item[0], item[1]); }); return code; } })(jQuery);