On Mon, May 12, 2014 at 4:15 PM, p-march <notifications@github.com> wrote:

> In js/delete_all_behavior_overlay.js:
>
> > +  'use strict';
> > +
> > +/** const */ var AppsDevTool = apps_dev_tool.AppsDevTool;
> > +
> > +  /**
> > +   * DeleteAllBehaviorOverlay class
> > +   * Encapsulated handling of the 'Delete All Behavior History' overlay page.
> > +   * @constructor
> > +   */
> > +  function DeleteAllBehaviorOverlay() {}
> > +
> > +  cr.addSingletonGetter(DeleteAllBehaviorOverlay);
> > +
> > +  DeleteAllBehaviorOverlay.prototype = {
> > +    initializePage: function() {
> > +      var overlay = $('overlay');
>
> I've looked into this issue. I do not see how can we reuse code without
> introducing complexity. What I can reuse is this:
>
> var overlay = $('overlay');
> cr.ui.overlay.setupOverlay(overlay);
> cr.ui.overlay.globalInitialization();
>
> I can make it a init function on apps_dev_tool which will initialize stuff
> once and return a ready object on later calls. Does it worth effort?
>

Can we just make sure that the initialization code is only called from a
single location, and not from many locations?  Calling setupOverlay, etc.
multiple times might end up with us registering multiple copies of the the
same onClick handlers--that might not cause a problem in the current code
but I think it is best avoided.  It's not just a matter of a performance
optimization.

--Michael Vrable