X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/8f0e18f498d6c07937c92d186bfa6b654a1afa14..af0693ddb5e4f6240d273c8a66fd1e6ef2a52872:/redakcja/static/js/wiki/view_history.js?ds=sidebyside diff --git a/redakcja/static/js/wiki/view_history.js b/redakcja/static/js/wiki/view_history.js index 348f0c78..94a369b6 100644 --- a/redakcja/static/js/wiki/view_history.js +++ b/redakcja/static/js/wiki/view_history.js @@ -15,6 +15,10 @@ self.showTagForm(); }); + $('#doc-revert-button').click(function() { + self.revertDialog(); + }); + $('#open-preview-button').click(function(event) { var selected = $('#changes-list .entry.selected'); @@ -31,11 +35,23 @@ $('#changes-list .entry').live('click', function(){ var $this = $(this); - if ($this.hasClass('selected')) - return $this.removeClass('selected'); - if ($("#changes-list .entry.selected").length < 2) - return $this.addClass('selected'); + 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; + }; + }; + + $('#history-view-editor .toolbar button').attr('disabled', 'disabled'). + filter('*[data-enabled-when~=' + selected_count + '], *[data-enabled-when~=*]'). + attr('disabled', null); }); $('#changes-list span.tag').live('click', function(event){ @@ -156,6 +172,19 @@ }); }; + HistoryPerspective.prototype.revertDialog = function(){ + var self = this; + var selected = $('#changes-list .entry.selected'); + + if (selected.length != 1) { + window.alert("Musisz zaznaczyć dokładnie jedną wersję."); + return; + } + + var version = parseInt($("*[data-stub-value='version']", selected[0]).text()); + $.wiki.showDialog('#revert_dialog', {revision: version}); + }; + $.wiki.HistoryPerspective = HistoryPerspective; })(jQuery);