jombo 0.0.1.beta10 → 0.0.1.beta11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -52,26 +52,45 @@
52
52
  $href = $(href)
53
53
 
54
54
  this.activate($this.parent('li'), $ul)
55
- this.activate($href, $href.parent())
56
-
57
- $this.trigger({
58
- type: 'shown'
59
- , relatedTarget: previous
55
+ this.activate($href, $href.parent(), function () {
56
+ $this.trigger({
57
+ type: 'shown'
58
+ , relatedTarget: previous
59
+ })
60
60
  })
61
61
  }
62
62
 
63
- , activate: function ( element, container ) {
64
- container
65
- .find('> .active')
66
- .removeClass('active')
67
- .find('> .dropdown-menu > .active')
68
- .removeClass('active')
63
+ , activate: function ( element, container, callback) {
64
+ var $active = container.find('> .active')
65
+ , transition = callback
66
+ && $.support.transition
67
+ && $active.hasClass('fade')
68
+
69
+ function next() {
70
+ $active
71
+ .removeClass('active')
72
+ .find('> .dropdown-menu > .active')
73
+ .removeClass('active')
69
74
 
70
- element.addClass('active')
75
+ element.addClass('active')
71
76
 
72
- if ( element.parent('.dropdown-menu') ) {
73
- element.closest('li.dropdown').addClass('active')
77
+ if (transition) {
78
+ element[0].offsetWidth // reflow for transition
79
+ element.addClass('in')
80
+ }
81
+
82
+ if ( element.parent('.dropdown-menu') ) {
83
+ element.closest('li.dropdown').addClass('active')
84
+ }
85
+
86
+ callback && callback()
74
87
  }
88
+
89
+ transition ?
90
+ $active.one($.support.transition.end, next) :
91
+ next()
92
+
93
+ $active.removeClass('in')
75
94
  }
76
95
  }
77
96
 
@@ -79,7 +98,7 @@
79
98
  /* TAB PLUGIN DEFINITION
80
99
  * ===================== */
81
100
 
82
- $.fn.tab = function (option) {
101
+ $.fn.tab = function ( option ) {
83
102
  return this.each(function () {
84
103
  var $this = $(this)
85
104
  , data = $this.data('tab')
@@ -88,17 +107,17 @@
88
107
  })
89
108
  }
90
109
 
91
- $.fn.tab.Tab = Tab
110
+ $.fn.tab.Constructor = Tab
92
111
 
93
112
 
94
113
  /* TAB DATA-API
95
114
  * ============ */
96
115
 
97
- $(document).ready(function () {
98
- $('body').delegate('[data-toggle="tab"], [data-toggle="pill"]', 'click.tab.data-api', function (e) {
116
+ $(function () {
117
+ $('body').on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
99
118
  e.preventDefault()
100
119
  $(this).tab('show')
101
120
  })
102
121
  })
103
122
 
104
- }( window.jQuery || window.ender )
123
+ }( window.jQuery )
@@ -19,6 +19,8 @@
19
19
 
20
20
  $(function () {
21
21
 
22
+ "use strict"
23
+
22
24
  /* CSS TRANSITION SUPPORT (https://gist.github.com/373874)
23
25
  * ======================================================= */
24
26
 
@@ -1,7 +1,7 @@
1
1
  /* ==========================================================
2
2
  * bootstrap-twipsy.js v2.0.0
3
3
  * http://twitter.github.com/bootstrap/javascript.html#twipsy
4
- * Adapted from the original jQuery.tipsy by Jason Frame
4
+ * Inspired by the original jQuery.tipsy by Jason Frame
5
5
  * ==========================================================
6
6
  * Copyright 2011 Twitter, Inc.
7
7
  *
@@ -26,59 +26,122 @@
26
26
  * ============================== */
27
27
 
28
28
  var Twipsy = function ( element, options ) {
29
- this.$element = $(element)
30
- this.options = options
31
- this.enabled = true
32
- this.fixTitle()
29
+ this.init('twipsy', element, options)
33
30
  }
34
31
 
35
32
  Twipsy.prototype = {
36
33
 
37
34
  constructor: Twipsy
38
35
 
39
- , show: function() {
40
- var pos
36
+ , init: function ( type, element, options ) {
37
+ var eventIn
38
+ , eventOut
39
+
40
+ this.type = type
41
+ this.$element = $(element)
42
+ this.options = this.getOptions(options)
43
+ this.enabled = true
44
+
45
+ if (this.options.trigger != 'manual') {
46
+ eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus'
47
+ eventOut = this.options.trigger == 'hover' ? 'mouseleave' : 'blur'
48
+ this.$element.on(eventIn, this.options.selector, $.proxy(this.enter, this))
49
+ this.$element.on(eventOut, this.options.selector, $.proxy(this.leave, this))
50
+ }
51
+
52
+ this.options.selector ?
53
+ (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
54
+ this.fixTitle()
55
+ }
56
+
57
+ , getOptions: function ( options ) {
58
+ options = $.extend({}, $.fn[this.type].defaults, options, this.$element.data())
59
+
60
+ if (options.delay && typeof options.delay == 'number') {
61
+ options.delay = {
62
+ show: options.delay
63
+ , hide: options.delay
64
+ }
65
+ }
66
+
67
+ return options
68
+ }
69
+
70
+ , enter: function ( e ) {
71
+ var self = $(e.currentTarget)[this.type](this._options).data(this.type)
72
+
73
+ if (!self.options.delay || !self.options.delay.show) {
74
+ self.show()
75
+ } else {
76
+ self.hoverState = 'in'
77
+ setTimeout(function() {
78
+ if (self.hoverState == 'in') {
79
+ self.show()
80
+ }
81
+ }, self.options.delay.show)
82
+ }
83
+ }
84
+
85
+ , leave: function ( e ) {
86
+ var self = $(e.currentTarget)[this.type](this._options).data(this.type)
87
+
88
+ if (!self.options.delay || !self.options.delay.hide) {
89
+ self.hide()
90
+ } else {
91
+ setTimeout(function() {
92
+ self.hoverState = 'out'
93
+ if (self.hoverState == 'out') {
94
+ self.hide()
95
+ }
96
+ }, self.options.delay.hide)
97
+ }
98
+ }
99
+
100
+ , show: function () {
101
+ var $tip
102
+ , inside
103
+ , pos
41
104
  , actualWidth
42
105
  , actualHeight
43
106
  , placement
44
- , $tip
45
107
  , tp
46
108
 
47
109
  if (this.hasContent() && this.enabled) {
48
110
  $tip = this.tip()
49
111
  this.setContent()
50
112
 
51
- if (this.options.animate) {
113
+ if (this.options.animation) {
52
114
  $tip.addClass('fade')
53
115
  }
54
116
 
117
+ placement = typeof this.options.placement == 'function' ?
118
+ thing.call(this, $tip[0], this.$element[0]) :
119
+ this.options.placement
120
+
121
+ inside = /in/.test(placement)
122
+
55
123
  $tip
56
124
  .remove()
57
125
  .css({ top: 0, left: 0, display: 'block' })
58
- .prependTo(document.body)
126
+ .prependTo(inside ? this.$element : document.body)
59
127
 
60
- pos = $.extend({}, this.$element.offset(), {
61
- width: this.$element[0].offsetWidth
62
- , height: this.$element[0].offsetHeight
63
- })
128
+ pos = this.getPosition(inside)
64
129
 
65
130
  actualWidth = $tip[0].offsetWidth
66
131
  actualHeight = $tip[0].offsetHeight
67
132
 
68
- placement = maybeCall(this.options.placement, this, [ $tip[0], this.$element[0] ])
69
-
70
- switch (placement) {
71
- case 'below':
72
- tp = {top: pos.top + pos.height + this.options.offset, left: pos.left + pos.width / 2 - actualWidth / 2}
133
+ switch (inside ? placement.split(' ')[1] : placement) {
134
+ case 'bottom':
135
+ tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
73
136
  break
74
- case 'above':
75
- tp = {top: pos.top - actualHeight - this.options.offset, left: pos.left + pos.width / 2 - actualWidth / 2}
137
+ case 'top':
138
+ tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
76
139
  break
77
140
  case 'left':
78
- tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth - this.options.offset}
141
+ tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}
79
142
  break
80
143
  case 'right':
81
- tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width + this.options.offset}
144
+ tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}
82
145
  break
83
146
  }
84
147
 
@@ -95,22 +158,29 @@
95
158
  $tip[0].className = 'twipsy'
96
159
  }
97
160
 
98
- , hide: function() {
161
+ , hide: function () {
99
162
  var that = this
100
163
  , $tip = this.tip()
101
164
 
102
165
  $tip.removeClass('in')
103
166
 
104
- function removeElement () {
105
- $tip.remove()
167
+ function removeWithAnimation() {
168
+ var timeout = setTimeout(function () {
169
+ $tip.off($.support.transition.end).remove()
170
+ }, 500)
171
+
172
+ $tip.one($.support.transition.end, function () {
173
+ clearTimeout(timeout)
174
+ $tip.remove()
175
+ })
106
176
  }
107
177
 
108
178
  $.support.transition && this.$tip.hasClass('fade') ?
109
- $tip.bind( $.support.transition.end, removeElement) :
110
- removeElement()
179
+ removeWithAnimation() :
180
+ $tip.remove()
111
181
  }
112
182
 
113
- , fixTitle: function() {
183
+ , fixTitle: function () {
114
184
  var $e = this.$element
115
185
  if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
116
186
  $e.attr('data-original-title', $e.attr('title') || '').removeAttr('title')
@@ -121,29 +191,31 @@
121
191
  return this.getTitle()
122
192
  }
123
193
 
124
- , getTitle: function() {
194
+ , getPosition: function (inside) {
195
+ return $.extend({}, (inside ? {top: 0, left: 0} : this.$element.offset()), {
196
+ width: this.$element[0].offsetWidth
197
+ , height: this.$element[0].offsetHeight
198
+ })
199
+ }
200
+
201
+ , getTitle: function () {
125
202
  var title
126
203
  , $e = this.$element
127
204
  , o = this.options
128
205
 
129
- this.fixTitle()
130
-
131
- if (typeof o.title == 'string') {
132
- title = $e.attr(o.title == 'title' ? 'data-original-title' : o.title)
133
- } else if (typeof o.title == 'function') {
134
- title = o.title.call($e[0])
135
- }
206
+ title = $e.attr('data-original-title')
207
+ || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
136
208
 
137
- title = ('' + title).replace(/(^\s*|\s*$)/, "")
209
+ title = title.toString().replace(/(^\s*|\s*$)/, "")
138
210
 
139
- return title
211
+ return title
140
212
  }
141
213
 
142
- , tip: function() {
143
- return this.$tip = this.$tip || $('<div class="twipsy" />').html(this.options.template)
214
+ , tip: function () {
215
+ return this.$tip = this.$tip || $(this.options.template)
144
216
  }
145
217
 
146
- , validate: function() {
218
+ , validate: function () {
147
219
  if (!this.$element[0].parentNode) {
148
220
  this.hide()
149
221
  this.$element = null
@@ -151,15 +223,15 @@
151
223
  }
152
224
  }
153
225
 
154
- , enable: function() {
226
+ , enable: function () {
155
227
  this.enabled = true
156
228
  }
157
229
 
158
- , disable: function() {
230
+ , disable: function () {
159
231
  this.enabled = false
160
232
  }
161
233
 
162
- , toggleEnabled: function() {
234
+ , toggleEnabled: function () {
163
235
  this.enabled = !this.enabled
164
236
  }
165
237
 
@@ -170,125 +242,29 @@
170
242
  }
171
243
 
172
244
 
173
- /* TWIPSY PRIVATE METHODS
174
- * ====================== */
175
-
176
- function maybeCall ( thing, ctx, args ) {
177
- return typeof thing == 'function' ? thing.apply(ctx, args) : thing
178
- }
179
-
180
245
  /* TWIPSY PLUGIN DEFINITION
181
246
  * ======================== */
182
247
 
183
- $.fn.twipsy = function (options) {
184
- $.fn.twipsy.initWith.call(this, options, Twipsy, 'twipsy')
185
- return this
248
+ $.fn.twipsy = function ( option ) {
249
+ return this.each(function () {
250
+ var $this = $(this)
251
+ , data = $this.data('twipsy')
252
+ , options = typeof option == 'object' && option
253
+ if (!data) $this.data('twipsy', (data = new Twipsy(this, options)))
254
+ if (typeof option == 'string') data[option]()
255
+ })
186
256
  }
187
257
 
188
- $.fn.twipsy.initWith = function (options, Base, name) {
189
- var twipsy
190
- , binder
191
- , eventIn
192
- , eventOut
193
-
194
- if (typeof options == 'string') {
195
- return this.each(function (){
196
- twipsy = $.data(this, name)
197
- if (twipsy) twipsy[options]()
198
- })
199
- }
200
-
201
- options = $.extend({}, $.fn[name].defaults, options)
202
-
203
- if (options.delay && typeof options.delay == 'number') {
204
- options.delay = {
205
- show: options.delay
206
- , hide: options.delay
207
- }
208
- }
209
-
210
- function get(ele) {
211
- var twipsy = $.data(ele, name)
212
-
213
- if (!twipsy) {
214
- twipsy = new Base(ele, $.fn.twipsy.elementOptions(ele, options))
215
- $.data(ele, name, twipsy)
216
- }
217
-
218
- return twipsy
219
- }
220
-
221
- function enter() {
222
- var twipsy = get(this)
223
- twipsy.hoverState = 'in'
224
-
225
- if (!options.delay || !options.delay.show) {
226
- twipsy.show()
227
- } else {
228
- twipsy.fixTitle()
229
- setTimeout(function() {
230
- if (twipsy.hoverState == 'in') {
231
- twipsy.show()
232
- }
233
- }, options.delay.show)
234
- }
235
- }
236
-
237
- function leave() {
238
- var twipsy = get(this)
239
- twipsy.hoverState = 'out'
240
- if (!options.delay || !options.delay.hide) {
241
- twipsy.hide()
242
- } else {
243
- setTimeout(function() {
244
- if (twipsy.hoverState == 'out') {
245
- twipsy.hide()
246
- }
247
- }, options.delay.hide)
248
- }
249
- }
250
-
251
- if (!options.live) {
252
- this.each(function() {
253
- get(this)
254
- })
255
- }
256
-
257
- if (options.trigger != 'manual') {
258
- binder = options.live ? 'live' : 'bind'
259
- eventIn = options.trigger == 'hover' ? 'mouseenter' : 'focus'
260
- eventOut = options.trigger == 'hover' ? 'mouseleave' : 'blur'
261
- this[binder](eventIn, enter)[binder](eventOut, leave)
262
- }
263
-
264
- return this
265
- }
266
-
267
- $.fn.twipsy.Twipsy = Twipsy
258
+ $.fn.twipsy.Constructor = Twipsy
268
259
 
269
260
  $.fn.twipsy.defaults = {
270
- animate: true
261
+ animation: true
271
262
  , delay: 0
272
- , placement: 'above'
273
- , live: false
274
- , offset: 0
263
+ , selector: false
264
+ , placement: 'top'
275
265
  , trigger: 'hover'
276
- , title: 'title'
277
- , template: '<div class="twipsy-arrow"></div><div class="twipsy-inner"></div>'
278
- }
279
-
280
- $.fn.twipsy.rejectAttrOptions = [ 'title' ]
281
-
282
- $.fn.twipsy.elementOptions = function(ele, options) {
283
- var data = $(ele).data()
284
- , rejects = $.fn.twipsy.rejectAttrOptions
285
- , i = rejects.length
286
-
287
- while (i--) {
288
- delete data[rejects[i]]
289
- }
290
-
291
- return $.extend({}, options, data)
266
+ , title: ''
267
+ , template: '<div class="twipsy"><div class="twipsy-arrow"></div><div class="twipsy-inner"></div></div>'
292
268
  }
293
269
 
294
- }( window.jQuery || window.ender )
270
+ }( window.jQuery )