You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

62 lines
1.7 KiB

  1. /* ============================================================
  2. * bootstrap-dropdown.js v1.4.0
  3. * http://twitter.github.com/bootstrap/javascript.html#dropdown
  4. * ============================================================
  5. * Copyright 2011 Twitter, Inc.
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. * ============================================================ */
  19. !function( $ ){
  20. "use strict"
  21. function setState(el, state) {
  22. var d = 'disabled'
  23. , $el = $(el)
  24. , data = $el.data()
  25. state = state + 'Text'
  26. data.resetText || $el.data('resetText', $el.html())
  27. $el.html( data[state] || $.fn.button.defaults[state] )
  28. state == 'loadingText' ?
  29. $el.addClass(d).attr(d, d) :
  30. $el.removeClass(d).removeAttr(d)
  31. }
  32. function toggle(el) {
  33. $(el).toggleClass('active')
  34. }
  35. $.fn.button = function(options) {
  36. return this.each(function () {
  37. if (options == 'toggle') {
  38. return toggle(this)
  39. }
  40. options && setState(this, options)
  41. })
  42. }
  43. $.fn.button.defaults = {
  44. loadingText: 'loading...'
  45. }
  46. $(function () {
  47. $('body').delegate('.btn[data-toggle]', 'click', function () {
  48. $(this).button('toggle')
  49. })
  50. })
  51. }( window.jQuery || window.ender );