Changeset 4834


Ignore:
Timestamp:
07/20/11 11:20:43 (13 years ago)
Author:
roberto.santosjunior
Message:

Ticket #1820 - Paginação some aleatóriamente no resultado de pesquisas. r4701

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/expressoMail1_2/js/search.js

    r4821 r4834  
    44        function searchE() 
    55        { 
     6                this.totalPages = 1;  
     7                this.numPages = 5;  
     8                this.lastPage = 0;  
    69                this.searchW            = []; 
    710                this.condition          = ""; 
    811                this.sort_type          = ""; 
    9                 this.page                       = 0; 
     12                //this.page                     = 0; 
    1013                this.name_box_search = ""; 
    1114                this.all_boxes          = []; 
     
    255258                else 
    256259                        span_pg.innerHTML = ""; 
    257                  
    258                 if ( size > preferences.max_email_per_page ) 
    259                 { 
    260                         for ( var i = (this.page > 2 ? this.page-2 : 0) ; i <= parseInt( this.page )+4 ; i+= 1 ) 
    261                         { 
    262                                 if( ( i * preferences.max_email_per_page ) > size) 
    263                                 { 
    264                                         break; 
    265                                 } 
    266  
    267                                 if( this.page == i ) 
    268                                 { 
    269                                         var _link = document.createElement('span'); 
    270                                                 _link.setAttribute("style", "font-weight:bold; color:red") 
    271                                                 _link.innerHTML = ( this.page + 1 ) + "&nbsp;&nbsp;"; 
    272                                 } 
    273                                 else 
    274                                 { 
    275                                         var _page = i; 
    276                                         var _link = document.createElement('A');                                         
    277                                                 _link.innerHTML = ( _page + 1 ) + "&nbsp;&nbsp;"; 
    278                                                 _link.href  = 'javascript:EsearchE.page='+i+';'; 
    279                                                 _link.href += 'cExecute("$this.imap_functions.search_msg",openpage,"condition='+this.condition+'&sort_type='+this.sort_type+'&page='+_page+'&current_tab='+currentTab+'");'; 
    280                                 } 
    281                                                  
    282                                 span_pg.appendChild( _link ); 
    283                         } 
    284  
    285                         Element("div_menu_c3").appendChild(span_pg); 
    286                 } 
    287         } 
     260  
     261                if(size > parseInt(preferences.max_email_per_page)) {  
     262                        this.totalPages = parseInt(size/preferences.max_email_per_page);  
     263                        if((size/preferences.max_email_per_page) > this.totalPages)  
     264                        this.totalPages++;  
     265                }  
     266  
     267                if(this.page != 0) {  
     268                        _link = document.createElement("A");  
     269            _link.href  = 'javascript:EsearchE.page=0;';  
     270            _link.href += 'cExecute("$this.imap_functions.search_msg",openpage,"condition='+this.condition+'&sort_type='+this.sort_type+'&page=0&current_tab='+currentTab+'");';  
     271        }  
     272        else {  
     273            _link = document.createElement("SPAN");  
     274                }  
     275                span_pg.appendChild(_link);  
     276  
     277                _link.innerHTML = "&lt;&lt;";  
     278        _link.title = get_lang("First");  
     279        span_pg.innerHTML += "&nbsp;";  
     280  
     281                if(this.page == this.lastPage + (this.numPages))  
     282                {  
     283                        this.lastPage = this.page - 1;  
     284                }  
     285                else if((this.lastPage != 0 && this.lastPage == this.page) || this.page == (this.totalPages-1))  
     286                {  
     287                        this.lastPage = this.page - (this.numPages - 1);  
     288                }  
     289                else if(this.page == 0)  
     290                {  
     291                        this.lastPage = 0;  
     292                }  
     293  
     294                if(this.lastPage < 0)  
     295                        this.lastPage = 0;  
     296                else if(this.lastPage > 0 && (this.lastPage > (this.totalPages -(this.numPages - 1))))  
     297                        this.lastPage = this.totalPages -(this.numPages);  
     298  
     299                var hasMarked = false;  
     300                for(i = this.lastPage; i <= this.totalPages; i++)  
     301                {  
     302                        if( ( i * preferences.max_email_per_page ) > size)  
     303                        {  
     304                                break;  
     305                        }  
     306                  
     307                        if( this.page == i || (i == this.totalPages && !hasMarked) )  
     308                        {  
     309                                var _link = document.createElement('span');  
     310                                _link.setAttribute("style", "font-weight:bold; color:red")  
     311                                _link.innerHTML = ( this.page + 1 ) + "&nbsp;&nbsp;";  
     312                        }  
     313                        else  
     314                        {  
     315                                var _page = i;  
     316                                var _link = document.createElement('A');  
     317                                _link.innerHTML = ( _page + 1 ) + "&nbsp;&nbsp;";  
     318                                _link.href  = 'javascript:EsearchE.page='+i+';';  
     319                                _link.href += 'cExecute("$this.imap_functions.search_msg",openpage,"condition='+this.condition+'&sort_type='+this.sort_type+'&page='+_page+'&current_tab='+currentTab+'");';  
     320                        }  
     321                        _link.innerHTML = "&nbsp;...&nbsp;";  
     322                        if(i == (this.lastPage + this.numPages))  
     323                        {  
     324                                span_pg.appendChild( _link );  
     325                                break;  
     326                        }  
     327                        else if(this.lastPage == 0 || i != this.lastPage)  
     328                        {  
     329                                _link.innerHTML = "&nbsp;"+( i + 1 )+"&nbsp;";  
     330                        }  
     331                                //span_pg.innerHTML += "&nbsp;";  
     332  
     333                                span_pg.appendChild( _link );  
     334                        }  
     335  
     336                        if(this.page != (this.totalPages - 1)) {  
     337                                _link = document.createElement("A");  
     338                                _link.href  = 'javascript:EsearchE.page='+(this.totalPages-1)+';';  
     339                                _link.href += 'cExecute("$this.imap_functions.search_msg",openpage,"condition='+this.condition+'&sort_type='+this.sort_type+'&page='+(this.totalPages-1)+'&current_tab='+currentTab+'");';  
     340                        }  
     341                else {  
     342                _link = document.createElement("SPAN");  
     343                        }  
     344  
     345                        span_pg.innerHTML += "&nbsp;";  
     346                        span_pg.appendChild(_link);  
     347                          
     348                        _link.title = get_lang("Last");  
     349                        _link.innerHTML += "&gt;&gt;";  
     350  
     351                        Element("div_menu_c3").appendChild(span_pg);  
     352                } 
    288353 
    289354        searchE.prototype.searchFor = function( borderID, sortType ) 
Note: See TracChangeset for help on using the changeset viewer.