Untitled diff

Criado O diff nunca expira
60 remoções
352 linhas
29 adições
349 linhas
/*##################################################
/**
* bbcode.js
* @copyright © 2005-2019 PHPBoost
* -------------------
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU/GPL-3.0
* begin : August 01, 2005
* @author Regis VIARRE <crowkait@phpboost.com>
* copyright : (C) 2005 Viarre Régis
* @version PHPBoost 5.2 - last update: 2018 11 18
* email : crowkait@phpboost.com
* @since PHPBoost 1.2 - 2005 08 01
*
* @contributor Julien BRISWALTER <j1.seth@phpboost.com>
*
* @contributor Arnaud GENET <elenwii@phpboost.com>
###################################################
* @contributor Sebastien LARTIGUE <babsolune@phpboost.com>
*
*/
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
###################################################*/
function textarea_resize(id, px, type)
function textarea_resize(id, px, type)
{
{
var textarea = document.getElementById(id);
var textarea = document.getElementById(id);
if( type == 'height' )
if( type == 'height' )
{
{
var current_height = parseInt(textarea.style.height) ? parseInt(textarea.style.height) : 300;
var current_height = parseInt(textarea.style.height) ? parseInt(textarea.style.height) : 300;
var new_height = current_height + px;
var new_height = current_height + px;
if( new_height > 40 )
if( new_height > 40 )
textarea.style.height = new_height + "px";
textarea.style.height = new_height + "px";
}
}
else
else
{
{
var current_width = parseInt(textarea.style.width) ? parseInt(textarea.style.width) : 150;
var current_width = parseInt(textarea.style.width) ? parseInt(textarea.style.width) : 150;
var new_width = current_width + px;
var new_width = current_width + px;
if( new_width > 40 )
if( new_width > 40 )
textarea.style.width = new_width + "px";
textarea.style.width = new_width + "px";
}
}
return false;
return false;
}
}
//Insertion dans le champs.
//Insertion dans le champs.
function simple_insert(open_balise, close_balise, field)
function simple_insert(open_balise, close_balise, field)
{
{
var textarea = document.getElementById(field);
var textarea = document.getElementById(field);
var scroll = textarea.scrollTop;
var scroll = textarea.scrollTop;
if( close_balise != "" && close_balise != "smile" )
if( close_balise != "" && close_balise != "smile" )
textarea.value += '[' + open_balise + '][/' + close_balise + ']';
textarea.value += '[' + open_balise + '][/' + close_balise + ']';
else if( close_balise == "smile" )
else if( close_balise == "smile" )
textarea.value += ' ' + open_balise + ' ';
textarea.value += ' ' + open_balise + ' ';
textarea.focus();
textarea.focus();
textarea.scrollTop = scroll;
textarea.scrollTop = scroll;
return;
return;
}
}
//Récupération de la sélection sur netscape, ajout des balises autour.
//Récupération de la sélection sur netscape, ajout des balises autour.
function netscape_sel(target, open_balise, close_balise)
function netscape_sel(target, open_balise, close_balise)
{
{
var sel_length = target.textLength;
var sel_length = target.textLength;
var sel_start = target.selectionStart;
var sel_start = target.selectionStart;
var sel_end = target.selectionEnd;
var sel_end = target.selectionEnd;
var scroll = target.scrollTop; //Position verticale.
var scroll = target.scrollTop; //Position verticale.
if( sel_end == 1 || sel_end == 2 )
if( sel_end == 1 || sel_end == 2 )
{
{
sel_end = sel_length;
sel_end = sel_length;
}
}
var string_start = (target.value).substring(0, sel_start);
var string_start = (target.value).substring(0, sel_start);
var selection = (target.value).substring(sel_start, sel_end);
var selection = (target.value).substring(sel_start, sel_end);
var string_end = (target.value).substring(sel_end, sel_length);
var string_end = (target.value).substring(sel_end, sel_length);
if( close_balise != "" && selection == "" && close_balise != "smile" )
if( close_balise != "" && selection == "" && close_balise != "smile" )
{
{
target.value = string_start + open_balise + close_balise + string_end;
target.value = string_start + open_balise + close_balise + string_end;
target.setSelectionRange(string_start.length + open_balise.length, target.value.length - string_end.length - close_balise.length);
target.setSelectionRange(string_start.length + open_balise.length, target.value.length - string_end.length - close_balise.length);
target.focus();
target.focus();
}
}
else if( close_balise == "smile" )
else if( close_balise == "smile" )
{
{
target.value = string_start + selection + ' ' + open_balise + ' ' + string_end;
target.value = string_start + selection + ' ' + open_balise + ' ' + string_end;
target.setSelectionRange(string_start.length + open_balise.length + 2, target.value.length - string_end.length);
target.setSelectionRange(string_start.length + open_balise.length + 2, target.value.length - string_end.length);
target.focus();
target.focus();
}
}
else
else
{
{
target.value = string_start + open_balise + selection + close_balise + string_end;
target.value = string_start + open_balise + selection + close_balise + string_end;
target.setSelectionRange(string_start.length + open_balise.length, target.value.length - string_end.length - close_balise.length);
target.setSelectionRange(string_start.length + open_balise.length, target.value.length - string_end.length - close_balise.length);
target.focus();
target.focus();
}
}
target.scrollTop = scroll; //Remet à la bonne position le textarea.
target.scrollTop = scroll; //Remet à la bonne position le textarea.
return;
return;
}
}
//Récupération de la sélection sur IE, ajout des balises autour.
//Récupération de la sélection sur IE, ajout des balises autour.
function ie_sel(target, open_balise, close_balise)
function ie_sel(target, open_balise, close_balise)
{
{
selText = false;
selText = false;
var scroll = target.scrollTop; //Position verticale.
var scroll = target.scrollTop; //Position verticale.
selection = document.selection.createRange().text; // Sélection
selection = document.selection.createRange().text; // Sélection
if( close_balise != "" && selection == "" && close_balise != "smile" )
if( close_balise != "" && selection == "" && close_balise != "smile" )
document.selection.createRange().text = open_balise + close_balise;
document.selection.createRange().text = open_balise + close_balise;
else if( close_balise == "smile" )
else if( close_balise == "smile" )
document.selection.createRange().text = selection + open_balise + ' ';
document.selection.createRange().text = selection + open_balise + ' ';
else
else
document.selection.createRange().text = open_balise + selection + close_balise;
document.selection.createRange().text = open_balise + selection + close_balise;
target.scrollTop = scroll; //Remet à la bonne position le textarea.
target.scrollTop = scroll; //Remet à la bonne position le textarea.
selText = '';
selText = '';
return;
return;
}
}