diff --git a/core/modules/tour/js/tour.js b/core/modules/tour/js/tour.js
index d8885be..df96b80 100644
--- a/core/modules/tour/js/tour.js
+++ b/core/modules/tour/js/tour.js
@@ -3,7 +3,7 @@
* Attaches behaviors for the Tour module's toolbar tab.
*/
-(function ($, Backbone, Drupal, document) {
+(function ($, Backbone, Drupal) {
"use strict";
@@ -11,11 +11,12 @@
* Attaches the tour's toolbar tab behavior.
*/
Drupal.behaviors.tour = {
- attach: function (context) {
- $('body').once('tour', function (index, element) {
+ attach: function () {
+ var $body = $('body').once('tour');
+ if ($body.length) {
var model = new Drupal.tour.models.StateModel();
var view = new Drupal.tour.views.ToggleTourView({
- el: $(context).find('#toolbar-tab-tour'),
+ el: $('#toolbar-tab-tour'),
model: model
});
@@ -52,17 +53,17 @@ Drupal.behaviors.tour = {
$(document).trigger((isActive) ? 'drupalTourStarted' : 'drupalTourStopped');
})
// Initialization: check whether a tour is available on the current page.
- .set('tour', $(context).find('ol#tour'));
- });
+ .set('tour', $('#tour'));
+ }
}
};
-Drupal.tour = Drupal.tour || { models: {}, views: {}};
+var tour = { models: {}, views: {} };
/**
* Backbone Model for tours.
*/
-Drupal.tour.models.StateModel = Backbone.Model.extend({
+tour.models.StateModel = Backbone.Model.extend({
defaults: {
// Indicates whether the Drupal root window has a tour.
tour: [],
@@ -80,7 +81,7 @@ Drupal.tour.models.StateModel = Backbone.Model.extend({
/**
* Handles edit mode toggle interactions.
*/
-Drupal.tour.views.ToggleTourView = Backbone.View.extend({
+tour.views.ToggleTourView = Backbone.View.extend({
events: { 'click': 'onClick' },
@@ -110,13 +111,13 @@ Drupal.tour.views.ToggleTourView = Backbone.View.extend({
* Model change handler; starts or stops the tour.
*/
toggleTour: function() {
+ var model = this.model;
+ function postRideCallback () {
+ model.set('isActive', false);
+ }
if (this.model.get('isActive')) {
var $tour = this._getTour();
- this._removeIrrelevantTourItems($tour, this._getDocument());
- var that = this;
- $tour.joyride({
- postRideCallback: function () { that.model.set('isActive', false); }
- });
+ $tour.joyride({ postRideCallback: postRideCallback });
this.model.set({ isActive: true, activeTour: $tour });
}
else {
@@ -141,64 +142,11 @@ Drupal.tour.views.ToggleTourView = Backbone.View.extend({
* A jQuery element pointing to a
containing tour items.
*/
_getTour: function () {
- var whichTour = (this.model.get('overlayIsOpen')) ? 'overlayTour' : 'tour';
+ var whichTour = this.model.get('overlayIsOpen') ? 'overlayTour' : 'tour';
return this.model.get(whichTour);
- },
-
- /**
- * Gets the relevant document as a jQuery element.
- *
- * @return jQuery
- * A jQuery element pointing to the document within which a tour would be
- * started given the current state. I.e. when the Overlay is open, this will
- * point to the HTML document inside the Overlay's iframe, otherwise it will
- * point to the Drupal root window.
- */
- _getDocument: function () {
- return (this.model.get('overlayIsOpen')) ? $(Drupal.overlay.iframeWindow.document) : $(document);
- },
-
- /**
- * Removes tour items for elements that don't exist.
- *
- * @param jQuery $tour
- * A jQuery element pointing to a containing tour items.
- * @param jQuery $document
- * A jQuery element pointing to the document within which the elements
- * should be sought.
- *
- * @see _getDocument()
- */
- _removeIrrelevantTourItems: function ($tour, $document) {
- var removals = false;
- $tour
- .find('li')
- .each(function () {
- var $this = $(this);
- var itemId = $this.attr('data-id');
- var itemClass = $this.attr('data-class');
- if ($document.find('#' + itemId + ', .' + itemClass).length === 0) {
- removals = true;
- $this.remove();
- }
- });
-
- // If there were removals, we'll have to do some clean-up.
- if (removals) {
- var total = $tour.find('li').length;
- $tour
- .find('li')
- // Rebuild the progress data.
- .each(function (index) {
- var progress = Drupal.t('!tour_item of !total', { '!tour_item': index + 1, '!total': total });
- $(this).find('.tour-progress').text(progress);
- })
- // Update the last item to have "End tour" as the button.
- .last()
- .attr('data-text', Drupal.t('End tour'));
- }
}
-
});
-})(jQuery, Backbone, Drupal, document);
\ No newline at end of file
+Drupal.tour = tour;
+
+})(jQuery, Backbone, Drupal);
diff --git a/core/modules/tour_ui/tour_ui.info b/core/modules/tour_ui/tour_ui.info
deleted file mode 100644
index e52f5ed..0000000
--- a/core/modules/tour_ui/tour_ui.info
+++ /dev/null
@@ -1,6 +0,0 @@
-name = Tour UI
-description = Provides a UI to manage guided tours.
-package = Core
-version = VERSION
-core = 8.x
-dependencies[] = tour
diff --git a/core/modules/tour_ui/tour_ui.info.yml b/core/modules/tour_ui/tour_ui.info.yml
new file mode 100644
index 0000000..1c06816
--- /dev/null
+++ b/core/modules/tour_ui/tour_ui.info.yml
@@ -0,0 +1,7 @@
+name: Tour UI
+description: Provides a UI to manage guided tours.
+package: Core
+version: VERSION
+core: 8.x
+dependencies:
+ - tour
diff --git a/core/modules/tour_ui/tour_ui.module b/core/modules/tour_ui/tour_ui.module
index 6939410..9b04ac9 100644
--- a/core/modules/tour_ui/tour_ui.module
+++ b/core/modules/tour_ui/tour_ui.module
@@ -18,50 +18,6 @@ function tour_ui_entity_info(&$entity_info) {
}
/**
- * Implements hook_menu().
- */
-function tour_ui_menu() {
- $items['admin/config/user-interface/tour'] = array(
- 'title' => 'Tour',
- 'description' => 'Add and modify guided tours.',
- 'page callback' => 'NOT_USED',
- 'access callback' => TRUE,
- );
- $items['admin/config/user-interface/tour/add'] = array(
- 'title' => 'Add tour',
- 'type' => MENU_LOCAL_ACTION,
- 'page callback' => 'NOT_USED',
- 'access callback' => TRUE,
- );
- $items['admin/config/user-interface/tour/manage/%/edit'] = array(
- 'title' => 'Edit tour',
- 'page callback' => 'NOT_USED',
- 'access callback' => TRUE,
- );
- $items['admin/config/user-interface/tour/manage/%/delete'] = array(
- 'title' => 'Delete tour',
- 'page callback' => 'NOT_USED',
- 'access callback' => TRUE,
- );
- $items['admin/config/user-interface/tour/manage/%/tip/add/%'] = array(
- 'title' => 'Add tour tip',
- 'page callback' => 'NOT_USED',
- 'access callback' => TRUE,
- );
- $items['admin/config/user-interface/tour/manage/%/tip/edit/%'] = array(
- 'title' => 'Edit tour tip',
- 'page callback' => 'NOT_USED',
- 'access callback' => TRUE,
- );
- $items['admin/config/user-interface/tour/manage/%/tip/delete/%'] = array(
- 'title' => 'Edit tour tip',
- 'page callback' => 'NOT_USED',
- 'access callback' => TRUE,
- );
- return $items;
-}
-
-/**
* Callback for the entity URI.
*/
function tour_ui_uri(EntityInterface $entity) {