added .replaceGid(..) + some work on URL hash support...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2015-12-28 07:09:06 +03:00
parent f2d6d7a5a9
commit b41bbd9738
7 changed files with 128 additions and 2 deletions

View File

@ -464,6 +464,35 @@ var DataPrototype = {
return this return this
}, },
// Replace image gid...
//
// XXX should this work for ribbon gids???
replaceGid: function(from, to){
from = this.getImage(from)
var i = this.getImageOrder(from)
var t = this.getImage(to)
if(t != -1 && t != null){
return
}
// current...
if(from == this.current){
this.current = to
}
// order...
this.order[i] = to
// image lists...
this.eachImageList(function(list){
if(list[i] != null){
list[i] = to
}
})
return this
},
/*********************************************** Introspection ***/ /*********************************************** Introspection ***/

View File

@ -245,6 +245,21 @@ actions.Actions({
return res return res
}], }],
replaceGid: ['- System/Replace image gid',
function(from, to){
from = this.data.getImage(from)
// data...
var res = this.data.replaceGid(from, to)
if(res == null){
return
}
// images...
this.images && this.images.replaceGid(from, to)
}],
// basic navigation... // basic navigation...
// //

View File

@ -49,11 +49,15 @@ core.ImageGridFeatures.Feature('viewer-testing', [
'image-marks', 'image-marks',
'image-bookmarks', 'image-bookmarks',
// local storage...
// local storage + url...
'config-local-storage', 'config-local-storage',
// XXX make this browser-only...
'ui-url-hash',
'url-history-local-storage', 'url-history-local-storage',
'ui-single-image-view-local-storage', 'ui-single-image-view-local-storage',
'fs-loader', 'fs-loader',
'ui-fs-loader', 'ui-fs-loader',
'fs-url-history', 'fs-url-history',
@ -92,6 +96,7 @@ core.ImageGridFeatures.Feature('viewer-testing', [
//'auto-single-image', //'auto-single-image',
//'auto-ribbon', //'auto-ribbon',
// XXX not yet fully tested... // XXX not yet fully tested...
'system-journal', 'system-journal',
]) ])

View File

@ -289,6 +289,13 @@ actions.Actions({
}], }],
replaceGid: [
function(from, to){
return function(res){
res && this.ribbons.replaceGid(from, to)
}
}],
// This is called by .ribbons, the goal is to use it to hook into // This is called by .ribbons, the goal is to use it to hook into
// image updating from features and extensions... // image updating from features and extensions...
// //
@ -2802,6 +2809,45 @@ module.DirectControlGSAP = core.ImageGridFeatures.Feature({
//---------------------------------------------------------------------
// XXX make this browser specific...
// XXX BUG: loading of current gid from url for some reason is broken,
// race?...
var URLHash =
module.URLHash = core.ImageGridFeatures.Feature({
title: '',
doc: '',
tag: 'ui-url-hash',
depends: ['ui'],
handlers: [
['focusImage',
function(res, a){
console.log('focus:', a)
if(this.current && this.current != ''){
location.hash = this.current
}
}],
// XXX this does not work for some reason...
// ...likely because of the slow async load and sync set...
['start',
function(){
var h = location.hash
h = h.replace(/^#/, '')
// for some odd reason this does not work...
if(h != ''){
console.log('!!!!', h)
this.current = h
}
}],
],
})
//--------------------------------------------------------------------- //---------------------------------------------------------------------
// XXX console / log / status bar // XXX console / log / status bar

View File

@ -501,6 +501,19 @@ module.ImagesPrototype = {
return r == null ? n : parseInt(r[1]) return r == null ? n : parseInt(r[1])
}, },
// Replace image gid...
//
replaceGid: function(from, to){
var img = this[from]
// XXX is the test needed here???
if(img != null){
delete this[from]
this[to] = img
}
return this
},
// Gid sorters... // Gid sorters...
// XXX might be a good idea to add caching... // XXX might be a good idea to add caching...

View File

@ -87,6 +87,11 @@ var obj2transform = function(obj, filter){
// .translate3d(1,2,3) // .translate3d(1,2,3)
// -> [1, 2, 3] // -> [1, 2, 3]
// NOTE: both set data correctly... // NOTE: both set data correctly...
// XXX add argument in place operations...
// +=
// -=
// *=
// /=
// XXX move the grammar out of this... // XXX move the grammar out of this...
// XXX need: // XXX need:
// - a way to minimize this, i.e. get only full and minimal functions... // - a way to minimize this, i.e. get only full and minimal functions...
@ -116,7 +121,7 @@ var transformEditor = function(){
// methods... // methods...
// XXX generate this... // XXX generate this...
simplify: function(filter){ simplify: function(filter){
data = this.data var data = this.data
// scale... // scale...
if(data.scale if(data.scale
@ -375,6 +380,7 @@ var transformEditor = function(){
} }
// XXX get these from grammar... // XXX get these from grammar...
// The Grammar...
func('translate', ['px', 'px'], 0) func('translate', ['px', 'px'], 0)
func('translate3d', ['px', 'px', 'px'], 0) func('translate3d', ['px', 'px', 'px'], 0)
func('translateX', ['px'], 0) func('translateX', ['px'], 0)

View File

@ -1315,6 +1315,18 @@ var RibbonsPrototype = {
return img return img
}, },
// Replace image gid...
//
// XXX should this work for ribbon gids???
replaceGid: function(from, to){
var img = this.getImage(from)
img && img.length > 0
&& this.setElemGID(img, to)
return this
},
// Update image(s)... // Update image(s)...
// //
// Update current image: // Update current image: