Skip to content

Commit

Permalink
Автоскроллинг в контент нижней панели, если она не видна при клике на…
Browse files Browse the repository at this point in the history
… категорию
  • Loading branch information
klimashkin committed Aug 6, 2013
1 parent be387d4 commit 777a7a2
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 22 deletions.
1 change: 1 addition & 0 deletions public/history.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* (added) Постраничный просмотр в галерее пользователя
* (added) Автоматический вход после востановления пароля
* (added) Парсинг кириллицы в url адресах, вставляемых в комментарии и свойства снимка. Преобразование закодированных браузером ссылок в кириллицу
* (added) Автоскроллинг в контент нижней панели, если она не видна при клике на категорию
* (fixed) При редактировании комментария с фрагментом, он начинал занимать всю площадь фотографии
* (fixed) Ошибка выборки галереи пользователя, если в ней присутствуют неактивные или удаленные фотографии
***
Expand Down
2 changes: 1 addition & 1 deletion public/js/module/appMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require([
'globalVM', 'Params', 'renderer', 'RouteManager',
'model/Photo', 'model/User',
'text!tpl/appMain.jade', 'css!style/common', 'css!style/appMain',
'backbone.queryparams', 'momentlang/ru', 'bs/bootstrap-transition', 'knockout.extends', 'noty', 'noty.layouts', 'noty.themes/pastvu'
'backbone.queryparams', 'momentlang/ru', 'bs/bootstrap-transition', 'knockout.extends', 'noty', 'noty.layouts', 'noty.themes/pastvu', 'jquery-plugins/scrollto'
], function (domReady, $, Browser, Utils, socket, _, Backbone, ko, ko_mapping, moment, globalVM, P, renderer, RouteManager, Photo, User, jade) {
"use strict";

Expand Down
2 changes: 1 addition & 1 deletion public/js/module/comment/comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Модель комментариев к объекту
*/
define(['underscore', 'underscore.string', 'Utils', '../../socket', 'Params', 'knockout', 'knockout.mapping', 'm/_moduleCliche', 'globalVM', 'renderer', 'moment', 'model/Photo', 'model/storage', 'text!tpl/comment/comments.jade', 'css!style/comment/comments', 'bs/bootstrap-tooltip', 'bs/bootstrap-popover', 'jquery-plugins/scrollto'], function (_, _s, Utils, socket, P, ko, ko_mapping, Cliche, globalVM, renderer, moment, Photo, storage, jade) {
define(['underscore', 'underscore.string', 'Utils', '../../socket', 'Params', 'knockout', 'knockout.mapping', 'm/_moduleCliche', 'globalVM', 'renderer', 'moment', 'model/Photo', 'model/storage', 'text!tpl/comment/comments.jade', 'css!style/comment/comments', 'bs/bootstrap-tooltip', 'bs/bootstrap-popover'], function (_, _s, Utils, socket, P, ko, ko_mapping, Cliche, globalVM, renderer, moment, Photo, storage, jade) {
'use strict';

return Cliche.extend({
Expand Down
2 changes: 1 addition & 1 deletion public/js/module/diff/news.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Модель профиля пользователя
*/
define(['underscore', 'underscore.string', 'Utils', '../../socket', 'Params', 'knockout', 'knockout.mapping', 'm/_moduleCliche', 'globalVM', 'renderer', 'moment', 'model/Photo', 'model/storage', 'text!tpl/diff/news.jade', 'css!style/diff/news', 'bs/bootstrap-tooltip', 'bs/bootstrap-popover', 'jquery-plugins/scrollto'], function (_, _s, Utils, socket, P, ko, ko_mapping, Cliche, globalVM, renderer, moment, Photo, storage, jade) {
define(['underscore', 'underscore.string', 'Utils', '../../socket', 'Params', 'knockout', 'knockout.mapping', 'm/_moduleCliche', 'globalVM', 'renderer', 'moment', 'model/Photo', 'model/storage', 'text!tpl/diff/news.jade', 'css!style/diff/news', 'bs/bootstrap-tooltip', 'bs/bootstrap-popover'], function (_, _s, Utils, socket, P, ko, ko_mapping, Cliche, globalVM, renderer, moment, Photo, storage, jade) {
'use strict';
var newsDefault = {
pdate: new Date(),
Expand Down
2 changes: 1 addition & 1 deletion public/js/module/diff/newsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
define([
'underscore', 'jquery', 'Browser', 'Utils', 'socket', 'Params', 'knockout', 'knockout.mapping', 'm/_moduleCliche', 'globalVM',
'model/User', 'model/storage',
'text!tpl/diff/newsList.jade', 'css!style/diff/newsList', 'jquery-plugins/scrollto'
'text!tpl/diff/newsList.jade', 'css!style/diff/newsList'
], function (_, $, Browser, Utils, socket, P, ko, ko_mapping, Cliche, globalVM, User, storage, jade) {
'use strict';

Expand Down
55 changes: 38 additions & 17 deletions public/js/module/main/bottomPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,40 @@ define(['underscore', 'Browser', 'Utils', 'socket', 'Params', 'knockout', 'knock
delete this.subscriptions.loggedIn;
},
catClick: function (data) {
this.catJump(data);
this.catJump(data, true);
},
catJump: function (id) {
catJump: function (id, scroll) {
this.catLoading(id);
this['get' + Utils.capitalizeFirst(id)](this.catActivate, this);
this['get' + Utils.capitalizeFirst(id)](this.catActivate, this, scroll);
},
catActivate: function (success) {
catActivate: function (success, scroll) {
if (success) {
this.catActive(this.catLoading());
if (scroll) {
var $catMenu = this.$dom.find('.catMenu'),
catContentHeight = this.$dom.find('.catContent').height(),
cBottom = $catMenu.offset().top + $catMenu.height() + 60,
wTop = $(window).scrollTop(),
wFold = $(window).height() + wTop;

if (wFold < cBottom) {
$(window).scrollTo('+=' + (cBottom - wFold + catContentHeight / 2 >> 0) + 'px', {axis: 'y', duration: 200, onAfter: function () {
this.catSetLoading();
}.bind(this)});
} else {
this.catSetLoading();
}
} else {
this.catSetLoading();
}
} else {
this.catLoading('');
}
},
catSetLoading: function (success, scroll) {
this.catActive(this.catLoading());
this.catLoading('');
},
getNews: function (cb, ctx) {
getNews: function (cb, ctx, scroll) {
socket.once('takeIndexNews', function (data) {
var success = false;
if (!data || data.error || !Array.isArray(data.news)) {
Expand All @@ -142,12 +163,12 @@ define(['underscore', 'Browser', 'Utils', 'socket', 'Params', 'knockout', 'knock
success = true;
}
if (Utils.isType('function', cb)) {
cb.call(ctx, success);
cb.call(ctx, success, scroll);
}
}.bind(this));
socket.emit('giveIndexNews');
},
getPhotos: function (cb, ctx) {
getPhotos: function (cb, ctx, scroll) {
socket.once('takePhotosPublicIndex', function (data) {
var success = false;
if (this.catLoading() === 'photos') {
Expand All @@ -161,12 +182,12 @@ define(['underscore', 'Browser', 'Utils', 'socket', 'Params', 'knockout', 'knock
}
}
if (Utils.isType('function', cb)) {
cb.call(ctx, success);
cb.call(ctx, success, scroll);
}
}.bind(this));
socket.emit('givePhotosPublicIndex');
},
getPhotosNoGeo: function (cb, ctx) {
getPhotosNoGeo: function (cb, ctx, scroll) {
socket.once('takePhotosPublicNoGeoIndex', function (data) {
var success = false;
if (this.catLoading() === 'photosNoGeo') {
Expand All @@ -180,12 +201,12 @@ define(['underscore', 'Browser', 'Utils', 'socket', 'Params', 'knockout', 'knock
}
}
if (Utils.isType('function', cb)) {
cb.call(ctx, success);
cb.call(ctx, success, scroll);
}
}.bind(this));
socket.emit('givePhotosPublicNoGeoIndex');
},
getPhotosToApprove: function (cb, ctx) {
getPhotosToApprove: function (cb, ctx, scroll) {
socket.once('takePhotosForApprove', function (data) {
var success = false;
if (this.catLoading() === 'photosToApprove') {
Expand All @@ -199,12 +220,12 @@ define(['underscore', 'Browser', 'Utils', 'socket', 'Params', 'knockout', 'knock
}
}
if (Utils.isType('function', cb)) {
cb.call(ctx, success);
cb.call(ctx, success, scroll);
}
}.bind(this));
socket.emit('givePhotosForApprove', {skip: 0, limit: 30});
},
getRatings: function (cb, ctx) {
getRatings: function (cb, ctx, scroll) {
var success = false;
socket.once('takeRatings', function (data) {
if (this.catLoading() === 'ratings') {
Expand All @@ -230,12 +251,12 @@ define(['underscore', 'Browser', 'Utils', 'socket', 'Params', 'knockout', 'knock
}
}
if (Utils.isType('function', cb)) {
cb.call(ctx, success);
cb.call(ctx, success, scroll);
}
}.bind(this));
socket.emit('giveRatings', {limit: 24});
},
getStats: function (cb, ctx) {
getStats: function (cb, ctx, scroll) {
var success = false;
socket.once('takeStats', function (data) {
if (this.catLoading() === 'stats') {
Expand All @@ -247,7 +268,7 @@ define(['underscore', 'Browser', 'Utils', 'socket', 'Params', 'knockout', 'knock
success = true;
}
if (Utils.isType('function', cb)) {
cb.call(ctx, success);
cb.call(ctx, success, scroll);
}
}.bind(this));
socket.emit('giveStats');
Expand Down
2 changes: 1 addition & 1 deletion public/js/module/photo/photo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Модель страницы фотографии
*/
define(['underscore', 'underscore.string', 'Utils', '../../socket', 'Params', 'knockout', 'knockout.mapping', 'm/_moduleCliche', 'globalVM', 'renderer', 'moment', 'model/Photo', 'model/storage', 'text!tpl/photo/photo.jade', 'css!style/photo/photo', 'bs/bootstrap-tooltip', 'bs/bootstrap-popover', 'bs/bootstrap-dropdown', 'bs/bootstrap-multiselect', 'knockout.bs', 'jquery-plugins/scrollto', 'jquery-plugins/imgareaselect'], function (_, _s, Utils, socket, P, ko, ko_mapping, Cliche, globalVM, renderer, moment, Photo, storage, jade) {
define(['underscore', 'underscore.string', 'Utils', '../../socket', 'Params', 'knockout', 'knockout.mapping', 'm/_moduleCliche', 'globalVM', 'renderer', 'moment', 'model/Photo', 'model/storage', 'text!tpl/photo/photo.jade', 'css!style/photo/photo', 'bs/bootstrap-tooltip', 'bs/bootstrap-popover', 'bs/bootstrap-dropdown', 'bs/bootstrap-multiselect', 'knockout.bs', 'jquery-plugins/imgareaselect'], function (_, _s, Utils, socket, P, ko, ko_mapping, Cliche, globalVM, renderer, moment, Photo, storage, jade) {
'use strict';
var imgFailTpl = _.template('<div class="imgFail"><div class="failContent" style="${ style }">${ txt }</div></div>');

Expand Down

0 comments on commit 777a7a2

Please sign in to comment.