Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

  1. #1
    Sencha User halogen's Avatar
    Join Date
    Jun 2012
    Posts
    11
    Vote Rating
    0
    halogen is on a distinguished road

      0  

    Default Answered: Text inside spinner

    Answered: Text inside spinner


    I want to put a unit after the number in a spinner that is sensitive to plurality. e.g. instead of "1", "2", and "3", I want it to display "1 person", "2 people", and "3 people".

    And no, putting a note in the label to remind the user what the units are is not satisfactory. The text has to be after the number and to the left of the minus and plus buttons. And it has to be changeable based on the value of the spinner.

  2. Actually you can extend the basic spinner and put text in it by overriding its component input type!
    This way you don't have to extend a textfield adding the whole spinner logic

    Here's a quick example

    Code:
    Ext.define('My.pplSpinner', {
        extend: 'Ext.field.Spinner',
        alias: 'widget.pplspinner',
    
        config: {
            component: {
                 //here's the <input type="..."> fix
                type: 'text'
            }
        },
        
        updateValue: function(newValue, oldValue) {
            if (newValue > 1)
                newValue = newValue + ' people';
            else
                newValue = newValue + ' person';
      
            this.callParent([newValue, oldValue]);
        },
        
        getValue: function() {
            // parseInt will do the dirty job of cutting off the attached string
            return parseInt(this.getComponent().getValue());
        }
    });

  3. #2
    Sencha User jerome76's Avatar
    Join Date
    Apr 2012
    Location
    New Jersey
    Posts
    1,149
    Answers
    132
    Vote Rating
    99
    jerome76 is just really nice jerome76 is just really nice jerome76 is just really nice jerome76 is just really nice jerome76 is just really nice

      0  

    Default


    Try inspecting the elements of where the "1", "2", and "3", show up and see if you can replace them with the "1 person", "2 people", and "3 people" that you want.

    If that doesn't work out I also suggest you look at the source code for Ext.Spinner and see how they build the "1", "2", and "3". Then create some sort of override for it.

    Good luck! Time for the weekend for me

  4. #3
    Sencha User halogen's Avatar
    Join Date
    Jun 2012
    Posts
    11
    Vote Rating
    0
    halogen is on a distinguished road

      0  

    Default


    I looked through the source code of Spinner.js and found that it is a child of the Number class, which means I'll have to define a new "SpinnerWithUnits" class that extends the Text class in order to allow non-numerical characters to show up in the HTML element.

    Maybe someone has already written such a class. I'll keep looking.

  5. #4
    Sencha User net02's Avatar
    Join Date
    Feb 2012
    Location
    Pavia, Italy
    Posts
    6
    Answers
    1
    Vote Rating
    3
    net02 is on a distinguished road

      2  

    Default


    Actually you can extend the basic spinner and put text in it by overriding its component input type!
    This way you don't have to extend a textfield adding the whole spinner logic

    Here's a quick example

    Code:
    Ext.define('My.pplSpinner', {
        extend: 'Ext.field.Spinner',
        alias: 'widget.pplspinner',
    
        config: {
            component: {
                 //here's the <input type="..."> fix
                type: 'text'
            }
        },
        
        updateValue: function(newValue, oldValue) {
            if (newValue > 1)
                newValue = newValue + ' people';
            else
                newValue = newValue + ' person';
      
            this.callParent([newValue, oldValue]);
        },
        
        getValue: function() {
            // parseInt will do the dirty job of cutting off the attached string
            return parseInt(this.getComponent().getValue());
        }
    });

Thread Participants: 2

Tags for this Thread