summaryrefslogtreecommitdiff
path: root/framework/Web/Javascripts
diff options
context:
space:
mode:
authorxue <>2006-05-05 12:14:48 +0000
committerxue <>2006-05-05 12:14:48 +0000
commit94583ceb3e1d6bb2ab7a61c4907487a152fb4801 (patch)
tree5fcb9cd8f42c352147ef61a4dc422911ee587c95 /framework/Web/Javascripts
parentdb7d5e7d65bba035a5adedc84d683f3195bf27ea (diff)
Merge from 3.0 branch till 1033.
Diffstat (limited to 'framework/Web/Javascripts')
-rw-r--r--framework/Web/Javascripts/extended/event.js17
-rw-r--r--framework/Web/Javascripts/js/prado.js21
-rw-r--r--framework/Web/Javascripts/prado/element.js17
3 files changed, 20 insertions, 35 deletions
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)