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();
99 // description: function(value) {
100 // return value.replace('\n', ');
109 return this.doc.fetchHistory({
115 HistoryPerspective.prototype.showTagForm = function(){
116 var selected = $('#changes-list .entry.selected');
118 if (selected.length != 1) {
119 window.alert("Musisz zaznaczyć dokładnie jedną wersję.");
123 var version = parseInt($("*[data-stub-value='version']", selected[0]).text());
124 $.wiki.showDialog('#add_tag_dialog', {'revision': version});
127 HistoryPerspective.prototype.makeDiff = function() {
128 var changelist = $('#changes-list');
129 var selected = $('.entry.selected', changelist);
131 if (selected.length != 2) {
132 window.alert("Musisz zaznaczyć dokładnie dwie wersje do porównania.");
137 message: 'Wczytywanie porównania...'
140 var rev_from = $("*[data-stub-value='version']", selected[1]).text();
141 var rev_to = $("*[data-stub-value='version']", selected[0]).text();
143 return this.doc.fetchDiff({
146 success: function(doc, data){
147 var result = $.wiki.newTab(doc, ''+rev_from +' -> ' + rev_to, 'DiffPerspective');
149 $(result.view).html(data);
150 $.wiki.switchToTab(result.tab);
153 failure: function(doc){
159 $.wiki.HistoryPerspective = HistoryPerspective;