underoos 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. data/.gitignore +8 -0
  2. data/.rvmrc +1 -0
  3. data/Gemfile +5 -0
  4. data/Gemfile.lock +143 -0
  5. data/LICENSE +26 -0
  6. data/Procfile +1 -0
  7. data/README.md +13 -0
  8. data/Rakefile +12 -0
  9. data/app/assets/javascripts/styleguide.js +132 -0
  10. data/app/assets/javascripts/underoos.js +18 -0
  11. data/app/assets/stylesheets/base/_button-btn-mixin.sass +72 -0
  12. data/app/assets/stylesheets/base/_elements.sass +61 -0
  13. data/app/assets/stylesheets/base/_forms.sass +362 -0
  14. data/app/assets/stylesheets/base/_helpers.sass +54 -0
  15. data/app/assets/stylesheets/base/_normalize.sass +114 -0
  16. data/app/assets/stylesheets/base/_scaffold.sass +51 -0
  17. data/app/assets/stylesheets/base/_tables.sass +99 -0
  18. data/app/assets/stylesheets/base/_transitions.sass +17 -0
  19. data/app/assets/stylesheets/base/_typography.sass +185 -0
  20. data/app/assets/stylesheets/components/_accordions.sass +17 -0
  21. data/app/assets/stylesheets/components/_breadcrumbs.sass +22 -0
  22. data/app/assets/stylesheets/components/_button-groups.sass +46 -0
  23. data/app/assets/stylesheets/components/_carets.sass +24 -0
  24. data/app/assets/stylesheets/components/_carousels.sass +18 -0
  25. data/app/assets/stylesheets/components/_close.sass +25 -0
  26. data/app/assets/stylesheets/components/_decals.sass +27 -0
  27. data/app/assets/stylesheets/components/_dropdowns.sass +85 -0
  28. data/app/assets/stylesheets/components/_media.sass +33 -0
  29. data/app/assets/stylesheets/components/_modals.sass +28 -0
  30. data/app/assets/stylesheets/components/_nav-lists.sass +22 -0
  31. data/app/assets/stylesheets/components/_navbars.sass +105 -0
  32. data/app/assets/stylesheets/components/_notifications.sass +108 -0
  33. data/app/assets/stylesheets/components/_paddles.sass +34 -0
  34. data/app/assets/stylesheets/components/_pagination.sass +41 -0
  35. data/app/assets/stylesheets/components/_pills.sass +64 -0
  36. data/app/assets/stylesheets/components/_popovers.sass +55 -0
  37. data/app/assets/stylesheets/components/_progress-bars.sass +29 -0
  38. data/app/assets/stylesheets/components/_tabs.sass +93 -0
  39. data/app/assets/stylesheets/components/_tooltips.sass +46 -0
  40. data/app/assets/stylesheets/components/_wells.sass +16 -0
  41. data/app/assets/stylesheets/layouts/_containers.sass +15 -0
  42. data/app/assets/stylesheets/layouts/_print.sass +48 -0
  43. data/app/assets/stylesheets/layouts/_queries.sass +121 -0
  44. data/app/assets/stylesheets/layouts/_upgrades.sass +64 -0
  45. data/app/assets/stylesheets/mixins/_arrows.sass +40 -0
  46. data/app/assets/stylesheets/mixins/_clearfixins.sass +15 -0
  47. data/app/assets/stylesheets/mixins/_coloring.sass +6 -0
  48. data/app/assets/stylesheets/mixins/_columns.sass +19 -0
  49. data/app/assets/stylesheets/mixins/_conversions.sass +25 -0
  50. data/app/assets/stylesheets/mixins/_font-size.sass +6 -0
  51. data/app/assets/stylesheets/mixins/_image-tools.sass +13 -0
  52. data/app/assets/stylesheets/mixins/_ir.sass +9 -0
  53. data/app/assets/stylesheets/mixins/_mixins.sass +14 -0
  54. data/app/assets/stylesheets/mixins/_tab-focus.sass +7 -0
  55. data/app/assets/stylesheets/mixins/_timing-equations.sass +29 -0
  56. data/app/assets/stylesheets/mixins/_visibility.sass +43 -0
  57. data/app/assets/stylesheets/polyfills/_box-shadow.sass +7 -0
  58. data/app/assets/stylesheets/polyfills/_box-sizing.sass +8 -0
  59. data/app/assets/stylesheets/polyfills/_functions.sass +22 -0
  60. data/app/assets/stylesheets/polyfills/_inline-block.sass +8 -0
  61. data/app/assets/stylesheets/polyfills/_opacity.sass +6 -0
  62. data/app/assets/stylesheets/polyfills/_polyfills.sass +10 -0
  63. data/app/assets/stylesheets/polyfills/_transition.sass +9 -0
  64. data/app/assets/stylesheets/polyfills/_user-select.sass +8 -0
  65. data/app/assets/stylesheets/styleguide.sass +199 -0
  66. data/app/assets/stylesheets/themes/_default.sass +119 -0
  67. data/app/assets/stylesheets/underoos.sass +52 -0
  68. data/app/controllers/underoos/styleguides_controller.rb +79 -0
  69. data/app/views/shared/_upgrades.html.haml +12 -0
  70. data/app/views/underoos/styleguides/_assets.haml +42 -0
  71. data/app/views/underoos/styleguides/_components.haml +42 -0
  72. data/app/views/underoos/styleguides/_elements.haml +242 -0
  73. data/app/views/underoos/styleguides/_forms.haml +305 -0
  74. data/app/views/underoos/styleguides/_layouts.haml +76 -0
  75. data/app/views/underoos/styleguides/_palettes.haml +18 -0
  76. data/app/views/underoos/styleguides/_resources.haml +27 -0
  77. data/app/views/underoos/styleguides/_tables.haml +124 -0
  78. data/app/views/underoos/styleguides/_typography.haml +284 -0
  79. data/app/views/underoos/styleguides/_utilities.haml +270 -0
  80. data/app/views/underoos/styleguides/components/_accordions.haml +83 -0
  81. data/app/views/underoos/styleguides/components/_breadcrumbs.haml +42 -0
  82. data/app/views/underoos/styleguides/components/_button-groups.haml +162 -0
  83. data/app/views/underoos/styleguides/components/_carets.haml +28 -0
  84. data/app/views/underoos/styleguides/components/_close.haml +20 -0
  85. data/app/views/underoos/styleguides/components/_decals.haml +40 -0
  86. data/app/views/underoos/styleguides/components/_dropdowns.haml +189 -0
  87. data/app/views/underoos/styleguides/components/_media.haml +78 -0
  88. data/app/views/underoos/styleguides/components/_modals.haml +42 -0
  89. data/app/views/underoos/styleguides/components/_nav-lists.haml +52 -0
  90. data/app/views/underoos/styleguides/components/_navbars.haml +144 -0
  91. data/app/views/underoos/styleguides/components/_navs-showcase.haml +27 -0
  92. data/app/views/underoos/styleguides/components/_notifications.haml +169 -0
  93. data/app/views/underoos/styleguides/components/_paddles.haml +68 -0
  94. data/app/views/underoos/styleguides/components/_pagination.haml +64 -0
  95. data/app/views/underoos/styleguides/components/_popovers.haml +33 -0
  96. data/app/views/underoos/styleguides/components/_progress-bars.haml +72 -0
  97. data/app/views/underoos/styleguides/components/_tabs-pills.haml +241 -0
  98. data/app/views/underoos/styleguides/components/_tooltips.haml +37 -0
  99. data/app/views/underoos/styleguides/components/_wells.haml +29 -0
  100. data/app/views/underoos/styleguides/index.html.haml +259 -0
  101. data/app/views/underoos/styleguides/partials/_form-template.haml +171 -0
  102. data/app/views/underoos/styleguides/partials/_table-data.haml +33 -0
  103. data/app/views/underoos/styleguides/partials/_transitions.haml +136 -0
  104. data/config.ru +38 -0
  105. data/config/routes.rb +3 -0
  106. data/features/generator.feature +78 -0
  107. data/features/step_definitions/underoos_steps.rb +3 -0
  108. data/features/support/env.rb +9 -0
  109. data/lib/generators/underoos/assets_generator.rb +33 -0
  110. data/lib/underoos.rb +5 -0
  111. data/lib/underoos/engine.rb +8 -0
  112. data/lib/underoos/version.rb +3 -0
  113. data/public/apple-touch-icon-114x114-precomposed.png +0 -0
  114. data/public/apple-touch-icon-57x57-precomposed.png +0 -0
  115. data/public/apple-touch-icon-72x72-precomposed.png +0 -0
  116. data/public/apple-touch-icon-precomposed.png +0 -0
  117. data/public/apple-touch-icon.png +0 -0
  118. data/public/favicon.ico +0 -0
  119. data/script/javascripts +15 -0
  120. data/underoos.gemspec +29 -0
  121. data/vendor/assets/javascripts/bootstrap-alert.js +94 -0
  122. data/vendor/assets/javascripts/bootstrap-button.js +100 -0
  123. data/vendor/assets/javascripts/bootstrap-collapse.js +138 -0
  124. data/vendor/assets/javascripts/bootstrap-dropdown.js +92 -0
  125. data/vendor/assets/javascripts/bootstrap-modal.js +210 -0
  126. data/vendor/assets/javascripts/bootstrap-popover.js +95 -0
  127. data/vendor/assets/javascripts/bootstrap-scrollspy.js +125 -0
  128. data/vendor/assets/javascripts/bootstrap-tab.js +130 -0
  129. data/vendor/assets/javascripts/bootstrap-tooltip.js +270 -0
  130. data/vendor/assets/javascripts/bootstrap-transition.js +51 -0
  131. data/vendor/assets/javascripts/bootstrap-typeahead.js +271 -0
  132. data/vendor/assets/javascripts/prettify.js +28 -0
  133. metadata +246 -0
@@ -0,0 +1,100 @@
1
+ /* ============================================================
2
+ * bootstrap-button.js v2.0.2
3
+ * http://twitter.github.com/bootstrap/javascript.html#buttons
4
+ * ============================================================
5
+ * Copyright 2012 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
+
20
+ !function( $ ){
21
+
22
+ "use strict"
23
+
24
+ /* BUTTON PUBLIC CLASS DEFINITION
25
+ * ============================== */
26
+
27
+ var Button = function ( element, options ) {
28
+ this.$element = $(element)
29
+ this.options = $.extend({}, $.fn.button.defaults, options)
30
+ }
31
+
32
+ Button.prototype = {
33
+
34
+ constructor: Button
35
+
36
+ , setState: function ( state ) {
37
+ var d = 'disabled'
38
+ , $el = this.$element
39
+ , data = $el.data()
40
+ , val = $el.is('input') ? 'val' : 'html'
41
+
42
+ state = state + 'Text'
43
+ data.resetText || $el.data('resetText', $el[val]())
44
+
45
+ $el[val](data[state] || this.options[state])
46
+
47
+ // push to event loop to allow forms to submit
48
+ setTimeout(function () {
49
+ state == 'loadingText' ?
50
+ $el.addClass(d).attr(d, d) :
51
+ $el.removeClass(d).removeAttr(d)
52
+ }, 0)
53
+ }
54
+
55
+ , toggle: function () {
56
+ var $parent = this.$element.parent('[data-toggle="buttons-radio"]')
57
+
58
+ $parent && $parent
59
+ .find('.active')
60
+ .removeClass('active')
61
+
62
+ this.$element.toggleClass('active')
63
+ }
64
+
65
+ }
66
+
67
+
68
+ /* BUTTON PLUGIN DEFINITION
69
+ * ======================== */
70
+
71
+ $.fn.button = function ( option ) {
72
+ return this.each(function () {
73
+ var $this = $(this)
74
+ , data = $this.data('button')
75
+ , options = typeof option == 'object' && option
76
+ if (!data) $this.data('button', (data = new Button(this, options)))
77
+ if (option == 'toggle') data.toggle()
78
+ else if (option) data.setState(option)
79
+ })
80
+ }
81
+
82
+ $.fn.button.defaults = {
83
+ loadingText: 'loading...'
84
+ }
85
+
86
+ $.fn.button.Constructor = Button
87
+
88
+
89
+ /* BUTTON DATA-API
90
+ * =============== */
91
+
92
+ $(function () {
93
+ $('body').on('click.button.data-api', '[data-toggle^=button]', function ( e ) {
94
+ var $btn = $(e.target)
95
+ if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
96
+ $btn.button('toggle')
97
+ })
98
+ })
99
+
100
+ }( window.jQuery );
@@ -0,0 +1,138 @@
1
+ /* =============================================================
2
+ * bootstrap-collapse.js v2.0.2
3
+ * http://twitter.github.com/bootstrap/javascript.html#collapse
4
+ * =============================================================
5
+ * Copyright 2012 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
+
20
+ !function( $ ){
21
+
22
+ "use strict"
23
+
24
+ var Collapse = function ( element, options ) {
25
+ this.$element = $(element)
26
+ this.options = $.extend({}, $.fn.collapse.defaults, options)
27
+
28
+ if (this.options["parent"]) {
29
+ this.$parent = $(this.options["parent"])
30
+ }
31
+
32
+ this.options.toggle && this.toggle()
33
+ }
34
+
35
+ Collapse.prototype = {
36
+
37
+ constructor: Collapse
38
+
39
+ , dimension: function () {
40
+ var hasWidth = this.$element.hasClass('width')
41
+ return hasWidth ? 'width' : 'height'
42
+ }
43
+
44
+ , show: function () {
45
+ var dimension = this.dimension()
46
+ , scroll = $.camelCase(['scroll', dimension].join('-'))
47
+ , actives = this.$parent && this.$parent.find('.in')
48
+ , hasData
49
+
50
+ if (actives && actives.length) {
51
+ hasData = actives.data('collapse')
52
+ actives.collapse('hide')
53
+ hasData || actives.data('collapse', null)
54
+ }
55
+
56
+ this.$element[dimension](0)
57
+ this.transition('addClass', 'show', 'shown')
58
+ this.$element[dimension](this.$element[0][scroll])
59
+
60
+ }
61
+
62
+ , hide: function () {
63
+ var dimension = this.dimension()
64
+ this.reset(this.$element[dimension]())
65
+ this.transition('removeClass', 'hide', 'hidden')
66
+ this.$element[dimension](0)
67
+ }
68
+
69
+ , reset: function ( size ) {
70
+ var dimension = this.dimension()
71
+
72
+ this.$element
73
+ .removeClass('collapse')
74
+ [dimension](size || 'auto')
75
+ [0].offsetWidth
76
+
77
+ this.$element[size ? 'addClass' : 'removeClass']('collapse')
78
+
79
+ return this
80
+ }
81
+
82
+ , transition: function ( method, startEvent, completeEvent ) {
83
+ var that = this
84
+ , complete = function () {
85
+ if (startEvent == 'show') that.reset()
86
+ that.$element.trigger(completeEvent)
87
+ }
88
+
89
+ this.$element
90
+ .trigger(startEvent)
91
+ [method]('in')
92
+
93
+ $.support.transition && this.$element.hasClass('collapse') ?
94
+ this.$element.one($.support.transition.end, complete) :
95
+ complete()
96
+ }
97
+
98
+ , toggle: function () {
99
+ this[this.$element.hasClass('in') ? 'hide' : 'show']()
100
+ }
101
+
102
+ }
103
+
104
+ /* COLLAPSIBLE PLUGIN DEFINITION
105
+ * ============================== */
106
+
107
+ $.fn.collapse = function ( option ) {
108
+ return this.each(function () {
109
+ var $this = $(this)
110
+ , data = $this.data('collapse')
111
+ , options = typeof option == 'object' && option
112
+ if (!data) $this.data('collapse', (data = new Collapse(this, options)))
113
+ if (typeof option == 'string') data[option]()
114
+ })
115
+ }
116
+
117
+ $.fn.collapse.defaults = {
118
+ toggle: true
119
+ }
120
+
121
+ $.fn.collapse.Constructor = Collapse
122
+
123
+
124
+ /* COLLAPSIBLE DATA-API
125
+ * ==================== */
126
+
127
+ $(function () {
128
+ $('body').on('click.collapse.data-api', '[data-toggle=collapse]', function ( e ) {
129
+ var $this = $(this), href
130
+ , target = $this.attr('data-target')
131
+ || e.preventDefault()
132
+ || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
133
+ , option = $(target).data('collapse') ? 'toggle' : $this.data()
134
+ $(target).collapse(option)
135
+ })
136
+ })
137
+
138
+ }( window.jQuery );
@@ -0,0 +1,92 @@
1
+ /* ============================================================
2
+ * bootstrap-dropdown.js v2.0.2
3
+ * http://twitter.github.com/bootstrap/javascript.html#dropdowns
4
+ * ============================================================
5
+ * Copyright 2012 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
+
20
+
21
+ !function( $ ){
22
+
23
+ "use strict"
24
+
25
+ /* DROPDOWN CLASS DEFINITION
26
+ * ========================= */
27
+
28
+ var toggle = '[data-toggle="dropdown"]'
29
+ , Dropdown = function ( element ) {
30
+ var $el = $(element).on('click.dropdown.data-api', this.toggle)
31
+ $('html').on('click.dropdown.data-api', function () {
32
+ $el.parent().removeClass('open')
33
+ })
34
+ }
35
+
36
+ Dropdown.prototype = {
37
+
38
+ constructor: Dropdown
39
+
40
+ , toggle: function ( e ) {
41
+ var $this = $(this)
42
+ , selector = $this.attr('data-target')
43
+ , $parent
44
+ , isActive
45
+
46
+ if (!selector) {
47
+ selector = $this.attr('href')
48
+ selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
49
+ }
50
+
51
+ $parent = $(selector)
52
+ $parent.length || ($parent = $this.parent())
53
+
54
+ isActive = $parent.hasClass('open')
55
+
56
+ clearMenus()
57
+ !isActive && $parent.toggleClass('open')
58
+
59
+ return false
60
+ }
61
+
62
+ }
63
+
64
+ function clearMenus() {
65
+ $(toggle).parent().removeClass('open')
66
+ }
67
+
68
+
69
+ /* DROPDOWN PLUGIN DEFINITION
70
+ * ========================== */
71
+
72
+ $.fn.dropdown = function ( option ) {
73
+ return this.each(function () {
74
+ var $this = $(this)
75
+ , data = $this.data('dropdown')
76
+ if (!data) $this.data('dropdown', (data = new Dropdown(this)))
77
+ if (typeof option == 'string') data[option].call($this)
78
+ })
79
+ }
80
+
81
+ $.fn.dropdown.Constructor = Dropdown
82
+
83
+
84
+ /* APPLY TO STANDARD DROPDOWN ELEMENTS
85
+ * =================================== */
86
+
87
+ $(function () {
88
+ $('html').on('click.dropdown.data-api', clearMenus)
89
+ $('body').on('click.dropdown.data-api', toggle, Dropdown.prototype.toggle)
90
+ })
91
+
92
+ }( window.jQuery );
@@ -0,0 +1,210 @@
1
+ /* =========================================================
2
+ * bootstrap-modal.js v2.0.2
3
+ * http://twitter.github.com/bootstrap/javascript.html#modals
4
+ * =========================================================
5
+ * Copyright 2012 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
+
20
+
21
+ !function( $ ){
22
+
23
+ "use strict"
24
+
25
+ /* MODAL CLASS DEFINITION
26
+ * ====================== */
27
+
28
+ var Modal = function ( content, options ) {
29
+ this.options = options
30
+ this.$element = $(content)
31
+ .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
32
+ }
33
+
34
+ Modal.prototype = {
35
+
36
+ constructor: Modal
37
+
38
+ , toggle: function () {
39
+ return this[!this.isShown ? 'show' : 'hide']()
40
+ }
41
+
42
+ , show: function () {
43
+ var that = this
44
+
45
+ if (this.isShown) return
46
+
47
+ $('body').addClass('modal-open')
48
+
49
+ this.isShown = true
50
+ this.$element.trigger('show')
51
+
52
+ escape.call(this)
53
+ backdrop.call(this, function () {
54
+ var transition = $.support.transition && that.$element.hasClass('fade')
55
+
56
+ !that.$element.parent().length && that.$element.appendTo(document.body) //don't move modals dom position
57
+
58
+ that.$element
59
+ .show()
60
+
61
+ if (transition) {
62
+ that.$element[0].offsetWidth // force reflow
63
+ }
64
+
65
+ that.$element.addClass('in')
66
+
67
+ transition ?
68
+ that.$element.one($.support.transition.end, function () { that.$element.trigger('shown') }) :
69
+ that.$element.trigger('shown')
70
+
71
+ })
72
+ }
73
+
74
+ , hide: function ( e ) {
75
+ e && e.preventDefault()
76
+
77
+ if (!this.isShown) return
78
+
79
+ var that = this
80
+ this.isShown = false
81
+
82
+ $('body').removeClass('modal-open')
83
+
84
+ escape.call(this)
85
+
86
+ this.$element
87
+ .trigger('hide')
88
+ .removeClass('in')
89
+
90
+ $.support.transition && this.$element.hasClass('fade') ?
91
+ hideWithTransition.call(this) :
92
+ hideModal.call(this)
93
+ }
94
+
95
+ }
96
+
97
+
98
+ /* MODAL PRIVATE METHODS
99
+ * ===================== */
100
+
101
+ function hideWithTransition() {
102
+ var that = this
103
+ , timeout = setTimeout(function () {
104
+ that.$element.off($.support.transition.end)
105
+ hideModal.call(that)
106
+ }, 500)
107
+
108
+ this.$element.one($.support.transition.end, function () {
109
+ clearTimeout(timeout)
110
+ hideModal.call(that)
111
+ })
112
+ }
113
+
114
+ function hideModal( that ) {
115
+ this.$element
116
+ .hide()
117
+ .trigger('hidden')
118
+
119
+ backdrop.call(this)
120
+ }
121
+
122
+ function backdrop( callback ) {
123
+ var that = this
124
+ , animate = this.$element.hasClass('fade') ? 'fade' : ''
125
+
126
+ if (this.isShown && this.options.backdrop) {
127
+ var doAnimate = $.support.transition && animate
128
+
129
+ this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
130
+ .appendTo(document.body)
131
+
132
+ if (this.options.backdrop != 'static') {
133
+ this.$backdrop.click($.proxy(this.hide, this))
134
+ }
135
+
136
+ if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
137
+
138
+ this.$backdrop.addClass('in')
139
+
140
+ doAnimate ?
141
+ this.$backdrop.one($.support.transition.end, callback) :
142
+ callback()
143
+
144
+ } else if (!this.isShown && this.$backdrop) {
145
+ this.$backdrop.removeClass('in')
146
+
147
+ $.support.transition && this.$element.hasClass('fade')?
148
+ this.$backdrop.one($.support.transition.end, $.proxy(removeBackdrop, this)) :
149
+ removeBackdrop.call(this)
150
+
151
+ } else if (callback) {
152
+ callback()
153
+ }
154
+ }
155
+
156
+ function removeBackdrop() {
157
+ this.$backdrop.remove()
158
+ this.$backdrop = null
159
+ }
160
+
161
+ function escape() {
162
+ var that = this
163
+ if (this.isShown && this.options.keyboard) {
164
+ $(document).on('keyup.dismiss.modal', function ( e ) {
165
+ e.which == 27 && that.hide()
166
+ })
167
+ } else if (!this.isShown) {
168
+ $(document).off('keyup.dismiss.modal')
169
+ }
170
+ }
171
+
172
+
173
+ /* MODAL PLUGIN DEFINITION
174
+ * ======================= */
175
+
176
+ $.fn.modal = function ( option ) {
177
+ return this.each(function () {
178
+ var $this = $(this)
179
+ , data = $this.data('modal')
180
+ , options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option)
181
+ if (!data) $this.data('modal', (data = new Modal(this, options)))
182
+ if (typeof option == 'string') data[option]()
183
+ else if (options.show) data.show()
184
+ })
185
+ }
186
+
187
+ $.fn.modal.defaults = {
188
+ backdrop: true
189
+ , keyboard: true
190
+ , show: true
191
+ }
192
+
193
+ $.fn.modal.Constructor = Modal
194
+
195
+
196
+ /* MODAL DATA-API
197
+ * ============== */
198
+
199
+ $(function () {
200
+ $('body').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) {
201
+ var $this = $(this), href
202
+ , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
203
+ , option = $target.data('modal') ? 'toggle' : $.extend({}, $target.data(), $this.data())
204
+
205
+ e.preventDefault()
206
+ $target.modal(option)
207
+ })
208
+ })
209
+
210
+ }( window.jQuery );