rectest/scripts/ColorTestCase.js

74 lines
1.6 KiB
JavaScript

rectest.ColorTestCase = Class( 'ColorTestCase' )
.implement( rectest.TestCase )
.extend(
{
'private static _sets': [
[ 'red', 'blue', 'green', 'yellow' ],
[ 'white', 'orange', 'black' ],
[ 'purple', 'brown', 'gray' ]
],
// Tango icon theme
'private static _cmap': {
black: '#2e3436',
blue: '#204a87',
brown: '#8f5902',
gray: '#babdb6',
green: '#73d216',
orange: '#f57900',
purple: '#75507b',
red: '#cc0000',
white: '#ffffff',
yellow: '#edd400'
},
/**
* 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',
this.__self.$( '_cmap' )[ id ] || id
);
}
} );
// TODO: move
rectest.cases.colors = {
title: 'Colors',
testCase: rectest.ColorTestCase
};