mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-03-31 18:54:29 +00:00
Saving/restoring the user interface state, see #7654
git-svn-id: https://develop.svn.wordpress.org/trunk@8784 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -486,7 +486,7 @@ endif; ?>
|
||||
|
||||
<div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea">
|
||||
|
||||
<div id="add-media-button"><a href="<?php echo clean_url( admin_url( 'media-upload.php?post_id=' . ( $post_ID ? $post_ID : $temp_ID ) . '&type=image&TB_iframe=true' ) ); ?>" class="thickbox button"><?php _e( 'Add Media' ); ?></a></div>
|
||||
<div id="add-media-button"><a id="add-media-link" href="<?php echo clean_url( admin_url( 'media-upload.php?post_id=' . ( $post_ID ? $post_ID : $temp_ID ) . '&type=image&TB_iframe=true' ) ); ?>" class="thickbox button"><?php _e( 'Add Media' ); ?></a></div>
|
||||
|
||||
<h3><?php _e('Post') ?></h3>
|
||||
|
||||
|
||||
@@ -358,7 +358,7 @@ endif; ?>
|
||||
|
||||
<div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea">
|
||||
|
||||
<div id="add-media-button"><a href="<?php echo clean_url( admin_url( 'media-upload.php?post_id=' . ( $post_ID ? $post_ID : $temp_ID ) . '&type=image&TB_iframe=true' ) ); ?>" class="thickbox button"><?php _e( 'Add Media' ); ?></a></div>
|
||||
<div id="add-media-button"><a id="add-media-link" href="<?php echo clean_url( admin_url( 'media-upload.php?post_id=' . ( $post_ID ? $post_ID : $temp_ID ) . '&type=image&TB_iframe=true' ) ); ?>" class="thickbox button"><?php _e( 'Add Media' ); ?></a></div>
|
||||
|
||||
<h3><?php _e('Page') ?></h3>
|
||||
<?php the_editor($post->post_content); ?>
|
||||
|
||||
@@ -1,24 +1,31 @@
|
||||
wpEditorInit = function() {
|
||||
var H;
|
||||
|
||||
// Activate tinyMCE if it's the user's default editor
|
||||
if ( ( 'undefined' == typeof wpTinyMCEConfig ) || 'tinymce' == wpTinyMCEConfig.defaultEditor ) {
|
||||
try { document.getElementById('editorcontainer').style.padding = '0px'; } catch(e){};
|
||||
try { document.getElementById("quicktags").style.display = "none"; } catch(e){};
|
||||
tinyMCE.execCommand("mceAddControl", false, "content");
|
||||
} else {
|
||||
if ( H = tinymce.util.Cookie.getHash("TinyMCE_content_size") )
|
||||
try { document.getElementById('content').style.height = H.ch - 30 + 'px'; } catch(e){};
|
||||
}
|
||||
};
|
||||
|
||||
switchEditors = {
|
||||
|
||||
I : function(e) {
|
||||
return document.getElementById(e);
|
||||
},
|
||||
|
||||
edInit : function() {
|
||||
var h = tinymce.util.Cookie.getHash("TinyMCE_content_size"), H = this.I('edButtonHTML'), P = this.I('edButtonPreview');
|
||||
|
||||
// Activate TinyMCE if it's the user's default editor
|
||||
if ( getUserSetting( 'editor', 'tinymce' ) == 'tinymce' ) {
|
||||
try { P.onclick = ''; P.className = 'active'; } catch(e){};
|
||||
try { this.I('editorcontainer').style.padding = '0px'; } catch(e){};
|
||||
try { this.I("quicktags").style.display = "none"; } catch(e){};
|
||||
tinyMCE.execCommand("mceAddControl", false, "content");
|
||||
} else {
|
||||
try { H.onclick = ''; H.className = 'active'; } catch(e){};
|
||||
if ( h )
|
||||
try { this.I('content').style.height = h.ch - 30 + 'px'; } catch(e){};
|
||||
}
|
||||
},
|
||||
|
||||
saveCallback : function(el, content, body) {
|
||||
|
||||
document.getElementById(el).style.color = '#fff';
|
||||
this.I(el).style.color = '#fff';
|
||||
if ( tinyMCE.activeEditor.isHidden() )
|
||||
content = document.getElementById(el).value;
|
||||
content = this.I(el).value;
|
||||
else
|
||||
content = this.pre_wpautop(content);
|
||||
|
||||
@@ -84,11 +91,11 @@ switchEditors = {
|
||||
|
||||
go : function(id) {
|
||||
var ed = tinyMCE.get(id);
|
||||
var qt = document.getElementById('quicktags');
|
||||
var H = document.getElementById('edButtonHTML');
|
||||
var P = document.getElementById('edButtonPreview');
|
||||
var ta = document.getElementById(id);
|
||||
var ec = document.getElementById('editorcontainer');
|
||||
var qt = this.I('quicktags');
|
||||
var H = this.I('edButtonHTML');
|
||||
var P = this.I('edButtonPreview');
|
||||
var ta = this.I(id);
|
||||
var ec = (ta.parentNode && ta.parentNode.nodeName == 'DIV') ? ta.parentNode : '';
|
||||
|
||||
if ( ! ed || ed.isHidden() ) {
|
||||
ta.style.color = '#fff';
|
||||
@@ -97,15 +104,16 @@ switchEditors = {
|
||||
edCloseAllTags(); // :-(
|
||||
|
||||
qt.style.display = 'none';
|
||||
ec.style.padding = '0px';
|
||||
ta.style.padding = '0px';
|
||||
if ( ec )
|
||||
ec.style.padding = '0px';
|
||||
|
||||
ta.value = this.wpautop(ta.value);
|
||||
|
||||
if ( ed ) ed.show();
|
||||
else tinyMCE.execCommand("mceAddControl", false, id);
|
||||
|
||||
this.wpSetDefaultEditor('tinymce');
|
||||
setUserSetting( 'editor', 'tinymce' );
|
||||
} else {
|
||||
this.edToggle(H, P);
|
||||
ta.style.height = ed.getContentAreaContainer().offsetHeight + 6 + 'px';
|
||||
@@ -115,15 +123,17 @@ switchEditors = {
|
||||
|
||||
if ( tinymce.isIE6 ) {
|
||||
ta.style.width = '98%';
|
||||
ec.style.padding = '0px';
|
||||
if ( ec )
|
||||
ec.style.padding = '0px';
|
||||
ta.style.padding = '6px';
|
||||
} else {
|
||||
ta.style.width = '100%';
|
||||
ec.style.padding = '6px';
|
||||
if ( ec )
|
||||
ec.style.padding = '6px';
|
||||
}
|
||||
|
||||
ta.style.color = '';
|
||||
this.wpSetDefaultEditor('html');
|
||||
setUserSetting( 'editor', 'html' );
|
||||
}
|
||||
},
|
||||
|
||||
@@ -135,19 +145,6 @@ switchEditors = {
|
||||
A.onclick = null;
|
||||
},
|
||||
|
||||
wpSetDefaultEditor : function(editor) {
|
||||
try {
|
||||
editor = escape( editor.toString() );
|
||||
} catch(err) {
|
||||
editor = 'tinymce';
|
||||
}
|
||||
|
||||
var userID = document.getElementById('user-id');
|
||||
var date = new Date();
|
||||
date.setTime(date.getTime()+(10*365*24*60*60*1000));
|
||||
document.cookie = "wordpress_editor_" + userID.value + "=" + editor + "; expires=" + date.toGMTString();
|
||||
},
|
||||
|
||||
wpautop : function(pee) {
|
||||
var blocklist = 'table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6]';
|
||||
|
||||
|
||||
129
wp-admin/js/user-settings.js
Normal file
129
wp-admin/js/user-settings.js
Normal file
@@ -0,0 +1,129 @@
|
||||
|
||||
wpCookies = {
|
||||
// The following functions are from Cookie.js class in TinyMCE, Moxiecode, used under LGPL.
|
||||
|
||||
each : function(o, cb, s) {
|
||||
var n, l;
|
||||
|
||||
if (!o)
|
||||
return 0;
|
||||
|
||||
s = s || o;
|
||||
|
||||
if (typeof(o.length) != 'undefined') {
|
||||
for (n=0, l = o.length; n<l; n++) {
|
||||
if (cb.call(s, o[n], n, o) === false)
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
for (n in o) {
|
||||
if (o.hasOwnProperty(n)) {
|
||||
if (cb.call(s, o[n], n, o) === false)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
},
|
||||
|
||||
getHash : function(n) {
|
||||
var v = this.get(n), h;
|
||||
|
||||
if (v) {
|
||||
this.each(v.split('&'), function(v) {
|
||||
v = v.split('=');
|
||||
h = h || {};
|
||||
h[v[0]] = v[1];
|
||||
});
|
||||
}
|
||||
return h;
|
||||
},
|
||||
|
||||
setHash : function(n, v, e, p, d, s) {
|
||||
var o = '';
|
||||
|
||||
this.each(v, function(v, k) {
|
||||
o += (!o ? '' : '&') + k + '=' + v;
|
||||
});
|
||||
|
||||
this.set(n, o, e, p, d, s);
|
||||
},
|
||||
|
||||
get : function(n) {
|
||||
var c = document.cookie, e, p = n + "=", b;
|
||||
|
||||
if (!c)
|
||||
return;
|
||||
|
||||
b = c.indexOf("; " + p);
|
||||
|
||||
if (b == -1) {
|
||||
b = c.indexOf(p);
|
||||
|
||||
if (b != 0)
|
||||
return null;
|
||||
} else
|
||||
b += 2;
|
||||
|
||||
e = c.indexOf(";", b);
|
||||
|
||||
if (e == -1)
|
||||
e = c.length;
|
||||
|
||||
return decodeURIComponent(c.substring(b + p.length, e));
|
||||
},
|
||||
|
||||
set : function(n, v, e, p, d, s) {
|
||||
document.cookie = n + "=" + encodeURIComponent(v) +
|
||||
((e) ? "; expires=" + e.toGMTString() : "") +
|
||||
((p) ? "; path=" + p : "") +
|
||||
((d) ? "; domain=" + d : "") +
|
||||
((s) ? "; secure" : "");
|
||||
},
|
||||
|
||||
remove : function(n, p) {
|
||||
var d = new Date();
|
||||
|
||||
d.setTime(d.getTime() - 1000);
|
||||
|
||||
this.set(n, '', d, p, d);
|
||||
}
|
||||
};
|
||||
|
||||
// Returns the value as string. Second arg or empty string is returned when value is not set.
|
||||
function getUserSetting( name, def ) {
|
||||
var o = getAllUserSettings();
|
||||
|
||||
if ( o.hasOwnProperty(name) )
|
||||
return o[name];
|
||||
|
||||
if ( typeof def != 'undefined' )
|
||||
return def;
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
// Both name and value must be only ASCII letters, numbers or underscore
|
||||
// and the shorter, the better (cookies can store maximum 4KB). Not suitable to store text.
|
||||
function setUserSetting( name, value, del ) {
|
||||
var c = 'wp-settings-'+userSettings.uid, o = wpCookies.getHash(c) || {}, d = new Date();
|
||||
var n = name.toString().replace(/[^A-Za-z0-9_]/, ''), v = value.toString().replace(/[^A-Za-z0-9_]/, '');
|
||||
|
||||
if ( del ) delete o[n];
|
||||
else o[n] = v;
|
||||
|
||||
d.setTime( d.getTime() + 31536000000 );
|
||||
p = userSettings.url;
|
||||
|
||||
wpCookies.setHash(c, o, d, p );
|
||||
wpCookies.set('wp-settings-time-'+userSettings.uid, userSettings.time, d, p );
|
||||
}
|
||||
|
||||
function deleteUserSetting( name ) {
|
||||
setUserSetting( name, '', 1 );
|
||||
}
|
||||
|
||||
// Returns all settings as js object.
|
||||
function getAllUserSettings() {
|
||||
return wpCookies.getHash('wp-settings-'+userSettings.uid) || {};
|
||||
}
|
||||
Reference in New Issue
Block a user