$(document).ready(function() {
$( '#cancel_delete' ).live ( 'click', function(event){
event.preventDefault();
$( this ).parent().slideUp( 'fast' );
});
// Remove surrounding [ ] from 'mod' links
$( '.creator_content span.mod' ) .each (
function (i)
{
$( this ) .html ( $( this ) .html () .replace ( '[', '' ) .replace ( ']', '' ) );
});
// Create a holder for AJAX stuff
//$( '.creator_content .align_left small br:first' ) .after ( '' );
//$( '.creator_content .align_left small span.loader' ) .hide();
// Overwrite links, add images
var index = 1;
var ajax_inprogress = false;
var ajax_lasturl = '';
var last_html = null;
$( '.creator_content span.mod a' )
.each (
function (i)
{
if ( last_html == '+' && $( this ) .html() == 'E' ) index++;
$( this ) .attr ( 'rel', index -1 );
if ( $( this ) .html() == '-' ) index++;
last_html = $( this ) .html ();
$( this )
.html(
(
$( this ) .html() == '+' ? ''
:
(
$( this ) .html() == '-' ? ''
: ''
)
)
//+ 'r('+index+') '
);
})
.click (
function ( e, url )
{
e .preventDefault ();
if ( ajax_inprogress ) return;
var link = $( this );
var href = ( url != undefined ? url : decodeURI ( $( this ) .attr ( 'href' ) ) );
if ( ajax_lasturl == href ) return;
if ( $( '.creator_content .align_left small span.loader' ) .length )
{
// Remove ajax holder
$( '.creator_content .align_left small span.loader' ) .slideUp ( 'fast', function(){$(this).remove(); link.trigger('click', [url])} );
}
else
{
// Move ajax holder
$( '.creator_content .align_left small br:eq('+ $( this ) .attr ( 'rel' ) +')' ) .after ( '' );
$( '.creator_content .align_left small span.loader' ) .hide();
// Add a loader gif, expand
$( '.creator_content .align_left small span.loader' ) .html ( '' ) .slideDown ();
// Get content
ajax_inprogress = true;
$.ajax({
type: "POST",
url: href,
data: "__ajax=1",
//cache: false,
complete: function()
{
ajax_inprogress=false;
},
success: function(html)
{
ajax_lasturl = href;
$( '.creator_content .align_left small span.loader' ) .slideUp ( 'fast',
function()
{
$( this ) .html ( html ) .slideDown ();
if ( url == undefined )
{
$( '.creator_content .align_left small span.loader a' )
.click (
function ( e )
{
if ( $( this ).hasClass ( 'no_ajax' ) )
{
return true;
}
e .preventDefault ();
link .trigger ( 'click', [ $( this ) .attr ( 'href' ) ] );
});
$( '.creator_content .align_left small span.loader button' ).live( 'click', function( e ){
e .preventDefault ();
link .trigger ( 'click', [ $( this ) .attr ( 'rel' ) ] );
}
);
}
});
}
});
}
});
// Preview box
//$( 'span.preview_link' ) .css ( { display: "none" } );
/*$( '.content_holder .creator_content .preview .preview_middle .preview_content_holder' ) .html ( '' );
$.ajax({
type: "GET",
dataType: "xml",
url: $( 'span.preview_link a' ) .attr ( 'href' ),
cache: false,
success: function(html)
{
$( '.content_holder .creator_content .preview .preview_middle .preview_content_holder' ) .html ( html );
}
});*/
$( '.content_holder .creator_content .preview' ) .css ( { display: 'block' } );
if ( jQuery .trim ( $( '.content_holder .creator_content .preview .preview_middle .preview_content_holder' ) .html() ) == '' )
{
$( '.content_holder .creator_content .preview .preview_middle .preview_content_holder' ) .html ( '' );
$( '.content_holder .creator_content .preview .preview_middle .preview_content_holder iframe' ) .load (
function ()
{
/* $( '.content_holder .creator_content .preview .preview_middle .i_title' )
.html ( window.preview.document.title ); */
});
}
// URL box
$( '.content_holder .creator_content .preview .preview_middle input' )
.click (
function (e)
{
$( this ) .select ();
})
.blur (
function ()
{
this .value = this .defaultValue;
});
});