From 97f02e144bfedfbca185c4a7d7738e85c4e85910 Mon Sep 17 00:00:00 2001 From: Fergal Moran Date: Mon, 17 Jun 2013 16:49:53 +0100 Subject: [PATCH] Fixed marionette require load timeout --- static/js/app/dss.bootstrapper.js | 20 +++++---- static/js/app/lib/utils.coffee | 3 +- static/js/app/views/header.coffee | 67 ++++++++++++++++++++++++++++ static/js/app/views/header.js | 73 ------------------------------- 4 files changed, 81 insertions(+), 82 deletions(-) create mode 100644 static/js/app/views/header.coffee delete mode 100644 static/js/app/views/header.js diff --git a/static/js/app/dss.bootstrapper.js b/static/js/app/dss.bootstrapper.js index c12a5b5..4c84e83 100644 --- a/static/js/app/dss.bootstrapper.js +++ b/static/js/app/dss.bootstrapper.js @@ -1,5 +1,5 @@ requirejs.config({ - baseUrl: "static/js", + baseUrl: 'static/js', urlArgs: com.podnoms.settings.urlArgs, waitSeconds: 200, paths: { @@ -14,6 +14,7 @@ requirejs.config({ text: 'libs/text', templates: '/templates', app: 'app/appv2', + utils: 'app/lib/utils', vent: 'app/lib/eventAggregator', views: 'app/views', models: 'app/models', @@ -24,25 +25,28 @@ requirejs.config({ shim: { backbone: { exports: 'Backbone', - deps: ['underscore'] + deps: ['jquery', 'underscore'] + }, + bootstrap: { + exports: 'bootstrap', + deps: ['jquery'] }, marionette: { exports: 'Marionette', - deps: ['backbone'] + deps: ['jquery', 'backbone'] }, underscore: { exports: '_' }, - 'toastr': { - deps: ['jquery'], - exports: 'toastr' + utils: { + deps: ['jquery', 'bootstrap'] } } }); requirejs(['toastr', 'underscore', 'backbone', 'app'], function (toastr, _, Backbone, App) { - "use strict" + 'use strict' - console.log("Dss.Bootstrapper: primed"); + console.log('Dss.Bootstrapper: primed'); App.start(); }); diff --git a/static/js/app/lib/utils.coffee b/static/js/app/lib/utils.coffee index d9a2c2e..a3af839 100644 --- a/static/js/app/lib/utils.coffee +++ b/static/js/app/lib/utils.coffee @@ -1,4 +1,4 @@ -define['jquery', 'bootstrap'] +define ['jquery', 'bootstrap'] ($, bootstrap) -> class Utils @@ -13,6 +13,7 @@ define['jquery', 'bootstrap'] ).success -> $("input:text:visible:first").focus() true + checkPlayCount: -> if document.cookie.indexOf("sessionId") $.getJSON "/ajax/session_play_count", (data) -> diff --git a/static/js/app/views/header.coffee b/static/js/app/views/header.coffee new file mode 100644 index 0000000..00e3cf5 --- /dev/null +++ b/static/js/app/views/header.coffee @@ -0,0 +1,67 @@ +### +@license + +---------------------------------------------- + +Copyright (c) 2012, Fergal Moran. All rights reserved. +Code provided under the BSD License: +### +define ["underscore", "backbone", "vent", "utils", "text!/tpl/HeaderView"], (_, Backbone, vent, utils, Template) -> + class HeaderView extends Backbone.View + template: _.template(Template) + events: + "click #header-play-pause-button": "togglePlayState" + "click #header-login-button": "login" + "click #header-live-button": "playLive" + + initialize: -> + @render() + @listenTo vent, "mix:play", @trackPlaying + @listenTo vent, "mix:pause", @trackPaused + + login: -> + utils.modal "tpl/LoginView" + + logout: -> + utils.showAlert "Success", "You are now logged out" + + trackChanged: (data) -> + $(@el).find("#track-description").text data.title + $(@el).find("#track-description").attr "href", "#" + data.item_url + + trackPlaying: (data) -> + $(@el).find("#header-play-button-icon").removeClass "icon-play" + $(@el).find("#header-play-button-icon").addClass "icon-pause" + + trackPaused: (data) -> + $(@el).find("#header-play-button-icon").removeClass "icon-pause" + $(@el).find("#header-play-button-icon").addClass "icon-play" + + render: -> + $(@el).html @template() + this + + playLive: -> + ref = this + dssSoundHandler.playLive() + _eventAggregator.trigger "track_playing" + button = $(@el).find("#header-play-pause-button") + button.data "mode", "pause" + $.getJSON "ajax/live_now_playing/", (data) -> + alert data.title + $(ref.el).find("#live-now-playing").text data.title + + + togglePlayState: -> + button = $(@el).find("#header-play-pause-button") + mode = button.data("mode") + if mode is "play" + dssSoundHandler.resumeSound() + _eventAggregator.trigger "track_playing" + button.data "mode", "pause" + else + dssSoundHandler.pauseSound() + _eventAggregator.trigger "track_paused" + button.data "mode", "play" + + HeaderView \ No newline at end of file diff --git a/static/js/app/views/header.js b/static/js/app/views/header.js deleted file mode 100644 index 1183cf1..0000000 --- a/static/js/app/views/header.js +++ /dev/null @@ -1,73 +0,0 @@ -/** @license - - ---------------------------------------------- - - Copyright (c) 2012, Fergal Moran. All rights reserved. - Code provided under the BSD License: - - */ -define(['underscore', 'backbone', 'vent', 'text!/tpl/HeaderView'], - function (_, Backbone, vent, Template) { - return Backbone.View.extend({ - template: _.template(Template), - events: { - "click #header-play-pause-button": "togglePlayState", - "click #header-login-button": "login", - "click #header-live-button": "playLive" - }, - initialize: function () { - this.render(); - this.listenTo(vent, 'mix:play', this.trackPlaying); - this.listenTo(vent, 'mix:pause', this.trackPaused); - }, - login: function () { - com.podnoms.utils.modal('tpl/LoginView'); - }, - logout: function () { - com.podnoms.utils.showAlert("Success", "You are now logged out"); - }, - trackChanged: function (data) { - $(this.el).find('#track-description').text(data.title); - $(this.el).find('#track-description').attr("href", "#" + data.item_url); - }, - trackPlaying: function (data) { - $(this.el).find('#header-play-button-icon').removeClass('icon-play'); - $(this.el).find('#header-play-button-icon').addClass('icon-pause'); - - }, - trackPaused: function (data) { - $(this.el).find('#header-play-button-icon').removeClass('icon-pause'); - $(this.el).find('#header-play-button-icon').addClass('icon-play'); - }, - render: function () { - $(this.el).html(this.template()); - return this; - }, - playLive: function () { - var ref = this; - dssSoundHandler.playLive(); - _eventAggregator.trigger("track_playing") - var button = $(this.el).find('#header-play-pause-button'); - button.data("mode", "pause"); - $.getJSON( - 'ajax/live_now_playing/', - function (data) { - alert(data.title); - $(ref.el).find('#live-now-playing').text(data.title); - }); - }, - togglePlayState: function () { - var button = $(this.el).find('#header-play-pause-button'); - var mode = button.data("mode"); - if (mode == "play") { - dssSoundHandler.resumeSound(); - _eventAggregator.trigger("track_playing"); - button.data("mode", "pause"); - } else { - dssSoundHandler.pauseSound(); - _eventAggregator.trigger("track_paused"); - button.data("mode", "play"); - } - } - }); - }); \ No newline at end of file