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) {
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() {