includes/clientside/static/paginate.js
changeset 359 e0787bb6285b
parent 98 6457a9b983c6
child 387 92664d2efab8
equal deleted inserted replaced
358:b25d34fbc7ab 359:e0787bb6285b
    66  */
    66  */
    67 
    67 
    68 function _build_paginator(this_page)
    68 function _build_paginator(this_page)
    69 {
    69 {
    70   var div_styling = ( IE ) ? 'width: 1px; margin: 10px auto 10px 0;' : 'display: table; margin: 10px 0 0 auto;';
    70   var div_styling = ( IE ) ? 'width: 1px; margin: 10px auto 10px 0;' : 'display: table; margin: 10px 0 0 auto;';
    71   var begin = '<div class="tblholder" style="'+div_styling+'"><table border="0" cellspacing="1" cellpadding="4"><tr><th>Page:</th>';
    71   var begin = '<div class="tblholder" style="'+div_styling+'"><table border="0" cellspacing="1" cellpadding="4"><tr><th>' + $lang.get('paginate_lbl_page') + '</th>';
    72   var block = '<td class="row1" style="text-align: center; white-space: nowrap;">{LINK}</td>';
    72   var block = '<td class="row1" style="text-align: center; white-space: nowrap;">{LINK}</td>';
    73   var end = '</tr></table></div>';
    73   var end = '</tr></table></div>';
    74   var blk = new templateParser(block);
    74   var blk = new templateParser(block);
    75   var inner = '';
    75   var inner = '';
    76   var cls = 'row2';
    76   var cls = 'row2';
    77   
    77   
    78   if ( this_page > 0 )
    78   if ( this_page > 0 )
    79   {
    79   {
    80     var url = '#page_'+(this_page);
    80     var url = '#page_'+(this_page);
    81     var link = "<a href=\""+url+"\" onclick=\"jspaginator_goto('"+this.random_id+"', "+(this_page-1)+"); return false;\" style='text-decoration: none;'>&laquo; Prev</a>";
    81     var link = "<a href=\""+url+"\" onclick=\"jspaginator_goto('"+this.random_id+"', "+(this_page-1)+"); return false;\" style='text-decoration: none;'>&laquo; " + $lang.get('paginate_btn_prev') + "</a>";
    82     cls = ( cls == 'row1' ) ? 'row2' : 'row1';
    82     cls = ( cls == 'row1' ) ? 'row2' : 'row1';
    83     blk.assign_vars({
    83     blk.assign_vars({
    84         CLASS: cls,
    84         CLASS: cls,
    85         LINK: link
    85         LINK: link
    86       });
    86       });
   124       {
   124       {
   125         list.push(lower + i);
   125         list.push(lower + i);
   126       }
   126       }
   127     }
   127     }
   128     var url = '#page_1';
   128     var url = '#page_1';
   129     var link = ( 0 == this_page ) ? "<b>First</b>" : "<a href=\""+url+"\" onclick=\"jspaginator_goto('"+this.random_id+"', 0); return false;\" style='text-decoration: none;'>&laquo; First</a>";
   129     var link = ( 0 == this_page ) ? "<b>" + $lang.get('paginate_btn_first') + "</b>" : "<a href=\""+url+"\" onclick=\"jspaginator_goto('"+this.random_id+"', 0); return false;\" style='text-decoration: none;'>&laquo; " + $lang.get('paginate_btn_first') + "</a>";
   130     blk.assign_vars({
   130     blk.assign_vars({
   131         CLASS: cls,
   131         CLASS: cls,
   132         LINK: link
   132         LINK: link
   133       });
   133       });
   134     inner += blk.run();
   134     inner += blk.run();
   162       // $blk->assign_vars(array('CLASS'=>$cls,'LINK'=>'...'));
   162       // $blk->assign_vars(array('CLASS'=>$cls,'LINK'=>'...'));
   163       // $inner .= $blk->run();
   163       // $inner .= $blk->run();
   164 
   164 
   165       cls = ( cls == 'row1' ) ? 'row2' : 'row1';
   165       cls = ( cls == 'row1' ) ? 'row2' : 'row1';
   166       var url = '#page_' + String( this.num_pages-1 );
   166       var url = '#page_' + String( this.num_pages-1 );
   167       var link = ( ( this.num_pages - 1 ) == this_page ) ? "<b>Last</b>" : "<a href=\""+url+"\" onclick=\"jspaginator_goto('"+this.random_id+"', "+(this.num_pages-1)+"); return false;\" style='text-decoration: none;'>Last &raquo;</a>";
   167       var link = ( ( this.num_pages - 1 ) == this_page ) ? "<b>" + $lang.get('paginate_btn_last') + "</b>" : "<a href=\""+url+"\" onclick=\"jspaginator_goto('"+this.random_id+"', "+(this.num_pages-1)+"); return false;\" style='text-decoration: none;'>" + $lang.get('paginate_btn_last') + " &raquo;</a>";
   168       blk.assign_vars({
   168       blk.assign_vars({
   169           CLASS: cls,
   169           CLASS: cls,
   170           LINK: link
   170           LINK: link
   171         });
   171         });
   172       inner += blk.run();
   172       inner += blk.run();
   175   }
   175   }
   176 
   176 
   177   if ( this_page < ( this.num_pages - 1 ) )
   177   if ( this_page < ( this.num_pages - 1 ) )
   178   {
   178   {
   179     var url = '#page_' + String(this_page + 2);
   179     var url = '#page_' + String(this_page + 2);
   180     var link = "<a href=\""+url+"\" onclick=\"jspaginator_goto('"+this.random_id+"', "+(this_page+1)+"); return false;\" style='text-decoration: none;'>Next &raquo;</a>";
   180     var link = "<a href=\""+url+"\" onclick=\"jspaginator_goto('"+this.random_id+"', "+(this_page+1)+"); return false;\" style='text-decoration: none;'>" + $lang.get('paginate_btn_next') + " &raquo;</a>";
   181     cls = ( cls == 'row1' ) ? 'row2' : 'row1';
   181     cls = ( cls == 'row1' ) ? 'row2' : 'row1';
   182     blk.assign_vars({
   182     blk.assign_vars({
   183           CLASS: cls,
   183           CLASS: cls,
   184           LINK: link
   184           LINK: link
   185         });
   185         });
   282   div.style.margin = '1px 0 0 2px';
   282   div.style.margin = '1px 0 0 2px';
   283   var vtmp = 'input_' + Math.floor(Math.random() * 1000000);
   283   var vtmp = 'input_' + Math.floor(Math.random() * 1000000);
   284   var regex = new RegExp('\"', 'g');
   284   var regex = new RegExp('\"', 'g');
   285   var submit_target = ( typeof(url_string) == 'object' ) ? ( toJSONString(url_string) ).replace(regex, '\'') : 'unescape(\'' + escape(url_string) + '\')';
   285   var submit_target = ( typeof(url_string) == 'object' ) ? ( toJSONString(url_string) ).replace(regex, '\'') : 'unescape(\'' + escape(url_string) + '\')';
   286   var onclick = 'paginator_submit(this, '+num_pages+', '+perpage+', '+submit_target+'); return false;';
   286   var onclick = 'paginator_submit(this, '+num_pages+', '+perpage+', '+submit_target+'); return false;';
   287   div.innerHTML = 'Go to page:<br /><input type="text" size="2" style="padding: 1px; font-size: 8pt;" value="'+(parseInt(this_page)+1)+'" id="'+vtmp+'" />&emsp;<a href="#" onclick="'+onclick+'" style="font-size: 14pt; text-decoration: none;">&raquo;</a>&emsp;<a href="#" onclick="fly_out_top(this.parentNode, false, true); return false;" style="font-size: 14pt; text-decoration: none;">&times;</a>';
   287   div.innerHTML = $lang.get('paginate_lbl_goto_page') + '<br /><input type="text" size="2" style="padding: 1px; font-size: 8pt;" value="'+(parseInt(this_page)+1)+'" id="'+vtmp+'" />&emsp;<a href="#" onclick="'+onclick+'" style="font-size: 14pt; text-decoration: none;">&raquo;</a>&emsp;<a href="#" onclick="fly_out_top(this.parentNode, false, true); return false;" style="font-size: 14pt; text-decoration: none;">&times;</a>';
   288   
   288   
   289   var body = document.getElementsByTagName('body')[0];
   289   var body = document.getElementsByTagName('body')[0];
   290   domObjChangeOpac(0, div);
   290   domObjChangeOpac(0, div);
   291   
   291   
   292   body.appendChild(div);
   292   body.appendChild(div);
   293   
   293   
   294   document.getElementById(vtmp).onkeypress = function(e){if(e.keyCode==13)this.nextSibling.nextSibling.onclick();};
   294   document.getElementById(vtmp).onkeypress = function(e)
       
   295     {
       
   296       if ( e.keyCode == 13 )
       
   297         this.nextSibling.nextSibling.onclick();
       
   298     };
   295   document.getElementById(vtmp).focus();
   299   document.getElementById(vtmp).focus();
   296   
   300   
   297   // fade the div
   301   // fade the div
   298   /*
   302   /*
   299   if(!div.id) div.id = 'autofade_'+Math.floor(Math.random() * 100000);
   303   if(!div.id) div.id = 'autofade_'+Math.floor(Math.random() * 100000);
   313   var userinput = obj.previousSibling.previousSibling.value;
   317   var userinput = obj.previousSibling.previousSibling.value;
   314   userinput = parseInt(userinput);
   318   userinput = parseInt(userinput);
   315   var offset = ( userinput - 1 ) * perpage;
   319   var offset = ( userinput - 1 ) * perpage;
   316   if ( userinput > max || isNaN(userinput) || userinput < 1 )
   320   if ( userinput > max || isNaN(userinput) || userinput < 1 )
   317   {
   321   {
   318     new messagebox(MB_OK|MB_ICONSTOP, 'Invalid entry', 'Please enter a page number between 1 and ' + max + '.');
   322     new messagebox(MB_OK|MB_ICONSTOP, $lang.get('paginate_err_bad_page_title'), $lang.get('paginate_err_bad_page_body', { max: max }));
   319     return false;
   323     return false;
   320   }
   324   }
   321   if ( typeof(formatstring) == 'object' )
   325   if ( typeof(formatstring) == 'object' )
   322   {
   326   {
   323     fly_out_top(obj.parentNode, false, true);
   327     fly_out_top(obj.parentNode, false, true);