Version 3.1.4
This commit is contained in:
1 parent
1d4720f3e2
commit
ae5c01cc78
2563 files changed
+283048
-240689
No files matched your search
+198
-40
@@ -25,11 +25,16 @@ _editor_rte = Class.create({
|
||||
{
|
||||
},
|
||||
editor_write_contents: function( text, do_init )
|
||||
{
|
||||
if ( text.blank() && Prototype.Browser.Gecko )
|
||||
{
|
||||
|
||||
if ( ( Object.isUndefined(text) || text === false || text.blank() ) && Prototype.Browser.Gecko )
|
||||
{
|
||||
text = '<br />';
|
||||
}
|
||||
else if ( Object.isUndefined(text) || text === false )
|
||||
{
|
||||
text = '';
|
||||
}
|
||||
|
||||
if ( this.editor_document && this.editor_document.initialized )
|
||||
{
|
||||
@@ -106,7 +111,7 @@ _editor_rte = Class.create({
|
||||
else
|
||||
{
|
||||
// Bug #17772
|
||||
if( !Object.isUndefined( init_text ) )
|
||||
if( !Object.isUndefined( init_text ) && init_text != false )
|
||||
{
|
||||
init_text = init_text.replace( /§/g, "&sect");
|
||||
}
|
||||
@@ -150,12 +155,35 @@ _editor_rte = Class.create({
|
||||
this.editor_window = this.editor_box.contentWindow;
|
||||
this.editor_document = this.editor_window.document;
|
||||
|
||||
this.editor_write_contents( (Object.isUndefined( init_text ) || ! init_text ? this.items['text_obj'].value : init_text), true );
|
||||
|
||||
if ( ! this.items['text_obj'].value && ( init_text === false || Object.isUndefined( init_text ) ) )
|
||||
{
|
||||
/* Wipe editor */
|
||||
this.editor_write_contents(false, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.editor_write_contents( (Object.isUndefined( init_text ) || ! init_text ? this.items['text_obj'].value : init_text), true );
|
||||
}
|
||||
|
||||
this.editor_document.editor_id = this.editor_id;
|
||||
this.editor_window.editor_id = this.editor_id;
|
||||
this.editor_window.has_focus = false;
|
||||
|
||||
// Go on.. cursor, flash you bastard
|
||||
try
|
||||
{
|
||||
Debug.write( "Attempt to get focus" );
|
||||
this.editor_check_focus();
|
||||
|
||||
// Sometimes moves the focus to the RTE
|
||||
this.editor_document.execCommand("InsertHorizontalRule", false, null);
|
||||
this.editor_document.execCommand("undo" , false, null);
|
||||
}
|
||||
catch(error)
|
||||
{
|
||||
Debug.write( "#011 " + error );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Kill tags
|
||||
//-----------------------------------------
|
||||
@@ -206,14 +234,20 @@ _editor_rte = Class.create({
|
||||
}
|
||||
|
||||
this.editor_document.execCommand( cmd, dialog, argument );
|
||||
|
||||
this._ie_cache = null;
|
||||
return false;
|
||||
},
|
||||
/* ! get_selection */
|
||||
get_selection: function()
|
||||
{
|
||||
var rng = this._ie_cache ? this._ie_cache : this.editor_document.selection.createRange();
|
||||
|
||||
//Debug.write( 'get selection: ie_cache:' + this._ie_cache.htmlText + '.' );
|
||||
|
||||
if ( rng.htmlText )
|
||||
{
|
||||
Debug.write( 'htmlTest:' + rng.htmlText + '.' );
|
||||
return rng.htmlText;
|
||||
}
|
||||
else
|
||||
@@ -377,10 +411,10 @@ _editor_rte = Class.create({
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/* ! insert_text */
|
||||
insert_text: function(text)
|
||||
{
|
||||
//Debug.write( this.editor_document );
|
||||
Debug.write( "Inserting " + text + "." );
|
||||
this.editor_check_focus();
|
||||
|
||||
if ( typeof( this.editor_document.selection ) != 'undefined'
|
||||
@@ -390,28 +424,24 @@ _editor_rte = Class.create({
|
||||
this.editor_document.selection.clear();
|
||||
}
|
||||
|
||||
/*if( this.get_selection() ){
|
||||
var sel = this._ie_cache;
|
||||
} else {
|
||||
var sel = this.editor_document.selection.createRange();
|
||||
}*/
|
||||
|
||||
var sel = this._ie_cache ? this._ie_cache : this.editor_document.selection.createRange();
|
||||
|
||||
sel.pasteHTML(text);
|
||||
sel.select();
|
||||
this._ie_cache = null;
|
||||
},
|
||||
|
||||
/* ! insert_emoticon */
|
||||
insert_emoticon: function( emo_id, emo_image, emo_code, event )
|
||||
{
|
||||
Debug.write( "Adding emoticon " + emo_code );
|
||||
|
||||
try
|
||||
{
|
||||
//this._ie_cache = null;
|
||||
// INIT
|
||||
var _emo_url = ipb.vars['emoticon_url'] + "/" + emo_image;
|
||||
var _emo_html = ' <img src="' + _emo_url + '" class="bbc_emoticon" alt="' + this.unhtmlspecialchars( emo_code ) + '" />';
|
||||
|
||||
this.wrap_tags_lite( " " + _emo_html, " ");
|
||||
this.wrap_tags_lite( " " + _emo_html, " ", false);
|
||||
}
|
||||
catch( error )
|
||||
{
|
||||
@@ -493,6 +523,13 @@ _editor_rte = Class.create({
|
||||
{
|
||||
Debug.write("Updating for submit");
|
||||
this.items['text_obj'].value = this.editor_get_contents();
|
||||
Debug.write( "Before: " + this.items['text_obj'].value );
|
||||
// IE does crappy things. </3
|
||||
if ( Prototype.Browser.IE )
|
||||
{
|
||||
this.items['text_obj'].value = this.items['text_obj'].value.replace( / /g, ' ' );
|
||||
this.items['text_obj'].value = this.items['text_obj'].value.replace( /\s+?$/, '' );
|
||||
}
|
||||
|
||||
// http://trac.webkit.org/changeset/47640
|
||||
// Safari bug with execcommand and underline + strikethrough
|
||||
@@ -501,7 +538,7 @@ _editor_rte = Class.create({
|
||||
this.items['text_obj'].value = this.items['text_obj'].value.replace( /<span class="Apple-style-span" style="text-decoration: underline;">([^>]*)<\/span>/gi, "<u>$1</u>" );
|
||||
this.items['text_obj'].value = this.items['text_obj'].value.replace( /<span class="Apple-style-span" style="text-decoration: line-through;">([^>]*)<\/span>/gi, "<strike>$1</strike>" );
|
||||
}
|
||||
|
||||
Debug.write( "After: " + this.items['text_obj'].value );
|
||||
return true;
|
||||
}
|
||||
});
|
||||
@@ -528,8 +565,8 @@ _editor_std = Class.create({
|
||||
this.editor_window = this.items['text_obj'];
|
||||
this.editor_document = this.items['text_obj'];
|
||||
this.editor_box = this.items['text_obj'];
|
||||
|
||||
if( !Object.isUndefined( init_text ) )
|
||||
|
||||
if( !Object.isUndefined( init_text ) && init_text !== false )
|
||||
{
|
||||
this.editor_write_contents( init_text );
|
||||
}
|
||||
@@ -564,7 +601,10 @@ _editor_std = Class.create({
|
||||
},
|
||||
editor_write_contents: function(text)
|
||||
{
|
||||
this.items['text_obj'].value = text;
|
||||
if ( text !== false )
|
||||
{
|
||||
this.items['text_obj'].value = text;
|
||||
}
|
||||
},
|
||||
editor_get_contents: function()
|
||||
{
|
||||
@@ -663,14 +703,14 @@ _editor_std = Class.create({
|
||||
//Debug.write('Set context');
|
||||
},
|
||||
get_selection: function()
|
||||
{
|
||||
if ( !Object.isUndefined( this.editor_document.selectionStart ) )
|
||||
{
|
||||
if ( !Object.isUndefined( this.editor_document.selectionStart ) )
|
||||
{
|
||||
return this.editor_document.value.substr(this.editor_document.selectionStart, this.editor_document.selectionEnd - this.editor_document.selectionStart);
|
||||
}
|
||||
else if ( ( document.selection && document.selection.createRange ) || this._ie_cache )
|
||||
{
|
||||
return this._ie_cache ? this._ie_cache.text : document.selection.createRange().text;
|
||||
return ( ! document.selection.createRange().text && this._ie_cache ) ? this._ie_cache.text : document.selection.createRange().text;
|
||||
}
|
||||
else if ( window.getSelection )
|
||||
{
|
||||
@@ -897,7 +937,7 @@ _editor_std = Class.create({
|
||||
// MAIN EDITOR CODE
|
||||
|
||||
if( USE_RTE ){//&& !Prototype.Browser.WebKit ){ // Dont support safari
|
||||
Debug.write("Extending with RTE")
|
||||
Debug.write("Extending with RTE");
|
||||
_type = _editor_rte;
|
||||
} else {
|
||||
Debug.write("Extending with STD");
|
||||
@@ -938,6 +978,7 @@ _editor.prototype.editor = Class.create(_type, {
|
||||
this.key_handlers = [];
|
||||
this.showing_sidebar = false;
|
||||
this.emoticons_loaded = false;
|
||||
this.emoClick = false;
|
||||
|
||||
this.options = Object.extend({
|
||||
file_path: '',
|
||||
@@ -947,7 +988,6 @@ _editor.prototype.editor = Class.create(_type, {
|
||||
button_update: []
|
||||
}, arguments[3] || {});
|
||||
|
||||
|
||||
this.button_update = $A( [ "bold", "italic", "underline", "justifyleft", "justifycenter",
|
||||
"justifyright", "insertorderedlist", "insertunorderedlist", "superscript", "subscript", "strikethrough" ].concat( this.options.button_update ) );
|
||||
|
||||
@@ -985,6 +1025,7 @@ _editor.prototype.editor = Class.create(_type, {
|
||||
|
||||
Debug.write("All editor initialization complete");
|
||||
},
|
||||
|
||||
/* ------------------------------ */
|
||||
/**
|
||||
* Initialization
|
||||
@@ -1111,7 +1152,7 @@ _editor.prototype.editor = Class.create(_type, {
|
||||
*/
|
||||
resize_to: function( size )
|
||||
{
|
||||
var afterFinish = function(){}
|
||||
var afterFinish = function(){};
|
||||
|
||||
// Bug #17799
|
||||
// Opera 10 wouldn't resize the emoticon pane when the editor resize buttons were used
|
||||
@@ -1162,9 +1203,30 @@ _editor.prototype.editor = Class.create(_type, {
|
||||
ips_frame_html += " background: #FFFFFF;\n";
|
||||
ips_frame_html += " margin: 0px;\n";
|
||||
ips_frame_html += " padding: 4px;\n";
|
||||
ips_frame_html += " font-family: Verdana, arial, sans-serif;\n";
|
||||
ips_frame_html += " font-family: arial, verdana, tahoma, sans-serif;\n";
|
||||
ips_frame_html += " font-size: 9pt;\n";
|
||||
ips_frame_html += "}\n";
|
||||
ips_frame_html += "font[size=\"1\"] {\n";
|
||||
ips_frame_html += " font-size: 9px;\n";
|
||||
ips_frame_html += "}\n";
|
||||
ips_frame_html += "font[size=\"2\"] {\n";
|
||||
ips_frame_html += " font-size: 13px;\n";
|
||||
ips_frame_html += "}\n";
|
||||
ips_frame_html += "font[size=\"3\"] {\n";
|
||||
ips_frame_html += " font-size: 15px;\n";
|
||||
ips_frame_html += "}\n";
|
||||
ips_frame_html += "font[size=\"4\"] {\n";
|
||||
ips_frame_html += " font-size: 17px;\n";
|
||||
ips_frame_html += "}\n";
|
||||
ips_frame_html += "font[size=\"5\"] {\n";
|
||||
ips_frame_html += " font-size: 21px;\n";
|
||||
ips_frame_html += "}\n";
|
||||
ips_frame_html += "font[size=\"6\"] {\n";
|
||||
ips_frame_html += " font-size: 26px;\n";
|
||||
ips_frame_html += "}\n";
|
||||
ips_frame_html += "font[size=\"7\"] {\n";
|
||||
ips_frame_html += " font-size: 36px;\n";
|
||||
ips_frame_html += "}\n";
|
||||
ips_frame_html += "</style>\n";
|
||||
|
||||
if( isRTL && rtlFull )
|
||||
@@ -1452,7 +1514,7 @@ _editor.prototype.editor = Class.create(_type, {
|
||||
|
||||
elem.insert( { after: wrap } );
|
||||
}
|
||||
|
||||
|
||||
// Init function for IE
|
||||
var beforeOpen = function( menu ){
|
||||
this.editor_check_focus();
|
||||
@@ -1507,7 +1569,7 @@ _editor.prototype.editor = Class.create(_type, {
|
||||
}
|
||||
|
||||
td = new Element('td', { id: this.id + '_' + elem.readAttribute('cmd') + '_color_' + color } );
|
||||
td.setStyle('background-color: #' + color).writeAttribute('colorname', color);
|
||||
td.setStyle('background-color: #' + color).setStyle('background-image: none').writeAttribute('colorname', color);
|
||||
|
||||
tr.insert( td );
|
||||
|
||||
@@ -1920,6 +1982,7 @@ _editor.prototype.editor = Class.create(_type, {
|
||||
|
||||
return false;
|
||||
},
|
||||
/* ! wrap_tags_lite */
|
||||
wrap_tags_lite: function( start_text, close_text, replace_selection )
|
||||
{
|
||||
selected_text = '';
|
||||
@@ -1935,11 +1998,15 @@ _editor.prototype.editor = Class.create(_type, {
|
||||
|
||||
return false;
|
||||
},
|
||||
/* ! preserve_ie_range */
|
||||
preserve_ie_range: function()
|
||||
{
|
||||
if ( Prototype.Browser.IE && document.selection )
|
||||
if ( Prototype.Browser.IE && document.selection && ! this.emoClick )
|
||||
{
|
||||
this._ie_cache = this.is_rte ? this.editor_document.selection.createRange() : document.selection.createRange();
|
||||
/* Don't preserve range for emoticon click. It buggers things up epically */
|
||||
this._ie_cache = this.is_rte ? ( this.editor_document.selection.createRange ) ? this.editor_document.selection.createRange() : null : document.selection.createRange();
|
||||
Debug.write( "Preserved IE Range: ");
|
||||
this.emoClick = false;
|
||||
}
|
||||
},
|
||||
clean_html: function( t )
|
||||
@@ -2471,9 +2538,8 @@ if( ( Prototype.Browser.Gecko || Prototype.Browser.WebKit ) && USE_RTE ){
|
||||
this.emoticon_window_id.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
//==============================================================================================================//
|
||||
// OPERA SPECIFIC CODE
|
||||
@@ -2644,6 +2710,13 @@ _editor_events = Class.create({
|
||||
Debug.write("Here 2");
|
||||
var option = ( $(this.id + '_' + styleid + '_option') ) ? $F( this.id + '_' + styleid + '_option' ) : '';
|
||||
|
||||
// If this is RTE, change newlines to br tags.
|
||||
// @link http://community.invisionpower.com/tracker/issue-21173-line-breaks-arent-converted-to-%26lt%3Bbr%26gt%3B-in-code-popup-in-rte/
|
||||
if( USE_RTE )
|
||||
{
|
||||
value = value.replace( /\n/g, '<br />' );
|
||||
}
|
||||
|
||||
if( ( info['optional_option'] == '1' && option.blank() ) || info['useoption'] == '0' ){
|
||||
this.wrap_tags_lite( '[' + info['tag'] + ']' + value, '[/' + info['tag'] + ']', 1 );
|
||||
} else {
|
||||
@@ -2663,12 +2736,17 @@ _editor_events = Class.create({
|
||||
|
||||
this.palettes[ 'otherstyles_' + styleid ].doClose();
|
||||
},
|
||||
|
||||
/* ! editor_document_onmouseup */
|
||||
editor_document_onmouseup: function(e)
|
||||
{
|
||||
Debug.write("Mouse up");
|
||||
ipb.menus.closeAll(); // Close menus
|
||||
this.set_context();
|
||||
|
||||
if ( Prototype.Browser.IE )
|
||||
{
|
||||
//this.preserve_ie_range();
|
||||
}
|
||||
},
|
||||
editor_document_onkeyup: function(e)
|
||||
{
|
||||
@@ -2757,7 +2835,14 @@ _editor_events = Class.create({
|
||||
else if( elem.readAttribute('cmd') == 'help' )
|
||||
{
|
||||
//Event.stop(e);
|
||||
window.open( ipb.vars['base_url'] + "&app=forums&module=extras§ion=legends&do=bbcode", "bbcode", "status=0,toolbar=0,width=1024,height=800,scrollbars=1");
|
||||
if( inACP )
|
||||
{
|
||||
window.open( ipb.vars['front_url'] + "&app=forums&module=extras§ion=legends&do=bbcode", "bbcode", "status=0,toolbar=0,width=1024,height=800,scrollbars=1");
|
||||
}
|
||||
else
|
||||
{
|
||||
window.open( ipb.vars['base_url'] + "&app=forums&module=extras§ion=legends&do=bbcode", "bbcode", "status=0,toolbar=0,width=1024,height=800,scrollbars=1");
|
||||
}
|
||||
Event.stop(e);
|
||||
return false;
|
||||
}
|
||||
@@ -2924,7 +3009,7 @@ _editor_events = Class.create({
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
this.insert_emoticon( emo.readAttribute('emo_id'), emo.readAttribute('emo_img'), emo.readAttribute('emo_code'), e );
|
||||
},
|
||||
link_onclick: function(e)
|
||||
@@ -2950,6 +3035,24 @@ _editor_events = Class.create({
|
||||
$( this.id + '_url' ).value = this.defaults['link_url'];
|
||||
$( this.id + '_urltext' ).value = selection;
|
||||
}
|
||||
else if( selection.match(/<a/) )
|
||||
{
|
||||
if ( res = selection.match( /href="([^"]+?)"([^>]+?)?>([^<]+?)<\/a>/i ) )
|
||||
{
|
||||
Debug.write( res );
|
||||
if ( res.length )
|
||||
{
|
||||
$( this.id + '_url' ).value = res[1];
|
||||
$( this.id + '_urltext' ).value = res[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
$( this.id + '_url' ).value = selection.strip();
|
||||
$( this.id + '_urltext' ).value = this.defaults['link_text'];
|
||||
}
|
||||
_active = $( this.id + '_urltext' );
|
||||
}
|
||||
}
|
||||
else if( selection.match(/[A-Za-z]+:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/) ){
|
||||
$( this.id + '_url' ).value = selection.strip();
|
||||
$( this.id + '_urltext' ).value = this.defaults['link_text'];
|
||||
@@ -3107,6 +3210,63 @@ _editor_events = Class.create({
|
||||
}
|
||||
});
|
||||
|
||||
var x_expanded = new Array();
|
||||
|
||||
function editorMinimize( key )
|
||||
{
|
||||
Debug.write( 'shrinking: ' + key );
|
||||
x_expanded[key] = 0;
|
||||
|
||||
$(key + '_textarea').setStyle( { height: '70px' } );
|
||||
|
||||
$('editor_' + key).removeClassName('ips_editor');
|
||||
$(key + '_controls').hide();
|
||||
|
||||
/* is there value? */
|
||||
if ( $(key + '_textarea').value )
|
||||
{
|
||||
editorExpand( key );
|
||||
}
|
||||
|
||||
$(key + '_textarea').observe( 'focus', function(e) {
|
||||
editorExpand( key );
|
||||
} );
|
||||
}
|
||||
|
||||
function editorExpand( key )
|
||||
{
|
||||
$H(x_expanded).each( function(i)
|
||||
{
|
||||
/* Shrink set up editors */
|
||||
if ( i.key != key )
|
||||
{
|
||||
editorCollapse( i.key );
|
||||
}
|
||||
} );
|
||||
|
||||
if ( x_expanded[key] == 0 )
|
||||
{
|
||||
Debug.write(" expanding: " + key);
|
||||
$(key + '_controls').appear();
|
||||
$('editor_' + key).addClassName('ips_editor');
|
||||
|
||||
ipb.editors[key] = new ipb.editor( key, USE_RTE );
|
||||
$( ipb.editors[key ] ).resize_to( 250 );
|
||||
x_expanded[ key ] = 1;
|
||||
|
||||
try
|
||||
{
|
||||
ipb.editors[key].editor_window.focus();
|
||||
} catch(err) { Debug.write( err ); }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function editorCollapse(key)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*_editor.prototype.switchEditor = function( editorID )
|
||||
{
|
||||
if( !ipb.editors[ editorID ] ){ Debug.error( "No editor found for ID " + editorID ); }
|
||||
@@ -3121,6 +3281,4 @@ _editor_events = Class.create({
|
||||
} else {
|
||||
editor._loading = true;
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
}*/
|
||||
Reference in new issue
Block a user