padrino-admin 0.10.7 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +22 -1
  3. data/lib/padrino-admin.rb +8 -1
  4. data/lib/padrino-admin/access_control.rb +6 -4
  5. data/lib/padrino-admin/bootstrap-less/accordion.less +34 -0
  6. data/lib/padrino-admin/bootstrap-less/alerts.less +98 -0
  7. data/lib/padrino-admin/bootstrap-less/badges.less +58 -0
  8. data/lib/padrino-admin/bootstrap-less/bootstrap.less +62 -0
  9. data/lib/padrino-admin/bootstrap-less/breadcrumbs.less +25 -0
  10. data/lib/padrino-admin/bootstrap-less/button-groups.less +166 -0
  11. data/lib/padrino-admin/bootstrap-less/buttons.less +175 -0
  12. data/lib/padrino-admin/bootstrap-less/carousel.less +192 -0
  13. data/lib/padrino-admin/bootstrap-less/close.less +32 -0
  14. data/lib/padrino-admin/bootstrap-less/code.less +61 -0
  15. data/lib/padrino-admin/bootstrap-less/component-animations.less +32 -0
  16. data/lib/padrino-admin/bootstrap-less/dropdowns.less +223 -0
  17. data/lib/padrino-admin/bootstrap-less/font-awesome-ie7.less +350 -0
  18. data/lib/padrino-admin/bootstrap-less/font-awesome.less +537 -0
  19. data/lib/padrino-admin/bootstrap-less/forms.less +543 -0
  20. data/lib/padrino-admin/bootstrap-less/glyphicons.less +200 -0
  21. data/lib/padrino-admin/bootstrap-less/grid.less +49 -0
  22. data/lib/padrino-admin/bootstrap-less/jumbotron.less +32 -0
  23. data/lib/padrino-admin/bootstrap-less/labels.less +46 -0
  24. data/lib/padrino-admin/bootstrap-less/media.less +54 -0
  25. data/lib/padrino-admin/bootstrap-less/mixins.less +530 -0
  26. data/lib/padrino-admin/bootstrap-less/modals.less +136 -0
  27. data/lib/padrino-admin/bootstrap-less/navbar.less +379 -0
  28. data/lib/padrino-admin/bootstrap-less/navs.less +277 -0
  29. data/lib/padrino-admin/bootstrap-less/normalize.less +396 -0
  30. data/lib/padrino-admin/bootstrap-less/padrino-admin.less +16 -0
  31. data/lib/padrino-admin/bootstrap-less/pager.less +43 -0
  32. data/lib/padrino-admin/bootstrap-less/pagination.less +100 -0
  33. data/lib/padrino-admin/bootstrap-less/popovers.less +133 -0
  34. data/lib/padrino-admin/bootstrap-less/print.less +74 -0
  35. data/lib/padrino-admin/bootstrap-less/progress-bars.less +118 -0
  36. data/lib/padrino-admin/bootstrap-less/responsive-utilities.less +59 -0
  37. data/lib/padrino-admin/bootstrap-less/scaffolding.less +90 -0
  38. data/lib/padrino-admin/bootstrap-less/tables.less +231 -0
  39. data/lib/padrino-admin/bootstrap-less/thumbnails.less +42 -0
  40. data/lib/padrino-admin/bootstrap-less/tooltip.less +71 -0
  41. data/lib/padrino-admin/bootstrap-less/type.less +252 -0
  42. data/lib/padrino-admin/bootstrap-less/utilities.less +42 -0
  43. data/lib/padrino-admin/bootstrap-less/variables.less +316 -0
  44. data/lib/padrino-admin/bootstrap-less/wells.less +29 -0
  45. data/lib/padrino-admin/generators/actions.rb +18 -2
  46. data/lib/padrino-admin/generators/admin_app.rb +38 -26
  47. data/lib/padrino-admin/generators/admin_page.rb +8 -1
  48. data/lib/padrino-admin/generators/orm.rb +58 -11
  49. data/lib/padrino-admin/generators/templates/account/couchrest.rb.tt +1 -1
  50. data/lib/padrino-admin/generators/templates/account/{mini_record.rb.tt → minirecord.rb.tt} +0 -0
  51. data/lib/padrino-admin/generators/templates/account/mongoid.rb.tt +1 -1
  52. data/lib/padrino-admin/generators/templates/account/ohm.rb.tt +61 -0
  53. data/lib/padrino-admin/generators/templates/account/sequel.rb.tt +1 -1
  54. data/lib/padrino-admin/generators/templates/app.rb.tt +36 -29
  55. data/lib/padrino-admin/generators/templates/app/controllers/{base.rb → base.rb.tt} +1 -2
  56. data/lib/padrino-admin/generators/templates/app/controllers/sessions.rb.tt +6 -3
  57. data/lib/padrino-admin/generators/templates/assets/images/favicon.ico +0 -0
  58. data/lib/padrino-admin/generators/templates/assets/images/font/FontAwesome.otf +0 -0
  59. data/lib/padrino-admin/generators/templates/assets/images/font/fontawesome-webfont.eot +0 -0
  60. data/lib/padrino-admin/generators/templates/assets/images/font/fontawesome-webfont.svg +284 -0
  61. data/lib/padrino-admin/generators/templates/assets/images/font/fontawesome-webfont.ttf +0 -0
  62. data/lib/padrino-admin/generators/templates/assets/images/font/fontawesome-webfont.woff +0 -0
  63. data/lib/padrino-admin/generators/templates/assets/images/logo.png +0 -0
  64. data/lib/padrino-admin/generators/templates/assets/javascripts/application.js +117 -0
  65. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/bootstrap-affix.js +117 -0
  66. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/bootstrap-alert.js +99 -0
  67. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/bootstrap-button.js +105 -0
  68. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/bootstrap-carousel.js +207 -0
  69. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/bootstrap-collapse.js +167 -0
  70. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/bootstrap-dropdown.js +165 -0
  71. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/bootstrap-modal.js +251 -0
  72. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/bootstrap-popover.js +114 -0
  73. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/bootstrap-scrollspy.js +162 -0
  74. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/bootstrap-tab.js +144 -0
  75. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/bootstrap-tooltip.js +361 -0
  76. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/bootstrap-transition.js +60 -0
  77. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/bootstrap-typeahead.js +335 -0
  78. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/bootstrap.min.js +6 -0
  79. data/lib/padrino-admin/generators/templates/assets/javascripts/jquery-1.9.0.min.js +4 -0
  80. data/lib/padrino-admin/generators/templates/assets/stylesheets/application.css +346 -0
  81. data/lib/padrino-admin/generators/templates/assets/stylesheets/bootstrap.css +952 -0
  82. data/lib/padrino-admin/generators/templates/erb/app/base/index.erb.tt +13 -15
  83. data/lib/padrino-admin/generators/templates/erb/app/errors/403.erb.tt +3 -0
  84. data/lib/padrino-admin/generators/templates/erb/app/errors/404.erb.tt +3 -0
  85. data/lib/padrino-admin/generators/templates/erb/app/errors/500.erb.tt +3 -0
  86. data/lib/padrino-admin/generators/templates/erb/app/layouts/application.erb.tt +59 -39
  87. data/lib/padrino-admin/generators/templates/erb/app/layouts/error.erb.tt +23 -0
  88. data/lib/padrino-admin/generators/templates/erb/app/sessions/new.erb.tt +41 -53
  89. data/lib/padrino-admin/generators/templates/erb/page/_form.erb.tt +16 -9
  90. data/lib/padrino-admin/generators/templates/erb/page/edit.erb.tt +9 -17
  91. data/lib/padrino-admin/generators/templates/erb/page/index.erb.tt +73 -31
  92. data/lib/padrino-admin/generators/templates/erb/page/new.erb.tt +8 -16
  93. data/lib/padrino-admin/generators/templates/haml/app/base/index.haml.tt +11 -24
  94. data/lib/padrino-admin/generators/templates/haml/app/errors/403.haml.tt +3 -0
  95. data/lib/padrino-admin/generators/templates/haml/app/errors/404.haml.tt +3 -0
  96. data/lib/padrino-admin/generators/templates/haml/app/errors/500.haml.tt +3 -0
  97. data/lib/padrino-admin/generators/templates/haml/app/layouts/application.haml.tt +47 -29
  98. data/lib/padrino-admin/generators/templates/haml/app/layouts/error.haml.tt +18 -0
  99. data/lib/padrino-admin/generators/templates/haml/app/sessions/new.haml.tt +33 -28
  100. data/lib/padrino-admin/generators/templates/haml/page/_form.haml.tt +13 -9
  101. data/lib/padrino-admin/generators/templates/haml/page/edit.haml.tt +7 -14
  102. data/lib/padrino-admin/generators/templates/haml/page/index.haml.tt +56 -27
  103. data/lib/padrino-admin/generators/templates/haml/page/new.haml.tt +6 -13
  104. data/lib/padrino-admin/generators/templates/page/controller.rb.tt +57 -12
  105. data/lib/padrino-admin/generators/templates/slim/app/base/index.slim.tt +11 -24
  106. data/lib/padrino-admin/generators/templates/slim/app/errors/403.slim.tt +3 -0
  107. data/lib/padrino-admin/generators/templates/slim/app/errors/404.slim.tt +3 -0
  108. data/lib/padrino-admin/generators/templates/slim/app/errors/500.slim.tt +3 -0
  109. data/lib/padrino-admin/generators/templates/slim/app/layouts/application.slim.tt +43 -26
  110. data/lib/padrino-admin/generators/templates/slim/app/layouts/error.slim.tt +19 -0
  111. data/lib/padrino-admin/generators/templates/slim/app/sessions/new.slim.tt +31 -27
  112. data/lib/padrino-admin/generators/templates/slim/page/_form.slim.tt +13 -11
  113. data/lib/padrino-admin/generators/templates/slim/page/edit.slim.tt +7 -15
  114. data/lib/padrino-admin/generators/templates/slim/page/index.slim.tt +54 -28
  115. data/lib/padrino-admin/generators/templates/slim/page/new.slim.tt +6 -14
  116. data/lib/padrino-admin/helpers/authentication_helpers.rb +6 -4
  117. data/lib/padrino-admin/helpers/view_helpers.rb +27 -5
  118. data/lib/padrino-admin/locale/admin/cs.yml +53 -13
  119. data/lib/padrino-admin/locale/admin/da.yml +53 -13
  120. data/lib/padrino-admin/locale/admin/de.yml +53 -13
  121. data/lib/padrino-admin/locale/admin/en.yml +53 -13
  122. data/lib/padrino-admin/locale/admin/es.yml +53 -13
  123. data/lib/padrino-admin/locale/admin/fr.yml +53 -13
  124. data/lib/padrino-admin/locale/admin/hu.yml +53 -13
  125. data/lib/padrino-admin/locale/admin/it.yml +53 -13
  126. data/lib/padrino-admin/locale/admin/ja.yml +54 -13
  127. data/lib/padrino-admin/locale/admin/lv.yml +53 -13
  128. data/lib/padrino-admin/locale/admin/nl.yml +53 -13
  129. data/lib/padrino-admin/locale/admin/no.yml +53 -13
  130. data/lib/padrino-admin/locale/admin/pl.yml +53 -13
  131. data/lib/padrino-admin/locale/admin/pt_br.yml +53 -13
  132. data/lib/padrino-admin/locale/admin/ro.yml +53 -13
  133. data/lib/padrino-admin/locale/admin/ru.yml +54 -13
  134. data/lib/padrino-admin/locale/admin/sv.yml +53 -13
  135. data/lib/padrino-admin/locale/admin/tr.yml +53 -13
  136. data/lib/padrino-admin/locale/admin/uk.yml +53 -13
  137. data/lib/padrino-admin/locale/admin/zh_cn.yml +53 -13
  138. data/lib/padrino-admin/locale/admin/zh_tw.yml +53 -13
  139. data/lib/padrino-admin/locale/orm/fr.yml +8 -8
  140. data/padrino-admin.gemspec +2 -0
  141. data/test/fixtures/data_mapper.rb +0 -4
  142. data/test/generators/test_account_model_generator.rb +88 -18
  143. data/test/generators/test_admin_app_generator.rb +120 -165
  144. data/test/generators/test_admin_page_generator.rb +53 -56
  145. data/test/helper.rb +4 -0
  146. data/test/test_admin_application.rb +5 -5
  147. data/test/test_locale.rb +3 -3
  148. metadata +119 -35
  149. data/lib/padrino-admin/generators/templates/assets/stylesheets/base.css +0 -95
  150. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/amro/style.css +0 -364
  151. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/bec-green/style.css +0 -290
  152. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/bec/style.css +0 -301
  153. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/blue/style.css +0 -287
  154. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/default/style.css +0 -373
  155. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/djime-cerulean/style.css +0 -305
  156. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/kathleene/style.css +0 -279
  157. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/olive/style.css +0 -345
  158. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/orange/style.css +0 -269
  159. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/reidb-greenish/style.css +0 -302
  160. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/ruby/style.css +0 -281
  161. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/warehouse/style.css +0 -391
  162. data/lib/padrino-admin/generators/templates/erb/app/base/_sidebar.erb.tt +0 -13
  163. data/lib/padrino-admin/generators/templates/haml/app/base/_sidebar.haml.tt +0 -11
  164. data/lib/padrino-admin/generators/templates/slim/app/base/_sidebar.slim.tt +0 -11
@@ -0,0 +1,114 @@
1
+ /* ===========================================================
2
+ * bootstrap-popover.js v3.0.0
3
+ * http://twitter.github.com/bootstrap/javascript.html#popovers
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
+ /* POPOVER PUBLIC CLASS DEFINITION
27
+ * =============================== */
28
+
29
+ var Popover = function (element, options) {
30
+ this.init('popover', element, options)
31
+ }
32
+
33
+
34
+ /* NOTE: POPOVER EXTENDS BOOTSTRAP-TOOLTIP.js
35
+ ========================================== */
36
+
37
+ Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype, {
38
+
39
+ constructor: Popover
40
+
41
+ , setContent: function () {
42
+ var $tip = this.tip()
43
+ , title = this.getTitle()
44
+ , content = this.getContent()
45
+
46
+ $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
47
+ $tip.find('.popover-content')[this.options.html ? 'html' : 'text'](content)
48
+
49
+ $tip.removeClass('fade top bottom left right in')
50
+ }
51
+
52
+ , hasContent: function () {
53
+ return this.getTitle() || this.getContent()
54
+ }
55
+
56
+ , getContent: function () {
57
+ var content
58
+ , $e = this.$element
59
+ , o = this.options
60
+
61
+ content = (typeof o.content == 'function' ? o.content.call($e[0]) : o.content)
62
+ || $e.attr('data-content')
63
+
64
+ return content
65
+ }
66
+
67
+ , tip: function () {
68
+ if (!this.$tip) {
69
+ this.$tip = $(this.options.template)
70
+ }
71
+ return this.$tip
72
+ }
73
+
74
+ , destroy: function () {
75
+ this.hide().$element.off('.' + this.type).removeData(this.type)
76
+ }
77
+
78
+ })
79
+
80
+
81
+ /* POPOVER PLUGIN DEFINITION
82
+ * ======================= */
83
+
84
+ var old = $.fn.popover
85
+
86
+ $.fn.popover = function (option) {
87
+ return this.each(function () {
88
+ var $this = $(this)
89
+ , data = $this.data('popover')
90
+ , options = typeof option == 'object' && option
91
+ if (!data) $this.data('popover', (data = new Popover(this, options)))
92
+ if (typeof option == 'string') data[option]()
93
+ })
94
+ }
95
+
96
+ $.fn.popover.Constructor = Popover
97
+
98
+ $.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, {
99
+ placement: 'right'
100
+ , trigger: 'click'
101
+ , content: ''
102
+ , template: '<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
103
+ })
104
+
105
+
106
+ /* POPOVER NO CONFLICT
107
+ * =================== */
108
+
109
+ $.fn.popover.noConflict = function () {
110
+ $.fn.popover = old
111
+ return this
112
+ }
113
+
114
+ }(window.jQuery);
@@ -0,0 +1,162 @@
1
+ /* =============================================================
2
+ * bootstrap-scrollspy.js v3.0.0
3
+ * http://twitter.github.com/bootstrap/javascript.html#scrollspy
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
+ /* SCROLLSPY CLASS DEFINITION
27
+ * ========================== */
28
+
29
+ function ScrollSpy(element, options) {
30
+ var process = $.proxy(this.process, this)
31
+ , $element = $(element).is('body') ? $(window) : $(element)
32
+ , href
33
+ this.options = $.extend({}, $.fn.scrollspy.defaults, options)
34
+ this.$scrollElement = $element.on('scroll.scroll-spy.data-api', process)
35
+ this.selector = (this.options.target
36
+ || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
37
+ || '') + ' .nav li > a'
38
+ this.$body = $('body')
39
+ this.refresh()
40
+ this.process()
41
+ }
42
+
43
+ ScrollSpy.prototype = {
44
+
45
+ constructor: ScrollSpy
46
+
47
+ , refresh: function () {
48
+ var self = this
49
+ , $targets
50
+
51
+ this.offsets = $([])
52
+ this.targets = $([])
53
+
54
+ $targets = this.$body
55
+ .find(this.selector)
56
+ .map(function () {
57
+ var $el = $(this)
58
+ , href = $el.data('target') || $el.attr('href')
59
+ , $href = /^#\w/.test(href) && $(href)
60
+ return ( $href
61
+ && $href.length
62
+ && [[ $href.position().top + (!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()), href ]] ) || null
63
+ })
64
+ .sort(function (a, b) { return a[0] - b[0] })
65
+ .each(function () {
66
+ self.offsets.push(this[0])
67
+ self.targets.push(this[1])
68
+ })
69
+ }
70
+
71
+ , process: function () {
72
+ var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
73
+ , scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
74
+ , maxScroll = scrollHeight - this.$scrollElement.height()
75
+ , offsets = this.offsets
76
+ , targets = this.targets
77
+ , activeTarget = this.activeTarget
78
+ , i
79
+
80
+ if (scrollTop >= maxScroll) {
81
+ return activeTarget != (i = targets.last()[0])
82
+ && this.activate ( i )
83
+ }
84
+
85
+ for (i = offsets.length; i--;) {
86
+ activeTarget != targets[i]
87
+ && scrollTop >= offsets[i]
88
+ && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
89
+ && this.activate( targets[i] )
90
+ }
91
+ }
92
+
93
+ , activate: function (target) {
94
+ var active
95
+ , selector
96
+
97
+ this.activeTarget = target
98
+
99
+ $(this.selector)
100
+ .parent('.active')
101
+ .removeClass('active')
102
+
103
+ selector = this.selector
104
+ + '[data-target="' + target + '"],'
105
+ + this.selector + '[href="' + target + '"]'
106
+
107
+ active = $(selector)
108
+ .parent('li')
109
+ .addClass('active')
110
+
111
+ if (active.parent('.dropdown-menu').length) {
112
+ active = active.closest('li.dropdown').addClass('active')
113
+ }
114
+
115
+ active.trigger('activate')
116
+ }
117
+
118
+ }
119
+
120
+
121
+ /* SCROLLSPY PLUGIN DEFINITION
122
+ * =========================== */
123
+
124
+ var old = $.fn.scrollspy
125
+
126
+ $.fn.scrollspy = function (option) {
127
+ return this.each(function () {
128
+ var $this = $(this)
129
+ , data = $this.data('scrollspy')
130
+ , options = typeof option == 'object' && option
131
+ if (!data) $this.data('scrollspy', (data = new ScrollSpy(this, options)))
132
+ if (typeof option == 'string') data[option]()
133
+ })
134
+ }
135
+
136
+ $.fn.scrollspy.Constructor = ScrollSpy
137
+
138
+ $.fn.scrollspy.defaults = {
139
+ offset: 10
140
+ }
141
+
142
+
143
+ /* SCROLLSPY NO CONFLICT
144
+ * ===================== */
145
+
146
+ $.fn.scrollspy.noConflict = function () {
147
+ $.fn.scrollspy = old
148
+ return this
149
+ }
150
+
151
+
152
+ /* SCROLLSPY DATA-API
153
+ * ================== */
154
+
155
+ $(window).on('load', function () {
156
+ $('[data-spy="scroll"]').each(function () {
157
+ var $spy = $(this)
158
+ $spy.scrollspy($spy.data())
159
+ })
160
+ })
161
+
162
+ }(window.jQuery);
@@ -0,0 +1,144 @@
1
+ /* ========================================================
2
+ * bootstrap-tab.js v3.0.0
3
+ * http://twitter.github.com/bootstrap/javascript.html#tabs
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
+ /* TAB CLASS DEFINITION
27
+ * ==================== */
28
+
29
+ var Tab = function (element) {
30
+ this.element = $(element)
31
+ }
32
+
33
+ Tab.prototype = {
34
+
35
+ constructor: Tab
36
+
37
+ , show: function () {
38
+ var $this = this.element
39
+ , $ul = $this.closest('ul:not(.dropdown-menu)')
40
+ , selector = $this.attr('data-target')
41
+ , previous
42
+ , $target
43
+ , e
44
+
45
+ if (!selector) {
46
+ selector = $this.attr('href')
47
+ selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
48
+ }
49
+
50
+ if ( $this.parent('li').hasClass('active') ) return
51
+
52
+ previous = $ul.find('.active:last a')[0]
53
+
54
+ e = $.Event('show', {
55
+ relatedTarget: previous
56
+ })
57
+
58
+ $this.trigger(e)
59
+
60
+ if (e.isDefaultPrevented()) return
61
+
62
+ $target = $(selector)
63
+
64
+ this.activate($this.parent('li'), $ul)
65
+ this.activate($target, $target.parent(), function () {
66
+ $this.trigger({
67
+ type: 'shown'
68
+ , relatedTarget: previous
69
+ })
70
+ })
71
+ }
72
+
73
+ , activate: function ( element, container, callback) {
74
+ var $active = container.find('> .active')
75
+ , transition = callback
76
+ && $.support.transition
77
+ && $active.hasClass('fade')
78
+
79
+ function next() {
80
+ $active
81
+ .removeClass('active')
82
+ .find('> .dropdown-menu > .active')
83
+ .removeClass('active')
84
+
85
+ element.addClass('active')
86
+
87
+ if (transition) {
88
+ element[0].offsetWidth // reflow for transition
89
+ element.addClass('in')
90
+ } else {
91
+ element.removeClass('fade')
92
+ }
93
+
94
+ if ( element.parent('.dropdown-menu') ) {
95
+ element.closest('li.dropdown').addClass('active')
96
+ }
97
+
98
+ callback && callback()
99
+ }
100
+
101
+ transition ?
102
+ $active.one($.support.transition.end, next) :
103
+ next()
104
+
105
+ $active.removeClass('in')
106
+ }
107
+ }
108
+
109
+
110
+ /* TAB PLUGIN DEFINITION
111
+ * ===================== */
112
+
113
+ var old = $.fn.tab
114
+
115
+ $.fn.tab = function ( option ) {
116
+ return this.each(function () {
117
+ var $this = $(this)
118
+ , data = $this.data('tab')
119
+ if (!data) $this.data('tab', (data = new Tab(this)))
120
+ if (typeof option == 'string') data[option]()
121
+ })
122
+ }
123
+
124
+ $.fn.tab.Constructor = Tab
125
+
126
+
127
+ /* TAB NO CONFLICT
128
+ * =============== */
129
+
130
+ $.fn.tab.noConflict = function () {
131
+ $.fn.tab = old
132
+ return this
133
+ }
134
+
135
+
136
+ /* TAB DATA-API
137
+ * ============ */
138
+
139
+ $(document).on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
140
+ e.preventDefault()
141
+ $(this).tab('show')
142
+ })
143
+
144
+ }(window.jQuery);
@@ -0,0 +1,361 @@
1
+ /* ===========================================================
2
+ * bootstrap-tooltip.js v3.0.0
3
+ * http://twitter.github.com/bootstrap/javascript.html#tooltips
4
+ * Inspired by the original jQuery.tipsy by Jason Frame
5
+ * ===========================================================
6
+ * Copyright 2012 Twitter, Inc.
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ * ========================================================== */
20
+
21
+
22
+ !function ($) {
23
+
24
+ "use strict"; // jshint ;_;
25
+
26
+
27
+ /* TOOLTIP PUBLIC CLASS DEFINITION
28
+ * =============================== */
29
+
30
+ var Tooltip = function (element, options) {
31
+ this.init('tooltip', element, options)
32
+ }
33
+
34
+ Tooltip.prototype = {
35
+
36
+ constructor: Tooltip
37
+
38
+ , init: function (type, element, options) {
39
+ var eventIn
40
+ , eventOut
41
+ , triggers
42
+ , trigger
43
+ , i
44
+
45
+ this.type = type
46
+ this.$element = $(element)
47
+ this.options = this.getOptions(options)
48
+ this.enabled = true
49
+
50
+ triggers = this.options.trigger.split(' ')
51
+
52
+ for (i = triggers.length; i--;) {
53
+ trigger = triggers[i]
54
+ if (trigger == 'click') {
55
+ this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
56
+ } else if (trigger != 'manual') {
57
+ eventIn = trigger == 'hover' ? 'mouseenter' : 'focus'
58
+ eventOut = trigger == 'hover' ? 'mouseleave' : 'blur'
59
+ this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
60
+ this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
61
+ }
62
+ }
63
+
64
+ this.options.selector ?
65
+ (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
66
+ this.fixTitle()
67
+ }
68
+
69
+ , getOptions: function (options) {
70
+ options = $.extend({}, $.fn[this.type].defaults, this.$element.data(), options)
71
+
72
+ if (options.delay && typeof options.delay == 'number') {
73
+ options.delay = {
74
+ show: options.delay
75
+ , hide: options.delay
76
+ }
77
+ }
78
+
79
+ return options
80
+ }
81
+
82
+ , enter: function (e) {
83
+ var defaults = $.fn[this.type].defaults
84
+ , options = {}
85
+ , self
86
+
87
+ this._options && $.each(this._options, function (key, value) {
88
+ if (defaults[key] != value) options[key] = value
89
+ }, this)
90
+
91
+ self = $(e.currentTarget)[this.type](options).data(this.type)
92
+
93
+ if (!self.options.delay || !self.options.delay.show) return self.show()
94
+
95
+ clearTimeout(this.timeout)
96
+ self.hoverState = 'in'
97
+ this.timeout = setTimeout(function() {
98
+ if (self.hoverState == 'in') self.show()
99
+ }, self.options.delay.show)
100
+ }
101
+
102
+ , leave: function (e) {
103
+ var self = $(e.currentTarget)[this.type](this._options).data(this.type)
104
+
105
+ if (this.timeout) clearTimeout(this.timeout)
106
+ if (!self.options.delay || !self.options.delay.hide) return self.hide()
107
+
108
+ self.hoverState = 'out'
109
+ this.timeout = setTimeout(function() {
110
+ if (self.hoverState == 'out') self.hide()
111
+ }, self.options.delay.hide)
112
+ }
113
+
114
+ , show: function () {
115
+ var $tip
116
+ , pos
117
+ , actualWidth
118
+ , actualHeight
119
+ , placement
120
+ , tp
121
+ , e = $.Event('show')
122
+
123
+ if (this.hasContent() && this.enabled) {
124
+ this.$element.trigger(e)
125
+ if (e.isDefaultPrevented()) return
126
+ $tip = this.tip()
127
+ this.setContent()
128
+
129
+ if (this.options.animation) {
130
+ $tip.addClass('fade')
131
+ }
132
+
133
+ placement = typeof this.options.placement == 'function' ?
134
+ this.options.placement.call(this, $tip[0], this.$element[0]) :
135
+ this.options.placement
136
+
137
+ $tip
138
+ .detach()
139
+ .css({ top: 0, left: 0, display: 'block' })
140
+
141
+ this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
142
+
143
+ pos = this.getPosition()
144
+
145
+ actualWidth = $tip[0].offsetWidth
146
+ actualHeight = $tip[0].offsetHeight
147
+
148
+ switch (placement) {
149
+ case 'bottom':
150
+ tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
151
+ break
152
+ case 'top':
153
+ tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
154
+ break
155
+ case 'left':
156
+ tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}
157
+ break
158
+ case 'right':
159
+ tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}
160
+ break
161
+ }
162
+
163
+ this.applyPlacement(tp, placement)
164
+ this.$element.trigger('shown')
165
+ }
166
+ }
167
+
168
+ , applyPlacement: function(offset, placement){
169
+ var $tip = this.tip()
170
+ , width = $tip[0].offsetWidth
171
+ , height = $tip[0].offsetHeight
172
+ , actualWidth
173
+ , actualHeight
174
+ , delta
175
+ , replace
176
+
177
+ $tip
178
+ .offset(offset)
179
+ .addClass(placement)
180
+ .addClass('in')
181
+
182
+ actualWidth = $tip[0].offsetWidth
183
+ actualHeight = $tip[0].offsetHeight
184
+
185
+ if (placement == 'top' && actualHeight != height) {
186
+ offset.top = offset.top + height - actualHeight
187
+ replace = true
188
+ }
189
+
190
+ if (placement == 'bottom' || placement == 'top') {
191
+ delta = 0
192
+
193
+ if (offset.left < 0){
194
+ delta = offset.left * -2
195
+ offset.left = 0
196
+ $tip.offset(offset)
197
+ actualWidth = $tip[0].offsetWidth
198
+ actualHeight = $tip[0].offsetHeight
199
+ }
200
+
201
+ this.replaceArrow(delta - width + actualWidth, actualWidth, 'left')
202
+ } else {
203
+ this.replaceArrow(actualHeight - height, actualHeight, 'top')
204
+ }
205
+
206
+ if (replace) $tip.offset(offset)
207
+ }
208
+
209
+ , replaceArrow: function(delta, dimension, position){
210
+ this
211
+ .arrow()
212
+ .css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
213
+ }
214
+
215
+ , setContent: function () {
216
+ var $tip = this.tip()
217
+ , title = this.getTitle()
218
+
219
+ $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
220
+ $tip.removeClass('fade in top bottom left right')
221
+ }
222
+
223
+ , hide: function () {
224
+ var that = this
225
+ , $tip = this.tip()
226
+ , e = $.Event('hide')
227
+
228
+ this.$element.trigger(e)
229
+ if (e.isDefaultPrevented()) return
230
+
231
+ $tip.removeClass('in')
232
+
233
+ function removeWithAnimation() {
234
+ var timeout = setTimeout(function () {
235
+ $tip.off($.support.transition.end).detach()
236
+ }, 500)
237
+
238
+ $tip.one($.support.transition.end, function () {
239
+ clearTimeout(timeout)
240
+ $tip.detach()
241
+ })
242
+ }
243
+
244
+ $.support.transition && this.$tip.hasClass('fade') ?
245
+ removeWithAnimation() :
246
+ $tip.detach()
247
+
248
+ this.$element.trigger('hidden')
249
+
250
+ return this
251
+ }
252
+
253
+ , fixTitle: function () {
254
+ var $e = this.$element
255
+ if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
256
+ $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
257
+ }
258
+ }
259
+
260
+ , hasContent: function () {
261
+ return this.getTitle()
262
+ }
263
+
264
+ , getPosition: function () {
265
+ var el = this.$element[0]
266
+ return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : {
267
+ width: el.offsetWidth
268
+ , height: el.offsetHeight
269
+ }, this.$element.offset())
270
+ }
271
+
272
+ , getTitle: function () {
273
+ var title
274
+ , $e = this.$element
275
+ , o = this.options
276
+
277
+ title = $e.attr('data-original-title')
278
+ || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
279
+
280
+ return title
281
+ }
282
+
283
+ , tip: function () {
284
+ return this.$tip = this.$tip || $(this.options.template)
285
+ }
286
+
287
+ , arrow: function(){
288
+ return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow")
289
+ }
290
+
291
+ , validate: function () {
292
+ if (!this.$element[0].parentNode) {
293
+ this.hide()
294
+ this.$element = null
295
+ this.options = null
296
+ }
297
+ }
298
+
299
+ , enable: function () {
300
+ this.enabled = true
301
+ }
302
+
303
+ , disable: function () {
304
+ this.enabled = false
305
+ }
306
+
307
+ , toggleEnabled: function () {
308
+ this.enabled = !this.enabled
309
+ }
310
+
311
+ , toggle: function (e) {
312
+ var self = e ? $(e.currentTarget)[this.type](this._options).data(this.type) : this
313
+ self.tip().hasClass('in') ? self.hide() : self.show()
314
+ }
315
+
316
+ , destroy: function () {
317
+ this.hide().$element.off('.' + this.type).removeData(this.type)
318
+ }
319
+
320
+ }
321
+
322
+
323
+ /* TOOLTIP PLUGIN DEFINITION
324
+ * ========================= */
325
+
326
+ var old = $.fn.tooltip
327
+
328
+ $.fn.tooltip = function ( option ) {
329
+ return this.each(function () {
330
+ var $this = $(this)
331
+ , data = $this.data('tooltip')
332
+ , options = typeof option == 'object' && option
333
+ if (!data) $this.data('tooltip', (data = new Tooltip(this, options)))
334
+ if (typeof option == 'string') data[option]()
335
+ })
336
+ }
337
+
338
+ $.fn.tooltip.Constructor = Tooltip
339
+
340
+ $.fn.tooltip.defaults = {
341
+ animation: true
342
+ , placement: 'top'
343
+ , selector: false
344
+ , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
345
+ , trigger: 'hover focus'
346
+ , title: ''
347
+ , delay: 0
348
+ , html: false
349
+ , container: false
350
+ }
351
+
352
+
353
+ /* TOOLTIP NO CONFLICT
354
+ * =================== */
355
+
356
+ $.fn.tooltip.noConflict = function () {
357
+ $.fn.tooltip = old
358
+ return this
359
+ }
360
+
361
+ }(window.jQuery);