diff --git a/js/hookLiveEdit.js b/js/hookLiveEdit.js
index 24ee445db..5d249070b 100644
--- a/js/hookLiveEdit.js
+++ b/js/hookLiveEdit.js
@@ -1,3 +1,4 @@
+var has_been_moved = false;
var modules_list = new Array();
var hooks_list = new Array();
var hookable_list = new Array();
@@ -33,28 +34,38 @@ $(document).ready(function() {
});
// populate
getHookableList();
- $('.unregisterHook').unbind('click').click(function() {
+ $('.unregisterHook').unbind('click').click(function()
+ {
id = $(this).attr('id');
$(this).parent().parent().parent().fadeOut('slow', function() {
$(this).remove();
});
return false;
});
- $('#cancelMove').unbind('click').click(function() {
+ $('#cancelMove').unbind('click').click(function()
+ {
$('#' + cancelMove + '').sortable('cancel');
return false;
});
- $('#saveLiveEdit').unbind('click').click(function() {
+ $('#saveLiveEdit').unbind('click').click(function()
+ {
saveModulePosition();
return false;
});
- $('#closeLiveEdit').unbind('click').click(function() {
- $("#live_edit_feedback_str").html('
');
- $("#fancy").attr('href', '#live_edit_feedback');
- $("#fancy").trigger("click");
- return false;
+ $('#closeLiveEdit').unbind('click').click(function()
+ {
+ if (!has_been_moved)
+ closeLiveEdit();
+ else
+ {
+ $("#live_edit_feedback_str").html('');
+ $("#fancy").attr('href', '#live_edit_feedback');
+ $("#fancy").trigger("click");
+ }
+ return false;
});
- $('.add_module_live_edit').unbind('click').click(function() {
+ $('.add_module_live_edit').unbind('click').click(function()
+ {
$("#live_edit_feedback_str").html('');
$("#fancy").attr('href', '#live_edit_feedback');
$("#fancy").trigger("click");
@@ -75,6 +86,7 @@ $(document).ready(function() {
if (new_target_id == '') {
new_target_id = event.target.id;
}
+ has_been_moved = true;
},
start: function(event, ui) {
new_target_id = ui.item[0].parentNode.id;
@@ -179,7 +191,8 @@ function getHookableModuleList(hook) {
}
});
}
-function saveModulePosition() {
+function saveModulePosition()
+{
$("input.dynamic-input-save-position").remove();
$("#live_edit_feedback_str").html('');
$("#fancy").attr('href', '#live_edit_feedback');
@@ -207,6 +220,7 @@ function saveModulePosition() {
success: function(jsonData) {
$('#live_edit_feedback_str').html('');
timer = setTimeout("hideFeedback()", 3000);
+ has_been_moved = false;
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
$('#live_edit_feedback_str').html('');
@@ -216,22 +230,26 @@ function saveModulePosition() {
return true;
}
-function closeFancybox() {
+function closeFancybox()
+{
clearTimeout(timer);
$.fancybox.close();
$('#live_edit_feedback_str').html('');
}
-function closeLiveEdit(){
+function closeLiveEdit()
+{
window.location.href = window.location.protocol+'//'+window.location.host+window.location.pathname;
}
-function hideFeedback() {
+function hideFeedback()
+{
$('#live_edit_feed_back').fadeOut('slow', function() {
$.fancybox.close();
$('#live_edit_feedback_str').html('');
});
};
-function get(name) {
+function get(name)
+{
var regexS = "[\\?&]" + name + "=([^]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.href);