mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-07-01 05:55:02 +03:00
Мелкие исправления в виджетах
This commit is contained in:
parent
9a6f58b23b
commit
c8059b2ec0
|
@ -39,7 +39,7 @@
|
|||
this._super();
|
||||
|
||||
// Повторная отправка инвайта
|
||||
this.elements.list.on('click', this.options.selectors.item_reinvite, function (e) {
|
||||
this.elements.list.on('click' + this.eventNamespace, this.options.selectors.item_reinvite, function (e) {
|
||||
_this.reinvite( $(this).data('user-id') );
|
||||
e.preventDefault();
|
||||
});
|
||||
|
@ -49,12 +49,7 @@
|
|||
* Отправляет инвайт заново
|
||||
*/
|
||||
reinvite: function (iUserId) {
|
||||
var _this = this,
|
||||
oParams = {
|
||||
iUserId: iUserId
|
||||
};
|
||||
|
||||
oParams = $.extend({}, oParams, this.options.params);
|
||||
var oParams = $.extend({}, { iUserId: iUserId }, this.options.params);
|
||||
|
||||
ls.ajax.load(this.options.urls.reinvite, oParams, function(oResponse) {
|
||||
ls.msg.notice(null, oResponse.sMsg);
|
||||
|
|
|
@ -95,8 +95,7 @@
|
|||
* @private
|
||||
*/
|
||||
_create: function () {
|
||||
var _this = this,
|
||||
oDocument = $(document);
|
||||
var _this = this;
|
||||
|
||||
// Получаем элементы
|
||||
this.form = this.element.find(this.options.selectors.form.form);
|
||||
|
@ -149,33 +148,31 @@
|
|||
//
|
||||
|
||||
// Навигация по комментариям
|
||||
oDocument.on('click', this.options.selectors.comment.scroll_to_parent, function (e) {
|
||||
this.document.on('click' + this.eventNamespace, this.options.selectors.comment.scroll_to_parent, function (e) {
|
||||
var element = $(this);
|
||||
|
||||
_this.scrollToParentComment(element.data('id'), element.data('parent-id'));
|
||||
});
|
||||
|
||||
// Показывает / скрывает форму комментирования
|
||||
oDocument.on('click', this.options.selectors.comment.reply, function (e) {
|
||||
this.document.on('click' + this.eventNamespace, this.options.selectors.comment.reply, function (e) {
|
||||
_this.formToggle($(this).data('id'), true, false, false);
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
// Превью текста
|
||||
this.elements.form.preview.on('click', this.previewShow.bind(this));
|
||||
this._on( this.elements.form.preview, { 'click': this.previewShow } );
|
||||
|
||||
// Отправка формы
|
||||
this.form.on('submit', function (e) {
|
||||
this.add(this.form, this.form.data('target-id'), this.form.data('target-type'));
|
||||
this._on( this.form, { 'submit': function (e) {
|
||||
this.add( this.form, this.form.data('target-id'), this.form.data('target-type') );
|
||||
e.preventDefault();
|
||||
}.bind(this));
|
||||
}});
|
||||
|
||||
this.elements.form.text.bind('keyup', function(e) {
|
||||
if ( e.ctrlKey && (e.keyCode || e.which) == 13 ) _this.form.submit();
|
||||
});
|
||||
this.elements.form.text.bind( 'keydown' + this.eventNamespace, 'ctrl+return', function() { _this.form.submit() } );
|
||||
|
||||
// Удаление
|
||||
this.element.on('click', this.options.selectors.comment.remove, function(e) {
|
||||
this.element.on('click' + this.eventNamespace, this.options.selectors.comment.remove, function(e) {
|
||||
var element = $(this),
|
||||
commentId = element.data('id');
|
||||
|
||||
|
@ -185,7 +182,7 @@
|
|||
});
|
||||
|
||||
// Редактирование
|
||||
this.element.on('click', this.options.selectors.comment.update, function(e) {
|
||||
this.element.on('click' + this.eventNamespace, this.options.selectors.comment.update, function(e) {
|
||||
var element = $(this),
|
||||
commentId = element.data('id');
|
||||
|
||||
|
@ -194,19 +191,19 @@
|
|||
});
|
||||
|
||||
// Отмена редактирования
|
||||
this.elements.form.update_cancel.on('click', function (e) {
|
||||
this.elements.form.update_cancel.on('click' + this.eventNamespace, function (e) {
|
||||
this.formToggle(this.formTargetId, false, true);
|
||||
e.preventDefault();
|
||||
}.bind(this));
|
||||
|
||||
// Сохранение после редактирования
|
||||
this.elements.form.update_submit.on('click', function (e) {
|
||||
this.elements.form.update_submit.on('click' + this.eventNamespace, function (e) {
|
||||
this.submitCommentUpdate(this.formTargetId);
|
||||
e.preventDefault();
|
||||
}.bind(this));
|
||||
|
||||
// Подписаться/отписаться от новых комментариев
|
||||
this.elements.subscribe.on('click', function (e) {
|
||||
this.elements.subscribe.on('click' + this.eventNamespace, function (e) {
|
||||
var element = $(this),
|
||||
isActive = element.hasClass('active');
|
||||
|
||||
|
@ -224,7 +221,7 @@
|
|||
// Сворачивание
|
||||
if ( this.options.folding ) {
|
||||
// Свернуть/развернуть все
|
||||
this.elements.fold_all_toggle.on('click', function (e) {
|
||||
this.elements.fold_all_toggle.on('click' + this.eventNamespace, function (e) {
|
||||
var element = $(this);
|
||||
|
||||
if ( ! element.hasClass('active') ) {
|
||||
|
@ -239,7 +236,7 @@
|
|||
});
|
||||
|
||||
// Свернуть/развернуть
|
||||
this.element.on('click', this.options.selectors.comment.fold, function(e) {
|
||||
this.element.on('click' + this.eventNamespace, this.options.selectors.comment.fold, function(e) {
|
||||
var element = $(this),
|
||||
comment = _this.getCommentById(element.data('id'));
|
||||
|
||||
|
@ -384,11 +381,11 @@
|
|||
// Обновляем таймеры
|
||||
this.initUpdateTimers();
|
||||
|
||||
$.proxy(callbacks.success, this)();
|
||||
callbacks && $.proxy( callbacks.success, this )();
|
||||
ls.hook.run('ls_comments_load_after', [ this.targetId, this.targetType, сommentSelfId, flush, response ]);
|
||||
}
|
||||
|
||||
$.proxy(callbacks.done, this)();
|
||||
callbacks && $.proxy( callbacks.done, this )();
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
|
|
|
@ -49,17 +49,13 @@
|
|||
_create: function () {
|
||||
this.options.params = $.extend({}, this.options.params, ls.utils.getDataOptions(this.element, 'param'));
|
||||
|
||||
this.elements = {};
|
||||
this.elements.toggle = this.element.find(this.options.selectors.toggle);
|
||||
this.elements.count = this.element.find(this.options.selectors.count);
|
||||
this.elements = {
|
||||
toggle: this.element.find( this.options.selectors.toggle ),
|
||||
count: this.element.find( this.options.selectors.count )
|
||||
};
|
||||
|
||||
// Обработка кликов по кнопкам голосования
|
||||
this._on({
|
||||
'click': function (e) {
|
||||
this.toggle();
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
this._on({ 'click': this.toggle });
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -40,13 +40,13 @@
|
|||
this._super();
|
||||
|
||||
// Отключение пользователя от диалога
|
||||
this.elements.list.on('click', this.options.selectors.item_inactivate, function (e) {
|
||||
this.elements.list.on('click' + this.eventNamespace, this.options.selectors.item_inactivate, function (e) {
|
||||
_this.inactivate( $(this) );
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
// Повторное приглашение пользователя в диалог
|
||||
this.elements.list.on('click', this.options.selectors.item_activate, function (e) {
|
||||
this.elements.list.on('click' + this.eventNamespace, this.options.selectors.item_activate, function (e) {
|
||||
_this.add( [ $(this).data('user-login') ] );
|
||||
e.preventDefault();
|
||||
});
|
||||
|
@ -63,8 +63,7 @@
|
|||
* Повторное приглашение пользователя в диалог
|
||||
*/
|
||||
inactivate: function (oButton) {
|
||||
var _this = this,
|
||||
iUserId = oButton.data('user-id'),
|
||||
var iUserId = oButton.data('user-id'),
|
||||
oParams = {
|
||||
iUserId: iUserId
|
||||
};
|
||||
|
|
|
@ -82,16 +82,18 @@
|
|||
|
||||
ls.ajax.load(this.options.url, params, function (oResponse) {
|
||||
if (oResponse.iCountLoaded > 0) {
|
||||
var html=$('<div></div>').html($.trim(oResponse[this.options.result]));
|
||||
if (html.find(this.options.target).length) {
|
||||
html=html.find(this.options.target).first();
|
||||
var html = $('<div></div>').html( $.trim( oResponse[this.options.result] ) );
|
||||
|
||||
if ( html.find( this.options.target ).length ) {
|
||||
html = html.find( this.options.target ).first();
|
||||
}
|
||||
this.target[ this.options.append ? 'append' : 'prepend' ](html.html());
|
||||
this.element.data('param-i-last-id', oResponse.iLastId);
|
||||
|
||||
this.target[ this.options.append ? 'append' : 'prepend' ]( html.html() );
|
||||
this.element.data( 'param-i-last-id', oResponse.iLastId );
|
||||
|
||||
// Обновляем счетчик
|
||||
if (this.counter.length) {
|
||||
var iCountLeft = parseInt(this.counter.text(), 10) - oResponse.iCountLoaded;
|
||||
var iCountLeft = parseInt( this.counter.text(), 10 ) - oResponse.iCountLoaded;
|
||||
|
||||
if (iCountLeft <= 0) {
|
||||
this.element.remove();
|
||||
|
@ -99,18 +101,20 @@
|
|||
this.counter.text(iCountLeft);
|
||||
}
|
||||
}
|
||||
|
||||
// Обновляем параметры
|
||||
$.each(this.options.proxy,function(k,v){
|
||||
if (oResponse[k]) {
|
||||
this.options.proxy[k]=oResponse[k];
|
||||
$.each(this.options.proxy,function( k, v ) {
|
||||
if ( oResponse[k] ) {
|
||||
this.options.proxy[k] = oResponse[k];
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
if (oResponse.bHideMore) {
|
||||
if ( oResponse.bHideMore ) {
|
||||
this.element.remove();
|
||||
}
|
||||
} else {
|
||||
// Для блоков без счетчиков
|
||||
// TODO: i18n
|
||||
ls.msg.notice(null, 'Больше нечего подгружать');
|
||||
this.element.remove();
|
||||
}
|
||||
|
|
|
@ -45,13 +45,12 @@
|
|||
*/
|
||||
_create: function () {
|
||||
this.elements = {
|
||||
document: $(document),
|
||||
next: this.element.find(this.options.selectors.next),
|
||||
prev: this.element.find(this.options.selectors.prev)
|
||||
};
|
||||
|
||||
this.elements.document.bind( 'keydown', this.options.keys.next, this.next.bind(this, false) );
|
||||
this.elements.document.bind( 'keydown', this.options.keys.prev, this.prev.bind(this, false) );
|
||||
this.document.bind( 'keydown', this.options.keys.next, this.next.bind(this, false) );
|
||||
this.document.bind( 'keydown', this.options.keys.prev, this.prev.bind(this, false) );
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -51,10 +51,10 @@
|
|||
//
|
||||
|
||||
// Обновление
|
||||
this.elements.update.on('click', this.update.bind(this));
|
||||
this._on( this.elements.update, { 'click': this.update } );
|
||||
|
||||
// Прокрутка к следующему новому комментарию
|
||||
this.elements.counter.on('click', this.scroll.bind(this));
|
||||
this._on( this.elements.counter, { 'click': this.scroll } );
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
* @private
|
||||
*/
|
||||
_create: function () {
|
||||
this.window = $(window);
|
||||
|
||||
this._on( { 'click': this.up } );
|
||||
this._on( this.window, { 'scroll': this.check } );
|
||||
},
|
||||
|
@ -37,7 +35,7 @@
|
|||
* Показывает/скрывает кнопку прокрутки в зависимости от значения scrollTop
|
||||
*/
|
||||
check: function() {
|
||||
this.element[ this.window.scrollTop() > this.window.height() / 2 ? 'fadeIn' : 'fadeOut' ](500);
|
||||
this.element[ this.window.scrollTop() > this.window.height() / 2 ? 'fadeIn' : 'fadeOut' ]( 500 );
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -45,7 +45,11 @@
|
|||
},
|
||||
|
||||
// Продолжительность прокрутки, мс
|
||||
duration: 500
|
||||
duration: 500,
|
||||
|
||||
// Параметр в хэше урл указывающий к какому объекту прокручивать
|
||||
// после загрузки страницы (first или last)
|
||||
param: 'gotopic'
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -57,7 +61,6 @@
|
|||
_create: function () {
|
||||
// Элементы
|
||||
this.elements = {
|
||||
document: $(document),
|
||||
next: this.element.find(this.options.selectors.next),
|
||||
prev: this.element.find(this.options.selectors.prev),
|
||||
pagination: $(this.options.selectors.pagination).eq(0),
|
||||
|
@ -75,23 +78,23 @@
|
|||
//
|
||||
|
||||
// Обработка нажатий по кнопкам след/пред
|
||||
this.elements.next.on( 'click', this.next.bind(this) );
|
||||
this.elements.prev.on( 'click', this.prev.bind(this) );
|
||||
this._on( this.elements.next, { 'click': this.next } );
|
||||
this._on( this.elements.prev, { 'click': this.prev } );
|
||||
|
||||
// Обработка хоткеев
|
||||
this.elements.document.bind( 'keydown', this.options.keys.next, this.next.bind(this) );
|
||||
this.elements.document.bind( 'keydown', this.options.keys.prev, this.prev.bind(this) );
|
||||
this.document.bind( 'keydown' + this.eventNamespace, this.options.keys.next, this.next.bind(this) );
|
||||
this.document.bind( 'keydown' + this.eventNamespace, this.options.keys.prev, this.prev.bind(this) );
|
||||
},
|
||||
|
||||
/**
|
||||
* Обработка параметров в хэше url'а
|
||||
*/
|
||||
_checkUrl: function () {
|
||||
// Проверяем наличие параметра gotopic в хэше url'а
|
||||
var goto = location.hash.match( /gotopic=(last|first)/i );
|
||||
// Проверяем наличие параметра options.param в хэше url'а
|
||||
var goto = new RegExp( this.option( 'param' ) + '=(last|first)', 'i' ).exec( location.hash );
|
||||
|
||||
if ( goto ) {
|
||||
// С помощью goto[1] получаем значение параметра gotopic (first или last)
|
||||
// С помощью goto[1] получаем значение параметра options.param (first или last)
|
||||
var item = this.elements.items[ goto[1] ]();
|
||||
|
||||
// Скроллим через небольшой промежуток времени,
|
||||
|
|
|
@ -64,13 +64,13 @@
|
|||
this.options.params = $.extend({}, this.options.params, ls.utils.getDataOptions(this.elements.container, 'param'));
|
||||
|
||||
// Ивент удаления
|
||||
this.elements.list.on('click', this.options.selectors.item_remove, function (e) {
|
||||
this.elements.list.on('click' + this.eventNamespace, this.options.selectors.item_remove, function (e) {
|
||||
_this.remove( $(this).data('user-id') );
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
// Ивент добавления
|
||||
this.elements.form.on('submit', function (e) {
|
||||
this.elements.form.on('submit' + this.eventNamespace, function (e) {
|
||||
var aItemList = _this.getItems();
|
||||
|
||||
if ( aItemList.length ) {
|
||||
|
@ -119,7 +119,7 @@
|
|||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* Коллбэк вызываемый при добавлении объекта
|
||||
*/
|
||||
_onAdd: function (oResponse) {
|
||||
var aUsers = this._getUsersAll();
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 7c69cd6f916d72861984934f1643ae2d86211c5b
|
||||
Subproject commit f3e123a8a77ed89ec0cdac74efdec1f8fd76f20e
|
Loading…
Reference in a new issue