rectest/scripts/ColorTestCase.js

58 lines
1.2 KiB
JavaScript

rectest.ColorTestCase = Class( 'ColorTestCase' )
.implement( rectest.TestCase )
.extend(
{
'private static _sets': [
[ 'red', 'blue', 'green', 'yellow' ],
[ 'white', 'orange', 'black' ],
[ 'purple', 'brown', 'gray' ]
],
/**
* Element to contain color
* @var {jQuery}
*/
'private _$color': null,
'public getSet': function( set_id )
{
var retset = [],
i = set_id;
// generate a set that fits the requested level of complexity by
// progressively combining each set, starting with the requested set
do
{
var set = this.__self.$( '_sets' )[ i ],
j = set.length;
while ( j-- )
{
retset.push( set[ j ] );
}
} while ( i-- )
return retset;
},
'public initRender': function( $element )
{
$element.append( this._$color = $( '<div>' )
.addClass( 'color-display' )
);
},
'public render': function( id, $element )
{
this._$color.css( 'background-color', id );
}
} );
// TODO: move
rectest.cases.colors = {
title: 'Colors',
testCase: rectest.ColorTestCase
};