From fac134dd955fe1a264a68897cd49d06a5afd9750 Mon Sep 17 00:00:00 2001 From: Sam Potts Date: Fri, 28 Sep 2018 00:42:42 +1000 Subject: Added download button --- src/js/config/defaults.js | 5 ++ src/js/config/types.js | 2 +- src/js/controls.js | 139 ++++++++++++++++++++++++++++++---------------- src/js/listeners.js | 19 ++++++- src/js/plugins/vimeo.js | 3 +- 5 files changed, 116 insertions(+), 52 deletions(-) (limited to 'src/js') diff --git a/src/js/config/defaults.js b/src/js/config/defaults.js index e6e2d7c1..5e2fc4a9 100644 --- a/src/js/config/defaults.js +++ b/src/js/config/defaults.js @@ -133,6 +133,7 @@ const defaults = { 'settings', 'pip', 'airplay', + 'download', 'fullscreen', ], settings: ['captions', 'quality', 'speed'], @@ -155,6 +156,7 @@ const defaults = { unmute: 'Unmute', enableCaptions: 'Enable captions', disableCaptions: 'Disable captions', + download: 'Download', enterFullscreen: 'Enter fullscreen', exitFullscreen: 'Exit fullscreen', frameTitle: 'Player for {title}', @@ -210,6 +212,7 @@ const defaults = { mute: null, volume: null, captions: null, + download: null, fullscreen: null, pip: null, airplay: null, @@ -245,6 +248,7 @@ const defaults = { 'cuechange', // Custom events + 'download', 'enterfullscreen', 'exitfullscreen', 'captionsenabled', @@ -290,6 +294,7 @@ const defaults = { fastForward: '[data-plyr="fast-forward"]', mute: '[data-plyr="mute"]', captions: '[data-plyr="captions"]', + download: '[data-plyr="download"]', fullscreen: '[data-plyr="fullscreen"]', pip: '[data-plyr="pip"]', airplay: '[data-plyr="airplay"]', diff --git a/src/js/config/types.js b/src/js/config/types.js index 13303573..c9d50937 100644 --- a/src/js/config/types.js +++ b/src/js/config/types.js @@ -15,7 +15,7 @@ export const types = { /** * Get provider by URL - * @param {string} url + * @param {String} url */ export function getProviderByUrl(url) { // YouTube diff --git a/src/js/controls.js b/src/js/controls.js index 661ceb32..785f100d 100644 --- a/src/js/controls.js +++ b/src/js/controls.js @@ -122,17 +122,13 @@ const controls = { }, // Create hidden text label - createLabel(type, attr = {}) { - // Skip i18n for abbreviations and brand names - const universals = { - pip: 'PIP', - airplay: 'AirPlay', - }; - const text = universals[type] || i18n.get(type, this.config); + createLabel(key, attr = {}) { + const text = i18n.get(key, this.config); const attributes = Object.assign({}, attr, { class: [attr.class, this.config.classNames.hidden].filter(Boolean).join(' '), }); + return createElement('span', attributes, text); }, @@ -161,21 +157,32 @@ const controls = { // Create a