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 $('#open-preview-button').click(function(event) {
19 var selected = $('#changes-list .entry.selected');
21 if (selected.length != 1) {
22 window.alert("Wybierz dokładnie *jedną* wersję.");
26 var version = parseInt($("*[data-stub-value='version']", selected[0]).text());
27 window.open($(this).attr('data-basehref') + "?revision=" + version);
29 event.preventDefault();
32 $('#changes-list .entry').live('click', function(){
34 if ($this.hasClass('selected'))
35 return $this.removeClass('selected');
37 if ($("#changes-list .entry.selected").length < 2)
38 return $this.addClass('selected');
41 $('#changes-list span.tag').live('click', function(event){
45 old_callback.call(this);
48 $.wiki.Perspective.call(this, options);
51 HistoryPerspective.prototype = new $.wiki.Perspective();
53 HistoryPerspective.prototype.freezeState = function(){
57 HistoryPerspective.prototype.onEnter = function(success, failure){
58 $.wiki.Perspective.prototype.onEnter.call(this);
61 message: 'Odświeżanie historii...'
64 function _finalize(s){
77 function _failure(doc, message){
78 $('#history-view .message-box').html('Nie udało się odświeżyć historii:' + message).show();
82 function _success(doc, data){
83 $('#history-view .message-box').hide();
84 var changes_list = $('#changes-list');
85 var $stub = $('#history-view .row-stub');
86 changes_list.html('');
88 var tags = $('select#id_addtag-tag option');
90 $.each(data, function(){
92 container: changes_list,
96 tag: function(value) {
97 return tags.filter("*[value='"+value+"']").text();
106 return this.doc.fetchHistory({
112 HistoryPerspective.prototype.showTagForm = function(){
113 var selected = $('#changes-list .entry.selected');
115 if (selected.length != 1) {
116 window.alert("Musisz zaznaczyć dokładnie jedną wersję.");
120 var version = parseInt($("*[data-stub-value='version']", selected[0]).text());
121 $.wiki.showDialog('#add_tag_dialog', {'revision': version});
124 HistoryPerspective.prototype.makeDiff = function() {
125 var changelist = $('#changes-list');
126 var selected = $('.entry.selected', changelist);
128 if (selected.length != 2) {
129 window.alert("Musisz zaznaczyć dokładnie dwie wersje do porównania.");
134 message: 'Wczytywanie porównania...'
137 var rev_from = $("*[data-stub-value='version']", selected[1]).text();
138 var rev_to = $("*[data-stub-value='version']", selected[0]).text();
140 return this.doc.fetchDiff({
143 success: function(doc, data){
144 var result = $.wiki.newTab(doc, ''+rev_from +' -> ' + rev_to, 'DiffPerspective');
146 $(result.view).html(data);
147 $.wiki.switchToTab(result.tab);
150 failure: function(doc){
156 $.wiki.HistoryPerspective = HistoryPerspective;