| 
									
										
										
										
											2013-05-22 10:30:33 +08:00
										 |  |  | /* ======================================================================== | 
					
						
							| 
									
										
										
										
											2013-11-07 04:57:28 +08:00
										 |  |  |  * Bootstrap: button.js v3.0.2 | 
					
						
							| 
									
										
										
										
											2013-10-30 01:10:47 +08:00
										 |  |  |  * http://getbootstrap.com/javascript/#buttons
 | 
					
						
							| 
									
										
										
										
											2013-05-22 10:30:33 +08:00
										 |  |  |  * ======================================================================== | 
					
						
							| 
									
										
										
										
											2013-05-17 02:06:30 +08:00
										 |  |  |  * Copyright 2013 Twitter, Inc. | 
					
						
							| 
									
										
										
										
											2011-11-21 10:19:50 +08:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Licensed under the Apache License, Version 2.0 (the "License"); | 
					
						
							|  |  |  |  * you may not use this file except in compliance with the License. | 
					
						
							|  |  |  |  * You may obtain a copy of the License at | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * http://www.apache.org/licenses/LICENSE-2.0
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Unless required by applicable law or agreed to in writing, software | 
					
						
							|  |  |  |  * distributed under the License is distributed on an "AS IS" BASIS, | 
					
						
							|  |  |  |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
					
						
							|  |  |  |  * See the License for the specific language governing permissions and | 
					
						
							|  |  |  |  * limitations under the License. | 
					
						
							| 
									
										
										
										
											2013-05-22 10:30:33 +08:00
										 |  |  |  * ======================================================================== */ | 
					
						
							| 
									
										
										
										
											2011-11-21 10:19:50 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-25 09:59:04 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-22 10:30:33 +08:00
										 |  |  | +function ($) { "use strict"; | 
					
						
							| 
									
										
										
										
											2012-04-15 07:29:53 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-17 02:06:30 +08:00
										 |  |  |   // BUTTON PUBLIC CLASS DEFINITION
 | 
					
						
							|  |  |  |   // ==============================
 | 
					
						
							| 
									
										
										
										
											2011-11-25 10:55:44 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-15 07:29:53 +08:00
										 |  |  |   var Button = function (element, options) { | 
					
						
							| 
									
										
										
										
											2011-11-25 11:40:25 +08:00
										 |  |  |     this.$element = $(element) | 
					
						
							| 
									
										
										
										
											2013-05-17 02:06:30 +08:00
										 |  |  |     this.options  = $.extend({}, Button.DEFAULTS, options) | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Button.DEFAULTS = { | 
					
						
							|  |  |  |     loadingText: 'loading...' | 
					
						
							| 
									
										
										
										
											2011-11-25 11:40:25 +08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2011-11-25 10:55:44 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-15 07:29:53 +08:00
										 |  |  |   Button.prototype.setState = function (state) { | 
					
						
							| 
									
										
										
										
											2013-05-17 02:06:30 +08:00
										 |  |  |     var d    = 'disabled' | 
					
						
							|  |  |  |     var $el  = this.$element | 
					
						
							|  |  |  |     var val  = $el.is('input') ? 'val' : 'html' | 
					
						
							|  |  |  |     var data = $el.data() | 
					
						
							| 
									
										
										
										
											2011-11-21 10:19:50 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-15 07:29:53 +08:00
										 |  |  |     state = state + 'Text' | 
					
						
							| 
									
										
										
										
											2013-05-17 02:06:30 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (!data.resetText) $el.data('resetText', $el[val]()) | 
					
						
							| 
									
										
										
										
											2011-11-21 10:19:50 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-15 07:29:53 +08:00
										 |  |  |     $el[val](data[state] || this.options[state]) | 
					
						
							| 
									
										
										
										
											2011-11-25 11:40:25 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-15 07:29:53 +08:00
										 |  |  |     // push to event loop to allow forms to submit
 | 
					
						
							|  |  |  |     setTimeout(function () { | 
					
						
							|  |  |  |       state == 'loadingText' ? | 
					
						
							|  |  |  |         $el.addClass(d).attr(d, d) : | 
					
						
							| 
									
										
										
										
											2013-05-17 02:06:30 +08:00
										 |  |  |         $el.removeClass(d).removeAttr(d); | 
					
						
							| 
									
										
										
										
											2012-04-15 07:29:53 +08:00
										 |  |  |     }, 0) | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2011-11-21 10:19:50 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-15 07:29:53 +08:00
										 |  |  |   Button.prototype.toggle = function () { | 
					
						
							| 
									
										
										
										
											2013-07-18 15:59:31 +08:00
										 |  |  |     var $parent = this.$element.closest('[data-toggle="buttons"]') | 
					
						
							| 
									
										
										
										
											2011-11-25 06:43:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-18 15:59:31 +08:00
										 |  |  |     if ($parent.length) { | 
					
						
							| 
									
										
										
										
											2013-08-03 06:13:12 +08:00
										 |  |  |       var $input = this.$element.find('input') | 
					
						
							|  |  |  |         .prop('checked', !this.$element.hasClass('active')) | 
					
						
							|  |  |  |         .trigger('change') | 
					
						
							| 
									
										
										
										
											2013-07-18 15:59:31 +08:00
										 |  |  |       if ($input.prop('type') === 'radio') $parent.find('.active').removeClass('active') | 
					
						
							| 
									
										
										
										
											2013-05-17 02:06:30 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-11-25 06:43:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-15 07:29:53 +08:00
										 |  |  |     this.$element.toggleClass('active') | 
					
						
							| 
									
										
										
										
											2011-11-21 10:19:50 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-25 10:55:44 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-17 02:06:30 +08:00
										 |  |  |   // BUTTON PLUGIN DEFINITION
 | 
					
						
							|  |  |  |   // ========================
 | 
					
						
							| 
									
										
										
										
											2011-11-25 10:55:44 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-08 06:06:01 +08:00
										 |  |  |   var old = $.fn.button | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-15 07:29:53 +08:00
										 |  |  |   $.fn.button = function (option) { | 
					
						
							| 
									
										
										
										
											2011-11-21 10:19:50 +08:00
										 |  |  |     return this.each(function () { | 
					
						
							| 
									
										
										
										
											2013-05-17 02:06:30 +08:00
										 |  |  |       var $this   = $(this) | 
					
						
							| 
									
										
										
										
											2013-07-31 04:31:57 +08:00
										 |  |  |       var data    = $this.data('bs.button') | 
					
						
							| 
									
										
										
										
											2013-05-17 02:06:30 +08:00
										 |  |  |       var options = typeof option == 'object' && option | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-17 11:19:51 +08:00
										 |  |  |       if (!data) $this.data('bs.button', (data = new Button(this, options))) | 
					
						
							| 
									
										
										
										
											2013-05-17 02:06:30 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-25 11:40:25 +08:00
										 |  |  |       if (option == 'toggle') data.toggle() | 
					
						
							|  |  |  |       else if (option) data.setState(option) | 
					
						
							| 
									
										
										
										
											2011-11-21 10:19:50 +08:00
										 |  |  |     }) | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-21 15:28:48 +08:00
										 |  |  |   $.fn.button.Constructor = Button | 
					
						
							| 
									
										
										
										
											2011-11-25 10:55:44 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-17 02:06:30 +08:00
										 |  |  |   // BUTTON NO CONFLICT
 | 
					
						
							|  |  |  |   // ==================
 | 
					
						
							| 
									
										
										
										
											2012-12-08 06:06:01 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   $.fn.button.noConflict = function () { | 
					
						
							|  |  |  |     $.fn.button = old | 
					
						
							|  |  |  |     return this | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-17 02:06:30 +08:00
										 |  |  |   // BUTTON DATA-API
 | 
					
						
							|  |  |  |   // ===============
 | 
					
						
							| 
									
										
										
										
											2011-11-25 10:55:44 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-17 11:19:51 +08:00
										 |  |  |   $(document).on('click.bs.button.data-api', '[data-toggle^=button]', function (e) { | 
					
						
							| 
									
										
										
										
											2012-09-28 06:00:02 +08:00
										 |  |  |     var $btn = $(e.target) | 
					
						
							|  |  |  |     if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') | 
					
						
							|  |  |  |     $btn.button('toggle') | 
					
						
							| 
									
										
										
										
											2013-07-18 16:07:11 +08:00
										 |  |  |     e.preventDefault() | 
					
						
							| 
									
										
										
										
											2011-11-21 10:19:50 +08:00
										 |  |  |   }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-23 02:50:15 +08:00
										 |  |  | }(jQuery); |