X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/9d566b4741eb66bf09b5c7d213aa8541886e100a..87bd94a94dc6cc3dbf47db2bdd17761b3f400138:/src/redakcja/static/js/wiki/view_column_diff.js diff --git a/src/redakcja/static/js/wiki/view_column_diff.js b/src/redakcja/static/js/wiki/view_column_diff.js index beb36ed5..30ef1bd4 100644 --- a/src/redakcja/static/js/wiki/view_column_diff.js +++ b/src/redakcja/static/js/wiki/view_column_diff.js @@ -2,27 +2,50 @@ class DiffPerspective extends $.wiki.Perspective { constructor(options) { - var old_callback = options.callback || function() {}; + super(options); + this.base_id = options.base_id; + } - options.callback = function() { - var self = this; - self.base_id = options.base_id; - old_callback.call(this); - }; - super(options); + static openId(id) { + let match = id.match(/R(\d+)-(\d+)/); + if (!match) + return []; + return this.open(match[1], match[2]); } - freezeState() { - // must - }; + static open(revFrom, revTo) { + let tabId = 'R' + revFrom + '-' + revTo; + let tab = $(".tabs #DiffPerspective_" + tabId); + if (tab.length) { + $.wiki.switchToTab(tab); + } else { + let result = $.wiki.newTab(CurrentDocument, ''+revFrom +' → ' + revTo, 'DiffPerspective', tabId); + $.blockUI({ + message: 'Wczytywanie porównania...' + }); + + CurrentDocument.fetchDiff({ + from: revFrom, + to: revTo, + success: function(doc, data){ + $(result.view).html(data); + $.wiki.switchToTab(result.tab); + $.unblockUI(); + }, + failure: function(doc){ + $.unblockUI(); + } + }); + return result.tab; + } + } - destroy() { + destroy() { $.wiki.switchToTab('#HistoryPerspective'); $('#' + this.base_id).remove(); $('#' + this.perspective_id).remove(); - } + } } $.wiki.DiffPerspective = DiffPerspective; })(jQuery); -