3 function HistoryPerspective(options) {
4 var old_callback = options.callback || function() {};
6 options.callback = function() {
8 if (CurrentDocument.diff) {
9 rev_from = CurrentDocument.diff[0];
10 rev_to = CurrentDocument.diff[1];
14 success: function(doc, data){
15 var result = $.wiki.newTab(doc, ''+rev_from +' -> ' + rev_to, 'DiffPerspective');
17 $(result.view).html(data);
18 $.wiki.switchToTab(result.tab);
23 // first time page is rendered
24 $('#make-diff-button').click(function() {
28 $('#tag-changeset-button').click(function() {
32 $('#pubmark-changeset-button').click(function() {
33 self.showPubmarkForm();
36 $('#doc-revert-button').click(function() {
40 $('#open-preview-button').click(function(event) {
41 var selected = $('#changes-list .entry.selected');
43 if (selected.length != 1) {
44 window.alert("Wybierz dokładnie *jedną* wersję.");
48 var version = parseInt($("*[data-stub-value='version']", selected[0]).text());
49 window.open($(this).attr('data-basehref') + "?revision=" + version);
51 event.preventDefault();
54 $('#changes-list .entry').live('click', function(){
57 var selected_count = $("#changes-list .entry.selected").length;
59 if ($this.hasClass('selected')) {
60 $this.removeClass('selected');
64 if (selected_count < 2) {
65 $this.addClass('selected');
70 $('#history-view-editor .toolbar button').attr('disabled', 'disabled').
71 filter('*[data-enabled-when~=' + selected_count + '], *[data-enabled-when~=*]').
72 attr('disabled', null);
75 $('#changes-list span.tag').live('click', function(event){
79 old_callback.call(this);
82 $.wiki.Perspective.call(this, options);
85 HistoryPerspective.prototype = new $.wiki.Perspective();
87 HistoryPerspective.prototype.freezeState = function(){
91 HistoryPerspective.prototype.onEnter = function(success, failure){
92 $.wiki.Perspective.prototype.onEnter.call(this);
95 message: 'Odświeżanie historii...'
98 function _finalize(s){
111 function _failure(doc, message){
112 $('#history-view .message-box').html('Nie udało się odświeżyć historii:' + message).show();
116 function _success(doc, data){
117 $('#history-view .message-box').hide();
118 var changes_list = $('#changes-list');
119 var $stub = $('#history-view .row-stub');
120 changes_list.html('');
122 var tags = $('select#id_addtag-tag option');
124 $.each(data, function(){
126 container: changes_list,
130 // tag: function(value) {
131 // return tags.filter("*[value='"+value+"']").text();
133 // description: function(value) {
134 // return value.replace('\n', ');
143 return this.doc.fetchHistory({
149 HistoryPerspective.prototype.showTagForm = function(){
150 var selected = $('#changes-list .entry.selected');
152 if (selected.length != 1) {
153 window.alert("Musisz zaznaczyć dokładnie jedną wersję.");
157 var version = parseInt($("*[data-stub-value='version']", selected[0]).text());
158 $.wiki.showDialog('#add_tag_dialog', {'revision': version});
161 HistoryPerspective.prototype.showPubmarkForm = function(){
162 var selected = $('#changes-list .entry.selected');
164 if (selected.length != 1) {
165 window.alert("Musisz zaznaczyć dokładnie jedną wersję.");
169 var version = parseInt($("*[data-stub-value='version']", selected[0]).text());
170 $.wiki.showDialog('#pubmark_dialog', {'revision': version});
173 HistoryPerspective.prototype.makeDiff = function() {
174 var changelist = $('#changes-list');
175 var selected = $('.entry.selected', changelist);
177 if (selected.length != 2) {
178 window.alert("Musisz zaznaczyć dokładnie dwie wersje do porównania.");
183 message: 'Wczytywanie porównania...'
186 var rev_from = $("*[data-stub-value='version']", selected[1]).text();
187 var rev_to = $("*[data-stub-value='version']", selected[0]).text();
189 return this.doc.fetchDiff({
192 success: function(doc, data){
193 var result = $.wiki.newTab(doc, ''+rev_from +' -> ' + rev_to, 'DiffPerspective');
195 $(result.view).html(data);
196 $.wiki.switchToTab(result.tab);
199 failure: function(doc){
205 HistoryPerspective.prototype.revertDialog = function(){
207 var selected = $('#changes-list .entry.selected');
209 if (selected.length != 1) {
210 window.alert("Musisz zaznaczyć dokładnie jedną wersję.");
214 var version = parseInt($("*[data-stub-value='version']", selected[0]).text());
215 $.wiki.showDialog('#revert_dialog', {revision: version});
218 $.wiki.HistoryPerspective = HistoryPerspective;