PageSourceSearch

http://bayalagbuteegch.mn/js/jquery.bootstrap.wizard.js

js bayalagbuteegch.mn collected 2026-10-04 13:28:34 UTC 8,856 bytes, 262 lines download raw bytes

1/*!
2 * jQuery twitter bootstrap wizard plugin
3 * Examples and documentation at: http://github.com/VinceG/twitter-bootstrap-wizard
4 * version 1.0
5 * Requires jQuery v1.3.2 or later
6 * Dual licensed under the MIT and GPL licenses:
7 * http://www.opensource.org/licenses/mit-license.php
8 * http://www.gnu.org/licenses/gpl.html
9 * Authors: Vadim Vincent Gabriel (http://vadimg.com), Jason Gill (www.gilluminate.com)
10 */
11
12;(function($) {
13var bootstrapWizardCreate = function(element, options) {
14  var element = $(element);
15  var obj = this;
16
17  // Merge options with defaults
18  var $settings = $.extend({}, $.fn.bootstrapWizard.defaults, options);
19  var $activeTab = null;
20  var $navigation = null;
21  
22  this.rebindClick = function(selector, fn)
23  {
24    selector.unbind('click', fn).bind('click', fn);
25  }
26
27  this.fixNavigationButtons = function() {
28    // Get the current active tab
29    if(!$activeTab.length) {
30      // Select first one
31      $navigation.find('a:first').tab('show');
32      $activeTab = $navigation.find('li:first');
33    }
34
35    // See if we're currently in the first/last then disable the previous and last buttons
36    $($settings.previousSelector, element).toggleClass('disabled', (obj.firstIndex() >= obj.currentIndex()));
37    $($settings.nextSelector, element).toggleClass('disabled', (obj.currentIndex() >= obj.navigationLength()));
38
39    // We are unbinding and rebinding to ensure single firing and no double-click errors
40    obj.rebindClick($($settings.nextSelector, element), obj.next);
41    obj.rebindClick($($settings.previousSelector, element), obj.previous);
42    obj.rebindClick($($settings.lastSelector, element), obj.last);
43    obj.rebindClick($($settings.firstSelector, element), obj.first);
44
45    if($settings.onTabShow && typeof $settings.onTabShow === 'function' && $settings.onTabShow($activeTab, $navigation, obj.currentIndex())===false){
46      return false;
47    }
48  };
49
50  this.next = function(e) {
51
52      // If we clicked the last then dont activate this
53      if(element.hasClass('last')) {
54          return false;
55      }
56
57      if($settings.onNext && typeof $settings.onNext === 'function' && $settings.onNext($activeTab, $navigation, obj.nextIndex())===false){
58          return false;
59      }
60
61      // Did we click the last button
62      $index = obj.nextIndex();
63      if($index > obj.navigationLength()) {
64      } else {
65          $navigation.find('li:eq('+$index+') a').tab('show');
66    $activeTab = $navigation.find('li.active', element);
67      $($settings.previousSelector, element).toggleClass('disabled', (obj.firstIndex() >= obj.currentIndex()));
68      $($settings.nextSelector, element).toggleClass('disabled', (obj.currentIndex() >= obj.navigationLength()));
69      }
70  };
71
72  this.previous = function(e) {
73
74      // If we clicked the first then dont activate this
75      if(element.hasClass('first')) {
76          return false;
77      }
78
79      if($settings.onPrevious && typeof $settings.onPrevious === 'function' && $settings.onPrevious($activeTab, $navigation, obj.previousIndex())===false){
80          return false;
81      }
82
83      $index = obj.previousIndex();
84      if($index < 0) {
85      } else {
86          $navigation.find('li:eq('+$index+') a').tab('show');
87    $activeTab = $navigation.find('li.active', element);
88      $($settings.previousSelector, element).toggleClass('disabled', (obj.firstIndex() >= obj.currentIndex()));
89      $($settings.nextSelector, element).toggleClass('disabled', (obj.currentIndex() >= obj.navigationLength()));
90      }
91  };
92
93  this.first = function(e) {
94    if($settings.onFirst && typeof $settings.onFirst === 'function' && $settings.onFirst($activeTab, $navigation, obj.firstIndex())===false){
95      return false;
96    }
97
98    // If the element is disabled then we won't do anything
99    if(element.hasClass('disabled')) {
100      return false;
101    }
102    $navigation.find('li:eq(0) a').tab('show');
103
104  };
105  this.last = function(e) {
106    if($settings.onLast && typeof $settings.onLast === 'function' && $settings.onLast($activeTab, $navigation, obj.lastIndex())===false){
107      return false;
108    }
109
110    // If the element is disabled then we won't do anything
111    if(element.hasClass('disabled')) {
112      return false;
113    }
114    $navigation.find('li:eq('+obj.navigationLength()+') a').tab('show');
115  };
116  this.currentIndex = function() {
117    return $navigation.find('li').index($activeTab);
118  };
119  this.firstIndex = function() {
120    return 0;
121  };
122  this.lastIndex = function() {
123    return obj.navigationLength();
124  };
125  this.getIndex = function(e) {
126    return $navigation.find('li').index(e);
127  };
128  this.nextIndex = function() {
129    return $navigation.find('li').index($activeTab) + 1;
130  };
131  this.previousIndex = function() {
132    return $navigation.find('li').index($activeTab) - 1;
133  };
134  this.navigationLength = function() {
135    return $navigation.find('li').length - 1;
136  };
137  this.activeTab = function() {
138    return $activeTab;
139  };
140  this.nextTab = function() {
141    return $navigation.find('li:eq('+(obj.currentIndex()+1)+')').length ? $navigation.find('li:eq('+(obj.currentIndex()+1)+')') : null;
142  };
143  this.previousTab = function() {
144    if(obj.currentIndex() <= 0) {
145      return null;
146    }
147    return $navigation.find('li:eq('+parseInt(obj.currentIndex()-1)+')');
148  };
149  this.show = function(index) {
150    return element.find('li:eq(' + index + ') a').tab('show');
151  };
152  this.disable = function(index) {
153    $navigation.find('li:eq('+index+')').addClass('disabled');
154  };
155  this.enable = function(index) {
156    $navigation.find('li:eq('+index+')').removeClass('disabled');
157  };
158  this.hide = function(index) {
159    $navigation.find('li:eq('+index+')').hide();
160  };
161  this.display = function(index) {
162    $navigation.find('li:eq('+index+')').show();
163  };
164  this.remove = function(args) {
165    var $index = args[0];
166    var $removeTabPane = typeof args[1] != 'undefined' ? args[1] : false;
167    var $item = $navigation.find('li:eq('+$index+')');
168
169    // Remove the tab pane first if needed
170    if($removeTabPane) {
171      var $href = $item.find('a').attr('href');
172      $($href).remove();
173    }
174
175    // Remove menu item
176    $item.remove();
177  };
178
179  $navigation = element.find('ul:first', element);
180  $activeTab = $navigation.find('li.active', element);
181
182  if(!$navigation.hasClass($settings.tabClass)) {
183    $navigation.addClass($settings.tabClass);
184  }
185
186  // Load onInit
187  if($settings.onInit && typeof $settings.onInit === 'function'){
188    $settings.onInit($activeTab, $navigation, 0);
189  }
190
191  // Load onShow
192  if($settings.onShow && typeof $settings.onShow === 'function'){
193    $settings.onShow($activeTab, $navigation, obj.nextIndex());
194  }
195
196  // Work the next/previous buttons
197  obj.fixNavigationButtons();
198
199  $('a[data-toggle="tab"]', $navigation).on('click', function (e) {
200    // Get the index of the clicked tab
201    var clickedIndex = $navigation.find('li').index($(e.currentTarget).parent('li'));
202    if($settings.onTabClick && typeof $settings.onTabClick === 'function' && $settings.onTabClick($activeTab, $navigation, obj.currentIndex(), clickedIndex)===false){
203      return false;
204    }
205  });
206
207  $('a[data-toggle="tab"]', $navigation).on('shown', function (e) {  // use shown instead of show to help prevent double firing
208    $element = $(e.target).parent();
209    var nextTab = $navigation.find('li').index($element);
210
211    // If it's disabled then do not change
212    if($element.hasClass('disabled')) {
213      return false;
214    }
215
216    if($settings.onTabChange && typeof $settings.onTabChange === 'function' && $settings.onTabChange($activeTab, $navigation, obj.currentIndex(), nextTab)===false){
217        return false;
218    }
219
220    $activeTab = $element; // activated tab
221    obj.fixNavigationButtons();
222  });
223};
224$.fn.bootstrapWizard = function(options) {
225  //expose methods
226  if (typeof options == 'string') {
227    var args = Array.prototype.slice.call(arguments, 1)
228    if(args.length === 1) {
229      args.toString();
230    }
231    return this.data('bootstrapWizard')[options](args);
232  }
233  return this.each(function(index){
234    var element = $(this);
235    // Return early if this element already has a plugin instance
236    if (element.data('bootstrapWizard')) return;
237    // pass options to plugin constructor
238    var wizard = new bootstrapWizardCreate(element, options);
239    // Store plugin object in this element's data
240    element.data('bootstrapWizard', wizard);
241  });
242};
243
244// expose options
245$.fn.bootstrapWizard.defaults = {
246  tabClass:         'nav nav-pills',
247  nextSelector:     '.wizard li.next',
248  previousSelector: '.wizard li.previous',
249  firstSelector:    '.wizard li.first',
250  lastSelector:     '.wizard li.last',
251  onShow:           null,
252  onInit:           null,
253  onNext:           null,
254  onPrevious:       null,
255  onLast:           null,
256  onFirst:          null,
257  onTabChange:      null, 
258  onTabClick:       null,
259  onTabShow:        null
260};
261
262})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.