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').css('right', 480).addClass('active');
 
  63                                 $('#editor .editor').css('right', 510);
 
  65                                 $.wiki.perspectiveForTab('#tabs-right .active').onEnter();
 
  68                                 $.wiki.state.perspectives.ScanGalleryPerspective.show = false;
 
  70                                 $('.vsplitbar').css('right', 0).removeClass('active');
 
  71                                 $('#editor .editor').css('right', 30);
 
  73                                 $.wiki.perspectiveForTab('#tabs-right .active').onExit();
 
  77                 if($.wiki.state.perspectives.ScanGalleryPerspective.show)
 
  78                         $('.vsplitbar').trigger('click');
 
  80         window.onbeforeunload = function(e) {
 
  81             if($.wiki.isDirty()) {
 
  82                                 e.returnValue = "Na stronie mogą być nie zapisane zmiany.";
 
  83                                 return "Na stronie mogą być nie zapisane zmiany.";
 
  87                 console.log("Fetching document's text");
 
  89                 $(document).bind('wlapi_document_changed', function(event, doc) {
 
  91                                 $('#document-revision').text(doc.revision);
 
  93                                 console.log("Failed handler", e);
 
  97                 CurrentDocument.fetch({
 
  99                                 console.log("Fetch success");
 
 100                                 $('#loading-overlay').fadeOut();
 
 101                                 var active_tab = document.location.hash || DEFAULT_PERSPECTIVE;
 
 103                                 if(active_tab == "#ScanGalleryPerspective")
 
 104                                         active_tab = DEFAULT_PERSPECTIVE;
 
 106                                 console.log("Initial tab is:", active_tab)
 
 107                                 $.wiki.switchToTab(active_tab);
 
 109                         failure: function() {
 
 110                                 $('#loading-overlay').fadeOut();
 
 114     }; /* end of initialize() */
 
 117         /* Load configuration */
 
 120         var initAll = function(a, f) {
 
 121                 if (a.length == 0) return f();
 
 125                         doc: CurrentDocument,
 
 126                         callback: function(){
 
 134          * Initialize all perspectives
 
 136         initAll( $.makeArray($('.tabs li')), initialize);
 
 137         console.log(location.hash);