Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Step destroy #156

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ scope of the uiTour directive, and can be required as `TourController` in direct
| goTo() | Hides the current step and jumps to the provided one. <br> **Parameters:** _step_ Can be step object, step ID string, or step index <br> **Returns:** _Promise_ Resolved when provided step is shown, rejects if no step provided or found. |
| getStatus() | Returns the current status of the tour based on TourStatus enum. <br> **Parameters:** \<none\> <br> **Returns:** TourStatus (ON, OFF, PAUSED, WAITING). Usage example: after tour starts: `tour.getStatus() === tour.Status.ON; //true` |
| createStep() | Adds a step via a step configuration object. <br> **Parameters:** _step_ - a step config object: must contain an `element` (jQLite object) or `selector` (string) attribute. `selector` is resolved the first time a step is shown. |
| destroyStep()| Remove a step from the tour as well as remove its popup from the DOM as well. <br> **Parameters:** _step_ - a step returned by `createStep()`. |
| reposition() | Forces the active step popover and backdrop (if visible) to reposition around the step target. This is useful when the size of the target changes dynamically after the step is activated. |

### `createStep()` Example
Expand Down
15 changes: 15 additions & 0 deletions app/tour-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,21 @@ export default function uiTourController($timeout, $q, $filter, $document, TourC
return step;
};

/**
* Destroy a step with destroying the created popup as well
*
* @protected
* @param step
*/
self.destroyStep = function (step) {
var index = stepList.indexOf(step);

if (index !== -1) {
TourStepService.destroyPopup(stepList[index]);
self.removeStep(step);
}
};

/**
* returns a copy of the current step (copied to avoid breaking internal functions)
*
Expand Down
11 changes: 10 additions & 1 deletion app/tour-step-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,16 @@ export default function (Tether, $compile, $document, $templateCache, $rootScope
}
}

/**
/**
* Destroy a step's popover
*
* @param {{}} step - Step options
*/
service.destroyPopup = function (step) {
step.popup.remove();
};

/**
* Initializes a step from a config object
*
* @param {{}} step - Step options
Expand Down
30 changes: 27 additions & 3 deletions dist/angular-ui-tour.js
Original file line number Diff line number Diff line change
Expand Up @@ -3275,12 +3275,21 @@ return /******/ (function(modules) { // webpackBootstrap
}

/**
* Initializes a step from a config object
* Destroy a step's popover
*
* @param {{}} step - Step options
* @param {{}} tour - The tour to which the step belongs
* @returns {*} configured step
*/
service.destroyPopup = function (step) {
step.popup.remove();
};

/**
* Initializes a step from a config object
*
* @param {{}} step - Step options
* @param {{}} tour - The tour to which the step belongs
* @returns {*} configured step
*/
service.createStep = function (step, tour) {
if (!step.element && !step.elementId && !step.selector) {
throw {
Expand Down Expand Up @@ -3997,6 +4006,21 @@ return /******/ (function(modules) { // webpackBootstrap
return step;
};

/**
* Destroy a step with destroying the created popup as well
*
* @protected
* @param step
*/
self.destroyStep = function (step) {
var index = stepList.indexOf(step);

if (index !== -1) {
TourStepService.destroyPopup(stepList[index]);
self.removeStep(step);
}
};

/**
* returns a copy of the current step (copied to avoid breaking internal functions)
*
Expand Down