Wiki source code of Confirmation Box UI Component

Version 12.1 by Jerome on 2009/10/09

Hide last authors
Jerome 1.1 1 {{toc start=2 /}}
2
Jerome 4.1 3 The Confirmation Box UI is an alternative to the old-fashioned browsers confirm boxes. It displays a nice popup box asking the user to confirm an action. Functions hooks are available on both confirm and cancel actions.
Jerome 1.1 4
Jerome 11.1 5 //Image of the confirmation box in action : //
Jerome 4.1 6 image:confirmbox.png
7
Jerome 11.1 8 {{html}}
Jerome 12.1 9 <a href="#" onclick="javascript:new XWiki.widgets.ConfirmationBox();">
Jerome 11.1 10 Or click this link to see one live!
11 </a>
12 {{/html}}
13
Jerome 1.1 14 == Usage ==
15
Jerome 4.1 16 {{code language="javascript"}}
Jerome 10.1 17 new XWiki.widgets.ConfirmationBox(behavior, interactionParameters);
Jerome 1.1 18 {{/code}}
19
Jerome 3.1 20 ; behavior
21 : Object that define confirm and cancel handlers. When the user chooses "Yes", its "onYes" method is triggered if it exists. When the user chooses "No", its "onNo" method is triggered, if it exists. The behavior parameter is not mandatory and is empty by default (It means nothing will happen upon confirmation or cancel).
Jerome 1.1 22
23 Example :
24
Jerome 4.1 25 {{code language="javascript"}}
Jerome 1.1 26 var myBehavior = {
27 onYes: function() {
28 alert("Yes !");
29 },
30 onNo: function() {
31 alert("Oh no :(");
32 }
Jerome 2.1 33 };
Jerome 1.1 34 {{/code}}
35
Jerome 10.1 36 ; interactionParameters
Jerome 3.1 37 : Object that defines the different text elements displayed with-in the confirmation box. Three variables are available for customization : **confirmationText**, the message to confirm (default value for the English language is //Are you sure ?//), **yesButtonText** the "yes" button text (or confirm button), **noButtonText** the "no" button text (or cancel button).
Jerome 1.1 38
Jerome 2.1 39 Example :
40
Jerome 8.1 41 {{code language="javascript"}}
Jerome 10.2 42 var myInteractionParameters = {
Jerome 10.1 43 confirmationText: "Are you sure you want to engage the wiki's self-destruction process ?",
Jerome 2.1 44 yesButtonText: "Yes, please do that",
45 noButtonText: "No thank you"
46 };
47 {{/code}}
48
Jerome 1.1 49 == Source Code (for tag xwiki-web-2.0) ==
50
51 {{remotecode language="javascript" source="http://svn.xwiki.org/svnroot/xwiki/platform/web/tags/xwiki-web-2.0/standard/src/main/webapp/resources/uicomponents/widgets/confirmationBox.js" /}}

Get Connected