mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
315 lines
6.9 KiB
HTML
Executable File
315 lines
6.9 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="compatibility.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
|
|
var SCROLLER_ANIMATE_DURATION = 100
|
|
// XXX scroller transitions not yet ready...
|
|
// ...need to disable transitions on some actions (where we
|
|
// explicitly say 'css')
|
|
//var TRANSITION_MODE_DEFAULT = 'css'
|
|
|
|
// setup...
|
|
$(function(){
|
|
// NOTE: keep this as early as possible...
|
|
$(document)
|
|
.keydown(makeKeyboardHandler(
|
|
KEYBOARD_CONFIG,
|
|
function(k){
|
|
window.DEBUG && console.log(k)
|
|
}))
|
|
|
|
// defaults...
|
|
toggleTheme('gray')
|
|
toggleImageInfo('on')
|
|
// XXX this needs at least an image loaded...
|
|
//toggleImageProportions('fit-viewer')
|
|
|
|
setupIndicators()
|
|
autoHideCursor($('.viewer'))
|
|
|
|
|
|
if(SCROLLER_ENABLED){
|
|
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...
|
|
// XXX BUG: if transition is set to non-0 then it initializes
|
|
// only after an action, e.g. a click...
|
|
transitionDuration: TRANSITION_MODE_DEFAULT == 'animate' ? 0 : SCROLLER_ANIMATE_DURATION,
|
|
transitionEasing: 'liner',
|
|
|
|
// keep selectable elements selectable...
|
|
ignoreElements: '.noScroll, '+
|
|
'.image .inline-image-info, '+
|
|
'.overlay-info, '+
|
|
'.overlay, '+
|
|
'',
|
|
})
|
|
|
|
$('.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()
|
|
shiftImageDown(null, DIRECTION)
|
|
centerRibbons()
|
|
})
|
|
.on('swipeDown', function(){
|
|
//nextRibbon()
|
|
shiftImageUp(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()
|
|
})
|
|
|
|
setupBaseURLHistory()
|
|
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
|
|
&& !/^\.[\/\\]*/.test(localStorage[DATA_ATTR + '_BASE_URL'])){
|
|
|
|
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)
|
|
IMAGES = DATA.images
|
|
DATA = DATA.data
|
|
reloadViewer()
|
|
}
|
|
var loading = $.Deferred().resolve()
|
|
}
|
|
|
|
loading
|
|
.done(function(){
|
|
showStatus('Loading settings...')
|
|
DATA_ATTR + '_SETTINGS' in localStorage && loadLocalStorageSettings()
|
|
|
|
// XXX this will reload everything...
|
|
(MARKED.length == 0
|
|
&& DATA_ATTR + '_MARKED' in localStorage
|
|
&& loadLocalStorageMarks())
|
|
|
|
updateImages()
|
|
|
|
SCROLLER.start()
|
|
})
|
|
|
|
})
|
|
|
|
|
|
</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>
|