Advertisement
Ranga14

History States JS/JQuery Function

Feb 3rd, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // HISTORY JS
  2. // ====================================================================
  3. // This file contains all history, transitions and animatinos between pages.
  4. // ====================================================================
  5.  
  6. var History = {
  7.  
  8.     entries: [],
  9.  
  10.     getSize: function(data) {
  11.         return this.entries.length;
  12.     },
  13.  
  14.     addEntry: function(action) {
  15.        
  16.         // Check to see if Entry exists, if not, add it
  17.         if ( $.inArray(action, this.entries) == -1 ) {
  18.             this.entries.push(action);
  19.         }
  20.         console.log(this.entries);
  21.  
  22.     },
  23.  
  24.     rewind: function(action) {
  25.  
  26.         if (this.getSize() <= 0) {                     
  27.             return false;
  28.         }
  29.  
  30.         // Remove last item from array
  31.         this.entries.pop();
  32.  
  33.         // List current section
  34.         var currentSection = this.entries[this.entries.length - 0];
  35.  
  36.         // List previous section
  37.         var prevSection = this.entries[this.entries.length - 1];
  38.  
  39.         // Pull the current section Div ID 
  40.         var $container = $('#patientFlow .panel:visible').prop('id');
  41.  
  42.         // Hide the current section
  43.         $('#' + $container).hide();
  44.  
  45.         // Show previous section of form
  46.         effect[prevSection]();
  47.  
  48.         // Hide Back button from first section of form
  49.         if ( this.entries.length == 1 ) {
  50.             $backBtn.css('visibility', 'hidden');
  51.         }
  52.  
  53.         return true;
  54.  
  55.     }
  56.  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement