[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kupu-checkins
Subject:    [kupu-checkins] r5819 - in kupu/trunk/tools: . flexitools
From:       guido () codespeak ! net
Date:       2004-07-30 13:36:21
Message-ID: 20040730133621.9D2245A4ED () thoth ! codespeak ! net
[Download RAW message or body]

Author: guido
Date: Fri Jul 30 15:36:21 2004
New Revision: 5819

Added:
   kupu/trunk/tools/
   kupu/trunk/tools/flexitools/
   kupu/trunk/tools/flexitools/flexitools.js
Log:
Added 'tools' dir to add (third-party) tools, added 'flexitools' as the first
'third-party' extension to Kupu. Flexitools is a tool that can be used to make
only certain parts of the iframe editable. 
Written by Tomas Hnilica.


Added: kupu/trunk/tools/flexitools/flexitools.js
==============================================================================
--- (empty file)
+++ kupu/trunk/tools/flexitools/flexitools.js	Fri Jul 30 15:36:21 2004
@@ -0,0 +1,55 @@
+/*****************************************************************************
+ *
+ * Copyright (c) 2004 Tomas Hnilica,  tomas.hnilica@webstep.net. 
+ * All rights reserved.
+ *
+ * Tool for KUPU, allows edit only parts of document, which are in the
+ * DIV elements that containts attribute "editable" with value "yes". 
+ * 
+ * init: iframe is the edited iframe element
+ *
+ * The tool works fine in IE5.5+, cannot protect typing in mozilla based 
+ * browsers (there is a bug on keydown event). 
+ *
+ *****************************************************************************/
+
+
+function fxWritable(iframe) {
+	
+    this.editable = false;
+    var fxWritable_status = false;
+    var fxWritable_MOZ_WARN = false;    
+    
+     this.initialize = function(editor) {
+        /* initialize the tool */
+      var doc = editor.getInnerDocument();
+      this.editable = false;
+     
+     /* set event onKeyPress, onKeyDown */
+     if (_SARISSA_IS_IE) doc.onkeydown = this.checkWrite;
+     if (_SARISSA_IS_MOZ) {
+     		doc.addEventListener('keydown',this.checkWrite, true);
+     		doc.captureEvents(Event.KEYPRESS);
+     		doc.onkeypress = this.checkWrite;
+	}
+   };
+   
+   this.checkWrite = function(ev) {
+   	if (!fxWritable_MOZ_WARN) {alert('Content outside the areas can not be \
modified.');fxWritable_MOZ_WARN = true;} +   	if (fxWritable_status) return true;
+	else return false;
+   };
+    
+   this.updateState = function(selNode, event) {
+            /* evaluate if we are in editable area */
+           fxWritable_status = false;
+            var currnode = selNode;
+            while (currnode.nodeName != '#document' && fxWritable_status == false) {
+            	if (currnode.nodeName.toLowerCase()=="div" && \
currnode.getAttribute("editable")=="yes") fxWritable_status = true; +                \
currnode = currnode.parentNode; +            };
+        };
+
+};
+
+fxWritable.prototype = new KupuTool;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic