Skip to content

Commit

Permalink
Addressed comments, updated docs, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Wagner authored and Robert Wagner committed Apr 3, 2015
1 parent e45c93f commit ebd697c
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 8 deletions.
8 changes: 2 additions & 6 deletions coffee/shepherd.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,8 @@ class Step extends Evented
@tether = new Tether extend(tetherOpts, @options.tetherOptions)

show: =>
if @options && @options.beforeShowPromise && typeof @options.beforeShowPromise is 'function'
@options.beforeShowPromise().then(=>
@_show()
)
else
@_show()
@options.beforeShowPromise?()?.then(=> @_show()) ? @_show()

_show: =>
@trigger 'before-show'

Expand Down
12 changes: 12 additions & 0 deletions docs/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ created.
- Function to be executed when the step is built. It must return one the three options above.
- `title`: The steps title. It becomes an `h3` at the top of the step.
- `attachTo`: What element the step should be attached to on the page. It can either be a string of the form
- `beforeShowPromise`: A function that returns a promise. When the promise resolves, the rest of the `show` code for
the step will execute.
`"element on"`, or an object with those properties. For example: `".some #element left"`, or `{element: '.some #element',
on: 'left'}`. If you use the object syntax, `element` can also be a DOM element. If you don't specify an `attachTo`
the element will appear in the middle of the screen.
Expand All @@ -155,6 +157,14 @@ properies. For example: `".some-element click"`, or `{selector: '.some-element'
the tour, it can be any event fired on any element on the page. You can also always manually advance the Tour by calling `myTour.next()`.
- `showCancelLink`: Should a cancel "✕" be shown in the header of the step?
- `scrollTo`: Should the element be scrolled to when this step is shown?
- `when`: You can define show, hide, etc events inside when. For example:
```js
when: {
show: function() {
window.scrollTo(0, 0);
}
}
```
- `tetherOptions`: Extra options to pass to [tether](http://github.hubspot.com/tether)

##### Step Methods
Expand All @@ -172,7 +182,9 @@ the tour, it can be any event fired on any element on the page. You can also al

##### Step Events

- `before-show`
- `show`
- `before-hide`
- `hide`
- `complete`
- `cancel`
Expand Down
9 changes: 9 additions & 0 deletions js/shepherd.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions shepherd-amd.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
this.cancel = __bind(this.cancel, this);
this.isOpen = __bind(this.isOpen, this);
this.hide = __bind(this.hide, this);
this._show = __bind(this._show, this);
this.show = __bind(this.show, this);
this.setOptions(options);
this;
Expand Down Expand Up @@ -171,6 +172,14 @@
};

Step.prototype.show = function() {
var _base, _ref1, _ref2,
_this = this;
return (_ref1 = typeof (_base = this.options).beforeShowPromise === "function" ? (_ref2 = _base.beforeShowPromise()) != null ? _ref2.then(function() {
return _this._show();
}) : void 0 : void 0) != null ? _ref1 : this._show();
};

Step.prototype._show = function() {
var _this = this;
this.trigger('before-show');
if (this.el == null) {
Expand Down
Loading

0 comments on commit ebd697c

Please sign in to comment.