Changeset 28269
- Timestamp:
- 01/10/09 22:08:01 (4 years ago)
- Location:
- lang/javascript/nohada/js
- Files:
-
- 3 added
- 2 modified
-
Key.js (modified) (1 diff)
-
KeyCode.js (added)
-
Relation.class.js (added)
-
TextEditor.class.js (modified) (2 diffs)
-
TextEditorCommand.js (added)
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/nohada/js/Key.js
r28244 r28269 2 2 var t=new TextEditor("this\nis\na\nTest"); 3 3 TagBuilder.write(t); 4 document.onkeydown=function (e) {return t.processKeyEvent(e);} 4 initTextEditorCommand(t); 5 var st=tag("span"); 6 TagBuilder.write(st); 7 document.onkeydown=function (e) { 8 st.set(e.keyCode); 9 return t.processKeyDownEvent(e); 10 } 11 document.onkeyup=function (e) { 12 st.set(e.keyCode); 13 return t.processKeyUpEvent(e); 14 } 5 15 } 6 16 function start2() { -
lang/javascript/nohada/js/TextEditor.class.js
r28244 r28269 2 2 initialize: function (content) { 3 3 this.content=content+"\n"; 4 this.keyCommands={}; 5 this.shiftState=0; 4 6 }, 5 7 toHTML: function () { … … 31 33 var curSel=cursor.pos; 32 34 var n=this.createLetter(str); 33 curSel.prev.next=n; 34 n.prev=curSel.prev; 35 var p=curSel.prev; 36 if (p) { 37 p.next=n; 38 n.prev=p; 39 } 35 40 n.next=curSel; 36 41 curSel.prev=n; 37 42 curSel.insertBefore(n); 38 43 }, 39 processKeyEvent: function (e) { 40 switch (e.keyCode) { 41 case 39: this.cursor.forward(); 42 break; 43 case 37: this.cursor.back(); 44 break; 45 default: this.insertAt(""+String.fromCharCode(e.keyCode)); 46 } 47 return e.keyCode!=9; 44 addKeyCommand: function (keyCode,shiftState,command) { 45 this.keyCommands[keyCode+shiftState*256]=command; 46 }, 47 processShiftOffEvent: function (e,key,state) { 48 if (e.keyCode==key) { 49 this.shiftState&=~state; 50 } 51 }, 52 processKeyUpEvent: function (e) { 53 this.processShiftOffEvent(e,this.KEY_SHIFT,this.SS_SHIFT); 54 this.processShiftOffEvent(e,this.KEY_CTRL,this.SS_CTRL); 55 this.processShiftOffEvent(e,this.KEY_ALT,this.SS_ALT); 56 }, 57 processShiftOnEvent: function (e,key,state) { 58 if (e.keyCode==key) { 59 this.shiftState|=state; 60 } 61 }, 62 processKeyDownEvent: function (e) { 63 this.processShiftOnEvent(e,this.KEY_SHIFT,this.SS_SHIFT); 64 this.processShiftOnEvent(e,this.KEY_CTRL,this.SS_CTRL); 65 this.processShiftOnEvent(e,this.KEY_ALT,this.SS_ALT); 66 var f=this.keyCommands[e.keyCode+this.shiftState*256]; 67 if (f) return f.apply(this,[e]); 68 return true; 48 69 }, 49 70 createCursor: function () { 50 71 return new this.Cursor(this); 51 72 }, 73 KEY_SHIFT:16, 74 KEY_CTRL:17, 75 KEY_ALT:18, 76 SS_SHIFT: 1, 77 SS_CTRL: 2, 78 SS_ALT: 4, 52 79 Cursor: Class.create({ 53 80 initialize: function (textEditor) {
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)