@@ -555,14 +555,17 @@ function sepiaFW_build_ui_cards(){
555555 $ ( this ) . on ( 'focusout' , function ( ) {
556556 //update data
557557 var newName = $ ( this ) . text ( ) . trim ( ) ;
558+ var eleData = JSON . parse ( $listEle . attr ( 'data-element' ) ) ;
558559 if ( newName ) {
559- var eleData = JSON . parse ( $listEle . attr ( 'data-element' ) ) ;
560+ newName = ( newName . length > 320 ) ? ( newName . substring ( 0 , 319 ) + "..." ) : newName ; //brutally shorten name - TODO: improve
560561 eleData . name = newName ;
561- $ ( this ) . text ( newName ) ;
562+ $ ( this ) . text ( eleData . name ) ;
562563 $listEle . attr ( 'data-element' , JSON . stringify ( eleData ) ) ;
563564 //activate save button
564565 var $saveBtn = $listBody . parent ( ) . find ( '.sepiaFW-cards-list-saveBtn' ) ; //note: we need to load the button here
565566 $saveBtn . addClass ( 'active' ) ; //saveBtn.css({"opacity": 0.92, "color": saveBtn.parent().css("color")});
567+ } else {
568+ $ ( this ) . text ( eleData . name ) ;
566569 }
567570 } ) ;
568571 $ ( this ) . keypress ( function ( event ) {
@@ -759,24 +762,27 @@ function sepiaFW_build_ui_cards(){
759762 var dataString = $ ( timeEvent ) . attr ( 'data-element' ) ;
760763 if ( dataString ) {
761764 var eleData = JSON . parse ( dataString ) ;
762- var newName = $ ( this ) . html ( ) ;
763- newName = newName . replace ( / < b r > | < d i v > | < \/ d i v > / g, "" ) . trim ( ) ; //happens when the user presses enter(?)
764- newName = newName . replace ( / - | _ | ! | \? | , | \. | ' / g, " " ) . trim ( ) ; //remove some special chars
765- newName = ( newName . length > 100 ) ? newName . substring ( 0 , 99 ) : newName ; //brutally shorten name - TODO: improve
766- eleData . name = newName . trim ( ) ;
767- $ ( this ) . html ( eleData . name ) ;
768- $ ( timeEvent ) . attr ( 'data-element' , JSON . stringify ( eleData ) ) ;
769- //update stored TIMER
770- var Timer = SepiaFW . events . getRunningOrActivatedTimeEventById ( eleData . eventId ) ;
771- if ( Timer ) {
772- eleData . lastChange = new Date ( ) . getTime ( ) ;
773- Timer . data = eleData ;
774- //trigger auto-save
775- SepiaFW . events . scheduleTimeEventsSync ( eleData . eleType ) ;
765+ var newName = $ ( this ) . text ( ) . trim ( ) ;
766+ if ( newName ) {
767+ //newName = newName.replace(/-|_|!|\?|,|\.|'/g, " ").trim(); //remove some special chars (?)
768+ newName = ( newName . length > 100 ) ? ( newName . substring ( 0 , 99 ) + "..." ) : newName ; //brutally shorten name - TODO: improve
769+ eleData . name = newName . trim ( ) ;
770+ $ ( this ) . text ( eleData . name ) ;
771+ $ ( timeEvent ) . attr ( 'data-element' , JSON . stringify ( eleData ) ) ;
772+ //update stored TIMER
773+ var Timer = SepiaFW . events . getRunningOrActivatedTimeEventById ( eleData . eventId ) ;
774+ if ( Timer ) {
775+ eleData . lastChange = new Date ( ) . getTime ( ) ;
776+ Timer . data = eleData ;
777+ //trigger auto-save
778+ SepiaFW . events . scheduleTimeEventsSync ( eleData . eleType ) ;
779+ }
780+ //activate save button
781+ var saveBtn = $ ( this ) . closest ( '.sepiaFW-cards-flexSize-container' ) . find ( '.sepiaFW-cards-list-saveBtn' ) ;
782+ saveBtn . addClass ( 'active' ) ;
783+ } else {
784+ $ ( this ) . text ( eleData . name ) ;
776785 }
777- //activate save button
778- var saveBtn = $ ( this ) . closest ( '.sepiaFW-cards-flexSize-container' ) . find ( '.sepiaFW-cards-list-saveBtn' ) ;
779- saveBtn . addClass ( 'active' ) ;
780786 }
781787 } ) ;
782788 timerEventName . keypress ( function ( event ) {
0 commit comments