selectable_popup_body_view.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. * Body-view for popups where shown content may be switched to textarea-view
  21. * @type {Ember.View}
  22. */
  23. App.SelectablePopupBodyView = Em.View.extend({
  24. templateName: require('templates/common/selectable_popup'),
  25. /**
  26. * True - if editable textarea is visible, false - otherwise
  27. * @type {boolean}
  28. */
  29. textareaVisible: false,
  30. /**
  31. * Switch <code>textareaVisible</code> value
  32. * @method textTrigger
  33. */
  34. textTrigger: function () {
  35. this.toggleProperty('textareaVisible');
  36. },
  37. /**
  38. * Set data to the visible textarea
  39. * @method putContentToTextarea
  40. */
  41. putContentToTextarea: function () {
  42. var content = this.get('parentView.content');
  43. if (this.get('textareaVisible')) {
  44. var wrapper = $(".task-detail-log-maintext");
  45. $('.task-detail-log-clipboard').html(content).width(wrapper.width()).height(wrapper.height());
  46. Em.run.next(function () {
  47. $('.task-detail-log-clipboard').select();
  48. });
  49. }
  50. }.observes('textareaVisible')
  51. });