hostLogPopupBody_view.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. App.WizardStep3HostLogPopupBody = Em.View.extend({
  20. templateName: require('templates/wizard/step3/step3_host_log_popup'),
  21. /**
  22. * Host's boot log
  23. * @type {string}
  24. */
  25. bootLog: function() {
  26. return this.get('parentView.host.bootLog');
  27. }.property('parentView.host.bootLog'),
  28. /**
  29. * Is textarea view active
  30. * @type {bool}
  31. */
  32. isTextArea: false,
  33. /**
  34. * Textbox with host's boot log
  35. * @type {Ember.TextArea}
  36. */
  37. textArea: Em.TextArea.extend({
  38. didInsertElement: function () {
  39. /* istanbul ignore next: simple DOM manipulations */
  40. $(this.get('element'))
  41. .width($(this.get('parentView').get('element')).width() - 10)
  42. .height($(this.get('parentView').get('element')).height())
  43. .select()
  44. .css('resize', 'none');
  45. },
  46. /**
  47. * Edit disabled
  48. * @type {bool}
  49. */
  50. readOnly: true,
  51. /**
  52. * <code>parentView.bootLog</code>
  53. * @type {string}
  54. */
  55. value: function () {
  56. return this.get('content');
  57. }.property('content')
  58. }),
  59. didInsertElement: function () {
  60. var self = this;
  61. var button = $(this.get('element')).find('.textTrigger');
  62. button.click(function () {
  63. $(this).text(self.get('isTextArea') ? Em.I18n.t('installer.step3.hostLogPopup.highlight') : Em.I18n.t('installer.step3.hostLogPopup.copy'));
  64. self.set('isTextArea', !self.get('isTextArea'));
  65. });
  66. /* istanbul ignore next: difficult to test */
  67. $(this.get('element')).find('.content-area')
  68. .mouseenter(
  69. function () {
  70. $(this).css('border', '1px solid #dcdcdc');
  71. button.css('visibility', 'visible');
  72. })
  73. .mouseleave(
  74. function () {
  75. $(this).css('border', 'none');
  76. button.css('visibility', 'hidden');
  77. });
  78. }
  79. });