diff --git a/static/js/app.js b/static/js/app.js index 153bf66b..a1496d5d 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -19,177 +19,177 @@ * */ define([ - 'require', - 'jquery', - 'underscore', - 'angular', - 'modernizr', - 'moment', - - 'services/services', - 'directives/directives', - 'filters/filters', - 'controllers/controllers', - - 'translation/languages', - - 'ui-bootstrap', - 'angular-sanitize', - 'angular-animate', - 'angular-humanize', - 'angular-route', - 'mobile-events', - 'dialogs' + 'require', + 'jquery', + 'underscore', + 'angular', + 'modernizr', + 'moment', + + 'services/services', + 'directives/directives', + 'filters/filters', + 'controllers/controllers', + + 'translation/languages', + + 'ui-bootstrap', + 'angular-sanitize', + 'angular-animate', + 'angular-humanize', + 'angular-route', + 'mobile-events', + 'dialogs' ], function(require, $, _, angular, modernizr, moment, services, directives, filters, controllers, languages) { - // Simple and fast split based URL query parser based on location.search. We require this before the - // angular App is bootstrap to control initialization parameters like translation based on URL parameters. - var urlQuery = (function() { - return (function(a) { - if (a === "") { - return {}; - } - var b = {}; - for (var i = 0; i < a.length; ++i) { - var p = a[i].split('='); - if (p.length != 2) { - continue; - } - b[p[0]] = window.decodeURIComponent(p[1].replace(/\+/g, " ")); - } - return b; - })(window.location.search.substr(1).split("&")); - }()); - - var initialize = function(ms) { - - var modules = ['ui.bootstrap', 'ngSanitize', 'ngAnimate', 'ngHumanize', 'ngRoute', 'dialogs']; - if (ms && ms.length) { - _.each(ms, function(module) { - modules.push(module); - }); - } - - var app = angular.module('app', modules); - services.initialize(app); - directives.initialize(app); - filters.initialize(app); - controllers.initialize(app); - - app.config(["$compileProvider", "$locationProvider", "$routeProvider", function($compileProvider, $locationProvider, $routeProvider) { - // Allow angular to use filesystem: hrefs which would else be prefixed with unsafe:. - $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|tel|file|filesystem|blob):/); - $compileProvider.imgSrcSanitizationWhitelist(/^\s*(https?|ftp|file|filesystem|blob):|data:image\//); - // Setup routing - $routeProvider.when("/:room", {}); - // Use HTML5 routing. - $locationProvider.html5Mode(true); - }]); - - app.run(["$rootScope", "mediaStream", "translation", function($rootScope, mediaStream, translation) { - translation.inject($rootScope); - console.log("Initializing ..."); - mediaStream.initialize($rootScope, translation); - }]); - - app.constant("availableLanguages", languages); - - angular.element(document).ready(function() { - - var globalContext = JSON.parse($("#globalcontext").text()); - app.constant("globalContext", globalContext); - - // Configure language. - var lang = (function() { - var lang = "en"; - var wanted = []; - var html = document.getElementsByTagName("html")[0]; - // Get from storage. - if (modernizr.localstorage) { - var lsl = localStorage.getItem("mediastream-language"); - if (lsl && lsl !== "undefined") { - wanted.push(lsl); - } - } - // Get from query. - var qsl = urlQuery.lang; - if (qsl) { - wanted.push(qsl); - } - // Expand browser languages with combined fallback. - _.each(globalContext.Languages, function(l) { - wanted.push(l); - if (l.indexOf("-") != -1) { - wanted.push(l.split("-")[0]); - } - }); - // Loop through browser languages and use first one we got. - for (var i=0; i do nothing. - } else { - scrollAfterInput = false; - // Return scroll function. - return function() { - o.scrollTop = o.scrollHeight; - }; - } - } - return false; - - } - - $scope.display = function(s, nodes, extra_css, title, picture) { - - var container; - var element; - var scroll = this.canScroll(); - lastMessageContainer = null; - - if (!extra_css) { - extra_css = ""; - } - if (s || title || picture) { - container = $('
'); - if (title) { - container.prepend(title); - } - if (picture) { - container.prepend(picture); - } - lastMessageContainer = $("