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();
var hidWidth; $filesWrapper = $('.files-wrapper');
$scrollerRight = $('.scroller-right');
$scrollerLeft = $('.scroller-left');
function widthOfList (){ function widthOfList (){
var itemsWidth = 0; var itemsWidth = 0;
...@@ -358,55 +358,48 @@ ...@@ -358,55 +358,48 @@
}; };
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 (){
console.log("left start: ", getLeftPosi())
console.log("outer width: ", widthOfVisible(), "content width: ", widthOfList(), " left+vis: ", getLeftPosi() + widthOfVisible())
if (widthOfList() + getLeftPosi() > + widthOfVisible()) { if (widthOfList() + getLeftPosi() > + widthOfVisible()) {
console.log( "show right scroll") $scrollerRight.fadeIn('fast');
$('.scroller-right').fadeIn('fast');
} else { } else {
console.log( "hide right scroll") $scrollerRight.fadeOut('fast');
$('.scroller-right').fadeOut('fast');
} }
if (getLeftPosi()<0) { if (getLeftPosi()<0) {
console.log( "show left scroll") $scrollerLeft.fadeIn('fast');
$('.scroller-left').fadeIn('fast');
} else { } else {
console.log( "hide left scroll") $scrollerLeft.fadeOut('fast');
$('.scroller-left').fadeOut('fast'); $filesEl.animate({left: getLeftPosi() + "px"},'slow');
$('#files').animate({left: getLeftPosi() + "px"},'slow');
} }
} }
$('.scroller-right').click(function() { $scrollerRight.click(function() {
var delta = (getLeftPosi() - 200) var delta = (getLeftPosi() - 200)
console.log(delta) $filesEl.animate({left: delta + "px"},'slow',function(){
$('#files').animate({left: delta + "px"},'slow',function(){
reAdjust(); reAdjust();
}); });
}); });
$('.scroller-left').click(function() { $scrollerLeft.click(function() {
var delta = Math.min( (getLeftPosi() + 200), 0 ) 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();
// ----------------- version selector------------- // ----------------- version selector-------------
// var soljsonSources is provided by bin/list.js // var soljsonSources is provided by bin/list.js
......
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