/** @jsx React.DOM */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ /* jshint newcap:false */ /* global loop:true, React */ (function() { "use strict"; // Stop the default init functions running to avoid conflicts. document.removeEventListener('DOMContentLoaded', loop.panel.init); document.removeEventListener('DOMContentLoaded', loop.conversation.init); // 1. Desktop components // 1.1 Panel var PanelView = loop.panel.PanelView; // 1.2. Conversation Window var IncomingCallView = loop.conversationViews.IncomingCallView; var DesktopPendingConversationView = loop.conversationViews.PendingConversationView; var CallFailedView = loop.conversationViews.CallFailedView; var DesktopRoomConversationView = loop.roomViews.DesktopRoomConversationView; // 2. Standalone webapp var HomeView = loop.webapp.HomeView; var UnsupportedBrowserView = loop.webapp.UnsupportedBrowserView; var UnsupportedDeviceView = loop.webapp.UnsupportedDeviceView; var CallUrlExpiredView = loop.webapp.CallUrlExpiredView; var GumPromptConversationView = loop.webapp.GumPromptConversationView; var WaitingConversationView = loop.webapp.WaitingConversationView; var StartConversationView = loop.webapp.StartConversationView; var FailedConversationView = loop.webapp.FailedConversationView; var EndedConversationView = loop.webapp.EndedConversationView; var StandaloneRoomView = loop.standaloneRoomViews.StandaloneRoomView; // 3. Shared components var ConversationToolbar = loop.shared.views.ConversationToolbar; var ConversationView = loop.shared.views.ConversationView; var FeedbackView = loop.shared.views.FeedbackView; // Store constants var ROOM_STATES = loop.store.ROOM_STATES; var FEEDBACK_STATES = loop.store.FEEDBACK_STATES; // Local helpers function returnTrue() { return true; } function returnFalse() { return false; } function noop(){} // Feedback API client configured to send data to the stage input server, // which is available at https://input.allizom.org var stageFeedbackApiClient = new loop.FeedbackAPIClient( "https://input.allizom.org/api/v1/feedback", { product: "Loop" } ); var dispatcher = new loop.Dispatcher(); var activeRoomStore = new loop.store.ActiveRoomStore(dispatcher, { mozLoop: navigator.mozLoop, sdkDriver: {} }); var roomStore = new loop.store.RoomStore(dispatcher, { mozLoop: navigator.mozLoop }); var feedbackStore = new loop.store.FeedbackStore(dispatcher, { feedbackClient: stageFeedbackApiClient }); var conversationStore = new loop.store.ConversationStore(dispatcher, { client: {}, mozLoop: navigator.mozLoop, sdkDriver: {} }); loop.store.StoreMixin.register({feedbackStore: feedbackStore}); // Local mocks var mockMozLoopRooms = _.extend({}, navigator.mozLoop); var mockContact = { name: ["Mr Smith"], email: [{ value: "smith@invalid.com" }] }; var mockClient = { requestCallUrlInfo: noop }; var mockSDK = {}; var mockConversationModel = new loop.shared.models.ConversationModel({ callerId: "Mrs Jones", urlCreationDate: (new Date() / 1000).toString() }, { sdk: mockSDK }); mockConversationModel.startSession = noop; var mockWebSocket = new loop.CallConnectionWebSocket({ url: "fake", callId: "fakeId", websocketToken: "fakeToken" }); var notifications = new loop.shared.models.NotificationCollection(); var errNotifications = new loop.shared.models.NotificationCollection(); errNotifications.add({ level: "error", message: "Could Not Authenticate", details: "Did you change your password?", detailsButtonLabel: "Retry", }); var SVGIcon = React.createClass({ render: function() { var sizeUnit = this.props.size.split("x")[0] + "px"; return ( ); } }); var SVGIcons = React.createClass({ shapes: { "10x10": ["close", "close-active", "close-disabled", "dropdown", "dropdown-white", "dropdown-active", "dropdown-disabled", "expand", "expand-active", "expand-disabled", "minimize", "minimize-active", "minimize-disabled" ], "14x14": ["audio", "audio-active", "audio-disabled", "facemute", "facemute-active", "facemute-disabled", "hangup", "hangup-active", "hangup-disabled", "incoming", "incoming-active", "incoming-disabled", "link", "link-active", "link-disabled", "mute", "mute-active", "mute-disabled", "pause", "pause-active", "pause-disabled", "video", "video-white", "video-active", "video-disabled", "volume", "volume-active", "volume-disabled" ], "16x16": ["audio", "audio-hover", "audio-active", "block", "block-red", "block-hover", "block-active", "contacts", "contacts-hover", "contacts-active", "copy", "checkmark", "google", "google-hover", "google-active", "history", "history-hover", "history-active", "leave", "precall", "precall-hover", "precall-active", "screen-white", "screenmute-white", "settings", "settings-hover", "settings-active", "tag", "tag-hover", "tag-active", "trash", "unblock", "unblock-hover", "unblock-active", "video", "video-hover", "video-active", "tour" ] }, render: function() { var icons = this.shapes[this.props.size].map(function(shapeId, i) { return (
  • {shapeId}

  • ); }, this); return ( ); } }); var Example = React.createClass({ makeId: function(prefix) { return (prefix || "") + this.props.summary.toLowerCase().replace(/\s/g, "-"); }, render: function() { var cx = React.addons.classSet; return (

    {this.props.summary}  ¶

    {this.props.children}
    ); } }); var Section = React.createClass({ render: function() { return (

    {this.props.name}

    {this.props.children}
    ); } }); var ShowCase = React.createClass({ render: function() { return (

    Loop UI Components Showcase

    {this.props.children}
    ); } }); var App = React.createClass({ render: function() { return (

    Note: 332px wide.

    Desktop Conversation Window

    Standalone

    Note: For the useable demo, you can access submitted data at  input.allizom.org.

    The person you were calling has ended the conversation.


    The person you were calling has ended the conversation.

    ); } }); /** * Render components that have different styles across * CSS media rules in their own iframe to mimic the viewport * */ function _renderComponentsInIframes() { var parents = document.querySelectorAll('.breakpoint'); [].forEach.call(parents, appendChildInIframe); /** * Extracts the component from the DOM and appends in the an iframe * * @type {HTMLElement} parent - Parent DOM node of a component & iframe * */ function appendChildInIframe(parent) { var styles = document.querySelector('head').children; var component = parent.children[0]; var iframe = document.createElement('iframe'); var width = parent.dataset.breakpointWidth; var height = parent.dataset.breakpointHeight; iframe.style.width = width; iframe.style.height = height; parent.appendChild(iframe); iframe.src = "about:blank"; // Workaround for bug 297685 iframe.onload = function () { var iframeHead = iframe.contentDocument.querySelector('head'); iframe.contentDocument.documentElement.querySelector('body') .appendChild(component); [].forEach.call(styles, function(style) { iframeHead.appendChild(style.cloneNode(true)); }); }; } } window.addEventListener("DOMContentLoaded", function() { try { React.render(, document.body); } catch(err) { console.log(err); } _renderComponentsInIframes(); // Put the title back, in case views changed it. document.title = "Loop UI Components Showcase"; }); })();