- Timestamp:
- 06/08/12 12:28:27 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/prototype/modules/filters/filters.js
r6443 r6452 1 1 /* Verifica se a regra fora de escritório está ativa */ 2 function outOfficeVerify() { 2 function outOfficeVerify() { 3 3 DataLayer.remove('filter', false); 4 4 var filters = DataLayer.get("filter"); … … 9 9 outoffice = true; 10 10 if(filters[index].id == "vacation" && filters[index].enabled == "true"){ 11 write_msg(get_lang("Attention, you are in out of office mode."), true); 11 write_msg(get_lang("Attention, you are in out of office mode."), true); 12 12 outoffice_active = true; 13 13 break; … … 52 52 error = true; 53 53 return; 54 } 54 } 55 55 }); 56 56 if(error){ … … 62 62 var criteria_list = list_container.find('[name="criteriaValue[]"]'); 63 63 var er_num = /^[0-9]+$/; 64 64 65 65 if($(".sizeRule").val() != "" && er_num.test($(".sizeRule").val()) == false) { 66 66 $.Zebra_Dialog(get_lang("Size rule must be a number"),{ … … 131 131 date2Time = function (timestamp) { 132 132 var date = new Date(); 133 if( typeof timestamp === "string" ) 134 timestamp = parseInt( timestamp, 10 ); 133 135 if ((date.getTime() - timestamp) < (24*60*60*1000)) { 134 136 return '<span class="timable" title="'+timestamp+'"> </span>'; … … 142 144 143 145 keys = function( object ){ 144 146 145 147 var array = []; 146 148 147 149 for( var key in object ) 148 150 array[ array.length ] = key; 149 151 150 152 return( array ); 151 153 … … 154 156 /* Mostra os detalhes do filtro para edição */ 155 157 showDetails = function( filter ){ 156 158 157 159 form.get(0).reset(); 158 160 … … 174 176 if(filter.actions[i].type == "redirect") 175 177 actions.siblings('[name="addressRedirect"]').val(filter.actions[i].parameter); 176 if(filter.actions[i].type == "reject") 178 if(filter.actions[i].type == "reject") 177 179 actions.siblings('[name="messageReject"]').val(filter.actions[i].parameter); 178 180 if(filter.actions[i].type == "fileinto" || filter.actions[i].type == "setflag") 179 181 actions.parent().find('[value="'+filter.actions[i].parameter+'"]').attr("selected", "selected"); 180 182 } 181 isExact.filter('[value="'+(filter.isExact != "false"? "and" : "or")+'"]').attr("checked", "True"); 183 isExact.filter('[value="'+(filter.isExact != "false"? "and" : "or")+'"]').attr("checked", "True"); 182 184 } 183 185 184 186 185 187 DataLayer.codec( "filter", "detail", { 186 188 187 189 decoder: function( form ){ 188 190 if( form.vacation ) … … 198 200 199 201 var apply_messages_ = keys(selectedMessages); 200 202 201 203 action = ''; 202 204 203 205 return { 204 206 name: form.name ? form.name.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>') : nameObj.val().replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'), 205 207 isExact: ( form.isExact === "and" ), 206 criteria: $.map( form.criteriaOperator || [], function( criteriaOperator, i ){ 208 criteria: $.map( form.criteriaOperator || [], function( criteriaOperator, i ){ 207 209 return (!form.criteriaValue[i]) ? null: 208 { 210 { 209 211 value: form.criteriaValue[i].replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'), 210 212 operator: criteriaOperator, … … 214 216 actions: $.map( form.actionType || [], function( type, i ){ 215 217 var the_parameter = form.actionParameter[i]; 216 218 217 219 !the_parameter ? the_parameter = form.actionParameter[i+1] : ""; 218 if (type == 'fileinto') { 220 if (type == 'fileinto') { 219 221 the_parameter = form.valueFileInto; 220 222 } … … 222 224 the_parameter = form.messageReject; 223 225 } 224 if (type == 'fileintoInbox') { 226 if (type == 'fileintoInbox') { 225 227 if(!$('[value="fileintoInbox"]').parent().hasClass("hidden")){ 226 228 type = 'fileinto'; … … 237 239 the_parameter = form.addressRedirect; 238 240 } 239 if (type == 'setflag') { 241 if (type == 'setflag') { 240 242 the_parameter = form.valueSetFlag; 241 243 action = form.valueSetFlag; … … 246 248 }), 247 249 enabled : true, 248 applyMessages: apply_messages_ 250 applyMessages: apply_messages_ 249 251 }; 250 252 }, 251 253 252 254 encoder: function( filters ){ 253 255 var rules = []; … … 259 261 260 262 } 261 263 262 264 }); 263 265 264 266 /* Codec do datalayer */ 265 267 DataLayer.codec( "folder", "select", { 266 268 267 269 decoder:function(){ 268 270 269 271 }, 270 272 encoder:function( data ){ 271 273 272 274 var tree1 = [], tree2 = [], tree3 = []; 273 275 … … 294 296 295 297 } 296 298 297 299 return {folders: [ tree1, tree2, tree3 ]}; 298 300 … … 310 312 311 313 /* Bloqueio de usuários na tela de mensagem do ExpressoMail */ 312 function block_user_email(email) { 314 function block_user_email(email) { 313 315 delete selectedMessages; 314 316 var idd = urlencode(email); … … 330 332 } 331 333 if(confirm(get_lang("Want to block the user") + " " + email + "?")){ 332 DataLayer.put( 'filter', idd, 333 { name: email, isExact: false, 334 DataLayer.put( 'filter', idd, 335 { name: email, isExact: false, 334 336 criteria:{ 0: {value: email, operator: "=", field: "from"} }, 335 actions: { 0: {parameter: "INBOX" + cyrus_delimiter + "Spam", type: "fileinto"}}, 336 enabled: true, 337 actions: { 0: {parameter: "INBOX" + cyrus_delimiter + "Spam", type: "fileinto"}}, 338 enabled: true, 337 339 id: email, 338 block: true 340 block: true 339 341 }); 340 342 DataLayer.commit("filter", false, function(){ … … 342 344 list_filters(); 343 345 }); 344 346 345 347 } 346 348 } … … 348 350 349 351 DataLayer.codec( 'message', 'jqGrid', { 350 352 351 353 encoder: function( data ){ 352 354 … … 378 380 for (i in criteria_) 379 381 if(criteria_[i] != "") 380 criterias_.push( criterias_.length ? {"0": "OR", "1": options[i], "2": criteria_value_[i], "3": criteria_[i]} : {"0": options[i], "1": criteria_value_[i], "2": criteria_[i]} ); 382 criterias_.push( criterias_.length ? {"0": "OR", "1": options[i], "2": criteria_value_[i], "3": criteria_[i]} : {"0": options[i], "1": criteria_value_[i], "2": criteria_[i]} ); 381 383 382 384 showGridButton = thiss.parent(); 383 385 384 showGridButton.siblings("#filtergrid-container").block({ 385 message: '<div id="loading-content"><div class="image"></div></div>', 386 css: { 387 backgroundImage: 'url('+BASE_PATH+'modules/attach_message/images/loading.gif)', 388 backgroundRepeat: 'no-repeat', 389 backgroundPosition: 'center', 390 backgroundColor: 'transparent', 391 width: '32px', 392 height: '32px', 393 border:'none' 394 }, 395 overlayCSS: { 396 backgroundColor: '#CCC', 397 opacity: 0.5 398 } 386 showGridButton.siblings("#filtergrid-container").block({ 387 message: '<div id="loading-content"><div class="image"></div></div>', 388 css: { 389 backgroundImage: 'url('+BASE_PATH+'modules/attach_message/images/loading.gif)', 390 backgroundRepeat: 'no-repeat', 391 backgroundPosition: 'center', 392 backgroundColor: 'transparent', 393 width: '32px', 394 height: '32px', 395 border:'none' 396 }, 397 overlayCSS: { 398 backgroundColor: '#CCC', 399 opacity: 0.5 400 } 399 401 }); 400 402 401 403 var data = DataLayer.get( 'message', { filter: criterias_, criteria: { properties: { context: { folder: 'INBOX' } } } }, true ); 402 404 403 405 DataLayer.register( 'criterias', 'message:jqGrid', function( crit ){ 404 406 405 407 crit.properties = { context: { folder: 'INBOX' } }; 406 408 407 409 return { filter: [ "msgNumber", "IN", data ], criteria: crit }; 408 410 }); 409 411 410 412 allMessages = data; 411 412 if (typeof grid !== "undefined") { 413 grid.jqGrid( 'setGridParam', { url: 'message:jqGrid', postData: data } ).trigger( 'reloadGrid' ); 413 414 if (typeof grid !== "undefined") { 415 grid.jqGrid( 'setGridParam', { url: 'message:jqGrid', postData: data } ).trigger( 'reloadGrid' ); 414 416 //return; 415 417 } … … 452 454 // jQuery('.timable').each(function (i) { 453 455 // jQuery(this).countdown({ 454 // since: new Date(parseInt(this.title)), 456 // since: new Date(parseInt(this.title)), 455 457 // significant: 1, 456 // layout: 'há {d<}{dn} {dl} {d>}{h<}{hn} {hl} {h>}{m<}{mn} {ml} {m>}{s<}{sn} {sl}{s>}', 458 // layout: 'há {d<}{dn} {dl} {d>}{h<}{hn} {hl} {h>}{m<}{mn} {ml} {m>}{s<}{sn} {sl}{s>}', 457 459 // description: ' atrás' 458 460 // }); … … 460 462 }, 461 463 onSelectRow: function (id, selected) { 462 if( selected ) 464 if( selected ) 463 465 { 464 466 selectedMessages[ id ] = true; … … 469 471 } 470 472 }, 471 onSelectAll: function (id, selected) { 473 onSelectAll: function (id, selected) { 472 474 for (i in id) { 473 475 if(selected) 474 476 selectedMessages[id[i]] = true; 475 477 else 476 delete selectedMessages[id[i]]; 478 delete selectedMessages[id[i]]; 477 479 } 478 480 }, … … 500 502 event.stopPropagation(); 501 503 if(list_container.find(".cancel").length) 502 list_container.find(".cancel").trigger('click'); 504 list_container.find(".cancel").trigger('click'); 503 505 $(".dialog-head-buttonpane").hide(); 504 506 }, … … 523 525 $(".dialog-head-buttonpane").css("padding", "5px"). 524 526 find(".header-buttonpane").html("<a href='#' class='button add' title='"+get_lang("Add new rule")+"'>"+get_lang("New rule")+"</a>"+(!outoffice ? "<a href='#' class='button add vacation' title='"+get_lang("Add rule out of office")+"'>"+get_lang("Out of office")+"</a>" : "")).find(".button").button(); 525 527 526 528 $(".ui-dialog-buttonpane.ui-widget-content").css("background-color", "#E0EEEE"); 527 529 var list = DataLayer.render( BASE_PATH + 'modules/filters/filter-list.ejs', DataLayer.get("filter:detail", true)); 528 530 list_container.html(list).find(".button").button(); 529 531 530 532 list_container.find(".rule-list").selectable({ 531 533 selecting: function(event, ui) { … … 536 538 } 537 539 }); 538 540 539 541 list_container.find( ".menu-control .button" ).filter(".update").button({ 540 542 icons: { … … 549 551 filters = filters[i]; 550 552 break; 551 } 553 } 552 554 } 553 555 DataLayer.render( BASE_PATH + 'modules/filters/edit-filter.ejs', {folders : DataLayer.get("folder", true), delimiter: cyrus_delimiter},function(html){ … … 578 580 else 579 581 return; 580 DataLayer.commit( 'filter', false,function(){ 581 if($('#gbox_fields-search-messages-grid').length > 0 && action != '') { 582 DataLayer.commit( 'filter', false,function(){ 583 if($('#gbox_fields-search-messages-grid').length > 0 && action != '') { 582 584 for (var index in selectedMessages) { 583 585 set_message_flag(index, action, false); … … 586 588 DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); 587 589 }); 588 }).end().filter('.button.search').click(function() { 590 }).end().filter('.button.search').click(function() { 589 591 /* Valida se o usuário preencheu as informações */ 590 592 if(valid_save()) … … 614 616 text: false 615 617 }).click(function(){ 616 var id = $(this).parents("li.rule").find('.id').val(); 618 var id = $(this).parents("li.rule").find('.id').val(); 617 619 DataLayer.put( 'filter', id, { enabled: false }); 618 620 DataLayer.commit("filter", false,function(){ … … 633 635 }); 634 636 }).end() 635 637 636 638 .filter(".close").button({ 637 639 icons: { … … 661 663 }); 662 664 }).end().removeClass("ui-button-icon-only"); 663 665 664 666 $(".button.allenable").click(function(){ 665 667 container.find('.rule-list').find('.rule').find('.select').find(':checked').parents('.rule').find('.title').each(function(i,o){ … … 670 672 }); 671 673 }); 672 674 673 675 $(".button.alldisable").click(function(){ 674 676 container.find('.rule-list').find('.rule').find('.select').find(':checked').parents('.rule').find('.title').each(function(i,o){ … … 679 681 }); 680 682 }); 681 683 682 684 $(".button.alldelete").click(function(){ 683 685 $.Zebra_Dialog(get_lang("Are you sure to delete the filters?"),{ … … 690 692 DataLayer.remove('filter', false); 691 693 DataLayer.get('filter'); 692 container.find('.rule-list').find('.rule').find('.select').find(':checked').parents('.rule').find('.title').each(function(i,o){ 694 container.find('.rule-list').find('.rule').find('.select').find(':checked').parents('.rule').find('.title').each(function(i,o){ 693 695 DataLayer.remove( 'filter', urlencode(o.innerHTML) ); 694 696 }); … … 702 704 }); 703 705 }); 704 706 705 707 var aa = 0; 706 708 707 709 list_container.parent().find(".button.add:first").click(function(){ 708 710 list_container.parent().find(".dialog-head-buttonpane").addClass("hidden"); … … 726 728 return; 727 729 DataLayer.commit( 'filter',false,function(){ 728 if($('#gbox_fields-search-messages-grid').length > 0 && action != '') { 730 if($('#gbox_fields-search-messages-grid').length > 0 && action != '') { 729 731 for (var index in selectedMessages) { 730 732 set_message_flag(index, action, false); … … 733 735 DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); 734 736 }); 735 }).end().filter('.button.search').click(function() { 737 }).end().filter('.button.search').click(function() { 736 738 if(valid_save()) 737 739 showGridMessages($(this)); … … 742 744 }); 743 745 list_container.parent().find(".button.add.vacation").click(function(){ 744 746 745 747 list_container.parent().find(".dialog-head-buttonpane").addClass("hidden"); 746 748 DataLayer.render( BASE_PATH + 'modules/filters/edit-filter.ejs', {folders : DataLayer.get("folder", true), delimiter: cyrus_delimiter},function(html){ … … 750 752 list_container.find(".button").button().filter(".back").click(function(){ 751 753 DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); 752 }).end().filter(".submit").click(function(){ 754 }).end().filter(".submit").click(function(){ 753 755 if(list_container.find(".vacation-details-container .filter-textarea").val().length <= 0){ 754 756 $.Zebra_Dialog(get_lang('Write a message')); … … 761 763 } 762 764 }); 763 }); 765 }); 764 766 }); 765 767 }
Note: See TracChangeset
for help on using the changeset viewer.