B2:
Please not the snippet below which sets styles to change in reaction to a user action -> i.e. blur, focus, keypress.
It is self contained…just give it an array of element ids and it sets the styles to change on certain events.
What module should I place this in Model, View, or Controller?
function styleTwitter1( pair_array )
{
var i;
var input;
var label;
for ( i = 0; i < pair_array.length; i+=2 )
{
input = document.getElementById( pair_array[ i ] );
label = document.getElementById( pair_array[ i + 1 ] );
label.style.fontSize = window.getComputedStyle( label, null ).getPropertyValue("font-size");
closureBuster( input, label );
}
function closureBuster( input, label )
{
input.addEventListener( "keypress", function()
{
label.style.opacity = 0;
}, false );
input.addEventListener( "focus", function()
{
if( input.value === '' )
{
label.style.opacity = 0.2;
input.style.border = '1px solid #888888';
}
} , false );
input.addEventListener( "blur", function()
{
if( input.value === '' )
{
label.style.opacity = 1;
new EffectsFont( label ).fade( 'up', 150 );
input.style.border = '1px solid #dddddd';
}
} , false );
}
}
In MVC the view:
So everything that the user sees (rendering, styling, …) and interacts with, should go to the view.