mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-12-19 09:41:40 +00:00
made crop modes alot more generic...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
fa64b51e89
commit
6d80a86ab2
56
ui/data.js
56
ui/data.js
@ -111,6 +111,8 @@ var MARKED = []
|
|||||||
|
|
||||||
var CROP_STACK = []
|
var CROP_STACK = []
|
||||||
|
|
||||||
|
var CROP_MODES = []
|
||||||
|
|
||||||
// NOTE: these are named: <mode>-<feature>
|
// NOTE: these are named: <mode>-<feature>
|
||||||
var SETTINGS = {
|
var SETTINGS = {
|
||||||
'global-theme': null,
|
'global-theme': null,
|
||||||
@ -1639,6 +1641,60 @@ function showAllData(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Helpers for making crop modes and using crop...
|
||||||
|
|
||||||
|
// Make a generic crop mode toggler
|
||||||
|
//
|
||||||
|
// NOTE: This will add the toggler to CROP_MODES, for use by
|
||||||
|
// uncropLastState(...)
|
||||||
|
function makeCropModeToggler(cls, crop){
|
||||||
|
var res = createCSSClassToggler(
|
||||||
|
'.viewer',
|
||||||
|
cls + ' cropped-mode',
|
||||||
|
function(action){
|
||||||
|
// prevent mixing marked-only and single-ribbon modes...
|
||||||
|
if(action == 'on'
|
||||||
|
&& $('.viewer').hasClass('cropped-mode')
|
||||||
|
&& res('?') != 'on'){
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
function(action){
|
||||||
|
if(action == 'on'){
|
||||||
|
showStatusQ('Cropping current ribbon...')
|
||||||
|
crop()
|
||||||
|
} else {
|
||||||
|
showStatusQ('Uncropping to all data...')
|
||||||
|
showAllData()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
CROP_MODES.push(res)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Uncrop to last state and there is no states to uncrop then exit
|
||||||
|
// cropped mode.
|
||||||
|
//
|
||||||
|
// NOTE: this will exit all crop modes when uncropping the last step.
|
||||||
|
function uncropLastState(){
|
||||||
|
// do nothing if we aren't in a crop mode...
|
||||||
|
if(!$('.viewer').hasClass('cropped-mode')){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// exit cropped all modes...
|
||||||
|
if(CROP_STACK.length == 1){
|
||||||
|
$.each(CROP_MODES, function(_, e){ e('off') })
|
||||||
|
|
||||||
|
// ucrop one state...
|
||||||
|
} else {
|
||||||
|
showStatusQ('Uncropping...')
|
||||||
|
uncropData()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************************************************* Workers ***/
|
/********************************************************* Workers ***/
|
||||||
|
|
||||||
|
|||||||
@ -22,9 +22,9 @@
|
|||||||
<script src="compatibility.js"></script>
|
<script src="compatibility.js"></script>
|
||||||
|
|
||||||
<script src="base.js"></script>
|
<script src="base.js"></script>
|
||||||
|
<script src="data.js"></script>
|
||||||
<script src="modes.js"></script>
|
<script src="modes.js"></script>
|
||||||
<script src="marks.js"></script>
|
<script src="marks.js"></script>
|
||||||
<script src="data.js"></script>
|
|
||||||
<script src="files.js"></script>
|
<script src="files.js"></script>
|
||||||
<script src="localstorage.js"></script>
|
<script src="localstorage.js"></script>
|
||||||
<script src="info.js"></script>
|
<script src="info.js"></script>
|
||||||
|
|||||||
24
ui/marks.js
24
ui/marks.js
@ -46,27 +46,9 @@ function cropMarkedImages(cmp, no_cleanout_marks){
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// XXX is this a mode???
|
// XXX is this a mode???
|
||||||
var toggleMarkedOnlyView = createCSSClassToggler(
|
var toggleMarkedOnlyView = makeCropModeToggler(
|
||||||
'.viewer',
|
'marked-only-view',
|
||||||
'marked-only-view cropped-mode',
|
cropMarkedImages)
|
||||||
function(action){
|
|
||||||
// prevent mixing marked-only and single-ribbon modes...
|
|
||||||
if(action == 'on'
|
|
||||||
&& $('.viewer').hasClass('cropped-mode')
|
|
||||||
&& toggleMarkedOnlyView('?') != 'on'){
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
function(action){
|
|
||||||
if(action == 'on'){
|
|
||||||
// XXX do we need to keep ribbons here???
|
|
||||||
showStatusQ('Cropping marked images...')
|
|
||||||
cropMarkedImages()
|
|
||||||
} else {
|
|
||||||
showStatusQ('Uncropping to all data...')
|
|
||||||
showAllData()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
// XXX shifting images and unmarking in this mode do not work correctly...
|
// XXX shifting images and unmarking in this mode do not work correctly...
|
||||||
|
|||||||
40
ui/modes.js
40
ui/modes.js
@ -173,47 +173,13 @@ var toggleSingleImageMode = createCSSClassToggler(
|
|||||||
// XXX make this not conflict with marked-only-mode, better yet, make them
|
// XXX make this not conflict with marked-only-mode, better yet, make them
|
||||||
// one single mode...
|
// one single mode...
|
||||||
// XXX is this a mode???
|
// XXX is this a mode???
|
||||||
var toggleSingleRibbonMode = createCSSClassToggler(
|
var toggleSingleRibbonMode = makeCropModeToggler(
|
||||||
'.viewer',
|
'single-ribbon-mode',
|
||||||
'single-ribbon-mode cropped-mode',
|
function(){
|
||||||
function(action){
|
|
||||||
// prevent mixing marked-only and single-ribbon modes...
|
|
||||||
if(action == 'on'
|
|
||||||
&& $('.viewer').hasClass('cropped-mode')
|
|
||||||
&& toggleSingleRibbonMode('?') != 'on'){
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
function(action){
|
|
||||||
if(action == 'on'){
|
|
||||||
showStatusQ('Cropping current ribbon...')
|
|
||||||
cropDataTo(DATA.ribbons[getRibbonIndex()].slice())
|
cropDataTo(DATA.ribbons[getRibbonIndex()].slice())
|
||||||
} else {
|
|
||||||
showStatusQ('Uncropping to all data...')
|
|
||||||
showAllData()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
function uncropLastState(){
|
|
||||||
if(toggleSingleRibbonMode('?') == 'off'
|
|
||||||
&& toggleMarkedOnlyView('?') == 'off'){
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// exit cropped mode...
|
|
||||||
if(CROP_STACK.length == 1){
|
|
||||||
toggleSingleRibbonMode('off')
|
|
||||||
toggleMarkedOnlyView('off')
|
|
||||||
|
|
||||||
// ucrop one state...
|
|
||||||
} else {
|
|
||||||
showStatusQ('Uncropping...')
|
|
||||||
uncropData()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// TODO transitions...
|
// TODO transitions...
|
||||||
// TODO a real setup UI (instead of prompt)
|
// TODO a real setup UI (instead of prompt)
|
||||||
var toggleSlideShowMode = createCSSClassToggler(
|
var toggleSlideShowMode = createCSSClassToggler(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user