$(function () { 'use strict'; /* --------------------------------------------------------------------------- */ /* Flex Slider /* --------------------------------------------------------------------------- */ (function () { $('.flexslider').flexslider({ animation: 'fade', //String: Select your animation type, 'fade' or 'slide' slideDirection: 'horizontal', //String: Select the sliding direction, 'horizontal' or 'vertical' slideshow: true, //Boolean: Animate slider automatically slideshowSpeed: 3000, //Integer: Set the speed of the slideshow cycling, in milliseconds animationDuration: 600, //Integer: Set the speed of animations, in milliseconds directionNav: true, //Boolean: Create navigation for previous/next navigation? (true/false) controlNav: true, //Boolean: Create navigation for paging control of each clide? Note: Leave true for manualControls usage keyboardNav: true, //Boolean: Allow slider navigating via keyboard left/right keys mousewheel: false, //Boolean: Allow slider navigating via mousewheel prevText: '', //String: Set the text for the 'previous' directionNav item nextText: '', //String: Set the text for the 'next' directionNav item pausePlay: false, //Boolean: Create pause/play dynamic element pauseText: '', //String: Set the text for the 'pause' pausePlay item playText: 'Play', //String: Set the text for the 'play' pausePlay item randomize: false, //Boolean: Randomize slide order slideToStart: 0, //Integer: The slide that the slider should start on. Array notation (0 = first slide) animationLoop: true, //Boolean: Should the animation loop? If false, directionNav will received 'disable' classes at either end pauseOnAction: true, //Boolean: Pause the slideshow when interacting with control elements, highly recommended. pauseOnHover: false, //Boolean: Pause the slideshow when hovering over slider, then resume when no longer hovering controlsContainer: '', //Selector: Declare which container the navigation elements should be appended too. Default container is the flexSlider element. Example use would be '.flexslider-container', '#container', etc. If the given element is not found, the default action will be taken. manualControls: '', //Selector: Declare custom control navigation. Example would be '.flex-control-nav li' or '#tabs-nav li img', etc. The number of elements in your controlNav should match the number of slides/tabs. start: function () { }, //Callback: function(slider) - Fires when the slider loads the first slide before: function () { }, //Callback: function(slider) - Fires asynchronously with each slider animation after: function () { }, //Callback: function(slider) - Fires after each slider animation completes end: function () { } //Callback: function(slider) - Fires when the slider reaches the last slide (asynchronous) }); })(); /* --------------------------------------------------------------------------- */ /* Info slider /* --------------------------------------------------------------------------- */ (function () { var $slideWrap = $('.info-slide-wrapper'), scrollSlider = $slideWrap.position().left - $('.info-slide-item').outerWidth(); setInterval(function () { $slideWrap.animate({left: scrollSlider}, 500, function () { $slideWrap .find('.info-slide-item:first') .appendTo($slideWrap) .parent() .css({'left': 0}); }); }, 6000); })(); /* ---------------------------------------------------------------------- */ /* Easytabs /* ---------------------------------------------------------------------- */ (function () { // Run easytabs $('#content-wrapper').easytabs({ animate: true, updateHash: true, transitionIn: 'slideDown', transitionOut: 'slideUp', animationSpeed: 600, tabs: '.tab', tabActiveClass: 'active' }); })(); /* ---------------------------------------------------------------------- */ /* Logo, Slider and audio /* ---------------------------------------------------------------------- */ (function () { // Needed variables var $logo = $('#logo'), $slider = $('.slider-wrapper'), audio = document.getElementsByTagName('audio')[0]; $('.tab-notmain').click(function () { $logo.fadeIn('slow'); $slider.slideUp(500); }); $('.tab-main').click(function () { $logo.fadeOut('slow'); $slider.delay(1000).slideDown(500); }); // Audio $('.tab').click(function () { audio.play(); }); })(); /* ---------------------------------------------------------------------- */ /* Portfolio /* ---------------------------------------------------------------------- */ (function () { // Needed variables var $container = $('#portfolio-content'), $filter = $('#portfolio-filter'); if (document.location.hash.substr(1) === 'portfolio') { $container.isotope(); } else { $(window).hashchange(function () { if (document.location.hash.substr(1) === 'portfolio') { $container.isotope(); } }); } $container.imagesLoaded(function () { $container.isotope({ filter: '*', layoutMode: 'masonry', animationOptions: { duration: 750, easing: 'linear' } }); }); // Isotope Filter $filter.find('a').click(function () { var selector = $(this).attr('data-filter'); $container.isotope({ filter: selector, animationOptions: { duration: 750, easing: 'linear', queue: false } }); return false; }); // Copy categories to item classes $filter.find('a').click(function () { $filter.find('a').removeClass('current'); $(this).addClass('current'); }); })(); /* ---------------------------------------------------------------------- */ /* Fancybox /* ---------------------------------------------------------------------- */ (function () { $("a#thumb").fancybox(); $('.fancybox').fancybox(); $('.fancybox-media').fancybox({ openEffect: 'fade', closeEffect: 'fade', helpers: { media: {} } }); })(); /* ---------------------------------------------------------------------- */ /* Modernizr Check csstransforms3d /* ---------------------------------------------------------------------- */ (function(){ Modernizr.load({ test: Modernizr.csstransforms3d && Modernizr.csstransitions, yep : 'js/jquery.hoverfold.js', nope: 'css/fallback-portfolio.css', callback : function( url, result, key ) { if( url === 'js/jquery.hoverfold.js' ) { $( '#portfolio-content' ).hoverfold(); } } }); })(); /* --------------------------------------------------------------------------- */ /* In-Field Labels /* --------------------------------------------------------------------------- */ (function () { $('.flabel').inFieldLabels(); })(); /* --------------------------------------------------------------------------- */ /* Google Maps /* --------------------------------------------------------------------------- */ (function () { if (document.location.hash.substr(1) === 'contacts-live') { console.log('call'); initGmap(); $('#content-wrapper').easytabs('select', '#contacts'); $('#content-wrapper').bind('easytabs:after', function() { window.location.hash = 'contacts-live'; $('.pan:nth-child(2)').trigger('click'); // activate tab2 (life location) $('input[name="autoupdate"]').attr('checked','checked'); // turn auto update on var timer = $.timer(function() { updateLastLocation(); }); var chk = $("#autoupdate:input"); timer.set({ time : 4000, autostart : chk.is(":checked") }); }); } if (document.location.hash.substr(1) === 'contacts') { initGmap(); } else { $(window).hashchange(function () { if (document.location.hash.substr(1) === 'contacts') { initGmap(); } }); } // Initialize Gmap function initGmap() { var position = new google.maps.LatLng(13.83305, 100.65066); $('#map').gmap3({ map: { options: { center: position, zoom: 15, } }, marker: { values: [ {latLng: position}, {latLng: [13, 100],id : "p3",options:{visible:true, icon: 'images/gmap_infoicons_facebook.png'}},{latLng: [113.83305, 100.65066],id : "p1",options:{visible:true, icon: 'images/gmap_infoicons.png'}}, // my Car (dynamic, permanently reloaded) {latLng: [13.83305, 100.65066],id : "p2",options:{visible:false}} // Office (static) ], options: { draggable: false, icon: 'images/gmap_infoicons_hover.png' } } }); } // Pan map $('.pan').click(function () { if($(this).data("livelocation")){ liveLocation = true; updateLastLocation(); } else { liveLocation = false; var lat = $(this).data('lat'), lng = $(this).data('lng'); $('#map').gmap3('get').panTo(new google.maps.LatLng(lat, lng)); } $('.map-pan').find('div').removeClass('pan-active'); $(this).addClass('pan-active'); }); })(); }); var liveLocation = true; function getHomeData() { $.getJSON("scripts/vera/publicStatus.php", function(dtb) { $("#connection").html(dtb.connection ); $("#v63s").html(dtb.v63s ); $("#v60s76p").html(dtb.v60s76p ); // Kitchen Light and Temp $("#v186s").html(dtb.v186s ); // back light $("#v16s").html(dtb.v16s ); // daynight $("#v57s").html(dtb.v57s ); // geofence $("#v112d").html(dtb.v112d ); // tv licht $("#v74d").html(dtb.v74d ); // dining $("#v72p").html(dtb.v72p ); // hifi power $("#v71p").html(dtb.v71p ); // kueche plug $("#v206d").html(dtb.v206d ); // treppe licht $("#v125d").html(dtb.v125d ); // Office licht $("#v124d").html(dtb.v124d ); // Sofa licht $("#v109d").html(dtb.v109d ); // TV Bed $("#v110d").html(dtb.v110d ); // Darcy PC $("#v108d").html(dtb.v108d ); // UVO (imac) $("#v101s85d").html(dtb.v101s85d ); // Office Combo $("#v26s").html(dtb.v26s ); // Weather $("#v130s132s").html(dtb.v130s132s ); // Fan Unten $("#v137d").html(dtb.v137d ); // RGB Unten $("#v14s").html(dtb.v14s ); // XBMC Status $("#v175s").html(dtb.v175s ); // Courtain $("#vacoffice").html(dtb.vacoffice ); // Aircon Office $("#vacunten").html(dtb.vacunten ); // Aircon unten $("#v188s").html(dtb.v188s ); // Front Gate $("#v253s").html(dtb.v253s ); // Grid Power }).fail(function(f){ //alert("Failed to get data, please reload page.."); }); } function updateLastLocation() { var pan = $(".pan[livelocation]"); $.getJSON("scripts/ThaiGps/loc.php", function(dt) { var lat = dt.lat; var lng = dt.lon; pan.attr("data-lat",lat); pan.attr("data-lng",lng); var p1 = $('#map').gmap3({get :{id:"p1"}}); var latlng = new google.maps.LatLng(lat, lng); p1.setPosition(latlng); p1.setVisible(true); p1.setIcon("images/map/" + dt.iconfileName); $("#lastlocationinfo").html(dt.headingtext + " (" + dt.ago + ")" ); if(liveLocation) { $('#map').gmap3('get').panTo(new google.maps.LatLng(lat, lng)); } }).fail(function(f){ //alert("json failed"); }); } $(document).ready(getHomeData()); $(document).ready(function() { var timer = $.timer(function() { updateLastLocation(); }); var chk = $("#autoupdate:input"); timer.set({ time : 4000, autostart : chk.is(":checked") }); //updateLastLocation(); chk.change(function(){ if(chk.is(":checked")) { timer.play(); } else { timer.stop(); } }); });