'use strict';
define(function() {
  var toolbarquickfilter = function(SelectManager) {
    return {
      templateUrl:
        'js/XG/widgets/mapapp/quickfilter/views/toolbarquickfilter.html',
      restrict: 'A',

      link: function(scope, element, attrs, ctrl) {
        var m = scope.map;
        var cf = scope.config;
        var btnElt = $(element.children()[0]);
        btnElt.bind('click', function() {
          SelectManager.clear();
          SelectManager.closepop();

          if (scope.isActive) {
            btnElt.removeClass('btn-info');
            btnElt.addClass('btn-default');
            scope.isActive = false;
          } else {
            btnElt.removeClass('btn-default');
            btnElt.addClass('btn-info');
            scope.isActive = true;
          }
        });
        scope.$on('closeToolsBar_toolbarquickfilter', function() {
          if (scope.isActive) $('#toolbar_quickfilter_popover').click();
          btnElt.removeClass('btn-info');
          btnElt.addClass('btn-default');
          scope.isActive = false;
        });
        // alert (m);
        /*element.bind("click", function(){

                    //alert(m);
                   scope.addtools({title: "Fond de Plan ", name: "Base Map" ,directive:"quickfilterwidget"});
                   scope.$apply(scope);
                   
                });*/
      },
    };
  };

  toolbarquickfilter.$inject = ['SelectManager'];
  return toolbarquickfilter;
});
