2011-08-17 03:14:30 +00:00
// Adding jQuery ui stuff
$ ( document ) . ready ( function ( ) {
var $confirm = $ ( '<div id="dialog-confirm"></div>' )
. html ( '<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>This image will be permanently deleted and cannot be recovered. Are you sure?</p>' )
. dialog ( {
resizable : false ,
height : 220 ,
modal : true ,
autoOpen : false ,
title : 'Delete Image?' ,
buttons : {
"Delete Image" : function ( ) {
$ ( this ) . dialog ( "close" ) ;
$ ( 'form#delete_image' ) . submit ( ) ;
} ,
Cancel : function ( ) {
$ ( this ) . dialog ( "close" ) ;
}
}
} ) ;
$ ( 'form#delete_image #delete_image_submit' ) . click ( function ( e ) {
e . preventDefault ( ) ;
$confirm . dialog ( 'open' ) ;
} ) ;
2011-12-31 14:12:05 +00:00
$ ( "time" ) . timeago ( ) ;
2011-08-17 03:14:30 +00:00
2012-02-09 14:45:18 +00:00
$ ( '.autocomplete_tags' ) . autocomplete ( base _href + '/api/internal/tag_list/complete' , {
2012-02-07 11:33:42 +00:00
width : 320 ,
max : 15 ,
highlight : false ,
multiple : true ,
multipleSeparator : ' ' ,
scroll : true ,
scrollHeight : 300 ,
selectFirst : false
} ) ;
2007-05-08 21:18:31 +00:00
2012-02-11 01:48:07 +00:00
$ ( "TABLE.sortable" ) . tablesorter ( ) ;
2012-02-22 13:49:57 +00:00
$ ( ".comment_link" ) . each ( function ( idx , elm ) {
2012-02-22 14:14:40 +00:00
var target _id = $ ( elm ) . text ( ) . match ( /#c?(\d+)/ ) ;
if ( target _id && $ ( "#c" + target _id [ 1 ] ) ) {
var target _name = $ ( "#c" + target _id [ 1 ] + " .username" ) . html ( ) ;
2012-02-22 15:13:05 +00:00
if ( target _name ) {
$ ( elm ) . attr ( "href" , "#c" + target _id [ 1 ] ) ;
$ ( elm ) . html ( "@" + target _name ) ;
}
2012-02-22 13:49:57 +00:00
}
} ) ;
2012-03-02 23:57:27 +00:00
2012-03-12 18:04:46 +00:00
try {
var sidebar _hidden = ( $ . cookie ( "sidebar-hidden" ) || "" ) . split ( "|" ) ;
for ( var i in sidebar _hidden ) {
if ( sidebar _hidden [ i ] . length > 0 ) {
$ ( sidebar _hidden [ i ] + " .blockbody" ) . hide ( ) ;
}
} ;
}
catch ( err ) {
var sidebar _hidden = [ ] ;
}
2012-03-02 23:57:27 +00:00
$ ( ".shm-toggler" ) . each ( function ( idx , elm ) {
2012-03-12 02:50:41 +00:00
var tid = $ ( elm ) . data ( "toggle-sel" ) ;
var tob = $ ( tid + " .blockbody" ) ;
2012-03-02 23:57:27 +00:00
$ ( elm ) . click ( function ( e ) {
tob . slideToggle ( "slow" ) ;
if ( sidebar _hidden . indexOf ( tid ) == - 1 ) {
sidebar _hidden . push ( tid ) ;
}
else {
for ( var i in sidebar _hidden ) {
if ( sidebar _hidden [ i ] === tid ) {
sidebar _hidden . splice ( i , 1 ) ;
}
}
}
$ . cookie ( "sidebar-hidden" , sidebar _hidden . join ( "|" ) , { path : '/' } ) ;
} )
} ) ;
2012-03-10 18:50:10 +00:00
$ ( ".shm-unlocker" ) . each ( function ( idx , elm ) {
2012-03-11 15:49:25 +00:00
var tid = $ ( elm ) . data ( "unlock-sel" ) ;
var tob = $ ( tid ) ;
2012-03-10 18:50:10 +00:00
$ ( elm ) . click ( function ( e ) {
$ ( elm ) . attr ( "disabled" , true ) ;
tob . attr ( "disabled" , false ) ;
} ) ;
} ) ;
2012-03-02 23:57:27 +00:00
if ( document . location . hash . length > 3 ) {
query = document . location . hash . substring ( 1 ) ;
a = document . getElementById ( "prevlink" ) ;
a . href = a . href + '?' + query ;
a = document . getElementById ( "nextlink" ) ;
a . href = a . href + '?' + query ;
}
2012-02-07 11:33:42 +00:00
} ) ;
2007-05-08 21:18:31 +00:00
/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \
* LibShish - JS *
\ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
2007-04-16 11:58:25 +00:00
function addEvent ( obj , event , func , capture ) {
if ( obj . addEventListener ) {
obj . addEventListener ( event , func , capture ) ;
} else if ( obj . attachEvent ) {
obj . attachEvent ( "on" + event , func ) ;
}
}
function byId ( id ) {
return document . getElementById ( id ) ;
}
2012-02-07 15:15:18 +00:00
// used once in ext/setup/main
2007-04-16 11:58:25 +00:00
function getHTTPObject ( ) {
if ( window . XMLHttpRequest ) {
return new XMLHttpRequest ( ) ;
}
else if ( window . ActiveXObject ) {
return new ActiveXObject ( "Microsoft.XMLHTTP" ) ;
}
}
/* get, set, and delete cookies */
function getCookie ( name ) {
var start = document . cookie . indexOf ( name + "=" ) ;
var len = start + name . length + 1 ;
if ( ( ! start ) && ( name != document . cookie . substring ( 0 , name . length ) ) ) {
return null ;
}
if ( start == - 1 ) return null ;
var end = document . cookie . indexOf ( ";" , len ) ;
if ( end == - 1 ) end = document . cookie . length ;
return unescape ( document . cookie . substring ( len , end ) ) ;
}
function setCookie ( name , value , expires , path , domain , secure ) {
var today = new Date ( ) ;
today . setTime ( today . getTime ( ) ) ;
if ( expires ) {
expires = expires * 1000 * 60 * 60 * 24 ;
}
var expires _date = new Date ( today . getTime ( ) + ( expires ) ) ;
document . cookie = name + "=" + escape ( value ) +
( ( expires ) ? ";expires=" + expires _date . toGMTString ( ) : "" ) + //expires.toGMTString()
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" ) ;
}
function deleteCookie ( name , path , domain ) {
if ( getCookie ( name ) ) document . cookie = name + "=" +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT" ;
}
2012-02-06 14:41:36 +00:00
function replyTo ( imageId , commentId ) {
var box = $ ( "#comment_on_" + imageId ) ;
2012-02-22 13:07:04 +00:00
var text = ">>" + imageId + "#c" + commentId + ": " ;
2012-02-06 14:41:36 +00:00
box . focus ( ) ;
box . val ( box . val ( ) + text ) ;
2012-02-22 14:14:40 +00:00
$ ( "#c" + commentId ) . parent ( ) . effect ( "highlight" , { } , 5000 ) ;
2012-02-06 14:41:36 +00:00
}