73 lines
2 KiB
JavaScript
Executable file
73 lines
2 KiB
JavaScript
Executable file
$(function() {
|
|
|
|
|
|
$('#slidesContainer').bind("contextmenu", function(e) {
|
|
return false;
|
|
});
|
|
|
|
|
|
$('.projectThumb').click(function() {
|
|
// alert("hi");
|
|
var $this = $(this);
|
|
if ($this.hasClass("selected")) {
|
|
return false;
|
|
}
|
|
$('.selected').removeClass("selected");
|
|
$this.addClass("selected");
|
|
var project_id = $this.attr("data-id");
|
|
// doProjectLoading();
|
|
$.getJSON("project_json", {'id': project_id}, function(data) {
|
|
location.hash = data.slug;
|
|
$('#projectTitle').next().text(data.title);
|
|
$('#projectSizeProgram').next().html(nl2br(data.size_program));
|
|
$('#projectDesignStatement').next().html(nl2br(data.design_statement));
|
|
if (data.extra_text == '') {
|
|
$('#projectExtraText').hide();
|
|
$('#projectExtraText').next().hide();
|
|
} else {
|
|
$('#projectExtraText').show().next().html(nl2br(data.extra_text)).show();
|
|
}
|
|
$('.slidesInner').empty();
|
|
for (var i=0; i<data.images.length; i++) {
|
|
var $a = getA(data.images[i]);
|
|
$('.slidesInner').append($a);
|
|
}
|
|
activateSlides();
|
|
});
|
|
});
|
|
|
|
|
|
var hash = location.hash;
|
|
if (hash == '') {
|
|
$('.projectThumb').eq(0).click();
|
|
} else {
|
|
var $thumb = $('#thumb_' + hash);
|
|
if ($thumb.length > 0) {
|
|
$thumb.click();
|
|
} else {
|
|
$('.projectThumb').eq(0).click();
|
|
}
|
|
}
|
|
});
|
|
|
|
|
|
function getA(image) {
|
|
var $a = $('<a />').attr("href", "#");
|
|
var $img = $('<img />').attr("src", image.url).appendTo($a);
|
|
return $a;
|
|
}
|
|
|
|
function activateSlides() {
|
|
$('#slidesDiv').slides({
|
|
preload: false,
|
|
preloadImage: '/static/images/loading.gif',
|
|
pagination: false, //SANJ NOT WORKING
|
|
play: 5000,
|
|
pause: 4000,
|
|
hoverPause: true
|
|
});
|
|
}
|
|
|
|
function nl2br(str) {
|
|
return str.replace("\n", "<br />");
|
|
}
|