Script unu:
Cod: Selectaţi tot
var hash = window.location.hash.toString();
var projectsArray = [
{
name: 'Carravel',
previous : 'cubink',
current: 'carravel',
next :'mhatis'
},
{
name: 'Mhatis',
previous: 'carravel',
current: 'mhatis',
next : 'cubink'
},
{
name: 'Cubink',
previous: 'mhatis',
current: 'cubink',
next : 'carravel'
}
];
var pI = [];
pI['carravel']=0;
pI['mhatis']=1;
pI['cubink']=2;
var siteUrl ='http://78.96.188.79/projects/';
Script doi:
Cod: Selectaţi tot
$(window).load(function(){
var PREV = $('#pnav-prev');
var NEXT = $('#pnav-next');
var NAV = $('a.pnav');
var query = hash.substr(3);
console.log(hash);
var pIndex = pI['carravel'];
console.log(query);
if(query in pI){
pIndex = pI[query];
}
var pItem = projectsArray[pIndex];
var pageProjects = $('#page-projects');
$('<div/>').attr('id','project-loading').html('Loading').appendTo(pageProjects);
$.ajax({
url:'/projects/page/',
async:false,
type: 'POST',
data:'current='+query,
success : function(data){
$('#project-loading').remove();
pageProjects.css({display:'none'});
pageProjects.html(data);
pageProjects.fadeIn(500);
$('#project-navigation').fadeIn(1000);
PREV.attr('data-url',pItem.previous);
NEXT.attr('data-url',pItem.next);
}
});
});
Script trei:
Cod: Selectaţi tot
$(window).load(function(){
var PREV = $('#pnav-prev');
var NEXT = $('#pnav-next');
var NAV = $('a.pnav');
var pageProjects = $('#page-projects');
NAV.click(function(e){
e.preventDefault();
urlToLoad = projectsArray[pI[$(this).attr('data-url')]];
pageProjects.fadeOut(500,function(){
pageProjects.empty();
$('<div/>').attr('id','project-loading').html('Loading').appendTo(pageProjects);
$.ajax({
async: false,
type: 'POST',
url:'/projects/page',
data:'current='+urlToLoad.current,
success:function(dt){
$('#project-loading').remove();
pageProjects.css({display:'none'});
pageProjects.html(dt);
pageProjects.fadeIn(500);
window.location.href=siteUrl+'#!/'+urlToLoad.current;
PREV.attr('data-url',urlToLoad.previous);
NEXT.attr('data-url',urlToLoad.next);
}
});
});
});
Astea sunt scripturile complete, contin cam tot ce ai zis tu, dar tot nu reusesc, poate trebuie si un fisier php pe undeva?! Vreau sa accesez cumva toate cele trei proiecte, fara sa trec url-ul lor specific, pentru ca se blocheaza sliderul pe acel proiect, nu trece la urmatorul. M-ai ajuta enorm daca i-ai da de cap. Merci