id
int32
0
58k
repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
16,400
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
addDynamicCssRule
function addDynamicCssRule(uniqueToken, site, selector, body) { flushDynamicCssRules(); var rule = "." + _Constants._listViewClass + " ." + uniqueToken + " " + selector + " { " + body + "}"; var perfId = "_addDynamicCssRule:" + uniqueToken + ",info"; if (site) { site._writeProfilerMark(perfId); } else { _WriteProfilerMark("WinJS.UI.ListView:Layout" + perfId); } layoutStyleElem.sheet.insertRule(rule, 0); }
javascript
function addDynamicCssRule(uniqueToken, site, selector, body) { flushDynamicCssRules(); var rule = "." + _Constants._listViewClass + " ." + uniqueToken + " " + selector + " { " + body + "}"; var perfId = "_addDynamicCssRule:" + uniqueToken + ",info"; if (site) { site._writeProfilerMark(perfId); } else { _WriteProfilerMark("WinJS.UI.ListView:Layout" + perfId); } layoutStyleElem.sheet.insertRule(rule, 0); }
[ "function", "addDynamicCssRule", "(", "uniqueToken", ",", "site", ",", "selector", ",", "body", ")", "{", "flushDynamicCssRules", "(", ")", ";", "var", "rule", "=", "\".\"", "+", "_Constants", ".", "_listViewClass", "+", "\" .\"", "+", "uniqueToken", "+", "\" \"", "+", "selector", "+", "\" { \"", "+", "body", "+", "\"}\"", ";", "var", "perfId", "=", "\"_addDynamicCssRule:\"", "+", "uniqueToken", "+", "\",info\"", ";", "if", "(", "site", ")", "{", "site", ".", "_writeProfilerMark", "(", "perfId", ")", ";", "}", "else", "{", "_WriteProfilerMark", "(", "\"WinJS.UI.ListView:Layout\"", "+", "perfId", ")", ";", "}", "layoutStyleElem", ".", "sheet", ".", "insertRule", "(", "rule", ",", "0", ")", ";", "}" ]
Creates a dynamic CSS rule and adds it to the DOM. uniqueToken is a class name which uniquely identifies a set of related rules. These rules may be removed using deleteDynamicCssRule. uniqueToken should be created using uniqueCssClassName.
[ "Creates", "a", "dynamic", "CSS", "rule", "and", "adds", "it", "to", "the", "DOM", ".", "uniqueToken", "is", "a", "class", "name", "which", "uniquely", "identifies", "a", "set", "of", "related", "rules", ".", "These", "rules", "may", "be", "removed", "using", "deleteDynamicCssRule", ".", "uniqueToken", "should", "be", "created", "using", "uniqueCssClassName", "." ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L11989-L12001
16,401
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
getOuter
function getOuter(side, element) { return getDimension(element, "margin" + side) + getDimension(element, "border" + side + "Width") + getDimension(element, "padding" + side); }
javascript
function getOuter(side, element) { return getDimension(element, "margin" + side) + getDimension(element, "border" + side + "Width") + getDimension(element, "padding" + side); }
[ "function", "getOuter", "(", "side", ",", "element", ")", "{", "return", "getDimension", "(", "element", ",", "\"margin\"", "+", "side", ")", "+", "getDimension", "(", "element", ",", "\"border\"", "+", "side", "+", "\"Width\"", ")", "+", "getDimension", "(", "element", ",", "\"padding\"", "+", "side", ")", ";", "}" ]
Returns the sum of the margin, border, and padding for the side of the element specified by side. side can be "Left", "Right", "Top", or "Bottom".
[ "Returns", "the", "sum", "of", "the", "margin", "border", "and", "padding", "for", "the", "side", "of", "the", "element", "specified", "by", "side", ".", "side", "can", "be", "Left", "Right", "Top", "or", "Bottom", "." ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L12024-L12028
16,402
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
_LayoutCommon_initialize
function _LayoutCommon_initialize(site, groupsEnabled) { site._writeProfilerMark("Layout:initialize,info"); if (!this._inListMode) { _ElementUtilities.addClass(site.surface, _Constants._gridLayoutClass); } if (this._backdropColorClassName) { _ElementUtilities.addClass(site.surface, this._backdropColorClassName); } if (this._disableBackdropClassName) { _ElementUtilities.addClass(site.surface, this._disableBackdropClassName); } this._groups = []; this._groupMap = {}; this._oldGroupHeaderPosition = null; this._usingStructuralNodes = false; this._site = site; this._groupsEnabled = groupsEnabled; this._resetAnimationCaches(true); }
javascript
function _LayoutCommon_initialize(site, groupsEnabled) { site._writeProfilerMark("Layout:initialize,info"); if (!this._inListMode) { _ElementUtilities.addClass(site.surface, _Constants._gridLayoutClass); } if (this._backdropColorClassName) { _ElementUtilities.addClass(site.surface, this._backdropColorClassName); } if (this._disableBackdropClassName) { _ElementUtilities.addClass(site.surface, this._disableBackdropClassName); } this._groups = []; this._groupMap = {}; this._oldGroupHeaderPosition = null; this._usingStructuralNodes = false; this._site = site; this._groupsEnabled = groupsEnabled; this._resetAnimationCaches(true); }
[ "function", "_LayoutCommon_initialize", "(", "site", ",", "groupsEnabled", ")", "{", "site", ".", "_writeProfilerMark", "(", "\"Layout:initialize,info\"", ")", ";", "if", "(", "!", "this", ".", "_inListMode", ")", "{", "_ElementUtilities", ".", "addClass", "(", "site", ".", "surface", ",", "_Constants", ".", "_gridLayoutClass", ")", ";", "}", "if", "(", "this", ".", "_backdropColorClassName", ")", "{", "_ElementUtilities", ".", "addClass", "(", "site", ".", "surface", ",", "this", ".", "_backdropColorClassName", ")", ";", "}", "if", "(", "this", ".", "_disableBackdropClassName", ")", "{", "_ElementUtilities", ".", "addClass", "(", "site", ".", "surface", ",", "this", ".", "_disableBackdropClassName", ")", ";", "}", "this", ".", "_groups", "=", "[", "]", ";", "this", ".", "_groupMap", "=", "{", "}", ";", "this", ".", "_oldGroupHeaderPosition", "=", "null", ";", "this", ".", "_usingStructuralNodes", "=", "false", ";", "this", ".", "_site", "=", "site", ";", "this", ".", "_groupsEnabled", "=", "groupsEnabled", ";", "this", ".", "_resetAnimationCaches", "(", "true", ")", ";", "}" ]
Implementation of part of ILayout interface
[ "Implementation", "of", "part", "of", "ILayout", "interface" ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L12185-L12205
16,403
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
updateGroups
function updateGroups() { function createGroup(groupInfo, itemsContainer) { var GroupType = (groupInfo.enableCellSpanning ? Groups.CellSpanningGroup : Groups.UniformGroup); return new GroupType(that, itemsContainer); } var oldRealizedItemRange = (that._groups.length > 0 ? that._getRealizationRange() : null), newGroups = [], prepared = [], cleanUpDom = {}, newGroupMap = {}, currentIndex = 0, len = tree.length, i; for (i = 0; i < len; i++) { var oldChangedRealizedRangeInGroup = null, groupInfo = that._getGroupInfo(i), groupKey = that._site.groupFromIndex(i).key, oldGroup = that._groupMap[groupKey], wasCellSpanning = oldGroup instanceof Groups.CellSpanningGroup, isCellSpanning = groupInfo.enableCellSpanning; if (oldGroup) { if (wasCellSpanning !== isCellSpanning) { // The group has changed types so DOM needs to be cleaned up cleanUpDom[groupKey] = true; } else { // Compute the range of changed items that is within the group's realized range var firstChangedIndexInGroup = Math.max(0, changedRange.firstIndex - oldGroup.startIndex), oldRealizedItemRangeInGroup = that._rangeForGroup(oldGroup, oldRealizedItemRange); if (oldRealizedItemRangeInGroup && firstChangedIndexInGroup <= oldRealizedItemRangeInGroup.lastIndex) { // The old changed realized range is non-empty oldChangedRealizedRangeInGroup = { firstIndex: Math.max(firstChangedIndexInGroup, oldRealizedItemRangeInGroup.firstIndex), lastIndex: oldRealizedItemRangeInGroup.lastIndex }; } } } var group = createGroup(groupInfo, tree[i].itemsContainer.element); var prepareLayoutPromise; if (group.prepareLayoutWithCopyOfTree) { prepareLayoutPromise = group.prepareLayoutWithCopyOfTree(copyItemsContainerTree(tree[i].itemsContainer), oldChangedRealizedRangeInGroup, oldGroup, { groupInfo: groupInfo, startIndex: currentIndex, }); } else { prepareLayoutPromise = group.prepareLayout(getItemsContainerLength(tree[i].itemsContainer), oldChangedRealizedRangeInGroup, oldGroup, { groupInfo: groupInfo, startIndex: currentIndex, }); } prepared.push(prepareLayoutPromise); currentIndex += group.count; newGroups.push(group); newGroupMap[groupKey] = group; } return Promise.join(prepared).then(function () { var currentOffset = 0; for (var i = 0, len = newGroups.length; i < len; i++) { var group = newGroups[i]; group.offset = currentOffset; currentOffset += that._getGroupSize(group); } // Clean up deleted groups Object.keys(that._groupMap).forEach(function (deletedKey) { var skipDomCleanUp = !cleanUpDom[deletedKey]; that._groupMap[deletedKey].cleanUp(skipDomCleanUp); }); that._groups = newGroups; that._groupMap = newGroupMap; }); }
javascript
function updateGroups() { function createGroup(groupInfo, itemsContainer) { var GroupType = (groupInfo.enableCellSpanning ? Groups.CellSpanningGroup : Groups.UniformGroup); return new GroupType(that, itemsContainer); } var oldRealizedItemRange = (that._groups.length > 0 ? that._getRealizationRange() : null), newGroups = [], prepared = [], cleanUpDom = {}, newGroupMap = {}, currentIndex = 0, len = tree.length, i; for (i = 0; i < len; i++) { var oldChangedRealizedRangeInGroup = null, groupInfo = that._getGroupInfo(i), groupKey = that._site.groupFromIndex(i).key, oldGroup = that._groupMap[groupKey], wasCellSpanning = oldGroup instanceof Groups.CellSpanningGroup, isCellSpanning = groupInfo.enableCellSpanning; if (oldGroup) { if (wasCellSpanning !== isCellSpanning) { // The group has changed types so DOM needs to be cleaned up cleanUpDom[groupKey] = true; } else { // Compute the range of changed items that is within the group's realized range var firstChangedIndexInGroup = Math.max(0, changedRange.firstIndex - oldGroup.startIndex), oldRealizedItemRangeInGroup = that._rangeForGroup(oldGroup, oldRealizedItemRange); if (oldRealizedItemRangeInGroup && firstChangedIndexInGroup <= oldRealizedItemRangeInGroup.lastIndex) { // The old changed realized range is non-empty oldChangedRealizedRangeInGroup = { firstIndex: Math.max(firstChangedIndexInGroup, oldRealizedItemRangeInGroup.firstIndex), lastIndex: oldRealizedItemRangeInGroup.lastIndex }; } } } var group = createGroup(groupInfo, tree[i].itemsContainer.element); var prepareLayoutPromise; if (group.prepareLayoutWithCopyOfTree) { prepareLayoutPromise = group.prepareLayoutWithCopyOfTree(copyItemsContainerTree(tree[i].itemsContainer), oldChangedRealizedRangeInGroup, oldGroup, { groupInfo: groupInfo, startIndex: currentIndex, }); } else { prepareLayoutPromise = group.prepareLayout(getItemsContainerLength(tree[i].itemsContainer), oldChangedRealizedRangeInGroup, oldGroup, { groupInfo: groupInfo, startIndex: currentIndex, }); } prepared.push(prepareLayoutPromise); currentIndex += group.count; newGroups.push(group); newGroupMap[groupKey] = group; } return Promise.join(prepared).then(function () { var currentOffset = 0; for (var i = 0, len = newGroups.length; i < len; i++) { var group = newGroups[i]; group.offset = currentOffset; currentOffset += that._getGroupSize(group); } // Clean up deleted groups Object.keys(that._groupMap).forEach(function (deletedKey) { var skipDomCleanUp = !cleanUpDom[deletedKey]; that._groupMap[deletedKey].cleanUp(skipDomCleanUp); }); that._groups = newGroups; that._groupMap = newGroupMap; }); }
[ "function", "updateGroups", "(", ")", "{", "function", "createGroup", "(", "groupInfo", ",", "itemsContainer", ")", "{", "var", "GroupType", "=", "(", "groupInfo", ".", "enableCellSpanning", "?", "Groups", ".", "CellSpanningGroup", ":", "Groups", ".", "UniformGroup", ")", ";", "return", "new", "GroupType", "(", "that", ",", "itemsContainer", ")", ";", "}", "var", "oldRealizedItemRange", "=", "(", "that", ".", "_groups", ".", "length", ">", "0", "?", "that", ".", "_getRealizationRange", "(", ")", ":", "null", ")", ",", "newGroups", "=", "[", "]", ",", "prepared", "=", "[", "]", ",", "cleanUpDom", "=", "{", "}", ",", "newGroupMap", "=", "{", "}", ",", "currentIndex", "=", "0", ",", "len", "=", "tree", ".", "length", ",", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "{", "var", "oldChangedRealizedRangeInGroup", "=", "null", ",", "groupInfo", "=", "that", ".", "_getGroupInfo", "(", "i", ")", ",", "groupKey", "=", "that", ".", "_site", ".", "groupFromIndex", "(", "i", ")", ".", "key", ",", "oldGroup", "=", "that", ".", "_groupMap", "[", "groupKey", "]", ",", "wasCellSpanning", "=", "oldGroup", "instanceof", "Groups", ".", "CellSpanningGroup", ",", "isCellSpanning", "=", "groupInfo", ".", "enableCellSpanning", ";", "if", "(", "oldGroup", ")", "{", "if", "(", "wasCellSpanning", "!==", "isCellSpanning", ")", "{", "// The group has changed types so DOM needs to be cleaned up", "cleanUpDom", "[", "groupKey", "]", "=", "true", ";", "}", "else", "{", "// Compute the range of changed items that is within the group's realized range", "var", "firstChangedIndexInGroup", "=", "Math", ".", "max", "(", "0", ",", "changedRange", ".", "firstIndex", "-", "oldGroup", ".", "startIndex", ")", ",", "oldRealizedItemRangeInGroup", "=", "that", ".", "_rangeForGroup", "(", "oldGroup", ",", "oldRealizedItemRange", ")", ";", "if", "(", "oldRealizedItemRangeInGroup", "&&", "firstChangedIndexInGroup", "<=", "oldRealizedItemRangeInGroup", ".", "lastIndex", ")", "{", "// The old changed realized range is non-empty", "oldChangedRealizedRangeInGroup", "=", "{", "firstIndex", ":", "Math", ".", "max", "(", "firstChangedIndexInGroup", ",", "oldRealizedItemRangeInGroup", ".", "firstIndex", ")", ",", "lastIndex", ":", "oldRealizedItemRangeInGroup", ".", "lastIndex", "}", ";", "}", "}", "}", "var", "group", "=", "createGroup", "(", "groupInfo", ",", "tree", "[", "i", "]", ".", "itemsContainer", ".", "element", ")", ";", "var", "prepareLayoutPromise", ";", "if", "(", "group", ".", "prepareLayoutWithCopyOfTree", ")", "{", "prepareLayoutPromise", "=", "group", ".", "prepareLayoutWithCopyOfTree", "(", "copyItemsContainerTree", "(", "tree", "[", "i", "]", ".", "itemsContainer", ")", ",", "oldChangedRealizedRangeInGroup", ",", "oldGroup", ",", "{", "groupInfo", ":", "groupInfo", ",", "startIndex", ":", "currentIndex", ",", "}", ")", ";", "}", "else", "{", "prepareLayoutPromise", "=", "group", ".", "prepareLayout", "(", "getItemsContainerLength", "(", "tree", "[", "i", "]", ".", "itemsContainer", ")", ",", "oldChangedRealizedRangeInGroup", ",", "oldGroup", ",", "{", "groupInfo", ":", "groupInfo", ",", "startIndex", ":", "currentIndex", ",", "}", ")", ";", "}", "prepared", ".", "push", "(", "prepareLayoutPromise", ")", ";", "currentIndex", "+=", "group", ".", "count", ";", "newGroups", ".", "push", "(", "group", ")", ";", "newGroupMap", "[", "groupKey", "]", "=", "group", ";", "}", "return", "Promise", ".", "join", "(", "prepared", ")", ".", "then", "(", "function", "(", ")", "{", "var", "currentOffset", "=", "0", ";", "for", "(", "var", "i", "=", "0", ",", "len", "=", "newGroups", ".", "length", ";", "i", "<", "len", ";", "i", "++", ")", "{", "var", "group", "=", "newGroups", "[", "i", "]", ";", "group", ".", "offset", "=", "currentOffset", ";", "currentOffset", "+=", "that", ".", "_getGroupSize", "(", "group", ")", ";", "}", "// Clean up deleted groups", "Object", ".", "keys", "(", "that", ".", "_groupMap", ")", ".", "forEach", "(", "function", "(", "deletedKey", ")", "{", "var", "skipDomCleanUp", "=", "!", "cleanUpDom", "[", "deletedKey", "]", ";", "that", ".", "_groupMap", "[", "deletedKey", "]", ".", "cleanUp", "(", "skipDomCleanUp", ")", ";", "}", ")", ";", "that", ".", "_groups", "=", "newGroups", ";", "that", ".", "_groupMap", "=", "newGroupMap", ";", "}", ")", ";", "}" ]
Updates the GridLayout's internal state to reflect the current tree. Similarly tells each group to update its internal state via prepareLayout. After this function runs, the ILayout functions will return results that are appropriate for the current tree.
[ "Updates", "the", "GridLayout", "s", "internal", "state", "to", "reflect", "the", "current", "tree", ".", "Similarly", "tells", "each", "group", "to", "update", "its", "internal", "state", "via", "prepareLayout", ".", "After", "this", "function", "runs", "the", "ILayout", "functions", "will", "return", "results", "that", "are", "appropriate", "for", "the", "current", "tree", "." ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L12365-L12447
16,404
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
layoutGroupContent
function layoutGroupContent(groupIndex, realizedItemRange, doRealizedRange) { var group = that._groups[groupIndex], firstChangedIndexInGroup = Math.max(0, changedRange.firstIndex - group.startIndex), realizedItemRangeInGroup = that._rangeForGroup(group, realizedItemRange), beforeRealizedRange; if (doRealizedRange) { group.layoutRealizedRange(firstChangedIndexInGroup, realizedItemRangeInGroup); } else { if (!realizedItemRangeInGroup) { beforeRealizedRange = (group.startIndex + group.count - 1 < realizedItemRange.firstIndex); } return group.layoutUnrealizedRange(firstChangedIndexInGroup, realizedItemRangeInGroup, beforeRealizedRange); } }
javascript
function layoutGroupContent(groupIndex, realizedItemRange, doRealizedRange) { var group = that._groups[groupIndex], firstChangedIndexInGroup = Math.max(0, changedRange.firstIndex - group.startIndex), realizedItemRangeInGroup = that._rangeForGroup(group, realizedItemRange), beforeRealizedRange; if (doRealizedRange) { group.layoutRealizedRange(firstChangedIndexInGroup, realizedItemRangeInGroup); } else { if (!realizedItemRangeInGroup) { beforeRealizedRange = (group.startIndex + group.count - 1 < realizedItemRange.firstIndex); } return group.layoutUnrealizedRange(firstChangedIndexInGroup, realizedItemRangeInGroup, beforeRealizedRange); } }
[ "function", "layoutGroupContent", "(", "groupIndex", ",", "realizedItemRange", ",", "doRealizedRange", ")", "{", "var", "group", "=", "that", ".", "_groups", "[", "groupIndex", "]", ",", "firstChangedIndexInGroup", "=", "Math", ".", "max", "(", "0", ",", "changedRange", ".", "firstIndex", "-", "group", ".", "startIndex", ")", ",", "realizedItemRangeInGroup", "=", "that", ".", "_rangeForGroup", "(", "group", ",", "realizedItemRange", ")", ",", "beforeRealizedRange", ";", "if", "(", "doRealizedRange", ")", "{", "group", ".", "layoutRealizedRange", "(", "firstChangedIndexInGroup", ",", "realizedItemRangeInGroup", ")", ";", "}", "else", "{", "if", "(", "!", "realizedItemRangeInGroup", ")", "{", "beforeRealizedRange", "=", "(", "group", ".", "startIndex", "+", "group", ".", "count", "-", "1", "<", "realizedItemRange", ".", "firstIndex", ")", ";", "}", "return", "group", ".", "layoutUnrealizedRange", "(", "firstChangedIndexInGroup", ",", "realizedItemRangeInGroup", ",", "beforeRealizedRange", ")", ";", "}", "}" ]
When doRealizedRange is true, this function is synchronous and has no return value. When doRealizedRange is false, this function is asynchronous and returns a promise.
[ "When", "doRealizedRange", "is", "true", "this", "function", "is", "synchronous", "and", "has", "no", "return", "value", ".", "When", "doRealizedRange", "is", "false", "this", "function", "is", "asynchronous", "and", "returns", "a", "promise", "." ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L12451-L12466
16,405
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
layoutUnrealizedRange
function layoutUnrealizedRange() { if (that._groups.length === 0) { return Promise.wrap(); } var realizedItemRange = that._getRealizationRange(), // Last group before the realized range which contains 1 or more unrealized items lastGroupBefore = site.groupIndexFromItemIndex(realizedItemRange.firstIndex - 1), // First group after the realized range which contains 1 or more unrealized items firstGroupAfter = site.groupIndexFromItemIndex(realizedItemRange.lastIndex + 1), firstChangedGroup = site.groupIndexFromItemIndex(changedRange.firstIndex), layoutPromises = [], groupCount = that._groups.length; var stop = false; var before = lastGroupBefore; var after = Math.max(firstChangedGroup, firstGroupAfter); after = Math.max(before + 1, after); while (!stop) { stop = true; if (before >= firstChangedGroup) { layoutPromises.push(layoutGroupContent(before, realizedItemRange, false)); stop = false; before--; } if (after < groupCount) { layoutPromises.push(layoutGroupContent(after, realizedItemRange, false)); stop = false; after++; } } return Promise.join(layoutPromises); }
javascript
function layoutUnrealizedRange() { if (that._groups.length === 0) { return Promise.wrap(); } var realizedItemRange = that._getRealizationRange(), // Last group before the realized range which contains 1 or more unrealized items lastGroupBefore = site.groupIndexFromItemIndex(realizedItemRange.firstIndex - 1), // First group after the realized range which contains 1 or more unrealized items firstGroupAfter = site.groupIndexFromItemIndex(realizedItemRange.lastIndex + 1), firstChangedGroup = site.groupIndexFromItemIndex(changedRange.firstIndex), layoutPromises = [], groupCount = that._groups.length; var stop = false; var before = lastGroupBefore; var after = Math.max(firstChangedGroup, firstGroupAfter); after = Math.max(before + 1, after); while (!stop) { stop = true; if (before >= firstChangedGroup) { layoutPromises.push(layoutGroupContent(before, realizedItemRange, false)); stop = false; before--; } if (after < groupCount) { layoutPromises.push(layoutGroupContent(after, realizedItemRange, false)); stop = false; after++; } } return Promise.join(layoutPromises); }
[ "function", "layoutUnrealizedRange", "(", ")", "{", "if", "(", "that", ".", "_groups", ".", "length", "===", "0", ")", "{", "return", "Promise", ".", "wrap", "(", ")", ";", "}", "var", "realizedItemRange", "=", "that", ".", "_getRealizationRange", "(", ")", ",", "// Last group before the realized range which contains 1 or more unrealized items", "lastGroupBefore", "=", "site", ".", "groupIndexFromItemIndex", "(", "realizedItemRange", ".", "firstIndex", "-", "1", ")", ",", "// First group after the realized range which contains 1 or more unrealized items", "firstGroupAfter", "=", "site", ".", "groupIndexFromItemIndex", "(", "realizedItemRange", ".", "lastIndex", "+", "1", ")", ",", "firstChangedGroup", "=", "site", ".", "groupIndexFromItemIndex", "(", "changedRange", ".", "firstIndex", ")", ",", "layoutPromises", "=", "[", "]", ",", "groupCount", "=", "that", ".", "_groups", ".", "length", ";", "var", "stop", "=", "false", ";", "var", "before", "=", "lastGroupBefore", ";", "var", "after", "=", "Math", ".", "max", "(", "firstChangedGroup", ",", "firstGroupAfter", ")", ";", "after", "=", "Math", ".", "max", "(", "before", "+", "1", ",", "after", ")", ";", "while", "(", "!", "stop", ")", "{", "stop", "=", "true", ";", "if", "(", "before", ">=", "firstChangedGroup", ")", "{", "layoutPromises", ".", "push", "(", "layoutGroupContent", "(", "before", ",", "realizedItemRange", ",", "false", ")", ")", ";", "stop", "=", "false", ";", "before", "--", ";", "}", "if", "(", "after", "<", "groupCount", ")", "{", "layoutPromises", ".", "push", "(", "layoutGroupContent", "(", "after", ",", "realizedItemRange", ",", "false", ")", ")", ";", "stop", "=", "false", ";", "after", "++", ";", "}", "}", "return", "Promise", ".", "join", "(", "layoutPromises", ")", ";", "}" ]
Asynchronously lays out the unrealized items
[ "Asynchronously", "lays", "out", "the", "unrealized", "items" ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L12489-L12522
16,406
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
updateIndicies
function updateIndicies(modifiedElements, cachedRecords) { var updatedCachedRecords = {}; for (var i = 0, len = modifiedElements.length; i < len; i++) { var modifiedElementLookup = modifiedElements[i]; var cachedRecord = cachedRecords[modifiedElementLookup.oldIndex]; if (cachedRecord) { updatedCachedRecords[modifiedElementLookup.newIndex] = cachedRecord; cachedRecord.element = modifiedElementLookup.element; delete cachedRecords[modifiedElementLookup.oldIndex]; } } var cachedRecordKeys = Object.keys(cachedRecords); for (var i = 0, len = cachedRecordKeys.length; i < len; i++) { var key = cachedRecordKeys[i], record = cachedRecords[key]; // We need to filter out containers which were removed from the DOM. If container's item // wasn't realized container can be removed without adding record to modifiedItems. if (!record.element || existingContainers[uniqueID(record.element)]) { updatedCachedRecords[key] = record; } } return updatedCachedRecords; }
javascript
function updateIndicies(modifiedElements, cachedRecords) { var updatedCachedRecords = {}; for (var i = 0, len = modifiedElements.length; i < len; i++) { var modifiedElementLookup = modifiedElements[i]; var cachedRecord = cachedRecords[modifiedElementLookup.oldIndex]; if (cachedRecord) { updatedCachedRecords[modifiedElementLookup.newIndex] = cachedRecord; cachedRecord.element = modifiedElementLookup.element; delete cachedRecords[modifiedElementLookup.oldIndex]; } } var cachedRecordKeys = Object.keys(cachedRecords); for (var i = 0, len = cachedRecordKeys.length; i < len; i++) { var key = cachedRecordKeys[i], record = cachedRecords[key]; // We need to filter out containers which were removed from the DOM. If container's item // wasn't realized container can be removed without adding record to modifiedItems. if (!record.element || existingContainers[uniqueID(record.element)]) { updatedCachedRecords[key] = record; } } return updatedCachedRecords; }
[ "function", "updateIndicies", "(", "modifiedElements", ",", "cachedRecords", ")", "{", "var", "updatedCachedRecords", "=", "{", "}", ";", "for", "(", "var", "i", "=", "0", ",", "len", "=", "modifiedElements", ".", "length", ";", "i", "<", "len", ";", "i", "++", ")", "{", "var", "modifiedElementLookup", "=", "modifiedElements", "[", "i", "]", ";", "var", "cachedRecord", "=", "cachedRecords", "[", "modifiedElementLookup", ".", "oldIndex", "]", ";", "if", "(", "cachedRecord", ")", "{", "updatedCachedRecords", "[", "modifiedElementLookup", ".", "newIndex", "]", "=", "cachedRecord", ";", "cachedRecord", ".", "element", "=", "modifiedElementLookup", ".", "element", ";", "delete", "cachedRecords", "[", "modifiedElementLookup", ".", "oldIndex", "]", ";", "}", "}", "var", "cachedRecordKeys", "=", "Object", ".", "keys", "(", "cachedRecords", ")", ";", "for", "(", "var", "i", "=", "0", ",", "len", "=", "cachedRecordKeys", ".", "length", ";", "i", "<", "len", ";", "i", "++", ")", "{", "var", "key", "=", "cachedRecordKeys", "[", "i", "]", ",", "record", "=", "cachedRecords", "[", "key", "]", ";", "// We need to filter out containers which were removed from the DOM. If container's item", "// wasn't realized container can be removed without adding record to modifiedItems.", "if", "(", "!", "record", ".", "element", "||", "existingContainers", "[", "uniqueID", "(", "record", ".", "element", ")", "]", ")", "{", "updatedCachedRecords", "[", "key", "]", "=", "record", ";", "}", "}", "return", "updatedCachedRecords", ";", "}" ]
Update the indicies before the insert since insert needs the new containers.
[ "Update", "the", "indicies", "before", "the", "insert", "since", "insert", "needs", "the", "new", "containers", "." ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L13840-L13863
16,407
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
assignGroupMarginsAndHeaders
function assignGroupMarginsAndHeaders(offset) { if (options.last) { // When looking for the *last* group, the *trailing* header and margin belong to the group. return offset - that._getHeaderSizeGroupAdjustment() - that._sizes.itemsContainerOuterStart; } else { // When looking for the *first* group, the *leading* header and margin belong to the group. // No need to make any adjustments to offset because the correct header and margin // already belong to the group. return offset; } }
javascript
function assignGroupMarginsAndHeaders(offset) { if (options.last) { // When looking for the *last* group, the *trailing* header and margin belong to the group. return offset - that._getHeaderSizeGroupAdjustment() - that._sizes.itemsContainerOuterStart; } else { // When looking for the *first* group, the *leading* header and margin belong to the group. // No need to make any adjustments to offset because the correct header and margin // already belong to the group. return offset; } }
[ "function", "assignGroupMarginsAndHeaders", "(", "offset", ")", "{", "if", "(", "options", ".", "last", ")", "{", "// When looking for the *last* group, the *trailing* header and margin belong to the group.", "return", "offset", "-", "that", ".", "_getHeaderSizeGroupAdjustment", "(", ")", "-", "that", ".", "_sizes", ".", "itemsContainerOuterStart", ";", "}", "else", "{", "// When looking for the *first* group, the *leading* header and margin belong to the group.", "// No need to make any adjustments to offset because the correct header and margin", "// already belong to the group.", "return", "offset", ";", "}", "}" ]
Assign the headers and margins to the appropriate groups.
[ "Assign", "the", "headers", "and", "margins", "to", "the", "appropriate", "groups", "." ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L14096-L14106
16,408
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
_LayoutCommon_getGroupInfo
function _LayoutCommon_getGroupInfo(groupIndex) { var group = this._site.groupFromIndex(groupIndex), groupInfo = this._groupInfo, margins = this._sizes.containerMargins, adjustedInfo = { enableCellSpanning: false }; groupInfo = (typeof groupInfo === "function" ? groupInfo(group) : groupInfo); if (groupInfo) { if (groupInfo.enableCellSpanning && (+groupInfo.cellWidth !== groupInfo.cellWidth || +groupInfo.cellHeight !== groupInfo.cellHeight)) { throw new _ErrorFromName("WinJS.UI.GridLayout.GroupInfoResultIsInvalid", strings.groupInfoResultIsInvalid); } adjustedInfo = { enableCellSpanning: !!groupInfo.enableCellSpanning, cellWidth: groupInfo.cellWidth + margins.left + margins.right, cellHeight: groupInfo.cellHeight + margins.top + margins.bottom }; } return adjustedInfo; }
javascript
function _LayoutCommon_getGroupInfo(groupIndex) { var group = this._site.groupFromIndex(groupIndex), groupInfo = this._groupInfo, margins = this._sizes.containerMargins, adjustedInfo = { enableCellSpanning: false }; groupInfo = (typeof groupInfo === "function" ? groupInfo(group) : groupInfo); if (groupInfo) { if (groupInfo.enableCellSpanning && (+groupInfo.cellWidth !== groupInfo.cellWidth || +groupInfo.cellHeight !== groupInfo.cellHeight)) { throw new _ErrorFromName("WinJS.UI.GridLayout.GroupInfoResultIsInvalid", strings.groupInfoResultIsInvalid); } adjustedInfo = { enableCellSpanning: !!groupInfo.enableCellSpanning, cellWidth: groupInfo.cellWidth + margins.left + margins.right, cellHeight: groupInfo.cellHeight + margins.top + margins.bottom }; } return adjustedInfo; }
[ "function", "_LayoutCommon_getGroupInfo", "(", "groupIndex", ")", "{", "var", "group", "=", "this", ".", "_site", ".", "groupFromIndex", "(", "groupIndex", ")", ",", "groupInfo", "=", "this", ".", "_groupInfo", ",", "margins", "=", "this", ".", "_sizes", ".", "containerMargins", ",", "adjustedInfo", "=", "{", "enableCellSpanning", ":", "false", "}", ";", "groupInfo", "=", "(", "typeof", "groupInfo", "===", "\"function\"", "?", "groupInfo", "(", "group", ")", ":", "groupInfo", ")", ";", "if", "(", "groupInfo", ")", "{", "if", "(", "groupInfo", ".", "enableCellSpanning", "&&", "(", "+", "groupInfo", ".", "cellWidth", "!==", "groupInfo", ".", "cellWidth", "||", "+", "groupInfo", ".", "cellHeight", "!==", "groupInfo", ".", "cellHeight", ")", ")", "{", "throw", "new", "_ErrorFromName", "(", "\"WinJS.UI.GridLayout.GroupInfoResultIsInvalid\"", ",", "strings", ".", "groupInfoResultIsInvalid", ")", ";", "}", "adjustedInfo", "=", "{", "enableCellSpanning", ":", "!", "!", "groupInfo", ".", "enableCellSpanning", ",", "cellWidth", ":", "groupInfo", ".", "cellWidth", "+", "margins", ".", "left", "+", "margins", ".", "right", ",", "cellHeight", ":", "groupInfo", ".", "cellHeight", "+", "margins", ".", "top", "+", "margins", ".", "bottom", "}", ";", "}", "return", "adjustedInfo", ";", "}" ]
Can only be called after measuring has been completed
[ "Can", "only", "be", "called", "after", "measuring", "has", "been", "completed" ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L14286-L14305
16,409
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
_LayoutCommon_getItemInfo
function _LayoutCommon_getItemInfo(itemIndex) { var result; if (!this._itemInfo || typeof this._itemInfo !== "function") { if (this._useDefaultItemInfo) { result = this._defaultItemInfo(itemIndex); } else { throw new _ErrorFromName("WinJS.UI.GridLayout.ItemInfoIsInvalid", strings.itemInfoIsInvalid); } } else { result = this._itemInfo(itemIndex); } return Promise.as(result).then(function (size) { if (!size || +size.width !== size.width || +size.height !== size.height) { throw new _ErrorFromName("WinJS.UI.GridLayout.ItemInfoIsInvalid", strings.itemInfoIsInvalid); } return size; }); }
javascript
function _LayoutCommon_getItemInfo(itemIndex) { var result; if (!this._itemInfo || typeof this._itemInfo !== "function") { if (this._useDefaultItemInfo) { result = this._defaultItemInfo(itemIndex); } else { throw new _ErrorFromName("WinJS.UI.GridLayout.ItemInfoIsInvalid", strings.itemInfoIsInvalid); } } else { result = this._itemInfo(itemIndex); } return Promise.as(result).then(function (size) { if (!size || +size.width !== size.width || +size.height !== size.height) { throw new _ErrorFromName("WinJS.UI.GridLayout.ItemInfoIsInvalid", strings.itemInfoIsInvalid); } return size; }); }
[ "function", "_LayoutCommon_getItemInfo", "(", "itemIndex", ")", "{", "var", "result", ";", "if", "(", "!", "this", ".", "_itemInfo", "||", "typeof", "this", ".", "_itemInfo", "!==", "\"function\"", ")", "{", "if", "(", "this", ".", "_useDefaultItemInfo", ")", "{", "result", "=", "this", ".", "_defaultItemInfo", "(", "itemIndex", ")", ";", "}", "else", "{", "throw", "new", "_ErrorFromName", "(", "\"WinJS.UI.GridLayout.ItemInfoIsInvalid\"", ",", "strings", ".", "itemInfoIsInvalid", ")", ";", "}", "}", "else", "{", "result", "=", "this", ".", "_itemInfo", "(", "itemIndex", ")", ";", "}", "return", "Promise", ".", "as", "(", "result", ")", ".", "then", "(", "function", "(", "size", ")", "{", "if", "(", "!", "size", "||", "+", "size", ".", "width", "!==", "size", ".", "width", "||", "+", "size", ".", "height", "!==", "size", ".", "height", ")", "{", "throw", "new", "_ErrorFromName", "(", "\"WinJS.UI.GridLayout.ItemInfoIsInvalid\"", ",", "strings", ".", "itemInfoIsInvalid", ")", ";", "}", "return", "size", ";", "}", ")", ";", "}" ]
itemIndex is optional
[ "itemIndex", "is", "optional" ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L14308-L14325
16,410
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
_LayoutCommon_groupFromOffset
function _LayoutCommon_groupFromOffset(offset) { return offset < this._groups[0].offset ? 0 : this._groupFrom(function (group) { return offset < group.offset; }); }
javascript
function _LayoutCommon_groupFromOffset(offset) { return offset < this._groups[0].offset ? 0 : this._groupFrom(function (group) { return offset < group.offset; }); }
[ "function", "_LayoutCommon_groupFromOffset", "(", "offset", ")", "{", "return", "offset", "<", "this", ".", "_groups", "[", "0", "]", ".", "offset", "?", "0", ":", "this", ".", "_groupFrom", "(", "function", "(", "group", ")", "{", "return", "offset", "<", "group", ".", "offset", ";", "}", ")", ";", "}" ]
offset should be relative to the grid layout's content box
[ "offset", "should", "be", "relative", "to", "the", "grid", "layout", "s", "content", "box" ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L14366-L14372
16,411
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
_LayoutCommon_viewportSizeChanged
function _LayoutCommon_viewportSizeChanged(viewportContentSize) { var sizes = this._sizes; sizes.viewportContentSize = viewportContentSize; sizes.surfaceContentSize = viewportContentSize - sizes.surfaceOuterCrossSize; sizes.maxItemsContainerContentSize = sizes.surfaceContentSize - sizes.itemsContainerOuterCrossSize - this._getHeaderSizeContentAdjustment(); // This calculation is for uniform layouts if (sizes.containerSizeLoaded && !this._inListMode) { this._itemsPerBar = Math.floor(sizes.maxItemsContainerContentSize / sizes.containerCrossSize); if (this.maximumRowsOrColumns) { this._itemsPerBar = Math.min(this._itemsPerBar, this.maximumRowsOrColumns); } this._itemsPerBar = Math.max(1, this._itemsPerBar); } else { if (this._inListMode) { sizes[this._horizontal ? "containerHeight" : "containerWidth"] = sizes.maxItemsContainerContentSize; } this._itemsPerBar = 1; } // Ignore animations if height changed this._resetAnimationCaches(); }
javascript
function _LayoutCommon_viewportSizeChanged(viewportContentSize) { var sizes = this._sizes; sizes.viewportContentSize = viewportContentSize; sizes.surfaceContentSize = viewportContentSize - sizes.surfaceOuterCrossSize; sizes.maxItemsContainerContentSize = sizes.surfaceContentSize - sizes.itemsContainerOuterCrossSize - this._getHeaderSizeContentAdjustment(); // This calculation is for uniform layouts if (sizes.containerSizeLoaded && !this._inListMode) { this._itemsPerBar = Math.floor(sizes.maxItemsContainerContentSize / sizes.containerCrossSize); if (this.maximumRowsOrColumns) { this._itemsPerBar = Math.min(this._itemsPerBar, this.maximumRowsOrColumns); } this._itemsPerBar = Math.max(1, this._itemsPerBar); } else { if (this._inListMode) { sizes[this._horizontal ? "containerHeight" : "containerWidth"] = sizes.maxItemsContainerContentSize; } this._itemsPerBar = 1; } // Ignore animations if height changed this._resetAnimationCaches(); }
[ "function", "_LayoutCommon_viewportSizeChanged", "(", "viewportContentSize", ")", "{", "var", "sizes", "=", "this", ".", "_sizes", ";", "sizes", ".", "viewportContentSize", "=", "viewportContentSize", ";", "sizes", ".", "surfaceContentSize", "=", "viewportContentSize", "-", "sizes", ".", "surfaceOuterCrossSize", ";", "sizes", ".", "maxItemsContainerContentSize", "=", "sizes", ".", "surfaceContentSize", "-", "sizes", ".", "itemsContainerOuterCrossSize", "-", "this", ".", "_getHeaderSizeContentAdjustment", "(", ")", ";", "// This calculation is for uniform layouts", "if", "(", "sizes", ".", "containerSizeLoaded", "&&", "!", "this", ".", "_inListMode", ")", "{", "this", ".", "_itemsPerBar", "=", "Math", ".", "floor", "(", "sizes", ".", "maxItemsContainerContentSize", "/", "sizes", ".", "containerCrossSize", ")", ";", "if", "(", "this", ".", "maximumRowsOrColumns", ")", "{", "this", ".", "_itemsPerBar", "=", "Math", ".", "min", "(", "this", ".", "_itemsPerBar", ",", "this", ".", "maximumRowsOrColumns", ")", ";", "}", "this", ".", "_itemsPerBar", "=", "Math", ".", "max", "(", "1", ",", "this", ".", "_itemsPerBar", ")", ";", "}", "else", "{", "if", "(", "this", ".", "_inListMode", ")", "{", "sizes", "[", "this", ".", "_horizontal", "?", "\"containerHeight\"", ":", "\"containerWidth\"", "]", "=", "sizes", ".", "maxItemsContainerContentSize", ";", "}", "this", ".", "_itemsPerBar", "=", "1", ";", "}", "// Ignore animations if height changed", "this", ".", "_resetAnimationCaches", "(", ")", ";", "}" ]
viewportContentSize is the new viewport size
[ "viewportContentSize", "is", "the", "new", "viewport", "size" ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L14899-L14922
16,412
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
_LayoutCommon_ensureContainerSize
function _LayoutCommon_ensureContainerSize(group) { var sizes = this._sizes; if (!sizes.containerSizeLoaded && !this._ensuringContainerSize) { var promise; if ((!this._itemInfo || typeof this._itemInfo !== "function") && this._useDefaultItemInfo) { var margins = sizes.containerMargins; promise = Promise.wrap({ width: group.groupInfo.cellWidth - margins.left - margins.right, height: group.groupInfo.cellHeight - margins.top - margins.bottom }); } else { promise = this._getItemInfo(); } var that = this; this._ensuringContainerSize = promise.then(function (itemSize) { sizes.containerSizeLoaded = true; sizes.containerWidth = itemSize.width + sizes.itemBoxOuterWidth + sizes.containerOuterWidth; sizes.containerHeight = itemSize.height + sizes.itemBoxOuterHeight + sizes.containerOuterHeight; if (!that._inListMode) { that._itemsPerBar = Math.floor(sizes.maxItemsContainerContentSize / sizes.containerCrossSize); if (that.maximumRowsOrColumns) { that._itemsPerBar = Math.min(that._itemsPerBar, that.maximumRowsOrColumns); } that._itemsPerBar = Math.max(1, that._itemsPerBar); } else { that._itemsPerBar = 1; } that._createContainerStyleRule(); }); promise.done( function () { that._ensuringContainerSize = null; }, function () { that._ensuringContainerSize = null; } ); return promise; } else { return this._ensuringContainerSize ? this._ensuringContainerSize : Promise.wrap(); } }
javascript
function _LayoutCommon_ensureContainerSize(group) { var sizes = this._sizes; if (!sizes.containerSizeLoaded && !this._ensuringContainerSize) { var promise; if ((!this._itemInfo || typeof this._itemInfo !== "function") && this._useDefaultItemInfo) { var margins = sizes.containerMargins; promise = Promise.wrap({ width: group.groupInfo.cellWidth - margins.left - margins.right, height: group.groupInfo.cellHeight - margins.top - margins.bottom }); } else { promise = this._getItemInfo(); } var that = this; this._ensuringContainerSize = promise.then(function (itemSize) { sizes.containerSizeLoaded = true; sizes.containerWidth = itemSize.width + sizes.itemBoxOuterWidth + sizes.containerOuterWidth; sizes.containerHeight = itemSize.height + sizes.itemBoxOuterHeight + sizes.containerOuterHeight; if (!that._inListMode) { that._itemsPerBar = Math.floor(sizes.maxItemsContainerContentSize / sizes.containerCrossSize); if (that.maximumRowsOrColumns) { that._itemsPerBar = Math.min(that._itemsPerBar, that.maximumRowsOrColumns); } that._itemsPerBar = Math.max(1, that._itemsPerBar); } else { that._itemsPerBar = 1; } that._createContainerStyleRule(); }); promise.done( function () { that._ensuringContainerSize = null; }, function () { that._ensuringContainerSize = null; } ); return promise; } else { return this._ensuringContainerSize ? this._ensuringContainerSize : Promise.wrap(); } }
[ "function", "_LayoutCommon_ensureContainerSize", "(", "group", ")", "{", "var", "sizes", "=", "this", ".", "_sizes", ";", "if", "(", "!", "sizes", ".", "containerSizeLoaded", "&&", "!", "this", ".", "_ensuringContainerSize", ")", "{", "var", "promise", ";", "if", "(", "(", "!", "this", ".", "_itemInfo", "||", "typeof", "this", ".", "_itemInfo", "!==", "\"function\"", ")", "&&", "this", ".", "_useDefaultItemInfo", ")", "{", "var", "margins", "=", "sizes", ".", "containerMargins", ";", "promise", "=", "Promise", ".", "wrap", "(", "{", "width", ":", "group", ".", "groupInfo", ".", "cellWidth", "-", "margins", ".", "left", "-", "margins", ".", "right", ",", "height", ":", "group", ".", "groupInfo", ".", "cellHeight", "-", "margins", ".", "top", "-", "margins", ".", "bottom", "}", ")", ";", "}", "else", "{", "promise", "=", "this", ".", "_getItemInfo", "(", ")", ";", "}", "var", "that", "=", "this", ";", "this", ".", "_ensuringContainerSize", "=", "promise", ".", "then", "(", "function", "(", "itemSize", ")", "{", "sizes", ".", "containerSizeLoaded", "=", "true", ";", "sizes", ".", "containerWidth", "=", "itemSize", ".", "width", "+", "sizes", ".", "itemBoxOuterWidth", "+", "sizes", ".", "containerOuterWidth", ";", "sizes", ".", "containerHeight", "=", "itemSize", ".", "height", "+", "sizes", ".", "itemBoxOuterHeight", "+", "sizes", ".", "containerOuterHeight", ";", "if", "(", "!", "that", ".", "_inListMode", ")", "{", "that", ".", "_itemsPerBar", "=", "Math", ".", "floor", "(", "sizes", ".", "maxItemsContainerContentSize", "/", "sizes", ".", "containerCrossSize", ")", ";", "if", "(", "that", ".", "maximumRowsOrColumns", ")", "{", "that", ".", "_itemsPerBar", "=", "Math", ".", "min", "(", "that", ".", "_itemsPerBar", ",", "that", ".", "maximumRowsOrColumns", ")", ";", "}", "that", ".", "_itemsPerBar", "=", "Math", ".", "max", "(", "1", ",", "that", ".", "_itemsPerBar", ")", ";", "}", "else", "{", "that", ".", "_itemsPerBar", "=", "1", ";", "}", "that", ".", "_createContainerStyleRule", "(", ")", ";", "}", ")", ";", "promise", ".", "done", "(", "function", "(", ")", "{", "that", ".", "_ensuringContainerSize", "=", "null", ";", "}", ",", "function", "(", ")", "{", "that", ".", "_ensuringContainerSize", "=", "null", ";", "}", ")", ";", "return", "promise", ";", "}", "else", "{", "return", "this", ".", "_ensuringContainerSize", "?", "this", ".", "_ensuringContainerSize", ":", "Promise", ".", "wrap", "(", ")", ";", "}", "}" ]
Computes container width and height if they haven't been computed yet. This should happen when the first uniform group is created.
[ "Computes", "container", "width", "and", "height", "if", "they", "haven", "t", "been", "computed", "yet", ".", "This", "should", "happen", "when", "the", "first", "uniform", "group", "is", "created", "." ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L14951-L14996
16,413
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
VirtualizeContentsView_updateAriaMarkers
function VirtualizeContentsView_updateAriaMarkers(listViewIsEmpty, firstIndexDisplayed, lastIndexDisplayed) { var that = this; if (this._listView._isZombie()) { return; } function getFirstVisibleItem() { return that.items.itemAt(firstIndexDisplayed); } // At a certain index, the VDS may return null for all items at that index and // higher. When this is the case, the end marker should point to the last // non-null item in the visible range. function getLastVisibleItem() { for (var i = lastIndexDisplayed; i >= firstIndexDisplayed; i--) { if (that.items.itemAt(i)) { return that.items.itemAt(i); } } return null; } this._listView._createAriaMarkers(); var startMarker = this._listView._ariaStartMarker, endMarker = this._listView._ariaEndMarker, firstVisibleItem, lastVisibleItem; if (firstIndexDisplayed !== -1 && lastIndexDisplayed !== -1 && firstIndexDisplayed <= lastIndexDisplayed) { firstVisibleItem = getFirstVisibleItem(); lastVisibleItem = getLastVisibleItem(); } if (listViewIsEmpty || !firstVisibleItem || !lastVisibleItem) { setFlow(startMarker, endMarker); this._listView._fireAccessibilityAnnotationCompleteEvent(-1, -1); } else { _ElementUtilities._ensureId(firstVisibleItem); _ElementUtilities._ensureId(lastVisibleItem); // Set startMarker's flowto if (this._listView._groupsEnabled()) { var groups = this._listView._groups, firstVisibleGroup = groups.group(groups.groupFromItem(firstIndexDisplayed)); if (firstVisibleGroup.header) { _ElementUtilities._ensureId(firstVisibleGroup.header); if (firstIndexDisplayed === firstVisibleGroup.startIndex) { _ElementUtilities._setAttribute(startMarker, "aria-flowto", firstVisibleGroup.header.id); } else { _ElementUtilities._setAttribute(startMarker, "aria-flowto", firstVisibleItem.id); } } } else { _ElementUtilities._setAttribute(startMarker, "aria-flowto", firstVisibleItem.id); } // Set endMarker's flowfrom _ElementUtilities._setAttribute(endMarker, "x-ms-aria-flowfrom", lastVisibleItem.id); } }
javascript
function VirtualizeContentsView_updateAriaMarkers(listViewIsEmpty, firstIndexDisplayed, lastIndexDisplayed) { var that = this; if (this._listView._isZombie()) { return; } function getFirstVisibleItem() { return that.items.itemAt(firstIndexDisplayed); } // At a certain index, the VDS may return null for all items at that index and // higher. When this is the case, the end marker should point to the last // non-null item in the visible range. function getLastVisibleItem() { for (var i = lastIndexDisplayed; i >= firstIndexDisplayed; i--) { if (that.items.itemAt(i)) { return that.items.itemAt(i); } } return null; } this._listView._createAriaMarkers(); var startMarker = this._listView._ariaStartMarker, endMarker = this._listView._ariaEndMarker, firstVisibleItem, lastVisibleItem; if (firstIndexDisplayed !== -1 && lastIndexDisplayed !== -1 && firstIndexDisplayed <= lastIndexDisplayed) { firstVisibleItem = getFirstVisibleItem(); lastVisibleItem = getLastVisibleItem(); } if (listViewIsEmpty || !firstVisibleItem || !lastVisibleItem) { setFlow(startMarker, endMarker); this._listView._fireAccessibilityAnnotationCompleteEvent(-1, -1); } else { _ElementUtilities._ensureId(firstVisibleItem); _ElementUtilities._ensureId(lastVisibleItem); // Set startMarker's flowto if (this._listView._groupsEnabled()) { var groups = this._listView._groups, firstVisibleGroup = groups.group(groups.groupFromItem(firstIndexDisplayed)); if (firstVisibleGroup.header) { _ElementUtilities._ensureId(firstVisibleGroup.header); if (firstIndexDisplayed === firstVisibleGroup.startIndex) { _ElementUtilities._setAttribute(startMarker, "aria-flowto", firstVisibleGroup.header.id); } else { _ElementUtilities._setAttribute(startMarker, "aria-flowto", firstVisibleItem.id); } } } else { _ElementUtilities._setAttribute(startMarker, "aria-flowto", firstVisibleItem.id); } // Set endMarker's flowfrom _ElementUtilities._setAttribute(endMarker, "x-ms-aria-flowfrom", lastVisibleItem.id); } }
[ "function", "VirtualizeContentsView_updateAriaMarkers", "(", "listViewIsEmpty", ",", "firstIndexDisplayed", ",", "lastIndexDisplayed", ")", "{", "var", "that", "=", "this", ";", "if", "(", "this", ".", "_listView", ".", "_isZombie", "(", ")", ")", "{", "return", ";", "}", "function", "getFirstVisibleItem", "(", ")", "{", "return", "that", ".", "items", ".", "itemAt", "(", "firstIndexDisplayed", ")", ";", "}", "// At a certain index, the VDS may return null for all items at that index and", "// higher. When this is the case, the end marker should point to the last", "// non-null item in the visible range.", "function", "getLastVisibleItem", "(", ")", "{", "for", "(", "var", "i", "=", "lastIndexDisplayed", ";", "i", ">=", "firstIndexDisplayed", ";", "i", "--", ")", "{", "if", "(", "that", ".", "items", ".", "itemAt", "(", "i", ")", ")", "{", "return", "that", ".", "items", ".", "itemAt", "(", "i", ")", ";", "}", "}", "return", "null", ";", "}", "this", ".", "_listView", ".", "_createAriaMarkers", "(", ")", ";", "var", "startMarker", "=", "this", ".", "_listView", ".", "_ariaStartMarker", ",", "endMarker", "=", "this", ".", "_listView", ".", "_ariaEndMarker", ",", "firstVisibleItem", ",", "lastVisibleItem", ";", "if", "(", "firstIndexDisplayed", "!==", "-", "1", "&&", "lastIndexDisplayed", "!==", "-", "1", "&&", "firstIndexDisplayed", "<=", "lastIndexDisplayed", ")", "{", "firstVisibleItem", "=", "getFirstVisibleItem", "(", ")", ";", "lastVisibleItem", "=", "getLastVisibleItem", "(", ")", ";", "}", "if", "(", "listViewIsEmpty", "||", "!", "firstVisibleItem", "||", "!", "lastVisibleItem", ")", "{", "setFlow", "(", "startMarker", ",", "endMarker", ")", ";", "this", ".", "_listView", ".", "_fireAccessibilityAnnotationCompleteEvent", "(", "-", "1", ",", "-", "1", ")", ";", "}", "else", "{", "_ElementUtilities", ".", "_ensureId", "(", "firstVisibleItem", ")", ";", "_ElementUtilities", ".", "_ensureId", "(", "lastVisibleItem", ")", ";", "// Set startMarker's flowto", "if", "(", "this", ".", "_listView", ".", "_groupsEnabled", "(", ")", ")", "{", "var", "groups", "=", "this", ".", "_listView", ".", "_groups", ",", "firstVisibleGroup", "=", "groups", ".", "group", "(", "groups", ".", "groupFromItem", "(", "firstIndexDisplayed", ")", ")", ";", "if", "(", "firstVisibleGroup", ".", "header", ")", "{", "_ElementUtilities", ".", "_ensureId", "(", "firstVisibleGroup", ".", "header", ")", ";", "if", "(", "firstIndexDisplayed", "===", "firstVisibleGroup", ".", "startIndex", ")", "{", "_ElementUtilities", ".", "_setAttribute", "(", "startMarker", ",", "\"aria-flowto\"", ",", "firstVisibleGroup", ".", "header", ".", "id", ")", ";", "}", "else", "{", "_ElementUtilities", ".", "_setAttribute", "(", "startMarker", ",", "\"aria-flowto\"", ",", "firstVisibleItem", ".", "id", ")", ";", "}", "}", "}", "else", "{", "_ElementUtilities", ".", "_setAttribute", "(", "startMarker", ",", "\"aria-flowto\"", ",", "firstVisibleItem", ".", "id", ")", ";", "}", "// Set endMarker's flowfrom", "_ElementUtilities", ".", "_setAttribute", "(", "endMarker", ",", "\"x-ms-aria-flowfrom\"", ",", "lastVisibleItem", ".", "id", ")", ";", "}", "}" ]
Sets aria-flowto on _ariaStartMarker and x-ms-aria-flowfrom on _ariaEndMarker. The former points to either the first visible group header or the first visible item. The latter points to the last visible item.
[ "Sets", "aria", "-", "flowto", "on", "_ariaStartMarker", "and", "x", "-", "ms", "-", "aria", "-", "flowfrom", "on", "_ariaEndMarker", ".", "The", "former", "points", "to", "either", "the", "first", "visible", "group", "header", "or", "the", "first", "visible", "item", ".", "The", "latter", "points", "to", "the", "last", "visible", "item", "." ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L17659-L17720
16,414
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
getLastVisibleItem
function getLastVisibleItem() { for (var i = lastIndexDisplayed; i >= firstIndexDisplayed; i--) { if (that.items.itemAt(i)) { return that.items.itemAt(i); } } return null; }
javascript
function getLastVisibleItem() { for (var i = lastIndexDisplayed; i >= firstIndexDisplayed; i--) { if (that.items.itemAt(i)) { return that.items.itemAt(i); } } return null; }
[ "function", "getLastVisibleItem", "(", ")", "{", "for", "(", "var", "i", "=", "lastIndexDisplayed", ";", "i", ">=", "firstIndexDisplayed", ";", "i", "--", ")", "{", "if", "(", "that", ".", "items", ".", "itemAt", "(", "i", ")", ")", "{", "return", "that", ".", "items", ".", "itemAt", "(", "i", ")", ";", "}", "}", "return", "null", ";", "}" ]
At a certain index, the VDS may return null for all items at that index and higher. When this is the case, the end marker should point to the last non-null item in the visible range.
[ "At", "a", "certain", "index", "the", "VDS", "may", "return", "null", "for", "all", "items", "at", "that", "index", "and", "higher", ".", "When", "this", "is", "the", "case", "the", "end", "marker", "should", "point", "to", "the", "last", "non", "-", "null", "item", "in", "the", "visible", "range", "." ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L17672-L17679
16,415
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
VirtualizeContentsView_updateAriaForAnnouncement
function VirtualizeContentsView_updateAriaForAnnouncement(item, count) { if (item === this._listView.header || item === this._listView.footer) { return; } var index = -1; var type = _UI.ObjectType.item; if (_ElementUtilities.hasClass(item, _Constants._headerClass)) { index = this._listView._groups.index(item); type = _UI.ObjectType.groupHeader; _ElementUtilities._setAttribute(item, "role", this._listView._headerRole); _ElementUtilities._setAttribute(item, "tabindex", this._listView._tabIndex); } else { index = this.items.index(item); _ElementUtilities._setAttribute(item, "aria-setsize", count); _ElementUtilities._setAttribute(item, "aria-posinset", index + 1); _ElementUtilities._setAttribute(item, "role", this._listView._itemRole); _ElementUtilities._setAttribute(item, "tabindex", this._listView._tabIndex); } if (type === _UI.ObjectType.groupHeader) { this._listView._fireAccessibilityAnnotationCompleteEvent(-1, -1, index, index); } else { this._listView._fireAccessibilityAnnotationCompleteEvent(index, index, -1, -1); } }
javascript
function VirtualizeContentsView_updateAriaForAnnouncement(item, count) { if (item === this._listView.header || item === this._listView.footer) { return; } var index = -1; var type = _UI.ObjectType.item; if (_ElementUtilities.hasClass(item, _Constants._headerClass)) { index = this._listView._groups.index(item); type = _UI.ObjectType.groupHeader; _ElementUtilities._setAttribute(item, "role", this._listView._headerRole); _ElementUtilities._setAttribute(item, "tabindex", this._listView._tabIndex); } else { index = this.items.index(item); _ElementUtilities._setAttribute(item, "aria-setsize", count); _ElementUtilities._setAttribute(item, "aria-posinset", index + 1); _ElementUtilities._setAttribute(item, "role", this._listView._itemRole); _ElementUtilities._setAttribute(item, "tabindex", this._listView._tabIndex); } if (type === _UI.ObjectType.groupHeader) { this._listView._fireAccessibilityAnnotationCompleteEvent(-1, -1, index, index); } else { this._listView._fireAccessibilityAnnotationCompleteEvent(index, index, -1, -1); } }
[ "function", "VirtualizeContentsView_updateAriaForAnnouncement", "(", "item", ",", "count", ")", "{", "if", "(", "item", "===", "this", ".", "_listView", ".", "header", "||", "item", "===", "this", ".", "_listView", ".", "footer", ")", "{", "return", ";", "}", "var", "index", "=", "-", "1", ";", "var", "type", "=", "_UI", ".", "ObjectType", ".", "item", ";", "if", "(", "_ElementUtilities", ".", "hasClass", "(", "item", ",", "_Constants", ".", "_headerClass", ")", ")", "{", "index", "=", "this", ".", "_listView", ".", "_groups", ".", "index", "(", "item", ")", ";", "type", "=", "_UI", ".", "ObjectType", ".", "groupHeader", ";", "_ElementUtilities", ".", "_setAttribute", "(", "item", ",", "\"role\"", ",", "this", ".", "_listView", ".", "_headerRole", ")", ";", "_ElementUtilities", ".", "_setAttribute", "(", "item", ",", "\"tabindex\"", ",", "this", ".", "_listView", ".", "_tabIndex", ")", ";", "}", "else", "{", "index", "=", "this", ".", "items", ".", "index", "(", "item", ")", ";", "_ElementUtilities", ".", "_setAttribute", "(", "item", ",", "\"aria-setsize\"", ",", "count", ")", ";", "_ElementUtilities", ".", "_setAttribute", "(", "item", ",", "\"aria-posinset\"", ",", "index", "+", "1", ")", ";", "_ElementUtilities", ".", "_setAttribute", "(", "item", ",", "\"role\"", ",", "this", ".", "_listView", ".", "_itemRole", ")", ";", "_ElementUtilities", ".", "_setAttribute", "(", "item", ",", "\"tabindex\"", ",", "this", ".", "_listView", ".", "_tabIndex", ")", ";", "}", "if", "(", "type", "===", "_UI", ".", "ObjectType", ".", "groupHeader", ")", "{", "this", ".", "_listView", ".", "_fireAccessibilityAnnotationCompleteEvent", "(", "-", "1", ",", "-", "1", ",", "index", ",", "index", ")", ";", "}", "else", "{", "this", ".", "_listView", ".", "_fireAccessibilityAnnotationCompleteEvent", "(", "index", ",", "index", ",", "-", "1", ",", "-", "1", ")", ";", "}", "}" ]
Update the ARIA attributes on item that are needed so that Narrator can announce it. item must be in the items container.
[ "Update", "the", "ARIA", "attributes", "on", "item", "that", "are", "needed", "so", "that", "Narrator", "can", "announce", "it", ".", "item", "must", "be", "in", "the", "items", "container", "." ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L17724-L17749
16,416
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
VirtualizeContentsView_createChunk
function VirtualizeContentsView_createChunk(groups, count, chunkSize) { var that = this; this._listView._writeProfilerMark("createChunk,StartTM"); function addToGroup(itemsContainer, groupSize) { var children = itemsContainer.element.children, oldSize = children.length, toAdd = Math.min(groupSize - itemsContainer.items.length, chunkSize); _SafeHtml.insertAdjacentHTMLUnsafe(itemsContainer.element, "beforeend", _Helpers._repeat("<div class='win-container win-backdrop'></div>", toAdd)); for (var i = 0; i < toAdd; i++) { var container = children[oldSize + i]; itemsContainer.items.push(container); that.containers.push(container); } } function newGroup(group) { var node = { header: that._listView._groupDataSource ? that._createHeaderContainer() : null, itemsContainer: { element: that._createItemsContainer(), items: [] } }; that.tree.push(node); that.keyToGroupIndex[group.key] = that.tree.length - 1; addToGroup(node.itemsContainer, group.size); } if (this.tree.length && this.tree.length <= groups.length) { var last = this.tree[this.tree.length - 1], finalSize = groups[this.tree.length - 1].size; // check if the last group in the tree already has all items. If not add items to this group if (last.itemsContainer.items.length < finalSize) { addToGroup(last.itemsContainer, finalSize); this._listView._writeProfilerMark("createChunk,StopTM"); return; } } if (this.tree.length < groups.length) { newGroup(groups[this.tree.length]); } this._listView._writeProfilerMark("createChunk,StopTM"); }
javascript
function VirtualizeContentsView_createChunk(groups, count, chunkSize) { var that = this; this._listView._writeProfilerMark("createChunk,StartTM"); function addToGroup(itemsContainer, groupSize) { var children = itemsContainer.element.children, oldSize = children.length, toAdd = Math.min(groupSize - itemsContainer.items.length, chunkSize); _SafeHtml.insertAdjacentHTMLUnsafe(itemsContainer.element, "beforeend", _Helpers._repeat("<div class='win-container win-backdrop'></div>", toAdd)); for (var i = 0; i < toAdd; i++) { var container = children[oldSize + i]; itemsContainer.items.push(container); that.containers.push(container); } } function newGroup(group) { var node = { header: that._listView._groupDataSource ? that._createHeaderContainer() : null, itemsContainer: { element: that._createItemsContainer(), items: [] } }; that.tree.push(node); that.keyToGroupIndex[group.key] = that.tree.length - 1; addToGroup(node.itemsContainer, group.size); } if (this.tree.length && this.tree.length <= groups.length) { var last = this.tree[this.tree.length - 1], finalSize = groups[this.tree.length - 1].size; // check if the last group in the tree already has all items. If not add items to this group if (last.itemsContainer.items.length < finalSize) { addToGroup(last.itemsContainer, finalSize); this._listView._writeProfilerMark("createChunk,StopTM"); return; } } if (this.tree.length < groups.length) { newGroup(groups[this.tree.length]); } this._listView._writeProfilerMark("createChunk,StopTM"); }
[ "function", "VirtualizeContentsView_createChunk", "(", "groups", ",", "count", ",", "chunkSize", ")", "{", "var", "that", "=", "this", ";", "this", ".", "_listView", ".", "_writeProfilerMark", "(", "\"createChunk,StartTM\"", ")", ";", "function", "addToGroup", "(", "itemsContainer", ",", "groupSize", ")", "{", "var", "children", "=", "itemsContainer", ".", "element", ".", "children", ",", "oldSize", "=", "children", ".", "length", ",", "toAdd", "=", "Math", ".", "min", "(", "groupSize", "-", "itemsContainer", ".", "items", ".", "length", ",", "chunkSize", ")", ";", "_SafeHtml", ".", "insertAdjacentHTMLUnsafe", "(", "itemsContainer", ".", "element", ",", "\"beforeend\"", ",", "_Helpers", ".", "_repeat", "(", "\"<div class='win-container win-backdrop'></div>\"", ",", "toAdd", ")", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "toAdd", ";", "i", "++", ")", "{", "var", "container", "=", "children", "[", "oldSize", "+", "i", "]", ";", "itemsContainer", ".", "items", ".", "push", "(", "container", ")", ";", "that", ".", "containers", ".", "push", "(", "container", ")", ";", "}", "}", "function", "newGroup", "(", "group", ")", "{", "var", "node", "=", "{", "header", ":", "that", ".", "_listView", ".", "_groupDataSource", "?", "that", ".", "_createHeaderContainer", "(", ")", ":", "null", ",", "itemsContainer", ":", "{", "element", ":", "that", ".", "_createItemsContainer", "(", ")", ",", "items", ":", "[", "]", "}", "}", ";", "that", ".", "tree", ".", "push", "(", "node", ")", ";", "that", ".", "keyToGroupIndex", "[", "group", ".", "key", "]", "=", "that", ".", "tree", ".", "length", "-", "1", ";", "addToGroup", "(", "node", ".", "itemsContainer", ",", "group", ".", "size", ")", ";", "}", "if", "(", "this", ".", "tree", ".", "length", "&&", "this", ".", "tree", ".", "length", "<=", "groups", ".", "length", ")", "{", "var", "last", "=", "this", ".", "tree", "[", "this", ".", "tree", ".", "length", "-", "1", "]", ",", "finalSize", "=", "groups", "[", "this", ".", "tree", ".", "length", "-", "1", "]", ".", "size", ";", "// check if the last group in the tree already has all items. If not add items to this group", "if", "(", "last", ".", "itemsContainer", ".", "items", ".", "length", "<", "finalSize", ")", "{", "addToGroup", "(", "last", ".", "itemsContainer", ",", "finalSize", ")", ";", "this", ".", "_listView", ".", "_writeProfilerMark", "(", "\"createChunk,StopTM\"", ")", ";", "return", ";", "}", "}", "if", "(", "this", ".", "tree", ".", "length", "<", "groups", ".", "length", ")", "{", "newGroup", "(", "groups", "[", "this", ".", "tree", ".", "length", "]", ")", ";", "}", "this", ".", "_listView", ".", "_writeProfilerMark", "(", "\"createChunk,StopTM\"", ")", ";", "}" ]
Overridden by tests. Tests should have _createChunk return true when they want _createContainers to stop creating containers.
[ "Overridden", "by", "tests", ".", "Tests", "should", "have", "_createChunk", "return", "true", "when", "they", "want", "_createContainers", "to", "stop", "creating", "containers", "." ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L18512-L18563
16,417
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
function (range, itemsCount) { range._lastKnownSizeOfData = itemsCount; // store this in order to make unions. if (!this._range) { this._range = range; } else { // Take the union of these two ranges. this._range.start = Math.min(this._range.start, range.start); // To accurately calculate the new unioned range 'end' value, we need to convert the current and new range end // positions into values that represent the remaining number of un-modified items in between the end of the range // and the end of the list of data. var previousUnmodifiedItemsFromEnd = (this._range._lastKnownSizeOfData - this._range.end); var newUnmodifiedItemsFromEnd = (range._lastKnownSizeOfData - range.end); var finalUnmodifiedItemsFromEnd = Math.min(previousUnmodifiedItemsFromEnd, newUnmodifiedItemsFromEnd); this._range._lastKnownSizeOfData = range._lastKnownSizeOfData; // Convert representation of the unioned end position back into a value which matches the above definition of _affecteRange.end this._range.end = this._range._lastKnownSizeOfData - finalUnmodifiedItemsFromEnd; } }
javascript
function (range, itemsCount) { range._lastKnownSizeOfData = itemsCount; // store this in order to make unions. if (!this._range) { this._range = range; } else { // Take the union of these two ranges. this._range.start = Math.min(this._range.start, range.start); // To accurately calculate the new unioned range 'end' value, we need to convert the current and new range end // positions into values that represent the remaining number of un-modified items in between the end of the range // and the end of the list of data. var previousUnmodifiedItemsFromEnd = (this._range._lastKnownSizeOfData - this._range.end); var newUnmodifiedItemsFromEnd = (range._lastKnownSizeOfData - range.end); var finalUnmodifiedItemsFromEnd = Math.min(previousUnmodifiedItemsFromEnd, newUnmodifiedItemsFromEnd); this._range._lastKnownSizeOfData = range._lastKnownSizeOfData; // Convert representation of the unioned end position back into a value which matches the above definition of _affecteRange.end this._range.end = this._range._lastKnownSizeOfData - finalUnmodifiedItemsFromEnd; } }
[ "function", "(", "range", ",", "itemsCount", ")", "{", "range", ".", "_lastKnownSizeOfData", "=", "itemsCount", ";", "// store this in order to make unions.", "if", "(", "!", "this", ".", "_range", ")", "{", "this", ".", "_range", "=", "range", ";", "}", "else", "{", "// Take the union of these two ranges.", "this", ".", "_range", ".", "start", "=", "Math", ".", "min", "(", "this", ".", "_range", ".", "start", ",", "range", ".", "start", ")", ";", "// To accurately calculate the new unioned range 'end' value, we need to convert the current and new range end", "// positions into values that represent the remaining number of un-modified items in between the end of the range", "// and the end of the list of data.", "var", "previousUnmodifiedItemsFromEnd", "=", "(", "this", ".", "_range", ".", "_lastKnownSizeOfData", "-", "this", ".", "_range", ".", "end", ")", ";", "var", "newUnmodifiedItemsFromEnd", "=", "(", "range", ".", "_lastKnownSizeOfData", "-", "range", ".", "end", ")", ";", "var", "finalUnmodifiedItemsFromEnd", "=", "Math", ".", "min", "(", "previousUnmodifiedItemsFromEnd", ",", "newUnmodifiedItemsFromEnd", ")", ";", "this", ".", "_range", ".", "_lastKnownSizeOfData", "=", "range", ".", "_lastKnownSizeOfData", ";", "// Convert representation of the unioned end position back into a value which matches the above definition of _affecteRange.end", "this", ".", "_range", ".", "end", "=", "this", ".", "_range", ".", "_lastKnownSizeOfData", "-", "finalUnmodifiedItemsFromEnd", ";", "}", "}" ]
Marks the union of the current affected range and range as requiring layout
[ "Marks", "the", "union", "of", "the", "current", "affected", "range", "and", "range", "as", "requiring", "layout" ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L19972-L19989
16,418
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
ListView_convertCoordinatesByCanvasMargins
function ListView_convertCoordinatesByCanvasMargins(coordinates, conversionCallback) { function fix(field, offset) { if (coordinates[field] !== undefined) { coordinates[field] = conversionCallback(coordinates[field], offset); } } var offset; if (this._horizontal()) { offset = this._getCanvasMargins()[this._rtl() ? "right" : "left"]; fix("left", offset); } else { offset = this._getCanvasMargins().top; fix("top", offset); } fix("begin", offset); fix("end", offset); return coordinates; }
javascript
function ListView_convertCoordinatesByCanvasMargins(coordinates, conversionCallback) { function fix(field, offset) { if (coordinates[field] !== undefined) { coordinates[field] = conversionCallback(coordinates[field], offset); } } var offset; if (this._horizontal()) { offset = this._getCanvasMargins()[this._rtl() ? "right" : "left"]; fix("left", offset); } else { offset = this._getCanvasMargins().top; fix("top", offset); } fix("begin", offset); fix("end", offset); return coordinates; }
[ "function", "ListView_convertCoordinatesByCanvasMargins", "(", "coordinates", ",", "conversionCallback", ")", "{", "function", "fix", "(", "field", ",", "offset", ")", "{", "if", "(", "coordinates", "[", "field", "]", "!==", "undefined", ")", "{", "coordinates", "[", "field", "]", "=", "conversionCallback", "(", "coordinates", "[", "field", "]", ",", "offset", ")", ";", "}", "}", "var", "offset", ";", "if", "(", "this", ".", "_horizontal", "(", ")", ")", "{", "offset", "=", "this", ".", "_getCanvasMargins", "(", ")", "[", "this", ".", "_rtl", "(", ")", "?", "\"right\"", ":", "\"left\"", "]", ";", "fix", "(", "\"left\"", ",", "offset", ")", ";", "}", "else", "{", "offset", "=", "this", ".", "_getCanvasMargins", "(", ")", ".", "top", ";", "fix", "(", "\"top\"", ",", "offset", ")", ";", "}", "fix", "(", "\"begin\"", ",", "offset", ")", ";", "fix", "(", "\"end\"", ",", "offset", ")", ";", "return", "coordinates", ";", "}" ]
Convert between canvas coordinates and viewport coordinates
[ "Convert", "between", "canvas", "coordinates", "and", "viewport", "coordinates" ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L22783-L22802
16,419
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
ListView_getViewportSize
function ListView_getViewportSize() { if (this._viewportWidth === _Constants._UNINITIALIZED || this._viewportHeight === _Constants._UNINITIALIZED) { this._viewportWidth = Math.max(0, _ElementUtilities.getContentWidth(this._element)); this._viewportHeight = Math.max(0, _ElementUtilities.getContentHeight(this._element)); this._writeProfilerMark("viewportSizeDetected width:" + this._viewportWidth + " height:" + this._viewportHeight); this._previousWidth = this._element.offsetWidth; this._previousHeight = this._element.offsetHeight; } return { width: this._viewportWidth, height: this._viewportHeight }; }
javascript
function ListView_getViewportSize() { if (this._viewportWidth === _Constants._UNINITIALIZED || this._viewportHeight === _Constants._UNINITIALIZED) { this._viewportWidth = Math.max(0, _ElementUtilities.getContentWidth(this._element)); this._viewportHeight = Math.max(0, _ElementUtilities.getContentHeight(this._element)); this._writeProfilerMark("viewportSizeDetected width:" + this._viewportWidth + " height:" + this._viewportHeight); this._previousWidth = this._element.offsetWidth; this._previousHeight = this._element.offsetHeight; } return { width: this._viewportWidth, height: this._viewportHeight }; }
[ "function", "ListView_getViewportSize", "(", ")", "{", "if", "(", "this", ".", "_viewportWidth", "===", "_Constants", ".", "_UNINITIALIZED", "||", "this", ".", "_viewportHeight", "===", "_Constants", ".", "_UNINITIALIZED", ")", "{", "this", ".", "_viewportWidth", "=", "Math", ".", "max", "(", "0", ",", "_ElementUtilities", ".", "getContentWidth", "(", "this", ".", "_element", ")", ")", ";", "this", ".", "_viewportHeight", "=", "Math", ".", "max", "(", "0", ",", "_ElementUtilities", ".", "getContentHeight", "(", "this", ".", "_element", ")", ")", ";", "this", ".", "_writeProfilerMark", "(", "\"viewportSizeDetected width:\"", "+", "this", ".", "_viewportWidth", "+", "\" height:\"", "+", "this", ".", "_viewportHeight", ")", ";", "this", ".", "_previousWidth", "=", "this", ".", "_element", ".", "offsetWidth", ";", "this", ".", "_previousHeight", "=", "this", ".", "_element", ".", "offsetHeight", ";", "}", "return", "{", "width", ":", "this", ".", "_viewportWidth", ",", "height", ":", "this", ".", "_viewportHeight", "}", ";", "}" ]
Methods in the site interface used by ScrollView
[ "Methods", "in", "the", "site", "interface", "used", "by", "ScrollView" ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L22815-L22828
16,420
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
ListView_updateSelection
function ListView_updateSelection() { var indices = this._selection.getIndices(), selectAll = this._selection.isEverything(), selectionMap = {}; if (!selectAll) { for (var i = 0, len = indices.length ; i < len; i++) { var index = indices[i]; selectionMap[index] = true; } } this._view.items.each(function (index, element, itemData) { if (itemData.itemBox) { var selected = selectAll || !!selectionMap[index]; _ItemEventsHandler._ItemEventsHandler.renderSelection(itemData.itemBox, element, selected, true); if (itemData.container) { _ElementUtilities[selected ? "addClass" : "removeClass"](itemData.container, _Constants._selectedClass); } } }); }
javascript
function ListView_updateSelection() { var indices = this._selection.getIndices(), selectAll = this._selection.isEverything(), selectionMap = {}; if (!selectAll) { for (var i = 0, len = indices.length ; i < len; i++) { var index = indices[i]; selectionMap[index] = true; } } this._view.items.each(function (index, element, itemData) { if (itemData.itemBox) { var selected = selectAll || !!selectionMap[index]; _ItemEventsHandler._ItemEventsHandler.renderSelection(itemData.itemBox, element, selected, true); if (itemData.container) { _ElementUtilities[selected ? "addClass" : "removeClass"](itemData.container, _Constants._selectedClass); } } }); }
[ "function", "ListView_updateSelection", "(", ")", "{", "var", "indices", "=", "this", ".", "_selection", ".", "getIndices", "(", ")", ",", "selectAll", "=", "this", ".", "_selection", ".", "isEverything", "(", ")", ",", "selectionMap", "=", "{", "}", ";", "if", "(", "!", "selectAll", ")", "{", "for", "(", "var", "i", "=", "0", ",", "len", "=", "indices", ".", "length", ";", "i", "<", "len", ";", "i", "++", ")", "{", "var", "index", "=", "indices", "[", "i", "]", ";", "selectionMap", "[", "index", "]", "=", "true", ";", "}", "}", "this", ".", "_view", ".", "items", ".", "each", "(", "function", "(", "index", ",", "element", ",", "itemData", ")", "{", "if", "(", "itemData", ".", "itemBox", ")", "{", "var", "selected", "=", "selectAll", "||", "!", "!", "selectionMap", "[", "index", "]", ";", "_ItemEventsHandler", ".", "_ItemEventsHandler", ".", "renderSelection", "(", "itemData", ".", "itemBox", ",", "element", ",", "selected", ",", "true", ")", ";", "if", "(", "itemData", ".", "container", ")", "{", "_ElementUtilities", "[", "selected", "?", "\"addClass\"", ":", "\"removeClass\"", "]", "(", "itemData", ".", "container", ",", "_Constants", ".", "_selectedClass", ")", ";", "}", "}", "}", ")", ";", "}" ]
Methods used by SelectionManager
[ "Methods", "used", "by", "SelectionManager" ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L22973-L22994
16,421
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
FlipView_inserted
function FlipView_inserted(itemPromise, previousHandle, nextHandle) { that._itemsManager._itemFromPromise(itemPromise).then(function (element) { var previous = that._itemsManager._elementFromHandle(previousHandle); var next = that._itemsManager._elementFromHandle(nextHandle); that._pageManager.inserted(element, previous, next, true); }); }
javascript
function FlipView_inserted(itemPromise, previousHandle, nextHandle) { that._itemsManager._itemFromPromise(itemPromise).then(function (element) { var previous = that._itemsManager._elementFromHandle(previousHandle); var next = that._itemsManager._elementFromHandle(nextHandle); that._pageManager.inserted(element, previous, next, true); }); }
[ "function", "FlipView_inserted", "(", "itemPromise", ",", "previousHandle", ",", "nextHandle", ")", "{", "that", ".", "_itemsManager", ".", "_itemFromPromise", "(", "itemPromise", ")", ".", "then", "(", "function", "(", "element", ")", "{", "var", "previous", "=", "that", ".", "_itemsManager", ".", "_elementFromHandle", "(", "previousHandle", ")", ";", "var", "next", "=", "that", ".", "_itemsManager", ".", "_elementFromHandle", "(", "nextHandle", ")", ";", "that", ".", "_pageManager", ".", "inserted", "(", "element", ",", "previous", ",", "next", ",", "true", ")", ";", "}", ")", ";", "}" ]
Callbacks for itemsManager
[ "Callbacks", "for", "itemsManager" ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L26982-L26988
16,422
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
function (date1, date2) { return date1.getHours() === date2.getHours() && date1.getMinutes() === date2.getMinutes(); }
javascript
function (date1, date2) { return date1.getHours() === date2.getHours() && date1.getMinutes() === date2.getMinutes(); }
[ "function", "(", "date1", ",", "date2", ")", "{", "return", "date1", ".", "getHours", "(", ")", "===", "date2", ".", "getHours", "(", ")", "&&", "date1", ".", "getMinutes", "(", ")", "===", "date2", ".", "getMinutes", "(", ")", ";", "}" ]
date1 and date2 must be Date objects with their date portions set to the sentinel date.
[ "date1", "and", "date2", "must", "be", "Date", "objects", "with", "their", "date", "portions", "set", "to", "the", "sentinel", "date", "." ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L29811-L29814
16,423
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
function (event) { this._lastKeyOrBlurEvent = this._currentKeyOrBlurEvent; switch (event.type) { case "keyup": if (event.keyCode === Key.shift) { this._currentKeyOrBlurEvent = null; } else { this._currentKeyOrBlurEvent = "keyboard"; } break; case "focusout": //anchor element no longer in focus, clear up the stack this._currentKeyOrBlurEvent = null; break; default: break; } }
javascript
function (event) { this._lastKeyOrBlurEvent = this._currentKeyOrBlurEvent; switch (event.type) { case "keyup": if (event.keyCode === Key.shift) { this._currentKeyOrBlurEvent = null; } else { this._currentKeyOrBlurEvent = "keyboard"; } break; case "focusout": //anchor element no longer in focus, clear up the stack this._currentKeyOrBlurEvent = null; break; default: break; } }
[ "function", "(", "event", ")", "{", "this", ".", "_lastKeyOrBlurEvent", "=", "this", ".", "_currentKeyOrBlurEvent", ";", "switch", "(", "event", ".", "type", ")", "{", "case", "\"keyup\"", ":", "if", "(", "event", ".", "keyCode", "===", "Key", ".", "shift", ")", "{", "this", ".", "_currentKeyOrBlurEvent", "=", "null", ";", "}", "else", "{", "this", ".", "_currentKeyOrBlurEvent", "=", "\"keyboard\"", ";", "}", "break", ";", "case", "\"focusout\"", ":", "//anchor element no longer in focus, clear up the stack", "this", ".", "_currentKeyOrBlurEvent", "=", "null", ";", "break", ";", "default", ":", "break", ";", "}", "}" ]
Support for keyboard navigation
[ "Support", "for", "keyboard", "navigation" ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L31080-L31098
16,424
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
function () { var rect = this._anchorElement.getBoundingClientRect(); return { x: rect.left, y: rect.top, width: rect.width, height: rect.height }; }
javascript
function () { var rect = this._anchorElement.getBoundingClientRect(); return { x: rect.left, y: rect.top, width: rect.width, height: rect.height }; }
[ "function", "(", ")", "{", "var", "rect", "=", "this", ".", "_anchorElement", ".", "getBoundingClientRect", "(", ")", ";", "return", "{", "x", ":", "rect", ".", "left", ",", "y", ":", "rect", ".", "top", ",", "width", ":", "rect", ".", "width", ",", "height", ":", "rect", ".", "height", "}", ";", "}" ]
This function returns the anchor element's position in the Window coordinates.
[ "This", "function", "returns", "the", "anchor", "element", "s", "position", "in", "the", "Window", "coordinates", "." ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L31243-L31252
16,425
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
function () { this._closeTooltip(); var firePreviewChange = true; if (this._tentativeRating <= 0) { firePreviewChange = false; } else { if (this._tentativeRating > 0) { this._tentativeRating--; } else if (this._tentativeRating === -1) { if (this._userRating !== 0) { if (this._userRating > 0) { this._tentativeRating = this._userRating - 1; } else { this._tentativeRating = 0; } } else { this._tentativeRating = 0; } } if ((this._tentativeRating === 0) && !this._enableClear) { this._tentativeRating = 1; firePreviewChange = false; } } this._showTentativeRating(firePreviewChange, "keyboard"); }
javascript
function () { this._closeTooltip(); var firePreviewChange = true; if (this._tentativeRating <= 0) { firePreviewChange = false; } else { if (this._tentativeRating > 0) { this._tentativeRating--; } else if (this._tentativeRating === -1) { if (this._userRating !== 0) { if (this._userRating > 0) { this._tentativeRating = this._userRating - 1; } else { this._tentativeRating = 0; } } else { this._tentativeRating = 0; } } if ((this._tentativeRating === 0) && !this._enableClear) { this._tentativeRating = 1; firePreviewChange = false; } } this._showTentativeRating(firePreviewChange, "keyboard"); }
[ "function", "(", ")", "{", "this", ".", "_closeTooltip", "(", ")", ";", "var", "firePreviewChange", "=", "true", ";", "if", "(", "this", ".", "_tentativeRating", "<=", "0", ")", "{", "firePreviewChange", "=", "false", ";", "}", "else", "{", "if", "(", "this", ".", "_tentativeRating", ">", "0", ")", "{", "this", ".", "_tentativeRating", "--", ";", "}", "else", "if", "(", "this", ".", "_tentativeRating", "===", "-", "1", ")", "{", "if", "(", "this", ".", "_userRating", "!==", "0", ")", "{", "if", "(", "this", ".", "_userRating", ">", "0", ")", "{", "this", ".", "_tentativeRating", "=", "this", ".", "_userRating", "-", "1", ";", "}", "else", "{", "this", ".", "_tentativeRating", "=", "0", ";", "}", "}", "else", "{", "this", ".", "_tentativeRating", "=", "0", ";", "}", "}", "if", "(", "(", "this", ".", "_tentativeRating", "===", "0", ")", "&&", "!", "this", ".", "_enableClear", ")", "{", "this", ".", "_tentativeRating", "=", "1", ";", "firePreviewChange", "=", "false", ";", "}", "}", "this", ".", "_showTentativeRating", "(", "firePreviewChange", ",", "\"keyboard\"", ")", ";", "}" ]
decrement tentative rating by one
[ "decrement", "tentative", "rating", "by", "one" ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L32040-L32067
16,426
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
function () { this._closeTooltip(); var firePreviewChange = true; if (this._tentativeRating < 0 || this._tentativeRating >= this._maxRating) { firePreviewChange = false; } if (this._tentativeRating !== -1) { if (this._tentativeRating < this._maxRating) { this._tentativeRating++; } } else { if (this._userRating !== 0) { if (this._userRating < this._maxRating) { this._tentativeRating = this._userRating + 1; } else { this._tentativeRating = this._maxRating; } } else { this._tentativeRating = 1; } } this._showTentativeRating(firePreviewChange, "keyboard"); }
javascript
function () { this._closeTooltip(); var firePreviewChange = true; if (this._tentativeRating < 0 || this._tentativeRating >= this._maxRating) { firePreviewChange = false; } if (this._tentativeRating !== -1) { if (this._tentativeRating < this._maxRating) { this._tentativeRating++; } } else { if (this._userRating !== 0) { if (this._userRating < this._maxRating) { this._tentativeRating = this._userRating + 1; } else { this._tentativeRating = this._maxRating; } } else { this._tentativeRating = 1; } } this._showTentativeRating(firePreviewChange, "keyboard"); }
[ "function", "(", ")", "{", "this", ".", "_closeTooltip", "(", ")", ";", "var", "firePreviewChange", "=", "true", ";", "if", "(", "this", ".", "_tentativeRating", "<", "0", "||", "this", ".", "_tentativeRating", ">=", "this", ".", "_maxRating", ")", "{", "firePreviewChange", "=", "false", ";", "}", "if", "(", "this", ".", "_tentativeRating", "!==", "-", "1", ")", "{", "if", "(", "this", ".", "_tentativeRating", "<", "this", ".", "_maxRating", ")", "{", "this", ".", "_tentativeRating", "++", ";", "}", "}", "else", "{", "if", "(", "this", ".", "_userRating", "!==", "0", ")", "{", "if", "(", "this", ".", "_userRating", "<", "this", ".", "_maxRating", ")", "{", "this", ".", "_tentativeRating", "=", "this", ".", "_userRating", "+", "1", ";", "}", "else", "{", "this", ".", "_tentativeRating", "=", "this", ".", "_maxRating", ";", "}", "}", "else", "{", "this", ".", "_tentativeRating", "=", "1", ";", "}", "}", "this", ".", "_showTentativeRating", "(", "firePreviewChange", ",", "\"keyboard\"", ")", ";", "}" ]
increase tentative rating by one
[ "increase", "tentative", "rating", "by", "one" ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L32147-L32170
16,427
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
filterOnScreen
function filterOnScreen(element) { var elementBoundingClientRect = element.getBoundingClientRect(); // Can't check left/right since it might be scrolled off. return elementBoundingClientRect.top < viewportBoundingClientRect.bottom && elementBoundingClientRect.bottom > viewportBoundingClientRect.top; }
javascript
function filterOnScreen(element) { var elementBoundingClientRect = element.getBoundingClientRect(); // Can't check left/right since it might be scrolled off. return elementBoundingClientRect.top < viewportBoundingClientRect.bottom && elementBoundingClientRect.bottom > viewportBoundingClientRect.top; }
[ "function", "filterOnScreen", "(", "element", ")", "{", "var", "elementBoundingClientRect", "=", "element", ".", "getBoundingClientRect", "(", ")", ";", "// Can't check left/right since it might be scrolled off.", "return", "elementBoundingClientRect", ".", "top", "<", "viewportBoundingClientRect", ".", "bottom", "&&", "elementBoundingClientRect", ".", "bottom", ">", "viewportBoundingClientRect", ".", "top", ";", "}" ]
Find the elements to slide in
[ "Find", "the", "elements", "to", "slide", "in" ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L35748-L35752
16,428
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
_allOverlaysCallback
function _allOverlaysCallback(event, nameOfFunctionCall, stopImmediatePropagationWhenHandled) { var elements = _Global.document.querySelectorAll("." + _Constants.overlayClass); if (elements) { var len = elements.length; for (var i = 0; i < len; i++) { var element = elements[i]; var overlay = element.winControl; if (!overlay._disposed) { if (overlay) { var handled = overlay[nameOfFunctionCall](event); if (stopImmediatePropagationWhenHandled && handled) { // The caller has indicated we should exit as soon as the event is handled. return handled; } } } } } }
javascript
function _allOverlaysCallback(event, nameOfFunctionCall, stopImmediatePropagationWhenHandled) { var elements = _Global.document.querySelectorAll("." + _Constants.overlayClass); if (elements) { var len = elements.length; for (var i = 0; i < len; i++) { var element = elements[i]; var overlay = element.winControl; if (!overlay._disposed) { if (overlay) { var handled = overlay[nameOfFunctionCall](event); if (stopImmediatePropagationWhenHandled && handled) { // The caller has indicated we should exit as soon as the event is handled. return handled; } } } } } }
[ "function", "_allOverlaysCallback", "(", "event", ",", "nameOfFunctionCall", ",", "stopImmediatePropagationWhenHandled", ")", "{", "var", "elements", "=", "_Global", ".", "document", ".", "querySelectorAll", "(", "\".\"", "+", "_Constants", ".", "overlayClass", ")", ";", "if", "(", "elements", ")", "{", "var", "len", "=", "elements", ".", "length", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "{", "var", "element", "=", "elements", "[", "i", "]", ";", "var", "overlay", "=", "element", ".", "winControl", ";", "if", "(", "!", "overlay", ".", "_disposed", ")", "{", "if", "(", "overlay", ")", "{", "var", "handled", "=", "overlay", "[", "nameOfFunctionCall", "]", "(", "event", ")", ";", "if", "(", "stopImmediatePropagationWhenHandled", "&&", "handled", ")", "{", "// The caller has indicated we should exit as soon as the event is handled.", "return", "handled", ";", "}", "}", "}", "}", "}", "}" ]
Helper for Global Event listeners. Invokes the specified callback member function on each _Overlay in the DOM.
[ "Helper", "for", "Global", "Event", "listeners", ".", "Invokes", "the", "specified", "callback", "member", "function", "on", "each", "_Overlay", "in", "the", "DOM", "." ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L38955-L38973
16,429
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
_Overlay_sendEvent
function _Overlay_sendEvent(eventName, detail) { if (this._disposed) { return; } var event = _Global.document.createEvent("CustomEvent"); event.initEvent(eventName, true, true, (detail || {})); this._element.dispatchEvent(event); }
javascript
function _Overlay_sendEvent(eventName, detail) { if (this._disposed) { return; } var event = _Global.document.createEvent("CustomEvent"); event.initEvent(eventName, true, true, (detail || {})); this._element.dispatchEvent(event); }
[ "function", "_Overlay_sendEvent", "(", "eventName", ",", "detail", ")", "{", "if", "(", "this", ".", "_disposed", ")", "{", "return", ";", "}", "var", "event", "=", "_Global", ".", "document", ".", "createEvent", "(", "\"CustomEvent\"", ")", ";", "event", ".", "initEvent", "(", "eventName", ",", "true", ",", "true", ",", "(", "detail", "||", "{", "}", ")", ")", ";", "this", ".", "_element", ".", "dispatchEvent", "(", "event", ")", ";", "}" ]
Send one of our events
[ "Send", "one", "of", "our", "events" ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L39464-L39471
16,430
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
_Overlay_showAndHideQueue
function _Overlay_showAndHideQueue() { // Only called if not currently animating. // We'll be done with the queued stuff when we return. this._queuedCommandAnimation = false; // Shortcut if hidden if (this.hidden) { this._showAndHideFast(this._queuedToShow, this._queuedToHide); // Might be something else to do Scheduler.schedule(this._checkDoNext, Scheduler.Priority.normal, this, "WinJS.UI._Overlay._checkDoNext"); } else { // Animation has 3 parts: "hiding", "showing", and "moving" // PVL has "addToList" and "deleteFromList", both of which allow moving parts. // So we'll set up "add" for showing, and use "delete" for "hiding" + moving, // then trigger both at the same time. var showCommands = this._queuedToShow; var hideCommands = this._queuedToHide; var siblings = this._findSiblings(showCommands.concat(hideCommands)); // Filter out the commands queued for animation that don't need to be animated. var count; for (count = 0; count < showCommands.length; count++) { // If this one's not real or not attached, skip it if (!showCommands[count] || !showCommands[count].style || !_Global.document.body.contains(showCommands[count])) { // Not real, skip it showCommands.splice(count, 1); count--; } else if (showCommands[count].style.visibility !== "hidden" && showCommands[count].style.opacity !== "0") { // Don't need to animate showing this one, already visible, so now it's a sibling siblings.push(showCommands[count]); showCommands.splice(count, 1); count--; } } for (count = 0; count < hideCommands.length; count++) { // If this one's not real or not attached, skip it if (!hideCommands[count] || !hideCommands[count].style || !_Global.document.body.contains(hideCommands[count]) || hideCommands[count].style.visibility === "hidden" || hideCommands[count].style.opacity === "0") { // Don't need to animate hiding this one, not real, or it's hidden, // so don't even need it as a sibling. hideCommands.splice(count, 1); count--; } } // Start command animations. var commandsAnimationPromise = this._baseBeginAnimateCommands(showCommands, hideCommands, siblings); // Hook end animations var that = this; if (commandsAnimationPromise) { // Needed to animate commandsAnimationPromise.done( function () { that._baseEndAnimateCommands(hideCommands); }, function () { that._baseEndAnimateCommands(hideCommands); } ); } else { // Already positioned correctly Scheduler.schedule(function Overlay_async_baseEndAnimationCommands() { that._baseEndAnimateCommands([]); }, Scheduler.Priority.normal, null, "WinJS.UI._Overlay._endAnimateCommandsWithoutAnimation"); } } // Done, clear queues this._queuedToShow = []; this._queuedToHide = []; }
javascript
function _Overlay_showAndHideQueue() { // Only called if not currently animating. // We'll be done with the queued stuff when we return. this._queuedCommandAnimation = false; // Shortcut if hidden if (this.hidden) { this._showAndHideFast(this._queuedToShow, this._queuedToHide); // Might be something else to do Scheduler.schedule(this._checkDoNext, Scheduler.Priority.normal, this, "WinJS.UI._Overlay._checkDoNext"); } else { // Animation has 3 parts: "hiding", "showing", and "moving" // PVL has "addToList" and "deleteFromList", both of which allow moving parts. // So we'll set up "add" for showing, and use "delete" for "hiding" + moving, // then trigger both at the same time. var showCommands = this._queuedToShow; var hideCommands = this._queuedToHide; var siblings = this._findSiblings(showCommands.concat(hideCommands)); // Filter out the commands queued for animation that don't need to be animated. var count; for (count = 0; count < showCommands.length; count++) { // If this one's not real or not attached, skip it if (!showCommands[count] || !showCommands[count].style || !_Global.document.body.contains(showCommands[count])) { // Not real, skip it showCommands.splice(count, 1); count--; } else if (showCommands[count].style.visibility !== "hidden" && showCommands[count].style.opacity !== "0") { // Don't need to animate showing this one, already visible, so now it's a sibling siblings.push(showCommands[count]); showCommands.splice(count, 1); count--; } } for (count = 0; count < hideCommands.length; count++) { // If this one's not real or not attached, skip it if (!hideCommands[count] || !hideCommands[count].style || !_Global.document.body.contains(hideCommands[count]) || hideCommands[count].style.visibility === "hidden" || hideCommands[count].style.opacity === "0") { // Don't need to animate hiding this one, not real, or it's hidden, // so don't even need it as a sibling. hideCommands.splice(count, 1); count--; } } // Start command animations. var commandsAnimationPromise = this._baseBeginAnimateCommands(showCommands, hideCommands, siblings); // Hook end animations var that = this; if (commandsAnimationPromise) { // Needed to animate commandsAnimationPromise.done( function () { that._baseEndAnimateCommands(hideCommands); }, function () { that._baseEndAnimateCommands(hideCommands); } ); } else { // Already positioned correctly Scheduler.schedule(function Overlay_async_baseEndAnimationCommands() { that._baseEndAnimateCommands([]); }, Scheduler.Priority.normal, null, "WinJS.UI._Overlay._endAnimateCommandsWithoutAnimation"); } } // Done, clear queues this._queuedToShow = []; this._queuedToHide = []; }
[ "function", "_Overlay_showAndHideQueue", "(", ")", "{", "// Only called if not currently animating.", "// We'll be done with the queued stuff when we return.", "this", ".", "_queuedCommandAnimation", "=", "false", ";", "// Shortcut if hidden", "if", "(", "this", ".", "hidden", ")", "{", "this", ".", "_showAndHideFast", "(", "this", ".", "_queuedToShow", ",", "this", ".", "_queuedToHide", ")", ";", "// Might be something else to do", "Scheduler", ".", "schedule", "(", "this", ".", "_checkDoNext", ",", "Scheduler", ".", "Priority", ".", "normal", ",", "this", ",", "\"WinJS.UI._Overlay._checkDoNext\"", ")", ";", "}", "else", "{", "// Animation has 3 parts: \"hiding\", \"showing\", and \"moving\"", "// PVL has \"addToList\" and \"deleteFromList\", both of which allow moving parts.", "// So we'll set up \"add\" for showing, and use \"delete\" for \"hiding\" + moving,", "// then trigger both at the same time.", "var", "showCommands", "=", "this", ".", "_queuedToShow", ";", "var", "hideCommands", "=", "this", ".", "_queuedToHide", ";", "var", "siblings", "=", "this", ".", "_findSiblings", "(", "showCommands", ".", "concat", "(", "hideCommands", ")", ")", ";", "// Filter out the commands queued for animation that don't need to be animated.", "var", "count", ";", "for", "(", "count", "=", "0", ";", "count", "<", "showCommands", ".", "length", ";", "count", "++", ")", "{", "// If this one's not real or not attached, skip it", "if", "(", "!", "showCommands", "[", "count", "]", "||", "!", "showCommands", "[", "count", "]", ".", "style", "||", "!", "_Global", ".", "document", ".", "body", ".", "contains", "(", "showCommands", "[", "count", "]", ")", ")", "{", "// Not real, skip it", "showCommands", ".", "splice", "(", "count", ",", "1", ")", ";", "count", "--", ";", "}", "else", "if", "(", "showCommands", "[", "count", "]", ".", "style", ".", "visibility", "!==", "\"hidden\"", "&&", "showCommands", "[", "count", "]", ".", "style", ".", "opacity", "!==", "\"0\"", ")", "{", "// Don't need to animate showing this one, already visible, so now it's a sibling", "siblings", ".", "push", "(", "showCommands", "[", "count", "]", ")", ";", "showCommands", ".", "splice", "(", "count", ",", "1", ")", ";", "count", "--", ";", "}", "}", "for", "(", "count", "=", "0", ";", "count", "<", "hideCommands", ".", "length", ";", "count", "++", ")", "{", "// If this one's not real or not attached, skip it", "if", "(", "!", "hideCommands", "[", "count", "]", "||", "!", "hideCommands", "[", "count", "]", ".", "style", "||", "!", "_Global", ".", "document", ".", "body", ".", "contains", "(", "hideCommands", "[", "count", "]", ")", "||", "hideCommands", "[", "count", "]", ".", "style", ".", "visibility", "===", "\"hidden\"", "||", "hideCommands", "[", "count", "]", ".", "style", ".", "opacity", "===", "\"0\"", ")", "{", "// Don't need to animate hiding this one, not real, or it's hidden,", "// so don't even need it as a sibling.", "hideCommands", ".", "splice", "(", "count", ",", "1", ")", ";", "count", "--", ";", "}", "}", "// Start command animations.", "var", "commandsAnimationPromise", "=", "this", ".", "_baseBeginAnimateCommands", "(", "showCommands", ",", "hideCommands", ",", "siblings", ")", ";", "// Hook end animations", "var", "that", "=", "this", ";", "if", "(", "commandsAnimationPromise", ")", "{", "// Needed to animate", "commandsAnimationPromise", ".", "done", "(", "function", "(", ")", "{", "that", ".", "_baseEndAnimateCommands", "(", "hideCommands", ")", ";", "}", ",", "function", "(", ")", "{", "that", ".", "_baseEndAnimateCommands", "(", "hideCommands", ")", ";", "}", ")", ";", "}", "else", "{", "// Already positioned correctly", "Scheduler", ".", "schedule", "(", "function", "Overlay_async_baseEndAnimationCommands", "(", ")", "{", "that", ".", "_baseEndAnimateCommands", "(", "[", "]", ")", ";", "}", ",", "Scheduler", ".", "Priority", ".", "normal", ",", "null", ",", "\"WinJS.UI._Overlay._endAnimateCommandsWithoutAnimation\"", ")", ";", "}", "}", "// Done, clear queues", "this", ".", "_queuedToShow", "=", "[", "]", ";", "this", ".", "_queuedToHide", "=", "[", "]", ";", "}" ]
show and hide the queued commands, perhaps animating if overlay isn't hidden.
[ "show", "and", "hide", "the", "queued", "commands", "perhaps", "animating", "if", "overlay", "isn", "t", "hidden", "." ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L39583-L39655
16,431
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
_Overlay_resolveCommands
function _Overlay_resolveCommands(commands) { // First make sure they're all DOM elements. commands = _resolveElements(commands); // Now make sure they're all in this container var result = {}; result.commands = []; result.others = []; var allCommands = this.element.querySelectorAll(".win-command"); var countAll, countIn; for (countAll = 0; countAll < allCommands.length; countAll++) { var found = false; for (countIn = 0; countIn < commands.length; countIn++) { if (commands[countIn] === allCommands[countAll]) { result.commands.push(allCommands[countAll]); commands.splice(countIn, 1); found = true; break; } } if (!found) { result.others.push(allCommands[countAll]); } } return result; }
javascript
function _Overlay_resolveCommands(commands) { // First make sure they're all DOM elements. commands = _resolveElements(commands); // Now make sure they're all in this container var result = {}; result.commands = []; result.others = []; var allCommands = this.element.querySelectorAll(".win-command"); var countAll, countIn; for (countAll = 0; countAll < allCommands.length; countAll++) { var found = false; for (countIn = 0; countIn < commands.length; countIn++) { if (commands[countIn] === allCommands[countAll]) { result.commands.push(allCommands[countAll]); commands.splice(countIn, 1); found = true; break; } } if (!found) { result.others.push(allCommands[countAll]); } } return result; }
[ "function", "_Overlay_resolveCommands", "(", "commands", ")", "{", "// First make sure they're all DOM elements.", "commands", "=", "_resolveElements", "(", "commands", ")", ";", "// Now make sure they're all in this container", "var", "result", "=", "{", "}", ";", "result", ".", "commands", "=", "[", "]", ";", "result", ".", "others", "=", "[", "]", ";", "var", "allCommands", "=", "this", ".", "element", ".", "querySelectorAll", "(", "\".win-command\"", ")", ";", "var", "countAll", ",", "countIn", ";", "for", "(", "countAll", "=", "0", ";", "countAll", "<", "allCommands", ".", "length", ";", "countAll", "++", ")", "{", "var", "found", "=", "false", ";", "for", "(", "countIn", "=", "0", ";", "countIn", "<", "commands", ".", "length", ";", "countIn", "++", ")", "{", "if", "(", "commands", "[", "countIn", "]", "===", "allCommands", "[", "countAll", "]", ")", "{", "result", ".", "commands", ".", "push", "(", "allCommands", "[", "countAll", "]", ")", ";", "commands", ".", "splice", "(", "countIn", ",", "1", ")", ";", "found", "=", "true", ";", "break", ";", "}", "}", "if", "(", "!", "found", ")", "{", "result", ".", "others", ".", "push", "(", "allCommands", "[", "countAll", "]", ")", ";", "}", "}", "return", "result", ";", "}" ]
Resolves our commands
[ "Resolves", "our", "commands" ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L39779-L39804
16,432
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
_Overlay_findSiblings
function _Overlay_findSiblings(commands) { // Now make sure they're all in this container var siblings = []; var allCommands = this.element.querySelectorAll(".win-command"); var countAll, countIn; for (countAll = 0; countAll < allCommands.length; countAll++) { var found = false; for (countIn = 0; countIn < commands.length; countIn++) { if (commands[countIn] === allCommands[countAll]) { commands.splice(countIn, 1); found = true; break; } } if (!found) { siblings.push(allCommands[countAll]); } } return siblings; }
javascript
function _Overlay_findSiblings(commands) { // Now make sure they're all in this container var siblings = []; var allCommands = this.element.querySelectorAll(".win-command"); var countAll, countIn; for (countAll = 0; countAll < allCommands.length; countAll++) { var found = false; for (countIn = 0; countIn < commands.length; countIn++) { if (commands[countIn] === allCommands[countAll]) { commands.splice(countIn, 1); found = true; break; } } if (!found) { siblings.push(allCommands[countAll]); } } return siblings; }
[ "function", "_Overlay_findSiblings", "(", "commands", ")", "{", "// Now make sure they're all in this container", "var", "siblings", "=", "[", "]", ";", "var", "allCommands", "=", "this", ".", "element", ".", "querySelectorAll", "(", "\".win-command\"", ")", ";", "var", "countAll", ",", "countIn", ";", "for", "(", "countAll", "=", "0", ";", "countAll", "<", "allCommands", ".", "length", ";", "countAll", "++", ")", "{", "var", "found", "=", "false", ";", "for", "(", "countIn", "=", "0", ";", "countIn", "<", "commands", ".", "length", ";", "countIn", "++", ")", "{", "if", "(", "commands", "[", "countIn", "]", "===", "allCommands", "[", "countAll", "]", ")", "{", "commands", ".", "splice", "(", "countIn", ",", "1", ")", ";", "found", "=", "true", ";", "break", ";", "}", "}", "if", "(", "!", "found", ")", "{", "siblings", ".", "push", "(", "allCommands", "[", "countAll", "]", ")", ";", "}", "}", "return", "siblings", ";", "}" ]
Find siblings, all DOM elements now. Returns all .win-commands in this Overlay that are NOT in the passed in 'commands' array.
[ "Find", "siblings", "all", "DOM", "elements", "now", ".", "Returns", "all", ".", "win", "-", "commands", "in", "this", "Overlay", "that", "are", "NOT", "in", "the", "passed", "in", "commands", "array", "." ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L39808-L39827
16,433
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
_Overlay_focusOnLastFocusableElement
function _Overlay_focusOnLastFocusableElement() { if (this._element.firstElementChild) { var oldFirstTabIndex = this._element.firstElementChild.tabIndex; var oldLastTabIndex = this._element.lastElementChild.tabIndex; this._element.firstElementChild.tabIndex = -1; this._element.lastElementChild.tabIndex = -1; var tabResult = _ElementUtilities._focusLastFocusableElement(this._element); if (tabResult) { _Overlay._trySelect(_Global.document.activeElement); } this._element.firstElementChild.tabIndex = oldFirstTabIndex; this._element.lastElementChild.tabIndex = oldLastTabIndex; return tabResult; } else { return false; } }
javascript
function _Overlay_focusOnLastFocusableElement() { if (this._element.firstElementChild) { var oldFirstTabIndex = this._element.firstElementChild.tabIndex; var oldLastTabIndex = this._element.lastElementChild.tabIndex; this._element.firstElementChild.tabIndex = -1; this._element.lastElementChild.tabIndex = -1; var tabResult = _ElementUtilities._focusLastFocusableElement(this._element); if (tabResult) { _Overlay._trySelect(_Global.document.activeElement); } this._element.firstElementChild.tabIndex = oldFirstTabIndex; this._element.lastElementChild.tabIndex = oldLastTabIndex; return tabResult; } else { return false; } }
[ "function", "_Overlay_focusOnLastFocusableElement", "(", ")", "{", "if", "(", "this", ".", "_element", ".", "firstElementChild", ")", "{", "var", "oldFirstTabIndex", "=", "this", ".", "_element", ".", "firstElementChild", ".", "tabIndex", ";", "var", "oldLastTabIndex", "=", "this", ".", "_element", ".", "lastElementChild", ".", "tabIndex", ";", "this", ".", "_element", ".", "firstElementChild", ".", "tabIndex", "=", "-", "1", ";", "this", ".", "_element", ".", "lastElementChild", ".", "tabIndex", "=", "-", "1", ";", "var", "tabResult", "=", "_ElementUtilities", ".", "_focusLastFocusableElement", "(", "this", ".", "_element", ")", ";", "if", "(", "tabResult", ")", "{", "_Overlay", ".", "_trySelect", "(", "_Global", ".", "document", ".", "activeElement", ")", ";", "}", "this", ".", "_element", ".", "firstElementChild", ".", "tabIndex", "=", "oldFirstTabIndex", ";", "this", ".", "_element", ".", "lastElementChild", ".", "tabIndex", "=", "oldLastTabIndex", ";", "return", "tabResult", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Sets focus to what we think is the last tab stop. This element must have a firstDiv with tabIndex equal to the lowest tabIndex in the element and a finalDiv with tabIndex equal to the highest tabIndex in the element. Also the firstDiv must be its first child and finalDiv be its last child. Returns true if successful, false otherwise.
[ "Sets", "focus", "to", "what", "we", "think", "is", "the", "last", "tab", "stop", ".", "This", "element", "must", "have", "a", "firstDiv", "with", "tabIndex", "equal", "to", "the", "lowest", "tabIndex", "in", "the", "element", "and", "a", "finalDiv", "with", "tabIndex", "equal", "to", "the", "highest", "tabIndex", "in", "the", "element", ".", "Also", "the", "firstDiv", "must", "be", "its", "first", "child", "and", "finalDiv", "be", "its", "last", "child", ".", "Returns", "true", "if", "successful", "false", "otherwise", "." ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L39898-L39918
16,434
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
_Overlay__focusOnFirstFocusableElement
function _Overlay__focusOnFirstFocusableElement(useSetActive, scroller) { if (this._element.firstElementChild) { var oldFirstTabIndex = this._element.firstElementChild.tabIndex; var oldLastTabIndex = this._element.lastElementChild.tabIndex; this._element.firstElementChild.tabIndex = -1; this._element.lastElementChild.tabIndex = -1; var tabResult = _ElementUtilities._focusFirstFocusableElement(this._element, useSetActive, scroller); if (tabResult) { _Overlay._trySelect(_Global.document.activeElement); } this._element.firstElementChild.tabIndex = oldFirstTabIndex; this._element.lastElementChild.tabIndex = oldLastTabIndex; return tabResult; } else { return false; } }
javascript
function _Overlay__focusOnFirstFocusableElement(useSetActive, scroller) { if (this._element.firstElementChild) { var oldFirstTabIndex = this._element.firstElementChild.tabIndex; var oldLastTabIndex = this._element.lastElementChild.tabIndex; this._element.firstElementChild.tabIndex = -1; this._element.lastElementChild.tabIndex = -1; var tabResult = _ElementUtilities._focusFirstFocusableElement(this._element, useSetActive, scroller); if (tabResult) { _Overlay._trySelect(_Global.document.activeElement); } this._element.firstElementChild.tabIndex = oldFirstTabIndex; this._element.lastElementChild.tabIndex = oldLastTabIndex; return tabResult; } else { return false; } }
[ "function", "_Overlay__focusOnFirstFocusableElement", "(", "useSetActive", ",", "scroller", ")", "{", "if", "(", "this", ".", "_element", ".", "firstElementChild", ")", "{", "var", "oldFirstTabIndex", "=", "this", ".", "_element", ".", "firstElementChild", ".", "tabIndex", ";", "var", "oldLastTabIndex", "=", "this", ".", "_element", ".", "lastElementChild", ".", "tabIndex", ";", "this", ".", "_element", ".", "firstElementChild", ".", "tabIndex", "=", "-", "1", ";", "this", ".", "_element", ".", "lastElementChild", ".", "tabIndex", "=", "-", "1", ";", "var", "tabResult", "=", "_ElementUtilities", ".", "_focusFirstFocusableElement", "(", "this", ".", "_element", ",", "useSetActive", ",", "scroller", ")", ";", "if", "(", "tabResult", ")", "{", "_Overlay", ".", "_trySelect", "(", "_Global", ".", "document", ".", "activeElement", ")", ";", "}", "this", ".", "_element", ".", "firstElementChild", ".", "tabIndex", "=", "oldFirstTabIndex", ";", "this", ".", "_element", ".", "lastElementChild", ".", "tabIndex", "=", "oldLastTabIndex", ";", "return", "tabResult", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Sets focus to what we think is the first tab stop. This element must have a firstDiv with tabIndex equal to the lowest tabIndex in the element and a finalDiv with tabIndex equal to the highest tabIndex in the element. Also the firstDiv must be its first child and finalDiv be its last child. Returns true if successful, false otherwise.
[ "Sets", "focus", "to", "what", "we", "think", "is", "the", "first", "tab", "stop", ".", "This", "element", "must", "have", "a", "firstDiv", "with", "tabIndex", "equal", "to", "the", "lowest", "tabIndex", "in", "the", "element", "and", "a", "finalDiv", "with", "tabIndex", "equal", "to", "the", "highest", "tabIndex", "in", "the", "element", ".", "Also", "the", "firstDiv", "must", "be", "its", "first", "child", "and", "finalDiv", "be", "its", "last", "child", ".", "Returns", "true", "if", "successful", "false", "otherwise", "." ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L39935-L39955
16,435
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
function (element, scroller) { if (!element || !_Global.document.body || !_Global.document.body.contains(element)) { return false; } if (!_ElementUtilities._setActive(element, scroller)) { return false; } return (element === _Global.document.activeElement); }
javascript
function (element, scroller) { if (!element || !_Global.document.body || !_Global.document.body.contains(element)) { return false; } if (!_ElementUtilities._setActive(element, scroller)) { return false; } return (element === _Global.document.activeElement); }
[ "function", "(", "element", ",", "scroller", ")", "{", "if", "(", "!", "element", "||", "!", "_Global", ".", "document", ".", "body", "||", "!", "_Global", ".", "document", ".", "body", ".", "contains", "(", "element", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "_ElementUtilities", ".", "_setActive", "(", "element", ",", "scroller", ")", ")", "{", "return", "false", ";", "}", "return", "(", "element", "===", "_Global", ".", "document", ".", "activeElement", ")", ";", "}" ]
Try to set us as active
[ "Try", "to", "set", "us", "as", "active" ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L39977-L39985
16,436
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
_LightDismissableLayer_hiding
function _LightDismissableLayer_hiding(client /*: ILightDismissable */) { var index = this._clients.indexOf(client); if (index !== -1) { this._clients[index]._focusable = false; this._activateTopFocusableClientIfNeeded(); } }
javascript
function _LightDismissableLayer_hiding(client /*: ILightDismissable */) { var index = this._clients.indexOf(client); if (index !== -1) { this._clients[index]._focusable = false; this._activateTopFocusableClientIfNeeded(); } }
[ "function", "_LightDismissableLayer_hiding", "(", "client", "/*: ILightDismissable */", ")", "{", "var", "index", "=", "this", ".", "_clients", ".", "indexOf", "(", "client", ")", ";", "if", "(", "index", "!==", "-", "1", ")", "{", "this", ".", "_clients", "[", "index", "]", ".", "_focusable", "=", "false", ";", "this", ".", "_activateTopFocusableClientIfNeeded", "(", ")", ";", "}", "}" ]
Dismissables should call this at the start of their exit animation. A "hiding", dismissable will still be rendered with the proper z-index but it will no longer be given focus. Also, focus is synchronously moved out of this dismissable.
[ "Dismissables", "should", "call", "this", "at", "the", "start", "of", "their", "exit", "animation", ".", "A", "hiding", "dismissable", "will", "still", "be", "rendered", "with", "the", "proper", "z", "-", "index", "but", "it", "will", "no", "longer", "be", "given", "focus", ".", "Also", "focus", "is", "synchronously", "moved", "out", "of", "this", "dismissable", "." ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L40237-L40243
16,437
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
fitsVerticallyWithCenteredAnchor
function fitsVerticallyWithCenteredAnchor(anchorBorderBox, flyoutMeasurements) { // Returns true if the flyout would always fit at least top // or bottom of its anchor, regardless of the position of the anchor, // as long as the anchor never changed its height, nor did the height of // the visualViewport change. return ((_Overlay._Overlay._keyboardInfo._visibleDocHeight - anchorBorderBox.height) / 2) >= flyoutMeasurements.totalHeight; }
javascript
function fitsVerticallyWithCenteredAnchor(anchorBorderBox, flyoutMeasurements) { // Returns true if the flyout would always fit at least top // or bottom of its anchor, regardless of the position of the anchor, // as long as the anchor never changed its height, nor did the height of // the visualViewport change. return ((_Overlay._Overlay._keyboardInfo._visibleDocHeight - anchorBorderBox.height) / 2) >= flyoutMeasurements.totalHeight; }
[ "function", "fitsVerticallyWithCenteredAnchor", "(", "anchorBorderBox", ",", "flyoutMeasurements", ")", "{", "// Returns true if the flyout would always fit at least top", "// or bottom of its anchor, regardless of the position of the anchor,", "// as long as the anchor never changed its height, nor did the height of", "// the visualViewport change.", "return", "(", "(", "_Overlay", ".", "_Overlay", ".", "_keyboardInfo", ".", "_visibleDocHeight", "-", "anchorBorderBox", ".", "height", ")", "/", "2", ")", ">=", "flyoutMeasurements", ".", "totalHeight", ";", "}" ]
If the anchor is centered vertically, would the flyout fit above it?
[ "If", "the", "anchor", "is", "centered", "vertically", "would", "the", "flyout", "fit", "above", "it?" ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L40615-L40621
16,438
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
fitTop
function fitTop(bottomConstraint, flyoutMeasurements) { nextTop = bottomConstraint - flyoutMeasurements.totalHeight; nextAnimOffset = AnimationOffsets.top; return (nextTop >= _Overlay._Overlay._keyboardInfo._visibleDocTop && nextTop + flyoutMeasurements.totalHeight <= _Overlay._Overlay._keyboardInfo._visibleDocBottom); }
javascript
function fitTop(bottomConstraint, flyoutMeasurements) { nextTop = bottomConstraint - flyoutMeasurements.totalHeight; nextAnimOffset = AnimationOffsets.top; return (nextTop >= _Overlay._Overlay._keyboardInfo._visibleDocTop && nextTop + flyoutMeasurements.totalHeight <= _Overlay._Overlay._keyboardInfo._visibleDocBottom); }
[ "function", "fitTop", "(", "bottomConstraint", ",", "flyoutMeasurements", ")", "{", "nextTop", "=", "bottomConstraint", "-", "flyoutMeasurements", ".", "totalHeight", ";", "nextAnimOffset", "=", "AnimationOffsets", ".", "top", ";", "return", "(", "nextTop", ">=", "_Overlay", ".", "_Overlay", ".", "_keyboardInfo", ".", "_visibleDocTop", "&&", "nextTop", "+", "flyoutMeasurements", ".", "totalHeight", "<=", "_Overlay", ".", "_Overlay", ".", "_keyboardInfo", ".", "_visibleDocBottom", ")", ";", "}" ]
See if we can fit in various places, fitting in the main view, ignoring viewport changes, like for the IHM.
[ "See", "if", "we", "can", "fit", "in", "various", "places", "fitting", "in", "the", "main", "view", "ignoring", "viewport", "changes", "like", "for", "the", "IHM", "." ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L40637-L40642
16,439
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
Flyout_ensurePosition
function Flyout_ensurePosition() { this._keyboardMovedUs = false; // Remove old height restrictions and scrolling. this._clearAdjustedStyles(); this._setAlignment(); // Set up the new position, and prep the offset for showPopup. var flyoutMeasurements = measureElement(this._element); var isRtl = _ElementUtilities._getComputedStyle(this._element).direction === "rtl"; this._currentPosition = this._positionRequest.getTopLeft(flyoutMeasurements, isRtl); // Adjust position if (this._currentPosition.top < 0) { // Overran bottom, attach to bottom. this._element.style.bottom = _Overlay._Overlay._keyboardInfo._visibleDocBottomOffset + "px"; this._element.style.top = "auto"; } else { // Normal, set top this._element.style.top = this._currentPosition.top + "px"; this._element.style.bottom = "auto"; } if (this._currentPosition.left < 0) { // Overran right, attach to right this._element.style.right = "0px"; this._element.style.left = "auto"; } else { // Normal, set left this._element.style.left = this._currentPosition.left + "px"; this._element.style.right = "auto"; } // Adjust height/scrollbar if (this._currentPosition.doesScroll) { _ElementUtilities.addClass(this._element, _Constants.scrollsClass); this._lastMaxHeight = this._element.style.maxHeight; this._element.style.maxHeight = this._currentPosition.contentHeight + "px"; } // May need to adjust if the IHM is showing. if (_Overlay._Overlay._keyboardInfo._visible) { // Use keyboard logic this._checkKeyboardFit(); if (this._keyboardMovedUs) { this._adjustForKeyboard(); } } }
javascript
function Flyout_ensurePosition() { this._keyboardMovedUs = false; // Remove old height restrictions and scrolling. this._clearAdjustedStyles(); this._setAlignment(); // Set up the new position, and prep the offset for showPopup. var flyoutMeasurements = measureElement(this._element); var isRtl = _ElementUtilities._getComputedStyle(this._element).direction === "rtl"; this._currentPosition = this._positionRequest.getTopLeft(flyoutMeasurements, isRtl); // Adjust position if (this._currentPosition.top < 0) { // Overran bottom, attach to bottom. this._element.style.bottom = _Overlay._Overlay._keyboardInfo._visibleDocBottomOffset + "px"; this._element.style.top = "auto"; } else { // Normal, set top this._element.style.top = this._currentPosition.top + "px"; this._element.style.bottom = "auto"; } if (this._currentPosition.left < 0) { // Overran right, attach to right this._element.style.right = "0px"; this._element.style.left = "auto"; } else { // Normal, set left this._element.style.left = this._currentPosition.left + "px"; this._element.style.right = "auto"; } // Adjust height/scrollbar if (this._currentPosition.doesScroll) { _ElementUtilities.addClass(this._element, _Constants.scrollsClass); this._lastMaxHeight = this._element.style.maxHeight; this._element.style.maxHeight = this._currentPosition.contentHeight + "px"; } // May need to adjust if the IHM is showing. if (_Overlay._Overlay._keyboardInfo._visible) { // Use keyboard logic this._checkKeyboardFit(); if (this._keyboardMovedUs) { this._adjustForKeyboard(); } } }
[ "function", "Flyout_ensurePosition", "(", ")", "{", "this", ".", "_keyboardMovedUs", "=", "false", ";", "// Remove old height restrictions and scrolling.", "this", ".", "_clearAdjustedStyles", "(", ")", ";", "this", ".", "_setAlignment", "(", ")", ";", "// Set up the new position, and prep the offset for showPopup.", "var", "flyoutMeasurements", "=", "measureElement", "(", "this", ".", "_element", ")", ";", "var", "isRtl", "=", "_ElementUtilities", ".", "_getComputedStyle", "(", "this", ".", "_element", ")", ".", "direction", "===", "\"rtl\"", ";", "this", ".", "_currentPosition", "=", "this", ".", "_positionRequest", ".", "getTopLeft", "(", "flyoutMeasurements", ",", "isRtl", ")", ";", "// Adjust position", "if", "(", "this", ".", "_currentPosition", ".", "top", "<", "0", ")", "{", "// Overran bottom, attach to bottom.", "this", ".", "_element", ".", "style", ".", "bottom", "=", "_Overlay", ".", "_Overlay", ".", "_keyboardInfo", ".", "_visibleDocBottomOffset", "+", "\"px\"", ";", "this", ".", "_element", ".", "style", ".", "top", "=", "\"auto\"", ";", "}", "else", "{", "// Normal, set top", "this", ".", "_element", ".", "style", ".", "top", "=", "this", ".", "_currentPosition", ".", "top", "+", "\"px\"", ";", "this", ".", "_element", ".", "style", ".", "bottom", "=", "\"auto\"", ";", "}", "if", "(", "this", ".", "_currentPosition", ".", "left", "<", "0", ")", "{", "// Overran right, attach to right", "this", ".", "_element", ".", "style", ".", "right", "=", "\"0px\"", ";", "this", ".", "_element", ".", "style", ".", "left", "=", "\"auto\"", ";", "}", "else", "{", "// Normal, set left", "this", ".", "_element", ".", "style", ".", "left", "=", "this", ".", "_currentPosition", ".", "left", "+", "\"px\"", ";", "this", ".", "_element", ".", "style", ".", "right", "=", "\"auto\"", ";", "}", "// Adjust height/scrollbar", "if", "(", "this", ".", "_currentPosition", ".", "doesScroll", ")", "{", "_ElementUtilities", ".", "addClass", "(", "this", ".", "_element", ",", "_Constants", ".", "scrollsClass", ")", ";", "this", ".", "_lastMaxHeight", "=", "this", ".", "_element", ".", "style", ".", "maxHeight", ";", "this", ".", "_element", ".", "style", ".", "maxHeight", "=", "this", ".", "_currentPosition", ".", "contentHeight", "+", "\"px\"", ";", "}", "// May need to adjust if the IHM is showing.", "if", "(", "_Overlay", ".", "_Overlay", ".", "_keyboardInfo", ".", "_visible", ")", "{", "// Use keyboard logic", "this", ".", "_checkKeyboardFit", "(", ")", ";", "if", "(", "this", ".", "_keyboardMovedUs", ")", "{", "this", ".", "_adjustForKeyboard", "(", ")", ";", "}", "}", "}" ]
Find our new flyout position.
[ "Find", "our", "new", "flyout", "position", "." ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L41232-L41281
16,440
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
Flyout_checkKeyboardFit
function Flyout_checkKeyboardFit() { // Special Flyout positioning rules to determine if the Flyout needs to adjust its // position because of the IHM. If the Flyout needs to adjust for the IHM, it will reposition // itself to be pinned to either the top or bottom edge of the visual viewport. // - Too Tall, above top, or below bottom. var keyboardMovedUs = false; var viewportHeight = _Overlay._Overlay._keyboardInfo._visibleDocHeight; var adjustedMarginBoxHeight = this._currentPosition.contentHeight + this._currentPosition.verticalMarginBorderPadding; if (adjustedMarginBoxHeight > viewportHeight) { // The Flyout is now too tall to fit in the viewport, pin to top and adjust height. keyboardMovedUs = true; this._currentPosition.top = _Constants.pinToBottomEdge; this._currentPosition.contentHeight = viewportHeight - this._currentPosition.verticalMarginBorderPadding; this._currentPosition.doesScroll = true; } else if (this._currentPosition.top >= 0 && this._currentPosition.top + adjustedMarginBoxHeight > _Overlay._Overlay._keyboardInfo._visibleDocBottom) { // Flyout clips the bottom of the viewport. Pin to bottom. this._currentPosition.top = _Constants.pinToBottomEdge; keyboardMovedUs = true; } else if (this._currentPosition.top === _Constants.pinToBottomEdge) { // We were already pinned to the bottom, so our position on screen will change keyboardMovedUs = true; } // Signals use of basic fadein animation this._keyboardMovedUs = keyboardMovedUs; }
javascript
function Flyout_checkKeyboardFit() { // Special Flyout positioning rules to determine if the Flyout needs to adjust its // position because of the IHM. If the Flyout needs to adjust for the IHM, it will reposition // itself to be pinned to either the top or bottom edge of the visual viewport. // - Too Tall, above top, or below bottom. var keyboardMovedUs = false; var viewportHeight = _Overlay._Overlay._keyboardInfo._visibleDocHeight; var adjustedMarginBoxHeight = this._currentPosition.contentHeight + this._currentPosition.verticalMarginBorderPadding; if (adjustedMarginBoxHeight > viewportHeight) { // The Flyout is now too tall to fit in the viewport, pin to top and adjust height. keyboardMovedUs = true; this._currentPosition.top = _Constants.pinToBottomEdge; this._currentPosition.contentHeight = viewportHeight - this._currentPosition.verticalMarginBorderPadding; this._currentPosition.doesScroll = true; } else if (this._currentPosition.top >= 0 && this._currentPosition.top + adjustedMarginBoxHeight > _Overlay._Overlay._keyboardInfo._visibleDocBottom) { // Flyout clips the bottom of the viewport. Pin to bottom. this._currentPosition.top = _Constants.pinToBottomEdge; keyboardMovedUs = true; } else if (this._currentPosition.top === _Constants.pinToBottomEdge) { // We were already pinned to the bottom, so our position on screen will change keyboardMovedUs = true; } // Signals use of basic fadein animation this._keyboardMovedUs = keyboardMovedUs; }
[ "function", "Flyout_checkKeyboardFit", "(", ")", "{", "// Special Flyout positioning rules to determine if the Flyout needs to adjust its", "// position because of the IHM. If the Flyout needs to adjust for the IHM, it will reposition", "// itself to be pinned to either the top or bottom edge of the visual viewport.", "// - Too Tall, above top, or below bottom.", "var", "keyboardMovedUs", "=", "false", ";", "var", "viewportHeight", "=", "_Overlay", ".", "_Overlay", ".", "_keyboardInfo", ".", "_visibleDocHeight", ";", "var", "adjustedMarginBoxHeight", "=", "this", ".", "_currentPosition", ".", "contentHeight", "+", "this", ".", "_currentPosition", ".", "verticalMarginBorderPadding", ";", "if", "(", "adjustedMarginBoxHeight", ">", "viewportHeight", ")", "{", "// The Flyout is now too tall to fit in the viewport, pin to top and adjust height.", "keyboardMovedUs", "=", "true", ";", "this", ".", "_currentPosition", ".", "top", "=", "_Constants", ".", "pinToBottomEdge", ";", "this", ".", "_currentPosition", ".", "contentHeight", "=", "viewportHeight", "-", "this", ".", "_currentPosition", ".", "verticalMarginBorderPadding", ";", "this", ".", "_currentPosition", ".", "doesScroll", "=", "true", ";", "}", "else", "if", "(", "this", ".", "_currentPosition", ".", "top", ">=", "0", "&&", "this", ".", "_currentPosition", ".", "top", "+", "adjustedMarginBoxHeight", ">", "_Overlay", ".", "_Overlay", ".", "_keyboardInfo", ".", "_visibleDocBottom", ")", "{", "// Flyout clips the bottom of the viewport. Pin to bottom.", "this", ".", "_currentPosition", ".", "top", "=", "_Constants", ".", "pinToBottomEdge", ";", "keyboardMovedUs", "=", "true", ";", "}", "else", "if", "(", "this", ".", "_currentPosition", ".", "top", "===", "_Constants", ".", "pinToBottomEdge", ")", "{", "// We were already pinned to the bottom, so our position on screen will change", "keyboardMovedUs", "=", "true", ";", "}", "// Signals use of basic fadein animation", "this", ".", "_keyboardMovedUs", "=", "keyboardMovedUs", ";", "}" ]
If you were not pinned to the bottom, you might have to be now.
[ "If", "you", "were", "not", "pinned", "to", "the", "bottom", "you", "might", "have", "to", "be", "now", "." ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L41359-L41386
16,441
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
Flyout_flyoutAnimateIn
function Flyout_flyoutAnimateIn() { if (this._keyboardMovedUs) { return this._baseAnimateIn(); } else { this._element.style.opacity = 1; this._element.style.visibility = "visible"; return Animations.showPopup(this._element, (typeof this._currentPosition !== 'undefined') ? this._currentPosition.animOffset : 0); } }
javascript
function Flyout_flyoutAnimateIn() { if (this._keyboardMovedUs) { return this._baseAnimateIn(); } else { this._element.style.opacity = 1; this._element.style.visibility = "visible"; return Animations.showPopup(this._element, (typeof this._currentPosition !== 'undefined') ? this._currentPosition.animOffset : 0); } }
[ "function", "Flyout_flyoutAnimateIn", "(", ")", "{", "if", "(", "this", ".", "_keyboardMovedUs", ")", "{", "return", "this", ".", "_baseAnimateIn", "(", ")", ";", "}", "else", "{", "this", ".", "_element", ".", "style", ".", "opacity", "=", "1", ";", "this", ".", "_element", ".", "style", ".", "visibility", "=", "\"visible\"", ";", "return", "Animations", ".", "showPopup", "(", "this", ".", "_element", ",", "(", "typeof", "this", ".", "_currentPosition", "!==", "'undefined'", ")", "?", "this", ".", "_currentPosition", ".", "animOffset", ":", "0", ")", ";", "}", "}" ]
AppBar flyout animations
[ "AppBar", "flyout", "animations" ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L41446-L41454
16,442
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
Flyout_hideAllOtherFlyouts
function Flyout_hideAllOtherFlyouts(thisFlyout) { var flyouts = _Global.document.querySelectorAll("." + _Constants.flyoutClass); for (var i = 0; i < flyouts.length; i++) { var flyoutControl = flyouts[i].winControl; if (flyoutControl && !flyoutControl.hidden && (flyoutControl !== thisFlyout)) { flyoutControl.hide(); } } }
javascript
function Flyout_hideAllOtherFlyouts(thisFlyout) { var flyouts = _Global.document.querySelectorAll("." + _Constants.flyoutClass); for (var i = 0; i < flyouts.length; i++) { var flyoutControl = flyouts[i].winControl; if (flyoutControl && !flyoutControl.hidden && (flyoutControl !== thisFlyout)) { flyoutControl.hide(); } } }
[ "function", "Flyout_hideAllOtherFlyouts", "(", "thisFlyout", ")", "{", "var", "flyouts", "=", "_Global", ".", "document", ".", "querySelectorAll", "(", "\".\"", "+", "_Constants", ".", "flyoutClass", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "flyouts", ".", "length", ";", "i", "++", ")", "{", "var", "flyoutControl", "=", "flyouts", "[", "i", "]", ".", "winControl", ";", "if", "(", "flyoutControl", "&&", "!", "flyoutControl", ".", "hidden", "&&", "(", "flyoutControl", "!==", "thisFlyout", ")", ")", "{", "flyoutControl", ".", "hide", "(", ")", ";", "}", "}", "}" ]
Hide all other flyouts besides this one
[ "Hide", "all", "other", "flyouts", "besides", "this", "one" ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L41466-L41474
16,443
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
Flyout_addFirstDiv
function Flyout_addFirstDiv() { var firstDiv = _Global.document.createElement("div"); firstDiv.className = _Constants.firstDivClass; firstDiv.style.display = "inline"; firstDiv.setAttribute("role", "menuitem"); firstDiv.setAttribute("aria-hidden", "true"); // add to beginning if (this._element.children[0]) { this._element.insertBefore(firstDiv, this._element.children[0]); } else { this._element.appendChild(firstDiv); } var that = this; _ElementUtilities._addEventListener(firstDiv, "focusin", function () { that._focusOnLastFocusableElementOrThis(); }, false); return firstDiv; }
javascript
function Flyout_addFirstDiv() { var firstDiv = _Global.document.createElement("div"); firstDiv.className = _Constants.firstDivClass; firstDiv.style.display = "inline"; firstDiv.setAttribute("role", "menuitem"); firstDiv.setAttribute("aria-hidden", "true"); // add to beginning if (this._element.children[0]) { this._element.insertBefore(firstDiv, this._element.children[0]); } else { this._element.appendChild(firstDiv); } var that = this; _ElementUtilities._addEventListener(firstDiv, "focusin", function () { that._focusOnLastFocusableElementOrThis(); }, false); return firstDiv; }
[ "function", "Flyout_addFirstDiv", "(", ")", "{", "var", "firstDiv", "=", "_Global", ".", "document", ".", "createElement", "(", "\"div\"", ")", ";", "firstDiv", ".", "className", "=", "_Constants", ".", "firstDivClass", ";", "firstDiv", ".", "style", ".", "display", "=", "\"inline\"", ";", "firstDiv", ".", "setAttribute", "(", "\"role\"", ",", "\"menuitem\"", ")", ";", "firstDiv", ".", "setAttribute", "(", "\"aria-hidden\"", ",", "\"true\"", ")", ";", "// add to beginning", "if", "(", "this", ".", "_element", ".", "children", "[", "0", "]", ")", "{", "this", ".", "_element", ".", "insertBefore", "(", "firstDiv", ",", "this", ".", "_element", ".", "children", "[", "0", "]", ")", ";", "}", "else", "{", "this", ".", "_element", ".", "appendChild", "(", "firstDiv", ")", ";", "}", "var", "that", "=", "this", ";", "_ElementUtilities", ".", "_addEventListener", "(", "firstDiv", ",", "\"focusin\"", ",", "function", "(", ")", "{", "that", ".", "_focusOnLastFocusableElementOrThis", "(", ")", ";", "}", ",", "false", ")", ";", "return", "firstDiv", ";", "}" ]
Create and add a new first div as the first child
[ "Create", "and", "add", "a", "new", "first", "div", "as", "the", "first", "child" ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L41500-L41518
16,444
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
Flyout_addFinalDiv
function Flyout_addFinalDiv() { var finalDiv = _Global.document.createElement("div"); finalDiv.className = _Constants.finalDivClass; finalDiv.style.display = "inline"; finalDiv.setAttribute("role", "menuitem"); finalDiv.setAttribute("aria-hidden", "true"); this._element.appendChild(finalDiv); var that = this; _ElementUtilities._addEventListener(finalDiv, "focusin", function () { that._focusOnFirstFocusableElementOrThis(); }, false); return finalDiv; }
javascript
function Flyout_addFinalDiv() { var finalDiv = _Global.document.createElement("div"); finalDiv.className = _Constants.finalDivClass; finalDiv.style.display = "inline"; finalDiv.setAttribute("role", "menuitem"); finalDiv.setAttribute("aria-hidden", "true"); this._element.appendChild(finalDiv); var that = this; _ElementUtilities._addEventListener(finalDiv, "focusin", function () { that._focusOnFirstFocusableElementOrThis(); }, false); return finalDiv; }
[ "function", "Flyout_addFinalDiv", "(", ")", "{", "var", "finalDiv", "=", "_Global", ".", "document", ".", "createElement", "(", "\"div\"", ")", ";", "finalDiv", ".", "className", "=", "_Constants", ".", "finalDivClass", ";", "finalDiv", ".", "style", ".", "display", "=", "\"inline\"", ";", "finalDiv", ".", "setAttribute", "(", "\"role\"", ",", "\"menuitem\"", ")", ";", "finalDiv", ".", "setAttribute", "(", "\"aria-hidden\"", ",", "\"true\"", ")", ";", "this", ".", "_element", ".", "appendChild", "(", "finalDiv", ")", ";", "var", "that", "=", "this", ";", "_ElementUtilities", ".", "_addEventListener", "(", "finalDiv", ",", "\"focusin\"", ",", "function", "(", ")", "{", "that", ".", "_focusOnFirstFocusableElementOrThis", "(", ")", ";", "}", ",", "false", ")", ";", "return", "finalDiv", ";", "}" ]
Create and add a new final div as the last child
[ "Create", "and", "add", "a", "new", "final", "div", "as", "the", "last", "child" ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L41521-L41533
16,445
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
_LegacyAppBar_setFocusToAppBar
function _LegacyAppBar_setFocusToAppBar(useSetActive, scroller) { if (!this._focusOnFirstFocusableElement(useSetActive, scroller)) { // No first element, set it to appbar itself _Overlay._Overlay._trySetActive(this._element, scroller); } }
javascript
function _LegacyAppBar_setFocusToAppBar(useSetActive, scroller) { if (!this._focusOnFirstFocusableElement(useSetActive, scroller)) { // No first element, set it to appbar itself _Overlay._Overlay._trySetActive(this._element, scroller); } }
[ "function", "_LegacyAppBar_setFocusToAppBar", "(", "useSetActive", ",", "scroller", ")", "{", "if", "(", "!", "this", ".", "_focusOnFirstFocusableElement", "(", "useSetActive", ",", "scroller", ")", ")", "{", "// No first element, set it to appbar itself", "_Overlay", ".", "_Overlay", ".", "_trySetActive", "(", "this", ".", "_element", ",", "scroller", ")", ";", "}", "}" ]
Set focus to the passed in _LegacyAppBar
[ "Set", "focus", "to", "the", "passed", "in", "_LegacyAppBar" ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L47287-L47292
16,446
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
_LegacyAppBar_updateFirstAndFinalDiv
function _LegacyAppBar_updateFirstAndFinalDiv() { var appBarFirstDiv = this._element.querySelectorAll("." + _Constants.firstDivClass); appBarFirstDiv = appBarFirstDiv.length >= 1 ? appBarFirstDiv[0] : null; var appBarFinalDiv = this._element.querySelectorAll("." + _Constants.finalDivClass); appBarFinalDiv = appBarFinalDiv.length >= 1 ? appBarFinalDiv[0] : null; // Remove the firstDiv & finalDiv if they are not at the appropriate locations if (appBarFirstDiv && (this._element.children[0] !== appBarFirstDiv)) { appBarFirstDiv.parentNode.removeChild(appBarFirstDiv); appBarFirstDiv = null; } if (appBarFinalDiv && (this._element.children[this._element.children.length - 1] !== appBarFinalDiv)) { appBarFinalDiv.parentNode.removeChild(appBarFinalDiv); appBarFinalDiv = null; } // Create and add the firstDiv & finalDiv if they don't already exist if (!appBarFirstDiv) { // Add a firstDiv that will be the first child of the appBar. // On focus set focus to the last element of the AppBar. appBarFirstDiv = _Global.document.createElement("div"); // display: inline is needed so that the div doesn't take up space and cause the page to scroll on focus appBarFirstDiv.style.display = "inline"; appBarFirstDiv.className = _Constants.firstDivClass; appBarFirstDiv.tabIndex = -1; appBarFirstDiv.setAttribute("aria-hidden", "true"); _ElementUtilities._addEventListener(appBarFirstDiv, "focusin", this._focusOnLastFocusableElementOrThis.bind(this), false); // add to beginning if (this._element.children[0]) { this._element.insertBefore(appBarFirstDiv, this._element.children[0]); } else { this._element.appendChild(appBarFirstDiv); } } if (!appBarFinalDiv) { // Add a finalDiv that will be the last child of the appBar. // On focus set focus to the first element of the AppBar. appBarFinalDiv = _Global.document.createElement("div"); // display: inline is needed so that the div doesn't take up space and cause the page to scroll on focus appBarFinalDiv.style.display = "inline"; appBarFinalDiv.className = _Constants.finalDivClass; appBarFinalDiv.tabIndex = -1; appBarFinalDiv.setAttribute("aria-hidden", "true"); _ElementUtilities._addEventListener(appBarFinalDiv, "focusin", this._focusOnFirstFocusableElementOrThis.bind(this), false); this._element.appendChild(appBarFinalDiv); } // invokeButton should be the second to last element in the _LegacyAppBar's tab order. Second to the finalDiv. if (this._element.children[this._element.children.length - 2] !== this._invokeButton) { this._element.insertBefore(this._invokeButton, appBarFinalDiv); } var elms = this._element.getElementsByTagName("*"); var highestTabIndex = _ElementUtilities._getHighestTabIndexInList(elms); this._invokeButton.tabIndex = highestTabIndex; // Update the tabIndex of the firstDiv & finalDiv if (appBarFirstDiv) { appBarFirstDiv.tabIndex = _ElementUtilities._getLowestTabIndexInList(elms); } if (appBarFinalDiv) { appBarFinalDiv.tabIndex = highestTabIndex; } }
javascript
function _LegacyAppBar_updateFirstAndFinalDiv() { var appBarFirstDiv = this._element.querySelectorAll("." + _Constants.firstDivClass); appBarFirstDiv = appBarFirstDiv.length >= 1 ? appBarFirstDiv[0] : null; var appBarFinalDiv = this._element.querySelectorAll("." + _Constants.finalDivClass); appBarFinalDiv = appBarFinalDiv.length >= 1 ? appBarFinalDiv[0] : null; // Remove the firstDiv & finalDiv if they are not at the appropriate locations if (appBarFirstDiv && (this._element.children[0] !== appBarFirstDiv)) { appBarFirstDiv.parentNode.removeChild(appBarFirstDiv); appBarFirstDiv = null; } if (appBarFinalDiv && (this._element.children[this._element.children.length - 1] !== appBarFinalDiv)) { appBarFinalDiv.parentNode.removeChild(appBarFinalDiv); appBarFinalDiv = null; } // Create and add the firstDiv & finalDiv if they don't already exist if (!appBarFirstDiv) { // Add a firstDiv that will be the first child of the appBar. // On focus set focus to the last element of the AppBar. appBarFirstDiv = _Global.document.createElement("div"); // display: inline is needed so that the div doesn't take up space and cause the page to scroll on focus appBarFirstDiv.style.display = "inline"; appBarFirstDiv.className = _Constants.firstDivClass; appBarFirstDiv.tabIndex = -1; appBarFirstDiv.setAttribute("aria-hidden", "true"); _ElementUtilities._addEventListener(appBarFirstDiv, "focusin", this._focusOnLastFocusableElementOrThis.bind(this), false); // add to beginning if (this._element.children[0]) { this._element.insertBefore(appBarFirstDiv, this._element.children[0]); } else { this._element.appendChild(appBarFirstDiv); } } if (!appBarFinalDiv) { // Add a finalDiv that will be the last child of the appBar. // On focus set focus to the first element of the AppBar. appBarFinalDiv = _Global.document.createElement("div"); // display: inline is needed so that the div doesn't take up space and cause the page to scroll on focus appBarFinalDiv.style.display = "inline"; appBarFinalDiv.className = _Constants.finalDivClass; appBarFinalDiv.tabIndex = -1; appBarFinalDiv.setAttribute("aria-hidden", "true"); _ElementUtilities._addEventListener(appBarFinalDiv, "focusin", this._focusOnFirstFocusableElementOrThis.bind(this), false); this._element.appendChild(appBarFinalDiv); } // invokeButton should be the second to last element in the _LegacyAppBar's tab order. Second to the finalDiv. if (this._element.children[this._element.children.length - 2] !== this._invokeButton) { this._element.insertBefore(this._invokeButton, appBarFinalDiv); } var elms = this._element.getElementsByTagName("*"); var highestTabIndex = _ElementUtilities._getHighestTabIndexInList(elms); this._invokeButton.tabIndex = highestTabIndex; // Update the tabIndex of the firstDiv & finalDiv if (appBarFirstDiv) { appBarFirstDiv.tabIndex = _ElementUtilities._getLowestTabIndexInList(elms); } if (appBarFinalDiv) { appBarFinalDiv.tabIndex = highestTabIndex; } }
[ "function", "_LegacyAppBar_updateFirstAndFinalDiv", "(", ")", "{", "var", "appBarFirstDiv", "=", "this", ".", "_element", ".", "querySelectorAll", "(", "\".\"", "+", "_Constants", ".", "firstDivClass", ")", ";", "appBarFirstDiv", "=", "appBarFirstDiv", ".", "length", ">=", "1", "?", "appBarFirstDiv", "[", "0", "]", ":", "null", ";", "var", "appBarFinalDiv", "=", "this", ".", "_element", ".", "querySelectorAll", "(", "\".\"", "+", "_Constants", ".", "finalDivClass", ")", ";", "appBarFinalDiv", "=", "appBarFinalDiv", ".", "length", ">=", "1", "?", "appBarFinalDiv", "[", "0", "]", ":", "null", ";", "// Remove the firstDiv & finalDiv if they are not at the appropriate locations", "if", "(", "appBarFirstDiv", "&&", "(", "this", ".", "_element", ".", "children", "[", "0", "]", "!==", "appBarFirstDiv", ")", ")", "{", "appBarFirstDiv", ".", "parentNode", ".", "removeChild", "(", "appBarFirstDiv", ")", ";", "appBarFirstDiv", "=", "null", ";", "}", "if", "(", "appBarFinalDiv", "&&", "(", "this", ".", "_element", ".", "children", "[", "this", ".", "_element", ".", "children", ".", "length", "-", "1", "]", "!==", "appBarFinalDiv", ")", ")", "{", "appBarFinalDiv", ".", "parentNode", ".", "removeChild", "(", "appBarFinalDiv", ")", ";", "appBarFinalDiv", "=", "null", ";", "}", "// Create and add the firstDiv & finalDiv if they don't already exist", "if", "(", "!", "appBarFirstDiv", ")", "{", "// Add a firstDiv that will be the first child of the appBar.", "// On focus set focus to the last element of the AppBar.", "appBarFirstDiv", "=", "_Global", ".", "document", ".", "createElement", "(", "\"div\"", ")", ";", "// display: inline is needed so that the div doesn't take up space and cause the page to scroll on focus", "appBarFirstDiv", ".", "style", ".", "display", "=", "\"inline\"", ";", "appBarFirstDiv", ".", "className", "=", "_Constants", ".", "firstDivClass", ";", "appBarFirstDiv", ".", "tabIndex", "=", "-", "1", ";", "appBarFirstDiv", ".", "setAttribute", "(", "\"aria-hidden\"", ",", "\"true\"", ")", ";", "_ElementUtilities", ".", "_addEventListener", "(", "appBarFirstDiv", ",", "\"focusin\"", ",", "this", ".", "_focusOnLastFocusableElementOrThis", ".", "bind", "(", "this", ")", ",", "false", ")", ";", "// add to beginning", "if", "(", "this", ".", "_element", ".", "children", "[", "0", "]", ")", "{", "this", ".", "_element", ".", "insertBefore", "(", "appBarFirstDiv", ",", "this", ".", "_element", ".", "children", "[", "0", "]", ")", ";", "}", "else", "{", "this", ".", "_element", ".", "appendChild", "(", "appBarFirstDiv", ")", ";", "}", "}", "if", "(", "!", "appBarFinalDiv", ")", "{", "// Add a finalDiv that will be the last child of the appBar.", "// On focus set focus to the first element of the AppBar.", "appBarFinalDiv", "=", "_Global", ".", "document", ".", "createElement", "(", "\"div\"", ")", ";", "// display: inline is needed so that the div doesn't take up space and cause the page to scroll on focus", "appBarFinalDiv", ".", "style", ".", "display", "=", "\"inline\"", ";", "appBarFinalDiv", ".", "className", "=", "_Constants", ".", "finalDivClass", ";", "appBarFinalDiv", ".", "tabIndex", "=", "-", "1", ";", "appBarFinalDiv", ".", "setAttribute", "(", "\"aria-hidden\"", ",", "\"true\"", ")", ";", "_ElementUtilities", ".", "_addEventListener", "(", "appBarFinalDiv", ",", "\"focusin\"", ",", "this", ".", "_focusOnFirstFocusableElementOrThis", ".", "bind", "(", "this", ")", ",", "false", ")", ";", "this", ".", "_element", ".", "appendChild", "(", "appBarFinalDiv", ")", ";", "}", "// invokeButton should be the second to last element in the _LegacyAppBar's tab order. Second to the finalDiv.", "if", "(", "this", ".", "_element", ".", "children", "[", "this", ".", "_element", ".", "children", ".", "length", "-", "2", "]", "!==", "this", ".", "_invokeButton", ")", "{", "this", ".", "_element", ".", "insertBefore", "(", "this", ".", "_invokeButton", ",", "appBarFinalDiv", ")", ";", "}", "var", "elms", "=", "this", ".", "_element", ".", "getElementsByTagName", "(", "\"*\"", ")", ";", "var", "highestTabIndex", "=", "_ElementUtilities", ".", "_getHighestTabIndexInList", "(", "elms", ")", ";", "this", ".", "_invokeButton", ".", "tabIndex", "=", "highestTabIndex", ";", "// Update the tabIndex of the firstDiv & finalDiv", "if", "(", "appBarFirstDiv", ")", "{", "appBarFirstDiv", ".", "tabIndex", "=", "_ElementUtilities", ".", "_getLowestTabIndexInList", "(", "elms", ")", ";", "}", "if", "(", "appBarFinalDiv", ")", "{", "appBarFinalDiv", ".", "tabIndex", "=", "highestTabIndex", ";", "}", "}" ]
If there is a shown non-sticky _LegacyAppBar then it sets the firstDiv tabIndex to the minimum tabIndex found in the _LegacyAppBars and finalDiv to the max found. Otherwise sets their tabIndex to -1 so they are not tab stops.
[ "If", "there", "is", "a", "shown", "non", "-", "sticky", "_LegacyAppBar", "then", "it", "sets", "the", "firstDiv", "tabIndex", "to", "the", "minimum", "tabIndex", "found", "in", "the", "_LegacyAppBars", "and", "finalDiv", "to", "the", "max", "found", ".", "Otherwise", "sets", "their", "tabIndex", "to", "-", "1", "so", "they", "are", "not", "tab", "stops", "." ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L47496-L47560
16,447
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
createQueryLinguisticDetails
function createQueryLinguisticDetails(compositionAlternatives, compositionStartOffset, compositionLength, queryTextPrefix, queryTextSuffix) { var linguisticDetails = null; // The linguistic alternatives we receive are only for the composition string being composed. We need to provide the linguistic alternatives // in the form of the full query text with alternatives embedded. var fullCompositionAlternatives = []; for (var i = 0; i < compositionAlternatives.length; i++) { fullCompositionAlternatives[i] = queryTextPrefix + compositionAlternatives[i] + queryTextSuffix; } if (_WinRT.Windows.ApplicationModel.Search.SearchQueryLinguisticDetails) { try { linguisticDetails = new _WinRT.Windows.ApplicationModel.Search.SearchQueryLinguisticDetails(fullCompositionAlternatives, compositionStartOffset, compositionLength); } catch (e) { // WP10 currently exposes SQLD API but throws on instantiation. } } if (!linguisticDetails) { // If we're in web compartment, create a script version of the WinRT SearchQueryLinguisticDetails object linguisticDetails = { queryTextAlternatives: fullCompositionAlternatives, queryTextCompositionStart: compositionStartOffset, queryTextCompositionLength: compositionLength }; } return linguisticDetails; }
javascript
function createQueryLinguisticDetails(compositionAlternatives, compositionStartOffset, compositionLength, queryTextPrefix, queryTextSuffix) { var linguisticDetails = null; // The linguistic alternatives we receive are only for the composition string being composed. We need to provide the linguistic alternatives // in the form of the full query text with alternatives embedded. var fullCompositionAlternatives = []; for (var i = 0; i < compositionAlternatives.length; i++) { fullCompositionAlternatives[i] = queryTextPrefix + compositionAlternatives[i] + queryTextSuffix; } if (_WinRT.Windows.ApplicationModel.Search.SearchQueryLinguisticDetails) { try { linguisticDetails = new _WinRT.Windows.ApplicationModel.Search.SearchQueryLinguisticDetails(fullCompositionAlternatives, compositionStartOffset, compositionLength); } catch (e) { // WP10 currently exposes SQLD API but throws on instantiation. } } if (!linguisticDetails) { // If we're in web compartment, create a script version of the WinRT SearchQueryLinguisticDetails object linguisticDetails = { queryTextAlternatives: fullCompositionAlternatives, queryTextCompositionStart: compositionStartOffset, queryTextCompositionLength: compositionLength }; } return linguisticDetails; }
[ "function", "createQueryLinguisticDetails", "(", "compositionAlternatives", ",", "compositionStartOffset", ",", "compositionLength", ",", "queryTextPrefix", ",", "queryTextSuffix", ")", "{", "var", "linguisticDetails", "=", "null", ";", "// The linguistic alternatives we receive are only for the composition string being composed. We need to provide the linguistic alternatives", "// in the form of the full query text with alternatives embedded.", "var", "fullCompositionAlternatives", "=", "[", "]", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "compositionAlternatives", ".", "length", ";", "i", "++", ")", "{", "fullCompositionAlternatives", "[", "i", "]", "=", "queryTextPrefix", "+", "compositionAlternatives", "[", "i", "]", "+", "queryTextSuffix", ";", "}", "if", "(", "_WinRT", ".", "Windows", ".", "ApplicationModel", ".", "Search", ".", "SearchQueryLinguisticDetails", ")", "{", "try", "{", "linguisticDetails", "=", "new", "_WinRT", ".", "Windows", ".", "ApplicationModel", ".", "Search", ".", "SearchQueryLinguisticDetails", "(", "fullCompositionAlternatives", ",", "compositionStartOffset", ",", "compositionLength", ")", ";", "}", "catch", "(", "e", ")", "{", "// WP10 currently exposes SQLD API but throws on instantiation.", "}", "}", "if", "(", "!", "linguisticDetails", ")", "{", "// If we're in web compartment, create a script version of the WinRT SearchQueryLinguisticDetails object", "linguisticDetails", "=", "{", "queryTextAlternatives", ":", "fullCompositionAlternatives", ",", "queryTextCompositionStart", ":", "compositionStartOffset", ",", "queryTextCompositionLength", ":", "compositionLength", "}", ";", "}", "return", "linguisticDetails", ";", "}" ]
createFilled=false always creates an empty linguistic details object, otherwise generate it or use the cache
[ "createFilled", "=", "false", "always", "creates", "an", "empty", "linguistic", "details", "object", "otherwise", "generate", "it", "or", "use", "the", "cache" ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L48969-L48996
16,448
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
SearchBox_requestingFocusOnKeyboardInputHandler
function SearchBox_requestingFocusOnKeyboardInputHandler() { this._fireEvent(EventName.receivingfocusonkeyboardinput, null); if (_Global.document.activeElement !== this._inputElement) { try { this._inputElement.focus(); } catch (e) { } } }
javascript
function SearchBox_requestingFocusOnKeyboardInputHandler() { this._fireEvent(EventName.receivingfocusonkeyboardinput, null); if (_Global.document.activeElement !== this._inputElement) { try { this._inputElement.focus(); } catch (e) { } } }
[ "function", "SearchBox_requestingFocusOnKeyboardInputHandler", "(", ")", "{", "this", ".", "_fireEvent", "(", "EventName", ".", "receivingfocusonkeyboardinput", ",", "null", ")", ";", "if", "(", "_Global", ".", "document", ".", "activeElement", "!==", "this", ".", "_inputElement", ")", "{", "try", "{", "this", ".", "_inputElement", ".", "focus", "(", ")", ";", "}", "catch", "(", "e", ")", "{", "}", "}", "}" ]
Type to search helpers
[ "Type", "to", "search", "helpers" ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L49968-L49976
16,449
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
_getChildSettingsControl
function _getChildSettingsControl(parentElement, id) { var settingElements = parentElement.querySelectorAll("." + _Constants.settingsFlyoutClass); var retValue, control; for (var i = 0; i < settingElements.length; i++) { control = settingElements[i].winControl; if (control) { if (control.settingsCommandId === id) { retValue = control; break; } if (settingElements[i].id === id) { retValue = retValue || control; } } } return retValue; }
javascript
function _getChildSettingsControl(parentElement, id) { var settingElements = parentElement.querySelectorAll("." + _Constants.settingsFlyoutClass); var retValue, control; for (var i = 0; i < settingElements.length; i++) { control = settingElements[i].winControl; if (control) { if (control.settingsCommandId === id) { retValue = control; break; } if (settingElements[i].id === id) { retValue = retValue || control; } } } return retValue; }
[ "function", "_getChildSettingsControl", "(", "parentElement", ",", "id", ")", "{", "var", "settingElements", "=", "parentElement", ".", "querySelectorAll", "(", "\".\"", "+", "_Constants", ".", "settingsFlyoutClass", ")", ";", "var", "retValue", ",", "control", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "settingElements", ".", "length", ";", "i", "++", ")", "{", "control", "=", "settingElements", "[", "i", "]", ".", "winControl", ";", "if", "(", "control", ")", "{", "if", "(", "control", ".", "settingsCommandId", "===", "id", ")", "{", "retValue", "=", "control", ";", "break", ";", "}", "if", "(", "settingElements", "[", "i", "]", ".", "id", "===", "id", ")", "{", "retValue", "=", "retValue", "||", "control", ";", "}", "}", "}", "return", "retValue", ";", "}" ]
Get the settings control by matching the settingsCommandId if no match we'll try to match element id
[ "Get", "the", "settings", "control", "by", "matching", "the", "settingsCommandId", "if", "no", "match", "we", "ll", "try", "to", "match", "element", "id" ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L50105-L50123
16,450
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
SettingsFlyout_addFirstDiv
function SettingsFlyout_addFirstDiv() { var _elms = this._element.getElementsByTagName("*"); var _minTab = 0; for (var i = 0; i < _elms.length; i++) { if ((0 < _elms[i].tabIndex) && (_minTab === 0 || _elms[i].tabIndex < _minTab)) { _minTab = _elms[i].tabIndex; } } var firstDiv = _Global.document.createElement("div"); firstDiv.className = _Constants.firstDivClass; firstDiv.style.display = "inline"; firstDiv.setAttribute("role", "menuitem"); firstDiv.setAttribute("aria-hidden", "true"); firstDiv.tabIndex = _minTab; _ElementUtilities._addEventListener(firstDiv, "focusin", this._focusOnLastFocusableElementFromParent, false); // add to beginning if (this._element.children[0]) { this._element.insertBefore(firstDiv, this._element.children[0]); } else { this._element.appendChild(firstDiv); } }
javascript
function SettingsFlyout_addFirstDiv() { var _elms = this._element.getElementsByTagName("*"); var _minTab = 0; for (var i = 0; i < _elms.length; i++) { if ((0 < _elms[i].tabIndex) && (_minTab === 0 || _elms[i].tabIndex < _minTab)) { _minTab = _elms[i].tabIndex; } } var firstDiv = _Global.document.createElement("div"); firstDiv.className = _Constants.firstDivClass; firstDiv.style.display = "inline"; firstDiv.setAttribute("role", "menuitem"); firstDiv.setAttribute("aria-hidden", "true"); firstDiv.tabIndex = _minTab; _ElementUtilities._addEventListener(firstDiv, "focusin", this._focusOnLastFocusableElementFromParent, false); // add to beginning if (this._element.children[0]) { this._element.insertBefore(firstDiv, this._element.children[0]); } else { this._element.appendChild(firstDiv); } }
[ "function", "SettingsFlyout_addFirstDiv", "(", ")", "{", "var", "_elms", "=", "this", ".", "_element", ".", "getElementsByTagName", "(", "\"*\"", ")", ";", "var", "_minTab", "=", "0", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "_elms", ".", "length", ";", "i", "++", ")", "{", "if", "(", "(", "0", "<", "_elms", "[", "i", "]", ".", "tabIndex", ")", "&&", "(", "_minTab", "===", "0", "||", "_elms", "[", "i", "]", ".", "tabIndex", "<", "_minTab", ")", ")", "{", "_minTab", "=", "_elms", "[", "i", "]", ".", "tabIndex", ";", "}", "}", "var", "firstDiv", "=", "_Global", ".", "document", ".", "createElement", "(", "\"div\"", ")", ";", "firstDiv", ".", "className", "=", "_Constants", ".", "firstDivClass", ";", "firstDiv", ".", "style", ".", "display", "=", "\"inline\"", ";", "firstDiv", ".", "setAttribute", "(", "\"role\"", ",", "\"menuitem\"", ")", ";", "firstDiv", ".", "setAttribute", "(", "\"aria-hidden\"", ",", "\"true\"", ")", ";", "firstDiv", ".", "tabIndex", "=", "_minTab", ";", "_ElementUtilities", ".", "_addEventListener", "(", "firstDiv", ",", "\"focusin\"", ",", "this", ".", "_focusOnLastFocusableElementFromParent", ",", "false", ")", ";", "// add to beginning", "if", "(", "this", ".", "_element", ".", "children", "[", "0", "]", ")", "{", "this", ".", "_element", ".", "insertBefore", "(", "firstDiv", ",", "this", ".", "_element", ".", "children", "[", "0", "]", ")", ";", "}", "else", "{", "this", ".", "_element", ".", "appendChild", "(", "firstDiv", ")", ";", "}", "}" ]
Create and add a new first div to the beginning of the list
[ "Create", "and", "add", "a", "new", "first", "div", "to", "the", "beginning", "of", "the", "list" ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L50558-L50580
16,451
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
SettingsFlyout_addFinalDiv
function SettingsFlyout_addFinalDiv() { var _elms = this._element.getElementsByTagName("*"); var _maxTab = 0; for (var i = 0; i < _elms.length; i++) { if (_elms[i].tabIndex > _maxTab) { _maxTab = _elms[i].tabIndex; } } var finalDiv = _Global.document.createElement("div"); finalDiv.className = _Constants.finalDivClass; finalDiv.style.display = "inline"; finalDiv.setAttribute("role", "menuitem"); finalDiv.setAttribute("aria-hidden", "true"); finalDiv.tabIndex = _maxTab; _ElementUtilities._addEventListener(finalDiv, "focusin", this._focusOnFirstFocusableElementFromParent, false); this._element.appendChild(finalDiv); }
javascript
function SettingsFlyout_addFinalDiv() { var _elms = this._element.getElementsByTagName("*"); var _maxTab = 0; for (var i = 0; i < _elms.length; i++) { if (_elms[i].tabIndex > _maxTab) { _maxTab = _elms[i].tabIndex; } } var finalDiv = _Global.document.createElement("div"); finalDiv.className = _Constants.finalDivClass; finalDiv.style.display = "inline"; finalDiv.setAttribute("role", "menuitem"); finalDiv.setAttribute("aria-hidden", "true"); finalDiv.tabIndex = _maxTab; _ElementUtilities._addEventListener(finalDiv, "focusin", this._focusOnFirstFocusableElementFromParent, false); this._element.appendChild(finalDiv); }
[ "function", "SettingsFlyout_addFinalDiv", "(", ")", "{", "var", "_elms", "=", "this", ".", "_element", ".", "getElementsByTagName", "(", "\"*\"", ")", ";", "var", "_maxTab", "=", "0", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "_elms", ".", "length", ";", "i", "++", ")", "{", "if", "(", "_elms", "[", "i", "]", ".", "tabIndex", ">", "_maxTab", ")", "{", "_maxTab", "=", "_elms", "[", "i", "]", ".", "tabIndex", ";", "}", "}", "var", "finalDiv", "=", "_Global", ".", "document", ".", "createElement", "(", "\"div\"", ")", ";", "finalDiv", ".", "className", "=", "_Constants", ".", "finalDivClass", ";", "finalDiv", ".", "style", ".", "display", "=", "\"inline\"", ";", "finalDiv", ".", "setAttribute", "(", "\"role\"", ",", "\"menuitem\"", ")", ";", "finalDiv", ".", "setAttribute", "(", "\"aria-hidden\"", ",", "\"true\"", ")", ";", "finalDiv", ".", "tabIndex", "=", "_maxTab", ";", "_ElementUtilities", ".", "_addEventListener", "(", "finalDiv", ",", "\"focusin\"", ",", "this", ".", "_focusOnFirstFocusableElementFromParent", ",", "false", ")", ";", "this", ".", "_element", ".", "appendChild", "(", "finalDiv", ")", ";", "}" ]
Create and add a new final div to the end of the list
[ "Create", "and", "add", "a", "new", "final", "div", "to", "the", "end", "of", "the", "list" ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L50583-L50600
16,452
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
ContentDialog_setState
function ContentDialog_setState(NewState, arg0) { if (!this._disposed) { this._state && this._state.exit(); this._state = new NewState(); this._state.dialog = this; this._state.enter(arg0); } }
javascript
function ContentDialog_setState(NewState, arg0) { if (!this._disposed) { this._state && this._state.exit(); this._state = new NewState(); this._state.dialog = this; this._state.enter(arg0); } }
[ "function", "ContentDialog_setState", "(", "NewState", ",", "arg0", ")", "{", "if", "(", "!", "this", ".", "_disposed", ")", "{", "this", ".", "_state", "&&", "this", ".", "_state", ".", "exit", "(", ")", ";", "this", ".", "_state", "=", "new", "NewState", "(", ")", ";", "this", ".", "_state", ".", "dialog", "=", "this", ";", "this", ".", "_state", ".", "enter", "(", "arg0", ")", ";", "}", "}" ]
Methods called by states
[ "Methods", "called", "by", "states" ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L54047-L54054
16,453
sitewaerts/cordova-plugin-document-viewer
src/common/js/winjs/js/ui.js
ContentDialog_renderForInputPane
function ContentDialog_renderForInputPane() { var rendered = this._rendered; if (!rendered.registeredForResize) { _ElementUtilities._resizeNotifier.subscribe(this._dom.root, this._onUpdateInputPaneRenderingBound); rendered.registeredForResize = true; } if (this._shouldResizeForInputPane()) { // Lay the dialog out using its normal rules but restrict it to the *visible document* // rather than the *visual viewport*. // Essentially, the dialog should be in the center of the part of the app that the user // can see regardless of the state of the input pane. var top = _KeyboardInfo._KeyboardInfo._visibleDocTop + "px"; var bottom = _KeyboardInfo._KeyboardInfo._visibleDocBottomOffset + "px"; if (rendered.top !== top) { this._dom.root.style.top = top; rendered.top = top; } if (rendered.bottom !== bottom) { this._dom.root.style.bottom = bottom; rendered.bottom = bottom; } if (!rendered.resizedForInputPane) { // Put title into scroller so there's more screen real estate for the content this._dom.scroller.insertBefore(this._dom.title, this._dom.content); this._dom.root.style.height = "auto"; // Height will be determined by setting top & bottom // Ensure activeElement is scrolled into view var activeElement = _Global.document.activeElement; if (activeElement && this._dom.scroller.contains(activeElement)) { activeElement.scrollIntoView(); } rendered.resizedForInputPane = true; } } }
javascript
function ContentDialog_renderForInputPane() { var rendered = this._rendered; if (!rendered.registeredForResize) { _ElementUtilities._resizeNotifier.subscribe(this._dom.root, this._onUpdateInputPaneRenderingBound); rendered.registeredForResize = true; } if (this._shouldResizeForInputPane()) { // Lay the dialog out using its normal rules but restrict it to the *visible document* // rather than the *visual viewport*. // Essentially, the dialog should be in the center of the part of the app that the user // can see regardless of the state of the input pane. var top = _KeyboardInfo._KeyboardInfo._visibleDocTop + "px"; var bottom = _KeyboardInfo._KeyboardInfo._visibleDocBottomOffset + "px"; if (rendered.top !== top) { this._dom.root.style.top = top; rendered.top = top; } if (rendered.bottom !== bottom) { this._dom.root.style.bottom = bottom; rendered.bottom = bottom; } if (!rendered.resizedForInputPane) { // Put title into scroller so there's more screen real estate for the content this._dom.scroller.insertBefore(this._dom.title, this._dom.content); this._dom.root.style.height = "auto"; // Height will be determined by setting top & bottom // Ensure activeElement is scrolled into view var activeElement = _Global.document.activeElement; if (activeElement && this._dom.scroller.contains(activeElement)) { activeElement.scrollIntoView(); } rendered.resizedForInputPane = true; } } }
[ "function", "ContentDialog_renderForInputPane", "(", ")", "{", "var", "rendered", "=", "this", ".", "_rendered", ";", "if", "(", "!", "rendered", ".", "registeredForResize", ")", "{", "_ElementUtilities", ".", "_resizeNotifier", ".", "subscribe", "(", "this", ".", "_dom", ".", "root", ",", "this", ".", "_onUpdateInputPaneRenderingBound", ")", ";", "rendered", ".", "registeredForResize", "=", "true", ";", "}", "if", "(", "this", ".", "_shouldResizeForInputPane", "(", ")", ")", "{", "// Lay the dialog out using its normal rules but restrict it to the *visible document*", "// rather than the *visual viewport*.", "// Essentially, the dialog should be in the center of the part of the app that the user", "// can see regardless of the state of the input pane.", "var", "top", "=", "_KeyboardInfo", ".", "_KeyboardInfo", ".", "_visibleDocTop", "+", "\"px\"", ";", "var", "bottom", "=", "_KeyboardInfo", ".", "_KeyboardInfo", ".", "_visibleDocBottomOffset", "+", "\"px\"", ";", "if", "(", "rendered", ".", "top", "!==", "top", ")", "{", "this", ".", "_dom", ".", "root", ".", "style", ".", "top", "=", "top", ";", "rendered", ".", "top", "=", "top", ";", "}", "if", "(", "rendered", ".", "bottom", "!==", "bottom", ")", "{", "this", ".", "_dom", ".", "root", ".", "style", ".", "bottom", "=", "bottom", ";", "rendered", ".", "bottom", "=", "bottom", ";", "}", "if", "(", "!", "rendered", ".", "resizedForInputPane", ")", "{", "// Put title into scroller so there's more screen real estate for the content", "this", ".", "_dom", ".", "scroller", ".", "insertBefore", "(", "this", ".", "_dom", ".", "title", ",", "this", ".", "_dom", ".", "content", ")", ";", "this", ".", "_dom", ".", "root", ".", "style", ".", "height", "=", "\"auto\"", ";", "// Height will be determined by setting top & bottom", "// Ensure activeElement is scrolled into view", "var", "activeElement", "=", "_Global", ".", "document", ".", "activeElement", ";", "if", "(", "activeElement", "&&", "this", ".", "_dom", ".", "scroller", ".", "contains", "(", "activeElement", ")", ")", "{", "activeElement", ".", "scrollIntoView", "(", ")", ";", "}", "rendered", ".", "resizedForInputPane", "=", "true", ";", "}", "}", "}" ]
This function assumes it's in an environment that supports -ms-device-fixed.
[ "This", "function", "assumes", "it", "s", "in", "an", "environment", "that", "supports", "-", "ms", "-", "device", "-", "fixed", "." ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/winjs/js/ui.js#L54142-L54181
16,454
sitewaerts/cordova-plugin-document-viewer
src/windows/sitewaertsdocumentviewer/js/pdfviewer.js
function (requestIndex, countBefore, countAfter) { if (requestIndex >= pages.length) return WinJS.Promise.wrapError( new WinJS.ErrorFromName( WinJS.UI.FetchError.doesNotExist)); // countBefore = Math.min(ctrl.options.pagesToLoad, // countBefore); // countAfter = Math.min(ctrl.options.pagesToLoad, // countAfter); var results = []; var fetchIndex = Math.max( requestIndex - countBefore, 0); var lastFetchIndex = Math.min( requestIndex + countAfter, pages.length - 1); pages[requestIndex].triggerLoad(); // trigger image generator on requested page first for (var i = fetchIndex; i <= lastFetchIndex; i++) { /** * @type Page */ var page = pages[i]; //page.triggerLoad(); // trigger image generator on requested pages results.push( {key: i.toString(), data: page}); } pdfViewer.setFocusedPageIndex(requestIndex); // implements IFetchResult return WinJS.Promise.wrap({ absoluteIndex: requestIndex, items: results, // The array of items. offset: requestIndex - fetchIndex, // The index of the requested item in the items array. totalCount: pages.length, // The total number of records. This is equal to total number of pages in a PDF file , atStart: fetchIndex === 0, atEnd: fetchIndex === pages.length - 1 }); }
javascript
function (requestIndex, countBefore, countAfter) { if (requestIndex >= pages.length) return WinJS.Promise.wrapError( new WinJS.ErrorFromName( WinJS.UI.FetchError.doesNotExist)); // countBefore = Math.min(ctrl.options.pagesToLoad, // countBefore); // countAfter = Math.min(ctrl.options.pagesToLoad, // countAfter); var results = []; var fetchIndex = Math.max( requestIndex - countBefore, 0); var lastFetchIndex = Math.min( requestIndex + countAfter, pages.length - 1); pages[requestIndex].triggerLoad(); // trigger image generator on requested page first for (var i = fetchIndex; i <= lastFetchIndex; i++) { /** * @type Page */ var page = pages[i]; //page.triggerLoad(); // trigger image generator on requested pages results.push( {key: i.toString(), data: page}); } pdfViewer.setFocusedPageIndex(requestIndex); // implements IFetchResult return WinJS.Promise.wrap({ absoluteIndex: requestIndex, items: results, // The array of items. offset: requestIndex - fetchIndex, // The index of the requested item in the items array. totalCount: pages.length, // The total number of records. This is equal to total number of pages in a PDF file , atStart: fetchIndex === 0, atEnd: fetchIndex === pages.length - 1 }); }
[ "function", "(", "requestIndex", ",", "countBefore", ",", "countAfter", ")", "{", "if", "(", "requestIndex", ">=", "pages", ".", "length", ")", "return", "WinJS", ".", "Promise", ".", "wrapError", "(", "new", "WinJS", ".", "ErrorFromName", "(", "WinJS", ".", "UI", ".", "FetchError", ".", "doesNotExist", ")", ")", ";", "// countBefore = Math.min(ctrl.options.pagesToLoad,\r", "// countBefore);\r", "// countAfter = Math.min(ctrl.options.pagesToLoad,\r", "// countAfter);\r", "var", "results", "=", "[", "]", ";", "var", "fetchIndex", "=", "Math", ".", "max", "(", "requestIndex", "-", "countBefore", ",", "0", ")", ";", "var", "lastFetchIndex", "=", "Math", ".", "min", "(", "requestIndex", "+", "countAfter", ",", "pages", ".", "length", "-", "1", ")", ";", "pages", "[", "requestIndex", "]", ".", "triggerLoad", "(", ")", ";", "// trigger image generator on requested page first\r", "for", "(", "var", "i", "=", "fetchIndex", ";", "i", "<=", "lastFetchIndex", ";", "i", "++", ")", "{", "/**\r\n * @type Page\r\n */", "var", "page", "=", "pages", "[", "i", "]", ";", "//page.triggerLoad(); // trigger image generator on requested pages\r", "results", ".", "push", "(", "{", "key", ":", "i", ".", "toString", "(", ")", ",", "data", ":", "page", "}", ")", ";", "}", "pdfViewer", ".", "setFocusedPageIndex", "(", "requestIndex", ")", ";", "// implements IFetchResult\r", "return", "WinJS", ".", "Promise", ".", "wrap", "(", "{", "absoluteIndex", ":", "requestIndex", ",", "items", ":", "results", ",", "// The array of items.\r", "offset", ":", "requestIndex", "-", "fetchIndex", ",", "// The index of the requested item in the items array.\r", "totalCount", ":", "pages", ".", "length", ",", "// The total number of records. This is equal to total number of pages in a PDF file ,\r", "atStart", ":", "fetchIndex", "===", "0", ",", "atEnd", ":", "fetchIndex", "===", "pages", ".", "length", "-", "1", "}", ")", ";", "}" ]
Called by the virtualized data source to fetch items It will request a specific item and optionally ask for a number of items on either side of the requested item. The implementation should return the specific item and, in addition, can choose to return a range of items on either side of the requested index. The number of extra items returned by the implementation can be more or less than the number requested.
[ "Called", "by", "the", "virtualized", "data", "source", "to", "fetch", "items", "It", "will", "request", "a", "specific", "item", "and", "optionally", "ask", "for", "a", "number", "of", "items", "on", "either", "side", "of", "the", "requested", "item", ".", "The", "implementation", "should", "return", "the", "specific", "item", "and", "in", "addition", "can", "choose", "to", "return", "a", "range", "of", "items", "on", "either", "side", "of", "the", "requested", "index", ".", "The", "number", "of", "extra", "items", "returned", "by", "the", "implementation", "can", "be", "more", "or", "less", "than", "the", "number", "requested", "." ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/windows/sitewaertsdocumentviewer/js/pdfviewer.js#L945-L991
16,455
sitewaerts/cordova-plugin-document-viewer
src/common/js/angular-winjs/js/angular-winjs.js
getElementRoot
function getElementRoot(element) { var curr = element; while (curr.parentNode) { curr = curr.parentNode; } return curr; }
javascript
function getElementRoot(element) { var curr = element; while (curr.parentNode) { curr = curr.parentNode; } return curr; }
[ "function", "getElementRoot", "(", "element", ")", "{", "var", "curr", "=", "element", ";", "while", "(", "curr", ".", "parentNode", ")", "{", "curr", "=", "curr", ".", "parentNode", ";", "}", "return", "curr", ";", "}" ]
Pure utility functions
[ "Pure", "utility", "functions" ]
25b82d959c20d7880d513100c2b979e1e15349dc
https://github.com/sitewaerts/cordova-plugin-document-viewer/blob/25b82d959c20d7880d513100c2b979e1e15349dc/src/common/js/angular-winjs/js/angular-winjs.js#L51-L57
16,456
words/syllable
index.js
syllable
function syllable(value) { var count = 0 var index var length var singular var parts var addOne var subtractOne if (value.length === 0) { return count } // Return early when possible. if (value.length < 3) { return 1 } // If `value` is a hard to count, it might be in `problematic`. if (own.call(problematic, value)) { return problematic[value] } // Additionally, the singular word might be in `problematic`. singular = pluralize(value, 1) if (own.call(problematic, singular)) { return problematic[singular] } addOne = returnFactory(1) subtractOne = returnFactory(-1) // Count some prefixes and suffixes, and remove their matched ranges. value = value .replace(EXPRESSION_TRIPLE, countFactory(3)) .replace(EXPRESSION_DOUBLE, countFactory(2)) .replace(EXPRESSION_SINGLE, countFactory(1)) // Count multiple consonants. parts = value.split(/[^aeiouy]+/) index = -1 length = parts.length while (++index < length) { if (parts[index] !== '') { count++ } } // Subtract one for occurrences which should be counted as one (but are // counted as two). value .replace(EXPRESSION_MONOSYLLABIC_ONE, subtractOne) .replace(EXPRESSION_MONOSYLLABIC_TWO, subtractOne) // Add one for occurrences which should be counted as two (but are counted as // one). value .replace(EXPRESSION_DOUBLE_SYLLABIC_ONE, addOne) .replace(EXPRESSION_DOUBLE_SYLLABIC_TWO, addOne) .replace(EXPRESSION_DOUBLE_SYLLABIC_THREE, addOne) .replace(EXPRESSION_DOUBLE_SYLLABIC_FOUR, addOne) // Make sure at least on is returned. return count || 1 // Define scoped counters, to be used in `String#replace()` calls. // The scoped counter removes the matched value from the input. function countFactory(addition) { return counter function counter() { count += addition return '' } } // Define scoped counters, to be used in `String#replace()` calls. // The scoped counter does not remove the matched value from the input. function returnFactory(addition) { return returner function returner($0) { count += addition return $0 } } }
javascript
function syllable(value) { var count = 0 var index var length var singular var parts var addOne var subtractOne if (value.length === 0) { return count } // Return early when possible. if (value.length < 3) { return 1 } // If `value` is a hard to count, it might be in `problematic`. if (own.call(problematic, value)) { return problematic[value] } // Additionally, the singular word might be in `problematic`. singular = pluralize(value, 1) if (own.call(problematic, singular)) { return problematic[singular] } addOne = returnFactory(1) subtractOne = returnFactory(-1) // Count some prefixes and suffixes, and remove their matched ranges. value = value .replace(EXPRESSION_TRIPLE, countFactory(3)) .replace(EXPRESSION_DOUBLE, countFactory(2)) .replace(EXPRESSION_SINGLE, countFactory(1)) // Count multiple consonants. parts = value.split(/[^aeiouy]+/) index = -1 length = parts.length while (++index < length) { if (parts[index] !== '') { count++ } } // Subtract one for occurrences which should be counted as one (but are // counted as two). value .replace(EXPRESSION_MONOSYLLABIC_ONE, subtractOne) .replace(EXPRESSION_MONOSYLLABIC_TWO, subtractOne) // Add one for occurrences which should be counted as two (but are counted as // one). value .replace(EXPRESSION_DOUBLE_SYLLABIC_ONE, addOne) .replace(EXPRESSION_DOUBLE_SYLLABIC_TWO, addOne) .replace(EXPRESSION_DOUBLE_SYLLABIC_THREE, addOne) .replace(EXPRESSION_DOUBLE_SYLLABIC_FOUR, addOne) // Make sure at least on is returned. return count || 1 // Define scoped counters, to be used in `String#replace()` calls. // The scoped counter removes the matched value from the input. function countFactory(addition) { return counter function counter() { count += addition return '' } } // Define scoped counters, to be used in `String#replace()` calls. // The scoped counter does not remove the matched value from the input. function returnFactory(addition) { return returner function returner($0) { count += addition return $0 } } }
[ "function", "syllable", "(", "value", ")", "{", "var", "count", "=", "0", "var", "index", "var", "length", "var", "singular", "var", "parts", "var", "addOne", "var", "subtractOne", "if", "(", "value", ".", "length", "===", "0", ")", "{", "return", "count", "}", "// Return early when possible.", "if", "(", "value", ".", "length", "<", "3", ")", "{", "return", "1", "}", "// If `value` is a hard to count, it might be in `problematic`.", "if", "(", "own", ".", "call", "(", "problematic", ",", "value", ")", ")", "{", "return", "problematic", "[", "value", "]", "}", "// Additionally, the singular word might be in `problematic`.", "singular", "=", "pluralize", "(", "value", ",", "1", ")", "if", "(", "own", ".", "call", "(", "problematic", ",", "singular", ")", ")", "{", "return", "problematic", "[", "singular", "]", "}", "addOne", "=", "returnFactory", "(", "1", ")", "subtractOne", "=", "returnFactory", "(", "-", "1", ")", "// Count some prefixes and suffixes, and remove their matched ranges.", "value", "=", "value", ".", "replace", "(", "EXPRESSION_TRIPLE", ",", "countFactory", "(", "3", ")", ")", ".", "replace", "(", "EXPRESSION_DOUBLE", ",", "countFactory", "(", "2", ")", ")", ".", "replace", "(", "EXPRESSION_SINGLE", ",", "countFactory", "(", "1", ")", ")", "// Count multiple consonants.", "parts", "=", "value", ".", "split", "(", "/", "[^aeiouy]+", "/", ")", "index", "=", "-", "1", "length", "=", "parts", ".", "length", "while", "(", "++", "index", "<", "length", ")", "{", "if", "(", "parts", "[", "index", "]", "!==", "''", ")", "{", "count", "++", "}", "}", "// Subtract one for occurrences which should be counted as one (but are", "// counted as two).", "value", ".", "replace", "(", "EXPRESSION_MONOSYLLABIC_ONE", ",", "subtractOne", ")", ".", "replace", "(", "EXPRESSION_MONOSYLLABIC_TWO", ",", "subtractOne", ")", "// Add one for occurrences which should be counted as two (but are counted as", "// one).", "value", ".", "replace", "(", "EXPRESSION_DOUBLE_SYLLABIC_ONE", ",", "addOne", ")", ".", "replace", "(", "EXPRESSION_DOUBLE_SYLLABIC_TWO", ",", "addOne", ")", ".", "replace", "(", "EXPRESSION_DOUBLE_SYLLABIC_THREE", ",", "addOne", ")", ".", "replace", "(", "EXPRESSION_DOUBLE_SYLLABIC_FOUR", ",", "addOne", ")", "// Make sure at least on is returned.", "return", "count", "||", "1", "// Define scoped counters, to be used in `String#replace()` calls.", "// The scoped counter removes the matched value from the input.", "function", "countFactory", "(", "addition", ")", "{", "return", "counter", "function", "counter", "(", ")", "{", "count", "+=", "addition", "return", "''", "}", "}", "// Define scoped counters, to be used in `String#replace()` calls.", "// The scoped counter does not remove the matched value from the input.", "function", "returnFactory", "(", "addition", ")", "{", "return", "returner", "function", "returner", "(", "$0", ")", "{", "count", "+=", "addition", "return", "$0", "}", "}", "}" ]
Get syllables in a given value.
[ "Get", "syllables", "in", "a", "given", "value", "." ]
9ce23aae3aa2ccdc5ae9b9136bfdd9a4d50103a5
https://github.com/words/syllable/blob/9ce23aae3aa2ccdc5ae9b9136bfdd9a4d50103a5/index.js#L254-L340
16,457
azuqua/jwt-redis-session
lib/utils.js
function(claims, callback){ if(typeof claims === "function" && !callback){ callback = claims; claims = {}; } var self = this, sid = uuid.v4(); var token = jwt.sign(_.extend({ jti: sid }, claims || {}), options.secret, { algorithm: options.algorithm }); options.client.setex(options.keyspace + sid, options.maxAge, JSON.stringify(serializeSession(self)), function(error){ self.id = sid; callback(error, token); }); }
javascript
function(claims, callback){ if(typeof claims === "function" && !callback){ callback = claims; claims = {}; } var self = this, sid = uuid.v4(); var token = jwt.sign(_.extend({ jti: sid }, claims || {}), options.secret, { algorithm: options.algorithm }); options.client.setex(options.keyspace + sid, options.maxAge, JSON.stringify(serializeSession(self)), function(error){ self.id = sid; callback(error, token); }); }
[ "function", "(", "claims", ",", "callback", ")", "{", "if", "(", "typeof", "claims", "===", "\"function\"", "&&", "!", "callback", ")", "{", "callback", "=", "claims", ";", "claims", "=", "{", "}", ";", "}", "var", "self", "=", "this", ",", "sid", "=", "uuid", ".", "v4", "(", ")", ";", "var", "token", "=", "jwt", ".", "sign", "(", "_", ".", "extend", "(", "{", "jti", ":", "sid", "}", ",", "claims", "||", "{", "}", ")", ",", "options", ".", "secret", ",", "{", "algorithm", ":", "options", ".", "algorithm", "}", ")", ";", "options", ".", "client", ".", "setex", "(", "options", ".", "keyspace", "+", "sid", ",", "options", ".", "maxAge", ",", "JSON", ".", "stringify", "(", "serializeSession", "(", "self", ")", ")", ",", "function", "(", "error", ")", "{", "self", ".", "id", "=", "sid", ";", "callback", "(", "error", ",", "token", ")", ";", "}", ")", ";", "}" ]
create a new session and return the jwt
[ "create", "a", "new", "session", "and", "return", "the", "jwt" ]
8161f7c2b0a5fc94d913a8a07a78950fee62a045
https://github.com/azuqua/jwt-redis-session/blob/8161f7c2b0a5fc94d913a8a07a78950fee62a045/lib/utils.js#L32-L44
16,458
azuqua/jwt-redis-session
lib/utils.js
function(callback){ if(!this.id){ return process.nextTick(function(){ callback(new Error("Invalid session ID")); }); } options.client.expire(options.keyspace + this.id, options.maxAge, callback); }
javascript
function(callback){ if(!this.id){ return process.nextTick(function(){ callback(new Error("Invalid session ID")); }); } options.client.expire(options.keyspace + this.id, options.maxAge, callback); }
[ "function", "(", "callback", ")", "{", "if", "(", "!", "this", ".", "id", ")", "{", "return", "process", ".", "nextTick", "(", "function", "(", ")", "{", "callback", "(", "new", "Error", "(", "\"Invalid session ID\"", ")", ")", ";", "}", ")", ";", "}", "options", ".", "client", ".", "expire", "(", "options", ".", "keyspace", "+", "this", ".", "id", ",", "options", ".", "maxAge", ",", "callback", ")", ";", "}" ]
update the TTL on a session
[ "update", "the", "TTL", "on", "a", "session" ]
8161f7c2b0a5fc94d913a8a07a78950fee62a045
https://github.com/azuqua/jwt-redis-session/blob/8161f7c2b0a5fc94d913a8a07a78950fee62a045/lib/utils.js#L47-L54
16,459
azuqua/jwt-redis-session
lib/utils.js
function(callback){ if(!this.id){ return process.nextTick(function(){ callback(new Error("Invalid session ID")); }); } options.client.setex(options.keyspace + this.id, options.maxAge, JSON.stringify(serializeSession(this)), callback); }
javascript
function(callback){ if(!this.id){ return process.nextTick(function(){ callback(new Error("Invalid session ID")); }); } options.client.setex(options.keyspace + this.id, options.maxAge, JSON.stringify(serializeSession(this)), callback); }
[ "function", "(", "callback", ")", "{", "if", "(", "!", "this", ".", "id", ")", "{", "return", "process", ".", "nextTick", "(", "function", "(", ")", "{", "callback", "(", "new", "Error", "(", "\"Invalid session ID\"", ")", ")", ";", "}", ")", ";", "}", "options", ".", "client", ".", "setex", "(", "options", ".", "keyspace", "+", "this", ".", "id", ",", "options", ".", "maxAge", ",", "JSON", ".", "stringify", "(", "serializeSession", "(", "this", ")", ")", ",", "callback", ")", ";", "}" ]
update a session's data, update the ttl
[ "update", "a", "session", "s", "data", "update", "the", "ttl" ]
8161f7c2b0a5fc94d913a8a07a78950fee62a045
https://github.com/azuqua/jwt-redis-session/blob/8161f7c2b0a5fc94d913a8a07a78950fee62a045/lib/utils.js#L57-L64
16,460
azuqua/jwt-redis-session
lib/utils.js
function(callback){ var self = this; if(!this.id){ return process.nextTick(function(){ callback(new Error("Invalid session ID")); }); } options.client.get(options.keyspace + self.id, function(error, resp){ if(error) return callback(error); try{ resp = JSON.parse(resp); }catch(e){ return callback(e); } extendSession(self, resp); callback(); }); }
javascript
function(callback){ var self = this; if(!this.id){ return process.nextTick(function(){ callback(new Error("Invalid session ID")); }); } options.client.get(options.keyspace + self.id, function(error, resp){ if(error) return callback(error); try{ resp = JSON.parse(resp); }catch(e){ return callback(e); } extendSession(self, resp); callback(); }); }
[ "function", "(", "callback", ")", "{", "var", "self", "=", "this", ";", "if", "(", "!", "this", ".", "id", ")", "{", "return", "process", ".", "nextTick", "(", "function", "(", ")", "{", "callback", "(", "new", "Error", "(", "\"Invalid session ID\"", ")", ")", ";", "}", ")", ";", "}", "options", ".", "client", ".", "get", "(", "options", ".", "keyspace", "+", "self", ".", "id", ",", "function", "(", "error", ",", "resp", ")", "{", "if", "(", "error", ")", "return", "callback", "(", "error", ")", ";", "try", "{", "resp", "=", "JSON", ".", "parse", "(", "resp", ")", ";", "}", "catch", "(", "e", ")", "{", "return", "callback", "(", "e", ")", ";", "}", "extendSession", "(", "self", ",", "resp", ")", ";", "callback", "(", ")", ";", "}", ")", ";", "}" ]
reload a session data from redis
[ "reload", "a", "session", "data", "from", "redis" ]
8161f7c2b0a5fc94d913a8a07a78950fee62a045
https://github.com/azuqua/jwt-redis-session/blob/8161f7c2b0a5fc94d913a8a07a78950fee62a045/lib/utils.js#L67-L86
16,461
azuqua/jwt-redis-session
lib/utils.js
function(callback){ if(!this.id){ return process.nextTick(function(){ callback(new Error("Invalid session ID")); }); } options.client.del(options.keyspace + this.id, callback); }
javascript
function(callback){ if(!this.id){ return process.nextTick(function(){ callback(new Error("Invalid session ID")); }); } options.client.del(options.keyspace + this.id, callback); }
[ "function", "(", "callback", ")", "{", "if", "(", "!", "this", ".", "id", ")", "{", "return", "process", ".", "nextTick", "(", "function", "(", ")", "{", "callback", "(", "new", "Error", "(", "\"Invalid session ID\"", ")", ")", ";", "}", ")", ";", "}", "options", ".", "client", ".", "del", "(", "options", ".", "keyspace", "+", "this", ".", "id", ",", "callback", ")", ";", "}" ]
destroy a session
[ "destroy", "a", "session" ]
8161f7c2b0a5fc94d913a8a07a78950fee62a045
https://github.com/azuqua/jwt-redis-session/blob/8161f7c2b0a5fc94d913a8a07a78950fee62a045/lib/utils.js#L89-L96
16,462
shama/gaze
lib/gaze.js
Gaze
function Gaze (patterns, opts, done) { EE.call(this); // If second arg is the callback if (typeof opts === 'function') { done = opts; opts = {}; } // Default options opts = opts || {}; opts.mark = true; opts.interval = opts.interval || 100; opts.debounceDelay = opts.debounceDelay || 500; opts.cwd = opts.cwd || process.cwd(); this.options = opts; // Default done callback done = done || emptyFunction; // Remember our watched dir:files this._watched = Object.create(null); // Store watchers this._watchers = Object.create(null); // Store watchFile listeners this._pollers = Object.create(null); // Store patterns this._patterns = []; // Cached events for debouncing this._cached = Object.create(null); // Set maxListeners if (this.options.maxListeners != null) { this.setMaxListeners(this.options.maxListeners); delete this.options.maxListeners; } // Initialize the watch on files if (patterns) { this.add(patterns, done); } // keep the process alive this._keepalive = setInterval(emptyFunction, 200); return this; }
javascript
function Gaze (patterns, opts, done) { EE.call(this); // If second arg is the callback if (typeof opts === 'function') { done = opts; opts = {}; } // Default options opts = opts || {}; opts.mark = true; opts.interval = opts.interval || 100; opts.debounceDelay = opts.debounceDelay || 500; opts.cwd = opts.cwd || process.cwd(); this.options = opts; // Default done callback done = done || emptyFunction; // Remember our watched dir:files this._watched = Object.create(null); // Store watchers this._watchers = Object.create(null); // Store watchFile listeners this._pollers = Object.create(null); // Store patterns this._patterns = []; // Cached events for debouncing this._cached = Object.create(null); // Set maxListeners if (this.options.maxListeners != null) { this.setMaxListeners(this.options.maxListeners); delete this.options.maxListeners; } // Initialize the watch on files if (patterns) { this.add(patterns, done); } // keep the process alive this._keepalive = setInterval(emptyFunction, 200); return this; }
[ "function", "Gaze", "(", "patterns", ",", "opts", ",", "done", ")", "{", "EE", ".", "call", "(", "this", ")", ";", "// If second arg is the callback", "if", "(", "typeof", "opts", "===", "'function'", ")", "{", "done", "=", "opts", ";", "opts", "=", "{", "}", ";", "}", "// Default options", "opts", "=", "opts", "||", "{", "}", ";", "opts", ".", "mark", "=", "true", ";", "opts", ".", "interval", "=", "opts", ".", "interval", "||", "100", ";", "opts", ".", "debounceDelay", "=", "opts", ".", "debounceDelay", "||", "500", ";", "opts", ".", "cwd", "=", "opts", ".", "cwd", "||", "process", ".", "cwd", "(", ")", ";", "this", ".", "options", "=", "opts", ";", "// Default done callback", "done", "=", "done", "||", "emptyFunction", ";", "// Remember our watched dir:files", "this", ".", "_watched", "=", "Object", ".", "create", "(", "null", ")", ";", "// Store watchers", "this", ".", "_watchers", "=", "Object", ".", "create", "(", "null", ")", ";", "// Store watchFile listeners", "this", ".", "_pollers", "=", "Object", ".", "create", "(", "null", ")", ";", "// Store patterns", "this", ".", "_patterns", "=", "[", "]", ";", "// Cached events for debouncing", "this", ".", "_cached", "=", "Object", ".", "create", "(", "null", ")", ";", "// Set maxListeners", "if", "(", "this", ".", "options", ".", "maxListeners", "!=", "null", ")", "{", "this", ".", "setMaxListeners", "(", "this", ".", "options", ".", "maxListeners", ")", ";", "delete", "this", ".", "options", ".", "maxListeners", ";", "}", "// Initialize the watch on files", "if", "(", "patterns", ")", "{", "this", ".", "add", "(", "patterns", ",", "done", ")", ";", "}", "// keep the process alive", "this", ".", "_keepalive", "=", "setInterval", "(", "emptyFunction", ",", "200", ")", ";", "return", "this", ";", "}" ]
`Gaze` EventEmitter object to return in the callback
[ "Gaze", "EventEmitter", "object", "to", "return", "in", "the", "callback" ]
19b87085606e80e02e5ca05ea942cf8a34732b59
https://github.com/shama/gaze/blob/19b87085606e80e02e5ca05ea942cf8a34732b59/lib/gaze.js#L24-L74
16,463
webpack-contrib/stylelint-webpack-plugin
lib/lint-dirty-modules-plugin.js
LintDirtyModulesPlugin
function LintDirtyModulesPlugin(compiler, options) { this.startTime = Date.now(); this.prevTimestamps = {}; this.isFirstRun = true; this.compiler = compiler; this.options = options; // bind(this) is here to prevent context overriding by webpack compiler.plugin('emit', this.lint.bind(this)); }
javascript
function LintDirtyModulesPlugin(compiler, options) { this.startTime = Date.now(); this.prevTimestamps = {}; this.isFirstRun = true; this.compiler = compiler; this.options = options; // bind(this) is here to prevent context overriding by webpack compiler.plugin('emit', this.lint.bind(this)); }
[ "function", "LintDirtyModulesPlugin", "(", "compiler", ",", "options", ")", "{", "this", ".", "startTime", "=", "Date", ".", "now", "(", ")", ";", "this", ".", "prevTimestamps", "=", "{", "}", ";", "this", ".", "isFirstRun", "=", "true", ";", "this", ".", "compiler", "=", "compiler", ";", "this", ".", "options", "=", "options", ";", "// bind(this) is here to prevent context overriding by webpack", "compiler", ".", "plugin", "(", "'emit'", ",", "this", ".", "lint", ".", "bind", "(", "this", ")", ")", ";", "}" ]
Binds callback with provided options and stores initial values. @param compiler - webpack compiler object @param options - stylelint nodejs options
[ "Binds", "callback", "with", "provided", "options", "and", "stores", "initial", "values", "." ]
5ae9467ef6eaabfb42bd2e77ce34f8d380095601
https://github.com/webpack-contrib/stylelint-webpack-plugin/blob/5ae9467ef6eaabfb42bd2e77ce34f8d380095601/lib/lint-dirty-modules-plugin.js#L12-L21
16,464
croqaz/clean-mark
lib/read.js
getArticle
function getArticle (candidates, $) { let topCandidate = null candidates.forEach(elem => { const linkDensity = getLinkDensity(elem, $) const siblings = elem.children('p').length const score = elem.data('readabilityScore') elem.data( 'readabilityScore', Math.min(2, Math.max(siblings, 1)) * score * (1 - linkDensity) ) if ( !topCandidate || elem.data('readabilityScore') > topCandidate.data('readabilityScore') ) { topCandidate = elem } }) /** * If we still have no top candidate, just use the body as a last resort. * Should not happen. * */ if (topCandidate === null) { return $('body') } // Perhaps the topCandidate is the parent? let parent if ( !(parent = topCandidate.parent()) || parent.length === 0 || topCandidate.children('p').length > 5 ) { return filterCandidates(topCandidate, topCandidate.children(), $) } return filterCandidates(topCandidate, parent.children(), $) }
javascript
function getArticle (candidates, $) { let topCandidate = null candidates.forEach(elem => { const linkDensity = getLinkDensity(elem, $) const siblings = elem.children('p').length const score = elem.data('readabilityScore') elem.data( 'readabilityScore', Math.min(2, Math.max(siblings, 1)) * score * (1 - linkDensity) ) if ( !topCandidate || elem.data('readabilityScore') > topCandidate.data('readabilityScore') ) { topCandidate = elem } }) /** * If we still have no top candidate, just use the body as a last resort. * Should not happen. * */ if (topCandidate === null) { return $('body') } // Perhaps the topCandidate is the parent? let parent if ( !(parent = topCandidate.parent()) || parent.length === 0 || topCandidate.children('p').length > 5 ) { return filterCandidates(topCandidate, topCandidate.children(), $) } return filterCandidates(topCandidate, parent.children(), $) }
[ "function", "getArticle", "(", "candidates", ",", "$", ")", "{", "let", "topCandidate", "=", "null", "candidates", ".", "forEach", "(", "elem", "=>", "{", "const", "linkDensity", "=", "getLinkDensity", "(", "elem", ",", "$", ")", "const", "siblings", "=", "elem", ".", "children", "(", "'p'", ")", ".", "length", "const", "score", "=", "elem", ".", "data", "(", "'readabilityScore'", ")", "elem", ".", "data", "(", "'readabilityScore'", ",", "Math", ".", "min", "(", "2", ",", "Math", ".", "max", "(", "siblings", ",", "1", ")", ")", "*", "score", "*", "(", "1", "-", "linkDensity", ")", ")", "if", "(", "!", "topCandidate", "||", "elem", ".", "data", "(", "'readabilityScore'", ")", ">", "topCandidate", ".", "data", "(", "'readabilityScore'", ")", ")", "{", "topCandidate", "=", "elem", "}", "}", ")", "/**\n * If we still have no top candidate, just use the body as a last resort.\n * Should not happen.\n * */", "if", "(", "topCandidate", "===", "null", ")", "{", "return", "$", "(", "'body'", ")", "}", "// Perhaps the topCandidate is the parent?", "let", "parent", "if", "(", "!", "(", "parent", "=", "topCandidate", ".", "parent", "(", ")", ")", "||", "parent", ".", "length", "===", "0", "||", "topCandidate", ".", "children", "(", "'p'", ")", ".", "length", ">", "5", ")", "{", "return", "filterCandidates", "(", "topCandidate", ",", "topCandidate", ".", "children", "(", ")", ",", "$", ")", "}", "return", "filterCandidates", "(", "topCandidate", ",", "parent", ".", "children", "(", ")", ",", "$", ")", "}" ]
Select the TopCandidate from all possible candidates
[ "Select", "the", "TopCandidate", "from", "all", "possible", "candidates" ]
48e5b95093e086ca88130af1800861a46895d2e6
https://github.com/croqaz/clean-mark/blob/48e5b95093e086ca88130af1800861a46895d2e6/lib/read.js#L37-L73
16,465
croqaz/clean-mark
lib/read.js
scoreCandidate
function scoreCandidate (node, contentScore, candidates) { let score if (typeof node.data('readabilityScore') === 'undefined') { score = initializeNode(node) candidates.push(node) } else { score = node.data('readabilityScore') || 0 } node.data('readabilityScore', score + contentScore) }
javascript
function scoreCandidate (node, contentScore, candidates) { let score if (typeof node.data('readabilityScore') === 'undefined') { score = initializeNode(node) candidates.push(node) } else { score = node.data('readabilityScore') || 0 } node.data('readabilityScore', score + contentScore) }
[ "function", "scoreCandidate", "(", "node", ",", "contentScore", ",", "candidates", ")", "{", "let", "score", "if", "(", "typeof", "node", ".", "data", "(", "'readabilityScore'", ")", "===", "'undefined'", ")", "{", "score", "=", "initializeNode", "(", "node", ")", "candidates", ".", "push", "(", "node", ")", "}", "else", "{", "score", "=", "node", ".", "data", "(", "'readabilityScore'", ")", "||", "0", "}", "node", ".", "data", "(", "'readabilityScore'", ",", "score", "+", "contentScore", ")", "}" ]
Give a score to each node based on the Content. @param node @param contentScore @param candidates
[ "Give", "a", "score", "to", "each", "node", "based", "on", "the", "Content", "." ]
48e5b95093e086ca88130af1800861a46895d2e6
https://github.com/croqaz/clean-mark/blob/48e5b95093e086ca88130af1800861a46895d2e6/lib/read.js#L252-L261
16,466
croqaz/clean-mark
lib/read.js
initializeNode
function initializeNode (node) { if (!node || node.length === 0) { return 0 } const tag = node.get(0).name if (nodeTypes.mostPositive.indexOf(tag) >= 0) { return 5 + getClassWeight(node) } if (nodeTypes.positive.indexOf(tag) >= 0) { return 3 + getClassWeight(node) } if (nodeTypes.negative.indexOf(tag) >= 0) { return -3 + getClassWeight(node) } if (nodeTypes.mostNegative.indexOf(tag) >= 0) { return -5 + getClassWeight(node) } return -1 }
javascript
function initializeNode (node) { if (!node || node.length === 0) { return 0 } const tag = node.get(0).name if (nodeTypes.mostPositive.indexOf(tag) >= 0) { return 5 + getClassWeight(node) } if (nodeTypes.positive.indexOf(tag) >= 0) { return 3 + getClassWeight(node) } if (nodeTypes.negative.indexOf(tag) >= 0) { return -3 + getClassWeight(node) } if (nodeTypes.mostNegative.indexOf(tag) >= 0) { return -5 + getClassWeight(node) } return -1 }
[ "function", "initializeNode", "(", "node", ")", "{", "if", "(", "!", "node", "||", "node", ".", "length", "===", "0", ")", "{", "return", "0", "}", "const", "tag", "=", "node", ".", "get", "(", "0", ")", ".", "name", "if", "(", "nodeTypes", ".", "mostPositive", ".", "indexOf", "(", "tag", ")", ">=", "0", ")", "{", "return", "5", "+", "getClassWeight", "(", "node", ")", "}", "if", "(", "nodeTypes", ".", "positive", ".", "indexOf", "(", "tag", ")", ">=", "0", ")", "{", "return", "3", "+", "getClassWeight", "(", "node", ")", "}", "if", "(", "nodeTypes", ".", "negative", ".", "indexOf", "(", "tag", ")", ">=", "0", ")", "{", "return", "-", "3", "+", "getClassWeight", "(", "node", ")", "}", "if", "(", "nodeTypes", ".", "mostNegative", ".", "indexOf", "(", "tag", ")", ">=", "0", ")", "{", "return", "-", "5", "+", "getClassWeight", "(", "node", ")", "}", "return", "-", "1", "}" ]
Check the type of node, and get its Weight
[ "Check", "the", "type", "of", "node", "and", "get", "its", "Weight" ]
48e5b95093e086ca88130af1800861a46895d2e6
https://github.com/croqaz/clean-mark/blob/48e5b95093e086ca88130af1800861a46895d2e6/lib/read.js#L308-L326
16,467
croqaz/clean-mark
lib/read.js
getClassWeight
function getClassWeight (node) { if (node === null || node.length === 0) { return 0 } const name = node.get(0).name || '' const cls = node.attr('class') || '' const nid = node.attr('id') || '' let weight = 0 // Schema.org/Article if (node.attr('itemprop') && /articleBody/.test(node.attr('itemprop'))) { weight += 50 } // Nodes of type text if (node.attr('type') && node.attr('type') === 'text') { weight += 30 } // Special cases if (name === 'article') { weight += 25 } if (name === 'section') { weight += 10 } if (name === 'header' || name === 'aside' || name === 'footer') { weight -= 25 } if (cls === 'comments' && nid === 'comments') { weight -= 25 } if (cls.search(regexps.negativeRe) !== -1) { weight -= 25 } if (nid.search(regexps.negativeRe) !== -1) { weight -= 20 } if (cls.search(regexps.positiveRe) !== -1) { weight += 25 } if (nid.search(regexps.positiveRe) !== -1) { weight += 20 } return weight }
javascript
function getClassWeight (node) { if (node === null || node.length === 0) { return 0 } const name = node.get(0).name || '' const cls = node.attr('class') || '' const nid = node.attr('id') || '' let weight = 0 // Schema.org/Article if (node.attr('itemprop') && /articleBody/.test(node.attr('itemprop'))) { weight += 50 } // Nodes of type text if (node.attr('type') && node.attr('type') === 'text') { weight += 30 } // Special cases if (name === 'article') { weight += 25 } if (name === 'section') { weight += 10 } if (name === 'header' || name === 'aside' || name === 'footer') { weight -= 25 } if (cls === 'comments' && nid === 'comments') { weight -= 25 } if (cls.search(regexps.negativeRe) !== -1) { weight -= 25 } if (nid.search(regexps.negativeRe) !== -1) { weight -= 20 } if (cls.search(regexps.positiveRe) !== -1) { weight += 25 } if (nid.search(regexps.positiveRe) !== -1) { weight += 20 } return weight }
[ "function", "getClassWeight", "(", "node", ")", "{", "if", "(", "node", "===", "null", "||", "node", ".", "length", "===", "0", ")", "{", "return", "0", "}", "const", "name", "=", "node", ".", "get", "(", "0", ")", ".", "name", "||", "''", "const", "cls", "=", "node", ".", "attr", "(", "'class'", ")", "||", "''", "const", "nid", "=", "node", ".", "attr", "(", "'id'", ")", "||", "''", "let", "weight", "=", "0", "// Schema.org/Article", "if", "(", "node", ".", "attr", "(", "'itemprop'", ")", "&&", "/", "articleBody", "/", ".", "test", "(", "node", ".", "attr", "(", "'itemprop'", ")", ")", ")", "{", "weight", "+=", "50", "}", "// Nodes of type text", "if", "(", "node", ".", "attr", "(", "'type'", ")", "&&", "node", ".", "attr", "(", "'type'", ")", "===", "'text'", ")", "{", "weight", "+=", "30", "}", "// Special cases", "if", "(", "name", "===", "'article'", ")", "{", "weight", "+=", "25", "}", "if", "(", "name", "===", "'section'", ")", "{", "weight", "+=", "10", "}", "if", "(", "name", "===", "'header'", "||", "name", "===", "'aside'", "||", "name", "===", "'footer'", ")", "{", "weight", "-=", "25", "}", "if", "(", "cls", "===", "'comments'", "&&", "nid", "===", "'comments'", ")", "{", "weight", "-=", "25", "}", "if", "(", "cls", ".", "search", "(", "regexps", ".", "negativeRe", ")", "!==", "-", "1", ")", "{", "weight", "-=", "25", "}", "if", "(", "nid", ".", "search", "(", "regexps", ".", "negativeRe", ")", "!==", "-", "1", ")", "{", "weight", "-=", "20", "}", "if", "(", "cls", ".", "search", "(", "regexps", ".", "positiveRe", ")", "!==", "-", "1", ")", "{", "weight", "+=", "25", "}", "if", "(", "nid", ".", "search", "(", "regexps", ".", "positiveRe", ")", "!==", "-", "1", ")", "{", "weight", "+=", "20", "}", "return", "weight", "}" ]
Node Weight is calculated based on className and ID of the node.
[ "Node", "Weight", "is", "calculated", "based", "on", "className", "and", "ID", "of", "the", "node", "." ]
48e5b95093e086ca88130af1800861a46895d2e6
https://github.com/croqaz/clean-mark/blob/48e5b95093e086ca88130af1800861a46895d2e6/lib/read.js#L332-L377
16,468
croqaz/clean-mark
lib/read.js
getLinkDensity
function getLinkDensity (node, $) { const links = node.find('a') const textLength = node.text().length let linkLength = 0 links.each(function (index, elem) { const href = $(this).attr('href') if (!href || (href.length > 0 && href[0] === '#')) { return } linkLength += $(this).text().length }) return linkLength / textLength || 0 }
javascript
function getLinkDensity (node, $) { const links = node.find('a') const textLength = node.text().length let linkLength = 0 links.each(function (index, elem) { const href = $(this).attr('href') if (!href || (href.length > 0 && href[0] === '#')) { return } linkLength += $(this).text().length }) return linkLength / textLength || 0 }
[ "function", "getLinkDensity", "(", "node", ",", "$", ")", "{", "const", "links", "=", "node", ".", "find", "(", "'a'", ")", "const", "textLength", "=", "node", ".", "text", "(", ")", ".", "length", "let", "linkLength", "=", "0", "links", ".", "each", "(", "function", "(", "index", ",", "elem", ")", "{", "const", "href", "=", "$", "(", "this", ")", ".", "attr", "(", "'href'", ")", "if", "(", "!", "href", "||", "(", "href", ".", "length", ">", "0", "&&", "href", "[", "0", "]", "===", "'#'", ")", ")", "{", "return", "}", "linkLength", "+=", "$", "(", "this", ")", ".", "text", "(", ")", ".", "length", "}", ")", "return", "linkLength", "/", "textLength", "||", "0", "}" ]
Get Link density of this node. Total length of link text in this node divided by the total text of the node. Relative links are not included.
[ "Get", "Link", "density", "of", "this", "node", ".", "Total", "length", "of", "link", "text", "in", "this", "node", "divided", "by", "the", "total", "text", "of", "the", "node", ".", "Relative", "links", "are", "not", "included", "." ]
48e5b95093e086ca88130af1800861a46895d2e6
https://github.com/croqaz/clean-mark/blob/48e5b95093e086ca88130af1800861a46895d2e6/lib/read.js#L385-L399
16,469
croqaz/clean-mark
lib/read.js
extract
function extract ($, base) { const candidates = getCandidates($, base) let article = getArticle(candidates, $) if (article.length < 1) { article = getArticle([$('body')], $) } return article }
javascript
function extract ($, base) { const candidates = getCandidates($, base) let article = getArticle(candidates, $) if (article.length < 1) { article = getArticle([$('body')], $) } return article }
[ "function", "extract", "(", "$", ",", "base", ")", "{", "const", "candidates", "=", "getCandidates", "(", "$", ",", "base", ")", "let", "article", "=", "getArticle", "(", "candidates", ",", "$", ")", "if", "(", "article", ".", "length", "<", "1", ")", "{", "article", "=", "getArticle", "(", "[", "$", "(", "'body'", ")", "]", ",", "$", ")", "}", "return", "article", "}" ]
Main method If the first run does not succeed, try the body element;
[ "Main", "method", "If", "the", "first", "run", "does", "not", "succeed", "try", "the", "body", "element", ";" ]
48e5b95093e086ca88130af1800861a46895d2e6
https://github.com/croqaz/clean-mark/blob/48e5b95093e086ca88130af1800861a46895d2e6/lib/read.js#L406-L413
16,470
croqaz/clean-mark
lib/meta/index.js
scrapeMetadata
function scrapeMetadata (html, rules) { rules = rules || RULES const keys = Object.keys(rules) const $ = cheerio.load(html) const promises = keys.map(function (key) { return scrapeMetadatum($, '', rules[key]) }) return Promise.all(promises).then(function (values) { return keys.reduce(function (memo, key, i) { memo[key] = values[i] return memo }, {}) }) }
javascript
function scrapeMetadata (html, rules) { rules = rules || RULES const keys = Object.keys(rules) const $ = cheerio.load(html) const promises = keys.map(function (key) { return scrapeMetadatum($, '', rules[key]) }) return Promise.all(promises).then(function (values) { return keys.reduce(function (memo, key, i) { memo[key] = values[i] return memo }, {}) }) }
[ "function", "scrapeMetadata", "(", "html", ",", "rules", ")", "{", "rules", "=", "rules", "||", "RULES", "const", "keys", "=", "Object", ".", "keys", "(", "rules", ")", "const", "$", "=", "cheerio", ".", "load", "(", "html", ")", "const", "promises", "=", "keys", ".", "map", "(", "function", "(", "key", ")", "{", "return", "scrapeMetadatum", "(", "$", ",", "''", ",", "rules", "[", "key", "]", ")", "}", ")", "return", "Promise", ".", "all", "(", "promises", ")", ".", "then", "(", "function", "(", "values", ")", "{", "return", "keys", ".", "reduce", "(", "function", "(", "memo", ",", "key", ",", "i", ")", "{", "memo", "[", "key", "]", "=", "values", "[", "i", "]", "return", "memo", "}", ",", "{", "}", ")", "}", ")", "}" ]
Scrape each entry in the metadata result dictionary in parallel. @param {String} html @param {String} url @param {Object} rules (optional) @return {Promise} metadata
[ "Scrape", "each", "entry", "in", "the", "metadata", "result", "dictionary", "in", "parallel", "." ]
48e5b95093e086ca88130af1800861a46895d2e6
https://github.com/croqaz/clean-mark/blob/48e5b95093e086ca88130af1800861a46895d2e6/lib/meta/index.js#L17-L31
16,471
croqaz/clean-mark
lib/meta/index.js
scrapeMetadatum
function scrapeMetadatum ($, url, rules) { if (!Array.isArray(rules)) rules = [rules] return rules.reduce(function (promise, rule) { return promise.then(function (value) { if (value != null && value !== '') return value var next = rule($, url) if (next != null && next !== '') return next return null }) }, Promise.resolve()) }
javascript
function scrapeMetadatum ($, url, rules) { if (!Array.isArray(rules)) rules = [rules] return rules.reduce(function (promise, rule) { return promise.then(function (value) { if (value != null && value !== '') return value var next = rule($, url) if (next != null && next !== '') return next return null }) }, Promise.resolve()) }
[ "function", "scrapeMetadatum", "(", "$", ",", "url", ",", "rules", ")", "{", "if", "(", "!", "Array", ".", "isArray", "(", "rules", ")", ")", "rules", "=", "[", "rules", "]", "return", "rules", ".", "reduce", "(", "function", "(", "promise", ",", "rule", ")", "{", "return", "promise", ".", "then", "(", "function", "(", "value", ")", "{", "if", "(", "value", "!=", "null", "&&", "value", "!==", "''", ")", "return", "value", "var", "next", "=", "rule", "(", "$", ",", "url", ")", "if", "(", "next", "!=", "null", "&&", "next", "!==", "''", ")", "return", "next", "return", "null", "}", ")", "}", ",", "Promise", ".", "resolve", "(", ")", ")", "}" ]
Scrape the first non-null value returned by an array of `rules` functions for a single property in the metadata result dictionary. @param {Cheerio} $ @param {String} url @param {Array or Function} rules @return {Promise} value
[ "Scrape", "the", "first", "non", "-", "null", "value", "returned", "by", "an", "array", "of", "rules", "functions", "for", "a", "single", "property", "in", "the", "metadata", "result", "dictionary", "." ]
48e5b95093e086ca88130af1800861a46895d2e6
https://github.com/croqaz/clean-mark/blob/48e5b95093e086ca88130af1800861a46895d2e6/lib/meta/index.js#L43-L54
16,472
NathanWalker/angular-seed-advanced
tools/install.js
AttemptRootSymlink
function AttemptRootSymlink() { if (process.platform === 'win32') { var curPath = resolve("./"); if (debugging) { console.log("RootSymlink Base path is", curPath); } cp.execSync("powershell -Command \"Start-Process 'node' -ArgumentList '"+curPath+"/install.js symlink' -verb runas\""); } else { console.log("To automatically create a SymLink between your web app and NativeScript, we need root for a second."); cp.execSync("sudo "+process.argv[0] + " " + process.argv[1] +" symlink"); } }
javascript
function AttemptRootSymlink() { if (process.platform === 'win32') { var curPath = resolve("./"); if (debugging) { console.log("RootSymlink Base path is", curPath); } cp.execSync("powershell -Command \"Start-Process 'node' -ArgumentList '"+curPath+"/install.js symlink' -verb runas\""); } else { console.log("To automatically create a SymLink between your web app and NativeScript, we need root for a second."); cp.execSync("sudo "+process.argv[0] + " " + process.argv[1] +" symlink"); } }
[ "function", "AttemptRootSymlink", "(", ")", "{", "if", "(", "process", ".", "platform", "===", "'win32'", ")", "{", "var", "curPath", "=", "resolve", "(", "\"./\"", ")", ";", "if", "(", "debugging", ")", "{", "console", ".", "log", "(", "\"RootSymlink Base path is\"", ",", "curPath", ")", ";", "}", "cp", ".", "execSync", "(", "\"powershell -Command \\\"Start-Process 'node' -ArgumentList '\"", "+", "curPath", "+", "\"/install.js symlink' -verb runas\\\"\"", ")", ";", "}", "else", "{", "console", ".", "log", "(", "\"To automatically create a SymLink between your web app and NativeScript, we need root for a second.\"", ")", ";", "cp", ".", "execSync", "(", "\"sudo \"", "+", "process", ".", "argv", "[", "0", "]", "+", "\" \"", "+", "process", ".", "argv", "[", "1", "]", "+", "\" symlink\"", ")", ";", "}", "}" ]
This will attempt to run the install script as root to make a symlink
[ "This", "will", "attempt", "to", "run", "the", "install", "script", "as", "root", "to", "make", "a", "symlink" ]
2d652e157a4841830f616fbc9be69d8fddf2ae2e
https://github.com/NathanWalker/angular-seed-advanced/blob/2d652e157a4841830f616fbc9be69d8fddf2ae2e/tools/install.js#L71-L83
16,473
NathanWalker/angular-seed-advanced
tools/install.js
createRootSymLink
function createRootSymLink() { var li1 = process.argv[1].lastIndexOf('\\'), li2 = process.argv[1].lastIndexOf('/'); if (li2 > li1) { li1 = li2; } var AppPath = process.argv[1].substring(0,li1); var p1 = resolve(AppPath + "/" + nativescriptAppPath); var p2 = resolve(AppPath + "/" + webAppPath); if (debugging) { console.log("Path: ", p1, p2); } fs.symlinkSync(p2, p1, 'junction'); }
javascript
function createRootSymLink() { var li1 = process.argv[1].lastIndexOf('\\'), li2 = process.argv[1].lastIndexOf('/'); if (li2 > li1) { li1 = li2; } var AppPath = process.argv[1].substring(0,li1); var p1 = resolve(AppPath + "/" + nativescriptAppPath); var p2 = resolve(AppPath + "/" + webAppPath); if (debugging) { console.log("Path: ", p1, p2); } fs.symlinkSync(p2, p1, 'junction'); }
[ "function", "createRootSymLink", "(", ")", "{", "var", "li1", "=", "process", ".", "argv", "[", "1", "]", ".", "lastIndexOf", "(", "'\\\\'", ")", ",", "li2", "=", "process", ".", "argv", "[", "1", "]", ".", "lastIndexOf", "(", "'/'", ")", ";", "if", "(", "li2", ">", "li1", ")", "{", "li1", "=", "li2", ";", "}", "var", "AppPath", "=", "process", ".", "argv", "[", "1", "]", ".", "substring", "(", "0", ",", "li1", ")", ";", "var", "p1", "=", "resolve", "(", "AppPath", "+", "\"/\"", "+", "nativescriptAppPath", ")", ";", "var", "p2", "=", "resolve", "(", "AppPath", "+", "\"/\"", "+", "webAppPath", ")", ";", "if", "(", "debugging", ")", "{", "console", ".", "log", "(", "\"Path: \"", ",", "p1", ",", "p2", ")", ";", "}", "fs", ".", "symlinkSync", "(", "p2", ",", "p1", ",", "'junction'", ")", ";", "}" ]
Create the symlink when running as root
[ "Create", "the", "symlink", "when", "running", "as", "root" ]
2d652e157a4841830f616fbc9be69d8fddf2ae2e
https://github.com/NathanWalker/angular-seed-advanced/blob/2d652e157a4841830f616fbc9be69d8fddf2ae2e/tools/install.js#L88-L98
16,474
contentful/contentful-export
lib/tasks/get-space-data.js
pagedGet
function pagedGet ({source, method, skip = 0, aggregatedResponse = null, query = null}) { const fullQuery = Object.assign({}, { skip: skip, limit: pageLimit, order: 'sys.createdAt,sys.id' }, query ) return source[method](fullQuery) .then((response) => { if (!aggregatedResponse) { aggregatedResponse = response } else { aggregatedResponse.items = aggregatedResponse.items.concat(response.items) } const page = Math.ceil(skip / pageLimit) + 1 const pages = Math.ceil(response.total / pageLimit) logEmitter.emit('info', `Fetched ${aggregatedResponse.items.length} of ${response.total} items (Page ${page}/${pages})`) if (skip + pageLimit <= response.total) { return pagedGet({source, method, skip: skip + pageLimit, aggregatedResponse, query}) } return aggregatedResponse }) }
javascript
function pagedGet ({source, method, skip = 0, aggregatedResponse = null, query = null}) { const fullQuery = Object.assign({}, { skip: skip, limit: pageLimit, order: 'sys.createdAt,sys.id' }, query ) return source[method](fullQuery) .then((response) => { if (!aggregatedResponse) { aggregatedResponse = response } else { aggregatedResponse.items = aggregatedResponse.items.concat(response.items) } const page = Math.ceil(skip / pageLimit) + 1 const pages = Math.ceil(response.total / pageLimit) logEmitter.emit('info', `Fetched ${aggregatedResponse.items.length} of ${response.total} items (Page ${page}/${pages})`) if (skip + pageLimit <= response.total) { return pagedGet({source, method, skip: skip + pageLimit, aggregatedResponse, query}) } return aggregatedResponse }) }
[ "function", "pagedGet", "(", "{", "source", ",", "method", ",", "skip", "=", "0", ",", "aggregatedResponse", "=", "null", ",", "query", "=", "null", "}", ")", "{", "const", "fullQuery", "=", "Object", ".", "assign", "(", "{", "}", ",", "{", "skip", ":", "skip", ",", "limit", ":", "pageLimit", ",", "order", ":", "'sys.createdAt,sys.id'", "}", ",", "query", ")", "return", "source", "[", "method", "]", "(", "fullQuery", ")", ".", "then", "(", "(", "response", ")", "=>", "{", "if", "(", "!", "aggregatedResponse", ")", "{", "aggregatedResponse", "=", "response", "}", "else", "{", "aggregatedResponse", ".", "items", "=", "aggregatedResponse", ".", "items", ".", "concat", "(", "response", ".", "items", ")", "}", "const", "page", "=", "Math", ".", "ceil", "(", "skip", "/", "pageLimit", ")", "+", "1", "const", "pages", "=", "Math", ".", "ceil", "(", "response", ".", "total", "/", "pageLimit", ")", "logEmitter", ".", "emit", "(", "'info'", ",", "`", "${", "aggregatedResponse", ".", "items", ".", "length", "}", "${", "response", ".", "total", "}", "${", "page", "}", "${", "pages", "}", "`", ")", "if", "(", "skip", "+", "pageLimit", "<=", "response", ".", "total", ")", "{", "return", "pagedGet", "(", "{", "source", ",", "method", ",", "skip", ":", "skip", "+", "pageLimit", ",", "aggregatedResponse", ",", "query", "}", ")", "}", "return", "aggregatedResponse", "}", ")", "}" ]
Gets all the existing entities based on pagination parameters. The first call will have no aggregated response. Subsequent calls will concatenate the new responses to the original one.
[ "Gets", "all", "the", "existing", "entities", "based", "on", "pagination", "parameters", ".", "The", "first", "call", "will", "have", "no", "aggregated", "response", ".", "Subsequent", "calls", "will", "concatenate", "the", "new", "responses", "to", "the", "original", "one", "." ]
8c5ad62494904967207479f338c6a0e102c9f186
https://github.com/contentful/contentful-export/blob/8c5ad62494904967207479f338c6a0e102c9f186/lib/tasks/get-space-data.js#L157-L182
16,475
pugjs/pug-cli
index.js
parseObj
function parseObj (input) { try { return require(path.resolve(input)); } catch (e) { var str; try { str = fs.readFileSync(program.obj, 'utf8'); } catch (e) { str = program.obj; } try { return JSON.parse(str); } catch (e) { return eval('(' + str + ')'); } } }
javascript
function parseObj (input) { try { return require(path.resolve(input)); } catch (e) { var str; try { str = fs.readFileSync(program.obj, 'utf8'); } catch (e) { str = program.obj; } try { return JSON.parse(str); } catch (e) { return eval('(' + str + ')'); } } }
[ "function", "parseObj", "(", "input", ")", "{", "try", "{", "return", "require", "(", "path", ".", "resolve", "(", "input", ")", ")", ";", "}", "catch", "(", "e", ")", "{", "var", "str", ";", "try", "{", "str", "=", "fs", ".", "readFileSync", "(", "program", ".", "obj", ",", "'utf8'", ")", ";", "}", "catch", "(", "e", ")", "{", "str", "=", "program", ".", "obj", ";", "}", "try", "{", "return", "JSON", ".", "parse", "(", "str", ")", ";", "}", "catch", "(", "e", ")", "{", "return", "eval", "(", "'('", "+", "str", "+", "')'", ")", ";", "}", "}", "}" ]
Parse object either in `input` or in the file called `input`. The latter is searched first.
[ "Parse", "object", "either", "in", "input", "or", "in", "the", "file", "called", "input", ".", "The", "latter", "is", "searched", "first", "." ]
0eb8d37c5a38cb297cf09361631b93312e0dfa21
https://github.com/pugjs/pug-cli/blob/0eb8d37c5a38cb297cf09361631b93312e0dfa21/index.js#L88-L104
16,476
pugjs/pug-cli
index.js
watchFile
function watchFile(path, base, rootPath) { path = normalize(path); var log = ' ' + chalk.gray('watching') + ' ' + chalk.cyan(path); if (!base) { base = path; } else { base = normalize(base); log += '\n ' + chalk.gray('as a dependency of') + ' '; log += chalk.cyan(base); } if (watchList[path]) { if (watchList[path].indexOf(base) !== -1) return; consoleLog(log); watchList[path].push(base); return; } consoleLog(log); watchList[path] = [base]; fs.watchFile(path, {persistent: true, interval: 200}, function (curr, prev) { // File doesn't exist anymore. Keep watching. if (curr.mtime.getTime() === 0) return; // istanbul ignore if if (curr.mtime.getTime() === prev.mtime.getTime()) return; watchList[path].forEach(function(file) { tryRender(file, rootPath); }); }); }
javascript
function watchFile(path, base, rootPath) { path = normalize(path); var log = ' ' + chalk.gray('watching') + ' ' + chalk.cyan(path); if (!base) { base = path; } else { base = normalize(base); log += '\n ' + chalk.gray('as a dependency of') + ' '; log += chalk.cyan(base); } if (watchList[path]) { if (watchList[path].indexOf(base) !== -1) return; consoleLog(log); watchList[path].push(base); return; } consoleLog(log); watchList[path] = [base]; fs.watchFile(path, {persistent: true, interval: 200}, function (curr, prev) { // File doesn't exist anymore. Keep watching. if (curr.mtime.getTime() === 0) return; // istanbul ignore if if (curr.mtime.getTime() === prev.mtime.getTime()) return; watchList[path].forEach(function(file) { tryRender(file, rootPath); }); }); }
[ "function", "watchFile", "(", "path", ",", "base", ",", "rootPath", ")", "{", "path", "=", "normalize", "(", "path", ")", ";", "var", "log", "=", "' '", "+", "chalk", ".", "gray", "(", "'watching'", ")", "+", "' '", "+", "chalk", ".", "cyan", "(", "path", ")", ";", "if", "(", "!", "base", ")", "{", "base", "=", "path", ";", "}", "else", "{", "base", "=", "normalize", "(", "base", ")", ";", "log", "+=", "'\\n '", "+", "chalk", ".", "gray", "(", "'as a dependency of'", ")", "+", "' '", ";", "log", "+=", "chalk", ".", "cyan", "(", "base", ")", ";", "}", "if", "(", "watchList", "[", "path", "]", ")", "{", "if", "(", "watchList", "[", "path", "]", ".", "indexOf", "(", "base", ")", "!==", "-", "1", ")", "return", ";", "consoleLog", "(", "log", ")", ";", "watchList", "[", "path", "]", ".", "push", "(", "base", ")", ";", "return", ";", "}", "consoleLog", "(", "log", ")", ";", "watchList", "[", "path", "]", "=", "[", "base", "]", ";", "fs", ".", "watchFile", "(", "path", ",", "{", "persistent", ":", "true", ",", "interval", ":", "200", "}", ",", "function", "(", "curr", ",", "prev", ")", "{", "// File doesn't exist anymore. Keep watching.", "if", "(", "curr", ".", "mtime", ".", "getTime", "(", ")", "===", "0", ")", "return", ";", "// istanbul ignore if", "if", "(", "curr", ".", "mtime", ".", "getTime", "(", ")", "===", "prev", ".", "mtime", ".", "getTime", "(", ")", ")", "return", ";", "watchList", "[", "path", "]", ".", "forEach", "(", "function", "(", "file", ")", "{", "tryRender", "(", "file", ",", "rootPath", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
Watch for changes on path Renders `base` if specified, otherwise renders `path`.
[ "Watch", "for", "changes", "on", "path" ]
0eb8d37c5a38cb297cf09361631b93312e0dfa21
https://github.com/pugjs/pug-cli/blob/0eb8d37c5a38cb297cf09361631b93312e0dfa21/index.js#L161-L192
16,477
pugjs/pug-cli
index.js
tryRender
function tryRender(path, rootPath) { try { renderFile(path, rootPath); } catch (e) { // keep watching when error occured. console.error(errorToString(e) + '\x07'); } }
javascript
function tryRender(path, rootPath) { try { renderFile(path, rootPath); } catch (e) { // keep watching when error occured. console.error(errorToString(e) + '\x07'); } }
[ "function", "tryRender", "(", "path", ",", "rootPath", ")", "{", "try", "{", "renderFile", "(", "path", ",", "rootPath", ")", ";", "}", "catch", "(", "e", ")", "{", "// keep watching when error occured.", "console", ".", "error", "(", "errorToString", "(", "e", ")", "+", "'\\x07'", ")", ";", "}", "}" ]
Try to render `path`; if an exception is thrown it is printed to stderr and otherwise ignored. This is used in watch mode.
[ "Try", "to", "render", "path", ";", "if", "an", "exception", "is", "thrown", "it", "is", "printed", "to", "stderr", "and", "otherwise", "ignored", "." ]
0eb8d37c5a38cb297cf09361631b93312e0dfa21
https://github.com/pugjs/pug-cli/blob/0eb8d37c5a38cb297cf09361631b93312e0dfa21/index.js#L207-L214
16,478
pugjs/pug-cli
index.js
stdin
function stdin() { var buf = ''; process.stdin.setEncoding('utf8'); process.stdin.on('data', function(chunk){ buf += chunk; }); process.stdin.on('end', function(){ var output; if (options.client) { output = pug.compileClient(buf, options); } else { var fn = pug.compile(buf, options); var output = fn(options); } process.stdout.write(output); }).resume(); }
javascript
function stdin() { var buf = ''; process.stdin.setEncoding('utf8'); process.stdin.on('data', function(chunk){ buf += chunk; }); process.stdin.on('end', function(){ var output; if (options.client) { output = pug.compileClient(buf, options); } else { var fn = pug.compile(buf, options); var output = fn(options); } process.stdout.write(output); }).resume(); }
[ "function", "stdin", "(", ")", "{", "var", "buf", "=", "''", ";", "process", ".", "stdin", ".", "setEncoding", "(", "'utf8'", ")", ";", "process", ".", "stdin", ".", "on", "(", "'data'", ",", "function", "(", "chunk", ")", "{", "buf", "+=", "chunk", ";", "}", ")", ";", "process", ".", "stdin", ".", "on", "(", "'end'", ",", "function", "(", ")", "{", "var", "output", ";", "if", "(", "options", ".", "client", ")", "{", "output", "=", "pug", ".", "compileClient", "(", "buf", ",", "options", ")", ";", "}", "else", "{", "var", "fn", "=", "pug", ".", "compile", "(", "buf", ",", "options", ")", ";", "var", "output", "=", "fn", "(", "options", ")", ";", "}", "process", ".", "stdout", ".", "write", "(", "output", ")", ";", "}", ")", ".", "resume", "(", ")", ";", "}" ]
Compile from stdin.
[ "Compile", "from", "stdin", "." ]
0eb8d37c5a38cb297cf09361631b93312e0dfa21
https://github.com/pugjs/pug-cli/blob/0eb8d37c5a38cb297cf09361631b93312e0dfa21/index.js#L220-L234
16,479
pugjs/pug-cli
index.js
renderFile
function renderFile(path, rootPath) { var isPug = /\.(?:pug|jade)$/; var isIgnored = /([\/\\]_)|(^_)/; var stat = fs.lstatSync(path); // Found pug file if (stat.isFile() && isPug.test(path) && !isIgnored.test(path)) { // Try to watch the file if needed. watchFile takes care of duplicates. if (program.watch) watchFile(path, null, rootPath); if (program.nameAfterFile) { options.name = getNameFromFileName(path); } var fn = options.client ? pug.compileFileClient(path, options) : pug.compileFile(path, options); if (program.watch && fn.dependencies) { // watch dependencies, and recompile the base fn.dependencies.forEach(function (dep) { watchFile(dep, path, rootPath); }); } // --extension var extname; if (program.extension) extname = '.' + program.extension; else if (options.client) extname = '.js'; else if (program.extension === '') extname = ''; else extname = '.html'; // path: foo.pug -> foo.<ext> path = path.replace(isPug, extname); if (program.out) { // prepend output directory if (rootPath) { // replace the rootPath of the resolved path with output directory path = relative(rootPath, path); } else { // if no rootPath handling is needed path = basename(path); } path = resolve(program.out, path); } var dir = resolve(dirname(path)); mkdirp.sync(dir); var output = options.client ? fn : fn(options); fs.writeFileSync(path, output); consoleLog(' ' + chalk.gray('rendered') + ' ' + chalk.cyan('%s'), normalize(path)); // Found directory } else if (stat.isDirectory()) { var files = fs.readdirSync(path); files.map(function(filename) { return path + '/' + filename; }).forEach(function (file) { render(file, rootPath || path); }); } }
javascript
function renderFile(path, rootPath) { var isPug = /\.(?:pug|jade)$/; var isIgnored = /([\/\\]_)|(^_)/; var stat = fs.lstatSync(path); // Found pug file if (stat.isFile() && isPug.test(path) && !isIgnored.test(path)) { // Try to watch the file if needed. watchFile takes care of duplicates. if (program.watch) watchFile(path, null, rootPath); if (program.nameAfterFile) { options.name = getNameFromFileName(path); } var fn = options.client ? pug.compileFileClient(path, options) : pug.compileFile(path, options); if (program.watch && fn.dependencies) { // watch dependencies, and recompile the base fn.dependencies.forEach(function (dep) { watchFile(dep, path, rootPath); }); } // --extension var extname; if (program.extension) extname = '.' + program.extension; else if (options.client) extname = '.js'; else if (program.extension === '') extname = ''; else extname = '.html'; // path: foo.pug -> foo.<ext> path = path.replace(isPug, extname); if (program.out) { // prepend output directory if (rootPath) { // replace the rootPath of the resolved path with output directory path = relative(rootPath, path); } else { // if no rootPath handling is needed path = basename(path); } path = resolve(program.out, path); } var dir = resolve(dirname(path)); mkdirp.sync(dir); var output = options.client ? fn : fn(options); fs.writeFileSync(path, output); consoleLog(' ' + chalk.gray('rendered') + ' ' + chalk.cyan('%s'), normalize(path)); // Found directory } else if (stat.isDirectory()) { var files = fs.readdirSync(path); files.map(function(filename) { return path + '/' + filename; }).forEach(function (file) { render(file, rootPath || path); }); } }
[ "function", "renderFile", "(", "path", ",", "rootPath", ")", "{", "var", "isPug", "=", "/", "\\.(?:pug|jade)$", "/", ";", "var", "isIgnored", "=", "/", "([\\/\\\\]_)|(^_)", "/", ";", "var", "stat", "=", "fs", ".", "lstatSync", "(", "path", ")", ";", "// Found pug file", "if", "(", "stat", ".", "isFile", "(", ")", "&&", "isPug", ".", "test", "(", "path", ")", "&&", "!", "isIgnored", ".", "test", "(", "path", ")", ")", "{", "// Try to watch the file if needed. watchFile takes care of duplicates.", "if", "(", "program", ".", "watch", ")", "watchFile", "(", "path", ",", "null", ",", "rootPath", ")", ";", "if", "(", "program", ".", "nameAfterFile", ")", "{", "options", ".", "name", "=", "getNameFromFileName", "(", "path", ")", ";", "}", "var", "fn", "=", "options", ".", "client", "?", "pug", ".", "compileFileClient", "(", "path", ",", "options", ")", ":", "pug", ".", "compileFile", "(", "path", ",", "options", ")", ";", "if", "(", "program", ".", "watch", "&&", "fn", ".", "dependencies", ")", "{", "// watch dependencies, and recompile the base", "fn", ".", "dependencies", ".", "forEach", "(", "function", "(", "dep", ")", "{", "watchFile", "(", "dep", ",", "path", ",", "rootPath", ")", ";", "}", ")", ";", "}", "// --extension", "var", "extname", ";", "if", "(", "program", ".", "extension", ")", "extname", "=", "'.'", "+", "program", ".", "extension", ";", "else", "if", "(", "options", ".", "client", ")", "extname", "=", "'.js'", ";", "else", "if", "(", "program", ".", "extension", "===", "''", ")", "extname", "=", "''", ";", "else", "extname", "=", "'.html'", ";", "// path: foo.pug -> foo.<ext>", "path", "=", "path", ".", "replace", "(", "isPug", ",", "extname", ")", ";", "if", "(", "program", ".", "out", ")", "{", "// prepend output directory", "if", "(", "rootPath", ")", "{", "// replace the rootPath of the resolved path with output directory", "path", "=", "relative", "(", "rootPath", ",", "path", ")", ";", "}", "else", "{", "// if no rootPath handling is needed", "path", "=", "basename", "(", "path", ")", ";", "}", "path", "=", "resolve", "(", "program", ".", "out", ",", "path", ")", ";", "}", "var", "dir", "=", "resolve", "(", "dirname", "(", "path", ")", ")", ";", "mkdirp", ".", "sync", "(", "dir", ")", ";", "var", "output", "=", "options", ".", "client", "?", "fn", ":", "fn", "(", "options", ")", ";", "fs", ".", "writeFileSync", "(", "path", ",", "output", ")", ";", "consoleLog", "(", "' '", "+", "chalk", ".", "gray", "(", "'rendered'", ")", "+", "' '", "+", "chalk", ".", "cyan", "(", "'%s'", ")", ",", "normalize", "(", "path", ")", ")", ";", "// Found directory", "}", "else", "if", "(", "stat", ".", "isDirectory", "(", ")", ")", "{", "var", "files", "=", "fs", ".", "readdirSync", "(", "path", ")", ";", "files", ".", "map", "(", "function", "(", "filename", ")", "{", "return", "path", "+", "'/'", "+", "filename", ";", "}", ")", ".", "forEach", "(", "function", "(", "file", ")", "{", "render", "(", "file", ",", "rootPath", "||", "path", ")", ";", "}", ")", ";", "}", "}" ]
Process the given path, compiling the pug files found. Always walk the subdirectories. @param path path of the file, might be relative @param rootPath path relative to the directory specified in the command
[ "Process", "the", "given", "path", "compiling", "the", "pug", "files", "found", ".", "Always", "walk", "the", "subdirectories", "." ]
0eb8d37c5a38cb297cf09361631b93312e0dfa21
https://github.com/pugjs/pug-cli/blob/0eb8d37c5a38cb297cf09361631b93312e0dfa21/index.js#L244-L300
16,480
pugjs/pug-cli
index.js
getNameFromFileName
function getNameFromFileName(filename) { var file = basename(filename).replace(/\.(?:pug|jade)$/, ''); return file.toLowerCase().replace(/[^a-z0-9]+([a-z])/g, function (_, character) { return character.toUpperCase(); }) + 'Template'; }
javascript
function getNameFromFileName(filename) { var file = basename(filename).replace(/\.(?:pug|jade)$/, ''); return file.toLowerCase().replace(/[^a-z0-9]+([a-z])/g, function (_, character) { return character.toUpperCase(); }) + 'Template'; }
[ "function", "getNameFromFileName", "(", "filename", ")", "{", "var", "file", "=", "basename", "(", "filename", ")", ".", "replace", "(", "/", "\\.(?:pug|jade)$", "/", ",", "''", ")", ";", "return", "file", ".", "toLowerCase", "(", ")", ".", "replace", "(", "/", "[^a-z0-9]+([a-z])", "/", "g", ",", "function", "(", "_", ",", "character", ")", "{", "return", "character", ".", "toUpperCase", "(", ")", ";", "}", ")", "+", "'Template'", ";", "}" ]
Get a sensible name for a template function from a file path @param {String} filename @returns {String}
[ "Get", "a", "sensible", "name", "for", "a", "template", "function", "from", "a", "file", "path" ]
0eb8d37c5a38cb297cf09361631b93312e0dfa21
https://github.com/pugjs/pug-cli/blob/0eb8d37c5a38cb297cf09361631b93312e0dfa21/index.js#L308-L313
16,481
npm/init-package-json
init-package-json.js
unParsePeople
function unParsePeople (data) { if (data.author) data.author = unParsePerson(data.author) ;["maintainers", "contributors"].forEach(function (set) { if (!Array.isArray(data[set])) return; data[set] = data[set].map(unParsePerson) }) return data }
javascript
function unParsePeople (data) { if (data.author) data.author = unParsePerson(data.author) ;["maintainers", "contributors"].forEach(function (set) { if (!Array.isArray(data[set])) return; data[set] = data[set].map(unParsePerson) }) return data }
[ "function", "unParsePeople", "(", "data", ")", "{", "if", "(", "data", ".", "author", ")", "data", ".", "author", "=", "unParsePerson", "(", "data", ".", "author", ")", ";", "[", "\"maintainers\"", ",", "\"contributors\"", "]", ".", "forEach", "(", "function", "(", "set", ")", "{", "if", "(", "!", "Array", ".", "isArray", "(", "data", "[", "set", "]", ")", ")", "return", ";", "data", "[", "set", "]", "=", "data", "[", "set", "]", ".", "map", "(", "unParsePerson", ")", "}", ")", "return", "data", "}" ]
turn the objects into somewhat more humane strings.
[ "turn", "the", "objects", "into", "somewhat", "more", "humane", "strings", "." ]
2b5d21ea3e3434f8e0d6050cd2733d5062b830c6
https://github.com/npm/init-package-json/blob/2b5d21ea3e3434f8e0d6050cd2733d5062b830c6/init-package-json.js#L136-L143
16,482
dagrejs/graphlib-dot
lib/build-graph.js
collectNodeIds
function collectNodeIds(stmt) { var ids = {}, stack = [], curr; var push = stack.push.bind(stack); push(stmt); while(stack.length) { curr = stack.pop(); switch(curr.type) { case "node": ids[curr.id] = true; break; case "edge": _.each(curr.elems, push); break; case "subgraph": _.each(curr.stmts, push); break; } } return _.keys(ids); }
javascript
function collectNodeIds(stmt) { var ids = {}, stack = [], curr; var push = stack.push.bind(stack); push(stmt); while(stack.length) { curr = stack.pop(); switch(curr.type) { case "node": ids[curr.id] = true; break; case "edge": _.each(curr.elems, push); break; case "subgraph": _.each(curr.stmts, push); break; } } return _.keys(ids); }
[ "function", "collectNodeIds", "(", "stmt", ")", "{", "var", "ids", "=", "{", "}", ",", "stack", "=", "[", "]", ",", "curr", ";", "var", "push", "=", "stack", ".", "push", ".", "bind", "(", "stack", ")", ";", "push", "(", "stmt", ")", ";", "while", "(", "stack", ".", "length", ")", "{", "curr", "=", "stack", ".", "pop", "(", ")", ";", "switch", "(", "curr", ".", "type", ")", "{", "case", "\"node\"", ":", "ids", "[", "curr", ".", "id", "]", "=", "true", ";", "break", ";", "case", "\"edge\"", ":", "_", ".", "each", "(", "curr", ".", "elems", ",", "push", ")", ";", "break", ";", "case", "\"subgraph\"", ":", "_", ".", "each", "(", "curr", ".", "stmts", ",", "push", ")", ";", "break", ";", "}", "}", "return", "_", ".", "keys", "(", "ids", ")", ";", "}" ]
Collect all nodes involved in a subgraph statement
[ "Collect", "all", "nodes", "involved", "in", "a", "subgraph", "statement" ]
dfdc417277fe2c51a551edbb497713113f715949
https://github.com/dagrejs/graphlib-dot/blob/dfdc417277fe2c51a551edbb497713113f715949/lib/build-graph.js#L110-L128
16,483
manuelstofer/json-pointer
index.js
api
function api (obj, pointer, value) { // .set() if (arguments.length === 3) { return api.set(obj, pointer, value); } // .get() if (arguments.length === 2) { return api.get(obj, pointer); } // Return a partially applied function on `obj`. var wrapped = api.bind(api, obj); // Support for oo style for (var name in api) { if (api.hasOwnProperty(name)) { wrapped[name] = api[name].bind(wrapped, obj); } } return wrapped; }
javascript
function api (obj, pointer, value) { // .set() if (arguments.length === 3) { return api.set(obj, pointer, value); } // .get() if (arguments.length === 2) { return api.get(obj, pointer); } // Return a partially applied function on `obj`. var wrapped = api.bind(api, obj); // Support for oo style for (var name in api) { if (api.hasOwnProperty(name)) { wrapped[name] = api[name].bind(wrapped, obj); } } return wrapped; }
[ "function", "api", "(", "obj", ",", "pointer", ",", "value", ")", "{", "// .set()", "if", "(", "arguments", ".", "length", "===", "3", ")", "{", "return", "api", ".", "set", "(", "obj", ",", "pointer", ",", "value", ")", ";", "}", "// .get()", "if", "(", "arguments", ".", "length", "===", "2", ")", "{", "return", "api", ".", "get", "(", "obj", ",", "pointer", ")", ";", "}", "// Return a partially applied function on `obj`.", "var", "wrapped", "=", "api", ".", "bind", "(", "api", ",", "obj", ")", ";", "// Support for oo style", "for", "(", "var", "name", "in", "api", ")", "{", "if", "(", "api", ".", "hasOwnProperty", "(", "name", ")", ")", "{", "wrapped", "[", "name", "]", "=", "api", "[", "name", "]", ".", "bind", "(", "wrapped", ",", "obj", ")", ";", "}", "}", "return", "wrapped", ";", "}" ]
Convenience wrapper around the api. Calls `.get` when called with an `object` and a `pointer`. Calls `.set` when also called with `value`. If only supplied `object`, returns a partially applied function, mapped to the object. @param {Object} obj @param {String|Array} pointer @param value @returns {*}
[ "Convenience", "wrapper", "around", "the", "api", ".", "Calls", ".", "get", "when", "called", "with", "an", "object", "and", "a", "pointer", ".", "Calls", ".", "set", "when", "also", "called", "with", "value", ".", "If", "only", "supplied", "object", "returns", "a", "partially", "applied", "function", "mapped", "to", "the", "object", "." ]
018e48894b5808db371568471952e9968f8bd830
https://github.com/manuelstofer/json-pointer/blob/018e48894b5808db371568471952e9968f8bd830/index.js#L19-L38
16,484
lukeed/taskr
packages/taskr/lib/plugins.js
getDependencies
function getDependencies(pkg) { if (!pkg) { return []; } if (!isObject(pkg)) { $.error('Content from `package.json` must be an `Object`!'); return []; } // get all possible dependencies const deps = [ 'dependencies', 'devDependencies', 'peerDependencies' ].filter(key => pkg[key] !== void 0).map(k => Object.keys(pkg[k])); return flatten(deps); }
javascript
function getDependencies(pkg) { if (!pkg) { return []; } if (!isObject(pkg)) { $.error('Content from `package.json` must be an `Object`!'); return []; } // get all possible dependencies const deps = [ 'dependencies', 'devDependencies', 'peerDependencies' ].filter(key => pkg[key] !== void 0).map(k => Object.keys(pkg[k])); return flatten(deps); }
[ "function", "getDependencies", "(", "pkg", ")", "{", "if", "(", "!", "pkg", ")", "{", "return", "[", "]", ";", "}", "if", "(", "!", "isObject", "(", "pkg", ")", ")", "{", "$", ".", "error", "(", "'Content from `package.json` must be an `Object`!'", ")", ";", "return", "[", "]", ";", "}", "// get all possible dependencies", "const", "deps", "=", "[", "'dependencies'", ",", "'devDependencies'", ",", "'peerDependencies'", "]", ".", "filter", "(", "key", "=>", "pkg", "[", "key", "]", "!==", "void", "0", ")", ".", "map", "(", "k", "=>", "Object", ".", "keys", "(", "pkg", "[", "k", "]", ")", ")", ";", "return", "flatten", "(", "deps", ")", ";", "}" ]
Find a sibling `package.json` file & return its contents. @param {Object} file A `package.json` contents as JSON @return {Array} The names of all dependencies, flattened
[ "Find", "a", "sibling", "package", ".", "json", "file", "&", "return", "its", "contents", "." ]
82d0bef537c598d32ef425af7eef7cee3cf59a5f
https://github.com/lukeed/taskr/blob/82d0bef537c598d32ef425af7eef7cee3cf59a5f/packages/taskr/lib/plugins.js#L38-L54
16,485
cgewecke/eth-gas-reporter
gasStats.js
gasToCost
function gasToCost (gas, ethPrice, gasPrice) { ethPrice = parseFloat(ethPrice) gasPrice = parseInt(gasPrice) return ((gasPrice / 1e9) * gas * ethPrice).toFixed(2) }
javascript
function gasToCost (gas, ethPrice, gasPrice) { ethPrice = parseFloat(ethPrice) gasPrice = parseInt(gasPrice) return ((gasPrice / 1e9) * gas * ethPrice).toFixed(2) }
[ "function", "gasToCost", "(", "gas", ",", "ethPrice", ",", "gasPrice", ")", "{", "ethPrice", "=", "parseFloat", "(", "ethPrice", ")", "gasPrice", "=", "parseInt", "(", "gasPrice", ")", "return", "(", "(", "gasPrice", "/", "1e9", ")", "*", "gas", "*", "ethPrice", ")", ".", "toFixed", "(", "2", ")", "}" ]
Expresses gas usage as a nation-state currency price @param {Number} gas gas used @param {Number} ethPrice e.g chf/eth @param {Number} gasPrice in wei e.g 5000000000 (5 gwei) @return {Number} cost of gas used (0.00)
[ "Expresses", "gas", "usage", "as", "a", "nation", "-", "state", "currency", "price" ]
cb2f540dbf00e3d1ac7871467eb628f05e8d8e90
https://github.com/cgewecke/eth-gas-reporter/blob/cb2f540dbf00e3d1ac7871467eb628f05e8d8e90/gasStats.js#L43-L47
16,486
cgewecke/eth-gas-reporter
gasStats.js
matchBinaries
function matchBinaries (input, binary) { const regExp = bytecodeToBytecodeRegex(binary); return (input.match(regExp) !== null); }
javascript
function matchBinaries (input, binary) { const regExp = bytecodeToBytecodeRegex(binary); return (input.match(regExp) !== null); }
[ "function", "matchBinaries", "(", "input", ",", "binary", ")", "{", "const", "regExp", "=", "bytecodeToBytecodeRegex", "(", "binary", ")", ";", "return", "(", "input", ".", "match", "(", "regExp", ")", "!==", "null", ")", ";", "}" ]
Return true if transaction input and binary are same, ignoring library link code. @param {String} code @return {Bool}
[ "Return", "true", "if", "transaction", "input", "and", "binary", "are", "same", "ignoring", "library", "link", "code", "." ]
cb2f540dbf00e3d1ac7871467eb628f05e8d8e90
https://github.com/cgewecke/eth-gas-reporter/blob/cb2f540dbf00e3d1ac7871467eb628f05e8d8e90/gasStats.js#L73-L76
16,487
cgewecke/eth-gas-reporter
gasStats.js
getContractNames
function getContractNames(filePath){ const names = []; const code = fs.readFileSync(filePath, 'utf-8'); const ast = parser.parse(code, {tolerant: true}); parser.visit(ast, { ContractDefinition: function(node) { names.push(node.name); } }); return names; }
javascript
function getContractNames(filePath){ const names = []; const code = fs.readFileSync(filePath, 'utf-8'); const ast = parser.parse(code, {tolerant: true}); parser.visit(ast, { ContractDefinition: function(node) { names.push(node.name); } }); return names; }
[ "function", "getContractNames", "(", "filePath", ")", "{", "const", "names", "=", "[", "]", ";", "const", "code", "=", "fs", ".", "readFileSync", "(", "filePath", ",", "'utf-8'", ")", ";", "const", "ast", "=", "parser", ".", "parse", "(", "code", ",", "{", "tolerant", ":", "true", "}", ")", ";", "parser", ".", "visit", "(", "ast", ",", "{", "ContractDefinition", ":", "function", "(", "node", ")", "{", "names", ".", "push", "(", "node", ".", "name", ")", ";", "}", "}", ")", ";", "return", "names", ";", "}" ]
Parses files for contract names @param {String} filePath path to file @return {Array} array of contract names
[ "Parses", "files", "for", "contract", "names" ]
cb2f540dbf00e3d1ac7871467eb628f05e8d8e90
https://github.com/cgewecke/eth-gas-reporter/blob/cb2f540dbf00e3d1ac7871467eb628f05e8d8e90/gasStats.js#L307-L319
16,488
jshttp/type-is
index.js
typeis
function typeis (value, types_) { var i var types = types_ // remove parameters and normalize var val = tryNormalizeType(value) // no type or invalid if (!val) { return false } // support flattened arguments if (types && !Array.isArray(types)) { types = new Array(arguments.length - 1) for (i = 0; i < types.length; i++) { types[i] = arguments[i + 1] } } // no types, return the content type if (!types || !types.length) { return val } var type for (i = 0; i < types.length; i++) { if (mimeMatch(normalize(type = types[i]), val)) { return type[0] === '+' || type.indexOf('*') !== -1 ? val : type } } // no matches return false }
javascript
function typeis (value, types_) { var i var types = types_ // remove parameters and normalize var val = tryNormalizeType(value) // no type or invalid if (!val) { return false } // support flattened arguments if (types && !Array.isArray(types)) { types = new Array(arguments.length - 1) for (i = 0; i < types.length; i++) { types[i] = arguments[i + 1] } } // no types, return the content type if (!types || !types.length) { return val } var type for (i = 0; i < types.length; i++) { if (mimeMatch(normalize(type = types[i]), val)) { return type[0] === '+' || type.indexOf('*') !== -1 ? val : type } } // no matches return false }
[ "function", "typeis", "(", "value", ",", "types_", ")", "{", "var", "i", "var", "types", "=", "types_", "// remove parameters and normalize", "var", "val", "=", "tryNormalizeType", "(", "value", ")", "// no type or invalid", "if", "(", "!", "val", ")", "{", "return", "false", "}", "// support flattened arguments", "if", "(", "types", "&&", "!", "Array", ".", "isArray", "(", "types", ")", ")", "{", "types", "=", "new", "Array", "(", "arguments", ".", "length", "-", "1", ")", "for", "(", "i", "=", "0", ";", "i", "<", "types", ".", "length", ";", "i", "++", ")", "{", "types", "[", "i", "]", "=", "arguments", "[", "i", "+", "1", "]", "}", "}", "// no types, return the content type", "if", "(", "!", "types", "||", "!", "types", ".", "length", ")", "{", "return", "val", "}", "var", "type", "for", "(", "i", "=", "0", ";", "i", "<", "types", ".", "length", ";", "i", "++", ")", "{", "if", "(", "mimeMatch", "(", "normalize", "(", "type", "=", "types", "[", "i", "]", ")", ",", "val", ")", ")", "{", "return", "type", "[", "0", "]", "===", "'+'", "||", "type", ".", "indexOf", "(", "'*'", ")", "!==", "-", "1", "?", "val", ":", "type", "}", "}", "// no matches", "return", "false", "}" ]
Compare a `value` content-type with `types`. Each `type` can be an extension like `html`, a special shortcut like `multipart` or `urlencoded`, or a mime type. If no types match, `false` is returned. Otherwise, the first `type` that matches is returned. @param {String} value @param {Array} types @public
[ "Compare", "a", "value", "content", "-", "type", "with", "types", ".", "Each", "type", "can", "be", "an", "extension", "like", "html", "a", "special", "shortcut", "like", "multipart", "or", "urlencoded", "or", "a", "mime", "type", "." ]
bfebe3d4ac312debccb7dbbc79242e2581dea5f0
https://github.com/jshttp/type-is/blob/bfebe3d4ac312debccb7dbbc79242e2581dea5f0/index.js#L43-L79
16,489
jshttp/type-is
index.js
typeofrequest
function typeofrequest (req, types_) { var types = types_ // no body if (!hasbody(req)) { return null } // support flattened arguments if (arguments.length > 2) { types = new Array(arguments.length - 1) for (var i = 0; i < types.length; i++) { types[i] = arguments[i + 1] } } // request content type var value = req.headers['content-type'] return typeis(value, types) }
javascript
function typeofrequest (req, types_) { var types = types_ // no body if (!hasbody(req)) { return null } // support flattened arguments if (arguments.length > 2) { types = new Array(arguments.length - 1) for (var i = 0; i < types.length; i++) { types[i] = arguments[i + 1] } } // request content type var value = req.headers['content-type'] return typeis(value, types) }
[ "function", "typeofrequest", "(", "req", ",", "types_", ")", "{", "var", "types", "=", "types_", "// no body", "if", "(", "!", "hasbody", "(", "req", ")", ")", "{", "return", "null", "}", "// support flattened arguments", "if", "(", "arguments", ".", "length", ">", "2", ")", "{", "types", "=", "new", "Array", "(", "arguments", ".", "length", "-", "1", ")", "for", "(", "var", "i", "=", "0", ";", "i", "<", "types", ".", "length", ";", "i", "++", ")", "{", "types", "[", "i", "]", "=", "arguments", "[", "i", "+", "1", "]", "}", "}", "// request content type", "var", "value", "=", "req", ".", "headers", "[", "'content-type'", "]", "return", "typeis", "(", "value", ",", "types", ")", "}" ]
Check if the incoming request contains the "Content-Type" header field, and it contains any of the give mime `type`s. If there is no request body, `null` is returned. If there is no content type, `false` is returned. Otherwise, it returns the first `type` that matches. Examples: // With Content-Type: text/html; charset=utf-8 this.is('html'); // => 'html' this.is('text/html'); // => 'text/html' this.is('text/*', 'application/json'); // => 'text/html' // When Content-Type is application/json this.is('json', 'urlencoded'); // => 'json' this.is('application/json'); // => 'application/json' this.is('html', 'application/*'); // => 'application/json' this.is('html'); // => false @param {String|Array} types... @return {String|false|null} @public
[ "Check", "if", "the", "incoming", "request", "contains", "the", "Content", "-", "Type", "header", "field", "and", "it", "contains", "any", "of", "the", "give", "mime", "type", "s", ".", "If", "there", "is", "no", "request", "body", "null", "is", "returned", ".", "If", "there", "is", "no", "content", "type", "false", "is", "returned", ".", "Otherwise", "it", "returns", "the", "first", "type", "that", "matches", "." ]
bfebe3d4ac312debccb7dbbc79242e2581dea5f0
https://github.com/jshttp/type-is/blob/bfebe3d4ac312debccb7dbbc79242e2581dea5f0/index.js#L123-L143
16,490
jshttp/type-is
index.js
normalize
function normalize (type) { if (typeof type !== 'string') { // invalid type return false } switch (type) { case 'urlencoded': return 'application/x-www-form-urlencoded' case 'multipart': return 'multipart/*' } if (type[0] === '+') { // "+json" -> "*/*+json" expando return '*/*' + type } return type.indexOf('/') === -1 ? mime.lookup(type) : type }
javascript
function normalize (type) { if (typeof type !== 'string') { // invalid type return false } switch (type) { case 'urlencoded': return 'application/x-www-form-urlencoded' case 'multipart': return 'multipart/*' } if (type[0] === '+') { // "+json" -> "*/*+json" expando return '*/*' + type } return type.indexOf('/') === -1 ? mime.lookup(type) : type }
[ "function", "normalize", "(", "type", ")", "{", "if", "(", "typeof", "type", "!==", "'string'", ")", "{", "// invalid type", "return", "false", "}", "switch", "(", "type", ")", "{", "case", "'urlencoded'", ":", "return", "'application/x-www-form-urlencoded'", "case", "'multipart'", ":", "return", "'multipart/*'", "}", "if", "(", "type", "[", "0", "]", "===", "'+'", ")", "{", "// \"+json\" -> \"*/*+json\" expando", "return", "'*/*'", "+", "type", "}", "return", "type", ".", "indexOf", "(", "'/'", ")", "===", "-", "1", "?", "mime", ".", "lookup", "(", "type", ")", ":", "type", "}" ]
Normalize a mime type. If it's a shorthand, expand it to a valid mime type. In general, you probably want: var type = is(req, ['urlencoded', 'json', 'multipart']); Then use the appropriate body parsers. These three are the most common request body types and are thus ensured to work. @param {String} type @private
[ "Normalize", "a", "mime", "type", ".", "If", "it", "s", "a", "shorthand", "expand", "it", "to", "a", "valid", "mime", "type", "." ]
bfebe3d4ac312debccb7dbbc79242e2581dea5f0
https://github.com/jshttp/type-is/blob/bfebe3d4ac312debccb7dbbc79242e2581dea5f0/index.js#L161-L182
16,491
jshttp/type-is
index.js
mimeMatch
function mimeMatch (expected, actual) { // invalid type if (expected === false) { return false } // split types var actualParts = actual.split('/') var expectedParts = expected.split('/') // invalid format if (actualParts.length !== 2 || expectedParts.length !== 2) { return false } // validate type if (expectedParts[0] !== '*' && expectedParts[0] !== actualParts[0]) { return false } // validate suffix wildcard if (expectedParts[1].substr(0, 2) === '*+') { return expectedParts[1].length <= actualParts[1].length + 1 && expectedParts[1].substr(1) === actualParts[1].substr(1 - expectedParts[1].length) } // validate subtype if (expectedParts[1] !== '*' && expectedParts[1] !== actualParts[1]) { return false } return true }
javascript
function mimeMatch (expected, actual) { // invalid type if (expected === false) { return false } // split types var actualParts = actual.split('/') var expectedParts = expected.split('/') // invalid format if (actualParts.length !== 2 || expectedParts.length !== 2) { return false } // validate type if (expectedParts[0] !== '*' && expectedParts[0] !== actualParts[0]) { return false } // validate suffix wildcard if (expectedParts[1].substr(0, 2) === '*+') { return expectedParts[1].length <= actualParts[1].length + 1 && expectedParts[1].substr(1) === actualParts[1].substr(1 - expectedParts[1].length) } // validate subtype if (expectedParts[1] !== '*' && expectedParts[1] !== actualParts[1]) { return false } return true }
[ "function", "mimeMatch", "(", "expected", ",", "actual", ")", "{", "// invalid type", "if", "(", "expected", "===", "false", ")", "{", "return", "false", "}", "// split types", "var", "actualParts", "=", "actual", ".", "split", "(", "'/'", ")", "var", "expectedParts", "=", "expected", ".", "split", "(", "'/'", ")", "// invalid format", "if", "(", "actualParts", ".", "length", "!==", "2", "||", "expectedParts", ".", "length", "!==", "2", ")", "{", "return", "false", "}", "// validate type", "if", "(", "expectedParts", "[", "0", "]", "!==", "'*'", "&&", "expectedParts", "[", "0", "]", "!==", "actualParts", "[", "0", "]", ")", "{", "return", "false", "}", "// validate suffix wildcard", "if", "(", "expectedParts", "[", "1", "]", ".", "substr", "(", "0", ",", "2", ")", "===", "'*+'", ")", "{", "return", "expectedParts", "[", "1", "]", ".", "length", "<=", "actualParts", "[", "1", "]", ".", "length", "+", "1", "&&", "expectedParts", "[", "1", "]", ".", "substr", "(", "1", ")", "===", "actualParts", "[", "1", "]", ".", "substr", "(", "1", "-", "expectedParts", "[", "1", "]", ".", "length", ")", "}", "// validate subtype", "if", "(", "expectedParts", "[", "1", "]", "!==", "'*'", "&&", "expectedParts", "[", "1", "]", "!==", "actualParts", "[", "1", "]", ")", "{", "return", "false", "}", "return", "true", "}" ]
Check if `expected` mime type matches `actual` mime type with wildcard and +suffix support. @param {String} expected @param {String} actual @return {Boolean} @private
[ "Check", "if", "expected", "mime", "type", "matches", "actual", "mime", "type", "with", "wildcard", "and", "+", "suffix", "support", "." ]
bfebe3d4ac312debccb7dbbc79242e2581dea5f0
https://github.com/jshttp/type-is/blob/bfebe3d4ac312debccb7dbbc79242e2581dea5f0/index.js#L195-L227
16,492
jshttp/type-is
index.js
normalizeType
function normalizeType (value) { // parse the type var type = typer.parse(value) // remove the parameters type.parameters = undefined // reformat it return typer.format(type) }
javascript
function normalizeType (value) { // parse the type var type = typer.parse(value) // remove the parameters type.parameters = undefined // reformat it return typer.format(type) }
[ "function", "normalizeType", "(", "value", ")", "{", "// parse the type", "var", "type", "=", "typer", ".", "parse", "(", "value", ")", "// remove the parameters", "type", ".", "parameters", "=", "undefined", "// reformat it", "return", "typer", ".", "format", "(", "type", ")", "}" ]
Normalize a type and remove parameters. @param {string} value @return {string} @private
[ "Normalize", "a", "type", "and", "remove", "parameters", "." ]
bfebe3d4ac312debccb7dbbc79242e2581dea5f0
https://github.com/jshttp/type-is/blob/bfebe3d4ac312debccb7dbbc79242e2581dea5f0/index.js#L237-L246
16,493
adametry/gulp-eslint
util.js
isErrorMessage
function isErrorMessage(message) { const level = message.fatal ? 2 : message.severity; if (Array.isArray(level)) { return level[0] > 1; } return level > 1; }
javascript
function isErrorMessage(message) { const level = message.fatal ? 2 : message.severity; if (Array.isArray(level)) { return level[0] > 1; } return level > 1; }
[ "function", "isErrorMessage", "(", "message", ")", "{", "const", "level", "=", "message", ".", "fatal", "?", "2", ":", "message", ".", "severity", ";", "if", "(", "Array", ".", "isArray", "(", "level", ")", ")", "{", "return", "level", "[", "0", "]", ">", "1", ";", "}", "return", "level", ">", "1", ";", "}" ]
Determine if a message is an error @param {Object} message - an ESLint message @returns {Boolean} whether the message is an error message
[ "Determine", "if", "a", "message", "is", "an", "error" ]
40d004fa2f48325f6a507cb10072ff6667aeaf41
https://github.com/adametry/gulp-eslint/blob/40d004fa2f48325f6a507cb10072ff6667aeaf41/util.js#L131-L139
16,494
adametry/gulp-eslint
util.js
countFixableErrorMessage
function countFixableErrorMessage(count, message) { return count + Number(isErrorMessage(message) && message.fix !== undefined); }
javascript
function countFixableErrorMessage(count, message) { return count + Number(isErrorMessage(message) && message.fix !== undefined); }
[ "function", "countFixableErrorMessage", "(", "count", ",", "message", ")", "{", "return", "count", "+", "Number", "(", "isErrorMessage", "(", "message", ")", "&&", "message", ".", "fix", "!==", "undefined", ")", ";", "}" ]
Increment count if message is a fixable error @param {Number} count - count of errors @param {Object} message - an ESLint message @returns {Number} The number of errors, message included
[ "Increment", "count", "if", "message", "is", "a", "fixable", "error" ]
40d004fa2f48325f6a507cb10072ff6667aeaf41
https://github.com/adametry/gulp-eslint/blob/40d004fa2f48325f6a507cb10072ff6667aeaf41/util.js#L171-L173
16,495
adametry/gulp-eslint
util.js
countFixableWarningMessage
function countFixableWarningMessage(count, message) { return count + Number(message.severity === 1 && message.fix !== undefined); }
javascript
function countFixableWarningMessage(count, message) { return count + Number(message.severity === 1 && message.fix !== undefined); }
[ "function", "countFixableWarningMessage", "(", "count", ",", "message", ")", "{", "return", "count", "+", "Number", "(", "message", ".", "severity", "===", "1", "&&", "message", ".", "fix", "!==", "undefined", ")", ";", "}" ]
Increment count if message is a fixable warning @param {Number} count - count of errors @param {Object} message - an ESLint message @returns {Number} The number of errors, message included
[ "Increment", "count", "if", "message", "is", "a", "fixable", "warning" ]
40d004fa2f48325f6a507cb10072ff6667aeaf41
https://github.com/adametry/gulp-eslint/blob/40d004fa2f48325f6a507cb10072ff6667aeaf41/util.js#L182-L184
16,496
adametry/gulp-eslint
index.js
gulpEslint
function gulpEslint(options) { options = migrateOptions(options) || {}; const linter = new CLIEngine(options); return transform((file, enc, cb) => { const filePath = relative(process.cwd(), file.path); if (file.isNull()) { cb(null, file); return; } if (file.isStream()) { cb(new PluginError('gulp-eslint', 'gulp-eslint doesn\'t support vinyl files with Stream contents.')); return; } if (linter.isPathIgnored(filePath)) { // Note: // Vinyl files can have an independently defined cwd, but ESLint works relative to `process.cwd()`. // (https://github.com/gulpjs/gulp/blob/master/docs/recipes/specifying-a-cwd.md) // Also, ESLint doesn't adjust file paths relative to an ancestory .eslintignore path. // E.g., If ../.eslintignore has "foo/*.js", ESLint will ignore ./foo/*.js, instead of ../foo/*.js. // Eslint rolls this into `CLIEngine.executeOnText`. So, gulp-eslint must account for this limitation. if (linter.options.ignore && options.warnFileIgnored) { // Warn that gulp.src is needlessly reading files that ESLint ignores file.eslint = createIgnoreResult(file); } cb(null, file); return; } let result; try { result = linter.executeOnText(file.contents.toString(), filePath).results[0]; } catch (e) { cb(new PluginError('gulp-eslint', e)); return; } // Note: Fixes are applied as part of "executeOnText". // Any applied fix messages have been removed from the result. if (options.quiet) { // ignore warnings file.eslint = filterResult(result, options.quiet); } else { file.eslint = result; } // Update the fixed output; otherwise, fixable messages are simply ignored. if (file.eslint.hasOwnProperty('output')) { file.contents = Buffer.from(file.eslint.output); file.eslint.fixed = true; } cb(null, file); }); }
javascript
function gulpEslint(options) { options = migrateOptions(options) || {}; const linter = new CLIEngine(options); return transform((file, enc, cb) => { const filePath = relative(process.cwd(), file.path); if (file.isNull()) { cb(null, file); return; } if (file.isStream()) { cb(new PluginError('gulp-eslint', 'gulp-eslint doesn\'t support vinyl files with Stream contents.')); return; } if (linter.isPathIgnored(filePath)) { // Note: // Vinyl files can have an independently defined cwd, but ESLint works relative to `process.cwd()`. // (https://github.com/gulpjs/gulp/blob/master/docs/recipes/specifying-a-cwd.md) // Also, ESLint doesn't adjust file paths relative to an ancestory .eslintignore path. // E.g., If ../.eslintignore has "foo/*.js", ESLint will ignore ./foo/*.js, instead of ../foo/*.js. // Eslint rolls this into `CLIEngine.executeOnText`. So, gulp-eslint must account for this limitation. if (linter.options.ignore && options.warnFileIgnored) { // Warn that gulp.src is needlessly reading files that ESLint ignores file.eslint = createIgnoreResult(file); } cb(null, file); return; } let result; try { result = linter.executeOnText(file.contents.toString(), filePath).results[0]; } catch (e) { cb(new PluginError('gulp-eslint', e)); return; } // Note: Fixes are applied as part of "executeOnText". // Any applied fix messages have been removed from the result. if (options.quiet) { // ignore warnings file.eslint = filterResult(result, options.quiet); } else { file.eslint = result; } // Update the fixed output; otherwise, fixable messages are simply ignored. if (file.eslint.hasOwnProperty('output')) { file.contents = Buffer.from(file.eslint.output); file.eslint.fixed = true; } cb(null, file); }); }
[ "function", "gulpEslint", "(", "options", ")", "{", "options", "=", "migrateOptions", "(", "options", ")", "||", "{", "}", ";", "const", "linter", "=", "new", "CLIEngine", "(", "options", ")", ";", "return", "transform", "(", "(", "file", ",", "enc", ",", "cb", ")", "=>", "{", "const", "filePath", "=", "relative", "(", "process", ".", "cwd", "(", ")", ",", "file", ".", "path", ")", ";", "if", "(", "file", ".", "isNull", "(", ")", ")", "{", "cb", "(", "null", ",", "file", ")", ";", "return", ";", "}", "if", "(", "file", ".", "isStream", "(", ")", ")", "{", "cb", "(", "new", "PluginError", "(", "'gulp-eslint'", ",", "'gulp-eslint doesn\\'t support vinyl files with Stream contents.'", ")", ")", ";", "return", ";", "}", "if", "(", "linter", ".", "isPathIgnored", "(", "filePath", ")", ")", "{", "// Note:", "// Vinyl files can have an independently defined cwd, but ESLint works relative to `process.cwd()`.", "// (https://github.com/gulpjs/gulp/blob/master/docs/recipes/specifying-a-cwd.md)", "// Also, ESLint doesn't adjust file paths relative to an ancestory .eslintignore path.", "// E.g., If ../.eslintignore has \"foo/*.js\", ESLint will ignore ./foo/*.js, instead of ../foo/*.js.", "// Eslint rolls this into `CLIEngine.executeOnText`. So, gulp-eslint must account for this limitation.", "if", "(", "linter", ".", "options", ".", "ignore", "&&", "options", ".", "warnFileIgnored", ")", "{", "// Warn that gulp.src is needlessly reading files that ESLint ignores", "file", ".", "eslint", "=", "createIgnoreResult", "(", "file", ")", ";", "}", "cb", "(", "null", ",", "file", ")", ";", "return", ";", "}", "let", "result", ";", "try", "{", "result", "=", "linter", ".", "executeOnText", "(", "file", ".", "contents", ".", "toString", "(", ")", ",", "filePath", ")", ".", "results", "[", "0", "]", ";", "}", "catch", "(", "e", ")", "{", "cb", "(", "new", "PluginError", "(", "'gulp-eslint'", ",", "e", ")", ")", ";", "return", ";", "}", "// Note: Fixes are applied as part of \"executeOnText\".", "// Any applied fix messages have been removed from the result.", "if", "(", "options", ".", "quiet", ")", "{", "// ignore warnings", "file", ".", "eslint", "=", "filterResult", "(", "result", ",", "options", ".", "quiet", ")", ";", "}", "else", "{", "file", ".", "eslint", "=", "result", ";", "}", "// Update the fixed output; otherwise, fixable messages are simply ignored.", "if", "(", "file", ".", "eslint", ".", "hasOwnProperty", "(", "'output'", ")", ")", "{", "file", ".", "contents", "=", "Buffer", ".", "from", "(", "file", ".", "eslint", ".", "output", ")", ";", "file", ".", "eslint", ".", "fixed", "=", "true", ";", "}", "cb", "(", "null", ",", "file", ")", ";", "}", ")", ";", "}" ]
Append ESLint result to each file @param {(Object|String)} [options] - Configure rules, env, global, and other options for running ESLint @returns {stream} gulp file stream
[ "Append", "ESLint", "result", "to", "each", "file" ]
40d004fa2f48325f6a507cb10072ff6667aeaf41
https://github.com/adametry/gulp-eslint/blob/40d004fa2f48325f6a507cb10072ff6667aeaf41/index.js#L26-L84
16,497
bitovi/syn
src/drag.js
function(focusWindow, fromPoint, toPoint, duration, callback){ this.currentDataTransferItem = null; this.focusWindow = focusWindow; // A series of events to simulate a drag operation this._mouseOver(fromPoint); this._mouseEnter(fromPoint); this._mouseMove(fromPoint); this._mouseDown(fromPoint); this._dragStart(fromPoint); this._drag(fromPoint); this._dragEnter(fromPoint); this._dragOver(fromPoint); DragonDrop.startMove(fromPoint, toPoint, duration, function () { // this happens later DragonDrop._dragLeave(fromPoint); DragonDrop._dragEnd(fromPoint); DragonDrop._mouseOut(fromPoint); DragonDrop._mouseLeave(fromPoint); DragonDrop._drop(toPoint); DragonDrop._dragEnd(toPoint); DragonDrop._mouseOver(toPoint); DragonDrop._mouseEnter(toPoint); // these are the "user" moving the mouse away after the drop DragonDrop._mouseMove(toPoint); DragonDrop._mouseOut(toPoint); DragonDrop._mouseLeave(toPoint); callback(); DragonDrop.cleanup(); }); }
javascript
function(focusWindow, fromPoint, toPoint, duration, callback){ this.currentDataTransferItem = null; this.focusWindow = focusWindow; // A series of events to simulate a drag operation this._mouseOver(fromPoint); this._mouseEnter(fromPoint); this._mouseMove(fromPoint); this._mouseDown(fromPoint); this._dragStart(fromPoint); this._drag(fromPoint); this._dragEnter(fromPoint); this._dragOver(fromPoint); DragonDrop.startMove(fromPoint, toPoint, duration, function () { // this happens later DragonDrop._dragLeave(fromPoint); DragonDrop._dragEnd(fromPoint); DragonDrop._mouseOut(fromPoint); DragonDrop._mouseLeave(fromPoint); DragonDrop._drop(toPoint); DragonDrop._dragEnd(toPoint); DragonDrop._mouseOver(toPoint); DragonDrop._mouseEnter(toPoint); // these are the "user" moving the mouse away after the drop DragonDrop._mouseMove(toPoint); DragonDrop._mouseOut(toPoint); DragonDrop._mouseLeave(toPoint); callback(); DragonDrop.cleanup(); }); }
[ "function", "(", "focusWindow", ",", "fromPoint", ",", "toPoint", ",", "duration", ",", "callback", ")", "{", "this", ".", "currentDataTransferItem", "=", "null", ";", "this", ".", "focusWindow", "=", "focusWindow", ";", "// A series of events to simulate a drag operation", "this", ".", "_mouseOver", "(", "fromPoint", ")", ";", "this", ".", "_mouseEnter", "(", "fromPoint", ")", ";", "this", ".", "_mouseMove", "(", "fromPoint", ")", ";", "this", ".", "_mouseDown", "(", "fromPoint", ")", ";", "this", ".", "_dragStart", "(", "fromPoint", ")", ";", "this", ".", "_drag", "(", "fromPoint", ")", ";", "this", ".", "_dragEnter", "(", "fromPoint", ")", ";", "this", ".", "_dragOver", "(", "fromPoint", ")", ";", "DragonDrop", ".", "startMove", "(", "fromPoint", ",", "toPoint", ",", "duration", ",", "function", "(", ")", "{", "// this happens later", "DragonDrop", ".", "_dragLeave", "(", "fromPoint", ")", ";", "DragonDrop", ".", "_dragEnd", "(", "fromPoint", ")", ";", "DragonDrop", ".", "_mouseOut", "(", "fromPoint", ")", ";", "DragonDrop", ".", "_mouseLeave", "(", "fromPoint", ")", ";", "DragonDrop", ".", "_drop", "(", "toPoint", ")", ";", "DragonDrop", ".", "_dragEnd", "(", "toPoint", ")", ";", "DragonDrop", ".", "_mouseOver", "(", "toPoint", ")", ";", "DragonDrop", ".", "_mouseEnter", "(", "toPoint", ")", ";", "// these are the \"user\" moving the mouse away after the drop", "DragonDrop", ".", "_mouseMove", "(", "toPoint", ")", ";", "DragonDrop", ".", "_mouseOut", "(", "toPoint", ")", ";", "DragonDrop", ".", "_mouseLeave", "(", "toPoint", ")", ";", "callback", "(", ")", ";", "DragonDrop", ".", "cleanup", "(", ")", ";", "}", ")", ";", "}" ]
Performs a series of dragStart, dragEnter, dragOver and drop operations to simulate a dragDrop @param fromElement: element from where drag is started @param channel: destination element for drop
[ "Performs", "a", "series", "of", "dragStart", "dragEnter", "dragOver", "and", "drop", "operations", "to", "simulate", "a", "dragDrop" ]
f04e87b18bee9b4308838db04682d3ce2b98afaa
https://github.com/bitovi/syn/blob/f04e87b18bee9b4308838db04682d3ce2b98afaa/src/drag.js#L47-L86
16,498
bitovi/syn
src/drag.js
function(point, eventName, options){ if (point){ var targetElement = elementFromPoint(point, this.focusWindow); syn.trigger(targetElement, eventName, options); } }
javascript
function(point, eventName, options){ if (point){ var targetElement = elementFromPoint(point, this.focusWindow); syn.trigger(targetElement, eventName, options); } }
[ "function", "(", "point", ",", "eventName", ",", "options", ")", "{", "if", "(", "point", ")", "{", "var", "targetElement", "=", "elementFromPoint", "(", "point", ",", "this", ".", "focusWindow", ")", ";", "syn", ".", "trigger", "(", "targetElement", ",", "eventName", ",", "options", ")", ";", "}", "}" ]
Creates and dispatches an event on the node received @param node @param eventName
[ "Creates", "and", "dispatches", "an", "event", "on", "the", "node", "received" ]
f04e87b18bee9b4308838db04682d3ce2b98afaa
https://github.com/bitovi/syn/blob/f04e87b18bee9b4308838db04682d3ce2b98afaa/src/drag.js#L138-L143
16,499
bitovi/syn
src/drag.js
function(dataFlavor, value){ var tempdata = {}; tempdata.dataFlavor = dataFlavor; tempdata.val = value; this.data.push(tempdata); }
javascript
function(dataFlavor, value){ var tempdata = {}; tempdata.dataFlavor = dataFlavor; tempdata.val = value; this.data.push(tempdata); }
[ "function", "(", "dataFlavor", ",", "value", ")", "{", "var", "tempdata", "=", "{", "}", ";", "tempdata", ".", "dataFlavor", "=", "dataFlavor", ";", "tempdata", ".", "val", "=", "value", ";", "this", ".", "data", ".", "push", "(", "tempdata", ")", ";", "}" ]
setData function assigns the dragValue to an object's property
[ "setData", "function", "assigns", "the", "dragValue", "to", "an", "object", "s", "property" ]
f04e87b18bee9b4308838db04682d3ce2b98afaa
https://github.com/bitovi/syn/blob/f04e87b18bee9b4308838db04682d3ce2b98afaa/src/drag.js#L176-L181