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                 $('#changes-list .entry').live('click', function(){
 
  20                 if ($this.hasClass('selected'))
 
  21                         return $this.removeClass('selected');
 
  23                 if ($("#changes-list .entry.selected").length < 2)
 
  24                         return $this.addClass('selected');
 
  27             $('#changes-list span.tag').live('click', function(event){
 
  31                 old_callback.call(this);
 
  34                 $.wiki.Perspective.call(this, options);
 
  37     HistoryPerspective.prototype = new $.wiki.Perspective();
 
  39     HistoryPerspective.prototype.freezeState = function(){
 
  43     HistoryPerspective.prototype.onEnter = function(success, failure){
 
  44         $.wiki.Perspective.prototype.onEnter.call(this);
 
  47             message: 'Odświeżanie historii...'
 
  50         function _finalize(s){
 
  63         function _failure(doc, message){
 
  64             $('#history-view .message-box').html('Nie udało się odświeżyć historii:' + message).show();
 
  68         function _success(doc, data){
 
  69             $('#history-view .message-box').hide();
 
  70             var changes_list = $('#changes-list');
 
  71             var $stub = $('#history-view .row-stub');
 
  72             changes_list.html('');
 
  74                         var tags = $('select#id_addtag-tag option');
 
  76             $.each(data, function(){
 
  78                                         container: changes_list,
 
  82                                                 tag: function(value) {
 
  83                                                         return tags.filter("*[value='"+value+"']").text();
 
  92         return this.doc.fetchHistory({
 
  98         HistoryPerspective.prototype.showTagForm = function(){
 
  99                 var selected = $('#changes-list .entry.selected');
 
 101                 if (selected.length != 1) {
 
 102             window.alert("Musisz dokładnie jedną wersję do oznaczenia.");
 
 106                 var version = parseInt($("*[data-stub-value='version']", selected[0]).text());
 
 107                 $.wiki.showDialog('#add_tag_dialog', {'revision': version});
 
 110         HistoryPerspective.prototype.makeDiff = function() {
 
 111         var changelist = $('#changes-list');
 
 112         var selected = $('.entry.selected', changelist);
 
 114         if (selected.length != 2) {
 
 115             window.alert("Musisz zaznaczyć dokładnie dwie wersje do porównania.");
 
 120             message: 'Wczytywanie porównania...'
 
 123                 var rev_from = $("*[data-stub-value='version']", selected[1]).text();
 
 124                 var rev_to =  $("*[data-stub-value='version']", selected[0]).text();
 
 126         return this.doc.fetchDiff({
 
 129             success: function(doc, data){
 
 130                 var result = $.wiki.newTab(doc, ''+rev_from +' -> ' + rev_to, 'DiffPerspective');
 
 132                                 $(result.view).html(data);
 
 133                                 $.wiki.switchToTab(result.tab);
 
 136             failure: function(doc){
 
 142     $.wiki.HistoryPerspective = HistoryPerspective;