somatonic / colorpicker Goto Github PK
View Code? Open in Web Editor NEWProcessWire2.+ ColorPicker Inputfieldtype
ProcessWire2.+ ColorPicker Inputfieldtype
I know this repo isn't active anymore, but for the sake of reporting.
For a project I am using 5 color pickers next to each other, however, only the first one opens when clicked. The rest doesn't trigger anything. I'm not sure where this bug comes from.
very quick and dirty hack, but seems to work. Not sure if it would cause any other issues.
function SetUpCPicker(){
$('div[id^=ColorPicker_]').each(function(){
var
$colorpicker.ColorPicker({
color: $(this).data('color').toString(),
onShow: function (colpkr) {
$(colpkr).fadeIn(500);
return false;
},
onHide: function (colpkr) {
$(colpkr).fadeOut(500);
return false;
},
onChange: function (hsb, hex, rgb) {
$colorpicker.css('backgroundColor', '#' + hex);
$colorpicker.css('background-image', 'none');
$colorpicker.next('input').val(hex).trigger('change');
}
});
});
$('a.ColorPickerReset').on('click',function(e){
e.preventDefault();
var color = $(this).data('default') && $(this).data('default') != 'transp' ? '#' + $(this).data('default').toString() : 'transparent';
$(this).parent().find('input').val($(this).data('default')).trigger('change');
$(this).parent().find('div[id^=ColorPicker_]').ColorPickerSetColor($(this).data('default').toString());
$(this).parent().find('div[id^=ColorPicker_]')
.css('backgroundColor', color)
.css('background-image', 'none')
.attr('data-color', $(this).data('default').toString());
if(color == 'transparent') {
var modurl = $(this).data('modurl');
$(this).parent().find('div[id^=ColorPicker_]')
.css('background-image', 'url(' + modurl + 'transparent.gif)');
}
});
/* additions (swatches) by @Rayden */
$('div.ColorPickerSwatch').on('click',function(e){
e.preventDefault();
var color = $(this).data('color') && $(this).data('color') != 'transp' ? '#' + $(this).data('color').toString() : 'transparent';
$(this).closest('.ui-widget-content, .InputfieldContent').find('input').val($(this).data('color')).trigger('change');
$(this).closest('.ui-widget-content, .InputfieldContent').find('div[id^=ColorPicker_]').ColorPickerSetColor($(this).data('color').toString());
$(this).closest('.ui-widget-content, .InputfieldContent').find('div[id^=ColorPicker_]')
.css('backgroundColor', color)
.css('background-image', 'none')
.attr('data-color', $(this).data('color').toString());
if(color == 'transparent') {
var modurl = $(this).closest('.ui-widget-content, .InputfieldContent').find('.ColorPickerReset').data('modurl');
$(this).closest('.ui-widget-content, .InputfieldContent').find('div[id^=ColorPicker_]')
.css('background-image', 'url(' + modurl + 'transparent.gif)');
}
});
};
$(document).ready(function() {
SetUpCPicker();
$(document).on('repeateradd', '.InputfieldRepeaterMatrix .InputfieldRepeaterMatrixAddLink', SetUpCPicker);
$(document).on('opened', '.InputfieldRepeaterItem', SetUpCPicker);
});
Hello Soma,
I have cloned the color picker and i have added the capability to use predefined color swatch and the posibility to use "transparent" as a value. This works great for 99%.
There is one known bug in that fork by me. That is that it always loads up with the default color. Do you perhaps can see what causes this problem?
I hope you like the idea of color swatches and transparent as value (in some cases i want to be able to use transparent as background, while being able to pick an other color). If you like it i hope you can implement these features in the original processwire colorpicker module.
After I installed this with Modules Manager, and created new field, system automatically locks up whenever I try to edit this field with
TemplateFile: Method InputfieldColorPicker::moduleGetInfo does not exist or is not callable in this context
I also can't uninstall it, since the systems just locks up when the error comes up.
I can see that the .js is dual licensed MIT or GPL, is this the main license of ColorPicker? Does this apply to the images also?
Perhaps some earlier versions has this too, but I had to increase the z-index in the css for the .colorpicker
Hey, I noticed with output formatting active, #0E1779
becomes #000000
.
Must be this line and some funny php behaviour.
var_dump("0E1779" == "0"); // bool(true)
I guess PHP interprets the color as 0e1779
(scientific notation), becoming 0
.
Strict comparison ===
fixes this.
Edit: I'm not really sure what this line does to begin with. I only see it "trigger" when I configure a Default Value "0".
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.