新封装的仿kijiji的城市菜单
/// <reference name="MicrosoftAjax.js"/>
Type.registerNamespace("DDT");
DDT.CityButton = function(element) {
DDT.CityButton.initializeBase(this, [element]);
this.cityDiv;
}
DDT.CityButton.prototype = {
initialize: function() {
DDT.CityButton.callBaseMethod(this, 'initialize');
this._onMouseOverHandler = Function.createDelegate(this,this._onMouseOver);
this._onMouseOutHandler = Function.createDelegate(this,this._onMouseOut);
$addHandler(this.get_element(), "mouseover",this._onMouseOverHandler);
$addHandler(this.get_element(), "mouseout",this._onMouseOutHandler);
$addHandler(this.cityDiv, "mouseout",this._onMouseOutHandler);
$addHandler(this.cityDiv, "mouseover",this._onMouseOverHandler);
},
get_cityDiv : function() {return this.cityDiv;},
set_cityDiv : function(value) {
if (this.cityDiv != value) {
this.cityDiv = value;
this.raisePropertyChanged("cityDiv");
}
},
_onMouseOver:function(){
var Bounds = Sys.UI.DomElement.getBounds(this.get_element());
var x = Bounds.x;
var y = Bounds.height+Bounds.y;
Sys.UI.DomElement.setLocation(this.cityDiv,x,y);
Sys.UI.DomElement.setVisible(this.cityDiv,true);
},
_onMouseOut:function(){
Sys.UI.DomElement.setVisible(this.cityDiv,false);
},
dispose: function() {
//Add custom dispose actions here
DDT.CityButton.callBaseMethod(this, 'dispose');
}
}
DDT.CityButton.registerClass('DDT.CityButton', Sys.UI.Behavior);
if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
使用方法:Type.registerNamespace("DDT");
DDT.CityButton = function(element) {
DDT.CityButton.initializeBase(this, [element]);
this.cityDiv;
}
DDT.CityButton.prototype = {
initialize: function() {
DDT.CityButton.callBaseMethod(this, 'initialize');
this._onMouseOverHandler = Function.createDelegate(this,this._onMouseOver);
this._onMouseOutHandler = Function.createDelegate(this,this._onMouseOut);
$addHandler(this.get_element(), "mouseover",this._onMouseOverHandler);
$addHandler(this.get_element(), "mouseout",this._onMouseOutHandler);
$addHandler(this.cityDiv, "mouseout",this._onMouseOutHandler);
$addHandler(this.cityDiv, "mouseover",this._onMouseOverHandler);
},
get_cityDiv : function() {return this.cityDiv;},
set_cityDiv : function(value) {
if (this.cityDiv != value) {
this.cityDiv = value;
this.raisePropertyChanged("cityDiv");
}
},
_onMouseOver:function(){
var Bounds = Sys.UI.DomElement.getBounds(this.get_element());
var x = Bounds.x;
var y = Bounds.height+Bounds.y;
Sys.UI.DomElement.setLocation(this.cityDiv,x,y);
Sys.UI.DomElement.setVisible(this.cityDiv,true);
},
_onMouseOut:function(){
Sys.UI.DomElement.setVisible(this.cityDiv,false);
},
dispose: function() {
//Add custom dispose actions here
DDT.CityButton.callBaseMethod(this, 'dispose');
}
}
DDT.CityButton.registerClass('DDT.CityButton', Sys.UI.Behavior);
if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
$create(DDT.CityButton,{"cityDiv":$get("Layer1")},null,null,$get("btn"));
posted on 2008-03-13 17:01 jueban's space 阅读(239) 评论(0) 编辑 收藏 举报