Load tinyMCE on post editor only if needed.

This commit is contained in:
Fabio Comuni 2011-07-20 11:08:42 +02:00
parent 11d1d309c2
commit 7a069c1438
5 changed files with 98 additions and 67 deletions

View file

@ -80,7 +80,9 @@ function editpost_content(&$a) {
call_hooks('jot_tool', $jotplugins);
call_hooks('jot_networks', $jotnets);
$tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins));
//$tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins));
$o .= replace_macros($tpl,array(
'$return_path' => $_SESSION['return_url'],
@ -110,10 +112,10 @@ function editpost_content(&$a) {
'$lockstate' => $lockstate,
'$acl' => '', // populate_acl((($group) ? $group_acl : $a->user), $celeb),
'$bang' => (($group) ? '!' : ''),
'$profile_uid' => $_SESSION['uid']
'$profile_uid' => $_SESSION['uid'],
'$jotplugins' => $jotplugins,
));
return $o;
}

View file

@ -1,68 +1,79 @@
<script language="javascript" type="text/javascript">
var editor;
var editor=false;
var textlen = 0;
function initEditor(){
$("#profile-jot-text-loading").show();
tinyMCE.init({
theme : "advanced",
mode : "specific_textareas",
editor_selector: /(profile-jot-text|prvmail-text)/,
plugins : "bbcode,paste,autoresize",
theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "center",
theme_advanced_blockformats : "blockquote,code",
paste_text_sticky : true,
entity_encoding : "raw",
add_unload_trigger : false,
remove_linebreaks : false,
force_p_newlines : false,
force_br_newlines : true,
forced_root_block : '',
convert_urls: false,
content_css: "$baseurl/view/custom_tinymce.css",
theme_advanced_path : false,
setup : function(ed) {
//Character count
ed.onKeyUp.add(function(ed, e) {
var txt = tinyMCE.activeEditor.getContent();
textlen = txt.length;
if(textlen != 0 && $('#jot-perms-icon').is('.unlock')) {
$('#profile-jot-desc').html(ispublic);
}
else {
$('#profile-jot-desc').html('&nbsp;');
}
tinyMCE.init({
theme : "advanced",
mode : "specific_textareas",
editor_selector: /(profile-jot-text|prvmail-text)/,
plugins : "bbcode,paste,autoresize",
theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "center",
theme_advanced_blockformats : "blockquote,code",
paste_text_sticky : true,
entity_encoding : "raw",
add_unload_trigger : false,
remove_linebreaks : false,
force_p_newlines : false,
force_br_newlines : true,
forced_root_block : '',
convert_urls: false,
content_css: "$baseurl/view/custom_tinymce.css",
theme_advanced_path : false,
setup : function(ed) {
//Character count
ed.onKeyUp.add(function(ed, e) {
var txt = tinyMCE.activeEditor.getContent();
textlen = txt.length;
if(textlen != 0 && $('#jot-perms-icon').is('.unlock')) {
$('#profile-jot-desc').html(ispublic);
}
else {
$('#profile-jot-desc').html('&nbsp;');
}
if(textlen <= 140) {
$('#character-counter').removeClass('red');
$('#character-counter').removeClass('orange');
$('#character-counter').addClass('grey');
}
if((textlen > 140) && (textlen <= 420)) {
$('#character-counter').removeClass('grey');
$('#character-counter').removeClass('red');
$('#character-counter').addClass('orange');
}
if(textlen > 420) {
$('#character-counter').removeClass('grey');
$('#character-counter').removeClass('orange');
$('#character-counter').addClass('red');
}
$('#character-counter').text(textlen);
});
if(textlen <= 140) {
$('#character-counter').removeClass('red');
$('#character-counter').removeClass('orange');
$('#character-counter').addClass('grey');
}
if((textlen > 140) && (textlen <= 420)) {
$('#character-counter').removeClass('grey');
$('#character-counter').removeClass('red');
$('#character-counter').addClass('orange');
}
if(textlen > 420) {
$('#character-counter').removeClass('grey');
$('#character-counter').removeClass('orange');
$('#character-counter').addClass('red');
}
$('#character-counter').text(textlen);
});
ed.onInit.add(function(ed) {
ed.pasteAsPlainText = true;
$("#profile-jot-text-loading").hide();
$("#profile-jot-submit-wrapper").show();
});
ed.onInit.add(function(ed) {
ed.pasteAsPlainText = true;
});
}
});
}
});
editor = true;
// setup acl popup
$("#profile-jot-acl-wrapper").hide();
$("a#jot-perms-icon").fancybox({
'transitionIn' : 'none',
'transitionOut' : 'none'
});
}
</script>
<script type="text/javascript" src="include/ajaxupload.js" ></script>
@ -70,12 +81,14 @@ tinyMCE.init({
var ispublic = '$ispublic';
$(document).ready(function() {
$("#profile-jot-acl-wrapper").hide();
$("a#jot-perms-icon").fancybox({
'transitionIn' : 'none',
'transitionOut' : 'none'
/* enable tinymce on focus */
$("#profile-jot-text").focus(function(){
if (editor) return;
$(this).val("");
initEditor();
});
var uploader = new window.AjaxUpload(
'wall-image-upload',
{ action: 'wall_upload/$nickname',

View file

@ -15,10 +15,12 @@
<input type="hidden" name="title" id="jot-title" value="" />
<input type="hidden" name="post_id" value="$post_id" />
<textarea rows="5" cols="64" class="profile-jot-text" id="profile-jot-text" name="body" >$content</textarea>
<img id="profile-jot-text-loading" src="images/rotator.gif" alt="$wait" title="$wait" style="display: none;" />
<textarea rows="5" cols="64" class="profile-jot-text" id="profile-jot-text" name="body" >{{ if $content }}$content{{ else }}$share{{ endif }}</textarea>
{{ if $content }}<script>initEditor();</script>{{ endif }}
<div id="profile-jot-submit-wrapper" >
<div id="profile-jot-submit-wrapper" style="display:none">
<input type="submit" id="profile-jot-submit" name="submit" value="$share" />
<div id="profile-upload-wrapper" style="display: $visitor;" >
<div id="wall-image-upload-div" ><a href="#" onclick="return false;" id="wall-image-upload" class="icon camera" title="$upload"></a></div>

View file

@ -1483,6 +1483,13 @@ input#dfrn-url {
width: 180px;
}
#profile-jot-text {
height: 20px;
color:#cccccc;
border: 1px solid #cccccc;
}
/** acl **/
#profile-jot-acl-wrapper{

View file

@ -1561,6 +1561,13 @@ padding: 5px 10px 0px;
overflow: auto;
}
#profile-jot-text {
height: 20px;
color:#cccccc;
border: 1px solid #cccccc;
}
/** acl **/
#profile-jot-acl-wrapper{
display:block!important;