Remove old lint system, layout adjust for gutter

Remove updateHints function, upgraded to new gutter based JS Hint system
On toggle of codeAssist, clear the gutter and set lintWith to false if
we're turning off
1st tab position is now an extra 12px, so 53px not 41px
This commit is contained in:
Matt Pass
2013-06-30 11:45:39 +01:00
parent 863ece66fa
commit 8a24eeff24
2 changed files with 30 additions and 77 deletions

View File

@@ -1476,40 +1476,6 @@ var ICEcoder = {
return i!=-1 ? i : false;
},
// Show JS Hint errors
updateHints: function() {
var cM;
if ("undefined" != typeof JSHINT && top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1].indexOf('.js')>-1) {
cM = ICEcoder.getcMInstance();
cM.operation(function(){
var widgets = top.ICEcoder['cM'+top.ICEcoder.cMInstances[top.ICEcoder.selectedTab-1]+'widgets'];
for (var i=0; i<widgets.length; ++i) {
cM.removeLineWidget(widgets[i]);
}
widgets.length = 0;
JSHINT(cM.getValue());
for (var i=0; i<JSHINT.errors.length; ++i) {
var err = JSHINT.errors[i];
if (!err) continue;
var msg = document.createElement("div");
var icon = msg.appendChild(document.createElement("span"));
icon.innerHTML = "!!";
icon.className = "lint-error-icon";
msg.appendChild(document.createTextNode(err.reason));
msg.className = "lint-error";
widgets.push(cM.addLineWidget(err.line-1, msg, {coverGutter: false, noHScroll: true}));
}
});
var info = cM.getScrollInfo();
var after = cM.charCoords({line: cM.getCursor().line+1, ch: 0}, "local").top;
if (info.top + info.clientHeight < after) {
cM.scrollTo(null, after - info.clientHeight+3);
}
}
},
// ==============
// SYSTEM
// ==============
@@ -1542,18 +1508,10 @@ var ICEcoder = {
cM.focus();
if (!top.ICEcoder.codeAssist) {
for (i=0;i<top.ICEcoder.cMInstances.length;i++) {
cM = top.ICEcoder.content.contentWindow['cM'+top.ICEcoder.cMInstances[i]];
cM.operation(function(){
var widgets = top.ICEcoder['cM'+top.ICEcoder.cMInstances[i]+'widgets'];
for (var j=0; j<widgets.length; ++j) {
cM.removeLineWidget(widgets[j]);
}
widgets.length = 0;
});
}
cM.clearGutter("CodeMirror-lint-markers");
cM.setOption("lintWith",false);
} else {
top.ICEcoder.updateHints();
cM.setOption("lintWith",top.ICEcoder.content.contentWindow.CodeMirror.javascriptValidator);
}
},
@@ -1821,9 +1779,6 @@ var ICEcoder = {
top.ICEcoder.findMode = false;
ICEcoder.findReplace(top.get('find').value,true,false);
// Rerun JS Hint
if (top.ICEcoder.codeAssist) {top.ICEcoder.updateHints()};
// Finally, update the cursor display
top.ICEcoder.getCaretPosition();
top.ICEcoder.updateCharDisplay();
@@ -2015,16 +1970,16 @@ var ICEcoder = {
var availWidth, avgWidth, tabWidth, lastLeft, lastWidth;
if (top.ICEcoder.ready) {
availWidth = parseInt(top.ICEcoder.content.style.width,10)-41-24-10; // - left margin - new tab - right margin
availWidth = parseInt(top.ICEcoder.content.style.width,10)-53-24-10; // - left margin - new tab - right margin
avgWidth = (availWidth/top.ICEcoder.openFiles.length)-18;
tabWidth = -18; // Incl 18px offset
lastLeft = 41;
lastLeft = 53;
lastWidth = 0;
top.ICEcoder.tabLeftPos = [];
for (var i=0;i<top.ICEcoder.openFiles.length;i++) {
if (posOnlyNewTab) {i=top.ICEcoder.openFiles.length};
tabWidth = top.ICEcoder.openFiles.length*(150+18) > availWidth ? parseInt(avgWidth*i,10) - parseInt(avgWidth*(i-1),10) : 150;
lastLeft = i==0 ? 41 : parseInt(top.get('tab'+(i)).style.left,10);
lastLeft = i==0 ? 53 : parseInt(top.get('tab'+(i)).style.left,10);
lastWidth = i==0 ? 0 : parseInt(top.get('tab'+(i)).style.width,10)+18;
if (!posOnlyNewTab) {
top.get('tab'+(i+1)).style.left = (lastLeft+lastWidth) + "px";
@@ -2042,7 +1997,7 @@ var ICEcoder = {
tabDragStart: function(tab) {
top.ICEcoder.draggingTab = tab;
top.ICEcoder.diffStartX = top.ICEcoder.mouseX;
top.ICEcoder.tabDragMouseXStart = (top.ICEcoder.mouseX - (parseInt(top.ICEcoder.files.style.width,10)+41+18)) % 150;
top.ICEcoder.tabDragMouseXStart = (top.ICEcoder.mouseX - (parseInt(top.ICEcoder.files.style.width,10)+53+18)) % 150;
top.get('tab'+tab).style.zIndex = 2;
for (var i=1; i<=top.ICEcoder.openFiles.length; i++) {
top.get('tab'+i).className = i!==tab
@@ -2057,9 +2012,9 @@ var ICEcoder = {
lastTabWidth = parseInt(top.get('tab'+top.ICEcoder.openFiles.length).style.width,10)+18;
top.ICEcoder.thisLeft = thisLeft = top.ICEcoder.tabDragMouseX >= 41
top.ICEcoder.thisLeft = thisLeft = top.ICEcoder.tabDragMouseX >= 53
? top.ICEcoder.tabDragMouseX <= parseInt(top.get('newTab').style.left,10) - lastTabWidth
? top.ICEcoder.tabDragMouseX : (parseInt(top.get('newTab').style.left,10) - lastTabWidth) : 41;
? top.ICEcoder.tabDragMouseX : (parseInt(top.get('newTab').style.left,10) - lastTabWidth) : 53;
top.get('tab'+top.ICEcoder.draggingTab).style.left = thisLeft + "px";