From 0beb0bf8e1f061894f48523e5d134c6b923f4c32 Mon Sep 17 00:00:00 2001 From: zuber Date: Tue, 18 Aug 2009 12:50:57 +0200 Subject: [PATCH] =?utf8?q?Dodanie=20mo=C5=BCliwo=C5=9Bci=20w=C5=82=C4=85cz?= =?utf8?q?ania=20i=20wy=C5=82=C4=85czania=20automatycznego=20przewijania.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- project/static/js/jquery.autoscroll.js | 30 ++++++++++++++++++------ project/templates/explorer/file_xml.html | 15 ++++++++++-- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/project/static/js/jquery.autoscroll.js b/project/static/js/jquery.autoscroll.js index c342bdf5..f8c07fbd 100644 --- a/project/static/js/jquery.autoscroll.js +++ b/project/static/js/jquery.autoscroll.js @@ -1,6 +1,7 @@ (function($) { $.fn.autoscroll = function(synchronizeWith, options) { - var self = $(this); + var $this = $(this); + var self = $this; var selfContainer = self.parent(); var synchronizeWith = $(synchronizeWith); var synchronizeWithContainer = synchronizeWith.parent(); @@ -17,15 +18,30 @@ synchronizeWithContainer = $('body', eventContainer); synchronizeWith = synchronizeWithContainer; } - - synchronizeWithContainer.data('autoscroll.lastCheckedScrollTop', synchronizeWithContainer.scrollTop()); + + $this.data('autoscroll:enabled', true); + synchronizeWithContainer.data('autoscroll:lastCheckedScrollTop', synchronizeWithContainer.scrollTop()); eventContainer.scroll(function() { - var distanceScrolled = synchronizeWithContainer.scrollTop() - synchronizeWithContainer.data('autoscroll:lastCheckedScrollTop'); - var percentScrolled = distanceScrolled / synchronizeWith.height(); - selfContainer.scrollTop(selfContainer.scrollTop() + percentScrolled * self.height()); + if ($this.data('autoscroll:enabled')) { + var distanceScrolled = synchronizeWithContainer.scrollTop() - synchronizeWithContainer.data('autoscroll:lastCheckedScrollTop'); + var percentScrolled = distanceScrolled / synchronizeWith.height(); + selfContainer.scrollTop(selfContainer.scrollTop() + percentScrolled * self.height()); + } synchronizeWithContainer.data('autoscroll:lastCheckedScrollTop', synchronizeWithContainer.scrollTop()); }); - }; + }, + + $.fn.enableAutoscroll = function() { + $(this).data('autoscroll:enabled', true); + }, + + $.fn.disableAutoscroll = function() { + $(this).data('autoscroll:enabled', false); + }, + + $.fn.toggleAutoscroll = function() { + $(this).data('autoscroll:enabled', !$(this).data('autoscroll:enabled')); + } })(jQuery); diff --git a/project/templates/explorer/file_xml.html b/project/templates/explorer/file_xml.html index 5bad3c4a..e9cd85c0 100644 --- a/project/templates/explorer/file_xml.html +++ b/project/templates/explorer/file_xml.html @@ -50,7 +50,13 @@ $('iframe').load(function() { $('#images').autoscroll('iframe'); - + $('.toggleAutoscroll').toggle(function() { + $(this).html('Synchronizuj przewijanie'); + $('#images').disableAutoscroll(); + }, function() { + $(this).html('Nie synchronizuj przewijania'); + $('#images').enableAutoscroll(); + }) setTimeout(function() {resizePanels();}, 10); }) @@ -84,7 +90,12 @@
{{ form.user.errors }} {{ form.commit_message.errors }} -

Użytkownik: {{ form.user }} Opis zmian: {{ form.commit_message }}

+

+ Użytkownik: {{ form.user }} + Opis zmian: {{ form.commit_message }} + + Nie synchronizuj przewijania +

{% endblock maincontent %} -- 2.20.1