diff options
Diffstat (limited to 'dist/plyr.js')
-rw-r--r-- | dist/plyr.js | 1006 |
1 files changed, 513 insertions, 493 deletions
diff --git a/dist/plyr.js b/dist/plyr.js index 6e1f3941..746d4dc3 100644 --- a/dist/plyr.js +++ b/dist/plyr.js @@ -99,279 +99,321 @@ typeof navigator === "object" && (function (global, factory) { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } - const defaults = { - addCSS: true, // Add CSS to the element to improve usability (required here or in your CSS!) - thumbWidth: 15, // The width of the thumb handle - watch: true, // Watch for new elements that match a string target + var defaults = { + addCSS: true, + // Add CSS to the element to improve usability (required here or in your CSS!) + thumbWidth: 15, + // The width of the thumb handle + watch: true // Watch for new elements that match a string target + }; // Element matches a selector function matches(element, selector) { - function match() { - return Array.from(document.querySelectorAll(selector)).includes(this); - } - - const matches = - match; + function match() { + return Array.from(document.querySelectorAll(selector)).includes(this); + } - return matches.call(element, selector); + var matches = match; + return matches.call(element, selector); } // Trigger event function trigger(element, type) { - if (!element || !type) { - return; - } + if (!element || !type) { + return; + } // Create and dispatch the event - // Create and dispatch the event - const event = new Event(type); - // Dispatch the event - element.dispatchEvent(event); + var event = new Event(type); // Dispatch the event + + element.dispatchEvent(event); } // ========================================================================== // Type checking utils // ========================================================================== + var getConstructor = function getConstructor(input) { + return input !== null && typeof input !== 'undefined' ? input.constructor : null; + }; + + var instanceOf = function instanceOf(input, constructor) { + return Boolean(input && constructor && input instanceof constructor); + }; + + var isNullOrUndefined = function isNullOrUndefined(input) { + return input === null || typeof input === 'undefined'; + }; + + var isObject = function isObject(input) { + return getConstructor(input) === Object; + }; + + var isNumber = function isNumber(input) { + return getConstructor(input) === Number && !Number.isNaN(input); + }; + + var isString = function isString(input) { + return getConstructor(input) === String; + }; + + var isBoolean = function isBoolean(input) { + return getConstructor(input) === Boolean; + }; + + var isFunction = function isFunction(input) { + return getConstructor(input) === Function; + }; + + var isArray = function isArray(input) { + return Array.isArray(input); + }; + + var isNodeList = function isNodeList(input) { + return instanceOf(input, NodeList); + }; + + var isElement = function isElement(input) { + return instanceOf(input, Element); + }; - const getConstructor = input => (input !== null && typeof input !== 'undefined' ? input.constructor : null); - const instanceOf = (input, constructor) => Boolean(input && constructor && input instanceof constructor); - - const isNullOrUndefined = input => input === null || typeof input === 'undefined'; - const isObject = input => getConstructor(input) === Object; - const isNumber = input => getConstructor(input) === Number && !Number.isNaN(input); - const isString = input => getConstructor(input) === String; - const isBoolean = input => getConstructor(input) === Boolean; - const isFunction = input => getConstructor(input) === Function; - const isArray = input => Array.isArray(input); - const isNodeList = input => instanceOf(input, NodeList); - const isElement = input => instanceOf(input, Element); - const isEvent = input => instanceOf(input, Event); - const isEmpty = input => - isNullOrUndefined(input) || - ((isString(input) || isArray(input) || isNodeList(input)) && !input.length) || - (isObject(input) && !Object.keys(input).length); + var isEvent = function isEvent(input) { + return instanceOf(input, Event); + }; + + var isEmpty = function isEmpty(input) { + return isNullOrUndefined(input) || (isString(input) || isArray(input) || isNodeList(input)) && !input.length || isObject(input) && !Object.keys(input).length; + }; var is = { - nullOrUndefined: isNullOrUndefined, - object: isObject, - number: isNumber, - string: isString, - boolean: isBoolean, - function: isFunction, - array: isArray, - nodeList: isNodeList, - element: isElement, - event: isEvent, - empty: isEmpty, + nullOrUndefined: isNullOrUndefined, + object: isObject, + number: isNumber, + string: isString, + boolean: isBoolean, + function: isFunction, + array: isArray, + nodeList: isNodeList, + element: isElement, + event: isEvent, + empty: isEmpty }; // Get the number of decimal places function getDecimalPlaces(value) { - const match = `${value}`.match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/); + var match = "".concat(value).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/); - if (!match) { - return 0; - } + if (!match) { + return 0; + } - return Math.max( - 0, - // Number of digits right of decimal point. - (match[1] ? match[1].length : 0) - - // Adjust for scientific notation. - (match[2] ? +match[2] : 0), - ); - } + return Math.max(0, // Number of digits right of decimal point. + (match[1] ? match[1].length : 0) - ( // Adjust for scientific notation. + match[2] ? +match[2] : 0)); + } // Round to the nearest step - // Round to the nearest step function round(number, step) { - if (step < 1) { - const places = getDecimalPlaces(step); - return parseFloat(number.toFixed(places)); - } - return Math.round(number / step) * step; + if (step < 1) { + var places = getDecimalPlaces(step); + return parseFloat(number.toFixed(places)); + } + + return Math.round(number / step) * step; } - // ========================================================================== + var RangeTouch = + /*#__PURE__*/ + function () { + /** + * Setup a new instance + * @param {String|Element} target + * @param {Object} options + */ + function RangeTouch(target, options) { + _classCallCheck(this, RangeTouch); - class RangeTouch { - /** - * Setup a new instance - * @param {String|Element} target - * @param {Object} options - */ - constructor(target, options) { - if (is.element(target)) { - // An Element is passed, use it directly - this.element = target; - } else if (is.string(target)) { - // A CSS Selector is passed, fetch it from the DOM - this.element = document.querySelector(target); - } + if (is.element(target)) { + // An Element is passed, use it directly + this.element = target; + } else if (is.string(target)) { + // A CSS Selector is passed, fetch it from the DOM + this.element = document.querySelector(target); + } + + if (!is.element(this.element) || !is.empty(this.element.rangeTouch)) { + return; + } + + this.config = Object.assign({}, defaults, options); + this.init(); + } + + _createClass(RangeTouch, [{ + key: "init", + value: function init() { + // Bail if not a touch enabled device + if (!RangeTouch.enabled) { + return; + } // Add useful CSS - if (!is.element(this.element) || !is.empty(this.element.rangeTouch)) { - return; - } - this.config = Object.assign({}, defaults, options); + if (this.config.addCSS) { + // TODO: Restore original values on destroy + this.element.style.userSelect = 'none'; + this.element.style.webKitUserSelect = 'none'; + this.element.style.touchAction = 'manipulation'; + } - this.init(); + this.listeners(true); + this.element.rangeTouch = this; } + }, { + key: "destroy", + value: function destroy() { + // Bail if not a touch enabled device + if (!RangeTouch.enabled) { + return; + } - static get enabled() { - return 'ontouchstart' in document.documentElement; + this.listeners(false); + this.element.rangeTouch = null; } + }, { + key: "listeners", + value: function listeners(toggle) { + var _this = this; + var method = toggle ? 'addEventListener' : 'removeEventListener'; // Listen for events + + ['touchstart', 'touchmove', 'touchend'].forEach(function (type) { + _this.element[method](type, function (event) { + return _this.set(event); + }, false); + }); + } /** - * Setup multiple instances - * @param {String|Element|NodeList|Array} target - * @param {Object} options + * Get the value based on touch position + * @param {Event} event */ - static setup(target, options = {}) { - let targets = null; - - if (is.empty(target) || is.string(target)) { - targets = Array.from(document.querySelectorAll(is.string(target) ? target : 'input[type="range"]')); - } else if (is.element(target)) { - targets = [target]; - } else if (is.nodeList(target)) { - targets = Array.from(target); - } else if (is.array(target)) { - targets = target.filter(is.element); - } - if (is.empty(targets)) { - return null; - } + }, { + key: "get", + value: function get(event) { + if (!RangeTouch.enabled || !is.event(event)) { + return null; + } - const config = Object.assign({}, defaults, options); - - if (is.string(target) && config.watch) { - // Create an observer instance - const observer = new MutationObserver(mutations => { - Array.from(mutations).forEach(mutation => { - Array.from(mutation.addedNodes).forEach(node => { - if (!is.element(node) || !matches(node, target)) { - return; - } - - // eslint-disable-next-line no-unused-vars - const range = new RangeTouch(node, config); - }); - }); - }); + var input = event.target; + var touch = event.changedTouches[0]; + var min = parseFloat(input.getAttribute('min')) || 0; + var max = parseFloat(input.getAttribute('max')) || 100; + var step = parseFloat(input.getAttribute('step')) || 1; + var delta = max - min; // Calculate percentage - // Pass in the target node, as well as the observer options - observer.observe(document.body, { - childList: true, - subtree: true, - }); - } + var percent; + var clientRect = input.getBoundingClientRect(); + var thumbWidth = 100 / clientRect.width * (this.config.thumbWidth / 2) / 100; // Determine left percentage - return targets.map(t => new RangeTouch(t, options)); - } + percent = 100 / clientRect.width * (touch.clientX - clientRect.left); // Don't allow outside bounds - init() { - // Bail if not a touch enabled device - if (!RangeTouch.enabled) { - return; - } + if (percent < 0) { + percent = 0; + } else if (percent > 100) { + percent = 100; + } // Factor in the thumb offset - // Add useful CSS - if (this.config.addCSS) { - // TODO: Restore original values on destroy - this.element.style.userSelect = 'none'; - this.element.style.webKitUserSelect = 'none'; - this.element.style.touchAction = 'manipulation'; - } - this.listeners(true); + if (percent < 50) { + percent -= (100 - percent * 2) * thumbWidth; + } else if (percent > 50) { + percent += (percent - 50) * 2 * thumbWidth; + } // Find the closest step to the mouse position + - this.element.rangeTouch = this; + return min + round(delta * (percent / 100), step); } + /** + * Update range value based on position + * @param {Event} event + */ - destroy() { - // Bail if not a touch enabled device - if (!RangeTouch.enabled) { - return; - } + }, { + key: "set", + value: function set(event) { + if (!RangeTouch.enabled || !is.event(event) || event.target.disabled) { + return; + } // Prevent text highlight on iOS - this.listeners(false); - this.element.rangeTouch = null; - } + event.preventDefault(); // Set value - listeners(toggle) { - const method = toggle ? 'addEventListener' : 'removeEventListener'; + event.target.value = this.get(event); // Trigger event - // Listen for events - ['touchstart', 'touchmove', 'touchend'].forEach(type => { - this.element[method](type, event => this.set(event), false); - }); + trigger(event.target, event.type === 'touchend' ? 'change' : 'input'); } + }], [{ + key: "setup", /** - * Get the value based on touch position - * @param {Event} event + * Setup multiple instances + * @param {String|Element|NodeList|Array} target + * @param {Object} options */ - get(event) { - if (!RangeTouch.enabled || !is.event(event)) { - return null; - } + value: function setup(target) { + var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + var targets = null; - const input = event.target; - const touch = event.changedTouches[0]; - const min = parseFloat(input.getAttribute('min')) || 0; - const max = parseFloat(input.getAttribute('max')) || 100; - const step = parseFloat(input.getAttribute('step')) || 1; - const delta = max - min; - - // Calculate percentage - let percent; - const clientRect = input.getBoundingClientRect(); - const thumbWidth = ((100 / clientRect.width) * (this.config.thumbWidth / 2)) / 100; - - // Determine left percentage - percent = (100 / clientRect.width) * (touch.clientX - clientRect.left); - - // Don't allow outside bounds - if (percent < 0) { - percent = 0; - } else if (percent > 100) { - percent = 100; - } + if (is.empty(target) || is.string(target)) { + targets = Array.from(document.querySelectorAll(is.string(target) ? target : 'input[type="range"]')); + } else if (is.element(target)) { + targets = [target]; + } else if (is.nodeList(target)) { + targets = Array.from(target); + } else if (is.array(target)) { + targets = target.filter(is.element); + } - // Factor in the thumb offset - if (percent < 50) { - percent -= (100 - percent * 2) * thumbWidth; - } else if (percent > 50) { - percent += (percent - 50) * 2 * thumbWidth; - } + if (is.empty(targets)) { + return null; + } - // Find the closest step to the mouse position - return min + round(delta * (percent / 100), step); - } + var config = Object.assign({}, defaults, options); - /** - * Update range value based on position - * @param {Event} event - */ - set(event) { - if (!RangeTouch.enabled || !is.event(event) || event.target.disabled) { - return; - } + if (is.string(target) && config.watch) { + // Create an observer instance + var observer = new MutationObserver(function (mutations) { + Array.from(mutations).forEach(function (mutation) { + Array.from(mutation.addedNodes).forEach(function (node) { + if (!is.element(node) || !matches(node, target)) { + return; + } // eslint-disable-next-line no-unused-vars - // Prevent text highlight on iOS - event.preventDefault(); - // Set value - event.target.value = this.get(event); + var range = new RangeTouch(node, config); + }); + }); + }); // Pass in the target node, as well as the observer options + + observer.observe(document.body, { + childList: true, + subtree: true + }); + } - // Trigger event - trigger(event.target, event.type === 'touchend' ? 'change' : 'input'); + return targets.map(function (t) { + return new RangeTouch(t, options); + }); } - } + }, { + key: "enabled", + get: function get() { + return 'ontouchstart' in document.documentElement; + } + }]); + + return RangeTouch; + }(); // ========================================================================== // Type checking utils @@ -3031,8 +3073,8 @@ typeof navigator === "object" && (function (global, factory) { /** * Parse a string to a URL object - * @param {string} input - the URL to be parsed - * @param {boolean} safe - failsafe parsing + * @param {String} input - the URL to be parsed + * @param {Boolean} safe - failsafe parsing */ function parseUrl(input) { @@ -3479,7 +3521,7 @@ typeof navigator === "object" && (function (global, factory) { // Sprite (for icons) loadSprite: true, iconPrefix: 'plyr', - iconUrl: 'https://cdn.plyr.io/3.5.0/plyr.svg', + iconUrl: 'https://cdn.plyr.io/3.5.1/plyr.svg', // Blank video (used to prevent errors on source change) blankVideo: 'https://cdn.plyr.io/static/blank.mp4', // Quality default @@ -5182,295 +5224,273 @@ typeof navigator === "object" && (function (global, factory) { } var loadjs_umd = createCommonjsModule(function (module, exports) { - (function(root, factory) { - { - module.exports = factory(); - } - }(commonjsGlobal, function() { - /** - * Global dependencies. - * @global {Object} document - DOM - */ + (function (root, factory) { + { + module.exports = factory(); + } + })(commonjsGlobal, function () { + /** + * Global dependencies. + * @global {Object} document - DOM + */ + var devnull = function devnull() {}, + bundleIdCache = {}, + bundleResultCache = {}, + bundleCallbackQueue = {}; + /** + * Subscribe to bundle load event. + * @param {string[]} bundleIds - Bundle ids + * @param {Function} callbackFn - The callback function + */ - var devnull = function() {}, - bundleIdCache = {}, - bundleResultCache = {}, - bundleCallbackQueue = {}; + function subscribe(bundleIds, callbackFn) { + // listify + bundleIds = bundleIds.push ? bundleIds : [bundleIds]; + var depsNotFound = [], + i = bundleIds.length, + numWaiting = i, + fn, + bundleId, + r, + q; // define callback function - /** - * Subscribe to bundle load event. - * @param {string[]} bundleIds - Bundle ids - * @param {Function} callbackFn - The callback function - */ - function subscribe(bundleIds, callbackFn) { - // listify - bundleIds = bundleIds.push ? bundleIds : [bundleIds]; - - var depsNotFound = [], - i = bundleIds.length, - numWaiting = i, - fn, - bundleId, - r, - q; - - // define callback function - fn = function (bundleId, pathsNotFound) { - if (pathsNotFound.length) depsNotFound.push(bundleId); - - numWaiting--; - if (!numWaiting) callbackFn(depsNotFound); - }; + fn = function fn(bundleId, pathsNotFound) { + if (pathsNotFound.length) depsNotFound.push(bundleId); + numWaiting--; + if (!numWaiting) callbackFn(depsNotFound); + }; // register callback - // register callback - while (i--) { - bundleId = bundleIds[i]; - // execute callback if in result cache - r = bundleResultCache[bundleId]; - if (r) { - fn(bundleId, r); - continue; - } + while (i--) { + bundleId = bundleIds[i]; // execute callback if in result cache - // add to callback queue - q = bundleCallbackQueue[bundleId] = bundleCallbackQueue[bundleId] || []; - q.push(fn); - } - } + r = bundleResultCache[bundleId]; + if (r) { + fn(bundleId, r); + continue; + } // add to callback queue - /** - * Publish bundle load event. - * @param {string} bundleId - Bundle id - * @param {string[]} pathsNotFound - List of files not found - */ - function publish(bundleId, pathsNotFound) { - // exit if id isn't defined - if (!bundleId) return; - var q = bundleCallbackQueue[bundleId]; + q = bundleCallbackQueue[bundleId] = bundleCallbackQueue[bundleId] || []; + q.push(fn); + } + } + /** + * Publish bundle load event. + * @param {string} bundleId - Bundle id + * @param {string[]} pathsNotFound - List of files not found + */ - // cache result - bundleResultCache[bundleId] = pathsNotFound; - // exit if queue is empty - if (!q) return; + function publish(bundleId, pathsNotFound) { + // exit if id isn't defined + if (!bundleId) return; + var q = bundleCallbackQueue[bundleId]; // cache result - // empty callback queue - while (q.length) { - q[0](bundleId, pathsNotFound); - q.splice(0, 1); - } - } + bundleResultCache[bundleId] = pathsNotFound; // exit if queue is empty + if (!q) return; // empty callback queue - /** - * Execute callbacks. - * @param {Object or Function} args - The callback args - * @param {string[]} depsNotFound - List of dependencies not found - */ - function executeCallbacks(args, depsNotFound) { - // accept function as argument - if (args.call) args = {success: args}; + while (q.length) { + q[0](bundleId, pathsNotFound); + q.splice(0, 1); + } + } + /** + * Execute callbacks. + * @param {Object or Function} args - The callback args + * @param {string[]} depsNotFound - List of dependencies not found + */ - // success and error callbacks - if (depsNotFound.length) (args.error || devnull)(depsNotFound); - else (args.success || devnull)(args); - } + function executeCallbacks(args, depsNotFound) { + // accept function as argument + if (args.call) args = { + success: args + }; // success and error callbacks - /** - * Load individual file. - * @param {string} path - The file path - * @param {Function} callbackFn - The callback function - */ - function loadFile(path, callbackFn, args, numTries) { - var doc = document, - async = args.async, - maxTries = (args.numRetries || 0) + 1, - beforeCallbackFn = args.before || devnull, - pathStripped = path.replace(/^(css|img)!/, ''), - isCss, - e; - - numTries = numTries || 0; - - if (/(^css!|\.css$)/.test(path)) { - isCss = true; - - // css - e = doc.createElement('link'); - e.rel = 'stylesheet'; - e.href = pathStripped; //.replace(/^css!/, ''); // remove "css!" prefix - } else if (/(^img!|\.(png|gif|jpg|svg)$)/.test(path)) { - // image - e = doc.createElement('img'); - e.src = pathStripped; - } else { - // javascript - e = doc.createElement('script'); - e.src = path; - e.async = async === undefined ? true : async; - } + if (depsNotFound.length) (args.error || devnull)(depsNotFound);else (args.success || devnull)(args); + } + /** + * Load individual file. + * @param {string} path - The file path + * @param {Function} callbackFn - The callback function + */ - e.onload = e.onerror = e.onbeforeload = function (ev) { - var result = ev.type[0]; - // Note: The following code isolates IE using `hideFocus` and treats empty - // stylesheets as failures to get around lack of onerror support - if (isCss && 'hideFocus' in e) { - try { - if (!e.sheet.cssText.length) result = 'e'; - } catch (x) { - // sheets objects created from load errors don't allow access to - // `cssText` (unless error is Code:18 SecurityError) - if (x.code != 18) result = 'e'; + function loadFile(path, callbackFn, args, numTries) { + var doc = document, + async = args.async, + maxTries = (args.numRetries || 0) + 1, + beforeCallbackFn = args.before || devnull, + pathStripped = path.replace(/^(css|img)!/, ''), + isCss, + e; + numTries = numTries || 0; + + if (/(^css!|\.css$)/.test(path)) { + isCss = true; // css + + e = doc.createElement('link'); + e.rel = 'stylesheet'; + e.href = pathStripped; //.replace(/^css!/, ''); // remove "css!" prefix + } else if (/(^img!|\.(png|gif|jpg|svg)$)/.test(path)) { + // image + e = doc.createElement('img'); + e.src = pathStripped; + } else { + // javascript + e = doc.createElement('script'); + e.src = path; + e.async = async === undefined ? true : async; } - } - // handle retries in case of load failure - if (result == 'e') { - // increment counter - numTries += 1; + e.onload = e.onerror = e.onbeforeload = function (ev) { + var result = ev.type[0]; // Note: The following code isolates IE using `hideFocus` and treats empty + // stylesheets as failures to get around lack of onerror support - // exit function and try again - if (numTries < maxTries) { - return loadFile(path, callbackFn, args, numTries); - } - } + if (isCss && 'hideFocus' in e) { + try { + if (!e.sheet.cssText.length) result = 'e'; + } catch (x) { + // sheets objects created from load errors don't allow access to + // `cssText` (unless error is Code:18 SecurityError) + if (x.code != 18) result = 'e'; + } + } // handle retries in case of load failure - // execute callback - callbackFn(path, result, ev.defaultPrevented); - }; - // add to document (unless callback returns `false`) - if (beforeCallbackFn(path, e) !== false) doc.head.appendChild(e); - } + if (result == 'e') { + // increment counter + numTries += 1; // exit function and try again + if (numTries < maxTries) { + return loadFile(path, callbackFn, args, numTries); + } + } // execute callback - /** - * Load multiple files. - * @param {string[]} paths - The file paths - * @param {Function} callbackFn - The callback function - */ - function loadFiles(paths, callbackFn, args) { - // listify paths - paths = paths.push ? paths : [paths]; - - var numWaiting = paths.length, - x = numWaiting, - pathsNotFound = [], - fn, - i; - - // define callback function - fn = function(path, result, defaultPrevented) { - // handle error - if (result == 'e') pathsNotFound.push(path); - - // handle beforeload event. If defaultPrevented then that means the load - // will be blocked (ex. Ghostery/ABP on Safari) - if (result == 'b') { - if (defaultPrevented) pathsNotFound.push(path); - else return; - } - - numWaiting--; - if (!numWaiting) callbackFn(pathsNotFound); - }; - // load scripts - for (i=0; i < x; i++) loadFile(paths[i], fn, args); - } + callbackFn(path, result, ev.defaultPrevented); + }; // add to document (unless callback returns `false`) - /** - * Initiate script load and register bundle. - * @param {(string|string[])} paths - The file paths - * @param {(string|Function)} [arg1] - The bundleId or success callback - * @param {Function} [arg2] - The success or error callback - * @param {Function} [arg3] - The error callback - */ - function loadjs(paths, arg1, arg2) { - var bundleId, - args; + if (beforeCallbackFn(path, e) !== false) doc.head.appendChild(e); + } + /** + * Load multiple files. + * @param {string[]} paths - The file paths + * @param {Function} callbackFn - The callback function + */ - // bundleId (if string) - if (arg1 && arg1.trim) bundleId = arg1; - // args (default is {}) - args = (bundleId ? arg2 : arg1) || {}; + function loadFiles(paths, callbackFn, args) { + // listify paths + paths = paths.push ? paths : [paths]; + var numWaiting = paths.length, + x = numWaiting, + pathsNotFound = [], + fn, + i; // define callback function - // throw error if bundle is already defined - if (bundleId) { - if (bundleId in bundleIdCache) { - throw "LoadJS"; - } else { - bundleIdCache[bundleId] = true; + fn = function fn(path, result, defaultPrevented) { + // handle error + if (result == 'e') pathsNotFound.push(path); // handle beforeload event. If defaultPrevented then that means the load + // will be blocked (ex. Ghostery/ABP on Safari) + + if (result == 'b') { + if (defaultPrevented) pathsNotFound.push(path);else return; + } + + numWaiting--; + if (!numWaiting) callbackFn(pathsNotFound); + }; // load scripts + + + for (i = 0; i < x; i++) { + loadFile(paths[i], fn, args); + } } - } + /** + * Initiate script load and register bundle. + * @param {(string|string[])} paths - The file paths + * @param {(string|Function)} [arg1] - The bundleId or success callback + * @param {Function} [arg2] - The success or error callback + * @param {Function} [arg3] - The error callback + */ - // load scripts - loadFiles(paths, function (pathsNotFound) { - // execute callbacks - executeCallbacks(args, pathsNotFound); - // publish bundle load event - publish(bundleId, pathsNotFound); - }, args); - } + function loadjs(paths, arg1, arg2) { + var bundleId, args; // bundleId (if string) + if (arg1 && arg1.trim) bundleId = arg1; // args (default is {}) - /** - * Execute callbacks when dependencies have been satisfied. - * @param {(string|string[])} deps - List of bundle ids - * @param {Object} args - success/error arguments - */ - loadjs.ready = function ready(deps, args) { - // subscribe to bundle load event - subscribe(deps, function (depsNotFound) { - // execute callbacks - executeCallbacks(args, depsNotFound); - }); + args = (bundleId ? arg2 : arg1) || {}; // throw error if bundle is already defined - return loadjs; - }; + if (bundleId) { + if (bundleId in bundleIdCache) { + throw "LoadJS"; + } else { + bundleIdCache[bundleId] = true; + } + } // load scripts - /** - * Manually satisfy bundle dependencies. - * @param {string} bundleId - The bundle id - */ - loadjs.done = function done(bundleId) { - publish(bundleId, []); - }; + loadFiles(paths, function (pathsNotFound) { + // execute callbacks + executeCallbacks(args, pathsNotFound); // publish bundle load event + publish(bundleId, pathsNotFound); + }, args); + } + /** + * Execute callbacks when dependencies have been satisfied. + * @param {(string|string[])} deps - List of bundle ids + * @param {Object} args - success/error arguments + */ - /** - * Reset loadjs dependencies statuses - */ - loadjs.reset = function reset() { - bundleIdCache = {}; - bundleResultCache = {}; - bundleCallbackQueue = {}; - }; + + loadjs.ready = function ready(deps, args) { + // subscribe to bundle load event + subscribe(deps, function (depsNotFound) { + // execute callbacks + executeCallbacks(args, depsNotFound); + }); + return loadjs; + }; + /** + * Manually satisfy bundle dependencies. + * @param {string} bundleId - The bundle id + */ - /** - * Determine if bundle has already been defined - * @param String} bundleId - The bundle id - */ - loadjs.isDefined = function isDefined(bundleId) { - return bundleId in bundleIdCache; - }; + loadjs.done = function done(bundleId) { + publish(bundleId, []); + }; + /** + * Reset loadjs dependencies statuses + */ - // export - return loadjs; + loadjs.reset = function reset() { + bundleIdCache = {}; + bundleResultCache = {}; + bundleCallbackQueue = {}; + }; + /** + * Determine if bundle has already been defined + * @param String} bundleId - The bundle id + */ + + + loadjs.isDefined = function isDefined(bundleId) { + return bundleId in bundleIdCache; + }; // export - })); + + return loadjs; + }); }); // ========================================================================== @@ -6267,7 +6287,7 @@ typeof navigator === "object" && (function (global, factory) { function () { /** * Ads constructor. - * @param {object} player + * @param {Object} player * @return {Ads} */ function Ads(player) { @@ -6414,7 +6434,7 @@ typeof navigator === "object" && (function (global, factory) { } /** * Update the ad countdown - * @param {boolean} start + * @param {Boolean} start */ }, { @@ -6782,7 +6802,7 @@ typeof navigator === "object" && (function (global, factory) { } /** * Handles callbacks after an ad event was invoked - * @param {string} event - Event type + * @param {String} event - Event type */ }, { @@ -6806,8 +6826,8 @@ typeof navigator === "object" && (function (global, factory) { } /** * Add event listeners - * @param {string} event - Event type - * @param {function} callback - Callback for when event occurs + * @param {String} event - Event type + * @param {Function} callback - Callback for when event occurs * @return {Ads} */ @@ -6826,8 +6846,8 @@ typeof navigator === "object" && (function (global, factory) { * The advertisement has 12 seconds to get its things together. We stop this timer when the * advertisement is playing, or when a user action is required to start, then we clear the * timer on ad ready - * @param {number} time - * @param {string} from + * @param {Number} time + * @param {String} from */ }, { @@ -6844,7 +6864,7 @@ typeof navigator === "object" && (function (global, factory) { } /** * Clear our safety timer(s) - * @param {string} from + * @param {String} from */ }, { @@ -8004,7 +8024,7 @@ typeof navigator === "object" && (function (global, factory) { /** * Toggle playback based on current status - * @param {boolean} input + * @param {Boolean} input */ value: function togglePlay(input) { // Toggle based on current state if nothing passed @@ -8041,7 +8061,7 @@ typeof navigator === "object" && (function (global, factory) { } /** * Rewind - * @param {number} seekTime - how far to rewind in seconds. Defaults to the config.seekTime + * @param {Number} seekTime - how far to rewind in seconds. Defaults to the config.seekTime */ }, { @@ -8051,7 +8071,7 @@ typeof navigator === "object" && (function (global, factory) { } /** * Fast forward - * @param {number} seekTime - how far to fast forward in seconds. Defaults to the config.seekTime + * @param {Number} seekTime - how far to fast forward in seconds. Defaults to the config.seekTime */ }, { @@ -8061,7 +8081,7 @@ typeof navigator === "object" && (function (global, factory) { } /** * Seek to a time - * @param {number} input - where to seek to in seconds. Defaults to 0 (the start) + * @param {Number} input - where to seek to in seconds. Defaults to 0 (the start) */ }, { @@ -8069,7 +8089,7 @@ typeof navigator === "object" && (function (global, factory) { /** * Increase volume - * @param {boolean} step - How much to decrease by (between 0 and 1) + * @param {Boolean} step - How much to decrease by (between 0 and 1) */ value: function increaseVolume(step) { var volume = this.media.muted ? 0 : this.volume; @@ -8077,7 +8097,7 @@ typeof navigator === "object" && (function (global, factory) { } /** * Decrease volume - * @param {boolean} step - How much to decrease by (between 0 and 1) + * @param {Boolean} step - How much to decrease by (between 0 and 1) */ }, { @@ -8087,7 +8107,7 @@ typeof navigator === "object" && (function (global, factory) { } /** * Set muted state - * @param {boolean} mute + * @param {Boolean} mute */ }, { @@ -8095,14 +8115,14 @@ typeof navigator === "object" && (function (global, factory) { /** * Toggle captions - * @param {boolean} input - Whether to enable captions + * @param {Boolean} input - Whether to enable captions */ value: function toggleCaptions(input) { captions.toggle.call(this, input, false); } /** * Set the caption track by index - * @param {number} - Caption index + * @param {Number} - Caption index */ }, { @@ -8120,7 +8140,7 @@ typeof navigator === "object" && (function (global, factory) { } /** * Toggle the player controls - * @param {boolean} [toggle] - Whether to show the controls + * @param {Boolean} [toggle] - Whether to show the controls */ }, { @@ -8152,8 +8172,8 @@ typeof navigator === "object" && (function (global, factory) { } /** * Add event listeners - * @param {string} event - Event type - * @param {function} callback - Callback for when event occurs + * @param {String} event - Event type + * @param {Function} callback - Callback for when event occurs */ }, { @@ -8163,8 +8183,8 @@ typeof navigator === "object" && (function (global, factory) { } /** * Add event listeners once - * @param {string} event - Event type - * @param {function} callback - Callback for when event occurs + * @param {String} event - Event type + * @param {Function} callback - Callback for when event occurs */ }, { @@ -8174,8 +8194,8 @@ typeof navigator === "object" && (function (global, factory) { } /** * Remove event listeners - * @param {string} event - Event type - * @param {function} callback - Callback for when event occurs + * @param {String} event - Event type + * @param {Function} callback - Callback for when event occurs */ }, { @@ -8187,8 +8207,8 @@ typeof navigator === "object" && (function (global, factory) { * Destroy an instance * Event listeners are removed when elements are removed * http://stackoverflow.com/questions/12528049/if-a-dom-element-is-removed-are-its-listeners-also-removed-from-memory - * @param {function} callback - Callback for when destroy is complete - * @param {boolean} soft - Whether it's a soft destroy (for source changes etc) + * @param {Function} callback - Callback for when destroy is complete + * @param {Boolean} soft - Whether it's a soft destroy (for source changes etc) */ }, { @@ -8282,7 +8302,7 @@ typeof navigator === "object" && (function (global, factory) { } /** * Check for support for a mime type (HTML5 only) - * @param {string} type - Mime type + * @param {String} type - Mime type */ }, { @@ -8292,9 +8312,9 @@ typeof navigator === "object" && (function (global, factory) { } /** * Check for support - * @param {string} type - Player type (audio/video) - * @param {string} provider - Provider (html5/youtube/vimeo) - * @param {bool} inline - Where player has `playsinline` sttribute + * @param {String} type - Player type (audio/video) + * @param {String} provider - Provider (html5/youtube/vimeo) + * @param {Boolean} inline - Where player has `playsinline` sttribute */ }, { @@ -8429,7 +8449,7 @@ typeof navigator === "object" && (function (global, factory) { } /** * Set the player volume - * @param {number} value - must be between 0 and 1. Defaults to the value from local storage and config.volume if not set in storage + * @param {Number} value - must be between 0 and 1. Defaults to the value from local storage and config.volume if not set in storage */ }, { @@ -8526,7 +8546,7 @@ typeof navigator === "object" && (function (global, factory) { } /** * Set playback speed - * @param {number} speed - the speed of playback (0.5-2.0) + * @param {Number} speed - the speed of playback (0.5-2.0) */ }, { @@ -8575,7 +8595,7 @@ typeof navigator === "object" && (function (global, factory) { /** * Set playback quality * Currently HTML5 & YouTube only - * @param {number} input - Quality level + * @param {Number} input - Quality level */ }, { @@ -8620,7 +8640,7 @@ typeof navigator === "object" && (function (global, factory) { /** * Toggle loop * TODO: Finish fancy new logic. Set the indicator on load as user may pass loop as config - * @param {boolean} input - Whether to loop or not + * @param {Boolean} input - Whether to loop or not */ }, { @@ -8676,7 +8696,7 @@ typeof navigator === "object" && (function (global, factory) { } /** * Set new media source - * @param {object} input - The new source object (see docs) + * @param {Object} input - The new source object (see docs) */ }, { @@ -8703,7 +8723,7 @@ typeof navigator === "object" && (function (global, factory) { } /** * Set the poster image for a video - * @param {input} - the URL for the new poster image + * @param {String} input - the URL for the new poster image */ }, { @@ -8729,7 +8749,7 @@ typeof navigator === "object" && (function (global, factory) { } /** * Set the autoplay state - * @param {boolean} input - Whether to autoplay or not + * @param {Boolean} input - Whether to autoplay or not */ }, { @@ -8763,7 +8783,7 @@ typeof navigator === "object" && (function (global, factory) { /** * Set the wanted language for captions * Since tracks can be added later it won't update the actual caption track until there is a matching track - * @param {string} - Two character ISO language code (e.g. EN, FR, PT, etc) + * @param {String} - Two character ISO language code (e.g. EN, FR, PT, etc) */ }, { @@ -8833,8 +8853,8 @@ typeof navigator === "object" && (function (global, factory) { } /** * Load an SVG sprite into the page - * @param {string} url - URL for the SVG sprite - * @param {string} [id] - Unique ID + * @param {String} url - URL for the SVG sprite + * @param {String} [id] - Unique ID */ }, { @@ -8845,7 +8865,7 @@ typeof navigator === "object" && (function (global, factory) { /** * Setup multiple instances * @param {*} selector - * @param {object} options + * @param {Object} options */ }, { |