migrated views in js into partials

v1.18.x
Julian Lam 11 years ago
parent 0e20350ca7
commit 7fe0ab6022

@ -268,8 +268,8 @@ define(['uploader'], function(uploader) {
Categories.launchPermissionsModal = function(cid) { Categories.launchPermissionsModal = function(cid) {
var modal = $('#category-permissions-modal'), var modal = $('#category-permissions-modal'),
searchEl = modal.find('#permission-search'), searchEl = modal.find('#permission-search'),
resultsEl = modal.find('.search-results'), resultsEl = modal.find('.search-results.users'),
groupsResultsEl = modal.find('.groups-results'), groupsResultsEl = modal.find('.search-results.groups'),
searchDelay; searchDelay;
// Clear the search field and results // Clear the search field and results
@ -291,24 +291,11 @@ define(['uploader'], function(uploader) {
return app.alertError(err.message); return app.alertError(err.message);
} }
var numResults = results.length, templates.parse('partials/admin/categories/users', {
resultObj; users: results
resultsEl.html(''); }, function(html) {
for(var x = 0; x < numResults; x++) { resultsEl.html(html);
resultObj = results[x]; });
liEl = $('<li />')
.attr('data-uid', resultObj.uid)
.html('<div class="pull-right">' +
'<div class="btn-group">' +
'<button type="button" data-priv="+r" class="btn btn-default' + (resultObj.privileges['+r'] ? ' active' : '') + '">Read</button>' +
'<button type="button" data-priv="+w" class="btn btn-default' + (resultObj.privileges['+w'] ? ' active' : '') + '">Write</button>' +
'<button type="button" data-priv="mods" class="btn btn-default' + (resultObj.privileges.mods ? ' active' : '') + '">Moderator</button>' +
'</div>' +
'</div>' +
'<img src="' + resultObj.picture + '" /> ' + resultObj.username);
resultsEl.append(liEl);
}
}); });
}, 250); }, 250);
}); });
@ -343,25 +330,31 @@ define(['uploader'], function(uploader) {
if(err) { if(err) {
return app.alertError(err.message); return app.alertError(err.message);
} }
var numResults = results.length,
trEl, templates.parse('partials/admin/categories/groups', {
resultObj; groups: results
}, function(html) {
groupsResultsEl.empty(); groupsResultsEl.html(html);
});
for(var x = 0; x < numResults; x++) { // var numResults = results.length,
resultObj = results[x]; // trEl,
trEl = $('<tr />') // resultObj;
.attr('data-name', resultObj.name)
.html('<td><h4>' + resultObj.name + '</h4></td>' + // groupsResultsEl.empty();
'<td>' +
'<div class="btn-group pull-right">' + // for(var x = 0; x < numResults; x++) {
'<button type="button" data-gpriv="g+r" class="btn btn-default' + (resultObj.privileges['g+r'] ? ' active' : '') + '">Read</button>' + // resultObj = results[x];
'<button type="button" data-gpriv="g+w" class="btn btn-default' + (resultObj.privileges['g+w'] ? ' active' : '') + '">Write</button>' + // trEl = $('<tr />')
'</div>' + // .attr('data-name', resultObj.name)
'</td>'); // .html('<td><h4>' + resultObj.name + '</h4></td>' +
groupsResultsEl.append(trEl); // '<td>' +
} // '<div class="btn-group pull-right">' +
// '<button type="button" data-gpriv="g+r" class="btn btn-default' + (resultObj.privileges['g+r'] ? ' active' : '') + '">Read</button>' +
// '<button type="button" data-gpriv="g+w" class="btn btn-default' + (resultObj.privileges['g+w'] ? ' active' : '') + '">Write</button>' +
// '</div>' +
// '</td>');
// groupsResultsEl.append(trEl);
// }
}); });
groupsResultsEl.off().on('click', '[data-gpriv]', function(e) { groupsResultsEl.off().on('click', '[data-gpriv]', function(e) {

Loading…
Cancel
Save