2 * Description: implements a wizard-like interface
3 * Copyright (c) 2012 UPMC Sorbonne Universite
8 * It's a best practice to pass jQuery to an IIFE (Immediately Invoked Function
9 * Expression) that maps it to the dollar sign so it can't be overwritten by
10 * another library in the scope of its execution.
15 $.fn.Wizard = function( method ) {
16 if ( methods[method] ) {
17 return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
18 } else if ( typeof method === 'object' || ! method ) {
19 return methods.init.apply( this, arguments );
21 $.error( 'Method ' + method + ' does not exist on jQuery.Wizard' );
25 /***************************************************************************
27 ***************************************************************************/
31 init : function ( options ) {
32 return this.each(function() {
35 // Initialize the smart-wizard third-party jquery plugin
36 $(wizard, this).smartWizard({
37 selected : options.start_step - 1,
39 onLeaveStep : leaveAStepCallback,
40 // onFinish : onFinishCallback
43 // XXX Mark some steps as done !
44 $(wizard, this).smartWizard('setDone',{stepnum: 1, isdone:true});
46 function leaveAStepCallback(obj){
47 var step_num= obj.attr('rel')-1; // get the current step number
48 func = options.validate_step_js[step_num];
51 return window[func]();
54 function onFinishCallback(){
55 window.location.href('/');