/** Licensed Materials - Property of IBM, 5724-E76 and 5724-E77, (C) Copyright IBM Corp. 2009, 2010, 2011 - All Rights reserved. **/
dojo.i18n._preloadLocalizations("portalclient.nls.ui_utils", ["ROOT","ar","ca","cs","da","de","el","en","es","fi","fr","he","hr","hu","it","ja","kk","ko","nl","no","pl","pt","pt-br","ro","ru","sk","sl","sv","th","tr","uk","xx","zh","zh-tw"]);
if(!dojo._hasResource["com.ibm.widgets.ConsoleWrapper"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.widgets.ConsoleWrapper"] = true;
//////////////////////////////////////////////////
// Licensed Materials - Property of IBM //
// 5724-E76, 5655-R17, 5655-M44 //
// Copyright IBM Corp. 2011 All Rights reserved.//
//////////////////////////////////////////////////
dojo.provide("com.ibm.widgets.ConsoleWrapper");
dojo.declare("com.ibm.widgets.ConsoleWrapper", [], {
// summary:
// This class serves as a wrapper of the non-standardized console object
// that can be used for logging and tracing purposes. If the console
// object is not available, the method calls to this wrapper do not have
// any effect but prevent the client from hitting JavaScript errors.
// If the console object is available but does not support all of the
// wrapped methods (e.g., log, debug, info, warn, error), the fallback
// of using the log method is used if supported. Otherwise the method
// calls do not write any message.
// _hasLogMethod: [private] Boolean
// Indicates whether the log() method is available on the console object
_hasLogMethod: false,
// _hasDebugMethod: [private] Boolean
// Indicates whether the debug() method is available on the console object
_hasDebugMethod: false,
// _hasInfoMethod: [private] Boolean
// Indicates whether the info() method is available on the console object
_hasInfoMethod: false,
// _hasWarnMethod: [private] Boolean
// Indicates whether the warn() method is available on the console object
_hasWarnMethod: false,
// _hasErrorMethod: [private] Boolean
// Indicates whether the error() method is available on the console object
_hasErrorMethod: false,
constructor: function() {
// summary:
// Constructs this console wrapper
if (typeof console == 'object') {
this._hasLogMethod = (typeof console.log == 'function');
this._hasDebugMethod = (typeof console.debug == 'function');
this._hasInfoMethod = (typeof console.info == 'function');
this._hasWarnMethod = (typeof console.warn == 'function');
this._hasErrorMethod = (typeof console.error == 'function');
} else {
this.log = function() {};
this.debug = function() {};
this.info = function() {};
this.warn = function() {};
this.error = function() {};
}
},
debug: function(/*Object...*/ args) {
// summary:
// Writes the given debug message to the console
// args:
// The message argument(s) to log
// tags:
// public
if (this._hasDebugMethod) {
console.debug.apply(console, arguments);
} else {
// fall back to common log method
this.log.apply(this, arguments);
}
},
error: function(/*Object...*/ args) {
// summary:
// Writes the given error message to the console
// args:
// The message argument(s) to log
// tags:
// public
if (this._hasErrorMethod) {
console.error.apply(console, arguments);
} else {
// fall back to common log method
this.log.apply(this, arguments);
}
},
info: function(/*Object...*/ args) {
// summary:
// Writes the given informational message to the console
// args:
// The message argument(s) to log
// tags:
// public
if (this._hasInfoMethod) {
console.info.apply(console, arguments);
} else {
// fall back to common log method
this.log.apply(this, arguments);
}
},
log: function(/*Object...*/ args) {
// summary:
// Writes the given log message to the console
// args:
// The message argument(s) to log
// tags:
// public
if (this._hasLogMethod) {
console.log.apply(console, arguments);
}
},
warning: function(/*Object...*/ args) {
// summary:
// Writes the given warning to the console
// args:
// The message argument(s) to log
// tags:
// public
if (this._hasWarnMethod) {
console.warn.apply(console, arguments);
} else {
// fall back to common log method
this.log.apply(this, arguments);
}
}
});
}
if(!dojo._hasResource["com.ibm.widgets._Traceable"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.widgets._Traceable"] = true;
dojo.provide("com.ibm.widgets._Traceable");
dojo.declare("com.ibm.widgets._Traceable", [], {
// LOGGER: [public] Object
// Reference to the Mashup enabler logger if it is available
LOGGER: null,
// LOG_LEVEL: [public] [deprecated] int
// Log level for trace messages written by this logger.
// Kept for code compatibility, use LOG_LEVEL_TRACE instead
LOG_LEVEL: null,
// LOG_LEVEL_ERROR: [public] [const] int
// Log level for error messages written by this logger
LOG_LEVEL_ERROR: 1000,
// LOG_LEVEL_INFO: [public] [const] int
// Log level for informational messages written by this logger
LOG_LEVEL_INFO: 800,
// LOG_LEVEL_TRACE: [public] [const] int
// Log level for trace messages written by this logger
LOG_LEVEL_TRACE: 500,
// LOG_LEVEL_WARNING: [public] [const] int
// Log level for warning messages written by this logger
LOG_LEVEL_WARNING: 900,
// _consoleWrapper: [private]
// Reference to the console wrapper for simple logging
_consoleWrapper: null,
// _isSimpleLogging: [private] Object
// RegExp object for checking the traceConfig string
_traceChecker: null,
// _isSimpleLogging: [private] Boolean
// true if the Mashup enabler logger is not available and the console is used instead
_isSimpleLogging: false, // true, if LOGGER not available
// _isLoggable: [private] Boolean
// true if simple logging is used and cc.isDebug + cc.traceConfig string are set for this class
_isLoggable: false,
constructor: function() {
// check, if Mashup enabler logger is available and if not,
// fall back to simple logging (using window.console() calls)
if (dojo.exists("com.ibm.mashups.enabler.logging.Logger")) {
this.LOGGER = com.ibm.mashups.enabler.logging.Logger.getLogger(this.declaredClass);
this._isSimpleLoggingisSimpleLogging = false;
// initialize the log levels of this logger using the Mashup enabler log levels
this.LOG_LEVEL_TRACE = com.ibm.mashups.enabler.logging.LogLevel.TRACE;
this.LOG_LEVEL_INFO = com.ibm.mashups.enabler.logging.LogLevel.INFO;
this.LOG_LEVEL_WARNING = com.ibm.mashups.enabler.logging.LogLevel.WARNING;
this.LOG_LEVEL_ERROR = com.ibm.mashups.enabler.logging.LogLevel.SEVERE;
}
else {
if (typeof ibmCfg != 'undefined' && typeof ibmCfg.enablerConfig != 'undefined' && typeof ibmCfg.enablerConfig.traceConfig != 'undefined') {
this._initConfig(ibmCfg.enablerConfig.traceConfig);
}
this._isSimpleLogging = true;
this._isLoggable = this.isLoggable();
// initialize the console wrapper for simple logging
this._consoleWrapper = new com.ibm.widgets.ConsoleWrapper();
}
// init LOG_LEVEL for backward compatibility reasons
this.LOG_LEVEL = this.LOG_LEVEL_TRACE;
},
// determines whether logging/tracing is enabled at all for the current
// widget. Can be used to omit traceEntry/traceExit/trace calls up front.
isTracing: function() {
// dispatch
return this.isLogging(this.LOG_LEVEL);
},
error: function(/*String*/ methodName, /*String*/ message, /*Array?*/ args) {
// summary:
// Logs an error message using the com.ibm.widgets._Traceable.LOG_LEVEL_ERROR log level
// methodName:
// The name of the method that contributes to the log
// message:
// The error message to log
// args:
// The arguments to incorporate into the log message by replacing corresponding placeholders
// tags:
// public
// dispatch to the common method
this.log(this.LOG_LEVEL_ERROR, methodName, message, args);
},
info: function(/*String*/ methodName, /*String*/ message, /*Array?*/ args) {
// summary:
// Logs an informational message using the com.ibm.widgets._Traceable.LOG_LEVEL_INFO log level
// methodName:
// The name of the method that contributes to the log
// message:
// The informational message to log
// args:
// The arguments to incorporate into the log message by replacing corresponding placeholders
// tags:
// public
// dispatch to the common method
this.log(this.LOG_LEVEL_INFO, methodName, message, args);
},
isLoggable: function() {
// summary:
// Returns true if the common component of IBM Portal is configured for debugging and if the trace specification
// enables tracing of the this class. Does not consider any particular log level specification.
// returns:
// a boolean value to indicate whether or not logging is enabled for this class
// tags:
// public
var result;
// check if debugging is enabled at all
if (typeof ibmCfg != 'undefined' && typeof ibmCfg.enablerConfig != 'undefined' && typeof ibmCfg.enablerConfig.isDebug != 'undefined') {
if (!ibmCfg.enablerConfig.isDebug) {
result = false; // Boolean
} else {
// check if the trace specification matches the class that wants to write logs or traces
var traceChecker = this._traceChecker;
result = traceChecker && traceChecker.test(this.declaredClass); // Boolean
}
} else {
// when the configuration is not available, tracing will be disabled
result = false; // Boolean
}
return result; // Boolean
},
isLogging: function(/*int*/ logLevel) {
// summary:
// Returns true if the common component of IBM Portal is configured for debugging and if the trace specification
// enables tracing of the this class for the specified level. Makes a distinction between the simple logger and
// the Mashup enabler logger, in that the log level is only considered for the latter one.
// logLevel:
// The log level to check for being enabled
// returns:
// a boolean value to indicate whether or not logging is enabeld for this class
// tags:
// public
// check which logger is used
if (this._isSimpleLogging) {
// level independent check for simple logger
return this._isLoggable;
} else {
// dispatch to the Mashup enabler logger
return this.LOGGER.isLoggable(logLevel);
}
},
log: function(/*int*/ logLevel, /*String*/ methodName, /*String*/ message, /*Array?*/ args) {
// summary:
// Logs a message with the specified log level
// logLevel:
// The log level of the message to log
// methodName:
// The name of the method that contributes to the log
// message:
// The informational message to log
// args:
// The arguments to incorporate into the log message by replacing corresponding placeholders
// tags:
// public
// check for the logging facility to use
if (this._isSimpleLogging) {
// dispatch for simple console logging
this._logSimple(logLevel, methodName, message, args);
} else {
// dispatch to the Mashup enabler logger
this.LOGGER.log(logLevel, methodName, msg, args);
}
},
// Write a message to the logger that will only be written, if the TRACE level is
// set. The message won't be logged, if TRACE is not enabled for this class.
trace: function(methodName, message, args) {
// check loggable info first, we want to build the args string
// for both loggers (simple & enabler logger) only once
var canLog = this.isTracing();
if (canLog) {
// build args string and log trace message
var msg = message;
var argStr = "";
// we do want to log '0' and 'null' values explicitly, while
// we don't want to log non-existent args values like 'undefined'
if (args || (args === 0) || (args === null) || (args === "")) {
if (!dojo.isArray(args)) {
argStr = args;
}
else {
if (args && args.length > 0) {
for (var arg in args) {
if (argStr === "") {
argStr = argStr + args[arg];
}
else {
argStr = argStr + ", " + args[arg];
}
}
}
}
msg = msg + " [ " + argStr + " ]";
}
if (this._isSimpleLogging) {
this._consoleWrapper.debug(this.declaredClass + " " + methodName + " : " + msg);
}
else {
this.LOGGER.log(this.LOG_LEVEL, methodName, msg);
}
}
},
// write Entry message for given methodName to the traceLog (console)
traceEntry: function(methodName, args) {
if (this._isSimpleLogging) {
if (this._isLoggable) {
// build args string and log trace message
var msg = " ENTRY";
var argStr = "";
// we do want to log '0' and 'null' values explicitly, while
// we don't want to log non-existent args values like 'undefined'
if (args || (args === 0) || (args === null) || (args === "")) {
if (!dojo.isArray(args)) {
argStr = args;
}
else {
if (args && args.length > 0) {
for (var arg in args) {
if (argStr === "") {
argStr = argStr + args[arg];
}
else {
argStr = argStr + ", " + args[arg];
}
}
}
}
msg = msg + " [ " + argStr + " ]";
}
this._consoleWrapper.debug(this.declaredClass + " " + methodName + msg);
}
}
else {
var bIsLoggable = this.LOGGER.isLoggable(this.LOG_LEVEL_TRACE);
if (bIsLoggable) {
this.LOGGER.entering(methodName, args);
}
}
},
// write Exit message for given methodName to the traceLog (console)
traceExit: function(methodName, retVal) {
if (this._isSimpleLogging) {
if (this._isLoggable) {
if (retVal || (retVal === 0) || (retVal === null) || (retVal === "")) {
this._consoleWrapper.debug(this.declaredClass + " " + methodName + " EXIT [ " + retVal + " ]");
}
else {
this._consoleWrapper.debug(this.declaredClass + " " + methodName + " EXIT");
}
}
}
else {
var bIsLoggable = this.LOGGER.isLoggable(this.LOG_LEVEL_TRACE);
if (bIsLoggable) {
if (typeof retVal === "boolean") {
retVal = retVal ? "true" : "false";
}
this.LOGGER.exiting(methodName, retVal);
}
}
},
warning: function(/*String*/ methodName, /*String*/ message, /*Array?*/ args) {
// summary:
// Logs a warning message using the com.ibm.widgets._Traceable.LOG_LEVEL_WARNING log level
// methodName:
// The name of the method that contributes to the log
// message:
// The warning message to log
// args:
// The arguments to incorporate into the log message by replacing corresponding placeholders
// tags:
// public
// dispatch to the common method
this.log(this.LOG_LEVEL_WARNING, methodName, message, args);
},
_initConfig: function(config) {
if (config && config.length > 0) {
this._traceChecker = new RegExp(dojo.isArray(config) ? config.join("|") : config);
}
else {
this._traceChecker = null;
}
},
_logSimple: function(/*int*/ logLevel, /*String*/ methodName, /*String*/ message, /*Array?*/ args) {
// summary:
// Logs the given message with the specified log level using the console
// logLevel:
// The log level of the message to log
// methodName:
// The name of the method that contributes to the log
// message:
// The message text to log
// args:
// The arguments to incorporate into the log message by replacing corresponding placeholders
// tags:
// private
// check if logging is enabled for the simple logger case
if (this._isLoggable) {
// incorporate the arguments into the message
if ((args && !dojo.isArray(args)) || args === false) {
args = [args];
}
var formattedMessage = args ? dojo.string.substitute(message, args) : message;
// write to the console using the specified level
if (logLevel == this.LOG_LEVEL_ERROR) {
this._consoleWrapper.error(this.declaredClass + " " + methodName + " : " + formattedMessage);
}
else if (logLevel == this.LOG_LEVEL_WARNING) {
this._consoleWrapper.warning(this.declaredClass + " " + methodName + " : " + formattedMessage);
}
else if (logLevel == this.LOG_LEVEL_INFO) {
this._consoleWrapper.info(this.declaredClass + " " + methodName + " : " + formattedMessage);
}
else if (logLevel == this.LOG_LEVEL_TRACE) {
this._consoleWrapper.debug(this.declaredClass + " " + methodName + " : " + formattedMessage);
}
else {
this._consoleWrapper.log(this.declaredClass + " " + methodName + " : " + formattedMessage);
}
}
}
});
}
if(!dojo._hasResource["com.ibm.widgets.GenericDialog"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.widgets.GenericDialog"] = true;
/** ****************************************************************** */
/* Licensed Materials - Property of IBM */
/* */
/* 5724Z67 */
/* */
/* Copyright IBM Corp. 2011 All Rights Reserved. */
/* */
/* US Government Users Restricted Rights - Use, duplication or */
/* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */
/** ****************************************************************** */
dojo.provide("com.ibm.widgets.GenericDialog");
dojo.registerModulePath("com.ibm.widgets","../com/ibm/widgets");
dojo.require("dijit.Dialog");
dojo.require("dijit._Templated");
dojo.require("dojo.i18n");
dojo.require("dojox.layout.ResizeHandle");
dojo.declare("com.ibm.widgets.GenericDialog",
[dijit.Dialog, dijit._Templated, com.ibm.widgets._Traceable], {
// summary:
// This dialog implementation serves as generic container for arbitrary widgets that are
// registered with this dialog upon instantiation.
// autoClose: [public] Boolean
// Indicates if this dialog is closed after executing any of the registered callback functions.
// If set to false, the caller of the dialog is responsible for closing it
autoClose: true,
// templateString:
// see dijit.Dialog
autofocus: true,
// blankImgUrl: Object
// URL pointing to a blank image (1x1 transparent pixel)
blankImgUrl: dojo.moduleUrl("dojo", "resources/blank.gif").toString(),
// templateString:
// see dijit.Dialog
duration: 200,
// templateString:
// see dijit.Dialog
extractContent: false,
// isResizable: [protected] Boolean
// Indicates whether or not this dialog offers the user a control to resize the dialog
isResizable: true,
// isResized: [protected] Boolean
// Indicates whether or not this dialog has been resized manually by the user since it was launched
isResized: false,
// minHeight: [protected] Integer
// Minimum height of the dialog in pixels. Neither the resize handle, nor the layout() code allows
// to reduce the height of the dialog to a lower value.
minHeight: 400,
// minWidth: [protected] Integer
// Minimum width of the dialog in pixels. Neither the resize handle, nor the layout() code allows
// to reduce the width of the dialog to a lower value.
minWidth: 400,
// namespace: [protected] String
// The namespace this dialog uses for building its user interface elements
namespace: "genDlg",
// templateString:
// see dijit.Dialog
title: "", // will be reset later by getting widget input
// templateString:
// see dijit.Dialog
parseOnLoad: true,
// templateString:
// see dijit.Dialog
preload: true,
// templateString:
// see dijit.Dialog
templateString: null,
// templateString:
// see dijit.Dialog
templateString:"
\n",
// _eventHandles: [private] Array
// Array of handles created when connecting events to methods
_eventHandles: [],
// _resizeEventHandle: [private] Object
// We need to handle the resizeEvent in a special way, as this event handler might get
// recreated, when recreateResizeHandler is invoked more than once
_resizeEventHandle: null,
// _isTracing: [private] Boolean
// Indicates whether or not this class writes trace messages to the console
_isTracing: false,
// _lotusui_div: DomNode
// Reference to the lotusUI wrapper DIV. We try to remove it on dialog destruction.
_lotusui_div: null,
// _nlsMessages: [private] Object
// Object holding localized strings used for providing localized messages
_nlsMessages: {},
// _nlsUserInterface: [private] Object
// Object holding localized strings used for providing localized user interface elements
_nlsUserInterface: {},
// _onCancelCallbackFn: [private] Function
// Callback function to execute when the user cancels or closes this dialog
_onCancelCallbackFn: null,
// _onConfirmCallbackFn: [private] Function
// Callback function to execute when the user confirms this dialog
_onConfirmCallbackFn: null,
// _resizeHandler: [private] Object
// Resize handler of this dialog
_resizeHandler: null,
// _widget: [private] Object
// Instance of the widget this generic dialog consumes, that is, the widget that is displayed by this dialog
_widget: null,
buildRendering: function() {
// summary:
// Constructs the user interface of this widget
// tags:
// protected
// entry trace
var m = "buildRendering()";
if (this._isTracing) {
this.traceEntry(m);
}
// default
this.inherited(arguments);
if (this._widget) {
this._widget.placeAt(this.widgetNode);
// retrieve title from widget instance and change it here
this.title = this._widget.getDialogTitle();
}
// exit trace
if (this._isTracing) {
this.traceExit(m);
}
},
constructor: function(/*Object*/ p_params) {
// summary:
// Constructs this dialog
// p_params.onCancelCallbackFn: Function
// Callback function to execute when the user cancels or closes this dialog
// p_params.onConfirmCallbackFn: Function
// Callback function to execute when the user confirms this dialog
// p_params.widgetInstance: Object
// Instance of the widget this generic dialog consumes, that is, the widget that is displayed by this dialog
// tags:
// public
// set instance trace support flag
this._isTracing = this.isTracing();
// entry trace
var m = "constructor(p_params)";
if (this._isTracing) {
// do not use dojo.toJson on p_params to avoid errors
this.traceEntry(m, p_params);
if (p_params) {
this.trace(m, "p_params.onCancelCallbackFn:", p_params.onCancelCallbackFn);
this.trace(m, "p_params.onConfirmCallbackFn:", p_params.onConfirmCallbackFn);
this.trace(m, "p_params.widgetInstance:", p_params.widgetInstance);
}
}
if (typeof p_params.onConfirmCallbackFn == 'function') {
this._onConfirmCallbackFn = p_params.onConfirmCallbackFn;
}
if (typeof p_params.onCancelCallbackFn == 'function') {
this._onCancelCallbackFn = p_params.onCancelCallbackFn;
}
if (p_params.widgetInstance && typeof p_params.widgetInstance == 'object') {
this._widget = p_params.widgetInstance;
}
// initialize the resource bundles for localization
this._initNLS();
// exit trace
if (this._isTracing) {
this.traceExit(m);
}
},
destroyDialog: function() {
// summary:
// Destroys this dialog
// tags:
// public
// entry trace
var m = "destroyDialog()";
if (this._isTracing) {
this.traceEntry(m);
}
this.destroyRecursive();
// also destroy global resize helper - workaround for dojo bug
var resizeHelper = dijit.byId("dojoxGlobalResizeHelper");
if (resizeHelper) {
resizeHelper.destroy();
} else if (this._resizeHandler && this._resizeHandler._resizeHelper) {
this._resizeHandler._resizeHelper.destroy();
}
// destroy the resize handler
if (this._resizeHandler) {
this._resizeHandler.destroy();
this._resizeHandler = null;
}
this._removeLotusOneUIDiv();
// exit trace
if (this._isTracing) {
this.traceExit(m);
}
},
getNlsMessages: function() {
// summary:
// Returns the NLS bundle for messages related to this dialog
// tags:
// protected
// returns:
// the Object holding localized strings used for providing localized messages
// entry trace
var m = "getNlsMessages()";
if (this._isTracing) {
this.traceEntry(m);
}
var result = this._nlsMessages;
// exit trace
if (this._isTracing) {
this.traceExit(m, dojo.toJson(result));
}
return result; // Object
},
getNlsUserInterface: function() {
// summary:
// Returns the NLS bundle for user interface elements related to this dialog
// tags:
// protected
// returns:
// the Object holding localized strings used for providing localized user interface elements
// entry trace
var m = "getNlsUserInterface()";
if (this._isTracing) {
this.traceEntry(m);
}
var result = this._nlsUserInterface;
// exit trace
if (this._isTracing) {
this.traceExit(m, dojo.toJson(result));
}
return result; // Object
},
postCreate: function() {
// summary:
// Binds resources required by this dialog after its DOM has been set up
// tags:
// protected
// entry trace
var m = "postCreate()";
if (this._isTracing) {
this.traceEntry(m);
}
// default
this.inherited(arguments);
this._initEventHandles();
this._recreateResizeHandler();
// exit trace
if (this._isTracing) {
this.traceExit(m);
}
},
postMixInProperties: function() {
// summary:
// Prepares the creation of the user interface of this dialog
// tags:
// protected
// entry trace
var m = "postMixInProperties()";
if (this._isTracing) {
this.traceEntry(m);
}
// default
this.inherited(arguments);
// add the styles of the dialog resize handle
this._addResizeHandleStyles();
// exit trace
if (this._isTracing) {
this.traceExit(m);
}
},
show: function() {
// summary:
// Overridden show() method of [dijit.Dialog], allowing us to trigger the startup
// method
// tags:
// protected
// entry trace
var m = "show()";
if (this._isTracing) {
this.traceEntry(m);
}
this.startup();
// default
this.inherited(arguments);
// exit trace
if (this._isTracing) {
this.traceExit(m);
}
},
uninitialize: function() {
// summary:
// Releases the resources bound by this dialog before it is destroyed
// tags:
// protected
// entry trace
var m = "uninitialize()";
if (this._isTracing) {
this.traceEntry(m);
}
// disconnect the callbacks from their related events
this._clearEventHandles();
// default
this.inherited(arguments);
// exit trace
if (this._isTracing) {
this.traceExit(m);
}
},
_addResizeHandleStyles : function() {
// summary:
// Dynamically adds a tag to the current HTML page pointing to the
// styles of the dialog resize handle.
// tags:
// private
// entry trace
var m = "_addStyles()";
if (this._isTracing) {
this.traceEntry(m);
}
// first, figure out, whether the CSS is already loaded
if (!dojo.byId(com.ibm.widgets.GenericDialog.resizeHandleCssId)) {
// trace
if (this._isTracing) {
this.trace(m, "Resize handle styles have not been loaded yet, adding element to DOM");
}
var node = document.getElementsByTagName('head');
var prepend = false;
if (node) {
node = node[0];
} else {
node = document;
prepend = true;
}
var styleNode = document.createElement('link');
dojo.attr(styleNode, "type", "text/css");
dojo.attr(styleNode, "rel", "stylesheet");
dojo.attr(styleNode, "href", dojo.moduleUrl("dojox.layout", "resources/ResizeHandle.css").toString());
dojo.attr(styleNode, "id", com.ibm.widgets.GenericDialog.resizeHandleCssId);
if (prepend) {
var before = (node.childNodes && node.childNodes[0]) ? node.childNodes[0] : null;
node.insertBefore(styleNode, before);
} else {
node.appendChild(styleNode);
}
}
// trace
else if (this._isTracing) {
this.trace(m, "Resize handle styles have already been loaded, not adding link element to DOM again");
}
// exit trace
if (this._isTracing) {
this.traceExit(m);
}
},
_clearEventHandles: function() {
// summary:
// Disconnects the events supported by this dialog from the corresponding callback methods
// tags:
// private
// entry trace
var m = "_clearEventHandles()";
if (this._isTracing) {
this.traceEntry(m);
}
dojo.forEach(this._eventHandles, dojo.disconnect);
dojo.disconnect(this._resizeEventHandle);
this._eventHandles = [];
// exit trace
if (this._isTracing) {
this.traceExit(m);
}
},
// @OVERRIDE dijit._DialogMixin._getFocusItems()
// Need to fix the buggy method, which does not take passed in domNode into account
// although dijit.Dialog relies on this method to take a domNode as an argument
_getFocusItems: function(/*Node*/ p_domNode){
// summary:
// see dijit._DialogMixin
// tags:
// protected
// Fixed _getFocusItems() method.
// Would also work with a fixed dojo version, so we're forward compatible here.
// store current containerNode reference and replace it with the passed in domNode,
// as current implementation uses 'this.containerNode' as the reference domNode
var oldContainerNode = this.containerNode;
this.containerNode = p_domNode;
// call original method
this.inherited(arguments);
// restore containerNode reference
this.containerNode = oldContainerNode;
},
_initEventHandles: function() {
// summary:
// Connects the events supported by this dialog to the corresponding callback methods
// and stores the handles in the _eventHandles array
// tags:
// private
// entry trace
var m = "_initEventHandles()";
if (this._isTracing) {
this.traceEntry(m);
}
this._eventHandles.push(dojo.connect(this.dialogClose, "onclick", this, "onCancel"));
this._eventHandles.push(dojo.connect(this.dialogCancel, "onclick", this, "onCancel"));
// the onCancel() method of dijit.Dialog is triggered when pressing the ESC key. We need
// to connect our _onCancel method which destroys the dialog to that event as well.
// Otherwise closing the dialog using the ESC key would only hide the dialog instead of
// destroying it
this._eventHandles.push(dojo.connect(this, "onCancel", this, "_onCancel"));
// exit trace
if (this._isTracing) {
this.traceExit(m);
}
},
_initNLS: function() {
// summary:
// Initializes the aspects for supporting localization, for example, by loading the required NLS bundle(s).
// May be overridden by extensions of this generic dialog. This dialog ensures to call the implementation
// of the extension up instantiation
// tags:
// protected
// entry trace
var m = "_initNLS()";
if (this._isTracing) {
this.traceEntry(m);
}
this._nlsUserInterface = dojo.i18n.getLocalization("com.ibm.widgets", 'GenericDialog');
// exit trace
if (this._isTracing) {
this.trace(m, "Initialized NLS object for user interface elements:", dojo.toJson(this._nlsUserInterface));
this.trace(m, "Initialized NLS object for messages:", dojo.toJson(this._nlsMessages));
this.traceExit(m);
}
},
_onCancel: function() {
// summary:
// Called when the user cancels this dialog. Informs the widget this dialog consumes about the
// cancellation event to retrieve the widget result data that is then passed to the client callback
// function registered with this dialog. Eventually, this dialog is destroyed if auto closing
// is enabled
// tags:
// private callback
// entry trace
var m = "_onCancel()";
if (this._isTracing) {
this.traceEntry(m);
}
var returnValues = {};
if (this._widget && (typeof this._widget.doCancel == 'function'))
{
returnValues = this._widget.doCancel();
}
if (this._onCancelCallbackFn) {
// trace
if (this._isTracing) {
this.trace(m, "Dispatching to callback function passing the return values from the widget:",
[ this._onCancelCallbackFn, returnValues ]);
}
// pass on return values from the widget to the caller of this dialog
this._onCancelCallbackFn(returnValues);
}
if (this.autoClose) {
setTimeout(dojo.hitch(this, "destroyDialog"), this.duration);
}
// exit trace
if (this._isTracing) {
this.traceExit(m);
}
},
_onConfirm: function() {
// summary:
// Called when the user confirms this dialog. Informs the widget this dialog consumes about the
// confirmation event to retrieve the widget result data that is then passed to the client callback
// function registered with this dialog. Eventually, this dialog is destroyed if auto closing
// is enabled
// tags:
// private callback
// entry trace
var m = "_onConfirm()";
if (this._isTracing) {
this.traceEntry(m);
}
var returnValues = {};
if (this._widget && (typeof this._widget.doConfirm == 'function'))
{
returnValues = this._widget.doConfirm();
}
// trace
if (this._isTracing) {
this.trace(m, "Return values from widget:", returnValues);
}
if (this._onConfirmCallbackFn) {
// trace
if (this._isTracing) {
this.trace(m, "Dispatching to callback function passing the return values from the widget:",
[ this._onConfirmCallbackFn, returnValues ]);
}
// pass on return values from the widget to the caller of this dialog
this._onConfirmCallbackFn(returnValues);
}
if (this.autoClose) {
this.hide();
setTimeout(dojo.hitch(this, "destroyDialog"), this.duration);
}
// exit trace
if (this._isTracing) {
this.traceExit(m);
}
},
_onResize: function() {
this.isResized = true;
this.layout();
},
_recreateResizeHandler: function() {
// summary:
// Used to create and recreate the resizeHandler for this dialog. This method can be called
// multiple times, as it destroys any existing resizeHandler before it (re)creates it.
// This method is useful, if another dialog destroyed the resizeHelper DomNode, which would
// cause the resizeHandler to no longer work ok. Creating a new resizeHandler will implicitly
// recreate the resizeHelper domNode.
// tags:
// private
// entry trace
var m = "_recreateResizeHandler()";
if (this._isTracing) {
this.traceEntry(m);
}
if(this.isResizable) {
if (this._resizeHandler) {
this._resizeHandler.destroy();
}
this._resizeHandler = new dojox.layout.ResizeHandle({
"targetId": this.id,
"intermediateChanges": false,
"activeResize": false,
"animateSizing": true,
"minHeight": this.minHeight,
"minWidth": this.minWidth
}).placeAt(this.id);
// listen to onResize events
this._resizeEventHandle = dojo.connect(this._resizeHandler, "onResize", this, "_onResize");
}
},
_removeLotusOneUIDiv: function() {
// summary:
// Checks whether the lotus Oneui wrapper DIV is empty and can be removed.
// If this condition is true, the DIV will be removed.
// tags:
// protected
if (this._lotusui_div) {
var nodes = dojo.query('*', this._lotusui_div);
if (nodes.length === 0) {
dojo.destroy(this._lotusui_div);
this._lotusui_div = null;
}
}
}
});
// com.ibm.workplace.wcm.ecm.picker.dialog.GenericDialog.resizeHandleCssId: [const] String
// Unique element ID, to identify whether the Federated Documents Picker CSS was already loaded into a page
com.ibm.widgets.GenericDialog.resizeHandleCssId = "com_ibm_widgets_GenericDialog_resizeHandleCssId";
}
if(!dojo._hasResource["com.ibm.widgets.GenericDialogWidget"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.widgets.GenericDialogWidget"] = true;
/** ****************************************************************** */
/* Licensed Materials - Property of IBM */
/* */
/* 5724Z67 */
/* */
/* Copyright IBM Corp. 2011 All Rights Reserved. */
/* */
/* US Government Users Restricted Rights - Use, duplication or */
/* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */
/** ****************************************************************** */
dojo.provide("com.ibm.widgets.GenericDialogWidget");
dojo.registerModulePath("com.ibm.widgets","../com/ibm/widgets");
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
dojo.declare("com.ibm.widgets.GenericDialogWidget",
[dijit._Widget, dijit._Templated, com.ibm.widgets._Traceable], {
// summary:
// This widget serves as base dojo class for widgets that are consumed by
// the [com.ibm.widgets.GenericDialog] dialog
// namespace: [protected] String
// The namespace this widget uses for building its user interface elements
namespace: "someNamespace",
// templateString:
// see dijit.Dialog
templateString: null,
// _isTracing: [private] Boolean
// Indicates whether or not this class writes trace messages to the console
_isTracing: false,
// _nlsMessages: [private] Object
// Object holding localized strings used for providing localized messages
_nlsMessages: {},
// _nlsUserInterface: [private] Object
// Object holding localized strings used for providing localized user interface elements
_nlsUserInterface: {},
constructor: function(/*Object*/ p_params) {
// summary:
// Constructs this widget
// p_params: Object
// The arguments for initializing this widget
// tags:
// public
// set instance trace support flag
this._isTracing = this.isTracing();
// entry trace
var m = "constructor(p_params)";
if (this._isTracing) {
this.traceEntry(m, p_params);
if (p_params) {
this.trace(m, "p_params.nlsMessages:", dojo.toJson(p_params.nlsMessages));
this.trace(m, "p_params.nlsUserInterface:", dojo.toJson(p_params.nlsUserInterface));
}
}
// initialize this dialog widget's instance variables
if (p_params) {
if (p_params.nlsMessages && dojo.isObject(p_params.nlsMessages)) {
this._nlsMessages = p_params.nlsMessages;
}
if (p_params.nlsUserInterface && dojo.isObject(p_params.nlsUserInterface)) {
this._nlsUserInterface = p_params.nlsUserInterface;
}
}
// exit trace
if (this._isTracing) {
this.traceExit(m);
}
},
doCancel: function() {
// summary:
// Called by the [com.ibm.widgets.GenericDialog] instance consuming
// this widget to inform this widget about the user having canceled the parent dialog.
// This widget decides whether it needs to return a JSON object, although the parent dialog
// was canceled
// returns:
// the data this widget contributes to the parent dialog result upon cancellation
// tags:
// public
// entry trace
var m = "doCancel()";
if (this._isTracing) {
this.traceEntry(m);
}
var result = { "returnCode": -1 };
// exit trace
if (this._isTracing) {
this.traceExit(m, result);
}
return result; // Object
},
doConfirm: function() {
// summary:
// Called by the [com.ibm.widgets.GenericDialog] instance consuming
// this widget to inform this widget about the user having confirmed the parent dialog.
// This widget needs to collect its result data and store it in a JSON object, which it needs
// to return with this function
// returns:
// The data this widget contributes to the parent dialog result upon confirmation
// tags:
// public
// entry trace
var m = "doConfirm()";
if (this._isTracing) {
this.traceEntry(m);
}
var result = { "returnCode": 0 };
// exit trace
if (this._isTracing) {
this.traceExit(m, result);
}
return result; // Object
},
getDialogTitle: function() {
// summary:
// Returns the title to show in the dialog that consumes this widget (see also
// [com.ibm.widgets.GenericDialog]).
// The dialog implementation is responsible of calling and honoring the title
// defined by this widget.
// tags:
// public
// entry trace
var m = "getDialogTitle()";
if (this._isTracing) {
this.traceEntry(m);
}
var result = "Generic Dialog Widget's Title";
// exit trace
if (this._isTracing) {
this.traceExit(m, result);
}
return result;
},
getNlsMessages: function() {
// summary:
// Returns the NLS bundle for messages related to this dialog widget
// tags:
// protected
// returns:
// the Object holding localized strings used for providing localized messages
// entry trace
var m = "getNlsMessages()";
if (this._isTracing) {
this.traceEntry(m);
}
var result = this._nlsMessages;
// exit trace
if (this._isTracing) {
this.traceExit(m, dojo.toJson(result));
}
return result; // Object
},
getNlsUserInterface: function() {
// summary:
// Returns the NLS bundle for user interface elements related to this dialog widget
// tags:
// protected
// returns:
// the Object holding localized strings used for providing localized user interface elements
// entry trace
var m = "getNlsUserInterface()";
if (this._isTracing) {
this.traceEntry(m);
}
var result = this._nlsUserInterface;
// exit trace
if (this._isTracing) {
this.traceExit(m, dojo.toJson(result));
}
return result; // Object
},
postCreate: function() {
// summary:
// Binds resources required by this dialog after its DOM has been set up
// tags:
// protected
// entry trace
var m = "postCreate()";
if (this._isTracing) {
this.traceEntry(m);
}
// default
this.inherited(arguments);
// exit trace
if (this._isTracing) {
this.traceExit(m);
}
},
postMixInProperties: function() {
// summary:
// Prepares the creation of the user interface of this widget
// tags:
// protected
// entry trace
var m = "postMixInProperties()";
if (this._isTracing) {
this.traceEntry(m);
}
// default
this.inherited(arguments);
// exit trace
if (this._isTracing) {
this.traceExit(m);
}
},
uninitialize: function() {
// summary:
// Releases the resources bound by this widget before it is destroyed
// tags:
// protected
// entry trace
var m = "uninitialize()";
if (this._isTracing) {
this.traceEntry(m);
}
// default
this.inherited(arguments);
// exit trace
if (this._isTracing) {
this.traceExit(m);
}
}
});
}
if(!dojo._hasResource["com.ibm.cp.DojoLocalized"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.cp.DojoLocalized"] = true;
dojo.provide("com.ibm.cp.DojoLocalized");
dojo.require("dojo.i18n");
/**
* Implements the Enabler com.ibm.mashups.enabler.Localized API using dojo i18n under
* the covers.
*/
dojo.declare("com.ibm.cp.DojoLocalized", [com.ibm.mashups.enabler.Localized], {
/**
* Defines the package where the resource bundle for this item exists
* @type String
*/
bundlePackage: "",
/**
* Defines the name of resource bundle for this item
* @type String
*/
bundleName: "",
/**
* Defines the key to use to look up the title and description in the resource bundle.
* The title is mapped to the "bundleKey.title" property and the description is mapped to the
* "bundleKey.description" property in the resource bundle.
* @type String
*/
bundleKey: "",
constructor: function(jsonObj) {
this.LOGGER = com.ibm.mashups.enabler.logging.Logger.getLogger(this.declaredClass);
this.bundlePackage = jsonObj.bundlePackage;
this.bundleName = jsonObj.bundleName;
this.bundleKey = jsonObj.bundleKey;
this._locales = [dojo.locale];
var extra = dojo.config && dojo.config.extraLocale;
if(extra) {this._locales.push.apply(this._locales, extra);}
// avoid build process picking this up... then failing; jslint complains, but its required
dojo["require" + "Localization"](this.bundlePackage, this.bundleName);
},
_getBundle: function(locale) {
var mname = "_getBundle", ret = {};
try {
ret = dojo.i18n.getLocalization(this.bundlePackage, this.bundleName, locale);
this.LOGGER.trace(mname, "Found bundle for locale ${0}", [locale]);
} catch(err) {
// no-op, just return {}
// must catch this per the API spec, instead of propagating to the caller
this.LOGGER.warning("_getBundle", "Bundle not found for locale ${0}", [locale]);
}
return ret;
},
getLocales: function() {
var mname = "getLocales";
this.LOGGER.entering(mname, []);
if(!this._locales.filtered) {
this.LOGGER.trace(mname, "Filtering locales", []);
// filter the locales list to only those locales where a title OR description exist
// for this localized instance in the bundle
this._locales = dojo.filter(this._locales, function(locale){
var bundle = this._getBundle(locale);
var ret = bundle[this.bundleKey] ||
bundle[this.bundleKey + "_title"] ||
bundle[this.bundleKey + "_description"];
this.LOGGER.trace(mname, "Does title or description exist for locale ${0}? ${1}", [locale, ret]);
return ret;
}, this);
this._locales.filtered = true;
}
this.LOGGER.exiting(mname, [this._locales]);
return this._locales;
},
getTitle: function(locale) {
var mname = "getTitle";
this.LOGGER.entering(mname, [locale]);
var bundle = this._getBundle(locale);
var ret = bundle[this.bundleKey + "_title"] || bundle[this.bundleKey];
this.LOGGER.exiting(mname, [locale]);
return ret;
},
getDescription: function(locale) {
var mname = "getDescription";
this.LOGGER.entering(mname, [locale]);
var ret = this._getBundle(locale)[this.bundleKey + "_description"];
this.LOGGER.exiting(mname, [locale]);
return ret;
}
});
}