X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/8132fc186eb0c5fd02c86828c3a4735754296d02..5913c54d19b8f6775633176032161d49f9b2f1aa:/src/redakcja/static/js/wiki_img/loader_readonly.js diff --git a/src/redakcja/static/js/wiki_img/loader_readonly.js b/src/redakcja/static/js/wiki_img/loader_readonly.js new file mode 100755 index 00000000..99e5ad0e --- /dev/null +++ b/src/redakcja/static/js/wiki_img/loader_readonly.js @@ -0,0 +1,93 @@ +if (!window.console) { + window.console = { + log: function(){ + } + } +} + + +DEFAULT_PERSPECTIVE = "#MotifsPerspective"; + + +$(function() +{ + var tabs = $('ol#tabs li'); + var gallery = null; + + CurrentDocument = new $.wikiapi.WikiDocument("document-meta"); + $.blockUI.defaults.baseZ = 10000; + + function initialize() + { + $('.editor').hide(); + + /* + * TABS + */ + $('#tabs li').live('click', function(event, callback) { + event.preventDefault(); + $.wiki.switchToTab(this); + }); + + $('#tabs li > .tabclose').live('click', function(event, callback) { + var $tab = $(this).parent(); + + if($tab.is('.active')) + $.wiki.switchToTab(DEFAULT_PERSPECTIVE); + + var p = $.wiki.perspectiveForTab($tab); + p.destroy(); + return false; + }); +/* + $(window).resize(function(){ + $('iframe').height($(window).height() - $('#tabs').outerHeight() - $('#source-editor .toolbar').outerHeight()); + }); + */ + + $(document).bind('wlapi_document_changed', function(event, doc) { + try { + $('#document-revision').text(doc.revision); + } catch(e) { + console.log("Failed handler", e); + } + }); + + CurrentDocument.fetch({ + success: function(){ + console.log("Fetch success"); + $('#loading-overlay').fadeOut(); + var active_tab = document.location.hash || DEFAULT_PERSPECTIVE; + + console.log("Initial tab is:", active_tab) + $.wiki.switchToTab(active_tab); + }, + failure: function() { + $('#loading-overlay').fadeOut(); + alert("FAILURE"); + } + }); + }; /* end of initialize() */ + + /* Load configuration */ + $.wiki.loadConfig(); + + var initAll = function(a, f) { + if (a.length == 0) return f(); + + $.wiki.initTab({ + tab: a.pop(), + doc: CurrentDocument, + callback: function(){ + initAll(a, f); + } + }); + }; + + + /* + * Initialize all perspectives + */ + initAll( $.makeArray($('ol#tabs li')), initialize); + console.log(location.hash); +});