diff options
author | wei <> | 2006-09-02 04:02:56 +0000 |
---|---|---|
committer | wei <> | 2006-09-02 04:02:56 +0000 |
commit | 32feb309dc59ca50757431d627db7437c0e29073 (patch) | |
tree | b31ef25e9e33a1a3cd63051fa8bdd39deab717cc /framework/Web | |
parent | 815c7462bbc4848939aa53cf375a0269d51b81fa (diff) |
Fixed #211
Diffstat (limited to 'framework/Web')
-rw-r--r-- | framework/Web/Javascripts/extended/event.js | 17 | ||||
-rw-r--r-- | framework/Web/Javascripts/js/compressed/prado.js | 7 | ||||
-rw-r--r-- | framework/Web/Javascripts/js/debug/prado.js | 18 | ||||
-rw-r--r-- | framework/Web/Javascripts/prado/controls.js | 1 | ||||
-rw-r--r-- | framework/Web/UI/TClientScriptManager.php | 2 | ||||
-rw-r--r-- | framework/Web/UI/TPage.php | 14 |
6 files changed, 48 insertions, 11 deletions
diff --git a/framework/Web/Javascripts/extended/event.js b/framework/Web/Javascripts/extended/event.js index 4fd041d8..e464fa94 100644 --- a/framework/Web/Javascripts/extended/event.js +++ b/framework/Web/Javascripts/extended/event.js @@ -82,10 +82,19 @@ Object.extend(Event, }
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);
+ var event = document.createEvent('MouseEvents');
+ if (event.initMouseEvent)
+ {
+ event.initMouseEvent(type,true,true,
+ document.defaultView, 1, 0, 0, 0, 0, false,
+ false, false, false, 0, null);
+ }
+ else
+ {
+ // Safari
+ // TODO we should be initialising other mouse-event related attributes here
+ event.initEvent(type, true, true);
+ }
}
element.dispatchEvent(event);
}
diff --git a/framework/Web/Javascripts/js/compressed/prado.js b/framework/Web/Javascripts/js/compressed/prado.js index 1ec69786..f2df6bf3 100644 --- a/framework/Web/Javascripts/js/compressed/prado.js +++ b/framework/Web/Javascripts/js/compressed/prado.js @@ -128,7 +128,10 @@ 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);} +{var event=document.createEvent('MouseEvents');if(event.initMouseEvent) +{event.initMouseEvent(type,true,true,document.defaultView,1,0,0,0,0,false,false,false,false,0,null);} +else +{event.initEvent(type,true,true);}} element.dispatchEvent(event);} else if(document.createEventObject) {var evObj=document.createEventObject();element.fireEvent('on'+type,evObj);} @@ -313,7 +316,7 @@ Event.observe(this.element,"keydown",this.handleReturnKey.bind(this));Event.obse {this.options=options;this._event=this.triggerEvent.bindEvent(this);Event.observe(options['Panel'],'keydown',this._event);},triggerEvent:function(ev,target) {var enterPressed=Event.keyCode(ev)==Event.KEY_RETURN;var isTextArea=Event.element(ev).tagName.toLowerCase()=="textarea";if(enterPressed&&!isTextArea) {var defaultButton=$(this.options['Target']);if(defaultButton) -{this.triggered=true;Event.fireEvent(defaultButton,this.options['Event']);Event.stop(ev);}}}};Prado.WebUI.TTextHighlighter=Class.create();Prado.WebUI.TTextHighlighter.prototype={initialize:function(id) +{this.triggered=true;$('PRADO_POSTBACK_TARGET').value=this.options.EventTarget;Event.fireEvent(defaultButton,this.options['Event']);Event.stop(ev);}}}};Prado.WebUI.TTextHighlighter=Class.create();Prado.WebUI.TTextHighlighter.prototype={initialize:function(id) {if(!window.clipboardData)return;var options={href:'javascript:;/'+'/copy code to clipboard',onclick:'Prado.WebUI.TTextHighlighter.copy(this)',onmouseover:'Prado.WebUI.TTextHighlighter.hover(this)',onmouseout:'Prado.WebUI.TTextHighlighter.out(this)'} var div=DIV({className:'copycode'},A(options,'Copy Code'));document.write(DIV(null,div).innerHTML);}};Object.extend(Prado.WebUI.TTextHighlighter,{copy:function(obj) {var parent=obj.parentNode.parentNode.parentNode;var text='';for(var i=0;i<parent.childNodes.length;i++) diff --git a/framework/Web/Javascripts/js/debug/prado.js b/framework/Web/Javascripts/js/debug/prado.js index 9a610de9..3dc8eefe 100644 --- a/framework/Web/Javascripts/js/debug/prado.js +++ b/framework/Web/Javascripts/js/debug/prado.js @@ -1689,10 +1689,19 @@ Object.extend(Event, }
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);
+ var event = document.createEvent('MouseEvents');
+ if (event.initMouseEvent)
+ {
+ event.initMouseEvent(type,true,true,
+ document.defaultView, 1, 0, 0, 0, 0, false,
+ false, false, false, 0, null);
+ }
+ else
+ {
+ // Safari
+ // TODO we should be initialising other mouse-event related attributes here
+ event.initEvent(type, true, true);
+ }
}
element.dispatchEvent(event);
}
@@ -2968,6 +2977,7 @@ Prado.WebUI.DefaultButton.prototype = if(defaultButton)
{
this.triggered = true;
+ $('PRADO_POSTBACK_TARGET').value = this.options.EventTarget;
Event.fireEvent(defaultButton, this.options['Event']);
Event.stop(ev);
}
diff --git a/framework/Web/Javascripts/prado/controls.js b/framework/Web/Javascripts/prado/controls.js index 2497c586..ae981524 100644 --- a/framework/Web/Javascripts/prado/controls.js +++ b/framework/Web/Javascripts/prado/controls.js @@ -202,6 +202,7 @@ Prado.WebUI.DefaultButton.prototype = if(defaultButton)
{
this.triggered = true;
+ $('PRADO_POSTBACK_TARGET').value = this.options.EventTarget;
Event.fireEvent(defaultButton, this.options['Event']);
Event.stop(ev);
}
diff --git a/framework/Web/UI/TClientScriptManager.php b/framework/Web/UI/TClientScriptManager.php index 30009c63..49a34a02 100644 --- a/framework/Web/UI/TClientScriptManager.php +++ b/framework/Web/UI/TClientScriptManager.php @@ -201,6 +201,7 @@ class TClientScriptManager extends TApplicationComponent $options = TJavaScript::encode($this->getDefaultButtonOptions($panel, $button)); $code = "new Prado.WebUI.DefaultButton($options);"; $this->registerEndScript("prado:".$panel->getClientID(), $code); + $this->registerHiddenField(TPage::FIELD_POSTBACK_TARGET,''); $this->registerPradoScript('prado'); } @@ -225,6 +226,7 @@ class TClientScriptManager extends TApplicationComponent { $options['Panel'] = $panel->getClientID(); $options['Target'] = $button->getClientID(); + $options['EventTarget'] = $button->getUniqueID(); $options['Event'] = 'click'; return $options; } diff --git a/framework/Web/UI/TPage.php b/framework/Web/UI/TPage.php index 8c01a501..f3fe7fc9 100644 --- a/framework/Web/UI/TPage.php +++ b/framework/Web/UI/TPage.php @@ -676,6 +676,14 @@ class TPage extends TTemplateControl {
if($beforeLoad)
$this->_restPostData=new TMap;
+ //change the post back target
+ if(($target=$postData[self::FIELD_POSTBACK_TARGET])!==null
+ && ($control=$this->findControl($target))
+ && ($control instanceof IPostBackEventHandler))
+ {
+ $this->_postData->add(self::FIELD_POSTBACK_TARGET,$target);
+ }
+
foreach($postData as $key=>$value)
{
if($this->isSystemPostField($key))
@@ -687,13 +695,17 @@ class TPage extends TTemplateControl if($control->loadPostData($key,$postData))
$this->_controlsPostDataChanged[]=$control;
}
- else if($control instanceof IPostBackEventHandler)
+ else if($control instanceof IPostBackEventHandler &&
+ empty($this->_postData[self::FIELD_POSTBACK_TARGET]))
+ {
$this->_postData->add(self::FIELD_POSTBACK_TARGET,$key); // not calling setPostBackEventTarget() because the control may be removed later
+ }
unset($this->_controlsRequiringPostData[$key]);
}
else if($beforeLoad)
$this->_restPostData->add($key,$value);
}
+
foreach($this->_controlsRequiringPostData as $key=>$value)
{
if($control=$this->findControl($key))
|