Return-Path: Delivered-To: apmail-tapestry-commits-archive@locus.apache.org Received: (qmail 11318 invoked from network); 22 May 2006 23:18:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 22 May 2006 23:18:29 -0000 Received: (qmail 36167 invoked by uid 500); 22 May 2006 23:17:20 -0000 Delivered-To: apmail-tapestry-commits-archive@tapestry.apache.org Received: (qmail 36141 invoked by uid 500); 22 May 2006 23:17:20 -0000 Mailing-List: contact commits-help@tapestry.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tapestry.apache.org Delivered-To: mailing list commits@tapestry.apache.org Received: (qmail 36103 invoked by uid 99); 22 May 2006 23:17:19 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 May 2006 16:17:19 -0700 X-ASF-Spam-Status: No, hits=0.6 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of jkuhnert@apache.org designates 140.211.166.113 as permitted sender) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 May 2006 16:17:03 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 200231A988C; Mon, 22 May 2006 16:15:48 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r408783 [20/27] - in /tapestry/tapestry4/trunk: examples/TimeTracker/src/context/ framework/src/descriptor/META-INF/ framework/src/java/org/apache/tapestry/ framework/src/java/org/apache/tapestry/dojo/ framework/src/java/org/apache/tapestry... Date: Mon, 22 May 2006 23:11:13 -0000 To: commits@tapestry.apache.org From: jkuhnert@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060522231548.200231A988C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Added: tapestry/tapestry4/trunk/framework/src/js/dojo/src/widget/RichText.js URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/js/dojo/src/widget/RichText.js?rev=408783&view=auto ============================================================================== --- tapestry/tapestry4/trunk/framework/src/js/dojo/src/widget/RichText.js (added) +++ tapestry/tapestry4/trunk/framework/src/js/dojo/src/widget/RichText.js Mon May 22 16:10:12 2006 @@ -0,0 +1,1451 @@ +/* + Copyright (c) 2004-2006, The Dojo Foundation + All Rights Reserved. + + Licensed under the Academic Free License version 2.1 or above OR the + modified BSD license. For more information on Dojo licensing, see: + + http://dojotoolkit.org/community/licensing.shtml +*/ + + /* -*- tab-width: 4 -*- */ +dojo.provide("dojo.widget.RichText"); +dojo.provide("dojo.widget.html.RichText"); + +dojo.require("dojo.widget.*"); +dojo.require("dojo.dom"); +dojo.require("dojo.html"); +dojo.require("dojo.event.*"); +dojo.require("dojo.style"); +dojo.require("dojo.string"); + +// used to save content +try { + document.write(''); +}catch(e){ } + +dojo.widget.defineWidget( + "dojo.widget.html.RichText", + dojo.widget.HtmlWidget, + { + /** whether to inherit the parent's width or simply use 100% */ + inheritWidth: false, + focusOnLoad: true, + + /** + * If a save name is specified the content is saved and restored if the + * editor is not properly closed after editing has started. + */ + saveName: "", + _content: "", + + /* set height to fix the editor at a specific height, with scrolling */ + height: null, + + /** The minimum height that the editor should have */ + minHeight: "1em", + + isClosed: true, + isLoaded: false, + + /** whether to use the active-x object in IE */ + useActiveX: false, + + /* whether to use relative URLs for images - if this is enabled + images will be given absolute URLs when inside the editor but + will be changed to use relative URLs (to the current page) on save + */ + relativeImageUrls: false, + + _SEPARATOR: "@@**%%__RICHTEXTBOUNDRY__%%**@@", + + // contentFilters: [], + + /* + defaultContentCleaner: function(content){ + if(!dojo.render.html.ie){ + return content; + } + + content = content.replace(/\x20/g, " "); + // alert(content); + return content; + }, + */ + + /* Init + *******/ + + fillInTemplate: function(){ + this.open(); + + // add the formatting functions + var funcs = ["queryCommandEnabled", "queryCommandState", + "queryCommandValue", "execCommand"]; + for(var i = 0; i < funcs.length; i++){ + dojo.event.connect("around", this, funcs[i], this, "_normalizeCommand"); + } + + // backwards compatibility, needs to be removed + dojo.event.connect(this, "onKeyPressed", this, "afterKeyPress"); + dojo.event.connect(this, "onKeyPress", this, "keyPress"); + dojo.event.connect(this, "onKeyDown", this, "keyDown"); + dojo.event.connect(this, "onKeyUp", this, "keyUp"); + + // add default some key handlers + var ctrl = this.KEY_CTRL; + var exec = function (cmd, arg) { + return arguments.length == 1 ? function () { this.execCommand(cmd); } : + function () { this.execCommand(cmd, arg); } + } + + this.addKeyHandler("b", ctrl, exec("bold")); + this.addKeyHandler("i", ctrl, exec("italic")); + this.addKeyHandler("u", ctrl, exec("underline")); + this.addKeyHandler("a", ctrl, exec("selectall")); + //this.addKeyHandler("k", ctrl, exec("createlink", "")); + //this.addKeyHandler("K", ctrl, exec("unlink")); + this.addKeyHandler("s", ctrl, function () { this.save(true); }); + + this.addKeyHandler("1", ctrl, exec("formatblock", "h1")); + this.addKeyHandler("2", ctrl, exec("formatblock", "h2")); + this.addKeyHandler("3", ctrl, exec("formatblock", "h3")); + this.addKeyHandler("4", ctrl, exec("formatblock", "h4")); + + this.addKeyHandler("\\", ctrl, exec("insertunorderedlist")); + if(!dojo.render.html.ie){ + this.addKeyHandler("Z", ctrl, exec("redo")); + } + }, + + + events: ["onBlur", "onFocus", "onKeyPress", "onKeyDown", "onKeyUp", "onClick"], + + /** + * Transforms the node referenced in this.domNode into a rich text editing + * node. This can result in the creation and replacement with an