8 var DEFAULT_PERSPECTIVE = "#SummaryPerspective";
12 var tabs = $('ol#tabs li');
14 CurrentDocument = new $.wikiapi.WikiDocument("document-meta");
16 $.blockUI.defaults.baseZ = 10000;
20 gallery = new $.wiki.ScanGalleryPerspective({
21 doc: CurrentDocument, id: "ScanGalleryPerspective"
24 $(document).keydown(function(event) {
25 console.log("Received key:", event);
29 $('#save-button').click(function(event){
30 event.preventDefault();
31 $.wiki.showDialog('#save_dialog');
39 $('#tabs li').live('click', function(event, callback) {
40 $.wiki.switchToTab(this);
43 $('#tabs li > .tabclose').live('click', function(event, callback) {
44 var $tab = $(this).parent();
46 if($tab.is('.active'))
47 $.wiki.switchToTab(DEFAULT_PERSPECTIVE);
49 var p = $.wiki.perspectiveForTab($tab);
56 $(window).resize(function(){
57 $('iframe').height($(window).height() - $('#tabs').outerHeight() - $('#source-editor .toolbar').outerHeight());
62 $('.vsplitbar').toggle(
64 $.wiki.state.perspectives.ScanGalleryPerspective.show = true;
65 $('#side-gallery').show();
66 $('.vsplitbar').css('right', 480).addClass('.active');
67 $('#editor .editor').css('right', 510);
72 $.wiki.state.perspectives.ScanGalleryPerspective.show = false;
73 $('#side-gallery').hide();
74 $('.vsplitbar').css('right', 0).removeClass('active');
75 $('#editor .editor').css('right', 30);
81 if($.wiki.state.perspectives.ScanGalleryPerspective.show)
82 $('.vsplitbar').trigger('click');
84 window.onbeforeunload = function(e) {
85 if($.wiki.isDirty()) {
86 e.returnValue = "Na stronie mogą być nie zapisane zmiany.";
87 return "Na stronie mogą być nie zapisane zmiany.";
91 console.log("Fetching document's text");
93 $(document).bind('wlapi_document_changed', function(event, doc) {
95 $('#document-revision').text(doc.revision);
97 console.log("Failed handler", e);
101 CurrentDocument.fetch({
103 console.log("Fetch success");
104 $('#loading-overlay').fadeOut();
105 var active_tab = document.location.hash || DEFAULT_PERSPECTIVE;
107 if(active_tab == "#ScanGalleryPerspective")
108 active_tab = DEFAULT_PERSPECTIVE;
110 console.log("Initial tab is:", active_tab)
111 $.wiki.switchToTab(active_tab);
113 failure: function() {
114 $('#loading-overlay').fadeOut();
118 }; /* end of initialize() */
121 /* Load configuration */
124 var initAll = function(a, f) {
125 if (a.length == 0) return f();
129 doc: CurrentDocument,
130 callback: function(){
138 * Initialize all perspectives
140 initAll( $.makeArray($('ol#tabs li')), initialize);
141 console.log(location.hash);