DataView refactoring: add alwaysVisibleScrollbar parameter
This commit is contained in:
parent
66f6dacc05
commit
e51c72052e
|
@ -197,6 +197,7 @@ define([
|
||||||
emptyText: '',
|
emptyText: '',
|
||||||
listenStoreEvents: true,
|
listenStoreEvents: true,
|
||||||
allowScrollbar: true,
|
allowScrollbar: true,
|
||||||
|
scrollAlwaysVisible: false,
|
||||||
showLast: true,
|
showLast: true,
|
||||||
useBSKeydown: false
|
useBSKeydown: false
|
||||||
},
|
},
|
||||||
|
@ -239,6 +240,7 @@ define([
|
||||||
me.emptyText = me.options.emptyText || '';
|
me.emptyText = me.options.emptyText || '';
|
||||||
me.listenStoreEvents= (me.options.listenStoreEvents!==undefined) ? me.options.listenStoreEvents : true;
|
me.listenStoreEvents= (me.options.listenStoreEvents!==undefined) ? me.options.listenStoreEvents : true;
|
||||||
me.allowScrollbar = (me.options.allowScrollbar!==undefined) ? me.options.allowScrollbar : true;
|
me.allowScrollbar = (me.options.allowScrollbar!==undefined) ? me.options.allowScrollbar : true;
|
||||||
|
me.scrollAlwaysVisible = me.options.scrollAlwaysVisible || false;
|
||||||
if (me.parentMenu)
|
if (me.parentMenu)
|
||||||
me.parentMenu.options.restoreHeight = (me.options.restoreHeight>0);
|
me.parentMenu.options.restoreHeight = (me.options.restoreHeight>0);
|
||||||
me.rendered = false;
|
me.rendered = false;
|
||||||
|
@ -308,7 +310,8 @@ define([
|
||||||
el: $(this.el).find('.inner').addBack().filter('.inner'),
|
el: $(this.el).find('.inner').addBack().filter('.inner'),
|
||||||
useKeyboard: this.enableKeyEvents && !this.handleSelect,
|
useKeyboard: this.enableKeyEvents && !this.handleSelect,
|
||||||
minScrollbarLength : 40,
|
minScrollbarLength : 40,
|
||||||
wheelSpeed: 10
|
wheelSpeed: 10,
|
||||||
|
alwaysVisibleY: this.scrollAlwaysVisible
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,11 +364,12 @@ define([
|
||||||
|
|
||||||
if (suspendEvents)
|
if (suspendEvents)
|
||||||
this.resumeEvents();
|
this.resumeEvents();
|
||||||
|
return record;
|
||||||
},
|
},
|
||||||
|
|
||||||
selectByIndex: function(index, suspendEvents) {
|
selectByIndex: function(index, suspendEvents) {
|
||||||
if (this.store.length > 0 && index > -1 && index < this.store.length) {
|
if (this.store.length > 0 && index > -1 && index < this.store.length) {
|
||||||
this.selectRecord(this.store.at(index), suspendEvents);
|
return this.selectRecord(this.store.at(index), suspendEvents);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -480,7 +484,8 @@ define([
|
||||||
el: $(this.el).find('.inner').addBack().filter('.inner'),
|
el: $(this.el).find('.inner').addBack().filter('.inner'),
|
||||||
useKeyboard: this.enableKeyEvents && !this.handleSelect,
|
useKeyboard: this.enableKeyEvents && !this.handleSelect,
|
||||||
minScrollbarLength : 40,
|
minScrollbarLength : 40,
|
||||||
wheelSpeed: 10
|
wheelSpeed: 10,
|
||||||
|
alwaysVisibleY: this.scrollAlwaysVisible
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -568,6 +573,7 @@ define([
|
||||||
},
|
},
|
||||||
|
|
||||||
scrollToRecord: function (record) {
|
scrollToRecord: function (record) {
|
||||||
|
if (!record) return;
|
||||||
var innerEl = $(this.el).find('.inner'),
|
var innerEl = $(this.el).find('.inner'),
|
||||||
inner_top = innerEl.offset().top,
|
inner_top = innerEl.offset().top,
|
||||||
idx = _.indexOf(this.store.models, record),
|
idx = _.indexOf(this.store.models, record),
|
||||||
|
@ -576,7 +582,7 @@ define([
|
||||||
|
|
||||||
var div_top = div.offset().top,
|
var div_top = div.offset().top,
|
||||||
div_first = $(this.dataViewItems[0].el),
|
div_first = $(this.dataViewItems[0].el),
|
||||||
div_first_top = (div_first.length>=0) ? div_first[0].offsetTop : 0;
|
div_first_top = (div_first.length>0) ? div_first[0].offsetTop : 0;
|
||||||
if (div_top < inner_top + div_first_top || div_top+div.outerHeight() > inner_top + innerEl.height()) {
|
if (div_top < inner_top + div_first_top || div_top+div.outerHeight() > inner_top + innerEl.height()) {
|
||||||
if (this.scroller && this.allowScrollbar) {
|
if (this.scroller && this.allowScrollbar) {
|
||||||
this.scroller.scrollTop(innerEl.scrollTop() + div_top - inner_top - div_first_top, 0);
|
this.scroller.scrollTop(innerEl.scrollTop() + div_top - inner_top - div_first_top, 0);
|
||||||
|
@ -718,14 +724,16 @@ define([
|
||||||
margins = parseInt(parent.css('margin-top')) + parseInt(parent.css('margin-bottom')) + parseInt(menuRoot.css('margin-top')),
|
margins = parseInt(parent.css('margin-top')) + parseInt(parent.css('margin-bottom')) + parseInt(menuRoot.css('margin-top')),
|
||||||
paddings = parseInt(menuRoot.css('padding-top')) + parseInt(menuRoot.css('padding-bottom')),
|
paddings = parseInt(menuRoot.css('padding-top')) + parseInt(menuRoot.css('padding-bottom')),
|
||||||
menuH = menuRoot.outerHeight(),
|
menuH = menuRoot.outerHeight(),
|
||||||
top = parseInt(menuRoot.css('top'));
|
top = parseInt(menuRoot.css('top')),
|
||||||
|
props = {minScrollbarLength : 40};
|
||||||
|
this.scrollAlwaysVisible && (props.alwaysVisibleY = this.scrollAlwaysVisible);
|
||||||
|
|
||||||
if (top + menuH > docH ) {
|
if (top + menuH > docH ) {
|
||||||
innerEl.css('max-height', (docH - top - paddings - margins) + 'px');
|
innerEl.css('max-height', (docH - top - paddings - margins) + 'px');
|
||||||
if (this.allowScrollbar) this.scroller.update({minScrollbarLength : 40});
|
if (this.allowScrollbar) this.scroller.update(props);
|
||||||
} else if ( top + menuH < docH && innerEl.height() < this.options.restoreHeight ) {
|
} else if ( top + menuH < docH && innerEl.height() < this.options.restoreHeight ) {
|
||||||
innerEl.css('max-height', (Math.min(docH - top - paddings - margins, this.options.restoreHeight)) + 'px');
|
innerEl.css('max-height', (Math.min(docH - top - paddings - margins, this.options.restoreHeight)) + 'px');
|
||||||
if (this.allowScrollbar) this.scroller.update({minScrollbarLength : 40});
|
if (this.allowScrollbar) this.scroller.update(props);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -158,6 +158,7 @@ define([
|
||||||
handleSelect: true,
|
handleSelect: true,
|
||||||
showLast: true,
|
showLast: true,
|
||||||
allowScrollbar: true,
|
allowScrollbar: true,
|
||||||
|
scrollAlwaysVisible: true,
|
||||||
emptyItemText: ''
|
emptyItemText: ''
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -245,24 +246,24 @@ define([
|
||||||
var isExpanded = !record.get('isExpanded');
|
var isExpanded = !record.get('isExpanded');
|
||||||
record.set('isExpanded', isExpanded);
|
record.set('isExpanded', isExpanded);
|
||||||
this.store[(isExpanded) ? 'expandSubItems' : 'collapseSubItems'](record);
|
this.store[(isExpanded) ? 'expandSubItems' : 'collapseSubItems'](record);
|
||||||
this.scroller.update({minScrollbarLength: 40});
|
this.scroller.update({minScrollbarLength: 40, alwaysVisibleY: this.scrollAlwaysVisible});
|
||||||
} else
|
} else
|
||||||
Common.UI.DataView.prototype.onClickItem.call(this, view, record, e);
|
Common.UI.DataView.prototype.onClickItem.call(this, view, record, e);
|
||||||
},
|
},
|
||||||
|
|
||||||
expandAll: function() {
|
expandAll: function() {
|
||||||
this.store.expandAll();
|
this.store.expandAll();
|
||||||
this.scroller.update({minScrollbarLength: 40});
|
this.scroller.update({minScrollbarLength: 40, alwaysVisibleY: this.scrollAlwaysVisible});
|
||||||
},
|
},
|
||||||
|
|
||||||
collapseAll: function() {
|
collapseAll: function() {
|
||||||
this.store.collapseAll();
|
this.store.collapseAll();
|
||||||
this.scroller.update({minScrollbarLength: 40});
|
this.scroller.update({minScrollbarLength: 40, alwaysVisibleY: this.scrollAlwaysVisible});
|
||||||
},
|
},
|
||||||
|
|
||||||
expandToLevel: function(expandLevel) {
|
expandToLevel: function(expandLevel) {
|
||||||
this.store.expandToLevel(expandLevel);
|
this.store.expandToLevel(expandLevel);
|
||||||
this.scroller.update({minScrollbarLength: 40});
|
this.scroller.update({minScrollbarLength: 40, alwaysVisibleY: this.scrollAlwaysVisible});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})());
|
})());
|
||||||
|
|
Loading…
Reference in a new issue