var Dom = YAHOO.util.Dom; var Event = YAHOO.util.Event; var DDM = YAHOO.util.DragDropMgr; function pane(parentContainerId, oCfg){ msg('pane:' + typeof(parentContainerId)); var _parentContainerId = parentContainerId; // Private var _oCfg; // Private var _sId = YAHOO.util.Dom.generateId(null, parentContainerId+"-pane-"); this.name = _sId; this.id = _sId; if(typeof(oCfg) == 'undefined') _oCfg = new Object(); else _oCfg = MVRZ.util.clone(oCfg); this.ocfg = _oCfg; // TODO Debug only msg('pane:' + _sId); this.event = { change: new YAHOO.util.CustomEvent("change", this) } this.fnChange = function fnChange(e, oPane) { // Scope is the html element that caused the event msg(this.name + ": pane.fnChange()"); oPane.event.change.fire(oPane); } this.subscribe = function subscribe(type, fn, arg, scope) { this.event[type].subscribe(fn, arg, scope); } this.unsubscribeAll = function unsubscribeAll() { this.event.change.unsubscribeAll(); } // --- getDataSelect this.getDatasetSelect = function getDatasetSelect(datasetName, selectedId, selectField, postponeOptions){ msg('pane.getDatasetSelect:' + datasetName); oDataset = MY[datasetName]; if (typeof(postponeOptions) == 'undefined') postponeOptions = false; if (typeof(selectField) == 'undefined') { msg('pane.getDatasetSelect: using dataset default select field'); selectField = oDataset.inputs.selectField; } else { msg('pane.getDatasetSelect: using argument select field, fnOnChange is ' + typeof(selectField.fnOnChange)); } if (typeof(selectField) != 'undefined') { var input = datasetName + 'ID'; //var id = MVRZ.util.encodeSelectId(this.datasetName, input); var id = oDataset.getSelectId(); oDataset.selectId = id; selectField.noHandlers = true; var oSelectWrapper = MVRZ.util.render.input(selectField, id, selectedId, oDataset, false, postponeOptions); if (typeof(oSelectWrapper) == 'undefined' || oSelectWrapper == null) { msg('getDatasetSelect(' + datasetName + '):: input already defined'); } else { //parentContainer.appendChild(oSelectWrapper); } // Add the events oSelect = document.getElementById(id); YAHOO.util.Event.addListener(id, "change", fnChange, this); //return oSelect; return oSelectWrapper; //this.select(oSelect, selectedId); } } // --- cfg this.cfg = { setProperty: function setProperty(item, value) { ret =_oCfg[item]; // old value _oCfg[item] = value; return ret; }, getProperty: function getProperty(item) { ret = _oCfg[item]; return ret; } } // --- render this.render = function render(oArgs, appendToParent) { msg('pane:render:' + typeof(oArgs)); if(typeof(appendToParent)=='undefined') appendToParent = false; // Unsubscribe all current listeners ////this.unsubscribeAll(); var oContainer = document.getElementById(_sId); if(oContainer==null) { if(typeof(_parentContainerId)=='undefined') { _parentContainerId = _oCfg.parentContainerId; } if(typeof(_parentContainerId)=='object') { var parentContainerId = _parentContainerId; } else { if(_parentContainerId.length>0) { var parentContainer = document.getElementById(_parentContainerId); } if(typeof(parentContainer)!='object') { msg('pane:' + sId + ' - no append object'); return; } } oContainer = document.createElement("div"); oContainer.id = _sId; oContainer.className = PANE_CONTAINER_CLASSNAME; if(!appendToParent) parentContainer.innerHTML = ''; parentContainer.appendChild(oContainer); } else { oContainer.innerHTML = ''; // Reset } msg('pane:render id=' + oContainer.id); var content, oContent; if(typeof(_oCfg.render) === 'function') { content = _oCfg.render(this); } else { content = _oCfg.render; } switch(typeof(content)) { case('undefined'): ////oContent = document.createTextNode(_sId + ': render cfg is NOT DEFINED'); return; break; case('object'): oContent = content; break; default: // Text oContent = document.createElement("div"); oContent.innerHTML = content; } oContainer.appendChild(oContent); } this.show = function show(oContainer) { if(typeof(oContainer)=='undefined') oContainer = document.getElementById(_sId); if(oContainer && oContainer.style.display !== 'block') oContainer.style.display = 'block'; } this.hide = function hide(oContainer) { if(typeof(oContainer)=='undefined') oContainer = document.getElementById(_sId); if(oContainer && oContainer.style.display !== 'none') oContainer.style.display = 'none'; } }