3 class HistoryPerspective extends $.wiki.Perspective {
8 // first time page is rendered
9 $('#make-diff-button').click(function() {
13 $('#pubmark-changeset-button').click(function() {
14 self.showPubmarkForm();
17 $('#doc-revert-button').click(function() {
21 $('#open-preview-button').click(function(event) {
22 var selected = $('#changes-list .entry.selected');
24 if (selected.length != 1) {
25 window.alert("Wybierz dokładnie *jedną* wersję.");
29 var version = parseInt($("*[data-stub-value='version']", selected[0]).text());
30 window.open($(this).attr('data-basehref') + "?revision=" + version);
32 event.preventDefault();
35 $(document).on('click', '#changes-list .entry', function(){
38 var selected_count = $("#changes-list .entry.selected").length;
40 if ($this.hasClass('selected')) {
41 $this.removeClass('selected');
45 if (selected_count < 2) {
46 $this.addClass('selected');
51 $('#history-view-editor .toolbar button').attr('disabled', 'disabled').
52 filter('*[data-enabled-when~="' + selected_count + '"]').
53 attr('disabled', null);
56 $(document).on('click', '#changes-list span.tag', function(event){
60 $('#history-view').on('scroll', function() {
61 if (self.finished || self.fetching) return;
62 var elemTop = $('#history-view .message-box').offset().top;
63 var windowH = $(window).innerHeight();
64 if (elemTop - 20 < windowH) {
70 onEnter(success, failure) {
77 $('#history-view .message-box').html('Wczytywanie historii…').show();
78 $('#changes-list').html('');
79 this.finished = false;
85 $('#history-view .message-box').hide()
92 function _finalize() {
93 self.fetching = false;
96 function _failure(doc, message){
97 $('#history-view .message-box').html('Nie udało się odświeżyć historii:' + message).show();
101 function _success(doc, data){
102 //$('#history-view .message-box').hide(); ONLY AFTER LAST!
103 var changes_list = $('#changes-list');
104 var $stub = $('#history-view .row-stub');
110 $.each(data, function(){
112 container: changes_list,
116 self.before = this.version;
117 if (this.version == 1) {
125 this.doc.fetchHistory({
133 var selected = $('#changes-list .entry.selected');
135 if (selected.length != 1) {
136 window.alert("Musisz zaznaczyć dokładnie jedną wersję.");
140 var version = parseInt($("*[data-stub-value='version']", selected[0]).text());
141 $.wiki.showDialog('#pubmark_dialog', {'revision': version});
145 var changelist = $('#changes-list');
146 var selected = $('.entry.selected', changelist);
148 if (selected.length != 2) {
149 window.alert("Musisz zaznaczyć dokładnie dwie wersje do porównania.");
153 var rev_from = $("*[data-stub-value='version']", selected[1]).text();
154 var rev_to = $("*[data-stub-value='version']", selected[0]).text();
156 $.wiki.DiffPerspective.open(rev_from, rev_to);
161 var selected = $('#changes-list .entry.selected');
163 if (selected.length != 1) {
164 window.alert("Musisz zaznaczyć dokładnie jedną wersję.");
168 var version = parseInt($("*[data-stub-value='version']", selected[0]).text());
169 $.wiki.showDialog('#revert_dialog', {revision: version});
172 $.wiki.HistoryPerspective = HistoryPerspective;