widget_popover_support.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. /**
  20. * Popover for configs widgets
  21. * Usage:
  22. * <code>
  23. * didInsertElement: function () {
  24. * this._super();
  25. * this.initPopover();
  26. * }
  27. * </code>
  28. * @type {Em.Mixin}
  29. */
  30. App.WidgetPopoverSupport = Em.Mixin.create({
  31. /**
  32. * Should popover be on the page
  33. * @type {boolean}
  34. */
  35. isPopoverEnabled: true,
  36. /**
  37. * Where popover should be displayed - top|left|right|bottom
  38. * @type {string}
  39. */
  40. popoverPlacement: 'right',
  41. initPopover: function () {
  42. // if description for this config not exist, then no need to show popover
  43. if (this.get('isPopoverEnabled') !== 'false' && this.get('config.description')) {
  44. App.popover(this.$('.original-widget'), {
  45. title: Em.I18n.t('installer.controls.serviceConfigPopover.title').format(
  46. this.get('configLabel'),
  47. (this.get('config.displayName') == this.get('config.name')) ? '' : this.get('config.name')
  48. ),
  49. content: this.get('config.description'),
  50. placement: this.get('popoverPlacement'),
  51. trigger: 'hover'
  52. });
  53. }
  54. },
  55. willDestroyElement: function() {
  56. this.$().popover('destroy');
  57. }
  58. });