mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-12-18 09:11:39 +00:00
alert(...) and prompt(...) dialogs now working, still need styling...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
74e984d9bb
commit
5c0741b99a
@ -69,6 +69,23 @@ var KEYBOARD_CONFIG = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// dialogs...
|
||||||
|
//
|
||||||
|
'.viewer.overlay .overlay-block.dialog': {
|
||||||
|
title: 'Dialog',
|
||||||
|
|
||||||
|
Enter: doc('Accept dialog',
|
||||||
|
function(){
|
||||||
|
getOverlay($('.viewer')).trigger('accept')
|
||||||
|
}),
|
||||||
|
Esc: doc('Close dialog',
|
||||||
|
function(){
|
||||||
|
hideOverlay($('.viewer'))
|
||||||
|
return false
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// help mode...
|
// help mode...
|
||||||
//
|
//
|
||||||
|
|||||||
73
ui/modes.js
73
ui/modes.js
@ -39,7 +39,7 @@ function makeDrawerToggler(contentRenderer, root){
|
|||||||
|
|
||||||
// prepare and cleanup...
|
// prepare and cleanup...
|
||||||
$(element_class).remove()
|
$(element_class).remove()
|
||||||
$(root).addClass('overlay')
|
showInOverlay($(root))
|
||||||
|
|
||||||
// build the help...
|
// build the help...
|
||||||
var doc = contentRenderer()
|
var doc = contentRenderer()
|
||||||
@ -83,7 +83,7 @@ function makeDrawerToggler(contentRenderer, root){
|
|||||||
// things to cleanup...
|
// things to cleanup...
|
||||||
var _cleanup = function(){
|
var _cleanup = function(){
|
||||||
$(element_class).remove()
|
$(element_class).remove()
|
||||||
$(root).removeClass('overlay')
|
hideOverlay($(root))
|
||||||
// XXX depends on body...
|
// XXX depends on body...
|
||||||
body.click()
|
body.click()
|
||||||
win.off('scroll', scroll_handler)
|
win.off('scroll', scroll_handler)
|
||||||
@ -179,50 +179,43 @@ var toggleSlideShowMode = createCSSClassToggler(
|
|||||||
if(action == 'on'){
|
if(action == 'on'){
|
||||||
updateStatus('Slideshow...').show()
|
updateStatus('Slideshow...').show()
|
||||||
|
|
||||||
// XXX is this the correct way to go???
|
|
||||||
$('.viewer').addClass('overlay')
|
|
||||||
|
|
||||||
// interval from user...
|
// interval from user...
|
||||||
// XXX make this a real UI...
|
//var interval = prompt('Slideshow interval (sec):', SLIDESHOW_INTERVAL/1000)
|
||||||
var interval = prompt('Slideshow interval (sec):', SLIDESHOW_INTERVAL/1000)
|
prompt('Slideshow interval (sec):', SLIDESHOW_INTERVAL/1000)
|
||||||
|
.done(function(interval){
|
||||||
|
interval = parseFloat(interval)
|
||||||
|
|
||||||
// user cancelled...
|
SLIDESHOW_INTERVAL = isNaN(interval) ? 3000 : interval*1000
|
||||||
if(interval == null){
|
|
||||||
showStatus('Slideshow: cencelled...')
|
|
||||||
toggleSlideShowMode('off')
|
|
||||||
|
|
||||||
// XXX is this the correct way to go???
|
showStatus('Slideshow: starting', SLIDESHOW_LOOP ? 'looped...' : 'unlooped...')
|
||||||
$('.viewer').removeClass('overlay')
|
|
||||||
|
// XXX is this the correct way to go???
|
||||||
|
hideOverlay($('.viewer'))
|
||||||
|
|
||||||
return
|
toggleSingleImageMode('on')
|
||||||
}
|
_slideshow_timer = setInterval(function(){
|
||||||
|
var cur = getImage()
|
||||||
|
// advance the image...
|
||||||
|
var next = SLIDESHOW_DIRECTION == 'next' ? nextImage() : prevImage()
|
||||||
|
|
||||||
SLIDESHOW_INTERVAL = isNaN(interval) ? 3000 : interval*1000
|
// handle slideshow end...
|
||||||
|
if(getImageGID(cur) == getImageGID(next)){
|
||||||
|
if(SLIDESHOW_LOOP){
|
||||||
|
SLIDESHOW_DIRECTION == 'next' ? firstImage() : lastImage()
|
||||||
|
} else {
|
||||||
|
toggleSlideShowMode('off')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
showStatus('Slideshow: starting', SLIDESHOW_LOOP ? 'looped...' : 'unlooped...')
|
// center and trigger load events...
|
||||||
|
centerRibbon()
|
||||||
// XXX is this the correct way to go???
|
}, SLIDESHOW_INTERVAL)
|
||||||
$('.viewer').removeClass('overlay')
|
})
|
||||||
|
// user cancelled...
|
||||||
toggleSingleImageMode('on')
|
.fail(function(){
|
||||||
_slideshow_timer = setInterval(function(){
|
toggleSlideShowMode('off')
|
||||||
var cur = getImage()
|
})
|
||||||
// advance the image...
|
|
||||||
var next = SLIDESHOW_DIRECTION == 'next' ? nextImage() : prevImage()
|
|
||||||
|
|
||||||
// handle slideshow end...
|
|
||||||
if(getImageGID(cur) == getImageGID(next)){
|
|
||||||
if(SLIDESHOW_LOOP){
|
|
||||||
SLIDESHOW_DIRECTION == 'next' ? firstImage() : lastImage()
|
|
||||||
} else {
|
|
||||||
toggleSlideShowMode('off')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// center and trigger load events...
|
|
||||||
centerRibbon()
|
|
||||||
}, SLIDESHOW_INTERVAL)
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
window._slideshow_timer != null && clearInterval(_slideshow_timer)
|
window._slideshow_timer != null && clearInterval(_slideshow_timer)
|
||||||
|
|||||||
75
ui/ui.js
75
ui/ui.js
@ -315,6 +315,11 @@ function showContextIndicator(cls, text){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* Modal dialogs...
|
||||||
|
*/
|
||||||
|
|
||||||
function getOverlay(root){
|
function getOverlay(root){
|
||||||
root = $(root)
|
root = $(root)
|
||||||
var overlay = root.find('.overlay-block')
|
var overlay = root.find('.overlay-block')
|
||||||
@ -345,9 +350,14 @@ function showInOverlay(root, data){
|
|||||||
|
|
||||||
dialog
|
dialog
|
||||||
.append(data)
|
.append(data)
|
||||||
.click(function(){ event.stopPropagation() })
|
.one('click', function(){
|
||||||
|
event.stopPropagation()
|
||||||
|
})
|
||||||
overlay.find('.content')
|
overlay.find('.content')
|
||||||
.click(function(){ hideOverlay(root) })
|
.on('click', function(){
|
||||||
|
overlay.trigger('close')
|
||||||
|
hideOverlay(root)
|
||||||
|
})
|
||||||
.append(container)
|
.append(container)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,24 +369,71 @@ function showInOverlay(root, data){
|
|||||||
|
|
||||||
function hideOverlay(root){
|
function hideOverlay(root){
|
||||||
root.removeClass('overlay')
|
root.removeClass('overlay')
|
||||||
root.find('.overlay-block').remove()
|
root.find('.overlay-block')
|
||||||
|
.trigger('close')
|
||||||
|
.remove()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/************************************************ Standard dialogs ***/
|
||||||
|
|
||||||
function alert(){
|
function alert(){
|
||||||
// XXX use CSS!!!
|
var res = $.Deferred()
|
||||||
return showInOverlay($('.viewer'), $('<span/>')
|
showInOverlay($('.viewer'), $('<span/>')
|
||||||
.text(Array.apply(null, arguments).join(' ')))
|
.text(Array.apply(null, arguments).join(' ')))
|
||||||
|
.addClass('alert dialog')
|
||||||
|
.on('close accept', function(){
|
||||||
|
res.resolve()
|
||||||
|
})
|
||||||
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function prompt(message, dfl){
|
||||||
|
var root = $('.viewer')
|
||||||
|
var res = $.Deferred()
|
||||||
|
|
||||||
|
var form = $('<div>'+
|
||||||
|
'<div class="text"/>'+
|
||||||
|
'<input type="text" tabindex=1/>'+
|
||||||
|
'<button tabindex=2>Done</button>'+
|
||||||
|
'</div>')
|
||||||
|
form.find('.text')
|
||||||
|
.text(message)
|
||||||
|
var overlay = showInOverlay(root, form)
|
||||||
|
.addClass('prompt dialog')
|
||||||
|
.on('close', function(){
|
||||||
|
res.reject()
|
||||||
|
})
|
||||||
|
.on('accept', function(){
|
||||||
|
res.resolve(form.find('input').attr('value'))
|
||||||
|
hideOverlay(root)
|
||||||
|
})
|
||||||
|
|
||||||
|
form.find('button')
|
||||||
|
.click(function(){
|
||||||
|
overlay.trigger('accept')
|
||||||
|
})
|
||||||
|
|
||||||
|
var input = form.find('input')
|
||||||
|
|
||||||
|
input
|
||||||
|
.focus()
|
||||||
|
setTimeout(function(){
|
||||||
|
input.attr('value', dfl == null ? '' : dfl)
|
||||||
|
}, 100)
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
function prompt(){
|
|
||||||
}
|
|
||||||
|
|
||||||
function confirm(){
|
function confirm(){
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
// vim:set ts=4 sw=4 nowrap :
|
// vim:set ts=4 sw=4 nowrap :
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user