spiderfw 0.6.30 → 0.6.31

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +15 -7
  2. data/CHANGELOG +11 -0
  3. data/VERSION +1 -1
  4. data/apps/app_server/config/options.rb +1 -1
  5. data/apps/core/auth/controllers/login_controller.rb +3 -0
  6. data/apps/core/components/assets.rb +61 -3
  7. data/apps/core/components/public/bootstrap_3/img/glyphicons-halflings-regular.eot +0 -0
  8. data/apps/core/components/public/bootstrap_3/img/glyphicons-halflings-regular.svg +229 -0
  9. data/apps/core/components/public/bootstrap_3/img/glyphicons-halflings-regular.ttf +0 -0
  10. data/apps/core/components/public/bootstrap_3/img/glyphicons-halflings-regular.woff +0 -0
  11. data/apps/core/components/public/bootstrap_3/js/affix.js +140 -0
  12. data/apps/core/components/public/bootstrap_3/js/alert.js +92 -0
  13. data/apps/core/components/public/bootstrap_3/js/button.js +110 -0
  14. data/apps/core/components/public/bootstrap_3/js/carousel.js +210 -0
  15. data/apps/core/components/public/bootstrap_3/js/collapse.js +180 -0
  16. data/apps/core/components/public/bootstrap_3/js/dropdown.js +151 -0
  17. data/apps/core/components/public/bootstrap_3/js/modal.js +277 -0
  18. data/apps/core/components/public/bootstrap_3/js/popover.js +113 -0
  19. data/apps/core/components/public/bootstrap_3/js/scrollspy.js +158 -0
  20. data/apps/core/components/public/bootstrap_3/js/tab.js +128 -0
  21. data/apps/core/components/public/bootstrap_3/js/tooltip.js +456 -0
  22. data/apps/core/components/public/bootstrap_3/js/transition.js +48 -0
  23. data/apps/core/components/public/bootstrap_3/scss/_alerts.scss +67 -0
  24. data/apps/core/components/public/bootstrap_3/scss/_badges.scss +57 -0
  25. data/apps/core/components/public/bootstrap_3/scss/_breadcrumbs.scss +26 -0
  26. data/apps/core/components/public/bootstrap_3/scss/_button-groups.scss +240 -0
  27. data/apps/core/components/public/bootstrap_3/scss/_buttons.scss +159 -0
  28. data/apps/core/components/public/bootstrap_3/scss/_carousel.scss +243 -0
  29. data/apps/core/components/public/bootstrap_3/scss/_close.scss +35 -0
  30. data/apps/core/components/public/bootstrap_3/scss/_code.scss +62 -0
  31. data/apps/core/components/public/bootstrap_3/scss/_component-animations.scss +35 -0
  32. data/apps/core/components/public/bootstrap_3/scss/_dropdowns.scss +214 -0
  33. data/apps/core/components/public/bootstrap_3/scss/_forms.scss +489 -0
  34. data/apps/core/components/public/bootstrap_3/scss/_glyphicons.scss +237 -0
  35. data/apps/core/components/public/bootstrap_3/scss/_grid.scss +84 -0
  36. data/apps/core/components/public/bootstrap_3/scss/_input-groups.scss +166 -0
  37. data/apps/core/components/public/bootstrap_3/scss/_jumbotron.scss +48 -0
  38. data/apps/core/components/public/bootstrap_3/scss/_labels.scss +66 -0
  39. data/apps/core/components/public/bootstrap_3/scss/_list-group.scss +129 -0
  40. data/apps/core/components/public/bootstrap_3/scss/_media.scss +56 -0
  41. data/apps/core/components/public/bootstrap_3/scss/_mixins.scss +39 -0
  42. data/apps/core/components/public/bootstrap_3/scss/_modals.scss +147 -0
  43. data/apps/core/components/public/bootstrap_3/scss/_navbar.scss +658 -0
  44. data/apps/core/components/public/bootstrap_3/scss/_navs.scss +242 -0
  45. data/apps/core/components/public/bootstrap_3/scss/_normalize.scss +425 -0
  46. data/apps/core/components/public/bootstrap_3/scss/_pager.scss +55 -0
  47. data/apps/core/components/public/bootstrap_3/scss/_pagination.scss +88 -0
  48. data/apps/core/components/public/bootstrap_3/scss/_panels.scss +240 -0
  49. data/apps/core/components/public/bootstrap_3/scss/_popovers.scss +133 -0
  50. data/apps/core/components/public/bootstrap_3/scss/_print.scss +101 -0
  51. data/apps/core/components/public/bootstrap_3/scss/_progress-bars.scss +89 -0
  52. data/apps/core/components/public/bootstrap_3/scss/_responsive-embed.scss +34 -0
  53. data/apps/core/components/public/bootstrap_3/scss/_responsive-utilities.scss +174 -0
  54. data/apps/core/components/public/bootstrap_3/scss/_scaffolding.scss +150 -0
  55. data/apps/core/components/public/bootstrap_3/scss/_tables.scss +233 -0
  56. data/apps/core/components/public/bootstrap_3/scss/_theme.scss +247 -0
  57. data/apps/core/components/public/bootstrap_3/scss/_thumbnails.scss +38 -0
  58. data/apps/core/components/public/bootstrap_3/scss/_tooltip.scss +95 -0
  59. data/apps/core/components/public/bootstrap_3/scss/_type.scss +298 -0
  60. data/apps/core/components/public/bootstrap_3/scss/_utilities.scss +56 -0
  61. data/apps/core/components/public/bootstrap_3/scss/_variables.scss +853 -0
  62. data/apps/core/components/public/bootstrap_3/scss/_wells.scss +29 -0
  63. data/apps/core/components/public/bootstrap_3/scss/bootstrap.scss +50 -0
  64. data/apps/core/components/public/bootstrap_3/scss/mixins/_alerts.scss +14 -0
  65. data/apps/core/components/public/bootstrap_3/scss/mixins/_background-variant.scss +11 -0
  66. data/apps/core/components/public/bootstrap_3/scss/mixins/_border-radius.scss +18 -0
  67. data/apps/core/components/public/bootstrap_3/scss/mixins/_buttons.scss +50 -0
  68. data/apps/core/components/public/bootstrap_3/scss/mixins/_center-block.scss +7 -0
  69. data/apps/core/components/public/bootstrap_3/scss/mixins/_clearfix.scss +22 -0
  70. data/apps/core/components/public/bootstrap_3/scss/mixins/_forms.scss +84 -0
  71. data/apps/core/components/public/bootstrap_3/scss/mixins/_gradients.scss +58 -0
  72. data/apps/core/components/public/bootstrap_3/scss/mixins/_grid-framework.scss +87 -0
  73. data/apps/core/components/public/bootstrap_3/scss/mixins/_grid.scss +122 -0
  74. data/apps/core/components/public/bootstrap_3/scss/mixins/_hide-text.scss +21 -0
  75. data/apps/core/components/public/bootstrap_3/scss/mixins/_image.scss +33 -0
  76. data/apps/core/components/public/bootstrap_3/scss/mixins/_labels.scss +12 -0
  77. data/apps/core/components/public/bootstrap_3/scss/mixins/_list-group.scss +31 -0
  78. data/apps/core/components/public/bootstrap_3/scss/mixins/_nav-divider.scss +10 -0
  79. data/apps/core/components/public/bootstrap_3/scss/mixins/_nav-vertical-align.scss +9 -0
  80. data/apps/core/components/public/bootstrap_3/scss/mixins/_opacity.scss +8 -0
  81. data/apps/core/components/public/bootstrap_3/scss/mixins/_pagination.scss +23 -0
  82. data/apps/core/components/public/bootstrap_3/scss/mixins/_panels.scss +20 -0
  83. data/apps/core/components/public/bootstrap_3/scss/mixins/_progress-bar.scss +8 -0
  84. data/apps/core/components/public/bootstrap_3/scss/mixins/_reset-filter.scss +8 -0
  85. data/apps/core/components/public/bootstrap_3/scss/mixins/_resize.scss +6 -0
  86. data/apps/core/components/public/bootstrap_3/scss/mixins/_responsive-visibility.scss +21 -0
  87. data/apps/core/components/public/bootstrap_3/scss/mixins/_size.scss +10 -0
  88. data/apps/core/components/public/bootstrap_3/scss/mixins/_tab-focus.scss +9 -0
  89. data/apps/core/components/public/bootstrap_3/scss/mixins/_table-row.scss +28 -0
  90. data/apps/core/components/public/bootstrap_3/scss/mixins/_text-emphasis.scss +11 -0
  91. data/apps/core/components/public/bootstrap_3/scss/mixins/_text-overflow.scss +8 -0
  92. data/apps/core/components/public/bootstrap_3/scss/mixins/_vendor-prefixes.scss +224 -0
  93. data/apps/core/components/public/js/jquery/plugins/bsmselect/js/jquery.bsmselect.js +1 -1
  94. data/apps/core/components/widgets/month_calendar/month_calendar.shtml +3 -3
  95. data/apps/core/components/widgets/table/table.rb +6 -2
  96. data/apps/core/components/widgets/table/table.shtml +4 -4
  97. data/apps/core/forms/widgets/form/form.rb +1 -1
  98. data/apps/core/forms/widgets/inputs/select/select.rb +13 -2
  99. data/apps/messenger/lib/backends/mobyt.rb +6 -2
  100. data/apps/messenger/lib/backends/skebby.rb +1 -1
  101. data/apps/webdav/controllers/webdav_controller.rb +16 -7
  102. data/lib/spiderfw/controller/http_controller.rb +4 -1
  103. data/lib/spiderfw/env.rb +0 -1
  104. data/lib/spiderfw/http/adapters/rack.rb +3 -1
  105. data/lib/spiderfw/model/base_model.rb +7 -3
  106. data/lib/spiderfw/model/storage/connection_pool.rb +6 -2
  107. data/lib/spiderfw/model/storage/db/db_storage.rb +25 -9
  108. data/lib/spiderfw/site.rb +1 -1
  109. metadata +308 -149
@@ -0,0 +1,92 @@
1
+ /* ========================================================================
2
+ * Bootstrap: alert.js v3.1.1
3
+ * http://getbootstrap.com/javascript/#alerts
4
+ * ========================================================================
5
+ * Copyright 2011-2014 Twitter, Inc.
6
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
7
+ * ======================================================================== */
8
+
9
+
10
+ +function ($) {
11
+ 'use strict';
12
+
13
+ // ALERT CLASS DEFINITION
14
+ // ======================
15
+
16
+ var dismiss = '[data-dismiss="alert"]'
17
+ var Alert = function (el) {
18
+ $(el).on('click', dismiss, this.close)
19
+ }
20
+
21
+ Alert.VERSION = '3.1.1'
22
+
23
+ Alert.prototype.close = function (e) {
24
+ var $this = $(this)
25
+ var selector = $this.attr('data-target')
26
+
27
+ if (!selector) {
28
+ selector = $this.attr('href')
29
+ selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
30
+ }
31
+
32
+ var $parent = $(selector)
33
+
34
+ if (e) e.preventDefault()
35
+
36
+ if (!$parent.length) {
37
+ $parent = $this.hasClass('alert') ? $this : $this.parent()
38
+ }
39
+
40
+ $parent.trigger(e = $.Event('close.bs.alert'))
41
+
42
+ if (e.isDefaultPrevented()) return
43
+
44
+ $parent.removeClass('in')
45
+
46
+ function removeElement() {
47
+ // detach from parent, fire event then clean up data
48
+ $parent.detach().trigger('closed.bs.alert').remove()
49
+ }
50
+
51
+ $.support.transition && $parent.hasClass('fade') ?
52
+ $parent
53
+ .one($.support.transition.end, removeElement)
54
+ .emulateTransitionEnd(150) :
55
+ removeElement()
56
+ }
57
+
58
+
59
+ // ALERT PLUGIN DEFINITION
60
+ // =======================
61
+
62
+ function Plugin(option) {
63
+ return this.each(function () {
64
+ var $this = $(this)
65
+ var data = $this.data('bs.alert')
66
+
67
+ if (!data) $this.data('bs.alert', (data = new Alert(this)))
68
+ if (typeof option == 'string') data[option].call($this)
69
+ })
70
+ }
71
+
72
+ var old = $.fn.alert
73
+
74
+ $.fn.alert = Plugin
75
+ $.fn.alert.Constructor = Alert
76
+
77
+
78
+ // ALERT NO CONFLICT
79
+ // =================
80
+
81
+ $.fn.alert.noConflict = function () {
82
+ $.fn.alert = old
83
+ return this
84
+ }
85
+
86
+
87
+ // ALERT DATA-API
88
+ // ==============
89
+
90
+ $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close)
91
+
92
+ }(jQuery);
@@ -0,0 +1,110 @@
1
+ /* ========================================================================
2
+ * Bootstrap: button.js v3.1.1
3
+ * http://getbootstrap.com/javascript/#buttons
4
+ * ========================================================================
5
+ * Copyright 2011-2014 Twitter, Inc.
6
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
7
+ * ======================================================================== */
8
+
9
+
10
+ +function ($) {
11
+ 'use strict';
12
+
13
+ // BUTTON PUBLIC CLASS DEFINITION
14
+ // ==============================
15
+
16
+ var Button = function (element, options) {
17
+ this.$element = $(element)
18
+ this.options = $.extend({}, Button.DEFAULTS, options)
19
+ this.isLoading = false
20
+ }
21
+
22
+ Button.VERSION = '3.1.1'
23
+
24
+ Button.DEFAULTS = {
25
+ loadingText: 'loading...'
26
+ }
27
+
28
+ Button.prototype.setState = function (state) {
29
+ var d = 'disabled'
30
+ var $el = this.$element
31
+ var val = $el.is('input') ? 'val' : 'html'
32
+ var data = $el.data()
33
+
34
+ state = state + 'Text'
35
+
36
+ if (data.resetText == null) $el.data('resetText', $el[val]())
37
+
38
+ $el[val](data[state] == null ? this.options[state] : data[state])
39
+
40
+ // push to event loop to allow forms to submit
41
+ setTimeout($.proxy(function () {
42
+ if (state == 'loadingText') {
43
+ this.isLoading = true
44
+ $el.addClass(d).attr(d, d)
45
+ } else if (this.isLoading) {
46
+ this.isLoading = false
47
+ $el.removeClass(d).removeAttr(d)
48
+ }
49
+ }, this), 0)
50
+ }
51
+
52
+ Button.prototype.toggle = function () {
53
+ var changed = true
54
+ var $parent = this.$element.closest('[data-toggle="buttons"]')
55
+
56
+ if ($parent.length) {
57
+ var $input = this.$element.find('input')
58
+ if ($input.prop('type') == 'radio') {
59
+ if ($input.prop('checked') && this.$element.hasClass('active')) changed = false
60
+ else $parent.find('.active').removeClass('active')
61
+ }
62
+ if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change')
63
+ }
64
+
65
+ if (changed) this.$element.toggleClass('active')
66
+ }
67
+
68
+
69
+ // BUTTON PLUGIN DEFINITION
70
+ // ========================
71
+
72
+ function Plugin(option) {
73
+ return this.each(function () {
74
+ var $this = $(this)
75
+ var data = $this.data('bs.button')
76
+ var options = typeof option == 'object' && option
77
+
78
+ if (!data) $this.data('bs.button', (data = new Button(this, options)))
79
+
80
+ if (option == 'toggle') data.toggle()
81
+ else if (option) data.setState(option)
82
+ })
83
+ }
84
+
85
+ var old = $.fn.button
86
+
87
+ $.fn.button = Plugin
88
+ $.fn.button.Constructor = Button
89
+
90
+
91
+ // BUTTON NO CONFLICT
92
+ // ==================
93
+
94
+ $.fn.button.noConflict = function () {
95
+ $.fn.button = old
96
+ return this
97
+ }
98
+
99
+
100
+ // BUTTON DATA-API
101
+ // ===============
102
+
103
+ $(document).on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) {
104
+ var $btn = $(e.target)
105
+ if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
106
+ Plugin.call($btn, 'toggle')
107
+ e.preventDefault()
108
+ })
109
+
110
+ }(jQuery);
@@ -0,0 +1,210 @@
1
+ /* ========================================================================
2
+ * Bootstrap: carousel.js v3.1.1
3
+ * http://getbootstrap.com/javascript/#carousel
4
+ * ========================================================================
5
+ * Copyright 2011-2014 Twitter, Inc.
6
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
7
+ * ======================================================================== */
8
+
9
+
10
+ +function ($) {
11
+ 'use strict';
12
+
13
+ // CAROUSEL CLASS DEFINITION
14
+ // =========================
15
+
16
+ var Carousel = function (element, options) {
17
+ this.$element = $(element)
18
+ this.$indicators = this.$element.find('.carousel-indicators')
19
+ this.options = options
20
+ this.paused =
21
+ this.sliding =
22
+ this.interval =
23
+ this.$active =
24
+ this.$items = null
25
+
26
+ this.options.pause == 'hover' && this.$element
27
+ .on('mouseenter', $.proxy(this.pause, this))
28
+ .on('mouseleave', $.proxy(this.cycle, this))
29
+ }
30
+
31
+ Carousel.VERSION = '3.1.1'
32
+
33
+ Carousel.DEFAULTS = {
34
+ interval: 5000,
35
+ pause: 'hover',
36
+ wrap: true
37
+ }
38
+
39
+ Carousel.prototype.cycle = function (e) {
40
+ e || (this.paused = false)
41
+
42
+ this.interval && clearInterval(this.interval)
43
+
44
+ this.options.interval
45
+ && !this.paused
46
+ && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
47
+
48
+ return this
49
+ }
50
+
51
+ Carousel.prototype.getActiveIndex = function () {
52
+ this.$active = this.$element.find('.item.active')
53
+ this.$items = this.$active.parent().children('.item')
54
+
55
+ return this.$items.index(this.$active)
56
+ }
57
+
58
+ Carousel.prototype.to = function (pos) {
59
+ var that = this
60
+ var activeIndex = this.getActiveIndex()
61
+
62
+ if (pos > (this.$items.length - 1) || pos < 0) return
63
+
64
+ if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) // yes, "slid"
65
+ if (activeIndex == pos) return this.pause().cycle()
66
+
67
+ return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos]))
68
+ }
69
+
70
+ Carousel.prototype.pause = function (e) {
71
+ e || (this.paused = true)
72
+
73
+ if (this.$element.find('.next, .prev').length && $.support.transition) {
74
+ this.$element.trigger($.support.transition.end)
75
+ this.cycle(true)
76
+ }
77
+
78
+ this.interval = clearInterval(this.interval)
79
+
80
+ return this
81
+ }
82
+
83
+ Carousel.prototype.next = function () {
84
+ if (this.sliding) return
85
+ return this.slide('next')
86
+ }
87
+
88
+ Carousel.prototype.prev = function () {
89
+ if (this.sliding) return
90
+ return this.slide('prev')
91
+ }
92
+
93
+ Carousel.prototype.slide = function (type, next) {
94
+ var $active = this.$element.find('.item.active')
95
+ var $next = next || $active[type]()
96
+ var isCycling = this.interval
97
+ var direction = type == 'next' ? 'left' : 'right'
98
+ var fallback = type == 'next' ? 'first' : 'last'
99
+ var that = this
100
+
101
+ if (!$next.length) {
102
+ if (!this.options.wrap) return
103
+ $next = this.$element.find('.item')[fallback]()
104
+ }
105
+
106
+ if ($next.hasClass('active')) return this.sliding = false
107
+
108
+ var relatedTarget = $next[0]
109
+ var slideEvent = $.Event('slide.bs.carousel', { relatedTarget: relatedTarget, direction: direction })
110
+ this.$element.trigger(slideEvent)
111
+ if (slideEvent.isDefaultPrevented()) return
112
+
113
+ this.sliding = true
114
+
115
+ isCycling && this.pause()
116
+
117
+ if (this.$indicators.length) {
118
+ this.$indicators.find('.active').removeClass('active')
119
+ this.$element.one('slid.bs.carousel', function () { // yes, "slid"
120
+ var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()])
121
+ $nextIndicator && $nextIndicator.addClass('active')
122
+ })
123
+ }
124
+
125
+ var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid"
126
+ if ($.support.transition && this.$element.hasClass('slide')) {
127
+ $next.addClass(type)
128
+ $next[0].offsetWidth // force reflow
129
+ $active.addClass(direction)
130
+ $next.addClass(direction)
131
+ $active
132
+ .one($.support.transition.end, function () {
133
+ $next.removeClass([type, direction].join(' ')).addClass('active')
134
+ $active.removeClass(['active', direction].join(' '))
135
+ that.sliding = false
136
+ setTimeout(function () { that.$element.trigger(slidEvent) }, 0)
137
+ })
138
+ .emulateTransitionEnd($active.css('transition-duration').slice(0, -1) * 1000)
139
+ } else {
140
+ $active.removeClass('active')
141
+ $next.addClass('active')
142
+ this.sliding = false
143
+ this.$element.trigger(slidEvent)
144
+ }
145
+
146
+ isCycling && this.cycle()
147
+
148
+ return this
149
+ }
150
+
151
+
152
+ // CAROUSEL PLUGIN DEFINITION
153
+ // ==========================
154
+
155
+ function Plugin(option) {
156
+ return this.each(function () {
157
+ var $this = $(this)
158
+ var data = $this.data('bs.carousel')
159
+ var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option)
160
+ var action = typeof option == 'string' ? option : options.slide
161
+
162
+ if (!data) $this.data('bs.carousel', (data = new Carousel(this, options)))
163
+ if (typeof option == 'number') data.to(option)
164
+ else if (action) data[action]()
165
+ else if (options.interval) data.pause().cycle()
166
+ })
167
+ }
168
+
169
+ var old = $.fn.carousel
170
+
171
+ $.fn.carousel = Plugin
172
+ $.fn.carousel.Constructor = Carousel
173
+
174
+
175
+ // CAROUSEL NO CONFLICT
176
+ // ====================
177
+
178
+ $.fn.carousel.noConflict = function () {
179
+ $.fn.carousel = old
180
+ return this
181
+ }
182
+
183
+
184
+ // CAROUSEL DATA-API
185
+ // =================
186
+
187
+ $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
188
+ var $this = $(this), href
189
+ var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
190
+ var options = $.extend({}, $target.data(), $this.data())
191
+ var slideIndex = $this.attr('data-slide-to')
192
+ if (slideIndex) options.interval = false
193
+
194
+ Plugin.call($target, options)
195
+
196
+ if (slideIndex = $this.attr('data-slide-to')) {
197
+ $target.data('bs.carousel').to(slideIndex)
198
+ }
199
+
200
+ e.preventDefault()
201
+ })
202
+
203
+ $(window).on('load', function () {
204
+ $('[data-ride="carousel"]').each(function () {
205
+ var $carousel = $(this)
206
+ Plugin.call($carousel, $carousel.data())
207
+ })
208
+ })
209
+
210
+ }(jQuery);
@@ -0,0 +1,180 @@
1
+ /* ========================================================================
2
+ * Bootstrap: collapse.js v3.1.1
3
+ * http://getbootstrap.com/javascript/#collapse
4
+ * ========================================================================
5
+ * Copyright 2011-2014 Twitter, Inc.
6
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
7
+ * ======================================================================== */
8
+
9
+
10
+ +function ($) {
11
+ 'use strict';
12
+
13
+ // COLLAPSE PUBLIC CLASS DEFINITION
14
+ // ================================
15
+
16
+ var Collapse = function (element, options) {
17
+ this.$element = $(element)
18
+ this.options = $.extend({}, Collapse.DEFAULTS, options)
19
+ this.transitioning = null
20
+
21
+ if (this.options.parent) this.$parent = $(this.options.parent)
22
+ if (this.options.toggle) this.toggle()
23
+ }
24
+
25
+ Collapse.VERSION = '3.1.1'
26
+
27
+ Collapse.DEFAULTS = {
28
+ toggle: true
29
+ }
30
+
31
+ Collapse.prototype.dimension = function () {
32
+ var hasWidth = this.$element.hasClass('width')
33
+ return hasWidth ? 'width' : 'height'
34
+ }
35
+
36
+ Collapse.prototype.show = function () {
37
+ if (this.transitioning || this.$element.hasClass('in')) return
38
+
39
+ var startEvent = $.Event('show.bs.collapse')
40
+ this.$element.trigger(startEvent)
41
+ if (startEvent.isDefaultPrevented()) return
42
+
43
+ var actives = this.$parent && this.$parent.find('> .panel > .in')
44
+
45
+ if (actives && actives.length) {
46
+ var hasData = actives.data('bs.collapse')
47
+ if (hasData && hasData.transitioning) return
48
+ Plugin.call(actives, 'hide')
49
+ hasData || actives.data('bs.collapse', null)
50
+ }
51
+
52
+ var dimension = this.dimension()
53
+
54
+ this.$element
55
+ .removeClass('collapse')
56
+ .addClass('collapsing')[dimension](0)
57
+
58
+ this.transitioning = 1
59
+
60
+ var complete = function (e) {
61
+ if (e && e.target != this.$element[0]) {
62
+ this.$element
63
+ .one($.support.transition.end, $.proxy(complete, this))
64
+ return
65
+ }
66
+ this.$element
67
+ .removeClass('collapsing')
68
+ .addClass('collapse in')[dimension]('')
69
+ this.transitioning = 0
70
+ this.$element
71
+ .off($.support.transition.end + '.bs.collapse')
72
+ .trigger('shown.bs.collapse')
73
+ }
74
+
75
+ if (!$.support.transition) return complete.call(this)
76
+
77
+ var scrollSize = $.camelCase(['scroll', dimension].join('-'))
78
+
79
+ this.$element
80
+ .on($.support.transition.end + '.bs.collapse', $.proxy(complete, this))
81
+ .emulateTransitionEnd(350)[dimension](this.$element[0][scrollSize])
82
+ }
83
+
84
+ Collapse.prototype.hide = function () {
85
+ if (this.transitioning || !this.$element.hasClass('in')) return
86
+
87
+ var startEvent = $.Event('hide.bs.collapse')
88
+ this.$element.trigger(startEvent)
89
+ if (startEvent.isDefaultPrevented()) return
90
+
91
+ var dimension = this.dimension()
92
+
93
+ this.$element[dimension](this.$element[dimension]())[0].offsetHeight
94
+
95
+ this.$element
96
+ .addClass('collapsing')
97
+ .removeClass('collapse')
98
+ .removeClass('in')
99
+
100
+ this.transitioning = 1
101
+
102
+ var complete = function (e) {
103
+ if (e && e.target != this.$element[0]) {
104
+ this.$element
105
+ .one($.support.transition.end, $.proxy(complete, this))
106
+ return
107
+ }
108
+ this.transitioning = 0
109
+ this.$element
110
+ .trigger('hidden.bs.collapse')
111
+ .removeClass('collapsing')
112
+ .addClass('collapse')
113
+ }
114
+
115
+ if (!$.support.transition) return complete.call(this)
116
+
117
+ this.$element
118
+ [dimension](0)
119
+ .one($.support.transition.end, $.proxy(complete, this))
120
+ .emulateTransitionEnd(350)
121
+ }
122
+
123
+ Collapse.prototype.toggle = function () {
124
+ this[this.$element.hasClass('in') ? 'hide' : 'show']()
125
+ }
126
+
127
+
128
+ // COLLAPSE PLUGIN DEFINITION
129
+ // ==========================
130
+
131
+ function Plugin(option) {
132
+ return this.each(function () {
133
+ var $this = $(this)
134
+ var data = $this.data('bs.collapse')
135
+ var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)
136
+
137
+ if (!data && options.toggle && option == 'show') option = !option
138
+ if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
139
+ if (typeof option == 'string') data[option]()
140
+ })
141
+ }
142
+
143
+ var old = $.fn.collapse
144
+
145
+ $.fn.collapse = Plugin
146
+ $.fn.collapse.Constructor = Collapse
147
+
148
+
149
+ // COLLAPSE NO CONFLICT
150
+ // ====================
151
+
152
+ $.fn.collapse.noConflict = function () {
153
+ $.fn.collapse = old
154
+ return this
155
+ }
156
+
157
+
158
+ // COLLAPSE DATA-API
159
+ // =================
160
+
161
+ $(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e) {
162
+ var $this = $(this), href
163
+ var target = $this.attr('data-target')
164
+ || e.preventDefault()
165
+ || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
166
+ var $target = $(target)
167
+ var data = $target.data('bs.collapse')
168
+ var option = data ? 'toggle' : $this.data()
169
+ var parent = $this.attr('data-parent')
170
+ var $parent = parent && $(parent)
171
+
172
+ if (!data || !data.transitioning) {
173
+ if ($parent) $parent.find('[data-toggle="collapse"][data-parent="' + parent + '"]').not($this).addClass('collapsed')
174
+ $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
175
+ }
176
+
177
+ Plugin.call($target, option)
178
+ })
179
+
180
+ }(jQuery);