@@ -11,27 +11,6 @@ var globals = require("app/globals");
1111
1212"use strict" ;
1313
14- var editorify = function ( el ) {
15- el = $ . htmlify ( el ) ;
16- el . setAttribute ( "contentEditable" , true ) ;
17-
18- el . on ( "focus" , function ( ) {
19- if ( el . classList . contains ( "isso-placeholder" ) ) {
20- el . innerHTML = "" ;
21- el . classList . remove ( "isso-placeholder" ) ;
22- }
23- } ) ;
24-
25- el . on ( "blur" , function ( ) {
26- if ( el . textContent . length === 0 ) {
27- el . textContent = i18n . translate ( "postbox-text" ) ;
28- el . classList . add ( "isso-placeholder" ) ;
29- }
30- } ) ;
31-
32- return el ;
33- }
34-
3514var Postbox = function ( parent ) {
3615
3716 var localStorage = utils . localStorageImpl ,
@@ -46,9 +25,7 @@ var Postbox = function(parent) {
4625 el . onsuccess = function ( ) { } ;
4726
4827 el . validate = function ( ) {
49- if ( utils . text ( $ ( ".isso-textarea" , this ) . innerHTML ) . length < 3 ||
50- $ ( ".isso-textarea" , this ) . classList . contains ( "isso-placeholder" ) )
51- {
28+ if ( $ ( ".isso-textarea" , this ) . value . length < 3 ) {
5229 $ ( ".isso-textarea" , this ) . focus ( ) ;
5330 return false ;
5431 }
@@ -92,7 +69,7 @@ var Postbox = function(parent) {
9269
9370 // preview function
9471 $ ( "[name='preview']" , el ) . on ( "click" , function ( ) {
95- api . preview ( utils . text ( $ ( ".isso-textarea" , el ) . innerHTML ) ) . then (
72+ api . preview ( $ ( ".isso-textarea" , el ) . value ) . then (
9673 function ( html ) {
9774 $ ( ".isso-preview .isso-text" , el ) . innerHTML = html ;
9875 el . classList . add ( 'isso-preview-mode' ) ;
@@ -104,8 +81,14 @@ var Postbox = function(parent) {
10481 $ ( ".isso-preview .isso-text" , el ) . innerHTML = '' ;
10582 el . classList . remove ( 'isso-preview-mode' ) ;
10683 } ;
107- $ ( "[name='edit']" , el ) . on ( "click" , edit ) ;
108- $ ( ".isso-preview" , el ) . on ( "click" , edit ) ;
84+ $ ( "[name='edit']" , el ) . on ( "click" , function ( ) {
85+ edit ( ) ;
86+ $ ( ".isso-textarea" , el ) . focus ( ) ;
87+ } ) ;
88+ $ ( ".isso-preview" , el ) . on ( "click" , function ( ) {
89+ edit ( ) ;
90+ $ ( ".isso-textarea" , el ) . focus ( ) ;
91+ } ) ;
10992
11093 // submit form, initialize optional fields with `null` and reset form.
11194 // If replied to a comment, remove form completely.
@@ -125,13 +108,12 @@ var Postbox = function(parent) {
125108
126109 api . create ( $ ( "#isso-thread" ) . getAttribute ( "data-isso-id" ) , {
127110 author : author , email : email , website : website ,
128- text : utils . text ( $ ( ".isso-textarea" , el ) . innerHTML ) ,
111+ text : $ ( ".isso-textarea" , el ) . value ,
129112 parent : parent || null ,
130113 title : $ ( "#isso-thread" ) . getAttribute ( "data-title" ) || null ,
131114 notification : $ ( "[name=notification]" , el ) . checked ( ) ? 1 : 0 ,
132115 } ) . then ( function ( comment ) {
133- $ ( ".isso-textarea" , el ) . innerHTML = "" ;
134- $ ( ".isso-textarea" , el ) . blur ( ) ;
116+ $ ( ".isso-textarea" , el ) . value = "" ;
135117 insert ( comment , true ) ;
136118
137119 if ( parent !== null ) {
@@ -140,8 +122,6 @@ var Postbox = function(parent) {
140122 } ) ;
141123 } ) ;
142124
143- editorify ( $ ( ".isso-textarea" , el ) ) ;
144-
145125 return el ;
146126} ;
147127
@@ -296,9 +276,12 @@ var insert = function(comment, scrollIntoView) {
296276
297277 toggler . canceled = false ;
298278 api . view ( comment . id , 1 ) . then ( function ( rv ) {
299- var textarea = editorify ( $ . new ( "div.isso-textarea" ) ) ;
279+ var textarea = $ . new ( "textarea.isso-textarea" ) ;
280+ textarea . setAttribute ( "rows" , 5 ) ;
281+ textarea . setAttribute ( "minlength" , 3 ) ;
282+ textarea . setAttribute ( "maxlength" , 65535 ) ;
300283
301- textarea . innerHTML = utils . detext ( rv . text ) ;
284+ textarea . value = rv . text ;
302285 textarea . focus ( ) ;
303286
304287 text . classList . remove ( "isso-text" ) ;
@@ -317,12 +300,12 @@ var insert = function(comment, scrollIntoView) {
317300 var avatar = config [ "avatar" ] || config [ "gravatar" ] ? $ ( ".isso-avatar" , el , false ) [ 0 ] : null ;
318301
319302 if ( ! toggler . canceled && textarea !== null ) {
320- if ( utils . text ( textarea . innerHTML ) . length < 3 ) {
303+ if ( textarea . value . length < 3 ) {
321304 textarea . focus ( ) ;
322305 toggler . wait ( ) ;
323306 return ;
324307 } else {
325- api . modify ( comment . id , { "text" : utils . text ( textarea . innerHTML ) } ) . then ( function ( rv ) {
308+ api . modify ( comment . id , { "text" : textarea . value } ) . then ( function ( rv ) {
326309 text . innerHTML = rv . text ;
327310 comment . text = rv . text ;
328311 } ) ;
@@ -416,7 +399,6 @@ var insert = function(comment, scrollIntoView) {
416399} ;
417400
418401module . exports = {
419- editorify : editorify ,
420402 insert : insert ,
421403 insert_loader : insert_loader ,
422404 Postbox : Postbox ,
0 commit comments