From 4dd37e616478fef02cbcb32049c6b94891a3cf35 Mon Sep 17 00:00:00 2001 From: Arun Persaud Date: Mon, 6 Feb 2012 22:09:34 -0800 Subject: added prev/next arrows on top of single picture --- arrow.svg | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ index.php | 42 +++++++++++++++++++++++++++---- left.png | Bin 0 -> 2792 bytes right.png | Bin 0 -> 2807 bytes style.css | 43 +++++++++++++++++++++++++++++++- 5 files changed, 163 insertions(+), 6 deletions(-) create mode 100644 arrow.svg create mode 100644 left.png create mode 100644 right.png diff --git a/arrow.svg b/arrow.svg new file mode 100644 index 0000000..569bda4 --- /dev/null +++ b/arrow.svg @@ -0,0 +1,84 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/index.php b/index.php index 34efdc4..d178a41 100644 --- a/index.php +++ b/index.php @@ -125,15 +125,16 @@ function load_content(a) { /* if ID is set, just show one pictures, else create an array of pictures */ if (ID>=0) { - pics.selectAll("li").data(picdata) - .enter().append("li") - .append("img") + var singlepicspace=pics.selectAll("li").data(picdata).enter().append("li").append("div").attr("class","singlepic"); + singlepicspace.append("div").attr("class","left").append("img").attr("src","/left.png"); + singlepicspace.append("img") .attr("class","large") .attr("src",function(d) { s= d.base_uri+'/'+d.filename; s = s.replace('file:\/\/','/Photos-small/'); return s; }); + singlepicspace.append("div").attr("class","right").append("img").attr("src","/right.png"); /* update thumbnails */ if(T!="") @@ -141,6 +142,9 @@ function load_content(a) { else url2 = "/getjson.php?NP=1&ID="+ID; + var IDprev=-1; + var IDnext=-1; + var IDcurr=-1; d3.json(url2, function(json2) { var thumbs= d3.select(".nextprev").select("ul").selectAll("li").data(json2); thumbs.enter().append("li") @@ -150,6 +154,14 @@ function load_content(a) { if(T!="") s = s + '/tag/' + T; s = s + '/pic/' + d.id; + + if( IDcurr != ID ) + { + IDprev = IDcurr; + IDcurr = IDnext; + IDnext = d.id; + } + return s; }) .append("img") @@ -161,6 +173,22 @@ function load_content(a) { thumbs.exit().remove(); + if (IDprev != -1 ) + { + s = ''; + if(T!="") + s = s + '/tag/' + T; + s = s + '/pic/' + IDprev; + d3.select(".left").on("click", function(d) { document.location.href=s }) + } + if (IDnext != -1 ) + { + s = ''; + if(T!="") + s = s + '/tag/' + T; + s = s + '/pic/' + IDnext; + d3.select(".right").on("click", function(d) { document.location.href=s }) + } }); } @@ -250,11 +278,15 @@ function checkbutton() function update_page_index(mypage) { /* load number of pictures */ + + myID = ""; + if(ID > 0) + myID = "&ID="+ID; if(T!="") - url = "/getjson.php?C=1&T="+T; + url = "/getjson.php?C=1&T="+T+myID; else - url = "/getjson.php?C=1"; + url = "/getjson.php?C=1"+myID; d3.json(url, function(json) { /* update index, show only page +-5 pages max */ diff --git a/left.png b/left.png new file mode 100644 index 0000000..c55bbf2 Binary files /dev/null and b/left.png differ diff --git a/right.png b/right.png new file mode 100644 index 0000000..d606e36 Binary files /dev/null and b/right.png differ diff --git a/style.css b/style.css index 75bea14..8b7a7b9 100644 --- a/style.css +++ b/style.css @@ -59,4 +59,45 @@ footer { } .nextprev ul li img { padding-right: 5px; -} \ No newline at end of file +} + +.singlepic { + position: relative; + display: inline-block; +} + +.singlepic:hover .left, .singlepic:hover .right { + display: inline-block; + opacity: 0.6; +} + +.singlepic .left img, .singlepic .right img { + position: absolute; + top: 50%; + width: 50px; + height: 50px; + margin-top: -25px; + border: 0px solid white; +} + +.singlepic .left, .singlepic .right { + display: none; + height: 500px; + width: 50px; + z-index:2; + opacity: 0.0; +} +.singlepic .left { + position: absolute; + left: 3px; + top: 3px; +} +.singlepic .right { + position: relative; + left: -56px; + top: -3px; +} + +.singlepic .left:hover, .singlepic .right:hover { + opacity: 0.95; +} -- cgit v1.2.3-18-g5258