0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2025-01-03 05:00:13 -05:00

Whitespace cleanup.

This commit is contained in:
Neil Jenkins 2012-01-25 11:47:26 +11:00
parent 78e8955be1
commit e3ee4dad12
8 changed files with 251 additions and 251 deletions

View file

@ -58,8 +58,8 @@
</p>
<p>
<span id="setTextColour" class="prompt">Text colour</span>
<span id="setTextHighlight" class="prompt">Text highlight</span>
<span id="link" class="prompt">Link</span>
<span id="setHighlightColour" class="prompt">Text highlight</span>
<span id="makeLink" class="prompt">Link</span>
</p>
<p>
<span id="incQuoteLevel">Quote</span>

View file

@ -36,12 +36,12 @@
}
h4,h5,h6 {
margin: 0;
}
}
ul, ol {
margin: 0 1em;
padding: 0 1em;
}
blockquote {
border-left: 2px solid blue;
margin: 0;

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,7 @@
/* Copyright © 2011 by Neil Jenkins. Licensed under the MIT license. */
( function () {
/*global Node, Text, Element, window, document */
"use strict";
@ -145,7 +145,7 @@ implement( Element, {
var path = this.parentNode.getPath(),
id = this.id,
className = this.className.trim();
path += '>' + tag;
if ( id ) {
path += '#' + id;
@ -259,30 +259,30 @@ implement( Element, {
container = container.parentNode;
}
container.detach();
offset = block.childNodes.length;
// Remove extra <BR> fixer if present.
last = block.lastChild;
if ( last && last.nodeName === 'BR' ) {
block.removeChild( last );
offset -= 1;
}
_range = {
startContainer: block,
startOffset: offset,
endContainer: block,
endOffset: offset
};
block.appendChild( next.empty() );
block.mergeInlines( _range );
range.setStart(
_range.startContainer, _range.startOffset );
range.collapse( true );
// Opera inserts a BR if you delete the last piece of text
// in a block-level element. Unfortunately, it then gets
// confused when setting the selection subsequently and
@ -308,43 +308,43 @@ implement( Element, {
},
split: function ( childNodeToSplitBefore, stopNode ) {
var node = this;
if ( typeof( childNodeToSplitBefore ) === 'number' ) {
childNodeToSplitBefore =
childNodeToSplitBefore < node.childNodes.length ?
node.childNodes[ childNodeToSplitBefore ] : null;
}
if ( node === stopNode ) {
return childNodeToSplitBefore;
}
// Clone node without children
var parent = node.parentNode,
clone = node.cloneNode( false ),
next;
// Add right-hand siblings to the clone
while ( childNodeToSplitBefore ) {
next = childNodeToSplitBefore.nextSibling;
clone.appendChild( childNodeToSplitBefore );
childNodeToSplitBefore = next;
}
// DO NOT NORMALISE. This may undo the fixCursor() call
// of a node lower down the tree!
// We need something in the element in order for the cursor to appear.
node.fixCursor();
clone.fixCursor();
// Inject clone after original node
if ( next = node.nextSibling ) {
parent.insertBefore( clone, next );
} else {
parent.appendChild( clone );
}
// Keep on splitting up the tree
return parent.split( clone, stopNode );
},
@ -356,7 +356,7 @@ implement( Element, {
var el = this,
doc = el.ownerDocument,
fixer, child;
if ( el.nodeName === 'BODY' ) {
if ( !( child = el.firstChild ) || child.nodeName === 'BR' ) {
fixer = doc.createElement( 'DIV' );
@ -370,7 +370,7 @@ implement( Element, {
fixer = null;
}
}
if ( el.isInline() ) {
if ( !el.firstChild ) {
fixer = doc.createTextNode( /* isWebkit ? '\u200B' :*/ '' );
@ -407,7 +407,7 @@ implement( Element, {
if ( fixer ) {
el.appendChild( fixer );
}
return this;
}
});

View file

@ -51,11 +51,11 @@ var getNodeAfter = function ( node, offset ) {
};
implement( Range, {
forEachTextNode: function ( fn ) {
var range = this.cloneRange();
range.moveBoundariesDownTree();
var startContainer = range.startContainer,
endContainer = range.endContainer,
root = range.commonAncestorContainer,
@ -64,12 +64,12 @@ implement( Range, {
return FILTER_ACCEPT;
}, false ),
textnode = walker.currentNode = startContainer;
while ( !fn( textnode, range ) &&
textnode !== endContainer &&
( textnode = walker.nextNode() ) ) {}
},
getTextContent: function () {
var textContent = '';
this.forEachTextNode( function ( textnode, range ) {
@ -86,9 +86,9 @@ implement( Range, {
});
return textContent;
},
// ---
_insertNode: function ( node ) {
// Insert at start.
var startContainer = this.startContainer,
@ -169,26 +169,26 @@ implement( Range, {
return frag;
},
_deleteContents: function () {
// Move boundaries up as much as possible to reduce need to split.
this.moveBoundariesUpTree();
// Remove selected range
this._extractContents();
// If we split into two different blocks, merge the blocks.
var startBlock = this.getStartBlock(),
endBlock = this.getEndBlock();
if ( startBlock && endBlock && startBlock !== endBlock ) {
startBlock.mergeWithBlock( endBlock, this );
}
// Ensure block has necessary children
if ( startBlock ) {
startBlock.fixCursor();
}
// Ensure body has a block-level element in it.
var body = this.endContainer.ownerDocument.body,
child = body.firstChild;
@ -196,7 +196,7 @@ implement( Range, {
body.fixCursor();
this.selectNodeContents( body.firstChild );
}
// Ensure valid range (must have only block or inline containers)
var isCollapsed = this.collapsed;
this.moveBoundariesDownTree();
@ -205,12 +205,12 @@ implement( Range, {
// Make that the focus point.
this.collapse( this.startContainer.nodeType === TEXT_NODE );
}
return this;
},
// ---
insertTreeFragment: function ( frag ) {
// Check if it's all inline content
var isInline = true,
@ -222,7 +222,7 @@ implement( Range, {
break;
}
}
// Delete any selected content
if ( !this.collapsed ) {
this._deleteContents();
@ -230,7 +230,7 @@ implement( Range, {
// Move range down into text ndoes
this.moveBoundariesDownTree();
// If inline, just insert at the current position.
if ( isInline ) {
this._insertNode( frag );
@ -248,7 +248,7 @@ implement( Range, {
endOffset = 0,
parent = nodeAfterSplit.parentNode,
child, node;
while ( ( child = startContainer.lastChild ) &&
child.nodeType === ELEMENT_NODE &&
child.nodeName !== 'BR' ) {
@ -267,19 +267,19 @@ implement( Range, {
endContainer.insertBefore( child, endContainer.firstChild );
endOffset += 1;
}
// Fix cursor before inserting block:
node = frag;
while ( node = node.getNextBlock() ) {
node.fixCursor();
}
parent.insertBefore( frag, nodeAfterSplit );
// Merge containers at edges
nodeAfterSplit.mergeContainers();
nodeBeforeSplit.nextSibling.mergeContainers();
// Remove empty nodes created by split.
if ( nodeAfterSplit === endContainer &&
!endContainer.textContent ) {
@ -293,7 +293,7 @@ implement( Range, {
startOffset = 0;
parent.removeChild( nodeBeforeSplit );
}
this.setStart( startContainer, startOffset );
this.setEnd( endContainer, endOffset );
this.moveBoundariesDownTree();
@ -301,7 +301,7 @@ implement( Range, {
},
// ---
containsNode: function ( node, partial ) {
var range = this,
nodeRange = node.ownerDocument.createRange();
@ -327,7 +327,7 @@ implement( Range, {
return ( nodeStartAfterStart && nodeEndBeforeEnd );
}
},
moveBoundariesDownTree: function () {
var startContainer = this.startContainer,
startOffset = this.startOffset,
@ -361,7 +361,7 @@ implement( Range, {
endContainer = child;
}
}
// If collapsed, this algorithm finds the nearest text node positions
// *outside* the range rather than inside, but also it flips which is
// assigned to which.
@ -372,7 +372,7 @@ implement( Range, {
this.setStart( startContainer, startOffset );
this.setEnd( endContainer, endOffset );
}
return this;
},
@ -411,7 +411,7 @@ implement( Range, {
getStartBlock: function () {
var container = this.startContainer,
block;
// If inline, get the containing block.
if ( container.isInline() ) {
block = container.getPreviousBlock();
@ -424,13 +424,13 @@ implement( Range, {
// Check the block actually intersects the range
return block && this.containsNode( block, true ) ? block : null;
},
// Returns the last block at least partially contained by the range,
// or null if no block is contained by the range.
getEndBlock: function () {
var container = this.endContainer,
block, child;
// If inline, get the containing block.
if ( container.isInline() ) {
block = container.getPreviousBlock();
@ -445,7 +445,7 @@ implement( Range, {
}
}
block = block.getPreviousBlock();
}
// Check the block actually intersects the range
return block && this.containsNode( block, true ) ? block : null;
@ -501,14 +501,14 @@ implement( Range, {
var start = this.getStartBlock(),
end = this.getEndBlock(),
parent;
if ( start && end ) {
parent = start.parentNode;
this.setStart( parent, indexOf.call( parent.childNodes, start ) );
parent = end.parentNode;
this.setEnd( parent, indexOf.call( parent.childNodes, end ) + 1 );
}
return this;
}
});

View file

@ -21,9 +21,9 @@ if ( !needsReplacement ) {
( function () {
var div = doc.createElement( 'div' ),
text = doc.createTextNode( '' );
div.appendChild( text );
var div1 = div.cloneNode( true ),
div2 = div.cloneNode( true ),
div3 = div.cloneNode( true ),

View file

@ -36,12 +36,12 @@
}
h4,h5,h6 {
margin: 0;
}
}
ul, ol {
margin: 0 1em;
padding: 0 1em;
}
blockquote {
border-left: 2px solid blue;
margin: 0;