Ignore:
Timestamp:
09/21/12 10:11:36 (12 years ago)
Author:
gustavo
Message:

Ticket #0000 - Criado novo modulo para o desenvolvimento do novo ExpressoMail?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/newExpressoMail/prototype/modules/newMail/js/tabs.js

    r7210 r7265  
    1 var countID = 2; 
    21var tab_content = ""; 
    32var tab_role = ""; 
    4 var lastIndexSelected = 0; 
    5 /*  
    6         method : createTab 
    7         descrition : create a new tab 
    8         params : { 
    9                 label : Label of the tab 
    10                 * role : Tab type 
    11                 * content : Content of the tab 
    12                 * href : Tab id  
    13                 * callback : a function 
    14         } 
    15         comments : { 
    16                 #1 : if the user just set the label, a tab with blank content and a dynamic id is created 
    17                 #2 : if a tab with a set href already exists, don't duplicate, this function only select the tab  
    18                 #3 : if the role is  
    19         * = Optional 
    20 */ 
    213 
    22 function createTab(label, role, content,href, callback){ 
    23         if( !$("#tabs-"+href).length){ 
    24                 tab_content = content ? content : ""; 
    25                 tab_role = role ? role : "new"; 
    26                 countID++; 
    27                 $tabs.wijtabs("add", "#tabs-"+(href ? href : countID), (label.length > 21 ? label.substring(0, 18)+"..." : label)); 
    28                 if(typeof(callback) == 'function')  
    29                         callback($("#ptabs_"+(href ? href : countID))); 
    30                 else 
    31                         return $("#tabs-"+(href ? href : countID)); 
    32         }else{ 
    33                 $tabs.wijtabs( "select", indexTab("#tabs-"+href) ); 
    34         } 
     4var Tab = { 
     5 
     6    /* 
     7     method : createTab 
     8     descrition : create a new tab 
     9     params : { 
     10     label : Label of the tab 
     11     * role : Tab type 
     12     * content : Content of the tab 
     13     * href : Tab id 
     14     * callback : a function 
     15     } 
     16     comments : { 
     17     #1 : if the user just set the label, a tab with blank content and a dynamic id is created 
     18     #2 : if a tab with a set href already exists, don't duplicate, this function only select the tab 
     19     #3 : if the role is 
     20     * = Optional 
     21     */ 
     22    create : function(label, role, content,href, callback){ 
     23        if( !$("#tabs-"+href).length){ 
     24            tab_content = content ? content : ""; 
     25            tab_role = role ? role : "new"; 
     26            Tab.count++; 
     27            $tabs.wijtabs("add", "#tabs-"+(href ? href : Tab.count), (label.length > 21 ? label.substring(0, 18)+"..." : label)); 
     28            if(typeof(callback) == 'function') 
     29                callback($("#ptabs_"+(href ? href : Tab.count))); 
     30            else 
     31                return $("#tabs-"+(href ? href : Tab.count)); 
     32        }else{ 
     33            $tabs.wijtabs( "select", Tab.index("#tabs-"+href) ); 
     34        } 
     35    }, 
     36 
     37 
     38    /* 
     39     method : removeTab 
     40     descrition : remove a tab 
     41     params : { 
     42     * href : Tab id 
     43     * callback : a function 
     44     } 
     45     comments : { 
     46     #1 : if the user doesn't set no parameter, this function just remove the open tab 
     47 
     48     * = Optional 
     49     */ 
     50    remove : function(href, callback){ 
     51        $tabs.wijtabs("remove", 
     52            ( 
     53                href ? 
     54                    Tab.index(href) : Tab.lastIndexSelected 
     55                ) 
     56        ); 
     57        if(typeof(callback) == 'function') 
     58            callback(); 
     59    }, 
     60 
     61    /* 
     62     method : Tab.index 
     63     descrition : return a tab index 
     64     params : { 
     65     * href : Tab id 
     66     } 
     67     comments : { 
     68     #1 : if the user doesn't set no parameter, this function just return the index of the open tab 
     69 
     70     * = Optional 
     71     */ 
     72 
     73    index : function(href){ 
     74        return href ? 
     75            $( "li", $tabs ).index( $('[href="'+href+'"]').parent() ) : Tab.lastIndexSelected; 
     76    }, 
     77 
     78    /* 
     79     method : idTab 
     80     descrition : remove a tab id 
     81     params : { 
     82     * index : Tab index 
     83     } 
     84     comments : { 
     85     #1 : if the user doesn't set no parameter, this function just return the id of the open tab 
     86 
     87     * = Optional 
     88     */ 
     89 
     90    id : function(index){ 
     91        return $( ".ui-tabs-panel", $tabs ).eq((index ? index : Tab.index())).attr("id"); 
     92    }, 
     93 
     94    getData : function(index){ 
     95        return { 
     96            id : parseInt(Tab.id(index).substring(6).split("_r_")[0]), 
     97            folder : Base64.decode(idTab(index).substring(6).split("_r_")[1]), 
     98            role : Tab.getRole(index), 
     99            header : Tab.getHeader(index), 
     100            content : Tab.getContent(index) 
     101        }; 
     102    }, 
     103 
     104    getHeader : function(index){ 
     105        return $( $tabs ).find('[href="#'+$( ".ui-tabs-panel", $tabs ).eq((index ? index : Tab.index())).attr("id")+'"]').parent(); 
     106    }, 
     107 
     108    getRole: function(index){ 
     109        return Tab.getContent(index).attr("role"); 
     110    }, 
     111 
     112    getContent: function(index){ 
     113        return $( ".ui-tabs-panel", $tabs ).eq((index ? index : Tab.index())); 
     114    }, 
     115 
     116    setFolderTotal: function(value){ 
     117        Tab.getHeader(0).find(".folder-tab-total-msgs-number").html(parseInt(value) ? value : 0); 
     118    }, 
     119 
     120    setFolderUnread: function(value){ 
     121        Tab.getHeader(0).find(".folder-tab-new-msgs-number").html(parseInt(value) ? value : 0); 
     122        if(parseInt(value)) 
     123            $("title").html($("title").html() +" ("+value+")"); 
     124    }, 
     125 
     126    setFolderName: function(value){ 
     127        Tab.getHeader(0).find(".folder-tab-name").html(value); 
     128        $("title").html(value); 
     129    }, 
     130 
     131    lastIndexSelected : 0, 
     132 
     133    count: 2, 
     134 
     135    roles : [ 
     136        "new", "draft", "search", "message", "folder" 
     137    ] 
    35138} 
    36  
    37 /*  
    38         method : removeTab 
    39         descrition : remove a tab 
    40         params : { 
    41                 * href : Tab id  
    42                 * callback : a function 
    43         } 
    44         comments : { 
    45                 #1 : if the user doesn't set no parameter, this function just remove the open tab 
    46  
    47         * = Optional 
    48 */ 
    49  
    50 function removeTab(href, callback){ 
    51         $tabs.wijtabs("remove",  
    52                 ( 
    53                         href ?  
    54                         indexTab(href) : lastIndexSelected 
    55                 ) 
    56         ); 
    57         if(typeof(callback) == 'function')  
    58                 callback(); 
    59 } 
    60  
    61 /*  
    62         method : indexTab 
    63         descrition : return a tab index 
    64         params : { 
    65                 * href : Tab id  
    66         } 
    67         comments : { 
    68                 #1 : if the user doesn't set no parameter, this function just return the index of the open tab 
    69  
    70         * = Optional 
    71 */ 
    72  
    73 function indexTab(href){ 
    74         return href ?  
    75                 $( "li", $tabs ).index( $('[href="'+href+'"]').parent() ) : lastIndexSelected; 
    76 } 
    77  
    78 /* 
    79  method : idTab 
    80  descrition : remove a tab id 
    81  params : { 
    82  * index : Tab index 
    83  } 
    84  comments : { 
    85  #1 : if the user doesn't set no parameter, this function just return the id of the open tab 
    86  
    87  * = Optional 
    88  */ 
    89  
    90 function idTab(index){ 
    91     return $( ".ui-tabs-panel", $tabs ).eq((index ? index : indexTab())).attr("id"); 
    92 } 
    93  
    94 function getTabData(index){ 
    95         return { 
    96                 id : parseInt(idTab(index).substring(6).split("_r_")[0]), 
    97                 folder : Base64.decode(idTab(index).substring(6).split("_r_")[1]), 
    98                 role : getTabRole(index), 
    99                 header : getTabHeader(index), 
    100                 content : getTabContent(index) 
    101         }; 
    102 } 
    103  
    104 function getTabHeader(index){ 
    105     return $( $tabs ).find('[href="#'+$( ".ui-tabs-panel", $tabs ).eq((index ? index : indexTab())).attr("id")+'"]').parent(); 
    106 } 
    107  
    108 function getTabRole(index){ 
    109         return getTabContent(index).attr("role"); 
    110 } 
    111  
    112 function getTabContent(index){ 
    113         return $( ".ui-tabs-panel", $tabs ).eq((index ? index : indexTab())); 
    114 } 
    115  
    116 function setFolderTabTotal(value){ 
    117         getTabHeader(0).find(".folder-tab-total-msgs-number").html(parseInt(value) ? value : 0); 
    118 } 
    119  
    120 function setFolderTabTotalUnread(value){ 
    121         getTabHeader(0).find(".folder-tab-new-msgs-number").html(parseInt(value) ? value : 0);   
    122         if(parseInt(value)) 
    123                 $("title").html($("title").html() +" ("+value+")"); 
    124 } 
    125  
    126 function setFolderTabName(value){ 
    127         getTabHeader(0).find(".folder-tab-name").html(value);    
    128         $("title").html(value); 
    129 } 
Note: See TracChangeset for help on using the changeset viewer.