this.ui = {
+ saveScrollTop: function()
+ {
+ this._scroll_top = $(document).scrollTop();
+ },
+
+ restoreScrollTop: function()
+ {
+ if (typeof(this._scroll_top) == 'undefined')
+ return;
+
+ $(document).scrollTop(this._scroll_top);
+
+ delete this._scroll_top;
+ },
+
loading: function(enable)
{
var win = $(window);
if (addb.prop('disabled') || name === '')
return;
+ _luci2.ui.saveScrollTop();
+
self.active_panel = -1;
self.map.save();
self.add(name);
self.map.redraw();
+
+ _luci2.ui.restoreScrollTop();
},
_remove: function(ev)
var self = ev.data.self;
var sid = ev.data.sid;
+ if (ev.data.index == (self.sections().length - 1))
+ self.active_panel = -1;
+
+ _luci2.ui.saveScrollTop();
+
self.map.save();
self.remove(sid);
self.map.redraw();
+ _luci2.ui.restoreScrollTop();
+
ev.stopPropagation();
},
return add;
},
- _render_remove: function(sid)
+ _render_remove: function(sid, index)
{
var text = _luci2.tr('Remove');
var ttip = _luci2.tr('Remove this section');
.addClass('cbi-button')
.addClass('cbi-button-remove')
.val(text).attr('title', ttip)
- .click({ self: this, sid: sid }, this._remove);
+ .click({ self: this, sid: sid, index: index }, this._remove);
},
_render_caption: function(sid)
$('<div />')
.addClass('cbi-section-remove')
.addClass('right')
- .append(this._render_remove(sid))
+ .append(this._render_remove(sid, panel_index))
.appendTo(head);
var body = $('<div />')
deletes: { }
};
- this.active_panel = 0;
+ if (typeof(this.active_panel) == 'undefined')
+ this.active_panel = 0;
var packages = { };
var self = this;
+ _luci2.ui.saveScrollTop();
_luci2.ui.loading(true);
return this.save().then(send_cb).then(function() {
self = null;
_luci2.ui.loading(false);
+ _luci2.ui.restoreScrollTop();
});
},