@@ -186,9 +186,9 @@ exports.activate = function (opts) {
186
186
var widget_data = poll_data . get_widget_data ( ) ;
187
187
var html = templates . render ( 'poll-widget-results' , widget_data ) ;
188
188
elem . find ( 'ul.poll-widget' ) . html ( html ) ;
189
-
190
189
elem . find ( '.poll-question-header' ) . text ( widget_data . question ) ;
191
190
if ( ! is_my_poll ) {
191
+ elem . find ( '.poll-edit-question' ) . hide ( ) ;
192
192
if ( widget_data . question !== '' ) {
193
193
// For the non-senders, we hide the question input bar
194
194
// when we have a question assigned to the poll
@@ -199,14 +199,56 @@ exports.activate = function (opts) {
199
199
elem . find ( 'button.poll-question' ) . attr ( 'disabled' , true ) ;
200
200
elem . find ( 'input.poll-question' ) . attr ( 'disabled' , true ) ;
201
201
}
202
+ } else {
203
+ if ( widget_data . question === '' ) {
204
+ elem . find ( '.poll-edit-question' ) . hide ( ) ;
205
+ } else {
206
+ elem . find ( '.poll-edit-question' ) . show ( ) ;
207
+ }
202
208
}
203
209
if ( widget_data . question !== '' ) {
204
- elem . find ( 'button.poll-question' ) . text ( i18n . t ( 'Edit question' ) ) ;
210
+ elem . find ( 'button.poll-question' ) . empty ( ) . addClass ( 'fa fa-check poll-question-check' ) ;
211
+ elem . find ( 'button.poll-question-remove' ) . removeClass ( 'd-none' ) ;
212
+ elem . find ( '.poll-question-bar' ) . hide ( ) ;
205
213
elem . find ( '.poll-comment-bar' ) . show ( ) ;
206
214
} else {
207
215
elem . find ( '.poll-comment-bar' ) . hide ( ) ;
216
+ elem . find ( '.poll-edit-question' ) . hide ( ) ;
208
217
}
218
+ if ( is_my_poll ) {
219
+ elem . find ( 'input.poll-question' ) . on ( 'keyup' , function ( ) {
220
+ if ( elem . find ( 'input.poll-question' ) . val ( ) . length > 0 ) {
221
+ elem . find ( 'button.poll-question' ) . removeAttr ( 'disabled' ) ;
222
+ } else {
223
+ elem . find ( 'button.poll-question' ) . attr ( 'disabled' , true ) ;
209
224
225
+ }
226
+ } ) ;
227
+ elem . find ( '.poll-edit-question' ) . on ( 'click' , function ( ) {
228
+ if ( elem . find ( 'input.poll-question' ) . val ( ) . length > 0 ) {
229
+ elem . find ( 'button.poll-question' ) . removeAttr ( 'disabled' ) ;
230
+ }
231
+ } ) ;
232
+ }
233
+ elem . find ( ".poll-edit-question" ) . on ( 'click' , function ( ) {
234
+ elem . find ( '.poll-question-header' ) . hide ( ) ;
235
+ elem . find ( '.poll-question-bar' ) . show ( ) ;
236
+ elem . find ( '.poll-edit-question' ) . hide ( ) ;
237
+ elem . find ( 'input.poll-question' ) . empty ( ) . val ( widget_data . question ) . select ( ) ;
238
+ } ) ;
239
+
240
+ elem . find ( "button.poll-question" ) . on ( 'click' , function ( ) {
241
+ if ( widget_data . question !== '' ) {
242
+ elem . find ( ".poll-question-bar" ) . hide ( ) ;
243
+ elem . find ( '.poll-question-header' ) . show ( ) ;
244
+ }
245
+ } ) ;
246
+
247
+ elem . find ( "button.poll-question-remove" ) . on ( 'click' , function ( ) {
248
+ elem . find ( '.poll-question-bar' ) . hide ( ) ;
249
+ elem . find ( '.poll-edit-question' ) . show ( ) ;
250
+ elem . find ( '.poll-question-header' ) . show ( ) ;
251
+ } ) ;
210
252
elem . find ( "button.poll-vote" ) . on ( 'click' , function ( e ) {
211
253
e . stopPropagation ( ) ;
212
254
var key = $ ( e . target ) . attr ( 'data-key' ) ;
0 commit comments