diff options
Diffstat (limited to 'askbot/skins')
3 files changed, 143 insertions, 88 deletions
diff --git a/askbot/skins/common/media/js/user.js b/askbot/skins/common/media/js/user.js index 2138746b..c52ffff9 100644 --- a/askbot/skins/common/media/js/user.js +++ b/askbot/skins/common/media/js/user.js @@ -86,16 +86,6 @@ $(document).ready(function(){ setupButtonEventHandlers($('#re_remove_flag'), function(){startAction('remove_flag')}); //setupButtonEventHandlers($('#re_close'), function(){startAction('close')}); setupButtonEventHandlers( - $('#re_delete_post'), - function(){ - var data = getSelected(); - if (data['id_list'].length === 0){ - return; - } - $('#rejectEditModal').modal('show'); - } - ); - setupButtonEventHandlers( $('#sel_all'), function(){ setCheckBoxesIn('#responses .new', true); @@ -121,39 +111,20 @@ $(document).ready(function(){ setCheckBoxesIn('#responses .seen', false); } ); + + var reject_post_dialog = new RejectPostDialog(); + reject_post_dialog.decorate($('#reject-edit-modal')); setupButtonEventHandlers( - $('.cancel-reject'), - function(){ - $('#rejectEditModal').modal('hide'); - } - ) - setupButtonEventHandlers( - $('#doReject'), - function(){ - $('#rejectEditModal').modal('hide'); - } - ); - setupButtonEventHandlers( - $('#doRejectWithNewReason'), - function(){ - $('#rejectEditModal').modal('hide'); - } - ); - setupButtonEventHandlers( - $('#useOldReason'), - function(){ - $('#old-reason-btns').show(); - $('#new-reason-btns').hide(); - } - ); - setupButtonEventHandlers( - $('#addReason'), + $('#re_delete_post'), function(){ - $('#old-reason-btns').hide(); - $('#new-reason-btns').show(); + var data = getSelected(); + if (data['id_list'].length === 0){ + return; + } + reject_post_dialog.setSelectedEditIds(data); + reject_post_dialog.show(); } ); - //setupButtonEventHandlers($('.re_expand'), // function(e){ // e.preventDefault(); @@ -183,6 +154,78 @@ $(document).ready(function(){ /** * @constructor + * manages post/edit reject reasons + * in the post moderation view + */ +var RejectPostDialog = function(){ + WrappedElement.call(this); + this._selected_edit_ids = null; + this._state = null;//'select', 'preview', 'add-new' +}; +inherits(RejectPostDialog, WrappedElement); + +RejectPostDialog.prototype.setSelectedEditIds = function(ids){ + this._selected_edit_ids = ids; +}; + +RejectPostDialog.prototype.setState = function(state){ + this._state = state; + if (this._element){ + this._selector.hide(); + this._adder.hide(); + this._previewer.hide(); + if (state === 'select'){ + this._selector.show(); + } else if (state === 'preview'){ + this._previewer.show(); + } else if (state === 'add-new'){ + this._adder.show(); + } + } +}; + +RejectPostDialog.prototype.show = function(){ + $(this._element).modal('show'); +}; + +RejectPostDialog.prototype.addReason = function(title, description){ + $(this._adder).find('.select-other-reason').show(); +}; + +RejectPostDialog.prototype.decorate = function(element){ + this._element = element; + //set default state according to the # of available reasons + this._selector = $(element).find('#reject-edit-modal-select'); + this._adder = $(element).find('#reject-edit-modal-add-new'); + this._previewer = $(element).find('#reject-edit-modal-preview'); + if (this._selector.find('li').length > 0){ + this.setState('select'); + } else { + this.setState('add-new'); + $(this._adder).find('.select-other-reason').hide(); + } + + //var select_box = new SelectBox(); + //select_box.decorate($(this._selector.find('.select-box'))); + + //setup tipped-inputs + var me = this; + setupButtonEventHandlers( + element.find('.select-other-reason'), + function(){ me.setState('select') } + ) + setupButtonEventHandlers( + element.find('.add-new-reason'), + function(){ me.setState('add-new') } + ); + setupButtonEventHandlers( + element.find('.cancel'), + function() { $(element).modal('hide') } + ); +}; + +/** + * @constructor * allows to follow/unfollow users */ var FollowUser = function(){ diff --git a/askbot/skins/default/templates/user_profile/reject_post_dialog.html b/askbot/skins/default/templates/user_profile/reject_post_dialog.html new file mode 100644 index 00000000..9b32121b --- /dev/null +++ b/askbot/skins/default/templates/user_profile/reject_post_dialog.html @@ -0,0 +1,60 @@ +<div class="modal" style="display:none" id="reject-edit-modal"> + <div class="modal-header"> + <a class="close" data-dismiss="modal">x</a> + <h3>{% trans %}Reject the post(s)?{% endtrans %}</h3> + </div> + <div id="reject-edit-modal-add-new">{# create new reject reason #} + <div class="modal-body"> + <p>{% trans %}Please explain why you are rejecting the post.{% endtrans %}</p> + <input + class="reject-reason-title tipped-input" + type="text" + value="{% trans %}Enter a very brief description - it will be used for the future selection of the reject reasons.{% endtrans %}" + /> + <textarea class="reject-reason-details tipped-input"> + {% trans %}Please enter details here. This text will be emailed to the user{% endtrans %} + </textarea> + </div> + <div class="modal-footer"> + <a class="btn use-this-reason" + >{% trans %}Use this reason & reject{% endtrans %}</a> + <a class="btn select-other-reason" + >{% trans %}Use other reason{% endtrans %}</a> + <a class="btn save-reason" + >{% trans %}Save reason, but do not reject{% endtrans %}</a> + <a class="btn cancel">{% trans %}Cancel{% endtrans %}</a> + </div> + </div> + <div id="reject-edit-modal-select">{# select one of existing reasons #} + <div class="modal-body"> + <ul class="select-box"> + {% for reason in reasons %} + <li data-original-title="{{reason.html|escape}}" + >{{reason.title|escape}}</li> + {% endfor %} + </ul> + </div> + <div class="modal-footer"> + <a class="btn select-this-reason" + >{% trans %}Select this reason{% endtrans %}</a> + <a class="btn add-new-reason" + >{% trans %}Add a new reason{% endtrans %}</a> + <a class="btn cancel">{% trans %}Cancel{% endtrans %}</a> + </div> + </div> + <div id="reject-edit-modal-preview">{# preview reject reason #} + <div class="modal-body"> + <p>{% trans %}You have selected reason for the rejection "not relevant for this community". The text shown below will be e-mailed to the user and the post will be deleted.{% endtrans %}</p> + <textarea disabled="disabled" class="selected-reason-text"></textarea> + </div> + <div class="modal-footer"> + <a class="btn use-this-reason" + >{% trans %}Use this reason & reject{% endtrans %}</a> + <a class="btn select-other-reason" + >{% trans %}Use other reason{% endtrans %}</a> + <a class="btn save-reason" + >{% trans %}Edit this reason{% endtrans %}</a> + <a class="btn cancel">{% trans %}Cancel{% endtrans %}</a> + </div> + </div> +</div> diff --git a/askbot/skins/default/templates/user_profile/user_inbox.html b/askbot/skins/default/templates/user_profile/user_inbox.html index 8d1a75fd..4e051a3b 100644 --- a/askbot/skins/default/templates/user_profile/user_inbox.html +++ b/askbot/skins/default/templates/user_profile/user_inbox.html @@ -67,49 +67,7 @@ inbox_section - forum|flags {% endif %} </div> </div> - <div class="modal" style="display:none" id="rejectEditModal"> - <div class="modal-header"> - <a class="close" data-dismiss="modal">x</a> - <h3>{% trans %}Want to reject the post(s)?{% endtrans %}</h3> - </div> - <div class="modal-body"> - <div id="old-reason-content"> - <p id="details"></p> - </div> - <div id="new-reason-content"> - <input - id="id_title" - class="questionTitleInput" - name="title" - autocomplete="off" - /> - {{ macros.edit_post() }} - </div> - <div class="modal-footer"> - <div id="old-reason-btns"> - <a href="#" class="btn cancel-reject">{% trans %}Do nothing{% endtrans %}</a> - <a - id="addReason" - href="#" - class="btn" - >{% trans %}Add new rejection reason{% endtrans %}</a> - <a id="doReject" href="#" class="btn btn-primary">{% trans %}Reject post{% endtrans %}</a> - </div> - <div id="new-reason-btns" style="display:none"> - <a href="#" class="btn cancel-reject">{% trans %}Do nothing{% endtrans %}</a> - <a - id="useOldReason" - href="#" - class="btn" - >{% trans %}Use existing rejection reason{% endtrans %}</a> - <a - id="doRejectWithNewReason" - href="#" - class="btn btn-primary" - >{% trans %}Save reason and reject post{% endtrans %}</a> - </div> - </div> - </div> + {% include "user_profile/reject_post_dialog.html" %} <div id="responses"> {% for response in responses %} <div class="response-parent"> @@ -130,12 +88,6 @@ inbox_section - forum|flags var askbot = askbot || {}; askbot['urls'] = askbot['urls'] || {}; askbot['urls']['manageInbox'] = '{% url manage_inbox %}'; - askbot['data']['rejectReasonDetails'] = []; - {% for reason in post_reject_reasons %} - askbot['data']['rejectReasonDetails'].push( - "{{reason.html|escapejs}}" - ) - {% endfor %} </script> <script type="text/javascript" src="{{'/bootstrap/js/bootstrap.js'|media}}" /> <!-- end user_responses.html --> |