FeaturesHeader.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. "use strict";
  2. /**
  3. * Licensed Materials - Property of IBM
  4. * IBM Cognos Products: Cognos Analytics
  5. * Copyright IBM Corp. 2015, 2018
  6. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. */
  8. define(['underscore', 'q', 'bi/commons/ui/View', 'bi/admin/nls/StringResource', 'doT', 'text!bi/admin/account/templates/FeaturesHeaderTemplate.html', 'bi/admin/common/ui/MagicWand'], function (_, Q, View, StringResource, dot, FeaturesHeaderTemplate, MagicWand) {
  9. 'use strict'; //NOSONAR
  10. var FeaturesHeader = View.extend({
  11. $body: null,
  12. init: function init(options) {
  13. FeaturesHeader.inherited('init', this, arguments);
  14. _.extend(this, options);
  15. },
  16. render: function render() {
  17. var deferred = Q.defer();
  18. var sHtml = dot.template(FeaturesHeaderTemplate)({
  19. 'title': StringResource.get('features'),
  20. 'onFilter': this.onFilter
  21. });
  22. this.$el.html(sHtml);
  23. MagicWand.searchInput(this.$el).done(function (widgets) {
  24. if (widgets.length === 1) {
  25. this._filterInput = widgets[0];
  26. this._filterInput.on('changed', function (e) {
  27. if (this.onFilter) {
  28. var trimmed = e.text.trim();
  29. if (trimmed.length > 0 || e.text === '') {
  30. this.onFilter(trimmed);
  31. }
  32. }
  33. }.bind(this));
  34. }
  35. deferred.resolve(this.$el);
  36. }.bind(this));
  37. return deferred.promise;
  38. },
  39. setFocus: function setFocus() {},
  40. remove: function remove() {
  41. if (this.$body) {
  42. this.$body.remove();
  43. }
  44. }
  45. });
  46. return FeaturesHeader;
  47. });