@@ -6,38 +6,45 @@ import Parser from "patternslib/src/core/parser";
6
6
const parser = new Parser ( "content-mirror" ) ;
7
7
parser . add_argument ( "target" ) ;
8
8
9
-
10
9
export default Base . extend ( {
11
- name : "content-mirror" ,
12
- trigger : ".pat-content-mirror" ,
13
- defaults : {
14
- target : "p.content-mirror .text" ,
15
- } ,
10
+ name : "content-mirror" ,
11
+ trigger : ".pat-content-mirror" ,
12
+ defaults : {
13
+ target : "p.content-mirror .text" ,
14
+ } ,
16
15
17
- init : function content_mirror_init ( $el , opts ) {
18
- const options = parser . parse ( $el , opts , true ) [ 0 ] ;
19
- this . options = _ . extend ( _ . clone ( this . defaults ) , options ) ;
20
- const $mirror = $ ( this . options . target ) . parents ( "p.content-mirror" ) . first ( ) ;
21
- $el . on ( "input propertychange" , $ . proxy ( this . updateMirror , this , this . options . target ) ) ;
22
- $el
23
- . parents ( "form" )
24
- . first ( )
25
- . on ( "reset" , function ( e ) {
26
- $el . val ( "" ) ;
27
- $mirror . html ( $mirror . html ( ) ) ;
28
- } ) ;
29
- $ ( ".placeholder" , this . options . target ) . text ( $el . attr ( "placeholder" ) || "" ) ;
30
- } ,
16
+ init : function content_mirror_init ( $el , opts ) {
17
+ const options = parser . parse ( $el , opts , true ) [ 0 ] ;
18
+ this . options = _ . extend ( _ . clone ( this . defaults ) , options ) ;
19
+ const $mirror = $ ( this . options . target )
20
+ . parents ( "p.content-mirror" )
21
+ . first ( ) ;
22
+ $el . on (
23
+ "input propertychange" ,
24
+ $ . proxy ( this . updateMirror , this , this . options . target )
25
+ ) ;
26
+ $el . parents ( "form" )
27
+ . first ( )
28
+ . on ( "reset" , function ( e ) {
29
+ $el . val ( "" ) ;
30
+ $mirror . html ( $mirror . html ( ) ) ;
31
+ } ) ;
32
+ $ ( ".placeholder" , this . options . target ) . text (
33
+ $el . attr ( "placeholder" ) || ""
34
+ ) ;
35
+ } ,
31
36
32
- updateMirror : function updateMirror ( target , ev ) {
33
- const $el = $ ( ev . target ) ;
34
- const the_mirror = $ ( target ) ;
35
- the_mirror . text ( $el . val ( ) ) ;
36
- if ( ! $el . val ( ) . length ) {
37
- const placeholder = $el . attr ( "placeholder" ) ;
38
- if ( placeholder ) {
39
- the_mirror . html ( '<em class="placeholder">' + placeholder + "</em>" ) ;
40
- }
41
- }
42
- } ,
37
+ updateMirror : function updateMirror ( target , ev ) {
38
+ const $el = $ ( ev . target ) ;
39
+ const the_mirror = $ ( target ) ;
40
+ the_mirror . text ( $el . val ( ) ) ;
41
+ if ( ! $el . val ( ) . length ) {
42
+ const placeholder = $el . attr ( "placeholder" ) ;
43
+ if ( placeholder ) {
44
+ the_mirror . html (
45
+ '<em class="placeholder">' + placeholder + "</em>"
46
+ ) ;
47
+ }
48
+ }
49
+ } ,
43
50
} ) ;
0 commit comments