- for(var i = 0, input; input = miniTab.inputArr[i]; i++) {
- if(input.className.search("active") != -1) {
- miniTab.activeTab = miniTab.currentTab = i;
- }
- /*input.style.borderBottom = "0px";*/
- /*input.style.paddingBottom = "6px";*/
- }
-
- miniTab.slideObj = miniTab.ul.parentNode.appendChild(document.createElement("div"));
- miniTab.slideObj.appendChild(document.createTextNode(String.fromCharCode(160)));
- miniTab.slideObj.id = "minitabs-sliding";
+minitabs.prototype.initSlide = function (pos, force) {
+
+ if(!force && pos == this.activeTab) return;
+ this.setActive (this.activeTab,false);
+ this.activeTab = pos;
+ this.setActive (this.activeTab,true);
+ this.initAnim();
+};
+
+minitabs.prototype.setActive = function (pos,active) {
+ var input=this.li_s[pos].select('input.minitabs-submit')[0];
+ if (active)
+ input.addClassName('active');
+ else
+ input.removeClassName('active');
+};
+
+minitabs.prototype.setSlidingTop = function () {
+ var delta=0;
+ /* up 5px for firefox */
+ /*window.console.log('agent=' + navigator.userAgent);*/
+ if (navigator.userAgent.match(/Firefox/)) delta=-5;
+ this.slideObj.style.top = (this.ul.offsetTop + this.li_s[this.activeTab].offsetTop
+ + this.input_s[this.activeTab].offsetTop + delta ) + "px";
+};
+
+minitabs.prototype.initAnim = function() {
+ /* search for the input with type != hidden */
+ var input=this.li_s[this.activeTab].select('input.minitabs-submit')[0];
+ this.destX = parseInt(this.li_s[this.activeTab].offsetLeft + input.offsetLeft
+ + this.ul.offsetLeft);
+ this.destW = parseInt(input.offsetWidth);
+ this.t = 0;
+ this.b = this.slideObj.offsetLeft;
+ this.c = this.destX - this.b;
+
+ this.bW = this.slideObj.offsetWidth;
+ this.cW = this.destW - this.bW;
+
+ this.setSlidingTop();
+};
+
+minitabs.prototype.slideIt = function() {
+
+ // Has the browser text size changed?
+ var active_li = this.li_s[this.activeTab];
+ var active_input = this.input_s[this.activeTab];
+ if (this.aHeight != this.ul.offsetTop + active_li.offsetTop + active_input.offsetTop) {
+ this.initAnim();
+ this.aHeight = this.ul.offsetTop + active_li.offsetTop + active_input.offsetTop;
+ }
+
+
+ if (this.t++ < this.d) {
+ var x = this.animate(this.t,this.b,this.c,this.d);
+ var w = this.animate(this.t,this.bW,this.cW,this.d);
+
+ this.slideObj.style.left = parseInt(x) + "px";
+ this.slideObj.style.width = parseInt(w) + "px";
+ } else {
+ this.slideObj.style.left = this.destX + "px";
+ this.slideObj.style.width = this.destW +"px";
+ }
+};
+
+minitabs.prototype.animate = function(t,b,c,d) {
+ if ((t/=d/2) < 1) return c/2*t*t + b;
+ return -c/2 * ((--t)*(t-2) - 1) + b;
+};