Subversion Repositories Integrator Subversion

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 espaco 1
/***
2
GLobal Directives
3
***/
4
 
5
// Route State Load Spinner(used on page or content load)
6
MetronicApp.directive('ngSpinnerBar', ['$rootScope',
7
    function($rootScope) {
8
        return {
9
            link: function(scope, element, attrs) {
10
                // by defult hide the spinner bar
11
                element.addClass('hide'); // hide spinner bar by default
12
 
13
                // display the spinner bar whenever the route changes(the content part started loading)
14
                $rootScope.$on('$stateChangeStart', function() {
15
                    element.removeClass('hide'); // show spinner bar
16
                    Layout.closeMainMenu();
17
                });
18
 
19
                // hide the spinner bar on rounte change success(after the content loaded)
20
                $rootScope.$on('$stateChangeSuccess', function() {
21
                    element.addClass('hide'); // hide spinner bar
22
                    $('body').removeClass('page-on-load'); // remove page loading indicator
23
                    Layout.setMainMenuActiveLink('match'); // activate selected link in the sidebar menu
24
 
25
                    // auto scorll to page top
26
                    setTimeout(function () {
27
                        Metronic.scrollTop(); // scroll to the top on content load
28
                    }, $rootScope.settings.layout.pageAutoScrollOnLoad);                    
29
                });
30
 
31
                // handle errors
32
                $rootScope.$on('$stateNotFound', function() {
33
                    element.addClass('hide'); // hide spinner bar
34
                });
35
 
36
                // handle errors
37
                $rootScope.$on('$stateChangeError', function() {
38
                    element.addClass('hide'); // hide spinner bar
39
                });
40
            }
41
        };
42
    }
43
])
44
 
45
// Handle global LINK click
46
MetronicApp.directive('a',
47
    function() {
48
        return {
49
            restrict: 'E',
50
            link: function(scope, elem, attrs) {
51
                if (attrs.ngClick || attrs.href === '' || attrs.href === '#') {
52
                    elem.on('click', function(e) {
53
                        e.preventDefault(); // prevent link click for above criteria
54
                    });
55
                }
56
            }
57
        };
58
    });
59
 
60
// Handle Dropdown Hover Plugin Integration
61
MetronicApp.directive('dropdownMenuHover', function () {
62
  return {
63
    link: function (scope, elem) {
64
      elem.dropdownHover();
65
    }
66
  };  
67
});