text-element-controllet.html 5.55 KB
<!--
@license
    The MIT License (MIT)

    Copyright (c) 2015 Dipartimento di Informatica - Università di Salerno - Italy

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.
-->

<link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="../../bower_components/paper-styles/color.html">

<!--
`text-element-controllet` is a text area with heading. It fires an event when the text value is modified. This event can be useful when you have to monitor many af this elements.


Example:

    <text-element-controllet heading="myField"
                             description="myFieldDescription"
                             number="1">
    </text-element-controllet>


@element text-element-controllet
@status beta
@homepage
@group controllets
-->


<dom-module id="text-element-controllet">
    <template>

        <style is="custom-style">

            .avatar {
                display: inline-block;
                position: relative;
                float: left;
                height: 1.7em;
                width: 1.7em;
                border-radius: 50%;
                background: var(--paper-blue-500);
                color: white;
                line-height: 2em;
                font-size: 0.74em;
                text-align: center;
            }

            .heading{
                /*width: 12.5em;*/
            }

            .big {
                display: inline-block;
                position: relative;
                float: left;
                font-size: 1em;
                padding: 0.5em 0.25em 0.5em;
                color: var(--google-grey-500);
            }

            .medium {
                position: relative;
                float: left;
                font-size: 0.8125em;
                padding-bottom: 0px;
                display: inline-block;
                width: 32.5em;
                padding-left: 10px;
            }


        </style>

        <div>
            <div>
                <div class="heading">
                    <div class="avatar">{{number}}</div>
                    <div class="medium">{{description}}</div>
                </div>
            </div><br>
            <paper-textarea id="text" label="{{heading}}" floatingLabel value="{{value}}"></paper-textarea>
        </div>

    </template>

    <script>

        Polymer({

            is: 'text-element-controllet',

            /**
             * Fired when the user change the text value
             *
             * @event text-element-controllet_content-changed
             */

            targets : null,

            properties: {
                /**
                 * It's the name of the elelent
                 *
                 * @attribute heading
                 * @type Strig
                 * @default 'Heading'
                 */
                heading : {
                    type : String,
                    value : "Heading"
                },
                /**
                 * It's the description of the elelent
                 *
                 * @attribute description
                 * @type Strig
                 * @default 'Description'
                 */
                description: {
                    type: String,
                    value: "Description"
                },
                /**
                 * It's a string value the represent the current number of elelent. It will be use in the label section.
                 *
                 * @attribute number
                 * @type Strig
                 * @default '0'
                 */
                number: {
                    type: String,
                    value : "0"
                },
                value :{
                    type: String,
                    value: "",
                    observer : '_valueChanged'
                }
            },
            /**
             * Callback related to text change
             *
             * @method _valueChanged
             *
             * @param {Event} e
             */
            _valueChanged : function(oldvalue, newValue){
                this.fire('text-element-controllet_content-changed', {newValue: newValue});
            },
            /**
             * It returns the value in text area
             *
             * @method getValue
             */
            getValue : function(){
                return this.$.text.value;
            }
        });

    </script>

</dom-module>