/* * Licensed Materials - Property of IBM * * IBM Cognos Products: SHARE * * (C) Copyright IBM Corp. 2015, 2016 * * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with * IBM Corp. */ define([ 'jquery', 'bi/sharecommon/utils/simpledoT', 'q', 'bi/schedule/views/DeliveryPickerView', 'bi/sharecommon/utils/translator', 'bi/commons/utils/Utils', 'bootstrap' ], function($, dot, Q, DeliveryPickerView, t, Utils) { 'use strict'; /* deliveryOptions look like: * { * "save": { * "notify": false * }, * "email": { * "emailAsAttachment": false, * "emailAsURL": false, * "subject": "blah", * "memoPart": "this is the body", * "to": [], * "cc": [], * "bcc": [] * } * mobile: { * to: [] * } * print: { * printer: "" * } * } */ var __SLIDEOUT_PRESET_WIDTH = '350px'; var scheduleDeliveryPickerView = DeliveryPickerView.extend({ init: function(options) { $.extend(this, options); scheduleDeliveryPickerView.inherited('init', this, arguments); if(options.slideoutparent == undefined) { throw "Error: slideoutparent parameter must be provided."; } this.isVisible = false; this.slideout = null; }, render: function() { // in update mode the permissions are passed if ( this.hasPermission && !this.hasPermission.write && this.hasPermission.read ) { this.$toggler.prop('disabled', true); } this._setEvents(); // Initially update the "delivery" area in the main pane if(this.$activeOptionsContainer) { this.updateActiveDeliveryList(this.$activeOptionsContainer); } }, _setEvents: function() { this.$toggler.on('primaryaction', function(event) { this._showDeliveryOptions(); }.bind(this)); }, _setpanelContent: function() { var allowRecipients = typeof this.allowRecipients === "function" ? this.allowRecipients() : true; var deliveryContent = this.getDeliveryContent(allowRecipients); this.$panelContent = $(deliveryContent); }, _showDeliveryOptions: function(){ this.isVisible = true; this._setpanelContent(); this.slideout = this.glassContext.appController.showSlideOut({ 'parent': this.slideoutparent, 'overlay': this.overlay, 'width': __SLIDEOUT_PRESET_WIDTH, 'enableTabLooping': true, 'label': t.translate('schedule_delivery_picker_name'), 'content': { 'module': 'bi/schedule/views/OptionsSlideoutView', 'content': this.$panelContent, 'title': t.translate("schedule_delivery_label"), 'closeCallback': function() { this._close(); }.bind(this), 'setUpCallback': function(content) { this.setDeliveryOptions(content, this.$activeOptionsContainer); }.bind(this) } }); }, _close: function() { this.isVisible = false; // clear event handler for editor dialogs and remove editor dialogs if($('body').hasClass('editorHideHandlerSet')) { $('body').removeClass('editorHideHandlerSet'); $('body').off( ".ckeditorDialog" ); var editorDialogs = $('body').find('.cke_reset_all'); var editorDialogBg = $('body').find('.cke_dialog_background_cover'); editorDialogs.remove(); editorDialogBg.remove(); } this.close(); } }); return scheduleDeliveryPickerView; });