helium-rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Tatsuo Kaniwa
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # Helium::Rails
2
+
3
+ This gem is a wrapper for Helium Helium CSS framework.
4
+
5
+ https://github.com/cbrauckmuller/helium
6
+
7
+ It vendors stylesheets and javascript library code for use with Rails' asset pipeline (Rails 3.1+).
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'helium-rails'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install helium-rails
22
+
23
+ ## Usage
24
+
25
+ Add it to your Gemfile:
26
+
27
+ group :assets do
28
+ # Your other asset gems (sass-rails, coffee-rails, etc)
29
+
30
+ gem 'helium-rails'
31
+ end
32
+
33
+ Then add this to `app/assets/stylesheets/application.css.scss`:
34
+
35
+ @import "compass";
36
+ @import "helium/master";
37
+
38
+
39
+ ## Contributing
40
+
41
+ 1. Fork it
42
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
43
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
44
+ 4. Push to the branch (`git push origin my-new-feature`)
45
+ 5. Create new Pull Request
@@ -0,0 +1,5 @@
1
+ module Helium
2
+ module Rails
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ require "helium/rails/version"
2
+
3
+ module Helium
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,156 @@
1
+ /* =============================================================
2
+ * bootstrap-collapse.js v2.2.1
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
+
21
+ !function ($) {
22
+
23
+ "use strict"; // jshint ;_;
24
+
25
+
26
+ /* COLLAPSE PUBLIC CLASS DEFINITION
27
+ * ================================ */
28
+
29
+ var Collapse = function (element, options) {
30
+ this.$element = $(element)
31
+ this.options = $.extend({}, $.fn.collapse.defaults, options)
32
+
33
+ if (this.options.parent) {
34
+ this.$parent = $(this.options.parent)
35
+ }
36
+
37
+ this.options.toggle && this.toggle()
38
+ }
39
+
40
+ Collapse.prototype = {
41
+
42
+ constructor: Collapse
43
+
44
+ , dimension: function () {
45
+ var hasWidth = this.$element.hasClass('width')
46
+ return hasWidth ? 'width' : 'height'
47
+ }
48
+
49
+ , show: function () {
50
+ var dimension
51
+ , scroll
52
+ , actives
53
+ , hasData
54
+
55
+ if (this.transitioning) return
56
+
57
+ dimension = this.dimension()
58
+ scroll = $.camelCase(['scroll', dimension].join('-'))
59
+ actives = this.$parent && this.$parent.find('> .accordion-group > .in')
60
+
61
+ if (actives && actives.length) {
62
+ hasData = actives.data('collapse')
63
+ if (hasData && hasData.transitioning) return
64
+ actives.collapse('hide')
65
+ hasData || actives.data('collapse', null)
66
+ }
67
+
68
+ this.$element[dimension](0)
69
+ this.transition('addClass', $.Event('show'), 'shown')
70
+ $.support.transition && this.$element[dimension](this.$element[0][scroll])
71
+ }
72
+
73
+ , hide: function () {
74
+ var dimension
75
+ if (this.transitioning) return
76
+ dimension = this.dimension()
77
+ this.reset(this.$element[dimension]())
78
+ this.transition('removeClass', $.Event('hide'), 'hidden')
79
+ this.$element[dimension](0)
80
+ }
81
+
82
+ , reset: function (size) {
83
+ var dimension = this.dimension()
84
+
85
+ this.$element
86
+ .removeClass('collapse')
87
+ [dimension](size || 'auto')
88
+ [0].offsetWidth
89
+
90
+ this.$element[size !== null ? 'addClass' : 'removeClass']('collapse')
91
+
92
+ return this
93
+ }
94
+
95
+ , transition: function (method, startEvent, completeEvent) {
96
+ var that = this
97
+ , complete = function () {
98
+ if (startEvent.type == 'show') that.reset()
99
+ that.transitioning = 0
100
+ that.$element.trigger(completeEvent)
101
+ }
102
+
103
+ this.$element.trigger(startEvent)
104
+
105
+ if (startEvent.isDefaultPrevented()) return
106
+
107
+ this.transitioning = 1
108
+
109
+ this.$element[method]('in')
110
+
111
+ $.support.transition && this.$element.hasClass('collapse') ?
112
+ this.$element.one($.support.transition.end, complete) :
113
+ complete()
114
+ }
115
+
116
+ , toggle: function () {
117
+ this[this.$element.hasClass('in') ? 'hide' : 'show']()
118
+ }
119
+
120
+ }
121
+
122
+
123
+ /* COLLAPSIBLE PLUGIN DEFINITION
124
+ * ============================== */
125
+
126
+ $.fn.collapse = function (option) {
127
+ return this.each(function () {
128
+ var $this = $(this)
129
+ , data = $this.data('collapse')
130
+ , options = typeof option == 'object' && option
131
+ if (!data) $this.data('collapse', (data = new Collapse(this, options)))
132
+ if (typeof option == 'string') data[option]()
133
+ })
134
+ }
135
+
136
+ $.fn.collapse.defaults = {
137
+ toggle: true
138
+ }
139
+
140
+ $.fn.collapse.Constructor = Collapse
141
+
142
+
143
+ /* COLLAPSIBLE DATA-API
144
+ * ==================== */
145
+
146
+ $(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) {
147
+ var $this = $(this), href
148
+ , target = $this.attr('data-target')
149
+ || e.preventDefault()
150
+ || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
151
+ , option = $(target).data('collapse') ? 'toggle' : $this.data()
152
+ $this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
153
+ $(target).collapse(option)
154
+ })
155
+
156
+ }(window.jQuery);
@@ -0,0 +1,153 @@
1
+ /* ============================================================
2
+ * bootstrap-dropdown.js v2.2.1
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"; // jshint ;_;
24
+
25
+
26
+ /* DROPDOWN CLASS DEFINITION
27
+ * ========================= */
28
+
29
+ var toggle = '[data-toggle=dropdown]'
30
+ , Dropdown = function (element) {
31
+ var $el = $(element).on('click.dropdown.data-api', this.toggle)
32
+ $('html').on('click.dropdown.data-api', function () {
33
+ $el.parent().removeClass('open')
34
+ })
35
+ }
36
+
37
+ Dropdown.prototype = {
38
+
39
+ constructor: Dropdown
40
+
41
+ , toggle: function (e) {
42
+ var $this = $(this)
43
+ , $parent
44
+ , isActive
45
+
46
+ if ($this.is('.disabled, :disabled')) return
47
+
48
+ $parent = getParent($this)
49
+
50
+ isActive = $parent.hasClass('open')
51
+
52
+ clearMenus()
53
+
54
+ if (!isActive) {
55
+ $parent.toggleClass('open')
56
+ $this.focus()
57
+ }
58
+
59
+ return false
60
+ }
61
+
62
+ , keydown: function (e) {
63
+ var $this
64
+ , $items
65
+ , $active
66
+ , $parent
67
+ , isActive
68
+ , index
69
+
70
+ if (!/(38|40|27)/.test(e.keyCode)) return
71
+
72
+ $this = $(this)
73
+
74
+ e.preventDefault()
75
+ e.stopPropagation()
76
+
77
+ if ($this.is('.disabled, :disabled')) return
78
+
79
+ $parent = getParent($this)
80
+
81
+ isActive = $parent.hasClass('open')
82
+
83
+ if (!isActive || (isActive && e.keyCode == 27)) return $this.click()
84
+
85
+ $items = $('[role=menu] li:not(.divider) a', $parent)
86
+
87
+ if (!$items.length) return
88
+
89
+ index = $items.index($items.filter(':focus'))
90
+
91
+ if (e.keyCode == 38 && index > 0) index-- // up
92
+ if (e.keyCode == 40 && index < $items.length - 1) index++ // down
93
+ if (!~index) index = 0
94
+
95
+ $items
96
+ .eq(index)
97
+ .focus()
98
+ }
99
+
100
+ }
101
+
102
+ function clearMenus() {
103
+ $(toggle).each(function () {
104
+ getParent($(this)).removeClass('open')
105
+ })
106
+ }
107
+
108
+ function getParent($this) {
109
+ var selector = $this.attr('data-target')
110
+ , $parent
111
+
112
+ if (!selector) {
113
+ selector = $this.attr('href')
114
+ selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
115
+ }
116
+
117
+ $parent = $(selector)
118
+ $parent.length || ($parent = $this.parent())
119
+
120
+ return $parent
121
+ }
122
+
123
+
124
+ /* DROPDOWN PLUGIN DEFINITION
125
+ * ========================== */
126
+
127
+ $.fn.dropdown = function (option) {
128
+ return this.each(function () {
129
+ var $this = $(this)
130
+ , data = $this.data('dropdown')
131
+ if (!data) $this.data('dropdown', (data = new Dropdown(this)))
132
+ if (typeof option == 'string') data[option].call($this)
133
+ })
134
+ }
135
+
136
+ $.fn.dropdown.Constructor = Dropdown
137
+
138
+
139
+ /* APPLY TO STANDARD DROPDOWN ELEMENTS
140
+ * =================================== */
141
+
142
+ $(function () {
143
+ $('html')
144
+ .on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus)
145
+ $('body')
146
+ .on('click.dropdown', '.dropdown form', function (e) { e.stopPropagation() })
147
+ .on('touchstart.dropdown.data-api', '.dropdown', function (e) { e.stopPropagation() })
148
+ .on('touchstart.dropdown.data-api', '.dropdown-menu', function (e) { e.stopPropagation() })
149
+ .on('click.dropdown.data-api touchstart.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
150
+ .on('keydown.dropdown.data-api touchstart.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
151
+ })
152
+
153
+ }(window.jQuery);
@@ -0,0 +1,18 @@
1
+ /* =========================================================
2
+ * bootstrap-modal.js v2.2.1
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
+ * ========================================================= */!function(e){"use strict";var t=function(t,n){this.options=n;this.$element=e(t).delegate('[data-dismiss="modal"]',"click.dismiss.modal",e.proxy(this.hide,this));this.options.remote&&this.$element.find(".modal-body").load(this.options.remote)};t.prototype={constructor:t,toggle:function(){return this[this.isShown?"hide":"show"]()},show:function(){var t=this,n=e.Event("show");this.$element.trigger(n);if(this.isShown||n.isDefaultPrevented())return;this.isShown=!0;this.escape();this.backdrop(function(){var n=e.support.transition&&t.$element.hasClass("fade");t.$element.parent().length||t.$element.appendTo(document.body);t.$element.show();n&&t.$element[0].offsetWidth;t.$element.addClass("in").attr("aria-hidden",!1);t.enforceFocus();n?t.$element.one(e.support.transition.end,function(){t.$element.focus().trigger("shown")}):t.$element.focus().trigger("shown")})},hide:function(t){t&&t.preventDefault();var n=this;t=e.Event("hide");this.$element.trigger(t);if(!this.isShown||t.isDefaultPrevented())return;this.isShown=!1;this.escape();e(document).off("focusin.modal");this.$element.removeClass("in").attr("aria-hidden",!0);e.support.transition&&this.$element.hasClass("fade")?this.hideWithTransition():this.hideModal()},enforceFocus:function(){var t=this;e(document).on("focusin.modal",function(e){t.$element[0]!==e.target&&!t.$element.has(e.target).length&&t.$element.focus()})},escape:function(){var e=this;this.isShown&&this.options.keyboard?this.$element.on("keyup.dismiss.modal",function(t){t.which==27&&e.hide()}):this.isShown||this.$element.off("keyup.dismiss.modal")},hideWithTransition:function(){var t=this,n=setTimeout(function(){t.$element.off(e.support.transition.end);t.hideModal()},500);this.$element.one(e.support.transition.end,function(){clearTimeout(n);t.hideModal()})},hideModal:function(e){this.$element.hide().trigger("hidden");this.backdrop()},removeBackdrop:function(){this.$backdrop.remove();this.$backdrop=null},backdrop:function(t){var n=this,r=this.$element.hasClass("fade")?"fade":"";if(this.isShown&&this.options.backdrop){var i=e.support.transition&&r;this.$backdrop=e('<div class="modal-backdrop '+r+'" />').appendTo(document.body);this.$backdrop.click(this.options.backdrop=="static"?e.proxy(this.$element[0].focus,this.$element[0]):e.proxy(this.hide,this));i&&this.$backdrop[0].offsetWidth;this.$backdrop.addClass("in");i?this.$backdrop.one(e.support.transition.end,t):t()}else if(!this.isShown&&this.$backdrop){this.$backdrop.removeClass("in");e.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one(e.support.transition.end,e.proxy(this.removeBackdrop,this)):this.removeBackdrop()}else t&&t()}};e.fn.modal=function(n){return this.each(function(){var r=e(this),i=r.data("modal"),s=e.extend({},e.fn.modal.defaults,r.data(),typeof n=="object"&&n);i||r.data("modal",i=new t(this,s));typeof n=="string"?i[n]():s.show&&i.show()})};e.fn.modal.defaults={backdrop:!0,keyboard:!0,show:!0};e.fn.modal.Constructor=t;e(document).on("click.modal.data-api",'[data-toggle="modal"]',function(t){var n=e(this),r=n.attr("href"),i=e(n.attr("data-target")||r&&r.replace(/.*(?=#[^\s]+$)/,"")),s=i.data("modal")?"toggle":e.extend({remote:!/#/.test(r)&&r},i.data(),n.data());t.preventDefault();i.modal(s).one("hide",function(){n.focus()})})}(window.jQuery);
@@ -0,0 +1,234 @@
1
+ /* =========================================================
2
+ * bootstrap-modal.js v2.2.1
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"; // jshint ;_;
24
+
25
+
26
+ /* MODAL CLASS DEFINITION
27
+ * ====================== */
28
+
29
+ var Modal = function (element, options) {
30
+ this.options = options
31
+ this.$element = $(element)
32
+ .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
33
+ this.options.remote && this.$element.find('.modal-body').load(this.options.remote)
34
+ }
35
+
36
+ Modal.prototype = {
37
+
38
+ constructor: Modal
39
+
40
+ , toggle: function () {
41
+ return this[!this.isShown ? 'show' : 'hide']()
42
+ }
43
+
44
+ , show: function () {
45
+ var that = this
46
+ , e = $.Event('show')
47
+
48
+ this.$element.trigger(e)
49
+
50
+ if (this.isShown || e.isDefaultPrevented()) return
51
+
52
+ this.isShown = true
53
+
54
+ this.escape()
55
+
56
+ this.backdrop(function () {
57
+ var transition = $.support.transition && that.$element.hasClass('fade')
58
+
59
+ if (!that.$element.parent().length) {
60
+ that.$element.appendTo(document.body) //don't move modals dom position
61
+ }
62
+
63
+ that.$element
64
+ .show()
65
+
66
+ if (transition) {
67
+ that.$element[0].offsetWidth // force reflow
68
+ }
69
+
70
+ that.$element
71
+ .addClass('in')
72
+ .attr('aria-hidden', false)
73
+
74
+ that.enforceFocus()
75
+
76
+ transition ?
77
+ that.$element.one($.support.transition.end, function () { that.$element.focus().trigger('shown') }) :
78
+ that.$element.focus().trigger('shown')
79
+
80
+ })
81
+ }
82
+
83
+ , hide: function (e) {
84
+ e && e.preventDefault()
85
+
86
+ var that = this
87
+
88
+ e = $.Event('hide')
89
+
90
+ this.$element.trigger(e)
91
+
92
+ if (!this.isShown || e.isDefaultPrevented()) return
93
+
94
+ this.isShown = false
95
+
96
+ this.escape()
97
+
98
+ $(document).off('focusin.modal')
99
+
100
+ this.$element
101
+ .removeClass('in')
102
+ .attr('aria-hidden', true)
103
+
104
+ $.support.transition && this.$element.hasClass('fade') ?
105
+ this.hideWithTransition() :
106
+ this.hideModal()
107
+ }
108
+
109
+ , enforceFocus: function () {
110
+ var that = this
111
+ $(document).on('focusin.modal', function (e) {
112
+ if (that.$element[0] !== e.target && !that.$element.has(e.target).length) {
113
+ that.$element.focus()
114
+ }
115
+ })
116
+ }
117
+
118
+ , escape: function () {
119
+ var that = this
120
+ if (this.isShown && this.options.keyboard) {
121
+ this.$element.on('keyup.dismiss.modal', function ( e ) {
122
+ e.which == 27 && that.hide()
123
+ })
124
+ } else if (!this.isShown) {
125
+ this.$element.off('keyup.dismiss.modal')
126
+ }
127
+ }
128
+
129
+ , hideWithTransition: function () {
130
+ var that = this
131
+ , timeout = setTimeout(function () {
132
+ that.$element.off($.support.transition.end)
133
+ that.hideModal()
134
+ }, 500)
135
+
136
+ this.$element.one($.support.transition.end, function () {
137
+ clearTimeout(timeout)
138
+ that.hideModal()
139
+ })
140
+ }
141
+
142
+ , hideModal: function (that) {
143
+ this.$element
144
+ .hide()
145
+ .trigger('hidden')
146
+
147
+ this.backdrop()
148
+ }
149
+
150
+ , removeBackdrop: function () {
151
+ this.$backdrop.remove()
152
+ this.$backdrop = null
153
+ }
154
+
155
+ , backdrop: function (callback) {
156
+ var that = this
157
+ , animate = this.$element.hasClass('fade') ? 'fade' : ''
158
+
159
+ if (this.isShown && this.options.backdrop) {
160
+ var doAnimate = $.support.transition && animate
161
+
162
+ this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
163
+ .appendTo(document.body)
164
+
165
+ this.$backdrop.click(
166
+ this.options.backdrop == 'static' ?
167
+ $.proxy(this.$element[0].focus, this.$element[0])
168
+ : $.proxy(this.hide, this)
169
+ )
170
+
171
+ if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
172
+
173
+ this.$backdrop.addClass('in')
174
+
175
+ doAnimate ?
176
+ this.$backdrop.one($.support.transition.end, callback) :
177
+ callback()
178
+
179
+ } else if (!this.isShown && this.$backdrop) {
180
+ this.$backdrop.removeClass('in')
181
+
182
+ $.support.transition && this.$element.hasClass('fade')?
183
+ this.$backdrop.one($.support.transition.end, $.proxy(this.removeBackdrop, this)) :
184
+ this.removeBackdrop()
185
+
186
+ } else if (callback) {
187
+ callback()
188
+ }
189
+ }
190
+ }
191
+
192
+
193
+ /* MODAL PLUGIN DEFINITION
194
+ * ======================= */
195
+
196
+ $.fn.modal = function (option) {
197
+ return this.each(function () {
198
+ var $this = $(this)
199
+ , data = $this.data('modal')
200
+ , options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option)
201
+ if (!data) $this.data('modal', (data = new Modal(this, options)))
202
+ if (typeof option == 'string') data[option]()
203
+ else if (options.show) data.show()
204
+ })
205
+ }
206
+
207
+ $.fn.modal.defaults = {
208
+ backdrop: true
209
+ , keyboard: true
210
+ , show: true
211
+ }
212
+
213
+ $.fn.modal.Constructor = Modal
214
+
215
+
216
+ /* MODAL DATA-API
217
+ * ============== */
218
+
219
+ $(document).on('click.modal.data-api', '[data-toggle="modal"]', function (e) {
220
+ var $this = $(this)
221
+ , href = $this.attr('href')
222
+ , $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
223
+ , option = $target.data('modal') ? 'toggle' : $.extend({ remote:!/#/.test(href) && href }, $target.data(), $this.data())
224
+
225
+ e.preventDefault()
226
+
227
+ $target
228
+ .modal(option)
229
+ .one('hide', function () {
230
+ $this.focus()
231
+ })
232
+ })
233
+
234
+ }(window.jQuery);