function ItemPickerOverlay($scope, localizationService) {

    function onInit() {
        $scope.model.hideSubmitButton = true;

        if (!$scope.model.title) {
            localizationService.localize("defaultdialogs_selectItem").then(function(value){
                $scope.model.title = value;
            });
        }

        if (!$scope.model.orderBy) {
            $scope.model.orderBy = "name";
        }
    }

    $scope.selectItem = function(item) {
        $scope.model.selectedItem = item;
        $scope.submitForm($scope.model);
    };

    $scope.tooltip = {
        show: false,
        event: null
    };

    $scope.showTooltip = function(item, $event) {
        if (!item.tooltip) {
            $scope.mouseLeave();
            return;
        }
        $scope.tooltip = {
            show: true,
            event: $event,
            text: item.tooltip
        };
    }

    $scope.hideTooltip = function () {
        $scope.tooltip = {
            show: false,
            event: null,
            text: null
        };
    }

    onInit();

}

angular.module("umbraco").controller("Umbraco.Overlays.ItemPickerOverlay", ItemPickerOverlay);

function ItemPickerOverlay($scope, localizationService) {

    function onInit() {
        $scope.model.hideSubmitButton = true;

        if (!$scope.model.title) {
            localizationService.localize("defaultdialogs_selectItem").then(function(value){
                $scope.model.title = value;
            });
        }

        if (!$scope.model.orderBy) {
            $scope.model.orderBy = "name";
        }
    }

    $scope.selectItem = function(item) {
        $scope.model.selectedItem = item;
        $scope.submitForm($scope.model);
    };

    $scope.tooltip = {
        show: false,
        event: null
    };

    $scope.showTooltip = function(item, $event) {
        if (!item.tooltip) {
            if($scope.mouseLeave) {
                $scope.mouseLeave();
            }
            return;
        }
        $scope.tooltip = {
            show: true,
            event: $event,
            text: item.tooltip
        };
    }

    $scope.hideTooltip = function () {
        $scope.tooltip = {
            show: false,
            event: null,
            text: null
        };
    }

    onInit();

}

angular.module("umbraco").controller("Umbraco.Overlays.ItemPickerOverlay", ItemPickerOverlay);

fix js issue appearing when mouseLeave is undefined.