Skip to content
This repository
Browse code

overCloseLink flag and position new tab on close

The 3 x instances where we define closeTabLink needs the
setting/unsetting of a new var flag called overCloseLink. This is so we
can choose not to start or end a drag function.
After processing a closeTab function, set canSwitchTabs back to true in
0.1s
Finally, the newTab left position should be set according to the length
of open files, not 1 less than it and we also need to have a tab width
of 0 but compensate for the padding, so needs to be -18
  • Loading branch information...
commit cc8230499674980e65d22600c8f1600a7c0de29e 1 parent 3d91b8a
Matt Pass authored

Showing 1 changed file with 8 additions and 4 deletions. Show diff stats Hide diff stats

  1. +8 4 lib/ice-coder.js
12 lib/ice-coder.js
@@ -617,7 +617,7 @@ var ICEcoder = {
617 617 if(i>-1) {
618 618 // rename array item and the tab
619 619 top.ICEcoder.openFiles[i] = newName;
620   - closeTabLink = '<a nohref onClick="top.ICEcoder.closeTab(parseInt(this.parentNode.id.slice(3),10))"><img src="images/nav-close.gif" class="closeTab" onMouseOver="prevBG=this.style.backgroundColor;this.style.backgroundColor=\'#333\'" onMouseOut="this.style.backgroundColor=prevBG"></a>';
  620 + closeTabLink = '<a nohref onClick="top.ICEcoder.closeTab(parseInt(this.parentNode.id.slice(3),10))"><img src="images/nav-close.gif" class="closeTab" onMouseOver="prevBG=this.style.backgroundColor;this.style.backgroundColor=\'#333\'; top.ICEcoder.overCloseLink=true" onMouseOut="this.style.backgroundColor=prevBG; top.ICEcoder.overCloseLink=false"></a>';
621 621 fileName = top.ICEcoder.openFiles[i];
622 622 top.document.getElementById('tab'+(i+1)).innerHTML = closeTabLink + " " + fileName.slice(fileName.lastIndexOf("/")).replace(/\//,"");
623 623 top.document.getElementById('tab'+(i+1)).title = newName;
@@ -1607,7 +1607,7 @@ var ICEcoder = {
1607 1607 top.ICEcoder.openFiles.push(top.ICEcoder.shortURL);
1608 1608
1609 1609 // Setup a new tab
1610   - closeTabLink = '<a nohref onClick="top.ICEcoder.closeTab(parseInt(this.parentNode.id.slice(3),10))"><img src="images/nav-close.gif" class="closeTab" onMouseOver="prevBG=this.style.backgroundColor;this.style.backgroundColor=\'#333\'" onMouseOut="this.style.backgroundColor=prevBG"></a>';
  1610 + closeTabLink = '<a nohref onClick="top.ICEcoder.closeTab(parseInt(this.parentNode.id.slice(3),10))"><img src="images/nav-close.gif" class="closeTab" onMouseOver="prevBG=this.style.backgroundColor;this.style.backgroundColor=\'#333\'; top.ICEcoder.overCloseLink=true" onMouseOut="this.style.backgroundColor=prevBG; top.ICEcoder.overCloseLink=false"></a>';
1611 1611 top.document.getElementById('tab'+(top.ICEcoder.openFiles.length)).style.display = "inline-block";
1612 1612 fileName = top.ICEcoder.openFiles[top.ICEcoder.openFiles.length-1];
1613 1613 top.document.getElementById('tab'+(top.ICEcoder.openFiles.length)).innerHTML = closeTabLink + " " + fileName.slice(fileName.lastIndexOf("/")).replace(/\//,"");
@@ -1650,7 +1650,7 @@ var ICEcoder = {
1650 1650 top.ICEcoder.openFiles[tabNum-1] = newName;
1651 1651
1652 1652 // Setup a new tab
1653   - closeTabLink = '<a nohref onClick="top.ICEcoder.closeTab(parseInt(this.parentNode.id.slice(3),10))"><img src="images/nav-close.gif" class="closeTab" onMouseOver="prevBG=this.style.backgroundColor;this.style.backgroundColor=\'#333\'" onMouseOut="this.style.backgroundColor=prevBG"></a>';
  1653 + closeTabLink = '<a nohref onClick="top.ICEcoder.closeTab(parseInt(this.parentNode.id.slice(3),10))"><img src="images/nav-close.gif" class="closeTab" onMouseOver="prevBG=this.style.backgroundColor;this.style.backgroundColor=\'#333\'; top.ICEcoder.overCloseLink=true" onMouseOut="this.style.backgroundColor=prevBG; top.ICEcoder.overCloseLink=false"></a>';
1654 1654 fileName = top.ICEcoder.openFiles[tabNum-1];
1655 1655 top.document.getElementById('tab'+tabNum).innerHTML = closeTabLink + " " + fileName.slice(fileName.lastIndexOf("/")).replace(/\//,"");
1656 1656 top.document.getElementById('tab'+tabNum).title = "/" + top.ICEcoder.openFiles[tabNum-1].replace(/\//,"");
@@ -1680,6 +1680,7 @@ var ICEcoder = {
1680 1680 // Close the tab upon request
1681 1681 closeTab: function(closeTabNum, dontSetPV) {
1682 1682 var cM, okToRemove, closeFileName;
  1683 +
1683 1684 cM = ICEcoder.getcMInstance();
1684 1685 okToRemove = true;
1685 1686 if (ICEcoder.changedContent[closeTabNum-1]==1) {
@@ -1738,6 +1739,7 @@ var ICEcoder = {
1738 1739 top.ICEcoder.canSwitchTabs=false;
1739 1740 // and set the widths
1740 1741 top.ICEcoder.setTabWidths('posOnlyNewTab');
  1742 + setTimeout(function() {top.ICEcoder.canSwitchTabs=true;},100);
1741 1743 },
1742 1744
1743 1745 // Close all tabs
@@ -1760,13 +1762,15 @@ var ICEcoder = {
1760 1762 lastWidth = 0;
1761 1763 top.ICEcoder.tabLeftPos = [];
1762 1764 for (var i=0;i<top.ICEcoder.openFiles.length;i++) {
1763   - if (posOnlyNewTab) {i=top.ICEcoder.openFiles.length-1};
  1765 + if (posOnlyNewTab) {i=top.ICEcoder.openFiles.length};
1764 1766 tabWidth = top.ICEcoder.openFiles.length*(150+18) > availWidth ? parseInt(avgWidth*i,10) - parseInt(avgWidth*(i-1),10) : 150;
1765 1767 lastLeft = i==0 ? 41 : parseInt(top.document.getElementById('tab'+(i)).style.left,10);
1766 1768 lastWidth = i==0 ? 0 : parseInt(top.document.getElementById('tab'+(i)).style.width,10)+18;
1767 1769 if (!posOnlyNewTab) {
1768 1770 top.document.getElementById('tab'+(i+1)).style.left = (lastLeft+lastWidth) + "px";
1769 1771 top.document.getElementById('tab'+(i+1)).style.width = tabWidth + "px";
  1772 + } else {
  1773 + tabWidth = -18;
1770 1774 }
1771 1775 top.ICEcoder.tabLeftPos.push(lastLeft+lastWidth);
1772 1776 }

0 comments on commit cc82304

Please sign in to comment.
Something went wrong with that request. Please try again.