split projects.js to separate files, fix projects gallery

This commit is contained in:
Sanj 2011-10-07 17:44:40 +05:30
parent 792d6a70d0
commit b33f70b34f
2 changed files with 55 additions and 42 deletions

View File

@ -0,0 +1,54 @@
$(function(){
$('.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");
$.getJSON("project_json", {'id': project_id}, function(data) {
$('#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();
});
});
$('.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: true,
preloadImage: 'img/loading.gif',
pagination: false, //SANJ NOT WORKING
play: 5000,
pause: 4000,
hoverPause: true
});
}
function nl2br(str) {
return str.replace("\n", "<br />");
}

View File

@ -15,48 +15,7 @@
<script type="text/javascript" src="/static/js/jquery.simplyscroll-1.0.4.js"></script> <script type="text/javascript" src="/static/js/jquery.simplyscroll-1.0.4.js"></script>
<script type="text/javascript"> <script type="text/javascript" src="/static/js/projects.js"></script>
$(function(){
$('#slidesDiv').slides({
preload: true,
preloadImage: 'img/loading.gif',
pagination: false, //SANJ NOT WORKING
play: 5000,
pause: 4000,
hoverPause: true
});
$('.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");
$.getJSON("project_json", {'id': project_id}, function(data) {
$('#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();
}
});
});
$('.projectThumb').eq(0).click();
});
function nl2br(str) {
return str.replace("\n", "<br />");
}
</script>
<script type="text/javascript"> <script type="text/javascript">