WordPress.org

Make WordPress Core

Changeset 5808


Ignore:
Timestamp:
07/17/2007 07:26:03 PM (14 years ago)
Author:
ryan
Message:

Revert jcalendar date picker experiment. Save it for another day. fixes #4641

Location:
trunk
Files:
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/template.php

    r5804 r5808  
    417417}
    418418
    419 // return an option/select list with correct html escaping
    420 function input_dropdown($name, $vals, $selected=null, $class='', $onchange='') {
    421 
    422     // cf. http://www.w3.org/TR/html401/appendix/notes.html#h-B.3.2.2
    423     $out = '<select name="' . htmlspecialchars($name) . '" class="' . htmlspecialchars($class) . '" onchange="' . htmlspecialchars($onchange) . '">' . "\n";
    424     foreach ($vals as $k=>$v) {
    425         $out .= '<option value="' . htmlspecialchars($k) . '"';
    426         if ( $selected !== null and $k == $selected )
    427             $out .= ' selected="selected"';
    428         $out .= '>' . htmlspecialchars($v) . "</option>\n";
    429     }
    430     $out .= "</select>\n";
    431 
    432     return $out;
    433 }
    434 
    435 // return an array of month names for the current locale, indexed 1..12
    436 function locale_months() {
    437     global $wp_locale;
    438 
    439     $months = array();
    440     foreach ( range(1, 12) as $m )
    441         $months[$m] = $wp_locale->get_month( $m );
    442     return $months;
    443 }
    444 
    445419function touch_time( $edit = 1, $for_post = 1 ) {
    446420    global $wp_locale, $post, $comment;
     
    449423        $edit = ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date || '0000-00-00 00:00:00' == $post->post_date ) ) ? false : true;
    450424
    451     echo '<fieldset class="jcalendar"><legend><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp" /> <label for="timestamp">'.__( 'Edit timestamp' ).'</label></legend>';
     425    echo '<fieldset><legend><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp" /> <label for="timestamp">'.__( 'Edit timestamp' ).'</label></legend>';
    452426
    453427    $time_adj = time() + (get_option( 'gmt_offset' ) * 3600 );
     
    460434    $ss = ($edit) ? mysql2date( 's', $post_date ) : gmdate( 's', $time_adj );
    461435
    462     echo '<div class="jcalendar-selects">';
    463     echo input_dropdown( 'mm', locale_months(), $mm, 'jcalendar-select-month', 'edit_date.checked=true' );
    464 
    465     foreach ( range(1, 31) as $i )
    466         $days[$i] = $i;
    467     echo input_dropdown( 'jj', $days, $jj, 'jcalendar-select-day', 'edit_date.checked=true' );
    468 
    469     foreach ( range(1970, 2038) as $i )
    470         $years[$i] = $i;
    471     echo input_dropdown( 'aa', $years, $aa, 'jcalendar-select-year', 'edit_date.checked=true' );
    472     echo '</div>';
    473 
    474     $jcal_css_url = get_bloginfo('wpurl') . '/wp-includes/js/jquery/css/jcalendar.css?version=' . get_bloginfo('version');
    475 
    476 ?>
    477 <script type="text/javascript">
    478 <!--
    479 jQuery(document).ready(function() {
    480     jQuery.jcalendar.setLanguageStrings(jcalendar_L10n.days, jcalendar_L10n.months, jcalendar_L10n.navLinks);
    481     jQuery('fieldset.jcalendar').jcalendar();
    482 });
    483 // -->
    484 </script>
    485 @ <input type="text" id="hh" name="hh" value="<?php echo $hh ?>" size="2" maxlength="2" onchange="edit_date.checked=true" /> :
     436    echo "<select name=\"mm\" onchange=\"edit_date.checked=true\">\n";
     437    for ( $i = 1; $i < 13; $i = $i +1 ) {
     438        echo "\t\t\t<option value=\"$i\"";
     439        if ( $i == $mm )
     440            echo ' selected="selected"';
     441        echo '>' . $wp_locale->get_month( $i ) . "</option>\n";
     442    }
     443?>
     444</select>
     445<input type="text" id="jj" name="jj" value="<?php echo $jj; ?>" size="2" maxlength="2" onchange="edit_date.checked=true"/>
     446<input type="text" id="aa" name="aa" value="<?php echo $aa ?>" size="4" maxlength="5" onchange="edit_date.checked=true" /> @
     447<input type="text" id="hh" name="hh" value="<?php echo $hh ?>" size="2" maxlength="2" onchange="edit_date.checked=true" /> :
    486448<input type="text" id="mn" name="mn" value="<?php echo $mn ?>" size="2" maxlength="2" onchange="edit_date.checked=true" />
    487449<input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" onchange="edit_date.checked=true" />
  • trunk/wp-admin/post-new.php

    r5804 r5808  
    77wp_enqueue_script('interface');
    88wp_enqueue_script('autosave');
    9 wp_enqueue_script('jcalendar');
    109require_once ('./admin-header.php');
    1110
  • trunk/wp-admin/post.php

    r5804 r5808  
    5858        wp_enqueue_script('autosave');
    5959    }
    60     wp_enqueue_script('jcalendar');
    6160    require_once('admin-header.php');
    6261
  • trunk/wp-admin/wp-admin.css

    r5804 r5808  
    13331333}
    13341334
    1335 /* jcalendar */
    1336 
    1337 #moremeta select.jcalendar-select-day, #moremeta select.jcalendar-select-month, #moremeta select.jcalendar-select-year {
    1338     font-size: 11px;
    1339     width: auto;
    1340 }
    1341 
    1342 div.jcalendar table {
    1343 color:#000;
    1344 width: 100%;
    1345 background: #a1a5a9;
    1346 }
    1347 
    1348 div.jcalendar table th {
    1349 font-size: 10px;
    1350 background:#eee;
    1351 }
    1352 
    1353 div.jcalendar table td {
    1354 background:#f9f9f9;
    1355 padding:0;
    1356 }
    1357 
    1358 div.jcalendar table th.weekend {
    1359 background:#ddd;
    1360 }
    1361 
    1362 div.jcalendar table td.weekend {
    1363 background:#e9e9e9;
    1364 }
    1365 
    1366 div.jcalendar table td a {
    1367 font-size: 11px;
    1368 color:#333;
    1369 display:block;
    1370 line-height:1.7em;
    1371 text-align:center;
    1372 text-decoration:none;
    1373 }
    1374 
    1375 div.jcalendar table td.today a {
    1376 background:#777;
    1377 border-color:#aaa;
    1378 color:#fff;
    1379 font-weight:700;
    1380 }
    1381 
    1382 div.jcalendar table td a:hover,div.jcalendar table td a:focus,div.jcalendar table td a:active {
    1383 background:#77b0d3;
    1384 color:#fff;
    1385 padding:0;
    1386 }
    1387 
    1388 div.jcalendar table td a.selected {
    1389 background:#2685af;
    1390 color:#E3EFF5;
    1391 }
    1392 
    1393 div.jcalendar-links {
    1394 text-align:center;
    1395 }
    1396 
    1397 div.jcalendar-links a {
    1398 font-size: 11px;
    1399 margin: 0 .4em;
    1400 }
    1401 
     1335a.view-link {
     1336    position: absolute;
     1337    right: 5%;
     1338    margin-right: 220px;
     1339    text-decoration:underline;
     1340}
  • trunk/wp-includes/script-loader.php

    r5804 r5808  
    7575        $this->add( 'jquery-form', '/wp-includes/js/jquery/jquery.form.js', array('jquery'), '1.0.3');
    7676        $this->add( 'interface', '/wp-includes/js/jquery/interface.js', array('jquery'), '1.2');
    77         $this->add( 'jcalendar', '/wp-includes/js/jquery/jcalendar.js', array('jquery'), '0.5' );
    78 
    79         // this would be much nicer if localize used json so it could handle arrays
    80         global $wp_locale;
    81         $this->localize( 'jcalendar', 'jcalendar_L10n', array(
    82             'days' => array_values($wp_locale->weekday_abbrev),
    83             'months' => array_values($wp_locale->month),
    84             'navLinks' => array(
    85                 'p' => __('Prev'),
    86                 'n' => __('Next'),
    87                 't' => __('Today'),
    88             ),
    89         ) );
    9077
    9178        if ( is_admin() ) {
     
    219206        echo "<script type='text/javascript'>\n";
    220207        echo "/* <![CDATA[ */\n";
    221         echo $this->js_encode_array( $object_name, $this->scripts[$handle]->l10n );
    222         echo "\n/* ]]> */\n";
     208        echo "\t$object_name = {\n";
     209        $eol = '';
     210        foreach ( $this->scripts[$handle]->l10n as $var => $val ) {
     211            echo "$eol\t\t$var: \"" . js_escape( $val ) . '"';
     212            $eol = ",\n";
     213        }
     214        echo "\n\t}\n";
     215        echo "/* ]]> */\n";
    223216        echo "</script>\n";
    224     }
    225 
    226     /**
    227      * Poor man's json: recursively encode an associative array of strings or arrays as a javascript array definition
    228      */
    229     function js_encode_array( $name, $vals, $level=0 ) {
    230         $out = array();
    231         foreach ( $vals as $var => $val ) {
    232             if ( is_array($val) )
    233                 $out[] = $this->js_encode_array( $var, $val, $level+1 );
    234             else
    235                 $out[] = str_repeat("\t", $level+1) . "{$var}: \"" . js_escape( $val ) . '"';
    236         }
    237 
    238         return str_repeat("\t", $level) . "{$name} " . ($level ? ':' : '=') . " {\n"
    239             . join( ",\n", $out )
    240             . "\n" . str_repeat("\t", $level) . "}";
    241217    }
    242218
Note: See TracChangeset for help on using the changeset viewer.