src/ztfy/utils/browser/templates/color_input.pt
branchZTK-1.1
changeset 148 d3668ecd9137
parent 140 d5e916191cf4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ztfy/utils/browser/templates/color_input.pt	Wed Jun 20 16:29:53 2012 +0200
@@ -0,0 +1,32 @@
+<div class="colorSelector"
+	 tal:attributes="id string:${view/id}_selector">
+	<input type="hidden"
+		   tal:attributes="id view/id;
+						   name view/name;
+						   lang view/lang;
+						   value view/value;" />
+	<div></div>
+	<script type="text/javascript" tal:content="string:
+		$$(document).ready(function() {
+			$$('DIV[id=${view/id}_selector] div').css('backgroundColor', '#${view/value}');
+			$$('DIV[id=${view/id}_selector]').ColorPicker({
+				color: '#${view/value}',
+				onShow: function (colpkr) {
+					$$(colpkr).fadeIn(500);
+					return false;
+				},
+				onHide: function (colpkr) {
+					$$(colpkr).fadeOut(500);
+					return false;
+				},
+				onChange: function (hsb, hex, rgb) {
+					$$('DIV[id=${view/id}_selector] div').css('backgroundColor', '#' + hex);
+					$$('INPUT[id=${view/id}]').val(hex);
+				},
+				onSubmit: function() {
+					$$('DIV[id=${view/id}_selector]').ColorPickerHide();
+				}
+			});
+		});
+	"></script>
+</div>
\ No newline at end of file