mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-11-02 20:30:09 +00:00
some refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
d708c45e30
commit
d721d1c14e
@ -115,7 +115,7 @@ module.IMAGE_UPDATERS = []
|
|||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
// XXX is this the right place for this???
|
// XXX use Ribbon.getElemGID(..) in place of this...
|
||||||
var getImageGID =
|
var getImageGID =
|
||||||
module.getImageGID =
|
module.getImageGID =
|
||||||
function(img){
|
function(img){
|
||||||
@ -126,6 +126,7 @@ function(img){
|
|||||||
// XXX getVisibleImageSize(...)
|
// XXX getVisibleImageSize(...)
|
||||||
// XXX getBestPreview(...)
|
// XXX getBestPreview(...)
|
||||||
// XXX setImageFlipState(...)
|
// XXX setImageFlipState(...)
|
||||||
|
// XXX makeGIDDistanceCmp(...)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -53,6 +53,10 @@ var image = require('image')
|
|||||||
|
|
||||||
var RibbonsClassPrototype =
|
var RibbonsClassPrototype =
|
||||||
module.RibbonsClassPrototype = {
|
module.RibbonsClassPrototype = {
|
||||||
|
getElemGID: function(elem){
|
||||||
|
return JSON.parse('"' + elem.attr('gid') + '"')
|
||||||
|
},
|
||||||
|
|
||||||
// NOTE: these will return unattached objects...
|
// NOTE: these will return unattached objects...
|
||||||
createViewer: function(){
|
createViewer: function(){
|
||||||
return $('<div>')
|
return $('<div>')
|
||||||
@ -94,10 +98,10 @@ module.RibbonsPrototype = {
|
|||||||
createRibbon: RibbonsClassPrototype.createRibbon,
|
createRibbon: RibbonsClassPrototype.createRibbon,
|
||||||
createImage: RibbonsClassPrototype.createImage,
|
createImage: RibbonsClassPrototype.createImage,
|
||||||
|
|
||||||
getElemGID: function(elem){
|
// Generic getters...
|
||||||
return JSON.parse('"' + elem.attr('gid') + '"')
|
getElemGID: RibbonsClassPrototype.getElemGID,
|
||||||
},
|
|
||||||
|
|
||||||
|
// Contextual getters...
|
||||||
// NOTE: these accept gids or jQuery objects...
|
// NOTE: these accept gids or jQuery objects...
|
||||||
getRibbon: function(target){
|
getRibbon: function(target){
|
||||||
if(target == null) {
|
if(target == null) {
|
||||||
@ -121,10 +125,6 @@ module.RibbonsPrototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
// NOTE: to remove a ribbon or an image just use .getRibbon(..).remove()
|
|
||||||
// and .getImage(...).remove() respectivly.
|
|
||||||
|
|
||||||
|
|
||||||
// Place a ribbon...
|
// Place a ribbon...
|
||||||
//
|
//
|
||||||
// position can be:
|
// position can be:
|
||||||
@ -286,6 +286,26 @@ module.RibbonsPrototype = {
|
|||||||
})
|
})
|
||||||
return this
|
return this
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
// Clear elements...
|
||||||
|
//
|
||||||
|
// Clear all elements:
|
||||||
|
// .clear()
|
||||||
|
// .clear('*')
|
||||||
|
// -> Ribbons
|
||||||
|
//
|
||||||
|
// Clear an image or a ribbon by gid:
|
||||||
|
// .clear(gid)
|
||||||
|
// -> Ribbons
|
||||||
|
//
|
||||||
|
// Clear a set of elements:
|
||||||
|
// .clear([gid, ...])
|
||||||
|
// -> Ribbons
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// NOTE: another way to remove a ribbon or an image just to use
|
||||||
|
// .getRibbon(..).remove() and .getImage(...).remove() respectivly.
|
||||||
clear: function(gids){
|
clear: function(gids){
|
||||||
// clear all...
|
// clear all...
|
||||||
if(gids == null || gids == '*'){
|
if(gids == null || gids == '*'){
|
||||||
@ -356,11 +376,12 @@ module.RibbonsPrototype = {
|
|||||||
270: 180,
|
270: 180,
|
||||||
},
|
},
|
||||||
rotateImage: function(target, direction){
|
rotateImage: function(target, direction){
|
||||||
var r_table = direction == this.CW ? _cw : _ccw
|
var r_table = direction == this.CW ? this._cw : this._ccw
|
||||||
target = this.getImage(target)
|
target = this.getImage(target)
|
||||||
target.each(function(i, e){
|
target.each(function(i, e){
|
||||||
var img = $(this)
|
var img = $(this)
|
||||||
var o = r_table[img.attr('orientation')]
|
var o = img.attr('orientation')
|
||||||
|
o = r_table[ o == null ? null : o ]
|
||||||
if(o == null){
|
if(o == null){
|
||||||
img.removeAttr('orientation')
|
img.removeAttr('orientation')
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user