Property changes on: trunk/extensions/SemanticForms/languages/SF_Namespaces.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 1 | + native |
Index: trunk/extensions/VisualEditor/demos/playground/playground.js |
— | — | @@ -1,228 +1,228 @@ |
2 | | -app = function () {
|
3 | | - var _this = this,
|
4 | | - $document = $( document );
|
5 | | -
|
6 | | - this.$editor = $('#editor');
|
7 | | -
|
8 | | - this.$editor.bind( {
|
9 | | - 'focus': function( e ) {
|
10 | | - $document.unbind( '.surfaceView' );
|
11 | | - $document.bind( {
|
12 | | - 'keydown.surfaceView': function( e ) {
|
13 | | - return _this.onKeyDown( e );
|
14 | | - },
|
15 | | - 'keyup.surfaceView': function( e ) {
|
16 | | - return _this.onKeyUp( e );
|
17 | | - },
|
18 | | - 'keypress.surfaceView': function( e ) {
|
19 | | - return _this.onKeyPress( e );
|
20 | | - }
|
21 | | - } );
|
22 | | - },
|
23 | | - 'blur': function( e ) {
|
24 | | - $document.unbind( '.surfaceView' );
|
25 | | - }
|
26 | | - } );
|
27 | | -
|
28 | | - document.addEventListener( 'compositionstart', function( e ) {
|
29 | | - _this.onCompositionStart( e );
|
30 | | - } );
|
31 | | - document.addEventListener( 'compositionend', function( e ) {
|
32 | | - _this.onCompositionEnd( e );
|
33 | | - } );
|
34 | | -
|
35 | | - this.$editor.mousedown( function(e) {
|
36 | | - return _this.onMouseDown( e );
|
37 | | - } );
|
38 | | -
|
39 | | - // Set initial content for the "editor"
|
40 | | -// this.$editor.html("<b>Lorem Ipsum is simply dummy text</b> of the printing and typesetting industry. <b>Lorem Ipsum has been the <i>industry's</i> standard</b> dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it <u>to <b>make <i>a type</i> specimen</b> book.</u>... New text...");
|
41 | | - this.$editor.html("Ipsum <b>New book me<i>ss</i>age is good</b> Lorem");
|
42 | | -// this.$editor.html("... <b>w</b>");
|
43 | | - this.$editor.addClass('leafNode');
|
44 | | -
|
45 | | - this.prevText = app.getDOMText2(this.$editor[0]);
|
46 | | - this.prevHash = app.getDOMHash(this.$editor[0]);
|
47 | | - this.prevOffset = null;
|
48 | | - this.inIME = false;
|
49 | | -
|
50 | | - setInterval(function() {
|
51 | | - _this.loopFunc();
|
52 | | - }, 100);
|
53 | | -};
|
54 | | -
|
55 | | -app.prototype.onCompositionStart = function( e ) {
|
56 | | - console.log('inIME', true);
|
57 | | - this.inIME = true;
|
58 | | -};
|
59 | | -
|
60 | | -app.prototype.onCompositionEnd = function( e ) {
|
61 | | - console.log('inIME', false);
|
62 | | - this.inIME = false;
|
63 | | -};
|
64 | | -
|
65 | | -app.prototype.onKeyDown = function( e ) {
|
66 | | -};
|
67 | | -
|
68 | | -app.prototype.onKeyUp = function( e ) {
|
69 | | -};
|
70 | | -
|
71 | | -app.prototype.onKeyPress = function( e ) {
|
72 | | -};
|
73 | | -
|
74 | | -app.prototype.onMouseDown = function( e ) {
|
75 | | -};
|
76 | | -
|
77 | | -app.prototype.loopFunc = function() {
|
78 | | - var selection = rangy.getSelection();
|
79 | | -
|
80 | | - if ( !selection.anchorNode || selection.anchorNode.nodeName === 'BODY' ) {
|
81 | | - return;
|
82 | | - }
|
83 | | -
|
84 | | - if ( this.inIME === true ) {
|
85 | | - return;
|
86 | | - }
|
87 | | -
|
88 | | - var text = app.getDOMText2( this.$editor[0] ),
|
89 | | - hash = app.getDOMHash( this.$editor[0] ),
|
90 | | - offset = ( selection.anchorNode === selection.focusNode && selection.anchorOffset === selection.focusOffset ) ? this.getOffset( selection.anchorNode, selection.anchorOffset ) : null;
|
91 | | -
|
92 | | - if ( text !== this.prevText ) {
|
93 | | -
|
94 | | - var lengthDiff = text.length - this.prevText.length,
|
95 | | - offsetDiff = offset - this.prevOffset;
|
96 | | -
|
97 | | - if ( lengthDiff === offsetDiff && offset !== null && this.prevOffset !== null && this.prevText.substring( 0, this.prevOffset ) === text.substring( 0, this.prevOffset ) ) {
|
98 | | - console.log("new text", text.substring( this.prevOffset, offset ), this.prevOffset);
|
99 | | - } else {
|
100 | | - var sameFromLeft = 0,
|
101 | | - sameFromRight = 0,
|
102 | | - l = text.length > this.prevText.length ? this.prevText.length : text.length;
|
103 | | -
|
104 | | - while ( sameFromLeft < l && this.prevText[sameFromLeft] == text[sameFromLeft] ) {
|
105 | | - ++sameFromLeft;
|
106 | | - }
|
107 | | - l = l - sameFromLeft;
|
108 | | - while ( sameFromRight < l && this.prevText[this.prevText.length - 1 - sameFromRight] == text[text.length - 1 - sameFromRight] ) {
|
109 | | - ++sameFromRight;
|
110 | | - }
|
111 | | - console.log('sameFromLeft', sameFromLeft);
|
112 | | - console.log('sameFromRight', sameFromRight);
|
113 | | - console.log('to delete', this.prevText.substring( sameFromLeft, this.prevText.length - sameFromRight), sameFromLeft );
|
114 | | - console.log('to insert', text.substring( sameFromLeft, text.length - sameFromRight ), sameFromLeft );
|
115 | | - }
|
116 | | - this.prevText = text;
|
117 | | - }
|
118 | | -
|
119 | | - if ( hash !== this.prevHash ) {
|
120 | | - console.log("DOM hash is different");
|
121 | | - this.prevHash = hash;
|
122 | | - }
|
123 | | -
|
124 | | - this.prevOffset = offset;
|
125 | | -
|
126 | | -};
|
127 | | -
|
128 | | -app.getDOMText2 = function( elem ) {
|
129 | | - var regex = new RegExp("[" + String.fromCharCode(32) + String.fromCharCode(160) + "]", "g");
|
130 | | - return app.getDOMText( elem ).replace( regex, " " );
|
131 | | -};
|
132 | | -
|
133 | | -app.getDOMText = function( elem ) {
|
134 | | - var nodeType = elem.nodeType,
|
135 | | - ret = '';
|
136 | | -
|
137 | | - if ( nodeType === 1 || nodeType === 9 ) {
|
138 | | - // Use textContent || innerText for elements
|
139 | | - if ( typeof elem.textContent === 'string' ) {
|
140 | | - return elem.textContent;
|
141 | | - } else if ( typeof elem.innerText === 'string' ) {
|
142 | | - // Replace IE's carriage returns
|
143 | | - return elem.innerText.replace( /\r\n/g, '' );
|
144 | | - } else {
|
145 | | - // Traverse it's children
|
146 | | - for ( elem = elem.firstChild; elem; elem = elem.nextSibling) {
|
147 | | - ret += app.getDOMText( elem );
|
148 | | - }
|
149 | | - }
|
150 | | - } else if ( nodeType === 3 || nodeType === 4 ) {
|
151 | | - return elem.nodeValue;
|
152 | | - }
|
153 | | -
|
154 | | - return ret;
|
155 | | -};
|
156 | | -
|
157 | | -app.getDOMHash = function( elem ) {
|
158 | | - var nodeType = elem.nodeType,
|
159 | | - nodeName = elem.nodeName,
|
160 | | - ret = '';
|
161 | | -
|
162 | | - if ( nodeType === 3 || nodeType === 4 ) {
|
163 | | - return '#';
|
164 | | - } else if ( nodeType === 1 || nodeType === 9 ) {
|
165 | | - ret += '<' + nodeName + '>';
|
166 | | - for ( elem = elem.firstChild; elem; elem = elem.nextSibling) {
|
167 | | - ret += app.getDOMHash( elem );
|
168 | | - }
|
169 | | - ret += '</' + nodeName + '>';
|
170 | | - }
|
171 | | - return ret;
|
172 | | -};
|
173 | | -
|
174 | | -app.prototype.getOffset = function( localNode, localOffset ) {
|
175 | | - var $node = $( localNode );
|
176 | | -
|
177 | | - if ( $node.hasClass( 'leafNode' ) ) {
|
178 | | - return localOffset;
|
179 | | - }
|
180 | | -
|
181 | | - while( !$node.hasClass( 'leafNode' ) ) {
|
182 | | - $node = $node.parent();
|
183 | | - }
|
184 | | -
|
185 | | - var current = [$node.contents(), 0];
|
186 | | - var stack = [current];
|
187 | | -
|
188 | | - var offset = 0;
|
189 | | -
|
190 | | - while ( stack.length > 0 ) {
|
191 | | - if ( current[1] >= current[0].length ) {
|
192 | | - stack.pop();
|
193 | | - current = stack[ stack.length - 1 ];
|
194 | | - continue;
|
195 | | - }
|
196 | | - var item = current[0][current[1]];
|
197 | | - var $item = current[0].eq( current[1] );
|
198 | | -
|
199 | | - if ( item.nodeType === 3 ) {
|
200 | | - if ( item === localNode ) {
|
201 | | - offset += localOffset;
|
202 | | - break;
|
203 | | - } else {
|
204 | | - offset += item.textContent.length;
|
205 | | - }
|
206 | | - } else if ( item.nodeType === 1 ) {
|
207 | | - if ( $( item ).attr('contentEditable') === "false" ) {
|
208 | | - offset += 1;
|
209 | | - } else {
|
210 | | - if ( item === localNode ) {
|
211 | | - offset += localOffset;
|
212 | | - break;
|
213 | | - }
|
214 | | -
|
215 | | - stack.push( [$item.contents(), 0] );
|
216 | | - current[1]++;
|
217 | | - current = stack[stack.length-1];
|
218 | | - continue;
|
219 | | - }
|
220 | | - }
|
221 | | - current[1]++;
|
222 | | - }
|
223 | | -
|
224 | | - return offset;
|
225 | | -};
|
226 | | -
|
227 | | -$(function() {
|
228 | | - new app();
|
| 2 | +app = function () { |
| 3 | + var _this = this, |
| 4 | + $document = $( document ); |
| 5 | + |
| 6 | + this.$editor = $('#editor'); |
| 7 | + |
| 8 | + this.$editor.bind( { |
| 9 | + 'focus': function( e ) { |
| 10 | + $document.unbind( '.surfaceView' ); |
| 11 | + $document.bind( { |
| 12 | + 'keydown.surfaceView': function( e ) { |
| 13 | + return _this.onKeyDown( e ); |
| 14 | + }, |
| 15 | + 'keyup.surfaceView': function( e ) { |
| 16 | + return _this.onKeyUp( e ); |
| 17 | + }, |
| 18 | + 'keypress.surfaceView': function( e ) { |
| 19 | + return _this.onKeyPress( e ); |
| 20 | + } |
| 21 | + } ); |
| 22 | + }, |
| 23 | + 'blur': function( e ) { |
| 24 | + $document.unbind( '.surfaceView' ); |
| 25 | + } |
| 26 | + } ); |
| 27 | + |
| 28 | + document.addEventListener( 'compositionstart', function( e ) { |
| 29 | + _this.onCompositionStart( e ); |
| 30 | + } ); |
| 31 | + document.addEventListener( 'compositionend', function( e ) { |
| 32 | + _this.onCompositionEnd( e ); |
| 33 | + } ); |
| 34 | + |
| 35 | + this.$editor.mousedown( function(e) { |
| 36 | + return _this.onMouseDown( e ); |
| 37 | + } ); |
| 38 | + |
| 39 | + // Set initial content for the "editor" |
| 40 | +// this.$editor.html("<b>Lorem Ipsum is simply dummy text</b> of the printing and typesetting industry. <b>Lorem Ipsum has been the <i>industry's</i> standard</b> dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it <u>to <b>make <i>a type</i> specimen</b> book.</u>... New text..."); |
| 41 | + this.$editor.html("Ipsum <b>New book me<i>ss</i>age is good</b> Lorem"); |
| 42 | +// this.$editor.html("... <b>w</b>"); |
| 43 | + this.$editor.addClass('leafNode'); |
| 44 | + |
| 45 | + this.prevText = app.getDOMText2(this.$editor[0]); |
| 46 | + this.prevHash = app.getDOMHash(this.$editor[0]); |
| 47 | + this.prevOffset = null; |
| 48 | + this.inIME = false; |
| 49 | + |
| 50 | + setInterval(function() { |
| 51 | + _this.loopFunc(); |
| 52 | + }, 100); |
| 53 | +}; |
| 54 | + |
| 55 | +app.prototype.onCompositionStart = function( e ) { |
| 56 | + console.log('inIME', true); |
| 57 | + this.inIME = true; |
| 58 | +}; |
| 59 | + |
| 60 | +app.prototype.onCompositionEnd = function( e ) { |
| 61 | + console.log('inIME', false); |
| 62 | + this.inIME = false; |
| 63 | +}; |
| 64 | + |
| 65 | +app.prototype.onKeyDown = function( e ) { |
| 66 | +}; |
| 67 | + |
| 68 | +app.prototype.onKeyUp = function( e ) { |
| 69 | +}; |
| 70 | + |
| 71 | +app.prototype.onKeyPress = function( e ) { |
| 72 | +}; |
| 73 | + |
| 74 | +app.prototype.onMouseDown = function( e ) { |
| 75 | +}; |
| 76 | + |
| 77 | +app.prototype.loopFunc = function() { |
| 78 | + var selection = rangy.getSelection(); |
| 79 | + |
| 80 | + if ( !selection.anchorNode || selection.anchorNode.nodeName === 'BODY' ) { |
| 81 | + return; |
| 82 | + } |
| 83 | + |
| 84 | + if ( this.inIME === true ) { |
| 85 | + return; |
| 86 | + } |
| 87 | + |
| 88 | + var text = app.getDOMText2( this.$editor[0] ), |
| 89 | + hash = app.getDOMHash( this.$editor[0] ), |
| 90 | + offset = ( selection.anchorNode === selection.focusNode && selection.anchorOffset === selection.focusOffset ) ? this.getOffset( selection.anchorNode, selection.anchorOffset ) : null; |
| 91 | + |
| 92 | + if ( text !== this.prevText ) { |
| 93 | + |
| 94 | + var lengthDiff = text.length - this.prevText.length, |
| 95 | + offsetDiff = offset - this.prevOffset; |
| 96 | + |
| 97 | + if ( lengthDiff === offsetDiff && offset !== null && this.prevOffset !== null && this.prevText.substring( 0, this.prevOffset ) === text.substring( 0, this.prevOffset ) ) { |
| 98 | + console.log("new text", text.substring( this.prevOffset, offset ), this.prevOffset); |
| 99 | + } else { |
| 100 | + var sameFromLeft = 0, |
| 101 | + sameFromRight = 0, |
| 102 | + l = text.length > this.prevText.length ? this.prevText.length : text.length; |
| 103 | + |
| 104 | + while ( sameFromLeft < l && this.prevText[sameFromLeft] == text[sameFromLeft] ) { |
| 105 | + ++sameFromLeft; |
| 106 | + } |
| 107 | + l = l - sameFromLeft; |
| 108 | + while ( sameFromRight < l && this.prevText[this.prevText.length - 1 - sameFromRight] == text[text.length - 1 - sameFromRight] ) { |
| 109 | + ++sameFromRight; |
| 110 | + } |
| 111 | + console.log('sameFromLeft', sameFromLeft); |
| 112 | + console.log('sameFromRight', sameFromRight); |
| 113 | + console.log('to delete', this.prevText.substring( sameFromLeft, this.prevText.length - sameFromRight), sameFromLeft ); |
| 114 | + console.log('to insert', text.substring( sameFromLeft, text.length - sameFromRight ), sameFromLeft ); |
| 115 | + } |
| 116 | + this.prevText = text; |
| 117 | + } |
| 118 | + |
| 119 | + if ( hash !== this.prevHash ) { |
| 120 | + console.log("DOM hash is different"); |
| 121 | + this.prevHash = hash; |
| 122 | + } |
| 123 | + |
| 124 | + this.prevOffset = offset; |
| 125 | + |
| 126 | +}; |
| 127 | + |
| 128 | +app.getDOMText2 = function( elem ) { |
| 129 | + var regex = new RegExp("[" + String.fromCharCode(32) + String.fromCharCode(160) + "]", "g"); |
| 130 | + return app.getDOMText( elem ).replace( regex, " " ); |
| 131 | +}; |
| 132 | + |
| 133 | +app.getDOMText = function( elem ) { |
| 134 | + var nodeType = elem.nodeType, |
| 135 | + ret = ''; |
| 136 | + |
| 137 | + if ( nodeType === 1 || nodeType === 9 ) { |
| 138 | + // Use textContent || innerText for elements |
| 139 | + if ( typeof elem.textContent === 'string' ) { |
| 140 | + return elem.textContent; |
| 141 | + } else if ( typeof elem.innerText === 'string' ) { |
| 142 | + // Replace IE's carriage returns |
| 143 | + return elem.innerText.replace( /\r\n/g, '' ); |
| 144 | + } else { |
| 145 | + // Traverse it's children |
| 146 | + for ( elem = elem.firstChild; elem; elem = elem.nextSibling) { |
| 147 | + ret += app.getDOMText( elem ); |
| 148 | + } |
| 149 | + } |
| 150 | + } else if ( nodeType === 3 || nodeType === 4 ) { |
| 151 | + return elem.nodeValue; |
| 152 | + } |
| 153 | + |
| 154 | + return ret; |
| 155 | +}; |
| 156 | + |
| 157 | +app.getDOMHash = function( elem ) { |
| 158 | + var nodeType = elem.nodeType, |
| 159 | + nodeName = elem.nodeName, |
| 160 | + ret = ''; |
| 161 | + |
| 162 | + if ( nodeType === 3 || nodeType === 4 ) { |
| 163 | + return '#'; |
| 164 | + } else if ( nodeType === 1 || nodeType === 9 ) { |
| 165 | + ret += '<' + nodeName + '>'; |
| 166 | + for ( elem = elem.firstChild; elem; elem = elem.nextSibling) { |
| 167 | + ret += app.getDOMHash( elem ); |
| 168 | + } |
| 169 | + ret += '</' + nodeName + '>'; |
| 170 | + } |
| 171 | + return ret; |
| 172 | +}; |
| 173 | + |
| 174 | +app.prototype.getOffset = function( localNode, localOffset ) { |
| 175 | + var $node = $( localNode ); |
| 176 | + |
| 177 | + if ( $node.hasClass( 'leafNode' ) ) { |
| 178 | + return localOffset; |
| 179 | + } |
| 180 | + |
| 181 | + while( !$node.hasClass( 'leafNode' ) ) { |
| 182 | + $node = $node.parent(); |
| 183 | + } |
| 184 | + |
| 185 | + var current = [$node.contents(), 0]; |
| 186 | + var stack = [current]; |
| 187 | + |
| 188 | + var offset = 0; |
| 189 | + |
| 190 | + while ( stack.length > 0 ) { |
| 191 | + if ( current[1] >= current[0].length ) { |
| 192 | + stack.pop(); |
| 193 | + current = stack[ stack.length - 1 ]; |
| 194 | + continue; |
| 195 | + } |
| 196 | + var item = current[0][current[1]]; |
| 197 | + var $item = current[0].eq( current[1] ); |
| 198 | + |
| 199 | + if ( item.nodeType === 3 ) { |
| 200 | + if ( item === localNode ) { |
| 201 | + offset += localOffset; |
| 202 | + break; |
| 203 | + } else { |
| 204 | + offset += item.textContent.length; |
| 205 | + } |
| 206 | + } else if ( item.nodeType === 1 ) { |
| 207 | + if ( $( item ).attr('contentEditable') === "false" ) { |
| 208 | + offset += 1; |
| 209 | + } else { |
| 210 | + if ( item === localNode ) { |
| 211 | + offset += localOffset; |
| 212 | + break; |
| 213 | + } |
| 214 | + |
| 215 | + stack.push( [$item.contents(), 0] ); |
| 216 | + current[1]++; |
| 217 | + current = stack[stack.length-1]; |
| 218 | + continue; |
| 219 | + } |
| 220 | + } |
| 221 | + current[1]++; |
| 222 | + } |
| 223 | + |
| 224 | + return offset; |
| 225 | +}; |
| 226 | + |
| 227 | +$(function() { |
| 228 | + new app(); |
229 | 229 | }); |
\ No newline at end of file |
Property changes on: trunk/extensions/VisualEditor/demos/playground/playground.js |
___________________________________________________________________ |
Added: svn:eol-style |
230 | 230 | + native |
Index: trunk/extensions/VisualEditor/demos/playground/index.html |
— | — | @@ -1,21 +1,21 @@ |
2 | | -<!DOCTYPE html>
|
3 | | -
|
4 | | -<html>
|
5 | | - <head>
|
6 | | - <title>Playground</title>
|
7 | | - <style>
|
8 | | - #editor {
|
9 | | - width: 300px;
|
10 | | - height: 300px;
|
11 | | - border: solid 1px;
|
12 | | - }
|
13 | | - </style>
|
14 | | - <script src="../../modules/jquery/jquery.js"></script>
|
15 | | - <script src="../../modules/rangy/rangy-core.js"></script>
|
16 | | - <script src="playground.js"></script>
|
17 | | - </head>
|
18 | | - <body>
|
19 | | - <div contenteditable="true" id="editor">
|
20 | | - </div>
|
21 | | - </body>
|
22 | | -</html>
|
| 2 | +<!DOCTYPE html> |
| 3 | + |
| 4 | +<html> |
| 5 | + <head> |
| 6 | + <title>Playground</title> |
| 7 | + <style> |
| 8 | + #editor { |
| 9 | + width: 300px; |
| 10 | + height: 300px; |
| 11 | + border: solid 1px; |
| 12 | + } |
| 13 | + </style> |
| 14 | + <script src="../../modules/jquery/jquery.js"></script> |
| 15 | + <script src="../../modules/rangy/rangy-core.js"></script> |
| 16 | + <script src="playground.js"></script> |
| 17 | + </head> |
| 18 | + <body> |
| 19 | + <div contenteditable="true" id="editor"> |
| 20 | + </div> |
| 21 | + </body> |
| 22 | +</html> |
Property changes on: trunk/extensions/VisualEditor/demos/playground/index.html |
___________________________________________________________________ |
Added: svn:eol-style |
23 | 23 | + native |
Property changes on: trunk/extensions/MobileFrontend/tests/js/test_banner.js |
___________________________________________________________________ |
Added: svn:eol-style |
24 | 24 | + native |
Property changes on: trunk/extensions/MobileFrontend/javascripts/banner.js |
___________________________________________________________________ |
Added: svn:eol-style |
25 | 25 | + native |