* merged in VRFS-1110
This commit is contained in:
commit
8f1d48da40
|
|
@ -11,7 +11,7 @@
|
|||
context.JK.BandSetupScreen = function (app) {
|
||||
var logger = context.JK.logger;
|
||||
var rest = context.JK.Rest();
|
||||
var friendSelectorDialog = null;
|
||||
var inviteMusiciansUtil = null;
|
||||
var invitationDialog = null;
|
||||
var autoComplete = null;
|
||||
var userNames = [];
|
||||
|
|
@ -21,6 +21,7 @@
|
|||
var nilOptionStr = '<option value=""></option>';
|
||||
var nilOptionText = 'n/a';
|
||||
var bandId = '';
|
||||
var friendInput=null;
|
||||
|
||||
function is_new_record() {
|
||||
return bandId.length == 0;
|
||||
|
|
@ -62,7 +63,7 @@
|
|||
$("#band-setup-step-1").show();
|
||||
$("#band-setup-step-2").hide();
|
||||
|
||||
$('#band-invitee-input')
|
||||
$(friendInput)
|
||||
.unbind('blur')
|
||||
.attr("placeholder", "Looking up friends...")
|
||||
.prop('disabled', true)
|
||||
|
|
@ -156,7 +157,7 @@
|
|||
function createBandInvitations(bandId, onComplete) {
|
||||
var callCount = 0;
|
||||
var totalInvitations = 0;
|
||||
$('#selected-band-invitees .invitation').each(function (index, invitation) {
|
||||
$('#selected-friends-band .invitation').each(function (index, invitation) {
|
||||
callCount++;
|
||||
totalInvitations++;
|
||||
var userId = $(invitation).attr('user-id');
|
||||
|
|
@ -179,16 +180,13 @@
|
|||
}
|
||||
|
||||
function beforeShow(data) {
|
||||
userNames = [];
|
||||
userIds = [];
|
||||
userPhotoUrls = [];
|
||||
inviteMusiciansUtil.clearSelections();
|
||||
bandId = data.id == 'new' ? '' : data.id;
|
||||
resetForm();
|
||||
}
|
||||
|
||||
function afterShow(data) {
|
||||
friendSelectorDialog.setCallback(friendSelectorCallback);
|
||||
loadFriends();
|
||||
inviteMusiciansUtil.loadFriends();
|
||||
|
||||
if (!is_new_record()) {
|
||||
$("#band-setup-title").html("edit band");
|
||||
|
|
@ -240,38 +238,6 @@
|
|||
});
|
||||
}
|
||||
|
||||
// TODO: this is repeated in createSession.js.erb
|
||||
function loadFriends() {
|
||||
rest.getFriends({ id: context.JK.currentUserId })
|
||||
.done(function (friends) {
|
||||
$.each(friends, function () {
|
||||
userNames.push(this.name);
|
||||
userIds.push(this.id);
|
||||
userPhotoUrls.push(this.photo_url);
|
||||
});
|
||||
|
||||
var autoCompleteOptions = {
|
||||
lookup: { suggestions: userNames, data: userIds },
|
||||
onSelect: addInvitation
|
||||
};
|
||||
|
||||
$('#band-invitee-input').attr("placeholder", "Type a friend\'s name").prop('disabled', false);
|
||||
|
||||
if (!autoComplete) {
|
||||
autoComplete = $('#band-invitee-input').autocomplete(autoCompleteOptions);
|
||||
}
|
||||
else {
|
||||
autoComplete.setOptions(autoCompleteOptions);
|
||||
}
|
||||
|
||||
$(".autocomplete").width("150px");
|
||||
})
|
||||
.fail(function () {
|
||||
$('#band-invitee-input').attr("placeholder", "Unable to lookup friends");
|
||||
app.ajaxError(arguments)
|
||||
});
|
||||
}
|
||||
|
||||
function loadGenres(selectedGenres) {
|
||||
$("#band-genres").empty();
|
||||
|
||||
|
|
@ -393,13 +359,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
function friendSelectorCallback(newSelections) {
|
||||
var keys = Object.keys(newSelections);
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
addInvitation(newSelections[keys[i]].userName, newSelections[keys[i]].userId);
|
||||
}
|
||||
}
|
||||
|
||||
function addInvitation(value, data) {
|
||||
if ($('#selected-band-invitees div[user-id=' + data + ']').length === 0) {
|
||||
var template = $('#template-band-invitation').html();
|
||||
|
|
@ -462,10 +421,6 @@
|
|||
|
||||
$('#btn-band-setup-save').click(saveBand);
|
||||
|
||||
$('#btn-band-choose-friends').click(function () {
|
||||
friendSelectorDialog.showDialog(selectedFriendIds);
|
||||
});
|
||||
|
||||
$('#band-country').on('change', function (evt) {
|
||||
evt.stopPropagation();
|
||||
loadRegions();
|
||||
|
|
@ -493,10 +448,13 @@
|
|||
$('div[layout-id="band/setup"] .btn-facebook-invitation').click(function () {
|
||||
invitationDialog.showFacebookDialog();
|
||||
});
|
||||
|
||||
$(friendInput).focus(function() { $(this).val(''); })
|
||||
}
|
||||
|
||||
function initialize(invitationDialogInstance, friendSelectorDialogInstance) {
|
||||
friendSelectorDialog = friendSelectorDialogInstance;
|
||||
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>");
|
||||
invitationDialog = invitationDialogInstance;
|
||||
events();
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
var inviteMusiciansUtil = null;
|
||||
var MAX_GENRES = 1;
|
||||
var sessionSettings = {};
|
||||
var friendInput = null;
|
||||
|
||||
function beforeShow(data) {
|
||||
inviteMusiciansUtil.clearSelections();
|
||||
|
|
@ -60,7 +61,7 @@
|
|||
context.JK.dropdown($('#musician-access', $form));
|
||||
context.JK.dropdown($('#fan-access', $form));
|
||||
|
||||
$('#friend-input')
|
||||
$(friendInput)
|
||||
.unbind('blur')
|
||||
.attr("placeholder", "Looking up friends...")
|
||||
.prop('disabled', true)
|
||||
|
|
@ -233,7 +234,7 @@
|
|||
invitationDialog.showFacebookDialog(e);
|
||||
});
|
||||
|
||||
$('#friend-input').focus(function() { $(this).val(''); })
|
||||
$(friendInput).focus(function() { $(this).val(''); })
|
||||
}
|
||||
|
||||
function toggleMusicianAccess() {
|
||||
|
|
@ -306,7 +307,7 @@
|
|||
function initialize(invitationDialogInstance, inviteMusiciansUtilInstance) {
|
||||
invitationDialog = invitationDialogInstance;
|
||||
inviteMusiciansUtil = inviteMusiciansUtilInstance;
|
||||
inviteMusiciansUtil.inviteSessionCreate('#create-session-invite-musicians');
|
||||
friendInput = inviteMusiciansUtil.inviteSessionCreate('#create-session-invite-musicians', "<div style='margin-right:140px;'>Start typing friends' names or:</div>"); //'
|
||||
events();
|
||||
loadBands();
|
||||
loadSessionSettings();
|
||||
|
|
|
|||
|
|
@ -14,18 +14,34 @@
|
|||
var autoComplete = null;
|
||||
var rest = context.JK.Rest();
|
||||
var inviteAction = 'create'; // create/update
|
||||
var friendInput = null;
|
||||
var updateSessionID = null;
|
||||
var addInstructions = '';
|
||||
|
||||
this.inviteSessionCreate = function(elemSelector) {
|
||||
inviteAction = 'create';
|
||||
function _initInvite(elemSelector, iAction, instructions) {
|
||||
addInstructions = instructions;
|
||||
inviteAction = iAction;
|
||||
friendInput = '#friend-input-'+inviteAction;
|
||||
_appendFriendSelector($(elemSelector));
|
||||
return friendInput;
|
||||
}
|
||||
|
||||
this.inviteSessionCreate = function(elemSelector, instructions) {
|
||||
return _initInvite(elemSelector, 'create', instructions)
|
||||
};
|
||||
|
||||
this.inviteBandCreate = function(elemSelector, instructions) {
|
||||
return _initInvite(elemSelector, 'band', instructions)
|
||||
};
|
||||
|
||||
this.inviteSessionUpdate = function(elemSelector, sessionId) {
|
||||
this.clearSelections();
|
||||
updateSessionID = sessionId;
|
||||
friendSelectorDialog.setCallback(friendSelectorCallback);
|
||||
|
||||
inviteAction = 'update';
|
||||
friendInput = '#friend-input-'+inviteAction;
|
||||
|
||||
if (0 == $(elemSelector + ' .friendbox').length) {
|
||||
_appendFriendSelector($(elemSelector));
|
||||
$('#btn-save-invites').click(function() {
|
||||
|
|
@ -52,6 +68,7 @@
|
|||
existingInvites = [];
|
||||
updateSessionID = null;
|
||||
$('.selected-friends').empty();
|
||||
$(friendInput).val('');
|
||||
};
|
||||
|
||||
this.loadFriends = function() {
|
||||
|
|
@ -64,27 +81,21 @@
|
|||
userIds.push(this.id);
|
||||
userPhotoUrls.push(this.photo_url);
|
||||
});
|
||||
|
||||
var autoCompleteOptions = {
|
||||
lookup: { suggestions: userNames, data: userIds },
|
||||
onSelect: addInvitation,
|
||||
serviceUrl: '/api/search.json?srch_sessinv=1',
|
||||
minChars: 3,
|
||||
autoSelectFirst: true
|
||||
};
|
||||
|
||||
$('#friend-input').attr("placeholder", "Type a friend\'s name").prop('disabled', false);
|
||||
|
||||
if (!autoComplete) {
|
||||
autoComplete = $('#friend-input').autocomplete(autoCompleteOptions);
|
||||
} else {
|
||||
autoComplete.setOptions(autoCompleteOptions);
|
||||
if (friendInput) {
|
||||
var autoCompleteOptions = {
|
||||
lookup: { suggestions: userNames, data: userIds },
|
||||
onSelect: addInvitation,
|
||||
serviceUrl: '/api/search.json?srch_sessinv=1',
|
||||
minChars: 3,
|
||||
autoSelectFirst: true
|
||||
};
|
||||
$(friendInput).attr("placeholder", "Type a friend\'s name").prop('disabled', false)
|
||||
autoComplete = $(friendInput).autocomplete(autoCompleteOptions);
|
||||
$(".autocomplete").width("150px");
|
||||
}
|
||||
|
||||
$(".autocomplete").width("150px");
|
||||
})
|
||||
.fail(function() {
|
||||
$('#friend-input').attr("placeholder", "Unable to lookup friends");
|
||||
$(friendInput).attr("placeholder", "Unable to lookup friends");
|
||||
app.ajaxError(arguments);
|
||||
});
|
||||
}
|
||||
|
|
@ -114,11 +125,11 @@
|
|||
userName: value,
|
||||
imageStyle: imgStyle});
|
||||
$('.selected-friends').append(invitationHtml);
|
||||
$('#friend-input').select();
|
||||
$(friendInput).select();
|
||||
invitedFriends.push(data);
|
||||
|
||||
} else {
|
||||
$('#friend-input').select();
|
||||
$(friendInput).select();
|
||||
context.alert('Invitation already exists for this musician.');
|
||||
}
|
||||
}
|
||||
|
|
@ -188,9 +199,12 @@
|
|||
}
|
||||
|
||||
function _friendSelectorHTML() {
|
||||
var fInput = friendInput ? friendInput.substring(1,friendInput.length) : '';
|
||||
return context.JK.fillTemplate($('#template-session-invite-musicians').html(),
|
||||
{choose_friends_id: 'btn-choose-friends-'+inviteAction,
|
||||
selected_friends_id: 'selected-friends-'+inviteAction});
|
||||
selected_friends_id: 'selected-friends-'+inviteAction,
|
||||
friend_input: fInput,
|
||||
instructions: addInstructions});
|
||||
}
|
||||
|
||||
function _appendFriendSelector(elemSelector) {
|
||||
|
|
@ -201,10 +215,14 @@
|
|||
invitedFriends.map(function(uid) { obj[uid] = true; });
|
||||
friendSelectorDialog.showDialog(obj);
|
||||
});
|
||||
if ('update' == inviteAction) {
|
||||
$(friendInput).hide();
|
||||
}
|
||||
};
|
||||
|
||||
this.initialize = function(friendSelectorDialogInstance) {
|
||||
friendSelectorDialog = friendSelectorDialogInstance;
|
||||
return this;
|
||||
};
|
||||
|
||||
return this;
|
||||
|
|
|
|||
|
|
@ -93,20 +93,8 @@
|
|||
<div id="band-setup-step-2" class="content-wrapper" style="padding:10px 35px 10px 35px; display:none;">
|
||||
<br/>
|
||||
<h2>Step 2: Add Band Members</h2><br/>
|
||||
<div class="left w70">If your bandmates are already on JamKazam, start typing their names in the box<br/> below, or click the Choose Friends button to select them.</div>
|
||||
<div class="right" layout-link="select-friends">
|
||||
<a href="#" id="btn-band-choose-friends" class="button-grey right">CHOOSE FRIENDS</a>
|
||||
</div>
|
||||
<br clear="all" />
|
||||
<br />
|
||||
|
||||
<div class="friendbox">
|
||||
<div id="selected-band-invitees"></div>
|
||||
<input id="band-invitee-input" type="text" placeholder="Looking up friends..." width="150px" />
|
||||
</div>
|
||||
<br/><br/>
|
||||
If your bandmates are not on JamKazam yet, use any of the options below to invite them to join the service.<br/><br/>
|
||||
|
||||
<div id="band-setup-invite-musicians"></div>
|
||||
If your bandmates are not on JamKazam yet, use any of the options below to invite them to join the service.<br/><br/>
|
||||
<div class="left mr20">
|
||||
<div class="left">
|
||||
<a class="btn-email-invitation">
|
||||
|
|
|
|||
|
|
@ -17,16 +17,14 @@
|
|||
<div class="right" layout-link="select-friends">
|
||||
<a href="#" class="btn-choose-friends button-grey" id="{choose_friends_id}">CHOOSE FRIENDS</a>
|
||||
</div>
|
||||
<div style="margin-right:140px;">
|
||||
Start typing friends'' names or:
|
||||
</div>
|
||||
{instructions}
|
||||
<div class="clearall"></div>
|
||||
</div>
|
||||
<br />
|
||||
<!-- friend invitation box -->
|
||||
<div class="friendbox">
|
||||
<div class="selected-friends" id="{selected_friends_id}"></div>
|
||||
<input id="friend-input" type="text" placeholder="Looking up friends..." />
|
||||
<input id="{friend_input}" type="text" placeholder="Looking up friends..." />
|
||||
</div>
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -142,9 +142,6 @@
|
|||
var friendSelectorDialog = new JK.FriendSelectorDialog(JK.app);
|
||||
friendSelectorDialog.initialize();
|
||||
|
||||
var inviteMusiciansUtil = new JK.InviteMusiciansUtil(JK.app);
|
||||
inviteMusiciansUtil.initialize(friendSelectorDialog);
|
||||
|
||||
var userDropdown = new JK.UserDropdown(JK.app);
|
||||
JK.UserDropdown = userDropdown;
|
||||
userDropdown.initialize(invitationDialog);
|
||||
|
|
@ -187,11 +184,15 @@
|
|||
JK.GenreSelectorHelper.initialize();
|
||||
JK.Banner.initialize();
|
||||
|
||||
var inviteMusiciansUtil1 = new JK.InviteMusiciansUtil(JK.app);
|
||||
inviteMusiciansUtil1.initialize(friendSelectorDialog);
|
||||
var createSessionScreen = new JK.CreateSessionScreen(JK.app);
|
||||
createSessionScreen.initialize(invitationDialog, inviteMusiciansUtil);
|
||||
createSessionScreen.initialize(invitationDialog, inviteMusiciansUtil1);
|
||||
|
||||
var inviteMusiciansUtil2 = new JK.InviteMusiciansUtil(JK.app);
|
||||
inviteMusiciansUtil2.initialize(friendSelectorDialog);
|
||||
var bandSetupScreen = new JK.BandSetupScreen(JK.app);
|
||||
bandSetupScreen.initialize(invitationDialog, friendSelectorDialog);
|
||||
bandSetupScreen.initialize(invitationDialog, inviteMusiciansUtil2);
|
||||
|
||||
var bandSetupPhotoScreen = new JK.BandSetupPhotoScreen(JK.app);
|
||||
bandSetupPhotoScreen.initialize();
|
||||
|
|
@ -212,8 +213,10 @@
|
|||
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, inviteMusiciansUtil);
|
||||
sessionScreen.initialize(localRecordingsDialog, recordingFinishedDialog, inviteMusiciansUtil3);
|
||||
|
||||
var sessionSettingsDialog = new JK.SessionSettingsDialog(JK.app, sessionScreen);
|
||||
sessionSettingsDialog.initialize();
|
||||
|
|
|
|||
Loading…
Reference in New Issue