Added form for tagging.
--- /dev/null
+from django import http
+from django.utils import simplejson as json
+from django.utils.functional import Promise
+from django.template.loader import render_to_string
+from datetime import datetime
+
+class ExtendedEncoder(json.JSONEncoder):
+
+ def default(self, obj):
+ if isinstance(obj, Promise):
+ return unicode(obj)
+
+ if isinstance(obj, datetime):
+ return datetime.ctime(obj) + " " + (datetime.tzname(obj) or 'GMT')
+
+ return json.JSONEncoder.default(self, obj)
+
+# shortcut for JSON reponses
+class JSONResponse(http.HttpResponse):
+
+ def __init__(self, data = {}, **kwargs):
+ # get rid of mimetype
+ kwargs.pop('mimetype', None)
+
+ super(JSONResponse, self).__init__(
+ json.dumps(data, cls=ExtendedEncoder),
+ mimetype = "application/json", **kwargs)
+
+
+# return errors
+class JSONFormInvalid(JSONResponse):
+ def __init__(self, form):
+ super(JSONFormInvalid, self).__init__(form.errors, status = 400)
+
+class JSONServerError(JSONResponse):
+ def __init__(self, *args, **kwargs):
+ kwargs['status'] = 500
+ super(JSONServerError, self).__init__(*args, **kwargs)
+
+
+
\ No newline at end of file
--- /dev/null
+<div id="add_tag_dialog" class="dialog">
+ <form method="POST" action="">
+ {{ forms.add_tag.as_p }}
+ </form>
+</div>
--- /dev/null
+(function(jQuery){jQuery.fn.extend({elastic:function(){var mimics=['paddingTop','paddingRight','paddingBottom','paddingLeft','fontSize','lineHeight','fontFamily','width','fontWeight'];return this.each(function(){if(this.type!='textarea'){return false;}
+var $textarea=jQuery(this),$twin=jQuery('<div />').css({'position':'absolute','display':'none','word-wrap':'break-word'}),lineHeight=parseInt($textarea.css('line-height'),10)||parseInt($textarea.css('font-size'),'10'),minheight=parseInt($textarea.css('height'),10)||lineHeight*3,maxheight=parseInt($textarea.css('max-height'),10)||Number.MAX_VALUE,goalheight=0,i=0;if(maxheight<0){maxheight=Number.MAX_VALUE;}
+$twin.appendTo($textarea.parent());var i=mimics.length;while(i--){$twin.css(mimics[i].toString(),$textarea.css(mimics[i].toString()));}
+function setHeightAndOverflow(height,overflow){curratedHeight=Math.floor(parseInt(height,10));if($textarea.height()!=curratedHeight){$textarea.css({'height':curratedHeight+'px','overflow':overflow});}}
+function update(){var textareaContent=$textarea.val().replace(/&/g,'&').replace(/ /g,' ').replace(/<|>/g,'>').replace(/\n/g,'<br />');var twinContent=$twin.html();if(textareaContent+' '!=twinContent){$twin.html(textareaContent+' ');if(Math.abs($twin.height()+lineHeight-$textarea.height())>3){var goalheight=$twin.height()+lineHeight;if(goalheight>=maxheight){setHeightAndOverflow(maxheight,'auto');}else if(goalheight<=minheight){setHeightAndOverflow(minheight,'hidden');}else{setHeightAndOverflow(goalheight,'hidden');}}}}
+$textarea.css({'overflow':'hidden'});$textarea.keyup(function(){update();});$textarea.live('input paste',function(e){setTimeout(update,250);});update();});}});})(jQuery);
\ No newline at end of file
--- /dev/null
+(function($){
+
+ function DiffPerspective(options) {
+ var old_callback = options.callback || function() {};
+ options.callback = function(){
+ old_callback.call(this);
+ };
+
+ $.wiki.Perspective.call(this, options);
+ };
+
+ DiffPerspective.prototype = new $.wiki.Perspective();
+
+ DiffPerspective.prototype.freezeState = function(){
+ // must
+ };
+
+ DiffPerspective.prototype.onEnter = function(success, failure){
+ $.wiki.Perspective.prototype.onEnter.call(this);
+
+ console.log("Entered diff view");
+ };
+
+ $.wiki.DiffPerspective = DiffPerspective;
+
+})(jQuery);
+
--- /dev/null
+/*
+ * Dialog for saving document to the server
+ *
+ */
+(function($) {
+
+ function SaveDialog(element) {
+ $.wiki.cls.GenericDialog.call(this, element);
+ this.ctx = $.wiki.exitContext();
+ };
+
+ SaveDialog.prototype = new $.wiki.cls.GenericDialog();
+
+ SaveDialog.prototype
+
+ SaveDialog.prototype.saveAction = function() {
+ var self = this;
+
+ self.$elem.block({
+ message: "Zapisywanie..."
+ });
+
+ try {
+
+ CurrentDocument.save({
+ comment: $("#komentarz").text(),
+ success: function(doc, changed, info){
+ self.$elem.block({
+ message: info,
+ timeout: 1000,
+ fadeOut: 0,
+ onUnblock: function() {
+ self.hide();
+ }
+ });
+ },
+ failure: function(doc, info) {
+ self.reportErrors(info);
+ self.$elem.unblock();
+ }
+ });
+ } catch(e) {
+ console.log('Exception:', e)
+ self.$elem.unblock();
+ }
+ }; /* end of save dialog */
+
+ /* make it global */
+ $.wiki.cls.SaveDialog = SaveDialog;
+})(jQuery);