# HG changeset patch # User Dan # Date 1240188638 14400 # Node ID 6eab82abc95264bf1217ee9c6bba809c8ddb9c19 # Parent 18db38c70a411c1d05188df49c2042e1c8aa33a6 Fixed sidebar editor not closing floating windows properly when FX off diff -r 18db38c70a41 -r 6eab82abc952 includes/clientside/sbedit.js --- a/includes/clientside/sbedit.js Sun Apr 19 19:13:41 2009 -0400 +++ b/includes/clientside/sbedit.js Sun Apr 19 20:50:38 2009 -0400 @@ -52,29 +52,32 @@ .css('height', $(parent).height()) .css('top', offset.top) .css('left', offset.left) - .appendTo('body') + .appendTo('body'); + var item_id = parseInt($(parent).attr('id').replace(/^block:/, '')); + + $(box) .animate({ width: 500, height: 400, top: top, left: (getWidth() / 2) - 250 }, 400, function() { var whitey = whiteOutElement(this); - $(this).append(''); + $(this).append(''); $(this).append('

' + $lang.get('etc_save_changes') + ' | ' + $lang.get('etc_cancel') + '

'); - $.get(makeUrlNS('Special', 'EditSidebar', 'action=getsource&noheaders&id=' + this.item_id), {}, function(response, statustext) + $.get(makeUrlNS('Special', 'EditSidebar', 'action=getsource&noheaders&id=' + item_id), {}, function(response, statustext) { - $('textarea', box).attr('value', response); + $('textarea', box).val(response); $(whitey).remove(); + + $(box).attr('enano:item_id', item_id); }, 'html'); }) .get(0); - box.parentdiv = parent; - box.item_id = parseInt($(parent).attr('id').replace(/^block:/, '')); } function sbedit_edit_save(a) { var box = a.parentNode.parentNode; - var parent = box.parentdiv; + var parent = document.getElementById('block:' + $(box).attr('enano:item_id')); var whitey = whiteOutElement(box); - $.post(makeUrlNS('Special', 'EditSidebar', 'noheaders&action=save&id=' + box.item_id), { content: $('textarea', box).attr('value') }, function(response, statustext) + $.post(makeUrlNS('Special', 'EditSidebar', 'noheaders&action=save&id=' + $(box).attr('enano:item_id')), { content: $('textarea', box).attr('value') }, function(response, statustext) { whiteOutReportSuccess(whitey); setTimeout(function() @@ -87,13 +90,25 @@ function sbedit_edit_cancel(a) { var box = a.parentNode.parentNode; - var parent = box.parentdiv; + var parent = document.getElementById('block:' + $(box).attr('enano:item_id')); sbedit_close_editor(parent, box); } function sbedit_close_editor(parent, box) { + if ( !parent ) + { + console.warn('Failed to get DOM object for parent, skipping transition effect'); + } + + if ( jQuery.fx.off || !parent ) + { + enlighten(true, 'sbedit-shade'); + $('body').get(0).removeChild(box); + return true; + } + var offset = $(parent).offset(); $(box).empty().animate( {