mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
292 lines
6.1 KiB
HTML
Executable File
292 lines
6.1 KiB
HTML
Executable File
<html>
|
|
<head>
|
|
<title>ImageGrid.Viewer</title>
|
|
|
|
|
|
<link rel="stylesheet" href="layout.css">
|
|
<!-- use only for devel... -->
|
|
<!--link rel="stylesheet/less" href="layout.less"-->
|
|
|
|
<style>
|
|
|
|
|
|
|
|
</style>
|
|
|
|
|
|
<!--
|
|
<script>
|
|
less = {
|
|
// or "production"
|
|
env: "development",
|
|
|
|
// load imports async
|
|
async: false,
|
|
|
|
// load imports async when in a page under
|
|
// a file protocol
|
|
fileAsync: false,
|
|
|
|
// when in watch mode, time in ms between polls
|
|
//poll: 1000,
|
|
|
|
// user functions, keyed by name
|
|
//functions: {},
|
|
|
|
// or "mediaQuery" or "all"
|
|
//dumpLineNumbers: "comments",
|
|
|
|
// whether to adjust url's to be relative
|
|
// if false, url's are already relative to the
|
|
// entry less file
|
|
//relativeUrls: false,
|
|
|
|
// a path to add on to the start of every url
|
|
//resource
|
|
//rootpath: ":/a.com/"
|
|
}
|
|
</script>
|
|
<script src="ext-lib/less.js"></script>
|
|
-->
|
|
<script src="ext-lib/jquery.js"></script>
|
|
|
|
<script src="lib/jli.js"></script>
|
|
<script src="lib/keyboard.js"></script>
|
|
<script src="lib/scroller.js"></script>
|
|
|
|
<script src="base.js"></script>
|
|
<script src="modes.js"></script>
|
|
<script src="marks.js"></script>
|
|
<script src="data.js"></script>
|
|
<script src="files.js"></script>
|
|
<script src="localstorage.js"></script>
|
|
<script src="info.js"></script>
|
|
<script src="ui.js"></script>
|
|
<script src="setup.js"></script>
|
|
<script src="keybindings.js"></script>
|
|
|
|
|
|
<!-- XXX STUB -->
|
|
<script src="images.js"></script>
|
|
|
|
|
|
<script>
|
|
|
|
//DEBUG = true
|
|
|
|
var SCROLLER_ENABLED = true
|
|
|
|
// setup...
|
|
$(function(){
|
|
// defaults...
|
|
toggleTheme('gray')
|
|
toggleImageInfo('on')
|
|
|
|
setupIndicators()
|
|
|
|
autoHideCursor($('.viewer'))
|
|
|
|
if(SCROLLER_ENABLED){
|
|
var scroller = makeScrollHandler($('.viewer'), {
|
|
// XXX after click and initial move the screen jumps
|
|
// (both x and y), margins, left vs. translate?
|
|
//
|
|
// the problem is in centerView(...), seems scroller.js
|
|
// seems to not know where the element is after it does
|
|
// it's job, so the jump is scroller resetting the
|
|
// position...
|
|
scrollDisabled: true,
|
|
|
|
//enableMultiClicks: true,
|
|
// XXX does not seem to work...
|
|
//multiClickTimeout: 100,
|
|
|
|
// it's either this or disable the jQuery animation...
|
|
// ...have to benchmark to see which is better...
|
|
transitionDuration: 0,
|
|
transitionEasing: 'liner',
|
|
})
|
|
.start()
|
|
|
|
$('.viewer')
|
|
.on('shortClick', function(){ clickHandler(event) })
|
|
// XXX for some reason this is broken...
|
|
//.on('doubleClick', dblClickHandler)
|
|
.on('longClick', dblClickHandler)
|
|
|
|
.on('swipeLeft', function(){
|
|
updateDirection('prev')
|
|
prevImage()
|
|
centerRibbons()
|
|
})
|
|
.on('swipeRight', function(){
|
|
updateDirection('next')
|
|
nextImage()
|
|
centerRibbons()
|
|
})
|
|
.on('swipeUp', function(){
|
|
prevRibbon()
|
|
//shiftImageUp(null, DIRECTION)
|
|
centerRibbons()
|
|
})
|
|
.on('swipeDown', function(){
|
|
nextRibbon()
|
|
//shiftImageDown(null, DIRECTION)
|
|
centerRibbons()
|
|
})
|
|
|
|
|
|
} else {
|
|
// NOTE: this is global so as to not to add any extra complexity to
|
|
// the internal workings...
|
|
$('.viewer')
|
|
// XXX this messes things up...
|
|
//.dblclick(dblClickHandler)
|
|
.click(clickHandler)
|
|
}
|
|
|
|
$(window)
|
|
.resize(function() {
|
|
toggleImageProportions('!')
|
|
centerView()
|
|
})
|
|
|
|
$(document)
|
|
.keydown(makeKeyboardHandler(
|
|
KEYBOARD_CONFIG,
|
|
function(k){
|
|
window.DEBUG && console.log(k)
|
|
}))
|
|
|
|
setupDataBindings()
|
|
|
|
|
|
/* XXX drag/drop
|
|
$(document)
|
|
.bind('dragover', function(e){
|
|
e.stopPropagation()
|
|
e.preventDefault()
|
|
// XXX is there a jQuery way out of this??
|
|
e.originalEvent.dataTransfer.dropEffect = 'copy' // Explicitly show this is a copy.
|
|
})
|
|
.bind('drop', function(e){
|
|
e.stopPropagation()
|
|
e.preventDefault()
|
|
|
|
// XXX is there a jQuery way out of this??
|
|
var files = e.originalEvent.dataTransfer.files
|
|
|
|
// XXX should we be using the loadJSON here???
|
|
// XXX desperatly need image caching and preview generation...
|
|
|
|
for (var i = 0, f; f = files[i]; i++) {
|
|
|
|
if (!f.type.match('image.*')) {
|
|
continue
|
|
}
|
|
console.log('FILE:', f)
|
|
|
|
var reader = new FileReader()
|
|
reader.onload = function(i){
|
|
return function(e){
|
|
// XXX need to avoid data URLs here and use plain old paths...
|
|
//ribbon.append(makeImage(e.target.result, i))
|
|
console.log('DROPPED')//, e.target.result)
|
|
}
|
|
}(i)
|
|
|
|
reader.readAsDataURL(f)
|
|
//reader.readAsText(f)
|
|
}
|
|
|
|
})
|
|
*/
|
|
|
|
// we have an image file...
|
|
if((DATA_ATTR + '_BASE_URL') in localStorage){
|
|
BASE_URL = localStorage[DATA_ATTR + '_BASE_URL']
|
|
|
|
var loading = statusNotify(loadDir(BASE_URL))
|
|
|
|
} else {
|
|
// everything is in localStorage...
|
|
if('DATA' in localStorage){
|
|
loadLocalStorage()
|
|
|
|
// legacy default data...
|
|
} else {
|
|
DATA = convertDataGen1(image_list)
|
|
DATA = DATA.data
|
|
IMAGES = DATA.images
|
|
reloadViewer()
|
|
}
|
|
var loading = $.Deferred().resolve()
|
|
}
|
|
|
|
loading
|
|
.done(function(){
|
|
showStatus('Loading settings...')
|
|
loadLocalStorageSettings()
|
|
|
|
// XXX this will reload everything...
|
|
// XXX this might load the wrong marks (not sure)...
|
|
if('MARKED' in localStorage){
|
|
loadLocalStorageMarks()
|
|
}
|
|
|
|
updateImages()
|
|
})
|
|
|
|
})
|
|
|
|
|
|
</script>
|
|
|
|
</head>
|
|
<body>
|
|
|
|
<!-- This is the basic viewer structure...
|
|
|
|
Unpopulated
|
|
NOTE: there can be only .ribbon-set element.
|
|
|
|
<div class="viewer">
|
|
<div class="ribbon-set"></div>
|
|
</div>
|
|
|
|
|
|
Populated
|
|
|
|
<div class="viewer">
|
|
<div class="ribbon-set">
|
|
<div class="ribbon">
|
|
<div class="image"></div>
|
|
<div class="image"></div>
|
|
</div>
|
|
<div class="ribbon">
|
|
<div class="image"></div>
|
|
<div class="current image"></div>
|
|
<div class="image"></div>
|
|
<div class="image"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
-->
|
|
|
|
<div class="viewer">
|
|
|
|
<div class="ribbon-set"></div>
|
|
|
|
|
|
<!-- XXX should these be here??? -->
|
|
<div class="overlay-block">
|
|
<div class="background"></div>
|
|
<div class="content"></div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<!-- vim:set ts=4 sw=4 spell : -->
|
|
</body>
|
|
</html>
|