RGB Color Picker For Mobile " jQuery"
Admin
Good day for all of you my readers, today we will learn a new tutorial. It's a very simple plugin which depends on jQuery. This plug will enable you to create an RGB color picker for a mobile. Not only that, but with a button that pops up the RGB color gadget.
Just try to understand the steps, then you will start to establish the plugins in the right way.
So right now let me show you how it looks like:
How To use the Plugins
1- Before you start doing anything, you should load the very important needed "jQuery library, jQuery Mobile's JavaScript and Style-sheet" in your template or in your HTML document. I consider this the most important step of all.
2- Add the jQuery Simple Colorpicker's files in your document
3- Create the HTML "button and popup picker", meaning the elements for the color picker.
4- Now let us add the options to activate the color picker and apply the picked color to the background of the document with JavaScript.
5- No problem if you would like to use another color for the color picker box. Yes, it's possible! Options to customize the color picker are available. In the event that you want to change the Red, Green, and Blue text to something else, then use the `redText`, `greenText`, and `blueText` options, respectively.
As I mentioned above, I will give you all the codes completely.
1- Before you start doing anything, you should load the very important needed "jQuery library, jQuery Mobile's JavaScript and Style-sheet" in your template or in your HTML document. I consider this the most important step of all.
<link rel="stylesheet" href="PATH TO JQUERY MOBILE HERE.CSS"> <script src="PATH TO JQUERY.MIN.JS"></script> <script src="PATH TO JQUERY MOBILE HERE.JS"></script>Great! Do not worry, I will give you full and complete codes for everything at the end of the topic. Just try to understand the steps, OK.
2- Add the jQuery Simple Colorpicker's files in your document
<link rel="stylesheet" href="PATH OF COLOR PICKER.CSS"> <script src="PATH OF COLOR PICKER.JS"></script>
3- Create the HTML "button and popup picker", meaning the elements for the color picker.
<a id="button" href="#picker" data-rel="popup" class="ui-btn ui-btn-inline">Pick color</a> <div id="picker" data-role="colorpicker" data-transition="turn">Test</div>
4- Now let us add the options to activate the color picker and apply the picked color to the background of the document with JavaScript.
$(function(){ $('#picker').colorpicker('option', { picked: function(event, data){ $('div[data-role=page]').css('background-color', data.color) }, defaultColor: $('div[data-role=page]').css('background-color') }) $('#button').click(function(){ $('#picker').colorpicker('open') }) })
5- No problem if you would like to use another color for the color picker box. Yes, it's possible! Options to customize the color picker are available. In the event that you want to change the Red, Green, and Blue text to something else, then use the `redText`, `greenText`, and `blueText` options, respectively.
{ redText: 'Red', greenText: 'Green', blueText: 'Blue', defaultColor: '#000000' },
As I mentioned above, I will give you all the codes completely.