diff options
-rw-r--r-- | HISTORY | 3 | ||||
-rw-r--r-- | framework/Web/Javascripts/extended/event.js | 17 | ||||
-rw-r--r-- | framework/Web/Javascripts/js/prado.js | 21 | ||||
-rw-r--r-- | framework/Web/Javascripts/prado/element.js | 17 | ||||
-rw-r--r-- | framework/Web/UI/TTemplateManager.php | 21 |
5 files changed, 35 insertions, 44 deletions
@@ -10,9 +10,8 @@ Version 3.0.1 June 1, 2006 ENH: Ticket#150 - TDataGrid and TDataList now render table section tags (Qiang)
ENH: Ticket#152 - constituent parts of TWizard are exposed (Qiang)
ENH: added sanity check to calling event handlers (Qiang)
-CHG: Ticket#153 - TAssetManager now ignores .svn directories (Qiang)
-CHG: Ticket#154 - HTML comments are now parsed as regular template strings (Qiang)
CHG: Ticket#151 - URL format is modified to handle empty GET values (Qiang)
+CHG: Ticket#153 - TAssetManager now ignores .svn directories (Qiang)
NEW: TTableHeaderRow, TTableFooterRow and table section support (Qiang)
NEW: TCompositeControl (Qiang)
diff --git a/framework/Web/Javascripts/extended/event.js b/framework/Web/Javascripts/extended/event.js index 13e875da..29a8d5aa 100644 --- a/framework/Web/Javascripts/extended/event.js +++ b/framework/Web/Javascripts/extended/event.js @@ -63,13 +63,15 @@ Object.extend(Event, * Dispatch the DOM event of a given <tt>type</tt> on a DOM
* <tt>element</tt>. Only HTMLEvent and MouseEvent can be
* dispatched, keyboard events or UIEvent can not be dispatch
- * via javascript.
+ * via javascript consistently.
* @param {Object} element id string or a DOM element.
* @param {String} event type to dispatch.
*/
fireEvent : function(element,type)
{
element = $(element);
+ if(type == "submit")
+ return element.submit();
if(document.createEvent)
{
if(Event.isHTMLEvent(type))
@@ -86,19 +88,18 @@ Object.extend(Event, }
else
{
- if(Logger)
+ if(typeof(Logger) != "undefined")
Logger.error("undefined event", type);
return;
}
element.dispatchEvent(event);
}
- else if(element.fireEvent)
+ else if(document.createEventObject)
{
- element.fireEvent('on'+type);
- if(element[type])
- element[type]();
+ var evObj = document.createEventObject();
+ element.fireEvent('on'+type, evObj);
}
- else if(element[type])
- element[type]();
+ else if(typeof(element['on'+type]) == "function")
+ element['on'+type]();
}
});
\ No newline at end of file diff --git a/framework/Web/Javascripts/js/prado.js b/framework/Web/Javascripts/js/prado.js index f545ee74..9442ed26 100644 --- a/framework/Web/Javascripts/js/prado.js +++ b/framework/Web/Javascripts/js/prado.js @@ -123,20 +123,20 @@ Event.observe(window,'unload',Event.unloadCache,false);Object.extend(Event,{OnLo {return e.keyCode!=null?e.keyCode:e.charCode},isHTMLEvent:function(type) {var events=['abort','blur','change','error','focus','load','reset','resize','scroll','select','submit','unload'];return events.include(type);},isMouseEvent:function(type) {var events=['click','mousedown','mousemove','mouseout','mouseover','mouseup'];return events.include(type);},fireEvent:function(element,type) -{element=$(element);if(document.createEvent) +{element=$(element);if(type=="submit") +return element.submit();if(document.createEvent) {if(Event.isHTMLEvent(type)) {var event=document.createEvent('HTMLEvents');event.initEvent(type,true,true);} else if(Event.isMouseEvent(type)) {var event=document.createEvent('MouseEvents');event.initMouseEvent(type,true,true,document.defaultView,1,0,0,0,0,false,false,false,false,0,null);} else -{if(Logger) +{if(typeof(Logger)!="undefined") Logger.error("undefined event",type);return;} element.dispatchEvent(event);} -else if(element.fireEvent) -{element.fireEvent('on'+type);if(element[type]) -element[type]();} -else if(element[type]) -element[type]();}});var Position={includeScrollOffsets:false,prepare:function(){this.deltaX=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0;this.deltaY=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0;},realOffset:function(element){var valueT=0,valueL=0;do{valueT+=element.scrollTop||0;valueL+=element.scrollLeft||0;element=element.parentNode;}while(element);return[valueL,valueT];},cumulativeOffset:function(element){var valueT=0,valueL=0;do{valueT+=element.offsetTop||0;valueL+=element.offsetLeft||0;element=element.offsetParent;}while(element);return[valueL,valueT];},positionedOffset:function(element){var valueT=0,valueL=0;do{valueT+=element.offsetTop||0;valueL+=element.offsetLeft||0;element=element.offsetParent;if(element){p=Element.getStyle(element,'position');if(p=='relative'||p=='absolute')break;}}while(element);return[valueL,valueT];},offsetParent:function(element){if(element.offsetParent)return element.offsetParent;if(element==document.body)return element;while((element=element.parentNode)&&element!=document.body) +else if(document.createEventObject) +{var evObj=document.createEventObject();element.fireEvent('on'+type,evObj);} +else if(typeof(element['on'+type])=="function") +element['on'+type]();}});var Position={includeScrollOffsets:false,prepare:function(){this.deltaX=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0;this.deltaY=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0;},realOffset:function(element){var valueT=0,valueL=0;do{valueT+=element.scrollTop||0;valueL+=element.scrollLeft||0;element=element.parentNode;}while(element);return[valueL,valueT];},cumulativeOffset:function(element){var valueT=0,valueL=0;do{valueT+=element.offsetTop||0;valueL+=element.offsetLeft||0;element=element.offsetParent;}while(element);return[valueL,valueT];},positionedOffset:function(element){var valueT=0,valueL=0;do{valueT+=element.offsetTop||0;valueL+=element.offsetLeft||0;element=element.offsetParent;if(element){p=Element.getStyle(element,'position');if(p=='relative'||p=='absolute')break;}}while(element);return[valueL,valueT];},offsetParent:function(element){if(element.offsetParent)return element.offsetParent;if(element==document.body)return element;while((element=element.parentNode)&&element!=document.body) if(Element.getStyle(element,'position')!='static') return element;return document.body;},within:function(element,x,y){if(this.includeScrollOffsets) return this.withinIncludingScrolloffsets(element,x,y);this.xcomp=x;this.ycomp=y;this.offset=this.cumulativeOffset(element);return(y>=this.offset[1]&&y<this.offset[1]+element.offsetHeight&&x>=this.offset[0]&&x<this.offset[0]+element.offsetWidth);},withinIncludingScrolloffsets:function(element,x,y){var offsetcache=this.realOffset(element);this.xcomp=x+offsetcache[0]-this.deltaX;this.ycomp=y+offsetcache[1]-this.deltaY;this.offset=this.cumulativeOffset(element);return(this.ycomp>=this.offset[1]&&this.ycomp<this.offset[1]+element.offsetHeight&&this.xcomp>=this.offset[0]&&this.xcomp<this.offset[0]+element.offsetWidth);},overlap:function(mode,element){if(!mode)return 0;if(mode=='vertical') @@ -253,11 +253,8 @@ Prado.Element={setValue:function(element,value) el.value=value;},select:function(element,method,value) {var el=$(element);var isList=element.indexOf('[]')>-1;if(!el&&!isList)return;method=isList?'check'+method:el.tagName.toLowerCase()+method;var selection=Prado.Element.Selection;if(isFunction(selection[method])) selection[method](isList?element:el,value);},click:function(element) -{var el=$(element);if(!el)return;if(document.createEvent) -{var evt=document.createEvent('HTMLEvents');evt.initEvent('click',true,true);el.dispatchEvent(evt);} -else if(el.fireEvent) -{el.fireEvent('onclick');if(typeof(el.onclick)=="function") -el.onclick();}},setAttribute:function(element,attribute,value) +{var el=$(element);if(el) +Event.fireEvent(el,'click');},setAttribute:function(element,attribute,value) {var el=$(element);if(attribute=="disabled"&&value==false) el.removeAttribute(attribute);else el.setAttribute(attribute,value);},setOptions:function(element,options) diff --git a/framework/Web/Javascripts/prado/element.js b/framework/Web/Javascripts/prado/element.js index cf02095b..eec7fb92 100644 --- a/framework/Web/Javascripts/prado/element.js +++ b/framework/Web/Javascripts/prado/element.js @@ -26,21 +26,8 @@ Prado.Element = click : function(element)
{
var el = $(element);
- //Logger.info(el);
- if(!el) return;
- if(document.createEvent)
- {
- var evt = document.createEvent('HTMLEvents');
- evt.initEvent('click', true, true);
- el.dispatchEvent(evt);
- //Logger.warn("dispatching click for "+el.id);
- }
- else if(el.fireEvent)
- {
- el.fireEvent('onclick');
- if(typeof(el.onclick) == "function")
- el.onclick();
- }
+ if(el)
+ Event.fireEvent(el,'click');
},
setAttribute : function(element, attribute, value)
diff --git a/framework/Web/UI/TTemplateManager.php b/framework/Web/UI/TTemplateManager.php index 27bd0ac6..6e12726a 100644 --- a/framework/Web/UI/TTemplateManager.php +++ b/framework/Web/UI/TTemplateManager.php @@ -132,7 +132,9 @@ class TTemplateManager extends TModule * - directive: directive specifies the property values for the template owner.
* It is in the format of <% property name-value pairs %>
* - expressions: They are in the formate of <= PHP expression > and <% PHP statements >
- * - comments: Special template comments enclosed within <!-- comments --!> will be stripped out.
+ * - comments: There are two kinds of comments, regular HTML comments and special template comments.
+ * The former is in the format of <!-- comments -->, which will be treated as text strings.
+ * The latter is in the format of <%* comments %>, which will be stripped out.
*
* Tags other than the above are not required to be well-formed.
*
@@ -150,12 +152,13 @@ class TTemplate extends TApplicationComponent implements ITemplate {
/**
* '<!--.*?--!>' - template comments
+ * '<!--.*?-->' - HTML comments
* '<\/?com:([\w\.]+)((?:\s*[\w\.]+=\'.*?\'|\s*[\w\.]+=".*?"|\s*[\w\.]+=<%.*?%>)*)\s*\/?>' - component tags
* '<\/?prop:([\w\.]+)\s*>' - property tags
* '<%@\s*((?:\s*[\w\.]+=\'.*?\'|\s*[\w\.]+=".*?")*)\s*%>' - directives
* '<%[%#~\\$=\\[](.*?)%>' - expressions
*/
- const REGEX_RULES='/<!--.*?--!>|<\/?com:([\w\.]+)((?:\s*[\w\.]+=\'.*?\'|\s*[\w\.]+=".*?"|\s*[\w\.]+=<%.*?%>)*)\s*\/?>|<\/?prop:([\w\.]+)\s*>|<%@\s*((?:\s*[\w\.]+=\'.*?\'|\s*[\w\.]+=".*?")*)\s*%>|<%[%#~\\$=\\[](.*?)%>/msS';
+ const REGEX_RULES='/<!--.*?--!>|<!--.*?-->|<\/?com:([\w\.]+)((?:\s*[\w\.]+=\'.*?\'|\s*[\w\.]+=".*?"|\s*[\w\.]+=<%.*?%>)*)\s*\/?>|<\/?prop:([\w\.]+)\s*>|<%@\s*((?:\s*[\w\.]+=\'.*?\'|\s*[\w\.]+=".*?")*)\s*%>|<%[%#~\\$=\\[](.*?)%>/msS';
/**
* Different configurations of component property/event/attribute
@@ -664,11 +667,15 @@ class TTemplate extends TApplicationComponent implements ITemplate }
else if(strpos($str,'<!--')===0) // comments
{
- if($expectPropEnd)
- throw new TConfigurationException('template_comments_forbidden');
- if($matchStart>$textStart)
- $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
- $textStart=$matchEnd+1;
+ if(strrpos($str,'--!>')===strlen($str)-4) // template comments
+ {
+ if($expectPropEnd)
+ throw new TConfigurationException('template_comments_forbidden');
+ if($matchStart>$textStart)
+ $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
+ $textStart=$matchEnd+1;
+ }
+ // else, HTML comments and we do nothing
}
else
throw new TConfigurationException('template_matching_unexpected',$match);
|