Commit 27a0938c authored by d11e9's avatar d11e9

tidy file tab handers

parent cf7ac731
...@@ -229,7 +229,7 @@ ...@@ -229,7 +229,7 @@
// ----------------- file selector------------- // ----------------- file selector-------------
var $filesEl = $('#files'); var $filesEl = $('#files');
$filesEl.on('click','.newFile', function() { $('.newFile').on('click', function() {
while (window.localStorage[SOL_CACHE_UNTITLED + untitledCount]) while (window.localStorage[SOL_CACHE_UNTITLED + untitledCount])
untitledCount = (untitledCount - 0) + 1; untitledCount = (untitledCount - 0) + 1;
SOL_CACHE_FILE = SOL_CACHE_UNTITLED + untitledCount; SOL_CACHE_FILE = SOL_CACHE_UNTITLED + untitledCount;
...@@ -343,10 +343,10 @@ ...@@ -343,10 +343,10 @@
return files; return files;
} }
updateFiles();
$filesWrapper = $('.files-wrapper');
var hidWidth; $scrollerRight = $('.scroller-right');
$scrollerLeft = $('.scroller-left');
function widthOfList (){ function widthOfList (){
var itemsWidth = 0; var itemsWidth = 0;
...@@ -355,61 +355,54 @@ ...@@ -355,61 +355,54 @@
itemsWidth += itemWidth; itemsWidth += itemWidth;
}); });
return itemsWidth; return itemsWidth;
}; };
function widthOfHidden(){ function widthOfHidden(){
return (($('.files-wrapper').outerWidth()) - widthOfList() - getLeftPosi()); return (($filesWrapper.outerWidth()) - widthOfList() - getLeftPosi());
}; };
function widthOfVisible(){ function widthOfVisible(){
return $('.files-wrapper').outerWidth(); return $filesWrapper.outerWidth();
}; };
function getLeftPosi(){ function getLeftPosi(){
return $('#files').position().left; return $filesEl.position().left;
}; };
function reAdjust (){ function reAdjust (){
if (widthOfList() + getLeftPosi() > + widthOfVisible()) {
console.log("left start: ", getLeftPosi()) $scrollerRight.fadeIn('fast');
console.log("outer width: ", widthOfVisible(), "content width: ", widthOfList(), " left+vis: ", getLeftPosi() + widthOfVisible()) } else {
if (widthOfList() + getLeftPosi() > + widthOfVisible()) { $scrollerRight.fadeOut('fast');
console.log( "show right scroll") }
$('.scroller-right').fadeIn('fast');
} else { if (getLeftPosi()<0) {
console.log( "hide right scroll") $scrollerLeft.fadeIn('fast');
$('.scroller-right').fadeOut('fast'); } else {
} $scrollerLeft.fadeOut('fast');
$filesEl.animate({left: getLeftPosi() + "px"},'slow');
if (getLeftPosi()<0) { }
console.log( "show left scroll") }
$('.scroller-left').fadeIn('fast');
} else { $scrollerRight.click(function() {
console.log( "hide left scroll") var delta = (getLeftPosi() - 200)
$('.scroller-left').fadeOut('fast'); $filesEl.animate({left: delta + "px"},'slow',function(){
$('#files').animate({left: getLeftPosi() + "px"},'slow'); reAdjust();
} });
} });
$('.scroller-right').click(function() { $scrollerLeft.click(function() {
var delta = (getLeftPosi() - 200) var delta = Math.min( (getLeftPosi() + 200), 0 )
console.log(delta) $filesEl.animate({left: delta + "px"},'slow',function(){
$('#files').animate({left: delta + "px"},'slow',function(){ reAdjust();
reAdjust(); });
}); });
});
updateFiles();
$('.scroller-left').click(function() {
var delta = Math.min( (getLeftPosi() + 200), 0 ) // ----------------- version selector-------------
console.log(delta)
$('#files').animate({left: delta + "px"},'slow',function(){ // var soljsonSources is provided by bin/list.js
reAdjust();
});
});
// ----------------- version selector-------------
// var soljsonSources is provided by bin/list.js
$('option', '#versionSelector').remove(); $('option', '#versionSelector').remove();
$.each(soljsonSources, function(i, file) { $.each(soljsonSources, function(i, file) {
if (file) { if (file) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment