bytes2Size = function(bytes) { var sizes = ['B', 'KB', 'MB', 'GB', 'TB']; if (bytes === 0) return 'n/a'; var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024))); var size = (i<2) ? Math.round((bytes / Math.pow(1024, i))) : Math.round((bytes / Math.pow(1024, i)) * 100)/100; return size + ' ' + sizes[i]; }; flags2Class = function(cellvalue) { var flags_enum = cellvalue.split(','); var classes = ''; for (var i=0; i '; } return classes; }; date2Time = function (timestamp) { var date = new Date(); if ((date.getTime() - timestamp) < (24*60*60*1000)) { return ' '; } else { date = new Date(timestamp); var b = date.toISOString().split("T")[0].split("-"); var c = b[2] + "/" + b[1] + "/" + b[0]; return '' + c + ''; } }; unorphanize = function(root, element) { var ok = false; for (var i=0; i "" }, encoder: function( filters ){ var rules = []; for( var id in filters ) rules[ rules.length ] = filters[id]; return { rules: rules }; } }); DataLayer.codec( "folder", "select", { decoder:function(){ }, encoder:function( data ){ var tree1 = [], tree2 = [], tree3 = []; for (var i=0; iminimize') .find('.ui-dialog-titlebar-minimize').click(function() { $(".ui-dialog-buttonpane, .ui-dialog-content").toggle(); $(".ui-icon-minusthick, .ui-icon-newwin").toggleClass('ui-icon-minusthick').toggleClass('ui-icon-newwin'); }); }, autoOpen: false }); details_container.accordion({autoHeight: false}); DataLayer.render( BASE_PATH + 'api/templates/folderselect.ejs', 'folder:select', function( html ){ details_container.find(".select-folderlist").append( html ); }); container.find(".button").button() .filter(".menu-filters > .button") .click(function(){ container.dialog( 'close' ); }) .filter(".cancel") .click(function(){ DataLayer.rollback( 'filter' ); return( false ); }) .end().filter(".submit") .click(function(){ DataLayer.commit( 'filter' ); return( false ); }); details_container.find( ".menu-container" ) .find(".button.cancel").click(function(event){ details_container.accordion('activate',0); showGridButton.removeClass('hidden'); grid.addClass('hidden').jqGrid('GridDestroy'); list_container.removeClass('hidden'); details_container.addClass('hidden'); return( false ); }).end() .find(".button.submit").click(function(event){ $(this).submit(); details_container.accordion('activate',0); showGridButton.removeClass('hidden'); grid.addClass('hidden').jqGrid('GridDestroy'); list_container.removeClass('hidden'); details_container.addClass('hidden'); return( false ); }).end() .find(".button.back").click(function(event){ details_container.accordion('activate',0); return( false ); }).end() .find(".button.forth").click(function(event){ details_container.accordion('activate',1); return( false ); }).end() //$( ".expresso-window-container .rule-details-container" ).accordion(); // var removeURL = new RegExp("^*.#"); // ------------------------------------------------------------ // ------------------------------------------------------------ //jqgrid .end().find(".fields-search-messages .button.search") .click(function(){ var rule = DataLayer.form( form ); showGridButton = $(this).parent(); var connect = rule.isExact ? "AND" : "OR"; var filter = $.map( rule.criteria, function( criteria, i ){ if( i === 0 ) return {"0": criteria.field, "1": criteria.operator, "2": criteria.value}; else return {"0": connect, "1": criteria.field, "2": criteria.operator, "3": criteria.value}; }); $.ajax( { url: DataLayer.basePath + 'folder/INBOX/message&' + $.param( {"filter": filter} ), dataType: 'json', success: function(data){ allMessages = data; grid = showGridButton.addClass('hidden') .siblings(".fields-search-messages-grid, .fields-search-messages-grid-pager") .removeClass('hidden').filter(".fields-search-messages-grid").jqGrid({ url: DataLayer.basePath + 'folder/INBOX/message&' + $.param( {"filter": [ "msgNumber", "IN", data ]} ), datatype: "json", mtype: 'GET', colNames:['#', ' ', 'De', 'Assunto', 'Data', 'Tamanho'], colModel:[ {name:'msg_number',index:'msg_number', width:45, hidden:true, sortable:false}, {name:'flags',index:'msg_number', width:40, sortable:false, formatter:flags2Class}, {name:'from.name',index:'msg_number', width:130, sortable:false}, {name:'subject',index:'subject', width:250, sortable:false}, {name:'timestamp',index:'timestamp', width:65, align:"center", sortable:false, formatter:date2Time}, {name:'size',index:'size', width:50, align:"right", sortable:false, formatter:bytes2Size} ], jsonReader : { root:"rows", page: "page", total: "total", records: "records", repeatitems: false, id: "0" }, rowNum:10, rowList:[10,25,50], pager: '#fields-search-messages-grid-pager', sortname: 'id', viewrecords: true, sortorder: "desc", multiselect: true, autowidth: true, height:40, loadComplete: function(data) { // // aplica o contador // jQuery('.timable').each(function (i) { // jQuery(this).countdown({ // since: new Date(parseInt(this.title)), // significant: 1, // layout: 'há {d<}{dn} {dl} {d>}{h<}{hn} {hl} {h>}{m<}{mn} {ml} {m>}{s<}{sn} {sl}{s>}', // description: ' atrás' // }); // }); }, onSelectRow: function (id, selected) { if( selected ) selectedMessages[ id ] = true; else delete selectedMessages[ id ]; }, caption: 'Mensagens que atendem aos critérios' }); } } ); }); vacation_container.find( ".menu-container" ) .find(".button.back").click(function(event){ list_container.removeClass('hidden'); vacation_container.addClass('hidden'); return( false ); }).end() .find(".button.submit").click(function(event){ $(this).submit(); list_container.removeClass('hidden'); vacation_container.addClass('hidden'); return( false ); }); } var reraster = function( html ){ list_container.find( '.ui-widget' ).remove(); list_container.html( html ).find(".button").button(); formatter(); } var formatter = function(){ checkBoxes = container.find(".rule-list").selectable({ selecting: function(event, ui) { $(ui.selecting).find(':checkbox').attr('checked', true); }, unselecting: function(event, ui) { $(ui.unselecting).find(':checkbox').attr('checked', false); } }) .find(':checkbox').change(function () { // if ($(this).attr("checked")) // $(this).parents('.rule').addClass('ui-selected'); // else $(this).parents('.rule').toggleClass('ui-selected'); }); list_container.children() .filter( ".fields-add" ) .find(".button.add").click(function(){ list_container.addClass('hidden'); details_container.removeClass('hidden'); form.get(0).reset(); return( false ); }) .filter(".vacation").click(function(){ details_container.addClass('hidden'); vacation_container.removeClass('hidden'); form.get(0).reset(); return( false ); }).end().end() .end().filter( ".fields-selected-itens" ) .find(".button.enable").click(function(){ var values = []; checkBoxes.filter(':checked').parents(".rule-list").find('.title').each(function(){ values[ values.length ] = { id: this.innerHTML, enabled: true }; }); DataLayer.put( 'filter', values ); }).end() .find(".button.disable").click(function(){ var values = []; checkBoxes.filter(':checked').parents(".rule-list").find('.title').each(function(){ values[ values.length ] = { id: this.innerHTML, enabled: false }; }); DataLayer.put( 'filter', values ); }).end() .find(".button.delete").click(function(){ checkBoxes.filter(':checked').parents(".rule-list").find('.title').each(function(i, o){ DataLayer.remove( 'filter', o.html() ); }); }).end() .end().find( ".menu-control .button" ) .filter(".enable, .disable").click( function(event) { var id = $(this).parents("li.rule").find('.title').html(); DataLayer.put( 'filter', id, { enabled: !$(this).is('.enable') } ); }) .filter(".enable").button({ icons: { primary: "ui-icon-circle-check" }, text: false }).end() .filter(".disable").button({ icons: { primary: "ui-icon-circle-close" }, text: false }).end().end() .filter(".close").button({ icons: { primary: "ui-icon-close" }, text: false }).click( function(event) { $(event.target) .parents("li.rule").find('.title') .each( function(){ DataLayer.remove( 'filter', $(this).html() ); }).end().remove(); }).end() .filter(".update").click(function(event){ var id = ( event.target.href || event.target.parentNode.href ).replace( new RegExp("^.*#"), "" ); var data = DataLayer.get( 'filter', id ); if( id === "vacation" ) { $('[name="vacation"]').val( data.actions[0].parameter ); list_container.addClass('hidden'); vacation_container.removeClass('hidden'); return; } showDetails( data ); list_container.addClass('hidden'); details_container.removeClass('hidden'); }).end() .removeClass('ui-button-icon-only'); }; DataLayer.render( BASE_PATH + 'modules/filters/filters.ejs', 'filter:detail', raster, true ); // ------------------------------------------------------------ // ------------------------------------------------------------