displayLightbox: function(display){ //将覆盖层显示 $('overlay').style.display = display; //将高亮层显示 $('lightbox').style.display = display; //如果不是隐藏状态,则调用该类中的loadInfo方法 if(display != 'none') this.loadInfo(); }, //该方法发送Ajax请求 loadInfo: function() { //当请求完成后调用本类中processInfo方法 var myAjax = new Ajax.Request( this.content, {method: 'get', parameters: "", onComplete: this.processInfo.bindAsEvent Listener (this)} ); }, // 将返回的文本信息显示到高亮层上 processInfo: function(response){ //获得返回的文本数据 var result = response.responseText; //显示到高亮层 info = "<div id='lbContent'>" + result + "</div>"; //在info元素前插入一个元素 new Insertion.Before($('lbLoadMessage'), info) //改变该元素的class name的值 $('lightbox').className = "done"; //调用本类中actions方法 this.actions(); var ctrl=$('lightbox'); //为高亮层添加事件处理方法reset Event.observe(ctrl, 'click', this.reset.bindAsEventListener(this), false); ctrl.onclick = function(){return false;}; }, //恢复初始状态 reset:function(){ //隐藏覆盖层 $('overlay').style.display="none"; //清空返回数据 $('lbContent').innerHTML=""; //隐藏高亮层 $('lightbox').style.display="none"; }, // Search through new links within the lightbox, and attach click event actions: function(){ lbActions = document.getElementsByClassName('lbAction'); for(i = 0; i < lbActions.length; i++) { Event.observe(lbActions[i], 'click', this[lbActions[i].rel].bindAs EventListener(this), false); lbActions[i].onclick = function(){return false;}; } |