New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the bootstrap colorpicker component #175

Closed
ceefour opened this Issue May 1, 2013 · 4 comments

Comments

Projects
None yet
2 participants
@ceefour
Copy link
Contributor

ceefour commented May 1, 2013

JavaScript plugin is here :

http://www.eyecon.ro/bootstrap-colorpicker/

@ceefour

This comment has been minimized.

Copy link
Contributor Author

ceefour commented May 1, 2013

Initial implementation:

package org.soluvas.web.bootstrap.widget;

import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.head.CssHeaderItem;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.resource.CssResourceReference;
import org.apache.wicket.request.resource.JavaScriptResourceReference;

/**
 * Bootstrap ColorPicker from http://www.eyecon.ro/bootstrap-colorpicker/
 * @author ceefour
 */
@SuppressWarnings("serial")
public class ColorPickerTextField extends TextField<String> {

    private static JavaScriptResourceReference colorpickerJs = new JavaScriptResourceReference(
            ColorPickerTextField.class, "bootstrap-colorpicker.js");
    private static CssResourceReference colorpickerCss = new CssResourceReference(
            ColorPickerTextField.class, "colorpicker.css");

    /**
     * @param id
     */
    public ColorPickerTextField(String id) {
        super(id, String.class);
    }

    /**
     * @param id
     * @param model
     */
    public ColorPickerTextField(String id, IModel<String> model) {
        super(id, model, String.class);
    }

    @Override
    protected void onInitialize() {
        super.onInitialize();
        add(new AttributeAppender("class", new Model<>("bootstrap-colorpicker"), " "));
    }

    @Override
    public void renderHead(IHeaderResponse response) {
        super.renderHead(response);
        response.render(CssHeaderItem.forReference(colorpickerCss));
        response.render(JavaScriptHeaderItem.forReference(colorpickerJs));
        response.render(JavaScriptHeaderItem.forScript("$(document).ready(function() {" +
                "$('.bootstrap-colorpicker').colorpicker();" +
            "});",
            "bootstrap-colorpicker"));
    }

    @Override
    protected void onComponentTag(ComponentTag tag) {
        super.onComponentTag(tag);
    }

}
@martin-g

This comment has been minimized.

Copy link
Collaborator

martin-g commented May 1, 2013

Use GitHub properly, i.e. make a Pull Request ;-)

@ceefour

This comment has been minimized.

Copy link
Contributor Author

ceefour commented May 15, 2013

Done :)

martin-g added a commit that referenced this issue May 16, 2013

martin-g added a commit that referenced this issue May 16, 2013

Issue #175 Color Picker
Add support for Ajax updates
Add support for usage as "component"

martin-g added a commit that referenced this issue May 16, 2013

@martin-g martin-g closed this in 23d1194 May 16, 2013

@ceefour

This comment has been minimized.

Copy link
Contributor Author

ceefour commented May 16, 2013

Thank you @martin-g ! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment