mirror of
https://github.com/icecoder/ICEcoder.git
synced 2026-03-03 07:13:59 +01:00
nest display err catching and tab sliding
Only show nest display if we have the cM variable On close setTabWidths with param to only set newTab position If we have that param, get values for the last tab by setting i to the last tab, but if we don't have posOnlyNewTab set, we can set widths & left pos's of tabs.
This commit is contained in:
@@ -1005,46 +1005,48 @@ var ICEcoder = {
|
||||
var cM, nestCheck, state, cx, startPos, fileName, events;
|
||||
|
||||
cM = ICEcoder.getcMInstance();
|
||||
nestCheck = cM.getValue();
|
||||
if (cM) {
|
||||
nestCheck = cM.getValue();
|
||||
|
||||
// Set up array to store nest data
|
||||
state = cM.getTokenAt(cM.getCursor()).state;
|
||||
if ("undefined" != typeof state.curState) {
|
||||
ICEcoder.htmlTagArray = [];
|
||||
for (cx = state.curState.context; cx; cx = cx.prev) {
|
||||
if ("undefined" != typeof cx.tagName) {
|
||||
ICEcoder.htmlTagArray.unshift(cx.tagName);
|
||||
// Set up array to store nest data
|
||||
state = cM.getTokenAt(cM.getCursor()).state;
|
||||
if ("undefined" != typeof state.curState) {
|
||||
ICEcoder.htmlTagArray = [];
|
||||
for (cx = state.curState.context; cx; cx = cx.prev) {
|
||||
if ("undefined" != typeof cx.tagName) {
|
||||
ICEcoder.htmlTagArray.unshift(cx.tagName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ICEcoder.tagString = ICEcoder.htmlTagArray[ICEcoder.htmlTagArray.length-1];
|
||||
if (ICEcoder.caretLocType=="JavaScript") {
|
||||
ICEcoder.tagString = "script";
|
||||
}
|
||||
ICEcoder.tagString = ICEcoder.htmlTagArray[ICEcoder.htmlTagArray.length-1];
|
||||
if (ICEcoder.caretLocType=="JavaScript") {
|
||||
ICEcoder.tagString = "script";
|
||||
}
|
||||
|
||||
// Now we've built up our nest depth array, if we're due to show it in the display
|
||||
if (updateNestDisplay && !top.ICEcoder.dontUpdateNest) {
|
||||
// Clear the display
|
||||
ICEcoder.nestDisplayText.innerHTML = "";
|
||||
ICEcoder.nestDisplay.innerHTML = "";
|
||||
if ("undefined" != typeof ICEcoder.openFiles[ICEcoder.selectedTab-1]) {
|
||||
fileName = ICEcoder.openFiles[ICEcoder.selectedTab-1];
|
||||
if (["js","coffee","rb","css","less"].indexOf(fileName.split(".")[1])<0 &&
|
||||
(nestCheck.indexOf("include(")==-1)&&(nestCheck.indexOf("include_once(")==-1)&&
|
||||
(nestCheck.indexOf("<html")>-1||nestCheck.indexOf("<body")>-1)) {
|
||||
// Now we've built up our nest depth array, if we're due to show it in the display
|
||||
if (updateNestDisplay && !top.ICEcoder.dontUpdateNest) {
|
||||
// Clear the display
|
||||
ICEcoder.nestDisplayText.innerHTML = "";
|
||||
ICEcoder.nestDisplay.innerHTML = "";
|
||||
if ("undefined" != typeof ICEcoder.openFiles[ICEcoder.selectedTab-1]) {
|
||||
fileName = ICEcoder.openFiles[ICEcoder.selectedTab-1];
|
||||
if (["js","coffee","rb","css","less"].indexOf(fileName.split(".")[1])<0 &&
|
||||
(nestCheck.indexOf("include(")==-1)&&(nestCheck.indexOf("include_once(")==-1)&&
|
||||
(nestCheck.indexOf("<html")>-1||nestCheck.indexOf("<body")>-1)) {
|
||||
|
||||
ICEcoder.nestDisplayText.innerHTML = ICEcoder.htmlTagArray.length > 0 ? "Cursor Position" : "";
|
||||
// Then for all the array items, output as the nest display
|
||||
for (var i=0;i<ICEcoder.htmlTagArray.length;i++) {
|
||||
events = 'onMouseover="top.ICEcoder.highlightBlock('+i+')" onMouseout="top.ICEcoder.highlightBlock('+i+',\'hide\')" onClick="top.ICEcoder.setPosition('+i+',top.ICEcoder.startPosLine,\''+ICEcoder.htmlTagArray[i]+'\')"';
|
||||
if (i==0) {ICEcoder.nestDisplay.innerHTML += '<div '+events+' style="display: inline-block; width: 7px; margin-top: -5px; height: 30px; background-image: url(images/nest-tag-bg.gif); cursor: pointer"></div>'};
|
||||
ICEcoder.nestDisplay.innerHTML += '<a '+events+' style="display: inline-block; cursor: pointer; background: #333; padding: 7px 2px 7px 7px; margin-top: -5px; height: 30px">'+ICEcoder.htmlTagArray[i]+'</a>';
|
||||
ICEcoder.nestDisplay.innerHTML += i<ICEcoder.htmlTagArray.length-1
|
||||
? '<div '+events+' style="display: inline-block; width: 8px; margin-top: -5px; height: 30px; background-image: url(images/nest-tag-bg.gif); background-position: -7px 0; cursor: pointer"></div>'
|
||||
: '<div '+events+' style="display: inline-block; width: 7px; margin-top: -5px; height: 30px; background-image: url(images/nest-tag-bg.gif); background-position: -15px 0; cursor: pointer"></div>';
|
||||
}
|
||||
if ("undefined" != typeof state.curState && ICEcoder.htmlTagArray.length > 0) {
|
||||
ICEcoder.nestDisplay.innerHTML += '<a style="display: inline-block; cursor: default; padding: 7px 2px 7px 7px; margin-top: -5px; height: 30px; color: #666">'+(state.curState.tagName ? state.curState.tagName : 'content')+'</a>';
|
||||
ICEcoder.nestDisplayText.innerHTML = ICEcoder.htmlTagArray.length > 0 ? "Cursor Position" : "";
|
||||
// Then for all the array items, output as the nest display
|
||||
for (var i=0;i<ICEcoder.htmlTagArray.length;i++) {
|
||||
events = 'onMouseover="top.ICEcoder.highlightBlock('+i+')" onMouseout="top.ICEcoder.highlightBlock('+i+',\'hide\')" onClick="top.ICEcoder.setPosition('+i+',top.ICEcoder.startPosLine,\''+ICEcoder.htmlTagArray[i]+'\')"';
|
||||
if (i==0) {ICEcoder.nestDisplay.innerHTML += '<div '+events+' style="display: inline-block; width: 7px; margin-top: -5px; height: 30px; background-image: url(images/nest-tag-bg.gif)"></div>'};
|
||||
ICEcoder.nestDisplay.innerHTML += '<a '+events+' style="display: inline-block; cursor: pointer; background: #333; padding: 7px 2px 7px 7px; margin-top: -5px; height: 30px">'+ICEcoder.htmlTagArray[i]+'</a>';
|
||||
ICEcoder.nestDisplay.innerHTML += i<ICEcoder.htmlTagArray.length-1
|
||||
? '<div '+events+' style="display: inline-block; width: 8px; margin-top: -5px; height: 30px; background-image: url(images/nest-tag-bg.gif); background-position: -7px 0; cursor: pointer"></div>'
|
||||
: '<div '+events+' style="display: inline-block; width: 7px; margin-top: -5px; height: 30px; background-image: url(images/nest-tag-bg.gif); background-position: -15px 0; cursor: pointer"></div>';
|
||||
}
|
||||
if ("undefined" != typeof state.curState && ICEcoder.htmlTagArray.length > 0) {
|
||||
ICEcoder.nestDisplay.innerHTML += '<a style="display: inline-block; cursor: default; padding: 7px 2px 7px 7px; margin-top: -5px; height: 30px; color: #666">'+(state.curState.tagName ? state.curState.tagName : 'content')+'</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1734,7 +1736,7 @@ var ICEcoder = {
|
||||
// Lastly, stop it from trying to also switch tab
|
||||
top.ICEcoder.canSwitchTabs=false;
|
||||
// and set the widths
|
||||
top.ICEcoder.setTabWidths();
|
||||
top.ICEcoder.setTabWidths('posOnlyNewTab');
|
||||
},
|
||||
|
||||
// Close all tabs
|
||||
@@ -1747,7 +1749,7 @@ var ICEcoder = {
|
||||
},
|
||||
|
||||
// Set the tabs width
|
||||
setTabWidths: function() {
|
||||
setTabWidths: function(posOnlyNewTab) {
|
||||
var availWidth, avgWidth, tabWidth, lastLeft, lastWidth;
|
||||
|
||||
availWidth = parseInt(top.ICEcoder.content.style.width,10)-41-24-10; // - left margin - new tab - right margin
|
||||
@@ -1756,13 +1758,15 @@ var ICEcoder = {
|
||||
lastLeft = 41;
|
||||
lastWidth = 0;
|
||||
top.ICEcoder.tabLeftPos = [];
|
||||
|
||||
for (var i=0;i<top.ICEcoder.openFiles.length;i++) {
|
||||
if (posOnlyNewTab) {i=top.ICEcoder.openFiles.length-1};
|
||||
tabWidth = top.ICEcoder.openFiles.length*(150+18) > availWidth ? parseInt(avgWidth*i,10) - parseInt(avgWidth*(i-1),10) : 150;
|
||||
lastLeft = i==0 ? 41 : parseInt(top.document.getElementById('tab'+(i)).style.left,10);
|
||||
lastWidth = i==0 ? 0 : parseInt(top.document.getElementById('tab'+(i)).style.width,10)+18;
|
||||
top.document.getElementById('tab'+(i+1)).style.left = (lastLeft+lastWidth) + "px";
|
||||
top.document.getElementById('tab'+(i+1)).style.width = tabWidth + "px";
|
||||
if (!posOnlyNewTab) {
|
||||
top.document.getElementById('tab'+(i+1)).style.left = (lastLeft+lastWidth) + "px";
|
||||
top.document.getElementById('tab'+(i+1)).style.width = tabWidth + "px";
|
||||
}
|
||||
top.ICEcoder.tabLeftPos.push(lastLeft+lastWidth);
|
||||
}
|
||||
top.document.getElementById('newTab').style.left = (lastLeft+lastWidth+tabWidth+18) + "px";
|
||||
|
||||
Reference in New Issue
Block a user