Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kuldeep Kamboj
committed
Jan 6, 2015
1 parent
ad29f0a
commit 22d7713
Showing
6 changed files
with
1,274 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
table.color-shades { | ||
border-collapse: collapse; | ||
} | ||
table.color-shades td, table.color-shades th { | ||
border: 1px solid black; | ||
} | ||
table.color-shades tr:first-child th { | ||
border-top: 0; | ||
} | ||
table.color-shades tr:last-child td { | ||
border-bottom: 0; | ||
} | ||
table.color-shades tr td:first-child, | ||
table.color-shades tr th:first-child { | ||
border-left: 0; | ||
} | ||
table.color-shades tr td:last-child, | ||
table.color-shades tr th:last-child { | ||
border-right: 0; | ||
} | ||
table.color-shades td { | ||
width: 20px; | ||
height: 30px; | ||
font-size: 9px; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
(function ( $ ) { | ||
$.fn.colorShades = function(options) { | ||
var settings = $.extend({ | ||
// These are the defaults. | ||
l_items: 3, | ||
r_items: 7, | ||
step: 2, | ||
base_color: '#568203', | ||
show_color_code: false | ||
|
||
}, options ); | ||
var cell_count = settings.l_items + settings.r_items + 1; | ||
var input_name = $(this).prop('name'); | ||
$('<table class="color-shades color-shades-'+ input_name +'"><tr></tr><tr></tr></table>').insertAfter($(this)); | ||
var col = tinycolor(settings.base_color); | ||
var colostr = col.toString(); | ||
for(i=0;i< cell_count;i++) | ||
{ | ||
$('table.color-shades-'+ input_name + ' tr:first').append('<td></td>'); | ||
if(settings.show_color_code === true) | ||
{ | ||
$('table.color-shades-'+ input_name + ' tr:eq(1)').append('<td></td>'); | ||
} | ||
} | ||
|
||
for(i=0;i<settings.l_items;i++) | ||
{ | ||
colostr = col.lighten(settings.step).toString(); | ||
$('table.color-shades-'+ input_name + ' tr:first').find('td').eq(settings.l_items-i-1).css('background-color', colostr); | ||
if(settings.show_color_code === true) | ||
{ | ||
$('table.color-shades-'+ input_name + ' tr:eq(1)').find('td').eq(settings.l_items-i-1).html(colostr); | ||
} | ||
} | ||
|
||
var col = tinycolor(settings.base_color); | ||
var colostr = col.toString(); | ||
|
||
$('table.color-shades-'+ input_name + ' tr:first').find('td').eq(settings.l_items).css('background-color', colostr); | ||
if(settings.show_color_code === true) | ||
{ | ||
$('table.color-shades-'+ input_name + ' tr:eq(1)').find('td').eq(settings.l_items).html(colostr); | ||
} | ||
for(i=0;i<settings.r_items;i++) | ||
{ | ||
colostr = col.darken(settings.step).toString(); | ||
$('table.color-shades-'+ input_name + ' tr:first').find('td').eq(settings.l_items+1+i).css('background-color', colostr); | ||
if(settings.show_color_code === true) | ||
{ | ||
$('table.color-shades-'+ input_name + ' tr:eq(1)').find('td').eq(settings.l_items+1+i).html(colostr);; | ||
} | ||
} | ||
var $input = $(this); | ||
$('table.color-shades-'+ input_name + ' tr:first').find('td').click(function() { | ||
var color = tinycolor($(this).css('background-color')); | ||
$input.val(color.toHex()); | ||
}); | ||
return this; | ||
}; | ||
}( jQuery )); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<html> | ||
<head> | ||
<link href="colorShades.css" media="screen" rel="stylesheet" type="text/css"> | ||
<script src="vendors/jquery.min.js"></script> | ||
<script src="vendors/tinycolor.js"></script> | ||
<script src="colorShades.js"></script> | ||
|
||
</head> | ||
<body> | ||
<input type="text" name="custom" id="custom" /> | ||
<br/> | ||
<br/><br/><br/><br/> | ||
|
||
<input type="text" name="custom1" id="custom1" /> | ||
|
||
|
||
<script> | ||
|
||
$('#custom').colorShades({ | ||
l_items: 3, | ||
r_items: 5, | ||
step: 3, | ||
base_color: '#568203' | ||
}); | ||
|
||
$('#custom1').colorShades({ | ||
l_items: 20, | ||
r_items: 20, | ||
step: 1, | ||
base_color: '#568203' | ||
}); | ||
|
||
|
||
</script> | ||
</body> | ||
</html> |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.