+ WikiDocument.prototype.publish = function(params) {
+ params = $.extend({}, noops, params);
+ var self = this;
+ $.ajax({
+ url: reverse("ajax_publish", self.id),
+ type: "POST",
+ dataType: "json",
+ success: function(data) {
+ params.success(self, data);
+ },
+ error: function(xhr) {
+ if (xhr.status == 403 || xhr.status == 401) {
+ params.failure(self, "Nie masz uprawnień lub nie jesteś zalogowany.");
+ }
+ else {
+ try {
+ params.failure(self, xhr.responseText);
+ }
+ catch (e) {
+ params.failure(self, "Nie udało się - błąd serwera.");
+ };
+ };
+
+ }
+ });
+ };
+ WikiDocument.prototype.setTag = function(params) {
+ params = $.extend({}, noops, params);
+ var self = this;
+ var data = {
+ "id": self.id,
+ };
+ /* unpack form */
+ $.each(params.form.serializeArray(), function() {
+ data[this.name] = this.value;
+ });
+ $.ajax({
+ url: reverse("ajax_document_addtag", self.id),
+ type: "POST",
+ dataType: "json",
+ data: data,
+ success: function(data) {
+ params.success(self, data.message);
+ },
+ error: function(xhr) {
+ if (xhr.status == 403 || xhr.status == 401) {
+ params.failure(self, {
+ "__all__": ["Nie masz uprawnień lub nie jesteś zalogowany."]
+ });
+ }
+ else {
+ try {
+ params.failure(self, $.parseJSON(xhr.responseText));
+ }
+ catch (e) {
+ params.failure(self, {
+ "__all__": ["Nie udało się - błąd serwera."]
+ });
+ };
+
+ };
+
+ }
+ });
+ };