Skip to content

Commit a8ff91c

Browse files
committed
Merge branch 'master' of github.com:JJJ/chosen
2 parents 93d6bc4 + 4b3c03e commit a8ff91c

File tree

11 files changed

+200
-27
lines changed

11 files changed

+200
-27
lines changed

coffee/lib/abstract-chosen.coffee

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -572,13 +572,6 @@ class AbstractChosen
572572
@browser_is_supported: ->
573573
if "Microsoft Internet Explorer" is window.navigator.appName
574574
return document.documentMode >= 8
575-
if /iP(od|hone)/i.test(window.navigator.userAgent) or
576-
/IEMobile/i.test(window.navigator.userAgent) or
577-
/Windows Phone/i.test(window.navigator.userAgent) or
578-
/BlackBerry/i.test(window.navigator.userAgent) or
579-
/BB10/i.test(window.navigator.userAgent) or
580-
/Android.*Mobile/i.test(window.navigator.userAgent)
581-
return false
582575
return true
583576

584577
@default_multiple_text: "Select Some Options"

dist/js/chosen.jquery.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,9 +1021,6 @@ This file is generated by `grunt build`, do not edit it by hand.
10211021
if ("Microsoft Internet Explorer" === window.navigator.appName) {
10221022
return document.documentMode >= 8;
10231023
}
1024-
if (/iP(od|hone)/i.test(window.navigator.userAgent) || /IEMobile/i.test(window.navigator.userAgent) || /Windows Phone/i.test(window.navigator.userAgent) || /BlackBerry/i.test(window.navigator.userAgent) || /BB10/i.test(window.navigator.userAgent) || /Android.*Mobile/i.test(window.navigator.userAgent)) {
1025-
return false;
1026-
}
10271024
return true;
10281025
}
10291026

dist/js/chosen.jquery.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/chosen.proto.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,9 +1021,6 @@ This file is generated by `grunt build`, do not edit it by hand.
10211021
if ("Microsoft Internet Explorer" === window.navigator.appName) {
10221022
return document.documentMode >= 8;
10231023
}
1024-
if (/iP(od|hone)/i.test(window.navigator.userAgent) || /IEMobile/i.test(window.navigator.userAgent) || /Windows Phone/i.test(window.navigator.userAgent) || /BlackBerry/i.test(window.navigator.userAgent) || /BB10/i.test(window.navigator.userAgent) || /Android.*Mobile/i.test(window.navigator.userAgent)) {
1025-
return false;
1026-
}
10271024
return true;
10281025
}
10291026

dist/js/chosen.proto.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/chosen.jquery.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,9 +1021,6 @@ This file is generated by `grunt build`, do not edit it by hand.
10211021
if ("Microsoft Internet Explorer" === window.navigator.appName) {
10221022
return document.documentMode >= 8;
10231023
}
1024-
if (/iP(od|hone)/i.test(window.navigator.userAgent) || /IEMobile/i.test(window.navigator.userAgent) || /Windows Phone/i.test(window.navigator.userAgent) || /BlackBerry/i.test(window.navigator.userAgent) || /BB10/i.test(window.navigator.userAgent) || /Android.*Mobile/i.test(window.navigator.userAgent)) {
1025-
return false;
1026-
}
10271024
return true;
10281025
}
10291026

docs/chosen.jquery.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/chosen.proto.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,9 +1021,6 @@ This file is generated by `grunt build`, do not edit it by hand.
10211021
if ("Microsoft Internet Explorer" === window.navigator.appName) {
10221022
return document.documentMode >= 8;
10231023
}
1024-
if (/iP(od|hone)/i.test(window.navigator.userAgent) || /IEMobile/i.test(window.navigator.userAgent) || /Windows Phone/i.test(window.navigator.userAgent) || /BlackBerry/i.test(window.navigator.userAgent) || /BB10/i.test(window.navigator.userAgent) || /Android.*Mobile/i.test(window.navigator.userAgent)) {
1025-
return false;
1026-
}
10271024
return true;
10281025
}
10291026

docs/chosen.proto.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/jquery/mobile.spec.coffee

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
describe "Mobile support", ->
2+
describe "mobile interactions", ->
3+
it "should initialize chosen on mobile device", ->
4+
# Mock iPhone user agent
5+
Object.defineProperty window.navigator, 'userAgent',
6+
value: 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15'
7+
writable: true
8+
configurable: true
9+
10+
tmpl = "
11+
<select data-placeholder='Choose a Country...'>
12+
<option value=''></option>
13+
<option value='United States'>United States</option>
14+
<option value='United Kingdom'>United Kingdom</option>
15+
<option value='Afghanistan'>Afghanistan</option>
16+
</select>
17+
"
18+
div = $("<div>").html(tmpl)
19+
$('body').append(div)
20+
select = div.find("select")
21+
select.chosen()
22+
23+
# Check that chosen container was created
24+
container = div.find(".chosen-container")
25+
expect(container.length).toBe 1
26+
expect(container.hasClass("chosen-container-single")).toBe true
27+
28+
# Cleanup
29+
div.remove()
30+
31+
it "should handle touchstart events", ->
32+
# Mock iPhone user agent
33+
Object.defineProperty window.navigator, 'userAgent',
34+
value: 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15'
35+
writable: true
36+
configurable: true
37+
38+
tmpl = "
39+
<select data-placeholder='Choose a Country...'>
40+
<option value=''></option>
41+
<option value='United States'>United States</option>
42+
<option value='United Kingdom'>United Kingdom</option>
43+
<option value='Afghanistan'>Afghanistan</option>
44+
</select>
45+
"
46+
div = $("<div>").html(tmpl)
47+
$('body').append(div)
48+
select = div.find("select")
49+
select.chosen()
50+
51+
container = div.find(".chosen-container")
52+
# Simulate touchstart to open the dropdown
53+
container.trigger("touchstart")
54+
expect(container.hasClass("chosen-container-active")).toBe true
55+
56+
# Cleanup
57+
div.remove()
58+
59+
it "should handle touchend on results", ->
60+
# Mock iPhone user agent
61+
Object.defineProperty window.navigator, 'userAgent',
62+
value: 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15'
63+
writable: true
64+
configurable: true
65+
66+
tmpl = "
67+
<select data-placeholder='Choose a Country...'>
68+
<option value=''></option>
69+
<option value='United States'>United States</option>
70+
<option value='United Kingdom'>United Kingdom</option>
71+
<option value='Afghanistan'>Afghanistan</option>
72+
</select>
73+
"
74+
div = $("<div>").html(tmpl)
75+
$('body').append(div)
76+
select = div.find("select")
77+
select.chosen()
78+
79+
container = div.find(".chosen-container")
80+
# Open the dropdown
81+
container.trigger("touchstart")
82+
83+
# Get the results
84+
results = container.find(".chosen-results")
85+
activeResult = results.find(".active-result").first()
86+
87+
# Simulate touch selection - touchstart sets up touch state, mouseup performs selection
88+
activeResult.trigger("touchstart")
89+
activeResult.trigger($.Event("mouseup", which: 1))
90+
91+
# Check that an option was selected
92+
expect(select.val()).toBe "United States"
93+
94+
# Cleanup
95+
div.remove()

0 commit comments

Comments
 (0)