diff options
author | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2012-04-27 11:09:33 -0300 |
---|---|---|
committer | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2012-04-27 11:09:33 -0300 |
commit | 2736c7faaacecd011fe5f3b280489563a736ae04 (patch) | |
tree | 223e3e2e638e3a18991b0ff2476bafdd452a6e58 /askbot/skins/common/media/js/user.js | |
parent | a78a6f0c7ae03d0460b72762d89cb5a55b527de6 (diff) | |
download | askbot-2736c7faaacecd011fe5f3b280489563a736ae04.tar.gz askbot-2736c7faaacecd011fe5f3b280489563a736ae04.tar.bz2 askbot-2736c7faaacecd011fe5f3b280489563a736ae04.zip |
started working on a menu for rejecting the post
Diffstat (limited to 'askbot/skins/common/media/js/user.js')
-rw-r--r-- | askbot/skins/common/media/js/user.js | 121 |
1 files changed, 82 insertions, 39 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(){ |