Created
September 17, 2014 16:59
-
-
Save whalesalad/660efeb9ff6e650ad8c6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| ** Farmers Insurance -- farmers.room.js | |
| ** (c) 2011 ZehnerGroup // Written by Michael Whalen <mwhalen@zehnergroup.com> | |
| ** zehnergroup.com | |
| */ | |
| var RoomController, Room; | |
| RoomController = Class.$extend({ | |
| __init__: function(a, b) { | |
| var c = this; | |
| c.frame = $("#primaryFrame"); | |
| c.frame_nav = c.frame.children("ul.frameNav"); | |
| c.frame_overlay = $(".frameOverlay"); | |
| c.floating_house = $(".floatingHouseOverlay"); | |
| c.core_controller = b; | |
| c.rooms = {}; | |
| c._rooms = _.map(a, function(a) { | |
| var b = new Room(a, c); | |
| c.rooms[b.slug] = b; | |
| return b | |
| }); | |
| c.renderFrameTabs() | |
| }, | |
| showRoomChooser: function() { | |
| var a = this; | |
| a.core_controller.showOverlay(); | |
| a.floating_house._show(); | |
| a.placeIndicators(); | |
| a.core_controller.white_overlay.bind("click", function(b) { | |
| a.hideRoomChooser(); | |
| a.core_controller.introScene() | |
| }) | |
| }, | |
| hideRoomChooser: function() { | |
| var a = this; | |
| a.floating_house._hide() | |
| }, | |
| getRoom: function(a) { | |
| var b = this; | |
| return b.rooms[a] | |
| }, | |
| placeIndicators: function() { | |
| var a = this; | |
| _.each(a.rooms, function(b, c) { | |
| if (!b.hasIndicator()) { | |
| a.floating_house.append(b.renderIndicator()) | |
| } | |
| b.indicatorAppear() | |
| }) | |
| }, | |
| renderFrameTabs: function() { | |
| var a = this; | |
| _.each(a.rooms, function(b, c) { | |
| var d = $("<li/>").html('<a href="#room-' + b.slug + '"><span>' + b.name + "</span></a>"); | |
| d.appendTo(a.frame_nav); | |
| if (b.tabwidth) { | |
| d.css("width", b.tabwidth) | |
| } | |
| d.click(function() { | |
| b.loadRoom(); | |
| return false | |
| }) | |
| }) | |
| } | |
| }); | |
| Room = Class.$extend({ | |
| __init__: function(a, b) { | |
| var c = this; | |
| c.indicator_position = a.indicator; | |
| c.name = a.name; | |
| c.slug = a.slug; | |
| c.tabwidth = a.tabwidth || false; | |
| c.controller = b; | |
| if (typeof a.children !== "undefined") { | |
| c.items = new ItemController(a.children, c) | |
| } | |
| }, | |
| hasItems: function() { | |
| var a = this; | |
| return a.items | |
| }, | |
| renderIndicator: function() { | |
| var a = this; | |
| var b = $("<div/>").addClass("indicator").css({ | |
| top: a.indicator_position[1], | |
| left: a.indicator_position[0] | |
| }); | |
| b.bind("click", function(b) { | |
| a.indicatorClick(b) | |
| }); | |
| a.indicator = b; | |
| var c = createTooltip(a.name); | |
| a.indicator.append(c); | |
| a.indicator.hover(function() { | |
| c.trigger("appear") | |
| }, function() { | |
| c.trigger("disappear") | |
| }); | |
| return a.indicator | |
| }, | |
| hasIndicator: function() { | |
| return typeof this.indicator == "undefined" ? false : true | |
| }, | |
| indicatorAppear: function() { | |
| var a = this; | |
| a.indicator.fadeIn() | |
| }, | |
| loadRoom: function() { | |
| var a = this, | |
| b = a.controller.frame; | |
| if (a.controller.current) { | |
| a.controller.current.unloadRoom() | |
| } | |
| if (a.controller.current == a) { | |
| return false | |
| } | |
| var c = "img/content/" + a.slug + ".jpg"; | |
| a.controller.core_controller.preloadImages([c], function() { | |
| a.controller.hideRoomChooser(); | |
| b.children(".frameInner").children("img.frameImage").attr("src", c); | |
| b.frame_name = $("span.frameName"); | |
| b.frame_name.text(a.name).fadeIn(); | |
| b.animate({ | |
| top: "120px" | |
| }, { | |
| duration: 700, | |
| specialEasing: { | |
| top: "easeOutSine" | |
| }, | |
| complete: function() { | |
| $(this).css({ | |
| "z-index": a.min_z_index + 1 | |
| }); | |
| a.controller.frame_nav.animate({ | |
| backgroundPosition: "0 0" | |
| }, 500).children("li").each(function(a) { | |
| var b = $(this); | |
| if ($.browser.msie) { | |
| b.css("marginTop", 0) | |
| } else { | |
| setTimeout(function() { | |
| b.animate({ | |
| marginTop: 0 | |
| }, 300) | |
| }, 60 * a) | |
| } | |
| }); | |
| if (a.items) { | |
| a.items.placeIndicators(a.controller.frame_overlay) | |
| } | |
| } | |
| }) | |
| }); | |
| if (a.controller.current) { | |
| b.fadeIn("fast") | |
| } | |
| a.controller.core_controller.white_overlay.unbind("click"); | |
| a.controller.core_controller.white_overlay.bind("click", function(b) { | |
| a.unloadRoom() | |
| }); | |
| $("a#smallCrossSectionButton").bind("click", function(b) { | |
| a.unloadRoom() | |
| }); | |
| a.controller.current = a | |
| }, | |
| unloadRoom: function() { | |
| var a = this; | |
| a.controller.frame.animate({ | |
| top: -800 | |
| }, { | |
| duration: 700, | |
| specialEasing: { | |
| top: "easeOutSine" | |
| }, | |
| complete: function() { | |
| a.controller.frame_nav.children("li").each(function(a) { | |
| $(this).css("margin-top", -60) | |
| }).css("backgroundPosition", "0 -48px"); | |
| if (a.hasItems()) { | |
| a.items.hideIndicators() | |
| } | |
| } | |
| }); | |
| if (typeof a.card !== "undefined") { | |
| a.hideCard() | |
| } | |
| if (a.controller.frame.frame_name.size()) { | |
| a.controller.frame.frame_name.hide() | |
| } | |
| a.controller.showRoomChooser(); | |
| a.controller.current = null | |
| }, | |
| indicatorClick: function(a) { | |
| var b = this; | |
| b.loadRoom() | |
| }, | |
| showCard: function(a) { | |
| var b = this; | |
| a.render(b.controller.frame_overlay); | |
| b.card = a | |
| }, | |
| hideCard: function() { | |
| var a = this; | |
| a.card.close() | |
| } | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment