@@ -96,32 +96,6 @@ openNote.controller("noteController", function( $scope,
9696 } ) ;
9797 } ;
9898
99- //Load or new
100- if ( ! $routeParams . id ) { //new
101- $scope . note . _id = null ;
102- $scope . note . parentFolderID = $location . search ( ) . folderID ;
103- $scope . note . title = "Note Title" ;
104-
105- activateEditMode ( ) ;
106- $ ( ".notePartial" ) . fadeIn ( config . fadeSpeedLong ( ) ) ;
107- }
108- else {
109- /**
110- * Load note
111- */
112- storageService . database ( ) . get ( $routeParams . id ) . then ( function ( doc ) {
113- $scope . note = doc ;
114- $ ( ".notePartial" ) . fadeIn ( config . fadeSpeedLong ( ) ) ;
115-
116- //Add buttons
117- $rootScope . buttons . push ( upButton ( $scope . note . parentFolderID ) ) ;
118- $rootScope . buttons . push ( copyButton ( $scope . note ) ) ;
119- $rootScope . buttons . push ( editButton ( ) ) ;
120-
121- $scope . $apply ( ) ;
122- } ) ;
123- }
124-
12599 /**
126100 * Save a note
127101 */
@@ -172,6 +146,7 @@ openNote.controller("noteController", function( $scope,
172146 var folderID = $scope . note . parentFolderID ; //need to keep track of this because we are about to delete it
173147 $ ( ".notePartial" ) . fadeOut ( config . fadeSpeedShort ( ) ) ;
174148 storageService . database ( ) . remove ( $scope . note ) . then ( function ( ) {
149+ $rootScope . $emit ( "noteDeleted" , $scope . note ) ;
175150 detachWindowUnload ( ) ;
176151 alertify . success ( "Note Deleted" ) ; //all done. close the notify dialog
177152 $location . url ( "/folder/" + folderID ) ;
@@ -221,4 +196,30 @@ openNote.controller("noteController", function( $scope,
221196 var detachWindowUnload = function ( ) {
222197 window . onbeforeunload = null ;
223198 } ;
199+
200+ //Load or new
201+ if ( ! $routeParams . id ) { //new
202+ $scope . note . _id = null ;
203+ $scope . note . parentFolderID = $location . search ( ) . folderID ;
204+ $scope . note . title = "Note Title" ;
205+
206+ activateEditMode ( ) ;
207+ $ ( ".notePartial" ) . fadeIn ( config . fadeSpeedLong ( ) ) ;
208+ }
209+ else {
210+ /**
211+ * Load note
212+ */
213+ storageService . database ( ) . get ( $routeParams . id ) . then ( function ( doc ) {
214+ $scope . note = doc ;
215+ $ ( ".notePartial" ) . fadeIn ( config . fadeSpeedLong ( ) ) ;
216+
217+ //Add buttons
218+ $rootScope . buttons . push ( upButton ( $scope . note . parentFolderID ) ) ;
219+ $rootScope . buttons . push ( copyButton ( $scope . note ) ) ;
220+ $rootScope . buttons . push ( editButton ( ) ) ;
221+
222+ $scope . $apply ( ) ;
223+ } ) ;
224+ }
224225} ) ;
0 commit comments