Usunięcie wszystkich wywołań console.log.
[redakcja.git] / project / static / js / panels.js
1 function loadPanel(target, url) {
2     $('.change-notification', $(target).parent()).fadeOut();
3     $(document).trigger('panel:unload', target);
4     $.ajax({
5         url: url,
6         dataType: 'html',
7         success: function(data, textStatus) {
8             $(target).html(data);
9             $(document).trigger('panel:load', target);
10         },
11         error: function(request, textStatus, errorThrown) {
12             console.log('ajax', url, target, 'error:', textStatus, errorThrown);
13         }
14     });
15 }
16
17 // Funkcja do tworzenia nowych paneli
18 function panel(load, unload) {
19     var self = null;
20     var eventId = Math.ceil(Math.random() * 1000000000);
21     
22     unloadHandler = function(event, panel) {
23         if (self && self == panel) {
24             $(document).unbind('panel:unload.' + eventId);
25             $(panel).html('');
26             unload(event, panel);
27             return false;
28         }
29     };
30     
31     $(document).one('panel:load', function(event, panel) {
32         self = panel;
33         $(document).bind('panel:unload.' + eventId, unloadHandler);
34         load(event, panel);
35     });
36 }
37
38 $(function() {
39     // ========================
40     // = Resizable panels =
41     // ========================
42 //    function resizePanels() {
43 //              // called on resize
44 //        $('.panel').height($(window).height() - $('.panel').position().top);
45 //        $('.panel-content').height($(window).height() - $('.panel-contents').position().top);
46 //        $('#right-panel-wrap').width($(window).width() - $('#left-panel-wrap').outerWidth());
47 //    }
48     
49 //    $(window).resize(function() {
50 //        resizePanels();
51 //    })
52
53     $('#panels').makeHorizPanel({});
54     $('#panels').css('top', ($('#header').outerHeight() ) + 'px');
55         
56 //    $('#left-panel-wrap').bind('resizable:stop', resizePanels)
57 //        .resizable({minWidth: 8});    
58 //    resizePanels();
59     
60     $('.panel-toolbar select').change(function() {
61         loadPanel($('.panel-content', $(this).parent().parent()), $(this).val())
62     });
63     // $('#id_folders').change(function() {
64     //     $('#images').load('{% url folder_image_ajax %}' + $('#id_folders').val() + '/', function() {
65     //         $('#images-wrap').data('lazyload:lastCheckedScrollTop', -10000);
66     //     });
67     // });
68     // 
69     //
70     
71     // var editor = CodeMirror.fromTextArea("id_text", {
72     //     parserfile: 'parsexml.js',
73     //     path: "/static/js/codemirror/",
74     //     stylesheet: "/static/css/xmlcolors.css",
75     //     parserConfig: {useHTMLKludges: false},
76     //     initCallback: function() {
77     //         $('#images').autoscroll('iframe');
78     //         $('.toggleAutoscroll').toggle(function() {
79     //             $(this).html('Synchronizuj przewijanie');
80     //             $('#images').disableAutoscroll();
81     //         }, function() {
82     //             $(this).html('Nie synchronizuj przewijania');
83     //             $('#images').enableAutoscroll();
84     //         })
85     //         
86     //         // Toolbar
87     //         $('#toolbar-tabs li').click(function() {
88     //             var id = $(this).attr('p:button-list');
89     //             $('#toolbar-tabs li').removeClass('active');
90     //             $(this).addClass('active');
91     //             if (!$('#' + id).is(':visible')) {
92     //                 $('#toolbar-buttons ol').not('#' + id).hide();
93     //                 $('#' + id).show();
94     //             }
95     //         })
96     // 
97     //         var keys = {};
98     //         $('#toolbar-buttons li').each(function() {
99     //             var tag = $(this).attr('p:tag');
100     //             var handler = function() {
101     //                 var text = editor.selection();
102     //                 editor.replaceSelection('<' + tag + '>' + text + '</' + tag + '>');
103     //                 if (text.length == 0) {
104     //                     var pos = editor.cursorPosition();
105     //                     editor.selectLines(pos.line, pos.character + tag.length + 2);
106     //                 }
107     //             }
108     //             if ($(this).attr('p:key')) {
109     //                 keys[$(this).attr('p:key')] = handler;
110     //             }
111     //             $(this).click(handler)
112     //         });
113     //         
114     //         editor.grabKeys(function(event) { 
115     //             if (keys[event.keyCode]) {
116     //                 keys[event.keyCode]();
117     //             }
118     //         }, function(event) {
119     //             return event.altKey && keys[event.keyCode];
120     //         });
121     //     }
122     // });
123     
124
125     
126
127     
128     // $('#toolbar-buttons li').wTooltip({
129     //     delay: 1000, 
130     //     style: {
131     //         border: "1px solid #7F7D67",
132     //         opacity: 0.9, 
133     //         background: "#FBFBC6", 
134     //         padding: "1px",
135     //         fontSize: "12px",
136     //     }});
137     
138     // $('#images-wrap').lazyload('.image-box', {threshold: 640 * 10, scrollTreshold: 640 * 5});
139 });