Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

normalize spacing in range docs

  • Loading branch information...
commit 827c866d572fc92bc20f168cc134dd0ad387780a 1 parent f747dfd
Joshua Peek authored March 05, 2009

Showing 1 changed file with 59 additions and 44 deletions. Show diff stats Hide diff stats

  1. 103  src/wysihat/dom/range.js
103  src/wysihat/dom/range.js
... ...
@@ -1,12 +1,12 @@
1 1
 /** section: dom
2 2
  *  class Range
3 3
  *
4  
- * This document is work in progress. It implements W3C Range for browsers
5  
- * that do not support it natively like Internet Explorer. The implementation
6  
- * is cross-browser compatible but only gets binded if no W3C Range
7  
- * implementation exists.
  4
+ *  This document is work in progress. It implements W3C Range for browsers
  5
+ *  that do not support it natively like Internet Explorer. The implementation
  6
+ *  is cross-browser compatible but only gets binded if no W3C Range
  7
+ *  implementation exists.
8 8
  *
9  
- * Originally created by Jorgen Horstink <mail@jorgenhorstink.nl>
  9
+ *  Originally created by Jorgen Horstink <mail@jorgenhorstink.nl>
10 10
 **/
11 11
 
12 12
 if (typeof Range == 'undefined') {
@@ -41,18 +41,20 @@ if (typeof Range == 'undefined') {
41 41
 
42 42
   Object.extend(Range.prototype, (function() {
43 43
     /**
44  
-     * Range#cloneContents() -> DocumentFragment
  44
+     *  Range#cloneContents() -> DocumentFragment
  45
+     *
45 46
      *  Duplicates the contents of a Range
46  
-     **/
  47
+    **/
47 48
     function cloneContents() {
48 49
       return _processContents(this, Range.CLONE_CONTENTS);
49 50
     }
50 51
 
51 52
     /**
52  
-     * Range#cloneRange() -> Range
  53
+     *  Range#cloneRange() -> Range
  54
+     *
53 55
      *  Produces a new Range whose boundary-points are equal to the
54 56
      *  boundary-points of the Range.
55  
-     **/
  57
+    **/
56 58
     function cloneRange() {
57 59
       try {
58 60
         var clone = new Range(this.ownerDocument);
@@ -73,11 +75,12 @@ if (typeof Range == 'undefined') {
73 75
     }
74 76
 
75 77
     /**
76  
-     * Range#collapse(toStart) -> undefined
  78
+     *  Range#collapse(toStart) -> undefined
77 79
      *  - toStart (Boolean): If TRUE, collapses the Range onto its start;
78  
-     *      if FALSE, collapses it onto its end.
  80
+     *    if FALSE, collapses it onto its end.
  81
+     *
79 82
      *  Collapse a Range onto one of its boundary-points
80  
-     **/
  83
+    **/
81 84
     function collapse(toStart) {
82 85
       if (toStart) {
83 86
         this.endContainer = this.startContainer;
@@ -91,12 +94,13 @@ if (typeof Range == 'undefined') {
91 94
     }
92 95
 
93 96
     /**
94  
-     * Range#compareBoundaryPoints(how, sourceRange) -> Integer
  97
+     *  Range#compareBoundaryPoints(how, sourceRange) -> Integer
95 98
      *  - how (Integer): A code representing the type of comparison
96 99
      *  - sourceRange (Range): The Range on which this current Range is
97  
-     *      compared to.
  100
+     *    compared to.
  101
+     *
98 102
      *  Compare the boundary-points of two Ranges in a document.
99  
-     **/
  103
+    **/
100 104
     function compareBoundaryPoints(compareHow, sourceRange) {
101 105
       try {
102 106
         var cmnSelf, cmnSource, rootSelf, rootSource;
@@ -135,11 +139,12 @@ if (typeof Range == 'undefined') {
135 139
     }
136 140
 
137 141
     /**
138  
-     * Range#deleteContents() -> undefined
  142
+     *  Range#deleteContents() -> undefined
  143
+     *
139 144
      *  Removes the contents of a Range from the containing document or
140 145
      *  document fragment without returning a reference to the
141 146
      *  removed content.
142  
-     **/
  147
+    **/
143 148
     function deleteContents() {
144 149
       try {
145 150
         _processContents(this, Range.DELETE_CONTENTS);
@@ -147,20 +152,22 @@ if (typeof Range == 'undefined') {
147 152
     }
148 153
 
149 154
     /**
150  
-     * Range#detach() -> undefined
  155
+     *  Range#detach() -> undefined
  156
+     *
151 157
      *  Called to indicate that the Range is no longer in use and that the
152 158
      *  implementation may relinquish any resources associated with
153 159
      *  this Range.
154  
-     **/
  160
+    **/
155 161
     function detach() {
156 162
       this.detached = true;
157 163
     }
158 164
 
159 165
     /**
160  
-     * Range#extractContents() -> DocumentFragment
  166
+     *  Range#extractContents() -> DocumentFragment
  167
+     *
161 168
      *  Moves the contents of a Range from the containing document or
162 169
      *  document fragment to a new DocumentFragment.
163  
-     **/
  170
+    **/
164 171
     function extractContents() {
165 172
       try {
166 173
         return _processContents(this, Range.EXTRACT_CONTENTS);
@@ -170,8 +177,9 @@ if (typeof Range == 'undefined') {
170 177
     }
171 178
 
172 179
     /**
173  
-     * Range#insertNode(newNode) -> undefined
  180
+     *  Range#insertNode(newNode) -> undefined
174 181
      *  - newNode (Node): The node to insert at the start of the Range
  182
+     *
175 183
      *  Inserts a node into the Document or DocumentFragment at the start
176 184
      *  of the Range. If the container is a Text node, this will be split at
177 185
      *  the start of the Range (as if the Text node's splitText method was
@@ -180,7 +188,7 @@ if (typeof Range == 'undefined') {
180 188
      *  be automatically merged. If the node to be inserted is a
181 189
      *  DocumentFragment node, the children will be inserted rather than the
182 190
      *  DocumentFragment node itself.
183  
-     **/
  191
+    **/
184 192
     function insertNode(newNode) {
185 193
       try {
186 194
         var n, newText, offset;
@@ -203,32 +211,35 @@ if (typeof Range == 'undefined') {
203 211
     }
204 212
 
205 213
     /**
206  
-     * Range#selectNode(refNode) -> undefined
  214
+     *  Range#selectNode(refNode) -> undefined
207 215
      *  - refNode (Node): The node to select.
  216
+     *
208 217
      *  Select a node and its contents
209  
-     **/
  218
+    **/
210 219
     function selectNode(refNode) {
211 220
       this.setStartBefore(refNode);
212 221
       this.setEndAfter(refNode);
213 222
     }
214 223
 
215 224
     /**
216  
-     * Range#selectNodeContents(refNode) -> undefined
  225
+     *  Range#selectNodeContents(refNode) -> undefined
217 226
      *  - refNode (Node): Node to select from
  227
+     *
218 228
      *  Select the contents within a node
219  
-     **/
  229
+    **/
220 230
     function selectNodeContents(refNode) {
221 231
       this.setStart(refNode, 0);
222 232
       this.setEnd(refNode, refNode.childNodes.length);
223 233
     }
224 234
 
225 235
     /**
226  
-     * Range#setStart(refNode, offset) -> undefined
  236
+     *  Range#setStart(refNode, offset) -> undefined
227 237
      *  - refNode (Node): The refNode value. This parameter must be different
228 238
      *      from null.
229 239
      *  - offset (Integer): The endOffset value.
  240
+     *
230 241
      *  Sets the attributes describing the end of a Range.
231  
-     **/
  242
+    **/
232 243
     function setStart(refNode, offset) {
233 244
       try {
234 245
         var endRootContainer, startRootContainer;
@@ -267,30 +278,33 @@ if (typeof Range == 'undefined') {
267 278
     }
268 279
 
269 280
     /**
270  
-     * Range#setStartAfter(refNode) -> undefined
  281
+     *  Range#setStartAfter(refNode) -> undefined
271 282
      *  - refNode (Node): Range ends after refNode.
  283
+     *
272 284
      *  Sets the end of a Range to be after a node
273  
-     **/
  285
+    **/
274 286
     function setStartAfter(refNode) {
275 287
       this.setStart(refNode.parentNode, _nodeIndex(refNode) + 1);
276 288
     }
277 289
 
278 290
     /**
279  
-     * Range#setStartBefore(refNode) -> undefined
  291
+     *  Range#setStartBefore(refNode) -> undefined
280 292
      *  - refNode (Node): Range ends before refNode
  293
+     *
281 294
      *  Sets the end position to be before a node.
282  
-     **/
  295
+    **/
283 296
     function setStartBefore(refNode) {
284 297
       this.setStart(refNode.parentNode, _nodeIndex(refNode));
285 298
     }
286 299
 
287 300
     /**
288  
-     * Range#setEnd(refNode, offset) -> undefined
  301
+     *  Range#setEnd(refNode, offset) -> undefined
289 302
      *  - refNode (Node): The refNode value. This parameter must be different
290  
-     *      from null.
  303
+     *  from null.
291 304
      *  - offset (Integer): The startOffset value.
  305
+     *
292 306
      *  Sets the attributes describing the start of the Range.
293  
-     **/
  307
+    **/
294 308
     function setEnd(refNode, offset) {
295 309
       try {
296 310
         this.endContainer = refNode;
@@ -326,29 +340,32 @@ if (typeof Range == 'undefined') {
326 340
     }
327 341
 
328 342
     /**
329  
-     * Range#setEndAfter(refNode) -> undefined
  343
+     *  Range#setEndAfter(refNode) -> undefined
330 344
      *  - refNode (Node): Range starts after refNode
  345
+     *
331 346
      *  Sets the start position to be after a node
332  
-     **/
  347
+    **/
333 348
     function setEndAfter(refNode) {
334 349
       this.setEnd(refNode.parentNode, _nodeIndex(refNode) + 1);
335 350
     }
336 351
 
337 352
     /**
338  
-     * Range#setEndBefore(refNode) -> undefined
  353
+     *  Range#setEndBefore(refNode) -> undefined
339 354
      *  - refNode (Node): Range starts before refNode
  355
+     *
340 356
      *  Sets the start position to be before a node
341  
-     **/
  357
+    **/
342 358
     function setEndBefore(refNode) {
343 359
       this.setEnd(refNode.parentNode, _nodeIndex(refNode));
344 360
     }
345 361
 
346 362
     /**
347  
-     * Range#surroundContents(newParent) -> undefined
  363
+     *  Range#surroundContents(newParent) -> undefined
348 364
      *  - newParent (Node): The node to surround the contents with.
  365
+     *
349 366
      *  Reparents the contents of the Range to the given node and inserts the
350 367
      *  node at the position of the start of the Range.
351  
-     **/
  368
+    **/
352 369
     function surroundContents(newParent) {
353 370
       try {
354 371
         var n, fragment;
@@ -365,7 +382,6 @@ if (typeof Range == 'undefined') {
365 382
       } catch (e) {}
366 383
     }
367 384
 
368  
-
369 385
     function _compareBoundaryPoints(range, containerA, offsetA, containerB, offsetB) {
370 386
       var c, offsetC, n, cmnRoot, childA;
371 387
       // In the first case the boundary-points have the same container. A is before B
@@ -382,7 +398,6 @@ if (typeof Range == 'undefined') {
382 398
         }
383 399
       }
384 400
 
385  
-
386 401
       // In the second case a child node C of the container of A is an ancestor
387 402
       // container of B. In this case, A is before B if the offset of A is less than or
388 403
       // equal to the index of the child node C and A is after B otherwise.

0 notes on commit 827c866

Please sign in to comment.
Something went wrong with that request. Please try again.