[ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
1 /*+*********************************************************************************** 2 * The contents of this file are subject to the vtiger CRM Public License Version 1.0 3 * ("License"); You may not use this file except in compliance with the License 4 * The Original Code is: vtiger CRM Open Source 5 * The Initial Developer of the Original Code is vtiger. 6 * Portions created by vtiger are Copyright (C) vtiger. 7 * All Rights Reserved. 8 *************************************************************************************/ 9 10 jQuery.Class("Settings_Vtiger_Announcements_Js",{},{ 11 12 //Contains Announcement container 13 container : false, 14 15 //return the container of Announcements 16 getContainer : function() { 17 if(this.container == false){ 18 this.container = jQuery('#AnnouncementContainer').find('.contents'); 19 } 20 return this.container; 21 }, 22 23 /* 24 * Function to save the Announcement content 25 */ 26 saveAnnouncement : function(textAreaElement) { 27 var aDeferred = jQuery.Deferred(); 28 29 var content = textAreaElement.val(); 30 var params = { 31 'module' : app.getModuleName(), 32 'parent' : app.getParentModuleName(), 33 'action' : 'AnnouncementSaveAjax', 34 'announcement' : content 35 } 36 37 AppConnector.request(params).then( 38 function(data) { 39 aDeferred.resolve(); 40 }, 41 function(error,err){ 42 aDeferred.reject(); 43 } 44 ); 45 return aDeferred.promise(); 46 }, 47 48 /* 49 * Function to register keyUp event for text area to show save button 50 */ 51 registerKeyUpEvent : function() { 52 var container = this.getContainer(); 53 container.one('keyup', '.announcementContent', function(e) { 54 jQuery('.saveAnnouncement', container).removeClass('hide'); 55 }); 56 }, 57 58 registerEvents: function() { 59 var thisInstance = this; 60 var container = thisInstance.getContainer(); 61 var textAreaElement = jQuery('.announcementContent', container); 62 var saveButton = jQuery('.saveAnnouncement', container); 63 64 //register text area fields to autosize 65 app.registerEventForTextAreaFields(textAreaElement); 66 thisInstance.registerKeyUpEvent(); 67 68 //Register click event for save button 69 saveButton.click(function(e) { 70 saveButton.addClass('hide'); 71 var progressIndicatorElement = jQuery.progressIndicator({ 72 'position' : 'html', 73 'blockInfo' : { 74 'enabled' : true 75 } 76 }); 77 78 //save the new Announcement 79 thisInstance.saveAnnouncement(textAreaElement).then( 80 function(data) { 81 progressIndicatorElement.progressIndicator({'mode' : 'hide'}); 82 thisInstance.registerKeyUpEvent(); 83 var params = { 84 text: app.vtranslate('JS_ANNOUNCEMENT_SAVED') 85 }; 86 Settings_Vtiger_Index_Js.showMessage(params); 87 }, 88 function(error){ 89 //TODO: Handle Error 90 } 91 ); 92 }) 93 } 94 95 }); 96 97 jQuery(document).ready(function(e){ 98 var instance = new Settings_Vtiger_Announcements_Js(); 99 instance.registerEvents(); 100 })
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:08:37 2014 | Cross-referenced by PHPXref 0.7.1 |