Subversion Repositories Integrator Subversion

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 espaco 1
var Layout = function () {
2
    var isMobileDevice = function() {
3
        return  ((
4
            navigator.userAgent.match(/Android/i) ||
5
            navigator.userAgent.match(/BlackBerry/i) ||
6
            navigator.userAgent.match(/iPhone|iPad|iPod/i) ||
7
            navigator.userAgent.match(/Opera Mini/i) ||
8
            navigator.userAgent.match(/IEMobile/i)
9
        ) ? true : false);
10
    }
11
 
12
    var WindowWidth = $(window).width();
13
    var WindowHeight = $(window).height();
14
 
15
    var handleParallax = function () {
16
        $(window).load(function(){
17
            if (isMobileDevice() === false) {
18
                $("#message-block").parallax("50%",0.4);
19
                $("#facts-block").parallax("50%",0.4);
20
            }
21
        });
22
    }
23
 
24
    var handleScrolling = function () {
25
        $(".scroll").on("click", function(event) {
26
            event.preventDefault();//the default action of the event will not be triggered
27
            $("html, body").animate({scrollTop:($("#"+this.href.split("#")[1]).offset().top)}, 600);
28
        });
29
    }
30
 
31
    /* Smooth scrolling and smart navigation when user scrolls on one-page sites */
32
    var handleNavItemCurrent = function () {
33
        $(".header-navigation").onePageNav({
34
            currentClass: "current",
35
            scrollThreshold: 0
36
        });
37
    }
38
 
39
    var handleHeaderPosition = function () {
40
        var CurrentHeaderPosition = $(".header").offset().top;// current header's vertical position
41
 
42
        var headerFix = function(){
43
            var CurrentWindowPosition = $(window).scrollTop();// current vertical position
44
            if (CurrentWindowPosition > CurrentHeaderPosition) {
45
                $(".header").addClass("fixNav");
46
            } else {
47
                $(".header").removeClass("fixNav");
48
            }
49
        };
50
 
51
        headerFix();// call headerFix() when the page was loaded
52
        if (navigator.userAgent.match(/iPhone|iPad|iPod/i)) {
53
            $(window).bind("touchend touchcancel touchleave", function(e){
54
                headerFix();
55
            });
56
        } else {
57
            $(window).scroll(function() {
58
                headerFix();
59
            });
60
        }
61
    }
62
 
63
    var handleGo2Top = function () {      
64
        var Go2TopOperation = function(){
65
            var CurrentWindowPosition = $(window).scrollTop();// current vertical position
66
            if (CurrentWindowPosition > 300) {
67
                $(".go2top").show();
68
            } else {
69
                $(".go2top").hide();
70
            }
71
        };
72
 
73
        Go2TopOperation();// call headerFix() when the page was loaded
74
        if (navigator.userAgent.match(/iPhone|iPad|iPod/i)) {
75
            $(window).bind("touchend touchcancel touchleave", function(e){
76
                Go2TopOperation();
77
            });
78
        } else {
79
            $(window).scroll(function() {
80
                Go2TopOperation();
81
            });
82
        }
83
    }
84
 
85
    function handleBootstrap() {
86
        $(".carousel").carousel({
87
            interval: 15000,
88
            pause: "hover"
89
        });
90
        $(".tooltips").tooltip();
91
        $(".popovers").popover();
92
    }
93
 
94
    function handleCounter() {
95
        /*$('.counter').counterUp({
96
            delay: 10,
97
            time: 1000
98
        });*/
99
    }
100
 
101
    var handlePortfolioSorting = function () {
102
        /*$(".sorting-grid").mixitup();*/
103
    }
104
 
105
    var handleFancybox = function () {
106
        if (!jQuery.fancybox) {
107
            return;
108
        }
109
        $(".zoom").fancybox();
110
    }
111
 
112
    var handleMobiToggler = function () {
113
        $(".mobi-toggler").on("click", function(event) {
114
            event.preventDefault();//the default action of the event will not be triggered
115
 
116
            $(".header").toggleClass("menuOpened");
117
            $(".header").find(".header-navigation").toggle(300);            
118
        });
119
 
120
        function SlideUpMenu () {
121
            $(".header-navigation a").on("click", function(event) {
122
                if ($(window).width()<1024) {
123
                    event.preventDefault();//the default action of the event will not be triggered
124
                    $(".header-navigation").slideUp(100);
125
                    $(".header").removeClass("menuOpened");
126
                }
127
            });
128
            $(window).scroll(function() {
129
                if (($(window).width()>480)&&($(window).width()<1024)) {
130
                    $(".header-navigation").slideUp(100);
131
                    $(".header").removeClass("menuOpened");
132
                }
133
            });
134
        }
135
        SlideUpMenu();
136
        $(window).resize(function() {
137
            SlideUpMenu();
138
        });
139
    }
140
 
141
    var handleTwitter = function () {
142
        !function(d,s,id){
143
            var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}
144
        }(document,"script","twitter-wjs");
145
    }  
146
 
147
    function valignCenterMessageFunction () {
148
         MessageCurrentElemHeight = $(".message-block .valign-center-elem").height();
149
 
150
        $(".message-block .valign-center-elem").css("position", "absolute")
151
            .css ("top", "50%")
152
            .css ("margin-top", "-"+MessageCurrentElemHeight/2+"px")
153
            .css ("width", "100%")
154
            .css ("height", MessageCurrentElemHeight);
155
    }
156
 
157
    function valignCenterPortfolioFunction () {
158
         PortfolioCurrentElemHeight = $(".portfolio-block .valign-center-elem").height();
159
 
160
        $(".portfolio-block .valign-center-elem").css("position", "absolute")
161
            .css ("top", "50%")
162
            .css ("margin-top", "-"+PortfolioCurrentElemHeight/2+"px")
163
            .css ("width", "100%")
164
            .css ("height", PortfolioCurrentElemHeight);
165
    }
166
 
167
    var valignCenterMessage = function () {
168
        valignCenterMessageFunction();
169
        $(window).resize(function() {
170
            valignCenterMessageFunction();
171
        });
172
    }
173
    var valignCenterPortfolio = function () {
174
        valignCenterPortfolioFunction();
175
        $(window).resize(function() {
176
            valignCenterPortfolioFunction();
177
        });
178
    }
179
 
180
    var handleTheme = function () {
181
 
182
        var panel = $('.color-panel');
183
 
184
        // handle theme colors
185
        var setColor = function (color) {
186
            $('#style-color').attr("href", "../../assets/frontend/onepage/css/themes/" + color + ".css");
187
            $('.site-logo img').attr("src", "../../assets/frontend/onepage/img/logo/" + color + ".png");
188
        }
189
 
190
        $('.icon-color', panel).click(function () {
191
            $('.color-mode').show();
192
            $('.icon-color-close').show();
193
        });
194
 
195
        $('.icon-color-close', panel).click(function () {
196
            $('.color-mode').hide();
197
            $('.icon-color-close').hide();
198
        });
199
 
200
        $('li', panel).click(function () {
201
            var color = $(this).attr("data-style");
202
            setColor(color);
203
            $('.inline li', panel).removeClass("current");
204
            $(this).addClass("current");
205
        });
206
 
207
        $('.color-panel .menu-pos').change(function(){
208
            if ($(this).val() == "top") {
209
                $('body').addClass("menu-always-on-top");
210
            } else {
211
                $('body').removeClass("menu-always-on-top");
212
            }
213
        });
214
    }
215
 
216
    return {
217
        init: function () {
218
            //handlePromoBlock();
219
            handleParallax();
220
            handleScrolling();
221
            handleNavItemCurrent();
222
            handleHeaderPosition();
223
            handleBootstrap();
224
            handleCounter();
225
            handleGo2Top();
226
            handlePortfolioSorting();
227
            handleFancybox();
228
            handleMobiToggler();
229
            handleTwitter();
230
            valignCenterMessage();
231
            valignCenterPortfolio();
232
            handleTheme();
233
        },
234
    };
235
}();