Advertisement
Guest User

Untitled

a guest
Aug 14th, 2012
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function(){
  2.  
  3.  
  4. // testing...
  5. notify('Notification title', 'This is a demo notification');
  6.  
  7.  
  8.  
  9.     /*
  10.      * -------------------------------------
  11.      * Elements
  12.      * -------------------------------------
  13.      */
  14.     var form = $('.wizard'),
  15.         centered;
  16.  
  17.  
  18.     /*
  19.      * -------------------------------------
  20.      * Installer: #Step 1
  21.      * -------------------------------------
  22.      */
  23.     if ( form.attr('id') === 'step_1' ) {
  24.         // Todo...
  25.     }
  26.  
  27.  
  28.     /*
  29.      * -------------------------------------
  30.      * Installer: #Step 2
  31.      * -------------------------------------
  32.      */
  33.     if ( form.attr('id') === 'step_2' ) {
  34.         // Disable the submit button.
  35.         //
  36.         $('#step_2 #next').disableInput();
  37.  
  38.         //
  39.         //
  40.         $('#step_2').find('select, input').on('focusx xkeyup change', function(e) {
  41.             // If we press the ENTER key.
  42.             //
  43.             if ( e.keyCode === 13 ) {
  44.                 // Do nothing.
  45.                 //
  46.                 return;
  47.             }
  48.  
  49.             // Make sure the form is validated.
  50.             //
  51.             //if ( $("#step_2").validationEngine('validate') ) {
  52.                 // Make the Ajax request.
  53.                 //
  54.                 $.ajax({
  55.                     type     : 'POST',
  56.                     url      : platform.url.base('installer/confirm_db'),
  57.                     data     : form.serialize(),
  58.                     dataType : 'JSON',
  59.                     success  : function(data, textStatus, jqXHR) {
  60.                         // Enable the button in case the connection succeeded.
  61.                         //
  62.                         if ( ! data.error ) {
  63.                             // Enable the submit button.
  64.                             //
  65.                             $('#step_2 #next').enableInput();
  66.  
  67.                         // We have an error.
  68.                         //
  69.                         } else {
  70.                             //
  71.                             //
  72.                             /*if ( data.code === 1000 ){
  73.                                 alert('No driver selected');
  74.                             } else*/
  75.  
  76.                             // Username and/or password are incorrect !
  77.                             //
  78.                             if ( data.code === 1045 ){
  79.                                 //alert('Wrong username/password');
  80.                             } else
  81.  
  82.                             // Database doesn't exist.
  83.                             //
  84.                             if ( data.code === 1049 ){
  85.                                 //alert('database does not exist');
  86.  
  87.                                 // Ask the user if he want us to create it..
  88.  
  89.                             }
  90.                         }
  91.                     }
  92.                 });
  93.             //}
  94.         });
  95.     }
  96.  
  97.  
  98.     /*
  99.      * -------------------------------------
  100.      * Installer: #Step 3
  101.      * -------------------------------------
  102.      */
  103.     if ( form.attr('id') === 'step_3' ) {
  104.         // Todo...
  105.     }
  106.  
  107.  
  108.  
  109.                 // Handle resizing (mostly for debugging)
  110.                 function handleWizardResize()
  111.                 {
  112.                     centerWizard(false);
  113.                 };
  114.  
  115.                 // Register and first call
  116.                 $(window).bind('normalized-resize', handleWizardResize);
  117.  
  118.                 /*
  119.                  * Center function
  120.                  * @param boolean animate whether or not to animate the position change
  121.                  * @return void
  122.                  */
  123.                 function centerWizard(animate)
  124.                 {
  125.                     form[animate ? 'animate' : 'css']({ marginTop: Math.max(0, Math.round(($.template.viewportHeight-30-form.outerHeight())/2))+'px' });
  126.                 };
  127.  
  128.                 // Initial vertical adjust
  129.                 centerWizard(false);
  130.  
  131.  
  132.     /*
  133.      * -------------------------------------
  134.      * Form validation.
  135.      * -------------------------------------
  136.      */
  137.     if ( $.validationEngine ) {
  138.         form.validationEngine();
  139.     }
  140. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement