jombo 1.0.2 → 1.0.3

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.
@@ -18,9 +18,10 @@
18
18
  * ======================================================== */
19
19
 
20
20
 
21
- !function( $ ){
21
+ !function ($) {
22
+
23
+ "use strict"; // jshint ;_;
22
24
 
23
- "use strict"
24
25
 
25
26
  /* TAB CLASS DEFINITION
26
27
  * ==================== */
@@ -39,6 +40,7 @@
39
40
  , selector = $this.attr('data-target')
40
41
  , previous
41
42
  , $target
43
+ , e
42
44
 
43
45
  if (!selector) {
44
46
  selector = $this.attr('href')
@@ -49,11 +51,14 @@
49
51
 
50
52
  previous = $ul.find('.active a').last()[0]
51
53
 
52
- $this.trigger({
53
- type: 'show'
54
- , relatedTarget: previous
54
+ e = $.Event('show', {
55
+ relatedTarget: previous
55
56
  })
56
57
 
58
+ $this.trigger(e)
59
+
60
+ if (e.isDefaultPrevented()) return
61
+
57
62
  $target = $(selector)
58
63
 
59
64
  this.activate($this.parent('li'), $ul)
@@ -127,4 +132,4 @@
127
132
  })
128
133
  })
129
134
 
130
- }( window.jQuery );
135
+ }(window.jQuery);
@@ -18,14 +18,16 @@
18
18
  * limitations under the License.
19
19
  * ========================================================== */
20
20
 
21
- !function( $ ) {
22
21
 
23
- "use strict"
22
+ !function ($) {
23
+
24
+ "use strict"; // jshint ;_;
25
+
24
26
 
25
27
  /* TOOLTIP PUBLIC CLASS DEFINITION
26
28
  * =============================== */
27
29
 
28
- var Tooltip = function ( element, options ) {
30
+ var Tooltip = function (element, options) {
29
31
  this.init('tooltip', element, options)
30
32
  }
31
33
 
@@ -33,7 +35,7 @@
33
35
 
34
36
  constructor: Tooltip
35
37
 
36
- , init: function ( type, element, options ) {
38
+ , init: function (type, element, options) {
37
39
  var eventIn
38
40
  , eventOut
39
41
 
@@ -54,7 +56,7 @@
54
56
  this.fixTitle()
55
57
  }
56
58
 
57
- , getOptions: function ( options ) {
59
+ , getOptions: function (options) {
58
60
  options = $.extend({}, $.fn[this.type].defaults, options, this.$element.data())
59
61
 
60
62
  if (options.delay && typeof options.delay == 'number') {
@@ -67,36 +69,28 @@
67
69
  return options
68
70
  }
69
71
 
70
- , enter: function ( e ) {
72
+ , enter: function (e) {
71
73
  var self = $(e.currentTarget)[this.type](this._options).data(this.type)
72
74
 
73
- if (!self.options.delay || !self.options.delay.show) {
74
- self.show()
75
- } else {
76
- clearTimeout(this.timeout)
77
- self.hoverState = 'in'
78
- this.timeout = setTimeout(function() {
79
- if (self.hoverState == 'in') {
80
- self.show()
81
- }
82
- }, self.options.delay.show)
83
- }
75
+ if (!self.options.delay || !self.options.delay.show) return self.show()
76
+
77
+ clearTimeout(this.timeout)
78
+ self.hoverState = 'in'
79
+ this.timeout = setTimeout(function() {
80
+ if (self.hoverState == 'in') self.show()
81
+ }, self.options.delay.show)
84
82
  }
85
83
 
86
- , leave: function ( e ) {
84
+ , leave: function (e) {
87
85
  var self = $(e.currentTarget)[this.type](this._options).data(this.type)
88
86
 
89
- if (!self.options.delay || !self.options.delay.hide) {
90
- self.hide()
91
- } else {
92
- clearTimeout(this.timeout)
93
- self.hoverState = 'out'
94
- this.timeout = setTimeout(function() {
95
- if (self.hoverState == 'out') {
96
- self.hide()
97
- }
98
- }, self.options.delay.hide)
99
- }
87
+ if (!self.options.delay || !self.options.delay.hide) return self.hide()
88
+
89
+ clearTimeout(this.timeout)
90
+ self.hoverState = 'out'
91
+ this.timeout = setTimeout(function() {
92
+ if (self.hoverState == 'out') self.hide()
93
+ }, self.options.delay.hide)
100
94
  }
101
95
 
102
96
  , show: function () {
@@ -154,9 +148,20 @@
154
148
  }
155
149
  }
156
150
 
151
+ , isHTML: function(text) {
152
+ // html string detection logic adapted from jQuery
153
+ return typeof text != 'string'
154
+ || ( text.charAt(0) === "<"
155
+ && text.charAt( text.length - 1 ) === ">"
156
+ && text.length >= 3
157
+ ) || /^(?:[^<]*<[\w\W]+>[^>]*$)/.exec(text)
158
+ }
159
+
157
160
  , setContent: function () {
158
161
  var $tip = this.tip()
159
- $tip.find('.tooltip-inner').html(this.getTitle())
162
+ , title = this.getTitle()
163
+
164
+ $tip.find('.tooltip-inner')[this.isHTML(title) ? 'html' : 'text'](title)
160
165
  $tip.removeClass('fade in top bottom left right')
161
166
  }
162
167
 
@@ -259,12 +264,12 @@
259
264
 
260
265
  $.fn.tooltip.defaults = {
261
266
  animation: true
262
- , delay: 0
263
- , selector: false
264
267
  , placement: 'top'
268
+ , selector: false
269
+ , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
265
270
  , trigger: 'hover'
266
271
  , title: ''
267
- , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
272
+ , delay: 0
268
273
  }
269
274
 
270
- }( window.jQuery );
275
+ }(window.jQuery);
@@ -17,35 +17,45 @@
17
17
  * limitations under the License.
18
18
  * ========================================================== */
19
19
 
20
- !function( $ ) {
20
+
21
+ !function ($) {
21
22
 
22
23
  $(function () {
23
24
 
24
- "use strict"
25
+ "use strict"; // jshint ;_;
26
+
25
27
 
26
- /* CSS TRANSITION SUPPORT (https://gist.github.com/373874)
28
+ /* CSS TRANSITION SUPPORT (http://www.modernizr.com/)
27
29
  * ======================================================= */
28
30
 
29
31
  $.support.transition = (function () {
30
- var thisBody = document.body || document.documentElement
31
- , thisStyle = thisBody.style
32
- , support = thisStyle.transition !== undefined || thisStyle.WebkitTransition !== undefined || thisStyle.MozTransition !== undefined || thisStyle.MsTransition !== undefined || thisStyle.OTransition !== undefined
33
-
34
- return support && {
35
- end: (function () {
36
- var transitionEnd = "TransitionEnd"
37
- if ( $.browser.webkit ) {
38
- transitionEnd = "webkitTransitionEnd"
39
- } else if ( $.browser.mozilla ) {
40
- transitionEnd = "transitionend"
41
- } else if ( $.browser.opera ) {
42
- transitionEnd = "oTransitionEnd"
32
+
33
+ var transitionEnd = (function () {
34
+
35
+ var el = document.createElement('bootstrap')
36
+ , transEndEventNames = {
37
+ 'WebkitTransition' : 'webkitTransitionEnd'
38
+ , 'MozTransition' : 'transitionend'
39
+ , 'OTransition' : 'oTransitionEnd'
40
+ , 'msTransition' : 'MSTransitionEnd'
41
+ , 'transition' : 'transitionend'
42
+ }
43
+ , name
44
+
45
+ for (name in transEndEventNames){
46
+ if (el.style[name] !== undefined) {
47
+ return transEndEventNames[name]
43
48
  }
44
- return transitionEnd
45
- }())
49
+ }
50
+
51
+ }())
52
+
53
+ return transitionEnd && {
54
+ end: transitionEnd
46
55
  }
56
+
47
57
  })()
48
58
 
49
59
  })
50
60
 
51
- }( window.jQuery );
61
+ }(window.jQuery);
@@ -17,16 +17,22 @@
17
17
  * limitations under the License.
18
18
  * ============================================================ */
19
19
 
20
- !function( $ ){
21
20
 
22
- "use strict"
21
+ !function($){
23
22
 
24
- var Typeahead = function ( element, options ) {
23
+ "use strict"; // jshint ;_;
24
+
25
+
26
+ /* TYPEAHEAD PUBLIC CLASS DEFINITION
27
+ * ================================= */
28
+
29
+ var Typeahead = function (element, options) {
25
30
  this.$element = $(element)
26
31
  this.options = $.extend({}, $.fn.typeahead.defaults, options)
27
32
  this.matcher = this.options.matcher || this.matcher
28
33
  this.sorter = this.options.sorter || this.sorter
29
34
  this.highlighter = this.options.highlighter || this.highlighter
35
+ this.updater = this.options.updater || this.updater
30
36
  this.$menu = $(this.options.menu).appendTo('body')
31
37
  this.source = this.options.source
32
38
  this.shown = false
@@ -40,11 +46,15 @@
40
46
  , select: function () {
41
47
  var val = this.$menu.find('.active').attr('data-value')
42
48
  this.$element
43
- .val(val)
49
+ .val(this.updater(val))
44
50
  .change()
45
51
  return this.hide()
46
52
  }
47
53
 
54
+ , updater: function (item) {
55
+ return item
56
+ }
57
+
48
58
  , show: function () {
49
59
  var pos = $.extend({}, this.$element.offset(), {
50
60
  height: this.$element[0].offsetHeight
@@ -78,7 +88,7 @@
78
88
  }
79
89
 
80
90
  items = $.grep(this.source, function (item) {
81
- if (that.matcher(item)) return item
91
+ return that.matcher(item)
82
92
  })
83
93
 
84
94
  items = this.sorter(items)
@@ -110,7 +120,7 @@
110
120
  }
111
121
 
112
122
  , highlighter: function (item) {
113
- var query = this.query.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')
123
+ var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&')
114
124
  return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
115
125
  return '<strong>' + match + '</strong>'
116
126
  })
@@ -203,11 +213,13 @@
203
213
  break
204
214
 
205
215
  case 38: // up arrow
216
+ if (e.type != 'keydown') break
206
217
  e.preventDefault()
207
218
  this.prev()
208
219
  break
209
220
 
210
221
  case 40: // down arrow
222
+ if (e.type != 'keydown') break
211
223
  e.preventDefault()
212
224
  this.next()
213
225
  break
@@ -238,7 +250,7 @@
238
250
  /* TYPEAHEAD PLUGIN DEFINITION
239
251
  * =========================== */
240
252
 
241
- $.fn.typeahead = function ( option ) {
253
+ $.fn.typeahead = function (option) {
242
254
  return this.each(function () {
243
255
  var $this = $(this)
244
256
  , data = $this.data('typeahead')
@@ -270,4 +282,4 @@
270
282
  })
271
283
  })
272
284
 
273
- }( window.jQuery );
285
+ }(window.jQuery);