CLTracker / CLT-webapp

Other
6 stars 1 forks source link

Menu should use Angular2 concepts instead of JQuery #9

Open Syntaf opened 7 years ago

Syntaf commented 7 years ago

The template used for the site is built off html5 & JQuery, so we should adapt certain features to use Angular2 instead of JQuery where possible. The menu currently has this logic:

    $menu
      .appendTo($body)
      .on('click', function(event) {
        // prevent element from bubbling up propagation tree
        event.stopPropagation();
        // hide
        $menu._hide();
      })
      .find('.inner')
      .on('click', '.close', function(event) {
        // stop all dat propagation
        event.preventDefault();
        event.stopPropagation();
        event.stopImmediatePropagation();
        // hide
        $menu._hide();
      })
      .on('click', function(event) {
        // we really hate propagation if you haven't noticed
        event.stopPropagation();
      })
      .on('click', 'a', function(event) {
        // TODO use angular router here instead of jquery href
        if ($(this).attr('href')) {

          let href = $(this).attr('href');

          event.preventDefault();
          event.stopPropagation();

          // hide
          $menu._hide();

          // redirect
          window.setTimeout(function() {
            window.location.href = href;
          }, 350);
        }
      });

This logic should be phased in favor of the Angular2 Router