summaryrefslogtreecommitdiffstats
path: root/askbot/skins
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-09-09 21:16:16 -0400
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-09-09 21:16:16 -0400
commit4e550d5358a512bf543efbf862ed75709b955340 (patch)
treebf37433f15e20dd1252ece9acb69163bac661dc8 /askbot/skins
parente5fbb42da5665df017cb98b7cb99d8c8d8d5fe52 (diff)
downloadaskbot-4e550d5358a512bf543efbf862ed75709b955340.tar.gz
askbot-4e550d5358a512bf543efbf862ed75709b955340.tar.bz2
askbot-4e550d5358a512bf543efbf862ed75709b955340.zip
tinymce editor works in the popups too
Diffstat (limited to 'askbot/skins')
-rw-r--r--askbot/skins/common/media/js/post.js76
-rw-r--r--askbot/skins/common/media/js/user.js54
-rw-r--r--askbot/skins/default/media/style/style.less19
-rw-r--r--askbot/skins/default/templates/answer_edit.html2
-rw-r--r--askbot/skins/default/templates/ask.html3
-rw-r--r--askbot/skins/default/templates/embed/ask_by_widget.html2
-rw-r--r--askbot/skins/default/templates/meta/bottom_scripts.html1
-rw-r--r--askbot/skins/default/templates/meta/tinymce.html20
-rw-r--r--askbot/skins/default/templates/question/javascript.html2
-rw-r--r--askbot/skins/default/templates/question_edit.html2
10 files changed, 125 insertions, 56 deletions
diff --git a/askbot/skins/common/media/js/post.js b/askbot/skins/common/media/js/post.js
index 4cbb9f7e..adcb0cd6 100644
--- a/askbot/skins/common/media/js/post.js
+++ b/askbot/skins/common/media/js/post.js
@@ -2177,10 +2177,6 @@ WMD.prototype.setPreviewerEnabled = function(state){
}
};
-WMD.prototype.setEscapeHandler = function(handler){
- this._escape_handler = handler;
-};
-
WMD.prototype.createDom = function(){
this._element = this.makeElement('div');
var clearfix = this.makeElement('div').addClass('clearfix');
@@ -2227,7 +2223,67 @@ WMD.prototype.getText = function(){
WMD.prototype.start = function(){
Attacklab.Util.startEditor(true, this._enabled_buttons);
- this._textarea.keyup(makeKeyHandler(27, this._escape_handler));
+};
+
+/**
+ * @constructor
+ */
+var TinyMCE = function(config) {
+ WrappedElement.call(this);
+ this._config = config || {};
+};
+inherits(TinyMCE, WrappedElement);
+
+/* 3 dummy functions to match WMD api */
+TinyMCE.prototype.setEnabledButtons = function() {};
+TinyMCE.prototype.start = function() {
+ this.loadEditor();
+};
+TinyMCE.prototype.setPreviewerEnabled = function() {};
+
+TinyMCE.prototype.setText = function(text) {
+ askbot['data']['editorContent'] = text;
+};
+
+TinyMCE.prototype.getText = function() {
+ return tinyMCE.activeEditor.getContent();
+};
+
+TinyMCE.prototype.loadEditor = function() {
+ var config = JSON.stringify(this._config);
+ var data = {config: config};
+ var editorBox = this._element;
+ var me = this;
+ $.ajax({
+ async: false,
+ type: 'GET',
+ dataType: 'json',
+ cache: false,
+ url: askbot['urls']['getEditor'],
+ data: data,
+ success: function(data) {
+ if (data['success']) {
+ editorBox.html(data['html']);
+ $.each(data['scripts'], function(idx, scriptData) {
+ var scriptElement = me.makeElement('script');
+ scriptElement.attr('type', 'text/javascript');
+ if (scriptData['src']) {
+ scriptElement.attr('src', scriptData['src']);
+ }
+ if (scriptData['contents']) {
+ scriptElement.html(scriptData['contents']);
+ }
+ $('head').append(scriptElement);
+ });
+ }
+ }
+ });
+};
+
+TinyMCE.prototype.createDom = function() {
+ var editorBox = this.makeElement('div');
+ editorBox.addClass('wmd-container');
+ this._element = editorBox;
};
/**
@@ -2379,13 +2435,19 @@ TagWikiEditor.prototype.decorate = function(element){
if (askbot['settings']['editorType'] === 'markdown') {
var editor = new WMD();
} else {
- var editor = new TinyMCEWrapper();
+ var editor = new TinyMCE({//override defaults
+ mode: 'exact',
+ elements: 'editor',
+ theme_advanced_buttons1: 'bold, italic, |, link, |, numlist, bullist',
+ theme_advanced_buttons2: '',
+ plugins: '',
+ width: '200'
+ });
}
if (this._enabled_editor_buttons){
editor.setEnabledButtons(this._enabled_editor_buttons);
}
editor.setPreviewerEnabled(this._is_previewer_enabled);
- editor.setEscapeHandler(function(){me.cancelEdit()});
this._editor = editor;
setupButtonEventHandlers(edit_btn, function(){ me.startActivatingEditor() });
setupButtonEventHandlers(cancel_btn, function(){me.cancelEdit()});
diff --git a/askbot/skins/common/media/js/user.js b/askbot/skins/common/media/js/user.js
index 4795b7d2..2fd1195b 100644
--- a/askbot/skins/common/media/js/user.js
+++ b/askbot/skins/common/media/js/user.js
@@ -1,3 +1,4 @@
+//todo: refactor this into "Inbox" object or more specialized
var setup_inbox = function(){
var getSelected = function(){
@@ -114,15 +115,15 @@ var setup_inbox = function(){
var rejectPostDialog = new RejectPostDialog();
rejectPostDialog.decorate($('#reject-edit-modal'));
+ rejectPostDialog.setSelectedEditDataReader(function(){
+ return getSelected();
+ });
setupButtonEventHandlers(
$('#re_delete_post'),
function(){
- var data = getSelected();
- if (data['id_list'].length === 0){
- return;
+ if (rejectPostDialog.readSelectedEditData()) {
+ rejectPostDialog.show();
}
- rejectPostDialog.setSelectedEditData(data);
- rejectPostDialog.show();
}
);
@@ -136,15 +137,6 @@ var setup_inbox = function(){
$(response).append(control.getElement());
});
}
- //setupButtonEventHandlers($('.re_expand'),
- // function(e){
- // e.preventDefault();
- // var re_snippet = $(this).find(".re_snippet:first")
- // var re_content = $(this).find(".re_content:first")
- // $(re_snippet).slideToggle();
- // $(re_content).slideToggle();
- // }
- //);
};
var setup_badge_details_toggle = function(){
@@ -182,9 +174,19 @@ PostModerationControls.prototype.getMemoId = function() {
return this._parent_element.data('responseId');
};
-PostModerationControls.prototype.removeMemo = function() {
+PostModerationControls.prototype.getMemoElement = function() {
var reId = this.getMemoId();
- $('#re_' + reId).remove();
+ return $('#re_' + reId);
+};
+
+PostModerationControls.prototype.removeMemo = function() {
+ this.getMemoElement().remove();
+};
+
+PostModerationControls.prototype.markMemo = function() {
+ var memo = this.getMemoElement();
+ var checkbox = memo.find('input[type="checkbox"]');
+ checkbox.attr('checked', true);
};
PostModerationControls.prototype.addReason = function(id, title) {
@@ -277,7 +279,9 @@ PostModerationControls.prototype.createDom = function() {
var reasonsDlg = this._reasonsDialog;
setupButtonEventHandlers(anchor, function() {
- reasonsDlg.show();
+ me.markMemo();//mark current post
+ reasonsDlg.readSelectedEditData();//read data of selected edits
+ reasonsDlg.show();//open the "big" dialog
});
setupButtonEventHandlers(acceptBtn, function() {
me.moderatePost(null, 'remove_flag');
@@ -295,9 +299,20 @@ var RejectPostDialog = function(){
this._selected_reason_id = null;
this._state = null;//'select', 'preview', 'add-new'
this._postModerationControls = [];
+ this._selectedEditDataReader = undefined;
};
inherits(RejectPostDialog, WrappedElement);
+RejectPostDialog.prototype.setSelectedEditDataReader = function(func) {
+ this._selectedEditDataReader = func;
+};
+
+RejectPostDialog.prototype.readSelectedEditData = function() {
+ var data = this._selectedEditDataReader();
+ this.setSelectedEditData(data);
+ return data['id_list'].length > 0;
+};
+
RejectPostDialog.prototype.setSelectedEditData = function(data){
this._selected_edit_data = data;
};
@@ -485,7 +500,10 @@ RejectPostDialog.prototype.rejectPost = function(reason_id){
url: askbot['urls']['manageInbox'],
success: function(data){
if (data['success']){
- memos.remove();
+ $.each(memos, function(idx, memo) {
+ $(memo).next('.post-moderation-controls').remove();
+ $(memo).remove();
+ });
me.hide();
} else {
//only fatal errors here
diff --git a/askbot/skins/default/media/style/style.less b/askbot/skins/default/media/style/style.less
index 71570ee1..8d10a4d4 100644
--- a/askbot/skins/default/media/style/style.less
+++ b/askbot/skins/default/media/style/style.less
@@ -1702,6 +1702,25 @@ ul#related-tags li {
max-width: 600px;
}
+.defaultSkin table.mceLayout,
+.defaultSkin table.mceLayout tr.mceFirst td {
+ border: none;
+}
+.defaultSkin table.mceLayout tr.mceLast td {
+ border-bottom: none;
+}
+.mceStatusbar {
+ height: 5px;
+ background: #fff;
+}
+.defaultSkin span.mce_askbot_imageuploader {
+ background-position: -380px 0px;
+}
+.defaultSkin span.mce_askbot_attachment {
+ background-image: url(../images/attachment.png);
+ background-position: 0px 0px;
+}
+
.user-page .wmd-buttons {
width: 725px;
}
diff --git a/askbot/skins/default/templates/answer_edit.html b/askbot/skins/default/templates/answer_edit.html
index b38f3fff..8c3687f1 100644
--- a/askbot/skins/default/templates/answer_edit.html
+++ b/askbot/skins/default/templates/answer_edit.html
@@ -59,8 +59,6 @@
{% if settings.EDITOR_TYPE == 'markdown' %}
<script type='text/javascript' src='{{"/js/wmd/showdown.js"|media}}'></script>
<script type='text/javascript' src='{{"/js/wmd/wmd.js"|media}}'></script>
- {% else %}
- {% include "meta/tinymce.html" %}
{% endif %}
<script type="text/javascript">
$().ready(function(){
diff --git a/askbot/skins/default/templates/ask.html b/askbot/skins/default/templates/ask.html
index 5f072577..27434f83 100644
--- a/askbot/skins/default/templates/ask.html
+++ b/askbot/skins/default/templates/ask.html
@@ -19,9 +19,6 @@
{% if settings.EDITOR_TYPE == 'markdown' %}
<script type='text/javascript' src='{{"/js/wmd/showdown.js"|media}}'></script>
<script type='text/javascript' src='{{"/js/wmd/wmd.js"|media}}'></script>
- {% else %}
- <script type='text/javascript' src='{{"/js/wmd/showdown.js"|media}}'></script>
- {% include "meta/tinymce.html" %}
{% endif %}
<script type='text/javascript'>
var sortMethod = undefined;//need for live_search
diff --git a/askbot/skins/default/templates/embed/ask_by_widget.html b/askbot/skins/default/templates/embed/ask_by_widget.html
index 96be40ac..416dc655 100644
--- a/askbot/skins/default/templates/embed/ask_by_widget.html
+++ b/askbot/skins/default/templates/embed/ask_by_widget.html
@@ -224,8 +224,6 @@
{% if editor_type == 'markdown' %}
<script type='text/javascript' src='{{"/js/wmd/showdown.js"|media}}'></script>
<script type='text/javascript' src='{{"/js/wmd/wmd.js"|media}}'></script>
-{% else %}
- {% include "meta/tinymce.html" %}
{% endif %}
{% endblock %}
diff --git a/askbot/skins/default/templates/meta/bottom_scripts.html b/askbot/skins/default/templates/meta/bottom_scripts.html
index a36a63ec..09970468 100644
--- a/askbot/skins/default/templates/meta/bottom_scripts.html
+++ b/askbot/skins/default/templates/meta/bottom_scripts.html
@@ -25,6 +25,7 @@
askbot['urls']['unfollow_user'] = '/followit/unfollow/user/{{'{{'}}userId{{'}}'}}/';
askbot['urls']['user_signin'] = '{{ settings.LOGIN_URL }}';
askbot['settings']['static_url'] = '{{ settings.STATIC_URL }}';
+ askbot['urls']['getEditor'] = '{% url "get_editor" %}';
</script>
<script
type="text/javascript"
diff --git a/askbot/skins/default/templates/meta/tinymce.html b/askbot/skins/default/templates/meta/tinymce.html
deleted file mode 100644
index d6b1b7b9..00000000
--- a/askbot/skins/default/templates/meta/tinymce.html
+++ /dev/null
@@ -1,20 +0,0 @@
-<style type="text/css">
- .defaultSkin table.mceLayout,
- .defaultSkin table.mceLayout tr.mceFirst td {
- border: none;
- }
- .defaultSkin table.mceLayout tr.mceLast td {
- border-bottom: none;
- }
- .mceStatusbar {
- height: 5px;
- background: #fff;
- }
- .defaultSkin span.mce_askbot_imageuploader {
- background-position: -380px 0px;
- }
- .defaultSkin span.mce_askbot_attachment {
- background-image: url({{ '/images/attachment.png'|media }});
- background-position: 0px 0px;
- }
-</style>
diff --git a/askbot/skins/default/templates/question/javascript.html b/askbot/skins/default/templates/question/javascript.html
index 19a7269c..d178acad 100644
--- a/askbot/skins/default/templates/question/javascript.html
+++ b/askbot/skins/default/templates/question/javascript.html
@@ -32,8 +32,6 @@
{% if settings.EDITOR_TYPE == 'markdown' %}
<script type='text/javascript' src='{{"/js/wmd/showdown.js"|media}}'></script>
<script type='text/javascript' src='{{"/js/wmd/wmd.js"|media}}'></script>
-{% else %}
- {% include "meta/tinymce.html" %}
{% endif %}
<script type='text/javascript' src='{{"/js/jquery.validate.min.js"|media}}'></script>
<script type='text/javascript' src='{{"/js/post.js"|media}}'></script>
diff --git a/askbot/skins/default/templates/question_edit.html b/askbot/skins/default/templates/question_edit.html
index f4e4fbbf..f176b11d 100644
--- a/askbot/skins/default/templates/question_edit.html
+++ b/askbot/skins/default/templates/question_edit.html
@@ -64,8 +64,6 @@
{% if settings.EDITOR_TYPE == 'markdown' %}
<script type='text/javascript' src='{{"/js/wmd/showdown.js"|media}}'></script>
<script type='text/javascript' src='{{"/js/wmd/wmd.js"|media}}'></script>
- {% else %}
- {% include "meta/tinymce.html" %}
{% endif %}
<script type="text/javascript">
{% if settings.ENABLE_MATHJAX or settings.MARKUP_CODE_FRIENDLY %}