cover previews
[redakcja.git] / redakcja / static / js / wiki / view_summary.js
index de6fcf1..8fdf4b9 100644 (file)
@@ -1,11 +1,32 @@
 (function($){
 
        function SummaryPerspective(options) {
+               var old_callback = options.callback || function() {};
+
+               options.callback = function() {
+                       var self = this;
+
+                       // first time page is rendered
+               $('#summary-cover-refresh').click(function() {
+                               self.refreshCover();
+                       });
+
+               old_callback.call(this);
+               }
+
                $.wiki.Perspective.call(this, options);
     };
 
     SummaryPerspective.prototype = new $.wiki.Perspective();
 
+       SummaryPerspective.prototype.refreshCover = function() {
+               this.doc.refreshCover({
+                       success: function(text) {
+                               $('#summary-cover').attr('src', text);
+                       }
+               });
+       };
+
     SummaryPerspective.prototype.showCharCount = function() {
         var cc;
         try {