From 7b359751399db190bd746a6a2bef83c01e43cf69 Mon Sep 17 00:00:00 2001 From: vAugagneur Date: Thu, 14 Jun 2012 13:19:23 +0000 Subject: [PATCH] [-] FO : fixed bug #PSCFV-2760 - live edit close confirm git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@16020 b9a71923-0436-4b27-9f14-aed3839534dd --- js/hookLiveEdit.js | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) 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('

' + confirmClose + '

' + confirm + '' + cancel + '

'); - $("#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('

' + confirmClose + '

' + confirm + '' + cancel + '

'); + $("#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('

' + saveOK + '

' + close + '
'); timer = setTimeout("hideFeedback()", 3000); + has_been_moved = false; }, error: function(XMLHttpRequest, textStatus, errorThrown) { $('#live_edit_feedback_str').html('

TECHNICAL ERROR:

' + unableToSaveModulePosition + '

' + close + '
'); @@ -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);