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

Мелкие исправления в виджетах

This commit is contained in:
Denis Shakhov 2014-06-24 20:29:04 +07:00
parent 9a6f58b23b
commit c8059b2ec0
11 changed files with 62 additions and 71 deletions

View file

@ -39,7 +39,7 @@
this._super(); 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') ); _this.reinvite( $(this).data('user-id') );
e.preventDefault(); e.preventDefault();
}); });
@ -49,12 +49,7 @@
* Отправляет инвайт заново * Отправляет инвайт заново
*/ */
reinvite: function (iUserId) { reinvite: function (iUserId) {
var _this = this, var oParams = $.extend({}, { iUserId: iUserId }, this.options.params);
oParams = {
iUserId: iUserId
};
oParams = $.extend({}, oParams, this.options.params);
ls.ajax.load(this.options.urls.reinvite, oParams, function(oResponse) { ls.ajax.load(this.options.urls.reinvite, oParams, function(oResponse) {
ls.msg.notice(null, oResponse.sMsg); ls.msg.notice(null, oResponse.sMsg);

View file

@ -95,8 +95,7 @@
* @private * @private
*/ */
_create: function () { _create: function () {
var _this = this, var _this = this;
oDocument = $(document);
// Получаем элементы // Получаем элементы
this.form = this.element.find(this.options.selectors.form.form); 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); var element = $(this);
_this.scrollToParentComment(element.data('id'), element.data('parent-id')); _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); _this.formToggle($(this).data('id'), true, false, false);
e.preventDefault(); 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._on( this.form, { 'submit': function (e) {
this.add(this.form, this.form.data('target-id'), this.form.data('target-type')); this.add( this.form, this.form.data('target-id'), this.form.data('target-type') );
e.preventDefault(); e.preventDefault();
}.bind(this)); }});
this.elements.form.text.bind('keyup', function(e) { this.elements.form.text.bind( 'keydown' + this.eventNamespace, 'ctrl+return', function() { _this.form.submit() } );
if ( e.ctrlKey && (e.keyCode || e.which) == 13 ) _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), var element = $(this),
commentId = element.data('id'); 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), var element = $(this),
commentId = element.data('id'); 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); this.formToggle(this.formTargetId, false, true);
e.preventDefault(); e.preventDefault();
}.bind(this)); }.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); this.submitCommentUpdate(this.formTargetId);
e.preventDefault(); e.preventDefault();
}.bind(this)); }.bind(this));
// Подписаться/отписаться от новых комментариев // Подписаться/отписаться от новых комментариев
this.elements.subscribe.on('click', function (e) { this.elements.subscribe.on('click' + this.eventNamespace, function (e) {
var element = $(this), var element = $(this),
isActive = element.hasClass('active'); isActive = element.hasClass('active');
@ -224,7 +221,7 @@
// Сворачивание // Сворачивание
if ( this.options.folding ) { 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); var element = $(this);
if ( ! element.hasClass('active') ) { 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), var element = $(this),
comment = _this.getCommentById(element.data('id')); comment = _this.getCommentById(element.data('id'));
@ -384,11 +381,11 @@
// Обновляем таймеры // Обновляем таймеры
this.initUpdateTimers(); 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 ]); 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)); }.bind(this));
}, },

View file

@ -49,17 +49,13 @@
_create: function () { _create: function () {
this.options.params = $.extend({}, this.options.params, ls.utils.getDataOptions(this.element, 'param')); this.options.params = $.extend({}, this.options.params, ls.utils.getDataOptions(this.element, 'param'));
this.elements = {}; this.elements = {
this.elements.toggle = this.element.find(this.options.selectors.toggle); toggle: this.element.find( this.options.selectors.toggle ),
this.elements.count = this.element.find(this.options.selectors.count); count: this.element.find( this.options.selectors.count )
};
// Обработка кликов по кнопкам голосования // Обработка кликов по кнопкам голосования
this._on({ this._on({ 'click': this.toggle });
'click': function (e) {
this.toggle();
e.preventDefault();
}
});
}, },
/** /**

View file

@ -40,13 +40,13 @@
this._super(); 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) ); _this.inactivate( $(this) );
e.preventDefault(); 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') ] ); _this.add( [ $(this).data('user-login') ] );
e.preventDefault(); e.preventDefault();
}); });
@ -63,8 +63,7 @@
* Повторное приглашение пользователя в диалог * Повторное приглашение пользователя в диалог
*/ */
inactivate: function (oButton) { inactivate: function (oButton) {
var _this = this, var iUserId = oButton.data('user-id'),
iUserId = oButton.data('user-id'),
oParams = { oParams = {
iUserId: iUserId iUserId: iUserId
}; };

View file

@ -82,16 +82,18 @@
ls.ajax.load(this.options.url, params, function (oResponse) { ls.ajax.load(this.options.url, params, function (oResponse) {
if (oResponse.iCountLoaded > 0) { if (oResponse.iCountLoaded > 0) {
var html=$('<div></div>').html($.trim(oResponse[this.options.result])); var html = $('<div></div>').html( $.trim( oResponse[this.options.result] ) );
if (html.find(this.options.target).length) {
html=html.find(this.options.target).first(); 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) { 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) { if (iCountLeft <= 0) {
this.element.remove(); this.element.remove();
@ -99,18 +101,20 @@
this.counter.text(iCountLeft); this.counter.text(iCountLeft);
} }
} }
// Обновляем параметры // Обновляем параметры
$.each(this.options.proxy,function(k,v){ $.each(this.options.proxy,function( k, v ) {
if (oResponse[k]) { if ( oResponse[k] ) {
this.options.proxy[k]=oResponse[k]; this.options.proxy[k] = oResponse[k];
} }
}.bind(this)); }.bind(this));
if (oResponse.bHideMore) { if ( oResponse.bHideMore ) {
this.element.remove(); this.element.remove();
} }
} else { } else {
// Для блоков без счетчиков // Для блоков без счетчиков
// TODO: i18n
ls.msg.notice(null, 'Больше нечего подгружать'); ls.msg.notice(null, 'Больше нечего подгружать');
this.element.remove(); this.element.remove();
} }

View file

@ -45,13 +45,12 @@
*/ */
_create: function () { _create: function () {
this.elements = { this.elements = {
document: $(document),
next: this.element.find(this.options.selectors.next), next: this.element.find(this.options.selectors.next),
prev: this.element.find(this.options.selectors.prev) prev: this.element.find(this.options.selectors.prev)
}; };
this.elements.document.bind( 'keydown', this.options.keys.next, this.next.bind(this, false) ); this.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.prev, this.prev.bind(this, false) );
}, },
/** /**

View file

@ -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 } );
}, },
/** /**

View file

@ -27,8 +27,6 @@
* @private * @private
*/ */
_create: function () { _create: function () {
this.window = $(window);
this._on( { 'click': this.up } ); this._on( { 'click': this.up } );
this._on( this.window, { 'scroll': this.check } ); this._on( this.window, { 'scroll': this.check } );
}, },
@ -37,7 +35,7 @@
* Показывает/скрывает кнопку прокрутки в зависимости от значения scrollTop * Показывает/скрывает кнопку прокрутки в зависимости от значения scrollTop
*/ */
check: function() { 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 );
}, },
/** /**

View file

@ -45,7 +45,11 @@
}, },
// Продолжительность прокрутки, мс // Продолжительность прокрутки, мс
duration: 500 duration: 500,
// Параметр в хэше урл указывающий к какому объекту прокручивать
// после загрузки страницы (first или last)
param: 'gotopic'
}, },
/** /**
@ -57,7 +61,6 @@
_create: function () { _create: function () {
// Элементы // Элементы
this.elements = { this.elements = {
document: $(document),
next: this.element.find(this.options.selectors.next), next: this.element.find(this.options.selectors.next),
prev: this.element.find(this.options.selectors.prev), prev: this.element.find(this.options.selectors.prev),
pagination: $(this.options.selectors.pagination).eq(0), pagination: $(this.options.selectors.pagination).eq(0),
@ -75,23 +78,23 @@
// //
// Обработка нажатий по кнопкам след/пред // Обработка нажатий по кнопкам след/пред
this.elements.next.on( 'click', this.next.bind(this) ); this._on( this.elements.next, { 'click': this.next } );
this.elements.prev.on( 'click', this.prev.bind(this) ); this._on( this.elements.prev, { 'click': this.prev } );
// Обработка хоткеев // Обработка хоткеев
this.elements.document.bind( 'keydown', this.options.keys.next, this.next.bind(this) ); this.document.bind( 'keydown' + this.eventNamespace, 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.prev, this.prev.bind(this) );
}, },
/** /**
* Обработка параметров в хэше url'а * Обработка параметров в хэше url'а
*/ */
_checkUrl: function () { _checkUrl: function () {
// Проверяем наличие параметра gotopic в хэше url'а // Проверяем наличие параметра options.param в хэше url'а
var goto = location.hash.match( /gotopic=(last|first)/i ); var goto = new RegExp( this.option( 'param' ) + '=(last|first)', 'i' ).exec( location.hash );
if ( goto ) { if ( goto ) {
// С помощью goto[1] получаем значение параметра gotopic (first или last) // С помощью goto[1] получаем значение параметра options.param (first или last)
var item = this.elements.items[ goto[1] ](); var item = this.elements.items[ goto[1] ]();
// Скроллим через небольшой промежуток времени, // Скроллим через небольшой промежуток времени,

View file

@ -64,13 +64,13 @@
this.options.params = $.extend({}, this.options.params, ls.utils.getDataOptions(this.elements.container, 'param')); 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') ); _this.remove( $(this).data('user-id') );
e.preventDefault(); e.preventDefault();
}); });
// Ивент добавления // Ивент добавления
this.elements.form.on('submit', function (e) { this.elements.form.on('submit' + this.eventNamespace, function (e) {
var aItemList = _this.getItems(); var aItemList = _this.getItems();
if ( aItemList.length ) { if ( aItemList.length ) {
@ -119,7 +119,7 @@
}, },
/** /**
* * Коллбэк вызываемый при добавлении объекта
*/ */
_onAdd: function (oResponse) { _onAdd: function (oResponse) {
var aUsers = this._getUsersAll(); var aUsers = this._getUsersAll();

@ -1 +1 @@
Subproject commit 7c69cd6f916d72861984934f1643ae2d86211c5b Subproject commit f3e123a8a77ed89ec0cdac74efdec1f8fd76f20e