mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-07-01 05:55:02 +03:00
fix developer-jquery
This commit is contained in:
parent
e0a109c13d
commit
a29dc1735e
|
@ -28,10 +28,10 @@
|
|||
|
||||
|
||||
<div class="blog">
|
||||
<div class="voting {if $oBlog->getRating()>=0}positive{else}negative{/if} {if !$oUserCurrent || $oBlog->getOwnerId()==$oUserCurrent->getId()}guest{/if} {if $oVote} voted {if $oVote->getDirection()>0}plus{elseif $oVote->getDirection()<0}minus{/if}{/if}">
|
||||
<a href="#" class="plus" onclick="vote.vote({$oBlog->getId()},this,1,'blog'); return false;"></a>
|
||||
<div class="total" title="{$aLang.blog_vote_count}: {$oBlog->getCountVote()}">{$oBlog->getRating()}</div>
|
||||
<a href="#" class="minus" onclick="vote.vote({$oBlog->getId()},this,-1,'blog'); return false;"></a>
|
||||
<div id="vote_area_blog_{$oBlog->getId()}" class="voting {if $oBlog->getRating()>=0}positive{else}negative{/if} {if !$oUserCurrent || $oBlog->getOwnerId()==$oUserCurrent->getId()}guest{/if} {if $oVote} voted {if $oVote->getDirection()>0}plus{elseif $oVote->getDirection()<0}minus{/if}{/if}">
|
||||
<a href="#" class="plus" onclick="return ls.vote.vote({$oBlog->getId()},this,1,'blog');"></a>
|
||||
<div id="vote_total_blog_{$oBlog->getId()}" class="total" title="{$aLang.blog_vote_count}: {$oBlog->getCountVote()}">{$oBlog->getRating()}</div>
|
||||
<a href="#" class="minus" onclick="return ls.vote.vote({$oBlog->getId()},this,-1,'blog');"></a>
|
||||
</div>
|
||||
|
||||
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
</p>
|
||||
|
||||
|
||||
<div class="voting {if $oUserProfile->getRating()>=0}positive{else}negative{/if} {if !$oUserCurrent || $oUserProfile->getId()==$oUserCurrent->getId()}guest{/if} {if $oVote} voted {if $oVote->getDirection()>0}plus{elseif $oVote->getDirection()<0}minus{/if}{/if}">
|
||||
<a href="#" class="plus" onclick="vote.vote({$oUserProfile->getId()},this,1,'user'); return false;"></a>
|
||||
<div class="total" title="{$aLang.user_vote_count}: {$oUserProfile->getCountVote()}">{$oUserProfile->getRating()}</div>
|
||||
<a href="#" class="minus" onclick="vote.vote({$oUserProfile->getId()},this,-1,'user'); return false;"></a>
|
||||
<div id="vote_area_user_{$oUserProfile->getId()}" class="voting {if $oUserProfile->getRating()>=0}positive{else}negative{/if} {if !$oUserCurrent || $oUserProfile->getId()==$oUserCurrent->getId()}guest{/if} {if $oVote} voted {if $oVote->getDirection()>0}plus{elseif $oVote->getDirection()<0}minus{/if}{/if}">
|
||||
<a href="#" class="plus" onclick="return ls.vote.vote({$oUserProfile->getId()},this,1,'user');"></a>
|
||||
<div id="vote_total_user_{$oUserProfile->getId()}" class="total" title="{$aLang.user_vote_count}: {$oUserProfile->getCountVote()}">{$oUserProfile->getRating()}</div>
|
||||
<a href="#" class="minus" onclick="return ls.vote.vote({$oUserProfile->getId()},this,-1,'user');"></a>
|
||||
</div>
|
||||
|
||||
|
||||
|
|
|
@ -26,10 +26,10 @@
|
|||
{/if}
|
||||
{hook run='comment_action' comment=$oComment}
|
||||
{if $oComment->getTargetType()!='talk'}
|
||||
<li class="voting {if $oComment->getRating()>0}positive{elseif $oComment->getRating()<0}negative{/if} {if !$oUserCurrent || $oComment->getUserId()==$oUserCurrent->getId() || strtotime($oComment->getDate())<$smarty.now-$oConfig->GetValue('acl.vote.comment.limit_time')}guest{/if} {if $oVote} voted {if $oVote->getDirection()>0}plus{else}minus{/if}{/if} ">
|
||||
<a href="#" class="plus" onclick="vote.vote({$oComment->getId()},this,1,'comment'); return false;"></a>
|
||||
<span class="total">{$oComment->getRating()}</span>
|
||||
<a href="#" class="minus" onclick="vote.vote({$oComment->getId()},this,-1,'comment'); return false;"></a>
|
||||
<li id="vote_area_comment_{$oComment->getId()}" class="voting {if $oComment->getRating()>0}positive{elseif $oComment->getRating()<0}negative{/if} {if !$oUserCurrent || $oComment->getUserId()==$oUserCurrent->getId() || strtotime($oComment->getDate())<$smarty.now-$oConfig->GetValue('acl.vote.comment.limit_time')}guest{/if} {if $oVote} voted {if $oVote->getDirection()>0}plus{else}minus{/if}{/if} ">
|
||||
<a href="#" class="plus" onclick="return ls.vote.vote({$oComment->getId()},this,1,'comment');"></a>
|
||||
<span id="vote_total_comment_{$oComment->getId()}" class="total">{$oComment->getRating()}</span>
|
||||
<a href="#" class="minus" onclick="return ls.vote.vote({$oComment->getId()},this,-1,'comment');"></a>
|
||||
</li>
|
||||
{/if}
|
||||
</ul>
|
||||
|
|
|
@ -39,6 +39,23 @@ ls.msg = (function ($) {
|
|||
|
||||
|
||||
|
||||
/**
|
||||
* Вспомогательные функции
|
||||
*/
|
||||
ls.tools = (function ($) {
|
||||
|
||||
/**
|
||||
* Переводит первый символ в верхний регистр
|
||||
*/
|
||||
this.ucfirst = function(str) {
|
||||
var f = str.charAt(0).toUpperCase();
|
||||
return f + str.substr(1, str.length-1);
|
||||
}
|
||||
|
||||
return this;
|
||||
}).call(ls.tools || {},jQuery);
|
||||
|
||||
|
||||
/**
|
||||
* Дополнительные функции
|
||||
*/
|
||||
|
|
|
@ -1,19 +1,23 @@
|
|||
var vote = {
|
||||
//==================
|
||||
// Опции
|
||||
//==================
|
||||
var ls = ls || {};
|
||||
|
||||
/**
|
||||
* Динамическая подгрузка блоков
|
||||
*/
|
||||
ls.vote = (function ($) {
|
||||
/**
|
||||
* Опции
|
||||
*/
|
||||
this.options = {
|
||||
classes: {
|
||||
voted: 'voted',
|
||||
plus: 'plus',
|
||||
minus: 'minus',
|
||||
positive: 'positive',
|
||||
negative: 'negative',
|
||||
total: 'total'
|
||||
negative: 'negative'
|
||||
},
|
||||
|
||||
|
||||
typeVote: {
|
||||
prefix_area: 'vote_area_',
|
||||
prefix_total: 'vote_total_',
|
||||
type: {
|
||||
comment: {
|
||||
url: aRouter['ajax']+'vote/comment/',
|
||||
targetName: 'idComment'
|
||||
|
@ -30,70 +34,69 @@ var vote = {
|
|||
url: aRouter['ajax']+'vote/user/',
|
||||
targetName: 'idUser'
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
this.vote = function(idTarget, objVote, value, type) {
|
||||
if (!this.options.type[type]) return false;
|
||||
|
||||
//==================
|
||||
// Функции
|
||||
//==================
|
||||
|
||||
vote: function(idTarget, objVote, value, type) {
|
||||
if (!this.typeVote[type]) return false;
|
||||
|
||||
this.idTarget = idTarget;
|
||||
this.objVote = $(objVote);
|
||||
this.value = value;
|
||||
thisObj = this;
|
||||
|
||||
objVote = $(objVote);
|
||||
var params = {};
|
||||
params['value'] = value;
|
||||
params[this.typeVote[type].targetName] = idTarget;
|
||||
params['security_ls_key'] = LIVESTREET_SECURITY_KEY;
|
||||
params[this.options.type[type].targetName] = idTarget;
|
||||
|
||||
$.post(this.typeVote[type].url, params, function(result) {
|
||||
thisObj.onVote(result, thisObj);
|
||||
});
|
||||
},
|
||||
ls.ajax(this.options.type[type].url, params, function(result) {
|
||||
this.onVote(idTarget, objVote, value, type, result);
|
||||
}.bind(this));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
onVote: function(result, thisObj) {
|
||||
this.onVote = function(idTarget, objVote, value, type, result) {
|
||||
if (result.bStateError) {
|
||||
$.notifier.error(null, result.sMsg);
|
||||
ls.msg.error(null, result.sMsg);
|
||||
} else {
|
||||
$.notifier.notice(null, result.sMsg);
|
||||
ls.msg.notice(null, result.sMsg);
|
||||
|
||||
var divVoting = thisObj.objVote.parent();
|
||||
divVoting.addClass(thisObj.classes.voted);
|
||||
var divVoting = $('#'+this.options.prefix_area+type+'_'+idTarget);
|
||||
divVoting.addClass(this.options.classes.voted);
|
||||
|
||||
if (thisObj.value > 0) {
|
||||
divVoting.addClass(thisObj.classes.plus);
|
||||
if (value > 0) {
|
||||
divVoting.addClass(this.options.classes.plus);
|
||||
}
|
||||
if (thisObj.value < 0) {
|
||||
divVoting.addClass(thisObj.classes.minus);
|
||||
if (value < 0) {
|
||||
divVoting.addClass(this.options.classes.minus);
|
||||
}
|
||||
|
||||
var divTotal = divVoting.children('.'+thisObj.classes.total);
|
||||
var divTotal = $('#'+this.options.prefix_total+type+'_'+idTarget);
|
||||
|
||||
result.iRating = parseFloat(result.iRating);
|
||||
|
||||
divVoting.removeClass(thisObj.classes.negative);
|
||||
divVoting.removeClass(thisObj.classes.positive);
|
||||
divVoting.removeClass(this.options.classes.negative);
|
||||
divVoting.removeClass(this.options.classes.positive);
|
||||
|
||||
if (result.iRating > 0) {
|
||||
divVoting.addClass(thisObj.classes.positive);
|
||||
divVoting.addClass(this.options.classes.positive);
|
||||
divTotal.text(result.iRating);
|
||||
}
|
||||
if (result.iRating < 0) {
|
||||
divVoting.addClass(thisObj.classes.negative);
|
||||
divVoting.addClass(this.options.classes.negative);
|
||||
divTotal.text(result.iRating);
|
||||
}
|
||||
if (result.iRating == 0) {
|
||||
divTotal.text(0);
|
||||
}
|
||||
|
||||
if (thisObj.type == 'user') {
|
||||
$('#user_skill_'+thisObj.idTarget).text(result.iSkill);
|
||||
var method='onVote'+ls.tools.ucfirst(type);
|
||||
if (typeof(this[method])=='function') {
|
||||
this[method].apply(this,[idTarget, objVote, value, type, result]);
|
||||
}
|
||||
}
|
||||
$(this).trigger('vote',[idTarget, objVote, value, type, result]);
|
||||
}
|
||||
}
|
||||
|
||||
this.onVoteUser = function(idTarget, objVote, value, type, result) {
|
||||
$('#user_skill_'+idTarget).text(result.iSkill);
|
||||
}
|
||||
|
||||
return this;
|
||||
}).call(ls.vote || {},jQuery);
|
|
@ -72,10 +72,10 @@
|
|||
|
||||
|
||||
<ul class="info">
|
||||
<li class="voting {if $oVote || ($oUserCurrent && $oTopic->getUserId()==$oUserCurrent->getId()) || strtotime($oTopic->getDateAdd())<$smarty.now-$oConfig->GetValue('acl.vote.topic.limit_time')}{if $oTopic->getRating()>0}positive{elseif $oTopic->getRating()<0}negative{/if}{/if} {if !$oUserCurrent || $oTopic->getUserId()==$oUserCurrent->getId() || strtotime($oTopic->getDateAdd())<$smarty.now-$oConfig->GetValue('acl.vote.topic.limit_time')}guest{/if}{if $oVote} voted {if $oVote->getDirection()>0}plus{elseif $oVote->getDirection()<0}minus{/if}{/if}">
|
||||
<a href="#" class="plus" onclick="vote.vote({$oTopic->getId()},this,1,'topic'); return false;"></a>
|
||||
<span class="total" title="{$aLang.topic_vote_count}: {$oTopic->getCountVote()}">{if $oVote || ($oUserCurrent && $oTopic->getUserId()==$oUserCurrent->getId()) || strtotime($oTopic->getDateAdd())<$smarty.now-$oConfig->GetValue('acl.vote.topic.limit_time')} {$oTopic->getRating()} {else} <a href="#" onclick="vote.vote({$oTopic->getId()},this,0,'topic'); return false;">?</a> {/if}</span>
|
||||
<a href="#" class="minus" onclick="vote.vote({$oTopic->getId()},this,-1,'topic'); return false;"></a>
|
||||
<li id="vote_area_topic_{$oTopic->getId()}" class="voting {if $oVote || ($oUserCurrent && $oTopic->getUserId()==$oUserCurrent->getId()) || strtotime($oTopic->getDateAdd())<$smarty.now-$oConfig->GetValue('acl.vote.topic.limit_time')}{if $oTopic->getRating()>0}positive{elseif $oTopic->getRating()<0}negative{/if}{/if} {if !$oUserCurrent || $oTopic->getUserId()==$oUserCurrent->getId() || strtotime($oTopic->getDateAdd())<$smarty.now-$oConfig->GetValue('acl.vote.topic.limit_time')}guest{/if}{if $oVote} voted {if $oVote->getDirection()>0}plus{elseif $oVote->getDirection()<0}minus{/if}{/if}">
|
||||
<a href="#" class="plus" onclick="return ls.vote.vote({$oTopic->getId()},this,1,'topic');"></a>
|
||||
<span id="vote_total_topic_{$oTopic->getId()}" class="total" title="{$aLang.topic_vote_count}: {$oTopic->getCountVote()}">{if $oVote || ($oUserCurrent && $oTopic->getUserId()==$oUserCurrent->getId()) || strtotime($oTopic->getDateAdd())<$smarty.now-$oConfig->GetValue('acl.vote.topic.limit_time')} {$oTopic->getRating()} {else} <a href="#" onclick="return ls.vote.vote({$oTopic->getId()},this,0,'topic');">?</a> {/if}</span>
|
||||
<a href="#" class="minus" onclick="return ls.vote.vote({$oTopic->getId()},this,-1,'topic');"></a>
|
||||
</li>
|
||||
<li class="username"><a href="{$oUser->getUserWebPath()}">{$oUser->getLogin()}</a></li>
|
||||
<li class="date">{date_format date=$oTopic->getDateAdd()}</li>
|
||||
|
|
Loading…
Reference in a new issue