Category AJAX fixes from mdawaffe. fixes #3343

git-svn-id: https://develop.svn.wordpress.org/trunk@4768 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2007-01-19 00:49:01 +00:00
parent 355cf17707
commit 3e8513baea
6 changed files with 45 additions and 45 deletions

View File

@ -8,7 +8,7 @@ function newCatAddIn() {
var jaxcat = $('jaxcat');
if ( !jaxcat )
return false;
jaxcat.update('<span id="ajaxcat"><input type="text" name="newcat" id="newcat" size="16" autocomplete="off"/><input type="button" name="Button" id="catadd" value="<?php echo js_escape(__('Add')); ?>"/><span id="howto"><?php echo js_escape(__('Separate multiple categories with commas.')); ?></span></span>');
Element.update(jaxcat,'<span id="ajaxcat"><input type="text" name="newcat" id="newcat" size="16" autocomplete="off"/><input type="button" name="Button" id="catadd" value="<?php echo js_escape(__('Add')); ?>"/><span id="howto"><?php echo js_escape(__('Separate multiple categories with commas.')); ?></span></span>');
$('newcat').onkeypress = function(e) { return killSubmit("catList.ajaxAdder('category','jaxcat');", e); };
$('catadd').onclick = function() { catList.ajaxAdder('category', 'jaxcat'); };
}

View File

@ -207,16 +207,16 @@ addLoadEvent( function() {
if ( !prep ) {
var filesEl = $('upload-files');
if ( filesEl )
filesEl.show();
Element.show(filesEl);
var navEl = $('current-tab-nav');
if ( navEl )
navEl.show();
Element.show(navEl);
}
if ( !this.ID )
this.grabImageData(0);
var div = $('upload-file');
if ( div )
div.remove();
Element.remove(div);
return false;
},

View File

@ -109,7 +109,7 @@ this.handleSW=Builder.node("div",{"class":_f+"handle "+_f+"handleSW"});
this.handleW=Builder.node("div",{"class":_f+"handle "+_f+"handleW"});
this.handleNW=Builder.node("div",{"class":_f+"handle "+_f+"handleNW"});
this.selArea=Builder.node("div",{"class":_f+"selArea"},[Builder.node("div",{"class":_f+"marqueeHoriz "+_f+"marqueeNorth"},[Builder.node("span")]),Builder.node("div",{"class":_f+"marqueeVert "+_f+"marqueeEast"},[Builder.node("span")]),Builder.node("div",{"class":_f+"marqueeHoriz "+_f+"marqueeSouth"},[Builder.node("span")]),Builder.node("div",{"class":_f+"marqueeVert "+_f+"marqueeWest"},[Builder.node("span")]),this.handleN,this.handleNE,this.handleE,this.handleSE,this.handleS,this.handleSW,this.handleW,this.handleNW,Builder.node("div",{"class":_f+"clickArea"})]);
$(this.selArea).setStyle({backgroundColor:"transparent",backgroundRepeat:"no-repeat",backgroundPosition:"0 0"});
Element.setStyle($(this.selArea),{backgroundColor:"transparent",backgroundRepeat:"no-repeat",backgroundPosition:"0 0"});
this.imgWrap.appendChild(this.img);
this.imgWrap.appendChild(this.dragArea);
this.dragArea.appendChild(this.selArea);
@ -131,17 +131,17 @@ this.setParams();
this.imgW=this.img.width;
this.imgH=this.img.height;
if(!this.isIE){
$(this.overlay).setStyle({width:this.imgW+"px",height:this.imgH+"px"});
$(this.overlay).hide();
$(this.selArea).setStyle({backgroundImage:"url("+this.img.src+")"});
Element.setStyle($(this.overlay),{width:this.imgW+"px",height:this.imgH+"px"});
Element.hide($(this.overlay));
Element.setStyle($(this.selArea),{backgroundImage:"url("+this.img.src+")"});
}else{
$(this.north).setStyle({height:0});
$(this.east).setStyle({width:0,height:0});
$(this.south).setStyle({height:0});
$(this.west).setStyle({width:0,height:0});
Element.setStyle($(this.north),{height:0});
Element.setStyle($(this.east),{width:0,height:0});
Element.setStyle($(this.south),{height:0});
Element.setStyle($(this.west),{width:0,height:0});
}
$(this.imgWrap).setStyle({"width":this.imgW+"px","height":this.imgH+"px"});
$(this.selArea).hide();
Element.setStyle($(this.imgWrap),{"width":this.imgW+"px","height":this.imgH+"px"});
Element.hide($(this.selArea));
var _15=Position.positionedOffset(this.imgWrap);
this.wrapOffsets={"top":_15[1],"left":_15[0]};
var _16={x1:0,y1:0,x2:0,y2:0};
@ -151,7 +151,7 @@ _16.x1=Math.ceil((this.imgW-this.options.ratioDim.x)/2);
_16.y1=Math.ceil((this.imgH-this.options.ratioDim.y)/2);
_16.x2=_16.x1+this.options.ratioDim.x;
_16.y2=_16.y1+this.options.ratioDim.y;
this.selArea.show();
Element.show(this.selArea);
this.drawArea();
this.endCrop();
}
@ -339,7 +339,7 @@ _37.a1=_37.a1=_37.a2-_3c;
return _37;
},drawArea:function(){
if(!this.isIE){
$(this.overlay).show();
Element.show($(this.overlay));
}
var _3e=this.calcW();
var _3f=this.calcH();
@ -402,10 +402,10 @@ fixEl.removeChild(n);
},startResize:function(e){
this.startCoords=this.cloneCoords(this.areaCoords);
this.resizing=true;
this.resizeHandle=Event.element(e).classNames().toString().replace(/([^N|NE|E|SE|S|SW|W|NW])+/,"");
this.resizeHandle=Element.classNames(Event.element(e)).toString().replace(/([^N|NE|E|SE|S|SW|W|NW])+/,"");
Event.stop(e);
},startDrag:function(e){
this.selArea.show();
Element.show(this.selArea);
this.clickCoords=this.getCurPos(e);
this.setAreaCoords({x1:this.clickCoords.x,y1:this.clickCoords.y,x2:this.clickCoords.x,y2:this.clickCoords.y});
this.dragging=true;
@ -496,8 +496,8 @@ this.previewWrap=$(this.options.previewWrap);
this.previewImg=this.img.cloneNode(false);
this.options.displayOnInit=true;
this.hasPreviewImg=true;
this.previewWrap.addClassName("imgCrop_previewWrap");
this.previewWrap.setStyle({width:this.options.minWidth+"px",height:this.options.minHeight+"px"});
Element.addClassName(this.previewWrap,"imgCrop_previewWrap");
Element.setStyle(this.previewWrap,{width:this.options.minWidth+"px",height:this.options.minHeight+"px"});
this.previewWrap.appendChild(this.previewImg);
}
},subDrawArea:function(){
@ -513,4 +513,4 @@ _5d.height=_5c.h;
_5d.left=_5c.x;
_5d.top=_5c.y;
}
}});
}});

View File

@ -23,7 +23,7 @@ Object.extend(listMan.prototype, {
this.theList = $(theListId ? theListId : 'the-list');
if ( !this.theList )
return false;
this.theList.cleanWhitespace();
Element.cleanWhitespace(this.theList);
},
// sends add-what and fields contained in where
@ -54,7 +54,7 @@ Object.extend(listMan.prototype, {
showLinkMessage += "<a href='#" + what + '-' + id + "'><?php echo js_escape(__('Jump to new item')); ?>";
});
if ( tempObj.showLink && showLinkMessage )
ajaxAdd.myResponseElement.update("<div id='jumplink' class='updated fade'><p>" + showLinkMessage + "</p></div>");
Element.update(ajaxAdd.myResponseElement,"<div id='jumplink' class='updated fade'><p>" + showLinkMessage + "</p></div>");
}
if ( tempObj.addComplete && typeof tempObj.addComplete == 'function' )
tempObj.addComplete( what, where, update, transport );
@ -82,7 +82,7 @@ Object.extend(listMan.prototype, {
var action = 'delete-' + what + '&id=' + id;
var idName = what.replace('-as-spam','') + '-' + id;
ajaxDel.addOnComplete( function(transport) {
ajaxDel.myResponseElement.update('');
Element.update(ajaxDel.myResponseElement,'');
tempObj.destore(action);
if( tempObj.delComplete && typeof tempObj.delComplete == 'function' )
tempObj.delComplete( what, id, transport );
@ -105,7 +105,7 @@ Object.extend(listMan.prototype, {
var action = 'dim-' + what + '&id=' + id;
var idName = what + '-' + id;
ajaxDim.addOnComplete( function(transport) {
ajaxDim.myResponseElement.update('');
Element.update(ajaxDim.myResponseElement,'');
tempObj.destore(action);
if ( tempObj.dimComplete && typeof tempObj.dimComplete == 'function' )
tempObj.dimComplete( what, id, dimClass, transport );
@ -120,11 +120,11 @@ Object.extend(listMan.prototype, {
addListItem: function( h ) {
new Insertion[this.topAdder ? 'Top' : 'Bottom'](this.theList,h);
this.theList.cleanWhitespace();
Element.cleanWhitespace(this.theList);
var id = this.topAdder ? this.theList.firstChild.id : this.theList.lastChild.id;
if ( this.alt )
if ( this.theList.childNodes.length % 2 )
$(id).addClassName(this.alt);
Element.addClassName($(id),this.alt);
Fat.fade_element(id);
},
@ -145,7 +145,7 @@ Object.extend(listMan.prototype, {
replaceListItem: function( id, h, update ) {
id = $(id);
if ( !update ) {
id.remove();
Element.remove(id);
this.addListItem( h );
return;
}
@ -156,14 +156,14 @@ Object.extend(listMan.prototype, {
// toggles class
dimItem: function( id, dimClass, noFade ) {
id = $(id);
if ( id.hasClassName(dimClass) ) {
if ( Element.hasClassName(id,dimClass) ) {
if ( !noFade )
Fat.fade_element(id.id,null,700,null);
id.removeClassName(dimClass);
Element.removeClassName(id,dimClass);
} else {
if ( !noFade )
Fat.fade_element(id.id,null,700,'#FF3333');
id.addClassName(dimClass);
Element.addClassName(id,dimClass);
}
},
@ -183,7 +183,7 @@ Object.extend(listMan.prototype, {
this.theList.replaceChild(this.dataStore[action], $(id));
delete(this.dataStore[action]);
if ( error ) {
func = function() { $(id).setStyle( { 'background-color': '#FF3333' } ); }
func = function() { Element.setStyle($(id),{backgroundColor:'#FF3333'}); }
func(); setTimeout(func, 705); // Hit it twice in case it's still fading.
}
},
@ -246,12 +246,12 @@ Object.extend(listMan.prototype, {
return;
var alt = this.alt;
var offset = this.altOffset;
var listItems = $A(this.theList.childNodes).findAll( function(i) { return i.visible() } );
var listItems = $A(this.theList.childNodes).findAll( function(i) { return Element.visible(i) } );
listItems.each( function(i,n) {
if ( ( n + offset ) % 2 )
i.removeClassName(alt);
Element.removeClassName(i,alt);
else
i.addClassName(alt);
Element.addClassName(i,alt);
});
}
});

View File

@ -38,26 +38,26 @@ Object.extend(WPAjax.prototype, {
this.myResponseElement = p;
},
parseAjaxResponse: function() { // 1 = good, 0 = strange (bad data?), -1 = you lack permission
if ( this.transport.responseXML && typeof this.transport.responseXML == 'object' ) {
if ( this.transport.responseXML && typeof this.transport.responseXML == 'object' && ( this.transport.responseXML.xml || 'undefined' == typeof this.transport.responseXML.xml ) ) {
var err = this.transport.responseXML.getElementsByTagName('wp_error');
if ( err[0] ) {
var msg = $A(err).inject( '', function(a, b) { return a + '<p>' + b.firstChild.nodeValue + '</p>'; } );
this.myResponseElement.update('<div class="error">' + msg + '</div>');
Element.update(this.myResponseElement,'<div class="error">' + msg + '</div>');
return false;
}
return true;
}
var r = this.transport.responseText;
if ( isNaN(r) ) {
this.myResponseElement.update('<div class="error"><p>' + r + '</p></div>');
Element.update(this.myResponseElement,'<div class="error"><p>' + r + '</p></div>');
return false;
}
var r = parseInt(r,10);
if ( -1 == r ) {
this.myResponseElement.update("<div class='error'><p><?php _e("You don't have permission to do that."); ?></p></div>");
Element.update(this.myResponseElement,"<div class='error'><p><?php _e("You don't have permission to do that."); ?></p></div>");
return false;
} else if ( 0 == r ) {
this.myResponseElement.update("<div class='error'><p><?php _e("Something strange happened. Try refreshing the page."); ?></p></div>");
Element.update(this.myResponseElement,"<div class='error'><p><?php _e("Something strange happened. Try refreshing the page."); ?></p></div>");
return false;
}
return true;

View File

@ -20,8 +20,8 @@ class WP_Scripts {
$this->add( 'wp_tiny_mce', $mce_config, array('tiny_mce'), '20061113' );
$this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.5.0');
$this->add( 'autosave', '/wp-includes/js/autosave-js.php', array('prototype', 'sack'), '20070116');
$this->add( 'wp-ajax', '/wp-includes/js/wp-ajax-js.php', array('prototype'), '4459');
$this->add( 'listman', '/wp-includes/js/list-manipulation-js.php', array('wp-ajax', 'fat'), '4583');
$this->add( 'wp-ajax', '/wp-includes/js/wp-ajax-js.php', array('prototype'), '20070118');
$this->add( 'listman', '/wp-includes/js/list-manipulation-js.php', array('wp-ajax', 'fat'), '20070118');
$this->add( 'scriptaculous-root', '/wp-includes/js/scriptaculous/wp-scriptaculous.js', array('prototype'), '1.6.1');
$this->add( 'scriptaculous-builder', '/wp-includes/js/scriptaculous/builder.js', array('scriptaculous-root'), '1.6.1');
$this->add( 'scriptaculous-dragdrop', '/wp-includes/js/scriptaculous/dragdrop.js', array('scriptaculous-builder'), '1.6.1');
@ -29,16 +29,16 @@ class WP_Scripts {
$this->add( 'scriptaculous-slider', '/wp-includes/js/scriptaculous/slider.js', array('scriptaculous-effects'), '1.6.1');
$this->add( 'scriptaculous-controls', '/wp-includes/js/scriptaculous/controls.js', array('scriptaculous-root'), '1.6.1');
$this->add( 'scriptaculous', '', array('scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls'), '1.6.1');
$this->add( 'cropper', '/wp-includes/js/crop/cropper.js', array('scriptaculous-dragdrop'), '1');
$this->add( 'cropper', '/wp-includes/js/crop/cropper.js', array('scriptaculous-dragdrop'), '20070118');
if ( is_admin() ) {
$this->add( 'dbx-admin-key', '/wp-admin/dbx-admin-key-js.php', array('dbx'), '3651' );
$this->add( 'ajaxcat', '/wp-admin/cat-js.php', array('listman'), '3684' );
$this->add( 'ajaxcat', '/wp-admin/cat-js.php', array('listman'), '20070118' );
$this->add( 'admin-categories', '/wp-admin/categories.js', array('listman'), '3684' );
$this->add( 'admin-custom-fields', '/wp-admin/custom-fields.js', array('listman'), '3733' );
$this->add( 'admin-comments', '/wp-admin/edit-comments.js', array('listman'), '3847' );
$this->add( 'admin-users', '/wp-admin/users.js', array('listman'), '4583' );
$this->add( 'xfn', '/wp-admin/xfn.js', false, '3517' );
$this->add( 'upload', '/wp-admin/upload-js.php', array('prototype'), '20070116' );
$this->add( 'upload', '/wp-admin/upload-js.php', array('prototype'), '20070118' );
}
}