123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- "use strict";
- /**
- * Licensed Materials - Property of IBM
- * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2014, 2017
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define(['./Menu', 'underscore', 'text!../templates/Menu.html'], function (Menu, _, template) {
- var MenuWithTickItem = null;
- /**
- * Represents a drop down menu that can be added to an app bar
- */
- MenuWithTickItem = Menu.extend({
- templateString: template,
- /**
- * Creates a new menu item
- *
- * @param spec -
- * The menu item spec
- * @param root -
- * A reference to the root menu item, where items go if the app bar is collapsed horizontally
- */
- init: function init(spec) {
- _.extend(this, spec);
- MenuWithTickItem.inherited('init', this, arguments);
- },
- _templateParams: function _templateParams() {
- var params = MenuWithTickItem.inherited('_templateParams', this, arguments);
- params.showTick = true;
- return params;
- },
- /**
- * Updates checked mark and aria-checked attributes in given menuItem
- */
- updateMenuItemTick: function updateMenuItemTick($MenuItem, checked) {
- if ($MenuItem) {
- var link = $MenuItem.find('a');
- if (checked) {
- link.addClass('menuitem-toggled');
- } else {
- link.removeClass('menuitem-toggled');
- }
- $MenuItem.find('a')[0].setAttribute('aria-checked', checked ? 'true' : 'false');
- }
- }
- });
- return MenuWithTickItem;
- });
|