チェンジセット 196
- コミット日時:
- 2008/01/13 03:16:38 (4 年前)
- ファイル:
-
- as3/aQuery/samples/test/Circle2.as (削除)
- as3/as3Query (移動) (as3/aQuery から 移動)
- as3/as3Query/samples (コピー) (as3/aQuery/samples から コピー)
- as3/as3Query/samples/CssSelectorDemo.as (追加)
- as3/as3Query/samples/CssSelectorDemo.swf (追加)
- as3/as3Query/samples/Test.as (更新) (1 diff)
- as3/as3Query/samples/test/Base.as (追加)
- as3/as3Query/samples/test/Circle.as (更新) (1 diff)
- as3/as3Query/samples/test/Polygon.as (追加)
- as3/as3Query/samples/test/Rect.as (追加)
- as3/as3Query/samples/test/RoundRect.as (追加)
- as3/as3Query/samples/test/Square.as (追加)
- as3/as3Query/samples/test/Star.as (追加)
- as3/as3Query/src (コピー) (as3/aQuery/src から コピー)
- as3/as3Query/src/com/nitoyon/as3query (移動) (as3/aQuery/src/com/nitoyon/aquery から 移動)
- as3/as3Query/src/com/nitoyon/as3query/$.as (コピー) (as3/aQuery/src/com/nitoyon/aquery/$.as から コピー) (1 diff)
- as3/as3Query/src/com/nitoyon/as3query/Dom.as (コピー) (as3/aQuery/src/com/nitoyon/aquery/Dom.as から コピー) (6 diffs)
- as3/as3Query/src/com/nitoyon/as3query/as3Query.as (移動) (as3/aQuery/src/com/nitoyon/aquery/aQuery.as から 移動) (82 diffs)
- as3/as3Query/src/com/nitoyon/as3query/as3QueryEvent.as (移動) (as3/aQuery/src/com/nitoyon/aquery/aQueryEvent.as から 移動) (11 diffs)
- as3/as3Query/src/com/nitoyon/as3query/as3QueryFx.as (移動) (as3/aQuery/src/com/nitoyon/aquery/aQueryFx.as から 移動) (11 diffs)
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
as3/as3Query/samples/Test.as
r184 r196 7 7 import test.Circle; Circle; 8 8 import test.Circle2; Circle2; 9 import com.nitoyon.a query.*;9 import com.nitoyon.as3query.*; 10 10 11 11 public class Test extends Sprite as3/as3Query/samples/test/Circle.as
r182 r196 1 1 package test 2 2 { 3 import flash.display.*; 4 5 public class Circle extends Sprite 3 public class Circle extends Base 6 4 { 7 public function Circle()5 internal override function drawShape():void 8 6 { 9 graphics.beginFill(0xff0000); 10 graphics.drawCircle(25, 25, 25); 11 graphics.endFill(); 7 graphics.drawEllipse(0, 0, width, height); 12 8 } 13 9 } as3/as3Query/src/com/nitoyon/as3query/$.as
r183 r196 1 package com.nitoyon.a query {2 public function $(... args):a Query {3 return a Query.create(args[0], args[1]);1 package com.nitoyon.as3query { 2 public function $(... args):as3Query { 3 return as3Query.create(args[0], args[1]); 4 4 } 5 5 } as3/as3Query/src/com/nitoyon/as3query/Dom.as
r186 r196 1 package com.nitoyon.a query {1 package com.nitoyon.as3query { 2 2 import flash.utils.getQualifiedClassName; 3 import flash.utils.Dictionary; 3 4 import flash.display.DisplayObject; 4 5 import flash.display.DisplayObjectContainer; … … 9 10 var c:DisplayObjectContainer = DisplayObjectContainer(node); 10 11 return c.numChildren ? c.getChildAt(0) : null; 12 } 13 14 return null; 15 } 16 17 static public function lastChild( node:DisplayObject):DisplayObject { 18 if ( node is DisplayObjectContainer ) { 19 var c:DisplayObjectContainer = DisplayObjectContainer(node); 20 return c.numChildren ? c.getChildAt(c.numChildren - 1) : null; 11 21 } 12 22 … … 26 36 } 27 37 38 static internal function getProperty( node:DisplayObject, prop:String ):Object { 39 return /firstChild|nextSibling|previousSibling/.test(prop) ? Dom[prop]( node ) : 40 node.hasOwnProperty(prop) ? node[prop] : null; 41 } 42 28 43 static public function nodeName( node:DisplayObject ):String { 29 44 return getQualifiedClassName( node ).replace(/.*::/, ""); … … 34 49 } 35 50 51 static private var idList:Dictionary = new Dictionary( false ); 52 53 static internal function registerId( id:String, obj:DisplayObject ):void { 54 idList[ id ] = obj; 55 } 56 57 static internal function unregisterId( id:String ):void { 58 if( idList.hasOwnProperty( id )) 59 delete idList[ id ]; 60 } 61 62 static public function getElementById( id:String ):DisplayObject { 63 return idList[ id ]; 64 } 65 36 66 static public function getElementsByTagName( tagName:String, parent:DisplayObject = null, arr:Array = null ):Array { 37 parent = parent || a Query.stage;67 parent = parent || as3Query.stage; 38 68 arr = arr || []; 39 69 … … 43 73 var n:DisplayObject = p.getChildAt( i ); 44 74 45 if ( nodeNameCmp( n, tagName ) )75 if ( tagName == "*" || nodeNameCmp( n, tagName ) ) 46 76 arr.push( n ); 47 77 if ( n is DisplayObjectContainer) … … 52 82 return arr; 53 83 } 54 55 static public function getProperty( node:DisplayObject, prop:String ):Object {56 return /firstChild|nextSibling|previousSibling/.test(prop) ? Dom[prop]( node ) :57 node.hasOwnProperty(prop) ? node[prop] : null;58 }59 84 } 60 85 } as3/as3Query/src/com/nitoyon/as3query/as3Query.as
r186 r196 1 package com.nitoyon.a query {1 package com.nitoyon.as3query { 2 2 import flash.utils.Proxy; 3 3 import flash.utils.flash_proxy; 4 4 import flash.utils.getDefinitionByName; 5 5 import flash.utils.getQualifiedClassName; 6 import flash.utils.ByteArray;7 6 import flash.utils.Dictionary; 8 7 import flash.events.Event; 9 8 import flash.net.registerClassAlias; 10 import flash.media.SoundTransform;11 import flash.geom.Transform;12 9 import flash.display.DisplayObject; 13 10 import flash.display.DisplayObjectContainer; 14 11 import flash.display.Stage; 15 import com.nitoyon.aquery.aQueryFx; 16 17 public class aQuery extends Proxy { 12 13 public class as3Query extends Proxy { 18 14 19 15 //-------------------------------------------------------------------------- … … 25 21 private static var quickExpr:RegExp = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/; 26 22 27 public function a Query(array:Array) {23 public function as3Query(array:Array) { 28 24 setArray( array ); 29 25 } … … 41 37 } 42 38 43 static public function create(... args):a Query {39 static public function create(... args):as3Query { 44 40 var a:Object = args[0] || _stage; 45 41 var c:Object = args[1]; … … 50 46 // HANDLE $(html) -> $(array) 51 47 if( m[ 1 ] ) { 52 a = a Query.clean( [ m[1] ] );48 a = as3Query.clean( [ m[1] ] ); 53 49 // HANDLE: $("#id") 54 50 } else { 55 throw new Error(); 51 var tmp:DisplayObject = Dom.getElementById( m[3] ); 52 if ( tmp ){ 53 return new as3Query( [ tmp ] ); 54 } 55 else 56 a = []; 56 57 } 57 58 // HANDLE: $(expr) … … 61 62 // HANDLE: $(function) 62 63 // Shortcut for ??? 63 } else if( a Query.isFunction(a) ) {64 } else if( as3Query.isFunction(a) ) { 64 65 throw new Error(); 65 66 // HANDLE: $(XML) 66 67 } else if( a is XML || a is XMLList ) { 67 a = a Query.clean( [ a ]);68 a = as3Query.clean( [ a ]); 68 69 // HANDLE: $(Class) 69 70 } else if( a is Class ) { … … 72 73 73 74 if ( a is Stage && !_stage) 74 a Query.stage = a as Stage;75 76 return new a Query(75 as3Query.stage = a as Stage; 76 77 return new as3Query( 77 78 // HANDLE: $(array) 78 79 a is Array ? a as Array : 79 80 80 81 // HANDLE: $(arraylike) 81 a.hasOwnProperty("length") && a.hasOwnProperty(0) ? a Query.makeArray(a) :82 a.hasOwnProperty("length") && a.hasOwnProperty(0) ? as3Query.makeArray(a) : 82 83 83 84 // HANDLE: $(*) … … 100 101 101 102 public function toString():String { 102 return "[a Query " + _array.toString() + "]";103 return "[as3Query " + _array.toString() + "]"; 103 104 } 104 105 … … 126 127 public function getArray():Array { 127 128 // Return a 'clean' array 128 return a Query.makeArray( this );129 } 130 131 private var prevObject:a Query = null;132 private function pushStack( a:Object ):a Query {133 var ret:a Query = aQuery.create(a);129 return as3Query.makeArray( this ); 130 } 131 132 private var prevObject:as3Query = null; 133 private function pushStack( a:Object ):as3Query { 134 var ret:as3Query = as3Query.create(a); 134 135 ret.prevObject = this; 135 136 return ret; 136 137 } 137 138 138 private function setArray(a:Array):a Query {139 private function setArray(a:Array):as3Query { 139 140 _array.push.apply(_array, a); 140 141 return this; 141 142 } 142 143 143 public function each(fn:Function, args:Object = null):a Query {144 return a Query.each( this, fn, args ) as aQuery;144 public function each(fn:Function, args:Object = null):as3Query { 145 return as3Query.each( this, fn, args ) as as3Query; 145 146 } 146 147 … … 155 156 if ( key is String ) 156 157 if ( value == null ) 157 return length && a Query[type || "attr"](this[0], key) || undefined;158 return length && as3Query[type || "attr"](this[0], key) || undefined; 158 159 else { 159 160 obj = {}; … … 165 166 // Set all the styles 166 167 for ( var prop:String in obj ) 167 a Query.attr(168 as3Query.attr( 168 169 this, 169 prop, a Query.prop(this, obj[prop], type, index, prop)170 prop, as3Query.prop(this, obj[prop], type, index, prop) 170 171 ); 171 172 }); … … 186 187 187 188 var t:String = ""; 188 a Query.each( e || this, function(index:int, val:Object):void {189 as3Query.each( e || this, function(index:int, val:Object):void { 189 190 if( this.hasOwnProperty("text") ) { 190 191 t += this["text"].toString(); … … 194 195 } 195 196 196 public function wrapAll(html:String):a Query {197 public function wrapAll(html:String):as3Query { 197 198 if ( this[0] ) 198 199 // The elements to wrap the target around 199 a Query.create(html, this[0].stage)200 as3Query.create(html, this[0].stage) 200 201 .clone() 201 202 .insertBefore(this[0]) … … 211 212 } 212 213 213 public function wrapInner(html:String):a Query {214 public function wrapInner(html:String):as3Query { 214 215 return each(function(...args):void{ 215 a Query.create(this).contents().wrapAll(html);216 }); 217 } 218 219 public function wrap(html:String):a Query {216 as3Query.create(this).contents().wrapAll(html); 217 }); 218 } 219 220 public function wrap(html:String):as3Query { 220 221 return each(function(...args):void{ 221 a Query.create(this).wrapAll(html);222 as3Query.create(this).wrapAll(html); 222 223 }); 223 224 } … … 239 240 }; 240 241 241 public function parent( filter:String = null ):a Query {242 public function parent( filter:String = null ):as3Query { 242 243 return mapAndPush(filter, function(a:DisplayObject, ...args):DisplayObject { 243 244 return a.parent; … … 245 246 } 246 247 247 public function parents( filter:String = null ):a Query {248 public function parents( filter:String = null ):as3Query { 248 249 return mapAndPush(filter, function(a:DisplayObject, ...args):Array { 249 return a Query.dir(a, 'parent');250 }); 251 } 252 253 public function next( filter:String = null ):a Query {250 return as3Query.dir(a, 'parent'); 251 }); 252 } 253 254 public function next( filter:String = null ):as3Query { 254 255 return mapAndPush(filter, function(a:DisplayObject, ...args):DisplayObject { 255 return a Query.nth(a, 2, 'nextSibling');256 }); 257 } 258 259 public function prev( filter:String = null ):a Query {256 return as3Query.nth(a, 2, 'nextSibling'); 257 }); 258 } 259 260 public function prev( filter:String = null ):as3Query { 260 261 return mapAndPush(filter, function(a:DisplayObject, ...args):DisplayObject { 261 return a Query.nth(a, 2, 'previousSibling');262 }); 263 } 264 265 public function nextAll( filter:String = null ):a Query {262 return as3Query.nth(a, 2, 'previousSibling'); 263 }); 264 } 265 266 public function nextAll( filter:String = null ):as3Query { 266 267 return mapAndPush(filter, function(a:DisplayObject, ...args):Array { 267 return a Query.dir(a, 'nextSibling');268 }); 269 } 270 271 public function prevAll( filter:String = null ):a Query {268 return as3Query.dir(a, 'nextSibling'); 269 }); 270 } 271 272 public function prevAll( filter:String = null ):as3Query { 272 273 return mapAndPush(filter, function(a:DisplayObject, ...args):Array { 273 return a Query.dir(a, 'previousSibling');274 }); 275 } 276 277 public function siblings( filter:String = null ):a Query {274 return as3Query.dir(a, 'previousSibling'); 275 }); 276 } 277 278 public function siblings( filter:String = null ):as3Query { 278 279 return mapAndPush(filter, function(a:DisplayObject, ...args):Array { 279 return a Query.sibling(a.parent.getChildAt(0), a);280 }); 281 } 282 283 public function children( filter:String = null ):a Query {280 return as3Query.sibling(a.parent.getChildAt(0), a); 281 }); 282 } 283 284 public function children( filter:String = null ):as3Query { 284 285 return mapAndPush(filter, function(a:DisplayObject, ...args):Array { 285 return a Query.sibling(Dom.firstChild(a));286 }); 287 } 288 289 public function contents( filter:String = null ):a Query {286 return as3Query.sibling(Dom.firstChild(a)); 287 }); 288 } 289 290 public function contents( filter:String = null ):as3Query { 290 291 return mapAndPush(filter, function(a:DisplayObject, ...args):DisplayObject { 291 292 return a.root; … … 293 294 } 294 295 295 private function mapAndPush( a:String, fn:Function ):a Query {296 var ret:Array = a Query.map( this, fn );296 private function mapAndPush( a:String, fn:Function ):as3Query { 297 var ret:Array = as3Query.map( this, fn ); 297 298 if ( a ) 298 ret = a Query.multiFilter(a, ret.getArray());299 return pushStack(a Query.unique(ret));300 } 301 302 public function append(... args):a Query {299 ret = as3Query.multiFilter(a, ret.getArray()); 300 return pushStack(as3Query.unique(ret)); 301 } 302 303 public function append(... args):as3Query { 303 304 return domManip(args, true, 1, function(a:DisplayObject):void{ 304 305 this.addChild( a ); … … 306 307 } 307 308 308 public function prepend(... args):a Query {309 public function prepend(... args):as3Query { 309 310 return domManip(args, true, -1, function(a:DisplayObject):void{ 310 311 this.addChildAt( a, 0 ); … … 312 313 } 313 314 314 public function before(... args):a Query {315 public function before(... args):as3Query { 315 316 return this.domManip(args, false, 1, function(a:DisplayObject):void{ 316 317 this.parent.addChildAt( a, this.parent.getChildIndex( this ) ); … … 318 319 } 319 320 320 public function after(... args):a Query {321 public function after(... args):as3Query { 321 322 return this.domManip(args, false, -1, function(a:DisplayObject):void{ 322 323 this.parent.addChildAt( a, this.parent.getChildIndex( this ) + 1 ); … … 324 325 } 325 326 326 public function end():a Query {327 return prevObject || a Query.create([]);328 } 329 330 public function find(t:*):a Query {331 var data:Array = a Query.map(this, function(a:DisplayObject, ...args):Array{ return aQuery.find(t,a); });327 public function end():as3Query { 328 return prevObject || as3Query.create([]); 329 } 330 331 public function find(t:*):as3Query { 332 var data:Array = as3Query.map(this, function(a:DisplayObject, ...args):Array{ return as3Query.find(t,a); }); 332 333 return pushStack( /[^+>] [^+>]/.test( t ) || t.indexOf("..") > -1 ? 333 a Query.unique( data ) : data );334 } 335 336 public function clone(events:Boolean = false):a Query {334 as3Query.unique( data ) : data ); 335 } 336 337 public function clone(events:Boolean = false):as3Query { 337 338 // Do the clone 338 var ret:a Query = map(function(...args):DisplayObject{339 return a Query.cloneObject(this) as DisplayObject;339 var ret:as3Query = map(function(...args):DisplayObject{ 340 return as3Query.cloneObject(this) as DisplayObject; 340 341 }); 341 342 342 343 if (events === true) { 343 var clone:a Query = ret.find("*").andSelf();344 var clone:as3Query = ret.find("*").andSelf(); 344 345 345 346 find("*").andSelf().each(function(i:int, ...args):void { 346 var events:Object = a Query.data(this, "events");347 var events:Object = as3Query.data(this, "events"); 347 348 for ( var type:String in events ) 348 349 for ( var handler:Object in events[type] ) 349 a QueryEvent.add(clone[i], type, events[type][handler], events[type][handler].data);350 as3QueryEvent.add(clone[i], type, events[type][handler], events[type][handler].data); 350 351 }); 351 352 } … … 355 356 } 356 357 357 public function filter(t:Object):a Query {358 public function filter(t:Object):as3Query { 358 359 return pushStack( 359 a Query.isFunction( t ) &&360 a Query.grep(this, function(el:Object, index:int):Object{360 as3Query.isFunction( t ) && 361 as3Query.grep(this, function(el:Object, index:int):Object{ 361 362 return t.apply(el, [index]); 362 363 }) || 363 364 364 a Query.multiFilter(t.toString(),_array) );365 } 366 367 public function not(t:Object):a Query {365 as3Query.multiFilter(t.toString(),_array) ); 366 } 367 368 public function not(t:Object):as3Query { 368 369 return pushStack( 369 370 t is String && 370 a Query.multiFilter(t as String, _array, true) ||371 372 a Query.grep(this, function(a:Object):Boolean {373 return ( t is Array ? a Query.inArray( a, t as Array ) < 0 :374 t is a Query ? aQuery.inArray( a, t._array ) < 0 : a != t);371 as3Query.multiFilter(t as String, _array, true) || 372 373 as3Query.grep(this, function(a:Object):Boolean { 374 return ( t is Array ? as3Query.inArray( a, t as Array ) < 0 : 375 t is as3Query ? as3Query.inArray( a, t._array ) < 0 : a != t); 375 376 }) 376 377 ); 377 378 } 378 379 379 public function add(t:Object):a Query {380 return pushStack( a Query.merge(380 public function add(t:Object):as3Query { 381 return pushStack( as3Query.merge( 381 382 get() as Array, 382 383 t is String ? 383 a Query(t).get() as Array :384 as3Query(t).get() as Array : 384 385 t is Array ? t as Array : 385 t is a Query ? t.get() as Array : [t] )386 t is as3Query ? t.get() as Array : [t] ) 386 387 ); 387 388 } 388 389 389 390 public function _is(expr:String):Boolean { 390 return expr ? a Query.multiFilter(expr, _array).length > 0 : false;391 return expr ? as3Query.multiFilter(expr, _array).length > 0 : false; 391 392 } 392 393 … … 399 400 if ( this.length ) { 400 401 var elem = this[0]; 401 402 402 403 // We need to handle select boxes special 403 if ( a Query.nodeName(elem, "select") ) {404 if ( as3Query.nodeName(elem, "select") ) { 404 405 var index = elem.selectedIndex, 405 406 a = [], … … 416 417 if ( option.selected ) { 417 418 // Get the specifc value for the option 418 var val = a Query.browser.msie && !option.attributes["value"].specified ? option.text : option.value;419 var val = as3Query.browser.msie && !option.attributes["value"].specified ? option.text : option.value; 419 420 420 421 // We don't need an array for one selects … … 436 437 return this.each(function(){ 437 438 if ( val.constructor == Array && /radio|checkbox/.test(this.type) ) 438 this.checked = (a Query.inArray(this.value, val) >= 0 ||439 a Query.inArray(this.name, val) >= 0);440 else if ( a Query.nodeName(this, "select") ) {439 this.checked = (as3Query.inArray(this.value, val) >= 0 || 440 as3Query.inArray(this.name, val) >= 0); 441 else if ( as3Query.nodeName(this, "select") ) { 441 442 var tmp = val.constructor == Array ? val : [val]; 442 443 443 a Query("option", this).each(function(){444 this.selected = (a Query.inArray(this.value, tmp) >= 0 ||445 a Query.inArray(this.text, tmp) >= 0);444 as3Query("option", this).each(function(){ 445 this.selected = (as3Query.inArray(this.value, tmp) >= 0 || 446 as3Query.inArray(this.text, tmp) >= 0); 446 447 }); 447 448 … … 463 464 } 464 465 465 public function replaceWith( val:Object ):a Query {466 public function replaceWith( val:Object ):as3Query { 466 467 return after( val ).remove(); 467 468 } 468 469 469 public function slice(...args):a Query {470 public function slice(...args):as3Query { 470 471 return pushStack( _array.slice.apply( this, args ) ); 471 472 } 472 473 473 public function map(fn:Function):a Query {474 return pushStack(a Query.map( this, function(elem:Object,i:int):Object{474 public function map(fn:Function):as3Query { 475 return pushStack(as3Query.map( this, function(elem:Object,i:int):Object{ 475 476 return fn.call( elem, i, elem ); 476 477 })); 477 478 } 478 479 479 public function andSelf():a Query {480 public function andSelf():as3Query { 480 481 return add( prevObject ); 481 482 } 482 483 483 public function domManip(args:Array, table:Boolean, dir:int, fn:Function):aQuery { 484 // this -> Sprite 485 // args -> aQuery ( "TextField" ) 484 public function domManip(args:Array, table:Boolean, dir:int, fn:Function):as3Query { 486 485 var clone:Boolean = length > 1, a:Array; 487 486 488 487 return each(function():void{ 489 488 if ( !a ) { 490 a = a Query.clean(args);489 a = as3Query.clean(args); 491 490 if ( dir < 0 ) 492 491 a.reverse(); 493 492 } 494 493 495 var obj:a Query = this;496 497 a Query.each( a, function():void{498 fn.apply( obj, [ clone ? a Query.cloneObject(this) : this ] );494 var obj:as3Query = this; 495 496 as3Query.each( a, function():void{ 497 fn.apply( obj, [ clone ? as3Query.cloneObject(this) : this ] ); 499 498 }); 500 }) as a Query;499 }) as as3Query; 501 500 } 502 501 … … 514 513 515 514 public function extend( ...args ):Object { 516 return a Query.extend.apply( null, args );515 return as3Query.extend.apply( null, args ); 517 516 } 518 517 … … 540 539 // Recurse if we're merging object values 541 540 if ( deep && prop[i] is Object && target[i] ) 542 a Query.extend( target[i], prop[i] );541 as3Query.extend( target[i], prop[i] ); 543 542 544 543 // Don't bring in undefined values … … 551 550 } 552 551 553 private static var expando:String = "a Query" + (new Date()).getTime();552 private static var expando:String = "as3Query" + (new Date()).getTime(); 554 553 555 554 static public function isFunction(fn:Object):Boolean … … 568 567 } 569 568 570 static private var cache:Dictionary = new Dictionary( );569 static private var cache:Dictionary = new Dictionary( false ); 571 570 572 571 static internal function data( elem:Object, name:String = "", data:Object = null ):Object { … … 578 577 // Prevent overriding the named cache with undefined values 579 578 if ( data != null ) 580 a Query.cache[ elem ][ name ] = data;579 as3Query.cache[ elem ][ name ] = data; 581 580 582 581 // Return the named cache data … … 587 586 // If we want to remove a specific section of the element's data 588 587 if ( name != "" ) { 589 if ( a Query.cache[ elem ] ) {588 if ( as3Query.cache[ elem ] ) { 590 589 // Remove the section of cache data 591 delete a Query.cache[ elem ][ name ];590 delete as3Query.cache[ elem ][ name ]; 592 591 593 592 // If we've removed all the data, remove the element's cache 594 593 name = ""; 595 for ( name in a Query.cache[ elem ] ) break;594 for ( name in as3Query.cache[ elem ] ) break; 596 595 if ( name != "" ) 597 a Query.removeData( elem );596 as3Query.removeData( elem ); 598 597 } 599 598 … … 601 600 } else { 602 601 // Clean up the element expando 603 delete a Query.cache[ elem ];602 delete as3Query.cache[ elem ]; 604 603 } 605 604 } … … 633 632 static public function prop(elem:Object, value:Object, type:Object, index:int, prop:Object):Object { 634 633 // Handle executable functions 635 if(a Query.isFunction(value))634 if(as3Query.isFunction(value)) 636 635 value = Function(value).call(elem, [index]); 637 636 … … 643 642 // internal only, use addClass("class") 644 643 add: function( elem, c ){ 645 a Query.each( (c || "").split(/\s+/), function(i, cur){646 if ( !a Query.className.has( elem.className, cur ) )644 as3Query.each( (c || "").split(/\s+/), function(i, cur){ 645 if ( !as3Query.className.has( elem.className, cur ) ) 647 646 elem.className += ( elem.className ? " " : "" ) + cur; 648 647 }); … … 652 651 remove: function( elem, c ){ 653 652 elem.className = c != undefined ? 654 a Query.grep( elem.className.split(/\s+/), function(cur){655 return !a Query.className.has( c, cur );653 as3Query.grep( elem.className.split(/\s+/), function(cur){ 654 return !as3Query.className.has( c, cur ); 656 655 }).join(" ") : ""; 657 656 }, … … 659 658 // internal only, use is(".class") 660 659 has: function( t, c ) { 661 return a Query.inArray( c, (t.className || t).toString().split(/\s+/) ) > -1;660 return as3Query.inArray( c, (t.className || t).toString().split(/\s+/) ) > -1; 662 661 } 663 662 }, … … 677 676 var old = {}, oHeight, oWidth, d = ["Top","Bottom","Right","Left"]; 678 677 679 a Query.each( d, function(){678 as3Query.each( d, function(){ 680 679 old["padding" + this] = 0; 681 680 old["border" + this + "Width"] = 0; 682 681 }); 683 682 684 a Query.swap( e, old, function() {685 if ( a Query(e).is(':visible') ) {683 as3Query.swap( e, old, function() { 684 if ( as3Query(e).is(':visible') ) { 686 685 oHeight = e.offsetHeight; 687 686 oWidth = e.offsetWidth; 688 687 } else { 689 e = a Query(e.cloneNode(true))688 e = as3Query(e.cloneNode(true)) 690 689 .find(":radio").removeAttr("checked").end() 691 690 .css({ … … 693 692 }).appendTo(e.parentNode)[0]; 694 693 695 var parPos = a Query.css(e.parentNode,"position") || "static";694 var parPos = as3Query.css(e.parentNode,"position") || "static"; 696 695 if ( parPos == "static" ) 697 696 e.parentNode.style.position = "relative"; … … 710 709 } 711 710 712 return a Query.curCSS( e, p );711 return as3Query.curCSS( e, p ); 713 712 }, 714 713 … … 718 717 // A helper method for determining if an element's values are broken 719 718 function color(a){ 720 if ( !a Query.browser.safari )719 if ( !as3Query.browser.safari ) 721 720 return false; 722 721 … … 725 724 } 726 725 727 if (prop == "opacity" && a Query.browser.msie) {728 ret = a Query.attr(elem.style, "opacity");726 if (prop == "opacity" && as3Query.browser.msie) { 727 ret = as3Query.attr(elem.style, "opacity"); 729 728 return ret == "" ? "1" : ret; 730 729 } … … 803 802 var r:Array = []; 804 803 805 a Query.each( a, function(i:int,arg:Object):void{804 as3Query.each( a, function(i:int,arg:Object):void{ 806 805 if ( !arg ) return; 807 806 … … 860 859 861 860 if ( arg ) 862 if( ! arg.hasOwnProperty(0) )861 if( !(arg is Array) ) 863 862 r.push( arg ); 864 863 else 865 r = a Query.merge( r, aQuery.makeArray( arg ) );864 r = as3Query.merge( r, as3Query.makeArray( arg ) ); 866 865 }); 867 866 … … 870 869 871 870 static public function attr( elem:Object, name:String, value:Object = null ):Object { 871 // special case "id" 872 if( elem is DisplayObject && name == "id" ) 873 if( value != null && value is String ) { 874 Dom.registerId( value.toString(), DisplayObject(elem) ); 875 as3Query.data( elem, "id", value ); 876 return value; 877 } 878 else 879 return as3Query.data( elem, "id" ); 880 881 if( !elem.hasOwnProperty( name ) ) 882 return null; 883 872 884 if( value != null ) 873 885 elem[name] = value; … … 947 959 } 948 960 949 public function appendTo(... args):a Query {961 public function appendTo(... args):as3Query { 950 962 return argCall("append", args); 951 963 } 952 964 953 public function prependTo(... args):a Query {965 public function prependTo(... args):as3Query { 954 966 return argCall("prepend", args); 955 967 } 956 968 957 public function insertBefore(... args):a Query {969 public function insertBefore(... args):as3Query { 958 970 return argCall("before", args); 959 971 } 960 972 961 public function insertAfter(... args):a Query {973 public function insertAfter(... args):as3Query { 962 974 return argCall("after", args); 963 975 } 964 976 965 public function replaceAll(... args):a Query {977 public function replaceAll(... args):as3Query { 966 978 return argCall("replaceWith", args); 967 979 } 968 980 969 private function argCall(n:String, args:Array):a Query981 private function argCall(n:String, args:Array):as3Query 970 982 { 971 983 return each(function():void{ 972 984 for ( var i:int = 0, al:int = args.length; i < al; i++) 973 (a Query.create(args[i]))[n]( this );974 }); 975 } 976 977 public function removeAttr( key:String ):a Query {985 (as3Query.create(args[i]))[n]( this ); 986 }); 987 } 988 989 public function removeAttr( key:String ):as3Query { 978 990 return each( function( a:Object, v:Object = null ):void { 979 991 delete this[ key ]; … … 992 1004 },*/ 993 1005 994 public function remove( a:String = null ):a Query {1006 public function remove( a:String = null ):as3Query { 995 1007 return each( function( ...args ):void { 996 if ( !a || a Query.filter( a, [this] ).r.length ) {997 a Query.removeData( this );1008 if ( !a || as3Query.filter( a, [this] ).r.length ) { 1009 as3Query.removeData( this ); 998 1010 this.parent.removeChild( this ); 999 1011 } … … 1040 1052 1041 1053 // Child Checks 1042 /* "first-child": function(a:DisplayObject,i:int){return a.parentNode.getElementsByTagName('*')[0]==a},1043 "last-child": function(a:DisplayObject,i:int){return aQuery.nth(a.parentNode.lastChild,1,'previousSibling')==a},1044 "only-child": function(a:DisplayObject,i:int){return !aQuery.nth(a.parentNode.lastChild,2,'previousSibling')},1045 */ 1054 "first-child": function(a:DisplayObject, ...args):Boolean{return Dom.firstChild(a.parent)==a}, 1055 "last-child": function(a:DisplayObject, ...args):Boolean{return Dom.lastChild(a.parent)==a}, 1056 "only-child": function(a:DisplayObject, ...args):Boolean{return a.parent.numChildren == 1}, 1057 1046 1058 // Parent Checks 1047 parent: function(a:DisplayObject,i:int, m:Array, r:Array):Boolean{return a is DisplayObjectContainer ? DisplayObjectContainer(a).numChildren != 0 : false}, 1048 empty: function(a:DisplayObject,i:int, m:Array, r:Array):Boolean{return a is DisplayObjectContainer ? DisplayObjectContainer(a).numChildren == 0 : false}, 1059 parent: function(a:DisplayObject,i:int, m:Array, r:Array):Boolean{return !!Dom.firstChild(a)}, 1060 empty: function(a:DisplayObject,i:int, m:Array, r:Array):Boolean{return !Dom.firstChild(a)}, 1061 root: function(a:DisplayObject,i:int, m:Array, r:Array):Boolean{return !a.parent}, 1049 1062 1050 1063 // Text Check … … 1059 1072 disabled: function(a:DisplayObject,i:int){return a.disabled}, 1060 1073 checked: function(a:DisplayObject,i:int){return a.checked}, 1061 selected: function(a:DisplayObject,i:int){return a.selected||a Query.attr(a,'selected')},1074 selected: function(a:DisplayObject,i:int){return a.selected||as3Query.attr(a,'selected')}, 1062 1075 */ 1063 1076 // Form elements … … 1070 1083 image: function(a:DisplayObject,i:int){return 'image'==a.type}, 1071 1084 reset: function(a:DisplayObject,i:int){return 'reset'==a.type}, 1072 button: '"button"==a.type||a Query.nodeName(a,"button")',1085 button: '"button"==a.type||as3Query.nodeName(a,"button")', 1073 1086 input: function(a:DisplayObject,i:int){return (/input|select|textarea|button/i).test(a.nodeName)}, 1074 1087 */ 1075 1088 // :has() 1076 has: function(a:DisplayObject,i:int, m:Array, r:Array):Boolean{return a Query.find(m[3],a).length != 0},1089 has: function(a:DisplayObject,i:int, m:Array, r:Array):Boolean{return as3Query.find(m[3],a).length != 0}, 1077 1090 1078 1091 // :header … … 1080 1093 1081 1094 // :animated 1082 //animated: function(a:DisplayObject,...args):Boolean{return a Query.grep(aQuery.timers,function(fn,...args){return a==fn.elem;}).length}*/1095 //animated: function(a:DisplayObject,...args):Boolean{return as3Query.grep(as3Query.timers,function(fn,...args){return a==fn.elem;}).length}*/ 1083 1096 } 1084 1097 }; … … 1101 1114 while ( expr && expr != old ) { 1102 1115 old = expr; 1103 var f:Object = a Query.filter( expr, elems, not );1116 var f:Object = as3Query.filter( expr, elems, not ); 1104 1117 expr = f.t.replace(/^\s*,\s*/, "" ); 1105 cur = not ? elems = f.r : a Query.merge( cur, f.r );1118 cur = not ? elems = f.r : as3Query.merge( cur, f.r ); 1106 1119 } 1107 1120 … … 1122 1135 last = t; 1123 1136 1124 t = a Query.trim(t);1137 t = as3Query.trim(t); 1125 1138 1126 1139 var foundToken:Boolean = false; … … 1149 1162 if ( (m = re.exec(t)) != null ) { 1150 1163 r = []; 1151 nodeName = m[2] 1164 nodeName = m[2]; 1152 1165 1153 1166 var merge:Dictionary = new Dictionary(); … … 1156 1169 for ( var j:int = 0, rl:int = ret.length; j < rl; j++ ) { 1157 1170 var n:DisplayObject = m1 == "~" || m1 == "+" ? Dom.nextSibling(ret[j]) : Dom.firstChild(ret[j]); 1158 for ( ; n; n = Dom.nextSibling(n) ) 1171 for ( ; n; n = Dom.nextSibling(n) ){ 1159 1172 if ( m1 == "~" && merge[n] ) break; 1160 1161 if (!nodeName || Dom.nodeName (n).toUpperCase() == nodeName.toUpperCase() ) {1173 1174 if (!nodeName || Dom.nodeNameCmp(n, nodeName) ) { 1162 1175 if ( m1 == "~" ) merge[n] = true; 1163 1176 r.push( n ); 1164 1177 } 1165 1178 1166 1179 if ( m1 == "+" ) break; 1180 } 1167 1181 } 1168 1182 … … 1170 1184 1171 1185 // And remove the token 1172 t = a Query.trim( t.replace( re, "" ) );1186 t = as3Query.trim( t.replace( re, "" ) ); 1173 1187 foundToken = true; 1174 1188 } … … 1184 1198 1185 1199 // Merge the result sets 1186 done = a Query.merge( done, ret );1200 done = as3Query.merge( done, ret ); 1187 1201 1188 1202 // Reset the context … … 1213 1227 1214 1228 // Try to do a global search by ID, where we can 1215 if ( m[1] == "#" ) {//&& elem && elem.getElementById && !a Query.isXMLDoc(elem) ) {1229 if ( m[1] == "#" ) {//&& elem && elem.getElementById && !as3Query.isXMLDoc(elem) ) { 1216 1230 throw new Error("not implemented"); 1217 1231 // Optimization for HTML document case … … 1220 1234 // Do a quick check for node name (where applicable) so 1221 1235 // that div#foo searches will be really fast 1222 //ret = r = oid && (!m[3] || a Query.nodeName(oid, m[3])) ? [oid] : [];1236 //ret = r = oid && (!m[3] || as3Query.nodeName(oid, m[3])) ? [oid] : []; 1223 1237 } else { 1224 1238 // We need to find all descendant elements … … 1227 1241 var tag:String = m[1] == "#" && m[3] ? m[3] : m[1] != "" || m[0] == "" ? "*" : m[2]; 1228 1242 1229 r = a Query.merge( r, Dom.getElementsByTagName( tag, ret[i] ));1243 r = as3Query.merge( r, Dom.getElementsByTagName( tag, ret[i] )); 1230 1244 } 1231 1245 1232 1246 // It's faster to filter by class and be done with it 1233 1247 if ( m[1] == "." ) 1234 r = a Query.classFilter( r, m[2] );1248 r = as3Query.classFilter( r, m[2] ); 1235 1249 1236 1250 // Same with ID filtering … … 1259 1273 if ( t ) { 1260 1274 // Attempt to filter it 1261 var val:Object = a Query.filter(t,r);1275 var val:Object = as3Query.filter(t,r); 1262 1276 ret = r = val.r; 1263 t = a Query.trim(val.t);1277 t = as3Query.trim(val.t); 1264 1278 } 1265 1279 } … … 1275 1289 1276 1290 // And combine the results 1277 done = a Query.merge( done, ret );1291 done = as3Query.merge( done, ret ); 1278 1292 1279 1293 return done; … … 1301 1315 last = t; 1302 1316 1303 var p:Object = a Query.parse, m:Array;1317 var p:Object = as3Query.parse, m:Array; 1304 1318 1305 1319 for ( var i:int = 0; p[i]; i++ ) { … … 1321 1335 // keeping it out of the expression list 1322 1336 if ( m[1] == ":" && m[2] == "not" ) 1323 r = a Query.filter(m[3], r, true).r;1337 r = as3Query.filter(m[3], r, true).r; 1324 1338 1325 1339 // We can get a big speed boost by filtering by class here 1326 1340 else if ( m[1] == "." ) 1327 r = a Query.classFilter(r, m[2], not);1341 r = as3Query.classFilter(r, m[2], not); 1328 1342 1329 1343 else if ( m[1] == "[" ) { … … 1332 1346 var rl:int; 1333 1347 for ( i = 0, rl = r.length; i < rl; i++ ) { 1334 var a:Object = r[i], z:Object = a [ aQuery.props[m[2]] || m[2] ];1348 var a:Object = r[i], z:Object = a.hasOwnProperty( m[2] ) ? a[ m[2] ] : null; 1335 1349 1336 1350 if ( z == null || /href|src|selected/.test(m[2]) ) 1337 z = a Query.attr(a,m[2]) || '';1351 z = as3Query.attr(a,m[2]) || ''; 1338 1352 1339 1353 if ( int(type == "" && !!z || … … 1388 1402 // Otherwise, find the expression to execute 1389 1403 } else { 1390 var f:Object = a Query.expr[m[1]];1404 var f:Object = as3Query.expr[m[1]]; 1391 1405 if ( f is Object ) 1392 f = a Query.expr[m[1]][m[2]];1406 f = as3Query.expr[m[1]][m[2]]; 1393 1407 1394 1408 if(f is Function) { … … 1397 1411 1398 1412 // Execute it against the current filter 1399 r = a Query.grep( r, ff, not );1413 r = as3Query.grep( r, ff, not ); 1400 1414 } 1401 1415 } … … 1445 1459 //-------------------------------------------------------------------------- 1446 1460 1447 public function bind( type:String, data:Object, fn:Object = null ):a Query {1461 public function bind( type:String, data:Object, fn:Object = null ):as3Query { 1448 1462 return each(function(... args):void{ 1449 a QueryEvent.add( this, type, (fn || data) as Function, fn && data );1450 }); 1451 } 1452 1453 public function one( type:String, data:Object, fn:Object = null ):a Query {1463 as3QueryEvent.add( this, type, (fn || data) as Function, fn && data ); 1464 }); 1465 } 1466 1467 public function one( type:String, data:Object, fn:Object = null ):as3Query { 1454 1468 return each(function(... args):void { 1455 a QueryEvent.add( this, type, function(event:Event):Object {1456 (a Query.create(this)).unbind(type, arguments.callee);1469 as3QueryEvent.add( this, type, function(event:Event):Object { 1470 (as3Query.create(this)).unbind(type, arguments.callee); 1457 1471 return ((fn || data) as Function).apply( this, arguments); 1458 1472 }, fn && data); … … 1460 1474 } 1461 1475 1462 public function unbind( type:Object = null, fn:Function = null ):a Query {1476 public function unbind( type:Object = null, fn:Function = null ):as3Query { 1463 1477 return each(function(... args):void { 1464 a QueryEvent.remove( this, type, fn );1465 }); 1466 } 1467 1468 public function trigger( type:String, data:Array = null ):a Query {1478 as3QueryEvent.remove( this, type, fn ); 1479 }); 1480 } 1481 1482 public function trigger( type:String, data:Array = null ):as3Query { 1469 1483 return this.each(function(...args):void { 1470 a QueryEvent.trigger( type, data, this );1484 as3QueryEvent.trigger( type, data, this ); 1471 1485 }); 1472 1486 } … … 1474 1488 public function triggerHandler( type:String, data:Array = null, fn:Function = null ):Object { 1475 1489 if ( this[0] ) 1476 return a QueryEvent.trigger( type, data, this[0], false, fn );1490 return as3QueryEvent.trigger( type, data, this[0], false, fn ); 1477 1491 return null; 1478 1492 } … … 1495 1509 */ 1496 1510 1497 public function focusOut ( f:Function = null):aQuery { return eventImpl("focusOut", f);} 1498 public function focusIn ( f:Function = null):aQuery { return eventImpl("focusIn", f);} 1499 public function resize ( f:Function = null):aQuery { return eventImpl("resize", f);} 1500 public function scroll ( f:Function = null):aQuery { return eventImpl("scroll", f);} 1501 public function click ( f:Function = null):aQuery { return eventImpl("click", f);} 1502 public function doubleClick ( f:Function = null):aQuery { return eventImpl("doubleClick", f);} 1503 public function mouseDown ( f:Function = null):aQuery { return eventImpl("mouseDown", f);} 1504 public function mouseUp ( f:Function = null):aQuery { return eventImpl("mouseUp", f);} 1505 public function mouseMove ( f:Function = null):aQuery { return eventImpl("mouseMove", f);} 1506 public function mouseOver ( f:Function = null):aQuery { return eventImpl("mouseOver", f);} 1507 public function mouseOut ( f:Function = null):aQuery { return eventImpl("mouseOut", f);} 1508 public function keyDown ( f:Function = null):aQuery { return eventImpl("keyDown", f);} 1509 public function keyUp ( f:Function = null):aQuery { return eventImpl("keyUp", f);} 1510 public function enterFrame ( f:Function = null):aQuery { return eventImpl("enterFrame", f);} 1511 public function hover(f:Function, g:Function):as3Query { 1512 1513 // A private function for handling mouse 'hovering' 1514 function handleHover(e:Event):Object { 1515 // Check if mouse(over|out) are still within the same parent element 1516 //var p = e.relatedTarget; 1517 1518 // Traverse up the tree 1519 //while ( p && p != this ) try { p = p.parentNode; } catch(e) { p = this; }; 1520 1521 // If we actually just moused on to a sub-element, ignore it 1522 //if ( p == this ) return false; 1523 1524 // Execute the right function 1525 return (e.type == "mouseOver" ? f : g).apply(this, [e]); 1526 } 1527 1528 // Bind the function to the two event listeners 1529 return this.mouseover(handleHover).mouseout(handleHover); 1530 } 1531 1532 public function focusOut ( f:Function = null):as3Query { return eventImpl("focusOut", f);} 1533 public function focusIn ( f:Function = null):as3Query { return eventImpl("focusIn", f);} 1534 public function resize ( f:Function = null):as3Query { return eventImpl("resize", f);} 1535 public function scroll ( f:Function = null):as3Query { return eventImpl("scroll", f);} 1536 public function click ( f:Function = null):as3Query { return eventImpl("click", f);} 1537 public function doubleClick ( f:Function = null):as3Query { return eventImpl("doubleClick", f);} 1538 public function mouseDown ( f:Function = null):as3Query { return eventImpl("mouseDown", f);} 1539 public function mouseUp ( f:Function = null):as3Query { return eventImpl("mouseUp", f);} 1540 public function mouseMove ( f:Function = null):as3Query { return eventImpl("mouseMove", f);} 1541 public function mouseOver ( f:Function = null):as3Query { return eventImpl("mouseOver", f);} 1542 public function mouseOut ( f:Function = null):as3Query { return eventImpl("mouseOut", f);} 1543 public function keyDown ( f:Function = null):as3Query { return eventImpl("keyDown", f);} 1544 public function keyUp ( f:Function = null):as3Query { return eventImpl("keyUp", f);} 1545 public function enterFrame ( f:Function = null):as3Query { return eventImpl("enterFrame", f);} 1511 1546 1512 1547 // jQuery compatible methods 1513 public function focus ( f:Function = null):aQuery { return focusIn(f);} 1514 public function blur ( f:Function = null):aQuery { return focusOut(f);} 1515 public function dblclick ( f:Function = null):aQuery { return doubleClick(f);} 1516 public function mousedown( f:Function = null):aQuery { return mouseDown(f);} 1517 public function mouseup ( f:Function = null):aQuery { return mouseUp(f);} 1518 public function mousemove( f:Function = null):aQuery { return mouseMove(f);} 1519 public function mouseout ( f:Function = null):aQuery { return mouseOut(f);} 1520 public function keydown ( f:Function = null):aQuery { return keyDown(f);} 1521 public function keyup ( f:Function = null):aQuery { return keyUp(f);} 1522 1523 private function eventImpl( type:String, f:Function = null):aQuery { 1548 public function focus ( f:Function = null):as3Query { return focusIn(f);} 1549 public function blur ( f:Function = null):as3Query { return focusOut(f);} 1550 public function dblclick ( f:Function = null):as3Query { return doubleClick(f);} 1551 public function mousedown( f:Function = null):as3Query { return mouseDown(f);} 1552 public function mouseup ( f:Function = null):as3Query { return mouseUp(f);} 1553 public function mousemove( f:Function = null):as3Query { return mouseMove(f);} 1554 public function mouseover( f:Function = null):as3Query { return mouseOver(f);} 1555 public function mouseout ( f:Function = null):as3Query { return mouseOut(f);} 1556 public function keydown ( f:Function = null):as3Query { return keyDown(f);} 1557 public function keyup ( f:Function = null):as3Query { return keyUp(f);} 1558 1559 private function eventImpl( type:String, f:Function = null):as3Query { 1524 1560 return f != null ? bind(type, f) : trigger(type); 1525 1561 } … … 1531 1567 //-------------------------------------------------------------------------- 1532 1568 1533 public function addTween(obj:Object):a Query {1569 public function addTween(obj:Object):as3Query { 1534 1570 var tweener:Class = getDefinitionByName("caurina.transitions.Tweener") as Class; 1535 1571 if(tweener && tweener.addTween is Function) { … … 1539 1575 } 1540 1576 1541 public function show(speed:Number = 0, callback:Function = null):a Query {1577 public function show(speed:Number = 0, callback:Function = null):as3Query { 1542 1578 return speed ? 1543 1579 animate({ … … 1549 1585 } 1550 1586 1551 public function hide(speed:Number = 0, callback:Function = null):a Query {1587 public function hide(speed:Number = 0, callback:Function = null):as3Query { 1552 1588 return speed ? 1553 1589 animate({ … … 1559 1595 } 1560 1596 1561 public function toggle( fn:Object = null, fn2:Object = null ):a Query {1562 //return //a Query.isFunction(fn) && aQuery.isFunction(fn2) ?1597 public function toggle( fn:Object = null, fn2:Object = null ):as3Query { 1598 //return //as3Query.isFunction(fn) && as3Query.isFunction(fn2) ? 1563 1599 //_toggle( fn, fn2 ) : 1564 1600 return fn != null ? … … 1567 1603 }, fn, fn2) : 1568 1604 each(function(...args):void{ 1569 a Query.create(this)[ aQuery.create(this)._is(":hidden") ? "show" : "hide" ]();1605 as3Query.create(this)[ as3Query.create(this)._is(":hidden") ? "show" : "hide" ](); 1570 1606 }); 1571 1607 } 1572 1608 1573 public function slideDown(speed:Object,callback:Object = null):a Query {1609 public function slideDown(speed:Object,callback:Object = null):as3Query { 1574 1610 return animate({height: "show"}, speed, callback); 1575 1611 } 1576 1612 1577 public function slideUp(speed:Object,callback:Object = null):a Query {1613 public function slideUp(speed:Object,callback:Object = null):as3Query { 1578 1614 return animate({height: "hide"}, speed, callback); 1579 1615 } 1580 1616 1581 public function slideToggle(speed:Object, callback:Object = null):a Query {1617 public function slideToggle(speed:Object, callback:Object = null):as3Query { 1582 1618 return animate({height: "toggle"}, speed, callback); 1583 1619 } 1584 1620 1585 public function fadeIn(speed:Object, callback:Object = null):a Query {1621 public function fadeIn(speed:Object, callback:Object = null):as3Query { 1586 1622 return animate({alpha: "show"}, speed, callback); 1587 1623 } 1588 1624 1589 public function fadeOut(speed:Object, callback:Object = null):a Query {1625 public function fadeOut(speed:Object, callback:Object = null):as3Query { 1590 1626 return animate({alpha: "hide"}, speed, callback); 1591 1627 } 1592 1628 1593 public function fadeTo(speed:Object, to:Number, callback:Object = null):a Query {1629 public function fadeTo(speed:Object, to:Number, callback:Object = null):as3Query { 1594 1630 return animate({alpha: to}, speed, callback); 1595 1631 } 1596 1632 1597 public function animate( prop:Object, speed:Object, easing:Object, callback:Function = null ):a Query {1598 var opt:Object = a Query.speed(speed, easing, callback);1633 public function animate( prop:Object, speed:Object, easing:Object, callback:Function = null ):as3Query { 1634 var opt:Object = as3Query.speed(speed, easing, callback); 1599 1635 1600 1636 return this[ opt.queue === false ? "each" : "queue" ](function(... args):Object { 1601 opt = a Query.extend({}, opt);1602 var hidden:Boolean = a Query.create(this)._is(":hidden"), self:DisplayObject = this;1637 opt = as3Query.extend({}, opt); 1638 var hidden:Boolean = as3Query.create(this)._is(":hidden"), self:DisplayObject = this; 1603 1639 1604 1640 for ( var p:String in prop ) { 1605 1641 if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden ) 1606 return a Query.isFunction(opt.complete) && opt.complete.apply(this);1642 return as3Query.isFunction(opt.complete) && opt.complete.apply(this); 1607 1643 1608 1644 if ( p == "height" || p == "width" ) { … … 1612 1648 } 1613 1649 1614 opt.curAnim = a Query.extend({}, prop);1650 opt.curAnim = as3Query.extend({}, prop); 1615 1651 1616 a Query.each( prop, function(name:String, val:Object):void {1617 var e:a QueryFx = new aQueryFx( self, opt, name );1652 as3Query.each( prop, function(name:String, val:Object):void { 1653 var e:as3QueryFx = new as3QueryFx( self, opt, name ); 1618 1654 1619 1655 if ( /toggle|show|hide/.test( val.toString() ) ) … … 1649 1685 } 1650 1686 1651 private function queue(type:Object, fn:Object = null):a Query {1687 private function queue(type:Object, fn:Object = null):as3Query { 1652 1688 if ( !fn ) { 1653 1689 fn = type; … … 1657 1693 return each(function(... args):void { 1658 1694 if ( fn is Array ) 1659 a Query.queue(this, type.toString(), fn as Array);1695 as3Query.queue(this, type.toString(), fn as Array); 1660 1696 else { 1661 a Query.queue(this, type.toString()).push( fn );1697 as3Query.queue(this, type.toString()).push( fn ); 1662 1698 1663 if ( a Query.queue(this, type.toString()).length == 1 )1699 if ( as3Query.queue(this, type.toString()).length == 1 ) 1664 1700 fn.apply(this); 1665 1701 } … … 1667 1703 } 1668 1704 1669 public function stop():a Query {1670 var timers:Array = a Query.timers;1705 public function stop():as3Query { 1706 var timers:Array = as3Query.timers; 1671 1707 1672 1708 return each(function(...args):void { … … 1681 1717 return []; 1682 1718 1683 var q:Array = a Query.data( elem, type + "queue" ) as Array;1719 var q:Array = as3Query.data( elem, type + "queue" ) as Array; 1684 1720 1685 1721 if ( !q || array ) 1686 q = a Query.data( elem, type + "queue",1687 array ? a Query.makeArray(array) : [] ) as Array;1722 q = as3Query.data( elem, type + "queue", 1723 array ? as3Query.makeArray(array) : [] ) as Array; 1688 1724 1689 1725 return q; 1690 1726 } 1691 1727 1692 public function dequeue(type:String = null):a Query {1728 public function dequeue(type:String = null):as3Query { 1693 1729 type = type || "fx"; 1694 1730 1695 1731 return each(function(... args):void{ 1696 var q:Array = a Query.queue(this, type);1732 var q:Array = as3Query.queue(this, type); 1697 1733 1698 1734 q.shift(); … … 1706 1742 var opt:Object = speed && getQualifiedClassName(speed) == "Object" ? speed : { 1707 1743 complete: fn || fn != null && easing || 1708 a Query.isFunction( speed ) && speed,1744 as3Query.isFunction( speed ) && speed, 1709 1745 duration: speed, 1710 1746 easing: fn && easing || easing && !(easing is Function) && easing … … 1717 1753 opt.old = opt.complete; 1718 1754 opt.complete = function():void{ 1719 a Query.create(this).dequeue();1720 if ( a Query.isFunction( opt.old ) )1755 as3Query.create(this).dequeue(); 1756 if ( as3Query.isFunction( opt.old ) ) 1721 1757 opt.old.apply( this ); 1722 1758 }; as3/as3Query/src/com/nitoyon/as3query/as3QueryEvent.as
r186 r196 1 package com.nitoyon.a query {1 package com.nitoyon.as3query { 2 2 import flash.utils.Dictionary; 3 3 import flash.display.DisplayObject; … … 5 5 import flash.events.Event; 6 6 7 internal class a QueryEvent {7 internal class as3QueryEvent { 8 8 static private var triggered:Boolean = false; 9 9 … … 22 22 23 23 // Init the element's event structure 24 var events:Object = a Query.data(element, "events") || aQuery.data(element, "events", {});24 var events:Object = as3Query.data(element, "events") || as3Query.data(element, "events", {}); 25 25 26 26 // Get the current list of functions bound to this event … … 31 31 handlers = events[type] = new Dictionary(); 32 32 33 var handle:Function = a Query.data(element, "handle", function(... args):Object{33 var handle:Function = as3Query.data(element, "handle", function(... args):Object{ 34 34 // returned undefined or false 35 35 var val:Object; 36 36 37 37 // Handle the second event of a trigger 38 if ( a QueryEvent.triggered )38 if ( as3QueryEvent.triggered ) 39 39 return val; 40 40 41 41 var event:Event = args.shift() as Event; 42 val = a QueryEvent.handle(element, event, args);42 val = as3QueryEvent.handle(element, event, args); 43 43 44 44 return val; … … 60 60 // Detach an event or set of events from an element 61 61 static public function remove(element:IEventDispatcher, type:Object, handler:Function = null):void { 62 var events:Object = a Query.data(element, "events"), ret:Object, index:int;62 var events:Object = as3Query.data(element, "events"), ret:Object, index:int; 63 63 64 64 if ( events ) { … … 91 91 if ( !ret ) { 92 92 if (element) 93 element.removeEventListener(typeStr, a Query.data(element, "handle") as Function, false);93 element.removeEventListener(typeStr, as3Query.data(element, "handle") as Function, false); 94 94 ret = null; 95 95 delete events[typeStr]; … … 100 100 for ( ret in events ) break; 101 101 if ( !ret ) { 102 a Query.removeData( element, "events" );103 a Query.removeData( element, "handle" );102 as3Query.removeData( element, "events" ); 103 as3Query.removeData( element, "handle" ); 104 104 } 105 105 } … … 108 108 static public function trigger(type:String, data:Array, element:IEventDispatcher, donative:Boolean = true, extra:Function = null):Object { 109 109 // Clone the incoming data, if any 110 data = a Query.makeArray(data || []);110 data = as3Query.makeArray(data || []); 111 111 var val:Object; 112 112 … … 115 115 // Only trigger if we've ever bound an event for it 116 116 if ( global[type] ) 117 a Query.create("*").add([aQuery.stage]).trigger(type, data);117 as3Query.create("*").add([as3Query.stage]).trigger(type, data); 118 118 119 119 // Handle triggering a single element … … 128 128 129 129 // Trigger the event 130 if ( a Query.isFunction( aQuery.data(element, "handle") ) )131 val = (a Query.data(element, "handle") as Function).apply( element, data );130 if ( as3Query.isFunction( as3Query.data(element, "handle") ) ) 131 val = (as3Query.data(element, "handle") as Function).apply( element, data ); 132 132 133 133 // Extra functions don't get the custom event object … … 156 156 var type:String = event.type; 157 157 158 var c:Dictionary = (a Query.data(element, "events") && aQuery.data(element, "events")[type]) as Dictionary;158 var c:Dictionary = (as3Query.data(element, "events") && as3Query.data(element, "events")[type]) as Dictionary; 159 159 args.unshift( event ); 160 160 as3/as3Query/src/com/nitoyon/as3query/as3QueryFx.as
r186 r196 1 package com.nitoyon.a query {1 package com.nitoyon.as3query { 2 2 3 3 import flash.display.DisplayObject; … … 5 5 import flash.utils.clearInterval; 6 6 7 public class a QueryFx {7 public class as3QueryFx { 8 8 public var options:Object; 9 9 public var elem:DisplayObject; … … 18 18 19 19 20 public function a QueryFx(_elem:DisplayObject, _options:Object, _prop:String) {20 public function as3QueryFx(_elem:DisplayObject, _options:Object, _prop:String) { 21 21 options = _options; 22 22 elem = _elem; … … 33 33 options.step.apply( elem, [ now, this ] ); 34 34 35 //(a QueryFx.step[prop] || aQueryFx.step._default)( this );35 //(as3QueryFx.step[prop] || as3QueryFx.step._default)( this ); 36 36 elem[prop] = now; 37 37 … … 47 47 48 48 return 0; 49 //var r = parseFloat(a Query.curCSS(this.elem, this.prop, force));50 //return r && r > -10000 ? r : parseFloat(a Query.css(this.elem, this.prop)) || 0;49 //var r = parseFloat(as3Query.curCSS(this.elem, this.prop, force)); 50 //return r && r > -10000 ? r : parseFloat(as3Query.css(this.elem, this.prop)) || 0; 51 51 } 52 52 … … 61 61 update(); 62 62 63 var self:a QueryFx = this;63 var self:as3QueryFx = this; 64 64 function t():Boolean { 65 65 return self.step(); 66 66 } 67 67 68 a Query.timers.push(t);68 as3Query.timers.push(t); 69 69 70 if ( a Query.timers.length == 1 ) {70 if ( as3Query.timers.length == 1 ) { 71 71 var timer:uint = setInterval(function():void{ 72 var timers:Array = a Query.timers;72 var timers:Array = as3Query.timers; 73 73 74 74 for ( var i:int = 0; i < timers.length; i++ ) … … 85 85 public function show(...args):void { 86 86 // Remember where we started, so that we can go back to it later 87 this.options.orig[this.prop] = a Query.attr( this.elem, this.prop );87 this.options.orig[this.prop] = as3Query.attr( this.elem, this.prop ); 88 88 this.options.show = true; 89 89 … … 97 97 98 98 // Start by showing the element 99 a Query.create(elem).show();99 as3Query.create(elem).show(); 100 100 } 101 101 … … 103 103 public function hide(...args):void { 104 104 // Remember where we started, so that we can go back to it later 105 this.options.orig[this.prop] = a Query.attr( this.elem, this.prop );105 this.options.orig[this.prop] = as3Query.attr( this.elem, this.prop ); 106 106 this.options.hide = true; 107 107 … … 139 139 if ( this.options.hide || this.options.show ) 140 140 for ( var p:String in this.options.curAnim ) 141 a Query.attr(this.elem, p, this.options.orig[p]);141 as3Query.attr(this.elem, p, this.options.orig[p]); 142 142 } 143 143 144 144 // If a callback was provided, execute it 145 if ( done && a Query.isFunction( this.options.complete ) )145 if ( done && as3Query.isFunction( this.options.complete ) ) 146 146 // Execute the complete function 147 147 this.options.complete.apply( this.elem ); … … 153 153 154 154 // Perform the easing function, defaults to swing 155 this.pos = a Query.easing[this.options.easing || (aQuery.easing.swing ? "swing" : "linear")](n, 0, 1, this.options.duration);155 this.pos = as3Query.easing[this.options.easing || (as3Query.easing.swing ? "swing" : "linear")](n, 0, 1, this.options.duration); 156 156 this.now = this.start + ((this.end - this.start) * this.pos); 157 157

