8 var DEFAULT_PERSPECTIVE = "#VisualPerspective";
12 var tabs = $('ol#tabs li');
14 CurrentDocument = new $.wikiapi.WikiDocument("document-meta");
16 $.blockUI.defaults.baseZ = 10000;
20 $(document).keydown(function(event) {
21 console.log("Received key:", event);
25 $('#save-button').click(function(event){
26 event.preventDefault();
27 $.wiki.showDialog('#save_dialog');
35 $('.tabs li').live('click', function(event, callback) {
36 $.wiki.switchToTab(this);
39 $('#tabs li > .tabclose').live('click', function(event, callback) {
40 var $tab = $(this).parent();
42 if($tab.is('.active'))
43 $.wiki.switchToTab(DEFAULT_PERSPECTIVE);
45 var p = $.wiki.perspectiveForTab($tab);
52 $(window).resize(function(){
53 $('iframe').height($(window).height() - $('#tabs').outerHeight() - $('#source-editor .toolbar').outerHeight());
58 $('.vsplitbar').toggle(
60 $.wiki.state.perspectives.ScanGalleryPerspective.show = true;
62 $('.vsplitbar').css('right', 480).addClass('active');
63 $('#editor .editor').css('right', 510);
65 $.wiki.perspectiveForTab('#tabs-right .active').onEnter();
68 var active_right = $.wiki.perspectiveForTab('#tabs-right .active');
69 $.wiki.state.perspectives.ScanGalleryPerspective.show = false;
71 $('.vsplitbar').css('right', 0).removeClass('active');
72 $(".vsplitbar-title").html("↑ " + active_right.vsplitbar + " ↑");
73 $('#editor .editor').css('right', 30);
75 active_right.onExit();
79 if($.wiki.state.perspectives.ScanGalleryPerspective.show){
80 $('.vsplitbar').trigger('click');
81 $(".vsplitbar-title").html("↓ GALERIA ↓");
83 $(".vsplitbar-title").html("↑ GALERIA ↑");
85 window.onbeforeunload = function(e) {
86 if($.wiki.isDirty()) {
87 e.returnValue = "Na stronie mogą być nie zapisane zmiany.";
88 return "Na stronie mogą być nie zapisane zmiany.";
92 console.log("Fetching document's text");
94 $(document).bind('wlapi_document_changed', function(event, doc) {
96 $('#document-revision').text(doc.revision);
98 console.log("Failed handler", e);
102 CurrentDocument.fetch({
104 console.log("Fetch success");
105 $('#loading-overlay').fadeOut();
106 var active_tab = document.location.hash || DEFAULT_PERSPECTIVE;
108 if(active_tab == "#ScanGalleryPerspective")
109 active_tab = DEFAULT_PERSPECTIVE;
111 console.log("Initial tab is:", active_tab)
112 $.wiki.switchToTab(active_tab);
114 /* every 5 minutes check for a newer version */
115 var revTimer = setInterval(function() {
116 CurrentDocument.checkRevision({outdated: function(){
117 $('#header').addClass('out-of-date');
118 clearInterval(revTimer);
122 failure: function() {
123 $('#loading-overlay').fadeOut();
127 }; /* end of initialize() */
130 /* Load configuration */
133 var initAll = function(a, f) {
134 if (a.length == 0) return f();
138 doc: CurrentDocument,
139 callback: function(){
147 * Initialize all perspectives
149 initAll( $.makeArray($('.tabs li')), initialize);
150 console.log(location.hash);