Procházet zdrojové kódy

Creates keyboard shortcuts module.

j8
hristoterezov před 10 roky
rodič
revize
c0a316c7df

+ 2
- 0
app.js Zobrazit soubor

@@ -18,6 +18,8 @@ $(document).ready(function () {
18 18
     
19 19
     // Set default desktop sharing method
20 20
     desktopsharing.init();
21
+
22
+    keyboardshortcut.init();
21 23
 });
22 24
 
23 25
 $(window).bind('beforeunload', function () {

+ 3
- 3
index.html Zobrazit soubor

@@ -27,17 +27,17 @@
27 27
     <script src="service/desktopsharing/DesktopSharingEventTypes.js?v=1"></script>
28 28
     <script src="libs/modules/simulcast.bundle.js?v=5"></script>
29 29
     <script src="libs/modules/connectionquality.bundle.js?v=2"></script>
30
-    <script src="libs/modules/UI.bundle.js?v=9"></script>
30
+    <script src="libs/modules/UI.bundle.js?v=10"></script>
31 31
     <script src="libs/modules/statistics.bundle.js?v=4"></script>
32 32
     <script src="libs/modules/RTC.bundle.js?v=6"></script>
33 33
     <script src="libs/modules/desktopsharing.bundle.js?v=3"></script><!-- desktop sharing -->
34 34
     <script src="util.js?v=7"></script><!-- utility functions -->
35 35
     <script src="libs/modules/xmpp.bundle.js?v=5"></script>
36
-    <script src="app.js?v=29"></script><!-- application logic -->
36
+    <script src="libs/modules/keyboardshortcut.bundle.js?v=1"></script>
37
+    <script src="app.js?v=30"></script><!-- application logic -->
37 38
     <script src="libs/modules/API.bundle.js?v=1"></script>
38 39
 
39 40
     <script src="analytics.js?v=1"></script><!-- google analytics plugin -->
40
-    <script src="keyboard_shortcut.js?v=5"></script>
41 41
     <link rel="stylesheet" href="css/font.css?v=6"/>
42 42
     <link rel="stylesheet" href="css/toastr.css?v=1">
43 43
     <link rel="stylesheet" type="text/css" media="screen" href="css/main.css?v=30"/>

+ 0
- 79
keyboard_shortcut.js Zobrazit soubor

@@ -1,79 +0,0 @@
1
-var KeyboardShortcut = (function(my) {
2
-    //maps keycode to character, id of popover for given function and function
3
-    var shortcuts = {
4
-        67: {
5
-            character: "C",
6
-            id: "toggleChatPopover",
7
-            function: UI.toggleChat
8
-        },
9
-        70: {
10
-            character: "F",
11
-            id: "filmstripPopover",
12
-            function: UI.toggleFilmStrip
13
-        },
14
-        77: {
15
-            character: "M",
16
-            id: "mutePopover",
17
-            function: UI.toggleAudio
18
-        },
19
-        84: {
20
-            character: "T",
21
-            function: function() {
22
-                if(!RTC.localAudio.isMuted()) {
23
-                    UI.toggleAudio();
24
-                }
25
-            }
26
-        },
27
-        86: {
28
-            character: "V",
29
-            id: "toggleVideoPopover",
30
-            function: UI.toggleVideo
31
-        }
32
-    };
33
-
34
-    window.onkeyup = function(e) {
35
-        var keycode = e.which;
36
-        if(!($(":focus").is("input[type=text]") || $(":focus").is("input[type=password]") || $(":focus").is("textarea"))) {
37
-            if (typeof shortcuts[keycode] === "object") {
38
-                shortcuts[keycode].function();
39
-            } else if (keycode >= "0".charCodeAt(0) && keycode <= "9".charCodeAt(0)) {
40
-                var remoteVideos = $(".videocontainer:not(#mixedstream)"),
41
-                    videoWanted = keycode - "0".charCodeAt(0) + 1;
42
-                if (remoteVideos.length > videoWanted) {
43
-                    remoteVideos[videoWanted].click();
44
-                }
45
-            }
46
-          //esc while the smileys are visible hides them
47
-        } else if (keycode === 27 && $('#smileysContainer').is(':visible')) {
48
-            UI.toggleSmileys();
49
-        }
50
-    };
51
-
52
-    window.onkeydown = function(e) {
53
-        if(!($(":focus").is("input[type=text]") || $(":focus").is("input[type=password]") || $(":focus").is("textarea"))) {
54
-            if(e.which === "T".charCodeAt(0)) {
55
-                if(RTC.localAudio.isMuted()) {
56
-                    UI.toggleAudio();
57
-                }
58
-            }
59
-        }
60
-    };
61
-    
62
-    /**
63
-     *  
64
-     * @param id indicates the popover associated with the shortcut
65
-     * @returns {string} the keyboard shortcut used for the id given
66
-     */
67
-    my.getShortcut = function(id) {
68
-        for(var keycode in shortcuts) {
69
-            if(shortcuts.hasOwnProperty(keycode)) {
70
-                if (shortcuts[keycode].id === id) {
71
-                    return " (" + shortcuts[keycode].character + ")";
72
-                }
73
-            }
74
-        }
75
-        return "";
76
-    };
77
-    return my;
78
-}(KeyboardShortcut || {}))
79
-

+ 8
- 1
libs/modules/UI.bundle.js Zobrazit soubor

@@ -202,7 +202,7 @@ UI.start = function () {
202 202
         trigger: 'click hover',
203 203
         content: function() {
204 204
             return this.getAttribute("content") +
205
-                KeyboardShortcut.getShortcut(this.getAttribute("shortcut"));
205
+                keyboardshortcut.getShortcut(this.getAttribute("shortcut"));
206 206
         }
207 207
     });
208 208
     VideoLayout.resizeLargeVideoContainer();
@@ -692,6 +692,13 @@ UI.addListener = function (type, listener) {
692 692
     eventEmitter.on(type, listener);
693 693
 }
694 694
 
695
+UI.clickOnVideo = function (videoNumber) {
696
+    var remoteVideos = $(".videocontainer:not(#mixedstream)");
697
+    if (remoteVideos.length > videoNumber) {
698
+        remoteVideos[videoNumber].click();
699
+    }
700
+}
701
+
695 702
 module.exports = UI;
696 703
 
697 704
 

+ 87
- 0
libs/modules/keyboardshortcut.bundle.js Zobrazit soubor

@@ -0,0 +1,87 @@
1
+!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var o;"undefined"!=typeof window?o=window:"undefined"!=typeof global?o=global:"undefined"!=typeof self&&(o=self),o.keyboardshortcut=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2
+//maps keycode to character, id of popover for given function and function
3
+var shortcuts = {
4
+    67: {
5
+        character: "C",
6
+        id: "toggleChatPopover",
7
+        function: UI.toggleChat
8
+    },
9
+    70: {
10
+        character: "F",
11
+        id: "filmstripPopover",
12
+        function: UI.toggleFilmStrip
13
+    },
14
+    77: {
15
+        character: "M",
16
+        id: "mutePopover",
17
+        function: UI.toggleAudio
18
+    },
19
+    84: {
20
+        character: "T",
21
+        function: function() {
22
+            if(!RTC.localAudio.isMuted()) {
23
+                UI.toggleAudio();
24
+            }
25
+        }
26
+    },
27
+    86: {
28
+        character: "V",
29
+        id: "toggleVideoPopover",
30
+        function: UI.toggleVideo
31
+    }
32
+};
33
+
34
+
35
+var KeyboardShortcut = {
36
+    init: function () {
37
+        window.onkeyup = function(e) {
38
+            var keycode = e.which;
39
+            if(!($(":focus").is("input[type=text]") ||
40
+                $(":focus").is("input[type=password]") ||
41
+                $(":focus").is("textarea"))) {
42
+                if (typeof shortcuts[keycode] === "object") {
43
+                    shortcuts[keycode].function();
44
+                }
45
+                else if (keycode >= "0".charCodeAt(0) &&
46
+                    keycode <= "9".charCodeAt(0)) {
47
+                    UI.clickOnVideo(keycode - "0".charCodeAt(0) + 1);
48
+                }
49
+                //esc while the smileys are visible hides them
50
+            } else if (keycode === 27 && $('#smileysContainer').is(':visible')) {
51
+                UI.toggleSmileys();
52
+            }
53
+        };
54
+
55
+        window.onkeydown = function(e) {
56
+            if(!($(":focus").is("input[type=text]") ||
57
+                $(":focus").is("input[type=password]") ||
58
+                $(":focus").is("textarea"))) {
59
+                if(e.which === "T".charCodeAt(0)) {
60
+                    if(RTC.localAudio.isMuted()) {
61
+                        UI.toggleAudio();
62
+                    }
63
+                }
64
+            }
65
+        };
66
+    },
67
+    /**
68
+     *
69
+     * @param id indicates the popover associated with the shortcut
70
+     * @returns {string} the keyboard shortcut used for the id given
71
+     */
72
+    getShortcut: function (id) {
73
+        for (var keycode in shortcuts) {
74
+            if (shortcuts.hasOwnProperty(keycode)) {
75
+                if (shortcuts[keycode].id === id) {
76
+                    return " (" + shortcuts[keycode].character + ")";
77
+                }
78
+            }
79
+        }
80
+        return "";
81
+    }
82
+};
83
+
84
+module.exports = KeyboardShortcut;
85
+
86
+},{}]},{},[1])(1)
87
+});

+ 8
- 1
modules/UI/UI.js Zobrazit soubor

@@ -201,7 +201,7 @@ UI.start = function () {
201 201
         trigger: 'click hover',
202 202
         content: function() {
203 203
             return this.getAttribute("content") +
204
-                KeyboardShortcut.getShortcut(this.getAttribute("shortcut"));
204
+                keyboardshortcut.getShortcut(this.getAttribute("shortcut"));
205 205
         }
206 206
     });
207 207
     VideoLayout.resizeLargeVideoContainer();
@@ -691,5 +691,12 @@ UI.addListener = function (type, listener) {
691 691
     eventEmitter.on(type, listener);
692 692
 }
693 693
 
694
+UI.clickOnVideo = function (videoNumber) {
695
+    var remoteVideos = $(".videocontainer:not(#mixedstream)");
696
+    if (remoteVideos.length > videoNumber) {
697
+        remoteVideos[videoNumber].click();
698
+    }
699
+}
700
+
694 701
 module.exports = UI;
695 702
 

+ 83
- 0
modules/keyboardshortcut/keyboardshortcut.js Zobrazit soubor

@@ -0,0 +1,83 @@
1
+//maps keycode to character, id of popover for given function and function
2
+var shortcuts = {
3
+    67: {
4
+        character: "C",
5
+        id: "toggleChatPopover",
6
+        function: UI.toggleChat
7
+    },
8
+    70: {
9
+        character: "F",
10
+        id: "filmstripPopover",
11
+        function: UI.toggleFilmStrip
12
+    },
13
+    77: {
14
+        character: "M",
15
+        id: "mutePopover",
16
+        function: UI.toggleAudio
17
+    },
18
+    84: {
19
+        character: "T",
20
+        function: function() {
21
+            if(!RTC.localAudio.isMuted()) {
22
+                UI.toggleAudio();
23
+            }
24
+        }
25
+    },
26
+    86: {
27
+        character: "V",
28
+        id: "toggleVideoPopover",
29
+        function: UI.toggleVideo
30
+    }
31
+};
32
+
33
+
34
+var KeyboardShortcut = {
35
+    init: function () {
36
+        window.onkeyup = function(e) {
37
+            var keycode = e.which;
38
+            if(!($(":focus").is("input[type=text]") ||
39
+                $(":focus").is("input[type=password]") ||
40
+                $(":focus").is("textarea"))) {
41
+                if (typeof shortcuts[keycode] === "object") {
42
+                    shortcuts[keycode].function();
43
+                }
44
+                else if (keycode >= "0".charCodeAt(0) &&
45
+                    keycode <= "9".charCodeAt(0)) {
46
+                    UI.clickOnVideo(keycode - "0".charCodeAt(0) + 1);
47
+                }
48
+                //esc while the smileys are visible hides them
49
+            } else if (keycode === 27 && $('#smileysContainer').is(':visible')) {
50
+                UI.toggleSmileys();
51
+            }
52
+        };
53
+
54
+        window.onkeydown = function(e) {
55
+            if(!($(":focus").is("input[type=text]") ||
56
+                $(":focus").is("input[type=password]") ||
57
+                $(":focus").is("textarea"))) {
58
+                if(e.which === "T".charCodeAt(0)) {
59
+                    if(RTC.localAudio.isMuted()) {
60
+                        UI.toggleAudio();
61
+                    }
62
+                }
63
+            }
64
+        };
65
+    },
66
+    /**
67
+     *
68
+     * @param id indicates the popover associated with the shortcut
69
+     * @returns {string} the keyboard shortcut used for the id given
70
+     */
71
+    getShortcut: function (id) {
72
+        for (var keycode in shortcuts) {
73
+            if (shortcuts.hasOwnProperty(keycode)) {
74
+                if (shortcuts[keycode].id === id) {
75
+                    return " (" + shortcuts[keycode].character + ")";
76
+                }
77
+            }
78
+        }
79
+        return "";
80
+    }
81
+};
82
+
83
+module.exports = KeyboardShortcut;

Načítá se…
Zrušit
Uložit