From shywolf9982 at codespeak.net Sun Apr 1 16:58:31 2007 From: shywolf9982 at codespeak.net (shywolf9982 at codespeak.net) Date: Sun, 1 Apr 2007 16:58:31 +0200 (CEST) Subject: [KSS-checkins] r41763 - kukit/kss.demo/trunk/kss/demo/browser Message-ID: <20070401145831.52AE410080@code0.codespeak.net> Author: shywolf9982 Date: Sun Apr 1 16:58:29 2007 New Revision: 41763 Modified: kukit/kss.demo/trunk/kss/demo/browser/preventdefault.kss Log: Restored the no-submission-on-submit-click that was removed to better debug safari event chain Modified: kukit/kss.demo/trunk/kss/demo/browser/preventdefault.kss ============================================================================== --- kukit/kss.demo/trunk/kss/demo/browser/preventdefault.kss (original) +++ kukit/kss.demo/trunk/kss/demo/browser/preventdefault.kss Sun Apr 1 16:58:29 2007 @@ -33,12 +33,10 @@ Apparently the default action for Safari is not "submit the form" but rather "click on submit", hence triggering another event through an event */ -/* input[type="submit"]:click { evt-click-preventdefault: true; action-client: log; } -*/ /* Second row, allowbubbling combined: */ From reebalazs at codespeak.net Sun Apr 1 17:44:14 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 1 Apr 2007 17:44:14 +0200 (CEST) Subject: [KSS-checkins] r41765 - kukit/kukit.js/trunk/kukit Message-ID: <20070401154414.4BF4A1007C@code0.codespeak.net> Author: reebalazs Date: Sun Apr 1 17:44:12 2007 New Revision: 41765 Modified: kukit/kukit.js/trunk/kukit/dom.js Log: Fix semicolons Modified: kukit/kukit.js/trunk/kukit/dom.js ============================================================================== --- kukit/kukit.js/trunk/kukit/dom.js (original) +++ kukit/kukit.js/trunk/kukit/dom.js Sun Apr 1 17:44:12 2007 @@ -141,11 +141,10 @@ tagName = node.tagName.toLowerCase(); if ((tagName == 'input') || (tagName == 'select') || (tagName == 'textarea')) { node.focus(); - } - else { + } else { kukit.logWarning('Focus on node that cannot have focus !'); - }; -} + } +}; /* * Gets the textual content of the node From reebalazs at codespeak.net Sun Apr 1 21:41:27 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 1 Apr 2007 21:41:27 +0200 (CEST) Subject: [KSS-checkins] r41778 - in kukit/kukit.js/trunk: 3rd_party kukit Message-ID: <20070401194127.429C71007C@code0.codespeak.net> Author: reebalazs Date: Sun Apr 1 21:41:25 2007 New Revision: 41778 Modified: kukit/kukit.js/trunk/3rd_party/sarissa.js kukit/kukit.js/trunk/kukit/plugin.js Log: update 3rdparty Sarissa library with version 0.9.7.6 Modified: kukit/kukit.js/trunk/3rd_party/sarissa.js ============================================================================== --- kukit/kukit.js/trunk/3rd_party/sarissa.js (original) +++ kukit/kukit.js/trunk/3rd_party/sarissa.js Sun Apr 1 21:41:25 2007 @@ -5,53 +5,36 @@ * Sarissa is an ECMAScript library acting as a cross-browser wrapper for native XML APIs. * The library supports Gecko based browsers like Mozilla and Firefox, * Internet Explorer (5.5+ with MSXML3.0+), Konqueror, Safari and a little of Opera - * @version 0.9.6.1 + * @version 0.9.7.6 * @author: Manos Batsis, mailto: mbatsis at users full stop sourceforge full stop net * ==================================================================== * Licence * ==================================================================== - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 or - * the GNU Lesser General Public License version 2.1 as published by - * the Free Software Foundation (your choice between the two). - * - * This program 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 General Public License or GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * or GNU Lesser General Public License along with this program; if not, - * write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * or visit http://www.gnu.org - * + * Sarissa is free software distributed under the GNU GPL version 2 (see gpl.txt) or higher, + * GNU LGPL version 2.1 (see lgpl.txt) or higher and Apache Software License 2.0 or higher + * (see asl.txt). This means you can choose one of the three and use that if you like. If + * you make modifications under the ASL, i would appreciate it if you submitted those. + * In case your copy of Sarissa does not include the license texts, you may find + * them online in various formats at http://www.gnu.org and + * http://www.apache.org. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + * WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE + * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /** - *
Sarissa is a utility class. Provides "static" methods for DOMDocument and - * XMLHTTP objects, DOM Node serializatrion to XML strings and other goodies.
+ *Sarissa is a utility class. Provides "static" methods for DOMDocument, + * DOM Node serialization to XML strings and other utility goodies.
* @constructor */ function Sarissa(){}; -/** @private */ Sarissa.PARSED_OK = "Document contains no parsing errors"; -/** - * Tells you whether transformNode and transformNodeToObject are available. This functionality - * is contained in sarissa_ieemu_xslt.js and is deprecated. If you want to control XSLT transformations - * use the XSLTProcessor - * @deprecated - * @type boolean - */ -Sarissa.IS_ENABLED_TRANSFORM_NODE = false; -/** - * tells you whether XMLHttpRequest (or equivalent) is available - * @type boolean - */ -Sarissa.IS_ENABLED_XMLHTTP = false; -/** - * tells you whether selectNodes/selectSingleNode is available - * @type boolean - */ -Sarissa.IS_ENABLED_SELECT_NODES = false; +Sarissa.PARSED_EMPTY = "Document is empty"; +Sarissa.PARSED_UNKNOWN_ERROR = "Not well-formed or other error"; var _sarissa_iNsCounter = 0; var _SARISSA_IEPREFIX4XSLPARAM = ""; var _SARISSA_HAS_DOM_IMPLEMENTATION = document.implementation && true; @@ -60,10 +43,12 @@ var _SARISSA_IS_MOZ = _SARISSA_HAS_DOM_CREATE_DOCUMENT && _SARISSA_HAS_DOM_FEATURE; var _SARISSA_IS_SAFARI = (navigator.userAgent && navigator.vendor && (navigator.userAgent.toLowerCase().indexOf("applewebkit") != -1 || navigator.vendor.indexOf("Apple") != -1)); var _SARISSA_IS_IE = document.all && window.ActiveXObject && navigator.userAgent.toLowerCase().indexOf("msie") > -1 && navigator.userAgent.toLowerCase().indexOf("opera") == -1; -if(!window.Node || !window.Node.ELEMENT_NODE){ - var Node = {ELEMENT_NODE: 1, ATTRIBUTE_NODE: 2, TEXT_NODE: 3, CDATA_SECTION_NODE: 4, ENTITY_REFERENCE_NODE: 5, ENTITY_NODE: 6, PROCESSING_INSTRUCTION_NODE: 7, COMMENT_NODE: 8, DOCUMENT_NODE: 9, DOCUMENT_TYPE_NODE: 10, DOCUMENT_FRAGMENT_NODE: 11, NOTATION_NODE: 12}; +if(!window.Node || !Node.ELEMENT_NODE){ + Node = {ELEMENT_NODE: 1, ATTRIBUTE_NODE: 2, TEXT_NODE: 3, CDATA_SECTION_NODE: 4, ENTITY_REFERENCE_NODE: 5, ENTITY_NODE: 6, PROCESSING_INSTRUCTION_NODE: 7, COMMENT_NODE: 8, DOCUMENT_NODE: 9, DOCUMENT_TYPE_NODE: 10, DOCUMENT_FRAGMENT_NODE: 11, NOTATION_NODE: 12}; }; +if(typeof XMLDocument == "undefined" && typeof Document !="undefined"){ XMLDocument = Document; } + // IE initialization if(_SARISSA_IS_IE){ // for XSLT parameter names, prefix needed by IE @@ -71,13 +56,15 @@ // used to store the most recent ProgID available out of the above var _SARISSA_DOM_PROGID = ""; var _SARISSA_XMLHTTP_PROGID = ""; + var _SARISSA_DOM_XMLWRITER = ""; /** * Called when the Sarissa_xx.js file is parsed, to pick most recent * ProgIDs for IE, then gets destroyed. + * @private * @param idList an array of MSXML PROGIDs from which the most recent will be picked for a given object * @param enabledList an array of arrays where each array has two items; the index of the PROGID for which a certain feature is enabled */ - pickRecentProgID = function (idList, enabledList){ + Sarissa.pickRecentProgID = function (idList){ // found progID flag var bFound = false; for(var i=0; i < idList.length && !bFound; i++){ @@ -85,50 +72,69 @@ var oDoc = new ActiveXObject(idList[i]); o2Store = idList[i]; bFound = true; - for(var j=0;jEnsures the document was loaded correctly, otherwise sets the @@ -224,8 +322,6 @@ * @private */ Sarissa.__handleLoad__ = function(oDoc){ - if (!oDoc.documentElement || oDoc.documentElement.tagName == "parsererror") - oDoc.parseError = -1; Sarissa.__setReadyState__(oDoc, 4); }; /** @@ -245,109 +341,37 @@ */ Sarissa.__setReadyState__ = function(oDoc, iReadyState){ oDoc.readyState = iReadyState; + oDoc.readystate = iReadyState; if (oDoc.onreadystatechange != null && typeof oDoc.onreadystatechange == "function") oDoc.onreadystatechange(); }; Sarissa.getDomDocument = function(sUri, sName){ - var oDoc = document.implementation.createDocument(sUri?sUri:"", sName?sName:"", null); + var oDoc = document.implementation.createDocument(sUri?sUri:null, sName?sName:null, null); + if(!oDoc.onreadystatechange){ + + /** + *
Emulate IE's onreadystatechange attribute
+ */ + oDoc.onreadystatechange = null; + }; + if(!oDoc.readyState){ + /** + *Emulates IE's readyState property, which always gives an integer from 0 to 4:
+ *Emulate IE's onreadystatechange attribute
- */ - XMLDocument.prototype.onreadystatechange = null; - /** - *Emulates IE's readyState property, which always gives an integer from 0 to 4:
- *Emulate IE's parseError attribute
- */ - XMLDocument.prototype.parseError = 0; - - // NOTE: setting async to false will only work with documents - // called over HTTP (meaning a server), not the local file system, - // unless you are using Moz 1.4+. - // BTW the try>catch block is for 1.4; I haven't found a way to check if - // the property is implemented without - // causing an error and I dont want to use user agent stuff for that... - var _SARISSA_SYNC_NON_IMPLEMENTED = false;// ("async" in XMLDocument.prototype) ? false: true; - /** - *Keeps a handle to the original load() method. Internal use and only - * if Mozilla version is lower than 1.4
- * @private - */ - XMLDocument.prototype._sarissa_load = XMLDocument.prototype.load; - - /** - *Overrides the original load method to provide synchronous loading for - * Mozilla versions prior to 1.4, using an XMLHttpRequest object (if - * async is set to false)
- * @returns the DOM Object as it was before the load() call (may be empty) - */ - XMLDocument.prototype.load = function(sURI) { - var oDoc = document.implementation.createDocument("", "", null); - Sarissa.copyChildNodes(this, oDoc); - this.parseError = 0; - Sarissa.__setReadyState__(this, 1); - try { - if(this.async == false && _SARISSA_SYNC_NON_IMPLEMENTED) { - var tmp = new XMLHttpRequest(); - tmp.open("GET", sURI, false); - tmp.send(null); - Sarissa.__setReadyState__(this, 2); - Sarissa.copyChildNodes(tmp.responseXML, this); - Sarissa.__setReadyState__(this, 3); - } - else { - this._sarissa_load(sURI); - }; - } - catch (objException) { - this.parseError = -1; - } - finally { - if(this.async == false){ - Sarissa.__handleLoad__(this); - }; - }; - return oDoc; - }; - - - }//if(window.XMLDocument) - else if(document.implementation && document.implementation.hasFeature && document.implementation.hasFeature('LS', '3.0')){ - Document.prototype.async = true; - Document.prototype.onreadystatechange = null; - Document.prototype.parseError = 0; - Document.prototype.load = function(sURI) { - var parser = document.implementation.createLSParser(this.async ? document.implementation.MODE_ASYNCHRONOUS : document.implementation.MODE_SYNCHRONOUS, null); - if(this.async){ - var self = this; - parser.addEventListener("load", - function(e) { - self.readyState = 4; - Sarissa.copyChildNodes(e.newDocument, self.documentElement, false); - self.onreadystatechange.call(); - }, - false); - }; - try { - var oDoc = parser.parseURI(sURI); - } - catch(e){ - this.parseError = -1; - }; - if(!this.async) - Sarissa.copyChildNodes(oDoc, this.documentElement, false); - return oDoc; - }; + // do nothing + }// TODO: check if the new document has content before trying to copynodes, check for error handling in DOM 3 LS + else if(_SARISSA_HAS_DOM_FEATURE && window.Document && !Document.prototype.load && document.implementation.hasFeature('LS', '3.0')){ + //Opera 9 may get the XPath branch which gives creates XMLDocument, therefore it doesn't reach here which is good /** *Factory method to obtain a new DOM Document object
* @argument sUri the namespace of the root node (if any) @@ -355,8 +379,19 @@ * @returns a new DOM Document */ Sarissa.getDomDocument = function(sUri, sName){ - return document.implementation.createDocument(sUri?sUri:"", sName?sName:"", null); - }; + var oDoc = document.implementation.createDocument(sUri?sUri:null, sName?sName:null, null); + return oDoc; + }; + } + else { + Sarissa.getDomDocument = function(sUri, sName){ + var oDoc = document.implementation.createDocument(sUri?sUri:null, sName?sName:null, null); + // looks like safari does not create the root element for some unknown reason + if(oDoc && (sUri || sName) && !oDoc.documentElement){ + oDoc.appendChild(oDoc.createElementNS(sUri, sName)); + }; + return oDoc; + }; }; };//if(_SARISSA_HAS_DOM_CREATE_DOCUMENT) }; @@ -364,13 +399,12 @@ // Common stuff //========================================== if(!window.DOMParser){ - /* - * DOMParser is a utility class, used to construct DOMDocuments from XML strings - * @constructor - */ - DOMParser = function() { - }; if(_SARISSA_IS_SAFARI){ + /* + * DOMParser is a utility class, used to construct DOMDocuments from XML strings + * @constructor + */ + DOMParser = function() { }; /** * Construct a new DOM Document from the given XMLstring * @param sXml the given XML string @@ -378,15 +412,13 @@ * @return a new DOM Document from the given XML string */ DOMParser.prototype.parseFromString = function(sXml, contentType){ - if(contentType.toLowerCase() != "application/xml"){ - throw "Cannot handle content type: \"" + contentType + "\""; - }; var xmlhttp = new XMLHttpRequest(); - xmlhttp.open("GET", "data:text/xml;charset=utf-8," + encodeURIComponent(str), false); + xmlhttp.open("GET", "data:text/xml;charset=utf-8," + encodeURIComponent(sXml), false); xmlhttp.send(null); return xmlhttp.responseXML; }; - }else if(Sarissa.getDomDocument && Sarissa.getDomDocument() && "loadXML" in Sarissa.getDomDocument()){ + }else if(Sarissa.getDomDocument && Sarissa.getDomDocument() && Sarissa.getDomDocument(null, "bar").xml){ + DOMParser = function() { }; DOMParser.prototype.parseFromString = function(sXml, contentType){ var doc = Sarissa.getDomDocument(); doc.loadXML(sXml); @@ -395,40 +427,36 @@ }; }; -if(window.XMLHttpRequest){ - Sarissa.IS_ENABLED_XMLHTTP = true; -} -else if(_SARISSA_IS_IE){ - /** - * Emulate XMLHttpRequest - * @constructor - */ - XMLHttpRequest = function() { - return new ActiveXObject(_SARISSA_XMLHTTP_PROGID); - }; - Sarissa.IS_ENABLED_XMLHTTP = true; -}; - -if(!window.document.importNode && _SARISSA_IS_IE){ +if((typeof(document.importNode) == "undefined") && _SARISSA_IS_IE){ try{ /** - * Implements importNode for the current window document in IE using innerHTML. - * Testing showed that DOM was multiple times slower than innerHTML for this, - * sorry folks. If you encounter trouble (who knows what IE does behind innerHTML) - * please gimme a call. + * Implementation of importNode for the context window document in IE * @param oNode the Node to import * @param bChildren whether to include the children of oNode * @returns the imported node for further use */ - window.document.importNode = function(oNode, bChildren){ - var importNode = document.createElement("div"); - if(bChildren) - importNode.innerHTML = Sarissa.serialize(oNode); - else - importNode.innerHTML = Sarissa.serialize(oNode.cloneNode(false)); - return importNode.firstChild; + document.importNode = function(oNode, bChildren){ + var tmp; + if(oNode.nodeName == "tbody" || oNode.nodeName == "tr"){ + tmp = document.createElement("table"); + } + else if(oNode.nodeName == "td"){ + tmp = document.createElement("tr"); + } + else if(oNode.nodeName == "option"){ + tmp = document.createElement("select"); + } + else{ + tmp = document.createElement("div"); + }; + if(bChildren){ + tmp.innerHTML = oNode.xml ? oNode.xml : oNode.outerHTML; + }else{ + tmp.innerHTML = oNode.xml ? oNode.cloneNode(false).xml : oNode.cloneNode(false).outerHTML; + }; + return tmp.getElementsByTagName("*")[0]; }; - }catch(e){}; + }catch(e){ }; }; if(!Sarissa.getParseErrorText){ /** @@ -442,17 +470,16 @@ */ Sarissa.getParseErrorText = function (oDoc){ var parseErrorText = Sarissa.PARSED_OK; - if(oDoc && oDoc.parseError && oDoc.parseError != 0){ - /*moz*/ - if(oDoc.documentElement.tagName == "parsererror"){ - parseErrorText = oDoc.documentElement.firstChild.data; - parseErrorText += "\n" + oDoc.documentElement.firstChild.nextSibling.firstChild.data; - }/*konq*/ - else{ - parseErrorText = Sarissa.getText(oDoc.documentElement);/*.getElementsByTagName("h1")[0], false) + "\n"; - parseErrorText += Sarissa.getText(oDoc.documentElement.getElementsByTagName("body")[0], false) + "\n"; - parseErrorText += Sarissa.getText(oDoc.documentElement.getElementsByTagName("pre")[0], false);*/ - }; + if(!oDoc.documentElement){ + parseErrorText = Sarissa.PARSED_EMPTY; + } else if(oDoc.documentElement.tagName == "parsererror"){ + parseErrorText = oDoc.documentElement.firstChild.data; + parseErrorText += "\n" + oDoc.documentElement.firstChild.nextSibling.firstChild.data; + } else if(oDoc.getElementsByTagName("parsererror").length > 0){ + var parsererror = oDoc.getElementsByTagName("parsererror")[0]; + parseErrorText = Sarissa.getText(parsererror, true)+"\n"; + } else if(oDoc.parseError && oDoc.parseError.errorCode != 0){ + parseErrorText = Sarissa.PARSED_UNKNOWN_ERROR; }; return parseErrorText; }; @@ -465,7 +492,7 @@ var nodeType = node.nodeType; if(nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE){ s += node.data; - }else if(deep == true + } else if(deep == true && (nodeType == Node.ELEMENT_NODE || nodeType == Node.DOCUMENT_NODE || nodeType == Node.DOCUMENT_FRAGMENT_NODE)){ @@ -474,40 +501,20 @@ }; return s; }; -if(window.XMLSerializer){ +if(!window.XMLSerializer + && Sarissa.getDomDocument + && Sarissa.getDomDocument("","foo", null).xml){ /** - *Factory method to obtain the serialization of a DOM Node
- * @returns the serialized Node as an XML string + * Utility class to serialize DOM Node objects to XML strings + * @constructor */ - Sarissa.serialize = function(oDoc){ - var s = null; - if(oDoc){ - s = oDoc.innerHTML?oDoc.innerHTML:(new XMLSerializer()).serializeToString(oDoc); - }; - return s; - }; -}else{ - if(Sarissa.getDomDocument && (Sarissa.getDomDocument("","foo", null)).xml){ - // see non-IE version - Sarissa.serialize = function(oDoc) { - var s = null; - if(oDoc){ - s = oDoc.innerHTML?oDoc.innerHTML:oDoc.xml; - }; - return s; - }; - /** - * Utility class to serialize DOM Node objects to XML strings - * @constructor - */ - XMLSerializer = function(){}; - /** - * Serialize the given DOM Node to an XML string - * @param oNode the DOM Node to serialize - */ - XMLSerializer.prototype.serializeToString = function(oNode) { - return oNode.xml; - }; + XMLSerializer = function(){}; + /** + * Serialize the given DOM Node to an XML string + * @param oNode the DOM Node to serialize + */ + XMLSerializer.prototype.serializeToString = function(oNode) { + return oNode.xml; }; }; @@ -523,7 +530,7 @@ */ Sarissa.clearChildNodes = function(oNode) { // need to check for firstChild due to opera 8 bug with hasChildNodes - while(oNode.firstChild){ + while(oNode.firstChild) { oNode.removeChild(oNode.firstChild); }; }; @@ -544,12 +551,11 @@ }; var ownerDoc = nodeTo.nodeType == Node.DOCUMENT_NODE ? nodeTo : nodeTo.ownerDocument; var nodes = nodeFrom.childNodes; - if(ownerDoc.importNode && (!_SARISSA_IS_IE)) { + if(typeof(ownerDoc.importNode) != "undefined") { for(var i=0;i < nodes.length;i++) { nodeTo.appendChild(ownerDoc.importNode(nodes[i], true)); }; - } - else{ + } else { for(var i=0;i < nodes.length;i++) { nodeTo.appendChild(nodes[i].cloneNode(true)); }; @@ -577,9 +583,9 @@ while(nodeFrom.firstChild){ nodeTo.appendChild(nodeFrom.firstChild); }; - }else{ + } else { var ownerDoc = nodeTo.nodeType == Node.DOCUMENT_NODE ? nodeTo : nodeTo.ownerDocument; - if(ownerDoc.importNode && (!_SARISSA_IS_IE)) { + if(typeof(ownerDoc.importNode) != "undefined") { for(var i=0;i < nodes.length;i++) { nodeTo.appendChild(ownerDoc.importNode(nodes[i], true)); }; Modified: kukit/kukit.js/trunk/kukit/plugin.js ============================================================================== --- kukit/kukit.js/trunk/kukit/plugin.js (original) +++ kukit/kukit.js/trunk/kukit/plugin.js Sun Apr 1 21:41:25 2007 @@ -94,9 +94,10 @@ }; kukit.pl.NativeEventBinder.prototype.__bind__ = function(name, func_to_bind, oper) { - oper.completeParms([], {'preventdefault': '', 'allowbubbling': ''}, 'native event binding'); + oper.completeParms([], {'preventdefault': '', 'allowbubbling': '', 'preventbubbling': ''}, 'native event binding'); oper.evalBool('preventdefault', 'native event binding'); oper.evalBool('allowbubbling', 'native event binding'); + oper.evalBool('preventbubbling', 'native event binding'); if (oper.parms.preventdefault) { if (name != 'click') { throw 'In native events only the click event can have preventdefault.'; @@ -108,6 +109,10 @@ var func = function(e) { target = kukit.pl.getTargetForBrowserEvent(e); if (allowbubbling || target == node) { + if (e.kss_preventbubbling) { + kukit.log('Ignored bubbling event because of preventbubbling=true for "' + name + '" (target =' + target.tagName + '), EventRule #' + oper.eventrule.getNr() + ' mergeid ' + oper.eventrule.kss_selector.mergeid); + return; + } // Execute the action, provide browserevent on oper // ... however, do it protected. We want the preventdefault // in any case! @@ -125,6 +130,11 @@ // MS style try { e.returnValue = false; } catch (exc2) {} } + // Prevent bubbling to other kss events ? + if (oper.parms.preventbubbling) { + e.kss_preventbubbling = true; + } + // if (exc != null) { // throw the original exception throw exc; From reebalazs at codespeak.net Sun Apr 1 23:35:43 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 1 Apr 2007 23:35:43 +0200 (CEST) Subject: [KSS-checkins] r41779 - kukit/kukit.js/trunk/kukit Message-ID: <20070401213543.70C581007C@code0.codespeak.net> Author: reebalazs Date: Sun Apr 1 23:35:41 2007 New Revision: 41779 Modified: kukit/kukit.js/trunk/kukit/plugin.js Log: Implement evt-xxx-preventbubbling event parameter Modified: kukit/kukit.js/trunk/kukit/plugin.js ============================================================================== --- kukit/kukit.js/trunk/kukit/plugin.js (original) +++ kukit/kukit.js/trunk/kukit/plugin.js Sun Apr 1 23:35:41 2007 @@ -109,10 +109,7 @@ var func = function(e) { target = kukit.pl.getTargetForBrowserEvent(e); if (allowbubbling || target == node) { - if (e.kss_preventbubbling) { - kukit.log('Ignored bubbling event because of preventbubbling=true for "' + name + '" (target =' + target.tagName + '), EventRule #' + oper.eventrule.getNr() + ' mergeid ' + oper.eventrule.kss_selector.mergeid); - return; - } + // Execute the action, provide browserevent on oper // ... however, do it protected. We want the preventdefault // in any case! @@ -132,7 +129,9 @@ } // Prevent bubbling to other kss events ? if (oper.parms.preventbubbling) { - e.kss_preventbubbling = true; + if (!e) var e = window.event; + e.cancelBubble = true; + if (e.stopPropagation) e.stopPropagation(); } // if (exc != null) { From reebalazs at codespeak.net Sun Apr 1 23:39:45 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 1 Apr 2007 23:39:45 +0200 (CEST) Subject: [KSS-checkins] r41780 - in kukit/kss.demo/trunk/kss/demo: browser browser/coreplugin tests/selenium_tests Message-ID: <20070401213945.97C7D1007C@code0.codespeak.net> Author: reebalazs Date: Sun Apr 1 23:39:42 2007 New Revision: 41780 Added: kukit/kss.demo/trunk/kss/demo/browser/coreplugin/ kukit/kss.demo/trunk/kss/demo/browser/coreplugin/__init__.py (contents, props changed) kukit/kss.demo/trunk/kss/demo/browser/coreplugin/azaxview.py (contents, props changed) kukit/kss.demo/trunk/kss/demo/browser/coreplugin/configure.zcml (contents, props changed) kukit/kss.demo/trunk/kss/demo/browser/coreplugin/kss_evt_preventbubbling.kss (contents, props changed) kukit/kss.demo/trunk/kss/demo/browser/coreplugin/kss_evt_preventbubbling.pt (contents, props changed) kukit/kss.demo/trunk/kss/demo/tests/selenium_tests/kss_prevent_bubbling.html (contents, props changed) Modified: kukit/kss.demo/trunk/kss/demo/browser/azax_demo_index.pt kukit/kss.demo/trunk/kss/demo/browser/configure.zcml Log: Adding selenium test for the preventbubbling Modified: kukit/kss.demo/trunk/kss/demo/browser/azax_demo_index.pt ============================================================================== --- kukit/kss.demo/trunk/kss/demo/browser/azax_demo_index.pt (original) +++ kukit/kss.demo/trunk/kss/demo/browser/azax_demo_index.pt Sun Apr 1 23:39:42 2007 @@ -8,7 +8,7 @@This demo shows how a rule can prevent bubbling of an event to its parent nodes
+ + ++Click anywhere inside this DIV to show an alert +
++Click here to trigger an event in both the A tag and in the parent node +
++Text +
++Click here to trigger an event only in the A tag +
++Text +
+| kss_prevent_bubbling | ||
| open | +/demo/kss_evt_preventbubbling.html | ++ |
| clickAt | +css=div#parent-node | ++ |
| assertAlert | +you clicked inside the DIV tag, rule=#0, node=DIV | ++ |
| assertAlertNotPresent | ++ | + |
| clickAt | +css=a#bubbling-node | ++ |
| assertAlert | +you clicked the bubbling A tag, rule=#1, node=A | ++ |
| assertAlert | +you clicked inside the DIV tag, rule=#0, node=DIV | ++ |
| assertAlertNotPresent | ++ | + |
| clickAt | +css=a#not-bubbling-node | ++ |
| assertAlert | +you clicked the not bubbling A tag, rule=#2, node=A | ++ |
| assertAlertNotPresent | ++ | + |