ソースを参照

Merge pull request #1075 from BeatC/menu-restyling-editions

Adjust alignment of remote video menu
master
yanas 8年前
コミット
ae9819a45c
4個のファイルの変更148行の追加91行の削除
  1. 2
    2
      css/_mixins.scss
  2. 52
    40
      css/_popup_menu.scss
  3. 1
    1
      css/_videolayout_default.scss
  4. 93
    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 {

+ 93
- 48
modules/UI/videolayout/RemoteVideo.js ファイルの表示

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

読み込み中…
キャンセル
保存