From 777a7a2932cff9a7fcfbebcf46f161b95ce8ce50 Mon Sep 17 00:00:00 2001 From: klimashkin Date: Tue, 6 Aug 2013 16:20:38 +0400 Subject: [PATCH] =?UTF-8?q?=D0=90=D0=B2=D1=82=D0=BE=D1=81=D0=BA=D1=80?= =?UTF-8?q?=D0=BE=D0=BB=D0=BB=D0=B8=D0=BD=D0=B3=20=D0=B2=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=BD=D1=82=D0=B5=D0=BD=D1=82=20=D0=BD=D0=B8=D0=B6=D0=BD=D0=B5?= =?UTF-8?q?=D0=B9=20=D0=BF=D0=B0=D0=BD=D0=B5=D0=BB=D0=B8,=20=D0=B5=D1=81?= =?UTF-8?q?=D0=BB=D0=B8=20=D0=BE=D0=BD=D0=B0=20=D0=BD=D0=B5=20=D0=B2=D0=B8?= =?UTF-8?q?=D0=B4=D0=BD=D0=B0=20=D0=BF=D1=80=D0=B8=20=D0=BA=D0=BB=D0=B8?= =?UTF-8?q?=D0=BA=D0=B5=20=D0=BD=D0=B0=20=D0=BA=D0=B0=D1=82=D0=B5=D0=B3?= =?UTF-8?q?=D0=BE=D1=80=D0=B8=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/history.txt | 1 + public/js/module/appMain.js | 2 +- public/js/module/comment/comments.js | 2 +- public/js/module/diff/news.js | 2 +- public/js/module/diff/newsList.js | 2 +- public/js/module/main/bottomPanel.js | 55 +++++++++++++++++++--------- public/js/module/photo/photo.js | 2 +- 7 files changed, 44 insertions(+), 22 deletions(-) diff --git a/public/history.txt b/public/history.txt index 945b38a95..c9f2749b0 100644 --- a/public/history.txt +++ b/public/history.txt @@ -5,6 +5,7 @@ * (added) Постраничный просмотр в галерее пользователя * (added) Автоматический вход после востановления пароля * (added) Парсинг кириллицы в url адресах, вставляемых в комментарии и свойства снимка. Преобразование закодированных браузером ссылок в кириллицу + * (added) Автоскроллинг в контент нижней панели, если она не видна при клике на категорию * (fixed) При редактировании комментария с фрагментом, он начинал занимать всю площадь фотографии * (fixed) Ошибка выборки галереи пользователя, если в ней присутствуют неактивные или удаленные фотографии *** diff --git a/public/js/module/appMain.js b/public/js/module/appMain.js index 1d428325a..9def3283b 100644 --- a/public/js/module/appMain.js +++ b/public/js/module/appMain.js @@ -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"; diff --git a/public/js/module/comment/comments.js b/public/js/module/comment/comments.js index c6c83d6d7..b6c3d4350 100644 --- a/public/js/module/comment/comments.js +++ b/public/js/module/comment/comments.js @@ -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({ diff --git a/public/js/module/diff/news.js b/public/js/module/diff/news.js index 7fb3fc605..bc2c25bdf 100644 --- a/public/js/module/diff/news.js +++ b/public/js/module/diff/news.js @@ -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(), diff --git a/public/js/module/diff/newsList.js b/public/js/module/diff/newsList.js index 4edeccf14..f2cab121b 100644 --- a/public/js/module/diff/newsList.js +++ b/public/js/module/diff/newsList.js @@ -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'; diff --git a/public/js/module/main/bottomPanel.js b/public/js/module/main/bottomPanel.js index 2e5ed3325..aaa06dee7 100644 --- a/public/js/module/main/bottomPanel.js +++ b/public/js/module/main/bottomPanel.js @@ -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)) { @@ -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') { @@ -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') { @@ -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') { @@ -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') { @@ -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') { @@ -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'); diff --git a/public/js/module/photo/photo.js b/public/js/module/photo/photo.js index f80282059..c6881dfeb 100644 --- a/public/js/module/photo/photo.js +++ b/public/js/module/photo/photo.js @@ -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('
${ txt }
');