* VRFS-1832 - making dialogs work everywhere

This commit is contained in:
Seth Call 2014-07-09 17:20:20 -05:00
parent 73d2d537da
commit e47d8c1abb
25 changed files with 148 additions and 129 deletions

View File

@ -659,7 +659,7 @@
// Callbacks from jamClient
if (context.jamClient !== undefined) {
context.jamClient.SendP2PMessage.connect(server.sendP2PMessage);
//context.jamClient.SendP2PMessage.connect(server.sendP2PMessage);
}
function initialize() {

View File

@ -45,3 +45,4 @@
//= require_directory ./wizard
//= require_directory ./wizard/gear
//= require_directory ./wizard/loopback
//= require everywhere/everywhere

View File

@ -9,6 +9,7 @@
context.JK.BackendAlerts = function(app) {
var $document = $(document);
var logger = context.JK.logger;
var ALERT_TYPES = context.JK.ALERT_TYPES;
@ -74,6 +75,7 @@
}
if (type === 2) { // BACKEND_MIXER_CHANGE
if(context.JK.CurrentSessionModel)
context.JK.CurrentSessionModel.onBackendMixerChanged(type, text)
}
else if (type === 19) { // NO_VALID_AUDIO_CONFIG
@ -83,9 +85,11 @@
onStunEvent();
}
else if (type === 26) { // DEAD_USER_REMOVE_EVENT
if(context.JK.CurrentSessionModel)
context.JK.CurrentSessionModel.onDeadUserRemove(type, text);
}
else if (type === 27) { // WINDOW_CLOSE_BACKGROUND_MODE
if(context.JK.CurrentSessionModel)
context.JK.CurrentSessionModel.onWindowBackgrounded(type, text);
}
else if(type != 30 && type != 31 && type != 21){ // these are handled elsewhere
@ -99,7 +103,6 @@
this.initialize = initialize;
context.JK.AlertCallback = alertCallback;
return this;

View File

@ -460,9 +460,10 @@
$(friendInput).focus(function() { $(this).val(''); })
}
function initialize(invitationDialogInstance, inviteMusiciansUtilInstance) {
inviteMusiciansUtil = inviteMusiciansUtilInstance;
friendInput = inviteMusiciansUtil.inviteBandCreate('#band-setup-invite-musicians', "<div class='left w70'>If your bandmates are already on JamKazam, start typing their names in the box below, or click the Choose Friends button to select them.</div>");
function initialize(invitationDialogInstance, friendSelectorDialog) {
inviteMusiciansUtil = new JK.InviteMusiciansUtil(app);
inviteMusiciansUtil.initialize(friendSelectorDialog);
friendInput = inviteMusiciansUtil.inviteBandCreate('#band-setup-invite-musicians', "<div class='left w70'>If your bandmates are already on JamKazam, start typing their names in the box below, or click the Choose Friends button to select them.</div>");
invitationDialog = invitationDialogInstance;
events();

View File

@ -58,7 +58,7 @@
}
hide();
logger.debug("opening banner:" + options.title);
var $h1 = $banner.find('h1');

View File

@ -1,4 +1,10 @@
// Includes code that should be run on every single page of the site
// !!!! Keep white space after last require !!!!
//
//= require fakeJamClient
//= require fakeJamClientMessages
//= require fakeJamClientRecordings
//= require backend_alerts
(function (context, $) {
@ -6,14 +12,65 @@
context.JK = context.JK || {};
$(document).on('JAMKAZAM_READY', function() {
// this event is fired when context.JK.app is initialized
var app = context.JK.app;
function initializeDialogs(app) {
if(!app) throw "JK.app not found"
var backendAlerts = new JK.BackendAlerts(app);
backendAlerts.initialize();
JK.Banner.initialize();
var shutdownDialog = new JK.ShutdownDialog(app);
shutdownDialog.initialize();
var facebookHelper = new JK.FacebookHelper(app);
JK.FacebookHelperInstance = facebookHelper;
facebookHelper.initialize(gon.global.facebook_app_id);
var invitationDialog = new JK.InvitationDialog(app);
JK.InvitationDialogInstance = invitationDialog;
invitationDialog.initialize(facebookHelper);
var textMessageDialog = new JK.TextMessageDialog(app);
JK.TextMessageDialogInstance = textMessageDialog;
textMessageDialog.initialize();
var friendSelectorDialog = new JK.FriendSelectorDialog(app);
JK.FriendSelectorDialogInstance = friendSelectorDialog;
friendSelectorDialog.initialize();
var launchAppDialog = new JK.LaunchAppDialog(app);
launchAppDialog.initialize();
var userDropdown = new JK.UserDropdown(app);
JK.UserDropdown = userDropdown;
userDropdown.initialize(invitationDialog);
var whatsNextDialog = new JK.WhatsNextDialog(app);
whatsNextDialog.initialize(invitationDialog);
var videoDialog = new JK.VideoDialog(app);
videoDialog.initialize();
}
$(document).on('JAMKAZAM_CONSTRUCTED', function(e, data) {
var app = data.app;
if(!app) throw "app not found";
// makes window.jamClient / context.jamClient set to something non-null very early on
context.JK.initJamClient(app);
})
$(document).on('JAMKAZAM_READY', function() {
// this event is fired when context.app is initialized
var app = context.JK.app;
if(!app) throw "app not found"
initializeDialogs(app);
});
})(window, jQuery);

View File

@ -347,7 +347,7 @@
});
}
$(document).triggerHandler('')
$(document).triggerHandler('JAMKAZAM_READY', {app:app})
};
@ -365,6 +365,7 @@
this.clientId = null;
this.initialRouting = initialRouting;
$(document).triggerHandler('JAMKAZAM_CONSTRUCTED', {app:this})
return this;
};

View File

@ -16,12 +16,14 @@
//= require jquery.browser
//= require jquery.custom-protocol
//= require jquery.ba-bbq
//= require jquery.icheck
//= require AAA_Log
//= require AAC_underscore
//= require globals
//= require AAB_message_factory
//= require facebook_helper
//= require layout
//= require user_dropdown
//= require jamkazam
//= require utils
//= require ui_helper
@ -32,4 +34,5 @@
//= require web/signin
//= require landing/init
//= require landing/signup
//= require_directory ../dialog
//= require_directory ../dialog
//= require everywhere/everywhere

View File

@ -1145,9 +1145,12 @@
$(friendInput).focus(function() { $(this).val(''); })
}
function initialize(invitationDialogInstance, inviteMusiciansUtilInstance, instrumentSelectorInstance, instrumentRSVPSelectorInstance) {
function initialize(invitationDialogInstance, friendSelectorDialog, instrumentSelectorInstance, instrumentRSVPSelectorInstance) {
inviteMusiciansUtil = new JK.InviteMusiciansUtil(app);
inviteMusiciansUtil.initialize(friendSelectorDialog);
invitationDialog = invitationDialogInstance;
inviteMusiciansUtil = inviteMusiciansUtilInstance;
friendInput = inviteMusiciansUtil.inviteSessionCreate('#create-session-invite-musicians', "<h3>Who do you want to invite?</h3>"); //'
instrumentSelector = instrumentSelectorInstance;

View File

@ -98,7 +98,6 @@
// Subscribe for callbacks on audio events
context.jamClient.SessionRegisterCallback("JK.HandleBridgeCallback");
context.jamClient.RegisterRecordingCallbacks("JK.HandleRecordingStartResult", "JK.HandleRecordingStopResult", "JK.HandleRecordingStarted", "JK.HandleRecordingStopped", "JK.HandleRecordingAborted");
context.jamClient.SessionSetAlertCallback("JK.AlertCallback");
context.jamClient.SessionSetConnectionStatusRefreshRate(1000);
// If you load this page directly, the loading of the current user
@ -1379,10 +1378,11 @@
.on('change-position', onChangePlayPosition);
}
this.initialize = function(localRecordingsDialogInstance, recordingFinishedDialogInstance, inviteMusiciansUtilInstance) {
this.initialize = function(localRecordingsDialogInstance, recordingFinishedDialogInstance, friendSelectorDialog) {
inviteMusiciansUtil = new JK.InviteMusiciansUtil(JK.app);
inviteMusiciansUtil.initialize(friendSelectorDialog);
localRecordingsDialog = localRecordingsDialogInstance;
recordingFinishedDialog = recordingFinishedDialogInstance;
inviteMusiciansUtil = inviteMusiciansUtilInstance;
context.jamClient.SetVURefreshRate(150);
context.jamClient.RegisterVolChangeCallBack("JK.HandleVolumeChangeCallback");
playbackControls = new context.JK.PlaybackControls($('.session-recordings .recording-controls'));

View File

@ -709,13 +709,13 @@
doneYet();
};
context.JK.initJamClient = function() {
context.JK.initJamClient = function(app) {
// If no jamClient (when not running in native client)
// create a fake one.
if (!(window.jamClient)) {
var p2pMessageFactory = new JK.FakeJamClientMessages();
window.jamClient = new JK.FakeJamClient(JK.app, p2pMessageFactory);
window.jamClient.SetFakeRecordingImpl(new JK.FakeJamClientRecordings(JK.app, jamClient, p2pMessageFactory));
window.jamClient = new JK.FakeJamClient(app, p2pMessageFactory);
window.jamClient.SetFakeRecordingImpl(new JK.FakeJamClientRecordings(app, jamClient, p2pMessageFactory));
}
else if(false) { // set to true to time long running bridge calls
var originalJamClient = window.jamClient;

View File

@ -16,6 +16,7 @@
//= require jquery.browser
//= require jquery.custom-protocol
//= require jquery.ba-bbq
//= require jquery.icheck
//= require AAA_Log
//= require AAC_underscore
//= require globals
@ -49,9 +50,9 @@
//= require web/session_info
//= require web/recordings
//= require web/welcome
//= require banner
//= require fakeJamClient
//= require fakeJamClientMessages
//= require fakeJamClientRecordings
//= require JamServer
//= require_directory ../dialog
//= require everywhere/everywhere

View File

@ -51,7 +51,6 @@
*= require ./genreSelector
*= require ./sessionList
*= require ./searchResults
*= require ./banner
*= require ./clientUpdate
*= require ./musician
*= require ./jquery-ui-overrides

View File

@ -1,5 +1,4 @@
/**
*= require client/banner
*= require client/jamServer
*= require client/ie
*= require client/jamkazam

View File

@ -7,7 +7,6 @@
<div class="dialog-overlay op70" style="display:none; width:100%; height:100%; z-index:99;"></div>
<%= render "banner" %> <!-- banner's overlay must be before dialog-overlay -->
<%= render "header" %>
<%= render "home" %>
@ -44,7 +43,6 @@
<%= render "account_identity" %>
<%= render "affiliate_report" %>
<%= render "account_profile" %>
<%= render "friendSelector" %>
<%= render "account_profile_avatar" %>
<%= render "account_audio_profile" %>
<%= render "account_sessions" %>
@ -58,7 +56,6 @@
<%= render "hoverSession" %>
<%= render "notify" %>
<%= render "client_update" %>
<%= render "clients/banners/disconnected" %>
<%= render "overlay_small" %>
<%= render "help" %>
<%= render 'dialogs/dialogs' %>
@ -129,51 +126,36 @@
var recordingManager = new JK.RecordingManager();
var facebookHelper = new JK.FacebookHelper(JK.app);
JK.FacebookHelperInstance = facebookHelper;
facebookHelper.initialize(gon.global.facebook_app_id);
var invitationDialog = new JK.InvitationDialog(JK.app);
invitationDialog.initialize(facebookHelper);
var textMessageDialog = new JK.TextMessageDialog(JK.app);
JK.TextMessageDialogInstance = textMessageDialog;
textMessageDialog.initialize();
var acceptFriendRequestDialog = new JK.AcceptFriendRequestDialog(JK.app);
var localRecordingsDialog = new JK.LocalRecordingsDialog(JK.app);
localRecordingsDialog.initialize();
var recordingFinishedDialog = new JK.RecordingFinishedDialog(JK.app);
recordingFinishedDialog.initialize();
var friendSelectorDialog = new JK.FriendSelectorDialog(JK.app);
friendSelectorDialog.initialize();
var launchAppDialog = new JK.LaunchAppDialog(JK.app);
launchAppDialog.initialize();
var editRecordingDialog = new JK.EditRecordingDialog(JK.app);
editRecordingDialog.initialize();
var userDropdown = new JK.UserDropdown(JK.app);
JK.UserDropdown = userDropdown;
userDropdown.initialize(invitationDialog);
var header = new JK.Header(JK.app);
JK.Header = header;
header.initialize();
var sidebar = new JK.Sidebar(JK.app);
acceptFriendRequestDialog.initialize(sidebar);
sidebar.initialize(invitationDialog, textMessageDialog);
sidebar.initialize(JK.InvitationDialogInstance, JK.TextMessageDialogInstance);
var editRecordingDialog = new JK.EditRecordingDialog(JK.app);
editRecordingDialog.initialize();
var recordingFinishedDialog = new JK.RecordingFinishedDialog(JK.app);
recordingFinishedDialog.initialize();
var localRecordingsDialog = new JK.LocalRecordingsDialog(JK.app);
localRecordingsDialog.initialize();
var configureTracksDialog = new JK.ConfigureTracksDialog(JK.app);
configureTracksDialog.initialize();
var networkTestDialog = new JK.NetworkTestDialog(JK.app);
networkTestDialog.initialize();
var homeScreen = new JK.HomeScreen(JK.app);
homeScreen.initialize();
var profileScreen = new JK.ProfileScreen(JK.app);
profileScreen.initialize(textMessageDialog);
profileScreen.initialize(JK.TextMessageDialogInstance);
var bandProfileScreen = new JK.BandProfileScreen(JK.app);
bandProfileScreen.initialize();
@ -188,7 +170,7 @@
accountSessionsScreen.initialize();
var accountSessionDetailScreen = new JK.AccountSessionDetail(JK.app);
accountSessionDetailScreen.initialize(invitationDialog);
accountSessionDetailScreen.initialize(JK.InvitationDialogInstance);
var accountSessionPropertiesScreen = new JK.AccountSessionProperties(JK.app);
accountSessionPropertiesScreen.initialize();
@ -200,7 +182,7 @@
accountProfileScreen.initialize();
var accountProfileAvatarScreen = new JK.AccountProfileAvatarScreen(JK.app);
accountProfileAvatarScreen.initialize(userDropdown);
accountProfileAvatarScreen.initialize(JK.UserDropdown);
var accountAudioProfile = new JK.AccountAudioProfile(JK.app);
accountAudioProfile.initialize();
@ -208,26 +190,20 @@
var searchResultScreen = new JK.SearchResultScreen(JK.app);
searchResultScreen.initialize();
var inviteMusiciansUtil1 = new JK.InviteMusiciansUtil(JK.app);
inviteMusiciansUtil1.initialize(friendSelectorDialog);
// var createSessionScreen = new JK.CreateSessionScreen(JK.app);
// createSessionScreen.initialize(invitationDialog, inviteMusiciansUtil1);
var instrumentSelectorInstance = new JK.InstrumentSelector(JK.app);
instrumentSelectorInstance.initialize(false);
var instrumentSelectorRSVPInstance = new JK.InstrumentSelector(JK.app);
instrumentSelectorRSVPInstance.initialize(true);
var createScheduledSessionScreen = new JK.CreateScheduledSession(JK.app);
createScheduledSessionScreen.initialize(
invitationDialog,
inviteMusiciansUtil1,
JK.InvitationDialogInstance,
JK.FriendSelectorDialogInstance,
instrumentSelectorInstance,
instrumentSelectorRSVPInstance
);
var inviteMusiciansUtil2 = new JK.InviteMusiciansUtil(JK.app);
inviteMusiciansUtil2.initialize(friendSelectorDialog);
var bandSetupScreen = new JK.BandSetupScreen(JK.app);
bandSetupScreen.initialize(invitationDialog, inviteMusiciansUtil2);
bandSetupScreen.initialize(JK.InvitationDialogInstance, JK.FriendSelectorDialogInstance);
var bandSetupPhotoScreen = new JK.BandSetupPhotoScreen(JK.app);
bandSetupPhotoScreen.initialize();
@ -244,38 +220,23 @@
// findSessionScreen.initialize(sessionLatency);
var findMusicianScreen = new JK.FindMusicianScreen(JK.app);
findMusicianScreen.initialize(textMessageDialog);
findMusicianScreen.initialize(JK.TextMessageDialogInstance);
var findBandScreen = new JK.FindBandScreen(JK.app);
findBandScreen.initialize();
var inviteMusiciansUtil3 = new JK.InviteMusiciansUtil(JK.app);
inviteMusiciansUtil3.initialize(friendSelectorDialog);
var sessionScreen = new JK.SessionScreen(JK.app);
sessionScreen.initialize(localRecordingsDialog, recordingFinishedDialog, inviteMusiciansUtil3);
sessionScreen.initialize(localRecordingsDialog, recordingFinishedDialog, JK.FriendSelectorDialogInstance);
var sessionSettingsDialog = new JK.SessionSettingsDialog(JK.app, sessionScreen);
sessionSettingsDialog.initialize();
var whatsNextDialog = new JK.WhatsNextDialog(JK.app);
whatsNextDialog.initialize(invitationDialog);
//var ftueWizard = new JK.FtueWizard(JK.app);
//ftueWizard.initialize();
var loopbackWizard = new JK.LoopbackWizard(JK.app);
loopbackWizard.initialize();
var gearWizard = new JK.GearWizard(JK.app);
gearWizard.initialize(loopbackWizard);
var configureTracksDialog = new JK.ConfigureTracksDialog(JK.app);
configureTracksDialog.initialize();
var networkTestDialog = new JK.NetworkTestDialog(JK.app);
networkTestDialog.initialize();
var testBridgeScreen = new JK.TestBridgeScreen(JK.app);
testBridgeScreen.initialize();
@ -287,16 +248,12 @@
var jamServer = new JK.JamServer(JK.app, function(event_type) {JK.app.activeElementEvent(event_type)});
jamServer.initialize();
JK.initJamClient();
// latency_tester does not want to be here - redirect it
if(window.jamClient.getOperatingMode && window.jamClient.getOperatingMode() == "server") {
window.location = "/latency_tester";
return;
}
JK.Banner.initialize();
// Let's get things rolling...
if (JK.currentUserId) {
@ -319,10 +276,6 @@
// this ensures that there is always a CurrentSessionModel, even if it's for a non-active session
JK.CurrentSessionModel = new JK.SessionModel(JK.app, JK.JamServer, window.jamClient, null);
}
// make surethe CurrentSessionModel exists before initializing backend alerts
var backendAlerts = new JK.BackendAlerts(JK.app);
backendAlerts.initialize();
JK.bindHoverEvents();
})

View File

@ -1,5 +1,7 @@
// pulls in all dialogs
= render 'dialogs/banner'
= render 'dialogs/banners/disconnected'
= render 'dialogs/leaveSessionWarningDialog'
= render 'dialogs/configure_tracks_dialog'
= render 'dialogs/edit_recording_dialog'
@ -19,4 +21,5 @@
= render 'dialogs/sessionCancelDialog'
= render 'dialogs/signinDialog'
= render 'dialogs/signupDialog'
= render 'dialogs/videoDialog'
= render 'dialogs/videoDialog'
= render 'dialogs/friendSelectorDialog'

View File

@ -70,8 +70,6 @@
<%= render "clients/footer" %>
</div>
<%= render "clients/banner" %>
<%= render "clients/banners/disconnected" %>
<%= render "clients/jamServer" %>
<%= render "clients/notify" %>
<%= render "clients/hoverMusician" %>
@ -105,33 +103,16 @@
var jamServer = new JK.JamServer(JK.app, $.noop);
jamServer.initialize();
// JamServer.connect needs the jamClient to be initialized
JK.initJamClient();
JK.app.initialize({inClient: false, layoutOpts: {layoutFooter: false, sizeOverlayToContent: true}});
var facebookHelper = new JK.FacebookHelper(JK.app);
JK.FacebookHelperInstance = facebookHelper;
facebookHelper.initialize(gon.global.facebook_app_id);
var invitationDialog = new JK.InvitationDialog(JK.app);
invitationDialog.initialize(facebookHelper);
var userDropdown = new JK.UserDropdown(JK.app);
userDropdown.initialize(invitationDialog);
var signupDialog = new JK.SignupDialog(JK.app);
signupDialog.initialize();
var signinDialog = new JK.SigninDialog(JK.app);
signinDialog.initialize();
var videoDialog = new JK.VideoDialog(JK.app);
videoDialog.initialize();
JK.bindHoverEvents();
JK.JamServer.connect() // singleton here defined in JamServer.js
.done(function() {
console.log("websocket connected")

View File

@ -9,10 +9,10 @@ describe "Accept Friend Request", :js => true, :type => :feature, :capybara_feat
let (:friend_request) { FactoryGirl.create(:friend_request, user: @user2, friend: @user1) }
before(:each) do
stub_const("APP_CONFIG", web_config)
@user1 = FactoryGirl.create(:user)
@user2 = FactoryGirl.create(:user, first_name: 'bone_crusher')
sign_in_poltergeist(@user1)
stub_const("APP_CONFIG", web_config)
end
describe "dialog behavior" do

View File

@ -9,7 +9,7 @@ describe "Profile History", :js => true, :type => :feature, :capybara_feature =>
before do
MusicSession.delete_all
Recording.delete_all
sign_in_poltergeist user
set_login_cookie user
stub_const("APP_CONFIG", web_config)
end

View File

@ -101,10 +101,26 @@ def sign_in_poltergeist(user, options = {})
validate = options[:validate]
validate = true if validate.nil?
uri = URI.parse(current_url)
# in tests, we often have an issue where an old signin screen is unloading
# as this one is loading.
# so one way to fix this is to go to a different page in this case, and then come back to /signin
if uri.path == signin_path
visit '/'
should_be_at_root
end
visit signin_path
fill_in "Email Address:", with: user.email
fill_in "Password:", with: user.password
click_button "SIGN IN"
within('#landing-inner form.signin-form') do
fill_in "Email Address:", with: user.email
fill_in "Password:", with: user.password
click_button "SIGN IN"
end
page.should have_no_selector('h1', text: 'sign in or register')
wait_until_curtain_gone
@ -114,7 +130,7 @@ end
# skip the typical login form, which redirects to /client (sloooow). Just sets the cookie, and puts you where you want to be
def fast_signin(user, url)
page.driver.set_cookie(:remember_token, user.remember_token)
set_login_cookie(user)
visit url
end
@ -124,6 +140,10 @@ def fast_signout
visit '/'
end
def set_login_cookie(user)
page.driver.set_cookie(:remember_token, user.remember_token)
end
def sign_out()
if Capybara.javascript_driver == :poltergeist
page.driver.remove_cookie(:remember_token)
@ -247,9 +267,7 @@ def create_session(options={})
in_client(creator) do
page.driver.resize(1500, 800) # makes sure all the elements are visible
emulate_client
sign_in_poltergeist creator
wait_until_curtain_gone
visit "/client#/createSession"
fast_signin(creator, "/client#/createSession")
expect(page).to have_selector('h1', text: 'create session')
within('#create-session-form') do
@ -328,9 +346,7 @@ def schedule_session(options = {})
in_client(creator) do
page.driver.resize(1500, 800) # makes sure all the elements are visible
emulate_client
sign_in_poltergeist creator
wait_until_curtain_gone
visit "/client#/createSession"
fast_signin(creator, "/client#/createSession")
expect(page).to have_selector('h1', text: 'create session')
within('#create-session-form') do
@ -369,9 +385,7 @@ def join_session(joiner, options)
in_client(joiner) do
page.driver.resize(1500, 800) # makes sure all the elements are visible
emulate_client
sign_in_poltergeist joiner
wait_until_curtain_gone
visit "/client#/findSession"
fast_signin(joiner, "/client#/findSession")
# verify the session description is seen by second client
expect(page).to have_text(description)