Commit d88aafcb5d15827029a8f42e1a88ac313b1d218e

Authored by Dmitriy Zaporozhets
2 parents 12dbd0a4 04ad19dc

Merge branch 'select2' of /home/git/repositories/gitlab/gitlabhq

@@ -144,7 +144,6 @@ gem "therubyracer" @@ -144,7 +144,6 @@ gem "therubyracer"
144 gem 'turbolinks' 144 gem 'turbolinks'
145 gem 'jquery-turbolinks' 145 gem 'jquery-turbolinks'
146 146
147 -gem 'chosen-rails', "1.0.1"  
148 gem 'select2-rails' 147 gem 'select2-rails'
149 gem 'jquery-atwho-rails', "~> 0.3.3" 148 gem 'jquery-atwho-rails', "~> 0.3.3"
150 gem "jquery-rails", "2.1.3" 149 gem "jquery-rails", "2.1.3"
@@ -71,12 +71,6 @@ GEM @@ -71,12 +71,6 @@ GEM
71 celluloid (0.15.2) 71 celluloid (0.15.2)
72 timers (~> 1.1.0) 72 timers (~> 1.1.0)
73 charlock_holmes (0.6.9.4) 73 charlock_holmes (0.6.9.4)
74 - chosen-rails (1.0.1)  
75 - coffee-rails (>= 3.2)  
76 - compass-rails (>= 1.0)  
77 - railties (>= 3.0)  
78 - sass-rails (>= 3.2)  
79 - chunky_png (1.2.9)  
80 cliver (0.2.2) 74 cliver (0.2.2)
81 code_analyzer (0.4.3) 75 code_analyzer (0.4.3)
82 sexp_processor 76 sexp_processor
@@ -92,12 +86,6 @@ GEM @@ -92,12 +86,6 @@ GEM
92 coffee-script-source (1.6.3) 86 coffee-script-source (1.6.3)
93 colored (1.2) 87 colored (1.2)
94 colorize (0.5.8) 88 colorize (0.5.8)
95 - compass (0.12.2)  
96 - chunky_png (~> 1.2)  
97 - fssm (>= 0.2.7)  
98 - sass (~> 3.1)  
99 - compass-rails (1.1.1)  
100 - compass (>= 0.12.2)  
101 connection_pool (1.2.0) 89 connection_pool (1.2.0)
102 coveralls (0.7.0) 90 coveralls (0.7.0)
103 multi_json (~> 1.3) 91 multi_json (~> 1.3)
@@ -161,7 +149,6 @@ GEM @@ -161,7 +149,6 @@ GEM
161 dotenv (>= 0.7) 149 dotenv (>= 0.7)
162 thor (>= 0.13.6) 150 thor (>= 0.13.6)
163 formatador (0.2.4) 151 formatador (0.2.4)
164 - fssm (0.2.10)  
165 gemoji (1.3.1) 152 gemoji (1.3.1)
166 gherkin-ruby (0.3.1) 153 gherkin-ruby (0.3.1)
167 racc 154 racc
@@ -572,7 +559,6 @@ DEPENDENCIES @@ -572,7 +559,6 @@ DEPENDENCIES
572 bootstrap-sass (~> 3.0) 559 bootstrap-sass (~> 3.0)
573 capybara 560 capybara
574 carrierwave 561 carrierwave
575 - chosen-rails (= 1.0.1)  
576 coffee-rails 562 coffee-rails
577 colored 563 colored
578 coveralls 564 coveralls
app/assets/javascripts/application.js
@@ -19,7 +19,6 @@ @@ -19,7 +19,6 @@
19 //= require jquery.turbolinks 19 //= require jquery.turbolinks
20 //= require bootstrap 20 //= require bootstrap
21 //= require modernizr 21 //= require modernizr
22 -//= require chosen-jquery  
23 //= require select2 22 //= require select2
24 //= require raphael 23 //= require raphael
25 //= require g.raphael-min 24 //= require g.raphael-min
app/assets/javascripts/issues.js.coffee
@@ -29,12 +29,10 @@ @@ -29,12 +29,10 @@
29 $('#filter_issue_search').val($('#issue_search').val()) 29 $('#filter_issue_search').val($('#issue_search').val())
30 30
31 initSelects: -> 31 initSelects: ->
32 - $("#update_status").chosen()  
33 - $("#update_assignee_id").chosen()  
34 - $("#update_milestone_id").chosen()  
35 - $("#label_name").chosen()  
36 - $("#assignee_id").chosen()  
37 - $("#milestone_id").chosen() 32 + $("select#update_status").select2()
  33 + $("select#update_assignee_id").select2()
  34 + $("select#update_milestone_id").select2()
  35 + $("select#label_name").select2()
38 $("#milestone_id, #assignee_id, #label_name").on "change", -> 36 $("#milestone_id, #assignee_id, #label_name").on "change", ->
39 $(this).closest("form").submit() 37 $(this).closest("form").submit()
40 38
app/assets/javascripts/main.js.coffee
@@ -67,8 +67,8 @@ $ -> @@ -67,8 +67,8 @@ $ ->
67 $('.appear-data').fadeIn() 67 $('.appear-data').fadeIn()
68 e.preventDefault() 68 e.preventDefault()
69 69
70 - # Initialize chosen selects  
71 - $('select.chosen').chosen() 70 + # Initialize select2 selects
  71 + $('select.select2').select2(width: 'resolve', dropdownAutoWidth: true)
72 72
73 # Initialize tooltips 73 # Initialize tooltips
74 $('.has_tooltip').tooltip() 74 $('.has_tooltip').tooltip()
@@ -126,12 +126,6 @@ $ -> @@ -126,12 +126,6 @@ $ ->
126 $(@).remove() 126 $(@).remove()
127 127
128 (($) -> 128 (($) ->
129 - _chosen = $.fn.chosen  
130 - $.fn.extend chosen: (options) ->  
131 - default_options = search_contains: "true"  
132 - $.extend default_options, options  
133 - _chosen.apply @, [default_options]  
134 -  
135 # Disable an element and add the 'disabled' Bootstrap class 129 # Disable an element and add the 'disabled' Bootstrap class
136 $.fn.extend disable: -> 130 $.fn.extend disable: ->
137 $(@).attr('disabled', 'disabled').addClass('disabled') 131 $(@).attr('disabled', 'disabled').addClass('disabled')
app/assets/javascripts/merge_requests.js.coffee
@@ -2,8 +2,8 @@ @@ -2,8 +2,8 @@
2 # * Filter merge requests 2 # * Filter merge requests
3 # 3 #
4 @merge_requestsPage = -> 4 @merge_requestsPage = ->
5 - $('#assignee_id').chosen()  
6 - $('#milestone_id').chosen() 5 + $('#assignee_id').select2()
  6 + $('#milestone_id').select2()
7 $('#milestone_id, #assignee_id').on 'change', -> 7 $('#milestone_id, #assignee_id').on 'change', ->
8 $(this).closest('form').submit() 8 $(this).closest('form').submit()
9 9
app/assets/stylesheets/application.scss
@@ -4,7 +4,6 @@ @@ -4,7 +4,6 @@
4 * the top of the compiled file, but it's generally better to create a new file per style scope. 4 * the top of the compiled file, but it's generally better to create a new file per style scope.
5 *= require jquery.ui.gitlab 5 *= require jquery.ui.gitlab
6 *= require jquery.atwho 6 *= require jquery.atwho
7 - *= require chosen  
8 *= require select2 7 *= require select2
9 *= require_self 8 *= require_self
10 */ 9 */
app/assets/stylesheets/generic/selects.scss
1 -/** Chosen.js selectbox style override **/  
2 -.chosen-container {  
3 - min-width: 100px; 1 +/** Select2 selectbox style override **/
4 2
5 - .chosen-single {  
6 - height: 26px;  
7 - background: #EEE !important;  
8 - border: 1px solid #DDD !important;  
9 - @include box-shadow(none !important);  
10 - @include border-radius(4px !important);  
11 - }  
12 -  
13 - .chosen-results li.highlighted {  
14 - background: #29b;  
15 - } 3 +.select2-container {
  4 + .select2-choice {
  5 + background: #FFF;
  6 + border-color: #BBB;
16 7
17 - .chosen-drop {  
18 - margin-top: 10px;  
19 - border: 1px solid #DDD !important;  
20 - @include border-radius(4px !important);  
21 - }  
22 -  
23 - .chosen-search input {  
24 - border: 1px solid #CCC !important;  
25 - @include box-shadow(none !important); 8 + .select2-arrow {
  9 + background: #FFF;
  10 + }
26 } 11 }
27 } 12 }
28 13
29 -/** Select2 styling **/  
30 -.select2-container .select2-choice {  
31 - @include bg-light-gray-gradient;  
32 -}  
33 -  
34 -.select2-container .select2-choice div {  
35 - border: none;  
36 - background: none;  
37 -}  
38 -  
39 -.select2-drop {  
40 - padding-top: 8px;  
41 -}  
42 -  
43 -.select2-no-results, .select2-searching {  
44 - padding: 7px;  
45 - color: #666;  
46 -}  
47 -  
48 -.chosen-container .chosen-single div b {  
49 - background-position-y: 0px !important;  
50 -}  
51 -  
52 -.chosen-container .chosen-drop .chosen-search input {  
53 - background-position-y: -24px !important;  
54 -}  
55 -  
56 -.chosen-compact {  
57 - max-width: 170px !important; 14 +.select2-drop-active {
  15 + border: 1px solid #BBB;
  16 + margin-top: 4px;
58 } 17 }
59 18
60 select { 19 select {
61 - &.chosen { 20 + &.select2 {
62 width: 100px; 21 width: 100px;
63 } 22 }
64 23
65 - &.chosen-sm { 24 + &.select2-sm {
66 width: 100px; 25 width: 100px;
67 } 26 }
68 } 27 }
69 28
70 @media (min-width: $screen-sm-min) { 29 @media (min-width: $screen-sm-min) {
71 select { 30 select {
72 - &.chosen { 31 + &.select2 {
73 width: 150px; 32 width: 150px;
74 } 33 }
75 - &.chosen-sm { 34 + &.select2-sm {
76 width: 120px; 35 width: 120px;
77 } 36 }
78 } 37 }
@@ -81,10 +40,10 @@ select { @@ -81,10 +40,10 @@ select {
81 /* Medium devices (desktops, 992px and up) */ 40 /* Medium devices (desktops, 992px and up) */
82 @media (min-width: $screen-md-min) { 41 @media (min-width: $screen-md-min) {
83 select { 42 select {
84 - &.chosen { 43 + &.select2 {
85 width: 170px; 44 width: 170px;
86 } 45 }
87 - &.chosen-sm { 46 + &.select2-sm {
88 width: 140px; 47 width: 140px;
89 } 48 }
90 } 49 }
@@ -93,11 +52,17 @@ select { @@ -93,11 +52,17 @@ select {
93 /* Large devices (large desktops, 1200px and up) */ 52 /* Large devices (large desktops, 1200px and up) */
94 @media (min-width: $screen-lg-min) { 53 @media (min-width: $screen-lg-min) {
95 select { 54 select {
96 - &.chosen { 55 + &.select2 {
97 width: 200px; 56 width: 200px;
98 } 57 }
99 - &.chosen-sm { 58 + &.select2-sm {
100 width: 150px; 59 width: 150px;
101 } 60 }
102 } 61 }
103 } 62 }
  63 +
  64 +
  65 +/** Branch/tag selector **/
  66 +.project-refs-form .select2-container {
  67 + margin-right: 10px;
  68 +}
app/assets/stylesheets/sections/issues.scss
@@ -77,8 +77,8 @@ input.check_all_issues { @@ -77,8 +77,8 @@ input.check_all_issues {
77 @media (min-width: 800px) { .issues_filters select { width: 160px; } } 77 @media (min-width: 800px) { .issues_filters select { width: 160px; } }
78 @media (min-width: 1200px) { .issues_filters select { width: 220px; } } 78 @media (min-width: 1200px) { .issues_filters select { width: 220px; } }
79 79
80 -@media (min-width: 800px) { .issues_bulk_update .chosen-container { min-width: 120px; } }  
81 -@media (min-width: 1200px) { .issues_bulk_update .chosen-container { min-width: 160px; } } 80 +@media (min-width: 800px) { .issues_bulk_update .select2-container { min-width: 120px; } }
  81 +@media (min-width: 1200px) { .issues_bulk_update .select2-container { min-width: 160px; } }
82 82
83 .issues-holder { 83 .issues-holder {
84 .issues_filters { 84 .issues_filters {
@@ -105,7 +105,7 @@ input.check_all_issues { @@ -105,7 +105,7 @@ input.check_all_issues {
105 } 105 }
106 106
107 .issues_bulk_update { 107 .issues_bulk_update {
108 - .chosen-container { 108 + .select2-container {
109 text-shadow: none; 109 text-shadow: none;
110 } 110 }
111 } 111 }
app/assets/stylesheets/sections/merge_requests.scss
@@ -95,7 +95,7 @@ @@ -95,7 +95,7 @@
95 font-weight: normal !important; 95 font-weight: normal !important;
96 } 96 }
97 97
98 - .chosen-container .chosen-single { 98 + .select2-container .select2-single {
99 span { 99 span {
100 font-weight: bold; 100 font-weight: bold;
101 color: #555; 101 color: #555;
app/assets/stylesheets/sections/projects.scss
@@ -75,7 +75,7 @@ @@ -75,7 +75,7 @@
75 .project-home-dropdown + & { 75 .project-home-dropdown + & {
76 margin-right: 45px; 76 margin-right: 45px;
77 } 77 }
78 - 78 +
79 .btn, 79 .btn,
80 .form-control { 80 .form-control {
81 border: 1px solid #E1E1E1; 81 border: 1px solid #E1E1E1;
@@ -230,43 +230,10 @@ ul.nav.nav-projects-tabs { @@ -230,43 +230,10 @@ ul.nav.nav-projects-tabs {
230 } 230 }
231 } 231 }
232 232
233 -.transfer-project .chosen-container { 233 +.transfer-project .select2-container {
234 min-width: 200px; 234 min-width: 200px;
235 } 235 }
236 236
237 -/** Branch/tag selector **/  
238 -.project-refs-form {  
239 - margin: 0;  
240 - span {  
241 - background:none !important;  
242 - position:static !important;  
243 - width:auto !important;  
244 - height:auto !important;  
245 - }  
246 -}  
247 -  
248 -.project-refs-form .chosen-container {  
249 - position: relative;  
250 - top: 0;  
251 - left: 0;  
252 - margin-right: 10px;  
253 -  
254 - .chosen-single span {  
255 - font-weight: bold;  
256 - color: #555;  
257 - }  
258 -  
259 - &.chosen-container-active {  
260 - .chosen-drop {  
261 - min-width: 400px;  
262 - }  
263 -  
264 - .chosen-results {  
265 - max-height: 400px;  
266 - }  
267 - }  
268 -}  
269 -  
270 .deploy-project-label { 237 .deploy-project-label {
271 margin: 1px; 238 margin: 1px;
272 } 239 }
app/views/admin/groups/show.html.haml
@@ -57,7 +57,7 @@ @@ -57,7 +57,7 @@
57 %div 57 %div
58 = users_select_tag(:user_ids, multiple: true) 58 = users_select_tag(:user_ids, multiple: true)
59 %div.prepend-top-10 59 %div.prepend-top-10
60 - = select_tag :group_access, options_for_select(UsersGroup.group_access_roles), class: "project-access-select chosen" 60 + = select_tag :group_access, options_for_select(UsersGroup.group_access_roles), class: "project-access-select select2"
61 %hr 61 %hr
62 = submit_tag 'Add users into group', class: "btn btn-create" 62 = submit_tag 'Add users into group', class: "btn btn-create"
63 .ui-box 63 .ui-box
app/views/groups/_new_group_member.html.haml
@@ -12,7 +12,7 @@ @@ -12,7 +12,7 @@
12 %p 2. Set access level for them 12 %p 2. Set access level for them
13 .form-group 13 .form-group
14 = f.label :group_access, "Group Access", class: 'control-label' 14 = f.label :group_access, "Group Access", class: 'control-label'
15 - .col-sm-10= select_tag :group_access, options_for_select(UsersGroup.group_access_roles, @users_group.group_access), class: "project-access-select chosen" 15 + .col-sm-10= select_tag :group_access, options_for_select(UsersGroup.group_access_roles, @users_group.group_access), class: "project-access-select select2"
16 16
17 .form-actions 17 .form-actions
18 = f.submit 'Add users into group', class: "btn btn-create" 18 = f.submit 'Add users into group', class: "btn btn-create"
app/views/projects/edit.html.haml
@@ -26,7 +26,7 @@ @@ -26,7 +26,7 @@
26 - if @project.repository.exists? && @project.repository.branch_names.any? 26 - if @project.repository.exists? && @project.repository.branch_names.any?
27 .form-group 27 .form-group
28 = f.label :default_branch, "Default Branch", class: 'control-label' 28 = f.label :default_branch, "Default Branch", class: 'control-label'
29 - .col-sm-10= f.select(:default_branch, @repository.branch_names, {}, {class: 'chosen select-wide'}) 29 + .col-sm-10= f.select(:default_branch, @repository.branch_names, {}, {class: 'select2 select-wide'})
30 30
31 31
32 = render "visibility_level", f: f, visibility_level: @project.visibility_level, can_change_visibility_level: can?(current_user, :change_visibility_level, @project) 32 = render "visibility_level", f: f, visibility_level: @project.visibility_level, can_change_visibility_level: can?(current_user, :change_visibility_level, @project)
@@ -145,7 +145,7 @@ @@ -145,7 +145,7 @@
145 %span Namespace 145 %span Namespace
146 .col-sm-10 146 .col-sm-10
147 .form-group 147 .form-group
148 - = f.select :namespace_id, namespaces_options(@project.namespace_id), { prompt: 'Choose a project namespace' }, { class: 'chosen' } 148 + = f.select :namespace_id, namespaces_options(@project.namespace_id), { prompt: 'Choose a project namespace' }, { class: 'select2' }
149 %ul 149 %ul
150 %li Be careful. Changing the project's namespace can have unintended side effects. 150 %li Be careful. Changing the project's namespace can have unintended side effects.
151 %li You can only transfer the project to namespaces you manage. 151 %li You can only transfer the project to namespaces you manage.
app/views/projects/issues/_form.html.haml
@@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
24 %i.icon-user 24 %i.icon-user
25 Assign to 25 Assign to
26 .col-sm-10 26 .col-sm-10
27 - = f.select(:assignee_id, assignee_options(@issue), { include_blank: "Select a user" }, {class: 'chosen'}) 27 + = f.select(:assignee_id, assignee_options(@issue), { include_blank: "Select a user" }, {class: 'select2'})
28   28  
29 = link_to 'Assign to me', '#', class: 'btn btn-small assign-to-me-link' 29 = link_to 'Assign to me', '#', class: 'btn btn-small assign-to-me-link'
30 .form-group 30 .form-group
@@ -32,7 +32,7 @@ @@ -32,7 +32,7 @@
32 = f.label :milestone_id, class: 'control-label' do 32 = f.label :milestone_id, class: 'control-label' do
33 %i.icon-time 33 %i.icon-time
34 Milestone 34 Milestone
35 - .col-sm-10= f.select(:milestone_id, milestone_options(@issue), { include_blank: "Select milestone" }, {class: 'chosen'}) 35 + .col-sm-10= f.select(:milestone_id, milestone_options(@issue), { include_blank: "Select milestone" }, {class: 'select2'})
36 36
37 .form-group 37 .form-group
38 = f.label :label_list, class: 'control-label' do 38 = f.label :label_list, class: 'control-label' do
@@ -87,6 +87,6 @@ @@ -87,6 +87,6 @@
87 }); 87 });
88 88
89 $('.assign-to-me-link').on('click', function(e){ 89 $('.assign-to-me-link').on('click', function(e){
90 - $('#issue_assignee_id').val("#{current_user.id}").trigger("chosen:updated"); 90 + $('#issue_assignee_id').val("#{current_user.id}").trigger("change");
91 e.preventDefault(); 91 e.preventDefault();
92 }); 92 });
app/views/projects/issues/_issue_context.html.haml
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 - if can?(current_user, :modify_issue, @issue) 6 - if can?(current_user, :modify_issue, @issue)
7 = link_to profile_path(issue.assignee) do 7 = link_to profile_path(issue.assignee) do
8 = image_tag(avatar_icon(issue.assignee.email), class: 'avatar avatar-inline s16 assignee') if issue.assignee 8 = image_tag(avatar_icon(issue.assignee.email), class: 'avatar avatar-inline s16 assignee') if issue.assignee
9 - = f.select(:assignee_id, assignee_options(@issue), { include_blank: "Assign to user (none):" }, {class: 'chosen'}) 9 + = f.select(:assignee_id, assignee_options(@issue), { include_blank: "Assign to user (none):" }, {class: 'select2'})
10 - elsif issue.assignee 10 - elsif issue.assignee
11 = link_to_member(@project, @issue.assignee) 11 = link_to_member(@project, @issue.assignee)
12 12
@@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
17 %cite.cgray Attached to milestone 17 %cite.cgray Attached to milestone
18 18
19 - if can?(current_user, :modify_issue, @issue) 19 - if can?(current_user, :modify_issue, @issue)
20 - = f.select(:milestone_id, milestone_options(@issue), { include_blank: "Select milestone (none):" }, {class: 'chosen chosen-compact'}) 20 + = f.select(:milestone_id, milestone_options(@issue), { include_blank: "Select milestone (none):" }, {class: 'select2 select2-compact'})
21 21
22 = hidden_field_tag :issue_context 22 = hidden_field_tag :issue_context
23 = f.submit class: 'btn' 23 = f.submit class: 'btn'
app/views/projects/issues/update.js.haml
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 - elsif params[:issue_context] 5 - elsif params[:issue_context]
6 $('.issue-box .context').html("#{escape_javascript(render partial: 'issue_context', locals: { issue: @issue })}"); 6 $('.issue-box .context').html("#{escape_javascript(render partial: 'issue_context', locals: { issue: @issue })}");
7 $('.issue-box .context').effect('highlight'); 7 $('.issue-box .context').effect('highlight');
8 - $('.chosen').chosen(); 8 + $('.select2').select2();
9 $('.edit-issue.inline-update input[type="submit"]').hide(); 9 $('.edit-issue.inline-update input[type="submit"]').hide();
10 - if @issue.milestone 10 - if @issue.milestone
11 $('.milestone-nav-link').replaceWith("<span class='milestone-nav-link'>| <span class='light'>Milestone</span> #{escape_javascript(link_to @issue.milestone.title, project_milestone_path(@issue.project, @issue.milestone))}</span>") 11 $('.milestone-nav-link').replaceWith("<span class='milestone-nav-link'>| <span class='light'>Milestone</span> #{escape_javascript(link_to @issue.milestone.title, project_milestone_path(@issue.project, @issue.milestone))}</span>")
app/views/projects/merge_requests/_form.html.haml
@@ -10,10 +10,10 @@ @@ -10,10 +10,10 @@
10 .col-md-5 10 .col-md-5
11 .clearfix 11 .clearfix
12 .pull-left 12 .pull-left
13 - = f.select(:source_project_id, [[@merge_request.source_project_path,@merge_request.source_project.id]] , {}, { class: 'source_project chosen span3', disabled: @merge_request.persisted? }) 13 + = f.select(:source_project_id, [[@merge_request.source_project_path,@merge_request.source_project.id]] , {}, { class: 'source_project select2 span3', disabled: @merge_request.persisted? })
14 .pull-left 14 .pull-left
15 &nbsp; 15 &nbsp;
16 - = f.select(:source_branch, @merge_request.source_project.repository.branch_names, { include_blank: "Select branch" }, {class: 'source_branch chosen span2'}) 16 + = f.select(:source_branch, @merge_request.source_project.repository.branch_names, { include_blank: "Select branch" }, {class: 'source_branch select2 span2'})
17 .mr_source_commit.prepend-top-10 17 .mr_source_commit.prepend-top-10
18 .col-md-2 18 .col-md-2
19 .merge-request-angle 19 .merge-request-angle
@@ -22,10 +22,10 @@ @@ -22,10 +22,10 @@
22 .clearfix 22 .clearfix
23 .pull-left 23 .pull-left
24 - projects = @project.forked_from_project.nil? ? [@project] : [ @project,@project.forked_from_project] 24 - projects = @project.forked_from_project.nil? ? [@project] : [ @project,@project.forked_from_project]
25 - = f.select(:target_project_id, options_from_collection_for_select(projects, 'id', 'path_with_namespace'), {}, { class: 'target_project chosen span3', disabled: @merge_request.persisted? }) 25 + = f.select(:target_project_id, options_from_collection_for_select(projects, 'id', 'path_with_namespace'), {}, { class: 'target_project select2 span3', disabled: @merge_request.persisted? })
26 .pull-left 26 .pull-left
27 &nbsp; 27 &nbsp;
28 - = f.select(:target_branch, @target_branches, { include_blank: "Select branch" }, {class: 'target_branch chosen span2'}) 28 + = f.select(:target_branch, @target_branches, { include_blank: "Select branch" }, {class: 'target_branch select2 span2'})
29 .mr_target_commit.prepend-top-10 29 .mr_target_commit.prepend-top-10
30 30
31 %hr 31 %hr
@@ -47,7 +47,7 @@ @@ -47,7 +47,7 @@
47 %i.icon-user 47 %i.icon-user
48 Assign to 48 Assign to
49 .col-sm-10 49 .col-sm-10
50 - = f.select(:assignee_id, assignee_options(@merge_request), { include_blank: "Select a user" }, {class: 'chosen'}) 50 + = f.select(:assignee_id, assignee_options(@merge_request), { include_blank: "Select a user" }, {class: 'select2'})
51 &nbsp; 51 &nbsp;
52 = link_to 'Assign to me', '#', class: 'btn btn-small assign-to-me-link' 52 = link_to 'Assign to me', '#', class: 'btn btn-small assign-to-me-link'
53 .form-group 53 .form-group
@@ -55,7 +55,7 @@ @@ -55,7 +55,7 @@
55 = f.label :milestone_id, class: 'control-label' do 55 = f.label :milestone_id, class: 'control-label' do
56 %i.icon-time 56 %i.icon-time
57 Milestone 57 Milestone
58 - .col-sm-10= f.select(:milestone_id, milestone_options(@merge_request), { include_blank: "Select milestone" }, {class: 'chosen'}) 58 + .col-sm-10= f.select(:milestone_id, milestone_options(@merge_request), { include_blank: "Select milestone" }, {class: 'select2'})
59 59
60 60
61 .form-actions 61 .form-actions
@@ -90,6 +90,6 @@ @@ -90,6 +90,6 @@
90 $.get("#{branch_to_project_merge_requests_path(@source_project)}", {target_project_id: target_project.val(),ref: $(this).val() }); 90 $.get("#{branch_to_project_merge_requests_path(@source_project)}", {target_project_id: target_project.val(),ref: $(this).val() });
91 }); 91 });
92 $('.assign-to-me-link').on('click', function(e){ 92 $('.assign-to-me-link').on('click', function(e){
93 - $('#merge_request_assignee_id').val("#{current_user.id}").trigger("chosen:updated"); 93 + $('#merge_request_assignee_id').val("#{current_user.id}").trigger("select2:updated");
94 e.preventDefault(); 94 e.preventDefault();
95 }); 95 });
app/views/projects/merge_requests/update_branches.js.haml
1 :plain 1 :plain
2 $(".target_branch").html("#{escape_javascript(options_for_select(@target_branches))}"); 2 $(".target_branch").html("#{escape_javascript(options_for_select(@target_branches))}");
3 - $(".target_branch").trigger("chosen:updated"); 3 + $(".target_branch").trigger("select2:updated");
4 $(".mr_target_commit").html(""); 4 $(".mr_target_commit").html("");
5 $(".target_branch").trigger("change"); 5 $(".target_branch").trigger("change");
app/views/projects/new.html.haml
@@ -27,7 +27,7 @@ @@ -27,7 +27,7 @@
27 = f.label :namespace_id, class: 'control-label' do 27 = f.label :namespace_id, class: 'control-label' do
28 %span Namespace 28 %span Namespace
29 .col-sm-10 29 .col-sm-10
30 - = f.select :namespace_id, namespaces_options(params[:namespace_id] || :current_user), {}, {class: 'chosen', tabindex: 2} 30 + = f.select :namespace_id, namespaces_options(params[:namespace_id] || :current_user), {}, {class: 'select2', tabindex: 2}
31 31
32 .form-group 32 .form-group
33 .col-sm-2 33 .col-sm-2
app/views/projects/protected_branches/index.html.haml
@@ -22,7 +22,7 @@ @@ -22,7 +22,7 @@
22 .entry.clearfix 22 .entry.clearfix
23 = f.label :name, "Branch" 23 = f.label :name, "Branch"
24 .col-md-3 24 .col-md-3
25 - = f.select(:name, @project.open_branches.map { |br| [br.name, br.name] } , {include_blank: "Select branch"}, {class: "chosen span3"}) 25 + = f.select(:name, @project.open_branches.map { |br| [br.name, br.name] } , {include_blank: "Select branch"}, {class: "select2 span3"})
26 &nbsp; 26 &nbsp;
27 = f.submit 'Protect', class: "btn-create btn" 27 = f.submit 'Protect', class: "btn-create btn"
28 - unless @branches.empty? 28 - unless @branches.empty?
app/views/projects/snippets/_form.html.haml
@@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
14 .col-sm-10= f.text_field :title, placeholder: "Example Snippet", class: 'form-control', required: true 14 .col-sm-10= f.text_field :title, placeholder: "Example Snippet", class: 'form-control', required: true
15 .form-group 15 .form-group
16 = f.label "Lifetime" 16 = f.label "Lifetime"
17 - .col-sm-10= f.select :expires_at, lifetime_select_options, {}, {class: 'chosen span2'} 17 + .col-sm-10= f.select :expires_at, lifetime_select_options, {}, {class: 'select2 span2'}
18 .form-group 18 .form-group
19 .file-editor 19 .file-editor
20 = f.label :file_name, "File" 20 = f.label :file_name, "File"
app/views/projects/team_members/_form.html.haml
@@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
17 %p 2. Set access level for them 17 %p 2. Set access level for them
18 .form-group 18 .form-group
19 = f.label :project_access, "Project Access", class: 'control-label' 19 = f.label :project_access, "Project Access", class: 'control-label'
20 - .col-sm-10= select_tag :project_access, options_for_select(Gitlab::Access.options, @user_project_relation.project_access), class: "project-access-select chosen" 20 + .col-sm-10= select_tag :project_access, options_for_select(Gitlab::Access.options, @user_project_relation.project_access), class: "project-access-select select2"
21 21
22 .form-actions 22 .form-actions
23 = f.submit 'Add users', class: "btn btn-create" 23 = f.submit 'Add users', class: "btn btn-create"
app/views/projects/team_members/import.html.haml
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 = form_tag apply_import_project_team_members_path(@project), method: 'post', class: 'form-horizontal' do 6 = form_tag apply_import_project_team_members_path(@project), method: 'post', class: 'form-horizontal' do
7 .form-group 7 .form-group
8 = label_tag :source_project_id, "Project", class: 'control-label' 8 = label_tag :source_project_id, "Project", class: 'control-label'
9 - .col-sm-10= select_tag(:source_project_id, options_from_collection_for_select(current_user.authorized_projects, :id, :name_with_namespace), prompt: "Select project", class: "chosen lg", required: true) 9 + .col-sm-10= select_tag(:source_project_id, options_from_collection_for_select(current_user.authorized_projects, :id, :name_with_namespace), prompt: "Select project", class: "select2 lg", required: true)
10 10
11 .form-actions 11 .form-actions
12 = submit_tag 'Import project members', class: "btn btn-create" 12 = submit_tag 'Import project members', class: "btn btn-create"
app/views/shared/_ref_switcher.html.haml
1 = form_tag switch_project_refs_path(@project), method: :get, class: "project-refs-form" do 1 = form_tag switch_project_refs_path(@project), method: :get, class: "project-refs-form" do
2 - = select_tag "ref", grouped_options_refs, class: "project-refs-select chosen chosen-sm" 2 + = select_tag "ref", grouped_options_refs, class: "project-refs-select select2 select2-sm"
3 = hidden_field_tag :destination, destination 3 = hidden_field_tag :destination, destination
4 - if defined?(path) 4 - if defined?(path)
5 = hidden_field_tag :path, path 5 = hidden_field_tag :path, path
features/steps/project/project_forked_merge_requests.rb
@@ -3,7 +3,7 @@ class ProjectForkedMergeRequests &lt; Spinach::FeatureSteps @@ -3,7 +3,7 @@ class ProjectForkedMergeRequests &lt; Spinach::FeatureSteps
3 include SharedProject 3 include SharedProject
4 include SharedNote 4 include SharedNote
5 include SharedPaths 5 include SharedPaths
6 - include ChosenHelper 6 + include Select2Helper
7 7
8 step 'I am a member of project "Shop"' do 8 step 'I am a member of project "Shop"' do
9 @project = Project.find_by_name "Shop" 9 @project = Project.find_by_name "Shop"
@@ -42,14 +42,14 @@ class ProjectForkedMergeRequests &lt; Spinach::FeatureSteps @@ -42,14 +42,14 @@ class ProjectForkedMergeRequests &lt; Spinach::FeatureSteps
42 end 42 end
43 43
44 step 'I fill out a "Merge Request On Forked Project" merge request' do 44 step 'I fill out a "Merge Request On Forked Project" merge request' do
45 - chosen @forked_project.id, from: "#merge_request_source_project_id"  
46 - chosen @project.id, from: "#merge_request_target_project_id" 45 + select2 @forked_project.id, from: "#merge_request_source_project_id"
  46 + select2 @project.id, from: "#merge_request_target_project_id"
47 47
48 find(:select, "merge_request_source_project_id", {}).value.should == @forked_project.id.to_s 48 find(:select, "merge_request_source_project_id", {}).value.should == @forked_project.id.to_s
49 find(:select, "merge_request_target_project_id", {}).value.should == @project.id.to_s 49 find(:select, "merge_request_target_project_id", {}).value.should == @project.id.to_s
50 50
51 - chosen "master", from: "#merge_request_source_branch"  
52 - chosen "stable", from: "#merge_request_target_branch" 51 + select2 "master", from: "#merge_request_source_branch"
  52 + select2 "stable", from: "#merge_request_target_branch"
53 53
54 find(:select, "merge_request_source_branch", {}).value.should == 'master' 54 find(:select, "merge_request_source_branch", {}).value.should == 'master'
55 find(:select, "merge_request_target_branch", {}).value.should == 'stable' 55 find(:select, "merge_request_target_branch", {}).value.should == 'stable'
features/steps/project/project_network_graph.rb
@@ -15,11 +15,11 @@ class ProjectNetworkGraph &lt; Spinach::FeatureSteps @@ -15,11 +15,11 @@ class ProjectNetworkGraph &lt; Spinach::FeatureSteps
15 end 15 end
16 16
17 And 'page should select "master" in select box' do 17 And 'page should select "master" in select box' do
18 - page.should have_selector '.chosen-single span', text: "master" 18 + page.should have_selector '.select2-chosen', text: "master"
19 end 19 end
20 20
21 And 'page should select "v2.1.0" in select box' do 21 And 'page should select "v2.1.0" in select box' do
22 - page.should have_selector '.chosen-single span', text: "v2.1.0" 22 + page.should have_selector '.select2-chosen', text: "v2.1.0"
23 end 23 end
24 24
25 And 'page should have "master" on graph' do 25 And 'page should have "master" on graph' do
@@ -56,11 +56,11 @@ class ProjectNetworkGraph &lt; Spinach::FeatureSteps @@ -56,11 +56,11 @@ class ProjectNetworkGraph &lt; Spinach::FeatureSteps
56 end 56 end
57 57
58 And 'page should select "stable" in select box' do 58 And 'page should select "stable" in select box' do
59 - page.should have_selector '.chosen-single span', text: "stable" 59 + page.should have_selector '.select2-chosen', text: "stable"
60 end 60 end
61 61
62 And 'page should select "v2.1.0" in select box' do 62 And 'page should select "v2.1.0" in select box' do
63 - page.should have_selector '.chosen-single span', text: "v2.1.0" 63 + page.should have_selector '.select2-chosen', text: "v2.1.0"
64 end 64 end
65 65
66 And 'page should have "stable" on graph' do 66 And 'page should have "stable" on graph' do
features/support/env.rb
@@ -15,7 +15,7 @@ require &#39;spinach/capybara&#39; @@ -15,7 +15,7 @@ require &#39;spinach/capybara&#39;
15 require 'sidekiq/testing/inline' 15 require 'sidekiq/testing/inline'
16 16
17 17
18 -%w(valid_commit big_commits select2_helper chosen_helper test_env).each do |f| 18 +%w(valid_commit big_commits select2_helper test_env).each do |f|
19 require Rails.root.join('spec', 'support', f) 19 require Rails.root.join('spec', 'support', f)
20 end 20 end
21 21
spec/support/chosen_helper.rb
@@ -1,21 +0,0 @@ @@ -1,21 +0,0 @@
1 -# Chosen programmatic helper  
2 -# It allows you to select value from chosen select  
3 -#  
4 -# Params  
5 -# value - real value of selected item  
6 -# opts - options containing css selector  
7 -#  
8 -# Usage:  
9 -#  
10 -# chosen(2, from: '#user_ids')  
11 -#  
12 -  
13 -module ChosenHelper  
14 - def chosen(value, options={})  
15 - raise "Must pass a hash containing 'from'" if not options.is_a?(Hash) or not options.has_key?(:from)  
16 -  
17 - selector = options[:from]  
18 -  
19 - page.execute_script("$('#{selector}').val('#{value}').trigger('chosen:updated');")  
20 - end  
21 -end