Ignore:
Timestamp:
2013/01/08 17:52:03 (11 years ago)
Author:
yomoro
Message:

#1987 (国際化テンプレート:年月日のセレクトボックス廃止)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_12-multilang/data/Smarty/templates/admin/contents/index.tpl

    r22134 r22212  
    105105} 
    106106 
     107    $(function(){ 
     108        $.datepicker.setDefaults( $.datepicker.regional[ "<!--{$smarty.const.LANG_CODE}-->" ] ); 
     109         
     110        $( "#datepicker" ).datepicker({ 
     111        beforeShowDay: function(date) { 
     112            if(date.getDay() == 0) { 
     113                return [true,"date-sunday"];  
     114            } else if(date.getDay() == 6){ 
     115                return [true,"date-saturday"]; 
     116            } else { 
     117                return [true]; 
     118            } 
     119        },changeMonth: 'true' 
     120        ,changeYear: 'true' 
     121        ,onSelect: function(dateText, inst){ 
     122            setDate(dateText); 
     123        }, 
     124        showButtonPanel: true, 
     125        beforeShow: showAdditionalButton,        
     126        onChangeMonthYear: showAdditionalButton 
     127        }); 
     128         
     129        $("#datepicker").blur( function() { 
     130            var dateText = $(this).val(); 
     131            setDate(dateText); 
     132        }); 
     133         
     134    }); 
     135     
     136    var btn = $('<button class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" type="button">Clear</button>'); 
     137     
     138    var showAdditionalButton = function (input) { 
     139        setTimeout(function () { 
     140            var buttonPane = $(input) 
     141                     .datepicker("widget") 
     142                     .find(".ui-datepicker-buttonpane"); 
     143            btn 
     144                    .unbind("click") 
     145                    .bind("click", function () { 
     146                        $.datepicker._clearDate(input); 
     147                        $("*[name=year]").val(""); 
     148                        $("*[name=month]").val(""); 
     149                        $("*[name=day]").val(""); 
     150                    }); 
     151            btn.appendTo(buttonPane); 
     152        }, 1); 
     153    }; 
     154     
     155    function setDate(dateText){ 
     156    var dates = dateText.split('/'); 
     157    $("*[name=year]").val(dates[0]); 
     158    $("*[name=month]").val(dates[1]); 
     159    $("*[name=day]").val(dates[2]); 
     160    } 
     161 
    107162//--> 
    108163</script> 
     
    121176            <td> 
    122177                <!--{if $arrErr.year || $arrErr.month || $arrErr.day}--><span class="attention"><!--{$arrErr.year}--><!--{$arrErr.month}--><!--{$arrErr.day}--></span><!--{/if}--> 
    123                 <select name="year" <!--{if $arrErr.year || $arrErr.month || $arrErr.day }-->style="background-color:<!--{$smarty.const.ERR_COLOR|h}-->"<!--{/if}-->> 
    124                     <option value="" selected="selected">----</option> 
    125                     <!--{html_options options=$arrYear selected=$arrForm.year}--> 
    126                 </select>年 
    127                 <select name="month" <!--{if $arrErr.year || $arrErr.month || $arrErr.day}-->style="background-color:<!--{$smarty.const.ERR_COLOR|h}-->"<!--{/if}-->> 
    128                     <option value="" selected="selected">--</option> 
    129                     <!--{html_options options=$arrMonth selected=$arrForm.month}--> 
    130                 </select>月 
    131                 <select name="day" <!--{if $arrErr.year || $arrErr.month || $arrErr.day}-->style="background-color:<!--{$smarty.const.ERR_COLOR|h}-->"<!--{/if}-->> 
    132                     <option value="" selected="selected">--</option> 
    133                     <!--{html_options options=$arrDay selected=$arrForm.day}--> 
    134                 </select>日 
     178                <input id="datepicker" type="text" value="<!--{if $arrForm.year != "" && $arrForm.month != "" && $arrForm.day != ""}--><!--{$arrForm.year|h}-->/<!--{$arrForm.month|h|string_format:'%02d'}-->/<!--{$arrForm.day|h|string_format:'%02d'}--><!--{/if}-->" <!--{if $arrErr.year != ""}--><!--{sfSetErrorStyle}--><!--{/if}--> /> 
     179                <input type="hidden" name="year" value="<!--{$arrForm.year}-->" /> 
     180                <input type="hidden" name="month" value="<!--{$arrForm.month}-->" /> 
     181                <input type="hidden" name="day" value="<!--{$arrForm.day}-->" /> 
    135182            </td> 
    136183        </tr> 
Note: See TracChangeset for help on using the changeset viewer.