From b1a66da8c37594de54619bdc282d63b82a644b91 Mon Sep 17 00:00:00 2001 From: Nicolas Perriault Date: Mon, 28 Jul 2014 12:51:42 -0700 Subject: [PATCH] Bug 1000131 (Part 2): Loop expired call url view styling, r=dmose. --- .../loop/content/shared/css/common.css | 64 +++++++++++++++-- .../loop/content/shared/css/conversation.css | 18 +++++ .../loop/content/shared/css/panel.css | 4 -- .../loop/content/shared/css/readme.html | 71 +++++++++++-------- .../loop/standalone/content/js/webapp.js | 63 ++++++++++++++-- .../loop/standalone/content/js/webapp.jsx | 63 ++++++++++++++-- .../loop/standalone/content/l10n/data.ini | 10 ++- .../loop/test/standalone/webapp_test.js | 35 +++++++++ 8 files changed, 273 insertions(+), 55 deletions(-) diff --git a/browser/components/loop/content/shared/css/common.css b/browser/components/loop/content/shared/css/common.css index 207268b5d71b..a4b29eb7e1f1 100644 --- a/browser/components/loop/content/shared/css/common.css +++ b/browser/components/loop/content/shared/css/common.css @@ -15,19 +15,27 @@ body { margin: 0; padding: 0; - font-family: "Helvetica Neue", Helvetica, Arial, sans; - font-size: 14px; + font-family: "Lucida Grande", sans-serif; + font-size: 12px; background: #fbfbfb; } button { - font-size: .9em; /* for some reason, text is larger within -
  • -
  • +
  • +
  • @@ -119,8 +122,8 @@
    • -
    • -
    • +
    • +
    @@ -150,8 +153,8 @@
    • -
    • -
    • +
    • +
    @@ -162,8 +165,8 @@
    • -
    • -
    • +
    • +
    @@ -174,33 +177,25 @@
    • -
    • -
    • +
    • +
    -

    Local audio streaming

    +

    Expired call url view

    -
    -
    -
      -
    • -
    • -
    • -
    +
    +
    + +

    Oops!

    +

    This URL is unavailable.

    -
    - -

    Local video streaming

    - -
    -
    -
      -
    • -
    • -
    • -
    +
    +

    Download Firefox to make free audio and video calls!

    +

    + Get Firefox +

    @@ -230,6 +225,16 @@

    +

    Large buttons

    + +

    + default + info + success + warning + error +

    +

    Alerts

    @@ -242,6 +247,12 @@

    Oops! This is a warning.

    +

    Logos

    + +

    Centered Firefox logo

    + + +

    Incoming call

    diff --git a/browser/components/loop/standalone/content/js/webapp.js b/browser/components/loop/standalone/content/js/webapp.js index c2714d546dc2..e358d182a01e 100644 --- a/browser/components/loop/standalone/content/js/webapp.js +++ b/browser/components/loop/standalone/content/js/webapp.js @@ -32,15 +32,51 @@ loop.webapp = (function($, _, OT, webL10n) { template: _.template('

    ') }); + /** + * Firefox promotion interstitial. Will display only to non-Firefox users. + */ + var PromoteFirefoxView = React.createClass({displayName: 'PromoteFirefoxView', + propTypes: { + helper: React.PropTypes.object.isRequired + }, + + render: function() { + if (this.props.helper.isFirefox(navigator.userAgent)) { + return React.DOM.div(null ); + } + return ( + React.DOM.div( {className:"promote-firefox"}, + React.DOM.h3(null, __("promote_firefox_hello_heading")), + React.DOM.p(null, + React.DOM.a( {className:"btn btn-large btn-success", + href:"https://www.mozilla.org/firefox/"}, + __("get_firefox_button") + ) + ) + ) + ); + } + }); + /** * Expired call URL view. */ var CallUrlExpiredView = React.createClass({displayName: 'CallUrlExpiredView', + propTypes: { + helper: React.PropTypes.object.isRequired + }, + render: function() { /* jshint ignore:start */ return ( - // XXX proper UX/design should be implemented here (see bug 1000131) - React.DOM.div(null, __("call_url_unavailable_notification")) + React.DOM.div( {className:"expired-url-info"}, + React.DOM.div( {className:"info-panel"}, + React.DOM.div( {className:"firefox-logo"} ), + React.DOM.h1(null, __("call_url_unavailable_notification_heading")), + React.DOM.h4(null, __("call_url_unavailable_notification_message")) + ), + PromoteFirefoxView( {helper:this.props.helper} ) + ) ); /* jshint ignore:end */ } @@ -135,7 +171,12 @@ loop.webapp = (function($, _, OT, webL10n) { "call/:token": "initiate" }, - initialize: function() { + initialize: function(options) { + this.helper = options.helper; + if (!this.helper) { + throw new Error("WebappRouter requires an helper object"); + } + // Load default view this.loadView(new HomeView()); @@ -193,7 +234,7 @@ loop.webapp = (function($, _, OT, webL10n) { }, expired: function() { - this.loadReactComponent(CallUrlExpiredView()); + this.loadReactComponent(CallUrlExpiredView({helper: this.helper})); }, /** @@ -238,8 +279,14 @@ loop.webapp = (function($, _, OT, webL10n) { this._iOSRegex = /^(iPad|iPhone|iPod)/; } - WebappHelper.prototype.isIOS = function isIOS(platform) { - return this._iOSRegex.test(platform); + WebappHelper.prototype = { + isFirefox: function(platform) { + return platform.indexOf("Firefox") !== -1; + }, + + isIOS: function(platform) { + return this._iOSRegex.test(platform); + } }; /** @@ -248,6 +295,7 @@ loop.webapp = (function($, _, OT, webL10n) { function init() { var helper = new WebappHelper(); router = new WebappRouter({ + helper: helper, notifier: new sharedViews.NotificationListView({el: "#messages"}), conversation: new sharedModels.ConversationModel({}, { sdk: OT, @@ -267,8 +315,9 @@ loop.webapp = (function($, _, OT, webL10n) { CallUrlExpiredView: CallUrlExpiredView, ConversationFormView: ConversationFormView, HomeView: HomeView, - WebappHelper: WebappHelper, init: init, + PromoteFirefoxView: PromoteFirefoxView, + WebappHelper: WebappHelper, WebappRouter: WebappRouter }; })(jQuery, _, window.OT, document.webL10n); diff --git a/browser/components/loop/standalone/content/js/webapp.jsx b/browser/components/loop/standalone/content/js/webapp.jsx index a3d90095abf0..8d71253c192e 100644 --- a/browser/components/loop/standalone/content/js/webapp.jsx +++ b/browser/components/loop/standalone/content/js/webapp.jsx @@ -32,15 +32,51 @@ loop.webapp = (function($, _, OT, webL10n) { template: _.template('

    ') }); + /** + * Firefox promotion interstitial. Will display only to non-Firefox users. + */ + var PromoteFirefoxView = React.createClass({ + propTypes: { + helper: React.PropTypes.object.isRequired + }, + + render: function() { + if (this.props.helper.isFirefox(navigator.userAgent)) { + return
    ; + } + return ( +
    +

    {__("promote_firefox_hello_heading")}

    +

    + + {__("get_firefox_button")} + +

    +
    + ); + } + }); + /** * Expired call URL view. */ var CallUrlExpiredView = React.createClass({ + propTypes: { + helper: React.PropTypes.object.isRequired + }, + render: function() { /* jshint ignore:start */ return ( - // XXX proper UX/design should be implemented here (see bug 1000131) -
    {__("call_url_unavailable_notification")}
    +
    +
    +
    +

    {__("call_url_unavailable_notification_heading")}

    +

    {__("call_url_unavailable_notification_message")}

    +
    + +
    ); /* jshint ignore:end */ } @@ -135,7 +171,12 @@ loop.webapp = (function($, _, OT, webL10n) { "call/:token": "initiate" }, - initialize: function() { + initialize: function(options) { + this.helper = options.helper; + if (!this.helper) { + throw new Error("WebappRouter requires an helper object"); + } + // Load default view this.loadView(new HomeView()); @@ -193,7 +234,7 @@ loop.webapp = (function($, _, OT, webL10n) { }, expired: function() { - this.loadReactComponent(CallUrlExpiredView()); + this.loadReactComponent(CallUrlExpiredView({helper: this.helper})); }, /** @@ -238,8 +279,14 @@ loop.webapp = (function($, _, OT, webL10n) { this._iOSRegex = /^(iPad|iPhone|iPod)/; } - WebappHelper.prototype.isIOS = function isIOS(platform) { - return this._iOSRegex.test(platform); + WebappHelper.prototype = { + isFirefox: function(platform) { + return platform.indexOf("Firefox") !== -1; + }, + + isIOS: function(platform) { + return this._iOSRegex.test(platform); + } }; /** @@ -248,6 +295,7 @@ loop.webapp = (function($, _, OT, webL10n) { function init() { var helper = new WebappHelper(); router = new WebappRouter({ + helper: helper, notifier: new sharedViews.NotificationListView({el: "#messages"}), conversation: new sharedModels.ConversationModel({}, { sdk: OT, @@ -267,8 +315,9 @@ loop.webapp = (function($, _, OT, webL10n) { CallUrlExpiredView: CallUrlExpiredView, ConversationFormView: ConversationFormView, HomeView: HomeView, - WebappHelper: WebappHelper, init: init, + PromoteFirefoxView: PromoteFirefoxView, + WebappHelper: WebappHelper, WebappRouter: WebappRouter }; })(jQuery, _, window.OT, document.webL10n); diff --git a/browser/components/loop/standalone/content/l10n/data.ini b/browser/components/loop/standalone/content/l10n/data.ini index f6887e332174..fa3f729581fb 100644 --- a/browser/components/loop/standalone/content/l10n/data.ini +++ b/browser/components/loop/standalone/content/l10n/data.ini @@ -19,7 +19,10 @@ incompatible_device=Incompatible device sorry_device_unsupported=Sorry, Loop does not currently support your device. use_firefox_windows_mac_linux=Please open this page using the latest Firefox on Windows, Android, Mac or Linux. connection_error_see_console_notification=Call failed; see console for details. -call_url_unavailable_notification=This URL is unavailable. +call_url_unavailable_notification_heading=Oops! +call_url_unavailable_notification_message=This URL is unavailable. +promote_firefox_hello_heading=Download Firefox to make free audio and video calls! +get_firefox_button=Get Firefox [fr] call_has_ended=L'appel est terminé. @@ -41,4 +44,7 @@ use_latest_firefox.innerHTML=Veuillez essayer ce lien dans un navigateur accepta incompatible_device=Plateforme non supportée sorry_device_unsupported=Désolé, Loop ne fonctionne actuellement pas sur votre appareil. use_firefox_windows_mac_linux=Merci d'ouvrir cette page avec une version récente de Firefox pour Windows, Android, Mac ou Linux. -call_url_unavailable_notification=Cette URL n'est pas disponible. +call_url_unavailable_notification_heading=Oups ! +call_url_unavailable_notification_message=Cette URL n'est pas disponible. +promote_firefox_hello_heading=Téléchargez Firefox pour passer des appels audio et vidéo gratuitement ! +get_firefox_button=Téléchargez Firefox diff --git a/browser/components/loop/test/standalone/webapp_test.js b/browser/components/loop/test/standalone/webapp_test.js index c700da3ba8f4..fa5ae49b167b 100644 --- a/browser/components/loop/test/standalone/webapp_test.js +++ b/browser/components/loop/test/standalone/webapp_test.js @@ -5,6 +5,7 @@ /* global loop, sinon */ var expect = chai.expect; +var TestUtils = React.addons.TestUtils; describe("loop.webapp", function() { "use strict"; @@ -76,6 +77,7 @@ describe("loop.webapp", function() { pendingCallTimeout: 1000 }); router = new loop.webapp.WebappRouter({ + helper: {}, conversation: conversation, notifier: notifier }); @@ -359,6 +361,26 @@ describe("loop.webapp", function() { }); }); + describe("PromoteFirefoxView", function() { + describe("#render", function() { + it("should not render when using Firefox", function() { + var comp = TestUtils.renderIntoDocument(loop.webapp.PromoteFirefoxView({ + helper: {isFirefox: function() { return true; }} + })); + + expect(comp.getDOMNode().querySelectorAll("h3").length).eql(0); + }); + + it("should render when not using Firefox", function() { + var comp = TestUtils.renderIntoDocument(loop.webapp.PromoteFirefoxView({ + helper: {isFirefox: function() { return false; }} + })); + + expect(comp.getDOMNode().querySelectorAll("h3").length).eql(1); + }); + }); + }); + describe("WebappHelper", function() { var helper; @@ -378,5 +400,18 @@ describe("loop.webapp", function() { expect(helper.isIOS("MacIntel")).eql(false); }); }); + + describe("#isFirefox", function() { + it("should detect Firefox", function() { + expect(helper.isFirefox("Firefox")).eql(true); + expect(helper.isFirefox("Gecko/Firefox")).eql(true); + expect(helper.isFirefox("Firefox/Gecko")).eql(true); + expect(helper.isFirefox("Gecko/Firefox/Chuck Norris")).eql(true); + }); + + it("shouldn't detect Firefox with other platforms", function() { + expect(helper.isFirefox("Opera")).eql(false); + }); + }); }); });