Commits

benoitc  committed a9d8129

somehow textmate removed some escaped characters....

  • Participants
  • Parent commits 2703b65

Comments (0)

Files changed (1)

File jquery.textarea.js

 
     },
 
-    init_toolbar: function() {
-      $.each(this.toolbar, function() {
-
-      });
-    },
-
     saveRange: function(){
       this.range = document.selection.createRange();  
     },
       else
       return false;
     },
-
-      	
+	
     replaceSelection: function(text){
       var scroll_top = this.element.scrollTop;
       if(!!document.selection){
 
 
     handleKey: function(e) {
-      c = e.keyCode;
+      c = e.charCode || e.keyCode;
       if (c == 9) {
         e.preventDefault();
         this.tab_selection();
         pos_start = start + this.tabulation.length;
         pos_end = pos_start;
       } else {
-        start = Math.max(0, this.element.value.substr(0, start).lastIndexOf("n") + 1);
+        start = Math.max(0, this.element.value.substr(0, start).lastIndexOf("\n") + 1);
         endText = this.element.value.substr(end);
         startText = this.element;
         value.substr(0, start);
-        tmp = insText.split("n");
-        insText = this.tabulation + tmp.join("n" + this.tabulation);
+        tmp = insText.split("\n");
+        insText = this.tabulation + tmp.join("\n" + this.tabulation);
         this.el.val(startText + insText + endText);
         pos_start = start;
-        pos_end = this.element.value.indexOf("n", startText.length + insText.length);
+        pos_end = this.element.value.indexOf("\n", startText.length + insText.length);
         if (pos_end == -1)
         pos_end = this.element.value.length;
       }
       var end = this.element.selectionEnd;
 
       var start_last_line = Math.max(0, 
-        this.element.value.substring(0, start).lastIndexOf("n") + 1);
+        this.element.value.substring(0, start).lastIndexOf("\n") + 1);
 
       var latest_line = this.element.value.substring(start_last_line,
         start)
 
-      if (latest_line.match(/^[ t]+$/mg, ""))
+      if (latest_line.match(/^[ \t]+$/mg, ""))
         return false;
 
-      var begin_line = latest_line.replace(/^([ t]*).*/gm, "$1");
-      if (begin_line == "n" || begin_line == "r")
+      var begin_line = latest_line.replace(/^([ \t]*).*/gm, "$1");
+      if (begin_line == "\n" || begin_line == "\r")
         return false;
 
       if ( !! document.selection || this.isOpera) {
-        begin_line = "rn" + begin_line;
+        begin_line = "\rn" + begin_line;
       } else {
-        begin_line = "n" + begin_line;
+        begin_line = "\n" + begin_line;
       }
       this.element.value = this.element.value.substring(0, start) +
       begin_line + this.element.value.substring(end);
     },
 
     _detect_tab: function() {
-      if (this.element.value.indexOf("t") > 0) {
-        this.tabulation = "t";
+      if (this.element.value.indexOf("\t") > 0) {
+        this.tabulation = "\t";
       } else {
         this.tabulation = "";
         for (var i = 0; i < this.options.tab_char; i++)
 
     _setIESelection: function() {
       var nbLineStart = this.element.value.substr(0,
-        this.element.selectionStart).split("n").length - 1;
+        this.element.selectionStart).split("\n").length - 1;
       var nbLineEnd = this.element.value.substr(0,
-        this.element.selectionEnd).split("n").length - 1;
+        this.element.selectionEnd).split("\n").length - 1;
       var range = document.selection.createRange();
       range.moveToElementText(this.element);
       range.setEndPoint('EndToStart', range);
 
 });
 
-})(jQuery);
+})(jQuery);
+
+
+