[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/layouts/vlayout/modules/Settings/Vtiger/resources/ -> Index.js (source)

   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_Index_Js",{
  11  
  12      showMessage : function(customParams){
  13          var params = {};
  14          params.animation = "show";
  15          params.type = 'info';
  16          params.title = app.vtranslate('JS_MESSAGE');
  17  
  18          if(typeof customParams != 'undefined') {
  19              var params = jQuery.extend(params,customParams);
  20          }
  21          Vtiger_Helper_Js.showPnotify(params);
  22      }
  23  },{
  24  
  25      registerDeleteShortCutEvent : function(shortCutBlock) {
  26          var thisInstance = this;
  27          if(typeof shortCutBlock == 'undefined') {
  28              var shortCutBlock = jQuery('div#settingsShortCutsContainer')
  29          }
  30          shortCutBlock.on('click','.unpin',function(e) {
  31              var actionEle = jQuery(e.currentTarget);
  32              var closestBlock = actionEle.closest('.moduleBlock');
  33              var fieldId = actionEle.data('id');
  34              var shortcutBlockActionUrl = closestBlock.data('actionurl');
  35              var actionUrl = shortcutBlockActionUrl+'&pin=false';
  36              var progressIndicatorElement = jQuery.progressIndicator({
  37                  'blockInfo' : {
  38                  'enabled' : true
  39                  }
  40              });
  41              AppConnector.request(actionUrl).then(function(data) {
  42                  if(data.result.SUCCESS == 'OK') {
  43                      closestBlock.remove();
  44                      thisInstance.registerSettingShortCutAlignmentEvent();
  45                      var menuItemId = '#'+fieldId+'_menuItem';
  46                      var shortCutActionEle = jQuery(menuItemId);
  47                      var imagePath = shortCutActionEle.data('pinimageurl');
  48                      shortCutActionEle.attr('src',imagePath).data('action','pin');
  49                      progressIndicatorElement.progressIndicator({
  50                          'mode' : 'hide'
  51                      });
  52                      var params = {
  53                          title : app.vtranslate('JS_MESSAGE'),
  54                          text: app.vtranslate('JS_SUCCESSFULLY_UNPINNED'),
  55                          animation: 'show',
  56                          type: 'info'
  57                      };
  58                                          thisInstance.registerReAlign();
  59                      Vtiger_Helper_Js.showPnotify(params);
  60                  }
  61              });
  62              e.stopPropagation();
  63          });
  64      },
  65  
  66      registerPinUnpinShortCutEvent : function() {
  67          var thisInstance = this;
  68          var widgets = jQuery('div.widgetContainer');
  69          widgets.on('click','.pinUnpinShortCut',function(e){
  70              var shortCutActionEle = jQuery(e.currentTarget);
  71              var url = shortCutActionEle.closest('.menuItem').data('actionurl');
  72              var shortCutElementActionStatus = shortCutActionEle.data('action');
  73              if(shortCutElementActionStatus == 'pin'){
  74                  var actionUrl = url+'&pin=true';
  75              } else {
  76                  actionUrl = url+'&pin=false';
  77              }
  78              var progressIndicatorElement = jQuery.progressIndicator({
  79                  'blockInfo' : {
  80                  'enabled' : true
  81                  }
  82              });
  83              AppConnector.request(actionUrl).then(function(data) {
  84                  if(data.result.SUCCESS == 'OK') {
  85                      if(shortCutElementActionStatus == 'pin'){
  86                          var imagePath = shortCutActionEle.data('unpinimageurl');
  87                          var unpinTitle = shortCutActionEle.data('unpintitle');
  88                          shortCutActionEle.attr('src',imagePath).data('action','unpin').attr('title',unpinTitle);
  89                          var params = {
  90                              'fieldid' : shortCutActionEle.data('id'),
  91                              'mode'  : 'getSettingsShortCutBlock',
  92                              'module'  : 'Vtiger',
  93                              'parent' : 'Settings',
  94                              'view' : 'IndexAjax'
  95                          }
  96                          AppConnector.request(params).then(function(data){
  97  //                            var shortCutsMainContainer = jQuery('#settingsShortCutsContainer');
  98                                                          var shortCutsMainContainer = jQuery('#settingsShortCutsContainer');
  99                                                          var existingDivBlock=jQuery('#settingsShortCutsContainer div.row-fluid:last');
 100                                                          var count=jQuery('#settingsShortCutsContainer div.row-fluid:last').children("span").length;
 101                                                          if(count==3){
 102                                                             
 103                                                              var newBlock =jQuery('#settingsShortCutsContainer').append('<div class="row-fluid">'+data);
 104                                                          }
 105                                                          else{
 106                                                              var newBlock = jQuery(data).appendTo(existingDivBlock);
 107                                                          }
 108  
 109  //                            var newBlock = jQuery(data).appendTo(shortCutsMainContainer);
 110                              thisInstance.registerSettingShortCutAlignmentEvent();
 111                              progressIndicatorElement.progressIndicator({
 112                                  'mode' : 'hide'
 113                              });
 114                              var params = {
 115                                  text: app.vtranslate('JS_SUCCESSFULLY_PINNED')
 116                              };
 117                              Settings_Vtiger_Index_Js.showMessage(params);
 118                          });
 119                      } else {
 120                          var imagePath = shortCutActionEle.data('pinimageurl');
 121                          var pinTitle = shortCutActionEle.data('pintitle');
 122                          shortCutActionEle.attr('src',imagePath).data('action','pin').attr('title',pinTitle);
 123                          jQuery('#shortcut_'+shortCutActionEle.data('id')).remove();
 124                          thisInstance.registerSettingShortCutAlignmentEvent();
 125                          progressIndicatorElement.progressIndicator({
 126                              'mode' : 'hide'
 127                          });
 128                          var params = {
 129                              title : app.vtranslate('JS_MESSAGE'),
 130                              text: app.vtranslate('JS_SUCCESSFULLY_UNPINNED'),
 131                              animation: 'show',
 132                              type: 'info'
 133                          };
 134                                                  thisInstance.registerReAlign();
 135                          Vtiger_Helper_Js.showPnotify(params);
 136                      }
 137                  }
 138              });
 139          });
 140      },
 141  
 142      registerSettingsShortcutClickEvent : function() {
 143          jQuery('#settingsShortCutsContainer').on('click','.moduleBlock',function(e){
 144              var url = jQuery(e.currentTarget).data('url');
 145              window.location.href = url;
 146          });
 147      },
 148  
 149      registerSettingShortCutAlignmentEvent : function() {
 150          jQuery('#settingsShortCutsContainer').find('.moduleBlock').removeClass('marginLeftZero');
 151          jQuery('#settingsShortCutsContainer').find('.moduleBlock:nth-child(3n+1)').addClass('marginLeftZero');
 152      },
 153  
 154      registerWidgetsEvents : function() {
 155          var widgets = jQuery('div.widgetContainer');
 156          widgets.on({
 157              shown: function(e) {
 158                  var widgetContainer = jQuery(e.currentTarget);
 159                  var quickWidgetHeader = widgetContainer.closest('.quickWidget').find('.quickWidgetHeader');
 160                  var imageEle = quickWidgetHeader.find('.imageElement')
 161                  var imagePath = imageEle.data('downimage');
 162                  imageEle.attr('src',imagePath);
 163              },
 164              hidden: function(e) {
 165                  var widgetContainer = jQuery(e.currentTarget);
 166                  var quickWidgetHeader = widgetContainer.closest('.quickWidget').find('.quickWidgetHeader');
 167                  var imageEle = quickWidgetHeader.find('.imageElement')
 168                  var imagePath = imageEle.data('rightimage');
 169                  imageEle.attr('src',imagePath);
 170              }
 171          });
 172      },
 173  
 174      registerAddShortcutDragDropEvent : function() {
 175          var thisInstance = this;
 176  
 177          jQuery( ".menuItemLabel" ).draggable({
 178              appendTo: "body",
 179              helper: "clone"
 180          });
 181          jQuery( "#settingsShortCutsContainer" ).droppable({
 182              activeClass: "ui-state-default",
 183              hoverClass: "ui-state-hover",
 184              accept: ".menuItemLabel",
 185              drop: function( event, ui ) {
 186                  var actionElement = ui.draggable.closest('.menuItem').find('.pinUnpinShortCut');
 187                  var pinStatus = actionElement.data('action');
 188                  if(pinStatus == 'unpin') {
 189                      var params = {
 190                          title : app.vtranslate('JS_MESSAGE'),
 191                          text: app.vtranslate('JS_SHORTCUT_ALREADY_ADDED'),
 192                          animation: 'show',
 193                          type: 'info'
 194                      };
 195                      Vtiger_Helper_Js.showPnotify(params);
 196                  } else {
 197                      ui.draggable.closest('.menuItem').find('.pinUnpinShortCut').trigger('click');
 198                      thisInstance.registerSettingShortCutAlignmentEvent();
 199                  }
 200              }
 201          });
 202      },
 203          
 204          registerReAlign : function()
 205          {
 206            
 207              var params = {
 208                              'mode'  : 'realignSettingsShortCutBlock',
 209                              'module'  : 'Vtiger',
 210                              'parent' : 'Settings',
 211                              'view' : 'IndexAjax'
 212                          }
 213  
 214                          AppConnector.request(params).then(function(data){
 215                                                      jQuery('#settingsShortCutsContainer').html(data);
 216                                                  
 217                                                  });
 218          },
 219  
 220      registerEvents: function() {
 221          this.registerSettingsShortcutClickEvent();
 222          this.registerDeleteShortCutEvent();
 223          this.registerWidgetsEvents();
 224          this.registerPinUnpinShortCutEvent();
 225          this.registerAddShortcutDragDropEvent();
 226          this.registerSettingShortCutAlignmentEvent();
 227      }
 228  
 229  });


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1