/*
 * dropdownToggle - Provides dropdown menu functionality in place of bootstrap js
 * @restrict class or attribute
 * @example:
   <li class="dropdown">
     <a class="dropdown-toggle">My Dropdown Menu</a>
     <ul class="dropdown-menu">
       <li ng-repeat="choice in dropChoices">
         <a ng-href="{{choice.href}}">{{choice.text}}</a>
       </li>
     </ul>
   </li>
 */

angular.module('ui.bootstrap.dropdownToggle', []).directive('dropdownToggle',
  ['$document', '$location', '$window', function ($document, $location, $window) {
  var openElement = null,
      closeMenu   = angular.noop;
  return {
    restrict: 'CA',
    link: function(scope, element, attrs) {
      scope.$watch('$location.path', function() { closeMenu(); });
      element.parent().bind('click', function() { closeMenu(); });
      element.bind('click', function(event) {
        event.preventDefault();
        event.stopPropagation();
        var elementWasOpen = (element === openElement);
        if (!!openElement) {
          closeMenu(); }
        if (!elementWasOpen){
          element.parent().addClass('open');
          openElement = element;
          closeMenu = function (event) {
            if (event) {
              event.preventDefault();
              event.stopPropagation();
            }
            $document.unbind('click', closeMenu);
            element.parent().removeClass('open');
            closeMenu   = angular.noop;
            openElement = null;
          };
          $document.bind('click', closeMenu);
        }
      });
    }
  };
}]);
@@ -452,18 +452,16 @@
 Toggle',
-%0A 
  %5B'$docu
@@ -483,19 +483,8 @@
 on',
- '$window',
  fun
@@ -514,17 +514,8 @@
 tion
-, $window
 ) %7B%0A
@@ -819,16 +819,17 @@
 function
+ 
 (event) 
@@ -822,32 +822,90 @@
 ction (event) %7B%0A
+%0A        var elementWasOpen = (element === openElement);%0A%0A
         event.pr
@@ -957,63 +957,8 @@
 ();%0A
-        var elementWasOpen = (element === openElement);
 %0A   
@@ -1005,19 +1005,28 @@
 eMenu();
+%0A       
  %7D%0A
+%0A
         
@@ -1045,16 +1045,17 @@
 WasOpen)
+ 
 %7B%0A      
@@ -1397,34 +1397,32 @@
       closeMenu 
-  
 = angular.noop;%0A

remove unused variables