X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/9d566b4741eb66bf09b5c7d213aa8541886e100a..971e08cc34959303fbbc8bc50742c9fbe1d66f53:/src/redakcja/static/js/wiki/view_history.js diff --git a/src/redakcja/static/js/wiki/view_history.js b/src/redakcja/static/js/wiki/view_history.js index e9693b71..def2bb6e 100644 --- a/src/redakcja/static/js/wiki/view_history.js +++ b/src/redakcja/static/js/wiki/view_history.js @@ -2,94 +2,69 @@ class HistoryPerspective extends $.wiki.Perspective { constructor(options) { - var old_callback = options.callback || function() {}; - - options.callback = function() { - var self = this; - if (CurrentDocument.diff) { - rev_from = CurrentDocument.diff[0]; - rev_to = CurrentDocument.diff[1]; - this.doc.fetchDiff({ - from: rev_from, - to: rev_to, - success: function(doc, data){ - var result = $.wiki.newTab(doc, ''+rev_from +' -> ' + rev_to, 'DiffPerspective'); - - $(result.view).html(data); - $.wiki.switchToTab(result.tab); - } - }); - } + super(options); + var self = this; - // first time page is rendered - $('#make-diff-button').click(function() { - self.makeDiff(); - }); + // first time page is rendered + $('#make-diff-button').click(function() { + self.makeDiff(); + }); - $('#pubmark-changeset-button').click(function() { - self.showPubmarkForm(); - }); + $('#pubmark-changeset-button').click(function() { + self.showPubmarkForm(); + }); - $('#doc-revert-button').click(function() { - self.revertDialog(); - }); + $('#doc-revert-button').click(function() { + self.revertDialog(); + }); - $('#open-preview-button').click(function(event) { - var selected = $('#changes-list .entry.selected'); + $('#open-preview-button').click(function(event) { + var selected = $('#changes-list .entry.selected'); - if (selected.length != 1) { - window.alert("Wybierz dokładnie *jedną* wersję."); - return; - } + if (selected.length != 1) { + window.alert("Wybierz dokładnie *jedną* wersję."); + return; + } - var version = parseInt($("*[data-stub-value='version']", selected[0]).text()); - window.open($(this).attr('data-basehref') + "?revision=" + version); + var version = parseInt($("*[data-stub-value='version']", selected[0]).text()); + window.open($(this).attr('data-basehref') + "?revision=" + version); - event.preventDefault(); - }); + event.preventDefault(); + }); - $(document).on('click', '#changes-list .entry', function(){ - var $this = $(this); + $(document).on('click', '#changes-list .entry', function(){ + var $this = $(this); - var selected_count = $("#changes-list .entry.selected").length; + var selected_count = $("#changes-list .entry.selected").length; - if ($this.hasClass('selected')) { - $this.removeClass('selected'); - selected_count -= 1; - } - else { - if (selected_count < 2) { - $this.addClass('selected'); - selected_count += 1; - }; + if ($this.hasClass('selected')) { + $this.removeClass('selected'); + selected_count -= 1; + } + else { + if (selected_count < 2) { + $this.addClass('selected'); + selected_count += 1; }; + }; - $('#history-view-editor .toolbar button').attr('disabled', 'disabled'). - filter('*[data-enabled-when~="' + selected_count + '"]'). - attr('disabled', null); - }); - - $(document).on('click', '#changes-list span.tag', function(event){ - return false; - }); - - $('#history-view').on('scroll', function() { - if (self.finished || self.fetching) return; - var elemTop = $('#history-view .message-box').offset().top; - var windowH = $(window).innerHeight(); - if (elemTop - 20 < windowH) { - self.triggerFetch(); - } - }); - - old_callback.call(this); - } + $('#history-view-editor .toolbar button').attr('disabled', 'disabled'). + filter('*[data-enabled-when~="' + selected_count + '"]'). + attr('disabled', null); + }); - super(options); - } + $(document).on('click', '#changes-list span.tag', function(event){ + return false; + }); - freezeState() { - // must + $('#history-view').on('scroll', function() { + if (self.finished || self.fetching) return; + var elemTop = $('#history-view .message-box').offset().top; + var windowH = $(window).innerHeight(); + if (elemTop - 20 < windowH) { + self.triggerFetch(); + } + }); } onEnter(success, failure) { @@ -175,26 +150,10 @@ return; } - $.blockUI({ - message: 'Wczytywanie porównania...' - }); - var rev_from = $("*[data-stub-value='version']", selected[1]).text(); var rev_to = $("*[data-stub-value='version']", selected[0]).text(); - return this.doc.fetchDiff({ - from: rev_from, - to: rev_to, - success: function(doc, data){ - var result = $.wiki.newTab(doc, ''+rev_from +' -> ' + rev_to, 'DiffPerspective'); - $(result.view).html(data); - $.wiki.switchToTab(result.tab); - $.unblockUI(); - }, - failure: function(doc){ - $.unblockUI(); - } - }); + $.wiki.DiffPerspective.open(rev_from, rev_to); } revertDialog() {