diff --git a/ui (gen4)/data.js b/ui (gen4)/data.js index 7a76dd73..fce5d74a 100755 --- a/ui (gen4)/data.js +++ b/ui (gen4)/data.js @@ -9,6 +9,8 @@ define(function(require){ var module = {} console.log('>>> data') +module.DATA_VERSION = '3.0' + /*********************************************************************/ // @@ -1396,27 +1398,6 @@ module.DataPrototype = { /****************************************** JSON serialization ***/ - // Convert gen3 data to gen4 json... - convertDataGen3: function(data){ - data = data.version == null ? convertDataGen1(data) : data - var that = this - var res = {} - res.version = '3.0' - res.current = data.current - res.order = data.order.slice() - res.ribbon_order = [] - res.ribbons = {} - // generate gids... - data.ribbons.forEach(function(e){ - var gid = that.newGid('R') - res.ribbon_order.push(gid) - res.ribbons[gid] = e.slice() - }) - // we set the base to the first ribbon... - res.base = res.ribbon_order[0] - return res - }, - // Load data from JSON... // // NOTE: this loads in-place, use .fromJSON(..) to create new data... @@ -1424,7 +1405,7 @@ module.DataPrototype = { if(typeof(data) == typeof('str')){ data = JSON.parse(data) } - data = data.version < '3.0' ? this.convertDataGen3(data) : data + data = formats.updateData(data) this.base = data.base this.current = data.current this.order = data.order.slice() @@ -1443,7 +1424,7 @@ module.DataPrototype = { // the result... dumpJSON: function(mode){ var res = { - varsion: '3.0', + varsion: module.DATA_VERSION, base: this.base, current: this.current, order: this.order.slice(), diff --git a/ui (gen4)/formats.js b/ui (gen4)/formats.js new file mode 100755 index 00000000..a3972b8e --- /dev/null +++ b/ui (gen4)/formats.js @@ -0,0 +1,129 @@ +/********************************************************************** +* +* +* +**********************************************************************/ + +define(function(require){ var module = {} +console.log('>>> formats') + + +module.VERSIONS = [] + + + +/*********************************************************************/ + + +// Convert legacy Gen1 data format to Gen3 format version 2.0+ +// +// XXX external deps: +// imageDateCmp +//module.convertDataGen1 = +module.VERSIONS['2.0'] = +function(data, cmp){ + var res = { + data: { + version: '2.0', + current: null, + ribbons: [], + order: [], + }, + images: {} + } + cmp = cmp == null ? + function(a, b){ + return imageDateCmp(a, b, null, res.images) + } + : cmp + var ribbons = res.data.ribbons + var order = res.data.order + var images = res.images + + // position... + res.data.current = data.position + + // ribbons and images... + $.each(data.ribbons, function(i, input_images){ + var ribbon = [] + ribbons.push(ribbon) + for(var id in input_images){ + var image = input_images[id] + ribbon.push(id) + order.push(id) + images[id] = image + } + ribbon.sort(cmp) + }) + + order.sort(cmp) + + // XXX STUB + res.data.current = order[0] + + return res +} + + +// Convert gen3 data to gen4 v3.0+... +// +// NOTE: this will just convert the JSON format and will not construct +// the Data object... +// NOTE: this uses require('data').Data().newGid(..) for ribbon gid +// generation... +//module.convertDataGen3 = +module.VERSIONS['3.0'] = +function(data){ + data = data.version == null ? module.VERSIONS['2.0'](data) : data + + // XXX is this the right way to go??? + var that = require('data').Data() + + var res = {} + res.version = '3.0' + res.current = data.current + res.order = data.order.slice() + res.ribbon_order = [] + res.ribbons = {} + // generate gids... + data.ribbons.forEach(function(e){ + var gid = that.newGid('R') + res.ribbon_order.push(gid) + res.ribbons[gid] = e.slice() + }) + // we set the base to the first ribbon... + res.base = res.ribbon_order[0] + return res +} + + +// Get latest updater version... +// +module.getLatestUpdaterVersion = function(){ + return Object.keys(module.VERSIONS).sort().pop() +} + + + +/*********************************************************************/ + +// Update data (JSON) to latest version... +// +// This is the main entry point in this module. +// +// Takes any compatable JSON data version and converts it to the latest +// format. +// NOTE: if data is already in the latest format this will return it +// as-is. +module.updateData = function(data){ + var v = module.getLatestUpdaterVersion() + return data.version < v + ? module.VERSIONS[v](data) + : data +} + + + +/********************************************************************** +* vim:set ts=4 sw=4 : */ +return module }) diff --git a/ui (gen4)/image.js b/ui (gen4)/image.js index c0aaa278..01c002fb 100755 --- a/ui (gen4)/image.js +++ b/ui (gen4)/image.js @@ -4,6 +4,13 @@ * **********************************************************************/ +define(function(require){ var module = {} +console.log('>>> image') + + + +/*********************************************************************/ + // A stub image, also here for documentation... var STUB_IMAGE_DATA = { // Entity GID... @@ -108,6 +115,8 @@ var IMAGE_UPDATERS = [] // Run all the image update functions registered in IMAGE_UPDATERS, on // an image... // +var updateImageIndicators = +module.updateImageIndicators = function updateImageIndicators(gid, image){ gid = gid == null ? getImageGID() : gid image = image == null ? getImage() : $(image) @@ -121,6 +130,8 @@ function updateImageIndicators(gid, image){ // helper... +var _loadImagePreviewURL = +module._loadImagePreviewURL = function _loadImagePreviewURL(image, url){ // pre-cache and load image... // NOTE: this will make images load without a blackout... @@ -140,6 +151,8 @@ function _loadImagePreviewURL(image, url){ // NOTE: care must be taken to reset ALL attributes an image can have, // a common bug if this is not done correctly, is that some settings // may leak to newly loaded images... +var updateImage = +module.updateImage = function updateImage(image, gid, size, sync){ image = image == null ? getImage() : $(image) sync = sync == null ? CONFIG.load_img_sync : sync @@ -237,6 +250,8 @@ function updateImage(image, gid, size, sync){ // distance from current image, loading the closest images first... // // If CONFIG.update_sync is set, this will run asynchronously. +var updateImages = +module.updateImages = function updateImages(list, size, cmp){ var deferred = $.Deferred() @@ -289,6 +304,8 @@ function updateImages(list, size, cmp){ // // NOTE: this is not needed for square image blocks. // NOTE: if an image block is square, this will remove the margins. +var correctImageProportionsForRotation = +module.correctImageProportionsForRotation = function correctImageProportionsForRotation(images, container){ container = container == null ? $('.viewer') : container @@ -347,3 +364,4 @@ function correctImageProportionsForRotation(images, container){ /********************************************************************** * vim:set ts=4 sw=4 : */ +return module }) diff --git a/ui (gen4)/images.js b/ui (gen4)/images.js index 41720809..b74c62b3 100755 --- a/ui (gen4)/images.js +++ b/ui (gen4)/images.js @@ -4,9 +4,13 @@ * **********************************************************************/ +define(function(require){ var module = {} +console.log('>>> images') + //var DEBUG = DEBUG != null ? DEBUG : true + /*********************************************************************/ @@ -14,3 +18,4 @@ /********************************************************************** * vim:set ts=4 sw=4 : */ +return module }) diff --git a/ui (gen4)/loader.js b/ui (gen4)/loader.js index 41720809..9a41fc39 100755 --- a/ui (gen4)/loader.js +++ b/ui (gen4)/loader.js @@ -4,13 +4,35 @@ * **********************************************************************/ -//var DEBUG = DEBUG != null ? DEBUG : true +define(function(require){ var module = {} +console.log('>>> loader') + +var data = require('data') + /*********************************************************************/ +module.loadData = function(target, callback){ + // Data... + if(target instanceof data.Data){ + callback(target) + + // Object... + } else if(typeof(target) == typeof({})){ + callback(data.Data(target)) + + // String... + } else if(typeof(target) == typeof('str')){ + // url... + if(/^(http:|file:|app:|embed:)/.test(target)){ + } + } +} + /********************************************************************** * vim:set ts=4 sw=4 : */ +return module }) diff --git a/ui (gen4)/ribbons.js b/ui (gen4)/ribbons.js index 59373e49..c08a9d91 100755 --- a/ui (gen4)/ribbons.js +++ b/ui (gen4)/ribbons.js @@ -10,6 +10,9 @@ console.log('>>> ribbons') //var DEBUG = DEBUG != null ? DEBUG : true +var data = require('data') +var image = require('image') + /*********************************************************************/ @@ -57,15 +60,21 @@ module.RibbonsClassPrototype = { .append($('