cash-dom
Advanced tools
Comparing version 8.1.1 to 8.1.2
@@ -20,10 +20,10 @@ interface Event { | ||
} | ||
declare type falsy = undefined | null | false | 0 | ''; | ||
declare type Ele = Window | Document | HTMLElement | Element | Node; | ||
declare type EleLoose = HTMLElement & Element & Node; | ||
declare type Selector = falsy | string | Function | HTMLCollection | NodeList | Ele | Ele[] | ArrayLike<Ele> | Cash; | ||
declare type Comparator = string | Ele | Cash | ((this: EleLoose, index: number, ele: EleLoose) => boolean); | ||
declare type Context = Document | HTMLElement | Element; | ||
declare type PlainObject<T> = Record<string, T>; | ||
declare type EventCallback = { | ||
type falsy = undefined | null | false | 0 | ''; | ||
type Ele = Window | Document | HTMLElement | Element | Node; | ||
type EleLoose = HTMLElement & Element & Node; | ||
type Selector = falsy | string | Function | HTMLCollection | NodeList | Ele | Ele[] | ArrayLike<Ele> | Cash; | ||
type Comparator = string | Ele | Cash | ((this: EleLoose, index: number, ele: EleLoose) => boolean); | ||
type Context = Document | HTMLElement | Element; | ||
type PlainObject<T> = Record<string, T>; | ||
type EventCallback = { | ||
(event: any, data?: any): any; | ||
@@ -37,35 +37,12 @@ guid?: number; | ||
declare const cash: ((selector?: Selector, context?: Context | Cash) => Cash) & CashStatic; | ||
declare type MapCallback<T> = (this: T, index: number, ele: T) => Ele; | ||
interface Cash { | ||
map(callback: MapCallback<EleLoose>): Cash; | ||
} | ||
interface Cash { | ||
slice(start?: number, end?: number): Cash; | ||
} | ||
interface CashStatic { | ||
guid: number; | ||
isWindow(x: unknown): x is Window; | ||
isFunction(x: unknown): x is Function; | ||
isArray(x: unknown): x is Array<any>; | ||
isNumeric(x: unknown): boolean; | ||
isPlainObject(x: unknown): x is PlainObject<any>; | ||
} | ||
type EachArrayCallback<T> = (this: T, index: number, ele: T) => any; | ||
type EachObjectCallback<T> = (this: T, key: string, value: T) => any; | ||
interface CashStatic { | ||
isWindow(x: any): x is Window; | ||
isFunction(x: any): x is Function; | ||
isArray(x: any): x is Array<any>; | ||
isNumeric(x: any): boolean; | ||
isPlainObject(x: any): x is PlainObject<any>; | ||
} | ||
interface Cash { | ||
get(): EleLoose[]; | ||
get(index: number): EleLoose | undefined; | ||
} | ||
interface Cash { | ||
eq(index: number): Cash; | ||
} | ||
interface Cash { | ||
first(): Cash; | ||
} | ||
interface Cash { | ||
last(): Cash; | ||
} | ||
declare type EachArrayCallback<T> = (this: T, index: number, ele: T) => any; | ||
declare type EachObjectCallback<T> = (this: T, key: string, value: T) => any; | ||
interface CashStatic { | ||
each<T>(arr: ArrayLike<T>, callback: EachArrayCallback<T>): void; | ||
@@ -78,8 +55,7 @@ each<T>(obj: PlainObject<T>, callback: EachObjectCallback<T>): void; | ||
interface Cash { | ||
prop(prop: string): any; | ||
prop(prop: string, value: any): this; | ||
prop(props: Record<string, any>): this; | ||
empty(): this; | ||
} | ||
interface Cash { | ||
removeProp(prop: string): this; | ||
text(): string; | ||
text(text: string): this; | ||
} | ||
@@ -96,6 +72,6 @@ interface CashStatic { | ||
interface Cash { | ||
filter(comparator?: Comparator): Cash; | ||
toggleClass(classes: string, force?: boolean): this; | ||
} | ||
interface Cash { | ||
hasClass(cls: string): boolean; | ||
addClass(classes: string): this; | ||
} | ||
@@ -112,99 +88,74 @@ interface Cash { | ||
interface Cash { | ||
toggleClass(classes: string, force?: boolean): this; | ||
removeClass(classes?: string): this; | ||
} | ||
interface Cash { | ||
addClass(classes: string): this; | ||
hasClass(cls: string): boolean; | ||
} | ||
interface Cash { | ||
removeClass(classes?: string): this; | ||
get(): EleLoose[]; | ||
get(index: number): EleLoose | undefined; | ||
} | ||
interface CashStatic { | ||
unique<T>(arr: ArrayLike<T>): ArrayLike<T>; | ||
} | ||
interface Cash { | ||
add(selector: Selector, context?: Context): Cash; | ||
eq(index: number): Cash; | ||
} | ||
interface Cash { | ||
css(prop: string): string | undefined; | ||
css(prop: string, value: number | string): this; | ||
css(props: Record<string, number | string>): this; | ||
first(): Cash; | ||
} | ||
interface Cash { | ||
data(): Record<string, any> | undefined; | ||
data(name: string): any; | ||
data(name: string, value: any): this; | ||
data(datas: Record<string, any>): this; | ||
last(): Cash; | ||
} | ||
interface Cash { | ||
innerWidth(): number | undefined; | ||
innerHeight(): number | undefined; | ||
outerWidth(includeMargins?: boolean): number; | ||
outerHeight(includeMargins?: boolean): number; | ||
filter(comparator?: Comparator): Cash; | ||
} | ||
interface Cash { | ||
width(): number; | ||
width(value: number | string): this; | ||
height(): number; | ||
height(value: number | string): this; | ||
detach(comparator?: Comparator): this; | ||
} | ||
interface CashStatic { | ||
parseHTML(html: string): EleLoose[]; | ||
} | ||
interface Cash { | ||
toggle(force?: boolean): this; | ||
has(selector: string | Node): Cash; | ||
} | ||
interface Cash { | ||
hide(): this; | ||
not(comparator?: Comparator): Cash; | ||
} | ||
interface Cash { | ||
show(): this; | ||
val(): string | string[]; | ||
val(value: string | string[]): this; | ||
} | ||
interface Cash { | ||
off(): this; | ||
off(events: string): this; | ||
off(events: Record<string, EventCallback>): this; | ||
off(events: string, callback: EventCallback): this; | ||
off(events: string, selector: string, callback: EventCallback): this; | ||
is(comparator?: Comparator): boolean; | ||
} | ||
interface CashStatic { | ||
guid: number; | ||
} | ||
interface CashStatic { | ||
unique<T>(arr: ArrayLike<T>): ArrayLike<T>; | ||
} | ||
interface Cash { | ||
on(events: Record<string, EventCallback>): this; | ||
on(events: Record<string, EventCallback>, selector: string): this; | ||
on(events: Record<string, EventCallback>, data: any): this; | ||
on(events: Record<string, EventCallback>, selector: string | null | undefined, data: any): this; | ||
on(events: string, callback: EventCallback): this; | ||
on(events: string, selector: string, callback: EventCallback): this; | ||
on(events: string, data: any, callback: EventCallback): this; | ||
on(events: string, selector: string | null | undefined, data: any, callback: EventCallback, _one?: boolean): this; | ||
add(selector: Selector, context?: Context): Cash; | ||
} | ||
interface Cash { | ||
one(events: Record<string, EventCallback>): this; | ||
one(events: Record<string, EventCallback>, selector: string): this; | ||
one(events: Record<string, EventCallback>, data: any): this; | ||
one(events: Record<string, EventCallback>, selector: string | null | undefined, data: any): this; | ||
one(events: string, callback: EventCallback): this; | ||
one(events: string, selector: string, callback: EventCallback): this; | ||
one(events: string, data: any, callback: EventCallback): this; | ||
one(events: string, selector: string | null | undefined, data: any, callback: EventCallback): this; | ||
children(comparator?: Comparator): Cash; | ||
} | ||
interface Cash { | ||
ready(callback: Function): this; | ||
parent(comparator?: Comparator): Cash; | ||
} | ||
interface Cash { | ||
trigger(event: Event | string, data?: any): this; | ||
index(selector?: Selector): number; | ||
} | ||
interface Cash { | ||
serialize(): string; | ||
closest(comparator?: Comparator): Cash; | ||
} | ||
interface Cash { | ||
val(): string | string[]; | ||
val(value: string | string[]): this; | ||
siblings(comparator?: Comparator): Cash; | ||
} | ||
interface Cash { | ||
clone(): this; | ||
find(selector: string): Cash; | ||
} | ||
interface Cash { | ||
detach(comparator?: Comparator): this; | ||
after(...selectors: Selector[]): this; | ||
} | ||
interface CashStatic { | ||
parseHTML(html: string): EleLoose[]; | ||
} | ||
interface Cash { | ||
empty(): this; | ||
append(...selectors: Selector[]): this; | ||
} | ||
@@ -216,120 +167,169 @@ interface Cash { | ||
interface Cash { | ||
remove(comparator?: Comparator): this; | ||
appendTo(selector: Selector): this; | ||
} | ||
interface Cash { | ||
text(): string; | ||
text(text: string): this; | ||
wrapInner(selector?: Selector): this; | ||
} | ||
interface Cash { | ||
unwrap(): this; | ||
before(...selectors: Selector[]): this; | ||
} | ||
interface Cash { | ||
offset(): undefined | { | ||
top: number; | ||
left: number; | ||
}; | ||
wrapAll(selector?: Selector): this; | ||
} | ||
interface Cash { | ||
offsetParent(): Cash; | ||
wrap(selector?: Selector): this; | ||
} | ||
interface Cash { | ||
position(): undefined | { | ||
top: number; | ||
left: number; | ||
}; | ||
insertAfter(selector: Selector): this; | ||
} | ||
interface Cash { | ||
children(comparator?: Comparator): Cash; | ||
insertBefore(selector: Selector): this; | ||
} | ||
interface Cash { | ||
prepend(...selectors: Selector[]): this; | ||
} | ||
interface Cash { | ||
prependTo(selector: Selector): this; | ||
} | ||
interface Cash { | ||
contents(): Cash; | ||
} | ||
interface Cash { | ||
find(selector: string): Cash; | ||
next(comparator?: Comparator, _all?: boolean, _until?: Comparator): Cash; | ||
} | ||
interface Cash { | ||
after(...selectors: Selector[]): this; | ||
nextAll(comparator?: Comparator): Cash; | ||
} | ||
interface Cash { | ||
append(...selectors: Selector[]): this; | ||
nextUntil(until?: Comparator, comparator?: Comparator): Cash; | ||
} | ||
interface Cash { | ||
appendTo(selector: Selector): this; | ||
parents(comparator?: Comparator, _until?: Comparator): Cash; | ||
} | ||
interface Cash { | ||
before(...selectors: Selector[]): this; | ||
parentsUntil(until?: Comparator, comparator?: Comparator): Cash; | ||
} | ||
interface Cash { | ||
insertAfter(selector: Selector): this; | ||
prev(comparator?: Comparator, _all?: boolean, _until?: Comparator): Cash; | ||
} | ||
interface Cash { | ||
insertBefore(selector: Selector): this; | ||
prevAll(comparator?: Comparator): Cash; | ||
} | ||
interface Cash { | ||
prepend(...selectors: Selector[]): this; | ||
prevUntil(until?: Comparator, comparator?: Comparator): Cash; | ||
} | ||
type MapCallback<T> = (this: T, index: number, ele: T) => Ele; | ||
interface Cash { | ||
prependTo(selector: Selector): this; | ||
map(callback: MapCallback<EleLoose>): Cash; | ||
} | ||
interface Cash { | ||
replaceWith(selector: Selector): this; | ||
clone(): this; | ||
} | ||
interface Cash { | ||
replaceAll(selector: Selector): this; | ||
offsetParent(): Cash; | ||
} | ||
interface Cash { | ||
wrapAll(selector?: Selector): this; | ||
slice(start?: number, end?: number): Cash; | ||
} | ||
interface Cash { | ||
wrap(selector?: Selector): this; | ||
ready(callback: Function): this; | ||
} | ||
interface Cash { | ||
wrapInner(selector?: Selector): this; | ||
unwrap(): this; | ||
} | ||
interface Cash { | ||
has(selector: string | Node): Cash; | ||
offset(): undefined | { | ||
top: number; | ||
left: number; | ||
}; | ||
} | ||
interface Cash { | ||
is(comparator?: Comparator): boolean; | ||
position(): undefined | { | ||
top: number; | ||
left: number; | ||
}; | ||
} | ||
interface Cash { | ||
next(comparator?: Comparator, _all?: boolean, _until?: Comparator): Cash; | ||
prop(prop: string): any; | ||
prop(prop: string, value: any): this; | ||
prop(props: Record<string, any>): this; | ||
} | ||
interface Cash { | ||
nextAll(comparator?: Comparator): Cash; | ||
removeProp(prop: string): this; | ||
} | ||
interface Cash { | ||
nextUntil(until?: Comparator, comparator?: Comparator): Cash; | ||
css(prop: string): string | undefined; | ||
css(prop: string, value: number | string): this; | ||
css(props: Record<string, number | string>): this; | ||
} | ||
interface Cash { | ||
not(comparator?: Comparator): Cash; | ||
data(): Record<string, any> | undefined; | ||
data(name: string): any; | ||
data(name: string, value: any): this; | ||
data(datas: Record<string, any>): this; | ||
} | ||
interface Cash { | ||
parent(comparator?: Comparator): Cash; | ||
innerWidth(): number | undefined; | ||
innerHeight(): number | undefined; | ||
outerWidth(includeMargins?: boolean): number; | ||
outerHeight(includeMargins?: boolean): number; | ||
} | ||
interface Cash { | ||
index(selector?: Selector): number; | ||
width(): number; | ||
width(value: number | string): this; | ||
height(): number; | ||
height(value: number | string): this; | ||
} | ||
interface Cash { | ||
closest(comparator?: Comparator): Cash; | ||
toggle(force?: boolean): this; | ||
} | ||
interface Cash { | ||
parents(comparator?: Comparator, _until?: Comparator): Cash; | ||
hide(): this; | ||
} | ||
interface Cash { | ||
parentsUntil(until?: Comparator, comparator?: Comparator): Cash; | ||
show(): this; | ||
} | ||
interface Cash { | ||
prev(comparator?: Comparator, _all?: boolean, _until?: Comparator): Cash; | ||
trigger(event: Event | string, data?: any): this; | ||
} | ||
interface Cash { | ||
prevAll(comparator?: Comparator): Cash; | ||
off(): this; | ||
off(events: string): this; | ||
off(events: Record<string, EventCallback>): this; | ||
off(events: string, callback: EventCallback): this; | ||
off(events: string, selector: string, callback: EventCallback): this; | ||
} | ||
interface Cash { | ||
prevUntil(until?: Comparator, comparator?: Comparator): Cash; | ||
remove(comparator?: Comparator): this; | ||
} | ||
interface Cash { | ||
siblings(comparator?: Comparator): Cash; | ||
replaceWith(selector: Selector): this; | ||
} | ||
interface Cash { | ||
replaceAll(selector: Selector): this; | ||
} | ||
interface Cash { | ||
on(events: Record<string, EventCallback>): this; | ||
on(events: Record<string, EventCallback>, selector: string): this; | ||
on(events: Record<string, EventCallback>, data: any): this; | ||
on(events: Record<string, EventCallback>, selector: string | null | undefined, data: any): this; | ||
on(events: string, callback: EventCallback): this; | ||
on(events: string, selector: string, callback: EventCallback): this; | ||
on(events: string, data: any, callback: EventCallback): this; | ||
on(events: string, selector: string | null | undefined, data: any, callback: EventCallback, _one?: boolean): this; | ||
} | ||
interface Cash { | ||
one(events: Record<string, EventCallback>): this; | ||
one(events: Record<string, EventCallback>, selector: string): this; | ||
one(events: Record<string, EventCallback>, data: any): this; | ||
one(events: Record<string, EventCallback>, selector: string | null | undefined, data: any): this; | ||
one(events: string, callback: EventCallback): this; | ||
one(events: string, selector: string, callback: EventCallback): this; | ||
one(events: string, data: any, callback: EventCallback): this; | ||
one(events: string, selector: string | null | undefined, data: any, callback: EventCallback): this; | ||
} | ||
interface Cash { | ||
serialize(): string; | ||
} | ||
export default cash; | ||
export { Cash, CashStatic, Ele as Element, Selector, Comparator, Context }; |
1234
dist/cash.esm.js
@@ -1,28 +0,15 @@ | ||
/* MIT https://github.com/fabiospampinato/cash */ | ||
const propMap = { | ||
/* GENERAL */ | ||
class: 'className', | ||
contenteditable: 'contentEditable', | ||
/* LABEL */ | ||
for: 'htmlFor', | ||
/* INPUT */ | ||
readonly: 'readOnly', | ||
maxlength: 'maxLength', | ||
tabindex: 'tabIndex', | ||
/* TABLE */ | ||
colspan: 'colSpan', | ||
rowspan: 'rowSpan', | ||
/* IMAGE */ | ||
usemap: 'useMap' | ||
}; | ||
function attempt(fn, arg) { | ||
try { | ||
return fn(arg); | ||
} | ||
catch (_a) { | ||
return arg; | ||
} | ||
} | ||
const doc = document, win = window, docEle = doc.documentElement, createElement = doc.createElement.bind(doc), div = createElement('div'), table = createElement('table'), tbody = createElement('tbody'), tr = createElement('tr'), { isArray, prototype: ArrayPrototype } = Array, { concat, filter, indexOf, map, push, slice, some, splice } = ArrayPrototype; | ||
const idRe = /^#(?:[\w-]|\\.|[^\x00-\xa0])*$/, classRe = /^\.(?:[\w-]|\\.|[^\x00-\xa0])*$/, htmlRe = /<.+>/, tagRe = /^\w+$/; | ||
const doc = document; | ||
const win = window; | ||
const docEle = doc.documentElement; | ||
const createElement = doc.createElement.bind(doc); | ||
const div = createElement('div'); | ||
const table = createElement('table'); | ||
const tbody = createElement('tbody'); | ||
const tr = createElement('tr'); | ||
const { isArray, prototype: ArrayPrototype } = Array; | ||
const { concat, filter, indexOf, map, push, slice, some, splice } = ArrayPrototype; | ||
const idRe = /^#(?:[\w-]|\\.|[^\x00-\xa0])*$/; | ||
const classRe = /^\.(?:[\w-]|\\.|[^\x00-\xa0])*$/; | ||
const htmlRe = /<.+>/; | ||
const tagRe = /^\w+$/; | ||
// @require ./variables.ts | ||
@@ -34,3 +21,3 @@ function find(selector, context) { | ||
: !isFragment && classRe.test(selector) | ||
? context.getElementsByClassName(selector.slice(1)) | ||
? context.getElementsByClassName(selector.slice(1).replace(/\\/g, '')) | ||
: !isFragment && tagRe.test(selector) | ||
@@ -52,3 +39,3 @@ ? context.getElementsByTagName(selector) | ||
eles = idRe.test(selector) && 'getElementById' in ctx | ||
? ctx.getElementById(selector.slice(1)) | ||
? ctx.getElementById(selector.slice(1).replace(/\\/g, '')) | ||
: htmlRe.test(selector) | ||
@@ -74,3 +61,4 @@ ? parseHTML(selector) | ||
} | ||
const fn = Cash.prototype, cash = fn.init; | ||
const fn = Cash.prototype; | ||
const cash = fn.init; | ||
cash.fn = cash.prototype = fn; // Ensuring that `cash () instanceof cash` | ||
@@ -82,56 +70,39 @@ fn.length = 0; | ||
} | ||
fn.map = function (callback) { | ||
return cash(concat.apply([], map.call(this, (ele, i) => callback.call(ele, i, ele)))); | ||
}; | ||
fn.slice = function (start, end) { | ||
return cash(slice.call(this, start, end)); | ||
}; | ||
// @require ./cash.ts | ||
const dashAlphaRe = /-([a-z])/g; | ||
function camelCase(str) { | ||
return str.replace(dashAlphaRe, (match, letter) => letter.toUpperCase()); | ||
function isCash(value) { | ||
return value instanceof Cash; | ||
} | ||
cash.guid = 1; | ||
// @require ./cash.ts | ||
function matches(ele, selector) { | ||
const matches = ele && (ele['matches'] || ele['webkitMatchesSelector'] || ele['msMatchesSelector']); | ||
return !!matches && !!selector && matches.call(ele, selector); | ||
function isWindow(value) { | ||
return !!value && value === value.window; | ||
} | ||
function isCash(x) { | ||
return x instanceof Cash; | ||
function isDocument(value) { | ||
return !!value && value.nodeType === 9; | ||
} | ||
function isWindow(x) { | ||
return !!x && x === x.window; | ||
function isDocumentFragment(value) { | ||
return !!value && value.nodeType === 11; | ||
} | ||
function isDocument(x) { | ||
return !!x && x.nodeType === 9; | ||
function isElement(value) { | ||
return !!value && value.nodeType === 1; | ||
} | ||
function isDocumentFragment(x) { | ||
return !!x && x.nodeType === 11; | ||
function isBoolean(value) { | ||
return typeof value === 'boolean'; | ||
} | ||
function isElement(x) { | ||
return !!x && x.nodeType === 1; | ||
function isFunction(value) { | ||
return typeof value === 'function'; | ||
} | ||
function isBoolean(x) { | ||
return typeof x === 'boolean'; | ||
function isString(value) { | ||
return typeof value === 'string'; | ||
} | ||
function isFunction(x) { | ||
return typeof x === 'function'; | ||
function isUndefined(value) { | ||
return value === undefined; | ||
} | ||
function isString(x) { | ||
return typeof x === 'string'; | ||
function isNull(value) { | ||
return value === null; | ||
} | ||
function isUndefined(x) { | ||
return x === undefined; | ||
function isNumeric(value) { | ||
return !isNaN(parseFloat(value)) && isFinite(value); | ||
} | ||
function isNull(x) { | ||
return x === null; | ||
} | ||
function isNumeric(x) { | ||
return !isNaN(parseFloat(x)) && isFinite(x); | ||
} | ||
function isPlainObject(x) { | ||
if (typeof x !== 'object' || x === null) | ||
function isPlainObject(value) { | ||
if (typeof value !== 'object' || value === null) | ||
return false; | ||
const proto = Object.getPrototypeOf(x); | ||
const proto = Object.getPrototypeOf(value); | ||
return proto === null || proto === Object.prototype; | ||
@@ -144,17 +115,2 @@ } | ||
cash.isPlainObject = isPlainObject; | ||
fn.get = function (index) { | ||
if (isUndefined(index)) | ||
return slice.call(this); | ||
index = Number(index); | ||
return this[index < 0 ? index + this.length : index]; | ||
}; | ||
fn.eq = function (index) { | ||
return cash(this.get(index)); | ||
}; | ||
fn.first = function () { | ||
return this.eq(0); | ||
}; | ||
fn.last = function () { | ||
return this.eq(-1); | ||
}; | ||
function each(arr, callback, _reverse) { | ||
@@ -188,21 +144,24 @@ if (_reverse) { | ||
}; | ||
fn.prop = function (prop, value) { | ||
if (!prop) | ||
return; | ||
if (isString(prop)) { | ||
prop = propMap[prop] || prop; | ||
if (arguments.length < 2) | ||
return this[0] && this[0][prop]; | ||
return this.each((i, ele) => { ele[prop] = value; }); | ||
} | ||
for (const key in prop) { | ||
this.prop(key, prop[key]); | ||
} | ||
return this; | ||
fn.empty = function () { | ||
return this.each((i, ele) => { | ||
while (ele.firstChild) { | ||
ele.removeChild(ele.firstChild); | ||
} | ||
}); | ||
}; | ||
fn.removeProp = function (prop) { | ||
return this.each((i, ele) => { delete ele[propMap[prop] || prop]; }); | ||
}; | ||
function text(text) { | ||
if (isUndefined(text)) | ||
return this[0] ? this[0].textContent : ''; | ||
return this.each((i, ele) => { | ||
if (!isElement(ele)) | ||
return; | ||
ele.textContent = text; | ||
}); | ||
} | ||
; | ||
fn.text = text; | ||
function extend(...sources) { | ||
const deep = isBoolean(sources[0]) ? sources.shift() : false, target = sources.shift(), length = sources.length; | ||
const deep = isBoolean(sources[0]) ? sources.shift() : false; | ||
const target = sources.shift(); | ||
const length = sources.length; | ||
if (!target) | ||
@@ -231,24 +190,3 @@ return {}; | ||
}; | ||
// @require ./matches.ts | ||
// @require ./type_checking.ts | ||
function getCompareFunction(comparator) { | ||
return isString(comparator) | ||
? (i, ele) => matches(ele, comparator) | ||
: isFunction(comparator) | ||
? comparator | ||
: isCash(comparator) | ||
? (i, ele) => comparator.is(ele) | ||
: !comparator | ||
? () => false | ||
: (i, ele) => ele === comparator; | ||
} | ||
fn.filter = function (comparator) { | ||
const compare = getCompareFunction(comparator); | ||
return cash(filter.call(this, (ele, i) => compare.call(ele, i, ele))); | ||
}; | ||
// @require collection/filter.ts | ||
function filtered(collection, comparator) { | ||
return !comparator ? collection : collection.filter(comparator); | ||
} | ||
// @require ./type_checking.ts | ||
const splitValuesRe = /\S+/g; | ||
@@ -258,5 +196,21 @@ function getSplitValues(str) { | ||
} | ||
fn.hasClass = function (cls) { | ||
return !!cls && some.call(this, (ele) => isElement(ele) && ele.classList.contains(cls)); | ||
fn.toggleClass = function (cls, force) { | ||
const classes = getSplitValues(cls); | ||
const isForce = !isUndefined(force); | ||
return this.each((i, ele) => { | ||
if (!isElement(ele)) | ||
return; | ||
each(classes, (i, c) => { | ||
if (isForce) { | ||
force ? ele.classList.add(c) : ele.classList.remove(c); | ||
} | ||
else { | ||
ele.classList.toggle(c); | ||
} | ||
}); | ||
}); | ||
}; | ||
fn.addClass = function (cls) { | ||
return this.toggleClass(cls, true); | ||
}; | ||
fn.removeAttr = function (attr) { | ||
@@ -298,20 +252,2 @@ const attrs = getSplitValues(attr); | ||
fn.attr = attr; | ||
fn.toggleClass = function (cls, force) { | ||
const classes = getSplitValues(cls), isForce = !isUndefined(force); | ||
return this.each((i, ele) => { | ||
if (!isElement(ele)) | ||
return; | ||
each(classes, (i, c) => { | ||
if (isForce) { | ||
force ? ele.classList.add(c) : ele.classList.remove(c); | ||
} | ||
else { | ||
ele.classList.toggle(c); | ||
} | ||
}); | ||
}); | ||
}; | ||
fn.addClass = function (cls) { | ||
return this.toggleClass(cls, true); | ||
}; | ||
fn.removeClass = function (cls) { | ||
@@ -322,4 +258,123 @@ if (arguments.length) | ||
}; | ||
fn.hasClass = function (cls) { | ||
return !!cls && some.call(this, (ele) => isElement(ele) && ele.classList.contains(cls)); | ||
}; | ||
fn.get = function (index) { | ||
if (isUndefined(index)) | ||
return slice.call(this); | ||
index = Number(index); | ||
return this[index < 0 ? index + this.length : index]; | ||
}; | ||
fn.eq = function (index) { | ||
return cash(this.get(index)); | ||
}; | ||
fn.first = function () { | ||
return this.eq(0); | ||
}; | ||
fn.last = function () { | ||
return this.eq(-1); | ||
}; | ||
// @require core/type_checking.ts | ||
// @require core/variables.ts | ||
function computeStyle(ele, prop, isVariable) { | ||
if (!isElement(ele)) | ||
return; | ||
const style = win.getComputedStyle(ele, null); | ||
return isVariable ? style.getPropertyValue(prop) || undefined : style[prop] || ele.style[prop]; | ||
} | ||
// @require ./compute_style.ts | ||
function computeStyleInt(ele, prop) { | ||
return parseInt(computeStyle(ele, prop), 10) || 0; | ||
} | ||
// @require css/helpers/compute_style_int.ts | ||
function getExtraSpace(ele, xAxis) { | ||
return computeStyleInt(ele, `border${xAxis ? 'Left' : 'Top'}Width`) + computeStyleInt(ele, `padding${xAxis ? 'Left' : 'Top'}`) + computeStyleInt(ele, `padding${xAxis ? 'Right' : 'Bottom'}`) + computeStyleInt(ele, `border${xAxis ? 'Right' : 'Bottom'}Width`); | ||
} | ||
// @require css/helpers/compute_style.ts | ||
const defaultDisplay = {}; | ||
function getDefaultDisplay(tagName) { | ||
if (defaultDisplay[tagName]) | ||
return defaultDisplay[tagName]; | ||
const ele = createElement(tagName); | ||
doc.body.insertBefore(ele, null); | ||
const display = computeStyle(ele, 'display'); | ||
doc.body.removeChild(ele); | ||
return defaultDisplay[tagName] = display !== 'none' ? display : 'block'; | ||
} | ||
// @require css/helpers/compute_style.ts | ||
function isHidden(ele) { | ||
return computeStyle(ele, 'display') === 'none'; | ||
} | ||
// @require ./cash.ts | ||
function matches(ele, selector) { | ||
const matches = ele && (ele['matches'] || ele['webkitMatchesSelector'] || ele['msMatchesSelector']); | ||
return !!matches && !!selector && matches.call(ele, selector); | ||
} | ||
// @require ./matches.ts | ||
// @require ./type_checking.ts | ||
function getCompareFunction(comparator) { | ||
return isString(comparator) | ||
? (i, ele) => matches(ele, comparator) | ||
: isFunction(comparator) | ||
? comparator | ||
: isCash(comparator) | ||
? (i, ele) => comparator.is(ele) | ||
: !comparator | ||
? () => false | ||
: (i, ele) => ele === comparator; | ||
} | ||
fn.filter = function (comparator) { | ||
const compare = getCompareFunction(comparator); | ||
return cash(filter.call(this, (ele, i) => compare.call(ele, i, ele))); | ||
}; | ||
// @require collection/filter.ts | ||
function filtered(collection, comparator) { | ||
return !comparator ? collection : collection.filter(comparator); | ||
} | ||
fn.detach = function (comparator) { | ||
filtered(this, comparator).each((i, ele) => { | ||
if (ele.parentNode) { | ||
ele.parentNode.removeChild(ele); | ||
} | ||
}); | ||
return this; | ||
}; | ||
const fragmentRe = /^\s*<(\w+)[^>]*>/; | ||
const singleTagRe = /^<(\w+)\s*\/?>(?:<\/\1>)?$/; | ||
const containers = { | ||
'*': div, | ||
tr: tbody, | ||
td: tr, | ||
th: tr, | ||
thead: table, | ||
tbody: table, | ||
tfoot: table | ||
}; | ||
//TODO: Create elements inside a document fragment, in order to prevent inline event handlers from firing | ||
//TODO: Ensure the created elements have the fragment as their parent instead of null, this also ensures we can deal with detatched nodes more reliably | ||
function parseHTML(html) { | ||
if (!isString(html)) | ||
return []; | ||
if (singleTagRe.test(html)) | ||
return [createElement(RegExp.$1)]; | ||
const fragment = fragmentRe.test(html) && RegExp.$1; | ||
const container = containers[fragment] || containers['*']; | ||
container.innerHTML = html; | ||
return cash(container.childNodes).detach().get(); | ||
} | ||
cash.parseHTML = parseHTML; | ||
fn.has = function (selector) { | ||
const comparator = isString(selector) | ||
? (i, ele) => find(selector, ele).length | ||
: (i, ele) => ele.contains(selector); | ||
return this.filter(comparator); | ||
}; | ||
fn.not = function (comparator) { | ||
const compare = getCompareFunction(comparator); | ||
return this.filter((i, ele) => (!isString(comparator) || isElement(ele)) && !compare.call(ele, i, ele)); | ||
}; | ||
function pluck(arr, prop, deep, until) { | ||
const plucked = [], isCallback = isFunction(prop), compare = until && getCompareFunction(until); | ||
const plucked = []; | ||
const isCallback = isFunction(prop); | ||
const compare = until && getCompareFunction(until); | ||
for (let i = 0, l = arr.length; i < l; i++) { | ||
@@ -343,2 +398,36 @@ if (isCallback) { | ||
} | ||
// @require core/pluck.ts | ||
// @require core/variables.ts | ||
function getValue(ele) { | ||
if (ele.multiple && ele.options) | ||
return pluck(filter.call(ele.options, option => option.selected && !option.disabled && !option.parentNode.disabled), 'value'); | ||
return ele.value || ''; | ||
} | ||
function val(value) { | ||
if (!arguments.length) | ||
return this[0] && getValue(this[0]); | ||
return this.each((i, ele) => { | ||
const isSelect = ele.multiple && ele.options; | ||
if (isSelect || checkableRe.test(ele.type)) { | ||
const eleValue = isArray(value) ? map.call(value, String) : (isNull(value) ? [] : [String(value)]); | ||
if (isSelect) { | ||
each(ele.options, (i, option) => { | ||
option.selected = eleValue.indexOf(option.value) >= 0; | ||
}, true); | ||
} | ||
else { | ||
ele.checked = eleValue.indexOf(ele.value) >= 0; | ||
} | ||
} | ||
else { | ||
ele.value = isUndefined(value) || isNull(value) ? '' : value; | ||
} | ||
}); | ||
} | ||
fn.val = val; | ||
fn.is = function (comparator) { | ||
const compare = getCompareFunction(comparator); | ||
return some.call(this, (ele, i) => compare.call(ele, i, ele)); | ||
}; | ||
cash.guid = 1; | ||
function unique(arr) { | ||
@@ -351,14 +440,278 @@ return arr.length > 1 ? filter.call(arr, (item, index, self) => indexOf.call(self, item) === index) : arr; | ||
}; | ||
// @require core/type_checking.ts | ||
fn.children = function (comparator) { | ||
return filtered(cash(unique(pluck(this, ele => ele.children))), comparator); | ||
}; | ||
fn.parent = function (comparator) { | ||
return filtered(cash(unique(pluck(this, 'parentNode'))), comparator); | ||
}; | ||
fn.index = function (selector) { | ||
const child = selector ? cash(selector)[0] : this[0]; | ||
const collection = selector ? this : cash(child).parent().children(); | ||
return indexOf.call(collection, child); | ||
}; | ||
fn.closest = function (comparator) { | ||
const filtered = this.filter(comparator); | ||
if (filtered.length) | ||
return filtered; | ||
const $parent = this.parent(); | ||
if (!$parent.length) | ||
return filtered; | ||
return $parent.closest(comparator); | ||
}; | ||
fn.siblings = function (comparator) { | ||
return filtered(cash(unique(pluck(this, ele => cash(ele).parent().children().not(ele)))), comparator); | ||
}; | ||
fn.find = function (selector) { | ||
return cash(unique(pluck(this, ele => find(selector, ele)))); | ||
}; | ||
// @require core/variables.ts | ||
function computeStyle(ele, prop, isVariable) { | ||
if (!isElement(ele)) | ||
return; | ||
const style = win.getComputedStyle(ele, null); | ||
return isVariable ? style.getPropertyValue(prop) || undefined : style[prop] || ele.style[prop]; | ||
// @require collection/filter.ts | ||
// @require traversal/find.ts | ||
const HTMLCDATARe = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g; | ||
const scriptTypeRe = /^$|^module$|\/(java|ecma)script/i; | ||
const scriptAttributes = ['type', 'src', 'nonce', 'noModule']; | ||
function evalScripts(node, doc) { | ||
const collection = cash(node); | ||
collection.filter('script').add(collection.find('script')).each((i, ele) => { | ||
if (scriptTypeRe.test(ele.type) && docEle.contains(ele)) { // The script type is supported // The element is attached to the DOM // Using `documentElement` for broader browser support | ||
const script = createElement('script'); | ||
script.text = ele.textContent.replace(HTMLCDATARe, ''); | ||
each(scriptAttributes, (i, attr) => { | ||
if (ele[attr]) | ||
script[attr] = ele[attr]; | ||
}); | ||
doc.head.insertBefore(script, null); | ||
doc.head.removeChild(script); | ||
} | ||
}); | ||
} | ||
// @require ./compute_style.ts | ||
function computeStyleInt(ele, prop) { | ||
return parseInt(computeStyle(ele, prop), 10) || 0; | ||
// @require ./eval_scripts.ts | ||
function insertElement(anchor, target, left, inside, evaluate) { | ||
if (inside) { // prepend/append | ||
anchor.insertBefore(target, left ? anchor.firstChild : null); | ||
} | ||
else { // before/after | ||
if (anchor.nodeName === 'HTML') { | ||
anchor.parentNode.replaceChild(target, anchor); | ||
} | ||
else { | ||
anchor.parentNode.insertBefore(target, left ? anchor : anchor.nextSibling); | ||
} | ||
} | ||
if (evaluate) { | ||
evalScripts(target, anchor.ownerDocument); | ||
} | ||
} | ||
// @require ./insert_element.ts | ||
function insertSelectors(selectors, anchors, inverse, left, inside, reverseLoop1, reverseLoop2, reverseLoop3) { | ||
each(selectors, (si, selector) => { | ||
each(cash(selector), (ti, target) => { | ||
each(cash(anchors), (ai, anchor) => { | ||
const anchorFinal = inverse ? target : anchor; | ||
const targetFinal = inverse ? anchor : target; | ||
const indexFinal = inverse ? ti : ai; | ||
insertElement(anchorFinal, !indexFinal ? targetFinal : targetFinal.cloneNode(true), left, inside, !indexFinal); | ||
}, reverseLoop3); | ||
}, reverseLoop2); | ||
}, reverseLoop1); | ||
return anchors; | ||
} | ||
fn.after = function () { | ||
return insertSelectors(arguments, this, false, false, false, true, true); | ||
}; | ||
fn.append = function () { | ||
return insertSelectors(arguments, this, false, false, true); | ||
}; | ||
function html(html) { | ||
if (!arguments.length) | ||
return this[0] && this[0].innerHTML; | ||
if (isUndefined(html)) | ||
return this; | ||
const hasScript = /<script[\s>]/.test(html); | ||
return this.each((i, ele) => { | ||
if (!isElement(ele)) | ||
return; | ||
if (hasScript) { | ||
cash(ele).empty().append(html); | ||
} | ||
else { | ||
ele.innerHTML = html; | ||
} | ||
}); | ||
} | ||
fn.html = html; | ||
fn.appendTo = function (selector) { | ||
return insertSelectors(arguments, this, true, false, true); | ||
}; | ||
fn.wrapInner = function (selector) { | ||
return this.each((i, ele) => { | ||
const $ele = cash(ele); | ||
const contents = $ele.contents(); | ||
contents.length ? contents.wrapAll(selector) : $ele.append(selector); | ||
}); | ||
}; | ||
fn.before = function () { | ||
return insertSelectors(arguments, this, false, true); | ||
}; | ||
fn.wrapAll = function (selector) { | ||
let structure = cash(selector); | ||
let wrapper = structure[0]; | ||
while (wrapper.children.length) | ||
wrapper = wrapper.firstElementChild; | ||
this.first().before(structure); | ||
return this.appendTo(wrapper); | ||
}; | ||
fn.wrap = function (selector) { | ||
return this.each((i, ele) => { | ||
const wrapper = cash(selector)[0]; | ||
cash(ele).wrapAll(!i ? wrapper : wrapper.cloneNode(true)); | ||
}); | ||
}; | ||
fn.insertAfter = function (selector) { | ||
return insertSelectors(arguments, this, true, false, false, false, false, true); | ||
}; | ||
fn.insertBefore = function (selector) { | ||
return insertSelectors(arguments, this, true, true); | ||
}; | ||
fn.prepend = function () { | ||
return insertSelectors(arguments, this, false, true, true, true, true); | ||
}; | ||
fn.prependTo = function (selector) { | ||
return insertSelectors(arguments, this, true, true, true, false, false, true); | ||
}; | ||
fn.contents = function () { | ||
return cash(unique(pluck(this, ele => ele.tagName === 'IFRAME' ? [ele.contentDocument] : (ele.tagName === 'TEMPLATE' ? ele.content.childNodes : ele.childNodes)))); | ||
}; | ||
fn.next = function (comparator, _all, _until) { | ||
return filtered(cash(unique(pluck(this, 'nextElementSibling', _all, _until))), comparator); | ||
}; | ||
fn.nextAll = function (comparator) { | ||
return this.next(comparator, true); | ||
}; | ||
fn.nextUntil = function (until, comparator) { | ||
return this.next(comparator, true, until); | ||
}; | ||
fn.parents = function (comparator, _until) { | ||
return filtered(cash(unique(pluck(this, 'parentElement', true, _until))), comparator); | ||
}; | ||
fn.parentsUntil = function (until, comparator) { | ||
return this.parents(comparator, until); | ||
}; | ||
fn.prev = function (comparator, _all, _until) { | ||
return filtered(cash(unique(pluck(this, 'previousElementSibling', _all, _until))), comparator); | ||
}; | ||
fn.prevAll = function (comparator) { | ||
return this.prev(comparator, true); | ||
}; | ||
fn.prevUntil = function (until, comparator) { | ||
return this.prev(comparator, true, until); | ||
}; | ||
fn.map = function (callback) { | ||
return cash(concat.apply([], map.call(this, (ele, i) => callback.call(ele, i, ele)))); | ||
}; | ||
fn.clone = function () { | ||
return this.map((i, ele) => ele.cloneNode(true)); | ||
}; | ||
fn.offsetParent = function () { | ||
return this.map((i, ele) => { | ||
let offsetParent = ele.offsetParent; | ||
while (offsetParent && computeStyle(offsetParent, 'position') === 'static') { | ||
offsetParent = offsetParent.offsetParent; | ||
} | ||
return offsetParent || docEle; | ||
}); | ||
}; | ||
fn.slice = function (start, end) { | ||
return cash(slice.call(this, start, end)); | ||
}; | ||
// @require ./cash.ts | ||
const dashAlphaRe = /-([a-z])/g; | ||
function camelCase(str) { | ||
return str.replace(dashAlphaRe, (match, letter) => letter.toUpperCase()); | ||
} | ||
fn.ready = function (callback) { | ||
const cb = () => setTimeout(callback, 0, cash); | ||
if (doc.readyState !== 'loading') { | ||
cb(); | ||
} | ||
else { | ||
doc.addEventListener('DOMContentLoaded', cb); | ||
} | ||
return this; | ||
}; | ||
fn.unwrap = function () { | ||
this.parent().each((i, ele) => { | ||
if (ele.tagName === 'BODY') | ||
return; | ||
const $ele = cash(ele); | ||
$ele.replaceWith($ele.children()); | ||
}); | ||
return this; | ||
}; | ||
fn.offset = function () { | ||
const ele = this[0]; | ||
if (!ele) | ||
return; | ||
const rect = ele.getBoundingClientRect(); | ||
return { | ||
top: rect.top + win.pageYOffset, | ||
left: rect.left + win.pageXOffset | ||
}; | ||
}; | ||
fn.position = function () { | ||
const ele = this[0]; | ||
if (!ele) | ||
return; | ||
const isFixed = (computeStyle(ele, 'position') === 'fixed'); | ||
const offset = isFixed ? ele.getBoundingClientRect() : this.offset(); | ||
if (!isFixed) { | ||
const doc = ele.ownerDocument; | ||
let offsetParent = ele.offsetParent || doc.documentElement; | ||
while ((offsetParent === doc.body || offsetParent === doc.documentElement) && computeStyle(offsetParent, 'position') === 'static') { | ||
offsetParent = offsetParent.parentNode; | ||
} | ||
if (offsetParent !== ele && isElement(offsetParent)) { | ||
const parentOffset = cash(offsetParent).offset(); | ||
offset.top -= parentOffset.top + computeStyleInt(offsetParent, 'borderTopWidth'); | ||
offset.left -= parentOffset.left + computeStyleInt(offsetParent, 'borderLeftWidth'); | ||
} | ||
} | ||
return { | ||
top: offset.top - computeStyleInt(ele, 'marginTop'), | ||
left: offset.left - computeStyleInt(ele, 'marginLeft') | ||
}; | ||
}; | ||
const propMap = { | ||
/* GENERAL */ | ||
class: 'className', | ||
contenteditable: 'contentEditable', | ||
/* LABEL */ | ||
for: 'htmlFor', | ||
/* INPUT */ | ||
readonly: 'readOnly', | ||
maxlength: 'maxLength', | ||
tabindex: 'tabIndex', | ||
/* TABLE */ | ||
colspan: 'colSpan', | ||
rowspan: 'rowSpan', | ||
/* IMAGE */ | ||
usemap: 'useMap' | ||
}; | ||
fn.prop = function (prop, value) { | ||
if (!prop) | ||
return; | ||
if (isString(prop)) { | ||
prop = propMap[prop] || prop; | ||
if (arguments.length < 2) | ||
return this[0] && this[0][prop]; | ||
return this.each((i, ele) => { ele[prop] = value; }); | ||
} | ||
for (const key in prop) { | ||
this.prop(key, prop[key]); | ||
} | ||
return this; | ||
}; | ||
fn.removeProp = function (prop) { | ||
return this.each((i, ele) => { delete ele[propMap[prop] || prop]; }); | ||
}; | ||
const cssVariableRe = /^--/; | ||
@@ -374,3 +727,5 @@ // @require ./variables.ts | ||
// @require ./is_css_variable.ts | ||
const prefixedProps = {}, { style } = div, vendorsPrefixes = ['webkit', 'moz', 'ms']; | ||
const prefixedProps = {}; | ||
const { style } = div; | ||
const vendorsPrefixes = ['webkit', 'moz', 'ms']; | ||
function getPrefixedProp(prop, isVariable = isCSSVariable(prop)) { | ||
@@ -380,3 +735,5 @@ if (isVariable) | ||
if (!prefixedProps[prop]) { | ||
const propCC = camelCase(prop), propUC = `${propCC[0].toUpperCase()}${propCC.slice(1)}`, props = (`${propCC} ${vendorsPrefixes.join(`${propUC} `)}${propUC}`).split(' '); | ||
const propCC = camelCase(prop); | ||
const propUC = `${propCC[0].toUpperCase()}${propCC.slice(1)}`; | ||
const props = (`${propCC} ${vendorsPrefixes.join(`${propUC} `)}${propUC}`).split(' '); | ||
each(props, (i, p) => { | ||
@@ -391,3 +748,2 @@ if (p in style) { | ||
} | ||
; | ||
// @require core/type_checking.ts | ||
@@ -445,3 +801,10 @@ // @require ./is_css_variable.ts | ||
fn.css = css; | ||
// @optional ./css.ts | ||
function attempt(fn, arg) { | ||
try { | ||
return fn(arg); | ||
} | ||
catch (_a) { | ||
return arg; | ||
} | ||
} | ||
// @require core/attempt.ts | ||
@@ -485,3 +848,2 @@ // @require core/camel_case.ts | ||
fn.data = data; | ||
// @optional ./data.ts | ||
function getDocumentDimension(doc, dimension) { | ||
@@ -491,6 +853,2 @@ const docEle = doc.documentElement; | ||
} | ||
// @require css/helpers/compute_style_int.ts | ||
function getExtraSpace(ele, xAxis) { | ||
return computeStyleInt(ele, `border${xAxis ? 'Left' : 'Top'}Width`) + computeStyleInt(ele, `padding${xAxis ? 'Left' : 'Top'}`) + computeStyleInt(ele, `padding${xAxis ? 'Right' : 'Bottom'}`) + computeStyleInt(ele, `border${xAxis ? 'Right' : 'Bottom'}Width`); | ||
} | ||
each([true, false], (i, outer) => { | ||
@@ -531,19 +889,2 @@ each(['Width', 'Height'], (i, prop) => { | ||
}); | ||
// @optional ./inner_outer.ts | ||
// @optional ./normal.ts | ||
// @require css/helpers/compute_style.ts | ||
const defaultDisplay = {}; | ||
function getDefaultDisplay(tagName) { | ||
if (defaultDisplay[tagName]) | ||
return defaultDisplay[tagName]; | ||
const ele = createElement(tagName); | ||
doc.body.insertBefore(ele, null); | ||
const display = computeStyle(ele, 'display'); | ||
doc.body.removeChild(ele); | ||
return defaultDisplay[tagName] = display !== 'none' ? display : 'block'; | ||
} | ||
// @require css/helpers/compute_style.ts | ||
function isHidden(ele) { | ||
return computeStyle(ele, 'display') === 'none'; | ||
} | ||
const displayProperty = '___cd'; | ||
@@ -573,9 +914,7 @@ fn.toggle = function (force) { | ||
}; | ||
// @optional ./hide.ts | ||
// @optional ./show.ts | ||
// @optional ./toggle.ts | ||
function hasNamespaces(ns1, ns2) { | ||
return !ns2 || !some.call(ns2, (ns) => ns1.indexOf(ns) < 0); | ||
} | ||
const eventsNamespace = '___ce', eventsNamespacesSeparator = '.', eventsFocus = { focus: 'focusin', blur: 'focusout' }, eventsHover = { mouseenter: 'mouseover', mouseleave: 'mouseout' }, eventsMouseRe = /^(mouse|pointer|contextmenu|drag|drop|click|dblclick)/i; | ||
const eventsNamespace = '___ce'; | ||
const eventsNamespacesSeparator = '.'; | ||
const eventsFocus = { focus: 'focusin', blur: 'focusout' }; | ||
const eventsHover = { mouseenter: 'mouseover', mouseleave: 'mouseout' }; | ||
const eventsMouseRe = /^(mouse|pointer|contextmenu|drag|drop|click|dblclick)/i; | ||
// @require ./variables.ts | ||
@@ -586,2 +925,30 @@ function getEventNameBubbling(name) { | ||
// @require ./variables.ts | ||
function parseEventName(eventName) { | ||
const parts = eventName.split(eventsNamespacesSeparator); | ||
return [parts[0], parts.slice(1).sort()]; // [name, namespace[]] | ||
} | ||
fn.trigger = function (event, data) { | ||
if (isString(event)) { | ||
const [nameOriginal, namespaces] = parseEventName(event); | ||
const name = getEventNameBubbling(nameOriginal); | ||
if (!name) | ||
return this; | ||
const type = eventsMouseRe.test(name) ? 'MouseEvents' : 'HTMLEvents'; | ||
event = doc.createEvent(type); | ||
event.initEvent(name, true, true); | ||
event.namespace = namespaces.join(eventsNamespacesSeparator); | ||
event.___ot = nameOriginal; | ||
} | ||
event.___td = data; | ||
const isEventFocus = (event.___ot in eventsFocus); | ||
return this.each((i, ele) => { | ||
if (isEventFocus && isFunction(ele[event.___ot])) { | ||
ele[`___i${event.type}`] = true; // Ensuring the native event is ignored | ||
ele[event.___ot](); | ||
ele[`___i${event.type}`] = false; // Ensuring the custom event is not ignored | ||
} | ||
ele.dispatchEvent(event); | ||
}); | ||
}; | ||
// @require ./variables.ts | ||
function getEventsCache(ele) { | ||
@@ -598,6 +965,4 @@ return ele[eventsNamespace] = (ele[eventsNamespace] || {}); | ||
} | ||
// @require ./variables.ts | ||
function parseEventName(eventName) { | ||
const parts = eventName.split(eventsNamespacesSeparator); | ||
return [parts[0], parts.slice(1).sort()]; // [name, namespace[]] | ||
function hasNamespaces(ns1, ns2) { | ||
return !ns2 || !some.call(ns2, (ns) => ns1.indexOf(ns) < 0); | ||
} | ||
@@ -641,3 +1006,4 @@ // @require ./get_events_cache.ts | ||
each(getSplitValues(eventFullName), (i, eventFullName) => { | ||
const [nameOriginal, namespaces] = parseEventName(eventFullName), name = getEventNameBubbling(nameOriginal); | ||
const [nameOriginal, namespaces] = parseEventName(eventFullName); | ||
const name = getEventNameBubbling(nameOriginal); | ||
this.each((i, ele) => { | ||
@@ -652,2 +1018,13 @@ if (!isElement(ele) && !isDocument(ele) && !isWindow(ele)) | ||
}; | ||
fn.remove = function (comparator) { | ||
filtered(this, comparator).detach().off(); | ||
return this; | ||
}; | ||
fn.replaceWith = function (selector) { | ||
return this.before(selector).remove(); | ||
}; | ||
fn.replaceAll = function (selector) { | ||
cash(selector).replaceWith(this); | ||
return this; | ||
}; | ||
function on(eventFullName, selector, data, callback, _one) { | ||
@@ -681,3 +1058,6 @@ if (!isString(eventFullName)) { | ||
each(getSplitValues(eventFullName), (i, eventFullName) => { | ||
const [nameOriginal, namespaces] = parseEventName(eventFullName), name = getEventNameBubbling(nameOriginal), isEventHover = (nameOriginal in eventsHover), isEventFocus = (nameOriginal in eventsFocus); | ||
const [nameOriginal, namespaces] = parseEventName(eventFullName); | ||
const name = getEventNameBubbling(nameOriginal); | ||
const isEventHover = (nameOriginal in eventsHover); | ||
const isEventFocus = (nameOriginal in eventsFocus); | ||
if (!name) | ||
@@ -746,51 +1126,9 @@ return; | ||
fn.one = one; | ||
fn.ready = function (callback) { | ||
const cb = () => setTimeout(callback, 0, cash); | ||
if (doc.readyState !== 'loading') { | ||
cb(); | ||
} | ||
else { | ||
doc.addEventListener('DOMContentLoaded', cb); | ||
} | ||
return this; | ||
}; | ||
fn.trigger = function (event, data) { | ||
if (isString(event)) { | ||
const [nameOriginal, namespaces] = parseEventName(event), name = getEventNameBubbling(nameOriginal); | ||
if (!name) | ||
return this; | ||
const type = eventsMouseRe.test(name) ? 'MouseEvents' : 'HTMLEvents'; | ||
event = doc.createEvent(type); | ||
event.initEvent(name, true, true); | ||
event.namespace = namespaces.join(eventsNamespacesSeparator); | ||
event.___ot = nameOriginal; | ||
} | ||
event.___td = data; | ||
const isEventFocus = (event.___ot in eventsFocus); | ||
return this.each((i, ele) => { | ||
if (isEventFocus && isFunction(ele[event.___ot])) { | ||
ele[`___i${event.type}`] = true; // Ensuring the native event is ignored | ||
ele[event.___ot](); | ||
ele[`___i${event.type}`] = false; // Ensuring the custom event is not ignored | ||
} | ||
ele.dispatchEvent(event); | ||
}); | ||
}; | ||
// @optional ./off.ts | ||
// @optional ./on.ts | ||
// @optional ./one.ts | ||
// @optional ./ready.ts | ||
// @optional ./trigger.ts | ||
// @require core/pluck.ts | ||
// @require core/variables.ts | ||
function getValue(ele) { | ||
if (ele.multiple && ele.options) | ||
return pluck(filter.call(ele.options, option => option.selected && !option.disabled && !option.parentNode.disabled), 'value'); | ||
return ele.value || ''; | ||
} | ||
const queryEncodeSpaceRe = /%20/g, queryEncodeCRLFRe = /\r?\n/g; | ||
const queryEncodeSpaceRe = /%20/g; | ||
const queryEncodeCRLFRe = /\r?\n/g; | ||
function queryEncode(prop, value) { | ||
return `&${encodeURIComponent(prop)}=${encodeURIComponent(value.replace(queryEncodeCRLFRe, '\r\n')).replace(queryEncodeSpaceRe, '+')}`; | ||
} | ||
const skippableRe = /file|reset|submit|button|image/i, checkableRe = /radio|checkbox/i; | ||
const skippableRe = /file|reset|submit|button|image/i; | ||
const checkableRe = /radio|checkbox/i; | ||
fn.serialize = function () { | ||
@@ -813,338 +1151,90 @@ let query = ''; | ||
}; | ||
function val(value) { | ||
if (!arguments.length) | ||
return this[0] && getValue(this[0]); | ||
return this.each((i, ele) => { | ||
const isSelect = ele.multiple && ele.options; | ||
if (isSelect || checkableRe.test(ele.type)) { | ||
const eleValue = isArray(value) ? map.call(value, String) : (isNull(value) ? [] : [String(value)]); | ||
if (isSelect) { | ||
each(ele.options, (i, option) => { | ||
option.selected = eleValue.indexOf(option.value) >= 0; | ||
}, true); | ||
} | ||
else { | ||
ele.checked = eleValue.indexOf(ele.value) >= 0; | ||
} | ||
} | ||
else { | ||
ele.value = isUndefined(value) || isNull(value) ? '' : value; | ||
} | ||
}); | ||
} | ||
fn.val = val; | ||
fn.clone = function () { | ||
return this.map((i, ele) => ele.cloneNode(true)); | ||
}; | ||
fn.detach = function (comparator) { | ||
filtered(this, comparator).each((i, ele) => { | ||
if (ele.parentNode) { | ||
ele.parentNode.removeChild(ele); | ||
} | ||
}); | ||
return this; | ||
}; | ||
const fragmentRe = /^\s*<(\w+)[^>]*>/, singleTagRe = /^<(\w+)\s*\/?>(?:<\/\1>)?$/; | ||
const containers = { | ||
'*': div, | ||
tr: tbody, | ||
td: tr, | ||
th: tr, | ||
thead: table, | ||
tbody: table, | ||
tfoot: table | ||
}; | ||
//TODO: Create elements inside a document fragment, in order to prevent inline event handlers from firing | ||
//TODO: Ensure the created elements have the fragment as their parent instead of null, this also ensures we can deal with detatched nodes more reliably | ||
function parseHTML(html) { | ||
if (!isString(html)) | ||
return []; | ||
if (singleTagRe.test(html)) | ||
return [createElement(RegExp.$1)]; | ||
const fragment = fragmentRe.test(html) && RegExp.$1, container = containers[fragment] || containers['*']; | ||
container.innerHTML = html; | ||
return cash(container.childNodes).detach().get(); | ||
} | ||
cash.parseHTML = parseHTML; | ||
fn.empty = function () { | ||
return this.each((i, ele) => { | ||
while (ele.firstChild) { | ||
ele.removeChild(ele.firstChild); | ||
} | ||
}); | ||
}; | ||
function html(html) { | ||
if (!arguments.length) | ||
return this[0] && this[0].innerHTML; | ||
if (isUndefined(html)) | ||
return this; | ||
return this.each((i, ele) => { | ||
if (!isElement(ele)) | ||
return; | ||
ele.innerHTML = html; | ||
}); | ||
} | ||
fn.html = html; | ||
fn.remove = function (comparator) { | ||
filtered(this, comparator).detach().off(); | ||
return this; | ||
}; | ||
function text(text) { | ||
if (isUndefined(text)) | ||
return this[0] ? this[0].textContent : ''; | ||
return this.each((i, ele) => { | ||
if (!isElement(ele)) | ||
return; | ||
ele.textContent = text; | ||
}); | ||
} | ||
; | ||
fn.text = text; | ||
fn.unwrap = function () { | ||
this.parent().each((i, ele) => { | ||
if (ele.tagName === 'BODY') | ||
return; | ||
const $ele = cash(ele); | ||
$ele.replaceWith($ele.children()); | ||
}); | ||
return this; | ||
}; | ||
fn.offset = function () { | ||
const ele = this[0]; | ||
if (!ele) | ||
return; | ||
const rect = ele.getBoundingClientRect(); | ||
return { | ||
top: rect.top + win.pageYOffset, | ||
left: rect.left + win.pageXOffset | ||
}; | ||
}; | ||
fn.offsetParent = function () { | ||
return this.map((i, ele) => { | ||
let offsetParent = ele.offsetParent; | ||
while (offsetParent && computeStyle(offsetParent, 'position') === 'static') { | ||
offsetParent = offsetParent.offsetParent; | ||
} | ||
return offsetParent || docEle; | ||
}); | ||
}; | ||
fn.position = function () { | ||
const ele = this[0]; | ||
if (!ele) | ||
return; | ||
const isFixed = (computeStyle(ele, 'position') === 'fixed'), offset = isFixed ? ele.getBoundingClientRect() : this.offset(); | ||
if (!isFixed) { | ||
const doc = ele.ownerDocument; | ||
let offsetParent = ele.offsetParent || doc.documentElement; | ||
while ((offsetParent === doc.body || offsetParent === doc.documentElement) && computeStyle(offsetParent, 'position') === 'static') { | ||
offsetParent = offsetParent.parentNode; | ||
} | ||
if (offsetParent !== ele && isElement(offsetParent)) { | ||
const parentOffset = cash(offsetParent).offset(); | ||
offset.top -= parentOffset.top + computeStyleInt(offsetParent, 'borderTopWidth'); | ||
offset.left -= parentOffset.left + computeStyleInt(offsetParent, 'borderLeftWidth'); | ||
} | ||
} | ||
return { | ||
top: offset.top - computeStyleInt(ele, 'marginTop'), | ||
left: offset.left - computeStyleInt(ele, 'marginLeft') | ||
}; | ||
}; | ||
fn.children = function (comparator) { | ||
return filtered(cash(unique(pluck(this, ele => ele.children))), comparator); | ||
}; | ||
fn.contents = function () { | ||
return cash(unique(pluck(this, ele => ele.tagName === 'IFRAME' ? [ele.contentDocument] : (ele.tagName === 'TEMPLATE' ? ele.content.childNodes : ele.childNodes)))); | ||
}; | ||
fn.find = function (selector) { | ||
return cash(unique(pluck(this, ele => find(selector, ele)))); | ||
}; | ||
// @require core/types.ts | ||
// @require core/cash.ts | ||
// @require core/type_checking.ts | ||
// @require core/variables.ts | ||
// @require core/each.ts | ||
// @require core/extend.ts | ||
// @require core/find.ts | ||
// @require core/get_compare_function.ts | ||
// @require core/get_split_values.ts | ||
// @require core/guid.ts | ||
// @require core/parse_html.ts | ||
// @require core/unique.ts | ||
// @require attributes/add_class.ts | ||
// @require attributes/attr.ts | ||
// @require attributes/has_class.ts | ||
// @require attributes/prop.ts | ||
// @require attributes/remove_attr.ts | ||
// @require attributes/remove_class.ts | ||
// @require attributes/remove_prop.ts | ||
// @require attributes/toggle_class.ts | ||
// @require collection/add.ts | ||
// @require collection/each.ts | ||
// @require collection/eq.ts | ||
// @require collection/filter.ts | ||
// @require collection/first.ts | ||
// @require collection/get.ts | ||
// @require collection/index.ts | ||
// @require collection/last.ts | ||
// @require collection/map.ts | ||
// @require collection/slice.ts | ||
// @require css/css.ts | ||
// @require data/data.ts | ||
// @require dimensions/inner_outer.ts | ||
// @require dimensions/normal.ts | ||
// @require effects/hide.ts | ||
// @require effects/show.ts | ||
// @require effects/toggle.ts | ||
// @require events/off.ts | ||
// @require events/on.ts | ||
// @require events/one.ts | ||
// @require events/ready.ts | ||
// @require events/trigger.ts | ||
// @require forms/serialize.ts | ||
// @require forms/val.ts | ||
// @require manipulation/after.ts | ||
// @require manipulation/append.ts | ||
// @require manipulation/append_to.ts | ||
// @require manipulation/before.ts | ||
// @require manipulation/clone.ts | ||
// @require manipulation/detach.ts | ||
// @require manipulation/empty.ts | ||
// @require manipulation/html.ts | ||
// @require manipulation/insert_after.ts | ||
// @require manipulation/insert_before.ts | ||
// @require manipulation/prepend.ts | ||
// @require manipulation/prepend_to.ts | ||
// @require manipulation/remove.ts | ||
// @require manipulation/replace_all.ts | ||
// @require manipulation/replace_with.ts | ||
// @require manipulation/text.ts | ||
// @require manipulation/unwrap.ts | ||
// @require manipulation/wrap.ts | ||
// @require manipulation/wrap_all.ts | ||
// @require manipulation/wrap_inner.ts | ||
// @require offset/offset.ts | ||
// @require offset/offset_parent.ts | ||
// @require offset/position.ts | ||
// @require traversal/children.ts | ||
// @require traversal/closest.ts | ||
// @require traversal/contents.ts | ||
// @require traversal/find.ts | ||
const HTMLCDATARe = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g, scriptTypeRe = /^$|^module$|\/(java|ecma)script/i, scriptAttributes = ['type', 'src', 'nonce', 'noModule']; | ||
function evalScripts(node, doc) { | ||
const collection = cash(node); | ||
collection.filter('script').add(collection.find('script')).each((i, ele) => { | ||
if (scriptTypeRe.test(ele.type) && docEle.contains(ele)) { // The script type is supported // The element is attached to the DOM // Using `documentElement` for broader browser support | ||
const script = createElement('script'); | ||
script.text = ele.textContent.replace(HTMLCDATARe, ''); | ||
each(scriptAttributes, (i, attr) => { | ||
if (ele[attr]) | ||
script[attr] = ele[attr]; | ||
}); | ||
doc.head.insertBefore(script, null); | ||
doc.head.removeChild(script); | ||
} | ||
}); | ||
} | ||
// @require ./eval_scripts.ts | ||
function insertElement(anchor, target, left, inside, evaluate) { | ||
if (inside) { // prepend/append | ||
anchor.insertBefore(target, left ? anchor.firstChild : null); | ||
} | ||
else { // before/after | ||
if (anchor.nodeName === 'HTML') { | ||
anchor.parentNode.replaceChild(target, anchor); | ||
} | ||
else { | ||
anchor.parentNode.insertBefore(target, left ? anchor : anchor.nextSibling); | ||
} | ||
} | ||
if (evaluate) { | ||
evalScripts(target, anchor.ownerDocument); | ||
} | ||
} | ||
// @require ./insert_element.ts | ||
function insertSelectors(selectors, anchors, inverse, left, inside, reverseLoop1, reverseLoop2, reverseLoop3) { | ||
each(selectors, (si, selector) => { | ||
each(cash(selector), (ti, target) => { | ||
each(cash(anchors), (ai, anchor) => { | ||
const anchorFinal = inverse ? target : anchor, targetFinal = inverse ? anchor : target, indexFinal = inverse ? ti : ai; | ||
insertElement(anchorFinal, !indexFinal ? targetFinal : targetFinal.cloneNode(true), left, inside, !indexFinal); | ||
}, reverseLoop3); | ||
}, reverseLoop2); | ||
}, reverseLoop1); | ||
return anchors; | ||
} | ||
fn.after = function () { | ||
return insertSelectors(arguments, this, false, false, false, true, true); | ||
}; | ||
fn.append = function () { | ||
return insertSelectors(arguments, this, false, false, true); | ||
}; | ||
fn.appendTo = function (selector) { | ||
return insertSelectors(arguments, this, true, false, true); | ||
}; | ||
fn.before = function () { | ||
return insertSelectors(arguments, this, false, true); | ||
}; | ||
fn.insertAfter = function (selector) { | ||
return insertSelectors(arguments, this, true, false, false, false, false, true); | ||
}; | ||
fn.insertBefore = function (selector) { | ||
return insertSelectors(arguments, this, true, true); | ||
}; | ||
fn.prepend = function () { | ||
return insertSelectors(arguments, this, false, true, true, true, true); | ||
}; | ||
fn.prependTo = function (selector) { | ||
return insertSelectors(arguments, this, true, true, true, false, false, true); | ||
}; | ||
fn.replaceWith = function (selector) { | ||
return this.before(selector).remove(); | ||
}; | ||
fn.replaceAll = function (selector) { | ||
cash(selector).replaceWith(this); | ||
return this; | ||
}; | ||
fn.wrapAll = function (selector) { | ||
let structure = cash(selector), wrapper = structure[0]; | ||
while (wrapper.children.length) | ||
wrapper = wrapper.firstElementChild; | ||
this.first().before(structure); | ||
return this.appendTo(wrapper); | ||
}; | ||
fn.wrap = function (selector) { | ||
return this.each((i, ele) => { | ||
const wrapper = cash(selector)[0]; | ||
cash(ele).wrapAll(!i ? wrapper : wrapper.cloneNode(true)); | ||
}); | ||
}; | ||
fn.wrapInner = function (selector) { | ||
return this.each((i, ele) => { | ||
const $ele = cash(ele), contents = $ele.contents(); | ||
contents.length ? contents.wrapAll(selector) : $ele.append(selector); | ||
}); | ||
}; | ||
fn.has = function (selector) { | ||
const comparator = isString(selector) | ||
? (i, ele) => find(selector, ele).length | ||
: (i, ele) => ele.contains(selector); | ||
return this.filter(comparator); | ||
}; | ||
fn.is = function (comparator) { | ||
const compare = getCompareFunction(comparator); | ||
return some.call(this, (ele, i) => compare.call(ele, i, ele)); | ||
}; | ||
fn.next = function (comparator, _all, _until) { | ||
return filtered(cash(unique(pluck(this, 'nextElementSibling', _all, _until))), comparator); | ||
}; | ||
fn.nextAll = function (comparator) { | ||
return this.next(comparator, true); | ||
}; | ||
fn.nextUntil = function (until, comparator) { | ||
return this.next(comparator, true, until); | ||
}; | ||
fn.not = function (comparator) { | ||
const compare = getCompareFunction(comparator); | ||
return this.filter((i, ele) => (!isString(comparator) || isElement(ele)) && !compare.call(ele, i, ele)); | ||
}; | ||
fn.parent = function (comparator) { | ||
return filtered(cash(unique(pluck(this, 'parentNode'))), comparator); | ||
}; | ||
fn.index = function (selector) { | ||
const child = selector ? cash(selector)[0] : this[0], collection = selector ? this : cash(child).parent().children(); | ||
return indexOf.call(collection, child); | ||
}; | ||
fn.closest = function (comparator) { | ||
const filtered = this.filter(comparator); | ||
if (filtered.length) | ||
return filtered; | ||
const $parent = this.parent(); | ||
if (!$parent.length) | ||
return filtered; | ||
return $parent.closest(comparator); | ||
}; | ||
fn.parents = function (comparator, _until) { | ||
return filtered(cash(unique(pluck(this, 'parentElement', true, _until))), comparator); | ||
}; | ||
fn.parentsUntil = function (until, comparator) { | ||
return this.parents(comparator, until); | ||
}; | ||
fn.prev = function (comparator, _all, _until) { | ||
return filtered(cash(unique(pluck(this, 'previousElementSibling', _all, _until))), comparator); | ||
}; | ||
fn.prevAll = function (comparator) { | ||
return this.prev(comparator, true); | ||
}; | ||
fn.prevUntil = function (until, comparator) { | ||
return this.prev(comparator, true, until); | ||
}; | ||
fn.siblings = function (comparator) { | ||
return filtered(cash(unique(pluck(this, ele => cash(ele).parent().children().not(ele)))), comparator); | ||
}; | ||
// @optional ./children.ts | ||
// @optional ./closest.ts | ||
// @optional ./contents.ts | ||
// @optional ./find.ts | ||
// @optional ./has.ts | ||
// @optional ./is.ts | ||
// @optional ./next.ts | ||
// @optional ./next_all.ts | ||
// @optional ./next_until.ts | ||
// @optional ./not.ts | ||
// @optional ./parent.ts | ||
// @optional ./parents.ts | ||
// @optional ./parents_until.ts | ||
// @optional ./prev.ts | ||
// @optional ./prev_all.ts | ||
// @optional ./prev_until.ts | ||
// @optional ./siblings.ts | ||
// @optional attributes/index.ts | ||
// @optional collection/index.ts | ||
// @optional css/index.ts | ||
// @optional data/index.ts | ||
// @optional dimensions/index.ts | ||
// @optional effects/index.ts | ||
// @optional events/index.ts | ||
// @optional forms/index.ts | ||
// @optional manipulation/index.ts | ||
// @optional offset/index.ts | ||
// @optional traversal/index.ts | ||
// @require core/index.ts | ||
// @priority -100 | ||
// @require ./cash.ts | ||
// @require traversal/has.ts | ||
// @require traversal/is.ts | ||
// @require traversal/next.ts | ||
// @require traversal/next_all.ts | ||
// @require traversal/next_until.ts | ||
// @require traversal/not.ts | ||
// @require traversal/parent.ts | ||
// @require traversal/parents.ts | ||
// @require traversal/parents_until.ts | ||
// @require traversal/prev.ts | ||
// @require traversal/prev_all.ts | ||
// @require traversal/prev_until.ts | ||
// @require traversal/siblings.ts | ||
// @no-require extras/get_script.ts | ||
// @no-require extras/shorthands.ts | ||
// @require methods.ts | ||
export default cash; | ||
export { Cash }; | ||
2337
dist/cash.js
@@ -1,183 +0,109 @@ | ||
/* MIT https://github.com/fabiospampinato/cash */ | ||
(function(){ | ||
"use strict"; | ||
var propMap = { | ||
/* GENERAL */ | ||
"class": 'className', | ||
contenteditable: 'contentEditable', | ||
/* LABEL */ | ||
"for": 'htmlFor', | ||
/* INPUT */ | ||
readonly: 'readOnly', | ||
maxlength: 'maxLength', | ||
tabindex: 'tabIndex', | ||
/* TABLE */ | ||
colspan: 'colSpan', | ||
rowspan: 'rowSpan', | ||
/* IMAGE */ | ||
usemap: 'useMap' | ||
}; | ||
function attempt(fn, arg) { | ||
try { | ||
return fn(arg); | ||
} catch (_a) { | ||
return arg; | ||
} | ||
var doc = document; | ||
var win = window; | ||
var docEle = doc.documentElement; | ||
var createElement = doc.createElement.bind(doc); | ||
var div = createElement('div'); | ||
var table = createElement('table'); | ||
var tbody = createElement('tbody'); | ||
var tr = createElement('tr'); | ||
var isArray = Array.isArray, ArrayPrototype = Array.prototype; | ||
var concat = ArrayPrototype.concat, filter = ArrayPrototype.filter, indexOf = ArrayPrototype.indexOf, map = ArrayPrototype.map, push = ArrayPrototype.push, slice = ArrayPrototype.slice, some = ArrayPrototype.some, splice = ArrayPrototype.splice; | ||
var idRe = /^#(?:[\w-]|\\.|[^\x00-\xa0])*$/; | ||
var classRe = /^\.(?:[\w-]|\\.|[^\x00-\xa0])*$/; | ||
var htmlRe = /<.+>/; | ||
var tagRe = /^\w+$/; | ||
// @require ./variables.ts | ||
function find(selector, context) { | ||
var isFragment = isDocumentFragment(context); | ||
return !selector || (!isFragment && !isDocument(context) && !isElement(context)) | ||
? [] | ||
: !isFragment && classRe.test(selector) | ||
? context.getElementsByClassName(selector.slice(1).replace(/\\/g, '')) | ||
: !isFragment && tagRe.test(selector) | ||
? context.getElementsByTagName(selector) | ||
: context.querySelectorAll(selector); | ||
} | ||
var doc = document, | ||
win = window, | ||
docEle = doc.documentElement, | ||
createElement = doc.createElement.bind(doc), | ||
div = createElement('div'), | ||
table = createElement('table'), | ||
tbody = createElement('tbody'), | ||
tr = createElement('tr'), | ||
isArray = Array.isArray, | ||
ArrayPrototype = Array.prototype, | ||
concat = ArrayPrototype.concat, | ||
filter = ArrayPrototype.filter, | ||
indexOf = ArrayPrototype.indexOf, | ||
map = ArrayPrototype.map, | ||
push = ArrayPrototype.push, | ||
slice = ArrayPrototype.slice, | ||
some = ArrayPrototype.some, | ||
splice = ArrayPrototype.splice; | ||
var idRe = /^#(?:[\w-]|\\.|[^\x00-\xa0])*$/, | ||
classRe = /^\.(?:[\w-]|\\.|[^\x00-\xa0])*$/, | ||
htmlRe = /<.+>/, | ||
tagRe = /^\w+$/; // @require ./variables.ts | ||
function find(selector, context) { | ||
var isFragment = isDocumentFragment(context); | ||
return !selector || !isFragment && !isDocument(context) && !isElement(context) ? [] : !isFragment && classRe.test(selector) ? context.getElementsByClassName(selector.slice(1)) : !isFragment && tagRe.test(selector) ? context.getElementsByTagName(selector) : context.querySelectorAll(selector); | ||
} // @require ./find.ts | ||
// @require ./find.ts | ||
// @require ./variables.ts | ||
var Cash = | ||
/** @class */ | ||
function () { | ||
function Cash(selector, context) { | ||
if (!selector) return; | ||
if (isCash(selector)) return selector; | ||
var eles = selector; | ||
if (isString(selector)) { | ||
var ctx = (isCash(context) ? context[0] : context) || doc; | ||
eles = idRe.test(selector) && 'getElementById' in ctx ? ctx.getElementById(selector.slice(1)) : htmlRe.test(selector) ? parseHTML(selector) : find(selector, ctx); | ||
if (!eles) return; | ||
} else if (isFunction(selector)) { | ||
return this.ready(selector); //FIXME: `fn.ready` is not included in `core`, but it's actually a core functionality | ||
var Cash = /** @class */ (function () { | ||
function Cash(selector, context) { | ||
if (!selector) | ||
return; | ||
if (isCash(selector)) | ||
return selector; | ||
var eles = selector; | ||
if (isString(selector)) { | ||
var ctx = (isCash(context) ? context[0] : context) || doc; | ||
eles = idRe.test(selector) && 'getElementById' in ctx | ||
? ctx.getElementById(selector.slice(1).replace(/\\/g, '')) | ||
: htmlRe.test(selector) | ||
? parseHTML(selector) | ||
: find(selector, ctx); | ||
if (!eles) | ||
return; | ||
} | ||
else if (isFunction(selector)) { | ||
return this.ready(selector); //FIXME: `fn.ready` is not included in `core`, but it's actually a core functionality | ||
} | ||
if (eles.nodeType || eles === win) | ||
eles = [eles]; | ||
this.length = eles.length; | ||
for (var i = 0, l = this.length; i < l; i++) { | ||
this[i] = eles[i]; | ||
} | ||
} | ||
if (eles.nodeType || eles === win) eles = [eles]; | ||
this.length = eles.length; | ||
for (var i = 0, l = this.length; i < l; i++) { | ||
this[i] = eles[i]; | ||
} | ||
} | ||
Cash.prototype.init = function (selector, context) { | ||
return new Cash(selector, context); | ||
}; | ||
return Cash; | ||
}(); | ||
var fn = Cash.prototype, | ||
cash = fn.init; | ||
Cash.prototype.init = function (selector, context) { | ||
return new Cash(selector, context); | ||
}; | ||
return Cash; | ||
}()); | ||
var fn = Cash.prototype; | ||
var cash = fn.init; | ||
cash.fn = cash.prototype = fn; // Ensuring that `cash () instanceof cash` | ||
fn.length = 0; | ||
fn.splice = splice; // Ensuring a cash collection gets printed as array-like in Chrome's devtools | ||
if (typeof Symbol === 'function') { | ||
// Ensuring a cash collection is iterable | ||
fn[Symbol['iterator']] = ArrayPrototype[Symbol['iterator']]; | ||
if (typeof Symbol === 'function') { // Ensuring a cash collection is iterable | ||
fn[Symbol['iterator']] = ArrayPrototype[Symbol['iterator']]; | ||
} | ||
fn.map = function (callback) { | ||
return cash(concat.apply([], map.call(this, function (ele, i) { | ||
return callback.call(ele, i, ele); | ||
}))); | ||
}; | ||
fn.slice = function (start, end) { | ||
return cash(slice.call(this, start, end)); | ||
}; // @require ./cash.ts | ||
var dashAlphaRe = /-([a-z])/g; | ||
function camelCase(str) { | ||
return str.replace(dashAlphaRe, function (match, letter) { | ||
return letter.toUpperCase(); | ||
}); | ||
function isCash(value) { | ||
return value instanceof Cash; | ||
} | ||
cash.guid = 1; // @require ./cash.ts | ||
function matches(ele, selector) { | ||
var matches = ele && (ele['matches'] || ele['webkitMatchesSelector'] || ele['msMatchesSelector']); | ||
return !!matches && !!selector && matches.call(ele, selector); | ||
function isWindow(value) { | ||
return !!value && value === value.window; | ||
} | ||
function isCash(x) { | ||
return x instanceof Cash; | ||
function isDocument(value) { | ||
return !!value && value.nodeType === 9; | ||
} | ||
function isWindow(x) { | ||
return !!x && x === x.window; | ||
function isDocumentFragment(value) { | ||
return !!value && value.nodeType === 11; | ||
} | ||
function isDocument(x) { | ||
return !!x && x.nodeType === 9; | ||
function isElement(value) { | ||
return !!value && value.nodeType === 1; | ||
} | ||
function isDocumentFragment(x) { | ||
return !!x && x.nodeType === 11; | ||
function isBoolean(value) { | ||
return typeof value === 'boolean'; | ||
} | ||
function isElement(x) { | ||
return !!x && x.nodeType === 1; | ||
function isFunction(value) { | ||
return typeof value === 'function'; | ||
} | ||
function isBoolean(x) { | ||
return typeof x === 'boolean'; | ||
function isString(value) { | ||
return typeof value === 'string'; | ||
} | ||
function isFunction(x) { | ||
return typeof x === 'function'; | ||
function isUndefined(value) { | ||
return value === undefined; | ||
} | ||
function isString(x) { | ||
return typeof x === 'string'; | ||
function isNull(value) { | ||
return value === null; | ||
} | ||
function isUndefined(x) { | ||
return x === undefined; | ||
function isNumeric(value) { | ||
return !isNaN(parseFloat(value)) && isFinite(value); | ||
} | ||
function isNull(x) { | ||
return x === null; | ||
function isPlainObject(value) { | ||
if (typeof value !== 'object' || value === null) | ||
return false; | ||
var proto = Object.getPrototypeOf(value); | ||
return proto === null || proto === Object.prototype; | ||
} | ||
function isNumeric(x) { | ||
return !isNaN(parseFloat(x)) && isFinite(x); | ||
} | ||
function isPlainObject(x) { | ||
if (typeof x !== 'object' || x === null) return false; | ||
var proto = Object.getPrototypeOf(x); | ||
return proto === null || proto === Object.prototype; | ||
} | ||
cash.isWindow = isWindow; | ||
@@ -188,262 +114,606 @@ cash.isFunction = isFunction; | ||
cash.isPlainObject = isPlainObject; | ||
fn.get = function (index) { | ||
if (isUndefined(index)) return slice.call(this); | ||
index = Number(index); | ||
return this[index < 0 ? index + this.length : index]; | ||
}; | ||
fn.eq = function (index) { | ||
return cash(this.get(index)); | ||
}; | ||
fn.first = function () { | ||
return this.eq(0); | ||
}; | ||
fn.last = function () { | ||
return this.eq(-1); | ||
}; | ||
function each(arr, callback, _reverse) { | ||
if (_reverse) { | ||
var i = arr.length; | ||
while (i--) { | ||
if (callback.call(arr[i], i, arr[i]) === false) return arr; | ||
if (_reverse) { | ||
var i = arr.length; | ||
while (i--) { | ||
if (callback.call(arr[i], i, arr[i]) === false) | ||
return arr; | ||
} | ||
} | ||
} else if (isPlainObject(arr)) { | ||
var keys = Object.keys(arr); | ||
for (var i = 0, l = keys.length; i < l; i++) { | ||
var key = keys[i]; | ||
if (callback.call(arr[key], key, arr[key]) === false) return arr; | ||
else if (isPlainObject(arr)) { | ||
var keys = Object.keys(arr); | ||
for (var i = 0, l = keys.length; i < l; i++) { | ||
var key = keys[i]; | ||
if (callback.call(arr[key], key, arr[key]) === false) | ||
return arr; | ||
} | ||
} | ||
} else { | ||
for (var i = 0, l = arr.length; i < l; i++) { | ||
if (callback.call(arr[i], i, arr[i]) === false) return arr; | ||
else { | ||
for (var i = 0, l = arr.length; i < l; i++) { | ||
if (callback.call(arr[i], i, arr[i]) === false) | ||
return arr; | ||
} | ||
} | ||
} | ||
return arr; | ||
return arr; | ||
} | ||
cash.each = each; | ||
fn.each = function (callback) { | ||
return each(this, callback); | ||
return each(this, callback); | ||
}; | ||
fn.prop = function (prop, value) { | ||
if (!prop) return; | ||
if (isString(prop)) { | ||
prop = propMap[prop] || prop; | ||
if (arguments.length < 2) return this[0] && this[0][prop]; | ||
fn.empty = function () { | ||
return this.each(function (i, ele) { | ||
ele[prop] = value; | ||
while (ele.firstChild) { | ||
ele.removeChild(ele.firstChild); | ||
} | ||
}); | ||
} | ||
for (var key in prop) { | ||
this.prop(key, prop[key]); | ||
} | ||
return this; | ||
}; | ||
fn.removeProp = function (prop) { | ||
return this.each(function (i, ele) { | ||
delete ele[propMap[prop] || prop]; | ||
}); | ||
}; | ||
function text(text) { | ||
if (isUndefined(text)) | ||
return this[0] ? this[0].textContent : ''; | ||
return this.each(function (i, ele) { | ||
if (!isElement(ele)) | ||
return; | ||
ele.textContent = text; | ||
}); | ||
} | ||
; | ||
fn.text = text; | ||
function extend() { | ||
var sources = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
sources[_i] = arguments[_i]; | ||
} | ||
var deep = isBoolean(sources[0]) ? sources.shift() : false, | ||
target = sources.shift(), | ||
length = sources.length; | ||
if (!target) return {}; | ||
if (!length) return extend(deep, cash, target); | ||
for (var i = 0; i < length; i++) { | ||
var source = sources[i]; | ||
for (var key in source) { | ||
if (deep && (isArray(source[key]) || isPlainObject(source[key]))) { | ||
if (!target[key] || target[key].constructor !== source[key].constructor) target[key] = new source[key].constructor(); | ||
extend(deep, target[key], source[key]); | ||
} else { | ||
target[key] = source[key]; | ||
} | ||
var sources = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
sources[_i] = arguments[_i]; | ||
} | ||
} | ||
return target; | ||
var deep = isBoolean(sources[0]) ? sources.shift() : false; | ||
var target = sources.shift(); | ||
var length = sources.length; | ||
if (!target) | ||
return {}; | ||
if (!length) | ||
return extend(deep, cash, target); | ||
for (var i = 0; i < length; i++) { | ||
var source = sources[i]; | ||
for (var key in source) { | ||
if (deep && (isArray(source[key]) || isPlainObject(source[key]))) { | ||
if (!target[key] || target[key].constructor !== source[key].constructor) | ||
target[key] = new source[key].constructor(); | ||
extend(deep, target[key], source[key]); | ||
} | ||
else { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
return target; | ||
} | ||
cash.extend = extend; | ||
fn.extend = function (plugins) { | ||
return extend(fn, plugins); | ||
}; // @require ./matches.ts | ||
return extend(fn, plugins); | ||
}; | ||
// @require ./type_checking.ts | ||
function getCompareFunction(comparator) { | ||
return isString(comparator) ? function (i, ele) { | ||
return matches(ele, comparator); | ||
} : isFunction(comparator) ? comparator : isCash(comparator) ? function (i, ele) { | ||
return comparator.is(ele); | ||
} : !comparator ? function () { | ||
return false; | ||
} : function (i, ele) { | ||
return ele === comparator; | ||
}; | ||
} | ||
fn.filter = function (comparator) { | ||
var compare = getCompareFunction(comparator); | ||
return cash(filter.call(this, function (ele, i) { | ||
return compare.call(ele, i, ele); | ||
})); | ||
}; // @require collection/filter.ts | ||
function filtered(collection, comparator) { | ||
return !comparator ? collection : collection.filter(comparator); | ||
} // @require ./type_checking.ts | ||
var splitValuesRe = /\S+/g; | ||
function getSplitValues(str) { | ||
return isString(str) ? str.match(splitValuesRe) || [] : []; | ||
return isString(str) ? str.match(splitValuesRe) || [] : []; | ||
} | ||
fn.hasClass = function (cls) { | ||
return !!cls && some.call(this, function (ele) { | ||
return isElement(ele) && ele.classList.contains(cls); | ||
}); | ||
fn.toggleClass = function (cls, force) { | ||
var classes = getSplitValues(cls); | ||
var isForce = !isUndefined(force); | ||
return this.each(function (i, ele) { | ||
if (!isElement(ele)) | ||
return; | ||
each(classes, function (i, c) { | ||
if (isForce) { | ||
force ? ele.classList.add(c) : ele.classList.remove(c); | ||
} | ||
else { | ||
ele.classList.toggle(c); | ||
} | ||
}); | ||
}); | ||
}; | ||
fn.addClass = function (cls) { | ||
return this.toggleClass(cls, true); | ||
}; | ||
fn.removeAttr = function (attr) { | ||
var attrs = getSplitValues(attr); | ||
return this.each(function (i, ele) { | ||
if (!isElement(ele)) return; | ||
each(attrs, function (i, a) { | ||
ele.removeAttribute(a); | ||
var attrs = getSplitValues(attr); | ||
return this.each(function (i, ele) { | ||
if (!isElement(ele)) | ||
return; | ||
each(attrs, function (i, a) { | ||
ele.removeAttribute(a); | ||
}); | ||
}); | ||
}); | ||
}; | ||
function attr(attr, value) { | ||
if (!attr) return; | ||
if (isString(attr)) { | ||
if (arguments.length < 2) { | ||
if (!this[0] || !isElement(this[0])) return; | ||
var value_1 = this[0].getAttribute(attr); | ||
return isNull(value_1) ? undefined : value_1; | ||
if (!attr) | ||
return; | ||
if (isString(attr)) { | ||
if (arguments.length < 2) { | ||
if (!this[0] || !isElement(this[0])) | ||
return; | ||
var value_1 = this[0].getAttribute(attr); | ||
return isNull(value_1) ? undefined : value_1; | ||
} | ||
if (isUndefined(value)) | ||
return this; | ||
if (isNull(value)) | ||
return this.removeAttr(attr); | ||
return this.each(function (i, ele) { | ||
if (!isElement(ele)) | ||
return; | ||
ele.setAttribute(attr, value); | ||
}); | ||
} | ||
if (isUndefined(value)) return this; | ||
if (isNull(value)) return this.removeAttr(attr); | ||
return this.each(function (i, ele) { | ||
if (!isElement(ele)) return; | ||
ele.setAttribute(attr, value); | ||
}); | ||
} | ||
for (var key in attr) { | ||
this.attr(key, attr[key]); | ||
} | ||
return this; | ||
for (var key in attr) { | ||
this.attr(key, attr[key]); | ||
} | ||
return this; | ||
} | ||
fn.attr = attr; | ||
fn.toggleClass = function (cls, force) { | ||
var classes = getSplitValues(cls), | ||
isForce = !isUndefined(force); | ||
return this.each(function (i, ele) { | ||
if (!isElement(ele)) return; | ||
each(classes, function (i, c) { | ||
if (isForce) { | ||
force ? ele.classList.add(c) : ele.classList.remove(c); | ||
} else { | ||
ele.classList.toggle(c); | ||
} | ||
fn.removeClass = function (cls) { | ||
if (arguments.length) | ||
return this.toggleClass(cls, false); | ||
return this.attr('class', ''); | ||
}; | ||
fn.hasClass = function (cls) { | ||
return !!cls && some.call(this, function (ele) { return isElement(ele) && ele.classList.contains(cls); }); | ||
}; | ||
fn.get = function (index) { | ||
if (isUndefined(index)) | ||
return slice.call(this); | ||
index = Number(index); | ||
return this[index < 0 ? index + this.length : index]; | ||
}; | ||
fn.eq = function (index) { | ||
return cash(this.get(index)); | ||
}; | ||
fn.first = function () { | ||
return this.eq(0); | ||
}; | ||
fn.last = function () { | ||
return this.eq(-1); | ||
}; | ||
// @require core/type_checking.ts | ||
// @require core/variables.ts | ||
function computeStyle(ele, prop, isVariable) { | ||
if (!isElement(ele)) | ||
return; | ||
var style = win.getComputedStyle(ele, null); | ||
return isVariable ? style.getPropertyValue(prop) || undefined : style[prop] || ele.style[prop]; | ||
} | ||
// @require ./compute_style.ts | ||
function computeStyleInt(ele, prop) { | ||
return parseInt(computeStyle(ele, prop), 10) || 0; | ||
} | ||
// @require css/helpers/compute_style_int.ts | ||
function getExtraSpace(ele, xAxis) { | ||
return computeStyleInt(ele, "border".concat(xAxis ? 'Left' : 'Top', "Width")) + computeStyleInt(ele, "padding".concat(xAxis ? 'Left' : 'Top')) + computeStyleInt(ele, "padding".concat(xAxis ? 'Right' : 'Bottom')) + computeStyleInt(ele, "border".concat(xAxis ? 'Right' : 'Bottom', "Width")); | ||
} | ||
// @require css/helpers/compute_style.ts | ||
var defaultDisplay = {}; | ||
function getDefaultDisplay(tagName) { | ||
if (defaultDisplay[tagName]) | ||
return defaultDisplay[tagName]; | ||
var ele = createElement(tagName); | ||
doc.body.insertBefore(ele, null); | ||
var display = computeStyle(ele, 'display'); | ||
doc.body.removeChild(ele); | ||
return defaultDisplay[tagName] = display !== 'none' ? display : 'block'; | ||
} | ||
// @require css/helpers/compute_style.ts | ||
function isHidden(ele) { | ||
return computeStyle(ele, 'display') === 'none'; | ||
} | ||
// @require ./cash.ts | ||
function matches(ele, selector) { | ||
var matches = ele && (ele['matches'] || ele['webkitMatchesSelector'] || ele['msMatchesSelector']); | ||
return !!matches && !!selector && matches.call(ele, selector); | ||
} | ||
// @require ./matches.ts | ||
// @require ./type_checking.ts | ||
function getCompareFunction(comparator) { | ||
return isString(comparator) | ||
? function (i, ele) { return matches(ele, comparator); } | ||
: isFunction(comparator) | ||
? comparator | ||
: isCash(comparator) | ||
? function (i, ele) { return comparator.is(ele); } | ||
: !comparator | ||
? function () { return false; } | ||
: function (i, ele) { return ele === comparator; }; | ||
} | ||
fn.filter = function (comparator) { | ||
var compare = getCompareFunction(comparator); | ||
return cash(filter.call(this, function (ele, i) { return compare.call(ele, i, ele); })); | ||
}; | ||
// @require collection/filter.ts | ||
function filtered(collection, comparator) { | ||
return !comparator ? collection : collection.filter(comparator); | ||
} | ||
fn.detach = function (comparator) { | ||
filtered(this, comparator).each(function (i, ele) { | ||
if (ele.parentNode) { | ||
ele.parentNode.removeChild(ele); | ||
} | ||
}); | ||
}); | ||
return this; | ||
}; | ||
fn.addClass = function (cls) { | ||
return this.toggleClass(cls, true); | ||
var fragmentRe = /^\s*<(\w+)[^>]*>/; | ||
var singleTagRe = /^<(\w+)\s*\/?>(?:<\/\1>)?$/; | ||
var containers = { | ||
'*': div, | ||
tr: tbody, | ||
td: tr, | ||
th: tr, | ||
thead: table, | ||
tbody: table, | ||
tfoot: table | ||
}; | ||
fn.removeClass = function (cls) { | ||
if (arguments.length) return this.toggleClass(cls, false); | ||
return this.attr('class', ''); | ||
//TODO: Create elements inside a document fragment, in order to prevent inline event handlers from firing | ||
//TODO: Ensure the created elements have the fragment as their parent instead of null, this also ensures we can deal with detatched nodes more reliably | ||
function parseHTML(html) { | ||
if (!isString(html)) | ||
return []; | ||
if (singleTagRe.test(html)) | ||
return [createElement(RegExp.$1)]; | ||
var fragment = fragmentRe.test(html) && RegExp.$1; | ||
var container = containers[fragment] || containers['*']; | ||
container.innerHTML = html; | ||
return cash(container.childNodes).detach().get(); | ||
} | ||
cash.parseHTML = parseHTML; | ||
fn.has = function (selector) { | ||
var comparator = isString(selector) | ||
? function (i, ele) { return find(selector, ele).length; } | ||
: function (i, ele) { return ele.contains(selector); }; | ||
return this.filter(comparator); | ||
}; | ||
fn.not = function (comparator) { | ||
var compare = getCompareFunction(comparator); | ||
return this.filter(function (i, ele) { return (!isString(comparator) || isElement(ele)) && !compare.call(ele, i, ele); }); | ||
}; | ||
function pluck(arr, prop, deep, until) { | ||
var plucked = [], | ||
isCallback = isFunction(prop), | ||
compare = until && getCompareFunction(until); | ||
for (var i = 0, l = arr.length; i < l; i++) { | ||
if (isCallback) { | ||
var val_1 = prop(arr[i]); | ||
if (val_1.length) push.apply(plucked, val_1); | ||
} else { | ||
var val_2 = arr[i][prop]; | ||
while (val_2 != null) { | ||
if (until && compare(-1, val_2)) break; | ||
plucked.push(val_2); | ||
val_2 = deep ? val_2[prop] : null; | ||
} | ||
var plucked = []; | ||
var isCallback = isFunction(prop); | ||
var compare = until && getCompareFunction(until); | ||
for (var i = 0, l = arr.length; i < l; i++) { | ||
if (isCallback) { | ||
var val_1 = prop(arr[i]); | ||
if (val_1.length) | ||
push.apply(plucked, val_1); | ||
} | ||
else { | ||
var val_2 = arr[i][prop]; | ||
while (val_2 != null) { | ||
if (until && compare(-1, val_2)) | ||
break; | ||
plucked.push(val_2); | ||
val_2 = deep ? val_2[prop] : null; | ||
} | ||
} | ||
} | ||
} | ||
return plucked; | ||
return plucked; | ||
} | ||
// @require core/pluck.ts | ||
// @require core/variables.ts | ||
function getValue(ele) { | ||
if (ele.multiple && ele.options) | ||
return pluck(filter.call(ele.options, function (option) { return option.selected && !option.disabled && !option.parentNode.disabled; }), 'value'); | ||
return ele.value || ''; | ||
} | ||
function val(value) { | ||
if (!arguments.length) | ||
return this[0] && getValue(this[0]); | ||
return this.each(function (i, ele) { | ||
var isSelect = ele.multiple && ele.options; | ||
if (isSelect || checkableRe.test(ele.type)) { | ||
var eleValue_1 = isArray(value) ? map.call(value, String) : (isNull(value) ? [] : [String(value)]); | ||
if (isSelect) { | ||
each(ele.options, function (i, option) { | ||
option.selected = eleValue_1.indexOf(option.value) >= 0; | ||
}, true); | ||
} | ||
else { | ||
ele.checked = eleValue_1.indexOf(ele.value) >= 0; | ||
} | ||
} | ||
else { | ||
ele.value = isUndefined(value) || isNull(value) ? '' : value; | ||
} | ||
}); | ||
} | ||
fn.val = val; | ||
fn.is = function (comparator) { | ||
var compare = getCompareFunction(comparator); | ||
return some.call(this, function (ele, i) { return compare.call(ele, i, ele); }); | ||
}; | ||
cash.guid = 1; | ||
function unique(arr) { | ||
return arr.length > 1 ? filter.call(arr, function (item, index, self) { | ||
return indexOf.call(self, item) === index; | ||
}) : arr; | ||
return arr.length > 1 ? filter.call(arr, function (item, index, self) { return indexOf.call(self, item) === index; }) : arr; | ||
} | ||
cash.unique = unique; | ||
fn.add = function (selector, context) { | ||
return cash(unique(this.get().concat(cash(selector, context).get()))); | ||
}; // @require core/type_checking.ts | ||
return cash(unique(this.get().concat(cash(selector, context).get()))); | ||
}; | ||
fn.children = function (comparator) { | ||
return filtered(cash(unique(pluck(this, function (ele) { return ele.children; }))), comparator); | ||
}; | ||
fn.parent = function (comparator) { | ||
return filtered(cash(unique(pluck(this, 'parentNode'))), comparator); | ||
}; | ||
fn.index = function (selector) { | ||
var child = selector ? cash(selector)[0] : this[0]; | ||
var collection = selector ? this : cash(child).parent().children(); | ||
return indexOf.call(collection, child); | ||
}; | ||
fn.closest = function (comparator) { | ||
var filtered = this.filter(comparator); | ||
if (filtered.length) | ||
return filtered; | ||
var $parent = this.parent(); | ||
if (!$parent.length) | ||
return filtered; | ||
return $parent.closest(comparator); | ||
}; | ||
fn.siblings = function (comparator) { | ||
return filtered(cash(unique(pluck(this, function (ele) { return cash(ele).parent().children().not(ele); }))), comparator); | ||
}; | ||
fn.find = function (selector) { | ||
return cash(unique(pluck(this, function (ele) { return find(selector, ele); }))); | ||
}; | ||
// @require core/variables.ts | ||
function computeStyle(ele, prop, isVariable) { | ||
if (!isElement(ele)) return; | ||
var style = win.getComputedStyle(ele, null); | ||
return isVariable ? style.getPropertyValue(prop) || undefined : style[prop] || ele.style[prop]; | ||
} // @require ./compute_style.ts | ||
function computeStyleInt(ele, prop) { | ||
return parseInt(computeStyle(ele, prop), 10) || 0; | ||
// @require collection/filter.ts | ||
// @require traversal/find.ts | ||
var HTMLCDATARe = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g; | ||
var scriptTypeRe = /^$|^module$|\/(java|ecma)script/i; | ||
var scriptAttributes = ['type', 'src', 'nonce', 'noModule']; | ||
function evalScripts(node, doc) { | ||
var collection = cash(node); | ||
collection.filter('script').add(collection.find('script')).each(function (i, ele) { | ||
if (scriptTypeRe.test(ele.type) && docEle.contains(ele)) { // The script type is supported // The element is attached to the DOM // Using `documentElement` for broader browser support | ||
var script_1 = createElement('script'); | ||
script_1.text = ele.textContent.replace(HTMLCDATARe, ''); | ||
each(scriptAttributes, function (i, attr) { | ||
if (ele[attr]) | ||
script_1[attr] = ele[attr]; | ||
}); | ||
doc.head.insertBefore(script_1, null); | ||
doc.head.removeChild(script_1); | ||
} | ||
}); | ||
} | ||
var cssVariableRe = /^--/; // @require ./variables.ts | ||
// @require ./eval_scripts.ts | ||
function insertElement(anchor, target, left, inside, evaluate) { | ||
if (inside) { // prepend/append | ||
anchor.insertBefore(target, left ? anchor.firstChild : null); | ||
} | ||
else { // before/after | ||
if (anchor.nodeName === 'HTML') { | ||
anchor.parentNode.replaceChild(target, anchor); | ||
} | ||
else { | ||
anchor.parentNode.insertBefore(target, left ? anchor : anchor.nextSibling); | ||
} | ||
} | ||
if (evaluate) { | ||
evalScripts(target, anchor.ownerDocument); | ||
} | ||
} | ||
// @require ./insert_element.ts | ||
function insertSelectors(selectors, anchors, inverse, left, inside, reverseLoop1, reverseLoop2, reverseLoop3) { | ||
each(selectors, function (si, selector) { | ||
each(cash(selector), function (ti, target) { | ||
each(cash(anchors), function (ai, anchor) { | ||
var anchorFinal = inverse ? target : anchor; | ||
var targetFinal = inverse ? anchor : target; | ||
var indexFinal = inverse ? ti : ai; | ||
insertElement(anchorFinal, !indexFinal ? targetFinal : targetFinal.cloneNode(true), left, inside, !indexFinal); | ||
}, reverseLoop3); | ||
}, reverseLoop2); | ||
}, reverseLoop1); | ||
return anchors; | ||
} | ||
fn.after = function () { | ||
return insertSelectors(arguments, this, false, false, false, true, true); | ||
}; | ||
fn.append = function () { | ||
return insertSelectors(arguments, this, false, false, true); | ||
}; | ||
function html(html) { | ||
if (!arguments.length) | ||
return this[0] && this[0].innerHTML; | ||
if (isUndefined(html)) | ||
return this; | ||
var hasScript = /<script[\s>]/.test(html); | ||
return this.each(function (i, ele) { | ||
if (!isElement(ele)) | ||
return; | ||
if (hasScript) { | ||
cash(ele).empty().append(html); | ||
} | ||
else { | ||
ele.innerHTML = html; | ||
} | ||
}); | ||
} | ||
fn.html = html; | ||
fn.appendTo = function (selector) { | ||
return insertSelectors(arguments, this, true, false, true); | ||
}; | ||
fn.wrapInner = function (selector) { | ||
return this.each(function (i, ele) { | ||
var $ele = cash(ele); | ||
var contents = $ele.contents(); | ||
contents.length ? contents.wrapAll(selector) : $ele.append(selector); | ||
}); | ||
}; | ||
fn.before = function () { | ||
return insertSelectors(arguments, this, false, true); | ||
}; | ||
fn.wrapAll = function (selector) { | ||
var structure = cash(selector); | ||
var wrapper = structure[0]; | ||
while (wrapper.children.length) | ||
wrapper = wrapper.firstElementChild; | ||
this.first().before(structure); | ||
return this.appendTo(wrapper); | ||
}; | ||
fn.wrap = function (selector) { | ||
return this.each(function (i, ele) { | ||
var wrapper = cash(selector)[0]; | ||
cash(ele).wrapAll(!i ? wrapper : wrapper.cloneNode(true)); | ||
}); | ||
}; | ||
fn.insertAfter = function (selector) { | ||
return insertSelectors(arguments, this, true, false, false, false, false, true); | ||
}; | ||
fn.insertBefore = function (selector) { | ||
return insertSelectors(arguments, this, true, true); | ||
}; | ||
fn.prepend = function () { | ||
return insertSelectors(arguments, this, false, true, true, true, true); | ||
}; | ||
fn.prependTo = function (selector) { | ||
return insertSelectors(arguments, this, true, true, true, false, false, true); | ||
}; | ||
fn.contents = function () { | ||
return cash(unique(pluck(this, function (ele) { return ele.tagName === 'IFRAME' ? [ele.contentDocument] : (ele.tagName === 'TEMPLATE' ? ele.content.childNodes : ele.childNodes); }))); | ||
}; | ||
fn.next = function (comparator, _all, _until) { | ||
return filtered(cash(unique(pluck(this, 'nextElementSibling', _all, _until))), comparator); | ||
}; | ||
fn.nextAll = function (comparator) { | ||
return this.next(comparator, true); | ||
}; | ||
fn.nextUntil = function (until, comparator) { | ||
return this.next(comparator, true, until); | ||
}; | ||
fn.parents = function (comparator, _until) { | ||
return filtered(cash(unique(pluck(this, 'parentElement', true, _until))), comparator); | ||
}; | ||
fn.parentsUntil = function (until, comparator) { | ||
return this.parents(comparator, until); | ||
}; | ||
fn.prev = function (comparator, _all, _until) { | ||
return filtered(cash(unique(pluck(this, 'previousElementSibling', _all, _until))), comparator); | ||
}; | ||
fn.prevAll = function (comparator) { | ||
return this.prev(comparator, true); | ||
}; | ||
fn.prevUntil = function (until, comparator) { | ||
return this.prev(comparator, true, until); | ||
}; | ||
fn.map = function (callback) { | ||
return cash(concat.apply([], map.call(this, function (ele, i) { return callback.call(ele, i, ele); }))); | ||
}; | ||
fn.clone = function () { | ||
return this.map(function (i, ele) { return ele.cloneNode(true); }); | ||
}; | ||
fn.offsetParent = function () { | ||
return this.map(function (i, ele) { | ||
var offsetParent = ele.offsetParent; | ||
while (offsetParent && computeStyle(offsetParent, 'position') === 'static') { | ||
offsetParent = offsetParent.offsetParent; | ||
} | ||
return offsetParent || docEle; | ||
}); | ||
}; | ||
fn.slice = function (start, end) { | ||
return cash(slice.call(this, start, end)); | ||
}; | ||
// @require ./cash.ts | ||
var dashAlphaRe = /-([a-z])/g; | ||
function camelCase(str) { | ||
return str.replace(dashAlphaRe, function (match, letter) { return letter.toUpperCase(); }); | ||
} | ||
fn.ready = function (callback) { | ||
var cb = function () { return setTimeout(callback, 0, cash); }; | ||
if (doc.readyState !== 'loading') { | ||
cb(); | ||
} | ||
else { | ||
doc.addEventListener('DOMContentLoaded', cb); | ||
} | ||
return this; | ||
}; | ||
fn.unwrap = function () { | ||
this.parent().each(function (i, ele) { | ||
if (ele.tagName === 'BODY') | ||
return; | ||
var $ele = cash(ele); | ||
$ele.replaceWith($ele.children()); | ||
}); | ||
return this; | ||
}; | ||
fn.offset = function () { | ||
var ele = this[0]; | ||
if (!ele) | ||
return; | ||
var rect = ele.getBoundingClientRect(); | ||
return { | ||
top: rect.top + win.pageYOffset, | ||
left: rect.left + win.pageXOffset | ||
}; | ||
}; | ||
fn.position = function () { | ||
var ele = this[0]; | ||
if (!ele) | ||
return; | ||
var isFixed = (computeStyle(ele, 'position') === 'fixed'); | ||
var offset = isFixed ? ele.getBoundingClientRect() : this.offset(); | ||
if (!isFixed) { | ||
var doc_1 = ele.ownerDocument; | ||
var offsetParent = ele.offsetParent || doc_1.documentElement; | ||
while ((offsetParent === doc_1.body || offsetParent === doc_1.documentElement) && computeStyle(offsetParent, 'position') === 'static') { | ||
offsetParent = offsetParent.parentNode; | ||
} | ||
if (offsetParent !== ele && isElement(offsetParent)) { | ||
var parentOffset = cash(offsetParent).offset(); | ||
offset.top -= parentOffset.top + computeStyleInt(offsetParent, 'borderTopWidth'); | ||
offset.left -= parentOffset.left + computeStyleInt(offsetParent, 'borderLeftWidth'); | ||
} | ||
} | ||
return { | ||
top: offset.top - computeStyleInt(ele, 'marginTop'), | ||
left: offset.left - computeStyleInt(ele, 'marginLeft') | ||
}; | ||
}; | ||
var propMap = { | ||
/* GENERAL */ | ||
class: 'className', | ||
contenteditable: 'contentEditable', | ||
/* LABEL */ | ||
for: 'htmlFor', | ||
/* INPUT */ | ||
readonly: 'readOnly', | ||
maxlength: 'maxLength', | ||
tabindex: 'tabIndex', | ||
/* TABLE */ | ||
colspan: 'colSpan', | ||
rowspan: 'rowSpan', | ||
/* IMAGE */ | ||
usemap: 'useMap' | ||
}; | ||
fn.prop = function (prop, value) { | ||
if (!prop) | ||
return; | ||
if (isString(prop)) { | ||
prop = propMap[prop] || prop; | ||
if (arguments.length < 2) | ||
return this[0] && this[0][prop]; | ||
return this.each(function (i, ele) { ele[prop] = value; }); | ||
} | ||
for (var key in prop) { | ||
this.prop(key, prop[key]); | ||
} | ||
return this; | ||
}; | ||
fn.removeProp = function (prop) { | ||
return this.each(function (i, ele) { delete ele[propMap[prop] || prop]; }); | ||
}; | ||
var cssVariableRe = /^--/; | ||
// @require ./variables.ts | ||
function isCSSVariable(prop) { | ||
return cssVariableRe.test(prop); | ||
} // @require core/camel_case.ts | ||
return cssVariableRe.test(prop); | ||
} | ||
// @require core/camel_case.ts | ||
// @require core/cash.ts | ||
@@ -453,935 +723,510 @@ // @require core/each.ts | ||
// @require ./is_css_variable.ts | ||
var prefixedProps = {}, | ||
style = div.style, | ||
vendorsPrefixes = ['webkit', 'moz', 'ms']; | ||
var prefixedProps = {}; | ||
var style = div.style; | ||
var vendorsPrefixes = ['webkit', 'moz', 'ms']; | ||
function getPrefixedProp(prop, isVariable) { | ||
if (isVariable === void 0) { | ||
isVariable = isCSSVariable(prop); | ||
} | ||
if (isVariable) return prop; | ||
if (!prefixedProps[prop]) { | ||
var propCC = camelCase(prop), | ||
propUC = "" + propCC[0].toUpperCase() + propCC.slice(1), | ||
props = (propCC + " " + vendorsPrefixes.join(propUC + " ") + propUC).split(' '); | ||
each(props, function (i, p) { | ||
if (p in style) { | ||
prefixedProps[prop] = p; | ||
return false; | ||
} | ||
}); | ||
} | ||
return prefixedProps[prop]; | ||
if (isVariable === void 0) { isVariable = isCSSVariable(prop); } | ||
if (isVariable) | ||
return prop; | ||
if (!prefixedProps[prop]) { | ||
var propCC = camelCase(prop); | ||
var propUC = "".concat(propCC[0].toUpperCase()).concat(propCC.slice(1)); | ||
var props = ("".concat(propCC, " ").concat(vendorsPrefixes.join("".concat(propUC, " "))).concat(propUC)).split(' '); | ||
each(props, function (i, p) { | ||
if (p in style) { | ||
prefixedProps[prop] = p; | ||
return false; | ||
} | ||
}); | ||
} | ||
return prefixedProps[prop]; | ||
} | ||
; // @require core/type_checking.ts | ||
// @require core/type_checking.ts | ||
// @require ./is_css_variable.ts | ||
var numericProps = { | ||
animationIterationCount: true, | ||
columnCount: true, | ||
flexGrow: true, | ||
flexShrink: true, | ||
fontWeight: true, | ||
gridArea: true, | ||
gridColumn: true, | ||
gridColumnEnd: true, | ||
gridColumnStart: true, | ||
gridRow: true, | ||
gridRowEnd: true, | ||
gridRowStart: true, | ||
lineHeight: true, | ||
opacity: true, | ||
order: true, | ||
orphans: true, | ||
widows: true, | ||
zIndex: true | ||
animationIterationCount: true, | ||
columnCount: true, | ||
flexGrow: true, | ||
flexShrink: true, | ||
fontWeight: true, | ||
gridArea: true, | ||
gridColumn: true, | ||
gridColumnEnd: true, | ||
gridColumnStart: true, | ||
gridRow: true, | ||
gridRowEnd: true, | ||
gridRowStart: true, | ||
lineHeight: true, | ||
opacity: true, | ||
order: true, | ||
orphans: true, | ||
widows: true, | ||
zIndex: true | ||
}; | ||
function getSuffixedValue(prop, value, isVariable) { | ||
if (isVariable === void 0) { | ||
isVariable = isCSSVariable(prop); | ||
} | ||
return !isVariable && !numericProps[prop] && isNumeric(value) ? value + "px" : value; | ||
if (isVariable === void 0) { isVariable = isCSSVariable(prop); } | ||
return !isVariable && !numericProps[prop] && isNumeric(value) ? "".concat(value, "px") : value; | ||
} | ||
function css(prop, value) { | ||
if (isString(prop)) { | ||
var isVariable_1 = isCSSVariable(prop); | ||
prop = getPrefixedProp(prop, isVariable_1); | ||
if (arguments.length < 2) return this[0] && computeStyle(this[0], prop, isVariable_1); | ||
if (!prop) return this; | ||
value = getSuffixedValue(prop, value, isVariable_1); | ||
return this.each(function (i, ele) { | ||
if (!isElement(ele)) return; | ||
if (isVariable_1) { | ||
ele.style.setProperty(prop, value); | ||
} else { | ||
ele.style[prop] = value; | ||
} | ||
}); | ||
} | ||
for (var key in prop) { | ||
this.css(key, prop[key]); | ||
} | ||
return this; | ||
if (isString(prop)) { | ||
var isVariable_1 = isCSSVariable(prop); | ||
prop = getPrefixedProp(prop, isVariable_1); | ||
if (arguments.length < 2) | ||
return this[0] && computeStyle(this[0], prop, isVariable_1); | ||
if (!prop) | ||
return this; | ||
value = getSuffixedValue(prop, value, isVariable_1); | ||
return this.each(function (i, ele) { | ||
if (!isElement(ele)) | ||
return; | ||
if (isVariable_1) { | ||
ele.style.setProperty(prop, value); | ||
} | ||
else { | ||
ele.style[prop] = value; | ||
} | ||
}); | ||
} | ||
for (var key in prop) { | ||
this.css(key, prop[key]); | ||
} | ||
return this; | ||
} | ||
; | ||
fn.css = css; // @optional ./css.ts | ||
fn.css = css; | ||
function attempt(fn, arg) { | ||
try { | ||
return fn(arg); | ||
} | ||
catch (_a) { | ||
return arg; | ||
} | ||
} | ||
// @require core/attempt.ts | ||
// @require core/camel_case.ts | ||
var JSONStringRe = /^\s+|\s+$/; | ||
function getData(ele, key) { | ||
var value = ele.dataset[key] || ele.dataset[camelCase(key)]; | ||
if (JSONStringRe.test(value)) return value; | ||
return attempt(JSON.parse, value); | ||
} // @require core/attempt.ts | ||
var value = ele.dataset[key] || ele.dataset[camelCase(key)]; | ||
if (JSONStringRe.test(value)) | ||
return value; | ||
return attempt(JSON.parse, value); | ||
} | ||
// @require core/attempt.ts | ||
// @require core/camel_case.ts | ||
function setData(ele, key, value) { | ||
value = attempt(JSON.stringify, value); | ||
ele.dataset[camelCase(key)] = value; | ||
value = attempt(JSON.stringify, value); | ||
ele.dataset[camelCase(key)] = value; | ||
} | ||
function data(name, value) { | ||
if (!name) { | ||
if (!this[0]) return; | ||
var datas = {}; | ||
for (var key in this[0].dataset) { | ||
datas[key] = getData(this[0], key); | ||
if (!name) { | ||
if (!this[0]) | ||
return; | ||
var datas = {}; | ||
for (var key in this[0].dataset) { | ||
datas[key] = getData(this[0], key); | ||
} | ||
return datas; | ||
} | ||
return datas; | ||
} | ||
if (isString(name)) { | ||
if (arguments.length < 2) return this[0] && getData(this[0], name); | ||
if (isUndefined(value)) return this; | ||
return this.each(function (i, ele) { | ||
setData(ele, name, value); | ||
}); | ||
} | ||
for (var key in name) { | ||
this.data(key, name[key]); | ||
} | ||
return this; | ||
if (isString(name)) { | ||
if (arguments.length < 2) | ||
return this[0] && getData(this[0], name); | ||
if (isUndefined(value)) | ||
return this; | ||
return this.each(function (i, ele) { setData(ele, name, value); }); | ||
} | ||
for (var key in name) { | ||
this.data(key, name[key]); | ||
} | ||
return this; | ||
} | ||
fn.data = data; // @optional ./data.ts | ||
fn.data = data; | ||
function getDocumentDimension(doc, dimension) { | ||
var docEle = doc.documentElement; | ||
return Math.max(doc.body["scroll" + dimension], docEle["scroll" + dimension], doc.body["offset" + dimension], docEle["offset" + dimension], docEle["client" + dimension]); | ||
} // @require css/helpers/compute_style_int.ts | ||
function getExtraSpace(ele, xAxis) { | ||
return computeStyleInt(ele, "border" + (xAxis ? 'Left' : 'Top') + "Width") + computeStyleInt(ele, "padding" + (xAxis ? 'Left' : 'Top')) + computeStyleInt(ele, "padding" + (xAxis ? 'Right' : 'Bottom')) + computeStyleInt(ele, "border" + (xAxis ? 'Right' : 'Bottom') + "Width"); | ||
var docEle = doc.documentElement; | ||
return Math.max(doc.body["scroll".concat(dimension)], docEle["scroll".concat(dimension)], doc.body["offset".concat(dimension)], docEle["offset".concat(dimension)], docEle["client".concat(dimension)]); | ||
} | ||
each([true, false], function (i, outer) { | ||
each(['Width', 'Height'], function (i, prop) { | ||
var name = "" + (outer ? 'outer' : 'inner') + prop; | ||
fn[name] = function (includeMargins) { | ||
if (!this[0]) return; | ||
if (isWindow(this[0])) return outer ? this[0]["inner" + prop] : this[0].document.documentElement["client" + prop]; | ||
if (isDocument(this[0])) return getDocumentDimension(this[0], prop); | ||
return this[0]["" + (outer ? 'offset' : 'client') + prop] + (includeMargins && outer ? computeStyleInt(this[0], "margin" + (i ? 'Top' : 'Left')) + computeStyleInt(this[0], "margin" + (i ? 'Bottom' : 'Right')) : 0); | ||
each(['Width', 'Height'], function (i, prop) { | ||
var name = "".concat(outer ? 'outer' : 'inner').concat(prop); | ||
fn[name] = function (includeMargins) { | ||
if (!this[0]) | ||
return; | ||
if (isWindow(this[0])) | ||
return outer ? this[0]["inner".concat(prop)] : this[0].document.documentElement["client".concat(prop)]; | ||
if (isDocument(this[0])) | ||
return getDocumentDimension(this[0], prop); | ||
return this[0]["".concat(outer ? 'offset' : 'client').concat(prop)] + (includeMargins && outer ? computeStyleInt(this[0], "margin".concat(i ? 'Top' : 'Left')) + computeStyleInt(this[0], "margin".concat(i ? 'Bottom' : 'Right')) : 0); | ||
}; | ||
}); | ||
}); | ||
each(['Width', 'Height'], function (index, prop) { | ||
var propLC = prop.toLowerCase(); | ||
fn[propLC] = function (value) { | ||
if (!this[0]) | ||
return isUndefined(value) ? undefined : this; | ||
if (!arguments.length) { | ||
if (isWindow(this[0])) | ||
return this[0].document.documentElement["client".concat(prop)]; | ||
if (isDocument(this[0])) | ||
return getDocumentDimension(this[0], prop); | ||
return this[0].getBoundingClientRect()[propLC] - getExtraSpace(this[0], !index); | ||
} | ||
var valueNumber = parseInt(value, 10); | ||
return this.each(function (i, ele) { | ||
if (!isElement(ele)) | ||
return; | ||
var boxSizing = computeStyle(ele, 'boxSizing'); | ||
ele.style[propLC] = getSuffixedValue(propLC, valueNumber + (boxSizing === 'border-box' ? getExtraSpace(ele, !index) : 0)); | ||
}); | ||
}; | ||
}); | ||
}); | ||
each(['Width', 'Height'], function (index, prop) { | ||
var propLC = prop.toLowerCase(); | ||
fn[propLC] = function (value) { | ||
if (!this[0]) return isUndefined(value) ? undefined : this; | ||
if (!arguments.length) { | ||
if (isWindow(this[0])) return this[0].document.documentElement["client" + prop]; | ||
if (isDocument(this[0])) return getDocumentDimension(this[0], prop); | ||
return this[0].getBoundingClientRect()[propLC] - getExtraSpace(this[0], !index); | ||
} | ||
var valueNumber = parseInt(value, 10); | ||
var displayProperty = '___cd'; | ||
fn.toggle = function (force) { | ||
return this.each(function (i, ele) { | ||
if (!isElement(ele)) return; | ||
var boxSizing = computeStyle(ele, 'boxSizing'); | ||
ele.style[propLC] = getSuffixedValue(propLC, valueNumber + (boxSizing === 'border-box' ? getExtraSpace(ele, !index) : 0)); | ||
if (!isElement(ele)) | ||
return; | ||
var show = isUndefined(force) ? isHidden(ele) : force; | ||
if (show) { | ||
ele.style.display = ele[displayProperty] || ''; | ||
if (isHidden(ele)) { | ||
ele.style.display = getDefaultDisplay(ele.tagName); | ||
} | ||
} | ||
else { | ||
ele[displayProperty] = computeStyle(ele, 'display'); | ||
ele.style.display = 'none'; | ||
} | ||
}); | ||
}; | ||
}); // @optional ./inner_outer.ts | ||
// @optional ./normal.ts | ||
// @require css/helpers/compute_style.ts | ||
var defaultDisplay = {}; | ||
function getDefaultDisplay(tagName) { | ||
if (defaultDisplay[tagName]) return defaultDisplay[tagName]; | ||
var ele = createElement(tagName); | ||
doc.body.insertBefore(ele, null); | ||
var display = computeStyle(ele, 'display'); | ||
doc.body.removeChild(ele); | ||
return defaultDisplay[tagName] = display !== 'none' ? display : 'block'; | ||
} // @require css/helpers/compute_style.ts | ||
function isHidden(ele) { | ||
return computeStyle(ele, 'display') === 'none'; | ||
} | ||
var displayProperty = '___cd'; | ||
fn.toggle = function (force) { | ||
return this.each(function (i, ele) { | ||
if (!isElement(ele)) return; | ||
var show = isUndefined(force) ? isHidden(ele) : force; | ||
if (show) { | ||
ele.style.display = ele[displayProperty] || ''; | ||
if (isHidden(ele)) { | ||
ele.style.display = getDefaultDisplay(ele.tagName); | ||
} | ||
} else { | ||
ele[displayProperty] = computeStyle(ele, 'display'); | ||
ele.style.display = 'none'; | ||
} | ||
}); | ||
}; | ||
fn.hide = function () { | ||
return this.toggle(false); | ||
return this.toggle(false); | ||
}; | ||
fn.show = function () { | ||
return this.toggle(true); | ||
}; // @optional ./hide.ts | ||
// @optional ./show.ts | ||
// @optional ./toggle.ts | ||
function hasNamespaces(ns1, ns2) { | ||
return !ns2 || !some.call(ns2, function (ns) { | ||
return ns1.indexOf(ns) < 0; | ||
}); | ||
return this.toggle(true); | ||
}; | ||
var eventsNamespace = '___ce'; | ||
var eventsNamespacesSeparator = '.'; | ||
var eventsFocus = { focus: 'focusin', blur: 'focusout' }; | ||
var eventsHover = { mouseenter: 'mouseover', mouseleave: 'mouseout' }; | ||
var eventsMouseRe = /^(mouse|pointer|contextmenu|drag|drop|click|dblclick)/i; | ||
// @require ./variables.ts | ||
function getEventNameBubbling(name) { | ||
return eventsHover[name] || eventsFocus[name] || name; | ||
} | ||
var eventsNamespace = '___ce', | ||
eventsNamespacesSeparator = '.', | ||
eventsFocus = { | ||
focus: 'focusin', | ||
blur: 'focusout' | ||
}, | ||
eventsHover = { | ||
mouseenter: 'mouseover', | ||
mouseleave: 'mouseout' | ||
}, | ||
eventsMouseRe = /^(mouse|pointer|contextmenu|drag|drop|click|dblclick)/i; // @require ./variables.ts | ||
function getEventNameBubbling(name) { | ||
return eventsHover[name] || eventsFocus[name] || name; | ||
} // @require ./variables.ts | ||
// @require ./variables.ts | ||
function parseEventName(eventName) { | ||
var parts = eventName.split(eventsNamespacesSeparator); | ||
return [parts[0], parts.slice(1).sort()]; // [name, namespace[]] | ||
} | ||
fn.trigger = function (event, data) { | ||
if (isString(event)) { | ||
var _a = parseEventName(event), nameOriginal = _a[0], namespaces = _a[1]; | ||
var name_1 = getEventNameBubbling(nameOriginal); | ||
if (!name_1) | ||
return this; | ||
var type = eventsMouseRe.test(name_1) ? 'MouseEvents' : 'HTMLEvents'; | ||
event = doc.createEvent(type); | ||
event.initEvent(name_1, true, true); | ||
event.namespace = namespaces.join(eventsNamespacesSeparator); | ||
event.___ot = nameOriginal; | ||
} | ||
event.___td = data; | ||
var isEventFocus = (event.___ot in eventsFocus); | ||
return this.each(function (i, ele) { | ||
if (isEventFocus && isFunction(ele[event.___ot])) { | ||
ele["___i".concat(event.type)] = true; // Ensuring the native event is ignored | ||
ele[event.___ot](); | ||
ele["___i".concat(event.type)] = false; // Ensuring the custom event is not ignored | ||
} | ||
ele.dispatchEvent(event); | ||
}); | ||
}; | ||
// @require ./variables.ts | ||
function getEventsCache(ele) { | ||
return ele[eventsNamespace] = ele[eventsNamespace] || {}; | ||
} // @require core/guid.ts | ||
return ele[eventsNamespace] = (ele[eventsNamespace] || {}); | ||
} | ||
// @require core/guid.ts | ||
// @require events/helpers/get_events_cache.ts | ||
function addEvent(ele, name, namespaces, selector, callback) { | ||
var eventCache = getEventsCache(ele); | ||
eventCache[name] = eventCache[name] || []; | ||
eventCache[name].push([namespaces, selector, callback]); | ||
ele.addEventListener(name, callback); | ||
} // @require ./variables.ts | ||
function parseEventName(eventName) { | ||
var parts = eventName.split(eventsNamespacesSeparator); | ||
return [parts[0], parts.slice(1).sort()]; // [name, namespace[]] | ||
} // @require ./get_events_cache.ts | ||
var eventCache = getEventsCache(ele); | ||
eventCache[name] = (eventCache[name] || []); | ||
eventCache[name].push([namespaces, selector, callback]); | ||
ele.addEventListener(name, callback); | ||
} | ||
function hasNamespaces(ns1, ns2) { | ||
return !ns2 || !some.call(ns2, function (ns) { return ns1.indexOf(ns) < 0; }); | ||
} | ||
// @require ./get_events_cache.ts | ||
// @require ./has_namespaces.ts | ||
// @require ./parse_event_name.ts | ||
function removeEvent(ele, name, namespaces, selector, callback) { | ||
var cache = getEventsCache(ele); | ||
if (!name) { | ||
for (name in cache) { | ||
removeEvent(ele, name, namespaces, selector, callback); | ||
var cache = getEventsCache(ele); | ||
if (!name) { | ||
for (name in cache) { | ||
removeEvent(ele, name, namespaces, selector, callback); | ||
} | ||
} | ||
} else if (cache[name]) { | ||
cache[name] = cache[name].filter(function (_a) { | ||
var ns = _a[0], | ||
sel = _a[1], | ||
cb = _a[2]; | ||
if (callback && cb.guid !== callback.guid || !hasNamespaces(ns, namespaces) || selector && selector !== sel) return true; | ||
ele.removeEventListener(name, cb); | ||
}); | ||
} | ||
else if (cache[name]) { | ||
cache[name] = cache[name].filter(function (_a) { | ||
var ns = _a[0], sel = _a[1], cb = _a[2]; | ||
if ((callback && cb.guid !== callback.guid) || !hasNamespaces(ns, namespaces) || (selector && selector !== sel)) | ||
return true; | ||
ele.removeEventListener(name, cb); | ||
}); | ||
} | ||
} | ||
fn.off = function (eventFullName, selector, callback) { | ||
var _this = this; | ||
if (isUndefined(eventFullName)) { | ||
this.each(function (i, ele) { | ||
if (!isElement(ele) && !isDocument(ele) && !isWindow(ele)) return; | ||
removeEvent(ele); | ||
}); | ||
} else if (!isString(eventFullName)) { | ||
for (var key in eventFullName) { | ||
this.off(key, eventFullName[key]); | ||
var _this = this; | ||
if (isUndefined(eventFullName)) { | ||
this.each(function (i, ele) { | ||
if (!isElement(ele) && !isDocument(ele) && !isWindow(ele)) | ||
return; | ||
removeEvent(ele); | ||
}); | ||
} | ||
} else { | ||
if (isFunction(selector)) { | ||
callback = selector; | ||
selector = ''; | ||
else if (!isString(eventFullName)) { | ||
for (var key in eventFullName) { | ||
this.off(key, eventFullName[key]); | ||
} | ||
} | ||
each(getSplitValues(eventFullName), function (i, eventFullName) { | ||
var _a = parseEventName(eventFullName), | ||
nameOriginal = _a[0], | ||
namespaces = _a[1], | ||
name = getEventNameBubbling(nameOriginal); | ||
_this.each(function (i, ele) { | ||
if (!isElement(ele) && !isDocument(ele) && !isWindow(ele)) return; | ||
removeEvent(ele, name, namespaces, selector, callback); | ||
}); | ||
}); | ||
} | ||
return this; | ||
else { | ||
if (isFunction(selector)) { | ||
callback = selector; | ||
selector = ''; | ||
} | ||
each(getSplitValues(eventFullName), function (i, eventFullName) { | ||
var _a = parseEventName(eventFullName), nameOriginal = _a[0], namespaces = _a[1]; | ||
var name = getEventNameBubbling(nameOriginal); | ||
_this.each(function (i, ele) { | ||
if (!isElement(ele) && !isDocument(ele) && !isWindow(ele)) | ||
return; | ||
removeEvent(ele, name, namespaces, selector, callback); | ||
}); | ||
}); | ||
} | ||
return this; | ||
}; | ||
fn.remove = function (comparator) { | ||
filtered(this, comparator).detach().off(); | ||
return this; | ||
}; | ||
fn.replaceWith = function (selector) { | ||
return this.before(selector).remove(); | ||
}; | ||
fn.replaceAll = function (selector) { | ||
cash(selector).replaceWith(this); | ||
return this; | ||
}; | ||
function on(eventFullName, selector, data, callback, _one) { | ||
var _this = this; | ||
if (!isString(eventFullName)) { | ||
for (var key in eventFullName) { | ||
this.on(key, selector, data, eventFullName[key], _one); | ||
var _this = this; | ||
if (!isString(eventFullName)) { | ||
for (var key in eventFullName) { | ||
this.on(key, selector, data, eventFullName[key], _one); | ||
} | ||
return this; | ||
} | ||
return this; | ||
} | ||
if (!isString(selector)) { | ||
if (isUndefined(selector) || isNull(selector)) { | ||
selector = ''; | ||
} else if (isUndefined(data)) { | ||
data = selector; | ||
selector = ''; | ||
} else { | ||
callback = data; | ||
data = selector; | ||
selector = ''; | ||
} | ||
} | ||
if (!isFunction(callback)) { | ||
callback = data; | ||
data = undefined; | ||
} | ||
if (!callback) return this; | ||
each(getSplitValues(eventFullName), function (i, eventFullName) { | ||
var _a = parseEventName(eventFullName), | ||
nameOriginal = _a[0], | ||
namespaces = _a[1], | ||
name = getEventNameBubbling(nameOriginal), | ||
isEventHover = (nameOriginal in eventsHover), | ||
isEventFocus = (nameOriginal in eventsFocus); | ||
if (!name) return; | ||
_this.each(function (i, ele) { | ||
if (!isElement(ele) && !isDocument(ele) && !isWindow(ele)) return; | ||
var finalCallback = function finalCallback(event) { | ||
if (event.target["___i" + event.type]) return event.stopImmediatePropagation(); // Ignoring native event in favor of the upcoming custom one | ||
if (event.namespace && !hasNamespaces(namespaces, event.namespace.split(eventsNamespacesSeparator))) return; | ||
if (!selector && (isEventFocus && (event.target !== ele || event.___ot === name) || isEventHover && event.relatedTarget && ele.contains(event.relatedTarget))) return; | ||
var thisArg = ele; | ||
if (selector) { | ||
var target = event.target; | ||
while (!matches(target, selector)) { | ||
if (target === ele) return; | ||
target = target.parentNode; | ||
if (!target) return; | ||
} | ||
thisArg = target; | ||
if (!isString(selector)) { | ||
if (isUndefined(selector) || isNull(selector)) { | ||
selector = ''; | ||
} | ||
Object.defineProperty(event, 'currentTarget', { | ||
configurable: true, | ||
get: function get() { | ||
return thisArg; | ||
} | ||
}); | ||
Object.defineProperty(event, 'delegateTarget', { | ||
configurable: true, | ||
get: function get() { | ||
return ele; | ||
} | ||
}); | ||
Object.defineProperty(event, 'data', { | ||
configurable: true, | ||
get: function get() { | ||
return data; | ||
} | ||
}); | ||
var returnValue = callback.call(thisArg, event, event.___td); | ||
if (_one) { | ||
removeEvent(ele, name, namespaces, selector, finalCallback); | ||
else if (isUndefined(data)) { | ||
data = selector; | ||
selector = ''; | ||
} | ||
if (returnValue === false) { | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
else { | ||
callback = data; | ||
data = selector; | ||
selector = ''; | ||
} | ||
}; | ||
finalCallback.guid = callback.guid = callback.guid || cash.guid++; | ||
addEvent(ele, name, namespaces, selector, finalCallback); | ||
} | ||
if (!isFunction(callback)) { | ||
callback = data; | ||
data = undefined; | ||
} | ||
if (!callback) | ||
return this; | ||
each(getSplitValues(eventFullName), function (i, eventFullName) { | ||
var _a = parseEventName(eventFullName), nameOriginal = _a[0], namespaces = _a[1]; | ||
var name = getEventNameBubbling(nameOriginal); | ||
var isEventHover = (nameOriginal in eventsHover); | ||
var isEventFocus = (nameOriginal in eventsFocus); | ||
if (!name) | ||
return; | ||
_this.each(function (i, ele) { | ||
if (!isElement(ele) && !isDocument(ele) && !isWindow(ele)) | ||
return; | ||
var finalCallback = function (event) { | ||
if (event.target["___i".concat(event.type)]) | ||
return event.stopImmediatePropagation(); // Ignoring native event in favor of the upcoming custom one | ||
if (event.namespace && !hasNamespaces(namespaces, event.namespace.split(eventsNamespacesSeparator))) | ||
return; | ||
if (!selector && ((isEventFocus && (event.target !== ele || event.___ot === name)) || (isEventHover && event.relatedTarget && ele.contains(event.relatedTarget)))) | ||
return; | ||
var thisArg = ele; | ||
if (selector) { | ||
var target = event.target; | ||
while (!matches(target, selector)) { | ||
if (target === ele) | ||
return; | ||
target = target.parentNode; | ||
if (!target) | ||
return; | ||
} | ||
thisArg = target; | ||
} | ||
Object.defineProperty(event, 'currentTarget', { | ||
configurable: true, | ||
get: function () { | ||
return thisArg; | ||
} | ||
}); | ||
Object.defineProperty(event, 'delegateTarget', { | ||
configurable: true, | ||
get: function () { | ||
return ele; | ||
} | ||
}); | ||
Object.defineProperty(event, 'data', { | ||
configurable: true, | ||
get: function () { | ||
return data; | ||
} | ||
}); | ||
var returnValue = callback.call(thisArg, event, event.___td); | ||
if (_one) { | ||
removeEvent(ele, name, namespaces, selector, finalCallback); | ||
} | ||
if (returnValue === false) { | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
} | ||
}; | ||
finalCallback.guid = callback.guid = (callback.guid || cash.guid++); | ||
addEvent(ele, name, namespaces, selector, finalCallback); | ||
}); | ||
}); | ||
}); | ||
return this; | ||
return this; | ||
} | ||
fn.on = on; | ||
function one(eventFullName, selector, data, callback) { | ||
return this.on(eventFullName, selector, data, callback, true); | ||
return this.on(eventFullName, selector, data, callback, true); | ||
} | ||
; | ||
fn.one = one; | ||
fn.ready = function (callback) { | ||
var cb = function cb() { | ||
return setTimeout(callback, 0, cash); | ||
}; | ||
if (doc.readyState !== 'loading') { | ||
cb(); | ||
} else { | ||
doc.addEventListener('DOMContentLoaded', cb); | ||
} | ||
return this; | ||
}; | ||
fn.trigger = function (event, data) { | ||
if (isString(event)) { | ||
var _a = parseEventName(event), | ||
nameOriginal = _a[0], | ||
namespaces = _a[1], | ||
name_1 = getEventNameBubbling(nameOriginal); | ||
if (!name_1) return this; | ||
var type = eventsMouseRe.test(name_1) ? 'MouseEvents' : 'HTMLEvents'; | ||
event = doc.createEvent(type); | ||
event.initEvent(name_1, true, true); | ||
event.namespace = namespaces.join(eventsNamespacesSeparator); | ||
event.___ot = nameOriginal; | ||
} | ||
event.___td = data; | ||
var isEventFocus = (event.___ot in eventsFocus); | ||
return this.each(function (i, ele) { | ||
if (isEventFocus && isFunction(ele[event.___ot])) { | ||
ele["___i" + event.type] = true; // Ensuring the native event is ignored | ||
ele[event.___ot](); | ||
ele["___i" + event.type] = false; // Ensuring the custom event is not ignored | ||
} | ||
ele.dispatchEvent(event); | ||
}); | ||
}; // @optional ./off.ts | ||
// @optional ./on.ts | ||
// @optional ./one.ts | ||
// @optional ./ready.ts | ||
// @optional ./trigger.ts | ||
// @require core/pluck.ts | ||
// @require core/variables.ts | ||
function getValue(ele) { | ||
if (ele.multiple && ele.options) return pluck(filter.call(ele.options, function (option) { | ||
return option.selected && !option.disabled && !option.parentNode.disabled; | ||
}), 'value'); | ||
return ele.value || ''; | ||
} | ||
var queryEncodeSpaceRe = /%20/g, | ||
queryEncodeCRLFRe = /\r?\n/g; | ||
var queryEncodeSpaceRe = /%20/g; | ||
var queryEncodeCRLFRe = /\r?\n/g; | ||
function queryEncode(prop, value) { | ||
return "&" + encodeURIComponent(prop) + "=" + encodeURIComponent(value.replace(queryEncodeCRLFRe, '\r\n')).replace(queryEncodeSpaceRe, '+'); | ||
return "&".concat(encodeURIComponent(prop), "=").concat(encodeURIComponent(value.replace(queryEncodeCRLFRe, '\r\n')).replace(queryEncodeSpaceRe, '+')); | ||
} | ||
var skippableRe = /file|reset|submit|button|image/i, | ||
checkableRe = /radio|checkbox/i; | ||
var skippableRe = /file|reset|submit|button|image/i; | ||
var checkableRe = /radio|checkbox/i; | ||
fn.serialize = function () { | ||
var query = ''; | ||
this.each(function (i, ele) { | ||
each(ele.elements || [ele], function (i, ele) { | ||
if (ele.disabled || !ele.name || ele.tagName === 'FIELDSET' || skippableRe.test(ele.type) || checkableRe.test(ele.type) && !ele.checked) return; | ||
var value = getValue(ele); | ||
if (!isUndefined(value)) { | ||
var values = isArray(value) ? value : [value]; | ||
each(values, function (i, value) { | ||
query += queryEncode(ele.name, value); | ||
var query = ''; | ||
this.each(function (i, ele) { | ||
each(ele.elements || [ele], function (i, ele) { | ||
if (ele.disabled || !ele.name || ele.tagName === 'FIELDSET' || skippableRe.test(ele.type) || (checkableRe.test(ele.type) && !ele.checked)) | ||
return; | ||
var value = getValue(ele); | ||
if (!isUndefined(value)) { | ||
var values = isArray(value) ? value : [value]; | ||
each(values, function (i, value) { | ||
query += queryEncode(ele.name, value); | ||
}); | ||
} | ||
}); | ||
} | ||
}); | ||
}); | ||
return query.slice(1); | ||
return query.slice(1); | ||
}; | ||
function val(value) { | ||
if (!arguments.length) return this[0] && getValue(this[0]); | ||
return this.each(function (i, ele) { | ||
var isSelect = ele.multiple && ele.options; | ||
if (isSelect || checkableRe.test(ele.type)) { | ||
var eleValue_1 = isArray(value) ? map.call(value, String) : isNull(value) ? [] : [String(value)]; | ||
if (isSelect) { | ||
each(ele.options, function (i, option) { | ||
option.selected = eleValue_1.indexOf(option.value) >= 0; | ||
}, true); | ||
} else { | ||
ele.checked = eleValue_1.indexOf(ele.value) >= 0; | ||
} | ||
} else { | ||
ele.value = isUndefined(value) || isNull(value) ? '' : value; | ||
} | ||
}); | ||
} | ||
fn.val = val; | ||
fn.clone = function () { | ||
return this.map(function (i, ele) { | ||
return ele.cloneNode(true); | ||
}); | ||
}; | ||
fn.detach = function (comparator) { | ||
filtered(this, comparator).each(function (i, ele) { | ||
if (ele.parentNode) { | ||
ele.parentNode.removeChild(ele); | ||
} | ||
}); | ||
return this; | ||
}; | ||
var fragmentRe = /^\s*<(\w+)[^>]*>/, | ||
singleTagRe = /^<(\w+)\s*\/?>(?:<\/\1>)?$/; | ||
var containers = { | ||
'*': div, | ||
tr: tbody, | ||
td: tr, | ||
th: tr, | ||
thead: table, | ||
tbody: table, | ||
tfoot: table | ||
}; //TODO: Create elements inside a document fragment, in order to prevent inline event handlers from firing | ||
//TODO: Ensure the created elements have the fragment as their parent instead of null, this also ensures we can deal with detatched nodes more reliably | ||
function parseHTML(html) { | ||
if (!isString(html)) return []; | ||
if (singleTagRe.test(html)) return [createElement(RegExp.$1)]; | ||
var fragment = fragmentRe.test(html) && RegExp.$1, | ||
container = containers[fragment] || containers['*']; | ||
container.innerHTML = html; | ||
return cash(container.childNodes).detach().get(); | ||
} | ||
cash.parseHTML = parseHTML; | ||
fn.empty = function () { | ||
return this.each(function (i, ele) { | ||
while (ele.firstChild) { | ||
ele.removeChild(ele.firstChild); | ||
} | ||
}); | ||
}; | ||
function html(html) { | ||
if (!arguments.length) return this[0] && this[0].innerHTML; | ||
if (isUndefined(html)) return this; | ||
return this.each(function (i, ele) { | ||
if (!isElement(ele)) return; | ||
ele.innerHTML = html; | ||
}); | ||
} | ||
fn.html = html; | ||
fn.remove = function (comparator) { | ||
filtered(this, comparator).detach().off(); | ||
return this; | ||
}; | ||
function text(text) { | ||
if (isUndefined(text)) return this[0] ? this[0].textContent : ''; | ||
return this.each(function (i, ele) { | ||
if (!isElement(ele)) return; | ||
ele.textContent = text; | ||
}); | ||
} | ||
; | ||
fn.text = text; | ||
fn.unwrap = function () { | ||
this.parent().each(function (i, ele) { | ||
if (ele.tagName === 'BODY') return; | ||
var $ele = cash(ele); | ||
$ele.replaceWith($ele.children()); | ||
}); | ||
return this; | ||
}; | ||
fn.offset = function () { | ||
var ele = this[0]; | ||
if (!ele) return; | ||
var rect = ele.getBoundingClientRect(); | ||
return { | ||
top: rect.top + win.pageYOffset, | ||
left: rect.left + win.pageXOffset | ||
}; | ||
}; | ||
fn.offsetParent = function () { | ||
return this.map(function (i, ele) { | ||
var offsetParent = ele.offsetParent; | ||
while (offsetParent && computeStyle(offsetParent, 'position') === 'static') { | ||
offsetParent = offsetParent.offsetParent; | ||
} | ||
return offsetParent || docEle; | ||
}); | ||
}; | ||
fn.position = function () { | ||
var ele = this[0]; | ||
if (!ele) return; | ||
var isFixed = computeStyle(ele, 'position') === 'fixed', | ||
offset = isFixed ? ele.getBoundingClientRect() : this.offset(); | ||
if (!isFixed) { | ||
var doc_1 = ele.ownerDocument; | ||
var offsetParent = ele.offsetParent || doc_1.documentElement; | ||
while ((offsetParent === doc_1.body || offsetParent === doc_1.documentElement) && computeStyle(offsetParent, 'position') === 'static') { | ||
offsetParent = offsetParent.parentNode; | ||
} | ||
if (offsetParent !== ele && isElement(offsetParent)) { | ||
var parentOffset = cash(offsetParent).offset(); | ||
offset.top -= parentOffset.top + computeStyleInt(offsetParent, 'borderTopWidth'); | ||
offset.left -= parentOffset.left + computeStyleInt(offsetParent, 'borderLeftWidth'); | ||
} | ||
} | ||
return { | ||
top: offset.top - computeStyleInt(ele, 'marginTop'), | ||
left: offset.left - computeStyleInt(ele, 'marginLeft') | ||
}; | ||
}; | ||
fn.children = function (comparator) { | ||
return filtered(cash(unique(pluck(this, function (ele) { | ||
return ele.children; | ||
}))), comparator); | ||
}; | ||
fn.contents = function () { | ||
return cash(unique(pluck(this, function (ele) { | ||
return ele.tagName === 'IFRAME' ? [ele.contentDocument] : ele.tagName === 'TEMPLATE' ? ele.content.childNodes : ele.childNodes; | ||
}))); | ||
}; | ||
fn.find = function (selector) { | ||
return cash(unique(pluck(this, function (ele) { | ||
return find(selector, ele); | ||
}))); | ||
}; // @require core/variables.ts | ||
// @require core/types.ts | ||
// @require core/cash.ts | ||
// @require core/type_checking.ts | ||
// @require core/variables.ts | ||
// @require core/each.ts | ||
// @require core/extend.ts | ||
// @require core/find.ts | ||
// @require core/get_compare_function.ts | ||
// @require core/get_split_values.ts | ||
// @require core/guid.ts | ||
// @require core/parse_html.ts | ||
// @require core/unique.ts | ||
// @require attributes/add_class.ts | ||
// @require attributes/attr.ts | ||
// @require attributes/has_class.ts | ||
// @require attributes/prop.ts | ||
// @require attributes/remove_attr.ts | ||
// @require attributes/remove_class.ts | ||
// @require attributes/remove_prop.ts | ||
// @require attributes/toggle_class.ts | ||
// @require collection/add.ts | ||
// @require collection/each.ts | ||
// @require collection/eq.ts | ||
// @require collection/filter.ts | ||
// @require collection/first.ts | ||
// @require collection/get.ts | ||
// @require collection/index.ts | ||
// @require collection/last.ts | ||
// @require collection/map.ts | ||
// @require collection/slice.ts | ||
// @require css/css.ts | ||
// @require data/data.ts | ||
// @require dimensions/inner_outer.ts | ||
// @require dimensions/normal.ts | ||
// @require effects/hide.ts | ||
// @require effects/show.ts | ||
// @require effects/toggle.ts | ||
// @require events/off.ts | ||
// @require events/on.ts | ||
// @require events/one.ts | ||
// @require events/ready.ts | ||
// @require events/trigger.ts | ||
// @require forms/serialize.ts | ||
// @require forms/val.ts | ||
// @require manipulation/after.ts | ||
// @require manipulation/append.ts | ||
// @require manipulation/append_to.ts | ||
// @require manipulation/before.ts | ||
// @require manipulation/clone.ts | ||
// @require manipulation/detach.ts | ||
// @require manipulation/empty.ts | ||
// @require manipulation/html.ts | ||
// @require manipulation/insert_after.ts | ||
// @require manipulation/insert_before.ts | ||
// @require manipulation/prepend.ts | ||
// @require manipulation/prepend_to.ts | ||
// @require manipulation/remove.ts | ||
// @require manipulation/replace_all.ts | ||
// @require manipulation/replace_with.ts | ||
// @require manipulation/text.ts | ||
// @require manipulation/unwrap.ts | ||
// @require manipulation/wrap.ts | ||
// @require manipulation/wrap_all.ts | ||
// @require manipulation/wrap_inner.ts | ||
// @require offset/offset.ts | ||
// @require offset/offset_parent.ts | ||
// @require offset/position.ts | ||
// @require traversal/children.ts | ||
// @require traversal/closest.ts | ||
// @require traversal/contents.ts | ||
// @require traversal/find.ts | ||
var HTMLCDATARe = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g, | ||
scriptTypeRe = /^$|^module$|\/(java|ecma)script/i, | ||
scriptAttributes = ['type', 'src', 'nonce', 'noModule']; | ||
function evalScripts(node, doc) { | ||
var collection = cash(node); | ||
collection.filter('script').add(collection.find('script')).each(function (i, ele) { | ||
if (scriptTypeRe.test(ele.type) && docEle.contains(ele)) { | ||
// The script type is supported // The element is attached to the DOM // Using `documentElement` for broader browser support | ||
var script_1 = createElement('script'); | ||
script_1.text = ele.textContent.replace(HTMLCDATARe, ''); | ||
each(scriptAttributes, function (i, attr) { | ||
if (ele[attr]) script_1[attr] = ele[attr]; | ||
}); | ||
doc.head.insertBefore(script_1, null); | ||
doc.head.removeChild(script_1); | ||
} | ||
}); | ||
} // @require ./eval_scripts.ts | ||
function insertElement(anchor, target, left, inside, evaluate) { | ||
if (inside) { | ||
// prepend/append | ||
anchor.insertBefore(target, left ? anchor.firstChild : null); | ||
} else { | ||
// before/after | ||
if (anchor.nodeName === 'HTML') { | ||
anchor.parentNode.replaceChild(target, anchor); | ||
} else { | ||
anchor.parentNode.insertBefore(target, left ? anchor : anchor.nextSibling); | ||
} | ||
} | ||
if (evaluate) { | ||
evalScripts(target, anchor.ownerDocument); | ||
} | ||
} // @require ./insert_element.ts | ||
function insertSelectors(selectors, anchors, inverse, left, inside, reverseLoop1, reverseLoop2, reverseLoop3) { | ||
each(selectors, function (si, selector) { | ||
each(cash(selector), function (ti, target) { | ||
each(cash(anchors), function (ai, anchor) { | ||
var anchorFinal = inverse ? target : anchor, | ||
targetFinal = inverse ? anchor : target, | ||
indexFinal = inverse ? ti : ai; | ||
insertElement(anchorFinal, !indexFinal ? targetFinal : targetFinal.cloneNode(true), left, inside, !indexFinal); | ||
}, reverseLoop3); | ||
}, reverseLoop2); | ||
}, reverseLoop1); | ||
return anchors; | ||
// @require traversal/has.ts | ||
// @require traversal/is.ts | ||
// @require traversal/next.ts | ||
// @require traversal/next_all.ts | ||
// @require traversal/next_until.ts | ||
// @require traversal/not.ts | ||
// @require traversal/parent.ts | ||
// @require traversal/parents.ts | ||
// @require traversal/parents_until.ts | ||
// @require traversal/prev.ts | ||
// @require traversal/prev_all.ts | ||
// @require traversal/prev_until.ts | ||
// @require traversal/siblings.ts | ||
// @no-require extras/get_script.ts | ||
// @no-require extras/shorthands.ts | ||
// @require methods.ts | ||
if (typeof exports !== 'undefined') { // Node.js | ||
module.exports = cash; | ||
} | ||
fn.after = function () { | ||
return insertSelectors(arguments, this, false, false, false, true, true); | ||
}; | ||
fn.append = function () { | ||
return insertSelectors(arguments, this, false, false, true); | ||
}; | ||
fn.appendTo = function (selector) { | ||
return insertSelectors(arguments, this, true, false, true); | ||
}; | ||
fn.before = function () { | ||
return insertSelectors(arguments, this, false, true); | ||
}; | ||
fn.insertAfter = function (selector) { | ||
return insertSelectors(arguments, this, true, false, false, false, false, true); | ||
}; | ||
fn.insertBefore = function (selector) { | ||
return insertSelectors(arguments, this, true, true); | ||
}; | ||
fn.prepend = function () { | ||
return insertSelectors(arguments, this, false, true, true, true, true); | ||
}; | ||
fn.prependTo = function (selector) { | ||
return insertSelectors(arguments, this, true, true, true, false, false, true); | ||
}; | ||
fn.replaceWith = function (selector) { | ||
return this.before(selector).remove(); | ||
}; | ||
fn.replaceAll = function (selector) { | ||
cash(selector).replaceWith(this); | ||
return this; | ||
}; | ||
fn.wrapAll = function (selector) { | ||
var structure = cash(selector), | ||
wrapper = structure[0]; | ||
while (wrapper.children.length) { | ||
wrapper = wrapper.firstElementChild; | ||
} | ||
this.first().before(structure); | ||
return this.appendTo(wrapper); | ||
}; | ||
fn.wrap = function (selector) { | ||
return this.each(function (i, ele) { | ||
var wrapper = cash(selector)[0]; | ||
cash(ele).wrapAll(!i ? wrapper : wrapper.cloneNode(true)); | ||
}); | ||
}; | ||
fn.wrapInner = function (selector) { | ||
return this.each(function (i, ele) { | ||
var $ele = cash(ele), | ||
contents = $ele.contents(); | ||
contents.length ? contents.wrapAll(selector) : $ele.append(selector); | ||
}); | ||
}; | ||
fn.has = function (selector) { | ||
var comparator = isString(selector) ? function (i, ele) { | ||
return find(selector, ele).length; | ||
} : function (i, ele) { | ||
return ele.contains(selector); | ||
}; | ||
return this.filter(comparator); | ||
}; | ||
fn.is = function (comparator) { | ||
var compare = getCompareFunction(comparator); | ||
return some.call(this, function (ele, i) { | ||
return compare.call(ele, i, ele); | ||
}); | ||
}; | ||
fn.next = function (comparator, _all, _until) { | ||
return filtered(cash(unique(pluck(this, 'nextElementSibling', _all, _until))), comparator); | ||
}; | ||
fn.nextAll = function (comparator) { | ||
return this.next(comparator, true); | ||
}; | ||
fn.nextUntil = function (until, comparator) { | ||
return this.next(comparator, true, until); | ||
}; | ||
fn.not = function (comparator) { | ||
var compare = getCompareFunction(comparator); | ||
return this.filter(function (i, ele) { | ||
return (!isString(comparator) || isElement(ele)) && !compare.call(ele, i, ele); | ||
}); | ||
}; | ||
fn.parent = function (comparator) { | ||
return filtered(cash(unique(pluck(this, 'parentNode'))), comparator); | ||
}; | ||
fn.index = function (selector) { | ||
var child = selector ? cash(selector)[0] : this[0], | ||
collection = selector ? this : cash(child).parent().children(); | ||
return indexOf.call(collection, child); | ||
}; | ||
fn.closest = function (comparator) { | ||
var filtered = this.filter(comparator); | ||
if (filtered.length) return filtered; | ||
var $parent = this.parent(); | ||
if (!$parent.length) return filtered; | ||
return $parent.closest(comparator); | ||
}; | ||
fn.parents = function (comparator, _until) { | ||
return filtered(cash(unique(pluck(this, 'parentElement', true, _until))), comparator); | ||
}; | ||
fn.parentsUntil = function (until, comparator) { | ||
return this.parents(comparator, until); | ||
}; | ||
fn.prev = function (comparator, _all, _until) { | ||
return filtered(cash(unique(pluck(this, 'previousElementSibling', _all, _until))), comparator); | ||
}; | ||
fn.prevAll = function (comparator) { | ||
return this.prev(comparator, true); | ||
}; | ||
fn.prevUntil = function (until, comparator) { | ||
return this.prev(comparator, true, until); | ||
}; | ||
fn.siblings = function (comparator) { | ||
return filtered(cash(unique(pluck(this, function (ele) { | ||
return cash(ele).parent().children().not(ele); | ||
}))), comparator); | ||
}; // @optional ./children.ts | ||
// @optional ./closest.ts | ||
// @optional ./contents.ts | ||
// @optional ./find.ts | ||
// @optional ./has.ts | ||
// @optional ./is.ts | ||
// @optional ./next.ts | ||
// @optional ./next_all.ts | ||
// @optional ./next_until.ts | ||
// @optional ./not.ts | ||
// @optional ./parent.ts | ||
// @optional ./parents.ts | ||
// @optional ./parents_until.ts | ||
// @optional ./prev.ts | ||
// @optional ./prev_all.ts | ||
// @optional ./prev_until.ts | ||
// @optional ./siblings.ts | ||
// @optional attributes/index.ts | ||
// @optional collection/index.ts | ||
// @optional css/index.ts | ||
// @optional data/index.ts | ||
// @optional dimensions/index.ts | ||
// @optional effects/index.ts | ||
// @optional events/index.ts | ||
// @optional forms/index.ts | ||
// @optional manipulation/index.ts | ||
// @optional offset/index.ts | ||
// @optional traversal/index.ts | ||
// @require core/index.ts | ||
// @priority -100 | ||
// @require ./cash.ts | ||
// @require ./variables.ts | ||
if (typeof exports !== 'undefined') { | ||
// Node.js | ||
module.exports = cash; | ||
} else { | ||
// Browser | ||
win['cash'] = win['$'] = cash; | ||
else { // Browser | ||
win['cash'] = win['$'] = cash; | ||
} | ||
})(); |
@@ -1,46 +0,2 @@ | ||
/* MIT https://github.com/fabiospampinato/cash */ | ||
(function(){ | ||
var aa={"class":"className",contenteditable:"contentEditable","for":"htmlFor",readonly:"readOnly",maxlength:"maxLength",tabindex:"tabIndex",colspan:"colSpan",rowspan:"rowSpan",usemap:"useMap"};function ba(a,b){try{return a(b)}catch(c){return b}} | ||
var e=document,k=window,ca=e.documentElement,p=e.createElement.bind(e),da=p("div"),q=p("table"),ea=p("tbody"),ha=p("tr"),v=Array.isArray,x=Array.prototype,ia=x.concat,y=x.filter,ja=x.indexOf,ka=x.map,la=x.push,ma=x.slice,z=x.some,na=x.splice,oa=/^#(?:[\w-]|\\.|[^\x00-\xa0])*$/,pa=/^\.(?:[\w-]|\\.|[^\x00-\xa0])*$/,qa=/<.+>/,ra=/^\w+$/; | ||
function A(a,b){var c=!!b&&11===b.nodeType;return a&&(c||B(b)||C(b))?!c&&pa.test(a)?b.getElementsByClassName(a.slice(1)):!c&&ra.test(a)?b.getElementsByTagName(a):b.querySelectorAll(a):[]} | ||
var D=function(){function a(b,c){if(b){if(b instanceof D)return b;var d=b;if(G(b)){if(d=(c instanceof D?c[0]:c)||e,d=oa.test(b)&&"getElementById"in d?d.getElementById(b.slice(1)):qa.test(b)?sa(b):A(b,d),!d)return}else if(H(b))return this.ready(b);if(d.nodeType||d===k)d=[d];this.length=d.length;b=0;for(c=this.length;b<c;b++)this[b]=d[b]}}a.prototype.init=function(b,c){return new a(b,c)};return a}(),I=D.prototype,J=I.init;J.fn=J.prototype=I;I.length=0;I.splice=na; | ||
"function"===typeof Symbol&&(I[Symbol.iterator]=x[Symbol.iterator]);I.map=function(a){return J(ia.apply([],ka.call(this,function(b,c){return a.call(b,c,b)})))};I.slice=function(a,b){return J(ma.call(this,a,b))};var ta=/-([a-z])/g;function K(a){return a.replace(ta,function(b,c){return c.toUpperCase()})}J.guid=1;function ua(a,b){var c=a&&(a.matches||a.webkitMatchesSelector||a.msMatchesSelector);return!!c&&!!b&&c.call(a,b)}function L(a){return!!a&&a===a.window} | ||
function B(a){return!!a&&9===a.nodeType}function C(a){return!!a&&1===a.nodeType}function H(a){return"function"===typeof a}function G(a){return"string"===typeof a}function va(a){return!isNaN(parseFloat(a))&&isFinite(a)}function wa(a){if("object"!==typeof a||null===a)return!1;a=Object.getPrototypeOf(a);return null===a||a===Object.prototype}J.isWindow=L;J.isFunction=H;J.isArray=v;J.isNumeric=va;J.isPlainObject=wa; | ||
I.get=function(a){if(void 0===a)return ma.call(this);a=Number(a);return this[0>a?a+this.length:a]};I.eq=function(a){return J(this.get(a))};I.first=function(){return this.eq(0)};I.last=function(){return this.eq(-1)};function M(a,b,c){if(c)for(c=a.length;c--&&!1!==b.call(a[c],c,a[c]););else if(wa(a)){var d=Object.keys(a);c=0;for(var f=d.length;c<f;c++){var g=d[c];if(!1===b.call(a[g],g,a[g]))break}}else for(c=0,f=a.length;c<f&&!1!==b.call(a[c],c,a[c]);c++);return a}J.each=M; | ||
I.each=function(a){return M(this,a)};I.prop=function(a,b){if(a){if(G(a))return a=aa[a]||a,2>arguments.length?this[0]&&this[0][a]:this.each(function(d,f){f[a]=b});for(var c in a)this.prop(c,a[c]);return this}};I.removeProp=function(a){return this.each(function(b,c){delete c[aa[a]||a]})}; | ||
function N(){for(var a=[],b=0;b<arguments.length;b++)a[b]=arguments[b];b="boolean"===typeof a[0]?a.shift():!1;var c=a.shift(),d=a.length;if(!c)return{};if(!d)return N(b,J,c);for(var f=0;f<d;f++){var g=a[f],h;for(h in g)b&&(v(g[h])||wa(g[h]))?(c[h]&&c[h].constructor===g[h].constructor||(c[h]=new g[h].constructor),N(b,c[h],g[h])):c[h]=g[h]}return c}J.extend=N;I.extend=function(a){return N(I,a)}; | ||
function O(a){return G(a)?function(b,c){return ua(c,a)}:H(a)?a:a instanceof D?function(b,c){return a.is(c)}:a?function(b,c){return c===a}:function(){return!1}}I.filter=function(a){var b=O(a);return J(y.call(this,function(c,d){return b.call(c,d,c)}))};function P(a,b){return b?a.filter(b):a}var xa=/\S+/g;function Q(a){return G(a)?a.match(xa)||[]:[]}I.hasClass=function(a){return!!a&&z.call(this,function(b){return C(b)&&b.classList.contains(a)})}; | ||
I.removeAttr=function(a){var b=Q(a);return this.each(function(c,d){C(d)&&M(b,function(f,g){d.removeAttribute(g)})})};I.attr=function(a,b){if(a){if(G(a)){if(2>arguments.length){if(!this[0]||!C(this[0]))return;var c=this[0].getAttribute(a);return null===c?void 0:c}return void 0===b?this:null===b?this.removeAttr(a):this.each(function(d,f){C(f)&&f.setAttribute(a,b)})}for(c in a)this.attr(c,a[c]);return this}}; | ||
I.toggleClass=function(a,b){var c=Q(a),d=void 0!==b;return this.each(function(f,g){C(g)&&M(c,function(h,m){d?b?g.classList.add(m):g.classList.remove(m):g.classList.toggle(m)})})};I.addClass=function(a){return this.toggleClass(a,!0)};I.removeClass=function(a){return arguments.length?this.toggleClass(a,!1):this.attr("class","")}; | ||
function R(a,b,c,d){for(var f=[],g=H(b),h=d&&O(d),m=0,l=a.length;m<l;m++)if(g){var u=b(a[m]);u.length&&la.apply(f,u)}else for(u=a[m][b];!(null==u||d&&h(-1,u));)f.push(u),u=c?u[b]:null;return f}function S(a){return 1<a.length?y.call(a,function(b,c,d){return ja.call(d,b)===c}):a}J.unique=S;I.add=function(a,b){return J(S(this.get().concat(J(a,b).get())))};function T(a,b,c){if(C(a)){var d=k.getComputedStyle(a,null);return c?d.getPropertyValue(b)||void 0:d[b]||a.style[b]}} | ||
function V(a,b){return parseInt(T(a,b),10)||0}var ya=/^--/,za={},Aa=da.style,Ba=["webkit","moz","ms"];function Ca(a,b){void 0===b&&(b=ya.test(a));if(b)return a;if(!za[a]){b=K(a);var c=""+b[0].toUpperCase()+b.slice(1);b=(b+" "+Ba.join(c+" ")+c).split(" ");M(b,function(d,f){if(f in Aa)return za[a]=f,!1})}return za[a]} | ||
var Da={animationIterationCount:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0};function Ea(a,b,c){void 0===c&&(c=ya.test(a));return c||Da[a]||!va(b)?b:b+"px"} | ||
I.css=function(a,b){if(G(a)){var c=ya.test(a);a=Ca(a,c);if(2>arguments.length)return this[0]&&T(this[0],a,c);if(!a)return this;b=Ea(a,b,c);return this.each(function(f,g){C(g)&&(c?g.style.setProperty(a,b):g.style[a]=b)})}for(var d in a)this.css(d,a[d]);return this};var Fa=/^\s+|\s+$/;function Ga(a,b){a=a.dataset[b]||a.dataset[K(b)];return Fa.test(a)?a:ba(JSON.parse,a)} | ||
I.data=function(a,b){if(!a){if(!this[0])return;var c={},d;for(d in this[0].dataset)c[d]=Ga(this[0],d);return c}if(G(a))return 2>arguments.length?this[0]&&Ga(this[0],a):void 0===b?this:this.each(function(f,g){f=b;f=ba(JSON.stringify,f);g.dataset[K(a)]=f});for(d in a)this.data(d,a[d]);return this};function Ha(a,b){var c=a.documentElement;return Math.max(a.body["scroll"+b],c["scroll"+b],a.body["offset"+b],c["offset"+b],c["client"+b])} | ||
function Ia(a,b){return V(a,"border"+(b?"Left":"Top")+"Width")+V(a,"padding"+(b?"Left":"Top"))+V(a,"padding"+(b?"Right":"Bottom"))+V(a,"border"+(b?"Right":"Bottom")+"Width")} | ||
M([!0,!1],function(a,b){M(["Width","Height"],function(c,d){I[(b?"outer":"inner")+d]=function(f){if(this[0])return L(this[0])?b?this[0]["inner"+d]:this[0].document.documentElement["client"+d]:B(this[0])?Ha(this[0],d):this[0][(b?"offset":"client")+d]+(f&&b?V(this[0],"margin"+(c?"Top":"Left"))+V(this[0],"margin"+(c?"Bottom":"Right")):0)}})}); | ||
M(["Width","Height"],function(a,b){var c=b.toLowerCase();I[c]=function(d){if(!this[0])return void 0===d?void 0:this;if(!arguments.length)return L(this[0])?this[0].document.documentElement["client"+b]:B(this[0])?Ha(this[0],b):this[0].getBoundingClientRect()[c]-Ia(this[0],!a);var f=parseInt(d,10);return this.each(function(g,h){C(h)&&(g=T(h,"boxSizing"),h.style[c]=Ea(c,f+("border-box"===g?Ia(h,!a):0)))})}});var Ja={}; | ||
I.toggle=function(a){return this.each(function(b,c){if(C(c))if(void 0===a?"none"===T(c,"display"):a){if(c.style.display=c.___cd||"","none"===T(c,"display")){b=c.style;c=c.tagName;if(Ja[c])c=Ja[c];else{var d=p(c);e.body.insertBefore(d,null);var f=T(d,"display");e.body.removeChild(d);c=Ja[c]="none"!==f?f:"block"}b.display=c}}else c.___cd=T(c,"display"),c.style.display="none"})};I.hide=function(){return this.toggle(!1)};I.show=function(){return this.toggle(!0)}; | ||
function Ka(a,b){return!b||!z.call(b,function(c){return 0>a.indexOf(c)})}var W={focus:"focusin",blur:"focusout"},X={mouseenter:"mouseover",mouseleave:"mouseout"},La=/^(mouse|pointer|contextmenu|drag|drop|click|dblclick)/i;function Ma(a,b,c,d,f){var g=a.___ce=a.___ce||{};g[b]=g[b]||[];g[b].push([c,d,f]);a.addEventListener(b,f)}function Na(a){a=a.split(".");return[a[0],a.slice(1).sort()]} | ||
function Y(a,b,c,d,f){var g=a.___ce=a.___ce||{};if(b)g[b]&&(g[b]=g[b].filter(function(h){var m=h[0],l=h[1];h=h[2];if(f&&h.guid!==f.guid||!Ka(m,c)||d&&d!==l)return!0;a.removeEventListener(b,h)}));else for(b in g)Y(a,b,c,d,f)} | ||
I.off=function(a,b,c){var d=this;if(void 0===a)this.each(function(g,h){(C(h)||B(h)||L(h))&&Y(h)});else if(G(a))H(b)&&(c=b,b=""),M(Q(a),function(g,h){g=Na(h);h=g[0];var m=g[1],l=X[h]||W[h]||h;d.each(function(u,w){(C(w)||B(w)||L(w))&&Y(w,l,m,b,c)})});else for(var f in a)this.off(f,a[f]);return this}; | ||
I.on=function(a,b,c,d,f){var g=this;if(!G(a)){for(var h in a)this.on(h,b,c,a[h],f);return this}G(b)||(void 0!==b&&null!==b&&(void 0!==c&&(d=c),c=b),b="");H(d)||(d=c,c=void 0);if(!d)return this;M(Q(a),function(m,l){m=Na(l);l=m[0];var u=m[1],w=X[l]||W[l]||l,U=l in X,E=l in W;w&&g.each(function(t,n){if(C(n)||B(n)||L(n))t=function Ra(r){if(r.target["___i"+r.type])return r.stopImmediatePropagation();if(!r.namespace||Ka(u,r.namespace.split(".")))if(b||!(E&&(r.target!==n||r.___ot===w)||U&&r.relatedTarget&& | ||
n.contains(r.relatedTarget))){var fa=n;if(b){for(var F=r.target;!ua(F,b);){if(F===n)return;F=F.parentNode;if(!F)return}fa=F}Object.defineProperty(r,"currentTarget",{configurable:!0,get:function(){return fa}});Object.defineProperty(r,"delegateTarget",{configurable:!0,get:function(){return n}});Object.defineProperty(r,"data",{configurable:!0,get:function(){return c}});F=d.call(fa,r,r.___td);f&&Y(n,w,u,b,Ra);!1===F&&(r.preventDefault(),r.stopPropagation())}},t.guid=d.guid=d.guid||J.guid++,Ma(n,w,u,b, | ||
t)})});return this};I.one=function(a,b,c,d){return this.on(a,b,c,d,!0)};I.ready=function(a){function b(){return setTimeout(a,0,J)}"loading"!==e.readyState?b():e.addEventListener("DOMContentLoaded",b);return this}; | ||
I.trigger=function(a,b){if(G(a)){var c=Na(a),d=c[0];c=c[1];var f=X[d]||W[d]||d;if(!f)return this;var g=La.test(f)?"MouseEvents":"HTMLEvents";a=e.createEvent(g);a.initEvent(f,!0,!0);a.namespace=c.join(".");a.___ot=d}a.___td=b;var h=a.___ot in W;return this.each(function(m,l){h&&H(l[a.___ot])&&(l["___i"+a.type]=!0,l[a.___ot](),l["___i"+a.type]=!1);l.dispatchEvent(a)})}; | ||
function Oa(a){return a.multiple&&a.options?R(y.call(a.options,function(b){return b.selected&&!b.disabled&&!b.parentNode.disabled}),"value"):a.value||""}var Pa=/%20/g,Qa=/\r?\n/g,Sa=/file|reset|submit|button|image/i,Ta=/radio|checkbox/i; | ||
I.serialize=function(){var a="";this.each(function(b,c){M(c.elements||[c],function(d,f){f.disabled||!f.name||"FIELDSET"===f.tagName||Sa.test(f.type)||Ta.test(f.type)&&!f.checked||(d=Oa(f),void 0!==d&&(d=v(d)?d:[d],M(d,function(g,h){g=a;h="&"+encodeURIComponent(f.name)+"="+encodeURIComponent(h.replace(Qa,"\r\n")).replace(Pa,"+");a=g+h})))})});return a.slice(1)}; | ||
I.val=function(a){return arguments.length?this.each(function(b,c){if((b=c.multiple&&c.options)||Ta.test(c.type)){var d=v(a)?ka.call(a,String):null===a?[]:[String(a)];b?M(c.options,function(f,g){g.selected=0<=d.indexOf(g.value)},!0):c.checked=0<=d.indexOf(c.value)}else c.value=void 0===a||null===a?"":a}):this[0]&&Oa(this[0])};I.clone=function(){return this.map(function(a,b){return b.cloneNode(!0)})};I.detach=function(a){P(this,a).each(function(b,c){c.parentNode&&c.parentNode.removeChild(c)});return this}; | ||
var Ua=/^\s*<(\w+)[^>]*>/,Va=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,Wa={"*":da,tr:ea,td:ha,th:ha,thead:q,tbody:q,tfoot:q};function sa(a){if(!G(a))return[];if(Va.test(a))return[p(RegExp.$1)];var b=Ua.test(a)&&RegExp.$1;b=Wa[b]||Wa["*"];b.innerHTML=a;return J(b.childNodes).detach().get()}J.parseHTML=sa;I.empty=function(){return this.each(function(a,b){for(;b.firstChild;)b.removeChild(b.firstChild)})}; | ||
I.html=function(a){return arguments.length?void 0===a?this:this.each(function(b,c){C(c)&&(c.innerHTML=a)}):this[0]&&this[0].innerHTML};I.remove=function(a){P(this,a).detach().off();return this};I.text=function(a){return void 0===a?this[0]?this[0].textContent:"":this.each(function(b,c){C(c)&&(c.textContent=a)})};I.unwrap=function(){this.parent().each(function(a,b){"BODY"!==b.tagName&&(a=J(b),a.replaceWith(a.children()))});return this}; | ||
I.offset=function(){var a=this[0];if(a)return a=a.getBoundingClientRect(),{top:a.top+k.pageYOffset,left:a.left+k.pageXOffset}};I.offsetParent=function(){return this.map(function(a,b){for(a=b.offsetParent;a&&"static"===T(a,"position");)a=a.offsetParent;return a||ca})}; | ||
I.position=function(){var a=this[0];if(a){var b="fixed"===T(a,"position"),c=b?a.getBoundingClientRect():this.offset();if(!b){var d=a.ownerDocument;for(b=a.offsetParent||d.documentElement;(b===d.body||b===d.documentElement)&&"static"===T(b,"position");)b=b.parentNode;b!==a&&C(b)&&(d=J(b).offset(),c.top-=d.top+V(b,"borderTopWidth"),c.left-=d.left+V(b,"borderLeftWidth"))}return{top:c.top-V(a,"marginTop"),left:c.left-V(a,"marginLeft")}}}; | ||
I.children=function(a){return P(J(S(R(this,function(b){return b.children}))),a)};I.contents=function(){return J(S(R(this,function(a){return"IFRAME"===a.tagName?[a.contentDocument]:"TEMPLATE"===a.tagName?a.content.childNodes:a.childNodes})))};I.find=function(a){return J(S(R(this,function(b){return A(a,b)})))};var Xa=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,Ya=/^$|^module$|\/(java|ecma)script/i,Za=["type","src","nonce","noModule"]; | ||
function $a(a,b){a=J(a);a.filter("script").add(a.find("script")).each(function(c,d){if(Ya.test(d.type)&&ca.contains(d)){var f=p("script");f.text=d.textContent.replace(Xa,"");M(Za,function(g,h){d[h]&&(f[h]=d[h])});b.head.insertBefore(f,null);b.head.removeChild(f)}})} | ||
function Z(a,b,c,d,f,g,h,m){M(a,function(l,u){M(J(u),function(w,U){M(J(b),function(E,t){var n=c?t:U;E=c?w:E;t=c?U:t;n=E?n.cloneNode(!0):n;E=!E;f?t.insertBefore(n,d?t.firstChild:null):"HTML"===t.nodeName?t.parentNode.replaceChild(n,t):t.parentNode.insertBefore(n,d?t:t.nextSibling);E&&$a(n,t.ownerDocument)},m)},h)},g);return b}I.after=function(){return Z(arguments,this,!1,!1,!1,!0,!0)};I.append=function(){return Z(arguments,this,!1,!1,!0)};I.appendTo=function(a){return Z(arguments,this,!0,!1,!0)}; | ||
I.before=function(){return Z(arguments,this,!1,!0)};I.insertAfter=function(a){return Z(arguments,this,!0,!1,!1,!1,!1,!0)};I.insertBefore=function(a){return Z(arguments,this,!0,!0)};I.prepend=function(){return Z(arguments,this,!1,!0,!0,!0,!0)};I.prependTo=function(a){return Z(arguments,this,!0,!0,!0,!1,!1,!0)};I.replaceWith=function(a){return this.before(a).remove()};I.replaceAll=function(a){J(a).replaceWith(this);return this}; | ||
I.wrapAll=function(a){a=J(a);for(var b=a[0];b.children.length;)b=b.firstElementChild;this.first().before(a);return this.appendTo(b)};I.wrap=function(a){return this.each(function(b,c){var d=J(a)[0];J(c).wrapAll(b?d.cloneNode(!0):d)})};I.wrapInner=function(a){return this.each(function(b,c){b=J(c);c=b.contents();c.length?c.wrapAll(a):b.append(a)})};I.has=function(a){var b=G(a)?function(c,d){return A(a,d).length}:function(c,d){return d.contains(a)};return this.filter(b)}; | ||
I.is=function(a){var b=O(a);return z.call(this,function(c,d){return b.call(c,d,c)})};I.next=function(a,b,c){return P(J(S(R(this,"nextElementSibling",b,c))),a)};I.nextAll=function(a){return this.next(a,!0)};I.nextUntil=function(a,b){return this.next(b,!0,a)};I.not=function(a){var b=O(a);return this.filter(function(c,d){return(!G(a)||C(d))&&!b.call(d,c,d)})};I.parent=function(a){return P(J(S(R(this,"parentNode"))),a)}; | ||
I.index=function(a){var b=a?J(a)[0]:this[0];a=a?this:J(b).parent().children();return ja.call(a,b)};I.closest=function(a){var b=this.filter(a);if(b.length)return b;var c=this.parent();return c.length?c.closest(a):b};I.parents=function(a,b){return P(J(S(R(this,"parentElement",!0,b))),a)};I.parentsUntil=function(a,b){return this.parents(b,a)};I.prev=function(a,b,c){return P(J(S(R(this,"previousElementSibling",b,c))),a)};I.prevAll=function(a){return this.prev(a,!0)}; | ||
I.prevUntil=function(a,b){return this.prev(b,!0,a)};I.siblings=function(a){return P(J(S(R(this,function(b){return J(b).parent().children().not(b)}))),a)};"undefined"!==typeof exports?module.exports=J:k.cash=k.$=J; | ||
})(); | ||
(function(){"use strict";var C=document,M=window,st=C.documentElement,L=C.createElement.bind(C),ft=L("div"),q=L("table"),Mt=L("tbody"),ot=L("tr"),H=Array.isArray,S=Array.prototype,Bt=S.concat,U=S.filter,at=S.indexOf,ct=S.map,Dt=S.push,ht=S.slice,z=S.some,_t=S.splice,Pt=/^#(?:[\w-]|\\.|[^\x00-\xa0])*$/,Ht=/^\.(?:[\w-]|\\.|[^\x00-\xa0])*$/,It=/<.+>/,$t=/^\w+$/;function J(t,n){var r=jt(n);return!t||!r&&!D(n)&&!h(n)?[]:!r&&Ht.test(t)?n.getElementsByClassName(t.slice(1).replace(/\\/g,"")):!r&&$t.test(t)?n.getElementsByTagName(t):n.querySelectorAll(t)}var dt=function(){function t(n,r){if(!!n){if(Y(n))return n;var i=n;if(g(n)){var u=(Y(r)?r[0]:r)||C;if(i=Pt.test(n)&&"getElementById"in u?u.getElementById(n.slice(1).replace(/\\/g,"")):It.test(n)?yt(n):J(n,u),!i)return}else if(A(n))return this.ready(n);(i.nodeType||i===M)&&(i=[i]),this.length=i.length;for(var s=0,f=this.length;s<f;s++)this[s]=i[s]}}return t.prototype.init=function(n,r){return new t(n,r)},t}(),e=dt.prototype,o=e.init;o.fn=o.prototype=e,e.length=0,e.splice=_t,typeof Symbol=="function"&&(e[Symbol.iterator]=S[Symbol.iterator]);function Y(t){return t instanceof dt}function B(t){return!!t&&t===t.window}function D(t){return!!t&&t.nodeType===9}function jt(t){return!!t&&t.nodeType===11}function h(t){return!!t&&t.nodeType===1}function Ft(t){return typeof t=="boolean"}function A(t){return typeof t=="function"}function g(t){return typeof t=="string"}function v(t){return t===void 0}function P(t){return t===null}function lt(t){return!isNaN(parseFloat(t))&&isFinite(t)}function G(t){if(typeof t!="object"||t===null)return!1;var n=Object.getPrototypeOf(t);return n===null||n===Object.prototype}o.isWindow=B,o.isFunction=A,o.isArray=H,o.isNumeric=lt,o.isPlainObject=G;function d(t,n,r){if(r){for(var i=t.length;i--;)if(n.call(t[i],i,t[i])===!1)return t}else if(G(t))for(var u=Object.keys(t),i=0,s=u.length;i<s;i++){var f=u[i];if(n.call(t[f],f,t[f])===!1)return t}else for(var i=0,s=t.length;i<s;i++)if(n.call(t[i],i,t[i])===!1)return t;return t}o.each=d,e.each=function(t){return d(this,t)},e.empty=function(){return this.each(function(t,n){for(;n.firstChild;)n.removeChild(n.firstChild)})};function Wt(t){return v(t)?this[0]?this[0].textContent:"":this.each(function(n,r){!h(r)||(r.textContent=t)})}e.text=Wt;function I(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=Ft(t[0])?t.shift():!1,i=t.shift(),u=t.length;if(!i)return{};if(!u)return I(r,o,i);for(var s=0;s<u;s++){var f=t[s];for(var a in f)r&&(H(f[a])||G(f[a]))?((!i[a]||i[a].constructor!==f[a].constructor)&&(i[a]=new f[a].constructor),I(r,i[a],f[a])):i[a]=f[a]}return i}o.extend=I,e.extend=function(t){return I(e,t)};var qt=/\S+/g;function $(t){return g(t)?t.match(qt)||[]:[]}e.toggleClass=function(t,n){var r=$(t),i=!v(n);return this.each(function(u,s){!h(s)||d(r,function(f,a){i?n?s.classList.add(a):s.classList.remove(a):s.classList.toggle(a)})})},e.addClass=function(t){return this.toggleClass(t,!0)},e.removeAttr=function(t){var n=$(t);return this.each(function(r,i){!h(i)||d(n,function(u,s){i.removeAttribute(s)})})};function Ut(t,n){if(!!t){if(g(t)){if(arguments.length<2){if(!this[0]||!h(this[0]))return;var r=this[0].getAttribute(t);return P(r)?void 0:r}return v(n)?this:P(n)?this.removeAttr(t):this.each(function(u,s){!h(s)||s.setAttribute(t,n)})}for(var i in t)this.attr(i,t[i]);return this}}e.attr=Ut,e.removeClass=function(t){return arguments.length?this.toggleClass(t,!1):this.attr("class","")},e.hasClass=function(t){return!!t&&z.call(this,function(n){return h(n)&&n.classList.contains(t)})},e.get=function(t){return v(t)?ht.call(this):(t=Number(t),this[t<0?t+this.length:t])},e.eq=function(t){return o(this.get(t))},e.first=function(){return this.eq(0)},e.last=function(){return this.eq(-1)};function T(t,n,r){if(!!h(t)){var i=M.getComputedStyle(t,null);return r?i.getPropertyValue(n)||void 0:i[n]||t.style[n]}}function E(t,n){return parseInt(T(t,n),10)||0}function gt(t,n){return E(t,"border".concat(n?"Left":"Top","Width"))+E(t,"padding".concat(n?"Left":"Top"))+E(t,"padding".concat(n?"Right":"Bottom"))+E(t,"border".concat(n?"Right":"Bottom","Width"))}var X={};function zt(t){if(X[t])return X[t];var n=L(t);C.body.insertBefore(n,null);var r=T(n,"display");return C.body.removeChild(n),X[t]=r!=="none"?r:"block"}function vt(t){return T(t,"display")==="none"}function pt(t,n){var r=t&&(t.matches||t.webkitMatchesSelector||t.msMatchesSelector);return!!r&&!!n&&r.call(t,n)}function j(t){return g(t)?function(n,r){return pt(r,t)}:A(t)?t:Y(t)?function(n,r){return t.is(r)}:t?function(n,r){return r===t}:function(){return!1}}e.filter=function(t){var n=j(t);return o(U.call(this,function(r,i){return n.call(r,i,r)}))};function x(t,n){return n?t.filter(n):t}e.detach=function(t){return x(this,t).each(function(n,r){r.parentNode&&r.parentNode.removeChild(r)}),this};var Jt=/^\s*<(\w+)[^>]*>/,Yt=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,mt={"*":ft,tr:Mt,td:ot,th:ot,thead:q,tbody:q,tfoot:q};function yt(t){if(!g(t))return[];if(Yt.test(t))return[L(RegExp.$1)];var n=Jt.test(t)&&RegExp.$1,r=mt[n]||mt["*"];return r.innerHTML=t,o(r.childNodes).detach().get()}o.parseHTML=yt,e.has=function(t){var n=g(t)?function(r,i){return J(t,i).length}:function(r,i){return i.contains(t)};return this.filter(n)},e.not=function(t){var n=j(t);return this.filter(function(r,i){return(!g(t)||h(i))&&!n.call(i,r,i)})};function R(t,n,r,i){for(var u=[],s=A(n),f=i&&j(i),a=0,y=t.length;a<y;a++)if(s){var c=n(t[a]);c.length&&Dt.apply(u,c)}else for(var p=t[a][n];p!=null&&!(i&&f(-1,p));)u.push(p),p=r?p[n]:null;return u}function bt(t){return t.multiple&&t.options?R(U.call(t.options,function(n){return n.selected&&!n.disabled&&!n.parentNode.disabled}),"value"):t.value||""}function Gt(t){return arguments.length?this.each(function(n,r){var i=r.multiple&&r.options;if(i||Ot.test(r.type)){var u=H(t)?ct.call(t,String):P(t)?[]:[String(t)];i?d(r.options,function(s,f){f.selected=u.indexOf(f.value)>=0},!0):r.checked=u.indexOf(r.value)>=0}else r.value=v(t)||P(t)?"":t}):this[0]&&bt(this[0])}e.val=Gt,e.is=function(t){var n=j(t);return z.call(this,function(r,i){return n.call(r,i,r)})},o.guid=1;function w(t){return t.length>1?U.call(t,function(n,r,i){return at.call(i,n)===r}):t}o.unique=w,e.add=function(t,n){return o(w(this.get().concat(o(t,n).get())))},e.children=function(t){return x(o(w(R(this,function(n){return n.children}))),t)},e.parent=function(t){return x(o(w(R(this,"parentNode"))),t)},e.index=function(t){var n=t?o(t)[0]:this[0],r=t?this:o(n).parent().children();return at.call(r,n)},e.closest=function(t){var n=this.filter(t);if(n.length)return n;var r=this.parent();return r.length?r.closest(t):n},e.siblings=function(t){return x(o(w(R(this,function(n){return o(n).parent().children().not(n)}))),t)},e.find=function(t){return o(w(R(this,function(n){return J(t,n)})))};var Xt=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,Kt=/^$|^module$|\/(java|ecma)script/i,Qt=["type","src","nonce","noModule"];function Vt(t,n){var r=o(t);r.filter("script").add(r.find("script")).each(function(i,u){if(Kt.test(u.type)&&st.contains(u)){var s=L("script");s.text=u.textContent.replace(Xt,""),d(Qt,function(f,a){u[a]&&(s[a]=u[a])}),n.head.insertBefore(s,null),n.head.removeChild(s)}})}function Zt(t,n,r,i,u){i?t.insertBefore(n,r?t.firstChild:null):t.nodeName==="HTML"?t.parentNode.replaceChild(n,t):t.parentNode.insertBefore(n,r?t:t.nextSibling),u&&Vt(n,t.ownerDocument)}function N(t,n,r,i,u,s,f,a){return d(t,function(y,c){d(o(c),function(p,O){d(o(n),function(b,W){var rt=r?O:W,it=r?W:O,m=r?p:b;Zt(rt,m?it.cloneNode(!0):it,i,u,!m)},a)},f)},s),n}e.after=function(){return N(arguments,this,!1,!1,!1,!0,!0)},e.append=function(){return N(arguments,this,!1,!1,!0)};function kt(t){if(!arguments.length)return this[0]&&this[0].innerHTML;if(v(t))return this;var n=/<script[\s>]/.test(t);return this.each(function(r,i){!h(i)||(n?o(i).empty().append(t):i.innerHTML=t)})}e.html=kt,e.appendTo=function(t){return N(arguments,this,!0,!1,!0)},e.wrapInner=function(t){return this.each(function(n,r){var i=o(r),u=i.contents();u.length?u.wrapAll(t):i.append(t)})},e.before=function(){return N(arguments,this,!1,!0)},e.wrapAll=function(t){for(var n=o(t),r=n[0];r.children.length;)r=r.firstElementChild;return this.first().before(n),this.appendTo(r)},e.wrap=function(t){return this.each(function(n,r){var i=o(t)[0];o(r).wrapAll(n?i.cloneNode(!0):i)})},e.insertAfter=function(t){return N(arguments,this,!0,!1,!1,!1,!1,!0)},e.insertBefore=function(t){return N(arguments,this,!0,!0)},e.prepend=function(){return N(arguments,this,!1,!0,!0,!0,!0)},e.prependTo=function(t){return N(arguments,this,!0,!0,!0,!1,!1,!0)},e.contents=function(){return o(w(R(this,function(t){return t.tagName==="IFRAME"?[t.contentDocument]:t.tagName==="TEMPLATE"?t.content.childNodes:t.childNodes})))},e.next=function(t,n,r){return x(o(w(R(this,"nextElementSibling",n,r))),t)},e.nextAll=function(t){return this.next(t,!0)},e.nextUntil=function(t,n){return this.next(n,!0,t)},e.parents=function(t,n){return x(o(w(R(this,"parentElement",!0,n))),t)},e.parentsUntil=function(t,n){return this.parents(n,t)},e.prev=function(t,n,r){return x(o(w(R(this,"previousElementSibling",n,r))),t)},e.prevAll=function(t){return this.prev(t,!0)},e.prevUntil=function(t,n){return this.prev(n,!0,t)},e.map=function(t){return o(Bt.apply([],ct.call(this,function(n,r){return t.call(n,r,n)})))},e.clone=function(){return this.map(function(t,n){return n.cloneNode(!0)})},e.offsetParent=function(){return this.map(function(t,n){for(var r=n.offsetParent;r&&T(r,"position")==="static";)r=r.offsetParent;return r||st})},e.slice=function(t,n){return o(ht.call(this,t,n))};var tn=/-([a-z])/g;function K(t){return t.replace(tn,function(n,r){return r.toUpperCase()})}e.ready=function(t){var n=function(){return setTimeout(t,0,o)};return C.readyState!=="loading"?n():C.addEventListener("DOMContentLoaded",n),this},e.unwrap=function(){return this.parent().each(function(t,n){if(n.tagName!=="BODY"){var r=o(n);r.replaceWith(r.children())}}),this},e.offset=function(){var t=this[0];if(!!t){var n=t.getBoundingClientRect();return{top:n.top+M.pageYOffset,left:n.left+M.pageXOffset}}},e.position=function(){var t=this[0];if(!!t){var n=T(t,"position")==="fixed",r=n?t.getBoundingClientRect():this.offset();if(!n){for(var i=t.ownerDocument,u=t.offsetParent||i.documentElement;(u===i.body||u===i.documentElement)&&T(u,"position")==="static";)u=u.parentNode;if(u!==t&&h(u)){var s=o(u).offset();r.top-=s.top+E(u,"borderTopWidth"),r.left-=s.left+E(u,"borderLeftWidth")}}return{top:r.top-E(t,"marginTop"),left:r.left-E(t,"marginLeft")}}};var Et={class:"className",contenteditable:"contentEditable",for:"htmlFor",readonly:"readOnly",maxlength:"maxLength",tabindex:"tabIndex",colspan:"colSpan",rowspan:"rowSpan",usemap:"useMap"};e.prop=function(t,n){if(!!t){if(g(t))return t=Et[t]||t,arguments.length<2?this[0]&&this[0][t]:this.each(function(i,u){u[t]=n});for(var r in t)this.prop(r,t[r]);return this}},e.removeProp=function(t){return this.each(function(n,r){delete r[Et[t]||t]})};var nn=/^--/;function Q(t){return nn.test(t)}var V={},rn=ft.style,en=["webkit","moz","ms"];function un(t,n){if(n===void 0&&(n=Q(t)),n)return t;if(!V[t]){var r=K(t),i="".concat(r[0].toUpperCase()).concat(r.slice(1)),u="".concat(r," ").concat(en.join("".concat(i," "))).concat(i).split(" ");d(u,function(s,f){if(f in rn)return V[t]=f,!1})}return V[t]}var sn={animationIterationCount:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0};function wt(t,n,r){return r===void 0&&(r=Q(t)),!r&&!sn[t]&<(n)?"".concat(n,"px"):n}function fn(t,n){if(g(t)){var r=Q(t);return t=un(t,r),arguments.length<2?this[0]&&T(this[0],t,r):t?(n=wt(t,n,r),this.each(function(u,s){!h(s)||(r?s.style.setProperty(t,n):s.style[t]=n)})):this}for(var i in t)this.css(i,t[i]);return this}e.css=fn;function Ct(t,n){try{return t(n)}catch{return n}}var on=/^\s+|\s+$/;function St(t,n){var r=t.dataset[n]||t.dataset[K(n)];return on.test(r)?r:Ct(JSON.parse,r)}function an(t,n,r){r=Ct(JSON.stringify,r),t.dataset[K(n)]=r}function cn(t,n){if(!t){if(!this[0])return;var r={};for(var i in this[0].dataset)r[i]=St(this[0],i);return r}if(g(t))return arguments.length<2?this[0]&&St(this[0],t):v(n)?this:this.each(function(u,s){an(s,t,n)});for(var i in t)this.data(i,t[i]);return this}e.data=cn;function Tt(t,n){var r=t.documentElement;return Math.max(t.body["scroll".concat(n)],r["scroll".concat(n)],t.body["offset".concat(n)],r["offset".concat(n)],r["client".concat(n)])}d([!0,!1],function(t,n){d(["Width","Height"],function(r,i){var u="".concat(n?"outer":"inner").concat(i);e[u]=function(s){if(!!this[0])return B(this[0])?n?this[0]["inner".concat(i)]:this[0].document.documentElement["client".concat(i)]:D(this[0])?Tt(this[0],i):this[0]["".concat(n?"offset":"client").concat(i)]+(s&&n?E(this[0],"margin".concat(r?"Top":"Left"))+E(this[0],"margin".concat(r?"Bottom":"Right")):0)}})}),d(["Width","Height"],function(t,n){var r=n.toLowerCase();e[r]=function(i){if(!this[0])return v(i)?void 0:this;if(!arguments.length)return B(this[0])?this[0].document.documentElement["client".concat(n)]:D(this[0])?Tt(this[0],n):this[0].getBoundingClientRect()[r]-gt(this[0],!t);var u=parseInt(i,10);return this.each(function(s,f){if(!!h(f)){var a=T(f,"boxSizing");f.style[r]=wt(r,u+(a==="border-box"?gt(f,!t):0))}})}});var Rt="___cd";e.toggle=function(t){return this.each(function(n,r){if(!!h(r)){var i=v(t)?vt(r):t;i?(r.style.display=r[Rt]||"",vt(r)&&(r.style.display=zt(r.tagName))):(r[Rt]=T(r,"display"),r.style.display="none")}})},e.hide=function(){return this.toggle(!1)},e.show=function(){return this.toggle(!0)};var xt="___ce",Z=".",k={focus:"focusin",blur:"focusout"},Nt={mouseenter:"mouseover",mouseleave:"mouseout"},hn=/^(mouse|pointer|contextmenu|drag|drop|click|dblclick)/i;function tt(t){return Nt[t]||k[t]||t}function nt(t){var n=t.split(Z);return[n[0],n.slice(1).sort()]}e.trigger=function(t,n){if(g(t)){var r=nt(t),i=r[0],u=r[1],s=tt(i);if(!s)return this;var f=hn.test(s)?"MouseEvents":"HTMLEvents";t=C.createEvent(f),t.initEvent(s,!0,!0),t.namespace=u.join(Z),t.___ot=i}t.___td=n;var a=t.___ot in k;return this.each(function(y,c){a&&A(c[t.___ot])&&(c["___i".concat(t.type)]=!0,c[t.___ot](),c["___i".concat(t.type)]=!1),c.dispatchEvent(t)})};function Lt(t){return t[xt]=t[xt]||{}}function dn(t,n,r,i,u){var s=Lt(t);s[n]=s[n]||[],s[n].push([r,i,u]),t.addEventListener(n,u)}function At(t,n){return!n||!z.call(n,function(r){return t.indexOf(r)<0})}function F(t,n,r,i,u){var s=Lt(t);if(n)s[n]&&(s[n]=s[n].filter(function(f){var a=f[0],y=f[1],c=f[2];if(u&&c.guid!==u.guid||!At(a,r)||i&&i!==y)return!0;t.removeEventListener(n,c)}));else for(n in s)F(t,n,r,i,u)}e.off=function(t,n,r){var i=this;if(v(t))this.each(function(s,f){!h(f)&&!D(f)&&!B(f)||F(f)});else if(g(t))A(n)&&(r=n,n=""),d($(t),function(s,f){var a=nt(f),y=a[0],c=a[1],p=tt(y);i.each(function(O,b){!h(b)&&!D(b)&&!B(b)||F(b,p,c,n,r)})});else for(var u in t)this.off(u,t[u]);return this},e.remove=function(t){return x(this,t).detach().off(),this},e.replaceWith=function(t){return this.before(t).remove()},e.replaceAll=function(t){return o(t).replaceWith(this),this};function ln(t,n,r,i,u){var s=this;if(!g(t)){for(var f in t)this.on(f,n,r,t[f],u);return this}return g(n)||(v(n)||P(n)?n="":v(r)?(r=n,n=""):(i=r,r=n,n="")),A(i)||(i=r,r=void 0),i?(d($(t),function(a,y){var c=nt(y),p=c[0],O=c[1],b=tt(p),W=p in Nt,rt=p in k;!b||s.each(function(it,m){if(!(!h(m)&&!D(m)&&!B(m))){var et=function(l){if(l.target["___i".concat(l.type)])return l.stopImmediatePropagation();if(!(l.namespace&&!At(O,l.namespace.split(Z)))&&!(!n&&(rt&&(l.target!==m||l.___ot===b)||W&&l.relatedTarget&&m.contains(l.relatedTarget)))){var ut=m;if(n){for(var _=l.target;!pt(_,n);)if(_===m||(_=_.parentNode,!_))return;ut=_}Object.defineProperty(l,"currentTarget",{configurable:!0,get:function(){return ut}}),Object.defineProperty(l,"delegateTarget",{configurable:!0,get:function(){return m}}),Object.defineProperty(l,"data",{configurable:!0,get:function(){return r}});var bn=i.call(ut,l,l.___td);u&&F(m,b,O,n,et),bn===!1&&(l.preventDefault(),l.stopPropagation())}};et.guid=i.guid=i.guid||o.guid++,dn(m,b,O,n,et)}})}),this):this}e.on=ln;function gn(t,n,r,i){return this.on(t,n,r,i,!0)}e.one=gn;var vn=/%20/g,pn=/\r?\n/g;function mn(t,n){return"&".concat(encodeURIComponent(t),"=").concat(encodeURIComponent(n.replace(pn,`\r | ||
`)).replace(vn,"+"))}var yn=/file|reset|submit|button|image/i,Ot=/radio|checkbox/i;e.serialize=function(){var t="";return this.each(function(n,r){d(r.elements||[r],function(i,u){if(!(u.disabled||!u.name||u.tagName==="FIELDSET"||yn.test(u.type)||Ot.test(u.type)&&!u.checked)){var s=bt(u);if(!v(s)){var f=H(s)?s:[s];d(f,function(a,y){t+=mn(u.name,y)})}}})}),t.slice(1)},typeof exports<"u"?module.exports=o:M.cash=M.$=o})(); |
{ | ||
"name": "cash-dom", | ||
"repository": "github:fabiospampinato/cash", | ||
"description": "An absurdly small jQuery alternative for modern browsers.", | ||
"version": "8.1.1", | ||
"version": "8.1.2", | ||
"license": "MIT", | ||
@@ -10,21 +11,13 @@ "browser": "./dist/cash.js", | ||
"jsnext:main": "./dist/cash.esm.js", | ||
"types": "dist/cash.d.ts", | ||
"files": [ | ||
"dist" | ||
], | ||
"types": "dist/cash.d.ts", | ||
"scripts": { | ||
"clean": "pacco clean", | ||
"build:esm": "pacco build-javascript -e esm", | ||
"build:prod": "pacco build-javascript", | ||
"build:deploy": "npm run build:prod && npm run build:esm", | ||
"build:dev": "pacco build-javascript -e development", | ||
"watch:prod": "pacco watch-javascript", | ||
"watch:dev": "pacco watch-javascript -e development", | ||
"dev": "npm run build:dev && npm run watch:dev", | ||
"prod": "npm run build:prod && npm run watch:prod", | ||
"test": "opn ./test/index.html", | ||
"test:watch": "browser-sync start -s . --files test,dist/cash.js --startPath test --no-notify", | ||
"build": "bash ./tasks/build.sh", | ||
"watch": "monex --watch src --exec npm:build", | ||
"dev": "npm run build && npm run watch", | ||
"test": "open ./test/index.html", | ||
"test:karma": "karma start --single-run", | ||
"test:karma:coverage": "karma start --single-run --generate-coverage && open ./coverage/index.html", | ||
"test:karma:sauce": "karma start --single-run --sauce", | ||
"test:jquery:init": "( git -C ./test/jquery reset --hard HEAD && git -C ./test/jquery pull ) || git clone https://github.com/jquery/jquery.git ./test/jquery", | ||
@@ -37,32 +30,20 @@ "test:jquery": "npm run test:jquery:init && npm run test:jquery:build && cd ./test/jquery && npm i && opn http://localhost:4444/test/index.html\\?module=css && php -S localhost:4444", | ||
"test:jquery:reverse:build:watch": "while sleep 1; do npm run test:jquery:reverse:build; done", | ||
"graph": "pacco build-javascript --dependencies-graph --fresh", | ||
"prepublishOnly": "npm run clean && npm run build:deploy && npm run test:karma" | ||
"graph": "minipacco graph src/export_esm.ts", | ||
"prepublishOnly": "npm run build && npm run test:karma" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/fabiospampinato/cash/issues" | ||
}, | ||
"homepage": "https://github.com/fabiospampinato/cash", | ||
"author": "Ken Wheeler <ken_wheeler@me.com>", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/fabiospampinato/cash.git" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"browser-sync": "^2.26.14", | ||
"coveralls": "^3.1.0", | ||
"jquery": "^3.6.0", | ||
"karma": "^4.0.0", | ||
"karma-chrome-launcher": "^3.1.0", | ||
"karma-coverage": "^2.0.3", | ||
"karma-firefox-launcher": "^1.3.0", | ||
"esbuild": "^0.15.14", | ||
"jquery": "^3.6.1", | ||
"karma": "^6.4.1", | ||
"karma-chrome-launcher": "^3.1.1", | ||
"karma-coverage": "^2.2.0", | ||
"karma-firefox-launcher": "^2.1.2", | ||
"karma-qunit": "^4.1.2", | ||
"karma-sauce-launcher": "^4.3.6", | ||
"karma-spec-reporter": "0.0.32", | ||
"opn-cli": "^3.1.0", | ||
"pacco": "^2.1.17", | ||
"qunit": "^2.7.1", | ||
"qunit-ava-spec": "^1.0.0", | ||
"typescript": "^4.2.4" | ||
"karma-spec-reporter": "0.0.34", | ||
"minipacco": "^1.0.3", | ||
"monex": "^1.4.1", | ||
"qunit": "^2.19.3", | ||
"qunit-ava-spec": "^2.0.0", | ||
"typescript": "^4.9.3" | ||
} | ||
} |
Sorry, the diff of this file is too big to display
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
207173
13
4592
2
1
1