This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var onceTransitionEnd = function (node, time, callback) { | |
var finished = false; | |
var timer = setTimeout(listener, time + 50); | |
var listener = function () { | |
if (finished === false) { | |
removeListener(); | |
node = null; | |
time = null; | |
listener = null; | |
removeListener = null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @see https://gist.github.com/john-yuan/e53f55d3e8ec63c3b55ceb502bf5ce36 | |
*/ | |
var ICibaDictionary = (function () { | |
'use strict'; | |
var BASE_URL = 'http://dict-co.iciba.com/api/dictionary.php'; | |
var TYPE_JSON = 'json'; | |
var TYPE_XML = 'xml'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Check whether the variable passed in is a normal object. Normal object means | |
* an object that is created by `{}` or `new Object()`. | |
* | |
* @param {any} it The variable to check | |
* @returns {boolean} Returns `true` if `it` is a normal object | |
*/ | |
var isNormalObject = function (it) { | |
if (!it || '[object Object]' !== {}.toString.call(it)) { | |
return false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Parse the URL string to get the details of the URL. | |
* | |
* The names of the properties of the returned object is same with the names of | |
* the properties in the `window.location` object in the browser, but the | |
* returned object only have one method, that is toString(). | |
* | |
* @typedef {Object} URLInformation The URL Information | |
* @property {string} protocol example: https: | |
* @property {string} hostname example: developer.mozilla.org |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 主域名跨标签轻量级事件通知机制 | |
* | |
* 主要用于具有相同主域名的多个浏览器标签之间的事件通知。比如现在浏览器中有两个标签, | |
* 第一个标签的域名为: site1.example.com;第二个标签的域名为:site2.example.com。 | |
* 两个标签中都可以进行登录操作,但在登录之后需要通知另一个标签。此时便可以使用这个类。 | |
* | |
* 注意: | |
* | |
* 1. 这个类使用 cookie 作为通信媒介 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 复制数据结构定义(definition)中指定的内容 | |
* | |
* @param {Object.<string, *>} definition 数据结构定义 | |
* @param {Object.<string, *>} dataSource 数据源 | |
* @param {Object.<string, *>} [options] (可选)附加选项 | |
* @param {any} [options.defaultObject=null] (可选)当数据源中没有定义中的对象时使用的默认值 | |
* @param {any} [options.defaultArray=[]] (可选)当数据源中没有定义中的数组时使用的默认值 | |
* @returns {Object.<string, *>} 返回过滤后的数据 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Convert rgb formatted color string to hash formatted color string | |
* | |
* @example | |
* // @returns #ff00ff | |
* rgb2hash('rgb(255, 0, 255)'); | |
* | |
* @param {string} rgbColorStr The rgb formatted color string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 将值转换为字符串并移除首尾空白字符 | |
* | |
* @param {any} value 需要转换的值 | |
* @returns {string} | |
*/ | |
function toTrimedString(value) { | |
if (typeof value !== 'string') { | |
if (value === null || value === undefined) { | |
value = ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 获取指定月份日历视图中的 42 个日期对象。 | |
* | |
* @param {number} year 完整的年份数字,如 `2019` 即代表 2019 年。 | |
* @param {number} month 月份数字,如 `11` 即代表 11 月。 | |
* @param {number} [startWeekDay=0] 可选的参数,默认为 `0`(星期日),表示日历中的第一列为星期几(一般为星期日或者星期一)。其中 `0` 表 | |
* 示星期日,`1` 表示星期一,后面以此类推。 | |
* @returns {Date[]} 返回一个数组,包含 42 个 `Date` 对象。 | |
*/ | |
function getCalendarDateList(year, month, startWeekDay) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 获取指定月份日历视图中的 42 个日期对象。 | |
* | |
* @param {number} year 完整的年份数字,如 `2019` 即代表 2019 年。 | |
* @param {number} month 月份数字,如 `11` 即代表 11 月。 | |
* @param {number} [startWeekDay=0] 可选的参数,默认为 `0`(星期日),表示日历中的第一列为星期几(一般为星期日或者星期一)。其中 `0` 表 | |
* 示星期日,`1` 表示星期一,后面以此类推。 | |
* @returns {Date[]} 返回一个数组,包含 42 个 `Date` 对象。 | |
*/ | |
function getCalendarDateList(year, month, startWeekDay) { |