/*
* ATTENTION! This file is automatically created from several JavaScript files.
* Find file path and name in the comments in the beginning of the each code block
*/
/*
* FILE START: _shared/code/js/front_editor.js
*/
/**
* @param {object} oDictionary Object containing properties as keys and its values as captions
* @return void
*
* @copyright Amiro.CMS. All rights reserved. Changes are not allowed.
*/
function amiDictionary(oDictionary){
/**
* @var {object}
*/
this.oDictionary = typeof(oDictionary) == 'object' ? oDictionary : {};
/**
* Set single caption
*
* @param {string} key
* @param {string} caption
* @return void
*/
this.set = function(key, caption){
this.oDictionary[key] = caption;
}
/**
* Append only new captions to dictionary
*
* @param {object} oDictionary Object containing properties as keys and its values as captions
* @return void
*/
this.append = function(oDictionary){
for(var key in oDictionary){
if(typeof(this.oDictionary[key]) == 'undefined'){
this.oDictionary[key] = oDictionary[key];
}
}
}
/**
* Append new captions, override obsolete
*
* @param {object} oDictionary Object containing properties as keys and its values as captions
* @return void
*/
this.megre = function(oDictionary){
for(var key in oDictionary){
this.oDictionary[key] = oDictionary[key];
}
}
/**
* Get caption by key
*
* @param {string} key
* @return {string} | null
*/
this.get = function(key){
if(typeof(this.oDictionary[key]) == 'undefined'){
if(typeof(console) == 'object' && typeof(console.warn) == 'function'){
// firebug debugging
console.warn("Undefined dictionary key '" + key + "'");
console.trace();
}
return null;
}else{
return this.oDictionary[key];
}
}
/**
* Parse caption specified by key using variables
*
* @param {string} key
* @param {object} oVariables Object containing properties as keys and its values as captions
* @return {string} | null
*/
this.parse = function(key, oVariables){
var caption = this.get(key);
if(caption){
for(var variable in oVariables){
caption = caption.replace('_' + variable + '_', oVariables[variable]);
}
}
return caption;
}
}
/**
* Amiro.CMS text editor
*
* @param {string} Global variable name
* @param {amiDictionary} oDictionary
*
* Textarea editor with pseudo codes and preview support
* @version 1.0. Last changes: 25/05/2010
* @copyright Amiro.CMS. All rights reserved. Changes are not allowed.
*/
function amiroTEdit(varName, oDictionary){
this.isInitialized = false;
this.currentMode = 'editor';
this.varName = varName;
this.editorId = 'amiroTEdDivEditor';
this.idPreviewDiv = 'amiroTEdDivPreview';
this.previewButtonObj = undefined;
this.editorObj = false;
this.oDictionary = (oDictionary == undefined ? {} : oDictionary);
this.isIE = true;
this.useNoIndex = false;
this.fontHeight = 15;
this.regTextAreaResizeY = 0;
this.editorModeCode = false;
this.updatePreviewMode = '';
this.allowedImages = [];
this.bAllowURLs = true;
this.ceMode = false;
this.aTags = {
'empty' : ['', ''],
'bold' : ['[B]', '[/B]'],
'strike' : ['[S]', '[/S]'],
'indent' : ['[INDENT]', '[/INDENT]'],
'code' : ['[CODE]', '[/CODE]'],
'italic' : ['[I]', '[/I]'],
'underlined' : ['[U]', '[/U]'],
'quote' : ['[Q]', '[Q="#\#value#\#"]', '[/Q]'],
'align:left' : ['[LEFT]', '[/LEFT]'],
'align:right' : ['[RIGHT]', '[/RIGHT]'],
'align:center' : ['[CENTER]', '[/CENTER]'],
'align:justify': ['[JUSTIFY]', '[/JUSTIFY]'],
'ulist' : ['[LIST]', '\n[/LIST]'],
'ulist_item' : ['\n[*]', ''],
'olist' : ['[OL]', '\n[/OL]'],
'olist_item' : ['\n[*]', ''],
'addlink' : ['[URL="#\#value#\#"]', '[/URL]'],
'addimg' : ['[IMG]', '[/IMG]'],
'font_family' : ['[FONT="#\#value#\#"]', '[/FONT]'],
'font_size' : ['[SIZE="#\#value#\#"]', '[/SIZE]'],
'font_color' : ['[COLOR="#\#value#\#"]', '[/COLOR]'],
'header' : ['[H#\#value#\#]', '[/H#\#value#\#]'],
'smile' : ['', '']
};
this.usedFonts = ['Times New Roman','Georgia','Arial','Arial Black','Arial Narrow','Book Antiqua','Comic Sans MS','Courier New','Lucida Concole','Tahoma','Verdana'];
this.maxTextSize = 7;
this.usedColors = ['Black','Sienna','DarkOliveGreen','DarkGreen','DarkSlateBlue','Navy','Indigo','DarkSlateGray','DarkRed','DarkOrange','Olive','Green','Teal','Blue','SlateGray','DimGray','Red','SandyBrown','YellowGreen','SeaGreen','MediumTurquoise','RoyalBlue','Purple','Gray','Magenta','Orange','Yellow','Lime','Cyan','DeepSkyBlue','DarkOrchid','Silver','Pink','Wheat','LemonChiffon','PaleGreen','PaleTurquoise','LightBlue','Plum','White'];
this.smilesPath = 'base';
this.baseSmiles = [new Array('smile.gif', 'Smile', ':)'),new Array('laugh.gif', 'Laugh', ':D'),new Array('frown.gif', 'Frown', ':('),new Array('wink.gif', 'Wink', ';)'),new Array('blush.gif', 'Blush', ':blush:'),new Array('eek.gif', 'Eek', ':eek:'),new Array('pardon.gif', 'Pardon', ':pardon:'),new Array('cry.gif', 'Cry', ':cry:'),new Array('cool.gif', 'Cool', ':cool:'),new Array('angry.gif', 'Angry', ':angry:'),new Array('finger_up.gif', 'Thumbs up', ':finger_up:'),new Array('finger_down.gif', 'Thumbs down', ':finger_down:'),new Array('rose.gif', 'Rose', ':rose:')];
this.allSmiles = [];
this.allSmilesTitles = {'': ''};
this.smilesCopyright = '';
this.baseHref = typeof(frontBaseHref) != 'undefined' ? frontBaseHref : (typeof(editorBaseHref) != 'undefined' ? editorBaseHref : '');
window.bbEditorBaseHref = this.baseHref;
this.init = function(){
userAgent = navigator.userAgent.toLowerCase();
this.isIE = userAgent.indexOf('msie') != -1 && userAgent.indexOf('opera') == -1 && typeof(window.opera) == 'undefined';
if(typeof(this.oDictionary) != 'object' || this.oDictionary.length == 0){
this.oDictionary = new amiDictionary({
'bold': 'Bold',
'italic': 'Italic',
'underline': 'Underline',
'strike': 'Strike through',
'quote': 'Quote',
'align_left': 'Align left',
'align_center': 'Align center',
'align_right': 'Align right',
'justify': 'Justify',
'insert_list': 'Insert list',
'insert_olist': 'Insert ordered list',
'insert_link': 'Insert link',
'delete_link': 'Delete link',
'insert_image': 'Insert image',
'font': 'Font',
'size': 'Size',
'header': 'Select header',
'color': 'Color',
'more': 'more',
'insert_code': 'Insert code',
'indent': 'Indent',
'outdent': 'Outdent',
'preview': 'Preview',
'hide_preview': 'Hide preview',
'update_preview': 'Update preview',
'warn_message_length': 'Message to short!',
'warn_invalid_image_url': 'Invalid image URL!',
'warn_image_url_internal_links_forbidden': 'Images from this site are forbidden!',
'warn_image_url_external_links_forbidden': 'Images from other sites are forbidden!',
'prompt_enter_list_element': 'Enter list element',
'prompt_enter_next_list_element': 'Enter list element or leave field empty to finish',
'prompt_enter_url': 'Enter URL',
'prompt_enter_image_url': 'Enter image URL',
'warn_urls_reg_only': 'Using URLs forbidden for unregistered users.'
});
}
for(i = 0; i /g, '').replace(/^\s+/g, '').replace(/\s+$/g, '');
selTxt = selTxt.replace(//g, '');
}
tmpTags[0] = tmpTags[0].replace(/#\#value#\#/g, subaction.replace(/"/g, '"'));
this._boundSelectionWithTags(tmpTags, selTxt);
success = true;
break;
case 'align':
if(subaction != undefined && this.aTags['align:'+subaction]){
this._boundSelectionWithTags(this.aTags['align:'+subaction]);
success = true;
}
break;
case 'ulist':
case 'olist':
var selTxt = this._getSelectedText();
if(selTxt != ''){
this._procSelectionList(selTxt, action);
}else{
this._boundSelectionWithTags(this.aTags[action]);
var listLine = '';
listLine = prompt(this.oDictionary.get('prompt_enter_list_element'), '');
while(listLine != '' && listLine != null){
this._boundSelectionWithTags(this.aTags[action + '_item'], listLine, true);
listLine = prompt(this.oDictionary.get('prompt_enter_next_list_element'), '');
}
}
success = true;
break;
case 'addlink':
if(this.bAllowURLs){
urlLine = prompt(this.oDictionary.get('prompt_enter_url'), 'http://');
if(urlLine != '' && urlLine != null){
var selTxt = this._getSelectedText();
var tmpTags = [this.aTags['addlink'][0], this.aTags['addlink'][1]];
tmpTags[0] = tmpTags[0].replace(/#\#value#\#/g, urlLine.replace(/"/g, '"'));
selTxt = selTxt == '' ? urlLine : selTxt;
this._boundSelectionWithTags(tmpTags, selTxt);
success = true;
}
}else{
alert(this.oDictionary.get('warn_urls_reg_only'));
}
break;
case 'dellink':
var selTxt = this._getSelectedText();
if(selTxt != '' && selTxt.indexOf('[URL') != -1 && selTxt.indexOf('[/URL]') != -1){
selTxt = selTxt.replace(/\[URL=\".*?\"\]/g, '');
selTxt = selTxt.replace(/\[\/URL\]/g, '');
this._boundSelectionWithTags(this.aTags['empty'], selTxt);
success = true;
}
break;
case 'addimg':
var urlLine = 'http://';
do {
urlLine = prompt(this.oDictionary.get('prompt_enter_image_url'), urlLine);
askURL = urlLine != null;
if (askURL) {
urlLine = urlLine.replace(/^(.*?)\?.*$/, '$1');
if (urlLine != '') {
var allowedImages = this.allowedImages;
var re = /^https?\:\/\/([^\/]+)(\/[^\?]*)(\?.*)?/;
re.exec(urlLine);
if (RegExp.$2 == '' || RegExp.$1 == '') {
alert(this.oDictionary.get('warn_invalid_image_url'));
} else if (allowedImages.indexOf('internal_links')
0){
begin = newText.substring(0, newSelDl);
}
var end = '';
if(newSelDr > 0){
end = newText.substring(newSelDr-1);
}
this.ce.highlighter.oEditor.replaceSelection(newText, (setPointerToEnd ? "end" : ""));
if(begin.length && end.length){
selStart = this.ce.highlighter.oEditor.getSelStart();
selEnd = this.ce.highlighter.oEditor.getSelEnd();
selStart.ch += newSelDl;
selEnd.ch -= newSelDr;
if((selEnd.line == selStart.line) && (selEnd.ch 0){
var reqHeight = this.editorObj.offsetHeight-this.regTextAreaResizeY+clientY;
if(reqHeight > 50){
this.editorObj.style.height = reqHeight;
this.regTextAreaResizeY = clientY;
}
}
return false;
}
this._HTMLSpecialChars = function(taValue){
taValue = taValue.replace(/&/g, '&');
taValue = taValue.replace(/"/g, '"');
taValue = taValue.replace(//g, '>');
return taValue;
}
this.raws = [];
this.getHTMLContent = function(cutLongURL){
var smilesPath = this.baseHref + '_mod_files/smiles/' + this.smilesPath + '/';
var specSmiles = {";)":"wink", ":)":"smile", ":D":"laugh", ":(":"frown"};
var localUseNoIndex = this.useNoIndex;
var fontHeight = this.fontHeight;
taValue = this._HTMLSpecialChars(this.editorObj.value);
if(this.ceMode && this.ce.useSpecialCharsFeature){
taValue = taValue.replace(/·/g, ' ');
}else{
taValue = taValue.replace(/\r?\n/g, '
\r\n');
}
if(this.ceMode){
taValue = taValue.replace(
/\[RAW\]((?:.|\r|\n)*?)\[\/RAW\]/gi,
function(obj){
return function(allstr, tagContent){
var rawIndex = obj.raws.length;
tagContent = tagContent.replace(/&/g, '&');
tagContent = tagContent.replace(/"/g, '"');
tagContent = tagContent.replace(/</g, '');
if(!obj.ce.useSpecialCharsFeature){
tagContent = tagContent.replace(/
/g, '');
}
obj.raws.push(tagContent);
return ('##__AMI_RAW_' + rawIndex + '__##');
}
}(this)
);
if(this.ce.useSpecialCharsFeature){
taValue = taValue.replace(/↵/g, '
');
}
// Script tag
taValue = taValue.replace(/\
((?:.|\r|\n)*?)\/gi, function(allstr, tagContent){
// Despecialcharsize
tagContent = tagContent.replace(/&/g, '&');
tagContent = tagContent.replace(/"/g, '"');
tagContent = tagContent.replace(/</g, '');
tagContent = tagContent.replace(/
/g, '');
return '
';
});
}
taValue = taValue.replace(/\[DIV\]/gi, '
');
taValue = taValue.replace(/\[\/DIV\]/gi, '
');
taValue = taValue.replace(/\[LEFT\]/gi, '
');
taValue = taValue.replace(/\[\/LEFT\]/gi, '
');
taValue = taValue.replace(/\[RIGHT\]/gi, '
');
taValue = taValue.replace(/\[\/RIGHT\]/gi, '
');
taValue = taValue.replace(/\[CENTER\]/gi, '
');
taValue = taValue.replace(/\[\/CENTER\]/gi, '
');
taValue = taValue.replace(/\[JUSTIFY\]/gi, '
');
taValue = taValue.replace(/\[\/JUSTIFY\]/gi, '
');
taValue = taValue.replace(/\[LEFT="DIV"\]/gi, '
');
taValue = taValue.replace(/\[RIGHT="DIV"\]/gi, '
');
taValue = taValue.replace(/\[CENTER="DIV"\]/gi, '
');
taValue = taValue.replace(/\[JUSTIFY="DIV"\]/gi, '
');
taValue = taValue.replace(/\[LEFT="P"\]((?:.|\r|\n)*?)\[\/LEFT="P"\]/gi, '
$1
');
taValue = taValue.replace(/\[RIGHT="P"\]((?:.|\r|\n)*?)\[\/RIGHT="P"\]/gi, '
$1
');
taValue = taValue.replace(/\[CENTER="P"\]((?:.|\r|\n)*?)\[\/CENTER="P"\]/gi, '
$1
');
taValue = taValue.replace(/\[JUSTIFY="P"\]((?:.|\r|\n)*?)\[\/JUSTIFY="P"\]/gi, '
$1
');
taValue = taValue.replace(/\[(\/?)(B|I|U|S|P|H\d)\]/gi, '');
window.amiSimpleEditorCodes = [];
taValue = taValue.replace(/\[CODE\]((?:.|\r|\n)*?)\[\/CODE\]/gi, function(allstr, tagContent){
tagContent = tagContent.replace(/
/gi, '');
var nlCount = 1;
var nlPos = tagContent.indexOf('\n');
while(nlPos != -1){
nlCount++;
nlPos = tagContent.indexOf('\n', nlPos+1);
}
if(nlCount > 10)
nlCount = 10;
var codeKey = window.amiSimpleEditorCodes.length;
window.amiSimpleEditorCodes[codeKey] = tagContent;
return '
CodeId_'+codeKey+'
';
});
taValue = taValue.replace(/\[Q\]/gi, '
');
taValue = taValue.replace(/\[Q="(.*?)"\]/gi, '
$1:
');
taValue = taValue.replace(/\[(\/?)(INDENT|Q)\]/gi, '');
taValue = taValue.replace(/\[LIST\]/gi, '
');
taValue = taValue.replace(/\[\/LIST\]/gi, '
');
taValue = taValue.replace(/\[UL\]/gi, '
');
taValue = taValue.replace(/\[\/UL\]/gi, '
');
taValue = taValue.replace(/\[OL\]/gi, '
');
taValue = taValue.replace(/\[\/OL\]/gi, '
');
taValue = taValue.replace(/\[\*\]/gi, '
');
taValue = taValue.replace(/\[FONT="(.*?)"\]/gi, function(allstr, fontName){return '
'});
taValue = taValue.replace(/\[(COLOR|SIZE)="(.*?)"\]/gi, function(allstr, tagParam, paramValue){return '
'});
taValue = taValue.replace(/\[\/(FONT|SIZE|COLOR)\]/gi, '
');
var urlMaxLength = typeof(cutLongURL) == 'undefined' ? 0 : 50;
if(this.ceMode){
taValue = taValue.replace(/\[URL="(.*?)"\]((?:.|\r|\n)*?)\[\/URL\]/gi, function(allstr, url, linkContent){
var curUseNoIndex = localUseNoIndex;
var curUrl = _tagsParamReplace(url, false);
if(curUseNoIndex && (!curUrl.match(/^https?:\/\//i) || (window.bbEditorBaseHref.length > 0 && curUrl.indexOf(window.bbEditorBaseHref) >= 0)))
curUseNoIndex = false;
var attributes = '';
linkContent = _trim(linkContent);
var noTagsLinkContent = _trim(_stripTags(linkContent).replace(/\"/g, '"'));
if ((urlMaxLength > 0) && (noTagsLinkContent.length > urlMaxLength)) {
attributes =
' title="' + noTagsLinkContent + '"';
linkContent = noTagsLinkContent.substr(0, urlMaxLength - 8 - 3) + '...' + noTagsLinkContent.substr(noTagsLinkContent.length - 8);
}
return (curUseNoIndex ? '
' : '')+'
'+linkContent+'
'+(curUseNoIndex ? '
' : '');
});
var allSmilesTitles = this.allSmilesTitles;
taValue = taValue.replace(/\[IMG\](.*?)\[\/IMG\]/gi, function(allstr, url){return '
'});
var specSmileReg = new RegExp(((this.ceMode) ? '[^A-Za-z\\d]?(;\\)|:\\)|:D|:\\()' : '(;\\)|:\\)|:D|:\\()'), 'g');
taValue = taValue.replace(specSmileReg, function(allstr, smile){var imgName = specSmiles[smile]+'.gif'; return '
'});
taValue = taValue.replace(/\:([a-z\_]{1,20})\:/gi, function(allstr, smile){var imgName = smile+'.gif'; return '
'});
taValue = taValue.replace(/((?:
)|(?:
))/gi, function(allstr, pTagContent){
pTagContent = pTagContent.replace(/http(s?)\:/gi, 'htBREAKtp$1:');
pTagContent = pTagContent.replace(/www/gi, 'wBREAKwBREAKw');
return pTagContent;
});
taValue = taValue.replace(/((?:
)|(?:
))/gi, function(allstr, pTagContent){
pTagContent = pTagContent.replace(/wBREAKwBREAKw/gi, 'www');
pTagContent = pTagContent.replace(/htBREAKtp(s?):/gi, 'http$1:');
return pTagContent;
});
}else{
taValue = taValue.replace(/\[URL="(.*?)"\]((?:.|\r|\n)*?)\[\/URL\]/gi, function(allstr, url, linkContent){
var curUseNoIndex = localUseNoIndex;
var curUrl = _tagsParamReplace(url, false);
if(curUseNoIndex && (!curUrl.match(/^https?:\/\//i) || (window.bbEditorBaseHref.length > 0 && curUrl.indexOf(window.bbEditorBaseHref) >= 0)))
curUseNoIndex = false;
var attributes = '';
linkContent = _trim(linkContent);
var noTagsLinkContent = _trim(_stripTags(linkContent).replace(/\"/g, '"'));
if ((urlMaxLength > 0) && (noTagsLinkContent.length > urlMaxLength)) {
attributes =
' title="' + noTagsLinkContent + '"';
linkContent = noTagsLinkContent.substr(0, urlMaxLength - 8 - 3) + '...' + noTagsLinkContent.substr(noTagsLinkContent.length - 8);
}
return (curUseNoIndex ? '
' : '')+'
'+linkContent+'
'+(curUseNoIndex ? '
' : '');
});
var allSmilesTitles = this.allSmilesTitles;
taValue = taValue.replace(/\[IMG\](.*?)\[\/IMG\]/gi, function(allstr, url){return '
'});
if(this.ceMode){
taValue = taValue.replace(/(\s;\)|\s:\)|:D|:\()/g, function(allstr, smile){smile = smile.replace(' ', ''); var imgName = specSmiles[smile]+'.gif'; return '
'});
}else{
taValue = taValue.replace(/(;\)|:\)|:D|:\()/g, function(allstr, smile){var imgName = specSmiles[smile]+'.gif'; return '
'});
}
taValue = taValue.replace(/\:([a-z\_]{1,20})\:/gi, function(allstr, smile){var imgName = smile+'.gif'; return '
'});
taValue = taValue.replace(/((?:
)|(?:
))/gi, function(allstr, pTagContent){
pTagContent = pTagContent.replace(/http(s?)\:/gi, 'htBREAKtp$1:');
pTagContent = pTagContent.replace(/www/gi, 'wBREAKwBREAKw');
return pTagContent;
});
taValue = taValue.replace(/(https?:\/\/www\.|https?:\/\/|www\.)(?:[a-z0-9\-]+\.)+[a-z]{2,8}[^ \r\n\t'"> 0 && curUrl.indexOf(window.bbEditorBaseHref) >= 0)))
curUseNoIndex = false;
return (curUseNoIndex ? '
' : '')+'
'+allstr+'
'+(curUseNoIndex ? '
' : '');
});
taValue = taValue.replace(/((?:
)|(?:
))/gi, function(allstr, pTagContent){
pTagContent = pTagContent.replace(/wBREAKwBREAKw/gi, 'www');
pTagContent = pTagContent.replace(/htBREAKtp(s?):/gi, 'http$1:');
return pTagContent;
});
}
taValue = taValue.replace(/(
]*?>)CodeId_(\d+)()/g, function(allstr, preStart, codeId, preEnd){
var result = preStart;
if(window.amiSimpleEditorCodes[codeId]){
result += window.amiSimpleEditorCodes[codeId];
}
result += preEnd;
return result;
});
if(this.ceMode){
taValue = taValue.replace(
/##__AMI_RAW_(\d+)__##/gi,
function(obj){
return function(allstr, tagContent){
return obj.raws[parseInt(tagContent)];
}
}(this)
);
}
taValue = taValue.replace(/
([^\n]*?)
([\r\n]*?)
/gi, '
$1
$2
');
taValue = taValue.replace(/
([^\n]*?)
([\r\n]*?)\>
$1
$2
\>\>]*>\>\>\>$1blockquote>
$1$2>
'); tavalue="">
([\r\n]*?)
/gi, '
$1
');
taValue = taValue.replace(/
([\r\n]*?)/gi, '\>
$1');
taValue = taValue.replace(/
([\r\n]*?)/gi, '$1');
taValue = taValue.replace(/
/gi, '
');
taValue = taValue.replace(/
/gi, '
');
taValue = taValue.replace(/
/gi, '\>
');
taValue = taValue.replace(/
/gi, '');
taValue = taValue.replace(/
/gi, '
');
taValue = taValue.replace(/
/gi, '');
taValue = taValue.replace(/
/gi, '');
taValue = taValue.replace(/
/gi, '');
taValue = taValue.replace(/
/gi, '');
taValue = taValue.replace(/
/gi, '');
taValue = taValue.replace(/
/gi, '');
taValue = taValue.replace(/
/gi, '
');
taValue = taValue.replace(/
/gi, '
');
taValue = taValue.replace(/
/gi, '
');
taValue = taValue.replace(/
/gi, '
');
taValue = taValue.replace(/
/gi, '
');
taValue = taValue.replace(/
/gi, '');
taValue = taValue.replace(/
/gi, '
');
taValue = taValue.replace(/
/gi, '
');
window.amiSimpleEditorCodes = [];
return taValue;
}
this.fromHTMLContent = function(taValue){
var smilesPath = '_mod_files/smiles/' + this.smilesPath + '/';
var specSmiles = {"wink":";)", "smile":":)", "laugh":":D", "frown":":("};
if(this.ceMode && this.ce.useSpecialCharsFeature){
taValue = taValue.replace(/
/gi, '_spec_rpl_val_br');
taValue = taValue.replace(/ /gi, '·');
}else{
taValue = taValue.replace(/\r?\n?
/gi, '\r\n
');
taValue = taValue.replace(/\r?\n?
/gi, '
\>
\>
\r\n
');
taValue = taValue.replace(/\r?\n?
/gi, '
\>\>
\r\n
');
taValue = taValue.replace(/\r?\n?
/gi, '
\r\n
');
taValue = taValue.replace(/\r?\n?
/gi, '\r\n
');
taValue = taValue.replace(/\r?\n?
/gi, '\r\n
');
taValue = taValue.replace(/\r?\n?
\r?\n?/gi, '\r\n');
}
taValue = taValue.replace(/ style=""/gi, '');
taValue = taValue.replace(/ class=""/gi, '');
taValue = taValue.replace(/ target="_self"/gi, '');
taValue = taValue.replace(/↵/gi, '[RAW]↵[/RAW]');
taValue = taValue.replace(/\\([rn])/gi, '[_spec_rpl_val_$1]');
taValue = taValue.replace(/\r?\n/g, '\\n');
// Replace simple elements
taValue = taValue.replace(/
/gi, '[CODE]');
taValue = taValue.replace(//gi, '[/CODE]');
taValue = taValue.replace(//gi, '[$1$2]');
taValue = taValue.replace(/
/gi, '[LIST]');
taValue = taValue.replace(//gi, '[/LIST]');
taValue = taValue.replace(/
/gi, '[OL]');
taValue = taValue.replace(//gi, '[/OL]');
taValue = taValue.replace(/
-
/gi, '[*]');
taValue = taValue.replace(//gi, '');
taValue = taValue.replace(/
/gi, '[S]');
taValue = taValue.replace(//gi, '[/S]');
taValue = taValue.replace(/
/gi, "[IMG]$1[/IMG]");
// Replace smiles
taValue = taValue.replace(/
]*?src=((?:"|').*?(?:"|')|[^\s]*).*?>/gi,
function(allstr, tagUrl){
var tagUrl = tagUrl.replace(/^('|")(.*?)\1$/g, '$2');
var pathPos = tagUrl.indexOf(smilesPath);
if(pathPos >= 0){
var dotPos = tagUrl.indexOf(".", pathPos+smilesPath.length);
if(dotPos >= 0){
var startPos = pathPos+smilesPath.length;
var smileName = tagUrl.substr(startPos, dotPos-startPos);
if(specSmiles[smileName] != undefined){
return specSmiles[smileName];
}else
return ':'+smileName+':';
}
}
return allstr;}
);
// Replace nested elements
var replaceType = ['align', 'font', 'url', 'blockquote'];
for(var i = 0; i
(.*?)/ig, '[DIV]$1[/DIV]');
taValue = taValue.replace(/
(.*?)/i, '[$1="DIV"]$2[/$1]');
taValue = taValue.replace(/
(.*?)/i, '[$1="DIV"]$2[/$1]');
taValue = taValue.replace(/
(.*?)/i, '[$1="P"]$2[/$1="P"]');
}else{
taValue = taValue.replace(/
(.*?)/i, '[$1]$2[/$1]');
taValue = taValue.replace(/
(.*?)/i, '[$1]$2[/$1]');
//taValue = taValue.replace(/^(.*)
]*?align=(?:"|')?(right|left|center|justify)(?:"|')?.*?>(.*?)|[^a-z].*?>)/i, '$1[$2]$3[/$2]');
}
}
else if(replaceType[i] == 'font')
taValue = taValue.replace(/^(.*)
]*?(face|size|color)=((?:"|').*?(?:"|')|[^\s>]*).*?>(.*?)/i, function(allstr, textStart, tagName, tagValue, tagContent){var tagTag = (tagName.toLowerCase() == "face" ? "FONT" : tagName.toUpperCase()); tagValue = tagValue.replace(/^('|")(.*?)\1$/g, '$2'); return textStart+'['+tagTag+'="'+tagValue+'"]'+tagContent+'[/'+tagTag+']';});
else if(replaceType[i] == 'url') {
if(this.ceMode){
taValue = taValue.replace(/
(.*?)/igm, '[URL="$1"]$3[/URL]');
}else{
taValue = taValue.replace(/^(.*)
]*?)href=((?:"|').*?(?:"|')|[^\s>]*)(.*?)>(.*?)|[^a-z].*?>)/i, function(allstr, textStart, tagParams1, tagUrl, tagParams2, tagContent){
if(tagUrl.indexOf('javascript:') > 0) return allstr;
var tagUrl = tagUrl.replace(/^('|")(.*?)\1$/g, '$2');
urlContent = tagContent;
if(aParts = (tagParams1 + " " + tagParams2).match(/[^a-z]title="([^"]+)"/i)){
urlContent = aParts[1].replace(/"/mg, '"').replace(/
/mg, '\n').replace(/
/mg, '\r');
}
return textStart + '[URL="' + tagUrl + '"]' + urlContent + '[/URL]';
});
}
}
else if(replaceType[i] == 'blockquote'){
taValue = taValue.replace(/^(.*)
(?:\[B\](.*?):\[\/B\]\\n)?(.*?)/i, function(allstr, tagBefore, tagInner, qAuthor, tagContent){
var isQuote = (tagInner.indexOf('edQuote') >= 0);
var hasAuthor = (typeof(qAuthor) != "undefined" && qAuthor.length > 0);
if(isQuote){
var startTag = '[Q'+(hasAuthor ? '="'+qAuthor+'"' : '')+']';
return tagBefore+startTag+tagContent+'[/Q]';
}else{
return tagBefore+'[INDENT]'+(hasAuthor ? qAuthor : '')+tagContent+'[/INDENT]';
}
});
}
}while(checkLen != taValue.length);
}
taValue = taValue.replace(//gi, '[$1$2]');
// Replace HTML base chars
taValue = taValue.replace(/®/gi, '®');
taValue = taValue.replace(/©/gi, '©');
taValue = taValue.replace(/«/gi, '«');
taValue = taValue.replace(/»/gi, '»');
taValue = taValue.replace(/–/gi, '–');
taValue = taValue.replace(/—/gi, '—');
taValue = taValue.replace(/€/gi, '€');
taValue = taValue.replace(/"/gi, '"');
taValue = taValue.replace(/ /gi, ' ');
// RAWs
if(this.ceMode){
taValue = taValue.replace(/(]|\n|\r|\s|\t)+)>)/ig,"[RAW]$1[/RAW]").replace(/\[\/RAW\]((\r|\n)*?)\[RAW\]/g, "$1");
// Tags fully closed with RAW
var rawTags = ['script', 'object', 'style', 'textarea'];
for(var i=0; i
', 'ig');
taValue = taValue.replace(
regExp,
function(tag){
return function(allstr, tagContent){
tagContent = tagContent.replace(/\[RAW\]/ig, "");
tagContent = tagContent.replace(/\[\/RAW\]/ig, "");
return '';
}
}(rawTags[i])
);
}
// Remove RAWs and replace brs inside RAW
var regExp = new RegExp('\\[RAW\\]\\[\\/RAW\\]', 'ig');
taValue = taValue.replace(
regExp,
function(allstr, tagContent){
tagContent = tagContent.replace(/\_spec\_rpl\_val\_br/gi, '
');
tagContent = tagContent.replace(/\[RAW\]/ig, "");
tagContent = tagContent.replace(/\[\/RAW\]/ig, "");
return '[RAW][/RAW]';
}
);
}
// Replace > and <
taValue = taValue.replace(/</gi, '');
// Make multiline string
taValue = taValue.replace(/\\n/g, '\r\n');
taValue = taValue.replace(/\[\_spec\_rpl\_val\_([rn])\]/gi, '\\$1');
taValue = taValue.replace(/\_spec\_rpl\_val\_br/gi, '↵');
return taValue;
}
this.createEditor = function(taWidth, taHeight, taValueName, taValue, isValueHTML, idPreviewDiv, divId){
if (typeof(isValueHTML) != undefined) {
var re = /(
|)/gi;
taValue = taValue.replace(re, '');
}
if(taValueName && taValueName != "message"){
this.editorId = 'id'+taValueName;
}
var i = 0;
/*var usedFonts = '';
for(i = 0; i '+this.usedFonts[i]+'';
}*/
var baseSmilesCount = 0;
var TEdDivBaseSmiles = document.createElement('DIV');
for(i = 0; i \>
');>'>((.|\r|\n)*?)>'>'>(([^>(\>\>
\>
\>\>
\>
\>\>
';
}
var allowedImages = this.allowedImages;
var TEdDiv = document.createElement('DIV');
TEdDiv.className = "amiroTEdDiv";
TEdDiv.style.width = taWidth + 'px';
// Separator
var separator = document.createElement('IMG');
separator.src = this.baseHref + '_img/ed_sep.gif';
separator.className = 'amiroTEdSep';
// Bold button
var btnBold = document.createElement('IMG');
btnBold.src = this.baseHref + '_img/ed_bold.gif';
btnBold.title = this.oDictionary.get('bold');
AMI.Browser.Event.addHandler(btnBold, 'click', function(_this){return function(e){_this.procAction('bold');}}(this));
// Italic button
var btnItalic = document.createElement('IMG');
btnItalic.src = this.baseHref + '_img/ed_italic.gif';
btnItalic.title = this.oDictionary.get('italic');
AMI.Browser.Event.addHandler(btnItalic, 'click', function(_this){return function(e){_this.procAction('italic');}}(this));
// Underline button
var btnUnderline = document.createElement('IMG');
btnUnderline.src = this.baseHref + '_img/ed_underline.gif';
btnUnderline.title = this.oDictionary.get('underline');
AMI.Browser.Event.addHandler(btnUnderline, 'click', function(_this){return function(e){_this.procAction('underlined');}}(this));
// StrikeThrough button
var btnStrike = document.createElement('IMG');
btnStrike.src = this.baseHref + '_img/ed_strike.gif';
btnStrike.title = this.oDictionary.get('strike');
AMI.Browser.Event.addHandler(btnStrike, 'click', function(_this){return function(e){_this.procAction('strike');}}(this));
// Quote button
var btnQuote = document.createElement('IMG');
btnQuote.src = this.baseHref + '_img/ed_quote.gif';
btnQuote.title = this.oDictionary.get('quote');
AMI.Browser.Event.addHandler(btnQuote, 'click', function(_this){return function(e){_this.procAction('quote');}}(this));
this.insertQuoteBtn = btnQuote;
var buttonsBlock1 = document.createElement('NOBR');
buttonsBlock1.appendChild(btnBold);
buttonsBlock1.appendChild(btnItalic);
buttonsBlock1.appendChild(btnUnderline);
buttonsBlock1.appendChild(btnStrike);
buttonsBlock1.appendChild(btnQuote);
// Outdent button
var btnOutdent = document.createElement('IMG');
btnOutdent.src = this.baseHref + '_img/ed_outdent.gif';
btnOutdent.title = this.oDictionary.get('outdent');
AMI.Browser.Event.addHandler(btnOutdent, 'click', function(_this){return function(e){_this.procAction('outdent');}}(this));
// Indent button
var btnIndent = document.createElement('IMG');
btnIndent.src = this.baseHref + '_img/ed_indent.gif';
btnIndent.title = this.oDictionary.get('indent');
AMI.Browser.Event.addHandler(btnIndent, 'click', function(_this){return function(e){_this.procAction('indent');}}(this));
var buttonsBlock2 = document.createElement('NOBR');
buttonsBlock2.appendChild(btnOutdent);
buttonsBlock2.appendChild(btnIndent);
// Left button
var btnLeft = document.createElement('IMG');
btnLeft.src = this.baseHref + '_img/ed_alignl.gif';
btnLeft.title = this.oDictionary.get('align_left');
AMI.Browser.Event.addHandler(btnLeft, 'click', function(_this){return function(e){_this.procAction('align', 'left');}}(this));
// Center button
var btnCenter = document.createElement('IMG');
btnCenter.src = this.baseHref + '_img/ed_alignc.gif';
btnCenter.title = this.oDictionary.get('align_center');
AMI.Browser.Event.addHandler(btnCenter, 'click', function(_this){return function(e){_this.procAction('align', 'center');}}(this));
// Right button
var btnRight = document.createElement('IMG');
btnRight.src = this.baseHref + '_img/ed_alignr.gif';
btnRight.title = this.oDictionary.get('align_right');
AMI.Browser.Event.addHandler(btnRight, 'click', function(_this){return function(e){_this.procAction('align', 'right');}}(this));
// Justify button
var btnJustify = document.createElement('IMG');
btnJustify.src = this.baseHref + '_img/ed_alignj.gif';
btnJustify.title = this.oDictionary.get('justify');
AMI.Browser.Event.addHandler(btnJustify, 'click', function(_this){return function(e){_this.procAction('align', 'justify');}}(this));
var buttonsBlock3 = document.createElement('NOBR');
buttonsBlock3.appendChild(btnLeft);
buttonsBlock3.appendChild(btnCenter);
buttonsBlock3.appendChild(btnRight);
buttonsBlock3.appendChild(btnJustify);
// List button
var btnUlist = document.createElement('IMG');
btnUlist.src = this.baseHref + '_img/ed_list.gif';
btnUlist.title = this.oDictionary.get('insert_list');
AMI.Browser.Event.addHandler(btnUlist, 'click', function(_this){return function(e){_this.procAction('ulist');}}(this));
// Orderes list button
var btnOlist = document.createElement('IMG');
btnOlist.src = this.baseHref + '_img/ed_ol.gif';
btnOlist.title = this.oDictionary.get('insert_olist');
AMI.Browser.Event.addHandler(btnOlist, 'click', function(_this){return function(e){_this.procAction('olist');}}(this));
// Add link button
var btnLink = document.createElement('IMG');
btnLink.src = this.baseHref + '_img/ed_link.gif';
btnLink.title = this.oDictionary.get('insert_link');
AMI.Browser.Event.addHandler(btnLink, 'click', function(_this){return function(e){_this.procAction('addlink');}}(this));
// Del link button
var btnUnlink = document.createElement('IMG');
btnUnlink.src = this.baseHref + '_img/ed_unlink.gif';
btnUnlink.title = this.oDictionary.get('delete_link');
AMI.Browser.Event.addHandler(btnUnlink, 'click', function(_this){return function(e){_this.procAction('dellink');}}(this));
// Add image button
var btnImg = document.createElement('IMG');
btnImg.src = this.baseHref + '_img/ed_image.gif';
btnImg.title = this.oDictionary.get('insert_image');
AMI.Browser.Event.addHandler(btnImg, 'click', function(_this){return function(e){_this.procAction('addimg');}}(this));
// Code button
var btnCode = document.createElement('IMG');
btnCode.src = this.baseHref + '_img/ed_code.gif';
btnCode.title = this.oDictionary.get('insert_code');
AMI.Browser.Event.addHandler(btnCode, 'click', function(_this){return function(e){_this.procAction('code');}}(this));
this.insertCodeBtn = btnCode;
var buttonsBlock4 = document.createElement('NOBR');
buttonsBlock4.appendChild(btnLink);
buttonsBlock4.appendChild(btnUnlink);
if(allowedImages.length){
buttonsBlock4.appendChild(btnImg);
}
buttonsBlock4.appendChild(btnCode);
var buttonsBlock5 = document.createElement('NOBR');
buttonsBlock5.style.display = 'inline-block';
buttonsBlock5.style.verticalAlign = 'top';
buttonsBlock5.style.marginTop = '-2px';
var selectSize = document.createElement('SELECT');
selectSize.name = 'amiroTEdit_selsize';
selectSize.className = 'amiroTEdCtrl';
AMI.Browser.Event.addHandler(selectSize, 'change', function(_this, sel){return function(e){_this.procAction('font_size', sel.value); sel.options[0].selected=true;}}(this, selectSize));
var option = document.createElement('option');
option.text = this.oDictionary.get('size');
option.value = "";
try{selectSize.add(option, null);}catch(ex){selectSize.add(option);}
buttonsBlock5.appendChild(selectSize);
for(i = 1; i => baseSmilesCount){
var more = document.createElement('SPAN');
more.className = 'amiroTEdMore';
more.innerHTML = this.oDictionary.get('more');
AMI.Browser.Event.addHandler(more, 'click', function(_this, allSmilesDiv, baseSmilesDiv){
return function(e){
allSmilesDiv.style.display = 'block';
baseSmilesDiv.style.display = 'none';
}
}(this, TEdDivAllSmiles, TEdDivBaseSmiles));
}
// Textarea
var TEdDivEditor = document.createElement('DIV');
TEdDivEditor.className = 'amiroTEdDivEditor';
var TEdTextarea = document.createElement('TEXTAREA');
TEdTextarea.id = this.editorId;
TEdTextarea.name = taValueName;
TEdTextarea.setAttribute('wrap', 'fisical');
TEdTextarea.className = 'amiroTEdCtrl';
TEdTextarea.style.width = '100%'; //taWidth + 'px';
TEdTextarea.style.height = taHeight + 'px';
TEdTextarea.value = (typeof(isValueHTML) == undefined || !isValueHTML ? taValue : this.fromHTMLContent(taValue));
AMI.Browser.Event.addHandler(TEdTextarea, 'keydown', function(_this){return function(e){_this.procKeyPress(e);}}(this));
AMI.Browser.Event.addHandler(TEdTextarea, 'keyup', function(_this){return function(e){_this.procKeyUp(e);}}(this));
TEdDivEditor.appendChild(TEdTextarea);
TEdDiv.innerHTML = contentPreviewDiv;
var TEdToolbar = document.createElement('DIV');
TEdToolbar.id = 'amiroTEdPureDiv';
this.toolbarObj = TEdToolbar;
TEdToolbar.appendChild(buttonsBlock1);
TEdToolbar.appendChild(separator.cloneNode(true));
TEdToolbar.appendChild(buttonsBlock2);
TEdToolbar.appendChild(separator.cloneNode(true));
TEdToolbar.appendChild(buttonsBlock3);
TEdToolbar.appendChild(separator.cloneNode(true));
TEdToolbar.appendChild(btnUlist);
TEdToolbar.appendChild(btnOlist);
TEdToolbar.appendChild(separator.cloneNode(true));
TEdToolbar.appendChild(buttonsBlock4);
TEdToolbar.appendChild(separator.cloneNode(true));
TEdToolbar.appendChild(buttonsBlock5);
TEdToolbar.appendChild(document.createElement('BR'));
TEdToolbar.appendChild(TEdDivBaseSmiles);
if((allSmilesCount > baseSmilesCount) && more){
TEdDivBaseSmiles.appendChild(more);
TEdToolbar.appendChild(TEdDivAllSmiles);
}
TEdDiv.appendChild(TEdToolbar);
TEdDiv.appendChild(TEdDivEditor);
if(divId == undefined){
divId = "amiBBEditor";
document.writeln('
');
}
AMI.find('#' + divId).appendChild(TEdDiv);
this.editorObj = document.getElementById(this.editorId);
this.editorDiv = TEdDiv;
this.isInitialized = true;
}
this.insertContent = function(taValue, actionType, isValueHTML, subaction, addon){
if (typeof(isValueHTML) != undefined) {
var re = /(
|)/gi;
taValue = taValue.replace(re, '');
}
this.setMode('editor');
if(typeof(addon) != "undefined" && actionType == "bold"){
taValue = "[B]"+taValue+"[/B]"+addon;
this._replaceSelection(typeof(isValueHTML) == undefined || !isValueHTML ? taValue : this.fromHTMLContent(taValue), 0, 0, true);
}else{
this._replaceSelection(typeof(isValueHTML) == undefined || !isValueHTML ? taValue : this.fromHTMLContent(taValue), 0, 0);
if(actionType != 'undefined' && (actionType == 'quote' || actionType == 'bold' || actionType == 'italic' || actionType == 'underlined')){
this.procAction(actionType, subaction);
}
}
}
this.setMode = function(mode){
if(mode == 'editor' && !this.updatePreviewMode){
document.getElementById(this.idPreviewDiv).style.display = 'none';
this.currentMode = 'editor';
if(this.editorModeCode.length > 0){
eval(this.editorModeCode);
}
}else if(mode == 'preview' || this.updatePreviewMode){
var content = this.getHTMLContent(1);
if (content.length) {
document.getElementById(this.idPreviewDiv).style.display = 'block';
document.getElementById(this.idPreviewDiv).innerHTML = content;
this.currentMode = 'preview';
if (this.updatePreviewMode) {
this.previewButtonObj.value = this.oDictionary.get('hide_preview');
}
this.updatePreviewMode = false;
}
}
if (typeof(amiroTEditOnSwitchMode) == 'function') {
amiroTEditOnSwitchMode(this.currentMode);
}
}
this.switchMode = function(){
if(this.currentMode == 'editor'){
this.setMode('preview');
}else{
this.setMode('editor');
}
}
this.stopEvent = function(evt){
if(typeof(evt.stopPropagation) == "function"){
evt.stopPropagation();
evt.preventDefault();
return evt;
}else{
window.event.returnValue = false;
window.event.cancelBubble = true;
return window.event;
}
}
this.procKeyPress = function(evt){
if(this.ceMode && this.ce.useSpecialCharsFeature){
switch(evt.keyCode){
case 13 /*ENTER */:
if(!evt.shiftKey){
this.procAction('br');
return this.stopEvent(evt);
}
break;
}
}
if(evt.ctrlKey && evt.keyCode != 17){
switch(evt.keyCode){
case 66 /*B*/:
this.procAction('bold');
return this.stopEvent(evt);
break;
case 73 /*I*/:
this.procAction('italic');
return this.stopEvent(evt);
break;
case 85 /*U*/:
this.procAction('underlined');
return this.stopEvent(evt);
break;
case 83 /*S*/:
this.procAction('strike');
return this.stopEvent(evt);
break;
}
}else if(!evt.ctrlKey && !evt.altKey){
this.updatePreviewButton();
}
}
this.procKeyUp = function()
{
if (this.currentMode == 'preview' && this.contentLength()
]+HREF=/gi);
if(!res){
alert(this.oDictionary.get('warn_urls_reg_only'));
}
return res;
}
this.init();
}
function handleMouseMove(evt){
if(typeof(globalATEObj) == 'object')
return globalATEObj.handleMouseMove(evt == undefined ? window.event.clientY : evt.pageY);
else
return false;
}
function releaseMouseMoveHandler(){
document.onmousemove = null;
document.onmouseup = null;
return false;
}
function _tagsParamReplace(param, doCheckImage){
var res = param.replace(/&/, '&');
do{
var prevLength = res.length;
res = res.replace(/^\s*javascript\:/, '');
}while(res.length != prevLength);
if(doCheckImage){
var test = res.replace(/^ *(.*?) *$/i, '$1').toLowerCase();
if(test.indexOf('/_admin/') >= 0){
res = '';
}else{
var isRelativeAddress = (test.search(/^https?:\/\//) == -1);
var isLocalAddress = false;
if(!isRelativeAddress){
test = test.replace(/^https:\/\//, 'http://');
var localURL = window.bbEditorBaseHref;
if(localURL != '' && test.indexOf(localURL) == 0){
isLocalAddress = true;
}
}
if((isRelativeAddress || isLocalAddress) && test.search(/^[^?]*\.(jpg|png|gif|jpeg|swf)$/) == -1){
res = '';
}
}
}
return res;
}
function _stripTags(str)
{
return str.replace(/]+[^>]*?>/gi, '');
}
function _trim(str)
{
return str.replace(/^\s+/mg, '').replace(/\s+$/mg, '');
}
/*
* FILE END: _shared/code/js/front_editor.js
*/
AMI.Template.Locale.merge({mediaBoxZommed : "Изображение уменьшено,
показать в оригинальном размере __width__х__height__
", mediaBoxNotZommed : "Изображение увеличено,
уменьшить до размеров окна
", mediaBoxCounter : "Изображение __current__ из __total__", mediaBoxPrevious : "Предыдущее изображение", mediaBoxNext : "Следующее изображение"});
\>\>
=>\>\>
\>
\>
\>
\>
\>
\>(\>\>
\>
\>
\>\>\>\>
\>\>\>\>\>\>\>\>\>\>
');>
[a-za-z\>[a-za-z\>