ovenplayer 0.10.46 → 0.10.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,38 +1,44 @@
1
- /**
2
- * Created by hoho on 2018. 8. 1..
3
- */
4
- import OvenTemplate from 'view/engine/OvenTemplate';
5
- import LA$ from 'utils/likeA$';
6
-
7
- const ContextPanel = function($container, api, position){
8
- const $root = LA$(api.getContainerElement());
9
-
10
- const onRendered = function($current, template){
11
- const panelWidth = $current.width();
12
- const panelHeight = $current.height();
13
-
14
- const x = Math.min(position.pageX - $root.offset().left, $root.width() - panelWidth);
15
- const y = Math.min(position.pageY - $root.offset().top, $root.height() - panelHeight);
16
-
17
- $current.css("left" , x + "px");
18
- $current.css("top" , y + "px");
19
- };
20
- const onDestroyed = function(){
21
- //Do nothing.
22
- };
23
- const events = {
24
- "click .op-context-item" : function(event, $current, template){
25
- event.preventDefault();
26
-
27
- window.open(
28
- 'https://github.com/AirenSoft/OvenPlayer',
29
- '_blank'
30
- );
31
- }
32
- };
33
-
34
- return OvenTemplate($container, "ContextPanel", api.getConfig(), position, events, onRendered, onDestroyed );
35
-
36
- };
37
-
38
- export default ContextPanel;
1
+ /**
2
+ * Created by hoho on 2018. 8. 1..
3
+ */
4
+ import { CONTEXT_ITEM_CLICKED } from 'api/constants';
5
+ import LA$ from 'utils/likeA$';
6
+ import OvenTemplate from 'view/engine/OvenTemplate';
7
+
8
+ const ContextPanel = function($container, api, position){
9
+ const $root = LA$(api.getContainerElement());
10
+
11
+ const onRendered = function($current, template){
12
+ const panelWidth = $current.width();
13
+ const panelHeight = $current.height();
14
+
15
+ const x = Math.min(position.pageX - $root.offset().left, $root.width() - panelWidth);
16
+ const y = Math.min(position.pageY - $root.offset().top, $root.height() - panelHeight);
17
+
18
+ $current.css("left" , x + "px");
19
+ $current.css("top" , y + "px");
20
+ };
21
+ const onDestroyed = function(){
22
+ //Do nothing.
23
+ };
24
+ const events = {
25
+ "click .op-context-item" : function(event, $current, template){
26
+ event.preventDefault();
27
+ const item = $current.find('.op-context-item').get();
28
+ const contextItem = Array.from((item instanceof NodeList) ? item : [item], LA$).find(
29
+ (item) => item.contains(event.target) || item.get() == event.target
30
+ );
31
+ const ident = contextItem?.attr('id');
32
+ if (ident == 'context-player-about') {
33
+ window.open('https://github.com/OvenMediaLabs/OvenPlayer', '_blank');
34
+ return;
35
+ }
36
+ api.getProvider().trigger(CONTEXT_ITEM_CLICKED, ident);
37
+ },
38
+ };
39
+
40
+ return OvenTemplate($container, "ContextPanel", api.getConfig(), api.getConfig().contextItems, events, onRendered, onDestroyed );
41
+
42
+ };
43
+
44
+ export default ContextPanel;
@@ -1,10 +1,20 @@
1
- import {version} from "version";
2
- export default (uiText) => {
3
- return (
4
- `<div class="op-context-panel animated fadeIn">` +
5
- `<div class="op-context-item" tabindex="1">` +
6
- `<span class="op-context-item-text">${uiText.context} ${version}</span>` +
7
- `</div>`+
8
- `</div>`
9
- );
1
+ import {version} from "version";
2
+ export default (uiText, items=[]) => {
3
+ let index = 1;
4
+ const contextEl = (item) => {
5
+ const id = item.id ?? `context-item-${index}`;
6
+ return (
7
+ `<div id="${id}" class="op-context-item" tabindex="${index++}">` +
8
+ `<span class="op-context-item-text">${item.label}</span>` +
9
+ `</div>`
10
+ );
11
+ };
12
+ return (
13
+ `<div class="op-context-panel animated fadeIn">` +
14
+ `<div id="context-player-about" class="op-context-item" tabindex="1">` +
15
+ `<span class="op-context-item-text">${uiText.context} ${version}</span>` +
16
+ `</div>` +
17
+ items.map(contextEl).join('') +
18
+ `</div>`
19
+ );
10
20
  };