Bug Tracker

Changeset 4500

Show
Ignore:
Timestamp:
01/21/08 12:22:09 (1 year ago)
Author:
kbwood.au
Message:

Refactor datepicker functions
Demonstrate removeDatepicker, showAnim

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/ui/current/datepicker/index.html

    r4493 r4500  
    4646                    <li><a href="#l10n">Localisation</a></li> 
    4747                    <li style="clear: left;"><a href="#range">Date range</a></li> 
    48                     <li><a href="#misc">Miscellaneous</a></li> 
     48                    <li><a href="#misc1">Misc. 1</a></li> 
     49                    <li><a href="#misc2">Misc. 2</a></li> 
    4950                    <li><a href="#change">Change Settings</a></li> 
    5051                    <li><a href="#inline">Inline</a></li> 
     
    137138<script type="text/jsdemo" charset="utf-8" class="demojs"> 
    138139$('#button1').click(function() {  
    139     $.datepicker.showFor('#invokeFocus'); 
     140    $('#invokeFocus').showDatepicker(); 
    140141});  
    141142</script>    
     
    198199                        <input type="text" size="10" id="relativeDates"/></p> 
    199200<script type="text/jsdemo" charset="utf-8" class="demojs"> 
    200 $('#relativeDates').datepicker({minDate: 0, maxDate: 365}); 
     201$('#relativeDates').attachDatepicker({minDate: 0, maxDate: 365}); 
    201202</script> 
    202203                    <p>The relative dates can also be specified as a number and a period - 
     
    205206                        <input type="text" size="10" id="extendedDates"/></p> 
    206207<script type="text/jsdemo" charset="utf-8" class="demojs"> 
    207 $('#extendedDates').datepicker({minDate: '-1d', maxDate: '6y'}); 
     208$('#extendedDates').attachDatepicker({minDate: '-1d', maxDate: '6y'}); 
    208209</script> 
    209210                    <p>Note that the range of selectable months and years changes appropriately. Also, 
     
    337338                    <p><span class="demoLabel"> 
    338339                        <select class="languageSelect"> 
    339                             <option value="he">&#1506;&#1489;&#1512;&#1497;&#1514; (Hebrew)</option> 
     340                            <option value="he" selected="selected">&#1506;&#1489;&#1512;&#1497;&#1514; (Hebrew)</option> 
    340341                        </select>:</span> 
    341342                        <input type="text" size="10" id="rtlDatepicker"/></p> 
     
    367368// Customize two date pickers to work as a date range 
    368369function customRange(input) { 
    369     return {minDate: (input.id == 'dTo' ? $.datepicker.getDateFor('#dFrom') : null), 
    370         maxDate: (input.id == 'dFrom' ? $.datepicker.getDateFor('#dTo') : null)}; 
     370    return {minDate: (input.id == 'dTo' ? $('#dFrom').getDatepickerDate() : null), 
     371        maxDate: (input.id == 'dFrom' ? $('#dTo').getDatepickerDate() : null)}; 
    371372} 
    372373</script> 
     
    392393</script> 
    393394                </div> 
    394                 <div id="misc" class="tab_group1 container"> 
    395                     <h3>Miscellaneous</h3> 
     395                <div id="misc1" class="tab_group1 container"> 
     396                    <h3>Miscellaneous 1</h3> 
    396397                    <p>Set the date shown when first opening the date picker. The default is today.</p> 
    397398                    <p><span class="demoLabel">Open at 01-Jan-2007:</span> 
     
    410411                        <input type="text" size="10" id="openDate2Weeks"/></p> 
    411412<script type="text/jsdemo" charset="utf-8" class="demojs"> 
    412 $('#openDate2Weeks').datepicker({defaultDate: '2w'}); 
     413$('#openDate2Weeks').attachDatepicker({defaultDate: '2w'}); 
    413414</script> 
    414415                    <p>Show the weeks of the year. Defaults to the ISO 8601 definition (weeks start  
     
    452453        (today.getTime() == date.getTime() ? ' (today)' : ''); 
    453454} 
     455</script> 
     456                </div> 
     457                <div id="misc2" class="tab_group1 container"> 
     458                    <h3>Miscellaneous 2</h3> 
     459                    <p>Remove the datepicker if you've finished with it.</p> 
     460                    <p><span class="demoLabel">Remove popup datepicker:</span> 
     461                        <input type="text" size="10" class="removeDatepicker"/><button id="removeButton">Remove</button></p> 
     462                    <p><span class="demoLabel">Remove inline datepicker:</span> 
     463                        <span class="removeDatepicker"></span></p> 
     464<script type="text/jsdemo" charset="utf-8" class="demojs"> 
     465var opts = {beforeShowDay: $.datepicker.noWeekends}; 
     466$('.removeDatepicker').attachDatepicker(opts); 
     467$('#removeButton').toggle(function() { 
     468        $(this).text('Re-attach'); 
     469        $('.removeDatepicker').removeDatepicker(); 
     470    }, 
     471    function() { 
     472        $(this).text('Remove'); 
     473        $('.removeDatepicker').attachDatepicker(opts); 
     474    } 
     475); 
    454476</script> 
    455477                    <p><strong>(Advanced Technique)</strong><br />Connect the date picker to linked drop-downs. You still need an input field, 
     
    525547                <div id="change" class="tab_group1 container"> 
    526548                    <h3>Changing Settings</h3> 
    527                     <p>If necessary, the datepicker settings for an input (or set of inputs) can be changed 
    528                         on the fly. As an example, here we change the speed at which the datepicker appears.</p> 
    529                     <p><span class="demoLabel">Display speed:</span> 
    530                         <select id="speedSelectr"> 
     549                    <p>If necessary, the datepicker settings for an input (or set of inputs)  
     550                        can be changed on the fly. As an example, here we change the  
     551                        animation and speed at which the datepicker appears.</p> 
     552                    <p><span class="demoLabel">Display animation and speed:</span> 
     553                        <select id="animSelector"> 
     554                            <option value="show">show</option> 
     555                            <option value="fadeIn">fade in</option> 
     556                            <option value="slideDown">slide down</option> 
     557                        </select> 
     558                        <select id="speedSelector"> 
    531559                            <option value="">immediate</option> 
    532560                            <option value="slow">slow</option> 
     
    541569$('#changeDP').attachDatepicker(); 
    542570// Change the datepicker to selected speed. 
    543 $("#speedSelectr").change(function() { 
    544     $('#changeDP').changeDatepicker({speed: $(this).val()}); 
     571$("#animSelector,#speedSelector").change(function() { 
     572    $('#changeDP').changeDatepicker({'showAnim': $('#animSelector').val(), 
     573        'speed': $('#speedSelector').val()}); 
    545574}); 
    546575</script> 
     
    602631// Display the date range from a multi-month inline date picker 
    603632function updateInlineRange(dateStr) { 
    604     var dates = $.datepicker.getDateFor('#rangeInline'); 
     633    var dates = $('#rangeInline').getDatepickerDate(); 
    605634    var dateFormat = $.datepicker.regional[''].dateFormat; 
    606635    $('#inlineRange').val(dateStr ? dateStr : 
     
    624653$("#setInlineRange").click(function() { 
    625654    // Set Inline Date Range Selection 
    626     $.datepicker.setDateFor('#rangeInline', lastWeek, nextWeek); 
     655    $('#rangeInline').setDatepickerDate(lastWeek, nextWeek); 
    627656     
    628657    // Update text field with current date selections 
    629     var dates = $.datepicker.getDateFor('#rangeInline'); 
     658    var dates = $('#rangeInline').getDatepickerDate(); 
    630659    var dateFormat = $.datepicker.regional[''].dateFormat; 
    631660    $('#inlineRange').val($.datepicker.formatDate(dateFormat, dates[0]) + ' to ' + 
     
    688717                <div id="compat" class="tab_group1 container"> 
    689718                    <h3>Compatibility</h3> 
     719                    <h4>v2.x to v3.3</h4> 
    690720                    <p>The date picker has been refactored to better fit 
    691721                        within the <a href="http://ui.jquery.com">jQuery UI</a> project. 
     
    700730&lt;script type="text/javascript" src="<b>ui.datepicker.js</b>"&gt;&lt;/script&gt; 
    701731&lt;script type="text/javascript" src="<b>jquery-calendar-compatibility.js</b>"&gt;&lt;/script&gt;</code></pre> 
    702                     <p>Download the <a href="compatibility/jquery-calendar-compatibility.js" target="_blank">jquery-calendar-compatibility.js</a></p> 
     732                    <p>Download the <a href="compatibility/jquery-calendar-compatibility.js" target="_blank">jquery-calendar-compatibility.js</a> module.</p> 
    703733                    <p>To migrate fully, the following steps need to be taken:</p> 
    704734                    <ul> 
    705                         <li>Replace references to the <code>datepicker</code> 
    706                             with <code>attachDatepicker</code>.</li> 
    707                         <li>Replace references to the <code>$.datpicker.reconfigureFor</code> 
    708                             with <code>changeDatepicker</code>.</li> 
    709                         <li>Replace references to the <code>$.datpicker.enableFor</code> 
    710                             with <code>enableDatepicker</code>.</li> 
    711                         <li>Replace references to the <code>$.datpicker.disableFor</code> 
    712                             with <code>disableDatepicker</code>.</li> 
    713735                        <li>Replace references to the <code>jquery-calendar*</code> 
    714736                            files with <code>ui.datepicker*</code>.</li> 
     
    716738                            object with <code>$.datepicker</code>.</li> 
    717739                        <li>Replace references to the <code>calendar</code> 
    718                             function with <code>datepicker</code>.</li> 
     740                            function with <code>attachDatepicker</code>.</li> 
    719741                        <li>Replace references to the <code>autoPopUp</code> 
    720742                            setting with <code>showOn</code>.</li> 
     
    729751                        <li>Replace references to the <code>dialogCalendar</code> 
    730752                            function with <code>dialogDatepicker</code>.</li> 
     753                        <li>Replace references to the <code>$.datepicker.reconfigureFor(selector, ...)</code> 
     754                            function with <code>$(selector).changeDatepicker(...)</code>.</li> 
     755                        <li>Replace references to the <code>$.datepicker.enableFor(selector)</code> 
     756                            function with <code>$(selector).enableDatepicker()</code>.</li> 
     757                        <li>Replace references to the <code>$.datepicker.disableFor(selector)</code> 
     758                            function with <code>$(selector).disableDatepicker()</code>.</li> 
     759                        <li>Replace references to the <code>$.datepicker.getDateFor(selector)</code> 
     760                            function with <code>$(selector).getDatepickerDate()</code>.</li> 
     761                        <li>Replace references to the <code>$.datepicker.setDateFor(selector, ...)</code> 
     762                            function with <code>$(selector).setDatepickerDate(...)</code>.</li> 
    731763                        <li>Replace references to the <code>calendar*</code> 
    732764                            CSS styles with <code>datepicker*</code>.</li> 
     
    742774     
    743775&lt;input type="text" id="inlineConfig" <b>date:</b>defaultDate="+7"/&gt;</code></pre> 
     776                    <h4>v3.2 to v3.3</h4> 
     777                    <p>To align the datepicker more closely with other jQuery UI components, 
     778                    further changes were made in v3.3, resulting in another compatibility module.</p> 
     779                    <p>Users of v3.2 of the datepicker should use the following 
     780                        header code to work with their existing implementation:</p> 
     781<pre><code class="html">&lt;link rel="stylesheet" type="text/css" href="<b>ui.datepicker.css</b>"/&gt; 
     782&lt;script type="text/javascript" src="<b>ui.datepicker.js</b>"&gt;&lt;/script&gt; 
     783&lt;script type="text/javascript" src="<b>ui.datepicker.compatibility-3.2.js</b>"&gt;&lt;/script&gt;</code></pre> 
     784                    <p>Download the <a href="compatibility/ui.datepicker.compatibility-3.2.js" target="_blank">ui.datepicker.compatibility-3.2.js</a> module.</p> 
     785                    <p>To migrate fully, the following steps need to be taken:</p> 
     786                    <ul> 
     787                        <li>Replace references to the <code>datepicker</code> 
     788                            function with <code>attachDatepicker</code>.</li> 
     789                        <li>Replace references to the <code>$.datepicker.reconfigureFor(selector, ...)</code> 
     790                            function with <code>$(selector).changeDatepicker(...)</code>.</li> 
     791                        <li>Replace references to the <code>$.datepicker.enableFor(selector)</code> 
     792                            function with <code>$(selector).enableDatepicker()</code>.</li> 
     793                        <li>Replace references to the <code>$.datepicker.disableFor(selector)</code> 
     794                            function with <code>$(selector).disableDatepicker()</code>.</li> 
     795                        <li>Replace references to the <code>$.datepicker.getDateFor(selector)</code> 
     796                            function with <code>$(selector).getDatepickerDate()</code>.</li> 
     797                        <li>Replace references to the <code>$.datepicker.setDateFor(selector, ...)</code> 
     798                            function with <code>$(selector).setDatepickerDate(...)</code>.</li> 
     799                    </ul> 
     800                    <p>For example, this old style code:</p> 
     801<pre><code class="javascript">$('inputs').<b>datepicker</b>(); 
     802$.<b>datepicker.reconfigureFor</b>('inputs', {...});</code></pre> 
     803                    <p>becomes:</p> 
     804<pre><code class="javascript">$('inputs').<b>attachDatepicker</b>(); 
     805$('input').<b>changeDatepicker</b>({...});</code></pre> 
    744806                </div> 
    745807<!--DEMO