javascripts/right-tabs-src.js in right-rails-0.4.3 vs javascripts/right-tabs-src.js in right-rails-0.4.4
- old
+ new
@@ -312,11 +312,11 @@
resizing: function(callback) {
if (Tabs.__working) return this.resizing.bind(this, callback).delay(20);
var controller = this.tab.controller;
var options = controller.options;
- var prev_panel = controller.element.subNodes().first('hasClass', 'right-tabs-panel-current');
+ var prev_panel = controller.element.first('.right-tabs-panel-current');
var this_panel = this.element;
var swapping = prev_panel != this_panel;
var loading = this.element.first('div.right-tabs-panel-locker');
if (options.resizeFx && self.Fx && prev_panel && (swapping || loading)) {
@@ -345,23 +345,27 @@
controller.element.style.height = controller.element.offsetHeight + 'px';
// wrapping the element with an overflowed element to visualize the resize
var fx_wrapper = $E('div', {'class': 'right-tabs-resizer'});
var set_back = fx_wrapper.replace.bind(fx_wrapper, this_panel);
- this_panel.wrap(fx_wrapper);
- fx_wrapper.setHeight(prev_panel_height);
+ fx_wrapper.style.height = prev_panel_height + 'px';
// in case of harmonica nicely hidding the previous panel
if (controller.isHarmonica && swapping) {
prev_panel.addClass('right-tabs-panel-current');
- var hide_wrapper = $E('div', {'class': 'right-tabs-resizer'}).setHeight(prev_panel.offsetHeight);
+ var hide_wrapper = $E('div', {'class': 'right-tabs-resizer'});
+ hide_wrapper.style.height = prev_panel.offsetHeight + 'px';
var prev_back = function() {
hide_wrapper.replace(prev_panel.removeClass('right-tabs-panel-current'));
};
prev_panel.wrap(hide_wrapper);
+
+ fx_wrapper.style.height = '0px';
}
+ this_panel.wrap(fx_wrapper);
+
// getting back the auto-size so we could resize it
controller.element.style.height = 'auto';
if (hide_wrapper) hide_wrapper.morph({height: '0px'}, {duration: resize_duration, onFinish: prev_back});
fx_wrapper.morph({height: new_panel_height + 'px'}, {duration: resize_duration, onFinish: set_back });
@@ -792,24 +796,21 @@
*
* @param Number optional delay in ms
* @return Tabs this
*/
startLoop: function(delay) {
- if (isNumber(delay)) this.options.loop = delay;
+ if (!delay && !this.options.loop) return this;
// attaching the loop pause feature
if (this.options.loopPause) {
- this._stopLoop = this._stopLoop || this.stopLoop.bind(this);
- this._startLoop = this._startLoop || this.startLoop.bind(this);
+ this._stopLoop = this._stopLoop || this.stopLoop.bind(this, true);
+ this._startLoop = this._startLoop || this.startLoop.bind(this, delay);
- this.element
- .stopObserving('mouseover', this._stopLoop)
- .stopObserving('mouseout', this._startLoop)
- .on({
- mouseover: this._stopLoop,
- mouseout: this._startLoop
- });
+ this.forgetHovers().on({
+ mouseover: this._stopLoop,
+ mouseout: this._startLoop
+ });
}
if (this.timer) this.timer.stop();
this.timer = function() {
@@ -817,25 +818,35 @@
var current = this.tabs.first('current');
var next = enabled[enabled.indexOf(current)+1];
this.show(next || enabled.first());
- }.bind(this).periodical(this.options.loop);
+ }.bind(this).periodical(this.options.loop || delay);
return this;
},
/**
* Stops the slideshow loop
*
* @return Tabs this
*/
- stopLoop: function() {
+ stopLoop: function(event, pause) {
if (this.timer) {
this.timer.stop();
this.timer = null;
}
+ if (!pause && this._startLoop)
+ this.forgetHovers();
+ },
+
+// private
+ forgetHovers: function() {
+ return this.element
+ .stopObserving('mouseover', this._stopLoop)
+ .stopObserving('mouseout', this._startLoop);
}
+
}})());
/**
* The document level hooks for the tabs-egnine
\ No newline at end of file