Index: trunk/parsers/wikidom/lib/es/es.Document.js |
— | — | @@ -48,7 +48,8 @@ |
49 | 49 | /** |
50 | 50 | * Adds a block to the document after an existing block. |
51 | 51 | * |
52 | | - * @param {Block} Block to insert |
| 52 | + * @param block {Block} Block to insert |
| 53 | + * @param before {Block} Block to insert before, if null then block will be inserted at the end |
53 | 54 | */ |
54 | 55 | Document.prototype.insertBlockBefore = function( block, before ) { |
55 | 56 | block.document = this; |
Index: trunk/parsers/wikidom/lib/es/es.js |
— | — | @@ -23,7 +23,7 @@ |
24 | 24 | var base = new src(); |
25 | 25 | for ( i in base ) { |
26 | 26 | if ( typeof base[i] === 'function' ) { |
27 | | - dst.prototype[i] = base.prototype[i]; |
| 27 | + dst.prototype[i] = base[i]; |
28 | 28 | } |
29 | 29 | } |
30 | 30 | } |
Index: trunk/parsers/wikidom/lib/es/es.Surface.css |
— | — | @@ -0,0 +1,49 @@ |
| 2 | +body { |
| 3 | + font-family: "Arial"; |
| 4 | + font-size: 0.8em; |
| 5 | +} |
| 6 | + |
| 7 | +.editSurface-container { |
| 8 | + position: absolute; |
| 9 | + left: 3%; |
| 10 | + width: 45%; |
| 11 | + border: solid 1px red; |
| 12 | + cursor: text; |
| 13 | +} |
| 14 | + |
| 15 | +.editSurface-paragraph { |
| 16 | + padding: 2em; |
| 17 | +} |
| 18 | + |
| 19 | +.editSurface-line { |
| 20 | + display: inline-block; |
| 21 | + height: 1.5em; |
| 22 | + line-height: 1.5em; |
| 23 | + cursor: text; |
| 24 | + white-space: nowrap; |
| 25 | +} |
| 26 | + |
| 27 | +.editSurface-line.empty { |
| 28 | + display: block; |
| 29 | + width: 0px; |
| 30 | +} |
| 31 | + |
| 32 | +.editSurface-line .editSurface-whitespace { |
| 33 | + color: #888888; |
| 34 | + padding: 0 0.25em; |
| 35 | +} |
| 36 | + |
| 37 | +.editSurface-range { |
| 38 | + display: none; |
| 39 | + position: absolute; |
| 40 | + background-color: Highlight; |
| 41 | + cursor: text; |
| 42 | +} |
| 43 | + |
| 44 | +.editSurface-cursor { |
| 45 | + position: absolute; |
| 46 | + background-color: black; |
| 47 | + width: 1px; |
| 48 | + height: 1.5em; |
| 49 | + display: none; |
| 50 | +} |
Property changes on: trunk/parsers/wikidom/lib/es/es.Surface.css |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 51 | + native |
Added: svn:mime-type |
2 | 52 | + text/plain |
Index: trunk/parsers/wikidom/lib/es/es.Surface.js |
— | — | @@ -7,6 +7,7 @@ |
8 | 8 | function Surface( $container, document ) { |
9 | 9 | this.$container = $container; |
10 | 10 | this.document = document; |
| 11 | + this.reflow(); |
11 | 12 | } |
12 | 13 | |
13 | 14 | /** |
— | — | @@ -167,5 +168,9 @@ |
168 | 169 | * @param from Location: Where to start re-flowing from (optional) |
169 | 170 | */ |
170 | 171 | Surface.prototype.reflow = function( from ) { |
171 | | - // |
| 172 | + this.$container.empty(); |
| 173 | + for ( var i = 0; i < this.document.blocks.length; i++ ) { |
| 174 | + $block = $( '<div></div>' ).appendTo( this.$container ); |
| 175 | + this.document.blocks[i].renderContent( $block ); |
| 176 | + } |
172 | 177 | }; |
Index: trunk/parsers/wikidom/lib/es/es.Block.js |
— | — | @@ -3,7 +3,7 @@ |
4 | 4 | * @returns {Block} |
5 | 5 | */ |
6 | 6 | function Block() { |
7 | | - this.document = document; |
| 7 | + this.document = null; |
8 | 8 | } |
9 | 9 | |
10 | 10 | /** |
— | — | @@ -12,6 +12,9 @@ |
13 | 13 | * @returns {Integer} Index of block |
14 | 14 | */ |
15 | 15 | Block.prototype.index = function() { |
| 16 | + if ( !this.document ) { |
| 17 | + throw 'Missing document error. Block is not attached to a document.'; |
| 18 | + } |
16 | 19 | return this.document.blocks.indexOf( this ); |
17 | 20 | }; |
18 | 21 | |
— | — | @@ -21,6 +24,9 @@ |
22 | 25 | * @returns {Block|Null} Block directly proceeding this one, or null if none exists |
23 | 26 | */ |
24 | 27 | Block.prototype.nextBlock = function() { |
| 28 | + if ( !this.document ) { |
| 29 | + throw 'Missing document error. Block is not attached to a document.'; |
| 30 | + } |
25 | 31 | var index = this.index() + 1; |
26 | 32 | return this.document.blocks.length < index ? this.document.blocks[index] : null; |
27 | 33 | }; |
— | — | @@ -31,6 +37,9 @@ |
32 | 38 | * @returns {Block|Null} Block directly preceding this one, or null if none exists |
33 | 39 | */ |
34 | 40 | Block.prototype.previousBlock = function() { |
| 41 | + if ( !this.document ) { |
| 42 | + throw 'Missing document error. Block is not attached to a document.'; |
| 43 | + } |
35 | 44 | var index = this.index() - 1; |
36 | 45 | return index >= 0 ? this.document.blocks[index] : null; |
37 | 46 | }; |
Index: trunk/parsers/wikidom/lib/es/es.TextFlow.js |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | TextFlow.prototype.render = function( $container, text ) { |
10 | 10 | //console.time( 'TextFlow.render' ); |
11 | 11 | var metrics = [], |
12 | | - $ruler = $( '<div class="editSurface-line"></div>' ).appendTo( $(this) ), |
| 12 | + $ruler = $( '<div class="editSurface-line"></div>' ).appendTo( $container ), |
13 | 13 | $line = $( '<div class="editSurface-line"></div>' ), |
14 | 14 | lines = this.getLines( this.getWords( text, $ruler[0] ), $ruler.innerWidth() ); |
15 | 15 | $container.empty(); |
— | — | @@ -20,14 +20,14 @@ |
21 | 21 | $container.append( $line.clone().html( lines[i].html ) ); |
22 | 22 | } |
23 | 23 | } |
24 | | - //console.timeEnd( 'TextFlow.render' ); |
25 | | - return metrics; |
| 24 | + console.timeEnd( 'TextFlow.render' ); |
| 25 | + //return metrics; |
26 | 26 | }; |
27 | 27 | |
28 | 28 | TextFlow.prototype.getWord = function( text, ruler ) { |
29 | 29 | var word = { |
30 | 30 | 'text': text, |
31 | | - 'html': word.text |
| 31 | + 'html': text |
32 | 32 | .replace( /&/g, '&' ) |
33 | 33 | .replace( / /g, ' ' ) |
34 | 34 | .replace( /</g, '<' ) |
— | — | @@ -35,7 +35,7 @@ |
36 | 36 | .replace( /'/g, ''' ) |
37 | 37 | .replace( /"/g, '"' ) |
38 | 38 | .replace( /\n/g, '<span class="editSurface-whitespace">\\n</span>' ) |
39 | | - .replace( /\t/g, '<span class="editSurface-whitespace">\\t</span>' ); |
| 39 | + .replace( /\t/g, '<span class="editSurface-whitespace">\\t</span>' ) |
40 | 40 | }; |
41 | 41 | ruler.innerHTML = word.html; |
42 | 42 | word.width = ruler.clientWidth; |
Index: trunk/parsers/wikidom/demos/es/index.html |
— | — | @@ -0,0 +1,45 @@ |
| 2 | +<!doctype html> |
| 3 | + |
| 4 | +<html> |
| 5 | + <head> |
| 6 | + <title>EditSurface Demo</title> |
| 7 | + <link rel="stylesheet" href="../../lib/es/es.Surface.css"> |
| 8 | + </head> |
| 9 | + <body> |
| 10 | + <h1>EditSurface Demo</h1> |
| 11 | + <div id="es"></div> |
| 12 | + |
| 13 | + <!-- EditSurface --> |
| 14 | + <script type="text/javascript" src="../../lib/jquery.js"></script> |
| 15 | + <script type="text/javascript" src="../../lib/es/es.js"></script> |
| 16 | + <script type="text/javascript" src="../../lib/es/es.Block.js"></script> |
| 17 | + <script type="text/javascript" src="../../lib/es/es.Document.js"></script> |
| 18 | + <script type="text/javascript" src="../../lib/es/es.Surface.js"></script> |
| 19 | + <script type="text/javascript" src="../../lib/es/es.TextFlow.js"></script> |
| 20 | + <script type="text/javascript" src="../../lib/es/es.ParagraphBlock.js"></script> |
| 21 | + |
| 22 | + <!-- Demo --> |
| 23 | + <script> |
| 24 | + $(document).ready( function() { |
| 25 | + var doc = new Document([ |
| 26 | + new ParagraphBlock([ |
| 27 | + { 'text': "In text display, line wrap is the feature of continuing on a new line when a line is full, such that each line fits in the viewable window, allowing text to be read from top to bottom without any horizontal scrolling." }, |
| 28 | + { 'text': "Word wrap is the additional feature of most text editors, word processors, and web browsers, of breaking lines between and not within words, except when a single word is longer than a line." }, |
| 29 | + { 'text': "It is usually done on the fly when viewing or printing a document, so no line break code is manually entered, or stored.[citation needed] If the user changes the margins, the editor will either automatically reposition the line breaks to ensure that all the text will \"flow\" within the margins and remain visible, or provide the typist some convenient way to reposition the line breaks." }, |
| 30 | + { 'text': "A soft return is the break resulting from line wrap or word wrap, whereas a hard return is an intentional break, creating a new paragraph." }, |
| 31 | + { 'text': "The soft returns are usually placed after the ends of complete words, or after the punctuation that follows complete words. However, word wrap may also occur following a hyphen." }, |
| 32 | + { 'text': "Word wrap following hyphens is sometimes not desired, and can be avoided by using a so-called non-breaking hyphen instead of a regular hyphen. On the other hand, when using word processors, invisible hyphens, called soft hyphens, can also be inserted inside words so that word wrap can occur following the soft hyphens." }, |
| 33 | + { 'text': "Sometimes, word wrap is not desirable between words. In such cases, word wrap can usually be avoided by using a hard space or non-breaking space between the words, instead of regular spaces." }, |
| 34 | + //{ 'text': "OccasionallyThereAreWordsThatAreSoLongTheyExceedTheWidthOfTheLineAndEndUpWrappingBetweenMultipleLines." }, |
| 35 | + { 'text': "Text might have \ttabs\t in it too." } |
| 36 | + ]) |
| 37 | + ]); |
| 38 | + var surface = new Surface( $('#es'), doc ); |
| 39 | + |
| 40 | + $(window).resize( function() { |
| 41 | + surface.reflow(); |
| 42 | + } ); |
| 43 | + } ); |
| 44 | + </script> |
| 45 | + </body> |
| 46 | +</html> |
Property changes on: trunk/parsers/wikidom/demos/es/index.html |
___________________________________________________________________ |
Added: svn:mime-type |
1 | 47 | + text/plain |