2012-06-05 15:26:41 +04:00
|
|
|
|
|
|
|
|
<!--
|
|
|
|
|
TODO:
|
|
|
|
|
- basic structure
|
|
|
|
|
ribbons
|
|
|
|
|
images
|
|
|
|
|
indicators
|
|
|
|
|
- basic control elements
|
|
|
|
|
touch zones / buttons
|
|
|
|
|
next
|
|
|
|
|
prev
|
|
|
|
|
shift up
|
|
|
|
|
shift down
|
|
|
|
|
promote
|
|
|
|
|
demote
|
|
|
|
|
zoom in
|
|
|
|
|
zoom out
|
|
|
|
|
toggle single image
|
2012-06-05 16:28:47 +04:00
|
|
|
|
|
|
|
|
ISSUES:
|
|
|
|
|
- jumping...
|
2012-06-05 15:26:41 +04:00
|
|
|
-->
|
|
|
|
|
|
|
|
|
|
<script src="jquery.js"></script>
|
|
|
|
|
<script>
|
|
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
|
$(".image").click(function(e) {
|
|
|
|
|
|
2012-06-05 17:35:13 +04:00
|
|
|
var cur = $(this)
|
|
|
|
|
|
2012-06-05 15:26:41 +04:00
|
|
|
// switch classes...
|
2012-06-05 17:35:13 +04:00
|
|
|
cur.parents().siblings().children(".image").removeClass("current-image")
|
|
|
|
|
cur.siblings(".image").removeClass("current-image")
|
2012-06-05 15:26:41 +04:00
|
|
|
|
2012-06-05 17:35:13 +04:00
|
|
|
cur.siblings().children(".image").removeClass("current-image")
|
|
|
|
|
cur.parents().siblings(".ribbon").removeClass("current-ribbon")
|
2012-06-05 15:26:41 +04:00
|
|
|
|
2012-06-05 17:35:13 +04:00
|
|
|
cur.addClass("current-image")
|
|
|
|
|
cur.parents(".ribbon").addClass("current-ribbon")
|
2012-06-05 15:26:41 +04:00
|
|
|
|
2012-06-06 16:59:32 +04:00
|
|
|
|
2012-06-05 17:35:13 +04:00
|
|
|
var container = cur.parents('.container')
|
|
|
|
|
var field = cur.parents(".field")
|
2012-06-05 15:26:41 +04:00
|
|
|
|
2012-06-05 17:35:13 +04:00
|
|
|
var image_offset = cur.offset()
|
2012-06-05 17:24:10 +04:00
|
|
|
var field_offset = field.offset()
|
2012-06-05 15:26:41 +04:00
|
|
|
|
2012-06-05 16:28:47 +04:00
|
|
|
// center the current image...
|
2012-06-05 17:28:50 +04:00
|
|
|
field.css({
|
2012-06-05 17:35:13 +04:00
|
|
|
left: field_offset.left - image_offset.left + (container.innerWidth() - cur.innerWidth())/2,
|
|
|
|
|
top: field_offset.top - image_offset.top + (container.innerHeight() - cur.innerHeight())/2
|
2012-06-05 17:24:10 +04:00
|
|
|
})
|
2012-06-05 17:28:50 +04:00
|
|
|
|
2012-06-05 16:28:47 +04:00
|
|
|
|
2012-06-05 17:35:13 +04:00
|
|
|
// XXX do I need this???
|
2012-06-05 16:28:47 +04:00
|
|
|
e.preventDefault();
|
2012-06-05 15:26:41 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// set the default position...
|
|
|
|
|
$('.current-image').click()
|
2012-06-06 22:06:10 +04:00
|
|
|
$(document).bind('keydown', handleKeys)
|
2012-06-05 15:26:41 +04:00
|
|
|
});
|
|
|
|
|
|
2012-06-06 22:06:10 +04:00
|
|
|
var keys = {
|
|
|
|
|
toggleHelpKeys: [72],
|
|
|
|
|
toggleRibbonView: [32],
|
|
|
|
|
closeKeys: [27, 88, 67],
|
|
|
|
|
|
|
|
|
|
previousKeys: [37, 80],
|
|
|
|
|
nextKeys: [39, 78],
|
|
|
|
|
|
|
|
|
|
helpShowOnUnknownKey: true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleKeys(event){
|
|
|
|
|
var code = event.keyCode, fn = $.inArray;
|
|
|
|
|
// XXX
|
|
|
|
|
var _ = (fn(code, keys.closeKeys) >= 0) ? function(){}()
|
|
|
|
|
: (fn(code, keys.nextKeys) >= 0) ? nextImage()
|
|
|
|
|
: (fn(code, keys.previousKeys) >= 0) ? prevImage()
|
|
|
|
|
: (fn(code, keys.toggleRibbonView) >= 0) ? toggleRibbonView()
|
|
|
|
|
// XXX
|
|
|
|
|
: (keys.helpShowOnUnknownKey) ? function(){}()
|
|
|
|
|
: false;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-06-06 16:47:53 +04:00
|
|
|
// modes...
|
|
|
|
|
function showRibbon(){
|
2012-06-06 16:53:06 +04:00
|
|
|
$('.single-image-mode').removeClass('single-image-mode')
|
2012-06-06 16:47:53 +04:00
|
|
|
}
|
|
|
|
|
function showSingle(){
|
2012-06-06 16:53:06 +04:00
|
|
|
$('.field').not('.single-image-mode').addClass('single-image-mode')
|
2012-06-06 16:47:53 +04:00
|
|
|
}
|
2012-06-06 22:06:10 +04:00
|
|
|
function toggleRibbonView(){
|
|
|
|
|
if($('.single-image-mode').length > 0){
|
|
|
|
|
showRibbon()
|
|
|
|
|
} else {
|
|
|
|
|
showSingle()
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-06-06 16:47:53 +04:00
|
|
|
|
2012-06-05 17:50:58 +04:00
|
|
|
// basic navigation...
|
2012-06-05 16:28:47 +04:00
|
|
|
function prevImage(){
|
|
|
|
|
$('.current-image').prev('.image').click()
|
|
|
|
|
}
|
2012-06-05 17:50:58 +04:00
|
|
|
|
2012-06-05 16:28:47 +04:00
|
|
|
function nextImage(){
|
|
|
|
|
$('.current-image').next('.image').click()
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-05 17:50:58 +04:00
|
|
|
// XXX move to above ribbon...
|
|
|
|
|
|
|
|
|
|
// XXX move to below ribbon...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// create ribbon above/below helpers...
|
|
|
|
|
// XXX
|
|
|
|
|
|
|
|
|
|
// promote...
|
|
|
|
|
// XXX
|
|
|
|
|
|
|
|
|
|
// demote...
|
|
|
|
|
// XXX
|
|
|
|
|
|
2012-06-05 16:28:47 +04:00
|
|
|
|
|
|
|
|
|
2012-06-05 15:26:41 +04:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style>
|
2012-06-05 17:44:42 +04:00
|
|
|
.image {
|
2012-06-05 15:26:41 +04:00
|
|
|
position: relative;
|
|
|
|
|
display: inline-block;
|
2012-06-05 16:28:47 +04:00
|
|
|
|
2012-06-05 17:44:42 +04:00
|
|
|
opacity: 0.3;
|
2012-06-05 15:26:41 +04:00
|
|
|
|
2012-06-05 16:28:47 +04:00
|
|
|
-webkit-transition: all 0.5s ease;
|
|
|
|
|
-moz-transition: all 0.5s ease;
|
|
|
|
|
-o-transition: all 0.5s ease;
|
|
|
|
|
-ms-transition: all 0.5s ease;
|
|
|
|
|
transition: all 0.5s ease;
|
2012-06-05 17:44:42 +04:00
|
|
|
|
|
|
|
|
cursor: hand;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.mock-image {
|
2012-06-06 16:16:13 +04:00
|
|
|
width: 350px;
|
|
|
|
|
height: 350px;
|
2012-06-05 17:44:42 +04:00
|
|
|
|
|
|
|
|
background: blue;
|
2012-06-05 15:26:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.container {
|
|
|
|
|
overflow: hidden;
|
2012-06-06 16:16:13 +04:00
|
|
|
width: 800px;
|
|
|
|
|
height: 500px;
|
2012-06-05 15:26:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.field {
|
|
|
|
|
position: relative;
|
|
|
|
|
overflow: visible;
|
|
|
|
|
top: 0px;
|
|
|
|
|
left: -100px;
|
2012-06-05 17:35:13 +04:00
|
|
|
|
|
|
|
|
-webkit-transition: all 0.5s ease;
|
|
|
|
|
-moz-transition: all 0.5s ease;
|
|
|
|
|
-o-transition: all 0.5s ease;
|
|
|
|
|
-ms-transition: all 0.5s ease;
|
|
|
|
|
transition: all 0.5s ease;
|
2012-06-05 15:26:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.ribbon {
|
2012-06-06 16:16:13 +04:00
|
|
|
height: 360px;
|
|
|
|
|
width: 5000px;
|
2012-06-05 15:26:41 +04:00
|
|
|
overflow: visible;
|
2012-06-05 16:28:47 +04:00
|
|
|
padding-top: 2px;
|
|
|
|
|
padding-bottom: 2px;
|
2012-06-05 15:26:41 +04:00
|
|
|
text-align: center;
|
2012-06-05 16:28:47 +04:00
|
|
|
opacity: 0.2;
|
2012-06-05 15:26:41 +04:00
|
|
|
|
|
|
|
|
-webkit-transition: all 0.5s ease;
|
|
|
|
|
-moz-transition: all 0.5s ease;
|
|
|
|
|
-o-transition: all 0.5s ease;
|
|
|
|
|
-ms-transition: all 0.5s ease;
|
|
|
|
|
transition: all 0.5s ease;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.current-image {
|
2012-06-05 17:44:42 +04:00
|
|
|
opacity: 1.0;
|
2012-06-05 15:26:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.current-ribbon {
|
2012-06-06 16:16:13 +04:00
|
|
|
padding-top: 20px;
|
|
|
|
|
padding-bottom: 20px;
|
2012-06-05 16:28:47 +04:00
|
|
|
|
|
|
|
|
opacity: 1.0;
|
2012-06-05 15:26:41 +04:00
|
|
|
|
|
|
|
|
-webkit-transition: all 0.5s ease;
|
|
|
|
|
-moz-transition: all 0.5s ease;
|
|
|
|
|
-o-transition: all 0.5s ease;
|
|
|
|
|
-ms-transition: all 0.5s ease;
|
|
|
|
|
transition: all 0.5s ease;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.current-ribbon .image {
|
|
|
|
|
}
|
2012-06-06 16:47:53 +04:00
|
|
|
|
|
|
|
|
|
2012-06-06 16:59:32 +04:00
|
|
|
/* single image theme (start everything with .single-image-mode)
|
|
|
|
|
*
|
|
|
|
|
* XXX need to make this touch friendly...
|
|
|
|
|
*/
|
2012-06-06 16:53:06 +04:00
|
|
|
.single-image-mode .image {
|
2012-06-06 16:47:53 +04:00
|
|
|
opacity: 0.0;
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-06 16:53:06 +04:00
|
|
|
.single-image-mode .image:hover {
|
2012-06-06 16:47:53 +04:00
|
|
|
opacity: 0.5;
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-06 16:53:06 +04:00
|
|
|
.single-image-mode .current-image:hover, .single-image-mode .current-image {
|
2012-06-06 16:47:53 +04:00
|
|
|
opacity: 1.0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-06-05 15:26:41 +04:00
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="container">
|
|
|
|
|
<div class="field">
|
|
|
|
|
<div class="ribbon">
|
|
|
|
|
<div class="image mock-image"></div>
|
|
|
|
|
<div class="image mock-image"></div>
|
|
|
|
|
<div class="image mock-image"></div>
|
|
|
|
|
<div class="image mock-image"></div>
|
|
|
|
|
<div class="image mock-image"></div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="ribbon">
|
|
|
|
|
<div class="image mock-image"></div>
|
|
|
|
|
<div class="image mock-image"></div>
|
|
|
|
|
<div class="image mock-image"></div>
|
|
|
|
|
<div class="image mock-image"></div>
|
|
|
|
|
<div class="image mock-image"></div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="ribbon current-ribbon">
|
|
|
|
|
<div class="image mock-image"></div>
|
|
|
|
|
<div class="image mock-image"></div>
|
|
|
|
|
<div class="image mock-image current-image"></div>
|
|
|
|
|
<div class="image mock-image"></div>
|
|
|
|
|
<div class="image mock-image"></div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="ribbon">
|
|
|
|
|
<div class="image mock-image"></div>
|
|
|
|
|
<div class="image mock-image"></div>
|
|
|
|
|
<div class="image mock-image"></div>
|
|
|
|
|
<div class="image mock-image"></div>
|
|
|
|
|
<div class="image mock-image"></div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="ribbon">
|
|
|
|
|
<div class="image mock-image"></div>
|
|
|
|
|
<div class="image mock-image"></div>
|
|
|
|
|
<div class="image mock-image"></div>
|
|
|
|
|
<div class="image mock-image"></div>
|
|
|
|
|
<div class="image mock-image"></div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2012-06-05 16:28:47 +04:00
|
|
|
<button onclick="prevImage()">prev</button>
|
|
|
|
|
<button onclick="nextImage()">next</button>
|
|
|
|
|
|
2012-06-06 16:47:53 +04:00
|
|
|
<br><br>
|
|
|
|
|
|
|
|
|
|
<button onclick="showSingle()">single</button>
|
|
|
|
|
<button onclick="showRibbon()">ribbon</button>
|
2012-06-06 22:06:10 +04:00
|
|
|
<button onclick="toggleRibbonView()">toggle ribbon view</button>
|
2012-06-06 16:47:53 +04:00
|
|
|
|
2012-06-06 16:59:32 +04:00
|
|
|
|
2012-06-05 16:28:47 +04:00
|
|
|
<!-- vim:set ts=4 sw=4 nowrap : -->
|