UNPKG

@ezuikit/theme-plugin-volume

Version:

volume

24 lines (23 loc) 10.9 kB
/* * * @ezuikit/theme-plugin-volume v0.1.0 * Copyright (c) 2024-3-23 Ezviz-OpenBiz * Released under MIT the License. * */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).ThemePluginVolume=t()}(this,(function(){"use strict"; /* * * @ezuikit/utils-dom v1.0.1-alpha.1 * Copyright (c) 2024-3-23 Ezviz-OpenBiz * Released under MIT the License. * */var e="ezui";function t(e){for(var t=arguments.length,o=new Array(t>1?t-1:0),n=1;n<t;n++)o[n-1]=arguments[n];var i;e&&(o=o.filter((function(e){return e&&!!e.replace(/ /g,"")})),(i=e.classList).add.apply(i,[].concat(o)))} /* * * @ezuikit/icons v0.1.0 * Copyright (c) 2024-3-23 Ezviz-OpenBiz * Released under MIT the License. * */ function o(o){var n;const i=`${e}-icon`,r=document.createElement("span");return r.className="",t(r,`${i}`,`${i}-${o.name}`,null!==(n=null==o?void 0:o.className)&&void 0!==n?n:""),r.setAttribute("role","img"),r.innerHTML=o.svg,r}!function(e,t){void 0===t&&(t={});var o=t.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===o&&n.firstChild?n.insertBefore(i,n.firstChild):n.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}(".ezui-icon{align-items:center;color:inherit;display:inline-flex;font-style:normal;line-height:0;text-align:center;text-rendering:optimizeLegibility;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.ezui-icon svg{display:inline-block}");!function(e,t){void 0===t&&(t={});var o=t.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===o&&n.firstChild?n.insertBefore(i,n.firstChild):n.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}(":root{--font-size:14px;--color:#fff;--background-color:#000;--active-color:#1890ff;--botton-color:var(--color);--botton-border-color:var(--color);--footer-height:48px;--footer-icon-size:27px;--footer-color:--color;--footer-background-color:var(--background-color,#000);--footer-active-color:var(--active-color,#1890ff);--header-height:var(--footer-height,48px);--header-icon-size:27px;--header-color:var(--footer-color);--header-background-color:var(-footer-bg-color,#000);--header-active-color:var(--footer-active-color,#1890ff);--date-picker-header-height:34px;--date-picker-color:#595959;--date-picker-primary-color:#1890ff;--date-picker-font-size:14px;--date-picker-border-color:rgba(5,5,5,.06);--date-picker-disable-border-color:rgba(0,0,0,.2);--data-picker-scrollbar-width:8px;--data-picker-border-radius:2px}.ezui-footer{background-color:#000;bottom:0;box-sizing:border-box;color:var(--ezui-footer-color,#fff);display:flex;flex-direction:column;height:var(--ezui-footer-height,48px);position:relative;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:100%}.ezui-footer-top{background-color:var(--ezui-footer-background-color,rgba(0,0,0,.5));bottom:var(--ezui-footer-height,48px);display:flex;flex-direction:row;justify-content:space-between;left:0;opacity:1;pointer-events:all;position:absolute;right:0;transition:opacity .3s ease;z-index:999}.ezui-footer-top-hidden{opacity:0;pointer-events:none}.ezui-footer-bottom .ezui-footer-item,.ezui-footer-left>.ezui-footer-item,.ezui-footer-left>span,.ezui-footer-right>.ezui-footer-item,.ezui-footer-right>span{align-items:center;cursor:pointer;display:inline-flex;font-size:var(--ezui-footer-icon-size,27px);justify-content:center;min-height:var(--ezui-footer-height,48px);width:var(--ezui-footer-height,48px)}.ezui-footer-left,.ezui-footer-right{box-sizing:border-box;display:flex;padding-left:12px;padding-right:12px}.ezui-footer-bottom{background-color:#000;color:#fff;display:flex;flex-direction:row;height:var(--ezui-footer-height,48px);justify-content:space-between}.ezui-footer-bottom .ezui-footer-bottom-item{align-items:center;cursor:pointer;display:inline-flex;font-size:20px;justify-content:center;min-height:var(--ezui-footer-height,48px);width:var(--ezui-footer-height,48px)}.ezui-footer-bottom-left{flex:1 1 auto}.ezui-footer-bottom-right{align-items:center;display:inline-flex;flex-direction:row;font-size:22px;justify-content:flex-end}.ezui-footer-bottom-right .ezui-icon{align-items:center;box-sizing:border-box;cursor:pointer;display:inline-flex;flex-wrap:nowrap;justify-content:center;padding-left:9px;padding-right:9px}.ezui-footer-mobile-extend{background-color:#fff;color:#000;display:flex;flex-direction:column}.ezui-footer-mobile-extend-type{display:flex;justify-content:space-between}.ezui-footer-mobile-extend-type .ezui-icon{color:#000}.ezui-theme-mobile .ezui-footer-top{bottom:0}");const n=`${e}-footer`,i=`${n}-left`;var r="object"==typeof global&&global&&global.Object===Object&&global,l="object"==typeof self&&self&&self.Object===Object&&self,a=r||l||Function("return this")(),c=a.Symbol,f=Object.prototype,u=f.hasOwnProperty,d=f.toString,s=c?c.toStringTag:void 0;var p=Object.prototype.toString;var h="[object Null]",v="[object Undefined]",g=c?c.toStringTag:void 0;function m(e){return null==e?void 0===e?v:h:g&&g in Object(e)?function(e){var t=u.call(e,s),o=e[s];try{e[s]=void 0;var n=!0}catch(e){}var i=d.call(e);return n&&(t?e[s]=o:delete e[s]),i}(e):function(e){return p.call(e)}(e)}var b="[object Symbol]";var y=/\s/;var x=/^\s+/;function z(e){return e?e.slice(0,function(e){for(var t=e.length;t--&&y.test(e.charAt(t)););return t}(e)+1).replace(x,""):e}function C(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}var w=NaN,T=/^[-+]0x[0-9a-f]+$/i,k=/^0b[01]+$/i,j=/^0o[0-7]+$/i,$=parseInt;function L(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return null!=e&&"object"==typeof e}(e)&&m(e)==b}(e))return w;if(C(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=C(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=z(e);var o=k.test(e);return o||j.test(e)?$(e.slice(2),o?2:8):T.test(e)?w:+e}var E=function(){return a.Date.now()},M="Expected a function",S=Math.max,N=Math.min;function O(e,t,o){var n,i,r,l,a,c,f=0,u=!1,d=!1,s=!0;if("function"!=typeof e)throw new TypeError(M);function p(t){var o=n,r=i;return n=i=void 0,f=t,l=e.apply(r,o)}function h(e){var o=e-c;return void 0===c||o>=t||o<0||d&&e-f>=r}function v(){var e=E();if(h(e))return g(e);a=setTimeout(v,function(e){var o=t-(e-c);return d?N(o,r-(e-f)):o}(e))}function g(e){return a=void 0,s&&n?p(e):(n=i=void 0,l)}function m(){var e=E(),o=h(e);if(n=arguments,i=this,c=e,o){if(void 0===a)return function(e){return f=e,a=setTimeout(v,t),u?p(e):l}(c);if(d)return clearTimeout(a),a=setTimeout(v,t),p(c)}return void 0===a&&(a=setTimeout(v,t)),l}return t=L(t)||0,C(o)&&(u=!!o.leading,r=(d="maxWait"in o)?S(L(o.maxWait)||0,t):r,s="trailing"in o?!!o.trailing:s),m.cancel=function(){void 0!==a&&clearTimeout(a),f=0,n=c=i=a=void 0},m.flush=function(){return void 0===a?l:g(E())},m}var A="Expected a function";return function(r){return function(l){const a=l;let c=!(!1!==a.options.audio);const f=(e=>{const t="sound-mute";return o({name:t,svg:null!=e?e:`<svg\n viewBox="1 1 19 19"\n focusable="false"\n data-icon="${t}"\n width="1em"\n height="1em"\n fill="currentColor"\n aria-hidden="true"\n >\n <path d="M8.5,4.2c0.8-0.7,2.1-0.2,2.2,0.9l0,0.1v10c0,1.1-1.2,1.7-2.1,1.1l-0.1-0.1l-3.3-2.8C5,13.2,5,12.9,5.1,12.7 c0.2-0.2,0.4-0.2,0.6-0.1l0.1,0.1l3.3,2.8c0.2,0.2,0.5,0.1,0.5-0.2l0-0.1v-10c0-0.3-0.3-0.4-0.5-0.3L9.2,5L5.9,7.8 C5.6,7.9,5.3,7.9,5.1,7.7C5,7.5,5,7.3,5.1,7.1L5.2,7L8.5,4.2z"></path>\n <path d="M5.5,6.9C5.8,6.9,6,7.1,6,7.4c0,0.2-0.2,0.4-0.4,0.5l-0.1,0h-2C3.4,7.9,3.3,8,3.2,8.2l0,0.1v4 c0,0.2,0.1,0.3,0.3,0.3l0.1,0h2C5.8,12.5,6,12.7,6,13c0,0.2-0.2,0.4-0.4,0.5l-0.1,0h-2c-0.7,0-1.3-0.5-1.3-1.2l0-0.1v-4 c0-0.7,0.5-1.3,1.2-1.3l0.1,0H5.5z"></path>\n <path d="M17.4,7.9c0.2-0.2,0.5-0.2,0.7,0c0.2,0.2,0.2,0.4,0.1,0.6l-0.1,0.1l-3.8,3.8c-0.2,0.2-0.5,0.2-0.7,0 c-0.2-0.2-0.2-0.4-0.1-0.6l0.1-0.1L17.4,7.9z"></path>\n <path d="M13.7,7.9c0.2-0.2,0.4-0.2,0.6-0.1l0.1,0.1l3.8,3.8c0.2,0.2,0.2,0.5,0,0.7c-0.2,0.2-0.4,0.2-0.6,0.1l-0.1-0.1 l-3.7-3.8C13.5,8.4,13.5,8.1,13.7,7.9z"></path>\n </svg>`})})(null==r?void 0:r.icon),u=(e=>{const t="sound";return o({name:t,svg:null!=e?e:`<svg\n viewBox="1 1 19 19"\n focusable="false"\n data-icon="${t}"\n width="1em"\n height="1em"\n fill="currentColor"\n aria-hidden="true"\n >\n <path d="M13.2,7.1c0.1-0.2,0.5-0.3,0.7-0.2c1.1,0.7,1.9,2.2,1.9,3.7c0,1.6-0.7,3-1.9,3.7c-0.2,0.1-0.5,0.1-0.7-0.2c-0.1-0.2-0.1-0.5,0.2-0.7c0.8-0.5,1.4-1.6,1.4-2.9c0-1.3-0.6-2.4-1.4-2.9C13.1,7.6,13,7.3,13.2,7.1z"\n />\n <path\n d="M15.7,4.5c0.2-0.2,0.5-0.2,0.7-0.1C18,5.8,19,8.2,19,10.7c0,2.5-1,4.8-2.7,6.3\n c-0.2,0.2-0.5,0.2-0.7-0.1c-0.2-0.2-0.2-0.5,0.1-0.7c1.4-1.2,2.3-3.3,2.3-5.5c0-2.2-0.9-4.3-2.3-5.5C15.5,5,15.5,4.7,15.7,4.5z"\n />\n <path\n d="M8.5,4.7c0.8-0.7,2.1-0.2,2.2,0.9l0,0.1v10c0,1.1-1.2,1.7-2.1,1.1l-0.1-0.1l-3.3-2.8\n C5,13.7,5,13.4,5.1,13.2c0.2-0.2,0.4-0.2,0.6-0.1l0.1,0.1l3.3,2.8c0.2,0.2,0.5,0.1,0.5-0.2l0-0.1v-10c0-0.3-0.3-0.4-0.5-0.3l-0.1,0\n L5.9,8.3C5.6,8.4,5.3,8.4,5.1,8.2C5,8,5,7.7,5.1,7.6l0.1-0.1L8.5,4.7z"\n />\n <path\n d="M5.5,7.4C5.8,7.4,6,7.6,6,7.9c0,0.2-0.2,0.4-0.4,0.5l-0.1,0h-2c-0.2,0-0.3,0.1-0.3,0.3l0,0.1v4\n c0,0.2,0.1,0.3,0.3,0.3l0.1,0h2C5.8,13,6,13.2,6,13.5c0,0.2-0.2,0.4-0.4,0.5l-0.1,0h-2c-0.7,0-1.3-0.5-1.3-1.2l0-0.1v-4\n c0-0.7,0.5-1.3,1.2-1.3l0.1,0H5.5z"\n />\n </svg>`})})(null==r?void 0:r.icon);t(u,`${e}-active`);const d=a.$container.querySelector(`.${i}`),s=document.createElement("div");function p(e){e?(s.innerHTML="",s.appendChild(f)):(s.innerHTML="",s.appendChild(u))}return t(s,`${n}-item`,`${e}-disable`),s.appendChild(f),s.addEventListener("click",function(e,t,o){var n=!0,i=!0;if("function"!=typeof e)throw new TypeError(A);return C(o)&&(n="leading"in o?!!o.leading:n,i="trailing"in o?!!o.trailing:i),O(e,t,{leading:n,maxWait:t,trailing:i})}((()=>{s.classList.contains(`${e}-disable`)||(c?a.player.setVolume(.8):a.player.setVolume(0),c=!c)}),100)),d&&d.appendChild(s),a.event.on("volumechange",(e=>{p(!(e.data>0))})),a.event.on("EVENT_CALLBACK",(t=>{"appearFirstFrameCallback"===t.data.type&&(!function(e){for(var t=arguments.length,o=new Array(t>1?t-1:0),n=1;n<t;n++)o[n-1]=arguments[n];var i;e&&(i=e.classList).remove.apply(i,[].concat(o))}(s,`${e}-disable`),p(c),c?a.player.setVolume(0):a.player.setVolume(.8))})),["urlChange","pause","stop","talk"].forEach((o=>{a.event.on(o,(()=>{s.innerHTML="",s.appendChild(f),t(s,`${e}-disable`)}))})),s}}}));