mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 15:23:29 -05:00
6b4dda816e
* If you load the squire.js script into a top-level page rather than an iframe, it will add a Squire constructor to the global scope. * The Squire constructor can be used to instantiate multiple instances on the same page without having to load/parse/execute the full code every time. * For each instance, create a new iframe, then call `new Squire( document )`, with the document node for each iframe.
45 lines
1.4 KiB
JavaScript
45 lines
1.4 KiB
JavaScript
/*global doc, navigator */
|
|
/*jshint strict:false */
|
|
|
|
var DOCUMENT_POSITION_PRECEDING = 2; // Node.DOCUMENT_POSITION_PRECEDING
|
|
var ELEMENT_NODE = 1; // Node.ELEMENT_NODE;
|
|
var TEXT_NODE = 3; // Node.TEXT_NODE;
|
|
var SHOW_ELEMENT = 1; // NodeFilter.SHOW_ELEMENT;
|
|
var SHOW_TEXT = 4; // NodeFilter.SHOW_TEXT;
|
|
var FILTER_ACCEPT = 1; // NodeFilter.FILTER_ACCEPT;
|
|
var FILTER_SKIP = 3; // NodeFilter.FILTER_SKIP;
|
|
|
|
var START_TO_START = 0; // Range.START_TO_START
|
|
var START_TO_END = 1; // Range.START_TO_END
|
|
var END_TO_END = 2; // Range.END_TO_END
|
|
var END_TO_START = 3; // Range.END_TO_START
|
|
|
|
var win = doc.defaultView;
|
|
|
|
var ua = navigator.userAgent;
|
|
|
|
var isIOS = /iP(?:ad|hone|od)/.test( ua );
|
|
var isMac = /Mac OS X/.test( ua );
|
|
|
|
var isGecko = /Gecko\//.test( ua );
|
|
var isIE = /Trident\//.test( ua );
|
|
var isIE8 = ( win.ie === 8 );
|
|
var isOpera = !!win.opera;
|
|
var isWebKit = /WebKit\//.test( ua );
|
|
|
|
var ctrlKey = isMac ? 'meta-' : 'ctrl-';
|
|
|
|
var useTextFixer = isIE || isOpera;
|
|
var cantFocusEmptyTextNodes = isIE || isWebKit;
|
|
var losesSelectionOnBlur = isIE;
|
|
var hasBuggySplit = ( function () {
|
|
var div = doc.createElement( 'div' ),
|
|
text = doc.createTextNode( '12' );
|
|
div.appendChild( text );
|
|
text.splitText( 2 );
|
|
return div.childNodes.length !== 2;
|
|
}() );
|
|
|
|
var notWS = /\S/;
|
|
|
|
var indexOf = Array.prototype.indexOf;
|