3 function HistoryPerspective(options) {
4 var old_callback = options.callback || function() {};
6 options.callback = function() {
9 // first time page is rendered
10 $('#make-diff-button').click(function() {
14 $('#tag-changeset-button').click(function() {
18 $('#pubmark-changeset-button').click(function() {
19 self.showPubmarkForm();
22 $('#doc-revert-button').click(function() {
26 $('#open-preview-button').click(function(event) {
27 var selected = $('#changes-list .entry.selected');
29 if (selected.length != 1) {
30 window.alert("Wybierz dokładnie *jedną* wersję.");
34 var version = parseInt($("*[data-stub-value='version']", selected[0]).text());
35 window.open($(this).attr('data-basehref') + "?revision=" + version);
37 event.preventDefault();
40 $('#changes-list .entry').live('click', function(){
43 var selected_count = $("#changes-list .entry.selected").length;
45 if ($this.hasClass('selected')) {
46 $this.removeClass('selected');
50 if (selected_count < 2) {
51 $this.addClass('selected');
56 $('#history-view-editor .toolbar button').attr('disabled', 'disabled').
57 filter('*[data-enabled-when~=' + selected_count + '], *[data-enabled-when~=*]').
58 attr('disabled', null);
61 $('#changes-list span.tag').live('click', function(event){
65 old_callback.call(this);
68 $.wiki.Perspective.call(this, options);
71 HistoryPerspective.prototype = new $.wiki.Perspective();
73 HistoryPerspective.prototype.freezeState = function(){
77 HistoryPerspective.prototype.onEnter = function(success, failure){
78 $.wiki.Perspective.prototype.onEnter.call(this);
81 message: 'Odświeżanie historii...'
84 function _finalize(s){
97 function _failure(doc, message){
98 $('#history-view .message-box').html('Nie udało się odświeżyć historii:' + message).show();
102 function _success(doc, data){
103 $('#history-view .message-box').hide();
104 var changes_list = $('#changes-list');
105 var $stub = $('#history-view .row-stub');
106 changes_list.html('');
108 var tags = $('select#id_addtag-tag option');
110 $.each(data, function(){
112 container: changes_list,
116 // tag: function(value) {
117 // return tags.filter("*[value='"+value+"']").text();
119 // description: function(value) {
120 // return value.replace('\n', ');
129 return this.doc.fetchHistory({
135 HistoryPerspective.prototype.showTagForm = function(){
136 var selected = $('#changes-list .entry.selected');
138 if (selected.length != 1) {
139 window.alert("Musisz zaznaczyć dokładnie jedną wersję.");
143 var version = parseInt($("*[data-stub-value='version']", selected[0]).text());
144 $.wiki.showDialog('#add_tag_dialog', {'revision': version});
147 HistoryPerspective.prototype.showPubmarkForm = function(){
148 var selected = $('#changes-list .entry.selected');
150 if (selected.length != 1) {
151 window.alert("Musisz zaznaczyć dokładnie jedną wersję.");
155 var version = parseInt($("*[data-stub-value='version']", selected[0]).text());
156 $.wiki.showDialog('#pubmark_dialog', {'revision': version});
159 HistoryPerspective.prototype.makeDiff = function() {
160 var changelist = $('#changes-list');
161 var selected = $('.entry.selected', changelist);
163 if (selected.length != 2) {
164 window.alert("Musisz zaznaczyć dokładnie dwie wersje do porównania.");
169 message: 'Wczytywanie porównania...'
172 var rev_from = $("*[data-stub-value='version']", selected[1]).text();
173 var rev_to = $("*[data-stub-value='version']", selected[0]).text();
175 return this.doc.fetchDiff({
178 success: function(doc, data){
179 var result = $.wiki.newTab(doc, ''+rev_from +' -> ' + rev_to, 'DiffPerspective');
181 $(result.view).html(data);
182 $.wiki.switchToTab(result.tab);
185 failure: function(doc){
191 HistoryPerspective.prototype.revertDialog = function(){
193 var selected = $('#changes-list .entry.selected');
195 if (selected.length != 1) {
196 window.alert("Musisz zaznaczyć dokładnie jedną wersję.");
200 var version = parseInt($("*[data-stub-value='version']", selected[0]).text());
201 $.wiki.showDialog('#revert_dialog', {revision: version});
204 $.wiki.HistoryPerspective = HistoryPerspective;