Skip to content

Commit

Permalink
Merge branch 'development' of github.com:laurencedawson/embr into dev…
Browse files Browse the repository at this point in the history
…elopment
  • Loading branch information
laurencedawson committed May 27, 2011
2 parents 01f758e + 06ca45a commit 0afa433
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 15 deletions.
75 changes: 61 additions & 14 deletions themes/collect/scripts.js
Expand Up @@ -8,10 +8,12 @@ var post_loading = false;
var base_url;
var $posts = $('.posts');
var loading = false; //If the page if loading
var endreached = false; //If we have reached the end
var image_loading = false;
$(document).ready(function(){

// Add loader.
loading = true;
image_loading = true;
var $loader = "<img src=\"img/load.gif\" id=\"loader\">";
$('.posts').prepend($loader);

Expand All @@ -29,29 +31,75 @@ $(document).ready(function(){
var o = 1;
}
$('.posts .post').animate({'opacity': o}, 1000);
loading = false;
image_loading = false;
if(window.location.hash != ''){

// AJAX load post.
post_loading = true;
$close_link = "<a href=\"#\" class=\"close\"></a>";

var h = window.location.hash;
var t = base_url+h.substring(1);
var c = 'a[href="'+t+'"]';
/*var c = 'a.post_link[href="'+t+'"]';
while($(c).length==0){
console.log($(c).length);
//Cancel if we have reached the end or are currently loading
if(!loading && !endreached){
loading = true;
//First extract the next page to load
var t=$("div.next a").attr('href');
if( t==null ){
endreached = true;
}else{
//Remove the old pagination links
$(".next").remove();
$(".prev").remove();
//Get the next set of posts
$.get(t,function(data){
var d=$(data);
var items=d.find('.post');
if(items.has(c).length != 0){
e == 1;
}
// Add loader.
var $loader = "<img src=\"img/load.gif\" id=\"loader\">";
$posts.append($loader);
// Add new posts.
$(items).addClass('new');
$posts.append($(items));
image_loading = true;
$('.new .image_box', $posts).imagesLoaded(function(){
$('#loader').remove();
$('.new .post_date span').fitTextToParent({adjust:0.95});
$posts.masonry({appendedContent:$(items), itemSelector: '.post.index'}, function(){
$(items).animate({'opacity':.5}, 1000, function(){$(this).removeClass('new')});
image_loading = false;
});
});
var v=d.find('.next');
$('.posts').append(v);
if(v.length==0){
endreached=true;
}
loading = false;
});
}
}
}
var top = $(c).parents('.post').position().top;
var left = $(c).parents('.post').position().left;
if(left > $('#post_viewer').width()){
left = 320;
}/*else if(left > 310 && left < $('#post_viewer').width()){
}else if(left > 310 && left < $('#post_viewer').width()){
left = 155;
}*/else{
}else{
left = 0;
}
$(c).parents('.post').scrollToTop();

$(c).parents('.post').scrollToTop();*/

// AJAX load post.
post_loading = true;
$close_link = "<a href=\"#\" class=\"close\"></a>";

$.get(t,function(data){
var d=$(data);
var item=d.find('.blog_post');
Expand All @@ -62,7 +110,7 @@ $(document).ready(function(){
$('.post_inner', item).prepend($close_link);
}

$('#post_viewer').append($(item)).css({'top': top, 'left': left});
$('#post_viewer').append($(item)).css({'top': 0, 'left': 0});
$('.blog_post .post_date span').fitTextToParent({adjust:0.95});
$('a.close').click(function(e){
e.preventDefault();
Expand Down Expand Up @@ -90,7 +138,7 @@ $(document).ready(function(){
//Focus on the title of any form
$(".form_title").focus();
//Sets the base url
base_url = $(".header h1 a").attr('href');
base_url = $("header h1 a").attr('href');

//Displays the admin buttons if logged in
l = base_url+"tools/logged_in";
Expand Down Expand Up @@ -258,7 +306,6 @@ $(".lg").click(function(){
/*
Endless scoll
*/
var endreached = false; //If we have reached the end
$(document).scroll(function(){
//Cancel if we have reached the end or are currently loading
if(loading || endreached) return;
Expand Down
1 change: 0 additions & 1 deletion themes/collect/style.css
Expand Up @@ -364,7 +364,6 @@ a.close:hover{
padding-bottom: 5px;
margin-top:0px;
margin-bottom:10px;
border-bottom: 1px #ccc solid
}

.info p{
Expand Down

0 comments on commit 0afa433

Please sign in to comment.