2014-10-02 04:36:39 -05:00
|
|
|
/*jshint strict:false, undef:false, unused:false */
|
2013-04-07 22:27:06 -05:00
|
|
|
|
|
|
|
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 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;
|
2013-05-20 01:14:28 -05:00
|
|
|
|
|
|
|
var isIOS = /iP(?:ad|hone|od)/.test( ua );
|
|
|
|
var isMac = /Mac OS X/.test( ua );
|
|
|
|
|
2013-04-07 22:27:06 -05:00
|
|
|
var isGecko = /Gecko\//.test( ua );
|
2013-10-07 23:00:38 -05:00
|
|
|
var isIE8or9or10 = /Trident\/[456]\./.test( ua );
|
2013-04-07 22:27:06 -05:00
|
|
|
var isIE8 = ( win.ie === 8 );
|
2014-10-02 04:22:51 -05:00
|
|
|
var isPresto = !!win.opera;
|
2013-04-07 22:27:06 -05:00
|
|
|
var isWebKit = /WebKit\//.test( ua );
|
|
|
|
|
2013-05-20 01:14:28 -05:00
|
|
|
var ctrlKey = isMac ? 'meta-' : 'ctrl-';
|
|
|
|
|
2014-10-02 04:22:51 -05:00
|
|
|
var useTextFixer = isIE8or9or10 || isPresto;
|
2013-10-07 23:00:38 -05:00
|
|
|
var cantFocusEmptyTextNodes = isIE8or9or10 || isWebKit;
|
|
|
|
var losesSelectionOnBlur = isIE8or9or10;
|
2014-10-02 04:36:39 -05:00
|
|
|
var hasBuggySplit = function ( doc ) {
|
2014-06-01 19:17:00 -05:00
|
|
|
var div = doc.createElement( 'DIV' ),
|
2013-06-20 08:15:18 -05:00
|
|
|
text = doc.createTextNode( '12' );
|
|
|
|
div.appendChild( text );
|
|
|
|
text.splitText( 2 );
|
|
|
|
return div.childNodes.length !== 2;
|
2014-10-02 04:36:39 -05:00
|
|
|
};
|
2013-04-07 22:27:06 -05:00
|
|
|
|
2013-11-04 02:21:57 -05:00
|
|
|
// Use [^ \t\r\n] instead of \S so that nbsp does not count as white-space
|
|
|
|
var notWS = /[^ \t\r\n]/;
|
2013-04-07 22:27:06 -05:00
|
|
|
|
|
|
|
var indexOf = Array.prototype.indexOf;
|