/** @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.conversation.IncomingCallView; var DesktopPendingConversationView = loop.conversationViews.PendingConversationView; var CallFailedView = loop.conversationViews.CallFailedView; // 2. Standalone webapp var HomeView = loop.webapp.HomeView; var UnsupportedBrowserView = loop.webapp.UnsupportedBrowserView; var UnsupportedDeviceView = loop.webapp.UnsupportedDeviceView; var CallUrlExpiredView = loop.webapp.CallUrlExpiredView; var PendingConversationView = loop.webapp.PendingConversationView; var StartConversationView = loop.webapp.StartConversationView; var FailedConversationView = loop.webapp.FailedConversationView; var EndedConversationView = loop.webapp.EndedConversationView; // 3. Shared components var ConversationToolbar = loop.shared.views.ConversationToolbar; var ConversationView = loop.shared.views.ConversationView; var FeedbackView = loop.shared.views.FeedbackView; // 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 roomListStore = new loop.store.RoomListStore({ dispatcher: dispatcher, mozLoop: {} }); // Local mocks var mockContact = { name: ["Mr Smith"], email: [{ value: "smith@invalid.com" }] }; var mockClient = { requestCallUrl: noop, 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 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() { var body = document.body; body.className = loop.shared.utils.getTargetPlatform(); React.renderComponent(, body); _renderComponentsInIframes(); // Put the title back, in case views changed it. document.title = "Loop UI Components Showcase"; }); })();