includes/clientside/static/misc.js
changeset 85 7c68a18a27be
parent 74 68469a95658d
child 125 fb31c951d3a2
equal deleted inserted replaced
84:f99fb84bd959 85:7c68a18a27be
   555     str = leftpart + subst + rightPart;
   555     str = leftpart + subst + rightPart;
   556   }
   556   }
   557   return str;
   557   return str;
   558 }
   558 }
   559 
   559 
   560 function paginator_goto(parentobj, this_page, num_pages, perpage, url_string)
       
   561 {
       
   562   var height = $(parentobj).Height();
       
   563   var width  = $(parentobj).Width();
       
   564   var left   = $(parentobj).Left();
       
   565   var top    = $(parentobj).Top();
       
   566   var left_pos = left + width ;
       
   567   var top_pos = height + top;
       
   568   var div = document.createElement('div');
       
   569   div.style.position = 'absolute';
       
   570   div.style.top = top_pos + 'px';
       
   571   div.className = 'question-box';
       
   572   div.style.margin = '1px 0 0 2px';
       
   573   var vtmp = 'input_' + Math.floor(Math.random() * 1000000);
       
   574   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="paginator_submit(this, '+num_pages+', '+perpage+', unescape(\'' + escape(url_string) + '\')); return false;" 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>';
       
   575   
       
   576   var body = document.getElementsByTagName('body')[0];
       
   577   domObjChangeOpac(0, div);
       
   578   
       
   579   body.appendChild(div);
       
   580   
       
   581   document.getElementById(vtmp).onkeypress = function(e){if(e.keyCode==13)this.nextSibling.nextSibling.onclick();};
       
   582   document.getElementById(vtmp).focus();
       
   583   
       
   584   // fade the div
       
   585   /*
       
   586   if(!div.id) div.id = 'autofade_'+Math.floor(Math.random() * 100000);
       
   587   var from = '#33FF33';
       
   588   Fat.fade_element(div.id,30,2000,from,Fat.get_bgcolor(div.id));
       
   589   */
       
   590   
       
   591   fly_in_bottom(div, false, true);
       
   592   
       
   593   var divh = $(div).Width();
       
   594   left_pos = left_pos - divh;
       
   595   div.style.left = left_pos + 'px';
       
   596 }
       
   597 
       
   598 function paginator_submit(obj, max, perpage, formatstring)
       
   599 {
       
   600   var userinput = obj.previousSibling.previousSibling.value;
       
   601   userinput = parseInt(userinput);
       
   602   var offset = ( userinput - 1 ) * perpage;
       
   603   if ( userinput > max || isNaN(userinput) || userinput < 1 )
       
   604   {
       
   605     new messagebox(MB_OK|MB_ICONSTOP, 'Invalid entry', 'Please enter a page number between 1 and ' + max + '.');
       
   606     return false;
       
   607   }
       
   608   var url = sprintf(formatstring, String(offset));
       
   609   fly_out_top(obj.parentNode, false, true);
       
   610   window.location = url;
       
   611 }
       
   612 
       
   613 /**
   560 /**
   614  * Insert a DOM object _after_ the specified child.
   561  * Insert a DOM object _after_ the specified child.
   615  * @param object Parent node
   562  * @param object Parent node
   616  * @param object Node to insert
   563  * @param object Node to insert
   617  * @param object Node to insert after
   564  * @param object Node to insert after