bootstrap-tour.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  1. /* ===========================================================
  2. # bootstrap-tour - v0.8.0
  3. # http://bootstraptour.com
  4. # ==============================================================
  5. # Copyright 2012-2013 Ulrich Sossou
  6. #
  7. # Licensed under the Apache License, Version 2.0 (the "License");
  8. # you may not use this file except in compliance with the License.
  9. # You may obtain a copy of the License at
  10. #
  11. # http://www.apache.org/licenses/LICENSE-2.0
  12. #
  13. # Unless required by applicable law or agreed to in writing, software
  14. # distributed under the License is distributed on an "AS IS" BASIS,
  15. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. # See the License for the specific language governing permissions and
  17. # limitations under the License.
  18. */
  19. (function($, window) {
  20. var Tour, document;
  21. document = window.document;
  22. Tour = (function() {
  23. function Tour(options) {
  24. this._options = $.extend({
  25. name: "tour",
  26. container: "body",
  27. keyboard: true,
  28. storage: window.localStorage,
  29. debug: false,
  30. backdrop: false,
  31. redirect: true,
  32. orphan: false,
  33. duration: false,
  34. basePath: "",
  35. template: "<div class='popover'> <div class='arrow'></div> <h3 class='popover-title'></h3> <div class='popover-content'></div> <div class='popover-navigation'> <div class='btn-group'> <button class='btn btn-sm btn-default' data-role='prev'>&laquo; Prev</button> <button class='btn btn-sm btn-default' data-role='next'>Next &raquo;</button> <button class='btn btn-sm btn-default' data-role='pause-resume' data-pause-text='Pause' data-resume-text='Resume' >Pause</button> </div> <button class='btn btn-sm btn-default' data-role='end'>End tour</button> </div> </div>",
  36. afterSetState: function(key, value) {},
  37. afterGetState: function(key, value) {},
  38. afterRemoveState: function(key) {},
  39. onStart: function(tour) {},
  40. onEnd: function(tour) {},
  41. onShow: function(tour) {},
  42. onShown: function(tour) {},
  43. onHide: function(tour) {},
  44. onHidden: function(tour) {},
  45. onNext: function(tour) {},
  46. onPrev: function(tour) {},
  47. onPause: function(tour, duration) {},
  48. onResume: function(tour, duration) {}
  49. }, options);
  50. this._force = false;
  51. this._inited = false;
  52. this._steps = [];
  53. this.backdrop = {
  54. overlay: null,
  55. $element: null,
  56. $background: null,
  57. backgroundShown: false,
  58. overlayElementShown: false
  59. };
  60. }
  61. Tour.prototype.setState = function(key, value) {
  62. var e, keyName;
  63. if (this._options.storage) {
  64. keyName = "" + this._options.name + "_" + key;
  65. try {
  66. this._options.storage.setItem(keyName, value);
  67. } catch (_error) {
  68. e = _error;
  69. if (e.code === DOMException.QUOTA_EXCEEDED_ERR) {
  70. this.debug("LocalStorage quota exceeded. setState failed.");
  71. }
  72. }
  73. return this._options.afterSetState(keyName, value);
  74. } else {
  75. if (this._state == null) {
  76. this._state = {};
  77. }
  78. return this._state[key] = value;
  79. }
  80. };
  81. Tour.prototype.removeState = function(key) {
  82. var keyName;
  83. if (this._options.storage) {
  84. keyName = "" + this._options.name + "_" + key;
  85. this._options.storage.removeItem(keyName);
  86. return this._options.afterRemoveState(keyName);
  87. } else {
  88. if (this._state != null) {
  89. return delete this._state[key];
  90. }
  91. }
  92. };
  93. Tour.prototype.getState = function(key) {
  94. var keyName, value;
  95. if (this._options.storage) {
  96. keyName = "" + this._options.name + "_" + key;
  97. value = this._options.storage.getItem(keyName);
  98. } else {
  99. if (this._state != null) {
  100. value = this._state[key];
  101. }
  102. }
  103. if (value === void 0 || value === "null") {
  104. value = null;
  105. }
  106. this._options.afterGetState(key, value);
  107. return value;
  108. };
  109. Tour.prototype.addSteps = function(steps) {
  110. var step, _i, _len, _results;
  111. _results = [];
  112. for (_i = 0, _len = steps.length; _i < _len; _i++) {
  113. step = steps[_i];
  114. _results.push(this.addStep(step));
  115. }
  116. return _results;
  117. };
  118. Tour.prototype.addStep = function(step) {
  119. return this._steps.push(step);
  120. };
  121. Tour.prototype.getStep = function(i) {
  122. if (this._steps[i] != null) {
  123. return $.extend({
  124. id: "step-" + i,
  125. path: "",
  126. placement: "right",
  127. title: "",
  128. content: "<p></p>",
  129. next: i === this._steps.length - 1 ? -1 : i + 1,
  130. prev: i - 1,
  131. animation: true,
  132. container: this._options.container,
  133. backdrop: this._options.backdrop,
  134. redirect: this._options.redirect,
  135. orphan: this._options.orphan,
  136. duration: this._options.duration,
  137. template: this._options.template,
  138. onShow: this._options.onShow,
  139. onShown: this._options.onShown,
  140. onHide: this._options.onHide,
  141. onHidden: this._options.onHidden,
  142. onNext: this._options.onNext,
  143. onPrev: this._options.onPrev,
  144. onPause: this._options.onPause,
  145. onResume: this._options.onResume
  146. }, this._steps[i]);
  147. }
  148. };
  149. Tour.prototype.init = function(force) {
  150. var _this = this;
  151. this._force = force;
  152. if (this.ended()) {
  153. return this._debug("Tour ended, init prevented.");
  154. }
  155. this.setCurrentStep();
  156. this._setupMouseNavigation();
  157. this._setupKeyboardNavigation();
  158. this._onResize(function() {
  159. return _this.showStep(_this._current);
  160. });
  161. if (this._current !== null) {
  162. this.showStep(this._current);
  163. }
  164. this._inited = true;
  165. return this;
  166. };
  167. Tour.prototype.start = function(force) {
  168. var promise;
  169. if (force == null) {
  170. force = false;
  171. }
  172. if (!this._inited) {
  173. this.init(force);
  174. }
  175. if (this._current === null) {
  176. promise = this._makePromise(this._options.onStart != null ? this._options.onStart(this) : void 0);
  177. return this._callOnPromiseDone(promise, this.showStep, 0);
  178. }
  179. };
  180. Tour.prototype.next = function() {
  181. var promise;
  182. if (this.ended()) {
  183. return this._debug("Tour ended, next prevented.");
  184. }
  185. promise = this.hideStep(this._current);
  186. return this._callOnPromiseDone(promise, this._showNextStep);
  187. };
  188. Tour.prototype.prev = function() {
  189. var promise;
  190. if (this.ended()) {
  191. return this._debug("Tour ended, prev prevented.");
  192. }
  193. promise = this.hideStep(this._current);
  194. return this._callOnPromiseDone(promise, this._showPrevStep);
  195. };
  196. Tour.prototype.goTo = function(i) {
  197. var promise;
  198. if (this.ended()) {
  199. return this._debug("Tour ended, goTo prevented.");
  200. }
  201. promise = this.hideStep(this._current);
  202. return this._callOnPromiseDone(promise, this.showStep, i);
  203. };
  204. Tour.prototype.end = function() {
  205. var endHelper, promise,
  206. _this = this;
  207. endHelper = function(e) {
  208. $(document).off("click.tour-" + _this._options.name);
  209. $(document).off("keyup.tour-" + _this._options.name);
  210. $(window).off("resize.tour-" + _this._options.name);
  211. _this.setState("end", "yes");
  212. _this._inited = false;
  213. _this._force = false;
  214. _this._clearTimer();
  215. if (_this._options.onEnd != null) {
  216. return _this._options.onEnd(_this);
  217. }
  218. };
  219. promise = this.hideStep(this._current);
  220. return this._callOnPromiseDone(promise, endHelper);
  221. };
  222. Tour.prototype.ended = function() {
  223. return !this._force && !!this.getState("end");
  224. };
  225. Tour.prototype.restart = function() {
  226. this.removeState("current_step");
  227. this.removeState("end");
  228. this.setCurrentStep(0);
  229. return this.start();
  230. };
  231. Tour.prototype.pause = function() {
  232. var step;
  233. step = this.getStep(this._current);
  234. if (!(step && step.duration)) {
  235. return;
  236. }
  237. this._paused = true;
  238. this._duration -= new Date().getTime() - this._start;
  239. window.clearTimeout(this._timer);
  240. this._debug("Paused/Stopped step " + (this._current + 1) + " timer (" + this._duration + " remaining).");
  241. if (step.onPause != null) {
  242. return step.onPause(this, this._duration);
  243. }
  244. };
  245. Tour.prototype.resume = function() {
  246. var step,
  247. _this = this;
  248. step = this.getStep(this._current);
  249. if (!(step && step.duration)) {
  250. return;
  251. }
  252. this._paused = false;
  253. this._start = new Date().getTime();
  254. this._duration = this._duration || step.duration;
  255. this._timer = window.setTimeout(function() {
  256. if (_this._isLast()) {
  257. return _this.next();
  258. } else {
  259. return _this.end();
  260. }
  261. }, this._duration);
  262. this._debug("Started step " + (this._current + 1) + " timer with duration " + this._duration);
  263. if ((step.onResume != null) && this._duration !== step.duration) {
  264. return step.onResume(this, this._duration);
  265. }
  266. };
  267. Tour.prototype.hideStep = function(i) {
  268. var hideStepHelper, promise, step,
  269. _this = this;
  270. step = this.getStep(i);
  271. if (!step) {
  272. return;
  273. }
  274. this._clearTimer();
  275. promise = this._makePromise(step.onHide != null ? step.onHide(this, i) : void 0);
  276. hideStepHelper = function(e) {
  277. var $element;
  278. $element = $(step.element);
  279. if (!($element.data("bs.popover") || $element.data("popover"))) {
  280. $element = $("body");
  281. }
  282. $element.popover("destroy");
  283. if (step.reflex) {
  284. $element.css("cursor", "").off("click.tour-" + _this._options.name);
  285. }
  286. if (step.backdrop) {
  287. _this._hideBackdrop();
  288. }
  289. if (step.onHidden != null) {
  290. return step.onHidden(_this);
  291. }
  292. };
  293. this._callOnPromiseDone(promise, hideStepHelper);
  294. return promise;
  295. };
  296. Tour.prototype.showStep = function(i) {
  297. var promise, showStepHelper, skipToPrevious, step,
  298. _this = this;
  299. step = this.getStep(i);
  300. if (!step) {
  301. return;
  302. }
  303. skipToPrevious = i < this._current;
  304. promise = this._makePromise(step.onShow != null ? step.onShow(this, i) : void 0);
  305. showStepHelper = function(e) {
  306. var current_path, path;
  307. _this.setCurrentStep(i);
  308. path = $.isFunction(step.path) ? step.path.call() : _this._options.basePath + step.path;
  309. current_path = [document.location.pathname, document.location.hash].join("");
  310. if (_this._isRedirect(path, current_path)) {
  311. _this._redirect(step, path);
  312. return;
  313. }
  314. if (_this._isOrphan(step)) {
  315. if (!step.orphan) {
  316. _this._debug("Skip the orphan step " + (_this._current + 1) + ". Orphan option is false and the element doesn't exist or is hidden.");
  317. if (skipToPrevious) {
  318. _this._showPrevStep();
  319. } else {
  320. _this._showNextStep();
  321. }
  322. return;
  323. }
  324. _this._debug("Show the orphan step " + (_this._current + 1) + ". Orphans option is true.");
  325. }
  326. if (step.backdrop) {
  327. _this._showBackdrop(!_this._isOrphan(step) ? step.element : void 0);
  328. }
  329. _this._scrollIntoView(step.element, function() {
  330. if ((step.element != null) && step.backdrop) {
  331. _this._showOverlayElement(step.element);
  332. }
  333. _this._showPopover(step, i);
  334. if (step.onShown != null) {
  335. step.onShown(_this);
  336. }
  337. return _this._debug("Step " + (_this._current + 1) + " of " + _this._steps.length);
  338. });
  339. if (step.duration) {
  340. return _this.resume();
  341. }
  342. };
  343. this._callOnPromiseDone(promise, showStepHelper);
  344. return promise;
  345. };
  346. Tour.prototype.setCurrentStep = function(value) {
  347. if (value != null) {
  348. this._current = value;
  349. this.setState("current_step", value);
  350. } else {
  351. this._current = this.getState("current_step");
  352. this._current = this._current === null ? null : parseInt(this._current, 10);
  353. }
  354. return this;
  355. };
  356. Tour.prototype._showNextStep = function() {
  357. var promise, showNextStepHelper, step,
  358. _this = this;
  359. step = this.getStep(this._current);
  360. showNextStepHelper = function(e) {
  361. return _this.showStep(step.next);
  362. };
  363. promise = this._makePromise((step.onNext != null ? step.onNext(this) : void 0));
  364. return this._callOnPromiseDone(promise, showNextStepHelper);
  365. };
  366. Tour.prototype._showPrevStep = function() {
  367. var promise, showPrevStepHelper, step,
  368. _this = this;
  369. step = this.getStep(this._current);
  370. showPrevStepHelper = function(e) {
  371. return _this.showStep(step.prev);
  372. };
  373. promise = this._makePromise((step.onPrev != null ? step.onPrev(this) : void 0));
  374. return this._callOnPromiseDone(promise, showPrevStepHelper);
  375. };
  376. Tour.prototype._debug = function(text) {
  377. if (this._options.debug) {
  378. return window.console.log("Bootstrap Tour '" + this._options.name + "' | " + text);
  379. }
  380. };
  381. Tour.prototype._isRedirect = function(path, currentPath) {
  382. return (path != null) && path !== "" && path.replace(/\?.*$/, "").replace(/\/?$/, "") !== currentPath.replace(/\/?$/, "");
  383. };
  384. Tour.prototype._redirect = function(step, path) {
  385. if ($.isFunction(step.redirect)) {
  386. return step.redirect.call(this, path);
  387. } else if (step.redirect === true) {
  388. this._debug("Redirect to " + path);
  389. return document.location.href = path;
  390. }
  391. };
  392. Tour.prototype._isOrphan = function(step) {
  393. return (step.element == null) || !$(step.element).length || $(step.element).is(":hidden") && ($(step.element)[0].namespaceURI !== "http://www.w3.org/2000/svg");
  394. };
  395. Tour.prototype._isLast = function() {
  396. return this._current < this._steps.length - 1;
  397. };
  398. Tour.prototype._showPopover = function(step, i) {
  399. var $element, $navigation, $template, $tip, isOrphan, options,
  400. _this = this;
  401. options = $.extend({}, this._options);
  402. $template = $.isFunction(step.template) ? $(step.template(i, step)) : $(step.template);
  403. $navigation = $template.find(".popover-navigation");
  404. isOrphan = this._isOrphan(step);
  405. if (isOrphan) {
  406. step.element = "body";
  407. step.placement = "top";
  408. $template = $template.addClass("orphan");
  409. }
  410. $element = $(step.element);
  411. $template.addClass("tour-" + this._options.name);
  412. if (step.options) {
  413. $.extend(options, step.options);
  414. }
  415. if (step.reflex) {
  416. $element.css("cursor", "pointer").on("click.tour-" + this._options.name, function() {
  417. if (_this._isLast()) {
  418. return _this.next();
  419. } else {
  420. return _this.end();
  421. }
  422. });
  423. }
  424. if (step.prev < 0) {
  425. $navigation.find("*[data-role=prev]").addClass("disabled");
  426. }
  427. if (step.next < 0) {
  428. $navigation.find("*[data-role=next]").addClass("disabled");
  429. }
  430. if (!step.duration) {
  431. $navigation.find("*[data-role='pause-resume']").remove();
  432. }
  433. step.template = $template.clone().wrap("<div>").parent().html();
  434. $element.popover({
  435. placement: step.placement,
  436. trigger: "manual",
  437. title: step.title,
  438. content: step.content,
  439. html: true,
  440. animation: step.animation,
  441. container: step.container,
  442. template: step.template,
  443. selector: step.element
  444. }).popover("show");
  445. $tip = $element.data("bs.popover") ? $element.data("bs.popover").tip() : $element.data("popover").tip();
  446. $tip.attr("id", step.id);
  447. this._reposition($tip, step);
  448. if (isOrphan) {
  449. return this._center($tip);
  450. }
  451. };
  452. Tour.prototype._reposition = function($tip, step) {
  453. var offsetBottom, offsetHeight, offsetRight, offsetWidth, originalLeft, originalTop, tipOffset;
  454. offsetWidth = $tip[0].offsetWidth;
  455. offsetHeight = $tip[0].offsetHeight;
  456. tipOffset = $tip.offset();
  457. originalLeft = tipOffset.left;
  458. originalTop = tipOffset.top;
  459. offsetBottom = $(document).outerHeight() - tipOffset.top - $tip.outerHeight();
  460. if (offsetBottom < 0) {
  461. tipOffset.top = tipOffset.top + offsetBottom;
  462. }
  463. offsetRight = $("html").outerWidth() - tipOffset.left - $tip.outerWidth();
  464. if (offsetRight < 0) {
  465. tipOffset.left = tipOffset.left + offsetRight;
  466. }
  467. if (tipOffset.top < 0) {
  468. tipOffset.top = 0;
  469. }
  470. if (tipOffset.left < 0) {
  471. tipOffset.left = 0;
  472. }
  473. $tip.offset(tipOffset);
  474. if (step.placement === "bottom" || step.placement === "top") {
  475. if (originalLeft !== tipOffset.left) {
  476. return this._replaceArrow($tip, (tipOffset.left - originalLeft) * 2, offsetWidth, "left");
  477. }
  478. } else {
  479. if (originalTop !== tipOffset.top) {
  480. return this._replaceArrow($tip, (tipOffset.top - originalTop) * 2, offsetHeight, "top");
  481. }
  482. }
  483. };
  484. Tour.prototype._center = function($tip) {
  485. return $tip.css("top", $(window).outerHeight() / 2 - $tip.outerHeight() / 2);
  486. };
  487. Tour.prototype._replaceArrow = function($tip, delta, dimension, position) {
  488. return $tip.find(".arrow").css(position, delta ? 50 * (1 - delta / dimension) + "%" : "");
  489. };
  490. Tour.prototype._scrollIntoView = function(element, callback) {
  491. var $element, $window, offsetTop, scrollTop, windowHeight,
  492. _this = this;
  493. if (!element) {
  494. return callback();
  495. }
  496. $element = $(element);
  497. $window = $(window);
  498. offsetTop = $element.offset().top;
  499. windowHeight = $window.height();
  500. scrollTop = Math.max(0, offsetTop - (windowHeight / 2));
  501. this._debug("Scroll into view. ScrollTop: " + scrollTop + ". Element offset: " + offsetTop + ". Window height: " + windowHeight + ".");
  502. return $("body").stop().animate({
  503. scrollTop: Math.ceil(scrollTop)
  504. }, function() {
  505. callback();
  506. return _this._debug("Scroll into view. Animation end element offset: " + ($element.offset().top) + ". Window height: " + ($window.height()) + ".");
  507. });
  508. };
  509. Tour.prototype._onResize = function(callback, timeout) {
  510. return $(window).on("resize.tour-" + this._options.name, function() {
  511. clearTimeout(timeout);
  512. return timeout = setTimeout(callback, 100);
  513. });
  514. };
  515. Tour.prototype._setupMouseNavigation = function() {
  516. var _this = this;
  517. _this = this;
  518. $(document).off("click.tour-" + this._options.name, ".popover.tour-" + this._options.name + " *[data-role=next]:not(.disabled)").on("click.tour-" + this._options.name, ".popover.tour-" + this._options.name + " *[data-role=next]:not(.disabled)", function(e) {
  519. e.preventDefault();
  520. return _this.next();
  521. });
  522. $(document).off("click.tour-" + this._options.name, ".popover.tour-" + this._options.name + " *[data-role=prev]:not(.disabled)").on("click.tour-" + this._options.name, ".popover.tour-" + this._options.name + " *[data-role=prev]:not(.disabled)", function(e) {
  523. e.preventDefault();
  524. return _this.prev();
  525. });
  526. $(document).off("click.tour-" + this._options.name, ".popover.tour-" + this._options.name + " *[data-role=end]").on("click.tour-" + this._options.name, ".popover.tour-" + this._options.name + " *[data-role=end]", function(e) {
  527. e.preventDefault();
  528. return _this.end();
  529. });
  530. return $(document).off("click.tour-" + this._options.name, ".popover.tour-" + this._options.name + " *[data-role=pause-resume]").on("click.tour-" + this._options.name, ".popover.tour-" + this._options.name + " *[data-role=pause-resume]", function(e) {
  531. var $this;
  532. e.preventDefault();
  533. $this = $(this);
  534. $this.text(_this._paused ? $this.data("pause-text") : $this.data("resume-text"));
  535. if (_this._paused) {
  536. return _this.resume();
  537. } else {
  538. return _this.pause();
  539. }
  540. });
  541. };
  542. Tour.prototype._setupKeyboardNavigation = function() {
  543. var _this = this;
  544. if (!this._options.keyboard) {
  545. return;
  546. }
  547. return $(document).on("keyup.tour-" + this._options.name, function(e) {
  548. if (!e.which) {
  549. return;
  550. }
  551. switch (e.which) {
  552. case 39:
  553. e.preventDefault();
  554. if (_this._isLast()) {
  555. return _this.next();
  556. } else {
  557. return _this.end();
  558. }
  559. break;
  560. case 37:
  561. e.preventDefault();
  562. if (_this._current > 0) {
  563. return _this.prev();
  564. }
  565. break;
  566. case 27:
  567. e.preventDefault();
  568. return _this.end();
  569. }
  570. });
  571. };
  572. Tour.prototype._makePromise = function(result) {
  573. if (result && $.isFunction(result.then)) {
  574. return result;
  575. } else {
  576. return null;
  577. }
  578. };
  579. Tour.prototype._callOnPromiseDone = function(promise, cb, arg) {
  580. var _this = this;
  581. if (promise) {
  582. return promise.then(function(e) {
  583. return cb.call(_this, arg);
  584. });
  585. } else {
  586. return cb.call(this, arg);
  587. }
  588. };
  589. Tour.prototype._showBackdrop = function(element) {
  590. if (this.backdrop.backgroundShown) {
  591. return;
  592. }
  593. this.backdrop = $("<div/>", {
  594. "class": "tour-backdrop"
  595. });
  596. this.backdrop.backgroundShown = true;
  597. return $("body").append(this.backdrop);
  598. };
  599. Tour.prototype._hideBackdrop = function() {
  600. this._hideOverlayElement();
  601. return this._hideBackground();
  602. };
  603. Tour.prototype._hideBackground = function() {
  604. this.backdrop.remove();
  605. this.backdrop.overlay = null;
  606. return this.backdrop.backgroundShown = false;
  607. };
  608. Tour.prototype._showOverlayElement = function(element) {
  609. var $background, $element, offset;
  610. if (this.backdrop.overlayElementShown) {
  611. return;
  612. }
  613. this.backdrop.overlayElementShown = true;
  614. $element = $(element);
  615. $background = $("<div/>");
  616. offset = $element.offset();
  617. offset.top = offset.top;
  618. offset.left = offset.left;
  619. $background.width($element.innerWidth()).height($element.innerHeight()).addClass("tour-step-background").offset(offset);
  620. $element.addClass("tour-step-backdrop");
  621. $("body").append($background);
  622. this.backdrop.$element = $element;
  623. return this.backdrop.$background = $background;
  624. };
  625. Tour.prototype._hideOverlayElement = function() {
  626. if (!this.backdrop.overlayElementShown) {
  627. return;
  628. }
  629. this.backdrop.$element.removeClass("tour-step-backdrop");
  630. this.backdrop.$background.remove();
  631. this.backdrop.$element = null;
  632. this.backdrop.$background = null;
  633. return this.backdrop.overlayElementShown = false;
  634. };
  635. Tour.prototype._clearTimer = function() {
  636. window.clearTimeout(this._timer);
  637. this._timer = null;
  638. return this._duration = null;
  639. };
  640. return Tour;
  641. })();
  642. return window.Tour = Tour;
  643. })(jQuery, window);