Remember what attachment options you pick, fixes #4565. Hat tip: filosofo.

git-svn-id: http://svn.automattic.com/wordpress/trunk@6386 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
matt 2007-12-16 03:00:38 +00:00
parent 7b16e3616c
commit 3225503174
1 changed files with 44 additions and 7 deletions

View File

@ -5,6 +5,38 @@ addLoadEvent( function() {
tab: '',
postID: 0,
// cookie create and read functions adapted from http://www.quirksmode.org/js/cookies.html
createCookie: function(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
},
readCookie: function(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
},
assignCookieOnChange: function() {
jQuery(this).bind("change", function(){
theFileList.createCookie(jQuery(this).attr('name'),jQuery(this).attr('id'),365);
});
},
checkCookieSetting: function(name, defaultSetting) {
return this.readCookie(name) ? this.readCookie(name) : defaultSetting;
},
toQueryParams: function( s ) {
var r = {}; if ( !s ) { return r; }
var q = s.split('?'); if ( q[1] ) { s = q[1]; }
@ -114,12 +146,12 @@ addLoadEvent( function() {
h += "<form name='uploadoptions' id='uploadoptions' class='alignleft'>";
h += "<table>";
var display = [];
var checked = 'display-title';
var checkedDisplay = 'display-title';
if ( 1 == this.currentImage.isImage ) {
checked = 'display-full';
checkedDisplay = 'display-full';
if ( this.currentImage.thumb ) {
display.push("<label for='display-thumb'><input type='radio' name='display' id='display-thumb' value='thumb' /> " + this.thumb + "</label><br />");
checked = 'display-thumb';
checkedDisplay = 'display-thumb';
}
display.push("<label for='display-full'><input type='radio' name='display' id='display-full' value='full' /> " + this.full + "</label>");
} else if ( this.currentImage.thumb ) {
@ -132,9 +164,9 @@ addLoadEvent( function() {
h += "</td></tr>";
}
h += "<tr><th>" + this.link + "</th><td>";
h += "<label for='link-file'><input type='radio' name='link' id='link-file' value='file' checked='checked'/> " + this.file + "</label><br />";
h += "<label for='link-page'><input type='radio' name='link' id='link-page' value='page' /> " + this.page + "</label><br />";
var checkedLink = 'link-file';
h += "<tr><th>" + this.link + "</th><td>";
h += "<label for='link-file'><input type='radio' name='link' id='link-file' value='file' /> " + this.file + "</label><br />"; h += "<label for='link-page'><input type='radio' name='link' id='link-page' value='page' /> " + this.page + "</label><br />";
h += "<label for='link-none'><input type='radio' name='link' id='link-none' value='none' /> " + this.none + "</label>";
h += "</td></tr>";
@ -146,7 +178,12 @@ addLoadEvent( function() {
h += "</div>";
jQuery(h).prependTo('#upload-content');
jQuery('#' + checked).attr('checked','checked');
jQuery("input[@name='display']").each(theFileList.assignCookieOnChange);
jQuery("input[@name='link']").each(theFileList.assignCookieOnChange);
checkedDisplay = this.checkCookieSetting('display', checkedDisplay);
checkedLink = this.checkCookieSetting('link', checkedLink);
jQuery('#' + checkedDisplay).attr('checked','checked');
jQuery('#' + checkedLink).attr('checked','checked');
if (e) return e.stopPropagation();
return false;
},