code
stringlengths
24
2.07M
docstring
stringlengths
25
85.3k
func_name
stringlengths
1
92
language
stringclasses
1 value
repo
stringlengths
5
64
path
stringlengths
4
172
url
stringlengths
44
218
license
stringclasses
7 values
isLoon() { return "undefined" != typeof $loon }
RegExp: https:\/\/api\.m\.jd\.com\/client\.action\?functionId=(trade_config|genToken)
isLoon
javascript
Toulu-debug/enen
iOS_Cookie.js
https://github.com/Toulu-debug/enen/blob/master/iOS_Cookie.js
MIT
toObj(t, e = null) { try { return JSON.parse(t) } catch { return e } }
RegExp: https:\/\/api\.m\.jd\.com\/client\.action\?functionId=(trade_config|genToken)
toObj
javascript
Toulu-debug/enen
iOS_Cookie.js
https://github.com/Toulu-debug/enen/blob/master/iOS_Cookie.js
MIT
toStr(t, e = null) { try { return JSON.stringify(t) } catch { return e } }
RegExp: https:\/\/api\.m\.jd\.com\/client\.action\?functionId=(trade_config|genToken)
toStr
javascript
Toulu-debug/enen
iOS_Cookie.js
https://github.com/Toulu-debug/enen/blob/master/iOS_Cookie.js
MIT
getjson(t, e) { let s = e; const i = this.getdata(t); if (i) try { s = JSON.parse(this.getdata(t)) } catch { } return s }
RegExp: https:\/\/api\.m\.jd\.com\/client\.action\?functionId=(trade_config|genToken)
getjson
javascript
Toulu-debug/enen
iOS_Cookie.js
https://github.com/Toulu-debug/enen/blob/master/iOS_Cookie.js
MIT
setjson(t, e) { try { return this.setdata(JSON.stringify(t), e) } catch { return !1 } }
RegExp: https:\/\/api\.m\.jd\.com\/client\.action\?functionId=(trade_config|genToken)
setjson
javascript
Toulu-debug/enen
iOS_Cookie.js
https://github.com/Toulu-debug/enen/blob/master/iOS_Cookie.js
MIT
getScript(t) { return new Promise(e => { this.get({url: t}, (t, s, i) => e(i)) }) }
RegExp: https:\/\/api\.m\.jd\.com\/client\.action\?functionId=(trade_config|genToken)
getScript
javascript
Toulu-debug/enen
iOS_Cookie.js
https://github.com/Toulu-debug/enen/blob/master/iOS_Cookie.js
MIT
runScript(t, e) { return new Promise(s => { let i = this.getdata("@chavy_boxjs_userCfgs.httpapi"); i = i ? i.replace(/\n/g, "").trim() : i; let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r; const [o, h] = i.split("@"), n = {url: `http://${h}/v1/scripting/evaluate`, body: {script_text: t, mock_type: "cron", timeout: r}, headers: {"X-Key": o, Accept: "*/*"}}; this.post(n, (t, e, i) => s(i)) }).catch(t => this.logErr(t)) }
RegExp: https:\/\/api\.m\.jd\.com\/client\.action\?functionId=(trade_config|genToken)
runScript
javascript
Toulu-debug/enen
iOS_Cookie.js
https://github.com/Toulu-debug/enen/blob/master/iOS_Cookie.js
MIT
loaddata() { if (!this.isNode()) return {}; { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e); if (!s && !i) return {}; { const i = s ? t : e; try { return JSON.parse(this.fs.readFileSync(i)) } catch (t) { return {} } } } }
RegExp: https:\/\/api\.m\.jd\.com\/client\.action\?functionId=(trade_config|genToken)
loaddata
javascript
Toulu-debug/enen
iOS_Cookie.js
https://github.com/Toulu-debug/enen/blob/master/iOS_Cookie.js
MIT
writedata() { if (this.isNode()) { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e), r = JSON.stringify(this.data); s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r) } }
RegExp: https:\/\/api\.m\.jd\.com\/client\.action\?functionId=(trade_config|genToken)
writedata
javascript
Toulu-debug/enen
iOS_Cookie.js
https://github.com/Toulu-debug/enen/blob/master/iOS_Cookie.js
MIT
lodash_get(t, e, s) { const i = e.replace(/\[(\d+)\]/g, ".$1").split("."); let r = t; for (const t of i) if (r = Object(r)[t], void 0 === r) return s; return r }
RegExp: https:\/\/api\.m\.jd\.com\/client\.action\?functionId=(trade_config|genToken)
lodash_get
javascript
Toulu-debug/enen
iOS_Cookie.js
https://github.com/Toulu-debug/enen/blob/master/iOS_Cookie.js
MIT
lodash_set(t, e, s) { return Object(t) !== t ? t : (Array.isArray(e) || (e = e.toString().match(/[^.[\]]+/g) || []), e.slice(0, -1).reduce((t, s, i) => Object(t[s]) === t[s] ? t[s] : t[s] = Math.abs(e[i + 1]) >> 0 == +e[i + 1] ? [] : {}, t)[e[e.length - 1]] = s, t) }
RegExp: https:\/\/api\.m\.jd\.com\/client\.action\?functionId=(trade_config|genToken)
lodash_set
javascript
Toulu-debug/enen
iOS_Cookie.js
https://github.com/Toulu-debug/enen/blob/master/iOS_Cookie.js
MIT
getdata(t) { let e = this.getval(t); if (/^@/.test(t)) { const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : ""; if (r) try { const t = JSON.parse(r); e = t ? this.lodash_get(t, i, "") : e } catch (t) { e = "" } } return e }
RegExp: https:\/\/api\.m\.jd\.com\/client\.action\?functionId=(trade_config|genToken)
getdata
javascript
Toulu-debug/enen
iOS_Cookie.js
https://github.com/Toulu-debug/enen/blob/master/iOS_Cookie.js
MIT
setdata(t, e) { let s = !1; if (/^@/.test(e)) { const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), o = this.getval(i), h = i ? "null" === o ? null : o || "{}" : "{}"; try { const e = JSON.parse(h); this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), i) } catch (e) { const o = {}; this.lodash_set(o, r, t), s = this.setval(JSON.stringify(o), i) } } else s = this.setval(t, e); return s }
RegExp: https:\/\/api\.m\.jd\.com\/client\.action\?functionId=(trade_config|genToken)
setdata
javascript
Toulu-debug/enen
iOS_Cookie.js
https://github.com/Toulu-debug/enen/blob/master/iOS_Cookie.js
MIT
getval(t) { return this.isSurge() || this.isLoon() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : this.isNode() ? (this.data = this.loaddata(), this.data[t]) : this.data && this.data[t] || null }
RegExp: https:\/\/api\.m\.jd\.com\/client\.action\?functionId=(trade_config|genToken)
getval
javascript
Toulu-debug/enen
iOS_Cookie.js
https://github.com/Toulu-debug/enen/blob/master/iOS_Cookie.js
MIT
setval(t, e) { return this.isSurge() || this.isLoon() ? $persistentStore.write(t, e) : this.isQuanX() ? $prefs.setValueForKey(t, e) : this.isNode() ? (this.data = this.loaddata(), this.data[e] = t, this.writedata(), !0) : this.data && this.data[e] || null }
RegExp: https:\/\/api\.m\.jd\.com\/client\.action\?functionId=(trade_config|genToken)
setval
javascript
Toulu-debug/enen
iOS_Cookie.js
https://github.com/Toulu-debug/enen/blob/master/iOS_Cookie.js
MIT
initGotEnv(t) { this.got = this.got ? this.got : require("got"), this.cktough = this.cktough ? this.cktough : require("tough-cookie"), this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar, t && (t.headers = t.headers ? t.headers : {}, void 0 === t.headers.Cookie && void 0 === t.cookieJar && (t.cookieJar = this.ckjar)) }
RegExp: https:\/\/api\.m\.jd\.com\/client\.action\?functionId=(trade_config|genToken)
initGotEnv
javascript
Toulu-debug/enen
iOS_Cookie.js
https://github.com/Toulu-debug/enen/blob/master/iOS_Cookie.js
MIT
get(t, e = (() => { })) { t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]), this.isSurge() || this.isLoon() ? (this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, {"X-Surge-Skip-Scripting": !1})), $httpClient.get(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, {hints: !1})), $task.fetch(t).then(t => { const {statusCode: s, statusCode: i, headers: r, body: o} = t; e(null, {status: s, statusCode: i, headers: r, body: o}, o) }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => { try { if (t.headers["set-cookie"]) { const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); s && this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar } } catch (t) { this.logErr(t) } }).then(t => { const {statusCode: s, statusCode: i, headers: r, body: o} = t; e(null, {status: s, statusCode: i, headers: r, body: o}, o) }, t => { const {message: s, response: i} = t; e(s, i, i && i.body) })) }
RegExp: https:\/\/api\.m\.jd\.com\/client\.action\?functionId=(trade_config|genToken)
get
javascript
Toulu-debug/enen
iOS_Cookie.js
https://github.com/Toulu-debug/enen/blob/master/iOS_Cookie.js
MIT
post(t, e = (() => { })) { if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), t.headers && delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, {"X-Surge-Skip-Scripting": !1})), $httpClient.post(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, {hints: !1})), $task.fetch(t).then(t => { const {statusCode: s, statusCode: i, headers: r, body: o} = t; e(null, {status: s, statusCode: i, headers: r, body: o}, o) }, t => e(t)); else if (this.isNode()) { this.initGotEnv(t); const {url: s, ...i} = t; this.got.post(s, i).then(t => { const {statusCode: s, statusCode: i, headers: r, body: o} = t; e(null, {status: s, statusCode: i, headers: r, body: o}, o) }, t => { const {message: s, response: i} = t; e(s, i, i && i.body) }) } }
RegExp: https:\/\/api\.m\.jd\.com\/client\.action\?functionId=(trade_config|genToken)
post
javascript
Toulu-debug/enen
iOS_Cookie.js
https://github.com/Toulu-debug/enen/blob/master/iOS_Cookie.js
MIT
time(t, e = null) { const s = e ? new Date(e) : new Date(new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000); let i = {"M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds()}; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).length))); return t }
RegExp: https:\/\/api\.m\.jd\.com\/client\.action\?functionId=(trade_config|genToken)
time
javascript
Toulu-debug/enen
iOS_Cookie.js
https://github.com/Toulu-debug/enen/blob/master/iOS_Cookie.js
MIT
o = t => { if (!t) return t; if ("string" == typeof t) return this.isLoon() ? t : this.isQuanX() ? {"open-url": t} : this.isSurge() ? {url: t} : void 0; if ("object" == typeof t) { if (this.isLoon()) { let e = t.openUrl || t.url || t["open-url"], s = t.mediaUrl || t["media-url"]; return {openUrl: e, mediaUrl: s} } if (this.isQuanX()) { let e = t["open-url"] || t.url || t.openUrl, s = t["media-url"] || t.mediaUrl; return {"open-url": e, "media-url": s} } if (this.isSurge()) { let e = t.url || t.openUrl || t["open-url"]; return {url: e} } } }
RegExp: https:\/\/api\.m\.jd\.com\/client\.action\?functionId=(trade_config|genToken)
o
javascript
Toulu-debug/enen
iOS_Cookie.js
https://github.com/Toulu-debug/enen/blob/master/iOS_Cookie.js
MIT
o = t => { if (!t) return t; if ("string" == typeof t) return this.isLoon() ? t : this.isQuanX() ? {"open-url": t} : this.isSurge() ? {url: t} : void 0; if ("object" == typeof t) { if (this.isLoon()) { let e = t.openUrl || t.url || t["open-url"], s = t.mediaUrl || t["media-url"]; return {openUrl: e, mediaUrl: s} } if (this.isQuanX()) { let e = t["open-url"] || t.url || t.openUrl, s = t["media-url"] || t.mediaUrl; return {"open-url": e, "media-url": s} } if (this.isSurge()) { let e = t.url || t.openUrl || t["open-url"]; return {url: e} } } }
RegExp: https:\/\/api\.m\.jd\.com\/client\.action\?functionId=(trade_config|genToken)
o
javascript
Toulu-debug/enen
iOS_Cookie.js
https://github.com/Toulu-debug/enen/blob/master/iOS_Cookie.js
MIT
log(...t) { t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator)) }
RegExp: https:\/\/api\.m\.jd\.com\/client\.action\?functionId=(trade_config|genToken)
log
javascript
Toulu-debug/enen
iOS_Cookie.js
https://github.com/Toulu-debug/enen/blob/master/iOS_Cookie.js
MIT
wait(t) { return new Promise(e => setTimeout(e, t)) }
RegExp: https:\/\/api\.m\.jd\.com\/client\.action\?functionId=(trade_config|genToken)
wait
javascript
Toulu-debug/enen
iOS_Cookie.js
https://github.com/Toulu-debug/enen/blob/master/iOS_Cookie.js
MIT
function tower() { var args = Array.prototype.slice.call(arguments); var fn = args.pop(); args.push('--output-directory', 'tmp'); var child = spawn('./bin/tower', args); var result = ''; var error = ''; child.stdout.setEncoding('utf-8'); child.stdout.on('data', function(data){ result += data; }); child.stderr.setEncoding('utf-8'); child.stderr.on('data', function(data){ error += data; }); child.on('close', function(){ fn(error ? error : null, result); }); }
Execute a tower command, return output as string.
tower
javascript
tower-archive/tower
test/cli.js
https://github.com/tower-archive/tower/blob/master/test/cli.js
MIT
function clearTmp() { if (fs.existsSync('tmp')) fs.removeDirectoryRecursiveSync('tmp'); fs.mkdirSync('tmp'); }
Execute a tower command, return output as string.
clearTmp
javascript
tower-archive/tower
test/cli.js
https://github.com/tower-archive/tower/blob/master/test/cli.js
MIT
function encode(name, value) { return "&" + encodeURIComponent(name) + "=" + encodeURIComponent(value).replace(/%20/g, "+"); }
Modified Triggers browser event @param String eventName @param Object data - Add properties to event object
encode
javascript
Dogfalo/materialize
dist/js/materialize.js
https://github.com/Dogfalo/materialize/blob/master/dist/js/materialize.js
MIT
function getSelectMultiple_(el) { var values = []; each(el.options, function (o) { if (o.selected) { values.push(o.value); } }); return values.length ? values : null; }
Modified Triggers browser event @param String eventName @param Object data - Add properties to event object
getSelectMultiple_
javascript
Dogfalo/materialize
dist/js/materialize.js
https://github.com/Dogfalo/materialize/blob/master/dist/js/materialize.js
MIT
function getSelectSingle_(el) { var selectedIndex = el.selectedIndex; return selectedIndex >= 0 ? el.options[selectedIndex].value : null; }
Modified Triggers browser event @param String eventName @param Object data - Add properties to event object
getSelectSingle_
javascript
Dogfalo/materialize
dist/js/materialize.js
https://github.com/Dogfalo/materialize/blob/master/dist/js/materialize.js
MIT
function getValue(el) { var type = el.type; if (!type) { return null; } switch (type.toLowerCase()) { case "select-one": return getSelectSingle_(el); case "select-multiple": return getSelectMultiple_(el); case "radio": return el.checked ? el.value : null; case "checkbox": return el.checked ? el.value : null; default: return el.value ? el.value : null; } }
Modified Triggers browser event @param String eventName @param Object data - Add properties to event object
getValue
javascript
Dogfalo/materialize
dist/js/materialize.js
https://github.com/Dogfalo/materialize/blob/master/dist/js/materialize.js
MIT
function insertElement(el, child, prepend) { if (prepend) { var first = el.childNodes[0]; el.insertBefore(child, first); } else { el.appendChild(child); } }
Modified Triggers browser event @param String eventName @param Object data - Add properties to event object
insertElement
javascript
Dogfalo/materialize
dist/js/materialize.js
https://github.com/Dogfalo/materialize/blob/master/dist/js/materialize.js
MIT
function insertContent(parent, child, prepend) { var str = isString(child); if (!str && child.length) { each(child, function (v) { return insertContent(parent, v, prepend); }); return; } each(parent, str ? function (v) { return v.insertAdjacentHTML(prepend ? "afterbegin" : "beforeend", child); } : function (v, i) { return insertElement(v, i === 0 ? child : child.cloneNode(true), prepend); }); }
Modified Triggers browser event @param String eventName @param Object data - Add properties to event object
insertContent
javascript
Dogfalo/materialize
dist/js/materialize.js
https://github.com/Dogfalo/materialize/blob/master/dist/js/materialize.js
MIT
function Component(classDef, el, options) { _classCallCheck(this, Component); // Display error if el is valid HTML Element if (!(el instanceof Element)) { console.error(Error(el + ' is not an HTML Element')); } // If exists, destroy and reinitialize in child var ins = classDef.getInstance(el); if (!!ins) { ins.destroy(); } this.el = el; this.$el = cash(el); }
Generic constructor for all components @constructor @param {Element} el @param {Object} options
Component
javascript
Dogfalo/materialize
dist/js/materialize.js
https://github.com/Dogfalo/materialize/blob/master/dist/js/materialize.js
MIT
function s4() { return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1); }
Generate approximated selector string for a jQuery object @param {jQuery} obj jQuery object to be parsed @returns {string}
s4
javascript
Dogfalo/materialize
dist/js/materialize.js
https://github.com/Dogfalo/materialize/blob/master/dist/js/materialize.js
MIT
function Collapsible(el, options) { _classCallCheck(this, Collapsible); var _this3 = _possibleConstructorReturn(this, (Collapsible.__proto__ || Object.getPrototypeOf(Collapsible)).call(this, Collapsible, el, options)); _this3.el.M_Collapsible = _this3; /** * Options for the collapsible * @member Collapsible#options * @prop {Boolean} [accordion=false] - Type of the collapsible * @prop {Function} onOpenStart - Callback function called before collapsible is opened * @prop {Function} onOpenEnd - Callback function called after collapsible is opened * @prop {Function} onCloseStart - Callback function called before collapsible is closed * @prop {Function} onCloseEnd - Callback function called after collapsible is closed * @prop {Number} inDuration - Transition in duration in milliseconds. * @prop {Number} outDuration - Transition duration in milliseconds. */ _this3.options = $.extend({}, Collapsible.defaults, options); // Setup tab indices _this3.$headers = _this3.$el.children('li').children('.collapsible-header'); _this3.$headers.attr('tabindex', 0); _this3._setupEventHandlers(); // Open first active var $activeBodies = _this3.$el.children('li.active').children('.collapsible-body'); if (_this3.options.accordion) { // Handle Accordion $activeBodies.first().css('display', 'block'); } else { // Handle Expandables $activeBodies.css('display', 'block'); } return _this3; }
Construct Collapsible instance @constructor @param {Element} el @param {Object} options
Collapsible
javascript
Dogfalo/materialize
dist/js/materialize.js
https://github.com/Dogfalo/materialize/blob/master/dist/js/materialize.js
MIT
function Modal(el, options) { _classCallCheck(this, Modal); var _this13 = _possibleConstructorReturn(this, (Modal.__proto__ || Object.getPrototypeOf(Modal)).call(this, Modal, el, options)); _this13.el.M_Modal = _this13; /** * Options for the modal * @member Modal#options * @prop {Number} [opacity=0.5] - Opacity of the modal overlay * @prop {Number} [inDuration=250] - Length in ms of enter transition * @prop {Number} [outDuration=250] - Length in ms of exit transition * @prop {Function} onOpenStart - Callback function called before modal is opened * @prop {Function} onOpenEnd - Callback function called after modal is opened * @prop {Function} onCloseStart - Callback function called before modal is closed * @prop {Function} onCloseEnd - Callback function called after modal is closed * @prop {Boolean} [dismissible=true] - Allow modal to be dismissed by keyboard or overlay click * @prop {String} [startingTop='4%'] - startingTop * @prop {String} [endingTop='10%'] - endingTop */ _this13.options = $.extend({}, Modal.defaults, options); /** * Describes open/close state of modal * @type {Boolean} */ _this13.isOpen = false; _this13.id = _this13.$el.attr('id'); _this13._openingTrigger = undefined; _this13.$overlay = $('<div class="modal-overlay"></div>'); _this13.el.tabIndex = 0; _this13._nthModalOpened = 0; Modal._count++; _this13._setupEventHandlers(); return _this13; }
Construct Modal instance and set up overlay @constructor @param {Element} el @param {Object} options
Modal
javascript
Dogfalo/materialize
dist/js/materialize.js
https://github.com/Dogfalo/materialize/blob/master/dist/js/materialize.js
MIT
function Materialbox(el, options) { _classCallCheck(this, Materialbox); var _this16 = _possibleConstructorReturn(this, (Materialbox.__proto__ || Object.getPrototypeOf(Materialbox)).call(this, Materialbox, el, options)); _this16.el.M_Materialbox = _this16; /** * Options for the modal * @member Materialbox#options * @prop {Number} [inDuration=275] - Length in ms of enter transition * @prop {Number} [outDuration=200] - Length in ms of exit transition * @prop {Function} onOpenStart - Callback function called before materialbox is opened * @prop {Function} onOpenEnd - Callback function called after materialbox is opened * @prop {Function} onCloseStart - Callback function called before materialbox is closed * @prop {Function} onCloseEnd - Callback function called after materialbox is closed */ _this16.options = $.extend({}, Materialbox.defaults, options); _this16.overlayActive = false; _this16.doneAnimating = true; _this16.placeholder = $('<div></div>').addClass('material-placeholder'); _this16.originalWidth = 0; _this16.originalHeight = 0; _this16.originInlineStyles = _this16.$el.attr('style'); _this16.caption = _this16.el.getAttribute('data-caption') || ''; // Wrap _this16.$el.before(_this16.placeholder); _this16.placeholder.append(_this16.$el); _this16._setupEventHandlers(); return _this16; }
Construct Materialbox instance @constructor @param {Element} el @param {Object} options
Materialbox
javascript
Dogfalo/materialize
dist/js/materialize.js
https://github.com/Dogfalo/materialize/blob/master/dist/js/materialize.js
MIT
function Tabs(el, options) { _classCallCheck(this, Tabs); var _this22 = _possibleConstructorReturn(this, (Tabs.__proto__ || Object.getPrototypeOf(Tabs)).call(this, Tabs, el, options)); _this22.el.M_Tabs = _this22; /** * Options for the Tabs * @member Tabs#options * @prop {Number} duration * @prop {Function} onShow * @prop {Boolean} swipeable * @prop {Number} responsiveThreshold */ _this22.options = $.extend({}, Tabs.defaults, options); // Setup _this22.$tabLinks = _this22.$el.children('li.tab').children('a'); _this22.index = 0; _this22._setupActiveTabLink(); // Setup tabs content if (_this22.options.swipeable) { _this22._setupSwipeableTabs(); } else { _this22._setupNormalTabs(); } // Setup tabs indicator after content to ensure accurate widths _this22._setTabsAndTabWidth(); _this22._createIndicator(); _this22._setupEventHandlers(); return _this22; }
Construct Tabs instance @constructor @param {Element} el @param {Object} options
Tabs
javascript
Dogfalo/materialize
dist/js/materialize.js
https://github.com/Dogfalo/materialize/blob/master/dist/js/materialize.js
MIT
function Tooltip(el, options) { _classCallCheck(this, Tooltip); var _this26 = _possibleConstructorReturn(this, (Tooltip.__proto__ || Object.getPrototypeOf(Tooltip)).call(this, Tooltip, el, options)); _this26.el.M_Tooltip = _this26; _this26.options = $.extend({}, Tooltip.defaults, options); _this26.isOpen = false; _this26.isHovered = false; _this26.isFocused = false; _this26._appendTooltipEl(); _this26._setupEventHandlers(); return _this26; }
Construct Tooltip instance @constructor @param {Element} el @param {Object} options
Tooltip
javascript
Dogfalo/materialize
dist/js/materialize.js
https://github.com/Dogfalo/materialize/blob/master/dist/js/materialize.js
MIT
function getWavesEffectElement(e) { if (TouchHandler.allowEvent(e) === false) { return null; } var element = null; var target = e.target || e.srcElement; while (target.parentNode !== null) { if (!(target instanceof SVGElement) && target.className.indexOf('waves-effect') !== -1) { element = target; break; } target = target.parentNode; } return element; }
Delegated click handler for .waves-effect element. returns null when .waves-effect element not in "click tree"
getWavesEffectElement
javascript
Dogfalo/materialize
dist/js/materialize.js
https://github.com/Dogfalo/materialize/blob/master/dist/js/materialize.js
MIT
function showEffect(e) { var element = getWavesEffectElement(e); if (element !== null) { Effect.show(e, element); if ('ontouchstart' in window) { element.addEventListener('touchend', Effect.hide, false); element.addEventListener('touchcancel', Effect.hide, false); } element.addEventListener('mouseup', Effect.hide, false); element.addEventListener('mouseleave', Effect.hide, false); element.addEventListener('dragend', Effect.hide, false); } }
Bubble the click and show effect if .waves-effect elem was found
showEffect
javascript
Dogfalo/materialize
dist/js/materialize.js
https://github.com/Dogfalo/materialize/blob/master/dist/js/materialize.js
MIT
function Toast(options) { _classCallCheck(this, Toast); /** * Options for the toast * @member Toast#options */ this.options = $.extend({}, Toast.defaults, options); this.message = this.options.html; /** * Describes current pan state toast * @type {Boolean} */ this.panning = false; /** * Time remaining until toast is removed */ this.timeRemaining = this.options.displayLength; if (Toast._toasts.length === 0) { Toast._createContainer(); } // Create new toast Toast._toasts.push(this); var toastElement = this._createToast(); toastElement.M_Toast = this; this.el = toastElement; this.$el = $(toastElement); this._animateIn(); this._setTimer(); }
Attach Waves to an input element (or any element which doesn't bubble mouseup/mousedown events). Intended to be used with dynamically loaded forms/inputs, or where the user doesn't want a delegated click handler.
Toast
javascript
Dogfalo/materialize
dist/js/materialize.js
https://github.com/Dogfalo/materialize/blob/master/dist/js/materialize.js
MIT
function Sidenav(el, options) { _classCallCheck(this, Sidenav); var _this31 = _possibleConstructorReturn(this, (Sidenav.__proto__ || Object.getPrototypeOf(Sidenav)).call(this, Sidenav, el, options)); _this31.el.M_Sidenav = _this31; _this31.id = _this31.$el.attr('id'); /** * Options for the Sidenav * @member Sidenav#options * @prop {String} [edge='left'] - Side of screen on which Sidenav appears * @prop {Boolean} [draggable=true] - Allow swipe gestures to open/close Sidenav * @prop {Number} [inDuration=250] - Length in ms of enter transition * @prop {Number} [outDuration=200] - Length in ms of exit transition * @prop {Function} onOpenStart - Function called when sidenav starts entering * @prop {Function} onOpenEnd - Function called when sidenav finishes entering * @prop {Function} onCloseStart - Function called when sidenav starts exiting * @prop {Function} onCloseEnd - Function called when sidenav finishes exiting */ _this31.options = $.extend({}, Sidenav.defaults, options); /** * Describes open/close state of Sidenav * @type {Boolean} */ _this31.isOpen = false; /** * Describes if Sidenav is fixed * @type {Boolean} */ _this31.isFixed = _this31.el.classList.contains('sidenav-fixed'); /** * Describes if Sidenav is being draggeed * @type {Boolean} */ _this31.isDragged = false; // Window size variables for window resize checks _this31.lastWindowWidth = window.innerWidth; _this31.lastWindowHeight = window.innerHeight; _this31._createOverlay(); _this31._createDragTarget(); _this31._setupEventHandlers(); _this31._setupClasses(); _this31._setupFixed(); Sidenav._sidenavs.push(_this31); return _this31; }
Construct Sidenav instance and set up overlay @constructor @param {Element} el @param {Object} options
Sidenav
javascript
Dogfalo/materialize
dist/js/materialize.js
https://github.com/Dogfalo/materialize/blob/master/dist/js/materialize.js
MIT
function ScrollSpy(el, options) { _classCallCheck(this, ScrollSpy); var _this35 = _possibleConstructorReturn(this, (ScrollSpy.__proto__ || Object.getPrototypeOf(ScrollSpy)).call(this, ScrollSpy, el, options)); _this35.el.M_ScrollSpy = _this35; /** * Options for the modal * @member Modal#options * @prop {Number} [throttle=100] - Throttle of scroll handler * @prop {Number} [scrollOffset=200] - Offset for centering element when scrolled to * @prop {String} [activeClass='active'] - Class applied to active elements * @prop {Function} [getActiveElement] - Used to find active element */ _this35.options = $.extend({}, ScrollSpy.defaults, options); // setup ScrollSpy._elements.push(_this35); ScrollSpy._count++; ScrollSpy._increment++; _this35.tickId = -1; _this35.id = ScrollSpy._increment; _this35._setupEventHandlers(); _this35._handleWindowScroll(); return _this35; }
Construct ScrollSpy instance @constructor @param {Element} el @param {Object} options
ScrollSpy
javascript
Dogfalo/materialize
dist/js/materialize.js
https://github.com/Dogfalo/materialize/blob/master/dist/js/materialize.js
MIT
function Autocomplete(el, options) { _classCallCheck(this, Autocomplete); var _this37 = _possibleConstructorReturn(this, (Autocomplete.__proto__ || Object.getPrototypeOf(Autocomplete)).call(this, Autocomplete, el, options)); _this37.el.M_Autocomplete = _this37; /** * Options for the autocomplete * @member Autocomplete#options * @prop {Number} duration * @prop {Number} dist * @prop {number} shift * @prop {number} padding * @prop {Boolean} fullWidth * @prop {Boolean} indicators * @prop {Boolean} noWrap * @prop {Function} onCycleTo */ _this37.options = $.extend({}, Autocomplete.defaults, options); // Setup _this37.isOpen = false; _this37.count = 0; _this37.activeIndex = -1; _this37.oldVal; _this37.$inputField = _this37.$el.closest('.input-field'); _this37.$active = $(); _this37._mousedown = false; _this37._setupDropdown(); _this37._setupEventHandlers(); return _this37; }
Construct Autocomplete instance @constructor @param {Element} el @param {Object} options
Autocomplete
javascript
Dogfalo/materialize
dist/js/materialize.js
https://github.com/Dogfalo/materialize/blob/master/dist/js/materialize.js
MIT
sortFunctionBound = function (a, b) { return _this39.options.sortFunction(a.key.toLowerCase(), b.key.toLowerCase(), val.toLowerCase()); }
Render dropdown content @param {Object} data data set @param {String} val current input value
sortFunctionBound
javascript
Dogfalo/materialize
dist/js/materialize.js
https://github.com/Dogfalo/materialize/blob/master/dist/js/materialize.js
MIT
function Slider(el, options) { _classCallCheck(this, Slider); var _this40 = _possibleConstructorReturn(this, (Slider.__proto__ || Object.getPrototypeOf(Slider)).call(this, Slider, el, options)); _this40.el.M_Slider = _this40; /** * Options for the modal * @member Slider#options * @prop {Boolean} [indicators=true] - Show indicators * @prop {Number} [height=400] - height of slider * @prop {Number} [duration=500] - Length in ms of slide transition * @prop {Number} [interval=6000] - Length in ms of slide interval */ _this40.options = $.extend({}, Slider.defaults, options); // setup _this40.$slider = _this40.$el.find('.slides'); _this40.$slides = _this40.$slider.children('li'); _this40.activeIndex = _this40.$slides.filter(function (item) { return $(item).hasClass('active'); }).first().index(); if (_this40.activeIndex != -1) { _this40.$active = _this40.$slides.eq(_this40.activeIndex); } _this40._setSliderHeight(); // Set initial positions of captions _this40.$slides.find('.caption').each(function (el) { _this40._animateCaptionIn(el, 0); }); // Move img src into background-image _this40.$slides.find('img').each(function (el) { var placeholderBase64 = 'data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='; if ($(el).attr('src') !== placeholderBase64) { $(el).css('background-image', 'url("' + $(el).attr('src') + '")'); $(el).attr('src', placeholderBase64); } }); _this40._setupIndicators(); // Show active slide if (_this40.$active) { _this40.$active.css('display', 'block'); } else { _this40.$slides.first().addClass('active'); anim({ targets: _this40.$slides.first()[0], opacity: 1, duration: _this40.options.duration, easing: 'easeOutQuad' }); _this40.activeIndex = 0; _this40.$active = _this40.$slides.eq(_this40.activeIndex); // Update indicators if (_this40.options.indicators) { _this40.$indicators.eq(_this40.activeIndex).addClass('active'); } } // Adjust height to current slide _this40.$active.find('img').each(function (el) { anim({ targets: _this40.$active.find('.caption')[0], opacity: 1, translateX: 0, translateY: 0, duration: _this40.options.duration, easing: 'easeOutQuad' }); }); _this40._setupEventHandlers(); // auto scroll _this40.start(); return _this40; }
Construct Slider instance and set up overlay @constructor @param {Element} el @param {Object} options
Slider
javascript
Dogfalo/materialize
dist/js/materialize.js
https://github.com/Dogfalo/materialize/blob/master/dist/js/materialize.js
MIT
function Chips(el, options) { _classCallCheck(this, Chips); var _this45 = _possibleConstructorReturn(this, (Chips.__proto__ || Object.getPrototypeOf(Chips)).call(this, Chips, el, options)); _this45.el.M_Chips = _this45; /** * Options for the modal * @member Chips#options * @prop {Array} data * @prop {String} placeholder * @prop {String} secondaryPlaceholder * @prop {Object} autocompleteOptions */ _this45.options = $.extend({}, Chips.defaults, options); _this45.$el.addClass('chips input-field'); _this45.chipsData = []; _this45.$chips = $(); _this45._setupInput(); _this45.hasAutocomplete = Object.keys(_this45.options.autocompleteOptions).length > 0; // Set input id if (!_this45.$input.attr('id')) { _this45.$input.attr('id', M.guid()); } // Render initial chips if (_this45.options.data.length) { _this45.chipsData = _this45.options.data; _this45._renderChips(_this45.chipsData); } // Setup autocomplete if needed if (_this45.hasAutocomplete) { _this45._setupAutocomplete(); } _this45._setPlaceholder(); _this45._setupLabel(); _this45._setupEventHandlers(); return _this45; }
Construct Chips instance and set up overlay @constructor @param {Element} el @param {Object} options
Chips
javascript
Dogfalo/materialize
dist/js/materialize.js
https://github.com/Dogfalo/materialize/blob/master/dist/js/materialize.js
MIT
function Pushpin(el, options) { _classCallCheck(this, Pushpin); var _this47 = _possibleConstructorReturn(this, (Pushpin.__proto__ || Object.getPrototypeOf(Pushpin)).call(this, Pushpin, el, options)); _this47.el.M_Pushpin = _this47; /** * Options for the modal * @member Pushpin#options */ _this47.options = $.extend({}, Pushpin.defaults, options); _this47.originalOffset = _this47.el.offsetTop; Pushpin._pushpins.push(_this47); _this47._setupEventHandlers(); _this47._updatePosition(); return _this47; }
Construct Pushpin instance @constructor @param {Element} el @param {Object} options
Pushpin
javascript
Dogfalo/materialize
dist/js/materialize.js
https://github.com/Dogfalo/materialize/blob/master/dist/js/materialize.js
MIT
function FloatingActionButton(el, options) { _classCallCheck(this, FloatingActionButton); var _this48 = _possibleConstructorReturn(this, (FloatingActionButton.__proto__ || Object.getPrototypeOf(FloatingActionButton)).call(this, FloatingActionButton, el, options)); _this48.el.M_FloatingActionButton = _this48; /** * Options for the fab * @member FloatingActionButton#options * @prop {Boolean} [direction] - Direction fab menu opens * @prop {Boolean} [hoverEnabled=true] - Enable hover vs click * @prop {Boolean} [toolbarEnabled=false] - Enable toolbar transition */ _this48.options = $.extend({}, FloatingActionButton.defaults, options); _this48.isOpen = false; _this48.$anchor = _this48.$el.children('a').first(); _this48.$menu = _this48.$el.children('ul').first(); _this48.$floatingBtns = _this48.$el.find('ul .btn-floating'); _this48.$floatingBtnsReverse = _this48.$el.find('ul .btn-floating').reverse(); _this48.offsetY = 0; _this48.offsetX = 0; _this48.$el.addClass("direction-" + _this48.options.direction); if (_this48.options.direction === 'top') { _this48.offsetY = 40; } else if (_this48.options.direction === 'right') { _this48.offsetX = -40; } else if (_this48.options.direction === 'bottom') { _this48.offsetY = -40; } else { _this48.offsetX = 40; } _this48._setupEventHandlers(); return _this48; }
Construct FloatingActionButton instance @constructor @param {Element} el @param {Object} options
FloatingActionButton
javascript
Dogfalo/materialize
dist/js/materialize.js
https://github.com/Dogfalo/materialize/blob/master/dist/js/materialize.js
MIT
function Datepicker(el, options) { _classCallCheck(this, Datepicker); var _this53 = _possibleConstructorReturn(this, (Datepicker.__proto__ || Object.getPrototypeOf(Datepicker)).call(this, Datepicker, el, options)); _this53.el.M_Datepicker = _this53; _this53.options = $.extend({}, Datepicker.defaults, options); // make sure i18n defaults are not lost when only few i18n option properties are passed if (!!options && options.hasOwnProperty('i18n') && typeof options.i18n === 'object') { _this53.options.i18n = $.extend({}, Datepicker.defaults.i18n, options.i18n); } // Remove time component from minDate and maxDate options if (_this53.options.minDate) _this53.options.minDate.setHours(0, 0, 0, 0); if (_this53.options.maxDate) _this53.options.maxDate.setHours(0, 0, 0, 0); _this53.id = M.guid(); _this53._setupVariables(); _this53._insertHTMLIntoDOM(); _this53._setupModal(); _this53._setupEventHandlers(); if (!_this53.options.defaultDate) { _this53.options.defaultDate = new Date(Date.parse(_this53.el.value)); } var defDate = _this53.options.defaultDate; if (Datepicker._isDate(defDate)) { if (_this53.options.setDefaultDate) { _this53.setDate(defDate, true); _this53.setInputValue(); } else { _this53.gotoDate(defDate); } } else { _this53.gotoDate(new Date()); } /** * Describes open/close state of datepicker * @type {Boolean} */ _this53.isOpen = false; return _this53; }
Construct Datepicker instance and set up overlay @constructor @param {Element} el @param {Object} options
Datepicker
javascript
Dogfalo/materialize
dist/js/materialize.js
https://github.com/Dogfalo/materialize/blob/master/dist/js/materialize.js
MIT
function CharacterCounter(el, options) { _classCallCheck(this, CharacterCounter); var _this61 = _possibleConstructorReturn(this, (CharacterCounter.__proto__ || Object.getPrototypeOf(CharacterCounter)).call(this, CharacterCounter, el, options)); _this61.el.M_CharacterCounter = _this61; /** * Options for the character counter */ _this61.options = $.extend({}, CharacterCounter.defaults, options); _this61.isInvalid = false; _this61.isValidLength = false; _this61._setupCounter(); _this61._setupEventHandlers(); return _this61; }
Construct CharacterCounter instance @constructor @param {Element} el @param {Object} options
CharacterCounter
javascript
Dogfalo/materialize
dist/js/materialize.js
https://github.com/Dogfalo/materialize/blob/master/dist/js/materialize.js
MIT
function Carousel(el, options) { _classCallCheck(this, Carousel); var _this62 = _possibleConstructorReturn(this, (Carousel.__proto__ || Object.getPrototypeOf(Carousel)).call(this, Carousel, el, options)); _this62.el.M_Carousel = _this62; /** * Options for the carousel * @member Carousel#options * @prop {Number} duration * @prop {Number} dist * @prop {Number} shift * @prop {Number} padding * @prop {Number} numVisible * @prop {Boolean} fullWidth * @prop {Boolean} indicators * @prop {Boolean} noWrap * @prop {Function} onCycleTo */ _this62.options = $.extend({}, Carousel.defaults, options); // Setup _this62.hasMultipleSlides = _this62.$el.find('.carousel-item').length > 1; _this62.showIndicators = _this62.options.indicators && _this62.hasMultipleSlides; _this62.noWrap = _this62.options.noWrap || !_this62.hasMultipleSlides; _this62.pressed = false; _this62.dragged = false; _this62.offset = _this62.target = 0; _this62.images = []; _this62.itemWidth = _this62.$el.find('.carousel-item').first().innerWidth(); _this62.itemHeight = _this62.$el.find('.carousel-item').first().innerHeight(); _this62.dim = _this62.itemWidth * 2 + _this62.options.padding || 1; // Make sure dim is non zero for divisions. _this62._autoScrollBound = _this62._autoScroll.bind(_this62); _this62._trackBound = _this62._track.bind(_this62); // Full Width carousel setup if (_this62.options.fullWidth) { _this62.options.dist = 0; _this62._setCarouselHeight(); // Offset fixed items when indicators. if (_this62.showIndicators) { _this62.$el.find('.carousel-fixed-item').addClass('with-indicators'); } } // Iterate through slides _this62.$indicators = $('<ul class="indicators"></ul>'); _this62.$el.find('.carousel-item').each(function (el, i) { _this62.images.push(el); if (_this62.showIndicators) { var $indicator = $('<li class="indicator-item"></li>'); // Add active to first by default. if (i === 0) { $indicator[0].classList.add('active'); } _this62.$indicators.append($indicator); } }); if (_this62.showIndicators) { _this62.$el.append(_this62.$indicators); } _this62.count = _this62.images.length; // Cap numVisible at count _this62.options.numVisible = Math.min(_this62.count, _this62.options.numVisible); // Setup cross browser string _this62.xform = 'transform'; ['webkit', 'Moz', 'O', 'ms'].every(function (prefix) { var e = prefix + 'Transform'; if (typeof document.body.style[e] !== 'undefined') { _this62.xform = e; return false; } return true; }); _this62._setupEventHandlers(); _this62._scroll(_this62.offset); return _this62; }
Construct Carousel instance @constructor @param {Element} el @param {Object} options
Carousel
javascript
Dogfalo/materialize
dist/js/materialize.js
https://github.com/Dogfalo/materialize/blob/master/dist/js/materialize.js
MIT
function TapTarget(el, options) { _classCallCheck(this, TapTarget); var _this67 = _possibleConstructorReturn(this, (TapTarget.__proto__ || Object.getPrototypeOf(TapTarget)).call(this, TapTarget, el, options)); _this67.el.M_TapTarget = _this67; /** * Options for the select * @member TapTarget#options * @prop {Function} onOpen - Callback function called when feature discovery is opened * @prop {Function} onClose - Callback function called when feature discovery is closed */ _this67.options = $.extend({}, TapTarget.defaults, options); _this67.isOpen = false; // setup _this67.$origin = $('#' + _this67.$el.attr('data-target')); _this67._setup(); _this67._calculatePositioning(); _this67._setupEventHandlers(); return _this67; }
Construct TapTarget instance @constructor @param {Element} el @param {Object} options
TapTarget
javascript
Dogfalo/materialize
dist/js/materialize.js
https://github.com/Dogfalo/materialize/blob/master/dist/js/materialize.js
MIT
function FormSelect(el, options) { _classCallCheck(this, FormSelect); // Don't init if browser default version var _this68 = _possibleConstructorReturn(this, (FormSelect.__proto__ || Object.getPrototypeOf(FormSelect)).call(this, FormSelect, el, options)); if (_this68.$el.hasClass('browser-default')) { return _possibleConstructorReturn(_this68); } _this68.el.M_FormSelect = _this68; /** * Options for the select * @member FormSelect#options */ _this68.options = $.extend({}, FormSelect.defaults, options); _this68.isMultiple = _this68.$el.prop('multiple'); // Setup _this68.el.tabIndex = -1; _this68._keysSelected = {}; _this68._valueDict = {}; // Maps key to original and generated option element. _this68._setupDropdown(); _this68._setupEventHandlers(); return _this68; }
Construct FormSelect instance @constructor @param {Element} el @param {Object} options
FormSelect
javascript
Dogfalo/materialize
dist/js/materialize.js
https://github.com/Dogfalo/materialize/blob/master/dist/js/materialize.js
MIT
function Range(el, options) { _classCallCheck(this, Range); var _this72 = _possibleConstructorReturn(this, (Range.__proto__ || Object.getPrototypeOf(Range)).call(this, Range, el, options)); _this72.el.M_Range = _this72; /** * Options for the range * @member Range#options */ _this72.options = $.extend({}, Range.defaults, options); _this72._mousedown = false; // Setup _this72._setupThumb(); _this72._setupEventHandlers(); return _this72; }
Construct Range instance @constructor @param {Element} el @param {Object} options
Range
javascript
Dogfalo/materialize
dist/js/materialize.js
https://github.com/Dogfalo/materialize/blob/master/dist/js/materialize.js
MIT
constructor(el, options) { super(Autocomplete, el, options); this.el.M_Autocomplete = this; /** * Options for the autocomplete * @member Autocomplete#options * @prop {Number} duration * @prop {Number} dist * @prop {number} shift * @prop {number} padding * @prop {Boolean} fullWidth * @prop {Boolean} indicators * @prop {Boolean} noWrap * @prop {Function} onCycleTo */ this.options = $.extend({}, Autocomplete.defaults, options); // Setup this.isOpen = false; this.count = 0; this.activeIndex = -1; this.oldVal; this.$inputField = this.$el.closest('.input-field'); this.$active = $(); this._mousedown = false; this._setupDropdown(); this._setupEventHandlers(); }
Construct Autocomplete instance @constructor @param {Element} el @param {Object} options
constructor
javascript
Dogfalo/materialize
js/autocomplete.js
https://github.com/Dogfalo/materialize/blob/master/js/autocomplete.js
MIT
static get defaults() { return _defaults; }
Options for the autocomplete @member Autocomplete#options @prop {Number} duration @prop {Number} dist @prop {number} shift @prop {number} padding @prop {Boolean} fullWidth @prop {Boolean} indicators @prop {Boolean} noWrap @prop {Function} onCycleTo
defaults
javascript
Dogfalo/materialize
js/autocomplete.js
https://github.com/Dogfalo/materialize/blob/master/js/autocomplete.js
MIT
static init(els, options) { return super.init(this, els, options); }
Options for the autocomplete @member Autocomplete#options @prop {Number} duration @prop {Number} dist @prop {number} shift @prop {number} padding @prop {Boolean} fullWidth @prop {Boolean} indicators @prop {Boolean} noWrap @prop {Function} onCycleTo
init
javascript
Dogfalo/materialize
js/autocomplete.js
https://github.com/Dogfalo/materialize/blob/master/js/autocomplete.js
MIT
_handleInputKeyupAndFocus(e) { if (e.type === 'keyup') { Autocomplete._keydown = false; } this.count = 0; let val = this.el.value.toLowerCase(); // Don't capture enter or arrow key usage. if (e.keyCode === 13 || e.keyCode === 38 || e.keyCode === 40) { return; } // Check if the input isn't empty // Check if focus triggered by tab if (this.oldVal !== val && (M.tabPressed || e.type !== 'focus')) { this.open(); } // Update oldVal this.oldVal = val; }
Handle Input Keyup and Focus @param {Event} e
_handleInputKeyupAndFocus
javascript
Dogfalo/materialize
js/autocomplete.js
https://github.com/Dogfalo/materialize/blob/master/js/autocomplete.js
MIT
_handleContainerMousedownAndTouchstart(e) { this._mousedown = true; }
Handle Container Mousedown and Touchstart @param {Event} e
_handleContainerMousedownAndTouchstart
javascript
Dogfalo/materialize
js/autocomplete.js
https://github.com/Dogfalo/materialize/blob/master/js/autocomplete.js
MIT
_handleContainerMouseupAndTouchend(e) { this._mousedown = false; }
Handle Container Mouseup and Touchend @param {Event} e
_handleContainerMouseupAndTouchend
javascript
Dogfalo/materialize
js/autocomplete.js
https://github.com/Dogfalo/materialize/blob/master/js/autocomplete.js
MIT
selectOption(el) { let text = el.text().trim(); this.el.value = text; this.$el.trigger('change'); this._resetAutocomplete(); this.close(); // Handle onAutocomplete callback. if (typeof this.options.onAutocomplete === 'function') { this.options.onAutocomplete.call(this, text); } }
Select autocomplete option @param {Element} el Autocomplete option list item element
selectOption
javascript
Dogfalo/materialize
js/autocomplete.js
https://github.com/Dogfalo/materialize/blob/master/js/autocomplete.js
MIT
_renderDropdown(data, val) { this._resetAutocomplete(); let matchingData = []; // Gather all matching data for (let key in data) { if (data.hasOwnProperty(key) && key.toLowerCase().indexOf(val) !== -1) { let entry = { data: data[key], key: key }; matchingData.push(entry); this.count++; } } // Sort if (this.options.sortFunction) { let sortFunctionBound = (a, b) => { return this.options.sortFunction( a.key.toLowerCase(), b.key.toLowerCase(), val.toLowerCase() ); }; matchingData.sort(sortFunctionBound); } // Limit matchingData = matchingData.slice(0, this.options.limit); // Render for (let i = 0; i < matchingData.length; i++) { let entry = matchingData[i]; let $autocompleteOption = $('<li></li>'); if (!!entry.data) { $autocompleteOption.append( `<img src="${entry.data}" class="right circle"><span>${entry.key}</span>` ); } else { $autocompleteOption.append('<span>' + entry.key + '</span>'); } $(this.container).append($autocompleteOption); this._highlight(val, $autocompleteOption); } }
Render dropdown content @param {Object} data data set @param {String} val current input value
_renderDropdown
javascript
Dogfalo/materialize
js/autocomplete.js
https://github.com/Dogfalo/materialize/blob/master/js/autocomplete.js
MIT
sortFunctionBound = (a, b) => { return this.options.sortFunction( a.key.toLowerCase(), b.key.toLowerCase(), val.toLowerCase() ); }
Render dropdown content @param {Object} data data set @param {String} val current input value
sortFunctionBound
javascript
Dogfalo/materialize
js/autocomplete.js
https://github.com/Dogfalo/materialize/blob/master/js/autocomplete.js
MIT
sortFunctionBound = (a, b) => { return this.options.sortFunction( a.key.toLowerCase(), b.key.toLowerCase(), val.toLowerCase() ); }
Render dropdown content @param {Object} data data set @param {String} val current input value
sortFunctionBound
javascript
Dogfalo/materialize
js/autocomplete.js
https://github.com/Dogfalo/materialize/blob/master/js/autocomplete.js
MIT
constructor(el, options) { super(FloatingActionButton, el, options); this.el.M_FloatingActionButton = this; /** * Options for the fab * @member FloatingActionButton#options * @prop {Boolean} [direction] - Direction fab menu opens * @prop {Boolean} [hoverEnabled=true] - Enable hover vs click * @prop {Boolean} [toolbarEnabled=false] - Enable toolbar transition */ this.options = $.extend({}, FloatingActionButton.defaults, options); this.isOpen = false; this.$anchor = this.$el.children('a').first(); this.$menu = this.$el.children('ul').first(); this.$floatingBtns = this.$el.find('ul .btn-floating'); this.$floatingBtnsReverse = this.$el.find('ul .btn-floating').reverse(); this.offsetY = 0; this.offsetX = 0; this.$el.addClass(`direction-${this.options.direction}`); if (this.options.direction === 'top') { this.offsetY = 40; } else if (this.options.direction === 'right') { this.offsetX = -40; } else if (this.options.direction === 'bottom') { this.offsetY = -40; } else { this.offsetX = 40; } this._setupEventHandlers(); }
Construct FloatingActionButton instance @constructor @param {Element} el @param {Object} options
constructor
javascript
Dogfalo/materialize
js/buttons.js
https://github.com/Dogfalo/materialize/blob/master/js/buttons.js
MIT
static get defaults() { return _defaults; }
Options for the fab @member FloatingActionButton#options @prop {Boolean} [direction] - Direction fab menu opens @prop {Boolean} [hoverEnabled=true] - Enable hover vs click @prop {Boolean} [toolbarEnabled=false] - Enable toolbar transition
defaults
javascript
Dogfalo/materialize
js/buttons.js
https://github.com/Dogfalo/materialize/blob/master/js/buttons.js
MIT
static init(els, options) { return super.init(this, els, options); }
Options for the fab @member FloatingActionButton#options @prop {Boolean} [direction] - Direction fab menu opens @prop {Boolean} [hoverEnabled=true] - Enable hover vs click @prop {Boolean} [toolbarEnabled=false] - Enable toolbar transition
init
javascript
Dogfalo/materialize
js/buttons.js
https://github.com/Dogfalo/materialize/blob/master/js/buttons.js
MIT
constructor(el, options) { super(Carousel, el, options); this.el.M_Carousel = this; /** * Options for the carousel * @member Carousel#options * @prop {Number} duration * @prop {Number} dist * @prop {Number} shift * @prop {Number} padding * @prop {Number} numVisible * @prop {Boolean} fullWidth * @prop {Boolean} indicators * @prop {Boolean} noWrap * @prop {Function} onCycleTo */ this.options = $.extend({}, Carousel.defaults, options); // Setup this.hasMultipleSlides = this.$el.find('.carousel-item').length > 1; this.showIndicators = this.options.indicators && this.hasMultipleSlides; this.noWrap = this.options.noWrap || !this.hasMultipleSlides; this.pressed = false; this.dragged = false; this.offset = this.target = 0; this.images = []; this.itemWidth = this.$el .find('.carousel-item') .first() .innerWidth(); this.itemHeight = this.$el .find('.carousel-item') .first() .innerHeight(); this.dim = this.itemWidth * 2 + this.options.padding || 1; // Make sure dim is non zero for divisions. this._autoScrollBound = this._autoScroll.bind(this); this._trackBound = this._track.bind(this); // Full Width carousel setup if (this.options.fullWidth) { this.options.dist = 0; this._setCarouselHeight(); // Offset fixed items when indicators. if (this.showIndicators) { this.$el.find('.carousel-fixed-item').addClass('with-indicators'); } } // Iterate through slides this.$indicators = $('<ul class="indicators"></ul>'); this.$el.find('.carousel-item').each((el, i) => { this.images.push(el); if (this.showIndicators) { let $indicator = $('<li class="indicator-item"></li>'); // Add active to first by default. if (i === 0) { $indicator[0].classList.add('active'); } this.$indicators.append($indicator); } }); if (this.showIndicators) { this.$el.append(this.$indicators); } this.count = this.images.length; // Cap numVisible at count this.options.numVisible = Math.min(this.count, this.options.numVisible); // Setup cross browser string this.xform = 'transform'; ['webkit', 'Moz', 'O', 'ms'].every((prefix) => { var e = prefix + 'Transform'; if (typeof document.body.style[e] !== 'undefined') { this.xform = e; return false; } return true; }); this._setupEventHandlers(); this._scroll(this.offset); }
Construct Carousel instance @constructor @param {Element} el @param {Object} options
constructor
javascript
Dogfalo/materialize
js/carousel.js
https://github.com/Dogfalo/materialize/blob/master/js/carousel.js
MIT
static get defaults() { return _defaults; }
Options for the carousel @member Carousel#options @prop {Number} duration @prop {Number} dist @prop {Number} shift @prop {Number} padding @prop {Number} numVisible @prop {Boolean} fullWidth @prop {Boolean} indicators @prop {Boolean} noWrap @prop {Function} onCycleTo
defaults
javascript
Dogfalo/materialize
js/carousel.js
https://github.com/Dogfalo/materialize/blob/master/js/carousel.js
MIT
static init(els, options) { return super.init(this, els, options); }
Options for the carousel @member Carousel#options @prop {Number} duration @prop {Number} dist @prop {Number} shift @prop {Number} padding @prop {Number} numVisible @prop {Boolean} fullWidth @prop {Boolean} indicators @prop {Boolean} noWrap @prop {Function} onCycleTo
init
javascript
Dogfalo/materialize
js/carousel.js
https://github.com/Dogfalo/materialize/blob/master/js/carousel.js
MIT
_setCarouselHeight(imageOnly) { let firstSlide = this.$el.find('.carousel-item.active').length ? this.$el.find('.carousel-item.active').first() : this.$el.find('.carousel-item').first(); let firstImage = firstSlide.find('img').first(); if (firstImage.length) { if (firstImage[0].complete) { // If image won't trigger the load event let imageHeight = firstImage.height(); if (imageHeight > 0) { this.$el.css('height', imageHeight + 'px'); } else { // If image still has no height, use the natural dimensions to calculate let naturalWidth = firstImage[0].naturalWidth; let naturalHeight = firstImage[0].naturalHeight; let adjustedHeight = this.$el.width() / naturalWidth * naturalHeight; this.$el.css('height', adjustedHeight + 'px'); } } else { // Get height when image is loaded normally firstImage.one('load', (el, i) => { this.$el.css('height', el.offsetHeight + 'px'); }); } } else if (!imageOnly) { let slideHeight = firstSlide.height(); this.$el.css('height', slideHeight + 'px'); } }
Set carousel height based on first slide @param {Booleam} imageOnly - true for image slides
_setCarouselHeight
javascript
Dogfalo/materialize
js/carousel.js
https://github.com/Dogfalo/materialize/blob/master/js/carousel.js
MIT
_xpos(e) { // touch event if (e.targetTouches && e.targetTouches.length >= 1) { return e.targetTouches[0].clientX; } // mouse event return e.clientX; }
Get x position from event @param {Event} e
_xpos
javascript
Dogfalo/materialize
js/carousel.js
https://github.com/Dogfalo/materialize/blob/master/js/carousel.js
MIT
_ypos(e) { // touch event if (e.targetTouches && e.targetTouches.length >= 1) { return e.targetTouches[0].clientY; } // mouse event return e.clientY; }
Get y position from event @param {Event} e
_ypos
javascript
Dogfalo/materialize
js/carousel.js
https://github.com/Dogfalo/materialize/blob/master/js/carousel.js
MIT
_autoScroll() { let elapsed, delta; if (this.amplitude) { elapsed = Date.now() - this.timestamp; delta = this.amplitude * Math.exp(-elapsed / this.options.duration); if (delta > 2 || delta < -2) { this._scroll(this.target - delta); requestAnimationFrame(this._autoScrollBound); } else { this._scroll(this.target); } } }
Auto scrolls to nearest carousel item.
_autoScroll
javascript
Dogfalo/materialize
js/carousel.js
https://github.com/Dogfalo/materialize/blob/master/js/carousel.js
MIT
_updateItemStyle(el, opacity, zIndex, transform) { el.style[this.xform] = transform; el.style.zIndex = zIndex; el.style.opacity = opacity; el.style.visibility = 'visible'; }
Cycle to target @param {Element} el @param {Number} opacity @param {Number} zIndex @param {String} transform
_updateItemStyle
javascript
Dogfalo/materialize
js/carousel.js
https://github.com/Dogfalo/materialize/blob/master/js/carousel.js
MIT
_cycleTo(n, callback) { let diff = this.center % this.count - n; // Account for wraparound. if (!this.noWrap) { if (diff < 0) { if (Math.abs(diff + this.count) < Math.abs(diff)) { diff += this.count; } } else if (diff > 0) { if (Math.abs(diff - this.count) < diff) { diff -= this.count; } } } this.target = this.dim * Math.round(this.offset / this.dim); // Next if (diff < 0) { this.target += this.dim * Math.abs(diff); // Prev } else if (diff > 0) { this.target -= this.dim * diff; } // Set one time callback if (typeof callback === 'function') { this.oneTimeCallback = callback; } // Scroll if (this.offset !== this.target) { this.amplitude = this.target - this.offset; this.timestamp = Date.now(); requestAnimationFrame(this._autoScrollBound); } }
Cycle to target @param {Number} n @param {Function} callback
_cycleTo
javascript
Dogfalo/materialize
js/carousel.js
https://github.com/Dogfalo/materialize/blob/master/js/carousel.js
MIT
next(n) { if (n === undefined || isNaN(n)) { n = 1; } let index = this.center + n; if (index >= this.count || index < 0) { if (this.noWrap) { return; } index = this._wrap(index); } this._cycleTo(index); }
Cycle to next item @param {Number} [n]
next
javascript
Dogfalo/materialize
js/carousel.js
https://github.com/Dogfalo/materialize/blob/master/js/carousel.js
MIT
prev(n) { if (n === undefined || isNaN(n)) { n = 1; } let index = this.center - n; if (index >= this.count || index < 0) { if (this.noWrap) { return; } index = this._wrap(index); } this._cycleTo(index); }
Cycle to previous item @param {Number} [n]
prev
javascript
Dogfalo/materialize
js/carousel.js
https://github.com/Dogfalo/materialize/blob/master/js/carousel.js
MIT
set(n, callback) { if (n === undefined || isNaN(n)) { n = 0; } if (n > this.count || n < 0) { if (this.noWrap) { return; } n = this._wrap(n); } this._cycleTo(n, callback); }
Cycle to nth item @param {Number} [n] @param {Function} callback
set
javascript
Dogfalo/materialize
js/carousel.js
https://github.com/Dogfalo/materialize/blob/master/js/carousel.js
MIT
function encode(name, value) { return "&" + encodeURIComponent(name) + "=" + encodeURIComponent(value).replace(/%20/g, "+"); }
Modified Triggers browser event @param String eventName @param Object data - Add properties to event object
encode
javascript
Dogfalo/materialize
js/cash.js
https://github.com/Dogfalo/materialize/blob/master/js/cash.js
MIT
function getSelectMultiple_(el) { var values = []; each(el.options, function (o) { if (o.selected) { values.push(o.value); } }); return values.length ? values : null; }
Modified Triggers browser event @param String eventName @param Object data - Add properties to event object
getSelectMultiple_
javascript
Dogfalo/materialize
js/cash.js
https://github.com/Dogfalo/materialize/blob/master/js/cash.js
MIT
function getSelectSingle_(el) { var selectedIndex = el.selectedIndex; return selectedIndex >= 0 ? el.options[selectedIndex].value : null; }
Modified Triggers browser event @param String eventName @param Object data - Add properties to event object
getSelectSingle_
javascript
Dogfalo/materialize
js/cash.js
https://github.com/Dogfalo/materialize/blob/master/js/cash.js
MIT
function getValue(el) { var type = el.type; if (!type) { return null; } switch (type.toLowerCase()) { case "select-one": return getSelectSingle_(el); case "select-multiple": return getSelectMultiple_(el); case "radio": return (el.checked) ? el.value : null; case "checkbox": return (el.checked) ? el.value : null; default: return el.value ? el.value : null; } }
Modified Triggers browser event @param String eventName @param Object data - Add properties to event object
getValue
javascript
Dogfalo/materialize
js/cash.js
https://github.com/Dogfalo/materialize/blob/master/js/cash.js
MIT
function insertElement(el, child, prepend) { if (prepend) { var first = el.childNodes[0]; el.insertBefore(child, first); } else { el.appendChild(child); } }
Modified Triggers browser event @param String eventName @param Object data - Add properties to event object
insertElement
javascript
Dogfalo/materialize
js/cash.js
https://github.com/Dogfalo/materialize/blob/master/js/cash.js
MIT
function insertContent(parent, child, prepend) { var str = isString(child); if (!str && child.length) { each(child, function (v) { return insertContent(parent, v, prepend); }); return; } each(parent, str ? function (v) { return v.insertAdjacentHTML(prepend ? "afterbegin" : "beforeend", child); } : function (v, i) { return insertElement(v, (i === 0 ? child : child.cloneNode(true)), prepend); }); }
Modified Triggers browser event @param String eventName @param Object data - Add properties to event object
insertContent
javascript
Dogfalo/materialize
js/cash.js
https://github.com/Dogfalo/materialize/blob/master/js/cash.js
MIT
constructor(el, options) { super(CharacterCounter, el, options); this.el.M_CharacterCounter = this; /** * Options for the character counter */ this.options = $.extend({}, CharacterCounter.defaults, options); this.isInvalid = false; this.isValidLength = false; this._setupCounter(); this._setupEventHandlers(); }
Construct CharacterCounter instance @constructor @param {Element} el @param {Object} options
constructor
javascript
Dogfalo/materialize
js/characterCounter.js
https://github.com/Dogfalo/materialize/blob/master/js/characterCounter.js
MIT
constructor(el, options) { super(Chips, el, options); this.el.M_Chips = this; /** * Options for the modal * @member Chips#options * @prop {Array} data * @prop {String} placeholder * @prop {String} secondaryPlaceholder * @prop {Object} autocompleteOptions */ this.options = $.extend({}, Chips.defaults, options); this.$el.addClass('chips input-field'); this.chipsData = []; this.$chips = $(); this._setupInput(); this.hasAutocomplete = Object.keys(this.options.autocompleteOptions).length > 0; // Set input id if (!this.$input.attr('id')) { this.$input.attr('id', M.guid()); } // Render initial chips if (this.options.data.length) { this.chipsData = this.options.data; this._renderChips(this.chipsData); } // Setup autocomplete if needed if (this.hasAutocomplete) { this._setupAutocomplete(); } this._setPlaceholder(); this._setupLabel(); this._setupEventHandlers(); }
Construct Chips instance and set up overlay @constructor @param {Element} el @param {Object} options
constructor
javascript
Dogfalo/materialize
js/chips.js
https://github.com/Dogfalo/materialize/blob/master/js/chips.js
MIT
static get defaults() { return _defaults; }
Options for the modal @member Chips#options @prop {Array} data @prop {String} placeholder @prop {String} secondaryPlaceholder @prop {Object} autocompleteOptions
defaults
javascript
Dogfalo/materialize
js/chips.js
https://github.com/Dogfalo/materialize/blob/master/js/chips.js
MIT
static init(els, options) { return super.init(this, els, options); }
Options for the modal @member Chips#options @prop {Array} data @prop {String} placeholder @prop {String} secondaryPlaceholder @prop {Object} autocompleteOptions
init
javascript
Dogfalo/materialize
js/chips.js
https://github.com/Dogfalo/materialize/blob/master/js/chips.js
MIT
_renderChip(chip) { if (!chip.tag) { return; } let renderedChip = document.createElement('div'); let closeIcon = document.createElement('i'); renderedChip.classList.add('chip'); renderedChip.textContent = chip.tag; renderedChip.setAttribute('tabindex', 0); $(closeIcon).addClass('material-icons close'); closeIcon.textContent = 'close'; // attach image if needed if (chip.image) { let img = document.createElement('img'); img.setAttribute('src', chip.image); renderedChip.insertBefore(img, renderedChip.firstChild); } renderedChip.appendChild(closeIcon); return renderedChip; }
Render Chip @param {chip} chip @return {Element}
_renderChip
javascript
Dogfalo/materialize
js/chips.js
https://github.com/Dogfalo/materialize/blob/master/js/chips.js
MIT
_isValid(chip) { if (chip.hasOwnProperty('tag') && chip.tag !== '') { let exists = false; for (let i = 0; i < this.chipsData.length; i++) { if (this.chipsData[i].tag === chip.tag) { exists = true; break; } } return !exists; } return false; }
Check if chip is valid @param {chip} chip
_isValid
javascript
Dogfalo/materialize
js/chips.js
https://github.com/Dogfalo/materialize/blob/master/js/chips.js
MIT
constructor(el, options) { super(Collapsible, el, options); this.el.M_Collapsible = this; /** * Options for the collapsible * @member Collapsible#options * @prop {Boolean} [accordion=false] - Type of the collapsible * @prop {Function} onOpenStart - Callback function called before collapsible is opened * @prop {Function} onOpenEnd - Callback function called after collapsible is opened * @prop {Function} onCloseStart - Callback function called before collapsible is closed * @prop {Function} onCloseEnd - Callback function called after collapsible is closed * @prop {Number} inDuration - Transition in duration in milliseconds. * @prop {Number} outDuration - Transition duration in milliseconds. */ this.options = $.extend({}, Collapsible.defaults, options); // Setup tab indices this.$headers = this.$el.children('li').children('.collapsible-header'); this.$headers.attr('tabindex', 0); this._setupEventHandlers(); // Open first active let $activeBodies = this.$el.children('li.active').children('.collapsible-body'); if (this.options.accordion) { // Handle Accordion $activeBodies.first().css('display', 'block'); } else { // Handle Expandables $activeBodies.css('display', 'block'); } }
Construct Collapsible instance @constructor @param {Element} el @param {Object} options
constructor
javascript
Dogfalo/materialize
js/collapsible.js
https://github.com/Dogfalo/materialize/blob/master/js/collapsible.js
MIT
static get defaults() { return _defaults; }
Options for the collapsible @member Collapsible#options @prop {Boolean} [accordion=false] - Type of the collapsible @prop {Function} onOpenStart - Callback function called before collapsible is opened @prop {Function} onOpenEnd - Callback function called after collapsible is opened @prop {Function} onCloseStart - Callback function called before collapsible is closed @prop {Function} onCloseEnd - Callback function called after collapsible is closed @prop {Number} inDuration - Transition in duration in milliseconds. @prop {Number} outDuration - Transition duration in milliseconds.
defaults
javascript
Dogfalo/materialize
js/collapsible.js
https://github.com/Dogfalo/materialize/blob/master/js/collapsible.js
MIT
static init(els, options) { return super.init(this, els, options); }
Options for the collapsible @member Collapsible#options @prop {Boolean} [accordion=false] - Type of the collapsible @prop {Function} onOpenStart - Callback function called before collapsible is opened @prop {Function} onOpenEnd - Callback function called after collapsible is opened @prop {Function} onCloseStart - Callback function called before collapsible is closed @prop {Function} onCloseEnd - Callback function called after collapsible is closed @prop {Number} inDuration - Transition in duration in milliseconds. @prop {Number} outDuration - Transition duration in milliseconds.
init
javascript
Dogfalo/materialize
js/collapsible.js
https://github.com/Dogfalo/materialize/blob/master/js/collapsible.js
MIT
_animateIn(index) { let $collapsibleLi = this.$el.children('li').eq(index); if ($collapsibleLi.length) { let $body = $collapsibleLi.children('.collapsible-body'); anim.remove($body[0]); $body.css({ display: 'block', overflow: 'hidden', height: 0, paddingTop: '', paddingBottom: '' }); let pTop = $body.css('padding-top'); let pBottom = $body.css('padding-bottom'); let finalHeight = $body[0].scrollHeight; $body.css({ paddingTop: 0, paddingBottom: 0 }); anim({ targets: $body[0], height: finalHeight, paddingTop: pTop, paddingBottom: pBottom, duration: this.options.inDuration, easing: 'easeInOutCubic', complete: (anim) => { $body.css({ overflow: '', paddingTop: '', paddingBottom: '', height: '' }); // onOpenEnd callback if (typeof this.options.onOpenEnd === 'function') { this.options.onOpenEnd.call(this, $collapsibleLi[0]); } } }); } }
Animate in collapsible slide @param {Number} index - 0th index of slide
_animateIn
javascript
Dogfalo/materialize
js/collapsible.js
https://github.com/Dogfalo/materialize/blob/master/js/collapsible.js
MIT
_animateOut(index) { let $collapsibleLi = this.$el.children('li').eq(index); if ($collapsibleLi.length) { let $body = $collapsibleLi.children('.collapsible-body'); anim.remove($body[0]); $body.css('overflow', 'hidden'); anim({ targets: $body[0], height: 0, paddingTop: 0, paddingBottom: 0, duration: this.options.outDuration, easing: 'easeInOutCubic', complete: () => { $body.css({ height: '', overflow: '', padding: '', display: '' }); // onCloseEnd callback if (typeof this.options.onCloseEnd === 'function') { this.options.onCloseEnd.call(this, $collapsibleLi[0]); } } }); } }
Animate out collapsible slide @param {Number} index - 0th index of slide to open
_animateOut
javascript
Dogfalo/materialize
js/collapsible.js
https://github.com/Dogfalo/materialize/blob/master/js/collapsible.js
MIT
open(index) { let $collapsibleLi = this.$el.children('li').eq(index); if ($collapsibleLi.length && !$collapsibleLi[0].classList.contains('active')) { // onOpenStart callback if (typeof this.options.onOpenStart === 'function') { this.options.onOpenStart.call(this, $collapsibleLi[0]); } // Handle accordion behavior if (this.options.accordion) { let $collapsibleLis = this.$el.children('li'); let $activeLis = this.$el.children('li.active'); $activeLis.each((el) => { let index = $collapsibleLis.index($(el)); this.close(index); }); } // Animate in $collapsibleLi[0].classList.add('active'); this._animateIn(index); } }
Open Collapsible @param {Number} index - 0th index of slide
open
javascript
Dogfalo/materialize
js/collapsible.js
https://github.com/Dogfalo/materialize/blob/master/js/collapsible.js
MIT
close(index) { let $collapsibleLi = this.$el.children('li').eq(index); if ($collapsibleLi.length && $collapsibleLi[0].classList.contains('active')) { // onCloseStart callback if (typeof this.options.onCloseStart === 'function') { this.options.onCloseStart.call(this, $collapsibleLi[0]); } // Animate out $collapsibleLi[0].classList.remove('active'); this._animateOut(index); } }
Close Collapsible @param {Number} index - 0th index of slide
close
javascript
Dogfalo/materialize
js/collapsible.js
https://github.com/Dogfalo/materialize/blob/master/js/collapsible.js
MIT
constructor(classDef, el, options) { // Display error if el is valid HTML Element if (!(el instanceof Element)) { console.error(Error(el + ' is not an HTML Element')); } // If exists, destroy and reinitialize in child let ins = classDef.getInstance(el); if (!!ins) { ins.destroy(); } this.el = el; this.$el = cash(el); }
Generic constructor for all components @constructor @param {Element} el @param {Object} options
constructor
javascript
Dogfalo/materialize
js/component.js
https://github.com/Dogfalo/materialize/blob/master/js/component.js
MIT