/** Licensed Materials - Property of IBM, 5724-E76 and 5724-E77, (C) Copyright IBM Corp. 2009, 2010, 2011 - All Rights reserved. **/
dojo.provide("com.ibm.mm.builder");
if(!dojo._hasResource["com.ibm.mashups.enabler.space.Factory"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mashups.enabler.space.Factory"] = true;
// A space model stub for Portal, which does not use spaces
dojo.provide("com.ibm.mashups.enabler.space.Factory");
com.ibm.mashups.enabler.space.Factory = {
getSpaceExtensionModel: function() {
return null;
},
getSpaceModel: function() {
return {
create: function() {
return null;
},
commit: function() {
return {
start: function() {
return null;
},
setFinishedCallback: function() {}
}
},
confirmExport: function() {
return false;
},
confirmCopy: function() {
return false;
},
getSubmittableImportForm: function() {
return null;
},
confirmCreate: function() {
return false;
},
insert: function() {},
confirmInsert: function() {
return false;
},
remove: function() {},
confirmRemove: function() {
return false;
},
iterator: function() {
return null;
},
setStrategy: function() {},
getStrategies: function() {
return null;
},
getStrategy: function() {
return null;
},
addStrategy: function() {},
removeStrategy: function() {},
find: function() {
return {
start: function() {
return null;
},
setFinishedCallback: function() {}
}
},
invalidate: function() {},
getSubmittableForm: function() {
return null;
},
findSpaceByNavigation: function() {
return {
start: function() {
return null;
},
setFinishedCallback: function() {}
}
},
findFavorites: function() {
return {
start: function() {
return null;
},
setFinishedCallback: function() {}
}
}
};
}
}
}
if(!dojo._hasResource["com.ibm.mm.builder.builderpre"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.builderpre"] = true;
dojo.i18n._preloadLocalizations("com.ibm.mm.builder.nls.mmbuilder_portal", ["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"]);
dojo.provide("com.ibm.mm.builder.builderpre");
builderConfig = {};
(function(){
var cs = com.ibm.mashups.services.ServiceManager.getService(com.ibm.mashups.enabler.services.ConfigService.SERVICE_NAME);
builderConfig.productName = cs.getValue(com.ibm.mashups.enabler.services.ConfigConstants.PRODUCT_NAME);
builderConfig.enablerPath = cs.getValue(com.ibm.mashups.enabler.services.ConfigConstants.CONTEXT_ROOT_ENABLER);
builderConfig.builderPath = cs.getValue(com.ibm.mashups.enabler.services.ConfigConstants.CONTEXT_ROOT_BUILDER);
builderConfig.locale = cs.getValue("locale");
builderConfig.isBidi = cs.getValue(com.ibm.mashups.enabler.services.ConfigConstants.CLIENT_IS_BIDI);
builderConfig.hasHub = false;
var hubUrl = cs.getValue(com.ibm.mashups.enabler.services.ConfigConstants.HUB_URL);
if (hubUrl && (dojo.trim(hubUrl) != "")) {
builderConfig.hasHub = true;
}
builderConfig.pageAutoWiringDefault = cs.getValue(com.ibm.mashups.enabler.services.ConfigConstants.AUTO_WIRING_DEFAULT_ENABLED);
builderConfig.sandboxDisabled = cs.getValue(com.ibm.mashups.enabler.services.ConfigConstants.WIDGETDEFID_SANDBOX_DISABLED);
builderConfig.createSpaceOnTemplateMode = cs.getValue(com.ibm.mashups.enabler.services.ConfigConstants.CREATE_SPACE_TEMPLATE_MODE);
builderConfig.favoriteSpacesMaximumNumber = cs.getValue(com.ibm.mashups.enabler.services.ConfigConstants.FAVORITE_SPACES_MAXIMUM_NUMBER);
builderConfig.recentSpacesMaximumNumber = cs.getValue(com.ibm.mashups.enabler.services.ConfigConstants.RECENT_SPACES_MAXIMUM_NUMBER);
builderConfig.spaceTemplateQueryCount = cs.getValue(com.ibm.mashups.enabler.services.ConfigConstants.SPACEMANAGER_SPACE_QUERYCOUNT);
builderConfig.spaceTemplateQueryKeyword = cs.getValue(com.ibm.mashups.enabler.services.ConfigConstants.SPACEMANAGER_SPACE_QUERYKEYWORD);
builderConfig.pageQueryCount = cs.getValue(com.ibm.mashups.enabler.services.ConfigConstants.SPACEMANAGER_PAGE_QUERYCOUNT);
builderConfig.pageQueryKeyword = cs.getValue(com.ibm.mashups.enabler.services.ConfigConstants.SPACEMANAGER_PAGE_QUERYKEYWORD);
})();
dojo.declare("com.ibm.mm.builder.builderpre",null, {});
try {
com.ibm.mm.builder.coreWidgetsMessages = dojo.i18n.getLocalization("com.ibm.mm.builder", "coreWidgetsMessages");
com.ibm.mm.builder.coreWidgetsStrings = dojo.i18n.getLocalization("com.ibm.mm.builder", "coreWidgetsStr");
} catch (e) {
com.ibm.mm.builder.coreWidgetsMessages = dojo.i18n.getLocalization("com.ibm.mm.builder", "coreWidgetsMessages", ibmConfig["default.locale"]);
com.ibm.mm.builder.coreWidgetsStrings = dojo.i18n.getLocalization("com.ibm.mm.builder", "coreWidgetsStr", ibmConfig["default.locale"]);
}
}
if(!dojo._hasResource["com.ibm.mm.builder.iwidget.SystemWidget"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.iwidget.SystemWidget"] = true;
/**
* @author Jarod
*/
dojo.provide("com.ibm.mm.builder.iwidget.SystemWidget");
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
/**
* Summary: Define common action in core iwidget level.
*/
dojo.declare("com.ibm.mm.builder.iwidget.SystemWidget", null, {
cws: com.ibm.mm.builder.coreWidgetsStrings,
cwm: com.ibm.mm.builder.coreWidgetsMessages,
eventService: com.ibm.mashups.services.ServiceManager.getService("eventService"),
LOGGER: com.ibm.mashups.enabler.logging.Logger.getLogger(this.declaredClass),
onPageModeChanged: function(iEvent){
var pl = iEvent.payload;
if(!pl || pl.length < 2){ return; }
var modeName = "on"+ pl.charAt(0).toUpperCase() + pl.substring(1).toLowerCase();
if (this[modeName]) { this[modeName](); }
},
getViewRootNode: function(){
return this._getModeRootNode("view");
},
// //todo cannot get edit root if edit dom shows in dialog
// getEditRootNode: function(){
// return this._getModeRootNode("edit");
// },
_getModeRootNode: function(mode){
var node = dojo.query("> .iw-Content." + mode, this.iContext.getRootElement())[0]; //spec
if (!node) {
node = dojo.query("> .mm_Content." + mode, this.iContext.getRootElement())[0]; //legacy
}
return node;
}
});
dojo.declare("com.ibm.mm.builder.iwidget.SystemTemplatedWidget", com.ibm.mm.builder.iwidget.SystemWidget, {
onView: function(){
this._loadMode("View");
},
onEdit: function(){
this._loadMode("Edit");
},
_loadMode: function(mode){
//only load once
if (this[mode + "IsLoaded"]) { return; }
var methods = {};
for(var elementName in this){
if(typeof this[elementName] == "function" && !(elementName in this.constructor.superclass)){
methods[elementName] = dojo.hitch(this, this[elementName]);
}
}
var modeNode = this["get"+ mode+"RootNode"]();
var modeNodeContent = dojo.isIE ? com.ibm.mm.builder.utils.htmlUtil.addMissingQuoteInTitle(modeNode.innerHTML) : modeNode.innerHTML;
//to make child object access template widget's attach points
var modeTemplate = new com.ibm.mm.builder.iwidget.TemplatedWidget(
//mix in the methods of this to support dojoAttachEvent
dojo.mixin({templateString: modeNodeContent}, methods)
);
var attachedNodes = {};
//mixin attachPoints in context
for(var nn in modeTemplate){
if (Object.prototype.hasOwnProperty.call(modeTemplate,nn)) {
var rr = modeTemplate[nn];
if ((rr && rr.nodeType == 1 && nn !== "domNode") || rr instanceof dijit._Widget) {
attachedNodes[nn] = rr;
}
}
}
dojo.mixin(this, attachedNodes);
modeNode.innerHTML = "";
modeNode.appendChild(modeTemplate.domNode);
this[mode + "IsLoaded"] = true;
}
});
dojo.declare("com.ibm.mm.builder.iwidget.TemplatedWidget", [dijit._Widget, dijit._Templated], {
widgetsInTemplate: true,
postMixInProperties: function(){
var t = this.templateString;
if (t) {
this.templateString = dojo.string.substitute(t, com.ibm.mm.builder.coreWidgetsStrings, function(v, k){
return v || "$ {" + k + "}"; //error if removing the blank space between $ and {
});
}
}
});
}
if(!dojo._hasResource["com.ibm.mm.builder.eventTopics"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.eventTopics"] = true;
/**
*/
dojo.provide("com.ibm.mm.builder.eventTopics");
com.ibm.mm.builder.eventTopics = {
/* Hidden Widgets Correl */
Hidden_Widgets_Correl_Display: "/builder/hwc/display",
/* Page start */
Page_ModeChanged: "/builder/changeMode",
Page_ContentChanged: "pageChanged",
Page_OnChanged: "onChangeMode",
Page_Save: "/builder/page/save",
Update_Page_With_Default_Content: "/builder/page/update",
// Page_OnSave will be published when current page is saved
// the parameter is a boolean (true: save successfully, false: save failed)
Page_OnSave: "/builder/pageSaved",
/* Page end */
//change mode
Goto_Catalog: "/builder/goto/catalog",
Open_Catalog: "/builder/open/catalog",
Open_Catalog_New_Window : "/builder/open/catalog_new_window",
/* Wiring start */
WirePane_OverWidget: "wirePane/moveOverWidget",
WirePane_OutWidget: "wirePane/moveOutWidget",
/* Wiring end */
/* Banner start */
//Banner_TitleChanged: "/builder/titleChanged", /*deprecated since we use iEvent wires*/
Banner_BackgroundChanged:"/builder/backgroundChanged",
Banner_BackgroundChangedBack:"/builder/backgroundChangedBack",
/* Banner end */
/* Widget start */
Widget_ConfigurationFinished: "/widget/action/finished",
Widget_Hide: "/widget/action/hide",
Widget_Create: "/widget/action/create",
Widget_Column_AddOrDel: "/widget/column/addOrDel",
/* Widget end */
/* Resize start */
Resize_StartSizing: "/startSizing",
Resize_StartHeightSizing: "/startHeightSizing",
Resize_ChangeSizing: "/changeSizing",
Resize_ChangeHeightSizing: "/changeHeightSizing",
Resize_EndSizing: "/endSizing",
Resize_EndHeightSizing: "/endHeightSizing",
/* Resize end */
Save_Icon_Change: "/saveIconChange",
/* Widget menu start */
WidgetMenu_Hide: "/widgetMenu/action/hide",
/* Widget menu end */
/* ACL Page Control start */
UpdateViewPageControl: "/ACL/pageControl/view",
UpdatePersonalizePageControl: "/ACL/pageControl/personalize",
UpdateEditPageControl: "/ACL/pageControl/edit",
UpdateSearchPageControl: "/ACL/pageControl/search",
UpdateAllPageControl: "/ACL/pageControl/all",
AclDialogHide:"/ACL/dialogHide",
/* ACL Page Control end */
/* Publish Page start*/
Publish_Page_Show: "/publish/page/show",
Publish_Page_Hide: "/publish/page/hide",
FreeForm_Layout_Loaded:"/freeformlayout/loaded"
};
// for v1.1 widget compatibility
com.ibm.mm.builder.Topics = com.ibm.mm.builder.eventTopics;
}
if(!dojo._hasResource["com.ibm.mm.builder.constant"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.constant"] = true;
/**
*/
dojo.provide("com.ibm.mm.builder.constant");
com.ibm.mm.builder.constant = {
//remove, useless
appURL: "https://localhost:8080",
enablerModelIdPrefix:"id:",
iwIWidget: "iw-iWidget",//iWidget spec v1
iWStandalone: "iw-Standalone",
mmIWidget: "mm_iWidget",//legacy
iwOAGadget: "iw-OAGadget", //openAjax
mmOAGadget: "mm_OAGadget", //openAjax
iwGGadget: "iw-OSGadget", //OpenSocial Gadget
mmGGadget: "mm_OSGadget", //OpenSocial Gadget
osGadgetChrome: "gadgets-gadget-chrome",
osGadgetUserPrefs: "gadgets-gadget-user-prefs-dialog",
osGadgetContent: "gadgets-gadget-content",
iwDefinition:"iw-Definition", //iWidget spec v1
mmDefinition:"mm_Definition", //legacy
iwItemSet: "iw-ItemSet",//iWidget spec v1
mmItemSet: "mm_ItemSet",//legacy
iwItem: "iw-Item",//iWidget spec v1
mmItem: "mm_Item",//legacy
generic_widget_icon: "/wps/mccbuilder.v3001/images/generic_widget_icon.gif",
skinIdPrefix: "mm_ibm_skin_",
skinClass: "iWidgetSkin",
dragHandler: "_dragHandler",
resizeHandler: "_resizer",
resizeHandlerExt: "_res",
resizeHeightExt: "_heightRes",
widgetBody: "_widgetBody",
widgetContent: "_content",
menuHandler: "_menu",
iWidgetContent: "mm_Content",
iwWidgetContent: "iw-Content",
iWidgetLoading: "mm_loading",
iwWidgetLoading: "iw-loading",
handledEvents: "mm_handledEvents",
event: "mm_event",
publishedEvents: "mm_publishedEvents",
iwReceivedEvent: "iw-ReceivedEvent",//iWidget spec v1
receivedEvent: "mm_ReceivedEvent",//legacy
iwEvent:"iw-Event",//iWidget spec v1
mmEvent:"mm_Event",//legacy
sourceWidget: "mm_SourceWidget",
mmSourceEventName:"mm_SourceEventName",//iWidget spec v1
mmTargetEventName:"mm_TargetEventName",//iWidget spec v1
iwSourceEvent: "iw-SourceEvent",
iwTargetEvent: "iw-TargetEvent",
sourceEvent: "mm_SourceEvent",
targetEvent: "mm_TargetEvent",
itemSet: "mm_itemSet",//to be removed, replaced by mmItemSet
item: "mm_item",
itemName: "mm_itemName",//to be removed, replaced by mmItemSet
itemValue: "mm_itemValue",//to be removed, replaced by mmItemSet
configPannelNode: "configPannelNode",
widget_span_attr_class: "class",
widget_span_attr_widget: "widget",//to be removed, replaced by mmDefinition
widget_span_attr_style: "style",
widget_span_attr_onNewWire: "onnewwire", //to be removed, enabler will handle onNewWire/onRemoveWire
widget_span_attr_id: "id",
widget_span_attr_visible: "visible",
widget_span_attr_skin: "skin",
nva_skin_upper: "_upper",
no_page_message:"No page to show. Please use navigation widget to create a new page.",
aclIdPrefix:"_acl",
editbarDragHandler:"_dragHandler_editbar",
freeformLayoutClass:"freednd",
columnLayoutClass:"fixeddnd",
HWCClass:"nva",
toolboxClass:"toolbox",
nvaSkinName:"nva",
layoutWidgetItemSet:"LayoutWidgetAttributes",
autoWiringEnabled: "com.ibm.mashups.builder.autoWiringEnabled",
dbcsEnlarged: "dbcsEnlarged",
/**
* navigation pagination number, default is 5;
* adjust by the whole page reslovation and item height
*/
NavigationPageSize: 20,
ToolboxPageSize: 20,
editBarHeight:35,
/**
* Send XmlHttpRequest to backend to keep session alive
* Current value: 5 minutes
*/
intervalToKeepSessionAlive:5*60*1000,
defaultWidgetWidth : 400,
cookieKey_previous_pid: "digest.ignore.previous_pid",
cookieKey_globalPageId: "digest.ignore.global_page_id",
cookieKey_globalPageOpenedSpaceId: "digest.ignore.global_page_id_openedSpace",
cookieKey_login_flag: "MUMLoginFlag"
};
}
if(!dojo._hasResource["com.ibm.mashups.builder.IEvent"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mashups.builder.IEvent"] = true;
dojo.provide("com.ibm.mashups.builder.IEvent");
/**
* com.ibm.mashups.builder.IEvent defines all the public builder iEvents.
* Usage: call com.ibm.mashups.builder.iEvents.SWITCH_PAGE to retreive the ievent name "com.ibm.mashups.builder.switchPage".
*
* 1. IEvent naming convention.
* IEvent name such as SWITCH_PAGE
and PAGE_SWITCHED
followed the basic rules:
* (1) Verb + Noun: the iEvent is broadcast before the action happen.
* (2) Noun + Past Tense Verb: the iEvent is broadcast after the action happen.
*
* 2. Terminology
* (1) System iWidget: iWidget defined in theme.
* (2) User iWidget: iWidget which user can add to a mashup page.
* (3) Layout iWidget: a kind of system iWidget that manages user iWidget instances.
* (4) None visible area: a kind of system iWidget that contains user iWidget instances in a hidden area.
* (5) iWidget definition id: unique id of the iWidget metadata in enabler catalog API.
* (6) iWidget instance id: unique id of the iWidget instance.
* @ibm-api
* @ibm-module Builder
*/
dojo.declare("com.ibm.mashups.builder.IEvent", null, {
/**
* Description: System iWidget should broadcast SWITCH_PAGE iEvent to switch to a given page.
* Navigation iWidget must handle SWITCH_PAGE iEvent to switch page;
* after page is switched, iEvent "com.ibm.mashups.builder.pageSwitched"
must be broadcast.
* Value: "com.ibm.mashups.builder.switchPage"
* Payload: id of page which will be switched to. Could be null
. If null, Navigation iWidget will load current user's first page.
* Payload type: text
* @type String
*/
SWITCH_PAGE: "com.ibm.mashups.builder.switchPage",
/**
* Description: Navigation iWidget must broadcast PAGE_SWITCHED iEvent after page is switched.
* System iWidget can handle PAGE_SWITCHED iEvent to do follow-up work.
* Value: "com.ibm.mashups.builder.pageSwitched"
* Payload: id of page switched to. Could be null
which means no page available for current user.
* Payload type: text
* @type String
*/
PAGE_SWITCHED: "com.ibm.mashups.builder.pageSwitched",
/**
* Description: System iWidget should broadcast SWITCH_SPACE iEvent to switch to a given space.
* SpaceSelector iWidget must handle SWITCH_PAGE iEvent to switch space.
* Value: "com.ibm.mashups.builder.switchSpace"
* Payload: id of space which will be switched to. Could be null
. If null, SpaceSelector iWidget will switch to personal space.
* Payload type: text
* @type String
*/
SWITCH_SPACE: "com.ibm.mashups.builder.switchSpace",
/**
* Description: System iWidget broadcasts REFRESH_SPACE_SELECTOR iEvent to announce the space model has been changed.
* SpaceSelector iWidget must handle REFRESH_SPACE_SELECTOR iEvent to retrieve the latest space model and re-render the UI.
* For example, when user creates space within space manager, REFRESH_SPACE_SELECTOR iEvent must be broadcast to refresh Space Selector iWidget UI.
* Value: "com.ibm.mashups.builder.refreshSpaceSelector"
* Payload: id of space which title will be shown up in space selector. Could be null
. If null, current space title will be used.
* Payload type: text
* @type String
*/
REFRESH_SPACE_SELECTOR: "com.ibm.mashups.builder.refreshSpaceSelector",
/**
* Description: REFRESH_SPACE_LIST_IN_SPACE_MANAGER iEvent is broadcasted to refresh the space list in the space manager when space manager is opened
* Space Manager iWidget must handle this iEvent to retrieve the latest space model and re-refresh the space list
* Value: "com.ibm.mashups.builder.spacemanager.refreshSpaceList"
* Payload: N/A
* @type String
*/
REFRESH_SPACE_LIST_IN_SPACE_MANAGER: "com.ibm.mashups.builder.spacemanager.refreshSpaceList",
/**
* Description: System iWidget broadcasts REFRESH_NAVIGATION iEvent to announce the navigation model has been changed.
* Navigation iWidget must handle REFRESH_NAVIGATION iEvent to retrieve the latest navigation model and re-render the UI.
* For example, when user changes the page title, REFRESH_NAVIGATION iEvent must be broadcast to refresh Navigation iWidget UI.
* Value: "com.ibm.mashups.builder.refreshNavigation"
* Payload: N/A
* @type String
*/
REFRESH_NAVIGATION: "com.ibm.mashups.builder.refreshNavigation",
/**
* Description: System iWidget broadcasts REFRESH_PALETTE iEvent to announce the catalog model has been changed.
* Palette iWidget must handle this iEvent to retrieve the latest catalog model and re-render the UI.
* For example, when a new iWidget is added to Palette, REFRESH_PALETTE iEvent must be broadcast to refresh Palette.
* Value: "com.ibm.mashups.builder.refreshPalette"
* Payload: N/A
* @type String
*/
REFRESH_PALETTE: "com.ibm.mashups.builder.refreshPalette",
/**
* Description: System iWidget can broadcast LAYOUT_REFRESH iEvent to announce the layout model has been changed.
* TemplateLayout iWidget handles LAYOUT_REFRESH iEvent to retrieve the latest layout model and re-render the UI.
* Value: "com.ibm.mashups.builder.layoutRefresh"
* Payload: id of layout container or control whose markup will be refreshed. Can be null
. If null, entire layout (all containers) will be refreshed.
* Payload type: text
* @type String
*/
LAYOUT_REFRESH: "com.ibm.mashups.builder.layoutRefresh",
/**
* Description: TemplateLayout iWidget broadcasts LAYOUT_REFRESHED iEvent after layout is done refreshing.
* Value: "com.ibm.mashups.builder.layoutRefreshed"
* Payload: null
if entire layout was just refreshed. Or, id of individual layout container or control that was just refreshed.
* Payload type: text
* @type String
*/
LAYOUT_REFRESHED: "com.ibm.mashups.builder.layoutRefreshed",
/**
* Description: System iWidget can broadcast REFRESH_CONTEXT_MENU iEvent to notify a context menu's listeners that it was updated.
* Value: "com.ibm.mashups.builder.refreshContextMenu"
* Payload: id of context menu whose listeners will be fired. Must not be null
.
* Payload type: text
* @type String
*/
REFRESH_CONTEXT_MENU: "com.ibm.mashups.builder.refreshContextMenu",
/**
* Description: System iWidget can broadcast VIEW_HIDDEN_WIDGETS iEvent to show any hidden-widget containers on the page.
* TemplateLayout iWidget handles VIEW_HIDDEN_WIDGETS iEvent to show any hidden-widget containers on the page.
* Value: "com.ibm.mashups.builder.viewHiddenWidgets"
* Payload: none; can be null
.
* Payload type: text
* @type String
*/
VIEW_HIDDEN_WIDGETS: "com.ibm.mashups.builder.viewHiddenWidgets",
/**
* Description: System iWidget can broadcast HIDE_HIDDEN_WIDGETS iEvent to hide any hidden-widget containers on the page.
* TemplateLayout iWidget handles HIDE_HIDDEN_WIDGETS iEvent to hide any hidden-widget containers on the page.
* Value: "com.ibm.mashups.builder.hideHiddenWidgets"
* Payload: none; can be null
.
* Payload type: text
* @type String
*/
HIDE_HIDDEN_WIDGETS: "com.ibm.mashups.builder.hideHiddenWidgets",
/**
* Description: CHANGE_PAGE_MODE iEvent will be broadcast when page mode is changed.
* System iWidgets can define CHANGE_PAGE_MODE iEvent as handled iEvent to update their UI accordingly. In current Lotus Mashups it only has 2 modes
* ("view"/"edit"), but it's not limited to.
* Value: "com.ibm.mashups.builder.changePageMode"
* Payload: new page mode. Either "view" or "edit". Must not be null
.
* Payload type: text
* @type String
*/
CHANGE_PAGE_MODE: "com.ibm.mashups.builder.changePageMode",
/**
* Deprecated: ADD_WIDGET_FROM_TOOLBOX iEvent is replaced witch ADD_WIDGET.
* Description: System iWidget can broadcast ADD_WIDGET_FROM_TOOLBOX iEvent to create a user iWidget instance.
* Layout iWidget must define ADD_WIDGET_FROM_TOOLBOX iEvent as handled iEvent to create the user iWidget instance according to the payload
* Base on the enabler CatalogModel API, system iWidget developer can get the user iWidget metadata according to user iWidget definition id.
* Value: "com.ibm.mashups.builder.addWidgetFromToolbox"
* Payload: this event could accept three kinds of payload.
* - Text: It is the iWidget definition id. The definition id must a valid value in enabler CatalogModel API. Must not be null
.
.
* For example: "feedReader".
* - Json Object: It includes widget definition id and itemset as preference. The itemset enable developer set/change preference of widget instance during widget rendering.
* For example:
* {id: "feedReader", itemset: {feedUrl:"https://www.ibm.com/feed.rss"} }.
* - Json Object: It includes widget definition metadata and itemset as preference. The keys in widgetMetadata should be same as enabler API.
* For example:
* {
* widgetMetadata:
* {
* id:"feedReader",
* definition:"/feedReader/feedReader.xml",
* icon: "/feedReader/feedreader.png",
* title:{en:"FeedReader", zh_CN:"yueduqi"},
* onNewWire: "",
* widgetParam: "[]"
* },
* itemset: {feedURL:"https://www.ibm.com/feed.rss"}
* }
* Payload type: text or json
* @type String
*/
ADD_WIDGET_FROM_TOOLBOX: "com.ibm.mashups.builder.addWidgetFromToolbox",
/**
* Description: System iWidget can broadcast ADD_WIDGET iEvent to create a user iWidget instance.
* Layout iWidget must define ADD_WIDGET iEvent as handled iEvent to create the user iWidget instance according to the payload
* Base on the enabler CatalogModel API, system iWidget developer can get the user iWidget metadata according to user iWidget definition id.
* Value: "com.ibm.mashups.builder.addWidget"
* Payload: this event could accept three kinds of payload.
* - Text: It is the iWidget definition id. The definition id must a valid value in enabler CatalogModel API. Must not be null
.
.
* For example: "feedReader".
* - Json Object: It includes widget definition id and itemset as preference. The itemset enable developer set/change preference of widget instance during widget rendering.
* For example:
* {id: "feedReader", itemset: {feedUrl:"https://www.ibm.com/feed.rss"} }.
* - Json Object: It includes widget definition metadata and itemset as preference. The keys in widgetMetadata should be same as enabler API.
* For example:
* {
* widgetMetadata:
* {
* id:"feedReader",
* definition:"/feedReader/feedReader.xml",
* icon: "/feedReader/feedreader.png",
* title:{en:"FeedReader", zh_CN:"yueduqi"},
* onNewWire: "",
* widgetParam: "[]"
* },
* itemset: {feedURL:"https://www.ibm.com/feed.rss"}
* }
* Payload type: text or json
* @type String
*/
ADD_WIDGET: "com.ibm.mashups.builder.addWidget",
/**
* Description: RESET_STYLE iEvent is broadcast to recreate a empty style of layout iWidget.
* Layout iWidget can define RESET_STYLE iEvent as handled iEvent to recreate style of itself.
* Value: "com.ibm.mashups.builder.resetStyle"
* Payload: N/A
* @type String
*/
RESET_STYLE: "com.ibm.mashups.builder.resetStyle",
/**
* Description: DISPLAY_WIDGET iEvent is broadcast to move a user iWidget instance from none visible area to layout iWidgets.
* Layout iWidget must define DISPLAY_WIDGET iEvent as handled iEvent to show a user iWidget instance in itself.
* Value: "com.ibm.mashups.builder.displayWidget"
* Payload: user iWidget instance id. Must not be null
.
* Payload type: text
* @type String
*/
DISPLAY_WIDGET: "com.ibm.mashups.builder.displayWidget",
/**
* Description: HIDE_WIDGET iEvent is broadcast to move a user iWidget instance from layout iWidget to none visible area.
* None visible area must define HIDE_WIDGET iEvent as handled iEvent to hide a user iWidget instance into itself.
* Value: "com.ibm.mashups.builder.hideWidget"
* Payload: user iWidget instance id. Must not be null
.
* Payload type: text
* @type String
*/
HIDE_WIDGET: "com.ibm.mashups.builder.hideWidget",
/**
* Description: RENAME_WIDGET iEvent is broadcast to rename a user iWidget instance.
* Layout iWidget must define RENAME_WIDGET iEvent as handled iEvent to update the user iWidget instance name.
* Value: "com.ibm.mashups.builder.renameWidget"
* Payload: data of the updated user iWidget name. Must not be null
.
* {
* id: user iWidget instance id,
* name: new name of the user iWidget instance
* locale(optional): locale of the name
* }
* Payload type: json
* @type String
*/
RENAME_WIDGET: "com.ibm.mashups.builder.renameWidget",
/**
* Description: RENAME_ACTION iEvent is broadcast from iWidget context menu to inform another system iWidget to handle rename iWidget action.
* Value: "com.ibm.mashups.builder.renameAction"
* Payload: user iWidget instance id. Must not be null
.
* Payload type: text
* @type String
*/
RENAME_ACTION: "com.ibm.mashups.builder.renameAction",
/**
* Description: MOVE_ACTION iEvent is broadcast from iWidget context menu to inform another system iWidget to handle move iWidget action.
* Value: "com.ibm.mashups.builder.moveAction"
* Payload: user iWidget instance id. Must not be null
.
* Payload type: text
* @type String
*/
MOVE_ACTION: "com.ibm.mashups.builder.moveAction",
/**
* Description: RESIZE_ACTION iEvent is broadcast from iWidget context menu to inform another system iWidget to handle resize iWidget action.
* Value: "com.ibm.mashups.builder.resizeAction"
* Payload: user iWidget instance id. Must not be null
.
* Payload type: text
* @type String
*/
RESIZE_ACTION: "com.ibm.mashups.builder.resizeAction",
/**
* Description: CHANGE_SKIN iEvent is broadcast to change the skin of a user iWidget instance.
* Layout iWidget must define CHANGE_SKIN iEvent as handled iEvent to update the skin of user iWidget instance.
* Enabler ThemeModel will provide all the Skin available in current theme. Builder runtime model API will provide current theme Id.
* Value: "com.ibm.mashups.builder.changeSkin"
* Payload: user iWidget instance and the new skin id. The new skin id must be a valid skin id in enabler ThemeModel api.
* Must not be null
.
* {
* id: user iWidget instance id
* skin: new skin name
* }
* Payload type: json
* @type String
*/
CHANGE_SKIN: "com.ibm.mashups.builder.changeSkin",
/**
* Description: Mashup skin service broadcasts SKIN_LOADED iEvent when skin is loaded.
* Layout iWidget could define SKIN_LOADED iEvent as handled iEvent if it needs to
* initialize some additional handlers in user iWidget skin, such as drag and drop handler, resize handler.
* Value: "com.ibm.mashups.builder.skinLoaded"
* Payload: skin parameters. Must not be null
.
* {
* widgetId: user iWidget instance id,
* skinNodeId: user iWidget skin node,
* skinParam: skin parameters defined in skin.js in the skin resource directory, json
* }
* Payload type: json
* @type String
*/
SKIN_LOADED: "com.ibm.mashups.builder.skinLoaded",
/**
* Description: RESIZE_WIDGET iEvent should be broadcast to adjust the width or height of user iWidget instance.
* Layout iWidget can define RESIZE_WIDGET iEvent as handled iEvent to update the size of user iWidget instance.
* Value: "com.ibm.mashups.builder.resizeWidget"
* Payload: size of user iWidget instance. Must not be null
.
* {
* widgetId: id of user iWidget instance,
* width: new width of user iWidget instance,
* height: new height of user iWidget instance
* }
* Payload type: json
* @type String
*/
RESIZE_WIDGET: "com.ibm.mashups.builder.resizeWidget",
/**
* Description: WIDGET_RESIZED iEvent should be broadcast after the size of user iWidget instance is changed.
* User iWidget can define WIDGET_RESIZED iEvent as handled iEvent to do some follow up work if necessary.
* Value: "com.ibm.mashups.builder.widgetResized"
* Payload: size of user iWidget instance. Must not be null
.
* {
* widgetId: id of user iWidget instance,
* width: new width of user iWidget instance,
* height: new height of user iWidget instance
* }
* Payload type: json
* @type String
*/
WIDGET_RESIZED: "com.ibm.mashups.builder.widgetResized",
/**
* Description: WIDGET_MOVED iEvent should be broadcast after a user iWidget instance is moved in the layout.
* User iWidget can define WIDGET_MOVED iEvent as handled iEvent to do some follow up work if necessary.
* Value: "com.ibm.mashups.builder.widgetMoved"
* Payload: user iWidget instance id. Must not be null
.
* Payload type: text
* @type String
*/
WIDGET_MOVED: "com.ibm.mashups.builder.widgetMoved",
/**
* Description: WIDGET_DELETED iEvent should be broadcast after a user iWidget instance has been deleted from the layout.
* User iWidget can define WIDGET_DELETED iEvent as handled iEvent to do some follow up work if necessary.
* Value: "com.ibm.mashups.builder.widgetDeleted"
* Payload: user iWidget instance id. Must not be null
.
* Payload type: text
* @type String
*/
WIDGET_DELETED: "com.ibm.mashups.builder.widgetDeleted",
/**
* Description: System iWidget should broadcast EMBED_PAGE iEvent to embed a mashup page.
* System iWidget (e.g EmbedPage) can define EMBED_PAGE iEvent as handled iEvent to accept to create the embedding UI for the page.
* Value: "com.ibm.mashups.builder.embedPage"
* Payload: page id. Must not be null
.
* Payload type: text
* @type String
*/
EMBED_PAGE: "com.ibm.mashups.builder.embedPage",
/**
* Description: System iWidget broadcasts EMBED_WIDGET iEvent to embed a user iWidget.
* System iWidget (e.g EmbedWidget) can define EMBED_WIDGET iEvent as handled iEvent to create the embedding UI for the user iWidget.
* Value: "com.ibm.mashups.builder.embedWidget"
* Payload: user iWidget definition id. Must not be null
.
* Payload type: text
* @type String
*/
EMBED_WIDGET: "com.ibm.mashups.builder.embedWidget",
/**
* Description: System iWidget broadcasts LOAD_PAGESOURCE iEvent to load the page source.
* System iWidget (e.g PageSource) can define LOAD_PAGESOURCE iEvent as handled iEvent to load the mashup page user iWidget markups into its source container.
* Value: "com.ibm.mashups.builder.loadPageSource"
* Payload: N/A
* @type String
*/
LOAD_PAGESOURCE: "com.ibm.mashups.builder.loadPageSource",
/**
* Description: System iWidget broadcasts SAVE_PAGE iEvent to save page source.
* System iWidget (e.g PageSource) must define SAVE_PAGE iEvent as handled iEvent to persist the user iWidget markups in current page.
* System iWidget developer can call enabler Navigation Model API to persist current page.
* Value: "com.ibm.mashups.builder.savePage"
* Payload: page id. Must not be null
.
* Payload type: text
* @type String
*/
SAVE_PAGE: "com.ibm.mashups.builder.savePage",
/**
* Description: PAGE_SAVED iEvent should be broadcast after the page has been saved.
* User iWidget can define PAGE_SAVED iEvent as handled iEvent to do some follow up work if necessary.
* Value: "com.ibm.mashups.builder.pageSaved"
* Payload: page id. Must not be null
.
* Payload type: text
* @type String
* @since 3.0.0.2
*/
PAGE_SAVED: "com.ibm.mashups.builder.pageSaved",
/**
* Description: System iWidget broadcasts EDIT_PAGE iEvent to load page property.
* System iWidget (e.g PagePropertyEditor) can define EDIT_PAGE iEvent as handled iEvent to load the page properties, for example, page theme and page title.
* Value: "com.ibm.mashups.builder.editPage"
* Payload: page id. Must not be null
.
* Payload type: text
* @type String
*/
EDIT_PAGE: "com.ibm.mashups.builder.editPage",
/**
* Description: System iWidget broadcasts UPDATE_PAGE_TITLE iEvent to update page title.
* System iWidget (e.g PageTitle) can define UPDATE_PAGE_TITLE iEvent as handled iEvent to update the title in its displaying area.
* Value: "com.ibm.mashups.builder.updatePageTitle"
* Payload: page title. Must not be null
.
* {
* title: page title,
* locale(optional): locale of the title
* }
* Payload type: json
* @type String
*/
UPDATE_PAGE_TITLE: "com.ibm.mashups.builder.updatePageTitle",
/**
* Description: System iWidgets broadcasts HIGHLIGHT_WIDGET iEvent to make Layout iWidget highlight a specific user iWidget.
* Layout iWidget should define HIGHLIGHT_WIDGET iEvent as handled iEvent in case it wants to highlight a user iWidget instance.
* Value: "com.ibm.mashups.builder.highlightWidget"
* Payload: id of user iWidget instance. Must not be null
.
* Payload type: text
* @type String
*/
HIGHLIGHT_WIDGET: "com.ibm.mashups.builder.highlightWidget",
/**
* Description: System iWidgets broadcasts REMOVE_WIDGET_HIGHTLIGHT iEvent to make Layout iWidget remove highlight of a specific user iWidget.
* Layout iWidget should define REMOVE_WIDGET_HIGHTLIGHT iEvent as handled iEvent in case it wants to remove the highlight on a user iWidget instance.
* Value: "com.ibm.mashups.builder.removeWidgetHighlight"
* Payload: id of user iWidget instance. Must not be null
.
* Payload type: text
* @type String
*/
REMOVE_WIDGET_HIGHTLIGHT: "com.ibm.mashups.builder.removeWidgetHighlight",
/**
* Description: System iWidget broadcasts ADD_NEW_WIRE iEvent to inform layout iWidget to add a new wire.
* Layout iWidget must define ADD_NEW_WIRE iEvent as handled iEvent, update the iWidget markup to add the new wire.
* Value: "com.ibm.mashups.builder.addNewWire"
* Payload: context information used to create new wire. Must not be null
.
* {
* sourceWidgetId: id of the wire's source iWidget
* sourceEvent: published event name of the source iWidget
* targetWidgetId: id of the wire's target iWidget
* targetEvent: handled event name of the target iWidget
* }
* Payload type: json
* @type String
*/
ADD_NEW_WIRE: "com.ibm.mashups.builder.addNewWire",
/**
* Description: System iWidget broadcasts REMOVE_NEW_WIRE iEvent to inform layout iWidget to remove an existing wire.
* Layout iWidget must define REMOVE_NEW_WIRE iEvent as handled iEvent, update the iWidget markup to remove the wire.
* Value: "com.ibm.mashups.builder.removeWire"
* Payload: context information used to remove the wire. Must not be null
.
* {
* sourceWidgetId: id of the wire's source iWidget
* sourceEvent: published event name of the source iWidget
* targetWidgetId: id of the wire's target iWidget
* targetEvent: handled event name of the target iWidget
* }
* Payload type: json
* @type String
*/
REMOVE_WIRE: "com.ibm.mashups.builder.removeWire",
/**
* Description: CREATE_AUTO_WIRE iEvent can be broadcast to add auto wire between the specified widget with other iWidget instances on the page.
* Auto wire: Auto wire happens when
* 1. Auto-wiring is enabled for the page;
* 2. Specified iWidget is auto-wiring enabled;
* 3. The wired-to iWidget is auto-wiring enabled;
* 4. Wire the specified iWidget's iEvent to other iWidget's iEvent when the two iEvent have exactly same event name and payload type.
* Value: "com.ibm.mashups.builder.createAutoWire"
* Payload: iWidget instance id. Must not be null
.
* Payload type: text
* @type String
*/
CREATE_AUTO_WIRE: "com.ibm.mashups.builder.createAutoWire",
/**
* Description: AUTO_WIRE_CREATED iEvent will be broadcast to after a auto wire is added between two iWidget instances.
* Auto wire: refer to the iEvent CREATE_AUTO_WIRE.
* Value: "com.ibm.mashups.builder.autoWireCreated"
* Payload: Created auto-wires information. Must not be null
.
* {
* widgetId: instance id of the new added iWidget
* publishTo: Array, contains all instance id of the widgets which the new added iWidget is wired with as source iWidget
* receiveFrom: Array, contains all instance id of the widgets which the new added iWidget is wired with as target iWidget
* }
* Payload type: json
* @type String
*/
AUTO_WIRE_CREATED: "com.ibm.mashups.builder.autoWireCreated",
/**
* Description: CREATE_QUICK_WIRE iEvent can be broadcast to add a wire between two iWidget instances automatically.
* Quick wire: Check the two iWidget's first iEvent, if they can be wired together(payload type is compatible), wire them.
* QUICK_WIRE_CREATED iEvent must be broadcast after the wire is created
* Value: "com.ibm.mashups.builder.createQuickWire"
* Payload: context information used to add the wire. Must not be null
.
* {
* sourceWidgetId: id of the wire's source iWidget
* targetWidgetId: id of the wire's target iWidget
* }
*
* Payload type: json
* @type String
*/
CREATE_QUICK_WIRE: "com.ibm.mashups.builder.createquickWire",
/**
* Description: QUICK_WIRE_CREATED iEvent will be broadcast to after a quick wire is added between two iWidget instances.
* Quick wire: refer to the iEvent CREATE_QUICK_WIRE.
* Value: "com.ibm.mashups.builder.quickWireCreated"
* Payload: context information of the added wire. Must not be null
.
* {
* sourceWidgetId: id of the wire's source iWidget
* targetWidgetId: id of the wire's target iWidget
* }
*
* Payload type: json
* @type String
*/
QUICK_WIRE_CREATED: "com.ibm.mashups.builder.quickWireCreated",
/**
* Description: EDIT_WIRE iEvent can be broadcast to launch the wiring interface of a iWidget instance.
* Value: "com.ibm.mashups.builder.editWire"
* Payload: id of the user iWidget instance. Must not be null
.
* Payload type: text
* @type String
*/
EDIT_WIRE: "com.ibm.mashups.builder.editWire",
/**
* Description: DISPLAY_WIRE_GRAPH iEvent can be broadcast to display the wire graph of a iWidget instance.
* Value: "com.ibm.mashups.builder.displayWireGraph"
* Payload: id of the user iWidget instance. Must not be null
.
* Payload type: text
* @type String
*/
DISPLAY_WIRE_GRAPH: "com.ibm.mashups.builder.displayWireGraph",
/**
* Description: System iWidget broadcasts SHARE_PAGE iEvent to notice other iWidgets to start the sharing work.
* System iWidget (e.g SharePage iWidget) which implements the sharing function should define this iEvent as handled iEvent
* Value: "com.ibm.mashups.builder.sharePage"
* Payload: id of the shared page. Must not be null
.
* Payload type: text
* @type String
*/
SHARE_PAGE: "com.ibm.mashups.builder.sharePage",
/**
* Description: System iWidget broadcasts SHARE_SPACE iEvent to notice other iWidgets to start the sharing work.
* System iWidget (e.g SharePage iWidget) which implements the sharing function should define this iEvent as handled iEvent
* Value: "com.ibm.mashups.builder.shareSpace"
* Payload: id of the shared space. Must not be null
.
* Payload type: text
* @type String
*/
SHARE_SPACE: "com.ibm.mashups.builder.shareSpace",
/**
* Description: System iWidget broadcasts PUBLISH_PAGE iEvent to notice other iWidgets to start the publishing page work.
* System iWidget (e.g PublishPage iWidget) which implements the publish function must define this iEvent as handled iEvent
* Value: "com.ibm.mashups.builder.publishPage"
* Payload: id of the published page. Must not be null
.
* Payload type: text
* @type String
*/
PUBLISH_PAGE: "com.ibm.mashups.builder.publishPage",
/**
* Description: System iWidget broadcasts VIEW_MORE_PAGE iEvent to notice other iWidgets it wants to accept pages from other users.
* System iWidget (e.g viewMorePage iWidget) which implements that function should define this iEvent as handled iEvent.
* Value: "com.ibm.mashups.builder.viewMorePage"
* Payload: N/A
* @type String
*/
VIEW_MORE_PAGE: "com.ibm.mashups.builder.viewMorePage",
/**
* Description: DISPLAY_IN_MASHUP_DIALOG iEvent can be broadcast to display system iWidget in a configurable mashup dialog.
* The system iWidget need to be linked to a type id in "dialogDisplayer" iWidget's itemset.
* Current supported type id:
*
null
.EDIT_WIRE iEvent.
* var dialogParam =
* {
* nodeWidth: "486px",
* ......
* displayCloseButton: false,
* hasRightBottomResizer: false
* }
* var payload =
* {
* widgetTypeId: "pageSoure",
* eventName: "com.ibm.mashups.builder.loadPageSource",
* eventPayload: ...,
* dialogParam: dialogParam
* }
* var eventService = com.ibm.mashups.services.ServiceManager.getService("eventService");
* eventService.broadcastEvent("com.ibm.mashups.builder.displayInMashupDialog", payload);
* Payload type: json
* @type String
*/
DISPLAY_IN_MASHUP_DIALOG: "com.ibm.mashups.builder.displayInMashupDialog",
/**
* Description: CLOSE_MASHUP_DIALOG iEvent can be broadcast with a system iWidget id.
* If that system iWidget is displayed in a mashup dialog, then the dialog will be closed.
* Value: "com.ibm.mashups.builder.closeMashupDialog"
* Payload: id of the system iWidget instance which is displayed in the mashup style dialog. Must not be null
.
* Payload type: text
* @type String
*/
CLOSE_MASHUP_DIALOG: "com.ibm.mashups.builder.closeMashupDialog",
/**
* Description: STATE_CHANGED iEvent can be broadcast to change the widget's state, restore/max/min the current widget by layout widget.
* Value: "com.ibm.mashups.builder.stateChanged"
* Payload: id of the iWidget instance, and widget's state. Must not be null
.
* {
* widgetId: iwidgetId,
* state: "max"/"min"/"normal"
* }
* Payload type: json
* @type String
*/
STATE_CHANGED: "com.ibm.mashups.builder.stateChanged",
/**
* Description: Broadcast OPEN_PAGE iEvent to open a given page and optionally broadcast widget events to it.
* Value: "com.ibm.mashups.builder.openPage"
* Payload: This event can accept two kinds of payload, id of the page to be opened or a json object in the follow format. Must not be null
.
* {
* pid: id of the page to be opened
* eventsArray: an array of events to be broadcast to the widgets on the page
* }
* The "eventsArray" should include one or more event objects in this format
* {
* targetEvent: targetEvent
* payload: payload
* payloadType: payloadType
* }
* Payload type: text or json
* @type String
*/
OPEN_PAGE:"com.ibm.mashups.builder.openPage",
/**
* Description: Broadcast CLOSE_PAGE iEvent to close a given page that was opened using the OPEN_PAGE iEvent. If CLOSE_PAGE is broadcast multiple times,
* the actual close page action only happen once.
* Value: "com.ibm.mashups.builder.closePage"
* Payload: id of the page to be closed.
* Payload type: text
* @type String
*/
CLOSE_PAGE:"com.ibm.mashups.builder.closePage",
/**
* Description: System iWidget broadcasts CREATE_PAGE iEvent to initiate Create Page widget, which allows to create a new page.
* Value: "com.ibm.mashups.builder.createPage"
* Payload: spaceId
refers to under which space new page will be created, parentPageId
refers to new page's parent page. Must not be null
.
* {
* spaceId: space id,
* parentPageId: parent page id
* }
* Payload type: json
* @type String
*/
CREATE_PAGE:"com.ibm.mashups.builder.createPage",
/**
* Description: System iWidget broadcasts CREATE_SPACE iEvent to initiate Create Space widget, which allows to create a new space.
* Value: "com.ibm.mashups.builder.createSpace"
* Payload: createSpaceFromSpaceManager
should be set as true
if CREATE_SPACE is broadcast inside Space Manager, otherwise false
. Must not be null
.
* {
* createSpaceFromSpaceManager: a boolean value to indicate whether the create space action is launched from space manager
* }
* Payload type: json
* @type String
*/
CREATE_SPACE:"com.ibm.mashups.builder.createSpace",
/**
* Description: System iWidget broadcasts EDIT_SPACE iEvent to initiate Edit Space widget, which allows to edit existing space.
* Value: "com.ibm.mashups.builder.editSpace"
* Payload: id of space to be edited. Must not be null
.
* Payload type: text
* @type String
*/
EDIT_SPACE:"com.ibm.mashups.builder.editSpace",
/**
* Description: System iWidget broadcasts COPY_SPACE iEvent to initiate Copy Space widget, which allows to clone given space.
* Value: "com.ibm.mashups.builder.copySpace"
* Payload: spaceId
is the id of space to be cloned, and copySpaceInSpaceManager
should be set as true
if COPY_SPACE is broadcast inside Space Manager, otherwise false
. Must not be null
.
* {
* spaceId: id of the space,
* copySpaceInSpaceManager: a boolean value to indicate whether the copy space action is launched from space manager
* }
* Payload type: json
* @type String
*/
COPY_SPACE:"com.ibm.mashups.builder.copySpace",
/**
* Description: System iWidget broadcasts CHANGE_SPACE_OWNER iEvent to initiate Change Space Owner widget, which allows to change space owner. After space owner is changed, two dojo events will be published:
* dojo.publish("com.ibm.mm.builder.spaceEditorWidget.OwnerName", [username]);
* dojo.publish("com.ibm.mm.builder.spaceEditorWidget.OwnerId", [userid]);
* These two dojo events should be subscribed to get new owner id and owner name.
* Value: "com.ibm.mashups.builder.changeSpaceOwner"
* Payload: original space owner id, Must not be null
.
* Payload type: text
* @type String
*/
CHANGE_SPACE_OWNER:"com.ibm.mashups.builder.changeSpaceOwner",
/**
* Description: System iWidget broadcasts MANAGE_SPACES iEvent to initiate Space Manager widget, which allows to manage spaces.
* Value: "com.ibm.mashups.builder.manageSpaces"
* Payload: N/A
* @type String
*/
MANAGE_SPACES:"com.ibm.mashups.builder.manageSpaces"
});
com.ibm.mashups.builder.iEvents = new com.ibm.mashups.builder.IEvent();
}
if(!dojo._hasResource["com.ibm.mashups.liveTracing"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mashups.liveTracing"] = true;
dojo.provide("com.ibm.mashups.liveTracing");
(function(){
var mmltrace = com.ibm.mashups.liveTracing = {
debugCookieName: "digest.ignore.debug.mashups",
_arrayToString: function(arr) {
var str = "";
while(arr.length > 0) {
str += arr.shift();
if(arr.length > 0) {
str += "|";
}
}
return str;
},
enableDebug: function(traceSetting) {
var stringValue = dojo.cookie(mmltrace.debugCookieName);
var value = {};
if (stringValue) value = dojo.fromJson(stringValue);
value.enableDebug = true;
if(traceSetting) {
if(dojo.isString(traceSetting)) {
var parts = traceSetting.split(",");
traceSetting = this._arrayToString(parts);
}
else if(dojo.isArray(traceSetting)) {
traceSetting = this._arrayToString(traceSetting);
}
value.traceString = traceSetting;
}
stringValue = dojo.toJson(value);
dojo.cookie(mmltrace.debugCookieName, stringValue, {path: "/"});
console.info("You just enabled debugging and uncompressed javascript versions. Please refresh to activate.");
},
disableDebug: function() {
var stringValue = dojo.cookie(mmltrace.debugCookieName);
var value = {};
if (stringValue) value = dojo.fromJson(stringValue);
if (value.enableDebug) {
delete value.enableDebug;
}
if (value.traceString) {
delete value.traceString;
}
stringValue = dojo.toJson(value);
dojo.cookie(mmltrace.debugCookieName, stringValue, {path: "/"});
console.info("You just disabled debugging and uncompressed javascript versions. Please refresh to activate.");
},
clear: function() {
dojo.cookie(mmltrace.debugCookieName, null, {path: "/", expires: -1});
},
showEffectiveTracing: function() {
// what is actually being used
alert(ibmConfig.traceConfig);
},
showConfiguredTracing: function() {
// what is set in the cookie
alert(dojo.cookie(mmltrace.debugCookieName));
}
}
})();
}
if(!dojo._hasResource["com.ibm.mm.builder.DeferredImpl"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.DeferredImpl"] = true;
dojo.provide("com.ibm.mm.builder.DeferredImpl");
// base
dojo.declare("com.ibm.mm.builder.DeferredImpl", [com.ibm.mashups.enabler.Deferred], {
// If you mixin the DeferredImpl into your class, you may use a different
// set of parameters for the constructor, but then you do not have access
// to the parameters 'context', 'startfn', as well as 'params' and thus,
// you need to overwrite the start function, which accesses those parameters.
// If you want to use the start function defined in DeferredImpl, you need
// to make sure, the parameters 'context', 'startfn', as well as 'params'
// are set in the constructor of DeferredImpl.
constructor: function(context, startfn, params){
// context for start function
this.context = context;
// start function
this.startfn = startfn;
// parameters to pass to start function
this.params = params;
},
setFinishedCallback: function(callback, parameters){
this.finishedCallback2 = callback;
this.finishedCallbackParameters2 = parameters;
return this;
},
start: function(sync){
var mode = (sync || typeof(sync) == 'undefined') ? true : false;
return dojo.hitch(this.context, this.startfn)(this, mode, this.params);
},
getFinishedCallback: function(){
return this.finishedCallback2;
},
getFinishedCallbackParameters: function(){
return this.finishedCallbackParameters2;
}
});
}
if(!dojo._hasResource["com.ibm.mashups.builder.model.Page"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mashups.builder.model.Page"] = true;
dojo.provide("com.ibm.mashups.builder.model.Page" );
/**
* This interface defines builder runtime page operations.
* Usage: var page = com.ibm.mashups.builder.model.Factory.getRuntimeModel().getCurrentPage();
* @ibm-module Builder
*/
dojo.declare( "com.ibm.mashups.builder.model.Page", null, {
/**
* Returns builder runtime page data changed or not.
* @ibm-api
* @type Boolean
* @return {Boolean} The boolean value of whether page data is dirty, if dirty, return true, if not dirty, return false. never null
*/
isDirty:function(){
return true;
},
/**
* Set builder runtime page data status.
* @ibm-spi
* @param {Boolean} _dirty boolean value to indicate whether page data is dirty or not, must not be null
.
* @type void
*/
setDirty:function(_dirty){
},
/**
* Returns builder runtime page id.
* @ibm-api
* @type String
* @return {String} runtime page id, never null
*/
getID:function(){
return "";
},
/**
* Set builder runtime page id
* @ibm-spi
* @param {String} _pid the page id to set, must not be null
.
* @type void
*/
setID:function(_pid){
},
/**
* Returns builder runtime page mode.
* @ibm-api
* @type String
* @return {String} runtime page mode, never null
*/
getPageMode:function(){
return "";
},
/**
* Set builder runtime page mode
* @ibm-spi
* @param {String} _pageMode the page mode to set, must not be null
.
* @type void
*/
setPageMode:function(_pageMode){
},
/**
* Set auto-wiring enablement status of current page
* @ibm-api
* @param {Boolean} _isEnabled true/false
* @type void
*/
setAutoWiringEnablement:function(_isEnabled) {
},
/**
* Return whether auto-wiring is enabled for this page
* @ibm-api
* @deprecated use isAutoWiringEnabled() instead.
* @type Boolean
* @return return true/false, never null
*/
getAutoWiringEnablement:function() {
},
/**
* Return whether auto-wiring is enabled for this page
* @ibm-api
* @type Boolean
* @return return true/false, never null
*/
isAutoWiringEnabled:function(){
}
});
}
if(!dojo._hasResource["com.ibm.mashups.builder.model.Theme"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mashups.builder.model.Theme"] = true;
dojo.provide("com.ibm.mashups.builder.model.Theme" );
/**
* This interface defines builder runtime theme operation.
* Usage: var theme = com.ibm.mashups.builder.model.Factory.getRuntimeModel().getCurrentTheme();
* @ibm-module Builder
*/
dojo.declare( "com.ibm.mashups.builder.model.Theme", null, {
/**
* Returns builder runtime theme id
* @ibm-api
* @type String
* @return runtime theme id, never null
*/
getID:function(){
return "";
},
/**
* Set builder runtime theme id
* @param {String} _themeId theme id to set, must not be null
.
* @ibm-spi
* @type void
*/
setID:function(_themeId){
},
/**
* Register the layout widget id in theme model
* @param {String} _layoutId layout widget id in theme.html
* @ibm-spi
* @deprecated not used
* @type void
*/
registerLayout:function(_layoutId){
},
/**
* Return array which contains all layout widgets' id in current theme.
* @ibm-api
* @type String[]
* @deprecated Use enabler layout model API to get the component container instead, some sample code:
* var navigationModel = com.ibm.mashups.enabler.navigation.Factory.getNavigationModel();
* var layoutModel = navigationModel.getLayoutModel(pageId);
* var root = layoutModel.getRoot().start();
* var children = layoutModel.getChildren(root);
* while(children.hasNext()) {
* var child = children.next();
* // check the child.getLayoutNodeType() result and see whether it is a LayoutContainer
* }
* @return null
*/
getLayouts:function(){
}
});
}
if(!dojo._hasResource["com.ibm.mashups.builder.model.ContextMenuItem"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mashups.builder.model.ContextMenuItem"] = true;
dojo.provide("com.ibm.mashups.builder.model.ContextMenuItem");
/**
* Defines the format for context menu items using simple object notation. Items in this format
* can be simple objects and are not restricted to instances of an interface, but must support
* these properties.
* {
* isSeparator
: true/false, whether this item is a menu separator,
* iconClass
: icon class name for menu item,
* description
: item description,
* title
: menu item title,
* localized
: com.ibm.mashups.enabler.Localized,contains titles and descriptions for all supported locales,
* enabled
: true/false, whether this item is enabled,
* id
: the id if listed, the id if listed, otherwise, null,
* ordinal
: this could be null, which means it wasn't provided in the data, so should add it to the end of the context menu,
* actionCallBackFunction
: actionFnDefinedByMenuItem(){}
* By default the actionCallBackFunction is a zero-argument function, however, extensions may define
* other semantics that are used by context menu consumers that pass arguments.
* }
*
* Any other properties may be added as extensions to be used by a context menu consumer.
* It should not be expected that changes to any properties on an underlying context menu item that is returned by a context menu loader
* will be surfaced in the user interface without first calling the context menu loader's onChange
function.
* @ibm-api
* @ibm-spi
* @ibm-module Builder
*/
dojo.declare("com.ibm.mashups.builder.model.ContextMenuItem", null, {
/**
* Indicates whether or not this item is actually a separator between other items. Typically,
* separator items do not contain many, if any, other properties at all, although extensions
* may define other semantics.
* @type Boolean
*/
isSeparator: false,
/**
* A CSS class specified for this item.
* @type String
*/
iconClass: "",
/**
* The description of the context menu item. Defaults to the localized object's
* description if this is empty or null
.
* @type String
*/
description: "",
/**
* The title of the context menu item. Defaults to the localized object's
* title if this is empty or null
.
* @type String
*/
title: "",
/**
* Localized object that provides access to a localized title and description for this item.
* @type com.ibm.mashups.enabler.Localized
*/
localized: null,
/**
* Indicates whether or not this item is enabled.
* @type Boolean
*/
enabled: true,
/**
* The String identifier of the context menu item.
* @type String
*/
id: "",
/**
* Specifies the relative order in which this item appears in its context menu loader.
* @type Number
*/
ordinal: 0,
/**
* The function to execute for this context menu item. Execution time is dependent on the
* context menu consumer and is not defined by the API or necessarily limited to selecting
* or clicking an element in a user interface.
* By default the actionCallBackFunction is a zero-argument function, however, extensions may define
* other semantics that are used by context menu consumers that pass arguments.
* @type Function
*/
actionCallBackFunction: null,
actionCallBackFunctionName: null
});
}
if(!dojo._hasResource["com.ibm.mashups.builder.model.ContextMenuLoader"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mashups.builder.model.ContextMenuLoader"] = true;
dojo.provide("com.ibm.mashups.builder.model.ContextMenuLoader");
/**
* This object is used to retrieve context menu items by returning a {@link com.ibm.mashups.enabler.Deferred Deferred} object
* that returns those items either directly in synchronous mode or via the callback
* in asynchronous mode. The items returned by the {@link com.ibm.mashups.enabler.Deferred Deferred} must be an array of items
* that follow the {@link com.ibm.mashups.builder.model.ContextMenuItem ContextMenuItem} format.
* @ibm-spi
* @ibm-module Builder
*/
dojo.declare("com.ibm.mashups.builder.model.ContextMenuLoader", null, {
/**
* Returns a {@link com.ibm.mashups.enabler.Deferred Deferred} object that will pass an array of the items loaded by this object
* as the first argument to the callback.
* @ibm-spi
* @param {String} contextMenuId this is id of the context menu. Examples: ContextMenu.page, ContextMenu.space, ContextMenu.toolbox, ContextMenu.modeSelector ContextMenu.widgetSkin, or any additional extension. Must not be null
.
* @param {String} targetResourceId this is the ID of the resource to associate the decision for this menu choice with. Must not be null
.
* @param {String} targetResourceType this is the resource type of the resource to associate the decision for this menu choice with. May be null
.
* Possible values for this could be "com.ibm.mashups.enabler.space.SpaceNode", "com.ibm.mashups.iwidget.widget.IWidgetDefinition", "com.ibm.mashups.enabler.navigation.NavigationNode",
* or any other type used by an extension.
* @param {Object} someObject this allows an arbitrary object to be passed into the context menu loader in case it needs additional data for making the decisions.
* @return {com.ibm.mashups.enabler.Deferred} Deferred object that loads the data and fires the callback
* with an array of items conforming to the {@link com.ibm.mashups.builder.model.ContextMenuItem ContextMenuItem}
* format that are retrieved by this loader; never null
.
*/
getItems: function(/*String*/ contextMenuId, /*String*/ targetResourceId, /*String*/ targetResourceType, /*Object*/ someObject){
},
/**
* Event that notifies the system that this loader's contents have changed and may be reloaded
* to avoid stale data. Callers may call this function on a loader that has been registered
* to a particular context menu id or used as a contribution to an existing context menu. The
* system listens to this event in order to notify any registered listeners on a context menu
* of the event.
* @ibm-spi
* @type void
*/
onChange: function() {
}
});
}
if(!dojo._hasResource["com.ibm.mashups.builder.model.ContextMenu"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mashups.builder.model.ContextMenu"] = true;
dojo.provide("com.ibm.mashups.builder.model.ContextMenu" );
//
/**
* This interface defines Context Menu operations.
* @ibm-module Builder
*/
dojo.declare( "com.ibm.mashups.builder.model.ContextMenu", null, {
/**
* Returns a array of JSON objects for a given collection of menu choices for the selected context menu.
* Each object in the array follows the {@link com.ibm.mashups.builder.model.ContextMenuItem ContextMenuItem}
* object format plus any custom extension properties that a context menu may define.
* @ibm-api
* @param {String} contextMenuId this is id of the context menu. Examples: ContextMenu.page, ContextMenu.space, ContextMenu.toolbox, ContextMenu.modeSelector ContextMenu.widgetSkin, or any additional extension. Must not be null
.
* @param {String} targetResourceId this is the ID of the resource to associate the decision for this menu choice with. This will be passed into the respective contextmenu functions and must not be null
.
* @param {String} targetResourceType this is the resource type of the resource to associate the decision for this menu choice with. This will be passed into the respective contextmenu functions. May be null
.
* Possible values for this could be "com.ibm.mashups.enabler.space.SpaceNode", "com.ibm.mashups.iwidget.widget.IWidgetDefinition", "com.ibm.mashups.enabler.navigation.NavigationNode",
* or any other type used by an extension.
* @param {Object} someObject this allows an arbitrary object to be passed into the context menu items' functions in case they need additional data for making the decisions.
* @type JSON[]
* @return {JSON[]} A JSON object array of menu choices; may be an empty array if no choices exist for that context menu, but never null
.
*/
getContextMenu:function(/*String*/ contextMenuId, /*String*/ targetResourceId, /*String*/ targetResourceType, /*Object*/ someObject){
return null;
},
/**
* Returns a deferred object that loads an array of JSON objects for a given collection of menu choices for the selected context menu. Its callback will
* receive this array as its first argument in asynchronous mode, and the deferred's start
function will return the array directly in synchronous mode.
* Each object in the array follows the {@link com.ibm.mashups.builder.model.ContextMenuItem ContextMenuItem}
* object format plus any custom extension properties that a context menu may define.
* @ibm-api
* @param {String} contextMenuId this is id of the context menu. Examples: ContextMenu.page, ContextMenu.space, ContextMenu.toolbox, ContextMenu.modeSelector ContextMenu.widgetSkin, or any additional extension. Must not be null
.
* @param {String} targetResourceId this is the ID of the resource to associate the decision for this menu choice with. This will be passed into the respective contextmenu functions and must not be null
.
* @param {String} targetResourceType this is the resource type of the resource to associate the decision for this menu choice with. This will be passed into the respective contextmenu functions. May be null
.
* Possible values for this could be "com.ibm.mashups.enabler.space.SpaceNode", "com.ibm.mashups.iwidget.widget.IWidgetDefinition", "com.ibm.mashups.enabler.navigation.NavigationNode",
* or any other type used by an extension.
* @param {Object} someObject this allows an arbitrary object to be passed into the context menu items' functions in case they need additional data for making the decisions.
* @type {com.ibm.mashups.enabler.Deferred}
* @return {com.ibm.mashups.enabler.Deferred} A deferred object used to start this operation,
* never null
. The return value when executed through the
* deferred object is A JSON object array of menu choices; may be an empty array if no choices exist for that context menu, but never null
.
* The deferred supports synchronous and asynchronous operations.
*/
getContextMenuDeferred:function(/*String*/ contextMenuId, /*String*/ targetResourceId, /*String*/ targetResourceType, /*Object*/ someObject){
return null;
},
/**
* Register a context menu loader at a particular id that will be used to load items when requested
* by the getContextMenu
or getContextMenuDeferred
functions using the registered id. A default loader
* will be used if nothing has been registered with a particular contextMenuId when requested.
* This function replaces any existing context menu loader that was registered to the same contextMenuId.
* Registering a null
context menu loader will effectively remove any existing loader that is
* already registered to the same contextMenuId.
* @ibm-spi
* @param {String} contextMenuId id of menu to retrieve contributions from. Must not be null
.
* @param {com.ibm.mashups.builder.model.ContextMenuLoader} contextMenuLoader contextMenuLoader to be register to a particular id. May be null
.
* @return {Boolean} boolean indicating if the registration was successful
*/
registerContextMenu: function(/*String*/ contextMenuId, /*com.ibm.mashups.builder.model.ContextMenuLoader*/ contextMenuLoader) {
},
/**
* Adds a contribution to a context menu with the given contextMenuId. The contribution defines a
* set of menu items to be inserted in a group into the given context menu. When the context menu is
* requested, its base contents as well as any contributions that have been added to it will be merged
* such that contribution items are kept together and are ordered relative to their contribution, then
* merged together into a flat list of items.
* @ibm-spi
* @param {String} contextMenuId id of menu to contribute to. Must not be null
.
* @param {com.ibm.mashups.builder.model.ContextMenuLoader} contributionLoader contribution to add to the menu.
* @param {Number} ordinal Optional value used for relative ordering with the base items and other contributions.
* @return {String} the id of the contribution that was added, or null
if the contribution was null
.
* This id may be used to remove the contribution later via the removeContribution function.
*/
addContribution: function(/*String*/ contextMenuId, /*com.ibm.mashups.builder.model.ContextMenuLoader*/ contributionLoader, /*Number*/ ordinal) {
},
/**
* Removes a contribution from a context menu with the given contextMenuId by the id that uniquely
* identifies that contribution within the particular context menu. The id is what the system returns
* when the contribution is added via the addContribution function.
* @ibm-spi
* @param {String} contextMenuId id of menu remove the contribution from. Must not be null
.
* @param {String} id id of contribution to remove from the menu.
* @return {com.ibm.mashups.builder.model.ContextMenuLoader} the contribution that was removed, or null
if no match was found
*/
removeContribution: function(/*String*/ contextMenuId, /*String*/ id) {
},
/**
* Gets an array of all the contributions that have been added to a context menu with the given contextMenuId.
* @ibm-spi
* @param {String} contextMenuId id of menu to retrieve contributions from. Must not be null
.
* @return {com.ibm.mashups.builder.model.ContextMenuLoader[]} an array of contributions; may be an empty array, but is never null
.
*/
getContributions: function(/*String*/ contextMenuId) {
},
/**
* Register a listener function which will be fired whenever a particular context menu identified
* by the contextMenuId is updated. This may occur any of the following circumstances:
* 1) A contribution is added
* 2) A contribution is removed
* 3) A contribution ContextMenuLoader is updated via its onChange event
* 4) The base context menu ContextMenuLoader is updated via its onChange event
*
* Listeners may choose to respond to this event however desired, such as by requesting the context menu again
* in order to receive an updated set of items.
* @ibm-spi
* @param {String} contextMenuId id of the context menu to which to register the listener. Must not be null
.
* @param {Object} scope scope in which the function will be invoked when the event is fired. May be null
to default
* to global scope.
* @param {Function} func function to be called whenever the context menu is changed. May be the function reference itself,
* or the String name of the function on the scope object. Must not be null
.
* The function signature is: function(contextMenuId){}
* String contextMenuId
id of the context menu that was updated
* @return {Object} a connection handle that can be used to unregister the listener.
*/
registerListener: function(/*String*/contextMenuId, /*Object*/scope, /*Function*/func) {
},
/**
* Register a listener function which will be fired whenever a particular context menu identified
* by the contextMenuId is updated. This may occur any of the following circumstances:
* 1) A contribution is added
* 2) A contribution is removed
* 3) A contribution ContextMenuLoader is updated via its onChange event
* 4) The base context menu ContextMenuLoader is updated via its onChange event
*
* Listeners can choose to respond to this event however desired, such as by requesting the context menu again
* in order to receive an updated set of items.
* @ibm-spi
* @param {String} contextMenuId id of the context menu to which to register the listener. Must not be null
.
* @param {Function} func function to be called whenever the context menu is changed. May be the function reference itself,
* or the String name of the function in the global scope. Must not be null
.
* The function signature is: function(contextMenuId){}
* String contextMenuId
id of the context menu that was updated
* @return {Object} a connection handle that can be used to unregister the listener.
*/
registerListener: function(/*String*/contextMenuId, /*Function*/func) { // JSLINT-IGNORE
},
/**
* Unregisters a previously registered listener to a context menu's onChange event.
* @ibm-spi
* @param {Object} handle connection handle that was returned by a call to registerListener
. Must not be null
.
* @type void
*/
unregisterListener: function(/*Object*/ handle) {
}
});
//
}
if(!dojo._hasResource["com.ibm.mashups.builder.model.Runtimemodel"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mashups.builder.model.Runtimemodel"] = true;
dojo.provide("com.ibm.mashups.builder.model.Runtimemodel");
/**
* Interface representing builder runtime model
* Usage: var runtimeModel = com.ibm.mashups.builder.model.Factory.getRuntimeModel();
* @ibm-api
* @ibm-module Builder
*/
dojo.declare( "com.ibm.mashups.builder.model.RuntimeModel", null, {
/**
* @deprecated
* Use com.ibm.mashups.builder.model.Factory.getContextMenuModel instead
* Returns the builder context menu model
* @type com.ibm.mashups.builder.model.ContextMenu
* @return {com.ibm.mashups.builder.model.ContextMenu}, never null
*/
getCurrentContextMenu: function() {
return new com.ibm.mashups.builder.model.ContextMenu();
},
/**
* Returns the builder page model
* @type com.ibm.mashups.builder.model.Page
* @return {com.ibm.mashups.builder.model.Page}, never null
*/
getCurrentPage: function() {
return new com.ibm.mashups.builder.model.Page();
},
/**
* Returns the builder theme model
* @type com.ibm.mashups.builder.model.Theme
* @return {com.ibm.mashups.builder.model.Theme}, never null
*/
getCurrentTheme: function() {
return new com.ibm.mashups.builder.model.Theme();
}
});
}
if(!dojo._hasResource["com.ibm.mashups.builder.model.Factory"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mashups.builder.model.Factory"] = true;
dojo.provide("com.ibm.mashups.builder.model.Factory");
/**
* Interface for an builder runtime model factory.
* @ibm-api
* @ibm-module Builder
*/
dojo.declare( "com.ibm.mashups.builder.model.Factory", null, {
/**
* Returns builder runtime model
* @type com.ibm.mashups.builder.model.RuntimeModel
* @return runtime model, never null
*/
getRuntimeModel: function() {
return new com.ibm.mashups.builder.model.RuntimeModel();
},
/**
* Returns the builder context menu model
* @type com.ibm.mashups.builder.model.ContextMenu
* @return context menu model, never null
*/
getContextMenuModel: function(){
return new com.ibm.mashups.builder.model.ContextMenu();
}
});
}
if(!dojo._hasResource["com.ibm.mashups.builder.Model"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mashups.builder.Model"] = true;
dojo.provide("com.ibm.mashups.builder.Model");
}
if(!dojo._hasResource["com.ibm.mm.builder.model.Page"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.model.Page"] = true;
dojo.provide("com.ibm.mm.builder.model.Page");
/**
* Implementation of builder runtime page model.
*/
dojo.declare( "com.ibm.mm.builder.model.PageImpl", [com.ibm.mashups.builder.model.Page], {
dirty:false,
currentPageId:null,
currentPageMode:null,
_isAutoWiringEnabled: builderConfig.pageAutoWiringDefault,
isDirty:function(){
return this.dirty;
},
setDirty:function(_dirty){
this.dirty = _dirty;
dojo.publish(com.ibm.mm.builder.eventTopics.Save_Icon_Change, [_dirty]);
},
getID:function(){
return this.currentPageId;
},
setID:function(_pid){
this.currentPageId = _pid;
},
getPageMode:function(){
return this.currentPageMode;
},
setPageMode:function(_pageMode){
this.currentPageMode = _pageMode;
},
setAutoWiringEnablement:function(_isEnabled) {
//eval the input param in case it's a "string" (IE)
if(_isEnabled !== null && (_isEnabled == "true" || _isEnabled == "false" || _isEnabled === true || _isEnabled === false)){
this._isAutoWiringEnabled = eval(_isEnabled); // JSLINT-IGNORE:
}else{
this._isAutoWiringEnabled = builderConfig.pageAutoWiringDefault;
}
},
getAutoWiringEnablement:function() {
// return this.isAutoWiringEnabled;
var currentPage = com.ibm.mm.builder.utils.pageUtil.getCurrentPageNode();
var pageContent = currentPage.getContent().start();
var enable = pageContent.getMetaData(com.ibm.mm.builder.constant.autoWiringEnabled);
if(enable===null) { // metadata not set, so we choose the default settings
enable = builderConfig.pageAutoWiringDefault;
}
return (enable===true || enable==="true");
},
isAutoWiringEnabled:function(){ // JSLINT-IGNORE:
// return this.isAutoWiringEnabled;
return this.getAutoWiringEnablement();
}
});
}
if(!dojo._hasResource["com.ibm.mm.builder.model.Theme"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.model.Theme"] = true;
dojo.provide("com.ibm.mm.builder.model.Theme");
/**
* Implementation of builder runtime page model.
*/
dojo.declare( "com.ibm.mm.builder.model.ThemeImpl", [com.ibm.mashups.builder.model.Theme], {
currentThemeId:null,
layouts: null,
constructor: function(){
this.layouts = [];
},
_hasRegister:function(_layoutId) {
for(var i = 0; i < this.layouts.length; i++){
if(_layoutId == this.layouts[i]){
return true;
}
}
return false;
},
registerLayout:function(_layoutId) {
// deprecated API
/*
if (!this._hasRegister(_layoutId)) {
this.layouts.push(_layoutId);
}
*/
},
getLayouts:function(){
// deprecated API
return this.layouts;
},
getID:function(){
return this.currentThemeId;
},
setID:function(_themeId){
this.currentThemeId = _themeId;
}
});
}
if(!dojo._hasResource["com.ibm.mm.builder.DelegatedDeferredImpl"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.DelegatedDeferredImpl"] = true;
/**
* Provides enhanced Deferred implementations for dealing with situations where data
* is loaded from one place by multiple consumers. Each consumer gets its own Deferred
* implementation, but the data loading can be performed by a single Deferred under the
* covers.
* @author Ben
*/
dojo.provide("com.ibm.mm.builder.DelegatedDeferredImpl");
/**
* A DelegatorDeferredImpl is a deferred that allows DelegatedDeferredImpls to piggy back on top of it
* so that its loading operation will fire the callbacks of all DelegatedDeferredImpls that are attached
* to it. This provides a mechanism for a single pipe to load data and then multiplex the output to
* multiple other outputs.
*/
dojo.declare("com.ibm.mm.builder.DelegatorDeferredImpl", com.ibm.mm.builder.DeferredImpl, {
constructor: function() {
this._delegates = [];
this._finishedData = [];
var me = this;
this.finishedCallback2 = function(result, status, params){
if(!me._restarted || !me._finished) {
// Only call the callbacks if we were never finished before, or if we've been finished
// already without having been restarted (like if a particular caller calls the callback
// multiple times at the end of an async operation; unlikely but possible)
me._finishedData = [result, status, params];
me._finished = true;
while(me._delegates.length > 0) {
me._fireDelegate(me._delegates.shift());
}
return me._finish.apply(me, arguments);
}
};
},
_finish: function(result, status, params) {
if(this._hiddenCallback) {
return this._hiddenCallback.apply(this, arguments);
}
},
setFinishedCallback: function(callback, parameters){
this._hiddenCallback = callback;
this.finishedCallbackParameters2 = parameters;
return this;
},
/**
* Important semantics to note here... cannot be started twice
*/
start: function(sync){
if(this._started) {
return;
}
this._started = true;
return this.inherited(arguments);
},
/**
* This allows a caller to "restart" this DelegatorDeferredImpl in sync mode if it is currently processing
* in async mode and hasn't finished yet.
*/
_restart: function(sync) {
if(sync && this._started && !this._finished) {
// we started in async mode but need to restart in sync mode
this._restarted = true;
this._started = false;
return this.start(true);
}
},
_fireDelegate: function(dfd) {
var data = this._finishedData,
cbk = dfd.getFinishedCallback(),
parms = dfd.getFinishedCallbackParameters();
if(cbk) {
// Do NOT catch errors so that they propagate to the top
// Side effect is the potential to stop calling callbacks if an error occurs in one of them
return cbk(data[0], data[1], parms);
}
},
/**
* Adds a DelegatedDeferredImpl to this DelegatorDeferredImpl's delegate chain
*/
addDelegate: function(dfd) {
this._delegates.push(dfd);
dfd.delegator = this;
if(this._finished) {
this._fireDelegate(this._delegates.shift());
}
return this;
}
});
/**
* A DelegatedDeferredImpl is a deferred which actually piggy backs on top of an existing DelegatorDeferredImpl.
* These are created without a start function and are then added to an existing DelegatorDeferredImpl via its
* addDelegate API. When the DelegatorDeferredImpl finishes, this Deferred is fired as well with the same results
* so that multiple Deferreds can be passed to consuming code while relying on a single pipe for the actual
* data.
*/
dojo.declare("com.ibm.mm.builder.DelegatedDeferredImpl", com.ibm.mm.builder.DeferredImpl, {
delegator: null,
setFinishedCallback: function(callback, parameters){
var me = this;
this.finishedCallback2 = function(result, status, params){
if(me._started) {
me._result = result; // store this for sync mode
// Only call our callback if we've been started already
return callback.apply(this, arguments);
}
};
this.finishedCallbackParameters2 = parameters;
return this;
},
/**
* Important note on side effects here... starting a DelegatedDeferredImpl will implicitly start the underlying
* delegator if it hasn't been started yet.
*/
start: function(sync){
if(!this.delegator) {
// if we have no delegator, just escape immediately
return;
}
this._started = true;
var mode = (sync || typeof(sync) === "undefined") ? true : false;
if(this.delegator._finished && this.finishedCallback2) {
// the delegator finished already, add us back to it to be automatically fired
this.delegator.addDelegate(this);
return this._result; // for sync support
}
else if(mode && this.delegator._started && !this.delegator._finished) {
// the delegator was started in async mode, hasn't finished, and we're starting in sync mode
return this.delegator._restart(mode);
}
else if(!this.delegator._started) {
// the delegator hasn't started yet
return this.delegator.start(mode);
}
}
});
}
if(!dojo._hasResource["com.ibm.mm.builder.model.contextMenu.ConfigServiceXmlMenuLoader"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.model.contextMenu.ConfigServiceXmlMenuLoader"] = true;
dojo.provide("com.ibm.mm.builder.model.contextMenu.ConfigServiceXmlMenuLoader");
dojo.require("dojox.xml.parser");
dojo.declare("com.ibm.mm.builder.model.contextMenu.ConfigServiceXmlLocalized", com.ibm.mashups.enabler.Localized, {
ns: {
"cm": "http://www.ibm.com/xmlns/prod/sw/context-menu/1.0"
},
constructor: function(){
this._data = [];
},
/**
* Returns a list model containing the locales that are supported by this
* object. The presence of a locale in this list does not mean that a title
* and description is available, but rather that either one or both are available in that locale.
* @return {Array} a list of locales defined for this object, returns an
* empty array if no locales are supported. Can never be null
.
*/
getLocales: function(){
var ret = [];
for (var i = 0; i < this._data.length; ++i) {
ret.push(this._data[i].locale);
}
return ret;
},
/**
* Returns the title of this object in the given locale.
* @param {String} locale the locale for which to retrieve the title,
* must not be null
.
* @return {String} the title of this node in the given locale. If a title is not
* available in the given locale, this method will return null
.
* It is up to the invoker of the method to implement an appropriate fallback mechanism.
*/
getTitle: function(locale){
var def = 0;
for (var i = 0; i < this._data.length; ++i) {
//if (this._data[i].locale.toLowerCase() == locale.toLowerCase()) {
if (this._data[i].locale.toLowerCase().replace("_", "-") == locale.toLowerCase()) {
return this._data[i].title;
}
else {
if (!def && this._data[i].locale.toLowerCase().replace("_", "-") == ibmConfig["default.locale"]) {
def = i;
}
}
}
return (this._data[def] && this._data[def].title) ? this._data[def].title : null;
},
/**
* Returns the description of this object in the given locale.
* @param {String} locale the locale for which to retrieve the
* description, must not be null
.
* @return {String} the description of this node in the given locale. If a
* description is not available in the given locale, this method
* will return null
. It is up to the invoker of the
* method to implement an appropriate fallback mechanism.
*/
getDescription: function(locale){
var def = 0;
for (var i = 0; i < this._data.length; ++i) {
//if (this._data[i].locale.toLowerCase() == locale.toLowerCase()) {
if (this._data[i].locale.toLowerCase().replace("_", "-") == locale.toLowerCase()) {
return this._data[i].description;
}
else {
if (!def && this._data[i].locale.toLowerCase().replace("_", "-") == ibmConfig["default.locale"]) {
def = i;
}
}
}
return (this._data[def] && this._data[def].description) ? this._data[def].description : null;
},
setTitles: function(_node){
var XPath = com.ibm.mashups.enabler.xml.XPath;
var titles = XPath.evaluateXPath("cm:title/cm:nls-string", _node, this.ns);
var i = titles.length;
if (i > 0) {
while (--i >= 0) {
var lang = com.ibm.mm.enabler.utils.Dom.getAttributeWithNS(titles[i], "xml:lang", "lang", "http://www.w3.org/XML/1998/namespace");
if (lang !== null) {
var title = titles[i].firstChild.nodeValue;
this._data.push({
"locale": lang,
"title": title,
"description": null
});
}
}
}
else { // Try to use the content of element "title" if there is no nls string
titles = XPath.evaluateXPath("cm:title", _node, this.ns);
if (titles.length > 0) {
this._data.push({
"locale": "en",
"title": titles[0].firstChild.nodeValue,
"description": null
});
}
}
},
/**
* Sets the title for the given locale.
* @param {String} title title to set; must not be null
* @param {String} locale locale to set the title for; must not be null
* @return null
*/
setTitle: function(title, locale){
locale.replace(/-/g, "_");
for (var i = 0; i < this._data.length; ++i) {
if (this._data[i].locale == locale) {
this._data[i].title = title;
return null;
}
}
var anItem = {
"locale": locale,
"title": title,
"description": null
};
this._data.push(anItem);
return null;
},
/**
* Sets the description for the given locale.
* @param {String} desc description to set; must not be null
* @param {String} locale locale to set the description for; must not be null
* @return null
*/
setDescription: function(desc, locale){
for (var i = 0; i < this._data.length; ++i) {
if (this._data[i].locale == locale) {
this._data[i].description = desc;
return null;
}
}
var anItem = {
"locale": locale,
"title": null,
"description": desc
};
this._data.push(anItem);
return null;
}
});
dojo.declare("com.ibm.mm.builder.model.contextMenu.ConfigServiceXmlMenuLoader", com.ibm.mashups.builder.model.ContextMenuLoader, {
CONTEXT_MENU_PROVIDER: ibmConfig["ConfigProvider.ContextMenu_Provider"] ? ibmConfig["ConfigProvider.ContextMenu_Provider"] : "ContextMenu_Provider",
CONFIG_SERVICE_PROPERTY: "contextmenu.xml",
ns: {
"cm": "http://www.ibm.com/xmlns/prod/sw/context-menu/1.0"
},
constructor: function(){
this.LOGGER = com.ibm.mashups.enabler.logging.Logger.getLogger(this.declaredClass);
this.xmlData = null;
},
getItems: function(/*String*/contextMenuId, /*String*/ targetResourceId, /*String*/ targetResourceType, /*Object*/ someObject){
var mname = "getItems", lgr = this.LOGGER;
lgr.entering(mname, arguments);
dfd = new com.ibm.mm.builder.DeferredImpl(this, function(deferred, sync, params){
var callBack = deferred.getFinishedCallback(), callBackParams = deferred.getFinishedCallbackParameters(), res;
if (!this.xmlData) {
var dfd = this.getData().setFinishedCallback(dojo.hitch(this, function(xmlData, status, params){
res = xmlData; // may be an Error
if (status == 200) {
this.xmlData = xmlData;
res = this._initMenuItems(contextMenuId, targetResourceId, targetResourceType, someObject);
}
if (callBack) {
callBack(res, status, callBackParams); // callback for success or error
}
}));
dfd.start(sync);
}
else {
res = this._initMenuItems(contextMenuId, targetResourceId, targetResourceType, someObject);
if (callBack) {
callBack(res, 200, callBackParams);
}
}
return res;
});
lgr.exiting(mname, arguments);
return dfd;
},
/**
* Gets context menu items from the ConfigService using the ContextMenu_Provider.
* @returns {com.ibm.mashups.enabler.Deferred} deferred object that loads the XML data from the ConfigService
*/
getData: function(){
// multiple calls to this before a previous call finishes may result in multiple requests for the same data.... depending on
// the implementation of the ConfigService Deferred
var mname = "getData", lgr = this.LOGGER;
if (!this._baseLoader) {
this._baseLoader = new com.ibm.mm.builder.DelegatorDeferredImpl(this, function(deferred, sync, params){
var callBack = deferred.getFinishedCallback(), callBackParams = deferred.getFinishedCallbackParameters();
lgr.trace(mname, "Start loading remote data");
if (this.xmlData) {
lgr.trace(mname, "Data already loaded ${0}", [this.xmlData]);
if (callBack) {
callBack(this.xmlData, 200, callBackParams);
}
}
else {
this._loadFromService(sync, dojo.hitch(this, function(data, status, parms){
lgr.trace(mname, "Called back from service loader ${0} ${1} ${2}", [typeof(data), status, parms||""]);
var res = data; // may be an Error
if (status == 200) {
res = this.xmlData = com.ibm.mm.enabler.utils.Dom.createDocument(data);
lgr.trace(mname, "Data loaded successfully ${0}", [this.xmlData]);
}
if (callBack) {
callBack(res, status, callBackParams); // callback for success or error
}
}));
}
return this.xmlData;
});
}
var dfd = new com.ibm.mm.builder.DelegatedDeferredImpl();
this._baseLoader.addDelegate(dfd);
return dfd;
},
_loadFromService: function(sync, callbackFunction){
var mname = "_loadFromService", lgr = this.LOGGER;
lgr.entering(mname, arguments);
var cs = com.ibm.mashups.services.ServiceManager.getService(com.ibm.mashups.enabler.services.ConfigService.SERVICE_NAME);
var co = cs.getConfigObject(this.CONTEXT_MENU_PROVIDER);
var propName = this.CONFIG_SERVICE_PROPERTY;
var propNameFromConfig = cs.getValue(com.ibm.mashups.enabler.services.ConfigConstants.CONTEXT_MENU_NAME);
if (propNameFromConfig && propNameFromConfig !== "") {
propName = propNameFromConfig;
}
var deferred = co.getValueDeferred(propName);
deferred.setFinishedCallback(callbackFunction);
var res = deferred.start(sync);
lgr.exiting(mname, [res]);
return res;
},
_initMenuItems: function(_contextMenuItemId, _targetResourceId, _targetResourceType, _someObject){
var mname = "_initMenuItems", lgr = this.LOGGER;
lgr.entering(mname, arguments);
var ret = [];
if (this.xmlData) {
var expr = 'cm:contextmenu/cm:menu[@definition="' + _contextMenuItemId + '"]';
var nodes = com.ibm.mashups.enabler.xml.XPath.evaluateXPath(expr, this.xmlData, this.ns);
var lclCtx = com.ibm.mashups.enabler.context.Factory.getLocalizedContext();
if (nodes && nodes.length > 0) {
expr = "cm:contextMenuItem";
var subnodes = com.ibm.mashups.enabler.xml.XPath.evaluateXPath(expr, nodes[0], this.ns);
if (subnodes && subnodes.length > 0) {
for (var i = 0; i < subnodes.length; ++i) {
var myMetadata = this._getMetaData("cm:meta-data", subnodes[i]);
myMetadata = myMetadata.length === 0 ? null : myMetadata;
if (this._checkVisibility(subnodes[i], _targetResourceId, _targetResourceType, myMetadata, _someObject)) {
var isSeparator = this._checkSeparator(subnodes[i]);
var myLocalized = this._getLocalized(subnodes[i]);
var mytitle = lclCtx.getTitle(myLocalized);
var mydescription = lclCtx.getDescription(myLocalized);
var myIconClass = this._getIconClass(subnodes[i]);
var myState = this._getState(subnodes[i], _targetResourceId, _targetResourceType, myMetadata, _someObject);
var myActionName = this._getFunction("cm:action-handler", subnodes[i]);
var myAction;
if (myActionName) {
myAction = this._buildMethod(myActionName, _targetResourceId, _targetResourceType, myMetadata, _someObject);
}
var anItem = {
"isSeparator": isSeparator,
"localized": myLocalized,
"title": mytitle,
"description": mydescription,
"iconClass": myIconClass === null ? "" : myIconClass,
"enabled": myState,
"id": subnodes[i].getAttribute("id"),
"ordinal": subnodes[i].getAttribute("ordinal"),
"actionCallBackFunction": myAction,
"actionCallBackFunctionName": myActionName
};
ret.push(anItem);
}
}
}
}
}
lgr.exiting(mname, [ret]);
return ret;
},
/**
* Default returns true, unless there is a javascript code that explicitly returns false "javascript:false"
* or state function that returns false
* @param {Object} _node
* @param {Object} _targetResourceId
* @param {Object} _targetResourceType
* @param {Object} _metadata
* @param {Object} _someObject
*/
_checkVisibility: function(_node, _targetResourceId, _targetResourceType, _metadata, _someObject){
var visible = true;
var myVisible = this._getFunction("cm:visibility-provider", _node);
if (myVisible) {
try {
visible = this._buildMethod(myVisible, _targetResourceId, _targetResourceType, _metadata, _someObject)();
if (visible === null || visible === "") { //Need to check this, if the visibility function returns null or nothing, then use default value
visible = true;
}
}
catch (e) {
this.LOGGER.severe("_checkVisibility", e, _node);
}
}
return !!visible;
},
/**
* Default returns false, unless there is a attributethat explicitly defines separator="true"
* @param {Object} _node
*/
_checkSeparator: function(_node){
var isSeparator = _node.getAttribute("separator");
if (isSeparator === true || isSeparator == "true") {
return true;
}
return false;
},
/**
* Default Returns "enabled", unless there is a javascript code that explicitly returns false "javascript:false"
* or state function that returns false
* @param {Object} _node
* @param {Object} _targetResourceId
* @param {Object} _targetResourceType
* @param {Object} _metadata
* @param {Object} _someObject
*/
_getState: function(_node, _targetResourceId, _targetResourceType, _metadata, _someObject){
var state = true;
var myState = this._getFunction("cm:state-provider", _node);
if (myState) {
try {
state = this._buildMethod(myState, _targetResourceId, _targetResourceType, _metadata, _someObject)();
if (state === null || state === "") { //Need to check this, if the state function returns null or nothing, then use default value
state = true;
}
}
catch (e) {
this.LOGGER.severe("_getState", e, _node);
}
}
return !!state;
},
_buildMethod: function(_myMethod, _targetResourceId, _targetResourceType, _metadata, _someObject){
var method = null;
try {
if (_myMethod.match("^" + "javascript:") == "javascript:") { // deal with something like "javascript:alert(1)" or "javascript:false", even "javascript:this.inNva" // JSLINT-IGNORE:
if (_someObject && _someObject.context) {
method = dojo.hitch(_someObject.context, function(){
return eval(_myMethod); // JSLINT-IGNORE:
});
}
else {
method = function(){
return eval(_myMethod); // JSLINT-IGNORE:
};
}
}
else {
if (_someObject && _someObject.context) {
method = dojo.hitch(_someObject.context, function(){
return eval(_myMethod).call(_someObject.context, _targetResourceId, _targetResourceType, _metadata, _someObject); // JSLINT-IGNORE:
});
}
else {
method = function(){
return eval(_myMethod).call(this, _targetResourceId, _targetResourceType, _metadata, _someObject); // JSLINT-IGNORE:
};
}
}
}
catch (e) {
this.LOGGER.severe("_buildMethod", e, _myMethod);
method = function(){
}; //never return null to avoid the possible error when the function is invoked
}
return method;
},
_getLocalized: function(_node){
var myloc = new com.ibm.mm.builder.model.contextMenu.ConfigServiceXmlLocalized();
myloc.setTitles(_node);
nodes = com.ibm.mashups.enabler.xml.XPath.evaluateXPath("cm:description", _node, this.ns);
if (nodes && nodes.length > 0) {
myloc.setDescription(nodes[0].firstChild.nodeValue, "en");
}
return myloc;
},
_getFunction: function(_expr, _node){
var nodes = com.ibm.mashups.enabler.xml.XPath.evaluateXPath(_expr, _node, this.ns);
if (nodes && nodes.length > 0 && nodes[0].firstChild) {
return nodes[0].firstChild.nodeValue;
}
return null;
},
/**
* Default returns null, unless there is a attributethat explicitly defines an iconClass value
* @param {Object} _node
*/
_getIconClass: function(_node){
return _node.getAttribute("iconClass");
},
_getMetaData: function(_expr, _node){
var myArray = [];
var nodes = com.ibm.mashups.enabler.xml.XPath.evaluateXPath(_expr, _node, this.ns);
if (nodes && nodes.length > 0) {
for (var i = 0; i < nodes.length; ++i) {
if (nodes[i].firstChild) {
var anItem = {
"key": nodes[i].firstChild.nodeValue,
"value": nodes[i].firstChild.nodeValue
};
myArray.push(anItem);
}
}
}
return myArray;
}
});
}
if(!dojo._hasResource["com.ibm.mm.builder.DeferredListImpl"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.DeferredListImpl"] = true;
dojo.provide("com.ibm.mm.builder.DeferredListImpl");
/**
* Manages a list of Deferreds and collects their results into a single callback for ease of
* consumption.
*/
dojo.declare("com.ibm.mm.builder.DeferredListImpl", com.ibm.mm.builder.DeferredImpl, {
constructor: function() {
this._list = [];
this._resultList = [];
this._status = 200;
this._numFinished = 0;
},
add: function(/*dfd1, dfd2, ... */) {
for(var i=0; i 0) {
dojo.forEach(this._list, function(obj){
obj.dfd.start(sync);
});
}
else {
this._done(); // finish immediately since we contain no deferreds
}
}
return this._resultList;
}
});
}
if(!dojo._hasResource["com.ibm.mm.builder.model.ContextMenu"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.model.ContextMenu"] = true;
dojo.provide("com.ibm.mm.builder.model.ContextMenu");
/**
* Implementation of builder runtime context menu model.
*/
dojo.declare( "com.ibm.mm.builder.model.ContextMenuImpl", [com.ibm.mashups.builder.model.ContextMenu], {
_baseTopic: "Builder/ContextMenuImpl",
configServiceLoader: new com.ibm.mm.builder.model.contextMenu.ConfigServiceXmlMenuLoader(),
constructor: function() {
this.LOGGER = com.ibm.mashups.enabler.logging.Logger.getLogger(this.declaredClass);
this._menus = {};
this._contrIdCounter = 0;
this.evtSvc = com.ibm.mashups.iwidget.services.ServiceManager.getService("eventService");
this.evtSvc.subscribeEvent("com.ibm.mashups.builder.refreshContextMenu", this, "_fireChange");
},
getContextMenu:function(/*String*/ contextMenuId, /*String*/ targetResourceId, /*String*/ targetResourceType, /*Object*/ someObject){
var mname = "getContextMenu", lgr = this.LOGGER;
lgr.entering(mname, arguments);
dojo.deprecated("com.ibm.mashups.builder.model.ContextMenu.getContextMenu", "The method com.ibm.mashups.builder.model.ContextMenu.getContextMenu is deprecated, please use com.ibm.mashups.builder.model.ContextMenu.getContextMenuDeferred instead!")
var results = this.getContextMenuDeferred.apply(this, arguments).start();
lgr.exiting(mname, [results]);
return results;
},
getContextMenuDeferred:function(/*String*/ contextMenuId, /*String*/ targetResourceId, /*String*/ targetResourceType, /*Object*/ someObject){
var mname = "getContextMenuDeferred", lgr = this.LOGGER;
lgr.entering(mname, arguments);
var menuDef = this._getMenuDef(contextMenuId),
cnbt = menuDef.contributions.slice(), // get a copy so we can mess with it
baseLoader = menuDef.base || this.configServiceLoader,
loaderArgs = [contextMenuId, targetResourceId, targetResourceType, someObject];
// if nothing is registered to this contextMenuId, default to the ConfigService one
var baseDfd = baseLoader.getItems.apply(baseLoader, loaderArgs);
var dfdContribsArray = dojo.map(cnbt, function(contribObj){
// contribObj is of the form {loader: contributionLoader, ordinal: ordinal, id: id, items: undefined|null|items}
return contribObj.loader.getItems.apply(contribObj.loader, loaderArgs);
}, this);
var mergingDfdList = new com.ibm.mm.builder.DeferredListImpl(this);
mergingDfdList.add(baseDfd).add.apply(mergingDfdList, dfdContribsArray);
var retDfd = new com.ibm.mm.builder.DeferredImpl(this, function(deferred, sync, params) {
var callBack = deferred.getFinishedCallback(), callBackParams = deferred.getFinishedCallbackParameters(),
res, me = this;
mergingDfdList.setFinishedCallback(function(result, status, dfdPms){
res = me._mergingCallback.apply(me, arguments);
if(callBack) {
callBack(res, status, callBackParams);
}
},{
contextMenuId: contextMenuId,
contributions: cnbt
}).start(sync);
return res;
});
lgr.exiting(mname, [retDfd]);
return retDfd;
},
_mergingCallback: function(resultsList, status, params) {
var mname = "_mergingCallback", lgr = this.LOGGER;
lgr.entering(mname, arguments);
// each item in resultsList is in the form [dfdResult, dfdStatus, dfdParams]
var loadedList = [], len = resultsList.length, ret;
if(len > 0) {
// pull the base items off the front
var baseItems = resultsList.shift();
len--;
if(baseItems[1] == 200) {
loadedList.push(baseItems[0]);
}
else {
lgr.severe(mname, com.ibm.mm.builder.coreWidgetsMessages.E_CONTEXT_MENU_FAIL_1, [[params.contextMenuId, baseItems[0], baseItems[1]]]);
}
}
// now iterate over contributions
for(var i=0; i 0) {
items.push.apply(items, resultLists[0]);
len = resultLists.length;
for(i=1; i 0) {
var thisIframe = iframes[0];
this.resetSrc(thisIframe,"javascript:false;");
}
})
});
} else {
this.dlg[hubServerUrl].show();
}
var iframes = dojo.query("iframe", this.dlg[hubServerUrl].domNode);
if (iframes.length > 0){
this.resetSrc(iframes[0],hubServerUrl);
} else {
dojo.query(dojo.create("iframe", {
src: hubServerUrl
}, this.dlg[hubServerUrl].containerNode, "only")).style({
width: "99.5%",
height: "99%",
border: "0 none"
});
}
}
else {
var hubWin = window.open(hubServerUrl, "hub");
if (hubWin) {
hubWin.focus();
}
}
}
},
resetSrc: function(/*DOMNode*/iframe, /*String*/src){
try{
var idoc;
if(dojo.isIE || dojo.isWebKit > 521){
idoc = iframe.contentWindow.document;
}else if(dojo.isSafari){
idoc = iframe.document;
}else{
idoc = iframe.contentWindow;
}
if(!idoc){
iframe.location = src;
return;
}else{
idoc.location.replace(src);
}
}catch(e){
console.log("resetSrc: ", e);
}
},
_addOpenedInSuffix: function(url, newWindow) {
var hubServerUrl = url;
if (!newWindow) {
if (hubServerUrl.indexOf("?") != -1) {
hubServerUrl = [hubServerUrl, "&"].join("");
}
hubServerUrl = [hubServerUrl, "openedIn=dialog"].join("");
}
return hubServerUrl;
},
getCatalogURL: function(option) {
dojo.require("dojox.encoding.base64");
var mumUrl = ([window.location.protocol, "//", window.location.host, builderConfig.enablerPath].join("")),
chars = [];
for (var i = 0, l = mumUrl.length; i < l; i++) {
chars.push(mumUrl.charCodeAt(i));
}
var mumUrl64 = dojox.encoding.base64.encode(chars);
switch (option) {
case com.ibm.mm.catalog.CATALOGCREATEFEEDUI:
return encodeURI([com.ibm.mm.catalog.hubUtil.getHubFeedCreationUrl(), "&serverUrl=", mumUrl64].join(""));
case com.ibm.mm.catalog.CATALOGCREATEFEEDMASHUPUI:
return encodeURI([com.ibm.mm.catalog.hubUtil.getHubFeedMashupCreationUrl(), "&serverUrl=", mumUrl64].join(""));
case com.ibm.mm.catalog.CATALOGCREATENEWWIDGETUI:
return encodeURI([com.ibm.mm.catalog.hubUtil.getHubWidgetCreationUrl(), "&serverUrl=", mumUrl64].join(""));
default:
var cs = com.ibm.mashups.services.ServiceManager.getService(com.ibm.mashups.enabler.services.ConfigService.SERVICE_NAME);
var anonymousUser = cs.getValue("anonymousUser");
var securityOff = cs.getValue("securityOff");
if (anonymousUser || securityOff){
return encodeURI([com.ibm.mm.catalog.hubUtil.getHubAnonymousUrl(), "?serverUrl=", mumUrl64].join(""));
} else {
return encodeURI([com.ibm.mm.catalog.hubUtil.getHubSecuredUrl(), "?serverUrl=", mumUrl64].join(""));
}
}
}
});
com.ibm.mm.catalog.CatalogPane = new com.ibm.mm.catalog.CatalogPane();
com.ibm.mm.catalog.CATALOGUI = 0;
com.ibm.mm.catalog.CATALOGUI_NEW_WINDOW = 3;
com.ibm.mm.catalog.CATALOGCREATEFEEDUI = 1;
com.ibm.mm.catalog.CATALOGCREATEFEEDMASHUPUI = 2;
com.ibm.mm.catalog.CATALOGCREATENEWWIDGETUI = 4;
}
if(!dojo._hasResource["com.ibm.mashups.builder.Api"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mashups.builder.Api"] = true;
/**
* Please note, the following builder JavaScript API are not public in Lotus Mashups v1.1.
* The APIs are not stable and subject to change before they go public in v2.
*/
dojo.provide("com.ibm.mashups.builder.Api");
com.ibm.mashups.builder.builderTopicHandlers = null;
com.ibm.mashups.builder.createLMDialog = function(contentDiv, params){
return new com.ibm.mm.builder.widget.CustomDialog(params, contentDiv);
};
com.ibm.mashups.builder.displayLMDialog = function(contentDiv, params){
var dlg = com.ibm.mashups.builder.createLMDialog(contentDiv, params);
dlg.show();
return dlg;
};
/**
* when user wants to open the widget configuration mode,
* this method should be called to create the widget config dialog and switch to edit mode
* @param {String} widgetId widget instance id
*/
com.ibm.mashups.builder.showWidgetConfigDialog=function(widgetId){
var menu = new com.ibm.mm.builder.widget.WidgetMenu({
iwidgetId: widgetId
});
menu.showEditPane();
};
/**
* when user finishes configuring the widget and clicks the save button,
* this method should be called to close the widget config dialog and switch to view mode
* @param {String} widgetId widget instance id
*/
com.ibm.mashups.builder.closeWidgetConfigDialog=function(widgetId){
dojo.publish(com.ibm.mm.builder.eventTopics.Widget_ConfigurationFinished, [widgetId]);
};
/**
* in case production widget need to subscribe the topic published from builder framework.
* @param {String} topicName
* @param {Object} obj
* @param {Object} callback
*/
com.ibm.mashups.builder.subscribeBuilderTopics = function(topicName,obj,callback){
var oneHandler = dojo.subscribe(topicName, obj, callback);
if (!com.ibm.mashups.builder.builderTopicHandlers){
com.ibm.mashups.builder.builderTopicHandlers = [];
}
com.ibm.mashups.builder.builderTopicHandlers.push(oneHandler);
};
/**
* builder api to unsubscribe all the topic handlers
*/
com.ibm.mashups.builder.clearBuilderTopicHandlers = function(){
dojo.forEach(com.ibm.mashups.builder.builderTopicHandlers, dojo.unsubscribe);
com.ibm.mashups.builder.builderTopicHandlers = [];
};
}
if(!dojo._hasResource["com.ibm.mm.builder.utils.userUtil"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.utils.userUtil"] = true;
/**
*/
dojo.provide("com.ibm.mm.builder.utils.userUtil");
com.ibm.mm.builder.utils.userUtil.isLookasideEnabled = function(attName){
var lookasideAttNames = this.getUserModel().getLookasideAttributeNames().start();
if ((typeof lookasideAttNames == "undefined") || (lookasideAttNames === null) || (lookasideAttNames.length === 0)) {
return false;
}
if ((typeof attName == "undefined") || (attName === null)) {
return true;
}
for (var i = 0; i < lookasideAttNames.length; i++) {
if (attName == lookasideAttNames[i]) {
return true;
}
}
return false;
};
com.ibm.mm.builder.utils.userUtil.getCurrentUser = function(){
return this.getUserModel().findCurrentUser().start();
};
com.ibm.mm.builder.utils.userUtil.getCurrentUserID = function(){
return this.getUserModel().findCurrentUser().start().getID();
};
com.ibm.mm.builder.utils.userUtil.getUserModel = function() {
if (com.ibm.mm.builder.userModel === null) {
com.ibm.mm.builder.userModel = com.ibm.mashups.enabler.user.Factory.getUserModel();
}
return com.ibm.mm.builder.userModel;
};
com.ibm.mm.builder.utils.userUtil.getAnonymousMode = function(){
return this.getUserModel().getAnonymousMode();
};
com.ibm.mm.builder.utils.userUtil.isLockedDownAnonymousMode = function(){
// there will be three mode of the return value from getAnonymousMode()
// com.ibm.mashups.enabler.user.AnonymousMode.ANONYMOUS -> nomral anonymous mode, most of the actions disabled
// com.ibm.mashups.enabler.user.AnonymousMode.USER -> extended anonymous mode, confirmable api to check further permission
// com.ibm.mashups.enabler.user.AnonymousMode.OFF -> anonymous is off
return this.getAnonymousMode() === com.ibm.mashups.enabler.user.AnonymousMode.ANONYMOUS;
};
com.ibm.mm.builder.userModel = null;
}
if(!dojo._hasResource["com.ibm.mm.builder.utils.enablerUtil"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.utils.enablerUtil"] = true;
/**
*/
dojo.provide("com.ibm.mm.builder.utils.enablerUtil");
/**
*
* @param {String} key
* @return {String} if the key is never saved, null will be returned
*/
com.ibm.mm.builder.utils.enablerUtil.getPageMetaData = function(key, pageId) {
var currentPage = null;
if (typeof pageId != "undefined") {
currentPage = com.ibm.mm.builder.utils.pageUtil.getPageNode(pageId);
}
else {
currentPage = com.ibm.mm.builder.utils.pageUtil.getCurrentPageNode();
}
if (currentPage) {
// var layoutModel = com.ibm.mm.builder.utils.navigationUtil.getNavigationModel().getLayoutModel(currentPage.getID());
// if(layoutModel) {
// var lmRoot = layoutModel.getRoot().start();
// if (lmRoot){
// return lmRoot.getMetaData(key);
// }
// }
var pageContent = currentPage.getContent().start();
return pageContent.getMetaData(key);
}
return null;
};
com.ibm.mm.builder.utils.enablerUtil.setPageMetaData = function(key, value, pageId) {
var pageNode = pageId ? com.ibm.mm.builder.utils.pageUtil.getPageNode(pageId) : com.ibm.mm.builder.utils.pageUtil.getCurrentPageNode();
if (pageNode) {
var navModel = com.ibm.mm.builder.utils.navigationUtil.getNavigationModel();
// var layoutModel = navModel.getLayoutModel(pageNode.getID());
// if (layoutModel) {
// var lmRoot = layoutModel.getRoot().start();
// if (lmRoot) {
// lmRoot.setMetaData(key, value);
// navModel.commit().start();
// }
// }
var pageContent = pageNode.getContent().start();
pageContent.setMetaData(key, value);
navModel.commit().start();
}
};
com.ibm.mm.builder.utils.enablerUtil.setPageJSONMetaData = function(metadata, pageId) {
var pageNode = pageId ? com.ibm.mm.builder.utils.pageUtil.getPageNode(pageId) : com.ibm.mm.builder.utils.pageUtil.getCurrentPageNode();
if (pageNode) {
var navModel = com.ibm.mm.builder.utils.navigationUtil.getNavigationModel();
var layoutModel = navModel.getLayoutModel(pageNode.getID());
if (layoutModel) {
var lmRoot = layoutModel.getRoot().start();
if (lmRoot) {
for (var key in metadata) {
if (Object.prototype.hasOwnProperty.call(metadata, key)) {
lmRoot.setMetaData(key, metadata[key]);
}
}
navModel.commit().start();
}
}
}
};
com.ibm.mm.builder.utils.enablerUtil.removePageMetaData = function(keys, pageId) {
var pageNode = pageId ? com.ibm.mm.builder.utils.pageUtil.getPageNode(pageId) : com.ibm.mm.builder.utils.pageUtil.getCurrentPageNode();
if (pageNode) {
var navModel = com.ibm.mm.builder.utils.navigationUtil.getNavigationModel();
var layoutModel = navModel.getLayoutModel(pageNode.getID());
if (layoutModel) {
var lmRoot = layoutModel.getRoot().start();
if (lmRoot) {
dojo.forEach(keys, function(key) {
if (key != "com.ibm.mashups.acl.role.USER" && key != "com.ibm.mashups.acl.role.EDITOR") {
lmRoot.removeMetaData(key);
}
});
navModel.commit().start();
}
}
}
};
com.ibm.mm.builder.utils.enablerUtil.getUnescapedNodeTitle = function(node, locale) {
if (!node) {
return null;
}
// node locale when created -- will be en if locale = en_**/en
var title = "";
if (locale) {
title = node.getTitle(locale);
}
if (!title) {
title = com.ibm.mashups.enabler.context.Factory.getLocalizedContext().getTitle(node);
}
return title;
};
com.ibm.mm.builder.utils.enablerUtil.getNodeTitle = function(node, locale) {
return com.ibm.mm.builder.utils.htmlUtil.escapeString(com.ibm.mm.builder.utils.enablerUtil.getUnescapedNodeTitle(node, locale));
};
com.ibm.mm.builder.utils.enablerUtil.getNodeDescription = function(node, locale) {
if (!node) {
return null;
}
var desc = null;
try {
if (locale) {
desc = node.getDescription(locale);
}
if (!desc) {
desc = com.ibm.mashups.enabler.context.Factory.getLocalizedContext().getDescription(node);
}
if (!desc || desc === "null"){
desc = "";
}
}
catch (ex) {
console.log("failed to load the description of the node");
}
return desc;
};
}
if(!dojo._hasResource["com.ibm.mm.builder.utils.spaceUtil"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.utils.spaceUtil"] = true;
/**
*/
dojo.provide("com.ibm.mm.builder.utils.spaceUtil");
/**
* Return navigation model, if refresh is true, the cache will be clean and retrieve the model again.
* @param {boolean} refresh
* @param {string} id
*/
(function(){
var enabler = com.ibm.mashups.enabler;
var builder = com.ibm.mm.builder;
var constant = builder.constant;
var strategy = enabler.strategy;
var ef = enabler.model.Factory;
var af = enabler.model.state.AccessorFactory;
var spaceFactory = com.ibm.mashups.enabler.space.Factory;
var userUtil = builder.utils.userUtil;
var enablerUtil = com.ibm.mm.builder.utils.enablerUtil;
var cs = com.ibm.mashups.services.ServiceManager.getService(enabler.services.ConfigService.SERVICE_NAME);
var configConstants = com.ibm.mashups.enabler.services.ConfigConstants;
var es = com.ibm.mashups.services.ServiceManager.getService("eventService");
var cws = com.ibm.mm.builder.coreWidgetsStrings;
var spaceUtil = {
getSpaceModel: function(refresh) {
if (refresh || !this.spaceModel) {
if (this.spaceModel) {
delete this.spaceModel;
};
var spaceModel = spaceFactory.getSpaceModel();
spaceModel.setStrategy(new com.ibm.mashups.enabler.strategy.ListLoadAheadStrategy(com.ibm.mm.builder.constant.NavigationPageSize));
this.spaceModel = spaceModel;
}
//clean cache
this.currentSpaceNode = null;
return this.spaceModel;
},
getSpaceByNavigation: function(navNode) {
if (navNode) { return this.getSpaceModel().findSpaceByNavigation(navNode).start(); }
return null;
},
getSpaceIdByPageId: function(pageId) {
var s = this.getSpaceByNavigation(com.ibm.mm.builder.utils.pageUtil.getPageNode(pageId));
if (s) { return s.getID(); }
return null;
},
getCurrentSpaceId: function() {
return this.getSpaceAccessor().getSpaceID();
},
getCurrentSpaceNode: function() {
if (!this.currentSpaceNode || this.currentSpaceNode.getID() !== this.getCurrentSpaceId()) {
this.currentSpaceNode = this.getSpaceNode(this.getCurrentSpaceId());
}
return this.currentSpaceNode;
},
setSpaceId: function(sid) {
this.getSpaceAccessor().setSpaceID(sid);
com.ibm.mm.builder.utils.navigationUtil.getNavigationModel().commit().start();
if (!sid) {
dojo.cookie("inPersonalSpace", "true");
}
else {
dojo.cookie("inPersonalSpace", null);
}
},
getSpaceAccessor: function() {
this.spaceAccessor = this.spaceAccessor ||
af.getSpaceAccessor(com.ibm.mm.builder.utils.navigationUtil.getNavigationStateModel());
return this.spaceAccessor;
},
getWelcomeSpaceId: function() {
return cs.getValue(configConstants.WELCOME_SPACE_ID);
},
getHomeSpaceId: function() {
if (userUtil.isLookasideEnabled("com.ibm.mashups.user.DEFAULT_SPACE")) {
try {
this._homeSpaceId = this._homeSpaceId || userUtil.getCurrentUser().getAttribute("com.ibm.mashups.user.DEFAULT_SPACE");
//check whether the space exists
if (this._homeSpaceId === "null") { return null; }
if (this._homeSpaceId === "-1") { return null; }
return this._homeSpaceId;
} catch (e) {
return null;
}
}
return null;
},
setHomeSpaceId: function(sid) {
sid = sid || "-1";
this._homeSpaceId = sid;
var userModel = userUtil.getUserModel();
var user = userUtil.getCurrentUser();
if (user) {
user.setAttribute("com.ibm.mashups.user.DEFAULT_SPACE", sid);
userModel.commit().start();
es.broadcastEvent("com.ibm.mashups.builder.refreshSpaceSelector");
}
},
isHomeSpace: function(spaceId) {
return this.getHomeSpaceId() === spaceId;
},
isWelcomeSpace: function(spaceId){
return this.getWelcomeSpaceId() === spaceId;
},
isPersonalSpace: function(spaceId) {
return !this.getCurrentSpaceId();
},
getSpaceTitle: function(spaceId, locale) {
return enablerUtil.getNodeTitle(this.getSpaceNode(spaceId), locale) || this.getPersonalSpaceTitle();
},
getPersonalSpaceTitle: function() {
if (ibmConfig.PERSONAL_SPACE_KEY && cws[ibmConfig.PERSONAL_SPACE_KEY]) { return cws[ibmConfig.PERSONAL_SPACE_KEY]; }
return cws.I_SPACE_PERSONAL_SPACE;
},
getSpaceIconURL: function(space) {
var names = space.getMetaDataNames();
for (var i = 0; i < names.length; i++) {
// this meta is for "iconUrl"
if (names[i] && (names[i] == "iconUrl" || names[i].search("^\{.*\}iconUrl$") !== -1)) { return space.getMetaData(names[i]); }// JSLINT-IGNORE:
}
return null;
},
setSpaceIconURL: function(space, iconUrl) {
var names = space.getMetaDataNames();
var found = false;
for (var i = 0; i < names.length; i++) {
// this meta is for "iconUrl"
if (names[i] && (names[i] == "iconUrl" || names[i].search("^\{.*\}iconUrl$") !== -1)) { // JSLINT-IGNORE:
space.setMetaData(names[i], iconUrl);
found = true;
}
}
if (!found) {
space.setMetaData("{http://www.ibm.com/xmlns/prod/lotus/mashups/v1.0/extensions}iconUrl", iconUrl);
}
return;
},
getSpaceNode: function(spaceId) {
if (spaceId === this.getCurrentSpaceId() && this.currentSpaceNode) { return this.currentSpaceNode; }
spaceId = spaceId || this.getCurrentSpaceId();
if (spaceId) { return this.getSpaceModel().find(spaceId).start(); }
},
//todo remove duplicate code to check title.
validateSpaceName: function(title) {
var cwm = com.ibm.mm.builder.coreWidgetsMessages;
if (!title) { return false; }
if (title.length === 0) {
alert(cwm.E_SPACE_UTIL_INVALID_NAME_EMPTY_0);
return false;
}
title = dojo.trim(title);
if (title.length === 0) {
alert(cwm.E_SPACE_UTIL_INVALID_NAME_BLANK_0);
return false;
}
if (title.length >= 256) {
alert(cwm.E_SPACE_UTIL_INVALID_NAME_LENGTH_0);
return false;
}
var match = ibmConfig[configConstants.BUILDER_TITLE_FILTER_REGEXP];
if (match) {
if (title.match(match)) {
alert(cwm.E_SPACE_UTIL_INVALID_NAME_CHAR_0);
return false;
}
}
return true;
},
isVisiable: function(node) {
if (!node) { return false; }
if (dojo.isString(node)) {
node = this.getSpaceNode(node);
}
if (!node.isHidden()) { return true; }
return this.isBusinessSpaceServer() ? this.canEdit(node) : false;
},
canEdit: function(node) {
if (!node) { return false; }
var ac = com.ibm.mm.builder.utils.acModelUtil;
return ac.isSpaceOwner(node) || ac.canEditSpace(node);
},
isBusinessSpaceServer: function() {
return cs.getValue(configConstants.SERVER_TYPE) == configConstants.SERVER_TYPE_BSPACE;
}
};
com.ibm.mm.builder.utils.spaceUtil = spaceUtil;
})();
}
if(!dojo._hasResource["com.ibm.mm.builder.utils.pageUtil"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.utils.pageUtil"] = true;
/**
*/
dojo.provide("com.ibm.mm.builder.utils.pageUtil");
com.ibm.mm.builder.utils.pageUtil.LOGGER = com.ibm.mashups.enabler.logging.Logger.getLogger("com.ibm.mm.builder.utils.pageUtil");
com.ibm.mm.builder.utils.pageUtil.getPageIdFromSpace = function(spaceId){
return this.getPageAccessor(spaceId).getPageID();
};
com.ibm.mm.builder.utils.pageUtil.getFirstPageInSpace = function(spaceId){
return this.getFirstChildPageId(com.ibm.mm.builder.utils.navigationUtil.getNavigationRootNodeId(spaceId));
};
com.ibm.mm.builder.utils.pageUtil.getFirstPageInHomeSpace = function(){
var spaceId = com.ibm.mm.builder.utils.spaceUtil.getHomeSpaceId();
return this.getFirstChildPageId(com.ibm.mm.builder.utils.navigationUtil.getNavigationRootNodeId(spaceId));
};
com.ibm.mm.builder.utils.pageUtil.setPageId = function(pid, spaceId){
this.getPageAccessor(spaceId||com.ibm.mm.builder.utils.spaceUtil.getCurrentSpaceId()).setPageID(pid);
//change to view mode because enabler needs that.
this.changePageMode("view");
};
com.ibm.mm.builder.utils.pageUtil.getPageAccessor = function(spaceId){
return com.ibm.mashups.enabler.model.state.AccessorFactory.getPageAccessor(com.ibm.mm.builder.utils.navigationUtil.getNavigationStateModel(), spaceId);
};
com.ibm.mm.builder.utils.pageUtil.getPageModeAccessor = function(spaceId){
return com.ibm.mashups.enabler.model.state.AccessorFactory.getPageModeAccessor(
com.ibm.mm.builder.utils.navigationUtil.getNavigationStateModel()
);
};
com.ibm.mm.builder.utils.pageUtil.getCurrentPageMode = function(){
return this.getPageModeAccessor(com.ibm.mm.builder.utils.spaceUtil.getCurrentSpaceId()).getPageMode();
};
/**
* Get current page id
*/
com.ibm.mm.builder.utils.pageUtil.getCurrentPageId = function(){
return com.ibm.mashups.builder.model.Factory.getRuntimeModel().getCurrentPage().getID();
};
com.ibm.mm.builder.utils.pageUtil.getCurrentPageNode = function(){
if(!this.currentPageNode || this.currentPageNode.getID() !== this.getCurrentPageId()){
this.currentPageNode = this.getPageNode(this.getCurrentPageId());
}
return this.currentPageNode;
};
/**
* Get current page id
*/
com.ibm.mm.builder.utils.pageUtil.getParentPageId = function(pageId){
var p = this.getParentPageNode(pageId);
return (p) ? p.getID() : null;
};
com.ibm.mm.builder.utils.pageUtil.getFirstChildPageId = function(pageId){
var p = this.getFirstChildPage(pageId);
return (p)? p.getID(): null;
};
/**
* get first visible page
* @param {String or NavigationNode} pageId
*/
com.ibm.mm.builder.utils.pageUtil.getFirstChildPage = function(pageId){
var page = this.getPageNode(pageId);
if (page) {
var _navModel = com.ibm.mm.builder.utils.navigationUtil.getNavigationModel();
if (_navModel.hasChildren(page)) {
var iter = _navModel.getChildren(page);
while (iter.hasNext()) {
var node = iter.next();
if (this.isVisiable(node)) { return node; }
}
}
}
return null;
};
com.ibm.mm.builder.utils.pageUtil.getParentPageNode = function(pageId){
var parentNode = null;
var navUtil = com.ibm.mm.builder.utils.navigationUtil;
var spaceUtil = com.ibm.mm.builder.utils.spaceUtil;
var _navModel = navUtil.getNavigationModel();
var pid = this._getPageId(pageId);
if(pid){
parentNode = _navModel.getParent(pid).start();
}
return parentNode || navUtil.getNavigationRootNode(spaceUtil.getCurrentSpaceId());
};
com.ibm.mm.builder.utils.pageUtil.getSiblingPages = function(pageId){
return this.getChildPages(this.getParentPageNode(pageId));
};
com.ibm.mm.builder.utils.pageUtil.getChildPages = function(page){
if (typeof page === "string") {
page = this.getPageNode(page);
if (!page) { return null; }
}
var navModel = com.ibm.mm.builder.utils.navigationUtil.getNavigationModel();
return navModel.hasChildren(page) ? navModel.getChildren(page) : null;
};
/**
* Determine the first page to render
*/
com.ibm.mm.builder.utils.pageUtil.getDefaultPage = function(pageId){
return this.getPageNode(pageId) || this.getFirstRootPageId();
};
com.ibm.mm.builder.utils.pageUtil.getDefaultPageId = function(pageId) {
var p = this.getDefaultPage(pageId);
if (!p.getID) { return p; } //added this line
return (p) ? p.getID() : null;
};
/**
* Determine the first page to render
*/
com.ibm.mm.builder.utils.pageUtil.getFirstRootPageId = function(){
var utils = com.ibm.mm.builder.utils;
var rootId = utils.navigationUtil.getNavigationRootNodeId(utils.spaceUtil.getCurrentSpaceId());
return this.getFirstChildPageId(rootId);
};
/**
* Determine the page id of the page in the current space whose page title matches title using locale.
* Used by links on Welcome page of Welcome Space to switch to other pages in the Welcome Space.
*/
com.ibm.mm.builder.utils.pageUtil.getCurrentSpacePageIdByPageTitle = function(title, locale) {
var iter = this.getSiblingPages(this.getFirstRootPageId());
while (iter.hasNext()) {
var page = iter.next();
if (this.getPageTitle(page.getID(), locale) == title) { return page.getID(); }
}
return null;
};
/**
* Get page content by page id
* If pageId is null, current page content is returned.
* @param {String} pageId
*/
com.ibm.mm.builder.utils.pageUtil.getPageContent = function(pageId){
var layoutModel = this.getPageLayoutModel(pageId);
if (!layoutModel) { return null; }
var lmRoot = layoutModel.getRoot().start();
if (lmRoot) { return lmRoot.getFragment(); }
alert(com.ibm.mm.builder.coreWidgetsMessages.E_NAV_NO_PAGE_OR_NET_DISCONNECT_0);
return null;
};
com.ibm.mm.builder.utils.pageUtil.getPageTitle = function(page, locale) {
if (!page) { return null; }
if (dojo.isString(page)) {
page = this.getPageNode(page);
}
return com.ibm.mm.builder.utils.enablerUtil.getNodeTitle(page, locale);
};
com.ibm.mm.builder.utils.pageUtil.getUnescapedPageTitle = function(page, locale){
if (!page) { return null; }
if (dojo.isString(page)) {
page = this.getPageNode(page);
}
return com.ibm.mm.builder.utils.enablerUtil.getUnescapedNodeTitle(page, locale);
};
com.ibm.mm.builder.utils.pageUtil.getCurrentPageTitle = function(locale){
return this.getPageTitle(this.getDefaultPageId(), locale);
};
/**
* @param {Object} pageId
* @param {Object} locale
*/
com.ibm.mm.builder.utils.pageUtil.getPageDescription = function(pageId, locale){
var node = this.getPageNode(pageId);
return com.ibm.mm.builder.utils.enablerUtil.getNodeDescription(node, locale);
};
/**
* return page layout itemset
* @param {String} pageId
*/
com.ibm.mm.builder.utils.pageUtil.getPageLayoutItemSet = function(pageId){
var layoutModel = this.getPageLayoutModel(this._getPageId(pageId));
if (!layoutModel) { return null; }
var lmRoot = layoutModel.getRoot().start();
if (lmRoot) {
return lmRoot.getMetaData(com.ibm.mm.builder.constant.layoutWidgetItemSet);
}
return null;
};
/**
* Create page with page title
* @param {String} title
* @param {String} parentId, if null, the new page will created as sibling of current page.
*/
com.ibm.mm.builder.utils.pageUtil.createPage = function(title, parentId, onErrorCb){
var utils = com.ibm.mm.builder.utils;
var parentPage = this.getPageNode(parentId || this.getParentPageId() ||
utils.navigationUtil.getNavigationRootNodeId(utils.spaceUtil.getCurrentSpaceId()));
var _navModel = utils.navigationUtil.getNavigationModel();
// create page
var newPage = _navModel.create(null);
newPage.setTitle(title, dojo.locale);
newPage.setTitle(title, ibmConfig["default.locale"]);
//we change this logic to save theme when save page instead saving theme after creating page.
var themeId = utils.themeUtil.getThemeId(parentPage.getID());
if (!utils.themeUtil.getThemeModel().find(themeId).start()){
themeId = utils.themeUtil.getDefaultThemeId();
}
newPage.setTheme(themeId);
_navModel.insert(newPage, parentPage, null);
// create layout
var layoutModel = _navModel.getLayoutModel(newPage.getID());
if (layoutModel) {
var lmRoot = layoutModel.create();
layoutModel.insert(lmRoot);
// set empty fragment
lmRoot.setFragment(" ");
// commit changes
var deferred = _navModel.commit();
var newNode = null;
deferred.setOperationCallback(function(node, operation, status, params) {
if(!node && status >= 400){
com.ibm.mm.builder.utils.pageUtil.LOGGER.severe("createPage", dojo.string.substitute(com.ibm.mm.builder.coreWidgetsMessages.E_PUB_API_CREATE_PAGE_1,[status]));
}else{
newNode = node.getID();
}
});
deferred.setFinishedCallback(function(ret, statusCode) {
if(!newNode || statusCode >= 400){
if (onErrorCb) {
onErrorCb();
}
com.ibm.mm.builder.utils.pageUtil.LOGGER.severe("createPage", dojo.string.substitute(com.ibm.mm.builder.coreWidgetsMessages.E_PUB_API_CREATE_PAGE_1,[statusCode]));
}else{
dojo.cookie(com.ibm.mm.builder.constant.cookieKey_previous_pid, null, {expires: -1});
var es = com.ibm.mashups.services.ServiceManager.getService("eventService");
es.broadcastEvent("com.ibm.mashups.builder.pageCreated", newNode);
es.broadcastEvent("com.ibm.mashups.builder.switchPage", newNode);
es.broadcastEvent("com.ibm.mashups.builder.spacemanager.pageCreated", newNode);
}
});
deferred.start(false);
} else {
this.LOGGER.trace("cannot get layoutmodel");
}
};
/**
* Update page's content, title and theme
* @param {Hash} pageProps, example: {content: "test", title:"new name", theme:"columnlayout"}
* @param {String} parentId, if null, the new page will created as sibling of current page.
*/
com.ibm.mm.builder.utils.pageUtil.updatePage = function(pageId, pageProps){
var pageNode = pageId ? this.getPageNode(pageId) : this.getCurrentPageNode();
if (!pageNode) { return; }
var _navModel = com.ibm.mm.builder.utils.navigationUtil.getNavigationModel();
var need_to_commit = false;
var target_page = null;
if(pageProps.content){
if (_navModel.hasLayoutModel(pageNode)) {
var layoutModel = _navModel.getLayoutModel(pageNode);
if (layoutModel) {
var lmRoot = layoutModel.getRoot().start() || layoutModel.create();
lmRoot.setFragment(pageProps.content);
layoutModel.insert(lmRoot);
need_to_commit = true;
}
}
}
if(pageProps.title && pageProps.title != this.getPageTitle(pageNode)){
if(this.validatePageName(pageProps.title)){
pageNode.setTitle(pageProps.title, dojo.locale);
need_to_commit = true;
}else{
return;
}
}
if(pageProps.description && pageProps.description != com.ibm.mm.builder.utils.enablerUtil.getNodeDescription(pageNode)){
pageNode.setDescriptione(pageProps.description, dojo.locale);
need_to_commit = true;
}
var themeId = com.ibm.mm.builder.utils.themeUtil.getThemeId(pageNode);
if (pageProps.theme && pageProps.theme != themeId) {
pageNode.setTheme(pageProps.theme);
need_to_commit = true;
}
//if theme is null, save default theme as well.
if (themeId === "null") {
pageNode.setTheme(com.ibm.mm.builder.utils.themeUtil.getDefaultThemeId());
need_to_commit = true;
}
if (need_to_commit){
_navModel.commit().start();
com.ibm.mashups.builder.model.Factory.getRuntimeModel().getCurrentPage().setDirty(false);
}
};
com.ibm.mm.builder.utils.pageUtil.saveCurrentPage = function(content){
var pageProps = {};
pageProps.content = content || this.getPageContent();
this.updatePage(null, pageProps);
};
/**
* Delete page
* @param {String} parentId, if null, current page will be deleted
*/
com.ibm.mm.builder.utils.pageUtil.deletePage = function(pageId){
//set page to false to disable the page save checker.
com.ibm.mashups.builder.model.Factory.getRuntimeModel().getCurrentPage().setDirty(false);
var navModel = com.ibm.mm.builder.utils.navigationUtil.getNavigationModel();
navModel.remove(this._getPageId(pageId));
navModel.commit().start();
//reset current page after delete page
com.ibm.mashups.builder.model.Factory.getRuntimeModel().getCurrentPage().setID(null);
};
com.ibm.mm.builder.utils.pageUtil.isRoot = function(pageId){
var node = this.getPageNode(pageId);
var currentSpaceId = com.ibm.mm.builder.utils.spaceUtil.getCurrentSpaceId();
return !node || node.getID() == com.ibm.mm.builder.utils.navigationUtil.getNavigationRootNodeId(currentSpaceId);
};
/**
* Get page layout model
* @param {String} pageId
*/
com.ibm.mm.builder.utils.pageUtil.getPageLayoutModel = function(pageId){
var navModel = com.ibm.mm.builder.utils.navigationUtil.getNavigationModel();
return navModel.getLayoutModel(this._getPageId(pageId));
};
com.ibm.mm.builder.utils.pageUtil.getPageLayoutNode = function(pageId){
var layoutModel = this.getPageLayoutModel(pageId);
if (layoutModel) { return layoutModel.getRoot().start(); }
};
/**
* Get the page node, return current page node if pageId is null
* @param {String} pageId
*/
com.ibm.mm.builder.utils.pageUtil.getPageNode = function(pageId){
var pid = this._getPageId(pageId);
if (pid) {
var navModel = com.ibm.mm.builder.utils.navigationUtil.getNavigationModel(true);
try {
return navModel.find(pid).start();
} catch (e) {
return null;
}
}
};
/**
* Get the page id, return current page id if pageId is null
* @param {String} pageId
*/
com.ibm.mm.builder.utils.pageUtil._getPageId = function(pageId){
return pageId || this.getCurrentPageId();
};
/**
* Check page name , if name is valid , return true , or , return false
* //todo change to one ui for error message display instead of alert
*/
com.ibm.mm.builder.utils.pageUtil.validatePageName = function(title){
var cwm = com.ibm.mm.builder.coreWidgetsMessages;
if (!title) {
return false;
}
if (title.length === 0) {
alert(cwm.E_PAGE_UTIL_INVALID_NAME_EMPTY_0);
return false;
}
title = dojo.trim(title);
if (title.length === 0) {
alert(cwm.E_PAGE_UTIL_INVALID_NAME_BLANK_0);
return false;
}
if (title.length >= 256) {
alert(cwm.E_PAGE_UTIL_INVALID_NAME_LENGTH_0);
return false;
}
var match = ibmConfig[com.ibm.mashups.enabler.services.ConfigConstants.BUILDER_TITLE_FILTER_REGEXP];
if (match) {
if (title.match(match)) {
alert(cwm.E_PAGE_UTIL_INVALID_NAME_CHAR_0);
return false;
}
}
return true;
};
com.ibm.mm.builder.utils.pageUtil.getEmptyPageMessage = function(msg){
var empty_content =
""+
"" +
"" +
com.ibm.mm.builder.utils.htmlUtil.formatMessage(msg) +
"" +
""+
"";
return empty_content;
};
com.ibm.mm.builder.utils.pageUtil.encodeBase64 = function(str){
function unicode2utf8(str){
var result = [];
for (var i = 0, len = str.length; i < len; i++) {
var ch = str.charCodeAt(i);
if ((ch >= 0x0001) && (ch <= 0x007F)) {
result.push(str.charAt(i));
}
else
if (ch > 0x07FF) {
result.push(String.fromCharCode(0xE0 | ((ch >> 12) & 0x0F)));
result.push(String.fromCharCode(0x80 | ((ch >> 6) & 0x3F)));
result.push(String.fromCharCode(0x80 | ((ch >> 0) & 0x3F)));
}
else {
result.push(String.fromCharCode(0xC0 | ((ch >> 6) & 0x1F)));
result.push(String.fromCharCode(0x80 | ((ch >> 0) & 0x3F)));
}
}
return result.join("");
}
str = unicode2utf8(str);
var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var out, i, len;
var c1, c2, c3;
len = str.length;
var i = 0;
out = [];
while (i < len) {
c1 = str.charCodeAt(i++) & 0xff;
if (i === len) {
out.push(base64EncodeChars.charAt(c1 >> 2));
out.push(base64EncodeChars.charAt((c1 & 0x3) << 4));
out.push("==");
break;
}
c2 = str.charCodeAt(i++);
if (i === len) {
out.push(base64EncodeChars.charAt(c1 >> 2));
out.push(base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4)));
out.push(base64EncodeChars.charAt((c2 & 0xF) << 2));
out.push("=");
break;
}
c3 = str.charCodeAt(i++);
out.push(base64EncodeChars.charAt(c1 >> 2));
out.push(base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4)));
out.push(base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >> 6)));
out.push(base64EncodeChars.charAt(c3 & 0x3F));
}
return out.join("");
};
com.ibm.mm.builder.utils.pageUtil.isEmptyPage = function(pageNode){
if (!pageNode) { return true; }
return !com.ibm.mm.builder.utils.navigationUtil.getNavigationModel().hasLayoutModel(pageNode);
};
com.ibm.mm.builder.utils.pageUtil.isVisiable = function(node){
if (!node) { return false; }
if (dojo.isString(node)) {
node = this.getPageNode(node);
}
if (!node.isHidden()) { return true; }
return com.ibm.mm.builder.utils.spaceUtil.isBusinessSpaceServer() ? this.canEdit(node) : false;
};
com.ibm.mm.builder.utils.pageUtil.canEdit = function(node){
// if (!node) { return false; }
// var ac = com.ibm.mm.builder.utils.acModelUtil;
// if (ac.isPageOwner(node.getID())) { return true; }
// if (ac.getUserPermission(node.getID()) === ac.EDIT) { return true; }
// return false;
var enabler = com.ibm.mashups.enabler;
var navModel = enabler.navigation.Factory.getNavigationModel();
var page = navModel.find(node.getID()).start();
var type = page.getNavigationElementType();
if (type == com.ibm.mashups.enabler.navigation.Constants.NAVIGATION_PAGE) {
var sc = page.getContent().start();
if (page.getMetaData("com.ibm.portal.static.page.file.name.html")) {
return sc.confirmSetStaticMarkup("");
} else {
if(page.hasRole(com.ibm.mashups.enabler.ac.RoleType.ADMIN) ||
page.hasRole(com.ibm.mashups.enabler.ac.RoleType.EDITOR) ||
page.hasRole("Privileged User")){
return true;
} else {
return false; }
}
} else if (type == com.ibm.mashups.enabler.navigation.Constants.NAVIGATION_LABEL) {
return page.confirmSetHidden(true);
} else {
return false;
}
};
com.ibm.mm.builder.utils.pageUtil.updatePageTitle = function(){
var pageTitle = this.getUnescapedPageTitle(this.getCurrentPageId());
var pageContext = com.ibm.mashups.enabler.context.Factory.getPageContext();
// use the enabler API to set the HTML page title in browser
if (pageContext){
if (!pageTitle || dojo.trim(pageTitle) == "") {
//dojo.doc.title = builderConfig.productName
pageContext.setBrowserTitle(builderConfig.productName);
} else {
//dojo.doc.title = builderConfig.productName + " - " + pageTitle;
pageContext.setBrowserTitle(builderConfig.productName + " - " + pageTitle);
}
}
};
com.ibm.mm.builder.utils.pageUtil.isGlobalPage = function(){
return dojo.cookie(com.ibm.mm.builder.constant.cookieKey_previous_pid) && dojo.cookie(com.ibm.mm.builder.constant.cookieKey_previous_pid) !== "null";
};
com.ibm.mm.builder.utils.pageUtil.savePageWithConfirm = function(callback, cancelcb){
if(com.ibm.pb.contextMenu.sharedActions.widgetEditModeChecker()) {
// skip the page dirty check and display another confirm dialog if there is unsaved widget
return;
}
if (com.ibm.mashups.builder.model.Factory.getRuntimeModel().getCurrentPage().isDirty()) {
var cws = com.ibm.mm.builder.coreWidgetsStrings;
var saveConfirmDlg = new com.ibm.mm.builder.dialog.PageSaveConfirmDialog({
contentWarning: cws.I_PAGE_SAVE_WARNING,
contentQuestion: cws.I_PAGE_SAVE_SUGGEST,
btnSaveText: cws.I_COMMON_SAVE,
btnNotSaveText: cws.I_PAGE_SAVE_NO_SAVE,
btnCancelText: cws.I_PAGE_SAVE_KEEP_EDIT,
hideNotSave: true,
callbackSave: callback,
callbackNotSave: callback,
callbackCancel: cancelcb
});
saveConfirmDlg.show();
}
else {
if (callback) {
callback();
}
}
};
com.ibm.mm.builder.utils.pageUtil.changePageMode = function(mode){
if (mode == "view" || mode == "edit") {
com.ibm.mm.builder.utils.pageUtil.getPageModeAccessor().setPageMode(mode);
com.ibm.mm.builder.utils.navigationUtil.getNavigationStateModel().commit().start();
}
};
com.ibm.mm.builder.utils.pageUtil.isPageDescriptionLengthExceed=function(description){
var descBytes = description.replace(/[^\x00-\xff]/gi, "--").length; // get the byte count of description string
var cs = com.ibm.mashups.services.ServiceManager.getService(com.ibm.mashups.enabler.services.ConfigService.SERVICE_NAME);
var maxLength = cs.getValue(com.ibm.mashups.enabler.services.ConfigConstants.LIMIT_PAGE_DESCRIPTION);
if (descBytes > maxLength) {
return maxLength;
}
else {
return 0;
}
};
com.ibm.mm.builder.utils.pageUtil.getLayoutModel = function(){
var navStateModel = com.ibm.mashups.enabler.model.state.NavigationStateModelFactory.getNavigationStateModel();
var pageAccessor = com.ibm.mashups.enabler.model.state.AccessorFactory.getPageAccessor(navStateModel, null);
var pageID = pageAccessor.getPageID();
var navigationModel = com.ibm.mashups.enabler.navigation.Factory.getNavigationModel();
var page = navigationModel.find(pageID).start();
var lm = navigationModel.getLayoutModel(page);
return lm;
};
com.ibm.mm.builder.utils.pageUtil.getLayoutControlByWidgetId = function(widgetId){
var lm = com.ibm.mm.builder.utils.pageUtil.getLayoutModel();
var layoutControl = lm.find(widgetId).start();
if (!layoutControl) {
// now we try to find it through a loop as the above assumption is actually invalid and should not have been made
layoutControl = com.ibm.mm.builder.utils.pageUtil.getLayoutControlByWidgetIdContinue(lm.getRoot().start(), widgetId);
}
return layoutControl;
};
com.ibm.mm.builder.utils.pageUtil.getLayoutControlByWidgetIdContinue = function(node, widgetId) {
var ret = null;
var lm = com.ibm.mm.builder.utils.pageUtil.getLayoutModel();
if (node.getLayoutNodeType() == com.ibm.mashups.enabler.layout.Constants.LAYOUT_CONTAINER) {
if (lm.hasChildren(node)) {
var childrenIter = lm.getChildren(node);
while (childrenIter.hasNext()) {
ret = com.ibm.mm.builder.utils.pageUtil.getLayoutControlByWidgetIdContinue(childrenIter.next(), widgetId);
if (ret) {
return ret;
}
}
}
}
else if (node.getLayoutNodeType() == com.ibm.mashups.enabler.layout.Constants.LAYOUT_CONTROL) {
var wm = com.ibm.mashups.enabler.widget.Factory.getWidgetModel();
var testWidgetId = wm.getWidgetWindow(node).start().getID();
if (testWidgetId == widgetId) {
return node;
}
}
return ret;
};
}
if(!dojo._hasResource["com.ibm.mm.builder.utils.navigationUtil"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.utils.navigationUtil"] = true;
/**
*/
dojo.provide("com.ibm.mm.builder.utils.navigationUtil");
dojo.require("dojo.data.ItemFileWriteStore");
dojo.require("dojo.cookie");
/**
* Return navigation model, if refresh is true, the cache will be clean and retrieve the model again.
* @param {boolean} refresh
* @param {string} id
*/
(function(){
var enabler = com.ibm.mashups.enabler;
var builder = com.ibm.mm.builder;
var strategy = enabler.strategy;
var ef = enabler.model.Factory;
var ems = enabler.model.state;
var af = ems.AccessorFactory;
var pageUtil = builder.utils.pageUtil;
var userUtil = builder.utils.userUtil;
var spaceUtil = builder.utils.spaceUtil;
var cs = com.ibm.mashups.services.ServiceManager.getService(enabler.services.ConfigService.SERVICE_NAME);
var es = com.ibm.mashups.services.ServiceManager.getService("eventService");
var logger = enabler.logging.Logger.getLogger("com.ibm.mm.builder.utils.navigationUtil");
var navigationUtil = {
getNavigationModel: function(doNotPreload){
if (!this._navModel) {
var _navModel = ef.getNavigationModel();
// list loadahead strategy
var llaStrategy = new strategy.ListLoadAheadStrategy(com.ibm.mm.builder.constant.NavigationPageSize);
var strats = [];
var isFromHub = dojo.trim(ibmConfig["com.ibm.mashups.builder.contentShelf.mode"] || "") == "hub";
if (isFromHub) {
strats = [llaStrategy];
} else {
var ulaStrategy = new strategy.UserLoadAheadStrategy(true);
ulaStrategy.setUserModel(builder.utils.userUtil.getUserModel());
strats = [llaStrategy, ulaStrategy];
}
for(var i=0; i= 400) {
if (request.responseText) {
retVal = request.responseText;
}
else {
var bundle = dojo.i18n.getLocalization("com.ibm.mm.builder", "coreWidgetsMessages");
retVal = dojo.string.substitute(bundle.E_PUB_API_MOVE_PAGE_1,[request.statusCode]);
}
}
}
}, null, true);
deferred.setFinishedCallback( function(result) {
if (result.statusCode < 400) {
es.broadcastEvent("com.ibm.mashups.builder.refreshNavigation");
}
}, null, true);
deferred.start(true);
}
// @Stephan #11481 End
} catch (e) {
retVal = e.message;
logger.severe("reorderPageNode", retVal);
}
return retVal;
},
getReorderPageContext: function(pageId, position) {
var navigationModel = this.getNavigationModel(),
page = pageUtil.getPageNode(pageId),
parent = null,
next = null;
switch (position) {
case "previous":
parent = navigationModel.getParent(pageId).start();
next = page;
break;
case "next":
parent = navigationModel.getParent(pageId).start();
var childrenIter = navigationModel.getChildren(parent);
while (childrenIter.hasNext()) {
var child = childrenIter.next();
if (child.getID() === pageId) {
next = childrenIter.next();
break;
}
}
break;
default: // children as default
parent = page;
}
return {
parent: parent,
next: next
};
},
getPageContext: function(pageId) {
var navigationModel = this.getNavigationModel(),
page = pageUtil.getPageNode(pageId),
parent = null,
next = null,
previous = null;
parent = navigationModel.getParent(pageId).start();
var childrenIter = navigationModel.getChildren(parent);
while (childrenIter.hasNext()) {
var child = childrenIter.next();
if (child.getID() === pageId) {
if(childrenIter.hasNext()){
next = childrenIter.next();
}
break;
}
previous=child;
}
return {parent:parent,previous:previous,next:next};
},
/**
* Check if descendantPage is descendant of parent
* @param {String} parentPageId
* @param {String} descendantPageId
* @param {int} generation .null/0 unlimited, 1 direct child, 2 grand child, etc
*/
isDescendant: function(parentPageId, descendantPageId,generation){
var navigationModel = this.getNavigationModel();
var rootId = this.getNavigationRootNodeId();
var pageId = descendantPageId;
if(!generation || generation<=0){
generation=0;
}
var currentGen=0;
while (parentPageId !== pageId) {
var parent = navigationModel.getParent(pageId).start();
if (!parent) { return false; }
pageId = parent.getID();
currentGen++;
if(generation>0 && currentGen >=generation){
//generation is set, break when currentGen is no less the requiredGeneration
break;
}
if (rootId === pageId) {
break;
}
}
if(generation<=0 || currentGen ==generation ){
return parentPageId === pageId;
}else {
return false;
}
},
isPortal: function() {
if (ibmCfg.portalConfig.portalContext) {
return true;
}
return false;
},
isLastPageWhenLogin: function() {
// 18968: return true in a portal environment
if (this.isPortal()) {
return true;
}
try {
var u = com.ibm.mm.builder.utils.userUtil.getCurrentUser();
return u.getAttribute("com.ibm.mashups.user.WHERE_TO_GO_WHEN_LOGIN") === "lastpage";
} catch (e) {
return true;
}
},
setPageIDCookie: function(pageID) {
// don't do this on Portal
if (this.isPortal()) {
return;
}
dojo.cookie("url_pid", "pid="+pageID, {path: "/"});
},
updateSpaceTitleInNavBar: function() {
var currentSpace = com.ibm.mm.builder.utils.spaceUtil.getCurrentSpaceNode();
var globalSpaceId = dojo.cookie(com.ibm.mm.builder.constant.cookieKey_globalPageOpenedSpaceId);
if (globalSpaceId) {
currentSpace = com.ibm.mm.builder.utils.spaceUtil.getSpaceNode(globalSpaceId);
}
var spanNode = dojo.query("span#spaceName")[0];
if(spanNode) {
var oldNode = dojo.query("h2",spanNode);
if(oldNode[0]) {
var n = spanNode.removeChild(oldNode[0]);
dojo.destroy(n);
}
currentSpaceTitle = currentSpace? com.ibm.mm.builder.utils.enablerUtil.getNodeTitle(currentSpace):null;
if (currentSpaceTitle) {
var newNode = dojo.create("h2", {
innerHTML: currentSpaceTitle
}, spanNode);
dojo.style(newNode, "width", "auto");
dojo.style(newNode, "padding", "15px 20px 0px");
}
}
}
};
com.ibm.mm.builder.utils.navigationUtil = navigationUtil;
})();
}
if(!dojo._hasResource["com.ibm.mm.builder.utils.acModelUtil"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.utils.acModelUtil"] = true;
/**
*/
dojo.provide("com.ibm.mm.builder.utils.acModelUtil");
com.ibm.mm.builder.utils.acModelUtil.VIEW = 0;
com.ibm.mm.builder.utils.acModelUtil.PERSONALIZE = 1;
com.ibm.mm.builder.utils.acModelUtil.EDIT = 2;
com.ibm.mm.builder.utils.acModelUtil.OWNER = 3;
com.ibm.mm.builder.utils.acModelUtil.getUserPermission = function(pageId) {
var navigationModel = com.ibm.mm.builder.utils.navigationUtil.getNavigationModel();
var navigationNode = navigationModel.find(pageId).start(true);
var contentNode = navigationNode.getContent().start(true);
if(navigationNode.getMetaData("com.ibm.portal.static.page.file.name.html")) {
if(contentNode.confirmSetStaticMarkup("")) {
return com.ibm.mm.builder.utils.acModelUtil.EDIT;
}
} else {
if(contentNode.hasRole(com.ibm.mashups.enabler.ac.RoleType.ADMIN) ||
contentNode.hasRole(com.ibm.mashups.enabler.ac.RoleType.EDITOR) ||
contentNode.hasRole("Privileged User")){
return com.ibm.mm.builder.utils.acModelUtil.EDIT;
}
}
return com.ibm.mm.builder.utils.acModelUtil.VIEW;
};
com.ibm.mm.builder.utils.acModelUtil.getPageOwner = function(pageId){
if (!pageId) { return null; }
var spaceId = com.ibm.mm.builder.utils.spaceUtil.getSpaceIdByPageId(pageId);
var navigationModel = com.ibm.mm.builder.utils.navigationUtil.getNavigationModel();
var layoutModel = navigationModel.getLayoutModel(pageId);
var layoutNode = layoutModel.getRoot().start();
var acModel = null;
if (!spaceId) {
// personal page
acModel = com.ibm.mashups.enabler.ac.AccessControlModelFactory.getAccessControlModel(layoutNode);
}
else {
var spaceModel = com.ibm.mm.builder.utils.spaceUtil.getSpaceModel();
var space = spaceModel.find(spaceId).start();
acModel = com.ibm.mashups.enabler.ac.AccessControlModelFactory.getAccessControlModel(space, layoutNode);
}
var pageOwner = acModel.getOwner();
if (pageOwner) { return pageOwner; }
return null;
};
com.ibm.mm.builder.utils.acModelUtil.getSpaceOwner = function(spaceId){
var space = com.ibm.mm.builder.utils.spaceUtil.getSpaceNode(spaceId);
var acModel = com.ibm.mashups.enabler.ac.AccessControlModelFactory.getAccessControlModel(space);
return acModel.getOwner();
};
/*
* @deprecated, repalce with isPageOwner
* @param {Object} pageId
*/
com.ibm.mm.builder.utils.acModelUtil.isOwner = function(pageId){
var pageOwner = com.ibm.mm.builder.utils.acModelUtil.getPageOwner(pageId);
if (pageOwner) {
var currentUserId = com.ibm.mm.builder.utils.userUtil.getCurrentUserID();
if (pageOwner.getID() == currentUserId) { return true; }
}
return false;
};
com.ibm.mm.builder.utils.acModelUtil.getViewers = function(acModel){
return com.ibm.mm.builder.utils.acModelUtil.getMemberListFromRoleModel(com.ibm.mashups.enabler.ac.RoleType.USER,acModel);
};
com.ibm.mm.builder.utils.acModelUtil.getEditors = function(acModel){
return com.ibm.mm.builder.utils.acModelUtil.getMemberListFromRoleModel(com.ibm.mashups.enabler.ac.RoleType.EDITOR,acModel);
};
/**
* Add the input id (user or group id)
* memberIds:JSON object, format like
* {memberId:membertype}
* membertype can be either "user" or "group"
*/
com.ibm.mm.builder.utils.acModelUtil.addViewers = function(acModel,memberIds){
com.ibm.mm.builder.utils.acModelUtil.insertMemberWithRoleType(acModel,memberIds,com.ibm.mashups.enabler.ac.RoleType.USER);
};
com.ibm.mm.builder.utils.acModelUtil.addEditors = function(acModel,memberIds){
com.ibm.mm.builder.utils.acModelUtil.insertMemberWithRoleType(acModel,memberIds,com.ibm.mashups.enabler.ac.RoleType.EDITOR);
};
com.ibm.mm.builder.utils.acModelUtil.insertMemberWithRoleType = function(acModel, memberIds, roleType){
if(!memberIds){
return;
}
var roleModel = acModel.getRoleModel();
var role = com.ibm.mm.builder.utils.acModelUtil.createRole(acModel, roleModel, roleType);
if (role) {
var memberModel = roleModel.getMemberModel(role);
if (memberModel) {
for (var memberId in memberIds) {
if (Object.prototype.hasOwnProperty.call(memberIds,memberId)) {
var newNode = memberModel.create({
type: memberIds[memberId],
id: memberId
});
memberModel.insert(newNode, null);
}
}
}
}
};
com.ibm.mm.builder.utils.acModelUtil.createRole = function(acModel, roleModel, roleType){
roleModel.setCursorPosition(0);
var iterator = roleModel.iterator();
if (!iterator) { return; }
var role = null;
while (iterator.hasNext()) {
role = iterator.next();
if (!role) { continue; }
if (role.getRoleType() == roleType) {
return role;
}
}
role = roleModel.create({ roletype: roleType });
roleModel.insert(role, null);
return role;
};
com.ibm.mm.builder.utils.acModelUtil.getPageAC = function(pageId){
if (!pageId) { return null; }
var acModel = null;
var navigationModel = com.ibm.mm.builder.utils.navigationUtil.getNavigationModel();
var page = navigationModel.find(pageId).start();
var type = page.getNavigationElementType();
if (type == com.ibm.mashups.enabler.navigation.Constants.NAVIGATION_PAGE) {
var layoutModel = navigationModel.getLayoutModel(pageId);
var layoutNode = layoutModel.getRoot().start();
var spaceId = com.ibm.mm.builder.utils.spaceUtil.getSpaceIdByPageId(pageId);
if (spaceId) {
//page in space
var spaceModel = com.ibm.mm.builder.utils.spaceUtil.getSpaceModel();
var space = spaceModel.find(spaceId).start();
acModel = com.ibm.mashups.enabler.ac.AccessControlModelFactory.getAccessControlModel(space, layoutNode);
}
else {
//page in personal space
acModel = com.ibm.mashups.enabler.ac.AccessControlModelFactory.getAccessControlModel(layoutNode);
}
return acModel;
} else if (type == com.ibm.mashups.enabler.navigation.Constants.NAVIGATION_LABEL) {
return null;
} else {
return null;
}
};
com.ibm.mm.builder.utils.acModelUtil.getPersonalPageAC = function(pageId) {
var navigationModel = com.ibm.mm.builder.utils.navigationUtil.getNavigationModel();
navigationModel.find(pageId).start();
var layoutModel = navigationModel.getLayoutModel(pageId);
var layoutNode = layoutModel.getRoot().start();
var acModel = com.ibm.mashups.enabler.ac.AccessControlModelFactory.getAccessControlModel(layoutNode);
return acModel;
};
com.ibm.mm.builder.utils.acModelUtil.getSpacePageAC = function(spaceId,pageId){
var spaceModel = com.ibm.mm.builder.utils.spaceUtil.getSpaceModel();
var space = spaceModel.find(spaceId).start();
var navigationModel = com.ibm.mm.builder.utils.navigationUtil.getNavigationModel();
navigationModel.find(pageId).start();
var layoutModel = navigationModel.getLayoutModel(pageId);
var layoutNode = layoutModel.getRoot().start();
return com.ibm.mashups.enabler.ac.AccessControlModelFactory.getAccessControlModel(space,layoutNode);
};
com.ibm.mm.builder.utils.acModelUtil.canEditSpace = function(spaceId){
var space = com.ibm.mm.builder.utils.spaceUtil.getSpaceNode(spaceId);
var ea = com.ibm.mashups.enabler.ac.AccessFactory.getEffectiveAccess(space);
if (ea.hasRole("editor") || ea.hasRole("manager")) {
return true;
}
return false;
};
com.ibm.mm.builder.utils.acModelUtil.getSpaceAC = function(spaceId){
if (!spaceId) {
return null;
}
var spaceModel = com.ibm.mm.builder.utils.spaceUtil.getSpaceModel();
var space = spaceModel.find(spaceId).start();
return com.ibm.mashups.enabler.ac.AccessControlModelFactory.getAccessControlModel(space);
};
com.ibm.mm.builder.utils.acModelUtil.getAllMembersInModel = function(acModel){
var memberList = [];
if (acModel.isInitialized()) {
var roleModel = acModel.getRoleModel();
roleModel.setCursorPosition(0);
var iterator = roleModel.iterator();
if (iterator) {
while (iterator.hasNext()) {
var role = iterator.next();
if (!role) {
continue;
}
var memberModel = roleModel.getMemberModel(role);
if (!memberModel) {
continue;
}
memberModel.setCursorPosition(0);
var iterator2 = memberModel.iterator();
if (!iterator2) {
continue;
}
while (iterator2.hasNext()) {
var member = iterator2.next();
if (!member) {
continue;
}
memberList.push(member.getEntity());
}
}
}
}
return memberList;
};
com.ibm.mm.builder.utils.acModelUtil.getMemberListFromRoleModel = function(roleType, acModel){
var memberList = [];
if (acModel.isInitialized()) {
var roleModel = acModel.getRoleModel();
roleModel.setCursorPosition(0);
var iterator = roleModel.iterator();
if (!iterator) {
return memberList;
}
while (iterator.hasNext()) {
var role = iterator.next();
if (!role || (role.getRoleType() != roleType)) {
continue;
}
var memberModel = roleModel.getMemberModel(role);
if (!memberModel) {
continue;
}
memberModel.setCursorPosition(0);
var iterator2 = memberModel.iterator();
if (!iterator2) {
continue;
}
while (iterator2.hasNext()) {
var member = iterator2.next();
if (!member) {
continue;
}
memberList.push(member.getEntity());
}
}
}
return memberList;
};
com.ibm.mm.builder.utils.acModelUtil.removeAllMembers = function(acModel){
com.ibm.mm.builder.utils.acModelUtil.removeViewers(acModel);
com.ibm.mm.builder.utils.acModelUtil.removeEditors(acModel);
};
com.ibm.mm.builder.utils.acModelUtil.removeViewers = function(acModel,removeIdList){
com.ibm.mm.builder.utils.acModelUtil.removeMembersWithRoleType(acModel,com.ibm.mashups.enabler.ac.RoleType.USER,removeIdList);
};
com.ibm.mm.builder.utils.acModelUtil.removeEditors = function(acModel,removeIdList){
com.ibm.mm.builder.utils.acModelUtil.removeMembersWithRoleType(acModel,com.ibm.mashups.enabler.ac.RoleType.EDITOR,removeIdList);
};
com.ibm.mm.builder.utils.acModelUtil.removeMembersWithRoleType = function(acModel, roleType,removeIdList){
var currentUserId = com.ibm.mm.builder.utils.userUtil.getCurrentUserID();
var needRemoveAll = (arguments.length == 2);
if(!needRemoveAll && !removeIdList){ return; }
var roleModel = acModel.getRoleModel();
roleModel.setCursorPosition(0);
var iterator = roleModel.iterator();
if (!iterator) { return; }
while (iterator.hasNext()) {
var role = iterator.next();
if (!role || (role.getRoleType() != roleType)) {
continue;
}
var memberModel = roleModel.getMemberModel(role);
if (!memberModel) {
continue;
}
memberModel.setCursorPosition(0);
var iterator2 = memberModel.iterator();
if (!iterator2) {
continue;
}
while (iterator2.hasNext()) {
var member = iterator2.next();
if (!member) {
continue;
}
var entity = member.getEntity();
if (entity.getID() != currentUserId) {
if (!needRemoveAll) {
for (var id in removeIdList) {
if ((entity.getID() == id) && (entity.getEntityType() == removeIdList[id])) {
memberModel.remove(member);
break;
}
}
}
else {
memberModel.remove(member);
}
}
}
}
};
com.ibm.mm.builder.utils.acModelUtil.isPageOwner = function(pageId){
return this.isOwner(pageId);
};
com.ibm.mm.builder.utils.acModelUtil.isSpaceOwner = function(space){
if (!space) { return false; }
if (!space.declaredClass) {
space = com.ibm.mm.builder.utils.spaceUtil.getSpaceNode(space);
}
if (space) {
var owner = this.getSpaceOwner(space.getID());
if (owner) {
return owner.getID() === com.ibm.mm.builder.utils.userUtil.getCurrentUserID();
}
}
return false;
};
}
if(!dojo._hasResource["com.ibm.mm.builder.utils.iwidgetUtil"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.utils.iwidgetUtil"] = true;
dojo.provide("com.ibm.mm.builder.utils.iwidgetUtil");
dojo.require("dojox.uuid.Uuid");
dojo.require("dojox.uuid.generateTimeBasedUuid");
com.ibm.mm.builder.utils.iwidgetUtil.LOGGER = com.ibm.mashups.enabler.logging.Logger.getLogger("com.ibm.mm.builder.utils.iwidgetUtil");
/**
*
* @param {Object} att iWidgetAttribute
*/
com.ibm.mm.builder.utils.iwidgetUtil.dumpItemSetsToJSON = function(att) {
var obj = {};
dojo.forEach(att.getAllNames(), function(name) {
obj[name] = att.getItemValue(name);
});
return dojo.toJson(obj);
};
com.ibm.mm.builder.utils.iwidgetUtil.loadItemSetsFromJSON = function(att, jsonStr) {
if (jsonStr) {
var obj = dojo.fromJson(jsonStr);
for (var key in obj) {
if(Object.prototype.hasOwnProperty.call(obj,key)) {
att.setItemValue(key, obj[key], false);
}
}
}
};
com.ibm.mm.builder.utils.iwidgetUtil.loadItemSetsFromJSONObject = function(att, jsonObj) {
if (jsonObj) {
for (var key in jsonObj) {
if(Object.prototype.hasOwnProperty.call(jsonObj,key)) {
att.setItemValue(key, jsonObj[key], false);
}
}
}
};
/**
* Return the widget instance icon
* @param {String} widgetInstanceId - this widget instance id
*/
com.ibm.mm.builder.utils.iwidgetUtil.getWidgetInstanceIcon = function(widgetInstanceId) {
var widgetModel = com.ibm.mashups.iwidget.model.Factory.getGlobalWidgetModel().find(widgetInstanceId);
if (!widgetModel) {
return com.ibm.mm.builder.constant.generic_widget_icon;
}
else {
var iconValue = widgetModel.getIWidgetInstance().getIDescriptorItems().getItemValue("icon");
var iconValue2 = com.ibm.mashups.enabler.utils.EndpointHelper.resolve(iconValue);
var retVal = iconValue2 || com.ibm.mm.builder.constant.generic_widget_icon;
if (builderConfig.isBidi) {
return this.getRtlIconUrl(retVal);
}
return retVal;
}
};
/**
* Return the widget instance title
* @param {String} widgetInstanceId - this widget instance id
*/
com.ibm.mm.builder.utils.iwidgetUtil.getOriginalWidgetInstanceTitle = function(widgetInstanceId) {
var widgetModel = com.ibm.mashups.iwidget.model.Factory.getGlobalWidgetModel().find(widgetInstanceId);
if (!widgetModel) {
return null;
}
var idi = widgetModel.getIWidgetInstance().getIDescriptorItems();
return unescape(idi.getItemValue("title", dojo.locale) || idi.getItemValue("title", ibmConfig["default.locale"]));
};
com.ibm.mm.builder.utils.iwidgetUtil.getWidgetInstanceTitle = function(widgetInstanceId) {
return com.ibm.mm.builder.utils.htmlUtil.escapeString(this.getOriginalWidgetInstanceTitle(widgetInstanceId));
};
/**
* This is a helper method; It is convenient to save the widget title and title in ItemSet
* @param {String} widgetInstanceId - this widget instance id
* @param {String} title - the new title for this widget instance
* @param {String} iconUrl - the url of icon
*/
com.ibm.mm.builder.utils.iwidgetUtil.saveWidgetInstanceTitleAndIcon = function(widgetInstanceId, title, iconUrl) {
this.saveWidgetInstanceTitle(widgetInstanceId, title, dojo.locale);
this.saveWidgetInstanceIcon(widgetInstanceId, iconUrl);
};
/**
* Save the widget instance title
* @param {String} widgetInstanceId - this widget instance id
* @param {String} title - the new title for this widget instance
* @param {String} locale - the locale for this title; used in v2.0
*/
com.ibm.mm.builder.utils.iwidgetUtil.saveWidgetInstanceTitle = function(widgetInstanceId, title, locale) {
var widgetModel = com.ibm.mashups.iwidget.model.Factory.getGlobalWidgetModel().find(widgetInstanceId);
if (widgetModel) {
// formalize locale, zh-TW
var separator = "-";
var localeParts = locale.split("-");
if (localeParts.length == 1) {
localeParts = locale.split("_");
separator = "_";
}
if (localeParts.length >= 2) {
localeParts[1] = localeParts[1].toUpperCase();
}
var formattedLocale = "";
for (var i = 0; i < localeParts.length; i++) {
formattedLocale = formattedLocale + localeParts[i];
if (i < localeParts.length - 1) {
formattedLocale = formattedLocale + separator;
}
}
var widgetInstance = widgetModel.getIWidgetInstance();
var md = widgetInstance.getIDescriptorItems();
md.setItemValue("title", escape(title), false, formattedLocale);
com.ibm.mashups.iwidget.model.Factory.getGlobalWidgetModel().commit().start();
}
};
com.ibm.mm.builder.utils.iwidgetUtil.formatWidgetTitle = function(title) {
if (!title) {
return '';
}
return title.replace(/^( )*/, "").replace(//g, ">");
};
/**
* Save the widget instance icon
* @param {String} widgetInstanceId - this widget instance id
* @param {String} iconUrl
*/
com.ibm.mm.builder.utils.iwidgetUtil.saveWidgetInstanceIcon = function(widgetInstanceId, iconUrl) {
var widgetInstance = this.getiWidgetWrapper(widgetInstanceId);
var md = widgetInstance.getIDescriptorItems();
if (!iconUrl) {
iconUrl = "/wps/mccbuilder.v3001/images/generic_widget_icon.gif";
}
md.setItemValue("icon", iconUrl);
com.ibm.mashups.iwidget.model.Factory.getGlobalWidgetModel().commit().start();
};
com.ibm.mm.builder.utils.iwidgetUtil.getRtlIconUrl = function(ltrIcon) {
//returns immediately if the icon is converted to rtl already
if (!ltrIcon || ltrIcon.match("_rtl")) {
return ltrIcon;
}
var rtlIcon = ltrIcon;
/*
* getRtlIconToTest will return the RTL version of the LTR filename. For example,
* if the LTR file is actiontimer.png, actiontimer_rtl.png will be returned.
*/
var tmpRtlIconUrl = this.getRtlIconToTest(ltrIcon);
try {
var xhr = this.getXhr();
if (xhr && tmpRtlIconUrl) {
xhr.onreadystatechange = function() {
};
xhr.open("HEAD", tmpRtlIconUrl, false);
xhr.send(null);
/*
* If the _rtl image file exists, its URL
* will be assigned to rtlIcon. The
* below condition will be true when the HEAD
* request returns with a success status indicating
* that the file was found.
*/
if (xhr.readyState == 4 && xhr.status == 200) {
rtlIcon = tmpRtlIconUrl;
}
}
}
catch (err) {//Quietly handle error, icon will be set to default ltr value
}
return rtlIcon;
};
com.ibm.mm.builder.utils.iwidgetUtil.getRtlIconToTest = function(ltrIcon) {
if (!ltrIcon) {
return ltrIcon;
}
var index = ltrIcon.lastIndexOf(".");
var filePrefix = ltrIcon.substr(0, index);
var fileSuffix = ltrIcon.substr(index + 1);
return filePrefix.concat("_rtl.", fileSuffix);
};
com.ibm.mm.builder.utils.iwidgetUtil.getXhr = function() {
if (window.ActiveXObject) { // if IE
try {
return new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
return new ActiveXObject("Microsoft.XMLHTTP");
}
catch (err) {
return;
}
}
}
else if (window.XMLHttpRequest) { // if Mozilla, Safari, etc.
return new XMLHttpRequest();
}
};
/**
* Save the widget instance title
* @param {String} widgetInstanceId the container node of script elements
*/
com.ibm.mm.builder.utils.iwidgetUtil.getiWidgetWrapper = function(widgetInstanceId) {
return com.ibm.mashups.iwidget.model.Factory.getGlobalWidgetModel().find(widgetInstanceId).getIWidgetInstance();
};
com.ibm.mm.builder.utils.iwidgetUtil.updateWidgetIDescriptor = function(widgetInstanceId, widgetMD) {
var widgetModel = com.ibm.mashups.iwidget.model.Factory.getGlobalWidgetModel().find(widgetInstanceId);
if (widgetModel) {
var widgetInstance = widgetModel.getIWidgetInstance();
var md = widgetInstance.getIDescriptorItems();
var iconUrl = widgetMD.getIconURL(false);
if (!iconUrl) {
iconUrl = "/wps/mccbuilder.v3001/images/generic_widget_icon.gif";
}
md.setItemValue("icon", iconUrl);
dojo.forEach(widgetMD.getLocales(), function(l) {
md.setItemValue("title", escape(widgetMD.getTitle(l)), false, l);
});
com.ibm.mashups.iwidget.model.Factory.getGlobalWidgetModel().commit().start();
}
};
com.ibm.mm.builder.utils.iwidgetUtil.definitionMap = {};
com.ibm.mm.builder.utils.iwidgetUtil.updateWidgetInstance = function(widgetInstanceNode, widgetDefinitionId) {
var self = com.ibm.mm.builder.utils.iwidgetUtil;
if (widgetDefinitionId) {
self.definitionMap[widgetInstanceNode.id] = widgetDefinitionId;
}
dojo.publish("/com/ibm/mashups/livetext/livetextchanged", [widgetInstanceNode, false, // preProcessCallback
function(domNode, tagArray) {
}, // postProcessCallback
function(domNode, tagArray, allErrors) {
var widgetmodel = com.ibm.mashups.iwidget.model.Factory.getGlobalWidgetModel().find(widgetInstanceNode.id);
if (widgetmodel) {
var wdid = self.definitionMap[widgetInstanceNode.id];
if (wdid) {
var widgetMD = com.ibm.mm.builder.utils.toolboxUtil.getWidgetDefinition(wdid);
//self.saveWidgetInstanceTitleAndIcon(widgetInstanceNode.id, com.ibm.mm.builder.utils.enablerUtil.getNodeTitle(widgetMD), widgetMD.getIconURL());
self.updateWidgetIDescriptor(widgetInstanceNode.id, widgetMD);
self.definitionMap[widgetInstanceNode.id] = null;
//com.ibm.mm.builder.utils.iwidgetUtil.invokeCallbackByWidgetInstanceId(widgetInstanceNode.id, function(){
// com.ibm.mashups.services.ServiceManager.getService("eventService").broadcastEvent("com.ibm.mashups.builder.autoWiringWidget", widgetInstanceNode.id);
//});
}
com.ibm.mm.builder.utils.skinUtil.updateTitleAndIcon(widgetInstanceNode.id);
}
}
]);
};
/**
* Return the widget definition xml file url
* @param {String} widgetId widget id
*/
com.ibm.mm.builder.utils.iwidgetUtil.getWidgetXMLURL = function(widgetId) {
var def = dojo.query(".mm_Definition", dojo.byId(widgetId))[0];
if (!def) {
def = dojo.query(".iw-Definition", dojo.byId(widgetId))[0];
}
if (def) {
return def.getAttribute("href");
}
else {
return "";
}
};
com.ibm.mm.builder.utils.iwidgetUtil._getUid = function() {
return "ns_" + dojox.uuid.generateTimeBasedUuid().replace(/\-/g, "");
};
//load system widgets
com.ibm.mm.builder.utils.iwidgetUtil.loadWidgets = function(/*Dom Node*/div, /*Function*/ callback) {
dojo.publish("/com/ibm/mashups/livetext/livetextchanged", [div, false, // preProcessCallback
function(domNode, tagArray) {
//do something before loading widgets
var widgetNumInTheme = tagArray.length;
var widgetLoadedCount = 0;
/*
var cb = function(){
widgetLoadedCount++
if (widgetLoadedCount == widgetNumInTheme) {
if(callback)callback();
}
}
dojo.forEach(tagArray, function(tag){dojo.subscribe(com.ibm.mashups.iwidget.Constants.WIDGET_LOADED + "."+tag.id, this, cb);})
*/
var cb = function() {
widgetLoadedCount++;
if (widgetLoadedCount == widgetNumInTheme) {
if (callback) {
callback();
}
}
};
dojo.forEach(tagArray, function(tag) {
var lazyLoad = tag.getAttribute("lazyLoad");
if (!lazyLoad || (lazyLoad && lazyLoad != "true")) {
dojo.subscribe(com.ibm.mashups.iwidget.Constants.WIDGET_LOADED + "." + tag.id, this, cb);
}
else {
cb();
}
});
}, // postProcessCallback
function(domNode, tagArray, allErrors) {
}
]);
};
com.ibm.mm.builder.utils.iwidgetUtil.toggleMarkedSandboxWidget = function(widgetDefId) {
var tu = com.ibm.mm.builder.utils.toolboxUtil;
var needMarkSandbox = this.isMarkedSandboxWidget(widgetDefId) ? "false" : "true";
tu.getWidgetDefinition(widgetDefId).setMetadata("sandbox_user", needMarkSandbox);
tu.getCatalogModel().commit().start();
return needMarkSandbox == "true";
};
com.ibm.mm.builder.utils.iwidgetUtil.isWidgetTrusted = function (widgetDefId) {
var cs = com.ibm.mashups.services.ServiceManager.getService(com.ibm.mashups.enabler.services.ConfigService.SERVICE_NAME);
var sandboxEnabled = cs.getValue(com.ibm.mashups.enabler.services.ConfigConstants.SANDBOXENABLED);
if (!sandboxEnabled) return false;
return com.ibm.mm.builder.utils.iwidgetUtil.isTrustedWidget(widgetDefId);
}
com.ibm.mm.builder.utils.iwidgetUtil.isMarkedSandboxWidget = function(widgetDefId) {
return "true" == com.ibm.mm.builder.utils.toolboxUtil.getWidgetDefinition(widgetDefId).getMetadata("sandbox_user");
};
com.ibm.mm.builder.utils.iwidgetUtil.isSandboxWidget = function(widgetDefId) {
return "true" == com.ibm.mm.builder.utils.toolboxUtil.getWidgetDefinition(widgetDefId).getMetadata("sandbox_definition");
};
com.ibm.mm.builder.utils.iwidgetUtil.isDisabledSandboxWidget = function(widgetDefId) {
if (!this.diabledSandboxList) {
if (dojo.isString(builderConfig.sandboxDisabled)) {
this.diabledSandboxList = [builderConfig.sandboxDisabled];
}
else {
this.diabledSandboxList = builderConfig.sandboxDisabled;
}
}
if (this.diabledSandboxList.length === 0) {
return false;
}
var widgetDefUrl = com.ibm.mm.builder.utils.toolboxUtil.getWidgetDefinition(widgetDefId).getDefinitionURL(false);
for (var i = 0; i < this.diabledSandboxList.length; i++) {
if (dojo.trim(widgetDefUrl) === dojo.trim(this.diabledSandboxList[i])) {
return true;
}
else if (dojo.trim(widgetDefUrl).indexOf(dojo.trim(this.diabledSandboxList[i])) !== -1 && dojo.trim(this.diabledSandboxList[i]).indexOf("/") !== 0) {//check relative path like dataEditor/dataEditor.xml
return true;
}
else if (dojo.trim(widgetDefUrl).indexOf(dojo.trim(this.diabledSandboxList[i])) !== -1 && dojo.trim(this.diabledSandboxList[i]).indexOf("/") === 0 && dojo.trim(widgetDefUrl).indexOf(":") !== -1) { //check absolute path like /dataEditor/dataEditor.xml
//make sure protocol, hostname,port match to window.location.
var buf = widgetDefUrl.split("//");
var protocol = buf[0];
var buf2 = buf[1].split("/");
var host = buf2[0];
if (protocol == window.location.protocol && window.location.host == host) {
return true;
}
else if (protocol == window.location.protocol && protocol == "http:" && host.indexOf(window.location.host) === 0) {
if (host.substr(host.indexOf(":") + 1) == "80") {
return true;
}
}
else if (protocol == window.location.protocol && protocol == "https:" && host.indexOf(window.location.host) === 0) {
if (host.substr(host.indexOf(":") + 1) == "443") {
return true;
}
}
}
}
return false;
};
com.ibm.mm.builder.utils.iwidgetUtil.isTrustedWidget = function(widgetDefId) {
return this.isDisabledSandboxWidget(widgetDefId) || !(this.isSandboxWidget(widgetDefId) || this.isMarkedSandboxWidget(widgetDefId));
};
/**
* This method will leverage subscribeEvent service to make sure the callback is invoked after the widget isntance is created
*
* @param {String} widgetInstanceId
* @param {Function} callback
*/
com.ibm.mm.builder.utils.iwidgetUtil.invokeCallbackByWidgetInstanceId = function(/*string*/widgetInstanceId, /*function*/ callback) {
var handler = null;
if (!widgetInstanceId || !callback) {
return handler;
}
var wm = com.ibm.mashups.iwidget.model.Factory.getGlobalWidgetModel().find(widgetInstanceId);
if (wm && wm.loaded) {
callback();
}
else {
var eventService = com.ibm.mashups.services.ServiceManager.getService("eventService");
handler = eventService.subscribeEvent(com.ibm.mashups.iwidget.Constants.WIDGET_LOADED + "." + widgetInstanceId, null, callback);
}
return handler;
};
com.ibm.mm.builder.utils.iwidgetUtil.hideWidget = function(widgetId) {
var widget = dojo.byId(com.ibm.mm.builder.constant.skinIdPrefix + widgetId);
if (widget) {
widget.style.display = "none";
}
};
com.ibm.mm.builder.utils.iwidgetUtil.showWidget = function(widgetId) {
var widget = dojo.byId(com.ibm.mm.builder.constant.skinIdPrefix + widgetId);
if (widget) {
widget.style.display = "";
}
};
com.ibm.mm.builder.utils.iwidgetUtil.getWidgetSpanByMetadata = function(widgetMD, itemSet) {
var param = null;
var widgetParam = dojo.fromJson(widgetMD.widgetParam);
//store metadata to toolbox widget metadata cache for updating title/icon in skin.
var wmdWithTitleIcon = {
id: widgetMD.id,
_md: widgetMD
};
wmdWithTitleIcon.getID = function() {
return this._md.id;
};
wmdWithTitleIcon.getTitle = function(locale) {
if (!this._md.title) {
return null;
}
return this._md.title[locale];
};
wmdWithTitleIcon.getLocales = function() {
if (!this._md.title) {
return [];
}
if (!this.locales) {
this.locales = [];
for (var l in this._md.title) {
if (Object.prototype.hasOwnProperty.call(this._md.title, l)) {
this.locales.push(l);
}
}
}
return this.locales;
};
wmdWithTitleIcon.getIconURL = function() {
return this._md.icon;
};
com.ibm.mm.builder.utils.toolboxUtil.setWidgetDefinition(wmdWithTitleIcon);
if (widgetParam && widgetParam.length) {
param = com.ibm.mm.builder.utils.iWidgetSpecUtil.newItemSetSpan();
dojo.forEach(widgetParam, function(item) {
com.ibm.mm.builder.utils.iWidgetSpecUtil.newItemSetKeyValue(param, item.itemName, item.itemValue);
});
}
if (itemSet) {
param = param || com.ibm.mm.builder.utils.iWidgetSpecUtil.newItemSetSpan();
for (var key in itemSet) {
if (Object.prototype.hasOwnProperty.call(itemSet, key)) {
var ii = dojo.query("[href='#" + key + "']", param);
if (ii && ii[0]) {
ii[0].innerHTML = itemSet[key];
}
else {
com.ibm.mm.builder.utils.iWidgetSpecUtil.newItemSetKeyValue(param, key, itemSet[key]);
}
}
}
}
var rootSpan = document.createElement("span");
// OpenSocial support change
if (this.widgetType !== null && this.widgetType == "mm_OAGadget") {
dojo.addClass(rootSpan, com.ibm.mm.builder.constant.mmOAGadget);
}
else {
if (this.widgetType !== null && this.widgetType == "mm_OSGadget") {
dojo.addClass(rootSpan, com.ibm.mm.builder.constant.mmGGadget);
}
else {
dojo.addClass(rootSpan, com.ibm.mm.builder.constant.mmIWidget);
}
}
rootSpan.setAttribute(com.ibm.mm.builder.constant.widget_span_attr_id, "" + this._getUid());
var layoutBean = com.ibm.mm.builder.freeLayOutBean || com.ibm.mm.builder.columnLayoutBean;
if (layoutBean) {
rootSpan.setAttribute(com.ibm.mm.builder.constant.widget_span_attr_skin, layoutBean.getSelectedSkin());
}
com.ibm.mm.builder.utils.iWidgetSpecUtil.setWidgetDefXML(rootSpan, widgetMD.definition);
if (com.ibm.mm.builder.widget.sandboxEnabled) {
if (widgetMD.sandbox_definition === "true" || widgetMD.sandbox_user === "true") {
rootSpan.setAttribute("sandbox", "true");
}
}
if (widgetMD['com.ibm.mashups.builder.autoWiringEnabled'] === "true") {
rootSpan.setAttribute("autowiringenabled", "true");
}
if (param) {
rootSpan.appendChild(param);
}
return rootSpan;
};
com.ibm.mm.builder.utils.iwidgetUtil.getWidgetSupportedModes = function(widgetId) {
var modes = null;
var widgetWrapper = com.ibm.mashups.iwidget.model.Factory.getGlobalWidgetModel().find(widgetId);
if (widgetWrapper) {
var getSMDeferred = widgetWrapper.getIWidgetDefinition();
getSMDeferred.setFinishedCallback(function(widgetDef, status) {
if (widgetDef) {
modes = widgetDef.getSupportedModes();
}
});
getSMDeferred.start(false);
}
return modes;
};
com.ibm.mm.builder.utils.iwidgetUtil.isWidgetVisible = function(widgetId) {
var widgetSpan = dojo.byId(widgetId);
if (widgetSpan) {
return widgetSpan.getAttribute("visible") ? eval(widgetSpan.getAttribute("visible")) : false; // JSLINT-IGNORE:
}
return false;
};
com.ibm.mm.builder.utils.iwidgetUtil.getWidgetTitleCSA2 = function(lcId) {
var layoutControl = com.ibm.mm.builder.utils.iwidgetUtil.getLayoutControl(lcId);
var lc = com.ibm.mashups.enabler.context.Factory.getLocalizedContext();
var prefLoc = lc.getPreferredLocale();
var title = layoutControl.getTitle(prefLoc);
if (!title) {
var wm = com.ibm.mashups.enabler.widget.Factory.getWidgetModel();
var widgetWin = wm.getWidgetWindow(layoutControl).start();
if (widgetWin) {
var widgetDef = wm.getWidgetDefinitionByWindow(widgetWin).start();
if (widgetDef) {
title = com.ibm.mashups.enabler.context.Factory.getLocalizedContext().getTitle(widgetDef);
}
}
}
return title || "";
};
com.ibm.mm.builder.utils.iwidgetUtil.getWidgetIconCSA2 = function(lcId) {
var lc = com.ibm.mm.builder.utils.iwidgetUtil.getLayoutControl(lcId);
var icon = lc.getMetaData("thumbnail") || lc.getMetaData("icon");
if (!icon) {
return com.ibm.mm.builder.constant.generic_widget_icon;
} else {
return icon;
}
};
com.ibm.mm.builder.utils.iwidgetUtil.getLayoutControl = function(lcId) {
var pageId = com.ibm.mashups.builder.model.Factory.getRuntimeModel().getCurrentPage().getID();
var navModel = com.ibm.mashups.enabler.navigation.Factory.getNavigationModel();
var currentPage = navModel.find(pageId).start();
var layoutModel = navModel.getLayoutModel(currentPage);
var layoutControl = layoutModel.find(lcId).start();
return layoutControl;
};
}
if(!dojo._hasResource["com.ibm.mm.builder.utils.wireUtil"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.utils.wireUtil"] = true;
/**
* Util class for wiring widget
*/
dojo.provide("com.ibm.mm.builder.utils.wireUtil");
com.ibm.mm.builder.utils.wireUtil.LOGGER = com.ibm.mashups.enabler.logging.Logger
.getLogger("com.ibm.mm.builder.utils.wireUtil");
com.ibm.mm.builder.utils.wireUtil.highlightWidget = function(id) {
var lcDiv = com.ibm.pb.layout.LayoutParser.findById(id);
var coords = dojo.coords(lcDiv);
var scroll = dojo._docScroll();
var highlightDiv = dojo.byId("mmDiv_highlight");
if (!highlightDiv) {
highlightDiv = document.createElement("div");
highlightDiv.id = "mmDiv_highlight";
highlightDiv.style.position = "absolute";
highlightDiv.style.backgroundImage = "url('" + builderConfig.builderPath + "/images/widget_highligh_color.png')";
document.body.appendChild(highlightDiv);
}
highlightDiv.style.display = "none";
highlightDiv.style.cssText += "; left: " + (coords.x + scroll.x) + "px; "
+ "top: " + (coords.y + scroll.y) + "px; "
+ "width: " + coords.w + "px; "
+ "height: " + coords.h + "px; "
+ "zIndex: 780;";
highlightDiv.style.display = "";
};
com.ibm.mm.builder.utils.wireUtil.removeHighlight = function() {
var highlightDiv = dojo.byId("mmDiv_highlight");
if (highlightDiv){
highlightDiv.style.display = "none";
}
};
/**
* Trigger auto wire logic for the specific widget
* @param {Object} lcId: LayoutControl ID
*/
com.ibm.mm.builder.utils.wireUtil.triggerAutowire = function(lcId) {
var isAutoWireEnabled = com.ibm.mashups.builder.model.Factory.getRuntimeModel()
.getCurrentPage().getAutoWiringEnablement();
// If auto wire is enabled on the current page
if(isAutoWireEnabled) {
var widgetAWEnabled = com.ibm.mm.builder.utils.wireUtil.isAutowireEnabled(lcId);
if(widgetAWEnabled) {
com.ibm.mashups.services.ServiceManager.getService("eventService")
.broadcastEvent("com.ibm.mashups.builder.createAutoWire", lcId);
}
}
};
/**
* Check whether the widget is auto wire enabled
* @param {Object} lcId: layout control/widget ID
*/
com.ibm.mm.builder.utils.wireUtil.isAutowireEnabled = function(lcId) {
var lc = com.ibm.mm.builder.utils.wireUtil.getLayoutControl(lcId);
//var autowire = widgetDef.getMetaData("com.ibm.mashups.builder.autoWiringEnabled");
var autowire = lc.getMetaData("onAutoWire");
return (autowire=="true" ? true : false);
};
/**
* @param {Object} lcId: layoutControl ID
* @return {Object} LayoutControl
*/
com.ibm.mm.builder.utils.wireUtil.getLayoutControl = function(lcId) {
var pageId = com.ibm.mashups.builder.model.Factory.getRuntimeModel().getCurrentPage().getID();
var navModel = com.ibm.mashups.enabler.navigation.Factory.getNavigationModel();
var currentPage = navModel.find(pageId).start();
var layoutModel = navModel.getLayoutModel(currentPage);
var layoutControl = layoutModel.find(lcId).start();
return layoutControl;
};
// # 17780 when the same event is both published and handled
// the event object returned by eventProvider.getEvent(eventName) is arbitrary
com.ibm.mm.builder.utils.wireUtil.getEventByNameAndType = function(eventProvider, eventName, type) {
var filter = new Object();
filter[type] = true;
var events = eventProvider.getEvents(filter);
var event = null;
for (var i=0,l=events.length; i ")){
root = root.substr(0,root.length - 2);
root = root + ">\n";
}else{
if (this.endsWith(root,"",true)){
root = root.substr(0,root.length - 6)+"\n";
}else{
return "";
}
}
root = root + left;
root = root + right;
root = root + "";
return root;
};
com.ibm.mm.builder.utils.htmlUtil.getElementById = function(parentNode, tagId) {
var retval = null;
var childTags = parentNode.getElementsByTagName("*");
for (var ii=0; ii0) {
for (var index=0;index 0) {
for (var index=0;index";
}else{
radioString = radioString + ">";
}
return radioString;
};
com.ibm.mm.builder.utils.htmlUtil.getLimitedString = function(text, restrictionNum){
if(!text) {
return "";
}
if(text.length > restrictionNum){
text = text.substr(0, restrictionNum) + "...";
}
return text;
};
/**
* @deprecated
*/
com.ibm.mm.builder.utils.htmlUtil.addShadow = function(domNode,classes) {
for(var i=0; i limitWidth) {
begin -= 1;
}
return (str.substring(0, begin) + "...");
}
var index = begin + Math.round((end - begin) * percentage);
var width_intercepted = this.getStrWidth(str.substring(0, index));
if (width_intercepted < limitWidth) {
begin = index;
end = end;
}else{
begin = begin;
end = index;
}
}
}
};
/*
* Truncate the string in 'textField' of 'node' and provide the whole string in 'tipField' if necessary.
*/
com.ibm.mm.builder.utils.htmlUtil.truncateAllChildNodesText = function(/* DomNode */node,/* String */tipField,/* obj */fontStyle){
dojo.forEach(dojo.query(".truncatedLabel",node),function(item){
com.ibm.mm.builder.utils.htmlUtil.truncateNodeText(item,tipField,fontStyle);
});
};
com.ibm.mm.builder.utils.htmlUtil.truncateNodeText = function(/* DomNode */node,/* String */tipField, /*obj */fontStyle){
var textField = (node.tagName.toLowerCase() === "input") ? "value" : "innerHTML";
if(!tipField){
tipField = "title";
}
var widthLimit = 0;
var str = node[textField];
if(str.length === 0 ){return;}
if (dojo.hasAttr(node, "widthlimit")) {
widthLimit = parseInt(dojo.attr(node, "widthlimit"),10);
}
else {
widthLimit = dojo.contentBox(node).w;
if (widthLimit === 0) {
widthLimit = parseInt(dojo.style(node,"width"),10);
}
}
if (widthLimit > 0) {
var shortStr = com.ibm.mm.builder.utils.htmlUtil.getStrWithLimit(str, node, widthLimit,fontStyle);
if(shortStr.length <= str.length + 2 && !dojo.hasAttr(node,tipField)){
dojo.attr(node,tipField,this.unEscapeString(str));
}
node[textField] = (textField === "innerHTML" && (!dojo.hasAttr(node,"keepBlankSpace"))) ? this.formatBlankSpace(shortStr) : shortStr;
}
};
com.ibm.mm.builder.utils.htmlUtil.truncateAllChildNodesWord = function(node){
dojo.forEach(dojo.query(".wordTruncatedLabel",node),function(item){
com.ibm.mm.builder.utils.htmlUtil.truncateWord(item);
});
};
com.ibm.mm.builder.utils.htmlUtil.truncateWord = function(node,strContent,widthLimit,ignoreEnlarge){
// always truncate if set ignoreEnlarge=true
if(ignoreEnlarge!==true)
if(ibmConfig.fontSizeEnlarged){ return strContent; }
if( !node ){return strContent;}
var textType = (node.tagName.toLowerCase() === "input") ? "value" : "innerHTML";
var str = strContent || node[textType];
if(str.length === 0){ return strContent; }
var wordsArr = str.split(" ");
if (!widthLimit && dojo.hasAttr(node, "widthlimit")) {
widthLimit = parseInt(dojo.attr(node, "widthlimit"),10);
}
var width = widthLimit ? widthLimit : dojo.contentBox(node).w;
dojo.forEach(wordsArr,function(singleWord,index){
wordsArr[index] =com.ibm.mm.builder.utils.htmlUtil.getStrWithLimit(singleWord,node,width);
});
var content = wordsArr.join(" ");
var resultContent = (textType === "innerHTML" && (!dojo.hasAttr(node,"keepBlankSpace"))) ? this.formatBlankSpace(content) : content;
if(!str){
node[textType] = resultContent;
} else{
return resultContent;
}
};
com.ibm.mm.builder.utils.htmlUtil.markTruncation = function(node,widthLimit){
dojo.addClass(node,"truncatedLabel");
dojo.attr(node,"widthLimit",widthLimit);
};
/**
*handle space and line separator
*/
com.ibm.mm.builder.utils.htmlUtil.formatBlankSpace = function(title){
if (!title) {
return "";
}
return title.replace(/\s/g, " ");
};
/*
* This method will replace & with & to avoid incorrect display string &bmp; as an instance.
* it will handle space as well.
*/
com.ibm.mm.builder.utils.htmlUtil.formatDisplayedContent = function(content, noNeedReplaceAmp, noNeedReplaceNbsp){
if (!content) {
return '';
}
if (!noNeedReplaceAmp) {
content = content.replace(/&/g, "&");
}
if (!noNeedReplaceNbsp) {
content = content.replace(/\s/g, " ");
}
return content;
};
com.ibm.mm.builder.utils.htmlUtil.escapeString = function(content){
if (!content) {
return "";
}
return content.replace(/&/g,"&").replace(/"/g,""").replace(//g,">");
};
com.ibm.mm.builder.utils.htmlUtil.unEscapeString = function(content){
if (!content) {
return "";
}
return content.replace(/&/g,"&").replace(/"/g,"\"").replace(/</g,"<").replace(/>/g,">").replace(/ /g," ");
};
/**
*
* @param {String} str the message
*/
com.ibm.mm.builder.utils.htmlUtil.formatMessage = function(str){
if (!str || str.length <= 0) {
return "";
}
else {
var lineSeparatorIndex = str.indexOf("\n");
if (lineSeparatorIndex > 0) {
var firstLine = str.substring(0, lineSeparatorIndex);
var leftLine = str.substring(lineSeparatorIndex);//include '\n'
return "" + firstLine + "" +
leftLine.replace(/\n/g, "
")+ "";
}
else {
return str.replace(/\n/g, "
");
}
}
};
/**
* set the title of node
* @param {String} tileStr the tile of node
* @param {Object} titleNode the node
* @param {Float} limitWidth the width of title
*
*/
com.ibm.mm.builder.utils.htmlUtil.setNodeTitle = function(titleStr, titleNode, limitWidth) {
if (!titleNode || !titleStr) {
return;
}
if(!limitWidth||limitWidth<=0){
try{
var valueStr=this.getCurrentStyle(titleNode,"width");
if(valueStr == "auto") {
limitWidth = dojo.style(titleNode,"width");
}
else if(valueStr.indexOf("%")>-1) {
limitWidth = dojo.coords(titleNode).w;
}
else {
limitWidth = parseFloat(valueStr.match(/\d*\.?\d*/));
}
}catch(e){
limitWidth = null;
}
}
titleNode.title = "";
if(!limitWidth||limitWidth=="auto"){
titleNode.innerHTML =this.formatBlankSpace(titleStr);
return;
}
var _title = this.getStrWithLimit(titleStr, titleNode, limitWidth);
titleNode.innerHTML = this.formatBlankSpace(_title);
if (titleStr != _title) {
titleNode.title = this.unEscapeString(titleStr);
}
};
/**
* set the title of node with font style
* @param {String} tileStr, the tile of node
* @param {Object} titleNode the node
* @param {Float} limitWidth, the width of title
* @param {Map} fontStyle, it should be a map like this {fontSize:"10px", fontFamily:"Sanson", fontWeight:"bold"}
*
*/
com.ibm.mm.builder.utils.htmlUtil.setNodeTitleWithStyle = function(titleStr, titleNode, limitWidth, fontStyle) {
if (!titleNode||!limitWidth||!titleStr||limitWidth<=0||!fontStyle){
return;
}
titleNode.title = "";
var _title = this.getStrWithLimit(titleStr, titleNode, limitWidth, fontStyle);
if(titleNode.tagName == "INPUT"){//button
titleNode.value = _title;
}else{
titleNode.innerHTML = this.formatDisplayedContent(_title);
}
titleNode.title = titleStr;
};
/**
* set label and title under such conditions with limited width
* node.innerHTML = dojo.string.substitute(label,[""+string+""]);
*/
com.ibm.mm.builder.utils.htmlUtil.setCombinedStringInNode = function(label, content, node, limitedWidth, className){
var labelWidth = this.getStrWidth(label, node);
if (labelWidth > limitedWidth) {
var title = dojo.string.substitute(label, [content]);
this.setNodeTitle(title, node, limitedWidth);
return;
}
var tempSpan = document.createElement("span");
tempSpan.className = className;
node.appendChild(tempSpan);
var limitedContent = this.getStrWithLimit(content, tempSpan, limitedWidth - labelWidth);
var _content = dojo.string.substitute(label, ["" + this.formatDisplayedContent(limitedContent) + ""]);
node.removeChild(tempSpan);
node.innerHTML = _content;
if (limitedContent != content) {
node.title = dojo.string.substitute(label, [content]);
}
};
/**
* load a CSS file on the fly.
*/
com.ibm.mm.builder.utils.htmlUtil.loadCss = function(css_url){
this.loadedCss = this.loadedCss || [];
for(var i=0; i div",rootNode)[0];
if(rDiv){ rDiv.style.position = "static"; }
var container = dojo.query(".wrapper",rootNode)[0];
if(container){ container.style.position = "static"; }
}
};
/*fix an ie bug: quotes of the attribute's value on a dom will be removed when use innerHTML to get the content.
*for example: will be in ie
*/
com.ibm.mm.builder.utils.htmlUtil.addMissingQuoteInTitle = function(str){
if(!str){ return ""; }
return str.replace(/title\s*=\s*\${([^}]+)}/g,"title=\"${$1}\""); // JSLINT-IGNORE:
};
}
if(!dojo._hasResource["com.ibm.mm.builder.widget.CustomDialogResizer"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.widget.CustomDialogResizer"] = true;
dojo.provide("com.ibm.mm.builder.widget.CustomDialogResizer");
dojo.require("dojox.layout.ResizeHandle");
dojo.declare("com.ibm.mm.builder.widget.CustomDialogResizer",
[dojox.layout.ResizeHandle], {
innerContainer: null,
innerMargin: null,
oritation: "right",
intLeftRTLOrig:0,
// shadow when resizing dialog
resizeShadow: null,
// onResize: function
// called each time dialog is resized
onResize: null,
templateString: '',
_beginSizing: function(/*Event*/ e){
// summary: setup movement listeners and calculate initial size
if (this._isSizing){ return false; }
this.targetWidget = dijit.byId(this.targetId);
// FIXME: resizing widgets does weird things, disable virtual resizing for now:
if (this.targetWidget) { this.activeResize = true; }
this.targetDomNode = this.targetWidget ? this.targetWidget.domNode : dojo.byId(this.targetId);
if (this.targetContainer) { this.targetDomNode = this.targetContainer; }
if (!this.targetDomNode){ return; }
this.intLeftRTLOrig = parseInt(this.targetDomNode.style.left,10);
if (!this.activeResize) {
this.targetDomNode.appendChild(this._activeResizeNode);
dojo.fadeIn({ node: this._activeResizeNode, duration:120,
beforeBegin: dojo.hitch(this,function(){
this._activeResizeNode.style.display='';
})
}).play();
}
this._isSizing = true;
this.startPoint = {'x':e.clientX, 'y':e.clientY};
// FIXME: this is funky: marginBox adds height, contentBox ignores padding (expected, but foo!)
var mb = (this.targetWidget) ? dojo.marginBox(this.targetDomNode) : dojo.contentBox(this.targetDomNode);
this.startSize = { 'w':mb.w, 'h':mb.h };
this._connects = [];
this._connects.push(dojo.connect(document,"onmousemove",this,"_updateSizing"));
this._connects.push(dojo.connect(document,"onmouseup", this, "_endSizing"));
this._connects.push(dojo.connect(document,"onmouseleave", this, "_endSizing"));
// create the resize shadow
this.resizeShadow = document.createElement("div");
this.targetContainer.appendChild(this.resizeShadow);
dojo.attr(this.resizeShadow, {"class": "dialog_resize_shadow"});
dojo.style(this.resizeShadow, "width", mb.w + "px");
dojo.style(this.resizeShadow, "height", mb.h + "px");
e.preventDefault();
},
_changeSizing: function(/*Event*/ e){
// summary: apply sizing information based on information in (e) to attached node
var tmp = this._getNewCoords(e);
if(tmp===false){ return; }
if(this.targetWidget && typeof this.targetWidget.resize == "function"){
this.targetWidget.resize(tmp);
}else{
var intLeft = 0;
if (builderConfig.isBidi) {
intLeft = this.intLeftRTLOrig - tmp.dx;
}
dojo.style(this.targetDomNode,"width",tmp.w+"px");
dojo.style(this.targetDomNode,"height",tmp.h+"px");
if (builderConfig.isBidi) {
dojo.style(this.targetDomNode,"left",intLeft+"px");
}
if(this.innerContainer && this.innerMargin){
this.innerContainer.style.height = (tmp.h - this.innerMargin.top - this.innerMargin.bottom ) + "px";
this.innerContainer.style.width = (tmp.w - this.innerMargin.left - this.innerMargin.right - 2) + "px";
}
}
dojo.style(this.resizeShadow, "width", tmp.w + "px");
dojo.style(this.resizeShadow, "height", tmp.h + "px");
e.preventDefault();
if(this.onResize !== null)
{
this.onResize(tmp.w, tmp.h);
}
},
_getNewCoords: function(/* Event */ e){
// On IE, if you move the mouse above/to the left of the object being resized,
// sometimes clientX/Y aren't set, apparently. Just ignore the event.
try{
if(!e.clientX || !e.clientY){ return false; }
}catch(exception){
// sometimes you get an exception accessing above fields...
return false;
}
this._activeResizeLastEvent = e;
var dx = this.startPoint.x - e.clientX;
var dy = this.startPoint.y - e.clientY;
var newW = 0;
var newH = (this._resizeY) ? this.startSize.h - dy : this.startSize.h;
if (!builderConfig.isBidi) {
newW = (this._resizeX) ? this.startSize.w - dx : this.startSize.w;
} else {
newW = (this._resizeX) ? this.startSize.w + dx : this.startSize.w;
}
// minimum size check
if(this.minSize){
//var mb = dojo.marginBox(this.targetDomNode);
if(newW < this.minSize.w){
newW = this.minSize.w;
}
if(newH < this.minSize.h){
newH = this.minSize.h;
}
}
return {w:newW, h:newH, dx:dx}; // Object
},
_endSizing: function(/*Event*/ e){
this.inherited(arguments);
dojo.forEach(this._connects,function(c){
dojo.disconnect(c);
});
// Note: the target dom node id is like : "widgetId_edit"
if (this.targetDomNode){
var domId = this.targetDomNode.id;
if (domId.indexOf("_edit")!=-1){
var widgetId = domId.substr(0,domId.length-5);
var eventService = com.ibm.mashups.services.ServiceManager.getService("eventService");
var dlgContentNode = dojo.query(".dialog_container",this.targetDomNode)[0];
var payload = {"newWidth": parseInt(dlgContentNode.style.width,10),"newHeight": parseInt(dlgContentNode.style.height,10)};
eventService.publishEvent(com.ibm.mashups.iwidget.Constants.RESIZE_WIDGET+"."+widgetId,payload);
}
}
// remove resize shadow
this.targetContainer.removeChild(this.resizeShadow);
this.resizeShadow = null;
}
});
}
if(!dojo._hasResource["com.ibm.mm.builder.widget.CustomDialogMoveable"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.widget.CustomDialogMoveable"] = true;
dojo.provide("com.ibm.mm.builder.widget.CustomDialogMoveable");
dojo.require("dojo.dnd.Mover");
dojo.declare("com.ibm.mm.builder.widget.CustomDialogMoveable", dojo.dnd.Moveable, {
adjustPosOnMouseUp: function(){
this.node.style.left = this.checkValue(this.node.style.left);
this.node.style.top = this.checkValue(this.node.style.top);
},
checkValue: function(value){
try {
var numValue = parseInt(value.substring(0, value.length - 2),10);
if (numValue < 0) {
return "0px";
}
}
catch (e) {
}
return value;
},
onMoveStop: function(/* dojo.dnd.Mover */mover){
com.ibm.mm.builder.widget.CustomDialogMoveable.superclass.onMoveStop.call(this, mover);
this.adjustPosOnMouseUp();
}
});
}
if(!dojo._hasResource["com.ibm.mm.builder.widget.CustomDialog"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.widget.CustomDialog"] = true;
dojo.provide("com.ibm.mm.builder.widget.CustomDialog");
dojo.require("dojo.fx");
dojo.require("dijit.Dialog");
dojo.declare("com.ibm.mm.builder.widget.CustomDialog", [dijit.Dialog], {
templateString:
"" +
"" +
"" +
" " +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"",
baseClass: "custom_dialog",
sharedWidget: false, //whether this dialog widget should alive when page change
belongId: null,
nodeWidth: null,
nodeHeight: null,
title: null,
titleHeight: 28,
titleBarHeight: "0px",
endBarHeight: "0px",
bottomHeight: 14,
topBarBackground: null,
topBarOpacity: null,
bottomBarBackground: null,
bottomBarOpacity: null,
bottomBarTip: null,
bottomBarTipColor: "white",
leftBarWidth: "0px",
rightBarWidth: "0px",
displayCloseButton: true,
containerNodePadding: null,
containerBackgroundColor: null,
containerOpacity: null,
dialogOpacity: null,
hasLeftBottomResizer: false,
hasRightBottomResizer: true,
modelDialog: true,
needUnderLay: true,
initLeftPosition: null,
initTopPosition: null,
alwaysCenter: true,
subDialogs: null,
roundCorner: false,
dialogStack: [],
innerConnects: [],
closeCallback: null, // a callback to set when you need to do something when the dialog is hided
displayCallback: null, // a callback to set when you need to do something after the dialog is displayed
dynaInitialized: false, // used when user doens't specify the node's width
// After calculate the outer container's width, will be set to true
closeIconTitle: com.ibm.mm.builder.coreWidgetsStrings.I_COMMON_CANCEL,
//isEmbedPageBidi: false, // 8143: embedPage will set to true when creating a bidi preview dialog
// 9637: removed rtl version of custom_dialog_nomodel so removed param isEmbedPageBidi
scrollEnabled: false,
postCreate: function(){
this.inherited(arguments);
this.domNode.className = "custom_dialog";
this.subDialogs = [];
//this.setTitle();//postpone until show to allow width to be set
if (this.scrollEnabled) {
dojo.style(this.containerNode, "overflow", "scroll");
}
dojo.subscribe("/enabler/pageChanged", this, "destroyOnPageChange");
},
setTitle: function(title){
this.title = title || this.title;
if (this.title && this.titleNode && this.title != this.titleNode.title) {
com.ibm.mm.builder.utils.htmlUtil.setNodeTitle(this.title, this.titleNode);
}
dojo.attr(this.dialogNode, "title", this.title);
dojo.attr(this.titleBar, "title", this.title);
},
// Search for if the page contains an applet
containXOjbect: function(){
return document.applets.length > 0 || document.getElementsByTagName("Object").length > 0;
},
// temp fix for old widget spec
oldWidgetSpecHitch: function(){ // for custom dialog instance to over write
},
// end temp fix
registerSubDialog: function(subDialogId){
if (dojo.isString(subDialogId)) {
this.subDialogs.push(subDialogId);
var subDialog = dijit.byId(subDialogId);
if (subDialog && !subDialog.modelDialog) {
subDialog.domNode.style.zIndex = this.domNode.style.zIndex;
}
}
},
hideWithKey: function(event){
var keyCode = event.keyCode;
if (keyCode != dojo.keys.ENTER) {
return true;
}
this.hide();
},
hide: function(){
this.doHide();
},
doHide: function(){
if (!this.open) {
return;
}
if (!dojo.isIE && this.closeButtonNode.style.display != "none") {
this.closeButtonNode.focus();
}
//disconnect the onkey function for the dialog
if (this.dialogStack.length > 1) {
var subDig = this.dialogStack.pop();
dojo.disconnect(subDig.onKeyHandler);
var parentDialog = this.dialogStack[this.dialogStack.length - 1];
parentDialog.onKeyHandler = dojo.connect(document.documentElement, "onkeypress", parentDialog, "_onKey");
}
else
if (this.dialogStack.length === 1) {
var dialog = this.dialogStack.pop();
dojo.disconnect(dialog.onKeyHandler);
}
dojo.forEach(this.subDialogs, function(subDialogId){
var subDialog = dijit.byId(subDialogId);
if(subDialog){
subDialog.hide();
}
});
// temp fix for old widget spec
setTimeout(this.oldWidgetSpecHitch, this.duration);
//override the dijit.Dialog hide logic here.
var ds = com.ibm.mm.builder.widget.customDialogStack;
if(!this._alreadyInitialized || this != ds[ds.length-1]){
return;
}
if(this.modelDialog){
com.ibm.mm.builder.widget.customDlgHighestZIndex -= 2;
this.domNode.style.zIndex = com.ibm.mm.builder.widget.customDlgZIndexOnPage;
}
if(this._fadeIn.status() == "playing"){
this._fadeIn.stop();
}
com.ibm.mm.builder.widget.customDialogStack.pop();
this._fadeOut.play();
if (this._scrollConnected){
this._scrollConnected = false;
}
dojo.forEach(this._modalconnects, dojo.disconnect);
this._modalconnects = [];
if(this._relativePosition){
delete this._relativePosition;
}
this.open = false;
},
trueHide: function(){
this.doHide();
},
_onKey: function(/*Event*/ evt){
// summary:
// Handles the keyboard events for accessibility reasons
// tags:
// private
// on dojo 1.6, the dijit._dialogStack ALWAYS contains a (non-dialog) element; plus the
// elements in dojo 1.4 are Dialogs, where in dojo 1.6 they are javascript objects
// containing Dialogs, amongst other properties
if (dijit._dialogStack && ((dijit._dialogStack.length > 1 && dijit._dialogStack[0].dialog === null) || (dijit._dialogStack.length > 0 && dijit._dialogStack[0] instanceof dijit.Dialog))) {
return;
}
var ds = com.ibm.mm.builder.widget.customDialogStack;
if (ds[ds.length - 1] != this) {
return;
}
if (evt.charOrCode) {
var dk = dojo.keys;
var node = evt.target;
if (evt.charOrCode === dk.TAB) {
this._getFocusItems(this.domNode);
}
var singleFocusItem = (this._firstFocusItem == this._lastFocusItem);
// see if we are shift-tabbing from first focusable item on dialog
if (node == this._firstFocusItem && evt.shiftKey && evt.charOrCode === dk.TAB) {
if (!singleFocusItem) {
dijit.focus(this._lastFocusItem); // send focus to last item in dialog
}
dojo.stopEvent(evt);
}
else
if (node == this._lastFocusItem && evt.charOrCode === dk.TAB && !evt.shiftKey) {
if (!singleFocusItem) {
dijit.focus(this._firstFocusItem); // send focus to first item in dialog
}
dojo.stopEvent(evt);
}
else {
// see if the key is for the dialog
while (node) {
if (node == this.domNode) {
if (evt.charOrCode == dk.ESCAPE) {
this.onCancel();
}
else {
return; // just let it go
}
}
node = node.parentNode;
}
// this key is for the disabled document window
if (evt.charOrCode !== dk.TAB) { // allow tabbing into the dialog for a11y
dojo.stopEvent(evt);
// opera won't tab to a div
}
else
if (!dojo.isOpera) {
try {
this._firstFocusItem.focus();
}
catch (e) { /*squelch*/
}
}
}
}
},
/**
* the recommended way to get underlay of the dialog.
*/
_getUnderlay: function(){
if (!this._underlay) {
this._underlay = new com.ibm.mm.builder.widget.CustomDialogUnderlay();
}
return this._underlay;
},
//In dojo 1.4, we can use dojo.isMac
_isMac : function() {
return navigator.appVersion.indexOf("Macintosh") >= 0;
},
/**
* Initialization when the dialog is showed for the first time
*/
_setup: function(){
this.moveableHandles = [];
//initialize the global dijit._underlay to avoid exception when the parent's uninitialize is called
if (!dijit._underlay) {
dijit._underlay = new dijit.DialogUnderlay();
}
if (this.titleBar) {
this.moveableHandles.push(new com.ibm.mm.builder.widget.CustomDialogMoveable(this.domNode, {
handle: this.titleBar
}));
}
if (this.leftBar) {
this.moveableHandles.push(new com.ibm.mm.builder.widget.CustomDialogMoveable(this.domNode, {
handle: this.leftBar
}));
}
if (this.rightBar) {
this.moveableHandles.push(new com.ibm.mm.builder.widget.CustomDialogMoveable(this.domNode, {
handle: this.rightBar
}));
}
if (this.endBar) {
this.moveableHandles.push(new com.ibm.mm.builder.widget.CustomDialogMoveable(this.domNode, {
handle: this.endBar
}));
}
if (this.modelDialog) { // is model dialog
// com.ibm.mm.builder.widget.customDlgZIndexOnPage += 2; //Increase every time when there is a new model dialog on the page
this.domNode.style.zIndex = com.ibm.mm.builder.widget.customDlgZIndexOnPage;
} else { // is not model dialog
//if (!this.isEmbedPageBidi) { 9637
com.ibm.mm.builder.utils.htmlUtil.setClass(this.domNode, "custom_dialog_nomodel");
//}
}
var node = this.domNode;
if (this.modelDialog && this.needUnderLay) {
var underlay = this._getUnderlay();
this._fadeIn = dojo.fx.combine([
dojo.fadeIn({
node: node,
duration: this.duration,
onEnd: dojo.hitch(this,function(){
if(this.dialogOpacity != null) {
dojo.style(this.domNode, "opacity", this.dialogOpacity);
}
})
}),
dojo.fadeIn({
node: underlay.domNode,
duration: this.duration,
onEnd: dojo.hitch(this, function(){
underlay.show();
underlay.setZIndex(dojo.style(node, "zIndex") - 1);
//TODO: from dojo1.4, this can be removed, dijit.dialogUnderlay will add iframe by default.
if (!(this._isMac() && dojo.isSafari == 4)) {
this._addBackIFrame(dojo.style(node, "zIndex") - 2);
}
})
})
]);
this._fadeOut = dojo.fx.combine([
dojo.fadeOut({
node: node,
duration: 600
}),
dojo.fadeOut({
node: underlay.domNode,
duration: 700,
onEnd: dojo.hitch(this, function(){
node.style.display = "none";
underlay.hide();
//TODO: from dojo1.4, this can be removed, dijit.dialogUnderlay will add iframe by default.
this._removeBackIFrame();
if (this.closeCallback) {
setTimeout(dojo.hitch(this, this.closeCallback), 500);
}
})
})
]);
} else {
this._fadeIn = dojo.fadeIn({
node: node,
duration: this.duration,
onEnd: dojo.hitch(this, function(){
if(this.dialogOpacity != null) {
dojo.style(this.domNode, "opacity", this.dialogOpacity);
}
})
});
this._fadeOut = dojo.fadeOut({
node: node,
duration: 600,
onEnd: dojo.hitch(this,function(){
node.style.display = "none";
if (this.closeCallback) {
setTimeout(dojo.hitch(this, this.closeCallback), 500);
}
})
});
}
},
/**
* Initialize the skin of the dialog accoring to the given params when the it's created
*/
InitDialogSkin: function(){
if (this.roundCorner) {
dojo.addClass(this.dialogNode, "mumRoundCorner");
}
this.closeButtonNode.style.display = this.displayCloseButton ? "" : "none";
if (!this.title) {
this.titleNode.style.display = "none";
com.ibm.mm.builder.utils.htmlUtil.setClass(this.titleBar, "dialog_titlebar_notitle");
com.ibm.mm.builder.utils.htmlUtil.setClass(this.leftBar, "dialog_leftsidebar_notitle");
com.ibm.mm.builder.utils.htmlUtil.setClass(this.rightBar, "dialog_rightsidebar_notitle");
this.titleHeight = 14;
}
else {
this.titleNode.style.display = "";
com.ibm.mm.builder.utils.htmlUtil.setClass(this.titleBar, "dialog_titlebar");
com.ibm.mm.builder.utils.htmlUtil.setClass(this.leftBar, "dialog_leftsidebar");
com.ibm.mm.builder.utils.htmlUtil.setClass(this.rightBar, "dialog_rightsidebar");
this.titleHeight = 28;
}
if (this.nodeWidth) {
(this.containerNode.style.width = this.nodeWidth);
}
dojo.forEach((this.nodeStyle || "").split(";"), function(singleStyle){
var kvp = singleStyle.split(":");
if (kvp.length === 2) {
this.containerNode.style[kvp[0]] = kvp[1];
}
}, this);
if (this.nodeHeight) {
this.containerNode.style.height = this.nodeHeight;
}
if (this.containerNodePadding){this.containerNode.style.padding = this.containerNodePadding;}
if (this.leftBarWidth) {
this.leftBar.style.width = this.leftBarWidth;
}
if (this.leftBarWidth) {
this.containerNode.style.marginLeft = this.leftBarWidth;
}
if (this.rightBarWidth) {
this.rightBar.style.width = this.rightBarWidth;
}
if (this.rightBarWidth) {
this.containerNode.style.marginRight = this.rightBarWidth;
}
if (this.containerBackgroundColor) {
this.containerNode.style.backgroundColor = this.containerBackgroundColor;
}
if (this.containerOpacity) {
this.containerNode.style.opacity = this.containerOpacity;
}
//the style of the title and bottom bar
if (this.topBarBackground) {
this.titleBar.style.backgroundColor = this.topBarBackground;
}
if (this.topBarOpacity) {
this.titleBar.style.opacity = this.topBarOpacity;
}
if (this.topBarOpacity) {
this.titleBar.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=" + this.topBarOpacity * 100;
}
if (this.titleBarHeight != "0px") {
this.titleBar.style.height = this.titleBarHeight;
}
if (this.bottomBarBackground) {
this.endBar.style.backgroundColor = this.bottomBarBackground;
}
if (this.bottomBarOpacity) {
this.endBar.style.opacity = this.bottomBarOpacity;
}
if (this.bottomBarOpacity) {
this.endBar.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=" + this.bottomBarOpacity * 100;
}
if (this.endBarHeight && this.endBarHeight != "0px") {
this.endBar.style.height = this.endBarHeight;
var _height = parseInt(this.endBarHeight,10) + 1 + "px";
this.leftBar.style.bottom = _height;
this.rightBar.style.bottom = _height;
}
if (this.bottomBarTip) {
this.endBar.innerHTML = this.bottomBarTip;
this.endBar.style.color = this.bottomBarTipColor;
}
//Init resize handle
if (this.hasLeftBottomResizer) {
this.leftResizeHandler.style.display = "";
this.leftResizer = new com.ibm.mm.builder.widget.CustomDialogResizer({
targetContainer: this.domNode,
animateSizing: false,
activeResize: true,
innerContainer: this.containerNode,
innerMargin: {
top: this.titleHeight,
bottom: this.bottomHeight,
left: parseInt(this.leftBarWidth,10),
right: parseInt(this.rightBarWidth,10)
},
onResize: dojo.hitch(this, "onResize")
}, this.leftResizeHandler);
this.leftResizer.startup();
}
if (this.hasRightBottomResizer) {
this.rightResizeHandler.style.display = "";
this.rightResizer = new com.ibm.mm.builder.widget.CustomDialogResizer({
targetContainer: this.domNode,
animateSizing: false,
activeResize: true,
innerContainer: this.containerNode,
innerMargin: {
top: this.titleHeight,
bottom: this.bottomHeight,
left: parseInt(this.leftBarWidth,10),
right: parseInt(this.rightBarWidth,10)
},
onResize: dojo.hitch(this, "onResize")
}, this.rightResizeHandler);
this.rightResizer.startup();
}
},
/**
* Display the dialog
*/
show: function(){
if (this.open) {
return;
}
// first time we show the dialog, there's some initialization stuff to do
if (!this._alreadyInitialized) {
this._setup();
this.InitDialogSkin();
this._alreadyInitialized = true;
}
if (this._fadeOut.status() == "playing") {
this._fadeOut.stop();
}
this._modalconnects.push(dojo.connect(window, "onscroll", this, "layout"));
this._modalconnects.push(dojo.connect(window, "onresize", this, function(){
// IE gives spurious resize events and can actually get stuck
// in an infinite loop if we don't ignore them
var viewport = dijit.getViewport();
if(!this._oldViewport ||
viewport.h != this._oldViewport.h ||
viewport.w != this._oldViewport.w){
this.layout();
this._oldViewport = viewport;
}
}));
if (this.dialogStack.length > 0) {
var formerDialog = this.dialogStack[this.dialogStack.length - 1];
dojo.disconnect(formerDialog.onKeyHandler);
}
this.dialogStack.push(this);
if (this.modelDialog) {
this._modalconnects.push(this.onKeyHandler = dojo.connect(document.documentElement, "onkeypress", this, "_onKey"));
}
dojo.style(this.domNode, "opacity", 0);
var hasHeightDivList = [];
//fix the width bug of IE6
if (!this.dynaInitialized) {
if (dojo.isIE == 6) {
dojo.query("div", this.domNode).forEach(function(node, i){
// add if cause here ,if need.
var heightObj = [];
heightObj.node = node;
heightObj.height = node.style.height;
node.style.height = "auto";
hasHeightDivList.push(heightObj);
});
}
}
this.domNode.style.display = "block";
this.domNode.style.visibility = "";
this.open = true;
//removed in dojo1.4
// this._loadCheck(); // lazy load trigger
//only do this once, when use modify the width/height of the dialog by resizer, the second time show will keep the user's config
if (!this.dynaInitialized) {
this.domNode.style.height = null;
if(this.nodeHeight !== null){
this.containerNode.style.height = this.nodeHeight;
}else {
this.containerNode.style.height = null;
}
var leftnum = parseInt(this.leftBarWidth.substring(0, this.leftBarWidth.length - 2),10);
var rightnum = parseInt(this.rightBarWidth.substring(0, this.rightBarWidth.length - 2),10);
var nodeWidthNum;
if (this.nodeWidth !== null) {
this.containerNode.style.width = this.nodeWidth;
nodeWidthNum = parseInt(this.nodeWidth.substring(0, this.nodeWidth.length - 2),10);
this.domNode.style.width = (nodeWidthNum + leftnum + rightnum + 2) + "px";
}
else {
var node;
if(this.containerNode.hasChildNodes())
{
node = this.containerNode.childNodes[0];
}
else
{
node = this.containerNode;
}
nodeWidthNum = dojo.coords(node).w;
this.containerNode.style.width = nodeWidthNum + "px";
// 20970
// this.domNode.style.width = (nodeWidthNum + leftnum + rightnum + 2) + "px";
this.domNode.style.width = "auto";
}
if (dojo.isIE == 6) {
for (var i = 0; i < hasHeightDivList.length; i++) {
if (hasHeightDivList[i].height && hasHeightDivList[i].height != "auto") {
hasHeightDivList[i].node.style.height = hasHeightDivList[i].height;
}
else {
hasHeightDivList[i].node.style.height = "";
}
}
}
this._position();
this.positionWithGivenValue();
this.dynaInitialized = true;
} else {
if (this.alwaysCenter && this.initLeftPosition === null && this.initTopPosition === null) {
this._position();
}
dojo.style(this.containerNode, "width", "100%");
}
// this.hasXObject = this.containXOjbect();
// if (this.hasXObject) {
// //hide all the applets, otherwise the applets will display beyond the background layer
// this._hideXObjects();
// }
//update the ZIndex information
if(this.modelDialog){
com.ibm.mm.builder.widget.customDlgHighestZIndex += 2;
this.domNode.style.zIndex = com.ibm.mm.builder.widget.customDlgHighestZIndex;
}
//set title after width has been set
this.setTitle();
com.ibm.mm.builder.widget.customDialogStack.push(this);
this._fadeIn.play();
this._savedFocus = dijit.getFocus(this);
hasHeightDivList = null;
//For dojo1.1.1 support
this._getFocusItems(this.domNode);
// set timeout to allow the browser to render dialog
setTimeout(dojo.hitch(this, function(){
try {
var elems = dijit._getTabNavigable(this.containerNode);
var f = elems.lowest || elems.first || this._firstFocusItem;
if (f) {
dijit.focus(f);
}
if(this.displayCallback){
this.displayCallback();
}
} catch (e) {
this.closeButtonNode.focus();
}
}), this.duration + 500);
},
setNodeWidth: function(newWidth){
this.containerNode.style.width = this.nodeWidth = newWidth;
if (this.dynaInitialized) { //if has been shown
var leftnum = parseInt(this.leftBarWidth,10);
var rightnum = parseInt(this.rightBarWidth,10);
var nodeWidthNum = this.nodeWidth ? parseInt(this.nodeWidth,10) : dojo.coords(this.containerNode).w;
this.domNode.style.width = (nodeWidthNum + leftnum + rightnum + 2) + "px";
}
},
setNodeHeight: function(newHeight){
this.containerNode.style.height = this.nodeHeight = newHeight;
},
setBottomTip: function(tip){
this.endBar.innerHTML = this.bottomBarTip = tip;
},
setBottomTipColor: function(color){
this.endBar.style.color = this.bottomBarTipColor = color;
},
autoAdjust: function(){},
//Although this is a protected function for dijit.Dialog
//Use it anyway to avoid copy much code from dijit.Dialog
onCancel: function(){
this.trueHide();
},
destroyOnPageChange: function(){
if (!this.sharedWidget) {
this.destroy();
}
},
destroy: function(){
this.open && this.hide();
dojo.forEach(this.innerConnects, dojo.disconnect);
if (this.moveableHandles){
for (var i = 0; i < this.moveableHandles.length; i++){
this.moveableHandles[i].destroy();
}
}
dojo.destroy(this.leftBar);
dojo.destroy(this.rightBar);
dojo.destroy(this.endBar);
dojo.destroy(this.closeButtonNode);
dojo.destroy(this.titleBar);
this.leftResizer && this.leftResizer.destroy();
this.rightResizer && this.rightResizer.destroy();
dojo.destroy(this.leftResizeHandler);
dojo.destroy(this.rightResizeHandler);
if (this._underlay) { // need this since from 1.3.2, dijit.dialog doesn't destroy the underlay
this._underlay.destroy();
this._underlay = null;
}
this.shimmer && dojo.destroy(this.shimmer);
this.inherited(arguments);
},
positionWithGivenValue: function(){
if (this.initLeftPosition) {
this.domNode.style.left = this.initLeftPosition;
}
if (this.initTopPosition) {
this.domNode.style.top = this.initTopPosition;
}
},
/**
* Position modal dialog in center of screen
*/
_position: function(){
if (dojo.hasClass(dojo.body(), "dojoMove")) {
return;
}
// wait a moment until the domNode is fully ready, otherwise it's height maybe wrong
window.setTimeout(dojo.hitch(this,function(){
var viewport = dijit.getViewport();
var mb = dojo.marginBox(this.domNode);
if (mb) { //fix defect 19481
var left = Math.floor((viewport.l + (viewport.w - mb.w) / 2));
var top = Math.floor((viewport.t + (viewport.h - mb.h) / 2));
this.domNode.style.left = left > 0 ? left + "px" : "0px";
this.domNode.style.top = top > 0 ? top + "px" : "0px";
} else {
this._position();
}
}),100);
},
layout: function(){
// summary: position the Dialog and the underlay
if (this.domNode.style.display != "none" && this.modelDialog && this.needUnderLay) {
this._getUnderlay().layout();
}
},
/**
* This function will add one iframe under the underlay of the dialog
* Its purpose is to solve the overlap problem of applet,flash,ActiveX object,ect.
*/
_addBackIFrame: function(zIndex){
this.shimmer = document.createElement('iframe');
this.shimmer.style.position = 'absolute';
this.shimmer.style.zIndex = zIndex;
this.shimmer.setAttribute('frameborder', '0');
this.shimmer.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';
document.body.appendChild(this.shimmer);
this._adjustBackIFramePosition();
},
/**
* This function is in charge of adjust the iframe's positon when user scroll the window
*/
_adjustBackIFramePosition: function(){
var viewport = dijit.getViewport();
this.shimmer.style.top = viewport.t + "px";
this.shimmer.style.left = viewport.l + "px";
this.shimmer.style.width = viewport.w + "px";
this.shimmer.style.height = viewport.h + "px";
// process twice since the scroll bar may have been removed
// by the previous resizing
var viewport2 = dijit.getViewport();
if (viewport.w != viewport2.w) {
this.shimmer.style.width = viewport2.w + "px";
}
if (viewport.h != viewport2.h) {
this.shimmer.style.height = viewport2.h + "px";
}
},
/**
* Remove the iframe when the dialog is hidden
*/
_removeBackIFrame: function(){
if (this.shimmer) {
dojo.destroy(this.shimmer);
this.shimmer = null;
}
},
// _hideXObjects: function(){
// //hide all the applets
// var applets = document.getElementsByTagName("Applet");
// for (var i = 0; i < applets.length; i++) {
// applets[i].style.visibility = "hidden";
// }
// //hide all object div(flash, svg)
// var objs = document.getElementsByTagName("Object");
// for (var i = 0; i < objs.length; i++) {
// objs[i].style.visibility = "hidden";
// }
// },
onResize: function(width, height){
// hook for child widgets
}
});
com.ibm.mm.builder.widget.customDialogStack = [];
com.ibm.mm.builder.widget.customDlgZIndexOnPage = 800;
com.ibm.mm.builder.widget.customDlgHighestZIndex = 800;
com.ibm.mm.builder.widget.editDialogUnderlay = null;
dojo.declare("com.ibm.mm.builder.widget.CleanDialog", com.ibm.mm.builder.widget.CustomDialog, {
/**
* Override the super method to make all WidgetEditDialog use the only global underlay:
* com.ibm.mm.builder.widget.editDialogUnderlay
*/
_getUnderlay: function(){
if (!com.ibm.mm.builder.widget.editDialogUnderlay) {
com.ibm.mm.builder.widget.editDialogUnderlay = new com.ibm.mm.builder.widget.CustomDialogUnderlay({
id: "cleanDialogUnderlay"
});
}
return com.ibm.mm.builder.widget.editDialogUnderlay;
}
});
dojo.declare("com.ibm.mm.builder.widget.GeneralWidgetModeDialog", com.ibm.mm.builder.widget.CleanDialog, {
postCreate: function(){
this.inherited(arguments);
this.modeChangeHandle = dojo.subscribe(iwConstants.EVENTS.modeChanged,
this, this.onModeChanged);
},
onModeChanged: function(widgetId, mode){
this.hide();
},
hideWithKey: function(event){
var keyCode = event.keyCode;
if (keyCode != dojo.keys.ENTER) {
return true;
}
this.trueHide();
},
trueHide: function(){
if(this.belongId) {
com.ibm.mashups.services.ServiceManager.getService("eventService").fireEvent(this.belongId, "onModeChanged", {newMode:'view'});
return;
}
this.doHide();
},
destroy: function(){
dojo.unsubscribe(this.modeChangeHandle);
this.inherited(arguments);
}
});
dojo.declare("com.ibm.mm.builder.widget.WidgetEditDialog", com.ibm.mm.builder.widget.GeneralWidgetModeDialog, {
onModeChanged: function(widgetId, mode){
if(mode === "edit" && this.belongId === widgetId) {
this.hide();
}
}
});
dojo.declare("com.ibm.mm.builder.widget.CustomDialogUnderlay", dijit.DialogUnderlay, {
templateString:
'' +
'' +
'',
setZIndex: function(zIndex){
dojo.style(this.domNode, "zIndex", zIndex);
}
// postCreate: function() {
// this.inherited('postCreate',arguments);
// if(this.bgIframe.iframe){
// dojo.attr(this.bgIframe.iframe,'title','underlay');
// }
// }
});
}
if(!dojo._hasResource["com.ibm.mm.builder.dialog.PageSaveConfirmDialog"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.dialog.PageSaveConfirmDialog"] = true;
/**
*/
dojo.provide("com.ibm.mm.builder.dialog.PageSaveConfirmDialog");
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
dojo.declare("com.ibm.mm.builder.dialog.PageSaveConfirmDialog", [dijit._Widget, dijit._Templated],
{
frameDialog: null,
callbackSave: null,
callbackNotSave: null,
callbackCancel: null,
contentWarning: null,
contentQuestion: null,
btnSaveText: null,
btnNotSaveText: null,
btnCancelText: null,
hideNotSave: false,
savePageOnSave: true,
frameWidth: "540px",
templateString:"\n \n \n ${contentWarning}\n \n \n ${contentQuestion}\n \n \n \n \n \n ${btnCancelText}\n \n\n",
postCreate: function(){
var dialogParams = {
id: "pageSaveConfirmDialog",
title: com.ibm.mm.builder.coreWidgetsStrings.I_PAGE_SAVE_TITLE,
displayCloseButton: true,
hasRightBottomResizer: false,
leftBarWidth: "0px",
rightBarWidth: "0px"
};
this.frameDialog = new com.ibm.mm.builder.widget.CleanDialog(dojo.mixin(dialogParams, {
nodeWidth: this.frameWidth,
displayCloseButton: true,
closeCallback: function(){
this.destroy();
}
}));
this.frameDialog.containerNode.appendChild(this.domNode);
if(this.hideNotSave) {
dojo.style(this.notSaveBtn, "display", "none");
}
},
_onSaveWithKey: function(e){
if (e.charCode === dojo.keys.SPACE || e.keyCode === dojo.keys.ENTER) {
this._onSave(e);
}
},
_onSave: function(){
this.frameDialog.hide();
if(this.savePageOnSave) {
var eventService = com.ibm.mashups.services.ServiceManager.getService("eventService");
this.pageSavedHandle = eventService.subscribeEvent("com.ibm.mashups.builder.pageSaved", this, "_onSaveContinue");
eventService.broadcastEvent("com.ibm.mashups.builder.savePage");
}
else {
this.callbackSave && this.callbackSave();
}
},
_onSaveContinue: function(){
if (this.pageSavedHandle) {
var eventService = com.ibm.mashups.services.ServiceManager.getService("eventService");
eventService.unsubscribeEvent(this.pageSavedHandle);
this.pageSavedHandle = null;
}
this.callbackSave && this.callbackSave();
},
_onNotSaveWithKey: function(e){
if (e.charCode === dojo.keys.SPACE || e.keyCode === dojo.keys.ENTER) {
this._onNotSave(e);
}
},
_onNotSave: function(){
this.frameDialog.hide();
var runtimePage = com.ibm.mashups.builder.model.Factory.getRuntimeModel().getCurrentPage();
if (runtimePage) {
// invalidate page
var pageId = runtimePage.getID();
var nm = com.ibm.mm.builder.utils.navigationUtil.getNavigationModel();
var page = nm.find(pageId).start();
page && nm.invalidate(page);
// invalidate widget windows
com.ibm.mashups.enabler.widget.Factory.getWidgetModel().cachedWindows = {};
// cancel widget sizes
var nsm = com.ibm.mashups.enabler.model.state.NavigationStateModelFactory.getNavigationStateModel();
var layoutAccessor = com.ibm.mashups.enabler.model.state.AccessorFactory.getLayoutAccessor(nsm, pageId);
layoutAccessor.setTemplateURL(null);
// clean page
runtimePage.setDirty(false);
}
this.callbackNotSave && this.callbackNotSave();
},
_onCancelWithKey: function(e){
if (e.charCode === dojo.keys.SPACE || e.keyCode === dojo.keys.ENTER) {
this._onCancel();
}
},
_onCancel: function(){
this.frameDialog.hide();
this.callbackCancel && this.callbackCancel();
},
show: function(){
this.frameDialog && this.frameDialog.show();
}
});
}
if(!dojo._hasResource["com.ibm.mm.builder.dnd.ACLSource"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.dnd.ACLSource"] = true;
dojo.provide("com.ibm.mm.builder.dnd.ACLSource");
dojo.declare("com.ibm.mm.builder.dnd.ACLSource",dojo.dnd.AutoSource,{
checkAcceptance: function(source, nodes){
//prevent dropping nodes to the searchSouce
return (this.name != "aclSearch");
},
onDndCancel: function(){
this.inherited(arguments);
},
_uncheckAll: function(source){
if(!source) source = this;
try {
if (source.node && source.node.childNodes) {
com.ibm.mm.builder.utils.htmlUtil.uncheckAll(source.node.childNodes);
}
} catch (e) {}
},
onDropExternal: function(source, nodes, copy){
//var draggedNodes = dojo.dnd.manager().avatar.node.childNodes[0].childNodes;
//Fix defect 15125
this._uncheckAll(source);
var draggedNodes = nodes;
if(!!source.selectedNodes&&source.selectedNodes.length >0){
draggedNodes=source.selectedNodes;
}
if(source.name == "aclSearch"){
draggedNodes = this.layout.checkDraggedNode(source,this,draggedNodes);
}
var anchor = this.before ? this.targetAnchor : (this.targetAnchor ? this.targetAnchor.nextSibling : null);
dojo.forEach(draggedNodes,function(item){
this.layout.transferNode(source,this,item.id,anchor,(source.name === "aclSearch"));
if (!this.before && anchor) { anchor = anchor.nextSibling; }
},this);
dojo.publish(source.name);
dojo.publish(com.ibm.mm.builder.eventTopics.UpdateAllPageControl);
},
onDropInternal: function(nodes, copy){},
destroy: function(){
dojo.forEach(this.container,"item.destroy();");
this.inherited(arguments);
}
});
com.ibm.mm.builder.dnd.ACLSource.createSource = function(domNode,accept,layout,name,listLengthPerPage,hiddenNodes){
return new com.ibm.mm.builder.dnd.ACLSource(domNode,{
accept:accept,
layout:layout,
name:name,
listLengthPerPage:listLengthPerPage,
container:[],
allStayedUsers:{},
currentPage:1,
totalPage:1,
creator: function(item, hint){
if (hint == "avatar") {
var n = document.createElement("div");
this.selectedNodes=[]
dojo.forEach(this.node.childNodes, function(item){
var checkBox = dojo.query("input", item)[0];
if (checkBox.checked) {
checkBox.checked = false;
dojo.removeClass(item, this.name + "ItemHover");
var cloneDraggedNode = item.cloneNode(true);
n.appendChild(cloneDraggedNode);
this.selectedNodes.push(cloneDraggedNode);
checkBox.checked = true;
}
},this);
return { node: n, data: item, type: ["acluser"] };
}
}
});
};
}
if(!dojo._hasResource["com.ibm.mm.builder.widget.OpenSearchPopup"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.widget.OpenSearchPopup"] = true;
dojo.provide("com.ibm.mm.builder.widget.OpenSearchPopup");
dojo.require("dijit._base.focus");
dojo.require("dijit._base.place");
dojo.require("dijit._base.window");
opensearch = {};
opensearch.popup = new function(){ //JSLINT-IGNORE:
// summary:
// This class is used to show/hide widgets as popups.
//
var stack = [],
beginZIndex=1003,
idGen = 1;
this.prepare = function(/*DomNode*/ node){
// summary:
// Prepares a node to be used as a popup
//
// description:
// Attaches node to dojo.doc.body, and
// positions it off screen, but not display:none, so that
// the widget doesn't appear in the page flow and/or cause a blank
// area at the bottom of the viewport (making scrollbar longer), but
// initialization of contained widgets works correctly
dojo.body().appendChild(node);
var s = node.style;
if(s.display == "none"){
s.display="";
}
s.visibility = "hidden"; // not needed for hiding, but used as flag that node is off-screen
s.position = "absolute";
s.top = "-9999px";
};
this.open = function(/*Object*/ args){
// summary:
// Popup the widget at the specified position
//
// args: Object
// popup: Widget
// widget to display,
// parent: Widget
// the button etc. that is displaying this popup
// around: DomNode
// DOM node (typically a button); place popup relative to this node
// orient: Object
// structure specifying possible positions of popup relative to "around" node
// onCancel: Function
// callback when user has canceled the popup by
// 1. hitting ESC or
// 2. by using the popup widget's proprietary cancel mechanism (like a cancel button in a dialog);
// ie: whenever popupWidget.onCancel() is called, args.onCancel is called
// onClose: Function
// callback whenever this popup is closed
// onExecute: Function
// callback when user "executed" on the popup/sub-popup by selecting a menu choice, etc. (top menu only)
//
// examples:
// 1. opening at the mouse position
// dijit.popup.open({popup: menuWidget, x: evt.pageX, y: evt.pageY});
// 2. opening the widget as a dropdown
// dijit.popup.open({parent: this, popup: menuWidget, around: this.domNode, onClose: function(){...} });
//
// Note that whatever widget called dijit.popup.open() should also listen to it's own _onBlur callback
// (fired from _base/focus.js) to know that focus has moved somewhere else and thus the popup should be closed.
var widget = args.popup,
orient = args.orient || {'BL':'TL', 'TL':'BL'},
around = args.around,
id = (args.around && args.around.id) ? (args.around.id+"_dropdown") : ("popup_"+idGen++);
// make wrapper div to hold widget and possibly hold iframe behind it.
// we can't attach the iframe as a child of the widget.domNode because
// widget.domNode might be a , , etc.
var wrapper = dojo.doc.createElement("div");
dijit.setWaiRole(wrapper, "presentation");
wrapper.id = id;
wrapper.className="dijitPopup";
wrapper.style.zIndex = beginZIndex + stack.length;
wrapper.style.left = wrapper.style.top = "0px"; // prevent transient scrollbar causing misalign (#5776)
wrapper.style.visibility = "hidden";
if(args.parent){
wrapper.dijitPopupParent=args.parent.id;
}
dojo.body().appendChild(wrapper);
var s = widget.domNode.style;
s.display = "";
s.visibility = "";
s.position = "";
wrapper.appendChild(widget.domNode);
var iframe = new dijit.BackgroundIframe(wrapper);
// position the wrapper node
var best = around ?
dijit.placeOnScreenAroundElement(wrapper, around, orient, widget.orient ? dojo.hitch(widget, "orient") : null) :
dijit.placeOnScreen(wrapper, args, orient == 'R' ? ['TR','BR','TL','BL'] : ['TL','BL','TR','BR']);
wrapper.style.visibility = "visible";
// TODO: use effects to fade in wrapper
var handlers = [];
// Compute the closest ancestor popup that's *not* a child of another popup.
// Ex: For a TooltipDialog with a button that spawns a tree of menus, find the popup of the button.
var getTopPopup = function(){
for(var pi=stack.length-1; pi > 0 && stack[pi].parent === stack[pi-1].widget; pi--){
/* do nothing, just trying to get right value for pi */
}
return stack[pi];
};
// provide default escape and tab key handling
// (this will work for any widget, not just menu)
handlers.push(dojo.connect(wrapper, "onkeypress", this, function(evt){
evt.keyChar = evt.charCode ? String.fromCharCode(evt.charCode) : '';
evt.charOrCode = evt.keyChar || evt.keyCode;
if(evt.charOrCode == dojo.keys.ESCAPE && args.onCancel){
dojo.stopEvent(evt);
args.onCancel();
}else if(evt.charOrCode === dojo.keys.TAB){
dojo.stopEvent(evt);
var topPopup = getTopPopup();
if(topPopup && topPopup.onCancel){
topPopup.onCancel();
}
}
}));
// watch for cancel/execute events on the popup and notify the caller
// (for a menu, "execute" means clicking an item)
if(widget.onCancel){
handlers.push(dojo.connect(widget, "onCancel", null, args.onCancel));
}
handlers.push(dojo.connect(widget, widget.onExecute ? "onExecute" : "onChange", null, function(){
var topPopup = getTopPopup();
if(topPopup && topPopup.onExecute){
topPopup.onExecute();
}
}));
stack.push({
wrapper: wrapper,
iframe: iframe,
widget: widget,
parent: args.parent,
onExecute: args.onExecute,
onCancel: args.onCancel,
onClose: args.onClose,
handlers: handlers
});
if(widget.onOpen){
widget.onOpen(best);
}
return best;
};
this.close = function(/*Widget*/ popup){
// summary:
// Close specified popup and any popups that it parented
while(dojo.some(stack, function(elem){return elem.widget == popup;})){ // JSLINT-IGNORE:
var top = stack.pop(),
wrapper = top.wrapper,
iframe = top.iframe,
widget = top.widget,
onClose = top.onClose;
if(widget.onClose){
widget.onClose();
}
dojo.forEach(top.handlers, dojo.disconnect);
// #2685: check if the widget still has a domNode so ContentPane can change its URL without getting an error
if(!widget||!widget.domNode){ return; }
this.prepare(widget.domNode);
iframe.destroy();
dojo.destroy(wrapper);
if(onClose){
onClose();
}
}
};
}();
}
if(!dojo._hasResource["com.ibm.mm.builder.widget.ShadowMenu"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.widget.ShadowMenu"] = true;
/**
* @author Jarod
*/
dojo.provide("com.ibm.mm.builder.widget.ShadowMenu");
dojo.require("dijit.Menu");
dojo.require("dojox.fx.Shadow");
/**
* summary: cusomize the dijit.Menu with shadow
*/
dojo.declare("com.ibm.mm.builder.widget.ShadowMenu", [dijit.Menu], {
offset_x: 0,
offset_y: 0,
leftClickToOpen: true,
openPosition:"BL",
disable_shadow: false,
postCreate: function(){
this.inherited(arguments);
if (!this.isLeftToRight()) { this.offset_x = -this.offset_x; }
if (dojo.isIE === 6) { return; }
this._connects.push([dojo.connect(window, "resize", this, function(){
if (this.shadow) {
this.shadow.setDisabled(true);
}
dijit.popup.close(this);
})]);
//bug: resolve the problem that the style of menu can't adjust when user change the page theme
dojo.addClass(this.domNode,"lotusActionMenu");
},
/*
* override this method to fix dojo issue and builder bug 8934
*/
onItemHover: function(item){
if (this.popupFocusTimer) {
clearTimeout(this.popupFocusTimer);
}
this.inherited(arguments);
},
/*
* Override _openMyself method to change the menu display position.
*
* offset_x and offset_y are used to adjust the position
* according to the target node.
*/
_openMyself: function(/*Event*/ e, /*DomNode?*/ node, /*DomNode?*/ iframe){
if(this.leftClickToOpen&&e.button>0){
return;
}
//TODO fix ie refresh issue..
try {
dojo.stopEvent(e);
} catch (err) {}
//---change the default open position begin
var tnode = e.target;
if(this.targetNodeIds && this.targetNodeIds.length == 1){
tnode = this.targetNodeIds[0];
}
var coords = dojo.coords(tnode, true);
var cbox = dojo.contentBox(tnode);
var xPack = 0;
if(this.openPosition.charAt(1) == "R"){
xPack = this.isLeftToRight() ? cbox.w : -cbox.w;
}
var x = coords.x + xPack + (this.offset_x||0) + (this.isLeftToRight() ? 0 : cbox.w);
var y = coords.y + (this.openPosition.charAt(0) == "B" ? cbox.h : 0) + (this.offset_y||0);
//---change the default open position end
var self=this;
var savedFocus = null; //hot fix for opera on spacemanager
try{savedFocus = dijit.getFocus(this);}catch(error){}
this.closeAndRestoreFocus = function(){
// user has clicked on a menu or popup
if (self.refocus && savedFocus) {
dijit.focus(savedFocus);
}
dijit.popup.close(self);
};
this._prepareData();
//no need to open menu without menu item
if (this.getChildren().length === 0) { return; }
dijit.popup.open({
popup: this,
x: x,
y: y,
onExecute: this.closeAndRestoreFocus,
onCancel: this.closeAndRestoreFocus,
orient: this.isLeftToRight() ? 'L' : 'R'
});
this.focus();
this._onBlur = function(){
this.inherited('_onBlur', arguments);
dijit.popup.close(this);
};
},
_prepareData: function(){
if (!this._isMenuCreated && !this._isMenuCreating) {
this._isMenuCreating = true;
this.prepareData();
this._isMenuCreated = true;
this._isMenuCreating = false;
}
},
prepareData: function(){},
_openPopup: function(){
if(this.focusedChild.popup._prepareData){ this.focusedChild.popup._prepareData(); }
if (this.focusedChild.popup.getChildren().length === 0) { return; }
this._orient = this.isLeftToRight() ? {'TR': 'TL', 'TL': 'TR'} : {'TL': 'TR', 'TR': 'TL'};
this.inherited(arguments);
},
onOpen: function(){
this.inherited(arguments);
if(this.disable_shadow){ return; }
//if domnode is too small, no necessary to create shadow
var p = dojo.marginBox(this.domNode);
if(p.w < 1 && p.h < 1){return;}
this.shadow = this.shadow || new com.ibm.mm.builder.widget.Shadow({
node: this.domNode
});
this.resizeShadow();
},
resizeShadow:function(){
var s = this.shadow;
setTimeout(function(){
if (s) {
s.resize();
s.setDisabled(false);
}
}, 50);
},
onClose: function(){
//fix dojo1.3.2 issue: dojo do not remove the hovered item style by default
dojo.forEach(this.containerNode.childNodes,function(item){
dojo.removeClass(item,"dijitMenuItemHover");
dojo.removeClass(item,"dijitMenuItemSelected");
});
this.inherited(arguments);
if(this.shadow){
this.shadow.setDisabled(true);
}
},
destroy: function(){
if(this.shadow){
this.shadow.destroy();
this.shadow = null;
}
//set the closure to null to avoid memory leak
this._onBlur = null;
this.closeAndRestoreFocus = null;
//close menu to avoid memory leak on IE
try {
dijit.popup.close(this);
} catch (e) {}//context menu of widget already destroy it, cannot close it.
this.inherited(arguments);
}
});
/**
* summary: Adds a drop-shadow (right and bottom side if LTR, left and bottom if RTL) to a node.
*/
dojo.declare("com.ibm.mm.builder.widget.Shadow", dojox.fx.Shadow, {
shadowPng: dojo.moduleUrl("com.ibm.mm.builder.widget", "resources/shadow"),
//shadowThickness: Integer
//How wide (in px) to make the shadow
shadowThickness: 5,
//shadowOffset: Integer
//How deep to make the shadow appear to be
shadowOffset: 0,
//shadowOffset_x: Integer
//How deep to make the shadow appear to be in x direction
shadowOffset_x: 5,
postCreate: function(){
this.inherited(arguments);
this.node.style.position = "relative";
//create a fake node to represent the original node
this.realNode = this.node;
this.node = this._getFakeNode(this.realNode);
this.pieces={};
var x0 = this.shadowOffset_x;
var x1 = -1 * this.shadowThickness + this.shadowOffset_x;
var y0 = this.shadowOffset;
var y1 = this.shadowOffset + this.shadowThickness;
if(this.isLeftToRight()){
this._makePiece("tr", "top", y0, "left", 0);
this._makePiece("r", "top", y1, "left", 0, "scale");
this._makePiece("bl", "top", 0, "left", x1);
this._makePiece("b", "top", 0, "left", x0, "scale");
this._makePiece("br", "top", 0, "left", 0);
}else{
x1 = -1 * this.shadowThickness;
this._makePiece("tl", "top", y0, "left", x1);
this._makePiece("l", "top", y1, "left", x1, "scale");
this._makePiece("bl", "top", 0, "left", x1);
this._makePiece("b", "top", 0, "left", 0, "scale");
this._makePiece("br", "top", 0, "right", 0);
}
this.nodeList = dojo.query(".shadowPiece",this.node);
//Set alt attribute for accessibility support and make sure all shadow can show over other menu
dojo.forEach(this.nodeList, 'dojo.attr(item,"alt","");item.style.zIndex=1001;');
//it seems menu will resize the created shadow, so commnet it to avoid invoke twice.
//this.resize();
},
_getFakeNode: function(node){
var coords = dojo.coords(node, true);
var shadowDiv = dojo.query(dojo.create("div", null, dojo.body()))
.addClass("mashupsShadowNode")
.style({
position: "absolute",
left: coords.x + "px",
top: coords.y + "px",
zIndex: 998
})[0];
dojo.query(dojo.create("iframe", {frameborder: 0}, shadowDiv))
.addClass("shadowedNodePlaceHolder").addClass("shadowPiece")
.style({heith: "0px", width: "0px"});
this._resizeFakeNode(shadowDiv);
return shadowDiv;
},
setDisabled: function(/* Boolean */disabled){
this.inherited(arguments);
if (this.node) {
this.node.style.visibility = disabled ? "hidden" : "visible";
}
},
resize: function(args){
this._resizeFakeNode();
var x, y;
if(args){
x = args.x; y = args.y;
}else{
var co = dojo.marginBox(this.realNode);
x = co.w; y = co.h;
}
var sideWidth = Math.max(x - this.shadowOffset_x, 0);
var sideHeight = Math.max(y - (this.shadowOffset + this.shadowThickness), 0);
y = Math.max(y, 1);
x = Math.max(x, 1);
if (this.isLeftToRight()) {
dojo.marginBox(this.pieces.r, {h:sideHeight, l:x});
dojo.marginBox(this.pieces.tr, {l:x});
dojo.marginBox(this.pieces.br, {l:x});
} else {
dojo.marginBox(this.pieces.l, {h:sideHeight});
}
dojo.marginBox(this.pieces.b, {w: sideWidth, t:y});
dojo.marginBox(this.pieces.bl, {t:y});
dojo.marginBox(this.pieces.br, {t:y});
},
_resizeFakeNode: function(node){
var fakeNode = node || this.node;
var coords = dojo.coords(this.realNode, true);
var pl = dojo.query(".shadowedNodePlaceHolder", fakeNode)[0];
if(pl) { dojo.marginBox(pl, { w: coords.w, h: coords.h }); }
if(fakeNode) { dojo.marginBox(fakeNode, {l: coords.x, t: coords.y}); }
},
uninitialize: function(){
if(this.node){
dojo.destroy(this.node);
this.node = null;
}
this.inherited(arguments);
}
});
}
if(!dojo._hasResource["com.ibm.mm.builder.widget.OpenSearchDropdownMenu"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.widget.OpenSearchDropdownMenu"] = true;
dojo.provide("com.ibm.mm.builder.widget.OpenSearchDropdownMenu");
dojo.require("dijit.Menu");
dojo.declare("com.ibm.mm.builder.widget.OpenSearchDropdownMenu",[com.ibm.mm.builder.widget.ShadowMenu],
{
/**
* rewrite this function just for popup zindex set in dialog
*/
_openMyself: function(/*Event*/ e, /*DomNode?*/ node, /*DomNode?*/ iframe){
if(this.leftClickToOpen&&e.button>0){
return;
}
//TODO fix ie refresh issue..
try {
dojo.stopEvent(e);
} catch (exp) {
}
//---change the default open position begin
var targetNode = e.target;
if(this.targetNodeIds && this.targetNodeIds.length == 1){
targetNode = this.targetNodeIds[0];
}
var coords = dojo.coords(targetNode, true);
var cbox = dojo.contentBox(targetNode);
var x = coords.x + (this.offset_x||0);
var y = coords.y + cbox.h + (this.offset_y||0);
//---change the default open position end
var self=this;
var savedFocus = dijit.getFocus(this);
function closeAndRestoreFocus(){
// user has clicked on a menu or popup
if(self.refocus){
dijit.focus(savedFocus);
}
opensearch.popup.close(self);
}
opensearch.popup.open({
popup: this,
x: x,
y: y,
onExecute: closeAndRestoreFocus,
onCancel: closeAndRestoreFocus,
orient: this.isLeftToRight() ? 'L' : 'R'
});
this.focus();
this._onBlur = function(){
this.inherited('_onBlur', arguments);
opensearch.popup.close(this);
};
},
destroy: function(){
com.ibm.mm.builder.widget.OpenSearchDropdownMenu.superclass.destroy.call(this);
if(this.domNode && this.domNode.id){
dijit.registry.remove(this.domNode.id);
}
if (this._onBlur) {
this._onBlur = null;
}
dijit.popup.close(this);
},
postCreate: function(){
this.entrys = [];
dojo.addClass(this.domNode,"OpenSearchDropdownMenu");
com.ibm.mm.builder.widget.OpenSearchDropdownMenu.superclass.postCreate.apply(this);
dojo.subscribe("com.ibm.mm.catalog.Topics.SearchType_Change",this,"changeSelected");
},
changeSelected: function(type){
var self = this;
dojo.forEach(this.entrys,function(item){
if(type === item.type){
self.setCurrentSearchType(item.domNode);
}
});
},
setCurrentSearchType : function(searchTypeDom) {
var describedNode = null;
if (this._currentSearchType) {
if(this._currentSearchType == searchTypeDom){
return;
}
var iconNode = dojo.query("td",this._currentSearchType)[0];
dojo.removeClass(iconNode, "checked");
var containerNode = dojo.query("td",this._currentSearchType)[1];
dojo.removeClass(containerNode, "checked");
describedNode = dojo.query("span",containerNode)[0];
describedNode.innerHTML = "";
}
var td0Dom = dojo.query("td",searchTypeDom)[0];
dojo.addClass(td0Dom, "checked");
var td1Dom = dojo.query("td",searchTypeDom)[1];
dojo.addClass(td1Dom, "checked");
this._currentSearchType = searchTypeDom;
describedNode = dojo.query("span",td1Dom)[0];
describedNode.innerHTML = " " +com.ibm.mm.builder.coreWidgetsStrings.I_MODE_IS_SELECT;
}
});
dojo.declare(
"com.ibm.mm.builder.widget.OpenSearchDropdownMenuItem",
[dijit.MenuItem],
{
type:"",
iconSrc: builderConfig.builderPath + "/images/blueCheckmark.gif",
postCreate: function(){
this.inherited("postCreate",arguments);
this.iconNode.src = this.iconSrc;
dojo.addClass(this.iconNode.parentNode,"menuItemCheckMark");
this.domNode.setAttribute("type", this.type);
var dijitMenuLabelA11y = dojo.doc.createElement("span");
dojo.addClass(dijitMenuLabelA11y,"access");
this.containerNode.appendChild(dijitMenuLabelA11y);
}
});
dojo.declare(
"com.ibm.mm.builder.widget.OpenSearchDropdownMenuSeparator",
[dijit.MenuSeparator],
{
templateString: '' +
'' +
'' +
' ' +
'' +
' ',
destroy: function(){
dijit.registry.remove(this.domNode.id);
},
postCreate: function(){
dojo.setSelectable(this.domNode, false);
this.domNode.style.height = "2px";
this.domNode.style.lineHeight = "2px";
this.markSeparator.style.background="url(/wps/mccbuilder.v3001/images/sideBar.gif)";
this.domNode.style.fontSize = "1pt";
}
});
}
if(!dojo._hasResource["com.ibm.mm.builder.widget.ViewMorePage"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.widget.ViewMorePage"] = true;
/**
* @author Jarod
* @author ERiK
*/
//todo refactory the html structure..
dojo.provide("com.ibm.mm.builder.widget.ViewMorePage");
dojo.declare("com.ibm.mm.builder.widget.ViewMorePage",
[dijit._Widget,dijit._Templated, dijit._Container],
{
templateString: '',
postCreate: function() {
this.pageList = [];
dojo.forEach(this.items, function(item) {
this.addChild(new com.ibm.mm.builder.widget.ViewMorePageItem({
title: item.title,
pid: item.pid,
pre: item.pre,
end: item.end
}));
}, this);
},
reGenerate: function(items) {
this.pageList = [];
this.items = items;
this.destroyDescendants();
dojo.forEach(this.items, function(item) {
this.addChild(new com.ibm.mm.builder.widget.ViewMorePageItem({
title: item.title,
pid: item.pid,
pre: item.pre,
end: item.end
}));
}, this);
}
});
dojo.declare("com.ibm.mm.builder.widget.ViewMorePageItem",
[dijit._Widget,dijit._Templated, dijit._Container, dijit._Contained],
{
templateString_rtl:
'' +
''+
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
''+
''+
'',
templateString:
'' +
''+
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
''+
''+
'',
postMixInProperties: function() {
if (builderConfig.isBidi) {
this.templateString = this.templateString_rtl;
}
},
postCreate: function() {
this.labelDescNodePre.innerHTML = this.pre;
this.labelDescNode.innerHTML = this.end;
this.labelNode.innerHTML = this.title;
this.domNode.title = com.ibm.mm.builder.utils.htmlUtil.unEscapeString(this.title);
this.btnAddNode.value = com.ibm.mm.builder.coreWidgetsStrings.I_COMMON_ADD;
this.btnRemoveNode.value = com.ibm.mm.builder.coreWidgetsStrings.I_COMMON_REMOVE;
this._changeToAdd();
},
_onHover: function() {
dojo.addClass(this.domNode, "highLightTreeItem");
dojo.addClass(this.labelNode, "highLightTreeText");
this.treeItemDividerTop.style.backgroundImage = "url('" + builderConfig.builderPath + "/images/divider_morepages_hover_top.png')";
},
_onUnhover: function(){
dojo.removeClass(this.domNode,"highLightTreeItem");
dojo.removeClass(this.labelNode,"highLightTreeText");
this.treeItemDividerTop.style.backgroundImage = "";
},
_changeToAdd: function(){
this.labelNode.style.color = "#000000";
this.labelNode.style.fontSize = "12px";
this.labelNode.fontFamily = "Arial";
this.btnAddNode.style.display = "";
this.btnRemoveNode.style.display = "none";
},
_changeToRemove: function(){
this.labelNode.style.color = "#BDBDD3";
this.btnAddNode.style.display = "none";
this.btnRemoveNode.style.display = "";
},
_onRemoveClick: function(){
this._changeToAdd();
this.removeItem(this.getParent().pageList,this.pid);
},
removeItem: function(array, value) {
for (var i = 0, n = 0; i < array.length; i++) {
if (array[i] != value) {
array[n++] = array[i];
}
}
array.length -= 1;
},
_onAddClick: function(){
this._changeToRemove();
this.getParent().pageList.push(this.pid);
}
});
}
if(!dojo._hasResource["com.ibm.mm.builder.dialog.ACLReassignDialog"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.dialog.ACLReassignDialog"] = true;
/**
*/
dojo.provide("com.ibm.mm.builder.dialog.ACLReassignDialog");
/**
* this class will create the access control reassign dialog
*/
dojo.declare("com.ibm.mm.builder.dialog.ACLReassignDialog", null, {
aclReassignDialog:null,
aclReassignRootDiv:null,
constructor: function(){
this.init();
},
init:function(){
this.initACLReassignContent();
var acrId = com.ibm.mashups.builder.model.Factory.getRuntimeModel().getCurrentPage().getID() + "_accessControlReassign";
var dialogWidth = (dojo.isIE)?"370px":"350px";
this.aclReassignDialog = new com.ibm.mm.builder.widget.CustomDialog(
{
id: acrId,
title: com.ibm.mm.builder.coreWidgetsStrings.I_ACL_CONFLICT_TITLE,
nodeWidth: dialogWidth,
containerBackgroundColor: "white",
hasRightBottomResizer: false
},
this.aclReassignRootDiv
);
},
initACLReassignContent:function(){
this.maxLen = dojo.isIE ? 50 : 95;
if (ibmConfig.fontSizeEnlarged && dojo.isSafari) {
this.maxLen = dojo.isSafari < 4 ? 65 : 60;
}
this.aclReassignRootDiv = document.createElement("div");
var aclReassignContentDiv = document.createElement("div");
dojo.addClass(aclReassignContentDiv,"accessControlReassignDiv");
var aclReassignTitleSpan = document.createElement("span");
dojo.addClass(aclReassignTitleSpan,"accessControlReassignTitle");
aclReassignTitleSpan.innerHTML= com.ibm.mm.builder.coreWidgetsStrings.I_ACL_INFORMATION_1 + "
";
aclReassignContentDiv.appendChild(aclReassignTitleSpan);
var aclReassignConfirmSpan = document.createElement("span");
dojo.addClass(aclReassignConfirmSpan,"accessControlReassignConfirm");
aclReassignConfirmSpan.innerHTML="
" + com.ibm.mm.builder.coreWidgetsStrings.I_ACL_INFORMATION_2 + "
";
aclReassignContentDiv.appendChild(aclReassignConfirmSpan);
var aclReassignButtonDiv = document.createElement("div");
dojo.addClass(aclReassignButtonDiv,"accessControlReassignBottomDiv");
var htmlUtil = com.ibm.mm.builder.utils.htmlUtil;
var aclReassignResignBtn = document.createElement("input");
aclReassignResignBtn.setAttribute("type","button");
aclReassignResignBtn.setAttribute("value",htmlUtil.getStrWithLimit(com.ibm.mm.builder.coreWidgetsStrings.I_ACL_REASSIGN_BTN,aclReassignResignBtn,this.maxLen));
aclReassignResignBtn.setAttribute("title",com.ibm.mm.builder.coreWidgetsStrings.I_ACL_REASSIGN_BTN);
/* begin a11y fixes for truncated value */
dojo.attr(aclReassignResignBtn,'role','button');
dojo.attr(aclReassignResignBtn,'wai-role','button');
dojo.attr(aclReassignResignBtn,'aria-label',com.ibm.mm.builder.coreWidgetsStrings.I_ACL_REASSIGN_BTN);
/* end a11y fixes for truncated value */
dojo.addClass(aclReassignResignBtn,"lotusFormButton");
dojo.addClass(aclReassignResignBtn,"lotusFormButtonReassign");
//for a11y
this._defaultFocus = aclReassignResignBtn;
var aclReassignNoChangeBtn = document.createElement("input");
aclReassignNoChangeBtn.setAttribute("type","button");
aclReassignNoChangeBtn.setAttribute("value",htmlUtil.getStrWithLimit(com.ibm.mm.builder.coreWidgetsStrings.I_ACL_REASSIGN_NOT_CHANGE,aclReassignNoChangeBtn,this.maxLen));
aclReassignNoChangeBtn.setAttribute("title",com.ibm.mm.builder.coreWidgetsStrings.I_ACL_REASSIGN_NOT_CHANGE);
/* some a11y fixes */
dojo.attr(aclReassignNoChangeBtn,'role','button');
dojo.attr(aclReassignNoChangeBtn,'wai-role','button');
dojo.attr(aclReassignNoChangeBtn,'aria-label',com.ibm.mm.builder.coreWidgetsStrings.I_ACL_REASSIGN_NOT_CHANGE);
dojo.addClass(aclReassignNoChangeBtn,"lotusFormButton");
dojo.addClass(aclReassignNoChangeBtn,"lotusFormButtonReassignNoChange");
aclReassignButtonDiv.appendChild(aclReassignResignBtn);
aclReassignButtonDiv.appendChild(aclReassignNoChangeBtn);
aclReassignContentDiv.appendChild(aclReassignButtonDiv);
this.aclReassignRootDiv.appendChild(aclReassignContentDiv);
dojo.connect(aclReassignResignBtn, "onclick", this, "reassign");
dojo.connect(aclReassignNoChangeBtn, "onclick", this, "noChange");
},
_getSource:function(perm){
switch(perm){
case "aclView":
this.viewIsSource = true;
return com.ibm.mm.builder.dnd.viewSource ;
case "aclPersonal":
this.personalizeIsSource = true;
return com.ibm.mm.builder.dnd.personalizeSource;
case "aclEdit":
this.editIsSource = true;
return com.ibm.mm.builder.dnd.editSource;
}
},
reassign:function(){
for(var i=0;i0){
dojo.destroy(existingList[0]);
}
var confirmButton = dojo.query(".accessControlReassignConfirm",this.aclReassignDialog.domNode)[0];
confirmButton.parentNode.insertBefore(aclReassignListSpan,confirmButton);
this.aclReassignDialog.show();
//for a11y
this._defaultFocus.focus();
},
/**
* hide the access control reassign dialog
*/
hide: function(){
this.aclReassignDialog.hide();
},
_listToHtml:function(list){
var content ="";
for(var i=0;i" + perm + ""," "," "]);
content = content+ ""+ newItem + "
";
}
return content;
}
});
}
if(!dojo._hasResource["com.ibm.mm.builder.iwidget.navigation.NavigationStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.iwidget.navigation.NavigationStore"] = true;
dojo.provide("com.ibm.mm.builder.iwidget.navigation.NavigationStore");
dojo.require("dojo.data.ItemFileReadStore");
dojo.declare("com.ibm.mm.builder.model.NavigationStore", dojo.data.ItemFileReadStore, {
/**
* summary:
* NavigationNodesReadStore extends ItemFileReadStore to implement an
* navigation model store in Lotus Mashups navigation nodes.
*/
constructor: function(navigationModel, spaceId, pageId){
this.navigationModel = navigationModel;
this.navigationUtil = com.ibm.mm.builder.utils.navigationUtil;
this.pageUtil = com.ibm.mm.builder.utils.pageUtil;
this.acModeUtil = com.ibm.mm.builder.utils.acModelUtil;
this.items = [];
this.canSeeHiddenPages = this.acModeUtil.isPageOwner(pageId) ||
this.acModeUtil.getUserPermission(pageId) === this.acModeUtil.EDIT;
var root = this.navigationUtil.getNavigationRootNode(spaceId);
this.items.push(root);
var childrenIter = this.navigationModel.getChildren(root);
while(childrenIter.hasNext()) {
var childNode = childrenIter.next();
if (this.pageUtil.isVisiable(childNode) || this.canSeeHiddenPages) {
this.items.push(childNode);
}
}
//convert to a map
this.parent_node_map = {};
this.id_node_map = {};
this.rootNode = root;
root.__type = "root";
dojo.forEach(this.items, function(node){
var parent = this.navigationModel.getParent(node.getID()).start();
var parentId = parent ? parent.getID() : null;
if (parentId) {
if (!this.parent_node_map[parentId]) {
this.parent_node_map[parentId] = [];
}
this.parent_node_map[parentId].push(node);
this.id_node_map[node.getID()] = node;
}
}, this);
dojo.forEach(this.items, function(node){
node.__children = this.parent_node_map[node.getID()];
var hasChildren = this.navigationModel.hasChildren(node);
node.__type = hasChildren ? "_stub" : "node";
}, this);
},
//dojo.data.api.Read API
getValue: function( /* item */ item, /* attribute-name-string */ attribute,
/* value? */ defaultValue){
var values = this.getValues(item, attribute);
return (values.length > 0)?values[0]:defaultValue;
},
getValues: function(/* item */ item, /* attribute-name-string */ attribute){
var values = null;
switch(attribute) {
case "id":
values = [item.getID()];
break;
case "title":
if (this.rootNode === item) {
values = [" "];
} else {
values = [this.pageUtil.getUnescapedPageTitle(item.getID())];
}
break;
case "description":
values = [this.pageUtil.getPageDescription(item.getID())];
break;
case "type":
values = item.__type;
break;
case "parentId":
var parent = this.navigationModel.getParent(item.getID()).start();
var parentId = parent ? parent.getID() : null;
values = [parentId];
break;
case "children":
values = item.__children;
break;
case "selfUri":
values = [item.getID()];
break;
default:
values = null;
}
values = (values && dojo.isArray(values)) ? values : [values];
return values;
},
getAttributes: function(/* item */ item){
return ["id", "title", "description", "type", "parentId", "children", "selfUri"];
},
hasAttribute: function( /* item */ item, /* attribute-name-string */ attribute){
return !!(this.getValue(item, attribute));
},
containsValue: function(/* item */ item, /* attribute-name-string */ attribute, /* anything */ value){
return this.getValue(item, attribute) == value;
},
isItem: function(/* anything */ something){
return something.getID();
},
isItemLoaded: function(/* anything */ something) {
return this.isItem(something) && something.__type !== "_stub";
},
/**
* Lazy load sub items
* @param {Object} keywordArgs
*/
loadItem: function(/* object */ keywordArgs){
var item = keywordArgs.item;
this._assertIsItem(item);
var childrenIter = this.navigationModel.getChildren(item);
item.__children = [];
while(childrenIter.hasNext()) {
var childNode = childrenIter.next();
if (this.pageUtil.isVisiable(childNode) || this.canSeeHiddenPages) {
if (!childNode.__type) {
childNode.__type = this.navigationModel.hasChildren(childNode) ? "_stub" : "node";
}
var parent = this.navigationModel.getParent(childNode.getID()).start();
var parentId = parent ? parent.getID() : null;
if (!this.parent_node_map[parentId]) {
this.parent_node_map[parentId] = [];
}
this.parent_node_map[parentId].push(childNode);
this.id_node_map[childNode.getID()] = childNode;
this.items.push(childNode);
item.__children.push(childNode);
}
}
item.__type = "node";
//Done processing! Call the onItem, if any.
if(keywordArgs.onItem){
var scope = keywordArgs.scope ? keywordArgs.scope : dojo.global;
keywordArgs.onItem.call(scope, item);
}
},
getFeatures: function(){
return {'dojo.data.api.Read':true, 'dojo.data.api.Identity':'id'};
},
close: function(/*dojo.data.api.Request || keywordArgs || null */ request){
},
getLabel: function(/* item */ item){
return this.getValue(item, "title");
},
getLabelAttributes: function(/* item */ item){
return ["title"];
},
//dojo.data.api.Identity API
getIdentity: function(/* item */ item){
return this.getValue(item, "id");
},
getIdentityAttributes: function(/* item */ item){
return ["id"];
},
fetchItemByIdentity: function(/* object */ keywordArgs){
var node = this.id_node_map[keywordArgs.identify];
node = node ? node : null;
if(keywordArgs.onItem){
var scope = keywordArgs.scope?keywordArgs.scope:dojo.global;
keywordArgs.onItem.call(scope, node);
}
},
fetch: function(/* Object */ keywordArgs){
var query = keywordArgs.query;
if(query === null){
keywordArgs.onComplete([this.rootNode], keywordArgs);
}
},
getRootItem: function(){
return this.rootNode;
},
reset: function() {
dojo.forEach(this.items, function(item) {
delete item.__type;
delete item.__children;
});
}
});
}
if(!dojo._hasResource["com.ibm.mm.builder.dialog.DialogFooter"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.dialog.DialogFooter"] = true;
dojo.provide("com.ibm.mm.builder.dialog.DialogFooter");
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
dojo.declare("com.ibm.mm.builder.dialog.DialogFooter",
[dijit._Widget, dijit._Templated],
{
templateString:
''+
''+
'${cancelText}'+
//''+
'',
baseClass: "lotusDialogFooter",
widgetId: "",
IWID: "",
saveId: "_${widgetId}_btn_save",
saveClass: "lotusFormButton common_save",
saveText: "${I_COMMON_SAVE}",
saveAccessKey: "Q",
cancelId: "_${widgetId}_cancel_text",
cancelClass: "common_cancel lotusAction",
cancelText: "${I_COMMON_CANCEL}",
cancelAccessKey: "",
resourceBundles: [com.ibm.mm.builder.coreWidgetsStrings],
postMixInProperties: function() {
this.inherited(arguments);
if (this.IWID) {
this.widgetId = this.IWID.substr(1, this.IWID.length - 2);
}
var smashedMixin = dojo.mixin.apply(dojo, [{}, this].concat(this.resourceBundles));
dojo.forEach(["saveId", "saveText", "cancelId", "cancelText"], function(prop){
this[prop] = dojo.string.substitute(this[prop], smashedMixin);
}, this);
},
postCreate: function() {
if (!this.cancelAccessKey) {
this.cancelNode.removeAttribute("accesskey");
}
if (!this.saveAccessKey) {
this.saveNode.removeAttribute("accesskey");
}
this.inherited(arguments);
},
_onSaveKeypress: function(e) {
if (e.charCode === dojo.keys.SPACE || e.keyCode === dojo.keys.ENTER) {
this.onSave(e);
}
},
_onCancelKeypress: function(e) {
if (e.charCode === dojo.keys.SPACE || e.keyCode === dojo.keys.ENTER) {
this.onCancel(e);
}
},
onSave: function(evt) {
},
onCancel: function(evt) {
}
}
);
}
if(!dojo._hasResource["com.ibm.mm.builder.iwidget.spacemanager.SpaceManagerConstants"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.iwidget.spacemanager.SpaceManagerConstants"] = true;
dojo.provide("com.ibm.mm.builder.iwidget.spacemanager.SpaceManagerConstants");
dojo.setObject("com.ibm.mm.builder.iwidget.spacemanager.SpaceManagerConstants", {
ModelName : {
"SpacesCategory" : "spaces_category",
"RecentlyVisitedSpaces" : "recently_visited_spaces",
"FavoriteSpaces" : "favorite_spaces",
"AllSpaces" : "all_spaces",
"MySpaces" : "my_spaces"
},
Topic : {
"Space" : {
"create" : "/spaceManager/space/create",
"update" : "/spaceManager/space/update",
"delete" : "/spaceManager/space/delete",
"filter" : "/spaceManager/space/filter",
"refresh" : "/spaceManager/space/refresh",
"switch" : "/spaceManager/space/switch",
"switchPage" : "/spaceManager/space/switchPage",
"addToRecentSpaces" : "/spaceManager/space/addToRecentSpaces",
"removeFromRecentSpaces" : "/spaceManager/space/removeFromRecentSpaces",
"refreshRecentSpaces" : "/spaceManager/space/refreshRecentSpaces",
"changeSpaceTitle" : "/spaceManager/space/changeSpaceTitle"
},
"Category" : {
"change" : "/spaceManager/category/change"
},
"Common" : {
"showMessage" : "/spaceManager/common/showMessage",
"hideMessage" : "/spaceManager/common/hideMessage"
}
},
Config : {
"RecentSpaces" : {
"MAX_LENGTH" : builderConfig.recentSpacesMaximumNumber,
"INITIAL_SIZE" : builderConfig.recentSpacesMaximumNumber
}
},
Action : {
"ADD_PAGE" : "refreshWithNewPages",
"ADD_FAVORITE" : "refreshWithAddFavorite",
"SHOW_SPACE" : "refreshWithShowSpace",
"HIDE_SPACE" : "refreshWithHideSpace",
"SHOW_PAGE" : "refreshWithShowPage",
"HIDE_PAGE" : "refreshWithHidePage",
"MAKE_HOME" : "refreshWithMakeHomeSpace",
"UNMAKE_HOME" : "refreshWithUnmakeHomeSpace",
"CREATE_SPACE" : "refreshWithCreateSpace",
"DELETE_SPACE" : "refreshWithDeleteSpace",
"EDIT_SPACE" : "refreshWithEditSpace",
"CHANGE_OWNER" : "refreshWithChangeOwner",
"DELETE_PAGE" : "refreshWithDeletePage",
"EDIT_PAGE" : "refreshWithEditPage",
"REMOVE_FAVORITE": "refreshWithRemoveFavorite",
"MOVE_PAGE" : "refreshWithMovePage"
},
CookieKey: {
RECENT_SPACES: "digest.ignore.recent.spaces."
},
"ALL" : "all",
"FAVORITE" : "favorite",
"MY" : "my"
});
}
if(!dojo._hasResource["com.ibm.mm.builder.dialog.ReorderingPageDialog"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.dialog.ReorderingPageDialog"] = true;
dojo.provide("com.ibm.mm.builder.dialog.ReorderingPageDialog");
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
dojo.require("dijit.Tree");
dojo.require("dijit.tree.TreeStoreModel");
dojo.require("dojo.fx");
dojo.require("dojo.string");
/**
* This class will initialize the embed page widget UI element.
*/
dojo.declare("com.ibm.mm.builder.dialog.ReorderingPageDialog", [dijit._Widget, dijit._Templated], {
/**
* the ID for the page to be reordered.
* @type String
*/
pageId:null,
spaceId:null,
widgetId:null,
store: null,
navigationTree: null,
targetPageId: null,
_lastSelection: null, // last selected dom node
// Attach points
messageBox: null,
navTree: null,
pageTitleLabel: null,
form: null,
widgetsInTemplate : true,
templateString: null,
constructor: function(args){
dojo.mixin(this,args);
this.navigationUtil = com.ibm.mm.builder.utils.navigationUtil;
this.pageUtil = com.ibm.mm.builder.utils.pageUtil;
this.spaceUtil = com.ibm.mm.builder.utils.spaceUtil;
this.LOGGER = com.ibm.mashups.enabler.logging.Logger.getLogger("com.ibm.mm.builder.dialog.ReorderingPageDialog");
this.templateString = "\
\
";
},
postMixInProperties: function() {
this.bundle = com.ibm.mm.builder.coreWidgetsStrings;
this.messages = com.ibm.mm.builder.coreWidgetsMessages;
dojo.mixin(this, this.bundle);
},
setPageId: function(pageId, spaceId) {
this.pageId = pageId;
this.spaceId = spaceId || this.spaceUtil.getSpaceIdByPageId(pageId);
dojo.fadeOut({node: this.messageBox}).play();
},
refresh: function() {
this.showMessage(false);
this.targetPageId = null;
this.currentPageId = this.pageId;
var currentPageName = this.pageUtil.getPageTitle(this.currentPageId);
// this.currentPageId = this.pageUtil.getCurrentPageId();
// var currentPageName = this.pageUtil.getCurrentPageTitle();
this.pageTitleLabel.innerHTML = this.bundle.I_MOVE_THE_PAGE_TO_BE;
if (this.navigationTree) {
this.navigationTree.destroy();
}
var navModel = this.navigationUtil.getNavigationModel();
this.store = new com.ibm.mm.builder.model.NavigationStore(navModel, this.spaceId, this.pageId);
var model = new dijit.tree.TreeStoreModel({
store : this.store,
labelAttr : "title",
typeAttr : "type",
childrenAttr: ["children"]
});
this.navigationTree = new dijit.Tree({
id: "navigation_tree_" + this.widgetId,
model: model,
persist : false,
showRoot : true,
getIconClass : function(/*dojo.data.Item*/ item, /*Boolean*/ opened) {
return (!item || item === this.model.store.rootNode) ? "rootNode" : "pageNode";
}
}).placeAt(this.navTree);
// #10147: remove the blue pane on the root node of the tree view.
if (!(dojo.isIE || window.ActiveXObject !== undefined)) {
dojo.query(".dijitTreeIsRoot .dijitTreeRow .dijitTreeLabel", this.navTree).at(0).style({
backgroundColor: "inherit"
});
}
this.navigationTree.startup();
this.connect(this.navigationTree, "onClick", "onTitleClick");
// #13126
this.connect(this.navigationTree, "_expandNode", "onExpandNode");
},
onRadioKeyPress: function(e) {
if(e.ctrlKey) {
var radioButtons = this.form.position;
var curRadioIndex = 0;
var curRadioButton = e.currentTarget;
var len = radioButtons.length;
for(var i = 0; i < len; i++) {
if(curRadioButton == radioButtons[i]) {
curRadioIndex = i;
break;
}
}
nextRadioIndex = curRadioIndex < len - 1 ? curRadioIndex + 1 : 0;
prevRadioIndex = curRadioIndex > 0 ? curRadioIndex - 1 : len - 1;
var key = e.keyCode;
if (key === dojo.keys.LEFT_ARROW || key === dojo.keys.UP_ARROW) {
radioButtons[prevRadioIndex].focus();
} else if (key === dojo.keys.RIGHT_ARROW || key === dojo.keys.DOWN_ARROW) {
radioButtons[nextRadioIndex].focus();
}
}
},
/**
* #13126
* Reset DijitTeeNode width in case the background position exceed the width when the node is being expanded.
*/
onExpandNode: function(node) {
// 20490: PORTAL: highlights not working properly on move pg. dialog
// not setting 'width' style to have the highlight cover the whole tree
// view
// var pixels = (Math.max(node.indent + 5, 0) * 19) + "px";
// dojo.style(node.domNode, "width", pixels);
},
onTitleClick: function(item, node) {
var domNode = node.contentNode;
if (domNode !== this._lastSelection) {
if (this._lastSelection) {
dojo.removeClass(this._lastSelection, "selected");
}
dojo.addClass(domNode, "selected");
this._lastSelection = domNode;
}
var inputNode = dojo.query("input[name='position']", this.form);
inputNode.forEach(function(input) {input.disabled = false;});
if (item === this.pageUtil.getPageNode(this.currentPageId)) {
// Current node is not allowed
this.showMessage(this.messages.E_DIFFERENT_LOCATION_REQUIRED_0, "error");
inputNode.forEach(function(input){
input.disabled = true;
});
} else if (this.navigationUtil.isDescendant(this.currentPageId, item.getID())) {
// Descendant node is not allowed
this.showMessage(this.messages.E_NEW_PAGE_POSITION_MISSING_0, "error");
inputNode.forEach(function(input){
input.disabled = true;
});
} else {
var currentPage = this.pageUtil.getPageNode(this.currentPageId);
var invalidMove=this._getInvalidMoveMethod(item,currentPage);
if(!!invalidMove && invalidMove.length>0){
if(invalidMove.length<3){
this.showMessage(false);
}else{
this.showMessage(this.messages.E_DIFFERENT_LOCATION_REQUIRED_0, "error");
}
this._disableInputs(inputNode,invalidMove);
}
if (!dojo.every(inputNode, function(input){
return input.disabled;
})) {//skip this check when all the inputs are already disabled
inputNode.forEach(function(input){
if (!input.disabled) {
var position = input.value;
var context = this.navigationUtil.getReorderPageContext(item.getID(), position);
// @Stephan #11481 Start
// input.disabled =
// !this.navigationUtil.getNavigationModel().confirmInsert(null,
// context.parent, null); // FIXME: comment out this
// line
input.disabled = !this.navigationUtil.getNavigationModel().confirmInsert(currentPage, context.parent, context.next);
// @Stephan #11481 End
}
}, this);
if (dojo.every(inputNode, function(input){
return input.disabled;
})) {
this.showMessage(this.messages.E_MOVE_PAGE_INSUFFICIENT_ACCESS_RIGHTS_0, "error");
}
else {
this.showMessage(false);
}
}
}
this.targetPageId = item.getID();
},
_getInvalidMoveMethod:function(item,page){
if (item === this.store.rootNode) {
// Only position children is allowed for rootNode
var invalidMove=["previous","next"];
var pageContenxt = this.navigationUtil.getPageContext(page.getID());
if(pageContenxt.parent == item){//if the page is already the direct child of root
invalidMove.push("children");
}
return invalidMove;
}else{
var pageContext = this.navigationUtil.getPageContext(item.getID());
var result=[];
if(pageContext.next==page){
result.push("next");
}
if(pageContext.previous ==page){
result.push("previous");
}
if(this.navigationUtil.isDescendant(item.getID(),page.getID(),1)){
result.push("children");
}
return result;
}
},
_disableInputs:function(inputNode,/*Array*/disableValues){
if(!dojo.isArray(disableValues)){
disableValues=[];// enable all
}
var changeSelection = false;
inputNode.forEach(function(input){
if (dojo.indexOf(disableValues,input.value)>=0) {
if (input.disabled === false && input.checked === true){
// uncheck disabled radio
input.checked = false;
changeSelection = true;
}
input.disabled = true;
} else {
input.disabled = false;
}
});
// find a new valid selection: first enabled radio from top
if (changeSelection === true) {
var selectionFound = false;
inputNode.forEach(function(input){
if (input.disabled === false && !selectionFound){
input.checked = true;
selectionFound = true;
}
});
}
},
hide: function() {
com.ibm.mashups.services.ServiceManager.getService("eventService").broadcastEvent("com.ibm.mashups.builder.closeMashupDialog", this.widgetId);
if (this.store) {
this.store.reset();
}
},
save: function() {
var position = dojo.formToObject(this.form).position;
var currentPageParentId = this.pageUtil.getParentPageId(this.currentPageId);
var targetPageParentId = this.pageUtil.getParentPageId(this.targetPageId);
var currentPage = this.pageUtil.getPageNode(this.currentPageId);
if (this.targetPageId && position) {
var context = this.navigationUtil.getReorderPageContext(this.targetPageId, position);
// @Stephan #11481 Start
// Enable if..else below
if (this.navigationUtil.getNavigationModel().confirmInsert(currentPage, context.parent, context.next)) {
var result = this.navigationUtil.reorderPageNode(this.currentPageId, this.targetPageId, position);
if (result) {
this.showMessage(result, "error");
}
else {
//update space manager UI
var constants = com.ibm.mm.builder.iwidget.spacemanager.SpaceManagerConstants;
dojo.publish(constants.Topic.Space.refresh,[constants.Action.MOVE_PAGE, {currentPageId:this.currentPageId, currentPageParentId:currentPageParentId, targetPageId:this.targetPageId, targetPageParentId:targetPageParentId, position:position}]);
this.hide();
}
}
else {
this.showMessage(this.messages.E_MOVE_PAGE_INSUFFICIENT_ACCESS_RIGHTS_0, "error");
}
// @Stephan #11481 End
} else {
this.showMessage(this.messages.E_NEW_PAGE_POSITION_MISSING_0, "error");
this.LOGGER.severe("save", this.messages.E_NEW_PAGE_POSITION_MISSING_0);
}
},
/**
* Display message in message box
* @param {Object} message
* @param {Object} type Optional. Type of message, includes 'info', 'error', 'warning'
*/
showMessage: function(message, type) {
if (!message) {
dojo.fadeOut({node: this.messageBox}).play();
dojo.style(this.messageBox, "display", "none");
return false;
}
dojo.empty(this.messageBox);
var img = dojo.create("img", {}, this.messageBox);
var span = dojo.create("span", {
"innerHTML": message
}, this.messageBox);
switch(type) {
case "info":
dojo.attr(img, {
"alt": "Information",
"src": builderConfig.builderPath + "/images/info_icon.png" // JSLINT-IGNORE
});
dojo.toggleClass(this.messageBox, "lotusWarning", false);
dojo.toggleClass(this.messageBox, "lotusInfo", true);
break;
case "warning":
dojo.attr(img, {
"alt": "Warning",
"src": builderConfig.builderPath + "/images/warning_icon.png"
});
dojo.toggleClass(this.messageBox, "lotusWarning", true);
dojo.toggleClass(this.messageBox, "lotusInfo", false);
break;
default: // "error" as default
dojo.attr(img, {
"alt": "Error",
"src": builderConfig.builderPath + "/images/error_icon.png"
});
dojo.toggleClass(this.messageBox, "lotusWarning", false);
dojo.toggleClass(this.messageBox, "lotusInfo", false);
}
dojo.style(this.messageBox, "display", "block");
dojo.fadeIn({node: this.messageBox}).play();
}
});
}
if(!dojo._hasResource["com.ibm.mm.builder.iwidget.wiringscreen.WiringModel"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.iwidget.wiringscreen.WiringModel"] = true;
dojo.provide("com.ibm.mm.builder.iwidget.wiringscreen.WiringModel");
dojo.provide("com.ibm.mm.builder.iwidget.wiringscreen.SelectedModel");
/**
* The Wiring model, contains an model array represent all the widgets data and their relationships
*/
dojo.declare("com.ibm.mm.builder.iwidget.wiringscreen.WiringModel", null, {
constructor: function(selectedWidgetId){
var pageID = com.ibm.mashups.builder.model.Factory.getRuntimeModel().getCurrentPage().getID();
this.navModel = com.ibm.mashups.enabler.navigation.Factory.getNavigationModel();
var currentPage = this.navModel.find(pageID).start();
this.layoutModel = this.navModel.getLayoutModel(currentPage);
this.widgetModel = com.ibm.mashups.enabler.widget.Factory.getWidgetModel();
var selectedLc = this.layoutModel.find(selectedWidgetId).start();
this.selectedWindowId = this.widgetModel.getWidgetWindow(selectedLc).start().getID();
this.selectedWidgetId = selectedWidgetId;
var themeModel = null;
themeModel = com.ibm.mashups.builder.model.Factory.getRuntimeModel().getCurrentTheme();
this.layouts = themeModel.getLayouts();
this.wiringModel = [];
this.root = null;
this.selectedRoot = [];
this.notRootWidgets = [];
this.rootArray = [];
},
setupWiringModel: function(){
this.setupInitialData();
//this._setupRootArray();
this._setupModel();
},
setupWidgetWindowMap: function() {
var lmRoot = this.layoutModel.getRoot().start();
if (this.layoutModel.hasChildren(lmRoot)) {
var iterator = this.layoutModel.getChildren(lmRoot);
iterator.setCursorPosition(0);
while (iterator.hasNext()) {
// it is com.ibm.mm.enabler.layout.LayoutContainerImpl
var node = iterator.next();
var _iterator = this.layoutModel.getChildren(node);
_iterator.setCursorPosition(0);
// iterate through the children
while (_iterator.hasNext()) {
// it is com.ibm.mm.enabler.layout.LayoutControlImpl
var childNode = _iterator.next();
if (childNode instanceof (com.ibm.mashups.enabler.layout.LayoutControl)) {
var lcID = childNode.getID();
var widgetWindow = this.widgetModel.getWidgetWindow(childNode).start();
var windowID = widgetWindow.getID();
this.widgetWindowMap[windowID] = lcID;
}
}
}
}
},
setupInitialData: function(){
this.eventsMap = {};
this.widgetWindowMap = {};
var incomingWires = null;
var eventTargetObject = {};
var handleEvent = null;
var incomingWire = null;
this.setupWidgetWindowMap();
// get current page
var navModel = com.ibm.mashups.enabler.navigation.Factory.getNavigationModel();
var currentPID = com.ibm.mashups.builder.model.Factory.getRuntimeModel().getCurrentPage().getID();
var currentPage = navModel.find(currentPID).start();
var lm = navModel.getLayoutModel(currentPage);
var lc = lm.find(this.selectedWidgetId).start();
incomingWires = com.ibm.mm.builder.utils.wireUtil.getWiresTargetCSA2(lc, currentPID);
eventTargetObject[this.selectedWidgetId] = this.selectedWidgetId;
for (var n = 0; n < incomingWires.length; n++) {
incomingWire = incomingWires[n];
handleEvent = {};
handleEvent[incomingWire.getSourceEventName()] = eventTargetObject;
//TODO: check because enabler has a bug here, remove source widget will not remove the wire
// #17088, the wire is still in wire model after you delete the widget..
// so we have to workaround with, detect wether the widget is removed
var sourceId = incomingWire.getSourceWidget().getID();
var targetId = incomingWire.getTargetWidget().getID();
if(this.widgetWindowMap[sourceId] && this.widgetWindowMap[targetId]) {
this.rootArray.push({
sourceWidget: sourceId,
sourceEvent: incomingWire.getSourceEventName(),
targetWidget: targetId,
targetEvent: incomingWire.getTargetEventName()
});
}
}
var widgetsArray = this._getOtherLayoutControls(currentPID);
for (var i = 0; i < widgetsArray.length; i++) {
var currLC = widgetsArray[i];
var wires = com.ibm.mm.builder.utils.wireUtil.getWiresTargetCSA2(currLC, currentPID);
for (var j = 0, length = wires.length; j < length; j++) {
if (wires[j].getSourceWidget().getID() == this.selectedWindowId) {
var wire = wires[j];
this.rootArray.push({
sourceWidget: wire.getSourceWidget().getID(),
sourceEvent: wire.getSourceEventName(),
targetWidget: wire.getTargetWidget().getID(),
targetEvent: wire.getTargetEventName()
});
}
}
}
},
_getOtherWidgets: function(){
var iwidgetsFromHTMLFragment = com.ibm.mm.builder.utils.wireUtil.getAllWidgetsInLayouts(this.layouts);
var len = iwidgetsFromHTMLFragment.length;
var widgetsArray = [];
for (var x = 0; x < len; x++) {
var id = iwidgetsFromHTMLFragment[x];
if (id != this.selectedWidgetId) {
// TODO: CSA2 Replace with model api
var targetWrapper = com.ibm.mashups.iwidget.model.Factory.getGlobalWidgetModel().find(id);
widgetsArray.push(targetWrapper);
}
}
return widgetsArray;
},
_getOtherLayoutControls: function(pageID){
var layoutControls = com.ibm.mm.builder.utils.wireUtil.getAllLayoutControlsCSA2(pageID);
var len = layoutControls.length;
var widgetsArray = [];
for (var x = 0; x < len; x++) {
var currLayout = layoutControls[x];
if (currLayout.getID() != this.selectedWidgetId) {
widgetsArray.push(currLayout);
}
}
return widgetsArray;
},
/**
* Find out the root widget from eventService
*/
_setupRootArray: function(){
var wires = this.eventsMap;
for (var source in wires) {
if (Object.prototype.hasOwnProperty.call(wires,source)) {
for (var event in wires[source]) {
if (Object.prototype.hasOwnProperty.call(wires[source],event)) {
for (var target in wires[source][event]) {
if (Object.prototype.hasOwnProperty.call(wires[source][event],target) && wires[source][event][target].length > 0) {
var wireItem = {
source: source,
event: event,
target: target,
dataName: ""
};
this.rootArray.push(wireItem);
}//end if
}//end for
}//end if(wires[source])
}//end for
}//end if(wires)
}//end for
},
/**
* set up the model
*/
_setupModel: function(){
for (var i = 0, length = this.rootArray.length; i < length; i++) {
var wire = this.rootArray[i];
// TODO: CSA2 Update with correct model calls
this._addLinkToModel(wire.sourceWidget, wire.targetWidget);
}
},
/**
* Add a link to the model, take
* @param {Object} sourceId source as parent
* @param {Object} targetId target as child
*/
_addLinkToModel: function(sourceId, targetId){
var _sourceLcId = this.widgetWindowMap[sourceId];
var _targetLcId = this.widgetWindowMap[targetId];
var sourceModel = this.getModel(_sourceLcId);
var targetModel = this.getModel(_targetLcId);
sourceModel.childrenArray.push(_targetLcId);
targetModel.parents.push(_sourceLcId);
},
/**
* Get the sub model centerd by selected widget
* @param {String} selectedWidgetId
* @return {com.ibm.mm.builder.iwidget.wiringscreen.SubWiringModel} sub model
*/
getSelectedModelFrom: function(selectedWidgetId){
return new com.ibm.mm.builder.iwidget.wiringscreen.SelectedModel(selectedWidgetId, this);
},
/**
* Get the root of the a widget,
* @param {String} widgetId
* @return {Array} widget list
*/
getRootFrom: function(widgetId){
this.selectedRoot = this.getParents(widgetId);
if (this.selectedRoot.length === 0) {
this.selectedRoot.push(this.getModel(widgetId));
}
return this.selectedRoot;
},
/**
* Get the children of the wiring model
* @param {String} widgetId
* @return {Array} the children list
*/
getChildren: function(widgetId){
var children = [];
for (var i = 0, length = this.wiringModel.length; i < length; i++) {
if (this.wiringModel[i].id == widgetId) {
var childrenID = this.wiringModel[i].childrenArray;
for (var j = 0; j < childrenID.length; j++) {
var childInfo = this.getInfo(childrenID[j]);
if (childInfo) {
children.push(childInfo);
}
}
break;
}
else {
continue;
}
}
return children;
},
/**
* Get the parent of the wiring model
* @param {String} widgetId
*/
getParents: function(widgetId){
//return [];
var parents = [];
for (var i = 0, length = this.wiringModel.length; i < length; i++) {
if (this.wiringModel[i].id == widgetId) {
var parentsID = this.wiringModel[i].parents;
for (var j = 0; j < parentsID.length; j++) {
var parentInfo = this.getInfo(parentsID[j]);
if (parentInfo) {
parents.push(parentInfo);
}
}
break;
}
else {
continue;
}
}
return parents;
},
/**
* Get the info of the specific wiring model
* @param {String} widgetId
* @return {Object} widgetModel
*/
getInfo: function(widgetId){
for (var i = 0, length = this.wiringModel.length; i < length; i++) {
if (this.wiringModel[i].id == widgetId) {
return this.wiringModel[i];
}
else {
continue;
}
}
},
/**
* Get the model info for the specific wiring model, if the model is not exist, create and return
* @param {Object} widgetId An iWidget Object
* @return {Object} widgetModel
*/
getModel: function(/*iWidget Object*/widgetId){
var widgetTitle = "";
var widgetIcon = "";
var visibility = true;
// get current page
var currentPageId = com.ibm.mashups.builder.model.Factory.getRuntimeModel().getCurrentPage().getID();
var navModel = com.ibm.mashups.enabler.navigation.Factory.getNavigationModel();
var currentPage = navModel.find(currentPageId).start();
var lm = navModel.getLayoutModel(currentPage);
var lc = lm.find(widgetId).start();
var widgetModel = com.ibm.mashups.enabler.widget.Factory.getWidgetModel();
var widgetWindow = widgetModel.getWidgetWindow(lc).start();
var title = com.ibm.mm.builder.utils.enablerUtil.getNodeTitle(lc,dojo.locale);
if (title == null) {
title = "";
}
var icon = lc.getMetaData("icon") || lc.getMetaData("thumbnail");
if (icon === null) {
icon = com.ibm.mm.builder.constant.generic_widget_icon;
}
widgetTitle = title;
widgetIcon = icon;
var widgetModel = this.getInfo(widgetId);
if (widgetModel === null || widgetModel === undefined) {
widgetModel = {
id: widgetId,
name: widgetTitle,
icon: widgetIcon,
parents: [],
childrenArray: [],
visibility: visibility,
position: {
x: 0,
y: 0
},
selected: false
};
this.wiringModel.push(widgetModel);
}
return widgetModel;
},
_alreadyInWidgetInfoArray: function(widgetInfo, widgetInfoArray){
var widgetInfoList = [];
var isAllExist = true;
if (dojo.isArray(widgetInfo)) {
widgetInfoList = widgetInfo;
}
else {
widgetInfoList = [widgetInfo];
}
for (var i = 0; i < widgetInfoList.length; i++) {
// var widgetInfo = widgetInfoList[i];
var isExist = false;
for (var j = 0, length = widgetInfoArray.length; j < length; j++) {
if (widgetInfoList[i].id == widgetInfoArray[j].id) {
isExist = true;
break;
}
}
isAllExist = isAllExist && isExist;
}
return isAllExist;
},
_removeFromWidgetInfoArray: function(widgetInfo, widgetInfoArray){
for (var i = 0, length = widgetInfoArray.length; i < length; i++) {
if (widgetInfo.id == widgetInfoArray[i].id) {
widgetInfoArray.splice(i, 1);
}
}
}
});
/**
* The subclass of Wiring model. used to represent a submodel that related to the selected widget
* It can compute the depth and width of the model tree, and the coordinate of each widget which will be rendered on the canvas.
*/
dojo.declare("com.ibm.mm.builder.iwidget.wiringscreen.SelectedModel", com.ibm.mm.builder.iwidget.wiringscreen.WiringModel, {
constructor: function(widgetId, parentModel){
this.size = {
x: 1,
y: 1
};//size of the sub model
this.parentsHeight = [0];
this.childrenHeight = [0];
this.levelHeight = []; //array contains the depth of each level in the tree
this.parentModel = parentModel;
this.widgetId = widgetId;
this.wiringModel = [];
//initial the model
this._setModelFrom(widgetId);
},
/**
* Initial the selected model from the selected widget
* @param {String} widgetId
*/
_setModelFrom: function(widgetId){
var centerWidgetInfo = this.parentModel.getModel(widgetId);
if (centerWidgetInfo) {
this._addSelectedItem(centerWidgetInfo);
this._addParentsToModel(this.widgetId, 1);
this._addChildrenToModel(this.widgetId, 1);
this._computeWiringMapSize();
this._computeWidgetsPosition();
}
},
/**
* Check weather the model has link in it
*/
hasLink: function(){
//if leveHeight length greater than zero, it has link in it
return (this.levelHeight.length > 1);
},
/**
* Add selected widget to the model
*/
_addSelectedItem: function(centerWidgetInfo){
centerWidgetInfo.position.y = 1;
centerWidgetInfo.position.x = 0;
centerWidgetInfo.selected = true;
this.wiringModel.push(centerWidgetInfo);
},
/**
* Add related parents to the submodel
* @param {String} widgetId
* @param {number} level The distance from the selected widget to this widget, start from 1
*/
_addParentsToModel: function(widgetId, level){
var parents = this.parentModel.getParents(widgetId);
if (parents.length > 0 && (this.parentsHeight[level] === null || this.parentsHeight[level] === undefined)) {
this.parentsHeight.push(0);
}
for (var i = 0, length = parents.length; i < length; i++) {
if (!this.getInfo(parents[i].id)) {
parents[i].position.x = -level;
this.parentsHeight[level]++;
parents[i].position.y = this.parentsHeight[level];
parents[i].selected = false;
this.wiringModel.push(parents[i]);
//now we only get the directly parents
//this._addParentsToModel(parents[i].id, level + 1);
}
}
},
/**
* Add related child to the submodel
* @param {String} widgetId
* @param {number} level The distance from the selected widget to this widget, start from 1
*/
_addChildrenToModel: function(widgetId, level){
var children = this.parentModel.getChildren(widgetId);
if (this._alreadyInWidgetInfoArray(children, this.wiringModel)) {
return;
}
if (children.length > 0 && (this.childrenHeight[level] === null || this.childrenHeight[level] === undefined)) {
this.childrenHeight.push(0);
}
for (var i = 0, length = children.length; i < length; i++) {
if (!this.getInfo(children[i].id)) {
children[i].position.x = level;
this.childrenHeight[level]++;
children[i].position.y = this.childrenHeight[level];
children[i].selected = false;
this.wiringModel.push(children[i]);
//now we only get the directly children
//this._addChildrenToModel(children[i].id, level + 1);
}
}
},
/**
* Compute the number of number of level and max height of levels of the model tree
*/
_computeWiringMapSize: function(){
//compute the max width
var maxWidth = this.parentsHeight.length + this.childrenHeight.length - 1;
var maxHeight = 1;
var i = 1;
//find the max height of each level
for (i = 1; i < this.parentsHeight.length; i++) {
if (this.parentsHeight[i] > maxHeight) {
maxHeight = this.parentsHeight[i];
}
}
for (i = 1; i < this.childrenHeight.length; i++) {
if (this.childrenHeight[i] > maxHeight) {
maxHeight = this.childrenHeight[i];
}
}
//record the size of the model
this.size = {
x: maxWidth,
y: maxHeight
};
//initial the array according to the max width.
for (i = 0; i < maxWidth; i++) {
this.levelHeight.push(0);
}
},
/**
* Compute the position of each widget thumb on canvas
*/
_computeWidgetsPosition: function(){
var parentsHeight = this.parentsHeight.length - 1;
for (var i = 0, length = this.wiringModel.length; i < length; i++) {
//Shift the position x to the place will be drawn
this.wiringModel[i].position.x += parentsHeight;
//record the height of each level
if (this.levelHeight[this.wiringModel[i].position.x] < this.wiringModel[i].position.y) {
this.levelHeight[this.wiringModel[i].position.x] = this.wiringModel[i].position.y;
}
}
}
});
}
if(!dojo._hasResource["com.ibm.mm.builder.iwidget.wiringscreen.WiringItem"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.iwidget.wiringscreen.WiringItem"] = true;
dojo.provide("com.ibm.mm.builder.iwidget.wiringscreen.WiringItem");
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
/**
* The WiringItem widget, serve as the thumb of each widget in the overview graph
*/
dojo.declare("com.ibm.mm.builder.iwidget.wiringscreen.WiringItem", [dijit._Widget, dijit._Templated],
{
templateString:"\n\t\n\t\n\n",
id:"",
icon:null,
name:null,
title:null,
originalname:null,
parents:null,
childrenArray:null,
visibility:true,
position: {x:0, y:0},
maxNameLength: 12,
cutLength: 9,
IEMaxNameLength: 12,
defaultName: "Mashups Widget",
isSelected:false,
widgetNameStyleName: "itemname",
postCreate : function(){
var locale = dojo.locale;
if(locale && (locale.indexOf("zh-tw") === 0 ||
locale.indexOf("ja") === 0 ||
locale.indexOf("ko") === 0)){
this.maxNameLength = 6;
this.cutLength = 4;
this.IEMaxNameLength = 6;
}
this._setWidgetName();
this._setWidgetImage();
this._setImageBackground();
this.domNode.setAttribute("id", this.id + "_overviewgraph_item");
},
/**
* set the widget name style
*/
_setWidgetName: function(){
this.textNode.innerHTML = this.title || this.defaultName;
com.ibm.mm.builder.utils.htmlUtil.truncateNodeText(this.textNode, null, {fontSize:"1.2em",fontWeight:"bold"});
if(this.isSelected){
this._setWidgetNameStyle("selected");
}else if(this.visibility){
this._setWidgetNameStyle("visible");
}else{
this._setWidgetNameStyle("hidden");
}
},
/**
* set the widget name style
*/
_setWidgetNameStyle: function(classPrefix){
com.ibm.mm.builder.utils.htmlUtil.addClass(this.textNode, classPrefix + this.widgetNameStyleName);
},
/**
* set the image of the widget item
*/
_setWidgetImage: function(){
var image = document.createElement("img");
image.setAttribute("src",this.icon);
dojo.attr(image, "width", 19);
dojo.attr(image, "height", 19);
this.imageNode.appendChild(image);
this.imageNode.setAttribute("id", this.id + "_overviewgraph_item_icon");
this.imageNode.title = this.title || this.defaultName;
image.alt = this.title || this.defaultName;
},
/**
* set the class as the hidden/visible style
*/
_setImageBackground: function(){
if(this.visibility){
com.ibm.mm.builder.utils.htmlUtil.addClass(this.imageNode, "visibleitembackground");
}else{
com.ibm.mm.builder.utils.htmlUtil.addClass(this.imageNode, "hiddenitembackground");
}
},
/**
* get the short name of the widget name
*/
_getShortName: function(){
this.originalname = this.title;
if(!this.title){
return this.defaultName;
}
this.title = dojo.trim(this.title);
var maxLength = this.maxNameLength;
if (dojo.isIE) {
maxLength = this.IEMaxNameLength;
}
if(this.title.length < maxLength){
return this.title;
}else{
this.title = this.title.substring(0, this.cutLength) + "...";
return this.title;
}
},
/**
* get the image dom node
*/
getImageNode : function(){
return this.imageNode;
}
});
}
if(!dojo._hasResource["com.ibm.mm.builder.iwidget.wiringscreen.WiringCanvas"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.iwidget.wiringscreen.WiringCanvas"] = true;
dojo.provide("com.ibm.mm.builder.iwidget.wiringscreen.WiringCanvas");
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
/**
* The WiringCanvas widget. it use the wiring model to render the overview graph in a dialog
*/
dojo.declare("com.ibm.mm.builder.iwidget.wiringscreen.WiringCanvas", [dijit._Widget, dijit._Templated], {
templateString: "" +
"" +
"" +
"",
alone:true,
diagramNode: null,
cws: com.ibm.mm.builder.coreWidgetsStrings,
constructor: function(params){
//all widget thumb in the canvas
this.itemList = [];
//the thumb of iwidget already drawed on canvas
this.finishedWidgetList = [];
this.finishedLinkList = [];
this.widgetItemQueue = [];
//the default size of thumb and the arrow link
this.bgWidth = 82;
this.itemWidth = 92;
this.gridHorizontalInterval = 120;
this.bgHeight = 54;
this.gridHeight = 2 * this.bgHeight;
this.gridWidth = this.itemWidth + this.gridHorizontalInterval;
this.arrowWidth = 12;
this.arrowHeight = 10;
this.canvasMargin = 0;
this.minCanvasWidth = 420 ;
this.minCanvasHeight = 100 ;
this.maxDialogHeight = 5 * this.gridHeight + 10;
this.lineCornerRadius = 4;
this.dialogSideBarWidth = 0;
this.dialogBackgroundColor = "#1f1f1f";
this.dialogTopAndBottom = 20/*bottom height*/ + 36/*top height*/ + 2/*dialog border*/ + 2;
this.explainText = "";
},
postCreate: function(){
this.createDialog();
},
/**
* create and show the wiring graph
*/
showGraph:function(){
this.showLoading();
this.createModel();
dojo["require"]("dojox.gfx"); // JSLINT-IGNORE: needed here, if not loaded in layer
this.hideLoading();
this.createGraph();
},
/**
* Create the dialog contains the wiring graph
*/
createDialog: function(){
this.wiringDialog = new com.ibm.mm.builder.widget.CleanDialog({
id: this.selectedWidgetId + "_wireGraph",
nodeWidth: null, // the content node width, not the dialog, so you can focus on your own node
nodeHeight: null, // the content node width, null for autofix
title: this.cws.I_WIRINGGRAPH_TITLE,
containerBackgroundColor: null, // the background color of the container
displayCloseButton: true,
modelDialog:this.alone,
hasRightBottomResizer: false,
leftBarWidth: this.dialogSideBarWidth + "px",
rightBarWidth: this.dialogSideBarWidth + "px",
containerNodePadding: "0px",
bottomBarTipColor: "#ff9a9a",
closeCallback: dojo.hitch(this, function(){
this.destroy();
})
});
this.wiringDialog.containerNode.appendChild(this.domNode);
if(!this.alone) {
var wirePaneDlg = dijit.byId("wireInterface_uniDialog");
if (wirePaneDlg) {
wirePaneDlg.registerSubDialog(this.selectedWidgetId + "_wireGraph");
}
}
},
/**
* Show a loading tips when computing the diagram
*/
showLoading: function(){
this.loadingNode = document.createElement("div");
var imgPath = builderConfig.builderPath + "/images/loading.gif";
this.loadingNode.innerHTML = "" +
"" + this.I_WIRINGGRAPH_LOADING_MESSAGE + "";
this.wiringDialog.domNode.style.width = this.minCanvasWidth + "px";
this.graphContainer.appendChild(this.loadingNode);
this.show();
},
/**
* Hide the loading tips when computing the diagram
*/
hideLoading: function(){
this.graphContainer.removeChild(this.loadingNode);
},
/**
* create the model of the wiring graph
*/
createModel: function(){
this.parentWiringModel = new com.ibm.mm.builder.iwidget.wiringscreen.WiringModel(this.selectedWidgetId);
//Initialize the whole model of all widget
this.parentWiringModel.setupWiringModel();
//Create the model from the selected widget
this.wiringModel = this.parentWiringModel.getSelectedModelFrom(this.selectedWidgetId);
},
/**
* create the the wiring graph and show it
*/
createGraph: function(){
this.wiringDialog.setNodeWidth(this.getCanvasWidth() + "px");
this.wiringDialog.show();
// #14393, IE failed if the vml node created before the dialog shown up.
window.setTimeout(dojo.hitch(this, function() {
//set up the canvas for drawing graph
this._setupCanvas();
//get root from the selected widget
var roots = this.wiringModel.getRootFrom(this.selectedWidgetId);
//loop to make all link in the tree added to the canvas
for (var i = 0, length = roots.length; i < length; i++) {
this.widgetItemQueue.push(roots[i]);
}
this._drawLinks();
// set the info tip at the bottom
if (this.wiringModel.hasLink()) {
this._setupBottomTips();
this.diagramExplainTextNode.innerHTML = this.explainText;
dojo.attr(this.diagramNode, "title", this.explainText);
} else {
var msg = this.cws.I_WIRINGGRAPH_NO_WIRING ? this.cws.I_WIRINGGRAPH_NO_WIRING : "No wiring connected";
this.diagramExplainTextNode.innerHTML = msg;
dojo.attr(this.diagramNode, "title", msg);
}
}), 700);
},
/**
* set the help information
*/
_setupBottomTips: function(){
var selectedWidget = this._getWidget({"id":this.selectedWidgetId});
var widgetName = com.ibm.mm.builder.utils.iwidgetUtil.formatWidgetTitle(selectedWidget.title);
var widgetNameForTip = "" + widgetName + "";
var bottomTip = dojo.string.substitute(this.cws.I_WIRINGGRAPH_BOTTOM_MESSAGE_BEFORE, [widgetNameForTip]);
//this.wiringDialog.setBottomTip(bottomTip);
com.ibm.mm.builder.utils.htmlUtil.setClass(this.diagramTip, "wiringgrpahbottomtip");
this.diagramTip.innerHTML = bottomTip;
//this.wiringDialog.setBottomTipColor("#ff9a9a");
},
/**
* initialize the canvas for drawing the wiring overview graph
*/
_setupCanvas: function(){
var canvasWidth = this.getCanvasWidth();
var canvasHeight = this.getCanvasHeight();
// setup the diagram node
this.diagramNode = document.createElement("div");
dojo.attr(this.diagramNode,"tabindex","0");
this.diagramExplainTextNode = document.createElement("span");
this.diagramTip = document.createElement("div");
this.domNode.style.width = canvasWidth + "px";
//this.domNode.style.height = canvasHeight + "px";
com.ibm.mm.builder.utils.htmlUtil.setClass(this.diagramNode, "diagramnode");
com.ibm.mm.builder.utils.htmlUtil.setClass(this.diagramExplainTextNode, "diagramExplainTextNode");
//must append on domNode before create surface, or will raise error on IE
this.graphContainer.appendChild(this.diagramExplainTextNode);
this.graphContainer.appendChild(this.diagramNode);
this.graphContainer.appendChild(this.diagramTip);
this.surface = dojox.gfx.createSurface(this.diagramNode, canvasWidth, this._getSurfaceHeight());
},
/**
* show the wiring graph dialog and set the backgound dark.
*/
show: function(){
this.wiringDialog.show();
},
/**
* draw all the links
*/
_drawLinks: function(){
var tmpItem = this.widgetItemQueue.splice(0,1)[0];
this._drawLinksFrom(tmpItem);
},
/**
* Draw the graph from root
* @param {Object} source The root node
*/
_drawLinksFrom: function(source){
if (!source) {
return;
}
//for 20752. A source can appear in widgetItemQueue multiple times depending how many events it wires to another widget.
//It appears that once a source is processed, it's removed from the queue. What left in there are those need to be processed.
//if (!this._isFinishedWidget(source.id)) {
var children = this.wiringModel.getChildren(source.id);
//first create the source widget in case it not exit.
this._getWidgetDomNode(source);
//find all the children of the source and create the link on the canvas
for (var i = 0, length = children.length; i < length; i++) {
var target = children[i];
if (target) {
this._createLink(source, target);
}
}
//mark this widget as finished
this.finishedWidgetList.push(source.id);
//recursion to the chldren of the source
for (var j = 0, jlength = children.length; j < jlength; j++) {
if (children[j]) {
this.widgetItemQueue.push(children[j]);
}
}
this._drawLinksFrom(this.widgetItemQueue.splice(0,1)[0]);
// }
},
/**
* Check weather the widget is already created in the graph
* @param {number} id The id of the widget
*/
_isFinishedWidget: function(id){
for (var i = 0, length = this.finishedWidgetList.length; i < length; i++) {
if (this.finishedWidgetList[i] == id) {
return true;
}
}
return false;
},
/**
* Check weather the link from srouce to target is already created in the graph
* @param {number} sourceId The id of the source widget
* @param {number} targetId The id of the target widget
*/
_isFinishedLink: function(sourceId,targetId){
for (var i = 0, length = this.finishedLinkList.length; i < length; i++) {
if (this.finishedLinkList[i].source == sourceId && this.finishedLinkList[i].target == targetId) {
return true;
}
}
return false;
},
/**
* create link between widgets
* @param {Object} source The source widget
* @param {Object} target The target widget
*/
_createLink: function(source, target){
if (this._isRelateToSelectedWidget(source, target)) {
if (this._isFinishedLink(target.id, source.id)) {
this._createBackArrow(target);
}
else {
this._createForwardLink(source, target);
}
this._generateExplainText(source, target);
}
},
_generateExplainText: function(source, target){
this.explainText += dojo.string.substitute(this.cws.I_WIRINGGRAPH_LINK_EXPLAIN_TEXT, [source.title, target.title]);
},
_isRelateToSelectedWidget:function(source, target){
if (source.id == this.selectedWidgetId || target.id == this.selectedWidgetId) {
return true;
}
return false;
},
/**
* Create a back arrow on exsit link
* @param {Object} target The id of the target widget
*/
_createBackArrow: function(target){
var targetWidgetNode = this._getWidgetDomNode(target);
var arrowPoint = this._getBackArrowPoint(targetWidgetNode);
//create the arrow on the surface
var image = this._createImage(builderConfig.builderPath + (!builderConfig.isBidi) ? "/images/arow_head_left.gif" : "/images/arow_head_left.gif",
this.arrowWidth,
this.arrowHeight
);
//move the image of arrow to the right place
image.setTransform(dojox.gfx.matrix.translate(arrowPoint.x, arrowPoint.y));
},
_createImage : function(src, width, height) {
var image = this.surface.createImage({
width: width,
height: height,
src: src
});
if (dojo.isSafari != 4) {
return image;
}
else {
var group = this.surface.createGroup();
group.add(image);
return image;
}
},
/**
* Create forword link
* @param {Object} source The id of the source widget
* @param {Object} target The id of the target widget
*/
_createForwardLink: function(source, target){
//get the model and create the related widget
var sourceWidgetNode = this._getWidgetDomNode(source);
var targetWidgetNode = this._getWidgetDomNode(target);
//if source is not finished and hasLoop(source, target) draw a loop
//else // a normal link
//caculate the place
var startPoint = this._getStartPoint(sourceWidgetNode);
var endPoint = this._getEndPoint(targetWidgetNode);
var middlePoints = this._getMiddlePoints(startPoint, endPoint);
var lineStyle = {
color: [255, 255, 255],
width: 2,
dashstyle: "solid"
};
//the start line
var startX = (!builderConfig.isBidi)?(middlePoints[0].x - this.lineCornerRadius):(middlePoints[0].x + this.lineCornerRadius);
var path = "M" + startPoint.x + " " + startPoint.y + //start point
" L" +
//(middlePoints[0].x - this.lineCornerRadius) +
(startX) +
" " +
middlePoints[0].y; //end point
this.surface.createPath(path).setStroke(lineStyle);
//the first round corner
//path = "M" + (middlePoints[0].x - this.lineCornerRadius) + " " + middlePoints[0].y +//start point
path = "M" + (startX) + " " + middlePoints[0].y +
" S" +
middlePoints[0].x +
" " +
middlePoints[0].y +
" " +
middlePoints[0].x +
" " +
this._getFirstCornerStartY(middlePoints);//end point
this.surface.createPath(path).setStroke(lineStyle);
//the vertical line
path = "M" + (middlePoints[0].x) + " " + this._getFirstCornerStartY(middlePoints) +//start point
" L" +
middlePoints[1].x +
" " +
this._getSecondCornerStartY(middlePoints);//end point
this.surface.createPath(path).setStroke(lineStyle);
//the second round corner
var endX = (!builderConfig.isBidi)?(middlePoints[1].x + this.lineCornerRadius):(middlePoints[1].x - this.lineCornerRadius);
path = "M" + middlePoints[1].x + " " + this._getSecondCornerStartY(middlePoints) +//start point
" S" +
middlePoints[1].x +
" " +
middlePoints[1].y +
" " +
//(middlePoints[1].x + this.lineCornerRadius) +
endX +
" " +
middlePoints[1].y ;
this.surface.createPath(path).setStroke(lineStyle);
//the end line
//path = "M" + (middlePoints[1].x + this.lineCornerRadius) + " " + middlePoints[1].y +//start point
path = "M" + (endX) + " " + middlePoints[1].y +//start point
" L" +
endPoint.x +
" " +
endPoint.y; //end point
this.surface.createPath(path).setStroke(lineStyle);
var arrowPoint = this._getArrowPoint(endPoint);
//create the arrow on the surface
var arrowHead = (!builderConfig.isBidi) ? "/images/arow_head.gif" : "/images/arow_head_left.gif";
var image = this._createImage(builderConfig.builderPath + arrowHead,
this.arrowWidth,
this.arrowHeight
);
//move the image of arrow to the right place
// #11717 No need to hack IE6 from 2.0
//if((dojo.isIE === 6 ) && builderConfig.isBidi){
// image.setTransform(dojox.gfx.matrix.translate(arrowPoint.x - this.getCanvasWidth(), arrowPoint.y));
//}else{
image.setTransform(dojox.gfx.matrix.translate(arrowPoint.x, arrowPoint.y));
//}
this.finishedLinkList.push({"source":source.id,"target":target.id});
},
/**
* get the Y of end point in the first coner(that is the start point of the vertical line)
* @param {Object} middlePoints
*/
_getFirstCornerStartY : function(middlePoints){
var y = middlePoints[0].y;
if(middlePoints[0].y < middlePoints[1].y){
return y + this.lineCornerRadius;
}else if(middlePoints[0].y > middlePoints[1].y){
return y - this.lineCornerRadius;
}else{
return y;
}
},
/**
* get the Y of end point in the second coner(that is the end point of the vertical line)
* @param {Object} middlePoints
*/
_getSecondCornerStartY : function(middlePoints){
var y = middlePoints[1].y;
if(middlePoints[0].y < middlePoints[1].y){
return y - this.lineCornerRadius;
}else if(middlePoints[0].y > middlePoints[1].y){
return y + this.lineCornerRadius;
}else{
return y;
}
},
/**
* Create or get(if already exsit) the item(as domNode) of the widget
* @param {Object} itemInfo The infomation of the widget
*/
_getWidgetDomNode: function(itemInfo){
return this._getWidget(itemInfo).domNode;
},
/**
* Create or get(if already exsit) the item's image dom node of the widget
* @param {Object} itemInfo The infomation of the widget
*/
_getWidgetImageNode: function(itemInfo){
return this._getWidget(itemInfo).getImageNode();
},
/**
* Create or get(if already exsit) the item(as a widget) of the widget
* @param {Object} itemInfo The infomation of the widget
*/
_getWidget : function(itemInfo){
//if has already been created, just return
for (var i = 0, length = this.itemList.length; i < length; i++) {
if (this.itemList[i].id == itemInfo.id) {
return this.itemList[i].itemWidget;
}
}
//if not created yet, create it
var widgetNode;
var widgetTitle = com.ibm.mm.builder.utils.iwidgetUtil.getWidgetTitleCSA2(itemInfo.id);
var widgetIcon = com.ibm.mm.builder.utils.iwidgetUtil.getWidgetIconCSA2(itemInfo.id);
dojo.mixin(itemInfo, {
"isSelected": (itemInfo.id == this.selectedWidgetId),
"title": widgetTitle, "icon": widgetIcon});
var item = new com.ibm.mm.builder.iwidget.wiringscreen.WiringItem(itemInfo);
//set the layout variable
var marginLeft = (this.wiringModel.size.x * this.gridWidth <= this.minCanvasWidth + 80)? 60: 20;
var marginTop = 20;
var marginLeftForOne = (this.minCanvasWidth- 100)/2;
var marginTopForOne = 20;
var gridWidth = this.gridWidth;
var gridHeight = this.gridHeight;
var itemWidth = this.itemWidth;
widgetNode = item.domNode;
var x = null;
var y = null;
if(!this.wiringModel.hasLink()){
if(builderConfig.isBidi){
x = this.getCanvasWidth() - (itemInfo.position.x * gridWidth + marginLeftForOne) - itemWidth + "px";
}else{
x = (itemInfo.position.x * gridWidth + marginLeftForOne) + "px";
}
y = ((itemInfo.position.y-1) * gridHeight + marginTopForOne) + "px";
this._setWidgetPositionAndAdd(widgetNode, x, y);
} else if (this.wiringModel.levelHeight[itemInfo.position.x] == this.wiringModel.size.y) {
//if the wiring model has no link relationship or the height of this level is the size of the model
//draw the widget according to the original place
if(builderConfig.isBidi){
x = this.getCanvasWidth() - (itemInfo.position.x * gridWidth + marginLeft) - itemWidth + "px";
}else{
x = (itemInfo.position.x * gridWidth + marginLeft) + "px";
}
y = ((itemInfo.position.y-1) * gridHeight + marginTop) + "px";
this._setWidgetPositionAndAdd(widgetNode, x, y);
}
else {
//if the height of this level is not the size of model, compute the height of the grid height
var interGridHight = ((this.wiringModel.size.y - 1) / this.wiringModel.levelHeight[itemInfo.position.x]) * gridHeight;
var extendMarginTop = interGridHight / 2;
if (builderConfig.isBidi) {
x = this.getCanvasWidth() - (itemInfo.position.x * gridWidth + marginLeft) - itemWidth + "px";
}else {
x = (itemInfo.position.x * gridWidth + marginLeft) + "px";
}
y = ((itemInfo.position.y - 1) * interGridHight + marginTop + extendMarginTop) + "px";
this._setWidgetPositionAndAdd(widgetNode, x, y);
}
//add the widget to the itemList
this.itemList.push({
id: itemInfo.id,
itemWidgetNode: widgetNode,
itemWidget: item
});
return item;
},
/**
* Create a Highlight div node for the selected widget
* @param {Widget} item A wiring item
*/
_createHighlightDiv: function(item){
var highlightDiv = document.createElement("div");
com.ibm.mm.builder.utils.htmlUtil.setClass(highlightDiv, "hightlightwiringgraphitem");
highlightDiv.appendChild(item.domNode);
return highlightDiv;
},
/**
* get the start point of a link
* @param {DomNode} node The node of the start item of a link
*/
_getStartPoint: function(node){
//compute the x and y coordinate of the start posion
var coords = dojo.coords(node);
var px = coords.l + this.itemWidth - (this.itemWidth-this.bgWidth)/2;
if (builderConfig.isBidi) {
px = px - this.itemWidth;
}
var py = coords.t + this.bgHeight / 2;
return {
x: px,
y: py
};
},
/**
* get the end point of a link
* @param {DomNode} node The node of the end item of a link
*/
_getEndPoint: function(node){
//compute the x and y coordinate of the end posion
var coords = dojo.coords(node);
var px = coords.l - this.arrowWidth + (this.itemWidth-this.bgWidth)/2;
if (builderConfig.isBidi) {
px = px + this.itemWidth;
}
var py = coords.t + this.bgHeight / 2;
return {
x: px,
y: py
};
},
/**
* get the middle points of a link to form the curve
* @param {Object} start The coordinate of the start position a link
* @param {Object} end The coordinate of the end position a link
*/
_getMiddlePoints: function(start, end){
//compute the x and y coordinate of the middle positions
var mx = (start.x + end.x) / 2;
//compute the y coordinate of the first and second middle positions
var my1 = start.y;
var my2 = end.y;
return [{
x: mx,
y: my1
}, {
x: mx,
y: my2
}];
},
/**
* get the points of the arrow on a link
* @param {Object} end The coordinate of the end position a link
*/
_getArrowPoint: function(end){
return {
x: end.x,
y: (end.y - this.arrowHeight/2)
};
},
/**
* get the points of the back arrow on a link
* @param {Object} end The coordinate of the end position a link
*/
_getBackArrowPoint: function(node){
//compute the x and y coordinate of the start posion
var startPoint = this._getStartPoint(node);
return {
x: startPoint.x - 2,
y: startPoint.y - this.arrowHeight/2
};
},
/**
* get the number of a size like "10px"
* @param {String} v The size in "10px" format
*/
_getPixel: function(v){
return parseInt(v.substring(0, v.indexOf('p')),10);
},
/**
* compute the canvas dom node width
*/
getCanvasWidth: function(){
var width = this.wiringModel.size.x * this.gridWidth - 80;
if (width < this.minCanvasWidth) {
width = this.minCanvasWidth;
}
return width;
},
/**
* compute the Dialog(Customized Dialog in Mashups) width
*/
getMMDialogWidth: function(){
var width = (this.getCanvasWidth() + 2*(this.dialogSideBarWidth+1) + 2*this.canvasMargin);
return (width + "px");
},
/**
* compute the canvas dom node height
*/
getCanvasHeight: function(){
var height = this.wiringModel.size.y * this.gridHeight + 10;
if (height < this.minCanvasHeight) {
height = this.minCanvasHeight;
}
return height;
},
/**
* compute the Dialog container height
*/
_getDialogContainerHeight: function(){
var height = this.getCanvasHeight();
if (height > this.maxDialogHeight) {
height = this.maxDialogHeight;
}
return height;
},
/**
* compute the Dialog(Customized Dialog in Mashups) height
*/
getMMDialogHeight: function(){
var height = this._getDialogContainerHeight() + this.dialogTopAndBottom;
return (height + "px");
},
/**
* compute the svg surface height
*/
_getSurfaceHeight: function(){
return (this.getCanvasHeight() - 4);
},
/**
* add a wiring item dom node on wiring canvas
*/
_setWidgetPositionAndAdd: function(widget, left, top){
widget.style.top = top;
// #11717 No need to hack on IE6 from 2.0
// if (dojo.isIE === 6 && builderConfig.isBidi) {
// widget.style.left = (parseInt(left) - this.getCanvasWidth())+"px";
// }
// else {
widget.style.left = left;
// }
this.graphContainer.appendChild(widget);
},
/**
* destroy all the wiring items and dialog
*/
destroy: function(){
for (var i = 0, length = this.itemList.length; i < length; i++) {
this.itemList[i].itemWidget.destroy();
}
this.inherited(arguments);
this.wiringDialog.destroy();
}
});
}
if(!dojo._hasResource["com.ibm.mm.builder.iwidget.wiringscreen.WiringSettingsDialog"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.iwidget.wiringscreen.WiringSettingsDialog"] = true;
dojo.provide("com.ibm.mm.builder.iwidget.wiringscreen.WiringSettingsDialog");
com.ibm.mm.builder.iwidget.wiringscreen.WiringSettingsConstants = {
SEMANTIC_TYPES_ONLY: 0,
PAYLOAD_TYPES_ONLY: 1,
SEMANTIC_OR_PAYLOAD_TYPES: 2,
SETTING_MATCHING_TYPE: "matchingType"
};
dojo.declare("com.ibm.mm.builder.iwidget.wiringscreen.WiringSettingsDialog", [dijit._Widget, dijit._Templated], {
notificationDialog:null,
widgetId: null,
dialogWidgetId: "Mashup_Wiring_Settings_Dlg",
templateString:"\n\n\n \n \n \n\n\n\n\t\n\n\n",
constants: com.ibm.mm.builder.iwidget.wiringscreen.WiringSettingsConstants,
constructor:function(){
},
onSettingsSaved: function ( /*Map*/settings ) {
},
postCreate:function(){
this.initContent();
},
setOuterContext: function ( ctx ) {
this.outerContext = ctx;
},
setMatchingType: function ( currentMatchingType ) {
//Should be set by the code opening the dialog.
switch ( currentMatchingType ) {
case 0: this.matchingOption1.checked = true; break;
case 1: this.matchingOption2.checked = true; break;
case 2: this.matchingOption3.checked = true; break;
default: this.matchingOption1.checked = true;
}
},
initContent:function(){
var cws = com.ibm.mm.builder.coreWidgetsStrings;
this.matchingOptionsTitleDiv.innerHTML = cws.I_WIRING_MATCHING_MODE;
this.matchingOption1Text.innerHTML = cws.I_WIRING_ALIAS_MATCH;
this.matchingOption1.value = this.constants.SEMANTIC_TYPES_ONLY;
this.matchingOption2Text.innerHTML = cws.I_WIRING_PAYLOAD_TYPE_MATCH;
this.matchingOption2.value = this.constants.PAYLOAD_TYPES_ONLY;
this.matchingOption3Text.innerHTML = cws.I_WIRING_PAYLOAD_TYPE_OR_ALIAS_MATCH;
this.matchingOption3.value = this.constants.SEMANTIC_OR_PAYLOAD_TYPES;
dojo.attr(this.buttonDivDone,"title",cws.I_WIRING_DONE);
dojo.attr(this.buttonDivDone,"value",cws.I_WIRING_DONE);
dojo.connect( this.buttonDivDone, "onclick", dojo.hitch( this, this.makeSelectionAndClose ) );
var contentDiv = document.createElement("div");
contentDiv.appendChild(this.wiringSettingsDiv);
this.notificationDialog = dijit.byId(this.dialogWidgetId);
if (!this.notificationDialog) {
this.notificationDialog = new com.ibm.mm.builder.widget.CustomDialog({
id: this.dialogWidgetId,
title: cws.I_WIRING_SETTINGS_DIALOG_NAME,
needUnderLay: true,
roundCorner: false,
modelDialog: true,
hasRightBottomResizer: false
}, contentDiv);
}
},
onRadioKeyPress: function(e) {
if(e.ctrlKey) {
var radioButtons = dojo.query("input[name='matchingOption']", this.wiringSettingsDiv);
var curRadioIndex = 0;
var curRadioButton = e.currentTarget;
var len = radioButtons.length;
for(var i = 0; i < len; i++) {
if(curRadioButton == radioButtons[i]) {
curRadioIndex = i;
break;
}
}
nextRadioIndex = curRadioIndex < len - 1 ? curRadioIndex + 1 : 0;
prevRadioIndex = curRadioIndex > 0 ? curRadioIndex - 1 : len - 1;
var key = e.keyCode;
if (key === dojo.keys.LEFT_ARROW || key === dojo.keys.UP_ARROW) {
radioButtons[prevRadioIndex].focus();
} else if (key === dojo.keys.RIGHT_ARROW || key === dojo.keys.DOWN_ARROW) {
radioButtons[nextRadioIndex].focus();
}
}
},
destroy:function() {
this.notificationDialog.destroy();
},
show:function(widgetId) {
this.notificationDialog.show();
},
hide:function(){
if(this.notificationDialog) {
this.notificationDialog.hide();
}
},
_buildSettingsMap: function () {
var settings = {};
settings[ this.constants.SETTING_MATCHING_TYPE ] = this._getMatchingType();
return settings;
},
_getMatchingType: function () {
var choice;
if ( this.matchingOption1.checked ) {
choice = parseInt( this.matchingOption1.value );
} else if ( this.matchingOption2.checked ) {
choice = parseInt( this.matchingOption2.value );
} else if ( this.matchingOption3.checked ) {
choice = parseInt( this.matchingOption3.value );
}
return choice;
},
makeSelection: function () {
var settings = this._buildSettingsMap();
this.onSettingsSaved( settings );
},
makeSelectionAndClose: function () {
this.makeSelection();
this.hide();
}
});
}
if(!dojo._hasResource["com.ibm.mm.builder.iwidget.wiringscreen.WirePaneWithSettings"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.iwidget.wiringscreen.WirePaneWithSettings"] = true;
dojo.provide("com.ibm.mm.builder.iwidget.wiringscreen.WirePaneWithSettings");
dojo.require("dijit.Dialog");
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
(function(){
var cws = com.ibm.mm.builder.coreWidgetsStrings;
var htmlUtil = com.ibm.mm.builder.utils.htmlUtil;
dojo.declare("com.ibm.mm.builder.iwidget.wiringscreen.WirePaneWithSettings", [dijit._Widget, dijit._Templated], {
templateString:"\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\t\n\n",
iContext: null,
iwidgetId: "", //the widget uid
displayQName: "true",
/*
* The divs for display the corresponding info
*/
wirePane: null,
wirePaneDiv: null,
wirePaneTitleDiv: null,
wirePaneTitleDivLeft: null,
wirePaneWarningMessage: null,
sendIconDiv: null,
sendWireCountDiv: null,
receiveWireCountDiv: null,
wirePaneTitleDivRight: null,
recIconDiv: null,
wirePaneCurrentWidgetDiv: null,
wirePaneEventsDiv: null,
wirePaneWidgetsDiv: null,
wirePaneWidgetEventsDiv: null,
wirePaneAdaptersDiv: null,
firstAreaTopDiv: null,
firstAreaDiv: null,
firstAreaBottomDiv: null,
secondAreaBottomDiv: null,
secondAreaDiv: null,
secondAreaTopDiv: null,
thirdAreaDiv: null,
bottomQmarkDiv: null,
bottomDiv: null,
prompter: null,
widgetObj: null, // cache object, store all the widget-related info(name,icon...)
highlightTimer: null,
selectedEvent: "", //user selected event
selectedWireWidget: "",
//cache object, widgets which have match event
widgets: null,
//cache object, the events map for current event
eventsMap: null,
currentType: "", // current tab ( send/receive)
grayTip: null, // The bottom Div for showing the Tip
showPrompter: true,
currentPageId: "", // Current page
localized: com.ibm.mashups.enabler.context.Factory.getLocalizedContext(), //TODO - does this need to change?
wiringSettingsDialog: null, // dialog to open the wiring settings - controlled by the displaySettings option
wiringSettings: null, // settings map - only available after the wiring settings dialog has been closed
wiringSettingsConstants: com.ibm.mm.builder.iwidget.wiringscreen.WiringSettingsConstants, // constants for settings
/**
* current action step
* 1: init
* 2: choose event
* 3: choose widget
*/
actionStep: 1,
clickedWidgetDiv: null, // the clicked widget div in the second pane
allHanWires: 0,
allPubWires: 0,
titleFontStyle: {
fontSize: "1.4em",
fontFamily: "Arial,Helvetica,sans-serif",
fontWeight: "bold"
},
defaultFontStyle: {
fontSize: "1.4em",
fontFamily: "Arial,Helvetica,sans-serif",
fontWeight: "normal"
},
italicStyle: {
fontSize: "1.4em",
fontFamily: "Arial,Helvetica,sans-serif",
fontWeight: "normal",
fontStyle: "italic"
},
LOGGER: com.ibm.mashups.enabler.logging.Logger.getLogger("com.ibm.mm.builder.iwidget.wiringscreen.WirePane2"),
setSelectedEvent: function(eventName){
this.selectedEvent = eventName;
},
destroy: function () {
if ( this.wiringSettingsDialog ) {
this.wiringSettingsDialog.destroy();
}
this.inherited( arguments );
},
/**
* Init the wire pane, place divs into right position and set the css class
*/
initWirePane: function(){
var config = this.iContext.getiWidgetAttributes();
var shouldShowSettings = config.getItemValue("displaySettings");
var shouldShowWarning = config.getItemValue("displayPortletsAndWidgetsWarningMessage");
shouldShowSettings = ( shouldShowSettings === "true" ? true : false );
shouldShowWarning = ( shouldShowWarning === "true" ? true : false );
if ( shouldShowWarning ) {
this.wirePaneWarningMessage.innerHTML = cws.I_WIRING_PORTLETS_AND_WIDGETS;
} else {
this.hideElement(this.wirePaneWarningMessage );
}
this.grayTip = document.createElement("div");
this.grayTip.innerHTML = cws.I_WIRING_NO_MATCH_WIDGET;
//Init the 2 main panes, hide the second at first
dojo.fx.wipeOut({
node: this.secondAreaDiv,
duration: 10
}).play();
this.hideElement(this.secondAreaBottomDiv);
//Init the title (text, icon)
this.createTitleDiv();
//Current widget's event
this.wirePaneEventsDiv.setAttribute("id", "wirePaneEventsDiv_id");
this.wirePaneWidgetsDiv.style.display = "none";
dojo.fx.wipeOut({
node: this.wirePaneWidgetEventsDiv,
duration: 10
}).play();
// Buttons on the right-bottom
dojo.attr(this.buttonDivDone, "title", cws.I_WIRING_DONE);
dojo.attr(this.buttonDivDone, "value", cws.I_WIRING_DONE);
dojo.attr(this.buttonDivGraph, "title", cws.I_WIRING_SHOW_GRAPH);
dojo.attr(this.buttonDivGraph, "value", cws.I_WIRING_SHOW_GRAPH);
dojo.attr(this.wirePaneTitleDivLeft, "title", cws.I_WIRING_TITLE_RECEIVE + " " + this.allHanWires);
dojo.attr(this.wirePaneTitleDivRight, "title", cws.I_WIRING_TITLE_SEND + " " + this.allPubWires);
this.connect(this.closer, "onclick", this.closePrompter);
this.connect(this.closer, "onkeypress", this.keyPrompter);
this.connect(this.bottomQmarkDiv, "onclick", this.onClickQmark);
this.connect(this.bottomQmarkDiv, "onkeypress", this.onKeyQmark);
var closeFun = function(){
com.ibm.mashups.services.ServiceManager.getService("eventService").broadcastEvent("com.ibm.mashups.builder.closeMashupDialog", this.iContext.widgetId);
com.ibm.mm.builder.utils.wireUtil.removeHighlight();
};
this.connect(this.buttonDivDone, "onclick", dojo.hitch(this, closeFun));
this.connect(this.buttonDivGraph, "onclick", dojo.hitch(this, function(){
this.onClickShowGraph();
com.ibm.mm.builder.utils.wireUtil.removeHighlight();
}));
if (shouldShowSettings) {
dojo.attr(this.buttonDivSettings, "title", cws.I_COMMON_ACTION_SETTINGS);
dojo.attr(this.buttonDivSettings, "value", cws.I_COMMON_ACTION_SETTINGS);
dojo.connect(this.buttonDivSettings, "onclick", dojo.hitch(this, this.openWiringSettings));
}
else {
this.hideElement(this.buttonDivSettings);
}
if (this.iContext.dialogContainer) {
this.connect(this.iContext.dialogContainer.closeButtonNode, "onclick", dojo.hitch(this, closeFun));
}
},
/**
* Util function, hide the div
* @param {Object} div
*/
hideElement: function(div){
div.style.display = "none";
},
showElement: function(div){
div.style.display = "";
},
/**
* Display the prompter on the left side based on action step
* @param {Object} step // in which step of current action, value should be 1,2,3
* @param {Object} domNode
*/
displayPrompter: function(step){
//save the status for restore from hidden
this.actionStep = step;
if (this.showPrompter === false) {
return;
}
var align = {
'TL': 'TR',
'BR': 'BL'
};
var properColor = this.getProperColor(step);
var closerNode = dojo.query(".mumPrompterCloser", this.prompter)[0];
htmlUtil.setClass(closerNode, "mumPrompterCloser");
dojo.addClass(closerNode, "mumCloser" + properColor);
//for a11y
closerNode.innerHTML = "";
var contentNode = dojo.query(".mumPrompterContent", this.prompter)[0];
htmlUtil.setClass(contentNode, "mumPrompterContent");
dojo.addClass(contentNode, "mumContent" + properColor);
var arrowNode = dojo.query(".mumPrompterArrow", this.prompter)[0];
htmlUtil.setClass(arrowNode, "mumPrompterArrow");
dojo.addClass(arrowNode, "mumPrompterArrow" + properColor);
var textNode = dojo.query(".mumPrompterContentText", this.prompter)[0];
var labelNode = dojo.query(".mumPrompterContentLabel", this.prompter)[0];
htmlUtil.setClass(labelNode, "mumPrompterContentLabel");
dojo.addClass(labelNode, "mumLabel" + properColor);
dojo.attr(textNode, "keepBlankSpace", "");
var truncatedWidgetName = htmlUtil.truncateWord(textNode, this.widgetObj.widgetname, 120);
// always truncate word no matter it is fontsizeEnlareged
var truncatedSelectedEvent = htmlUtil.truncateWord(textNode, this.selectedEventTitle, 120, true);
var truncatedWiredWidget = htmlUtil.truncateWord(textNode, this.selectedWireWidget, 120);
var prompterFont = {fontSize: "1.2em"};
switch (step) {
case "1":
if (this.currentType == "Send") {
textNode.innerHTML = htmlUtil.getStrWithLimit(
dojo.string.substitute(cws.I_WIRING_PROMPTER_SEND_1, ["" + truncatedWidgetName + ""]),
textNode, 585, prompterFont);
}
else {
textNode.innerHTML = htmlUtil.getStrWithLimit(
dojo.string.substitute(cws.I_WIRING_PROMPTER_RECEIVE_1, ["" + truncatedWidgetName + ""]),
textNode, 530, prompterFont);
}
labelNode.innerHTML = cws.I_WIRING_PROMPTER_STEP_1;
htmlUtil.setClass(this.prompter, "mumPrompterAtEvents");
break;
case "2":
if (this.currentType == "Send") {
textNode.innerHTML = htmlUtil.getStrWithLimit(
dojo.string.substitute(cws.I_WIRING_PROMPTER_SEND_2, ["" + truncatedSelectedEvent + ""]),
textNode, 585, prompterFont);
}
else {
textNode.innerHTML = htmlUtil.getStrWithLimit(
dojo.string.substitute(cws.I_WIRING_PROMPTER_RECEIVE_2, ["" + truncatedSelectedEvent + ""]),
textNode, 530, prompterFont);
}
labelNode.innerHTML = cws.I_WIRING_PROMPTER_STEP_2;
htmlUtil.setClass(this.prompter, "mumPrompterAtWidgets");
break;
case "3":
if (this.currentType == "Send") {
textNode.innerHTML = htmlUtil.getStrWithLimit(
dojo.string.substitute(cws.I_WIRING_PROMPTER_SEND_3, ["" + truncatedWiredWidget + "", "" + truncatedSelectedEvent + ""]),
textNode, 585, prompterFont);
}
else {
textNode.innerHTML = htmlUtil.getStrWithLimit(
dojo.string.substitute(cws.I_WIRING_PROMPTER_RECEIVE_3, ["" + truncatedWiredWidget + "", "" + truncatedWidgetName + ""]),
textNode, 530, prompterFont);
}
labelNode.innerHTML = cws.I_WIRING_PROMPTER_STEP_3;
htmlUtil.setClass(this.prompter, "mumPrompterAtWidgetEvents");
break;
}
this.prompter.style.visibility = "visible";
// var borderTop = htmlUtil.getCurrentStyle(this.prompter,'border-top-width');
// var borderBottom = htmlUtil.getCurrentStyle(this.prompter,'border-bottom-width');
window.setTimeout(dojo.hitch(this, function() {
var coord = dojo.coords(this.prompter);
var coordArrow = dojo.coords(this.arrowNode);
var temp = coord.h - coordArrow.h + coordArrow.t;
this.arrowNodeMid.style.height = temp + "px";
}), 200); // set innerHTML will be slow
},
keyPrompter: function(e){
if(e.keyCode === dojo.keys.ENTER) this.closePrompter();
},
closePrompter: function(){
this.showPrompter = false;
this.prompter.style.visibility = "hidden";
this.bottomQmarkDiv.style.visibility = "visible";
},
onKeyQmark: function(e){
if(e.keyCode === dojo.keys.ENTER) this.onClickQmark();
},
onClickQmark: function(){
this.showPrompter = true;
this.prompter.style.visibility = "visible";
this.displayPrompter(this.actionStep);
this.bottomQmarkDiv.style.visibility = "hidden";
},
/**
* This function will be invoked when user click the "Show Graph" button
* Hide the wire interface and display the wiring graph
*/
onClickShowGraph: function(){
com.ibm.mashups.services.ServiceManager.getService("eventService").broadcastEvent("com.ibm.mashups.builder.displayWireGraph", this.iwidgetId);
// this.iContext.scope.displayWireGraph(this.iwidgetId,true);
},
/**
* Get the proper color name based on current tab and action step
* @param {Object} step: action step, should be 1/2/3
* @return Blue or Green
*/
getProperColor: function(step){
switch (step) {
case "1":
if (this.currentType == "Send") {
return "Green";
}
else {
return "Blue";
}
break;
case "2":
if (this.currentType == "Send") {
return "Blue";
}
else {
return "Green";
}
break;
case "3":
if (this.currentType == "Send") {
return "Blue";
}
else {
return "Green";
}
break;
}
},
/**
* Util function
* Get the proper text for event name display
* @param {Object} name
*/
getProperName: function(name){
var result = "";
if (name.length >= 18) {
result = result + name.substring(0, 14) + "...";
}
else {
result = result + name;
}
result = result + "";
return result;
},
/**
* Util function
* Get the proper text for widget title display
* @param {Object} name
*/
getProperTitle: function(name, len){
var result = "";
if (len === null) {
len = 25;
}
if (name.length >= len) {
result = result + name.substring(0, len - 4) + "...";
}
else {
result = result + name;
}
result = result + "";
return result;
},
/**
* Util function
* Get the proper text for combined common data type
* @param {Object} type
*/
getShownType: function(type){
var checker = com.ibm.mm.builder.utils.wireUtil.dataTypeChecker();
if(this.displayQName=="false") { // remove the qname in {}
type = type.replace(/^\{.*}/, "");
}
return checker.getTypeLabel(type);
},
/**
* Own wipeIn function to avoid the "height=auto" problem of dojo.fx.wipeIn
* @param {Object} args
*/
wipeIn: function(args){
args.node = dojo.byId(args.node);
var node = args.node, s = node.style, o;
var anim = dojo.animateProperty(dojo.mixin({
properties: {
height: {
// wrapped in functions so we wait till the last second to query (in case value has changed)
start: function(){
// start at current [computed] height, but use 1px rather than 0
// because 0 causes IE to display the whole panel
o = s.overflow;
s.overflow = "hidden";
if (s.visibility == "hidden" || s.display == "none") {
s.height = "1px";
s.display = "";
s.visibility = "";
return 1;
}
else {
var height = dojo.style(node, "height");
return Math.max(height, 1);
}
},
end: function(){
return node.scrollHeight;
}
}
}
}, args));
this.connect(anim, "onEnd", function(){
//s.height = "auto";
s.overflow = o;
});
return anim; // dojo._Animation
},
/**
* Util function
* Generate a div element with the given css class
* @param {string} className : the css class name for the div
*/
createDivWithClass: function(className){
var tempDiv = document.createElement("div");
dojo.addClass(tempDiv, className);
return tempDiv;
},
/**
* Adjust the div class when switch between "Send" and "Receive" model
*/
adjustDivsStyle: function(){
this.tabpanel.setAttribute("aria-labelledby", "wirePaneTab" + this.currentType);
this.adjustTitleDiv();
htmlUtil.setClass(this.firstAreaTopDiv, "firstAreaTopDiv" + this.currentType);
htmlUtil.setClass(this.firstAreaDiv, "mumFirstAreaDiv" + this.currentType);
htmlUtil.setClass(this.secondAreaDiv, "mumSecondAreaDiv" + this.currentType);
htmlUtil.setClass(this.firstAreaBottomDiv, "mumFirstAreaBottomDiv" + this.currentType);
htmlUtil.setClass(this.secondAreaBottomDiv, "mumSecondAreaBottomDiv" + this.currentType);
this.hideElement(this.secondAreaBottomDiv);
},
/**
* This function will be invoke when user click on the left(receive) tab on wire pane title
* Switch between "Send" and "Receive" and change the pane content
*/
onClickTitlePaneLeft: function(e){
if (this.currentType == "Send") {
this.currentType = "Receive";
htmlUtil.setClass(this.wirePaneTitleDivLeft, "mumWirePaneTitleDivLeftClick");
htmlUtil.setClass(this.wirePaneTitleDivRight, "mumWirePaneTitleDivSendTab");
dijit.setWaiState(this.wirePaneTitleDivLeft, "pressed", "true");
dijit.setWaiState(this.wirePaneTitleDivLeft, "selected", "true");
dojo.removeAttr(this.wirePaneTitleDivLeft, "tabindex");
dijit.setWaiState(this.wirePaneTitleDivRight, "pressed", "false");
dijit.setWaiState(this.wirePaneTitleDivRight, "selected", "false");
dojo.attr(this.wirePaneTitleDivRight, "tabindex", "-1");
htmlUtil.setClass(this.sendIconDiv, "mumSendIconDiv");
htmlUtil.setClass(this.recIconDiv, "mumReceiveIconDivClick");
this.adjustDivsStyle();
this.createReceiveEventsDiv();
dojo.fx.wipeOut({
node: this.secondAreaDiv,
duration: 10
}).play();
this.hideElement(this.secondAreaBottomDiv);
}
this.displayPrompter("1");
dijit.focus(this.wirePaneTitleDivLeft);
},
onKeyPresTitlePane: function(e){
var key = e.keyCode;
if (key === dojo.keys.LEFT_ARROW || key === dojo.keys.UP_ARROW) {
this.onClickTitlePaneLeft(e);
} else if (key === dojo.keys.RIGHT_ARROW || key === dojo.keys.DOWN_ARROW) {
this.onClickTitlePaneRight(e);
}
},
/*onKeyPresTitlePane: function(e){
var key = e.keyCode;
if (key === dojo.keys.LEFT_ARROW || key === dojo.keys.UP_ARROW || key === dojo.keys.RIGHT_ARROW || key === dojo.keys.DOWN_ARROW) {
if(this.currentType == "Send") this.onClickTitlePaneLeft(e);
else if(this.currentType == "Receive") this.onClickTitlePaneRight(e);
}
},*/
/**
* This function will be invoke when user click on the right(send) tab on wire pane title
* Switch between "Send" and "Receive" and change the pane content
*/
onClickTitlePaneRight: function(e){
if (this.currentType == "Receive") {
this.currentType = "Send";
htmlUtil.setClass(this.wirePaneTitleDivLeft, "mumWirePaneTitleDivReceiveTab");
htmlUtil.setClass(this.wirePaneTitleDivRight, "mumWirePaneTitleDivRightClick");
dijit.setWaiState(this.wirePaneTitleDivRight, "pressed", "true");
dijit.setWaiState(this.wirePaneTitleDivRight, "selected", "true");
dojo.removeAttr(this.wirePaneTitleDivRight, "tabindex");
dijit.setWaiState(this.wirePaneTitleDivLeft, "pressed", "false");
dijit.setWaiState(this.wirePaneTitleDivLeft, "selected", "false");
dojo.attr(this.wirePaneTitleDivLeft, "tabindex", "-1");
htmlUtil.setClass(this.sendIconDiv, "mumSendIconDivClick");
htmlUtil.setClass(this.recIconDiv, "mumReceiveIconDiv");
this.adjustDivsStyle();
this.createSendEventsDiv();
//wipe out other panes, only remain the first event pane
dojo.fx.wipeOut({
node: this.secondAreaDiv,
duration: 10
}).play();
this.hideElement(this.secondAreaBottomDiv);
}
this.displayPrompter("1");
dijit.focus(this.wirePaneTitleDivRight);
},
onMouseOverCurrentWidget: function(e){
var widgetDiv = e.currentTarget;
dojo.addClass(widgetDiv, "mumMouseOverCurrentWidget" + this.currentType);
},
onMouseOutCurrentWidget: function(e){
var widgetDiv = e.currentTarget;
dojo.removeClass(widgetDiv, "mumMouseOverCurrentWidget" + this.currentType);
},
onKeyPressEvent: function(e){
switch (e.keyCode) { // JSLINT-IGNORE:
case dojo.keys.ENTER:
this.onClickEvent(e);
break;
}
},
/**
* This function will be invoke when user choose one event
* Display the second widgets pane based on the selected event
*/
onClickEvent: function(e){
var eventDiv = e.currentTarget;
//Display the return image
var returnImgs = dojo.query(".mumEventDivReturnImg" + this.currentType, eventDiv);
returnImgs[0].style.visibility = "visible";
returnImgs[0].setAttribute("role", "button");
/*
* Hide all other events
*/
if (eventDiv.getAttribute("isClicked") != "true") {
var eventName = eventDiv.getAttribute("eventName");
this.selectedEvent = eventName;
this.selectedEventTitle = eventDiv.getAttribute("eventTitle");
this.widgets = this.eventsMap[this.currentType + "-" + eventName];
//fade all other events
var otherEvents = dojo.query(".mumEventDiv", this.wirePaneEventsDiv);
if (otherEvents.length > 1) {
for (var i = 0; i < otherEvents.length; i++) {
var event = otherEvents[i];
if (event.getAttribute("eventName") != eventName) {
dojo.fx.combine([dojo.fadeOut({
node: event,
duration: 1000
}), dojo.fx.wipeOut({
node: event,
duration: 1000
})]).play();
event.setAttribute("isClicked", "false");
}
}
}
eventDiv.setAttribute("isClicked", "true");
htmlUtil.setClass(eventDiv, "mumEventDivClicked" + this.currentType);
//new event , hide the widget's event pane
var matchWidgetCount = this.createWidgetsDiv();
//show new link pane
//htmlUtil.setClass(this.firstAreaDiv, "mumFirstAreaDivClick" + this.currentType);
htmlUtil.setClass(this.firstAreaBottomDiv, "mumFirstAreaBottomDivExpand" + this.currentType);
this.showElement(this.secondAreaBottomDiv);
dojo.fx.wipeIn({
node: this.secondAreaDiv,
duration: 1000
}).play();
this.showElement(this.secondAreaBottomDiv);
this.displayPrompter("2");
}
},
onKeyPressEventReturnImg: function(e){
switch (e.keyCode) { // JSLINT-IGNORE:
case dojo.keys.ENTER:
this.onClickEventReturnImg(e);
break;
}
},
/**
* This function will be invoke when user click on the return image of one event.It will
* 1. hide the return image
* 2. display all other events
* 3. hide the second pane
* @param {event} e: the "onclick" event of the return image in selected event's div
*/
onClickEventReturnImg: function(e){
var eventDiv = e.currentTarget.parentNode;
//restore to the org status, need to judget whether this event has wired with other event or not.
htmlUtil.setClass(eventDiv, "mumEventDiv");
var countDiv = dojo.query(".mumEventDivCount" + this.currentType, eventDiv);
var count = parseInt(countDiv[0].innerHTML, 10);
if (count > 0) {
dojo.addClass(eventDiv, "mumEventDivWired");
}
if (eventDiv.getAttribute("isClicked") == "false") {
return;
}
//hide the return image and the separator bar
var returnImg = e.currentTarget;
returnImg.style.visibility = "hidden";
//fade all other events
var otherEvents = dojo.query(".mumEventDiv", this.firstAreaDiv);
if (otherEvents.length == 1) {
otherEvents[0].setAttribute("isClicked", "false");
dojo.stopEvent(e);
}
else
if (otherEvents.length > 1) {
for (var j = 0; j < otherEvents.length; j++) {
var event = otherEvents[j];
dojo.fx.combine([dojo.fadeIn({
node: event,
duration: 1000
}), this.wipeIn({
node: event,
duration: 1000
})]).play();
event.setAttribute("isClicked", "false");
}
dojo.stopEvent(e);
}
htmlUtil.setClass(this.firstAreaBottomDiv, "mumFirstAreaBottomDiv" + this.currentType);
dojo.fx.wipeOut({
node: this.secondAreaDiv,
duration: 500
}).play();
this.hideElement(this.secondAreaBottomDiv);
dojo.fx.wipeOut({
node: this.wirePaneWidgetEventsDiv,
duration: 10
}).play();
this.displayPrompter("1");
},
onKeyPressWidget: function(e){
switch (e.keyCode) { // JSLINT-IGNORE:
case dojo.keys.ENTER:
this.onClickWidget(e);
break;
}
},
/**
* This function will be invoked when user click on one widget in the second area
* @param {Event} e: the event object of the widget div's "onclick"
*/
onClickWidget: function(e){
var aWidgetDiv = e.currentTarget;
this.selectedWireWidget = aWidgetDiv.getAttribute("widgetName");
this.clickedWidgetDiv = aWidgetDiv;
// Find the return image button
var returnImgs = dojo.query(".mumWidgetDivReturnImg" + this.currentType, aWidgetDiv);
returnImgs[0].style.visibility = "visible";
//A11Y
returnImgs[0].setAttribute("role", "button");
var widgetId = e.currentTarget.getAttribute("widgetId");
htmlUtil.setClass(aWidgetDiv, "mumWidgetClicked" + this.currentType);
//dojo.addClass(aWidgetDiv, "mumWidgetClicked" + this.currentType);
if (aWidgetDiv.getAttribute("isClicked") == "true") {
return;
}
//fade out all other widgets
var widgetDivs = dojo.query(".mumWireWidget" + this.currentType, this.wirePaneWidgetsDiv);
if (widgetDivs.length > 0) {
for (var i = 0; i < widgetDivs.length; i++) {
var widgetDiv = widgetDivs[i];
if (widgetDiv.getAttribute("widgetId") != widgetId) {
dojo.fx.combine([dojo.fadeOut({
node: widgetDiv,
duration: 1000
}), dojo.fx.wipeOut({
node: widgetDiv,
duration: 1000
})]).play();
widgetDiv.setAttribute("isClicked", false);
}
}
}
//make the selected widget div
aWidgetDiv.setAttribute("isClicked", "true");
this.createWidgetEventsDiv(widgetId);
//display the event-event wire pane
dojo.fx.wipeIn({
node: this.wirePaneWidgetEventsDiv,
duration: 1000
}).play();
dojo.fadeIn({
node: this.wirePaneWidgetEventsDiv,
duration: 1000
}).play();
this.displayPrompter("3");
//Remove the widget highlight
window.clearTimeout(this.highlightTimer);
dojo.publish(com.ibm.mm.builder.eventTopics.WirePane_OutWidget, [widgetId]);
},
onKeyPressWidgetReturnImg: function(e){
switch (e.keyCode) { // JSLINT-IGNORE:
case dojo.keys.ENTER:
this.onClickWidgetReturnImg(e);
break;
}
},
/**
* This function will be invoked when user click on the return image button
* on the right side of the selected widget's div
* @param {Event} e: the "onclick" event of the widget div's return image
*/
onClickWidgetReturnImg: function(e){
//hide the return image
e.currentTarget.style.visibility = "hidden";
var aWidgetDiv = e.currentTarget.parentNode;
if (aWidgetDiv.getAttribute("isClicked") == "false") {
return;
}
htmlUtil.setClass(aWidgetDiv, "mumWireWidget" + this.currentType);
//fade in other widgets
var widgetDivs = dojo.query(".mumWireWidget" + this.currentType, this.wirePaneWidgetsDiv);
if (widgetDivs.length > 1) {
for (var i = 0; i < widgetDivs.length; i++) {
var widgetDiv = widgetDivs[i];
dojo.fadeIn({
node: widgetDiv,
duration: 1000
}).play();
this.wipeIn({
node: widgetDiv,
duration: 1000
}).play();
widgetDiv.setAttribute("isClicked", "false");
}
}
//restore the widget div status
aWidgetDiv.setAttribute("isClicked", "false");
dojo.fx.wipeOut({
node: this.wirePaneWidgetEventsDiv,
duration: 1000
}).play();
dojo.fadeOut({
node: this.wirePaneWidgetEventsDiv,
duration: 1000
}).play();
dojo.stopEvent(e);
this.displayPrompter("2");
},
onMouseOverWidget: function(e){
var widgetDiv = e.currentTarget;
if (widgetDiv.getAttribute("isClicked") == "true") {
return;
}
var widgetId = widgetDiv.getAttribute("widgetId");
var _this = this;
this.highlightTimer = window.setTimeout(function(){
com.ibm.mm.builder.utils.wireUtil.highlightWidget(widgetId);
//com.ibm.mashups.services.ServiceManager.getService("eventService").broadcastEvent("com.ibm.mashups.builder.highlightWidget", widgetId);
// _this.iContext.iEvents.publishEvent("widgetHighlighted", widgetId);
}, 300);
},
onMouseOutWidget: function(e){
var widgetDiv = e.currentTarget;
if (widgetDiv.getAttribute("isClicked") == "true") {
return;
}
var widgetId = widgetDiv.getAttribute("widgetId");
var widget = this.getWidgetFromMap(widgetId);
if (widget.totalWiredEvents > 0) {
dojo.addClass(widgetDiv, "mumHasWiredEvent");
}
window.clearTimeout(this.highlightTimer);
com.ibm.mm.builder.utils.wireUtil.removeHighlight();
//com.ibm.mashups.services.ServiceManager.getService("eventService").broadcastEvent("com.ibm.mashups.builder.removeWidgetHighlight", widgetId);
// this.iContext.iEvents.publishEvent("widgetHighlightRemoved",widgetId);
},
/**
* Invoke when user click on one widget's event div in the second pane
* which has been click before(already display the wire div)
* It will remove the wire div and restore the event back to normal status
* @param {Object} aEventDiv: the clicked div
*/
restoreEventDiv: function(aEventDiv){
if (aEventDiv.getAttribute("isClicked")) { // Click before, now in expand status
aEventDiv.setAttribute("isClicked", "false");
htmlUtil.setClass(aEventDiv, "mumWidgetPaneEventDiv");
var actionDivs = dojo.query(".mumWidgetPaneEventActionDiv", aEventDiv);
if (actionDivs && actionDivs.length > 0) {
for (var i = 0; i < actionDivs.length; i++) {
var actionDiv = actionDivs[i];
aEventDiv.removeChild(actionDiv);
}
}
}
},
/**
* Invoke when user click on a matched event and want to connect
* 1. restore all other event back to normal status
* 2. generate a connection div and append to this event's div
* @param {Event} e The "onclick" event of the selected event div
*/
onClickConEventDiv: function(e){
var aEventDiv = e.currentTarget;
// Fetch all needed info and fill them into the new generated event connection div
var id = aEventDiv.getAttribute("belongId");
var eventName = aEventDiv.getAttribute("eventName");
//here
var aEvent = this.getEventFromWidget(id, eventName);
var aEventInfoDiv = document.createElement("div");
htmlUtil.setClass(aEventInfoDiv, "mumWidgetPaneEventInfoDiv" + this.currentType);
// the text and checkbox
var checkMarkDiv = dojo.query(".checkMarkDiv", aEventDiv)[0];
if (aEvent.isWired) {
htmlUtil.setClass(aEventDiv, "mumWidgetPaneEventDiv");
this.disconnectEvent(id, eventName);
checkMarkDiv.innerHTML = "";
aEventDiv.setAttribute("isChecked", "");
}
else {
this.connectEvent(id, eventName);
checkMarkDiv.innerHTML = "";
htmlUtil.setClass(aEventDiv, "mumWidgetPaneEventDivCheck" + this.currentType);
aEventDiv.setAttribute("isChecked", "checked");
}
// still focus to the check box
checkMarkDiv.childNodes[0].focus();
},
onMouseOverConEventDiv: function(e){
var aEventDiv = e.currentTarget;
var checked = aEventDiv.getAttribute("isChecked");
if (checked == "checked") {
htmlUtil.setClass(aEventDiv, "mumWidgetPaneEventDivCheckMouseOver" + this.currentType);
}
else {
htmlUtil.setClass(aEventDiv, "mumWidgetPaneEventDivMouseOver");
}
},
onMouseOutConEventDiv: function(e){
var aEventDiv = e.currentTarget;
var checked = aEventDiv.getAttribute("isChecked");
if (checked == "checked") {
htmlUtil.setClass(aEventDiv, "mumWidgetPaneEventDivCheck" + this.currentType);
}
else {
htmlUtil.setClass(aEventDiv, "mumWidgetPaneEventDiv");
}
},
onClickWidgetPaneEventReturnImg: function(e){
var aEventDiv = e.currentTarget.parentNode;
var infoDiv = dojo.query(".mumWidgetPaneEventInfoDiv" + this.currentType, aEventDiv);
var returnImg = dojo.query(".mumWidgetPaneEventReturnImg", aEventDiv);
aEventDiv.removeChild(returnImg[0]);
dojo.removeClass(infoDiv[0], "mumFloatLeft");
var allEventsDiv = dojo.query(".mumWidgetPaneEventDiv", this.mumWidgetEventsDiv);
var anotherEvent = null;
for (var m = 0; m < allEventsDiv.length; m++) {
anotherEvent = allEventsDiv[m];
dojo.fadeIn({
node: anotherEvent,
duration: 1000
}).play();
dojo.fx.wipeIn({
node: anotherEvent,
duration: 1000
}).play();
}
var allGrayEventsDiv = dojo.query(".mumWidgetPaneEventDivGray", this.mumWidgetEventsDiv);
for (var n = 0; n < allGrayEventsDiv.length; n++) {
anotherEvent = allGrayEventsDiv[n];
dojo.fadeIn({
node: anotherEvent,
duration: 1000
}).play();
dojo.fx.wipeIn({
node: anotherEvent,
duration: 1000
}).play();
}
dojo.stopEvent(e);
},
/**
* Fetch the widget object from the cache
* @param {Object} id: the widget id
*/
getWidgetFromMap: function(id){
var widget;
for (var i = 0; i < this.widgets.length; i++) {
widget = this.widgets[i];
if (id == widget.id) {
return widget;
}
}
return null;
},
/**
* Get the event object from cache based on the widget id and event name
* @param {Object} id : the id of the widget
* @param {Object} eventName : the name of the event
*/
getEventFromWidget: function(id, eventName){
var event;
for (var i = 0; i < this.widgets.length; i++) {
var widget = this.widgets[i];
if (id == widget.id) {
var events = widget.events;
for (var j = 0; j < events.length; j++) {
event = events[j];
if (event.name == eventName) {
break;
}
}
break;
}
}
return event;
},
/**
* Update the cache after add/remove wire on the interaction interface
* @param {string} sourceId
* @param {string} sourceEvent
* @param {string} targetId
* @param {string} targetEvent
*/
updateEventsMap: function(sourceId, sourceEvent, targetId, targetEvent, isAddWire){
//var widgetsArray = com.ibm.mm.builder.utils.wireUtil.getAllMatchHandleEvents(sourceId, sourceEvent,this.iContext.scope.layouts);
//this.eventsMap["Send-" + sourceEvent] = widgetsArray;
//this.widgets = widgetsArray;
var eventName = targetEvent;
var widgetId = targetId;
if (this.currentType == "Receive") {
eventName = sourceEvent;
widgetId = sourceId;
}
var wireVar = -1;
if (isAddWire) {
wireVar = 1;
}
for (var i = 0; i < this.widgets.length; i++) {
var widget = this.widgets[i];
if (widgetId == widget.id) {
//Find the widget
widget.totalWiredEvents += wireVar;
var events = widget.events;
for (var j = 0; j < events.length; j++) {
var event = events[j];
if (event.name == eventName) {
//Find the event
event.isWired = isAddWire;
}
}
break;
}
}
},
getWireModel: function(){
// get current page
var navModel = com.ibm.mashups.enabler.navigation.Factory.getNavigationModel();
var currentPage = navModel.find(this.currentPageId).start();
var lm = navModel.getLayoutModel(currentPage);
var wiringModel = lm.getWireModel();
return wiringModel;
},
getLayoutModel: function(){
// get current page
var navModel = com.ibm.mashups.enabler.navigation.Factory.getNavigationModel();
var currentPage = navModel.find(this.currentPageId).start();
var lm = navModel.getLayoutModel(currentPage);
return lm;
},
getLayoutControl: function(lcId){
var lc = this.getLayoutModel().find(lcId).start();
return lc;
},
addWire: function(sourceId, sourceEvent, targetId, targetEvent, needUpdate){
// Update WireModel
// Create the JSON object
// Get WidgetWindow for layout control
var currentPageId = com.ibm.mashups.builder.model.Factory.getRuntimeModel().getCurrentPage().getID();
var navModel = com.ibm.mashups.enabler.navigation.Factory.getNavigationModel();
var currentPage = navModel.find(this.currentPageId).start();
var widgetModel = com.ibm.mashups.enabler.widget.Factory.getWidgetModel();
var sourcelc = this.getLayoutControl(sourceId);
var sourceWidgetWindow = widgetModel.getWidgetWindow(sourcelc).start();
var sourceEventProvider = widgetModel.getHierarchicalEventProvider(sourceWidgetWindow).start();
//var sourceEventObject = sourceEventProvider.getEvent(sourceEvent);
var sourceEventObject = com.ibm.mm.builder.utils.wireUtil.getEventByNameAndType(
sourceEventProvider, sourceEvent, com.ibm.mashups.enabler.widget.Constants.FILTER_PUBLISHED_EVENTS);
var targetlc = this.getLayoutControl(targetId);
var targetWidgetWindow = widgetModel.getWidgetWindow(targetlc).start();
var targetEventProvider = widgetModel.getHierarchicalEventProvider(targetWidgetWindow).start();
//var targetEventObject = targetEventProvider.getEvent(targetEvent);
var targetEventObject = com.ibm.mm.builder.utils.wireUtil.getEventByNameAndType(
targetEventProvider, targetEvent, com.ibm.mashups.enabler.widget.Constants.FILTER_HANDLED_EVENTS);
var ctx = {};
ctx.sourceWidgetId = sourceWidgetWindow;
ctx.sourcePageId = currentPage;
ctx.sourceEventId = sourceEventObject;
ctx.targetWidgetId = targetWidgetWindow;
ctx.targetPageId = currentPage;
ctx.targetEventId = targetEventObject;
// create the wire
var wireModel = this.getWireModel();
var wire = wireModel.create(ctx);
// insert the wire
if (wire) {
wireModel.insert(wire, null);
}
if (needUpdate) {
this.updateEventsMap(sourceId, sourceEvent, targetId, targetEvent, true);
}
com.ibm.mashups.builder.model.Factory.getRuntimeModel().getCurrentPage().setDirty(true);
},
removeWire: function(sourceId, sourceEvent, targetId, targetEvent, needUpdate){
// Remove Wire from WireModel
var wireModel = this.getWireModel();
var widgetModel = com.ibm.mashups.enabler.widget.Factory.getWidgetModel();
var sourcelc = this.getLayoutControl(sourceId);
var sourceWidgetWindow = widgetModel.getWidgetWindow(sourcelc).start();
var targetlc = this.getLayoutControl(targetId);
var targetWidgetWindow = widgetModel.getWidgetWindow(targetlc).start();
var targetEventProvider = widgetModel.getHierarchicalEventProvider(targetWidgetWindow).start();
var sourceEventProvider = widgetModel.getHierarchicalEventProvider(sourceWidgetWindow).start();
//var targetEventObj = targetEventProvider.getEvent(targetEvent);
//var sourceEventObj = sourceEventProvider.getEvent(sourceEvent);
var targetEventObj = com.ibm.mm.builder.utils.wireUtil.getEventByNameAndType(
targetEventProvider, targetEvent, com.ibm.mashups.enabler.widget.Constants.FILTER_HANDLED_EVENTS);
var sourceEventObj = com.ibm.mm.builder.utils.wireUtil.getEventByNameAndType(
sourceEventProvider, sourceEvent, com.ibm.mashups.enabler.widget.Constants.FILTER_PUBLISHED_EVENTS);
// Find the wire
var aWire = null;
var wireIter = wireModel.iterator();
if (wireIter !== null) {
wireIter.setCursorPosition(0);
while (wireIter.hasNext()) {
var wireNode = wireIter.next();
// Need to see if this wire has the current layoutControl as target
if (wireNode.getTargetWidget().getID() == targetWidgetWindow.getID() &&
wireNode.getSourceWidget().getID() == sourceWidgetWindow.getID()) {
if (wireNode.getTargetEvent().getID() == targetEventObj.getID() &&
wireNode.getSourceEvent().getID() == sourceEventObj.getID()) {
aWire = wireNode;
}
}
}
}
if (aWire !== null) {
// Remove the wire
wireModel.remove(aWire);
}
if (needUpdate) {
this.updateEventsMap(sourceId, sourceEvent, targetId, targetEvent, false);
}
},
disconnectEvent: function(id, eventName){
if (this.currentType == "Send") {
this.removeWire(this.iwidgetId, this.selectedEvent, id, eventName, true);
}
else {
this.removeWire(id, eventName, this.iwidgetId, this.selectedEvent, true);
}
this.updateEventWireCount(id, -1);
},
connectEvent: function(id, eventName){
if (this.currentType == "Send") {
this.addWire(this.iwidgetId, this.selectedEvent, id, eventName, true);
}
else {
this.addWire(id, eventName, this.iwidgetId, this.selectedEvent, true);
}
this.updateEventWireCount(id, 1);
},
/**
* Update the wire count on the UI
* @param {string} id: target widget id
* @param {number} num: wire added(1)/ wire removed (-1)
*/
updateEventWireCount: function(id, num){
var eventDivs = dojo.query(".mumEventDivClicked" + this.currentType, this.wirePaneEventsDiv);
for (var i = 0; i < eventDivs.length; i++) {
var eventDiv = eventDivs[i];
if (eventDiv.getAttribute("eventName") == this.selectedEvent) {
var countDiv = dojo.query(".mumEventDivCount" + this.currentType, eventDiv)[0];
var count;
if (countDiv.innerHTML == "" || countDiv.innerHTML === null) {
count = 0;
}
else {
count = parseInt(countDiv.innerHTML, 10);
}
count = count + num;
htmlUtil.setClass(countDiv, "mumEventDivCount" + this.currentType);
if (count > 0) {
countDiv.innerHTML = count;
if (count == 1) {
dojo.addClass(countDiv, "mumEventDivCountSingleWire" + this.currentType);
}
else {
dojo.addClass(countDiv, "mumEventDivCountMultiWire" + this.currentType);
}
}
else {
countDiv.innerHTML = "";
}
//for a11y
this._insertEventA11yHint(this.currentType, eventDiv, count);
}
}
var curWireIcon = dojo.query(".mumCurrentWidgetArrow" + this.currentType, this.wirePaneCurrentWidgetDiv)[0];
var currentWidgetName = dojo.query(".mumCurrentWidgetName" + this.currentType, this.wirePaneCurrentWidgetDiv)[0];
if (this.currentType == "Send") {
this.allPubWires += num;
if (builderConfig.isBidi) {
this.sendIconDiv.innerHTML = "(" + this.allPubWires + ")";
}
else {
this.sendWireCountDiv.innerHTML = "(" + this.allPubWires + ")";
}
//update the UI of the current widget
if (this.allPubWires === 0) {
dojo.addClass(curWireIcon, "mumHiddenElement");
htmlUtil.setNodeTitleWithStyle(currentWidgetName.title, currentWidgetName, 375, this.titleFontStyle);
}
else
if (this.allPubWires == 1 && num == 1) {
dojo.removeClass(curWireIcon, "mumHiddenElement");
htmlUtil.setNodeTitleWithStyle(currentWidgetName.title, currentWidgetName, 345, this.titleFontStyle);
}
dojo.attr(this.wirePaneTitleDivRight, "title", cws.I_WIRING_TITLE_SEND + " " + this.allPubWires);
}
else {
this.allHanWires += num;
if (builderConfig.isBidi) {
this.recIconDiv.innerHTML = "(" + this.allHanWires + ")";
}
else {
this.receiveWireCountDiv.innerHTML = "(" + this.allHanWires + ")";
}
//update the UI of the current widget
if (this.allHanWires === 0) {
dojo.addClass(curWireIcon, "mumHiddenElement");
htmlUtil.setNodeTitleWithStyle(currentWidgetName.title, currentWidgetName, 375, this.titleFontStyle);
}
else
if (this.allHanWires == 1 && num == 1) {
dojo.removeClass(curWireIcon, "mumHiddenElement");
htmlUtil.setNodeTitleWithStyle(currentWidgetName.title, currentWidgetName, 345, this.titleFontStyle);
}
dojo.attr(this.wirePaneTitleDivLeft, "title", cws.I_WIRING_TITLE_RECEIVE + " " + this.allHanWires);
}
//update the UI of the selected widget
var widget = this.getWidgetFromMap(id);
var arrow = dojo.query(".mumWireIndicator" + this.currentType, this.clickedWidgetDiv)[0];
var widgetname = dojo.query(".mumWireWidgetTitle", this.clickedWidgetDiv)[0];
if (widget.totalWiredEvents > 0) {
arrow.style.display = "";
htmlUtil.setNodeTitleWithStyle(widgetname.title, widgetname, 345, this.titleFontStyle);
}
else {
htmlUtil.setNodeTitleWithStyle(widgetname.title, widgetname, 375, this.titleFontStyle);
arrow.style.display = "none";
}
},
/**
* Update the wire count on the UI
* @param {string} id: target widget id
* @param {number} num: wire added(1)/ wire removed (-1)
*/
resetEventWireCount: function(){
if (builderConfig.isBidi) {
this.sendIconDiv.innerHTML = "(" + this.allPubWires + ")";
}
else {
this.sendWireCountDiv.innerHTML = "(" + this.allPubWires + ")";
}
if (builderConfig.isBidi) {
this.recIconDiv.innerHTML = "(" + this.allHanWires + ")";
}
else {
this.receiveWireCountDiv.innerHTML = "(" + this.allHanWires + ")";
}
},
createWidgetEventsDiv: function(id){
this.wirePaneWidgetEventsDiv.innerHTML = "";
var widgetsTitleDiv = document.createElement("div");
if (this.currentType == "Send") {
htmlUtil.setClass(widgetsTitleDiv, "mumWireWidgetsTitleDivSend");
htmlUtil.setNodeTitleWithStyle(cws.I_WIRING_WIDGETEVENTS_SEND, widgetsTitleDiv, 425, this.titleFontStyle);
}
else if (this.currentType == "Receive") {
htmlUtil.setClass(widgetsTitleDiv, "mumWireWidgetsTitleDivReceive");
htmlUtil.setNodeTitleWithStyle(cws.I_WIRING_WIDGETEVENTS_RECEIVE, widgetsTitleDiv, 425, this.titleFontStyle);
}
htmlUtil.setClass(this.wirePaneWidgetEventsDiv, "mumWidgetEventsDiv" + this.currentType);
var mumWidgetEventsContentDiv = this.createDivWithClass("mumWidgetEventsContentDiv" + this.currentType);
mumWidgetEventsContentDiv.setAttribute("role", "menu");
// #17333 add hover class
dojo.disconnect(this.eventsDivOverHandler);
dojo.disconnect(this.eventsDivOutHandler);
this.eventsDivOverHandler = dojo.connect(mumWidgetEventsContentDiv,'onmouseover',mumWidgetEventsContentDiv,function() {
dojo.addClass(this, 'hover');
},true);
this.eventsDivOutHandler = dojo.connect(mumWidgetEventsContentDiv,'onmouseout',mumWidgetEventsContentDiv,function() {
dojo.removeClass(this,'hover');
},true);
for (var i = 0; i < this.widgets.length; i++) {
var aWidget = this.widgets[i];
if (aWidget.id == id) {
var events = aWidget.events;
for (var j = 0; j < events.length; j++) {
var aEvent = events[j];
var eventName = aEvent.name;
var aEventDiv = document.createElement("div");
aEventDiv.setAttribute("belongId", id);
aEventDiv.setAttribute("eventName", eventName);
if (aEvent.isMatch) {
this.connect(aEventDiv, "onclick", this.onClickConEventDiv);
this.connect(aEventDiv, "onmouseover", this.onMouseOverConEventDiv);
this.connect(aEventDiv, "onmouseout", this.onMouseOutConEventDiv);
var checkMarkDiv = document.createElement("div");
dojo.addClass(checkMarkDiv, "checkMarkDiv");
dojo.addClass(checkMarkDiv, "mumFloatLeft");
if (aEvent.isWired) {
checkMarkDiv.innerHTML = "";
aEventDiv.setAttribute("isChecked", "checked");
htmlUtil.setClass(aEventDiv, "mumWidgetPaneEventDivCheck" + this.currentType);
}
else {
htmlUtil.setClass(aEventDiv, "mumWidgetPaneEventDiv");
checkMarkDiv.innerHTML = "";
aEventDiv.setAttribute("isChecked", "");
}
var aEventInfoDiv = this.createDivWithClass("mumWidgetPaneEventInfoDiv" + this.currentType);
aEventInfoDiv.setAttribute("role", "menuitem");
var title = "";
var description = "";
var oneEvent = null;
var layoutControl = this.getLayoutControl(id);
oneEvent = null;
if (layoutControl) {
// get widgetmodel
var widgetModel = com.ibm.mashups.enabler.widget.Factory.getWidgetModel();
// get widgetWindow
var widgetWindow = widgetModel.getWidgetWindow(layoutControl).start();
var eventProvider = widgetModel.getHierarchicalEventProvider(widgetWindow).start();
// Find target event
oneEvent = eventProvider.getEvent(eventName);
}
title = oneEvent.getTitle(dojo.locale) || oneEvent.getTitle(ibmConfig["default.locale"]) || oneEvent.getName();
description = oneEvent.getDescription(dojo.locale) || oneEvent.getName();
var eventDivText1 = this.createDivWithClass("mumWidgetPaneEventInfoText" + this.currentType);
dojo.addClass(eventDivText1, "mumEventDivText1");
var eventDivText3 = this.createDivWithClass("mumWidgetPaneEventInfoText" + this.currentType);
dojo.addClass(eventDivText3, "mumEventDivText3");
eventDivText1.title = title;
eventDivText1.innerHTML = htmlUtil.escapeString(title);
this._setupEventTypeDiv(eventDivText3, aEvent.payloadType);
var wrapperDiv1 = document.createElement("div");
wrapperDiv1.appendChild(eventDivText1);
var wrapperDiv3 = document.createElement("div");
wrapperDiv3.appendChild(eventDivText3);
//A11Y
if (aEvent.isWired) {
checkMarkDiv.innerHTML = "";
aEventDiv.setAttribute("isChecked", "checked");
htmlUtil.setClass(aEventDiv, "mumWidgetPaneEventDivCheck" + this.currentType);
}
else {
htmlUtil.setClass(aEventDiv, "mumWidgetPaneEventDiv");
checkMarkDiv.innerHTML = "";
aEventDiv.setAttribute("isChecked", "");
}
aEventInfoDiv.appendChild(checkMarkDiv);
var storeEventDivInnerHTML = aEventInfoDiv.innerHTML;
//construct the event content
var eventContent;
var eventTitle = null;
if (this.currentType == "Send") {
// To fix bug 3218 3228
eventTitle = dojo.string.substitute(cws.I_WIRING_EVENT_TITLE_RECEIVE, [title, this.getShownType(aEvent.payloadType), description]);
aEventInfoDiv.title = eventTitle;
//construct the event content
eventContent = dojo.string.substitute(cws.I_WIRING_EVENT_CONTENT_RECEIVE, [wrapperDiv1.innerHTML, '', '', wrapperDiv3.innerHTML]);
}
else {
// To fix bug 3218 3228
eventTitle = dojo.string.substitute(cws.I_WIRING_EVENT_TITLE_SEND, [eventName, this.getShownType(aEvent.payloadType), description]);
aEventInfoDiv.title = eventTitle;
eventContent = dojo.string.substitute(cws.I_WIRING_EVENT_CONTENT_SEND, [wrapperDiv1.innerHTML, '', '', wrapperDiv3.innerHTML]);
}
aEventInfoDiv.innerHTML = aEventInfoDiv.innerHTML + eventContent;
eventDivText1 = dojo.query(".mumEventDivText1", aEventInfoDiv)[0];
var div1Width = htmlUtil.getStrWidth(eventDivText1.innerHTML, eventDivText1, this.defaultFontStyle);
eventDivText3 = dojo.query(".mumEventDivText3", aEventInfoDiv)[0];
var div3Width = htmlUtil.getStrWidth(eventDivText3.innerHTML, eventDivText3, this.defaultFontStyle);
var eventDivText2 = dojo.query(".mumWidgetPaneEventInfoTextMid", aEventInfoDiv)[0];
var div2Width = htmlUtil.getStrWidth(eventDivText2.innerHTML, eventDivText2, this.italicStyle);
eventDivText2.title = eventDivText2.innerHTML;
var totalWidth = dojo.isIE || window.ActiveXObject !== undefined ? 380 : 395;
if (div1Width + div2Width + div3Width > totalWidth) {
var widthLeft = totalWidth - div2Width; //the center text will never be truncated.
var widthLeftFor3 = widthLeft - div1Width;
var widthLeftFor1 = widthLeft - div3Width;
if (widthLeftFor3 > 60) { //try to only truncate one only
div3Width = widthLeftFor3;
htmlUtil.setNodeTitleWithStyle(eventDivText3.innerHTML, eventDivText3, div3Width, this.defaultFontStyle);
}
else
if (widthLeftFor1 > 60) {
div1Width = widthLeftFor1;
htmlUtil.setNodeTitleWithStyle(eventDivText1.innerHTML, eventDivText1, div1Width, this.defaultFontStyle);
}
else {
div1Width = widthLeft * 0.6;
div3Width = widthLeft * 0.4;
htmlUtil.setNodeTitleWithStyle(eventDivText1.innerHTML, eventDivText1, div1Width, this.defaultFontStyle);
htmlUtil.setNodeTitleWithStyle(eventDivText3.innerHTML, eventDivText3, div3Width, this.defaultFontStyle);
}
}
aEventDiv.appendChild(aEventInfoDiv);
}
mumWidgetEventsContentDiv.appendChild(aEventDiv);
}
break;
}
}
var mumWidgetEventsBottomDiv = this.createDivWithClass("mumWidgetEventsBottomDiv" + this.currentType);
this.wirePaneWidgetEventsDiv.appendChild(widgetsTitleDiv);
this.wirePaneWidgetEventsDiv.appendChild(mumWidgetEventsContentDiv);
this.wirePaneWidgetEventsDiv.appendChild(mumWidgetEventsBottomDiv);
},
/**
* This function will be invoked when user click on one event in first area.
* 1. Init and display the second area
* 2. Render every other widget based on the info fetched by wireUtil
* 3. Place the return image button and the tip
*/
createWidgetsDiv: function(){
//reset the whole widgets pane
this.wirePaneWidgetsDiv.innerHTML = "";
this.wirePaneWidgetEventsDiv.innerHTML = "";
this.hideElement(this.wirePaneWidgetEventsDiv);
htmlUtil.setClass(this.wirePaneWidgetsDiv, "mumPaneDiv");
//Init the tip div
htmlUtil.setClass(this.grayTip, "mumWireWidgetTip" + this.currentType);
this.grayTip.innerHTML = cws.I_WIRING_NO_MATCH_WIDGET;
//Init the title
var widgetsTitleDiv = document.createElement("div");
if (this.currentType == "Send") {
htmlUtil.setClass(widgetsTitleDiv, "mumWireWidgetsTitleDivSend");
htmlUtil.setNodeTitleWithStyle(cws.I_WIRING_WIDGETS_SEND, widgetsTitleDiv, 425, this.titleFontStyle);
// widgetsTitleDiv.innerHTML = this.getProperTitle(cws.I_WIRING_WIDGETS_SEND,40);
}
else
if (this.currentType == "Receive") {
htmlUtil.setClass(widgetsTitleDiv, "mumWireWidgetsTitleDivReceive");
htmlUtil.setNodeTitleWithStyle(cws.I_WIRING_WIDGETS_RECEIVE, widgetsTitleDiv, 425, this.titleFontStyle);
// widgetsTitleDiv.innerHTML = this.getProperTitle(cws.I_WIRING_WIDGETS_RECEIVE,40);
}
// The content pane in the middle
var wirePaneWidgetsContentDiv = this.createDivWithClass("mumWidgetsContentDiv" + this.currentType);
wirePaneWidgetsContentDiv.setAttribute("role", "menu");
this.wirePaneEventsDiv.appendChild(wirePaneWidgetsContentDiv);
var matchWidgetCount = 0;
var preFetchId;
//Render every other widgets in the widgets pane if they have at least one event can be wired with current widget's event
for (var i = 0; i < this.widgets.length; i++) {
var aWidget = this.widgets[i];
if (aWidget.hasMatchEvent) { // has event can be wired to this widgets, create div
matchWidgetCount++;
preFetchId = aWidget.id;
var aWidgetDiv = document.createElement("div");
aWidgetDiv.setAttribute("tabindex", "0");
aWidgetDiv.setAttribute("widgetId", aWidget.id);
aWidgetDiv.setAttribute("isClicked", "false");
aWidgetDiv.setAttribute("widgetName", aWidget.type);
//A11Y
aWidgetDiv.setAttribute("title", aWidget.type);
aWidgetDiv.setAttribute("role", "menuitem");
dojo.addClass(aWidgetDiv, "mumWireWidget" + this.currentType);
//arrow to indicate is currently wired with the widget
var wireIndicator = document.createElement("div");
this.connect(aWidgetDiv, "onmouseover", this.onMouseOverWidget);
this.connect(aWidgetDiv, "onmouseout", this.onMouseOutWidget);
this.connect(aWidgetDiv, "onclick", this.onClickWidget);
//A11Y
//dojo.connect(aWidgetDiv, "onfocus", this, "onMouseOverWidget");
//dojo.connect(aWidgetDiv, "onblur", this, "onMouseOutWidget");
this.connect(aWidgetDiv, "onkeypress", this.onKeyPressWidget);
var widgetUtil = com.ibm.mm.builder.utils.iwidgetUtil;
var titleIcon = widgetUtil.getWidgetIconCSA2(aWidget.id);
var aWidgetImg = document.createElement("div");
aWidgetImg.innerHTML = "";
htmlUtil.setClass(aWidgetImg, "mumWireWidgetImg");
aWidgetDiv.appendChild(aWidgetImg);
var aWidgetTitle = document.createElement("div");
htmlUtil.setClass(aWidgetTitle, "mumWireWidgetTitle");
aWidgetDiv.appendChild(aWidgetTitle);
wireIndicator.innerHTML = "" : "_arrow.png' alt=''>");
htmlUtil.setClass(wireIndicator, "mumWireIndicator" + this.currentType);
//deal with the inidcator
wireIndicator.style.display = "none";
// wireIndicator.style.visibility = "hidden";
if (aWidget.totalWiredEvents > 0) {
dojo.addClass(aWidgetDiv, "mumHasWiredEvent");
wireIndicator.style.display = "";
htmlUtil.setNodeTitleWithStyle(aWidget.type, aWidgetTitle, 345, this.titleFontStyle);
// wireIndicator.style.visibility = "visible";
}
else {
htmlUtil.setNodeTitleWithStyle(aWidget.type, aWidgetTitle, 375, this.titleFontStyle);
}
var widgetDivReturnImg = document.createElement("a");
widgetDivReturnImg.setAttribute("href", "javascript:;");
widgetDivReturnImg.setAttribute("role", "button");
htmlUtil.setClass(widgetDivReturnImg, "mumWidgetDivReturnImg" + this.currentType);
this.connect(widgetDivReturnImg, "onclick", this.onClickWidgetReturnImg);
//A11Y-todo
this.connect(widgetDivReturnImg, "onkeypress", this.onKeyPressWidgetReturnImg);
dojo.attr(widgetDivReturnImg, "title", cws["I_WIRING_OTHER_WIDGETS_" + this.currentType.toUpperCase()]);
widgetDivReturnImg.innerHTML = "";
widgetDivReturnImg.style.visibility = "hidden";
aWidgetDiv.appendChild(widgetDivReturnImg);
aWidgetDiv.appendChild(wireIndicator);
wirePaneWidgetsContentDiv.appendChild(aWidgetDiv);
}
}
this.wirePaneWidgetEventsDiv.innerHTML = "";
//this.wirePaneWidgetsDiv.appendChild(this.wirePaneWidgetEventsDiv);
//The bottom pane, only contains one round corner image
var wirePaneWidgetsBottomDiv = this.createDivWithClass("mumWidgetsBottomDiv" + this.currentType);
this.wirePaneWidgetsDiv.appendChild(widgetsTitleDiv);
//If there is no widget which contains event can be wired with this widget's event, show the tip
if (matchWidgetCount === 0) {
wirePaneWidgetsContentDiv.appendChild(this.grayTip);
}
this.wirePaneWidgetsDiv.appendChild(wirePaneWidgetsContentDiv);
this.wirePaneWidgetsDiv.appendChild(wirePaneWidgetsBottomDiv);
this.wirePaneWidgetsDiv.style.display = "";
this.LOGGER.exiting("WirePane_createWidgetsDiv");
return matchWidgetCount;
},
/**
* This function will be invoked every time a new wire pane is poped up.
* Fetch all related events' and wire data for current widget. Wrap them into Object "eventsMap".
*/
initAllData: function(){
if ( typeof this.matchingType === "undefined" ) {
var config = this.iContext.getiWidgetAttributes();
var mType = config.getItemValue( "matchingType" );
if ( !mType ) {
mType = config.getItemValue("defaultMatchingType");
}
this.matchingType = parseInt( mType );
}
this.eventsMap = {};
var hEvents = null;
var pEvents = null;
var hanEvent = null;
var pubEvent = null;
var currentPID = com.ibm.mashups.builder.model.Factory.getRuntimeModel().getCurrentPage().getID();
this.currentPageId = currentPID;
var layoutControl = this.getLayoutControl(this.iwidgetId);
// var hEvents = widgetWrapper.getWidgetHandledEvents();
hEvents = com.ibm.mm.builder.utils.wireUtil.getWidgetHandledEventsCSA2(layoutControl);
// var pEvents = widgetWrapper.getWidgetPublishedEvents();
pEvents = com.ibm.mm.builder.utils.wireUtil.getWidgetPublishedEventsCSA2(layoutControl);
/* *** */
this.allHanWires = 0;
this.allPubWires = 0;
var lcArray = null;
// LayoutModel has the controls
if (hEvents) {
for (var n = 0; n < hEvents.length; n++) {
hanEvent = hEvents[n];
lcArray = com.ibm.mm.builder.utils.wireUtil.getAllMatchPubEventsCSA2(layoutControl, hanEvent.getName(), currentPID, this.matchingType);
for (var i = 0; i < lcArray.length; i++) {
this.allHanWires = this.allHanWires + lcArray[i].wiredEvents.length;
}
this.eventsMap["Receive-" + hanEvent.getName()] = lcArray;
}
}
if (pEvents) {
for (var m = 0; m < pEvents.length; m++) {
pubEvent = pEvents[m];
lcArray = com.ibm.mm.builder.utils.wireUtil.getAllMatchHandleEventsCSA2(layoutControl, pubEvent.getName(), currentPID, this.matchingType);
for (var j = 0; j < lcArray.length; j++) {
this.allPubWires = this.allPubWires + lcArray[j].wiredEvents.length;
}
this.eventsMap["Send-" + pubEvent.getName()] = lcArray;
}
}
},
/**
* Generate the receive Events pane of current widget
*/
createReceiveEventsDiv: function(){
this.createCurrentWidgetDiv();
this.wirePaneEventsDiv.innerHTML = "";
htmlUtil.setClass(this.wirePaneEventsDiv, "mumEventsDiv");
htmlUtil.setClass(this.grayTip, "mumWireWidgetTipSend");
this.grayTip.innerHTML = cws.I_WIRING_NO_RECEIVE_EVENTS;
dojo.attr(this.grayTip, "title", cws.I_WIRING_NO_RECEIVE_EVENTS);
var eventsTitleDiv = document.createElement("div");
htmlUtil.setClass(eventsTitleDiv, "mumEventsTitleDivReceive");
htmlUtil.setNodeTitleWithStyle(cws.I_WIRING_EVENTS_RECEIVE, eventsTitleDiv, 425, this.titleFontStyle);
this.wirePaneEventsDiv.appendChild(eventsTitleDiv);
var hEvents = [];
var layoutControl = this.getLayoutControl(this.iwidgetId);
hEvents = com.ibm.mm.builder.utils.wireUtil.getWidgetHandledEventsCSA2(layoutControl);
var wirePaneEventsContentDiv = this.createDivWithClass("mumEventsContentDiv" + this.currentType);
wirePaneEventsContentDiv.setAttribute("role", "menu");
this.wirePaneEventsDiv.appendChild(wirePaneEventsContentDiv);
var hasEventToShow = false;
for (var n = 0; n < hEvents.length; n++) {
var hanEvent = hEvents[n];
var eventDiv = document.createElement("div");
eventDiv.setAttribute("tabindex", "0");
htmlUtil.setClass(eventDiv, "mumEventDiv");
wirePaneEventsContentDiv.appendChild(eventDiv);
hasEventToShow = true;
var title = "";
var description = "";
var shownType = "";
var shownEventName = "";
title = hanEvent.getTitle(dojo.locale) || hanEvent.getTitle(ibmConfig["default.locale"]) || hanEvent.getName();
description = hanEvent.getDescription(dojo.locale) || hanEvent.getName();
shownType = hanEvent.getPayloadType();
shownEventName = hanEvent.getName();
// To fix bug 3218 3228
var eventTitle = dojo.string.substitute(cws.I_WIRING_EVENT_TITLE_RECEIVE, [title, this.getShownType(shownType), description]);
eventDiv.title = eventTitle;
var widgetsArray = this.eventsMap["Receive-" + shownEventName];
var wiredEventCount = 0;
for (var i = 0; i < widgetsArray.length; i++) {
wiredEventCount = wiredEventCount + widgetsArray[i].totalWiredEvents;
}
var eventDivCount = document.createElement("div");
htmlUtil.setClass(eventDivCount, "mumEventDivCount" + this.currentType);
//if this event already has wired with other events
if (wiredEventCount > 0) {
eventDivCount.innerHTML = wiredEventCount;
dojo.addClass(eventDiv, "mumEventDivWired");
if (wiredEventCount == 1) {
dojo.addClass(eventDivCount, "mumEventDivCountSingleWire" + this.currentType);
}
else {
dojo.addClass(eventDivCount, "mumEventDivCountMultiWire" + this.currentType);
}
}
var eventDivReturnImg = document.createElement("a");
eventDivReturnImg.setAttribute("role", "button");
eventDivReturnImg.setAttribute("href", "javascript:;");
eventDivReturnImg.innerHTML = "";
htmlUtil.setClass(eventDivReturnImg, "mumEventDivReturnImg" + this.currentType);
this.connect(eventDivReturnImg, "onclick", this.onClickEventReturnImg);
eventDivReturnImg.style.visibility = "hidden";
//A11Y
this.connect(eventDivReturnImg, "onkeypress", this.onKeyPressEventReturnImg);
dojo.attr(eventDivReturnImg, "title", cws["I_WIRING_OTHER_EVENTS_" + this.currentType.toUpperCase()]);
var eventDivVline = document.createElement("div");
htmlUtil.setClass(eventDivVline, "grayBar");
eventDivVline.style.visibility = "hidden";
eventDiv.setAttribute("eventName", shownEventName);
eventDiv.setAttribute("eventTitle", title);
eventDiv.setAttribute("isClicked", "false");
eventDiv.setAttribute("role", "menuitem");
//A11Y
eventDiv.appendChild(eventDivCount);
var eventDivText1 = this.createDivWithClass("mumEventDivTextReceive");
dojo.addClass(eventDivText1, "mumEventDivText1");
eventDivText1.title = title;
eventDivText1.innerHTML = htmlUtil.escapeString(title);
var eventDivText3 = this.createDivWithClass("mumEventDivTextReceive");
dojo.addClass(eventDivText3, "mumEventDivText3");
this._setupEventTypeDiv(eventDivText3, shownType);
var wrapperDiv1 = document.createElement("div");
wrapperDiv1.appendChild(eventDivText1);
var wrapperDiv3 = document.createElement("div");
wrapperDiv3.appendChild(eventDivText3);
var storeEventDivInnerHTML = eventDiv.innerHTML;
//construct the event content
var eventContent = dojo.string.substitute(cws.I_WIRING_EVENT_CONTENT_RECEIVE, [wrapperDiv1.innerHTML, '', '', wrapperDiv3.innerHTML]);
eventDiv.innerHTML = eventDiv.innerHTML + eventContent;
eventDivText1 = dojo.query(".mumEventDivText1", eventDiv)[0];
var div1Width = htmlUtil.getStrWidth(eventDivText1.innerHTML, eventDivText1, this.defaultFontStyle);
eventDivText3 = dojo.query(".mumEventDivText3", eventDiv)[0];
var div3Width = htmlUtil.getStrWidth(eventDivText3.innerHTML, eventDivText3, this.defaultFontStyle);
var eventDivText2 = dojo.query(".mumEventDivText2", eventDiv)[0];
var div2Width = htmlUtil.getStrWidth(eventDivText2.innerHTML, eventDivText2, this.italicStyle);
eventDivText2.title = eventDivText2.innerHTML;
var totalWidth = dojo.isIE || window.ActiveXObject !== undefined ? 370 : 380;
if (div1Width + div2Width + div3Width > totalWidth) {
var widthLeft = totalWidth - div2Width; //the center text will never be truncated.
var widthLeftFor3 = widthLeft - div1Width;
var widthLeftFor1 = widthLeft - div3Width;
if (widthLeftFor3 > 60) { //try to only truncate one only
div3Width = widthLeftFor3;
htmlUtil.setNodeTitleWithStyle(eventDivText3.innerHTML, eventDivText3, div3Width, this.defaultFontStyle);
}
else
if (widthLeftFor1 > 60) {
div1Width = widthLeftFor1;
htmlUtil.setNodeTitleWithStyle(eventDivText1.innerHTML, eventDivText1, div1Width, this.defaultFontStyle);
}
else {
div1Width = widthLeft * 0.6;
div3Width = widthLeft * 0.4;
htmlUtil.setNodeTitleWithStyle(eventDivText1.innerHTML, eventDivText1, div1Width, this.defaultFontStyle);
htmlUtil.setNodeTitleWithStyle(eventDivText3.innerHTML, eventDivText3, div3Width, this.defaultFontStyle);
}
}
eventDiv.appendChild(eventDivReturnImg);
this.connect(eventDiv, "onclick", this.onClickEvent);
//A11Y
this.connect(eventDiv, "onkeypress", this.onKeyPressEvent);
this._insertEventA11yHint("Receive", eventDiv, wiredEventCount);
}
if (!hasEventToShow) {
wirePaneEventsContentDiv.appendChild(this.grayTip);
}
var wirePaneEventsBottomDiv = this.createDivWithClass("mumEventsBottomDiv" + this.currentType);
this.wirePaneEventsDiv.appendChild(wirePaneEventsBottomDiv);
},
/**
* Generate the send Events pane of current widget
*/
createSendEventsDiv: function(){
this.createCurrentWidgetDiv();
//reset the whole wire pane
this.wirePaneEventsDiv.innerHTML = "";
htmlUtil.setClass(this.wirePaneEventsDiv, "mumEventsDiv");
htmlUtil.setClass(this.grayTip, "mumWireWidgetTipReceive");
this.grayTip.innerHTML = cws.I_WIRING_NO_SEND_EVENTS;
dojo.attr(this.grayTip, "title", cws.I_WIRING_NO_SEND_EVENTS);
//Init the title
var eventsTitleDiv = document.createElement("div");
htmlUtil.setClass(eventsTitleDiv, "mumEventsTitleDivSend");
htmlUtil.setNodeTitleWithStyle(cws.I_WIRING_EVENTS_SEND, eventsTitleDiv, 425, this.titleFontStyle);
this.wirePaneEventsDiv.appendChild(eventsTitleDiv);
//Fetch the send events' info
var pEvents = [];
var layoutControl = this.getLayoutControl(this.iwidgetId);
pEvents = com.ibm.mm.builder.utils.wireUtil.getWidgetPublishedEventsCSA2(layoutControl);
var wirePaneEventsContentDiv = this.createDivWithClass("mumEventsContentDiv" + this.currentType);
wirePaneEventsContentDiv.setAttribute("role", "menu");
this.wirePaneEventsDiv.appendChild(wirePaneEventsContentDiv);
var hasEventToShow = false;
//Generate the event div recuisively
for (var n = 0; n < pEvents.length; n++) {
var pubEvent = pEvents[n];
var eventDiv = document.createElement("div");
eventDiv.setAttribute("tabindex", "0");
eventDiv.setAttribute("role", "menuitem");
htmlUtil.setClass(eventDiv, "mumEventDiv");
wirePaneEventsContentDiv.appendChild(eventDiv);
hasEventToShow = true;
var title = "";
var description = "";
var shownType = "";
var shownEventName = "";
title = pubEvent.getTitle(dojo.locale) || pubEvent.getTitle(ibmConfig["default.locale"]) || pubEvent.getName();
description = pubEvent.getDescription(dojo.locale) || pubEvent.getName();
shownType = pubEvent.getPayloadType();
shownEventName = pubEvent.getName();
// To fix bug 3218 3228
var eventTitle = dojo.string.substitute(cws.I_WIRING_EVENT_TITLE_SEND, [title, this.getShownType(shownType), description]);
eventDiv.title = eventTitle;
var widgetsArray = this.eventsMap["Send-" + shownEventName];
var wiredEventCount = 0;
for (var i = 0; i < widgetsArray.length; i++) {
wiredEventCount = wiredEventCount + widgetsArray[i].totalWiredEvents;
}
var eventDivCount = document.createElement("div");
htmlUtil.setClass(eventDivCount, "mumEventDivCount" + this.currentType);
if (wiredEventCount > 0) {
eventDivCount.innerHTML = wiredEventCount;
dojo.addClass(eventDiv, "mumEventDivWired");
if (wiredEventCount == 1) {
dojo.addClass(eventDivCount, "mumEventDivCountSingleWire" + this.currentType);
}
else {
dojo.addClass(eventDivCount, "mumEventDivCountMultiWire" + this.currentType);
}
}
var eventDivReturnImg = document.createElement("a");
eventDivReturnImg.setAttribute("role", "button");
eventDivReturnImg.setAttribute("href", "javascript:;");
//defect 7491
eventDivReturnImg.innerHTML = "";
htmlUtil.setClass(eventDivReturnImg, "mumEventDivReturnImg" + this.currentType);
this.connect(eventDivReturnImg, "onclick", this.onClickEventReturnImg);
eventDivReturnImg.style.visibility = "hidden";
//A11Y
this.connect(eventDivReturnImg, "onkeypress", this.onKeyPressEventReturnImg);
dojo.attr(eventDivReturnImg, "title", cws["I_WIRING_OTHER_EVENTS_" + this.currentType.toUpperCase()]);
eventDiv.setAttribute("eventName", shownEventName);
eventDiv.setAttribute("eventTitle", title);
eventDiv.setAttribute("isClicked", "false");
eventDiv.appendChild(eventDivCount);
//init the event name and payload type div
var eventDivText1 = this.createDivWithClass("mumEventDivTextSend");
dojo.addClass(eventDivText1, "mumEventDivText1");
eventDivText1.title = title;
eventDivText1.innerHTML = htmlUtil.escapeString(title);
var eventDivText3 = this.createDivWithClass("mumEventDivTextSend");
dojo.addClass(eventDivText3, "mumEventDivText3");
this._setupEventTypeDiv(eventDivText3, shownType);
var wrapperDiv1 = document.createElement("div");
wrapperDiv1.appendChild(eventDivText1);
var wrapperDiv3 = document.createElement("div");
wrapperDiv3.appendChild(eventDivText3);
var storeEventDivInnerHTML = eventDiv.innerHTML;
//construct the event content
var eventContent = dojo.string.substitute(cws.I_WIRING_EVENT_CONTENT_SEND, [wrapperDiv1.innerHTML, '', '', wrapperDiv3.innerHTML]);
eventDiv.innerHTML = eventDiv.innerHTML + eventContent;
eventDivText1 = dojo.query(".mumEventDivText1", eventDiv)[0];
var div1Width = htmlUtil.getStrWidth(eventDivText1.innerHTML, eventDivText1, this.defaultFontStyle);
eventDivText3 = dojo.query(".mumEventDivText3", eventDiv)[0];
var div3Width = htmlUtil.getStrWidth(eventDivText3.innerHTML, eventDivText3, this.defaultFontStyle);
var eventDivText2 = dojo.query(".mumEventDivText2", eventDiv)[0];
var div2Width = htmlUtil.getStrWidth(eventDivText2.innerHTML, eventDivText2, this.italicStyle);
eventDivText2.title = eventDivText2.innerHTML;
var totalWidth = dojo.isIE || window.ActiveXObject !== undefined ? 370 : 380;
if (div1Width + div2Width + div3Width > totalWidth) {
var widthLeft = totalWidth - div2Width; //the center text will never be truncated.
var widthLeftFor3 = widthLeft - div1Width;
var widthLeftFor1 = widthLeft - div3Width;
if (widthLeftFor3 > 60) { //try to only truncate one only
div3Width = widthLeftFor3;
htmlUtil.setNodeTitleWithStyle(eventDivText3.innerHTML, eventDivText3, div3Width, this.defaultFontStyle);
}
else
if (widthLeftFor1 > 60) {
div1Width = widthLeftFor1;
htmlUtil.setNodeTitleWithStyle(eventDivText1.innerHTML, eventDivText1, div1Width, this.defaultFontStyle);
}
else {
div1Width = widthLeft * 0.6;
div3Width = widthLeft * 0.4;
htmlUtil.setNodeTitleWithStyle(eventDivText1.innerHTML, eventDivText1, div1Width, this.defaultFontStyle);
htmlUtil.setNodeTitleWithStyle(eventDivText3.innerHTML, eventDivText3, div3Width, this.defaultFontStyle);
}
}
eventDiv.appendChild(eventDivReturnImg);
this.connect(eventDiv, "onclick", this.onClickEvent);
//A11Y
this.connect(eventDiv, "onkeypress", this.onKeyPressEvent);
this._insertEventA11yHint("Send", eventDiv, wiredEventCount);
}
if (!hasEventToShow) {
wirePaneEventsContentDiv.appendChild(this.grayTip);
}
var wirePaneEventsBottomDiv = this.createDivWithClass("mumEventsBottomDiv" + this.currentType);
this.wirePaneEventsDiv.appendChild(wirePaneEventsBottomDiv);
},
createCurrentWidgetDiv: function(){
this.wirePaneCurrentWidgetDiv.innerHTML = "";
var currentWidgetTitleDiv;
htmlUtil.setClass(this.wirePaneCurrentWidgetDiv, "mumPaneDiv");
var currentWidgetArrow = this.createDivWithClass("mumCurrentWidgetArrow" + this.currentType);
// defect 7491
currentWidgetArrow.innerHTML = "" : "_arrow.png' alt=''>");
// the mid centent of the current widget div
var currentWidgetContentDiv = this.createDivWithClass("mumCurrentWidgetContentDiv" + this.currentType);
currentWidgetContentDiv.setAttribute("role", "menu");
var currentWidgetDiv = this.createDivWithClass("mumCurrentWidgetDiv" + this.currentType);
currentWidgetDiv.setAttribute("role", "menuitem");
// #17333 add hover class
dojo.disconnect(this.widgetDivOverHandler);
dojo.disconnect(this.widgetDivOutHandler);
this.widgetDivOverHandler = dojo.connect(currentWidgetDiv,'onmouseover',currentWidgetDiv,function() {
dojo.addClass(this, 'hover');
},true);
this.widgetDivOutHandler = dojo.connect(currentWidgetDiv,'onmouseout',currentWidgetDiv,function() {
dojo.removeClass(this,'hover');
},true);
//init the currentWidget div's content
var currentWidgetIcon = this.createDivWithClass("mumCurrentWidgetIcon");
currentWidgetIcon.innerHTML = "";
var currentWidgetName = this.createDivWithClass("mumCurrentWidgetName" + this.currentType);
if (this.currentType == "Send") {
currentWidgetTitleDiv = this.createDivWithClass("mumGreenTitleDiv");
htmlUtil.setNodeTitleWithStyle(cws.I_WIRING_CWIDGET_SEND, currentWidgetTitleDiv, 425, this.titleFontStyle);
dojo.attr(currentWidgetTitleDiv, "title", cws.I_WIRING_CWIDGET_SEND);
if (this.allPubWires === 0) {
dojo.addClass(currentWidgetArrow, "mumHiddenElement");
htmlUtil.setNodeTitleWithStyle(this.widgetObj.widgetname, currentWidgetName, 375, this.titleFontStyle);
}
else {
htmlUtil.setNodeTitleWithStyle(this.widgetObj.widgetname, currentWidgetName, 345, this.titleFontStyle);
}
}
else {
currentWidgetTitleDiv = this.createDivWithClass("mumBlueTitleDiv");
htmlUtil.setNodeTitleWithStyle(cws.I_WIRING_CWIDGET_RECEIVE, currentWidgetTitleDiv, 425, this.titleFontStyle);
dojo.attr(currentWidgetTitleDiv, "title", cws.I_WIRING_CWIDGET_RECEIVE);
if (this.allHanWires === 0) {
dojo.addClass(currentWidgetArrow, "mumHiddenElement");
htmlUtil.setNodeTitleWithStyle(this.widgetObj.widgetname, currentWidgetName, 375, this.titleFontStyle);
}
else {
htmlUtil.setNodeTitleWithStyle(this.widgetObj.widgetname, currentWidgetName, 345, this.titleFontStyle);
}
}
currentWidgetDiv.appendChild(currentWidgetIcon);
currentWidgetDiv.appendChild(currentWidgetName);
currentWidgetDiv.appendChild(currentWidgetArrow);
var currentWidgetBottomDiv = this.createDivWithClass("mumCurrentWidgetBottom" + this.currentType);
currentWidgetContentDiv.appendChild(currentWidgetDiv);
this.wirePaneCurrentWidgetDiv.appendChild(currentWidgetTitleDiv);
this.wirePaneCurrentWidgetDiv.appendChild(currentWidgetContentDiv);
this.wirePaneCurrentWidgetDiv.appendChild(currentWidgetBottomDiv);
},
createTitleDiv: function(){
var span = document.createElement("span");
span.innerHTML = cws.I_WIRING_TITLE_RECEIVE;
this.receiveTextDiv.appendChild(span);
if (builderConfig.isBidi) {
this.recIconDiv.innerHTML = "(" + this.allHanWires + ")";
//defect 7491
this.receiveWireCountDiv.innerHTML = "";
}
else {
this.receiveWireCountDiv.innerHTML = "(" + this.allHanWires + ")";
//defect 7491
this.recIconDiv.innerHTML = "";
}
var spanSend = document.createElement("span");
spanSend.innerHTML = cws.I_WIRING_TITLE_SEND;
this.sendTextDiv.appendChild(spanSend);
if (builderConfig.isBidi) {
this.sendIconDiv.innerHTML = "(" + this.allPubWires + ")";
//defect 7491
this.sendWireCountDiv.innerHTML = "";
}
else {
this.sendWireCountDiv.innerHTML = "(" + this.allPubWires + ")";
//defect 7491
this.sendIconDiv.innerHTML = "";
}
this.connect(this.wirePaneTitleDivLeft, "onclick", this.onClickTitlePaneLeft);
this.connect(this.wirePaneTitleDivLeft, "onkeypress", this.onKeyPresTitlePane);
this.connect(this.wirePaneTitleDivRight, "onclick", this.onClickTitlePaneRight);
this.connect(this.wirePaneTitleDivRight, "onkeypress", this.onKeyPresTitlePane);
//Set the correct Div Styles on creation
this.adjustDivsStyle();
},
adjustTitleDiv: function(){
htmlUtil.setClass(this.wirePaneTitleDivLeft, "mumWirePaneTitleDivReceiveTab" + this.currentType);
htmlUtil.setClass(this.leftDivOfReceiveTab, "mumLeftDivOfReceiveTab" + this.currentType);
htmlUtil.setClass(this.midDivOfReceiveTab, "mumMidDivOfReceiveTab" + this.currentType);
htmlUtil.setClass(this.rightDivOfReceiveTab, "mumRightDivOfReceiveTab" + this.currentType);
if (builderConfig.isBidi) {
htmlUtil.setClass(this.receiveWireCountDiv, "mumReceiveIconDiv" + this.currentType);
htmlUtil.setClass(this.recIconDiv, "mumReceiveWireCountDiv");
this.receiveWireCountDiv.innerHTML = "";
}
else {
htmlUtil.setClass(this.recIconDiv, "mumReceiveIconDivReceive");
this.recIconDiv.innerHTML = "";
}
htmlUtil.setClass(this.wirePaneTitleDivRight, "mumWirePaneTitleDivSendTab" + this.currentType);
htmlUtil.setClass(this.leftDivOfSendTab, "mumLeftDivOfSendTab" + this.currentType);
htmlUtil.setClass(this.midDivOfSendTab, "mumMidDivOfSendTab" + this.currentType);
htmlUtil.setClass(this.rightDivOfSendTab, "mumRightDivOfSendTab" + this.currentType);
if (builderConfig.isBidi) {
htmlUtil.setClass(this.sendWireCountDiv, "mumSendIconDiv" + this.currentType);
htmlUtil.setClass(this.sendIconDiv, "mumSendWireCountDiv");
this.sendWireCountDiv.innerHTML = "";
}
else {
htmlUtil.setClass(this.sendIconDiv, "mumSendIconDivSend");
this.sendIconDiv.innerHTML = "";
}
},
/**
* This function will be invoke when user click on the "wire" icon
* 1. Gather all widget info
* 2. Init the wire pane
* 3. Init the Customized Dialog to show the wire pane
*/
display: function(iwidgetId){
// actually it is layoutControlId, not widgetId
this.iwidgetId = iwidgetId;
// Default: View send events
this.currentType = "Send";
this.eventsMap = {};
//Clean up the current wirepane
if (this.wirePane) {
this.wirePaneDiv.innerHTML = "";
// reconstruct the UI.
this.buildRendering();
}
this.widgetObj = {};
//temporary - find first layoutcontrol in container
var currentPID = com.ibm.mashups.builder.model.Factory.getRuntimeModel().getCurrentPage().getID();
this.currentPageId = currentPID;
this.widgetObj.widgetIconSrc = com.ibm.mm.builder.utils.iwidgetUtil.getWidgetIconCSA2(this.iwidgetId);
this.widgetObj.widgetname = com.ibm.mm.builder.utils.iwidgetUtil.getWidgetTitleCSA2(this.iwidgetId);
//Init work
this.initAllData();
this.initWirePane();
this.createSendEventsDiv();
var contentDiv = dojo.query("." + com.ibm.mm.builder.constant.iwWidgetContent, this.iContext.getRootElement())[0];
if (contentDiv) {
contentDiv.appendChild(this.wirePaneDiv);
}
else {
this.iContext.getRootElement().appendChild(this.wirePaneDiv);
}
this.displayPrompter("1");
},
setContext: function(context){
this.iContext = context;
},
_insertA11yHint: function(domNode, hint){
this._removeA11yHint(domNode);
dojo.create("span", {
innerHTML: hint,
'class': "access"
}, domNode, "first");
},
_removeA11yHint: function(domNode){
dojo.query(".access", domNode).forEach(dojo.destroy);
},
_insertEventA11yHint: function(currentType, eventDiv, count){
if (count > 0) {
this._insertA11yHint(eventDiv, "This event" + (currentType == "Send" ? " sends data to " : " receives data from ") + count + " event" + (count == 1 ? "" : "s"));
}
else {
this._removeA11yHint(eventDiv);
}
},
/**
* Opens the wiring settings dialog widget.
*/
openWiringSettings: function(){
if (!this.wiringSettingsDialog) {
this.wiringSettingsDialog = new com.ibm.mm.builder.iwidget.wiringscreen.WiringSettingsDialog();
this.wiringSettingsDialog.setOuterContext( this.iContext );
//Register as a listener to get notified when the settings dialog is dismissed using the Done button.
dojo.connect(this.wiringSettingsDialog, "onSettingsSaved", this, this.settingsSaved);
}
this.wiringSettingsDialog.setMatchingType( this.matchingType );
this.wiringSettingsDialog.show();
},
resetView: function () {
if ( this.firstAreaBottomDiv ) {
htmlUtil.setClass(this.firstAreaBottomDiv, "mumFirstAreaBottomDiv" + this.currentType);
dojo.fx.wipeOut({
node: this.secondAreaDiv,
duration: 500
}).play();
}
if ( this.secondAreaBottomDiv ) {
this.hideElement(this.secondAreaBottomDiv);
dojo.fx.wipeOut({
node: this.wirePaneWidgetEventsDiv,
duration: 10
}).play();
}
this.displayPrompter("1");
if ( this.currentType === "Send" ) {
this.createSendEventsDiv();
} else if ( this.currentType === "Receive" ) {
this.createReceiveEventsDiv();
}
this.resetEventWireCount();
},
/**
* Handler for saved settings from the wiring settings dialog.
*/
settingsSaved: function(settings){
this.wiringSettings = settings;
this.matchingType = settings[this.wiringSettingsConstants.SETTING_MATCHING_TYPE];
var config = this.iContext.getiWidgetAttributes();
config.setItemValue( "matchingType", this.matchingType );
var me = this;
// TODO: not work for system widget!
config.save(function () {
//reset the data now
me.initAllData();
//reset the view with the new data
me.resetView();
});
},
_setupEventTypeDiv: function(div, payloadType) {
payloadLabel = this.getShownType(payloadType);
div.innerHTML = htmlUtil.escapeString(payloadLabel);
div.title = payloadLabel;
}
});
})();
}
if(!dojo._hasResource["com.ibm.mm.builder.iwidget.wiringscreen.AutoWiringDisabledTip"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.iwidget.wiringscreen.AutoWiringDisabledTip"] = true;
/**
*
*/
dojo.provide("com.ibm.mm.builder.iwidget.wiringscreen.AutoWiringDisabledTip");
dojo.declare("com.ibm.mm.builder.iwidget.wiringscreen.AutoWiringDisabledTip", [dijit._Widget, dijit._Templated], {
autoWiringResult: false,
contentRoot: null,
notificationDialog:null,
widgetId: null,
templateString: "" +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
""+
"" +
""+
"" +
"",
constructor:function(){
},
postCreate:function(){
this.initContent();
},
updateContent:function(widgetId){
var widgetTitle = com.ibm.mm.builder.utils.iwidgetUtil.getWidgetTitleCSA2(widgetId);
widgetTitle = com.ibm.mm.builder.utils.htmlUtil.formatBlankSpace(widgetTitle);
var tip = dojo.query(".mumAWDNTip", this.notificationDialog.domNode)[0];
tip.innerHTML = dojo.string.substitute(com.ibm.mm.builder.coreWidgetsStrings.I_AUTO_WIRING_INTERFACE_TIP,[widgetTitle,"",""]);
var link = dojo.query(".mumAWDNTipLink", tip)[0];
dojo.connect(link,"onclick", this,"onClickOpenAWProperties");
// check/uncheck the NotiCfgCheckNode
if (com.ibm.mm.builder.utils.userUtil.isLookasideEnabled("com.ibm.mashups.user.AUTO_WIRE_DISABLED_NOTIFICATIONS")) {
var userModel = com.ibm.mm.builder.utils.userUtil.getUserModel();
var user = userModel.findCurrentUser().start();
var showNoti = user.getAttribute("com.ibm.mashups.user.AUTO_WIRE_DISABLED_NOTIFICATIONS");
this.NotiCfgCheckNode.checked = !showNoti;
}
},
setOuterWirePaneContext:function(iContext) {
this.outerContext = iContext;
},
onNotNotifyMeClicked: function(event){
if (com.ibm.mm.builder.utils.userUtil.isLookasideEnabled("com.ibm.mashups.user.AUTO_WIRE_DISABLED_NOTIFICATIONS")) {
var userModel = com.ibm.mm.builder.utils.userUtil.getUserModel();
var user = userModel.findCurrentUser().start();
user.setAttribute("com.ibm.mashups.user.AUTO_WIRE_DISABLED_NOTIFICATIONS",!this.NotiCfgCheckNode.checked);
userModel.commit().start();
}
},
onClickOpenAWProperties:function(){
this.hide();
var currentPageId = com.ibm.mashups.builder.model.Factory.getRuntimeModel().getCurrentPage().getID();
com.ibm.mashups.services.ServiceManager.getService("eventService").broadcastEvent("com.ibm.mashups.builder.closeMashupDialog", this.outerContext.widgetId);
com.ibm.mm.builder.commonActions.editPage(currentPageId);
},
initContent:function(){
this.wiringIcon.alt = this.wiringIcon.title= com.ibm.mm.builder.coreWidgetsStrings.I_WIRING_NAME;
dojo.attr(this.wiringIcon,"src",builderConfig.builderPath + (builderConfig.isBidi ? "/images/d_wiring_icon_rtl.png" :
"/images/d_wiring_icon.png"));
this.NotiCfgLabel.innerHTML = com.ibm.mm.builder.coreWidgetsStrings.I_AUTO_WIRING_NOTIFICATION_DISABLE_NOTI;
this.okText.innerHTML = "" + com.ibm.mm.builder.coreWidgetsStrings.I_COMMON_OK + "";
dojo.connect(this.okText,"onclick", this,"hide");
this.okTextHidden.innerHTML = "" + com.ibm.mm.builder.coreWidgetsStrings.I_COMMON_OK + "";
var contentDiv = document.createElement("div");
contentDiv.appendChild(this.autoWiringNotiDiv);
this.notificationDialog = dijit.byId("this.notificationDialog");
if (!this.notificationDialog) {
this.notificationDialog = new com.ibm.mm.builder.widget.CustomDialog({
id: "Mashup_Auto_Wiring_Disable_Tip_Dlg",
needUnderLay: false,
roundCorner: true,
modelDialog: true,
hasRightBottomResizer: false,
dialogOpacity: 0.85
}, contentDiv);
}
},
destroy:function() {
this.notificationDialog.destroy();
},
show:function(widgetId) {
this.updateContent(widgetId);
this.notificationDialog.show();
},
hide:function(){
if(this.notificationDialog) {
this.notificationDialog.hide();
}
}
});
}
if(!dojo._hasResource["com.ibm.mm.builder.iwidget.wiringscreen.AutoWiringNotification"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["com.ibm.mm.builder.iwidget.wiringscreen.AutoWiringNotification"] = true;
/**
*/
dojo.provide("com.ibm.mm.builder.iwidget.wiringscreen.AutoWiringNotification");
dojo.declare("com.ibm.mm.builder.iwidget.wiringscreen.AutoWiringNotification", [dijit._Widget, dijit._Templated], {
autoWiringResult: null,
contentRoot: null,
notificationDialog:null,
widgetId: null,
location:null,
templateString: "" +
""+
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
""+
"" +
""+
"" +
"",
constructor: function(){
},
onNotifyMeClicked:function(event){
if (com.ibm.mm.builder.utils.userUtil.isLookasideEnabled("com.ibm.mashups.user.AUTO_WIRE_ENABLED_NOTIFICATIONS")) {
var userModel = com.ibm.mm.builder.utils.userUtil.getUserModel();
var user = userModel.findCurrentUser().start();
user.setAttribute("com.ibm.mashups.user.AUTO_WIRE_ENABLED_NOTIFICATIONS", !this.NotiCfgCheckNode.checked);
userModel.commit().start();
}
},
onClickOpenWiring:function(){
var widgetId = this.autoWiringResult.widgetId;
var widgetUtil = com.ibm.mm.builder.utils.iwidgetUtil;
var widgetIcon = widgetUtil.getWidgetIconCSA2(widgetId);
var dialogParam = {
nodeWidth: "486px",
title: com.ibm.mm.builder.coreWidgetsStrings.I_WIRING_NAME,
titleIconUrl: widgetIcon,
leftBarWidth: "18px",
rightBarWidth: "12px",
displayCloseButton: true,
hasRightBottomResizer: false
};
var payload = {
widgetTypeId: "wireInterface",
eventName: "com.ibm.mashups.builder.editWire",
eventPayload: widgetId,
dialogParam: dialogParam,
hasRightBottomResizer: false,
requestRefresh: true
};
com.ibm.mashups.services.ServiceManager.getService("eventService").broadcastEvent("com.ibm.mashups.builder.displayInMashupDialog", payload);
},
initContent:function(){
this.fillInText();
if (!this.autoWiringResult) {
return;
}
this.titleIconNode.innerHTML = "";
var wiringIcon = document.createElement("img");
this.titleIconNode.appendChild(wiringIcon);
wiringIcon.alt = wiringIcon.title= com.ibm.mm.builder.coreWidgetsStrings.I_WIRING_NAME;
dojo.attr(wiringIcon,"src",builderConfig.builderPath + (builderConfig.isBidi ? "/images/d_wiring_icon_rtl.png":"/images/d_wiring_icon.png"));
this.contentNode.innerHTML = "";
var publishToWidgets = this.autoWiringResult.publishTo;
var receiveFromWidgets = this.autoWiringResult.receiveFrom;
var wireDiv=null;
for(var i = 0; i < publishToWidgets.length; i++) {
wireDiv = this.createWireDiv(publishToWidgets[i],"Send");
this.contentNode.appendChild(wireDiv);
}
for(var j = 0; j < receiveFromWidgets.length; j++) {
wireDiv = this.createWireDiv(receiveFromWidgets[j],"Receive");
this.contentNode.appendChild(wireDiv);
}
dojo.connect(this.openWiringNode,"onclick", this,"onClickOpenWiring");
dojo.connect(this.okText,"onclick", this,"hide");
},
hide:function(){
var notificationDlg = dijit.byId("Mashup_Auto_Wiring_Notification_Dlg" + this.widgetId);
if(notificationDlg) {
notificationDlg.hide();
notificationDlg.destroy();
}
},
createWireDiv:function(widgetId,type) {
//var widgetTitle = com.ibm.mm.builder.utils.iwidgetUtil.getWidgetInstanceTitle(widgetId);
var widgetTitle = com.ibm.mm.builder.utils.iwidgetUtil.getWidgetTitleCSA2(widgetId);
widgetTitle = com.ibm.mm.builder.utils.htmlUtil.formatBlankSpace(widgetTitle);
var widgetIconUrl = com.ibm.mm.builder.utils.iwidgetUtil.getWidgetIconCSA2(widgetId);
var wireDiv = document.createElement("div");
dojo.addClass(wireDiv,"mumAutoWiringWireDiv");
var iconDiv = document.createElement("div");
wireDiv.appendChild(iconDiv);
dojo.addClass(iconDiv,"mumAWWireDivIcon");
var widgetIcon = document.createElement("img");
iconDiv.appendChild(widgetIcon);
widgetIcon.alt = widgetIcon.title= com.ibm.mm.builder.utils.htmlUtil.unEscapeString(widgetTitle);
dojo.attr(widgetIcon,"src",widgetIconUrl);
var textDiv = document.createElement("div");
wireDiv.appendChild(textDiv);
dojo.addClass(textDiv,"mumAWWireDivText");
if(type == "Send") {
textDiv.innerHTML = textDiv.title = dojo.string.substitute(com.ibm.mm.builder.coreWidgetsStrings.I_AUTO_WIRING_NOTIFICATION_SENDING_TO,[widgetTitle]);
}
else {
textDiv.innerHTML = textDiv.title = dojo.string.substitute(com.ibm.mm.builder.coreWidgetsStrings.I_AUTO_WIRING_NOTIFICATION_RECEIVING_FROM,[widgetTitle]);
}
return wireDiv;
},
fillInText:function(){
var widgetTitle = com.ibm.mm.builder.utils.iwidgetUtil.getWidgetInstanceTitle(this.widgetId);
widgetTitle = com.ibm.mm.builder.utils.htmlUtil.formatBlankSpace(widgetTitle);
if (this.location.inNVA) {
this.titleText.innerHTML = dojo.string.substitute(com.ibm.mm.builder.coreWidgetsStrings.I_AUTO_WIRING_NOTIFICATION_TITLE_FOR_WIDGET, [widgetTitle]);
}
else {
this.titleText.innerHTML = com.ibm.mm.builder.coreWidgetsStrings.I_AUTO_WIRING_NOTIFICATION_TITLE;
}
this.openWiringNode.innerHTML = "" + com.ibm.mm.builder.coreWidgetsStrings.I_AUTO_WIRING_NOTIFICATION_OPEN_WIRE_INTERFACE + "";
this.NotiCfgLabel.innerHTML = com.ibm.mm.builder.coreWidgetsStrings.I_AUTO_WIRING_NOTIFICATION_DISABLE_NOTI;
this.okText.innerHTML = "" + com.ibm.mm.builder.coreWidgetsStrings.I_COMMON_OK + "";
this.okTextHidden.innerHTML = "" + com.ibm.mm.builder.coreWidgetsStrings.I_COMMON_OK + "";
},
/**
* show the access control reassign dialog
*/
showAutoWiringResult: function(id,autoWiringResult,location){
this.widgetId = id;
this.autoWiringResult = autoWiringResult;
this.location = location;
dojo.subscribe("widgetDeleted"+id,this,"hide");
this.initContent();
var notificationDlg = dijit.byId("Mashup_Auto_Wiring_Notification_Dlg" + this.widgetId);
if (notificationDlg){
notificationDlg.destroy();
}
var contentDiv = document.createElement("div");
contentDiv.appendChild(this.autoWiringNotiDiv);
this.notificationDialog = new com.ibm.mm.builder.widget.CustomDialog(
{
id: "Mashup_Auto_Wiring_Notification_Dlg"+this.widgetId,
needUnderLay:false,
roundCorner:true,
modelDialog:false,
initLeftPosition:location.x+"px",
initTopPosition:location.y+"px",
hasRightBottomResizer: false,
dialogOpacity: 0.85
},
contentDiv
);
this.notificationDialog.show();
}
});
}