| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574 |
- /* Copyright (c) Business Objects 2006. All rights reserved. */
- if (typeof bobj.crv.params.ParameterPanel == 'undefined') {
- bobj.crv.params.ParameterPanel = {};
- bobj.crv.params.ParameterPanelToolbar = {};
- bobj.crv.params.ParameterTab = {};
- bobj.crv.params.ParameterDialog = {};
- }
- /*
- ================================================================================
- ParameterPanel
- ================================================================================
- */
- /**
- * Constructor
- */
- bobj.crv.params.newParameterPanel = function(kwArgs) {
- kwArgs = MochiKit.Base.update({
- id: bobj.uniqueId() + '_IPPanel'
- }, kwArgs);
-
- var o = newWidget(kwArgs.id);
- o.widgetType = 'ParameterPanel';
-
- // Update instance with constructor arguments
- bobj.fillIn(o, kwArgs);
-
- // Update instance with member functions
- MochiKit.Base.update(o, bobj.crv.params.ParameterPanel);
-
- o._tabPanel = bobj.crv.newStackedPanel({
- id: o.id + '_ParamtersStack'
- });
- o._selected = null;
-
- o._toolbar = bobj.crv.params.newParameterPanelToolbar({
- id: o.id + '_IPToolbar'
- });
-
- return o;
- };
- bobj.crv.params.ParameterPanel.setToolbarCallBacks = function(delClickCB,applyClickCB)
- {
- if(this._toolbar) {
- this._toolbar.delClickCB = delClickCB;
- this._toolbar.applyClickCB = applyClickCB;
- }
- };
- bobj.crv.params.ParameterPanel.init = function() {
- Widget_init.call(this);
- this._toolbar.init();
- if (this._tabPanel) {
- this._tabPanel.init();
- }
- };
- bobj.crv.params.ParameterPanel.getHTML = function() {
- var DIV = bobj.html.DIV;
- var layerStyle = this._getCommonLayerStyle();
- layerStyle.overflow = 'hidden';
-
- var innerHTML = this._toolbar.getHTML();
- if (this._tabPanel) {
- innerHTML += this._tabPanel.getHTML();
- }
-
- return DIV({id: this.id, style: layerStyle}, innerHTML);
- };
- bobj.crv.params.ParameterPanel._getErrorMsgContent = function(errMsg) {
- var DIV = bobj.html.DIV;
- var layerStyle = this._getCommonLayerStyle();
- return DIV({id: this.id, style: layerStyle}, errMsg);
- };
- bobj.crv.params.ParameterPanel._getCommonLayerStyle = function() {
- var layerStyle = {};
-
- if (this.height) {
- layerStyle.height = bobj.unitValue(this.height);
- }
-
- if (this.width) {
- layerStyle.width = bobj.unitValue(this.width);
- }
-
- return layerStyle;
- };
- /**
- * Show error message in the panel.
- *
- * @param errMsg [string] Error message to be shown
- */
- bobj.crv.params.ParameterPanel.showError = function(errMsg) {
- if (errMsg) {
- this.setHTML(this._getErrorMsgContent(errMsg));
- }
- };
- /**
- * Resize the panel
- *
- * @param w [int - optional] Width in pixels
- * @param h [int - optional] Height in pixels
- */
- bobj.crv.params.ParameterPanel.resize = function(w, h) {
- Widget_resize.call(this, w, h);
- if (this._toolbar) {
- w = this.layer.clientWidth;
- this._toolbar.resize(w);
- if (this._tabPanel) {
- h = this.layer.clientHeight - this._toolbar.getHeight();
- this._tabPanel.resize(w, h);
- }
- }
- };
- /**
- * Add a ParameterUI instance to the panel
- *
- * @param paramUI [ParameterUI]
- * @param label [String] Parameter title
- * @param isDataFetching [bool] Shows the data fetching icon when true
- * @param isDirty [bool] Shows the dirty icon when true
- */
- bobj.crv.params.ParameterPanel.addParameter = function(kwArgs) {
- kwArgs = MochiKit.Base.update({
- paramUI: null,
- label: null,
- isDataFetching: false,
- isDirty: false,
- isReadOnly: false,
- selectCB: null,
- openAdvCB: null,
- minMaxTooltip: null,
- id: this._tabPanel.id + '_P' + (this._tabPanel.getNumTabs() + 1)
- },kwArgs);
-
- if (kwArgs.paramUI) {
- var paramTab = bobj.crv.params.newParameterTab(kwArgs);
- paramTab.setContent(kwArgs.paramUI);
- this._tabPanel.addTab(paramTab);
- }
- };
- /**
- * Remove a ParameterUI instance from the panel
- *
- * @param index [int] Index of the widget
- */
- bobj.crv.params.ParameterPanel.removeParameter = function(index) {
- this._tabPanel.removeTab(index);
- };
- /**
- * @return [int] The width, in pixels, of the panel
- */
- bobj.crv.params.ParameterPanel.getWidth = function() {
- if (this.layer) {
- return this.layer.offsetWidth;
- }
- return this.width;
- };
- bobj.crv.params.ParameterPanel.setDeleteButtonEnabled = function(isEnabled) {
- this._toolbar.delButton.setDisabled(!isEnabled);
- };
- bobj.crv.params.ParameterPanel.setApplyButtonEnabled = function(isEnabled) {
- this._toolbar.applyButton.setDisabled(!isEnabled);
- };
- bobj.crv.params.ParameterPanel.getIndex = function(paramUI) {
- var numTabs = this._tabPanel.getNumTabs();
- for (var idx = 0; idx < numTabs; ++idx) {
- var tab = this._tabPanel.getTab(idx);
- if (tab.getContent() === paramUI) {
- return idx;
- }
- }
- return -1;
- };
- bobj.crv.params.ParameterPanel.getParameter = function(index) {
- var tab = this._tabPanel.getTab(index);
- if (tab) {
- return tab.getContent();
- }
- return null;
- };
- bobj.crv.params.ParameterPanel.setDirty = function(index, isDirty) {
- var tab = this._tabPanel.getTab(index);
- if (tab) {
- tab.setDirty(isDirty);
- tab.getContent().setBgColor ();
- }
- };
- bobj.crv.params.ParameterPanel.isDirty = function(index) {
- var tab = this._tabPanel.getTab(index);
- if (tab) {
- return tab.isDirty();
- }
- return false;
- };
- bobj.crv.params.ParameterPanel.setSelected = function(index, isSelected) {
- var tab = this._tabPanel.getTab(index);
- if (tab) {
- if (this._selected) {
- this._selected.setSelected(false);
- }
- tab.setSelected(isSelected);
- this._selected = tab;
- }
- };
- bobj.crv.params.ParameterPanel.expand = function(index) {
- var tab = this._tabPanel.getTab(index);
- if (tab) {
- tab.expand();
- }
- };
- /*
- ================================================================================
- ParameterPanelToolbar
- Contains the Delete and Run buttons
- ================================================================================
- */
- // these are the Y offsets of the icons in the param_panel.gif image
- bobj.crv.paramPanelIcon = bobj.crvUri('images/param_panel.gif');
- bobj.crv.paramDataFetchingIconYOffset = 32; // param_datafetching.gif
- bobj.crv.paramDirtyIconYOffset = 48; // param_dirty.gif
- bobj.crv.paramInfoIconYOffset = 64; // param_info.gif
- bobj.crv.paramsApplyIconYOffset = 80; // param_run.gif
- bobj.crv.paramsDeleteIconYOffset = 102; // delete.gif
- /**
- * Constructor
- */
- bobj.crv.params.newParameterPanelToolbar = function(kwArgs) {
- kwArgs = MochiKit.Base.update({
- id: bobj.uniqueId()
- }, kwArgs);
- var o = newPaletteContainerWidget(kwArgs.id);
- bobj.fillIn(o, kwArgs);
- o.widgetType = 'ParameterPanelToolbar';
-
- // Attach member functions
- o._paletteContainerInit = o.init;
- MochiKit.Base.update(o, bobj.crv.params.ParameterPanelToolbar);
-
- o._palette = newPaletteWidget(o.id + "_palette");
- o.add(o._palette);
-
- var bind = MochiKit.Base.bind;
-
- o.delButton = newIconWidget(
- o.id + '_delBtn',
- bobj.crv.paramPanelIcon,
- bind(o._onDelClick, o), //clickCB,
- L_bobj_crv_ParamsDelete,//text,
- L_bobj_crv_ParamsDeleteTooltip,//tooltip,
- 16, 16, 3, 3 + bobj.crv.paramsDeleteIconYOffset, 25, 3 + bobj.crv.paramsDeleteIconYOffset); //width, height, dx, dy, disDx, disDy
-
- o.applyButton = newIconWidget(
- o.id + '_applyBtn',
- bobj.crv.paramPanelIcon,
- bind(o._onApplyClick, o), //clickCB,
- L_bobj_crv_ParamsApply, //text
- L_bobj_crv_ParamsApplyTip,//tooltip,
- 16, 16, 3, 3 + bobj.crv.paramsApplyIconYOffset, 25, 3 + bobj.crv.paramsApplyIconYOffset); //width, height, dx, dy, disDx, disDy
-
-
- o._palette.add(o.applyButton);
- o._palette.add(); // separator
- o._palette.add(o.delButton);
-
- return o;
- };
- bobj.crv.params.ParameterPanelToolbar.init = function() {
- this._paletteContainerInit();
- this._palette.init();
-
- this.delButton.setDisabled(true);
- this.applyButton.setDisabled(true);
- };
- /**
- * Overrides parent. Opens the toolbar's tags.
- */
- bobj.crv.params.ParameterPanelToolbar.beginHTML = function()
- {
- return bobj.html.openTag('div', {
- id: this.id,
- 'class':'dialogzone',
- style:{overflow:'hidden', margin:'0'}});
- };
- bobj.crv.params.ParameterPanelToolbar.getHTML = function() {
- return (this.beginHTML() +
- this._palette.getHTML() +
- this.endHTML() );
- };
- bobj.crv.params.ParameterPanelToolbar._onDelClick = function() {
- if (this.delClickCB) {
- bobj.crv.logger.info('UIAction ParameterPanel.Delete');
- this.delClickCB();
- }
- };
- bobj.crv.params.ParameterPanelToolbar._onApplyClick = function() {
- if (this.applyClickCB) {
- bobj.crv.logger.info('UIAction ParameterPanel.Apply');
- this.applyClickCB();
- }
- };
- /*
- ================================================================================
- ParameterTab
- Internal class. Stackable container for a prompt UI. Draws the prompt Title over
- the content.
- ================================================================================
- */
- bobj.crv.params.newParameterTab = function(kwArgs) {
- kwArgs = MochiKit.Base.update({
- label: null,
- isDataFetching: false,
- isDirty: false,
- isReadOnly: false,
- minMaxTooltip: null,
- openAdvCB: null,
- selectCB: null,
- id: null
- }, kwArgs);
-
- kwArgs.iconPos = "right";
- kwArgs.expandImgPos = "right";
-
- var o = bobj.crv.newStackedTab(kwArgs);
-
- // Update instance with constructor arguments
- bobj.fillIn(o, kwArgs);
- o._isDirtyInit = kwArgs.isDirty;
-
- // Update instance with member functions
- MochiKit.Base.update(o, bobj.crv.params.ParameterTab);
-
- o._dirtyId = o.id + '_dirty';
- o.addIcon(bobj.crv.paramPanelIcon, 0, bobj.crv.paramDirtyIconYOffset, L_bobj_crv_ParamsDirtyTip, false, o._isDirtyInit, o._dirtyId);
-
- if(kwArgs.minMaxTooltip || kwArgs.isReadOnly) {
- var tooltip = "";
- if(kwArgs.isReadOnly && kwArgs.minMaxTooltip) {
- tooltip = L_bobj_crv_ParamsReadOnly + "<BR>" + kwArgs.minMaxTooltip;
- }
- else if(kwArgs.minMaxTooltip) {
- tooltip = kwArgs.minMaxTooltip;
- }
- else if(kwArgs.isReadOnly) {
- tooltip = L_bobj_crv_ParamsReadOnly;
- }
-
- o.addIcon(bobj.crv.paramPanelIcon, 0, bobj.crv.paramInfoIconYOffset,tooltip, false, true, o.id + '_icnInfo');
- }
-
- if (o.isDataFetching) {
- o.addIcon(bobj.crv.paramPanelIcon, 0, bobj.crv.paramDataFetchingIconYOffset, L_bobj_crv_ParamsDataTip, true, true, null);
- }
-
- return o;
- };
- /**
- * Set whether dirty icon is displayed
- *
- * @param isDirty [bool] True shows the icon. False hides it.
- */
- bobj.crv.params.ParameterTab.setDirty = function(isDirty) {
- if (isDirty) {
- this.showIcon.call(this, this._dirtyId);
- }
- else {
- this.hideIcon.call(this, this._dirtyId);
- }
- };
- /**
- * @return [boolean] True if the dirty icon is showing
- */
- bobj.crv.params.ParameterTab.isDirty = function() {
- if (this.layer) {
- return this.isIconShowing(this._dirtyId);
- }
- else {
- return this._isDirtyInit;
- }
- };
- /**
- * @return [boolean] True if the tab is selected.
- */
- bobj.crv.params.ParameterTab.isSelected = function() {
- return MochiKit.DOM.hasElementClass(this._labelCtn, 'iactParamLabelSel');
- };
- /**
- * Select or deselect the tab
- *
- * @param isSelected [bool] True selects the tab. False deselects it.
- */
- bobj.crv.params.ParameterTab.setSelected = function(isSelected) {
- if (isSelected) {
- MochiKit.DOM.addElementClass(this._labelCtn, 'iactParamLabelSel');
- }
- else {
- MochiKit.DOM.removeElementClass(this._labelCtn, 'iactParamLabelSel');
- }
- };
- /*
- ================================================================================
- ParameterDialog
- Advanced Dialog for editing parameters using the prompt engine
- ================================================================================
- */
- bobj.crv.params.newParameterDialog = function(kwArgs) {
- kwArgs = MochiKit.Base.update({
- id: bobj.uniqueId(),
- prompt: null,
- promptHTML: '',
- showCB : null,
- hideCB : null
- }, kwArgs);
-
- var o = newDialogBoxWidget(
- kwArgs.id,
- L_bobj_crv_ParamsDlgTitle,
- kwArgs.width,
- kwArgs.height /*,defaultCB,cancelCB,noCloseButton*/);
- // Update instance with constructor arguments
- bobj.fillIn(o, kwArgs);
-
- // Update instance with member functions
- o._showDialogBox = o.show;
- o._initDialogBox = o.init;
- MochiKit.Base.update(o, bobj.crv.params.ParameterDialog);
-
- return o;
- };
- bobj.crv.params.ParameterDialog.init = function() {
- this._initDialogBox();
- this._form = document.getElementById(this.id + '_form');
- };
- bobj.crv.params.ParameterDialog._checkInitialization= function() {
- if(!this.layer) {
- targetApp(this.getHTML());
- this.init();
- }
- };
- bobj.crv.params.ParameterDialog.show = function(show) {
- if (show) {
- this._checkInitialization();
- this.setResize(MochiKit.Base.noop);
- this._showDialogBox(true);
- }
- else if (this.layer){
- this._showDialogBox(false);
- }
-
- if(show && this.showCB) {
- this.showCB();
- }
- else if(!show && this.hideCB) {
- this.hideCB();
- }
- };
- bobj.crv.params.ParameterDialog.isVisible = function() {
- return (this.initialized() && this.isDisplayed());
- };
- bobj.crv.params.ParameterDialog.setPromptHTML = function(html) {
-
- if (html) {
- this._checkInitialization();
-
- if(this.isDisplayed()) {
- this._showDialogBox(false);
- }
-
- this._deleteScripts();
-
- var ext = bobj.html.extractHtml(html);
- this.promptHTML = ext.html;
-
- if (this._form) {
- this._form.innerHTML = '<div style="overflow:auto">' + this.promptHTML + '</div>';
- }
-
- var links = ext.links;
- for(var iLinks = 0, linksLen = links.length; iLinks < linksLen; ++iLinks)
- {
- bobj.includeLink(links[iLinks]);
- }
-
- var winScroll_before = {x: getScrollX() , y : getScrollY()};
-
- var scripts = ext.scripts;
- for (var iScripts = 0, scriptsLen = scripts.length; iScripts < scriptsLen; ++iScripts) {
- var script = scripts[iScripts];
- if (!script) {continue;}
-
- if (script.text) {
- bobj.evalInWindow(script.text);
- }
- }
-
- var winScroll_after = {x: getScrollX() , y : getScrollY()};
-
- if(winScroll_before.x != winScroll_after.x || winScroll_before.y != winScroll_after.y) {
- _curWin.scrollTo(winScroll_before.x, winScroll_before.y);
- }
- }
- };
- /**
- * Private. Deletes global scope objects that were created for the dialog
- */
- bobj.crv.params.ParameterDialog._deleteScripts = function() {
- var form = this._form;
- if (form && form.ContextHandleID) {
- var prefix = form.ContextHandleID.value;
- for (var i in window) {
- if (i.indexOf(prefix) === 0) {
- delete window[i];
- }
- }
- }
- };
- bobj.crv.params.ParameterDialog.getHTML = function(html) {
- var FORM = bobj.html.FORM;
-
- var onsubmit = 'eventCancelBubble(event);return false;';
-
- return this.beginHTML() +
- FORM({id: this.id + '_form', onsubmit: onsubmit}, this.promptHTML) +
- this.endHTML();
- };
|