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,700
|
box/t3js
|
lib/application.js
|
function(data) {
if (globalConfig.debug) {
// We grab console via getGlobal() so we can stub it out in tests
var globalConsole = this.getGlobal('console');
if (globalConsole && globalConsole.warn) {
globalConsole.warn(data);
}
} else {
application.fire('warning', data);
}
}
|
javascript
|
function(data) {
if (globalConfig.debug) {
// We grab console via getGlobal() so we can stub it out in tests
var globalConsole = this.getGlobal('console');
if (globalConsole && globalConsole.warn) {
globalConsole.warn(data);
}
} else {
application.fire('warning', data);
}
}
|
[
"function",
"(",
"data",
")",
"{",
"if",
"(",
"globalConfig",
".",
"debug",
")",
"{",
"// We grab console via getGlobal() so we can stub it out in tests",
"var",
"globalConsole",
"=",
"this",
".",
"getGlobal",
"(",
"'console'",
")",
";",
"if",
"(",
"globalConsole",
"&&",
"globalConsole",
".",
"warn",
")",
"{",
"globalConsole",
".",
"warn",
"(",
"data",
")",
";",
"}",
"}",
"else",
"{",
"application",
".",
"fire",
"(",
"'warning'",
",",
"data",
")",
";",
"}",
"}"
] |
Signals that an warning has occurred.
If in development mode, console.warn is invoked.
If in production mode, an event is fired.
@param {*} data A message string or arbitrary data
@returns {void}
|
[
"Signals",
"that",
"an",
"warning",
"has",
"occurred",
".",
"If",
"in",
"development",
"mode",
"console",
".",
"warn",
"is",
"invoked",
".",
"If",
"in",
"production",
"mode",
"an",
"event",
"is",
"fired",
"."
] |
1cc1751650e339bd5243a0f20cc76543c834ac09
|
https://github.com/box/t3js/blob/1cc1751650e339bd5243a0f20cc76543c834ac09/lib/application.js#L842-L852
|
|
16,701
|
box/t3js
|
lib/application.js
|
function(data) {
if (globalConfig.debug) {
// We grab console via getGlobal() so we can stub it out in tests
var globalConsole = this.getGlobal('console');
if (globalConsole && globalConsole.info) {
globalConsole.info(data);
}
}
}
|
javascript
|
function(data) {
if (globalConfig.debug) {
// We grab console via getGlobal() so we can stub it out in tests
var globalConsole = this.getGlobal('console');
if (globalConsole && globalConsole.info) {
globalConsole.info(data);
}
}
}
|
[
"function",
"(",
"data",
")",
"{",
"if",
"(",
"globalConfig",
".",
"debug",
")",
"{",
"// We grab console via getGlobal() so we can stub it out in tests",
"var",
"globalConsole",
"=",
"this",
".",
"getGlobal",
"(",
"'console'",
")",
";",
"if",
"(",
"globalConsole",
"&&",
"globalConsole",
".",
"info",
")",
"{",
"globalConsole",
".",
"info",
"(",
"data",
")",
";",
"}",
"}",
"}"
] |
Display console info messages.
If in development mode, console.info is invoked.
@param {*} data A message string or arbitrary data
@returns {void}
|
[
"Display",
"console",
"info",
"messages",
".",
"If",
"in",
"development",
"mode",
"console",
".",
"info",
"is",
"invoked",
"."
] |
1cc1751650e339bd5243a0f20cc76543c834ac09
|
https://github.com/box/t3js/blob/1cc1751650e339bd5243a0f20cc76543c834ac09/lib/application.js#L860-L868
|
|
16,702
|
box/t3js
|
examples/todo/js/services/router.js
|
parseRoutes
|
function parseRoutes() {
// Regexs to convert a route (/file/:fileId) into a regex
var optionalParam = /\((.*?)\)/g,
namedParam = /(\(\?)?:\w+/g,
splatParam = /\*\w+/g,
escapeRegExp = /[\-{}\[\]+?.,\\\^$|#\s]/g,
namedParamCallback = function(match, optional) {
return optional ? match : '([^\/]+)';
},
route,
regexRoute;
for (var i = 0, len = pageRoutes.length; i < len; i++) {
route = pageRoutes[i];
regexRoute = route.replace(escapeRegExp, '\\$&')
.replace(optionalParam, '(?:$1)?')
.replace(namedParam, namedParamCallback)
.replace(splatParam, '(.*?)');
regexRoutes.push(new RegExp('^' + regexRoute + '$'));
}
}
|
javascript
|
function parseRoutes() {
// Regexs to convert a route (/file/:fileId) into a regex
var optionalParam = /\((.*?)\)/g,
namedParam = /(\(\?)?:\w+/g,
splatParam = /\*\w+/g,
escapeRegExp = /[\-{}\[\]+?.,\\\^$|#\s]/g,
namedParamCallback = function(match, optional) {
return optional ? match : '([^\/]+)';
},
route,
regexRoute;
for (var i = 0, len = pageRoutes.length; i < len; i++) {
route = pageRoutes[i];
regexRoute = route.replace(escapeRegExp, '\\$&')
.replace(optionalParam, '(?:$1)?')
.replace(namedParam, namedParamCallback)
.replace(splatParam, '(.*?)');
regexRoutes.push(new RegExp('^' + regexRoute + '$'));
}
}
|
[
"function",
"parseRoutes",
"(",
")",
"{",
"// Regexs to convert a route (/file/:fileId) into a regex",
"var",
"optionalParam",
"=",
"/",
"\\((.*?)\\)",
"/",
"g",
",",
"namedParam",
"=",
"/",
"(\\(\\?)?:\\w+",
"/",
"g",
",",
"splatParam",
"=",
"/",
"\\*\\w+",
"/",
"g",
",",
"escapeRegExp",
"=",
"/",
"[\\-{}\\[\\]+?.,\\\\\\^$|#\\s]",
"/",
"g",
",",
"namedParamCallback",
"=",
"function",
"(",
"match",
",",
"optional",
")",
"{",
"return",
"optional",
"?",
"match",
":",
"'([^\\/]+)'",
";",
"}",
",",
"route",
",",
"regexRoute",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"pageRoutes",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"route",
"=",
"pageRoutes",
"[",
"i",
"]",
";",
"regexRoute",
"=",
"route",
".",
"replace",
"(",
"escapeRegExp",
",",
"'\\\\$&'",
")",
".",
"replace",
"(",
"optionalParam",
",",
"'(?:$1)?'",
")",
".",
"replace",
"(",
"namedParam",
",",
"namedParamCallback",
")",
".",
"replace",
"(",
"splatParam",
",",
"'(.*?)'",
")",
";",
"regexRoutes",
".",
"push",
"(",
"new",
"RegExp",
"(",
"'^'",
"+",
"regexRoute",
"+",
"'$'",
")",
")",
";",
"}",
"}"
] |
Parses the user-friendly declared routes at the top of the application,
these could be init'ed or passed in from another context to help extract
navigation for T3 from the framework. Populates the regexRoutes variable
that is local to the service.
Regexs and parsing borrowed from Backbone's router since they did it right
and not inclined to make a new router syntax unless we have a reason to.
@returns {void}
|
[
"Parses",
"the",
"user",
"-",
"friendly",
"declared",
"routes",
"at",
"the",
"top",
"of",
"the",
"application",
"these",
"could",
"be",
"init",
"ed",
"or",
"passed",
"in",
"from",
"another",
"context",
"to",
"help",
"extract",
"navigation",
"for",
"T3",
"from",
"the",
"framework",
".",
"Populates",
"the",
"regexRoutes",
"variable",
"that",
"is",
"local",
"to",
"the",
"service",
".",
"Regexs",
"and",
"parsing",
"borrowed",
"from",
"Backbone",
"s",
"router",
"since",
"they",
"did",
"it",
"right",
"and",
"not",
"inclined",
"to",
"make",
"a",
"new",
"router",
"syntax",
"unless",
"we",
"have",
"a",
"reason",
"to",
"."
] |
1cc1751650e339bd5243a0f20cc76543c834ac09
|
https://github.com/box/t3js/blob/1cc1751650e339bd5243a0f20cc76543c834ac09/examples/todo/js/services/router.js#L28-L48
|
16,703
|
box/t3js
|
examples/todo/js/services/router.js
|
broadcastStateChanged
|
function broadcastStateChanged(fragment) {
var globMatches = matchGlob(fragment);
if (!!globMatches) {
application.broadcast('statechanged', {
url: fragment,
prevUrl: prevUrl,
params: globMatches.splice(1) // Get everything after the URL
});
}
}
|
javascript
|
function broadcastStateChanged(fragment) {
var globMatches = matchGlob(fragment);
if (!!globMatches) {
application.broadcast('statechanged', {
url: fragment,
prevUrl: prevUrl,
params: globMatches.splice(1) // Get everything after the URL
});
}
}
|
[
"function",
"broadcastStateChanged",
"(",
"fragment",
")",
"{",
"var",
"globMatches",
"=",
"matchGlob",
"(",
"fragment",
")",
";",
"if",
"(",
"!",
"!",
"globMatches",
")",
"{",
"application",
".",
"broadcast",
"(",
"'statechanged'",
",",
"{",
"url",
":",
"fragment",
",",
"prevUrl",
":",
"prevUrl",
",",
"params",
":",
"globMatches",
".",
"splice",
"(",
"1",
")",
"// Get everything after the URL",
"}",
")",
";",
"}",
"}"
] |
Gets the fragment and broadcasts the previous URL and the current URL of
the page, ideally we wouldn't have a dependency on the previous URL...
@param {string} fragment the current "URL" the user is getting to
@returns {void}
|
[
"Gets",
"the",
"fragment",
"and",
"broadcasts",
"the",
"previous",
"URL",
"and",
"the",
"current",
"URL",
"of",
"the",
"page",
"ideally",
"we",
"wouldn",
"t",
"have",
"a",
"dependency",
"on",
"the",
"previous",
"URL",
"..."
] |
1cc1751650e339bd5243a0f20cc76543c834ac09
|
https://github.com/box/t3js/blob/1cc1751650e339bd5243a0f20cc76543c834ac09/examples/todo/js/services/router.js#L78-L88
|
16,704
|
box/t3js
|
examples/todo/js/services/router.js
|
function(state, title, fragment) {
prevUrl = history.state.hash;
// First push the state
history.pushState(state, title, fragment);
// Then make the AJAX request
broadcastStateChanged(fragment);
}
|
javascript
|
function(state, title, fragment) {
prevUrl = history.state.hash;
// First push the state
history.pushState(state, title, fragment);
// Then make the AJAX request
broadcastStateChanged(fragment);
}
|
[
"function",
"(",
"state",
",",
"title",
",",
"fragment",
")",
"{",
"prevUrl",
"=",
"history",
".",
"state",
".",
"hash",
";",
"// First push the state",
"history",
".",
"pushState",
"(",
"state",
",",
"title",
",",
"fragment",
")",
";",
"// Then make the AJAX request",
"broadcastStateChanged",
"(",
"fragment",
")",
";",
"}"
] |
The magical method the application code will call to navigate around,
high level it pushes the state, gets the templates from server, puts
them on the page and broadcasts the statechanged.
@param {Object} state the state associated with the URL
@param {string} title the title of the page
@param {string} fragment the current "URL" the user is getting to
@returns {void}
|
[
"The",
"magical",
"method",
"the",
"application",
"code",
"will",
"call",
"to",
"navigate",
"around",
"high",
"level",
"it",
"pushes",
"the",
"state",
"gets",
"the",
"templates",
"from",
"server",
"puts",
"them",
"on",
"the",
"page",
"and",
"broadcasts",
"the",
"statechanged",
"."
] |
1cc1751650e339bd5243a0f20cc76543c834ac09
|
https://github.com/box/t3js/blob/1cc1751650e339bd5243a0f20cc76543c834ac09/examples/todo/js/services/router.js#L100-L108
|
|
16,705
|
box/t3js
|
examples/todo/js/behaviors/todo.js
|
getClosestTodoElement
|
function getClosestTodoElement(element) {
var matchesSelector = element.matches || element.webkitMatchesSelector || element.mozMatchesSelector || element.msMatchesSelector;
while (element) {
if (matchesSelector.bind(element)('li')) {
return element;
} else {
element = element.parentNode;
}
}
return false;
}
|
javascript
|
function getClosestTodoElement(element) {
var matchesSelector = element.matches || element.webkitMatchesSelector || element.mozMatchesSelector || element.msMatchesSelector;
while (element) {
if (matchesSelector.bind(element)('li')) {
return element;
} else {
element = element.parentNode;
}
}
return false;
}
|
[
"function",
"getClosestTodoElement",
"(",
"element",
")",
"{",
"var",
"matchesSelector",
"=",
"element",
".",
"matches",
"||",
"element",
".",
"webkitMatchesSelector",
"||",
"element",
".",
"mozMatchesSelector",
"||",
"element",
".",
"msMatchesSelector",
";",
"while",
"(",
"element",
")",
"{",
"if",
"(",
"matchesSelector",
".",
"bind",
"(",
"element",
")",
"(",
"'li'",
")",
")",
"{",
"return",
"element",
";",
"}",
"else",
"{",
"element",
"=",
"element",
".",
"parentNode",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Returns the nearest todo element
@param {HTMLElement} element A root/child node of a todo element to search from
@returns {HTMLElement}
@private
|
[
"Returns",
"the",
"nearest",
"todo",
"element"
] |
1cc1751650e339bd5243a0f20cc76543c834ac09
|
https://github.com/box/t3js/blob/1cc1751650e339bd5243a0f20cc76543c834ac09/examples/todo/js/behaviors/todo.js#L31-L44
|
16,706
|
box/t3js
|
examples/todo/js/behaviors/todo.js
|
function(event, element, elementType) {
if (elementType === 'delete-btn') {
var todoEl = getClosestTodoElement(element),
todoId = getClosestTodoId(element);
moduleEl.querySelector('#todo-list').removeChild(todoEl);
todosDB.remove(todoId);
context.broadcast('todoremoved', {
id: todoId
});
}
}
|
javascript
|
function(event, element, elementType) {
if (elementType === 'delete-btn') {
var todoEl = getClosestTodoElement(element),
todoId = getClosestTodoId(element);
moduleEl.querySelector('#todo-list').removeChild(todoEl);
todosDB.remove(todoId);
context.broadcast('todoremoved', {
id: todoId
});
}
}
|
[
"function",
"(",
"event",
",",
"element",
",",
"elementType",
")",
"{",
"if",
"(",
"elementType",
"===",
"'delete-btn'",
")",
"{",
"var",
"todoEl",
"=",
"getClosestTodoElement",
"(",
"element",
")",
",",
"todoId",
"=",
"getClosestTodoId",
"(",
"element",
")",
";",
"moduleEl",
".",
"querySelector",
"(",
"'#todo-list'",
")",
".",
"removeChild",
"(",
"todoEl",
")",
";",
"todosDB",
".",
"remove",
"(",
"todoId",
")",
";",
"context",
".",
"broadcast",
"(",
"'todoremoved'",
",",
"{",
"id",
":",
"todoId",
"}",
")",
";",
"}",
"}"
] |
Handles all click events for the behavior.
@param {Event} event A DOM-normalized event object.
@param {HTMLElement} element The nearest HTML element with a data-type
attribute specified or null if there is none.
@param {string} elementType The value of data-type for the nearest
element with that attribute specified or null if there is none.
@returns {void}
|
[
"Handles",
"all",
"click",
"events",
"for",
"the",
"behavior",
"."
] |
1cc1751650e339bd5243a0f20cc76543c834ac09
|
https://github.com/box/t3js/blob/1cc1751650e339bd5243a0f20cc76543c834ac09/examples/todo/js/behaviors/todo.js#L90-L105
|
|
16,707
|
box/t3js
|
examples/todo/js/behaviors/todo.js
|
function(event, element, elementType) {
if (elementType === 'mark-as-complete-checkbox') {
var todoEl = getClosestTodoElement(element),
todoId = getClosestTodoId(element);
if (element.checked) {
todoEl.classList.add('completed');
todosDB.markAsComplete(todoId);
} else {
todoEl.classList.remove('completed');
todosDB.markAsIncomplete(todoId);
}
context.broadcast('todostatuschange');
}
}
|
javascript
|
function(event, element, elementType) {
if (elementType === 'mark-as-complete-checkbox') {
var todoEl = getClosestTodoElement(element),
todoId = getClosestTodoId(element);
if (element.checked) {
todoEl.classList.add('completed');
todosDB.markAsComplete(todoId);
} else {
todoEl.classList.remove('completed');
todosDB.markAsIncomplete(todoId);
}
context.broadcast('todostatuschange');
}
}
|
[
"function",
"(",
"event",
",",
"element",
",",
"elementType",
")",
"{",
"if",
"(",
"elementType",
"===",
"'mark-as-complete-checkbox'",
")",
"{",
"var",
"todoEl",
"=",
"getClosestTodoElement",
"(",
"element",
")",
",",
"todoId",
"=",
"getClosestTodoId",
"(",
"element",
")",
";",
"if",
"(",
"element",
".",
"checked",
")",
"{",
"todoEl",
".",
"classList",
".",
"add",
"(",
"'completed'",
")",
";",
"todosDB",
".",
"markAsComplete",
"(",
"todoId",
")",
";",
"}",
"else",
"{",
"todoEl",
".",
"classList",
".",
"remove",
"(",
"'completed'",
")",
";",
"todosDB",
".",
"markAsIncomplete",
"(",
"todoId",
")",
";",
"}",
"context",
".",
"broadcast",
"(",
"'todostatuschange'",
")",
";",
"}",
"}"
] |
Handles change events for the behavior.
@param {Event} event A DOM-normalized event object.
@param {HTMLElement} element The nearest HTML element with a data-type
attribute specified or null if there is none.
@param {string} elementType The value of data-type for the nearest
element with that attribute specified or null if there is none.
@returns {void}
|
[
"Handles",
"change",
"events",
"for",
"the",
"behavior",
"."
] |
1cc1751650e339bd5243a0f20cc76543c834ac09
|
https://github.com/box/t3js/blob/1cc1751650e339bd5243a0f20cc76543c834ac09/examples/todo/js/behaviors/todo.js#L116-L134
|
|
16,708
|
box/t3js
|
examples/todo/js/behaviors/todo.js
|
function(event, element, elementType) {
if (elementType === 'todo-label') {
var todoEl = getClosestTodoElement(element);
event.preventDefault();
event.stopPropagation();
this.showEditor(todoEl);
}
}
|
javascript
|
function(event, element, elementType) {
if (elementType === 'todo-label') {
var todoEl = getClosestTodoElement(element);
event.preventDefault();
event.stopPropagation();
this.showEditor(todoEl);
}
}
|
[
"function",
"(",
"event",
",",
"element",
",",
"elementType",
")",
"{",
"if",
"(",
"elementType",
"===",
"'todo-label'",
")",
"{",
"var",
"todoEl",
"=",
"getClosestTodoElement",
"(",
"element",
")",
";",
"event",
".",
"preventDefault",
"(",
")",
";",
"event",
".",
"stopPropagation",
"(",
")",
";",
"this",
".",
"showEditor",
"(",
"todoEl",
")",
";",
"}",
"}"
] |
Handles double click events for the behavior.
@param {Event} event A DOM-normalized event object.
@param {HTMLElement} element The nearest HTML element with a data-type
attribute specified or null if there is none.
@param {string} elementType The value of data-type for the nearest
element with that attribute specified or null if there is none.
@returns {void}
|
[
"Handles",
"double",
"click",
"events",
"for",
"the",
"behavior",
"."
] |
1cc1751650e339bd5243a0f20cc76543c834ac09
|
https://github.com/box/t3js/blob/1cc1751650e339bd5243a0f20cc76543c834ac09/examples/todo/js/behaviors/todo.js#L145-L156
|
|
16,709
|
box/t3js
|
examples/todo/js/behaviors/todo.js
|
function(event, element, elementType) {
if (elementType === 'edit-input') {
var todoEl = getClosestTodoElement(element);
if (event.keyCode === ENTER_KEY) {
this.saveLabel(todoEl);
this.hideEditor(todoEl);
} else if (event.keyCode === ESCAPE_KEY) {
this.hideEditor(todoEl);
}
}
}
|
javascript
|
function(event, element, elementType) {
if (elementType === 'edit-input') {
var todoEl = getClosestTodoElement(element);
if (event.keyCode === ENTER_KEY) {
this.saveLabel(todoEl);
this.hideEditor(todoEl);
} else if (event.keyCode === ESCAPE_KEY) {
this.hideEditor(todoEl);
}
}
}
|
[
"function",
"(",
"event",
",",
"element",
",",
"elementType",
")",
"{",
"if",
"(",
"elementType",
"===",
"'edit-input'",
")",
"{",
"var",
"todoEl",
"=",
"getClosestTodoElement",
"(",
"element",
")",
";",
"if",
"(",
"event",
".",
"keyCode",
"===",
"ENTER_KEY",
")",
"{",
"this",
".",
"saveLabel",
"(",
"todoEl",
")",
";",
"this",
".",
"hideEditor",
"(",
"todoEl",
")",
";",
"}",
"else",
"if",
"(",
"event",
".",
"keyCode",
"===",
"ESCAPE_KEY",
")",
"{",
"this",
".",
"hideEditor",
"(",
"todoEl",
")",
";",
"}",
"}",
"}"
] |
Handles keydown events for the behavior.
@param {Event} event A DOM-normalized event object.
@param {HTMLElement} element The nearest HTML element with a data-type
attribute specified or null if there is none.
@param {string} elementType The value of data-type for the nearest
element with that attribute specified or null if there is none.
@returns {void}
|
[
"Handles",
"keydown",
"events",
"for",
"the",
"behavior",
"."
] |
1cc1751650e339bd5243a0f20cc76543c834ac09
|
https://github.com/box/t3js/blob/1cc1751650e339bd5243a0f20cc76543c834ac09/examples/todo/js/behaviors/todo.js#L167-L181
|
|
16,710
|
box/t3js
|
examples/todo/js/behaviors/todo.js
|
function(todoEl) {
var todoId = getClosestTodoId(todoEl),
editInputEl = todoEl.querySelector('.edit'),
title = todosDB.get(todoId).title; // Grab current label
// Set the edit input value to current label
editInputEl.value = title;
todoEl.classList.add('editing');
// Place user cursor in the input
editInputEl.focus();
}
|
javascript
|
function(todoEl) {
var todoId = getClosestTodoId(todoEl),
editInputEl = todoEl.querySelector('.edit'),
title = todosDB.get(todoId).title; // Grab current label
// Set the edit input value to current label
editInputEl.value = title;
todoEl.classList.add('editing');
// Place user cursor in the input
editInputEl.focus();
}
|
[
"function",
"(",
"todoEl",
")",
"{",
"var",
"todoId",
"=",
"getClosestTodoId",
"(",
"todoEl",
")",
",",
"editInputEl",
"=",
"todoEl",
".",
"querySelector",
"(",
"'.edit'",
")",
",",
"title",
"=",
"todosDB",
".",
"get",
"(",
"todoId",
")",
".",
"title",
";",
"// Grab current label",
"// Set the edit input value to current label",
"editInputEl",
".",
"value",
"=",
"title",
";",
"todoEl",
".",
"classList",
".",
"add",
"(",
"'editing'",
")",
";",
"// Place user cursor in the input",
"editInputEl",
".",
"focus",
"(",
")",
";",
"}"
] |
Displays a input box for the user to edit the label with
@param {HTMLElement} todoEl The todo element to edit
@returns {void}
|
[
"Displays",
"a",
"input",
"box",
"for",
"the",
"user",
"to",
"edit",
"the",
"label",
"with"
] |
1cc1751650e339bd5243a0f20cc76543c834ac09
|
https://github.com/box/t3js/blob/1cc1751650e339bd5243a0f20cc76543c834ac09/examples/todo/js/behaviors/todo.js#L188-L200
|
|
16,711
|
box/t3js
|
examples/todo/js/behaviors/todo.js
|
function(todoEl) {
var todoId = getClosestTodoId(todoEl),
editInputEl = todoEl.querySelector('.edit'),
newTitle = (editInputEl.value).trim();
todoEl.querySelector('label').textContent = newTitle;
todosDB.edit(todoId, newTitle);
}
|
javascript
|
function(todoEl) {
var todoId = getClosestTodoId(todoEl),
editInputEl = todoEl.querySelector('.edit'),
newTitle = (editInputEl.value).trim();
todoEl.querySelector('label').textContent = newTitle;
todosDB.edit(todoId, newTitle);
}
|
[
"function",
"(",
"todoEl",
")",
"{",
"var",
"todoId",
"=",
"getClosestTodoId",
"(",
"todoEl",
")",
",",
"editInputEl",
"=",
"todoEl",
".",
"querySelector",
"(",
"'.edit'",
")",
",",
"newTitle",
"=",
"(",
"editInputEl",
".",
"value",
")",
".",
"trim",
"(",
")",
";",
"todoEl",
".",
"querySelector",
"(",
"'label'",
")",
".",
"textContent",
"=",
"newTitle",
";",
"todosDB",
".",
"edit",
"(",
"todoId",
",",
"newTitle",
")",
";",
"}"
] |
Saves the value of the edit input and saves it to the db
@param {HTMLElement} todoEl The todo element to edit
@returns {void}
|
[
"Saves",
"the",
"value",
"of",
"the",
"edit",
"input",
"and",
"saves",
"it",
"to",
"the",
"db"
] |
1cc1751650e339bd5243a0f20cc76543c834ac09
|
https://github.com/box/t3js/blob/1cc1751650e339bd5243a0f20cc76543c834ac09/examples/todo/js/behaviors/todo.js#L216-L223
|
|
16,712
|
box/t3js
|
examples/todo/js/modules/list.js
|
isListCompleted
|
function isListCompleted() {
var todos = todosDB.getList();
var len = todos.length;
var isComplete = len > 0;
for (var i = 0; i < len; i++) {
if (!todos[i].completed) {
isComplete = false;
break;
}
}
return isComplete;
}
|
javascript
|
function isListCompleted() {
var todos = todosDB.getList();
var len = todos.length;
var isComplete = len > 0;
for (var i = 0; i < len; i++) {
if (!todos[i].completed) {
isComplete = false;
break;
}
}
return isComplete;
}
|
[
"function",
"isListCompleted",
"(",
")",
"{",
"var",
"todos",
"=",
"todosDB",
".",
"getList",
"(",
")",
";",
"var",
"len",
"=",
"todos",
".",
"length",
";",
"var",
"isComplete",
"=",
"len",
">",
"0",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"todos",
"[",
"i",
"]",
".",
"completed",
")",
"{",
"isComplete",
"=",
"false",
";",
"break",
";",
"}",
"}",
"return",
"isComplete",
";",
"}"
] |
Returns true if all todos in the list are complete
@returns {boolean}
@private
|
[
"Returns",
"true",
"if",
"all",
"todos",
"in",
"the",
"list",
"are",
"complete"
] |
1cc1751650e339bd5243a0f20cc76543c834ac09
|
https://github.com/box/t3js/blob/1cc1751650e339bd5243a0f20cc76543c834ac09/examples/todo/js/modules/list.js#L26-L37
|
16,713
|
box/t3js
|
examples/todo/js/modules/list.js
|
function(event, element, elementType) {
if (elementType === 'select-all-checkbox') {
var shouldMarkAsComplete = element.checked;
if (shouldMarkAsComplete) {
todosDB.markAllAsComplete();
} else {
todosDB.markAllAsIncomplete();
}
this.renderList();
context.broadcast('todostatuschange');
}
}
|
javascript
|
function(event, element, elementType) {
if (elementType === 'select-all-checkbox') {
var shouldMarkAsComplete = element.checked;
if (shouldMarkAsComplete) {
todosDB.markAllAsComplete();
} else {
todosDB.markAllAsIncomplete();
}
this.renderList();
context.broadcast('todostatuschange');
}
}
|
[
"function",
"(",
"event",
",",
"element",
",",
"elementType",
")",
"{",
"if",
"(",
"elementType",
"===",
"'select-all-checkbox'",
")",
"{",
"var",
"shouldMarkAsComplete",
"=",
"element",
".",
"checked",
";",
"if",
"(",
"shouldMarkAsComplete",
")",
"{",
"todosDB",
".",
"markAllAsComplete",
"(",
")",
";",
"}",
"else",
"{",
"todosDB",
".",
"markAllAsIncomplete",
"(",
")",
";",
"}",
"this",
".",
"renderList",
"(",
")",
";",
"context",
".",
"broadcast",
"(",
"'todostatuschange'",
")",
";",
"}",
"}"
] |
Handles all click events for the module.
@param {Event} event A DOM-normalized event object.
@param {HTMLElement} element The nearest HTML element with a data-type
attribute specified or null if there is none.
@param {string} elementType The value of data-type for the nearest
element with that attribute specified or null if there is none.
@returns {void}
|
[
"Handles",
"all",
"click",
"events",
"for",
"the",
"module",
"."
] |
1cc1751650e339bd5243a0f20cc76543c834ac09
|
https://github.com/box/t3js/blob/1cc1751650e339bd5243a0f20cc76543c834ac09/examples/todo/js/modules/list.js#L101-L117
|
|
16,714
|
box/t3js
|
examples/todo/js/modules/list.js
|
function(name, data) {
switch(name) {
case 'todoadded':
case 'todoremoved':
this.renderList();
this.updateSelectAllCheckbox();
break;
case 'todostatuschange':
this.updateSelectAllCheckbox();
break;
case 'statechanged':
setFilterByUrl(data.url);
this.renderList();
break;
}
}
|
javascript
|
function(name, data) {
switch(name) {
case 'todoadded':
case 'todoremoved':
this.renderList();
this.updateSelectAllCheckbox();
break;
case 'todostatuschange':
this.updateSelectAllCheckbox();
break;
case 'statechanged':
setFilterByUrl(data.url);
this.renderList();
break;
}
}
|
[
"function",
"(",
"name",
",",
"data",
")",
"{",
"switch",
"(",
"name",
")",
"{",
"case",
"'todoadded'",
":",
"case",
"'todoremoved'",
":",
"this",
".",
"renderList",
"(",
")",
";",
"this",
".",
"updateSelectAllCheckbox",
"(",
")",
";",
"break",
";",
"case",
"'todostatuschange'",
":",
"this",
".",
"updateSelectAllCheckbox",
"(",
")",
";",
"break",
";",
"case",
"'statechanged'",
":",
"setFilterByUrl",
"(",
"data",
".",
"url",
")",
";",
"this",
".",
"renderList",
"(",
")",
";",
"break",
";",
"}",
"}"
] |
Handles all messages received for the module.
@param {string} name The name of the message received.
@param {*} [data] Additional data sent along with the message.
@returns {void}
|
[
"Handles",
"all",
"messages",
"received",
"for",
"the",
"module",
"."
] |
1cc1751650e339bd5243a0f20cc76543c834ac09
|
https://github.com/box/t3js/blob/1cc1751650e339bd5243a0f20cc76543c834ac09/examples/todo/js/modules/list.js#L125-L144
|
|
16,715
|
box/t3js
|
examples/todo/js/modules/list.js
|
function(id, title, isCompleted) {
var todoTemplateEl = moduleEl.querySelector('.todo-template-container li'),
newTodoEl = todoTemplateEl.cloneNode(true);
// Set the label of the todo
newTodoEl.querySelector('label').textContent = title;
newTodoEl.setAttribute('data-todo-id', id);
if (isCompleted) {
newTodoEl.classList.add('completed');
newTodoEl.querySelector('input[type="checkbox"]').checked = true;
}
return newTodoEl;
}
|
javascript
|
function(id, title, isCompleted) {
var todoTemplateEl = moduleEl.querySelector('.todo-template-container li'),
newTodoEl = todoTemplateEl.cloneNode(true);
// Set the label of the todo
newTodoEl.querySelector('label').textContent = title;
newTodoEl.setAttribute('data-todo-id', id);
if (isCompleted) {
newTodoEl.classList.add('completed');
newTodoEl.querySelector('input[type="checkbox"]').checked = true;
}
return newTodoEl;
}
|
[
"function",
"(",
"id",
",",
"title",
",",
"isCompleted",
")",
"{",
"var",
"todoTemplateEl",
"=",
"moduleEl",
".",
"querySelector",
"(",
"'.todo-template-container li'",
")",
",",
"newTodoEl",
"=",
"todoTemplateEl",
".",
"cloneNode",
"(",
"true",
")",
";",
"// Set the label of the todo",
"newTodoEl",
".",
"querySelector",
"(",
"'label'",
")",
".",
"textContent",
"=",
"title",
";",
"newTodoEl",
".",
"setAttribute",
"(",
"'data-todo-id'",
",",
"id",
")",
";",
"if",
"(",
"isCompleted",
")",
"{",
"newTodoEl",
".",
"classList",
".",
"add",
"(",
"'completed'",
")",
";",
"newTodoEl",
".",
"querySelector",
"(",
"'input[type=\"checkbox\"]'",
")",
".",
"checked",
"=",
"true",
";",
"}",
"return",
"newTodoEl",
";",
"}"
] |
Creates a list item for a todo based off of a template
@param {number} id The id of the todo
@param {string} title The todo label
@param {boolean} isCompleted Is todo complete
@returns {Node}
|
[
"Creates",
"a",
"list",
"item",
"for",
"a",
"todo",
"based",
"off",
"of",
"a",
"template"
] |
1cc1751650e339bd5243a0f20cc76543c834ac09
|
https://github.com/box/t3js/blob/1cc1751650e339bd5243a0f20cc76543c834ac09/examples/todo/js/modules/list.js#L153-L166
|
|
16,716
|
box/t3js
|
examples/todo/js/modules/list.js
|
function() {
// Clear the todo list first
this.clearList();
var todos = todosDB.getList(),
todo;
// Render todos - factor in the current filter as well
for (var i = 0, len = todos.length; i < len; i++) {
todo = todos[i];
if (!filter
|| (filter === 'incomplete' && !todo.completed)
|| (filter === 'complete' && todo.completed)) {
this.addTodoItem(todo.id, todo.title, todo.completed);
}
}
}
|
javascript
|
function() {
// Clear the todo list first
this.clearList();
var todos = todosDB.getList(),
todo;
// Render todos - factor in the current filter as well
for (var i = 0, len = todos.length; i < len; i++) {
todo = todos[i];
if (!filter
|| (filter === 'incomplete' && !todo.completed)
|| (filter === 'complete' && todo.completed)) {
this.addTodoItem(todo.id, todo.title, todo.completed);
}
}
}
|
[
"function",
"(",
")",
"{",
"// Clear the todo list first",
"this",
".",
"clearList",
"(",
")",
";",
"var",
"todos",
"=",
"todosDB",
".",
"getList",
"(",
")",
",",
"todo",
";",
"// Render todos - factor in the current filter as well",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"todos",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"todo",
"=",
"todos",
"[",
"i",
"]",
";",
"if",
"(",
"!",
"filter",
"||",
"(",
"filter",
"===",
"'incomplete'",
"&&",
"!",
"todo",
".",
"completed",
")",
"||",
"(",
"filter",
"===",
"'complete'",
"&&",
"todo",
".",
"completed",
")",
")",
"{",
"this",
".",
"addTodoItem",
"(",
"todo",
".",
"id",
",",
"todo",
".",
"title",
",",
"todo",
".",
"completed",
")",
";",
"}",
"}",
"}"
] |
Renders all todos in the todos db
@returns {void}
|
[
"Renders",
"all",
"todos",
"in",
"the",
"todos",
"db"
] |
1cc1751650e339bd5243a0f20cc76543c834ac09
|
https://github.com/box/t3js/blob/1cc1751650e339bd5243a0f20cc76543c834ac09/examples/todo/js/modules/list.js#L203-L221
|
|
16,717
|
box/t3js
|
dist/t3-jquery.js
|
function(type, handler) {
var handlers = this._handlers[type],
i,
len;
if (typeof handlers === 'undefined') {
handlers = this._handlers[type] = [];
}
for (i = 0, len = handlers.length; i < len; i++) {
if (handlers[i] === handler) {
// prevent duplicate handlers
return;
}
}
handlers.push(handler);
}
|
javascript
|
function(type, handler) {
var handlers = this._handlers[type],
i,
len;
if (typeof handlers === 'undefined') {
handlers = this._handlers[type] = [];
}
for (i = 0, len = handlers.length; i < len; i++) {
if (handlers[i] === handler) {
// prevent duplicate handlers
return;
}
}
handlers.push(handler);
}
|
[
"function",
"(",
"type",
",",
"handler",
")",
"{",
"var",
"handlers",
"=",
"this",
".",
"_handlers",
"[",
"type",
"]",
",",
"i",
",",
"len",
";",
"if",
"(",
"typeof",
"handlers",
"===",
"'undefined'",
")",
"{",
"handlers",
"=",
"this",
".",
"_handlers",
"[",
"type",
"]",
"=",
"[",
"]",
";",
"}",
"for",
"(",
"i",
"=",
"0",
",",
"len",
"=",
"handlers",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"handlers",
"[",
"i",
"]",
"===",
"handler",
")",
"{",
"// prevent duplicate handlers",
"return",
";",
"}",
"}",
"handlers",
".",
"push",
"(",
"handler",
")",
";",
"}"
] |
Adds a new event handler for a particular type of event.
@param {string} type The name of the event to listen for.
@param {Function} handler The function to call when the event occurs.
@returns {void}
|
[
"Adds",
"a",
"new",
"event",
"handler",
"for",
"a",
"particular",
"type",
"of",
"event",
"."
] |
1cc1751650e339bd5243a0f20cc76543c834ac09
|
https://github.com/box/t3js/blob/1cc1751650e339bd5243a0f20cc76543c834ac09/dist/t3-jquery.js#L73-L91
|
|
16,718
|
box/t3js
|
dist/t3-jquery.js
|
DOMEventDelegate
|
function DOMEventDelegate(element, handler, eventTypes) {
/**
* The DOM element that this object is handling events for.
* @type {HTMLElement}
*/
this.element = element;
/**
* Object on which event handlers are available.
* @type {Object}
* @private
*/
this._handler = handler;
/**
* List of event types to handle (make sure these events bubble!)
* @type {string[]}
* @private
*/
this._eventTypes = eventTypes || DEFAULT_EVENT_TYPES;
/**
* Tracks event handlers whose this-value is bound to the correct
* object.
* @type {Object}
* @private
*/
this._boundHandler = {};
/**
* Indicates if events have been attached.
* @type {boolean}
* @private
*/
this._attached = false;
}
|
javascript
|
function DOMEventDelegate(element, handler, eventTypes) {
/**
* The DOM element that this object is handling events for.
* @type {HTMLElement}
*/
this.element = element;
/**
* Object on which event handlers are available.
* @type {Object}
* @private
*/
this._handler = handler;
/**
* List of event types to handle (make sure these events bubble!)
* @type {string[]}
* @private
*/
this._eventTypes = eventTypes || DEFAULT_EVENT_TYPES;
/**
* Tracks event handlers whose this-value is bound to the correct
* object.
* @type {Object}
* @private
*/
this._boundHandler = {};
/**
* Indicates if events have been attached.
* @type {boolean}
* @private
*/
this._attached = false;
}
|
[
"function",
"DOMEventDelegate",
"(",
"element",
",",
"handler",
",",
"eventTypes",
")",
"{",
"/**\n\t\t * The DOM element that this object is handling events for.\n\t\t * @type {HTMLElement}\n\t\t */",
"this",
".",
"element",
"=",
"element",
";",
"/**\n\t\t * Object on which event handlers are available.\n\t\t * @type {Object}\n\t\t * @private\n\t\t */",
"this",
".",
"_handler",
"=",
"handler",
";",
"/**\n\t\t * List of event types to handle (make sure these events bubble!)\n\t\t * @type {string[]}\n\t\t * @private\n\t\t */",
"this",
".",
"_eventTypes",
"=",
"eventTypes",
"||",
"DEFAULT_EVENT_TYPES",
";",
"/**\n\t\t * Tracks event handlers whose this-value is bound to the correct\n\t\t * object.\n\t\t * @type {Object}\n\t\t * @private\n\t\t */",
"this",
".",
"_boundHandler",
"=",
"{",
"}",
";",
"/**\n\t\t * Indicates if events have been attached.\n\t\t * @type {boolean}\n\t\t * @private\n\t\t */",
"this",
".",
"_attached",
"=",
"false",
";",
"}"
] |
An object that manages events within a single DOM element.
@param {HTMLElement} element The DOM element to handle events for.
@param {Object} handler An object containing event handlers such as "onclick".
@param {string[]} [eventTypes] A list of event types to handle (events must bubble). Defaults to a common set of events.
@constructor
|
[
"An",
"object",
"that",
"manages",
"events",
"within",
"a",
"single",
"DOM",
"element",
"."
] |
1cc1751650e339bd5243a0f20cc76543c834ac09
|
https://github.com/box/t3js/blob/1cc1751650e339bd5243a0f20cc76543c834ac09/dist/t3-jquery.js#L314-L350
|
16,719
|
box/t3js
|
dist/t3-jquery.js
|
function() {
if (!this._attached) {
forEachEventType(this._eventTypes, this._handler, function(eventType) {
var that = this;
function handleEvent() {
that._handleEvent.apply(that, arguments);
}
Box.DOM.on(this.element, eventType, handleEvent);
this._boundHandler[eventType] = handleEvent;
}, this);
this._attached = true;
}
}
|
javascript
|
function() {
if (!this._attached) {
forEachEventType(this._eventTypes, this._handler, function(eventType) {
var that = this;
function handleEvent() {
that._handleEvent.apply(that, arguments);
}
Box.DOM.on(this.element, eventType, handleEvent);
this._boundHandler[eventType] = handleEvent;
}, this);
this._attached = true;
}
}
|
[
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_attached",
")",
"{",
"forEachEventType",
"(",
"this",
".",
"_eventTypes",
",",
"this",
".",
"_handler",
",",
"function",
"(",
"eventType",
")",
"{",
"var",
"that",
"=",
"this",
";",
"function",
"handleEvent",
"(",
")",
"{",
"that",
".",
"_handleEvent",
".",
"apply",
"(",
"that",
",",
"arguments",
")",
";",
"}",
"Box",
".",
"DOM",
".",
"on",
"(",
"this",
".",
"element",
",",
"eventType",
",",
"handleEvent",
")",
";",
"this",
".",
"_boundHandler",
"[",
"eventType",
"]",
"=",
"handleEvent",
";",
"}",
",",
"this",
")",
";",
"this",
".",
"_attached",
"=",
"true",
";",
"}",
"}"
] |
Attaches all event handlers for the DOM element.
@returns {void}
|
[
"Attaches",
"all",
"event",
"handlers",
"for",
"the",
"DOM",
"element",
"."
] |
1cc1751650e339bd5243a0f20cc76543c834ac09
|
https://github.com/box/t3js/blob/1cc1751650e339bd5243a0f20cc76543c834ac09/dist/t3-jquery.js#L369-L386
|
|
16,720
|
box/t3js
|
dist/t3-jquery.js
|
function() {
forEachEventType(this._eventTypes, this._handler, function(eventType) {
Box.DOM.off(this.element, eventType, this._boundHandler[eventType]);
}, this);
}
|
javascript
|
function() {
forEachEventType(this._eventTypes, this._handler, function(eventType) {
Box.DOM.off(this.element, eventType, this._boundHandler[eventType]);
}, this);
}
|
[
"function",
"(",
")",
"{",
"forEachEventType",
"(",
"this",
".",
"_eventTypes",
",",
"this",
".",
"_handler",
",",
"function",
"(",
"eventType",
")",
"{",
"Box",
".",
"DOM",
".",
"off",
"(",
"this",
".",
"element",
",",
"eventType",
",",
"this",
".",
"_boundHandler",
"[",
"eventType",
"]",
")",
";",
"}",
",",
"this",
")",
";",
"}"
] |
Detaches all event handlers for the DOM element.
@returns {void}
|
[
"Detaches",
"all",
"event",
"handlers",
"for",
"the",
"DOM",
"element",
"."
] |
1cc1751650e339bd5243a0f20cc76543c834ac09
|
https://github.com/box/t3js/blob/1cc1751650e339bd5243a0f20cc76543c834ac09/dist/t3-jquery.js#L392-L396
|
|
16,721
|
box/t3js
|
examples/todo/js/modules/footer.js
|
function(url) {
var linkEls = moduleEl.querySelectorAll('a');
for (var i = 0, len = linkEls.length; i < len; i++) {
if (url === linkEls[i].pathname) {
linkEls[i].classList.add('selected');
} else {
linkEls[i].classList.remove('selected');
}
}
}
|
javascript
|
function(url) {
var linkEls = moduleEl.querySelectorAll('a');
for (var i = 0, len = linkEls.length; i < len; i++) {
if (url === linkEls[i].pathname) {
linkEls[i].classList.add('selected');
} else {
linkEls[i].classList.remove('selected');
}
}
}
|
[
"function",
"(",
"url",
")",
"{",
"var",
"linkEls",
"=",
"moduleEl",
".",
"querySelectorAll",
"(",
"'a'",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"linkEls",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"url",
"===",
"linkEls",
"[",
"i",
"]",
".",
"pathname",
")",
"{",
"linkEls",
"[",
"i",
"]",
".",
"classList",
".",
"add",
"(",
"'selected'",
")",
";",
"}",
"else",
"{",
"linkEls",
"[",
"i",
"]",
".",
"classList",
".",
"remove",
"(",
"'selected'",
")",
";",
"}",
"}",
"}"
] |
Updates the selected class on the filter links
@param {string} url The current url
@returns {void}
|
[
"Updates",
"the",
"selected",
"class",
"on",
"the",
"filter",
"links"
] |
1cc1751650e339bd5243a0f20cc76543c834ac09
|
https://github.com/box/t3js/blob/1cc1751650e339bd5243a0f20cc76543c834ac09/examples/todo/js/modules/footer.js#L90-L100
|
|
16,722
|
box/t3js
|
examples/todo/js/modules/footer.js
|
function() {
var todos = todosDB.getList();
var completedCount = 0;
for (var i = 0, len = todos.length; i < len; i++) {
if (todos[i].completed) {
completedCount++;
}
}
var itemsLeft = todos.length - completedCount;
this.updateItemsLeft(itemsLeft);
this.updateCompletedButton(completedCount);
}
|
javascript
|
function() {
var todos = todosDB.getList();
var completedCount = 0;
for (var i = 0, len = todos.length; i < len; i++) {
if (todos[i].completed) {
completedCount++;
}
}
var itemsLeft = todos.length - completedCount;
this.updateItemsLeft(itemsLeft);
this.updateCompletedButton(completedCount);
}
|
[
"function",
"(",
")",
"{",
"var",
"todos",
"=",
"todosDB",
".",
"getList",
"(",
")",
";",
"var",
"completedCount",
"=",
"0",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"todos",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"todos",
"[",
"i",
"]",
".",
"completed",
")",
"{",
"completedCount",
"++",
";",
"}",
"}",
"var",
"itemsLeft",
"=",
"todos",
".",
"length",
"-",
"completedCount",
";",
"this",
".",
"updateItemsLeft",
"(",
"itemsLeft",
")",
";",
"this",
".",
"updateCompletedButton",
"(",
"completedCount",
")",
";",
"}"
] |
Updates todo counts based on what is in the todo DB
@returns {void}
|
[
"Updates",
"todo",
"counts",
"based",
"on",
"what",
"is",
"in",
"the",
"todo",
"DB"
] |
1cc1751650e339bd5243a0f20cc76543c834ac09
|
https://github.com/box/t3js/blob/1cc1751650e339bd5243a0f20cc76543c834ac09/examples/todo/js/modules/footer.js#L107-L122
|
|
16,723
|
box/t3js
|
examples/todo/js/modules/footer.js
|
function(itemsLeft) {
var itemText = itemsLeft === 1 ? 'item' : 'items';
moduleEl.querySelector('.items-left-counter').textContent = itemsLeft;
moduleEl.querySelector('.items-left-text').textContent = itemText + ' left';
}
|
javascript
|
function(itemsLeft) {
var itemText = itemsLeft === 1 ? 'item' : 'items';
moduleEl.querySelector('.items-left-counter').textContent = itemsLeft;
moduleEl.querySelector('.items-left-text').textContent = itemText + ' left';
}
|
[
"function",
"(",
"itemsLeft",
")",
"{",
"var",
"itemText",
"=",
"itemsLeft",
"===",
"1",
"?",
"'item'",
":",
"'items'",
";",
"moduleEl",
".",
"querySelector",
"(",
"'.items-left-counter'",
")",
".",
"textContent",
"=",
"itemsLeft",
";",
"moduleEl",
".",
"querySelector",
"(",
"'.items-left-text'",
")",
".",
"textContent",
"=",
"itemText",
"+",
"' left'",
";",
"}"
] |
Updates the displayed count of incomplete tasks
@param {number} itemsLeft # of incomplete tasks
@returns {void}
|
[
"Updates",
"the",
"displayed",
"count",
"of",
"incomplete",
"tasks"
] |
1cc1751650e339bd5243a0f20cc76543c834ac09
|
https://github.com/box/t3js/blob/1cc1751650e339bd5243a0f20cc76543c834ac09/examples/todo/js/modules/footer.js#L129-L134
|
|
16,724
|
hugomrdias/prettier-stylelint
|
src/index.js
|
resolveConfig
|
function resolveConfig({
filePath,
stylelintPath,
stylelintConfig,
prettierOptions
}) {
const resolve = resolveConfig.resolve;
const stylelint = requireRelative(stylelintPath, filePath, 'stylelint');
const linterAPI = stylelint.createLinter();
if (stylelintConfig) {
return Promise.resolve(resolve(stylelintConfig, prettierOptions));
}
return linterAPI
.getConfigForFile(filePath)
.then(({ config }) => resolve(config, prettierOptions));
}
|
javascript
|
function resolveConfig({
filePath,
stylelintPath,
stylelintConfig,
prettierOptions
}) {
const resolve = resolveConfig.resolve;
const stylelint = requireRelative(stylelintPath, filePath, 'stylelint');
const linterAPI = stylelint.createLinter();
if (stylelintConfig) {
return Promise.resolve(resolve(stylelintConfig, prettierOptions));
}
return linterAPI
.getConfigForFile(filePath)
.then(({ config }) => resolve(config, prettierOptions));
}
|
[
"function",
"resolveConfig",
"(",
"{",
"filePath",
",",
"stylelintPath",
",",
"stylelintConfig",
",",
"prettierOptions",
"}",
")",
"{",
"const",
"resolve",
"=",
"resolveConfig",
".",
"resolve",
";",
"const",
"stylelint",
"=",
"requireRelative",
"(",
"stylelintPath",
",",
"filePath",
",",
"'stylelint'",
")",
";",
"const",
"linterAPI",
"=",
"stylelint",
".",
"createLinter",
"(",
")",
";",
"if",
"(",
"stylelintConfig",
")",
"{",
"return",
"Promise",
".",
"resolve",
"(",
"resolve",
"(",
"stylelintConfig",
",",
"prettierOptions",
")",
")",
";",
"}",
"return",
"linterAPI",
".",
"getConfigForFile",
"(",
"filePath",
")",
".",
"then",
"(",
"(",
"{",
"config",
"}",
")",
"=>",
"resolve",
"(",
"config",
",",
"prettierOptions",
")",
")",
";",
"}"
] |
Resolve Config for the given file
@export
@param {string} file - filepath
@param {Object} options - options
@returns {Promise} -
|
[
"Resolve",
"Config",
"for",
"the",
"given",
"file"
] |
2e37e73e600a3e01aef9b053c712914f872385d1
|
https://github.com/hugomrdias/prettier-stylelint/blob/2e37e73e600a3e01aef9b053c712914f872385d1/src/index.js#L16-L33
|
16,725
|
artsy/gemup
|
gemup.js
|
function() {
var xhr = $.ajaxSettings.xhr();
if (!xhr.upload) return xhr;
xhr.upload.addEventListener('progress', function(e) {
options.progress(e.loaded / e.total);
});
return xhr;
}
|
javascript
|
function() {
var xhr = $.ajaxSettings.xhr();
if (!xhr.upload) return xhr;
xhr.upload.addEventListener('progress', function(e) {
options.progress(e.loaded / e.total);
});
return xhr;
}
|
[
"function",
"(",
")",
"{",
"var",
"xhr",
"=",
"$",
".",
"ajaxSettings",
".",
"xhr",
"(",
")",
";",
"if",
"(",
"!",
"xhr",
".",
"upload",
")",
"return",
"xhr",
";",
"xhr",
".",
"upload",
".",
"addEventListener",
"(",
"'progress'",
",",
"function",
"(",
"e",
")",
"{",
"options",
".",
"progress",
"(",
"e",
".",
"loaded",
"/",
"e",
".",
"total",
")",
";",
"}",
")",
";",
"return",
"xhr",
";",
"}"
] |
Send progress updates
|
[
"Send",
"progress",
"updates"
] |
25f8883218b974a6c713dde071274f144974dc6f
|
https://github.com/artsy/gemup/blob/25f8883218b974a6c713dde071274f144974dc6f/gemup.js#L66-L73
|
|
16,726
|
beyondxgb/xredux
|
examples/standard/src/core/request/index.js
|
buildRequest
|
async function buildRequest(method, url, params, options) {
let param = {};
let config = {};
if (noneBodyMethod.indexOf(method) >= 0) {
param = { params: { ...params }, ...reqConfig, ...options };
} else {
param = JSON.stringify(params);
config = {
...reqConfig,
headers: {
'Content-Type': 'application/json',
...csrfConfig,
},
};
config = Object.assign({}, config, options);
}
return axios[method](url, param, config);
}
|
javascript
|
async function buildRequest(method, url, params, options) {
let param = {};
let config = {};
if (noneBodyMethod.indexOf(method) >= 0) {
param = { params: { ...params }, ...reqConfig, ...options };
} else {
param = JSON.stringify(params);
config = {
...reqConfig,
headers: {
'Content-Type': 'application/json',
...csrfConfig,
},
};
config = Object.assign({}, config, options);
}
return axios[method](url, param, config);
}
|
[
"async",
"function",
"buildRequest",
"(",
"method",
",",
"url",
",",
"params",
",",
"options",
")",
"{",
"let",
"param",
"=",
"{",
"}",
";",
"let",
"config",
"=",
"{",
"}",
";",
"if",
"(",
"noneBodyMethod",
".",
"indexOf",
"(",
"method",
")",
">=",
"0",
")",
"{",
"param",
"=",
"{",
"params",
":",
"{",
"...",
"params",
"}",
",",
"...",
"reqConfig",
",",
"...",
"options",
"}",
";",
"}",
"else",
"{",
"param",
"=",
"JSON",
".",
"stringify",
"(",
"params",
")",
";",
"config",
"=",
"{",
"...",
"reqConfig",
",",
"headers",
":",
"{",
"'Content-Type'",
":",
"'application/json'",
",",
"...",
"csrfConfig",
",",
"}",
",",
"}",
";",
"config",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"config",
",",
"options",
")",
";",
"}",
"return",
"axios",
"[",
"method",
"]",
"(",
"url",
",",
"param",
",",
"config",
")",
";",
"}"
] |
Build uniform request
|
[
"Build",
"uniform",
"request"
] |
b889468837016cc0770c04f72822fea90fdb75fb
|
https://github.com/beyondxgb/xredux/blob/b889468837016cc0770c04f72822fea90fdb75fb/examples/standard/src/core/request/index.js#L27-L44
|
16,727
|
beyondxgb/xredux
|
examples/standard/src/index.js
|
renderRoutes
|
function renderRoutes() {
return (
<Switch>
{
routes.map(route => (
<Route key={route.path || ''} {...route} />
))
}
</Switch>
);
}
|
javascript
|
function renderRoutes() {
return (
<Switch>
{
routes.map(route => (
<Route key={route.path || ''} {...route} />
))
}
</Switch>
);
}
|
[
"function",
"renderRoutes",
"(",
")",
"{",
"return",
"(",
"<",
"Switch",
">",
"\n ",
"{",
"routes",
".",
"map",
"(",
"route",
"=>",
"(",
"<",
"Route",
"key",
"=",
"{",
"route",
".",
"path",
"||",
"''",
"}",
"{",
"...",
"route",
"}",
"/",
">",
")",
")",
"}",
"\n ",
"<",
"/",
"Switch",
">",
")",
";",
"}"
] |
Render routes from route config
|
[
"Render",
"routes",
"from",
"route",
"config"
] |
b889468837016cc0770c04f72822fea90fdb75fb
|
https://github.com/beyondxgb/xredux/blob/b889468837016cc0770c04f72822fea90fdb75fb/examples/standard/src/index.js#L29-L39
|
16,728
|
dominictarr/epidemic-broadcast-trees
|
events.js
|
isAlreadyReplicating
|
function isAlreadyReplicating(state, feed_id, ignore_id) {
for(var id in state.peers) {
if(id !== ignore_id) {
var peer = state.peers[id]
if(peer.notes && getReceive(peer.notes[id])) return id
if(peer.replicating && peer.replicating[feed_id] && peer.replicating[feed_id].rx) return id
}
}
return false
}
|
javascript
|
function isAlreadyReplicating(state, feed_id, ignore_id) {
for(var id in state.peers) {
if(id !== ignore_id) {
var peer = state.peers[id]
if(peer.notes && getReceive(peer.notes[id])) return id
if(peer.replicating && peer.replicating[feed_id] && peer.replicating[feed_id].rx) return id
}
}
return false
}
|
[
"function",
"isAlreadyReplicating",
"(",
"state",
",",
"feed_id",
",",
"ignore_id",
")",
"{",
"for",
"(",
"var",
"id",
"in",
"state",
".",
"peers",
")",
"{",
"if",
"(",
"id",
"!==",
"ignore_id",
")",
"{",
"var",
"peer",
"=",
"state",
".",
"peers",
"[",
"id",
"]",
"if",
"(",
"peer",
".",
"notes",
"&&",
"getReceive",
"(",
"peer",
".",
"notes",
"[",
"id",
"]",
")",
")",
"return",
"id",
"if",
"(",
"peer",
".",
"replicating",
"&&",
"peer",
".",
"replicating",
"[",
"feed_id",
"]",
"&&",
"peer",
".",
"replicating",
"[",
"feed_id",
"]",
".",
"rx",
")",
"return",
"id",
"}",
"}",
"return",
"false",
"}"
] |
check if a feed is already being replicated on another peer from ignore_id
|
[
"check",
"if",
"a",
"feed",
"is",
"already",
"being",
"replicated",
"on",
"another",
"peer",
"from",
"ignore_id"
] |
48cfd33a757d378ce78235a33c294f22791e133d
|
https://github.com/dominictarr/epidemic-broadcast-trees/blob/48cfd33a757d378ce78235a33c294f22791e133d/events.js#L34-L43
|
16,729
|
dominictarr/epidemic-broadcast-trees
|
events.js
|
isAvailable
|
function isAvailable(state, feed_id, ignore_id) {
for(var peer_id in state.peers) {
if(peer_id != ignore_id) {
var peer = state.peers[peer_id]
//BLOCK: check wether id has blocked this peer
if((peer.clock && peer.clock[feed_id] || 0) > (state.clock[feed_id] || 0) && isShared(state, feed_id, peer_id)) {
return true
}
}
}
}
|
javascript
|
function isAvailable(state, feed_id, ignore_id) {
for(var peer_id in state.peers) {
if(peer_id != ignore_id) {
var peer = state.peers[peer_id]
//BLOCK: check wether id has blocked this peer
if((peer.clock && peer.clock[feed_id] || 0) > (state.clock[feed_id] || 0) && isShared(state, feed_id, peer_id)) {
return true
}
}
}
}
|
[
"function",
"isAvailable",
"(",
"state",
",",
"feed_id",
",",
"ignore_id",
")",
"{",
"for",
"(",
"var",
"peer_id",
"in",
"state",
".",
"peers",
")",
"{",
"if",
"(",
"peer_id",
"!=",
"ignore_id",
")",
"{",
"var",
"peer",
"=",
"state",
".",
"peers",
"[",
"peer_id",
"]",
"//BLOCK: check wether id has blocked this peer",
"if",
"(",
"(",
"peer",
".",
"clock",
"&&",
"peer",
".",
"clock",
"[",
"feed_id",
"]",
"||",
"0",
")",
">",
"(",
"state",
".",
"clock",
"[",
"feed_id",
"]",
"||",
"0",
")",
"&&",
"isShared",
"(",
"state",
",",
"feed_id",
",",
"peer_id",
")",
")",
"{",
"return",
"true",
"}",
"}",
"}",
"}"
] |
check if a feed is available from a peer apart from ignore_id
|
[
"check",
"if",
"a",
"feed",
"is",
"available",
"from",
"a",
"peer",
"apart",
"from",
"ignore_id"
] |
48cfd33a757d378ce78235a33c294f22791e133d
|
https://github.com/dominictarr/epidemic-broadcast-trees/blob/48cfd33a757d378ce78235a33c294f22791e133d/events.js#L53-L63
|
16,730
|
dominictarr/epidemic-broadcast-trees
|
events.js
|
eachFrom
|
function eachFrom(keys, key, iter) {
var i = keys.indexOf(key)
if(!~i) return
//start at 1 because we want to visit all keys but key.
for(var j = 1; j < keys.length; j++)
if(iter(keys[(j+i)%keys.length], j))
return
}
|
javascript
|
function eachFrom(keys, key, iter) {
var i = keys.indexOf(key)
if(!~i) return
//start at 1 because we want to visit all keys but key.
for(var j = 1; j < keys.length; j++)
if(iter(keys[(j+i)%keys.length], j))
return
}
|
[
"function",
"eachFrom",
"(",
"keys",
",",
"key",
",",
"iter",
")",
"{",
"var",
"i",
"=",
"keys",
".",
"indexOf",
"(",
"key",
")",
"if",
"(",
"!",
"~",
"i",
")",
"return",
"//start at 1 because we want to visit all keys but key.",
"for",
"(",
"var",
"j",
"=",
"1",
";",
"j",
"<",
"keys",
".",
"length",
";",
"j",
"++",
")",
"if",
"(",
"iter",
"(",
"keys",
"[",
"(",
"j",
"+",
"i",
")",
"%",
"keys",
".",
"length",
"]",
",",
"j",
")",
")",
"return",
"}"
] |
jump to a particular key in a list, then iterate from there back around to the key. this is used for switching away from peers that stall so that you'll rotate through all the peers not just swich between two different peers.
|
[
"jump",
"to",
"a",
"particular",
"key",
"in",
"a",
"list",
"then",
"iterate",
"from",
"there",
"back",
"around",
"to",
"the",
"key",
".",
"this",
"is",
"used",
"for",
"switching",
"away",
"from",
"peers",
"that",
"stall",
"so",
"that",
"you",
"ll",
"rotate",
"through",
"all",
"the",
"peers",
"not",
"just",
"swich",
"between",
"two",
"different",
"peers",
"."
] |
48cfd33a757d378ce78235a33c294f22791e133d
|
https://github.com/dominictarr/epidemic-broadcast-trees/blob/48cfd33a757d378ce78235a33c294f22791e133d/events.js#L70-L77
|
16,731
|
Kurento/kurento-utils-js
|
lib/WebRtcPeer.js
|
WebRtcPeerRecvonly
|
function WebRtcPeerRecvonly(options, callback) {
if (!(this instanceof WebRtcPeerRecvonly)) {
return new WebRtcPeerRecvonly(options, callback)
}
WebRtcPeerRecvonly.super_.call(this, 'recvonly', options, callback)
}
|
javascript
|
function WebRtcPeerRecvonly(options, callback) {
if (!(this instanceof WebRtcPeerRecvonly)) {
return new WebRtcPeerRecvonly(options, callback)
}
WebRtcPeerRecvonly.super_.call(this, 'recvonly', options, callback)
}
|
[
"function",
"WebRtcPeerRecvonly",
"(",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"WebRtcPeerRecvonly",
")",
")",
"{",
"return",
"new",
"WebRtcPeerRecvonly",
"(",
"options",
",",
"callback",
")",
"}",
"WebRtcPeerRecvonly",
".",
"super_",
".",
"call",
"(",
"this",
",",
"'recvonly'",
",",
"options",
",",
"callback",
")",
"}"
] |
Specialized child classes
|
[
"Specialized",
"child",
"classes"
] |
b808a5403320ba55ffb265ccac9a2fe598b54087
|
https://github.com/Kurento/kurento-utils-js/blob/b808a5403320ba55ffb265ccac9a2fe598b54087/lib/WebRtcPeer.js#L739-L745
|
16,732
|
englercj/node-esl
|
examples/chatty/public/js/app.js
|
sendMessage
|
function sendMessage(e) {
var txt = $('#msgtxt').val().trim();
if(!txt) return;
$('#messages').append(createMsgBox(txt));
socket.emit('sendmsg', txt, function(evtJson) {
var evt = JSON.parse(evtJson),
reply = evt['Reply-Text'].split(' '), //0 = +OK, 1 = uuid
$elm = $('#messages').children().last().removeClass('sending');
if(reply[0] == '+OK')
$elm.addClass('sent').data('uuid', reply[1]);
else
$elm.addClass('failed').data('error', evt['Reply-Text']);
});
$('#msgtxt').val('');
}
|
javascript
|
function sendMessage(e) {
var txt = $('#msgtxt').val().trim();
if(!txt) return;
$('#messages').append(createMsgBox(txt));
socket.emit('sendmsg', txt, function(evtJson) {
var evt = JSON.parse(evtJson),
reply = evt['Reply-Text'].split(' '), //0 = +OK, 1 = uuid
$elm = $('#messages').children().last().removeClass('sending');
if(reply[0] == '+OK')
$elm.addClass('sent').data('uuid', reply[1]);
else
$elm.addClass('failed').data('error', evt['Reply-Text']);
});
$('#msgtxt').val('');
}
|
[
"function",
"sendMessage",
"(",
"e",
")",
"{",
"var",
"txt",
"=",
"$",
"(",
"'#msgtxt'",
")",
".",
"val",
"(",
")",
".",
"trim",
"(",
")",
";",
"if",
"(",
"!",
"txt",
")",
"return",
";",
"$",
"(",
"'#messages'",
")",
".",
"append",
"(",
"createMsgBox",
"(",
"txt",
")",
")",
";",
"socket",
".",
"emit",
"(",
"'sendmsg'",
",",
"txt",
",",
"function",
"(",
"evtJson",
")",
"{",
"var",
"evt",
"=",
"JSON",
".",
"parse",
"(",
"evtJson",
")",
",",
"reply",
"=",
"evt",
"[",
"'Reply-Text'",
"]",
".",
"split",
"(",
"' '",
")",
",",
"//0 = +OK, 1 = uuid",
"$elm",
"=",
"$",
"(",
"'#messages'",
")",
".",
"children",
"(",
")",
".",
"last",
"(",
")",
".",
"removeClass",
"(",
"'sending'",
")",
";",
"if",
"(",
"reply",
"[",
"0",
"]",
"==",
"'+OK'",
")",
"$elm",
".",
"addClass",
"(",
"'sent'",
")",
".",
"data",
"(",
"'uuid'",
",",
"reply",
"[",
"1",
"]",
")",
";",
"else",
"$elm",
".",
"addClass",
"(",
"'failed'",
")",
".",
"data",
"(",
"'error'",
",",
"evt",
"[",
"'Reply-Text'",
"]",
")",
";",
"}",
")",
";",
"$",
"(",
"'#msgtxt'",
")",
".",
"val",
"(",
"''",
")",
";",
"}"
] |
send a text
|
[
"send",
"a",
"text"
] |
2b7780e5307c0c0bd68baf09893dcef6780186e3
|
https://github.com/englercj/node-esl/blob/2b7780e5307c0c0bd68baf09893dcef6780186e3/examples/chatty/public/js/app.js#L28-L47
|
16,733
|
englercj/node-esl
|
examples/chatty/public/js/app.js
|
openChat
|
function openChat() {
var num = validateNum();
if(num) {
socket.emit('setup', num, function() {
number = num;
$('#num').hide();
$('#chat').show();
});
}
}
|
javascript
|
function openChat() {
var num = validateNum();
if(num) {
socket.emit('setup', num, function() {
number = num;
$('#num').hide();
$('#chat').show();
});
}
}
|
[
"function",
"openChat",
"(",
")",
"{",
"var",
"num",
"=",
"validateNum",
"(",
")",
";",
"if",
"(",
"num",
")",
"{",
"socket",
".",
"emit",
"(",
"'setup'",
",",
"num",
",",
"function",
"(",
")",
"{",
"number",
"=",
"num",
";",
"$",
"(",
"'#num'",
")",
".",
"hide",
"(",
")",
";",
"$",
"(",
"'#chat'",
")",
".",
"show",
"(",
")",
";",
"}",
")",
";",
"}",
"}"
] |
opens a chat session with a number
|
[
"opens",
"a",
"chat",
"session",
"with",
"a",
"number"
] |
2b7780e5307c0c0bd68baf09893dcef6780186e3
|
https://github.com/englercj/node-esl/blob/2b7780e5307c0c0bd68baf09893dcef6780186e3/examples/chatty/public/js/app.js#L55-L65
|
16,734
|
englercj/node-esl
|
examples/chatty/public/js/app.js
|
validateNum
|
function validateNum() {
var pass = true,
num = '';
['#areacode', '#phnum1', '#phnum2'].forEach(function(id) {
var $e = $(id),
val = $e.val();
if(!val || val.length !== parseInt($e.attr('maxlength'), 10)) {
pass = false;
$e.addClass('error');
}
else
num += val;
});
if(!pass) return false;
return num;
}
|
javascript
|
function validateNum() {
var pass = true,
num = '';
['#areacode', '#phnum1', '#phnum2'].forEach(function(id) {
var $e = $(id),
val = $e.val();
if(!val || val.length !== parseInt($e.attr('maxlength'), 10)) {
pass = false;
$e.addClass('error');
}
else
num += val;
});
if(!pass) return false;
return num;
}
|
[
"function",
"validateNum",
"(",
")",
"{",
"var",
"pass",
"=",
"true",
",",
"num",
"=",
"''",
";",
"[",
"'#areacode'",
",",
"'#phnum1'",
",",
"'#phnum2'",
"]",
".",
"forEach",
"(",
"function",
"(",
"id",
")",
"{",
"var",
"$e",
"=",
"$",
"(",
"id",
")",
",",
"val",
"=",
"$e",
".",
"val",
"(",
")",
";",
"if",
"(",
"!",
"val",
"||",
"val",
".",
"length",
"!==",
"parseInt",
"(",
"$e",
".",
"attr",
"(",
"'maxlength'",
")",
",",
"10",
")",
")",
"{",
"pass",
"=",
"false",
";",
"$e",
".",
"addClass",
"(",
"'error'",
")",
";",
"}",
"else",
"num",
"+=",
"val",
";",
"}",
")",
";",
"if",
"(",
"!",
"pass",
")",
"return",
"false",
";",
"return",
"num",
";",
"}"
] |
validate the phone number fields
|
[
"validate",
"the",
"phone",
"number",
"fields"
] |
2b7780e5307c0c0bd68baf09893dcef6780186e3
|
https://github.com/englercj/node-esl/blob/2b7780e5307c0c0bd68baf09893dcef6780186e3/examples/chatty/public/js/app.js#L68-L87
|
16,735
|
vitalets/angular-xeditable
|
dist/js/xeditable.js
|
function() {
if (this.$visible) {
return;
}
this.$visible = true;
var pc = editablePromiseCollection();
//own show
pc.when(this.$onshow());
//clear errors
this.$setError(null, '');
//children show
angular.forEach(this.$editables, function(editable) {
pc.when(editable.show());
});
//wait promises and activate
pc.then({
onWait: angular.bind(this, this.$setWaiting),
onTrue: angular.bind(this, this.$activate),
onFalse: angular.bind(this, this.$activate),
onString: angular.bind(this, this.$activate)
});
// add to internal list of shown forms
// setTimeout needed to prevent closing right after opening (e.g. when trigger by button)
setTimeout(angular.bind(this, function() {
// clear `clicked` to get ready for clicks on visible form
this._clicked = false;
if(editableUtils.indexOf(shown, this) === -1) {
shown.push(this);
}
}), 0);
}
|
javascript
|
function() {
if (this.$visible) {
return;
}
this.$visible = true;
var pc = editablePromiseCollection();
//own show
pc.when(this.$onshow());
//clear errors
this.$setError(null, '');
//children show
angular.forEach(this.$editables, function(editable) {
pc.when(editable.show());
});
//wait promises and activate
pc.then({
onWait: angular.bind(this, this.$setWaiting),
onTrue: angular.bind(this, this.$activate),
onFalse: angular.bind(this, this.$activate),
onString: angular.bind(this, this.$activate)
});
// add to internal list of shown forms
// setTimeout needed to prevent closing right after opening (e.g. when trigger by button)
setTimeout(angular.bind(this, function() {
// clear `clicked` to get ready for clicks on visible form
this._clicked = false;
if(editableUtils.indexOf(shown, this) === -1) {
shown.push(this);
}
}), 0);
}
|
[
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"$visible",
")",
"{",
"return",
";",
"}",
"this",
".",
"$visible",
"=",
"true",
";",
"var",
"pc",
"=",
"editablePromiseCollection",
"(",
")",
";",
"//own show",
"pc",
".",
"when",
"(",
"this",
".",
"$onshow",
"(",
")",
")",
";",
"//clear errors",
"this",
".",
"$setError",
"(",
"null",
",",
"''",
")",
";",
"//children show",
"angular",
".",
"forEach",
"(",
"this",
".",
"$editables",
",",
"function",
"(",
"editable",
")",
"{",
"pc",
".",
"when",
"(",
"editable",
".",
"show",
"(",
")",
")",
";",
"}",
")",
";",
"//wait promises and activate",
"pc",
".",
"then",
"(",
"{",
"onWait",
":",
"angular",
".",
"bind",
"(",
"this",
",",
"this",
".",
"$setWaiting",
")",
",",
"onTrue",
":",
"angular",
".",
"bind",
"(",
"this",
",",
"this",
".",
"$activate",
")",
",",
"onFalse",
":",
"angular",
".",
"bind",
"(",
"this",
",",
"this",
".",
"$activate",
")",
",",
"onString",
":",
"angular",
".",
"bind",
"(",
"this",
",",
"this",
".",
"$activate",
")",
"}",
")",
";",
"// add to internal list of shown forms",
"// setTimeout needed to prevent closing right after opening (e.g. when trigger by button)",
"setTimeout",
"(",
"angular",
".",
"bind",
"(",
"this",
",",
"function",
"(",
")",
"{",
"// clear `clicked` to get ready for clicks on visible form",
"this",
".",
"_clicked",
"=",
"false",
";",
"if",
"(",
"editableUtils",
".",
"indexOf",
"(",
"shown",
",",
"this",
")",
"===",
"-",
"1",
")",
"{",
"shown",
".",
"push",
"(",
"this",
")",
";",
"}",
"}",
")",
",",
"0",
")",
";",
"}"
] |
Shows form with editable controls.
@method $show()
@memberOf editable-form
|
[
"Shows",
"form",
"with",
"editable",
"controls",
"."
] |
257ad977266d093bf853b328690ec0d670dbe4f2
|
https://github.com/vitalets/angular-xeditable/blob/257ad977266d093bf853b328690ec0d670dbe4f2/dist/js/xeditable.js#L1558-L1595
|
|
16,736
|
vitalets/angular-xeditable
|
dist/js/xeditable.js
|
function(name, msg) {
angular.forEach(this.$editables, function(editable) {
if(!name || editable.name === name) {
editable.setError(msg);
}
});
}
|
javascript
|
function(name, msg) {
angular.forEach(this.$editables, function(editable) {
if(!name || editable.name === name) {
editable.setError(msg);
}
});
}
|
[
"function",
"(",
"name",
",",
"msg",
")",
"{",
"angular",
".",
"forEach",
"(",
"this",
".",
"$editables",
",",
"function",
"(",
"editable",
")",
"{",
"if",
"(",
"!",
"name",
"||",
"editable",
".",
"name",
"===",
"name",
")",
"{",
"editable",
".",
"setError",
"(",
"msg",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Shows error message for particular field.
@method $setError(name, msg)
@param {string} name name of field
@param {string} msg error message
@memberOf editable-form
|
[
"Shows",
"error",
"message",
"for",
"particular",
"field",
"."
] |
257ad977266d093bf853b328690ec0d670dbe4f2
|
https://github.com/vitalets/angular-xeditable/blob/257ad977266d093bf853b328690ec0d670dbe4f2/dist/js/xeditable.js#L1700-L1706
|
|
16,737
|
vitalets/angular-xeditable
|
dist/js/xeditable.js
|
getNearest
|
function getNearest($select, value) {
var delta = {};
angular.forEach($select.children('option'), function(opt, i){
var optValue = angular.element(opt).attr('value');
if(optValue === '') return;
var distance = Math.abs(optValue - value);
if(typeof delta.distance === 'undefined' || distance < delta.distance) {
delta = {value: optValue, distance: distance};
}
});
return delta.value;
}
|
javascript
|
function getNearest($select, value) {
var delta = {};
angular.forEach($select.children('option'), function(opt, i){
var optValue = angular.element(opt).attr('value');
if(optValue === '') return;
var distance = Math.abs(optValue - value);
if(typeof delta.distance === 'undefined' || distance < delta.distance) {
delta = {value: optValue, distance: distance};
}
});
return delta.value;
}
|
[
"function",
"getNearest",
"(",
"$select",
",",
"value",
")",
"{",
"var",
"delta",
"=",
"{",
"}",
";",
"angular",
".",
"forEach",
"(",
"$select",
".",
"children",
"(",
"'option'",
")",
",",
"function",
"(",
"opt",
",",
"i",
")",
"{",
"var",
"optValue",
"=",
"angular",
".",
"element",
"(",
"opt",
")",
".",
"attr",
"(",
"'value'",
")",
";",
"if",
"(",
"optValue",
"===",
"''",
")",
"return",
";",
"var",
"distance",
"=",
"Math",
".",
"abs",
"(",
"optValue",
"-",
"value",
")",
";",
"if",
"(",
"typeof",
"delta",
".",
"distance",
"===",
"'undefined'",
"||",
"distance",
"<",
"delta",
".",
"distance",
")",
"{",
"delta",
"=",
"{",
"value",
":",
"optValue",
",",
"distance",
":",
"distance",
"}",
";",
"}",
"}",
")",
";",
"return",
"delta",
".",
"value",
";",
"}"
] |
function to find nearest value in select options
|
[
"function",
"to",
"find",
"nearest",
"value",
"in",
"select",
"options"
] |
257ad977266d093bf853b328690ec0d670dbe4f2
|
https://github.com/vitalets/angular-xeditable/blob/257ad977266d093bf853b328690ec0d670dbe4f2/dist/js/xeditable.js#L2500-L2512
|
16,738
|
libp2p/js-libp2p-kad-dht
|
src/providers.js
|
writeProviderEntry
|
function writeProviderEntry (store, cid, peer, time, callback) {
const dsKey = [
makeProviderKey(cid),
'/',
utils.encodeBase32(peer.id)
].join('')
store.put(new Key(dsKey), Buffer.from(varint.encode(time)), callback)
}
|
javascript
|
function writeProviderEntry (store, cid, peer, time, callback) {
const dsKey = [
makeProviderKey(cid),
'/',
utils.encodeBase32(peer.id)
].join('')
store.put(new Key(dsKey), Buffer.from(varint.encode(time)), callback)
}
|
[
"function",
"writeProviderEntry",
"(",
"store",
",",
"cid",
",",
"peer",
",",
"time",
",",
"callback",
")",
"{",
"const",
"dsKey",
"=",
"[",
"makeProviderKey",
"(",
"cid",
")",
",",
"'/'",
",",
"utils",
".",
"encodeBase32",
"(",
"peer",
".",
"id",
")",
"]",
".",
"join",
"(",
"''",
")",
"store",
".",
"put",
"(",
"new",
"Key",
"(",
"dsKey",
")",
",",
"Buffer",
".",
"from",
"(",
"varint",
".",
"encode",
"(",
"time",
")",
")",
",",
"callback",
")",
"}"
] |
Write a provider into the given store.
@param {Datastore} store
@param {CID} cid
@param {PeerId} peer
@param {number} time
@param {function(Error)} callback
@returns {undefined}
@private
|
[
"Write",
"a",
"provider",
"into",
"the",
"given",
"store",
"."
] |
18ac394245419d453f017c8407127e55fcde3edd
|
https://github.com/libp2p/js-libp2p-kad-dht/blob/18ac394245419d453f017c8407127e55fcde3edd/src/providers.js#L297-L305
|
16,739
|
libp2p/js-libp2p-kad-dht
|
src/providers.js
|
loadProviders
|
function loadProviders (store, cid, callback) {
pull(
store.query({ prefix: makeProviderKey(cid) }),
pull.map((entry) => {
const parts = entry.key.toString().split('/')
const lastPart = parts[parts.length - 1]
const rawPeerId = utils.decodeBase32(lastPart)
return [new PeerId(rawPeerId), readTime(entry.value)]
}),
pull.collect((err, res) => {
if (err) {
return callback(err)
}
return callback(null, new Map(res))
})
)
}
|
javascript
|
function loadProviders (store, cid, callback) {
pull(
store.query({ prefix: makeProviderKey(cid) }),
pull.map((entry) => {
const parts = entry.key.toString().split('/')
const lastPart = parts[parts.length - 1]
const rawPeerId = utils.decodeBase32(lastPart)
return [new PeerId(rawPeerId), readTime(entry.value)]
}),
pull.collect((err, res) => {
if (err) {
return callback(err)
}
return callback(null, new Map(res))
})
)
}
|
[
"function",
"loadProviders",
"(",
"store",
",",
"cid",
",",
"callback",
")",
"{",
"pull",
"(",
"store",
".",
"query",
"(",
"{",
"prefix",
":",
"makeProviderKey",
"(",
"cid",
")",
"}",
")",
",",
"pull",
".",
"map",
"(",
"(",
"entry",
")",
"=>",
"{",
"const",
"parts",
"=",
"entry",
".",
"key",
".",
"toString",
"(",
")",
".",
"split",
"(",
"'/'",
")",
"const",
"lastPart",
"=",
"parts",
"[",
"parts",
".",
"length",
"-",
"1",
"]",
"const",
"rawPeerId",
"=",
"utils",
".",
"decodeBase32",
"(",
"lastPart",
")",
"return",
"[",
"new",
"PeerId",
"(",
"rawPeerId",
")",
",",
"readTime",
"(",
"entry",
".",
"value",
")",
"]",
"}",
")",
",",
"pull",
".",
"collect",
"(",
"(",
"err",
",",
"res",
")",
"=>",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"callback",
"(",
"err",
")",
"}",
"return",
"callback",
"(",
"null",
",",
"new",
"Map",
"(",
"res",
")",
")",
"}",
")",
")",
"}"
] |
Load providers from the store.
@param {Datastore} store
@param {CID} cid
@param {function(Error, Map<PeerId, Date>)} callback
@returns {undefined}
@private
|
[
"Load",
"providers",
"from",
"the",
"store",
"."
] |
18ac394245419d453f017c8407127e55fcde3edd
|
https://github.com/libp2p/js-libp2p-kad-dht/blob/18ac394245419d453f017c8407127e55fcde3edd/src/providers.js#L317-L334
|
16,740
|
libp2p/js-libp2p-kad-dht
|
src/rpc/index.js
|
handleMessage
|
function handleMessage (peer, msg, callback) {
// update the peer
dht._add(peer, (err) => {
if (err) {
log.error('Failed to update the kbucket store')
log.error(err)
}
// get handler & exectue it
const handler = getMessageHandler(msg.type)
if (!handler) {
log.error(`no handler found for message type: ${msg.type}`)
return callback()
}
handler(peer, msg, callback)
})
}
|
javascript
|
function handleMessage (peer, msg, callback) {
// update the peer
dht._add(peer, (err) => {
if (err) {
log.error('Failed to update the kbucket store')
log.error(err)
}
// get handler & exectue it
const handler = getMessageHandler(msg.type)
if (!handler) {
log.error(`no handler found for message type: ${msg.type}`)
return callback()
}
handler(peer, msg, callback)
})
}
|
[
"function",
"handleMessage",
"(",
"peer",
",",
"msg",
",",
"callback",
")",
"{",
"// update the peer",
"dht",
".",
"_add",
"(",
"peer",
",",
"(",
"err",
")",
"=>",
"{",
"if",
"(",
"err",
")",
"{",
"log",
".",
"error",
"(",
"'Failed to update the kbucket store'",
")",
"log",
".",
"error",
"(",
"err",
")",
"}",
"// get handler & exectue it",
"const",
"handler",
"=",
"getMessageHandler",
"(",
"msg",
".",
"type",
")",
"if",
"(",
"!",
"handler",
")",
"{",
"log",
".",
"error",
"(",
"`",
"${",
"msg",
".",
"type",
"}",
"`",
")",
"return",
"callback",
"(",
")",
"}",
"handler",
"(",
"peer",
",",
"msg",
",",
"callback",
")",
"}",
")",
"}"
] |
Process incoming DHT messages.
@param {PeerInfo} peer
@param {Message} msg
@param {function(Error, Message)} callback
@returns {void}
@private
|
[
"Process",
"incoming",
"DHT",
"messages",
"."
] |
18ac394245419d453f017c8407127e55fcde3edd
|
https://github.com/libp2p/js-libp2p-kad-dht/blob/18ac394245419d453f017c8407127e55fcde3edd/src/rpc/index.js#L25-L43
|
16,741
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function () {
this.writeDebug('reset');
locationset = [];
featuredset = [];
normalset = [];
markers = [];
firstRun = false;
$(document).off('click.'+pluginName, '.' + this.settings.locationList + ' li');
if ( $('.' + this.settings.locationList + ' .bh-sl-close-directions-container').length ) {
$('.bh-sl-close-directions-container').remove();
}
if (this.settings.inlineDirections === true) {
// Remove directions panel if it's there
var $adp = $('.' + this.settings.locationList + ' .adp');
if ( $adp.length > 0 ) {
$adp.remove();
$('.' + this.settings.locationList + ' ul').fadeIn();
}
$(document).off('click', '.' + this.settings.locationList + ' li .loc-directions a');
}
if (this.settings.pagination === true) {
$(document).off('click.'+pluginName, '.bh-sl-pagination li');
}
}
|
javascript
|
function () {
this.writeDebug('reset');
locationset = [];
featuredset = [];
normalset = [];
markers = [];
firstRun = false;
$(document).off('click.'+pluginName, '.' + this.settings.locationList + ' li');
if ( $('.' + this.settings.locationList + ' .bh-sl-close-directions-container').length ) {
$('.bh-sl-close-directions-container').remove();
}
if (this.settings.inlineDirections === true) {
// Remove directions panel if it's there
var $adp = $('.' + this.settings.locationList + ' .adp');
if ( $adp.length > 0 ) {
$adp.remove();
$('.' + this.settings.locationList + ' ul').fadeIn();
}
$(document).off('click', '.' + this.settings.locationList + ' li .loc-directions a');
}
if (this.settings.pagination === true) {
$(document).off('click.'+pluginName, '.bh-sl-pagination li');
}
}
|
[
"function",
"(",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'reset'",
")",
";",
"locationset",
"=",
"[",
"]",
";",
"featuredset",
"=",
"[",
"]",
";",
"normalset",
"=",
"[",
"]",
";",
"markers",
"=",
"[",
"]",
";",
"firstRun",
"=",
"false",
";",
"$",
"(",
"document",
")",
".",
"off",
"(",
"'click.'",
"+",
"pluginName",
",",
"'.'",
"+",
"this",
".",
"settings",
".",
"locationList",
"+",
"' li'",
")",
";",
"if",
"(",
"$",
"(",
"'.'",
"+",
"this",
".",
"settings",
".",
"locationList",
"+",
"' .bh-sl-close-directions-container'",
")",
".",
"length",
")",
"{",
"$",
"(",
"'.bh-sl-close-directions-container'",
")",
".",
"remove",
"(",
")",
";",
"}",
"if",
"(",
"this",
".",
"settings",
".",
"inlineDirections",
"===",
"true",
")",
"{",
"// Remove directions panel if it's there",
"var",
"$adp",
"=",
"$",
"(",
"'.'",
"+",
"this",
".",
"settings",
".",
"locationList",
"+",
"' .adp'",
")",
";",
"if",
"(",
"$adp",
".",
"length",
">",
"0",
")",
"{",
"$adp",
".",
"remove",
"(",
")",
";",
"$",
"(",
"'.'",
"+",
"this",
".",
"settings",
".",
"locationList",
"+",
"' ul'",
")",
".",
"fadeIn",
"(",
")",
";",
"}",
"$",
"(",
"document",
")",
".",
"off",
"(",
"'click'",
",",
"'.'",
"+",
"this",
".",
"settings",
".",
"locationList",
"+",
"' li .loc-directions a'",
")",
";",
"}",
"if",
"(",
"this",
".",
"settings",
".",
"pagination",
"===",
"true",
")",
"{",
"$",
"(",
"document",
")",
".",
"off",
"(",
"'click.'",
"+",
"pluginName",
",",
"'.bh-sl-pagination li'",
")",
";",
"}",
"}"
] |
Reset function
This method clears out all the variables and removes events. It does not reload the map.
|
[
"Reset",
"function",
"This",
"method",
"clears",
"out",
"all",
"the",
"variables",
"and",
"removes",
"events",
".",
"It",
"does",
"not",
"reload",
"the",
"map",
"."
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L280-L306
|
|
16,742
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function () {
this.writeDebug('formFiltersReset');
if (this.settings.taxonomyFilters === null) {
return;
}
var $inputs = $('.' + this.settings.taxonomyFiltersContainer + ' input'),
$selects = $('.' + this.settings.taxonomyFiltersContainer + ' select');
if ( typeof($inputs) !== 'object') {
return;
}
// Loop over the input fields
$inputs.each(function() {
if ($(this).is('input[type="checkbox"]') || $(this).is('input[type="radio"]')) {
$(this).prop('checked',false);
}
});
// Loop over select fields
$selects.each(function() {
$(this).prop('selectedIndex',0);
});
}
|
javascript
|
function () {
this.writeDebug('formFiltersReset');
if (this.settings.taxonomyFilters === null) {
return;
}
var $inputs = $('.' + this.settings.taxonomyFiltersContainer + ' input'),
$selects = $('.' + this.settings.taxonomyFiltersContainer + ' select');
if ( typeof($inputs) !== 'object') {
return;
}
// Loop over the input fields
$inputs.each(function() {
if ($(this).is('input[type="checkbox"]') || $(this).is('input[type="radio"]')) {
$(this).prop('checked',false);
}
});
// Loop over select fields
$selects.each(function() {
$(this).prop('selectedIndex',0);
});
}
|
[
"function",
"(",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'formFiltersReset'",
")",
";",
"if",
"(",
"this",
".",
"settings",
".",
"taxonomyFilters",
"===",
"null",
")",
"{",
"return",
";",
"}",
"var",
"$inputs",
"=",
"$",
"(",
"'.'",
"+",
"this",
".",
"settings",
".",
"taxonomyFiltersContainer",
"+",
"' input'",
")",
",",
"$selects",
"=",
"$",
"(",
"'.'",
"+",
"this",
".",
"settings",
".",
"taxonomyFiltersContainer",
"+",
"' select'",
")",
";",
"if",
"(",
"typeof",
"(",
"$inputs",
")",
"!==",
"'object'",
")",
"{",
"return",
";",
"}",
"// Loop over the input fields",
"$inputs",
".",
"each",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"$",
"(",
"this",
")",
".",
"is",
"(",
"'input[type=\"checkbox\"]'",
")",
"||",
"$",
"(",
"this",
")",
".",
"is",
"(",
"'input[type=\"radio\"]'",
")",
")",
"{",
"$",
"(",
"this",
")",
".",
"prop",
"(",
"'checked'",
",",
"false",
")",
";",
"}",
"}",
")",
";",
"// Loop over select fields",
"$selects",
".",
"each",
"(",
"function",
"(",
")",
"{",
"$",
"(",
"this",
")",
".",
"prop",
"(",
"'selectedIndex'",
",",
"0",
")",
";",
"}",
")",
";",
"}"
] |
Reset the form filters
|
[
"Reset",
"the",
"form",
"filters"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L311-L335
|
|
16,743
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function() {
this.writeDebug('mapReload');
this.reset();
reload = true;
if ( this.settings.taxonomyFilters !== null ) {
this.formFiltersReset();
this.taxonomyFiltersInit();
}
if ((olat) && (olng)) {
this.settings.mapSettings.zoom = originalZoom;
this.processForm();
}
else {
this.mapping(mappingObj);
}
}
|
javascript
|
function() {
this.writeDebug('mapReload');
this.reset();
reload = true;
if ( this.settings.taxonomyFilters !== null ) {
this.formFiltersReset();
this.taxonomyFiltersInit();
}
if ((olat) && (olng)) {
this.settings.mapSettings.zoom = originalZoom;
this.processForm();
}
else {
this.mapping(mappingObj);
}
}
|
[
"function",
"(",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'mapReload'",
")",
";",
"this",
".",
"reset",
"(",
")",
";",
"reload",
"=",
"true",
";",
"if",
"(",
"this",
".",
"settings",
".",
"taxonomyFilters",
"!==",
"null",
")",
"{",
"this",
".",
"formFiltersReset",
"(",
")",
";",
"this",
".",
"taxonomyFiltersInit",
"(",
")",
";",
"}",
"if",
"(",
"(",
"olat",
")",
"&&",
"(",
"olng",
")",
")",
"{",
"this",
".",
"settings",
".",
"mapSettings",
".",
"zoom",
"=",
"originalZoom",
";",
"this",
".",
"processForm",
"(",
")",
";",
"}",
"else",
"{",
"this",
".",
"mapping",
"(",
"mappingObj",
")",
";",
"}",
"}"
] |
Reload everything
This method does a reset of everything and reloads the map as it would first appear.
|
[
"Reload",
"everything",
"This",
"method",
"does",
"a",
"reset",
"of",
"everything",
"and",
"reloads",
"the",
"map",
"as",
"it",
"would",
"first",
"appear",
"."
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L341-L358
|
|
16,744
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function (notifyText) {
this.writeDebug('notify',notifyText);
if (this.settings.callbackNotify) {
this.settings.callbackNotify.call(this, notifyText);
}
else {
alert(notifyText);
}
}
|
javascript
|
function (notifyText) {
this.writeDebug('notify',notifyText);
if (this.settings.callbackNotify) {
this.settings.callbackNotify.call(this, notifyText);
}
else {
alert(notifyText);
}
}
|
[
"function",
"(",
"notifyText",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'notify'",
",",
"notifyText",
")",
";",
"if",
"(",
"this",
".",
"settings",
".",
"callbackNotify",
")",
"{",
"this",
".",
"settings",
".",
"callbackNotify",
".",
"call",
"(",
"this",
",",
"notifyText",
")",
";",
"}",
"else",
"{",
"alert",
"(",
"notifyText",
")",
";",
"}",
"}"
] |
Notifications
Some errors use alert by default. This is overridable with the callbackNotify option
@param notifyText {string} the notification message
|
[
"Notifications",
"Some",
"errors",
"use",
"alert",
"by",
"default",
".",
"This",
"is",
"overridable",
"with",
"the",
"callbackNotify",
"option"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L366-L374
|
|
16,745
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function(param) {
this.writeDebug('getQueryString',param);
if(param) {
param = param.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + param + '=([^&#]*)'),
results = regex.exec(location.search);
return (results === null) ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
}
}
|
javascript
|
function(param) {
this.writeDebug('getQueryString',param);
if(param) {
param = param.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + param + '=([^&#]*)'),
results = regex.exec(location.search);
return (results === null) ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
}
}
|
[
"function",
"(",
"param",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'getQueryString'",
",",
"param",
")",
";",
"if",
"(",
"param",
")",
"{",
"param",
"=",
"param",
".",
"replace",
"(",
"/",
"[\\[]",
"/",
",",
"'\\\\['",
")",
".",
"replace",
"(",
"/",
"[\\]]",
"/",
",",
"'\\\\]'",
")",
";",
"var",
"regex",
"=",
"new",
"RegExp",
"(",
"'[\\\\?&]'",
"+",
"param",
"+",
"'=([^&#]*)'",
")",
",",
"results",
"=",
"regex",
".",
"exec",
"(",
"location",
".",
"search",
")",
";",
"return",
"(",
"results",
"===",
"null",
")",
"?",
"''",
":",
"decodeURIComponent",
"(",
"results",
"[",
"1",
"]",
".",
"replace",
"(",
"/",
"\\+",
"/",
"g",
",",
"' '",
")",
")",
";",
"}",
"}"
] |
Check for query string
@param param {string} query string parameter to test
@returns {string} query string value
|
[
"Check",
"for",
"query",
"string"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L398-L406
|
|
16,746
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function () {
this.writeDebug('_formEventHandler');
var _this = this;
// ASP.net or regular submission?
if (this.settings.noForm === true) {
$(document).on('click.'+pluginName, '.' + this.settings.formContainer + ' button', function (e) {
_this.processForm(e);
});
$(document).on('keydown.'+pluginName, function (e) {
if (e.keyCode === 13 && $('#' + _this.settings.addressID).is(':focus')) {
_this.processForm(e);
}
});
}
else {
$(document).on('submit.'+pluginName, '#' + this.settings.formID, function (e) {
_this.processForm(e);
});
}
// Reset button trigger
if ($('.bh-sl-reset').length && $('#' + this.settings.mapID).length) {
$(document).on('click.' + pluginName, '.bh-sl-reset', function () {
_this.mapReload();
});
}
}
|
javascript
|
function () {
this.writeDebug('_formEventHandler');
var _this = this;
// ASP.net or regular submission?
if (this.settings.noForm === true) {
$(document).on('click.'+pluginName, '.' + this.settings.formContainer + ' button', function (e) {
_this.processForm(e);
});
$(document).on('keydown.'+pluginName, function (e) {
if (e.keyCode === 13 && $('#' + _this.settings.addressID).is(':focus')) {
_this.processForm(e);
}
});
}
else {
$(document).on('submit.'+pluginName, '#' + this.settings.formID, function (e) {
_this.processForm(e);
});
}
// Reset button trigger
if ($('.bh-sl-reset').length && $('#' + this.settings.mapID).length) {
$(document).on('click.' + pluginName, '.bh-sl-reset', function () {
_this.mapReload();
});
}
}
|
[
"function",
"(",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'_formEventHandler'",
")",
";",
"var",
"_this",
"=",
"this",
";",
"// ASP.net or regular submission?",
"if",
"(",
"this",
".",
"settings",
".",
"noForm",
"===",
"true",
")",
"{",
"$",
"(",
"document",
")",
".",
"on",
"(",
"'click.'",
"+",
"pluginName",
",",
"'.'",
"+",
"this",
".",
"settings",
".",
"formContainer",
"+",
"' button'",
",",
"function",
"(",
"e",
")",
"{",
"_this",
".",
"processForm",
"(",
"e",
")",
";",
"}",
")",
";",
"$",
"(",
"document",
")",
".",
"on",
"(",
"'keydown.'",
"+",
"pluginName",
",",
"function",
"(",
"e",
")",
"{",
"if",
"(",
"e",
".",
"keyCode",
"===",
"13",
"&&",
"$",
"(",
"'#'",
"+",
"_this",
".",
"settings",
".",
"addressID",
")",
".",
"is",
"(",
"':focus'",
")",
")",
"{",
"_this",
".",
"processForm",
"(",
"e",
")",
";",
"}",
"}",
")",
";",
"}",
"else",
"{",
"$",
"(",
"document",
")",
".",
"on",
"(",
"'submit.'",
"+",
"pluginName",
",",
"'#'",
"+",
"this",
".",
"settings",
".",
"formID",
",",
"function",
"(",
"e",
")",
"{",
"_this",
".",
"processForm",
"(",
"e",
")",
";",
"}",
")",
";",
"}",
"// Reset button trigger",
"if",
"(",
"$",
"(",
"'.bh-sl-reset'",
")",
".",
"length",
"&&",
"$",
"(",
"'#'",
"+",
"this",
".",
"settings",
".",
"mapID",
")",
".",
"length",
")",
"{",
"$",
"(",
"document",
")",
".",
"on",
"(",
"'click.'",
"+",
"pluginName",
",",
"'.bh-sl-reset'",
",",
"function",
"(",
")",
"{",
"_this",
".",
"mapReload",
"(",
")",
";",
"}",
")",
";",
"}",
"}"
] |
Form event handler setup - private
|
[
"Form",
"event",
"handler",
"setup",
"-",
"private"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L506-L532
|
|
16,747
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function (lat, lng, address, geocodeData, map) {
this.writeDebug('_getData',arguments);
var _this = this,
northEast = '',
southWest = '',
formattedAddress = '';
// Define extra geocode result info
if (typeof geocodeData !== 'undefined' && typeof geocodeData.geometry.bounds !== 'undefined') {
formattedAddress = geocodeData.formatted_address;
northEast = JSON.stringify( geocodeData.geometry.bounds.getNorthEast() );
southWest = JSON.stringify( geocodeData.geometry.bounds.getSouthWest() );
}
// Before send callback
if (this.settings.callbackBeforeSend) {
this.settings.callbackBeforeSend.call(this, lat, lng, address, formattedAddress, northEast, southWest, map);
}
// Raw data
if(_this.settings.dataRaw !== null) {
// XML
if( dataTypeRead === 'xml' ) {
return $.parseXML(_this.settings.dataRaw);
}
// JSON
else if (dataTypeRead === 'json') {
if (Array.isArray && Array.isArray(_this.settings.dataRaw)) {
return _this.settings.dataRaw;
}
else if (typeof _this.settings.dataRaw === 'string') {
return JSON.parse(_this.settings.dataRaw);
}
else {
return [];
}
}
}
// Remote data
else {
var d = $.Deferred();
// Loading
if (this.settings.loading === true) {
$('.' + this.settings.formContainer).append('<div class="' + this.settings.loadingContainer +'"></div>');
}
// Data to pass with the AJAX request
var ajaxData = {
'origLat' : lat,
'origLng' : lng,
'origAddress': address,
'formattedAddress': formattedAddress,
'boundsNorthEast' : northEast,
'boundsSouthWest' : southWest
};
// Set up extra object for custom extra data to be passed with the AJAX request
if (this.settings.ajaxData !== null && typeof this.settings.ajaxData === 'object') {
$.extend(ajaxData, this.settings.ajaxData);
}
// AJAX request
$.ajax({
type : 'GET',
url : this.settings.dataLocation + (this.settings.dataType === 'jsonp' ? (this.settings.dataLocation.match(/\?/) ? '&' : '?') + 'callback=?' : ''),
// Passing the lat, lng, address, formatted address and bounds with the AJAX request so they can optionally be used by back-end languages
data : ajaxData,
dataType : dataTypeRead,
jsonpCallback: (this.settings.dataType === 'jsonp' ? this.settings.callbackJsonp : null)
}).done(function(p) {
d.resolve(p);
// Loading remove
if (_this.settings.loading === true) {
$('.' + _this.settings.formContainer + ' .' + _this.settings.loadingContainer).remove();
}
}).fail(d.reject);
return d.promise();
}
}
|
javascript
|
function (lat, lng, address, geocodeData, map) {
this.writeDebug('_getData',arguments);
var _this = this,
northEast = '',
southWest = '',
formattedAddress = '';
// Define extra geocode result info
if (typeof geocodeData !== 'undefined' && typeof geocodeData.geometry.bounds !== 'undefined') {
formattedAddress = geocodeData.formatted_address;
northEast = JSON.stringify( geocodeData.geometry.bounds.getNorthEast() );
southWest = JSON.stringify( geocodeData.geometry.bounds.getSouthWest() );
}
// Before send callback
if (this.settings.callbackBeforeSend) {
this.settings.callbackBeforeSend.call(this, lat, lng, address, formattedAddress, northEast, southWest, map);
}
// Raw data
if(_this.settings.dataRaw !== null) {
// XML
if( dataTypeRead === 'xml' ) {
return $.parseXML(_this.settings.dataRaw);
}
// JSON
else if (dataTypeRead === 'json') {
if (Array.isArray && Array.isArray(_this.settings.dataRaw)) {
return _this.settings.dataRaw;
}
else if (typeof _this.settings.dataRaw === 'string') {
return JSON.parse(_this.settings.dataRaw);
}
else {
return [];
}
}
}
// Remote data
else {
var d = $.Deferred();
// Loading
if (this.settings.loading === true) {
$('.' + this.settings.formContainer).append('<div class="' + this.settings.loadingContainer +'"></div>');
}
// Data to pass with the AJAX request
var ajaxData = {
'origLat' : lat,
'origLng' : lng,
'origAddress': address,
'formattedAddress': formattedAddress,
'boundsNorthEast' : northEast,
'boundsSouthWest' : southWest
};
// Set up extra object for custom extra data to be passed with the AJAX request
if (this.settings.ajaxData !== null && typeof this.settings.ajaxData === 'object') {
$.extend(ajaxData, this.settings.ajaxData);
}
// AJAX request
$.ajax({
type : 'GET',
url : this.settings.dataLocation + (this.settings.dataType === 'jsonp' ? (this.settings.dataLocation.match(/\?/) ? '&' : '?') + 'callback=?' : ''),
// Passing the lat, lng, address, formatted address and bounds with the AJAX request so they can optionally be used by back-end languages
data : ajaxData,
dataType : dataTypeRead,
jsonpCallback: (this.settings.dataType === 'jsonp' ? this.settings.callbackJsonp : null)
}).done(function(p) {
d.resolve(p);
// Loading remove
if (_this.settings.loading === true) {
$('.' + _this.settings.formContainer + ' .' + _this.settings.loadingContainer).remove();
}
}).fail(d.reject);
return d.promise();
}
}
|
[
"function",
"(",
"lat",
",",
"lng",
",",
"address",
",",
"geocodeData",
",",
"map",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'_getData'",
",",
"arguments",
")",
";",
"var",
"_this",
"=",
"this",
",",
"northEast",
"=",
"''",
",",
"southWest",
"=",
"''",
",",
"formattedAddress",
"=",
"''",
";",
"// Define extra geocode result info",
"if",
"(",
"typeof",
"geocodeData",
"!==",
"'undefined'",
"&&",
"typeof",
"geocodeData",
".",
"geometry",
".",
"bounds",
"!==",
"'undefined'",
")",
"{",
"formattedAddress",
"=",
"geocodeData",
".",
"formatted_address",
";",
"northEast",
"=",
"JSON",
".",
"stringify",
"(",
"geocodeData",
".",
"geometry",
".",
"bounds",
".",
"getNorthEast",
"(",
")",
")",
";",
"southWest",
"=",
"JSON",
".",
"stringify",
"(",
"geocodeData",
".",
"geometry",
".",
"bounds",
".",
"getSouthWest",
"(",
")",
")",
";",
"}",
"// Before send callback",
"if",
"(",
"this",
".",
"settings",
".",
"callbackBeforeSend",
")",
"{",
"this",
".",
"settings",
".",
"callbackBeforeSend",
".",
"call",
"(",
"this",
",",
"lat",
",",
"lng",
",",
"address",
",",
"formattedAddress",
",",
"northEast",
",",
"southWest",
",",
"map",
")",
";",
"}",
"// Raw data",
"if",
"(",
"_this",
".",
"settings",
".",
"dataRaw",
"!==",
"null",
")",
"{",
"// XML",
"if",
"(",
"dataTypeRead",
"===",
"'xml'",
")",
"{",
"return",
"$",
".",
"parseXML",
"(",
"_this",
".",
"settings",
".",
"dataRaw",
")",
";",
"}",
"// JSON",
"else",
"if",
"(",
"dataTypeRead",
"===",
"'json'",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"&&",
"Array",
".",
"isArray",
"(",
"_this",
".",
"settings",
".",
"dataRaw",
")",
")",
"{",
"return",
"_this",
".",
"settings",
".",
"dataRaw",
";",
"}",
"else",
"if",
"(",
"typeof",
"_this",
".",
"settings",
".",
"dataRaw",
"===",
"'string'",
")",
"{",
"return",
"JSON",
".",
"parse",
"(",
"_this",
".",
"settings",
".",
"dataRaw",
")",
";",
"}",
"else",
"{",
"return",
"[",
"]",
";",
"}",
"}",
"}",
"// Remote data",
"else",
"{",
"var",
"d",
"=",
"$",
".",
"Deferred",
"(",
")",
";",
"// Loading",
"if",
"(",
"this",
".",
"settings",
".",
"loading",
"===",
"true",
")",
"{",
"$",
"(",
"'.'",
"+",
"this",
".",
"settings",
".",
"formContainer",
")",
".",
"append",
"(",
"'<div class=\"'",
"+",
"this",
".",
"settings",
".",
"loadingContainer",
"+",
"'\"></div>'",
")",
";",
"}",
"// Data to pass with the AJAX request",
"var",
"ajaxData",
"=",
"{",
"'origLat'",
":",
"lat",
",",
"'origLng'",
":",
"lng",
",",
"'origAddress'",
":",
"address",
",",
"'formattedAddress'",
":",
"formattedAddress",
",",
"'boundsNorthEast'",
":",
"northEast",
",",
"'boundsSouthWest'",
":",
"southWest",
"}",
";",
"// Set up extra object for custom extra data to be passed with the AJAX request",
"if",
"(",
"this",
".",
"settings",
".",
"ajaxData",
"!==",
"null",
"&&",
"typeof",
"this",
".",
"settings",
".",
"ajaxData",
"===",
"'object'",
")",
"{",
"$",
".",
"extend",
"(",
"ajaxData",
",",
"this",
".",
"settings",
".",
"ajaxData",
")",
";",
"}",
"// AJAX request",
"$",
".",
"ajax",
"(",
"{",
"type",
":",
"'GET'",
",",
"url",
":",
"this",
".",
"settings",
".",
"dataLocation",
"+",
"(",
"this",
".",
"settings",
".",
"dataType",
"===",
"'jsonp'",
"?",
"(",
"this",
".",
"settings",
".",
"dataLocation",
".",
"match",
"(",
"/",
"\\?",
"/",
")",
"?",
"'&'",
":",
"'?'",
")",
"+",
"'callback=?'",
":",
"''",
")",
",",
"// Passing the lat, lng, address, formatted address and bounds with the AJAX request so they can optionally be used by back-end languages",
"data",
":",
"ajaxData",
",",
"dataType",
":",
"dataTypeRead",
",",
"jsonpCallback",
":",
"(",
"this",
".",
"settings",
".",
"dataType",
"===",
"'jsonp'",
"?",
"this",
".",
"settings",
".",
"callbackJsonp",
":",
"null",
")",
"}",
")",
".",
"done",
"(",
"function",
"(",
"p",
")",
"{",
"d",
".",
"resolve",
"(",
"p",
")",
";",
"// Loading remove",
"if",
"(",
"_this",
".",
"settings",
".",
"loading",
"===",
"true",
")",
"{",
"$",
"(",
"'.'",
"+",
"_this",
".",
"settings",
".",
"formContainer",
"+",
"' .'",
"+",
"_this",
".",
"settings",
".",
"loadingContainer",
")",
".",
"remove",
"(",
")",
";",
"}",
"}",
")",
".",
"fail",
"(",
"d",
".",
"reject",
")",
";",
"return",
"d",
".",
"promise",
"(",
")",
";",
"}",
"}"
] |
AJAX data request - private
@param lat {number} latitude
@param lng {number} longitude
@param address {string} street address
@param geocodeData {object} full Google geocode results object
@param map (object} Google Maps object.
@returns {Object} deferred object
|
[
"AJAX",
"data",
"request",
"-",
"private"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L545-L627
|
|
16,748
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function () {
this.writeDebug('_start');
var _this = this,
doAutoGeo = this.settings.autoGeocode,
latlng;
// Full map blank start
if (_this.settings.fullMapStartBlank !== false) {
var $mapDiv = $('#' + _this.settings.mapID);
$mapDiv.addClass('bh-sl-map-open');
var myOptions = _this.settings.mapSettings;
myOptions.zoom = _this.settings.fullMapStartBlank;
latlng = new google.maps.LatLng(this.settings.defaultLat, this.settings.defaultLng);
myOptions.center = latlng;
// Create the map
_this.map = new google.maps.Map(document.getElementById(_this.settings.mapID), myOptions);
// Re-center the map when the browser is re-sized
google.maps.event.addDomListener(window, 'resize', function() {
var center = _this.map.getCenter();
google.maps.event.trigger(_this.map, 'resize');
_this.map.setCenter(center);
});
// Only do this once
_this.settings.fullMapStartBlank = false;
myOptions.zoom = originalZoom;
}
else {
// If a default location is set
if (this.settings.defaultLoc === true) {
this.defaultLocation();
}
// If there is already have a value in the address bar
if ($.trim($('#' + this.settings.addressID).val()) !== ''){
_this.writeDebug('Using Address Field');
_this.processForm(null);
doAutoGeo = false; // No need for additional processing
}
// If show full map option is true
else if (this.settings.fullMapStart === true) {
if ((this.settings.querystringParams === true && this.getQueryString(this.settings.addressID)) || (this.settings.querystringParams === true && this.getQueryString(this.settings.searchID)) || (this.settings.querystringParams === true && this.getQueryString(this.settings.maxDistanceID))) {
_this.writeDebug('Using Query String');
this.processForm(null);
doAutoGeo = false; // No need for additional processing
}
else {
this.mapping(null);
}
}
}
// HTML5 auto geolocation API option
if (this.settings.autoGeocode === true && doAutoGeo === true) {
_this.writeDebug('Auto Geo');
_this.htmlGeocode();
}
// HTML5 geolocation API button option
if (this.settings.autoGeocode !== null) {
_this.writeDebug('Button Geo');
$(document).on('click.'+pluginName, '#' + this.settings.geocodeID, function () {
_this.htmlGeocode();
});
}
}
|
javascript
|
function () {
this.writeDebug('_start');
var _this = this,
doAutoGeo = this.settings.autoGeocode,
latlng;
// Full map blank start
if (_this.settings.fullMapStartBlank !== false) {
var $mapDiv = $('#' + _this.settings.mapID);
$mapDiv.addClass('bh-sl-map-open');
var myOptions = _this.settings.mapSettings;
myOptions.zoom = _this.settings.fullMapStartBlank;
latlng = new google.maps.LatLng(this.settings.defaultLat, this.settings.defaultLng);
myOptions.center = latlng;
// Create the map
_this.map = new google.maps.Map(document.getElementById(_this.settings.mapID), myOptions);
// Re-center the map when the browser is re-sized
google.maps.event.addDomListener(window, 'resize', function() {
var center = _this.map.getCenter();
google.maps.event.trigger(_this.map, 'resize');
_this.map.setCenter(center);
});
// Only do this once
_this.settings.fullMapStartBlank = false;
myOptions.zoom = originalZoom;
}
else {
// If a default location is set
if (this.settings.defaultLoc === true) {
this.defaultLocation();
}
// If there is already have a value in the address bar
if ($.trim($('#' + this.settings.addressID).val()) !== ''){
_this.writeDebug('Using Address Field');
_this.processForm(null);
doAutoGeo = false; // No need for additional processing
}
// If show full map option is true
else if (this.settings.fullMapStart === true) {
if ((this.settings.querystringParams === true && this.getQueryString(this.settings.addressID)) || (this.settings.querystringParams === true && this.getQueryString(this.settings.searchID)) || (this.settings.querystringParams === true && this.getQueryString(this.settings.maxDistanceID))) {
_this.writeDebug('Using Query String');
this.processForm(null);
doAutoGeo = false; // No need for additional processing
}
else {
this.mapping(null);
}
}
}
// HTML5 auto geolocation API option
if (this.settings.autoGeocode === true && doAutoGeo === true) {
_this.writeDebug('Auto Geo');
_this.htmlGeocode();
}
// HTML5 geolocation API button option
if (this.settings.autoGeocode !== null) {
_this.writeDebug('Button Geo');
$(document).on('click.'+pluginName, '#' + this.settings.geocodeID, function () {
_this.htmlGeocode();
});
}
}
|
[
"function",
"(",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'_start'",
")",
";",
"var",
"_this",
"=",
"this",
",",
"doAutoGeo",
"=",
"this",
".",
"settings",
".",
"autoGeocode",
",",
"latlng",
";",
"// Full map blank start",
"if",
"(",
"_this",
".",
"settings",
".",
"fullMapStartBlank",
"!==",
"false",
")",
"{",
"var",
"$mapDiv",
"=",
"$",
"(",
"'#'",
"+",
"_this",
".",
"settings",
".",
"mapID",
")",
";",
"$mapDiv",
".",
"addClass",
"(",
"'bh-sl-map-open'",
")",
";",
"var",
"myOptions",
"=",
"_this",
".",
"settings",
".",
"mapSettings",
";",
"myOptions",
".",
"zoom",
"=",
"_this",
".",
"settings",
".",
"fullMapStartBlank",
";",
"latlng",
"=",
"new",
"google",
".",
"maps",
".",
"LatLng",
"(",
"this",
".",
"settings",
".",
"defaultLat",
",",
"this",
".",
"settings",
".",
"defaultLng",
")",
";",
"myOptions",
".",
"center",
"=",
"latlng",
";",
"// Create the map",
"_this",
".",
"map",
"=",
"new",
"google",
".",
"maps",
".",
"Map",
"(",
"document",
".",
"getElementById",
"(",
"_this",
".",
"settings",
".",
"mapID",
")",
",",
"myOptions",
")",
";",
"// Re-center the map when the browser is re-sized",
"google",
".",
"maps",
".",
"event",
".",
"addDomListener",
"(",
"window",
",",
"'resize'",
",",
"function",
"(",
")",
"{",
"var",
"center",
"=",
"_this",
".",
"map",
".",
"getCenter",
"(",
")",
";",
"google",
".",
"maps",
".",
"event",
".",
"trigger",
"(",
"_this",
".",
"map",
",",
"'resize'",
")",
";",
"_this",
".",
"map",
".",
"setCenter",
"(",
"center",
")",
";",
"}",
")",
";",
"// Only do this once",
"_this",
".",
"settings",
".",
"fullMapStartBlank",
"=",
"false",
";",
"myOptions",
".",
"zoom",
"=",
"originalZoom",
";",
"}",
"else",
"{",
"// If a default location is set",
"if",
"(",
"this",
".",
"settings",
".",
"defaultLoc",
"===",
"true",
")",
"{",
"this",
".",
"defaultLocation",
"(",
")",
";",
"}",
"// If there is already have a value in the address bar",
"if",
"(",
"$",
".",
"trim",
"(",
"$",
"(",
"'#'",
"+",
"this",
".",
"settings",
".",
"addressID",
")",
".",
"val",
"(",
")",
")",
"!==",
"''",
")",
"{",
"_this",
".",
"writeDebug",
"(",
"'Using Address Field'",
")",
";",
"_this",
".",
"processForm",
"(",
"null",
")",
";",
"doAutoGeo",
"=",
"false",
";",
"// No need for additional processing",
"}",
"// If show full map option is true",
"else",
"if",
"(",
"this",
".",
"settings",
".",
"fullMapStart",
"===",
"true",
")",
"{",
"if",
"(",
"(",
"this",
".",
"settings",
".",
"querystringParams",
"===",
"true",
"&&",
"this",
".",
"getQueryString",
"(",
"this",
".",
"settings",
".",
"addressID",
")",
")",
"||",
"(",
"this",
".",
"settings",
".",
"querystringParams",
"===",
"true",
"&&",
"this",
".",
"getQueryString",
"(",
"this",
".",
"settings",
".",
"searchID",
")",
")",
"||",
"(",
"this",
".",
"settings",
".",
"querystringParams",
"===",
"true",
"&&",
"this",
".",
"getQueryString",
"(",
"this",
".",
"settings",
".",
"maxDistanceID",
")",
")",
")",
"{",
"_this",
".",
"writeDebug",
"(",
"'Using Query String'",
")",
";",
"this",
".",
"processForm",
"(",
"null",
")",
";",
"doAutoGeo",
"=",
"false",
";",
"// No need for additional processing",
"}",
"else",
"{",
"this",
".",
"mapping",
"(",
"null",
")",
";",
"}",
"}",
"}",
"// HTML5 auto geolocation API option",
"if",
"(",
"this",
".",
"settings",
".",
"autoGeocode",
"===",
"true",
"&&",
"doAutoGeo",
"===",
"true",
")",
"{",
"_this",
".",
"writeDebug",
"(",
"'Auto Geo'",
")",
";",
"_this",
".",
"htmlGeocode",
"(",
")",
";",
"}",
"// HTML5 geolocation API button option",
"if",
"(",
"this",
".",
"settings",
".",
"autoGeocode",
"!==",
"null",
")",
"{",
"_this",
".",
"writeDebug",
"(",
"'Button Geo'",
")",
";",
"$",
"(",
"document",
")",
".",
"on",
"(",
"'click.'",
"+",
"pluginName",
",",
"'#'",
"+",
"this",
".",
"settings",
".",
"geocodeID",
",",
"function",
"(",
")",
"{",
"_this",
".",
"htmlGeocode",
"(",
")",
";",
"}",
")",
";",
"}",
"}"
] |
Checks for default location, full map, and HTML5 geolocation settings - private
|
[
"Checks",
"for",
"default",
"location",
"full",
"map",
"and",
"HTML5",
"geolocation",
"settings",
"-",
"private"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L632-L702
|
|
16,749
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function() {
this.writeDebug('htmlGeocode',arguments);
var _this = this;
if (_this.settings.sessionStorage === true && window.sessionStorage && window.sessionStorage.getItem('myGeo')){
_this.writeDebug('Using Session Saved Values for GEO');
_this.autoGeocodeQuery(JSON.parse(window.sessionStorage.getItem('myGeo')));
return false;
}
else if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position){
_this.writeDebug('Current Position Result');
// To not break autoGeocodeQuery then we create the obj to match the geolocation format
var pos = {
coords: {
latitude : position.coords.latitude,
longitude: position.coords.longitude,
accuracy : position.coords.accuracy
}
};
// Have to do this to get around scope issues
if (_this.settings.sessionStorage === true && window.sessionStorage) {
window.sessionStorage.setItem('myGeo',JSON.stringify(pos));
}
// Callback
if (_this.settings.callbackAutoGeoSuccess) {
_this.settings.callbackAutoGeoSuccess.call(this, pos);
}
_this.autoGeocodeQuery(pos);
}, function(error){
_this._autoGeocodeError(error);
});
}
}
|
javascript
|
function() {
this.writeDebug('htmlGeocode',arguments);
var _this = this;
if (_this.settings.sessionStorage === true && window.sessionStorage && window.sessionStorage.getItem('myGeo')){
_this.writeDebug('Using Session Saved Values for GEO');
_this.autoGeocodeQuery(JSON.parse(window.sessionStorage.getItem('myGeo')));
return false;
}
else if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position){
_this.writeDebug('Current Position Result');
// To not break autoGeocodeQuery then we create the obj to match the geolocation format
var pos = {
coords: {
latitude : position.coords.latitude,
longitude: position.coords.longitude,
accuracy : position.coords.accuracy
}
};
// Have to do this to get around scope issues
if (_this.settings.sessionStorage === true && window.sessionStorage) {
window.sessionStorage.setItem('myGeo',JSON.stringify(pos));
}
// Callback
if (_this.settings.callbackAutoGeoSuccess) {
_this.settings.callbackAutoGeoSuccess.call(this, pos);
}
_this.autoGeocodeQuery(pos);
}, function(error){
_this._autoGeocodeError(error);
});
}
}
|
[
"function",
"(",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'htmlGeocode'",
",",
"arguments",
")",
";",
"var",
"_this",
"=",
"this",
";",
"if",
"(",
"_this",
".",
"settings",
".",
"sessionStorage",
"===",
"true",
"&&",
"window",
".",
"sessionStorage",
"&&",
"window",
".",
"sessionStorage",
".",
"getItem",
"(",
"'myGeo'",
")",
")",
"{",
"_this",
".",
"writeDebug",
"(",
"'Using Session Saved Values for GEO'",
")",
";",
"_this",
".",
"autoGeocodeQuery",
"(",
"JSON",
".",
"parse",
"(",
"window",
".",
"sessionStorage",
".",
"getItem",
"(",
"'myGeo'",
")",
")",
")",
";",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"navigator",
".",
"geolocation",
")",
"{",
"navigator",
".",
"geolocation",
".",
"getCurrentPosition",
"(",
"function",
"(",
"position",
")",
"{",
"_this",
".",
"writeDebug",
"(",
"'Current Position Result'",
")",
";",
"// To not break autoGeocodeQuery then we create the obj to match the geolocation format",
"var",
"pos",
"=",
"{",
"coords",
":",
"{",
"latitude",
":",
"position",
".",
"coords",
".",
"latitude",
",",
"longitude",
":",
"position",
".",
"coords",
".",
"longitude",
",",
"accuracy",
":",
"position",
".",
"coords",
".",
"accuracy",
"}",
"}",
";",
"// Have to do this to get around scope issues",
"if",
"(",
"_this",
".",
"settings",
".",
"sessionStorage",
"===",
"true",
"&&",
"window",
".",
"sessionStorage",
")",
"{",
"window",
".",
"sessionStorage",
".",
"setItem",
"(",
"'myGeo'",
",",
"JSON",
".",
"stringify",
"(",
"pos",
")",
")",
";",
"}",
"// Callback",
"if",
"(",
"_this",
".",
"settings",
".",
"callbackAutoGeoSuccess",
")",
"{",
"_this",
".",
"settings",
".",
"callbackAutoGeoSuccess",
".",
"call",
"(",
"this",
",",
"pos",
")",
";",
"}",
"_this",
".",
"autoGeocodeQuery",
"(",
"pos",
")",
";",
"}",
",",
"function",
"(",
"error",
")",
"{",
"_this",
".",
"_autoGeocodeError",
"(",
"error",
")",
";",
"}",
")",
";",
"}",
"}"
] |
Geocode function used for auto geocode setting and geocodeID button
|
[
"Geocode",
"function",
"used",
"for",
"auto",
"geocode",
"setting",
"and",
"geocodeID",
"button"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L707-L743
|
|
16,750
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function (thisObj) {
thisObj.writeDebug('reverseGoogleGeocode',arguments);
var geocoder = new google.maps.Geocoder();
this.geocode = function (request, callbackFunction) {
geocoder.geocode(request, function (results, status) {
if (status === google.maps.GeocoderStatus.OK) {
if (results[0]) {
var result = {};
result.address = results[0].formatted_address;
callbackFunction(result);
}
} else {
callbackFunction(null);
throw new Error('Reverse geocode was not successful for the following reason: ' + status);
}
});
};
}
|
javascript
|
function (thisObj) {
thisObj.writeDebug('reverseGoogleGeocode',arguments);
var geocoder = new google.maps.Geocoder();
this.geocode = function (request, callbackFunction) {
geocoder.geocode(request, function (results, status) {
if (status === google.maps.GeocoderStatus.OK) {
if (results[0]) {
var result = {};
result.address = results[0].formatted_address;
callbackFunction(result);
}
} else {
callbackFunction(null);
throw new Error('Reverse geocode was not successful for the following reason: ' + status);
}
});
};
}
|
[
"function",
"(",
"thisObj",
")",
"{",
"thisObj",
".",
"writeDebug",
"(",
"'reverseGoogleGeocode'",
",",
"arguments",
")",
";",
"var",
"geocoder",
"=",
"new",
"google",
".",
"maps",
".",
"Geocoder",
"(",
")",
";",
"this",
".",
"geocode",
"=",
"function",
"(",
"request",
",",
"callbackFunction",
")",
"{",
"geocoder",
".",
"geocode",
"(",
"request",
",",
"function",
"(",
"results",
",",
"status",
")",
"{",
"if",
"(",
"status",
"===",
"google",
".",
"maps",
".",
"GeocoderStatus",
".",
"OK",
")",
"{",
"if",
"(",
"results",
"[",
"0",
"]",
")",
"{",
"var",
"result",
"=",
"{",
"}",
";",
"result",
".",
"address",
"=",
"results",
"[",
"0",
"]",
".",
"formatted_address",
";",
"callbackFunction",
"(",
"result",
")",
";",
"}",
"}",
"else",
"{",
"callbackFunction",
"(",
"null",
")",
";",
"throw",
"new",
"Error",
"(",
"'Reverse geocode was not successful for the following reason: '",
"+",
"status",
")",
";",
"}",
"}",
")",
";",
"}",
";",
"}"
] |
Reverse geocode to get address for automatic options needed for directions link
|
[
"Reverse",
"geocode",
"to",
"get",
"address",
"for",
"automatic",
"options",
"needed",
"for",
"directions",
"link"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L770-L787
|
|
16,751
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function (num, dec) {
this.writeDebug('roundNumber',arguments);
return Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec);
}
|
javascript
|
function (num, dec) {
this.writeDebug('roundNumber',arguments);
return Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec);
}
|
[
"function",
"(",
"num",
",",
"dec",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'roundNumber'",
",",
"arguments",
")",
";",
"return",
"Math",
".",
"round",
"(",
"num",
"*",
"Math",
".",
"pow",
"(",
"10",
",",
"dec",
")",
")",
"/",
"Math",
".",
"pow",
"(",
"10",
",",
"dec",
")",
";",
"}"
] |
Rounding function used for distances
@param num {number} the full number
@param dec {number} the number of digits to show after the decimal
@returns {number}
|
[
"Rounding",
"function",
"used",
"for",
"distances"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L796-L799
|
|
16,752
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function (obj) {
this.writeDebug('hasEmptyObjectVals',arguments);
var objTest = true;
for(var key in obj) {
if (obj.hasOwnProperty(key)) {
if (obj[key] !== '' && obj[key].length !== 0) {
objTest = false;
}
}
}
return objTest;
}
|
javascript
|
function (obj) {
this.writeDebug('hasEmptyObjectVals',arguments);
var objTest = true;
for(var key in obj) {
if (obj.hasOwnProperty(key)) {
if (obj[key] !== '' && obj[key].length !== 0) {
objTest = false;
}
}
}
return objTest;
}
|
[
"function",
"(",
"obj",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'hasEmptyObjectVals'",
",",
"arguments",
")",
";",
"var",
"objTest",
"=",
"true",
";",
"for",
"(",
"var",
"key",
"in",
"obj",
")",
"{",
"if",
"(",
"obj",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"if",
"(",
"obj",
"[",
"key",
"]",
"!==",
"''",
"&&",
"obj",
"[",
"key",
"]",
".",
"length",
"!==",
"0",
")",
"{",
"objTest",
"=",
"false",
";",
"}",
"}",
"}",
"return",
"objTest",
";",
"}"
] |
Checks to see if all the property values in the object are empty
@param obj {Object} the object to check
@returns {boolean}
|
[
"Checks",
"to",
"see",
"if",
"all",
"the",
"property",
"values",
"in",
"the",
"object",
"are",
"empty"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L823-L836
|
|
16,753
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function () {
this.writeDebug('modalClose');
// Callback
if (this.settings.callbackModalClose) {
this.settings.callbackModalClose.call(this);
}
// Reset the filters
filters = {};
// Undo category selections
$('.' + this.settings.overlay + ' select').prop('selectedIndex', 0);
$('.' + this.settings.overlay + ' input').prop('checked', false);
// Hide the modal
$('.' + this.settings.overlay).hide();
}
|
javascript
|
function () {
this.writeDebug('modalClose');
// Callback
if (this.settings.callbackModalClose) {
this.settings.callbackModalClose.call(this);
}
// Reset the filters
filters = {};
// Undo category selections
$('.' + this.settings.overlay + ' select').prop('selectedIndex', 0);
$('.' + this.settings.overlay + ' input').prop('checked', false);
// Hide the modal
$('.' + this.settings.overlay).hide();
}
|
[
"function",
"(",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'modalClose'",
")",
";",
"// Callback",
"if",
"(",
"this",
".",
"settings",
".",
"callbackModalClose",
")",
"{",
"this",
".",
"settings",
".",
"callbackModalClose",
".",
"call",
"(",
"this",
")",
";",
"}",
"// Reset the filters",
"filters",
"=",
"{",
"}",
";",
"// Undo category selections",
"$",
"(",
"'.'",
"+",
"this",
".",
"settings",
".",
"overlay",
"+",
"' select'",
")",
".",
"prop",
"(",
"'selectedIndex'",
",",
"0",
")",
";",
"$",
"(",
"'.'",
"+",
"this",
".",
"settings",
".",
"overlay",
"+",
"' input'",
")",
".",
"prop",
"(",
"'checked'",
",",
"false",
")",
";",
"// Hide the modal",
"$",
"(",
"'.'",
"+",
"this",
".",
"settings",
".",
"overlay",
")",
".",
"hide",
"(",
")",
";",
"}"
] |
Modal window close function
|
[
"Modal",
"window",
"close",
"function"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L841-L857
|
|
16,754
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function (loopcount) {
this.writeDebug('_createLocationVariables',arguments);
var value;
locationData = {};
for (var key in locationset[loopcount]) {
if (locationset[loopcount].hasOwnProperty(key)) {
value = locationset[loopcount][key];
if (key === 'distance' || key === 'altdistance') {
value = this.roundNumber(value, 2);
}
locationData[key] = value;
}
}
}
|
javascript
|
function (loopcount) {
this.writeDebug('_createLocationVariables',arguments);
var value;
locationData = {};
for (var key in locationset[loopcount]) {
if (locationset[loopcount].hasOwnProperty(key)) {
value = locationset[loopcount][key];
if (key === 'distance' || key === 'altdistance') {
value = this.roundNumber(value, 2);
}
locationData[key] = value;
}
}
}
|
[
"function",
"(",
"loopcount",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'_createLocationVariables'",
",",
"arguments",
")",
";",
"var",
"value",
";",
"locationData",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"key",
"in",
"locationset",
"[",
"loopcount",
"]",
")",
"{",
"if",
"(",
"locationset",
"[",
"loopcount",
"]",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"value",
"=",
"locationset",
"[",
"loopcount",
"]",
"[",
"key",
"]",
";",
"if",
"(",
"key",
"===",
"'distance'",
"||",
"key",
"===",
"'altdistance'",
")",
"{",
"value",
"=",
"this",
".",
"roundNumber",
"(",
"value",
",",
"2",
")",
";",
"}",
"locationData",
"[",
"key",
"]",
"=",
"value",
";",
"}",
"}",
"}"
] |
Create the location variables - private
@param loopcount {number} current marker id
|
[
"Create",
"the",
"location",
"variables",
"-",
"private"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L864-L880
|
|
16,755
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function(locationsarray) {
this.writeDebug('sortAlpha',arguments);
var property = (this.settings.sortBy.hasOwnProperty('prop') && typeof this.settings.sortBy.prop !== 'undefined') ? this.settings.sortBy.prop : 'name';
if (this.settings.sortBy.hasOwnProperty('order') && this.settings.sortBy.order.toString() === 'desc') {
locationsarray.sort(function (a, b) {
return b[property].toLowerCase().localeCompare(a[property].toLowerCase());
});
} else {
locationsarray.sort(function (a, b) {
return a[property].toLowerCase().localeCompare(b[property].toLowerCase());
});
}
}
|
javascript
|
function(locationsarray) {
this.writeDebug('sortAlpha',arguments);
var property = (this.settings.sortBy.hasOwnProperty('prop') && typeof this.settings.sortBy.prop !== 'undefined') ? this.settings.sortBy.prop : 'name';
if (this.settings.sortBy.hasOwnProperty('order') && this.settings.sortBy.order.toString() === 'desc') {
locationsarray.sort(function (a, b) {
return b[property].toLowerCase().localeCompare(a[property].toLowerCase());
});
} else {
locationsarray.sort(function (a, b) {
return a[property].toLowerCase().localeCompare(b[property].toLowerCase());
});
}
}
|
[
"function",
"(",
"locationsarray",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'sortAlpha'",
",",
"arguments",
")",
";",
"var",
"property",
"=",
"(",
"this",
".",
"settings",
".",
"sortBy",
".",
"hasOwnProperty",
"(",
"'prop'",
")",
"&&",
"typeof",
"this",
".",
"settings",
".",
"sortBy",
".",
"prop",
"!==",
"'undefined'",
")",
"?",
"this",
".",
"settings",
".",
"sortBy",
".",
"prop",
":",
"'name'",
";",
"if",
"(",
"this",
".",
"settings",
".",
"sortBy",
".",
"hasOwnProperty",
"(",
"'order'",
")",
"&&",
"this",
".",
"settings",
".",
"sortBy",
".",
"order",
".",
"toString",
"(",
")",
"===",
"'desc'",
")",
"{",
"locationsarray",
".",
"sort",
"(",
"function",
"(",
"a",
",",
"b",
")",
"{",
"return",
"b",
"[",
"property",
"]",
".",
"toLowerCase",
"(",
")",
".",
"localeCompare",
"(",
"a",
"[",
"property",
"]",
".",
"toLowerCase",
"(",
")",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"locationsarray",
".",
"sort",
"(",
"function",
"(",
"a",
",",
"b",
")",
"{",
"return",
"a",
"[",
"property",
"]",
".",
"toLowerCase",
"(",
")",
".",
"localeCompare",
"(",
"b",
"[",
"property",
"]",
".",
"toLowerCase",
"(",
")",
")",
";",
"}",
")",
";",
"}",
"}"
] |
Location alphabetical sorting function
@param locationsarray {array} locationset array
|
[
"Location",
"alphabetical",
"sorting",
"function"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L887-L900
|
|
16,756
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function(locationsarray) {
this.writeDebug('sortDate',arguments);
var property = (this.settings.sortBy.hasOwnProperty('prop') && typeof this.settings.sortBy.prop !== 'undefined') ? this.settings.sortBy.prop : 'date';
if (this.settings.sortBy.hasOwnProperty('order') && this.settings.sortBy.order.toString() === 'desc') {
locationsarray.sort(function (a, b) {
return new Date(b[property]).getTime() - new Date(a[property]).getTime();
});
} else {
locationsarray.sort(function (a, b) {
return new Date(a[property]).getTime() - new Date(b[property]).getTime();
});
}
}
|
javascript
|
function(locationsarray) {
this.writeDebug('sortDate',arguments);
var property = (this.settings.sortBy.hasOwnProperty('prop') && typeof this.settings.sortBy.prop !== 'undefined') ? this.settings.sortBy.prop : 'date';
if (this.settings.sortBy.hasOwnProperty('order') && this.settings.sortBy.order.toString() === 'desc') {
locationsarray.sort(function (a, b) {
return new Date(b[property]).getTime() - new Date(a[property]).getTime();
});
} else {
locationsarray.sort(function (a, b) {
return new Date(a[property]).getTime() - new Date(b[property]).getTime();
});
}
}
|
[
"function",
"(",
"locationsarray",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'sortDate'",
",",
"arguments",
")",
";",
"var",
"property",
"=",
"(",
"this",
".",
"settings",
".",
"sortBy",
".",
"hasOwnProperty",
"(",
"'prop'",
")",
"&&",
"typeof",
"this",
".",
"settings",
".",
"sortBy",
".",
"prop",
"!==",
"'undefined'",
")",
"?",
"this",
".",
"settings",
".",
"sortBy",
".",
"prop",
":",
"'date'",
";",
"if",
"(",
"this",
".",
"settings",
".",
"sortBy",
".",
"hasOwnProperty",
"(",
"'order'",
")",
"&&",
"this",
".",
"settings",
".",
"sortBy",
".",
"order",
".",
"toString",
"(",
")",
"===",
"'desc'",
")",
"{",
"locationsarray",
".",
"sort",
"(",
"function",
"(",
"a",
",",
"b",
")",
"{",
"return",
"new",
"Date",
"(",
"b",
"[",
"property",
"]",
")",
".",
"getTime",
"(",
")",
"-",
"new",
"Date",
"(",
"a",
"[",
"property",
"]",
")",
".",
"getTime",
"(",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"locationsarray",
".",
"sort",
"(",
"function",
"(",
"a",
",",
"b",
")",
"{",
"return",
"new",
"Date",
"(",
"a",
"[",
"property",
"]",
")",
".",
"getTime",
"(",
")",
"-",
"new",
"Date",
"(",
"b",
"[",
"property",
"]",
")",
".",
"getTime",
"(",
")",
";",
"}",
")",
";",
"}",
"}"
] |
Location date sorting function
@param locationsarray {array} locationset array
|
[
"Location",
"date",
"sorting",
"function"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L907-L920
|
|
16,757
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function (locationsarray) {
this.writeDebug('sortNumerically',arguments);
var property = (
this.settings.sortBy !== null &&
this.settings.sortBy.hasOwnProperty('prop') &&
typeof this.settings.sortBy.prop !== 'undefined'
) ? this.settings.sortBy.prop : 'distance';
if (this.settings.sortBy !== null && this.settings.sortBy.hasOwnProperty('order') && this.settings.sortBy.order.toString() === 'desc') {
locationsarray.sort(function (a, b) {
return ((b[property] < a[property]) ? -1 : ((b[property] > a[property]) ? 1 : 0));
});
} else {
locationsarray.sort(function (a, b) {
return ((a[property] < b[property]) ? -1 : ((a[property] > b[property]) ? 1 : 0));
});
}
}
|
javascript
|
function (locationsarray) {
this.writeDebug('sortNumerically',arguments);
var property = (
this.settings.sortBy !== null &&
this.settings.sortBy.hasOwnProperty('prop') &&
typeof this.settings.sortBy.prop !== 'undefined'
) ? this.settings.sortBy.prop : 'distance';
if (this.settings.sortBy !== null && this.settings.sortBy.hasOwnProperty('order') && this.settings.sortBy.order.toString() === 'desc') {
locationsarray.sort(function (a, b) {
return ((b[property] < a[property]) ? -1 : ((b[property] > a[property]) ? 1 : 0));
});
} else {
locationsarray.sort(function (a, b) {
return ((a[property] < b[property]) ? -1 : ((a[property] > b[property]) ? 1 : 0));
});
}
}
|
[
"function",
"(",
"locationsarray",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'sortNumerically'",
",",
"arguments",
")",
";",
"var",
"property",
"=",
"(",
"this",
".",
"settings",
".",
"sortBy",
"!==",
"null",
"&&",
"this",
".",
"settings",
".",
"sortBy",
".",
"hasOwnProperty",
"(",
"'prop'",
")",
"&&",
"typeof",
"this",
".",
"settings",
".",
"sortBy",
".",
"prop",
"!==",
"'undefined'",
")",
"?",
"this",
".",
"settings",
".",
"sortBy",
".",
"prop",
":",
"'distance'",
";",
"if",
"(",
"this",
".",
"settings",
".",
"sortBy",
"!==",
"null",
"&&",
"this",
".",
"settings",
".",
"sortBy",
".",
"hasOwnProperty",
"(",
"'order'",
")",
"&&",
"this",
".",
"settings",
".",
"sortBy",
".",
"order",
".",
"toString",
"(",
")",
"===",
"'desc'",
")",
"{",
"locationsarray",
".",
"sort",
"(",
"function",
"(",
"a",
",",
"b",
")",
"{",
"return",
"(",
"(",
"b",
"[",
"property",
"]",
"<",
"a",
"[",
"property",
"]",
")",
"?",
"-",
"1",
":",
"(",
"(",
"b",
"[",
"property",
"]",
">",
"a",
"[",
"property",
"]",
")",
"?",
"1",
":",
"0",
")",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"locationsarray",
".",
"sort",
"(",
"function",
"(",
"a",
",",
"b",
")",
"{",
"return",
"(",
"(",
"a",
"[",
"property",
"]",
"<",
"b",
"[",
"property",
"]",
")",
"?",
"-",
"1",
":",
"(",
"(",
"a",
"[",
"property",
"]",
">",
"b",
"[",
"property",
"]",
")",
"?",
"1",
":",
"0",
")",
")",
";",
"}",
")",
";",
"}",
"}"
] |
Location distance sorting function
@param locationsarray {array} locationset array
|
[
"Location",
"distance",
"sorting",
"function"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L927-L944
|
|
16,758
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function (data, filters) {
this.writeDebug('filterData',arguments);
var filterTest = true;
for (var k in filters) {
if (filters.hasOwnProperty(k)) {
// Exclusive filtering
if (this.settings.exclusiveFiltering === true || (this.settings.exclusiveTax !== null && Array.isArray(this.settings.exclusiveTax) && this.settings.exclusiveTax.indexOf(k) !== -1)) {
var filterTests = filters[k];
var exclusiveTest = [];
if (typeof data[k] !== 'undefined') {
for (var l = 0; l < filterTests.length; l++) {
exclusiveTest[l] = new RegExp(filterTests[l], 'i').test(data[k].replace(/([^\x00-\x7F]|[.*+?^=!:${}()|\[\]\/\\]|&\s+)/g, ''));
}
}
if (exclusiveTest.indexOf(true) === -1) {
filterTest = false;
}
}
// Inclusive filtering
else {
if (typeof data[k] === 'undefined' || !(new RegExp(filters[k].join(''), 'i').test(data[k].replace(/([^\x00-\x7F]|[.*+?^=!:${}()|\[\]\/\\]|&\s+)/g, '')))) {
filterTest = false;
}
}
}
}
if (filterTest) {
return true;
}
}
|
javascript
|
function (data, filters) {
this.writeDebug('filterData',arguments);
var filterTest = true;
for (var k in filters) {
if (filters.hasOwnProperty(k)) {
// Exclusive filtering
if (this.settings.exclusiveFiltering === true || (this.settings.exclusiveTax !== null && Array.isArray(this.settings.exclusiveTax) && this.settings.exclusiveTax.indexOf(k) !== -1)) {
var filterTests = filters[k];
var exclusiveTest = [];
if (typeof data[k] !== 'undefined') {
for (var l = 0; l < filterTests.length; l++) {
exclusiveTest[l] = new RegExp(filterTests[l], 'i').test(data[k].replace(/([^\x00-\x7F]|[.*+?^=!:${}()|\[\]\/\\]|&\s+)/g, ''));
}
}
if (exclusiveTest.indexOf(true) === -1) {
filterTest = false;
}
}
// Inclusive filtering
else {
if (typeof data[k] === 'undefined' || !(new RegExp(filters[k].join(''), 'i').test(data[k].replace(/([^\x00-\x7F]|[.*+?^=!:${}()|\[\]\/\\]|&\s+)/g, '')))) {
filterTest = false;
}
}
}
}
if (filterTest) {
return true;
}
}
|
[
"function",
"(",
"data",
",",
"filters",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'filterData'",
",",
"arguments",
")",
";",
"var",
"filterTest",
"=",
"true",
";",
"for",
"(",
"var",
"k",
"in",
"filters",
")",
"{",
"if",
"(",
"filters",
".",
"hasOwnProperty",
"(",
"k",
")",
")",
"{",
"// Exclusive filtering",
"if",
"(",
"this",
".",
"settings",
".",
"exclusiveFiltering",
"===",
"true",
"||",
"(",
"this",
".",
"settings",
".",
"exclusiveTax",
"!==",
"null",
"&&",
"Array",
".",
"isArray",
"(",
"this",
".",
"settings",
".",
"exclusiveTax",
")",
"&&",
"this",
".",
"settings",
".",
"exclusiveTax",
".",
"indexOf",
"(",
"k",
")",
"!==",
"-",
"1",
")",
")",
"{",
"var",
"filterTests",
"=",
"filters",
"[",
"k",
"]",
";",
"var",
"exclusiveTest",
"=",
"[",
"]",
";",
"if",
"(",
"typeof",
"data",
"[",
"k",
"]",
"!==",
"'undefined'",
")",
"{",
"for",
"(",
"var",
"l",
"=",
"0",
";",
"l",
"<",
"filterTests",
".",
"length",
";",
"l",
"++",
")",
"{",
"exclusiveTest",
"[",
"l",
"]",
"=",
"new",
"RegExp",
"(",
"filterTests",
"[",
"l",
"]",
",",
"'i'",
")",
".",
"test",
"(",
"data",
"[",
"k",
"]",
".",
"replace",
"(",
"/",
"([^\\x00-\\x7F]|[.*+?^=!:${}()|\\[\\]\\/\\\\]|&\\s+)",
"/",
"g",
",",
"''",
")",
")",
";",
"}",
"}",
"if",
"(",
"exclusiveTest",
".",
"indexOf",
"(",
"true",
")",
"===",
"-",
"1",
")",
"{",
"filterTest",
"=",
"false",
";",
"}",
"}",
"// Inclusive filtering",
"else",
"{",
"if",
"(",
"typeof",
"data",
"[",
"k",
"]",
"===",
"'undefined'",
"||",
"!",
"(",
"new",
"RegExp",
"(",
"filters",
"[",
"k",
"]",
".",
"join",
"(",
"''",
")",
",",
"'i'",
")",
".",
"test",
"(",
"data",
"[",
"k",
"]",
".",
"replace",
"(",
"/",
"([^\\x00-\\x7F]|[.*+?^=!:${}()|\\[\\]\\/\\\\]|&\\s+)",
"/",
"g",
",",
"''",
")",
")",
")",
")",
"{",
"filterTest",
"=",
"false",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"filterTest",
")",
"{",
"return",
"true",
";",
"}",
"}"
] |
Filter the data with Regex
@param data {array} data array to check for filter values
@param filters {Object} taxonomy filters object
@returns {boolean}
|
[
"Filter",
"the",
"data",
"with",
"Regex"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L971-L1005
|
|
16,759
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function (currentPage) {
this.writeDebug('paginationSetup',arguments);
var pagesOutput = '';
var totalPages;
var $paginationList = $('.bh-sl-pagination-container .bh-sl-pagination');
// Total pages
if ( this.settings.storeLimit === -1 || locationset.length < this.settings.storeLimit ) {
totalPages = locationset.length / this.settings.locationsPerPage;
} else {
totalPages = this.settings.storeLimit / this.settings.locationsPerPage;
}
// Current page check
if (typeof currentPage === 'undefined') {
currentPage = 0;
}
// Initial pagination setup
if ($paginationList.length === 0) {
pagesOutput = this._paginationOutput(currentPage, totalPages);
}
// Update pagination on page change
else {
// Remove the old pagination
$paginationList.empty();
// Add the numbers
pagesOutput = this._paginationOutput(currentPage, totalPages);
}
$paginationList.append(pagesOutput);
}
|
javascript
|
function (currentPage) {
this.writeDebug('paginationSetup',arguments);
var pagesOutput = '';
var totalPages;
var $paginationList = $('.bh-sl-pagination-container .bh-sl-pagination');
// Total pages
if ( this.settings.storeLimit === -1 || locationset.length < this.settings.storeLimit ) {
totalPages = locationset.length / this.settings.locationsPerPage;
} else {
totalPages = this.settings.storeLimit / this.settings.locationsPerPage;
}
// Current page check
if (typeof currentPage === 'undefined') {
currentPage = 0;
}
// Initial pagination setup
if ($paginationList.length === 0) {
pagesOutput = this._paginationOutput(currentPage, totalPages);
}
// Update pagination on page change
else {
// Remove the old pagination
$paginationList.empty();
// Add the numbers
pagesOutput = this._paginationOutput(currentPage, totalPages);
}
$paginationList.append(pagesOutput);
}
|
[
"function",
"(",
"currentPage",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'paginationSetup'",
",",
"arguments",
")",
";",
"var",
"pagesOutput",
"=",
"''",
";",
"var",
"totalPages",
";",
"var",
"$paginationList",
"=",
"$",
"(",
"'.bh-sl-pagination-container .bh-sl-pagination'",
")",
";",
"// Total pages",
"if",
"(",
"this",
".",
"settings",
".",
"storeLimit",
"===",
"-",
"1",
"||",
"locationset",
".",
"length",
"<",
"this",
".",
"settings",
".",
"storeLimit",
")",
"{",
"totalPages",
"=",
"locationset",
".",
"length",
"/",
"this",
".",
"settings",
".",
"locationsPerPage",
";",
"}",
"else",
"{",
"totalPages",
"=",
"this",
".",
"settings",
".",
"storeLimit",
"/",
"this",
".",
"settings",
".",
"locationsPerPage",
";",
"}",
"// Current page check",
"if",
"(",
"typeof",
"currentPage",
"===",
"'undefined'",
")",
"{",
"currentPage",
"=",
"0",
";",
"}",
"// Initial pagination setup",
"if",
"(",
"$paginationList",
".",
"length",
"===",
"0",
")",
"{",
"pagesOutput",
"=",
"this",
".",
"_paginationOutput",
"(",
"currentPage",
",",
"totalPages",
")",
";",
"}",
"// Update pagination on page change",
"else",
"{",
"// Remove the old pagination",
"$paginationList",
".",
"empty",
"(",
")",
";",
"// Add the numbers",
"pagesOutput",
"=",
"this",
".",
"_paginationOutput",
"(",
"currentPage",
",",
"totalPages",
")",
";",
"}",
"$paginationList",
".",
"append",
"(",
"pagesOutput",
")",
";",
"}"
] |
Set up the pagination pages
@param currentPage {number} optional current page
|
[
"Set",
"up",
"the",
"pagination",
"pages"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L1052-L1085
|
|
16,760
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function (markerUrl, markerWidth, markerHeight) {
this.writeDebug('markerImage',arguments);
var markerImg;
// User defined marker dimensions
if (typeof markerWidth !== 'undefined' && typeof markerHeight !== 'undefined') {
markerImg = {
url: markerUrl,
size: new google.maps.Size(markerWidth, markerHeight),
scaledSize: new google.maps.Size(markerWidth, markerHeight)
};
}
// Default marker dimensions: 32px x 32px
else {
markerImg = {
url: markerUrl,
size: new google.maps.Size(32, 32),
scaledSize: new google.maps.Size(32, 32)
};
}
return markerImg;
}
|
javascript
|
function (markerUrl, markerWidth, markerHeight) {
this.writeDebug('markerImage',arguments);
var markerImg;
// User defined marker dimensions
if (typeof markerWidth !== 'undefined' && typeof markerHeight !== 'undefined') {
markerImg = {
url: markerUrl,
size: new google.maps.Size(markerWidth, markerHeight),
scaledSize: new google.maps.Size(markerWidth, markerHeight)
};
}
// Default marker dimensions: 32px x 32px
else {
markerImg = {
url: markerUrl,
size: new google.maps.Size(32, 32),
scaledSize: new google.maps.Size(32, 32)
};
}
return markerImg;
}
|
[
"function",
"(",
"markerUrl",
",",
"markerWidth",
",",
"markerHeight",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'markerImage'",
",",
"arguments",
")",
";",
"var",
"markerImg",
";",
"// User defined marker dimensions",
"if",
"(",
"typeof",
"markerWidth",
"!==",
"'undefined'",
"&&",
"typeof",
"markerHeight",
"!==",
"'undefined'",
")",
"{",
"markerImg",
"=",
"{",
"url",
":",
"markerUrl",
",",
"size",
":",
"new",
"google",
".",
"maps",
".",
"Size",
"(",
"markerWidth",
",",
"markerHeight",
")",
",",
"scaledSize",
":",
"new",
"google",
".",
"maps",
".",
"Size",
"(",
"markerWidth",
",",
"markerHeight",
")",
"}",
";",
"}",
"// Default marker dimensions: 32px x 32px",
"else",
"{",
"markerImg",
"=",
"{",
"url",
":",
"markerUrl",
",",
"size",
":",
"new",
"google",
".",
"maps",
".",
"Size",
"(",
"32",
",",
"32",
")",
",",
"scaledSize",
":",
"new",
"google",
".",
"maps",
".",
"Size",
"(",
"32",
",",
"32",
")",
"}",
";",
"}",
"return",
"markerImg",
";",
"}"
] |
Marker image setup
@param markerUrl {string} path to marker image
@param markerWidth {number} width of marker
@param markerHeight {number} height of marker
@returns {Object} Google Maps icon object
|
[
"Marker",
"image",
"setup"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L1095-L1117
|
|
16,761
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function (point, name, address, letter, map, category) {
this.writeDebug('createMarker',arguments);
var marker, markerImg, letterMarkerImg;
var categories = [];
// Custom multi-marker image override (different markers for different categories
if (this.settings.catMarkers !== null) {
if (typeof category !== 'undefined') {
// Multiple categories
if (category.indexOf(',') !== -1) {
// Break the category variable into an array if there are multiple categories for the location
categories = category.split(',');
// With multiple categories the color will be determined by the last matched category in the data
for(var i = 0; i < categories.length; i++) {
if (categories[i] in this.settings.catMarkers) {
markerImg = this.markerImage(this.settings.catMarkers[categories[i]][0], parseInt(this.settings.catMarkers[categories[i]][1]), parseInt(this.settings.catMarkers[categories[i]][2]));
}
}
}
// Single category
else {
if (category in this.settings.catMarkers) {
markerImg = this.markerImage(this.settings.catMarkers[category][0], parseInt(this.settings.catMarkers[category][1]), parseInt(this.settings.catMarkers[category][2]));
}
}
}
}
// Custom single marker image override
if (this.settings.markerImg !== null) {
if (this.settings.markerDim === null) {
markerImg = this.markerImage(this.settings.markerImg);
}
else {
markerImg = this.markerImage(this.settings.markerImg, this.settings.markerDim.width, this.settings.markerDim.height);
}
}
// Marker setup
if (this.settings.callbackCreateMarker) {
// Marker override callback
marker = this.settings.callbackCreateMarker.call(this, map, point, letter, category);
}
else {
// Create the default markers
if (this.settings.disableAlphaMarkers === true || this.settings.storeLimit === -1 || this.settings.storeLimit > 26 || this.settings.catMarkers !== null || this.settings.markerImg !== null || (this.settings.fullMapStart === true && firstRun === true && (isNaN(this.settings.fullMapStartListLimit) || this.settings.fullMapStartListLimit > 26 || this.settings.fullMapStartListLimit === -1))) {
marker = new google.maps.Marker({
position : point,
map : map,
draggable: false,
icon: markerImg // Reverts to default marker if nothing is passed
});
}
else {
// Letter markers image
letterMarkerImg = {
url: 'https://mt.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-b.png&text=' + letter + '&psize=16&font=fonts/Roboto-Regular.ttf&color=ff333333&ax=44&ay=48'
};
// Letter markers
marker = new google.maps.Marker({
position : point,
map : map,
icon : letterMarkerImg,
draggable: false
});
}
}
return marker;
}
|
javascript
|
function (point, name, address, letter, map, category) {
this.writeDebug('createMarker',arguments);
var marker, markerImg, letterMarkerImg;
var categories = [];
// Custom multi-marker image override (different markers for different categories
if (this.settings.catMarkers !== null) {
if (typeof category !== 'undefined') {
// Multiple categories
if (category.indexOf(',') !== -1) {
// Break the category variable into an array if there are multiple categories for the location
categories = category.split(',');
// With multiple categories the color will be determined by the last matched category in the data
for(var i = 0; i < categories.length; i++) {
if (categories[i] in this.settings.catMarkers) {
markerImg = this.markerImage(this.settings.catMarkers[categories[i]][0], parseInt(this.settings.catMarkers[categories[i]][1]), parseInt(this.settings.catMarkers[categories[i]][2]));
}
}
}
// Single category
else {
if (category in this.settings.catMarkers) {
markerImg = this.markerImage(this.settings.catMarkers[category][0], parseInt(this.settings.catMarkers[category][1]), parseInt(this.settings.catMarkers[category][2]));
}
}
}
}
// Custom single marker image override
if (this.settings.markerImg !== null) {
if (this.settings.markerDim === null) {
markerImg = this.markerImage(this.settings.markerImg);
}
else {
markerImg = this.markerImage(this.settings.markerImg, this.settings.markerDim.width, this.settings.markerDim.height);
}
}
// Marker setup
if (this.settings.callbackCreateMarker) {
// Marker override callback
marker = this.settings.callbackCreateMarker.call(this, map, point, letter, category);
}
else {
// Create the default markers
if (this.settings.disableAlphaMarkers === true || this.settings.storeLimit === -1 || this.settings.storeLimit > 26 || this.settings.catMarkers !== null || this.settings.markerImg !== null || (this.settings.fullMapStart === true && firstRun === true && (isNaN(this.settings.fullMapStartListLimit) || this.settings.fullMapStartListLimit > 26 || this.settings.fullMapStartListLimit === -1))) {
marker = new google.maps.Marker({
position : point,
map : map,
draggable: false,
icon: markerImg // Reverts to default marker if nothing is passed
});
}
else {
// Letter markers image
letterMarkerImg = {
url: 'https://mt.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-b.png&text=' + letter + '&psize=16&font=fonts/Roboto-Regular.ttf&color=ff333333&ax=44&ay=48'
};
// Letter markers
marker = new google.maps.Marker({
position : point,
map : map,
icon : letterMarkerImg,
draggable: false
});
}
}
return marker;
}
|
[
"function",
"(",
"point",
",",
"name",
",",
"address",
",",
"letter",
",",
"map",
",",
"category",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'createMarker'",
",",
"arguments",
")",
";",
"var",
"marker",
",",
"markerImg",
",",
"letterMarkerImg",
";",
"var",
"categories",
"=",
"[",
"]",
";",
"// Custom multi-marker image override (different markers for different categories",
"if",
"(",
"this",
".",
"settings",
".",
"catMarkers",
"!==",
"null",
")",
"{",
"if",
"(",
"typeof",
"category",
"!==",
"'undefined'",
")",
"{",
"// Multiple categories",
"if",
"(",
"category",
".",
"indexOf",
"(",
"','",
")",
"!==",
"-",
"1",
")",
"{",
"// Break the category variable into an array if there are multiple categories for the location",
"categories",
"=",
"category",
".",
"split",
"(",
"','",
")",
";",
"// With multiple categories the color will be determined by the last matched category in the data",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"categories",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"categories",
"[",
"i",
"]",
"in",
"this",
".",
"settings",
".",
"catMarkers",
")",
"{",
"markerImg",
"=",
"this",
".",
"markerImage",
"(",
"this",
".",
"settings",
".",
"catMarkers",
"[",
"categories",
"[",
"i",
"]",
"]",
"[",
"0",
"]",
",",
"parseInt",
"(",
"this",
".",
"settings",
".",
"catMarkers",
"[",
"categories",
"[",
"i",
"]",
"]",
"[",
"1",
"]",
")",
",",
"parseInt",
"(",
"this",
".",
"settings",
".",
"catMarkers",
"[",
"categories",
"[",
"i",
"]",
"]",
"[",
"2",
"]",
")",
")",
";",
"}",
"}",
"}",
"// Single category",
"else",
"{",
"if",
"(",
"category",
"in",
"this",
".",
"settings",
".",
"catMarkers",
")",
"{",
"markerImg",
"=",
"this",
".",
"markerImage",
"(",
"this",
".",
"settings",
".",
"catMarkers",
"[",
"category",
"]",
"[",
"0",
"]",
",",
"parseInt",
"(",
"this",
".",
"settings",
".",
"catMarkers",
"[",
"category",
"]",
"[",
"1",
"]",
")",
",",
"parseInt",
"(",
"this",
".",
"settings",
".",
"catMarkers",
"[",
"category",
"]",
"[",
"2",
"]",
")",
")",
";",
"}",
"}",
"}",
"}",
"// Custom single marker image override",
"if",
"(",
"this",
".",
"settings",
".",
"markerImg",
"!==",
"null",
")",
"{",
"if",
"(",
"this",
".",
"settings",
".",
"markerDim",
"===",
"null",
")",
"{",
"markerImg",
"=",
"this",
".",
"markerImage",
"(",
"this",
".",
"settings",
".",
"markerImg",
")",
";",
"}",
"else",
"{",
"markerImg",
"=",
"this",
".",
"markerImage",
"(",
"this",
".",
"settings",
".",
"markerImg",
",",
"this",
".",
"settings",
".",
"markerDim",
".",
"width",
",",
"this",
".",
"settings",
".",
"markerDim",
".",
"height",
")",
";",
"}",
"}",
"// Marker setup",
"if",
"(",
"this",
".",
"settings",
".",
"callbackCreateMarker",
")",
"{",
"// Marker override callback",
"marker",
"=",
"this",
".",
"settings",
".",
"callbackCreateMarker",
".",
"call",
"(",
"this",
",",
"map",
",",
"point",
",",
"letter",
",",
"category",
")",
";",
"}",
"else",
"{",
"// Create the default markers",
"if",
"(",
"this",
".",
"settings",
".",
"disableAlphaMarkers",
"===",
"true",
"||",
"this",
".",
"settings",
".",
"storeLimit",
"===",
"-",
"1",
"||",
"this",
".",
"settings",
".",
"storeLimit",
">",
"26",
"||",
"this",
".",
"settings",
".",
"catMarkers",
"!==",
"null",
"||",
"this",
".",
"settings",
".",
"markerImg",
"!==",
"null",
"||",
"(",
"this",
".",
"settings",
".",
"fullMapStart",
"===",
"true",
"&&",
"firstRun",
"===",
"true",
"&&",
"(",
"isNaN",
"(",
"this",
".",
"settings",
".",
"fullMapStartListLimit",
")",
"||",
"this",
".",
"settings",
".",
"fullMapStartListLimit",
">",
"26",
"||",
"this",
".",
"settings",
".",
"fullMapStartListLimit",
"===",
"-",
"1",
")",
")",
")",
"{",
"marker",
"=",
"new",
"google",
".",
"maps",
".",
"Marker",
"(",
"{",
"position",
":",
"point",
",",
"map",
":",
"map",
",",
"draggable",
":",
"false",
",",
"icon",
":",
"markerImg",
"// Reverts to default marker if nothing is passed",
"}",
")",
";",
"}",
"else",
"{",
"// Letter markers image",
"letterMarkerImg",
"=",
"{",
"url",
":",
"'https://mt.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-b.png&text='",
"+",
"letter",
"+",
"'&psize=16&font=fonts/Roboto-Regular.ttf&color=ff333333&ax=44&ay=48'",
"}",
";",
"// Letter markers",
"marker",
"=",
"new",
"google",
".",
"maps",
".",
"Marker",
"(",
"{",
"position",
":",
"point",
",",
"map",
":",
"map",
",",
"icon",
":",
"letterMarkerImg",
",",
"draggable",
":",
"false",
"}",
")",
";",
"}",
"}",
"return",
"marker",
";",
"}"
] |
Map marker setup
@param point {Object} LatLng of current location
@param name {string} location name
@param address {string} location address
@param letter {string} optional letter used for front-end identification and correlation between list and points
@param map {Object} the Google Map
@param category {string} location category/categories
@returns {Object} Google Maps marker
|
[
"Map",
"marker",
"setup"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L1130-L1200
|
|
16,762
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function (currentMarker, storeStart, page) {
this.writeDebug('_defineLocationData',arguments);
var indicator = '';
this._createLocationVariables(currentMarker.get('id'));
var altDistLength,
distLength;
if (locationData.distance <= 1) {
if (this.settings.lengthUnit === 'km') {
distLength = this.settings.kilometerLang;
altDistLength = this.settings.mileLang;
}
else {
distLength = this.settings.mileLang;
altDistLength = this.settings.kilometerLang;
}
}
else {
if (this.settings.lengthUnit === 'km') {
distLength = this.settings.kilometersLang;
altDistLength = this.settings.milesLang;
}
else {
distLength = this.settings.milesLang;
altDistLength = this.settings.kilometersLang;
}
}
// Set up alpha character
var markerId = currentMarker.get('id');
// Use dot markers instead of alpha if there are more than 26 locations
if (this.settings.disableAlphaMarkers === true || this.settings.storeLimit === -1 || this.settings.storeLimit > 26 || (this.settings.fullMapStart === true && firstRun === true && (isNaN(this.settings.fullMapStartListLimit) || this.settings.fullMapStartListLimit > 26 || this.settings.fullMapStartListLimit === -1))) {
indicator = markerId + 1;
}
else {
if (page > 0) {
indicator = String.fromCharCode('A'.charCodeAt(0) + (storeStart + markerId));
}
else {
indicator = String.fromCharCode('A'.charCodeAt(0) + markerId);
}
}
// Define location data
return {
location: [$.extend(locationData, {
'markerid' : markerId,
'marker' : indicator,
'altlength': altDistLength,
'length' : distLength,
'origin' : originalOrigin
})]
};
}
|
javascript
|
function (currentMarker, storeStart, page) {
this.writeDebug('_defineLocationData',arguments);
var indicator = '';
this._createLocationVariables(currentMarker.get('id'));
var altDistLength,
distLength;
if (locationData.distance <= 1) {
if (this.settings.lengthUnit === 'km') {
distLength = this.settings.kilometerLang;
altDistLength = this.settings.mileLang;
}
else {
distLength = this.settings.mileLang;
altDistLength = this.settings.kilometerLang;
}
}
else {
if (this.settings.lengthUnit === 'km') {
distLength = this.settings.kilometersLang;
altDistLength = this.settings.milesLang;
}
else {
distLength = this.settings.milesLang;
altDistLength = this.settings.kilometersLang;
}
}
// Set up alpha character
var markerId = currentMarker.get('id');
// Use dot markers instead of alpha if there are more than 26 locations
if (this.settings.disableAlphaMarkers === true || this.settings.storeLimit === -1 || this.settings.storeLimit > 26 || (this.settings.fullMapStart === true && firstRun === true && (isNaN(this.settings.fullMapStartListLimit) || this.settings.fullMapStartListLimit > 26 || this.settings.fullMapStartListLimit === -1))) {
indicator = markerId + 1;
}
else {
if (page > 0) {
indicator = String.fromCharCode('A'.charCodeAt(0) + (storeStart + markerId));
}
else {
indicator = String.fromCharCode('A'.charCodeAt(0) + markerId);
}
}
// Define location data
return {
location: [$.extend(locationData, {
'markerid' : markerId,
'marker' : indicator,
'altlength': altDistLength,
'length' : distLength,
'origin' : originalOrigin
})]
};
}
|
[
"function",
"(",
"currentMarker",
",",
"storeStart",
",",
"page",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'_defineLocationData'",
",",
"arguments",
")",
";",
"var",
"indicator",
"=",
"''",
";",
"this",
".",
"_createLocationVariables",
"(",
"currentMarker",
".",
"get",
"(",
"'id'",
")",
")",
";",
"var",
"altDistLength",
",",
"distLength",
";",
"if",
"(",
"locationData",
".",
"distance",
"<=",
"1",
")",
"{",
"if",
"(",
"this",
".",
"settings",
".",
"lengthUnit",
"===",
"'km'",
")",
"{",
"distLength",
"=",
"this",
".",
"settings",
".",
"kilometerLang",
";",
"altDistLength",
"=",
"this",
".",
"settings",
".",
"mileLang",
";",
"}",
"else",
"{",
"distLength",
"=",
"this",
".",
"settings",
".",
"mileLang",
";",
"altDistLength",
"=",
"this",
".",
"settings",
".",
"kilometerLang",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"this",
".",
"settings",
".",
"lengthUnit",
"===",
"'km'",
")",
"{",
"distLength",
"=",
"this",
".",
"settings",
".",
"kilometersLang",
";",
"altDistLength",
"=",
"this",
".",
"settings",
".",
"milesLang",
";",
"}",
"else",
"{",
"distLength",
"=",
"this",
".",
"settings",
".",
"milesLang",
";",
"altDistLength",
"=",
"this",
".",
"settings",
".",
"kilometersLang",
";",
"}",
"}",
"// Set up alpha character",
"var",
"markerId",
"=",
"currentMarker",
".",
"get",
"(",
"'id'",
")",
";",
"// Use dot markers instead of alpha if there are more than 26 locations",
"if",
"(",
"this",
".",
"settings",
".",
"disableAlphaMarkers",
"===",
"true",
"||",
"this",
".",
"settings",
".",
"storeLimit",
"===",
"-",
"1",
"||",
"this",
".",
"settings",
".",
"storeLimit",
">",
"26",
"||",
"(",
"this",
".",
"settings",
".",
"fullMapStart",
"===",
"true",
"&&",
"firstRun",
"===",
"true",
"&&",
"(",
"isNaN",
"(",
"this",
".",
"settings",
".",
"fullMapStartListLimit",
")",
"||",
"this",
".",
"settings",
".",
"fullMapStartListLimit",
">",
"26",
"||",
"this",
".",
"settings",
".",
"fullMapStartListLimit",
"===",
"-",
"1",
")",
")",
")",
"{",
"indicator",
"=",
"markerId",
"+",
"1",
";",
"}",
"else",
"{",
"if",
"(",
"page",
">",
"0",
")",
"{",
"indicator",
"=",
"String",
".",
"fromCharCode",
"(",
"'A'",
".",
"charCodeAt",
"(",
"0",
")",
"+",
"(",
"storeStart",
"+",
"markerId",
")",
")",
";",
"}",
"else",
"{",
"indicator",
"=",
"String",
".",
"fromCharCode",
"(",
"'A'",
".",
"charCodeAt",
"(",
"0",
")",
"+",
"markerId",
")",
";",
"}",
"}",
"// Define location data",
"return",
"{",
"location",
":",
"[",
"$",
".",
"extend",
"(",
"locationData",
",",
"{",
"'markerid'",
":",
"markerId",
",",
"'marker'",
":",
"indicator",
",",
"'altlength'",
":",
"altDistLength",
",",
"'length'",
":",
"distLength",
",",
"'origin'",
":",
"originalOrigin",
"}",
")",
"]",
"}",
";",
"}"
] |
Define the location data for the templates - private
@param currentMarker {Object} Google Maps marker
@param storeStart {number} optional first location on the current page
@param page {number} optional current page
@returns {Object} extended location data object
|
[
"Define",
"the",
"location",
"data",
"for",
"the",
"templates",
"-",
"private"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L1210-L1264
|
|
16,763
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function (marker, storeStart, page) {
this.writeDebug('listSetup',arguments);
// Define the location data
var locations = this._defineLocationData(marker, storeStart, page);
// Set up the list template with the location data
var listHtml = listTemplate(locations);
$('.' + this.settings.locationList + ' > ul').append(listHtml);
}
|
javascript
|
function (marker, storeStart, page) {
this.writeDebug('listSetup',arguments);
// Define the location data
var locations = this._defineLocationData(marker, storeStart, page);
// Set up the list template with the location data
var listHtml = listTemplate(locations);
$('.' + this.settings.locationList + ' > ul').append(listHtml);
}
|
[
"function",
"(",
"marker",
",",
"storeStart",
",",
"page",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'listSetup'",
",",
"arguments",
")",
";",
"// Define the location data",
"var",
"locations",
"=",
"this",
".",
"_defineLocationData",
"(",
"marker",
",",
"storeStart",
",",
"page",
")",
";",
"// Set up the list template with the location data",
"var",
"listHtml",
"=",
"listTemplate",
"(",
"locations",
")",
";",
"$",
"(",
"'.'",
"+",
"this",
".",
"settings",
".",
"locationList",
"+",
"' > ul'",
")",
".",
"append",
"(",
"listHtml",
")",
";",
"}"
] |
Set up the list templates
@param marker {Object} Google Maps marker
@param storeStart {number} optional first location on the current page
@param page {number} optional current page
|
[
"Set",
"up",
"the",
"list",
"templates"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L1273-L1281
|
|
16,764
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function (marker) {
var markerImg;
// Reset the previously selected marker
if ( typeof prevSelectedMarkerAfter !== 'undefined' ) {
prevSelectedMarkerAfter.setIcon( prevSelectedMarkerBefore );
}
// Change the selected marker icon
if (this.settings.selectedMarkerImgDim === null) {
markerImg = this.markerImage(this.settings.selectedMarkerImg);
} else {
markerImg = this.markerImage(this.settings.selectedMarkerImg, this.settings.selectedMarkerImgDim.width, this.settings.selectedMarkerImgDim.height);
}
// Save the marker before switching it
prevSelectedMarkerBefore = marker.icon;
marker.setIcon( markerImg );
// Save the marker to a variable so it can be reverted when another marker is clicked
prevSelectedMarkerAfter = marker;
}
|
javascript
|
function (marker) {
var markerImg;
// Reset the previously selected marker
if ( typeof prevSelectedMarkerAfter !== 'undefined' ) {
prevSelectedMarkerAfter.setIcon( prevSelectedMarkerBefore );
}
// Change the selected marker icon
if (this.settings.selectedMarkerImgDim === null) {
markerImg = this.markerImage(this.settings.selectedMarkerImg);
} else {
markerImg = this.markerImage(this.settings.selectedMarkerImg, this.settings.selectedMarkerImgDim.width, this.settings.selectedMarkerImgDim.height);
}
// Save the marker before switching it
prevSelectedMarkerBefore = marker.icon;
marker.setIcon( markerImg );
// Save the marker to a variable so it can be reverted when another marker is clicked
prevSelectedMarkerAfter = marker;
}
|
[
"function",
"(",
"marker",
")",
"{",
"var",
"markerImg",
";",
"// Reset the previously selected marker",
"if",
"(",
"typeof",
"prevSelectedMarkerAfter",
"!==",
"'undefined'",
")",
"{",
"prevSelectedMarkerAfter",
".",
"setIcon",
"(",
"prevSelectedMarkerBefore",
")",
";",
"}",
"// Change the selected marker icon",
"if",
"(",
"this",
".",
"settings",
".",
"selectedMarkerImgDim",
"===",
"null",
")",
"{",
"markerImg",
"=",
"this",
".",
"markerImage",
"(",
"this",
".",
"settings",
".",
"selectedMarkerImg",
")",
";",
"}",
"else",
"{",
"markerImg",
"=",
"this",
".",
"markerImage",
"(",
"this",
".",
"settings",
".",
"selectedMarkerImg",
",",
"this",
".",
"settings",
".",
"selectedMarkerImgDim",
".",
"width",
",",
"this",
".",
"settings",
".",
"selectedMarkerImgDim",
".",
"height",
")",
";",
"}",
"// Save the marker before switching it",
"prevSelectedMarkerBefore",
"=",
"marker",
".",
"icon",
";",
"marker",
".",
"setIcon",
"(",
"markerImg",
")",
";",
"// Save the marker to a variable so it can be reverted when another marker is clicked",
"prevSelectedMarkerAfter",
"=",
"marker",
";",
"}"
] |
Change the selected marker image
@param marker {Object} Google Maps marker object
|
[
"Change",
"the",
"selected",
"marker",
"image"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L1288-L1310
|
|
16,765
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function (marker, location, infowindow, storeStart, page) {
this.writeDebug('createInfowindow',arguments);
var _this = this;
// Define the location data
var locations = this._defineLocationData(marker, storeStart, page);
// Set up the infowindow template with the location data
var formattedAddress = infowindowTemplate(locations);
// Opens the infowindow when list item is clicked
if (location === 'left') {
infowindow.setContent(formattedAddress);
infowindow.open(marker.get('map'), marker);
}
// Opens the infowindow when the marker is clicked
else {
google.maps.event.addListener(marker, 'click', function () {
infowindow.setContent(formattedAddress);
infowindow.open(marker.get('map'), marker);
// Focus on the list
var markerId = marker.get('id');
var $selectedLocation = $('.' + _this.settings.locationList + ' li[data-markerid=' + markerId + ']');
if ($selectedLocation.length > 0) {
// Marker click callback
if (_this.settings.callbackMarkerClick) {
_this.settings.callbackMarkerClick.call(this, marker, markerId, $selectedLocation, locationset[markerId]);
}
$('.' + _this.settings.locationList + ' li').removeClass('list-focus');
$selectedLocation.addClass('list-focus');
// Scroll list to selected marker
var $container = $('.' + _this.settings.locationList);
$container.animate({
scrollTop: $selectedLocation.offset().top - $container.offset().top + $container.scrollTop()
});
}
// Custom selected marker override
if (_this.settings.selectedMarkerImg !== null) {
_this.changeSelectedMarker(marker);
}
});
}
}
|
javascript
|
function (marker, location, infowindow, storeStart, page) {
this.writeDebug('createInfowindow',arguments);
var _this = this;
// Define the location data
var locations = this._defineLocationData(marker, storeStart, page);
// Set up the infowindow template with the location data
var formattedAddress = infowindowTemplate(locations);
// Opens the infowindow when list item is clicked
if (location === 'left') {
infowindow.setContent(formattedAddress);
infowindow.open(marker.get('map'), marker);
}
// Opens the infowindow when the marker is clicked
else {
google.maps.event.addListener(marker, 'click', function () {
infowindow.setContent(formattedAddress);
infowindow.open(marker.get('map'), marker);
// Focus on the list
var markerId = marker.get('id');
var $selectedLocation = $('.' + _this.settings.locationList + ' li[data-markerid=' + markerId + ']');
if ($selectedLocation.length > 0) {
// Marker click callback
if (_this.settings.callbackMarkerClick) {
_this.settings.callbackMarkerClick.call(this, marker, markerId, $selectedLocation, locationset[markerId]);
}
$('.' + _this.settings.locationList + ' li').removeClass('list-focus');
$selectedLocation.addClass('list-focus');
// Scroll list to selected marker
var $container = $('.' + _this.settings.locationList);
$container.animate({
scrollTop: $selectedLocation.offset().top - $container.offset().top + $container.scrollTop()
});
}
// Custom selected marker override
if (_this.settings.selectedMarkerImg !== null) {
_this.changeSelectedMarker(marker);
}
});
}
}
|
[
"function",
"(",
"marker",
",",
"location",
",",
"infowindow",
",",
"storeStart",
",",
"page",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'createInfowindow'",
",",
"arguments",
")",
";",
"var",
"_this",
"=",
"this",
";",
"// Define the location data",
"var",
"locations",
"=",
"this",
".",
"_defineLocationData",
"(",
"marker",
",",
"storeStart",
",",
"page",
")",
";",
"// Set up the infowindow template with the location data",
"var",
"formattedAddress",
"=",
"infowindowTemplate",
"(",
"locations",
")",
";",
"// Opens the infowindow when list item is clicked",
"if",
"(",
"location",
"===",
"'left'",
")",
"{",
"infowindow",
".",
"setContent",
"(",
"formattedAddress",
")",
";",
"infowindow",
".",
"open",
"(",
"marker",
".",
"get",
"(",
"'map'",
")",
",",
"marker",
")",
";",
"}",
"// Opens the infowindow when the marker is clicked",
"else",
"{",
"google",
".",
"maps",
".",
"event",
".",
"addListener",
"(",
"marker",
",",
"'click'",
",",
"function",
"(",
")",
"{",
"infowindow",
".",
"setContent",
"(",
"formattedAddress",
")",
";",
"infowindow",
".",
"open",
"(",
"marker",
".",
"get",
"(",
"'map'",
")",
",",
"marker",
")",
";",
"// Focus on the list",
"var",
"markerId",
"=",
"marker",
".",
"get",
"(",
"'id'",
")",
";",
"var",
"$selectedLocation",
"=",
"$",
"(",
"'.'",
"+",
"_this",
".",
"settings",
".",
"locationList",
"+",
"' li[data-markerid='",
"+",
"markerId",
"+",
"']'",
")",
";",
"if",
"(",
"$selectedLocation",
".",
"length",
">",
"0",
")",
"{",
"// Marker click callback",
"if",
"(",
"_this",
".",
"settings",
".",
"callbackMarkerClick",
")",
"{",
"_this",
".",
"settings",
".",
"callbackMarkerClick",
".",
"call",
"(",
"this",
",",
"marker",
",",
"markerId",
",",
"$selectedLocation",
",",
"locationset",
"[",
"markerId",
"]",
")",
";",
"}",
"$",
"(",
"'.'",
"+",
"_this",
".",
"settings",
".",
"locationList",
"+",
"' li'",
")",
".",
"removeClass",
"(",
"'list-focus'",
")",
";",
"$selectedLocation",
".",
"addClass",
"(",
"'list-focus'",
")",
";",
"// Scroll list to selected marker",
"var",
"$container",
"=",
"$",
"(",
"'.'",
"+",
"_this",
".",
"settings",
".",
"locationList",
")",
";",
"$container",
".",
"animate",
"(",
"{",
"scrollTop",
":",
"$selectedLocation",
".",
"offset",
"(",
")",
".",
"top",
"-",
"$container",
".",
"offset",
"(",
")",
".",
"top",
"+",
"$container",
".",
"scrollTop",
"(",
")",
"}",
")",
";",
"}",
"// Custom selected marker override",
"if",
"(",
"_this",
".",
"settings",
".",
"selectedMarkerImg",
"!==",
"null",
")",
"{",
"_this",
".",
"changeSelectedMarker",
"(",
"marker",
")",
";",
"}",
"}",
")",
";",
"}",
"}"
] |
Create the infowindow
@param marker {Object} Google Maps marker object
@param location {string} indicates if the list or a map marker was clicked
@param infowindow Google Maps InfoWindow constructor
@param storeStart {number}
@param page {number}
|
[
"Create",
"the",
"infowindow"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L1321-L1366
|
|
16,766
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function (position) {
this.writeDebug('autoGeocodeQuery',arguments);
var _this = this,
distance = null,
$distanceInput = $('#' + this.settings.maxDistanceID),
originAddress;
// Query string parameters
if (this.settings.querystringParams === true) {
// Check for distance query string parameters
if (this.getQueryString(this.settings.maxDistanceID)){
distance = this.getQueryString(this.settings.maxDistanceID);
if ($distanceInput.val() !== '') {
distance = $distanceInput.val();
}
}
else{
// Get the distance if set
if (this.settings.maxDistance === true) {
distance = $distanceInput.val() || '';
}
}
}
else {
// Get the distance if set
if (this.settings.maxDistance === true) {
distance = $distanceInput.val() || '';
}
}
// The address needs to be determined for the directions link
var r = new this.reverseGoogleGeocode(this);
var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
r.geocode({'latLng': latlng}, function (data) {
if (data !== null) {
originAddress = addressInput = data.address;
olat = mappingObj.lat = position.coords.latitude;
olng = mappingObj.lng = position.coords.longitude;
mappingObj.origin = originAddress;
mappingObj.distance = distance;
_this.mapping(mappingObj);
// Fill in the search box.
if (typeof originAddress !== 'undefined') {
$('#' + _this.settings.addressID).val(originAddress);
}
} else {
// Unable to geocode
_this.notify(_this.settings.addressErrorAlert);
}
});
}
|
javascript
|
function (position) {
this.writeDebug('autoGeocodeQuery',arguments);
var _this = this,
distance = null,
$distanceInput = $('#' + this.settings.maxDistanceID),
originAddress;
// Query string parameters
if (this.settings.querystringParams === true) {
// Check for distance query string parameters
if (this.getQueryString(this.settings.maxDistanceID)){
distance = this.getQueryString(this.settings.maxDistanceID);
if ($distanceInput.val() !== '') {
distance = $distanceInput.val();
}
}
else{
// Get the distance if set
if (this.settings.maxDistance === true) {
distance = $distanceInput.val() || '';
}
}
}
else {
// Get the distance if set
if (this.settings.maxDistance === true) {
distance = $distanceInput.val() || '';
}
}
// The address needs to be determined for the directions link
var r = new this.reverseGoogleGeocode(this);
var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
r.geocode({'latLng': latlng}, function (data) {
if (data !== null) {
originAddress = addressInput = data.address;
olat = mappingObj.lat = position.coords.latitude;
olng = mappingObj.lng = position.coords.longitude;
mappingObj.origin = originAddress;
mappingObj.distance = distance;
_this.mapping(mappingObj);
// Fill in the search box.
if (typeof originAddress !== 'undefined') {
$('#' + _this.settings.addressID).val(originAddress);
}
} else {
// Unable to geocode
_this.notify(_this.settings.addressErrorAlert);
}
});
}
|
[
"function",
"(",
"position",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'autoGeocodeQuery'",
",",
"arguments",
")",
";",
"var",
"_this",
"=",
"this",
",",
"distance",
"=",
"null",
",",
"$distanceInput",
"=",
"$",
"(",
"'#'",
"+",
"this",
".",
"settings",
".",
"maxDistanceID",
")",
",",
"originAddress",
";",
"// Query string parameters",
"if",
"(",
"this",
".",
"settings",
".",
"querystringParams",
"===",
"true",
")",
"{",
"// Check for distance query string parameters",
"if",
"(",
"this",
".",
"getQueryString",
"(",
"this",
".",
"settings",
".",
"maxDistanceID",
")",
")",
"{",
"distance",
"=",
"this",
".",
"getQueryString",
"(",
"this",
".",
"settings",
".",
"maxDistanceID",
")",
";",
"if",
"(",
"$distanceInput",
".",
"val",
"(",
")",
"!==",
"''",
")",
"{",
"distance",
"=",
"$distanceInput",
".",
"val",
"(",
")",
";",
"}",
"}",
"else",
"{",
"// Get the distance if set",
"if",
"(",
"this",
".",
"settings",
".",
"maxDistance",
"===",
"true",
")",
"{",
"distance",
"=",
"$distanceInput",
".",
"val",
"(",
")",
"||",
"''",
";",
"}",
"}",
"}",
"else",
"{",
"// Get the distance if set",
"if",
"(",
"this",
".",
"settings",
".",
"maxDistance",
"===",
"true",
")",
"{",
"distance",
"=",
"$distanceInput",
".",
"val",
"(",
")",
"||",
"''",
";",
"}",
"}",
"// The address needs to be determined for the directions link",
"var",
"r",
"=",
"new",
"this",
".",
"reverseGoogleGeocode",
"(",
"this",
")",
";",
"var",
"latlng",
"=",
"new",
"google",
".",
"maps",
".",
"LatLng",
"(",
"position",
".",
"coords",
".",
"latitude",
",",
"position",
".",
"coords",
".",
"longitude",
")",
";",
"r",
".",
"geocode",
"(",
"{",
"'latLng'",
":",
"latlng",
"}",
",",
"function",
"(",
"data",
")",
"{",
"if",
"(",
"data",
"!==",
"null",
")",
"{",
"originAddress",
"=",
"addressInput",
"=",
"data",
".",
"address",
";",
"olat",
"=",
"mappingObj",
".",
"lat",
"=",
"position",
".",
"coords",
".",
"latitude",
";",
"olng",
"=",
"mappingObj",
".",
"lng",
"=",
"position",
".",
"coords",
".",
"longitude",
";",
"mappingObj",
".",
"origin",
"=",
"originAddress",
";",
"mappingObj",
".",
"distance",
"=",
"distance",
";",
"_this",
".",
"mapping",
"(",
"mappingObj",
")",
";",
"// Fill in the search box.",
"if",
"(",
"typeof",
"originAddress",
"!==",
"'undefined'",
")",
"{",
"$",
"(",
"'#'",
"+",
"_this",
".",
"settings",
".",
"addressID",
")",
".",
"val",
"(",
"originAddress",
")",
";",
"}",
"}",
"else",
"{",
"// Unable to geocode",
"_this",
".",
"notify",
"(",
"_this",
".",
"settings",
".",
"addressErrorAlert",
")",
";",
"}",
"}",
")",
";",
"}"
] |
HTML5 geocoding function for automatic location detection
@param position {Object} coordinates
|
[
"HTML5",
"geocoding",
"function",
"for",
"automatic",
"location",
"detection"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L1373-L1425
|
|
16,767
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function() {
this.writeDebug('defaultLocation');
var _this = this,
distance = null,
$distanceInput = $('#' + this.settings.maxDistanceID),
originAddress;
// Query string parameters
if (this.settings.querystringParams === true) {
// Check for distance query string parameters
if (this.getQueryString(this.settings.maxDistanceID)){
distance = this.getQueryString(this.settings.maxDistanceID);
if ($distanceInput.val() !== '') {
distance = $distanceInput.val();
}
}
else {
// Get the distance if set
if (this.settings.maxDistance === true) {
distance = $distanceInput.val() || '';
}
}
}
else {
// Get the distance if set
if (this.settings.maxDistance === true) {
distance = $distanceInput.val() || '';
}
}
// The address needs to be determined for the directions link
var r = new this.reverseGoogleGeocode(this);
var latlng = new google.maps.LatLng(this.settings.defaultLat, this.settings.defaultLng);
r.geocode({'latLng': latlng}, function (data) {
if (data !== null) {
originAddress = addressInput = data.address;
olat = mappingObj.lat = _this.settings.defaultLat;
olng = mappingObj.lng = _this.settings.defaultLng;
mappingObj.distance = distance;
mappingObj.origin = originAddress;
_this.mapping(mappingObj);
} else {
// Unable to geocode
_this.notify(_this.settings.addressErrorAlert);
}
});
}
|
javascript
|
function() {
this.writeDebug('defaultLocation');
var _this = this,
distance = null,
$distanceInput = $('#' + this.settings.maxDistanceID),
originAddress;
// Query string parameters
if (this.settings.querystringParams === true) {
// Check for distance query string parameters
if (this.getQueryString(this.settings.maxDistanceID)){
distance = this.getQueryString(this.settings.maxDistanceID);
if ($distanceInput.val() !== '') {
distance = $distanceInput.val();
}
}
else {
// Get the distance if set
if (this.settings.maxDistance === true) {
distance = $distanceInput.val() || '';
}
}
}
else {
// Get the distance if set
if (this.settings.maxDistance === true) {
distance = $distanceInput.val() || '';
}
}
// The address needs to be determined for the directions link
var r = new this.reverseGoogleGeocode(this);
var latlng = new google.maps.LatLng(this.settings.defaultLat, this.settings.defaultLng);
r.geocode({'latLng': latlng}, function (data) {
if (data !== null) {
originAddress = addressInput = data.address;
olat = mappingObj.lat = _this.settings.defaultLat;
olng = mappingObj.lng = _this.settings.defaultLng;
mappingObj.distance = distance;
mappingObj.origin = originAddress;
_this.mapping(mappingObj);
} else {
// Unable to geocode
_this.notify(_this.settings.addressErrorAlert);
}
});
}
|
[
"function",
"(",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'defaultLocation'",
")",
";",
"var",
"_this",
"=",
"this",
",",
"distance",
"=",
"null",
",",
"$distanceInput",
"=",
"$",
"(",
"'#'",
"+",
"this",
".",
"settings",
".",
"maxDistanceID",
")",
",",
"originAddress",
";",
"// Query string parameters",
"if",
"(",
"this",
".",
"settings",
".",
"querystringParams",
"===",
"true",
")",
"{",
"// Check for distance query string parameters",
"if",
"(",
"this",
".",
"getQueryString",
"(",
"this",
".",
"settings",
".",
"maxDistanceID",
")",
")",
"{",
"distance",
"=",
"this",
".",
"getQueryString",
"(",
"this",
".",
"settings",
".",
"maxDistanceID",
")",
";",
"if",
"(",
"$distanceInput",
".",
"val",
"(",
")",
"!==",
"''",
")",
"{",
"distance",
"=",
"$distanceInput",
".",
"val",
"(",
")",
";",
"}",
"}",
"else",
"{",
"// Get the distance if set",
"if",
"(",
"this",
".",
"settings",
".",
"maxDistance",
"===",
"true",
")",
"{",
"distance",
"=",
"$distanceInput",
".",
"val",
"(",
")",
"||",
"''",
";",
"}",
"}",
"}",
"else",
"{",
"// Get the distance if set",
"if",
"(",
"this",
".",
"settings",
".",
"maxDistance",
"===",
"true",
")",
"{",
"distance",
"=",
"$distanceInput",
".",
"val",
"(",
")",
"||",
"''",
";",
"}",
"}",
"// The address needs to be determined for the directions link",
"var",
"r",
"=",
"new",
"this",
".",
"reverseGoogleGeocode",
"(",
"this",
")",
";",
"var",
"latlng",
"=",
"new",
"google",
".",
"maps",
".",
"LatLng",
"(",
"this",
".",
"settings",
".",
"defaultLat",
",",
"this",
".",
"settings",
".",
"defaultLng",
")",
";",
"r",
".",
"geocode",
"(",
"{",
"'latLng'",
":",
"latlng",
"}",
",",
"function",
"(",
"data",
")",
"{",
"if",
"(",
"data",
"!==",
"null",
")",
"{",
"originAddress",
"=",
"addressInput",
"=",
"data",
".",
"address",
";",
"olat",
"=",
"mappingObj",
".",
"lat",
"=",
"_this",
".",
"settings",
".",
"defaultLat",
";",
"olng",
"=",
"mappingObj",
".",
"lng",
"=",
"_this",
".",
"settings",
".",
"defaultLng",
";",
"mappingObj",
".",
"distance",
"=",
"distance",
";",
"mappingObj",
".",
"origin",
"=",
"originAddress",
";",
"_this",
".",
"mapping",
"(",
"mappingObj",
")",
";",
"}",
"else",
"{",
"// Unable to geocode",
"_this",
".",
"notify",
"(",
"_this",
".",
"settings",
".",
"addressErrorAlert",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Default location method
|
[
"Default",
"location",
"method"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L1440-L1487
|
|
16,768
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function (newPage) {
this.writeDebug('paginationChange',arguments);
// Page change callback
if (this.settings.callbackPageChange) {
this.settings.callbackPageChange.call(this, newPage);
}
mappingObj.page = newPage;
this.mapping(mappingObj);
}
|
javascript
|
function (newPage) {
this.writeDebug('paginationChange',arguments);
// Page change callback
if (this.settings.callbackPageChange) {
this.settings.callbackPageChange.call(this, newPage);
}
mappingObj.page = newPage;
this.mapping(mappingObj);
}
|
[
"function",
"(",
"newPage",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'paginationChange'",
",",
"arguments",
")",
";",
"// Page change callback",
"if",
"(",
"this",
".",
"settings",
".",
"callbackPageChange",
")",
"{",
"this",
".",
"settings",
".",
"callbackPageChange",
".",
"call",
"(",
"this",
",",
"newPage",
")",
";",
"}",
"mappingObj",
".",
"page",
"=",
"newPage",
";",
"this",
".",
"mapping",
"(",
"mappingObj",
")",
";",
"}"
] |
Change the page
@param newPage {number} page to change to
|
[
"Change",
"the",
"page"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L1494-L1504
|
|
16,769
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function(markerID) {
this.writeDebug('getAddressByMarker',arguments);
var formattedAddress = "";
// Set up formatted address
if(locationset[markerID].address){ formattedAddress += locationset[markerID].address + ' '; }
if(locationset[markerID].address2){ formattedAddress += locationset[markerID].address2 + ' '; }
if(locationset[markerID].city){ formattedAddress += locationset[markerID].city + ', '; }
if(locationset[markerID].state){ formattedAddress += locationset[markerID].state + ' '; }
if(locationset[markerID].postal){ formattedAddress += locationset[markerID].postal + ' '; }
if(locationset[markerID].country){ formattedAddress += locationset[markerID].country + ' '; }
return formattedAddress;
}
|
javascript
|
function(markerID) {
this.writeDebug('getAddressByMarker',arguments);
var formattedAddress = "";
// Set up formatted address
if(locationset[markerID].address){ formattedAddress += locationset[markerID].address + ' '; }
if(locationset[markerID].address2){ formattedAddress += locationset[markerID].address2 + ' '; }
if(locationset[markerID].city){ formattedAddress += locationset[markerID].city + ', '; }
if(locationset[markerID].state){ formattedAddress += locationset[markerID].state + ' '; }
if(locationset[markerID].postal){ formattedAddress += locationset[markerID].postal + ' '; }
if(locationset[markerID].country){ formattedAddress += locationset[markerID].country + ' '; }
return formattedAddress;
}
|
[
"function",
"(",
"markerID",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'getAddressByMarker'",
",",
"arguments",
")",
";",
"var",
"formattedAddress",
"=",
"\"\"",
";",
"// Set up formatted address",
"if",
"(",
"locationset",
"[",
"markerID",
"]",
".",
"address",
")",
"{",
"formattedAddress",
"+=",
"locationset",
"[",
"markerID",
"]",
".",
"address",
"+",
"' '",
";",
"}",
"if",
"(",
"locationset",
"[",
"markerID",
"]",
".",
"address2",
")",
"{",
"formattedAddress",
"+=",
"locationset",
"[",
"markerID",
"]",
".",
"address2",
"+",
"' '",
";",
"}",
"if",
"(",
"locationset",
"[",
"markerID",
"]",
".",
"city",
")",
"{",
"formattedAddress",
"+=",
"locationset",
"[",
"markerID",
"]",
".",
"city",
"+",
"', '",
";",
"}",
"if",
"(",
"locationset",
"[",
"markerID",
"]",
".",
"state",
")",
"{",
"formattedAddress",
"+=",
"locationset",
"[",
"markerID",
"]",
".",
"state",
"+",
"' '",
";",
"}",
"if",
"(",
"locationset",
"[",
"markerID",
"]",
".",
"postal",
")",
"{",
"formattedAddress",
"+=",
"locationset",
"[",
"markerID",
"]",
".",
"postal",
"+",
"' '",
";",
"}",
"if",
"(",
"locationset",
"[",
"markerID",
"]",
".",
"country",
")",
"{",
"formattedAddress",
"+=",
"locationset",
"[",
"markerID",
"]",
".",
"country",
"+",
"' '",
";",
"}",
"return",
"formattedAddress",
";",
"}"
] |
Get the address by marker ID
@param markerID {number} location ID
@returns {string} formatted address
|
[
"Get",
"the",
"address",
"by",
"marker",
"ID"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L1512-L1524
|
|
16,770
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function() {
this.writeDebug('clearMarkers');
var locationsLimit = null;
if (locationset.length < this.settings.storeLimit) {
locationsLimit = locationset.length;
}
else {
locationsLimit = this.settings.storeLimit;
}
for (var i = 0; i < locationsLimit; i++) {
markers[i].setMap(null);
}
}
|
javascript
|
function() {
this.writeDebug('clearMarkers');
var locationsLimit = null;
if (locationset.length < this.settings.storeLimit) {
locationsLimit = locationset.length;
}
else {
locationsLimit = this.settings.storeLimit;
}
for (var i = 0; i < locationsLimit; i++) {
markers[i].setMap(null);
}
}
|
[
"function",
"(",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'clearMarkers'",
")",
";",
"var",
"locationsLimit",
"=",
"null",
";",
"if",
"(",
"locationset",
".",
"length",
"<",
"this",
".",
"settings",
".",
"storeLimit",
")",
"{",
"locationsLimit",
"=",
"locationset",
".",
"length",
";",
"}",
"else",
"{",
"locationsLimit",
"=",
"this",
".",
"settings",
".",
"storeLimit",
";",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"locationsLimit",
";",
"i",
"++",
")",
"{",
"markers",
"[",
"i",
"]",
".",
"setMap",
"(",
"null",
")",
";",
"}",
"}"
] |
Clear the markers from the map
|
[
"Clear",
"the",
"markers",
"from",
"the",
"map"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L1529-L1543
|
|
16,771
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function(origin, locID, map) {
this.writeDebug('directionsRequest',arguments);
// Directions request callback
if (this.settings.callbackDirectionsRequest) {
this.settings.callbackDirectionsRequest.call(this, origin, locID, map, locationset[locID]);
}
var destination = this.getAddressByMarker(locID);
if (destination) {
// Hide the location list
$('.' + this.settings.locationList + ' ul').hide();
// Remove the markers
this.clearMarkers();
// Clear the previous directions request
if (directionsDisplay !== null && typeof directionsDisplay !== 'undefined') {
directionsDisplay.setMap(null);
directionsDisplay = null;
}
directionsDisplay = new google.maps.DirectionsRenderer();
directionsService = new google.maps.DirectionsService();
// Directions request
directionsDisplay.setMap(map);
directionsDisplay.setPanel($('.bh-sl-directions-panel').get(0));
var request = {
origin: origin,
destination: destination,
travelMode: google.maps.TravelMode.DRIVING
};
directionsService.route(request, function(response, status) {
if (status === google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
$('.' + this.settings.locationList).prepend('<div class="bh-sl-close-directions-container"><div class="' + this.settings.closeIcon + '"></div></div>');
}
$(document).off('click', '.' + this.settings.locationList + ' li .loc-directions a');
}
|
javascript
|
function(origin, locID, map) {
this.writeDebug('directionsRequest',arguments);
// Directions request callback
if (this.settings.callbackDirectionsRequest) {
this.settings.callbackDirectionsRequest.call(this, origin, locID, map, locationset[locID]);
}
var destination = this.getAddressByMarker(locID);
if (destination) {
// Hide the location list
$('.' + this.settings.locationList + ' ul').hide();
// Remove the markers
this.clearMarkers();
// Clear the previous directions request
if (directionsDisplay !== null && typeof directionsDisplay !== 'undefined') {
directionsDisplay.setMap(null);
directionsDisplay = null;
}
directionsDisplay = new google.maps.DirectionsRenderer();
directionsService = new google.maps.DirectionsService();
// Directions request
directionsDisplay.setMap(map);
directionsDisplay.setPanel($('.bh-sl-directions-panel').get(0));
var request = {
origin: origin,
destination: destination,
travelMode: google.maps.TravelMode.DRIVING
};
directionsService.route(request, function(response, status) {
if (status === google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
$('.' + this.settings.locationList).prepend('<div class="bh-sl-close-directions-container"><div class="' + this.settings.closeIcon + '"></div></div>');
}
$(document).off('click', '.' + this.settings.locationList + ' li .loc-directions a');
}
|
[
"function",
"(",
"origin",
",",
"locID",
",",
"map",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'directionsRequest'",
",",
"arguments",
")",
";",
"// Directions request callback",
"if",
"(",
"this",
".",
"settings",
".",
"callbackDirectionsRequest",
")",
"{",
"this",
".",
"settings",
".",
"callbackDirectionsRequest",
".",
"call",
"(",
"this",
",",
"origin",
",",
"locID",
",",
"map",
",",
"locationset",
"[",
"locID",
"]",
")",
";",
"}",
"var",
"destination",
"=",
"this",
".",
"getAddressByMarker",
"(",
"locID",
")",
";",
"if",
"(",
"destination",
")",
"{",
"// Hide the location list",
"$",
"(",
"'.'",
"+",
"this",
".",
"settings",
".",
"locationList",
"+",
"' ul'",
")",
".",
"hide",
"(",
")",
";",
"// Remove the markers",
"this",
".",
"clearMarkers",
"(",
")",
";",
"// Clear the previous directions request",
"if",
"(",
"directionsDisplay",
"!==",
"null",
"&&",
"typeof",
"directionsDisplay",
"!==",
"'undefined'",
")",
"{",
"directionsDisplay",
".",
"setMap",
"(",
"null",
")",
";",
"directionsDisplay",
"=",
"null",
";",
"}",
"directionsDisplay",
"=",
"new",
"google",
".",
"maps",
".",
"DirectionsRenderer",
"(",
")",
";",
"directionsService",
"=",
"new",
"google",
".",
"maps",
".",
"DirectionsService",
"(",
")",
";",
"// Directions request",
"directionsDisplay",
".",
"setMap",
"(",
"map",
")",
";",
"directionsDisplay",
".",
"setPanel",
"(",
"$",
"(",
"'.bh-sl-directions-panel'",
")",
".",
"get",
"(",
"0",
")",
")",
";",
"var",
"request",
"=",
"{",
"origin",
":",
"origin",
",",
"destination",
":",
"destination",
",",
"travelMode",
":",
"google",
".",
"maps",
".",
"TravelMode",
".",
"DRIVING",
"}",
";",
"directionsService",
".",
"route",
"(",
"request",
",",
"function",
"(",
"response",
",",
"status",
")",
"{",
"if",
"(",
"status",
"===",
"google",
".",
"maps",
".",
"DirectionsStatus",
".",
"OK",
")",
"{",
"directionsDisplay",
".",
"setDirections",
"(",
"response",
")",
";",
"}",
"}",
")",
";",
"$",
"(",
"'.'",
"+",
"this",
".",
"settings",
".",
"locationList",
")",
".",
"prepend",
"(",
"'<div class=\"bh-sl-close-directions-container\"><div class=\"'",
"+",
"this",
".",
"settings",
".",
"closeIcon",
"+",
"'\"></div></div>'",
")",
";",
"}",
"$",
"(",
"document",
")",
".",
"off",
"(",
"'click'",
",",
"'.'",
"+",
"this",
".",
"settings",
".",
"locationList",
"+",
"' li .loc-directions a'",
")",
";",
"}"
] |
Handle inline direction requests
@param origin {string} origin address
@param locID {number} location ID
@param map {Object} Google Map
|
[
"Handle",
"inline",
"direction",
"requests"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L1552-L1596
|
|
16,772
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function() {
this.writeDebug('closeDirections');
// Close directions callback
if (this.settings.callbackCloseDirections) {
this.settings.callbackCloseDirections.call(this);
}
// Remove the close icon, remove the directions, add the list back
this.reset();
if ((olat) && (olng)) {
if (this.countFilters() === 0) {
this.settings.mapSettings.zoom = originalZoom;
}
else {
this.settings.mapSettings.zoom = 0;
}
this.processForm(null);
}
$(document).off('click.'+pluginName, '.' + this.settings.locationList + ' .bh-sl-close-icon');
}
|
javascript
|
function() {
this.writeDebug('closeDirections');
// Close directions callback
if (this.settings.callbackCloseDirections) {
this.settings.callbackCloseDirections.call(this);
}
// Remove the close icon, remove the directions, add the list back
this.reset();
if ((olat) && (olng)) {
if (this.countFilters() === 0) {
this.settings.mapSettings.zoom = originalZoom;
}
else {
this.settings.mapSettings.zoom = 0;
}
this.processForm(null);
}
$(document).off('click.'+pluginName, '.' + this.settings.locationList + ' .bh-sl-close-icon');
}
|
[
"function",
"(",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'closeDirections'",
")",
";",
"// Close directions callback",
"if",
"(",
"this",
".",
"settings",
".",
"callbackCloseDirections",
")",
"{",
"this",
".",
"settings",
".",
"callbackCloseDirections",
".",
"call",
"(",
"this",
")",
";",
"}",
"// Remove the close icon, remove the directions, add the list back",
"this",
".",
"reset",
"(",
")",
";",
"if",
"(",
"(",
"olat",
")",
"&&",
"(",
"olng",
")",
")",
"{",
"if",
"(",
"this",
".",
"countFilters",
"(",
")",
"===",
"0",
")",
"{",
"this",
".",
"settings",
".",
"mapSettings",
".",
"zoom",
"=",
"originalZoom",
";",
"}",
"else",
"{",
"this",
".",
"settings",
".",
"mapSettings",
".",
"zoom",
"=",
"0",
";",
"}",
"this",
".",
"processForm",
"(",
"null",
")",
";",
"}",
"$",
"(",
"document",
")",
".",
"off",
"(",
"'click.'",
"+",
"pluginName",
",",
"'.'",
"+",
"this",
".",
"settings",
".",
"locationList",
"+",
"' .bh-sl-close-icon'",
")",
";",
"}"
] |
Close the directions panel and reset the map with the original locationset and zoom
|
[
"Close",
"the",
"directions",
"panel",
"and",
"reset",
"the",
"map",
"with",
"the",
"original",
"locationset",
"and",
"zoom"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L1601-L1623
|
|
16,773
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function($lengthSwap) {
this.writeDebug('lengthUnitSwap',arguments);
if ($lengthSwap.val() === 'alt-distance') {
$('.' + this.settings.locationList + ' .loc-alt-dist').show();
$('.' + this.settings.locationList + ' .loc-default-dist').hide();
} else if ($lengthSwap.val() === 'default-distance') {
$('.' + this.settings.locationList + ' .loc-default-dist').show();
$('.' + this.settings.locationList + ' .loc-alt-dist').hide();
}
}
|
javascript
|
function($lengthSwap) {
this.writeDebug('lengthUnitSwap',arguments);
if ($lengthSwap.val() === 'alt-distance') {
$('.' + this.settings.locationList + ' .loc-alt-dist').show();
$('.' + this.settings.locationList + ' .loc-default-dist').hide();
} else if ($lengthSwap.val() === 'default-distance') {
$('.' + this.settings.locationList + ' .loc-default-dist').show();
$('.' + this.settings.locationList + ' .loc-alt-dist').hide();
}
}
|
[
"function",
"(",
"$lengthSwap",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'lengthUnitSwap'",
",",
"arguments",
")",
";",
"if",
"(",
"$lengthSwap",
".",
"val",
"(",
")",
"===",
"'alt-distance'",
")",
"{",
"$",
"(",
"'.'",
"+",
"this",
".",
"settings",
".",
"locationList",
"+",
"' .loc-alt-dist'",
")",
".",
"show",
"(",
")",
";",
"$",
"(",
"'.'",
"+",
"this",
".",
"settings",
".",
"locationList",
"+",
"' .loc-default-dist'",
")",
".",
"hide",
"(",
")",
";",
"}",
"else",
"if",
"(",
"$lengthSwap",
".",
"val",
"(",
")",
"===",
"'default-distance'",
")",
"{",
"$",
"(",
"'.'",
"+",
"this",
".",
"settings",
".",
"locationList",
"+",
"' .loc-default-dist'",
")",
".",
"show",
"(",
")",
";",
"$",
"(",
"'.'",
"+",
"this",
".",
"settings",
".",
"locationList",
"+",
"' .loc-alt-dist'",
")",
".",
"hide",
"(",
")",
";",
"}",
"}"
] |
Handle length unit swap
@param $lengthSwap
|
[
"Handle",
"length",
"unit",
"swap"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L1630-L1640
|
|
16,774
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function (data, lat, lng, origin, maxDistance) {
this.writeDebug('locationsSetup',arguments);
if (typeof origin !== 'undefined') {
if (!data.distance) {
data.distance = this.geoCodeCalcCalcDistance(lat, lng, data.lat, data.lng, GeoCodeCalc.EarthRadius);
// Alternative distance length unit
if (this.settings.lengthUnit === 'm') {
// Miles to kilometers
data.altdistance = parseFloat(data.distance)*1.609344;
} else if (this.settings.lengthUnit === 'km') {
// Kilometers to miles
data.altdistance = parseFloat(data.distance)/1.609344;
}
}
}
// Create the array
if (this.settings.maxDistance === true && typeof maxDistance !== 'undefined' && maxDistance !== null) {
if (data.distance <= maxDistance) {
locationset.push( data );
}
else {
return;
}
}
else if (this.settings.maxDistance === true && this.settings.querystringParams === true && typeof maxDistance !== 'undefined' && maxDistance !== null) {
if (data.distance <= maxDistance) {
locationset.push( data );
}
else {
return;
}
}
else {
locationset.push( data );
}
}
|
javascript
|
function (data, lat, lng, origin, maxDistance) {
this.writeDebug('locationsSetup',arguments);
if (typeof origin !== 'undefined') {
if (!data.distance) {
data.distance = this.geoCodeCalcCalcDistance(lat, lng, data.lat, data.lng, GeoCodeCalc.EarthRadius);
// Alternative distance length unit
if (this.settings.lengthUnit === 'm') {
// Miles to kilometers
data.altdistance = parseFloat(data.distance)*1.609344;
} else if (this.settings.lengthUnit === 'km') {
// Kilometers to miles
data.altdistance = parseFloat(data.distance)/1.609344;
}
}
}
// Create the array
if (this.settings.maxDistance === true && typeof maxDistance !== 'undefined' && maxDistance !== null) {
if (data.distance <= maxDistance) {
locationset.push( data );
}
else {
return;
}
}
else if (this.settings.maxDistance === true && this.settings.querystringParams === true && typeof maxDistance !== 'undefined' && maxDistance !== null) {
if (data.distance <= maxDistance) {
locationset.push( data );
}
else {
return;
}
}
else {
locationset.push( data );
}
}
|
[
"function",
"(",
"data",
",",
"lat",
",",
"lng",
",",
"origin",
",",
"maxDistance",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'locationsSetup'",
",",
"arguments",
")",
";",
"if",
"(",
"typeof",
"origin",
"!==",
"'undefined'",
")",
"{",
"if",
"(",
"!",
"data",
".",
"distance",
")",
"{",
"data",
".",
"distance",
"=",
"this",
".",
"geoCodeCalcCalcDistance",
"(",
"lat",
",",
"lng",
",",
"data",
".",
"lat",
",",
"data",
".",
"lng",
",",
"GeoCodeCalc",
".",
"EarthRadius",
")",
";",
"// Alternative distance length unit",
"if",
"(",
"this",
".",
"settings",
".",
"lengthUnit",
"===",
"'m'",
")",
"{",
"// Miles to kilometers",
"data",
".",
"altdistance",
"=",
"parseFloat",
"(",
"data",
".",
"distance",
")",
"*",
"1.609344",
";",
"}",
"else",
"if",
"(",
"this",
".",
"settings",
".",
"lengthUnit",
"===",
"'km'",
")",
"{",
"// Kilometers to miles",
"data",
".",
"altdistance",
"=",
"parseFloat",
"(",
"data",
".",
"distance",
")",
"/",
"1.609344",
";",
"}",
"}",
"}",
"// Create the array",
"if",
"(",
"this",
".",
"settings",
".",
"maxDistance",
"===",
"true",
"&&",
"typeof",
"maxDistance",
"!==",
"'undefined'",
"&&",
"maxDistance",
"!==",
"null",
")",
"{",
"if",
"(",
"data",
".",
"distance",
"<=",
"maxDistance",
")",
"{",
"locationset",
".",
"push",
"(",
"data",
")",
";",
"}",
"else",
"{",
"return",
";",
"}",
"}",
"else",
"if",
"(",
"this",
".",
"settings",
".",
"maxDistance",
"===",
"true",
"&&",
"this",
".",
"settings",
".",
"querystringParams",
"===",
"true",
"&&",
"typeof",
"maxDistance",
"!==",
"'undefined'",
"&&",
"maxDistance",
"!==",
"null",
")",
"{",
"if",
"(",
"data",
".",
"distance",
"<=",
"maxDistance",
")",
"{",
"locationset",
".",
"push",
"(",
"data",
")",
";",
"}",
"else",
"{",
"return",
";",
"}",
"}",
"else",
"{",
"locationset",
".",
"push",
"(",
"data",
")",
";",
"}",
"}"
] |
Checks distance of each location and sets up the locationset array
@param data {Object} location data object
@param lat {number} origin latitude
@param lng {number} origin longitude
@param origin {string} origin address
@param maxDistance {number} maximum distance if set
|
[
"Checks",
"distance",
"of",
"each",
"location",
"and",
"sets",
"up",
"the",
"locationset",
"array"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L1801-L1838
|
|
16,775
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function() {
this.writeDebug('sorting',arguments);
var _this = this,
$mapDiv = $('#' + _this.settings.mapID),
$sortSelect = $('#' + _this.settings.sortID);
if ($sortSelect.length === 0) {
return;
}
$sortSelect.on('change.'+pluginName, function (e) {
e.stopPropagation();
// Reset pagination.
if (_this.settings.pagination === true) {
_this.paginationChange(0);
}
var sortMethod,
sortVal;
sortMethod = (typeof $(this).find(':selected').attr('data-method') !== 'undefined') ? $(this).find(':selected').attr('data-method') : 'distance';
sortVal = $(this).val();
_this.settings.sortBy.method = sortMethod;
_this.settings.sortBy.prop = sortVal;
// Callback
if (_this.settings.callbackSorting) {
_this.settings.callbackSorting.call(this, _this.settings.sortBy);
}
if ($mapDiv.hasClass('bh-sl-map-open')) {
_this.mapping(mappingObj);
}
});
}
|
javascript
|
function() {
this.writeDebug('sorting',arguments);
var _this = this,
$mapDiv = $('#' + _this.settings.mapID),
$sortSelect = $('#' + _this.settings.sortID);
if ($sortSelect.length === 0) {
return;
}
$sortSelect.on('change.'+pluginName, function (e) {
e.stopPropagation();
// Reset pagination.
if (_this.settings.pagination === true) {
_this.paginationChange(0);
}
var sortMethod,
sortVal;
sortMethod = (typeof $(this).find(':selected').attr('data-method') !== 'undefined') ? $(this).find(':selected').attr('data-method') : 'distance';
sortVal = $(this).val();
_this.settings.sortBy.method = sortMethod;
_this.settings.sortBy.prop = sortVal;
// Callback
if (_this.settings.callbackSorting) {
_this.settings.callbackSorting.call(this, _this.settings.sortBy);
}
if ($mapDiv.hasClass('bh-sl-map-open')) {
_this.mapping(mappingObj);
}
});
}
|
[
"function",
"(",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'sorting'",
",",
"arguments",
")",
";",
"var",
"_this",
"=",
"this",
",",
"$mapDiv",
"=",
"$",
"(",
"'#'",
"+",
"_this",
".",
"settings",
".",
"mapID",
")",
",",
"$sortSelect",
"=",
"$",
"(",
"'#'",
"+",
"_this",
".",
"settings",
".",
"sortID",
")",
";",
"if",
"(",
"$sortSelect",
".",
"length",
"===",
"0",
")",
"{",
"return",
";",
"}",
"$sortSelect",
".",
"on",
"(",
"'change.'",
"+",
"pluginName",
",",
"function",
"(",
"e",
")",
"{",
"e",
".",
"stopPropagation",
"(",
")",
";",
"// Reset pagination.",
"if",
"(",
"_this",
".",
"settings",
".",
"pagination",
"===",
"true",
")",
"{",
"_this",
".",
"paginationChange",
"(",
"0",
")",
";",
"}",
"var",
"sortMethod",
",",
"sortVal",
";",
"sortMethod",
"=",
"(",
"typeof",
"$",
"(",
"this",
")",
".",
"find",
"(",
"':selected'",
")",
".",
"attr",
"(",
"'data-method'",
")",
"!==",
"'undefined'",
")",
"?",
"$",
"(",
"this",
")",
".",
"find",
"(",
"':selected'",
")",
".",
"attr",
"(",
"'data-method'",
")",
":",
"'distance'",
";",
"sortVal",
"=",
"$",
"(",
"this",
")",
".",
"val",
"(",
")",
";",
"_this",
".",
"settings",
".",
"sortBy",
".",
"method",
"=",
"sortMethod",
";",
"_this",
".",
"settings",
".",
"sortBy",
".",
"prop",
"=",
"sortVal",
";",
"// Callback",
"if",
"(",
"_this",
".",
"settings",
".",
"callbackSorting",
")",
"{",
"_this",
".",
"settings",
".",
"callbackSorting",
".",
"call",
"(",
"this",
",",
"_this",
".",
"settings",
".",
"sortBy",
")",
";",
"}",
"if",
"(",
"$mapDiv",
".",
"hasClass",
"(",
"'bh-sl-map-open'",
")",
")",
"{",
"_this",
".",
"mapping",
"(",
"mappingObj",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Set up front-end sorting functionality
|
[
"Set",
"up",
"front",
"-",
"end",
"sorting",
"functionality"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L1843-L1879
|
|
16,776
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function() {
this.writeDebug('order',arguments);
var _this = this,
$mapDiv = $('#' + _this.settings.mapID),
$orderSelect = $('#' + _this.settings.orderID);
if ($orderSelect.length === 0) {
return;
}
$orderSelect.on('change.'+pluginName, function (e) {
e.stopPropagation();
// Reset pagination.
if (_this.settings.pagination === true) {
_this.paginationChange(0);
}
_this.settings.sortBy.order = $(this).val();
// Callback
if (_this.settings.callbackOrder) {
_this.settings.callbackOrder.call(this, _this.settings.order);
}
if ($mapDiv.hasClass('bh-sl-map-open')) {
_this.mapping(mappingObj);
}
});
}
|
javascript
|
function() {
this.writeDebug('order',arguments);
var _this = this,
$mapDiv = $('#' + _this.settings.mapID),
$orderSelect = $('#' + _this.settings.orderID);
if ($orderSelect.length === 0) {
return;
}
$orderSelect.on('change.'+pluginName, function (e) {
e.stopPropagation();
// Reset pagination.
if (_this.settings.pagination === true) {
_this.paginationChange(0);
}
_this.settings.sortBy.order = $(this).val();
// Callback
if (_this.settings.callbackOrder) {
_this.settings.callbackOrder.call(this, _this.settings.order);
}
if ($mapDiv.hasClass('bh-sl-map-open')) {
_this.mapping(mappingObj);
}
});
}
|
[
"function",
"(",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'order'",
",",
"arguments",
")",
";",
"var",
"_this",
"=",
"this",
",",
"$mapDiv",
"=",
"$",
"(",
"'#'",
"+",
"_this",
".",
"settings",
".",
"mapID",
")",
",",
"$orderSelect",
"=",
"$",
"(",
"'#'",
"+",
"_this",
".",
"settings",
".",
"orderID",
")",
";",
"if",
"(",
"$orderSelect",
".",
"length",
"===",
"0",
")",
"{",
"return",
";",
"}",
"$orderSelect",
".",
"on",
"(",
"'change.'",
"+",
"pluginName",
",",
"function",
"(",
"e",
")",
"{",
"e",
".",
"stopPropagation",
"(",
")",
";",
"// Reset pagination.",
"if",
"(",
"_this",
".",
"settings",
".",
"pagination",
"===",
"true",
")",
"{",
"_this",
".",
"paginationChange",
"(",
"0",
")",
";",
"}",
"_this",
".",
"settings",
".",
"sortBy",
".",
"order",
"=",
"$",
"(",
"this",
")",
".",
"val",
"(",
")",
";",
"// Callback",
"if",
"(",
"_this",
".",
"settings",
".",
"callbackOrder",
")",
"{",
"_this",
".",
"settings",
".",
"callbackOrder",
".",
"call",
"(",
"this",
",",
"_this",
".",
"settings",
".",
"order",
")",
";",
"}",
"if",
"(",
"$mapDiv",
".",
"hasClass",
"(",
"'bh-sl-map-open'",
")",
")",
"{",
"_this",
".",
"mapping",
"(",
"mappingObj",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Set up front-end ordering functionality - this ties in to sorting and that has to be enabled for this to work.
|
[
"Set",
"up",
"front",
"-",
"end",
"ordering",
"functionality",
"-",
"this",
"ties",
"in",
"to",
"sorting",
"and",
"that",
"has",
"to",
"be",
"enabled",
"for",
"this",
"to",
"work",
"."
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L1884-L1913
|
|
16,777
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function () {
this.writeDebug('countFilters');
var filterCount = 0;
if (!this.isEmptyObject(filters)) {
for (var key in filters) {
if (filters.hasOwnProperty(key)) {
filterCount += filters[key].length;
}
}
}
return filterCount;
}
|
javascript
|
function () {
this.writeDebug('countFilters');
var filterCount = 0;
if (!this.isEmptyObject(filters)) {
for (var key in filters) {
if (filters.hasOwnProperty(key)) {
filterCount += filters[key].length;
}
}
}
return filterCount;
}
|
[
"function",
"(",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'countFilters'",
")",
";",
"var",
"filterCount",
"=",
"0",
";",
"if",
"(",
"!",
"this",
".",
"isEmptyObject",
"(",
"filters",
")",
")",
"{",
"for",
"(",
"var",
"key",
"in",
"filters",
")",
"{",
"if",
"(",
"filters",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"filterCount",
"+=",
"filters",
"[",
"key",
"]",
".",
"length",
";",
"}",
"}",
"}",
"return",
"filterCount",
";",
"}"
] |
Count the selected filters
@returns {number}
|
[
"Count",
"the",
"selected",
"filters"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L1920-L1933
|
|
16,778
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function(key) {
this.writeDebug('_existingRadioFilters',arguments);
$('#' + this.settings.taxonomyFilters[key] + ' input[type=radio]').each(function () {
if ($(this).prop('checked')) {
var filterVal = $(this).val();
// Only add the taxonomy id if it doesn't already exist
if (typeof filterVal !== 'undefined' && filterVal !== '' && filters[key].indexOf(filterVal) === -1) {
filters[key] = [filterVal];
}
}
});
}
|
javascript
|
function(key) {
this.writeDebug('_existingRadioFilters',arguments);
$('#' + this.settings.taxonomyFilters[key] + ' input[type=radio]').each(function () {
if ($(this).prop('checked')) {
var filterVal = $(this).val();
// Only add the taxonomy id if it doesn't already exist
if (typeof filterVal !== 'undefined' && filterVal !== '' && filters[key].indexOf(filterVal) === -1) {
filters[key] = [filterVal];
}
}
});
}
|
[
"function",
"(",
"key",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'_existingRadioFilters'",
",",
"arguments",
")",
";",
"$",
"(",
"'#'",
"+",
"this",
".",
"settings",
".",
"taxonomyFilters",
"[",
"key",
"]",
"+",
"' input[type=radio]'",
")",
".",
"each",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"$",
"(",
"this",
")",
".",
"prop",
"(",
"'checked'",
")",
")",
"{",
"var",
"filterVal",
"=",
"$",
"(",
"this",
")",
".",
"val",
"(",
")",
";",
"// Only add the taxonomy id if it doesn't already exist",
"if",
"(",
"typeof",
"filterVal",
"!==",
"'undefined'",
"&&",
"filterVal",
"!==",
"''",
"&&",
"filters",
"[",
"key",
"]",
".",
"indexOf",
"(",
"filterVal",
")",
"===",
"-",
"1",
")",
"{",
"filters",
"[",
"key",
"]",
"=",
"[",
"filterVal",
"]",
";",
"}",
"}",
"}",
")",
";",
"}"
] |
Find the existing selected value for each radio button filter - private
@param key {string} object key
|
[
"Find",
"the",
"existing",
"selected",
"value",
"for",
"each",
"radio",
"button",
"filter",
"-",
"private"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L1976-L1988
|
|
16,779
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function () {
this.writeDebug('checkFilters');
for(var key in this.settings.taxonomyFilters) {
if (this.settings.taxonomyFilters.hasOwnProperty(key)) {
// Find the existing checked boxes for each checkbox filter
this._existingCheckedFilters(key);
// Find the existing selected value for each select filter
this._existingSelectedFilters(key);
// Find the existing value for each radio button filter
this._existingRadioFilters(key);
}
}
}
|
javascript
|
function () {
this.writeDebug('checkFilters');
for(var key in this.settings.taxonomyFilters) {
if (this.settings.taxonomyFilters.hasOwnProperty(key)) {
// Find the existing checked boxes for each checkbox filter
this._existingCheckedFilters(key);
// Find the existing selected value for each select filter
this._existingSelectedFilters(key);
// Find the existing value for each radio button filter
this._existingRadioFilters(key);
}
}
}
|
[
"function",
"(",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'checkFilters'",
")",
";",
"for",
"(",
"var",
"key",
"in",
"this",
".",
"settings",
".",
"taxonomyFilters",
")",
"{",
"if",
"(",
"this",
".",
"settings",
".",
"taxonomyFilters",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"// Find the existing checked boxes for each checkbox filter",
"this",
".",
"_existingCheckedFilters",
"(",
"key",
")",
";",
"// Find the existing selected value for each select filter",
"this",
".",
"_existingSelectedFilters",
"(",
"key",
")",
";",
"// Find the existing value for each radio button filter",
"this",
".",
"_existingRadioFilters",
"(",
"key",
")",
";",
"}",
"}",
"}"
] |
Check for existing filter selections
|
[
"Check",
"for",
"existing",
"filter",
"selections"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L1993-L2008
|
|
16,780
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function( taxonomy, value ) {
this.writeDebug('selectQueryStringFilters', arguments);
var $taxGroupContainer = $('#' + this.settings.taxonomyFilters[taxonomy]);
// Handle checkboxes.
if ( $taxGroupContainer.find('input[type="checkbox"]').length ) {
for ( var i = 0; i < value.length; i++ ) {
$taxGroupContainer.find('input:checkbox[value="' + value[i] + '"]').prop('checked', true);
}
}
// Handle select fields.
if ( $taxGroupContainer.find('select').length ) {
// Only expecting one value for select fields.
$taxGroupContainer.find('option[value="' + value[0] + '"]').prop('selected', true);
}
// Handle radio buttons.
if ( $taxGroupContainer.find('input[type="radio"]').length ) {
// Only one value for radio button.
$taxGroupContainer.find('input:radio[value="' + value[0] + '"]').prop('checked', true);
}
}
|
javascript
|
function( taxonomy, value ) {
this.writeDebug('selectQueryStringFilters', arguments);
var $taxGroupContainer = $('#' + this.settings.taxonomyFilters[taxonomy]);
// Handle checkboxes.
if ( $taxGroupContainer.find('input[type="checkbox"]').length ) {
for ( var i = 0; i < value.length; i++ ) {
$taxGroupContainer.find('input:checkbox[value="' + value[i] + '"]').prop('checked', true);
}
}
// Handle select fields.
if ( $taxGroupContainer.find('select').length ) {
// Only expecting one value for select fields.
$taxGroupContainer.find('option[value="' + value[0] + '"]').prop('selected', true);
}
// Handle radio buttons.
if ( $taxGroupContainer.find('input[type="radio"]').length ) {
// Only one value for radio button.
$taxGroupContainer.find('input:radio[value="' + value[0] + '"]').prop('checked', true);
}
}
|
[
"function",
"(",
"taxonomy",
",",
"value",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'selectQueryStringFilters'",
",",
"arguments",
")",
";",
"var",
"$taxGroupContainer",
"=",
"$",
"(",
"'#'",
"+",
"this",
".",
"settings",
".",
"taxonomyFilters",
"[",
"taxonomy",
"]",
")",
";",
"// Handle checkboxes.",
"if",
"(",
"$taxGroupContainer",
".",
"find",
"(",
"'input[type=\"checkbox\"]'",
")",
".",
"length",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"value",
".",
"length",
";",
"i",
"++",
")",
"{",
"$taxGroupContainer",
".",
"find",
"(",
"'input:checkbox[value=\"'",
"+",
"value",
"[",
"i",
"]",
"+",
"'\"]'",
")",
".",
"prop",
"(",
"'checked'",
",",
"true",
")",
";",
"}",
"}",
"// Handle select fields.",
"if",
"(",
"$taxGroupContainer",
".",
"find",
"(",
"'select'",
")",
".",
"length",
")",
"{",
"// Only expecting one value for select fields.",
"$taxGroupContainer",
".",
"find",
"(",
"'option[value=\"'",
"+",
"value",
"[",
"0",
"]",
"+",
"'\"]'",
")",
".",
"prop",
"(",
"'selected'",
",",
"true",
")",
";",
"}",
"// Handle radio buttons.",
"if",
"(",
"$taxGroupContainer",
".",
"find",
"(",
"'input[type=\"radio\"]'",
")",
".",
"length",
")",
"{",
"// Only one value for radio button.",
"$taxGroupContainer",
".",
"find",
"(",
"'input:radio[value=\"'",
"+",
"value",
"[",
"0",
"]",
"+",
"'\"]'",
")",
".",
"prop",
"(",
"'checked'",
",",
"true",
")",
";",
"}",
"}"
] |
Select the indicated values from query string parameters.
@param taxonomy {string} Current taxonomy.
@param value {array} Query string array values.
|
[
"Select",
"the",
"indicated",
"values",
"from",
"query",
"string",
"parameters",
"."
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L2016-L2040
|
|
16,781
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function () {
this.writeDebug('checkQueryStringFilters',arguments);
// Loop through the filters.
for(var key in filters) {
if (filters.hasOwnProperty(key)) {
var filterVal = this.getQueryString(key);
// Check for multiple values separated by comma.
if ( filterVal.indexOf( ',' ) !== -1 ) {
filterVal = filterVal.split( ',' );
}
// Only add the taxonomy id if it doesn't already exist
if (typeof filterVal !== 'undefined' && filterVal !== '' && filters[key].indexOf(filterVal) === -1) {
if ( Array.isArray( filterVal ) ) {
filters[key] = filterVal;
} else {
filters[key] = [filterVal];
}
}
// Select the filters indicated in the query string.
if ( filters[key].length ) {
this.selectQueryStringFilters( key, filters[key] );
}
}
}
}
|
javascript
|
function () {
this.writeDebug('checkQueryStringFilters',arguments);
// Loop through the filters.
for(var key in filters) {
if (filters.hasOwnProperty(key)) {
var filterVal = this.getQueryString(key);
// Check for multiple values separated by comma.
if ( filterVal.indexOf( ',' ) !== -1 ) {
filterVal = filterVal.split( ',' );
}
// Only add the taxonomy id if it doesn't already exist
if (typeof filterVal !== 'undefined' && filterVal !== '' && filters[key].indexOf(filterVal) === -1) {
if ( Array.isArray( filterVal ) ) {
filters[key] = filterVal;
} else {
filters[key] = [filterVal];
}
}
// Select the filters indicated in the query string.
if ( filters[key].length ) {
this.selectQueryStringFilters( key, filters[key] );
}
}
}
}
|
[
"function",
"(",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'checkQueryStringFilters'",
",",
"arguments",
")",
";",
"// Loop through the filters.",
"for",
"(",
"var",
"key",
"in",
"filters",
")",
"{",
"if",
"(",
"filters",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"var",
"filterVal",
"=",
"this",
".",
"getQueryString",
"(",
"key",
")",
";",
"// Check for multiple values separated by comma.",
"if",
"(",
"filterVal",
".",
"indexOf",
"(",
"','",
")",
"!==",
"-",
"1",
")",
"{",
"filterVal",
"=",
"filterVal",
".",
"split",
"(",
"','",
")",
";",
"}",
"// Only add the taxonomy id if it doesn't already exist",
"if",
"(",
"typeof",
"filterVal",
"!==",
"'undefined'",
"&&",
"filterVal",
"!==",
"''",
"&&",
"filters",
"[",
"key",
"]",
".",
"indexOf",
"(",
"filterVal",
")",
"===",
"-",
"1",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"filterVal",
")",
")",
"{",
"filters",
"[",
"key",
"]",
"=",
"filterVal",
";",
"}",
"else",
"{",
"filters",
"[",
"key",
"]",
"=",
"[",
"filterVal",
"]",
";",
"}",
"}",
"// Select the filters indicated in the query string.",
"if",
"(",
"filters",
"[",
"key",
"]",
".",
"length",
")",
"{",
"this",
".",
"selectQueryStringFilters",
"(",
"key",
",",
"filters",
"[",
"key",
"]",
")",
";",
"}",
"}",
"}",
"}"
] |
Check query string parameters for filter values.
|
[
"Check",
"query",
"string",
"parameters",
"for",
"filter",
"values",
"."
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L2045-L2074
|
|
16,782
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function (filterContainer) {
this.writeDebug('getFilterKey',arguments);
for (var key in this.settings.taxonomyFilters) {
if (this.settings.taxonomyFilters.hasOwnProperty(key)) {
for (var i = 0; i < this.settings.taxonomyFilters[key].length; i++) {
if (this.settings.taxonomyFilters[key] === filterContainer) {
return key;
}
}
}
}
}
|
javascript
|
function (filterContainer) {
this.writeDebug('getFilterKey',arguments);
for (var key in this.settings.taxonomyFilters) {
if (this.settings.taxonomyFilters.hasOwnProperty(key)) {
for (var i = 0; i < this.settings.taxonomyFilters[key].length; i++) {
if (this.settings.taxonomyFilters[key] === filterContainer) {
return key;
}
}
}
}
}
|
[
"function",
"(",
"filterContainer",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'getFilterKey'",
",",
"arguments",
")",
";",
"for",
"(",
"var",
"key",
"in",
"this",
".",
"settings",
".",
"taxonomyFilters",
")",
"{",
"if",
"(",
"this",
".",
"settings",
".",
"taxonomyFilters",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"settings",
".",
"taxonomyFilters",
"[",
"key",
"]",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"this",
".",
"settings",
".",
"taxonomyFilters",
"[",
"key",
"]",
"===",
"filterContainer",
")",
"{",
"return",
"key",
";",
"}",
"}",
"}",
"}",
"}"
] |
Get the filter key from the taxonomyFilter setting
@param filterContainer {string} ID of the changed filter's container
|
[
"Get",
"the",
"filter",
"key",
"from",
"the",
"taxonomyFilter",
"setting"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L2081-L2092
|
|
16,783
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function () {
this.writeDebug('taxonomyFiltersInit');
// Set up the filters
for(var key in this.settings.taxonomyFilters) {
if (this.settings.taxonomyFilters.hasOwnProperty(key)) {
filters[key] = [];
}
}
}
|
javascript
|
function () {
this.writeDebug('taxonomyFiltersInit');
// Set up the filters
for(var key in this.settings.taxonomyFilters) {
if (this.settings.taxonomyFilters.hasOwnProperty(key)) {
filters[key] = [];
}
}
}
|
[
"function",
"(",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'taxonomyFiltersInit'",
")",
";",
"// Set up the filters",
"for",
"(",
"var",
"key",
"in",
"this",
".",
"settings",
".",
"taxonomyFilters",
")",
"{",
"if",
"(",
"this",
".",
"settings",
".",
"taxonomyFilters",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"filters",
"[",
"key",
"]",
"=",
"[",
"]",
";",
"}",
"}",
"}"
] |
Initialize or reset the filters object to its original state
|
[
"Initialize",
"or",
"reset",
"the",
"filters",
"object",
"to",
"its",
"original",
"state"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L2097-L2106
|
|
16,784
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function(markers, map) {
this.writeDebug('checkVisibleMarkers',arguments);
var _this = this;
var locations, listHtml;
// Empty the location list
$('.' + this.settings.locationList + ' ul').empty();
// Set up the new list
$(markers).each(function(x, marker){
if (map.getBounds().contains(marker.getPosition())) {
// Define the location data
_this.listSetup(marker, 0, 0);
// Set up the list template with the location data
listHtml = listTemplate(locations);
$('.' + _this.settings.locationList + ' > ul').append(listHtml);
}
});
// Re-add the list background colors
$('.' + this.settings.locationList + ' ul li:even').css('background', this.settings.listColor1);
$('.' + this.settings.locationList + ' ul li:odd').css('background', this.settings.listColor2);
}
|
javascript
|
function(markers, map) {
this.writeDebug('checkVisibleMarkers',arguments);
var _this = this;
var locations, listHtml;
// Empty the location list
$('.' + this.settings.locationList + ' ul').empty();
// Set up the new list
$(markers).each(function(x, marker){
if (map.getBounds().contains(marker.getPosition())) {
// Define the location data
_this.listSetup(marker, 0, 0);
// Set up the list template with the location data
listHtml = listTemplate(locations);
$('.' + _this.settings.locationList + ' > ul').append(listHtml);
}
});
// Re-add the list background colors
$('.' + this.settings.locationList + ' ul li:even').css('background', this.settings.listColor1);
$('.' + this.settings.locationList + ' ul li:odd').css('background', this.settings.listColor2);
}
|
[
"function",
"(",
"markers",
",",
"map",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'checkVisibleMarkers'",
",",
"arguments",
")",
";",
"var",
"_this",
"=",
"this",
";",
"var",
"locations",
",",
"listHtml",
";",
"// Empty the location list",
"$",
"(",
"'.'",
"+",
"this",
".",
"settings",
".",
"locationList",
"+",
"' ul'",
")",
".",
"empty",
"(",
")",
";",
"// Set up the new list",
"$",
"(",
"markers",
")",
".",
"each",
"(",
"function",
"(",
"x",
",",
"marker",
")",
"{",
"if",
"(",
"map",
".",
"getBounds",
"(",
")",
".",
"contains",
"(",
"marker",
".",
"getPosition",
"(",
")",
")",
")",
"{",
"// Define the location data",
"_this",
".",
"listSetup",
"(",
"marker",
",",
"0",
",",
"0",
")",
";",
"// Set up the list template with the location data",
"listHtml",
"=",
"listTemplate",
"(",
"locations",
")",
";",
"$",
"(",
"'.'",
"+",
"_this",
".",
"settings",
".",
"locationList",
"+",
"' > ul'",
")",
".",
"append",
"(",
"listHtml",
")",
";",
"}",
"}",
")",
";",
"// Re-add the list background colors",
"$",
"(",
"'.'",
"+",
"this",
".",
"settings",
".",
"locationList",
"+",
"' ul li:even'",
")",
".",
"css",
"(",
"'background'",
",",
"this",
".",
"settings",
".",
"listColor1",
")",
";",
"$",
"(",
"'.'",
"+",
"this",
".",
"settings",
".",
"locationList",
"+",
"' ul li:odd'",
")",
".",
"css",
"(",
"'background'",
",",
"this",
".",
"settings",
".",
"listColor2",
")",
";",
"}"
] |
Updates the location list to reflect the markers that are displayed on the map
@param markers {Object} Map markers
@param map {Object} Google map
|
[
"Updates",
"the",
"location",
"list",
"to",
"reflect",
"the",
"markers",
"that",
"are",
"displayed",
"on",
"the",
"map"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L2230-L2253
|
|
16,785
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function(map) {
this.writeDebug('dragSearch',arguments);
var newCenter = map.getCenter(),
newCenterCoords,
_this = this;
// Save the new zoom setting
this.settings.mapSettings.zoom = map.getZoom();
olat = mappingObj.lat = newCenter.lat();
olng = mappingObj.lng = newCenter.lng();
// Determine the new origin addresss
var newAddress = new this.reverseGoogleGeocode(this);
newCenterCoords = new google.maps.LatLng(mappingObj.lat, mappingObj.lng);
newAddress.geocode({'latLng': newCenterCoords}, function (data) {
if (data !== null) {
mappingObj.origin = addressInput = data.address;
_this.mapping(mappingObj);
} else {
// Unable to geocode
_this.notify(_this.settings.addressErrorAlert);
}
});
}
|
javascript
|
function(map) {
this.writeDebug('dragSearch',arguments);
var newCenter = map.getCenter(),
newCenterCoords,
_this = this;
// Save the new zoom setting
this.settings.mapSettings.zoom = map.getZoom();
olat = mappingObj.lat = newCenter.lat();
olng = mappingObj.lng = newCenter.lng();
// Determine the new origin addresss
var newAddress = new this.reverseGoogleGeocode(this);
newCenterCoords = new google.maps.LatLng(mappingObj.lat, mappingObj.lng);
newAddress.geocode({'latLng': newCenterCoords}, function (data) {
if (data !== null) {
mappingObj.origin = addressInput = data.address;
_this.mapping(mappingObj);
} else {
// Unable to geocode
_this.notify(_this.settings.addressErrorAlert);
}
});
}
|
[
"function",
"(",
"map",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'dragSearch'",
",",
"arguments",
")",
";",
"var",
"newCenter",
"=",
"map",
".",
"getCenter",
"(",
")",
",",
"newCenterCoords",
",",
"_this",
"=",
"this",
";",
"// Save the new zoom setting",
"this",
".",
"settings",
".",
"mapSettings",
".",
"zoom",
"=",
"map",
".",
"getZoom",
"(",
")",
";",
"olat",
"=",
"mappingObj",
".",
"lat",
"=",
"newCenter",
".",
"lat",
"(",
")",
";",
"olng",
"=",
"mappingObj",
".",
"lng",
"=",
"newCenter",
".",
"lng",
"(",
")",
";",
"// Determine the new origin addresss",
"var",
"newAddress",
"=",
"new",
"this",
".",
"reverseGoogleGeocode",
"(",
"this",
")",
";",
"newCenterCoords",
"=",
"new",
"google",
".",
"maps",
".",
"LatLng",
"(",
"mappingObj",
".",
"lat",
",",
"mappingObj",
".",
"lng",
")",
";",
"newAddress",
".",
"geocode",
"(",
"{",
"'latLng'",
":",
"newCenterCoords",
"}",
",",
"function",
"(",
"data",
")",
"{",
"if",
"(",
"data",
"!==",
"null",
")",
"{",
"mappingObj",
".",
"origin",
"=",
"addressInput",
"=",
"data",
".",
"address",
";",
"_this",
".",
"mapping",
"(",
"mappingObj",
")",
";",
"}",
"else",
"{",
"// Unable to geocode",
"_this",
".",
"notify",
"(",
"_this",
".",
"settings",
".",
"addressErrorAlert",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Performs a new search when the map is dragged to a new position
@param map {Object} Google map
|
[
"Performs",
"a",
"new",
"search",
"when",
"the",
"map",
"is",
"dragged",
"to",
"a",
"new",
"position"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L2260-L2284
|
|
16,786
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function() {
this.writeDebug('emptyResult',arguments);
var center,
locList = $('.' + this.settings.locationList + ' ul'),
myOptions = this.settings.mapSettings,
noResults;
// Create the map
this.map = new google.maps.Map(document.getElementById(this.settings.mapID), myOptions);
// Callback
if (this.settings.callbackNoResults) {
this.settings.callbackNoResults.call(this, this.map, myOptions);
}
// Empty the location list
locList.empty();
// Append the no results message
noResults = $('<li><div class="bh-sl-noresults-title">' + this.settings.noResultsTitle + '</div><br><div class="bh-sl-noresults-desc">' + this.settings.noResultsDesc + '</li>').hide().fadeIn();
locList.append(noResults);
// Center on the original origin or 0,0 if not available
if ((olat) && (olng)) {
center = new google.maps.LatLng(olat, olng);
} else {
center = new google.maps.LatLng(0, 0);
}
this.map.setCenter(center);
if (originalZoom) {
this.map.setZoom(originalZoom);
}
}
|
javascript
|
function() {
this.writeDebug('emptyResult',arguments);
var center,
locList = $('.' + this.settings.locationList + ' ul'),
myOptions = this.settings.mapSettings,
noResults;
// Create the map
this.map = new google.maps.Map(document.getElementById(this.settings.mapID), myOptions);
// Callback
if (this.settings.callbackNoResults) {
this.settings.callbackNoResults.call(this, this.map, myOptions);
}
// Empty the location list
locList.empty();
// Append the no results message
noResults = $('<li><div class="bh-sl-noresults-title">' + this.settings.noResultsTitle + '</div><br><div class="bh-sl-noresults-desc">' + this.settings.noResultsDesc + '</li>').hide().fadeIn();
locList.append(noResults);
// Center on the original origin or 0,0 if not available
if ((olat) && (olng)) {
center = new google.maps.LatLng(olat, olng);
} else {
center = new google.maps.LatLng(0, 0);
}
this.map.setCenter(center);
if (originalZoom) {
this.map.setZoom(originalZoom);
}
}
|
[
"function",
"(",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'emptyResult'",
",",
"arguments",
")",
";",
"var",
"center",
",",
"locList",
"=",
"$",
"(",
"'.'",
"+",
"this",
".",
"settings",
".",
"locationList",
"+",
"' ul'",
")",
",",
"myOptions",
"=",
"this",
".",
"settings",
".",
"mapSettings",
",",
"noResults",
";",
"// Create the map",
"this",
".",
"map",
"=",
"new",
"google",
".",
"maps",
".",
"Map",
"(",
"document",
".",
"getElementById",
"(",
"this",
".",
"settings",
".",
"mapID",
")",
",",
"myOptions",
")",
";",
"// Callback",
"if",
"(",
"this",
".",
"settings",
".",
"callbackNoResults",
")",
"{",
"this",
".",
"settings",
".",
"callbackNoResults",
".",
"call",
"(",
"this",
",",
"this",
".",
"map",
",",
"myOptions",
")",
";",
"}",
"// Empty the location list",
"locList",
".",
"empty",
"(",
")",
";",
"// Append the no results message",
"noResults",
"=",
"$",
"(",
"'<li><div class=\"bh-sl-noresults-title\">'",
"+",
"this",
".",
"settings",
".",
"noResultsTitle",
"+",
"'</div><br><div class=\"bh-sl-noresults-desc\">'",
"+",
"this",
".",
"settings",
".",
"noResultsDesc",
"+",
"'</li>'",
")",
".",
"hide",
"(",
")",
".",
"fadeIn",
"(",
")",
";",
"locList",
".",
"append",
"(",
"noResults",
")",
";",
"// Center on the original origin or 0,0 if not available",
"if",
"(",
"(",
"olat",
")",
"&&",
"(",
"olng",
")",
")",
"{",
"center",
"=",
"new",
"google",
".",
"maps",
".",
"LatLng",
"(",
"olat",
",",
"olng",
")",
";",
"}",
"else",
"{",
"center",
"=",
"new",
"google",
".",
"maps",
".",
"LatLng",
"(",
"0",
",",
"0",
")",
";",
"}",
"this",
".",
"map",
".",
"setCenter",
"(",
"center",
")",
";",
"if",
"(",
"originalZoom",
")",
"{",
"this",
".",
"map",
".",
"setZoom",
"(",
"originalZoom",
")",
";",
"}",
"}"
] |
Handle no results
|
[
"Handle",
"no",
"results"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L2289-L2323
|
|
16,787
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function(map, origin, originPoint) {
this.writeDebug('originMarker',arguments);
if (this.settings.originMarker !== true) {
return;
}
var marker,
originImg = '';
if (typeof origin !== 'undefined') {
if (this.settings.originMarkerImg !== null) {
if (this.settings.originMarkerDim === null) {
originImg = this.markerImage(this.settings.originMarkerImg);
}
else {
originImg = this.markerImage(this.settings.originMarkerImg, this.settings.originMarkerDim.width, this.settings.originMarkerDim.height);
}
}
else {
originImg = {
url: 'https://mt.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-a.png'
};
}
marker = new google.maps.Marker({
position : originPoint,
map : map,
icon : originImg,
draggable: false
});
}
}
|
javascript
|
function(map, origin, originPoint) {
this.writeDebug('originMarker',arguments);
if (this.settings.originMarker !== true) {
return;
}
var marker,
originImg = '';
if (typeof origin !== 'undefined') {
if (this.settings.originMarkerImg !== null) {
if (this.settings.originMarkerDim === null) {
originImg = this.markerImage(this.settings.originMarkerImg);
}
else {
originImg = this.markerImage(this.settings.originMarkerImg, this.settings.originMarkerDim.width, this.settings.originMarkerDim.height);
}
}
else {
originImg = {
url: 'https://mt.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-a.png'
};
}
marker = new google.maps.Marker({
position : originPoint,
map : map,
icon : originImg,
draggable: false
});
}
}
|
[
"function",
"(",
"map",
",",
"origin",
",",
"originPoint",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'originMarker'",
",",
"arguments",
")",
";",
"if",
"(",
"this",
".",
"settings",
".",
"originMarker",
"!==",
"true",
")",
"{",
"return",
";",
"}",
"var",
"marker",
",",
"originImg",
"=",
"''",
";",
"if",
"(",
"typeof",
"origin",
"!==",
"'undefined'",
")",
"{",
"if",
"(",
"this",
".",
"settings",
".",
"originMarkerImg",
"!==",
"null",
")",
"{",
"if",
"(",
"this",
".",
"settings",
".",
"originMarkerDim",
"===",
"null",
")",
"{",
"originImg",
"=",
"this",
".",
"markerImage",
"(",
"this",
".",
"settings",
".",
"originMarkerImg",
")",
";",
"}",
"else",
"{",
"originImg",
"=",
"this",
".",
"markerImage",
"(",
"this",
".",
"settings",
".",
"originMarkerImg",
",",
"this",
".",
"settings",
".",
"originMarkerDim",
".",
"width",
",",
"this",
".",
"settings",
".",
"originMarkerDim",
".",
"height",
")",
";",
"}",
"}",
"else",
"{",
"originImg",
"=",
"{",
"url",
":",
"'https://mt.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-a.png'",
"}",
";",
"}",
"marker",
"=",
"new",
"google",
".",
"maps",
".",
"Marker",
"(",
"{",
"position",
":",
"originPoint",
",",
"map",
":",
"map",
",",
"icon",
":",
"originImg",
",",
"draggable",
":",
"false",
"}",
")",
";",
"}",
"}"
] |
Origin marker setup
@param map {Object} Google map
@param origin {string} Origin address
@param originPoint {Object} LatLng of origin point
|
[
"Origin",
"marker",
"setup"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L2333-L2365
|
|
16,788
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function() {
this.writeDebug('modalWindow');
if (this.settings.modal !== true) {
return;
}
var _this = this;
// Callback
if (_this.settings.callbackModalOpen) {
_this.settings.callbackModalOpen.call(this);
}
// Pop up the modal window
$('.' + _this.settings.overlay).fadeIn();
// Close modal when close icon is clicked and when background overlay is clicked
$(document).on('click.'+pluginName, '.' + _this.settings.closeIcon + ', .' + _this.settings.overlay, function () {
_this.modalClose();
});
// Prevent clicks within the modal window from closing the entire thing
$(document).on('click.'+pluginName, '.' + _this.settings.modalWindow, function (e) {
e.stopPropagation();
});
// Close modal when escape key is pressed
$(document).on('keyup.'+pluginName, function (e) {
if (e.keyCode === 27) {
_this.modalClose();
}
});
}
|
javascript
|
function() {
this.writeDebug('modalWindow');
if (this.settings.modal !== true) {
return;
}
var _this = this;
// Callback
if (_this.settings.callbackModalOpen) {
_this.settings.callbackModalOpen.call(this);
}
// Pop up the modal window
$('.' + _this.settings.overlay).fadeIn();
// Close modal when close icon is clicked and when background overlay is clicked
$(document).on('click.'+pluginName, '.' + _this.settings.closeIcon + ', .' + _this.settings.overlay, function () {
_this.modalClose();
});
// Prevent clicks within the modal window from closing the entire thing
$(document).on('click.'+pluginName, '.' + _this.settings.modalWindow, function (e) {
e.stopPropagation();
});
// Close modal when escape key is pressed
$(document).on('keyup.'+pluginName, function (e) {
if (e.keyCode === 27) {
_this.modalClose();
}
});
}
|
[
"function",
"(",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'modalWindow'",
")",
";",
"if",
"(",
"this",
".",
"settings",
".",
"modal",
"!==",
"true",
")",
"{",
"return",
";",
"}",
"var",
"_this",
"=",
"this",
";",
"// Callback",
"if",
"(",
"_this",
".",
"settings",
".",
"callbackModalOpen",
")",
"{",
"_this",
".",
"settings",
".",
"callbackModalOpen",
".",
"call",
"(",
"this",
")",
";",
"}",
"// Pop up the modal window",
"$",
"(",
"'.'",
"+",
"_this",
".",
"settings",
".",
"overlay",
")",
".",
"fadeIn",
"(",
")",
";",
"// Close modal when close icon is clicked and when background overlay is clicked",
"$",
"(",
"document",
")",
".",
"on",
"(",
"'click.'",
"+",
"pluginName",
",",
"'.'",
"+",
"_this",
".",
"settings",
".",
"closeIcon",
"+",
"', .'",
"+",
"_this",
".",
"settings",
".",
"overlay",
",",
"function",
"(",
")",
"{",
"_this",
".",
"modalClose",
"(",
")",
";",
"}",
")",
";",
"// Prevent clicks within the modal window from closing the entire thing",
"$",
"(",
"document",
")",
".",
"on",
"(",
"'click.'",
"+",
"pluginName",
",",
"'.'",
"+",
"_this",
".",
"settings",
".",
"modalWindow",
",",
"function",
"(",
"e",
")",
"{",
"e",
".",
"stopPropagation",
"(",
")",
";",
"}",
")",
";",
"// Close modal when escape key is pressed",
"$",
"(",
"document",
")",
".",
"on",
"(",
"'keyup.'",
"+",
"pluginName",
",",
"function",
"(",
"e",
")",
"{",
"if",
"(",
"e",
".",
"keyCode",
"===",
"27",
")",
"{",
"_this",
".",
"modalClose",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Modal window setup
|
[
"Modal",
"window",
"setup"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L2370-L2400
|
|
16,789
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function(nearestLoc, infowindow, storeStart, page) {
this.writeDebug('openNearestLocation',arguments);
if (this.settings.openNearest !== true || typeof nearestLoc === 'undefined' || (this.settings.fullMapStart === true && firstRun === true) || (this.settings.defaultLoc === true && firstRun === true)) {
return;
}
var _this = this;
// Callback
if (_this.settings.callbackNearestLoc) {
_this.settings.callbackNearestLoc.call(this, _this.map, nearestLoc, infowindow, storeStart, page);
}
var markerId = 0;
var selectedMarker = markers[markerId];
_this.createInfowindow(selectedMarker, 'left', infowindow, storeStart, page);
// Scroll list to selected marker
var $container = $('.' + _this.settings.locationList);
var $selectedLocation = $('.' + _this.settings.locationList + ' li[data-markerid=' + markerId + ']');
// Focus on the list
$('.' + _this.settings.locationList + ' li').removeClass('list-focus');
$selectedLocation.addClass('list-focus');
$container.animate({
scrollTop: $selectedLocation.offset().top - $container.offset().top + $container.scrollTop()
});
}
|
javascript
|
function(nearestLoc, infowindow, storeStart, page) {
this.writeDebug('openNearestLocation',arguments);
if (this.settings.openNearest !== true || typeof nearestLoc === 'undefined' || (this.settings.fullMapStart === true && firstRun === true) || (this.settings.defaultLoc === true && firstRun === true)) {
return;
}
var _this = this;
// Callback
if (_this.settings.callbackNearestLoc) {
_this.settings.callbackNearestLoc.call(this, _this.map, nearestLoc, infowindow, storeStart, page);
}
var markerId = 0;
var selectedMarker = markers[markerId];
_this.createInfowindow(selectedMarker, 'left', infowindow, storeStart, page);
// Scroll list to selected marker
var $container = $('.' + _this.settings.locationList);
var $selectedLocation = $('.' + _this.settings.locationList + ' li[data-markerid=' + markerId + ']');
// Focus on the list
$('.' + _this.settings.locationList + ' li').removeClass('list-focus');
$selectedLocation.addClass('list-focus');
$container.animate({
scrollTop: $selectedLocation.offset().top - $container.offset().top + $container.scrollTop()
});
}
|
[
"function",
"(",
"nearestLoc",
",",
"infowindow",
",",
"storeStart",
",",
"page",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'openNearestLocation'",
",",
"arguments",
")",
";",
"if",
"(",
"this",
".",
"settings",
".",
"openNearest",
"!==",
"true",
"||",
"typeof",
"nearestLoc",
"===",
"'undefined'",
"||",
"(",
"this",
".",
"settings",
".",
"fullMapStart",
"===",
"true",
"&&",
"firstRun",
"===",
"true",
")",
"||",
"(",
"this",
".",
"settings",
".",
"defaultLoc",
"===",
"true",
"&&",
"firstRun",
"===",
"true",
")",
")",
"{",
"return",
";",
"}",
"var",
"_this",
"=",
"this",
";",
"// Callback",
"if",
"(",
"_this",
".",
"settings",
".",
"callbackNearestLoc",
")",
"{",
"_this",
".",
"settings",
".",
"callbackNearestLoc",
".",
"call",
"(",
"this",
",",
"_this",
".",
"map",
",",
"nearestLoc",
",",
"infowindow",
",",
"storeStart",
",",
"page",
")",
";",
"}",
"var",
"markerId",
"=",
"0",
";",
"var",
"selectedMarker",
"=",
"markers",
"[",
"markerId",
"]",
";",
"_this",
".",
"createInfowindow",
"(",
"selectedMarker",
",",
"'left'",
",",
"infowindow",
",",
"storeStart",
",",
"page",
")",
";",
"// Scroll list to selected marker",
"var",
"$container",
"=",
"$",
"(",
"'.'",
"+",
"_this",
".",
"settings",
".",
"locationList",
")",
";",
"var",
"$selectedLocation",
"=",
"$",
"(",
"'.'",
"+",
"_this",
".",
"settings",
".",
"locationList",
"+",
"' li[data-markerid='",
"+",
"markerId",
"+",
"']'",
")",
";",
"// Focus on the list",
"$",
"(",
"'.'",
"+",
"_this",
".",
"settings",
".",
"locationList",
"+",
"' li'",
")",
".",
"removeClass",
"(",
"'list-focus'",
")",
";",
"$selectedLocation",
".",
"addClass",
"(",
"'list-focus'",
")",
";",
"$container",
".",
"animate",
"(",
"{",
"scrollTop",
":",
"$selectedLocation",
".",
"offset",
"(",
")",
".",
"top",
"-",
"$container",
".",
"offset",
"(",
")",
".",
"top",
"+",
"$container",
".",
"scrollTop",
"(",
")",
"}",
")",
";",
"}"
] |
Open and select the location closest to the origin
@param nearestLoc {Object} Details for the nearest location
@param infowindow {Object} Info window object
@param storeStart {number} Starting point of current page when pagination is enabled
@param page {number} Current page number when pagination is enabled
|
[
"Open",
"and",
"select",
"the",
"location",
"closest",
"to",
"the",
"origin"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L2410-L2440
|
|
16,790
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function(map, infowindow, storeStart, page) {
this.writeDebug('listClick',arguments);
var _this = this;
$(document).on('click.' + pluginName, '.' + _this.settings.locationList + ' li', function () {
var markerId = $(this).data('markerid');
var selectedMarker = markers[markerId];
// List click callback
if (_this.settings.callbackListClick) {
_this.settings.callbackListClick.call(this, markerId, selectedMarker, locationset[markerId], map);
}
map.panTo(selectedMarker.getPosition());
var listLoc = 'left';
if (_this.settings.bounceMarker === true) {
selectedMarker.setAnimation(google.maps.Animation.BOUNCE);
setTimeout(function () {
selectedMarker.setAnimation(null);
_this.createInfowindow(selectedMarker, listLoc, infowindow, storeStart, page);
}, 700
);
}
else {
_this.createInfowindow(selectedMarker, listLoc, infowindow, storeStart, page);
}
// Custom selected marker override
if (_this.settings.selectedMarkerImg !== null) {
_this.changeSelectedMarker(selectedMarker);
}
// Focus on the list
$('.' + _this.settings.locationList + ' li').removeClass('list-focus');
$('.' + _this.settings.locationList + ' li[data-markerid=' + markerId + ']').addClass('list-focus');
});
// Prevent bubbling from list content links
$(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' li a', function(e) {
e.stopPropagation();
});
}
|
javascript
|
function(map, infowindow, storeStart, page) {
this.writeDebug('listClick',arguments);
var _this = this;
$(document).on('click.' + pluginName, '.' + _this.settings.locationList + ' li', function () {
var markerId = $(this).data('markerid');
var selectedMarker = markers[markerId];
// List click callback
if (_this.settings.callbackListClick) {
_this.settings.callbackListClick.call(this, markerId, selectedMarker, locationset[markerId], map);
}
map.panTo(selectedMarker.getPosition());
var listLoc = 'left';
if (_this.settings.bounceMarker === true) {
selectedMarker.setAnimation(google.maps.Animation.BOUNCE);
setTimeout(function () {
selectedMarker.setAnimation(null);
_this.createInfowindow(selectedMarker, listLoc, infowindow, storeStart, page);
}, 700
);
}
else {
_this.createInfowindow(selectedMarker, listLoc, infowindow, storeStart, page);
}
// Custom selected marker override
if (_this.settings.selectedMarkerImg !== null) {
_this.changeSelectedMarker(selectedMarker);
}
// Focus on the list
$('.' + _this.settings.locationList + ' li').removeClass('list-focus');
$('.' + _this.settings.locationList + ' li[data-markerid=' + markerId + ']').addClass('list-focus');
});
// Prevent bubbling from list content links
$(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' li a', function(e) {
e.stopPropagation();
});
}
|
[
"function",
"(",
"map",
",",
"infowindow",
",",
"storeStart",
",",
"page",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'listClick'",
",",
"arguments",
")",
";",
"var",
"_this",
"=",
"this",
";",
"$",
"(",
"document",
")",
".",
"on",
"(",
"'click.'",
"+",
"pluginName",
",",
"'.'",
"+",
"_this",
".",
"settings",
".",
"locationList",
"+",
"' li'",
",",
"function",
"(",
")",
"{",
"var",
"markerId",
"=",
"$",
"(",
"this",
")",
".",
"data",
"(",
"'markerid'",
")",
";",
"var",
"selectedMarker",
"=",
"markers",
"[",
"markerId",
"]",
";",
"// List click callback",
"if",
"(",
"_this",
".",
"settings",
".",
"callbackListClick",
")",
"{",
"_this",
".",
"settings",
".",
"callbackListClick",
".",
"call",
"(",
"this",
",",
"markerId",
",",
"selectedMarker",
",",
"locationset",
"[",
"markerId",
"]",
",",
"map",
")",
";",
"}",
"map",
".",
"panTo",
"(",
"selectedMarker",
".",
"getPosition",
"(",
")",
")",
";",
"var",
"listLoc",
"=",
"'left'",
";",
"if",
"(",
"_this",
".",
"settings",
".",
"bounceMarker",
"===",
"true",
")",
"{",
"selectedMarker",
".",
"setAnimation",
"(",
"google",
".",
"maps",
".",
"Animation",
".",
"BOUNCE",
")",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"selectedMarker",
".",
"setAnimation",
"(",
"null",
")",
";",
"_this",
".",
"createInfowindow",
"(",
"selectedMarker",
",",
"listLoc",
",",
"infowindow",
",",
"storeStart",
",",
"page",
")",
";",
"}",
",",
"700",
")",
";",
"}",
"else",
"{",
"_this",
".",
"createInfowindow",
"(",
"selectedMarker",
",",
"listLoc",
",",
"infowindow",
",",
"storeStart",
",",
"page",
")",
";",
"}",
"// Custom selected marker override",
"if",
"(",
"_this",
".",
"settings",
".",
"selectedMarkerImg",
"!==",
"null",
")",
"{",
"_this",
".",
"changeSelectedMarker",
"(",
"selectedMarker",
")",
";",
"}",
"// Focus on the list",
"$",
"(",
"'.'",
"+",
"_this",
".",
"settings",
".",
"locationList",
"+",
"' li'",
")",
".",
"removeClass",
"(",
"'list-focus'",
")",
";",
"$",
"(",
"'.'",
"+",
"_this",
".",
"settings",
".",
"locationList",
"+",
"' li[data-markerid='",
"+",
"markerId",
"+",
"']'",
")",
".",
"addClass",
"(",
"'list-focus'",
")",
";",
"}",
")",
";",
"// Prevent bubbling from list content links",
"$",
"(",
"document",
")",
".",
"on",
"(",
"'click.'",
"+",
"pluginName",
",",
"'.'",
"+",
"_this",
".",
"settings",
".",
"locationList",
"+",
"' li a'",
",",
"function",
"(",
"e",
")",
"{",
"e",
".",
"stopPropagation",
"(",
")",
";",
"}",
")",
";",
"}"
] |
Handle clicks from the location list
@param map {Object} Google map
@param infowindow {Object} Info window object
@param storeStart {number} Starting point of current page when pagination is enabled
@param page {number} Current page number when pagination is enabled
|
[
"Handle",
"clicks",
"from",
"the",
"location",
"list"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L2450-L2491
|
|
16,791
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function(map, origin) {
this.writeDebug('inlineDirections',arguments);
if (this.settings.inlineDirections !== true || typeof origin === 'undefined') {
return;
}
var _this = this;
// Open directions
$(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' li .loc-directions a', function (e) {
e.preventDefault();
var locID = $(this).closest('li').attr('data-markerid');
_this.directionsRequest(origin, parseInt(locID), map);
// Close directions
$(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' .bh-sl-close-icon', function () {
_this.closeDirections();
});
});
}
|
javascript
|
function(map, origin) {
this.writeDebug('inlineDirections',arguments);
if (this.settings.inlineDirections !== true || typeof origin === 'undefined') {
return;
}
var _this = this;
// Open directions
$(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' li .loc-directions a', function (e) {
e.preventDefault();
var locID = $(this).closest('li').attr('data-markerid');
_this.directionsRequest(origin, parseInt(locID), map);
// Close directions
$(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' .bh-sl-close-icon', function () {
_this.closeDirections();
});
});
}
|
[
"function",
"(",
"map",
",",
"origin",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'inlineDirections'",
",",
"arguments",
")",
";",
"if",
"(",
"this",
".",
"settings",
".",
"inlineDirections",
"!==",
"true",
"||",
"typeof",
"origin",
"===",
"'undefined'",
")",
"{",
"return",
";",
"}",
"var",
"_this",
"=",
"this",
";",
"// Open directions",
"$",
"(",
"document",
")",
".",
"on",
"(",
"'click.'",
"+",
"pluginName",
",",
"'.'",
"+",
"_this",
".",
"settings",
".",
"locationList",
"+",
"' li .loc-directions a'",
",",
"function",
"(",
"e",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"var",
"locID",
"=",
"$",
"(",
"this",
")",
".",
"closest",
"(",
"'li'",
")",
".",
"attr",
"(",
"'data-markerid'",
")",
";",
"_this",
".",
"directionsRequest",
"(",
"origin",
",",
"parseInt",
"(",
"locID",
")",
",",
"map",
")",
";",
"// Close directions",
"$",
"(",
"document",
")",
".",
"on",
"(",
"'click.'",
"+",
"pluginName",
",",
"'.'",
"+",
"_this",
".",
"settings",
".",
"locationList",
"+",
"' .bh-sl-close-icon'",
",",
"function",
"(",
")",
"{",
"_this",
".",
"closeDirections",
"(",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] |
Inline directions setup
@param map {Object} Google map
@param origin {string} Origin address
|
[
"Inline",
"directions",
"setup"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L2516-L2536
|
|
16,792
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function(map, markers) {
this.writeDebug('visibleMarkersList',arguments);
if (this.settings.visibleMarkersList !== true) {
return;
}
var _this = this;
// Add event listener to filter the list when the map is fully loaded
google.maps.event.addListenerOnce(map, 'idle', function(){
_this.checkVisibleMarkers(markers, map);
});
// Add event listener for center change
google.maps.event.addListener(map, 'center_changed', function() {
_this.checkVisibleMarkers(markers, map);
});
// Add event listener for zoom change
google.maps.event.addListener(map, 'zoom_changed', function() {
_this.checkVisibleMarkers(markers, map);
});
}
|
javascript
|
function(map, markers) {
this.writeDebug('visibleMarkersList',arguments);
if (this.settings.visibleMarkersList !== true) {
return;
}
var _this = this;
// Add event listener to filter the list when the map is fully loaded
google.maps.event.addListenerOnce(map, 'idle', function(){
_this.checkVisibleMarkers(markers, map);
});
// Add event listener for center change
google.maps.event.addListener(map, 'center_changed', function() {
_this.checkVisibleMarkers(markers, map);
});
// Add event listener for zoom change
google.maps.event.addListener(map, 'zoom_changed', function() {
_this.checkVisibleMarkers(markers, map);
});
}
|
[
"function",
"(",
"map",
",",
"markers",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'visibleMarkersList'",
",",
"arguments",
")",
";",
"if",
"(",
"this",
".",
"settings",
".",
"visibleMarkersList",
"!==",
"true",
")",
"{",
"return",
";",
"}",
"var",
"_this",
"=",
"this",
";",
"// Add event listener to filter the list when the map is fully loaded",
"google",
".",
"maps",
".",
"event",
".",
"addListenerOnce",
"(",
"map",
",",
"'idle'",
",",
"function",
"(",
")",
"{",
"_this",
".",
"checkVisibleMarkers",
"(",
"markers",
",",
"map",
")",
";",
"}",
")",
";",
"// Add event listener for center change",
"google",
".",
"maps",
".",
"event",
".",
"addListener",
"(",
"map",
",",
"'center_changed'",
",",
"function",
"(",
")",
"{",
"_this",
".",
"checkVisibleMarkers",
"(",
"markers",
",",
"map",
")",
";",
"}",
")",
";",
"// Add event listener for zoom change",
"google",
".",
"maps",
".",
"event",
".",
"addListener",
"(",
"map",
",",
"'zoom_changed'",
",",
"function",
"(",
")",
"{",
"_this",
".",
"checkVisibleMarkers",
"(",
"markers",
",",
"map",
")",
";",
"}",
")",
";",
"}"
] |
Visible markers list setup
@param map {Object} Google map
@param markers {Object} Map markers
|
[
"Visible",
"markers",
"list",
"setup"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L2544-L2567
|
|
16,793
|
bjorn2404/jQuery-Store-Locator-Plugin
|
dist/assets/js/plugins/storeLocator/jquery.storelocator.js
|
function (mappingObject) {
this.writeDebug('mapping',arguments);
var _this = this;
var orig_lat, orig_lng, geocodeData, origin, originPoint, page;
if (!this.isEmptyObject(mappingObject)) {
orig_lat = mappingObject.lat;
orig_lng = mappingObject.lng;
geocodeData = mappingObject.geocodeResult;
origin = mappingObject.origin;
page = mappingObject.page;
}
// Set the initial page to zero if not set
if ( _this.settings.pagination === true ) {
if (typeof page === 'undefined' || originalOrigin !== addressInput ) {
page = 0;
}
}
// Data request
if (typeof origin === 'undefined' && this.settings.nameSearch === true) {
dataRequest = _this._getData();
}
else {
// Setup the origin point
originPoint = new google.maps.LatLng(orig_lat, orig_lng);
// If the origin hasn't changed use the existing data so we aren't making unneeded AJAX requests
if ((typeof originalOrigin !== 'undefined') && (origin === originalOrigin) && (typeof originalData !== 'undefined')) {
origin = originalOrigin;
dataRequest = originalData;
}
else {
// Do the data request - doing this in mapping so the lat/lng and address can be passed over and used if needed
dataRequest = _this._getData(olat, olng, origin, geocodeData, mappingObject);
}
}
// Check filters here to handle selected filtering after page reload
if (_this.settings.taxonomyFilters !== null && _this.hasEmptyObjectVals(filters)) {
_this.checkFilters();
}
/**
* Process the location data
*/
// Raw data
if ( _this.settings.dataRaw !== null ) {
_this.processData(mappingObject, originPoint, dataRequest, page);
}
// Remote data
else {
dataRequest.done(function (data) {
_this.processData(mappingObject, originPoint, data, page);
});
}
}
|
javascript
|
function (mappingObject) {
this.writeDebug('mapping',arguments);
var _this = this;
var orig_lat, orig_lng, geocodeData, origin, originPoint, page;
if (!this.isEmptyObject(mappingObject)) {
orig_lat = mappingObject.lat;
orig_lng = mappingObject.lng;
geocodeData = mappingObject.geocodeResult;
origin = mappingObject.origin;
page = mappingObject.page;
}
// Set the initial page to zero if not set
if ( _this.settings.pagination === true ) {
if (typeof page === 'undefined' || originalOrigin !== addressInput ) {
page = 0;
}
}
// Data request
if (typeof origin === 'undefined' && this.settings.nameSearch === true) {
dataRequest = _this._getData();
}
else {
// Setup the origin point
originPoint = new google.maps.LatLng(orig_lat, orig_lng);
// If the origin hasn't changed use the existing data so we aren't making unneeded AJAX requests
if ((typeof originalOrigin !== 'undefined') && (origin === originalOrigin) && (typeof originalData !== 'undefined')) {
origin = originalOrigin;
dataRequest = originalData;
}
else {
// Do the data request - doing this in mapping so the lat/lng and address can be passed over and used if needed
dataRequest = _this._getData(olat, olng, origin, geocodeData, mappingObject);
}
}
// Check filters here to handle selected filtering after page reload
if (_this.settings.taxonomyFilters !== null && _this.hasEmptyObjectVals(filters)) {
_this.checkFilters();
}
/**
* Process the location data
*/
// Raw data
if ( _this.settings.dataRaw !== null ) {
_this.processData(mappingObject, originPoint, dataRequest, page);
}
// Remote data
else {
dataRequest.done(function (data) {
_this.processData(mappingObject, originPoint, data, page);
});
}
}
|
[
"function",
"(",
"mappingObject",
")",
"{",
"this",
".",
"writeDebug",
"(",
"'mapping'",
",",
"arguments",
")",
";",
"var",
"_this",
"=",
"this",
";",
"var",
"orig_lat",
",",
"orig_lng",
",",
"geocodeData",
",",
"origin",
",",
"originPoint",
",",
"page",
";",
"if",
"(",
"!",
"this",
".",
"isEmptyObject",
"(",
"mappingObject",
")",
")",
"{",
"orig_lat",
"=",
"mappingObject",
".",
"lat",
";",
"orig_lng",
"=",
"mappingObject",
".",
"lng",
";",
"geocodeData",
"=",
"mappingObject",
".",
"geocodeResult",
";",
"origin",
"=",
"mappingObject",
".",
"origin",
";",
"page",
"=",
"mappingObject",
".",
"page",
";",
"}",
"// Set the initial page to zero if not set",
"if",
"(",
"_this",
".",
"settings",
".",
"pagination",
"===",
"true",
")",
"{",
"if",
"(",
"typeof",
"page",
"===",
"'undefined'",
"||",
"originalOrigin",
"!==",
"addressInput",
")",
"{",
"page",
"=",
"0",
";",
"}",
"}",
"// Data request",
"if",
"(",
"typeof",
"origin",
"===",
"'undefined'",
"&&",
"this",
".",
"settings",
".",
"nameSearch",
"===",
"true",
")",
"{",
"dataRequest",
"=",
"_this",
".",
"_getData",
"(",
")",
";",
"}",
"else",
"{",
"// Setup the origin point",
"originPoint",
"=",
"new",
"google",
".",
"maps",
".",
"LatLng",
"(",
"orig_lat",
",",
"orig_lng",
")",
";",
"// If the origin hasn't changed use the existing data so we aren't making unneeded AJAX requests",
"if",
"(",
"(",
"typeof",
"originalOrigin",
"!==",
"'undefined'",
")",
"&&",
"(",
"origin",
"===",
"originalOrigin",
")",
"&&",
"(",
"typeof",
"originalData",
"!==",
"'undefined'",
")",
")",
"{",
"origin",
"=",
"originalOrigin",
";",
"dataRequest",
"=",
"originalData",
";",
"}",
"else",
"{",
"// Do the data request - doing this in mapping so the lat/lng and address can be passed over and used if needed",
"dataRequest",
"=",
"_this",
".",
"_getData",
"(",
"olat",
",",
"olng",
",",
"origin",
",",
"geocodeData",
",",
"mappingObject",
")",
";",
"}",
"}",
"// Check filters here to handle selected filtering after page reload",
"if",
"(",
"_this",
".",
"settings",
".",
"taxonomyFilters",
"!==",
"null",
"&&",
"_this",
".",
"hasEmptyObjectVals",
"(",
"filters",
")",
")",
"{",
"_this",
".",
"checkFilters",
"(",
")",
";",
"}",
"/**\n\t\t\t * Process the location data\n\t\t\t */",
"// Raw data",
"if",
"(",
"_this",
".",
"settings",
".",
"dataRaw",
"!==",
"null",
")",
"{",
"_this",
".",
"processData",
"(",
"mappingObject",
",",
"originPoint",
",",
"dataRequest",
",",
"page",
")",
";",
"}",
"// Remote data",
"else",
"{",
"dataRequest",
".",
"done",
"(",
"function",
"(",
"data",
")",
"{",
"_this",
".",
"processData",
"(",
"mappingObject",
",",
"originPoint",
",",
"data",
",",
"page",
")",
";",
"}",
")",
";",
"}",
"}"
] |
The primary mapping function that runs everything
@param mappingObject {Object} all the potential mapping properties - latitude, longitude, origin, name, max distance, page
|
[
"The",
"primary",
"mapping",
"function",
"that",
"runs",
"everything"
] |
1145d04f7988e06e00f7b6014f8a7eca26fe4eb6
|
https://github.com/bjorn2404/jQuery-Store-Locator-Plugin/blob/1145d04f7988e06e00f7b6014f8a7eca26fe4eb6/dist/assets/js/plugins/storeLocator/jquery.storelocator.js#L2574-L2629
|
|
16,794
|
cibernox/ember-basic-dropdown
|
addon/utils/scroll-helpers.js
|
calculateScrollDistribution
|
function calculateScrollDistribution(deltaX, deltaY, element, container, accumulator = []) {
const scrollInformation = {
element,
scrollLeft: 0,
scrollTop: 0
};
const scrollLeftMax = element.scrollWidth - element.clientWidth;
const scrollTopMax = element.scrollHeight - element.clientHeight;
const availableScroll = {
deltaXNegative: -element.scrollLeft,
deltaXPositive: scrollLeftMax - element.scrollLeft,
deltaYNegative: -element.scrollTop,
deltaYPositive: scrollTopMax - element.scrollTop
};
const elementStyle = window.getComputedStyle(element);
if (elementStyle.overflowX !== 'hidden') {
// The `deltaX` can be larger than the available scroll for the element, thus overshooting.
// The result of that is that it scrolls the element as far as possible. We don't need to
// calculate exactly because we reduce the amount of desired scroll for the
// parent elements by the correct amount below.
scrollInformation.scrollLeft = element.scrollLeft + deltaX;
if (deltaX > availableScroll.deltaXPositive) {
deltaX = deltaX - availableScroll.deltaXPositive;
} else if (deltaX < availableScroll.deltaXNegative) {
deltaX = deltaX - availableScroll.deltaXNegative;
} else {
deltaX = 0;
}
}
if (elementStyle.overflowY !== 'hidden') {
scrollInformation.scrollTop = element.scrollTop + deltaY;
if (deltaY > availableScroll.deltaYPositive) {
deltaY = deltaY - availableScroll.deltaYPositive;
} else if (deltaY < availableScroll.deltaYNegative) {
deltaY = deltaY - availableScroll.deltaYNegative;
} else {
deltaY = 0;
}
}
if (element !== container && (deltaX || deltaY)) {
return calculateScrollDistribution(deltaX, deltaY, element.parentNode, container, accumulator.concat([scrollInformation]));
}
return accumulator.concat([scrollInformation]);
}
|
javascript
|
function calculateScrollDistribution(deltaX, deltaY, element, container, accumulator = []) {
const scrollInformation = {
element,
scrollLeft: 0,
scrollTop: 0
};
const scrollLeftMax = element.scrollWidth - element.clientWidth;
const scrollTopMax = element.scrollHeight - element.clientHeight;
const availableScroll = {
deltaXNegative: -element.scrollLeft,
deltaXPositive: scrollLeftMax - element.scrollLeft,
deltaYNegative: -element.scrollTop,
deltaYPositive: scrollTopMax - element.scrollTop
};
const elementStyle = window.getComputedStyle(element);
if (elementStyle.overflowX !== 'hidden') {
// The `deltaX` can be larger than the available scroll for the element, thus overshooting.
// The result of that is that it scrolls the element as far as possible. We don't need to
// calculate exactly because we reduce the amount of desired scroll for the
// parent elements by the correct amount below.
scrollInformation.scrollLeft = element.scrollLeft + deltaX;
if (deltaX > availableScroll.deltaXPositive) {
deltaX = deltaX - availableScroll.deltaXPositive;
} else if (deltaX < availableScroll.deltaXNegative) {
deltaX = deltaX - availableScroll.deltaXNegative;
} else {
deltaX = 0;
}
}
if (elementStyle.overflowY !== 'hidden') {
scrollInformation.scrollTop = element.scrollTop + deltaY;
if (deltaY > availableScroll.deltaYPositive) {
deltaY = deltaY - availableScroll.deltaYPositive;
} else if (deltaY < availableScroll.deltaYNegative) {
deltaY = deltaY - availableScroll.deltaYNegative;
} else {
deltaY = 0;
}
}
if (element !== container && (deltaX || deltaY)) {
return calculateScrollDistribution(deltaX, deltaY, element.parentNode, container, accumulator.concat([scrollInformation]));
}
return accumulator.concat([scrollInformation]);
}
|
[
"function",
"calculateScrollDistribution",
"(",
"deltaX",
",",
"deltaY",
",",
"element",
",",
"container",
",",
"accumulator",
"=",
"[",
"]",
")",
"{",
"const",
"scrollInformation",
"=",
"{",
"element",
",",
"scrollLeft",
":",
"0",
",",
"scrollTop",
":",
"0",
"}",
";",
"const",
"scrollLeftMax",
"=",
"element",
".",
"scrollWidth",
"-",
"element",
".",
"clientWidth",
";",
"const",
"scrollTopMax",
"=",
"element",
".",
"scrollHeight",
"-",
"element",
".",
"clientHeight",
";",
"const",
"availableScroll",
"=",
"{",
"deltaXNegative",
":",
"-",
"element",
".",
"scrollLeft",
",",
"deltaXPositive",
":",
"scrollLeftMax",
"-",
"element",
".",
"scrollLeft",
",",
"deltaYNegative",
":",
"-",
"element",
".",
"scrollTop",
",",
"deltaYPositive",
":",
"scrollTopMax",
"-",
"element",
".",
"scrollTop",
"}",
";",
"const",
"elementStyle",
"=",
"window",
".",
"getComputedStyle",
"(",
"element",
")",
";",
"if",
"(",
"elementStyle",
".",
"overflowX",
"!==",
"'hidden'",
")",
"{",
"// The `deltaX` can be larger than the available scroll for the element, thus overshooting.",
"// The result of that is that it scrolls the element as far as possible. We don't need to",
"// calculate exactly because we reduce the amount of desired scroll for the",
"// parent elements by the correct amount below.",
"scrollInformation",
".",
"scrollLeft",
"=",
"element",
".",
"scrollLeft",
"+",
"deltaX",
";",
"if",
"(",
"deltaX",
">",
"availableScroll",
".",
"deltaXPositive",
")",
"{",
"deltaX",
"=",
"deltaX",
"-",
"availableScroll",
".",
"deltaXPositive",
";",
"}",
"else",
"if",
"(",
"deltaX",
"<",
"availableScroll",
".",
"deltaXNegative",
")",
"{",
"deltaX",
"=",
"deltaX",
"-",
"availableScroll",
".",
"deltaXNegative",
";",
"}",
"else",
"{",
"deltaX",
"=",
"0",
";",
"}",
"}",
"if",
"(",
"elementStyle",
".",
"overflowY",
"!==",
"'hidden'",
")",
"{",
"scrollInformation",
".",
"scrollTop",
"=",
"element",
".",
"scrollTop",
"+",
"deltaY",
";",
"if",
"(",
"deltaY",
">",
"availableScroll",
".",
"deltaYPositive",
")",
"{",
"deltaY",
"=",
"deltaY",
"-",
"availableScroll",
".",
"deltaYPositive",
";",
"}",
"else",
"if",
"(",
"deltaY",
"<",
"availableScroll",
".",
"deltaYNegative",
")",
"{",
"deltaY",
"=",
"deltaY",
"-",
"availableScroll",
".",
"deltaYNegative",
";",
"}",
"else",
"{",
"deltaY",
"=",
"0",
";",
"}",
"}",
"if",
"(",
"element",
"!==",
"container",
"&&",
"(",
"deltaX",
"||",
"deltaY",
")",
")",
"{",
"return",
"calculateScrollDistribution",
"(",
"deltaX",
",",
"deltaY",
",",
"element",
".",
"parentNode",
",",
"container",
",",
"accumulator",
".",
"concat",
"(",
"[",
"scrollInformation",
"]",
")",
")",
";",
"}",
"return",
"accumulator",
".",
"concat",
"(",
"[",
"scrollInformation",
"]",
")",
";",
"}"
] |
Calculates the scroll distribution for `element` inside` container.
@param {Number} deltaX
@param {Number} deltaY
@param {Element} element
@param {Element} container
@param {ScrollInformation[]} accumulator
@return {ScrollInforamtion}
|
[
"Calculates",
"the",
"scroll",
"distribution",
"for",
"element",
"inside",
"container",
"."
] |
799c2c52120f0f518c655437ad6d17716788b5b7
|
https://github.com/cibernox/ember-basic-dropdown/blob/799c2c52120f0f518c655437ad6d17716788b5b7/addon/utils/scroll-helpers.js#L113-L162
|
16,795
|
cibernox/ember-basic-dropdown
|
addon/components/basic-dropdown-content.js
|
dropdownIsValidParent
|
function dropdownIsValidParent(el, dropdownId) {
let closestDropdown = closestContent(el);
if (closestDropdown) {
let trigger = document.querySelector(`[aria-owns=${closestDropdown.attributes.id.value}]`);
let parentDropdown = closestContent(trigger);
return parentDropdown && parentDropdown.attributes.id.value === dropdownId || dropdownIsValidParent(parentDropdown, dropdownId);
} else {
return false;
}
}
|
javascript
|
function dropdownIsValidParent(el, dropdownId) {
let closestDropdown = closestContent(el);
if (closestDropdown) {
let trigger = document.querySelector(`[aria-owns=${closestDropdown.attributes.id.value}]`);
let parentDropdown = closestContent(trigger);
return parentDropdown && parentDropdown.attributes.id.value === dropdownId || dropdownIsValidParent(parentDropdown, dropdownId);
} else {
return false;
}
}
|
[
"function",
"dropdownIsValidParent",
"(",
"el",
",",
"dropdownId",
")",
"{",
"let",
"closestDropdown",
"=",
"closestContent",
"(",
"el",
")",
";",
"if",
"(",
"closestDropdown",
")",
"{",
"let",
"trigger",
"=",
"document",
".",
"querySelector",
"(",
"`",
"${",
"closestDropdown",
".",
"attributes",
".",
"id",
".",
"value",
"}",
"`",
")",
";",
"let",
"parentDropdown",
"=",
"closestContent",
"(",
"trigger",
")",
";",
"return",
"parentDropdown",
"&&",
"parentDropdown",
".",
"attributes",
".",
"id",
".",
"value",
"===",
"dropdownId",
"||",
"dropdownIsValidParent",
"(",
"parentDropdown",
",",
"dropdownId",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Evaluates if the given element is in a dropdown or any of its parent dropdowns.
@param {HTMLElement} el
@param {String} dropdownId
|
[
"Evaluates",
"if",
"the",
"given",
"element",
"is",
"in",
"a",
"dropdown",
"or",
"any",
"of",
"its",
"parent",
"dropdowns",
"."
] |
799c2c52120f0f518c655437ad6d17716788b5b7
|
https://github.com/cibernox/ember-basic-dropdown/blob/799c2c52120f0f518c655437ad6d17716788b5b7/addon/components/basic-dropdown-content.js#L43-L52
|
16,796
|
jshttp/content-disposition
|
index.js
|
contentDisposition
|
function contentDisposition (filename, options) {
var opts = options || {}
// get type
var type = opts.type || 'attachment'
// get parameters
var params = createparams(filename, opts.fallback)
// format into string
return format(new ContentDisposition(type, params))
}
|
javascript
|
function contentDisposition (filename, options) {
var opts = options || {}
// get type
var type = opts.type || 'attachment'
// get parameters
var params = createparams(filename, opts.fallback)
// format into string
return format(new ContentDisposition(type, params))
}
|
[
"function",
"contentDisposition",
"(",
"filename",
",",
"options",
")",
"{",
"var",
"opts",
"=",
"options",
"||",
"{",
"}",
"// get type",
"var",
"type",
"=",
"opts",
".",
"type",
"||",
"'attachment'",
"// get parameters",
"var",
"params",
"=",
"createparams",
"(",
"filename",
",",
"opts",
".",
"fallback",
")",
"// format into string",
"return",
"format",
"(",
"new",
"ContentDisposition",
"(",
"type",
",",
"params",
")",
")",
"}"
] |
Create an attachment Content-Disposition header.
@param {string} [filename]
@param {object} [options]
@param {string} [options.type=attachment]
@param {string|boolean} [options.fallback=true]
@return {string}
@public
|
[
"Create",
"an",
"attachment",
"Content",
"-",
"Disposition",
"header",
"."
] |
f6d7cba7ea09dfea1492d5ffe438fe2f2e3cc3bb
|
https://github.com/jshttp/content-disposition/blob/f6d7cba7ea09dfea1492d5ffe438fe2f2e3cc3bb/index.js#L144-L155
|
16,797
|
FVANCOP/ChartNew.js
|
ChartNew.js
|
getCSSText
|
function getCSSText(className) {
if (typeof document.styleSheets != "object") return "";
if (document.styleSheets.length <= 0) return "";
var classes = document.styleSheets[0].rules || document.styleSheets[0].cssRules;
for (var x = 0; x < classes.length; x++) {
if (classes[x].selectorText == "." + className || classes[x].selectorText == "#" + className) {
return ((classes[x].cssText) ? (classes[x].cssText) : (classes[x].style.cssText));
}
}
return "";
}
|
javascript
|
function getCSSText(className) {
if (typeof document.styleSheets != "object") return "";
if (document.styleSheets.length <= 0) return "";
var classes = document.styleSheets[0].rules || document.styleSheets[0].cssRules;
for (var x = 0; x < classes.length; x++) {
if (classes[x].selectorText == "." + className || classes[x].selectorText == "#" + className) {
return ((classes[x].cssText) ? (classes[x].cssText) : (classes[x].style.cssText));
}
}
return "";
}
|
[
"function",
"getCSSText",
"(",
"className",
")",
"{",
"if",
"(",
"typeof",
"document",
".",
"styleSheets",
"!=",
"\"object\"",
")",
"return",
"\"\"",
";",
"if",
"(",
"document",
".",
"styleSheets",
".",
"length",
"<=",
"0",
")",
"return",
"\"\"",
";",
"var",
"classes",
"=",
"document",
".",
"styleSheets",
"[",
"0",
"]",
".",
"rules",
"||",
"document",
".",
"styleSheets",
"[",
"0",
"]",
".",
"cssRules",
";",
"for",
"(",
"var",
"x",
"=",
"0",
";",
"x",
"<",
"classes",
".",
"length",
";",
"x",
"++",
")",
"{",
"if",
"(",
"classes",
"[",
"x",
"]",
".",
"selectorText",
"==",
"\".\"",
"+",
"className",
"||",
"classes",
"[",
"x",
"]",
".",
"selectorText",
"==",
"\"#\"",
"+",
"className",
")",
"{",
"return",
"(",
"(",
"classes",
"[",
"x",
"]",
".",
"cssText",
")",
"?",
"(",
"classes",
"[",
"x",
"]",
".",
"cssText",
")",
":",
"(",
"classes",
"[",
"x",
"]",
".",
"style",
".",
"cssText",
")",
")",
";",
"}",
"}",
"return",
"\"\"",
";",
"}"
] |
First Time entered;
|
[
"First",
"Time",
"entered",
";"
] |
08681cadc1c1b6ea334c11d48b2ae43d2267d611
|
https://github.com/FVANCOP/ChartNew.js/blob/08681cadc1c1b6ea334c11d48b2ae43d2267d611/ChartNew.js#L569-L579
|
16,798
|
FVANCOP/ChartNew.js
|
ChartNew.js
|
checkBrowser
|
function checkBrowser() {
this.ver = navigator.appVersion
this.dom = document.getElementById ? 1 : 0
this.ie5 = (this.ver.indexOf("MSIE 5") > -1 && this.dom) ? 1 : 0;
this.ie4 = (document.all && !this.dom) ? 1 : 0;
this.ns5 = (this.dom && parseInt(this.ver) >= 5) ? 1 : 0;
this.ns4 = (document.layers && !this.dom) ? 1 : 0;
this.bw = (this.ie5 || this.ie4 || this.ns4 || this.ns5)
return this
}
|
javascript
|
function checkBrowser() {
this.ver = navigator.appVersion
this.dom = document.getElementById ? 1 : 0
this.ie5 = (this.ver.indexOf("MSIE 5") > -1 && this.dom) ? 1 : 0;
this.ie4 = (document.all && !this.dom) ? 1 : 0;
this.ns5 = (this.dom && parseInt(this.ver) >= 5) ? 1 : 0;
this.ns4 = (document.layers && !this.dom) ? 1 : 0;
this.bw = (this.ie5 || this.ie4 || this.ns4 || this.ns5)
return this
}
|
[
"function",
"checkBrowser",
"(",
")",
"{",
"this",
".",
"ver",
"=",
"navigator",
".",
"appVersion",
"this",
".",
"dom",
"=",
"document",
".",
"getElementById",
"?",
"1",
":",
"0",
"this",
".",
"ie5",
"=",
"(",
"this",
".",
"ver",
".",
"indexOf",
"(",
"\"MSIE 5\"",
")",
">",
"-",
"1",
"&&",
"this",
".",
"dom",
")",
"?",
"1",
":",
"0",
";",
"this",
".",
"ie4",
"=",
"(",
"document",
".",
"all",
"&&",
"!",
"this",
".",
"dom",
")",
"?",
"1",
":",
"0",
";",
"this",
".",
"ns5",
"=",
"(",
"this",
".",
"dom",
"&&",
"parseInt",
"(",
"this",
".",
"ver",
")",
">=",
"5",
")",
"?",
"1",
":",
"0",
";",
"this",
".",
"ns4",
"=",
"(",
"document",
".",
"layers",
"&&",
"!",
"this",
".",
"dom",
")",
"?",
"1",
":",
"0",
";",
"this",
".",
"bw",
"=",
"(",
"this",
".",
"ie5",
"||",
"this",
".",
"ie4",
"||",
"this",
".",
"ns4",
"||",
"this",
".",
"ns5",
")",
"return",
"this",
"}"
] |
Default browsercheck, added to all scripts!
|
[
"Default",
"browsercheck",
"added",
"to",
"all",
"scripts!"
] |
08681cadc1c1b6ea334c11d48b2ae43d2267d611
|
https://github.com/FVANCOP/ChartNew.js/blob/08681cadc1c1b6ea334c11d48b2ae43d2267d611/ChartNew.js#L793-L802
|
16,799
|
FVANCOP/ChartNew.js
|
ChartNew.js
|
reverseData
|
function reverseData(data) {
data.labels = data.labels.reverse();
for (var i = 0; i < data.datasets.length; i++) {
for (var key in data.datasets[i]) {
if (Array.isArray(data.datasets[i][key])) {
data.datasets[i][key] = data.datasets[i][key].reverse();
}
}
}
return data;
}
|
javascript
|
function reverseData(data) {
data.labels = data.labels.reverse();
for (var i = 0; i < data.datasets.length; i++) {
for (var key in data.datasets[i]) {
if (Array.isArray(data.datasets[i][key])) {
data.datasets[i][key] = data.datasets[i][key].reverse();
}
}
}
return data;
}
|
[
"function",
"reverseData",
"(",
"data",
")",
"{",
"data",
".",
"labels",
"=",
"data",
".",
"labels",
".",
"reverse",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"data",
".",
"datasets",
".",
"length",
";",
"i",
"++",
")",
"{",
"for",
"(",
"var",
"key",
"in",
"data",
".",
"datasets",
"[",
"i",
"]",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"data",
".",
"datasets",
"[",
"i",
"]",
"[",
"key",
"]",
")",
")",
"{",
"data",
".",
"datasets",
"[",
"i",
"]",
"[",
"key",
"]",
"=",
"data",
".",
"datasets",
"[",
"i",
"]",
"[",
"key",
"]",
".",
"reverse",
"(",
")",
";",
"}",
"}",
"}",
"return",
"data",
";",
"}"
] |
Reverse the data structure for horizontal charts
- reverse labels and every array inside datasets
@param {object} data datasets and labels for the chart
@return return the reversed data
|
[
"Reverse",
"the",
"data",
"structure",
"for",
"horizontal",
"charts",
"-",
"reverse",
"labels",
"and",
"every",
"array",
"inside",
"datasets"
] |
08681cadc1c1b6ea334c11d48b2ae43d2267d611
|
https://github.com/FVANCOP/ChartNew.js/blob/08681cadc1c1b6ea334c11d48b2ae43d2267d611/ChartNew.js#L4290-L4300
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.