[ 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 Vtiger_List_Js("Rss_List_Js",{}, 11 { 12 /** 13 * Function get the height of the document 14 * @return <integer> height 15 */ 16 getDocumentHeight : function() { 17 return jQuery(document).height(); 18 }, 19 20 registerRssAddButtonClickEvent : function() { 21 var thisInstance = this; 22 jQuery(document).on('click', '.rssAddButton',function(e) { 23 thisInstance.showRssAddForm(); 24 }) 25 }, 26 27 /** 28 * Function show rssAddForm model 29 */ 30 showRssAddForm : function() { 31 var thisInstance = this; 32 var progressInstance = jQuery.progressIndicator(); 33 thisInstance.getRssAddFormUi().then(function(data) { 34 var resetPasswordUi = jQuery('.rssAddFormContainer').find('#rssAddFormUi'); 35 if(resetPasswordUi.length > 0){ 36 resetPasswordUi = resetPasswordUi.clone(true,true); 37 progressInstance.hide(); 38 var callBackFunction = function(data) { 39 var params = app.validationEngineOptions; 40 var form = data.find('#rssAddForm'); 41 params.onValidationComplete = function(form, valid){ 42 if(valid) { 43 thisInstance.rssFeedSave(form); 44 } 45 return false; 46 } 47 form.validationEngine(params); 48 } 49 var modalWindowParams = { 50 data : resetPasswordUi, 51 cb : callBackFunction 52 } 53 app.showModalWindow(modalWindowParams); 54 } 55 }); 56 }, 57 58 /** 59 * Function to get the rss add form 60 * @param <string> url 61 */ 62 getRssAddFormUi : function(url) { 63 var aDeferred = jQuery.Deferred(); 64 var resetPasswordContainer = jQuery('.rssAddFormContainer'); 65 var resetPasswordUi = resetPasswordContainer.find('#rssAddFormUi'); 66 if(resetPasswordUi.length == 0) { 67 var actionParams = { 68 'module' : app.getModuleName(), 69 'view' : 'ViewTypes', 70 'mode' : 'getRssAddForm' 71 }; 72 AppConnector.request(actionParams).then( 73 function(data){ 74 resetPasswordContainer.html(data); 75 aDeferred.resolve(data); 76 }, 77 function(textStatus, errorThrown){ 78 aDeferred.reject(textStatus, errorThrown); 79 } 80 ); 81 } else { 82 aDeferred.resolve(); 83 } 84 return aDeferred.promise(); 85 }, 86 87 /** 88 * Function to save rss feed 89 * @parm form 90 */ 91 rssFeedSave : function(form) { 92 var thisInstance = this; 93 var data = form.serializeFormData(); 94 var progressIndicatorElement = jQuery.progressIndicator({ 95 'position' : 'html', 96 'blockInfo' : { 97 'enabled' : true 98 } 99 }); 100 var params = { 101 'module': app.getModuleName(), 102 'action' : 'Save', 103 'feedurl' : data.feedurl 104 } 105 AppConnector.request(params).then( 106 function(result) { 107 progressIndicatorElement.progressIndicator({ 108 'mode' : 'hide' 109 }); 110 if(result.result.success){ 111 app.hideModalWindow(); 112 thisInstance.getRssFeeds(result.result.id).then(function() { 113 thisInstance.loadRssWidget().then(function() { 114 var params = { 115 title : app.vtranslate('JS_MESSAGE'), 116 text: app.vtranslate(result.result.message), 117 animation: 'show', 118 type: 'info' 119 }; 120 Vtiger_Helper_Js.showPnotify(params); 121 }); 122 }); 123 } else { 124 var params = { 125 title : app.vtranslate('JS_MESSAGE'), 126 text: app.vtranslate(result.result.message), 127 animation: 'show' 128 }; 129 Vtiger_Helper_Js.showPnotify(params); 130 } 131 } 132 ); 133 }, 134 135 /** 136 * Function to register click on the rss sidebar link 137 */ 138 registerRssUrlClickEvent : function() { 139 var thisInstance = this; 140 jQuery('.quickWidgetContainer').on('click','.rssLink', function(e) { 141 var element = jQuery(e.currentTarget); 142 var id = element.data('id'); 143 thisInstance.getRssFeeds(id); 144 }); 145 }, 146 147 /** 148 * Function to get the feeds for specific id 149 * @param <integer> id 150 */ 151 getRssFeeds : function(id) { 152 var thisInstance = this; 153 var aDeferred = jQuery.Deferred(); 154 var container = thisInstance.getListViewContainer(); 155 var progressIndicatorElement = jQuery.progressIndicator({ 156 'position' : 'html', 157 'blockInfo' : { 158 'enabled' : true 159 } 160 }); 161 var params = { 162 'module' : app.getModuleName(), 163 'view' : 'List', 164 'id' : id 165 } 166 AppConnector.requestPjax(params).then(function(data) { 167 aDeferred.resolve(data); 168 container.find('#listViewContents').html(data); 169 thisInstance.setFeedContainerHeight(container); 170 progressIndicatorElement.progressIndicator({ 171 'mode' : 'hide' 172 }) 173 }); 174 175 return aDeferred.promise(); 176 }, 177 178 /** 179 * Function to get the height of the Feed Container 180 * @param container 181 */ 182 setFeedContainerHeight : function(container) { 183 var height = this.getDocumentHeight()/4; 184 container.find('.feedListContainer').height(height); 185 }, 186 187 /** 188 * Function to register the click of feeds 189 * @param container 190 */ 191 registerFeedClickEvent : function(container) { 192 var thisInstance = this; 193 container.on('click' , '.feedLink', function(e) { 194 var element = jQuery(e.currentTarget); 195 var url = element.data('url'); 196 var frameElement = thisInstance.getFrameElement(url) 197 container.find('.feedFrame').html(frameElement); 198 }); 199 }, 200 201 /** 202 * Function to get the iframe element 203 * @param <string> url 204 * @retrun <element> frameElement 205 */ 206 getFrameElement : function(url) { 207 var progressIndicatorElement = jQuery.progressIndicator({ 208 'position' : 'html', 209 'blockInfo' : { 210 'enabled' : true 211 } 212 }); 213 var frameElement = jQuery('<iframe>', { 214 id: 'feedFrame', 215 scrolling: 'auto', 216 width: '100%', 217 height: this.getDocumentHeight()/2 218 }); 219 frameElement.addClass('table-bordered'); 220 this.getHtml(url).then(function(html) { 221 progressIndicatorElement.progressIndicator({ 222 'mode' : 'hide' 223 }); 224 var frame = frameElement[0].contentDocument; 225 frame.open(); 226 frame.write(html); 227 frame.close(); 228 }); 229 230 return frameElement; 231 }, 232 233 /** 234 * Function to get the html contents from url 235 * @param <string> url 236 * @return <string> html contents 237 */ 238 getHtml : function(url) { 239 var aDeferred = jQuery.Deferred(); 240 var params = { 241 'module' : app.getModuleName(), 242 'action' : 'GetHtml', 243 'url' : url 244 } 245 AppConnector.request(params).then(function(data) { 246 aDeferred.resolve(data.result.html); 247 }); 248 249 return aDeferred.promise(); 250 }, 251 252 /** 253 * Function to register record delete event 254 */ 255 registerDeleteRecordClickEvent: function(){ 256 var container = this.getListViewContainer(); 257 var thisInstance = this; 258 container.on('click','#deleteButton', function(e) { 259 thisInstance.deleteRecord(container); 260 }) 261 }, 262 263 /** 264 * Function to delete the record 265 */ 266 deleteRecord : function(container) { 267 var thisInstance = this; 268 var recordId = container.find('#recordId').val(); 269 var message = app.vtranslate('LBL_DELETE_CONFIRMATION'); 270 Vtiger_Helper_Js.showConfirmationBox({'message' : message}).then( 271 function(e) { 272 var module = app.getModuleName(); 273 var postData = { 274 "module": module, 275 "action": "DeleteAjax", 276 "record": recordId 277 } 278 var deleteMessage = app.vtranslate('JS_RECORD_GETTING_DELETED'); 279 var progressIndicatorElement = jQuery.progressIndicator({ 280 'message' : deleteMessage, 281 'position' : 'html', 282 'blockInfo' : { 283 'enabled' : true 284 } 285 }); 286 AppConnector.request(postData).then( 287 function(data){ 288 progressIndicatorElement.progressIndicator({ 289 'mode' : 'hide' 290 }) 291 if(data.success) { 292 thisInstance.getRssFeeds().then(function() { 293 thisInstance.loadRssWidget(); 294 }); 295 } else { 296 var params = { 297 text : app.vtranslate(data.error.message), 298 title : app.vtranslate('JS_LBL_PERMISSION') 299 } 300 Vtiger_Helper_Js.showPnotify(params); 301 } 302 }, 303 function(error,err){ 304 305 } 306 ); 307 }, 308 function(error, err){ 309 } 310 ); 311 }, 312 313 /** 314 * Function to register make default button click event 315 */ 316 registerMakeDefaultClickEvent : function(container) { 317 var thisInstance = this; 318 container.on('click','#makeDefaultButton',function() { 319 thisInstance.makeDefault(container); 320 }); 321 }, 322 323 /** 324 * Function to make a record as default rss feed 325 */ 326 makeDefault : function(container) { 327 var listInstance = Vtiger_List_Js.getInstance(); 328 var recordId = container.find('#recordId').val(); 329 var module = app.getModuleName(); 330 var postData = { 331 "module": module, 332 "action": "MakeDefaultAjax", 333 "record": recordId 334 } 335 var progressIndicatorElement = jQuery.progressIndicator({ 336 'position' : 'html', 337 'blockInfo' : { 338 'enabled' : true 339 } 340 }); 341 AppConnector.request(postData).then( 342 function(data){ 343 progressIndicatorElement.progressIndicator({ 344 'mode' : 'hide' 345 }) 346 if(data.success) { 347 var params = { 348 title : app.vtranslate('JS_MESSAGE'), 349 text: app.vtranslate(result.result.message), 350 animation: 'show', 351 type: 'info' 352 }; 353 Vtiger_Helper_Js.showPnotify(params); 354 } else { 355 var params = { 356 text : app.vtranslate(data.error.message), 357 title : app.vtranslate('JS_LBL_PERMISSION') 358 } 359 Vtiger_Helper_Js.showPnotify(params); 360 } 361 } 362 ); 363 }, 364 365 loadRssWidget : function () { 366 var aDeferred = jQuery.Deferred(); 367 var widgetContainer = jQuery('.widgetContainer'); 368 var url = widgetContainer.data('url'); 369 AppConnector.request(url).then(function(data) { 370 aDeferred.resolve(data); 371 widgetContainer.html(data); 372 }); 373 return aDeferred.promise(); 374 }, 375 376 registerEvents : function() { 377 this._super(); 378 var container = this.getListViewContainer(); 379 this.registerRssAddButtonClickEvent(); 380 this.registerRssUrlClickEvent(); 381 this.registerFeedClickEvent(container); 382 this.registerMakeDefaultClickEvent(container); 383 this.setFeedContainerHeight(container); 384 } 385 });
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 |