Skip to content

Commit

Permalink
added rgba fallback for hex with opacity
Browse files Browse the repository at this point in the history
  • Loading branch information
istvan-ujjmeszaros committed Aug 11, 2014
1 parent 7a7ea8e commit e6519ae
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 52 deletions.
49 changes: 25 additions & 24 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,37 @@ <h1>Bootstrap Color Picker Sliders</h1>

<h2>Examples</h2>

<h3>Full featured popover (HSV panel, HSL and RGB sliders, color swatches)</h3>

This popovers shows all the features in a grouped manner, so the user can choose the preferred color picking method.

<div class="row">
<div class="col-md-4">
<form class="form-vertical" role="form">
<div class="form-group">
<label for="small" class="control-label">Full featured popover</label>
<input type="text" class="form-control" id="full-popover" value="#A6FF00" data-color-format="hex">
</div>
</form>
</div>
</div>

<script>
$("input#full-popover").ColorPickerSliders({
placement: 'right',
hsvpanel: true,
previewformat: 'hex'
});
</script>

<h3>HSV flat</h3>

<div class="row">
<div class="col-md-6">
<div class="col-md-4">
<div id="hsvflat"></div>
</div>

<div class="col-md-6">
<div class="col-md-8">
<pre class="prettyprint">
&lt;div id=&quot;hsvflat&quot;&gt;&lt;/div&gt;
&lt;script&gt;
Expand Down Expand Up @@ -113,28 +136,6 @@ <h3>HSL and CIE Lch sliders with customizable color swatches (flat rendering)</h
</div>
</div>

<h3>Full featured popover (HSV panel, HSL and RGB sliders, color swatches)</h3>

This popovers shows all the features in a grouped manner, so the user can choose the preferred color picking method.

<div class="row">
<div class="col-md-4">
<form class="form-vertical" role="form">
<div class="form-group">
<label for="small" class="control-label">Full featured popover</label>
<input type="text" class="form-control" id="full-popover" value="#0040FF">
</div>
</form>
</div>
</div>

<script>
$("input#full-popover").ColorPickerSliders({
placement: 'right',
hsvpanel: true
});
</script>

<h3>Different sizes and color sliders (in bootstrap popovers)</h3>

<div class="row">
Expand Down
49 changes: 25 additions & 24 deletions nocielch.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,37 @@ <h1>Bootstrap Color Picker Sliders</h1>

<h2>Examples</h2>

<h3>Full featured popover (HSV panel, HSL and RGB sliders, color swatches)</h3>

This popovers shows all the features in a grouped manner, so the user can choose the preferred color picking method.

<div class="row">
<div class="col-md-4">
<form class="form-vertical" role="form">
<div class="form-group">
<label for="small" class="control-label">Full featured popover</label>
<input type="text" class="form-control" id="full-popover" value="#A6FF00" data-color-format="hex">
</div>
</form>
</div>
</div>

<script>
$("input#full-popover").ColorPickerSliders({
placement: 'right',
hsvpanel: true,
previewformat: 'hex'
});
</script>

<h3>HSV flat</h3>

<div class="row">
<div class="col-md-6">
<div class="col-md-4">
<div id="hsvflat"></div>
</div>

<div class="col-md-6">
<div class="col-md-8">
<pre class="prettyprint">
&lt;div id=&quot;hsvflat&quot;&gt;&lt;/div&gt;
&lt;script&gt;
Expand Down Expand Up @@ -111,28 +134,6 @@ <h3>HSL sliders with customizable color swatches (flat rendering)</h3>
</div>
</div>

<h3>Full featured popover (HSV panel, HSL and RGB sliders, color swatches)</h3>

This popovers shows all the features in a grouped manner, so the user can choose the preferred color picking method.

<div class="row">
<div class="col-md-4">
<form class="form-vertical" role="form">
<div class="form-group">
<label for="small" class="control-label">Full featured popover</label>
<input type="text" class="form-control" id="full-popover" value="#0040FF">
</div>
</form>
</div>
</div>

<script>
$("input#full-popover").ColorPickerSliders({
placement: 'right',
hsvpanel: true
});
</script>

<h3>Different sizes and color sliders (in bootstrap popovers)</h3>

<div class="row">
Expand Down
14 changes: 12 additions & 2 deletions src/bootstrap.colorpickersliders.js
Original file line number Diff line number Diff line change
Expand Up @@ -1336,7 +1336,12 @@

switch (format) {
case 'hex':
$element.val(color.tiny.toHexString());
if (color.hsla.a < 1) {
$element.val(color.tiny.toRgbString());
}
else {
$element.val(color.tiny.toHexString());
}
break;
case 'hsl':
$element.val(color.tiny.toHslString());
Expand Down Expand Up @@ -1479,7 +1484,12 @@

switch (settings.previewformat) {
case 'hex':
colorstring = color.tiny.toHexString();
if (color.hsla.a < 1) {
colorstring = color.tiny.toRgbString();
}
else {
colorstring = color.tiny.toHexString();
}
break;
case 'hsl':
colorstring = color.tiny.toHslString();
Expand Down
14 changes: 12 additions & 2 deletions src/bootstrap.colorpickersliders.nocielch.js
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,12 @@

switch (format) {
case 'hex':
$element.val(color.tiny.toHexString());
if (color.hsla.a < 1) {
$element.val(color.tiny.toRgbString());
}
else {
$element.val(color.tiny.toHexString());
}
break;
case 'hsl':
$element.val(color.tiny.toHslString());
Expand Down Expand Up @@ -1301,7 +1306,12 @@

switch (settings.previewformat) {
case 'hex':
colorstring = color.tiny.toHexString();
if (color.hsla.a < 1) {
colorstring = color.tiny.toRgbString();
}
else {
colorstring = color.tiny.toHexString();
}
break;
case 'hsl':
colorstring = color.tiny.toHslString();
Expand Down

0 comments on commit e6519ae

Please sign in to comment.