mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-11-01 11:50:07 +00:00
added button widget to formDialog and some refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
ed2ccef269
commit
77e5945a31
@ -97,6 +97,7 @@ zip: $(APP_ZIP)
|
||||
|
||||
node-deps:
|
||||
npm install fs.extra
|
||||
npm install exif
|
||||
|
||||
dev: $(CSS_FILES)
|
||||
unzip -uj $(wildcard targets/node-webkit/node-webkit-*-win-ia32.zip) -d .
|
||||
|
||||
@ -28,6 +28,8 @@ if(window.CEF_dumpJSON != null){
|
||||
var fs = require('fs')
|
||||
var fse = require('fs.extra')
|
||||
var proc = require('child_process')
|
||||
var crypto = require('crypto')
|
||||
//var exif = require('exif2')
|
||||
var gui = require('nw.gui')
|
||||
|
||||
var fp = /file:\/\/\//
|
||||
@ -282,6 +284,32 @@ if(window.CEF_dumpJSON != null){
|
||||
return _PREVIW_CREATE_QUEUE
|
||||
}
|
||||
|
||||
// XXX should this be sync???
|
||||
// XXX we are cheating here right now...
|
||||
/*
|
||||
window.makeImageGID = function(path, make_text_gid){
|
||||
|
||||
// XXX get exif...
|
||||
|
||||
var artist =
|
||||
// format: "20130102-122315"
|
||||
var date =
|
||||
var name = path.split(/[\\\/]/).pop()
|
||||
|
||||
var text_gid = artist +'-'+ date +'-'+ name
|
||||
|
||||
if(make_text_gid){
|
||||
return text_gid
|
||||
}
|
||||
|
||||
var h = crypto.createHash('sha1')
|
||||
h.update(text_gid)
|
||||
var hex_gid = h.digest('hex')
|
||||
|
||||
return hex_gid
|
||||
}
|
||||
*/
|
||||
|
||||
// UI-specific...
|
||||
window.toggleFullscreenMode = createCSSClassToggler(
|
||||
document.body,
|
||||
|
||||
@ -616,10 +616,12 @@ Date.prototype.toShortDate = function(){
|
||||
H = H < 10 ? '0'+H : H
|
||||
var m = this.getMinutes()
|
||||
m = m < 10 ? '0'+m : m
|
||||
var s = this.getSeconds()
|
||||
s = s < 10 ? '0'+s : s
|
||||
|
||||
return ''+y+'-'+M+'-'+D+' '+H+':'+m
|
||||
return ''+y+'-'+M+'-'+D+' '+H+':'+m+':'+s
|
||||
}
|
||||
Date.prototype.getTimeStamp = function(){
|
||||
Date.prototype.getTimeStamp = function(no_seconds){
|
||||
var y = this.getFullYear()
|
||||
var M = this.getMonth()+1
|
||||
M = M < 10 ? '0'+M : M
|
||||
@ -629,8 +631,10 @@ Date.prototype.getTimeStamp = function(){
|
||||
H = H < 10 ? '0'+H : H
|
||||
var m = this.getMinutes()
|
||||
m = m < 10 ? '0'+m : m
|
||||
var s = this.getSeconds()
|
||||
s = s < 10 ? '0'+s : s
|
||||
|
||||
return ''+y+M+D+H+m
|
||||
return ''+y+M+D+H+m+s
|
||||
}
|
||||
Date.prototype.setTimeStamp = function(ts){
|
||||
this.setFullYear(ts.slice(0, 4))
|
||||
@ -638,6 +642,7 @@ Date.prototype.setTimeStamp = function(ts){
|
||||
this.setDate(ts.slice(6, 8))
|
||||
this.setHours(ts.slice(8, 10))
|
||||
this.setMinutes(ts.slice(10, 12))
|
||||
this.setSeconds(ts.slice(12, 14))
|
||||
return this
|
||||
}
|
||||
Date.timeStamp = function(){
|
||||
|
||||
49
ui/ui.js
49
ui/ui.js
@ -379,6 +379,8 @@ function hideOverlay(root){
|
||||
|
||||
|
||||
var FIELD_TYPES = {
|
||||
// format:
|
||||
// string
|
||||
text: {
|
||||
type: 'text',
|
||||
text: null,
|
||||
@ -397,6 +399,9 @@ var FIELD_TYPES = {
|
||||
return $(field).find('.value').attr('value')
|
||||
},
|
||||
},
|
||||
|
||||
// format:
|
||||
// true | false
|
||||
bool: {
|
||||
type: 'bool',
|
||||
text: null,
|
||||
@ -421,6 +426,8 @@ var FIELD_TYPES = {
|
||||
},
|
||||
|
||||
// NOTE: this will not work without node-webkit...
|
||||
// format:
|
||||
// { dir: <default-path> }
|
||||
dir: {
|
||||
type: 'dir',
|
||||
text: null,
|
||||
@ -429,7 +436,6 @@ var FIELD_TYPES = {
|
||||
'<span class="text"></span>'+
|
||||
'<input type="file" class="value" nwdirectory />'+
|
||||
'</div>',
|
||||
// format: {dir: <default-path>}
|
||||
test: function(val){
|
||||
return typeof(val) == typeof({}) && 'dir' in val
|
||||
},
|
||||
@ -444,7 +450,10 @@ var FIELD_TYPES = {
|
||||
return f[0].path
|
||||
},
|
||||
},
|
||||
|
||||
// NOTE: this will not work without node-webkit...
|
||||
// format:
|
||||
// { dir: <default-path> }
|
||||
ndir: {
|
||||
type: 'ndir',
|
||||
text: null,
|
||||
@ -454,7 +463,6 @@ var FIELD_TYPES = {
|
||||
'<input type="text" class="path"/>'+
|
||||
'<button class="browse">Browse</button>'+
|
||||
'</div>',
|
||||
// format: {dir: <default-path>}
|
||||
test: function(val){
|
||||
return typeof(val) == typeof({}) && 'ndir' in val
|
||||
},
|
||||
@ -491,6 +499,8 @@ var FIELD_TYPES = {
|
||||
},
|
||||
},
|
||||
|
||||
// format:
|
||||
// ['a', 'b', 'c', ...]
|
||||
choice: {
|
||||
type: 'choice',
|
||||
text: null,
|
||||
@ -502,7 +512,6 @@ var FIELD_TYPES = {
|
||||
'<span class="item-text"></span>'+
|
||||
'</label></div>'+
|
||||
'</div>',
|
||||
// format: ['a', 'b', 'c', ...]
|
||||
test: function(val){
|
||||
return typeof(val) == typeof([]) && val.constructor.name == 'Array'
|
||||
},
|
||||
@ -528,6 +537,40 @@ var FIELD_TYPES = {
|
||||
return $(field).find('.value:checked').val()
|
||||
},
|
||||
},
|
||||
|
||||
// NOTE: a button can have state...
|
||||
// format:
|
||||
// {
|
||||
// // click event handler...
|
||||
// button: <function>,
|
||||
// // optional, button text (default 'OK')...
|
||||
// text: <button-label>,
|
||||
// // optional, initial state setup...
|
||||
// default: <function>,
|
||||
// }
|
||||
button: {
|
||||
type: 'button',
|
||||
text: null,
|
||||
default: false,
|
||||
html: '<div class="field button">'+
|
||||
'<span class="text"></span>'+
|
||||
'<button class="button"></button>'+
|
||||
'</div>',
|
||||
test: function(val){
|
||||
return 'button' in val
|
||||
},
|
||||
set: function(field, value){
|
||||
var btn = $(field).find('button')
|
||||
.click(value.button)
|
||||
.html(value.text == null ? 'OK' : value.text)
|
||||
if('default' in value){
|
||||
value.default(btn)
|
||||
}
|
||||
},
|
||||
get: function(field){
|
||||
return $(field).attr('state')
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// Show a complex form dialog
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user