text: /**
   .                              .o8                     oooo
   .o8                             "888                     `888
   .o888oo oooo d8b oooo  oooo   .oooo888   .ooooo.   .oooo.o  888  oooo
   888   `888""8P `888  `888  d88' `888  d88' `88b d88(  "8  888 .8P'
   888    888      888   888  888   888  888ooo888 `"Y88b.   888888.
   888 .  888      888   888  888   888  888    .o o.  )88b  888 `88b.
   "888" d888b     `V88V"V8P' `Y8bod88P" `Y8bod8P' 8""888P' o888o o888o
   ========================================================================
   Created:    03/14/2017
   Author:     Chris Brame
  
   **/
  
  define('modules/tour', [
      'jquery',
      'shepherd',
      'uikit',
      'tether'
  
  ], function($, Shepherd, UIKit) {
      var tour = {};
  
      tour = new Shepherd.Tour({
          defaults: {
              classes: 'shepherd-theme-square shepherd-theme-arrows'
          }
      });
  
      tour.addStep('welcome', {
          title: 'Welcome!',
          text: '<div class="logo" style="margin-left: 70px;">' +
          '<svg style="width: 140px; height: 75px;" viewBox="0 0 288.9 70.1">' +
          '<path style="fill: #222;" d="M28.5,28.4c-0.1,1.6-0.7,3.4-1.6,5.4c-2.4-0.3-4.6-0.4-6.8-0.4h-1.7c-2.9,13.9-4.3,22.6-4.3,26.1 c0,1.8,0.4,2.7,1.2,2.7c0.8,0,2.9-0.8,6.2-2.3l1.7,3.1C17.7,67.7,12.5,70,7.8,70c-2.2,0-4-0.7-5.4-2.1c-1.4-1.4-2.1-3.2-2.1-5.5	c0-2.3,0.3-4.9,0.8-7.7c0.5-2.9,1.3-6.4,2.2-10.6c0.9-4.2,1.6-7.5,2.1-10.1c-2.3,0.2-4,0.4-5.2,0.6c-0.1-0.8-0.2-1.8-0.2-3	c0-1.3,0.1-2.3,0.3-3.1h5.9c0.5-3.4,0.8-6.6,0.8-9.6L6.8,16v-0.3c4.9-1.7,9.5-2.5,13.8-2.5c0.2,1.3,0.4,2.8,0.4,4.7	c0,1.9-0.5,5.4-1.6,10.6H28.5z"/>' +
          '<path style="fill: #222;" d="M29.6,69.1H29c-0.1-0.5-0.2-1.6-0.2-3.4c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C172.1,49,174.6,47.6,176.5,45.5z"/>' +
          '<path style="fill: #222;" d="M223.2,56.6c0,3.9-1.7,7.2-5.2,9.7c-3.5,2.5-7.4,3.8-11.9,3.8c-4.4,0-8-0.9-10.6-2.8c-2.6-1.9-3.9-3.5-3.9-5	c0-0.9,1.1-2.3,3.3-4.3c2.2-2,4-3.2,5.5-3.6c3.1,2.3,5.7,6,7.7,11c2.3-0.2,3.5-1.3,3.5-3.3c0-2.9-2.5-7-7.6-12.2	c-5.1-5.3-7.6-9.5-7.6-12.6c0-3.1,1.4-5.5,4.2-7.3c2.8-1.7,6.2-2.6,10.2-2.6c4,0,7,0.7,9,2.1c2,1.4,3,3.3,3,5.7	c0,2.4-1.9,5.7-5.7,10c0.4,0.4,1,1,1.7,1.7c0.7,0.7,1.6,2.1,2.7,4.1C222.6,52.9,223.2,54.8,223.2,56.6z M218.1,35.2	c0-2.2-1.5-3.3-4.5-3.3c-1.4,0-2.6,0.3-3.6,0.9c-0.9,0.6-1.4,1.3-1.4,2c0,1.4,1.4,3.3,4.1,5.8l1.4,1.2	C216.8,39.6,218.1,37.4,218.1,35.2z"/>' +
          '<path style="fill: #222;" d="M238.1,6.9c0-2.1-0.2-3.5-0.6-4.4C242.4,0.8,247,0,251.3,0c0.6,0.6,0.8,2,0.8,4.3c0,5.2-1.7,15.1-5.2,29.8	c5.6-4.6,11.1-6.8,16.5-6.8c2.4,0,4.5,0.8,6.2,2.3c1.7,1.5,2.5,3.7,2.5,6.6c0,5.4-4.4,9.3-13.2,11.7c2.1,6.5,3.9,10.9,5.4,13.2	c0.7,1,1.2,1.5,1.5,1.5c0.7,0,2.1-0.5,4.3-1.6l1-0.5l1.5,3.2c-1.5,1.4-3.6,2.8-6.2,4.2c-2.7,1.4-5.1,2.1-7.3,2.1	c-4.9,0-8.3-4.4-10.2-13.3c-0.9-3.8-1.4-7.4-1.6-10.7c4-0.9,7-2.1,9-3.4c2-1.3,3-3.1,3-5.2c0-2.1-1.1-3.1-3.2-3.1	c-2.1,0-5.7,2.1-10.7,6.4c-3.1,13.2-4.7,22.2-4.7,27.1c-3.4,1-7.9,1.5-13.4,1.5c-0.1-1.1-0.1-2-0.1-2.8c0-2.7,1.8-11.9,5.4-27.6	C236.3,23.1,238.1,12.5,238.1,6.9z"/>' +
          '<circle style="fill: #E74C3C;" cx="284.9" cy="64.7" r="4"/>' +
          '</svg>' +
          '</div>' +
          'Welcome to the trudesk tour! <br /> I\'m going to guide you through the system and show you around a little. <br /><br />' +
          '<span style="font-style: italic;">You may choose to skip the tour if you do not require it. Simply press the skip button below.</span>',
          buttons: [
              {
                  text: 'Lets Start',
                  action: tour.next
              },
              {
                  text: 'Skip',
                  classes: 'uk-float-left',
                  action: function() {
                      var username = window.trudeskSessionService.getUser().username;
                      $.ajax({
                          url: '/api/v1/users/' + username + '/updatepreferences',
                          method: 'PUT',
                          headers: {
                              'Content-Type': 'application/json'
                          },
                          data: JSON.stringify({
                              preference: 'tourCompleted',
                              value: true
                          }),
                          success: function() {
                              tour.cancel();
                          },
                          error: function(error) {
                              console.error(error);
                          }
                      });
                  }
              }
          ],
          when: {
              show: function() {
                  var overlay = $('#serverRestarting');
                  overlay.css('z-index', 999).removeClass('hide');
                  overlay.find('*').hide();
              },
              hide: function() {
                  var overlay = $('#serverRestarting');
                  overlay.animate({opacity: 0}, 500, function() {
                      overlay.css('z-index', 9999).addClass('hide');
                      overlay.find('*').show();
                  });
              }
          }
      });
  
      tour.addStep('dashboard', {
          title: 'Dashboard',
          text: 'This is your dashboard screen. It will show you stats at a glance.'
      });
  
      tour.addStep('topbar', {
          title: 'Top Nav',
          text: 'This is your top nav. It has quick links to frequently used functions and notifications.',
          attachTo: '.top-nav bottom'
      });
  
      tour.addStep('addTicket', {
          title: 'Quick Link - Add Ticket',
          text: '<strong> Add Ticket </strong> quick link will is the fastest way to submit and enter a ticket. Go ahead give it a push!',
          attachTo: '.top-menu .tour-addTicket bottom',
          buttons: [],
          when: {
              show: function() {
                  var $target = $('.tour-addTicket');
                  $target.on('click', advanceTourDelayed);
                  $('button.uk-modal-close').attr('disabled', true);
                  $('button#submitNewTicket').attr('disabled', true);
              },
              hide: function() {
                  setTimeout(function() {
                      var $target = $('.tour-addTicket');
                      $target.off('click', advanceTourDelayed);
                  }, 5000);
              }
          }
      });
  
      tour.addStep('addTicketForm', {
          title: 'Add Ticket Form',
          text: 'The great ticket form. Use this to submit new request. Don\'t worry it\'s pretty simple. Remember, always try to be as detailed as possible.',
          attachTo: '#ticketCreateModal .uk-modal-dialog left',
          when: {
              hide: function() {
                  UIKit.modal($('#ticketCreateModal')).hide();
              }
          }
      });
  
      tour.addStep('messagesIcon', {
          title: 'Messages Notification',
          text: 'Here you will see your notification for chat messages sent by other users.',
          attachTo: '.tour-messagesNotification bottom'
      });
  
      tour.addStep('ticketNotifications', {
          title: 'Ticket Notifications',
          text: 'This is where you\'ll get notification updates about tickets.',
          attachTo: '.tour-ticketNotifications bottom'
      });
  
      tour.addStep('onlineUserListButton', {
          title: 'Chat - User List',
          text: 'Push this to open the user list to quickly send a message to any user.',
          attachTo: '.tour-onlineUserListButton bottom',
          buttons: [],
          //advanceOn: '.tour-onlineUserListButton click',
          when: {
              show: function() {
                  var $target = $('.tour-onlineUserListButton');
                  $target.on('click', function() {
                      setTimeout(function() {
                          tour.show('onlineUserList');
                      }, 300);
                  });
              },
              hide: function() {
                  var $target = $('.tour-onlineUserListButton');
                  $target.off('click');
              }
          }
      });
  
      tour.addStep('onlineUserList', {
          title: 'Chat - User List',
          text: 'There it is! Your user list. Lets move on!',
          when: {
              hide: function() {
                  // History.pushState(null, null, '/tickets');
              }
          }
      });
  
  
      // tour.addStep('profileButton', {
      //     title: 'Profile',
      //     text: 'Clicking your profile picture will open up your profile dropdown.',
      //     attachTo: 'img#profileImage bottom'
      // });
  
      tour.addStep('sidebar_tickets', {
          title: 'Tickets',
          text: 'This is the core of trudesk. You\'ll find all your current and past tickets located here.',
          attachTo: '.navTickets right',
          buttons: [],
          when: {
              show: function() {
                  UIKit.offcanvas.hide();
                  //$('#page-content').css({background: 'rgba(0,0,0,0.5)'});
                  $('#page-content').css({opacity: 0.5});
                  var $target = $('.navTickets');
                  $target.on('click', function() {
                      tour.next();
                  });
              }
          }
      });
  
      tour.addStep('tickets_page', {
          title: 'Tickets',
          text: 'Here you will find all new, open, or pending tickets. If any tickets are overdue they will flash red. <br /><br />' +
                  'Take a minute to review this screen and click next to proceed.'
      });
  
      tour.addStep('sidebar_messages', {
          title: 'Messages',
          text: 'This will take you to your messages. Messages are sent between users privately and securely.',
          attachTo: '.navMessages right',
          buttons: [],
          when: {
              show: function() {
                  var $target = $('.navMessages');
                  $target.on('click', function() {
                      setTimeout(function() {
                          tour.next();
                      }, 1000);
                  });
              }
          }
      });
  
      tour.addStep('message_list', {
          title: 'Message List',
          text: 'Here you will find your current active conversations. If there are no current conversation, you can start a conversation. We will view that next.',
          attachTo: 'ul.message-items right'
      });
  
      tour.addStep('start_conversation', {
          title: 'Start New Conversation',
          text: 'Simply click the (+) sign to start a new conversation with a user.',
          attachTo: '#convo-actions a right',
          buttons: [],
          when: {
              show: function() {
                  var $target = $('#convo-actions a');
                  $target.on('click', function() {
                      tour.next();
                  });
              }
          }
      });
  
      tour.addStep('all_user_list', {
          title: 'User List',
          text: 'Here you will find the same list as before, the all user list. Clicking on a user will start the conversation.',
          attachTo: '#new-convo-user-list right',
          when: {
              show: function() {
                  $('.all-user-list *').css({'pointer-events': 'none'});
              }
          }
      });
  
  
      tour.on('complete', function() {
  
      });
  
  
  
  
  
      tour.init = function() {
          tour.start();
      };
  
      function advanceTourDelayed() {
          setTimeout(function() {
              tour.next();
          }, 300);
      }
  
      return tour;
  });