Changeset 4701


Ignore:
Timestamp:
07/13/11 09:48:54 (13 years ago)
Author:
rafaelraymundo
Message:

Ticket #2069 - Paginação some aleatóriamente no resultado de pesquisas

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.0.1/expressoMail1_2/js/search.js

    r4686 r4701  
    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          = []; 
     
    247250        { 
    248251                var span_pg = Element("span_paging"+currentTab); 
    249                  
     252 
    250253                if( span_pg == null ) 
    251254                { 
     
    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                 } 
     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); 
    287352        } 
    288353 
Note: See TracChangeset for help on using the changeset viewer.