window.VTO = window.VTO || { }; angular.module('VTO', ['ngResource', 'ngAnimate', 'ngLocale', 'ui.bootstrap', 'toggle-switch', 'hl.sticky']) .constant('settings', VTO.Settings) .provider('themeSettings', function () { function ThemeSettings(a) { this.listingPageTruncateDescription = a; } var listingPageTruncateDescription = false; this.listingPageTruncateDescription = function (value) { listingPageTruncateDescription = !!value; }; this.$get = function () { return new ThemeSettings(listingPageTruncateDescription); }; }) .config(['settings', '$locationProvider', function (settings, $locationProvider) { /* Responsive visibility and dpi */ settings.IsSize = { XS: function() { return $('#visibleXS').is(":visible"); }, SM: function() { return $('#visibleSM').is(":visible"); }, MD: function() { return $('#visibleMD').is(":visible"); }, LG: function() { return $('#visibleLG').is(":visible"); }, XLG: function () { return $('#visibleXLG').is(":visible"); } }; settings.PixelRatio = 1; if ($("#visible3dpi").is(":visible")) { settings.PixelRatio = 3; } else if ($("#visible2dpi").is(":visible")) { settings.PixelRatio = 2; } else if ($("#visible15dpi").is(":visible")) { settings.PixelRatio = 1.5; } //Location $locationProvider.html5Mode(false); $locationProvider.hashPrefix('!'); //Map BaseTool.Maps.Localize.setLang(settings.Lang); BaseTool.Maps.Constants.BaseToolMediaUrl = settings.BasetoolMediaUrl; //Local storage enabled? settings.localStorageEnabled = false; try { if (localStorage) { localStorage.setItem('m2b.vto.test', 1); localStorage.removeItem('m2b.vto.test'); settings.localStorageEnabled = true; } } catch (e) {} }]) .run(['$rootScope', 'favourites', 'settings', 'facebook', function ($rootScope, favourites, settings, facebook) { //Make the favourites service global $rootScope.favourites = favourites; $rootScope.translate = window.Translate; //Broadcast breakpoints var breakPoints = [1170, 960, 606, 0]; var breakPointMax = [-1, 1169, 959, 606]; $(window).setBreakpoints({ distinct: true, breakpoints: breakPoints }); $rootScope.preventBreakpointReload = false; angular.forEach(breakPoints, function (w) { $(window).bind('enterBreakpoint' + w, $.debounce(1000, function (e) { //Send breakpoint event $rootScope.$broadcast('breakpoint', { 'event': 'enter', size: w, max: breakPointMax[breakPoints.indexOf(w)] }); //Reload page on breakpoint change if (!$rootScope.preventBreakpointReload) { window.location.reload(false); } })); }); settings.GetSize = function () { var w = $(window).width(); for (var i = 0; i < breakPoints.length; i++) { if (w >= breakPoints[i]) { return { size: breakPoints[i], max: breakPointMax[i] }; } }; return { size: 0, max: 606 }; }; //Facebook init if (!window.FB) { window.fbAsyncInit = function () { facebook.init(); }; } else { facebook.init(); } //New window info on target="_blank"-links var htmlBlankWinArrow = ''; $("a[target='_blank']").each(function () { var txt = $(this).attr("aria-label") || ""; if (txt.length == 0) { txt = $(this).text(); } if (txt.length == 0) { txt = $(this).attr("title"); } $(this).attr("aria-label", txt + " (" + window.Translate.NewWindow + ")"); if (!$(this).is(":empty")) { var appendTo = $(this); if ($(this).children().length > 0) { appendTo = $(this).children().last(); } if (appendTo.prop("tagName") == "br") { appendTo.prepend(htmlBlankWinArrow); } else { appendTo.append(htmlBlankWinArrow); } } }); //Photographer var imgTimer = null; $("body").on("mouseover", "[data-copyright]", function (e) { var img = $(this); var copyright = img.data("copyright"); if (copyright.length > 0) { imgTimer = setTimeout(function () { var offset = img.offset(); var top = offset.top + img.outerHeight() - 24; if (img.data("copyright-pos") == "top") { top = offset.top; } $("
") .addClass("dynamicByline") .css({ width: img.width(), left: offset.left, top: top, display: 'none' }) .text(copyright) .appendTo("body") .fadeIn() .mouseout(function () { $(this).remove(); }); }, 900); } }); $("body").on("mouseout", "[data-copyright]", function (e) { if (imgTimer != null) { clearTimeout(imgTimer); } if (!e.relatedTarget || e.relatedTarget == null || !$(e.relatedTarget).hasClass("dynamicByline")) { $(".dynamicByline").remove(); } }); }]) .animation('.ts-slide', function () { return { elementHeight: -1, beforeAddClass: function (element, className, done) { if (className == "ng-hide") { this.elementHeight = element.height(); element.animate({ height: 0 }, done); } }, removeClass: function (element, className, done) { if (className == "ng-hide") { if (typeof (this.elementHeight) == "undefined") { this.elementHeight = element.height(); } var scope = this; element.css("height", 0).animate({ height: this.elementHeight }, { easing: 'easeInQuad', duration: 600, done: function () { $(this).css("height", "auto"); done.apply(scope); } }); } } } });