diff options
Diffstat (limited to 'askbot/skins/common/media/js')
-rw-r--r-- | askbot/skins/common/media/js/post.js | 76 | ||||
-rw-r--r-- | askbot/skins/common/media/js/user.js | 54 |
2 files changed, 105 insertions, 25 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 |