// Вывод текста
function echo(text)
{
document.write(text);
}
// Вывод текста с переводом строки
function echoln(text)
{
document.writeln(text);
}
// Подключить css
function use_css(url)
{
echo('');
}
// Подключить скрипт
function use_script(url)
{
echo('');
}
// Назад
function go_back()
{
history.go(-1);
}
// Перейти по ссылке
function redirect(url)
{
window.location = url;
}
// Обработчик меню для IE
admin_menu_hover = function()
{
$('#admin_menu li').each(
function()
{
$(this).hover(
function()
{
this.className+=' iehover';
},
function()
{
this.className=this.className.replace(new RegExp(' iehover\\b'), '');
}
);
}
);
}
if (window.attachEvent) window.attachEvent('onload', admin_menu_hover);
// Коррекция альфа-канала PNG в IE
function fix_png(element)
{
if (/MSIE (5|6)/.test(navigator.userAgent))
{
var src;
if (element.tagName=='IMG')
{
if (/\.png$/.test(element.src))
{
src = element.src;
var w = element.width;
var h = element.height;
element.src = "/ui/x.gif";
//element.width = w;
//element.height = h;
}
if (src)
{
element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='image')";
}
}
else
{
src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i)
if (src)
{
src = src[1];
element.runtimeStyle.backgroundImage="none";
}
if (src)
element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
}
}
}
String.prototype.starts = function(item)
{
return this.substr(0, item.length) === item;
};
function admin_set_checkboxes(form, name, checked)
{
for (var i=0; i < form.length; i++)
if (form[i].name.starts(name))
form[i].checked = checked;
}
function ui_detail_window(url, width, height, scroll, resizable)
{
if (scroll == null)
scroll = 0;
if (resizable == null)
resizable = 0;
w = width;
h = height;
var x, y, w, h;
x = Math.round((screen.availWidth - w) / 2);
y = Math.round((screen.availHeight - h) / 2);
var param = 'toolbar=0,status=0,scrollbars=' + scroll + ',resizable=' + resizable +
',left=' + x.toString() +
',top=' + y.toString() +
',width=' + w.toString() +
',height=' + h.toString();
wnd=open(url, 'detail' + Math.round(Math.random() * 4000000000), param);
wnd.focus();
return wnd;
}
function insert_text(area, text)
{
area.focus();
// IE
if(typeof document.selection != 'undefined')
{
var range = area.document.selection.createRange();
var sel = range.text;
range.text = text;
range = area.document.selection.createRange();
range.select();
}
// Mozilla
else if(typeof area.attr('selectionStart') != 'undefined')
{
var scroll = area.attr('scrollTop');
var start = area.attr('selectionStart');
var end = area.attr('selectionEnd');
var before = area.attr('value').substring(0, start);
var sel = area.attr('value').substring(start, end);
var after = area.attr('value').substring(end, area.attr('textLength'));
area.attr('value', before + text + after);
var caret = sel.length == 0 ? start + text.length : start + text.length + sel.length;
area.attr('selectionStart', caret);
area.attr('selectionEnd', caret);
area.attr('scrollTop', scroll);
}
}
function insert_tags(area, tag1, tag2, attr)
{
if (!attr)
attr = '';
area.focus();
// IE
if(typeof document.selection != 'undefined')
{
var range = document.selection.createRange();
var sel = range.text;
range.text = tag2 ? "[" + tag1 + attr + "]" + sel + "[/" + tag2 + "]" : ":" + tag1 + ":";
range = document.selection.createRange();
if (tag2 && !sel.length)
range.move('character', -tag2.length - 3);
else if(tag2)
range.move('character', tag1.length + 2 + attr.length + sel.length + tag2.length + 3);
range.select();
}
// Mozilla
else if(typeof area.attr('selectionStart') != 'undefined')
{
var scroll = area.attr('scrollTop');
var start = area.attr('selectionStart');
var end = area.attr('selectionEnd');
var before = area.attr('value').substring(0, start);
var sel = area.attr('value').substring(start, end);
var after = area.attr('value').substring(end, area.attr('textLength'));
area.attr('value', tag2 ? before + "[" + tag1 + attr + "]" + sel + "[/" + tag2 + "]" + after : before + ":" + tag1 + ":" + after);
var caret = sel.length == 0 ? start + tag1.length + 2 + attr.length : start + tag1.length + 2 + attr.length + sel.length + tag2.length + 3;
area.attr('selectionStart', caret);
area.attr('selectionEnd', caret);
area.attr('scrollTop', scroll);
}
}
function bb_insert_url(area)
{
var enterURL = prompt('Введите ссылку', 'http://');
if (!enterURL)
return;
var enterTITLE = prompt('Введите текст ссылки', 'Ссылка');
if (enterTITLE)
insert_text(area, '[url=' + enterURL + ']' + enterTITLE + '[/url]');
else
insert_text(area, enterURL);
}
function bb_insert_img(area)
{
var enterURL = prompt('Введите путь к картинке', '');
if (!enterURL)
return;
var enterTITLE = prompt('Введите альтернативный текст', '');
if (enterTITLE)
insert_text(area, '[img alt="' + enterTITLE + '"]' + enterURL + '[/img]');
else
insert_text(area, '[img]' + enterURL + '[/img]');
}
function bb_insert_list(area, type)
{
var listvalue = "init";
var thelist = "";
opentag = ( type == 'ordered' ) ? '[list=1]' : '[list]';
while ( (listvalue != "") && (listvalue != null) )
{
listvalue = prompt('Введите пункт списка. Для завершения списка, нажмите «отмена» или оставьте очередное поле пустым', '');
if ( (listvalue != "") && (listvalue != null) )
{
thelist = thelist+"[*]"+listvalue+"\n";
}
}
if (thelist != "")
{
insert_text(area, opentag + "\n" + thelist + "[/list]\n");
}
}
function bb_bar(area, page_id, sub_id, block)
{
if (page_id == null)
page_id = 0;
if (sub_id == null)
sub_id = 0;
if (block == null)
block = '';
echo
(
'' +
'' +
'' +
'' +
'' +
'' +
'' +
/*(page_id ?
'' +
''
: ''
) +*/
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'
'
)
}
function b_edit()
{
echo('');
}
function b_new()
{
echo('');
}
function b_delete()
{
echo('');
}
function b_browse()
{
echo('');
}
function b_up()
{
echo('');
}
function b_down()
{
echo('');
}
function b_cut()
{
echo('');
}
function b_copy()
{
echo('');
}
function b_paste()
{
echo('');
}
function b_folder()
{
echo('');
}
function b_item()
{
echo('');
}
function b_folder_new()
{
echo('');
}
function b_active()
{
echo('');
}
function b_inactive()
{
echo('');
}
function b_apply()
{
echo('');
}
function b_textfield()
{
echo('');
}
function pic_frame_start()
{
echo('
');
}
function pic_frame_end()
{
echo('
');
}
function antispam_error()
{
echo('
Сработала защита от спама! Вы ввели неправильный код.
');
}
function antispam_block_title()
{
echo('Защита от спама');
}
function antispam_block_input()
{
echo('');
}
function antispam_block_pic()
{
echo('');
}
function antispam_block()
{
echo('
Защита от спама:
');
}
function admin_panel_start()
{
echo(
'
' +
'
' +
'
' +
'
'
);
}
function admin_panel_end()
{
echo(
'
' +
'
' +
'
' +
'
'
);
}
/* Ajax */
function loading_set(id)
{
var w = $('#' + id).attr('offsetWidth') + "px";
var h = $('#' + id).attr('offsetHeight') + "px";
$('#' + id + ' div.loading-overlay').css({ width:w, height:h });
}
function loading_show(id)
{
$('#' + id).prepend('');
$('#' + id).prepend('
Загрузка…
');
loading_set(id);
$(window).resize(function() {
loading_set(id);
});
}
function load_page(id, url, _this)
{
var data = _this ? $(_this).serialize() : "";
$.ajax({
type: "get",
url: url,
data: data,
beforeSend: function(){
loading_show(id);
},
success: function(html) {
$("#"+id).php(html);
}
});
}
function reload_page(id, url, _this)
{
var data = _this ? $(_this).serialize() : "";
$.ajax({
type: "get",
url: url,
data: data,
beforeSend: function(){
loading_show(id);
},
success: function(html) {
$("#"+id).replaceWith(html);
}
});
}
/* */
function feedback_check_form()
{
var reg = new RegExp("[0-9a-z_]+@[0-9a-z_^.\-]+\\.[a-z]", 'i');
if
(
($('#feedback_person').attr('value') == '') ||
($('#feedback_email').attr('value') == '') ||
($('#feedback_text').attr('value') == '')
)
alert('Необходимо заполнить все поля!');
else if (!reg.test($('#feedback_email').attr('value')))
alert('Некорректный адрес эл. почты!');
else
document.forms['feedback'].submit();
}
/* */
function init()
{
}
$(document).ready(init);