mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
added loadURLs action + some tweaks and fixes...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
aab609e66b
commit
38ea605f00
@ -96,18 +96,32 @@ module.DATA_VERSION = '3.0'
|
|||||||
//
|
//
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
|
// decide to use a hashing function...
|
||||||
|
if(typeof(sha1) != 'undefined'){
|
||||||
|
var hash = sha1.hash.bind(sha1)
|
||||||
|
} else {
|
||||||
|
var hash = function(g){ return g }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*********************************************************************/
|
||||||
|
|
||||||
// Data class methods and API...
|
// Data class methods and API...
|
||||||
//
|
//
|
||||||
var DataClassPrototype =
|
var DataClassPrototype =
|
||||||
module.DataClassPrototype = {
|
module.DataClassPrototype = {
|
||||||
// NOTE: we consider the input list sorted...
|
// NOTE: we consider the input list sorted...
|
||||||
fromList: function(list){
|
fromArray: function(list){
|
||||||
var res = new Data()
|
var res = new Data()
|
||||||
// XXX make a real ribbon gid...
|
// XXX make a real ribbon gid...
|
||||||
var gid = res.newGid()
|
var gid = res.newGid()
|
||||||
res.order = list
|
res.order = list
|
||||||
res.ribbon_order.push(gid)
|
res.ribbon_order.push(gid)
|
||||||
res.ribbons[gid] = list.slice()
|
res.ribbons[gid] = list.slice()
|
||||||
|
|
||||||
|
res.focusImage(list[0])
|
||||||
|
res.setBase(gid)
|
||||||
|
|
||||||
return res
|
return res
|
||||||
},
|
},
|
||||||
// XXX is this the right way to construct data???
|
// XXX is this the right way to construct data???
|
||||||
@ -251,12 +265,6 @@ module.DataPrototype = {
|
|||||||
if(typeof(process) != 'undefined'){
|
if(typeof(process) != 'undefined'){
|
||||||
p += process.pid + '-'
|
p += process.pid + '-'
|
||||||
}
|
}
|
||||||
// decide to use a hashing function...
|
|
||||||
if(typeof(sha1) != 'undefined'){
|
|
||||||
var hash = sha1.hash.bind(sha1)
|
|
||||||
} else {
|
|
||||||
var hash = function(g){ return g }
|
|
||||||
}
|
|
||||||
|
|
||||||
// return string as-is...
|
// return string as-is...
|
||||||
if(nohash){
|
if(nohash){
|
||||||
|
|||||||
@ -4,27 +4,29 @@
|
|||||||
*
|
*
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
|
var glob = require('glob')
|
||||||
|
var path = require('path')
|
||||||
|
|
||||||
|
|
||||||
define(function(require){ var module = {}
|
define(function(require){ var module = {}
|
||||||
console.log('>>> file')
|
console.log('>>> file')
|
||||||
|
|
||||||
//var DEBUG = DEBUG != null ? DEBUG : true
|
//var DEBUG = DEBUG != null ? DEBUG : true
|
||||||
|
|
||||||
|
var tasks = require('lib/tasks')
|
||||||
/*********************************************************************/
|
|
||||||
|
|
||||||
function listDir(path){
|
|
||||||
}
|
|
||||||
|
|
||||||
function openFile(path){
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadJSONFile(path){
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
|
var INDEX_DIR = '.ImageGrid'
|
||||||
|
|
||||||
|
|
||||||
|
/*********************************************************************/
|
||||||
|
|
||||||
|
function listIndexes(base){
|
||||||
|
return glob(base +'/**/'+ INDEX_DIR)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
|
|||||||
@ -9,6 +9,17 @@ console.log('>>> images')
|
|||||||
|
|
||||||
//var DEBUG = DEBUG != null ? DEBUG : true
|
//var DEBUG = DEBUG != null ? DEBUG : true
|
||||||
|
|
||||||
|
var sha1 = require('./ext-lib/sha1')
|
||||||
|
|
||||||
|
|
||||||
|
/*********************************************************************/
|
||||||
|
|
||||||
|
// decide to use a hashing function...
|
||||||
|
if(typeof(sha1) != 'undefined'){
|
||||||
|
var hash = sha1.hash.bind(sha1)
|
||||||
|
} else {
|
||||||
|
var hash = function(g){ return g }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
@ -224,6 +235,20 @@ module.makeImageSeqOrNameCmp = function(data, get, seq){
|
|||||||
|
|
||||||
var ImagesClassPrototype =
|
var ImagesClassPrototype =
|
||||||
module.ImagesClassPrototype = {
|
module.ImagesClassPrototype = {
|
||||||
|
fromArray: function(data){
|
||||||
|
var images = new this()
|
||||||
|
// XXX stub...
|
||||||
|
var i = 0
|
||||||
|
data.forEach(function(path){
|
||||||
|
var gid = hash('I'+i)
|
||||||
|
images[gid] = {
|
||||||
|
id: gid,
|
||||||
|
path: path,
|
||||||
|
}
|
||||||
|
i += 1
|
||||||
|
})
|
||||||
|
return images
|
||||||
|
},
|
||||||
fromJSON: function(data){
|
fromJSON: function(data){
|
||||||
return new this().loadJSON(data)
|
return new this().loadJSON(data)
|
||||||
},
|
},
|
||||||
@ -324,6 +349,7 @@ module.ImagesPrototype = {
|
|||||||
var url = img_data.path
|
var url = img_data.path
|
||||||
var preview_size = 'Original'
|
var preview_size = 'Original'
|
||||||
var p = Infinity
|
var p = Infinity
|
||||||
|
var previews = img_data.preview || {}
|
||||||
|
|
||||||
for(var k in img_data.preview){
|
for(var k in img_data.preview){
|
||||||
s = parseInt(k)
|
s = parseInt(k)
|
||||||
|
|||||||
@ -20,7 +20,7 @@ var browser = require('browser')
|
|||||||
//var data = require('data')
|
//var data = require('data')
|
||||||
|
|
||||||
window.toggleFullscreenMode =
|
window.toggleFullscreenMode =
|
||||||
module.toggleFullscreenMode = makeCSSClassToggler(
|
module.toggleFullscreenMode = CSSClassToggler(
|
||||||
document.body,
|
document.body,
|
||||||
'.full-screen-mode',
|
'.full-screen-mode',
|
||||||
function(action){
|
function(action){
|
||||||
|
|||||||
@ -1,26 +1,23 @@
|
|||||||
{
|
{
|
||||||
"name": "ImageGrid.Viewer",
|
"name": "ImageGrid.Viewer",
|
||||||
"main": "index.html",
|
"main": "index.html",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
|
"window": {
|
||||||
"window": {
|
"title": "ImageGrid.Viewer",
|
||||||
"title": "ImageGrid.Viewer",
|
"position": "center",
|
||||||
"position": "center",
|
"width": 900,
|
||||||
"width": 900,
|
"height": 700,
|
||||||
"height": 700,
|
"min_width": 400,
|
||||||
"min_width": 400,
|
"min_height": 400,
|
||||||
"min_height": 400,
|
"frame": false,
|
||||||
"frame": false,
|
"toolbar": false
|
||||||
"toolbar": false
|
},
|
||||||
},
|
"webkit": {
|
||||||
|
"page-cache": true
|
||||||
"webkit": {
|
},
|
||||||
"page-cache": true
|
"dependencies": {
|
||||||
},
|
"fs.extra": "*",
|
||||||
|
"glob": "^4.0.6",
|
||||||
"dependencies": {
|
"requirejs": "*"
|
||||||
"requirejs": "*",
|
}
|
||||||
"fs.extra": "*"
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@ -197,8 +197,8 @@ actions.Actions({
|
|||||||
//
|
//
|
||||||
load: [
|
load: [
|
||||||
function(d){
|
function(d){
|
||||||
this.data = data.Data(d.data)
|
|
||||||
this.images = images.Images(d.images)
|
this.images = images.Images(d.images)
|
||||||
|
this.data = data.Data(d.data)
|
||||||
}],
|
}],
|
||||||
clear: [
|
clear: [
|
||||||
function(){
|
function(){
|
||||||
@ -206,6 +206,13 @@ actions.Actions({
|
|||||||
delete this.Images
|
delete this.Images
|
||||||
}],
|
}],
|
||||||
|
|
||||||
|
// XXX should this be here???
|
||||||
|
loadURLs: ['Load a URL list',
|
||||||
|
function(lst){
|
||||||
|
this.images = images.Images.fromArray(lst)
|
||||||
|
this.data = data.Data.fromArray(Object.keys(this.images))
|
||||||
|
}],
|
||||||
|
|
||||||
|
|
||||||
// basic navigation...
|
// basic navigation...
|
||||||
//
|
//
|
||||||
@ -523,21 +530,16 @@ actions.Actions(Client, {
|
|||||||
|
|
||||||
load: [
|
load: [
|
||||||
function(data){
|
function(data){
|
||||||
// recycle the viewer if one is not given specifically...
|
|
||||||
var viewer = data.viewer
|
|
||||||
viewer = viewer == null && this.ribbons != null
|
|
||||||
? this.ribbons.viewer
|
|
||||||
: viewer
|
|
||||||
// XXX do we need to recycle the images???
|
|
||||||
|
|
||||||
// XXX is keeping ribbons here correct???
|
|
||||||
if(this.ribbons == null){
|
|
||||||
this.ribbons = ribbons.Ribbons(viewer, data.images)
|
|
||||||
}
|
|
||||||
|
|
||||||
return function(){
|
return function(){
|
||||||
// XXX do a partial load...
|
// recycle the viewer if one is not given specifically...
|
||||||
// XXX
|
var viewer = data.viewer
|
||||||
|
viewer = viewer == null && this.ribbons != null
|
||||||
|
? this.ribbons.viewer
|
||||||
|
: viewer
|
||||||
|
|
||||||
|
if(this.ribbons == null){
|
||||||
|
this.ribbons = ribbons.Ribbons(viewer, data.images)
|
||||||
|
}
|
||||||
|
|
||||||
this.reload()
|
this.reload()
|
||||||
}
|
}
|
||||||
@ -567,12 +569,28 @@ actions.Actions(Client, {
|
|||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
clear: [
|
clear: [
|
||||||
// XXX do we need to delete the ribbons???
|
function(){ this.ribbons.clear() }],
|
||||||
|
|
||||||
|
loadURLs: [
|
||||||
function(){
|
function(){
|
||||||
this.ribbons.clear()
|
return function(){
|
||||||
delete this.ribbons
|
// recycle the viewer if one is not given specifically...
|
||||||
|
var viewer = this.ribbons != null
|
||||||
|
? this.ribbons.viewer
|
||||||
|
: viewer
|
||||||
|
|
||||||
|
if(this.ribbons == null){
|
||||||
|
this.ribbons = ribbons.Ribbons(viewer, data.images)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
this.ribbons.clear()
|
||||||
|
}
|
||||||
|
|
||||||
|
this.reload()
|
||||||
|
}
|
||||||
}],
|
}],
|
||||||
|
|
||||||
|
|
||||||
// XXX move this to a viewer window action set
|
// XXX move this to a viewer window action set
|
||||||
close: ['Cloase viewer',
|
close: ['Cloase viewer',
|
||||||
function(){
|
function(){
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user