//********************************************************// // Popup Class Ver. 0.5 // ÀÛ¼ºÀÚ : Çø³Ä¿¹Â´ÏÄÉÀ̼ÇÁî Á¤º´Å // ÀÛ¼ºÀÏ : 2008-04-01 // //********************************************************// var Popup = Class.create({ // Ŭ·¡½º »ý¼ºÀÚ ÇÔ¼ö initialize: function(element, url, options) { // ºñ¾îÀÖ´Â option °´Ã¼¸¦ »ý¼ºÇÑ´Ù. this.options = { top: 0, left: 0, width: 0, height: 0, overlay : false, opacity : 60, parameters : "", onLoad: Prototype.emptyFunction, onCloseBefore: Prototype.emptyFunction, onClose: Prototype.emptyFunction }; Object.extend(this.options, options || {}); if($(element)) this.element = $(element); else this.element = new Element("div",{id:element}); $$("body")[0].insert(this.element); this.closeHandler = this.close.bind(this); this.url = url; this.open(); }, // ÆË¾÷À» »ý¼ºÇÑ´Ù. open : function() { new Ajax.Request(this.url,{ parameters : this.options.parameters, onSuccess : function(request) { if(this.options.overlay) { this.overlay = new Effect.Overlay({opacity:this.options.opacity}); this.overlay.show(); } this.element.update(request.responseText); var arrayPageSize = getPageSize(); var arrayPageScroll = getPageScroll(); var width = (this.options.width ? this.options.width : this.element.down("div").offsetWidth); var height = (this.options.height ? this.options.height : this.element.down("div").offsetHeight); var toTop = (arrayPageScroll[1] + ((arrayPageSize[3] - height) / 2)); var top = (this.options.top ? this.options.top : toTop > 0? toTop : 0); var left = (this.options.left ? this.options.left : (((arrayPageSize[0] - width) / 2))); this.element.setStyle({position:"absolute", display:"block", width:width+"px", height:height+"px", top:(height > 0 ? top : 0)+"px", left:(width > 0 ? left : 0)+"px", zIndex:this.options.overlay ? this.overlay.options.zIndex+1 : 1000}); //this.element.setOpacity(1); //this.startDrag(); this.element.select(".popupClose").invoke("observe", "click", this.closeHandler).invoke("setStyle",{cursor:"pointer"}); if(typeof this.options.onLoad == "function") this.options.onLoad(); }.bind(this), onFailure : function(request) { trace(request.responseText); } }); }, // ÇöÀç ÆË¾÷¿¡ µå·¡±× ¼Ó¼ºÀ» ºÎ¿©ÇÑ´Ù. startDrag : function() { this.draggable = new Effect.Drag(this.element); }, // ÇöÀç ÆË¾÷¿¡ µå·¡±× ¼Ó¼ºÀ» »èÁ¦ÇÑ´Ù. stopDrag : function() { this.draggable.stop(); }, // ÇöÀç ÆË¾÷À» »èÁ¦ÇÑ´Ù. close : function() { if(this.options.overlay) this.overlay.hide(); this.element.select(".popupClose").invoke("stopObserving", "click", this.closeHandler); if(typeof this.options.onCloseBefore == "function") this.options.onCloseBefore(); this.element.remove(); if(typeof this.options.onClose == "function") this.options.onClose(); } });