mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 02:10:08 +00:00
refactored out args2array(..) and its derivatives...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
fe389e6465
commit
299732762f
@ -52,7 +52,7 @@ module.Alias = core.ImageGridFeatures.Feature({
|
||||
// other than the ones created by .alias(..).
|
||||
['alias',
|
||||
function(_, alias, target){
|
||||
var args = [].slice.call(arguments, 1)
|
||||
var args = [...arguments].slice(1)
|
||||
var alias = args.shift()
|
||||
var target = args[args.length-1]
|
||||
|
||||
|
||||
@ -1899,7 +1899,7 @@ module.CropActions = actions.Actions({
|
||||
var current = this.current
|
||||
var focus = false
|
||||
|
||||
gids = arguments.length > 1 ? [].slice.call(arguments) : gids
|
||||
gids = arguments.length > 1 ? [...arguments] : gids
|
||||
gids = gids || 'current'
|
||||
gids = gids instanceof Array ? gids : [gids]
|
||||
|
||||
|
||||
@ -131,7 +131,7 @@ module.CLI = core.ImageGridFeatures.Feature({
|
||||
push: function(){
|
||||
var o = Object.create(this)
|
||||
o.root = false
|
||||
o.__prefix = (this.__prefix || []).concat([].slice.call(arguments))
|
||||
o.__prefix = (this.__prefix || []).concat([...arguments])
|
||||
return o
|
||||
},
|
||||
pop: function(){
|
||||
@ -139,7 +139,7 @@ module.CLI = core.ImageGridFeatures.Feature({
|
||||
},
|
||||
emit: function(){
|
||||
console.log.apply(console,
|
||||
(this.__prefix || []).concat([].slice.call(arguments)))
|
||||
(this.__prefix || []).concat([...arguments]))
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
@ -1405,7 +1405,7 @@ module.Collection = core.ImageGridFeatures.Feature({
|
||||
],
|
||||
function(){
|
||||
var that = this
|
||||
var args = [].slice.call(arguments)
|
||||
var args = [...arguments]
|
||||
var title = (args.length == 1 ? args[0] : args[1]) || this.collection
|
||||
var collection = (this.collections || {})[title] || {}
|
||||
|
||||
@ -1435,7 +1435,7 @@ module.Collection = core.ImageGridFeatures.Feature({
|
||||
}],
|
||||
['joinCollect',
|
||||
function(_, align, collection, data){
|
||||
var args = [].slice.call(arguments)
|
||||
var args = [...arguments]
|
||||
var title = (args.length == 1 ? args[0] : args[1]) || this.collection
|
||||
var collection = (this.collections || {})[title] || {}
|
||||
|
||||
@ -2247,7 +2247,7 @@ var AutoCollectionsActions = actions.Actions({
|
||||
NOTE: at least one tag must be supplied...
|
||||
`,
|
||||
function(title, tags){
|
||||
tags = arguments.length > 2 ? [].slice.call(arguments, 1) : tags
|
||||
tags = arguments.length > 2 ? [...arguments].slice(1) : tags
|
||||
tags = tags instanceof Array ? tags : [tags]
|
||||
|
||||
if(tags.length == 0){
|
||||
@ -2323,7 +2323,7 @@ module.AutoCollections = core.ImageGridFeatures.Feature({
|
||||
// passed to func with an appended title...
|
||||
var mixedModeCollectionAction = function(func, n, last_used_collection){
|
||||
return widgets.uiDialog(function(){
|
||||
var args = [].slice.call(arguments)
|
||||
var args = [...arguments]
|
||||
// check if minimum number of arguments is reached...
|
||||
return args.length < (n || 1) ?
|
||||
// show the dialog...
|
||||
@ -2338,7 +2338,7 @@ var mixedModeCollectionAction = function(func, n, last_used_collection){
|
||||
// are given...
|
||||
var collectionGetterWrapper = function(func, n, last_used_collection){
|
||||
return widgets.uiDialog(function(){
|
||||
var args = [].slice.call(arguments)
|
||||
var args = [...arguments]
|
||||
// check if minimum number of arguments is reached...
|
||||
return args.length < (n || 1)
|
||||
// show the dialog...
|
||||
|
||||
@ -1414,7 +1414,7 @@ var JournalActions = actions.Actions({
|
||||
var handler = function(action){
|
||||
return function(){
|
||||
var cur = this.current
|
||||
var args = util.args2array(arguments)
|
||||
var args = [...arguments]
|
||||
|
||||
var data = {
|
||||
type: 'basic',
|
||||
@ -1696,7 +1696,7 @@ var ChangesActions = actions.Actions({
|
||||
var that = this
|
||||
var args = section instanceof Array ?
|
||||
section
|
||||
: util.args2array(arguments)
|
||||
: [...arguments]
|
||||
//var changes = this.changes =
|
||||
var changes =
|
||||
this.hasOwnProperty('changes') ?
|
||||
|
||||
@ -36,9 +36,9 @@ var ExampleActions = actions.Actions({
|
||||
// i.e. once defined it can't be overwritten...
|
||||
exampleAction: ['Test/Action',
|
||||
function(){
|
||||
console.log('>>>', [].slice.call(arguments))
|
||||
console.log('>>>', [...arguments])
|
||||
return function(){
|
||||
console.log('<<<', [].slice.call(arguments)) }}],
|
||||
console.log('<<<', [...arguments]) }}],
|
||||
exampleActionFull: ['- Test/',
|
||||
core.doc`Example full action long documentation string
|
||||
`,
|
||||
@ -64,7 +64,7 @@ var ExampleActions = actions.Actions({
|
||||
|
||||
// a normal method...
|
||||
exampleMethod: function(){
|
||||
console.log('example method:', [].slice.call(arguments))
|
||||
console.log('example method:', [...arguments])
|
||||
return 'example result'
|
||||
},
|
||||
|
||||
@ -306,7 +306,7 @@ var ExampleUIActions = actions.Actions({
|
||||
exampleActionDisabled: ['Test/$Disabled example action',
|
||||
{browseMode: function(){ return 'disabled' }},
|
||||
function(){
|
||||
console.log('Disabled action called:', [].slice.call(arguments)) }],
|
||||
console.log('Disabled action called:', [...arguments]) }],
|
||||
|
||||
// Usage Examples:
|
||||
// .exampleDrawer() - show html in base drawer...
|
||||
@ -340,7 +340,7 @@ var ExampleUIActions = actions.Actions({
|
||||
widgets.makeUIDialog(function(){
|
||||
var actions = this
|
||||
|
||||
console.log('>>> args:', [].slice.call(arguments))
|
||||
console.log('>>> args:', [...arguments])
|
||||
|
||||
return browse.makeLister(null, function(path, make){
|
||||
var that = this
|
||||
@ -391,7 +391,7 @@ var ExampleUIActions = actions.Actions({
|
||||
widgets.makeUIDialog(function(){
|
||||
var actions = this
|
||||
|
||||
console.log('>>> args:', [].slice.call(arguments))
|
||||
console.log('>>> args:', [...arguments])
|
||||
|
||||
return browse.makeLister(null, function(path, make){
|
||||
var that = this
|
||||
|
||||
@ -260,7 +260,7 @@ var LocationActions = actions.Actions({
|
||||
XXX introspection...
|
||||
`,
|
||||
function(spec){
|
||||
var args = [].slice.call(arguments, 1)
|
||||
var args = [...arguments].slice(1)
|
||||
spec = spec instanceof Array ? spec : spec.split(':')
|
||||
|
||||
var cache = this.protocols
|
||||
|
||||
@ -135,7 +135,7 @@ function(protocol, func){
|
||||
return function(id){
|
||||
return id.startsWith(protocol + ':')
|
||||
&& function(res){
|
||||
res.set(func.apply(this, [].slice.call(arguments, 1))) }}}
|
||||
res.set(func.apply(this, [...arguments].slice(1))) }}}
|
||||
|
||||
|
||||
|
||||
@ -228,7 +228,7 @@ var PeerActions = actions.Actions({
|
||||
// is no need to reload it...
|
||||
peerCall: ['- System/Peer/',
|
||||
function(id, action){
|
||||
var args = [].slice.call(arguments, 2)
|
||||
var args = [...arguments].slice(2)
|
||||
return this.peerApply(id, action, args)
|
||||
}],
|
||||
peerApply: ['- System/Peer/',
|
||||
|
||||
@ -857,7 +857,7 @@ var StatusLogActions = actions.Actions({
|
||||
}],
|
||||
statusMessage: ['- Interface/',
|
||||
function(){
|
||||
var msg = args2array(arguments)
|
||||
var msg = [...arguments]
|
||||
if(msg.len == 0){
|
||||
return
|
||||
}
|
||||
|
||||
@ -432,7 +432,7 @@ module.uiDialog = function(func){
|
||||
// extended/overloaded...
|
||||
var makeUIDialog =
|
||||
module.makeUIDialog = function(a, b){
|
||||
var args = [].slice.call(arguments)
|
||||
var args = [...arguments]
|
||||
|
||||
// container name (optional)...
|
||||
var dfl = typeof(args[0]) == typeof('str') ?
|
||||
@ -444,7 +444,7 @@ module.makeUIDialog = function(a, b){
|
||||
var cargs = args
|
||||
|
||||
return uiDialog(function(){
|
||||
var args = [].slice.call(arguments)
|
||||
var args = [...arguments]
|
||||
|
||||
// see if the first arg is a container spec...
|
||||
var container = !(args[0] instanceof Array) && this.isUIContainer(args[0]) ?
|
||||
|
||||
@ -249,7 +249,7 @@ var DataPrototype = {
|
||||
return this.getImages(gids)
|
||||
}
|
||||
|
||||
gids = arguments.length > 1 ? [].slice.call(arguments) : gids
|
||||
gids = arguments.length > 1 ? [...arguments] : gids
|
||||
gids = gids instanceof Array ? gids : [gids]
|
||||
|
||||
return gids
|
||||
@ -1267,7 +1267,7 @@ var DataPrototype = {
|
||||
// list of image gids...
|
||||
getImagePositions: function(gids){
|
||||
gids = arguments.length > 1 ?
|
||||
[].slice.call(arguments)
|
||||
[...arguments]
|
||||
: (gids || this.current)
|
||||
gids = (gids instanceof Array ? gids.slice() : [gids])
|
||||
// sort ribbon gids to .ribbon_order
|
||||
@ -2344,7 +2344,7 @@ var DataPrototype = {
|
||||
// .getImage(..)
|
||||
// NOTE: if no target is given this will assume the current image.
|
||||
split: function(target){
|
||||
target = arguments.length > 1 ? [].slice.call(arguments)
|
||||
target = arguments.length > 1 ? [...arguments]
|
||||
: target == null || target instanceof Array ? target
|
||||
: [target]
|
||||
|
||||
@ -3183,7 +3183,7 @@ var DataWithTagsPrototype = {
|
||||
hasTag: function(gid, tag){
|
||||
return ((this.tags || {})[tag] || []).indexOf(this.getImage(gid)) >= 0 },
|
||||
getTags: function(gids){
|
||||
gids = arguments.length > 1 ? [].slice.call(arguments)
|
||||
gids = arguments.length > 1 ? [...arguments]
|
||||
: gids == null || gids == 'current' ? this.getImage()
|
||||
: gids
|
||||
gids = gids == null ? [] : gids
|
||||
@ -3212,7 +3212,7 @@ var DataWithTagsPrototype = {
|
||||
// NOTE: if raw is set to true then this will return all the tagged
|
||||
// gids even if they are not loaded in ribbons (i.e. cropped out)...
|
||||
getTaggedByAny: function(tags, raw){
|
||||
tags = arguments.length > 1 ? [].slice.call(arguments) : tags
|
||||
tags = arguments.length > 1 ? [...arguments] : tags
|
||||
tags = tags instanceof Array ? tags : [tags]
|
||||
|
||||
var res = []
|
||||
@ -3234,7 +3234,7 @@ var DataWithTagsPrototype = {
|
||||
: this.getImages(res.compact())
|
||||
},
|
||||
getTaggedByAll: function(tags, raw){
|
||||
tags = arguments.length > 1 ? [].slice.call(arguments) : tags
|
||||
tags = arguments.length > 1 ? [...arguments] : tags
|
||||
tags = tags instanceof Array ? tags : [tags]
|
||||
|
||||
if(this.tags == null){
|
||||
|
||||
@ -158,9 +158,7 @@ module.denodeify =
|
||||
function(func){
|
||||
var that = this
|
||||
return function(){
|
||||
// XXX for some reason this does not see args2array...
|
||||
// XXX and for some reason the error is not reported...
|
||||
var args = [].slice.call(arguments)
|
||||
var args = [...arguments]
|
||||
return new Promise(function(resolve, reject){
|
||||
func.apply(that, args.concat([function(err, res){
|
||||
return err ? reject(err) : resolve(res)
|
||||
|
||||
@ -307,13 +307,13 @@ var BaseRibbonsPrototype = {
|
||||
// XXX do we need custom target support here???
|
||||
noTransitions: function(func){
|
||||
this.preventTransitions()
|
||||
func.apply(this, args2array(arguments).slice(1))
|
||||
func.apply(this, [...arguments].slice(1))
|
||||
this.restoreTransitions(true)
|
||||
return this
|
||||
},
|
||||
noTransitionsDeep: function(func){
|
||||
this.preventTransitions(null, true)
|
||||
func.apply(this, args2array(arguments).slice(1))
|
||||
func.apply(this, [...arguments].slice(1))
|
||||
this.restoreTransitions(true)
|
||||
return this
|
||||
},
|
||||
|
||||
@ -846,7 +846,7 @@ function makeDeferredPool(size, paused){
|
||||
var deferred = $.Deferred()
|
||||
|
||||
// add worker to queue...
|
||||
this.queue.push([deferred, func, args2array(arguments).slice(1)])
|
||||
this.queue.push([deferred, func, [...arguments].slice(1)])
|
||||
|
||||
// start work if we have not already...
|
||||
this._fill()
|
||||
@ -1029,13 +1029,6 @@ function sign(x){
|
||||
}
|
||||
|
||||
|
||||
// convert JS arguments to Array...
|
||||
function args2array(args){
|
||||
//return Array.apply(null, args)
|
||||
return [].slice.call(args)
|
||||
}
|
||||
|
||||
|
||||
var getAnimationFrame = (window.requestAnimationFrame
|
||||
|| window.webkitRequestAnimationFrame
|
||||
|| window.mozRequestAnimationFrame
|
||||
|
||||
@ -661,7 +661,7 @@ var KeyboardPrototype = {
|
||||
var service_fields = this.service_fields
|
||||
|| this.constructor.service_fields
|
||||
|
||||
handler = arguments.length > 1 ? [].slice.call(arguments)
|
||||
handler = arguments.length > 1 ? [...arguments]
|
||||
: handler == null ? '*'
|
||||
: handler == '*' || handler == '?' || handler instanceof Function ? handler
|
||||
: handler instanceof Array ? handler
|
||||
|
||||
@ -158,8 +158,8 @@ var transformEditor = function(){
|
||||
},
|
||||
|
||||
toString: function(){
|
||||
//return obj2transform(this.data, args2array(arguments))
|
||||
var args = args2array(arguments)
|
||||
//return obj2transform(this.data, [...arguments])
|
||||
var args = [...arguments]
|
||||
return obj2transform(this.simplify(args), args)
|
||||
},
|
||||
// NOTE: this will not build the alias data...
|
||||
@ -197,7 +197,7 @@ var transformEditor = function(){
|
||||
var that = this
|
||||
var attrs = arguments[0] instanceof Array ?
|
||||
arguments[0]
|
||||
: args2array(arguments)
|
||||
: [...arguments]
|
||||
var res = {}
|
||||
|
||||
attrs.forEach(function(a){
|
||||
@ -373,7 +373,7 @@ var transformEditor = function(){
|
||||
// i.e. this will iterate the arguments (width) while
|
||||
// the handler(..) will iterate the aliases...
|
||||
function(){
|
||||
var args = args2array(arguments)
|
||||
var args = [...arguments]
|
||||
// XXX do a full search through the alias values and merge results...
|
||||
if(args.length == 0 && k in this.__direct){
|
||||
return this.__direct[k].call(this)
|
||||
@ -388,7 +388,7 @@ var transformEditor = function(){
|
||||
return b
|
||||
}
|
||||
: function(){
|
||||
var args = args2array(arguments)
|
||||
var args = [...arguments]
|
||||
return func.call(this, k, args)
|
||||
}
|
||||
|
||||
@ -461,7 +461,7 @@ var transformEditor = function(){
|
||||
Object.keys(editor.__direct).forEach(function(k){
|
||||
if(!(k in editor)){
|
||||
editor[k] = function(){
|
||||
var args = args2array(arguments)
|
||||
var args = [...arguments]
|
||||
editor.__direct[k].apply(this, args.length > 0 ? [args]: [])
|
||||
return editor.__direct[k].call(this)
|
||||
}
|
||||
@ -485,7 +485,7 @@ jQuery.fn.transform = function(){
|
||||
var e = $(this)
|
||||
var elem = e[0]
|
||||
|
||||
var args = args2array(arguments)
|
||||
var args = [...arguments]
|
||||
// normalize...
|
||||
args = args.length == 0
|
||||
|| typeof(args[0]) == typeof('str') ? args
|
||||
@ -532,7 +532,7 @@ jQuery.fn.transform = function(){
|
||||
// shorthands...
|
||||
jQuery.fn.scale = function(value){
|
||||
if(arguments.length > 0){
|
||||
return $(this).transform({scale: args2array(arguments)})
|
||||
return $(this).transform({scale: [...arguments]})
|
||||
|
||||
} else {
|
||||
return $(this).transform('scale')
|
||||
@ -540,7 +540,7 @@ jQuery.fn.scale = function(value){
|
||||
}
|
||||
jQuery.fn.rotate = function(value){
|
||||
if(arguments.length > 0){
|
||||
return $(this).transform({rotate: args2array(arguments)})
|
||||
return $(this).transform({rotate: [...arguments]})
|
||||
|
||||
} else {
|
||||
return $(this).transform('rotate')
|
||||
|
||||
@ -173,12 +173,6 @@ Array.prototype.setCmp = function(other){
|
||||
.sort()) }
|
||||
|
||||
|
||||
var args2array =
|
||||
module.args2array =
|
||||
Array.fromArgs =
|
||||
function(args){ return [].slice.call(args) }
|
||||
|
||||
|
||||
Array.prototype.sortAs = function(other){
|
||||
return this.sort(function(a, b){
|
||||
var i = other.indexOf(a)
|
||||
|
||||
@ -1871,7 +1871,7 @@ var BrowserPrototype = {
|
||||
|
||||
// NOTE: this will propagate up to the dialog...
|
||||
if(elem.length > 0){
|
||||
var args = [].slice.call(arguments).slice(1)
|
||||
var args = [...arguments].slice(1)
|
||||
elem.trigger({
|
||||
type: arguments[0],
|
||||
source: this,
|
||||
@ -2579,7 +2579,7 @@ var BrowserPrototype = {
|
||||
if(item_shortcut_marker){
|
||||
var _replace = function(){
|
||||
// get the last group...
|
||||
var key = [].slice.call(arguments).slice(-3)[0]
|
||||
var key = [...arguments].slice(-3)[0]
|
||||
!item_shortcuts[keyboard.normalizeKey(key)]
|
||||
// NOTE: this is a side-effect...
|
||||
&& that.keyboard.handler(
|
||||
|
||||
@ -44,13 +44,13 @@ function(name, defaults){
|
||||
return function(){
|
||||
// register...
|
||||
if(arguments[0] instanceof Function){
|
||||
this.dom.trigger(name, [].slice.call(arguments))
|
||||
this.dom.trigger(name, [...arguments])
|
||||
|
||||
// trigger...
|
||||
} else {
|
||||
var args = (arguments.length == 0 && defaults) ?
|
||||
defaults.call(this)
|
||||
: [].slice.call(arguments)
|
||||
: [...arguments]
|
||||
args = args instanceof Array ? args : [args]
|
||||
|
||||
this.dom.trigger(name, args)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user