/******************************************************************** * openWYSIWYG v1.47 Copyright (c) 2006 openWebWare.com * Contact us at devs@openwebware.com * This copyright notice MUST stay intact for use. * * $Id: wysiwyg.js,v 1.22 2007/09/08 21:45:57 xhaggi Exp $ * $Revision: 1.22 $ * * An open source WYSIWYG editor for use in web based applications. * For full source code and docs, visit http://www.openwebware.com * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public License along * with this library; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA ********************************************************************/ var WYSIWYG = { /** * Settings class, holds all customizeable properties */ Settings: function() { // Images Directory this.ImagesDir = "/ow/images/"; // Popups Directory this.PopupsDir = "/ow/popups/"; // CSS Directory File // this.CSSFile = "ow/styles/wysiwyg.css"; this.CSSFile = "/templates/main/editor.css"; // Default WYSIWYG width and height (use px or %) this.Width = "500px"; this.Height = "200px"; // Default stylesheet of the WYSIWYG editor window this.DefaultStyle = "font-family: Arial; font-size: 12px; background-color: #FFFFFF"; // Stylesheet if editor is disabled this.DisabledStyle = "font-family: Arial; font-size: 12px; background-color: #EEEEEE"; // Width + Height of the preview window this.PreviewWidth = 500; this.PreviewHeight = 400; // Confirmation message if you strip any HTML added by word this.RemoveFormatConfMessage = "Clean HTML inserted by MS Word ?"; // Nofication if browser is not supported by openWYSIWYG, leave it blank for no message output. this.NoValidBrowserMessage = ""; // Anchor path to strip, leave it blank to ignore // or define auto to strip the path where the editor is placed // (only IE) this.AnchorPathToStrip = ""; // Image path to strip, leave it blank to ignore // or define auto to strip the path where the editor is placed // (only IE) this.ImagePathToStrip = ""; // Enable / Disable the custom context menu this.ContextMenu = true; // Enabled the status bar update. Within the status bar // node tree of the actually selected element will build this.StatusBarEnabled = false; // If enabled than the capability of the IE inserting line breaks will be inverted. // Normal: ENTER =
, SHIFT + ENTER =
// Inverted: ENTER =
, SHIFT + ENTER =
this.InvertIELineBreaks = false;
// Replace line breaks with ])*>( )*\s*<\/p>/gi, '');
str = str.replace(/ ]*>/gi, '');
str = str.replace(/<\/p[^>]*>/gi, '');
str = str.replace(/
tags
this.ReplaceLineBreaks = true;
// Page that opened the WYSIWYG (Used for the return command)
this.Opener = "/index.php";
// Insert image implementation
this.ImagePopupFile = "";
this.ImagePopupWidth = 0;
this.ImagePopupHeight = 0;
// Holds the available buttons displayed
// on the toolbar of the editor
this.Toolbar = new Array();
this.Toolbar[0] = new Array(
"font",
"fontsize",
"headings",
"bold",
"italic",
"underline",
"strikethrough",
"seperator",
"forecolor",
"backcolor",
"seperator",
"justifyfull",
"justifyleft",
"justifycenter",
"justifyright"
);
this.Toolbar[1] = new Array(
// "return", // return button disabled by default
"unorderedlist",
"orderedlist",
"outdent",
"indent",
"seperator",
"subscript",
"superscript",
"seperator",
// "removeformat",
// "seperator",
"undo",
"redo",
"seperator",
// "inserttable",
"insertimage",
"insertobject",
"createlink",
"insertsmiley"//,
// "seperator",
// "viewSource"
);
// DropDowns
this.DropDowns = new Array();
// Fonts
this.DropDowns['font'] = {
id: "fonts",
command: "FontName",
label: "{value}",
width: "90px",
elements: new Array(
"Arial",
"Sans Serif",
"Tahoma",
"Verdana",
"Courier New",
"Georgia",
"Times New Roman",
"Impact",
"Comic Sans MS"
)
};
// Font sizes
this.DropDowns['fontsize'] = {
id: "fontsizes",
command: "FontSize",
label: "Size {value}",
width: "54px",
elements: new Array(
"1",
"2",
"3",
"4",
"5",
"6",
"7"
)
};
// Headings
this.DropDowns['headings'] = {
id: "headings",
command: "FormatBlock",
label: "<{value} style=\"margin:0px;text-decoration:none;font-family:Arial\">{value}{value}>",
width: "74px",
elements: new Array(
"H1",
"H2",
"H3",
"H4",
"H5",
"H6"
)
};
// Add the given element to the defined toolbar
// on the defined position
this.addToolbarElement = function(element, toolbar, position) {
if(element != "seperator") {this.removeToolbarElement(element);}
if(this.Toolbar[toolbar-1] == null) {
this.Toolbar[toolbar-1] = new Array();
}
this.Toolbar[toolbar-1].splice(position+1, 1, element);
};
// Remove an element from the toolbar
this.removeToolbarElement = function(element) {
if(element == "seperator") {return;} // do not remove seperators
for(var i=0;i