Skip to content

Commit

Permalink
Merge pull request #21 from pulse-studio/master
Browse files Browse the repository at this point in the history
single_name отсутствует
  • Loading branch information
osben authored Dec 25, 2019
2 parents 8950f5a + dc6cae0 commit afc9cfe
Show file tree
Hide file tree
Showing 21 changed files with 146 additions and 409 deletions.
2 changes: 1 addition & 1 deletion design/default/html/index.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
{* Всплывающие подсказки для администратора *}
{if $smarty.session.admin == 'admin'}
<script src ="simpla/design/js/admintooltip/admintooltip.js" type="text/javascript"></script>
<link href="simpla/design/js/admintooltip/css/admintooltip.css" rel="stylesheet" type="text/css" />
<link href="simpla/design/js/admintooltip/admintooltip.css" rel="stylesheet" type="text/css" />
{/if}

{* Ctrl-навигация на соседние товары *}
Expand Down
3 changes: 1 addition & 2 deletions simpla/design/html/feature.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@
<select class=multiple_categories multiple name="feature_categories[]">
{function name=category_select selected_id=$product_category level=0}
{foreach $categories as $category}
<option value='{$category->id}' {if in_array($category->id, $feature_categories)}selected{/if}
category_name='{$category->single_name}'>{section name=sp loop=$level}&nbsp;&nbsp;&nbsp;&nbsp;{/section}{$category->name}</option>
<option value='{$category->id}' {if in_array($category->id, $feature_categories)}selected{/if}>{section name=sp loop=$level}&nbsp;&nbsp;&nbsp;&nbsp;{/section}{$category->name}</option>
{category_select categories=$category->subcategories selected_id=$selected_id level=$level+1}
{/foreach}
{/function}
Expand Down
Binary file added simpla/design/js/admintooltip/add.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 75 additions & 0 deletions simpla/design/js/admintooltip/admintooltip.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
.admin-bookmark{
position:absolute;
left:3%;
top:0px;
width: 12px;
height: 35px;
background-image: url(bookmark.gif);
background-repeat: no-repeat;
}
.admin-tooltip{
position: absolute;
visibility: hidden;
opacity: 0;
z-index: 9999;
transition: all .3s ease .1s;
width: 200px;
padding-top: 10px;
top: 0;
left: 0;
}
.admin-tooltip-inner{
padding: 5px 10px;
background: #ffedb6;
border: 1px solid #FFC107;
border-radius: 3px;
position: relative;
box-shadow: 0 5px 5px -5px #d4ad38;
}

.admin-tooltip a{
display: block;
color: #795548;
padding: 3px 2px 3px 20px;
background-position: left center;
background-repeat: no-repeat;
text-decoration: none;
}
.admin-tooltip a:hover{
color: #ec6331;
}
.admin-tooltip:hover,
.admin-tooltip.admin-tooltip-visible{
visibility: visible;
opacity: 1;
transition: none;
}
.admin-tooltip-edit {
background-image:url(edit.png);
}
.admin-tooltip-add {
background-image:url(add.png);
}
.admin-tooltip-inner:before{
content: '';
display: block;
position: absolute;
border: 4px solid transparent;
top: -8px;
left: 10px;
border-bottom-color: #ffc107;
}
.admin-tooltip-inner:after{
content: '';
display: block;
position: absolute;
border: 4px solid transparent;
top: -7px;
left: 10px;
border-bottom-color: #ffedb6;
}
.flipped .admin-tooltip-inner:before,
.flipped .admin-tooltip-inner:after{
left: auto;
right: 10px
}
224 changes: 69 additions & 155 deletions simpla/design/js/admintooltip/admintooltip.js
Original file line number Diff line number Diff line change
@@ -1,164 +1,78 @@
$(function() {
if(!('live' in jQuery.fn))
(function($){
'use strict';

$('<a href="simpla/" class="admin-bookmark"></a>').appendTo('body');

var $tooltip = $('<div>', { class: 'admin-tooltip', html: $('<div>', {class: 'admin-tooltip-inner'}) }).appendTo('body');
var tooltipCanClose = false;

$(document)
.on('mouseover', '[data-page]', show_tooltip)
.on('mouseover', '[data-category]', show_tooltip)
.on('mouseover', '[data-brand]', show_tooltip)
.on('mouseover', '[data-product]', show_tooltip)
.on('mouseover', '[data-post]', show_tooltip)
.on('mouseover', '[data-feature]', show_tooltip);

function show_tooltip()
{
jQuery.fn.extend({
live: function (event, callback) {
if (this.selector) {
jQuery(document).on(event, this.selector, callback);
}
}
var $link = $(this);

$tooltip.addClass('admin-tooltip-visible');

$link.on('mouseleave', function(){
$tooltip.removeClass('admin-tooltip-visible');
});
}
$("<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-category]').live('mouseover', show_tooltip);
$('[data-brand]').live('mouseover', show_tooltip);
$('[data-product]').live('mouseover', show_tooltip);
$('[data-post]').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-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>";
var flip = $link.offset().left + $tooltip.width() + 25 > $('body').width();

$tooltip
.css({
'top': $link.height() + $link.offset().top + 'px',
'left': $link.offset().left - (flip ? $tooltip.width() - $link.outerWidth(true) : 0) + 'px'
})
.removeClass('flipped')
.addClass(flip ? 'flipped' : '');

var urlFrom = encodeURIComponent(window.location);
var tooltipContent = '';

var id = '';

if(id = $link.attr('data-page'))
tooltipContent = createTooltipContent('PageAdmin', id, urlFrom);
else if(id = $link.attr('data-category'))
tooltipContent = createTooltipContent('CategoryAdmin', id, urlFrom);
else if(id = $link.attr('data-brand'))
tooltipContent = createTooltipContent('BrandAdmin', id, urlFrom);
else if(id = $link.attr('data-product'))
tooltipContent = createTooltipContent('ProductAdmin', id, urlFrom);
else if(id = $link.attr('data-post'))
tooltipContent = createTooltipContent('PostAdmin', id, urlFrom);
else if(id = $link.attr('data-feature'))
tooltipContent = createTooltipContent('FeatureAdmin', id, urlFrom);

$tooltip.find('.admin-tooltip-inner').html( tooltipContent );
}

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-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)
function createTooltipContent(module, id, urlFrom){
var $linkEdit = $('<a>', {
href: 'simpla/index.php?module=' + module + '&id=' + id + '&return=' + urlFrom,
class: 'admin-tooltip-edit',
text: 'Редактировать'
});

if(module == 'PageAdmin' || module == 'CategoryAdmin')
{
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;
}


var $linkAdd = $('<a>', {
href: 'simpla/index.php?module=' + (module == 'CategoryAdmin' ? 'ProductAdmin&category_id=' + id : module) + '&return=' + urlFrom,
class: 'admin-tooltip-add',
text: module == 'PageAdmin' ? 'Добавить страницу' : 'Добавить товар'
});

return [$linkEdit, $linkAdd];
}

return $linkEdit;
}

}


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;
}
})(window.jQuery);
File renamed without changes
Loading

0 comments on commit afc9cfe

Please sign in to comment.