瀏覽代碼

Adjust alignment of remote video menu

j8
Ilya Daynatovich 8 年之前
父節點
當前提交
d84d0b65ca
共有 4 個檔案被更改,包括 146 行新增91 行删除
  1. 2
    2
      css/_mixins.scss
  2. 52
    40
      css/_popup_menu.scss
  3. 1
    1
      css/_videolayout_default.scss
  4. 91
    48
      modules/UI/videolayout/RemoteVideo.js

+ 2
- 2
css/_mixins.scss 查看文件

@@ -59,11 +59,11 @@
59 59
     left: 0;
60 60
 }
61 61
 
62
-@mixin absoluteAligning($sizeX, $sizeY) {
62
+@mixin absoluteAligning() {
63 63
   top: 50%;
64 64
   left: 50%;
65 65
   position: absolute;
66
-  @include transform(translate(-#{$sizeX / 2}, -#{$sizeY / 2}))
66
+  @include transform(translate(-50%, -50%))
67 67
 }
68 68
 
69 69
 @mixin transform($func) {

+ 52
- 40
css/_popup_menu.scss 查看文件

@@ -1,57 +1,69 @@
1
-/*Initialize*/
2
-ul.popupmenu {
1
+/**
2
+* Initialize
3
+**/
4
+
5
+.popupmenu {
3 6
     padding: 0;
4 7
     margin: 2px 0;
5 8
     bottom: 0;
6 9
     width: 100px;
7 10
     height: auto;
8
-}
9 11
 
10
-ul.popupmenu li {
11
-    list-style-type: none;
12
-    text-align: left;
13
-}
12
+    &:first-child {
13
+        margin-top: 2px;
14
+    }
14 15
 
15
-ul.popupmenu li:hover {
16
-    background-color: $popupMenuSelectedItemBackground;
17
-}
16
+    &__item {
17
+        list-style-type: none;
18
+        text-align: left;
19
+        height: 35px;
18 20
 
19
-/*Link Appearance*/
20
-ul.popupmenu li a {
21
-    display: block;
22
-    text-decoration: none;
23
-    color: #fff;
24
-    padding: 5px;
25
-    font-size: 9pt;
26
-    width: 100%;
27
-    cursor: hand;
28
-}
21
+        &:hover {
22
+            background-color: $popupMenuSelectedItemBackground;
23
+        }
24
+    }
29 25
 
30
-ul.popupmenu li a i.icon-kick {
31
-    font-size: 8pt;
32
-}
26
+    // Link Appearance
27
+    &__link {
28
+        display: block;
29
+        box-sizing: border-box;
30
+        text-decoration: none;
31
+        color: #fff;
32
+        padding: 5px;
33
+        height: 100%;
34
+        font-size: 9pt;
35
+        width: 100%;
36
+        cursor: hand;
33 37
 
34
-ul.popupmenu li a span {
35
-    display: inline-block;
36
-    width: 20px;
37
-    height: 16px;
38
-    text-align: center;
39
-}
38
+        &.disabled {
39
+            color: gray !important;
40
+            pointer-events: none;
41
+        }
42
+    }
40 43
 
41
-ul.popupmenu li a div {
42
-    display: inline-block;
43
-    line-height: 25px;
44
-}
44
+    &__text {
45
+        display: inline-block;
46
+        vertical-align: middle;
47
+    }
48
+
49
+    &__icon {
50
+        vertical-align: middle;
51
+        position: relative;
52
+        display: inline-block;
53
+        width: 20px;
54
+        height: 100%;
55
+        text-align: center;
45 56
 
46
-ul.popupmenu li a i {
47
-    line-height: 25px;
57
+        > * {
58
+            @include absoluteAligning();
59
+        }
60
+    }
61
+
62
+    .icon-kick {
63
+        font-size: 8pt;
64
+    }
48 65
 }
49 66
 
50 67
 span.remotevideomenu:hover ul.popupmenu, ul.popupmenu:hover {
51 68
     display:block !important;
52
-}
53
-
54
-a.disabled {
55
-    color: gray !important;
56
-    pointer-events: none;
57 69
 }

+ 1
- 1
css/_videolayout_default.scss 查看文件

@@ -472,7 +472,7 @@
472 472
 
473 473
 .userAvatar {
474 474
     @include circle(60px);
475
-    @include absoluteAligning(60px, 60px);
475
+    @include absoluteAligning();
476 476
 }
477 477
 
478 478
 .sharedVideoAvatar {

+ 91
- 48
modules/UI/videolayout/RemoteVideo.js 查看文件

@@ -109,74 +109,117 @@ RemoteVideo.prototype._initPopupMenu = function (popupMenuElement) {
109 109
  * @private
110 110
  */
111 111
 RemoteVideo.prototype._generatePopupContent = function () {
112
-    var popupmenuElement = document.createElement('ul');
112
+    let popupmenuElement = document.createElement('ul');
113 113
     popupmenuElement.className = 'popupmenu';
114 114
     popupmenuElement.id = `remote_popupmenu_${this.id}`;
115 115
 
116
-    var muteMenuItem = document.createElement('li');
117
-    var muteLinkItem = document.createElement('a');
116
+    let muteTranslationKey;
117
+    let muteClassName;
118
+    if (this.isAudioMuted) {
119
+        muteTranslationKey = 'videothumbnail.muted';
120
+        muteClassName = 'mutelink disabled';
121
+    } else {
122
+        muteTranslationKey = 'videothumbnail.domute';
123
+        muteClassName = 'mutelink';
124
+    }
118 125
 
119
-    var mutedIndicator = "<i class='icon-mic-disabled'></i>";
126
+    let muteHandler = this._muteHandler.bind(this);
127
+    let kickHandler = this._kickHandler.bind(this);
128
+
129
+    let menuItems = [
130
+        {
131
+            id: 'mutelink_' + this.id,
132
+            handler: muteHandler,
133
+            icon: 'icon-mic-disabled',
134
+            text: {
135
+                className: muteClassName,
136
+                data: {
137
+                    i18n: muteTranslationKey
138
+                }
139
+            }
140
+        }, {
141
+            id: 'ejectlink_' + this.id,
142
+            handler: kickHandler,
143
+            icon: 'icon-kick',
144
+            text: {
145
+                data: {
146
+                    i18n: 'videothumbnail.kick'
147
+                }
148
+            }
149
+        }
150
+    ];
120 151
 
121
-    var doMuteHTML = mutedIndicator +
122
-        " <div data-i18n='videothumbnail.domute'></div>";
152
+    menuItems.forEach(el => {
153
+        let menuItem = this._generatePopupMenuItem(el);
154
+        popupmenuElement.appendChild(menuItem);
155
+    });
123 156
 
124
-    var mutedHTML = mutedIndicator +
125
-        " <div data-i18n='videothumbnail.muted'></div>";
157
+    APP.translation.translateElement($(popupmenuElement));
126 158
 
127
-    muteLinkItem.id = "mutelink_" + this.id;
159
+    return popupmenuElement;
160
+};
128 161
 
129
-    if (this.isAudioMuted) {
130
-        muteLinkItem.innerHTML = mutedHTML;
131
-        muteLinkItem.className = 'mutelink disabled';
132
-    }
133
-    else {
134
-        muteLinkItem.innerHTML = doMuteHTML;
135
-        muteLinkItem.className = 'mutelink';
136
-    }
162
+RemoteVideo.prototype._muteHandler = function () {
163
+    if (this.isAudioMuted)
164
+        return;
137 165
 
138
-    // Delegate event to the document.
139
-    $(document).on("click", "#mutelink_" + this.id, () => {
140
-        if (this.isAudioMuted)
141
-            return;
166
+    RemoteVideo.showMuteParticipantDialog().then(reason => {
167
+        if(reason === MUTED_DIALOG_BUTTON_VALUES.muted) {
168
+            this.emitter.emit(UIEvents.REMOTE_AUDIO_MUTED, this.id);
169
+        }
170
+    }).catch(e => {
171
+        //currently shouldn't be called
172
+        console.error(e);
173
+    });
142 174
 
143
-        RemoteVideo.showMuteParticipantDialog().then(reason => {
144
-            if(reason === MUTED_DIALOG_BUTTON_VALUES.muted) {
145
-                this.emitter.emit(UIEvents.REMOTE_AUDIO_MUTED, this.id);
146
-            }
147
-        }).catch(e => {
148
-            //currently shouldn't be called
149
-            console.error(e);
150
-        });
175
+    this.popover.forceHide();
176
+};
151 177
 
152
-        this.popover.forceHide();
153
-    });
178
+RemoteVideo.prototype._kickHandler = function () {
179
+    this.emitter.emit(UIEvents.USER_KICKED, this.id);
180
+    this.popover.forceHide();
181
+};
182
+
183
+RemoteVideo.prototype._generatePopupMenuItem = function (opts = {}) {
184
+    let {
185
+        id,
186
+        handler,
187
+        icon,
188
+        text
189
+    } = opts;
154 190
 
155
-    muteMenuItem.appendChild(muteLinkItem);
156
-    popupmenuElement.appendChild(muteMenuItem);
191
+    handler = handler || $.noop;
157 192
 
158
-    var ejectIndicator = "<i style='float:left;' class='icon-kick'></i>";
193
+    let menuItem = document.createElement('li');
194
+    menuItem.className = 'popupmenu__item';
159 195
 
160
-    var ejectMenuItem = document.createElement('li');
161
-    var ejectLinkItem = document.createElement('a');
196
+    let linkItem = document.createElement('a');
197
+    linkItem.className = 'popupmenu__link';
162 198
 
163
-    var ejectText = "<div data-i18n='videothumbnail.kick'></div>";
199
+    if (icon) {
200
+        let indicator = document.createElement('span');
201
+        indicator.className = 'popupmenu__icon';
202
+        indicator.innerHTML = `<i class="${icon}"></i>`;
203
+        linkItem.appendChild(indicator);
204
+    }
164 205
 
165
-    ejectLinkItem.className = 'ejectlink';
166
-    ejectLinkItem.innerHTML = ejectIndicator + ' ' + ejectText;
167
-    ejectLinkItem.id = "ejectlink_" + this.id;
206
+    let textContent = document.createElement('span');
207
+    textContent.className = 'popupmenu__text';
168 208
 
169
-    $(document).on("click", "#ejectlink_" + this.id, function(){
170
-        this.emitter.emit(UIEvents.USER_KICKED, this.id);
171
-        this.popover.forceHide();
172
-    }.bind(this));
209
+    let dataKeys = Object.keys(text.data);
210
+    dataKeys.forEach(key => {
211
+        textContent.dataset[key] = text.data[key];
212
+    });
213
+    textContent.className +=  ` ${text.className}` || '';
173 214
 
174
-    ejectMenuItem.appendChild(ejectLinkItem);
175
-    popupmenuElement.appendChild(ejectMenuItem);
215
+    linkItem.appendChild(textContent);
216
+    linkItem.id = id;
176 217
 
177
-    APP.translation.translateElement($(popupmenuElement));
218
+    // Delegate event to the document.
219
+    $(document).on("click", `#${id}`, handler);
220
+    menuItem.appendChild(linkItem);
178 221
 
179
-    return popupmenuElement;
222
+    return menuItem;
180 223
 };
181 224
 
182 225
 /**

Loading…
取消
儲存