Modifications webEdition team made to CSCC core files

Whole file structure was modified. CSCC has been moved into contrib folder of CodeMirror.

Subsequent you'll find complete diffs of changes we've made inside CSCC files. Each change has a comment on it






############ cscc-parse-xml.js ############
--- cscc-1.1/cscc-parse-xml.js	2010-06-23 13:48:26.000000000 +0200
+++ webEdition/editors/template/CodeMirror/contrib/cscc/js/cscc-parse-xml.js	2010-08-08 16:10:04.000000000 +0200
@@ -64,7 +64,7 @@ csccParseXml.prototype =
     switch (this.state) {
       case csccParseXml.atStart:
       case csccParseXml.inTagName:
-        if (c.match(/[\w\._\-]/)) {
+        if (c.match(/[\w\._\-:]/)) { //modified by we:willRockYou to match namespaced tags
           this.tagName += c;
           this.state = csccParseXml.inTagName;
         }
         
         
         
         
         
         
         
############ cscc.js ############
--- cscc-1.1/cscc.js	2010-06-24 09:45:50.000000000 +0200
+++ webEdition/editors/template/CodeMirror/contrib/cscc/js/cscc.js	2010-08-10 21:19:11.000000000 +0200
@@ -35,25 +35,18 @@ var cscc = {
   // creates the CodeMirror instance
   init: function(textareaId) {
     cscc.addStyle();
-    csccSense.init();
-
-    // modify some values below to meet your wishes    
-    var options = {
-      tabMode: "shift",
-      height: "90%",
-      textWrapping: true,
-      parserfile: ["parsexml.js", "parsecss.js", "tokenizejavascript.js", "parsejavascript.js", "parsequplo.js"],
-      stylesheet: ["CodeMirror-0.67/css/xmlcolors.css", "CodeMirror-0.67/css/jscolors.css", "CodeMirror-0.67/css/csscolors.css"],
-      path: "CodeMirror-0.67/js/",
-      autoMatchParens: false,
-      lineNumbers: false,
-      cursorActivity: cscc.cursorActivity
-    };
+    csccSense.init();
+
+	//CMoptions removed by we:willRockYou. CMoptions are now in the calling document
+   	for(i in top.we_tags){ //added by we:willRockYou - inject dynamic we:tag dictionary
+   		top.weEditorFrameController.getVisibleEditorFrame().csccSense.xmlDictionary[i]=top.we_tags[i].attributes;
+   	}
+
     if (!cscc.IE) {
-      options.keyDownFunction = cscc.keyDown;
-      options.keyUpFunction = cscc.keyUp;
+      CMoptions.keyDownFunction = cscc.keyDown; //Modified by we:willRockYou - renamed to CMoptions
+      CMoptions.keyUpFunction = cscc.keyUp; //Modified by we:willRockYou - renamed to CMoptions
     }
-    cscc.editor = CodeMirror.fromTextArea(textareaId, options);
+    cscc.editor = CodeMirror.fromTextArea(textareaId, CMoptions); //Modified by we:willRockYou - renamed to CMoptions
   },
 
   cursorActivity: function(elAtCursor) {
@@ -65,7 +58,10 @@ var cscc = {
     var style = document.createElement('style');
     var cssStr = [
       "#cmc-suggestions",
-      "{",
+      "{",
+      "  max-height: 203px;", //added by we:willRockYou - we need a maximum height
+      "  overflow-y: auto;", //added by we:willRockYou - and therefor we need a scrollbar as well
+      "  overflow-x: hidden;", //added by we:willRockYou
       "  margin-top: 12px;",
       "  position: absolute;",
       "  z-index: 999;        ",
@@ -81,7 +77,8 @@ var cscc = {
       "}",
       "#cmc-suggestions div      ",
       "{",
-      "  padding: 2px 5px;",
+      "  padding: 2px 5px;",
+      "  padding-right: 20px;", //added by we:willRockYou - now with overflow-y:auto we might have a scrolbar. this makes room for it
       "}",
       "#cmc-suggestions div.selected",
       "{",
@@ -99,7 +96,11 @@ var cscc = {
     document.body.appendChild(style);
   },
 
-  keyDown: function(evt, select, editor) {
+  keyDown: function(evt, select, editor) {
+    cscc.selectX=select; //added by we:willRockYou - we need this in onclick-event. I know, doesn't look pretty. didn't know how to get these objects, but they are out here somewhere, I'm sure!
+    cscc.editorX=editor; //added by we:willRockYou
+    top.currentHoveredTag=undefined; //added by we:willRockYou - we need to hide our tooltip on keypress
+    hideDescription(); //added by we:willRockYou - we need to hide our tooltip on keypress
     var l = cscc.getCursorInfo();
     var text = l.text.substr(0, l.pos);
     var startPos = text.lastIndexOf("<");
@@ -144,7 +145,7 @@ var cscc = {
 
     // get the tagName that we're in
     text = text.substr(startPos + 1);
-    var tagName = text.replace(/^([\w\._\-]+).*$/, "$1");
+    var tagName = text.replace(/^([\w\._\-:]+).*$/, "$1"); //modified by we:willRockYou to match namespaced tags
 
     // ">" pressed, check for autoclosing the tag
     if (evt.shiftKey && evt.keyCode == 190) {
@@ -318,7 +319,22 @@ var cscc = {
 
     // add the items, and take into account the prev selected item
     for (var i = 0; i < items.length; i++) {
-      var el = root.ownerDocument.createElement("div");
+      var el = root.ownerDocument.createElement("div");
+      el.onclick=function(e) { //added by we:willRockYou, enables clicking on an item
+      	var results = cscc.getSuggestionsElement().getElementsByTagName("div");
+      	var selectedIndex = -1;
+      	for (var i = 0; i < results.length; i++) {
+	        var result = results[i];
+      	  if (result.className.indexOf("selected") != -1) {
+	          selectedIndex = i;
+      	    result.className = "";
+	        }
+      	}
+      	e.target.className="selected";
+      	cscc.selected = e.target;
+      	cscc.pick(e,cscc.selectX, cscc.editorX);
+      	document.getElementById("editarea").nextSibling.getElementsByTagName('iframe')[0].contentWindow.focus();
+      }
       var value = items[i].replace(/\|/, "");
       el.setAttribute("rel", items[i]);
       el.innerHTML = value;
@@ -348,20 +364,12 @@ var cscc = {
       el = cm.nthLine(line + 1);
       offsetTop = -26;
     }
-    // hardcode height
-    var top = (line - 2) * 16;
-    var scrollOffsetTop = cscc.editor.win.document.body.scrollTop;
-    var scrollOffsetLeft = cscc.editor.win.document.body.scrollLeft;
-    offsetTop = 5 - scrollOffsetTop;
-
+    // following lines modified by we:willRockYou - CodeMirror now has it's own methods to get cursorCoords()!
     var el = cscc.getSuggestionsElement();
     el.style.display = "block";
     el.setAttribute("size", items.length);
-    el.style.top = (top + 18 + offsetTop) + "px";
-    var left = cscc.visible ? cscc.currentLeft : ((pos + 1) * 8);
-    left -= scrollOffsetLeft;
-    cscc.currentLeft = left;
-    el.style.left = left + "px";
+    el.style.top = cscc.editor.cursorCoords().y-5 + "px";
+    el.style.left = cscc.editor.cursorCoords().x-7 + "px";
     cscc.visible = true;
     if (!cscc.selected)
       cscc.next();
@@ -436,7 +444,10 @@ var cscc = {
       selectedIndex = 0;
     if (results[selectedIndex]) {
       cscc.selected = results[selectedIndex];
-      results[selectedIndex].className = "selected";
+      results[selectedIndex].className = "selected";
+      if(results[selectedIndex].scrollIntoView) { //added by we:willRockYou - will scroll selected item into viewport. the div has now overflow-y:auto, so the currently selected item might be outside of viewport
+        results[selectedIndex].scrollIntoView();
+      }
     }
   },
 
@@ -458,6 +469,9 @@ var cscc = {
     if (results[selectedIndex]) {
       cscc.selected = results[selectedIndex];
       results[selectedIndex].className = "selected";
+    }
+    if(results[selectedIndex].scrollIntoView) { //added by we:willRockYou - will scroll selected item into viewport. the div has now overflow-y:auto, so the currently selected item might be outside of viewport
+      results[selectedIndex].scrollIntoView();
     }
   },
 
