1- /* angular-summernote v0.5.2 | (c) 2014, 2015 JeongHoon Byun | MIT license */
1+ /* angular-summernote v0.7.0 | (c) 2014, 2015 JeongHoon Byun | MIT license */
22/* global angular */
33angular . module ( 'summernote' , [ ] )
44
@@ -18,21 +18,22 @@ angular.module('summernote', [])
1818 summernoteConfig . lang = $attrs . lang ;
1919 }
2020
21- summernoteConfig . onInit = $scope . init ;
22- summernoteConfig . onEnter = function ( evt ) { $scope . enter ( { evt :evt } ) ; } ;
23- summernoteConfig . onFocus = function ( evt ) { $scope . focus ( { evt :evt } ) ; } ;
24- summernoteConfig . onPaste = function ( evt ) { $scope . paste ( { evt :evt } ) ; } ;
25- summernoteConfig . onKeyup = function ( evt ) { $scope . keyup ( { evt :evt } ) ; } ;
26- summernoteConfig . onKeydown = function ( evt ) { $scope . keydown ( { evt :evt } ) ; } ;
21+ var callbacks = { } ;
22+ callbacks . onInit = $scope . init ;
23+ callbacks . onEnter = function ( evt ) { $scope . enter ( { evt :evt } ) ; } ;
24+ callbacks . onFocus = function ( evt ) { $scope . focus ( { evt :evt } ) ; } ;
25+ callbacks . onPaste = function ( evt ) { $scope . paste ( { evt :evt } ) ; } ;
26+ callbacks . onKeyup = function ( evt ) { $scope . keyup ( { evt :evt } ) ; } ;
27+ callbacks . onKeydown = function ( evt ) { $scope . keydown ( { evt :evt } ) ; } ;
2728 if ( angular . isDefined ( $attrs . onImageUpload ) ) {
28- summernoteConfig . onImageUpload = function ( files ) {
29+ callbacks . onImageUpload = function ( files ) {
2930 $scope . imageUpload ( { files :files , editable : $scope . editable } ) ;
3031 } ;
3132 }
3233
3334 this . activate = function ( scope , element , ngModel ) {
3435 var updateNgModel = function ( ) {
35- var newValue = element . code ( ) ;
36+ var newValue = element . summernote ( 'code' ) ;
3637 if ( element . summernote ( 'isEmpty' ) ) { newValue = '' ; }
3738 if ( ngModel && ngModel . $viewValue !== newValue ) {
3839 $timeout ( function ( ) {
@@ -41,21 +42,16 @@ angular.module('summernote', [])
4142 }
4243 } ;
4344
44- summernoteConfig . onChange = function ( contents ) {
45+ callbacks . onChange = function ( contents ) {
4546 if ( element . summernote ( 'isEmpty' ) ) { contents = '' ; }
4647 updateNgModel ( ) ;
4748 $scope . change ( { contents :contents , editable : $scope . editable } ) ;
4849 } ;
49- summernoteConfig . onBlur = function ( evt ) {
50+ callbacks . onBlur = function ( evt ) {
5051 ( ! summernoteConfig . airMode ) && element . blur ( ) ;
5152 $scope . blur ( { evt :evt } ) ;
5253 } ;
53- if ( angular . isDefined ( $attrs . onToolbarClick ) ) {
54- element . on ( 'summernote.toolbar.click' , function ( evt ) {
55- $scope . toolbarClick ( { evt : evt } ) ;
56- } ) ;
57- }
58-
54+ summernoteConfig . callbacks = callbacks ;
5955 element . summernote ( summernoteConfig ) ;
6056
6157 var editor$ = element . next ( '.note-editor' ) ,
@@ -83,7 +79,7 @@ angular.module('summernote', [])
8379
8480 if ( ngModel ) {
8581 ngModel . $render = function ( ) {
86- element . code ( ngModel . $viewValue || '' ) ;
82+ element . summernote ( 'code' , ngModel . $viewValue || '' ) ;
8783 } ;
8884 }
8985
@@ -98,15 +94,15 @@ angular.module('summernote', [])
9894 currentElement = element ;
9995 // use jquery Event binding instead $on('$destroy') to preserve options data of DOM
10096 element . on ( '$destroy' , function ( ) {
101- element . destroy ( ) ;
97+ element . summernote ( 'destroy' ) ;
10298 $scope . summernoteDestroyed = true ;
10399 } ) ;
104100 } ;
105101
106102 $scope . $on ( '$destroy' , function ( ) {
107103 // when destroying scope directly
108104 if ( ! $scope . summernoteDestroyed ) {
109- currentElement . destroy ( ) ;
105+ currentElement . summernote ( 'destroy' ) ;
110106 }
111107 } ) ;
112108 } ] )
@@ -131,7 +127,6 @@ angular.module('summernote', [])
131127 keyup : '&onKeyup' ,
132128 keydown : '&onKeydown' ,
133129 change : '&onChange' ,
134- toolbarClick : '&onToolbarClick' ,
135130 imageUpload : '&onImageUpload'
136131 } ,
137132 template : '<div class="summernote"></div>' ,
0 commit comments