Browse Source

added better toggle callback support

pull/25/head
peterd 7 years ago
parent
commit
127a27dd23
  1. 12
      index.html
  2. 5
      jqColorPicker.js

12
index.html

@ -73,9 +73,9 @@ window.myColorPicker = $('input.color').colorPicker({
<p>Will follow... See <a href="https://github.com/PitPik/tinyColorPicker">tinyColorPicke on GitHub</a> for now.</p>
<!-- <script type="text/javascript" src="jquery-1.11.2.js"></script> -->
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
<!-- <script type="text/javascript" src="colors.js"></script> -->
<!-- <script type="text/javascript" src="jqColorPicker.js"></script> -->
<script type="text/javascript" src="jqColorPicker.min.js"></script>
<script type="text/javascript" src="colors.js"></script>
<script type="text/javascript" src="jqColorPicker.js"></script>
<!-- <script type="text/javascript" src="jqColorPicker.min.js"></script> -->
<script type="text/javascript">
(function(window, undefined){
'use strict';
@ -330,9 +330,13 @@ window.myColorPicker = $('input.color').colorPicker({
$('.cp-patch div').css({'background-color': $elm.css('background-color')});
$('.cp-disp').text($elm.val());
if (toggled) {
if (toggled === true) {
// here you can recalculate position after showing the color picker
// in case it doesn't fit into view.
$('.color').removeClass('active');
$elm.closest('.color').addClass('active');
} else if (toggled === false) {
$elm.closest('.color').removeClass('active');
}
}

5
jqColorPicker.js

@ -228,7 +228,10 @@
// _cache.$element[0].value = text;
_options.renderCallback.call(
_colorPicker, _cache.$element, toggled === true);
_colorPicker,
_cache.$element,
typeof toggled === 'boolean' ? toggled : undefined
);
}
// export as plugin to jQuery

Loading…
Cancel
Save