function swickiUI_init() //onload...
{
if( $('sr') ) //are there results? if not, no vote- or moderator- tools
{
var pos_li, pos_a, elems = new Array()
//pos_li = pos_li.concat( $('sr').getElementsByTagName("li"), $('sr').getElementsByTagName("a") );
pos_li = $('sr').getElementsByTagName("li");
pos_a = $('sr').getElementsByTagName("a");
for(i=0;i<pos_li.length;i++){ elems.push( pos_li[i] ); }
for(i=0;i<pos_a.length;i++){ elems.push( pos_a[i] ); }
var collectTemp = []; //for like/dislike
for (var i =0; i < elems.length; i++)
{
if( elems[i].className.match(/(([vV]ote[d]{0,1})|likeSite|viewcomments_links)/) )
{
collectTemp[collectTemp.length]=elems[i];
}
}
for (i=0; i<collectTemp.length; i++){
switch (collectTemp[i].className)
{
/* user vote tools */
case 'votedDown':
collectTemp[i].voteActive = false;
collectTemp[i].onclick = createVoter(-1);
break;
case 'voteDown':
collectTemp[i].voteActive = true;
collectTemp[i].onclick = createVoter(-1);
break;
case 'votedUp':
collectTemp[i].voteActive = false;
collectTemp[i].onclick = createVoter(1);
break;
case 'voteUp':
collectTemp[i].voteActive = true;
collectTemp[i].onclick = createVoter(1);
break;
/* moderator options... */
case 'dislikeSiteDP':
collectTemp[i].onclick = createModerator('dp');
break;
case 'dislikeSiteDS':
collectTemp[i].onclick = createModerator('ds');
break;
case 'likeSitePP':
//we now use listSitePP instead of listSiteTPP. The operation passed through to the resultaction call is still tpp, so don't change that!
collectTemp[i].onclick = createModerator('tpp');
break;
case 'likeSitePS':
collectTemp[i].onclick = createModerator('ps');
break;
/* comment on results */
case 'viewcomments_links':
viewcomments( collectTemp[i].id );
break;
default:
//collectTemp[i].onclick = function(){ return false; }
break;
}
}
elems=null; pos_li=null; pos_a=null;
}
// default alt to title or visa versa for images with one but not both...
var i = document.images;
for ( i_idx=0;i_idx<i.length; i_idx++){ i_img=i[i_idx];((i_img.title && !i_img.alt) || ( i_img.alt && !i_img.title)) ? ( !i_img.alt ? i_img.alt=!i_img.title : i_img.title=i_img.alt ) : {};}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
if(typeof(rowc)!='undefined' && rowc>=1 )
{
attach = function( target, subt )
{
target.subt = subt;
addEvent( target, 'mouseover',
function(e)
{
if ( this.subt.className!='swickiModeratorTools_hover')
{
this.subt.className='swickiModeratorTools_hover';
// this.auto_out = setTimeout("$('"+this.subt.id+"').className='swickiModeratorTools'", 700);
}
}
);
/*
addEvent( subt, 'mouseover',
function(e)
{
clearTimeout( this.auto_out );
}
);
*/
addEvent( subt, 'mouseout',
function(e)
{
if( checkMouseLeave( subt , e) )
{
// clearTimeout( this.auto_out );
if ( this.className=='swickiModeratorTools_hover')
{
this.className='swickiModeratorTools';
}
}
}
);
}
var target=null;
for(var i=1;i<=rowc;i++)
{
target=$('row'+i.toString());
if(!target)
{
break;
}
addEvent( target, 'mouseover',
function()
{
if( !this.className.match(/activeRow_hover/) )
{
this.className=this.className.replace(/activeRow/,'activeRow_hover');
}
}
);
addEvent( target, 'mouseout',
function(e)
{
if( this.className.toString().match(/activeRow_hover/) )
{
this.className=this.className.toString().replace(/activeRow_hover/,'activeRow');
}
}
);
if ( tool = $('voteButtons'+ i.toString()) )
{
tool.className = tool.className.replace(/votehidden/, '');
}
}
}
brow = new BrowserHacks();
ui = new swickiUI();
// getContainer();
ui.registerHandlers( swicki_ui_onload_handlers ); // others are attached as each form is loaded
/* check if coming from questions page to write an answer */
if(window.location.search.match(/post=1/)) {
ui.displayForm('swicki_ui_form_post_container');
}
// specify initial focus if any for each form...
ui.focus =
{
'swicki_ui_form_signup_container' : function(){ $('swicki_ui_signup_username').focus(); },
'swicki_ui_form_login_container' : function(){ $('swicki_ui_login_email').focus(); },
'swicki_ui_form_post_container' : function(){ $('swicki_ui_post_title').focus(); },
'swicki_ui_form_message_container' : function(){ $('swicki_ui_message_button_ok').focus(); },
'swicki_ui_form_comment_container' : function(){ $('swicki_ui_comment_text').focus(); }
}
} // swickiUI_init();
_init.push( swickiUI_init );
Partager