Skip to content

Commit

Permalink
Merge pull request #2452 from gnestor/issue-1254
Browse files Browse the repository at this point in the history
Use different favicons for different components (notebook, terminal, file)
  • Loading branch information
Carreau authored Apr 28, 2017
2 parents 7b5c42d + 3e01e12 commit 57b3cb7
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 16 deletions.
Binary file added notebook/static/base/images/favicon-busy-1.ico
Binary file not shown.
Binary file added notebook/static/base/images/favicon-busy-2.ico
Binary file not shown.
Binary file added notebook/static/base/images/favicon-busy-3.ico
Binary file not shown.
Binary file removed notebook/static/base/images/favicon-busy.ico
Binary file not shown.
Binary file added notebook/static/base/images/favicon-file.ico
Binary file not shown.
Binary file added notebook/static/base/images/favicon-notebook.ico
Binary file not shown.
Binary file added notebook/static/base/images/favicon-terminal.ico
Binary file not shown.
14 changes: 13 additions & 1 deletion notebook/static/base/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,17 @@ define([
fn();
}
}

var change_favicon = function (src) {
var link = document.createElement('link'),
oldLink = document.getElementById('favicon');
link.id = 'favicon';
link.type = 'image/x-icon';
link.rel = 'shortcut icon';
link.href = utils.url_path_join(utils.get_body_data('baseUrl'), src);
if (oldLink) document.head.removeChild(oldLink);
document.head.appendChild(link);
};

var utils = {
throttle: throttle,
Expand Down Expand Up @@ -1101,7 +1112,8 @@ define([
format_datetime: format_datetime,
datetime_sort_helper: datetime_sort_helper,
dnd_contain_file: dnd_contain_file,
_ansispan:_ansispan
_ansispan:_ansispan,
change_favicon: change_favicon
};

return utils;
Expand Down
36 changes: 21 additions & 15 deletions notebook/static/notebook/js/notificationarea.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,23 @@ define([
var $modal_ind_icon = $("#modal_indicator");
var $readonly_ind_icon = $('#readonly-indicator');
var $body = $('body');
var interval = 0;

var set_busy_favicon = function(on) {
if (on && !interval) {
var i = 0;
var icons = ['favicon-busy-1.ico', 'favicon-busy-3.ico', 'favicon-busy-3.ico'];
interval = setInterval(function() {
var icon = icons[i % 3];
utils.change_favicon('/static/base/images/' + icon);
i += 1;
}, 300);
} else {
clearInterval(interval);
utils.change_favicon('/static/base/images/favicon-notebook.ico');
interval = 0;
}
};

// Listen for the notebook loaded event. Set readonly indicator.
this.events.on('notebook_loaded.Notebook', function() {
Expand Down Expand Up @@ -244,41 +261,30 @@ define([
knw.danger(short, undefined, showMsg);
});

var change_favicon = function (src) {
var link = document.createElement('link'),
oldLink = document.getElementById('favicon');
link.id = 'favicon';
link.type = 'image/x-icon';
link.rel = 'shortcut icon';
link.href = utils.url_path_join(utils.get_body_data('baseUrl'), src);
if (oldLink) document.head.removeChild(oldLink);
document.head.appendChild(link);
};

this.events.on('kernel_starting.Kernel kernel_created.Session', function () {
// window.document.title='(Starting) '+window.document.title;
$kernel_ind_icon.attr('class','kernel_busy_icon').attr('title','Kernel Busy');
knw.set_message("Kernel starting, please wait...");
change_favicon('/static/base/images/favicon-busy.ico');
set_busy_favicon(true);
});

this.events.on('kernel_ready.Kernel', function () {
// that.save_widget.update_document_title();
$kernel_ind_icon.attr('class','kernel_idle_icon').attr('title','Kernel Idle');
knw.info("Kernel ready", 500);
change_favicon('/static/base/images/favicon.ico');
set_busy_favicon(false);
});

this.events.on('kernel_idle.Kernel', function () {
// that.save_widget.update_document_title();
$kernel_ind_icon.attr('class','kernel_idle_icon').attr('title','Kernel Idle');
change_favicon('/static/base/images/favicon.ico');
set_busy_favicon(false);
});

this.events.on('kernel_busy.Kernel', function () {
// window.document.title='(Busy) '+window.document.title;
$kernel_ind_icon.attr('class','kernel_busy_icon').attr('title','Kernel Busy');
change_favicon('/static/base/images/favicon-busy.ico');
set_busy_favicon(true);
});

this.events.on('spec_match_found.Kernel', function (evt, data) {
Expand Down
2 changes: 2 additions & 0 deletions notebook/templates/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

{% block title %}{{page_title}}{% endblock %}

{% block favicon %}<link rel="shortcut icon" type="image/x-icon" href="{{static_url("base/images/favicon-file.ico") }}">{% endblock %}

{% block stylesheet %}
<link rel="stylesheet" href="{{ static_url('components/codemirror/lib/codemirror.css') }}">
<link rel="stylesheet" href="{{ static_url('components/codemirror/addon/dialog/dialog.css') }}">
Expand Down
2 changes: 2 additions & 0 deletions notebook/templates/notebook.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{% extends "page.html" %}

{% block favicon %}<link rel="shortcut icon" type="image/x-icon" href="{{static_url("base/images/favicon-notebook.ico") }}">{% endblock %}

{% block stylesheet %}

{% if mathjax_url %}
Expand Down
2 changes: 2 additions & 0 deletions notebook/templates/terminal.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

{% block title %}{{page_title}}{% endblock %}

{% block favicon %}<link rel="shortcut icon" type="image/x-icon" href="{{static_url("base/images/favicon-terminal.ico") }}">{% endblock %}

{% block bodyclasses %}terminal-app {{super()}}{% endblock %}

{% block params %}
Expand Down

0 comments on commit 57b3cb7

Please sign in to comment.