function updateCacheFollowupflag(msgNumber, msgFolder, op){ if(op){ if(typeof msgNumber == 'object'){ var extend = DataLayer.get('followupflagged', { filter: ['AND', ['IN', 'messageNumber', msgNumber], ['IN', 'folderName', msgFolder]], criteria: {deepness: 1} }, true); } else{ var extend = DataLayer.get('followupflagged', { filter: ['AND', ['=', 'messageNumber', msgNumber], ['=', 'folderName', msgFolder]], criteria: {deepness: 1} }, true); } if(extend != "" || extend != 'undefined' || extend != []){ for(var i = 0; i < extend.length; i++){ if(onceOpenedHeadersMessages[extend[i].folderName]){ if(onceOpenedHeadersMessages[extend[i].folderName][extend[i].messageNumber]){ onceOpenedHeadersMessages[extend[i].folderName][extend[i].messageNumber]['followupflagged'] = {}; DataLayer.merge(onceOpenedHeadersMessages[extend[i].folderName][extend[i].messageNumber]['followupflagged'], extend[i]); } } } } }else{ onceOpenedHeadersMessages[msgFolder][msgNumber]['followupflagged'] = undefined; } } function init_followup(data){ winElement = data.window; selectedMessageIds = data.selectedMessages; folder = current_folder; /** * Implementação do widget de input-combobox */ (function( $ ) { $.widget( "ui.combobox", { _create: function() { var self = this, select = this.element.hide(), selected = select.children( ":selected" ), value = selected.val() ? selected.text() : ""; var input = this.input = $( "" ) .insertAfter( select ) .val( value ) .autocomplete({ delay: 0, minLength: 0, source: function( request, response ) { var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" ); response( select.children( "option" ).map(function() { var text = $( this ).text(); if ( this.value && ( !request.term || matcher.test(text) ) ) return { label: text.replace( new RegExp( "(?![^&;]+;)(?!<[^<>]*)(" + $.ui.autocomplete.escapeRegex(request.term) + ")(?![^<>]*>)(?![^&;]+;)", "gi" ), "$1" ), value: text, option: this }; }) ); }, select: function( event, ui ) { ui.item.option.selected = true; self._trigger( "selected", event, { item: ui.item.option }); }, change: function( event, ui ) { if ( !ui.item ) { var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ), valid = false; select.children( "option" ).each(function() { if ( $( this ).text().match( matcher ) ) { this.selected = valid = true; return false; } }); /* if ( !valid ) { // remove invalid value, as it didn't match anything $( this ).val( "" ); select.val( "" ); input.data( "autocomplete" ).term = ""; return false; } */ if ( !valid ) { if(select.has('option[value="custom"]').length > 0) { select.find('option:last').val('custom').html($(this).val()).attr('selected', 'selected'); } else { select.append(select.find('option:last').clone().val('custom').html($(this).val())); select.find('option[value="custom"]').attr('selected', 'selected'); } } } } }) .addClass( "ui-widget ui-widget-content ui-corner-left" ); input.data( "autocomplete" )._renderItem = function( ul, item ) { return $( "
  • " ) .data( "item.autocomplete", item ) .append( "" + item.label + "" ) .appendTo( ul ); }; this.button = $( "" ) .attr( "tabIndex", -1 ) .attr( "title", "Show All Items" ) .insertAfter( input ) .button({ icons: { primary: "ui-icon-triangle-1-s" }, text: false }) .removeClass( "ui-corner-all" ) .addClass( "ui-corner-right ui-button-icon" ) .click(function() { // close if already visible if ( input.autocomplete( "widget" ).is( ":visible" ) ) { input.autocomplete( "close" ); return; } // work around a bug (likely same cause as #5265) $( this ).blur(); // pass empty string as value to search for, displaying all results input.autocomplete( "search", "" ); input.focus(); }); }, destroy: function() { this.input.remove(); this.button.remove(); this.element.show(); $.Widget.prototype.destroy.call( this ); } }); })( jQuery ); /** * #END: Implementação do widget de input-combobox */ winElement.find('.button').button() .filter('.menu-configure-followupflag .cancel').click(function(){ winElement.dialog("close"); }).end() .filter('.menu-configure-followupflag .save').click(function(){ var saveFollowupflagged = function(){ var idFollowupflagged = winElement.find('[name="followupflagId"]').val(); idFollowupflagged = idFollowupflagged.split(','); for(x=0; x").find("span").click(function(event){ var id = $('.followupflag-configure').find('option')[$(this).parents('li').index()].value; var nameFollowupflag = $('.followupflag-configure').find('option')[$(this).parents('li').index()].text; var removeLi = $(this).parents("li"); $.Zebra_Dialog(get_lang('All messages flagged with the flag type ') + ''+ nameFollowupflag + '' + get_lang(' will be removed. This action cannot be undone. Want to continue?'), { 'type': 'question', 'custom_class': (is_ie ? 'configure-zebra-dialog' : ''), 'title': 'Atenção', 'buttons': ['Sim','Não'], 'overlay_opacity': '0.5', 'onClose': function(caption) { if(caption == 'Sim'){ var listFollowupflag = DataLayer.get('followupflagged', ['=', 'followupflagId', id]); for (var i=0; i < listFollowupflag.length; i++) DataLayer.remove('followupflagged', listFollowupflag[i].id); DataLayer.remove('followupflag',false); DataLayer.get('followupflag'); DataLayer.remove('followupflag', ''+id); DataLayer.commit(false, false, function(data){ $('[title="'+nameFollowupflag+'"]').attr('title', '').find('div').css({backgroundColor:'#CCC'}); $(removeLi).remove(); $('option[value="'+ id +'"]').remove(); $('.ui-autocomplete.ui-menu li:first'); $('.followupflag-configure').find('option:first').attr("selected","selected"); $('.ui-autocomplete-input').val($('.followupflag-configure').find('option:selected').text()); }); event.stopImmediatePropagation(); } } }); if(is_ie) $(".ZebraDialogOverlay").css("z-index","1006"); }); }); winElement.find('.ui-corner-right.ui-button-icon').attr('title', get_lang('Show All Items')); winElement.find('[name="alarmDate"],[name="alarmTime"]').attr("disabled","disabled"); winElement.find('[name="alarm"]').click(function(){ if($(this).is(":checked")){ winElement.find('[name="alarmDate"],[name="alarmTime"]').removeAttr("disabled"); }else{ winElement.find('[name="alarmDate"],[name="alarmTime"]').attr("disabled","disabled"); } }); if(winElement.find('[name="alarm"]').is(":checked")){ winElement.find('[name="alarmDate"],[name="alarmTime"]').removeAttr("disabled"); } winElement.find('[name="done"]').click(function(){ if($(this).is(":checked")){ winElement.find(".input-done input").attr("disabled","disabled"); }else{ winElement.find(".input-done input").removeAttr("disabled"); } }); winElement.find(".followupflag-color-fields").hide(); winElement.find(".followupflag-color.sample-list .sample-item").click(function(){ winElement.find('.menu-configure-followupflag .save').button("enable"); winElement.find(".followupflag-color.sample-list .sample-item").removeClass("selected"); $(this).addClass("selected"); var color = $(this).attr('alt'); winElement.find('[name="backgroundColor"]').css('background-color', color).val(color) }); winElement.find(".followupflag-color.sample-list .sample-item.selected").trigger('click'); winElement.find('[name="setColor"]').change(function(){ if(winElement.find('[name="setColor"]').val() == "default"){ winElement.find(".followupflag-color.sample-list").show("fast"); winElement.find(".followupflag-color-fields").hide(); winElement.find(".followupflag-color.sample-list .sample-item.selected").trigger('click'); } else if(winElement.find('[name="setColor"]').val() == "custom"){ winElement.find(".followupflag-color-fields").show("fast"); winElement.find(".followupflag-color.sample-list").hide(); winElement.find(".colorwell").focus(); } }); if(winElement.find('[name="setColor"] option:selected').val() == "custom"){ winElement.find('[name="setColor"]').trigger("change"); } var colorpickerPreviewChange = function(color) { winElement.find('.menu-configure-followupflag .save').button("enable"); winElement.find('.colorwell-selected').val(color).css('background-color', color); winElement.find('.flag-color-preview').css('background',color); } var f = $.farbtastic(winElement.find('.colorpicker'), colorpickerPreviewChange); var selected; winElement.find('.colorwell').each(function () { f.linkTo(this); }).focus(function() { if (selected) { $(selected).removeClass('colorwell-selected'); } $(selected = this).addClass('colorwell-selected'); f.linkTo(this, colorpickerPreviewChange); f.linkTo(colorpickerPreviewChange); }); if(winElement.find('[name="setColor"] option:selected').val() == "custom"){ winElement.find(".colorwell").focus(); } } /** * constrói as duas possíveis janela de alerta, utilizando o mesmo template */ function alarmFollowupflagged(){ $('.followupflag-alarm').remove(); var toIterate = [ { attrDeadline: 'doneDeadline', caption: {singular:'You have one undone message today:', plural:"You have %1 undone messages today:" }, onOk: function(event){ if($(event.target).parents('.doneDeadline').find('[name="stopAlert"]').is(':checked')){ $.cookie("fadeCompleted", (new Date).toString("dd/MM/yyyy"), { expires: 1 }); } }, enable: ($.cookie("fadeCompleted") != (new Date).toString("dd/MM/yyyy")) }, { attrDeadline: 'alarmDeadline', caption: { singular:'You have a follow up due for today:', plural:'You have %1 follow ups due for today:' }, onOk: function(event){ if($(event.target).parents('.alarmDeadline').find('[name="stopAlert"]').is(':checked')){ $.cookie("fadeAlarm", (new Date).toString("dd/MM/yyyy"), { expires: 1 }); } }, enable: ($.cookie("fadeAlarm") != (new Date).toString("dd/MM/yyyy")) } ]; var i = 0; while (it = toIterate.pop()){ if (!it.enable) continue; 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')], ['<', it.attrDeadline, (new Date()).set({hour:0, minute:0, second:0}).addHours(24).toString('yyyy-MM-dd 00:00:00')]], criteria: {deepness: 1}}); if(alarmInRange.length > 0){ for(var i=0; i 0){ for(var i=0; i