package org.gwtbootstrap3.extras.slider.client.ui.base;

/*
 * #%L
 * GwtBootstrap3
 * %%
 * Copyright (C) 2013 - 2015 GwtBootstrap3
 * %%
 * 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.
 * #L%
 */

/**
 * Boostrap slider options enumeration type.<br>
 * <br>
 * Options can be passed either as a data (<code>data-slider-foo</code>)
 * attribute, or as part of an object in the slider call. The only exception
 * here is the <strong>formatter</strong> option, that can not be passed as a
 * data attribute.
 *
 * @author Xiaodong SUN
 * @see https://github.com/seiyria/bootstrap-slider#options
 */
enum SliderOption {

    ID("id"),
    MIN("min"),
    MAX("max"),
    STEP("step"),
    PRECISION("precision"),
    ORIENTATION("orientation"),
    VALUE("value"),
    RANGE("range"),
    SELECTION("selection"),
    TOOLTIP("tooltip"),
    TOOLTIP_SPLIT("tooltip_split"),
    HANDLE("handle"),
    REVERSED("reversed"),
    ENABLED("enabled"),
    FORMATTER("formatter"),
    NATURAL_ARROW_KEYS("natural_arrow_keys"),
    TICKS("ticks"),
    TICKS_LABELS("ticks_labels"),
    TICKS_SNAP_BOUNDS("ticks_snap_bounds"),
    SCALE("scale"),
    ;

    private final String name;
    private final static String DATA_ATTRIBUTE_PREFIX = "data-slider-";

    /**
     * @param name the option name
     */
    private SliderOption(final String name) {
        this.name = name;
    }

    /**
     * Returns the option name.
     *
     * @return the option name.
     */
    public String getName() {
        return name;
    }

    /**
     * Returns the data attribute name prefixed by
     * {@value #DATA_ATTRIBUTE_PREFIX}.
     *
     * @return the data attribute name
     */
    public String getDataAttribute() {
        return DATA_ATTRIBUTE_PREFIX + name;
    }
}

@@ -1672,24 +1672,63 @@
 tring name;%0A
+    private final String dataAttrName;%0A
     private 
@@ -1907,24 +1907,79 @@
 ame = name;%0A
+        this.dataAttrName = name.replaceAll(%22_%22, %22-%22);%0A
     %7D%0A%0A    /
@@ -2349,17 +2349,25 @@
 REFIX + 
-n
+dataAttrN
 ame;%0A   

fix #185 The data atttribute name always uses "-" form rather than "_" form.