8 DEFAULT_PERSPECTIVE = "#MotifsPerspective";
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 $(document).on('click', '.tabs li', function(event, callback) {
36 event.preventDefault();
37 $.wiki.switchToTab(this);
40 $(document).on('click', '#tabs li .tabclose', function(event, callback) {
41 var $tab = $(this).parent().parent();
43 if($('a', $tab).is('.active'))
44 $.wiki.switchToTab(DEFAULT_PERSPECTIVE);
46 var p = $.wiki.perspectiveForTab($tab);
53 window.onbeforeunload = function(e) {
54 if($.wiki.isDirty()) {
55 e.returnValue = "Na stronie mogą być nie zapisane zmiany.";
56 return "Na stronie mogą być nie zapisane zmiany.";
60 console.log("Fetching document's text");
62 $(document).bind('wlapi_document_changed', function(event, doc) {
64 $('#document-revision').text(doc.revision);
66 console.log("Failed handler", e);
70 CurrentDocument.fetch({
72 console.log("Fetch success");
73 $('#loading-overlay').fadeOut();
74 var active_tab = document.location.hash || DEFAULT_PERSPECTIVE;
76 console.log("Initial tab is:", active_tab)
77 $.wiki.switchToTab(active_tab);
80 $('#loading-overlay').fadeOut();
84 }; /* end of initialize() */
87 /* Load configuration */
90 var initAll = function(a, f) {
91 if (a.length == 0) return f();
104 * Initialize all perspectives
106 initAll( $.makeArray($('.tabs li')), initialize);
107 console.log(location.hash);