publics.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /**
  2. * Represents a jQuery wizard plugin.
  3. *
  4. * @class steps
  5. * @constructor
  6. * @param [method={}] The name of the method as `String` or an JSON object for initialization
  7. * @param [params=]* {Array} Additional arguments for a method call
  8. * @chainable
  9. **/
  10. $.fn.steps = function (method)
  11. {
  12. if ($.fn.steps[method])
  13. {
  14. return $.fn.steps[method].apply(this, Array.prototype.slice.call(arguments, 1));
  15. }
  16. else if (typeof method === "object" || !method)
  17. {
  18. return initialize.apply(this, arguments);
  19. }
  20. else
  21. {
  22. $.error("Method " + method + " does not exist on jQuery.steps");
  23. }
  24. };
  25. /**
  26. * Adds a new step.
  27. *
  28. * @method add
  29. * @param step {Object} The step object to add
  30. * @chainable
  31. **/
  32. $.fn.steps.add = function (step)
  33. {
  34. var state = getState(this);
  35. return insertStep(this, getOptions(this), state, state.stepCount, step);
  36. };
  37. /**
  38. * Removes the control functionality completely and transforms the current state to the initial HTML structure.
  39. *
  40. * @method destroy
  41. * @chainable
  42. **/
  43. $.fn.steps.destroy = function ()
  44. {
  45. return destroy(this, getOptions(this));
  46. };
  47. /**
  48. * Triggers the onFinishing and onFinished event.
  49. *
  50. * @method finish
  51. **/
  52. $.fn.steps.finish = function ()
  53. {
  54. finishStep(this, getState(this));
  55. };
  56. /**
  57. * Gets the current step index.
  58. *
  59. * @method getCurrentIndex
  60. * @return {Integer} The actual step index (zero-based)
  61. * @for steps
  62. **/
  63. $.fn.steps.getCurrentIndex = function ()
  64. {
  65. return getState(this).currentIndex;
  66. };
  67. /**
  68. * Gets the current step object.
  69. *
  70. * @method getCurrentStep
  71. * @return {Object} The actual step object
  72. **/
  73. $.fn.steps.getCurrentStep = function ()
  74. {
  75. return getStep(this, getState(this).currentIndex);
  76. };
  77. /**
  78. * Gets a specific step object by index.
  79. *
  80. * @method getStep
  81. * @param index {Integer} An integer that belongs to the position of a step
  82. * @return {Object} A specific step object
  83. **/
  84. $.fn.steps.getStep = function (index)
  85. {
  86. return getStep(this, index);
  87. };
  88. /**
  89. * Inserts a new step to a specific position.
  90. *
  91. * @method insert
  92. * @param index {Integer} The position (zero-based) to add
  93. * @param step {Object} The step object to add
  94. * @example
  95. * $("#wizard").steps().insert(0, {
  96. * title: "Title",
  97. * content: "", // optional
  98. * contentMode: "async", // optional
  99. * contentUrl: "/Content/Step/1" // optional
  100. * });
  101. * @chainable
  102. **/
  103. $.fn.steps.insert = function (index, step)
  104. {
  105. return insertStep(this, getOptions(this), getState(this), index, step);
  106. };
  107. /**
  108. * Routes to the next step.
  109. *
  110. * @method next
  111. * @return {Boolean} Indicates whether the action executed
  112. **/
  113. $.fn.steps.next = function ()
  114. {
  115. return goToNextStep(this, getOptions(this), getState(this));
  116. };
  117. /**
  118. * Routes to the previous step.
  119. *
  120. * @method previous
  121. * @return {Boolean} Indicates whether the action executed
  122. **/
  123. $.fn.steps.previous = function ()
  124. {
  125. return goToPreviousStep(this, getOptions(this), getState(this));
  126. };
  127. /**
  128. * Removes a specific step by an given index.
  129. *
  130. * @method remove
  131. * @param index {Integer} The position (zero-based) of the step to remove
  132. * @return Indecates whether the item is removed.
  133. **/
  134. $.fn.steps.remove = function (index)
  135. {
  136. return removeStep(this, getOptions(this), getState(this), index);
  137. };
  138. /**
  139. * Sets a specific step object by index.
  140. *
  141. * @method setStep
  142. * @param index {Integer} An integer that belongs to the position of a step
  143. * @param step {Object} The step object to change
  144. **/
  145. $.fn.steps.setStep = function (index, step)
  146. {
  147. throw new Error("Not yet implemented!");
  148. };
  149. /**
  150. * Skips an certain amount of steps.
  151. *
  152. * @method skip
  153. * @param count {Integer} The amount of steps that should be skipped
  154. * @return {Boolean} Indicates whether the action executed
  155. **/
  156. $.fn.steps.skip = function (count)
  157. {
  158. throw new Error("Not yet implemented!");
  159. };