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 07:53:06 +00:00
parent c98ad406a0
commit a5bd56aa23
7 changed files with 51 additions and 59 deletions

View file

@ -29,7 +29,7 @@
</td>
<td align="center">
<a href="#" onclick="favourite.toggle({$oTalk->getId()},this,'talk'); return false;" class="favourite {if $oTalk->getIsFavourite()}active{/if}"></a>
<a href="#" onclick="return ls.favourite.toggle({$oTalk->getId()},this,'talk');" class="favourite {if $oTalk->getIsFavourite()}active{/if}"></a>
</td>
<td>
{if $oTalkUserAuthor->getCommentCountNew() or !$oTalkUserAuthor->getDateLast()}

View file

@ -30,7 +30,7 @@
{/foreach}
</td>
<td align="center">
<a href="#" onclick="favourite.toggle({$oTalk->getId()},this,'talk'); return false;" class="favourite {if $oTalk->getIsFavourite()}active{/if}"></a>
<a href="#" onclick="return ls.favourite.toggle({$oTalk->getId()},this,'talk');" class="favourite {if $oTalk->getIsFavourite()}active{/if}"></a>
</td>
<td>
{if $oTalkUserAuthor->getCommentCountNew() or !$oTalkUserAuthor->getDateLast()}

View file

@ -18,7 +18,7 @@
<ul class="info">
<li class="username"><a href="{$oUser->getUserWebPath()}">{$oUser->getLogin()}</a></li>
<li class="date">{date_format date=$oTalk->getDate()}</li>
<li><a href="#" onclick="lsFavourite.toggle({$oTalk->getId()},this,'talk'); return false;" class="favorite {if $oTalk->getIsFavourite()}active{/if}"></a></li>
<li><a href="#" onclick="return ls.favourite.toggle({$oTalk->getId()},this,'talk');" class="favourite {if $oTalk->getIsFavourite()}active{/if}"></a></li>
</ul>
</div>

View file

@ -16,7 +16,7 @@
{/if}
<li class="goto-comment-child"><a href="#" title="{$aLang.comment_goto_child}">↓</a></li>
{if $oUserCurrent and !$bNoCommentFavourites}
<li><a href="#" onclick="favourite.toggle({$oComment->getId()},this,'comment'); return false;" class="favourite {if $oComment->getIsFavourite()}active{/if}"></a></li>
<li><a href="#" onclick="return ls.favourite.toggle({$oComment->getId()},this,'comment');" class="favourite {if $oComment->getIsFavourite()}active{/if}"></a></li>
{/if}
{if !$oComment->getDelete() and $oUserCurrent and $oUserCurrent->isAdministrator()}
<li><a href="#" class="delete" onclick="comments.toggle(this,{$oComment->getId()}); return false;">{$aLang.comment_delete}</a></li>

View file

@ -1,64 +1,56 @@
var favourite = {
//==================
// Опции
//==================
var ls = ls || {};
classes: {
active: 'active',
favourite: 'favourite'
},
typeFavourite: {
topic: {
url: aRouter['ajax']+'favourite/topic/',
targetName: 'idTopic'
},
talk: {
url: aRouter['ajax']+'favourite/talk/',
targetName: 'idTalk'
},
comment: {
url: aRouter['ajax']+'favourite/comment/',
targetName: 'idComment'
/**
* Добавление в избранное
*/
ls.favourite = (function ($) {
/**
* Опции
*/
this.options = {
active: 'active',
type: {
topic: {
url: aRouter['ajax']+'favourite/topic/',
targetName: 'idTopic'
},
talk: {
url: aRouter['ajax']+'favourite/talk/',
targetName: 'idTalk'
},
comment: {
url: aRouter['ajax']+'favourite/comment/',
targetName: 'idComment'
}
}
},
//==================
// Функции
//==================
// Добавить/удалить из избранного
toggle: function(idTarget, objFavourite, type) {
if (!this.typeFavourite[type]) { return false; }
};
this.objFavourite = $(objFavourite);
this.type = type;
thisObj = this;
var value = 1;
if (this.objFavourite.hasClass(this.classes.active)) {
value = 0;
}
/**
* Переключение избранного
*/
this.toggle = function(idTarget, objFavourite, type) {
if (!this.options.type[type]) { return false; }
this.objFavourite = $(objFavourite);
var params = {};
params['type'] = value;
params[this.typeFavourite[type].targetName] = idTarget;
params['security_ls_key'] = LIVESTREET_SECURITY_KEY;
params['type'] = !this.objFavourite.hasClass(this.options.active);
params[this.options.type[type].targetName] = idTarget;
$.post(this.typeFavourite[type].url, params, function(result) {
ls.ajax(this.options.type[type].url, params, function(result) {
$(this).trigger('toggle',[idTarget,objFavourite,type,params,result]);
if (result.bStateError) {
$.notifier.error(null, result.sMsg);
ls.msg.error(null, result.sMsg);
} else {
$.notifier.notice(null, result.sMsg);
var divFavourite = thisObj.objFavourite;
divFavourite.removeClass(thisObj.classes.active);
ls.msg.notice(null, result.sMsg);
this.objFavourite.removeClass(this.options.active);
if (result.bState) {
divFavourite.addClass(thisObj.classes.active);
this.objFavourite.addClass(this.options.active);
}
}
});
}
}.bind(this));
return false;
}
}
return this;
}).call(ls.favourite || {},jQuery);

View file

@ -9,7 +9,7 @@ var vote = {
minus: 'minus',
positive: 'positive',
negative: 'negative',
total: 'total',
total: 'total'
},

View file

@ -79,7 +79,7 @@
</li>
<li class="username"><a href="{$oUser->getUserWebPath()}">{$oUser->getLogin()}</a></li>
<li class="date">{date_format date=$oTopic->getDateAdd()}</li>
<li><a href="#" onclick="favourite.toggle({$oTopic->getId()},this,'topic'); return false;" class="favourite {if $oUserCurrent && $oTopic->getIsFavourite()}active{/if}"></a></li>
<li><a href="#" onclick="return ls.favourite.toggle({$oTopic->getId()},this,'topic');" class="favourite {if $oUserCurrent && $oTopic->getIsFavourite()}active{/if}"></a></li>
{if $oTopic->getType()=='link'}
<li><a href="{router page='link'}go/{$oTopic->getId()}/" title="{$aLang.topic_link_count_jump}: {$oTopic->getLinkCountJump()}">{$oTopic->getLinkUrl(true)}</a></li>
{/if}