Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function(){
- // testing...
- notify('Notification title', 'This is a demo notification');
- /*
- * -------------------------------------
- * Elements
- * -------------------------------------
- */
- var form = $('.wizard'),
- centered;
- /*
- * -------------------------------------
- * Installer: #Step 1
- * -------------------------------------
- */
- if ( form.attr('id') === 'step_1' ) {
- // Todo...
- }
- /*
- * -------------------------------------
- * Installer: #Step 2
- * -------------------------------------
- */
- if ( form.attr('id') === 'step_2' ) {
- // Disable the submit button.
- //
- $('#step_2 #next').disableInput();
- //
- //
- $('#step_2').find('select, input').on('focusx xkeyup change', function(e) {
- // If we press the ENTER key.
- //
- if ( e.keyCode === 13 ) {
- // Do nothing.
- //
- return;
- }
- // Make sure the form is validated.
- //
- //if ( $("#step_2").validationEngine('validate') ) {
- // Make the Ajax request.
- //
- $.ajax({
- type : 'POST',
- url : platform.url.base('installer/confirm_db'),
- data : form.serialize(),
- dataType : 'JSON',
- success : function(data, textStatus, jqXHR) {
- // Enable the button in case the connection succeeded.
- //
- if ( ! data.error ) {
- // Enable the submit button.
- //
- $('#step_2 #next').enableInput();
- // We have an error.
- //
- } else {
- //
- //
- /*if ( data.code === 1000 ){
- alert('No driver selected');
- } else*/
- // Username and/or password are incorrect !
- //
- if ( data.code === 1045 ){
- //alert('Wrong username/password');
- } else
- // Database doesn't exist.
- //
- if ( data.code === 1049 ){
- //alert('database does not exist');
- // Ask the user if he want us to create it..
- }
- }
- }
- });
- //}
- });
- }
- /*
- * -------------------------------------
- * Installer: #Step 3
- * -------------------------------------
- */
- if ( form.attr('id') === 'step_3' ) {
- // Todo...
- }
- // Handle resizing (mostly for debugging)
- function handleWizardResize()
- {
- centerWizard(false);
- };
- // Register and first call
- $(window).bind('normalized-resize', handleWizardResize);
- /*
- * Center function
- * @param boolean animate whether or not to animate the position change
- * @return void
- */
- function centerWizard(animate)
- {
- form[animate ? 'animate' : 'css']({ marginTop: Math.max(0, Math.round(($.template.viewportHeight-30-form.outerHeight())/2))+'px' });
- };
- // Initial vertical adjust
- centerWizard(false);
- /*
- * -------------------------------------
- * Form validation.
- * -------------------------------------
- */
- if ( $.validationEngine ) {
- form.validationEngine();
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement