Concatenated and compressed versions of the default TinyMCE scripts

git-svn-id: http://svn.automattic.com/wordpress/trunk@10369 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2009-01-16 12:58:38 +00:00
parent bc2485eed1
commit 5ce5238272
6 changed files with 91 additions and 255 deletions

View File

@ -38,7 +38,7 @@ var pagenow = '<?php echo substr($pagenow, 0, -4); ?>';
<?php
if ( in_array( $pagenow, array('post.php', 'post-new.php', 'page.php', 'page-new.php') ) ) {
add_action( 'admin_footer', 'wp_tiny_mce' );
add_action( 'admin_print_footer_scripts', 'wp_tiny_mce', 25 );
wp_enqueue_script('quicktags');
}

View File

@ -1113,6 +1113,8 @@ function post_preview() {
* @since 2.7
*/
function wp_tiny_mce( $teeny = false ) {
global $concatenate_scripts, $compress_scripts;
if ( ! user_can_richedit() )
return;
@ -1143,7 +1145,7 @@ function wp_tiny_mce( $teeny = false ) {
*/
$mce_external_plugins = apply_filters('mce_external_plugins', array());
$ext_plugins = "\n";
$ext_plugins = '';
if ( ! empty($mce_external_plugins) ) {
/*
@ -1285,9 +1287,12 @@ function wp_tiny_mce( $teeny = false ) {
$initArray = apply_filters('tiny_mce_before_init', $initArray);
}
$language = $initArray['language'];
if ( ! isset($concatenate_scripts) )
script_concat_settings();
$ver = apply_filters('tiny_mce_version', '3101');
$language = $initArray['language'];
$zip = $compress_scripts ? 1 : 0;
$ver = apply_filters('tiny_mce_version', '3211');
if ( 'en' != $language )
include_once(ABSPATH . WPINC . '/js/tinymce/langs/wp-langs.php');
@ -1305,50 +1310,32 @@ tinyMCEPreInit = {
suffix : "",
query : "ver=<?php echo $ver; ?>",
mceInit : {<?php echo $mce_options; ?>},
go : function() {
var t = this, sl = tinymce.ScriptLoader, ln = t.mceInit.language, th = t.mceInit.theme, pl = t.mceInit.plugins;
sl.markDone(t.base + '/langs/' + ln + '.js');
sl.markDone(t.base + '/themes/' + th + '/langs/' + ln + '.js');
sl.markDone(t.base + '/themes/' + th + '/langs/' + ln + '_dlg.js');
tinymce.each(pl.split(','), function(n) {
if (n && n.charAt(0) != '-') {
sl.markDone(t.base + '/plugins/' + n + '/langs/' + ln + '.js');
sl.markDone(t.base + '/plugins/' + n + '/langs/' + ln + '_dlg.js');
}
});
},
load_ext : function(url,lang) {
var sl = tinymce.ScriptLoader;
sl.markDone(url + '/langs/' + lang + '.js');
sl.markDone(url + '/langs/' + lang + '_dlg.js');
}
load_ext : function(url,lang){var sl=tinymce.ScriptLoader;sl.markDone(url+'/langs/'+lang+'.js');sl.markDone(url+'/langs/'+lang+'_dlg.js');}
};
/* ]]> */
</script>
<script type="text/javascript" src="<?php echo $baseurl; ?>/tiny_mce.js?ver=<?php echo $ver; ?>"></script>
<?php if ( 'en' != $language && isset($lang) ) { ?>
<script type="text/javascript">
<?php echo $lang; ?>
</script>
<?php } else { ?>
<script type="text/javascript" src="<?php echo $baseurl; ?>/langs/wp-langs-en.js?ver=<?php echo $ver; ?>"></script>
<?php } ?>
<script type="text/javascript">
<?php if ( $ext_plugins ) echo $ext_plugins; ?>
// Mark translations as done
tinyMCEPreInit.go();
// Init
tinyMCE.init(tinyMCEPreInit.mceInit);
</script>
<?php
if ( $concatenate_scripts ) {
echo "<script type='text/javascript' src='$baseurl/wp-tinymce.php?c=$zip&amp;ver=$ver'></script>";
} else {
echo "<script type='text/javascript' src='$baseurl/tiny_mce.js?ver=$ver'></script>";
if ( 'en' != $language && isset($lang) )
echo "<script type='text/javascript'>\n$lang\n</script>";
else
echo "<script type='text/javascript' src='$baseurl/langs/wp-langs-en.js?ver=$ver'></script>";
}
?>
<script type="text/javascript">
<?php if ( $ext_plugins ) echo $ext_plugins; ?>
<?php if ( $concatenate_scripts ) { ?>
tinyMCEPreInit.go();
<?php } else { ?>
(function(){var t=tinyMCEPreInit,sl=tinymce.ScriptLoader,ln=t.mceInit.language,th=t.mceInit.theme,pl=t.mceInit.plugins;sl.markDone(t.base+'/langs/'+ln+'.js');sl.markDone(t.base+'/themes/'+th+'/langs/'+ln+'.js');sl.markDone(t.base+'/themes/'+th+'/langs/'+ln+'_dlg.js');tinymce.each(pl.split(','),function(n){if(n&&n.charAt(0)!='-'){sl.markDone(t.base+'/plugins/'+n+'/langs/'+ln+'.js');sl.markDone(t.base+'/plugins/'+n+'/langs/'+ln+'_dlg.js');}});})();
<?php } ?>
tinyMCE.init(tinyMCEPreInit.mceInit);
</script>
<?php
}
?>

View File

@ -1,210 +0,0 @@
/**
* $Id: mclayer.js 520 2008-01-07 16:30:32Z spocke $
*
* Moxiecode floating layer script.
*
* @author Moxiecode
* @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
*/
function MCLayer(id) {
this.id = id;
this.settings = new Array();
this.blockerElement = null;
this.isMSIE = navigator.appName == "Microsoft Internet Explorer";
this.events = false;
this.autoHideCallback = null;
}
MCLayer.prototype = {
moveRelativeTo : function(re, p, a) {
var rep = this.getAbsPosition(re);
var w = parseInt(re.offsetWidth);
var h = parseInt(re.offsetHeight);
var x, y;
switch (p) {
case "tl":
break;
case "tr":
x = rep.absLeft + w;
y = rep.absTop;
break;
case "bl":
break;
case "br":
break;
}
this.moveTo(x, y);
},
moveBy : function(dx, dy) {
var e = this.getElement();
var x = parseInt(e.style.left);
var y = parseInt(e.style.top);
e.style.left = (x + dx) + "px";
e.style.top = (y + dy) + "px";
this.updateBlocker();
},
moveTo : function(x, y) {
var e = this.getElement();
e.style.left = x + "px";
e.style.top = y + "px";
this.updateBlocker();
},
show : function() {
MCLayer.visibleLayer = this;
this.getElement().style.display = 'block';
this.updateBlocker();
},
hide : function() {
this.getElement().style.display = 'none';
this.updateBlocker();
},
setAutoHide : function(s, cb) {
this.autoHideCallback = cb;
this.registerEventHandlers();
},
getElement : function() {
return document.getElementById(this.id);
},
updateBlocker : function() {
if (!this.isMSIE)
return;
var e = this.getElement();
var b = this.getBlocker();
var x = this.parseInt(e.style.left);
var y = this.parseInt(e.style.top);
var w = this.parseInt(e.offsetWidth);
var h = this.parseInt(e.offsetHeight);
b.style.left = x + 'px';
b.style.top = y + 'px';
b.style.width = w + 'px';
b.style.height = h + 'px';
b.style.display = e.style.display;
},
getBlocker : function() {
if (!this.blockerElement) {
var d = document, b = d.createElement("iframe");
b.style.cssText = 'display: none; left: 0px; position: absolute; top: 0';
b.src = 'javascript:false;';
b.frameBorder = '0';
b.scrolling = 'no';
d.body.appendChild(b);
this.blockerElement = b;
}
return this.blockerElement;
},
getAbsPosition : function(n) {
var p = {absLeft : 0, absTop : 0};
while (n) {
p.absLeft += n.offsetLeft;
p.absTop += n.offsetTop;
n = n.offsetParent;
}
return p;
},
registerEventHandlers : function() {
if (!this.events) {
var d = document;
this.addEvent(d, 'mousedown', MCLayer.prototype.onMouseDown);
this.events = true;
}
},
addEvent : function(o, n, h) {
if (o.attachEvent)
o.attachEvent("on" + n, h);
else
o.addEventListener(n, h, false);
},
onMouseDown : function(e) {
e = typeof(e) == "undefined" ? window.event : e;
var b = document.body;
var l = MCLayer.visibleLayer;
if (l) {
var mx = l.isMSIE ? e.clientX + b.scrollLeft : e.pageX;
var my = l.isMSIE ? e.clientY + b.scrollTop : e.pageY;
var el = l.getElement();
var x = parseInt(el.style.left);
var y = parseInt(el.style.top);
var w = parseInt(el.offsetWidth);
var h = parseInt(el.offsetHeight);
if (!(mx > x && mx < x + w && my > y && my < y + h)) {
MCLayer.visibleLayer = null;
if (l.autoHideCallback && l.autoHideCallback(l, e, mx, my))
return true;
l.hide();
}
}
},
addCSSClass : function(e, c) {
this.removeCSSClass(e, c);
var a = this.explode(' ', e.className);
a[a.length] = c;
e.className = a.join(' ');
},
removeCSSClass : function(e, c) {
var a = this.explode(' ', e.className), i;
for (i=0; i<a.length; i++) {
if (a[i] == c)
a[i] = '';
}
e.className = a.join(' ');
},
explode : function(d, s) {
var ar = s.split(d);
var oar = new Array();
for (var i = 0; i<ar.length; i++) {
if (ar[i] != "")
oar[oar.length] = ar[i];
}
return oar;
},
parseInt : function(s) {
if (s == null || s == '')
return 0;
return parseInt(s);
}
}

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -0,0 +1,29 @@
<?php
while ( @ob_end_clean() );
function get_file($path) {
if ( function_exists('realpath') )
$path = realpath($path);
if ( ! $path || ! @is_file($path) )
return '';
return @file_get_contents($path);
}
$expires_offset = 31536000;
header('Content-Type: application/x-javascript; charset=UTF-8');
header('Vary: Accept-Encoding'); // Handle proxies
header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT');
header("Cache-Control: public, max-age=$expires_offset");
if ( isset($_GET['c']) && 1 == $_GET['c'] && ! ini_get('zlib.output_compression') && false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') ) {
header('Content-Encoding: gzip');
echo get_file('wp-tinymce.js.gz');
} else {
echo get_file('wp-tinymce.js');
}
exit;