<a href="{{button.link}}" target="_new">\r
{% endif %}\r
<button type="button"\r
- ui:action="{{ button.scriptlet_id }}"\r
- ui:action-params="{{ button.params|escape }}"\r
+ data-ui-action="{{ button.scriptlet_id }}"\r
+ data-ui-action-params="{{ button.params|escape }}"\r
{% if button.key %}ui:hotkey="{{ button.hotkey_code }}"{% endif %}\r
{% if button.tooltip %}title="{{ button.full_tooltip }}"{% endif %} >\r
{{ button.label|safe }}\r
#
from django import forms
from wiki.models import Document, getstorage
+from django.utils.translation import ugettext_lazy as _
class DocumentForm(forms.Form):
+ """ Old form for saving document's text """
+
name = forms.CharField(widget=forms.HiddenInput)
text = forms.CharField(widget=forms.Textarea)
revision = forms.IntegerField(widget=forms.HiddenInput)
return storage.get(self.cleaned_data['name'])
+class DocumentTextSaveForm(forms.Form):
+ """
+ Form for saving document's text:
+
+ * name - document's storage identifier.
+ * parent_revision - revision which the modified text originated from.
+ * comment - user's verbose comment; will be used in commit.
+ * stage_completed - mark this change as end of given stage.
+
+ """
+ DOC_STAGES = (
+ ('', 'Nic konkretnego'),
+ ('tagging', 'Tagowanie'),
+ ('modernized', 'Uwspółcześnienia'),
+ ('editing', 'Redakcja'),
+ )
+
+ id = forms.CharField(widget=forms.HiddenInput)
+ parent_revision = forms.IntegerField(widget=forms.HiddenInput)
+
+ author = forms.CharField(
+ required = False,
+ label = _(u"Autor"),
+ help_text = _(u"Twoje imie i nazwisko lub email.")
+
+ )
+
+ comment = forms.CharField(
+ required = False,
+ widget=forms.Textarea,
+ label = _(u"Twój komentarz"),
+ help_text = _(u"Opisz w miarę dokładnie swoje zmiany."),
+ )
+
+ stage_completed = forms.ChoiceField(
+ choices=DOC_STAGES,
+ required= False,
+ label = _(u"Skończyłem robić"),
+ help_text = _(u"Jeśli skończyłeś jeden z etapów utworu, wybierz go."),
+ )
+
\ No newline at end of file
k, v = line.split(':', 1)
result[k.strip()] = v.strip()
except ValueError:
- continue
+ continue
+
+ if 'gallery' not in result:
+ result['gallery'] = (settings.GALLERY_URL + self.name).replace(' ', '_')
+
+ if 'title' not in result:
+ result['title'] = self.name.title()
return result
+
+ def info(self):
+ return dict(zip(
+ ('revision', 'last_update', 'last_comitter', 'commit_message'),
+ self.storage._info(self.name)
+ ))
def getstorage():
return DocumentStorage(settings.REPOSITORY_PATH)
raise Exception('You must set WIKI_REPOSITORY_PATH in your settings file.')
REPOSITORY_PATH = settings.WIKI_REPOSITORY_PATH
+GALLERY_URL = settings.MEDIA_URL + 'images/'
</div>
</div>
-<div id="document-meta" data-document-name="{{ document.name }}" style="display:none">
-{% for k, v in document.meta.items %}
- <span data-key="{{ k }}">{{ v }}</span>
-{% endfor %}
+<div id="document-meta"
+ data-document-name="{{ document.name }}" style="display:none">
+
+ {% for k, v in document_meta.items %}
+ <span data-key="{{ k }}">{{ v }}</span>
+ {% endfor %}
</div>
<div id="header">
<div id="tools">
<a href="{{ REDMINE_URL }}projects/wl-publikacje/wiki/Pomoc" target="_blank">Pomoc</a>
| {% include "registration/head_login.html" %}
- | Wersja: <span id="document-revision">{{ document.revision }}</span>
+ | Wersja: <span id="document-revision">{{ document_info.revision }}</span>
|
<button style="margin-left: 6px" id="save-button">
Zapisz
</button>
</div>
<ol id="tabs">
- <li id="HistoryPerspective-tab"
- data-ui-related="history-viewer"
- data-ui-jsclass="HistoryPerspective">
- Historia
- </li>
+
+ <li id="SummaryPerspective-tab"
+ data-ui-related="summary-view-editor" data-ui-jsclass="SummaryPerspective">
+ <span>{{ document_meta.title }}</span>
+ </li>
<li id="VisualPerspective-tab"
data-ui-related="simple-editor" data-ui-jsclass="VisualPerspective">
- <span id="document-name">{{ document.name }}</span>
+ <span>Edytor</span>
+ </li>
+
+ <li id="HistoryPerspective-tab"
+ data-ui-related="history-view-editor"
+ data-ui-jsclass="HistoryPerspective">
+ Historia
</li>
<li id="CodeMirrorPerspective-tab"
<div id="source-editor" class="editor">
{% toolbar %}
<textarea id="codemirror_placeholder"><br/></textarea>
- <input type="hidden" name="name" value="{{ document.name }}" /><input type="hidden" name="author" value="annonymous" /><input type="hidden" name="comment" value="no comment" /><input type="hidden" name="revision" value="{{ document.revision }}" />
+ <input type="hidden" name="name" value="{{ document.name }}" /><input type="hidden" name="author" value="annonymous" /><input type="hidden" name="comment" value="no comment" /><input type="hidden" name="revision" value="{{ document_info.revision }}" />
</div>
<div id="simple-editor" class="editor" style="display: none">
<div id="html-view" class="htmlview">
</div>
</div>
</div>
- {% include "wiki/history_panel.html" %}
+ {% include "wiki/history_view.html" %}
+ {% include "wiki/summary_view.html" %}
</div>
<div class="vsplitbar" title="Klinknij aby (ro)zwinąć galerię."> </div>
- <div id="sidebar">
+
+ <div id="side-gallery">
+ <!-- gallery toolbar -->
<div class="toolbar">
<button class="previous-page">
<img src="{{STATIC_URL}}icons/go-previous.png" alt="Poprzednia" title="Poprzednia"/>
<button class="zoom-out">
Pomniejsz
</button>
- {% if request.user.is_staff %}
- <button class="change-gallery">
- Opcje
- </button>
- {% endif %}
<div class="toolbar-end">
</div>
- </div>
- {% if request.user.is_staff %}
- <div class="toolbar" id="change-gallery-toolbar">
- <input type="text" value="" class="chosen-gallery" />
- <button class="change-gallery-ok">
- Zmień galerię
- </button>
- <button class="change-gallery-cancel">
- Anuluj
- </button>
- <div class="toolbar-end">
- </div>
- </div>
- {% endif %}
- <div class="gallery-image"><img src="" /></div>
+ </div>
+ <div class="error_message"> </div>
+ <div class="gallery-image">
+ <img src="{{MEDIA_URL}}/images/empty.png" />
+ </div>
</div>
</div>
-<div id="save-dialog" style="display: none; text-align: left">
- <label for="komentarz" style="display: block">
- Opis zmian:
- </label>
- <textarea name="komentarz" id="komentarz" style="display: block; width: 100%">
- </textarea>
- <button id="save-ok">
- Zapisz
- </button>
- <button id="save-cancel">
- Anuluj
- </button>
-</div>
+{% include "wiki/save_dialog.html" %}
{% endblock %}
\ No newline at end of file
+++ /dev/null
-<div id="history-viewer" class="editor" style="display: none">
- <div class="toolbar">
- </div>
- <div id="history-view">
- <p class="message-box" style="display:none;">
- </p>
- <div class="row-stub" style="display: none;">
- <span data-stub-value="version"></span>
- <input type="checkbox" name="revision" data-stub-value="version" data-stub-target="value"><span data-stub-value="description"></span>
- <span data-stub-value="author"></span>
- <span data-stub-value="date"></span>
- </div>
- <div id="changes-list">
- </div>
- <p>
- <button type="button" id="make-diff-button">
- Porównaj
- </button>
- </p>
- <!-- <p><button type="button" id="more-history-button">Więcej</button></p> -->
- <div id="diff-view">
- </div>
- </div>
-</div>
--- /dev/null
+<div id="history-view-editor" class="editor" style="display: none">
+ <div class="toolbar">
+ <button type="button" id="make-diff-button">Porównaj</button>
+ </div>
+ <div id="history-view">
+ <p class="message-box" style="display:none;">
+ </p>
+ <div class="row-stub" style="display: none;">
+ <span class="tag" data-stub-target="data-version-tag" data-stub-value="tag">dodaj tag</span>
+ <span data-stub-value="version"></span>: <span data-stub-value="description"></span>
+ (<span data-stub-value="author"></span>, <span data-stub-value="date"></span>)
+ </div>
+ <div id="changes-list">
+ </div>
+ <p>
+
+ <div id="diff-view">
+ </div>
+ </div>
+</div>
--- /dev/null
+<div id="save_dialog" class="dialog">
+ <p>{{ text_save_form.comment.label }}</p>
+ <p class="help_text">{{text_save_form.comment.help_text}}</p>
+ {{ text_save_form.comment }}
+
+ {% if request.user.is_anonymous %}
+ <p>
+ {{ text_save_form.author.label }}:
+ {{ text_save_form.author }}
+ <span class="help_text">{{ text_save_form.author.help_text }}</span>
+ </p>
+ {% else %}
+ <p>
+ {{ text_save_form.stage_completed.label }}:
+ {{ text_save_form.stage_completed }}
+ <span class="help_text">{{ text_save_form.stage_completed.help_text }}</span>
+ </p>
+ {% endif %}
+
+ <p class="action_area">
+ <button type="submit" class="ok-button">Zapisz</button>
+ <button class="cancel-button">Anuluj</button>
+ </p>
+</div>
--- /dev/null
+<div id="summary-view-editor" class="editor" style="display: none">
+ <!-- <div class="toolbar">
+ </div> -->
+ <div id="summary-view">
+ <img class="book-cover" src="{{MEDIA_URL}}images/empty.png">
+ <form>
+ <h2>
+ <label for="title">Tytuł:</label>
+ <span data-ui-editable="true" data-edit-target="meta.displayTitle"
+ >{{ document_meta.title }}</span>
+ </h2>
+ <p>
+ <label>ID dokumentu:</label>
+ <span>{{ document.name|urlencode }}</span>
+ </p>
+ <p>
+ <label>Aktulana wersja:</label>
+ {{ document_info.revision }} ({{document_info.last_update}})
+ <p>
+ <label>Ostatnio edytowane przez:</label>
+ {{document_info.last_comitter}}
+ </p>
+ <p>
+ <label for="gallery">Link do galerii:</label>
+ <span data-ui-editable="true" data-edit-target="meta.galleryLink"
+ >{{ document_meta.gallery}}</span>
+ </p>
+ </form>
+
+ </div>
+</div>
\ No newline at end of file
from django.conf.urls.defaults import *
+from django.conf import settings
-urlpatterns = patterns('wiki.views',
+urlpatterns = patterns('wiki.views',
url(r'^$',
'document_list', name='wiki_doclist'),
url(r'^gallery/(?P<directory>[^/]+)$',
url(r'^(?P<name>[^/]+)/diff/(?P<revA>\d+)/(?P<revB>\d+)$',
'document_diff', name="wiki_diff"),
url(r'^(?P<name>[^/]+)$',
- 'document_detail', name="wiki_details"),
-
-)
-
+ 'document_detail', name="wiki_details"),
+)
\ No newline at end of file
from django.utils import simplejson as json
from wiki.models import Document, DocumentNotFound, getstorage
-from wiki.forms import DocumentForm
+from wiki.forms import DocumentForm, DocumentTextSaveForm
from datetime import datetime
from django.utils.encoding import smart_unicode
import wlapi
request.session['wiki_last_docs'] = last_documents
return direct_to_template(request, template_name, extra_context = {
- 'document': document,
+ 'document': document,
+ 'document_info': document.info,
+ 'document_meta': document.meta,
+ 'text_save_form': DocumentTextSaveForm(),
})
@never_cache
document = form.save(document_author = request.user.username)
return HttpResponse(json.dumps({'text': document.plain_text, 'meta': document.meta(), 'revision': document.revision()}))
else:
- return HttpResponse(json.dumps({'errors': form.errors}))
+ return HttpResponse(json.dumps({'errors': list(form.errors)}))
else:
return HttpResponse(json.dumps({'text': document.plain_text, 'meta': document.meta(), 'revision': document.revision()}))
except wlapi.APICallException, e:
result = {"success": False, "reason": str(e)}
- return HttpResponse( json.dumps(result), mimetype='application/json')
\ No newline at end of file
+ return HttpResponse( json.dumps(result), mimetype='application/json')
\ No newline at end of file
author = unicode(filectx.user(), "utf-8",
'replace').split('<')[0].strip()
comment = unicode(filectx.description(), "utf-8", 'replace')
- yield {"version": rev, "date": date, "author": author, "description": comment}
+ tags = filectx.changectx().tags()
+ yield {
+ "version": rev,
+ "date": date,
+ "author": author,
+ "description": comment,
+ "tag": tags[0] if tags else None,
+ }
def page_revision(self, title, rev):
"""Get unicode contents of specified revision of the page."""
## Django
Django>=1.1.1,<1.2
sorl-thumbnail>=3.2
-django-maintanancemode>=0.9
+django-maintenancemode>=0.9
# migrations
south>=0.6
'django.middleware.doc.XViewMiddleware',
'maintenancemode.middleware.MaintenanceModeMiddleware',
- 'debug_toolbar.middleware.DebugToolbarMiddleware'
+ # 'debug_toolbar.middleware.DebugToolbarMiddleware' #
)
AUTHENTICATION_BACKENDS = (
'detail': {
'source_filenames': (
'css/master.css',
+ 'css/gallery.css',
'css/history.css',
+ 'css/summary.css',
'css/html.css',
'css/jquery.autocomplete.css',
+ 'css/dialogs.css',
),
'output_filename': 'compressed/detail_styles_?.css',
},
'js/wiki/wikiapi.js',
'js/wiki/base.js',
'js/wiki/xslt.js',
- 'js/wiki/history.js',
+ 'js/wiki/history_view.js',
+ 'js/wiki/summary_view.js',
'js/wiki/source_editor.js',
- 'js/wiki/wysiwyg_editor.js',
+ 'js/wiki/wysiwyg_editor.js',
+ 'js/wiki/scan_gallery.js',
'js/wiki/main.js',
),
'output_filename': 'compressed/detail_scripts_?.js',
# REPOSITORY_PATH = '/Users/zuber/Projekty/platforma/files/books'
IMAGE_DIR = 'images'
-# Python logging settings
-import logging
-
-log = logging.getLogger('platforma')
-log.setLevel(logging.DEBUG)
-ch = logging.StreamHandler()
-ch.setLevel(logging.DEBUG)
-formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
-ch.setFormatter(formatter)
-log.addHandler(ch)
-
# Import localsettings file, which may override settings defined here
try:
from localsettings import *
try:
LOGGING_CONFIG_FILE
except NameError:
- LOGGING_CONFIG_FILE = os.path.join(PROJECT_ROOT,
+ LOGGING_CONFIG_FILE = os.path.join(PROJECT_ROOT, 'config',
('logging.cfg' if not DEBUG else 'logging.cfg.dev'))
-
try:
import logging
import logging.config
-
+
logging.config.fileConfig(LOGGING_CONFIG_FILE)
except ImportError, exc:
- import traceback
- traceback.print_exc()
- raise
-
+ raise
\ No newline at end of file
--- /dev/null
+#save_dialog {
+ display: none;
+ padding: 5px;
+ text-align: left;
+ cursor: auto;
+ background-color: #E1E1E1; /* #e0ffb8; */
+}
+
+#save_dialog textarea {
+ width: 90%;
+ margin: 0.2em 4%;
+}
+
+.dialog .help_text {
+ font-size: 11px;
+ color: #2e3536;
+}
+
+.dialog .action_area {
+ padding: 1em 0.5em 0.5em;
+ border-top: 1px solid black;
+ margin-top: 0.5em;
+}
+
+.dialog p {
+ margin: 0.5em;
+}
--- /dev/null
+/* =========== */
+/* = Gallery = */
+/* =========== */
+
+#side-gallery {
+ position: absolute;
+ /* overflow: hidden; */
+ top: 0px;
+ right: 0px;
+ bottom: 0px;
+ width: 480px;
+ display: none;
+ background-color: #FFF;
+}
+
+#side-gallery .error_message
+{
+ background-color: white;
+ color: black;
+ padding: 0.5em 1em;
+}
+
+.change-gallery-panel {
+ width: 100%;
+ border-bottom: 1px solid #777;
+ background-color: #C1C1C1;
+ margin: 0;
+ padding: 2px;
+ z-index: 10;
+}
+
+.gallery-image {
+ position: absolute;
+ top: 30px;
+ right: 0;
+ bottom: 0;
+ left: 0;
+ margin: 0;
+ border: none;
+ background-color: transparent;
+ overflow: hidden;
+}
+
+.gallery-image img {
+ position: absolute;
+ -moz-drag: none;
+ user-select: none;
+ -webkit-user-select: none;
+ -khtml-user-select: none;
+ -moz-user-select: none;
+ cursor: pointer;
+
+ background-color: white;
+ min-height: 100px;
+ min-width: 100px;
+}
+
+.gallery-image img[src=''] {
+ background-color: red;
+}
+#history-view {
+ overflow: auto;
+ position: absolute;
+ top: 30px; /* 0 for no toolbar, 30 for toolbar */
+ bottom: 0px;
+ left: 0px;
+ right: 0px;
+ z-index: 1;
+}
+
+/*
+ * File History
+ */
+#changes-list {
+ margin: 0.5em 0.2em;
+}
+
+#changes-list div {
+ position: relative;
+ padding: 0.5em;
+ margin: 0.5em;
+}
+
+#changes-list div:hover {
+ background-color: #f0f0f0;
+}
+
+#changes-list div.selected {
+ background-color: #ffec63;
+}
+
+#changes-list span.tag {
+ display: inline-block;
+ visibility: hidden;
+ width: 60px;
+ margin: 0 0.5em 0 0;
+ font-size: 11px;
+ padding: 3px 2px;
+ text-align: center;
+ color: black;
+ background: #add8e6;
+ cursor: pointer;
+ vertical-align: middle;
+ -moz-border-radius: 10px;
+ -webkit-border-radius: 10px;
+ border-radius: 10px;
+}
+
+#changes-list div:hover span.tag {
+ visibility: visible;
+}
+
+#changes-list span.tag:hover {
+ background: #bde8f6;
+}
+
+#changes-list span[data-version-tag] {
+ visibility: visible;
+ border: 1px solid black;
+
+ color: black;
+}
+
+#changes-list span[data-stub-value='version'] {
+ font-weight: bold;
+}
+
+#changes-list span[data-stub-value='date'],
+#changes-list span[data-stub-value='author']
+{
+ font-size: 11px;
+ color: gray;
+}
+
+
+/*
+ * Graphical DIFF view
+ *
+ */
#history-view .diff_table {
width: 90%;
}
-
-/* DIFFS */
+
.diff_table {
border-width: 1px;
border-style: solid;
position: absolute;
top: 0px;
bottom: 0;
- right: 0;;
- width: 13px;
- background: #C1C1C1 url(../img/gallery.png) no-repeat scroll center center;
- text-
- border-left: 1px solid #999;
- border-right: 1px solid #999;
+ right: 0;
+ width: 26px;
+ background: #C1C1C1 url(../img/gallery.png) no-repeat scroll center center;
+ border-left: 2px solid #999;
+ border-right: 2px solid #999;
cursor: pointer;
}
.vsplitbar:hover {
- background-color: #e6e6fa;
-}
-
-.vsplitbar.active {
- background-
-
+ background-color: yellow;
+ border-color: orange;
}
-#source-editor, #simple-editor, #history-viewer {
+.editor {
position: absolute;
top: 0px;
bottom: 0;
left: 0;
- right: 15px;
+ right: 30px;
overflow: hidden;
}
-#html-view, #history-view {
+#html-view {
overflow: auto;
position: absolute;
top: 30px;
z-index: 1;
}
-#sidebar {
- position: absolute;
- overflow: hidden;
- top: 0px;
- right: 0;
- bottom: 0;
- width: 0;
- display: none;
- background-color: #FFF;
-}
-
-
#splitter {
position: fixed;
top: 31px;
margin: 0;
padding: 2px;
z-index: 100;
-/* height: 22px;*/
+ height: 28px;
}
.toolbar button {
p { margin: 0;}
-/* =========== */
-/* = Gallery = */
-/* =========== */
-.change-gallery-panel {
- width: 100%;
- border-bottom: 1px solid #777;
- background-color: #C1C1C1;
- margin: 0;
- padding: 2px;
- z-index: 10;
-}
-
-.gallery-image {
- position: absolute;
- top: 30px;
- right: 0;
- bottom: 0;
- left: 0;
- margin: 0;
- border: none;
- background-color: #000;
- overflow: hidden;
-}
-
-.gallery-image img {
- position: absolute;
- -moz-drag: none;
- user-select: none;
- -webkit-user-select: none;
- -khtml-user-select: none;
- -moz-user-select: none;
- cursor: pointer;
-}
-
-
#body-wrap {
height: 100%;
width: 100%;
margin-top: -6px;
}
-
-
-
/*
* CodeMirror
*/
background-color: #FAFAFA;
border: 1px solid #DDD;
/* -webkit-transition: all 1s linear;*/
-}
\ No newline at end of file
+}
+
+.blockOverlay {
+ background-color: black;
+ opacity: 0.4;
+}
--- /dev/null
+#summary-view-editor {
+ background: white;
+}
+
+#summary-view {
+ padding: 1em;
+}
+
+#summary-view .book-cover {
+ float: left;
+ margin: 1em;
+ max-height: 300px;
+}
+
+#summary-view form p {
+ margin: 0.5em;
+}
+
+#summary-view form label {
+ font-weight: bold;
+}
+++ /dev/null
-/**
-* @name Elastic
-* @descripton Elastic is Jquery plugin that grow and shrink your textareas automaticliy
-* @version 1.6.3
-* @requires Jquery 1.2.6+
-*
-* @author Jan Jarfalk
-* @author-email jan.jarfalk@unwrongest.com
-* @author-website http://www.unwrongest.com
-*
-* @licens MIT License - http://www.opensource.org/licenses/mit-license.php
-*/
-
-(function(jQuery){
- jQuery.fn.extend({
- elastic: function() {
-
- // We will create a div clone of the textarea
- // by copying these attributes from the textarea to the div.
- var mimics = [
- 'paddingTop',
- 'paddingRight',
- 'paddingBottom',
- 'paddingLeft',
- 'fontSize',
- 'lineHeight',
- 'fontFamily',
- 'width',
- 'fontWeight'];
-
- return this.each( function() {
-
- // Elastic only works on textareas
- 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;
-
- // Opera returns max-height of -1 if not set
- if (maxheight < 0) { maxheight = Number.MAX_VALUE; }
-
- // Append the twin to the DOM
- // We are going to meassure the height of this, not the textarea.
- $twin.appendTo($textarea.parent());
-
- // Copy the essential styles (mimics) from the textarea to the twin
- var i = mimics.length;
- while(i--){
- $twin.css(mimics[i].toString(),$textarea.css(mimics[i].toString()));
- }
-
-
- // Sets a given height and overflow state on the textarea
- function setHeightAndOverflow(height, overflow){
- curratedHeight = Math.floor(parseInt(height,10));
- if($textarea.height() != curratedHeight){
- $textarea.css({'height': curratedHeight + 'px','overflow':overflow});
-
- }
- }
-
-
- // This function will update the height of the textarea if necessary
- function update() {
-
- // Get curated content from the textarea.
- var textareaContent = $textarea.val().replace(/&/g,'&').replace(/ /g, ' ').replace(/<|>/g, '>').replace(/\n/g, '<br />');
-
- var twinContent = $twin.html();
-
- if(textareaContent+' ' != twinContent){
-
- // Add an extra white space so new rows are added when you are at the end of a row.
- $twin.html(textareaContent+' ');
-
- // Change textarea height if twin plus the height of one line differs more than 3 pixel from textarea height
- 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');
- }
-
- }
-
- }
-
- }
-
- // Hide scrollbars
- $textarea.css({'overflow':'hidden'});
-
- // Update textarea size on keyup
- $textarea.keyup(function(){ update(); });
-
- // And this line is to catch the browser paste event
- $textarea.live('input paste',function(e){ setTimeout( update, 250); });
-
- // Run update once when elastic is initialized
- update();
-
- });
-
- }
- });
-})(jQuery);
\ No newline at end of file
$.wiki.Perspective.prototype.onEnter = function () {
// called when perspective in initialized
- document.location.hash = '#' + this.perspective_id;
+ if (this.perspective_id) {
+ document.location.hash = '#' + this.perspective_id;
+ }
+
console.log(document.location.hash);
};
+++ /dev/null
-(function($){
-
- function fetchDiff(success, failed){
- var changelist = $('#changes-list');
- var rev_a = $("input[name='rev_from']:checked", changelist);
- var rev_b = $("input[name='rev_to']:checked", changelist);
-
- if (rev_a.length != 1 || rev_b.length != 1) {
- window.alert("Musisz zaznaczyć dwie wersje do porównania.");
- failed();
- }
-
- if (rev_a.val() == rev_b.val()) {
- window.alert("Musisz zaznaczyć dwie różne wersje do porównania.");
- failed();
- }
-
- $.blockUI({
- message: 'Wczytywanie porównania...'
- });
-
- $.ajax({
- url: document.location.href + '/diff/' + rev_a.val() + '/' + rev_b.val(),
- dataType: 'html',
- error: function(){
- $.unblockUI();
- error();
- },
- success: function(data){
- var diffview = $('#diff-view');
- diffview.html(data);
- diffview.show();
- $.unblockUI();
- success();
- }
- });
- }
-
- function HistoryPerspective(doc, callback) {
- this.perspective_id = 'HistoryPerspective';
- this.doc = doc;
-
- // first time page is rendered
- $('#make-diff-button').click(fetchDiff);
- callback.call(this);
- };
-
- HistoryPerspective.prototype = new $.wiki.Perspective();
-
- HistoryPerspective.prototype.freezeState = function(){
- // must
- };
-
- HistoryPerspective.prototype.onEnter = function(success, failure)
- {
- $.wiki.Perspective.prototype.onEnter.call(this);
-
- $.blockUI({
- message: 'Odświeżanie historii...'
- });
-
- function _finalize(s) {
- $.unblockUI();
-
- if(s) { if(success) success(); }
- else { if(failure) failure(); }
- }
-
- function _failure(doc, message) {
- $('#history-view .message-box').html('Nie udało się odświeżyć historii:' + message).show();
- _finalize(false);
- };
-
- function _success(doc, data) {
- $('#history-view .message-box').hide();
- var changes_list = $('#changes-list');
- var $stub = $('#history-view .row-stub');
- changes_list.html('');
-
- $.each(data, function(){
- $.wiki.renderStub(changes_list, $stub, this);
- });
-
- _finalize(true);
- };
-
- return this.doc.fetchHistory({success: _success, failure: _failure});
- };
-
- $.wiki.HistoryPerspective = HistoryPerspective;
-
-})(jQuery);
--- /dev/null
+(function($){
+
+ function fetchDiff(success, failed){
+ var changelist = $('#changes-list');
+
+ var selected = $('div.selected', changelist);
+
+ if (selected.length != 2) {
+ window.alert("Musisz zaznaczyć dokładnie dwie wersje do porównania.");
+ if(failed) failed();
+ }
+
+ $.blockUI({
+ message: 'Wczytywanie porównania...'
+ });
+
+ $.ajax({
+ method: "GET",
+ url: document.location.href + '/diff/' + rev_a.val() + '/' + rev_b.val(),
+ dataType: 'html',
+ error: function(){
+ $.unblockUI();
+ if(failed) failed('Nie udało się wczytać porównania z serwera.');
+ },
+ success: function(data){
+ var diffview = $('#diff-view');
+ diffview.html(data);
+ diffview.show();
+ $.unblockUI();
+ if(success) success(data);
+ }
+ });
+ }
+
+ function HistoryPerspective(doc, callback) {
+ this.perspective_id = 'HistoryPerspective';
+ this.doc = doc;
+
+ // first time page is rendered
+ $('#make-diff-button').click(fetchDiff);
+
+ $('#changes-list div').live('click', function() {
+ var $this = $(this);
+ if($this.hasClass('selected'))
+ return $this.removeClass('selected');
+
+ if($("#changes-list div.selected").length < 2)
+ return $this.addClass('selected');
+ });
+
+ $('#changes-list span.tag').live('click', function(event) {
+ return false;
+ });
+
+ callback.call(this);
+ };
+
+ HistoryPerspective.prototype = new $.wiki.Perspective();
+
+ HistoryPerspective.prototype.freezeState = function(){
+ // must
+ };
+
+ HistoryPerspective.prototype.onEnter = function(success, failure)
+ {
+ $.wiki.Perspective.prototype.onEnter.call(this);
+
+ $.blockUI({
+ message: 'Odświeżanie historii...'
+ });
+
+ function _finalize(s) {
+ $.unblockUI();
+
+ if(s) { if(success) success(); }
+ else { if(failure) failure(); }
+ }
+
+ function _failure(doc, message) {
+ $('#history-view .message-box').html('Nie udało się odświeżyć historii:' + message).show();
+ _finalize(false);
+ };
+
+ function _success(doc, data) {
+ $('#history-view .message-box').hide();
+ var changes_list = $('#changes-list');
+ var $stub = $('#history-view .row-stub');
+ changes_list.html('');
+
+ $.each(data, function(){
+ $.wiki.renderStub(changes_list, $stub, this);
+ });
+
+ $('span[data-version-tag]', changes_list).each(function() {
+ $(this).text($(this).attr('data-version-tag'));
+ });
+
+ _finalize(true);
+ };
+
+ return this.doc.fetchHistory({success: _success, failure: _failure});
+ };
+
+ $.wiki.HistoryPerspective = HistoryPerspective;
+
+})(jQuery);
}
}
-THEMES = ['Alkohol', 'Ambicja', 'Anioł', 'Antysemityzm', 'Arkadia', 'Artysta', 'Bezdomność', 'Bezpieczeństwo', 'Bieda', 'Bijatyka', 'Błazen', 'Błądzenie', 'Błoto', 'Bogactwo', 'Bóg', 'Brat', 'Bunt', 'Buntownik', 'Burza', 'Car', 'Carpe diem', 'Ciemność', 'Cień', 'Cisza', 'Chciwość', 'Chleb', 'Chłop', 'Choroba', 'Chrystus', 'Chrzest', 'Ciało', 'Cierpienie', 'Cmentarz', 'Cnota', 'Córka', 'Cud', 'Czarownika', 'Czary', 'Czas', 'Czyn', 'Czyściec', 'Dama', 'Danse macabre', 'Deszcz', 'Diabeł', 'Dobro', 'Dom', 'Dorosłość', 'Drzewo', 'Duch', 'Dusza', 'Duma', 'Dworek', 'Dworzanin', 'Dwór', 'Dzieciństwo', 'Dziecko', 'Dziedzictwo', 'Dziewictwo', 'Dźwięk', 'Egzorcyzm', 'Elita', 'Emigrant', 'Fałsz', 'Filozof', 'Fircyk', 'Flirt', 'Głupiec', 'Głupota', 'Głód', 'Gospodarz', 'Gospodyni', 'Gość', 'Gotycyzm', 'Góra', 'Gra', 'Grób', 'Grzech', 'Grzeczność', 'Gwiazda', 'Handel', 'Hańba', 'Historia', 'Honor', 'Idealista', 'Imię', 'Interes', 'Jabłka', 'Jedzenie', 'Jesień', 'Kaleka', 'Kara', 'Karczma', 'Klęska', 'Kłamstwo', 'Kłótnia', 'Kobieta', 'Kobieta demoniczna', 'Kobieta "upadła"', 'Kochanek', 'Kochanek romantyczny', 'Kolonializm', 'Kondycja ludzka', 'Konflikt', 'Konflikt wewnętrzny', 'Koniec świata', 'Koń', 'Korzyść', 'Kot', 'Kradzież', 'Krew', 'Król', 'Krzywda', 'Ksiądz', 'Książka', 'Księżyc', 'Kuchnia', 'Kuszenie', 'Kwiaty', 'Labirynt', 'Las', 'Lato', 'Lekarz', 'Lenistwo', 'List', 'Liberat', 'Los', 'Lud', 'Lustro', 'Łzy', 'Małżeństwo', 'Marzenie', 'Maska', 'Maszyna', 'Matka', 'Matka Boska', 'Mądrość', 'Mąż', 'Melancholia', 'Mędrzec', 'Mężczyzna', 'Miasto', 'Mieszczanin', 'Miłosierdzie', 'Miłość', 'Miłość niespełniona', 'Miłość platoniczna', 'Miłość romantyczna', 'Miłość silniejsza niż śmierć', 'Miłość spełniona', 'Miłość tragiczna', 'Mizoginia', 'Młodość', 'Moda', 'Modlitwa', 'Morderstwo', 'Morze', 'Motyl', 'Mucha', 'Muzyka', 'Narodziny', 'Naród', 'Natura', 'Nauczyciel', 'Nauczycielka', 'Nauka', 'Niebezpieczeństwo', 'Niedziela', 'Niemiec', 'Nienawiść', 'Nieśmiertelność', 'Niewola', 'Noc', 'Nuda', 'Obcy', 'Obłok', 'Obowiązek', 'Obraz świata', 'Obrzędy', 'Obyczaje', 'Obywatel', 'Odrodzenie przez grób', 'Odwaga', 'Ofiara', 'Ogień', 'Ogród', 'Ojciec', 'Ojczyzna', 'Oko', 'Okręt', 'Okrucieństwo', 'Omen', 'Opieka', 'Organizm', 'Otchłań', 'Pająk', 'Pamięć', 'Pan', 'Panna młoda', 'Państwo', 'Patriota', 'Piekło', 'Pielgrzym', 'Pieniądz', 'Pies', 'Piętno', 'Pijaństwo', 'Piwnica', 'Plotka', 'Pobożność', 'Pocałunek', 'Pochlebstwo', 'Poeta', 'Poetka', 'Poezja', 'Podróż', 'Podstęp', 'Pogrzeb', 'Pojedynek', 'Pokora', 'Pokusa', 'Polak', 'Polityka', 'Polowanie', 'Polska', 'Portret', 'Porwanie', 'Poświęcenie', 'Potwór', 'Powstanie', 'Powstaniec', 'Pozory', 'Pozycja społeczna', 'Pożar', 'Pożądanie', 'Praca', 'Praca u podstaw', 'Praca organiczna', 'Prawda', 'Prawnik', 'Prometeusz', 'Proroctwo', 'Prorok', 'Próżność', 'Przebranie', 'Przeczucie', 'Przedmurze chrześcijaństwa', 'Przekleństwo', 'Przekupstwo', 'Przemiana', 'Przemijanie', 'Przemoc', 'Przestrzeń', 'Przyjaźń', 'Przyroda nieożywiona', 'Przysięga', 'Przywódca', 'Ptak', 'Pustynia', 'Pycha', 'Raj', 'Realista', 'Religia', 'Rewolucja', 'Robak', 'Robotnik', 'Rodzina', 'Rosja', 'Rosjanin', 'Rośliny', 'Rozczarowanie', 'Rozpacz', 'Rozstanie', 'Rozum', 'Ruiny', 'Rycerz', 'Rzeka', 'Salon', 'Samobójstwo', 'Samolubstwo', 'Samotnik', 'Samotność', 'Sarmata', 'Sąsiad', 'Sąd', 'Sąd Ostateczny', 'Sen', 'Serce', 'Sędzia', 'Sielanka', 'Sierota', 'Siła', 'Siostra', 'Sława', 'Słońce', 'Słowo', 'Sługa', 'Służalczość', 'Skąpiec', 'Sobowtór', 'Społecznik', 'Spowiedź', 'Sprawiedliwość', 'Starość', 'Strach', 'Strój', 'Stworzenie', 'Sumienie', 'Swaty', 'Syberia', 'Syn', 'Syn marnotrawny', 'Syzyf', 'Szaleniec', 'Szaleństwo', 'Szantaż', 'Szatan', 'Szczęście', 'Szkoła', 'Szlachcic', 'Szpieg', 'Sztuka', 'Ślub', 'Śmiech', 'Śmierć', 'Śmierć bohaterska', 'Śpiew', 'Światło', 'Świętoszek', 'Święty', 'Świt', 'Tajemnica', 'Taniec', 'Tchórzostwo', 'Teatr', 'Testament', 'Tęsknota', 'Theatrum mundi', 'Tłum', 'Trucizna', 'Trup', 'Twórczość', 'Uczeń', 'Uczta', 'Uroda', 'Umiarkowanie', 'Upadek', 'Upiór', 'Urzędnik', 'Vanitas', 'Walka', 'Walka klas', 'Wampir', 'Warszawa', 'Wąż', 'Wdowa', 'Wdowiec', 'Wesele', 'Wiatr', 'Wierność', 'Wierzenia', 'Wieś', 'Wiedza', 'Wieża Babel', 'Więzienie', 'Więzień', 'Wina', 'Wino', 'Wiosna', 'Wizja', 'Władza', 'Własność', 'Woda', 'Wojna', 'Wojna pokoleń', 'Wolność', 'Wróg', 'Wspomnienia', 'Współpraca', 'Wygnanie', 'Wyrzuty sumienia', 'Wyspa', 'Wzrok', 'Zabawa', 'Zabobony', 'Zamek', 'Zaręczyny', 'Zaświaty', 'Zazdrość', 'Zbawienie', 'Zbrodnia', 'Zbrodniarz', 'Zdrada', 'Zdrowie', 'Zemsta', 'Zesłaniec', 'Ziarno', 'Ziemia', 'Zima', 'Zło', 'Złodziej', 'Złoty wiek', 'Zmartwychwstanie', 'Zwątpienie', 'Zwierzęta', 'Zwycięstwo', 'Żałoba', 'Żebrak', 'Żołnierz', 'Żona', 'Życie jako wędrówka', 'Życie snem', 'Żyd', 'Żywioły', 'Oświadczyny']
+THEMES = ['Alkohol', 'Ambicja', 'Anioł', 'Antysemityzm', 'Arkadia', 'Artysta', 'Bezdomność', 'Bezpieczeństwo', 'Bieda', 'Bijatyka', 'Błazen', 'Błądzenie', 'Błoto', 'Bogactwo', 'Bóg', 'Brat', 'Bunt', 'Buntownik', 'Burza', 'Car', 'Carpe diem', 'Ciemność', 'Cień', 'Cisza', 'Chciwość', 'Chleb', 'Chłop', 'Choroba', 'Chrystus', 'Chrzest', 'Ciało', 'Cierpienie', 'Cmentarz', 'Cnota', 'Córka', 'Cud', 'Czarownika', 'Czary', 'Czas', 'Czyn', 'Czyściec', 'Dama', 'Danse macabre', 'Deszcz', 'Diabeł', 'Dobro', 'Dom', 'Dorosłość', 'Drzewo', 'Duch', 'Dusza', 'Duma', 'Dworek', 'Dworzanin', 'Dwór', 'Dzieciństwo', 'Dziecko', 'Dziedzictwo', 'Dziewictwo', 'Dźwięk', 'Egzorcyzm', 'Elita', 'Emigrant', 'Fałsz', 'Filozof', 'Fircyk', 'Flirt', 'Głupiec', 'Głupota', 'Głód', 'Gospodarz', 'Gospodyni', 'Gość', 'Gotycyzm', 'Góra', 'Gra', 'Grób', 'Grzech', 'Grzeczność', 'Gwiazda', 'Handel', 'Hańba', 'Historia', 'Honor', 'Idealista', 'Imię', 'Interes', 'Jabłka', 'Jedzenie', 'Jesień', 'Kaleka', 'Kara', 'Karczma', 'Klęska', 'Kłamstwo', 'Kłótnia', 'Kobieta', 'Kobieta demoniczna', 'Kobieta "upadła"', 'Kochanek', 'Kochanek romantyczny', 'Kolonializm', 'Kondycja ludzka', 'Konflikt', 'Konflikt wewnętrzny', 'Koniec świata', 'Koń', 'Korzyść', 'Kot', 'Kradzież', 'Krew', 'Król', 'Krzywda', 'Ksiądz', 'Książka', 'Księżyc', 'Kuchnia', 'Kuszenie', 'Kwiaty', 'Labirynt', 'Las', 'Lato', 'Lekarz', 'Lenistwo', 'List', 'Liberat', 'Los', 'Lud', 'Lustro', 'Łzy', 'Małżeństwo', 'Marzenie', 'Maska', 'Maszyna', 'Matka', 'Matka Boska', 'Mądrość', 'Mąż', 'Melancholia', 'Mędrzec', 'Mężczyzna', 'Miasto', 'Mieszczanin', 'Miłosierdzie', 'Miłość', 'Miłość niespełniona', 'Miłość platoniczna', 'Miłość romantyczna', 'Miłość silniejsza niż śmierć', 'Miłość spełniona', 'Miłość tragiczna', 'Mizoginia', 'Młodość', 'Moda', 'Modlitwa', 'Morderstwo', 'Morze', 'Motyl', 'Mucha', 'Muzyka', 'Narodziny', 'Naród', 'Natura', 'Nauczyciel', 'Nauczycielka', 'Nauka', 'Niebezpieczeństwo', 'Niedziela', 'Niemiec', 'Nienawiść', 'Nieśmiertelność', 'Niewola', 'Noc', 'Nuda', 'Obcy', 'Obłok', 'Obowiązek', 'Obraz świata', 'Obrzędy', 'Obyczaje', 'Obywatel', 'Odrodzenie przez grób', 'Odwaga', 'Ofiara', 'Ogień', 'Ogród', 'Ojciec', 'Ojczyzna', 'Oko', 'Okręt', 'Okrucieństwo', 'Omen', 'Opieka', 'Organizm', 'Otchłań', 'Pająk', 'Pamięć', 'Pan', 'Panna młoda', 'Państwo', 'Patriota', 'Piekło', 'Pielgrzym', 'Pieniądz', 'Pies', 'Piętno', 'Pijaństwo', 'Piwnica', 'Plotka', 'Pobożność', 'Pocałunek', 'Pochlebstwo', 'Poeta', 'Poetka', 'Poezja', 'Podróż', 'Podstęp', 'Pogrzeb', 'Pojedynek', 'Pokora', 'Pokusa', 'Polak', 'Polityka', 'Polowanie', 'Polska', 'Portret', 'Porwanie', 'Poświęcenie', 'Potwór', 'Powstanie', 'Powstaniec', 'Pozory', 'Pozycja społeczna', 'Pożar', 'Pożądanie', 'Praca', 'Praca u podstaw', 'Praca organiczna', 'Prawda', 'Prawnik', 'Prometeusz', 'Proroctwo', 'Prorok', 'Próżność', 'Przebranie', 'Przeczucie', 'Przedmurze chrześcijaństwa', 'Przekleństwo', 'Przekupstwo', 'Przemiana', 'Przemijanie', 'Przemoc', 'Przestrzeń', 'Przyjaźń', 'Przyroda nieożywiona', 'Przysięga', 'Przywódca', 'Ptak', 'Pustynia', 'Pycha', 'Raj', 'Realista', 'Religia', 'Rewolucja', 'Robak', 'Robotnik', 'Rodzina', 'Rosja', 'Rosjanin', 'Rośliny', 'Rozczarowanie', 'Rozpacz', 'Rozstanie', 'Rozum', 'Ruiny', 'Rycerz', 'Rzeka', 'Salon', 'Samobójstwo', 'Samolubstwo', 'Samotnik', 'Samotność', 'Sarmata', 'Sąsiad', 'Sąd', 'Sąd Ostateczny', 'Sen', 'Serce', 'Sędzia', 'Sielanka', 'Sierota', 'Siła', 'Siostra', 'Sława', 'Słońce', 'Słowo', 'Sługa', 'Służalczość', 'Skąpiec', 'Sobowtór', 'Społecznik', 'Spowiedź', 'Sprawiedliwość', 'Starość', 'Strach', 'Strój', 'Stworzenie', 'Sumienie', 'Swaty', 'Syberia', 'Syn', 'Syn marnotrawny', 'Syzyf', 'Szaleniec', 'Szaleństwo', 'Szantaż', 'Szatan', 'Szczęście', 'Szkoła', 'Szlachcic', 'Szpieg', 'Sztuka', 'Ślub', 'Śmiech', 'Śmierć', 'Śmierć bohaterska', 'Śpiew', 'Światło', 'Świętoszek', 'Święty', 'Świt', 'Tajemnica', 'Taniec', 'Tchórzostwo', 'Teatr', 'Testament', 'Tęsknota', 'Theatrum mundi', 'Tłum', 'Trucizna', 'Trup', 'Twórczość', 'Uczeń', 'Uczta', 'Uroda', 'Umiarkowanie', 'Upadek', 'Upiór', 'Urzędnik', 'Vanitas', 'Walka', 'Walka klas', 'Wampir', 'Warszawa', 'Wąż', 'Wdowa', 'Wdowiec', 'Wesele', 'Wiatr', 'Wierność', 'Wierzenia', 'Wieś', 'Wiedza', 'Wieża Babel', 'Więzienie', 'Więzień', 'Wina', 'Wino', 'Wiosna', 'Wizja', 'Władza', 'Własność', 'Woda', 'Wojna', 'Wojna pokoleń', 'Wolność', 'Wróg', 'Wspomnienia', 'Współpraca', 'Wygnanie', 'Wyrzuty sumienia', 'Wyspa', 'Wzrok', 'Zabawa', 'Zabobony', 'Zamek', 'Zaręczyny', 'Zaświaty', 'Zazdrość', 'Zbawienie', 'Zbrodnia', 'Zbrodniarz', 'Zdrada', 'Zdrowie', 'Zemsta', 'Zesłaniec', 'Ziarno', 'Ziemia', 'Zima', 'Zło', 'Złodziej', 'Złoty wiek', 'Zmartwychwstanie', 'Zwątpienie', 'Zwierzęta', 'Zwycięstwo', 'Żałoba', 'Żebrak', 'Żołnierz', 'Żona', 'Życie jako wędrówka', 'Życie snem', 'Żyd', 'Żywioły', 'Oświadczyny'];
-function gallery(element, url){
- var element = $(element);
- var imageDimensions = {};
- element.data('images', []);
-
- function changePage(pageNumber){
- $('.gallery-image img', element).attr('src', element.data('images')[pageNumber - 1]);
- }
-
- function normalizeNumber(pageNumber){
- // Numer strony musi być pomiędzy 1 a najwyższym numerem
- var pageCount = element.data('images').length;
- pageNumber = parseInt(pageNumber, 10);
-
- if (!pageNumber || pageNumber == NaN || pageNumber == Infinity || pageNumber == -Infinity) {
- return 1;
- }
- else
- if (pageNumber < 1) {
- return 1;
- }
- else
- if (pageNumber > pageCount) {
- return pageCount;
- }
- else {
- return pageNumber;
- }
- }
-
- var pn = $('.page-number', element);
- pn.change(function(event){
- event.preventDefault();
- var n = normalizeNumber(pn.val());
- pn.val(n);
- changePage(n);
- });
- $('.previous-page', element).click(function(){
- pn.val(normalizeNumber(pn.val()) - 1);
- pn.change();
- });
- $('.next-page', element).click(function(){
- pn.val(normalizeNumber(pn.val()) + 1);
- pn.change();
- });
-
-
- var image = $('.gallery-image img', element).attr('unselectable', 'on');
- var origin = {};
- var imageOrigin = {};
- var zoomFactor = 1;
-
- $('.zoom-in', element).click(function(){
- zoomFactor = Math.min(2, zoomFactor + 0.2);
- zoom();
- });
- $('.zoom-out', element).click(function(){
- zoomFactor = Math.max(0.2, zoomFactor - 0.2);
- zoom();
- });
- $('.change-gallery', element).click(function(){
- $('.chosen-gallery').val($('#document-meta .gallery').html() || '/platforma/gallery/');
- $('.gallery-image').animate({
- top: 60
- }, 200);
- $('.chosen-gallery').focus();
- });
- $('.change-gallery-ok', element).click(function(){
- if ($('#document-meta .gallery').length == 0) {
- $('<div class="gallery"></div>').appendTo('#document-meta');
- }
- $('#document-meta .gallery').html($('.chosen-gallery').val());
- updateGallery($('.chosen-gallery').val());
- $('.gallery-image').animate({
- top: 30
- }, 200);
- });
- $('.change-gallery-cancel', element).click(function(){
- $('.gallery-image').animate({
- top: 30
- }, 200);
- });
-
- $('.gallery-image img', element).load(function(){
- image.css({
- width: null,
- height: null
- });
- imageDimensions = {
- width: $(this).width() * zoomFactor,
- height: $(this).height() * zoomFactor,
- originWidth: $(this).width(),
- originHeight: $(this).height(),
- galleryWidth: $(this).parent().width(),
- galleryHeight: $(this).parent().height()
- };
-
- if (!(imageDimensions.width && imageDimensions.height)) {
- setTimeout(function(){
- $('.gallery-image img', element).load();
- }, 100);
- }
- var position = normalizePosition(image.position().left, image.position().top, imageDimensions.galleryWidth, imageDimensions.galleryHeight, imageDimensions.width, imageDimensions.height);
- image.css({
- left: position.x,
- top: position.y,
- width: $(this).width() * zoomFactor,
- height: $(this).height() * zoomFactor
- });
- });
-
- $(window).resize(function(){
- imageDimensions.galleryWidth = image.parent().width();
- imageDimensions.galleryHeight = image.parent().height();
- });
-
- function bounds(galleryWidth, galleryHeight, imageWidth, imageHeight){
- return {
- maxX: 0,
- maxY: 0,
- minX: galleryWidth - imageWidth,
- minY: galleryHeight - imageHeight
- }
- }
-
- function normalizePosition(x, y, galleryWidth, galleryHeight, imageWidth, imageHeight){
- var b = bounds(galleryWidth, galleryHeight, imageWidth, imageHeight);
- return {
- x: Math.min(b.maxX, Math.max(b.minX, x)),
- y: Math.min(b.maxY, Math.max(b.minY, y))
- }
- }
-
- function onMouseMove(event){
- var position = normalizePosition(event.clientX - origin.x + imageOrigin.left, event.clientY - origin.y + imageOrigin.top, imageDimensions.galleryWidth, imageDimensions.galleryHeight, imageDimensions.width, imageDimensions.height);
- image.css({
- position: 'absolute',
- top: position.y,
- left: position.x
- });
- return false;
- }
-
- function setZoom(factor){
- zoomFactor = factor;
- }
-
- function zoom(){
- imageDimensions.width = imageDimensions.originWidth * zoomFactor;
- imageDimensions.height = imageDimensions.originHeight * zoomFactor;
- var position = normalizePosition(image.position().left, image.position().top, imageDimensions.galleryWidth, imageDimensions.galleryHeight, imageDimensions.width, imageDimensions.height);
- image.css({
- width: imageDimensions.width,
- height: imageDimensions.height,
- left: position.x,
- top: position.y
- });
-
- }
-
- function onMouseUp(event){
- $(document).unbind('mousemove.gallery').unbind('mouseup.gallery');
- return false;
- }
-
- image.bind('mousedown', function(event){
- origin = {
- x: event.clientX,
- y: event.clientY
- };
- imageOrigin = image.position();
- $(document).bind('mousemove.gallery', onMouseMove).bind('mouseup.gallery', onMouseUp);
- return false;
- });
-
- function updateGallery(url){
- $.ajax({
- url: url,
- type: 'GET',
- dataType: 'json',
-
- success: function(data){
- element.data('images', data);
- pn.val(1);
- pn.change();
- $('.gallery-image img', element).show();
- },
-
- error: function(data){
- element.data('images', []);
- pn.val(1);
- pn.change();
- $('.gallery-image img', element).hide();
- }
- });
- }
-
- if (url) {
- updateGallery(url);
- }
-}
-
-$(function() {
- // gallery('#sidebar', $('#document-meta .gallery').html());
-
+$(function()
+{
var tabs = $('ol#tabs li');
var perspectives = {};
+ var gallery = null;
var wikidoc = new $.wikiapi.WikiDocument("document-meta");
+
+ $.blockUI.defaults.baseZ = 10000;
function activePerspective() {
return perspectives[$("#tabs " + document.location.hash + "-tab").attr('data-ui-jsclass')];
function initialize()
{
+ gallery = new $.wiki.ScanGalleryPerspective(wikidoc);
+
/* The save button */
$('#save-button').click(function(event){
event.preventDefault();
$.blockUI({
- message: $('#save-dialog')
+ message: $('#save_dialog'),
+ css: {
+ 'top': '25%',
+ 'left': '25%',
+ 'width': '50%'
+ }
});
});
- $('#save-ok').click(function(){
+ $('#save_dialog .ok-button').click(function(){
$.blockUI({
message: 'Zapisywanie...'
});
$.unblockUI();
};
- wikidoc.save( $("#komentarz").text(),
- function(doc, changed) {
- console.log("Saved.");
- finalize();
- },
- function(doc, message) {
- alert(message);
- finalize();
+ wikidoc.save({
+ comment: $("#komentarz").text(),
+ success: function(doc, changed, info){
+ console.log(info);
+ $.blockUI({
+ message: info
+ });
+ setTimeout(finalize, 2000);
+ },
+ failure: function(doc, info) {
+ console.log(info);
+ $.blockUI({
+ message: info
+ });
+ setTimeout(finalize, 3000);
}
- );
+ });
});
- $('#save-cancel').click(function(){
+ $('#save_dialog .cancel-button').click(function(){
$.unblockUI();
});
$(window).resize();
- $('.vsplitbar').click(function(){
- if ($('#sidebar').width() == 0) {
- $('#sidebar').width(480).css({
- right: 0
- }).show();
- $('#editor .editor').css({
- right: 495
- });
- $('.vsplitbar').css({
- right: 480
- }).addClass('active');
- }
- else {
- $('#sidebar').width(0).hide();
- $('#editor .editor').css({
- right: 15
- });
- $('.vsplitbar').css({
- right: 0
- }).removeClass('active');
- }
- $(window).resize();
- });
+ $('.vsplitbar').toggle(
+ function() {
+ $('#side-gallery').show();
+ $('.vsplitbar').css('right', 480).addClass('.active');
+ $('#editor .editor').css('right', 510);
+ $(window).resize();
+ gallery.onEnter();
+ },
+ function() {
+ $('#side-gallery').hide();
+ $('.vsplitbar').css('right', 0).removeClass('active');
+ $('#editor .editor').css('right', 30);
+ $(window).resize();
+ gallery.onExit();
+ }
+ );
$(window).bind('beforeunload', function(event){
- return "Na stronie mogą być zmiany.";
+ if(wikidoc.has_local_changes) return "Na stronie mogą być zmiany.";
});
- console.log("prepare for fetch");
+ console.log("Fetching document's text");
wikidoc.fetch({
success: function(){
console.log("Fetch success");
$('#loading-overlay').fadeOut();
- var active_tab = document.location.hash || "#VisualPerspective";
+ var active_tab = document.location.hash || "#SummaryPerspective";
var $active = $("#tabs " + active_tab + "-tab");
$active.trigger("click");
--- /dev/null
+(function($){
+
+ function normalizeNumber(number, length){
+ // Numer strony musi być pomiędzy 1 a najwyższym numerem
+ var pageCount = length;
+ pageNumber = parseInt(pageNumber, 10);
+
+ if (!pageNumber ||
+ pageNumber == NaN ||
+ pageNumber == Infinity ||
+ pageNumber == -Infinity ||
+ pageNumber < 1)
+ return 1;
+
+ if (pageNumber > pageCount)
+ return pageCount;
+
+ return pageNumber;
+ }
+
+ function bounds(galleryWidth, galleryHeight, imageWidth, imageHeight){
+ return {
+ maxX: 0,
+ maxY: 0,
+ minX: galleryWidth - imageWidth,
+ minY: galleryHeight - imageHeight
+ }
+ };
+
+ function normalizePosition(x, y, galleryWidth, galleryHeight, imageWidth, imageHeight){
+ var b = bounds(galleryWidth, galleryHeight, imageWidth, imageHeight);
+ return {
+ x: Math.min(b.maxX, Math.max(b.minX, x)),
+ y: Math.min(b.maxY, Math.max(b.minY, y))
+ }
+ };
+
+ function fixImageSize(){
+
+ }
+
+ /*
+ * Perspective
+ */
+ function ScanGalleryPerspective(doc, callback){
+ var self = this;
+
+ this.perspective_id = '';
+ this.doc = doc;
+
+ this.dimensions = {};
+ this.zoomFactor = 1;
+ this.$element = $("#side-gallery");
+ this.$numberInput = $('.page-number', this.$element);
+
+ // ...
+ var origin = {};
+ var imageOrigin = {};
+
+ this.$image = $('.gallery-image img', this.$element).attr('unselectable', 'on');
+
+ // button handlers
+ this.$numberInput.change(function(event){
+ event.preventDefault();
+ self.setPage($(this).val());
+ });
+
+ $('.previous-page', this.$element).click(function(){
+ self.setPage(self.$numberInput.val() - 1);
+ });
+
+ $('.nexy-page', this.$element).click(function(){
+ self.setPage(self.$numberInput.val() + 1);
+ });
+
+ $('.zoom-in', this.$element).click(function(){
+ self.alterZoom(0.2);
+ });
+
+ $('.zoom-out', this.$element).click(function(){
+ self.alterZoom(-0.2);
+ });
+
+ $(window).resize(function(){
+ self.dimensions.galleryWidth = self.$image.parent().width();
+ self.dimensions.galleryHeight = self.$image.parent().height();
+ });
+
+ $('.gallery-image img', this.$element).load(function(){
+ console.load("Image loaded.")
+ self._resizeImage();
+ });
+ };
+
+ ScanGalleryPerspective.prototype = new $.wiki.Perspective();
+
+ ScanGalleryPerspective.prototype._resizeImage = function(){
+ var $img = this.$image;
+
+ $img.css({
+ width: null,
+ height: null
+ });
+
+ this.dimensions = {
+ width: $img.width() * this.zoomFactor,
+ height: $img.height() * this.zoomFactor,
+ originWidth: $img.width(),
+ originHeight: $img.height(),
+ galleryWidth: $img.parent().width(),
+ galleryHeight: $img.parent().height()
+ };
+
+ if (!(this.dimensions.width && this.dimensions.height)) {
+ setTimeout(function(){
+ $img.load();
+ }, 100);
+ }
+
+ var position = normalizePosition($img.position().left, $img.position().top, this.dimensions.galleryWidth, this.dimensions.galleryHeight, this.dimensions.width, this.dimensions.height);
+
+ $img.css({
+ left: position.x,
+ top: position.y,
+ width: $img.width() * this.zoomFactor,
+ height: $img.height() * this.zoomFactor
+ });
+ };
+
+ ScanGalleryPerspective.prototype.setPage = function(newPage){
+ newPage = normalizeNumber(newPage, this.$image.length);
+ this.$numberInput.val(newPage);
+ $('.gallery-image img', this.$element).attr('src', this.doc.galleryImages[newPage - 1]);
+ };
+
+ ScanGalleryPerspective.prototype.alterZoom = function(delta){
+ var zoomFactor = this.zoomFactor + delta;
+ if (zoomFactor < 0.2)
+ zoomFactor = 0.2;
+ if (zoomFactor > 2)
+ zoomFactor = 2;
+ this.setZoom(zoomFactor);
+ };
+
+ ScanGalleryPerspective.prototype.setZoom = function(factor){
+ this.zoomFactor = factor;
+
+ this.dimensions.width = this.dimensions.originWidth * this.zoomFactor;
+ this.dimensions.height = this.dimensions.originHeight * this.zoomFactor;
+
+ var position = normalizePosition(this.$image.position().left, this.$image.position().top, this.dimensions.galleryWidth, this.dimensions.galleryHeight, this.dimensions.width, this.dimensions.height);
+
+ this.$image.css({
+ width: this.dimensions.width,
+ height: this.dimensions.height,
+ left: position.x,
+ top: position.y
+ });
+ };
+
+ /*
+ * Loading gallery
+ */
+ ScanGalleryPerspective.prototype.onEnter = function(success, failure){
+ var self = this;
+
+ $.wiki.Perspective.prototype.onEnter.call(this);
+
+ this.doc.refreshGallery({
+ success: function(doc, data) {
+ self.$image.show();
+ $('.error_message', self.$element).hide();
+ success();
+ },
+ failure: function(doc, message) {
+ self.$image.hide();
+ $('.error_message', self.$element).show().html(message);
+ failure();
+ }
+ });
+ };
+
+ $.wiki.ScanGalleryPerspective = ScanGalleryPerspective;
+})(jQuery);
+
+
+/*
+
+
+ function onMouseMove(event){
+
+
+ var position = normalizePosition(event.clientX - origin.x + imageOrigin.left, event.clientY - origin.y + imageOrigin.top, imageDimensions.galleryWidth, imageDimensions.galleryHeight, imageDimensions.width, imageDimensions.height);
+
+
+ image.css({
+
+
+ position: 'absolute',
+
+
+ top: position.y,
+
+
+ left: position.x
+
+
+ });
+
+
+ return false;
+
+
+ }
+
+
+ function onMouseUp(event){
+
+
+ $(document).unbind('mousemove.gallery').unbind('mouseup.gallery');
+
+
+ return false;
+
+
+ }
+
+
+ image.bind('mousedown', function(event){
+
+
+ origin = {
+
+
+ x: event.clientX,
+
+
+ y: event.clientY
+
+
+ };
+
+
+ imageOrigin = image.position();
+
+
+ $(document).bind('mousemove.gallery', onMouseMove).bind('mouseup.gallery', onMouseUp);
+
+
+ return false;
+
+
+ });
+
+
+ if (url) {
+
+
+ updateGallery(url);
+
+
+ }
+
+
+ }*/
+
+
function CodeMirrorPerspective(doc, callback)
{
this.perspective_id = 'CodeMirrorPerspective';
- this.doc = doc;
+ this.doc = doc; // document model
var self = this;
- $('#source-editor .toolbar button').click(function(event){
- event.preventDefault();
- var params = eval("(" + $(this).attr('ui:action-params') + ")");
- scriptletCenter.scriptlets[$(this).attr('ui:action')](editor, params);
- });
-
- $('.toolbar select').change(function(event){
- var slug = $(this).val();
-
- $('.toolbar-buttons-container').hide().filter('[data-group=' + slug + ']').show();
- $(window).resize();
- });
-
- $('.toolbar-buttons-container').hide();
- $('.toolbar select').change();
-
this.codemirror = CodeMirror.fromTextArea('codemirror_placeholder', {
parserfile: 'parsexml.js',
path: STATIC_URL + "js/lib/codemirror/",
tabMode: 'spaces',
indentUnit: 0,
initCallback: function() {
+ $('#source-editor .toolbar button').click(function(event){
+ event.preventDefault();
+ var params = eval("(" + $(this).attr('data-ui-action-params') + ")");
+ scriptletCenter.scriptlets[$(this).attr('data-ui-action')](self.codemirror, params);
+ });
+
+ $('.toolbar select').change(function(event){
+ var slug = $(this).val();
+
+ $('.toolbar-buttons-container').hide().filter('[data-group=' + slug + ']').show();
+ $(window).resize();
+ });
+
+ $('.toolbar-buttons-container').hide();
+ $('.toolbar select').change();
+
console.log("Initialized CodeMirror");
+ // textarea is no longer needed
+ $('codemirror_placeholder').remove();
callback.call(self);
}
});
if(success) success();
}
+ CodeMirrorPerspective.prototype.onExit = function(success, failure) {
+ $.wiki.Perspective.prototype.onExit.call(this);
+
+ console.log(this.doc);
+ this.doc.setText(this.codemirror.getCode());
+ if(success) success();
+ }
+
$.wiki.CodeMirrorPerspective = CodeMirrorPerspective;
})(jQuery);
--- /dev/null
+(function($){
+
+ function SummaryPerspective(doc, callback) {
+ this.perspective_id = 'SummaryPerspective';
+ this.doc = doc;
+
+ callback.call(this);
+ };
+
+ SummaryPerspective.prototype = new $.wiki.Perspective();
+
+ SummaryPerspective.prototype.freezeState = function(){
+ // must
+ };
+
+ SummaryPerspective.prototype.onEnter = function(success, failure){
+ $.wiki.Perspective.prototype.onEnter.call(this);
+
+ console.log("Entered summery view");
+ };
+
+ $.wiki.SummaryPerspective = SummaryPerspective;
+
+})(jQuery);
+
if (vname == "ajax_document_history") {
return "/" + arguments[1] + "/history";
- }
+ }
+
+ if (vname == "ajax_document_gallery") {
+ return "/gallery/" + arguments[1];
+ }
if(vname == "ajax_document_diff")
- return "/" + arguments[1] + "/diff/" + arguments[2] + "/" + arguments[3]
+ return "/" + arguments[1] + "/diff";
console.log("Couldn't reverse match:", vname);
return "/404.html";
this.id = meta.attr('data-document-name');
this.revision = $("*[data-key='revision']", meta).text();
- this.gallery = $("*[data-key='gallery']", meta).text();
-
+ this.galleryLink = $("*[data-key='gallery']", meta).text();
+ this.galleryImages = [];
this.text = null;
this.has_local_changes = false;
params['success'](self, data);
},
error: function() {
- params['failure'](self, "Nie udało się wczytać treści dokumentu.");
+ params['failure'](self, "Nie udało się wczytać historii dokumentu.");
+ }
+ });
+ };
+
+ WikiDocument.prototype.fetchDiff = function(params) {
+ /* this doesn't modify anything, so no locks */
+ params = $.extend({
+ 'from': self.revision,
+ 'to': self.revision
+ }, noops, params);
+
+ var self = this;
+
+ $.ajax({
+ method: "GET",
+ url: reverse("ajax_document_diff", self.id),
+ dataType: 'json',
+ data: {"from": params['from'], "to": params['to']},
+ success: function(data) {
+ params['success'](self, data);
+ },
+ error: function() {
+ params['failure'](self, "Nie udało się wczytać porównania wersji.");
}
});
};
+ /*
+ * Fetch gallery
+ */
+ WikiDocument.prototype.refreshGallery = function(params) {
+ params = $.extend({}, noops, params);
+ var self = this;
+
+ $.ajax({
+ method: "GET",
+ url: reverse("ajax_document_gallery", self.galleryLink),
+ dataType: 'json',
+ // data: {},
+ success: function(data) {
+ this.galleryImages = data.images;
+ params['success'](self, data);
+ },
+ error: function() {
+ this.galleryImages = [];
+ params['failure'](self, "<p>Nie udało się wczytać gallerii pod nazwą: '"
+ + self.galleryLink + "'.</p>");
+
+ }
+ });
+ };
+
/*
* Set document's text
*/
- WikiDocument.prototype.setText = function(text) {
- this.text = text;
- this.has_local_changes = true;
+ WikiDocument.prototype.setText = function(text) {
+ if (this.text != text) {
+ this.text = text;
+ this.has_local_changes = true;
+ }
};
/*
* Set document's gallery link
*/
- WikiDocument.prototype.setGallery = function(gallery) {
- this.gallery = gallery;
+ WikiDocument.prototype.setGalleryLink = function(gallery) {
+ this.galleryLink = gallery;
this.has_local_changes = true;
};
/*
* Save text back to the server
*/
- WikiDocument.prototype.save = function(comment, success, failure){
+ WikiDocument.prototype.save = function(params){
+ params = $.extend({'comment': 'No comment.'}, noops, params);
var self = this;
+ /* you can't set text while some is fetching it (or saving) */
+
if (!self.has_local_changes) {
- return success(self, "Nie ma zmian do zapisania.");
- }
+ console.log("Abort: no changes.");
+ return params['success'](self, false, "Nie ma zmian do zapisania.");
+ };
- /* you can't set text while some is fetching it (or saving) */
var metaComment = '<!--';
- metaComment += '\n\tgallery:' + self.gallery;
- metaComment += '\n-->'
+ metaComment += '\n\tgallery:' + self.galleryLink;
+ metaComment += '\n-->\n'
var data = {
name: self.id,
- text: self.text,
+ text: metaComment + self.text,
parent_revision: self.revision,
- comment: comment,
+ comment: params['comment'],
};
$.ajax({
self.gallery = data.gallery;
changed = true;
}
- success(self, changed);
+ params['success'](self, changed, "Zapisano");
},
- error: function(){
- failure(self, "Nie udało się zapisać.");
+ error: function() {
+ params['failure'](self, "Nie udało się zapisać.");
}
});
}; /* end of save() */
base = kwargs.pop('base')
def generator():
for path in paths:
- path = os.path.join(base, path)
- print path
-
+ path = os.path.join(base, path)
if not os.path.isdir(path) or is_package(path): continue
for dir, _, files in os.walk(path):
'toolbar',
'wiki',
],
+ requires = [
+ "librarian (>=1.3)",
+ "Django (>=1.1.1,<1.2)",
+ ]
# data_files=[ ('', ['LICENSE', 'NOTICE', 'README.rst', 'AUTHORS.md', 'requirements.txt'])],
)