XML added as a filetype & nest indicator fixes

Nest indicator now works with XML too
Set cx as false and then set if we have a matching object structure
Do nest indicator even if we don't have a html or body tag, as we may
have XML
Always show 'content' after the nest tags, except if it's JavaScript
This commit is contained in:
Matt Pass
2013-08-09 07:35:44 +01:00
parent 4eb6d699c1
commit e5fac3efa3
2 changed files with 48 additions and 35 deletions

View File

@@ -252,6 +252,7 @@ var ICEcoder = {
: fileName.indexOf('.css')>0 ? cM.setOption("mode","css")
: fileName.indexOf('.less')>0 ? cM.setOption("mode","less")
: fileName.indexOf('.md')>0 ? cM.setOption("mode","markdown")
: fileName.indexOf('.xml')>0 ? cM.setOption("mode","xml")
: cM.setOption("mode","application/x-httpd-php");
}
},
@@ -1183,11 +1184,23 @@ var ICEcoder = {
if (cM) {
nestCheck = cM.getValue();
// Set up array to store nest data
// Get the token state at our cursor
state = cM.getTokenAt(cM.getCursor()).state;
cx = false;
// XML
if ("undefined" != typeof state) {
cx = state.context;
}
// HTML
if ("undefined" != typeof state.curState && "undefined" != typeof state.curState.htmlState) {
ICEcoder.htmlTagArray = [];
for (cx = state.curState.htmlState.context; cx; cx = cx.prev) {
cx = state.curState.htmlState.context;
}
// Set up array to store nest data
ICEcoder.htmlTagArray = [];
if (cx) {
for (cx = cx; cx; cx = cx.prev) {
if ("undefined" != typeof cx.tagName) {
ICEcoder.htmlTagArray.unshift(cx.tagName);
}
@@ -1205,8 +1218,7 @@ var ICEcoder = {
if ("undefined" != typeof ICEcoder.openFiles[ICEcoder.selectedTab-1]) {
fileName = ICEcoder.openFiles[ICEcoder.selectedTab-1];
if (["js","coffee","css","less"].indexOf(fileName.split(".")[1])<0 &&
(nestCheck.indexOf("include(")==-1)&&(nestCheck.indexOf("include_once(")==-1)&&
(nestCheck.indexOf("<html")>-1||nestCheck.indexOf("<body")>-1)) {
(nestCheck.indexOf("include(")==-1)&&(nestCheck.indexOf("include_once(")==-1)) {
// Then for all the array items, output as the nest display
for (var i=0;i<ICEcoder.htmlTagArray.length;i++) {
@@ -1217,8 +1229,8 @@ var ICEcoder = {
? '<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>';
if (ICEcoder.tagString != "script") {
ICEcoder.nestDisplay.innerHTML += '<a style="display: inline-block; cursor: default; padding: 7px 2px 7px 7px; margin-top: -5px; height: 30px; color: #666">content</a>';
}
}
}
@@ -1296,7 +1308,8 @@ var ICEcoder = {
else if (fileName.indexOf(".rb")>0) {caretLocType="Ruby"}
else if (fileName.indexOf(".css")>0) {caretLocType="CSS"}
else if (fileName.indexOf(".less")>0) {caretLocType="LESS"}
else if (fileName.indexOf(".md")>0) {caretLocType="Markdown"};
else if (fileName.indexOf(".md")>0) {caretLocType="Markdown"}
else if (fileName.indexOf(".xml")>0) {caretLocType="XML"};
}
ICEcoder.caretLocType = caretLocType;