8 var DEFAULT_PERSPECTIVE = "#SummaryPerspective";
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-title").html("↓ GALLERY ↓");
63 $('.vsplitbar').css('right', 480).addClass('active');
64 $('#editor .editor').css('right', 510);
66 $.wiki.perspectiveForTab('#tabs-right .active').onEnter();
69 $.wiki.state.perspectives.ScanGalleryPerspective.show = false;
71 $('.vsplitbar').css('right', 0).removeClass('active');
72 if($(".vsplitbar-title").html() == "↓ ZNAJDŹ I ZAMIEŃ ↓"){
73 $(".vsplitbar-title").html("↑ ZNAJDŹ I ZAMIEŃ ↑");
74 } else if($(".vsplitbar-title").html() == "↓ PRZYPISY ↓"){
75 $(".vsplitbar-title").html("↑ PRZYPISY ↑");
77 $(".vsplitbar-title").html("↑ GALERIA ↑");
79 $('#editor .editor').css('right', 30);
81 $.wiki.perspectiveForTab('#tabs-right .active').onExit();
85 if($.wiki.state.perspectives.ScanGalleryPerspective.show){
86 $('.vsplitbar').trigger('click');
87 $(".vsplitbar-title").html("↓ GALLERY ↓");
89 $(".vsplitbar-title").html("↑ GALLERY ↑");
91 window.onbeforeunload = function(e) {
92 if($.wiki.isDirty()) {
93 e.returnValue = "Na stronie mogą być nie zapisane zmiany.";
94 return "Na stronie mogą być nie zapisane zmiany.";
98 console.log("Fetching document's text");
100 $(document).bind('wlapi_document_changed', function(event, doc) {
102 $('#document-revision').text(doc.revision);
104 console.log("Failed handler", e);
108 CurrentDocument.fetch({
110 console.log("Fetch success");
111 $('#loading-overlay').fadeOut();
112 var active_tab = document.location.hash || DEFAULT_PERSPECTIVE;
114 if(active_tab == "#ScanGalleryPerspective")
115 active_tab = DEFAULT_PERSPECTIVE;
117 console.log("Initial tab is:", active_tab)
118 $.wiki.switchToTab(active_tab);
120 failure: function() {
121 $('#loading-overlay').fadeOut();
125 }; /* end of initialize() */
128 /* Load configuration */
131 var initAll = function(a, f) {
132 if (a.length == 0) return f();
136 doc: CurrentDocument,
137 callback: function(){
145 * Initialize all perspectives
147 initAll( $.makeArray($('.tabs li')), initialize);
148 console.log(location.hash);