1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-05-19 01:08:19 +03:00

Fixes #722 Доработка аякс поиска

This commit is contained in:
Denis Shakhov 2015-11-02 23:22:39 +07:00
parent b3cf245d31
commit 83430311ce
9 changed files with 88 additions and 35 deletions

View file

@ -95,15 +95,18 @@ class HookMain extends Hook
'comments.folding.unfold_all',
'comments.folding.fold_all',
'poll.notices.error_answers_max',
'blog.blog',
'favourite.add',
'favourite.remove',
'field.geo.select_city',
'field.geo.select_region',
'blog.blog',
'blog.add.fields.type.note_open',
'blog.add.fields.type.note_close',
'blog.search.result_title',
'blog.blocks.navigator.blog',
'common.success.add',
'common.success.remove',
'common.remove_confirm',
'pagination.notices.first',
'pagination.notices.last',
'user.actions.unfollow',
@ -114,9 +117,8 @@ class HookMain extends Hook
'user.friends.status.rejected',
'user.friends.status.sent',
'user.friends.status.linked',
'blog.blocks.navigator.blog',
'user.settings.profile.notices.error_max_userfields',
'common.remove_confirm',
'user.search.result_title',
'more.empty',
'validate.tags.count'
));

View file

@ -5,20 +5,16 @@
* @param array $pagination
* @param boolean $useMore
* @param boolean $hideMore
* @param integer $searchCount
* @param string $textEmpty
*}
{if $smarty.local.blogs}
{$paging = $smarty.local.pagination}
{* Заголовок *}
{if $smarty.local.searchCount}
<h3 class="h3">{lang name='blog.search.result_title' count=$smarty.local.searchCount plural=true}</h3>
{/if}
{* Список блогов *}
{component 'item' template='group' classes='js-more-blogs-container' items={component 'blog' template='list-loop' blogs=$smarty.local.blogs}}
{component 'item' template='group'
classes = 'js-more-blogs-container'
items = {component 'blog' template='list-loop' blogs=$smarty.local.blogs}}
{* Кнопка подгрузки *}
{if $smarty.local.useMore}
@ -32,5 +28,5 @@
{component 'pagination' total=+$paging.iCountPage current=+$paging.iCurrentPage url="{$paging.sBaseUrl}/page__page__/{$paging.sGetParams}"}
{/if}
{else}
{component 'blankslate' text=(($smarty.local.textEmpty) ? $smarty.local.textEmpty : $aLang.blog.alerts.empty)}
{component 'blankslate' text=$smarty.local.textEmpty|default:{lang name='blog.alerts.empty'}}
{/if}

View file

@ -5,6 +5,7 @@
"ls-component": "*",
"user-list-add": "*",
"search-form": "*",
"search-ajax": "*",
"button": "*",
"modal": "*",
"block": "*",

View file

@ -23,7 +23,18 @@
// Селекторы
selectors: {
more: '.js-more-search'
list: '.js-search-ajax-list',
more: '.js-search-ajax-more'
},
// Селекторы внешних элементов
extSelectors: {
title: null
},
// Локализация
i18n: {
title: null
},
// Фильтры
@ -44,21 +55,21 @@
var _this = this;
this.extElements = this._getElementsFromSelectors( this.options.extSelectors );
// Иниц-ия фильтров
$.each( this.option( 'filters' ), function ( index, value ) {
_this._initFilter( value );
});
// Кнопка подгрузки
this.elements.more.livequery(function () {
$( this ).lsMore({
urls: {
load: _this.option( 'urls.search' )
},
beforeload: function ( event, context ) {
$.extend( context.option( 'params' ), _this.option( 'params' ) );
}
});
this.elements.more.lsMore({
urls: {
load: _this.option( 'urls.search' )
},
beforeload: function ( event, context ) {
$.extend( context.option( 'params' ), _this.option( 'params' ) );
}
});
},
@ -197,9 +208,28 @@
this.updateFilter( this.option( 'filters' )[i] );
};
this._load( 'search', function ( response ) {
this.element.html( $.trim( response.html ) );
});
this._trigger( 'beforeupdate', null, this );
this._load( 'search', 'onUpdate' );
},
/**
*
*/
onUpdate: function ( response ) {
this.elements.more[ response.hide ? 'hide' : 'show' ]();
if ( response.searchCount ) {
this.elements.list.show().html( $.trim( response.html ) );
} else {
this.elements.list.hide();
}
if ( this.option( 'i18n.title' ) && this.extElements.title.length ) {
this.extElements.title.show().text( ls.lang.pluralize( response.searchCount, this.option( 'i18n.title' ) ) );
}
this._trigger( 'afterupdate', null, { context: this, response: response } );
},
/**

View file

@ -5,20 +5,12 @@
* @param array $pagination
* @param boolean $useMore
* @param boolean $hideMore
* @param integer $searchCount
* @param string $textEmpty
*}
{if $smarty.local.users}
{$pagination = $smarty.local.pagination}
{* Заголовок *}
{if $smarty.local.searchCount}
<h3 class="h3">
{lang name='user.search.result_title' count=$smarty.local.searchCount plural=true}
</h3>
{/if}
{* Список пользователей *}
{component 'item' template='group'
classes = 'js-more-users-container'

View file

@ -29,7 +29,10 @@
[ name => 'blog_title', text => $aLang.sort.by_title ]
]}
{* Список блогов *}
<div class="js-search-ajax-blog">
<h3 class="h3 js-blog-list-search-title" style="display: none"></h3>
{component 'blog' template='list' blogs=$blogs useMore=true}
</div>
{/block}

View file

@ -27,7 +27,10 @@
[ name => 'user_date_register', text => $aLang.sort.by_date_registration ]
]}
{* Список пользователей *}
<div class="js-search-ajax-users">
<h3 class="h3 js-user-list-search-title" style="display: none"></h3>
{component 'user' template='list' users=$users useMore=true}
</div>
{/block}

View file

@ -273,6 +273,16 @@ jQuery(document).ready(function($){
urls: {
search: aRouter.people + 'ajax-search/'
},
i18n: {
title: ls.lang.get( 'user.search.result_title' )
},
extSelectors: {
title: '.js-user-list-search-title'
},
selectors: {
list: '.js-more-users-container',
more: '.js-more-search'
},
filters : [
{
type: 'text',
@ -309,7 +319,10 @@ jQuery(document).ready(function($){
name: 'city',
selector: '.js-field-geo-city'
}
]
],
afterupdate: function ( event, data ) {
data.context.getElement( 'more' ).lsMore( 'option', 'params.next_page', 2 );
}
});
// Добавление пользователя в свою активность
@ -470,6 +483,16 @@ jQuery(document).ready(function($){
urls: {
search: aRouter.blogs + 'ajax-search/'
},
i18n: {
title: ls.lang.get( 'blog.search.result_title' )
},
extSelectors: {
title: '.js-blog-list-search-title'
},
selectors: {
list: '.js-more-blogs-container',
more: '.js-more-search'
},
filters : [
{
type: 'text',
@ -496,7 +519,10 @@ jQuery(document).ready(function($){
name: 'sort_by',
selector: '.js-search-sort-menu li'
}
]
],
afterupdate: function ( event, data ) {
data.context.getElement( 'more' ).lsMore( 'option', 'params.next_page', 2 );
}
});
// Аватар блога

@ -1 +1 @@
Subproject commit 7259712cad10c24b86e32579511bdccf8f64f270
Subproject commit fce2a720edf08e411eee114c3de1712294a5a08e