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
                });
17
 
18
                // hide the spinner bar on rounte change success(after the content loaded)
19
                $rootScope.$on('$stateChangeSuccess', function() {
20
                    element.addClass('hide'); // hide spinner bar
21
                    $('body').removeClass('page-on-load'); // remove page loading indicator
22
                    Layout.setSidebarMenuActiveLink('match'); // activate selected link in the sidebar menu
23
 
24
                    // auto scorll to page top
25
                    setTimeout(function () {
26
                        Metronic.scrollTop(); // scroll to the top on content load
27
                    }, $rootScope.settings.layout.pageAutoScrollOnLoad);                    
28
                });
29
 
30
                // handle errors
31
                $rootScope.$on('$stateNotFound', function() {
32
                    element.addClass('hide'); // hide spinner bar
33
                });
34
 
35
                // handle errors
36
                $rootScope.$on('$stateChangeError', function() {
37
                    element.addClass('hide'); // hide spinner bar
38
                });
39
            }
40
        };
41
    }
42
])
43
 
44
// Handle global LINK click
45
MetronicApp.directive('a',
46
    function() {
47
        return {
48
            restrict: 'E',
49
            link: function(scope, elem, attrs) {
50
                if (attrs.ngClick || attrs.href === '' || attrs.href === '#') {
51
                    elem.on('click', function(e) {
52
                        e.preventDefault(); // prevent link click for above criteria
53
                    });
54
                }
55
            }
56
        };
57
    });
58
 
59
// Handle Dropdown Hover Plugin Integration
60
MetronicApp.directive('dropdownMenuHover', function () {
61
  return {
62
    link: function (scope, elem) {
63
      elem.dropdownHover();
64
    }
65
  };  
66
});