Currently, a json is being generated using ng model
and then placed in a binding box at the bottom of the page with ng-binding
. The dynamic colourpicker is altering two elements - the textbox and box. You can see an example here: http://codepen.io/voronianski/pen/zpahm
I am looking to obtain either the text hex code (preferred) or the RGB code, both are feasible options.
The code structure matches that of the codepen example provided.
<script type="text/javascript">
var hexText="";
var colorList = [ '000000', '993300', '333300', '003300', '003366', '000066', '333399', '333333',
'660000', 'FF6633', '666633', '336633', '336666', '0066FF', '666699', '666666', 'CC3333', 'FF9933',
'99CC33', '669966', '66CCCC', '3366FF', '663366', '999999', 'CC66FF', 'FFCC33', 'FFFF66', '99FF66'];
var codeHex = $(this).data('hex');
hexText = codeHex;
var picker = $('#color-picker');
for (var i = 0; i < colorList.length; i++ ) {
picker.append('<li class="color-item" data-hex="' + '#' + colorList[i] + '" style="background-color:' + '#' + colorList[i] + ';"></li>');
}
$('body').click(function () {
picker.fadeOut(1);
});
$('.call-picker').click(function(event) {
event.stopPropagation();
picker.fadeIn(1);
picker.children('li').hover(function() {
var codeHex = $(this).data('hex');
$('.color-holder').css('background-color', codeHex);
$('#pickcolor').val(codeHex);
});
});
</script>
Html
<div class="color-wrapper">
<p>Choose color for Header</p>
<!-- ng-model="eventData.header" This is to post the information in the color picker box into the json at the bottom to make it useable by the server. -->
<input type="text" name="custom_color" ng-model="eventData.header" placeholder="#FFFFFF" id="pickcolor" class="call-picker">
<div class="color-holder call-picker"></div>
<div class="color-picker" id="color-picker" style="display: none"></div>
</div>