var oPopup = { 0: null, 1: null, 3: null } function popupDebug(txt, oCfg){ if(gIsDebug) popup(NOTIFY_TYPE_DEBUG, txt, oCfg); } var dbgp = popupDebug; function popupPreview(txt, oArg1, oArg2){ popup(NOTIFY_TYPE_PREVIEW, txt, oArg1, oArg2); } function popupInfo(txt, oArg1, oArg2){ popup(NOTIFY_TYPE_INFO, txt, oArg1, oArg2); } function popupErr(txt, oArg1, oArg2){ popup(NOTIFY_TYPE_ERROR, txt, oArg1, oArg2); } function popupWarn(txt, oArg1, oArg2){ popup(NOTIFY_TYPE_WARNING, txt, oArg1, oArg2); } function popup(type, txt, oArg1, oArg2){ //alert("popup(" + type + ", txt)"); var sMsg='', isFn=0; if(typeof(oArg2)=='object') { if(typeof(oArg2.txt)!='undefined') txt = oArg2.txt; } if(typeof(txt)=='undefined' || txt.length==0) return; if (txt instanceof Array) { sMsg = txt.join('
'); } else if (typeof(txt)=='function') { isFn=1; } else { sMsg = txt; } if(sMsg.length==0 && isFn==0) return; var icon=null; var appendContent = true; var width = null; //width = YAHOO.util.Dom.getViewportWidth() * 0.5 + 'px'; width = '400px'; var height = null; var modal = false; var constraintoviewport = true; var autoscroll = true; var fixedcenter = true; //alert(type); switch (type) { case (NOTIFY_TYPE_PREVIEW): //icon = YAHOO.widget.SimpleDialog.ICON_WARN; appendContent = false; width = YAHOO.util.Dom.getViewportWidth() * 0.99 + 'px'; //height = YAHOO.util.Dom.getViewportHeight() * 0.99 + 'px'; constraintoviewport = true; fixedcenter = false; modal = true; break; case (NOTIFY_TYPE_DEBUG): icon = YAHOO.widget.SimpleDialog.ICON_WARN; modal = false; break; case (NOTIFY_TYPE_WARNING): icon = YAHOO.widget.SimpleDialog.ICON_WARN; break; case (NOTIFY_TYPE_ERROR): icon = YAHOO.widget.SimpleDialog.ICON_BLOCK; break; case (NOTIFY_TYPE_INFO): default: type = NOTIFY_TYPE_INFO; // Make sure it's set icon = YAHOO.widget.SimpleDialog.ICON_INFO; break; } icon = null; // Doesn't seem to work var handleClick = function handleClick(){ this.hide(); }; var sId = 'mvrz_popup' + type; var el = document.getElementById(sId); if(!el) { el = document.createElement('div'); el.id = sId; el.className = 'mvrz_popup' document.body.appendChild(el); } var oCfg = { width: width, height: height, fixedcenter: fixedcenter, visible: false, draggable: true, close: true, hideaftersubmit: true, modal: modal, zIndex: 999, iframe: true, postmethod: "none", //autoscroll: autoscroll, autoscroll: true, //icon: icon, //text: sMsg, constraintoviewport: constraintoviewport, buttons: [{ text: "OK", handler: handleClick, isDefault: true }] }; if (typeof(oPopup[type]) != 'object' || oPopup[type] == null) { oPopup[type] = new YAHOO.widget.SimpleDialog(sId, oCfg); if(icon!=null) oPopup[type].cfg.setProperty("icon", icon); oPopup[type].setHeader(notifyType[type]); oPopup[type].render(); } if (oPopup[type].cfg.getProperty("visible")) { var sPre = ''; if(appendContent) { var sBody = oPopup[type].body.innerHTML; if (sBody.length > 0) sPre = sBody + "
"; } if(isFn) { oPopup[type].setBody(sPre); txt(oPopup[type].body); } else oPopup[type].setBody(sPre + sMsg); //oPopup[type].show(); } else { if(isFn) { oPopup[type].setBody(''); txt(oPopup[type].body); } else oPopup[type].setBody(sMsg); oPopup[type].show(); } } var gPopupPage; function popupPage(fn, title, oCfg) { msg("popupPage(" + typeof(fn) + ")"); type = NOTIFY_TYPE_INFO; // Make sure it's set icon = YAHOO.widget.SimpleDialog.ICON_INFO; if(typeof(title)=='undefined') title = 'Information'; var handleClick = function(){ this.hide(); }; if (typeof(fn) !== 'function') { msg("No function"); } //var gPopupPage; // Temp this.resize = function resize(height, width) { //popupInfo("resize()"); if(typeof(width)=='undefined') width = YAHOO.util.Dom.getViewportWidth() * 0.95; if(width!=null) gPopupPage.cfg.setProperty('width', width+"px"); if(typeof(height)=='undefined') height = YAHOO.util.Dom.getViewportHeight() * 0.9; if(height!=null) gPopupPage.cfg.setProperty('height', height+"px"); } if(typeof(gPopupPage) != 'object') { var sId = 'mvrz-popuppage'; var el = document.getElementById(sId); if(!el) { el = document.createElement('div'); el.id = sId; //el.className += " yui-skin-sam"; //var oLayout = document.getElementById('layout'); //if(oLayout) oLayout.appendChild(el); //else document.body.appendChild(el); document.body.appendChild(el); } //var width = YAHOO.util.Dom.getViewportWidth() * 0.95; //var height = YAHOO.util.Dom.getViewportHeight() * 0.9; var oDialogCfg = { width: "100%", height: "100%", autoheight: "body", fixedcenter: true, visible: false, draggable: false, close: true, effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.25}, hideaftersubmit: true, modal: false, // if true then popups don't show over the top postmethod: "none", autoscroll: true, //icon: icon, //text: sMsg, constraintoviewport: true, buttons: [{ text: "OK", handler: handleClick, isDefault: true }] }; //gPopupPage = new YAHOO.widget.SimpleDialog(sId, oCfg); gPopupPage = new YAHOO.widget.Panel(sId, oDialogCfg); gPopupPage.setHeader(title); gPopupPage.setBody(''); gPopupPage.render(); gPopupPage.body.id = sId + '-bd'; YAHOO.util.Event.addListener(window, "resize", function() { this.resize(); },this, this); //resize(); //gPopupPage.show(); //gPopupPage.hide(); //popupPage(fn, title); // To try to get over issue with dropdowns in inline table editor not working //return; } else { //resize(); gPopupPage.setHeader(title); gPopupPage.setBody(''); } var oExtra, oNotice, oMessage; var oExtra = document.createElement('div'); //var ftStr = 'No Save button! - Don\'t worry, all changes are saved automatically.'; var ftStr = ''; if(typeof(oCfg)!='undefined' && typeof(oCfg.ft)!='undefined') { ftStr = oCfg.ft; if(ftStr.length) { var oNotice = document.createElement('p'); oNotice.className = 'popup-page-notice'; oExtra.appendChild(oNotice); } } var oMessage = document.createElement('p'); oMessage.className = 'popup-page-message'; var ftStr = 'No Save button! - Don\'t worry, all changes are saved automatically.'; if(ftStr.length) { oMessage.appendChild(document.createTextNode(ftStr)); oExtra.appendChild(oMessage); } gPopupPage.setFooter(oExtra); //oPopup.cfg.setProperty("icon", icon); fn(gPopupPage.body); //oPopup.forceDocumentRedraw(); resize(); gPopupPage.show(); $('#mvrz-popup-page a.container-close').bind('click', function(e){ $(this).closest('#mvrz-popup-page_c').css({visibility: 'hidden'}); }); }