Init
167
js/admintooltip/admintooltip.js
Normal file
@@ -0,0 +1,167 @@
|
||||
$(function() {
|
||||
$("<a href='simpla/' class='admin_bookmark'></a>").appendTo('body');
|
||||
tooltip = $("<div class='tooltip'><div class='tooltipHeader'></div><div class='tooltipBody'></div><div class='tooltipFooter'></div></div>").appendTo($('body'));
|
||||
$('.tooltip').live('mouseleave', function(){tooltipcanclose=true;setTimeout("close_tooltip();", 300);});
|
||||
$('.tooltip').live('mouseover', function(){tooltipcanclose=false;});
|
||||
|
||||
$('[data-page]').live('mouseover', show_tooltip);
|
||||
$('[data-service]').live('mouseover', show_tooltip);
|
||||
$('[data-category]').live('mouseover', show_tooltip);
|
||||
$('[data-brand]').live('mouseover', show_tooltip);
|
||||
$('[data-product]').live('mouseover', show_tooltip);
|
||||
$('[data-post]').live('mouseover', show_tooltip);
|
||||
$('[data-act]').live('mouseover', show_tooltip);
|
||||
$('[data-feature]').live('mouseover', show_tooltip);
|
||||
});
|
||||
|
||||
function show_tooltip()
|
||||
{
|
||||
tooltipcanclose=false;
|
||||
tooltip.show();
|
||||
$(this).live('mouseleave', function(){tooltipcanclose=true;setTimeout("close_tooltip();", 500);});
|
||||
|
||||
|
||||
|
||||
flip = !($(this).offset().left+tooltip.width()+25 < $('body').width());
|
||||
|
||||
tooltip.css('top', $(this).height() + 5 + $(this).offset().top + 'px');
|
||||
tooltip.css('left', ($(this).offset().left + $(this).outerWidth()*0.5 - (flip ? tooltip.width()-40 : 0) + 0) + 'px');
|
||||
tooltip.find('.tooltipHeader').addClass(flip ? 'tooltipHeaderFlip' : 'tooltipHeaderDirect').removeClass(flip ? 'tooltipHeaderDirect' : 'tooltipHeaderFlip');
|
||||
|
||||
from = encodeURIComponent(window.location);
|
||||
tooltipcontent = '';
|
||||
|
||||
if(id = $(this).attr('data-service'))
|
||||
{
|
||||
tooltipcontent = "<a href='simpla/index.php?module=ServiceAdmin&id="+id+"&return="+from+"' class=admin_tooltip_edit>Редактировать</a>";
|
||||
tooltipcontent += "<a href='simpla/index.php?module=ServiceAdmin&return="+from+"' class=admin_tooltip_add>Добавить услугу</a>";
|
||||
}
|
||||
|
||||
if(id = $(this).attr('data-page'))
|
||||
{
|
||||
tooltipcontent = "<a href='simpla/index.php?module=PageAdmin&id="+id+"&return="+from+"' class=admin_tooltip_edit>Редактировать</a>";
|
||||
tooltipcontent += "<a href='simpla/index.php?module=PageAdmin&return="+from+"' class=admin_tooltip_add>Добавить страницу</a>";
|
||||
}
|
||||
|
||||
if(id = $(this).attr('data-category'))
|
||||
{
|
||||
tooltipcontent = "<a href='simpla/index.php?module=CategoryAdmin&id="+id+"&return="+from+"' class=admin_tooltip_edit>Редактировать</a>";
|
||||
tooltipcontent += "<a href='simpla/index.php?module=ProductAdmin&category_id="+id+"&return="+from+"' class=admin_tooltip_add>Добавить товар</a>";
|
||||
}
|
||||
|
||||
if(id = $(this).attr('data-brand'))
|
||||
{
|
||||
tooltipcontent = "<a href='simpla/index.php?module=BrandAdmin&id="+id+"&return="+from+"' class=admin_tooltip_edit>Редактировать</a>";
|
||||
}
|
||||
|
||||
if(id = $(this).attr('data-product'))
|
||||
{
|
||||
tooltipcontent = "<a href='simpla/index.php?module=ProductAdmin&id="+id+"&return="+from+"' class=admin_tooltip_edit>Редактировать</a>";
|
||||
}
|
||||
|
||||
if(id = $(this).attr('data-post'))
|
||||
{
|
||||
tooltipcontent = "<a href='simpla/index.php?module=PostAdmin&id="+id+"&return="+from+"' class=admin_tooltip_edit>Редактировать</a>";
|
||||
}
|
||||
|
||||
if(id = $(this).attr('data-act'))
|
||||
{
|
||||
tooltipcontent = "<a href='simpla/index.php?module=ActionsPostAdmin&id="+id+"&return="+from+"' class=admin_tooltip_edit>Редактировать</a>";
|
||||
}
|
||||
|
||||
if(id = $(this).attr('data-feature'))
|
||||
{
|
||||
tooltipcontent = "<a href='simpla/index.php?module=FeatureAdmin&id="+id+"&return="+from+"' class=admin_tooltip_edit>Редактировать</a>";
|
||||
}
|
||||
|
||||
$('.tooltipBody').html(tooltipcontent);
|
||||
}
|
||||
|
||||
function close_tooltip()
|
||||
{
|
||||
if(tooltipcanclose)
|
||||
{
|
||||
tooltipcanclose=false;
|
||||
tooltip.hide();
|
||||
}
|
||||
}
|
||||
|
||||
function SetTooltips() {
|
||||
elements = document.getElementsByTagName("body")[0].getElementsByTagName("*");
|
||||
|
||||
for (i = 0; i <elements.length; i++)
|
||||
{
|
||||
tooltip = elements[i].getAttribute('tooltip');
|
||||
if(tooltip)
|
||||
{
|
||||
elements[i].onmouseout = function(e) {tooltipcanclose=true;setTimeout("CloseTooltip();", 1000);};
|
||||
switch(tooltip)
|
||||
{
|
||||
case 'product':
|
||||
elements[i].onmouseover = function(e) {AdminProductTooltip(this, this.getAttribute('product_id'));tooltipcanclose=false;}
|
||||
break;
|
||||
case 'hit':
|
||||
elements[i].onmouseover = function(e) {AdminHitTooltip(this, this.getAttribute('product_id'));tooltipcanclose=false;tooltipcanclose=false;}
|
||||
break;
|
||||
case 'category':
|
||||
elements[i].onmouseover = function(e) {AdminCategoryTooltip(this, this.getAttribute('category_id'));tooltipcanclose=false;}
|
||||
break;
|
||||
case 'news':
|
||||
elements[i].onmouseover = function(e) {AdminNewsTooltip(this, this.getAttribute('news_id'));tooltipcanclose=false;}
|
||||
break;
|
||||
case 'article':
|
||||
elements[i].onmouseover = function(e) {AdminArticleTooltip(this, this.getAttribute('article_id'));tooltipcanclose=false;}
|
||||
break;
|
||||
case 'page':
|
||||
elements[i].onmouseover = function(e) {AdminPageTooltip(this, this.getAttribute('id')); tooltipcanclose=false;}
|
||||
break;
|
||||
case 'currency':
|
||||
elements[i].onmouseover = function(e) {AdminCurrencyTooltip(this); tooltipcanclose=false;}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function ShowTooltip(i, content) {
|
||||
|
||||
tooltip = document.getElementById('tooltip');
|
||||
|
||||
document.getElementById('tooltipBody').innerHTML = content;
|
||||
tooltip.style.display = 'block';
|
||||
|
||||
var xleft=0;
|
||||
var xtop=0;
|
||||
o = i;
|
||||
|
||||
do {
|
||||
xleft += o.offsetLeft;
|
||||
xtop += o.offsetTop;
|
||||
|
||||
} while (o=o.offsetParent);
|
||||
|
||||
xwidth = i.offsetWidth ? i.offsetWidth : i.style.pixelWidth;
|
||||
xheight = i.offsetHeight ? i.offsetHeight : i.style.pixelHeight;
|
||||
|
||||
bwidth = tooltip.offsetWidth ? tooltip.offsetWidth : tooltip.style.pixelWidth;
|
||||
|
||||
w = window;
|
||||
|
||||
xbody = document.compatMode=='CSS1Compat' ? w.document.documentElement : w.document.body;
|
||||
dwidth = xbody.clientWidth ? xbody.clientWidth : w.innerWidth;
|
||||
bwidth = tooltip.offsetWidth ? tooltip.offsetWidth : tooltip.style.pixelWidth;
|
||||
|
||||
flip = !( 25 + xleft + bwidth < dwidth);
|
||||
|
||||
tooltip.style.top = xheight - 3 + xtop + 'px';
|
||||
tooltip.style.left = (xleft - (flip ? bwidth : 0) + 25) + 'px';
|
||||
|
||||
document.getElementById('tooltipHeader').className = flip ? 'tooltipHeaderFlip' : 'tooltipHeaderDirect';
|
||||
|
||||
return false;
|
||||
}
|
||||
93
js/admintooltip/css/admintooltip.css
Normal file
@@ -0,0 +1,93 @@
|
||||
a.admin_bookmark
|
||||
{
|
||||
position:absolute;
|
||||
left:3%;
|
||||
top:0px;
|
||||
width: 12px;
|
||||
height: 35px;
|
||||
background-image: url('../i/bookmark.gif');
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
.tooltip a
|
||||
{
|
||||
display: block;
|
||||
color: black;
|
||||
padding:3px 2px 5px 20px;
|
||||
background-position: left center;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
.tooltip a:hover
|
||||
{
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
a.admin_tooltip_edit { background-image:url('../i/edit.png'); }
|
||||
a.admin_tooltip_delete { background-image:url('../i/invisible.png'); }
|
||||
a.admin_tooltip_hit { background-image:url('../i/hit.png'); }
|
||||
a.admin_tooltip_up { background-image:url('../i/up.png'); }
|
||||
a.admin_tooltip_down { background-image:url('../i/down.png'); }
|
||||
a.admin_tooltip_add { background-image:url('../i/add.png'); }
|
||||
|
||||
.tooltip {
|
||||
width: 187px;
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
|
||||
display: none;
|
||||
position: absolute;
|
||||
z-index: 64999;
|
||||
|
||||
filter: Alpha(Opacity='85');
|
||||
-moz-opacity: 0.85;
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
.tooltipHeader {
|
||||
width: 187px;
|
||||
height: 19px;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-size: 0;
|
||||
line-height: 0;
|
||||
background-repeat: no-repeat;
|
||||
|
||||
display: block;
|
||||
}
|
||||
|
||||
.tooltipHeaderDirect {
|
||||
background-image: url(../i/tooltip-header.gif);
|
||||
}
|
||||
|
||||
.tooltipHeaderFlip {
|
||||
background-image: url(../i/tooltip-header-flip.gif);
|
||||
}
|
||||
|
||||
.tooltipFooter {
|
||||
width: 187px;
|
||||
height: 3px;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-size: 0;
|
||||
line-height: 0;
|
||||
background-image: url(../i/tooltip-footer.gif);
|
||||
background-repeat: no-repeat;
|
||||
|
||||
display: block;
|
||||
}
|
||||
|
||||
.tooltipBody {
|
||||
padding: 10px;
|
||||
color: black;
|
||||
background-color: #D0D0D0;
|
||||
width: auto;
|
||||
margin: 0;
|
||||
font: normal normal 12px/14px Verdana, Arial, serif;
|
||||
line-height: 140%;
|
||||
background-image: url(../i/tooltip-body.gif);
|
||||
background-repeat: repeat-y;
|
||||
|
||||
display: block;
|
||||
}
|
||||
BIN
js/admintooltip/i/add.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
js/admintooltip/i/bookmark.gif
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
js/admintooltip/i/down.png
Normal file
|
After Width: | Height: | Size: 477 B |
BIN
js/admintooltip/i/edit.png
Normal file
|
After Width: | Height: | Size: 570 B |
BIN
js/admintooltip/i/hit.png
Normal file
|
After Width: | Height: | Size: 664 B |
BIN
js/admintooltip/i/invisible.png
Normal file
|
After Width: | Height: | Size: 715 B |
BIN
js/admintooltip/i/lamp_off.png
Normal file
|
After Width: | Height: | Size: 554 B |
BIN
js/admintooltip/i/lamp_on.png
Normal file
|
After Width: | Height: | Size: 525 B |
BIN
js/admintooltip/i/tooltip-body.gif
Normal file
|
After Width: | Height: | Size: 194 B |
BIN
js/admintooltip/i/tooltip-footer.gif
Normal file
|
After Width: | Height: | Size: 104 B |
BIN
js/admintooltip/i/tooltip-header-flip.gif
Normal file
|
After Width: | Height: | Size: 194 B |
BIN
js/admintooltip/i/tooltip-header.gif
Normal file
|
After Width: | Height: | Size: 195 B |
BIN
js/admintooltip/i/up.png
Normal file
|
After Width: | Height: | Size: 477 B |
156
js/admintooltip/index.html
Normal file
@@ -0,0 +1,156 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Validate JS</TITLE>
|
||||
|
||||
<SCRIPT src="js/default.js" language="JavaScript" type="text/javascript"></SCRIPT>
|
||||
<SCRIPT src="js/validate.js" language="JavaScript" type="text/javascript"></SCRIPT>
|
||||
<SCRIPT src="js/baloon.js" language="JavaScript" type="text/javascript"></SCRIPT>
|
||||
|
||||
<LINK href="css/default.css" rel="stylesheet" type="text/css" />
|
||||
<LINK href="css/baloon.css" rel="stylesheet" type="text/css" />
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
<TABLE width="100%" border="0" cellpadding="10" cellspacing="0">
|
||||
<FORM action="index.html" method="GET" enctype="multipart/form-data">
|
||||
<TR valign="top">
|
||||
<TD width="50%">
|
||||
Текст сообщения об ошибке будет браться из атрибута <STRONG>notice</STRONG>, если тот есть. Если у формы есть атрибут <STRONG>onsubmit</STRONG>, то стандартный скрипт валидации подцепляться не будет.
|
||||
Допустимые значения текстовых полей (<STRONG>text</STRONG>, <STRONG>password</STRONG> или <STRONG>textarea</STRONG>) определяются атрибутом <STRONG>pattern</STRONG>, значение которого в общем случае
|
||||
представляет из себя регулярное выражение, соотвествующее корректному значению поля. Ограничители писать не надо.
|
||||
Например значение этого поля должно начинаться с 'a', заканчиваться на 'c', и содержать внутри хотя бы один 'b' (<STRONG>^ab+c$</STRONG>).
|
||||
<BR /><BR /> Кстати, в старых Opera’ах (< 7) регулярные выражения вроде бы отсутвуют как класс.
|
||||
</TD>
|
||||
<TD width="50%">
|
||||
<INPUT type="text" name="count" pattern="^aq+c$" notice="skiri"/>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR valign="top">
|
||||
<TD>
|
||||
Если атрибут <STRONG>pattern</STRONG> равен number, то в поле ожидается неотрицательное целое число
|
||||
</TD>
|
||||
|
||||
<TD>
|
||||
<INPUT type="text" name="number" pattern="number" notice="В этом поле должно быть целое число"/>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR valign="top">
|
||||
<TD>
|
||||
Если атрибут <STRONG>pattern</STRONG> равен url, то в поле ожидается URL. К сожалению, в регулярных выражениях я не очень силен,
|
||||
поэтому шаблон иногда сбоит. Так что перед использованием протестите
|
||||
</TD>
|
||||
|
||||
<TD>
|
||||
<INPUT type="text" name="url" pattern="url" notice="В этом поле должен быть URL"/>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR valign="top">
|
||||
<TD>
|
||||
Если атрибут <STRONG>pattern</STRONG> равен string, то поле просто не должно быть пустым
|
||||
</TD>
|
||||
<TD>
|
||||
<INPUT type="text" name="string" pattern="string" notice="В этом поле хоть что-то надо вписать"/>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR valign="top">
|
||||
<TD>
|
||||
Если атрибут <STRONG>pattern</STRONG> равен email, то в поле ожидается email адрес
|
||||
</TD>
|
||||
<TD>
|
||||
<INPUT type="text" name="email" pattern="email" notice="В этом поле должен быть email адрес"/>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
|
||||
<TR valign="top">
|
||||
<TD>
|
||||
Ошибка возникает при выборе OPTION’а с атрибутом <STRONG>notselected</STRONG>.
|
||||
Элемент с атрибутом <STRONG>select-multiple</STRONG> я еще не придумал как проверять (пока не было еще в этом нужды)
|
||||
</TD>
|
||||
|
||||
<TD>
|
||||
<SELECT name="choise" notice="Надо выбрать 1 элемент, причем не первый">
|
||||
<OPTION value="1" notselected="notselected">Одын</OPTION>
|
||||
<OPTION value="2">Две</OPTION>
|
||||
<OPTION value="3">Три</OPTION>
|
||||
<OPTION value="4">Четыре</OPTION>
|
||||
</SELECT>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR valign="top">
|
||||
<TD>
|
||||
У любого из checkbox’ов можно указать атрибуты <STRONG>min</STRONG>, <STRONG>max</STRONG> и
|
||||
<STRONG>notice</STRONG>
|
||||
</TD>
|
||||
|
||||
<TD>
|
||||
<FIELDSET>
|
||||
<LEGEND>Группа checkbox’ов с одинаковым именем</LEGEND>
|
||||
|
||||
<INPUT class="radio" type="checkbox" name="rand" min="1" max="2" notice="Надо выбрать по краней мере 1 элемент, но не больше 2х"/>
|
||||
<INPUT class="radio" type="checkbox" name="rand"/>
|
||||
<INPUT class="radio" type="checkbox" name="rand"/>
|
||||
<INPUT class="radio" type="checkbox" name="rand"/>
|
||||
<INPUT class="radio" type="checkbox" name="rand"/>
|
||||
</FIELDSET>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR valign="top">
|
||||
<TD>
|
||||
<STRONG>TEXTAREA</STRONG> проверяется так же, как и <STRONG>INPUT[@type = 'text']</STRONG>
|
||||
</TD>
|
||||
|
||||
<TD>
|
||||
<TEXTAREA name="text" pattern="string" notice="Сюда надо просто что то ввести"></TEXTAREA>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR valign="top">
|
||||
<TD>
|
||||
У любого из radiobutton’ов можно указать атрибуты <STRONG>min</STRONG>, <STRONG>max</STRONG> и <STRONG>notice</STRONG>.
|
||||
<BR>Причем, так как это radiobutton, а не checkbox, то <STRONG>min</STRONG> = <STRONG>max</STRONG> = 1
|
||||
</TD>
|
||||
|
||||
<TD>
|
||||
<FIELDSET>
|
||||
<LEGEND>Группа radiobutton’ов с одинаковым именем</LEGEND>
|
||||
|
||||
<INPUT class="radio" type="radio" name="mask"/>
|
||||
<INPUT class="radio" type="radio" name="mask" min="1" max="1" notice="Надо выбрать какой то 1 элемент"/>
|
||||
<INPUT class="radio" type="radio" name="mask"/>
|
||||
<INPUT class="radio" type="radio" name="mask"/>
|
||||
</FIELDSET>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR valign="top">
|
||||
<TD>
|
||||
Элемент типа <STRONG>file</STRONG> я не придумал как проверять. Да и проверять его редко когда надо, разве что при закачке картинок.
|
||||
Но в их случае я пользуюсь превьюшками, а имя файла и расширение как правило интереса совсем не представляют
|
||||
</TD>
|
||||
|
||||
<TD>
|
||||
<INPUT type="file" name="photo"/>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR valign="top">
|
||||
<TD>
|
||||
Значения полей типа <STRONG>image</STRONG>, <STRONG>button</STRONG>, <STRONG>submit</STRONG>,
|
||||
<STRONG>reset</STRONG> и <STRONG>hidden</STRONG> никак не проверяются
|
||||
</TD>
|
||||
<TD>
|
||||
<INPUT type="submit" value="submit"/>
|
||||
</TD>
|
||||
</TR>
|
||||
</FORM>
|
||||
</TABLE>
|
||||
</BODY>
|
||||
</HTML>
|
||||