Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// <reference path="../../plugins/jquery/jquery-ui-1.10.0.js" />
- /// <reference path="../../plugins/jquery/jquery.transit.js" />
- /// <reference path="../../plugins/jquery/jquery-1.9.0.js" />
- /// <reference path="../../plugins/jquery/jquery.backstretch.js" />
- /// <reference path="../../plugins/customScroll/jquery.mCustomScrollbar.js" />
- /// <reference path="../../plugins/gsap/TweenMax.min.js" />
- TweenMax.ticker.useRAF(false);
- //Helpers
- // Array shuffle
- function shuffle(o) {
- /// <summary>Shuffles any given one dimensional array</summary>
- /// <param name="o" type="Object">One dimensional array</param>
- for (var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
- return o;
- };
- //Global variables
- var key_hole_visiable = $("#key-hole").length, // Get keyhole visibility
- testing_env = $("#key-hole-2").length; // Get underconstruction keyhole visibility
- var under_construction = $("#view-area-2").length; // Get underconstruction view area visibility
- var key_hole = $("#key-hole"); // Key hole DOM element, only visible at start -> "/"
- var sim_bg = $("#simulated-background"); // Simulated bg element
- var main_area = $("#main-area"); // Main area DOM element
- var menu_item = $(".menu-item"); // Menu item collection
- // Menu button array for animation purposes
- var menu_item_array = [menu_item[0],
- [menu_item[1], menu_item[3]],
- [menu_item[2], menu_item[4], menu_item[6], menu_item[9]],
- [menu_item[5], menu_item[7], menu_item[8]],
- menu_item[10]];
- var start_warning_show = true; // Let warning sign apear after time interval, can be changed
- var temp_menuitem_pos = {}; // Stores menu item original position for reset position purpose
- var temp_menuitem_ele = null; // Store temp menu item
- // Layer route button handlers
- var layer_btn_handlers = {
- "animals": function () {
- // Get location
- var getTween = tweens.main_area.layer_buttons;
- // Define button tweens
- var contact = getTween.getTween($(".info", "#animals-contact"), {
- left: 0,
- opacity: 1
- }),
- start_text = getTween.getTween($(".text", "#animals-start"), {
- opacity: 0
- }),
- start_info = getTween.getTween($(".info", "#animals-start"), {
- opacity: 1
- }),
- castle = getTween.getTween($(".info", "#animals-castle"), {
- left: 0,
- opacity: 1
- });
- $("#layers").on("mouseenter", "#animals-contact", function () {
- contact.play();
- }).on("mouseleave", "#animals-contact", function () {
- contact.reverse();
- });
- $("#layers").on("mouseenter", "#animals-start", function () {
- start_info.play();
- start_text.play();
- }).on("mouseleave", "#animals-start", function () {
- start_info.reverse();
- start_text.reverse();
- });
- $("#layers").on("mouseenter", "#animals-castle", function () {
- castle.play();
- }).on("mouseleave", "#animals-castle", function () {
- castle.reverse();
- });
- },
- "dress": function () {
- var getT = tweens.main_area.layer_buttons;
- var animals_info = getT.getTween($(".info", "#dress-animals"), {
- opacity: 1
- }),
- animals_text = getT.getTween($(".text", "#dress-animals"), {
- opacity: 0
- }),
- start_info = getT.getTween($(".info", "#dress-start"),{opacity: 1}),
- start_text = getT.getTween($(".text", "#dress-start"),{opacity: 0}),
- hippy_info = getT.getTween($(".info", "#dress-hippy"),{opacity: 1}),
- hippy_text = getT.getTween($(".text", "#dress-hippy"),{opacity: 0})
- $("#layers").on("mouseenter", "#dress-animals", function () {
- animals_info.play();
- animals_text.play();
- }).on("mouseleave", "#dress-animals", function () {
- animals_info.reverse();
- animals_text.reverse();
- });
- $("#layers").on("mouseenter", "#dress-start", function () {
- start_info.play();
- start_text.play();
- }).on("mouseleave", "#dress-start", function () {
- start_info.reverse();
- start_text.reverse();
- });
- $("#layers").on("mouseenter", "#dress-hippy", function () {
- hippy_info.play();
- hippy_text.play();
- }).on("mouseleave", "#dress-hippy", function () {
- hippy_info.reverse();
- hippy_text.reverse();
- });
- },
- "zuj": function () {
- var g = tweens.main_area.layer_buttons.getTween;
- var information_info = g($(".info", "#zuj-information"),{opacity: 1,top: 56}),
- information_text = g($(".text", "#zuj-information"),{opacity: 0}),
- start_info = g($(".info", "#zuj-start"),{
- opacity: 1,
- left: -82
- }),
- start_text = g($(".text", "#zuj-start"),{opacity: 0}),
- dress_info = g($(".info", "#zuj-dress"),{
- opacity: 1,
- top: -44
- }),
- dress_text = g($(".text", "#zuj-dress"),{
- opacity: 0
- });
- $("#layers").on("mouseenter", "#zuj-information", function () {
- information_info.play();
- information_text.play();
- }).on("mouseleave", "#zuj-information", function () {
- information_info.reverse();
- information_text.reverse();
- });
- $("#layers").on("mouseenter", "#zuj-start", function () {
- start_info.play();
- start_text.play();
- }).on("mouseleave", "#zuj-start", function () {
- start_info.reverse();
- start_text.reverse();
- });
- $("#layers").on("mouseenter", "#zuj-dress", function () {
- dress_info.play();
- dress_text.play();
- }).on("mouseleave", "#zuj-dress", function () {
- dress_info.reverse();
- dress_text.reverse();
- });
- },
- "contact": function () {
- var g = tweens.main_area.layer_buttons.getTween;
- var information_info = g($(".info", "#contact-information"), { opacity: 1, top: 19 }),
- information_text = g($(".text", "#contact-information"), { opacity: 0 }),
- start_info = g($(".info", "#contact-start"), {
- opacity: 1
- }),
- start_text = g($(".text", "#contact-start"), { opacity: 0 });
- $("#layers").on("mouseenter", "#contact-start", function () {
- start_info.play();
- start_text.play();
- }).on("mouseleave", "#contact-start", function () {
- start_info.reverse();
- start_text.reverse();
- });
- $("#layers").on("mouseenter", "#contact-information", function () {
- information_info.play();
- information_text.play();
- }).on("mouseleave", "#contact-information", function () {
- information_info.reverse();
- information_text.reverse();
- });
- },
- "hippy": function () {
- var g = tweens.main_area.layer_buttons.getTween;
- var st_info = g($(".info", "#hippy-start"),{opacity: 1}),
- st_txt = g($(".text", "#hippy-start"),{opacity: 0}),
- cont_info = g($(".info", "#hippy-contact"),{opacity: 1,top: 65}),
- abs_info = g($(".info", "#hippy-abstract"),{opacity: 1, left: -167}),
- abs_text = g($(".text", "#hippy-abstract"),{opacity: 0});
- $("#layers").on("mouseenter", "#hippy-start", function () {
- st_info.play();
- st_txt.play();
- }).on("mouseleave", "#hippy-start", function () {
- st_info.reverse();
- st_txt.reverse();
- });
- $("#layers").on("mouseenter", "#hippy-contact", function () {
- cont_info.play();
- }).on("mouseleave", "#hippy-contact", function () {
- cont_info.reverse();
- });
- $("#layers").on("mouseenter", "#hippy-abstract", function () {
- abs_info.play();
- abs_info.play();
- }).on("mouseleave", "#hippy-abstract", function () {
- abs_info.reverse();
- abs_text.reverse();
- });
- },
- "information": function () {
- var g = tweens.main_area.layer_buttons.getTween;
- var start = g($(".info", "#information-start"),{opacity: 1}),
- ani_info = g($(".info", "#information-animals"), { opacity: 1 }),
- ani_text = g($(".text", "#information-animals"), { opacity: 0 }),
- mas_info = g($(".info", "#information-masks"),{opacity: 1}),
- mas_text = g($(".text", "#information-masks"),{opacity: 0}),
- hippy = g($(".info", "#information-hippy"),{opacity: 1, left: 115});
- $("#layers").on("mouseenter", "#information-start", function () {
- start.play();
- }).on("mouseleave", "#information-start", function () {
- start.reverse();
- });
- $("#layers").on("mouseenter", "#information-animals", function () {
- ani_info.play();
- ani_text.play();
- }).on("mouseleave", "#information-animals", function () {
- ani_info.reverse();
- ani_text.reverse();
- });
- $("#layers").on("mouseenter", "#information-masks", function () {
- mas_info.play();
- mas_text.play();
- }).on("mouseleave", "#information-masks", function () {
- mas_info.reverse();
- mas_text.reverse();
- });
- $("#layers").on("mouseenter", "#information-hippy", function () {
- hippy.play();
- }).on("mouseleave", "#information-hippy", function () {
- hippy.reverse();
- });
- },
- "abstract": function () {
- var g = tweens.main_area.layer_buttons.getTween;
- var information = g($(".info", "#abstract-information"), { opacity: 1, left: 212 }),
- start = g($(".info", "#abstract-start"), { opacity: 1, top: 70 }),
- castle = g($(".info", "#abstract-castle"), { opacity: 1, left: -30 });
- $("#layers").on("mouseenter", "#abstract-information", function () {
- information.play();
- }).on("mouseleave", "#abstract-information", function () {
- information.reverse();
- });
- $("#layers").on("mouseenter", "#abstract-start", function () {
- start.play();
- }).on("mouseleave", "#abstract-start", function () {
- start.reverse();
- });
- $("#layers").on("mouseenter", "#abstract-castle", function () {
- castle.play();
- }).on("mouseleave", "#abstract-castle", function () {
- castle.reverse();
- });
- },
- "masks": function () {
- var g = tweens.main_area.layer_buttons.getTween;
- var st_info = g($(".info", "#masks-start"), { opacity: 1 }),
- st_text = g($(".text", "#masks-start"), { opacity: 0 }),
- mas_info = g($(".info", "#masks-dress"), { opacity: 1 }),
- mas_text = g($(".text", "#masks-dress"), { opacity: 0 }),
- abs = g($(".info", "#masks-abstract"), { opacity: 1, top: 70 });
- $("#layers").on("mouseenter", "#masks-start", function () {
- st_info.play();
- st_text.play();
- }).on("mouseleave", "#masks-start", function () {
- st_info.reverse();
- st_text.reverse();
- });
- $("#layers").on("mouseenter", "#masks-dress", function () {
- mas_info.play();
- mas_text.play();
- }).on("mouseleave", "#masks-dress", function () {
- mas_info.reverse();
- mas_text.reverse();
- });
- $("#layers").on("mouseenter", "#masks-abstract", function () {
- abs.play();
- }).on("mouseleave", "#masks-abstract", function () {
- abs.reverse();
- });
- },
- "castle": function () {
- var g = tweens.main_area.layer_buttons.getTween;
- var start = g($(".info", "#castle-start"), { opacity: 1 }),
- zuj_info = g($(".info", "#castle-zuj"), { opacity: 1 }),
- zuj_text = g($(".text", "#castle-zuj"), { opacity: 0 }),
- mas_info = g($(".info", "#castle-masks"), { opacity: 1 }),
- mas_text = g($(".text", "#castle-masks"), { opacity: 0 });
- $("#layers").on("mouseenter", "#castle-start", function () {
- start.play();
- }).on("mouseleave", "#castle-start", function () {
- start.reverse();
- });
- $("#layers").on("mouseenter", "#castle-zuj", function () {
- zuj_info.play();
- zuj_text.play();
- }).on("mouseleave", "#castle-zuj", function () {
- zuj_info.reverse();
- zuj_text.reverse();
- });
- $("#layers").on("mouseenter", "#castle-masks", function () {
- mas_info.play();
- mas_text.play();
- }).on("mouseleave", "#castle-masks", function () {
- mas_info.reverse();
- mas_text.reverse();
- });
- }
- }
- // DOM element map
- var map = {
- main_area: $("#main-area"),
- view_port: $("#view-port"),
- view_area: $("#view-area"),
- layer: $("#layers"),
- menu: $("#menu")
- }
- // Defined routes
- var routes = {
- "start": {
- url: "/",
- opt: {
- width: 816,
- height: 816,
- marginTop: -408,
- marginLeft: -408,
- rotation: "0_short"
- }
- },
- "animals": {
- ele: $(".animals","#menu"),
- url: "/i/zveri/",
- opt: {
- width: 3326,
- height: 3326,
- marginTop: -2100,
- marginLeft: -1900,
- rotation: "0_short"
- }
- },
- "contact": {
- ele: $(".contact", "#menu"),
- url: "/kontakti/",
- opt: {
- width: 3326,
- height: 3326,
- marginTop: -900,
- marginLeft: -1480,
- rotation: "80_short"
- }
- },
- "information": {
- ele: $(".information", "#menu"),
- url: "/informacija/",
- opt: {
- width: 3326,
- height: 3326,
- marginTop: -1445,
- marginLeft: -1680,
- rotation: "-5_short"
- }
- },
- "castle": {
- ele: $(".castle", "#menu"),
- url: "/i/pasaku-teli/",
- opt: {
- width: 3326,
- height: 3326,
- marginTop: -866,
- marginLeft: -1560,
- rotation: "-95_short"
- }
- },
- "masks": {
- ele: $(".masks", "#menu"),
- url: "/i/maskas-un-cepures/",
- opt: {
- width: 3326,
- height: 3326,
- marginTop: -873,
- marginLeft: -1833,
- rotation: "-32_short"
- }
- },
- "abstract": {
- ele: $(".abstract", "#menu"),
- url: "/i/abstrakti-teli/",
- opt: {
- width: 3326,
- height: 3326,
- marginTop: -2637,
- marginLeft: -923,
- rotation: "-180_short"
- }
- },
- "hippy": {
- ele: $(".hippy", "#menu"),
- url: "/i/raksturlomas/",
- opt: {
- width: 3326,
- height: 3326,
- marginTop: -2100,
- marginLeft: -1100,
- rotation: "-110_short"
- }
- },
- "dress": {
- ele: $(".dress", "#menu"),
- url: "/i/vakarterpi/",
- opt: {
- width: 3326,
- height: 3326,
- marginTop: -850,
- marginLeft: -785,
- rotation: "-10_short"
- }
- },
- "zuj": {
- ele: $(".zuj", "#menu"),
- url: "/i/ziemassvetki-un-jaunais-gads/",
- opt: {
- width: 3326,
- height: 3326,
- marginTop: -916,
- marginLeft: -1442,
- rotation: "0_short"
- }
- }
- }
- var loadContent = function (_routeName) {
- /// <summary>Loads content into layer</summary>
- /// <param name="_routeName" type="String">Content index name</param>
- // TODO: Check stackoverflow
- }
- // Collections of all tweens
- // a.k.a. all site animations
- var tweens = {
- start: {
- key_hole: {
- expand: function () {
- return TweenMax.to(key_hole, 2, {
- ease: 'Expo.easeIn',
- width: 8645,
- height: 8000,
- left: -((8645 - $("#view-area").width()) / 2),
- top: -((8000 - $("#view-area").height()) / 2),
- onComplete: function () {
- key_hole.fadeOut(800, function () {
- key_hole.remove();
- sim_bg.remove();
- $("#view-port").removeClass("view-port-bg-start").addClass("view-port-bg-normal");
- });
- }
- })
- },
- light_contur: function () {
- }
- },
- sim_background: function () {
- return TweenMax.to(sim_bg, 2.7, {
- ease: 'Expo.easeInOut',
- width: $("#view-port").width() + "px",
- height: $("#view-port").height() + "px",
- top: ($(window).height() >= $("#view-area").height()) ?
- -(($(window).height() - $("#view-area").height()) / 2) :
- 0,
- left: ($(window).width() >= $("#view-area").width()) ?
- -(($(window).width() - $("#view-area").width()) / 2) :
- 0
- });
- },
- light_contur: function () {
- return TweenMax.to($("#light-contur"), 1, {
- opacity: 1,
- paused: true,
- delay: 0.2
- });
- },
- rev_light_contur: function () {
- return TweenMax.to($("#light-contur"), 1, {
- opacity: 0
- });
- },
- warning: function () {
- return TweenMax.to($(".warning", "#start-content"), 1, {
- opacity: 0
- });
- },
- title: function () {
- return TweenMax.to($(".title", "#start-content"), 1, {
- opacity: 0
- });
- }
- },
- main_area: {
- start: {
- expand: function () {
- return TweenMax.to(main_area, 2.7, {
- ease: 'Expo.easeInOut',
- css: {
- marginTop: -408,
- marginLeft: -408,
- width: 816,
- height: 816
- }
- });
- }
- },
- menu: {
- shrink: function () {
- return 0;
- }
- },
- route: {
- toRoute: function (_routeName) {
- return TweenMax.to(map.main_area, 2, {
- css: routes[_routeName].opt,
- onComplete: function () {
- // TODO: add callback functions
- },
- paused: true
- });
- },
- hide_menuitem: function (_this) {
- return TweenMax.to(_this, 1, {
- css: {
- opacity: 0
- },
- onComplete: function () {
- TweenMax.set(_this, {
- css: {
- left: temp_menuitem_pos.left,
- top: temp_menuitem_pos.top,
- scale: [1,1]
- }
- });
- map.menu.css({
- display: "none"
- });
- }
- });
- },
- show_content: function () {
- return TweenMax.to(map.layer, 1, {
- css: {
- opacity: 1
- }
- });
- },
- hide_content: function () {
- return TweenMax.to(map.layer, 1, {
- css: {
- opacity: 0
- }
- });
- },
- show_menuitem: function (_this) {
- return TweenMax.to(_this, 1, {
- css: {
- opacity: 1
- }
- });
- },
- getToRoute: function (_routeName) {
- return TweenMax.to(map.main_area, 2, {
- css: routes[_routeName].opt,
- ease: "easeIn"
- });
- }
- },
- layer_buttons: {
- getTween: function (_this, _properties) {
- return TweenMax.to(_this,0.5, {
- css: _properties,
- paused: true,
- delay: 0.2
- });
- }
- }
- },
- menu: {
- show: function () {
- return TweenMax.staggerTo(menu_item_array, 1, {
- opacity: 1
- }, 0.25)
- },
- hide: function (lastElement) {
- // Hide menu
- // TODO: Stagger each menu item with 0.1 interval leaving lastElement as last element
- },
- menu_item_title: function (_this) {
- return TweenMax.to(_this.parent().find("img.title"), 0.3, {
- css: {
- scaleX: 1,
- scaleY: 1
- },
- ease: "linear",
- onStart: function () {
- TweenMax.set(_this.parent().find("img.title"), {
- css: {
- opacity: 1
- }
- });
- },
- onReverseComplete: function () {
- TweenMax.set(_this.parent().find("img.title"), {
- css: {
- opacity: 0
- }
- });
- }
- });
- },
- menu_item_icon: function (_this) {
- return TweenMax.to(_this.parent().find("img.icon"), 0.3, {
- css: {
- scaleX: 2,
- scaleY: 0
- },
- ease: "linear"
- });
- },
- menu_item_click: {
- clicked_btn: function (_this) {
- return TweenMax.to(_this, 2, {
- css: {
- left: 472,
- top: 292.5,
- scale: [2,2]
- },
- ease: "easeIn"
- });
- },
- other_btns: function (_this) {
- return TweenMax.to(_this, 1, {
- css: {
- opacity: 0
- }
- });
- }
- }
- },
- layer: {
- },
- gallery: {
- }
- }
- var routeExe = {
- menu_to_route: function (_this) {
- timelines.menu.item_click(_this).play();
- },
- route_to_route: function (_routeName) {
- // 1. reove click,mouseeneter
- // 2. trigger mouseleave
- // 3. remove mouseleave
- // 4. set appropriate menu button to center and scale[2,2]
- // 5. fade out content
- // .. onComplete clear inner html
- // 6. push state with new url
- // 7. start routeTo and fade in menu button at same time
- // 8. onComplete start to load new content
- // 9. onLoad fadeOut menubutton and fadein content+ +
- },
- start: function () {
- // 1. Fade out layers
- // ...clear layers html
- // 2. Route to start
- // 3. Fade in menu and attach menuhandler
- tweens.main_area.route.hide_content().eventCallback("onComplete", function () {
- // Clear layers html
- map.layer.html("");
- // Hide layers
- map.layer.css({
- display: "none"
- });
- // Shows menu
- map.menu.css({
- display: "block"
- });
- // Route to start
- tweens.main_area.route.getToRoute("start").eventCallback("onComplete", function () {
- // Attach event handler
- menuButtonHandler();
- // Fade in menu
- tweens.menu.show();
- });
- });
- }
- }
- // Timeline object
- // stored all animations in timelines
- // it's possible to call them independently trough console
- var timelines = {
- start: {
- intro: function () {
- _this = new TimelineMax({
- onComplete: function () {
- $("#menu").css("display", "block");
- timelines.menu.show().play();
- },
- paused: true
- });
- _this.add([
- tweens.start.key_hole.expand(),
- tweens.start.sim_background(),
- tweens.main_area.start.expand()
- ]);
- return _this;
- },
- fade_out: function () {
- _this = new TimelineMax({
- onComplete: function () {
- $("#start-content").remove();
- timelines.start.intro().play();
- },
- paused: true
- });
- _this.add([
- tweens.start.title(),
- tweens.start.rev_light_contur(),
- tweens.start.warning()
- ]);
- return _this;
- }
- },
- menu: {
- show: function () {
- _this = new TimelineMax();
- _this.add(tweens.menu.show());
- return _this;
- },
- hover_item: function (_dom) {
- _this = new TimelineMax({ paused: true });
- _this.add([
- tweens.menu.menu_item_icon(_dom),
- tweens.menu.menu_item_title(_dom)
- ]);
- return _this;
- },
- item_click: function (_this) {
- // Get routename
- var routeName = _this.find("a.handler").attr("data-menu-item");
- // Push HTML state
- history.pushState("", "", routes[routeName].url);
- // Set up Timeline object
- var _self = new TimelineMax(
- {
- paused: true,
- onComplete: function () {
- // Hide layer
- TweenMax.set(map.layer, {
- css: {
- display: "block",
- opacity: 0
- }
- });
- // Load content
- map.layer.load("" + routes[routeName].url + " #" + routeName, function (data) {
- // Hide menu button and fade in loaded content
- timelines.main_area.show_content(_this).play();
- // If we get information route, attach customscrollbar plugin
- if (routeName === "information") {
- $(".text", "#information-content").mCustomScrollbar({
- set_width: 436,
- set_height: 357,
- });
- }
- // Attach layers event handler
- attachLayerBtnHandlers();
- });
- }
- });
- // First fade out all other buttons
- _self.add(tweens.menu.menu_item_click.other_btns($(".menu-item", "#menu").not(_this)));
- // Secon pull menu button to center and animate route
- _self.add([
- tweens.menu.menu_item_click.clicked_btn(_this),
- tweens.main_area.route.getToRoute(routeName)
- ]);
- // Return object for use
- return _self;
- }
- },
- main_area: {
- show_content: function (_this) {
- var _self = new TimelineMax({ paused: true });
- _self.add(
- tweens.main_area.route.hide_menuitem(_this)
- );
- _self.add(
- tweens.main_area.route.show_content());
- return _self;
- }
- },
- layers: {
- },
- gallery: {
- }
- }
- // Custom binds for animation manipulation
- var binds = {
- start: {
- lc_click: function () {
- start_warning_show = false;
- $(this).off("mouseenter mouseleave");
- timelines.start.fade_out().play();
- }
- },
- menu: {
- },
- main_area: {
- },
- gallery: {
- }
- }
- // Set css rules for cross browser support
- // all chrome,firefox,opera,safari broswers >2009 year
- // ie9+
- var xbrowser = function() {
- /// <summary>Set cross browser css rules for elements</summary>
- // Set starting page images
- TweenMax.set($("#light-contur"), {
- css: {
- opacity: 0
- }
- });
- }
- // Resize title,price,size fonts using trim and fit
- var resizeDetails = function () {
- /// <summary>Resizes image surface detail fonts to fit container</summary>
- if ($("#layers")[0] > 0) {
- $(".title", ".detail-container").textfill();
- $(".size", ".detail-container").textfill();
- $(".price", ".detail-container").textfill();
- }
- }
- // Update legs position all the time
- var legPos = function () {
- /// <summary>Updates fixed leg position</summary>
- // Legs positioning
- if (under_construction) {
- $("#legs-2").css("bottom", "-" + $("#view-area-2").offset().top + "px")
- } else {
- $("#legs").css("bottom", "-" + $("#view-area").offset().top + "px")
- }
- }
- // Trim text inside information divisions on image surface
- var trimAndFit = function () {
- /// <summary>Finds all elements and resizes fonts to container size</summary>
- $("#layers").find(".detail-container").each(function () {
- $(".title", this).text($(".title", this).text().trim());
- $(".size", this).text($(".size", this).text().trim());
- $(".price", this).text($(".price", this).text().trim());
- });
- $(".title", ".detail-container").fill_with_text();
- $(".size", ".detail-container").fill_with_text();
- $(".price", ".detail-container").fill_with_text();
- }
- // Update keyHoleComponent positions
- // on start screen
- var keyHolePos = function () {
- /// <summary>Updates key hole position</summary>
- if (under_construction) {
- var keyHoleStyle2 = {
- 'left': -((375 - $("#view-area-2").width()) / 2) + "px",
- 'top': -((375 - $("#view-area-2").height()) / 2) + "px"
- }
- $("#key-hole-2").css(keyHoleStyle2)
- } else {
- var keyHoleStyle = {
- 'left': -(($("#key-hole").width() - $("#view-area").width()) / 2) + "px",
- 'top': -((375 - $("#view-area").height()) / 2) + "px"
- }
- var simulatedBgStyle = {
- 'left': -((375 - $("#view-area").width()) / 2) + "px",
- 'top': -((375 - $("#view-area").height()) / 2) + "px"
- }
- var starting_content = {
- 'left': -(($("#start-content").width() - $("#view-area").width()) / 2) + "px",
- 'top': -((375 - $("#view-area").height()) / 2) + "px"
- }
- $("#simulated-background").css(simulatedBgStyle);
- $("#key-hole").css(keyHoleStyle)
- $("#start-content").css(starting_content);
- }
- }
- // Set KeyHoleComponent event handlers
- // and intro animation launch
- var keyHoleHandler = function () {
- /// <summary>Attach key hole handlers</summary>
- // Define light contur animation timeline
- var light_contur = tweens.start.light_contur();
- // Attach functions to even listeners
- $("#light-contur").on('mouseenter', function () {
- light_contur.play();
- }).on('mouseleave', function () {
- light_contur.reverse();
- });
- // Launch on click event
- $("#light-contur").on("click", binds.start.lc_click);
- }
- // Set menu button handlers
- var menuButtonHandler = function () {
- /// <summary>Attach menu handlers</summary>
- // Find all menu buttons and assign actions to each of them
- $("#menu").find(".menu-item a.handler").each(function () {
- // Define menu buttons timeline
- var menu_tl = timelines.menu.hover_item($(this));
- // Set title begining css rules
- TweenMax.set($(this).parent().find("img.title"), {
- css: {
- scaleY: 0,
- scaleX: 0,
- opacity: 0
- }
- });
- // Set icon begining css rules
- TweenMax.set($(this).parent().find("img.icon"), {
- css: {
- scaleY: 1,
- scaleX: 1,
- opacity: 1
- }
- });
- // Actions for mouseenter/mouseleave/click
- $(this).on("mouseenter",function () {
- $(this).parent().css({"z-index": "10"});
- menu_tl.play();
- }).on("mouseleave",function () {
- $(this).parent().css({ "z-index": "0" });
- menu_tl.reverse();
- }).on("click tap",function () {
- _this = $(this).parent();
- // Remove all events on all menu buttons
- $(".menu-item a.handler", "#menu").off("mouseenter mouseleave click");
- // Save current menu buttons position
- temp_menuitem_pos = _this.position();
- temp_menuitem_ele = _this;
- // Animate new main area position
- menu_tl.reverse().eventCallback("onReverseComplete", function () {
- // Execute menu to route
- routeExe.menu_to_route(_this);
- });
- });
- });
- }
- // Set route button event handlers and destinations
- // and push history state
- var layerRouteBtnHandler = function () {
- /// <summary>Attach layer route button handlers</summary>
- // Define destination for route buttons
- $("#layers").delegate(".route-btn", "mouseenter", function () {
- $(this).bind('click', function () {
- var routeName = $(this).attr("data-route");
- // Push new URL and execute route
- if (routeName === "start") {
- // Push state
- history.pushState("", "", "/");
- // Execute route
- routeExe.start();
- } else {
- // Push state
- history.pushState("", "", routes[routeName].url);
- // Execute route
- routeExe.route_to_route(routeName);
- }
- });
- }).on('mouseleave', function () {
- $(this).unbind('click');
- });
- }
- // Attach appropriate handlers
- // this is needed to increase overall performance
- // attaching destinct handlers only if needed
- // not all at once
- var attachLayerBtnHandlers = function() {
- /// <summary>Attach layer route button animations</summary>
- if ($(".layer-item", "#layers").length) {
- _this = $(".layer-item", "#layers");
- // Get appropriate handlers and launch them
- layer_btn_handlers[_this.attr("data-current-pos")]();
- }
- }
- // Initiation functions
- var init = function () {
- // Update legs position
- legPos();
- if (key_hole_visiable > 0) {
- // Update keyhole
- keyHolePos();
- // Update keyhole event handlers
- keyHoleHandler();
- // Warning direction
- setTimeout(function () {
- if (start_warning_show)
- $(".warning", "#start-content").fadeIn(800);
- }, 3000);
- }
- if (testing_env > 0) {
- console.log("Under construction site");
- // Update keyhole
- keyHolePos();
- }
- // If information layer is loaded at first
- if ($("#information-content").length > 0) {
- $(".text", "#information-content").mCustomScrollbar({
- set_width: 436,
- set_height: 357,
- });
- }
- // Set manu button event Handlers
- menuButtonHandler();
- // Set route button event handlers and destinations
- layerRouteBtnHandler();
- // Attach appropriate animations to layer buttons
- attachLayerBtnHandlers();
- // Resize details
- resizeDetails();
- //Trim
- trimAndFit();
- // Disable any functions if #menu div click event is fired
- $("#menu").bind('click', false);
- // Cross browser css rule ssupport
- xbrowser();
- // Attach handlers to layers buttons
- attachLayerBtnHandlers();
- }
- // On resize update functions
- $(window).resize(function () {
- // Update legs position
- legPos();
- if (key_hole_visiable > 0) {
- // Update keyhole
- keyHolePos();
- }
- });
- // Initial function after window is fully loaded
- $(window).load(function () {
- // Set keyhole position
- if ($("#key-hole").length || $("#key-hole-2").length)
- keyHolePos();
- // Normal site
- TweenMax.to($("#view-port"), 0.5, {
- css: {
- opacity: 1
- }
- });
- // Under construction site
- TweenMax.to($("#view-port-2"), 0.5, {
- css: {
- opacity: 1
- }
- });
- // Launch initialisation
- init();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement