Make WordPress Core


Ignore:
Timestamp:
04/16/2008 08:58:03 PM (19 years ago)
Author:
ryan
Message:

Custom header and color picker fixes from mdawaffe. fixes #6577 for trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/custom-header.php

    r7049 r7698  
    1212
    1313                add_action("admin_print_scripts-$page", array(&$this, 'js_includes'));
     14                add_action("admin_head-$page", array(&$this, 'take_action'), 50);
    1415                add_action("admin_head-$page", array(&$this, 'js'), 50);
    1516                add_action("admin_head-$page", $this->admin_header_callback, 51);
    1617        }
    1718
     19        function step() {
     20                $step = (int) @$_GET['step'];
     21                if ( $step < 1 || 3 < $step )
     22                        $step = 1;
     23                return $step;
     24        }
     25
    1826        function js_includes() {
    19                 wp_enqueue_script('cropper');
    20                 wp_enqueue_script('colorpicker');
    21         }
    22 
    23         function js() {
    24 
     27                $step = $this->step();
     28                if ( 1 == $step )
     29                        wp_enqueue_script('colorpicker');
     30                elseif ( 2 == $step )   
     31                        wp_enqueue_script('cropper');
     32        }
     33
     34        function take_action() {
    2535                if ( isset( $_POST['textcolor'] ) ) {
    2636                        check_admin_referer('custom-header');
    … …  
    3747                        remove_theme_mods();
    3848                }
    39         ?>
     49        }
     50
     51        function js() {
     52                $step = $this->step();
     53                if ( 1 == $step )
     54                        $this->js_1();
     55                elseif ( 2 == $step )
     56                        $this->js_2();
     57        }
     58
     59        function js_1() { ?>
    4060<script type="text/javascript">
    41 
     61        var cp = new ColorPicker();
     62
     63        function pickColor(color) {
     64                $('name').style.color = color;
     65                $('desc').style.color = color;
     66                $('textcolor').value = color;
     67        }
     68        function PopupWindow_hidePopup(magicword) {
     69                if ( magicword != 'prettyplease' )
     70                        return false;
     71                if (this.divName != null) {
     72                        if (this.use_gebi) {
     73                                document.getElementById(this.divName).style.visibility = "hidden";
     74                        }
     75                        else if (this.use_css) {
     76                                document.all[this.divName].style.visibility = "hidden";
     77                        }
     78                        else if (this.use_layers) {
     79                                document.layers[this.divName].visibility = "hidden";
     80                        }
     81                }
     82                else {
     83                        if (this.popupWindow && !this.popupWindow.closed) {
     84                                this.popupWindow.close();
     85                                this.popupWindow = null;
     86                        }
     87                }
     88                return false;
     89        }
     90        function colorSelect(t,p) {
     91                if ( cp.p == p && document.getElementById(cp.divName).style.visibility != "hidden" ) {
     92                        cp.hidePopup('prettyplease');
     93                } else {
     94                        cp.p = p;
     95                        cp.select(t,p);
     96                }
     97        }
     98        function colorDefault() {
     99                pickColor('#<?php echo HEADER_TEXTCOLOR; ?>');
     100        }
     101
     102        function hide_text() {
     103                $('name').style.display = 'none';
     104                $('desc').style.display = 'none';
     105                $('pickcolor').style.display = 'none';
     106                $('defaultcolor').style.display = 'none';
     107                $('textcolor').value = 'blank';
     108                $('hidetext').value = '<?php _e('Show Text'); ?>';
     109//              $('hidetext').onclick = 'show_text()';
     110                Event.observe( $('hidetext'), 'click', show_text );
     111        }
     112
     113        function show_text() {
     114                $('name').style.display = 'block';
     115                $('desc').style.display = 'block';
     116                $('pickcolor').style.display = 'inline';
     117                $('defaultcolor').style.display = 'inline';
     118                $('textcolor').value = '<?php echo HEADER_TEXTCOLOR; ?>';
     119                $('hidetext').value = '<?php _e('Hide Text'); ?>';
     120                Event.stopObserving( $('hidetext'), 'click', show_text );
     121                Event.observe( $('hidetext'), 'click', hide_text );
     122        }
     123
     124        <?php if ( 'blank' == get_theme_mod('header_textcolor', HEADER_TEXTCOLOR) ) { ?>
     125Event.observe( window, 'load', hide_text );
     126        <?php } ?>
     127
     128</script>
     129<?php
     130        }
     131
     132        function js_2() { ?>
     133<script type="text/javascript">
    42134        function onEndCrop( coords, dimensions ) {
    43135                $( 'x1' ).value = coords.x1;
    … …  
    78170                }
    79171        );
    80 
    81         var cp = new ColorPicker();
    82 
    83         function pickColor(color) {
    84                 $('name').style.color = color;
    85                 $('desc').style.color = color;
    86                 $('textcolor').value = color;
    87         }
    88         function PopupWindow_hidePopup(magicword) {
    89                 if ( magicword != 'prettyplease' )
    90                         return false;
    91                 if (this.divName != null) {
    92                         if (this.use_gebi) {
    93                                 document.getElementById(this.divName).style.visibility = "hidden";
    94                         }
    95                         else if (this.use_css) {
    96                                 document.all[this.divName].style.visibility = "hidden";
    97                         }
    98                         else if (this.use_layers) {
    99                                 document.layers[this.divName].visibility = "hidden";
    100                         }
    101                 }
    102                 else {
    103                         if (this.popupWindow && !this.popupWindow.closed) {
    104                                 this.popupWindow.close();
    105                                 this.popupWindow = null;
    106                         }
    107                 }
    108                 return false;
    109         }
    110         function colorSelect(t,p) {
    111                 if ( cp.p == p && document.getElementById(cp.divName).style.visibility != "hidden" ) {
    112                         cp.hidePopup('prettyplease');
    113                 } else {
    114                         cp.p = p;
    115                         cp.select(t,p);
    116                 }
    117         }
    118         function colorDefault() {
    119                 pickColor('<?php echo HEADER_TEXTCOLOR; ?>');
    120         }
    121 
    122         function hide_text() {
    123                 $('name').style.display = 'none';
    124                 $('desc').style.display = 'none';
    125                 $('pickcolor').style.display = 'none';
    126                 $('defaultcolor').style.display = 'none';
    127                 $('textcolor').value = 'blank';
    128                 $('hidetext').value = '<?php _e('Show Text'); ?>';
    129 //              $('hidetext').onclick = 'show_text()';
    130                 Event.observe( $('hidetext'), 'click', show_text );
    131         }
    132 
    133         function show_text() {
    134                 $('name').style.display = 'block';
    135                 $('desc').style.display = 'block';
    136                 $('pickcolor').style.display = 'inline';
    137                 $('defaultcolor').style.display = 'inline';
    138                 $('textcolor').value = '<?php echo HEADER_TEXTCOLOR; ?>';
    139                 $('hidetext').value = '<?php _e('Hide Text'); ?>';
    140                 Event.stopObserving( $('hidetext'), 'click', show_text );
    141                 Event.observe( $('hidetext'), 'click', hide_text );
    142         }
    143 
    144         <?php if ( 'blank' == get_theme_mod('header_textcolor', HEADER_TEXTCOLOR) ) { ?>
    145 Event.observe( window, 'load', hide_text );
    146         <?php } ?>
    147 
    148172</script>
    149173<?php
    … …  
    253277
    254278<p><?php _e('Choose the part of the image you want to use as your header.'); ?></p>
    255 <div id="testWrap">
     279<div id="testWrap" style="position: relative">
    256280<img src="<?php echo $url; ?>" id="upload" width="<?php echo $width; ?>" height="<?php echo $height; ?>" />
    257281</div>
    … …  
    328352
    329353        function admin_page() {
    330                 if ( !isset( $_GET['step'] ) )
    331                         $step = 1;
    332                 else
    333                         $step = (int) $_GET['step'];
    334 
    335                 if ( 1 == $step ) {
     354                $step = $this->step();
     355                if ( 1 == $step )
    336356                        $this->step_1();
    337                 } elseif ( 2 == $step ) {
     357                elseif ( 2 == $step )
    338358                        $this->step_2();
    339                 } elseif ( 3 == $step ) {
     359                elseif ( 3 == $step )
    340360                        $this->step_3();
    341                 }
    342 
    343361        }
    344362
Note: See TracChangeset for help on using the changeset viewer.