diff --git a/frappe/core/page/desktop/desktop.js b/frappe/core/page/desktop/desktop.js index 7a8b1ec089..31837ba7f5 100644 --- a/frappe/core/page/desktop/desktop.js +++ b/frappe/core/page/desktop/desktop.js @@ -18,7 +18,7 @@ $.extend(frappe.desktop, { render: function() { var me = this; - document.title = "Desktop"; + frappe.utils.set_title("Desktop"); this.wrapper.html(frappe.render_template("desktop_icon_grid", { // all visible icons diff --git a/frappe/desk/page/messages/messages.js b/frappe/desk/page/messages/messages.js index 42690046b2..d7ead8937a 100644 --- a/frappe/desk/page/messages/messages.js +++ b/frappe/desk/page/messages/messages.js @@ -19,6 +19,11 @@ frappe.pages.messages.on_page_load = function(parent) { frappe.desk.pages.messages = new frappe.desk.pages.Messages(parent); } +frappe.pages.messages.on_page_show = function() { + // clear title prefix + frappe.utils.set_title_prefix(""); +} + frappe.desk.pages.Messages = Class.extend({ init: function(wrapper, page) { this.wrapper = wrapper; diff --git a/frappe/public/images/favicon.ico b/frappe/public/images/favicon.ico deleted file mode 100644 index 19714782c3..0000000000 Binary files a/frappe/public/images/favicon.ico and /dev/null differ diff --git a/frappe/public/images/favicon.png b/frappe/public/images/favicon.png new file mode 100644 index 0000000000..00d97cb834 Binary files /dev/null and b/frappe/public/images/favicon.png differ diff --git a/frappe/public/js/frappe/desk.js b/frappe/public/js/frappe/desk.js index 2e9e6b4150..c837b5e2c9 100644 --- a/frappe/public/js/frappe/desk.js +++ b/frappe/public/js/frappe/desk.js @@ -109,13 +109,13 @@ frappe.Application = Class.extend({ me.update_notification_count_in_modules(); if(frappe.get_route()[0] != "messages") { - $.each(r.message.new_messages, function(i, m) { - if (Notify.needsPermission) { - Notify.requestPermission(function() { me.browser_notify(m); }); - } else { - me.browser_notify(m); - } - }); + if(r.message.new_messages.length) { + $.each(r.message.new_messages, function(i, m) { + frappe.utils.notify(__("Message from {0}", [m.comment_by_fullname]), + m.comment); + }); + frappe.utils.set_title_prefix("(" + r.message.new_messages.length + ")"); + } } } }, @@ -124,14 +124,8 @@ frappe.Application = Class.extend({ } }, - browser_notify: function(m) { - var notify = new Notify(__("Message from {0}", [m.comment_by_fullname]), { - body: m.comment, - notifyClick: function() { - frappe.set_route("messages"); - } - }); - notify.show(); + set_unread_messages: function() { + }, update_notification_count_in_modules: function() { diff --git a/frappe/public/js/frappe/form/toolbar.js b/frappe/public/js/frappe/form/toolbar.js index cf4c67e64b..baff5c5602 100644 --- a/frappe/public/js/frappe/form/toolbar.js +++ b/frappe/public/js/frappe/form/toolbar.js @@ -44,7 +44,7 @@ frappe.ui.form.Toolbar = Class.extend({ var me = this; this.page.set_title(title); if(this.frm.meta.title_field) { - document.title = title + " - " + this.frm.docname; + frappe.utils.set_title(title + " - " + this.frm.docname); } this.set_indicator(); }, diff --git a/frappe/public/js/frappe/misc/utils.js b/frappe/public/js/frappe/misc/utils.js index d86795f239..d9f969655a 100644 --- a/frappe/public/js/frappe/misc/utils.js +++ b/frappe/public/js/frappe/misc/utils.js @@ -448,4 +448,42 @@ frappe.utils = { warn_page_name_change: function(frm) { frappe.msgprint("Note: Changing the Page Name will break previous URL to this page."); }, + + if_notify_permitted: function(callback) { + if (Notify.needsPermission) { + Notify.requestPermission(callback); + } else { + callback(); + } + }, + + notify: function(subject, body, route, onclick) { + if(!route) route = "messages"; + if(!onclick) onclick = function() { + frappe.set_route(route); + } + + frappe.utils.if_notify_permitted(function() { + var notify = new Notify(subject, { + body: body, + notifyClick: onclick + }); + notify.show(); + }); + }, + + set_title: function(title) { + frappe._original_title = title; + if(frappe._title_prefix) { + title = frappe._title_prefix + " " + title; + } + document.title = title; + }, + + set_title_prefix: function(prefix) { + frappe._title_prefix = prefix; + + // reset the original title + frappe.utils.set_title(frappe._original_title); + } }; diff --git a/frappe/public/js/frappe/router.js b/frappe/public/js/frappe/router.js index 0b728686db..30cd375df1 100644 --- a/frappe/public/js/frappe/router.js +++ b/frappe/public/js/frappe/router.js @@ -47,7 +47,7 @@ frappe.route = function() { } if(frappe.route_titles[window.location.hash]) { - document.title = frappe.route_titles[window.location.hash]; + frappe.utils.set_title(frappe.route_titles[window.location.hash]); } } @@ -117,7 +117,7 @@ frappe._cur_route = null; $(window).on('hashchange', function() { // save the title - frappe.route_titles[frappe._cur_route] = document.title; + frappe.route_titles[frappe._cur_route] = frappe._original_title || document.title; if(window.location.hash==frappe._cur_route) return; diff --git a/frappe/public/js/frappe/ui/listing.js b/frappe/public/js/frappe/ui/listing.js index 80bb8b0fd3..4fdfec9916 100644 --- a/frappe/public/js/frappe/ui/listing.js +++ b/frappe/public/js/frappe/ui/listing.js @@ -173,7 +173,7 @@ frappe.ui.Listing = Class.extend({ return frappe.call({ method: this.opts.method || 'frappe.desk.query_builder.runquery', type: "GET", - freeze: this.opts.freeze || true, + freeze: (this.opts.freeze != undefined ? this.opts.freeze : true), args: this.get_call_args(), callback: function(r) { if(!me.opts.no_loading) diff --git a/frappe/public/js/frappe/ui/page.js b/frappe/public/js/frappe/ui/page.js index a58cd975bf..cf7d235942 100644 --- a/frappe/public/js/frappe/ui/page.js +++ b/frappe/public/js/frappe/ui/page.js @@ -239,7 +239,7 @@ frappe.ui.Page = Class.extend({ set_title: function(txt, icon) { // strip icon this.title = txt; - document.title = txt.replace(/<[^>]*>/g, ""); + frappe.utils.set_title(txt.replace(/<[^>]*>/g, "")); if(icon) { txt = ' ' + txt; } diff --git a/frappe/public/js/legacy/dom.js b/frappe/public/js/legacy/dom.js index 87d03f3bbb..268230c64e 100644 --- a/frappe/public/js/legacy/dom.js +++ b/frappe/public/js/legacy/dom.js @@ -42,9 +42,6 @@ function add_sel_options(s, list, sel_val, o_style) { } var $n = '\n'; -function set_title(t) { - document.title = (frappe.title_prefix ? (frappe.title_prefix + ' - ') : '') + t; -} function $a(parent, newtag, className, cs, innerHTML, onclick) { if(parent && parent.substr)parent = $i(parent); diff --git a/frappe/public/js/legacy/form.js b/frappe/public/js/legacy/form.js index 9a378deac1..b4d4a762f1 100644 --- a/frappe/public/js/legacy/form.js +++ b/frappe/public/js/legacy/form.js @@ -302,7 +302,7 @@ _f.Frm.prototype.refresh_header = function() { // set title // main title if(!this.meta.in_dialog || this.in_form) { - set_title(this.meta.issingle ? this.doctype : this.docname); + frappe.utils.set_title(this.meta.issingle ? this.doctype : this.docname); } if(frappe.ui.toolbar.recent) diff --git a/frappe/templates/base.html b/frappe/templates/base.html index 67976730ae..fa0d9acd1f 100644 --- a/frappe/templates/base.html +++ b/frappe/templates/base.html @@ -11,10 +11,10 @@ {% block favicon %} {% endblock %} {%- block head -%} diff --git a/frappe/templates/pages/desk.html b/frappe/templates/pages/desk.html index 87b224f791..457e49ec31 100644 --- a/frappe/templates/pages/desk.html +++ b/frappe/templates/pages/desk.html @@ -11,9 +11,9 @@ Frappe Desk + href="{{ favicon or "/assets/frappe/images/favicon.png" }}" type="image/x-icon"> + href="{{ favicon or "/assets/frappe/images/favicon.png" }}" type="image/x-icon"> {% for include in include_css -%} {%- endfor -%} diff --git a/frappe/website/doctype/website_settings/website_settings.py b/frappe/website/doctype/website_settings/website_settings.py index 1a281e1588..3b98a660e1 100644 --- a/frappe/website/doctype/website_settings/website_settings.py +++ b/frappe/website/doctype/website_settings/website_settings.py @@ -98,9 +98,6 @@ def get_website_settings(): if hasattr(settings, k): context[k] = settings.get(k) - if not context.get("favicon"): - context["favicon"] = "/assets/frappe/images/favicon.ico" - if settings.address: context["footer_address"] = settings.address @@ -125,8 +122,12 @@ def get_website_settings(): via_hooks = frappe.get_hooks("website_context") for key in via_hooks: context[key] = via_hooks[key] - if key not in ("top_bar_items", "footer_items", "post_login") and isinstance(context[key], (list, tuple)): + if key not in ("top_bar_items", "footer_items", "post_login") \ + and isinstance(context[key], (list, tuple)): context[key] = context[key][0] + if not context.get("favicon"): + context["favicon"] = "/assets/frappe/images/favicon.png" + return context