$(function(){recents=$.controller.array("dashboard/recents");$("div.modified_at").formatDate("M. j, Y | g:i a","modified_at",true);$("div.item").format(function(elem,data){var link="",linkEnd="";var title=data.title;if(title.length>75){title=title.slice(0,75)+"...";}
if(data.blog_category_id==undefined){if(data.user_id==$.session.user.id||data.shared=="YES"){link='<a href="http://demo.firerift.com/app/gallery/edit?id='+data.id+'" title="Edit '+title+'">';linkEnd='</a>';}
if(data.cover_pic!=null&&data.cover_pic!="NULL"){$(elem).append('<div class="item-image">'+link+'<img src="http://demo.firerift.com/upload/media/frt_'+data.cover_pic+'" alt="'+data.cover_pic+'" />'+linkEnd+'</div>').hide();$(elem).find("img").hide().load(function(){$(this).imgCenter({parentSteps:1});});$(elem).show();}
$(elem).append('<div class="item-title" style="margin-top:26px;">'+link+title+linkEnd+'</div>');}else{if(data.user_id==$.session.user.id||data.shared=="YES"){link='<a href="http://demo.firerift.com/app/blog/edit?id='+data.id+'" title="Edit '+title+'">';linkEnd='</a>';}
$(elem).append('<div class="item-title">'+link+title+linkEnd+'</div>');}
$(elem).parent().show();});$("a.lb-preview").format(function(elem,data){var preview="";if(data.gallery_category_id!=undefined){preview="_gallery";}
$(elem).attr("href","http://demo.firerift.com/app/core/shared/preview"+preview+"?id="+data.id);$(elem).fancybox({'zoomSpeedIn':300,'zoomSpeedOut':300,'frameWidth':700,'frameHeight':400,'overlayShow':true});})
$("div.item-text").format(function(elem,data){var text=data.text;if(text){text=text.replace(/<\S[^><]*>/g,"");text=text.replace(/\{\{base_url\}\}/g,"http://demo.firerift.com/");if(text.length>250){text=text.slice(0,250)+"...";}}
$(elem).text(text);});deleteHappened="FALSE",deleteHappenedA="FALSE",deleteHappenedB="FALSE";$("a.item-delete").format(function(elem,data){if(data.user_id==$.session.user.id){$(elem).click(function(event){$("div#dropdown-holder").html($("#delete_confirmation").html());if(data.blog_category_id==undefined){$("div#dropdown-holder .form-item:first span:first").show();}
$("div#dropdown-holder .btn-delete").click(function(event){if(data.blog_category_id==undefined){var url="http://demo.firerift.com/api/gallery/galleries?id="+data.id;}else{var url="http://demo.firerift.com/api/blog/blog_entries?id="+data.id;}
$.ajax({url:url,type:"DELETE",success:function(){recents.retrieve();deleteHappened="TRUE",deleteHappenedA="TRUE",deleteHappenedB="TRUE";},error:function(){errorAlert();}});$("div#dropdown-holder").hide("slide",{direction:"up"},500);return false;});$("div#dropdown-holder").show("slide",{direction:"up"},500);return false;});}else{$(elem).hide();}});$("#recents_body").template(recents,{success:function(){if($("#recents_body div").length<=0){$('<div class="empty">There has not been any Recent Activity</div>').prependTo("#recents_body");}}});$("#you-recently").click(function(){if(!$("#you_recents_body").hasClass("created")){$("#you_recents_body").addClass("created");recents=$.controller.array("dashboard/recents?user_id="+$.session.user.id);$("#you_recents_body").template(recents,{success:function(){if($("#you_recents_body div").length<=0){$('<div class="empty">There has not been any Recent Activity</div>').prependTo("#you_recents_body");}}});}
$(this).addClass("active");$("#everyone-recently").removeClass("active");$("#recents_body").hide();$("#you_recents_body").show();return false;});$("#everyone-recently").click(function(){if(deleteHappened=="TRUE"){recents=$.controller.array("dashboard/recents?user_id="+$.session.user.id);recents.retrieve();deleteHappened="FALSE";}
$(this).addClass("active");$("#you-recently").removeClass("active");$("#you_recents_body").hide();$("#recents_body").show();return false;});});