Skip to content

Commit c3d57f4

Browse files
committed
Fixes 174
1 parent e1433b0 commit c3d57f4

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

index.html

+1-2
Original file line numberDiff line numberDiff line change
@@ -620,8 +620,7 @@ <h3 id="methods">Methods</h3>
620620
<dd>
621621
<p>
622622
Gets or sets a control's color value. To use this method as a setter, pass
623-
<code>data</code> in as a hex value. (You can also obtain this value by checking the
624-
input element's <code>value</code> attribute.)
623+
in a color string or an object (ex: <code>{color: '#fc0', opacity: .5}</code>).
625624
</p>
626625
</dd>
627626
</dl>

jquery.minicolors.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,17 @@
115115
} else {
116116
// Setter
117117
$(this).each( function() {
118-
updateFromInput($(this).val(data));
118+
if( typeof(data) === 'object' ) {
119+
if( data.opacity ) {
120+
$(this).attr('data-opacity', keepWithin(data.opacity, 0, 1));
121+
}
122+
if( data.color ) {
123+
$(this).val(data.color);
124+
}
125+
} else {
126+
$(this).val(data);
127+
}
128+
updateFromInput($(this));
119129
});
120130
}
121131
return $(this);

0 commit comments

Comments
 (0)