uber_select_rails 0.6.0 → 0.6.1
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf09e09761faba19203a94b5cc53f7d59aaaf114dde0cef6b4624ba5d1b4a916
|
4
|
+
data.tar.gz: 6a22b0a860276671c3c10253165e3f06d0735ea383865e077ca3ed2ee81dc286
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9adcece32e2b8db8049459f8daeac77c25e8f796295b0215297772a34e1b8faf70dd11e7676cdfb3e98d5f25d8ae9ec3ef572325471ec38418e38e7c65c1fa46
|
7
|
+
data.tar.gz: 53d97f64a172512b486aeff0094fa4d6493f45b662e4aebef91712535debf63386a1a410f9949daf3a6227a1ad0e8deeac347839da1ac5ee697bc4f9cbbbf9ab
|
@@ -1,7 +1,8 @@
|
|
1
|
-
function Pane(
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
function Pane(){
|
2
|
+
var eventsTriggered = {
|
3
|
+
shown: 'shown.UberSelect',
|
4
|
+
hidden: 'hidden.UberSelect'
|
5
|
+
}
|
5
6
|
|
6
7
|
var context = this
|
7
8
|
var model = {}
|
@@ -27,13 +28,6 @@ function Pane(options){
|
|
27
28
|
|
28
29
|
// BEHAVIOUR
|
29
30
|
|
30
|
-
// Hide the pane when clicked out
|
31
|
-
$(document).on('mousedown', function(event){
|
32
|
-
if (isEventOutsidePane(event) && isEventOutsideTrigger(event)){
|
33
|
-
context.hide()
|
34
|
-
}
|
35
|
-
})
|
36
|
-
|
37
31
|
// Make it possible to have elements in the pane that close it
|
38
32
|
view.on('click', '[data-behaviour~=close-pane]', function(event){
|
39
33
|
context.hide()
|
@@ -72,13 +66,13 @@ function Pane(options){
|
|
72
66
|
if (isOpen) { return }
|
73
67
|
isOpen = true
|
74
68
|
view.show()
|
75
|
-
|
69
|
+
triggerEvent(eventsTriggered.shown)
|
76
70
|
}
|
77
71
|
function hide(){
|
78
72
|
if (!isOpen) { return }
|
79
73
|
isOpen = false
|
80
74
|
view.hide()
|
81
|
-
|
75
|
+
triggerEvent(eventsTriggered.hidden)
|
82
76
|
}
|
83
77
|
function toggle(){
|
84
78
|
if (isOpen) {
|
@@ -88,13 +82,8 @@ function Pane(options){
|
|
88
82
|
}
|
89
83
|
}
|
90
84
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
}
|
95
|
-
|
96
|
-
function isEventOutsideTrigger(event){
|
97
|
-
return !$(event.target).closest(options.trigger).length
|
85
|
+
function triggerEvent(eventType, callbackArgs){
|
86
|
+
view.trigger(eventType, callbackArgs)
|
87
|
+
$(context).trigger(eventType, callbackArgs)
|
98
88
|
}
|
99
|
-
|
100
89
|
}
|
@@ -71,6 +71,13 @@ var UberSearch = function(data, options){
|
|
71
71
|
pane.show()
|
72
72
|
})
|
73
73
|
|
74
|
+
// Hide the pane when clicked out or another pane is opened
|
75
|
+
$(document).on('click shown.UberSelect', function(event){
|
76
|
+
if (isEventOutsidePane(event) && isEventOutsideOutputContainer(event)){
|
77
|
+
pane.hide()
|
78
|
+
}
|
79
|
+
})
|
80
|
+
|
74
81
|
// Show the pane if the user was tabbed onto the trigger and pressed enter, space, or down arrow
|
75
82
|
$(outputContainer.view).on('keyup', function(event){
|
76
83
|
if (outputContainer.view.hasClass('disabled')) { return }
|
@@ -359,6 +366,15 @@ var UberSearch = function(data, options){
|
|
359
366
|
return search.getResults().length
|
360
367
|
}
|
361
368
|
|
369
|
+
// returns true if the event originated outside the pane
|
370
|
+
function isEventOutsidePane(event){
|
371
|
+
return !$(event.target).closest(pane.view).length
|
372
|
+
}
|
373
|
+
|
374
|
+
function isEventOutsideOutputContainer(event){
|
375
|
+
return !$(event.target).closest(outputContainer.view).length
|
376
|
+
}
|
377
|
+
|
362
378
|
// Allow observer to be attached to the UberSearch itself
|
363
379
|
function triggerEvent(eventType, callbackArgs){
|
364
380
|
view.trigger(eventType, callbackArgs)
|