|
1 | 1 | /*!
|
2 |
| - * jQuery Steps Plugin v0.9.5 - A powerful jQuery wizard plugin that supports accessibility and HTML5 |
| 2 | + * jQuery Steps Plugin v0.9.6b - A powerful jQuery wizard plugin that supports accessibility and HTML5 |
3 | 3 | * https://github.com/rstaib/jquery-steps
|
4 | 4 | *
|
5 | 5 | * Copyright (c) 2013 Rafael J. Staib
|
|
25 | 25 | * - Implement functionality to skip a certain amount of steps
|
26 | 26 | * - Dynamic settings change
|
27 | 27 | * - Dynamic step update
|
| 28 | + * - Save Step State to a cookie |
| 29 | + * - Jump from any page to a specific step |
28 | 30 | *
|
29 | 31 | */
|
30 | 32 |
|
31 | 33 | /**
|
32 | 34 | * @module jQuery.steps
|
33 |
| - * @requires jQuery |
| 35 | + * @requires jQuery (always required), jQuery.cookie (only required if saveState is `true`) |
34 | 36 | */
|
35 | 37 | (function ($)
|
36 | 38 | {
|
|
351 | 353 | forceMoveForward: false,
|
352 | 354 |
|
353 | 355 | /**
|
354 |
| - * The position to start (zero-based). |
| 356 | + * Saves the current state (step position) to a cookie. |
| 357 | + * By coming next time the last active step becomes activated. |
| 358 | + * |
| 359 | + * @property saveState |
| 360 | + * @type Boolean |
| 361 | + * @default false |
| 362 | + * @for defaults |
| 363 | + **/ |
| 364 | + saveState: false, |
| 365 | + |
| 366 | + /** |
| 367 | + * The position to start on (zero-based). |
355 | 368 | *
|
356 | 369 | * @property startIndex
|
357 | 370 | * @type Integer
|
|
365 | 378 | */
|
366 | 379 |
|
367 | 380 | /**
|
368 |
| - * The animation effect which should be used for step transitions. |
| 381 | + * The animation effect which will be used for step transitions. |
369 | 382 | *
|
370 | 383 | * @property transitionEffect
|
371 | 384 | * @type transitionEffect
|
|
375 | 388 | transitionEffect: $.fn.steps.transitionEffect.none,
|
376 | 389 |
|
377 | 390 | /**
|
378 |
| - * The animation speed for step transitions (in milliseconds). |
| 391 | + * Animation speed for step transitions (in milliseconds). |
379 | 392 | *
|
380 | 393 | * @property transitionEffectSpeed
|
381 | 394 | * @type Integer
|
|
1337 | 1350 | * @private
|
1338 | 1351 | * @method getUniqueId
|
1339 | 1352 | * @param wizard {Object} A jQuery wizard object
|
1340 |
| - * @return {String} Returns the unique for the given wizard |
| 1353 | + * @return {String} Returns the unique id for the given wizard |
1341 | 1354 | */
|
1342 | 1355 | function getUniqueId(wizard)
|
1343 | 1356 | {
|
1344 | 1357 | return wizard.data("uid");
|
1345 | 1358 | }
|
1346 | 1359 |
|
| 1360 | + /** |
| 1361 | + * Gets the current unique step id by the given step anchor DOM element. |
| 1362 | + * |
| 1363 | + * @private |
| 1364 | + * @method getUniqueStepId |
| 1365 | + * @param anchor {Object} The step anchor DOM element |
| 1366 | + * @return {String} Returns the unique step id |
| 1367 | + */ |
| 1368 | + function getUniqueStepId(anchor) |
| 1369 | + { |
| 1370 | + return anchor.attr("href").substring(anchor.attr("href").lastIndexOf("#")); |
| 1371 | + } |
| 1372 | + |
| 1373 | + /** |
| 1374 | + * Gets the step position (zero-based) by the given step anchor DOM element. |
| 1375 | + * |
| 1376 | + * @private |
| 1377 | + * @method getStepPosition |
| 1378 | + * @param anchor {Object} The step anchor DOM element |
| 1379 | + * @return {String} Returns the step position |
| 1380 | + */ |
| 1381 | + function getStepPosition(anchor) |
| 1382 | + { |
| 1383 | + return Number(anchor.attr("href").substring(anchor.attr("href").lastIndexOf("-") + 1)); |
| 1384 | + } |
| 1385 | + |
1347 | 1386 | /**
|
1348 | 1387 | * Handles the keyup DOM event.
|
1349 | 1388 | *
|
|
1386 | 1425 |
|
1387 | 1426 | var anchor = $(this),
|
1388 | 1427 | wizard = anchor.parents(".wizard");
|
1389 |
| - switch (anchor.attr("href").substring(anchor.attr("href").lastIndexOf("#"))) |
| 1428 | + switch (getUniqueStepId(anchor)) |
1390 | 1429 | {
|
1391 | 1430 | case "#finish":
|
1392 | 1431 | wizard.steps("finish");
|
|
1420 | 1459 |
|
1421 | 1460 | if (anchor.parent().is(":not(.disabled):not(.current)"))
|
1422 | 1461 | {
|
1423 |
| - goToStep(wizard, Number(anchor.attr("href").substring(anchor.attr("href").lastIndexOf("-") + 1))); |
| 1462 | + goToStep(wizard, getStepPosition(anchor)); |
1424 | 1463 | }
|
1425 | 1464 |
|
1426 | 1465 | // If nothing has changed
|
|
0 commit comments