HomeHelpTrac

Changeset 15848 for trunk


Ignore:
Timestamp:
01/07/12 23:00:41 (5 months ago)
Author:
Alexander Trofimov
Message:

Form - clear input button

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/inc/js/jquery.webForms.js

    r15845 r15848  
    1111 
    1212        $(this).addNonWebForms(); 
    13          
     13 
    1414        // switchers 
    1515        $('.bx-switcher-cont', this).each(function() { 
     
    3434 
    3535            eInput.on('enable', function () { 
    36                 if ('checked' != $(this).attr('checked')) { 
    37                     console.log('onEnable'); 
     36                if ('checked' != $(this).attr('checked')) 
    3837                    $(this).attr('checked', 'checked').trigger('change'); 
    39                 } 
    4038                if (!eSwitcher.hasClass('on')) 
    4139                    eSwitcher.removeClass('off').addClass('on'); 
     
    4341 
    4442            eInput.on('disable', function () { 
    45                 if (undefined != $(this).attr('checked')) { 
    46                     console.log('onDisable'); 
     43                if (undefined != $(this).attr('checked')) 
    4744                    $(this).removeAttr('checked').trigger('change'); 
    48                 } 
    4945                if (!eSwitcher.hasClass('off')) 
    5046                    eSwitcher.removeClass('on').addClass('off'); 
     
    253249            } 
    254250 
     251            // add clear input button 
     252            var eInput = $(this); 
     253            var aClearInputClassSelectors = ['.bx-form-input-wrapper-datetime', '.bx-form-input-wrapper-datepicker', '.bx-form-input-wrapper-text', '.bx-form-input-wrapper-password']; 
     254            for (var i in aClearInputClassSelectors) { 
     255                var sClassSelector = aClearInputClassSelectors[i]; 
     256 
     257                var eWrapper = $(this).parents().filter(sClassSelector); 
     258                if (!eWrapper.length) 
     259                    continue; 
     260                if (eWrapper.hasClass('bx-form-input-btn-cross-processed')) 
     261                    return; 
     262                eWrapper.addClass('bx-form-input-btn-cross-processed'); 
     263 
     264                if ('relative' != eWrapper.css('position') && 'absolute' != eWrapper.css('position')) 
     265                    eWrapper.css('position', 'relative'); 
     266                eWrapper.append('<a href="javascript:void(0);"><div class="bx-form-input-btn-cross"></div></a>'); 
     267                eInput.css('padding-right', parseInt(eInput.css('padding-right')) + 10 + 'px'); 
     268                var eBtnCross = eWrapper.find('.bx-form-input-btn-cross');                 
     269                var iLeft = eInput.outerWidth() - eBtnCross.outerWidth() - 8; 
     270                eBtnCross.css('left', iLeft + 'px').on('click', function () { 
     271                    eInput.val(''); 
     272                    if (!eInput.hasClass('bx-form-input-datetime') && !eInput.hasClass('bx-form-input-datepicker')) 
     273                        eInput.focus(); 
     274                }); 
     275            } 
     276 
    255277        }); 
    256278        return this; 
  • trunk/templates/base/css/forms.css

    r15844 r15848  
    187187 
    188188.bx-form-input-datepicker { 
    189     width:110px; 
     189    width:120px; 
    190190} 
    191191 
    192192.bx-form-input-datetime { 
    193     width:190px; 
     193    width:180px; 
    194194} 
    195195 
     
    354354} 
    355355 
     356.bx-form-input-btn-cross { 
     357    position:absolute; 
     358    top:11px; 
     359    left:10px; 
     360    width:16px; 
     361    height:16px; 
     362     
     363    background-image:url(../images/icons/cross-script.png); 
     364} 
     365 
    356366/* extra features */ 
    357367 
Note: See TracChangeset for help on using the changeset viewer.