yui显示弹出窗口js代码
来源:互联网 发布:小甲鱼c语言 编辑:程序博客网 时间:2024/05/16 09:24
YAHOO.namespace("example.container");//YAHOO.util.Event.onDOMReady(init);var beginer = null;function setBeginer(obj){beginer = obj;}function getBeginer(){return beginer;}function init(w,h) {//Instantiate the DialogYAHOO.example.container.dialog1 = new YAHOO.widget.SimpleDialog("dialog1", { width:w, height:h, modal: true, fixedcenter : true, visible : false, draggable:true, constraintoviewport : true});YAHOO.widget.SimpleDialog.prototype.cancel = function() {this.cancelEvent.fire();this.hide();document.getElementById("sCont1").src = "";};var dialog1_resize = new YAHOO.util.Resize("dialog1", { handles: ["br"], autoRatio: false, minWidth: w, minHeight: h, status: false });dialog1_resize.on("startResize", function(args) { if (this.cfg.getProperty("constraintoviewport")) { var D = YAHOO.util.Dom; var clientRegion = D.getClientRegion(); var elRegion = D.getRegion(this.element); dialog1_resize.set("maxWidth", clientRegion.right - elRegion.left - YAHOO.widget.Overlay.VIEWPORT_OFFSET); dialog1_resize.set("maxHeight", clientRegion.bottom - elRegion.top - YAHOO.widget.Overlay.VIEWPORT_OFFSET); } else { dialog1_resize.set("maxWidth", null); dialog1_resize.set("maxHeight", null);}}, YAHOO.example.container.dialog1, true);dialog1_resize.on("resize", function(args) { var panelHeight = args.height; this.cfg.setProperty("height", panelHeight + "px");}, YAHOO.example.container.dialog1, true);// Render the DialogYAHOO.example.container.dialog1.render();}//Closefunction saveAndClose(){ YAHOO.example.container.dialog1.hide(); document.getElementById("sCont1").src = ""; document.getElementById("sCont1").width="0" document.getElementById("sCont1").height="0"; document.getElementById("autoScrollIframe").src = ""; document.getElementById("autoScrollIframe").width="0"; document.getElementById("autoScrollIframe"). height="0"; }function saveAndClose2(){ YAHOO.example.container.dialog2.hide(); document.getElementById("sCont2").src = ""; //document.getElementById("sCont2").width="0"; //document.getElementById("sCont2"). height="0"; }/** * 显示模态层,传入宽、高时,自动调整iframe的宽高 * @param {String}层标题 * @param {String}层里iframe要显示路径 * @param {String}层里iframe的ID,缺省是sCont1 * @param {int} 层宽,缺省860 * @param {int} 层高,缺省520 */function _show(header,reqpath,frameId,w,h,isScroll){var showFrameId ;var defaultWidth = 860;var defaultHeight = 520;var defaultFrameId = 'sCont1';//alert('w:'+ w + ';' + 'h:' + h);if(frameId == '' || typeof(frameId)== "undefined" ){showFrameId = defaultFrameId;}else{showFrameId = frameId;}//alert(,w,h w + h);if(w == '' || typeof(w)== "undefined" ){w = defaultWidth;}if(h == '' || typeof(h)== "undefined"){h = defaultHeight;}//alert('w:'+ w + ';' + 'h:' + h);var dFrame;if (isScroll){ dFrame = document.getElementById('autoScrollIframe'); document.getElementById(showFrameId).width = 0 ; document.getElementById(showFrameId).height = 0 ;}else{ dFrame = document.getElementById(showFrameId); document.getElementById('autoScrollIframe').width = 0 ;document.getElementById('autoScrollIframe').height = 0;} dFrame.width = w ;dFrame.height = h;init(w + 20 +'px',h + 50 + 'px');//init();document.getElementById(showFrameId).srcdFrame.src = reqpath;YAHOO.example.container.dialog1.setHeader(header);YAHOO.example.container.dialog1.show(); }/*** Make a map like java.* You can use this map like this : * var myMap = new Map();* myMap.put("key","value");* var key = myMap.get("key");*/function Map() {this.elements = new Array();this.size = function() {return this.elements.length;}this.isEmpty = function() {return (this.elements.length < 1);}this.clear = function() {this.elements = new Array();}this.put = function(_key, _value) {if(!this.containsKey(_key))this.elements.push({key:_key, value:_value});}this.remove = function(_key) {var bln = false;try {for (i = 0; i < this.elements.length; i++) {if (this.elements[i].key == _key) {this.elements.splice(i, 1);return true;}}} catch(e) {bln = false;}return bln;}this.get = function(_key) {try{ for (i = 0; i < this.elements.length; i++) {if (this.elements[i].key == _key) {return this.elements[i].value;}}}catch(e) {return null;}}this.element = function(_index) {if (_index < 0 || _index >= this.elements.length) {return null;}return this.elements[_index];}this.containsKey = function(_key) {var bln = false;try {for (i = 0; i < this.elements.length; i++) {if (this.elements[i].key == _key) {bln = true;}}}catch(e) {bln = false;}return bln;}this.containsValue = function(_value) {var bln = false;try {for (i = 0; i < this.elements.length; i++) {if (this.elements[i].value == _value){bln = true;}}} catch(e) {bln = false;}return bln;}this.values = function() {var arr = new Array();for (i = 0; i < this.elements.length; i++) {arr.push(this.elements[i].value);}return arr;}this.keys = function() {var arr = new Array();for (i = 0; i < this.elements.length; i++) {arr.push(this.elements[i].key);}return arr;}}