Skip to content

Commit

Permalink
Updated lib files
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim committed Sep 21, 2014
1 parent 4e41bee commit 6a3bbc5
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 53 deletions.
6 changes: 3 additions & 3 deletions lib/rangy-classapplier.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
* Adds, removes and toggles classes on Ranges and Selections
*
* Part of Rangy, a cross-browser JavaScript range and selection library
* http://code.google.com/p/rangy/
* https://github.com/timdown/rangy
*
* Depends on Rangy core.
*
* Copyright 2014, Tim Down
* Licensed under the MIT license.
* Version: 1.3.0-alpha.20140827
* Build date: 27 August 2014
* Version: 1.3.0-alpha.20140921
* Build date: 21 September 2014
*/
(function(factory, root) {
if (typeof define == "function" && define.amd) {
Expand Down
17 changes: 10 additions & 7 deletions lib/rangy-core.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
* Rangy, a cross-browser JavaScript range and selection library
* http://code.google.com/p/rangy/
* https://github.com/timdown/rangy
*
* Copyright 2014, Tim Down
* Licensed under the MIT license.
* Version: 1.3.0-alpha.20140827
* Build date: 27 August 2014
* Version: 1.3.0-alpha.20140921
* Build date: 21 September 2014
*/

(function(factory, root) {
Expand Down Expand Up @@ -98,7 +98,7 @@
};

var api = {
version: "1.3.0-alpha.20140827",
version: "1.3.0-alpha.20140921",
initialized: false,
isBrowser: isBrowser,
supported: true,
Expand Down Expand Up @@ -167,7 +167,7 @@
var options = {};
extend(options, defaults);
if (optionsParam) {
extend(options, optionsParam, true);
extend(options, optionsParam);
}
return options;
};
Expand Down Expand Up @@ -387,6 +387,9 @@
} catch (ex) {
var errorMessage = "Module '" + name + "' failed to load: " + getErrorDesc(ex);
consoleLog(errorMessage);
if (ex.stack) {
consoleLog(ex.stack);
}
}
}
});
Expand Down Expand Up @@ -3736,7 +3739,7 @@

if (isBrowser) {
// Test whether the document has already been loaded and initialize immediately if so
if (/^(?:complete|interactive)$/.test(document.readyState)) {
if (document.readyState == "complete") {
loadHandler();
} else {
if (isHostMethod(document, "addEventListener")) {
Expand All @@ -3749,4 +3752,4 @@
}

return api;
}, /* build:replaceWithGlobalObject */this/* build:replaceWithGlobalObjectEnd */);
}, this);
6 changes: 3 additions & 3 deletions lib/rangy-highlighter.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/**
* Highlighter module for Rangy, a cross-browser JavaScript range and selection library
* http://code.google.com/p/rangy/
* https://github.com/timdown/rangy
*
* Depends on Rangy core, TextRange and CssClassApplier modules.
*
* Copyright 2014, Tim Down
* Licensed under the MIT license.
* Version: 1.3.0-alpha.20140827
* Build date: 27 August 2014
* Version: 1.3.0-alpha.20140921
* Build date: 21 September 2014
*/
(function(factory, root) {
if (typeof define == "function" && define.amd) {
Expand Down
6 changes: 3 additions & 3 deletions lib/rangy-selectionsaverestore.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
* Saves and restores user selections using marker invisible elements in the DOM.
*
* Part of Rangy, a cross-browser JavaScript range and selection library
* http://code.google.com/p/rangy/
* https://github.com/timdown/rangy
*
* Depends on Rangy core.
*
* Copyright 2014, Tim Down
* Licensed under the MIT license.
* Version: 1.3.0-alpha.20140827
* Build date: 27 August 2014
* Version: 1.3.0-alpha.20140921
* Build date: 21 September 2014
*/
(function(factory, root) {
if (typeof define == "function" && define.amd) {
Expand Down
6 changes: 3 additions & 3 deletions lib/rangy-serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
* cookie or local storage and restore it on the user's next visit to the same page.
*
* Part of Rangy, a cross-browser JavaScript range and selection library
* http://code.google.com/p/rangy/
* https://github.com/timdown/rangy
*
* Depends on Rangy core.
*
* Copyright 2014, Tim Down
* Licensed under the MIT license.
* Version: 1.3.0-alpha.20140827
* Build date: 27 August 2014
* Version: 1.3.0-alpha.20140921
* Build date: 21 September 2014
*/
(function(factory, root) {
if (typeof define == "function" && define.amd) {
Expand Down
59 changes: 25 additions & 34 deletions lib/rangy-textrange.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
* http://dvcs.w3.org/hg/editing/raw-file/tip/editing.html
*
* Part of Rangy, a cross-browser JavaScript range and selection library
* http://code.google.com/p/rangy/
* https://github.com/timdown/rangy
*
* Depends on Rangy core.
*
* Copyright 2014, Tim Down
* Licensed under the MIT license.
* Version: 1.3.0-alpha.20140827
* Build date: 27 August 2014
* Version: 1.3.0-alpha.20140921
* Build date: 21 September 2014
*/

/**
Expand Down Expand Up @@ -257,17 +257,14 @@
}
}

function createCharacterOptions(options) {
return createOptions(options, defaultCharacterOptions);
}

function createCaretCharacterOptions(options) {
return createOptions(options, defaultCaretCharacterOptions);
}

function createFindOptions(optionsParam) {
var options = createOptions(optionsParam, defaultFindOptions);
options.characterOptions = createCharacterOptions(options.wordOptions);
function createNestedOptions(optionsParam, defaults) {
var options = createOptions(optionsParam, defaults);
if (defaults.hasOwnProperty("wordOptions")) {
options.wordOptions = createWordOptions(options.wordOptions);
}
if (defaults.hasOwnProperty("characterOptions")) {
options.characterOptions = createOptions(options.characterOptions, defaultCharacterOptions);
}
return options;
}

Expand Down Expand Up @@ -1478,10 +1475,10 @@
if (isRegex) {
result = searchTerm.exec(text);
if (result) {
matchStartIndex = result.index;
matchEndIndex = matchStartIndex + result[0].length;
if (insideRegexMatch) {
// Check whether the match is now over
matchStartIndex = result.index;
matchEndIndex = matchStartIndex + result[0].length;
if ((!backward && matchEndIndex < text.length) || (backward && matchStartIndex > 0)) {
returnValue = handleMatch(matchStartIndex, matchEndIndex);
break;
Expand Down Expand Up @@ -1534,20 +1531,18 @@
*/
return createEntryPointFunction(
function(session, unit, count, moveOptions) {
if (typeof count == "undefined") {
if (typeof count == UNDEF) {
count = unit;
unit = CHARACTER;
}
moveOptions = createOptions(moveOptions, defaultMoveOptions);
var characterOptions = createCharacterOptions(moveOptions.characterOptions);
var wordOptions = createWordOptions(moveOptions.wordOptions);
moveOptions = createNestedOptions(moveOptions, defaultMoveOptions);

var boundaryIsStart = isStart;
if (collapse) {
boundaryIsStart = (count >= 0);
this.collapse(!boundaryIsStart);
}
var moveResult = movePositionBy(session.getRangeBoundaryPosition(this, boundaryIsStart), unit, count, characterOptions, wordOptions);
var moveResult = movePositionBy(session.getRangeBoundaryPosition(this, boundaryIsStart), unit, count, moveOptions.characterOptions, moveOptions.wordOptions);
var newPos = moveResult.position;
this[boundaryIsStart ? "setStart" : "setEnd"](newPos.node, newPos.offset);
return moveResult.unitsMoved;
Expand All @@ -1558,7 +1553,7 @@
function createRangeTrimmer(isStart) {
return createEntryPointFunction(
function(session, characterOptions) {
characterOptions = createCharacterOptions(characterOptions);
characterOptions = createOptions(characterOptions, defaultCharacterOptions);
var pos;
var it = createRangeCharacterIterator(session, this, characterOptions, !isStart);
var trimCharCount = 0;
Expand Down Expand Up @@ -1600,13 +1595,13 @@
expand: createEntryPointFunction(
function(session, unit, expandOptions) {
var moved = false;
expandOptions = createOptions(expandOptions, defaultExpandOptions);
var characterOptions = createCharacterOptions(expandOptions.characterOptions);
expandOptions = createNestedOptions(expandOptions, defaultExpandOptions);
var characterOptions = expandOptions.characterOptions;
if (!unit) {
unit = CHARACTER;
}
if (unit == WORD) {
var wordOptions = createWordOptions(expandOptions.wordOptions);
var wordOptions = expandOptions.wordOptions;
var startPos = session.getRangeBoundaryPosition(this, true);
var endPos = session.getRangeBoundaryPosition(this, false);

Expand Down Expand Up @@ -1651,7 +1646,7 @@
text: createEntryPointFunction(
function(session, characterOptions) {
return this.collapsed ?
"" : getRangeCharacters(session, this, createCharacterOptions(characterOptions)).join("");
"" : getRangeCharacters(session, this, createOptions(characterOptions, defaultCharacterOptions)).join("");
}
),

Expand Down Expand Up @@ -1698,12 +1693,10 @@
findText: createEntryPointFunction(
function(session, searchTermParam, findOptions) {
// Set up options
findOptions = createFindOptions(findOptions);
findOptions = createNestedOptions(findOptions, defaultFindOptions);

// Create word options if we're matching whole words only
if (findOptions.wholeWordsOnly) {
findOptions.wordOptions = createWordOptions(findOptions.wordOptions);

// We don't ever want trailing spaces for search results
findOptions.wordOptions.includeTrailingSpace = false;
}
Expand Down Expand Up @@ -1814,7 +1807,7 @@
if (!options) {
options = {};
}
options.characterOptions = createCaretCharacterOptions(options.characterOptions);
options.characterOptions = createOptions(options.characterOptions, defaultCaretCharacterOptions);
unitsMoved = range.move(unit, count, options);
this.setSingleRange(range);
}
Expand Down Expand Up @@ -1890,11 +1883,9 @@

api.createWordIterator = function(startNode, startOffset, iteratorOptions) {
var session = getSession();
iteratorOptions = createOptions(iteratorOptions, defaultWordIteratorOptions);
var characterOptions = createCharacterOptions(iteratorOptions.characterOptions);
var wordOptions = createWordOptions(iteratorOptions.wordOptions);
iteratorOptions = createNestedOptions(iteratorOptions, defaultWordIteratorOptions);
var startPos = session.getPosition(startNode, startOffset);
var tokenizedTextProvider = createTokenizedTextProvider(startPos, characterOptions, wordOptions);
var tokenizedTextProvider = createTokenizedTextProvider(startPos, iteratorOptions.characterOptions, iteratorOptions.wordOptions);
var backward = isDirectionBackward(iteratorOptions.direction);

return {
Expand Down

0 comments on commit 6a3bbc5

Please sign in to comment.