From e41427616dba910c993c8ab08d70313ca1d8872d Mon Sep 17 00:00:00 2001
From: =?utf8?q?Marek=20St=C4=99pniowski?= <marek@stepniowski.com>
Date: Fri, 7 Aug 2009 15:35:49 +0200
Subject: [PATCH] =?utf8?q?=20-=20Usuni=C4=99cie=20wywo=C5=82a=C5=84=20cons?=
 =?utf8?q?ole.log=20ze=20skrypt=C3=B3w.=20=20-=20Dodanie=20funkcji=20addEd?=
 =?utf8?q?itorButton,=20kt=C3=B3ra=20odpowiada=20za=20tworzenie=20przycisk?=
 =?utf8?q?=C3=B3w=20edytora.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit

---
 project/templates/explorer/file_html.html |  4 ----
 project/templates/explorer/file_xml.html  | 23 ++++++++++++-----------
 2 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/project/templates/explorer/file_html.html b/project/templates/explorer/file_html.html
index 7e126f0a..bb2c230c 100644
--- a/project/templates/explorer/file_html.html
+++ b/project/templates/explorer/file_html.html
@@ -15,11 +15,7 @@
         var lastScroll = -1000;
                     
         function checkScroll() {
-            console.log('checkScroll', $('#images').scrollTop(), lastScroll);
-            
             if (Math.abs($('#images').scrollTop() - lastScroll) > 300) {
-                console.log('checking!');
-                
                 var container = $('#images');
                 lastScroll = container.scrollTop();
                 
diff --git a/project/templates/explorer/file_xml.html b/project/templates/explorer/file_xml.html
index 66e128de..2a2afaac 100644
--- a/project/templates/explorer/file_xml.html
+++ b/project/templates/explorer/file_xml.html
@@ -15,11 +15,7 @@
         var lastScroll = -1000;
                     
         function checkScroll() {
-            console.log('checkScroll', $('#images').scrollTop(), lastScroll);
-            
             if (Math.abs($('#images').scrollTop() - lastScroll) > 300) {
-                console.log('checking!');
-                
                 var container = $('#images');
                 lastScroll = container.scrollTop();
                 
@@ -36,20 +32,25 @@
             setTimeout(checkScroll, 2000);
         }
         
+        function addEditorButton(label, fn) {
+            $('<button type="button">' + label + '</button>').click(function(event) {
+                var text = $('#id_text').getSelection().text;
+                $('#id_text').replaceSelection(fn(text));
+                event.preventDefault();
+            }).appendTo('#buttons');
+        }
+        
         $(function() {
             $('#id_folders').change(function() {
                 $('#images').load('/images/' + $('#id_folders').val() + '/', function() {
                     lastScroll = -1000;
                 });
             });
+
+            addEditorButton('utwór', function(text) { return '<utwor>' + text + '</utwor>'; });
+            addEditorButton('akap', function(text) { return '<akap>' + text + '</akap>'; });
             
             setTimeout(checkScroll, 2000);
-            
-            $('#rozdzial-button').click(function(event) {
-                console.log($('#id_text').getSelection().text);
-                $('#id_text').replaceSelection('<rozdzial>' + $('#id_text').getSelection().text + '</rozdzial>', true);
-                event.preventDefault();
-            });
         });
     </script>
 {% endblock extrahead %}
@@ -65,7 +66,7 @@
         </div>
     </div>
     <form action="." method="post" accept-charset="utf-8">
-        <a href="#" id="rozdzial-button">Rodział</a>
+        <div id="buttons"></div>
         {{ form.text }}
         <p>Użytkownik: {{ form.user }} Opis zmian: {{ form.commit_message }} <input type="submit" value="Zapisz"/></p>
     </form>
-- 
2.20.1