您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

113 行
3.0 KiB

  1. /* ==========================================================
  2. * bootstrap-alerts.js v1.4.0
  3. * http://twitter.github.com/bootstrap/javascript.html#alerts
  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. /* CSS TRANSITION SUPPORT (https://gist.github.com/373874)
  22. * ======================================================= */
  23. var transitionEnd
  24. $(document).ready(function () {
  25. $.support.transition = (function () {
  26. var thisBody = document.body || document.documentElement
  27. , thisStyle = thisBody.style
  28. , support = thisStyle.transition !== undefined || thisStyle.WebkitTransition !== undefined || thisStyle.MozTransition !== undefined || thisStyle.MsTransition !== undefined || thisStyle.OTransition !== undefined
  29. return support
  30. })()
  31. // set CSS transition event type
  32. if ( $.support.transition ) {
  33. transitionEnd = "TransitionEnd"
  34. if ( $.browser.webkit ) {
  35. transitionEnd = "webkitTransitionEnd"
  36. } else if ( $.browser.mozilla ) {
  37. transitionEnd = "transitionend"
  38. } else if ( $.browser.opera ) {
  39. transitionEnd = "oTransitionEnd"
  40. }
  41. }
  42. })
  43. /* ALERT CLASS DEFINITION
  44. * ====================== */
  45. var Alert = function ( content, options ) {
  46. this.settings = $.extend({}, $.fn.alert.defaults, options)
  47. this.$element = $(content)
  48. .delegate(this.settings.selector, 'click', this.close)
  49. }
  50. Alert.prototype = {
  51. close: function (e) {
  52. var $element = $(this).parent('.alert-message')
  53. e && e.preventDefault()
  54. $element.removeClass('in')
  55. function removeElement () {
  56. $element.remove()
  57. }
  58. $.support.transition && $element.hasClass('fade') ?
  59. $element.bind(transitionEnd, removeElement) :
  60. removeElement()
  61. }
  62. }
  63. /* ALERT PLUGIN DEFINITION
  64. * ======================= */
  65. $.fn.alert = function ( options ) {
  66. if ( options === true ) {
  67. return this.data('alert')
  68. }
  69. return this.each(function () {
  70. var $this = $(this)
  71. if ( typeof options == 'string' ) {
  72. return $this.data('alert')[options]()
  73. }
  74. $(this).data('alert', new Alert( this, options ))
  75. })
  76. }
  77. $.fn.alert.defaults = {
  78. selector: '.close'
  79. }
  80. $(document).ready(function () {
  81. new Alert($('body'), {
  82. selector: '.alert-message[data-alert] .close'
  83. })
  84. })
  85. }( window.jQuery || window.ender );