/*
 * Copyright 2004-2014 ICEsoft Technologies Canada Corp.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the
 * License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an "AS
 * IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */

package org.icefaces.ace.component.richtextentry;

import org.icefaces.ace.meta.annotation.Component;
import org.icefaces.ace.meta.annotation.Property;
import org.icefaces.ace.meta.baseMeta.UIInputMeta;

import org.icefaces.ace.resources.ACEResourceNames;
import org.icefaces.resources.ICEResourceDependencies;
import org.icefaces.resources.ICEResourceDependency;

import org.icefaces.ace.meta.annotation.ClientBehaviorHolder;
import org.icefaces.ace.meta.annotation.ClientEvent;
import org.icefaces.ace.api.IceClientBehaviorHolder;
import org.icefaces.resources.ICEResourceLibrary;

@Component(
        tagName = "richTextEntry",
        componentClass = "org.icefaces.ace.component.richtextentry.RichTextEntry",
        generatedClass = "org.icefaces.ace.component.richtextentry.RichTextEntryBase",
        extendsClass = "javax.faces.component.UIInput",
        componentFamily = "org.icefaces.ace.component.Menu",
        componentType = "org.icefaces.ace.component.RichTextEntry",
        rendererClass = "org.icefaces.ace.component.richtextentry.RichTextEntryRenderer",
        rendererType = "org.icefaces.ace.component.RichTextEntryRenderer",
        tlddoc = "RichTextEntry uses the CKEditor API to provide JSF based rich text editor component." +
                 "<p>For more information, see the " +
                 "<a href=\"http://wiki.icefaces.org/display/ICE/RichTextEntry\">RichTextEntry Wiki Documentation</a>."
)
@ICEResourceLibrary(ACEResourceNames.ACE_LIBRARY)
@ICEResourceDependencies({
	@ICEResourceDependency(name = ACEResourceNames.JQUERY_JS),
    @ICEResourceDependency(name = "richtextentry/ckeditor.mapping.js")
})
@ClientBehaviorHolder(events = {
	@ClientEvent( name="save",
		javadoc="Fired when the 'Save' button is clicked and the contents of the editor are saved.",
		tlddoc="Fired when the 'Save' button is clicked and the contents of the editor are saved.",
		defaultRender="@all", defaultExecute="@this" ),
	@ClientEvent( name="blur",
		javadoc="Fired any time the editor loses focus.",
		tlddoc="Fired any time the editor loses focus.",
		defaultRender="@all", defaultExecute="@this" )},
	defaultEvent="save" )
public class RichTextEntryMeta extends UIInputMeta {

    @Property(tlddoc = "Specifies the language to be used for the user interface.", defaultValue="en")
    private String language;
	
    @Property(tlddoc = "Inline CSS styling for the editor.")
    private String style;
	
    @Property(tlddoc = "The CSS style class of the editor.")
    private String styleClass;
	
    @Property(tlddoc = "The width of the entire editor. It can be expressed in px, em, and % units. If no unit is specified, the value is assumed to be in pixels.", defaultValue="100%")
    private String width;
	
    @Property(tlddoc = "The height of the editable area only. It can be expressed in px and em units (percent units (%) are not supported). If no unit is specified, the value is assumed to be in pixels.", defaultValue="200px")
    private String height;
	
    @Property(tlddoc = "Specifies the type of toolbar. There are two valid values for this field (case sensitive): 'Default' and 'Basic'.", defaultValue="Default")
    private String toolbar;

    @Property(tlddoc = "This attribute defines the path of the custom config file, the path is relative to the web app.")
    private String customConfigPath;

    @Property(tlddoc = "Specify the pre-defined skin for the editor. Possible values are 'moono', 'moonocolor', 'moonodark', 'moonoblue', 'moonolisa', 'office2013', 'kama', and 'bootstrap' for all browsers, except for IE7 (which uses a previous editor version). Possible values for IE7 are 'v2', 'office2003', and 'kama' ('default' is synonymous of 'moono' for all browsers except for IE7 and 'v2' for IE7).", defaultValue="default")
    private String skin;
	
    @Property(tlddoc = "Boolean value to disable the editor functions.", defaultValue="false")
    private boolean disabled;
	
    @Property(tlddoc = "By default the data of the editor will only be saved when its 'Save' button is clicked. Any other submit request will not save its data. In order to save its data on any submit request like inputText does, this attribute can be set to true.", defaultValue="false")
    private boolean saveOnSubmit;
    
    @Property(tlddoc = "Enabling this behaviour will automatically expand and shrink vertically the editor, depending on the amount and size of the content. Customize the maximum and minimum heights, as well as the buffer space, via the attributes 'autogrowMinHeight', 'autogrowMaxHeight', and 'autogrowBufferSpace'.", defaultValue="false")
    private boolean autogrow;
    
    @Property(tlddoc = "When the autogrow behaviour is enabled, the editing area will be no shorter than the amount specified by this attribute, in pixels. This and the 'autogrowMaxHeight' attributes override the regular 'height' attribute.", defaultValue="300")
    private int autogrowMinHeight;
    
    @Property(tlddoc = "When the autogrow behaviour is enabled, the editing area will be no taller than the amount specified by this attribute, in pixels. A value of 0 indicates that there is no set limit. This and the 'autogrowMinHeight' attributes override the regular 'height' attribute.", defaultValue="0")
    private int autogrowMaxHeight;
    
    @Property(tlddoc = "When the autogrow behaviour is enabled, this is the vertical space between the last line of content in the editing area and the editor's footer, in pixels (when the editing area is taller than the minimum height).", defaultValue="50")
    private int autogrowBufferSpace;
}
