VRFS-3325 : Re-enable change to allow multiple of the widget for online presence and performance samples.

This commit is contained in:
Steven Miers 2015-07-13 18:14:10 -05:00
parent 9980aef982
commit fe9e604d70
2 changed files with 55 additions and 55 deletions

View File

@ -4,9 +4,9 @@
context.JK = context.JK || {};
// TODO: Add a target type, which can be band or user -- call the
// appropriate API methods.
context.JK.AccountProfileSamples = function(app) {
// Using loadFn & updateFn, this can be used to render online
// presences and performance samples for both users and bands:
context.JK.AccountProfileSamples = function(app, parent, loadFn, updateFn) {
var $document = $(document)
// used to initialize RecordingSourceValidator in site_validator.js.coffee
@ -20,8 +20,6 @@
var ui = new context.JK.UIHelper(JK.app);
var target = {};
var profileUtils = context.JK.ProfileUtils;
var parent = $(".account-profile-samples")
var $screen = $('.profile-online-sample-controls', parent);
// online presences
var $website = $screen.find('.website');
@ -60,8 +58,11 @@
}
function afterShow(data) {
api.getUserProfile().done(function(targetPlayer) {
renderPlayer(targetPlayer)
$.when(loadFn())
.done(function(targetPlayer) {
if (targetPlayer && targetPlayer.keys && targetPlayer.keys.length > 0) {
renderPlayer(targetPlayer)
}
})
}
@ -146,29 +147,24 @@
if (samples && samples.length > 0) {
$.each(samples, function(index, val) {
var source = {
recordingSources.push({
'url': val.url,
'recording_id': val.service_id,
'recording_title': val.description
}
recordingSources.push(source);
buildNonJamKazamEntry($sampleList, type, source);
});
// TODO: this code is repeated in HTML file
var recordingIdAttr = ' data-recording-id="' + val.service_id + '" ';
var recordingUrlAttr = ' data-recording-url="' + val.url + '" ';
var recordingTitleAttr = ' data-recording-title="' + val.description + '"';
var title = formatTitle(val.description);
$sampleList.append('<div class="clearall recording-row left entry"' + recordingIdAttr + recordingUrlAttr + recordingTitleAttr + '>' + title + '</div>');
$sampleList.append('<div class="right close-button" data-recording-type="' + type + '"' + recordingIdAttr + '>X</div>');
});
}
}
}
function buildNonJamKazamEntry($sampleList, type, source) {
// TODO: this code is repeated in HTML file
var recordingIdAttr = ' data-recording-id="' + source.recording_id + '" ';
var recordingUrlAttr = ' data-recording-url="' + source.url + '" ';
var recordingTitleAttr = ' data-recording-title="' + source.recording_title + '"';
var title = formatTitle(source.recording_title);
$sampleList.find(".empty").addClass("hidden")
$sampleList.append('<div class="clearall recording-row left entry"' + recordingIdAttr + recordingUrlAttr + recordingTitleAttr + '>' + title + '</div>');
$sampleList.append('<div class="right close-button" data-recording-type="' + type + '"' + recordingIdAttr + '>X</div>');
}
function buildJamkazamEntry(recordingId, recordingName) {
var title = formatTitle(recordingName);
@ -183,22 +179,25 @@
$btnAddJkRecording.click(function(evt) {
evt.preventDefault();
ui.launchRecordingSelectorDialog(jamkazamRecordingSources, function(selectedRecordings) {
$jamkazamSampleList.empty();
// retrieve recordings and pass to modal dialog
api.getClaimedRecordings()
.done(function(response) {
ui.launchRecordingSelectorDialog(response, jamkazamRecordingSources, function(selectedRecordings) {
$jamkazamSampleList.empty();
jamkazamRecordingSources = [];
jamkazamRecordingSources = [];
// update the list with the selected recordings
$.each(selectedRecordings, function(index, val) {
jamkazamRecordingSources.push({
'claimed_recording_id': val.id,
'description': val.name
// update the list with the selected recordings
$.each(selectedRecordings, function(index, val) {
jamkazamRecordingSources.push({
'claimed_recording_id': val.id,
'description': val.name
});
buildJamkazamEntry(val.id, val.name);
});
});
buildJamkazamEntry(val.id, val.name);
});
});
return false;
});
@ -222,8 +221,8 @@
})
}
function enableSubmits() {
$btnSubmit.off("click").on("click", function(e) {
function enableSubmits() {
$btnSubmit.off("click").on("click", function(e) {
e.stopPropagation();
handleUpdateProfile();
return false;
@ -288,7 +287,7 @@
disableSubmits()
var player = buildPlayer()
api.updateUser({
updateFn({
website: player.website,
online_presences: player.online_presences,
performance_samples: player.performance_samples
@ -317,13 +316,8 @@
addPerformanceSamples(ps, $soundCloudSampleList, performanceSampleTypes.SOUNDCLOUD.description);
addPerformanceSamples(ps, $youTubeSampleList, performanceSampleTypes.YOUTUBE.description);
var website = $website.val()
if (website == '') {
website = null;
}
return {
website: website,
website: $website.val(),
online_presences: op,
performance_samples: ps
}
@ -369,7 +363,7 @@
// refactor:
function initializeValidators() {
var initialized = false;
//$document.on('JAMKAZAM_READY', function(e, data) {
$document.on('JAMKAZAM_READY', function(e, data) {
JK.JamServer.get$Server().on(JK.EVENTS.CONNECTION_UP, function() {
if(initialized) {
return;
@ -434,8 +428,8 @@
siteSuccessCallback($inputDiv, youTubeRecordingValidator, $youTubeSampleList, 'youtube');
}
function siteSuccessCallback($inputDiv, recordingSiteValidator, $sampleList, type) {
$sampleList.find(".empty").addClass("hidden")
function siteSuccessCallback($inputDiv, recordingSiteValidator, sampleList, type) {
sampleList.find(".empty").addClass("hidden")
$inputDiv.removeClass('error');
$inputDiv.find('.error-text').remove();
@ -443,7 +437,13 @@
if (recordingSources && recordingSources.length > 0) {
var addedRecording = recordingSources[recordingSources.length-1];
buildNonJamKazamEntry($sampleList, type, addedRecording);
// TODO: this code is repeated in elsewhere in this JS file:
var recordingIdAttr = ' data-recording-id="' + addedRecording.recording_id + '" ';
var recordingUrlAttr = ' data-recording-url="' + addedRecording.url + '" ';
var recordingTitleAttr = ' data-recording-title="' + addedRecording.recording_title + '"';
var title = formatTitle(addedRecording.recording_title);
sampleList.append('<div class="clearall recording-row left entry"' + recordingIdAttr + recordingUrlAttr + recordingTitleAttr + '>' + title + '</div>');
sampleList.append('<div class="right close-button" data-recording-type="' + type + '"' + recordingIdAttr + '>X</div>');
}
$inputDiv.find('input').val('');
@ -455,9 +455,9 @@
$inputDiv.append("<span class='error-text'>Invalid URL</span>").show();
}
});
//});
});
} // end initializeValidators.

View File

@ -16,7 +16,7 @@
<%= render "searchResults" %>
<%= render "faders" %>
<%= render "vu_meters" %>
<!--%= render "ftue" % No longer used-->
<!--%= render "ftue" % No longer used-->
<%= render "jamServer" %>
<%= render "iconInstrumentSelect" %>
<%= render "muteSelect" %>
@ -183,10 +183,10 @@
var jamtrackLicenseDialog = new JK.JamtrackLicenseDialog(JK.app);
jamtrackLicenseDialog.initialize();
var jamtrackPaymentHistoryDialog = new JK.JamtrackPaymentHistoryDialog(JK.app);
jamtrackPaymentHistoryDialog.initialize();
var audioProfileInvalidDialog = new JK.AudioProfileInvalidDialog(JK.app);
audioProfileInvalidDialog.initialize();
@ -240,8 +240,8 @@
var accountProfileInterests = new JK.AccountProfileInterests(JK.app);
accountProfileInterests.initialize();
var accountProfileSamples = new JK.AccountProfileSamples(JK.app)
accountProfileSamples.initialize();
var accountProfileSamples = new JK.AccountProfileSamples(JK.app, $(".account-profile-samples"), api.getUserProfile, api.updateUser)
accountProfileSamples.initialize()
var accountAudioProfile = new JK.AccountAudioProfile(JK.app);
accountAudioProfile.initialize();
@ -407,7 +407,7 @@
else {
_initAfterConnect(false);
}
JK.bindHoverEvents();
})
</script>