2012-05-28 07:10:27 +00:00
|
|
|
|
|
|
|
// CLIPBUCKET MAIN FUNCTIONS ----------------------
|
|
|
|
|
|
|
|
|
|
|
|
function displayConfirm( id, confirmMessage, onConfirm, heading ) {
|
2012-08-16 20:10:07 +00:00
|
|
|
if ( !document.getElementById(id) ) {
|
|
|
|
con = "<div id='"+id+"' class='modal hide confirm-modal'>";
|
2012-05-28 07:10:27 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
if ( heading ) {
|
|
|
|
con += "<div id='modal_header_"+id+"' class='modal-header'>";
|
|
|
|
con += "<h3>"+heading+"</h3>";
|
|
|
|
con += "</div>";
|
|
|
|
}
|
2012-05-28 07:10:27 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
con += "<div id='modal_body_"+id+"' class='modal-body'> ";
|
|
|
|
con += "<span>"+confirmMessage+"</span>";
|
|
|
|
con += "</div>";
|
2012-05-28 07:10:27 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
con += "<div id='modal_footer_"+id+"' class='modal-footer'>";
|
|
|
|
con += "<div class='pull-left'><div id='function_loader_"+id+"' class='loading_pointer'><img src='"+imageurl+"/loaders/1.gif' /></div></div>";
|
|
|
|
con += "<div class='pull-right'>";
|
|
|
|
con += "<button data-dismiss='modal' class='btn '>Cancel</button>";
|
|
|
|
con += "<button id='confirm_"+id+"' class='btn btn-primary '>Confirm</button>"
|
|
|
|
con += "</div>";
|
|
|
|
con += "</div>";
|
2012-05-28 07:10:27 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
con += "</div>";
|
2012-05-28 07:10:27 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
$('body').append(con);
|
|
|
|
}
|
2012-05-28 07:10:27 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
$('#confirm_'+id).on('click',function( event ){
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
|
|
if ( jQuery.isFunction(onConfirm) ) {
|
|
|
|
onConfirm.call( this, id );
|
|
|
|
} else {
|
|
|
|
$('#'+id).modal('hide');
|
|
|
|
if ( onConfirm.search('http://') == -1 ) {
|
|
|
|
var error = ['Please check the function name provided,"'+onConfirm+'". Either it does not exist or name is not right. '];
|
|
|
|
displayError( error );
|
|
|
|
} else {
|
|
|
|
window.location = onConfirm;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2012-05-28 07:10:27 +00:00
|
|
|
}
|
|
|
|
|
2012-06-01 11:57:50 +00:00
|
|
|
function save_exif_settings() {
|
2012-08-16 20:10:07 +00:00
|
|
|
var obj = $('#save_exif'), form = $('#exif_settings'), fields = form.serialize();
|
|
|
|
var pid = $('#pid').val();
|
2012-06-01 11:57:50 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
$('#exif-error').hide().empty();
|
|
|
|
$('#exif-success').hide().empty();
|
2012-06-01 11:57:50 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
disable_form_inputs( form.attr('id') );
|
|
|
|
disable_form_inputs('modal_footer');
|
|
|
|
obj.button('loading');
|
|
|
|
loading_pointer('photo-'+pid);
|
2012-06-01 11:57:50 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
amplify.request('photos',fields+'&mode=inline_exif_setting', function( data ) {
|
|
|
|
enable_form_inputs( form.attr('id') );
|
|
|
|
enable_form_inputs('modal_footer');
|
2012-06-01 11:57:50 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
obj.button('reset');
|
|
|
|
loading_pointer('photo-'+pid,'hide');
|
2012-06-01 11:57:50 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
if ( data.error ) {
|
|
|
|
$('#exif-error').text( data.error ).show();
|
|
|
|
}
|
2012-06-01 11:57:50 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
if ( data.success ) {
|
|
|
|
$('#exif-success').text( data.success ).show();
|
|
|
|
setTimeout(function(){
|
|
|
|
$('#exif-settings').modal('hide');
|
|
|
|
},1500);
|
|
|
|
}
|
|
|
|
});
|
2012-06-01 11:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function show_colors(e) {
|
2012-08-16 20:10:07 +00:00
|
|
|
e.preventDefault();
|
|
|
|
var link = $( e.target ), text = link.text(), pid = link.attr('data-photo-id'), icon = link.find('i');
|
2012-06-01 11:57:50 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
if ( link.hasClass('is-loading-colors') || link.hasClass('no-colors-found') ) {
|
|
|
|
return;
|
|
|
|
}
|
2012-06-01 11:57:50 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
if ( document.getElementById(pid+'-colors-modal') ) {
|
|
|
|
$('#'+pid+'-colors-modal').modal('show');
|
|
|
|
return;
|
|
|
|
}
|
2012-06-01 11:57:50 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
link.addClass('is-loading-colors').text(' Loading ... ').prepend( icon );
|
2012-06-01 11:57:50 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
amplify.request('photos',{
|
|
|
|
mode : 'get_colors',
|
|
|
|
id : pid
|
|
|
|
}, function( data ) {
|
2012-06-01 11:57:50 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
link.removeClass('is-loading-colors').text( text ).prepend( icon );
|
2012-06-01 11:57:50 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
if ( data.error ) {
|
|
|
|
if ( typeof data.error == 'string' ) {
|
|
|
|
error = [data.error];
|
|
|
|
data.error = error
|
|
|
|
}
|
2012-06-01 11:57:50 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
displayError( data.error );
|
|
|
|
link.addClass('no-colors-found').text(' No colors found').prepend( icon );
|
|
|
|
}
|
2012-06-01 11:57:50 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
if ( data.success ) {
|
|
|
|
$('body').append( data.template );
|
|
|
|
$('#'+pid+'-colors-modal').modal('show');
|
|
|
|
$('#'+pid+'-colors-modal .cb-tooltip').tooltip();
|
|
|
|
}
|
|
|
|
});
|
2012-06-01 11:57:50 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-05-28 07:10:27 +00:00
|
|
|
function delete_photo_ajax( id ) {
|
2012-08-16 20:10:07 +00:00
|
|
|
var modal = $('#'+id), button = $('#'+this.id), buttonText = button.text();
|
|
|
|
if ( button.hasClass('disabled') ) {
|
|
|
|
return;
|
|
|
|
}
|
2012-05-28 07:10:27 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
disable_form_inputs( button.parents('.modal-footer').attr('id') );
|
|
|
|
button.text('Deleting ...');
|
|
|
|
var photo_id = id.split('_')[ id.split('_').length - 1 ];
|
2012-05-28 07:10:27 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
amplify.request('photos',{
|
|
|
|
mode : 'delete_photo',
|
|
|
|
id : photo_id
|
|
|
|
}, function( data ) {
|
|
|
|
if( data.error ) {
|
|
|
|
enable_form_inputs( button.parents('.modal-footer').attr('id') );
|
|
|
|
button.text(buttonText);
|
|
|
|
modal.modal('hide');
|
|
|
|
displayError( data.error );
|
|
|
|
}
|
2012-05-28 07:10:27 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
if ( data.success ) {
|
|
|
|
if ( data.redirect_to ) {
|
|
|
|
window.location = data.redirect_to;
|
|
|
|
} else if ( $.cookie('pagedir') ) {
|
|
|
|
window.location = $.cookie('pagedir');
|
|
|
|
} else {
|
|
|
|
window.location = baseurl;
|
|
|
|
}
|
|
|
|
modal.modal('hide');
|
|
|
|
}
|
|
|
|
});
|
2012-05-28 07:10:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*Function used to display an error message popup box
|
|
|
|
*/
|
|
|
|
function displayError(err)
|
|
|
|
{
|
|
|
|
$('#error .modal-body p').html('');
|
|
|
|
|
|
|
|
$.each(err,function(index,data){
|
|
|
|
$('#error .modal-body p').append(data+'<br />');
|
|
|
|
})
|
|
|
|
$('#error').modal('show');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*Function used to display an error message popup box
|
|
|
|
*/
|
|
|
|
function displayMsg(msg)
|
|
|
|
{
|
|
|
|
$('#msg .modal-body p').html('');
|
|
|
|
|
|
|
|
$.each(msg,function(index,data){
|
|
|
|
$('#msg .modal-body p').append(data+'<br />');
|
|
|
|
})
|
|
|
|
$('#msg').modal('show');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Relative input highlight and add error
|
|
|
|
*/
|
|
|
|
function focusObj(err,type)
|
|
|
|
{
|
|
|
|
$.each(err,function(rel,msg){
|
|
|
|
$('#'+rel).parent().parent().addClass(type);
|
|
|
|
$('#'+rel).parent().find('.help-inline').text(msg);
|
|
|
|
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* function used to hide or show loading pointer
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function loading_pointer(ID,toDo)
|
|
|
|
{
|
|
|
|
var pointer = $('#'+ID+'-loader');
|
|
|
|
|
|
|
|
if(toDo=='hide')
|
|
|
|
{
|
|
|
|
pointer.hide();
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
pointer.show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function loading(ID,ToDo)
|
|
|
|
{
|
|
|
|
return loading_pointer(ID,ToDo)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates counts of an object such as
|
|
|
|
* adding playlist will increase playlist_count
|
|
|
|
*/
|
|
|
|
function update_counter(obj,inc)
|
|
|
|
{
|
|
|
|
var val = $(obj).text();
|
|
|
|
val = parseInt(val);
|
|
|
|
if(inc==1)
|
|
|
|
{
|
|
|
|
val += 1;
|
|
|
|
$(obj).text(val);
|
|
|
|
}else
|
|
|
|
{
|
|
|
|
val -= 1;
|
|
|
|
$(obj).text(val);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function toggleBox(bttn,box)
|
|
|
|
{
|
|
|
|
if($(bttn).hasClass('active'))
|
|
|
|
{
|
|
|
|
$(box).hide();
|
2012-09-10 12:48:37 +00:00
|
|
|
$(bttn).removeClass('active').removeClass('pressed');
|
2012-05-28 07:10:27 +00:00
|
|
|
}else
|
|
|
|
{
|
|
|
|
$(box).show();
|
2012-09-10 12:48:37 +00:00
|
|
|
$(bttn).addClass('active').addClass('pressed');
|
2012-05-28 07:10:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-12 10:31:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get Comments via ajax
|
|
|
|
*/
|
|
|
|
|
|
|
|
var comments_voting = 'no';
|
|
|
|
function get_comments(type,type_id,last_update,pageNum,total,object_type,admin)
|
|
|
|
{
|
|
|
|
|
|
|
|
amplify.request('main',
|
|
|
|
{
|
|
|
|
mode:'get_comments',
|
2012-08-16 20:10:07 +00:00
|
|
|
page:pageNum,
|
|
|
|
type:type,
|
2012-06-12 10:31:46 +00:00
|
|
|
type_id:type_id,
|
|
|
|
object_type : object_type,
|
|
|
|
last_update : last_update,
|
|
|
|
total_comments : total,
|
2012-08-16 20:10:07 +00:00
|
|
|
comments_voting : comments_voting,
|
|
|
|
admin : admin
|
2012-06-12 10:31:46 +00:00
|
|
|
},function(data){
|
|
|
|
|
|
|
|
|
|
|
|
$('#comments').hide();
|
|
|
|
$('#comments').html(data.output);
|
|
|
|
$('#comments').fadeIn('slow');
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2012-05-28 07:10:27 +00:00
|
|
|
// CLIPBUCKET MAIN FUNCTIONS ----------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Toggle watch video less and more
|
|
|
|
*/
|
|
|
|
function toggleLessMore(div,type)
|
|
|
|
{
|
|
|
|
var LessHeight = 60; //in pixels
|
|
|
|
|
|
|
|
if(type=='less')
|
|
|
|
{
|
|
|
|
$('#'+div).css('height',LessHeight);
|
|
|
|
$('#'+div+'-less').hide();
|
|
|
|
$('#'+div+'-more').show();
|
|
|
|
}else
|
|
|
|
{
|
|
|
|
$('#'+div).css('height','auto');
|
|
|
|
$('#'+div+'-less').show();
|
|
|
|
$('#'+div+'-more').hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rate object and get result..
|
|
|
|
*
|
|
|
|
* cbv3Rate
|
|
|
|
*
|
|
|
|
* @param id INT
|
|
|
|
* @param rating INT
|
|
|
|
* @param type STRING
|
|
|
|
*/
|
|
|
|
function cbv3rate(id,rating,type)
|
|
|
|
{
|
|
|
|
loading('rating');
|
2012-08-16 20:10:07 +00:00
|
|
|
amplify.request("main",{
|
|
|
|
"mode":"rating",
|
|
|
|
type:type,
|
|
|
|
id:id,
|
|
|
|
rating:rating
|
|
|
|
}//params,
|
|
|
|
,function(data){
|
2012-05-28 07:10:27 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
$('#video-rating-container')
|
|
|
|
.html(data.template);
|
|
|
|
loading('rating','hide');
|
|
|
|
}
|
2012-05-28 07:10:27 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create play list
|
|
|
|
*/
|
|
|
|
function create_playlist(type)
|
|
|
|
{
|
|
|
|
$('#create_playlist_bttn').button('loading');
|
|
|
|
var formData = $('#create-playlist-modal form').serialize();
|
|
|
|
formData += "&mode=create_playlist&type="+type;
|
|
|
|
|
|
|
|
$('#create_playlist_bttn').button('loading');
|
|
|
|
amplify.request('main',formData,function(data){
|
|
|
|
|
|
|
|
if(data.err)
|
|
|
|
{
|
|
|
|
if(data.rel.err)
|
|
|
|
{
|
|
|
|
focusObj(data.rel.err,'error');
|
|
|
|
}
|
|
|
|
|
|
|
|
if(data.rel.err.length<1)
|
|
|
|
{
|
|
|
|
$.each(data.err,function(index,err)
|
|
|
|
{
|
|
|
|
$('#create-playlist-error')
|
2012-08-16 20:10:07 +00:00
|
|
|
.append('<div>'+err+'</div>')
|
|
|
|
.show();
|
2012-05-28 07:10:27 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#create_playlist_bttn').button('reset');
|
|
|
|
}else
|
|
|
|
{
|
|
|
|
|
|
|
|
$('#create-playlist-modal').modal('hide');
|
|
|
|
|
|
|
|
$('#playlist-list').append(data.template);
|
|
|
|
$('#'+data.pid+'-playlist').hide().fadeIn('slow');
|
|
|
|
|
|
|
|
update_counter('#playlists_count',1);
|
|
|
|
|
|
|
|
updatePlaylistPage();
|
|
|
|
$('#create_playlist_bttn').button('reset');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* toggle Playlist options,
|
|
|
|
*
|
|
|
|
* will hide controls if playlist counts is 0
|
|
|
|
* otherwise show them
|
|
|
|
*/
|
|
|
|
function updatePlaylistPage()
|
|
|
|
{
|
|
|
|
if($('.playlist-list').length>0)
|
|
|
|
{
|
|
|
|
$('.playlist-list-controls').show();
|
|
|
|
$('.no-playlist').hide();
|
|
|
|
}else{
|
|
|
|
$('.playlist-list-controls').hide();
|
|
|
|
$('.no-playlist').show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete playlist
|
|
|
|
*/
|
|
|
|
function delete_playlist(pid)
|
|
|
|
{
|
|
|
|
amplify.request('main',
|
2012-08-16 20:10:07 +00:00
|
|
|
{
|
|
|
|
mode:'delete_playlist',
|
|
|
|
pid:pid
|
|
|
|
},function(data){
|
2012-05-28 07:10:27 +00:00
|
|
|
if(data.err)
|
|
|
|
{
|
|
|
|
displayError(data.err);
|
|
|
|
}else
|
|
|
|
{
|
|
|
|
displayMsg(data.msg);
|
|
|
|
$('#'+pid+'-playlist').remove();
|
|
|
|
updatePlaylistPage();
|
|
|
|
update_counter('#playlists_count',-1);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add item into the playlist
|
|
|
|
*/
|
|
|
|
function add_to_playlist(pid,oid,type)
|
|
|
|
{
|
|
|
|
var mainDiv = '#add-videos-to-playlist';
|
|
|
|
|
|
|
|
loading('playlist-'+pid);
|
|
|
|
|
|
|
|
amplify.request('main',{
|
|
|
|
'mode' : 'add_playlist_item',
|
|
|
|
'pid' : pid,
|
|
|
|
'oid' : oid,
|
|
|
|
'type' : type
|
2012-08-16 20:10:07 +00:00
|
|
|
},
|
|
|
|
function(data){
|
|
|
|
$(mainDiv+' > .alert').hide();
|
2012-05-28 07:10:27 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
loading('playlist-'+pid,'hide');
|
|
|
|
if(data.err)
|
|
|
|
{
|
|
|
|
$(mainDiv+' .alert-danger')
|
|
|
|
.text(data.err[0])
|
|
|
|
.show();
|
|
|
|
}else
|
|
|
|
{
|
|
|
|
$('#no_playlist').remove();
|
|
|
|
update_counter('#playlist-counter-'+pid,'1');
|
|
|
|
$('#playlist-ul-'+pid+' .date_updated').
|
|
|
|
text(data.updated);
|
2012-05-28 07:10:27 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
$(mainDiv+' .alert-success')
|
|
|
|
.text(data.msg[0])
|
|
|
|
.show();
|
2012-05-28 07:10:27 +00:00
|
|
|
}
|
2012-08-16 20:10:07 +00:00
|
|
|
}
|
2012-05-28 07:10:27 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create new playlist..
|
|
|
|
*/
|
|
|
|
function create_playlist_quick(type,oid)
|
|
|
|
{
|
|
|
|
var name = $('#playlist_name').val();
|
|
|
|
var privacy = $('#playlist_privacy option:selected').val();
|
|
|
|
var mainDiv = '#add-videos-to-playlist';
|
|
|
|
|
|
|
|
$('#create_playlist_bttn').button('loading');
|
|
|
|
|
|
|
|
amplify.request('main',{
|
|
|
|
'mode' : 'create_playlist',
|
|
|
|
'name' : name,
|
|
|
|
'privacy' : privacy,
|
|
|
|
'type' : type,
|
|
|
|
'oid' : oid
|
2012-08-16 20:10:07 +00:00
|
|
|
},
|
|
|
|
function(data){
|
2012-05-28 07:10:27 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
$('#create_playlist_bttn').button('reset');
|
|
|
|
$(mainDiv+' > .alert').hide();
|
2012-05-28 07:10:27 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
if(data.err)
|
|
|
|
{
|
|
|
|
$(mainDiv+' .alert-danger')
|
|
|
|
.text(data.err[0])
|
|
|
|
.show();
|
|
|
|
}else{
|
|
|
|
|
|
|
|
$('#playlist_name').val('');
|
|
|
|
$('#new-playlist-pointer')
|
|
|
|
.after(data.ul_template);
|
2012-05-28 07:10:27 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
$('.add-playlist-box').show();
|
2012-05-28 07:10:27 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
$(mainDiv+' .alert-success')
|
|
|
|
.text(data.msg[0])
|
|
|
|
.show();
|
2012-05-28 07:10:27 +00:00
|
|
|
}
|
2012-08-16 20:10:07 +00:00
|
|
|
}
|
2012-05-28 07:10:27 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function disable_form_inputs( id , enable ) {
|
2012-08-16 20:10:07 +00:00
|
|
|
if ( !enable ) {
|
|
|
|
$('#'+id+' :input').attr('disabled', 'disabled');
|
|
|
|
}
|
2012-05-28 07:10:27 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
if ( enable ) {
|
|
|
|
$('#'+id+' :input').removeAttr('disabled');
|
|
|
|
}
|
2012-05-28 07:10:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function enable_form_inputs( id ) {
|
2012-08-16 20:10:07 +00:00
|
|
|
disable_form_inputs( id, true );
|
2012-05-28 07:10:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function send_private_message(e) {
|
2012-08-16 20:10:07 +00:00
|
|
|
var obj = $( e.target ), form = e.target.form, fields = $('#'+form.id ).serializeArray(), forward = {};
|
|
|
|
$.each( fields, function(index, val) {
|
|
|
|
forward[ val.name ] = val.value
|
|
|
|
});
|
2012-05-28 07:10:27 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
forward['mode'] = 'send_photo_pm';
|
|
|
|
disable_form_inputs( form.id )
|
|
|
|
$('#private_message_response').fadeOut('fast').removeClass('alert-error alert-success');
|
|
|
|
obj.button('loading');
|
2012-05-28 07:10:27 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
amplify.request('photos',forward, function( data ) {
|
|
|
|
enable_form_inputs( form.id )
|
|
|
|
if ( data.success ) {
|
|
|
|
$('#private_message_response').addClass('alert-success').html( data.success ).show();
|
|
|
|
form.reset();
|
|
|
|
var autoClose = setTimeout(function() {
|
|
|
|
obj.prev().trigger('click');
|
|
|
|
},2000)
|
|
|
|
}
|
2012-05-28 07:10:27 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
if ( data.error ) {
|
|
|
|
$('#private_message_response').addClass('alert-error').html( data.error ).show();
|
|
|
|
}
|
|
|
|
obj.button('reset');
|
|
|
|
})
|
2012-05-30 14:56:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
/**
|
2012-05-30 14:56:38 +00:00
|
|
|
* Save playlist text
|
|
|
|
* @param item_id INT
|
|
|
|
* @param text STRING
|
|
|
|
*/
|
2012-08-16 20:10:07 +00:00
|
|
|
function save_playlist_item_note(item_id,text)
|
|
|
|
{
|
|
|
|
amplify.request('main',{
|
|
|
|
'mode' : 'save_playlist_item_note',
|
|
|
|
'item_id' : item_id,
|
|
|
|
'text' : text
|
|
|
|
},function(data){
|
|
|
|
if(data.err){
|
|
|
|
displayError(data.err);
|
|
|
|
}else
|
|
|
|
{
|
|
|
|
$('.save-plst-text[data-id='+item_id+']')
|
|
|
|
.button('reset');
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2012-05-30 14:56:38 +00:00
|
|
|
|
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
/**
|
2012-05-30 14:56:38 +00:00
|
|
|
* function used to remove item from playlist
|
|
|
|
*
|
|
|
|
* @param itemid
|
|
|
|
*/
|
2012-08-16 20:10:07 +00:00
|
|
|
function remove_playlist_item(itemid)
|
|
|
|
{
|
|
|
|
loading('confirm');
|
2012-05-30 14:56:38 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
amplify.request('main',{
|
|
|
|
mode : 'remove_playlist_item',
|
|
|
|
item_id : itemid
|
|
|
|
},function(data){
|
2012-05-30 14:56:38 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
//Incase there is any..
|
|
|
|
$('#confirm').modal('hide');
|
|
|
|
clear_confirm();
|
2012-05-30 14:56:38 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
loading('confirm','hide');
|
2012-05-30 14:56:38 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
if(data.err)
|
|
|
|
displayError(data.err);
|
|
|
|
else{
|
|
|
|
$('#'+itemid+'-pitem')
|
|
|
|
.hide('fast')
|
|
|
|
.remove();
|
2012-05-30 14:56:38 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
update_manage_playlist_order();
|
|
|
|
update_counter('#playlist_items_count',-1);
|
|
|
|
}
|
2012-05-30 14:56:38 +00:00
|
|
|
}
|
2012-08-16 20:10:07 +00:00
|
|
|
);
|
|
|
|
}
|
2012-05-30 14:56:38 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
/**
|
2012-05-30 14:56:38 +00:00
|
|
|
* Update manage playlist order
|
|
|
|
*/
|
2012-08-16 20:10:07 +00:00
|
|
|
function update_manage_playlist_order(){
|
|
|
|
var $length = $('#playlist-manage > li').size();
|
2012-05-30 14:56:38 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
if($length>0){
|
|
|
|
for(i=1;i<=$length;i++)
|
|
|
|
{
|
|
|
|
var my = i+1;
|
|
|
|
$('#playlist-manage li:nth-child('+my+') ul .iteration')
|
|
|
|
.text(i+'.');
|
2012-05-30 14:56:38 +00:00
|
|
|
}
|
2012-08-16 20:10:07 +00:00
|
|
|
}else{
|
|
|
|
$('#no-playlist-items-div').show();
|
2012-05-30 14:56:38 +00:00
|
|
|
}
|
2012-08-16 20:10:07 +00:00
|
|
|
}
|
2012-05-30 14:56:38 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
/**
|
2012-05-30 14:56:38 +00:00
|
|
|
* Function used to make confirmation about any action
|
|
|
|
*/
|
2012-08-16 20:10:07 +00:00
|
|
|
function cb_confirm(title,text,callback)
|
|
|
|
{
|
|
|
|
$('#confirm .modal-header h3').text(title);
|
|
|
|
$('#confirm .modal-body').html(text);
|
|
|
|
$('#confirm-yes').bind('click',callback);
|
|
|
|
$('#confirm').modal('show');
|
|
|
|
}
|
2012-05-30 14:56:38 +00:00
|
|
|
|
2012-09-26 11:28:20 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
/**
|
2012-05-30 14:56:38 +00:00
|
|
|
* Clears confirm form events and text
|
|
|
|
*/
|
2012-08-16 20:10:07 +00:00
|
|
|
function clear_confirm(){
|
|
|
|
$('#confirm .modal-header h3').text('');
|
|
|
|
$('#confirm .modal-body').html('');
|
|
|
|
$('#confirm-yes').unbind('click');
|
|
|
|
}
|
2012-09-26 11:28:20 +00:00
|
|
|
|
|
|
|
function close_confirm(){
|
|
|
|
|
|
|
|
clear_confirm();
|
|
|
|
$('#confirm').modal('hide');
|
|
|
|
}
|
2012-06-12 10:31:46 +00:00
|
|
|
|
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
/**
|
2012-11-05 11:35:42 +00:00
|
|
|
* Add comment
|
|
|
|
*/
|
2012-08-16 20:10:07 +00:00
|
|
|
function add_comment()
|
|
|
|
{
|
|
|
|
var comment_form = '#comment-form';
|
|
|
|
$('#add-comment-button').button('loading');
|
2012-06-12 10:31:46 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
form_data = $(comment_form).serialize();
|
|
|
|
form_data += '&mode=add_comment';
|
2012-06-12 10:31:46 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
amplify.request('main',form_data,function(data){
|
2012-06-12 10:31:46 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
$('#add-comment-button').button('reset');
|
|
|
|
if(data.err)
|
|
|
|
{
|
|
|
|
displayError(data.err);
|
|
|
|
}else
|
|
|
|
{
|
2012-10-01 10:40:38 +00:00
|
|
|
$('textarea[name=comment]').val('');
|
2012-08-16 20:10:07 +00:00
|
|
|
$('#no_comments').hide();
|
|
|
|
$('#latest_comment_container')
|
|
|
|
.prepend(data.comment)
|
2012-06-21 11:22:38 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
$('#comment-text').val('');
|
|
|
|
update_counter('#total_comments',1);
|
|
|
|
$('#comment-'+data.cid).hide().fadeIn("slow");
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2012-06-21 11:22:38 +00:00
|
|
|
|
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
/**
|
2012-06-21 11:22:38 +00:00
|
|
|
* function to rate comment..
|
|
|
|
*/
|
2012-08-16 20:10:07 +00:00
|
|
|
function rate_comment(cid,thumb,type,typeid)
|
|
|
|
{
|
|
|
|
amplify.request('main',
|
|
|
|
{
|
|
|
|
mode : 'rate_comment',
|
|
|
|
thumb : thumb,
|
|
|
|
cid : cid,
|
|
|
|
type : type,
|
|
|
|
typeid : typeid
|
|
|
|
},
|
|
|
|
function(data)
|
2012-06-21 11:22:38 +00:00
|
|
|
{
|
2012-08-16 20:10:07 +00:00
|
|
|
if(data.err)
|
2012-06-21 11:22:38 +00:00
|
|
|
{
|
2012-08-16 20:10:07 +00:00
|
|
|
displayError(data.err);
|
|
|
|
}else
|
|
|
|
{
|
|
|
|
$('#comment-rating-'+cid).removeClass('btn-info')
|
|
|
|
.removeClass('btn-info');
|
2012-06-21 11:22:38 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
if(data.rating<0)
|
|
|
|
$('#comment-rating-'+cid).addClass('btn-danger');
|
2012-06-21 11:22:38 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
if(data.rating>0)
|
|
|
|
$('#comment-rating-'+cid).addClass('btn-info');
|
2012-06-21 11:22:38 +00:00
|
|
|
|
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
$('#comment-rating-'+cid).text(data.rating);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2012-06-21 11:22:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
/**
|
2012-06-21 11:22:38 +00:00
|
|
|
* Add reply values to comment field...
|
|
|
|
*/
|
2012-08-16 20:10:07 +00:00
|
|
|
function add_reply(cid,author){
|
2012-06-21 11:22:38 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
var cancelBttn = ' <span>x</span> ';
|
|
|
|
$('#reply-author').html('@'+author+' '+cancelBttn).parent().show()
|
|
|
|
$('#reply-to').val(cid);
|
|
|
|
$('#comment-text').focus();
|
|
|
|
}
|
2012-06-21 11:22:38 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
/**
|
2012-06-21 11:22:38 +00:00
|
|
|
* cancel reply ..
|
|
|
|
*/
|
2012-08-16 20:10:07 +00:00
|
|
|
function cancel_reply()
|
|
|
|
{
|
|
|
|
$('#reply-author').html('').parent().hide();
|
|
|
|
$('#reply-to').val('');
|
|
|
|
}
|
2012-06-21 11:22:38 +00:00
|
|
|
|
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
/**
|
2012-06-21 11:22:38 +00:00
|
|
|
* Mark comment as spam..
|
|
|
|
*/
|
2012-08-16 20:10:07 +00:00
|
|
|
function spam_comment(cid,type,typeid)
|
|
|
|
{
|
2012-06-21 11:22:38 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
amplify.request('main',{
|
|
|
|
mode : 'spam_comment',
|
|
|
|
cid : cid,
|
|
|
|
type : type,
|
|
|
|
typeid : typeid
|
|
|
|
},function(data){
|
|
|
|
if(data.msg)
|
|
|
|
{
|
|
|
|
$("#comment-container-"+cid).after(data.comment).remove();
|
|
|
|
}
|
|
|
|
if(data.err)
|
|
|
|
{
|
|
|
|
displayError(data.err)
|
|
|
|
}
|
|
|
|
})
|
2012-06-21 11:22:38 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
}
|
2012-06-21 11:22:38 +00:00
|
|
|
|
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
/**
|
2012-06-21 11:22:38 +00:00
|
|
|
* not spam function
|
|
|
|
*/
|
2012-08-16 20:10:07 +00:00
|
|
|
function unspam_comment(cid,type,typeid)
|
|
|
|
{
|
2012-06-21 11:22:38 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
amplify.request('main',{
|
|
|
|
mode : 'unspam_comment',
|
|
|
|
cid : cid,
|
|
|
|
type : type,
|
|
|
|
typeid : typeid
|
|
|
|
},function(data){
|
|
|
|
if(data.msg)
|
|
|
|
{
|
|
|
|
$("#comment-container-"+cid).after(data.comment).remove();
|
|
|
|
}
|
|
|
|
if(data.err)
|
|
|
|
{
|
|
|
|
displayError(data.err)
|
|
|
|
}
|
|
|
|
})
|
2012-06-21 11:22:38 +00:00
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
}
|
2012-06-21 11:22:38 +00:00
|
|
|
|
|
|
|
|
2012-08-16 20:10:07 +00:00
|
|
|
/**
|
2012-06-21 11:22:38 +00:00
|
|
|
* Delete comment...
|
|
|
|
*/
|
2012-08-16 20:10:07 +00:00
|
|
|
function delete_comment(cid,type)
|
|
|
|
{
|
|
|
|
amplify.request('main',{
|
|
|
|
mode : 'delete_comment',
|
|
|
|
cid : cid,
|
|
|
|
type : type,
|
|
|
|
},function(data){
|
|
|
|
if(data.msg)
|
|
|
|
{
|
|
|
|
$("#comment-container-"+cid).fadeOut('slow',function(){
|
|
|
|
$(this).remove();
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if(data.err)
|
|
|
|
{
|
|
|
|
displayError(data.err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Toggle upload options
|
|
|
|
*/
|
|
|
|
function toggle_upload($obj)
|
|
|
|
{
|
|
|
|
$id = $($obj).attr('data-target');
|
|
|
|
$('.upload-window').hide();
|
|
|
|
$('#window-'+$id).show();
|
|
|
|
|
|
|
|
$('.upload_options li').removeClass('active');
|
|
|
|
$($obj).addClass('active');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function toggle_upload_list(obj)
|
|
|
|
{
|
|
|
|
$fileid = $(obj).attr('rel');
|
|
|
|
$('.upload_list').removeClass('upload_list_active');
|
|
|
|
$(obj).addClass('upload_list_active');
|
|
|
|
$('.upload-form').hide();
|
|
|
|
$('#file-form-'+$fileid+' .upload-form').show();
|
|
|
|
}
|
|
|
|
|
|
|
|
function toggle_upload_tab(obj)
|
|
|
|
{
|
|
|
|
$(obj).tab('show');
|
|
|
|
$(obj).parent().children('.form-btn')
|
|
|
|
.removeClass('active').addClass('disabled');
|
|
|
|
$(obj).removeClass('disabled').addClass('active');
|
2012-09-10 12:48:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function share_object(form_id,type,bttn)
|
|
|
|
{
|
|
|
|
if(bttn)
|
|
|
|
$(bttn).button('loading')
|
|
|
|
|
|
|
|
amplify.request('main',{
|
|
|
|
mode : 'share_object',
|
|
|
|
type : type,
|
|
|
|
users : $("#"+form_id+" textarea:#share_users").val(),
|
|
|
|
message : $("#"+form_id+" textarea:#message").val(),
|
|
|
|
id : $("#"+form_id+" input:#objectid").val()
|
|
|
|
},function(data){
|
|
|
|
if(data.err)
|
|
|
|
{
|
|
|
|
displayError(data.err);
|
|
|
|
}else
|
|
|
|
{
|
|
|
|
|
|
|
|
$('#'+form_id).hide();
|
|
|
|
$('#share_email_success').show();
|
|
|
|
}
|
|
|
|
|
2012-11-05 11:35:42 +00:00
|
|
|
if(bttn)
|
|
|
|
$(bttn).button('reset');
|
2012-09-11 08:41:23 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function report(obj,bttn)
|
|
|
|
{
|
|
|
|
$id = $(obj+' input[name=id]').val();
|
|
|
|
$type = $(obj+' input[name=type]').val();
|
|
|
|
$flag_type = $(obj+' input[name=flag_type]:checked').val();
|
|
|
|
if(bttn)
|
|
|
|
$(bttn).button('loading');
|
|
|
|
|
|
|
|
|
|
|
|
$(obj+' .alert').hide().html('');
|
|
|
|
|
|
|
|
amplify.request('main',{
|
|
|
|
mode : 'flag_object',
|
|
|
|
type : $type,
|
|
|
|
flag_type : $flag_type,
|
|
|
|
id : $id
|
|
|
|
},function(data){
|
|
|
|
if(data.err)
|
|
|
|
{
|
|
|
|
$(obj+' #report-error-msg').show().html(data.err);
|
|
|
|
}else
|
|
|
|
{
|
|
|
|
$(obj+' #report-success-msg').show().html(data.msg);
|
|
|
|
$(obj).modal('hide');
|
|
|
|
}
|
|
|
|
|
2012-11-05 11:35:42 +00:00
|
|
|
if(bttn)
|
|
|
|
$(bttn).button('reset');
|
2012-09-10 12:48:37 +00:00
|
|
|
});
|
2012-11-05 11:35:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function nl2br (str, is_xhtml) {
|
|
|
|
var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br />' : '<br>';
|
|
|
|
return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ breakTag +'$2');
|
2012-11-27 10:15:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function prettyDate(time){
|
|
|
|
var date = new Date((time || "").replace(/-/g,"/").replace(/[TZ]/g," ")),
|
|
|
|
diff = (((new Date()).getTime() - date.getTime()) / 1000),
|
|
|
|
day_diff = Math.floor(diff / 86400);
|
|
|
|
|
|
|
|
if ( isNaN(day_diff) || day_diff < 0 || day_diff >= 31 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
return day_diff == 0 && (
|
|
|
|
diff < 60 && "just now" ||
|
|
|
|
diff < 120 && "1 minute ago" ||
|
|
|
|
diff < 3600 && Math.floor( diff / 60 ) + " minutes ago" ||
|
|
|
|
diff < 7200 && "1 hour ago" ||
|
|
|
|
diff < 86400 && Math.floor( diff / 3600 ) + " hours ago") ||
|
|
|
|
day_diff == 1 && "Yesterday" ||
|
|
|
|
day_diff < 7 && day_diff + " days ago" ||
|
|
|
|
day_diff < 31 && Math.ceil( day_diff / 7 ) + " weeks ago";
|
|
|
|
}
|
|
|
|
|