[Wikiwyg-dev] Switch mode only if different



Hi,

I would like to send a very little fix but it'sis important for my configuration.

When you are in edit mode the user is allowed to switch mode. But if the user click on the same mode that he is editing the entire algorithm is executed. So, if the mode to switch is the same than the current mode it's not necessary to convert.

That's why I've changed In wikiwyg.js : proto.switchMode :

--------------------------------------------------------------
proto.switchMode = function(new_mode_key) {
   var new_mode = this.mode_objects[new_mode_key];
   var old_mode = this.current_mode;

   if (old_mode == new_mode )
     return;

   var self = this;
   new_mode.enableStarted();
   old_mode.disableStarted();
   old_mode.toHtml(
       function(html) {
           self.previous_mode = old_mode;
           new_mode.fromHtml(html);
           old_mode.disableThis();
           new_mode.enableThis();
           new_mode.enableFinished();
           old_mode.disableFinished();
           self.current_mode = new_mode;
       }
   );
}

--------------------------------------------------------------


I've added  :

if (old_mode == new_mode )
     return;


 I hope it will be useful.


Cheers.

Jean-Nicolas.





This archive was generated by a fusion of Pipermail (Mailman edition) and MHonArc.