code
stringlengths 24
2.07M
| docstring
stringlengths 25
85.3k
| func_name
stringlengths 1
92
| language
stringclasses 1
value | repo
stringlengths 5
64
| path
stringlengths 4
172
| url
stringlengths 44
218
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
nativeHandler = function (element, fn, args) {
return function (event) {
event = fixEvent(event || ((this.ownerDocument || this.document || this).parentWindow || win).event, true)
return fn.apply(element, [event].concat(args))
}
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
nativeHandler
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
customHandler = function (element, fn, type, condition, args, isNative) {
return function (event) {
if (condition ? condition.apply(this, arguments) : W3C_MODEL ? true : event && event.propertyName === '_on' + type || !event) {
if (event)
event = fixEvent(event || ((this.ownerDocument || this.document || this).parentWindow || win).event, isNative)
fn.apply(element, event && (!args || args.length === 0) ? arguments : slice.call(arguments, event ? 0 : 1).concat(args))
}
}
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
customHandler
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
once = function (rm, element, type, fn, originalFn) {
// wrap the handler in a handler that does a remove as well
return function () {
rm(element, type, originalFn)
fn.apply(this, arguments)
}
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
once
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
removeListener = function (element, orgType, handler, namespaces) {
var i, l, entry
, type = (orgType && orgType.replace(nameRegex, ''))
, handlers = registry.get(element, type, handler)
for (i = 0, l = handlers.length; i < l; i++) {
if (handlers[i].inNamespaces(namespaces)) {
if ((entry = handlers[i]).eventSupport)
listener(entry.target, entry.eventType, entry.handler, false, entry.type)
// TODO: this is problematic, we have a registry.get() and registry.del() that
// both do registry searches so we waste cycles doing this. Needs to be rolled into
// a single registry.forAll(fn) that removes while finding, but the catch is that
// we'll be splicing the arrays that we're iterating over. Needs extra tests to
// make sure we don't screw it up. @rvagg
registry.del(entry)
}
}
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
removeListener
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
addListener = function (element, orgType, fn, originalFn, args) {
var entry
, type = orgType.replace(nameRegex, '')
, namespaces = orgType.replace(namespaceRegex, '').split('.')
if (registry.has(element, type, fn))
return element // no dupe
if (type === 'unload')
fn = once(removeListener, element, type, fn, originalFn) // self clean-up
if (customEvents[type]) {
if (customEvents[type].condition)
fn = customHandler(element, fn, type, customEvents[type].condition, true)
type = customEvents[type].base || type
}
entry = registry.put(new RegEntry(element, type, fn, originalFn, namespaces[0] && namespaces))
entry.handler = entry.isNative ?
nativeHandler(element, entry.handler, args) :
customHandler(element, entry.handler, type, false, args, false)
if (entry.eventSupport)
listener(entry.target, entry.eventType, entry.handler, true, entry.customType)
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
addListener
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
del = function (selector, fn, $) {
return function (e) {
var target, i, array = typeof selector === 'string' ? $(selector, this) : selector
for (target = e.target; target && target !== this; target = target.parentNode) {
for (i = array.length; i--;) {
if (array[i] === target) {
return fn.apply(target, arguments)
}
}
}
}
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
del
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
remove = function (element, typeSpec, fn) {
var k, m, type, namespaces, i
, rm = removeListener
, isString = typeSpec && typeof typeSpec === 'string'
if (isString && typeSpec.indexOf(' ') > 0) {
// remove(el, 't1 t2 t3', fn) or remove(el, 't1 t2 t3')
typeSpec = typeSpec.split(' ')
for (i = typeSpec.length; i--;)
remove(element, typeSpec[i], fn)
return element
}
type = isString && typeSpec.replace(nameRegex, '')
if (type && customEvents[type])
type = customEvents[type].type
if (!typeSpec || isString) {
// remove(el) or remove(el, t1.ns) or remove(el, .ns) or remove(el, .ns1.ns2.ns3)
if (namespaces = isString && typeSpec.replace(namespaceRegex, ''))
namespaces = namespaces.split('.')
rm(element, type, fn, namespaces)
} else if (typeof typeSpec === 'function') {
// remove(el, fn)
rm(element, null, typeSpec)
} else {
// remove(el, { t1: fn1, t2, fn2 })
for (k in typeSpec) {
if (typeSpec.hasOwnProperty(k))
remove(element, k, typeSpec[k])
}
}
return element
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
remove
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
add = function (element, events, fn, delfn, $) {
var type, types, i, args
, originalFn = fn
, isDel = fn && typeof fn === 'string'
if (events && !fn && typeof events === 'object') {
for (type in events) {
if (events.hasOwnProperty(type))
add.apply(this, [ element, type, events[type] ])
}
} else {
args = arguments.length > 3 ? slice.call(arguments, 3) : []
types = (isDel ? fn : events).split(' ')
isDel && (fn = del(events, (originalFn = delfn), $)) && (args = slice.call(args, 1))
// special case for one()
this === ONE && (fn = once(remove, element, events, fn, originalFn))
for (i = types.length; i--;) addListener(element, types[i], fn, originalFn, args)
}
return element
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
add
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
one = function () {
return add.apply(ONE, arguments)
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
one
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
fire = function (element, type, args) {
var i, j, l, names, handlers
, types = type.split(' ')
for (i = types.length; i--;) {
type = types[i].replace(nameRegex, '')
if (names = types[i].replace(namespaceRegex, ''))
names = names.split('.')
if (!names && !args && element[eventSupport]) {
fireListener(nativeEvents[type], type, element)
} else {
// non-native event, either because of a namespace, arguments or a non DOM element
// iterate over all listeners and manually 'fire'
handlers = registry.get(element, type)
args = [false].concat(args)
for (j = 0, l = handlers.length; j < l; j++) {
if (handlers[j].inNamespaces(names))
handlers[j].handler.apply(element, args)
}
}
}
return element
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
fire
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
clone = function (element, from, type) {
var i = 0
, handlers = registry.get(from, type)
, l = handlers.length
for (;i < l; i++)
handlers[i].original && add(element, handlers[i].type, handlers[i].original)
return element
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
clone
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
cleanup = function () {
var i, entries = registry.entries()
for (i in entries) {
if (entries[i].type && entries[i].type !== 'unload')
remove(entries[i].element, entries[i].type)
}
win[detachEvent]('onunload', cleanup)
win.CollectGarbage && win.CollectGarbage()
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
cleanup
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function lookupEntity(name) {
name = lcase(name); // TODO: π is different from Π
if (ENTITIES.hasOwnProperty(name)) { return ENTITIES[name]; }
var m = name.match(decimalEscapeRe);
if (m) {
return String.fromCharCode(parseInt(m[1], 10));
} else if (!!(m = name.match(hexEscapeRe))) {
return String.fromCharCode(parseInt(m[1], 16));
}
return '';
}
|
Decodes an HTML entity.
{@updoc
$ lookupEntity('lt')
# '<'
$ lookupEntity('GT')
# '>'
$ lookupEntity('amp')
# '&'
$ lookupEntity('nbsp')
# '\xA0'
$ lookupEntity('apos')
# "'"
$ lookupEntity('quot')
# '"'
$ lookupEntity('#xa')
# '\n'
$ lookupEntity('#10')
# '\n'
$ lookupEntity('#x0a')
# '\n'
$ lookupEntity('#010')
# '\n'
$ lookupEntity('#x00A')
# '\n'
$ lookupEntity('Pi') // Known failure
# '\u03A0'
$ lookupEntity('pi') // Known failure
# '\u03C0'
}
@param name the content between the '&' and the ';'.
@return a single unicode code-point as a string.
|
lookupEntity
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function decodeOneEntity(_, name) {
return lookupEntity(name);
}
|
Decodes an HTML entity.
{@updoc
$ lookupEntity('lt')
# '<'
$ lookupEntity('GT')
# '>'
$ lookupEntity('amp')
# '&'
$ lookupEntity('nbsp')
# '\xA0'
$ lookupEntity('apos')
# "'"
$ lookupEntity('quot')
# '"'
$ lookupEntity('#xa')
# '\n'
$ lookupEntity('#10')
# '\n'
$ lookupEntity('#x0a')
# '\n'
$ lookupEntity('#010')
# '\n'
$ lookupEntity('#x00A')
# '\n'
$ lookupEntity('Pi') // Known failure
# '\u03A0'
$ lookupEntity('pi') // Known failure
# '\u03C0'
}
@param name the content between the '&' and the ';'.
@return a single unicode code-point as a string.
|
decodeOneEntity
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function stripNULs(s) {
return s.replace(nulRe, '');
}
|
Decodes an HTML entity.
{@updoc
$ lookupEntity('lt')
# '<'
$ lookupEntity('GT')
# '>'
$ lookupEntity('amp')
# '&'
$ lookupEntity('nbsp')
# '\xA0'
$ lookupEntity('apos')
# "'"
$ lookupEntity('quot')
# '"'
$ lookupEntity('#xa')
# '\n'
$ lookupEntity('#10')
# '\n'
$ lookupEntity('#x0a')
# '\n'
$ lookupEntity('#010')
# '\n'
$ lookupEntity('#x00A')
# '\n'
$ lookupEntity('Pi') // Known failure
# '\u03A0'
$ lookupEntity('pi') // Known failure
# '\u03C0'
}
@param name the content between the '&' and the ';'.
@return a single unicode code-point as a string.
|
stripNULs
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function unescapeEntities(s) {
return s.replace(entityRe, decodeOneEntity);
}
|
The plain text of a chunk of HTML CDATA which possibly containing.
{@updoc
$ unescapeEntities('')
# ''
$ unescapeEntities('hello World!')
# 'hello World!'
$ unescapeEntities('1 < 2 && 4 > 3 ')
# '1 < 2 && 4 > 3\n'
$ unescapeEntities('<< <- unfinished entity>')
# '<< <- unfinished entity>'
$ unescapeEntities('/foo?bar=baz©=true') // & often unescaped in URLS
# '/foo?bar=baz©=true'
$ unescapeEntities('pi=ππ, Pi=Π\u03A0') // FIXME: known failure
# 'pi=\u03C0\u03c0, Pi=\u03A0\u03A0'
}
@param s a chunk of HTML CDATA. It must not start or end inside an HTML
entity.
|
unescapeEntities
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function escapeAttrib(s) {
// Escaping '=' defangs many UTF-7 and SGML short-tag attacks.
return s.replace(ampRe, '&').replace(ltRe, '<').replace(gtRe, '>')
.replace(quotRe, '"').replace(eqRe, '=');
}
|
Escapes HTML special characters in attribute values as HTML entities.
{@updoc
$ escapeAttrib('')
# ''
$ escapeAttrib('"<<&==&>>"') // Do not just escape the first occurrence.
# '"<<&==&>>"'
$ escapeAttrib('Hello <World>!')
# 'Hello <World>!'
}
|
escapeAttrib
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function normalizeRCData(rcdata) {
return rcdata
.replace(looseAmpRe, '&$1')
.replace(ltRe, '<')
.replace(gtRe, '>');
}
|
Escape entities in RCDATA that can be escaped without changing the meaning.
{@updoc
$ normalizeRCData('1 < 2 && 3 > 4 && 5 < 7&8')
# '1 < 2 && 3 > 4 && 5 < 7&8'
}
|
normalizeRCData
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function makeSaxParser(handler) {
return function parse(htmlText, param) {
htmlText = String(htmlText);
var htmlLower = null;
var inTag = false; // True iff we're currently processing a tag.
var attribs = []; // Accumulates attribute names and values.
var tagName = void 0; // The name of the tag currently being processed.
var eflags = void 0; // The element flags for the current tag.
var openTag = void 0; // True if the current tag is an open tag.
if (handler.startDoc) { handler.startDoc(param); }
while (htmlText) {
var m = htmlText.match(inTag ? INSIDE_TAG_TOKEN : OUTSIDE_TAG_TOKEN);
htmlText = htmlText.substring(m[0].length);
if (inTag) {
if (m[1]) { // attribute
// setAttribute with uppercase names doesn't work on IE6.
var attribName = lcase(m[1]);
var decodedValue;
if (m[2]) {
var encodedValue = m[3];
switch (encodedValue.charCodeAt(0)) { // Strip quotes
case 34: case 39:
encodedValue = encodedValue.substring(
1, encodedValue.length - 1);
break;
}
decodedValue = unescapeEntities(stripNULs(encodedValue));
} else {
// Use name as value for valueless attribs, so
// <input type=checkbox checked>
// gets attributes ['type', 'checkbox', 'checked', 'checked']
decodedValue = attribName;
}
attribs.push(attribName, decodedValue);
} else if (m[4]) {
if (eflags !== void 0) { // False if not in whitelist.
if (openTag) {
if (handler.startTag) {
handler.startTag(tagName, attribs, param);
}
} else {
if (handler.endTag) {
handler.endTag(tagName, param);
}
}
}
if (openTag
&& (eflags & (html4.eflags.CDATA | html4.eflags.RCDATA))) {
if (htmlLower === null) {
htmlLower = lcase(htmlText);
} else {
htmlLower = htmlLower.substring(
htmlLower.length - htmlText.length);
}
var dataEnd = htmlLower.indexOf('</' + tagName);
if (dataEnd < 0) { dataEnd = htmlText.length; }
if (dataEnd) {
if (eflags & html4.eflags.CDATA) {
if (handler.cdata) {
handler.cdata(htmlText.substring(0, dataEnd), param);
}
} else if (handler.rcdata) {
handler.rcdata(
normalizeRCData(htmlText.substring(0, dataEnd)), param);
}
htmlText = htmlText.substring(dataEnd);
}
}
tagName = eflags = openTag = void 0;
attribs.length = 0;
inTag = false;
}
} else {
if (m[1]) { // Entity
if (handler.pcdata) { handler.pcdata(m[0], param); }
} else if (m[3]) { // Tag
openTag = !m[2];
inTag = true;
tagName = lcase(m[3]);
eflags = html4.ELEMENTS.hasOwnProperty(tagName)
? html4.ELEMENTS[tagName] : void 0;
} else if (m[4]) { // Text
if (handler.pcdata) { handler.pcdata(m[4], param); }
} else if (m[5]) { // Cruft
if (handler.pcdata) {
var ch = m[5];
handler.pcdata(
ch === '<' ? '<' : ch === '>' ? '>' : '&',
param);
}
}
}
}
if (handler.endDoc) { handler.endDoc(param); }
};
}
|
Given a SAX-like event handler, produce a function that feeds those
events and a parameter to the event handler.
The event handler has the form:{@code
{
// Name is an upper-case HTML tag name. Attribs is an array of
// alternating upper-case attribute names, and attribute values. The
// attribs array is reused by the parser. Param is the value passed to
// the saxParser.
startTag: function (name, attribs, param) { ... },
endTag: function (name, param) { ... },
pcdata: function (text, param) { ... },
rcdata: function (text, param) { ... },
cdata: function (text, param) { ... },
startDoc: function (param) { ... },
endDoc: function (param) { ... }
}}
@param {Object} handler a record containing event handlers.
@return {Function} that takes a chunk of html and a parameter.
The parameter is passed on to the handler methods.
|
makeSaxParser
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function makeHtmlSanitizer(sanitizeAttributes) {
var stack;
var ignoring;
return makeSaxParser({
startDoc: function (_) {
stack = [];
ignoring = false;
},
startTag: function (tagName, attribs, out) {
if (ignoring) { return; }
if (!html4.ELEMENTS.hasOwnProperty(tagName)) { return; }
var eflags = html4.ELEMENTS[tagName];
if (eflags & html4.eflags.FOLDABLE) {
return;
} else if (eflags & html4.eflags.UNSAFE) {
ignoring = !(eflags & html4.eflags.EMPTY);
return;
}
attribs = sanitizeAttributes(tagName, attribs);
// TODO(mikesamuel): relying on sanitizeAttributes not to
// insert unsafe attribute names.
if (attribs) {
if (!(eflags & html4.eflags.EMPTY)) {
stack.push(tagName);
}
out.push('<', tagName);
for (var i = 0, n = attribs.length; i < n; i += 2) {
var attribName = attribs[i],
value = attribs[i + 1];
if (value !== null && value !== void 0) {
out.push(' ', attribName, '="', escapeAttrib(value), '"');
}
}
out.push('>');
}
},
endTag: function (tagName, out) {
if (ignoring) {
ignoring = false;
return;
}
if (!html4.ELEMENTS.hasOwnProperty(tagName)) { return; }
var eflags = html4.ELEMENTS[tagName];
if (!(eflags & (html4.eflags.UNSAFE | html4.eflags.EMPTY
| html4.eflags.FOLDABLE))) {
var index;
if (eflags & html4.eflags.OPTIONAL_ENDTAG) {
for (index = stack.length; --index >= 0;) {
var stackEl = stack[index];
if (stackEl === tagName) { break; }
if (!(html4.ELEMENTS[stackEl]
& html4.eflags.OPTIONAL_ENDTAG)) {
// Don't pop non optional end tags looking for a match.
return;
}
}
} else {
for (index = stack.length; --index >= 0;) {
if (stack[index] === tagName) { break; }
}
}
if (index < 0) { return; } // Not opened.
for (var i = stack.length; --i > index;) {
var stackEl = stack[i];
if (!(html4.ELEMENTS[stackEl]
& html4.eflags.OPTIONAL_ENDTAG)) {
out.push('</', stackEl, '>');
}
}
stack.length = index;
out.push('</', tagName, '>');
}
},
pcdata: function (text, out) {
if (!ignoring) { out.push(text); }
},
rcdata: function (text, out) {
if (!ignoring) { out.push(text); }
},
cdata: function (text, out) {
if (!ignoring) { out.push(text); }
},
endDoc: function (out) {
for (var i = stack.length; --i >= 0;) {
out.push('</', stack[i], '>');
}
stack.length = 0;
}
});
}
|
Returns a function that strips unsafe tags and attributes from html.
@param {Function} sanitizeAttributes
maps from (tagName, attribs[]) to null or a sanitized attribute array.
The attribs array can be arbitrarily modified, but the same array
instance is reused, so should not be held.
@return {Function} from html to sanitized html
|
makeHtmlSanitizer
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function sanitize(htmlText, opt_uriPolicy, opt_nmTokenPolicy) {
var out = [];
makeHtmlSanitizer(
function sanitizeAttribs(tagName, attribs) {
for (var i = 0; i < attribs.length; i += 2) {
var attribName = attribs[i];
var value = attribs[i + 1];
var atype = null, attribKey;
if ((attribKey = tagName + '::' + attribName,
html4.ATTRIBS.hasOwnProperty(attribKey))
|| (attribKey = '*::' + attribName,
html4.ATTRIBS.hasOwnProperty(attribKey))) {
atype = html4.ATTRIBS[attribKey];
}
if (atype !== null) {
switch (atype) {
case html4.atype.NONE: break;
case html4.atype.SCRIPT:
case html4.atype.STYLE:
value = null;
break;
case html4.atype.ID:
case html4.atype.IDREF:
case html4.atype.IDREFS:
case html4.atype.GLOBAL_NAME:
case html4.atype.LOCAL_NAME:
case html4.atype.CLASSES:
value = opt_nmTokenPolicy ? opt_nmTokenPolicy(value) : value;
break;
case html4.atype.URI:
var parsedUri = ('' + value).match(URI_SCHEME_RE);
if (!parsedUri) {
value = null;
} else if (!parsedUri[1] ||
WHITELISTED_SCHEMES.test(parsedUri[1])) {
value = opt_uriPolicy && opt_uriPolicy(value);
} else {
value = null;
}
break;
case html4.atype.URI_FRAGMENT:
if (value && '#' === value.charAt(0)) {
value = opt_nmTokenPolicy ? opt_nmTokenPolicy(value) : value;
if (value) { value = '#' + value; }
} else {
value = null;
}
break;
default:
value = null;
break;
}
} else {
value = null;
}
attribs[i + 1] = value;
}
return attribs;
})(htmlText, out);
return out.join('');
}
|
Strips unsafe tags and attributes from html.
@param {string} htmlText to sanitize
@param {Function} opt_uriPolicy -- a transform to apply to uri/url
attribute values. If no opt_uriPolicy is provided, no uris
are allowed ie. the default uriPolicy rewrites all uris to null
@param {Function} opt_nmTokenPolicy : string -> string? -- a transform to
apply to names, ids, and classes. If no opt_nmTokenPolicy is provided,
all names, ids and classes are passed through ie. the default
nmTokenPolicy is an identity transform
@return {string} html
|
sanitize
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function handleReadyState (r, success, error) {
return function () {
// use _aborted to mitigate against IE err c00c023f
// (can't read props on aborted request objects)
if (r._aborted) return error(r.request)
if (r.request && r.request[readyState] == 4) {
r.request.onreadystatechange = noop
if (twoHundo.test(r.request.status))
success(r.request)
else
error(r.request)
}
}
}
|
Strips unsafe tags and attributes from html.
@param {string} htmlText to sanitize
@param {Function} opt_uriPolicy -- a transform to apply to uri/url
attribute values. If no opt_uriPolicy is provided, no uris
are allowed ie. the default uriPolicy rewrites all uris to null
@param {Function} opt_nmTokenPolicy : string -> string? -- a transform to
apply to names, ids, and classes. If no opt_nmTokenPolicy is provided,
all names, ids and classes are passed through ie. the default
nmTokenPolicy is an identity transform
@return {string} html
|
handleReadyState
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function setHeaders (http, o) {
var headers = o.headers || {}
, h
headers.Accept = headers.Accept
|| defaultHeaders.accept[o.type]
|| defaultHeaders.accept['*']
// breaks cross-origin requests with legacy browsers
if (!o.crossOrigin && !headers[requestedWith]) headers[requestedWith] = defaultHeaders.requestedWith
if (!headers[contentType]) headers[contentType] = o.contentType || defaultHeaders.contentType
for (h in headers)
headers.hasOwnProperty(h) && http.setRequestHeader(h, headers[h])
}
|
Strips unsafe tags and attributes from html.
@param {string} htmlText to sanitize
@param {Function} opt_uriPolicy -- a transform to apply to uri/url
attribute values. If no opt_uriPolicy is provided, no uris
are allowed ie. the default uriPolicy rewrites all uris to null
@param {Function} opt_nmTokenPolicy : string -> string? -- a transform to
apply to names, ids, and classes. If no opt_nmTokenPolicy is provided,
all names, ids and classes are passed through ie. the default
nmTokenPolicy is an identity transform
@return {string} html
|
setHeaders
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function setCredentials (http, o) {
if (typeof o.withCredentials !== 'undefined' && typeof http.withCredentials !== 'undefined') {
http.withCredentials = !!o.withCredentials
}
}
|
Strips unsafe tags and attributes from html.
@param {string} htmlText to sanitize
@param {Function} opt_uriPolicy -- a transform to apply to uri/url
attribute values. If no opt_uriPolicy is provided, no uris
are allowed ie. the default uriPolicy rewrites all uris to null
@param {Function} opt_nmTokenPolicy : string -> string? -- a transform to
apply to names, ids, and classes. If no opt_nmTokenPolicy is provided,
all names, ids and classes are passed through ie. the default
nmTokenPolicy is an identity transform
@return {string} html
|
setCredentials
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function generalCallback (data) {
lastValue = data
}
|
Strips unsafe tags and attributes from html.
@param {string} htmlText to sanitize
@param {Function} opt_uriPolicy -- a transform to apply to uri/url
attribute values. If no opt_uriPolicy is provided, no uris
are allowed ie. the default uriPolicy rewrites all uris to null
@param {Function} opt_nmTokenPolicy : string -> string? -- a transform to
apply to names, ids, and classes. If no opt_nmTokenPolicy is provided,
all names, ids and classes are passed through ie. the default
nmTokenPolicy is an identity transform
@return {string} html
|
generalCallback
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function urlappend (url, s) {
return url + (/\?/.test(url) ? '&' : '?') + s
}
|
Strips unsafe tags and attributes from html.
@param {string} htmlText to sanitize
@param {Function} opt_uriPolicy -- a transform to apply to uri/url
attribute values. If no opt_uriPolicy is provided, no uris
are allowed ie. the default uriPolicy rewrites all uris to null
@param {Function} opt_nmTokenPolicy : string -> string? -- a transform to
apply to names, ids, and classes. If no opt_nmTokenPolicy is provided,
all names, ids and classes are passed through ie. the default
nmTokenPolicy is an identity transform
@return {string} html
|
urlappend
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function handleJsonp (o, fn, err, url) {
var reqId = uniqid++
, cbkey = o.jsonpCallback || 'callback' // the 'callback' key
, cbval = o.jsonpCallbackName || reqwest.getcallbackPrefix(reqId)
// , cbval = o.jsonpCallbackName || ('reqwest_' + reqId) // the 'callback' value
, cbreg = new RegExp('((^|\\?|&)' + cbkey + ')=([^&]+)')
, match = url.match(cbreg)
, script = doc.createElement('script')
, loaded = 0
, isIE10 = navigator.userAgent.indexOf('MSIE 10.0') !== -1;
if (match) {
if (match[3] === '?') {
url = url.replace(cbreg, '$1=' + cbval) // wildcard callback func name
} else {
cbval = match[3] // provided callback func name
}
} else {
url = urlappend(url, cbkey + '=' + cbval) // no callback details, add 'em
}
win[cbval] = generalCallback
script.type = 'text/javascript'
if (typeof script.onreadystatechange !== 'undefined' && !isIE10) {
// need this for IE due to out-of-order onreadystatechange(), binding script
// execution to an event listener gives us control over when the script
// is executed. See http://jaubourg.net/2010/07/loading-script-as-onclick-handler-of.html
//
// if this hack is used in IE10 jsonp callback are never called
script.event = 'onclick'
script.htmlFor = script.id = '_reqwest_' + reqId
}
script.onload = script.onreadystatechange = function () {
if ((script[readyState] && script[readyState] !== 'complete' && script[readyState] !== 'loaded') || loaded) {
return false
}
script.onload = script.onreadystatechange = null
script.onclick && script.onclick()
// Call the user callback with the last value stored and clean up values and scripts.
o.success && o.success(lastValue)
lastValue = undefined
head.removeChild(script)
loaded = 1
}
script.src = url
script.async = true
// Add the script to the DOM head
head.appendChild(script)
// Enable JSONP timeout
return {
abort: function () {
script.onload = script.onreadystatechange = null
o.error && o.error({}, 'Request is aborted: timeout', {})
lastValue = undefined
head.removeChild(script)
loaded = 1
}
}
}
|
Strips unsafe tags and attributes from html.
@param {string} htmlText to sanitize
@param {Function} opt_uriPolicy -- a transform to apply to uri/url
attribute values. If no opt_uriPolicy is provided, no uris
are allowed ie. the default uriPolicy rewrites all uris to null
@param {Function} opt_nmTokenPolicy : string -> string? -- a transform to
apply to names, ids, and classes. If no opt_nmTokenPolicy is provided,
all names, ids and classes are passed through ie. the default
nmTokenPolicy is an identity transform
@return {string} html
|
handleJsonp
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function getRequest (fn, err) {
var o = this.o
, method = (o.method || 'GET').toUpperCase()
, url = typeof o === 'string' ? o : o.url
// convert non-string objects to query-string form unless o.processData is false
, data = (o.processData !== false && o.data && typeof o.data !== 'string')
? reqwest.toQueryString(o.data)
: (o.data || null)
, http
// if we're working on a GET request and we have data then we should append
// query string to end of URL and not post data
if ((o.type == 'jsonp' || method == 'GET') && data) {
url = urlappend(url, data)
data = null
}
if (o.type == 'jsonp') return handleJsonp(o, fn, err, url)
http = xhr()
http.open(method, url, true)
setHeaders(http, o)
setCredentials(http, o)
http.onreadystatechange = handleReadyState(this, fn, err)
o.before && o.before(http)
http.send(data)
return http
}
|
Strips unsafe tags and attributes from html.
@param {string} htmlText to sanitize
@param {Function} opt_uriPolicy -- a transform to apply to uri/url
attribute values. If no opt_uriPolicy is provided, no uris
are allowed ie. the default uriPolicy rewrites all uris to null
@param {Function} opt_nmTokenPolicy : string -> string? -- a transform to
apply to names, ids, and classes. If no opt_nmTokenPolicy is provided,
all names, ids and classes are passed through ie. the default
nmTokenPolicy is an identity transform
@return {string} html
|
getRequest
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function Reqwest (o, fn) {
this.o = o
this.fn = fn
init.apply(this, arguments)
}
|
Strips unsafe tags and attributes from html.
@param {string} htmlText to sanitize
@param {Function} opt_uriPolicy -- a transform to apply to uri/url
attribute values. If no opt_uriPolicy is provided, no uris
are allowed ie. the default uriPolicy rewrites all uris to null
@param {Function} opt_nmTokenPolicy : string -> string? -- a transform to
apply to names, ids, and classes. If no opt_nmTokenPolicy is provided,
all names, ids and classes are passed through ie. the default
nmTokenPolicy is an identity transform
@return {string} html
|
Reqwest
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function setType (url) {
var m = url.match(/\.(json|jsonp|html|xml)(\?|$)/)
return m ? m[1] : 'js'
}
|
Strips unsafe tags and attributes from html.
@param {string} htmlText to sanitize
@param {Function} opt_uriPolicy -- a transform to apply to uri/url
attribute values. If no opt_uriPolicy is provided, no uris
are allowed ie. the default uriPolicy rewrites all uris to null
@param {Function} opt_nmTokenPolicy : string -> string? -- a transform to
apply to names, ids, and classes. If no opt_nmTokenPolicy is provided,
all names, ids and classes are passed through ie. the default
nmTokenPolicy is an identity transform
@return {string} html
|
setType
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function init (o, fn) {
this.url = typeof o == 'string' ? o : o.url
this.timeout = null
// whether request has been fulfilled for purpose
// of tracking the Promises
this._fulfilled = false
// success handlers
this._fulfillmentHandlers = []
// error handlers
this._errorHandlers = []
// complete (both success and fail) handlers
this._completeHandlers = []
this._erred = false
this._responseArgs = {}
var self = this
, type = o.type || setType(this.url)
fn = fn || function () {}
if (o.timeout) {
this.timeout = setTimeout(function () {
self.abort()
}, o.timeout)
}
if (o.success) {
this._fulfillmentHandlers.push(function () {
o.success.apply(o, arguments)
})
}
if (o.error) {
this._errorHandlers.push(function () {
o.error.apply(o, arguments)
})
}
if (o.complete) {
this._completeHandlers.push(function () {
o.complete.apply(o, arguments)
})
}
function complete (resp) {
o.timeout && clearTimeout(self.timeout)
self.timeout = null
while (self._completeHandlers.length > 0) {
self._completeHandlers.shift()(resp)
}
}
function success (resp) {
var r = resp.responseText
if (r) {
switch (type) {
case 'json':
try {
resp = win.JSON ? win.JSON.parse(r) : eval('(' + r + ')')
} catch (err) {
return error(resp, 'Could not parse JSON in response', err)
}
break
case 'js':
resp = eval(r)
break
case 'html':
resp = r
break
case 'xml':
resp = resp.responseXML
&& resp.responseXML.parseError // IE trololo
&& resp.responseXML.parseError.errorCode
&& resp.responseXML.parseError.reason
? null
: resp.responseXML
break
}
}
self._responseArgs.resp = resp
self._fulfilled = true
fn(resp)
while (self._fulfillmentHandlers.length > 0) {
self._fulfillmentHandlers.shift()(resp)
}
complete(resp)
}
function error (resp, msg, t) {
self._responseArgs.resp = resp
self._responseArgs.msg = msg
self._responseArgs.t = t
self._erred = true
while (self._errorHandlers.length > 0) {
self._errorHandlers.shift()(resp, msg, t)
}
complete(resp)
}
this.request = getRequest.call(this, success, error)
}
|
Strips unsafe tags and attributes from html.
@param {string} htmlText to sanitize
@param {Function} opt_uriPolicy -- a transform to apply to uri/url
attribute values. If no opt_uriPolicy is provided, no uris
are allowed ie. the default uriPolicy rewrites all uris to null
@param {Function} opt_nmTokenPolicy : string -> string? -- a transform to
apply to names, ids, and classes. If no opt_nmTokenPolicy is provided,
all names, ids and classes are passed through ie. the default
nmTokenPolicy is an identity transform
@return {string} html
|
init
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function complete (resp) {
o.timeout && clearTimeout(self.timeout)
self.timeout = null
while (self._completeHandlers.length > 0) {
self._completeHandlers.shift()(resp)
}
}
|
Strips unsafe tags and attributes from html.
@param {string} htmlText to sanitize
@param {Function} opt_uriPolicy -- a transform to apply to uri/url
attribute values. If no opt_uriPolicy is provided, no uris
are allowed ie. the default uriPolicy rewrites all uris to null
@param {Function} opt_nmTokenPolicy : string -> string? -- a transform to
apply to names, ids, and classes. If no opt_nmTokenPolicy is provided,
all names, ids and classes are passed through ie. the default
nmTokenPolicy is an identity transform
@return {string} html
|
complete
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function success (resp) {
var r = resp.responseText
if (r) {
switch (type) {
case 'json':
try {
resp = win.JSON ? win.JSON.parse(r) : eval('(' + r + ')')
} catch (err) {
return error(resp, 'Could not parse JSON in response', err)
}
break
case 'js':
resp = eval(r)
break
case 'html':
resp = r
break
case 'xml':
resp = resp.responseXML
&& resp.responseXML.parseError // IE trololo
&& resp.responseXML.parseError.errorCode
&& resp.responseXML.parseError.reason
? null
: resp.responseXML
break
}
}
self._responseArgs.resp = resp
self._fulfilled = true
fn(resp)
while (self._fulfillmentHandlers.length > 0) {
self._fulfillmentHandlers.shift()(resp)
}
complete(resp)
}
|
Strips unsafe tags and attributes from html.
@param {string} htmlText to sanitize
@param {Function} opt_uriPolicy -- a transform to apply to uri/url
attribute values. If no opt_uriPolicy is provided, no uris
are allowed ie. the default uriPolicy rewrites all uris to null
@param {Function} opt_nmTokenPolicy : string -> string? -- a transform to
apply to names, ids, and classes. If no opt_nmTokenPolicy is provided,
all names, ids and classes are passed through ie. the default
nmTokenPolicy is an identity transform
@return {string} html
|
success
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function error (resp, msg, t) {
self._responseArgs.resp = resp
self._responseArgs.msg = msg
self._responseArgs.t = t
self._erred = true
while (self._errorHandlers.length > 0) {
self._errorHandlers.shift()(resp, msg, t)
}
complete(resp)
}
|
Strips unsafe tags and attributes from html.
@param {string} htmlText to sanitize
@param {Function} opt_uriPolicy -- a transform to apply to uri/url
attribute values. If no opt_uriPolicy is provided, no uris
are allowed ie. the default uriPolicy rewrites all uris to null
@param {Function} opt_nmTokenPolicy : string -> string? -- a transform to
apply to names, ids, and classes. If no opt_nmTokenPolicy is provided,
all names, ids and classes are passed through ie. the default
nmTokenPolicy is an identity transform
@return {string} html
|
error
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function reqwest (o, fn) {
return new Reqwest(o, fn)
}
|
`fail` will execute when the request fails
|
reqwest
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function normalize (s) {
return s ? s.replace(/\r?\n/g, '\r\n') : ''
}
|
`fail` will execute when the request fails
|
normalize
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function serial (el, cb) {
var n = el.name
, t = el.tagName.toLowerCase()
, optCb = function (o) {
// IE gives value="" even where there is no value attribute
// 'specified' ref: http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-862529273
if (o && !o.disabled)
cb(n, normalize(o.attributes.value && o.attributes.value.specified ? o.value : o.text))
}
, ch, ra, val, i
// don't serialize elements that are disabled or without a name
if (el.disabled || !n) return
switch (t) {
case 'input':
if (!/reset|button|image|file/i.test(el.type)) {
ch = /checkbox/i.test(el.type)
ra = /radio/i.test(el.type)
val = el.value
// WebKit gives us "" instead of "on" if a checkbox has no value, so correct it here
;(!(ch || ra) || el.checked) && cb(n, normalize(ch && val === '' ? 'on' : val))
}
break
case 'textarea':
cb(n, normalize(el.value))
break
case 'select':
if (el.type.toLowerCase() === 'select-one') {
optCb(el.selectedIndex >= 0 ? el.options[el.selectedIndex] : null)
} else {
for (i = 0; el.length && i < el.length; i++) {
el.options[i].selected && optCb(el.options[i])
}
}
break
}
}
|
`fail` will execute when the request fails
|
serial
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
optCb = function (o) {
// IE gives value="" even where there is no value attribute
// 'specified' ref: http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-862529273
if (o && !o.disabled)
cb(n, normalize(o.attributes.value && o.attributes.value.specified ? o.value : o.text))
}
|
`fail` will execute when the request fails
|
optCb
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function eachFormElement () {
var cb = this
, e, i
, serializeSubtags = function (e, tags) {
var i, j, fa
for (i = 0; i < tags.length; i++) {
fa = e[byTag](tags[i])
for (j = 0; j < fa.length; j++) serial(fa[j], cb)
}
}
for (i = 0; i < arguments.length; i++) {
e = arguments[i]
if (/input|select|textarea/i.test(e.tagName)) serial(e, cb)
serializeSubtags(e, [ 'input', 'select', 'textarea' ])
}
}
|
`fail` will execute when the request fails
|
eachFormElement
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
serializeSubtags = function (e, tags) {
var i, j, fa
for (i = 0; i < tags.length; i++) {
fa = e[byTag](tags[i])
for (j = 0; j < fa.length; j++) serial(fa[j], cb)
}
}
|
`fail` will execute when the request fails
|
serializeSubtags
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function serializeQueryString () {
return reqwest.toQueryString(reqwest.serializeArray.apply(null, arguments))
}
|
`fail` will execute when the request fails
|
serializeQueryString
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function serializeHash () {
var hash = {}
eachFormElement.apply(function (name, value) {
if (name in hash) {
hash[name] && !isArray(hash[name]) && (hash[name] = [hash[name]])
hash[name].push(value)
} else hash[name] = value
}, arguments)
return hash
}
|
`fail` will execute when the request fails
|
serializeHash
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
push = function (k, v) {
qs += enc(k) + '=' + enc(v) + '&'
}
|
`fail` will execute when the request fails
|
push
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function bwTest() {
wax.bw = -1;
var im = new Image();
im.src = testImage;
var first = true;
var timeout = setTimeout(function() {
if (first && wax.bw == -1) {
detector.bw(0);
first = false;
}
}, threshold);
im.onload = function() {
if (first && wax.bw == -1) {
clearTimeout(timeout);
detector.bw(1);
first = false;
}
};
}
|
`fail` will execute when the request fails
|
bwTest
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function resolveCode(key) {
if (key >= 93) key--;
if (key >= 35) key--;
key -= 32;
return key;
}
|
`fail` will execute when the request fails
|
resolveCode
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
gridUrl = function(url) {
if (url) {
return url.replace(/(\.png|\.jpg|\.jpeg)(\d*)/, '.grid.json');
}
}
|
`fail` will execute when the request fails
|
gridUrl
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function templatedGridUrl(template) {
if (typeof template === 'string') template = [template];
return function templatedGridFinder(url) {
if (!url) return;
var rx = new RegExp(manager.tileRegexp())
var xyz = rx.exec(url);
if (!xyz) return;
return template[parseInt(xyz[2], 10) % template.length]
.replace(/\{z\}/g, xyz[1])
.replace(/\{x\}/g, xyz[2])
.replace(/\{y\}/g, xyz[3]);
};
}
|
`fail` will execute when the request fails
|
templatedGridUrl
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function getState() {
return location.hash.substring(1);
}
|
`fail` will execute when the request fails
|
getState
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function pushState(state) {
var l = window.location;
l.replace(l.toString().replace((l.hash || /$/), '#' + state));
}
|
`fail` will execute when the request fails
|
pushState
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function parseHash(s) {
var args = s.split('/');
for (var i = 0; i < args.length; i++) {
args[i] = Number(args[i]);
if (isNaN(args[i])) return true;
}
if (args.length < 3) {
// replace bogus hash
return true;
} else if (args.length == 3) {
options.setCenterZoom(args);
}
}
|
`fail` will execute when the request fails
|
parseHash
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function move() {
var s1 = options.getCenterZoom();
if (s0 !== s1) {
s0 = s1;
// don't recenter the map!
pushState(s0);
}
}
|
`fail` will execute when the request fails
|
move
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function stateChange(state) {
// ignore spurious hashchange events
if (state === s0) return;
if (parseHash(s0 = state)) {
// replace bogus hash
move();
}
}
|
`fail` will execute when the request fails
|
stateChange
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function getTile(e) {
var g = grid();
var regExp = new RegExp(gm.tileRegexp());
for (var i = 0; i < g.length; i++) {
if (e) {
var isInside = ((g[i][0] <= e.y) &&
((g[i][0] + 256) > e.y) &&
(g[i][1] <= e.x) &&
((g[i][1] + 256) > e.x));
if(isInside && regExp.exec(g[i][2].src)) {
return g[i][2];
}
}
}
return false;
}
|
`fail` will execute when the request fails
|
getTile
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function killTimeout() {
if (_clickTimeout) {
window.clearTimeout(_clickTimeout);
_clickTimeout = null;
return true;
} else {
return false;
}
}
|
`fail` will execute when the request fails
|
killTimeout
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function onMove(e) {
// If the user is actually dragging the map, exit early
// to avoid performance hits.
if (_downLock) return;
var _e = (e.type !== "MSPointerMove" && e.type !== "pointermove" ? e : e.originalEvent);
var pos = wax.u.eventoffset(_e);
interaction.screen_feature(pos, function(feature) {
if (feature) {
bean.fire(interaction, 'on', {
parent: parent(),
data: feature,
formatter: gm.formatter().format,
e: e
});
} else {
bean.fire(interaction, 'off');
}
});
}
|
`fail` will execute when the request fails
|
onMove
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function onDown(e) {
// Prevent interaction offset calculations happening while
// the user is dragging the map.
//
// Store this event so that we can compare it to the
// up event
_downLock = true;
var _e = (e.type !== "MSPointerDown" && e.type !== "pointerdown" ? e : e.originalEvent);
_d = wax.u.eventoffset(_e);
if (e.type === 'mousedown') {
bean.add(document.body, 'click', onUp);
// track mouse up to remove lockDown when the drags end
bean.add(document.body, 'mouseup', dragEnd);
// Only track single-touches. Double-touches will not affect this
// control
} else if (e.type === 'touchstart' && e.touches.length === 1) {
//GMaps fix: Because it's triggering always mousedown and click, we've to remove it
bean.remove(document.body, 'click', onUp); //GMaps fix
//When we finish dragging, then the click will be
bean.add(document.body, 'click', onUp);
bean.add(document.body, 'touchEnd', dragEnd);
} else if (e.originalEvent.type === "MSPointerDown" && e.originalEvent.touches && e.originalEvent.touches.length === 1) {
// Don't make the user click close if they hit another tooltip
bean.fire(interaction, 'off');
// Touch moves invalidate touches
bean.add(parent(), mspointerEnds);
} else if (e.type === "pointerdown" && e.originalEvent.touches && e.originalEvent.touches.length === 1) {
// Don't make the user click close if they hit another tooltip
bean.fire(interaction, 'off');
// Touch moves invalidate touches
bean.add(parent(), pointerEnds);
} else {
// Fix layer interaction in IE10/11 (CDBjs #139)
// Reason: Internet Explorer is triggering pointerdown when you click on the marker, and other browsers don't.
// Because of that, _downLock was active and it believed that you're dragging the map, instead of dragging the marker
_downLock = false;
}
}
|
`fail` will execute when the request fails
|
onDown
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function dragEnd() {
_downLock = false;
}
|
`fail` will execute when the request fails
|
dragEnd
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function touchCancel() {
bean.remove(parent(), touchEnds);
bean.remove(parent(), mspointerEnds);
bean.remove(parent(), pointerEnds);
_downLock = false;
}
|
`fail` will execute when the request fails
|
touchCancel
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function onUp(e) {
var evt = {};
var _e = (e.type !== "MSPointerMove" && e.type !== "MSPointerUp" && e.type !== "pointerup" && e.type !== "pointermove" ? e : e.originalEvent);
var pos = wax.u.eventoffset(_e);
_downLock = false;
for (var key in _e) {
evt[key] = _e[key];
}
// for (var key in e) {
// evt[key] = e[key];
// }
bean.remove(document.body, 'mouseup', onUp);
bean.remove(parent(), touchEnds);
bean.remove(parent(), mspointerEnds);
bean.remove(parent(), pointerEnds);
if (e.type === 'touchend') {
// If this was a touch and it survived, there's no need to avoid a double-tap
// but also wax.u.eventoffset will have failed, since this touch
// event doesn't have coordinates
interaction.click(e, _d);
} else if (pos && _d) {
// If pos is not defined means wax can't calculate event position,
// So next cases aren't possible.
if (evt.type === "MSPointerMove" || evt.type === "MSPointerUp") {
evt.changedTouches = [];
interaction.click(evt, pos);
} else if (evt.type === "pointermove" || evt.type === "pointerup") {
interaction.click(evt, pos);
} else if (Math.round(pos.y / tol) === Math.round(_d.y / tol) &&
Math.round(pos.x / tol) === Math.round(_d.x / tol)) {
// if mousemove and click are sent at the same time this code
// will not trigger click event because less than 150ms pass between
// those events.
// Because of that this flag discards touchMove
if (_discardTouchMove && evt.type === 'touchmove') return onUp;
// Contain the event data in a closure.
// Ignore double-clicks by ignoring clicks within 300ms of
// each other.
if(!_clickTimeout) {
_clickTimeout = window.setTimeout(function() {
_clickTimeout = null;
interaction.click(evt, pos);
}, 150);
} else {
killTimeout();
}
}
}
return onUp;
}
|
`fail` will execute when the request fails
|
onUp
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function on(o) {
if ((o.e.type === 'mousemove' || !o.e.type)) {
return;
} else {
var loc = o.formatter({ format: 'location' }, o.data);
if (loc) {
window.location.href = loc;
}
}
}
|
`fail` will execute when the request fails
|
on
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
calculateOffset = function(el) {
if (el === doc_body || el === document.documentElement) return;
top += el.offsetTop;
left += el.offsetLeft;
var style = el.style.transform ||
el.style.WebkitTransform ||
el.style.OTransform ||
el.style.MozTransform ||
el.style.msTransform;
if (style) {
var match;
if (match = style.match(/translate\((.+)px, (.+)px\)/)) {
top += parseInt(match[2], 10);
left += parseInt(match[1], 10);
} else if (match = style.match(/translate3d\((.+)px, (.+)px, (.+)px\)/)) {
top += parseInt(match[2], 10);
left += parseInt(match[1], 10);
} else if (match = style.match(/matrix3d\(([\-\d,\s]+)\)/)) {
var pts = match[1].split(',');
top += parseInt(pts[13], 10);
left += parseInt(pts[12], 10);
} else if (match = style.match(/matrix\(.+, .+, .+, .+, (.+), (.+)\)/)) {
top += parseInt(match[2], 10);
left += parseInt(match[1], 10);
}
}
}
|
`fail` will execute when the request fails
|
calculateOffset
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function calculateOffsetIE(){
calculateOffset(el);
try {
while (el = el.offsetParent) { calculateOffset(el); }
} catch(e) {
// Hello, internet explorer.
}
}
|
`fail` will execute when the request fails
|
calculateOffsetIE
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
throttler = function() {
timeout = null;
func.apply(context, args);
}
|
`fail` will execute when the request fails
|
throttler
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function urlX(url) {
// Data URIs are subject to a bug in Firefox
// https://bugzilla.mozilla.org/show_bug.cgi?id=255107
// which let them be a vector. But WebKit does 'the right thing'
// or at least 'something' about this situation, so we'll tolerate
// them.
if (/^(https?:\/\/|data:image)/.test(url)) {
return url;
}
}
|
`fail` will execute when the request fails
|
urlX
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function grid() {
// TODO: don't build for tiles outside of viewport
// Touch interaction leads to intermediate
//var zoomLayer = map.createOrGetLayer(Math.round(map.getZoom())); //?what is this doing?
// Calculate a tile grid and cache it, by using the `.tiles`
// element on this map.
if (!dirty && _grid) {
return _grid;
} else {
return (_grid = (function(layers) {
var o = [];
for (var layerId in layers) {
// This only supports tiled layers
if (layers[layerId]._tiles) {
for (var tile in layers[layerId]._tiles) {
var _tile = layers[layerId]._tiles[tile];
// avoid adding tiles without src, grid url can't be found for them
if(_tile.src) {
var offset = wax.u.offset(_tile);
o.push([offset.top, offset.left, _tile]);
}
}
}
}
return o;
})(map._layers));
}
}
|
`fail` will execute when the request fails
|
grid
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function attach(x) {
if (!arguments.length) return map;
map = x;
var l = ['moveend'];
for (var i = 0; i < l.length; i++) {
map.on(l[i], setdirty);
}
}
|
`fail` will execute when the request fails
|
attach
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function detach(x) {
if (!arguments.length) return map;
map = x;
var l = ['moveend'];
for (var i = 0; i < l.length; i++) {
map.off(l[i], setdirty);
}
}
|
`fail` will execute when the request fails
|
detach
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function grid() {
// when interaction is enabled there should be grid tiles
if (!dirty && _grid && (_grid.length > 0 || !interactionEnabled)) {
return _grid;
} else {
_grid = [];
var zoom = map.getZoom();
var mapOffset = wax.u.offset(map.getDiv());
var get = function(mapType) {
if (!mapType || !mapType.interactive) return;
interactionEnabled = true;
for (var key in mapType.cache) {
if (key.split('/')[0] != zoom) continue;
var tileOffset = wax.u.offset(mapType.cache[key]);
_grid.push([
tileOffset.top,
tileOffset.left,
mapType.cache[key]
]);
}
};
// Iterate over base mapTypes and overlayMapTypes.
for (var i in map.mapTypes) get(map.mapTypes[i]);
map.overlayMapTypes.forEach(get);
}
return _grid;
}
|
`fail` will execute when the request fails
|
grid
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
get = function(mapType) {
if (!mapType || !mapType.interactive) return;
interactionEnabled = true;
for (var key in mapType.cache) {
if (key.split('/')[0] != zoom) continue;
var tileOffset = wax.u.offset(mapType.cache[key]);
_grid.push([
tileOffset.top,
tileOffset.left,
mapType.cache[key]
]);
}
}
|
`fail` will execute when the request fails
|
get
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function attach(x) {
if (!arguments.length) return map;
map = x;
tileloadListener = google.maps.event.addListener(map, 'tileloaded',
setdirty);
idleListener = google.maps.event.addListener(map, 'idle',
setdirty);
}
|
`fail` will execute when the request fails
|
attach
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function detach(x) {
if(tileloadListener)
google.maps.event.removeListener(tileloadListener);
if(idleListener)
google.maps.event.removeListener(idleListener);
}
|
`fail` will execute when the request fails
|
detach
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
GeoJSON = function( geojson, options ){
var _geometryToGoogleMaps = function( geojsonGeometry, opts, geojsonProperties ){
var googleObj;
switch ( geojsonGeometry.type ){
case "Point":
opts.position = new google.maps.LatLng(geojsonGeometry.coordinates[1], geojsonGeometry.coordinates[0]);
googleObj = new google.maps.Marker(opts);
if (geojsonProperties) {
googleObj.set("geojsonProperties", geojsonProperties);
}
break;
case "MultiPoint":
googleObj = [];
for (var i = 0; i < geojsonGeometry.coordinates.length; i++){
opts.position = new google.maps.LatLng(geojsonGeometry.coordinates[i][1], geojsonGeometry.coordinates[i][0]);
googleObj.push(new google.maps.Marker(opts));
}
if (geojsonProperties) {
for (var k = 0; k < googleObj.length; k++){
googleObj[k].set("geojsonProperties", geojsonProperties);
}
}
break;
case "LineString":
var path = [];
for (var i = 0; i < geojsonGeometry.coordinates.length; i++){
var coord = geojsonGeometry.coordinates[i];
var ll = new google.maps.LatLng(coord[1], coord[0]);
path.push(ll);
}
opts.path = path;
googleObj = new google.maps.Polyline(opts);
if (geojsonProperties) {
googleObj.set("geojsonProperties", geojsonProperties);
}
break;
case "MultiLineString":
googleObj = [];
for (var i = 0; i < geojsonGeometry.coordinates.length; i++){
var path = [];
for (var j = 0; j < geojsonGeometry.coordinates[i].length; j++){
var coord = geojsonGeometry.coordinates[i][j];
var ll = new google.maps.LatLng(coord[1], coord[0]);
path.push(ll);
}
opts.path = path;
googleObj.push(new google.maps.Polyline(opts));
}
if (geojsonProperties) {
for (var k = 0; k < googleObj.length; k++){
googleObj[k].set("geojsonProperties", geojsonProperties);
}
}
break;
case "Polygon":
var paths = [];
var exteriorDirection;
var interiorDirection;
for (var i = 0; i < geojsonGeometry.coordinates.length; i++){
var path = [];
for (var j = 0; j < geojsonGeometry.coordinates[i].length; j++){
var ll = new google.maps.LatLng(geojsonGeometry.coordinates[i][j][1], geojsonGeometry.coordinates[i][j][0]);
path.push(ll);
}
if(!i){
exteriorDirection = _ccw(path);
paths.push(path);
}else if(i == 1){
interiorDirection = _ccw(path);
if(exteriorDirection == interiorDirection){
paths.push(path.reverse());
}else{
paths.push(path);
}
}else{
if(exteriorDirection == interiorDirection){
paths.push(path.reverse());
}else{
paths.push(path);
}
}
}
opts.paths = paths;
googleObj = new google.maps.Polygon(opts);
if (geojsonProperties) {
googleObj.set("geojsonProperties", geojsonProperties);
}
break;
case "MultiPolygon":
googleObj = [];
for (var i = 0; i < geojsonGeometry.coordinates.length; i++){
var paths = [];
var exteriorDirection;
var interiorDirection;
for (var j = 0; j < geojsonGeometry.coordinates[i].length; j++){
var path = [];
for (var k = 0; k < geojsonGeometry.coordinates[i][j].length - 1; k++){
var ll = new google.maps.LatLng(geojsonGeometry.coordinates[i][j][k][1], geojsonGeometry.coordinates[i][j][k][0]);
path.push(ll);
}
if(!j){
exteriorDirection = _ccw(path);
paths.push(path);
}else if(j == 1){
interiorDirection = _ccw(path);
if(exteriorDirection == interiorDirection){
paths.push(path.reverse());
}else{
paths.push(path);
}
}else{
if(exteriorDirection == interiorDirection){
paths.push(path.reverse());
}else{
paths.push(path);
}
}
}
opts.paths = paths;
googleObj.push(new google.maps.Polygon(opts));
}
if (geojsonProperties) {
for (var k = 0; k < googleObj.length; k++){
googleObj[k].set("geojsonProperties", geojsonProperties);
}
}
break;
case "GeometryCollection":
googleObj = [];
if (!geojsonGeometry.geometries){
googleObj = _error("Invalid GeoJSON object: GeometryCollection object missing \"geometries\" member.");
}else{
for (var i = 0; i < geojsonGeometry.geometries.length; i++){
googleObj.push(_geometryToGoogleMaps(geojsonGeometry.geometries[i], opts, geojsonProperties || null));
}
}
break;
default:
googleObj = _error("Invalid GeoJSON object: Geometry object must be one of \"Point\", \"LineString\", \"Polygon\" or \"MultiPolygon\".");
}
return googleObj;
};
var _error = function( message ){
return {
type: "Error",
message: message
};
};
var _ccw = function( path ){
var isCCW;
var a = 0;
for (var i = 0; i < path.length-2; i++){
a += ((path[i+1].lat() - path[i].lat()) * (path[i+2].lng() - path[i].lng()) - (path[i+2].lat() - path[i].lat()) * (path[i+1].lng() - path[i].lng()));
}
if(a > 0){
isCCW = true;
}
else{
isCCW = false;
}
return isCCW;
};
var obj;
var opts = options || {};
switch ( geojson.type ){
case "FeatureCollection":
if (!geojson.features){
obj = _error("Invalid GeoJSON object: FeatureCollection object missing \"features\" member.");
}else{
obj = [];
for (var i = 0; i < geojson.features.length; i++){
obj.push(_geometryToGoogleMaps(geojson.features[i].geometry, opts, geojson.features[i].properties));
}
}
break;
case "GeometryCollection":
if (!geojson.geometries){
obj = _error("Invalid GeoJSON object: GeometryCollection object missing \"geometries\" member.");
}else{
obj = [];
for (var i = 0; i < geojson.geometries.length; i++){
obj.push(_geometryToGoogleMaps(geojson.geometries[i], opts));
}
}
break;
case "Feature":
if (!( geojson.properties && geojson.geometry )){
obj = _error("Invalid GeoJSON object: Feature object missing \"properties\" or \"geometry\" member.");
}else{
obj = _geometryToGoogleMaps(geojson.geometry, opts, geojson.properties);
}
break;
case "Point": case "MultiPoint": case "LineString": case "MultiLineString": case "Polygon": case "MultiPolygon":
obj = geojson.coordinates
? obj = _geometryToGoogleMaps(geojson, opts)
: _error("Invalid GeoJSON object: Geometry object missing \"coordinates\" member.");
break;
default:
obj = _error("Invalid GeoJSON object: GeoJSON object must be one of \"Point\", \"LineString\", \"Polygon\", \"MultiPolygon\", \"Feature\", \"FeatureCollection\" or \"GeometryCollection\".");
}
return obj;
}
|
`fail` will execute when the request fails
|
GeoJSON
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
_geometryToGoogleMaps = function( geojsonGeometry, opts, geojsonProperties ){
var googleObj;
switch ( geojsonGeometry.type ){
case "Point":
opts.position = new google.maps.LatLng(geojsonGeometry.coordinates[1], geojsonGeometry.coordinates[0]);
googleObj = new google.maps.Marker(opts);
if (geojsonProperties) {
googleObj.set("geojsonProperties", geojsonProperties);
}
break;
case "MultiPoint":
googleObj = [];
for (var i = 0; i < geojsonGeometry.coordinates.length; i++){
opts.position = new google.maps.LatLng(geojsonGeometry.coordinates[i][1], geojsonGeometry.coordinates[i][0]);
googleObj.push(new google.maps.Marker(opts));
}
if (geojsonProperties) {
for (var k = 0; k < googleObj.length; k++){
googleObj[k].set("geojsonProperties", geojsonProperties);
}
}
break;
case "LineString":
var path = [];
for (var i = 0; i < geojsonGeometry.coordinates.length; i++){
var coord = geojsonGeometry.coordinates[i];
var ll = new google.maps.LatLng(coord[1], coord[0]);
path.push(ll);
}
opts.path = path;
googleObj = new google.maps.Polyline(opts);
if (geojsonProperties) {
googleObj.set("geojsonProperties", geojsonProperties);
}
break;
case "MultiLineString":
googleObj = [];
for (var i = 0; i < geojsonGeometry.coordinates.length; i++){
var path = [];
for (var j = 0; j < geojsonGeometry.coordinates[i].length; j++){
var coord = geojsonGeometry.coordinates[i][j];
var ll = new google.maps.LatLng(coord[1], coord[0]);
path.push(ll);
}
opts.path = path;
googleObj.push(new google.maps.Polyline(opts));
}
if (geojsonProperties) {
for (var k = 0; k < googleObj.length; k++){
googleObj[k].set("geojsonProperties", geojsonProperties);
}
}
break;
case "Polygon":
var paths = [];
var exteriorDirection;
var interiorDirection;
for (var i = 0; i < geojsonGeometry.coordinates.length; i++){
var path = [];
for (var j = 0; j < geojsonGeometry.coordinates[i].length; j++){
var ll = new google.maps.LatLng(geojsonGeometry.coordinates[i][j][1], geojsonGeometry.coordinates[i][j][0]);
path.push(ll);
}
if(!i){
exteriorDirection = _ccw(path);
paths.push(path);
}else if(i == 1){
interiorDirection = _ccw(path);
if(exteriorDirection == interiorDirection){
paths.push(path.reverse());
}else{
paths.push(path);
}
}else{
if(exteriorDirection == interiorDirection){
paths.push(path.reverse());
}else{
paths.push(path);
}
}
}
opts.paths = paths;
googleObj = new google.maps.Polygon(opts);
if (geojsonProperties) {
googleObj.set("geojsonProperties", geojsonProperties);
}
break;
case "MultiPolygon":
googleObj = [];
for (var i = 0; i < geojsonGeometry.coordinates.length; i++){
var paths = [];
var exteriorDirection;
var interiorDirection;
for (var j = 0; j < geojsonGeometry.coordinates[i].length; j++){
var path = [];
for (var k = 0; k < geojsonGeometry.coordinates[i][j].length - 1; k++){
var ll = new google.maps.LatLng(geojsonGeometry.coordinates[i][j][k][1], geojsonGeometry.coordinates[i][j][k][0]);
path.push(ll);
}
if(!j){
exteriorDirection = _ccw(path);
paths.push(path);
}else if(j == 1){
interiorDirection = _ccw(path);
if(exteriorDirection == interiorDirection){
paths.push(path.reverse());
}else{
paths.push(path);
}
}else{
if(exteriorDirection == interiorDirection){
paths.push(path.reverse());
}else{
paths.push(path);
}
}
}
opts.paths = paths;
googleObj.push(new google.maps.Polygon(opts));
}
if (geojsonProperties) {
for (var k = 0; k < googleObj.length; k++){
googleObj[k].set("geojsonProperties", geojsonProperties);
}
}
break;
case "GeometryCollection":
googleObj = [];
if (!geojsonGeometry.geometries){
googleObj = _error("Invalid GeoJSON object: GeometryCollection object missing \"geometries\" member.");
}else{
for (var i = 0; i < geojsonGeometry.geometries.length; i++){
googleObj.push(_geometryToGoogleMaps(geojsonGeometry.geometries[i], opts, geojsonProperties || null));
}
}
break;
default:
googleObj = _error("Invalid GeoJSON object: Geometry object must be one of \"Point\", \"LineString\", \"Polygon\" or \"MultiPolygon\".");
}
return googleObj;
}
|
`fail` will execute when the request fails
|
_geometryToGoogleMaps
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
_error = function( message ){
return {
type: "Error",
message: message
};
}
|
`fail` will execute when the request fails
|
_error
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
_ccw = function( path ){
var isCCW;
var a = 0;
for (var i = 0; i < path.length-2; i++){
a += ((path[i+1].lat() - path[i].lat()) * (path[i+2].lng() - path[i].lng()) - (path[i+2].lat() - path[i].lat()) * (path[i+1].lng() - path[i].lng()));
}
if(a > 0){
isCCW = true;
}
else{
isCCW = false;
}
return isCCW;
}
|
`fail` will execute when the request fails
|
_ccw
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function JScrollPane(elem, s)
{
var settings, jsp = this, pane, paneWidth, paneHeight, container, contentWidth, contentHeight,
percentInViewH, percentInViewV, isScrollableV, isScrollableH, verticalDrag, dragMaxY,
verticalDragPosition, horizontalDrag, dragMaxX, horizontalDragPosition,
verticalBar, verticalTrack, scrollbarWidth, verticalTrackHeight, verticalDragHeight, arrowUp, arrowDown,
horizontalBar, horizontalTrack, horizontalTrackWidth, horizontalDragWidth, arrowLeft, arrowRight,
reinitialiseInterval, originalPadding, originalPaddingTotalWidth, previousContentWidth,
wasAtTop = true, wasAtLeft = true, wasAtBottom = false, wasAtRight = false,
originalElement = elem.clone(false, false).empty(),
mwEvent = $.fn.mwheelIntent ? 'mwheelIntent.jsp' : 'mousewheel.jsp';
originalPadding = elem.css('paddingTop') + ' ' +
elem.css('paddingRight') + ' ' +
elem.css('paddingBottom') + ' ' +
elem.css('paddingLeft');
originalPaddingTotalWidth = (parseInt(elem.css('paddingLeft'), 10) || 0) +
(parseInt(elem.css('paddingRight'), 10) || 0);
function initialise(s)
{
var /*firstChild, lastChild, */isMaintainingPositon, lastContentX, lastContentY,
hasContainingSpaceChanged, originalScrollTop, originalScrollLeft,
maintainAtBottom = false, maintainAtRight = false;
settings = s;
if (pane === undefined) {
originalScrollTop = elem.scrollTop();
originalScrollLeft = elem.scrollLeft();
elem.css(
{
overflow: 'hidden',
padding: 0
}
);
// TODO: Deal with where width/ height is 0 as it probably means the element is hidden and we should
// come back to it later and check once it is unhidden...
paneWidth = elem.innerWidth() + originalPaddingTotalWidth;
paneHeight = elem.innerHeight();
elem.width(paneWidth);
pane = $('<div class="jspPane" />').css('padding', originalPadding).append(elem.children());
container = $('<div class="jspContainer" />')
.css({
'width': paneWidth + 'px',
'height': paneHeight + 'px'
}
).append(pane).appendTo(elem);
/*
// Move any margins from the first and last children up to the container so they can still
// collapse with neighbouring elements as they would before jScrollPane
firstChild = pane.find(':first-child');
lastChild = pane.find(':last-child');
elem.css(
{
'margin-top': firstChild.css('margin-top'),
'margin-bottom': lastChild.css('margin-bottom')
}
);
firstChild.css('margin-top', 0);
lastChild.css('margin-bottom', 0);
*/
} else {
elem.css('width', '');
maintainAtBottom = settings.stickToBottom && isCloseToBottom();
maintainAtRight = settings.stickToRight && isCloseToRight();
hasContainingSpaceChanged = elem.innerWidth() + originalPaddingTotalWidth != paneWidth || elem.outerHeight() != paneHeight;
if (hasContainingSpaceChanged) {
paneWidth = elem.innerWidth() + originalPaddingTotalWidth;
paneHeight = elem.innerHeight();
container.css({
width: paneWidth + 'px',
height: paneHeight + 'px'
});
}
// If nothing changed since last check...
if (!hasContainingSpaceChanged && previousContentWidth == contentWidth && pane.outerHeight() == contentHeight) {
elem.width(paneWidth);
return;
}
previousContentWidth = contentWidth;
pane.css('width', '');
elem.width(paneWidth);
container.find('>.jspVerticalBar,>.jspHorizontalBar').remove().end();
}
pane.css('overflow', 'auto');
if (s.contentWidth) {
contentWidth = s.contentWidth;
} else {
contentWidth = pane[0].scrollWidth;
}
contentHeight = pane[0].scrollHeight;
pane.css('overflow', '');
percentInViewH = contentWidth / paneWidth;
percentInViewV = contentHeight / paneHeight;
isScrollableV = percentInViewV > 1;
isScrollableH = percentInViewH > 1;
//console.log(paneWidth, paneHeight, contentWidth, contentHeight, percentInViewH, percentInViewV, isScrollableH, isScrollableV);
if (!(isScrollableH || isScrollableV)) {
elem.removeClass('jspScrollable');
pane.css({
top: 0,
width: container.width() - originalPaddingTotalWidth
});
removeMousewheel();
removeFocusHandler();
removeKeyboardNav();
removeClickOnTrack();
} else {
elem.addClass('jspScrollable');
isMaintainingPositon = settings.maintainPosition && (verticalDragPosition || horizontalDragPosition);
if (isMaintainingPositon) {
lastContentX = contentPositionX();
lastContentY = contentPositionY();
}
initialiseVerticalScroll();
initialiseHorizontalScroll();
resizeScrollbars();
if (isMaintainingPositon) {
scrollToX(maintainAtRight ? (contentWidth - paneWidth ) : lastContentX, false);
scrollToY(maintainAtBottom ? (contentHeight - paneHeight) : lastContentY, false);
}
initFocusHandler();
initMousewheel();
initTouch();
if (settings.enableKeyboardNavigation) {
initKeyboardNav();
}
if (settings.clickOnTrack) {
initClickOnTrack();
}
observeHash();
if (settings.hijackInternalLinks) {
hijackInternalLinks();
}
}
if (settings.autoReinitialise && !reinitialiseInterval) {
reinitialiseInterval = setInterval(
function()
{
initialise(settings);
},
settings.autoReinitialiseDelay
);
} else if (!settings.autoReinitialise && reinitialiseInterval) {
clearInterval(reinitialiseInterval);
}
originalScrollTop && elem.scrollTop(0) && scrollToY(originalScrollTop, false);
originalScrollLeft && elem.scrollLeft(0) && scrollToX(originalScrollLeft, false);
elem.trigger('jsp-initialised', [isScrollableH || isScrollableV]);
}
function initialiseVerticalScroll()
{
if (isScrollableV) {
container.append(
$('<div class="jspVerticalBar" />').append(
$('<div class="jspCap jspCapTop" />'),
$('<div class="jspTrack" />').append(
$('<div class="jspDrag" />').append(
$('<div class="jspDragTop" />'),
$('<div class="jspDragBottom" />')
)
),
$('<div class="jspCap jspCapBottom" />')
)
);
verticalBar = container.find('>.jspVerticalBar');
verticalTrack = verticalBar.find('>.jspTrack');
verticalDrag = verticalTrack.find('>.jspDrag');
if (settings.showArrows) {
arrowUp = $('<a class="jspArrow jspArrowUp" />').bind(
'mousedown.jsp', getArrowScroll(0, -1)
).bind('click.jsp', nil);
arrowDown = $('<a class="jspArrow jspArrowDown" />').bind(
'mousedown.jsp', getArrowScroll(0, 1)
).bind('click.jsp', nil);
if (settings.arrowScrollOnHover) {
arrowUp.bind('mouseover.jsp', getArrowScroll(0, -1, arrowUp));
arrowDown.bind('mouseover.jsp', getArrowScroll(0, 1, arrowDown));
}
appendArrows(verticalTrack, settings.verticalArrowPositions, arrowUp, arrowDown);
}
verticalTrackHeight = paneHeight;
container.find('>.jspVerticalBar>.jspCap:visible,>.jspVerticalBar>.jspArrow').each(
function()
{
verticalTrackHeight -= $(this).outerHeight();
}
);
verticalDrag.hover(
function()
{
verticalDrag.addClass('jspHover');
},
function()
{
verticalDrag.removeClass('jspHover');
}
).bind(
'mousedown.jsp',
function(e)
{
// Stop IE from allowing text selection
$('html').bind('dragstart.jsp selectstart.jsp', nil);
verticalDrag.addClass('jspActive');
var startY = e.pageY - verticalDrag.position().top;
$('html').bind(
'mousemove.jsp',
function(e)
{
positionDragY(e.pageY - startY, false);
}
).bind('mouseup.jsp mouseleave.jsp', cancelDrag);
return false;
}
);
sizeVerticalScrollbar();
}
}
function sizeVerticalScrollbar()
{
verticalTrack.height(verticalTrackHeight + 'px');
verticalDragPosition = 0;
scrollbarWidth = settings.verticalGutter + verticalTrack.outerWidth();
// Make the pane thinner to allow for the vertical scrollbar
pane.width(paneWidth - scrollbarWidth - originalPaddingTotalWidth);
// Add margin to the left of the pane if scrollbars are on that side (to position
// the scrollbar on the left or right set it's left or right property in CSS)
try {
if (verticalBar.position().left === 0) {
pane.css('margin-left', scrollbarWidth + 'px');
}
} catch (err) {
}
}
function initialiseHorizontalScroll()
{
if (isScrollableH) {
container.append(
$('<div class="jspHorizontalBar" />').append(
$('<div class="jspCap jspCapLeft" />'),
$('<div class="jspTrack" />').append(
$('<div class="jspDrag" />').append(
$('<div class="jspDragLeft" />'),
$('<div class="jspDragRight" />')
)
),
$('<div class="jspCap jspCapRight" />')
)
);
horizontalBar = container.find('>.jspHorizontalBar');
horizontalTrack = horizontalBar.find('>.jspTrack');
horizontalDrag = horizontalTrack.find('>.jspDrag');
if (settings.showArrows) {
arrowLeft = $('<a class="jspArrow jspArrowLeft" />').bind(
'mousedown.jsp', getArrowScroll(-1, 0)
).bind('click.jsp', nil);
arrowRight = $('<a class="jspArrow jspArrowRight" />').bind(
'mousedown.jsp', getArrowScroll(1, 0)
).bind('click.jsp', nil);
if (settings.arrowScrollOnHover) {
arrowLeft.bind('mouseover.jsp', getArrowScroll(-1, 0, arrowLeft));
arrowRight.bind('mouseover.jsp', getArrowScroll(1, 0, arrowRight));
}
appendArrows(horizontalTrack, settings.horizontalArrowPositions, arrowLeft, arrowRight);
}
horizontalDrag.hover(
function()
{
horizontalDrag.addClass('jspHover');
},
function()
{
horizontalDrag.removeClass('jspHover');
}
).bind(
'mousedown.jsp',
function(e)
{
// Stop IE from allowing text selection
$('html').bind('dragstart.jsp selectstart.jsp', nil);
horizontalDrag.addClass('jspActive');
var startX = e.pageX - horizontalDrag.position().left;
$('html').bind(
'mousemove.jsp',
function(e)
{
positionDragX(e.pageX - startX, false);
}
).bind('mouseup.jsp mouseleave.jsp', cancelDrag);
return false;
}
);
horizontalTrackWidth = container.innerWidth();
sizeHorizontalScrollbar();
}
}
function sizeHorizontalScrollbar()
{
container.find('>.jspHorizontalBar>.jspCap:visible,>.jspHorizontalBar>.jspArrow').each(
function()
{
horizontalTrackWidth -= $(this).outerWidth();
}
);
horizontalTrack.width(horizontalTrackWidth + 'px');
horizontalDragPosition = 0;
}
function resizeScrollbars()
{
if (isScrollableH && isScrollableV) {
var horizontalTrackHeight = horizontalTrack.outerHeight(),
verticalTrackWidth = verticalTrack.outerWidth();
verticalTrackHeight -= horizontalTrackHeight;
$(horizontalBar).find('>.jspCap:visible,>.jspArrow').each(
function()
{
horizontalTrackWidth += $(this).outerWidth();
}
);
horizontalTrackWidth -= verticalTrackWidth;
paneHeight -= verticalTrackWidth;
paneWidth -= horizontalTrackHeight;
horizontalTrack.parent().append(
$('<div class="jspCorner" />').css('width', horizontalTrackHeight + 'px')
);
sizeVerticalScrollbar();
sizeHorizontalScrollbar();
}
// reflow content
if (isScrollableH) {
pane.width((container.outerWidth() - originalPaddingTotalWidth) + 'px');
}
contentHeight = pane.outerHeight();
percentInViewV = contentHeight / paneHeight;
if (isScrollableH) {
horizontalDragWidth = Math.ceil(1 / percentInViewH * horizontalTrackWidth);
if (horizontalDragWidth > settings.horizontalDragMaxWidth) {
horizontalDragWidth = settings.horizontalDragMaxWidth;
} else if (horizontalDragWidth < settings.horizontalDragMinWidth) {
horizontalDragWidth = settings.horizontalDragMinWidth;
}
horizontalDrag.width(horizontalDragWidth + 'px');
dragMaxX = horizontalTrackWidth - horizontalDragWidth;
_positionDragX(horizontalDragPosition); // To update the state for the arrow buttons
}
if (isScrollableV) {
verticalDragHeight = Math.ceil(1 / percentInViewV * verticalTrackHeight);
if (verticalDragHeight > settings.verticalDragMaxHeight) {
verticalDragHeight = settings.verticalDragMaxHeight;
} else if (verticalDragHeight < settings.verticalDragMinHeight) {
verticalDragHeight = settings.verticalDragMinHeight;
}
verticalDrag.height(verticalDragHeight + 'px');
dragMaxY = verticalTrackHeight - verticalDragHeight;
_positionDragY(verticalDragPosition); // To update the state for the arrow buttons
}
}
function appendArrows(ele, p, a1, a2)
{
var p1 = "before", p2 = "after", aTemp;
// Sniff for mac... Is there a better way to determine whether the arrows would naturally appear
// at the top or the bottom of the bar?
if (p == "os") {
p = /Mac/.test(navigator.platform) ? "after" : "split";
}
if (p == p1) {
p2 = p;
} else if (p == p2) {
p1 = p;
aTemp = a1;
a1 = a2;
a2 = aTemp;
}
ele[p1](a1)[p2](a2);
}
function getArrowScroll(dirX, dirY, ele)
{
return function()
{
arrowScroll(dirX, dirY, this, ele);
this.blur();
return false;
};
}
function arrowScroll(dirX, dirY, arrow, ele)
{
arrow = $(arrow).addClass('jspActive');
var eve,
scrollTimeout,
isFirst = true,
doScroll = function()
{
if (dirX !== 0) {
jsp.scrollByX(dirX * settings.arrowButtonSpeed);
}
if (dirY !== 0) {
jsp.scrollByY(dirY * settings.arrowButtonSpeed);
}
scrollTimeout = setTimeout(doScroll, isFirst ? settings.initialDelay : settings.arrowRepeatFreq);
isFirst = false;
};
doScroll();
eve = ele ? 'mouseout.jsp' : 'mouseup.jsp';
ele = ele || $('html');
ele.bind(
eve,
function()
{
arrow.removeClass('jspActive');
scrollTimeout && clearTimeout(scrollTimeout);
scrollTimeout = null;
ele.unbind(eve);
}
);
}
function initClickOnTrack()
{
removeClickOnTrack();
if (isScrollableV) {
verticalTrack.bind(
'mousedown.jsp',
function(e)
{
if (e.originalTarget === undefined || e.originalTarget == e.currentTarget) {
var clickedTrack = $(this),
offset = clickedTrack.offset(),
direction = e.pageY - offset.top - verticalDragPosition,
scrollTimeout,
isFirst = true,
doScroll = function()
{
var offset = clickedTrack.offset(),
pos = e.pageY - offset.top - verticalDragHeight / 2,
contentDragY = paneHeight * settings.scrollPagePercent,
dragY = dragMaxY * contentDragY / (contentHeight - paneHeight);
if (direction < 0) {
if (verticalDragPosition - dragY > pos) {
jsp.scrollByY(-contentDragY);
} else {
positionDragY(pos);
}
} else if (direction > 0) {
if (verticalDragPosition + dragY < pos) {
jsp.scrollByY(contentDragY);
} else {
positionDragY(pos);
}
} else {
cancelClick();
return;
}
scrollTimeout = setTimeout(doScroll, isFirst ? settings.initialDelay : settings.trackClickRepeatFreq);
isFirst = false;
},
cancelClick = function()
{
scrollTimeout && clearTimeout(scrollTimeout);
scrollTimeout = null;
$(document).unbind('mouseup.jsp', cancelClick);
};
doScroll();
$(document).bind('mouseup.jsp', cancelClick);
return false;
}
}
);
}
if (isScrollableH) {
horizontalTrack.bind(
'mousedown.jsp',
function(e)
{
if (e.originalTarget === undefined || e.originalTarget == e.currentTarget) {
var clickedTrack = $(this),
offset = clickedTrack.offset(),
direction = e.pageX - offset.left - horizontalDragPosition,
scrollTimeout,
isFirst = true,
doScroll = function()
{
var offset = clickedTrack.offset(),
pos = e.pageX - offset.left - horizontalDragWidth / 2,
contentDragX = paneWidth * settings.scrollPagePercent,
dragX = dragMaxX * contentDragX / (contentWidth - paneWidth);
if (direction < 0) {
if (horizontalDragPosition - dragX > pos) {
jsp.scrollByX(-contentDragX);
} else {
positionDragX(pos);
}
} else if (direction > 0) {
if (horizontalDragPosition + dragX < pos) {
jsp.scrollByX(contentDragX);
} else {
positionDragX(pos);
}
} else {
cancelClick();
return;
}
scrollTimeout = setTimeout(doScroll, isFirst ? settings.initialDelay : settings.trackClickRepeatFreq);
isFirst = false;
},
cancelClick = function()
{
scrollTimeout && clearTimeout(scrollTimeout);
scrollTimeout = null;
$(document).unbind('mouseup.jsp', cancelClick);
};
doScroll();
$(document).bind('mouseup.jsp', cancelClick);
return false;
}
}
);
}
}
function removeClickOnTrack()
{
if (horizontalTrack) {
horizontalTrack.unbind('mousedown.jsp');
}
if (verticalTrack) {
verticalTrack.unbind('mousedown.jsp');
}
}
function cancelDrag()
{
$('html').unbind('dragstart.jsp selectstart.jsp mousemove.jsp mouseup.jsp mouseleave.jsp');
if (verticalDrag) {
verticalDrag.removeClass('jspActive');
}
if (horizontalDrag) {
horizontalDrag.removeClass('jspActive');
}
}
function positionDragY(destY, animate)
{
if (!isScrollableV) {
return;
}
if (destY < 0) {
destY = 0;
} else if (destY > dragMaxY) {
destY = dragMaxY;
}
// can't just check if(animate) because false is a valid value that could be passed in...
if (animate === undefined) {
animate = settings.animateScroll;
}
if (animate) {
jsp.animate(verticalDrag, 'top', destY, _positionDragY);
} else {
verticalDrag.css('top', destY);
_positionDragY(destY);
}
}
function _positionDragY(destY)
{
if (destY === undefined) {
destY = verticalDrag.position().top;
}
container.scrollTop(0);
verticalDragPosition = destY;
var isAtTop = verticalDragPosition === 0,
isAtBottom = verticalDragPosition == dragMaxY,
percentScrolled = destY/ dragMaxY,
destTop = -percentScrolled * (contentHeight - paneHeight);
if (wasAtTop != isAtTop || wasAtBottom != isAtBottom) {
wasAtTop = isAtTop;
wasAtBottom = isAtBottom;
elem.trigger('jsp-arrow-change', [wasAtTop, wasAtBottom, wasAtLeft, wasAtRight]);
}
updateVerticalArrows(isAtTop, isAtBottom);
pane.css('top', destTop);
elem.trigger('jsp-scroll-y', [-destTop, isAtTop, isAtBottom]).trigger('scroll');
}
function positionDragX(destX, animate)
{
if (!isScrollableH) {
return;
}
if (destX < 0) {
destX = 0;
} else if (destX > dragMaxX) {
destX = dragMaxX;
}
if (animate === undefined) {
animate = settings.animateScroll;
}
if (animate) {
jsp.animate(horizontalDrag, 'left', destX, _positionDragX);
} else {
horizontalDrag.css('left', destX);
_positionDragX(destX);
}
}
function _positionDragX(destX)
{
if (destX === undefined) {
destX = horizontalDrag.position().left;
}
container.scrollTop(0);
horizontalDragPosition = destX;
var isAtLeft = horizontalDragPosition === 0,
isAtRight = horizontalDragPosition == dragMaxX,
percentScrolled = destX / dragMaxX,
destLeft = -percentScrolled * (contentWidth - paneWidth);
if (wasAtLeft != isAtLeft || wasAtRight != isAtRight) {
wasAtLeft = isAtLeft;
wasAtRight = isAtRight;
elem.trigger('jsp-arrow-change', [wasAtTop, wasAtBottom, wasAtLeft, wasAtRight]);
}
updateHorizontalArrows(isAtLeft, isAtRight);
pane.css('left', destLeft);
elem.trigger('jsp-scroll-x', [-destLeft, isAtLeft, isAtRight]).trigger('scroll');
}
function updateVerticalArrows(isAtTop, isAtBottom)
{
if (settings.showArrows) {
arrowUp[isAtTop ? 'addClass' : 'removeClass']('jspDisabled');
arrowDown[isAtBottom ? 'addClass' : 'removeClass']('jspDisabled');
}
}
function updateHorizontalArrows(isAtLeft, isAtRight)
{
if (settings.showArrows) {
arrowLeft[isAtLeft ? 'addClass' : 'removeClass']('jspDisabled');
arrowRight[isAtRight ? 'addClass' : 'removeClass']('jspDisabled');
}
}
function scrollToY(destY, animate)
{
var percentScrolled = destY / (contentHeight - paneHeight);
positionDragY(percentScrolled * dragMaxY, animate);
}
function scrollToX(destX, animate)
{
var percentScrolled = destX / (contentWidth - paneWidth);
positionDragX(percentScrolled * dragMaxX, animate);
}
function scrollToElement(ele, stickToTop, animate)
{
var e, eleHeight, eleWidth, eleTop = 0, eleLeft = 0, viewportTop, viewportLeft, maxVisibleEleTop, maxVisibleEleLeft, destY, destX;
// Legal hash values aren't necessarily legal jQuery selectors so we need to catch any
// errors from the lookup...
try {
e = $(ele);
} catch (err) {
return;
}
eleHeight = e.outerHeight();
eleWidth= e.outerWidth();
container.scrollTop(0);
container.scrollLeft(0);
// loop through parents adding the offset top of any elements that are relatively positioned between
// the focused element and the jspPane so we can get the true distance from the top
// of the focused element to the top of the scrollpane...
while (!e.is('.jspPane')) {
eleTop += e.position().top;
eleLeft += e.position().left;
e = e.offsetParent();
if (/^body|html$/i.test(e[0].nodeName)) {
// we ended up too high in the document structure. Quit!
return;
}
}
viewportTop = contentPositionY();
maxVisibleEleTop = viewportTop + paneHeight;
if (eleTop < viewportTop || stickToTop) { // element is above viewport
destY = eleTop - settings.verticalGutter;
} else if (eleTop + eleHeight > maxVisibleEleTop) { // element is below viewport
destY = eleTop - paneHeight + eleHeight + settings.verticalGutter;
}
if (destY) {
scrollToY(destY, animate);
}
viewportLeft = contentPositionX();
maxVisibleEleLeft = viewportLeft + paneWidth;
if (eleLeft < viewportLeft || stickToTop) { // element is to the left of viewport
destX = eleLeft - settings.horizontalGutter;
} else if (eleLeft + eleWidth > maxVisibleEleLeft) { // element is to the right viewport
destX = eleLeft - paneWidth + eleWidth + settings.horizontalGutter;
}
if (destX) {
scrollToX(destX, animate);
}
}
function contentPositionX()
{
return -pane.position().left;
}
function contentPositionY()
{
return -pane.position().top;
}
function isCloseToBottom()
{
var scrollableHeight = contentHeight - paneHeight;
return (scrollableHeight > 20) && (scrollableHeight - contentPositionY() < 10);
}
function isCloseToRight()
{
var scrollableWidth = contentWidth - paneWidth;
return (scrollableWidth > 20) && (scrollableWidth - contentPositionX() < 10);
}
function initMousewheel()
{
container.unbind(mwEvent).bind(
mwEvent,
function (event, delta, deltaX, deltaY) {
var dX = horizontalDragPosition, dY = verticalDragPosition;
jsp.scrollBy(deltaX * settings.mouseWheelSpeed, -deltaY * settings.mouseWheelSpeed, false);
// return true if there was no movement so rest of screen can scroll
return dX == horizontalDragPosition && dY == verticalDragPosition;
}
);
}
function removeMousewheel()
{
container.unbind(mwEvent);
}
function nil()
{
return false;
}
function initFocusHandler()
{
pane.find(':input,a').unbind('focus.jsp').bind(
'focus.jsp',
function(e)
{
scrollToElement(e.target, false);
}
);
}
function removeFocusHandler()
{
pane.find(':input,a').unbind('focus.jsp');
}
function initKeyboardNav()
{
var keyDown, elementHasScrolled, validParents = [];
isScrollableH && validParents.push(horizontalBar[0]);
isScrollableV && validParents.push(verticalBar[0]);
// IE also focuses elements that don't have tabindex set.
pane.focus(
function()
{
elem.focus();
}
);
elem.attr('tabindex', 0)
.unbind('keydown.jsp keypress.jsp')
.bind(
'keydown.jsp',
function(e)
{
if (e.target !== this && !(validParents.length && $(e.target).closest(validParents).length)){
return;
}
var dX = horizontalDragPosition, dY = verticalDragPosition;
switch(e.keyCode) {
case 40: // down
case 38: // up
case 34: // page down
case 32: // space
case 33: // page up
case 39: // right
case 37: // left
keyDown = e.keyCode;
keyDownHandler();
break;
case 35: // end
scrollToY(contentHeight - paneHeight);
keyDown = null;
break;
case 36: // home
scrollToY(0);
keyDown = null;
break;
}
elementHasScrolled = e.keyCode == keyDown && dX != horizontalDragPosition || dY != verticalDragPosition;
return !elementHasScrolled;
}
).bind(
'keypress.jsp', // For FF/ OSX so that we can cancel the repeat key presses if the JSP scrolls...
function(e)
{
if (e.keyCode == keyDown) {
keyDownHandler();
}
return !elementHasScrolled;
}
);
if (settings.hideFocus) {
elem.css('outline', 'none');
if ('hideFocus' in container[0]){
elem.attr('hideFocus', true);
}
} else {
elem.css('outline', '');
if ('hideFocus' in container[0]){
elem.attr('hideFocus', false);
}
}
function keyDownHandler()
{
var dX = horizontalDragPosition, dY = verticalDragPosition;
switch(keyDown) {
case 40: // down
jsp.scrollByY(settings.keyboardSpeed, false);
break;
case 38: // up
jsp.scrollByY(-settings.keyboardSpeed, false);
break;
case 34: // page down
case 32: // space
jsp.scrollByY(paneHeight * settings.scrollPagePercent, false);
break;
case 33: // page up
jsp.scrollByY(-paneHeight * settings.scrollPagePercent, false);
break;
case 39: // right
jsp.scrollByX(settings.keyboardSpeed, false);
break;
case 37: // left
jsp.scrollByX(-settings.keyboardSpeed, false);
break;
}
elementHasScrolled = dX != horizontalDragPosition || dY != verticalDragPosition;
return elementHasScrolled;
}
}
function removeKeyboardNav()
{
elem.attr('tabindex', '-1')
.removeAttr('tabindex')
.unbind('keydown.jsp keypress.jsp');
}
function observeHash()
{
if (location.hash && location.hash.length > 1) {
var e,
retryInt,
hash = escape(location.hash.substr(1)) // hash must be escaped to prevent XSS
;
try {
e = $('#' + hash + ', a[name="' + hash + '"]');
} catch (err) {
return;
}
if (e.length && pane.find(hash)) {
// nasty workaround but it appears to take a little while before the hash has done its thing
// to the rendered page so we just wait until the container's scrollTop has been messed up.
if (container.scrollTop() === 0) {
retryInt = setInterval(
function()
{
if (container.scrollTop() > 0) {
scrollToElement(e, true);
$(document).scrollTop(container.position().top);
clearInterval(retryInt);
}
},
50
);
} else {
scrollToElement(e, true);
$(document).scrollTop(container.position().top);
}
}
}
}
function hijackInternalLinks()
{
// only register the link handler once
if ($(document.body).data('jspHijack')) {
return;
}
// remember that the handler was bound
$(document.body).data('jspHijack', true);
// use live handler to also capture newly created links
$(document.body).delegate('a[href*=#]', 'click', function(event) {
// does the link point to the same page?
// this also takes care of cases with a <base>-Tag or Links not starting with the hash #
// e.g. <a href="index.html#test"> when the current url already is index.html
var href = this.href.substr(0, this.href.indexOf('#')),
locationHref = location.href,
hash,
element,
container,
jsp,
scrollTop,
elementTop;
if (location.href.indexOf('#') !== -1) {
locationHref = location.href.substr(0, location.href.indexOf('#'));
}
if (href !== locationHref) {
// the link points to another page
return;
}
// check if jScrollPane should handle this click event
hash = escape(this.href.substr(this.href.indexOf('#') + 1));
// find the element on the page
element;
try {
element = $('#' + hash + ', a[name="' + hash + '"]');
} catch (e) {
// hash is not a valid jQuery identifier
return;
}
if (!element.length) {
// this link does not point to an element on this page
return;
}
container = element.closest('.jspScrollable');
jsp = container.data('jsp');
// jsp might be another jsp instance than the one, that bound this event
// remember: this event is only bound once for all instances.
jsp.scrollToElement(element, true);
if (container[0].scrollIntoView) {
// also scroll to the top of the container (if it is not visible)
scrollTop = $(window).scrollTop();
elementTop = element.offset().top;
if (elementTop < scrollTop || elementTop > scrollTop + $(window).height()) {
container[0].scrollIntoView();
}
}
// jsp handled this event, prevent the browser default (scrolling :P)
event.preventDefault();
});
}
// Init touch on iPad, iPhone, iPod, Android
function initTouch()
{
var startX,
startY,
touchStartX,
touchStartY,
moved,
moving = false;
container.unbind('touchstart.jsp touchmove.jsp touchend.jsp click.jsp-touchclick').bind(
'touchstart.jsp',
function(e)
{
var touch = e.originalEvent.touches[0];
startX = contentPositionX();
startY = contentPositionY();
touchStartX = touch.pageX;
touchStartY = touch.pageY;
moved = false;
moving = true;
}
).bind(
'touchmove.jsp',
function(ev)
{
if(!moving) {
return;
}
var touchPos = ev.originalEvent.touches[0],
dX = horizontalDragPosition, dY = verticalDragPosition;
jsp.scrollTo(startX + touchStartX - touchPos.pageX, startY + touchStartY - touchPos.pageY);
moved = moved || Math.abs(touchStartX - touchPos.pageX) > 5 || Math.abs(touchStartY - touchPos.pageY) > 5;
// return true if there was no movement so rest of screen can scroll
return dX == horizontalDragPosition && dY == verticalDragPosition;
}
).bind(
'touchend.jsp',
function(e)
{
moving = false;
/*if(moved) {
return false;
}*/
}
).bind(
'click.jsp-touchclick',
function(e)
{
if(moved) {
moved = false;
return false;
}
}
);
}
function destroy(){
var currentY = contentPositionY(),
currentX = contentPositionX();
elem.removeClass('jspScrollable').unbind('.jsp');
elem.replaceWith(originalElement.append(pane.children()));
originalElement.scrollTop(currentY);
originalElement.scrollLeft(currentX);
// clear reinitialize timer if active
if (reinitialiseInterval) {
clearInterval(reinitialiseInterval);
}
}
// Public API
$.extend(
jsp,
{
// Reinitialises the scroll pane (if it's internal dimensions have changed since the last time it
// was initialised). The settings object which is passed in will override any settings from the
// previous time it was initialised - if you don't pass any settings then the ones from the previous
// initialisation will be used.
reinitialise: function(s)
{
s = $.extend({}, settings, s);
initialise(s);
},
// Scrolls the specified element (a jQuery object, DOM node or jQuery selector string) into view so
// that it can be seen within the viewport. If stickToTop is true then the element will appear at
// the top of the viewport, if it is false then the viewport will scroll as little as possible to
// show the element. You can also specify if you want animation to occur. If you don't provide this
// argument then the animateScroll value from the settings object is used instead.
scrollToElement: function(ele, stickToTop, animate)
{
scrollToElement(ele, stickToTop, animate);
},
// Scrolls the pane so that the specified co-ordinates within the content are at the top left
// of the viewport. animate is optional and if not passed then the value of animateScroll from
// the settings object this jScrollPane was initialised with is used.
scrollTo: function(destX, destY, animate)
{
scrollToX(destX, animate);
scrollToY(destY, animate);
},
// Scrolls the pane so that the specified co-ordinate within the content is at the left of the
// viewport. animate is optional and if not passed then the value of animateScroll from the settings
// object this jScrollPane was initialised with is used.
scrollToX: function(destX, animate)
{
scrollToX(destX, animate);
},
// Scrolls the pane so that the specified co-ordinate within the content is at the top of the
// viewport. animate is optional and if not passed then the value of animateScroll from the settings
// object this jScrollPane was initialised with is used.
scrollToY: function(destY, animate)
{
scrollToY(destY, animate);
},
// Scrolls the pane to the specified percentage of its maximum horizontal scroll position. animate
// is optional and if not passed then the value of animateScroll from the settings object this
// jScrollPane was initialised with is used.
scrollToPercentX: function(destPercentX, animate)
{
scrollToX(destPercentX * (contentWidth - paneWidth), animate);
},
// Scrolls the pane to the specified percentage of its maximum vertical scroll position. animate
// is optional and if not passed then the value of animateScroll from the settings object this
// jScrollPane was initialised with is used.
scrollToPercentY: function(destPercentY, animate)
{
scrollToY(destPercentY * (contentHeight - paneHeight), animate);
},
// Scrolls the pane by the specified amount of pixels. animate is optional and if not passed then
// the value of animateScroll from the settings object this jScrollPane was initialised with is used.
scrollBy: function(deltaX, deltaY, animate)
{
jsp.scrollByX(deltaX, animate);
jsp.scrollByY(deltaY, animate);
},
// Scrolls the pane by the specified amount of pixels. animate is optional and if not passed then
// the value of animateScroll from the settings object this jScrollPane was initialised with is used.
scrollByX: function(deltaX, animate)
{
var destX = contentPositionX() + Math[deltaX<0 ? 'floor' : 'ceil'](deltaX),
percentScrolled = destX / (contentWidth - paneWidth);
positionDragX(percentScrolled * dragMaxX, animate);
},
// Scrolls the pane by the specified amount of pixels. animate is optional and if not passed then
// the value of animateScroll from the settings object this jScrollPane was initialised with is used.
scrollByY: function(deltaY, animate)
{
var destY = contentPositionY() + Math[deltaY<0 ? 'floor' : 'ceil'](deltaY),
percentScrolled = destY / (contentHeight - paneHeight);
positionDragY(percentScrolled * dragMaxY, animate);
},
// Positions the horizontal drag at the specified x position (and updates the viewport to reflect
// this). animate is optional and if not passed then the value of animateScroll from the settings
// object this jScrollPane was initialised with is used.
positionDragX: function(x, animate)
{
positionDragX(x, animate);
},
// Positions the vertical drag at the specified y position (and updates the viewport to reflect
// this). animate is optional and if not passed then the value of animateScroll from the settings
// object this jScrollPane was initialised with is used.
positionDragY: function(y, animate)
{
positionDragY(y, animate);
},
// This method is called when jScrollPane is trying to animate to a new position. You can override
// it if you want to provide advanced animation functionality. It is passed the following arguments:
// * ele - the element whose position is being animated
// * prop - the property that is being animated
// * value - the value it's being animated to
// * stepCallback - a function that you must execute each time you update the value of the property
// You can use the default implementation (below) as a starting point for your own implementation.
animate: function(ele, prop, value, stepCallback)
{
var params = {};
params[prop] = value;
ele.animate(
params,
{
'duration' : settings.animateDuration,
'easing' : settings.animateEase,
'queue' : false,
'step' : stepCallback
}
);
},
// Returns the current x position of the viewport with regards to the content pane.
getContentPositionX: function()
{
return contentPositionX();
},
// Returns the current y position of the viewport with regards to the content pane.
getContentPositionY: function()
{
return contentPositionY();
},
// Returns the width of the content within the scroll pane.
getContentWidth: function()
{
return contentWidth;
},
// Returns the height of the content within the scroll pane.
getContentHeight: function()
{
return contentHeight;
},
// Returns the horizontal position of the viewport within the pane content.
getPercentScrolledX: function()
{
return contentPositionX() / (contentWidth - paneWidth);
},
// Returns the vertical position of the viewport within the pane content.
getPercentScrolledY: function()
{
return contentPositionY() / (contentHeight - paneHeight);
},
// Returns whether or not this scrollpane has a horizontal scrollbar.
getIsScrollableH: function()
{
return isScrollableH;
},
// Returns whether or not this scrollpane has a vertical scrollbar.
getIsScrollableV: function()
{
return isScrollableV;
},
// Gets a reference to the content pane. It is important that you use this method if you want to
// edit the content of your jScrollPane as if you access the element directly then you may have some
// problems (as your original element has had additional elements for the scrollbars etc added into
// it).
getContentPane: function()
{
return pane;
},
// Scrolls this jScrollPane down as far as it can currently scroll. If animate isn't passed then the
// animateScroll value from settings is used instead.
scrollToBottom: function(animate)
{
positionDragY(dragMaxY, animate);
},
// Hijacks the links on the page which link to content inside the scrollpane. If you have changed
// the content of your page (e.g. via AJAX) and want to make sure any new anchor links to the
// contents of your scroll pane will work then call this function.
hijackInternalLinks: $.noop,
// Removes the jScrollPane and returns the page to the state it was in before jScrollPane was
// initialised.
destroy: function()
{
destroy();
}
}
);
initialise(s);
}
|
`fail` will execute when the request fails
|
JScrollPane
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function initialise(s)
{
var /*firstChild, lastChild, */isMaintainingPositon, lastContentX, lastContentY,
hasContainingSpaceChanged, originalScrollTop, originalScrollLeft,
maintainAtBottom = false, maintainAtRight = false;
settings = s;
if (pane === undefined) {
originalScrollTop = elem.scrollTop();
originalScrollLeft = elem.scrollLeft();
elem.css(
{
overflow: 'hidden',
padding: 0
}
);
// TODO: Deal with where width/ height is 0 as it probably means the element is hidden and we should
// come back to it later and check once it is unhidden...
paneWidth = elem.innerWidth() + originalPaddingTotalWidth;
paneHeight = elem.innerHeight();
elem.width(paneWidth);
pane = $('<div class="jspPane" />').css('padding', originalPadding).append(elem.children());
container = $('<div class="jspContainer" />')
.css({
'width': paneWidth + 'px',
'height': paneHeight + 'px'
}
).append(pane).appendTo(elem);
/*
// Move any margins from the first and last children up to the container so they can still
// collapse with neighbouring elements as they would before jScrollPane
firstChild = pane.find(':first-child');
lastChild = pane.find(':last-child');
elem.css(
{
'margin-top': firstChild.css('margin-top'),
'margin-bottom': lastChild.css('margin-bottom')
}
);
firstChild.css('margin-top', 0);
lastChild.css('margin-bottom', 0);
*/
} else {
elem.css('width', '');
maintainAtBottom = settings.stickToBottom && isCloseToBottom();
maintainAtRight = settings.stickToRight && isCloseToRight();
hasContainingSpaceChanged = elem.innerWidth() + originalPaddingTotalWidth != paneWidth || elem.outerHeight() != paneHeight;
if (hasContainingSpaceChanged) {
paneWidth = elem.innerWidth() + originalPaddingTotalWidth;
paneHeight = elem.innerHeight();
container.css({
width: paneWidth + 'px',
height: paneHeight + 'px'
});
}
// If nothing changed since last check...
if (!hasContainingSpaceChanged && previousContentWidth == contentWidth && pane.outerHeight() == contentHeight) {
elem.width(paneWidth);
return;
}
previousContentWidth = contentWidth;
pane.css('width', '');
elem.width(paneWidth);
container.find('>.jspVerticalBar,>.jspHorizontalBar').remove().end();
}
pane.css('overflow', 'auto');
if (s.contentWidth) {
contentWidth = s.contentWidth;
} else {
contentWidth = pane[0].scrollWidth;
}
contentHeight = pane[0].scrollHeight;
pane.css('overflow', '');
percentInViewH = contentWidth / paneWidth;
percentInViewV = contentHeight / paneHeight;
isScrollableV = percentInViewV > 1;
isScrollableH = percentInViewH > 1;
//console.log(paneWidth, paneHeight, contentWidth, contentHeight, percentInViewH, percentInViewV, isScrollableH, isScrollableV);
if (!(isScrollableH || isScrollableV)) {
elem.removeClass('jspScrollable');
pane.css({
top: 0,
width: container.width() - originalPaddingTotalWidth
});
removeMousewheel();
removeFocusHandler();
removeKeyboardNav();
removeClickOnTrack();
} else {
elem.addClass('jspScrollable');
isMaintainingPositon = settings.maintainPosition && (verticalDragPosition || horizontalDragPosition);
if (isMaintainingPositon) {
lastContentX = contentPositionX();
lastContentY = contentPositionY();
}
initialiseVerticalScroll();
initialiseHorizontalScroll();
resizeScrollbars();
if (isMaintainingPositon) {
scrollToX(maintainAtRight ? (contentWidth - paneWidth ) : lastContentX, false);
scrollToY(maintainAtBottom ? (contentHeight - paneHeight) : lastContentY, false);
}
initFocusHandler();
initMousewheel();
initTouch();
if (settings.enableKeyboardNavigation) {
initKeyboardNav();
}
if (settings.clickOnTrack) {
initClickOnTrack();
}
observeHash();
if (settings.hijackInternalLinks) {
hijackInternalLinks();
}
}
if (settings.autoReinitialise && !reinitialiseInterval) {
reinitialiseInterval = setInterval(
function()
{
initialise(settings);
},
settings.autoReinitialiseDelay
);
} else if (!settings.autoReinitialise && reinitialiseInterval) {
clearInterval(reinitialiseInterval);
}
originalScrollTop && elem.scrollTop(0) && scrollToY(originalScrollTop, false);
originalScrollLeft && elem.scrollLeft(0) && scrollToX(originalScrollLeft, false);
elem.trigger('jsp-initialised', [isScrollableH || isScrollableV]);
}
|
`fail` will execute when the request fails
|
initialise
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function initialiseVerticalScroll()
{
if (isScrollableV) {
container.append(
$('<div class="jspVerticalBar" />').append(
$('<div class="jspCap jspCapTop" />'),
$('<div class="jspTrack" />').append(
$('<div class="jspDrag" />').append(
$('<div class="jspDragTop" />'),
$('<div class="jspDragBottom" />')
)
),
$('<div class="jspCap jspCapBottom" />')
)
);
verticalBar = container.find('>.jspVerticalBar');
verticalTrack = verticalBar.find('>.jspTrack');
verticalDrag = verticalTrack.find('>.jspDrag');
if (settings.showArrows) {
arrowUp = $('<a class="jspArrow jspArrowUp" />').bind(
'mousedown.jsp', getArrowScroll(0, -1)
).bind('click.jsp', nil);
arrowDown = $('<a class="jspArrow jspArrowDown" />').bind(
'mousedown.jsp', getArrowScroll(0, 1)
).bind('click.jsp', nil);
if (settings.arrowScrollOnHover) {
arrowUp.bind('mouseover.jsp', getArrowScroll(0, -1, arrowUp));
arrowDown.bind('mouseover.jsp', getArrowScroll(0, 1, arrowDown));
}
appendArrows(verticalTrack, settings.verticalArrowPositions, arrowUp, arrowDown);
}
verticalTrackHeight = paneHeight;
container.find('>.jspVerticalBar>.jspCap:visible,>.jspVerticalBar>.jspArrow').each(
function()
{
verticalTrackHeight -= $(this).outerHeight();
}
);
verticalDrag.hover(
function()
{
verticalDrag.addClass('jspHover');
},
function()
{
verticalDrag.removeClass('jspHover');
}
).bind(
'mousedown.jsp',
function(e)
{
// Stop IE from allowing text selection
$('html').bind('dragstart.jsp selectstart.jsp', nil);
verticalDrag.addClass('jspActive');
var startY = e.pageY - verticalDrag.position().top;
$('html').bind(
'mousemove.jsp',
function(e)
{
positionDragY(e.pageY - startY, false);
}
).bind('mouseup.jsp mouseleave.jsp', cancelDrag);
return false;
}
);
sizeVerticalScrollbar();
}
}
|
`fail` will execute when the request fails
|
initialiseVerticalScroll
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function sizeVerticalScrollbar()
{
verticalTrack.height(verticalTrackHeight + 'px');
verticalDragPosition = 0;
scrollbarWidth = settings.verticalGutter + verticalTrack.outerWidth();
// Make the pane thinner to allow for the vertical scrollbar
pane.width(paneWidth - scrollbarWidth - originalPaddingTotalWidth);
// Add margin to the left of the pane if scrollbars are on that side (to position
// the scrollbar on the left or right set it's left or right property in CSS)
try {
if (verticalBar.position().left === 0) {
pane.css('margin-left', scrollbarWidth + 'px');
}
} catch (err) {
}
}
|
`fail` will execute when the request fails
|
sizeVerticalScrollbar
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function initialiseHorizontalScroll()
{
if (isScrollableH) {
container.append(
$('<div class="jspHorizontalBar" />').append(
$('<div class="jspCap jspCapLeft" />'),
$('<div class="jspTrack" />').append(
$('<div class="jspDrag" />').append(
$('<div class="jspDragLeft" />'),
$('<div class="jspDragRight" />')
)
),
$('<div class="jspCap jspCapRight" />')
)
);
horizontalBar = container.find('>.jspHorizontalBar');
horizontalTrack = horizontalBar.find('>.jspTrack');
horizontalDrag = horizontalTrack.find('>.jspDrag');
if (settings.showArrows) {
arrowLeft = $('<a class="jspArrow jspArrowLeft" />').bind(
'mousedown.jsp', getArrowScroll(-1, 0)
).bind('click.jsp', nil);
arrowRight = $('<a class="jspArrow jspArrowRight" />').bind(
'mousedown.jsp', getArrowScroll(1, 0)
).bind('click.jsp', nil);
if (settings.arrowScrollOnHover) {
arrowLeft.bind('mouseover.jsp', getArrowScroll(-1, 0, arrowLeft));
arrowRight.bind('mouseover.jsp', getArrowScroll(1, 0, arrowRight));
}
appendArrows(horizontalTrack, settings.horizontalArrowPositions, arrowLeft, arrowRight);
}
horizontalDrag.hover(
function()
{
horizontalDrag.addClass('jspHover');
},
function()
{
horizontalDrag.removeClass('jspHover');
}
).bind(
'mousedown.jsp',
function(e)
{
// Stop IE from allowing text selection
$('html').bind('dragstart.jsp selectstart.jsp', nil);
horizontalDrag.addClass('jspActive');
var startX = e.pageX - horizontalDrag.position().left;
$('html').bind(
'mousemove.jsp',
function(e)
{
positionDragX(e.pageX - startX, false);
}
).bind('mouseup.jsp mouseleave.jsp', cancelDrag);
return false;
}
);
horizontalTrackWidth = container.innerWidth();
sizeHorizontalScrollbar();
}
}
|
`fail` will execute when the request fails
|
initialiseHorizontalScroll
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function sizeHorizontalScrollbar()
{
container.find('>.jspHorizontalBar>.jspCap:visible,>.jspHorizontalBar>.jspArrow').each(
function()
{
horizontalTrackWidth -= $(this).outerWidth();
}
);
horizontalTrack.width(horizontalTrackWidth + 'px');
horizontalDragPosition = 0;
}
|
`fail` will execute when the request fails
|
sizeHorizontalScrollbar
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function resizeScrollbars()
{
if (isScrollableH && isScrollableV) {
var horizontalTrackHeight = horizontalTrack.outerHeight(),
verticalTrackWidth = verticalTrack.outerWidth();
verticalTrackHeight -= horizontalTrackHeight;
$(horizontalBar).find('>.jspCap:visible,>.jspArrow').each(
function()
{
horizontalTrackWidth += $(this).outerWidth();
}
);
horizontalTrackWidth -= verticalTrackWidth;
paneHeight -= verticalTrackWidth;
paneWidth -= horizontalTrackHeight;
horizontalTrack.parent().append(
$('<div class="jspCorner" />').css('width', horizontalTrackHeight + 'px')
);
sizeVerticalScrollbar();
sizeHorizontalScrollbar();
}
// reflow content
if (isScrollableH) {
pane.width((container.outerWidth() - originalPaddingTotalWidth) + 'px');
}
contentHeight = pane.outerHeight();
percentInViewV = contentHeight / paneHeight;
if (isScrollableH) {
horizontalDragWidth = Math.ceil(1 / percentInViewH * horizontalTrackWidth);
if (horizontalDragWidth > settings.horizontalDragMaxWidth) {
horizontalDragWidth = settings.horizontalDragMaxWidth;
} else if (horizontalDragWidth < settings.horizontalDragMinWidth) {
horizontalDragWidth = settings.horizontalDragMinWidth;
}
horizontalDrag.width(horizontalDragWidth + 'px');
dragMaxX = horizontalTrackWidth - horizontalDragWidth;
_positionDragX(horizontalDragPosition); // To update the state for the arrow buttons
}
if (isScrollableV) {
verticalDragHeight = Math.ceil(1 / percentInViewV * verticalTrackHeight);
if (verticalDragHeight > settings.verticalDragMaxHeight) {
verticalDragHeight = settings.verticalDragMaxHeight;
} else if (verticalDragHeight < settings.verticalDragMinHeight) {
verticalDragHeight = settings.verticalDragMinHeight;
}
verticalDrag.height(verticalDragHeight + 'px');
dragMaxY = verticalTrackHeight - verticalDragHeight;
_positionDragY(verticalDragPosition); // To update the state for the arrow buttons
}
}
|
`fail` will execute when the request fails
|
resizeScrollbars
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function appendArrows(ele, p, a1, a2)
{
var p1 = "before", p2 = "after", aTemp;
// Sniff for mac... Is there a better way to determine whether the arrows would naturally appear
// at the top or the bottom of the bar?
if (p == "os") {
p = /Mac/.test(navigator.platform) ? "after" : "split";
}
if (p == p1) {
p2 = p;
} else if (p == p2) {
p1 = p;
aTemp = a1;
a1 = a2;
a2 = aTemp;
}
ele[p1](a1)[p2](a2);
}
|
`fail` will execute when the request fails
|
appendArrows
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function getArrowScroll(dirX, dirY, ele)
{
return function()
{
arrowScroll(dirX, dirY, this, ele);
this.blur();
return false;
};
}
|
`fail` will execute when the request fails
|
getArrowScroll
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function arrowScroll(dirX, dirY, arrow, ele)
{
arrow = $(arrow).addClass('jspActive');
var eve,
scrollTimeout,
isFirst = true,
doScroll = function()
{
if (dirX !== 0) {
jsp.scrollByX(dirX * settings.arrowButtonSpeed);
}
if (dirY !== 0) {
jsp.scrollByY(dirY * settings.arrowButtonSpeed);
}
scrollTimeout = setTimeout(doScroll, isFirst ? settings.initialDelay : settings.arrowRepeatFreq);
isFirst = false;
};
doScroll();
eve = ele ? 'mouseout.jsp' : 'mouseup.jsp';
ele = ele || $('html');
ele.bind(
eve,
function()
{
arrow.removeClass('jspActive');
scrollTimeout && clearTimeout(scrollTimeout);
scrollTimeout = null;
ele.unbind(eve);
}
);
}
|
`fail` will execute when the request fails
|
arrowScroll
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
doScroll = function()
{
if (dirX !== 0) {
jsp.scrollByX(dirX * settings.arrowButtonSpeed);
}
if (dirY !== 0) {
jsp.scrollByY(dirY * settings.arrowButtonSpeed);
}
scrollTimeout = setTimeout(doScroll, isFirst ? settings.initialDelay : settings.arrowRepeatFreq);
isFirst = false;
}
|
`fail` will execute when the request fails
|
doScroll
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function initClickOnTrack()
{
removeClickOnTrack();
if (isScrollableV) {
verticalTrack.bind(
'mousedown.jsp',
function(e)
{
if (e.originalTarget === undefined || e.originalTarget == e.currentTarget) {
var clickedTrack = $(this),
offset = clickedTrack.offset(),
direction = e.pageY - offset.top - verticalDragPosition,
scrollTimeout,
isFirst = true,
doScroll = function()
{
var offset = clickedTrack.offset(),
pos = e.pageY - offset.top - verticalDragHeight / 2,
contentDragY = paneHeight * settings.scrollPagePercent,
dragY = dragMaxY * contentDragY / (contentHeight - paneHeight);
if (direction < 0) {
if (verticalDragPosition - dragY > pos) {
jsp.scrollByY(-contentDragY);
} else {
positionDragY(pos);
}
} else if (direction > 0) {
if (verticalDragPosition + dragY < pos) {
jsp.scrollByY(contentDragY);
} else {
positionDragY(pos);
}
} else {
cancelClick();
return;
}
scrollTimeout = setTimeout(doScroll, isFirst ? settings.initialDelay : settings.trackClickRepeatFreq);
isFirst = false;
},
cancelClick = function()
{
scrollTimeout && clearTimeout(scrollTimeout);
scrollTimeout = null;
$(document).unbind('mouseup.jsp', cancelClick);
};
doScroll();
$(document).bind('mouseup.jsp', cancelClick);
return false;
}
}
);
}
if (isScrollableH) {
horizontalTrack.bind(
'mousedown.jsp',
function(e)
{
if (e.originalTarget === undefined || e.originalTarget == e.currentTarget) {
var clickedTrack = $(this),
offset = clickedTrack.offset(),
direction = e.pageX - offset.left - horizontalDragPosition,
scrollTimeout,
isFirst = true,
doScroll = function()
{
var offset = clickedTrack.offset(),
pos = e.pageX - offset.left - horizontalDragWidth / 2,
contentDragX = paneWidth * settings.scrollPagePercent,
dragX = dragMaxX * contentDragX / (contentWidth - paneWidth);
if (direction < 0) {
if (horizontalDragPosition - dragX > pos) {
jsp.scrollByX(-contentDragX);
} else {
positionDragX(pos);
}
} else if (direction > 0) {
if (horizontalDragPosition + dragX < pos) {
jsp.scrollByX(contentDragX);
} else {
positionDragX(pos);
}
} else {
cancelClick();
return;
}
scrollTimeout = setTimeout(doScroll, isFirst ? settings.initialDelay : settings.trackClickRepeatFreq);
isFirst = false;
},
cancelClick = function()
{
scrollTimeout && clearTimeout(scrollTimeout);
scrollTimeout = null;
$(document).unbind('mouseup.jsp', cancelClick);
};
doScroll();
$(document).bind('mouseup.jsp', cancelClick);
return false;
}
}
);
}
}
|
`fail` will execute when the request fails
|
initClickOnTrack
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
doScroll = function()
{
var offset = clickedTrack.offset(),
pos = e.pageY - offset.top - verticalDragHeight / 2,
contentDragY = paneHeight * settings.scrollPagePercent,
dragY = dragMaxY * contentDragY / (contentHeight - paneHeight);
if (direction < 0) {
if (verticalDragPosition - dragY > pos) {
jsp.scrollByY(-contentDragY);
} else {
positionDragY(pos);
}
} else if (direction > 0) {
if (verticalDragPosition + dragY < pos) {
jsp.scrollByY(contentDragY);
} else {
positionDragY(pos);
}
} else {
cancelClick();
return;
}
scrollTimeout = setTimeout(doScroll, isFirst ? settings.initialDelay : settings.trackClickRepeatFreq);
isFirst = false;
}
|
`fail` will execute when the request fails
|
doScroll
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
cancelClick = function()
{
scrollTimeout && clearTimeout(scrollTimeout);
scrollTimeout = null;
$(document).unbind('mouseup.jsp', cancelClick);
}
|
`fail` will execute when the request fails
|
cancelClick
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
doScroll = function()
{
var offset = clickedTrack.offset(),
pos = e.pageX - offset.left - horizontalDragWidth / 2,
contentDragX = paneWidth * settings.scrollPagePercent,
dragX = dragMaxX * contentDragX / (contentWidth - paneWidth);
if (direction < 0) {
if (horizontalDragPosition - dragX > pos) {
jsp.scrollByX(-contentDragX);
} else {
positionDragX(pos);
}
} else if (direction > 0) {
if (horizontalDragPosition + dragX < pos) {
jsp.scrollByX(contentDragX);
} else {
positionDragX(pos);
}
} else {
cancelClick();
return;
}
scrollTimeout = setTimeout(doScroll, isFirst ? settings.initialDelay : settings.trackClickRepeatFreq);
isFirst = false;
}
|
`fail` will execute when the request fails
|
doScroll
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
cancelClick = function()
{
scrollTimeout && clearTimeout(scrollTimeout);
scrollTimeout = null;
$(document).unbind('mouseup.jsp', cancelClick);
}
|
`fail` will execute when the request fails
|
cancelClick
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function removeClickOnTrack()
{
if (horizontalTrack) {
horizontalTrack.unbind('mousedown.jsp');
}
if (verticalTrack) {
verticalTrack.unbind('mousedown.jsp');
}
}
|
`fail` will execute when the request fails
|
removeClickOnTrack
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function cancelDrag()
{
$('html').unbind('dragstart.jsp selectstart.jsp mousemove.jsp mouseup.jsp mouseleave.jsp');
if (verticalDrag) {
verticalDrag.removeClass('jspActive');
}
if (horizontalDrag) {
horizontalDrag.removeClass('jspActive');
}
}
|
`fail` will execute when the request fails
|
cancelDrag
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function positionDragY(destY, animate)
{
if (!isScrollableV) {
return;
}
if (destY < 0) {
destY = 0;
} else if (destY > dragMaxY) {
destY = dragMaxY;
}
// can't just check if(animate) because false is a valid value that could be passed in...
if (animate === undefined) {
animate = settings.animateScroll;
}
if (animate) {
jsp.animate(verticalDrag, 'top', destY, _positionDragY);
} else {
verticalDrag.css('top', destY);
_positionDragY(destY);
}
}
|
`fail` will execute when the request fails
|
positionDragY
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function _positionDragY(destY)
{
if (destY === undefined) {
destY = verticalDrag.position().top;
}
container.scrollTop(0);
verticalDragPosition = destY;
var isAtTop = verticalDragPosition === 0,
isAtBottom = verticalDragPosition == dragMaxY,
percentScrolled = destY/ dragMaxY,
destTop = -percentScrolled * (contentHeight - paneHeight);
if (wasAtTop != isAtTop || wasAtBottom != isAtBottom) {
wasAtTop = isAtTop;
wasAtBottom = isAtBottom;
elem.trigger('jsp-arrow-change', [wasAtTop, wasAtBottom, wasAtLeft, wasAtRight]);
}
updateVerticalArrows(isAtTop, isAtBottom);
pane.css('top', destTop);
elem.trigger('jsp-scroll-y', [-destTop, isAtTop, isAtBottom]).trigger('scroll');
}
|
`fail` will execute when the request fails
|
_positionDragY
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function positionDragX(destX, animate)
{
if (!isScrollableH) {
return;
}
if (destX < 0) {
destX = 0;
} else if (destX > dragMaxX) {
destX = dragMaxX;
}
if (animate === undefined) {
animate = settings.animateScroll;
}
if (animate) {
jsp.animate(horizontalDrag, 'left', destX, _positionDragX);
} else {
horizontalDrag.css('left', destX);
_positionDragX(destX);
}
}
|
`fail` will execute when the request fails
|
positionDragX
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function _positionDragX(destX)
{
if (destX === undefined) {
destX = horizontalDrag.position().left;
}
container.scrollTop(0);
horizontalDragPosition = destX;
var isAtLeft = horizontalDragPosition === 0,
isAtRight = horizontalDragPosition == dragMaxX,
percentScrolled = destX / dragMaxX,
destLeft = -percentScrolled * (contentWidth - paneWidth);
if (wasAtLeft != isAtLeft || wasAtRight != isAtRight) {
wasAtLeft = isAtLeft;
wasAtRight = isAtRight;
elem.trigger('jsp-arrow-change', [wasAtTop, wasAtBottom, wasAtLeft, wasAtRight]);
}
updateHorizontalArrows(isAtLeft, isAtRight);
pane.css('left', destLeft);
elem.trigger('jsp-scroll-x', [-destLeft, isAtLeft, isAtRight]).trigger('scroll');
}
|
`fail` will execute when the request fails
|
_positionDragX
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function updateVerticalArrows(isAtTop, isAtBottom)
{
if (settings.showArrows) {
arrowUp[isAtTop ? 'addClass' : 'removeClass']('jspDisabled');
arrowDown[isAtBottom ? 'addClass' : 'removeClass']('jspDisabled');
}
}
|
`fail` will execute when the request fails
|
updateVerticalArrows
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function updateHorizontalArrows(isAtLeft, isAtRight)
{
if (settings.showArrows) {
arrowLeft[isAtLeft ? 'addClass' : 'removeClass']('jspDisabled');
arrowRight[isAtRight ? 'addClass' : 'removeClass']('jspDisabled');
}
}
|
`fail` will execute when the request fails
|
updateHorizontalArrows
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function scrollToY(destY, animate)
{
var percentScrolled = destY / (contentHeight - paneHeight);
positionDragY(percentScrolled * dragMaxY, animate);
}
|
`fail` will execute when the request fails
|
scrollToY
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.