GUI -- Strange Device View Table layout fixed in Safari.
Change-Id: Icfb3d80654a2ab009ca12b64f35a20ba98f37681
Showing
4 changed files
with
71 additions
and
7 deletions
... | @@ -122,6 +122,28 @@ | ... | @@ -122,6 +122,28 @@ |
122 | return patt.test(ua); | 122 | return patt.test(ua); |
123 | } | 123 | } |
124 | 124 | ||
125 | + // Returns true if the current browser determined to be Chrome | ||
126 | + function isChrome() { | ||
127 | + var isChromium = $window.chrome, | ||
128 | + vendorName = $window.navigator.vendor, | ||
129 | + isOpera = $window.navigator.userAgent.indexOf("OPR") > -1; | ||
130 | + return (isChromium !== null && | ||
131 | + isChromium !== undefined && | ||
132 | + vendorName === "Google Inc." && | ||
133 | + isOpera == false); | ||
134 | + } | ||
135 | + | ||
136 | + // Returns true if the current browser determined to be Safari | ||
137 | + function isSafari() { | ||
138 | + return ($window.navigator.userAgent.indexOf('Safari') !== -1 && | ||
139 | + $window.navigator.userAgent.indexOf('Chrome') === -1); | ||
140 | + } | ||
141 | + | ||
142 | + // Returns true if the current browser determined to be Firefox | ||
143 | + function isFirefox() { | ||
144 | + return typeof InstallTrigger !== 'undefined'; | ||
145 | + } | ||
146 | + | ||
125 | // search through an array of objects, looking for the one with the | 147 | // search through an array of objects, looking for the one with the |
126 | // tagged property matching the given key. tag defaults to 'id'. | 148 | // tagged property matching the given key. tag defaults to 'id'. |
127 | // returns the index of the matching object, or -1 for no match. | 149 | // returns the index of the matching object, or -1 for no match. |
... | @@ -249,6 +271,9 @@ | ... | @@ -249,6 +271,9 @@ |
249 | areFunctionsNonStrict: areFunctionsNonStrict, | 271 | areFunctionsNonStrict: areFunctionsNonStrict, |
250 | windowSize: windowSize, | 272 | windowSize: windowSize, |
251 | isMobile: isMobile, | 273 | isMobile: isMobile, |
274 | + isChrome: isChrome, | ||
275 | + isSafari: isSafari, | ||
276 | + isFirefox: isFirefox, | ||
252 | debugOn: debugOn, | 277 | debugOn: debugOn, |
253 | find: find, | 278 | find: find, |
254 | inArray: inArray, | 279 | inArray: inArray, | ... | ... |
... | @@ -251,8 +251,9 @@ | ... | @@ -251,8 +251,9 @@ |
251 | $log.log('OvDeviceCtrl has been created'); | 251 | $log.log('OvDeviceCtrl has been created'); |
252 | }]) | 252 | }]) |
253 | 253 | ||
254 | - .directive('deviceDetailsPanel', ['$rootScope', '$window', 'KeyService', | 254 | + .directive('deviceDetailsPanel', |
255 | - function ($rootScope, $window, ks) { | 255 | + ['$rootScope', '$window', '$timeout', 'KeyService', |
256 | + function ($rootScope, $window, $timeout, ks) { | ||
256 | return function (scope) { | 257 | return function (scope) { |
257 | var unbindWatch; | 258 | var unbindWatch; |
258 | 259 | ||
... | @@ -262,10 +263,19 @@ | ... | @@ -262,10 +263,19 @@ |
262 | wSize = fs.windowSize(pStartY); | 263 | wSize = fs.windowSize(pStartY); |
263 | pHeight = wSize.height; | 264 | pHeight = wSize.height; |
264 | } | 265 | } |
265 | - heightCalc(); | ||
266 | 266 | ||
267 | - createDetailsPane(); | 267 | + function initPanel() { |
268 | + heightCalc(); | ||
269 | + createDetailsPane(); | ||
270 | + } | ||
268 | 271 | ||
272 | + // Safari has a bug where it renders the fixed-layout table wrong | ||
273 | + // if you ask for the window's size too early | ||
274 | + if (scope.onos.browser === 'safari') { | ||
275 | + $timeout(initPanel); | ||
276 | + } else { | ||
277 | + initPanel(); | ||
278 | + } | ||
269 | // create key bindings to handle panel | 279 | // create key bindings to handle panel |
270 | ks.keyBindings({ | 280 | ks.keyBindings({ |
271 | esc: [closePanel, 'Close the details panel'], | 281 | esc: [closePanel, 'Close the details panel'], |
... | @@ -276,6 +286,7 @@ | ... | @@ -276,6 +286,7 @@ |
276 | ['scroll down', 'See more devices'] | 286 | ['scroll down', 'See more devices'] |
277 | ]); | 287 | ]); |
278 | 288 | ||
289 | + // if the panelData changes | ||
279 | scope.$watch('panelData', function () { | 290 | scope.$watch('panelData', function () { |
280 | if (!fs.isEmptyObject(scope.panelData)) { | 291 | if (!fs.isEmptyObject(scope.panelData)) { |
281 | populateDetails(scope.panelData); | 292 | populateDetails(scope.panelData); |
... | @@ -283,6 +294,7 @@ | ... | @@ -283,6 +294,7 @@ |
283 | } | 294 | } |
284 | }); | 295 | }); |
285 | 296 | ||
297 | + // if the window size changes | ||
286 | unbindWatch = $rootScope.$watchCollection( | 298 | unbindWatch = $rootScope.$watchCollection( |
287 | function () { | 299 | function () { |
288 | return { | 300 | return { | ... | ... |
... | @@ -145,7 +145,7 @@ | ... | @@ -145,7 +145,7 @@ |
145 | 145 | ||
146 | </head> | 146 | </head> |
147 | <body class="light" ng-app="onosApp"> | 147 | <body class="light" ng-app="onosApp"> |
148 | -<div id="frame" ng-controller="OnosCtrl as onosCtrl"> | 148 | +<div id="frame" ng-controller="OnosCtrl as onosCtrl" detect-browser> |
149 | <div id="mast" | 149 | <div id="mast" |
150 | ng-controller="MastCtrl as mastCtrl" | 150 | ng-controller="MastCtrl as mastCtrl" |
151 | ng-include="'app/fw/mast/mast.html'"></div> | 151 | ng-include="'app/fw/mast/mast.html'"></div> | ... | ... |
... | @@ -69,12 +69,12 @@ | ... | @@ -69,12 +69,12 @@ |
69 | angular.module('onosApp', moduleDependencies) | 69 | angular.module('onosApp', moduleDependencies) |
70 | 70 | ||
71 | .controller('OnosCtrl', [ | 71 | .controller('OnosCtrl', [ |
72 | - '$log', '$route', '$routeParams', '$location', | 72 | + '$log', '$scope', '$route', '$routeParams', '$location', |
73 | 'KeyService', 'ThemeService', 'GlyphService', 'VeilService', | 73 | 'KeyService', 'ThemeService', 'GlyphService', 'VeilService', |
74 | 'PanelService', 'FlashService', 'QuickHelpService', | 74 | 'PanelService', 'FlashService', 'QuickHelpService', |
75 | 'WebSocketService', | 75 | 'WebSocketService', |
76 | 76 | ||
77 | - function ($log, $route, $routeParams, $location, | 77 | + function ($log, $scope, $route, $routeParams, $location, |
78 | ks, ts, gs, vs, ps, flash, qhs, wss) { | 78 | ks, ts, gs, vs, ps, flash, qhs, wss) { |
79 | var self = this; | 79 | var self = this; |
80 | 80 | ||
... | @@ -83,6 +83,9 @@ | ... | @@ -83,6 +83,9 @@ |
83 | self.$location = $location; | 83 | self.$location = $location; |
84 | self.version = '1.3.0'; | 84 | self.version = '1.3.0'; |
85 | 85 | ||
86 | + // shared object inherited by all views: | ||
87 | + $scope.onos = {}; | ||
88 | + | ||
86 | // initialize services... | 89 | // initialize services... |
87 | ts.init(); | 90 | ts.init(); |
88 | ks.installOn(d3.select('body')); | 91 | ks.installOn(d3.select('body')); |
... | @@ -131,5 +134,29 @@ | ... | @@ -131,5 +134,29 @@ |
131 | }); | 134 | }); |
132 | } | 135 | } |
133 | }); | 136 | }); |
137 | + }]) | ||
138 | + | ||
139 | + .directive('detectBrowser', ['$log', 'FnService', | ||
140 | + function ($log, fs) { | ||
141 | + return function (scope) { | ||
142 | + var body = d3.select('body'), | ||
143 | + browser = ''; | ||
144 | + if (fs.isChrome()) { | ||
145 | + browser = 'chrome'; | ||
146 | + } else if (fs.isSafari()) { | ||
147 | + browser = 'safari'; | ||
148 | + } else if (fs.isFirefox()) { | ||
149 | + browser = 'firefox'; | ||
150 | + } | ||
151 | + body.classed(browser, true); | ||
152 | + scope.onos.browser = browser; | ||
153 | + | ||
154 | + if (fs.isMobile()) { | ||
155 | + body.classed('mobile', true); | ||
156 | + scope.onos.mobile = true; | ||
157 | + } | ||
158 | + | ||
159 | + $log.debug('Detected browser is', fs.cap(browser)); | ||
160 | + }; | ||
134 | }]); | 161 | }]); |
135 | }()); | 162 | }()); | ... | ... |
-
Please register or login to post a comment