From 2377c265f938f4493450fc78d1a064d7b8929dce Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Mon, 10 Nov 2008 14:00:43 +0000 Subject: [PATCH] - LSview : Utilisation de LSconfirmBox pour la confirmation de suppression. --- trunk/includes/js/LSview.js | 48 ++++++++++++++++++++++++++++++++ trunk/templates/default/view.tpl | 2 +- trunk/view.php | 5 ++++ 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/trunk/includes/js/LSview.js b/trunk/includes/js/LSview.js index 242ca750..cca01d14 100644 --- a/trunk/includes/js/LSview.js +++ b/trunk/includes/js/LSview.js @@ -9,6 +9,18 @@ var LSview = new Class({ $$('td.LSobject-list-names').each(function(el) { el.addEvent('mouseleave',this.onTdLSobjectListNamesOut.bind(this,el)); }, this); + $$('a.LSobject-list-actions').each(function(el) { + var checkRemove = /remove\.php.*/; + if (checkRemove.exec(el.href)) { + el.addEvent('click',this.onRemoveListBtnClick.bindWithEvent(this,el)); + } + }, this); + $$('a.LSview-actions').each(function(el) { + var checkRemove = /remove\.php.*/; + if (checkRemove.exec(el.href)) { + el.addEvent('click',this.onRemoveViewBtnClick.bindWithEvent(this,el)); + } + }, this); }, onTdLSobjectListNamesClick: function(td) { @@ -23,6 +35,42 @@ var LSview = new Class({ onTdLSobjectListNamesOut: function(td) { td.imgEdit.destroy(); + }, + + onRemoveListBtnClick: function(event,a) { + Event(event).stop(); + if (!this._confirmBoxOpen) { + this._confirmBoxOpen = 1; + var name = a.getParent().getPrevious('td').getElement('a').innerHTML; + this.confirmBox = new LSconfirmBox({ + text: 'Etês-vous sur de vouloir supprimer "'+name+'" ?', + startElement: a, + onConfirm: this.removeFromA.bind(this,a), + onClose: this.onConfirmBoxClose.bind(this) + }); + } + }, + + onRemoveViewBtnClick: function(event,a) { + Event(event).stop(); + if (!this._confirmBoxOpen) { + this._confirmBoxOpen = 1; + var name = $('LSview_title').innerHTML; + this.confirmBox = new LSconfirmBox({ + text: 'Etês-vous sur de vouloir supprimer "'+name+'" ?', + startElement: a, + onConfirm: this.removeFromA.bind(this,a), + onClose: this.onConfirmBoxClose.bind(this) + }); + } + }, + + onConfirmBoxClose: function() { + this._confirmBoxOpen = 0; + }, + + removeFromA: function(a) { + document.location = a.href+'&valid'; } }); diff --git a/trunk/templates/default/view.tpl b/trunk/templates/default/view.tpl index b2437fe8..de06885e 100644 --- a/trunk/templates/default/view.tpl +++ b/trunk/templates/default/view.tpl @@ -1,5 +1,5 @@ {include file='top.tpl'} - {if $pagetitle != ''}

{$pagetitle}

{/if} + {if $pagetitle != ''}

{$pagetitle}

{/if} {if $LSview_actions != ''}