1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-06-26 03:30:48 +03:00

Доработка компонента toolbar

This commit is contained in:
Denis Shakhov 2015-02-17 21:40:18 +07:00
parent 7d92d40fd0
commit 7b51f40d0d
15 changed files with 120 additions and 122 deletions

View file

@ -3,13 +3,12 @@
* Кнопка перехода в админку
*}
{extends 'component@toolbar.toolbar.item'}
{block 'toolbar_item_options' append}
{$_mods = 'admin'}
{$_bShow = $oUserCurrent && $oUserCurrent->isAdministrator()}
{/block}
{block 'toolbar_item'}
{toolbar_item_icon url="{router page='admin'}" title="{lang name='admin.title'}" icon="icon-cog"}
{/block}
{if $oUserCurrent && $oUserCurrent->isAdministrator()}
{component 'toolbar' template='item'
buttons = [[
url => {router 'admin'},
attributes => [ 'title' => {lang 'admin.title'} ],
icon => 'cog'
]]
mods = 'admin'}
{/if}

View file

@ -2,25 +2,21 @@
* Модальное окно с формами входа, регистрации и напоминанием пароля
*}
{capture 'modal_content'}
{if ! Config::Get('general.reg.invite')}
{component 'auth' template='registration' assign=auth_tab_reg}
{else}
{component 'auth' template='invite' assign=auth_tab_reg}
{/if}
{component 'tabs' classes='js-tabs-auth' tabs=[
[ 'text' => {lang 'auth.login.title'}, 'content' => {component 'auth' template='login'}, 'classes' => 'js-auth-tab-login' ],
[ 'text' => {lang 'auth.registration.title'}, 'content' => $auth_tab_reg, 'classes' => 'js-auth-tab-reg' ],
[ 'text' => {lang 'auth.reset.title'}, 'content' => {component 'auth' template='reset'} ]
]}
{/capture}
{if ! Config::Get('general.reg.invite')}
{component 'auth' template='registration' assign=auth_tab_reg}
{else}
{component 'auth' template='invite' assign=auth_tab_reg}
{/if}
{component 'modal'
title = {lang 'auth.authorization'}
tabs = $smarty.capture.modal_content
options = [ 'center' => 'false' ]
showFooter = false
classes = 'js-modal-default'
mods = 'auth'
id = 'modal-login'}
id = 'modal-login'
tabs = [ 'tabs' => [
[ 'text' => {lang 'auth.login.title'}, 'content' => {component 'auth' template='login'}, 'classes' => 'js-auth-tab-login' ],
[ 'text' => {lang 'auth.registration.title'}, 'content' => $auth_tab_reg, 'classes' => 'js-auth-tab-reg' ],
[ 'text' => {lang 'auth.reset.title'}, 'content' => {component 'auth' template='reset'} ]
]]}

View file

@ -40,7 +40,9 @@
{/if}
{/block}
{add_block group='toolbar' name='component@comment.toolbar' target='.js-comment'}
{if $oUserCurrent}
{add_block group='toolbar' name='component@comment.toolbar' target='.js-comment'}
{/if}
<div class="{$component} js-comments {cmods name=$component mods=$mods} {$smarty.local.classes}"
data-target-type="{$targetType}"

View file

@ -1,22 +1,9 @@
/**
* Кнопка обновления комментариев
*
* @template toolbar/toolbar.comment.tpl
* @template toolbar.comment.tpl
*/
.toolbar-item--comments .toolbar-comments-update {
padding: 9px;
cursor: pointer;
}
.toolbar-item--comments .toolbar-comments-update i {
display: block;
width: 16px;
height: 16px;
background: url(../images/update.gif) no-repeat;
}
.toolbar-item--comments .toolbar-comments-update.active i {
background-position: -16px 0;
}
.toolbar-item--comments .toolbar-comments-count {
border-top: 1px solid #eee;
padding: 10px 0;
@ -24,4 +11,11 @@
text-align: center;
font-size: 11px;
cursor: pointer;
}
.icon-comment-update {
background-image: url(../images/update.gif);
}
.toolbar-comments-update.active .icon-comment-update {
background-position: -16px 0;
}

View file

@ -68,9 +68,10 @@
count = typeof count === 'undefined' ? this.options.comments.lsComments( 'getCommentsNew' ).length : count;
if ( count ) {
this.elements.counter.show().text( count );
this.showCounter();
this.elements.counter.text( count );
} else {
this.elements.counter.hide();
this.hideCounter();
}
},
@ -86,6 +87,22 @@
}.bind( this ));
},
/**
* Показывает счетчик
*/
showCounter: function() {
if ( this.elements.counter.is( ':visible' ) ) return;
this.element.append( this.elements.counter.show() );
},
/**
* Скрывает счетчик
*/
hideCounter: function() {
this.elements.counter.hide().detach();
},
/**
* Прокрутка к следующему новому комментарию
*/

View file

@ -3,16 +3,23 @@
* Кнопка обновления комментариев
*}
{extends 'component@toolbar.toolbar.item'}
{block 'toolbar_item_options' append}
{$_mods = 'comments'}
{$_bShow = !! $oUserCurrent}
{$_classes = 'js-comments-toolbar'}
{$_attributes = [ 'data-target' => '.js-comment' ]}
{/block}
{block 'toolbar_item'}
{capture 'toolbar_item'}
<div class="toolbar-comments-update js-toolbar-comments-update"><i></i></div>
<div class="toolbar-comments-count js-toolbar-comments-count" style="display: none;" title="{$aLang.comments.comment.count_new}"></div>
{/block}
{/capture}
{component 'toolbar' template='item'
classes = 'js-comments-toolbar'
mods = 'comments'
buttons = [
[
classes => 'toolbar-comments-update js-toolbar-comments-update',
attributes => [ 'title' => {lang 'comments.comment.count_new'} ],
icon => 'comment-update'
],
[
classes => 'js-toolbar-comments-count',
attributes => [ 'title' => {lang 'comments.comment.count_new'} ],
text => '12'
]
]}

View file

@ -3,15 +3,18 @@
* Кнопка прокручивания к следующему/предыдущему топику
*}
{extends 'component@toolbar.toolbar.item'}
{block 'toolbar_item_options' append}
{$_mods = 'topic'}
{$_classes = 'js-toolbar-topics'}
{$_bShow = $params.show}
{/block}
{block 'toolbar_item'}
{toolbar_item_icon classes='toolbar-topic-prev js-toolbar-topics-prev' title="{lang 'toolbar.topic_nav.prev'}" icon="icon-arrow-up"}
{toolbar_item_icon classes='toolbar-topic-next js-toolbar-topics-next' title="{lang 'toolbar.topic_nav.next'}" icon="icon-arrow-down"}
{/block}
{component 'toolbar' template='item'
classes = 'js-toolbar-topics'
mods = 'topic'
buttons = [
[
classes => 'toolbar-topic-prev js-toolbar-topics-prev',
attributes => [ 'title' => {lang 'toolbar.topic_nav.prev'} ],
icon => 'arrow-up'
],
[
classes => 'toolbar-topic-next js-toolbar-topics-next',
attributes => [ 'title' => {lang 'toolbar.topic_nav.next'} ],
icon => 'arrow-down'
]
]}

View file

@ -1,5 +1,7 @@
/**
* Кнопка прокрутки вверх
*
* TODO: Fix icons;
*/
.toolbar-item--scrollup { display: none; }

View file

@ -27,8 +27,8 @@
* @private
*/
_create: function () {
this._on( { 'click': this.onClick } );
this._on( this.window, { 'scroll': this.onScroll } );
this._on({ click: 'onClick' });
this._on( this.window, { scroll: 'onScroll' } );
},
/**

View file

@ -1,19 +1,12 @@
{**
* Тулбар
* Кнопка прокрутки страницы вверх
*
* @styles css/toolbar.css
* @scripts js/livestreet/toolbar.js
*}
{extends 'component@toolbar.toolbar.item'}
{block 'toolbar_item_options' append}
{$_mods = 'scrollup'}
{$_classes = 'js-toolbar-scrollup'}
{$_attributes = [ 'id' => 'toolbar_scrollup' ]}
{/block}
{block 'toolbar_item'}
{toolbar_item_icon title="{lang 'toolbar.scrollup.title'}" icon="icon-chevron-up"}
{/block}
{component 'toolbar' template='item'
classes='toolbar-item--scrollup js-toolbar-scrollup'
attributes=[ 'style' => 'display: none' ]
buttons=[[
'icon' => 'chevron-up',
'attributes' => [ 'title' => {lang 'toolbar.scrollup.title'}, 'id' => 'toolbar_scrollup' ]
]]}

View file

@ -11,7 +11,7 @@
(function($) {
"use strict";
$.widget( "livestreet.lsUserFollow", {
$.widget( "livestreet.lsUserFollow", $.livestreet.lsComponent, {
/**
* Дефолтные опции
*/
@ -23,7 +23,11 @@
// Отписаться
unfollow: null
}
},
classes: {
active: 'active'
},
params: {}
},
/**
@ -33,7 +37,8 @@
* @private
*/
_create: function () {
this._on({ click: this.onClick });
this._super();
this._on({ click: 'onClick' });
},
/**
@ -48,28 +53,28 @@
* Подписаться
*/
follow: function() {
ls.ajax.load( this.option( 'urls.follow' ), { aUserList: [ this.element.data('login') ] }, this.onFollow.bind(this) );
this._load( 'follow', { users: [ this.element.data('login') ] }, 'onFollow' );
},
/**
* Коллбэк вызываемый при подписке
*/
onFollow: function( response ) {
this.element.addClass( ls.options.classes.states.active ).text( ls.lang.get('user.actions.unfollow') );
this._addClass( 'active' ).text( ls.lang.get('user.actions.unfollow') );
},
/**
* Отписаться
*/
unfollow: function() {
ls.ajax.load( this.option( 'urls.unfollow' ), { iUserId: this.element.data('id') }, this.onUnfollow.bind(this) );
this._load( 'unfollow', { user_id: this.element.data('id') }, 'onUnfollow' );
},
/**
* Коллбэк вызываемый при отписке
*/
onUnfollow: function( response ) {
this.element.removeClass( ls.options.classes.states.active ).text( ls.lang.get('user.actions.follow') );
this._removeClass( 'active' ).text( ls.lang.get('user.actions.follow') );
}
});
})(jQuery);

View file

@ -11,7 +11,7 @@
(function($) {
"use strict";
$.widget( "livestreet.lsUserFriend", {
$.widget( "livestreet.lsUserFriend", $.livestreet.lsComponent, {
/**
* Дефолтные опции
*/
@ -43,9 +43,11 @@
* @private
*/
_create: function () {
this._super();
this.target = this.element.data( 'target' );
this._on({ click: this.onClick });
this._on({ click: 'onClick' });
},
/**
@ -135,41 +137,25 @@
* Повторное подтверждение
*/
addLinked: function() {
this.accept( this.option( 'urls.add' ) );
this.accept( 'add' );
},
/**
* Подтверждение
*/
accept: function( url ) {
ls.ajax.load( url || this.option( 'urls.accept' ), {
idUser: this.target,
}, function( response ) {
if ( response.bStateError ) {
ls.msg.error( null, response.sMsg );
} else {
ls.msg.notice( null, response.sMsg );
this.setStatus( 'added' );
}
}.bind(this));
this._load( url || 'accept', { idUser: this.target }, function( response ) {
this.setStatus( 'added' );
});
},
/**
* Удаление из друзей
*/
remove: function() {
ls.ajax.load( this.option( 'urls.remove' ), {
idUser: this.target
}, function( response ) {
if ( response.bStateError ) {
ls.msg.error(null,response.sMsg);
} else {
ls.msg.notice(null,response.sMsg);
this.setStatus( 'linked' );
}
}.bind(this));
this._load( 'remove', { idUser: this.target }, function( response ) {
this.setStatus( 'linked' );
});
}
});
})(jQuery);

View file

@ -65,12 +65,6 @@ jQuery(document).ready(function($){
});
/**
* Tabs
*/
$( '.js-tabs-auth' ).lsTabs();
/**
* Fields
*/
@ -549,7 +543,7 @@ jQuery(document).ready(function($){
/**
* Toolbar
*/
$('.js-toolbar').lsToolbar({
$('.js-toolbar-default').lsToolbar({
target: '.grid-role-wrapper',
offsetX: 10
});

View file

@ -176,5 +176,5 @@
{add_block group='toolbar' name='component@toolbar-scrollup.toolbar.scrollup' priority=-100}
{* Подключение тулбара *}
{component 'toolbar'}
{component 'toolbar' classes='js-toolbar-default' items={include 'blocks.tpl' group='toolbar'}}
{/block}

@ -1 +1 @@
Subproject commit 6096d5003ab32e5d2ed67ed10c325ddd55de1428
Subproject commit b959798ea07f3d5780f5a24776391b48b9fda1ba