@@ -124,6 +124,9 @@ WireIt.WiringEditor = function(options) {
124124 // Render buttons
125125 this . renderButtons ( ) ;
126126
127+ // Saved status
128+ this . renderSavedStatus ( ) ;
129+
127130 // Properties Form
128131 this . renderPropertiesForm ( ) ;
129132
@@ -209,6 +212,10 @@ WireIt.WiringEditor.prototype = {
209212 parentEl : YAHOO . util . Dom . get ( 'propertiesForm' ) ,
210213 fields : this . options . propertiesFields
211214 } ) ;
215+
216+ this . propertiesForm . updatedEvt . subscribe ( function ( ) {
217+ this . markUnsaved ( ) ;
218+ } , this , true ) ;
212219 } ,
213220
214221 /**
@@ -286,6 +293,15 @@ WireIt.WiringEditor.prototype = {
286293 helpButton . on ( "click" , this . onHelp , this , true ) ;
287294 } ,
288295
296+ /**
297+ * @method renderSavedStatus
298+ */
299+ renderSavedStatus : function ( ) {
300+ var top = Dom . get ( 'top' ) ;
301+ this . savedStatusEl = WireIt . cn ( 'div' , { className : 'savedStatus' , title : 'Not saved' } , { display : 'none' } , "*" ) ;
302+ top . appendChild ( this . savedStatusEl ) ;
303+ } ,
304+
289305 /**
290306 * save the current module
291307 * @method saveModule
@@ -315,17 +331,17 @@ WireIt.WiringEditor.prototype = {
315331 */
316332 saveModuleSuccess : function ( o ) {
317333
318- this . alert ( "Saved !" ) ;
334+ this . markSaved ( ) ;
319335
320- //console.log( this.tempSavedWiring );
321- var name = this . tempSavedWiring . name ;
322-
336+ this . alert ( "Saved !" ) ;
337+
338+ /*var name = this.tempSavedWiring.name;
323339 if(this.modulesByName.hasOwnProperty(name) ) {
324340 //console.log("already exists !");
325341 }
326342 else {
327343 //console.log("new one !");
328- }
344+ }*/
329345
330346 } ,
331347
@@ -358,7 +374,10 @@ WireIt.WiringEditor.prototype = {
358374 this . preventLayerChangedEvent = true ;
359375
360376 this . layer . clear ( ) ;
361- this . propertiesForm . clear ( ) ;
377+
378+ this . propertiesForm . clear ( false ) ; // false to tell inputEx to NOT send the updatedEvt
379+
380+ this . markSaved ( ) ;
362381
363382 this . preventLayerChangedEvent = false ;
364383 } ,
@@ -547,7 +566,7 @@ WireIt.WiringEditor.prototype = {
547566 // TODO: check if current wiring is saved...
548567 this . layer . clear ( ) ;
549568
550- this . propertiesForm . setValue ( wiring . properties ) ;
569+ this . propertiesForm . setValue ( wiring . properties , false ) ; // the false tells inputEx to NOT fire the updatedEvt
551570
552571 if ( lang . isArray ( wiring . modules ) ) {
553572
@@ -576,8 +595,9 @@ WireIt.WiringEditor.prototype = {
576595 }
577596 }
578597
579-
580- this . preventLayerChangedEvent = true ;
598+ this . markSaved ( ) ;
599+
600+ this . preventLayerChangedEvent = false ;
581601
582602 }
583603 catch ( ex ) {
@@ -606,20 +626,18 @@ WireIt.WiringEditor.prototype = {
606626 } , this , true ) ;
607627 } ,
608628
609-
610629 onLayerChanged : function ( ) {
611630 if ( ! this . preventLayerChangedEvent ) {
612- //console.log("layer changed !");
613631 this . markUnsaved ( ) ;
614632 }
615633 } ,
616634
617635 markSaved : function ( ) {
618-
636+ this . savedStatusEl . style . display = 'none' ;
619637 } ,
620638
621639 markUnsaved : function ( ) {
622-
640+ this . savedStatusEl . style . display = '' ;
623641 } ,
624642
625643
0 commit comments