mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
07f881e2b8
commit
1bb34d8d60
@ -99,7 +99,7 @@ actions.Actions({
|
||||
|
||||
// Base ribbon...
|
||||
get base(){
|
||||
return this.data == null ? null : this.data.base
|
||||
return this.data.base
|
||||
},
|
||||
set base(value){
|
||||
this.setBaseRibbon(value)
|
||||
@ -107,7 +107,7 @@ actions.Actions({
|
||||
|
||||
// Current image...
|
||||
get current(){
|
||||
return this.data == null ? null : this.data.current
|
||||
return this.data.current
|
||||
},
|
||||
set current(value){
|
||||
this.focusImage(value)
|
||||
@ -115,7 +115,7 @@ actions.Actions({
|
||||
|
||||
// Current ribbon...
|
||||
get currentRibbon(){
|
||||
return this.data == null ? null : this.data.getRibbon()
|
||||
return this.data.getRibbon()
|
||||
},
|
||||
set currentRibbon(value){
|
||||
this.focusRibbon(value)
|
||||
@ -275,8 +275,7 @@ actions.Actions({
|
||||
// basic navigation...
|
||||
//
|
||||
focusImage: ['- Navigate/Focus image',
|
||||
function(img, list){
|
||||
this.data.focusImage(img, list) }],
|
||||
function(img, list){ this.data.focusImage(img, list) }],
|
||||
// Focuses a ribbon by selecting an image in it...
|
||||
//
|
||||
// modes supported:
|
||||
@ -290,6 +289,10 @@ actions.Actions({
|
||||
focusRibbon: ['- Navigate/Focus Ribbon',
|
||||
function(target, mode){
|
||||
var data = this.data
|
||||
if(data == null){
|
||||
return
|
||||
}
|
||||
|
||||
var r = data.getRibbon(target)
|
||||
if(r == null){
|
||||
return
|
||||
@ -741,7 +744,7 @@ module.TagsActions = actions.Actions({
|
||||
function(source, mode){
|
||||
// can't do anything if either .data or .images are not
|
||||
// defined...
|
||||
if(this.data == null || this.images == null){
|
||||
if(this.images == null){
|
||||
return
|
||||
}
|
||||
|
||||
@ -838,6 +841,10 @@ module.CropActions = actions.Actions({
|
||||
//
|
||||
crop: ['- Crop/Crop image list',
|
||||
function(list, flatten){
|
||||
if(this.data.length == 0){
|
||||
return
|
||||
}
|
||||
|
||||
//list = list || this.data.order
|
||||
list = list || this.data.getImages()
|
||||
|
||||
@ -929,8 +936,11 @@ module.CropActions = actions.Actions({
|
||||
ribbon = ribbon || this.data.getRibbon()
|
||||
|
||||
var data = this.data
|
||||
var that = this
|
||||
if(data == null){
|
||||
return
|
||||
}
|
||||
|
||||
var that = this
|
||||
var i = data.ribbon_order.indexOf(ribbon)
|
||||
var ribbons = data.ribbon_order.slice(0, i)
|
||||
var images = ribbons
|
||||
|
||||
@ -18,6 +18,8 @@ var actions = require('lib/actions')
|
||||
var features = require('lib/features')
|
||||
var toggler = require('lib/toggler')
|
||||
|
||||
var data = require('imagegrid/data')
|
||||
|
||||
|
||||
|
||||
/*********************************************************************/
|
||||
@ -80,6 +82,10 @@ function(attr, states, a, b){
|
||||
//
|
||||
var ImageGridMetaActions =
|
||||
module.ImageGridMetaActions = {
|
||||
// XXX experimental...
|
||||
get data(){ return this.__data || data.Data() },
|
||||
set data(value){ this.__data = value },
|
||||
|
||||
// Test if the action is a Toggler...
|
||||
//
|
||||
isToggler: actions.doWithRootAction(function(action){
|
||||
|
||||
@ -20,9 +20,9 @@ var core = require('features/core')
|
||||
// helper...
|
||||
function didAdvance(indicator){
|
||||
return function(){
|
||||
var img = this.data.current
|
||||
var img = this.data ? this.data.current : null
|
||||
return function(){
|
||||
if(img == this.data.current){
|
||||
if(img == null || img == this.data.current){
|
||||
this.flashIndicator(indicator)
|
||||
}
|
||||
}
|
||||
|
||||
@ -429,6 +429,10 @@ module.ViewerActions = actions.Actions({
|
||||
var ribbons = this.ribbons
|
||||
var data = this.data
|
||||
|
||||
if(data == null){
|
||||
return
|
||||
}
|
||||
|
||||
// XXX handle raw dom elements...
|
||||
var gid = target instanceof jQuery
|
||||
? ribbons.getElemGID(target)
|
||||
@ -490,6 +494,10 @@ module.ViewerActions = actions.Actions({
|
||||
var ribbons = this.ribbons
|
||||
var data = this.data
|
||||
|
||||
if(data == null){
|
||||
return
|
||||
}
|
||||
|
||||
// XXX handle raw dom elements...
|
||||
var gid = target instanceof jQuery
|
||||
? ribbons.getElemGID(target)
|
||||
|
||||
@ -1568,6 +1568,9 @@ var DataPrototype = {
|
||||
// XXX needs better docs...
|
||||
shiftImage: function(from, target, mode, direction){
|
||||
from = from == null || from == 'current' ? this.current : from
|
||||
if(from == null){
|
||||
return
|
||||
}
|
||||
from = from.constructor !== Array ? [from] : from
|
||||
|
||||
var place
|
||||
@ -1613,7 +1616,8 @@ var DataPrototype = {
|
||||
// NOTE: if base ribbon is removed this will try and reset it to the
|
||||
// ribbon above or the top ribbon...
|
||||
shiftImageUp: function(gid){
|
||||
var g = gid.constructor === Array ? gid[0] : gid
|
||||
gid = gid || this.current
|
||||
var g = gid && gid.constructor === Array ? gid[0] : gid
|
||||
var r = this.getRibbonOrder(g)
|
||||
// check if we need to create a ribbon here...
|
||||
if(r == 0){
|
||||
@ -1621,6 +1625,9 @@ var DataPrototype = {
|
||||
this.newRibbon(g)
|
||||
}
|
||||
var res = this.shiftImage(gid, r-1, 'vertical')
|
||||
if(res == null){
|
||||
return
|
||||
}
|
||||
// clear empty ribbon...
|
||||
r = r == 0 ? 1 : r
|
||||
if(this.ribbons[this.ribbon_order[r]].len == 0){
|
||||
@ -1629,13 +1636,17 @@ var DataPrototype = {
|
||||
return res
|
||||
},
|
||||
shiftImageDown: function(gid){
|
||||
var g = gid.constructor === Array ? gid[0] : gid
|
||||
gid = gid || this.current
|
||||
var g = gid && gid.constructor === Array ? gid[0] : gid
|
||||
var r = this.getRibbonOrder(g)
|
||||
// check if we need to create a ribbon here...
|
||||
if(r == this.ribbon_order.length-1){
|
||||
this.newRibbon(g, 'below')
|
||||
}
|
||||
var res = this.shiftImage(gid, r+1, 'vertical')
|
||||
if(res == null){
|
||||
return
|
||||
}
|
||||
// clear empty ribbon...
|
||||
if(this.ribbons[this.ribbon_order[r]].len == 0){
|
||||
this.clear(this.ribbon_order[r])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user