3 function fetchDiff(success, failed){
4 var changelist = $('#changes-list');
6 var selected = $('div.selected', changelist);
8 if (selected.length != 2) {
9 window.alert("Musisz zaznaczyć dokładnie dwie wersje do porównania.");
14 message: 'Wczytywanie porównania...'
19 url: document.location.href + '/diff/' + rev_a.val() + '/' + rev_b.val(),
23 if(failed) failed('Nie udało się wczytać porównania z serwera.');
25 success: function(data){
26 var diffview = $('#diff-view');
30 if(success) success(data);
35 function HistoryPerspective(doc, callback) {
36 this.perspective_id = 'HistoryPerspective';
39 // first time page is rendered
40 $('#make-diff-button').click(fetchDiff);
42 $('#changes-list div').live('click', function() {
44 if($this.hasClass('selected'))
45 return $this.removeClass('selected');
47 if($("#changes-list div.selected").length < 2)
48 return $this.addClass('selected');
51 $('#changes-list span.tag').live('click', function(event) {
58 HistoryPerspective.prototype = new $.wiki.Perspective();
60 HistoryPerspective.prototype.freezeState = function(){
64 HistoryPerspective.prototype.onEnter = function(success, failure)
66 $.wiki.Perspective.prototype.onEnter.call(this);
69 message: 'Odświeżanie historii...'
72 function _finalize(s) {
75 if(s) { if(success) success(); }
76 else { if(failure) failure(); }
79 function _failure(doc, message) {
80 $('#history-view .message-box').html('Nie udało się odświeżyć historii:' + message).show();
84 function _success(doc, data) {
85 $('#history-view .message-box').hide();
86 var changes_list = $('#changes-list');
87 var $stub = $('#history-view .row-stub');
88 changes_list.html('');
90 $.each(data, function(){
91 $.wiki.renderStub(changes_list, $stub, this);
94 $('span[data-version-tag]', changes_list).each(function() {
95 $(this).text($(this).attr('data-version-tag'));
101 return this.doc.fetchHistory({success: _success, failure: _failure});
104 $.wiki.HistoryPerspective = HistoryPerspective;