Make WordPress Core


Ignore:
Timestamp:
08/10/2005 11:39:15 PM (19 years ago)
Author:
matt
Message:

Getting much better! Fixes #1566

File:
1 edited

Legend:

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

    r2767 r2776  
    101101<script type="text/javascript" src="dbx.js"></script>
    102102<script type="text/javascript" src="dbx-key.js"></script>
     103
     104<?php if ( current_user_can('manage_categories') ) : ?>
    103105<script type="text/javascript" src="tw-sack.js"></script>
    104106<script type="text/javascript">
    105107var ajaxCat = new sack();
     108var newcat;
     109 
     110function newCatAddIn() {
     111    var ajaxcat = document.createElement('p');
     112    ajaxcat.id = 'ajaxcat';
     113
     114    newcat = document.createElement('input');
     115    newcat.type = 'text';
     116    newcat.name = 'newcat';
     117    newcat.id = 'newcat';
     118    newcat.size = '16';
     119    newcat.setAttribute('autocomplete', 'off');
     120    newcat.setAttribute('onkeypress', 'return ajaxNewCatKeyPress(event);');
     121
     122    var newcatSub = document.createElement('input');
     123    newcatSub.type = 'button';
     124    newcatSub.name = 'Button';
     125    newcatSub.value = '+';
     126    newcatSub.setAttribute('onclick', 'ajaxNewCat();');
     127
     128    ajaxcat.appendChild(newcat);
     129    ajaxcat.appendChild(newcatSub);
     130    document.getElementById('categorychecklist').parentNode.appendChild(ajaxcat);
     131}
     132
     133addLoadEvent(newCatAddIn);
    106134
    107135function getResponseElement() {
    108 var p = document.getElementById('ajaxcatresponse');
     136    var p = document.getElementById('ajaxcatresponse');
    109137    if (!p) {
    110138        p = document.createElement('p');
     
    166194        newCheck.id = 'category-' + id;
    167195
    168         var newLabelText = document.createTextNode(' ' + document.getElementById('newcat').value);
     196        var newLabelText = document.createTextNode(' ' + newcat.value);
    169197        newLabel.appendChild(newLabelText);
    170198        Fat.fade_all();
    171199        newLabel.setAttribute('class', 'selectit');
    172200    }
    173 }
    174 
    175 function ajaxNewCatKeyUp(e) {
     201    newcat.value = '';
     202}
     203
     204function ajaxNewCatKeyPress(e) {
    176205    if (!e) {
    177206        if (window.event) {
     
    183212    if (e.keyCode == 13) {
    184213        ajaxNewCat();
     214        e.returnValue = false;
     215        e.cancelBubble = true;
     216        return false;
    185217    }
    186218}
     
    200232<?php endif; ?>
    201233
     234<?php endif; ?>
     235
    202236<?php do_action('admin_head'); ?>
    203237</head>
Note: See TracChangeset for help on using the changeset viewer.