checkbox_config_widget_view.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. require('views/common/controls_view');
  19. var App = require('app');
  20. /**
  21. * Checkbox config widget for enhanced configs.
  22. * @type {Em.View}
  23. */
  24. App.CheckboxConfigWidgetView = App.ConfigWidgetView.extend({
  25. templateName: require('templates/common/configs/widgets/checkbox_config_widget'),
  26. classNames: ['widget-config', 'checkbox-widget'],
  27. didInsertElement: function () {
  28. var self = this;
  29. this.initPopover();
  30. this._super(arguments);
  31. Em.run.next(function () {
  32. if (self.$())
  33. self.$('input[type="checkbox"]:eq(0)').checkbox({
  34. defaultState: self.get('config.value'),
  35. buttonStyle: 'btn-link btn-large',
  36. checkedClass: 'icon-check',
  37. uncheckedClass: 'icon-check-empty'
  38. });
  39. });
  40. },
  41. configView: App.ServiceConfigCheckbox.extend({
  42. serviceConfigBinding: 'parentView.config',
  43. // @TODO maybe find use case of this method for widget
  44. focusIn: function() {},
  45. toggleValue: function() {
  46. this._super();
  47. this.sendRequestRorDependentConfigs(this.get('serviceConfig'));
  48. }.observes('checked')
  49. }),
  50. /**
  51. * Manually reset bootstrap-checkbox
  52. * @method restoreValue
  53. */
  54. restoreValue: function () {
  55. this.$('input[type="checkbox"]:eq(0)').checkbox('click');
  56. this._super();
  57. }
  58. });