OptionsSlideoutView.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * Licensed Materials - Property of IBM
  3. *
  4. * IBM Cognos Products: SHARE
  5. *
  6. * (C) Copyright IBM Corp. 2015, 2017
  7. *
  8. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with
  9. * IBM Corp.
  10. */
  11. define([
  12. 'jquery',
  13. 'q',
  14. 'bi/sharecommon/utils/simpledoT',
  15. 'bi/sharecommon/utils/translator',
  16. 'bi/glass/app/ContentView',
  17. 'bi/commons/utils/Utils',
  18. 'bi/commons/ui/properties/PropertyUIControl',
  19. 'bootstrap'
  20. ], function($, Q, dot, t, View, Utils, PropertyUIControl) {
  21. 'use strict';
  22. var optionsSlideoutView = View.extend({
  23. /**
  24. * @constructs
  25. * @public
  26. * @param {Object} options - set of initial properties
  27. * @param {Object} options.$el - The HTML element this view will be created at
  28. * @param {Object} options.slideout - Glass slideout object.
  29. * @param {function} options.closeCallback - If defined this is called when remove() is executed.
  30. */
  31. init: function(options) {
  32. optionsSlideoutView.inherited('init', this, arguments);
  33. $.extend(this, options);
  34. },
  35. render: function() {
  36. var deferred = Q.defer();
  37. this._propertyUIControl = new PropertyUIControl({
  38. 'glassContext': this.glassContext,
  39. 'el': this.$el,
  40. 'closeCallback': this._close.bind(this),
  41. 'items': [{
  42. 'type': 'Banner',
  43. 'centerLabel': true,
  44. 'backButton': this.slideout.overlay,
  45. 'value': this.title
  46. }]
  47. });
  48. this._propertyUIControl.render().done(function() {
  49. this.$el.find('.propertiesUIControlPageView').append(this.content);
  50. this.$el.find('.propertyUIControl').addClass('new_schedule_panel');
  51. if(typeof this.setUpCallback === 'function') {
  52. this.setUpCallback(this.content);
  53. }
  54. this._setEvents();
  55. deferred.resolve(true);
  56. }.bind(this));
  57. return deferred.promise;
  58. },
  59. setFocus: function() {
  60. if(!this.slideout.overlay){
  61. this.$el.find(".checkbox:eq(0)").focus();
  62. }
  63. else {
  64. this.$el.find('*[tabindex]:eq(0)').focus();
  65. }
  66. },
  67. remove: function() {
  68. if(typeof this.closeCallback === 'function') {
  69. this.closeCallback();
  70. }
  71. },
  72. _setEvents: function() {
  73. this.$el.find('.schedule_primary_button').on('clicktap', function(){
  74. this._close();
  75. }.bind(this));
  76. },
  77. _close: function() {
  78. this.slideout.hide({
  79. hideOnly: true
  80. });
  81. }
  82. });
  83. return optionsSlideoutView;
  84. });