
com.jwebmp.plugins.spectrum.colourpicker.JQSpectrumColourPickerOptions Maven / Gradle / Ivy
/*
* Copyright (C) 2017 GedMarc
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package com.jwebmp.plugins.spectrum.colourpicker;
import com.jwebmp.core.htmlbuilder.css.colours.ColourNames;
import com.jwebmp.core.htmlbuilder.javascript.JavaScriptPart;
import com.jwebmp.core.htmlbuilder.javascript.JavascriptPartType;
/**
* The options granted by the spectrum plugin
*
*
* @author GedMarc
* @since 2015/05/02
*/
public class JQSpectrumColourPickerOptions
extends JavaScriptPart
{
/**
* The initial color will be set with the color option. If you don't pass in a color, Spectrum will use the value attribute on the input.
*
* The color parsing is based on the TinyColor plugin. This should parse any color string you throw at it.
*/
private String color;
/**
* This means that it will always show up at full size, and be positioned as an inline-block element. Look to the left for a full sized flat picker.
*/
private Boolean flat;
/**
* You can add an input to allow free form typing. The color parsing is very permissive in the allowed strings. See TinyColor for more details.
*/
private Boolean showInput;
/**
* Spectrum can show the color that was initially set when opening. This provides an easy way to click back to what was set when opened.
*/
private Boolean showInitial;
/**
* If you specify both the showInput, showInitial, and allowEmpty options, the CSS keeps things in order by wrapping the buttons to the bottom row, and shrinking the input.
* Note: this is all
* customizable via CSS.
*/
private Boolean allowEmpty;
/**
* You can allow alpha transparency selection. Check out these examples:
*/
private Boolean showAlpha;
/**
* You can have the colorpicker automatically hide after a palette color is selected.
*/
private Boolean hideAfterPaletteSelect;
/**
* Spectrum can be automatically disabled if you pass in the disabled flag. Additionally, if the input that you initialize spectrum on is disabled, this will be the default
* value. Note: you cannot
* enable spectrum if the input is disabled (see below).
*/
private Boolean disabled;
private String localStorageKey;
/**
* Spectrum can show a palette below the colorpicker to make it convenient for users to choose from frequently or recently used colors. When the colorpicker is closed, the
* current color will be
* added to the palette if it isn't there already. Check it out here:
*/
private Boolean showPalette;
/**
* If you'd like, spectrum can show the palettes you specify, and nothing else.
*/
private Boolean showPaletteOnly;
/**
* Spectrum can show a button to toggle the colorpicker next to the palette. This way, the user can choose from a limited number of colors in the palette, but still be able to
* pick a color that's
* not in the palette. The default value for togglePaletteOnly is FALSE. Set it to TRUE to enable the Toggle button.
*
* You can also change the text on the Toggle Button with the options togglePaletteMoreText (default is "more") and togglePaletteLessText (default is "less").
*/
private Boolean togglePaletteOnly;
/**
* You can show or hide the buttons using the showButtons property. If there are no buttons, the behavior will be to fire the `change` event (and update the original input)
* when the picker is
* closed.
*/
private Boolean showButtons;
/**
*
* Spectrum can keep track of what has been selected by the user with the showSelectionPalette option.
*
* If the localStorageKey option is defined, the selection will be
*
*/
private Boolean showSelectionPalette;
/**
* When clicking outside of the colorpicker, you can force it to fire a change event rather than having it revert the change. This is true by default.
*/
private Boolean clickoutFiresChange;
/**
* You can set the button's text using cancelText and chooseText properties.
*/
private String cancelText;
/**
* You can set the button's text using cancelText and chooseText properties.
*/
private String chooseText;
/**
* You can also change the text on the Toggle Button with the options togglePaletteMoreText (default is "more") and togglePaletteLessText (default is "less").
*/
private String togglePaletteMoreText;
/**
* You can also change the text on the Toggle Button with the options togglePaletteMoreText (default is "more") and togglePaletteLessText (default is "less").
*/
private String togglePaletteLessText;
/**
* You can add an additional class name to the just the container element using the containerClassName property.
*/
private String containerClassName;
/**
* You can add an additional class name to just the replacer element using the replacerClassName property.
*/
private String replacerClassName;
/**
*
* You can set the format that is displayed in the text box.
*
* This will also change the format that is displayed in the titles from the palette swatches.
*
*/
private JQSpectrumaletteFormats preferredFormat;
/**
*
* This is how many elements are allowed in the selectionPallete at once.
*
* Elements will be removed from the palette in first in - first out order if this limit is reached.
*
*/
private Integer maxSelectionSize;
/**
*
*/
private JQSpectrumColourPalettes palette;
/**
*
* The default values inside of the selection palette. Make sure that showSelectionPalette and showPalette are both enabled.
*
* If a localStorageKey is defined, then this value will be overwritten by it.
*
*/
private JQSpectrumColourPalette selectionPalette;
/**
* The initial color will be set with the color option. If you don't pass in a color, Spectrum will use the value attribute on the input.
*
* The color parsing is based on the TinyColor plugin. This should parse any color string you throw at it.
*
*
* @return
*/
public String getColor()
{
return color;
}
/**
* The initial color will be set with the color option. If you don't pass in a color, Spectrum will use the value attribute on the input.
*
* The color parsing is based on the TinyColor plugin. This should parse any color string you throw at it.
*
*
* @param color
*/
public void setColor(ColourNames color)
{
this.color = color.getValue();
}
/**
* This means that it will always show up at full size, and be positioned as an inline-block element. Look to the left for a full sized flat picker.
*
*
* @return
*/
public Boolean getFlat()
{
return flat;
}
/**
* This means that it will always show up at full size, and be positioned as an inline-block element. Look to the left for a full sized flat picker.
*
*
* @param flat
*/
public void setFlat(Boolean flat)
{
this.flat = flat;
}
/**
* You can add an input to allow free form typing. The color parsing is very permissive in the allowed strings. See TinyColor for more details.
*
*
* @return
*/
public Boolean getShowInput()
{
return showInput;
}
/**
* You can add an input to allow free form typing. The color parsing is very permissive in the allowed strings. See TinyColor for more details.
*
*
* @param showInput
*/
public void setShowInput(Boolean showInput)
{
this.showInput = showInput;
}
/**
* Spectrum can show the color that was initially set when opening. This provides an easy way to click back to what was set when opened.
*
*
* @return
*/
public Boolean getShowInitial()
{
return showInitial;
}
/**
* Spectrum can show the color that was initially set when opening. This provides an easy way to click back to what was set when opened.
*
*
* @param showInitial
*/
public void setShowInitial(Boolean showInitial)
{
this.showInitial = showInitial;
}
/**
* If you specify both the showInput, showInitial, and allowEmpty options, the CSS keeps things in order by wrapping the buttons to the bottom row, and shrinking the input.
* Note: this is all
* customizable via CSS.
*
*
* @return
*/
public Boolean getAllowEmpty()
{
return allowEmpty;
}
/**
* If you specify both the showInput, showInitial, and allowEmpty options, the CSS keeps things in order by wrapping the buttons to the bottom row, and shrinking the input.
* Note: this is all
* customizable via CSS.
*
*
* @param allowEmpty
*/
public void setAllowEmpty(Boolean allowEmpty)
{
this.allowEmpty = allowEmpty;
}
/**
* You can allow alpha transparency selection. Check out these examples:
*
*
* @return
*/
public Boolean getShowAlpha()
{
return showAlpha;
}
/**
* You can allow alpha transparency selection. Check out these examples:
*
*
* @param showAlpha
*/
public void setShowAlpha(Boolean showAlpha)
{
this.showAlpha = showAlpha;
}
public String getLocalStorageKey()
{
return localStorageKey;
}
public void setLocalStorageKey(String localStorageKey)
{
this.localStorageKey = localStorageKey;
}
/**
* Spectrum can show a palette below the colorpicker to make it convenient for users to choose from frequently or recently used colors. When the colorpicker is closed, the
* current color will be
* added to the palette if it isn't there already. Check it out here:
*
*
* @return
*/
public Boolean getShowPalette()
{
return showPalette;
}
/**
* Spectrum can show a palette below the colorpicker to make it convenient for users to choose from frequently or recently used colors. When the colorpicker is closed, the
* current color will be
* added to the palette if it isn't there already. Check it out here:
*
*
* @param showPalette
*/
public void setShowPalette(Boolean showPalette)
{
this.showPalette = showPalette;
}
/**
* If you'd like, spectrum can show the palettes you specify, and nothing else.
*
*
* @return
*/
public Boolean getShowPaletteOnly()
{
return showPaletteOnly;
}
/**
* If you'd like, spectrum can show the palettes you specify, and nothing else.
*
*
* @param showPaletteOnly
*/
public void setShowPaletteOnly(Boolean showPaletteOnly)
{
this.showPaletteOnly = showPaletteOnly;
}
/**
* Spectrum can show a button to toggle the colorpicker next to the palette. This way, the user can choose from a limited number of colors in the palette, but still be able to
* pick a color that's
* not in the palette. The default value for togglePaletteOnly is FALSE. Set it to TRUE to enable the Toggle button.
*
* You can also change the text on the Toggle Button with the options togglePaletteMoreText (default is "more") and togglePaletteLessText (default is "less").
*
*
* @return
*/
public Boolean getTogglePaletteOnly()
{
return togglePaletteOnly;
}
/**
* Spectrum can show a button to toggle the colorpicker next to the palette. This way, the user can choose from a limited number of colors in the palette, but still be able to
* pick a color that's
* not in the palette. The default value for togglePaletteOnly is FALSE. Set it to TRUE to enable the Toggle button.
*
* You can also change the text on the Toggle Button with the options togglePaletteMoreText (default is "more") and togglePaletteLessText (default is "less").
*
*
* @param togglePaletteOnly
*/
public void setTogglePaletteOnly(Boolean togglePaletteOnly)
{
this.togglePaletteOnly = togglePaletteOnly;
}
/**
*
* Spectrum can keep track of what has been selected by the user with the showSelectionPalette option.
*
* If the localStorageKey option is defined, the selection will be
*
*
* @return
*/
public Boolean getShowSelectionPalette()
{
return showSelectionPalette;
}
/**
*
* Spectrum can keep track of what has been selected by the user with the showSelectionPalette option.
*
* If the localStorageKey option is defined, the selection will be
*
*
* @param showSelectionPalette
*/
public void setShowSelectionPalette(Boolean showSelectionPalette)
{
this.showSelectionPalette = showSelectionPalette;
}
/**
* When clicking outside of the colorpicker, you can force it to fire a change event rather than having it revert the change. This is true by default.
*
*
* @return
*/
public Boolean getClickoutFiresChange()
{
return clickoutFiresChange;
}
/**
* When clicking outside of the colorpicker, you can force it to fire a change event rather than having it revert the change. This is true by default.
*
*
* @param clickoutFiresChange
*/
public void setClickoutFiresChange(Boolean clickoutFiresChange)
{
this.clickoutFiresChange = clickoutFiresChange;
}
/**
* You can set the button's text using cancelText and chooseText properties.
*
*
* @return
*/
public String getCancelText()
{
return cancelText;
}
/**
* You can set the button's text using cancelText and chooseText properties.
*
*
* @param cancelText
*/
public void setCancelText(String cancelText)
{
this.cancelText = cancelText;
}
/**
* You can set the button's text using cancelText and chooseText properties.
*
*
* @return
*/
public String getChooseText()
{
return chooseText;
}
/**
* You can set the button's text using cancelText and chooseText properties.
*
*
* @param chooseText
*/
public void setChooseText(String chooseText)
{
this.chooseText = chooseText;
}
/**
* You can also change the text on the Toggle Button with the options togglePaletteMoreText (default is "more") and togglePaletteLessText (default is "less").
*
*
* @return
*/
public String getTogglePaletteMoreText()
{
return togglePaletteMoreText;
}
/**
* You can also change the text on the Toggle Button with the options togglePaletteMoreText (default is "more") and togglePaletteLessText (default is "less").
*
*
* @param togglePaletteMoreText
*/
public void setTogglePaletteMoreText(String togglePaletteMoreText)
{
this.togglePaletteMoreText = togglePaletteMoreText;
}
/**
* You can also change the text on the Toggle Button with the options togglePaletteMoreText (default is "more") and togglePaletteLessText (default is "less").
*
*
* @return
*/
public String getTogglePaletteLessText()
{
return togglePaletteLessText;
}
/**
* You can also change the text on the Toggle Button with the options togglePaletteMoreText (default is "more") and togglePaletteLessText (default is "less").
*
*
* @param togglePaletteLessText
*/
public void setTogglePaletteLessText(String togglePaletteLessText)
{
this.togglePaletteLessText = togglePaletteLessText;
}
/**
* You can add an additional class name to the just the container element using the containerClassName property.
*
*
* @return
*/
public String getContainerClassName()
{
return containerClassName;
}
/**
* You can add an additional class name to the just the container element using the containerClassName property.
*
*
* @param containerClassName
*/
public void setContainerClassName(String containerClassName)
{
this.containerClassName = containerClassName;
}
/**
* You can add an additional class name to just the replacer element using the replacerClassName property.
*
*
* @return
*/
public String getReplacerClassName()
{
return replacerClassName;
}
/**
* You can add an additional class name to just the replacer element using the replacerClassName property.
*
*
* @param replacerClassName
*/
public void setReplacerClassName(String replacerClassName)
{
this.replacerClassName = replacerClassName;
}
/**
*
* You can set the format that is displayed in the text box.
*
* This will also change the format that is displayed in the titles from the palette swatches.
*
*/
public JQSpectrumaletteFormats getPreferredFormat()
{
return preferredFormat;
}
/**
*
* You can set the format that is displayed in the text box.
*
* This will also change the format that is displayed in the titles from the palette swatches.
*
*/
public void setPreferredFormat(JQSpectrumaletteFormats preferredFormat)
{
this.preferredFormat = preferredFormat;
}
/**
*
* This is how many elements are allowed in the selectionPallete at once.
*
* Elements will be removed from the palette in first in - first out order if this limit is reached.
*
*
* @return
*/
public Integer getMaxSelectionSize()
{
return maxSelectionSize;
}
/**
*
* This is how many elements are allowed in the selectionPallete at once.
*
* Elements will be removed from the palette in first in - first out order if this limit is reached.
*
*
* @param maxSelectionSize
*/
public void setMaxSelectionSize(Integer maxSelectionSize)
{
this.maxSelectionSize = maxSelectionSize;
}
public JQSpectrumColourPalettes getPalette()
{
return palette;
}
public void setPalette(JQSpectrumColourPalettes palette)
{
this.palette = palette;
}
/**
*
* The default values inside of the selection palette. Make sure that showSelectionPalette and showPalette are both enabled.
*
* If a localStorageKey is defined, then this value will be overwritten by it.
*
*
* @return
*/
public JQSpectrumColourPalette getSelectionPalette()
{
return selectionPalette;
}
/**
*
* The default values inside of the selection palette. Make sure that showSelectionPalette and showPalette are both enabled.
*
* If a localStorageKey is defined, then this value will be overwritten by it.
*
*
* @param selectionPalette
*/
public void setSelectionPalette(JQSpectrumColourPalette selectionPalette)
{
this.selectionPalette = selectionPalette;
}
/**
* Spectrum can be automatically disabled if you pass in the disabled flag. Additionally, if the input that you initialize spectrum on is disabled, this will be the default
* value. Note: you cannot
* enable spectrum if the input is disabled (see below).
*
* @return
*/
public Boolean getDisabled()
{
return disabled;
}
/**
* Spectrum can be automatically disabled if you pass in the disabled flag. Additionally, if the input that you initialize spectrum on is disabled, this will be the default
* value. Note: you cannot
* enable spectrum if the input is disabled (see below).
*
* @param disabled
*/
public void setDisabled(Boolean disabled)
{
this.disabled = disabled;
}
/**
* You can have the colorpicker automatically hide after a palette color is selected.
*/
public Boolean getHideAfterPaletteSelect()
{
return hideAfterPaletteSelect;
}
/**
* You can have the colorpicker automatically hide after a palette color is selected.
*/
public void setHideAfterPaletteSelect(Boolean hideAfterPaletteSelect)
{
this.hideAfterPaletteSelect = hideAfterPaletteSelect;
}
/**
* You can show or hide the buttons using the showButtons property. If there are no buttons, the behavior will be to fire the `change` event (and update the original input)
* when the picker is
* closed.
*
*
* @return
*/
public Boolean getShowButtons()
{
return showButtons;
}
/**
* You can show or hide the buttons using the showButtons property. If there are no buttons, the behavior will be to fire the `change` event (and update the original input)
* when the picker is
* closed.
*
*
* @param showButtons
*/
public void setShowButtons(Boolean showButtons)
{
this.showButtons = showButtons;
}
@Override
public JavascriptPartType getJavascriptType()
{
return JavascriptPartType.Javascript;
}
}