Array.prototype.whose = function F(/*obj|fct*/condition)
//————————————–
// Note: support nested objs (see Example 1 below)
{
// Default test function (cached)
// —
F.OBJ_TEST || (F.OBJ_TEST = function T(t,o)
{
var r = 1,
k;
for( k in o )
{
if( !o.hasOwnProperty(k) ) continue;
r = ( ‘object’ == typeof o[k] ) ?
T(t[k],o[k]) :
+(t[k] == o[k]);
if( !r ) break;
}
return r;
});
// Vars
// —
var fCond = ‘function’==typeof condition || (condition instanceof Function),
oCond = fCond ? undefined : condition,
n = this.length,
z = 0,
i;
// Do we use the default function?
// —
fCond = fCond ? condition : F.OBJ_TEST;
// Processing…
// —
for( i=0 ; i < n ; ++i )
fCond(this[i],oCond) && (this[z++] = this[i]);
this.length = z;
fCond = oCond = null;
// Will allow compound calls :-)
// —
return this;
};
var main = function() {
var doc = app.properties.activeDocument, xGap = .25;
if ( !doc ) return;
var items = doc.allPageItems.whose ( function(item) {
return item.appliedObjectStyle.name == “OZALTO”;
});
var n = items.length;
while ( n– ) {
items[n].move ( undefined, [xGap, 0] );
}
}
var u;
app.doScript ( “main()”,u,u,UndoModes.ENTIRE_SCRIPT, “The Script” );