1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-06-29 04:55:02 +03:00

fix developer-jquery

This commit is contained in:
Mzhelskiy Maxim 2011-05-03 10:10:28 +00:00
parent e0a109c13d
commit a29dc1735e
6 changed files with 115 additions and 95 deletions

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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);
/**
* Дополнительные функции
*/

View file

@ -1,99 +1,102 @@
var vote = {
//==================
// Опции
//==================
classes: {
voted: 'voted',
plus: 'plus',
minus: 'minus',
positive: 'positive',
negative: 'negative',
total: 'total'
},
typeVote: {
comment: {
url: aRouter['ajax']+'vote/comment/',
targetName: 'idComment'
var ls = ls || {};
/**
* Динамическая подгрузка блоков
*/
ls.vote = (function ($) {
/**
* Опции
*/
this.options = {
classes: {
voted: 'voted',
plus: 'plus',
minus: 'minus',
positive: 'positive',
negative: 'negative'
},
topic: {
url: aRouter['ajax']+'vote/topic/',
targetName: 'idTopic'
},
blog: {
url: aRouter['ajax']+'vote/blog/',
targetName: 'idBlog'
},
user: {
url: aRouter['ajax']+'vote/user/',
targetName: 'idUser'
prefix_area: 'vote_area_',
prefix_total: 'vote_total_',
type: {
comment: {
url: aRouter['ajax']+'vote/comment/',
targetName: 'idComment'
},
topic: {
url: aRouter['ajax']+'vote/topic/',
targetName: 'idTopic'
},
blog: {
url: aRouter['ajax']+'vote/blog/',
targetName: 'idBlog'
},
user: {
url: aRouter['ajax']+'vote/user/',
targetName: 'idUser'
}
}
},
//==================
// Функции
//==================
vote: function(idTarget, objVote, value, type) {
if (!this.typeVote[type]) return false;
this.idTarget = idTarget;
this.objVote = $(objVote);
this.value = value;
thisObj = this;
};
this.vote = function(idTarget, objVote, value, type) {
if (!this.options.type[type]) return false;
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);
});
},
onVote: function(result, thisObj) {
ls.ajax(this.options.type[type].url, params, function(result) {
this.onVote(idTarget, objVote, value, type, result);
}.bind(this));
return false;
}
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);
var divVoting = thisObj.objVote.parent();
divVoting.addClass(thisObj.classes.voted);
ls.msg.notice(null, result.sMsg);
if (thisObj.value > 0) {
divVoting.addClass(thisObj.classes.plus);
var divVoting = $('#'+this.options.prefix_area+type+'_'+idTarget);
divVoting.addClass(this.options.classes.voted);
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);
result.iRating = parseFloat(result.iRating);
divVoting.removeClass(thisObj.classes.negative);
divVoting.removeClass(thisObj.classes.positive);
if (result.iRating > 0) {
divVoting.addClass(thisObj.classes.positive);
var divTotal = $('#'+this.options.prefix_total+type+'_'+idTarget);
result.iRating = parseFloat(result.iRating);
divVoting.removeClass(this.options.classes.negative);
divVoting.removeClass(this.options.classes.positive);
if (result.iRating > 0) {
divVoting.addClass(this.options.classes.positive);
divTotal.text(result.iRating);
}
if (result.iRating < 0) {
divVoting.addClass(thisObj.classes.negative);
if (result.iRating < 0) {
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);

View file

@ -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>