Browse Source

[notifications] added to title and new favicon

version-14
Rushabh Mehta 10 years ago
parent
commit
c34221a58e
15 changed files with 68 additions and 33 deletions
  1. +1
    -1
      frappe/core/page/desktop/desktop.js
  2. +5
    -0
      frappe/desk/page/messages/messages.js
  3. BIN
      frappe/public/images/favicon.ico
  4. BIN
      frappe/public/images/favicon.png
  5. +9
    -15
      frappe/public/js/frappe/desk.js
  6. +1
    -1
      frappe/public/js/frappe/form/toolbar.js
  7. +38
    -0
      frappe/public/js/frappe/misc/utils.js
  8. +2
    -2
      frappe/public/js/frappe/router.js
  9. +1
    -1
      frappe/public/js/frappe/ui/listing.js
  10. +1
    -1
      frappe/public/js/frappe/ui/page.js
  11. +0
    -3
      frappe/public/js/legacy/dom.js
  12. +1
    -1
      frappe/public/js/legacy/form.js
  13. +2
    -2
      frappe/templates/base.html
  14. +2
    -2
      frappe/templates/pages/desk.html
  15. +5
    -4
      frappe/website/doctype/website_settings/website_settings.py

+ 1
- 1
frappe/core/page/desktop/desktop.js View File

@@ -18,7 +18,7 @@ $.extend(frappe.desktop, {


render: function() { render: function() {
var me = this; var me = this;
document.title = "Desktop";
frappe.utils.set_title("Desktop");


this.wrapper.html(frappe.render_template("desktop_icon_grid", { this.wrapper.html(frappe.render_template("desktop_icon_grid", {
// all visible icons // all visible icons


+ 5
- 0
frappe/desk/page/messages/messages.js View File

@@ -19,6 +19,11 @@ frappe.pages.messages.on_page_load = function(parent) {
frappe.desk.pages.messages = new frappe.desk.pages.Messages(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({ frappe.desk.pages.Messages = Class.extend({
init: function(wrapper, page) { init: function(wrapper, page) {
this.wrapper = wrapper; this.wrapper = wrapper;


BIN
frappe/public/images/favicon.ico View File

Before After

BIN
frappe/public/images/favicon.png View File

Before After
Width: 32  |  Height: 32  |  Size: 1.3 KiB

+ 9
- 15
frappe/public/js/frappe/desk.js View File

@@ -109,13 +109,13 @@ frappe.Application = Class.extend({
me.update_notification_count_in_modules(); me.update_notification_count_in_modules();


if(frappe.get_route()[0] != "messages") { 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() { update_notification_count_in_modules: function() {


+ 1
- 1
frappe/public/js/frappe/form/toolbar.js View File

@@ -44,7 +44,7 @@ frappe.ui.form.Toolbar = Class.extend({
var me = this; var me = this;
this.page.set_title(title); this.page.set_title(title);
if(this.frm.meta.title_field) { if(this.frm.meta.title_field) {
document.title = title + " - " + this.frm.docname;
frappe.utils.set_title(title + " - " + this.frm.docname);
} }
this.set_indicator(); this.set_indicator();
}, },


+ 38
- 0
frappe/public/js/frappe/misc/utils.js View File

@@ -448,4 +448,42 @@ frappe.utils = {
warn_page_name_change: function(frm) { warn_page_name_change: function(frm) {
frappe.msgprint("Note: Changing the Page Name will break previous URL to this page."); 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);
}
}; };

+ 2
- 2
frappe/public/js/frappe/router.js View File

@@ -47,7 +47,7 @@ frappe.route = function() {
} }


if(frappe.route_titles[window.location.hash]) { 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() { $(window).on('hashchange', function() {
// save the title // 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) if(window.location.hash==frappe._cur_route)
return; return;


+ 1
- 1
frappe/public/js/frappe/ui/listing.js View File

@@ -173,7 +173,7 @@ frappe.ui.Listing = Class.extend({
return frappe.call({ return frappe.call({
method: this.opts.method || 'frappe.desk.query_builder.runquery', method: this.opts.method || 'frappe.desk.query_builder.runquery',
type: "GET", type: "GET",
freeze: this.opts.freeze || true,
freeze: (this.opts.freeze != undefined ? this.opts.freeze : true),
args: this.get_call_args(), args: this.get_call_args(),
callback: function(r) { callback: function(r) {
if(!me.opts.no_loading) if(!me.opts.no_loading)


+ 1
- 1
frappe/public/js/frappe/ui/page.js View File

@@ -239,7 +239,7 @@ frappe.ui.Page = Class.extend({
set_title: function(txt, icon) { set_title: function(txt, icon) {
// strip icon // strip icon
this.title = txt; this.title = txt;
document.title = txt.replace(/<[^>]*>/g, "");
frappe.utils.set_title(txt.replace(/<[^>]*>/g, ""));
if(icon) { if(icon) {
txt = '<span class="'+ icon +' text-muted" style="font-size: inherit;"></span> ' + txt; txt = '<span class="'+ icon +' text-muted" style="font-size: inherit;"></span> ' + txt;
} }


+ 0
- 3
frappe/public/js/legacy/dom.js View File

@@ -42,9 +42,6 @@ function add_sel_options(s, list, sel_val, o_style) {
} }


var $n = '\n'; var $n = '\n';
function set_title(t) {
document.title = (frappe.title_prefix ? (frappe.title_prefix + ' - ') : '') + t;
}


function $a(parent, newtag, className, cs, innerHTML, onclick) { function $a(parent, newtag, className, cs, innerHTML, onclick) {
if(parent && parent.substr)parent = $i(parent); if(parent && parent.substr)parent = $i(parent);


+ 1
- 1
frappe/public/js/legacy/form.js View File

@@ -302,7 +302,7 @@ _f.Frm.prototype.refresh_header = function() {
// set title // set title
// main title // main title
if(!this.meta.in_dialog || this.in_form) { 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) if(frappe.ui.toolbar.recent)


+ 2
- 2
frappe/templates/base.html View File

@@ -11,10 +11,10 @@


{% block favicon %} {% block favicon %}
<link rel="shortcut icon" <link rel="shortcut icon"
href="{{ (favicon or "/assets/frappe/images/favicon.ico") | with_leading_slash }}"
href="{{ (favicon or "/assets/frappe/images/favicon.png") | with_leading_slash }}"
type="image/x-icon"> type="image/x-icon">
<link rel="icon" <link rel="icon"
href="{{ (favicon or "/assets/frappe/images/favicon.ico") | with_leading_slash }}"
href="{{ (favicon or "/assets/frappe/images/favicon.png") | with_leading_slash }}"
type="image/x-icon"> type="image/x-icon">
{% endblock %} {% endblock %}
{%- block head -%} {%- block head -%}


+ 2
- 2
frappe/templates/pages/desk.html View File

@@ -11,9 +11,9 @@
<meta name="mobile-web-app-capable" content="yes"> <meta name="mobile-web-app-capable" content="yes">
<title>Frappe Desk</title> <title>Frappe Desk</title>
<link rel="shortcut icon" <link rel="shortcut icon"
href="{{ favicon or "/assets/frappe/images/favicon.ico" }}" type="image/x-icon">
href="{{ favicon or "/assets/frappe/images/favicon.png" }}" type="image/x-icon">
<link rel="icon" <link rel="icon"
href="{{ favicon or "/assets/frappe/images/favicon.ico" }}" type="image/x-icon">
href="{{ favicon or "/assets/frappe/images/favicon.png" }}" type="image/x-icon">
{% for include in include_css -%} {% for include in include_css -%}
<link type="text/css" rel="stylesheet" href="{{ include }}"> <link type="text/css" rel="stylesheet" href="{{ include }}">
{%- endfor -%} {%- endfor -%}


+ 5
- 4
frappe/website/doctype/website_settings/website_settings.py View File

@@ -98,9 +98,6 @@ def get_website_settings():
if hasattr(settings, k): if hasattr(settings, k):
context[k] = settings.get(k) context[k] = settings.get(k)


if not context.get("favicon"):
context["favicon"] = "/assets/frappe/images/favicon.ico"

if settings.address: if settings.address:
context["footer_address"] = settings.address context["footer_address"] = settings.address


@@ -125,8 +122,12 @@ def get_website_settings():
via_hooks = frappe.get_hooks("website_context") via_hooks = frappe.get_hooks("website_context")
for key in via_hooks: for key in via_hooks:
context[key] = via_hooks[key] 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] context[key] = context[key][0]


if not context.get("favicon"):
context["favicon"] = "/assets/frappe/images/favicon.png"

return context return context



Loading…
Cancel
Save