mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
started reworking external editor UI...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
d78fac69a7
commit
14f62ace9a
@ -11,6 +11,8 @@ define(function(require){ var module = {}
|
||||
var actions = require('lib/actions')
|
||||
var core = require('features/core')
|
||||
|
||||
var widgets = require('features/ui-widgets')
|
||||
|
||||
// widgets...
|
||||
var browse = require('lib/widget/browse')
|
||||
var overlay = require('lib/widget/overlay')
|
||||
@ -44,6 +46,12 @@ var ExternalEditorActions = actions.Actions({
|
||||
// as argument unless it uses only '\' and not '/'
|
||||
['IrfanView|"C:/Program Files (x86)/IrfanView/i_view32.exe" "$PATH"'],
|
||||
],
|
||||
|
||||
'external-editor-targets': [
|
||||
'Original image',
|
||||
'Best preview',
|
||||
// XXX
|
||||
],
|
||||
},
|
||||
|
||||
// XXX this still needs image type and better support for OS paths
|
||||
@ -109,6 +117,106 @@ module.ExternalEditor = core.ImageGridFeatures.Feature({
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
var ExternalEditorUIActions = actions.Actions({
|
||||
// XXX get editor data...
|
||||
// XXX set editor data...
|
||||
// XXX revise editor format...
|
||||
// XXX empty title -- use app name without ext...
|
||||
externalEditorDialog: ['- Edit/',
|
||||
function(editor){
|
||||
var that = this
|
||||
|
||||
// XXX STUB: get the real editor...
|
||||
var editor = {
|
||||
// NOTE: empty means use app name...
|
||||
title: '',
|
||||
// NOTE: empty means system to select editor...
|
||||
path: '/',
|
||||
// NOTE: empty is the same as '$TARGET'...
|
||||
// XXX use $TARGET...
|
||||
arguments: '',
|
||||
target: 'Original image',
|
||||
}
|
||||
|
||||
var o = overlay.Overlay(this.ribbons.viewer,
|
||||
browse.makeLister(null, function(_, make){
|
||||
make(['Title: ', function(){ return editor.title || '' }])
|
||||
.on('open', function(){
|
||||
event.preventDefault()
|
||||
widgets.makeEditableItem(o.client,
|
||||
$(this).find('.text').last(),
|
||||
function(_, text){ editor.title = text }) })
|
||||
|
||||
make(['Path: ', function(){ return editor.path }], {
|
||||
buttons: [
|
||||
['browse', function(p){
|
||||
var e = this.filter('"'+p+'"', false)
|
||||
var path = e.find('.text').last().text()
|
||||
var txt = e.find('.text').first().text()
|
||||
|
||||
var b = overlay.Overlay(that.ribbons.viewer,
|
||||
browseWalk.makeWalk(null, path,
|
||||
// XXX
|
||||
'*+(exe|cmd|ps1|sh)',
|
||||
{})
|
||||
// path selected...
|
||||
.open(function(evt, path){
|
||||
editor.path = path
|
||||
|
||||
b.close()
|
||||
|
||||
o.client.update()
|
||||
.then(function(){ o.client.select(txt+path) })
|
||||
}))
|
||||
.close(function(){
|
||||
// XXX
|
||||
that.getOverlay().focus()
|
||||
})
|
||||
}]
|
||||
]
|
||||
})
|
||||
.on('open', function(){
|
||||
event.preventDefault()
|
||||
widgets.makeEditableItem(o.client,
|
||||
$(this).find('.text').last(),
|
||||
function(_, text){ editor.path = text }) })
|
||||
|
||||
make(['Arguments: ', function(){ return editor.arguments || '' }])
|
||||
.on('open', function(){
|
||||
event.preventDefault()
|
||||
widgets.makeEditableItem(o.client,
|
||||
$(this).find('.text').last(),
|
||||
function(_, text){ editor.arguments = text }) })
|
||||
|
||||
make(['Target: ', function(){ return editor.target || 'Original image' }])
|
||||
.on('open',
|
||||
widgets.makeNestedConfigListEditor(that, o,
|
||||
'external-editor-targets',
|
||||
function(val){
|
||||
if(val == null){
|
||||
return editor.target
|
||||
} else {
|
||||
editor.target = val
|
||||
}
|
||||
},
|
||||
{
|
||||
new_button: false,
|
||||
itemButtons: [],
|
||||
}))
|
||||
|
||||
make(['Save'])
|
||||
.on('open', function(){
|
||||
// XXX save stuff...
|
||||
// XXX
|
||||
|
||||
o.close()
|
||||
})
|
||||
}))
|
||||
|
||||
o.client.dom.addClass('metadata-view tail-action')
|
||||
|
||||
return o
|
||||
}],
|
||||
// XXX use .externalEditorDialog(..)
|
||||
listExtenalEditors: ['Edit/List external editors',
|
||||
function(){
|
||||
var that = this
|
||||
|
||||
@ -860,7 +860,7 @@ var FileSystemWriterActions = actions.Actions({
|
||||
// XXX copy img.path -- the main image, especially when no previews present....
|
||||
// XXX
|
||||
|
||||
Object.keys(previews).forEach(function(res){
|
||||
previews && Object.keys(previews).forEach(function(res){
|
||||
var preview_path = decodeURI(previews[res])
|
||||
|
||||
var from = (img_base || base_dir) +'/'+ preview_path
|
||||
|
||||
@ -507,6 +507,8 @@ module.MetadataUI = core.ImageGridFeatures.Feature({
|
||||
|
||||
|
||||
|
||||
// Load etdata on demand...
|
||||
//
|
||||
var MetadataFSUI =
|
||||
module.MetadataFSUI = core.ImageGridFeatures.Feature({
|
||||
title: '',
|
||||
|
||||
@ -31,6 +31,27 @@ var browseWalk = require('lib/widget/browse-walk')
|
||||
|
||||
/*********************************************************************/
|
||||
|
||||
// XXX make the selector more accurate...
|
||||
// ...at this point this will select the first elem with text which
|
||||
// can be a different elem...
|
||||
var makeEditableItem =
|
||||
module.makeEditableItem =
|
||||
function(list, elem, callback, options){
|
||||
return elem
|
||||
.makeEditable({
|
||||
clear_on_edit: false,
|
||||
})
|
||||
.on('edit-done', callback || function(){})
|
||||
.on('edit-aborted edit-done', function(_, text){
|
||||
list.update()
|
||||
// XXX make the selector more accurate...
|
||||
// ...at this point this will select the first elem
|
||||
// with text which can be a different elem...
|
||||
.then(function(){ list.select(text) })
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Options format:
|
||||
// {
|
||||
@ -224,7 +245,11 @@ function(actions, parent, list_key, value_key, options){
|
||||
// NOTE: this is called when adding a new value and
|
||||
// list maximum length is reached...
|
||||
callback: function(value){
|
||||
actions.config[value_key] = value
|
||||
if(typeof(value_key) == typeof(function(){})){
|
||||
value_key(value)
|
||||
} else {
|
||||
actions.config[value_key] = value
|
||||
}
|
||||
|
||||
o.close()
|
||||
},
|
||||
@ -244,7 +269,12 @@ function(actions, parent, list_key, value_key, options){
|
||||
parent.focus()
|
||||
})
|
||||
|
||||
o.client.select(actions.config[value_key])
|
||||
if(typeof(value_key) == typeof(function(){})){
|
||||
o.client.select(value_key())
|
||||
|
||||
} else {
|
||||
o.client.select(actions.config[value_key])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user