From 3fd7c44331d764f579396a9b4eb5000d8a047829 Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Thu, 13 Jun 2013 18:25:02 -0400 Subject: [PATCH] Tweak desktop app JS to support Cocoa WebScript (imported from commit 6b0c3442f92cffedbd210530479a13d4af5ea266) --- tools/jslint/check-all.js | 3 +++ zephyr/static/js/notifications.js | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/jslint/check-all.js b/tools/jslint/check-all.js index a3d3c903e2..a882c17326 100644 --- a/tools/jslint/check-all.js +++ b/tools/jslint/check-all.js @@ -5,6 +5,9 @@ var globals = // Third-party libraries ' $ jQuery Spinner Handlebars XDate zxcvbn Intl mixpanel' + // Cocoa<-> Javascript bridge + + ' bridge' + // index.html + ' page_params' diff --git a/zephyr/static/js/notifications.js b/zephyr/static/js/notifications.js index c0a6c21ec7..10cc20c642 100644 --- a/zephyr/static/js/notifications.js +++ b/zephyr/static/js/notifications.js @@ -182,7 +182,7 @@ function process_desktop_notification(message) { notification_object.show(); } else { // Shunt the message along to the desktop client - window.bridge.desktopNotification({title: title, content: content}); + window.bridge.desktopNotification(title, content); } } @@ -232,6 +232,14 @@ exports.received_messages = function (messages) { }); }; +$(function () { + // Shim for Cocoa WebScript exporting top-level JS + // objects instead of window.foo objects + if (typeof(bridge) !== 'undefined' && window.bridge === undefined) { + window.bridge = bridge; + } +}); + return exports; }());