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 .entry .approved', function(){
57 $("#changes-list .entry.selected").removeClass('selected');
58 $(this).closest('.entry').click();
59 self.showPubmarkForm();
62 $(document).on('click', '#changes-list span.tag', function(event){
66 $('#history-view').on('scroll', function() {
67 if (self.finished || self.fetching) return;
68 var elemTop = $('#history-view .message-box').offset().top;
69 var windowH = $(window).innerHeight();
70 if (elemTop - 20 < windowH) {
76 onEnter(success, failure) {
83 $('#history-view .message-box').html('Wczytywanie historii…').show();
84 $('#changes-list').html('');
85 this.finished = false;
91 $('#history-view .message-box').hide()
98 function _finalize() {
99 self.fetching = false;
102 function _failure(doc, message){
103 $('#history-view .message-box').html('Nie udało się odświeżyć historii:' + message).show();
107 function _success(doc, data){
108 //$('#history-view .message-box').hide(); ONLY AFTER LAST!
109 var changes_list = $('#changes-list');
110 var $stub = $('#history-view .row-stub');
116 $.each(data, function(){
118 container: changes_list,
122 self.before = this.version;
123 if (this.version == 1) {
131 this.doc.fetchHistory({
139 var selected = $('#changes-list .entry.selected');
141 if (selected.length != 1) {
142 window.alert("Musisz zaznaczyć dokładnie jedną wersję.");
146 var version = parseInt($("*[data-stub-value='version']", selected[0]).text());
147 var approved = selected.attr('data-approved') == 'true';
148 $.wiki.showDialog('#pubmark_dialog', {'revision': version, 'approved': !approved});
152 var changelist = $('#changes-list');
153 var selected = $('.entry.selected', changelist);
155 if (selected.length != 2) {
156 window.alert("Musisz zaznaczyć dokładnie dwie wersje do porównania.");
160 var rev_from = $("*[data-stub-value='version']", selected[1]).text();
161 var rev_to = $("*[data-stub-value='version']", selected[0]).text();
163 $.wiki.DiffPerspective.open(rev_from, rev_to);
168 var selected = $('#changes-list .entry.selected');
170 if (selected.length != 1) {
171 window.alert("Musisz zaznaczyć dokładnie jedną wersję.");
175 var version = parseInt($("*[data-stub-value='version']", selected[0]).text());
176 $.wiki.showDialog('#revert_dialog', {revision: version});
179 $.wiki.HistoryPerspective = HistoryPerspective;