From f67e6a86363fd9bd480209527393653f3e008186 Mon Sep 17 00:00:00 2001 From: Denis Shakhov Date: Thu, 24 Jul 2014 23:28:52 +0700 Subject: [PATCH] =?UTF-8?q?Fixes=20#496=20=D0=94=D0=BE=D1=80=D0=B0=D0=B1?= =?UTF-8?q?=D0=BE=D1=82=D0=B0=D1=82=D1=8C=20=D1=84=D0=BE=D1=80=D0=BC=D1=83?= =?UTF-8?q?=20=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=BE?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D1=81=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/frontend/common/js/poll-manage.js | 14 +++++++++----- .../developer/components/poll/poll.form.item.tpl | 2 +- .../skin/developer/components/poll/poll.form.tpl | 3 ++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/application/frontend/common/js/poll-manage.js b/application/frontend/common/js/poll-manage.js index fcf91a7b..26b51a85 100644 --- a/application/frontend/common/js/poll-manage.js +++ b/application/frontend/common/js/poll-manage.js @@ -159,10 +159,14 @@ * @param {jQuery} list Список ответов */ answerAdd: function( list ) { + var answers = list.find( this.option( 'selectors.form.item' ) ); + // Ограничиваем кол-во добавляемых ответов - if ( list.find( this.option( 'selectors.form.item' ) ).length == this.option( 'max' ) ) { + if ( answers.length == this.option( 'max' ) ) { ls.msg.error( null, ls.lang.get( 'poll.notices.error_answers_max' ) ); return; + } else if ( answers.length == 2 ) { + answers.find( this.option( 'selectors.form.item_remove' ) ).show(); } var item = $( this.option( 'selectors.form.item' ) + '[data-is-template=true]' ).clone().removeAttr( 'data-is-template' ).show(); @@ -178,10 +182,10 @@ * @param {jQuery} button Кнопка удаления */ answerRemove: function( list, button ) { - if ( list.find( this.option( 'selectors.form.item' ) ).length == 1 ) { - // TODO: Fix text - ls.msg.error( null, ls.lang.get( 'poll.notices.error_answers_max' ) ); - return; + var answers = list.find( this.option( 'selectors.form.item' ) ); + + if ( answers.length == 3 ) { + answers.find( this.option( 'selectors.form.item_remove' ) ).hide(); } button.closest( this.option( 'selectors.form.item' ) ).fadeOut(200, function () { diff --git a/application/frontend/skin/developer/components/poll/poll.form.item.tpl b/application/frontend/skin/developer/components/poll/poll.form.item.tpl index f2262240..e71c0064 100644 --- a/application/frontend/skin/developer/components/poll/poll.form.item.tpl +++ b/application/frontend/skin/developer/components/poll/poll.form.item.tpl @@ -24,6 +24,6 @@ {* Кнопка удаления *} {if $bPollIsAllowRemove|default:true} - + {/if} \ No newline at end of file diff --git a/application/frontend/skin/developer/components/poll/poll.form.tpl b/application/frontend/skin/developer/components/poll/poll.form.tpl index 6474e1ef..dfa98276 100644 --- a/application/frontend/skin/developer/components/poll/poll.form.tpl +++ b/application/frontend/skin/developer/components/poll/poll.form.tpl @@ -63,7 +63,8 @@ bPollIsAllowRemove = $oPoll->isAllowUpdate() && ! $oAnswer->getCountVote()} {/foreach} {else} - {include './poll.form.item.tpl'} + {include './poll.form.item.tpl' showRemove=false} + {include './poll.form.item.tpl' showRemove=false} {/if}