X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/ab76a5c2c90d386b3d5f40aee3d784b02cb92434..d0928737c06697f6284101bfded61cb8d933ce34:/redakcja/static/js/wiki/dialog_revert.js?ds=sidebyside diff --git a/redakcja/static/js/wiki/dialog_revert.js b/redakcja/static/js/wiki/dialog_revert.js new file mode 100644 index 00000000..4d550f9d --- /dev/null +++ b/redakcja/static/js/wiki/dialog_revert.js @@ -0,0 +1,65 @@ +/* + * Dialog for reverting document on the server + * + */ +(function($) { + + function RevertDialog(element, options) { + this.ctx = $.wiki.exitContext(); + this.clearForm(); + + /* fill out hidden fields */ + this.$form = $('form', element); + + $("input[name='textrevert-revision']", this.$form).val(options.revision); + + $.wiki.cls.GenericDialog.call(this, element); + }; + + RevertDialog.prototype = new $.wiki.cls.GenericDialog(); + + RevertDialog.prototype.cancelAction = function() { + $.wiki.enterContext(this.ctx); + this.hide(); + }; + + RevertDialog.prototype.revertAction = function() { + var self = this; + + self.$elem.block({ + message: "Przywracanie...", + fadeIn: 0, + }); + $.wiki.blocking = self.$elem; + + try { + + CurrentDocument.revertToVersion({ + form: self.$form, + success: function(e, msg) { + self.$elem.block({ + message: msg, + timeout: 2000, + fadeOut: 0, + onUnblock: function() { + self.hide(); + $.wiki.enterContext(self.ctx); + } + }); + }, + 'failure': function(e, info) { + console.log("Failure", info); + self.reportErrors(info); + self.$elem.unblock(); + } + }); + + } catch(e) { + console.log('Exception:', e) + self.$elem.unblock(); + } + }; /* end of revert dialog */ + + /* make it global */ + $.wiki.cls.RevertDialog = RevertDialog; +})(jQuery);