Author: simoneg
Date: Wed Jan 20 03:55:42 2010
New Revision: 901048
URL: http://svn.apache.org/viewvc?rev=901048&view=rev
Log:
Show source for rich text
Added:
labs/magma/trunk/website-dojo-textareas-showsource/pom.xml
labs/magma/trunk/website-dojo-textareas-showsource/src/
labs/magma/trunk/website-dojo-textareas-showsource/src/main/
labs/magma/trunk/website-dojo-textareas-showsource/src/main/java/
labs/magma/trunk/website-dojo-textareas-showsource/src/main/java/org/
labs/magma/trunk/website-dojo-textareas-showsource/src/main/java/org/apache/
labs/magma/trunk/website-dojo-textareas-showsource/src/main/java/org/apache/magma/
labs/magma/trunk/website-dojo-textareas-showsource/src/main/java/org/apache/magma/dojo/
labs/magma/trunk/website-dojo-textareas-showsource/src/main/java/org/apache/magma/dojo/AddViewSourceToPlugins.aj
labs/magma/trunk/website-dojo-textareas-showsource/src/main/resources/
labs/magma/trunk/website-dojo-textareas-showsource/src/main/resources/dojo-1.3.0/
labs/magma/trunk/website-dojo-textareas-showsource/src/main/resources/dojo-1.3.0/dijit/
labs/magma/trunk/website-dojo-textareas-showsource/src/main/resources/dojo-1.3.0/dijit/_editor/
labs/magma/trunk/website-dojo-textareas-showsource/src/main/resources/dojo-1.3.0/dijit/_editor/nls/
labs/magma/trunk/website-dojo-textareas-showsource/src/main/resources/dojo-1.3.0/dijit/_editor/nls/ViewSource.js
labs/magma/trunk/website-dojo-textareas-showsource/src/main/resources/dojo-1.3.0/dijit/_editor/plugins/
labs/magma/trunk/website-dojo-textareas-showsource/src/main/resources/dojo-1.3.0/dijit/_editor/plugins/ViewSource.js
labs/magma/trunk/website-dojo-textareas-showsource/src/main/resources/dojo-1.3.0/dijit/_editor/resources/
labs/magma/trunk/website-dojo-textareas-showsource/src/main/resources/dojo-1.3.0/dijit/_editor/resources/ViewSource.css
labs/magma/trunk/website-dojo-textareas-showsource/src/main/resources/dojo-1.3.0/dijit/_editor/resources/viewsource_icon.gif
(with props)
Added: labs/magma/trunk/website-dojo-textareas-showsource/pom.xml
URL:
http://svn.apache.org/viewvc/labs/magma/trunk/website-dojo-textareas-showsource/pom.xml?rev=901048&view=auto
==============================================================================
--- labs/magma/trunk/website-dojo-textareas-showsource/pom.xml (added)
+++ labs/magma/trunk/website-dojo-textareas-showsource/pom.xml Wed Jan 20
03:55:42 2010
@@ -0,0 +1,37 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>magma-parent</artifactId>
+ <groupId>org.apache.magma</groupId>
+ <version>3</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.magma</groupId>
+ <artifactId>website-dojo-textareas-showsource</artifactId>
+ <name>Magma Dojo Textareas showsource plugin</name>
+ <version>0.0.3-SNAPSHOT</version>
+ <packaging>magma</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.magma</groupId>
+ <artifactId>website-dojo-textareas</artifactId>
+ <version>0.0.3-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+</project>
Added:
labs/magma/trunk/website-dojo-textareas-showsource/src/main/java/org/apache/magma/dojo/AddViewSourceToPlugins.aj
URL:
http://svn.apache.org/viewvc/labs/magma/trunk/website-dojo-textareas-showsource/src/main/java/org/apache/magma/dojo/AddViewSourceToPlugins.aj?rev=901048&view=auto
==============================================================================
---
labs/magma/trunk/website-dojo-textareas-showsource/src/main/java/org/apache/magma/dojo/AddViewSourceToPlugins.aj
(added)
+++
labs/magma/trunk/website-dojo-textareas-showsource/src/main/java/org/apache/magma/dojo/AddViewSourceToPlugins.aj
Wed Jan 20 03:55:42 2010
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.magma.dojo;
+
+import java.util.List;
+
+import org.apache.magma.website.Head;
+import org.apache.magma.website.beansview.BeanFormProducer;
+import org.apache.magma.website.HtmlProducer;
+
+public aspect AddViewSourceToPlugins {
+
+ after(List<String> plugins) :
+ execution(public static void
RichEditorPlugins.addObjectPlugins(List<String>)) &&
+ args(plugins) {
+
+ plugins.add("{name: 'dijit._editor.plugins.ViewSource',
command: 'viewsource'}");
+ }
+
+ after(BeanFormProducer producer, Head head) :
+ execution(void HtmlProducer+.head(..)) && this(producer) &&
args(head) {
+ if (!producer.hasDojoRichText) return;
+ head.addRawScript("dojo.require.viewsource",
"dojo.require('dijit._editor.plugins.ViewSource');");
+
head.addCss("magma:/dojo/dijit/_editor/resources/ViewSource.css");
+ }
+
+}
Added:
labs/magma/trunk/website-dojo-textareas-showsource/src/main/resources/dojo-1.3.0/dijit/_editor/nls/ViewSource.js
URL:
http://svn.apache.org/viewvc/labs/magma/trunk/website-dojo-textareas-showsource/src/main/resources/dojo-1.3.0/dijit/_editor/nls/ViewSource.js?rev=901048&view=auto
==============================================================================
---
labs/magma/trunk/website-dojo-textareas-showsource/src/main/resources/dojo-1.3.0/dijit/_editor/nls/ViewSource.js
(added)
+++
labs/magma/trunk/website-dojo-textareas-showsource/src/main/resources/dojo-1.3.0/dijit/_editor/nls/ViewSource.js
Wed Jan 20 03:55:42 2010
@@ -0,0 +1 @@
+({"ViewSource": "View Source"})
\ No newline at end of file
Added:
labs/magma/trunk/website-dojo-textareas-showsource/src/main/resources/dojo-1.3.0/dijit/_editor/plugins/ViewSource.js
URL:
http://svn.apache.org/viewvc/labs/magma/trunk/website-dojo-textareas-showsource/src/main/resources/dojo-1.3.0/dijit/_editor/plugins/ViewSource.js?rev=901048&view=auto
==============================================================================
---
labs/magma/trunk/website-dojo-textareas-showsource/src/main/resources/dojo-1.3.0/dijit/_editor/plugins/ViewSource.js
(added)
+++
labs/magma/trunk/website-dojo-textareas-showsource/src/main/resources/dojo-1.3.0/dijit/_editor/plugins/ViewSource.js
Wed Jan 20 03:55:42 2010
@@ -0,0 +1,539 @@
+if(!dojo._hasResource["dijit._editor.plugins.ViewSource"]){ //_hasResource
checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dijit._editor.plugins.ViewSource"] = true;
+dojo.provide("dijit._editor.plugins.ViewSource");
+
+dojo.require("dijit._editor._Plugin");
+dojo.require("dijit.form.Button");
+dojo.require("dojo.i18n");
+
+dojo.requireLocalization("dijit._editor", "ViewSource", null, "ROOT");
+
+dojo.declare("dijit._editor.plugins.ViewSource",dijit._editor._Plugin,{
+ // summary:
+ // This plugin provides a simple view source capability.
When view
+ // source mode is enabled, it disables all other
buttons/plugins on the RTE.
+ // It also binds to the hotkey: CTRL-SHIFT-F11 for
toggling ViewSource mode.
+
+ // stripScripts: [public] Boolean
+ // Boolean flag used to indicate if script tags should be
stripped from the document.
+ // Defaults to true.
+ stripScripts: true,
+
+ // stripComments: [public] Boolean
+ // Boolean flag used to indicate if comment tags should be
stripped from the document.
+ // Defaults to true.
+ stripComments: true,
+
+ // stripComments: [public] Boolean
+ // Boolean flag used to indicate if iframe tags should be
stripped from the document.
+ // Defaults to true.
+ stripIFrames: true,
+
+ // readOnly: [const] Boolean
+ // Boolean flag used to indicate if the source view should
be readonly or not.
+ // Cannot be changed after initialization of the plugin.
+ // Defaults to false.
+ readOnly: false,
+
+ // _fsPlugin: [private] Object
+ // Reference to a registered fullscreen plugin so that
viewSource knows
+ // how to scale.
+ _fsPlugin: null,
+
+ toggle: function(){
+ // summary:
+ // Function to allow programmatic toggling of the
view.
+
+ // For Webkit, we have to focus a very particular way.
+ // when swapping views, otherwise focus doesn't shift right
+ // but can't focus this way all the time, only for VS changes.
+ // If we did it all the time, buttons like bold, italic, etc
+ // break.
+ if(dojo.isWebKit){this._vsFocused = true;}
+ this.button.attr("checked", !this.button.attr("checked"));
+
+ },
+
+ _initButton: function(){
+ // summary:
+ // Over-ride for creation of the resize button.
+ var strings = dojo.i18n.getLocalization("dijit._editor",
"ViewSource");
+ this.button = new dijit.form.ToggleButton({
+ label: strings["ViewSource"],
+ showLabel: false,
+ iconClass: this.iconClassPrefix + " " +
this.iconClassPrefix + "ViewSource",
+ tabIndex: "-1",
+ onChange: dojo.hitch(this, "_showSource")
+ });
+
+ // IE 7 has a horrible bug with zoom, so we have to create this
node
+ // to cross-check later. Sigh.
+ if(dojo.isIE == 7){
+ this._ieFixNode = dojo.create("div", {
+ style: {
+ opacity: "0",
+ zIndex: "-1000",
+ position: "absolute",
+ top: "-1000px"
+ }
+ }, dojo.body());
+ }
+ // Make sure readonly mode doesn't make the wrong cursor appear
over the button.
+ this.button.attr("readOnly", false);
+ },
+
+
+ setEditor: function(/*dijit.Editor*/ editor){
+ // summary:
+ // Tell the plugin which Editor it is associated
with.
+ // editor: Object
+ // The editor object to attach the print
capability to.
+ this.editor = editor;
+ this._initButton();
+
+ this.editor.addKeyHandler(dojo.keys.F12, true, true,
dojo.hitch(this, function(e){
+ // Move the focus before switching
+ // It'll focus back. Hiding a focused
+ // node causes issues.
+ this.button.focus();
+ this.toggle();
+ dojo.stopEvent(e);
+
+ // Call the focus shift outside of the handler.
+ setTimeout(dojo.hitch(this, function(){
+ // We over-ride focus, so we just need to call.
+ this.editor.focus();
+ }), 100);
+ }));
+ },
+
+ _showSource: function(source){
+ // summary:
+ // Function to toggle between the source and RTE
views.
+ // source: boolean
+ // Boolean value indicating if it should be in
source mode or not.
+ // tags:
+ // private
+ var ed = this.editor;
+ var edPlugins = ed._plugins;
+ var html;
+ this._sourceShown = source;
+ var self = this;
+ try{
+ if(!this.sourceArea){
+ this._createSourceView();
+ }
+ if(source){
+ // Update the QueryCommandEnabled function to
disable everything but
+ // the source view mode. Have to over-ride a
function, then kick all
+ // plugins to check their state.
+ ed._sourceQueryCommandEnabled =
ed.queryCommandEnabled;
+ ed.queryCommandEnabled = function(cmd){
+ var lcmd = cmd.toLowerCase();
+ if(lcmd === "viewsource"){
+ return true;
+ }else{
+ return false;
+ }
+ };
+ this.editor.onDisplayChanged();
+ html = ed.attr("value");
+ html = this._filter(html);
+ ed.attr("value", html);
+ this._pluginList = [];
+ this._disabledPlugins = dojo.filter(edPlugins,
function(p){
+ // Turn off any plugins not controlled
by queryCommandenabled.
+ if(p && p.button &&
!p.button.attr("disabled") &&
+ !(p instanceof
dijit._editor.plugins.ViewSource)){
+ p._vs_updateState =
p.updateState;
+ p.updateState = function(){
+ return false;
+ };
+ p.button.attr("disabled", true);
+ if(p.command){
+ // FF has a weird
behavior when spellcheck is off,
+ // queryCommandValue()
returns true on the doc, and as such
+ // toggles 'on' some
actions. So, we need to explictly
+ // toggle them off.
TODO: Add a disable API to _Plugin.js
+ // It would aleviate
the need for this.
+ switch(p.command){
+ case "bold":
+ case "italic":
+ case
"underline":
+ case
"strikethrough":
+ case
"superscript":
+ case
"subscript":
+
p.button.attr("checked", false);
+ break;
+ default:
+ break;
+ }
+ }
+ return true;
+ }
+ });
+
+ // We actually do need to trap this plugin and
adjust how we
+ // display the textarea.
+ if(this._fsPlugin){
+ this._fsPlugin._getAltViewNode =
function(){
+ return self.sourceArea;
+ };
+ }
+
+ this.sourceArea.value = html;
+ var is = dojo.marginBox(ed.iframe.parentNode);
+ dojo.marginBox(this.sourceArea, {
+ w: is.w,
+ h: is.h
+ });
+
+ dojo.style(ed.iframe, "display", "none");
+ dojo.style(this.sourceArea, {
+ display: "block"
+ });
+
+ var resizer = function(){
+ // function to handle resize events.
+ // Will check current VP and only
resize if
+ // different.
+ var vp = dijit.getViewport();
+
+ if("_prevW" in this && "_prevH" in
this){
+ // No actual size change,
ignore.
+ if(vp.w === this._prevW && vp.h
=== this._prevH){
+ return;
+ }else{
+ this._prevW = vp.w;
+ this._prevH = vp.h;
+ }
+ }else{
+ this._prevW = vp.w;
+ this._prevH = vp.h;
+ }
+ if(this._resizer){
+ clearTimeout(this._resizer);
+ delete this._resizer;
+ }
+ // Timeout it to help avoid spamming
resize on IE.
+ // Works for all browsers.
+ this._resizer =
setTimeout(dojo.hitch(this, function(){
+ delete this._resizer;
+ this._resize();
+ }), 10);
+ };
+ this._resizeHandle = dojo.connect(window,
"onresize", this, resizer);
+
+ //Call this on a delay once to deal with IE
glitchiness on initial size.
+ setTimeout(dojo.hitch(this, this._resize), 100);
+
+ //Trigger a check for command
enablement/disablement.
+ this.editor.onNormalizedDisplayChanged();
+ }else{
+ // First check that we were in source view
before doing anything.
+ // corner case for being called with a value of
false and we hadn't
+ // actually been in source display mode.
+ if(!ed._sourceQueryCommandEnabled){
+ return;
+ }
+ dojo.disconnect(this._resizeHandle);
+ delete this._resizeHandle;
+
+ // Restore all the plugin buttons state.
+ ed.queryCommandEnabled =
ed._sourceQueryCommandEnabled;
+ if(!this._readOnly){
+ html = this.sourceArea.value;
+ html = this._filter(html);
+ ed.attr("value", html);
+ }
+
+ dojo.forEach(this._disabledPlugins, function(p){
+ // Turn back on any plugins we turned
off.
+ p.button.attr("disabled", false);
+ if(p._vs_updateState){
+ p.updateState =
p._vs_updateState;
+ }
+ });
+
+ this._disabledPlugins = null;
+ dojo.style(this.sourceArea, "display", "none");
+ dojo.style(ed.iframe, "display", "block");
+ delete ed._sourceQueryCommandEnabled;
+
+ //Trigger a check for command
enablement/disablement.
+ this.editor.onDisplayChanged();
+ }
+ }catch(e){
+ console.log(e);
+ }
+ },
+
+ _resize: function(){
+ // summary:
+ // Internal function to resize the source view
+ // tags:
+ // private
+ // TODO commented, no support for this in 1.3.0
+ /*
+ var ed = this.editor;
+ var tb = dojo.position(ed.toolbar.domNode);
+ var eb = dojo.position(ed.domNode);
+
+ var extents = dojo._getPadBorderExtents(ed.domNode);
+ var edb = {
+ w: eb.w - extents.w,
+ h: eb.h - (tb.h + extents.h)
+ };
+
+ // Fullscreen gets odd, so we need to check for the FS plugin
and
+ // adapt.
+ if(this._fsPlugin && this._fsPlugin.isFullscreen){
+ //Okay, probably in FS, adjust.
+ var vp = dijit.getViewport();
+ edb.w = (vp.w - extents.w);
+ edb.h = (vp.h - (tb.h + extents.h));
+ }
+
+ if(dojo.isIE){
+ // IE is always off by 2px, so we have to adjust here
+ // Note that IE ZOOM is broken here. I can't get
+ //it to scale right.
+ edb.h -= 2;
+ }
+
+ // IE has a horrible zoom bug. So, we have to try and account
for
+ // it and fix up the scaling.
+ if(this._ieFixNode){
+ var _ie7zoom = -this._ieFixNode.offsetTop / 1000;
+ edb.w = Math.floor((edb.w + 0.9) / _ie7zoom);
+ edb.h = Math.floor((edb.h + 0.9) / _ie7zoom);
+ }
+
+
+ dojo.marginBox(this.sourceArea, {
+ w: edb.w,
+ h: edb.h
+ });
+ */
+ },
+
+ _createSourceView: function(){
+ // summary:
+ // Internal function for creating the source view
area.
+ // tags:
+ // private
+ var ed = this.editor;
+ var edPlugins = ed._plugins;
+ this.sourceArea = dojo.create("textarea");
+ if(this.readOnly){
+ dojo.attr(this.sourceArea, "readOnly", true);
+ this._readOnly = true;
+ }
+ dojo.style(this.sourceArea, {
+ padding: "0px",
+ margin: "0px",
+ borderWidth: "0px",
+ borderStyle: "none"
+ });
+ dojo.place(this.sourceArea, ed.iframe, "before");
+ dojo.style(this.sourceArea.parentNode, {
+ padding: "0px",
+ margin: "0px",
+ borderWidth: "0px",
+ borderStyle: "none"
+ });
+
+ if(dojo.isIE && ed.iframe.parentNode.lastChild !== ed.iframe){
+ // There's some weirdo div in IE used for focus control
+ // But is messed up scaling the textarea if we don't
config
+ // it some so it doesn't have a varying height.
+ dojo.style(ed.iframe.parentNode.lastChild,{
+ width: "0px",
+ height: "0px",
+ padding: "0px",
+ margin: "0px",
+ borderWidth: "0px",
+ borderStyle: "none"
+ });
+ }
+
+ // We also need to take over editor focus a bit here, so that
focus calls to
+ // focus the editor will focus to the right node when VS is
active.
+ ed._viewsource_oldFocus = ed.focus;
+ var self = this;
+ ed.focus = function(){
+ if(self._sourceShown){
+ self.setSourceAreaCaret();
+ }else{
+ try{
+ if(this._vsFocused){
+ delete this._vsFocused;
+ // Must focus edit node in this
case (webkit only) or
+ // focus doesn't shift right,
but in normal
+ // cases we focus with the
regular function.
+ dijit.focus(ed.editNode);
+ }else{
+ ed._viewsource_oldFocus();
+ }
+ }catch(e){
+ console.log(e);
+ }
+ }
+ };
+
+ var i, p;
+ for(i = 0; i < edPlugins.length; i++){
+ // We actually do need to trap this plugin and adjust
how we
+ // display the textarea.
+ p = edPlugins[i];
+ if(p && (p.declaredClass ===
"dijit._editor.plugins.FullScreen" ||
+ p.declaredClass === (dijit._scopeName +
+ "._editor.plugins.FullScreen"))){
+ this._fsPlugin = p;
+ break;
+ }
+ }
+ if(this._fsPlugin){
+ // Found, we need to over-ride the alt-view node
function
+ // on FullScreen with our own, chain up to parent call
when appropriate.
+ this._fsPlugin._viewsource_getAltViewNode =
this._fsPlugin._getAltViewNode;
+ this._fsPlugin._getAltViewNode = function(){
+ return
self._sourceShown?self.sourceArea:this._viewsource_getAltViewNode();
+ };
+ }
+
+ // Listen to the source area for key events as well, as we need
to be able to hotkey toggle
+ // it from there too.
+ this.connect(this.sourceArea, "onkeydown", dojo.hitch(this,
function(e){
+ if(this._sourceShown && e.keyCode == dojo.keys.F12 &&
e.ctrlKey && e.shiftKey){
+ this.button.focus();
+ this.button.attr("checked", false);
+ setTimeout(dojo.hitch(this,
function(){ed.focus();}), 100);
+ dojo.stopEvent(e);
+ }
+ }));
+ },
+
+ _stripScripts: function(html){
+ // summary:
+ // Strips out script tags from the HTML used in
editor.
+ // html: String
+ // The HTML to filter
+ // tags:
+ // private
+ if(html){
+ // Look for closed and unclosed (malformed) script
attacks.
+ html =
html.replace(/<\s*script[^>]*>((.|\s)*?)<\\?\/\s*script\s*>/ig, "");
+ html = html.replace(/<\s*script\b([^<>]|\s)*>?/ig, "")
+ html =
html.replace(/<[^>]*=(\s|)*[("|')]javascript:[^$1][(\s|.)]*[$1][^>]*>/ig, "");
+ }
+ return html;
+ },
+
+ _stripComments: function(html){
+ // summary:
+ // Strips out comments from the HTML used in
editor.
+ // html: String
+ // The HTML to filter
+ // tags:
+ // private
+ if(html){
+ html = html.replace(/<!--(.|\s){1,}?-->/g, "");
+ }
+ return html;
+ },
+
+ _stripIFrames: function(html){
+ // summary:
+ // Strips out iframe tags from the content, to
avoid iframe script
+ // style injection attacks.
+ // html: String
+ // The HTML to filter
+ // tags:
+ // private
+ if(html){
+ html =
html.replace(/<\s*iframe[^>]*>((.|\s)*?)<\\?\/\s*iframe\s*>/ig, "");
+ }
+ return html;
+ },
+
+ _filter: function(html){
+ // summary:
+ // Internal function to perform some filtering on
the HTML.
+ // html: String
+ // The HTML to filter
+ // tags:
+ // private
+ if(html){
+ if(this.stripScripts){
+ html = this._stripScripts(html);
+ }
+ if(this.stripComments){
+ html = this._stripComments(html);
+ }
+ if(this.stripIFrames){
+ html = this._stripIFrames(html);
+ }
+ }
+ return html;
+ },
+
+ setSourceAreaCaret: function(){
+ // summary:
+ // Internal function to set the caret in the
sourceArea
+ // to 0x0
+ var win = dojo.global;
+ var elem = this.sourceArea;
+ dijit.focus(elem);
+ if(this._sourceShown && !this.readOnly){
+ if(dojo.isIE){
+ if(this.sourceArea.createTextRange){
+ var range = elem.createTextRange();
+ range.collapse(true);
+ range.moveStart("character", -99999);
// move to 0
+ range.moveStart("character", 0); //
delta from 0 is the correct position
+ range.moveEnd("character", 0);
+ range.select();
+ }
+ }else if(win.getSelection){
+ if(elem.setSelectionRange){
+ elem.setSelectionRange(0,0);
+ }
+ }
+ }
+ },
+
+ destroy: function(){
+ // summary:
+ // Over-ride to remove the node used to correct
for IE's
+ // zoom bug.
+ if(this._ieFixNode){
+ dojo.body().removeChild(this._ieFixNode);
+ }
+ if(this._resizer){
+ clearTimeout(this._resizer);
+ delete this._resizer;
+ }
+ if(this._resizeHandle){
+ dojo.disconnect(this._resizeHandle);
+ delete this._resizeHandle;
+ }
+ this.inherited(arguments);
+ }
+});
+
+// Register this plugin.
+dojo.subscribe(dijit._scopeName + ".Editor.getPlugin",null,function(o){
+ if(o.plugin){ return; }
+ var name = o.args.name.toLowerCase();
+ if(name === "viewsource"){
+ o.plugin = new dijit._editor.plugins.ViewSource({
+ readOnly: ("readOnly" in o.args)?o.args.readOnly:false,
+ stripComments: ("stripComments" in
o.args)?o.args.stripComments:true,
+ stripScripts: ("stripScripts" in
o.args)?o.args.stripScripts:true,
+ stripIFrames: ("stripIFrames" in
o.args)?o.args.stripIFrames:true
+ });
+ }
+});
+
+}
\ No newline at end of file
Added:
labs/magma/trunk/website-dojo-textareas-showsource/src/main/resources/dojo-1.3.0/dijit/_editor/resources/ViewSource.css
URL:
http://svn.apache.org/viewvc/labs/magma/trunk/website-dojo-textareas-showsource/src/main/resources/dojo-1.3.0/dijit/_editor/resources/ViewSource.css?rev=901048&view=auto
==============================================================================
---
labs/magma/trunk/website-dojo-textareas-showsource/src/main/resources/dojo-1.3.0/dijit/_editor/resources/ViewSource.css
(added)
+++
labs/magma/trunk/website-dojo-textareas-showsource/src/main/resources/dojo-1.3.0/dijit/_editor/resources/ViewSource.css
Wed Jan 20 03:55:42 2010
@@ -0,0 +1,3 @@
+.dijitEditorIcon.dijitEditorIconViewSource {
+ background-image: url(viewsource_icon.gif);
+}
\ No newline at end of file
Added:
labs/magma/trunk/website-dojo-textareas-showsource/src/main/resources/dojo-1.3.0/dijit/_editor/resources/viewsource_icon.gif
URL:
http://svn.apache.org/viewvc/labs/magma/trunk/website-dojo-textareas-showsource/src/main/resources/dojo-1.3.0/dijit/_editor/resources/viewsource_icon.gif?rev=901048&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
labs/magma/trunk/website-dojo-textareas-showsource/src/main/resources/dojo-1.3.0/dijit/_editor/resources/viewsource_icon.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]