Merge branch 'master' of bitbucket.org:jamkazam/jam-web
This commit is contained in:
commit
754f273332
|
|
@ -25,59 +25,7 @@
|
|||
logger.debug('query=' + query);
|
||||
if (query !== '') {
|
||||
$('#query').html(query + "\"");
|
||||
|
||||
var url = "/api/search?query=" + query;
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
contentType: 'application/json',
|
||||
url: url,
|
||||
processData: false,
|
||||
success: function(response) {
|
||||
$.each(response.musicians, function(index, val) {
|
||||
|
||||
// fill in template for Connect pre-click
|
||||
var template = $('#template-search-result').html();
|
||||
var searchResultHtml = context.JK.fillTemplate(template, {
|
||||
userId: val.id,
|
||||
avatar_url: context.JK.resolveAvatarUrl(val.photo_url),
|
||||
userName: val.name,
|
||||
location: val.location,
|
||||
instruments: getInstrumentHtml(val.instruments)
|
||||
});
|
||||
|
||||
$('#search-results').append(searchResultHtml);
|
||||
|
||||
// fill in template for Connect post-click
|
||||
template = $('#template-invitation-sent').html();
|
||||
var invitationSentHtml = context.JK.fillTemplate(template, {
|
||||
userId: val.id,
|
||||
first_name: val.first_name,
|
||||
profile_url: "/users/" + val.id
|
||||
});
|
||||
|
||||
$('#search-results').append(invitationSentHtml);
|
||||
|
||||
// initialize visibility of the divs
|
||||
$('div[user-id=' + val.id + '].search-connected').hide();
|
||||
$('div[user-id=' + val.id + '].search-result').show();
|
||||
|
||||
// wire up button click handler
|
||||
$('div[user-id=' + val.id + ']').find('#btn-connect-friend').click(sendFriendRequest);
|
||||
});
|
||||
|
||||
var resultCount = response.musicians.length;
|
||||
$('#result-count').html(resultCount);
|
||||
|
||||
if (resultCount === 1) {
|
||||
$('#result-count').append(" Result for \"");
|
||||
}
|
||||
else {
|
||||
$('#result-count').append(" Results for \"");
|
||||
}
|
||||
},
|
||||
error: app.ajaxError
|
||||
});
|
||||
context.JK.search(query, app, onSearchSuccess);
|
||||
}
|
||||
|
||||
else {
|
||||
|
|
@ -88,6 +36,50 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
function onSearchSuccess(response) {
|
||||
|
||||
$.each(response.musicians, function(index, val) {
|
||||
// fill in template for Connect pre-click
|
||||
var template = $('#template-search-result').html();
|
||||
var searchResultHtml = context.JK.fillTemplate(template, {
|
||||
userId: val.id,
|
||||
avatar_url: context.JK.resolveAvatarUrl(val.photo_url),
|
||||
userName: val.name,
|
||||
location: val.location,
|
||||
instruments: getInstrumentHtml(val.instruments)
|
||||
});
|
||||
|
||||
$('#search-results').append(searchResultHtml);
|
||||
|
||||
// fill in template for Connect post-click
|
||||
template = $('#template-invitation-sent').html();
|
||||
var invitationSentHtml = context.JK.fillTemplate(template, {
|
||||
userId: val.id,
|
||||
first_name: val.first_name,
|
||||
profile_url: "/users/" + val.id
|
||||
});
|
||||
|
||||
$('#search-results').append(invitationSentHtml);
|
||||
|
||||
// initialize visibility of the divs
|
||||
$('div[user-id=' + val.id + '].search-connected').hide();
|
||||
$('div[user-id=' + val.id + '].search-result').show();
|
||||
|
||||
// wire up button click handler
|
||||
$('div[user-id=' + val.id + ']').find('#btn-connect-friend').click(sendFriendRequest);
|
||||
});
|
||||
|
||||
var resultCount = response.musicians.length;
|
||||
$('#result-count').html(resultCount);
|
||||
|
||||
if (resultCount === 1) {
|
||||
$('#result-count').append(" Result for \"");
|
||||
}
|
||||
else {
|
||||
$('#result-count').append(" Results for \"");
|
||||
}
|
||||
}
|
||||
|
||||
function sendFriendRequest(evt) {
|
||||
evt.stopPropagation();
|
||||
var userId = $(this).parent().attr('user-id');
|
||||
|
|
|
|||
|
|
@ -69,67 +69,59 @@
|
|||
}
|
||||
|
||||
function initializeNotificationsPanel() {
|
||||
|
||||
// pull down pending friend requests for this user
|
||||
}
|
||||
|
||||
function initializeChatPanel() {
|
||||
|
||||
}
|
||||
|
||||
// TODO: same code is in searchResults.js - REFACTOR
|
||||
// TODO: most of this code is in searchResults.js - REFACTOR
|
||||
function search(query) {
|
||||
|
||||
logger.debug('query=' + query);
|
||||
if (query !== '') {
|
||||
|
||||
var url = "/api/search?query=" + query;
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
contentType: 'application/json',
|
||||
url: url,
|
||||
processData: false,
|
||||
success: function(response) {
|
||||
$.each(response.musicians, function(index, val) {
|
||||
|
||||
// fill in template for Connect pre-click
|
||||
var template = $('#template-sidebar-search-result').html();
|
||||
var searchResultHtml = context.JK.fillTemplate(template, {
|
||||
userId: val.id,
|
||||
avatar_url: context.JK.resolveAvatarUrl(val.photo_url),
|
||||
userName: val.name,
|
||||
location: val.location
|
||||
});
|
||||
|
||||
$('#sidebar-search-results').append(searchResultHtml);
|
||||
|
||||
// fill in template for Connect post-click
|
||||
template = $('#template-sidebar-invitation-sent').html();
|
||||
var invitationSentHtml = context.JK.fillTemplate(template, {
|
||||
userId: val.id,
|
||||
first_name: val.first_name,
|
||||
profile_url: "/users/" + val.id
|
||||
});
|
||||
|
||||
$('#sidebar-search-results').append(invitationSentHtml);
|
||||
|
||||
// initialize visibility of the divs
|
||||
$('div[layout=sidebar] div[user-id=' + val.id + '].sidebar-search-connected').hide();
|
||||
$('div[layout=sidebar] div[user-id=' + val.id + '].result').show();
|
||||
|
||||
// wire up button click handler
|
||||
$('div[layout=sidebar] div[user-id=' + val.id + ']').find('#btn-connect-friend').click(sendFriendRequest);
|
||||
|
||||
$('#sidebar-search-header').show();
|
||||
hidePanels();
|
||||
});
|
||||
$('#sidebar-search-results').height(getHeight() + 'px');
|
||||
},
|
||||
error: app.ajaxError
|
||||
});
|
||||
context.JK.search(query, app, onSearchSuccess);
|
||||
}
|
||||
}
|
||||
|
||||
function onSearchSuccess(response) {
|
||||
$.each(response.musicians, function(index, val) {
|
||||
|
||||
// fill in template for Connect pre-click
|
||||
var template = $('#template-sidebar-search-result').html();
|
||||
var searchResultHtml = context.JK.fillTemplate(template, {
|
||||
userId: val.id,
|
||||
avatar_url: context.JK.resolveAvatarUrl(val.photo_url),
|
||||
userName: val.name,
|
||||
location: val.location
|
||||
});
|
||||
|
||||
$('#sidebar-search-results').append(searchResultHtml);
|
||||
|
||||
// fill in template for Connect post-click
|
||||
template = $('#template-sidebar-invitation-sent').html();
|
||||
var invitationSentHtml = context.JK.fillTemplate(template, {
|
||||
userId: val.id,
|
||||
first_name: val.first_name,
|
||||
profile_url: "/users/" + val.id
|
||||
});
|
||||
|
||||
$('#sidebar-search-results').append(invitationSentHtml);
|
||||
|
||||
// initialize visibility of the divs
|
||||
$('div[layout=sidebar] div[user-id=' + val.id + '].sidebar-search-connected').hide();
|
||||
$('div[layout=sidebar] div[user-id=' + val.id + '].sidebar-search-result').show();
|
||||
|
||||
// wire up button click handler
|
||||
$('div[layout=sidebar] div[user-id=' + val.id + ']').find('#btn-connect-friend').click(sendFriendRequest);
|
||||
});
|
||||
|
||||
$('#sidebar-search-header').show();
|
||||
hidePanels();
|
||||
$('#sidebar-search-results').height(getHeight() + 'px');
|
||||
}
|
||||
|
||||
function hidePanels() {
|
||||
$('[layout-panel="contents"]').hide();
|
||||
$('[layout-panel="contents"]').css({"height": "1px"});
|
||||
|
|
@ -174,8 +166,9 @@
|
|||
processData: false,
|
||||
success: function(response) {
|
||||
// toggle the pre-click and post-click divs
|
||||
logger.debug('userId=' + userId);
|
||||
$('div[layout=sidebar] div[user-id=' + userId + '].sidebar-search-connected').show();
|
||||
$('div[layout=sidebar] div[user-id=' + userId + '].result').hide();
|
||||
$('div[layout=sidebar] div[user-id=' + userId + '].sidebar-search-result').hide();
|
||||
},
|
||||
error: app.ajaxError
|
||||
});
|
||||
|
|
|
|||
|
|
@ -48,6 +48,21 @@
|
|||
return instrumentIconMap45;
|
||||
}
|
||||
|
||||
context.JK.search = function(query, app, callback) {
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
contentType: 'application/json',
|
||||
url: "/api/search?query=" + query,
|
||||
processData: false,
|
||||
success: function(response) {
|
||||
callback(response);
|
||||
},
|
||||
error: app.ajaxError
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the length of a dictionary
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@
|
|||
right:3px;
|
||||
}
|
||||
|
||||
.result {
|
||||
.sidebar-search-result {
|
||||
display:block;
|
||||
position:relative;
|
||||
border-bottom:solid 1px #01545f;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,8 @@
|
|||
</div>
|
||||
</div>
|
||||
<div style="clear:both;"></div><br />
|
||||
<div class="result"></div>
|
||||
<!-- border between header and beginning of search results -->
|
||||
<div class="sidebar-search-result"></div>
|
||||
<div id="sidebar-search-results" class="results-wrapper">
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -204,7 +205,7 @@
|
|||
</script>
|
||||
|
||||
<script type="text/template" id="template-sidebar-search-result">
|
||||
<div user-id="{userId}" class="result">
|
||||
<div user-id="{userId}" class="sidebar-search-result">
|
||||
<a href="#" class="avatar-small"><img src="{avatar_url}" /></a>
|
||||
<div class="result-name">{userName}<br />
|
||||
<span class="result-location">{location}</span>
|
||||
|
|
|
|||
Loading…
Reference in New Issue