Skip to content

Commit

Permalink
Merge pull request #1159 from harvesthq/fix-rtl-issue-take-2
Browse files Browse the repository at this point in the history
This fixes the Right To Left scrollbar issue
  • Loading branch information
Ken Earley committed Apr 24, 2013
2 parents a1b98c6 + f1ff92a commit 37b64bc
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 62 deletions.
20 changes: 14 additions & 6 deletions chosen/chosen.css
Expand Up @@ -13,7 +13,7 @@
border-top: 0;
position: absolute;
top: 100%;
left: 0;
left: -9999px;
-webkit-box-shadow: 0 4px 5px rgba(0,0,0,.15);
-moz-box-shadow : 0 4px 5px rgba(0,0,0,.15);
box-shadow : 0 4px 5px rgba(0,0,0,.15);
Expand All @@ -25,6 +25,11 @@
-khtml-box-sizing : border-box;
box-sizing : border-box;
}

.chzn-container.chzn-with-drop .chzn-drop {
left: 0;
}

/* @end */

/* @group Single Chosen */
Expand Down Expand Up @@ -337,7 +342,7 @@
box-shadow : 0 0 5px rgba(0,0,0,.3);
border: 1px solid #5897fb;
}
.chzn-container-active .chzn-single-with-drop {
.chzn-container-active.chzn-with-drop .chzn-single {
border: 1px solid #aaa;
-webkit-box-shadow: 0 1px 0 #fff inset;
-moz-box-shadow : 0 1px 0 #fff inset;
Expand All @@ -356,11 +361,11 @@
border-bottom-left-radius : 0;
border-bottom-right-radius: 0;
}
.chzn-container-active .chzn-single-with-drop div {
.chzn-container-active.chzn-with-drop .chzn-single div {
background: transparent;
border-left: none;
}
.chzn-container-active .chzn-single-with-drop div b {
.chzn-container-active.chzn-with-drop .chzn-single div b {
background-position: -18px 2px;
}
.chzn-container-active .chzn-choices {
Expand Down Expand Up @@ -400,9 +405,12 @@
.chzn-rtl .chzn-choices li { float: right; }
.chzn-rtl .chzn-choices .search-choice { padding: 3px 5px 3px 19px; margin: 3px 5px 3px 0; }
.chzn-rtl .chzn-choices .search-choice .search-choice-close { left: 4px; right: auto; }
.chzn-rtl .chzn-search { left: 9999px; }
.chzn-rtl.chzn-with-drop .chzn-search { left: 0px; }
.chzn-rtl .chzn-drop { left: 9999px; }
.chzn-rtl.chzn-container-single .chzn-results { margin: 0 0 4px 4px; padding: 0 4px 0 0; }
.chzn-rtl .chzn-results .group-option { padding-left: 0; padding-right: 15px; }
.chzn-rtl.chzn-container-active .chzn-single-with-drop div { border-right: none; }
.chzn-rtl.chzn-container-active.chzn-with-drop .chzn-single div { border-right: none; }
.chzn-rtl .chzn-search input {
background: #fff url('chosen-sprite.png') no-repeat -30px -20px;
background: url('chosen-sprite.png') no-repeat -30px -20px, -webkit-gradient(linear, 0 0, 0 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff));
Expand All @@ -416,7 +424,7 @@
.chzn-container-single.chzn-rtl .chzn-single div b {
background-position: 6px 2px;
}
.chzn-container-single.chzn-rtl .chzn-single-with-drop div b {
.chzn-container-single.chzn-rtl.chzn-with-drop .chzn-single div b {
background-position: -12px 2px;
}
/* @end */
Expand Down
24 changes: 7 additions & 17 deletions chosen/chosen.jquery.js
Expand Up @@ -384,9 +384,9 @@ Copyright (c) 2011 by Harvest
};
this.container = $("<div />", container_props);
if (this.is_multiple) {
this.container.html('<ul class="chzn-choices"><li class="search-field"><input type="text" value="' + this.default_text + '" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>');
this.container.html('<ul class="chzn-choices"><li class="search-field"><input type="text" value="' + this.default_text + '" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop"><ul class="chzn-results"></ul></div>');
} else {
this.container.html('<a href="javascript:void(0)" class="chzn-single chzn-default" tabindex="-1"><span>' + this.default_text + '</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>');
this.container.html('<a href="javascript:void(0)" class="chzn-single chzn-default" tabindex="-1"><span>' + this.default_text + '</span><div><b></b></div></a><div class="chzn-drop"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>');
}
this.form_field_jq.hide().after(this.container);
this.dropdown = this.container.find('div.chzn-drop').first();
Expand Down Expand Up @@ -617,40 +617,30 @@ Copyright (c) 2011 by Harvest
};

Chosen.prototype.results_show = function() {
if (!this.is_multiple) {
this.selected_item.addClass("chzn-single-with-drop");
if (this.result_single_selected) {
this.result_do_highlight(this.result_single_selected);
}
} else if (this.max_selected_options <= this.choices) {
if (this.result_single_selected != null) {
this.result_do_highlight(this.result_single_selected);
} else if (this.is_multiple && this.max_selected_options <= this.choices) {
this.form_field_jq.trigger("liszt:maxselected", {
chosen: this
});
return false;
}
this.container.addClass("chzn-with-drop");
this.form_field_jq.trigger("liszt:showing_dropdown", {
chosen: this
});
this.dropdown.css({
"left": 0
});
this.results_showing = true;
this.search_field.focus();
this.search_field.val(this.search_field.val());
return this.winnow_results();
};

Chosen.prototype.results_hide = function() {
if (!this.is_multiple) {
this.selected_item.removeClass("chzn-single-with-drop");
}
this.result_clear_highlight();
this.container.removeClass("chzn-with-drop");
this.form_field_jq.trigger("liszt:hiding_dropdown", {
chosen: this
});
this.dropdown.css({
"left": "-9000px"
});
return this.results_showing = false;
};

Expand Down
2 changes: 1 addition & 1 deletion chosen/chosen.jquery.min.js

Large diffs are not rendered by default.

24 changes: 7 additions & 17 deletions chosen/chosen.proto.js
Expand Up @@ -348,8 +348,8 @@ Copyright (c) 2011 by Harvest

Chosen.prototype.set_default_values = function() {
Chosen.__super__.set_default_values.call(this);
this.single_temp = new Template('<a href="javascript:void(0)" class="chzn-single chzn-default" tabindex="-1"><span>#{default}</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>');
this.multi_temp = new Template('<ul class="chzn-choices"><li class="search-field"><input type="text" value="#{default}" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>');
this.single_temp = new Template('<a href="javascript:void(0)" class="chzn-single chzn-default" tabindex="-1"><span>#{default}</span><div><b></b></div></a><div class="chzn-drop"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>');
this.multi_temp = new Template('<ul class="chzn-choices"><li class="search-field"><input type="text" value="#{default}" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop"><ul class="chzn-results"></ul></div>');
this.choice_temp = new Template('<li class="search-choice" id="#{id}"><span>#{choice}</span><a href="javascript:void(0)" class="search-choice-close" rel="#{position}"></a></li>');
this.choice_noclose_temp = new Template('<li class="search-choice search-choice-disabled" id="#{id}"><span>#{choice}</span></li>');
return this.no_results_temp = new Template('<li class="no-results">' + this.results_none_found + ' "<span>#{terms}</span>"</li>');
Expand Down Expand Up @@ -605,40 +605,30 @@ Copyright (c) 2011 by Harvest
};

Chosen.prototype.results_show = function() {
if (!this.is_multiple) {
this.selected_item.addClassName('chzn-single-with-drop');
if (this.result_single_selected) {
this.result_do_highlight(this.result_single_selected);
}
} else if (this.max_selected_options <= this.choices) {
if (this.result_single_selected != null) {
this.result_do_highlight(this.result_single_selected);
} else if (this.is_multiple && this.max_selected_options <= this.choices) {
this.form_field.fire("liszt:maxselected", {
chosen: this
});
return false;
}
this.container.addClassName("chzn-with-drop");
this.form_field.fire("liszt:showing_dropdown", {
chosen: this
});
this.dropdown.setStyle({
"left": 0
});
this.results_showing = true;
this.search_field.focus();
this.search_field.value = this.search_field.value;
return this.winnow_results();
};

Chosen.prototype.results_hide = function() {
if (!this.is_multiple) {
this.selected_item.removeClassName('chzn-single-with-drop');
}
this.result_clear_highlight();
this.container.removeClassName("chzn-with-drop");
this.form_field.fire("liszt:hiding_dropdown", {
chosen: this
});
this.dropdown.setStyle({
"left": "-9000px"
});
return this.results_showing = false;
};

Expand Down
2 changes: 1 addition & 1 deletion chosen/chosen.proto.min.js

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions coffee/chosen.jquery.coffee
Expand Up @@ -44,9 +44,9 @@ class Chosen extends AbstractChosen
@container = ($ "<div />", container_props)

if @is_multiple
@container.html '<ul class="chzn-choices"><li class="search-field"><input type="text" value="' + @default_text + '" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>'
@container.html '<ul class="chzn-choices"><li class="search-field"><input type="text" value="' + @default_text + '" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop"><ul class="chzn-results"></ul></div>'
else
@container.html '<a href="javascript:void(0)" class="chzn-single chzn-default" tabindex="-1"><span>' + @default_text + '</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>'
@container.html '<a href="javascript:void(0)" class="chzn-single chzn-default" tabindex="-1"><span>' + @default_text + '</span><div><b></b></div></a><div class="chzn-drop"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>'

@form_field_jq.hide().after @container
@dropdown = @container.find('div.chzn-drop').first()
Expand Down Expand Up @@ -220,16 +220,15 @@ class Chosen extends AbstractChosen
@result_highlight = null

results_show: ->
if not @is_multiple
@selected_item.addClass "chzn-single-with-drop"
if @result_single_selected
this.result_do_highlight( @result_single_selected )
else if @max_selected_options <= @choices
if @result_single_selected?
this.result_do_highlight @result_single_selected
else if @is_multiple and @max_selected_options <= @choices
@form_field_jq.trigger("liszt:maxselected", {chosen: this})
return false

@container.addClass "chzn-with-drop"
@form_field_jq.trigger("liszt:showing_dropdown", {chosen: this})
@dropdown.css {"left":0}

@results_showing = true

@search_field.focus()
Expand All @@ -238,10 +237,11 @@ class Chosen extends AbstractChosen
this.winnow_results()

results_hide: ->
@selected_item.removeClass "chzn-single-with-drop" unless @is_multiple
this.result_clear_highlight()

@container.removeClass "chzn-with-drop"
@form_field_jq.trigger("liszt:hiding_dropdown", {chosen: this})
@dropdown.css {"left":"-9000px"}

@results_showing = false


Expand Down
20 changes: 10 additions & 10 deletions coffee/chosen.proto.coffee
Expand Up @@ -17,8 +17,8 @@ class Chosen extends AbstractChosen
super()

# HTML Templates
@single_temp = new Template('<a href="javascript:void(0)" class="chzn-single chzn-default" tabindex="-1"><span>#{default}</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>')
@multi_temp = new Template('<ul class="chzn-choices"><li class="search-field"><input type="text" value="#{default}" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>')
@single_temp = new Template('<a href="javascript:void(0)" class="chzn-single chzn-default" tabindex="-1"><span>#{default}</span><div><b></b></div></a><div class="chzn-drop"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>')
@multi_temp = new Template('<ul class="chzn-choices"><li class="search-field"><input type="text" value="#{default}" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop"><ul class="chzn-results"></ul></div>')
@choice_temp = new Template('<li class="search-choice" id="#{id}"><span>#{choice}</span><a href="javascript:void(0)" class="search-choice-close" rel="#{position}"></a></li>')
@choice_noclose_temp = new Template('<li class="search-choice search-choice-disabled" id="#{id}"><span>#{choice}</span></li>')
@no_results_temp = new Template('<li class="no-results">' + @results_none_found + ' "<span>#{terms}</span>"</li>')
Expand Down Expand Up @@ -207,16 +207,15 @@ class Chosen extends AbstractChosen
@result_highlight = null

results_show: ->
if not @is_multiple
@selected_item.addClassName('chzn-single-with-drop')
if @result_single_selected
this.result_do_highlight( @result_single_selected )
else if @max_selected_options <= @choices
if @result_single_selected?
this.result_do_highlight @result_single_selected
else if @is_multiple and @max_selected_options <= @choices
@form_field.fire("liszt:maxselected", {chosen: this})
return false

@container.addClassName "chzn-with-drop"
@form_field.fire("liszt:showing_dropdown", {chosen: this})
@dropdown.setStyle {"left":0}

@results_showing = true

@search_field.focus()
Expand All @@ -225,10 +224,11 @@ class Chosen extends AbstractChosen
this.winnow_results()

results_hide: ->
@selected_item.removeClassName('chzn-single-with-drop') unless @is_multiple
this.result_clear_highlight()

@container.removeClassName "chzn-with-drop"
@form_field.fire("liszt:hiding_dropdown", {chosen: this})
@dropdown.setStyle({"left":"-9000px"})

@results_showing = false


Expand Down
5 changes: 5 additions & 0 deletions example.jquery.html
Expand Up @@ -48,6 +48,11 @@
}
</style>
<link rel="stylesheet" href="chosen/chosen.css" />
<style type="text/css" media="all">
/* fix rtl for demo */
.chzn-rtl .chzn-search { left: -9000px; }
.chzn-rtl .chzn-drop { left: -9000px; }
</style>
</head>
<body>
<form>
Expand Down
5 changes: 5 additions & 0 deletions example.proto.html
Expand Up @@ -48,6 +48,11 @@
}
</style>
<link rel="stylesheet" href="chosen/chosen.css" />
<style type="text/css" media="all">
/* fix rtl for demo */
.chzn-rtl .chzn-search { left: -9000px; }
.chzn-rtl .chzn-drop { left: -9000px; }
</style>
</head>
<body>
<div id="container">
Expand Down

0 comments on commit 37b64bc

Please sign in to comment.