Ignore:
Timestamp:
02/28/12 08:12:32 (12 years ago)
Author:
adriano
Message:

Ticket #2486 - correcoes de diversos bugs e refactory de parte do codigo dos alarms

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/prototype/modules/mail/js/followupflag.js

    r5564 r5571  
    1 //se  caso não existir nenhuma mensagem concluida para o dia atual, ele não mostra a modal. 
    2  if($.cookie("fadeAlarm") != (new Date).toString("dd/MM/yyyy")){ 
    3         var alarmInRange = DataLayer.get('followupflagged', {filter: ['AND', ['>', 'alarmDeadline', (new Date()).set({hour:0, minute:0, second:0}).toString('yyyy-MM-dd 00:00:00')], ['<', 'alarmDeadline', (new Date()).set({hour:0, minute:0, second:0}).addHours(24).toString('yyyy-MM-dd 00:00:00')]], criteria: {deepness: 1}}); 
     1/** 
     2 * constrói as duas possíveis janela de alerta, utilizando o mesmo template 
     3 */ 
     4var toIterate = [ 
     5        { 
     6                attrDeadline: 'doneDeadline',  
     7                caption: {singular:'Você tem uma mensagem concluindo hoje:', plural:"Você tem %1 mensagens concluindo hoje:"}, 
     8                onOk: function(event){ 
     9                        if($(event.target).parents('.followupflag-alarm').find('[name="stopAlert"]').is(':checked')){ 
     10                                $.cookie("fadeCompleted", (new Date).toString("dd/MM/yyyy"), { expires: 1 }); 
     11                        } 
     12                }, 
     13                enable: ($.cookie("fadeCompleted") != (new Date).toString("dd/MM/yyyy")) 
     14        }, 
     15        { 
     16                attrDeadline: 'alarmDeadline',  
     17                caption: {singular:'Você tem uma mensagem sinalizada para hoje:', plural:'Você tem %1 mensagens sinalizadas para hoje:'}, 
     18                onOk: function(event){ 
     19                        if($(event.target).parents('.followupflag-alarm').find('[name="stopAlert"]').is(':checked')){ 
     20                                $.cookie("fadeAlarm", (new Date).toString("dd/MM/yyyy"), { expires: 1 }); 
     21                        } 
     22                }, 
     23                enable: ($.cookie("fadeAlarm") != (new Date).toString("dd/MM/yyyy")) 
     24        } 
     25]; 
     26 
     27while (it = toIterate.pop()){ 
     28        if (!it.enable) continue; 
     29         
     30        var alarmInRange = DataLayer.get('followupflagged', {filter: ['AND', ['>', it.attrDeadline, (new Date()).set({hour:0, minute:0, second:0}).toString('yyyy-MM-dd 00:00:00')], ['<', toIterate.attrDeadline, (new Date()).set({hour:0, minute:0, second:0}).addHours(24).toString('yyyy-MM-dd 00:00:00')]], criteria: {deepness: 1}}); 
    431        if(alarmInRange.length > 0){ 
    532                for(var i=0; i<alarmInRange.length; i++){ 
     
    734                        alarmInRange[i].alarmDeadline = date.toString('hh:mm'); 
    835                } 
    9                 var data = {alarmInRange : alarmInRange}; 
    10                 var valueZebra = DataLayer.render("../prototype/modules/mail/templates/followupflag_alarm_list.ejs", data); 
    11                  
    12                 new $.Zebra_Dialog(valueZebra, { 
    13                 'buttons':  ['Ok'], 
    14                 'modal': false, 
    15                 'position': ['right - 20', 'bottom - 30'], 
    16                 'custom_class': 'zebraClass2', 
    17                 });      
    18                  
    19         $(".ZebraDialog_Body .footerMenos").hide() 
    20  
    21                 $(".ZebraDialog_Body .footerMais").click(function(){ 
    22                         $('.ZebraDialog').css('visibility','hidden'); 
    23                         $(this).parents('.ZebraDialog').css("visibility","visible"); 
    24                         $(this).parents('.ZebraDialog').animate( { top: '-=300px' } , 280) 
    25                         .find("ul.alert-flags").animate( { height: 375 } , 300); 
    26                         $(".ZebraDialog_Body .footerMais").hide(); 
    27                         $(".ZebraDialog_Body .footerMenos").show(); 
     36                var caption = (alarmInRange.length == 1) ? 
     37                        get_lang(it.caption.singular): 
     38                        get_lang(it.caption.plural, alarmInRange.length); 
     39                         
     40                var data = {alarmInRange : alarmInRange, caption: caption}; 
     41                var dialogText = DataLayer.render("../prototype/modules/mail/templates/followupflag_alarm_list.ejs", data); 
     42                 
     43                /** 
     44                 * A última dialog criada é a dialog mais ao alto 
     45                 */ 
     46                var offsetHeight = $('.ZebraDialog.right-bottom:last').length ?  
     47                        $(window).height() - $('.ZebraDialog.right-bottom:last').position().top : 0; 
     48 
     49                /** 
     50                 * Se for a primeira, desloca para cima do rodapé do grid 
     51                 * caso contrário desloca para um pouco acima da última dialog criada 
     52                 */ 
     53                offsetHeight = !offsetHeight ? 35 : offsetHeight + 20 ; 
     54                var dialog = new $.Zebra_Dialog(dialogText, { 
     55                        'buttons':  ['Ok'], 
     56                        'modal': false, 
     57                        'vcenter_short_message': false, 
     58                        'position': ['right - 20', 'bottom - ' + offsetHeight.toString() ], 
     59                        'custom_class': 'right-bottom followupflag-alarm', 
     60                }).dialog; 
     61 
     62                $(".ZebraDialog.followupflag-alarm .ZebraDialog_Button0").click(it.onOk); 
     63                 
     64                $(".ZebraDialog.followupflag-alarm .display-options .more").click(function(event) { 
     65                        $(event.target).parents('.followupflag-alarm').find('.message-list').css('height', 'auto'); 
    2866                }); 
    29                 $(".ZebraDialog_Body .footermenos").click(function(){ 
    30                         $('.ZebraDialog').css('visibility','visible'); 
    31                         $(this).parents('.ZebraDialog').animate( { top: '+=300px' } , 280) 
    32                         .find("ul.alert-flags").animate( { height: 70 } , 300); 
    33                          
    34                         $(this).parents('.ZebraDialog').css({ 
    35                         }); 
    36                         $(".ZebraDialog_Body .footerMenos").hide(); 
    37                         $(".ZebraDialog_Body .footerMais").show(); 
    38                 }); 
    39                  
    40                  
    41                 $("ul.alert-flags li").css({ 
    42                         'width': '270px', 
    43                         'white-space': 'nowrap', 
    44                         'overflow': 'hidden', 
    45                         'text-overflow': 'ellipsis' 
    46                 }); 
    47                  
    48                 $("span.exc-ocul").css({ 
    49                         'float' : 'right', 
    50                         'margin-right' : '0', 
    51                         'color' : '#2363a4', 
    52                         'cursor' : 'pointer' 
    53                 }).parent("ul").css(); 
    54                  
    55                 $(".zebraClass2 .ZebraDialog_Buttons .ZebraDialog_Button0").click(function(){ 
    56                         var countCheckbox2 = $("input:checked").length; 
    57  
    58                         if(countCheckbox2 == 1){ 
    59                                 date2 = (new Date).toString("dd/MM/yyyy"); 
    60                                 $.cookie("fadeAlarm", date2 , { expires: 1 }); 
    61                         } 
    62                 }); 
     67                 
    6368        }                
    6469} 
    6570 
    66 if($.cookie("fadeCompleted") != (new Date).toString("dd/MM/yyyy")){      
    67         var doneInRange = DataLayer.get('followupflagged', {filter: ['AND', ['>', 'doneDeadline', (new Date()).set({hour:0, minute:0, second:0}).toString('yyyy-MM-dd 00:00:00')], ['<', 'doneDeadline', (new Date()).set({hour:0, minute:0, second:0}).addHours(24).toString('yyyy-MM-dd 00:00:00')]], criteria: {deepness: 1}}); 
    68         if(doneInRange.length > 0){ 
    69                 for(var i=0; i<doneInRange.length; i++){ 
    70                         var date = Date.parseExact(doneInRange[i].doneDeadline, 'yyyy-MM-dd hh:mm:ss'); 
    71                         doneInRange[i].doneDeadline = date.toString('hh:mm'); 
    72                 } 
    73                 var data = {doneInRange : doneInRange}; 
    74                 var valueZebra = DataLayer.render("../prototype/modules/mail/templates/followupflag_completed_list.ejs", data); 
    75                  
    76                 //verificando se a primeira "model de alarme" está oculta ou não.. 
    77                 //caso ela esteja caira nesse primeiro if, que coloca a model de "concluidos" no lugar da model de alarme. 
    78                 if($(".zebraClass2").length == 0){ 
    79                         new $.Zebra_Dialog(valueZebra, { 
    80                                 'buttons':  ['Ok'], 
    81                                 'modal': false, 
    82                                 'position': ['right - 20', 'bottom - 30' ], 
    83                                 'custom_class': 'zebraClass', 
    84                                 });               
    85                 }else{ 
    86                         new $.Zebra_Dialog(valueZebra, { 
    87                                 'buttons':  ['Ok'], 
    88                                 'modal': false, 
    89                                 'position': ['right - 20', 'bottom - 275' ], 
    90                                 'custom_class': 'zebraClass', 
    91                                 });      
    92                 } 
    93                  
    94         $(".ZebraDialog_Body .footerMenos2").hide() 
    95  
    96                 $(".ZebraDialog_Body .footerMais2").click(function(){ 
    97                         $('.ZebraDialog').css('visibility','hidden'); 
    98                         $(this).parents('.ZebraDialog').css("visibility","visible"); 
    99                         if($.cookie("fadeAlarm") != (new Date).toString("dd/MM/yyyy")){ 
    100                                 $(this).parents('.ZebraDialog').animate( { top: '-=60px' } , 280) 
    101                                 .find("ul.alert-flags").animate( { height: 360 } , 300); 
    102                         } else { 
    103                                 $(this).parents('.ZebraDialog').animate( { top: '-=300px' } , 280) 
    104                                 .find("ul.alert-flags").animate( { height: 360 } , 300); 
    105                         } 
    106                          
    107                         $(".ZebraDialog_Body .footerMais2").hide(); 
    108                         $(".ZebraDialog_Body .footerMenos2").show(); 
    109                 }); 
    110                 $(".ZebraDialog_Body .footermenos2").click(function(){ 
    111                         $('.ZebraDialog').css('visibility','visible'); 
    112                         if($.cookie("fadeAlarm") != (new Date).toString("dd/MM/yyyy")){ 
    113                                 $(this).parents('.ZebraDialog').animate( { top: '+=60px' } , 280) 
    114                                 .find("ul.alert-flags").animate( { height: 70 } , 300); 
    115                         } else { 
    116                                 $(this).parents('.ZebraDialog').animate( { top: '+=300px' } , 280) 
    117                                 .find("ul.alert-flags").animate( { height: 70 } , 300); 
    118                         } 
    119                         $(this).parents('.ZebraDialog').css({ 
    120                         }); 
    121                         $(".ZebraDialog_Body .footerMenos2").hide(); 
    122                         $(".ZebraDialog_Body .footerMais2").show(); 
    123                 }); 
    124                  
    125                  
    126                 $("ul.alert-flags li").css({ 
    127                         'width': '270px', 
    128                         'white-space': 'nowrap', 
    129                         'overflow': 'hidden', 
    130                         'text-overflow': 'ellipsis' 
    131                 }); 
    132                  
    133                 $("span.exc-ocul").css({ 
    134                         'float' : 'right', 
    135                         'margin-right' : '0', 
    136                         'color' : '#2363a4', 
    137                         'cursor' : 'pointer' 
    138                 }).parent("ul").css(); 
    139                  
    140                 $(".zebraClass .ZebraDialog_Buttons .ZebraDialog_Button0").click(function(){ 
    141                  
    142                         var countCheckbox1 = $("input:checked").length; 
    143  
    144                         if(countCheckbox1 == 1){ 
    145                                 date1 = (new Date).toString("dd/MM/yyyy"); 
    146                                 $.cookie("fadeCompleted", date1 , { expires: 1 }); 
    147                         } 
    148                 }); 
    149         }                
    150 } 
    15171function init_followup(data){ 
    15272 
     
    423343        }); 
    424344         
    425         if(winElement.find("#selectCor option:selected").val() == "custom"){ 
    426                 winElement.find("#selectCor").trigger("change"); 
     345        if(winElement.find('[name="setColor"] option:selected').val() == "custom"){ 
     346                winElement.find('[name="setColor"]').trigger("change"); 
    427347        } 
    428348 
     
    445365                 
    446366        }); 
    447         if(winElement.find("#selectCor option:selected").val() == "custom"){ 
     367        if(winElement.find('[name="setColor"] option:selected').val() == "custom"){ 
    448368                winElement.find(".colorwell").focus(); 
    449369        } 
Note: See TracChangeset for help on using the changeset viewer.