split projects.js to separate files, fix projects gallery
This commit is contained in:
parent
792d6a70d0
commit
b33f70b34f
54
urbstudio/static/js/projects.js
Normal file
54
urbstudio/static/js/projects.js
Normal 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 />");
|
||||
}
|
|
@ -15,48 +15,7 @@
|
|||
|
||||
<script type="text/javascript" src="/static/js/jquery.simplyscroll-1.0.4.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(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" src="/static/js/projects.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user