Make WordPress Core


Ignore:
Timestamp:
04/04/2006 12:16:27 AM (20 years ago)
Author:
ryan
Message:

List manip improvements from mdawaffe. fixes #2633

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/list-manipulation-js.php

    r3677 r3684  
    88
    99function WPAjax(file, responseEl){//class WPAjax extends sack
    10     this.getResponseElement=function(r){var p=document.getElementById(r+'-p');if(!p){p=document.createElement('span');p.id=r+'ajax-response-p';document.getElementById(r).appendChild(p);}this.myResponseElement=p; }
     10    this.getResponseElement=function(r){var p=document.getElementById(r+'-p');if(!p){p=document.createElement('span');p.id=r+'-p';document.getElementById(r).appendChild(p);}this.myResponseElement=p;  }
    1111    this.parseAjaxResponse=function(){
    12         if(isNaN(this.response)){this.myResponseElement.innerHTML='<div class="error">'+this.response+'</div>';return false;}
     12        if(isNaN(this.response)){this.myResponseElement.innerHTML='<div class="error"><p>'+this.response+'</p></div>';return false;}
    1313        this.response=parseInt(this.response,10);
    14         if(-1==this.response){this.myResponseElement.innerHTML="<?php _e("You don't have permission to do that."); ?>";return false;}
    15         else if(0==this.response){this.myResponseElement.innerHTML="<?php _e("Something odd happened. Try refreshing the page? Either that or what you tried to change never existed in the first place."); ?>";return false;}
     14        if(-1==this.response){this.myResponseElement.innerHTML="<div class='error'><p><?php _e("You don't have permission to do that."); ?></p></div>";return false;}
     15        else if(0==this.response){this.myResponseElement.innerHTML="<div class='error'><p><?php _e("Something odd happened. Try refreshing the page? Either that or what you tried to change never existed in the first place."); ?></p></div>";return false;}
    1616        return true;
    1717    }
    1818    this.parseAjaxResponseXML=function(){
    1919        if(this.responseXML&&typeof this.responseXML=='object')return true;
    20         if(isNaN(this.response)){this.myResponseElement.innerHTML='<div class="error">'+this.response+'</div>';return false;}
     20        if(isNaN(this.response)){this.myResponseElement.innerHTML='<div class="error"><p>'+this.response+'</p></div>';return false;}
    2121        var r=parseInt(this.response,10);
    22         if(-1==r){this.myResponseElement.innerHTML="<?php _e("You don't have permission to do that."); ?>";}
    23         else if(0==r){this.myResponseElement.innerHTML="<?php _e("Invalid Entry."); ?>";}
     22        if(-1==r){this.myResponseElement.innerHTML="<div class='error'><p><?php _e("You don't have permission to do that."); ?></p></div>";}
     23        else if(0==r){this.myResponseElement.innerHTML="<div class='error'><p><?php _e("Invalid Entry."); ?></p></div>";}
    2424        return false;
    2525    }
     
    3737    this.theList=null;
    3838    this.ajaxRespEl=null;
    39     this.inputData='';this.clearInputs=new Array();
     39    this.inputData='';this.clearInputs=new Array();this.showLink=1;
    4040    this.topAdder=0;this.alt='alternate';this.recolorPos;this.reg_color='#FFFFFF';this.alt_color='#F1F1F1';
    4141    var listType;var listItems;
     
    5858                else tempObj.addListItem(getNodeValue(newItems[c],'newitem'),newItems.length);
    5959            }}
    60             this.myResponseElement.innerHTML='';tempObj.inputData='';
     60            tempObj.inputData='';
     61            if(tempObj.showLink){this.myResponseElement.innerHTML='<div id="jumplink" class="updated fade"><p><a href="#'+what+'-'+id+'"><?php _e('Jump to new item'); ?></a></p></div>';}
     62            else this.myResponseElement.innerHTML='';
    6163            for(var i=0;i<tempObj.clearInputs.length;i++){try{var theI=document.getElementById(tempObj.clearInputs[i]);if(theI.tagName.match(/select/i))theI.selectedIndex=0;else theI.value='';}catch(e){}}
    6264            if(onComplete&&typeof onComplete=='function')onComplete();
    63             tempObj.recolorList(tempObj.recolorPos,1000)
     65            tempObj.recolorList(tempObj.recolorPos,1000);
    6466        }
    6567        this.ajaxAdd.runAJAX('action='+(update?'update-':'add-')+what+this.inputData);
     
    124126                if('action'==inputs[a][i].name)continue;
    125127                if('text'==inputs[a][i].type||'password'==inputs[a][i].type||'hidden'==inputs[a][i].type||inputs[a][i].tagName.match(/textarea/i)){
    126                     this.inputData+='&'+inputs[a][i].name+'='+encodeURIComponent(inputs[a][i].value);
     128                    this.inputData+='&'+inputs[a][i].name+'='+encodeURIComponent(inputs[a][i].value);if('hidden'!=inputs[a][i].type)this.clearInputs.push(inputs[a][i].id);
    127129                }else if(inputs[a][i].tagName.match(/select/i)){
    128                     this.inputData+='&'+inputs[a][i].name+'='+encodeURIComponent(inputs[a][i].options[inputs[a][i].selectedIndex].value);
     130                    this.inputData+='&'+inputs[a][i].name+'='+encodeURIComponent(inputs[a][i].options[inputs[a][i].selectedIndex].value);this.clearInputs.push(inputs[a][i].id);
    129131                }
    130132            }   
Note: See TracChangeset for help on using the changeset viewer.