12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- 'use strict';
- define(['jquery'], function ($) {
- var TriggerEventActionHandler = function TriggerEventActionHandler(options) {
-
- this.dashboardApi = options && options.dashboardApi;
- };
-
- TriggerEventActionHandler.prototype.execute = function (event, buttonDefinition) {
- TriggerEventActionHandler._triggerEvent(this.dashboardApi, buttonDefinition);
- };
-
- TriggerEventActionHandler.prototype.onSelectItem = function (context) {
- var menuId = context.target.itemId;
-
- var menuSpec = $.grep(context.target.plugin.itemSpec.items, function (item) {
- return item.id === menuId;
- });
- if (!menuSpec || menuSpec.length === 0) {
- console.debug('Could not find menu with id ' + menuId);
- }
- var dashboardApi = context.glassContext.appController.getCurrentContentView().getDashboardApi();
- TriggerEventActionHandler._triggerEvent(dashboardApi, menuSpec[0]);
- };
- TriggerEventActionHandler._triggerEvent = function (dashboardApi, contribDef) {
- var eventName = contribDef ? contribDef.eventName : null;
- if (!eventName) {
- console.debug('No eventName property in the button definition.');
- return;
- }
- dashboardApi.triggerDashboardEvent(eventName);
- };
- return TriggerEventActionHandler;
- });
|