You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xap-commits@incubator.apache.org by jm...@apache.org on 2007/04/20 20:14:10 UTC
svn commit: r530904 - in /incubator/xap/trunk/codebase/src/xap: Xap.js
bridges/basic/HtmlHostBridge.js util/CssUtils.js
xml/xmodify/CommandDirective.js
Author: jmargaris
Date: Fri Apr 20 13:14:10 2007
New Revision: 530904
URL: http://svn.apache.org/viewvc?view=rev&rev=530904
Log:
Patches for https://issues.apache.org/jira/browse/XAP-369, 370
and 387
Added:
incubator/xap/trunk/codebase/src/xap/util/CssUtils.js (with props)
Modified:
incubator/xap/trunk/codebase/src/xap/Xap.js
incubator/xap/trunk/codebase/src/xap/bridges/basic/HtmlHostBridge.js
incubator/xap/trunk/codebase/src/xap/xml/xmodify/CommandDirective.js
Modified: incubator/xap/trunk/codebase/src/xap/Xap.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/Xap.js?view=diff&rev=530904&r1=530903&r2=530904
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/Xap.js (original)
+++ incubator/xap/trunk/codebase/src/xap/Xap.js Fri Apr 20 13:14:10 2007
@@ -149,7 +149,7 @@
*
*/
Xap.provide = function(){
- dojo.provide.apply(dojo,arguments);
+ return dojo.provide.apply(dojo,arguments);
}
Modified: incubator/xap/trunk/codebase/src/xap/bridges/basic/HtmlHostBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/bridges/basic/HtmlHostBridge.js?view=diff&rev=530904&r1=530903&r2=530904
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/bridges/basic/HtmlHostBridge.js (original)
+++ incubator/xap/trunk/codebase/src/xap/bridges/basic/HtmlHostBridge.js Fri Apr 20 13:14:10 2007
@@ -41,13 +41,15 @@
*/
xap.bridges.basic.HtmlHostBridge = function() {
xap.taghandling.AbstractTagImpl.call( this );
-}
+};
+
+
+Xap.setupClassAsSubclassOf("xap.bridges.basic.HtmlHostBridge", "xap.taghandling.AbstractTagImpl");
-xap.bridges.basic.HtmlHostBridge.prototype = new xap.taghandling.AbstractTagImpl;
xap.bridges.basic.HtmlHostBridge.prototype.toString = function() {
return "xap.bridges.basic.HtmlHostBridge";
-}
+};
/**
* All bridges to DwtControls should go through these steps:
@@ -68,51 +70,85 @@
* from tail to head we do it from head to tail.
*/
xap.bridges.basic.HtmlHostBridge.prototype.init = function() {
- this.createPeer();
-}
+ var element = this.getElement();
+ this.parseInitialAttributes( element );
+ if(element && element.getAttribute('htmlElementId')) {
+ this.createPeer( element.getAttribute('htmlElementId') );
+ var contentHandler = this.getSession().getUiDocumentHandler();
+ var childNodes = this.getElement().childNodes;
+ if (!xap.taghandling.AbstractTagImpl.TAIL_RECURSION){
+ for (var i = 0; i<childNodes.length;i++){
+ if (childNodes[i].nodeType==google.DOM_ELEMENT_NODE){
+ contentHandler.parseChild( childNodes[i] );
+ }
+ }
+ }
+ }
+};
+
/**
* Creates the peer component that this bridge controls.
+ * This implementation uses existing HTML element.
+ * @param parentElementId The id of HTML peer element
+ *
*/
-xap.bridges.basic.HtmlHostBridge.prototype.createPeer = function() {
-}
+xap.bridges.basic.HtmlHostBridge.prototype.createPeer = function(parentElementId) {
+ var parentElement = document.getElementById(parentElementId);
+ this.createHost(parentElement, "dojo");
+};
+
+/**
+ * Sets the peer element for this instance of HtmlHostBridge.
+ * @param parentElement HTML element to use as peer
+ * @param toolkitType Should be 'dojo'.
+ *
+ */
xap.bridges.basic.HtmlHostBridge.prototype.createHost = function(parentElement, toolkitType) {
- var parentElementWrapper = null ;
+
+ var parentElementWrapper = null ;
+
// If the handler handles a dojo widget, its relevant dom node will be the parentElement;
// if zimbroid, it will have to be found some other way Zimbra will handle:
- if( toolkitType && toolkitType=="dojo"){
- parentElementWrapper = parentElement!=null? parentElement : document.body ;
-
- this.getNodeForChildren = function(){
- return parentElement ;
- }
-
- this.childAdded = function( e ) {
- var childElement = e.getChange();
- var childHandler = this.getUiContentHandler().getHandlerForElement( childElement );
- this.addChild(childHandler, e.getIndex());
- }
-
- this.addChild = function(child, index){
- if (child.getRootDomNode && child.getRootDomNode()){
- this.getNodeForChildren().appendChild(child.getRootDomNode());
- }
- }
+ if( toolkitType && toolkitType=="dojo") {
+ parentElementWrapper = ( parentElement != null ) ? parentElement : document.body ;
}
//have the parentElementWrapper be the peer of the xap.taghandling.AbstractTagImpl
this.setPeer(parentElementWrapper);
-
-}
+};
+
+
+/**
+ * On child added to XAL document
+ * @param e Event object
+ */
+xap.bridges.basic.HtmlHostBridge.prototype.childAdded = function( e ) {
+ var childElement = e.getChange();
+ var childHandler = this.getUiContentHandler().getHandlerForElement( childElement );
+ this.addChild(childHandler, e.getIndex());
+};
+
+/**
+ * Appends a child to this node
+ * @param childHandler XAL child node
+ * @param index Unused
+ */
+xap.bridges.basic.HtmlHostBridge.prototype.addChild = function(childHandler, index) {
+ if ( childHandler.getRootDomNode ) {
+ this.getRootDomNode().appendChild(childHandler.getRootDomNode());
+ }
+};
+
/**
* Returns the node that represents this widget at the top level,
* for example the wrapping div. We will set basic attributes
* like color on this div in the absence of better setter methods.
*/
-xap.bridges.basic.HtmlHostBridge.prototype.getRootDomNode = function(){
+xap.bridges.basic.HtmlHostBridge.prototype.getRootDomNode = function() {
return this.getPeer();
-}
+};
Added: incubator/xap/trunk/codebase/src/xap/util/CssUtils.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/util/CssUtils.js?view=auto&rev=530904
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/util/CssUtils.js (added)
+++ incubator/xap/trunk/codebase/src/xap/util/CssUtils.js Fri Apr 20 13:14:10 2007
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ *
+ */
+
+ /**
+ * This class contains useful helper methods for working with HTML/CSS.
+ *
+ */
+
+//Let Dojo know what to expect from this file:
+Xap.provide("xap.util.CssUtils");
+
+
+/**
+ * Finds CSS rule by name in all loaded stylesheets.
+ * @param ruleName an exact name of the CSS rule as declared inline or in CSS file
+ * @return CSS Rule object or null
+ *
+ */
+xap.util.CssUtils.getCSSRule = function (ruleName) {
+ if (document.styleSheets) {
+ for (var i = 0; i < document.styleSheets.length; i++) {
+ var currentStyleSheet=document.styleSheets[i];
+ if( ! currentStyleSheet) { continue; }
+ var rule = xap.util.CssUtils.getCSSRuleFromStyleSheet(ruleName, currentStyleSheet);
+ if(rule && rule.selectorText == ruleName) { return rule; }
+ }
+ }
+ return null;
+};
+
+/**
+ * Finds CSS rule by name in given stylesheet.
+ * @param ruleName an exact name of the CSS rule as declared inline or in CSS file
+ * @param styleSheet stylesheet object to search in
+ * @return CSS Rule object or null
+ *
+ */
+xap.util.CssUtils.getCSSRuleFromStyleSheet = function (ruleName, styleSheet) {
+ if(styleSheet) {
+ var styleSheetRules = styleSheet.cssRules ? styleSheet.cssRules : styleSheet.rules;
+ if(!styleSheetRules) { return null; }
+ for(var j = 0; j < styleSheetRules.length; j++) {
+ var rule = styleSheetRules[j];
+ if(rule.type == 3) { rule = xap.util.CssUtils.getCSSRuleFromStyleSheet(ruleName, rule.styleSheet); }
+ if(rule && rule.selectorText == ruleName) {
+ return rule;
+ }
+ }
+ } return null;
+};
Propchange: incubator/xap/trunk/codebase/src/xap/util/CssUtils.js
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/xap/trunk/codebase/src/xap/xml/xmodify/CommandDirective.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/xml/xmodify/CommandDirective.js?view=diff&rev=530904&r1=530903&r2=530904
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/xml/xmodify/CommandDirective.js (original)
+++ incubator/xap/trunk/codebase/src/xap/xml/xmodify/CommandDirective.js Fri Apr 20 13:14:10 2007
@@ -790,17 +790,19 @@
* @param uiDocument
* @param targetNodes
*/
-xap.xml.xmodify.CommandDirective.prototype._handleEmbedXal = function(uiDocument, targetNodes)
+xap.xml.xmodify.CommandDirective.prototype._handleEmbedXal = function(htmlDocument, targetNodes)
{
Xap.require("xap.bridges.basic.HtmlHostBridge");
var elemsToAppend = this._commandArguments;
+ var uiDocument = this._session.getDocumentContainer().getUiDocument();
for(var i = 0; i < targetNodes.length; i++) {
+
var parentElement = targetNodes[i] ;
- //create the element and add it to the document
- var hostElement = uiDocument.createElement("htmlHost", "http://openxal.org/ui", null);
- hostElement = uiDocument.getRootElement().appendChild(hostElement);
+ //create the element and add it to the document
+ var hostElement = uiDocument.createElement("htmlHost", "http://openxal.org/ui");
+ uiDocument.getRootElement().appendChild(hostElement);
//get the handler and set up the peer.
var htmlHostBridge = this._session.getUiDocumentHandler().getHandlerForElement(hostElement);