2012-08-06 19:56:01 +00:00
|
|
|
function js(){
|
|
|
|
return false;
|
|
|
|
}
|
2012-05-19 13:42:45 +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');
|
|
|
|
}
|
|
|
|
|
2012-07-10 20:25:48 +00:00
|
|
|
|
2012-05-19 13:42:45 +00:00
|
|
|
/**
|
|
|
|
*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');
|
|
|
|
}
|
|
|
|
|
2012-07-10 20:25:48 +00:00
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
})
|
|
|
|
}
|
2012-05-19 13:42:45 +00:00
|
|
|
|
2012-05-05 14:41:49 +00:00
|
|
|
/**
|
|
|
|
* toggles the sidebar for widgets
|
|
|
|
* @param object
|
|
|
|
*/
|
|
|
|
function toggleSidebar($obj)
|
|
|
|
{
|
|
|
|
$('.sidebar').hide();
|
|
|
|
var text = $($obj).text();
|
|
|
|
var ref = $($obj).attr('ref');
|
|
|
|
|
|
|
|
$('#sidebar-dd-text').text(text);
|
|
|
|
$('#'+ref).show();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a widget inside the sidebar so that it can be used
|
|
|
|
*/
|
|
|
|
function createWidget($widgetId,$sideBarId)
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
var $widget = $('#'+$widgetId);
|
|
|
|
var $sidebar = $('#'+$sideBarId);
|
|
|
|
var $widgetList = $('#'+$sideBarId+' .widgets-list');
|
|
|
|
var $widgetTitle = $('#'+$widgetId+' .admin-widget-box-title').text();
|
|
|
|
$sideBarId = $('#'+$sideBarId+' input[name=sidebar_id]').val();
|
|
|
|
var $sideBarTitle = $('a[ref='+$sideBarId+']').text();
|
|
|
|
|
|
|
|
if($('#'+$widgetId+'-'+$sideBarId).html())
|
|
|
|
{
|
|
|
|
alert($widgetTitle+' is already in '+$sideBarTitle)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
var $newWidget = '<div class="widget-bar" id="'+$widgetId+'-'+$sideBarId+'" >';
|
2012-08-06 19:56:01 +00:00
|
|
|
$newWidget += '<div class="btn-group">';
|
|
|
|
$newWidget += '<span class="btn widget-btn-long relative">';
|
|
|
|
$newWidget += '<img src="'+imageurl+'/loaders/1.gif"';
|
|
|
|
$newWidget += 'class="loader absolute" style="left:5px"/>';
|
|
|
|
$newWidget += $widgetTitle+'</span>';
|
|
|
|
$newWidget += '<button class="btn dropdown-toggle"';
|
|
|
|
$newWidget += ' data-toggle="modal" ';
|
|
|
|
$newWidget += ' data-target="#'+$widgetId+'-'+$sideBarId+'-modal" ';
|
|
|
|
$newWidget += '><i class="caret"></i></button>';
|
|
|
|
$newWidget += '</div>';
|
|
|
|
$newWidget += '<input type="hidden" name="widgets[]" value="'+$widgetId+'"/>';
|
|
|
|
$newWidget += '</div>';
|
2012-05-07 10:21:36 +00:00
|
|
|
|
2012-05-05 14:41:49 +00:00
|
|
|
|
|
|
|
/*Widget Modal
|
|
|
|
var WidgetModal = '<div class="modal hide fade"';
|
|
|
|
WidgetModal += 'id="'+$widgetId+'-'+$sideBarId+'-modal">';
|
|
|
|
WidgetModal +=$('#'+$widgetId+'--modal').html();
|
|
|
|
WidgetModal +='</div>'
|
|
|
|
|
|
|
|
//Append widget...*/
|
|
|
|
|
|
|
|
$widgetList.append($newWidget);
|
2012-05-07 10:21:36 +00:00
|
|
|
|
|
|
|
saveAndFetch($sideBarId,$widgetId);
|
2012-05-05 14:41:49 +00:00
|
|
|
|
2012-05-07 10:21:36 +00:00
|
|
|
|
2012-05-05 14:41:49 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Save Sidebar ..
|
|
|
|
*/
|
|
|
|
function saveSidebar($Id,$widgetId)
|
|
|
|
{
|
|
|
|
var FormData = $('#'+$Id+'-form').serialize();
|
|
|
|
FormData = FormData + '&mode=update-sidebar';
|
|
|
|
amplify.request( "update-sidebar",FormData,
|
|
|
|
function( data ) {
|
|
|
|
|
|
|
|
}
|
2012-08-06 19:56:01 +00:00
|
|
|
);
|
2012-05-05 14:41:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Save and fetch widget form as well....
|
|
|
|
*/
|
|
|
|
function saveAndFetch($Id,$widgetId)
|
|
|
|
{
|
|
|
|
var FormData = $('#'+$Id+'-form').serialize();
|
|
|
|
FormData = FormData + '&mode=update-sidebar&fetch-widget='+$widgetId;
|
|
|
|
amplify.request("update-sidebar",FormData,
|
|
|
|
function(data){
|
2012-05-07 10:21:36 +00:00
|
|
|
$('#modal-forms-'+$Id).append(data.data);
|
|
|
|
$('#'+$widgetId+'-'+$Id+' .loader' ).hide();
|
2012-05-05 14:41:49 +00:00
|
|
|
}
|
2012-08-06 19:56:01 +00:00
|
|
|
);
|
2012-05-05 14:41:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Save widget
|
|
|
|
*/
|
|
|
|
function saveWidget($bttn,$id)
|
|
|
|
{
|
|
|
|
$($bttn).attr('disabled','disabled');
|
|
|
|
$($bttn).addClass('disabled');
|
|
|
|
$($bttn).text('Saving...');
|
|
|
|
|
|
|
|
var FormData = $('#'+$id+'-form').serialize();
|
|
|
|
FormData = FormData+'&mode=update-widget';
|
|
|
|
amplify.request("update-sidebar",FormData,
|
|
|
|
function(data){
|
|
|
|
$($bttn).removeAttr('disabled');
|
|
|
|
$($bttn).removeClass('disabled');
|
|
|
|
$($bttn).text('Save');
|
|
|
|
$($bttn).prev().trigger('click');
|
|
|
|
}
|
2012-08-06 19:56:01 +00:00
|
|
|
);
|
2012-05-05 14:41:49 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove widget from sidebar...
|
|
|
|
*/
|
|
|
|
|
|
|
|
function deleteWidget($widgetId,$sidebarId){
|
|
|
|
|
|
|
|
if($('#'+$widgetId+'-'+$sidebarId).html())
|
|
|
|
{
|
2012-08-06 19:56:01 +00:00
|
|
|
$('#'+$widgetId+'-'+$sidebarId).remove();
|
|
|
|
saveSidebar($sidebarId);
|
|
|
|
$('#'+$widgetId+'-'+$sidebarId+'-modal').modal('hide').remove();
|
2012-05-05 14:41:49 +00:00
|
|
|
}
|
2012-05-19 13:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add Category..
|
|
|
|
*/
|
|
|
|
function add_category()
|
|
|
|
{
|
|
|
|
var formData = $('#add-category').serialize();
|
|
|
|
formData += '&mode=add_category';
|
|
|
|
|
|
|
|
loading('add-category');
|
|
|
|
amplify.request("categories",formData,
|
|
|
|
function(data){
|
|
|
|
if(data.err)
|
|
|
|
{
|
|
|
|
displayError(data.err);
|
|
|
|
}else if(data.data)
|
|
|
|
{
|
|
|
|
$('#categories-list').append(data.data);
|
|
|
|
$('#category-'+data.cid).hide().fadeIn('slow');
|
|
|
|
loading('add-category','hide');
|
|
|
|
scrollTo('#category-'+data.cid);
|
|
|
|
}
|
|
|
|
}
|
2012-08-06 19:56:01 +00:00
|
|
|
);
|
2012-05-19 13:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-06 19:56:01 +00:00
|
|
|
/**
|
2012-07-10 20:25:48 +00:00
|
|
|
* Function used to make confirmation about any action
|
|
|
|
*/
|
2012-08-06 19:56:01 +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-07-10 20:25:48 +00:00
|
|
|
|
2012-08-06 19:56:01 +00:00
|
|
|
/**
|
2012-07-10 20:25:48 +00:00
|
|
|
* Clears confirm form events and text
|
|
|
|
*/
|
2012-08-06 19:56:01 +00:00
|
|
|
function clear_confirm(){
|
|
|
|
$('#confirm .modal-header h3').text('');
|
|
|
|
$('#confirm .modal-body').html('');
|
|
|
|
$('#confirm-yes').unbind('click');
|
|
|
|
}
|
2012-07-10 20:25:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-19 13:42:45 +00:00
|
|
|
/**
|
|
|
|
* Scroll to an elemet
|
|
|
|
*/
|
|
|
|
function scrollTo($element){
|
|
|
|
$('html, body').animate({
|
2012-08-06 19:56:01 +00:00
|
|
|
scrollTop: $($element).offset().top
|
2012-05-19 13:42:45 +00:00
|
|
|
}, 'fast');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete category
|
|
|
|
* @param cid STRING
|
|
|
|
*/
|
2012-07-30 13:26:32 +00:00
|
|
|
function delete_category(cid,type)
|
2012-05-19 13:42:45 +00:00
|
|
|
{
|
2012-08-06 19:56:01 +00:00
|
|
|
amplify.request("categories",{
|
|
|
|
cid : cid,
|
|
|
|
'mode' : 'delete_category',
|
|
|
|
type:type
|
|
|
|
},
|
|
|
|
function(data){
|
|
|
|
if(data.err)
|
|
|
|
{
|
|
|
|
displayError(data.err);
|
|
|
|
}else
|
|
|
|
{
|
|
|
|
$('#category-'+cid).fadeOut();
|
2012-05-19 13:42:45 +00:00
|
|
|
}
|
2012-08-06 19:56:01 +00:00
|
|
|
}
|
2012-05-19 13:42:45 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Make Default
|
|
|
|
* @param cid STRING
|
|
|
|
*/
|
2012-07-30 13:26:32 +00:00
|
|
|
function make_default(cid,category_name,type)
|
2012-05-19 13:42:45 +00:00
|
|
|
{
|
2012-08-06 19:56:01 +00:00
|
|
|
amplify.request("categories",{
|
|
|
|
cid : cid,
|
|
|
|
'mode' : 'make_default',
|
|
|
|
'name':category_name,
|
|
|
|
type:type
|
|
|
|
},
|
|
|
|
function(data){
|
|
|
|
if(data.err)
|
|
|
|
{
|
|
|
|
displayError(data.err);
|
|
|
|
}else
|
|
|
|
{
|
|
|
|
displayMsg(data.msg)
|
2012-05-19 13:42:45 +00:00
|
|
|
}
|
2012-08-06 19:56:01 +00:00
|
|
|
}
|
2012-05-19 13:42:45 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* edit category...
|
|
|
|
*/
|
2012-07-30 13:26:32 +00:00
|
|
|
function edit_category(id,type)
|
2012-05-19 13:42:45 +00:00
|
|
|
{
|
|
|
|
|
2012-08-06 19:56:01 +00:00
|
|
|
amplify.request("categories",{
|
|
|
|
'mode' : 'edit_category',
|
|
|
|
cid:id,
|
|
|
|
type:type
|
|
|
|
},
|
|
|
|
function(data){
|
|
|
|
if(data.success)
|
|
|
|
{
|
|
|
|
$('#edit-category-modal .form-basic').html(data.template);
|
|
|
|
$('#edit-category-modal h3').html(data.title);
|
|
|
|
$('#edit-category-modal .update-message').html('');
|
|
|
|
$('#edit-category-modal').modal('show');
|
|
|
|
}else
|
|
|
|
if(data.err)
|
|
|
|
displayError(data.err);
|
|
|
|
}
|
2012-05-19 13:42:45 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Change Category
|
|
|
|
* @param id INT
|
|
|
|
*/
|
|
|
|
function save_category(id)
|
|
|
|
{
|
|
|
|
$('#save-category-button').addClass('disable');
|
|
|
|
loading('save-category');
|
|
|
|
|
|
|
|
var formData = $('#edit-category').serialize();
|
2012-08-06 19:56:01 +00:00
|
|
|
formData += '&mode=save_category';
|
2012-07-30 13:26:32 +00:00
|
|
|
|
2012-08-06 19:56:01 +00:00
|
|
|
amplify.request("categories",formData,
|
2012-05-19 13:42:45 +00:00
|
|
|
function(data){
|
|
|
|
if(data.err)
|
|
|
|
$('#edit-category-modal .update-message').html('<div class="alert alert-danger">'+data.err+'</div>')
|
|
|
|
else
|
|
|
|
$('#edit-category-modal .update-message').html('<div class="alert alert-success">'+data.msg+'</div>')
|
|
|
|
loading('save-category','hide');
|
|
|
|
$('#save-category-button').removeClass('disable');
|
|
|
|
}
|
2012-08-06 19:56:01 +00:00
|
|
|
);
|
2012-05-19 13:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update Order
|
|
|
|
*
|
|
|
|
* @param id INT
|
|
|
|
* @param order INT
|
|
|
|
* @param type STRING
|
|
|
|
*/
|
|
|
|
function update_order(id,order,type)
|
|
|
|
{
|
|
|
|
if(type=='category')
|
|
|
|
var amplify_type = 'categories';
|
|
|
|
|
|
|
|
loading(type+'-'+id);
|
|
|
|
|
2012-08-06 19:56:01 +00:00
|
|
|
amplify.request(amplify_type,{
|
|
|
|
"mode":"update_order",
|
|
|
|
"cid":id,
|
|
|
|
'order':order,
|
|
|
|
type:type
|
|
|
|
},
|
|
|
|
function(data){
|
|
|
|
if(data.err)
|
|
|
|
displayError(data.err);
|
|
|
|
loading(type+'-'+id,"hide");
|
|
|
|
}
|
2012-05-19 13:42:45 +00:00
|
|
|
);
|
2012-07-10 20:25:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add video profile..
|
|
|
|
*/
|
|
|
|
function add_video_profile()
|
|
|
|
{
|
|
|
|
var $form = $('#video-profile-form').serialize();
|
|
|
|
|
|
|
|
$('#video-profile-bttn').button('loading');
|
|
|
|
|
|
|
|
$('#video-profile-alert').hide().html('');
|
|
|
|
|
|
|
|
var postData = $form+'&mode=add_profile';
|
|
|
|
amplify.request('videos',postData,function(data){
|
|
|
|
|
|
|
|
if(data.rel.err)
|
|
|
|
{
|
|
|
|
focusObj(data.rel.err,'error');
|
|
|
|
}
|
|
|
|
|
|
|
|
if(data.err)
|
|
|
|
{
|
|
|
|
$.each(data.err,function(rel,msg){
|
|
|
|
$('#video-profile-alert').append(msg+'<br>').show();
|
|
|
|
})
|
|
|
|
$('#video-profile-bttn').button('reset');
|
|
|
|
}else
|
|
|
|
{
|
|
|
|
$('#profile_id').val(data.profile_id);
|
|
|
|
$('#video-profile-form').submit();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update video profile...
|
|
|
|
*/
|
|
|
|
function update_video_profile(pid)
|
|
|
|
{
|
|
|
|
var $form = $('#video-profile-form'+pid).serialize();
|
|
|
|
|
|
|
|
$('#video-profile-bttn'+pid).button('loading');
|
|
|
|
|
|
|
|
$('#video-profile-alert'+pid).hide().html('');
|
|
|
|
|
|
|
|
var postData = $form+'&mode=update_profile';
|
|
|
|
amplify.request('videos',postData,function(data){
|
|
|
|
|
|
|
|
if(data.rel.err)
|
|
|
|
{
|
|
|
|
focusObj(data.rel.err,'error');
|
|
|
|
}
|
|
|
|
|
|
|
|
if(data.err)
|
|
|
|
{
|
|
|
|
$.each(data.err,function(rel,msg){
|
|
|
|
$('#video-profile-alert'+pid).append(msg+'<br>').show();
|
|
|
|
})
|
|
|
|
$('#video-profile-bttn').button('reset');
|
|
|
|
}else
|
|
|
|
{
|
|
|
|
$('#video-profile-form'+pid).submit();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2012-08-06 19:56:01 +00:00
|
|
|
/**
|
|
|
|
* Adjust notification sidebar height.
|
|
|
|
*/
|
|
|
|
function notificationHeight()
|
|
|
|
{
|
|
|
|
var height = $(window).height();
|
|
|
|
if(height<450)
|
|
|
|
height = 450;
|
|
|
|
$('.notification-container').height(height + 10);
|
|
|
|
$('.home-box').css('min-height',height);
|
2012-08-08 12:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add Note for admin
|
|
|
|
*/
|
|
|
|
|
|
|
|
function add_note()
|
|
|
|
{
|
|
|
|
var $note = $('#note-text').val();
|
|
|
|
|
|
|
|
amplify.request('main',{"mode":"add-note","note":$note},function(data){
|
|
|
|
if(data.err)
|
|
|
|
{
|
|
|
|
displayError(data.err);
|
|
|
|
}else
|
|
|
|
{
|
|
|
|
var new_note = '<tr id="note-'+data.id+'" class="display-none"><td>';
|
|
|
|
new_note += data.note;
|
|
|
|
new_note += '</td>';
|
|
|
|
new_note += '<td><a href="javascript:void(0)" class="icon-trash" onclick="delete_note(\''+data.id+'\')"></i></td></tr>';
|
|
|
|
|
|
|
|
$('#note-text').val('');
|
|
|
|
$('#notes-container').prepend(new_note);
|
|
|
|
$('#note-'+data.id).fadeIn();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function delete_note($id)
|
|
|
|
{
|
|
|
|
amplify.request('main',{mode:'delete-note',id:$id},function(data){
|
|
|
|
if(data.err){
|
|
|
|
displayError(data.err);
|
|
|
|
}else
|
|
|
|
{
|
|
|
|
$('#note-'+$id).fadeOut(function(){ $(this).remove() });
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function update_admin_home_order()
|
|
|
|
{
|
|
|
|
var formData = $('#admin-home-blocks-form').serialize();
|
|
|
|
formData += '&mode=update-home-block-order';
|
|
|
|
|
|
|
|
amplify.request('main',formData,function(data){
|
|
|
|
if(data.err){
|
|
|
|
displayError(data.err);
|
|
|
|
}else
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
})
|
2012-08-16 20:10:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
//NOw we wil check which box does not have any box..and changes its style
|
|
|
|
$('.blocks-container').each(function(){
|
|
|
|
if($(this).children('.home-block').size() <1 )
|
|
|
|
$(this).addClass('no-blocks');
|
|
|
|
else
|
|
|
|
$(this).removeClass('no-blocks');
|
|
|
|
})
|
2012-08-06 19:56:01 +00:00
|
|
|
}
|