⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 atlascontrols.js

📁 《圣殿祭司的ASP.NET 2.0开发详解——使用C#》光盘内容.包含了书籍所含的源代码.非常经典的一本asp.net2.0的书籍
💻 JS
📖 第 1 页 / 共 3 页
字号:
//-----------------------------------------------------------------------// Copyright (C) Microsoft Corporation. All rights reserved.//-----------------------------------------------------------------------// AtlasControls.js// Atlas UI Toolkit.Type.registerNamespace('Web.UI');Web.UI.Label =function(associatedElement){Web.UI.Label.initializeBase(this,[associatedElement]);this.get_text =function(){return this.element.innerHTML;}this.set_text =function(value){this.element.innerHTML =value;}this.getDescriptor =function(){var td =Web.UI.Label.callBaseMethod(this,'getDescriptor');td.addProperty('text',String);return td;}Web.UI.Label.registerBaseMethod(this,'getDescriptor');}Type.registerClass('Web.UI.Label',Web.UI.Control);Web.TypeDescriptor.addType('script','label',Web.UI.Label);Web.UI.Image =function(associatedElement){Web.UI.Image.initializeBase(this,[associatedElement]);this.get_alternateText =function(){return this.element.alt;}this.set_alternateText =function(value){this.element.alt =value;}this.get_height =function(){return this.element.height;}this.set_height =function(value){this.element.height =value;}this.get_imageURL =function(){return this.element.src;}this.set_imageURL =function(value){this.element.src =value;}this.get_width =function(){return this.element.width;}this.set_width =function(value){this.element.width =value;}this.getDescriptor =function(){var td =Web.UI.Image.callBaseMethod(this,'getDescriptor');td.addProperty('alternateText',String);td.addProperty('height',Number);td.addProperty('imageURL',String);td.addProperty('width',Number);return td;}Web.UI.Image.registerBaseMethod(this,'getDescriptor');}Type.registerClass('Web.UI.Image',Web.UI.Control);Web.TypeDescriptor.addType('script','image',Web.UI.Image);Web.UI.HyperLink =function(associatedElement){Web.UI.HyperLink.initializeBase(this,[associatedElement]);var _clickHandler;this.get_navigateURL =function(){return this.element.href;}this.set_navigateURL =function(value){this.element.href =value;}this.getDescriptor =function(){var td =Web.UI.HyperLink.callBaseMethod(this,'getDescriptor');td.addProperty('navigateURL',String);td.addEvent('click',true);return td;}Web.UI.HyperLink.registerBaseMethod(this,'getDescriptor');this.click =this.createEvent();this.dispose =function(){if (_clickHandler){this.element.detachEvent('onclick',_clickHandler);_clickHandler =null;}Web.UI.HyperLink.callBaseMethod(this,'dispose');}this.initialize =function(){Web.UI.HyperLink.callBaseMethod(this,'initialize');_clickHandler =Function.createDelegate(this,this._onClick);this.element.attachEvent('onclick',_clickHandler);}this._onClick =function(){this.click.invoke(this,Web.EventArgs.Empty);}}Type.registerClass('Web.UI.HyperLink',Web.UI.Label);Web.TypeDescriptor.addType('script','hyperLink',Web.UI.HyperLink);Web.UI.Button =function(associatedElement){Web.UI.Button.initializeBase(this,[associatedElement]);var _clickHandler;this.getDescriptor =function(){var td =Web.UI.Button.callBaseMethod(this,'getDescriptor');td.addEvent('click',true);return td;}Web.UI.Button.registerBaseMethod(this,'getDescriptor');this.click =this.createEvent();this.dispose =function(){if (_clickHandler){this.element.detachEvent('onclick',_clickHandler);_clickHandler =null;}Web.UI.Button.callBaseMethod(this,'dispose');}this.initialize =function(){Web.UI.Button.callBaseMethod(this,'initialize');_clickHandler =Function.createDelegate(this,this._onClick);this.element.attachEvent('onclick',_clickHandler);}this._onClick =function(){this.click.invoke(this,Web.EventArgs.Empty);}}Type.registerClass('Web.UI.Button',Web.UI.Control);Web.TypeDescriptor.addType('script','button',Web.UI.Button);Web.UI.CheckBox =function(associatedElement){Web.UI.CheckBox.initializeBase(this,[associatedElement]);var _clickHandler;this.get_checked =function(){return this.element.checked;}this.set_checked =function(value){if (value !=this.get_checked()){this.element.checked =value;this.raisePropertyChanged('checked');}}this.click =this.createEvent();this.getDescriptor =function(){var td =Web.UI.CheckBox.callBaseMethod(this,'getDescriptor');td.addProperty('checked',Boolean);td.addEvent('click',true);return td;}Web.UI.CheckBox.registerBaseMethod(this,'getDescriptor');this.dispose =function(){if (_clickHandler){this.element.detachEvent('onclick',_clickHandler);_clickHandler =null;}Web.UI.CheckBox.callBaseMethod(this,'dispose');}this.initialize =function(){Web.UI.CheckBox.callBaseMethod(this,'initialize');_clickHandler =Function.createDelegate(this,this._onClick);this.element.attachEvent('onclick',_clickHandler);}this._onClick =function(){this.raisePropertyChanged('checked');this.click.invoke(this,Web.EventArgs.Empty);}}Type.registerClass('Web.UI.CheckBox',Web.UI.Control);Web.TypeDescriptor.addType('script','checkBox',Web.UI.CheckBox);Web.UI.Select =function(associatedElement){Web.UI.Select.initializeBase(this,[associatedElement]);var _selectionChangedHandler;var _data;var _textProperty;var _valueProperty;var _firstItemText;this.get_data =function(){return _data;}this.set_data =function(data){if (_data &&Web.INotifyCollectionChanged.isImplementedBy(_data)){_data.collectionChanged.remove(_dataChangedDelegate);}_data =data;if (_data){if (!Web.Data.DataTable.isInstanceOfType(_data)){_data =new Web.Data.DataTable(_data);}_data.collectionChanged.add(_dataChangedDelegate);}dataBind.call(this);this.raisePropertyChanged('data');}this.get_firstItemText =function(){return _firstItemText;}this.set_firstItemText =function(value){if (_firstItemText !=value){_firstItemText =value;this.raisePropertyChanged('firstItemText');dataBind.call(this);}}this.get_selectedValue =function(){return this.element.value;}this.set_selectedValue =function(value){this.element.value =value;}this.get_textProperty =function(){return _textProperty;}this.set_textProperty =function(name){_textProperty =name;this.raisePropertyChanged('textProperty');}this.get_valueProperty =function(){return _valueProperty;}this.set_valueProperty =function(name){_valueProperty =name;this.raisePropertyChanged('valueProperty');}this.selectionChanged =this.createEvent();function dataBind(){var options =this.element.options;var selectedValues =[];var i;for (i =options.length -1;i >=0;i--){if (options(i).selected){selectedValues.add(options(i).value);}options.remove(i);}var option;if (_firstItemText &&(_firstItemText.length !=0)){option =document.createElement("OPTION");option.text =_firstItemText;option.value ="";options.add(option);}if (_data){var length =_data.get_length();for (i =0;i <length;i++){var item =_data.getItem(i);option =document.createElement("OPTION");option.text =Web.TypeDescriptor.getProperty(item,_textProperty);option.value =Web.TypeDescriptor.getProperty(item,_valueProperty);option.selected =selectedValues.contains(option.value);options.add(option);}}}_dataChangedDelegate =Function.createDelegate(this,dataBind);this.dispose =function(){if (_selectionChangedHandler){this.element.detachEvent('onchange',_selectionChangedHandler);_selectionChangedHandler =null;}Web.UI.Select.callBaseMethod(this,'dispose');}this.getDescriptor =function(){var td =Web.UI.Select.callBaseMethod(this,'getDescriptor');td.addProperty("data",Web.Data.DataTable);td.addProperty('firstItemText',String);td.addProperty('selectedValue',String);td.addProperty('textProperty',String);td.addProperty('valueProperty',String);td.addEvent('selectionChanged',true);return td;}Web.UI.Select.registerBaseMethod(this,'getDescriptor');this.initialize =function(){Web.UI.Select.callBaseMethod(this,'initialize');_selectionChangedHandler =Function.createDelegate(this,this._onSelectionChanged);this.element.attachEvent('onchange',_selectionChangedHandler);}this._onSelectionChanged =function(){this.raisePropertyChanged('selectedValue');this.selectionChanged.invoke(this,Web.EventArgs.Empty);}}Type.registerClass('Web.UI.Select',Web.UI.Control);Web.TypeDescriptor.addType('script','select',Web.UI.Select);Web.UI.TextBox =function(associatedElement){Web.UI.TextBox.initializeBase(this,[associatedElement]);var _text;var _changeHandler;var _keyPressHandler;this.get_text =function(){return this.element.value;}this.set_text =function(value){if (this.element.value !=value){this.element.value =value;this.raisePropertyChanged('text');}}this.dispose =function(){if (_changeHandler){this.element.detachEvent('onchange',_changeHandler);_changeHandler =null;}if (_keyPressHandler){this.element.detachEvent('onkeypress',_keyPressHandler);_keyPressHandler =null;}Web.UI.TextBox.callBaseMethod(this,'dispose');}this.getDescriptor =function(){var td =Web.UI.TextBox.callBaseMethod(this,'getDescriptor');td.addProperty('text',String);td.addAttribute(Web.Attributes.ValueProperty,'text');return td;}Web.UI.TextBox.registerBaseMethod(this,'getDescriptor');this.initialize =function(){Web.UI.TextBox.callBaseMethod(this,'initialize');_text =this.element.value;_changeHandler =Function.createDelegate(this,this._onChanged);this.element.attachEvent('onchange',_changeHandler);_keyPressHandler =Function.createDelegate(this,this._onKeyPress);this.element.attachEvent('onkeypress',_keyPressHandler);}this._onChanged =function(){if (this.element.value !=_text){_text =this.element.value;this.raisePropertyChanged('text');}}this._onKeyPress =function(){var e =window.event;var key =e.keyCode;if (key ==13){if (this.element.value !=_text){_text =this.element.value;this.raisePropertyChanged('text');}}}}Type.registerClass('Web.UI.TextBox',Web.UI.InputControl);Web.TypeDescriptor.addType('script','textBox',Web.UI.TextBox);Web.UI.PopupBehavior =function(){Web.UI.PopupBehavior.initializeBase(this);var _x =0;var _y =0;var _positioningMode =Web.UI.PositioningMode.Absolute;var _parentElement;var _moveHandler;this.get_parentElement =function(){return _parentElement;}this.set_parentElement =function(element){_parentElement =element;this.raisePropertyChanged('parentElement');}this.get_positioningMode =function(){return _positioningMode;}this.set_positioningMode =function(mode){_positioningMode =mode;this.raisePropertyChanged('positioningMode');}this.get_x =function(){return _x;}this.set_x =function(x){_x =x;if (this.control.get_visible()){this.show();}this.raisePropertyChanged('x');}this.get_y =function(){return _y;}this.set_y =function(y){_y =y;if (this.control.get_visible()){this.show();}this.raisePropertyChanged('y');}this.hide =function(){this.control.set_visible(false);var elt =this.control.element;if (elt.originalWidth){elt.style.width =elt.originalWidth +"px";elt.originalWidth =null;}if (window.navigator &&window.navigator.appName =="Microsoft Internet Explorer"&&!window.opera){var childFrame =elt._hideWindowedElementsIFrame;if (childFrame){childFrame.style.display ="none";}}}this.show =function(){this.control.set_visible(true);var elt =this.control.element;var offsetParent =elt.offsetParent;if (!offsetParent)offsetParent =document.documentElement;var offsetParentLocation =Web.UI.Control.getLocation(offsetParent);var parent =_parentElement ?_parentElement :offsetParent;var parentBounds =Web.UI.Control.getBounds(parent);var diff ={x:parentBounds.x -offsetParentLocation.x,y:parentBounds.y -offsetParentLocation.y};var width =elt.offsetWidth -(elt.clientLeft ?elt.clientLeft *2 :0);var height =elt.offsetHeight -(elt.clientTop ?elt.clientTop *2 :0);var position;switch (_positioningMode){case Web.UI.PositioningMode.Center:position ={x:Math.round(parentBounds.width /2 -width /2),y:Math.round(parentBounds.height /2 -height /2)};break;case Web.UI.PositioningMode.BottomLeft:position ={x:0,y:parentBounds.height};break;case Web.UI.PositioningMode.BottomRight:position ={x:parentBounds.width -width,y:parentBounds.height};break;case Web.UI.PositioningMode.TopLeft:position ={x:0,y:-elt.offsetHeight};break;case Web.UI.PositioningMode.TopRight:position ={x:parentBounds.width -width,y:-elt.offsetHeight};break;default:position ={x:0,y:0};}position.x +=_x +diff.x;position.y +=_y +diff.y;Web.UI.Control.setLocation(elt,position);elt.style.width =width +"px";var newPosition =Web.UI.Control.getBounds(elt);var documentWidth =self.innerWidth ?self.innerWidth :document.documentElement.clientWidth;if (!documentWidth){documentWidth =document.body.clientWidth;}if (newPosition.x +newPosition.width >documentWidth -5){position.x -=newPosition.x +newPosition.width -documentWidth +5;}if (newPosition.x <0){position.x -=newPosition.x;}if (newPosition.y <0){position.y -=newPosition.y;}Web.UI.Control.setLocation(elt,position);if ((Web.Application.get_type()==Web.ApplicationType.InternetExplorer)&&!window.opera){var childFrame =elt._hideWindowedElementsIFrame;if (!childFrame){childFrame =document.createElement("iframe");childFrame.src ="about:blank";childFrame.style.position ="absolute";childFrame.style.display ="none";childFrame.scrolling ="no";childFrame.frameBorder ="0";childFrame.style.filter ="progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)";elt.parentNode.insertBefore(childFrame,elt);elt._hideWindowedElementsIFrame =childFrame;_moveHandler =Function.createDelegate(this,moveHandler);elt.attachEvent('onmove',_moveHandler);}childFrame.style.top =elt.style.top;childFrame.style.left =elt.style.left;childFrame.style.width =elt.offsetWidth +"px";childFrame.style.height =elt.offsetHeight +"px";childFrame.style.display =elt.style.display;if (elt.currentStyle &&elt.currentStyle.zIndex){childFrame.style.zIndex =elt.currentStyle.zIndex;}else if (elt.style.zIndex){childFrame.style.zIndex =elt.style.zIndex;}}}this.getDescriptor =function(){var td =Web.UI.PopupBehavior.callBaseMethod(this,'getDescriptor');td.addProperty('parentElement',Object,false,Web.Attributes.Element,true);td.addProperty('positioningMode',Web.UI.PositioningMode);td.addProperty('x',Number);td.addProperty('y',Number);td.addMethod('show');td.addMethod('hide');return td;}Web.UI.PopupBehavior.registerBaseMethod(this,'getDescriptor');this.initialize =function(){Web.UI.PopupBehavior.callBaseMethod(this,'initialize');this.hide();this.control.element.style.position ="absolute";}Web.UI.PopupBehavior.registerBaseMethod(this,'initialize');this.dispose =function(){if (_moveHandler &&this.control &&this.control.element){this.control.element.detachEvent('onmove',_moveHandler);}_parentElement =null;Web.UI.PopupBehavior.callBaseMethod(this,'dispose');}Web.UI.PopupBehavior.registerBaseMethod(this,'dispose');function moveHandler(){var elt =this.control.element;if (elt._hideWindowedElementsIFrame){elt.parentNode.insertBefore(elt._hideWindowedElementsIFrame,elt);elt._hideWindowedElementsIFrame.style.top =elt.style.top;elt._hideWindowedElementsIFrame.style.left =elt.style.left;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -