123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- 'use strict';
- /**
- * Licensed Materials - Property of IBM
- * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2014, 2018
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define(['../../../lib/@waca/core-client/js/core-client/ui/dialogs/BaseDialog', 'jquery', 'underscore', '../../nls/StringResources'], function (BaseDialog, $, _, stringResources) {
- var Dialog = null;
- Dialog = BaseDialog.extend({
- init: function init(options) {
- this._props = {
- 'type': options.sType,
- 'title': options.sTitle,
- 'value': options.sValue,
- 'actionHandler': options.actionHandler
- };
- // Add a close (predefined in BaseDialog), Copy and (optionally) a custom Save button
- this._close = {
- 'text': stringResources.get('close'),
- 'handler': this.cancel,
- 'type': options.updateable ? 'secondary' : 'primary'
- };
- this._buttons = [this._close];
- if (options.updateable) {
- this._buttons.push({
- 'text': stringResources.get('dlg_update'),
- 'handler': this.save,
- 'type': 'primary'
- });
- }
- this._buttons.push({
- 'text': stringResources.get('copyButton'),
- 'handler': this.copy,
- 'type': options.updateable ? 'secondary' : 'primary'
- });
- Dialog.inherited('init', this, arguments);
- },
- save: function save() {
- if (this._props.actionHandler && this._props.actionHandler(this.$textarea.val())) {
- this.hide();
- }
- },
- copy: function copy() {
- document.execCommand('copy');
- },
- focusOnButton: function focusOnButton() {
- var secondBtn = this._container().find('footer').children('.dialogButton')[1];
- if (secondBtn) {
- secondBtn.focus();
- }
- },
- show: function show() {
- Dialog.inherited('show', this, arguments);
- this.$textarea[0].select();
- },
- renderContent: function renderContent(n) {
- this.$textarea = $('<textarea>', {
- 'class': 'dashboardMessageBox ' + this._props.type,
- 'html': _.escape(this._props.value)
- });
- n.append(this.$textarea);
- return n;
- },
- renderTitle: function renderTitle(n) {
- n.text(this._props.title);
- return n;
- }
- });
- return Dialog;
- });
- //# sourceMappingURL=EditableDialog.js.map
|