Added Bootstrap wizard plug-in
authorThierry Florac <thierry.florac@onf.fr>
Fri, 12 May 2017 13:42:04 +0200
changeset 202 cc928d5f90d5
parent 201 8d9da7dce6ba
child 203 108498416bee
Added Bootstrap wizard plug-in
src/ztfy/myams/resources/js/ext/bootstrap-wizard-1.4.2.js
src/ztfy/myams/resources/js/ext/bootstrap-wizard-1.4.2.min.js
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ztfy/myams/resources/js/ext/bootstrap-wizard-1.4.2.js	Fri May 12 13:42:04 2017 +0200
@@ -0,0 +1,347 @@
+/*!
+ * jQuery twitter bootstrap wizard plugin
+ * Examples and documentation at: http://github.com/VinceG/twitter-bootstrap-wizard
+ * version 1.4.2
+ * Requires jQuery v1.3.2 or later
+ * Supports Bootstrap 2.2.x, 2.3.x, 3.0
+ * Dual licensed under the MIT and GPL licenses:
+ * http://www.opensource.org/licenses/mit-license.php
+ * http://www.gnu.org/licenses/gpl.html
+ * Authors: Vadim Vincent Gabriel (http://vadimg.com), Jason Gill (www.gilluminate.com)
+ */
+;(function($) {
+var bootstrapWizardCreate = function(element, options) {
+	var element = $(element);
+	var obj = this;
+
+	// selector skips any 'li' elements that do not contain a child with a tab data-toggle
+	var baseItemSelector = 'li:has([data-toggle="tab"])';
+	var historyStack = [];
+
+	// Merge options with defaults
+	var $settings = $.extend({}, $.fn.bootstrapWizard.defaults, options);
+	var $activeTab = null;
+	var $navigation = null;
+
+	this.rebindClick = function(selector, fn)
+	{
+		selector.unbind('click', fn).bind('click', fn);
+	}
+
+	this.fixNavigationButtons = function() {
+		// Get the current active tab
+		if(!$activeTab.length) {
+			// Select first one
+			$navigation.find('a:first').tab('show');
+			$activeTab = $navigation.find(baseItemSelector + ':first');
+		}
+
+		// See if we're currently in the first/last then disable the previous and last buttons
+		$($settings.previousSelector, element).toggleClass('disabled', (obj.firstIndex() >= obj.currentIndex()));
+		$($settings.nextSelector, element).toggleClass('disabled', (obj.currentIndex() >= obj.navigationLength()));
+		$($settings.nextSelector, element).toggleClass('hidden', (obj.currentIndex() >= obj.navigationLength() && $($settings.finishSelector, element).length > 0));
+		$($settings.lastSelector, element).toggleClass('hidden', (obj.currentIndex() >= obj.navigationLength() && $($settings.finishSelector, element).length > 0));
+		$($settings.finishSelector, element).toggleClass('hidden', (obj.currentIndex() < obj.navigationLength()));
+		$($settings.backSelector, element).toggleClass('disabled', historyStack.length === 0);
+		$($settings.backSelector, element).toggleClass('hidden', (obj.currentIndex() >= obj.navigationLength() && $($settings.finishSelector, element).length > 0));
+
+		// We are unbinding and rebinding to ensure single firing and no double-click errors
+		obj.rebindClick($($settings.nextSelector, element), obj.next);
+		obj.rebindClick($($settings.previousSelector, element), obj.previous);
+		obj.rebindClick($($settings.lastSelector, element), obj.last);
+		obj.rebindClick($($settings.firstSelector, element), obj.first);
+		obj.rebindClick($($settings.finishSelector, element), obj.finish);
+		obj.rebindClick($($settings.backSelector, element), obj.back);
+
+		if($settings.onTabShow && typeof $settings.onTabShow === 'function' && $settings.onTabShow($activeTab, $navigation, obj.currentIndex())===false){
+			return false;
+		}
+	};
+
+	this.next = function(e) {
+		// If we clicked the last then dont activate this
+		if(element.hasClass('last')) {
+			return false;
+		}
+
+		if($settings.onNext && typeof $settings.onNext === 'function' && $settings.onNext($activeTab, $navigation, obj.nextIndex())===false){
+			return false;
+		}
+
+		var formerIndex = obj.currentIndex();
+		var $index = obj.nextIndex();
+
+	  // Did we click the last button
+		if($index > obj.navigationLength()) {
+		} else {
+		  historyStack.push(formerIndex);
+		  $navigation.find(baseItemSelector + ($settings.withVisible ? ':visible' : '') + ':eq(' + $index + ') a').tab('show');
+		}
+	};
+
+	this.previous = function(e) {
+		// If we clicked the first then dont activate this
+		if(element.hasClass('first')) {
+			return false;
+		}
+
+		if($settings.onPrevious && typeof $settings.onPrevious === 'function' && $settings.onPrevious($activeTab, $navigation, obj.previousIndex())===false){
+			return false;
+		}
+
+		var formerIndex = obj.currentIndex();
+		var $index = obj.previousIndex();
+
+		if($index < 0) {
+		} else {
+		  historyStack.push(formerIndex);
+		  $navigation.find(baseItemSelector + ($settings.withVisible ? ':visible' : '') + ':eq(' + $index + ') a').tab('show');
+		}
+	};
+
+	this.first = function (e) {
+		if($settings.onFirst && typeof $settings.onFirst === 'function' && $settings.onFirst($activeTab, $navigation, obj.firstIndex())===false){
+			return false;
+		}
+
+		// If the element is disabled then we won't do anything
+		if(element.hasClass('disabled')) {
+			return false;
+		}
+
+        
+		historyStack.push(obj.currentIndex());
+		$navigation.find(baseItemSelector + ':eq(0) a').tab('show');
+	};
+
+	this.last = function(e) {
+		if($settings.onLast && typeof $settings.onLast === 'function' && $settings.onLast($activeTab, $navigation, obj.lastIndex())===false){
+			return false;
+		}
+
+		// If the element is disabled then we won't do anything
+		if(element.hasClass('disabled')) {
+			return false;
+		}
+
+		historyStack.push(obj.currentIndex());
+		$navigation.find(baseItemSelector + ':eq(' + obj.navigationLength() + ') a').tab('show');
+	};
+
+	this.finish = function (e) {
+	  if ($settings.onFinish && typeof $settings.onFinish === 'function') {
+	    $settings.onFinish($activeTab, $navigation, obj.lastIndex());
+	  }
+	};
+
+	this.back = function () {
+	  if (historyStack.length == 0) {
+	    return null;
+	  }
+
+	  var formerIndex = historyStack.pop();
+	  if ($settings.onBack && typeof $settings.onBack === 'function' && $settings.onBack($activeTab, $navigation, formerIndex) === false) {
+	    historyStack.push(formerIndex);
+	    return false;
+	  }
+
+	  element.find(baseItemSelector + ':eq(' + formerIndex + ') a').tab('show');
+	};
+
+	this.currentIndex = function() {
+		return $navigation.find(baseItemSelector + ($settings.withVisible ? ':visible' : '')).index($activeTab);
+	};
+
+	this.firstIndex = function() {
+		return 0;
+	};
+
+	this.lastIndex = function() {
+		return obj.navigationLength();
+	};
+	
+	this.getIndex = function(e) {
+		return $navigation.find(baseItemSelector + ($settings.withVisible ? ':visible' : '')).index(e);
+	};
+	
+	this.nextIndex = function() {
+		var nextIndexCandidate=this.currentIndex();
+		var nextTabCandidate=null;
+		do {
+			nextIndexCandidate++;
+			nextTabCandidate = $navigation.find(baseItemSelector + ($settings.withVisible ? ':visible' : '') + ":eq(" + nextIndexCandidate + ")");
+		} while ((nextTabCandidate)&&(nextTabCandidate.hasClass("disabled")));
+		return nextIndexCandidate;
+	};
+	this.previousIndex = function() {
+		var prevIndexCandidate=this.currentIndex();
+		var prevTabCandidate=null;
+		do {
+			prevIndexCandidate--;
+			prevTabCandidate = $navigation.find(baseItemSelector + ($settings.withVisible ? ':visible' : '') + ":eq(" + prevIndexCandidate + ")");
+		} while ((prevTabCandidate)&&(prevTabCandidate.hasClass("disabled")));
+		return prevIndexCandidate;
+	};	
+	this.navigationLength = function() {
+		return $navigation.find(baseItemSelector + ($settings.withVisible ? ':visible' : '')).length - 1;
+	};
+	this.activeTab = function() {
+		return $activeTab;
+	};
+	this.nextTab = function() {
+		return $navigation.find(baseItemSelector + ':eq('+(obj.currentIndex()+1)+')').length ? $navigation.find(baseItemSelector + ':eq('+(obj.currentIndex()+1)+')') : null;
+	};
+	this.previousTab = function() {
+		if(obj.currentIndex() <= 0) {
+			return null;
+		}
+		return $navigation.find(baseItemSelector + ':eq('+parseInt(obj.currentIndex()-1)+')');
+	};
+	this.show = function(index) {
+	  var tabToShow = isNaN(index) ?
+      element.find(baseItemSelector + ' a[href="#' + index + '"]') :
+      element.find(baseItemSelector + ':eq(' + index + ') a');
+	  if (tabToShow.length > 0) {
+	    historyStack.push(obj.currentIndex());
+	    tabToShow.tab('show');
+	  }
+	};
+	this.disable = function (index) {
+		$navigation.find(baseItemSelector + ':eq('+index+')').addClass('disabled');
+	};
+	this.enable = function(index) {
+		$navigation.find(baseItemSelector + ':eq('+index+')').removeClass('disabled');
+	};
+	this.hide = function(index) {
+		$navigation.find(baseItemSelector + ':eq('+index+')').hide();
+	};
+	this.display = function(index) {
+		$navigation.find(baseItemSelector + ':eq('+index+')').show();
+	};
+	this.remove = function(args) {
+		var $index = args[0];
+		var $removeTabPane = typeof args[1] != 'undefined' ? args[1] : false;
+		var $item = $navigation.find(baseItemSelector + ':eq('+$index+')');
+
+		// Remove the tab pane first if needed
+		if($removeTabPane) {
+			var $href = $item.find('a').attr('href');
+			$($href).remove();
+		}
+
+		// Remove menu item
+		$item.remove();
+	};
+
+	var innerTabClick = function (e) {
+		// Get the index of the clicked tab
+		var $ul = $navigation.find(baseItemSelector);
+		var clickedIndex = $ul.index($(e.currentTarget).parent(baseItemSelector));
+		var $clickedTab = $( $ul[clickedIndex] );
+		if($settings.onTabClick && typeof $settings.onTabClick === 'function' && $settings.onTabClick($activeTab, $navigation, obj.currentIndex(), clickedIndex, $clickedTab)===false){
+		    return false;
+		}
+	};
+
+	var innerTabShown = function (e) {  
+		var $element = $(e.target).parent();
+		var nextTab = $navigation.find(baseItemSelector).index($element);
+
+		// If it's disabled then do not change
+		if($element.hasClass('disabled')) {
+			return false;
+		}
+
+		if($settings.onTabChange && typeof $settings.onTabChange === 'function' && $settings.onTabChange($activeTab, $navigation, obj.currentIndex(), nextTab)===false){
+				return false;
+		}
+
+		$activeTab = $element; // activated tab
+		obj.fixNavigationButtons();
+	};
+
+	this.resetWizard = function() {
+
+		// remove the existing handlers
+		$('a[data-toggle="tab"]', $navigation).off('click', innerTabClick);
+		$('a[data-toggle="tab"]', $navigation).off('show show.bs.tab', innerTabShown);
+
+		// reset elements based on current state of the DOM
+		$navigation = element.find('ul:first', element);
+		$activeTab = $navigation.find(baseItemSelector + '.active', element);
+
+		// re-add handlers
+		$('a[data-toggle="tab"]', $navigation).on('click', innerTabClick);
+		$('a[data-toggle="tab"]', $navigation).on('show show.bs.tab', innerTabShown);
+
+		obj.fixNavigationButtons();
+	};
+
+	$navigation = element.find('ul:first', element);
+	$activeTab = $navigation.find(baseItemSelector + '.active', element);
+
+	if(!$navigation.hasClass($settings.tabClass)) {
+		$navigation.addClass($settings.tabClass);
+	}
+
+	// Load onInit
+	if($settings.onInit && typeof $settings.onInit === 'function'){
+		$settings.onInit($activeTab, $navigation, 0);
+	}
+
+	// Load onShow
+	if($settings.onShow && typeof $settings.onShow === 'function'){
+		$settings.onShow($activeTab, $navigation, obj.nextIndex());
+	}
+
+	$('a[data-toggle="tab"]', $navigation).on('click', innerTabClick);
+
+	// attach to both show and show.bs.tab to support Bootstrap versions 2.3.2 and 3.0.0
+	$('a[data-toggle="tab"]', $navigation).on('show show.bs.tab', innerTabShown);
+};
+$.fn.bootstrapWizard = function(options) {
+	//expose methods
+	if (typeof options == 'string') {
+		var args = Array.prototype.slice.call(arguments, 1)
+		if(args.length === 1) {
+			args.toString();
+		}
+		return this.data('bootstrapWizard')[options](args);
+	}
+	return this.each(function(index){
+		var element = $(this);
+		// Return early if this element already has a plugin instance
+		if (element.data('bootstrapWizard')) return;
+		// pass options to plugin constructor
+		var wizard = new bootstrapWizardCreate(element, options);
+		// Store plugin object in this element's data
+		element.data('bootstrapWizard', wizard);
+		// and then trigger initial change
+		wizard.fixNavigationButtons();
+	});
+};
+
+// expose options
+$.fn.bootstrapWizard.defaults = {
+	withVisible:      true,
+	tabClass:         'nav nav-pills',
+	nextSelector:     '.wizard li.next',
+	previousSelector: '.wizard li.previous',
+	firstSelector:    '.wizard li.first',
+	lastSelector:     '.wizard li.last',
+  finishSelector:   '.wizard li.finish',
+	backSelector:     '.wizard li.back',
+	onShow:           null,
+	onInit:           null,
+	onNext:           null,
+	onPrevious:       null,
+	onLast:           null,
+	onFirst:          null,
+  onFinish:         null,
+  onBack:           null,
+	onTabChange:      null,
+	onTabClick:       null,
+	onTabShow:        null
+};
+
+})(jQuery);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ztfy/myams/resources/js/ext/bootstrap-wizard-1.4.2.min.js	Fri May 12 13:42:04 2017 +0200
@@ -0,0 +1,12 @@
+/*
+ * jQuery twitter bootstrap wizard plugin
+ * Examples and documentation at: http://github.com/VinceG/twitter-bootstrap-wizard
+ * version 1.4.2
+ * Requires jQuery v1.3.2 or later
+ * Supports Bootstrap 2.2.x, 2.3.x, 3.0
+ * Dual licensed under the MIT and GPL licenses:
+ * http://www.opensource.org/licenses/mit-license.php
+ * http://www.gnu.org/licenses/gpl.html
+ * Authors: Vadim Vincent Gabriel (http://vadimg.com), Jason Gill (www.gilluminate.com)
+ */
+(function(b){var a=function(f,l){var f=b(f);var e=this;var j='li:has([data-toggle="tab"])';var h=[];var k=b.extend({},b.fn.bootstrapWizard.defaults,l);var g=null;var i=null;this.rebindClick=function(m,n){m.unbind("click",n).bind("click",n)};this.fixNavigationButtons=function(){if(!g.length){i.find("a:first").tab("show");g=i.find(j+":first")}b(k.previousSelector,f).toggleClass("disabled",(e.firstIndex()>=e.currentIndex()));b(k.nextSelector,f).toggleClass("disabled",(e.currentIndex()>=e.navigationLength()));b(k.nextSelector,f).toggleClass("hidden",(e.currentIndex()>=e.navigationLength()&&b(k.finishSelector,f).length>0));b(k.lastSelector,f).toggleClass("hidden",(e.currentIndex()>=e.navigationLength()&&b(k.finishSelector,f).length>0));b(k.finishSelector,f).toggleClass("hidden",(e.currentIndex()<e.navigationLength()));b(k.backSelector,f).toggleClass("disabled",h.length===0);b(k.backSelector,f).toggleClass("hidden",(e.currentIndex()>=e.navigationLength()&&b(k.finishSelector,f).length>0));e.rebindClick(b(k.nextSelector,f),e.next);e.rebindClick(b(k.previousSelector,f),e.previous);e.rebindClick(b(k.lastSelector,f),e.last);e.rebindClick(b(k.firstSelector,f),e.first);e.rebindClick(b(k.finishSelector,f),e.finish);e.rebindClick(b(k.backSelector,f),e.back);if(k.onTabShow&&typeof k.onTabShow==="function"&&k.onTabShow(g,i,e.currentIndex())===false){return false}};this.next=function(n){if(f.hasClass("last")){return false}if(k.onNext&&typeof k.onNext==="function"&&k.onNext(g,i,e.nextIndex())===false){return false}var o=e.currentIndex();var m=e.nextIndex();if(m>e.navigationLength()){}else{h.push(o);i.find(j+(k.withVisible?":visible":"")+":eq("+m+") a").tab("show")}};this.previous=function(n){if(f.hasClass("first")){return false}if(k.onPrevious&&typeof k.onPrevious==="function"&&k.onPrevious(g,i,e.previousIndex())===false){return false}var o=e.currentIndex();var m=e.previousIndex();if(m<0){}else{h.push(o);i.find(j+(k.withVisible?":visible":"")+":eq("+m+") a").tab("show")}};this.first=function(m){if(k.onFirst&&typeof k.onFirst==="function"&&k.onFirst(g,i,e.firstIndex())===false){return false}if(f.hasClass("disabled")){return false}h.push(e.currentIndex());i.find(j+":eq(0) a").tab("show")};this.last=function(m){if(k.onLast&&typeof k.onLast==="function"&&k.onLast(g,i,e.lastIndex())===false){return false}if(f.hasClass("disabled")){return false}h.push(e.currentIndex());i.find(j+":eq("+e.navigationLength()+") a").tab("show")};this.finish=function(m){if(k.onFinish&&typeof k.onFinish==="function"){k.onFinish(g,i,e.lastIndex())}};this.back=function(){if(h.length==0){return null}var m=h.pop();if(k.onBack&&typeof k.onBack==="function"&&k.onBack(g,i,m)===false){h.push(m);return false}f.find(j+":eq("+m+") a").tab("show")};this.currentIndex=function(){return i.find(j+(k.withVisible?":visible":"")).index(g)};this.firstIndex=function(){return 0};this.lastIndex=function(){return e.navigationLength()};this.getIndex=function(m){return i.find(j+(k.withVisible?":visible":"")).index(m)};this.nextIndex=function(){var m=this.currentIndex();var n=null;do{m++;n=i.find(j+(k.withVisible?":visible":"")+":eq("+m+")")}while((n)&&(n.hasClass("disabled")));return m};this.previousIndex=function(){var n=this.currentIndex();var m=null;do{n--;m=i.find(j+(k.withVisible?":visible":"")+":eq("+n+")")}while((m)&&(m.hasClass("disabled")));return n};this.navigationLength=function(){return i.find(j+(k.withVisible?":visible":"")).length-1};this.activeTab=function(){return g};this.nextTab=function(){return i.find(j+":eq("+(e.currentIndex()+1)+")").length?i.find(j+":eq("+(e.currentIndex()+1)+")"):null};this.previousTab=function(){if(e.currentIndex()<=0){return null}return i.find(j+":eq("+parseInt(e.currentIndex()-1)+")")};this.show=function(m){var n=isNaN(m)?f.find(j+' a[href="#'+m+'"]'):f.find(j+":eq("+m+") a");if(n.length>0){h.push(e.currentIndex());n.tab("show")}};this.disable=function(m){i.find(j+":eq("+m+")").addClass("disabled")};this.enable=function(m){i.find(j+":eq("+m+")").removeClass("disabled")};this.hide=function(m){i.find(j+":eq("+m+")").hide()};this.display=function(m){i.find(j+":eq("+m+")").show()};this.remove=function(o){var m=o[0];var p=typeof o[1]!="undefined"?o[1]:false;var n=i.find(j+":eq("+m+")");if(p){var q=n.find("a").attr("href");b(q).remove()}n.remove()};var d=function(p){var m=i.find(j);var n=m.index(b(p.currentTarget).parent(j));var o=b(m[n]);if(k.onTabClick&&typeof k.onTabClick==="function"&&k.onTabClick(g,i,e.currentIndex(),n,o)===false){return false}};var c=function(o){var n=b(o.target).parent();var m=i.find(j).index(n);if(n.hasClass("disabled")){return false}if(k.onTabChange&&typeof k.onTabChange==="function"&&k.onTabChange(g,i,e.currentIndex(),m)===false){return false}g=n;e.fixNavigationButtons()};this.resetWizard=function(){b('a[data-toggle="tab"]',i).off("click",d);b('a[data-toggle="tab"]',i).off("show show.bs.tab",c);i=f.find("ul:first",f);g=i.find(j+".active",f);b('a[data-toggle="tab"]',i).on("click",d);b('a[data-toggle="tab"]',i).on("show show.bs.tab",c);e.fixNavigationButtons()};i=f.find("ul:first",f);g=i.find(j+".active",f);if(!i.hasClass(k.tabClass)){i.addClass(k.tabClass)}if(k.onInit&&typeof k.onInit==="function"){k.onInit(g,i,0)}if(k.onShow&&typeof k.onShow==="function"){k.onShow(g,i,e.nextIndex())}b('a[data-toggle="tab"]',i).on("click",d);b('a[data-toggle="tab"]',i).on("show show.bs.tab",c)};b.fn.bootstrapWizard=function(d){if(typeof d=="string"){var c=Array.prototype.slice.call(arguments,1);if(c.length===1){c.toString()}return this.data("bootstrapWizard")[d](c)}return this.each(function(e){var f=b(this);if(f.data("bootstrapWizard")){return}var g=new a(f,d);f.data("bootstrapWizard",g);g.fixNavigationButtons()})};b.fn.bootstrapWizard.defaults={withVisible:true,tabClass:"nav nav-pills",nextSelector:".wizard li.next",previousSelector:".wizard li.previous",firstSelector:".wizard li.first",lastSelector:".wizard li.last",finishSelector:".wizard li.finish",backSelector:".wizard li.back",onShow:null,onInit:null,onNext:null,onPrevious:null,onLast:null,onFirst:null,onFinish:null,onBack:null,onTabChange:null,onTabClick:null,onTabShow:null}})(jQuery);
\ No newline at end of file