Revision b1e6a2de ui/static/snf/js/ui/web/ui_main_view.js
b/ui/static/snf/js/ui/web/ui_main_view.js | ||
---|---|---|
72 | 72 |
|
73 | 73 |
storage.vms.bind("change:pending_action", _.bind(this.handle_vm_change, this)); |
74 | 74 |
storage.vms.bind("change:reboot_required", _.bind(this.handle_vm_change, this)); |
75 |
|
|
75 | 76 |
}, |
76 |
|
|
77 |
|
|
77 | 78 |
handle_vm_change: function(vm) { |
78 | 79 |
if (vm.has_pending_action()) { |
79 | 80 |
var action = vm.get("pending_action"); |
... | ... | |
314 | 315 |
this.initial_view = this.session_view(); |
315 | 316 |
|
316 | 317 |
views.MainView.__super__.initialize.call(this); |
318 |
|
|
319 |
$(window).focus(_.bind(this.handle_window_focus, this, "focus")); |
|
320 |
$(window).blur(_.bind(this.handle_window_focus, this, "out")); |
|
321 |
|
|
322 |
this.focused = true; |
|
323 |
}, |
|
324 |
|
|
325 |
handle_window_focus: function(focus) { |
|
326 |
if (!snf.config.delay_on_blur) { return }; |
|
327 |
|
|
328 |
if (focus === "focus") { |
|
329 |
this.focused = true; |
|
330 |
this.set_interval_timeouts(snf.config.update_interval); |
|
331 |
} else { |
|
332 |
this.focused = false; |
|
333 |
this.set_interval_timeouts(snf.config.update_interval*3); |
|
334 |
} |
|
335 |
}, |
|
336 |
|
|
337 |
set_interval_timeouts: function(time) { |
|
338 |
_.each([this._networks, this._vms], function(fetcher){ |
|
339 |
if (!fetcher) { return }; |
|
340 |
fetcher.timeout = time; |
|
341 |
fetcher.stop().start(); |
|
342 |
}) |
|
317 | 343 |
}, |
318 | 344 |
|
319 | 345 |
vms_handlers_registered: false, |
Also available in: Unified diff