tidy file tab handers

pull/1/head
d11e9 9 years ago
parent cf7ac73156
commit 27a0938cf6
  1. 111
      assets/js/app.js

@ -229,7 +229,7 @@
// ----------------- file selector-------------
var $filesEl = $('#files');
$filesEl.on('click','.newFile', function() {
$('.newFile').on('click', function() {
while (window.localStorage[SOL_CACHE_UNTITLED + untitledCount])
untitledCount = (untitledCount - 0) + 1;
SOL_CACHE_FILE = SOL_CACHE_UNTITLED + untitledCount;
@ -343,10 +343,10 @@
return files;
}
updateFiles();
var hidWidth;
$filesWrapper = $('.files-wrapper');
$scrollerRight = $('.scroller-right');
$scrollerLeft = $('.scroller-left');
function widthOfList (){
var itemsWidth = 0;
@ -355,61 +355,54 @@
itemsWidth += itemWidth;
});
return itemsWidth;
};
function widthOfHidden(){
return (($('.files-wrapper').outerWidth()) - widthOfList() - getLeftPosi());
};
function widthOfVisible(){
return $('.files-wrapper').outerWidth();
};
function getLeftPosi(){
return $('#files').position().left;
};
function reAdjust (){
console.log("left start: ", getLeftPosi())
console.log("outer width: ", widthOfVisible(), "content width: ", widthOfList(), " left+vis: ", getLeftPosi() + widthOfVisible())
if (widthOfList() + getLeftPosi() > + widthOfVisible()) {
console.log( "show right scroll")
$('.scroller-right').fadeIn('fast');
} else {
console.log( "hide right scroll")
$('.scroller-right').fadeOut('fast');
}
if (getLeftPosi()<0) {
console.log( "show left scroll")
$('.scroller-left').fadeIn('fast');
} else {
console.log( "hide left scroll")
$('.scroller-left').fadeOut('fast');
$('#files').animate({left: getLeftPosi() + "px"},'slow');
}
}
$('.scroller-right').click(function() {
var delta = (getLeftPosi() - 200)
console.log(delta)
$('#files').animate({left: delta + "px"},'slow',function(){
reAdjust();
});
});
$('.scroller-left').click(function() {
var delta = Math.min( (getLeftPosi() + 200), 0 )
console.log(delta)
$('#files').animate({left: delta + "px"},'slow',function(){
reAdjust();
});
});
// ----------------- version selector-------------
// var soljsonSources is provided by bin/list.js
};
function widthOfHidden(){
return (($filesWrapper.outerWidth()) - widthOfList() - getLeftPosi());
};
function widthOfVisible(){
return $filesWrapper.outerWidth();
};
function getLeftPosi(){
return $filesEl.position().left;
};
function reAdjust (){
if (widthOfList() + getLeftPosi() > + widthOfVisible()) {
$scrollerRight.fadeIn('fast');
} else {
$scrollerRight.fadeOut('fast');
}
if (getLeftPosi()<0) {
$scrollerLeft.fadeIn('fast');
} else {
$scrollerLeft.fadeOut('fast');
$filesEl.animate({left: getLeftPosi() + "px"},'slow');
}
}
$scrollerRight.click(function() {
var delta = (getLeftPosi() - 200)
$filesEl.animate({left: delta + "px"},'slow',function(){
reAdjust();
});
});
$scrollerLeft.click(function() {
var delta = Math.min( (getLeftPosi() + 200), 0 )
$filesEl.animate({left: delta + "px"},'slow',function(){
reAdjust();
});
});
updateFiles();
// ----------------- version selector-------------
// var soljsonSources is provided by bin/list.js
$('option', '#versionSelector').remove();
$.each(soljsonSources, function(i, file) {
if (file) {

Loading…
Cancel
Save