Created
July 17, 2012 21:04
-
-
Save randito/3132063 to your computer and use it in GitHub Desktop.
Google Art Project: Backbone js code. Beautified via http://jsbeautifier.org/
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
| ap.globals.MainBaseView = Backbone.View.extend({ | |
| el: $("body"), | |
| elements: { | |
| $header: $("#header"), | |
| $footer: $("#footer"), | |
| $secondaryNav: $("nav.secondary"), | |
| $pageContent: $(".content-wrapper"), | |
| $mainContent: $(".main-content") | |
| }, | |
| options: { | |
| visibleButtons: [".plusone", ".discover", ".share", ".add-to-collection", ".slideshow", ".streetview"] | |
| }, | |
| router: null, | |
| sidebar: null, | |
| jScrollPaneApi: null, | |
| minHeight: 560, | |
| streetview: null, | |
| initialize: function () { | |
| var a = this; | |
| _.bindAll(this, "renderSidebar", "resizeContentArea", "setupSearch", "render", "langSelector"); | |
| if (_.isUndefined(a.options.useSidebar)) { | |
| a.options.useSidebar = true | |
| } | |
| if (a.options.useSidebar) { | |
| $(window).smartresize(this.resizeContentArea) | |
| } | |
| if ($("#header-nav-user-template").length) { | |
| a.userHeaderNavTpl = _.template($("#header-nav-user-template").html()) | |
| } | |
| a.initSidebar(a.options); | |
| $("#secondary-prop .artwork-title .pegman").click(function (b) { | |
| b.preventDefault(); | |
| $("#sidebar .toolbar-actions-container .streetview").trigger("click") | |
| }); | |
| if (a.options.dontFetchUserData !== true) { | |
| ap.getCurrentUser(function () { | |
| a.sidebar.trigger("userDataLoaded"); | |
| a.trigger("userDataLoaded") | |
| }) | |
| } | |
| a.elements.$header.on("click", "a", ap.clearCurrentArtworkCollectionState); | |
| a.elements.$header.on("click", ".sign-in-out.in .username", a.toggleSignOut); | |
| return a | |
| }, | |
| initSidebar: function (a) { | |
| this.sidebar = new ap.sidebar.MainView(a); | |
| this.sidebar.parentView = this | |
| }, | |
| showMuseumView: function () { | |
| window.app.sidebar.showMuseumView() | |
| }, | |
| renderSidebar: function () { | |
| this.sidebar.render(); | |
| this.resizeContentArea() | |
| }, | |
| resizeContentArea: function () { | |
| var k = $(window).height(); | |
| var a = this.elements.$header.outerHeight(true); | |
| var f = (!ap.isMobile) ? 70 : 46; | |
| var j = this.elements.$secondaryNav.outerHeight(true); | |
| var c = k - (a + j + f); | |
| this.elements.$pageContent.height(c - 1); | |
| var d = $(window).width(); | |
| var e = this.sidebar.closedWidth + this.sidebar.el.position().left; | |
| var b = d - e; | |
| $(".content-with-sidebar").css({ | |
| marginLeft: e, | |
| width: b + "px" | |
| }); | |
| if (this.jScrollPaneApi !== null) { | |
| this.jScrollPaneApi.reinitialise() | |
| } | |
| if (this.sidebar && this.sidebar.discover) { | |
| this.sidebar.discover.trigger("contentAreaResized") | |
| } | |
| this.trigger("contentAreaResized"); | |
| if (this.streetview) { | |
| this.streetview.updateStreetview(); | |
| if (this.streetview.thumbnailStrip) { | |
| this.streetview.thumbnailStrip.resize(b) | |
| } | |
| } | |
| }, | |
| render: function () { | |
| if (this.options.useSidebar) { | |
| this.renderSidebar() | |
| } | |
| this.langSelector() | |
| }, | |
| setupSearch: function () { | |
| var a = new ap.search.AutosuggestSearchView({ | |
| $input: $("#input-header-search"), | |
| $wrapper: $("#search-autosuggest-wrapper") | |
| }); | |
| a.render() | |
| }, | |
| langSelector: function () { | |
| $("#current-lang a").click(function () { | |
| $langselector = $("#lang-selector"); | |
| var b = $("#current-lang").offset(); | |
| var a = b.left; | |
| var c = b.top; | |
| var d = $langselector.height(); | |
| lang_selector_top = c - d - 16; | |
| lang_selector_left = a - 30; | |
| $langselector.css("left", lang_selector_left); | |
| $langselector.css("top", lang_selector_top); | |
| if ($langselector.is(":visible")) { | |
| $langselector.hide("slide", { | |
| direction: "down" | |
| }) | |
| } else { | |
| $langselector.show("slide", { | |
| direction: "down" | |
| }) | |
| } | |
| return false | |
| }) | |
| }, | |
| toggleSignOut: function () { | |
| var a = $("#profile-navigation .sign-in-out.in"); | |
| if (a.hasClass("active")) { | |
| a.removeClass("active") | |
| } else { | |
| a.addClass("active") | |
| } | |
| return false | |
| } | |
| }); | |
| ap.globals.MainCollectionView = ap.globals.MainBaseView.extend({ | |
| events: { | |
| currentCollectionChange: "currentCollectionChange" | |
| }, | |
| options: { | |
| aggregationConfig: { | |
| artworkDimensions: { | |
| height: null, | |
| width: null | |
| }, | |
| aggregationType: null, | |
| collectionOptions: {}, | |
| modelViewType: null, | |
| useDynamicRows: true, | |
| viewType: null | |
| } | |
| }, | |
| initialPreloader: null, | |
| addToExistingPreloader: null, | |
| mainScrollingView: null, | |
| preloaderview: null, | |
| addToExistingPreloader: null, | |
| pagingProcessManager: null, | |
| loadedViewArray: [], | |
| fullViewArray: [], | |
| defaultQueryStringParams: { | |
| offset: 0, | |
| limit: 30 | |
| }, | |
| currentCollection: {}, | |
| initialize: function (d) { | |
| var c = this, | |
| a, b, f; | |
| _.bindAll(c, "filterCurrentCollection", "addAll", "addOne", "addNewlyLoaded", "render", "onSidebarResize", "closeSidebar", "closeTopFilter", "clearCollectionElements"); | |
| ap.globals.MainBaseView.prototype.initialize.apply(c, [d]); | |
| b = c.options.aggregationConfig; | |
| c.pagingProcessManager = new ap.system.ProcessManager("paging"); | |
| if (b.aggregationBodyType && b.aggregationBodyType !== "artworks") { | |
| ap.clearCurrentArtworkCollectionState() | |
| } | |
| if (c.sidebar && c.sidebar.discover) { | |
| var e = c.sidebar.discover.get_restrict_next_by(true); | |
| if (e) { | |
| $.extend(c.defaultQueryStringParams, e) | |
| } | |
| } | |
| a = ap.buildApiUrl(c.options.urlParts, $.extend(c.defaultQueryStringParams, c.options.qs_params)); | |
| f = $.extend({}, { | |
| url: a, | |
| activeFilters: c.options.qs_params | |
| }, b.collectionInitOptions); | |
| c.currentCollection = new ap[b.aggregationType](null, f); | |
| c.currentCollection.bind("reset", c.addAll); | |
| c.currentCollection.bind("addNewlyLoaded", c.addNewlyLoaded); | |
| if (c.currentCollection.filterTypes && !$.isEmptyObject(c.currentCollection.filterTypes)) { | |
| if (!ap.isMobile) { | |
| c.topFiltersView = new ap.aggregation.layout.TopFiltersView({ | |
| filtersToInit: c.currentCollection.filterTypes, | |
| parentView: c, | |
| isOpen: (["collection", "artist"].indexOf(c.currentCollection.collectionType) !== -1) | |
| }) | |
| } else { | |
| c.topFiltersView = new ap.mobile.aggregation.TopFiltersView({ | |
| filtersToInit: c.currentCollection.filterTypes, | |
| parentView: c, | |
| isOpen: (["collection", "artist"].indexOf(c.currentCollection.collectionType) !== -1) | |
| }) | |
| } | |
| } | |
| c.bind("filterCurrentCollection", c.filterCurrentCollection); | |
| c.bind("topFilterOpening", c.closeSidebar); | |
| c.bind("sidebarOpening", c.closeTopFilter); | |
| if (c.rowsView) { | |
| ap.aggregation.layout.Global.currentRowView = ap.aggregation.layout.Config["rowView" + b.rowId] | |
| } | |
| if (b.preloadImages) { | |
| c.initialPreloader = new ap.system.imagePreload("initial", { | |
| imageLoaded: c.imageLoadedCallback, | |
| imageLoadError: c.imageLoadErrorCallback, | |
| batchLoaded: c.initialBatchLoadedCallback | |
| }); | |
| c.addToExistingPreloader = new ap.system.imagePreload("addToExisting", { | |
| imageLoaded: c.imageLoadedCallback, | |
| imageLoadError: c.imageLoadErrorCallback, | |
| batchLoaded: c.addToExistingBatchLoadedCallback | |
| }) | |
| } | |
| return c | |
| }, | |
| closeTopFilter: function () { | |
| if (this.topFiltersView) { | |
| this.topFiltersView.closeFilter() | |
| } | |
| }, | |
| filterCurrentCollection: function (b, d, c) { | |
| var a = { | |
| offset: 0, | |
| limit: 30 | |
| }; | |
| if (b) { | |
| if (d) { | |
| this.currentCollection.setFilter(b, d) | |
| } else { | |
| this.currentCollection.removeFilter(b) | |
| } | |
| } | |
| if (c && c.silent === true) { | |
| return | |
| } | |
| this.currentCollectionChange() | |
| }, | |
| currentCollectionChange: function (a, c) { | |
| var b = this; | |
| if (b.currentXHR) { | |
| b.currentXHR.abort() | |
| } | |
| b.clearCollectionElements(); | |
| b.jScrollPaneApi.scrollToX(0, false); | |
| ap.aggregation.layout.RowFormat.resetRowWidth(); | |
| b.jScrollPaneApi.reinitialise(); | |
| if (b.pagingProcessManager) { | |
| b.pagingProcessManager.reset(); | |
| b.pagingProcessManager.start() | |
| } | |
| b.fullViewArray = []; | |
| b.loadedViewArray = []; | |
| ap.aggregation.layout.Global.numberOfImages = 0; | |
| if (c) { | |
| b.currentCollection = c; | |
| if (b.rowsView) { | |
| b.rowsView.collection = b.currentCollection; | |
| b.rowsView.infiniteScrollingView.collection = b.currentCollection | |
| } | |
| b.currentCollection.bind("reset", b.addAll); | |
| b.currentCollection.bind("addNewlyLoaded", b.addNewlyLoaded) | |
| } | |
| if (b.rowsView) { | |
| ap.aggregation.layout.Global.lastRow = 0 | |
| } | |
| b.currentXHR = b.currentCollection.fetch() | |
| }, | |
| closeSidebar: function () { | |
| if (this.sidebar && this.sidebar.open) { | |
| this.sidebar.closeSidebar(); | |
| if ($("#streetview").is(":visible")) { | |
| this.sidebar.killMuseumView(); | |
| this.sidebar.el.find(".toolbar-actions-container .streetview").trigger("click") | |
| } | |
| if (this.museumDetails) { | |
| this.museumDetails.togglePopup("up") | |
| } | |
| } else { | |
| if (ap.isMobile) { | |
| if ($("#streetview").is(":visible")) { | |
| this.sidebar.killMuseumView(); | |
| this.sidebar.el.find(".toolbar-actions-container .streetview").trigger("click") | |
| } | |
| } | |
| } | |
| }, | |
| clearCollectionElements: function () { | |
| $(".row").empty() | |
| }, | |
| updateCounts: function () { | |
| var a = JSON.parse(this.currentXHR.responseText); | |
| $("#secondary-prop h2.artwork-artist .count").text(a.meta.total_count) | |
| }, | |
| addAll: function () { | |
| var a = this; | |
| this.updateCounts(); | |
| if (this.sidebar) { | |
| this.sidebar.config.aggregation = this.currentCollection; | |
| this.sidebar.config.aggregation_view = this; | |
| this.sidebar.disableButton(".slideshow") | |
| } | |
| a.clearCollectionElements(); | |
| a.fullViewArray = []; | |
| a.loadedViewArray = []; | |
| ap.aggregation.layout.Global.numberOfImages = 0; | |
| a.currentCollection.each(function (b) { | |
| a.addOne(b, a.initialPreloader) | |
| }); | |
| if (a.options.aggregationConfig.preloadImages) { | |
| ap.log("preloading..."); | |
| a.initialPreloader.load() | |
| } else { | |
| ap.log("skipping preloading..."); | |
| a.initialBatchLoadedCallback.call(a) | |
| } | |
| }, | |
| addNewlyLoaded: function () { | |
| ap.log("addNewlyLoaded..."); | |
| var a = this; | |
| $.each(a.currentCollection.newlyAdded, | |
| function (c, b) { | |
| ap.aggregation.layout.Global.numberOfImages++; | |
| a.addOne(b, a.addToExistingPreloader, true) | |
| }); | |
| if (a.options.aggregationConfig.preloadImages) { | |
| a.addToExistingPreloader.load() | |
| } else { | |
| a.addToExistingBatchLoadedCallback.call(a) | |
| } | |
| }, | |
| addOne: function (c, d, k) { | |
| var l = this; | |
| var f = l.options.aggregationConfig; | |
| if (ap.isMobile && f.modelViewType == "ArtworkView") { | |
| var j = new ap.mobile.aggregation[f.modelViewType]({ | |
| model: c, | |
| isAppendToExisting: k, | |
| imageSize: f.artworkDimensions, | |
| addExtraOptions: true, | |
| parentView: l | |
| }) | |
| } else { | |
| var j = new ap.aggregation.layout[f.modelViewType]({ | |
| model: c, | |
| isAppendToExisting: k, | |
| imageSize: f.artworkDimensions, | |
| addExtraOptions: true, | |
| parentView: l | |
| }) | |
| } | |
| l.loadedViewArray.push(j); | |
| ap.aggregation.layout.Global.numberOfImages++; | |
| var e = c.viewOrder - 1; | |
| if (!e) { | |
| l.fullViewArray.push(j) | |
| } else { | |
| l.fullViewArray[e] = j | |
| } | |
| if (j.model.attributes.primary_image != null && j.model.attributes.cached_artwork_primary_image_full_url != null) { | |
| var b = { | |
| self: l, | |
| view: j | |
| }; | |
| var a = ap.aggregation.layout.Global.currentRowView.image; | |
| d.addToQueue(j.model.image(ap.aggregation.layout.Global.currentRowView.image.height), b) | |
| } | |
| return j | |
| }, | |
| onSidebarResize: function () { | |
| this.jScrollPaneApi.reinitialise() | |
| }, | |
| render: function () { | |
| ap.globals.MainBaseView.prototype.render.apply(this, [this.options]); | |
| this.preloaderview = new ap.aggregation.layout.PreloaderView(); | |
| this.preloaderview.render(); | |
| if (this.topFiltersView) { | |
| this.topFiltersView.render() | |
| } | |
| this.mainScrollingView = new ap.aggregation.layout.MainScrollingView({ | |
| el: this.el | |
| }); | |
| this.jScrollPaneApi = this.mainScrollingView.render(); | |
| this.infiniteScrollingView = new ap.aggregation.layout.InfiniteScrollingView({ | |
| el: this.el, | |
| jScrollPaneApi: this.jScrollPaneApi, | |
| collection: this.currentCollection, | |
| selector: ".column:last-child" | |
| }); | |
| $(this.sidebar.el.selector).on("resize", this.sidebar.el.selector, this.onSidebarResize); | |
| this.pagingProcessManager.start(); | |
| this.currentXHR = this.currentCollection.fetch() | |
| } | |
| }); | |
| ap.globals.MainNameListView = ap.globals.MainCollectionView.extend({ | |
| el: $(".content-with-sidebar"), | |
| defaultQueryStringParams: { | |
| offset: 0, | |
| limit: 30 | |
| }, | |
| currentLetter: null, | |
| currentColumn: null, | |
| maxItemsInColumn: 0, | |
| options: { | |
| disabledButtons: [".add-to-collection"], | |
| visibleButtons: [".plusone", ".discover", ".share", ".add-to-collection", ".slideshow"], | |
| }, | |
| columns: [], | |
| columnsCount: 0, | |
| itemHeight: 44, | |
| initialize: function () { | |
| var a = this; | |
| _.bindAll(this, "render", "filterCurrentCollection", "addAll", "addNewlyLoaded", "reorganiseColumns", "setMaxWidth", "addToColumn", "needToLoadMore", "clearCollectionElements"); | |
| ap.globals.MainCollectionView.prototype.initialize.apply(a, [a.options]) | |
| }, | |
| clearCollectionElements: function () { | |
| this.currentColumn = null; | |
| this.columnsCount = 0; | |
| this.container.empty(); | |
| this.container.width(0) | |
| }, | |
| addAll: function () { | |
| var a = this; | |
| this.updateCounts(); | |
| a.pagingProcessManager.end(); | |
| ap.log("addAll started", "info"); | |
| a.clearCollectionElements(); | |
| a.calculateMaxHeight(); | |
| ap.log("started adding", "warn"); | |
| a.currentCollection.each(function (c) { | |
| a.addOne(c) | |
| }); | |
| ap.log("ended adding", "warn"); | |
| var b = a.setMaxWidth(); | |
| ap.log("set max width", "warn"); | |
| a.jScrollPaneApi.reinitialise({ | |
| contentWidth: b | |
| }); | |
| ap.log("jsp reinitialised", "warn"); | |
| a.pagingProcessManager.end(); | |
| ap.log("addAll finished", "info"); | |
| if (a.needToLoadMore()) { | |
| a.currentXHR = a.currentCollection.nextPage(); | |
| if (a.currentXHR === false) { | |
| a.currentLetter = null | |
| } | |
| } | |
| }, | |
| addNewlyLoaded: function () { | |
| var a = this; | |
| $.each(a.currentCollection.newlyAdded, | |
| function (c, d) { | |
| a.addOne(d) | |
| }); | |
| var b = a.setMaxWidth(); | |
| a.jScrollPaneApi.reinitialise({ | |
| contentWidth: b | |
| }); | |
| a.pagingProcessManager.end(); | |
| if (a.needToLoadMore()) { | |
| a.currentXHR = a.currentCollection.nextPage(); | |
| if (a.currentXHR === false) { | |
| a.currentLetter = null | |
| } | |
| } | |
| }, | |
| onSidebarResize: function () { | |
| this.jScrollPaneApi.reinitialise() | |
| }, | |
| createNewColumn: function () { | |
| var a = this; | |
| a.currentColumn = new ap.artist.layout.ColumnView(); | |
| a.columns.push[a.currentColumn]; | |
| a.columnsCount++; | |
| a.container.append(a.currentColumn.el); | |
| return $(a.currentColumn.el) | |
| }, | |
| addToColumn: function (d) { | |
| if (!this.currentColumn) { | |
| this.createNewColumn() | |
| } | |
| var b = this.currentColumn.itemCount; | |
| var a = (b == this.maxItemsInColumn); | |
| var c = false; | |
| if ($(d).hasClass("letter") && (b + 1 == this.maxItemsInColumn)) { | |
| c = true | |
| } | |
| if (this.maxItemsInColumn && (c || a)) { | |
| this.createNewColumn() | |
| } | |
| $(this.currentColumn.el).append($(d)); | |
| this.currentColumn.itemCount++ | |
| }, | |
| setMaxWidth: function () { | |
| var b = 320; | |
| var a = this.columnsCount * b; | |
| this.container.width(a); | |
| this.calculateMaxHeight(); | |
| return a | |
| }, | |
| needToLoadMore: function () { | |
| return this.container.width() < $(this.el).width() | |
| }, | |
| calculateMaxHeight: function () { | |
| var a = this; | |
| var c = (!ap.isMobile) ? 120 : 180; | |
| var b = $(a.el).height() - c; | |
| var d = Math.floor(b / a.itemHeight); | |
| a.maxItemsInColumn = d | |
| }, | |
| reorganiseColumns: function (e) { | |
| var d = this; | |
| ap.log("Starting reorder", "warn"); | |
| d.calculateMaxHeight(); | |
| var b = $(d.container); | |
| var c = b.find(".column").not(".dontTouchMe").find(".item"); | |
| d.currentColumn = null; | |
| d.columnsCount = 1; | |
| var a = 0; | |
| b.find(".column").not(".dontTouchMe").addClass("removeme"); | |
| $.each(c, | |
| function (f, j) { | |
| d.addToColumn(j) | |
| }); | |
| $(".removeme").remove(); | |
| d.setMaxWidth(); | |
| d.jScrollPaneApi.reinitialise({ | |
| contentWidth: b.width() | |
| }); | |
| d.pagingProcessManager.end(); | |
| if (d.currentXHR && d.currentXHR.status == 0) {} else { | |
| if (e !== false && d.needToLoadMore()) { | |
| d.currentXHR = d.currentCollection.nextPage(); | |
| if (d.currentXHR === false) { | |
| d.currentLetter = null | |
| } | |
| } | |
| } | |
| ap.log("Finished reorder", "warn") | |
| } | |
| }); | |
| ap.globals.AudioPlayerView = Backbone.View.extend({ | |
| el: $(".audioplayer"), | |
| events: { | |
| mouseenter: "growProgressbar", | |
| mouseleave: "setShrinkTimeout" | |
| }, | |
| template: null, | |
| jqueryPlayerTemplate: '<div id="jquery_jplayer_<%= artwork_id %>" class="jp-jplayer"></div>', | |
| context: null, | |
| player: null, | |
| playlistItems: [], | |
| swfPath: null, | |
| progressBar: null, | |
| defaultProgressbarHeight: null, | |
| shrinkTimeout: null, | |
| shrinkProgressbarDelay: 2000, | |
| scrollDurationPer100px: 3500, | |
| scrollDirection: -1, | |
| scrollDelayDuration: 1000, | |
| playlistOptions: { | |
| autoPlay: false, | |
| loopOnPrevious: false, | |
| shuffleOnLoop: false, | |
| enableRemoveControls: false, | |
| displayTime: "slow", | |
| addTime: "fast", | |
| removeTime: "fast", | |
| shuffleTime: "slow" | |
| }, | |
| initialize: function () { | |
| _.bindAll(this, "render", "growProgressbar", "setShrinkTimeout", "shrinkProgressbar", "scrollTitle", "setupTitleScroller", "play"); | |
| this.playlistItems = this.options.playlistItems; | |
| this.context = { | |
| artwork_id: $(this.el).data("artwork-id") | |
| } | |
| }, | |
| growProgressbar: function () { | |
| clearTimeout(this.shrinkTimeout); | |
| var a = this; | |
| a.progressBar.animate({ | |
| height: 10 | |
| }) | |
| }, | |
| setShrinkTimeout: function () { | |
| this.shrinkTimeout = setTimeout(this.shrinkProgressbar, this.shrinkProgressbarDelay) | |
| }, | |
| shrinkProgressbar: function () { | |
| var a = this; | |
| a.progressBar.animate({ | |
| height: a.defaultProgressbarHeight | |
| }) | |
| }, | |
| setupTitleScroller: function () { | |
| var d = this; | |
| var b = d.el.find(".jp-title").eq(0); | |
| var e = b.width(); | |
| var f = b.find("li").eq(0); | |
| f.stop().css("margin-left", 0); | |
| var j = f.outerWidth(); | |
| var c = j - e; | |
| var a = c * d.scrollDurationPer100px / 100; | |
| d.scrollParams = { | |
| titleContainer: b, | |
| titleContainerWidth: e, | |
| title: f, | |
| titleWidth: j, | |
| amountToAnimate: c, | |
| durationToAnimate: a, | |
| scrollDirection: d.scrollDirection | |
| } | |
| }, | |
| play: function () { | |
| this.player.jPlayer("play", 0) | |
| }, | |
| scrollTitle: function () { | |
| var a = this; | |
| if (a.scrollParams.amountToAnimate > 0) { | |
| a.scrollParams.title.animate({ | |
| marginLeft: a.scrollParams.scrollDirection * a.scrollParams.amountToAnimate | |
| }, { | |
| duration: a.scrollParams.durationToAnimate, | |
| easing: "linear", | |
| complete: function () { | |
| if (a.scrollParams.scrollDirection == 0) { | |
| a.scrollParams.scrollDirection = -1 | |
| } else { | |
| a.scrollParams.scrollDirection = 0 | |
| } | |
| setTimeout(function () { | |
| a.scrollTitle() | |
| }, a.scrollDelayDuration) | |
| } | |
| }) | |
| } | |
| }, | |
| initPlayer: function () { | |
| var a = this; | |
| a.player = new jPlayerPlaylist({ | |
| jPlayer: "#jquery_jplayer_" + a.context.artwork_id, | |
| cssSelectorAncestor: $(a.el).selector | |
| }, a.playlistItems, { | |
| playlistOptions: a.playlistOptions, | |
| swfPath: a.swfPath, | |
| supplied: "mp3", | |
| ready: function () { | |
| a.player.select(0); | |
| a.setupTitleScroller(); | |
| a.scrollTitle() | |
| } | |
| }) | |
| }, | |
| render: function () { | |
| var a = this; | |
| a.template = _.template($("#audio_player-template").html(), a.context); | |
| a.el.append(a.template); | |
| a.progressBar = a.el.find(".jp-progress").eq(0); | |
| a.defaultProgressbarHeight = a.progressBar.height(); | |
| a.swfPath = $(a.el).find(".audioplayer").data("swf-url"); | |
| a.jqueryPlayerTemplate = _.template(a.jqueryPlayerTemplate, a.context); | |
| $(a.jqueryPlayerTemplate).insertBefore($(a.el)); | |
| a.initPlayer() | |
| } | |
| }); | |
| ap.globals.InlineRename = Backbone.View.extend({ | |
| events: { | |
| "click .edit-inline": "replace_with_input", | |
| "keypress #rename-input": "key_handler", | |
| "blur #rename-input": "blur_rename", | |
| "blur #rename-textarea": "blur_rename" | |
| }, | |
| template: '<div class="rename-cont"><input type="text" name="rename-input" id="rename-input" /></div>', | |
| textareaTemplate: '<div class="rename-cont"><textarea cols="10" rows="8" name="rename-textarea" id="rename-textarea"></textarea></div>', | |
| current_heading: "", | |
| initialize: function () { | |
| var a = this | |
| }, | |
| addEditClass: function () { | |
| var b = this; | |
| var c = $(b.el).find(b.options.target_element); | |
| var a = !_.isUndefined(b.options.auto_edit) && b.options.auto_edit; | |
| _.each(c, | |
| function (e) { | |
| var d = $(e); | |
| if ($.trim(d.text()) === b.options.target_default) { | |
| d.addClass("edit-inline") | |
| } | |
| if (a) { | |
| d.click() | |
| } | |
| }) | |
| }, | |
| key_handler: function (b) { | |
| var a = this; | |
| if (b.keyCode === 13) { | |
| if (_.isUndefined(a.options.textarea) || !a.options.textarea) { | |
| b.preventDefault(); | |
| a.save_rename(b, $("#rename-input")) | |
| } | |
| } else { | |
| if (b.keyCode === 27) { | |
| a.cancel_rename() | |
| } | |
| } | |
| }, | |
| save_rename: function (d, c) { | |
| d.preventDefault(); | |
| d.stopPropagation(); | |
| var a = this; | |
| var e = c.val(); | |
| var b = {}; | |
| if (e === "" || e === undefined || e === a.options.target_default) { | |
| a.cancel_rename() | |
| } else { | |
| b[a.options.replace] = e; | |
| if (typeof (a.model.get("artwork")) === "object") { | |
| b.artwork = a.model.get("artwork").resource_uri; | |
| b.bookmark_group = a.model.get("bookmark_group").resource_uri | |
| } | |
| a.model.set(b); | |
| if ($("#rename-input").parent().parent().is("a")) { | |
| $("#rename-input").parent().parent().attr("href", ap.slugify(a.model.get("id")) + "/update/") | |
| } | |
| if (!_.isUndefined(a.options.saveCallback)) { | |
| $(a.el).find(".rename-cont").after('<span class="spinner"></span>'); | |
| a.model.save({}, { | |
| success: function (j, f) { | |
| var k = a.options.saveCallback(j, f); | |
| $(a.el).find(".user-content").replaceWith(k) | |
| }, | |
| error: function (j, f) { | |
| a.cancel_rename(d); | |
| alert('"' + j.get("youtube_id") + '" ' + TRANSLATIONS.invalid_youtube_link) | |
| } | |
| }) | |
| } else { | |
| a.current_heading.text(a.model.get(a.options.replace)); | |
| $(a.el).find(".rename-cont").replaceWith(a.current_heading); | |
| $(a.el).find(a.options.target_element).removeClass("edit-inline"); | |
| a.model.save() | |
| } | |
| return false | |
| } | |
| }, | |
| blur_rename: function (b) { | |
| var a = this; | |
| return a.save_rename(b, $(b.currentTarget)) | |
| }, | |
| cancel_rename: function (c) { | |
| var a = this; | |
| $(a.el).find(".spinner").remove(); | |
| if (_.isUndefined(a.options.textarea) || !a.options.textarea) { | |
| var b = $("#rename-input"); | |
| if (!_.isUndefined(a.options.replace_parent) && a.options.replace_parent) { | |
| b.parent().replaceWith(a.current_heading) | |
| } else { | |
| b.replaceWith(a.current_heading) | |
| } | |
| } else { | |
| $("#rename-input, .spinner").replaceWith(a.current_heading).find(".video").hide() | |
| } | |
| }, | |
| replace_with_input: function (c) { | |
| var a = this; | |
| var b = $(c.target); | |
| c.preventDefault(); | |
| if (b.parent().is("a")) { | |
| a.current_heading = b.parent() | |
| } else { | |
| a.current_heading = b | |
| } | |
| if (_.isUndefined(a.options.textarea) || !a.options.textarea) { | |
| $(a.el).find(a.options.target_element).replaceWith(a.template) | |
| } else { | |
| $(a.el).find(a.options.target_element).replaceWith(a.textareaTemplate) | |
| } | |
| $("#rename-input, #rename-textarea").val(a.options.target_default).focus().select() | |
| } | |
| }); | |
| ap.namespace("ap.aggregation.layout").Global = { | |
| currentRowView: {}, | |
| lastRow: 0, | |
| numberOfImages: 0 | |
| }; | |
| ap.namespace("ap.aggregation.layout").Config = { | |
| rowViewOne: { | |
| image: { | |
| height: 470, | |
| padding: 9 | |
| }, | |
| zoom: { | |
| size: 100, | |
| image: { | |
| height: 800 | |
| } | |
| }, | |
| minHeight: 106, | |
| maxHeight: 212, | |
| hasVariableNumberOfRows: false, | |
| numberOfRows: 1, | |
| artworkInfo: "fixed", | |
| title: "One" | |
| }, | |
| rowViewTwo: { | |
| image: { | |
| height: 190, | |
| padding: 9 | |
| }, | |
| zoom: { | |
| size: 50, | |
| image: { | |
| height: 402 | |
| } | |
| }, | |
| minHeight: 232, | |
| maxHeight: 512, | |
| hasVariableNumberOfRows: false, | |
| numberOfRows: 2, | |
| artworkInfo: "popup", | |
| title: "Two" | |
| }, | |
| rowViewMulti: { | |
| image: { | |
| height: 106, | |
| padding: 9 | |
| }, | |
| zoom: { | |
| size: 25, | |
| image: { | |
| height: 232 | |
| } | |
| }, | |
| minHeight: 106, | |
| maxHeight: 232, | |
| hasVariableNumberOfRows: true, | |
| numberOfRows: 4, | |
| artworkInfo: "popup", | |
| title: "Multi" | |
| }, | |
| singleArtworkView: { | |
| zoom: { | |
| size: 70, | |
| useAnchorPosition: true, | |
| image: { | |
| height: 300 | |
| } | |
| } | |
| }, | |
| rowViewBookmarks: { | |
| image: { | |
| height: 106, | |
| padding: 9 | |
| }, | |
| zoom: { | |
| size: 25, | |
| image: { | |
| height: 232 | |
| } | |
| }, | |
| minHeight: 106, | |
| maxHeight: 106, | |
| hasVariableNumberOfRows: true, | |
| numberOfRows: 4, | |
| artworkInfo: "popup", | |
| title: "Bookmarks" | |
| }, | |
| }; | |
| ap.bookmarks.CreateBookmark = Backbone.View.extend({ | |
| el: $(".add-to-collection-content"), | |
| events: { | |
| "submit #add-bookmark": "createNewBookmark", | |
| "click a.create-new": "createNewGroupSidebar" | |
| }, | |
| getTpl: function (a) { | |
| return _.template($(a).html()) | |
| }, | |
| jScrollPane: null, | |
| initialize: function (b) { | |
| var a = this; | |
| _.bindAll(this, "getGroupById", "reinitialiseScrollPane", "applyTpl", "setupJScrollPane", "addNewlyLoaded"); | |
| a.bookmarkGroups = new ap.UserBookmarkGroupList(); | |
| a.bookmarkGroups.bind("addNewlyLoaded", a.addNewlyLoaded); | |
| a.$scrollPane = $(a.el).find(".scroll-pane"); | |
| a.setupJScrollPane(); | |
| $(window).smartresize(a.reinitialiseScrollPane); | |
| a.options.sidebar.el.bind("resize", a.reinitialiseScrollPane); | |
| $(a.el).on("change", "input:radio", | |
| function (c) { | |
| $(a.el).find("li").removeClass("selected"); | |
| $(c.target).closest("li").addClass("selected") | |
| }); | |
| a.bookmarkGroups.fetchBunch() | |
| }, | |
| addNewlyLoaded: function () { | |
| var a = this, | |
| c = a.el.find("ul.collections"), | |
| d = c.children(".loading-more"), | |
| b = a.getTpl("#sidebar_new_bookmark_group-template"); | |
| _.each(a.bookmarkGroups.newlyAdded, | |
| function (f, e) { | |
| d.before(b({ | |
| bookmark_group: f.attributes | |
| })) | |
| }); | |
| if (!a.bookmarkGroups.nextUrl) { | |
| d.remove() | |
| } | |
| a.calculateHeights(); | |
| a.reinitialiseScrollPane(); | |
| a.bookmarkGroups.nextPage() | |
| }, | |
| getGroupById: function (a) { | |
| var b = this; | |
| var c = _.filter(b.bookmarkGroups.models, | |
| function (d) { | |
| return d.get("id") == a | |
| }); | |
| return c[0] | |
| }, | |
| createNewGroupSidebar: function (d) { | |
| d.preventDefault(); | |
| var a = this; | |
| var e = new ap.UserBookmarkGroup(); | |
| this.bookmarkGroups.add(e); | |
| var c = $(d.currentTarget).parent(); | |
| var b = c.find(".spinner"); | |
| if (!b.size() > 0) { | |
| c.append('<span class="spinner"></span>') | |
| } else { | |
| b.fadeIn("fast") | |
| } | |
| e.save({ | |
| is_public: false | |
| }, { | |
| success: function (j, f) { | |
| a.applyTpl(j); | |
| c.find(".spinner").fadeOut("fast") | |
| }, | |
| error: function (j, f) { | |
| ap.log("bookmark group creation error"); | |
| c.find(".spinner").fadeOut("fast") | |
| } | |
| }) | |
| }, | |
| applyTpl: function (f) { | |
| var b = this, | |
| c = this.getTpl("#sidebar_new_bookmark_group-template"), | |
| d = this.getTpl("#sidebar_edit_bookmark_group-template"); | |
| var e = $(c({ | |
| bookmark_group: f.attributes | |
| })); | |
| $("ul.collections li.unassigned").after(e); | |
| $(b.el).find("li").removeClass("selected"); | |
| e.addClass("selected").find('input[type="radio"]').attr("checked", true); | |
| if (!$(".edit-prompt").length) { | |
| $(".bookmark-collections").append(d({ | |
| bookmarkDashboardUrl: $("#my-galleries-toplink").attr("href") | |
| })).show() | |
| } | |
| var a = new ap.globals.InlineRename({ | |
| el: e, | |
| model: f, | |
| target_element: "span", | |
| replace: "name", | |
| target_default: TRANSLATIONS.untitled_set, | |
| auto_edit: true, | |
| replace_parent: true | |
| }); | |
| a.addEditClass(); | |
| b.reinitialiseScrollPane() | |
| }, | |
| createNewBookmark: function (e) { | |
| ap.log("Saving"); | |
| e.preventDefault(); | |
| var c = this; | |
| var d = $("form#add-bookmark input:checked").val(); | |
| var b = d != "" ? this.getGroupById(d) : false; | |
| this.options.sidebar.closeSidebar(); | |
| var a = c.addBookmark(b) | |
| }, | |
| addBookmark: function (b) { | |
| var e = (app.microscope && app.microscope.microscope) ? app.microscope.microscope.GetState() : $(".add-to-collection-content").data("zoomState"); | |
| var d = { | |
| artwork: ap.buildApiUrl(["artwork", $("body").data("artwork-id")], false, false, true), | |
| part_x: e.x, | |
| part_y: e.y, | |
| part_zoom: e.z | |
| }; | |
| if (b !== false) { | |
| d.bookmark_group = b.get("resource_uri"); | |
| d.weight = 1024 * (b.get("list_length") + 1) | |
| } | |
| var c = $("#bookmark-comment").val(); | |
| if (c.match(/^[ \t]*$/) ? false : true) { | |
| d.comment = c | |
| } | |
| var a = new ap.UserBookmark(d); | |
| a.save({}, { | |
| success: function (j, f) { | |
| ap.log("saved!"); | |
| ap.trackAddToGallery({ | |
| aw_slug: $("body").data("artwork-slug"), | |
| aw_id: $("body").data("artwork-id"), | |
| source: "sidebar" | |
| }, ap.getMuseumAnalyticsId()); | |
| if (b === false) { | |
| ap.bookmarks.updateUnassignedCount(1) | |
| } | |
| $("#bookmark-comment").val(""); | |
| return a | |
| }, | |
| error: function (j, f) { | |
| ap.log("Could not save new bookmark"); | |
| return | |
| }, | |
| noGet: true | |
| }) | |
| }, | |
| calculateHeights: function () { | |
| var b = $(this.el); | |
| var c = b.find(".bookmarks-wrapper"); | |
| var a = b.find(".existing-groups-outer-wrapper"); | |
| a.hide(); | |
| var d = b.outerHeight(true) - c.outerHeight(true); | |
| a.css({ | |
| height: d + "px" | |
| }); | |
| a.show() | |
| }, | |
| reinitialiseScrollPane: function () { | |
| ap.log("Logging!"); | |
| this.calculateHeights(); | |
| this.jScrollPane.reinitialise() | |
| }, | |
| setupJScrollPane: function () { | |
| this.calculateHeights(); | |
| this.$scrollPane.pScrollPane(); | |
| this.jScrollPane = this.$scrollPane.data("jsp") | |
| } | |
| }); | |
| var g = !0, | |
| h = null, | |
| i = !1; | |
| ap.e = function (b, d) { | |
| this.u = 1 === (new Int8Array((new Int32Array([1])).buffer))[0]; | |
| this.h = new Uint8Array(8); | |
| this.buffer = b; | |
| this.f = d || 0; | |
| this.length = this.buffer.byteLength - this.f; | |
| if (0 > this.f || 0 > this.length || this.f + this.length > this.buffer.byteLength) { | |
| throw Error("Illegal offset and/or length") | |
| } | |
| Object.defineProperties(this, { | |
| buffer: { | |
| value: this.buffer, | |
| enumerable: i, | |
| writable: i, | |
| configurable: i | |
| }, | |
| byteOffset: { | |
| value: this.f, | |
| enumerable: i, | |
| writable: i, | |
| configurable: i | |
| }, | |
| byteLength: { | |
| value: this.length, | |
| enumerable: i, | |
| writable: i, | |
| configurable: i | |
| }, | |
| m: { | |
| value: new Uint8Array(this.buffer, this.f, this.length), | |
| enumerable: i, | |
| writable: i, | |
| configurable: i | |
| } | |
| }); | |
| return this | |
| }; | |
| ap.e.prototype.get = function (j, m, l, f, k) { | |
| if (void 0 === f) { | |
| throw Error("Missing required offset argument") | |
| } | |
| if (0 > f || f + l > j.byteLength) { | |
| throw Error("Invalid index: " + f) | |
| } | |
| if (1 === l || !! k === this.u) { | |
| if (0 === (j.byteOffset + f) % l) { | |
| return (new m(j.buffer, j.byteOffset + f, 1))[0] | |
| } | |
| for (k = 0; k < l; k++) { | |
| this.h[k] = j.m[f + k] | |
| } | |
| return (new m(this.h.buffer))[0] | |
| } | |
| for (k = 0; k < l; k++) { | |
| this.h[l - k - 1] = j.m[f + k] | |
| } | |
| return (new m(this.h.buffer))[0] | |
| }; | |
| ap.e.prototype.getUint8 = function (b) { | |
| return this.get(this, Uint8Array, 1, b, h) | |
| }; | |
| ap.e.prototype.getUint16 = function (b, d) { | |
| return this.get(this, Uint16Array, 2, b, d) | |
| }; | |
| ap.e.prototype.getFloat32 = function (b, d) { | |
| return this.get(this, Float32Array, 4, b, d) | |
| }; | |
| ap.l = function (b, d) { | |
| this.r = b / (2 * Math.PI); | |
| this.s = 1 / this.r; | |
| this.z = d / Math.PI; | |
| this.A = 1 / this.z; | |
| this.g = {}; | |
| return this | |
| }; | |
| ap.l.prototype.i = function (k, o) { | |
| var n = (o + 0.5) * this.A, | |
| j = Math.sin(n), | |
| n = Math.cos(n), | |
| m = 1.5 * Math.PI - k * this.s, | |
| l = Math.sin(m); | |
| this.g.x = j * Math.cos(m); | |
| this.g.y = j * l; | |
| this.g.B = n; | |
| return this.g | |
| }; | |
| ap.b = function () { | |
| this.d = this.c = 0; | |
| this.k = this.a = this.j = h; | |
| return this | |
| }; | |
| ap.b.C = 256; | |
| ap.b.prototype.w = function (u) { | |
| u = new ap.e(u.buffer, 0); | |
| if (8 != u.getUint8(0)) { | |
| return i | |
| } | |
| var s = u.getUint16(1, g), | |
| r = u.getUint16(3, g), | |
| t = u.getUint16(5, g); | |
| if (this.c != r || this.d != t) { | |
| this.c = r, this.d = t, this.j = new Uint8Array(r * t), this.k = new ap.l(r, t) | |
| } | |
| if ((this.a ? this.a.length / 4 : 0) != s) { | |
| this.a = 0 < s ? new Float32Array(4 * s) : h | |
| } | |
| var q = u.getUint8(7); | |
| if (8 != q) { | |
| return i | |
| } | |
| for (var p = this.c * this.d, r = 0, t = q; r < p; ++r, ++t) { | |
| this.j[r] = u.getUint8(t) | |
| } | |
| r = 0; | |
| for (t = q + p; r < s; r++) { | |
| var q = u.getFloat32(t, g), | |
| t = t + 4, | |
| o = u.getFloat32(t, g), | |
| t = t + 4, | |
| n = u.getFloat32(t, g), | |
| t = t + 4, | |
| m = u.getFloat32(t, g), | |
| t = t + 4; | |
| p = r; | |
| if (!(p >= (this.a ? this.a.length / 4 : 0))) { | |
| p *= 4, this.a[p++] = q, this.a[p++] = o, this.a[p++] = n, this.a[p++] = m | |
| } | |
| } | |
| return g | |
| }; | |
| ap.b.prototype.n = function (b, f, e) { | |
| b = Math.floor(b + 0.5); | |
| f = Math.floor(f + 0.5); | |
| b >= this.c ? b -= this.c : 0 > b && (b += this.c); | |
| f >= this.d ? f -= this.d : 0 > f && (f += this.d); | |
| e && (e[0] = b, e[1] = f); | |
| return this.j[f * this.c + b] | |
| }; | |
| ap.b.prototype.p = function (l, q, p) { | |
| var k = this.n(l, q, h); | |
| if (0 == k) { | |
| return 0 | |
| } | |
| var k = 4 * k, | |
| o = this.a[k++], | |
| n = this.a[k++], | |
| m = this.a[k++], | |
| k = this.a[k++]; | |
| p && (p[0] = o, p[1] = n, p[2] = m); | |
| l = this.k.i(l, q); | |
| return k / (l.x * o + l.y * n + l.B * m) | |
| }; | |
| ap.b.prototype.i = function (b, d) { | |
| return this.k.i(b, d) | |
| }; | |
| ap.b.D = function () { | |
| for (var f = new Uint8Array(768), k = 0, j = 0; 256 > j; j++) { | |
| var e = j / 255, | |
| e = ap.b.t(0 * (1 - e) + 240 * e); | |
| f[k++] = e.v; | |
| f[k++] = e.q; | |
| f[k++] = e.o | |
| } | |
| return f | |
| }; | |
| ap.b.t = function (k) { | |
| var o = k / 60, | |
| k = Math.floor(o), | |
| n = o - k, | |
| o = 1 * (1 - 1 * n), | |
| n = 1 * (1 - 1 * (1 - n)), | |
| j, m, l; | |
| switch (k % 6) { | |
| case 0: | |
| j = 1; | |
| m = n; | |
| l = 0; | |
| break; | |
| case 1: | |
| j = o; | |
| m = 1; | |
| l = 0; | |
| break; | |
| case 2: | |
| j = 0; | |
| m = 1; | |
| l = n; | |
| break; | |
| case 3: | |
| j = 0; | |
| m = o; | |
| l = 1; | |
| break; | |
| case 4: | |
| j = n; | |
| m = 0; | |
| l = 1; | |
| break; | |
| case 5: | |
| j = 1, m = 0, l = o | |
| } | |
| return { | |
| v: Math.round(255 * j), | |
| q: Math.round(255 * m), | |
| o: Math.round(255 * l) | |
| } | |
| }; | |
| ap.DepthMap = ap.b; | |
| ap.DepthMap.prototype.computeDepthAndNormal = ap.DepthMap.prototype.p; | |
| ap.DepthMap.prototype.readBinaryData = ap.DepthMap.prototype.w; | |
| ap.DepthMap.prototype.getPlaneIndex = ap.DepthMap.prototype.n; | |
| ap.namespace("ap.streetview").Annotation = Backbone.View.extend({ | |
| template: '<a id="<%=iconId%>" href="<%=url%>" title="<%=title%>" class="<%=className%>"><span></span><%=title%></a>', | |
| events: { | |
| click: "trackClickEvent" | |
| }, | |
| relativePosition: {}, | |
| distance: 0, | |
| shape: null, | |
| initialize: function () { | |
| _.bindAll(this, "render", "trackClickEvent", "isVisible", "setSizeAndLocation"); | |
| this.panoid = this.options.pano; | |
| this.level = this.options.level; | |
| this.lat = this.options.lat; | |
| this.lng = this.options.lng; | |
| this.elevation = this.options.height - 2.1435; | |
| this.direction = this.options.dir; | |
| this.artwork_id = this.options.artwork_id; | |
| this.url = ap.getLocaleUrl(this.options.url) + "#ref=annotation"; | |
| this.title = this.options.title; | |
| this.iconId = this.id = "infoPoint_" + this.options.id; | |
| this.className = "point" + (this.options.gigaPixel ? " giga" : ""); | |
| return this | |
| }, | |
| withinRoom: function () { | |
| if (this.level != app.streetview.currentLevel) { | |
| return false | |
| } | |
| var a = app.streetview.floorPlan.roomLookup[this.panoid]; | |
| if (a && a == app.streetview.floorPlan.currentRoom()) { | |
| return true | |
| } else { | |
| return false | |
| } | |
| }, | |
| withinDistance: function () { | |
| if (this.distance > 15) { | |
| return false | |
| } | |
| var a = app.streetview.calculateDepth(this.relativePosition.yaw, this.relativePosition.pitch); | |
| if (a == 0) { | |
| return true | |
| } | |
| if (this.distance < a + 0.3) { | |
| return true | |
| } else { | |
| return false | |
| } | |
| }, | |
| withinAngle: function () { | |
| if (this.direction == 0) { | |
| return true | |
| } | |
| var a = this.relativePosition.yaw - this.direction; | |
| while (a < -180) { | |
| a += 360 | |
| } | |
| while (a > 180) { | |
| a -= 360 | |
| } | |
| if (Math.abs(a) < 80) { | |
| return true | |
| } else { | |
| return false | |
| } | |
| }, | |
| isVisible: function () { | |
| return this.withinRoom() && this.withinAngle() && this.withinDistance() | |
| }, | |
| setSizeAndLocation: function () { | |
| var a = app.streetview.pano.getScreenPoint(this.relativePosition); | |
| var b = 16 - Math.ceil(this.distance); | |
| if (!a) { | |
| a = { | |
| x: 0, | |
| y: 0 | |
| }; | |
| b = 0 | |
| } | |
| this.el.css({ | |
| left: a.x, | |
| top: a.y, | |
| width: b, | |
| height: b | |
| }).stop().show(); | |
| this.el.find("span").css({ | |
| width: b, | |
| height: b | |
| }) | |
| }, | |
| hide: function (a) { | |
| if (_.isUndefined(a)) { | |
| a = false | |
| } | |
| if (a) { | |
| this.el.stop().fadeOut("slow") | |
| } else { | |
| this.el.stop().hide() | |
| } | |
| }, | |
| show: function (a) { | |
| if (_.isUndefined(a)) { | |
| a = false | |
| } | |
| if (a) { | |
| this.el.stop().fadeIn("slow") | |
| } else { | |
| this.el.stop().show() | |
| } | |
| }, | |
| setRelativePosition: function (a) { | |
| this.distance = ap.geo_distance(this.lat, this.lng, a.lat(), a.lng()); | |
| this.relativePosition = { | |
| yaw: ap.geo_bearing(this.lat, this.lng, a.lat(), a.lng()) - 180, | |
| pitch: -Math.atan2(this.elevation, this.distance) * (180 / Math.PI) | |
| } | |
| }, | |
| trackClickEvent: function (a) { | |
| var b = this; | |
| a.preventDefault(); | |
| window.app.streetview.updateCookies(function () { | |
| setTimeout('document.location = "' + b.url + '"', 200) | |
| }) | |
| }, | |
| render: function () { | |
| var a = { | |
| iconId: this.iconId, | |
| url: this.url, | |
| title: this.title, | |
| className: this.className | |
| }; | |
| this.el = $(_.template(this.template, a)); | |
| this.el.click(this.trackClickEvent); | |
| return this | |
| } | |
| }); | |
| ap.namespace("ap.streetview").FloorPlan = Backbone.View.extend({ | |
| el: $("#sidebar .floorplan-content"), | |
| events: { | |
| "click a.level": "changeLevel" | |
| }, | |
| title: null, | |
| map: null, | |
| mapContainer: $("#floorplan"), | |
| mapsLoaded: false, | |
| mapOptions: { | |
| zoom: 20, | |
| mapTypeId: "roadmap", | |
| mapTypeControl: false, | |
| streetViewControl: false, | |
| panControl: false, | |
| disableDoubleClickZoom: true, | |
| styles: [{ | |
| stylers: [{ | |
| lightness: -100 | |
| }, { | |
| hue: "#000000" | |
| }] | |
| }] | |
| }, | |
| roomStates: { | |
| normal: { | |
| fillColor: "#2f2f2f" | |
| }, | |
| interactive: { | |
| fillColor: "#666" | |
| }, | |
| selected: { | |
| fillColor: "#ebb52d" | |
| }, | |
| hover: { | |
| fillColor: "#c6a34f" | |
| } | |
| }, | |
| polygonOptions: { | |
| strokeColor: "#000", | |
| strokeOpacity: 0.8, | |
| strokeWeight: 1, | |
| fillColor: "#2f2f2f", | |
| fillOpacity: 1, | |
| }, | |
| circleOptions: { | |
| fillColor: "#ebb52d", | |
| fillOpacity: 1, | |
| strokeColor: "#ebb52d", | |
| strokeWeight: 1, | |
| radius: 3 | |
| }, | |
| pointsUrlBase: "/levels/%s/panoramas.json", | |
| floorplanUrlBase: "/levels/%s/floorplan.json", | |
| levels: {}, | |
| rooms: [], | |
| allRooms: [], | |
| coordinates: [], | |
| currentSelectedRoom: null, | |
| latLngArray: [], | |
| rendered: false, | |
| alwaysFitToBounds: true, | |
| currentKml: null, | |
| currentRef: null, | |
| currentPointCircle: null, | |
| currentPointMarker: null, | |
| usePositionCircle: false, | |
| usePositionMarker: true, | |
| roomsCleared: false, | |
| firstTime: true, | |
| comingFromLevelButton: false, | |
| roomLookup: {}, | |
| initialize: function () { | |
| _.bindAll(this, "render", "loadKML", "parseKML", "changeLevel", "levelChanged", "drawShape", "loadPoints", "loadFloorPlan", "checkBounds"); | |
| this.streetview = this.options.streetview; | |
| this.title = $(this.el).find("h2").eq(0); | |
| window.ap.events.bind("pano:changed", this.panoChanged, this); | |
| window.ap.events.bind("pano:levelChanged", this.levelChanged, this) | |
| }, | |
| getFloorplanUrl: function () { | |
| return this.floorplanUrlBase.replace("%s", this.currentRef) | |
| }, | |
| getPointsUrl: function () { | |
| return this.pointsUrlBase.replace("%s", this.currentRef) | |
| }, | |
| drawShape: function (f) { | |
| var b = this; | |
| var e = []; | |
| var j, d, c; | |
| _.each(f, | |
| function (k) { | |
| j = k[1]; | |
| d = k[0]; | |
| c = new google.maps.LatLng(j, d); | |
| e.push(c); | |
| b.activeLevel.latLngArray.push(c) | |
| }); | |
| var a = new google.maps.Polygon(b.polygonOptions); | |
| a.setOptions({ | |
| paths: e, | |
| zIndex: 4 | |
| }); | |
| a.setMap(b.map); | |
| return a | |
| }, | |
| createMap: function () { | |
| var a = this; | |
| a.map = new google.maps.Map(a.mapContainer.get(0), a.mapOptions); | |
| google.maps.event.addListener(a.map, "dragend", a.checkBounds) | |
| }, | |
| checkBounds: function () { | |
| if (!this.shapeBounds.contains(this.map.getCenter())) { | |
| if (this.usePositionCircle) { | |
| this.map.setCenter(this.currentPointCircle.getCenter()) | |
| } else { | |
| if (this.usePositionMarker) { | |
| this.map.setCenter(this.currentPointMarker.getPosition()) | |
| } else { | |
| this.map.setCenter(this.shapeBounds.getCenter()) | |
| } | |
| } | |
| } | |
| }, | |
| levelChanged: function (a) { | |
| ap.log("levelChanged"); | |
| this.currentRef = a.currentLevel; | |
| $(this.el).find("a.level.active").removeClass("active"); | |
| var b = $("#level" + this.currentRef); | |
| b.addClass("active"); | |
| if (!this.comingFromLevelButton) { | |
| this.title.addClass("loading") | |
| } | |
| this.comingFromLevelButton = false; | |
| this.render() | |
| }, | |
| changeLevel: function (a) { | |
| ap.log("changeLevel"); | |
| var b = this; | |
| if (b.rendered) { | |
| b.title.addClass("loading"); | |
| b.comingFromLevelButton = true; | |
| b.rendered = false; | |
| b.roomsCleared = false; | |
| var c = $(a.currentTarget); | |
| b.currentRef = c.data("level-id"); | |
| $(b.el).find("a.level.active").removeClass("active"); | |
| c.addClass("active"); | |
| b.streetview.moveToPano(c.data("pano-id")); | |
| b.loadKML() | |
| } else { | |
| ap.log("Can't change, I'm busy!") | |
| } | |
| return false | |
| }, | |
| getMarkerImage: function (a, b, c) { | |
| if (_.isUndefined(c)) { | |
| c = 0 | |
| } | |
| return new google.maps.MarkerImage(a, new google.maps.Size(b, b), new google.maps.Point(b * c, 0), new google.maps.Point((b - 1) / 2, (b - 1) / 2)) | |
| }, | |
| angleToOffset: function (d, c) { | |
| if (_.isUndefined(c)) { | |
| c = 5 | |
| } | |
| var a = 360 / c; | |
| var b = Math.round(d / c) % a; | |
| return b | |
| }, | |
| createMarker: function (a, d) { | |
| var c = this.getMarkerImage("/skip_media_generator/radar_sprite.png", 57, this.angleToOffset(d) + 1); | |
| var b = new google.maps.Marker({ | |
| position: new google.maps.LatLng(a.lat(), a.lng()), | |
| icon: c, | |
| clickable: true, | |
| zIndex: 5 | |
| }); | |
| return b | |
| }, | |
| position Circle: function (b) { | |
| var a = this; | |
| if (a.currentPointCircle) { | |
| a.currentPointCircle.setMap(null) | |
| } | |
| a.currentPointCircle = new google.maps.Circle(a.circleOptions); | |
| a.currentPointCircle.setMap(a.map); | |
| a.currentPointCircle.setCenter(b) | |
| }, | |
| positionMarker: function (c, d) { | |
| var a = this; | |
| if (a.currentPointMarker) { | |
| var b = a.getMarkerImage("/skip_media_generator/radar_sprite.png", 57, this.angleToOffset(d)); | |
| a.currentPointMarker.setIcon(b) | |
| } else { | |
| a.currentPointMarker = this.createMarker(c, d) | |
| } | |
| if (!a.currentPointMarker.map) { | |
| a.currentPointMarker.setMap(a.map) | |
| } | |
| a.currentPointMarker.setPosition(c) | |
| }, | |
| panoChanged: function () { | |
| var b = this; | |
| if (!b.map) { | |
| return | |
| } | |
| var c = b.currentLatLng(); | |
| if (b.usePositionCircle) { | |
| b.positionCircle(c) | |
| } else { | |
| if (b.usePositionMarker) { | |
| b.positionMarker(c, b.streetview.pano.getPOV().yaw) | |
| } else { | |
| var a = false; | |
| _.each(b.activeLevel.interactiveRooms, | |
| function (e, d) { | |
| var f = e.SignedDistanceTo(c); | |
| if (f < 0.1) { | |
| a = true; | |
| b.changeRoom(e); | |
| return false | |
| } | |
| }) | |
| } | |
| } | |
| }, | |
| changeRoom: function (b) { | |
| var a = this; | |
| if (!a.usePositionCircle && !a.usePositionMarker) { | |
| if (a.currentSelectedRoom && a.currentSelectedRoom !== b) { | |
| a.dehighlightRoom(a.currentSelectedRoom, true); | |
| a.currentSelectedRoom.selected = false | |
| } | |
| b.setOptions(a.roomStates.selected); | |
| b.selected = true; | |
| a.currentSelectedRoom = b | |
| } | |
| }, | |
| currentRoom: function () { | |
| return this.roomLookup[app.streetview.currentPano] | |
| }, | |
| clickRoom: function (c) { | |
| var b = this; | |
| var a = {}; | |
| var d = null; | |
| $.each(b.activeLevel.points, | |
| function (f, e) { | |
| a[f] = c.SignedDistanceTo(new google.maps.LatLng(e.lat, e.lng)); | |
| if (!d || a[f] < a[d]) { | |
| d = f | |
| } | |
| }); | |
| b.streetview.moveToPano(d) | |
| }, | |
| highlightRoom: function (a, b) { | |
| if (b || !a.selected) { | |
| a.setOptions(this.roomStates.hover) | |
| } | |
| }, | |
| dehighlightRoom: function (b, a) { | |
| if (a || !b.selected) { | |
| if (b.interactive) { | |
| b.setOptions(this.roomStates.interactive) | |
| } else { | |
| b.setOptions(this.roomStates.normal) | |
| } | |
| } | |
| }, | |
| clearRooms: function () { | |
| var a = this; | |
| if (a.currentPointCircle) { | |
| a.currentPointCircle.setMap(null) | |
| } | |
| if (a.activeLevel) { | |
| $.each(a.activeLevel.rooms, | |
| function (b, c) { | |
| c.setMap(null); | |
| google.maps.event.clearListeners(c, "click"); | |
| google.maps.event.clearListeners(c, "mouseover"); | |
| google.maps.event.clearListeners(c, "mouseout") | |
| }); | |
| a.roomsCleared = true | |
| } | |
| }, | |
| createNewLevel: function (a) { | |
| return { | |
| levelId: a, | |
| rooms: [], | |
| interactiveRooms: [], | |
| points: null, | |
| latLngArray: [], | |
| floorPlan: [], | |
| coordinates: [] | |
| } | |
| }, | |
| loadFloorPlan: function () { | |
| var a = this; | |
| $.ajax({ | |
| url: a.getFloorplanUrl(), | |
| success: function (b) { | |
| a.activeLevel.floorPlan = b; | |
| a.parseKML() | |
| } | |
| }) | |
| }, | |
| loadPoints: function () { | |
| var a = this; | |
| $.ajax({ | |
| url: a.getPointsUrl(), | |
| dataType: "json", | |
| success: function (b) { | |
| a.activeLevel.points = b; | |
| a.loadFloorPlan() | |
| } | |
| }) | |
| }, | |
| loadKML: function () { | |
| var a = this; | |
| app.streetview.floorplanReady = false; | |
| a.clearRooms(); | |
| if (!a.currentRef) { | |
| a.currentRef = a.streetview.currentLevel | |
| } | |
| if (_.isUndefined(a.levels[a.currentRef])) { | |
| a.levels[a.currentRef] = a.createNewLevel(a.currentRef) | |
| } | |
| a.activeLevel = a.levels[a.currentRef]; | |
| if (!a.activeLevel.points) { | |
| a.loadPoints() | |
| } else { | |
| a.parseKML() | |
| } | |
| }, | |
| currentLatLng: function () { | |
| var a = this.activeLevel.points[app.streetview.currentPano]; | |
| return new google.maps.LatLng(a.lat, a.lng) | |
| }, | |
| parseKML: function () { | |
| var a = this; | |
| if (!a.map) { | |
| a.createMap() | |
| } | |
| if (!a.activeLevel) { | |
| return | |
| } | |
| a.shapeBounds = null; | |
| if (a.activeLevel.coordinates.length) { | |
| ap.log("skipping parse") | |
| } else { | |
| $.each(a.activeLevel.floorPlan, | |
| function (b, c) { | |
| if (c.length > 0) { | |
| a.activeLevel.coordinates.push(c) | |
| } | |
| }) | |
| } | |
| if (a.activeLevel.rooms.length) { | |
| ap.log("skipping room generation"); | |
| _.each(a.activeLevel.rooms, | |
| function (b) { | |
| b.setOptions(a.roomStates.normal); | |
| b.setMap(a.map); | |
| if (b.interactive) { | |
| b.setOptions(a.roomStates.interactive); | |
| google.maps.event.addListener(b, "mouseover", | |
| function () { | |
| a.highlightRoom(b) | |
| }); | |
| google.maps.event.addListener(b, "mouseout", | |
| function () { | |
| a.dehighlightRoom(b) | |
| }); | |
| google.maps.event.addListener(b, "click", | |
| function () { | |
| a.clickRoom(b) | |
| }) | |
| } | |
| }) | |
| } else { | |
| _.each(a.activeLevel.coordinates, | |
| function (c, b) { | |
| var d = a.drawShape(c); | |
| d.setOptions(a.roomStates.normal); | |
| a.activeLevel.rooms.push(d); | |
| if (a.checkInteractivity(d)) { | |
| a.activeLevel.interactiveRooms.push(d); | |
| d.setOptions(a.roomStates.interactive); | |
| d.interactive = true; | |
| google.maps.event.addListener(d, "mouseover", | |
| function () { | |
| a.highlightRoom(d) | |
| }); | |
| google.maps.event.addListener(d, "mouseout", | |
| function () { | |
| a.dehighlightRoom(d) | |
| }); | |
| google.maps.event.addListener(d, "click", | |
| function () { | |
| a.clickRoom(d) | |
| }) | |
| } | |
| }) | |
| } | |
| a.panoChanged(); | |
| if (a.alwaysFitToBounds) { | |
| a.fitToView() | |
| } | |
| a.rendered = true; | |
| a.title.removeClass("loading"); | |
| app.streetview.floorplanReady = true; | |
| app.streetview.loadAnnotations() | |
| }, | |
| checkInteractivity: function (c) { | |
| var b = this; | |
| var a = false; | |
| if (this.activeLevel.points) { | |
| c.points = []; | |
| $.each(this.activeLevel.points, | |
| function (e, d) { | |
| var f = new google.maps.LatLng(d.lat, d.lng); | |
| if (c.getPath()) { | |
| if (c.SignedDistanceTo(f) < 0.1) { | |
| c.points.push(f); | |
| b.roomLookup[e] = c; | |
| a = true | |
| } | |
| } | |
| }) | |
| } | |
| return a | |
| }, | |
| fitToView: function () { | |
| var a = this; | |
| a.shapeBounds = new google.maps.LatLngBounds(); | |
| _.each(a.activeLevel.latLngArray, | |
| function (b, c) { | |
| a.shapeBounds.extend(b) | |
| }); | |
| a.map.fitBounds(a.shapeBounds); | |
| a.map.setCenter(a.shapeBounds.getCenter()) | |
| }, | |
| loadMapsAPI: function () { | |
| callbackName = "app.streetview.floorPlan.mapsLoadCallback"; | |
| if (_.isUndefined(window.google.maps) || _.isUndefined(window.google.maps.Geocoder)) { | |
| var b = ap.getMapsApiKey(); | |
| var a = "//maps.googleapis.com/maps/api/js?key=" + b + "&sensor=false&callback=" + callbackName; | |
| $('<script src="' + a + '">').appendTo($("body")) | |
| } else { | |
| this.mapsLoadCallback() | |
| } | |
| }, | |
| mapsLoadCallback: function () { | |
| var a = this; | |
| $.ajax({ | |
| url: "/skip_media_generator/google.maps.Polygon.js", | |
| dataType: "script", | |
| cache: true, | |
| success: function () { | |
| a.mapsLoaded = true; | |
| a.render() | |
| } | |
| }) | |
| }, | |
| render: function () { | |
| var a = this; | |
| if (this.mapsLoaded) { | |
| if (this.streetview.currentLevel) { | |
| if (!this.activeLevel || this.streetview.currentLevel != this.activeLevel.levelId) { | |
| this.loadKML() | |
| } | |
| } else { | |
| ap.log("streetview.currentLevel does NOT exists"); | |
| if (ap.debugMode) { | |
| this.loadKML() | |
| } | |
| } | |
| } else { | |
| this.loadMapsAPI() | |
| } | |
| } | |
| }); | |
| ap.namespace("ap.streetview").MainView = Backbone.View.extend({ | |
| el: $("#streetview"), | |
| events: { | |
| mousemove: "setAnnotationFadeoutTimer", | |
| keypress: "setAnnotationFadeoutTimer", | |
| "click .navigate_floorplan": "toggleSidebar" | |
| }, | |
| addNavigateFloorplanButtonTemplate: '<a href="#" class="navigate_floorplan"><%=TRANSLATIONS.close_floorplan%></a>', | |
| initialized: false, | |
| readyToLoad: false, | |
| room: null, | |
| annotationsById: {}, | |
| annotations: [], | |
| visibleAnnotations: [], | |
| panoramaOptions: { | |
| povUpdateFreq: 0.2, | |
| features: { | |
| streetView: true, | |
| userPhotos: false | |
| }, | |
| enableFullScreen: false | |
| }, | |
| POV: { | |
| yaw: 0, | |
| pitch: 0, | |
| }, | |
| depthMap: null, | |
| floorPlan: null, | |
| updateTimer: null, | |
| updateDelay: 400, | |
| annotationFadeoutTimer: null, | |
| annotationFadeoutDelay: 1000, | |
| disableAnnotationFadeout: false, | |
| currentUrl: null, | |
| locationData: null, | |
| initialize: function () { | |
| _.bindAll(this, "render", "changedPano", "updateStreetview", "updateCookies", "streetviewUpdated", "setAnnotationFadeoutTimer", "toggleSidebar"); | |
| this.sidebar = this.options.sidebar; | |
| this.floorPlan = new ap.streetview.FloorPlan({ | |
| streetview: this | |
| }); | |
| if (this.options.encodedLocation) { | |
| this.locationData = $.base64.decode(this.options.encodedLocation).split("|") | |
| } | |
| return this | |
| }, | |
| createResponseForPanoId: function (a) { | |
| return { | |
| code: GStreetviewClient.ReturnValues.SUCCESS, | |
| Location: { | |
| panoId: a | |
| } | |
| } | |
| }, | |
| handleNoFlash: function (a) { | |
| if (a == FLASH_UNAVAILABLE) { | |
| return | |
| } | |
| }, | |
| calculateDepth: function (e, d) { | |
| var a = this; | |
| e += 180 - a.offset; | |
| while (e < 0) { | |
| e += 360 | |
| } | |
| while (e >= 360) { | |
| e -= 360 | |
| } | |
| d *= -1; | |
| d += 90; | |
| var c = 512 * e / 360; | |
| var b = 256 * d / 180; | |
| return a.depthMap.computeDepthAndNormal(c, b) | |
| }, | |
| constructDepthPolygon: function () { | |
| var m = this; | |
| var a = []; | |
| var j = m.currentLatLng.lat() * Math.PI / 180; | |
| var k = m.currentLatLng.lng() * Math.PI / 180; | |
| for (i = 0; i < 360; i++) { | |
| var b = m.calculateDepth(i, 0); | |
| if (b == 0) { | |
| b = m.calculateDepth(i, - 5) | |
| } | |
| if (b == 0) { | |
| b = m.calculateDepth(i, 5) | |
| } | |
| if (b == 0) { | |
| b = 15 | |
| } | |
| var c = b / 6371000; | |
| var l = i * Math.PI / 180; | |
| var e = Math.asin(Math.sin(j) * Math.cos(c) + Math.cos(j) * Math.sin(c) * Math.cos(l)); | |
| var f = k + Math.atan2(Math.sin(l) * Math.sin(c) * Math.cos(j), Math.cos(c) - Math.sin(j) * Math.sin(e)); | |
| a.push(new google.maps.LatLng(e * 180 / Math.PI, f * 180 / Math.PI)) | |
| } | |
| if (!m.depthShape) { | |
| m.depthShape = new google.maps.Polygon({ | |
| strokeColor: "#F00", | |
| strokeOpacity: 0.8, | |
| strokeWeight: 1, | |
| fillColor: "#FF0000", | |
| fillOpacity: 0.5, | |
| zIndex: 1001 | |
| }) | |
| } | |
| m.depthShape.setPath(a); | |
| m.depthShape.setMap(m.floorPlan.map) | |
| }, | |
| changedPano: function (f) { | |
| var l = this; | |
| l.readyToLoad = false; | |
| l.depthmapReady = false; | |
| l.currentPano = f.panoId; | |
| l.currentLatLng = new GLatLng(f.lat, f.lng); | |
| l.hideVisibleAnnotations(); | |
| l.visibleAnnotations = []; | |
| if (!l.initialized && !l.fromCookies) { | |
| var d = l.el.data("yaw"); | |
| var a = l.el.data("pitch"); | |
| var e = l.el.data("zoom"); | |
| if (d || a || e) { | |
| l.POV = { | |
| yaw: parseFloat(d), | |
| pitch: parseFloat(a), | |
| zoom: parseFloat(e) | |
| } | |
| } else { | |
| var j = l.el.data("lat") || 0; | |
| var k = l.el.data("lng") || 0; | |
| var b = l.el.data("height") || 2.1435; | |
| b -= 2.1435; | |
| var c = ap.geo_distance(j, k, l.currentLatLng.lat(), l.currentLatLng.lng()); | |
| l.POV = { | |
| yaw: ap.geo_bearing(j, k, l.currentLatLng.lat(), l.currentLatLng.lng()) - 180, | |
| pitch: -Math.atan2(b, c) * (180 / Math.PI) | |
| } | |
| } | |
| l.pano.setPOV(l.POV); | |
| l.initialized = true; | |
| window.ap.events.trigger("pano:init", l) | |
| } | |
| $.getJSON("/pano/?panoid=" + l.currentPano).success(function (p, n, o) { | |
| var m = o.getResponseHeader("Level"); | |
| if (m && m != l.currentLevel) { | |
| l.currentLevel = m; | |
| window.ap.events.trigger("pano:levelChanged", l) | |
| } else { | |
| window.ap.events.trigger("pano:changed", l) | |
| } | |
| if (!p || p.length < 10) { | |
| return | |
| } | |
| l.offset = o.getResponseHeader("Offset") || 0; | |
| var q = new Uint8Array(p); | |
| l.depthMap.readBinaryData(q); | |
| l.depthmapReady = true; | |
| l.loadAnnotations() | |
| }); | |
| l.updateStreetview() | |
| }, | |
| loadAnnotations: function () { | |
| var b = this; | |
| if (!b.depthmapReady || !b.floorplanReady) { | |
| return | |
| } | |
| if (ap.streetview_annotations) { | |
| var c; | |
| $.each(ap.streetview_annotations, | |
| function (f, e) { | |
| c = b.annotationsById[e.id]; | |
| if (_.isUndefined(c)) { | |
| c = new ap.streetview.Annotation(e); | |
| c.render(); | |
| b.el.append(c.el); | |
| b.annotationsById[e.id] = c; | |
| b.annotations.push(c) | |
| } | |
| c.setRelativePosition(b.currentLatLng) | |
| }); | |
| var b = this; | |
| var d = ["artwork", "set"]; | |
| var a = []; | |
| $.each(b.annotations, | |
| function (f, e) { | |
| if (e.isVisible()) { | |
| b.visibleAnnotations.push(e); | |
| a.push(e.artwork_id) | |
| } | |
| }); | |
| if (b.visibleAnnotations.length) { | |
| d.push(a.join(";")); | |
| apiUrl = ap.buildApiUrl(d); | |
| b.updateThumbnailStrip(apiUrl) | |
| } | |
| } else { | |
| ap.log("No annotation data") | |
| } | |
| b.readyToLoad = true; | |
| b.updateStreetview() | |
| }, | |
| updateThumbnailStrip: function (b) { | |
| var a = new ap.ArtworkList(null, { | |
| url: b | |
| }); | |
| if (!this.thumbnailStrip) { | |
| this.thumbnailStrip = new ap.thumbnailstrip.layout.Main({ | |
| id: "museumview-thumbnail-strip", | |
| container: this.el, | |
| parentView: this, | |
| settings: { | |
| showPivots: false, | |
| collectionToUse: a | |
| } | |
| }) | |
| } else { | |
| if (this.thumbnailStrip.artworkList.url != b) { | |
| this.thumbnailStrip.el.trigger("artworkListChange", [a]); | |
| this.thumbnailStrip.processManager.reset(); | |
| this.thumbnailStrip.processManager.start(); | |
| this.thumbnailStrip.artworkList.fetch() | |
| } else { | |
| ap.log("Thumbnailstrip: No need to fetch. Collection urls are the same.") | |
| } | |
| } | |
| }, | |
| hideVisibleAnnotations: function (b) { | |
| var a = this; | |
| if (_.isUndefined(b)) { | |
| b = false | |
| } | |
| $.each(a.visibleAnnotations, | |
| function (d, c) { | |
| c.hide(b) | |
| }) | |
| }, | |
| showHiddenVisibleAnnotations: function () { | |
| var a = this; | |
| $.each(a.visibleAnnotations, | |
| function (c, b) { | |
| b.show(true) | |
| }) | |
| }, | |
| updateStreetview: function () { | |
| var a = this; | |
| a.pano.checkResize(); | |
| if (a.readyToLoad) { | |
| _.each(a.visibleAnnotations, | |
| function (b) { | |
| b.setSizeAndLocation() | |
| }) | |
| } | |
| a.disableAnnotationFadeout = false; | |
| a.setAnnotationFadeoutTimer() | |
| }, | |
| updateCookies: function (e) { | |
| var a = this; | |
| var c = a.pano.getPOV(); | |
| var b = []; | |
| b.push(a.currentPano); | |
| b.push(c.zoom); | |
| b.push(c.yaw); | |
| b.push(c.pitch); | |
| var d = $.base64.encode(b.join("|")); | |
| ap.log(a.currentUrl + d); | |
| a.sidebar.parentView.router.navigate(a.currentUrl + d, false); | |
| if (e) { | |
| e() | |
| } | |
| }, | |
| streetviewUpdated: function () { | |
| var a = this; | |
| if (a.updateTimer) { | |
| clearTimeout(a.updateTimer); | |
| a.hideVisibleAnnotations() | |
| } | |
| if (a.annotationFadeoutTimer) { | |
| clearTimeout(a.annotationFadeoutTimer) | |
| } | |
| a.disableAnnotationFadeout = true; | |
| a.updateTimer = setTimeout(a.updateStreetview, a.updateDelay); | |
| if (a.floorPlan.usePositionMarker) { | |
| a.floorPlan.positionMarker(a.pano.getLatLng(), a.pano.getPOV().yaw) | |
| } | |
| }, | |
| setAnnotationFadeoutTimer: function () { | |
| var a = this; | |
| if (a.annotationFadeoutTimer) { | |
| clearTimeout(a.annotationFadeoutTimer); | |
| if (!a.disableAnnotationFadeout) { | |
| a.showHiddenVisibleAnnotations() | |
| } | |
| } | |
| if (!a.disableAnnotationFadeout) { | |
| a.annotationFadeoutTimer = setTimeout(function () { | |
| if (!a.disableAnnotationFadeout) { | |
| a.hideVisibleAnnotations(true) | |
| } | |
| }, a.annotationFadeoutDelay) | |
| } | |
| }, | |
| moveToPano: function (c, b) { | |
| var a = this; | |
| if (a.pano) { | |
| a.currentPano = c; | |
| a.pano.show(); | |
| a.pano.setLocationAndPOVFromServerResponse(a.createResponseForPanoId(c), b || a.POV); | |
| return a | |
| } | |
| }, | |
| show: function () { | |
| var a = this; | |
| a.el && a.el.show().addClass("active") | |
| }, | |
| hide: function () { | |
| var a = this; | |
| a.el && a.el.hide().removeClass("active") | |
| }, | |
| addNavigateFloorplanButton: function () { | |
| this.el.append(_.template(this.addNavigateFloorplanButtonTemplate)); | |
| this.navigateFloorplanButton = $(".navigate_floorplan").eq(0) | |
| }, | |
| toggleSidebar: function (a) { | |
| if (this.navigateFloorplanButton.text() == TRANSLATIONS.close_floorplan) { | |
| this.navigateFloorplanButton.text(TRANSLATIONS.navigate_floorplan) | |
| } else { | |
| this.navigateFloorplanButton.text(TRANSLATIONS.close_floorplan) | |
| } | |
| app.sidebar.toggleSidebar() | |
| }, | |
| render: function () { | |
| var a = this; | |
| a.currentUrl = window.location.pathname.replace("/", ""); | |
| a.currentPano = (typeof a.currentPano === "undefined" || a.currentPano === "undefined") ? a.el.data("panoid") : a.currentPano; | |
| a.depthMap = new ap.DepthMap(); | |
| a.initialized = false; | |
| a.pano = new GStreetviewPanorama(a.el.get(0), a.panoramaOptions); | |
| GEvent.addListener(a.pano, "error", a.handleNoFlash); | |
| GEvent.addListener(a.pano, "initialized", a.changedPano); | |
| GEvent.addListener(a.pano, "yawchanged", a.streetviewUpdated); | |
| GEvent.addListener(a.pano, "pitchchanged", a.streetviewUpdated); | |
| GEvent.addListener(a.pano, "zoomchanged", a.streetviewUpdated); | |
| if (a.locationData) { | |
| a.currentPano = a.locationData[0]; | |
| a.POV = { | |
| zoom: a.locationData[1], | |
| yaw: a.locationData[2], | |
| pitch: a.locationData[3] | |
| }; | |
| a.fromCookies = true; | |
| a.initialized = true; | |
| a.currentUrl = a.currentUrl.replace(this.options.encodedLocation, "") | |
| } | |
| a.pano.setLocationAndPOVFromServerResponse(a.createResponseForPanoId(a.currentPano), a.POV); | |
| $(document.body).bind("streetview:move", | |
| function (c, b) { | |
| a.streetviewUpdated(); | |
| a.moveToPano(b.panoId, b.pov) | |
| }); | |
| $(document.body).bind("layout:changed", a.updateStreetview); | |
| a.addNavigateFloorplanButton() | |
| } | |
| }); | |
| ap.globals.Discover = Backbone.View.extend({ | |
| filter_sets: $(".filter-sets"), | |
| discover_content: $(".discover-content"), | |
| isAnimating: false, | |
| sidebar: null, | |
| scrollables: [], | |
| el: $(".sb-content.discover-content"), | |
| bladeEls: null, | |
| alphabet: ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"], | |
| blades: ["collection", "artist"], | |
| bladeCollections: { | |
| collection: new ap.CollectionBlade(), | |
| artist: new ap.ArtistBlade() | |
| }, | |
| current_blade_requests: { | |
| collection: null, | |
| artist: null | |
| }, | |
| current_blade_selection: { | |
| collection: null, | |
| artist: null | |
| }, | |
| offsetLoading: { | |
| collection: false, | |
| artist: false | |
| }, | |
| limit_increment: 30, | |
| date_filter_white_list: [8, 9, 13, 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 109, 189], | |
| whiteListedKeys: [8, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90], | |
| unwanted_params: ["open", "filter"], | |
| retried: 0, | |
| retries: 5, | |
| total_range: { | |
| from: -500000, | |
| to: 2012 | |
| }, | |
| default_params: { | |
| limit: 60, | |
| artist_limit: 60, | |
| offset: 0 | |
| }, | |
| offsets: { | |
| collection: "collection_offset", | |
| artist: "artist_offset" | |
| }, | |
| alphabet_queries: { | |
| collection: "name__firstletter", | |
| artist: "last_name__firstletter" | |
| }, | |
| breadcrumbs: { | |
| collection: null, | |
| artist: null, | |
| date: null | |
| }, | |
| blade_request: null, | |
| alphabet_request: null, | |
| aggregation_test: null, | |
| search_request: null, | |
| search_interval: null, | |
| events: { | |
| "click li.blade.closed": "toggle_blades", | |
| "click li.blade.open .heading": "handle_close_blade", | |
| "click .remove-percent-filtered": "remove_filter", | |
| "click .filtered-list li a": "update_filter", | |
| "click .filtered-list li span.show-decades": "toggle_decades", | |
| "click .button": "date_filter", | |
| "click .all-dates": "show_all_dates", | |
| "click .ad-bc": "ad_bc", | |
| "keypress .control-set.from input": "detect_dates", | |
| "keypress .control-set.to input": "detect_dates", | |
| "click .alphabet-filter li a": "alphabet_query", | |
| "click .alphabet-filter li.reset a.all": "alphabet_query", | |
| "jsp-arrow-change .blade .scroll-pane": "offset_load", | |
| "focus .blade input.blade-filter": "text_search", | |
| "blur .blade input.blade-filter": "cancel_search_interval", | |
| "submit .blade form.input-filter": "cancel_submit" | |
| }, | |
| templates: { | |
| filter_set: '<ul class="filtered-list"></ul>', | |
| percent_filter: '<div class="percent-filtered"></div>', | |
| remove_button: '<a class="remove-percent-filtered" title="Remove" href="#"><span>Remove</span></a>' | |
| }, | |
| initialize: function () { | |
| var a = this; | |
| _.bindAll(this, "set_blade_data", "get_blade_data", "render", "remove_filter", "onContentAreaResized"); | |
| a.initial_data(); | |
| a.sidebar = a.options.sidebar; | |
| return a | |
| }, | |
| render: function () { | |
| var b = this, | |
| a = ap.getCurrentArtworkCollectionState(); | |
| b.breadcrumb_holder = $(".collection-mutators"); | |
| b.breadcrumb_holder.on("click", ".clear-blade-filter", b.remove_filter); | |
| b.bladeEls = b.el.find(".filter-sets > .blade"); | |
| b.bladeEls.each(function () { | |
| $(this).append($(b.templates.remove_button).addClass("hide")) | |
| }); | |
| _.each(a, | |
| function (d, c) { | |
| var e = c == "canonical_artist" ? "artist" : c; | |
| _.each(b.bladeCollections, | |
| function (f, j) { | |
| if (f.getCollectionFilterType() === c) { | |
| b.setFilter(e, d.value, d.text, true) | |
| } | |
| if (c === f.collectionUrlPart) { | |
| b.bladeEls.filter("." + j).find(".remove-percent-filtered").removeClass("hide") | |
| } | |
| }) | |
| }); | |
| b.bind("contentAreaResized", b.onContentAreaResized); | |
| b.initial_collapse(); | |
| $(".loader").addClass("hidden"); | |
| $(b.el).off("click", "li.blade.open .heading"); | |
| $(b.el).on("click", "li.blade.open .heading", false, "handle_close_blade"); | |
| _.each(b.blades, | |
| function (c) { | |
| b.updateBlade(c) | |
| }) | |
| }, | |
| get_blade_data: function () { | |
| var a = { | |
| artist: null, | |
| artist_offset: null, | |
| collection: null, | |
| collection_offset: null, | |
| f: null, | |
| filter: null, | |
| latest_date__gte: null, | |
| latest_date__lte: null, | |
| open: null, | |
| t: null | |
| }; | |
| return JSON.parse(localStorage.getItem("blade")) || a | |
| }, | |
| set_blade_data: function (c) { | |
| var a = this, | |
| b; | |
| var d = a.get_blade_data("blade"); | |
| if (d !== null || d !== undefined) { | |
| b = JSON.stringify($.extend(true, d, c)) | |
| } else { | |
| b = JSON.stringify(c) | |
| } | |
| localStorage.setItem("blade", b) | |
| }, | |
| initial_data: function () { | |
| var a = this, | |
| b = a.get_restrict_next_by(); | |
| if (!a.get_blade_data()) { | |
| a.set_blade_data({ | |
| collection: null, | |
| artist: null, | |
| collection_offset: null, | |
| artist_offset: null | |
| }) | |
| } else { | |
| if (a.get_blade_data().length <= 1) { | |
| a.set_blade_data({ | |
| collection: null, | |
| artist: null, | |
| collection_offset: null, | |
| artist_offset: null | |
| }) | |
| } else { | |
| if (!b) { | |
| a.set_blade_data({ | |
| collection: null, | |
| artist: null, | |
| collection_offset: null, | |
| artist_offset: null | |
| }) | |
| } | |
| } | |
| } | |
| }, | |
| get_current_offset: function (c) { | |
| var b = this; | |
| var a = $("." + c).find(".filtered-list li").length | |
| }, | |
| set_restrict_next_by: function (b, a) { | |
| var c = {}; | |
| c[b] = a; | |
| this.set_blade_data({ | |
| restrict_next_by: c | |
| }) | |
| }, | |
| get_restrict_next_by: function (b) { | |
| var c = this.get_blade_data(), | |
| a = c.restrict_next_by || false; | |
| if (a && b) { | |
| this.set_blade_data({ | |
| restrict_next_by: null | |
| }) | |
| } | |
| return a | |
| }, | |
| updateBlade: function (f, c) { | |
| var e = this, | |
| b = e.bladeEls.filter("." + f), | |
| j = e.bladeCollections[f], | |
| a = b.find(".loader"), | |
| d = b.find(".scroll-pane").data("jsp"); | |
| if (!c) { | |
| b.find(".filtered-list").empty(); | |
| if (d) { | |
| d.reinitialise() | |
| } | |
| j.resetCount() | |
| } | |
| if (!j.moreToLoad) { | |
| return | |
| } | |
| a.removeClass("hidden").removeClass("error"); | |
| if (e.current_blade_requests[f] !== null) { | |
| e.current_blade_requests[f].abort() | |
| } | |
| e.current_blade_requests[f] = j.fetch({ | |
| success: function (l, m) { | |
| var k = b.find(".scroll-pane").data("jsp"); | |
| a.addClass("hidden"), e.offsetLoading[f] = false; | |
| e.update_filtered_list(b, m.objects, f); | |
| if (k) { | |
| k.reinitialise(); | |
| if (b.hasClass("open") && !k.getIsScrollableV() && j.moreToLoad) { | |
| e.updateBlade(f, true) | |
| } | |
| } | |
| } | |
| }) | |
| }, | |
| alphabet_query: function (k) { | |
| k.preventDefault(); | |
| var b = this, | |
| c = $(k.currentTarget), | |
| f = $(k.currentTarget).parent("li"); | |
| if (f.hasClass("selected")) { | |
| return | |
| } | |
| var j = c.parents(".blade"), | |
| a = j.data("type"), | |
| d = c.attr("class"); | |
| j.find(".alphabet-filter li").removeClass("selected"); | |
| j.find("input.blade-filter").val(""); | |
| f.addClass("selected"); | |
| if (c.hasClass("all")) { | |
| b.bladeCollections[a].filterAlpha() | |
| } else { | |
| b.bladeCollections[a].filterAlpha(d) | |
| } | |
| b.updateBlade(a) | |
| }, | |
| date_filter: function (d) { | |
| var b = this; | |
| var a = { | |
| from: $("#from").val(), | |
| to: $("#to").val() | |
| }; | |
| $.each(a, | |
| function (f, e) { | |
| if (e === "") { | |
| a[f] = b.total_range[f] | |
| } | |
| if (a[f].substr(0, 1) != "-") { | |
| a[f] = parseInt(a[f], 10) | |
| } | |
| if ($("#" + f).siblings("a").hasClass("selected")) { | |
| if (typeof (a[f]) == "string") { | |
| if (a[f].substr(0, 1) != "-") { | |
| a[f] = a[f] / -1 | |
| } | |
| } else { | |
| a[f] = a[f] / -1 | |
| } | |
| } | |
| }); | |
| b.date_validate(a); | |
| var c = { | |
| latest_date__gte: a.from, | |
| latest_date__lte: a.to | |
| }; | |
| b.set_blade_data(c); | |
| b.aggregation_loader(); | |
| b.show_all_dates(false); | |
| $.each($("a.century"), | |
| function () { | |
| var f, e; | |
| f = parseInt($(this).data("date").from, 10); | |
| e = parseInt($(this).data("date").to, 10); | |
| if (f > a.to) { | |
| $(this).parent("li").addClass("hidden") | |
| } | |
| if (e < a.from) { | |
| $(this).parent("li").addClass("hidden") | |
| } | |
| if ($(this).is(":visible")) { | |
| $.each($(this).parent("li").find(".decades li a"), | |
| function () { | |
| var k = parseInt($(this).data("date").from, 10); | |
| var j = parseInt($(this).data("date").to, 10); | |
| if (k > a.to) { | |
| $(this).parent("li").addClass("hidden") | |
| } | |
| if (j < a.from) { | |
| $(this).parent("li").addClass("hidden") | |
| } | |
| }) | |
| } | |
| }) | |
| }, | |
| ad_bc: function (b) { | |
| var a = $(b.currentTarget); | |
| if (a.hasClass("selected")) { | |
| a.text("AD"); | |
| a.removeClass("selected") | |
| } else { | |
| a.text("BC"); | |
| a.addClass("selected") | |
| } | |
| }, | |
| detect_dates: function (c) { | |
| var b = this; | |
| if ($.inArray(c.which, b.date_filter_white_list) != -1 && c.which != 13) { | |
| var a = $(c.currentTarget).val(); | |
| if (a.substr(0, 1) == "-" || a == "-") { | |
| $(c.currentTarget).siblings("a").addClass("selected").text("BC") | |
| } else { | |
| $(c.currentTarget).siblings("a").removeClass("selected").text("AD") | |
| } | |
| } else { | |
| if (c.which == 13) { | |
| if ($("#from").val() != "" || $("#to").val() != "") { | |
| b.date_filter(c) | |
| } | |
| } else { | |
| return false | |
| } | |
| } | |
| }, | |
| validate_bc: function (a) { | |
| if (a.val().substr(0, 1) == "-" || a.val() == "-") { | |
| a.siblings("a").addClass("selected").text("BC") | |
| } else { | |
| a.siblings("a").removeClass("selected").text("AD") | |
| } | |
| if (parseInt(a.val(), 10) >= 0) { | |
| a.siblings("a").removeClass("selected").text("AD") | |
| } | |
| }, | |
| show_all_dates: function (b) { | |
| var a = this; | |
| $(".centuries li").removeClass("hidden").find(".decades li").removeClass("hidden"); | |
| if (b == true) { | |
| $("#from").val(""); | |
| $("#to").val("") | |
| } | |
| a.set_blade_data({ | |
| latest_date__gte: null, | |
| latest_date__lte: null, | |
| f: null, | |
| t: null | |
| }); | |
| a.attach_scrolling($(".blade.date")) | |
| }, | |
| date_validate: function (d) { | |
| var c = this; | |
| if (d.from <= c.total_range.from && d.from >= c.total_range.from) { | |
| d.from = c.total_range.from | |
| } | |
| if (d.to <= c.total_range.to && d.to >= c.total_range.to) { | |
| d.to = c.total_range.to | |
| } | |
| if (parseInt(d.from, 10) > parseInt(d.to, 10)) { | |
| $("#from").val(d.to); | |
| $("#to").val(d.from); | |
| var a = d.from; | |
| var b = d.to; | |
| d.from = b; | |
| d.to = a | |
| } | |
| c.validate_bc($("#from")); | |
| c.validate_bc($("#to")); | |
| return d | |
| }, | |
| hide_unmatched_dates: function (b, c) { | |
| var a = this; | |
| a.show_all_dates(true); | |
| $.each(b.find(".filtered-list li a.century"), | |
| function () { | |
| var f = parseInt($(this).data("date").from, 10); | |
| if ($.inArray(f, c.centuries) == -1) { | |
| $(this).parent("li").addClass("hidden") | |
| } else { | |
| $(this).parent("li").removeClass("hidden"); | |
| var e = $(this).parent("li").find("ul.decades li a"); | |
| if (e.length > 0) { | |
| var d = false; | |
| $.each(e, | |
| function (k, j) { | |
| var l = parseInt($(j).data("date").from, 10); | |
| if ($.inArray(l, c.decades) !== -1) { | |
| d = true; | |
| $(j).parent().removeClass("hidden") | |
| } else { | |
| $(j).parent().addClass("hidden") | |
| } | |
| }); | |
| if (d) { | |
| $(this).parent("li").removeClass("hidden") | |
| } else { | |
| $(this).parent("li").addClass("hidden") | |
| } | |
| } | |
| } | |
| }) | |
| }, | |
| update_filtered_list: function (j, f, d, e) { | |
| var a = this; | |
| var c = 0; | |
| if (e) { | |
| j.find(".filtered-list").empty() | |
| } | |
| var b = j.find(".filtered-list"); | |
| if (d == "collection") { | |
| $.each(f, | |
| function (l, k) { | |
| if (a.current_blade_selection.collection == k.id) { | |
| j.find(".alphabet-filter li").removeClass("selected"); | |
| b.append('<li class="' + k.slug + '"><a class="filter-result-selected" type="' + d + '" href="/collection/' + k.slug + '" data-id="' + k.id + '">' + k.name + "</a></li>"); | |
| a.breadcrumbs.collection = k.name | |
| } else { | |
| b.append('<li class="' + k.slug + '"><a type="' + d + '" href="/collection/' + k.slug + '" data-id="' + k.id + '">' + k.name + "</a></li>") | |
| } | |
| }) | |
| } else { | |
| if (d == "artist") { | |
| $.each(f, | |
| function (n, l) { | |
| var m = ""; | |
| m = l.display_name; | |
| var k = m ? ap.slugify(m) : ""; | |
| if (m) { | |
| if (a.current_blade_selection.artist == l.id) { | |
| j.find(".alphabet-filter li").removeClass("filter-select"); | |
| b.append('<li class="' + k + '"><a class="filter-result-selected" type="' + d + '" href="/artist/' + k + "/" + l.id + '" data-id="' + l.id + '">' + m + "</a></li>"); | |
| a.breadcrumbs.artist = m | |
| } else { | |
| b.append('<li class="' + k + '"><a type="' + d + '" href="/artist/' + k + "/" + l.id + '" data-id="' + l.id + '">' + m + "</a></li>") | |
| } | |
| } | |
| }) | |
| } | |
| } | |
| a.render_breadcrumbs(); | |
| a.attach_scrolling(j); | |
| a.get_current_offset(d) | |
| }, | |
| render_breadcrumbs: function () { | |
| var b = this; | |
| var a = ""; | |
| $.each(b.breadcrumbs, | |
| function (e, d) { | |
| if (d != null) { | |
| var c = ' <span class="blade blade-breadcrumb" data-type="' + e + '">' + d + ' <span class="remove clear-mutator clear-blade-filter"></span></span>'; | |
| a += c | |
| } | |
| }); | |
| b.breadcrumb_holder.children(".blade-breadcrumb").remove(); | |
| b.breadcrumb_holder.append(a) | |
| }, | |
| offset_load: function (d, j, c, f, e) { | |
| var b = this; | |
| var a = $(d.currentTarget).parents(".blade").data("type"); | |
| if (a != "date") { | |
| if (c == true && b.offsetLoading[a] == false) { | |
| b.offsetLoading[a] = true; | |
| b.updateBlade(a, true) | |
| } | |
| } | |
| }, | |
| text_search: function (f) { | |
| var b = this; | |
| var d = $(f.currentTarget).val(); | |
| var c = $(f.currentTarget).parents(".blade"); | |
| var a = c.data("type"); | |
| b.search_interval = setInterval(function () { | |
| if (d != $(f.currentTarget).val()) { | |
| d = $(f.currentTarget).val(); | |
| if (d != "") { | |
| c.find(".alphabet-filter li").removeClass("selected"); | |
| b.bladeCollections[a].filterText(d); | |
| b.updateBlade(a) | |
| } else { | |
| b.bladeCollections[a].filterText(); | |
| b.updateBlade(a); | |
| c.find(".alphabet-filter li a.all").parent("li").addClass("selected") | |
| } | |
| } | |
| }, 100) | |
| }, | |
| cancel_search_interval: function (c) { | |
| var b = this; | |
| var a = $(c.currentTarget).closest(".blade").data("type"); | |
| if (b.search_interval != null) { | |
| clearInterval(b.search_interval) | |
| } | |
| }, | |
| cancel_submit: function (a) { | |
| $(a.currentTarget).children("input.blade-filter").blur(); | |
| return false | |
| }, | |
| update_filter: function (j) { | |
| j.preventDefault(); | |
| var a = this; | |
| var f = ["open", "filter", "f", "t", "offset", "limit"]; | |
| var d = {}; | |
| var b = $(j.currentTarget); | |
| var c = b.parents(".blade.open"); | |
| var k = c.data("type"); | |
| var l = []; | |
| if (b.hasClass("filter-result-selected")) { | |
| if (b.hasClass("reset")) { | |
| return | |
| } else { | |
| c.find(".remove-percent-filtered").addClass("hide"); | |
| return a.remove_filter(j) | |
| } | |
| } | |
| c.find(".remove-percent-filtered").removeClass("hide"); | |
| c.find("a.filter-result-selected").removeClass("filter-result-selected"); | |
| b.addClass("filter-result-selected"); | |
| a.setFilter(k, b.data("id"), b.text()); | |
| a.aggregation_loader() | |
| }, | |
| setFilter: function (d, c, e, f) { | |
| var b = this, | |
| a = []; | |
| b.breadcrumbs[d] = e; | |
| b.render_breadcrumbs(); | |
| b.current_blade_selection[d] = c; | |
| $.each(b.blades, | |
| function (k, j) { | |
| var l = {}; | |
| if (j != d) { | |
| b.bladeCollections[j].filterCollection(c); | |
| l = b.bladeCollections[j].getCollectionFilter(); | |
| l.filterText = e; | |
| a.push(l); | |
| b.bladeEls.filter("." + j).find(".current-selection").addClass("show").children(".item").text(e); | |
| b.updateBlade(j) | |
| } | |
| }); | |
| if (!f) { | |
| ap.setCurrentArtworkCollectionState(a) | |
| } | |
| }, | |
| aggregation_loader: function () { | |
| var b = this; | |
| var e = $.extend({}, b.current_blade_selection); | |
| var c = b.sidebar.parentView; | |
| var a = c && c.currentCollection || false; | |
| var d = a ? a : new ap.ArtworkList(); | |
| if (a && c.topFiltersView) { | |
| c.topFiltersView.removeAllFilters(true) | |
| } | |
| if (e.hasOwnProperty("artist")) { | |
| e.canonical_artist = e.artist; | |
| delete e.artist | |
| } | |
| $.each(e, | |
| function (j, f) { | |
| if (f !== null) { | |
| d.setFilter(j, f) | |
| } else { | |
| d.removeFilter(j) | |
| } | |
| }); | |
| d.setFilter("api", true); | |
| if (a) { | |
| c.el.trigger("currentCollectionChange") | |
| } else { | |
| c.el.trigger("currentCollectionChange", [d]) | |
| } | |
| }, | |
| remove_filter: function (j) { | |
| j.preventDefault(); | |
| j.stopPropagation(); | |
| var b = this; | |
| var f = $(j.currentTarget).parents(".blade").data("type"); | |
| var a; | |
| $.each(b.blades, | |
| function (k, e) { | |
| if (e != f) { | |
| a = e | |
| } | |
| }); | |
| var d = b.bladeEls.filter("." + f); | |
| var c = b.bladeEls.filter("." + a); | |
| d.find(".remove-percent-filtered").addClass("hide"); | |
| c.find(".current-selection").removeClass("show").children(".item").text(""); | |
| b.breadcrumbs[f] = null; | |
| b.render_breadcrumbs(); | |
| b.el.find(".filtered-list." + f + " .filter-result-selected").removeClass("filter-result-selected"); | |
| b.bladeCollections[a].filterCollection(); | |
| ap.setCurrentArtworkCollectionState([{ | |
| filterType: b.bladeCollections[a].getCollectionFilterType(), | |
| filterValue: false | |
| }]); | |
| b.updateBlade(a); | |
| b.current_blade_selection[f] = null; | |
| b.aggregation_loader() | |
| }, | |
| attach_scrolling: function (b) { | |
| var a = this; | |
| if (b.find(".scroll-pane").data("jsp")) { | |
| b.find(".scroll-pane").data("jsp").reinitialise() | |
| } else { | |
| b.find(".scroll-pane").pScrollPane() | |
| } | |
| b.find(".scroll-pane").data("jsp").reinitialise() | |
| }, | |
| initial_collapse: function () { | |
| var a = this; | |
| a.filter_sets.find("li").not(".open").find(".contents").hide(); | |
| a.filter_sets.find("li.open").find(".filters-selected").hide() | |
| }, | |
| collapse_others: function () { | |
| var a = this; | |
| var b = a.filter_sets.find("li.blade.open"); | |
| a.filter_sets.find("li.blade.open").find("h3").addClass("rotated"); | |
| a.filter_sets.find("li.blade.open").removeClass("display-open").animate({ | |
| width: 60 | |
| }, | |
| function () { | |
| $(this).removeClass("open").addClass("closed") | |
| }).find(".contents").fadeOut(function () { | |
| $(this).parent("li").find(".filters-selected").fadeIn() | |
| }) | |
| }, | |
| handle_close_blade: function (c) { | |
| var a = this; | |
| var b = $(c.currentTarget).parents(".blade"); | |
| if (!a.isAnimating) { | |
| a.close_blade(b) | |
| } | |
| }, | |
| close_blade: function (b) { | |
| var a = this; | |
| $blade = $(b); | |
| a.isAnimating = true; | |
| $blade.find("h3").addClass("rotated"); | |
| $blade.removeClass("display-open").animate({ | |
| width: 60 | |
| }, | |
| function () { | |
| $(this).addClass("closed").removeClass("open") | |
| }).find(".contents").fadeOut().end().find(".filters-selected").fadeOut(function () { | |
| $(this).parent("li").find(".filters-selected").fadeIn() | |
| }); | |
| a.sidebar.resize(120); | |
| a.discover_content.animate({ | |
| width: 120 | |
| }, | |
| function () { | |
| a.isAnimating = false | |
| }) | |
| }, | |
| toggle_blades: function (b) { | |
| var a = this; | |
| b = $(b.currentTarget); | |
| if (a.bladeEls.filter(":animated").length !== 0 || a.discover_content.is(":animated")) { | |
| return | |
| } | |
| a.el.undelegate("li.blade.closed", "click"); | |
| a.el.undelegate("li.blade.open .heading", "click"); | |
| if (a.filter_sets.find(".open").length === 0) { | |
| a.sidebar.resize(320); | |
| a.discover_content.animate({ | |
| width: 320 | |
| }) | |
| } | |
| if (b.hasClass("closed")) { | |
| a.collapse_others(); | |
| b.find("h3").removeClass("rotated"); | |
| b.find(".percent-filtered").slideUp(function () { | |
| $(this).remove() | |
| }); | |
| b.addClass("display-open").animate({ | |
| width: 260 | |
| }).addClass("open").removeClass("closed").find(".filters-selected").fadeOut(function () { | |
| b.find(".contents").fadeIn().slideDown(function () { | |
| var c = b.find(".scroll-pane").data("jsp"), | |
| d = b.data("type"); | |
| a.delegateEvents(); | |
| $.each(a.scrollables, | |
| function (f, e) { | |
| e.reinitialise({ | |
| verticalGutter: 4 | |
| }) | |
| }); | |
| a.attach_scrolling(b); | |
| if (c && !c.getIsScrollableV() && a.bladeCollections[d].moreToLoad) { | |
| a.updateBlade(d, true) | |
| } | |
| }) | |
| }) | |
| } | |
| }, | |
| toggle_decades: function (a) { | |
| $(".century").not($(a.currentTarget).parent(".century")).removeClass("open").end().find($("ul.decades")).not($(a.currentTarget).next("ul.decades")).slideUp(); | |
| $(a.currentTarget).parent(".century").addClass("open"); | |
| $(a.currentTarget).next("ul.decades").slideToggle("fast") | |
| }, | |
| filter_count: function (b) { | |
| var k = this; | |
| if (!b.hasClass("open")) { | |
| b.find(".remove-percent-filtered").remove(); | |
| b.find(".percent-filtered").slideUp(function () { | |
| $(this).remove() | |
| }); | |
| if (k.get_blade_data().filter) { | |
| var f = 800; | |
| var d = b.find(".filtered-list li:not(ul.decades li)").length; | |
| var l; | |
| if (d == 0) { | |
| l = 100 * (f / f) | |
| } else { | |
| l = 100 * (d / f) | |
| } | |
| var e = "400"; | |
| var a = (l / 100) * e; | |
| var c = $(k.templates.percent_filter); | |
| var j = $(k.templates.remove_button); | |
| b.append(c); | |
| b.append(j); | |
| c.animate({ | |
| height: a | |
| }) | |
| } | |
| } | |
| }, | |
| onContentAreaResized: function () { | |
| var b = this, | |
| e = this.bladeEls.eq(0), | |
| c = 102, | |
| f = ap.isMobile ? 52 : 29, | |
| j = ap.isMobile ? 147 : 104, | |
| d = this.el.outerHeight(true) - (c + f + j + 45), | |
| a = this.el.find(".scroll-pane"); | |
| a.each(function () { | |
| var n = $(this), | |
| k = n.height(d).data("jsp"), | |
| l = n.closest(".blade"), | |
| m = l.data("type"), | |
| o = b.bladeCollections[m]; | |
| if (k) { | |
| k.reinitialise(); | |
| if (l.hasClass("open") && !k.getIsScrollableV() && o.moreToLoad) { | |
| b.updateBlade(m, true) | |
| } | |
| } | |
| }) | |
| } | |
| }); | |
| ap.globals.Bookmarks = Backbone.View.extend({ | |
| el: $("#sidebar"), | |
| events: { | |
| "click #sidebar-content button.cancel": "closeBookmarkPanel" | |
| }, | |
| closeBookmarkPanel: function () { | |
| this.sidebar.closeSidebar() | |
| }, | |
| initialize: function () { | |
| this.sidebar = this.options.sidebar; | |
| _.bindAll(this, "postHandler"); | |
| this.postHandler() | |
| }, | |
| postHandler: function () { | |
| this.createNewBookmarkView = new ap.bookmarks.CreateBookmark({ | |
| sidebar: this.sidebar | |
| }) | |
| } | |
| }); | |
| ap.globals.Share = Backbone.View.extend({ | |
| el: $("#sidebar"), | |
| events: { | |
| "click .share-content li a": "trackShareAction", | |
| "focus #short-url": "autoSelectShareURL" | |
| }, | |
| initialize: function () { | |
| _.bindAll(this, "trackShareAction", "autoSelectShareURL"); | |
| this.$el = $(this.el); | |
| this.sidebar = this.options.sidebar; | |
| this.setupShortUrl(); | |
| this.setupGPlusShare(); | |
| this.setupTweet(); | |
| $(".content-with-sidebar").bind("content-change", this.setupShortUrl) | |
| }, | |
| autoSelectShareURL: function (b) { | |
| var a = $(b.target).get(0); | |
| this.setSelection(a, 0, a.value.length); | |
| this.trackShareAction(b) | |
| }, | |
| setupShortUrl: function () { | |
| var a = this.options.shareUrl ? window.location.origin + this.options.shareUrl : window.location; | |
| $("#short-url").val(""); | |
| url = "/shorturl/?url=" + a; | |
| $.get(url, | |
| function (b) { | |
| $("#short-url").val(b); | |
| $(".plusone a, .twitter a, .facebook a").each(function () { | |
| $this = $(this); | |
| href = $this.attr("href"); | |
| $this.attr("href", href + b) | |
| }); | |
| $(".email a").each(function () { | |
| $this = $(this); | |
| href = $this.attr("href"); | |
| $this.attr("href", href + "&body=" + b) | |
| }) | |
| }) | |
| }, | |
| setupGPlusShare: function () { | |
| $(".plusone a").click(function () { | |
| window.open($(this).attr("href"), "ap-gplus-share", "width=640,height=300"); | |
| return false | |
| }) | |
| }, | |
| setupTweet: function () { | |
| $(".twitter a").click(function () { | |
| window.open($(this).attr("href"), "ap-tweet-share", "width=550,height=420"); | |
| return false | |
| }) | |
| }, | |
| setSelection: function (b, a, d) { | |
| if (b.createTextRange) { | |
| var c = b.createTextRange(); | |
| c.collapse(true); | |
| c.moveStart("character", a); | |
| c.moveEnd("character", a + d); | |
| c.select() | |
| } else { | |
| if (b.selectionEnd) { | |
| b.selectionStart = a; | |
| b.selectionEnd = a + d | |
| } | |
| } | |
| }, | |
| trackShareAction: function (c) { | |
| var a = $(c.target); | |
| var b = a.data("service-name"); | |
| ap.trackShareAction(b, ap.getMuseumAnalyticsId()) | |
| } | |
| }); | |
| ap.namespace("ap.sidebar").MainView = Backbone.View.extend({ | |
| el: $("#sidebar"), | |
| events: { | |
| "click a.disabled": "disabledButton_Click", | |
| "click a.enabled.has_section": "hasSection_Click", | |
| "mouseenter .tb-action-link": "showLabel", | |
| "mouseleave .tb-action-link": "hideLabel", | |
| "click a.enabled.add-to-collection": "initBookmarks", | |
| "click a.enabled.share": "initShare", | |
| "click a.enabled.discover": "initDiscover", | |
| "click a.enabled.slideshow": "startSlideShow", | |
| "click a.streetview": "toggleStreetview", | |
| }, | |
| closedWidth: 50, | |
| config: { | |
| aggregation: null, | |
| aggregation_view: null | |
| }, | |
| options: { | |
| plusoneOptions: { | |
| size: "small", | |
| annotation: "none" | |
| }, | |
| visibleButtons: [".plusone", ".discover", ".share", ".add-to-collection", ".slideshow", ".streetview"], | |
| disabledButtons: [], | |
| shareUrl: null | |
| }, | |
| open: false, | |
| streetview: null, | |
| lastPanel: null, | |
| initialize: function () { | |
| var a = this; | |
| _.bindAll(a, "render", "hasSection_Click", "onResizeComplete", "resize", "killMuseumView"); | |
| a.bind("userDataLoaded", | |
| function () { | |
| ap.log("userDataLoaded callback init in sidebar/MainView.js"); | |
| if (a.buttonShouldBeEnabled(".add-to-collection")) { | |
| a.enableButton(".add-to-collection"); | |
| this.bookmarks = new ap.globals.Bookmarks({ | |
| sidebar: this | |
| }) | |
| } | |
| if (a.buttonShouldBeEnabled(".slideshow")) { | |
| a.enableButton(".slideshow") | |
| } | |
| }); | |
| $.each(a.options.visibleButtons, | |
| function (b, c) { | |
| var d = a.el.find(c); | |
| d.removeClass("hidden"); | |
| if ((c !== ".add-to-collection" && c !== ".slideshow") && a.buttonShouldBeEnabled(c)) { | |
| d.removeClass("disabled"); | |
| d.addClass("enabled") | |
| } | |
| }); | |
| a.initDiscover(); | |
| if (this.discover.get_blade_data()) { | |
| if (this.discover.get_blade_data().open == true) { | |
| a.openSidebar($("a.tb-action-link.discover")) | |
| } | |
| } | |
| if ($("body").data("museumId")) { | |
| this.discover.set_blade_data({ | |
| collection: $("body").data("museumId"), | |
| artist: null | |
| }) | |
| } else { | |
| if ($("body").data("artistId")) { | |
| this.discover.set_blade_data({ | |
| collection: null, | |
| artist: $("body").data("artistId") | |
| }) | |
| } | |
| } | |
| if (ap.isMobile) { | |
| this.closedWidth = 60 | |
| } | |
| a.el.find(".hidden").parent().remove() | |
| }, | |
| buttonShouldBeEnabled: function (a) { | |
| if (!_.include(this.options.disabledButtons, a)) { | |
| return true | |
| } | |
| return false | |
| }, | |
| showLabel: function (a) { | |
| var b = $(a.currentTarget); | |
| if (!b.hasClass("disabled")) { | |
| var c = b.find(".tb-action-label"); | |
| if (!$(c).is(":visible")) { | |
| $(c).stop().fadeIn() | |
| } | |
| if (!$(a.currentTarget).hasClass("selected")) {} | |
| } | |
| return false | |
| }, | |
| hideLabel: function (a) { | |
| var b = $(a.currentTarget); | |
| if (!b.hasClass("disabled")) { | |
| var c = b.find(".tb-action-label"); | |
| if ($(c).is(":visible")) { | |
| $(c).stop().fadeOut() | |
| } | |
| } | |
| return false | |
| }, | |
| initDiscover: function () { | |
| if (_.isUndefined(this.discover)) { | |
| this.discover = new ap.globals.Discover({ | |
| sidebar: this | |
| }) | |
| } | |
| }, | |
| initBookmarks: function (a) { | |
| $(".add-to-collection-content").data("zoomState", this.parentView.microscope.getCurrentState()) | |
| }, | |
| initShare: function (b) { | |
| var a = this; | |
| if (_.isUndefined(this.share)) { | |
| this.share = new ap.globals.Share({ | |
| sidebar: this, | |
| shareUrl: a.options.shareUrl | |
| }) | |
| } | |
| }, | |
| startSlideShow: function () { | |
| var b = this; | |
| var c = $(".artwork").first().data("model"); | |
| var k = 0; | |
| var a = "UNKNOWN_COLLECTION"; | |
| var e = ap.getMuseumAnalyticsId(); | |
| var j = $("body").data("museum-id"); | |
| var f = $("body").data("group-id"); | |
| if (_.isUndefined(c)) { | |
| k = $("#artwork-wrapper").data("artworkId"); | |
| k = "/api/int/gap2/artwork/" + k + "/"; | |
| a = $("body").data("museum-url") | |
| } else { | |
| k = c.id; | |
| a = c.get("collection_detail_url") | |
| } | |
| if (j) { | |
| ap.trackOpenSlideshow("sidebar", { | |
| "collection-slug": a | |
| }, e) | |
| } else { | |
| if (f) { | |
| ap.trackOpenSlideshow("sidebar", { | |
| bookmarkgroup: "bookmarkgroup", | |
| bookmarkgroup_id: f | |
| }) | |
| } else { | |
| ap.trackOpenSlideshow("sidebar", {}) | |
| } | |
| } | |
| var d = new ap.slideshow.layout.MainView({ | |
| sidebar: this | |
| }); | |
| d.render(k) | |
| }, | |
| remoteStartSlideshow: function (a) { | |
| ap.trackOpenSlideshow("artwork_icon", { | |
| aw_slug: a.get("slug"), | |
| aw_id: a.get("id"), | |
| "collection-slug": a.get("collection_detail_url") | |
| }, ap.getMuseumAnalyticsId()); | |
| var b = new ap.slideshow.layout.MainView({ | |
| sidebar: this | |
| }); | |
| var c = a.id; | |
| b.render(c) | |
| }, | |
| openCloseAnimation: function (d, b) { | |
| var a = this, | |
| e = $(".main-content"), | |
| c = $(".content-with-sidebar"); | |
| a.el.animate({ | |
| left: d | |
| }, { | |
| queue: false, | |
| complete: a.onResizeComplete, | |
| step: function (f) { | |
| if (a.parentView && a.parentView.preloaderview) { | |
| a.parentView.preloaderview.positionPreloader({ | |
| "margin-left": f | |
| }, true) | |
| } | |
| e.css({ | |
| width: b - (f + 50) + "px" | |
| }); | |
| c.css({ | |
| marginLeft: f + 50, | |
| width: b - (f + 50) + "px" | |
| }) | |
| } | |
| }) | |
| }, | |
| resizeAnimation: function (d, b) { | |
| var a = this, | |
| e = $(".main-content"), | |
| c = $(".content-with-sidebar"); | |
| a.el.animate({ | |
| left: d | |
| }, { | |
| queue: false | |
| }); | |
| c.animate({ | |
| marginLeft: d + 50, | |
| width: b - (d + 50) + "px" | |
| }, { | |
| queue: false | |
| }); | |
| e.animate({ | |
| width: b - (d + 50) + "px" | |
| }, { | |
| queue: false, | |
| step: (a.parentView && a.parentView.preloaderview) ? function (f) { | |
| a.parentView.preloaderview.positionPreloader({ | |
| "margin-left": b - f - 50 | |
| }, true) | |
| } : function () {}, | |
| complete: a.onResizeComplete | |
| }) | |
| }, | |
| closeSidebar: function () { | |
| var a = this; | |
| this.onBeforeResize(); | |
| var b = $(window).width(); | |
| a.openCloseAnimation(0, b); | |
| this.el.find(".tb-action-link").not(".streetview").removeClass("selected"); | |
| a.open = false | |
| }, | |
| toggleSidebar: function () { | |
| if (this.open) { | |
| this.closeSidebar() | |
| } else { | |
| this.openSidebar(this.lastPanel) | |
| } | |
| }, | |
| openSidebar: function (j) { | |
| var c = this, | |
| f = $("body"), | |
| b = {}; | |
| c.lastPanel = j; | |
| if (j.data("container") == "discover") { | |
| if (f.data("artworks") == undefined) { | |
| if (f.attr("id") == "museum") { | |
| b.filterType = "collection"; | |
| b.filterValue = f.data("museum-id"); | |
| b.filterText = f.data("museum-title") | |
| } else { | |
| if (f.attr("id") == "artist") { | |
| b.filterType = "canonical_artist"; | |
| b.filterValue = f.data("artist-id"); | |
| b.filterText = f.data("artist-name") | |
| } | |
| } | |
| ap.clearCurrentArtworkCollectionState(); | |
| ap.setCurrentArtworkCollectionState([b]); | |
| ap.redirectTo("/artworks/"); | |
| return false | |
| } else { | |
| this.discover.set_blade_data({ | |
| open: false | |
| }) | |
| } | |
| } | |
| this.onBeforeResize(); | |
| if (this.parentView) { | |
| this.parentView.trigger("sidebarOpening") | |
| } | |
| this.el.find(".tb-action-link").not(".streetview").removeClass("selected"); | |
| j.addClass("selected"); | |
| var a = $("." + j.data("container") + "-content"); | |
| $(".sb-content").hide(); | |
| a.show(); | |
| var d = $(window).width(); | |
| var e = a.width(); | |
| c.openCloseAnimation(e, d); | |
| this.open = true | |
| }, | |
| resize: function (c) { | |
| var a = this; | |
| var b = $(window).width(); | |
| a.resizeAnimation(c, b) | |
| }, | |
| onBeforeResize: function (a) { | |
| var b = this; | |
| b.el.trigger("beforeResize") | |
| }, | |
| onResizeComplete: function (a) { | |
| var b = this; | |
| b.el.trigger("resize") | |
| }, | |
| needsClosing: function (a) { | |
| return this.el.find(".tb-action-link.selected").data("container") == a.data("container") ? true : false | |
| }, | |
| hasSection_Click: function (a) { | |
| var b = this; | |
| var d = $(a.currentTarget); | |
| var c = b.needsClosing(d); | |
| if (d.hasClass("add-to-collection") && !ap.userIsAuthenticated) { | |
| return true | |
| } | |
| b.killMuseumView(); | |
| if (c) { | |
| b.closeSidebar() | |
| } else { | |
| b.openSidebar(d) | |
| } | |
| if (d.hasClass("streetview") && b.parentView.router) {} | |
| return false | |
| }, | |
| disabledButton_Click: function (a) { | |
| return false | |
| }, | |
| toggleStreetview: function (a) { | |
| var b = $(a.currentTarget); | |
| this.parentView.router.navigate(b.attr("href").replace("/", ""), true); | |
| return false | |
| }, | |
| showMuseumView: function (b, a) { | |
| var c = this; | |
| if ($("#streetview").length) { | |
| var d; | |
| if (!b) { | |
| d = $(c.el).find("a.streetview").eq(0) | |
| } else { | |
| d = $(b.currentTarget) | |
| } | |
| d.attr("href", d.data("real-url")); | |
| if (ap.isMobile) { | |
| c.parentView.trigger("sidebarOpening") | |
| } else { | |
| c.openSidebar(d) | |
| } | |
| if (c.parentView.artworkDetailView) { | |
| c.parentView.showArtwork() | |
| } | |
| if (c.parentView.museumDetails) { | |
| c.parentView.museumDetails.togglePopup("up") | |
| } | |
| $("#streetview").css({ | |
| "z-index": 1009 | |
| }); | |
| $("#streetview").show(); | |
| $(c.el).find("a.streetview").addClass("selected"); | |
| if (!c.parentView.streetview) { | |
| if (!ap.isMobile) { | |
| c.parentView.streetview = new ap.streetview.MainView({ | |
| sidebar: this, | |
| encodedLocation: a | |
| }) | |
| } else { | |
| c.parentView.streetview = new ap.mobile.streetview.MainView({ | |
| sidebar: this, | |
| encodedLocation: a | |
| }) | |
| } | |
| c.parentView.streetview.render() | |
| } | |
| } else { | |
| ap.log("no streetview") | |
| } | |
| }, | |
| hideMuseumView: function () { | |
| var a = $(this.el).find("a.streetview").eq(0); | |
| a.attr("href", a.data("museumview-url")); | |
| this.killMuseumView(); | |
| this.closeSidebar() | |
| }, | |
| killMuseumView: function (a) { | |
| var b = this; | |
| if (b.parentView.streetview && b.parentView.streetview.initialized) { | |
| $("#streetview").css({ | |
| "z-index": -10000 | |
| }); | |
| $(this.el).find("a.streetview").removeClass("selected").addClass("unselected"); | |
| $("#streetview").hide() | |
| } | |
| }, | |
| disableButton: function (a) { | |
| $(this.el).find("a.tb-action-link").filter(a).removeClass("enabled").addClass("disabled") | |
| }, | |
| enableButton: function (b, a) { | |
| $(this.el).find("a.tb-action-link").filter(b).removeClass("disabled").addClass("enabled") | |
| }, | |
| render: function () { | |
| if ($("body").data("artworks")) { | |
| this.discover.render(); | |
| this.openSidebar($("a.tb-action-link.discover")) | |
| } | |
| return this | |
| } | |
| }); | |
| ap.namespace("ap.system").ProcessManager = function (c) { | |
| var d = "default"; | |
| var b = function (e) { | |
| this.processName = e; | |
| this.isTerminated = false; | |
| this.isBusy = false; | |
| this.ownerDocument = document; | |
| this.start = function (j) { | |
| if (!this.isTerminated) { | |
| f(this, j, "processStarted", true) | |
| } else { | |
| ap.log("I can't start my work because I'm terminated", "warn") | |
| } | |
| }; | |
| this.end = function (j) { | |
| if (!this.isTerminated) { | |
| f(this, j, "processEnded", false) | |
| } else { | |
| ap.log("I can't end my work because I'm terminated", "warn") | |
| } | |
| }; | |
| this.terminate = function (j) { | |
| this.isTerminated = true; | |
| this.isBusy = false; | |
| f(this, j, "processTerminated", false) | |
| }; | |
| this.reset = function (j) { | |
| this.isTerminated = false; | |
| this.isBusy = false; | |
| f(this, j, "processReset", false) | |
| }; | |
| function f(l, n, k, m) { | |
| var j = l.processName != d ? "_" + l.processName : ""; | |
| l.isBusy = m; | |
| $(ap.system.ProcessManager.Singleton[l.processName]).trigger(k + j, n) | |
| } | |
| }; | |
| var a = c || d; | |
| return ap.system.ProcessManager.Singleton[a] || (ap.system.ProcessManager.Singleton[a] = new b(a)) | |
| }; | |
| ap.namespace("ap.system.ProcessManager").Singleton = { | |
| "default": null | |
| }; | |
| ap.namespace("ap.system").imagePreload = function (d, b) { | |
| var a = "default"; | |
| var e = function (n, l) { | |
| this.queueName = n; | |
| var p = { | |
| items: [], | |
| loadedItems: [], | |
| abort: false, | |
| imageLoaded: null, | |
| imageLoadError: null, | |
| batchLoaded: null | |
| }; | |
| var m = $.extend(p, l); | |
| this.addToQueue = function (r, q) { | |
| m.abort = false; | |
| m.items.push({ | |
| imageSrc: r, | |
| preLoadData: q | |
| }) | |
| }; | |
| this.abort = function () { | |
| m.abort = true; | |
| m.items = []; | |
| m.loadedItems = [] | |
| }; | |
| this.reset = function () { | |
| m.abort = false | |
| }; | |
| function k(r, q, s) { | |
| if (!m.abort) { | |
| m.loadedItems.push(s); | |
| if (m.imageLoaded != null) { | |
| m.imageLoaded(r, q) | |
| } | |
| if (o()) { | |
| f(true) | |
| } | |
| } | |
| } | |
| function o() { | |
| if (m.loadedItems.length == m.items.length) { | |
| return true | |
| } | |
| return false | |
| } | |
| function j(q) { | |
| m.loadedItems.push(q); | |
| if (m.imageLoadError != null) { | |
| m.imageLoadError(q.imageSrc, q.preLoadData) | |
| } | |
| if (o()) { | |
| f(false) | |
| } | |
| } | |
| function f(q) { | |
| m.items = []; | |
| m.loadedItems = []; | |
| if (!m.abort && m.batchLoaded != null) { | |
| m.batchLoaded(q) | |
| } | |
| m.abort = false | |
| } | |
| this.load = function () { | |
| if (!m.abort) { | |
| if (!m.items.length) { | |
| f(false) | |
| } else { | |
| if (Image.prototype == undefined) { | |
| Image.prototype = {} | |
| } | |
| Image.prototype.preLoadData = {}; | |
| for (var r in m.items) { | |
| q(m.items[r]) | |
| } | |
| } | |
| } | |
| function q(t) { | |
| var s = new Image(); | |
| s.preLoadData = t.preLoadData; | |
| s.onload = function () { | |
| k(s, s.preLoadData, t) | |
| }; | |
| s.onabort = function () { | |
| j(t) | |
| }; | |
| s.onerror = function () { | |
| j(t) | |
| }; | |
| s.src = t.imageSrc | |
| } | |
| } | |
| }; | |
| var c = d || a; | |
| return ap.system.imagePreload.Singleton[c] || (ap.system.imagePreload.Singleton[c] = new e(c, b)) | |
| }; | |
| ap.namespace("ap.system.imagePreload").Singleton = { | |
| "default": null | |
| }; | |
| ap.namespace("ap.slideshow.layout").MicroscropeSlideView = Backbone.View.extend({ | |
| tagName: "div", | |
| className: "slide", | |
| microscope: null, | |
| currentState: null, | |
| state: null, | |
| events: {}, | |
| initialize: function () { | |
| _.bindAll(this, "render", "update", "show", "hide", "addMicroscope"); | |
| this.state = this.options.state | |
| }, | |
| update: function (e, f) { | |
| var m = this, | |
| b = m.model, | |
| a = b.get("artwork"), | |
| c = 0, | |
| d = b && b.cid === e.cid; | |
| if (d) { | |
| return | |
| } | |
| m.hide(); | |
| m.model = e; | |
| if (!m.microscope) { | |
| m.addMicroscope() | |
| } | |
| if (!d && a && ((typeof (a) === "string" && a === m.model.get("artwork")) || (a.id === m.model.get("artwork").id))) { | |
| f = false; | |
| c = 1500 | |
| } | |
| if (e.artworkModel) { | |
| var l = e.attributes.part_x; | |
| var k = e.attributes.part_y; | |
| var j = e.attributes.part_zoom; | |
| m.currentState = new MicroscopeState(l, k, j) | |
| } else { | |
| m.currentState = null | |
| } | |
| if (_.isUndefined(f) || f == true) { | |
| m.microscope.microscope.LoadImage(this.model.attributes.cached_artwork_primary_image_full_url, m.currentState) | |
| } else { | |
| m.microscope.animate(m.currentState, c) | |
| } | |
| m.show() | |
| }, | |
| show: function (b) { | |
| var a = this; | |
| a.state = "current"; | |
| $(a.el).addClass("current") | |
| }, | |
| hide: function (b) { | |
| var a = this; | |
| a.state = null; | |
| $(a.el).removeClass("current") | |
| }, | |
| addMicroscope: function () { | |
| var a = this, | |
| b = { | |
| container: $(a.el), | |
| imageUrl: a.model.attributes.cached_artwork_primary_image_full_url, | |
| aspectRatio: a.model.attributes.primary_image_aspect_ratio, | |
| dontAnimate: true | |
| }, | |
| c = {}; | |
| if (a.model.artworkModel) { | |
| c.x = a.model.get("part_x"); | |
| c.y = a.model.get("part_y"); | |
| c.z = a.model.get("part_zoom"); | |
| b.microscopeState = new MicroscopeState(c.x, c.y, c.z) | |
| } | |
| a.microscope = new ap.microscope.layout.Main(b) | |
| }, | |
| render: function () { | |
| var a = this; | |
| if (a.options.model) { | |
| a.addMicroscope(); | |
| a.update(a.options.model, true) | |
| } | |
| $(a.options.parentView.el).append(this.el); | |
| return a | |
| } | |
| }); | |
| ap.namespace("ap.slideshow.layout").ImageSlideView = Backbone.View.extend({ | |
| tagName: "div", | |
| className: "slide", | |
| imageWrapper: null, | |
| image: null, | |
| cropWrapper: null, | |
| state: null, | |
| model: null, | |
| events: {}, | |
| initialize: function () { | |
| var a = this; | |
| _.bindAll(a, "render", "update", "center", "show", "hide", "addBookmarkCrop"); | |
| a.state = a.options.state; | |
| $(window).on("resize", a.center) | |
| }, | |
| update: function (b) { | |
| var a = this; | |
| a.model = b.artworkModel || b; | |
| var d = a.model.calculateImageSizeForAPI({ | |
| width: $(window).width(), | |
| height: $(window).height() | |
| }); | |
| var c = '<div class="image-slide-wrapper"><img class="image-slide" src="' + a.model.image(d) + '" alt="' + b.attributes.title + '" /><span class="crop-wrapper"></span></div>'; | |
| $(this.el).empty().append(c); | |
| a.imageWrapper = $(this.el).find(".image-slide-wrapper"); | |
| a.image = $(this.el).find(".image-slide"); | |
| a.cropWrapper = $(this.el).find(".crop-wrapper"); | |
| a.image.one("load", a.center); | |
| if (b.artworkModel) { | |
| a.addBookmarkCrop(b) | |
| } | |
| }, | |
| addBookmarkCrop: function (b) { | |
| var a = this; | |
| ap.drawCrop(a.image, a.cropWrapper, b.get("part_x"), b.get("part_y"), b.get("part_zoom")) | |
| }, | |
| center: function (f) { | |
| var c = this; | |
| if (c.image && c.image.length) { | |
| var d = $(window).width(); | |
| var l = $(window).height(); | |
| var b = c.image.width(); | |
| var a = c.image.height(); | |
| var k = Math.round((d * 0.5) - (b * 0.5)); | |
| var j = Math.round((l * 0.5) - (a * 0.5)); | |
| if (a > l) { | |
| c.image.css("height", l) | |
| } | |
| c.imageWrapper.css({ | |
| top: j, | |
| left: k | |
| }) | |
| } | |
| }, | |
| show: function (b) { | |
| var a = this; | |
| a.center(); | |
| a.state = "current"; | |
| $(a.el).addClass("current"); | |
| a.center() | |
| }, | |
| hide: function (b) { | |
| var a = this; | |
| a.state = null; | |
| $(a.el).removeClass("current") | |
| }, | |
| render: function () { | |
| var a = this; | |
| if (a.options.model) { | |
| a.update(a.options.model) | |
| } | |
| $(a.options.parentView.el).append(this.el); | |
| a.center(); | |
| return a | |
| } | |
| }); | |
| ap.namespace("ap.slideshow.layout").BaseSlideManager = Backbone.View.extend({ | |
| tagName: "div", | |
| className: "slideMover", | |
| currentDataIndex: -1, | |
| collection: null, | |
| initialize: function (a) { | |
| _.bindAll(this, "render", "change"); | |
| this.collection = this.options.parentView.collection | |
| }, | |
| getItemIndexFromModel: function (c) { | |
| var b = this.collection._byId[c]; | |
| var a = _.indexOf(this.collection.models, b); | |
| return a | |
| }, | |
| getItemFromCollection: function (a) { | |
| return this.collection.at(a) | |
| }, | |
| goToItem: function (b, d, c) { | |
| var a = this; | |
| var b = b; | |
| if (b === null || b < 0) { | |
| b = a.getItemIndexFromModel(d) | |
| } | |
| a.render(b, c) | |
| }, | |
| change: function (b) { | |
| var a = this; | |
| if (a.currentDataIndex < a.collection.models.length - 1) { | |
| $(a.el).trigger("more", ["next"]) | |
| } | |
| if (a.currentDataIndex > 0) { | |
| $(a.el).trigger("more", ["prev"]) | |
| } | |
| if (a.currentDataIndex == a.collection.models.length - 1) { | |
| $(a.el).trigger("nomore", ["next"]) | |
| } | |
| if (a.currentDataIndex == 0) { | |
| $(a.el).trigger("nomore", ["prev"]) | |
| } | |
| }, | |
| render: function (a, b) {}, | |
| go: function () {} | |
| }); | |
| ap.namespace("ap.slideshow.layout").StandardSlideManager = ap.slideshow.layout.BaseSlideManager.extend({ | |
| currentSlideIndex: -1, | |
| slides: [], | |
| initialize: function () { | |
| ap.slideshow.layout.BaseSlideManager.prototype.initialize.call(this, [this.options]); | |
| _.bind(this, "recycle") | |
| }, | |
| change: function (c) { | |
| var a = this; | |
| if (c == "next" && a.currentDataIndex < a.collection.models.length - 1) { | |
| var b = a.currentSlideIndex + 1; | |
| a.showHideSlides(b); | |
| a.currentDataIndex++; | |
| a.recycle(c) | |
| } else { | |
| if (c == "next" && a.currentDataIndex == a.collection.models.length - 1) { | |
| a.goToItem(0, null, true) | |
| } else { | |
| if (c == "prev" && a.currentDataIndex > 0) { | |
| var b = a.currentSlideIndex - 1; | |
| a.showHideSlides(b); | |
| a.currentDataIndex--; | |
| a.recycle(c) | |
| } | |
| } | |
| } | |
| if (a.currentDataIndex < a.collection.models.length - 1) { | |
| $(a.el).trigger("more", ["next"]) | |
| } | |
| if (a.currentDataIndex > 0) { | |
| $(a.el).trigger("more", ["prev"]) | |
| } | |
| if (a.currentDataIndex == a.collection.models.length - 1) { | |
| $(a.el).trigger("nomore", ["next"]) | |
| } | |
| if (a.currentDataIndex == 0) { | |
| $(a.el).trigger("nomore", ["prev"]) | |
| } | |
| }, | |
| showHideSlides: function (b) { | |
| var a = this; | |
| if (a.currentSlideIndex > -1) { | |
| a.slides[a.currentSlideIndex].hide() | |
| } | |
| a.slides[b].show(); | |
| $(a.el).trigger("changed", [a.slides[b].model, a.currentDataIndex]); | |
| a.currentSlideIndex = b | |
| }, | |
| recycle: function (e) { | |
| var c = this; | |
| var d = $(c.slides[c.currentSlideIndex].el); | |
| var a = d.index(); | |
| if (a >= 3 && e == "next" && c.currentDataIndex + 2 < c.collection.models.length) { | |
| var b = c.getItemFromCollection(c.currentDataIndex + 2); | |
| var f = c.slides.shift(); | |
| f.update(b); | |
| c.slides.push(f); | |
| c.currentSlideIndex--; | |
| $(c.el).append($(".slide").first()) | |
| } else { | |
| if (a <= 2 && e == "prev" && c.currentDataIndex - 2 > -1) { | |
| var b = c.getItemFromCollection(c.currentDataIndex - 2); | |
| var f = c.slides.pop(); | |
| f.update(b); | |
| c.slides.unshift(f); | |
| c.currentSlideIndex++; | |
| $(c.el).prepend($(".slide").last()) | |
| } | |
| } | |
| }, | |
| render: function (c, j) { | |
| ap.slideshow.layout.BaseSlideManager.prototype.render.call(this, []); | |
| var b = this; | |
| $(".slide").remove(); | |
| b.slides = []; | |
| if (c < 0) { | |
| c = 0 | |
| } | |
| if (c > 0) { | |
| c-- | |
| } | |
| var e = (b.collection.models.length >= 5) ? 5 : b.collection.models.length; | |
| for (var d = 0; d < e; d++) { | |
| var f = b.getItemFromCollection(c + d); | |
| var a = new ap.slideshow.layout.ImageSlideView({ | |
| parentView: b, | |
| model: f | |
| }); | |
| $(a.el).addClass("s" + d); | |
| a.render(); | |
| b.slides.push(a) | |
| } | |
| $(b.options.parentView.el).append(b.el); | |
| b.currentDataIndex = c; | |
| b.currentSlideIndex = (c > 0) ? 1 : 0; | |
| if (j) { | |
| b.go() | |
| } | |
| }, | |
| go: function () { | |
| var a = this; | |
| a.slides[a.currentSlideIndex].show(); | |
| if (a.currentDataIndex == 0) { | |
| $(a.el).trigger("nomore", ["prev"]) | |
| } | |
| $(a.el).trigger("changed", [a.slides[a.currentSlideIndex].model, a.currentDataIndex]) | |
| } | |
| }); | |
| ap.namespace("ap.slideshow.layout").timeout = []; | |
| ap.namespace("ap.slideshow.layout").MicroscopeSlideManager = ap.slideshow.layout.BaseSlideManager.extend({ | |
| slide: null, | |
| currentModel: null, | |
| initialize: function () { | |
| ap.slideshow.layout.BaseSlideManager.prototype.initialize.call(this, [this.options]) | |
| }, | |
| change: function (b) { | |
| var a = this; | |
| if (b == "next" && a.currentDataIndex < a.collection.models.length - 1) { | |
| a.currentDataIndex++; | |
| a.updateSlide() | |
| } else { | |
| if (b == "next" && a.currentDataIndex == a.collection.models.length - 1) { | |
| a.slide.hide(); | |
| a.goToItem(0, null, true) | |
| } else { | |
| if (b == "prev" && a.currentDataIndex > 0) { | |
| a.currentDataIndex--; | |
| a.updateSlide() | |
| } | |
| } | |
| } | |
| ap.slideshow.layout.BaseSlideManager.prototype.change.call(this, []) | |
| }, | |
| updateSlide: function () { | |
| var b = this; | |
| var c = b.getItemFromCollection(b.currentDataIndex); | |
| var a = b.currentModel; | |
| var d = c; | |
| var e = (a.id == d.id) ? false : true; | |
| b.slide.update(c, e); | |
| b.currentModel = c; | |
| $(b.el).trigger("changed", [c, b.currentDataIndex]) | |
| }, | |
| render: function (b, d) { | |
| ap.slideshow.layout.BaseSlideManager.prototype.render.call(this, []); | |
| var a = this; | |
| if (b < 0) { | |
| b = 0 | |
| } | |
| var c = a.getItemFromCollection(b); | |
| if (!a.slide) { | |
| a.slide = new ap.slideshow.layout.MicroscropeSlideView({ | |
| parentView: a, | |
| model: c | |
| }); | |
| a.slide.render(); | |
| $(a.options.parentView.el).append(a.el) | |
| } else { | |
| a.slide.update(c, true) | |
| } | |
| a.currentModel = c; | |
| a.currentDataIndex = b; | |
| a.currentSlideIndex = (b > 0) ? 1 : 0; | |
| if (d) { | |
| a.go() | |
| } | |
| }, | |
| go: function () { | |
| var a = this; | |
| a.slide.show(); | |
| if (a.currentDataIndex == 0) { | |
| $(a.el).trigger("nomore", ["prev"]) | |
| } | |
| $(a.el).trigger("changed", [a.getItemFromCollection(a.currentDataIndex), a.currentDataIndex]) | |
| } | |
| }); | |
| ap.namespace("ap.slideshow.layout").ControlsView = Backbone.View.extend({ | |
| tagName: "div", | |
| className: "controls", | |
| timer: "", | |
| templates: { | |
| control_template: '<div class="controller"><div class="mover previous" direction="prev" title="' + TRANSLATIONS.previous + '"></div><div class="pp pause" title="' + TRANSLATIONS.pause + '"></div><div class="mover next" direction="next" title="' + TRANSLATIONS.next + '"></div></div>', | |
| duration_template: '<div class="duration"><div class="label">' + TRANSLATIONS.duration + '</div><div class="minus" title="-"></div><input type="text" class="number" name="number" /><div class="plus" title="+"></div></div>', | |
| close_template: '<div class="close" title="' + TRANSLATIONS.close + '" href="javascript:void(0)"></div>' | |
| }, | |
| mobileTemplates: { | |
| control_template: '<div class="controller"><div class="mover previous" direction="prev" title="' + TRANSLATIONS.previous + '"><span class="sprite"></span></div><div class="pp pause" title="' + TRANSLATIONS.pause + '"><span class="sprite"></span></div><div class="mover next" direction="next" title="' + TRANSLATIONS.next + '"><span class="sprite"></span></div></div>', | |
| duration_template: '<div class="duration"><div class="label">' + TRANSLATIONS.duration + '</div><div class="minus" title="-"><span class="sprite"></span></div><input type="text" class="number" name="number" /><div class="plus" title="+"><span class="sprite"></span></div></div>', | |
| close_template: '<div class="close" title="' + TRANSLATIONS.close + '" href="javascript:void(0)"><span class="sprite"></span></div>' | |
| }, | |
| events: { | |
| "click .close": "close", | |
| "click .previous": "previous_next", | |
| "click .pause": "play_pause", | |
| "click .play": "play_pause", | |
| "click .next": "previous_next", | |
| "click .minus": "minus", | |
| "click .plus": "plus", | |
| "change .number": "change_timer" | |
| }, | |
| initialize: function () { | |
| var a = this; | |
| _.bindAll(a, "render"); | |
| a.collection = a.options.mainView.artworkList; | |
| if (ap.isMobile) { | |
| a.events = { | |
| "touchend .close": "close", | |
| "touchend .previous": "previous_next", | |
| "touchend .pause": "play_pause", | |
| "touchend .play": "play_pause", | |
| "touchend .next": "previous_next", | |
| "touchend .minus": "minus", | |
| "touchend .plus": "plus", | |
| "change .number": "change_timer" | |
| } | |
| } | |
| }, | |
| previous_next: function (c) { | |
| var a = this; | |
| var b = $(c.currentTarget); | |
| var d = b.attr("direction"); | |
| $(a.el).trigger("seek", [d]) | |
| }, | |
| hide_control: function (b) { | |
| var a = this; | |
| $(a.el).find("div." + b).fadeOut() | |
| }, | |
| show_control: function (b) { | |
| var a = this; | |
| $(a.el).find("div." + b).fadeIn() | |
| }, | |
| show_controls: function () { | |
| var b = this; | |
| var a = $(b.el).find("div.mover"); | |
| if (a.is(":hidden")) { | |
| a.fadeIn() | |
| } | |
| }, | |
| play_pause: function (b) { | |
| var a = this; | |
| if (a.options.mainView.isPlaying) { | |
| $(a.el).trigger("playpause", ["pause"]) | |
| } else { | |
| $(a.el).trigger("playpause", ["play"]) | |
| } | |
| return false | |
| }, | |
| updateState: function (b) { | |
| var a = this; | |
| if (b == "play") { | |
| a.showPauseButton() | |
| } else { | |
| if (b == "pause") { | |
| a.showPlayButton() | |
| } | |
| } | |
| }, | |
| showPauseButton: function () { | |
| $(".pp").removeClass("play").addClass("pause").attr("title", TRANSLATIONS.pause) | |
| }, | |
| showPlayButton: function () { | |
| $(".pp").removeClass("pause").addClass("play").attr("title", TRANSLATIONS.play) | |
| }, | |
| minus: function () { | |
| var c = this; | |
| var b = $(".number"); | |
| var a = b.val(); | |
| if (--a <= 2) { | |
| b.val(2) | |
| } else { | |
| b.val(--a) | |
| } | |
| c.change_timer(null) | |
| }, | |
| plus: function () { | |
| var c = this; | |
| var b = $(".number"); | |
| var a = b.val(); | |
| b.val(++a); | |
| c.change_timer(null) | |
| }, | |
| change_timer: function (c) { | |
| var b = this; | |
| if (c === null) { | |
| var a = $(".number") | |
| } else { | |
| var a = $(c.currentTarget) | |
| } | |
| if (+a.val() != NaN) { | |
| $(b.el).trigger("changetimer", [a.val()]) | |
| } | |
| }, | |
| close: function () { | |
| var a = this; | |
| $(a.el).trigger("exit") | |
| }, | |
| render: function () { | |
| var a = this; | |
| var b = (ap.isMobile) ? a.mobileTemplates : a.templates; | |
| $(a.el).append(b.duration_template); | |
| $(a.el).append(b.control_template); | |
| $(a.el).append(b.close_template); | |
| $(a.el).find(".number").val(a.options.initialDuration); | |
| $(a.options.mainView.el).prepend(a.el) | |
| } | |
| }); | |
| ap.slideshow.layout.MainView = Backbone.View.extend({ | |
| tagName: "div", | |
| id: "slideshow", | |
| hudView: null, | |
| slideManager: null, | |
| events: { | |
| mousedown: "handleMouseDown", | |
| mousemove: "handleMouseMove", | |
| mouseup: "handleMouseUp", | |
| "mouseenter .controls": "handleMouseEnter", | |
| "mouseenter #thumbnail-strip": "handleMouseEnter", | |
| "mouseleave .controls": "handleMouseLeave", | |
| "mouseleave #thumbnail-strip": "handleMouseLeave", | |
| "playpause .controls": "playPauseSlideshow", | |
| "seek .controls": "prevNextSlide", | |
| "changetimer .controls": "changeDuration", | |
| "exit .controls": "exitSlideshow", | |
| "more .slideMover": "handleMoreSlides", | |
| "nomore .slideMover": "handleNoMoreSlides", | |
| "changed .slideMover": "handleSlideChange" | |
| }, | |
| isPlaying: false, | |
| mouseIsDown: false, | |
| mouseIsDragging: false, | |
| mouseIsOver: false, | |
| drag: null, | |
| timer: null, | |
| timerDuration: 4, | |
| isFirstTime: true, | |
| closerTemplate: '<div id="close-slideshow-esc"><p>' + TRANSLATIONS.press_esc + "</p></div>", | |
| initialize: function () { | |
| _.bindAll(this, "render", "startSlideShow", "handleMouseDown", "handleMouseMove", "handleMouseUp", "handleMouseEnter", "handleMouseLeave", "playPauseSlideshow", "runTimer", "prevNextSlide", "changeDuration", "exitSlideshow", "handleMoreSlides", "handleNoMoreSlides", "handleSlideChange", "handleThumbnailClick", "handleInfoClick"); | |
| var a = this.options.sidebar.parentView.currentCollection || this.options.sidebar.parentView.thumbnailStrip.artworkList; | |
| this.collection = $.extend(true, {}, a); | |
| this.collection.unbind() | |
| }, | |
| render: function (a) { | |
| if (!$("#slideshow").length) { | |
| $("body").append(this.el) | |
| } | |
| this.prep(a) | |
| }, | |
| prep: function (b) { | |
| var a = this; | |
| if (ap.isMobile) { | |
| a.slideManager = new ap.slideshow.layout.StandardSlideManager({ | |
| parentView: a | |
| }) | |
| } else { | |
| a.slideManager = new ap.slideshow.layout.MicroscopeSlideManager({ | |
| parentView: a | |
| }) | |
| } | |
| a.slideManager.goToItem(null, b, false); | |
| a.hudView = new ap.slideshow.layout.HudView({ | |
| container: $(this.el), | |
| parentView: a, | |
| slideManager: a.slideManager, | |
| initialDuration: a.timerDuration | |
| }); | |
| $(a.hudView.bottomBar).on("artworkClicked", a.handleThumbnailClick); | |
| $(a.hudView.label.el).on("detailClicked", a.handleInfoClick); | |
| this.startSlideShow() | |
| }, | |
| startSlideShow: function () { | |
| var a = this; | |
| $(a.el).fadeIn(); | |
| a.slideManager.go(); | |
| if (!ap.isMobile) { | |
| a.showCloser(); | |
| a.attachKeyListeners() | |
| } | |
| a.playPauseSlideshow(null, "play", a.hudView.TIMER_SLOW) | |
| }, | |
| showCloser: function () { | |
| var b = this; | |
| $(b.el).append(b.closerTemplate); | |
| var c = $("#close-slideshow-esc"); | |
| c.fadeIn(function a() { | |
| var d = setTimeout(function e() { | |
| c.fadeOut("slow", | |
| function f() { | |
| c.remove() | |
| }) | |
| }, 2000) | |
| }) | |
| }, | |
| handleSlideChange: function (d, c, b) { | |
| var a = this; | |
| a.hudView.label.update(c); | |
| a.hudView.bottomBar.highlightArtwork(c.attributes.id); | |
| a.hudView.bottomBar.scrollToCurrentArtwork() | |
| }, | |
| handleThumbnailClick: function (d, a) { | |
| var b = this; | |
| var c = a.bookmarkModel || a.model; | |
| b.slideManager.goToItem(null, c.id, true); | |
| clearTimeout(b.timer); | |
| b.runTimer() | |
| }, | |
| handleInfoClick: function (b) { | |
| var a = this; | |
| a.exitSlideshow() | |
| }, | |
| playPauseSlideshow: function (c, b, d) { | |
| var a = this; | |
| if (a.timer != null) { | |
| clearTimeout(a.timer); | |
| a.timer = null | |
| } | |
| if (!_.isUndefined(b)) { | |
| a.hudView.topBar.updateState(b); | |
| if (b == "pause") { | |
| a.isPlaying = false; | |
| a.hudView.hideHud(d) | |
| } else { | |
| a.isPlaying = true; | |
| a.runTimer(); | |
| a.hudView.hideHud(d) | |
| } | |
| } | |
| }, | |
| runTimer: function () { | |
| var a = this; | |
| var b = a.timerDuration * 1000; | |
| if (a.timer == null && !a.isFirstTime) { | |
| b = 1000 | |
| } | |
| a.timer = setTimeout(function () { | |
| a.isFirstTime = false; | |
| if (a.collection.models.length > 1 && a.isPlaying) { | |
| a.prevNextSlide(null, "next"); | |
| a.runTimer() | |
| } else { | |
| a.playPauseSlideshow(null, "pause", a.hudView.TIMER_SLOW) | |
| } | |
| }, b) | |
| }, | |
| prevNextSlide: function (c, b) { | |
| var a = this; | |
| if (c != null) { | |
| a.playPauseSlideshow(null, "pause", a.hudView.TIMER_SLOW) | |
| } | |
| switch (b) { | |
| case "next": | |
| a.slideManager.change("next"); | |
| break; | |
| case "prev": | |
| a.slideManager.change("prev"); | |
| break | |
| } | |
| return false | |
| }, | |
| changeDuration: function (c, b) { | |
| var a = this; | |
| a.timerDuration = b; | |
| a.isFirstTime = true; | |
| return false | |
| }, | |
| exitSlideshow: function (b) { | |
| var a = this; | |
| a.playPauseSlideshow(null, "pause", a.hudView.TIMER_SLOW); | |
| a.isPlaying = false; | |
| if (a.collection) { | |
| a.collection.unbind(); | |
| a.collection = null | |
| } | |
| a.hudView.bottomBar.unload(); | |
| $(a.el).fadeOut(function () { | |
| a.remove() | |
| }) | |
| }, | |
| attachKeyListeners: function () { | |
| var a = this; | |
| document.addEventListener("keydown", | |
| function (b) { | |
| switch (b.keyCode) { | |
| case 13: | |
| case 27: | |
| b.preventDefault(); | |
| a.exitSlideshow(); | |
| break | |
| } | |
| }, false) | |
| }, | |
| handleMouseDown: function (b) { | |
| var a = this; | |
| a.mouseIsDown = true; | |
| if (a.isPlaying) { | |
| if (!a.hudView.visible) { | |
| a.playPauseSlideshow(b, "pause", a.hudView.TIMER_FAST) | |
| } | |
| a.hudView.showHud(a.hudView.TIMER_FAST); | |
| a.hudView.hideHud(a.hudView.TIMER_SLOW) | |
| } | |
| }, | |
| handleMouseMove: function (f) { | |
| var c = this; | |
| var a = f.pageY; | |
| if (c.mouseIsDown) { | |
| if (c.drag == null) { | |
| c.drag = { | |
| startX: f.pageX, | |
| startY: f.pageY | |
| } | |
| } | |
| var b = f.pageX; | |
| var j = c.drag.startX - b; | |
| var d = c.drag.startY - a; | |
| if (j < 0) { | |
| j = -j | |
| } | |
| if (d < 0) { | |
| d = -d | |
| } | |
| if (j > 10 || d > 10) { | |
| c.mouseIsDragging = true; | |
| if (c.hudView.visible) { | |
| c.hudView.hideHud(0) | |
| } | |
| } | |
| } else { | |
| if (a < 100) { | |
| c.hudView.showHud(c.hudView.TIMER_FAST); | |
| c.hudView.hideHud(c.hudView.TIMER_SLOW) | |
| } | |
| } | |
| }, | |
| handleMouseUp: function (f) { | |
| var b = this; | |
| b.mouseIsDown = false; | |
| b.drag = null; | |
| var c = $(".controls").height(); | |
| var d = $(window).height() - $("#thumbnail-strip").height() - 10; | |
| if (b.hudView.visible && f.pageY > c && f.pageY < d && !b.mouseIsOver) { | |
| var a = $("artworkInfo a").attr("href"); | |
| if (a) { | |
| b.exitSlideshow(); | |
| window.location = a | |
| } else { | |
| b.hudView.hideHud(b.hudView.TIMER_FAST) | |
| } | |
| } else { | |
| if (!b.hudView.visible && !b.mouseIsDragging && !b.mouseIsOver) { | |
| b.hudView.showHud(b.hudView.TIMER_FAST); | |
| b.hudView.hideHud(b.hudView.TIMER_SLOW) | |
| } | |
| } | |
| b.mouseIsDragging = false | |
| }, | |
| handleMouseEnter: function (b) { | |
| var a = this; | |
| a.mouseIsOver = true; | |
| a.hudView.showHud(a.hudView.TIMER_FAST) | |
| }, | |
| handleMouseLeave: function (b) { | |
| var a = this; | |
| a.mouseIsOver = false; | |
| a.hudView.hideHud(a.hudView.TIMER_SLOW) | |
| }, | |
| handleMoreSlides: function (c, b) { | |
| var a = this; | |
| if (b == "next") { | |
| a.hudView.topBar.show_control("next") | |
| } else { | |
| a.hudView.topBar.show_control("previous") | |
| } | |
| }, | |
| handleNoMoreSlides: function (c, b) { | |
| var a = this; | |
| if (b == "next") { | |
| a.hudView.topBar.hide_control("next") | |
| } else { | |
| a.hudView.topBar.hide_control("previous") | |
| } | |
| }, | |
| enterFullscreen: function () { | |
| var a = this; | |
| var b = document.getElementById("slideshow"); | |
| ap.system.FullScreen.enterFullScreen(b); | |
| ap.system.FullScreen.onFullScreenChange(b, | |
| function () { | |
| if (!ap.system.FullScreen.isFullScreen()) { | |
| a.exitSlideshow() | |
| } | |
| }) | |
| }, | |
| exitFullScreen: function () { | |
| ap.system.FullScreen.exitFullScreen() | |
| } | |
| }); | |
| ap.namespace("ap.system").FullScreen = { | |
| toggle: function (a) { | |
| if ((document.fullScreenElement && document.fullScreenElement !== null) || (!document.mozFullScreen && !document.webkitIsFullScreen)) { | |
| this.enterFullScreen(a) | |
| } else { | |
| this.exitFullScreen() | |
| } | |
| }, | |
| isFullScreen: function () { | |
| if (document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen) { | |
| return true | |
| } else { | |
| return false | |
| } | |
| }, | |
| enterFullScreen: function (a) { | |
| if (a.requestFullScreen) { | |
| a.requestFullScreen() | |
| } else { | |
| if (a.mozRequestFullScreen) { | |
| a.mozRequestFullScreen() | |
| } else { | |
| if (a.webkitRequestFullScreen) { | |
| a.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT) | |
| } | |
| } | |
| } | |
| }, | |
| exitFullScreen: function () { | |
| if (document.cancelFullScreen) { | |
| document.cancelFullScreen() | |
| } else { | |
| if (document.mozCanceFullScreen) { | |
| document.mozCanceFullScreen() | |
| } else { | |
| if (document.webkitCancelFullScreen) { | |
| document.webkitCancelFullScreen() | |
| } | |
| } | |
| } | |
| }, | |
| onFullScreenChange: function (a, b) { | |
| a.onwebkitfullscreenchange = b | |
| } | |
| }; | |
| ap.slideshow.layout.HudView = Backbone.View.extend({ | |
| topBar: null, | |
| label: null, | |
| bottomBar: null, | |
| visible: true, | |
| showTimer: null, | |
| hideTimer: null, | |
| TIMER_FAST: 100, | |
| TIMER_MED: 1500, | |
| TIMER_SLOW: 5000, | |
| initialize: function () { | |
| _.bindAll(this, "render"); | |
| this.render() | |
| }, | |
| render: function () { | |
| this.setupTopBar(); | |
| this.setupLabel(); | |
| this.setupBottomBar(); | |
| this.hideHud(this.TIMER_SLOW) | |
| }, | |
| setupTopBar: function () { | |
| var a = this; | |
| a.topBar = new ap.slideshow.layout.ControlsView({ | |
| mainView: a.options.parentView, | |
| initialDuration: a.options.initialDuration | |
| }); | |
| a.topBar.render() | |
| }, | |
| setupLabel: function () { | |
| var a = this; | |
| a.label = new ap.slideshow.layout.SlideInfoView({ | |
| mainView: a.options.parentView | |
| }); | |
| a.label.render() | |
| }, | |
| setupBottomBar: function () { | |
| var b = this; | |
| var a = { | |
| showPivots: false, | |
| autoHide: false, | |
| collectionToUse: b.options.parentView.collection | |
| }; | |
| b.bottomBar = new ap.slideshow.layout.ThumbnailStripView({ | |
| container: b.options.container, | |
| parentView: b.options.parentView, | |
| settings: a | |
| }) | |
| }, | |
| showHud: function (b) { | |
| var a = this; | |
| $(".slideMover").css("cursor", "pointer"); | |
| if (a.showTimer) { | |
| clearTimeout(a.showTimer) | |
| } | |
| if (a.hideTimer) { | |
| clearTimeout(a.hideTimer) | |
| } | |
| a.showTimer = setTimeout(function () { | |
| a.visible = true; | |
| $(a.topBar.el).animate({ | |
| top: 0 | |
| }); | |
| $(a.label.el).fadeIn(); | |
| $(a.bottomBar.el).animate({ | |
| bottom: 0 | |
| }) | |
| }, b); | |
| a.bottomBar.scrollToCurrentArtwork() | |
| }, | |
| hideHud: function (b) { | |
| var a = this; | |
| $(".slideMover").css("cursor", "auto"); | |
| if (a.hideTimer) { | |
| clearTimeout(a.hideTimer) | |
| } | |
| a.hideTimer = setTimeout(function () { | |
| a.visible = false; | |
| $(a.topBar.el).animate({ | |
| top: -$(a.topBar.el).height() | |
| }); | |
| $(a.label.el).fadeOut(); | |
| $(a.bottomBar.el).animate({ | |
| bottom: -$(a.bottomBar.el).height() | |
| }) | |
| }, b) | |
| } | |
| }); | |
| ap.slideshow.layout.SlideInfoView = Backbone.View.extend({ | |
| tagName: "div", | |
| className: "artworkInfo", | |
| template: '<a href="#"><span class="title"></span><span class="date"></span><span class="artist"></span></a>', | |
| events: { | |
| "click a": "handleInfoClick" | |
| }, | |
| titleEl: null, | |
| dateEl: null, | |
| artistEl: null, | |
| artworkUrl: null, | |
| initialize: function () { | |
| _.bindAll(this, "render", "update", "handleInfoClick"); | |
| $(self.el).addClass("active") | |
| }, | |
| render: function () { | |
| var a = this; | |
| $(a.el).append(a.template); | |
| $(a.options.mainView.el).append(a.el); | |
| a.titleEl = $(".artworkInfo .title"); | |
| a.dateEl = $(".artworkInfo .date"); | |
| a.artistEl = $(".artworkInfo .artist") | |
| }, | |
| update: function (c) { | |
| var a = this; | |
| var b = c; | |
| $(a.el).find("a").attr("href", b.attributes.detail_url); | |
| a.titleEl.html(b.attributes.title); | |
| a.dateEl.html(b.attributes.pretty_display_date); | |
| a.artistEl.html(b.attributes.artist_display_name) | |
| }, | |
| handleInfoClick: function (b) { | |
| var a = this; | |
| $(a.el).trigger("detailClicked") | |
| } | |
| }); | |
| ap.faqs.MainView = ap.globals.MainBaseView.extend({ | |
| options: { | |
| disabledButtons: [".add-to-collection", ".slideshow"], | |
| }, | |
| initialize: function () { | |
| ap.globals.MainBaseView.prototype.initialize.call(this, [this.options]); | |
| this.render() | |
| }, | |
| }); | |
| $(document).ready(function () { | |
| if ($("#faqs").length) { | |
| window.app = new ap.faqs.MainView() | |
| } | |
| }); | |
| ap.education.MainView = ap.globals.MainBaseView.extend({ | |
| options: { | |
| disabledButtons: [".add-to-collection", ".slideshow"], | |
| }, | |
| initialize: function () { | |
| ap.globals.MainBaseView.prototype.initialize.call(this, [this.options]); | |
| this.render() | |
| }, | |
| }); | |
| $(document).ready(function () { | |
| if ($("#education").length) { | |
| window.app = new ap.education.MainView() | |
| } | |
| }); | |
| ap.namespace("ap.aggregation.layout").ArtworkInfoPopupView = Backbone.View.extend({ | |
| el: $("body"), | |
| artworkInfo: {}, | |
| template: '<div style="display: none;" id="artwork-info"><h4></h4><p class="date"></p><p class="artist"></p><p class="museum"></p></div>', | |
| events: { | |
| "mouseenter .main-content a.artwork": "showArtworkInfo", | |
| "mouseleave .main-content a.artwork": "hideArtworkInfo", | |
| "jsp-scroll-x .scroll-pane": "scrollPanelXScroll" | |
| }, | |
| initialize: function () { | |
| _.bindAll(this, "render") | |
| }, | |
| attach: function () { | |
| this.render(); | |
| this.delegateEvents() | |
| }, | |
| remove: function () { | |
| $(this.el).unbind(".delegateEvents" + this.cid); | |
| this.artworkInfo.remove() | |
| }, | |
| scrollPanelXScroll: function (a, b, j, f) { | |
| var d = $(".rows .left-c-box") || $(".rows .right-c-box"); | |
| if (d) { | |
| var c = { | |
| currentTarget: d | |
| }; | |
| this.hideArtworkInfo(c) | |
| } | |
| }, | |
| showArtworkInfo: function (c) { | |
| var a = $(c.currentTarget); | |
| var b = a.find("img"); | |
| this.populateArtworkInfoPanel(a); | |
| this.positionArtworkInfoPanel(b); | |
| if (this.isPushRight(b)) { | |
| a.addClass("right-c-box"); | |
| this.artworkInfo.addClass("left-c-box") | |
| } else { | |
| a.addClass("left-c-box"); | |
| this.artworkInfo.addClass("right-c-box") | |
| } | |
| this.artworkInfo.show() | |
| }, | |
| hideArtworkInfo: function (b) { | |
| this.artworkInfo.hide(); | |
| var a = $(b.currentTarget); | |
| a.removeClass("right-c-box"); | |
| a.removeClass("left-c-box"); | |
| this.artworkInfo.removeClass("right-c-box"); | |
| this.artworkInfo.removeClass("left-c-box") | |
| }, | |
| isPushRight: function (a) { | |
| return $(a).offset().left - $(".main-content").scrollLeft() - this.artworkInfo.outerWidth(true) - parseInt($(".content-with-sidebar").css("margin-left"), 10) <= 0 | |
| }, | |
| populateArtworkInfoPanel: function (b) { | |
| var a = b.data("model"); | |
| this.artworkInfo.find("h4").text(ap.truncatewords(a.attributes.title, 8)); | |
| if (a.attributes.pretty_display_date) { | |
| this.artworkInfo.find(".date").html(a.attributes.pretty_display_date) | |
| } else { | |
| this.artworkInfo.find(".date").html("") | |
| } | |
| this.artworkInfo.find(".artist").html(a.artistDisplayName()); | |
| this.artworkInfo.find(".museum").html(a.attributes.collection_display_name) | |
| }, | |
| positionArtworkInfoPanel: function (b) { | |
| this.artworkInfo.css("top", $(b.context).offset().top); | |
| this.artworkInfo.css("min-height", b.height()); | |
| var a = 2; | |
| if (this.isPushRight(b)) { | |
| this.artworkInfo.css("left", $(b).offset().left - $(".main-content").scrollLeft() + b.context.offsetWidth - a) | |
| } else { | |
| this.artworkInfo.css("left", $(b).offset().left - $(".main-content").scrollLeft() - this.artworkInfo.outerWidth(true) + a) | |
| } | |
| }, | |
| render: function () { | |
| this.artworkInfo = $("#artwork-info"); | |
| if (!this.artworkInfo.length) { | |
| this.el.append(this.template); | |
| this.artworkInfo = $("#artwork-info") | |
| } | |
| } | |
| }); | |
| ap.namespace("ap.aggregation.layout").ArtworkInfoFixedView = Backbone.View.extend({ | |
| el: $(".artwork-info-fixed"), | |
| artworkInfo: [], | |
| template: '<div class="artwork-info-fixed" style="display: none;"><h4><%= title %></h4><p class="date"><%= date %></p><p class="artist"><%= artist %></p><p class="museum"><%=collection %></p></div>', | |
| events: {}, | |
| initialize: function () { | |
| _.bindAll(this, "render") | |
| }, | |
| reinitialise: function () { | |
| $(this.artworkInfo).remove(); | |
| this.artworkInfo = [] | |
| }, | |
| showArtworkInfo: function () { | |
| var a = this; | |
| var b = $(".artwork").not($(".artwork-info-fixed").parent()); | |
| _.each(b, | |
| function (c) { | |
| var d = $(c); | |
| d.append(a.getArtworkInfoPanel(d.data("model"))) | |
| }); | |
| this.artworkInfo = $(".artwork-info-fixed"); | |
| this.artworkInfo.show() | |
| }, | |
| hideArtworkInfo: function () { | |
| this.artworkInfo.hide() | |
| }, | |
| getArtworkInfoPanel: function (a) { | |
| var c = ""; | |
| if (a) { | |
| var b = { | |
| title: ap.truncatewords(a.attributes.title, 8), | |
| date: "", | |
| artist: a.artistDisplayName(), | |
| collection: a.attributes.collection_display_name | |
| }; | |
| if (a.attributes.pretty_display_date) { | |
| b.date = a.attributes.pretty_display_date | |
| } | |
| c = _.template(this.template, b) | |
| } | |
| return c | |
| }, | |
| render: function () { | |
| this.showArtworkInfo() | |
| }, | |
| remove: function () { | |
| this.hideArtworkInfo() | |
| } | |
| }); | |
| ap.namespace("ap.aggregation.layout").ArtworkInfo = Backbone.View.extend({ | |
| initialize: function () { | |
| _.bindAll(this, "render", "removeArtworkInfo", "setArtworkInfo") | |
| }, | |
| artworkInfoPopupView: null, | |
| artworkInfoFixedView: null, | |
| removeArtworkInfo: function () { | |
| this.artworkInfoPopupView.remove(); | |
| if (this.artworkInfoFixedView != null) { | |
| this.artworkInfoFixedView.remove() | |
| } | |
| }, | |
| setArtworkInfo: function () { | |
| if (ap.aggregation.layout.Global.currentRowView.artworkInfo == "popup") { | |
| this.artworkInfoPopupView.attach() | |
| } else { | |
| if (ap.aggregation.layout.Global.currentRowView.artworkInfo == "fixed") { | |
| if (this.artworkInfoFixedView == null) { | |
| this.artworkInfoFixedView = new ap.aggregation.layout.ArtworkInfoFixedView({ | |
| collection: this.collection | |
| }) | |
| } | |
| this.artworkInfoFixedView.render() | |
| } | |
| } | |
| }, | |
| render: function () { | |
| if (!ap.isMobile) { | |
| this.artworkInfoPopupView = new ap.aggregation.layout.ArtworkInfoPopupView({ | |
| collection: this.collection | |
| }) | |
| } else { | |
| this.artworkInfoPopupView = new ap.mobile.aggregation.ArtworkInfoPopupView({ | |
| collection: this.collection | |
| }) | |
| } | |
| this.artworkInfoPopupView.render() | |
| } | |
| }); | |
| ap.namespace("ap.artwork").OptionsView = Backbone.View.extend({ | |
| el: $("body"), | |
| spinnerTemplate: '<span class="spinner"><span class="icon"></span></span>', | |
| events: { | |
| "mouseenter .main-content .artwork": "showOptions", | |
| "mouseleave .main-content .artwork": "hideOptions" | |
| }, | |
| initialize: function () { | |
| ap.log("ap.artwork.OptionsView.init"); | |
| this.template = _.template($("#artwork-options-template").html(), { | |
| anonymous_user: !ap.userIsAuthenticated | |
| }) | |
| }, | |
| hideOptions: function (b) { | |
| var a = $(b.currentTarget); | |
| a.find(".artwork-options").remove() | |
| }, | |
| showOptions: function (b) { | |
| var a = $(b.currentTarget); | |
| var c = a.find(".artwork-options"); | |
| if (!c.length) { | |
| a.append(this.template) | |
| } | |
| a.find(".start-slideshow").css({ | |
| top: a.data("view").currentHeight - 15, | |
| bottom: "auto" | |
| }) | |
| } | |
| }); | |
| ap.namespace("ap.aggregation.layout").ArtworkView = Backbone.View.extend({ | |
| tagName: "a", | |
| className: "row-item artwork hasMagnifier", | |
| template: '<img style="<%= style %>" src="<%= img_path %>" alt="<%= title %>" width="<%= width %>" />', | |
| spinnerTemplate: '<span class="spinner"><span class="icon"></span></span>', | |
| giga_pixel_template: '<span class="gpxl"></span>', | |
| gpxl: null, | |
| events: { | |
| click: "clickCallback", | |
| recalculateWidth: "recalculateWidth", | |
| "click .add-to-collection": "addToCollection", | |
| "click .start-slideshow": "startSlideshow", | |
| load: "removeSpinner" | |
| }, | |
| options: { | |
| imageSize: 200, | |
| addExtraOptions: false | |
| }, | |
| currentHeight: 0, | |
| currentWidth: 0, | |
| initialize: function () { | |
| _.bindAll(this, "render", "clickCallback", "startSlideshow", "addToCollectionComplete"); | |
| this.parentView = this.options.parentView | |
| }, | |
| removeSpinner: function (a) { | |
| return $(this.el).parent().find(".spinner").remove() | |
| }, | |
| addToCollection: function (a) { | |
| if (ap.userIsAvailable && ap.userIsAuthenticated) { | |
| a.preventDefault() | |
| } | |
| if (!$(a.currentTarget).hasClass("done")) { | |
| var f = $(this.el); | |
| f.append(this.spinnerTemplate); | |
| var c = f.find("span.add-to-collection span:first"); | |
| c.css("display", "none"); | |
| var b = this; | |
| var e = { | |
| artwork: ap.buildApiUrl(["artwork", this.model.attributes.id], false, false, true), | |
| part_x: 0, | |
| part_y: 0, | |
| part_zoom: 1 | |
| }; | |
| var d = new ap.UserBookmark(e); | |
| d.save({}, { | |
| success: function (k, j) { | |
| b.addToCollectionComplete(); | |
| ap.bookmarks.updateUnassignedCount(1) | |
| }, | |
| noGet: true | |
| }) | |
| } | |
| }, | |
| addToCollectionComplete: function () { | |
| var a = this; | |
| ap.trackAddToGallery({ | |
| aw_slug: a.model.get("slug"), | |
| aw_id: a.model.get("id"), | |
| source: "aggregation" | |
| }, a.model.get("collection_analytics_id")); | |
| $el = $(a.el); | |
| $addIcon = $el.find("span.add-to-collection"); | |
| var b = $addIcon.find("span:first"); | |
| b.css("display", "block"); | |
| $el.find(".spinner").addClass("done highlight"); | |
| setTimeout(function () { | |
| $el.find(".spinner").fadeOut(500, | |
| function () { | |
| $(this).remove() | |
| }) | |
| }, 1000) | |
| }, | |
| startSlideshow: function (b) { | |
| b.preventDefault(); | |
| var a = this.bookmarkModel || this.model; | |
| this.parentView.sidebar.remoteStartSlideshow(a) | |
| }, | |
| clickCallback: function (a) { | |
| if (this.options.clickCallback) { | |
| this.options.clickCallback(a, this); | |
| return false | |
| } | |
| }, | |
| resize: function (a, f, d) { | |
| var c = this; | |
| if (d !== false) { | |
| d = true | |
| } | |
| var b = c.model.attributes; | |
| var j = $(c.el).find("img").eq(0); | |
| if (a > 512) { | |
| a = 512 | |
| } | |
| var e = Math.round(a * b.primary_image_aspect_ratio); | |
| if (e > 512) { | |
| e = 512; | |
| a = Math.round(e / b.primary_image_aspect_ratio) | |
| } | |
| c.currentHeight = a; | |
| c.currentWidth = e; | |
| if (d) { | |
| j.animate({ | |
| height: a, | |
| width: e | |
| }, | |
| function () { | |
| $(j).attr("width", e); | |
| c.positionGigapixelIndicator() | |
| }) | |
| } else { | |
| j.css({ | |
| height: a, | |
| width: e | |
| }, | |
| function () { | |
| $(j).attr("width", e) | |
| }); | |
| c.positionGigapixelIndicator() | |
| } | |
| }, | |
| positionGigapixelIndicator: function () { | |
| if (this.gpxl) { | |
| this.gpxl.css({ | |
| top: this.currentHeight - 7, | |
| bottom: "auto" | |
| }) | |
| } | |
| }, | |
| recalculateWidth: function (b) { | |
| var a = $(this.el).find("img").eq(0); | |
| var c = height; | |
| if (this.model.attributes.primary_image_aspect_ratio < 1) { | |
| c = Math.round(height * this.model.attributes.primary_image_aspect_ratio) | |
| } | |
| a.attr("width", c) | |
| }, | |
| render: function (f, e, k) { | |
| var c = this.model.bookmark || this.model, | |
| a = c.artwork || c; | |
| if (f.width && !f.height) { | |
| if (f.width > 512) { | |
| f.width = 512 | |
| } | |
| f.height = Math.round(f.width / a.primary_image_aspect_ratio); | |
| if (f.height > 512) { | |
| f.height = 512; | |
| f.width = Math.round(f.height * a.primary_image_aspect_ratio) | |
| } | |
| } else { | |
| if (!f.width && f.height) { | |
| if (f.height > 512) { | |
| f.height = 512 | |
| } | |
| f.width = Math.round(f.height * a.primary_image_aspect_ratio); | |
| if (f.width > 512) { | |
| f.width = 512; | |
| f.height = Math.round(f.width / a.primary_image_aspect_ratio) | |
| } | |
| } | |
| } | |
| var j = c.calculateImageSizeForAPI(f); | |
| var b = (k) ? "max-height: " + f.maxHeight + " px; max-width: " + f.maxWidth + "px" : "height: " + f.height + "px;"; | |
| var d = { | |
| img_path: c.image(j), | |
| title: a.title, | |
| style: b, | |
| width: f.width | |
| }; | |
| this.currentHeight = f.height; | |
| this.currentWidth = f.width; | |
| if (this.options.zoomState) { | |
| $(this.el).attr("href", ap.getLocaleUrl(c.attributes.detail_url) + "?" + $.param(this.options.zoomState)) | |
| } else { | |
| $(this.el).attr("href", ap.getLocaleUrl(c.attributes.detail_url)) | |
| } | |
| $(this.el).attr("data-cid", c.cid); | |
| $(this.el).attr("data-vieworder", c.viewOrder); | |
| $(this.el).attr("data-imageurl", c.attributes.aggregation_image_url); | |
| $(this.el).attr("data-slug", c.attributes.slug); | |
| $(this.el).attr("data-artwork-id", c.attributes.id); | |
| $(this.el).data("model", c); | |
| $(this.el).data("view", this); | |
| if (this.options.noMagnifier === true) { | |
| $(this.el).removeClass("hasMagnifier") | |
| } | |
| $(this.el).html(_.template(this.template, d)); | |
| if (c.attributes.primary_asset_is_gigapixel) { | |
| $(this.el).append(this.giga_pixel_template); | |
| this.gpxl = $(this.el).find(".gpxl").eq(0) | |
| } | |
| return this | |
| } | |
| }); | |
| ap.namespace("ap.aggregation.layout").ArtworkMagnifierView = Backbone.View.extend({ | |
| el: $(".main-content"), | |
| template: '<span class="artwork-magnifier"></span>', | |
| magnifier: null, | |
| imageZoomRatio: null, | |
| imageTopOffset: null, | |
| imageLeftOffset: null, | |
| verticalBoundry: null, | |
| horizontalBoundry: null, | |
| hasScrolled: false, | |
| imagePreload: null, | |
| events: { | |
| "mousemove a.artwork.hasMagnifier": "moveMagnifier", | |
| "mouseenter a.artwork.hasMagnifier": "showMagnifier", | |
| "mouseleave a.artwork.hasMagnifier": "hideMagnifier", | |
| "jsp-scroll-x .scroll-pane": "scrollPanelXScroll" | |
| }, | |
| initialize: function () { | |
| _.bindAll(this, "render", "preloadHighResolutionImage", "imagePreloaded"); | |
| this.imagePreload = new ap.system.imagePreload("magnifier", { | |
| imageLoaded: this.imagePreloaded | |
| }) | |
| }, | |
| scrollPanelXScroll: function () { | |
| this.hasScrolled = true | |
| }, | |
| showMagnifier: function (a) { | |
| this.render(); | |
| this.updateMagnifierImage(a) | |
| }, | |
| updateMagnifierImage: function (b) { | |
| var a = $(b.currentTarget).find("img"); | |
| this.imagePreload.abort(); | |
| this.imageZoomRatio = a.height() / ap.aggregation.layout.Global.currentRowView.zoom.image.height; | |
| this.setImageOffset(a); | |
| this.setMaginifierContainer(a); | |
| this.setMagnifiedImage(a); | |
| this.preloadHighResolutionImage(a) | |
| }, | |
| setImageOffset: function (b) { | |
| var a = b.outerHeight(true) - b.height(); | |
| this.imageTopOffset = b.offset().top + a / 2 - $(window).scrollTop(); | |
| this.imageLeftOffset = b.offset().left + a / 2 - $(window).scrollLeft() | |
| }, | |
| preloadHighResolutionImage: function (c) { | |
| var a = c.parents("a").data("model"); | |
| var b = this; | |
| this.imagePreload.addToQueue(a.image(a.calculateImageSizeForAPI({ | |
| height: ap.aggregation.layout.Global.currentRowView.zoom.image.height | |
| })), b.magnifier); | |
| this.imagePreload.load() | |
| }, | |
| imagePreloaded: function (a, b) { | |
| b.css("background-image", "url(" + a.src + ")") | |
| }, | |
| setMaginifierContainer: function (b) { | |
| this.magnifier = $(".artwork-magnifier"); | |
| var a = { | |
| "background-image": "url(" + b.attr("src") + ")", | |
| height: b.height() < ap.aggregation.layout.Global.currentRowView.zoom.size ? b.height() : ap.aggregation.layout.Global.currentRowView.zoom.size + "px", | |
| left: b.position().left + b.outerWidth() - parseInt(b.css("padding-right")) - this.magnifier.outerWidth(true), | |
| top: b.position().top + b.outerHeight() - parseInt(b.css("padding-bottom")) - this.magnifier.outerHeight(true), | |
| width: b.width() < ap.aggregation.layout.Global.currentRowView.zoom.size ? b.width() : ap.aggregation.layout.Global.currentRowView.zoom.size + "px" | |
| }; | |
| this.magnifier.css(a); | |
| b.parent().append(this.magnifier); | |
| this.magnifier.show() | |
| }, | |
| setMagnifiedImage: function (c) { | |
| var a = (1 + this.imageZoomRatio) * c.height(); | |
| var b = (1 + this.imageZoomRatio) * c.width(); | |
| this.verticalBoundry = a - this.magnifier.outerHeight(true); | |
| this.horizontalBoundry = b - this.magnifier.outerWidth(true); | |
| this.magnifier.css("background-size", b + "px " + a + "px ") | |
| }, | |
| moveMagnifier: function (j) { | |
| if (this.magnifier) { | |
| var f = $(j.currentTarget).find("img"); | |
| var d = f.attr("src"); | |
| d = d.slice(0, d.lastIndexOf("=s")); | |
| var b = this.magnifier.css("background-image"); | |
| b = b.slice(5, b.lastIndexOf("=s")); | |
| if (b !== d) { | |
| this.updateMagnifierImage(j) | |
| } | |
| if (this.hasScrolled) { | |
| this.setImageOffset(f); | |
| this.hasScrolled = false | |
| } | |
| var a = this.zoomPosition(j.clientY, this.imageTopOffset); | |
| var c = this.zoomPosition(j.clientX, this.imageLeftOffset); | |
| c = c >= this.horizontalBoundry ? this.horizontalBoundry : c; | |
| a = a >= this.verticalBoundry ? this.verticalBoundry : a; | |
| this.magnifier.css("background-position", "-" + c + "px -" + a + "px") | |
| } | |
| }, | |
| zoomPosition: function (d, c) { | |
| var b = 0; | |
| var a = (d - c - b) * (1 + this.imageZoomRatio) - ap.aggregation.layout.Global.currentRowView.zoom.size / 2; | |
| a = a < 0 ? 0 : a; | |
| return a | |
| }, | |
| hideMagnifier: function (a) { | |
| $(".artwork-magnifier").hide() | |
| }, | |
| remove: function (a) { | |
| $(".artwork-magnifier").remove() | |
| }, | |
| render: function () { | |
| if ($(".artwork-magnifier").length == 0) { | |
| this.el.append(this.template) | |
| } | |
| } | |
| }); | |
| ap.namespace("ap.aggregation.layout").BookmarkGroupView = Backbone.View.extend({ | |
| tagName: "div", | |
| className: "gallery row-item", | |
| template: $("#aggregation-gallery-view-template").html(), | |
| events: {}, | |
| initialize: function () { | |
| _.bindAll(this, "render") | |
| }, | |
| render: function () { | |
| var a = this.model.attributes; | |
| if (a.name.match(/^[ \t\r\n]*$/)) { | |
| a.isUntitled = true | |
| } | |
| if (a.absolute_url) { | |
| a.absolute_url = ap.getLocaleUrl(a.absolute_url) | |
| } | |
| $(this.el).data("model", this.model); | |
| var c = _.template(this.template, a); | |
| var b = $(c); | |
| $(this.el).html(b); | |
| return this | |
| } | |
| }); | |
| ap.namespace("ap.aggregation.layout").BookmarkArtworkView = ap.aggregation.layout.ArtworkView.extend({ | |
| tagName: "a", | |
| className: "row-item artwork hasMagnifier", | |
| template: '<div class="artwork-wrapper"><img style="<%= style %>" class="bookmark-preview" src="<%= img_path %>" alt="<%= title %>" width="<%= width %>" /><span class="crop-wrapper"></span></div>', | |
| artworkModel: null, | |
| bookmarkModel: null, | |
| initialize: function () { | |
| this.bookmarkModel = this.model; | |
| this.model = new ap.Artwork(this.model.get("is_public") ? this.model.get("artwork") : this.model); | |
| this.model.attributes.detail_url = this.bookmarkModel.attributes.absolute_url; | |
| ap.aggregation.layout.ArtworkView.prototype.initialize.apply(this, [this.options]) | |
| }, | |
| render: function (d, c, e) { | |
| ap.aggregation.layout.ArtworkView.prototype.render.apply(this, [d, c, e]); | |
| ap.log("Drawing box", "info"); | |
| var a = $(this.el).find(".bookmark-preview"); | |
| var b = this.bookmarkModel; | |
| ap.drawCrop(a, $(this.el).find(".crop-wrapper"), b.get("part_x"), b.get("part_y"), b.get("part_zoom")) | |
| }, | |
| }); | |
| ap.namespace("ap.aggregation.layout").PreloaderView = Backbone.View.extend({ | |
| el: $(".main-content.scroll-pane"), | |
| processManager: null, | |
| preLoaderTemplate: '<div style="display: none" class="preloader">' + TRANSLATIONS.loading + "</div>", | |
| preloader: null, | |
| currentCSS: {}, | |
| options: { | |
| useDefaultPreloader: true, | |
| }, | |
| initialize: function () { | |
| var a = this; | |
| _.bindAll(this, "render", "displayPreloader", "hidePreloader"); | |
| if (this.options.useDefaultPreloader) { | |
| this.preloader = $(this.preLoaderTemplate) | |
| } | |
| this.processManager = new ap.system.ProcessManager("paging"); | |
| $(this.processManager).bind("processStarted_paging", | |
| function () { | |
| a.displayPreloader() | |
| }); | |
| $(a.processManager).bind("processReset_paging", | |
| function () { | |
| a.showOnLeft = true | |
| }); | |
| $(a.processManager).bind("processEnded_paging", | |
| function () { | |
| a.hidePreloader(); | |
| a.showOnLeft = false | |
| }); | |
| $(this.processManager).bind("processTerminated_paging", | |
| function () { | |
| a.hidePreloader() | |
| }) | |
| }, | |
| displayPreloader: function (a) { | |
| if (this.options.useDefaultPreloader) { | |
| if (a !== undefined && a === true || this.showOnLeft === true) { | |
| this.preloader.addClass("left"); | |
| this.positionPreloader(this.currentCSS, true) | |
| } | |
| this.preloader.show() | |
| } | |
| }, | |
| hidePreloader: function () { | |
| if (this.options.useDefaultPreloader) { | |
| this.preloader.removeClass("left"); | |
| this.preloader.hide() | |
| } | |
| }, | |
| positionPreloader: function (a, b) { | |
| this.currentCSS = $.extend({}, a); | |
| if (this.preloader.hasClass("left")) { | |
| if (a.right != undefined) { | |
| delete a.right | |
| } | |
| if (a["margin-right"] != undefined) { | |
| delete a["margin-right"] | |
| } | |
| } else { | |
| if (a.left != undefined) { | |
| delete a.left | |
| } | |
| if (a["margin-left"] != undefined) { | |
| delete a["margin-left"] | |
| } | |
| } | |
| if (!b && this.preloader.is(":visible")) { | |
| this.preloader.animate(a, { | |
| queue: false | |
| }) | |
| } else { | |
| this.preloader.css(a) | |
| } | |
| }, | |
| render: function () { | |
| if (this.options.useDefaultPreloader) { | |
| this.el.append(this.preloader) | |
| } | |
| } | |
| }); | |
| ap.namespace("ap.aggregation.layout").SetupRow = function () { | |
| var b = ap.aggregation.layout.Global.currentRowView; | |
| var a = 75; | |
| this.setRowconfig = function () { | |
| if (ap.aggregation.layout.Global.currentRowView.hasVariableNumberOfRows) { | |
| var j = c(); | |
| var k = e(j); | |
| var f = k - (b.image.padding * 2); | |
| if (f < b.minHeight) { | |
| f = b.minHeight; | |
| j = c(f); | |
| k = f + (b.image.padding * 2) | |
| } else { | |
| if (f > b.maxHeight) { | |
| f = b.maxHeight; | |
| j = c(f); | |
| k = f + (b.image.padding * 2) | |
| } | |
| } | |
| b.image.height = f; | |
| b.numberOfRows = j; | |
| d(j, f) | |
| } else { | |
| d() | |
| } | |
| }; | |
| function d(j, f) { | |
| if (_.isUndefined(j)) { | |
| j = b.numberOfRows | |
| } | |
| if (_.isUndefined(f)) { | |
| f = e() - (b.image.padding * 2); | |
| b.image.height = f | |
| } | |
| var k = b.zoom.image.height / b.image.height; | |
| b.zoom.image.height = Math.ceil(f * k) | |
| } | |
| function c(f) { | |
| if (_.isUndefined(f)) { | |
| f = b.image.height | |
| } | |
| var l = $(".main-content").height() - a; | |
| var k = f + (b.image.padding * 2); | |
| var j = Math.floor(l / k); | |
| if (j == 0) { | |
| j = 1 | |
| } | |
| return j | |
| } | |
| function e(f) { | |
| var k = a; | |
| if (_.isUndefined(f)) { | |
| f = b.numberOfRows; | |
| if (f == 1) { | |
| k = 170 | |
| } | |
| } | |
| var j = $(".main-content").height() - (k); | |
| if (f) { | |
| rowHeight = parseInt(j / f) | |
| } else { | |
| if (rowHeight > b.maxHeight) { | |
| rowHeight = b.maxHeight | |
| } | |
| } | |
| return rowHeight | |
| } | |
| }; | |
| ap.namespace("ap.aggregation.layout").InfiniteScrollingView = Backbone.View.extend({ | |
| processManagerPaging: null, | |
| processManagerAggregationZoom: null, | |
| lastXPosition: 0, | |
| jScrollPaneApi: null, | |
| artworkInfo: null, | |
| scrollTriggerOffset: 150, | |
| xScrollTriggers: { | |
| load: 0, | |
| triggerArtwork: null | |
| }, | |
| events: {}, | |
| selector: ".row .row-item:last-child", | |
| initialize: function () { | |
| var a = this; | |
| _.bindAll(a, "render", "setArtworkScrollTrigger", "scrollPanelXScroll", "reinitialise", "logEnded", "logStarted", "logTerminated"); | |
| if (a.options.selector) { | |
| a.selector = a.options.selector | |
| } | |
| if (a.options.scrollTriggerOffset) { | |
| a.scrollTriggerOffset = a.options.scrollTriggerOffset | |
| } | |
| a.jScrollPaneApi = a.options.jScrollPaneApi; | |
| a.artworkInfo = a.options.artworkInfo; | |
| a.processManagerPaging = new ap.system.ProcessManager("paging"); | |
| a.processManagerAggregationZoom = new ap.system.ProcessManager("aggregationZoom"); | |
| $(a.processManagerPaging).bind("processEnded_paging", a.reinitialise); | |
| $(a.processManagerPaging).bind("processTerminated_paging", a.reinitialise); | |
| $(a.processManagerAggregationZoom).bind("processEnded_aggregationZoom", a.reinitialise); | |
| $(a.processManagerPaging).bind("processStarted_paging", a.logStarted); | |
| $(a.processManagerPaging).bind("processEnded_paging", a.logEnded); | |
| $(a.processManagerPaging).bind("processTerminated_paging", a.logTerminated); | |
| a.xScrollTriggers.load = $(document).width() + 400; | |
| a.setArtworkScrollTrigger() | |
| }, | |
| logStarted: function () { | |
| ap.log("I started my job", "info") | |
| }, | |
| logEnded: function () { | |
| ap.log("I finished my job", "info") | |
| }, | |
| logTerminated: function () { | |
| ap.log("Someone finished my job", "warn") | |
| }, | |
| isMovingRight: function (a) { | |
| return a > this.lastXPosition | |
| }, | |
| scrollPanelXScroll: function (b, e, j, f) { | |
| var a = this; | |
| if (!a.processManagerPaging.isBusy && !a.processManagerPaging.isTerminated) { | |
| var d = a.options.jScrollPaneApi.getContentPositionX(); | |
| if (a.isMovingRight(d) && d > a.lastXPosition + a.scrollTriggerOffset) { | |
| var c = a.xScrollTriggers.triggerArtwork.offset().left; | |
| if (c <= a.xScrollTriggers.load) { | |
| a.collection.nextPage() | |
| } | |
| a.lastXPosition = d | |
| } | |
| } | |
| }, | |
| reinitialise: function () { | |
| var a = this; | |
| if (a.artworkInfo) { | |
| a.artworkInfo.setArtworkInfo() | |
| } | |
| a.setArtworkScrollTrigger(); | |
| a.lastXPosition = 0 | |
| }, | |
| setArtworkScrollTrigger: function () { | |
| var a = this; | |
| a.xScrollTriggers.triggerArtwork = null; | |
| $(a.selector).each(function () { | |
| a.xScrollTriggers.triggerArtwork = a.xScrollTriggers.triggerArtwork || $(this); | |
| a.xScrollTriggers.triggerArtwork = $(this).position().left < a.xScrollTriggers.triggerArtwork.position().left ? $(this) : a.xScrollTriggers.triggerArtwork | |
| }) | |
| }, | |
| render: function () { | |
| var a = this; | |
| if (ap.isMobile) { | |
| $(".scroll-pane").on("scroll", a.scrollPanelXScroll) | |
| } else { | |
| $(".scroll-pane").on("jsp-scroll-x", a.scrollPanelXScroll) | |
| } | |
| } | |
| }); | |
| ap.namespace("ap.aggregation.layout").RowRender = function (b) { | |
| var c = { | |
| isPrepend: false | |
| }; | |
| $.extend(c, b); | |
| var e = {}; | |
| a(); | |
| function a() { | |
| for (var j = 1; j <= 10; j++) { | |
| var f = $("<div></div>"); | |
| f.ownerDocument = document; | |
| e[j] = f | |
| } | |
| } | |
| var d = ap.aggregation.layout.Global.lastRow; | |
| this.addToNextRow = function (k, l, m) { | |
| var f = m || (d >= ap.aggregation.layout.Global.currentRowView.numberOfRows ? 1 : d + 1); | |
| var j = e[f]; | |
| if (c.isPrepend) { | |
| $(j).prepend(k) | |
| } else { | |
| $(j).append(k) | |
| } | |
| e[f] = $(j); | |
| d = f | |
| }; | |
| this.RenderRows = function (f) { | |
| var k = e.length; | |
| for (var l = 1; l <= ap.aggregation.layout.Global.currentRowView.numberOfRows; l++) { | |
| var j = $(".row-" + l); | |
| if (f) { | |
| j.empty() | |
| } | |
| if (c.isPrepend) { | |
| j.prepend($(e[l]).html()) | |
| } else { | |
| j.append($(e[l]).html()) | |
| } | |
| } | |
| ap.aggregation.layout.Global.lastRow = d | |
| } | |
| }; | |
| ap.namespace("ap.aggregation.layout").PageLoading = { | |
| needToLoadMore: function () { | |
| var b = $(".content-with-sidebar").width(); | |
| var a = ap.aggregation.layout.RowFormat.rowWidths.minWidth; | |
| if (a - 200 < b) { | |
| var c = Math.round(b / a); | |
| if (c > 0) { | |
| return true | |
| } | |
| return false | |
| } | |
| return false | |
| } | |
| }; | |
| ap.namespace("ap.aggregation.layout").RowFormat = { | |
| rowWidths: { | |
| minWidth: 320000, | |
| maxWidth: 0 | |
| }, | |
| setRowWidth: function (c) { | |
| var b = ap.aggregation.layout.RowFormat.rowWidths; | |
| b.minWidth = 320000; | |
| b.maxWidth = 0; | |
| if (c) { | |
| var a = 200; | |
| $("div.row:visible").each(function (o) { | |
| var q = $(this); | |
| var p = q.children(".row-item"); | |
| var m = p.eq(0); | |
| var k = 0; | |
| var r = p.size(); | |
| var l = 0 + parseInt(m.css("padding-left"), 10) + parseInt(m.css("padding-right"), 10); | |
| var e = 0 + parseInt(m.css("border-left-width"), 10) + parseInt(m.css("border-right-width"), 10); | |
| var s = 0; | |
| var f = parseInt(m.css("marginLeft"), 10); | |
| var n = parseInt(m.css("marginRight"), 10); | |
| var j; | |
| if (f) { | |
| s += f | |
| } | |
| if (n) { | |
| s += n | |
| } | |
| j = l + s + e; | |
| for (var d = 0; d < r; d++) { | |
| k += p.eq(d).width() + j | |
| } | |
| if (k > 0) { | |
| k += a; | |
| if (k < b.minWidth) { | |
| b.minWidth = k | |
| } | |
| if (k > b.maxWidth) { | |
| b.maxWidth = k | |
| } | |
| q.width(k) | |
| } else { | |
| if (k === 0) { | |
| q.width(k) | |
| } | |
| } | |
| }); | |
| return b | |
| } else { | |
| $("div.row").width(320000); | |
| return b | |
| } | |
| }, | |
| resetRowWidth: function () { | |
| $("div.row:visible").width(0) | |
| }, | |
| renderToNextRow: function (b, d, e) { | |
| var a = e || (ap.aggregation.layout.Global.lastRow >= ap.aggregation.layout.Global.currentRowView.numberOfRows ? 1 : ap.aggregation.layout.Global.lastRow + 1); | |
| var c = $(".row-" + a); | |
| if (d) { | |
| c.prepend(b) | |
| } else { | |
| c.append(b) | |
| } | |
| ap.aggregation.layout.Global.lastRow = a | |
| } | |
| }; | |
| ap.namespace("ap.aggregation.layout").RowsView = Backbone.View.extend({ | |
| artworkInfoPopupView: null, | |
| artworkInfoFixedView: null, | |
| artworkInfoView: null, | |
| infiniteScrollingView: null, | |
| jScrollPaneApi: null, | |
| magnifierView: null, | |
| processManagerAggregationZoom: null, | |
| firstTimeLoad: true, | |
| currentAnchorImage: null, | |
| parentView: null, | |
| useRowAnimations: false, | |
| events: { | |
| "click .view-options a": "viewXRows" | |
| }, | |
| initialize: function () { | |
| _.bindAll(this, "render", "zoomChangeImageReorder", "progressiveImageShow", "formatRows", "animateRow", "viewXRows", "imageReOrderCompleted"); | |
| var a = this; | |
| a.jScrollPaneApi = a.options.jScrollPaneApi; | |
| a.parentView = a.options.parentView; | |
| a.processManagerAggregationZoom = new ap.system.ProcessManager("aggregationZoom") | |
| }, | |
| viewXRows: function (f) { | |
| var b = this; | |
| var d = $(f.target).data("row-id"); | |
| var k = $(".row-1"); | |
| var j = k.parent().position().left; | |
| var a = $("#sidebar").outerWidth() + $("#sidebar").position().left; | |
| var c = $(".row-1 a.artwork"); | |
| $.each(c, | |
| function (l, e) { | |
| var m = $(e).offset().left - a; | |
| if (m >= 0) { | |
| b.currentAnchorImage = $(e); | |
| return false | |
| } | |
| }); | |
| this.rowView(d) | |
| }, | |
| rowView: function (c) { | |
| var b = c.toLowerCase(); | |
| var a = "view-" + b + "-rows"; | |
| $(".view-options a.current").removeClass("current"); | |
| $(".view-options .view-option-" + b).addClass("current"); | |
| if (!$("body").hasClass(a)) { | |
| _.each($(".view-options a"), | |
| function (d) { | |
| $("body").removeClass("view-" + $(d).data("row-id").toLowerCase() + "-rows") | |
| }); | |
| $("body").addClass("view-" + b + "-rows"); | |
| if (this.options.aggregationConfig.dynamicRows) { | |
| this.aggregationZoomChange(c) | |
| } | |
| } else { | |
| if (this.artworkInfo) { | |
| this.artworkInfo.removeArtworkInfo(); | |
| this.artworkInfo.setArtworkInfo() | |
| } | |
| } | |
| }, | |
| aggregationZoomChange: function (j, f) { | |
| var c = this; | |
| if (_.isUndefined(f)) { | |
| f = false | |
| } | |
| c.processManagerAggregationZoom.start(); | |
| c.artworkInfoView.removeArtworkInfo(); | |
| var a = ap.aggregation.layout.Global.currentRowView; | |
| var e = ap.aggregation.layout.Global.currentRowView = ap.aggregation.layout.Config["rowView" + j]; | |
| var b = a.image.height < e.image.height; | |
| var d = new ap.aggregation.layout.SetupRow(); | |
| d.setRowconfig(); | |
| ap.aggregation.layout.Global.lastRow = 0; | |
| ap.aggregation.layout.RowFormat.setRowWidth(true); | |
| if (f) { | |
| c.animationCompleted() | |
| } else { | |
| c.animateRow(e, b) | |
| } | |
| }, | |
| animationCompleted: function () { | |
| var a = this; | |
| a.formatRows(); | |
| a.zoomChangeImageReorder(); | |
| a.firstTimeLoad = false | |
| }, | |
| imageReOrderCompleted: function () { | |
| var a = this; | |
| a.artworkInfoView.setArtworkInfo(); | |
| if (!a.firstTimeLoad) { | |
| a.setImageResolutionForZoom() | |
| } | |
| ap.aggregation.layout.RowFormat.setRowWidth(true); | |
| a.jScrollPaneApi.reinitialise(); | |
| if (!a.jScrollPaneApi.getIsScrollableH()) { | |
| a.jScrollPaneApi.getContentPane().animate({ | |
| left: 0 | |
| }) | |
| } else { | |
| if (a.currentAnchorImage) { | |
| a.jScrollPaneApi.scrollToElement(a.currentAnchorImage, true) | |
| } | |
| } | |
| a.processManagerAggregationZoom.end(); | |
| if (ap.aggregation.layout.PageLoading.needToLoadMore()) { | |
| a.collection.nextPage() | |
| } | |
| }, | |
| setImageResolutionForZoom: function () { | |
| var a = this; | |
| var b = new ap.system.imagePreload("imageZoomResolution", { | |
| imageLoaded: function (d, e) { | |
| var c = $(e).find("img").attr("src", d.src) | |
| }, | |
| batchLoaded: function () { | |
| a.artworkInfoView.setArtworkInfo() | |
| } | |
| }); | |
| $(".rows a").each(function () { | |
| var f = this; | |
| var e = $(f); | |
| var c = e.data("model"); | |
| if (c) { | |
| var d = c.calculateImageSizeForAPI({ | |
| height: ap.aggregation.layout.Global.currentRowView.image.height | |
| }); | |
| b.addToQueue(c.image(d), f) | |
| } | |
| }); | |
| b.load() | |
| }, | |
| formatRows: function () { | |
| for (var a = 1; a <= $("div.row").length; a++) { | |
| if (a <= ap.aggregation.layout.Global.currentRowView.numberOfRows) { | |
| $(".row-" + a).show() | |
| } else { | |
| $(".row-" + a).hide() | |
| } | |
| } | |
| }, | |
| animateRow: function (c, f) { | |
| var e = this; | |
| var b = _.groupBy($("div.main-content .artworks img"), this.isElementInView); | |
| var j = b[true]; | |
| var d = b[false]; | |
| if (_.isUndefined(j) || _.isNull(j)) { | |
| return | |
| } | |
| if (!e.firstTimeLoad) { | |
| $(j).attr("width", ""); | |
| $(d).attr("width", "") | |
| } | |
| if (!e.firstTimeLoad && !f) { | |
| e.imagesSizeChangeNoAnimate(c, d) | |
| } | |
| var a = null; | |
| $.each(j, | |
| function (k, l) { | |
| heightToUse = c.image.height; | |
| a = $(l).parents("a").data("view"); | |
| if (a) { | |
| a.resize(c.image.height, c.maxHeight, e.useRowAnimations) | |
| } | |
| }); | |
| if (e.useRowAnimations) { | |
| setTimeout(function () { | |
| if (f) { | |
| e.imagesSizeChangeNoAnimate(c, d) | |
| } | |
| e.animationCompleted() | |
| }, 500) | |
| } else { | |
| if (f) { | |
| e.imagesSizeChangeNoAnimate(c, d) | |
| } | |
| e.animationCompleted() | |
| } | |
| e.firstTimeLoad = false | |
| }, | |
| imagesSizeChangeNoAnimate: function (a, b) { | |
| if (b) { | |
| $.each(b, | |
| function (c, d) { | |
| view = $(d).parents("a").data("view"); | |
| if (view) { | |
| view.resize(a.image.height, a.maxHeight, false) | |
| } | |
| }) | |
| } | |
| }, | |
| isElementInView: function (c) { | |
| var e = $(window).scrollLeft(); | |
| var d = e + $(window).width(); | |
| var b = $(c).offset().left; | |
| var a = b + $(c).width(); | |
| return ((a >= e) && (b <= d)) | |
| }, | |
| zoomChangeImageReorder: function () { | |
| var a = null; | |
| for (var b = 1; b <= ap.aggregation.layout.Global.numberOfImages; b++) { | |
| a = this.parentView.fullViewArray[b - 1]; | |
| if (a) { | |
| ap.aggregation.layout.RowFormat.renderToNextRow(a.el) | |
| } | |
| } | |
| setTimeout(this.imageReOrderCompleted, 200) | |
| }, | |
| progressiveImageShow: function (f) { | |
| var c = 0; | |
| var e = _.sortBy($("div.main-content .artworks img"), | |
| function (k) { | |
| return $(k).parent().data("vieworder") | |
| }); | |
| var b = _.groupBy($(e), this.isElementInView); | |
| var j = b[true]; | |
| var d = b[false]; | |
| if (j) { | |
| var a = j.length; | |
| if (f != null) { | |
| f() | |
| } | |
| } | |
| }, | |
| render: function (c) { | |
| var b = this; | |
| var a = $("div.main-content .artworks img"); | |
| this.artworkInfoView = new ap.aggregation.layout.ArtworkInfo(); | |
| this.artworkInfoView.render(); | |
| if (!b.options.aggregationConfig.isSearch) { | |
| if (ap.userIsAvailable) { | |
| ap.log("userDataLoaded in rowsview.render"); | |
| if (!ap.isMobile) { | |
| this.artworkOptionsView = new ap.artwork.OptionsView() | |
| } else { | |
| this.artworkOptionsView = new ap.mobile.artwork.OptionsView() | |
| } | |
| this.artworkOptionsView.render() | |
| } else { | |
| b.parentView.bind("userDataLoaded", | |
| function () { | |
| ap.log("userDataLoaded in rowsview.render"); | |
| if (!ap.isMobile) { | |
| this.artworkOptionsView = new ap.artwork.OptionsView() | |
| } else { | |
| this.artworkOptionsView = new ap.mobile.artwork.OptionsView() | |
| } | |
| this.artworkOptionsView.render() | |
| }) | |
| } | |
| } | |
| this.infiniteScrollingView = new ap.aggregation.layout.InfiniteScrollingView({ | |
| el: b.el, | |
| jScrollPaneApi: this.jScrollPaneApi, | |
| rowFormat: ap.aggregation.layout.RowFormat, | |
| collection: this.collection, | |
| artworkInfo: this.artworkInfoView | |
| }); | |
| this.infiniteScrollingView.render(); | |
| if (!ap.isMobile) { | |
| this.artworkMagnifierView = new ap.aggregation.layout.ArtworkMagnifierView({ | |
| rowView: ap.aggregation.layout.Global.currentRowView | |
| }); | |
| this.artworkMagnifierView.render() | |
| } | |
| this.rowView(c) | |
| } | |
| }); | |
| ap.namespace("ap.aggregation.layout").WheelScrollingView = Backbone.View.extend({ | |
| events: { | |
| "mousewheel .scroll-pane": "scrollPanelWheel" | |
| }, | |
| jScrollPaneApi: null, | |
| initialize: function () { | |
| _.bindAll(this, "render"); | |
| this.jScrollPaneApi = this.options.jScrollPaneApi | |
| }, | |
| scrollPanelWheel: function (c, d, b, a) { | |
| this.jScrollPaneApi.scrollByX(d * -150); | |
| return false | |
| }, | |
| remove: function () { | |
| var a = $(".scroll-pane"); | |
| a.unbind("mousewheel") | |
| }, | |
| render: function () { | |
| var a = $(".scroll-pane"); | |
| a.bind("mousewheel") | |
| } | |
| }); | |
| ap.namespace("ap.aggregation.layout").FloatingArrowScrollingView = Backbone.View.extend({ | |
| jScrollPaneApi: null, | |
| floatingArrowLeft: null, | |
| floatingArrowRight: null, | |
| isHoverOverArrow: false, | |
| _isAtLeft: true, | |
| _isAtRight: false, | |
| contentPane: null, | |
| mainPane: null, | |
| options: { | |
| scrollBy: 600, | |
| hideAfter: 1000, | |
| arrowPosition: "far" | |
| }, | |
| template: '<a class="floating-arrow-left" href="#"><span class="arrow"></span></a><a class="floating-arrow-right" href="#"><span class="arrow"></span></a>', | |
| events: { | |
| "click .floating-arrow-left": "floatingArrowLeft_Click", | |
| "click .floating-arrow-right": "floatingArrowRight_Click", | |
| "mouseover .floating-arrow-left": "floatingArrowLeft_Mouseover", | |
| "mouseout .floating-arrow-left": "floatingArrowLeft_Mouseout", | |
| "mouseover .floating-arrow-right": "floatingArrowRight_Mouseover", | |
| "mouseout .floating-arrow-right": "floatingArrowRight_Mouseout", | |
| }, | |
| initialize: function () { | |
| _.bindAll(this, "render", "followMouseY", "scroll", "atLeftRight"); | |
| this.jScrollPaneApi = this.options.jScrollPaneApi; | |
| this.contentPane = this.jScrollPaneApi.getContentPane(); | |
| this.mainPane = this.jScrollPaneApi.getContentPane().parent().parent() | |
| }, | |
| floatingArrowLeft_Click: function (a) { | |
| this.options.scrollLeftHandler(a); | |
| return false | |
| }, | |
| floatingArrowRight_Click: function (a) { | |
| this.options.scrollRightHandler(a); | |
| return false | |
| }, | |
| floatingArrowLeft_Mouseover: function (a) { | |
| this.isHoverOverArrow = true | |
| }, | |
| floatingArrowLeft_Mouseout: function (a) { | |
| this.isHoverOverArrow = false | |
| }, | |
| floatingArrowRight_Mouseover: function (a) { | |
| this.isHoverOverArrow = true | |
| }, | |
| floatingArrowRight_Mouseout: function (a) { | |
| this.isHoverOverArrow = false | |
| }, | |
| atLeftRight: function (a, b, d, c) { | |
| this._isAtLeft = d; | |
| this._isAtRight = c; | |
| if (d) { | |
| this.floatingArrowLeft.hide() | |
| } else { | |
| this.floatingArrowLeft.show() | |
| } | |
| if (c) { | |
| this.floatingArrowRight.hide() | |
| } else { | |
| this.floatingArrowRight.show() | |
| } | |
| }, | |
| followMouseY: function (f) { | |
| var b = this; | |
| var a = 24; | |
| var j = b.floatingArrowRight.height() / 2; | |
| window.clearTimeout("floatingpagearrows"); | |
| if (!b._isAtLeft) { | |
| b.floatingArrowLeft.not(":visible").fadeIn("slow") | |
| } | |
| if (!b._isAtRight) { | |
| b.floatingArrowRight.not(":visible").fadeIn("slow") | |
| } | |
| if (c(f) || d(f)) { | |
| if (b.options.hideAfter) { | |
| b.leaveMouseFollowArea("fast") | |
| } | |
| } else { | |
| b.floatingArrowRight.css("top", f.clientY); | |
| b.floatingArrowLeft.css("top", f.clientY); | |
| if (b.options.hideAfter) { | |
| $.doTimeout("floatingpagearrows", b.options.hideAfter, | |
| function () { | |
| if (!b.isHoverOverArrow) { | |
| b.leaveMouseFollowArea("slow"); | |
| return false | |
| } | |
| return true | |
| }) | |
| } | |
| } | |
| function c(k) { | |
| return k.clientY + j > b.contentPane.offset().top + b.contentPane.outerHeight(true) | |
| } | |
| function d(k) { | |
| return k.clientY - j < b.contentPane.offset().top | |
| } | |
| }, | |
| leaveMouseFollowArea: function (a) { | |
| this.floatingArrowLeft.fadeOut(a); | |
| this.floatingArrowRight.fadeOut(a) | |
| }, | |
| centerYArrows: function () { | |
| var a = "45%"; | |
| this.floatingArrowLeft.css("top", a); | |
| this.floatingArrowRight.css("top", a); | |
| if (this.options.hideAfter) { | |
| this.floatingArrowRight.hide() | |
| } | |
| this.floatingArrowLeft.hide() | |
| }, | |
| setArrowPosition: function () { | |
| var a = 0; | |
| var b = this.mainPane.parent().outerWidth() - this.floatingArrowLeft.width(); | |
| this.floatingArrowLeft.css({ | |
| left: a, | |
| position: "absolute" | |
| }); | |
| this.floatingArrowRight.css({ | |
| left: b, | |
| position: "absolute" | |
| }) | |
| }, | |
| scroll: function (a) { | |
| this.jScrollPaneApi.scrollByX(a * this.options.scrollBy) | |
| }, | |
| remove: function () {}, | |
| render: function () { | |
| this.el = $(this.el); | |
| if (this.options.arrowPosition == "far") { | |
| $(".content-with-sidebar").append(this.template) | |
| } else { | |
| this.el.append(this.template) | |
| } | |
| this.floatingArrowLeft = this.el.find(".floating-arrow-left").eq(0); | |
| this.floatingArrowRight = this.el.find(".floating-arrow-right").eq(0); | |
| this.el.bind("jsp-scroll-x", this.atLeftRight); | |
| if (this.options.arrowPosition == "close") { | |
| this.setArrowPosition() | |
| } | |
| this.leaveMouseFollowArea(0) | |
| } | |
| }); | |
| ap.namespace("ap.aggregation.layout").DragScrollingView = Backbone.View.extend({ | |
| el: $("body"), | |
| jScrollPaneApi: null, | |
| dragData: {}, | |
| events: { | |
| "mousedown .main-content": "startScroll", | |
| "mousemove .main-content": "scroll", | |
| "mouseup .main-content": "stopScroll" | |
| }, | |
| initialize: function () { | |
| _.bindAll(this, "render"); | |
| this.jScrollPaneApi = this.options.jScrollPaneApi; | |
| $(".main-content").bind("mousedown"); | |
| $(".main-content").bind("mouseup"); | |
| $(".main-content").bind("mousemove") | |
| }, | |
| startScroll: function (a) { | |
| this.dragData.down = true; | |
| this.dragData.x = a.clientX; | |
| this.dragData.scrollLeft = $(".jspPane").scrollLeft(); | |
| $("body").addClass("mouse-grabbing"); | |
| return false | |
| }, | |
| scroll: function (a) { | |
| if (this.dragData.down) { | |
| this.jScrollPaneApi.scrollByX(this.dragData.scrollLeft + this.dragData.x - a.clientX) | |
| } | |
| }, | |
| stopScroll: function (a) { | |
| this.dragData.down = false; | |
| $("body").removeClass("mouse-grabbing") | |
| }, | |
| remove: function () { | |
| $(".main-content").unbind("mousedown").unbind("mouseup").unbind("mousemove") | |
| }, | |
| render: function () {} | |
| }); | |
| ap.namespace("ap.aggregation.layout").KeyboardScrollingView = Backbone.View.extend({ | |
| el: $("document"), | |
| jScrollPaneApi: null, | |
| events: {}, | |
| options: { | |
| scrollBy: 600 | |
| }, | |
| initialize: function () { | |
| _.bindAll(this, "render", "keyScroll"); | |
| $(document).keydown(this.keyScroll) | |
| }, | |
| keyScroll: function (b) { | |
| var d = 37; | |
| var a = 39; | |
| var c = $("input:focus").size() + $("textarea:focus").size(); | |
| if (c < 1) { | |
| if (b.keyCode == a) { | |
| this.options.scrollRightHandler(b); | |
| return false | |
| } else { | |
| if (b.keyCode == d) { | |
| this.options.scrollLeftHandler(b); | |
| return false | |
| } | |
| } | |
| } | |
| }, | |
| remove: function () { | |
| $("document").unbind("keypress") | |
| }, | |
| render: function () {} | |
| }); | |
| ap.namespace("ap.aggregation.layout").MainScrollingView = Backbone.View.extend({ | |
| events: {}, | |
| options: { | |
| element: $(".main-content.scroll-pane"), | |
| useFloatingArrows: true, | |
| useDragScrolling: false, | |
| useKeyboardScrolling: true, | |
| useWheelScrolling: true, | |
| scrollBy: 600, | |
| defaults: {}, | |
| jScrollPaneSettings: {} | |
| }, | |
| floatingArrowScrollingView: null, | |
| dragScrollingView: null, | |
| keyboardScrollingView: null, | |
| wheelScrollingView: null, | |
| jScrollPaneApi: null, | |
| initialize: function () { | |
| _.bindAll(this, "render", "setupDefaults", "scrollLeftHandler", "scrollRightHandler", "doScroll"); | |
| var b = this; | |
| b.setupDefaults(); | |
| var c = { | |
| showArrows: false, | |
| verticalGutter: 10, | |
| animateScroll: true, | |
| mouseWheelSpeed: 30, | |
| horizontalDragMinWidth: 40, | |
| hijackInternalLinks: true, | |
| horizontalGutter: 60, | |
| enableKeyboardNavigation: false, | |
| maintainPosition: true | |
| }; | |
| $.extend(c, b.options.jScrollPaneSettings); | |
| if (b.options.events) { | |
| $.each(b.options.events, | |
| function (d, e) { | |
| b.options.element.bind(d, e) | |
| }) | |
| } | |
| var a = b.options.element.pScrollPane(c); | |
| this.jScrollPaneApi = a.data("jsp") | |
| }, | |
| setupDefaults: function () { | |
| $.extend(this.options.defaults, { | |
| floatingArrowOptions: { | |
| el: this.el, | |
| scrollLeftHandler: this.scrollLeftHandler, | |
| scrollRightHandler: this.scrollRightHandler | |
| }, | |
| keyboardScrollOptions: { | |
| scrollLeftHandler: this.scrollLeftHandler, | |
| scrollRightHandler: this.scrollRightHandler | |
| } | |
| }) | |
| }, | |
| doScroll: function (a) { | |
| if (this.options.customScrollHandler) { | |
| this.options.customScrollHandler(a) | |
| } else { | |
| this.jScrollPaneApi.scrollByX(a * this.options.scrollBy) | |
| } | |
| }, | |
| scrollLeftHandler: function () { | |
| this.doScroll(-1) | |
| }, | |
| scrollRightHandler: function () { | |
| this.doScroll(1) | |
| }, | |
| remove: function () {}, | |
| render: function () { | |
| if (!ap.isMobile) { | |
| if (this.options.useFloatingArrows) { | |
| var b = $.extend({ | |
| jScrollPaneApi: this.jScrollPaneApi, | |
| container: this.el | |
| }, this.options.defaults.floatingArrowOptions, this.options.floatingArrowOptions); | |
| this.floatingArrowScrollingView = new ap.aggregation.layout.FloatingArrowScrollingView(b); | |
| this.floatingArrowScrollingView.render() | |
| } | |
| if (this.options.useDragScrolling) { | |
| this.dragScrollingView = new ap.aggregation.layout.DragScrollingView({ | |
| jScrollPaneApi: this.jScrollPaneApi | |
| }); | |
| this.dragScrollingView.render() | |
| } | |
| if (this.options.useKeyboardScrolling) { | |
| var a = $.extend({}, this.options.defaults.keyboardScrollOptions, this.options.keyboardScrollOptions); | |
| this.keyboardScrollingView = new ap.aggregation.layout.KeyboardScrollingView(a); | |
| this.keyboardScrollingView.render() | |
| } | |
| if (this.options.useWheelScrolling) { | |
| this.wheelScrollingView = new ap.aggregation.layout.WheelScrollingView({ | |
| el: this.el, | |
| jScrollPaneApi: this.jScrollPaneApi | |
| }); | |
| this.wheelScrollingView.render() | |
| } | |
| } | |
| return this.jScrollPaneApi | |
| } | |
| }); | |
| ap.namespace("ap.aggregation.layout").TopFiltersView = Backbone.View.extend({ | |
| el: $("#top-filters"), | |
| toggleEls: null, | |
| mainFiltersEl: null, | |
| navEl: null, | |
| filterEls: null, | |
| summaryEl: null, | |
| buttonEls: null, | |
| activeFilters: {}, | |
| events: { | |
| "click #main-filters .filter": "activateFilter", | |
| "click #main-filters .bttn-filter": "activateFilter", | |
| "click .toggle.main-filters": "toggleMainFilters", | |
| "click .close-filter": "closeFilter", | |
| "click #main-filters .nav a": "updateTabs", | |
| toggleFilterDisplay: "toggleMainFilters", | |
| closeFilter: "closeFilter" | |
| }, | |
| buttons: ["museumView", "gigaPixel", "location", "streetView"], | |
| filterTypes: { | |
| alpha: { | |
| callback: function () {} | |
| }, | |
| dateRange: { | |
| callback: function () { | |
| $(".date-range").find(".slider").slider({ | |
| range: true, | |
| min: 0, | |
| max: 500, | |
| values: [75, 300], | |
| slide: function (a, b) {} | |
| }) | |
| } | |
| }, | |
| medium: {}, | |
| category: {}, | |
| museumView: {}, | |
| streetView: {}, | |
| gigaPixel: {}, | |
| location: {} | |
| }, | |
| filterDisplayNames: { | |
| country: "Country" | |
| }, | |
| filterButtons: [], | |
| initialize: function () { | |
| var a = this; | |
| ap.log("[Debug] Main filters: Starting init"); | |
| _.bindAll(this, "updateTabs", "activateFilter", "updateResults", "toggleFilter", "resetFilters", "setActiveFilter", "removeActiveFilter", "updateSelection", "enableFilter", "toggleMainFilters", "removeFilter", "closeFilter"); | |
| this.toggleEls = this.el.find(".toggle"); | |
| this.mainFiltersEl = this.el.find("#main-filters"); | |
| this.navEl = this.mainFiltersEl.find(".nav"); | |
| this.filterEls = this.mainFiltersEl.find(".filter"); | |
| this.toggleEls.filter(".main-filters").addClass("enabled"); | |
| this.summaryEl = $("#secondary-prop .collection-mutators"); | |
| this.buttonEls = this.mainFiltersEl.find(".bttn-filter"); | |
| this.parentView = a.options.parentView; | |
| _.each(a.options.filtersToInit, | |
| function (b, c) { | |
| a.enableFilter(b, c, _.indexOf(a.buttons, b.type) !== -1) | |
| }); | |
| this.navEl.find("a").first().click(); | |
| this.summaryEl.on("click", ".clear-mutator", this.removeFilter); | |
| this.renderSummary(); | |
| ap.log("[Debug] Main filters: Finished init") | |
| }, | |
| resetFilters: function (b) { | |
| var a = this; | |
| _.each(a.activeFilters, | |
| function (d, c) { | |
| var f = a.el.find('#main-filters [data-filter-key="' + c + '"]'), | |
| e = f.find('[data-filter-value="' + d.val + '"]'); | |
| a.toggleFilter(c, d, e, f, b) | |
| }) | |
| }, | |
| enableFilter: function (j, c, a) { | |
| var e = j.type, | |
| f = this.filterTypes[e], | |
| b = window.TRANSLATIONS && TRANSLATIONS.hasOwnProperty(j.displayNameKey) ? TRANSLATIONS[j.displayNameKey] : j.displayName, | |
| d; | |
| if (typeof f == "undefined") { | |
| ap.log("[Debug] Main filters: " + c + " of type " + e + " has not been found"); | |
| return | |
| } | |
| this.filterDisplayNames[c] = b; | |
| if (a) { | |
| ap.log(e + " is a button"); | |
| this.el.find("#main-filters > .wrap .filter-" + e).addClass("enabled").attr("data-filter-key", c); | |
| this.filterButtons.push(c) | |
| } else { | |
| d = this.navEl.find(".filter-" + e); | |
| d.text(b).attr("title", b); | |
| d.parent().addClass("enabled"); | |
| this.el.find("#main-filters > .wrap > .filter-" + e).attr("data-filter-key", c) | |
| } | |
| if (typeof f.callback === "function") { | |
| f.callback(); | |
| ap.log("[Debug] Main filters: " + c + " of type " + e + " callback done") | |
| } | |
| ap.log("[Debug] Main filters: " + c + " of type " + e + " enabled") | |
| }, | |
| closeFilter: function () { | |
| this.mainFiltersEl.is(":visible") && this.toggleMainFilters() | |
| }, | |
| toggleMainFilters: function (j) { | |
| if (j && j.preventDefault) { | |
| j.preventDefault() | |
| } | |
| var f = $("#page-content > .content-wrapper"), | |
| a = f.children(".content-with-sidebar"), | |
| k = $("#museum-list .mapwrapper"), | |
| b = this, | |
| c = this.mainFiltersEl.is(":visible"), | |
| d = function () { | |
| var m = c ? ["slideUp", 70, 0] : ["slideDown", 0, 6], | |
| e = $(document.documentElement), | |
| l = e.css("overflow"); | |
| $("#footer").stop().animate({ | |
| height: m[1] | |
| }); | |
| e.css({ | |
| overflow: "hidden" | |
| }); | |
| b.el.find(".close-filter").stop().animate({ | |
| top: m[2] | |
| }); | |
| b.mainFiltersEl.stop()[m[0]]({ | |
| complete: function () { | |
| e.css({ | |
| overflow: l | |
| }) | |
| }, | |
| step: function (p) { | |
| var n = b.mainFiltersEl.height(), | |
| o = b.mainFiltersEl.outerHeight(); | |
| f.css({ | |
| "padding-bottom": n | |
| }); | |
| a.css({ | |
| "padding-top": o | |
| }); | |
| k.css({ | |
| top: o | |
| }); | |
| b.parentView.preloaderview.positionPreloader({ | |
| "margin-top": o | |
| }, true) | |
| } | |
| }) | |
| }; | |
| this.toggleEls.filter(".main-filters").toggleClass("open", !c); | |
| b.parentView.trigger(c ? "topFilterClosing" : "topFilterOpening"); | |
| d(); | |
| return false | |
| }, | |
| openMainFilters: function () { | |
| var e = $("#page-content > .content-wrapper"), | |
| a = e.children(".content-with-sidebar"), | |
| f = $("#museum-list .mapwrapper"), | |
| c = this, | |
| d = this.mainFiltersEl.is(":visible"), | |
| b = function () { | |
| var m = ["slideDown", 0, 6, "70px"], | |
| j = $(document.documentElement); | |
| $("#footer").stop().css({ | |
| height: m[1] | |
| }); | |
| c.el.find(".close-filter").css({ | |
| top: m[2] | |
| }); | |
| c.mainFiltersEl.show(); | |
| var k = c.mainFiltersEl.height(), | |
| l = c.mainFiltersEl.outerHeight(); | |
| e.css({ | |
| "padding-bottom": k | |
| }); | |
| a.css({ | |
| "padding-top": l | |
| }); | |
| f.css({ | |
| top: l | |
| }); | |
| c.parentView.preloaderview.positionPreloader({ | |
| "margin-top": m[3] | |
| }, true) | |
| }; | |
| if (d) { | |
| return | |
| } | |
| this.toggleEls.filter(".main-filters").toggleClass("open", !d); | |
| b() | |
| }, | |
| updateTabs: function (a) { | |
| $(a.delegateTarget).find("dd").removeClass("active").filter(a.currentTarget.parentNode).addClass("active"); | |
| this.filterEls.removeClass("active").filter("." + $(a.currentTarget).data("filter-name")).addClass("active"); | |
| a.preventDefault() | |
| }, | |
| getNewResults: function (b, c, a) { | |
| var d; | |
| ap.log("[stub]: request for filter by " + b + ", with value " + c); | |
| d = "[new results]"; | |
| if (a && typeof a.callback === "function") { | |
| a.callback(d, a.el) | |
| } else { | |
| return d | |
| } | |
| }, | |
| updateSelection: function (a) { | |
| this.filterEls.find(".active").removeClass("active"); | |
| $(a).addClass("active") | |
| }, | |
| updateResults: function (b, a) { | |
| ap.log("[stub]: updated results with " + b); | |
| this.updateSelection(a) | |
| }, | |
| activateFilter: function (j) { | |
| var d = $(j.currentTarget), | |
| a = $(j.target), | |
| c = d.data("filter-key"), | |
| f = a.data("filter-value"), | |
| b = this; | |
| if (this.parentView.continentDropdown) { | |
| this.parentView.continentDropdown.resetDropdown() | |
| } | |
| if (!c) { | |
| c = a.parent().data("filter-key") | |
| } | |
| b.toggleFilter(c, f, a, d); | |
| j.preventDefault(); | |
| return false | |
| }, | |
| toggleFilter: function (e, f, a, d, c) { | |
| var b = this; | |
| if (!e || !f) { | |
| return | |
| } | |
| if (a.length === 0 && d.length === 0) { | |
| if (this.activeFilters[e]) { | |
| delete this.activeFilters[e]; | |
| this.renderSummary(); | |
| this.toggleEls.toggleClass("active", !$.isEmptyObject(this.activeFilters)); | |
| this.parentView.trigger("filterCurrentCollection", e, false, { | |
| silent: true | |
| }); | |
| this.parentView.trigger("filterCurrentCollection") | |
| } | |
| return | |
| } | |
| if (f && f == "reset") { | |
| if (!a.hasClass("active")) { | |
| delete this.activeFilters[e]; | |
| a.closest("ul").find("a.active").not(a).each(function () { | |
| var j = $(this).data("filter-value"); | |
| !c && b.parentView.trigger("filterCurrentCollection", e, false, { | |
| silent: true | |
| }) | |
| }).removeClass("active"); | |
| a.addClass("active"); | |
| !c && this.parentView.trigger("filterCurrentCollection") | |
| } | |
| } else { | |
| if (a.hasClass("active")) { | |
| delete this.activeFilters[e]; | |
| this.parentView.trigger("filterCurrentCollection", e, false, { | |
| silent: true | |
| }); | |
| this.parentView.trigger("filterCurrentCollection") | |
| } else { | |
| _.each(this.activeFilters, | |
| function (l, j) { | |
| b.parentView.trigger("filterCurrentCollection", j, false, { | |
| silent: true | |
| }) | |
| }); | |
| this.filterEls.add(this.buttonEls).find('.active:not(".reset")').removeClass("active"); | |
| this.filterEls.find(".reset").addClass("active"); | |
| this.activeFilters = {}; | |
| this.activeFilters[e] = { | |
| val: f, | |
| disp: a.text() | |
| }; | |
| !c && this.parentView.trigger("filterCurrentCollection", e, f) | |
| } | |
| a.toggleClass("active"); | |
| a.closest("ul").find('a[data-filter-value="reset"]').toggleClass("active", (a.closest("ul").find('a.active:not([data-filter-value="reset"])').length === 0)) | |
| } | |
| this.toggleEls.toggleClass("active", !$.isEmptyObject(this.activeFilters)); | |
| this.renderSummary() | |
| }, | |
| removeFilter: function (f) { | |
| var a = $(f.currentTarget), | |
| b = a.data("filter-key"), | |
| j = a.data("filter-value") + "", | |
| d = this.el.find('#main-filters [data-filter-key="' + b + '"]'), | |
| c = d.find('[data-filter-value="' + j + '"]'); | |
| if (this.parentView.continentDropdown) { | |
| this.parentView.continentDropdown.resetDropdown() | |
| } | |
| this.toggleFilter(b, j, c, d) | |
| }, | |
| removeAllFilters: function (b) { | |
| var a = this; | |
| _.each(a.activeFilters, | |
| function (d, c) { | |
| var e = a.el.find('#main-filters [data-filter-key="' + c + '"]'); | |
| e.find(".active").removeClass("active"); | |
| e.find(".reset").addClass("active"); | |
| delete a.activeFilters[c]; | |
| a.parentView.trigger("filterCurrentCollection", c, false, { | |
| silent: b | |
| }) | |
| }); | |
| a.toggleEls.removeClass("active"); | |
| a.renderSummary() | |
| }, | |
| renderSummary: function () { | |
| var a = this, | |
| b = function (e, f, d) { | |
| if ((f).toLowerCase() === "zzz") { | |
| d = "Other" | |
| } | |
| var c = _.indexOf(a.filterButtons, e) === -1 ? " " + d.charAt(0).toUpperCase() + d.substr(1) : ""; | |
| return $("<span />", { | |
| "class": "active-filter top-filter", | |
| "data-filter-name": e, | |
| text: a.filterDisplayNames[e] + c | |
| }).append(" ").append($("<span />", { | |
| "class": "clear-mutator", | |
| "data-filter-key": e, | |
| "data-filter-value": f | |
| })) | |
| }; | |
| a.summaryEl.find(".top-filter").remove(); | |
| if (!$.isEmptyObject(a.activeFilters)) { | |
| _.each(a.activeFilters, | |
| function (d, c) { | |
| a.summaryEl.append(b(c, d.val + "", d.disp + "")).append(" ") | |
| }) | |
| } | |
| }, | |
| setActiveFilter: function (c, d, a) { | |
| var b = this; | |
| _.each(this.activeFilters, | |
| function (f, e) { | |
| if (_.indexOf(b.filterButtons, e) !== -1) { | |
| b.parentView.trigger("filterCurrentCollection", e, false, { | |
| silent: true | |
| }); | |
| delete b.activeFilters[e]; | |
| b.el.find('#main-filters [data-filter-key="' + e + '"] .active').removeClass("active") | |
| } | |
| b.parentView.trigger("filterCurrentCollection", e, false, { | |
| silent: true | |
| }) | |
| }); | |
| this.activeFilters[c] = { | |
| val: d, | |
| disp: a || d | |
| }; | |
| b.el.find('#main-filters [data-filter-key="' + c + '"] [data-filter-value="' + d + '"] ').addClass("active").closest("ul").find(".reset").removeClass("active"); | |
| this.renderSummary(); | |
| this.toggleEls.toggleClass("active", !$.isEmptyObject(this.activeFilters)) | |
| }, | |
| removeActiveFilter: function (a) { | |
| if (this.activeFilters[a]) { | |
| delete this.activeFilters[a]; | |
| this.renderSummary(); | |
| this.toggleEls.toggleClass("active", !$.isEmptyObject(this.activeFilters)) | |
| } | |
| }, | |
| hideFilterButton: function () { | |
| this.toggleEls.filter(".main-filters").removeClass("enabled") | |
| }, | |
| showFilterButton: function () { | |
| this.toggleEls.filter(".main-filters").addClass("enabled") | |
| }, | |
| render: function () { | |
| var a = this; | |
| if (a.options.isOpen) { | |
| a.openMainFilters() | |
| } | |
| } | |
| }); | |
| ap.namespace("ap.aggregations").MainView = ap.globals.MainCollectionView.extend({ | |
| el: $("body.aggregation .content-with-sidebar"), | |
| options: { | |
| aggregationConfig: { | |
| artworkDimensions: { | |
| height: null, | |
| width: null | |
| }, | |
| aggregationType: null, | |
| collectionOptions: {}, | |
| modelViewType: null, | |
| useDynamicRows: true, | |
| viewType: null | |
| }, | |
| disabledButtons: [".add-to-collection"], | |
| visibleButtons: [".plusone", ".discover", ".share", ".add-to-collection", ".slideshow", ".streetview"] | |
| }, | |
| currentRowId: null, | |
| isInitialLoad: true, | |
| museumDetails: null, | |
| rowsView: null, | |
| lastHeight: null, | |
| initialPreloader: null, | |
| pagingProcessManager: null, | |
| loadedViewArray: [], | |
| slideShowData: { | |
| collection: null, | |
| startModel: null | |
| }, | |
| router: null, | |
| initialize: function (b) { | |
| var a = this; | |
| var c = a.options.aggregationConfig; | |
| a.router = a.options.router; | |
| _.bindAll(a, "addAll", "calculateDimensionsForRender", "imageLoadedCallback", "imageLoadErrorCallback", "initialBatchLoadedCallback", "addToExistingBatchLoadedCallback", "renderArtworkToPage", "render"); | |
| $.extend(true, this.options, this.options.aggregationConfig.overrideOptions); | |
| ap.globals.MainCollectionView.prototype.initialize.apply(a, [b]); | |
| a.currentRowId = c.rowId; | |
| ap.aggregation.layout.Global.currentRowView = ap.aggregation.layout.Config["rowView" + c.rowId]; | |
| a.lastHeight = $(window).height(); | |
| $(window).smartresize(function () { | |
| var d = a.lastHeight; | |
| a.lastHeight = $(window).height(); | |
| if (d != a.lastHeight && a.rowsView) { | |
| var e = false; | |
| if (c.aggregationBodyType === "galleries") { | |
| e = true | |
| } | |
| a.rowsView.aggregationZoomChange(ap.aggregation.layout.Global.currentRowView.title, e) | |
| } | |
| }); | |
| return a | |
| }, | |
| calculateDimensionsForRender: function () { | |
| var a = this; | |
| var c = a.options.aggregationConfig; | |
| var b = {}; | |
| if (!_.isNull(c.artworkDimensions.height)) { | |
| if (c.artworkDimensions.height === "auto") { | |
| b.height = ap.aggregation.layout.Global.currentRowView.image.height | |
| } else { | |
| b.height = c.artworkDimensions.height | |
| } | |
| if (b.height > 512) { | |
| b.height = 512 | |
| } | |
| } | |
| if (!_.isNull(c.artworkDimensions.width)) { | |
| b.width = c.artworkDimensions.width; | |
| if (b.width > 512) { | |
| b.width = 512 | |
| } | |
| } | |
| return b | |
| }, | |
| imageLoadedCallback: function (c, b) { | |
| var a = this; | |
| b.view.render(a.calculateDimensionsForRender()) | |
| }, | |
| imageLoadErrorCallback: function (b, a) { | |
| ap.log("Image load error for URL " + b, "warn"); | |
| a.self.loadedViewArray.splice(_.indexOf(a.self.loadedViewArray, a.view), 1) | |
| }, | |
| initialBatchLoadedCallback: function () { | |
| this.renderArtworkToPage(); | |
| if (this.sidebar && !_.include(this.options.disabledButtons, ".slideshow")) { | |
| this.sidebar.enableButton(".slideshow") | |
| } | |
| }, | |
| addToExistingBatchLoadedCallback: function () { | |
| this.isInitialLoad = false; | |
| this.renderArtworkToPage() | |
| }, | |
| renderArtworkToPage: function () { | |
| ap.aggregation.layout.RowFormat.setRowWidth(); | |
| var c = this.loadedViewArray.length; | |
| var d = !this.options.aggregationConfig.preloadImages; | |
| for (var b = 0; b < c; b++) { | |
| var a = this.loadedViewArray[b]; | |
| if (d) { | |
| ap.aggregation.layout.RowFormat.renderToNextRow((a.render(this.calculateDimensionsForRender())).el) | |
| } else { | |
| ap.aggregation.layout.RowFormat.renderToNextRow(a.el) | |
| } | |
| } | |
| if (this.isInitialLoad && !ap.isMobile) { | |
| this.rowsView = new ap.aggregation.layout.RowsView({ | |
| aggregationConfig: this.options.aggregationConfig, | |
| collection: this.currentCollection, | |
| el: this.el, | |
| jScrollPaneApi: this.jScrollPaneApi, | |
| rowFormat: ap.aggregation.layout.RowFormat, | |
| parentView: this | |
| }); | |
| this.rowsView.render(this.currentRowId) | |
| } else { | |
| if (this.isInitialLoad && ap.isMobile) { | |
| this.rowsView = new ap.mobile.aggregation.RowsView({ | |
| aggregationConfig: this.options.aggregationConfig, | |
| collection: this.currentCollection, | |
| el: this.el, | |
| jScrollPaneApi: this.jScrollPaneApi, | |
| rowFormat: ap.aggregation.layout.RowFormat, | |
| parentView: this | |
| }); | |
| this.rowsView.render(this.currentRowId) | |
| } | |
| } | |
| ap.aggregation.layout.RowFormat.setRowWidth(true); | |
| this.loadedViewArray = []; | |
| this.jScrollPaneApi.reinitialise(); | |
| if (ap.aggregation.layout.PageLoading.needToLoadMore() && this.isInitialLoad) { | |
| this.currentCollection.nextPage() | |
| } else { | |
| this.pagingProcessManager.end() | |
| } | |
| }, | |
| render: function () { | |
| ap.globals.MainCollectionView.prototype.render.apply(this, [this.options]); | |
| var a = new ap.aggregation.layout.SetupRow(); | |
| a.setRowconfig() | |
| } | |
| }); | |
| var AggregationWorkspace = Backbone.Router.extend({ | |
| routes: { | |
| "collection/:museumslug/museumview/*encodedLocation": "showMuseumView", | |
| ":countryCode/collection/:museumslug/museumview/*encodedLocation": "showMuseumViewI18N", | |
| "*defaulturl": "setupAggregationView" | |
| }, | |
| aggregationConfig: { | |
| aggregationBodyType: null, | |
| aggregationType: null, | |
| artworkDimensions: { | |
| height: "auto", | |
| width: null, | |
| }, | |
| dynamicRows: true, | |
| isSearch: null, | |
| magnifier: true, | |
| modelViewType: null, | |
| overrideOptions: {}, | |
| preloadImages: true, | |
| rowId: null, | |
| useDynamicArtworkInfo: true | |
| }, | |
| urlParts: null, | |
| showMuseumViewI18N: function (c, b, a) { | |
| this.showMuseumView(b, a) | |
| }, | |
| showMuseumView: function (b, a) { | |
| if (!window.app) { | |
| this.setupAggregationView() | |
| } | |
| ap.trackOpenMuseumView($("body").data("museum-slug"), ap.getMuseumAnalyticsId()); | |
| window.app.sidebar.killMuseumView(); | |
| window.app.sidebar.showMuseumView(null, a) | |
| }, | |
| hideMuseumView: function () { | |
| window.app.sidebar.hideMuseumView() | |
| }, | |
| setupAggregationView: function () { | |
| if (window.app) { | |
| this.hideMuseumView() | |
| } else { | |
| var b = this; | |
| var e = this.aggregationConfig; | |
| var d = ap.getQueryStringParams(); | |
| var j = {}; | |
| var f = window.location.hash; | |
| if (f && f.indexOf("museumview") == -1 && f.indexOf("collection") == -1) { | |
| rowId = window.location.hash.replace("#", "").split("-")[0]; | |
| e.rowId = rowId.charAt(0).toUpperCase() + rowId.slice(1) | |
| } | |
| e.aggregationBodyType = $("body").attr("id"); | |
| e.isSearch = (e.aggregationBodyType === "search") ? true : false; | |
| if (e.aggregationBodyType === "artworks") { | |
| j = ap.getCurrentArtworkCollectionState() | |
| } else { | |
| ap.clearCurrentArtworkCollectionState() | |
| } | |
| if (e.aggregationBodyType === "artists") { | |
| e.aggregationType = "ArtistList" | |
| } else { | |
| if (e.aggregationBodyType === "artworks") { | |
| var a = {}; | |
| e.aggregationType = "ArtworkList"; | |
| e.modelViewType = "ArtworkView"; | |
| e.artworkDimensions = { | |
| height: "auto" | |
| }; | |
| _.each(j, | |
| function (m, l) { | |
| a[l] = m.value | |
| }); | |
| d = $.extend(d, a); | |
| b.urlParts = ["artwork"] | |
| } else { | |
| if (e.aggregationBodyType === "galleries") { | |
| e.aggregationType = "PublicBookmarkGroupList"; | |
| e.dynamicRows = true; | |
| e.magnifier = false; | |
| e.rowId = "Bookmarks", e.modelViewType = "BookmarkGroupView"; | |
| e.preloadImages = false, e.useDynamicArtworkInfo = false; | |
| e.overrideOptions = { | |
| disabledButtons: [".add-to-collection", ".slideshow"] | |
| }; | |
| b.urlParts = ["public_bookmarkgroup"] | |
| } else { | |
| if (e.aggregationBodyType === "gallery") { | |
| e.aggregationType = "PublicBookmarkList"; | |
| e.modelViewType = "BookmarkArtworkView"; | |
| e.artworkDimensions = { | |
| height: "auto" | |
| }; | |
| b.urlParts = ["public_bookmark"]; | |
| e.artworkDimensions = { | |
| height: "auto" | |
| }; | |
| e.overrideOptions = { | |
| disabledButtons: [".add-to-collection"] | |
| }; | |
| d = $.extend(d, { | |
| bookmark_group: $("body").data("group-id") | |
| }) | |
| } else { | |
| if (e.aggregationBodyType === "museum") { | |
| e.aggregationType = "ArtworkList"; | |
| e.modelViewType = "ArtworkView"; | |
| e.overrideOptions = { | |
| disabledButtons: [".add-to-collection", ".slideshow"] | |
| }; | |
| b.urlParts = ["artwork"]; | |
| d = $.extend(d, { | |
| collection: $("body").data("museum-id") | |
| }) | |
| } else { | |
| if (e.aggregationBodyType === "artist") { | |
| e.aggregationType = "ArtworkList"; | |
| e.modelViewType = "ArtworkView"; | |
| e.overrideOptions = { | |
| disabledButtons: [".add-to-collection", ".slideshow"] | |
| }; | |
| b.urlParts = ["artwork"]; | |
| d = $.extend(d, { | |
| canonical_artist: $("body").data("artist-id") | |
| }) | |
| } else { | |
| if (e.aggregationBodyType === "level") { | |
| e.aggregationType = "ArtworkList"; | |
| e.modelViewType = "ArtworkView"; | |
| b.urlParts = ["artwork"]; | |
| d = $.extend(d, { | |
| level: $("body").data("level-id") | |
| }) | |
| } else { | |
| if (e.aggregationBodyType === "room") { | |
| e.aggregationType = "ArtworkList"; | |
| e.modelViewType = "ArtworkView"; | |
| b.urlParts = ["artwork"]; | |
| d = $.extend(d, { | |
| room: $("body").data("room-id") | |
| }) | |
| } else { | |
| if (e.aggregationBodyType === "search") { | |
| var c = $("body").attr("class").split(/\s+/); | |
| $.each(c, | |
| function (l, n) { | |
| var m = n.indexOf("-search-aggregation"); | |
| var k = null; | |
| if (m !== -1) { | |
| k = n.substring(0, m); | |
| if (k === "artworks") { | |
| e.aggregationType = "ArtworkList"; | |
| e.artworkDimensions = { | |
| height: 80, | |
| width: 80 | |
| }; | |
| e.dynamicRows = false; | |
| e.magnifier = false; | |
| e.modelViewType = "SearchArtworkView"; | |
| e.useDynamicArtworkInfo = false; | |
| e.overrideOptions = { | |
| disabledButtons: [".add-to-collection"] | |
| }; | |
| b.urlParts = ["artwork"] | |
| } else { | |
| if (k === "artists") { | |
| e.aggregationType = "ArtistList"; | |
| e.artworkDimensions = { | |
| height: 80, | |
| width: 80 | |
| }; | |
| e.dynamicRows = false; | |
| e.magnifier = false; | |
| e.modelViewType = "SearchArtistView"; | |
| e.preloadImages = false, e.useDynamicArtworkInfo = false; | |
| e.overrideOptions = { | |
| disabledButtons: [".add-to-collection", ".slideshow"] | |
| }; | |
| b.urlParts = ["artist"] | |
| } else { | |
| if (k === "collections") { | |
| e.aggregationType = "MuseumList"; | |
| e.artworkDimensions = { | |
| height: 80, | |
| width: 80 | |
| }; | |
| e.dynamicRows = false; | |
| e.magnifier = false; | |
| e.modelViewType = "SearchMuseumView"; | |
| e.preloadImages = false, e.useDynamicArtworkInfo = false; | |
| e.overrideOptions = { | |
| disabledButtons: [".add-to-collection", ".slideshow"] | |
| }; | |
| b.urlParts = ["collection"] | |
| } else { | |
| if (k === "galleries") { | |
| e.aggregationType = "PublicBookmarkGroupList"; | |
| e.collectionOptions = { | |
| url: ap.buildApiUrl(["public_bookmarkgroup"], { | |
| offset: 0 | |
| }) | |
| }; | |
| e.artworkDimensions = { | |
| height: 80, | |
| width: 80 | |
| }; | |
| e.dynamicRows = false; | |
| e.magnifier = false; | |
| e.modelViewType = "SearchBookmarkGroupView"; | |
| e.preloadImages = false, e.useDynamicArtworkInfo = false; | |
| e.overrideOptions = { | |
| disabledButtons: [".add-to-collection", ".slideshow"] | |
| }; | |
| b.urlParts = ["public_bookmarkgroup"] | |
| } else { | |
| if (k === "videos") { | |
| e.aggregationType = "ArtistList"; | |
| e.artworkDimensions = { | |
| height: 80, | |
| width: 80 | |
| }; | |
| e.dynamicRows = false; | |
| e.magnifier = false; | |
| e.modelViewType = "SearchArtistView"; | |
| e.preloadImages = false, e.useDynamicArtworkInfo = false; | |
| e.overrideOptions = { | |
| disabledButtons: [".add-to-collection", ".slideshow"] | |
| }; | |
| b.urlParts = ["artist"] | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| }); | |
| e.rowId = "Multi"; | |
| if (_.isNull(e.aggregationType)) { | |
| ap.log("Could not determine aggregation type for search results", "error"); | |
| return | |
| } else { | |
| ap.log("Page is a search aggregation of " + e.aggregationType, "info") | |
| } | |
| } else { | |
| return | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| window.app = {}; | |
| if (_.isNull(e.rowId)) { | |
| e.rowId = "Two" | |
| } | |
| if (!e.dynamicRows) { | |
| e.rowId = "Multi" | |
| } | |
| window.app = new ap.aggregations.MainView({ | |
| aggregationConfig: e, | |
| qs_params: d, | |
| urlParts: b.urlParts, | |
| router: this | |
| }); | |
| window.app.render(); | |
| if (e.aggregationBodyType === "museum") { | |
| window.app.museumDetails = new ap.details.layout.Main({ | |
| sidebar: window.app.sidebar, | |
| parentView: window.app | |
| }) | |
| } | |
| } | |
| } | |
| }); | |
| $(document).ready(function () { | |
| var a = $("body"); | |
| if (a.hasClass("aggregation") && a.attr("id") != "museumlist") { | |
| new AggregationWorkspace(); | |
| if (ap.isMobile) { | |
| Backbone.history.start({}) | |
| } else { | |
| Backbone.history.start({ | |
| pushState: true | |
| }) | |
| } | |
| } | |
| }); | |
| ap.namespace("ap.aggregation.layout").ArtworkBaseView = Backbone.View.extend({ | |
| tagName: "img", | |
| className: "artwork", | |
| events: { | |
| recalculateWidth: "recalculateWidth" | |
| }, | |
| initialize: function () { | |
| _.bindAll(this, "render") | |
| }, | |
| render: function (d, f) { | |
| var a = this.model.attributes; | |
| var c = $(this.el); | |
| var e = this.model.calculateImageSizeForAPI(d); | |
| var b = (f) ? "max-height: " + d.maxHeight + " px; max-width: " + d.maxWidth + "px" : "height: " + d.height + "px;"; | |
| c.attr("data-cid", this.model.cid); | |
| c.attr("src", this.model.image(e)); | |
| c.data("model", this.model); | |
| return this | |
| }, | |
| recalculateWidth: function (b, a) { | |
| var c = $(this.el); | |
| c.attr("width", Math.round(a * this.model.attributes.primary_image_aspect_ratio)) | |
| } | |
| }); | |
| ap.namespace("ap.artwork.layout").CollapserView = Backbone.View.extend({ | |
| tagName: "a", | |
| className: "collapser", | |
| events: { | |
| click: "toggleContainer" | |
| }, | |
| container: null, | |
| lineHeight: 0, | |
| currentHeight: 0, | |
| lines: 3, | |
| wrapper: null, | |
| initialize: function () { | |
| if (!this.options.container) { | |
| return | |
| } | |
| _.bindAll(this, "render", "toggleContainer"); | |
| if (this.options.lines) { | |
| this.lines = this.options.lines | |
| } | |
| this.container = this.options.container; | |
| this.wrapper = this.container.find(".wrapper").eq(0); | |
| this.lineHeight = parseInt(this.wrapper.css("line-height"), 10); | |
| this.currentHeight = this.wrapper.outerHeight(true); | |
| this.targetHeight = this.lineHeight * this.lines; | |
| if (this.currentHeight > this.targetHeight) { | |
| return this.render() | |
| } | |
| }, | |
| toggleContainer: function (a, c) { | |
| var b = this; | |
| var d; | |
| if (b.container.hasClass("shrinked")) { | |
| b.el.text(TRANSLATIONS.less); | |
| b.container.removeClass("shrinked"); | |
| d = b.currentHeight | |
| } else { | |
| b.el.text(TRANSLATIONS.more); | |
| b.container.addClass("shrinked"); | |
| d = b.targetHeight | |
| } | |
| if (c === true) { | |
| b.wrapper.css({ | |
| height: d | |
| }) | |
| } else { | |
| b.wrapper.animate({ | |
| height: d | |
| }, | |
| function () { | |
| if (!_.isUndefined(a)) { | |
| b.options.detailsView.recalculateHeights(true, | |
| function () { | |
| b.options.detailsView.jScrollPaneApi.reinitialise() | |
| }) | |
| } | |
| }) | |
| } | |
| }, | |
| render: function () { | |
| $(this.el).text(TRANSLATIONS.more); | |
| this.container.append($(this.el)); | |
| this.el = $(this.el); | |
| this.toggleContainer(null, true); | |
| return this | |
| } | |
| }); | |
| ap.namespace("ap.microscope.layout").Main = Backbone.View.extend({ | |
| tagName: "div", | |
| className: "microscope artwork-large", | |
| microscope: null, | |
| initialState: { | |
| x: 0.5, | |
| y: 0.5, | |
| z: 2 | |
| }, | |
| imageUrl: null, | |
| aspectRatio: null, | |
| microscopeState: null, | |
| maxSize: 2048, | |
| initialize: function () { | |
| _.bindAll(this, "render", "loadImage", "animate", "center", "loadSingleImage", "getCurrentState"); | |
| var a = this; | |
| a.imageUrl = a.options.imageUrl; | |
| a.aspectRatio = a.options.aspectRatio; | |
| a.microscopeState = a.options.microscopeState; | |
| return this.render() | |
| }, | |
| loadImage: function (a, b) { | |
| this.imageUrl = a; | |
| this.aspectRatio = b; | |
| this.microscope.LoadImage(a, this.microscopeState) | |
| }, | |
| loadSingleImage: function (b, d) { | |
| ap.log("Tile data not found, loading single image: " + b, "info"); | |
| ap.log("Aspect ratio: " + d, "info"); | |
| var c = this.maxSize; | |
| var a = parseInt((this.maxSize / d), 10); | |
| this.microscope.LoadSingleImage(b + "=s" + this.maxSize, c, a, this.microscopeState) | |
| }, | |
| getCurrentState: function () { | |
| return this.microscope.GetState() | |
| }, | |
| center: function () { | |
| try { | |
| this.microscope.Center() | |
| } catch (a) {} | |
| }, | |
| animate: function (b, a) { | |
| if (_.isUndefined(b)) { | |
| var b = new MicroscopeState(this.initialState.x, this.initialState.y, this.initialState.z) | |
| } | |
| if (!a) { | |
| a = 0 | |
| } | |
| this.microscope.AnimateTo(b, a) | |
| }, | |
| render: function () { | |
| var a = this; | |
| if (a.options.prepend) { | |
| a.options.container.prepend($(a.el)) | |
| } else { | |
| a.options.container.append($(a.el)) | |
| } | |
| a.microscope = new Microscope(a.el, true); | |
| a.microscope.SetLoadCallback(function (b) { | |
| if (b !== true) {} | |
| }); | |
| a.loadImage(a.imageUrl, a.aspectRatio); | |
| a.el = $(a.el); | |
| return a.microscope | |
| } | |
| }); | |
| ap.namespace("ap.artwork.layout").RecommendedBarView = Backbone.View.extend({ | |
| tagName: "div", | |
| className: "recommended-artworks", | |
| template: $("#recommended_artworks-template").html(), | |
| container: null, | |
| events: { | |
| "click .tabs a": "switchTab", | |
| "click .artwork": "artworkClickHandler" | |
| }, | |
| artwork: null, | |
| recommendedArtworkList: null, | |
| sameMuseumArtworkList: null, | |
| sameArtistArtworkList: null, | |
| limit: 20, | |
| initialize: function () { | |
| var a = this; | |
| a.container = a.options.container; | |
| a.parentView = a.options.parentView; | |
| _.bindAll(this, "render", "addSingleArtwork", "addArtworks", "addRecommendedArtworks", "addSameMuseumArtworks", "addSameArtistArtworks", "switchTab", "artworkClickHandler"); | |
| a.artwork = a.options.artwork; | |
| a.recommendedArtworkList = new ap.ArtworkList(null, { | |
| url: ap.buildApiUrl(["artwork"], { | |
| limit: a.limit | |
| }) | |
| }); | |
| a.sameMuseumArtworkList = new ap.ArtworkList(null, { | |
| url: ap.buildApiUrl(["artwork"], { | |
| limit: a.limit, | |
| collection: a.artwork.collection_id | |
| }) | |
| }); | |
| a.sameArtistArtworkList = new ap.ArtworkList(null, { | |
| url: ap.buildApiUrl(["artwork"], { | |
| limit: a.limit, | |
| canonical_artist: a.artwork.canonical_artist_id | |
| }) | |
| }); | |
| a.recommendedArtworkList.bind("reset", a.addRecommendedArtworks); | |
| a.sameMuseumArtworkList.bind("reset", a.addSameMuseumArtworks); | |
| a.sameArtistArtworkList.bind("reset", a.addSameArtistArtworks) | |
| }, | |
| artworkClickHandler: function (a) { | |
| var b = this; | |
| if ($("body").hasClass(b.parentView.cssHooks.DETAILS_CLASS)) { | |
| var c = $(a.currentTarget).data("artworkListToUse"); | |
| b.parentView.showArtwork(function () { | |
| b.parentView.thumbnailStrip.el.trigger("artworkListChange", [c]); | |
| b.parentView.router.navigate($(a.currentTarget).attr("href").replace("/", ""), true) | |
| }) | |
| } | |
| return false | |
| }, | |
| switchTab: function (f) { | |
| var b = this; | |
| var c = b.el.find(".tabs li a"); | |
| c.removeClass("active"); | |
| var d = $(f.currentTarget); | |
| b.el.find("a[href=" + d.attr("href") + "]").addClass("active"); | |
| var a = d.attr("href").replace("#", "."); | |
| var j = b.el.find(a); | |
| b.el.find(".tab.active").fadeOut("fast"); | |
| j.addClass("active").fadeIn("fast"); | |
| return false | |
| }, | |
| addSingleArtwork: function (d, b) { | |
| var c = this; | |
| if (c.artwork.id != b.attributes.id) { | |
| var a = new ap.aggregation.layout.ArtworkView({ | |
| model: b, | |
| noMagnifier: true | |
| }); | |
| a.render({ | |
| height: 100 | |
| }); | |
| var e = c.recommendedArtworkList; | |
| if (d == "same-museum") { | |
| e = c.sameMuseumArtworkList | |
| } else { | |
| if (d == "same-artist") { | |
| e = c.sameArtistArtworkList | |
| } | |
| } | |
| $(a.el).data("artworkListToUse", e); | |
| c.el.find("." + d).append(a.el) | |
| } | |
| }, | |
| addArtworks: function (b, c) { | |
| var a = this; | |
| if (c.models.length <= 1) { | |
| a.removeTab(b) | |
| } else { | |
| $.each(c.models, | |
| function (e, d) { | |
| a.addSingleArtwork(b, d) | |
| }) | |
| } | |
| }, | |
| removeTab: function (b) { | |
| var a = this; | |
| var d = a.el.find(".tab-" + b); | |
| var c = a.el.find("." + b); | |
| d.prev().remove(); | |
| d.remove(); | |
| c.remove() | |
| }, | |
| addRecommendedArtworks: function () { | |
| var a = this; | |
| a.addArtworks("recommended", a.recommendedArtworkList) | |
| }, | |
| addSameMuseumArtworks: function () { | |
| var a = this; | |
| a.addArtworks("same-museum", a.sameMuseumArtworkList) | |
| }, | |
| addSameArtistArtworks: function () { | |
| var a = this; | |
| a.addArtworks("same-artist", a.sameArtistArtworkList) | |
| }, | |
| render: function () { | |
| this.el = $(this.el); | |
| this.el.html(_.template(this.template, this.artwork)); | |
| this.container.append(this.el); | |
| this.el.find(".tabs li a").eq(0).trigger("click"); | |
| this.recommendedArtworkList.fetch(); | |
| this.sameMuseumArtworkList.fetch(); | |
| if (this.artwork.canonical_artist_id) { | |
| this.sameArtistArtworkList.fetch() | |
| } | |
| return this | |
| } | |
| }); | |
| ap.namespace("ap.artwork.layout").MapView = Backbone.View.extend({ | |
| tagName: "div", | |
| className: "artwork-artist-map", | |
| template: '<div id="mapcanvas" class="mapcanvas" style="width: 770px; height: 512px; position: relative;"></div>', | |
| infoboxTemplate: null, | |
| extraScripts: ["markerwithlabel", "markerclusterer", "infobox"], | |
| mainMapOptions: { | |
| centre: { | |
| lat: 48.89364, | |
| lng: 2.33739 | |
| }, | |
| zoom: 3, | |
| mapTypeId: "ROADMAP", | |
| disableDefaultUI: true | |
| }, | |
| mapCanvas: null, | |
| context: null, | |
| geocoder: null, | |
| markers: {}, | |
| initialize: function () { | |
| _.bindAll(this, "render", "loadExtraScripts", "refreshMap", "addMarker", "renderMarkers", "geocodeAll", "createMarkers", "loadMapsAPI"); | |
| this.context = this.options.context | |
| }, | |
| addMarker: function (e, f, d) { | |
| var c = this; | |
| var a = e[0]; | |
| var j = a.geometry.location; | |
| var b = new google.maps.Marker({ | |
| position: new google.maps.LatLng(j.lat(), j.lng()), | |
| draggable: false, | |
| map: c.map, | |
| icon: "/skip_media_generator/map-pin-circle-" + f + ".png", | |
| infobox: new InfoBox($.extend({}, c.infoboxOptions, d)) | |
| }); | |
| return b | |
| }, | |
| createInfoBoxContent: function (a) { | |
| var b = _.template($("#map_infobox-template").html(), { | |
| contexts: a | |
| }); | |
| return b | |
| }, | |
| getSize: function (c) { | |
| var b = 0; | |
| for (var a in c) { | |
| if (c.hasOwnProperty(a)) { | |
| ++b | |
| } | |
| } | |
| return b | |
| }, | |
| geocodeAll: function () { | |
| var a = this; | |
| $.each(a.addressesToGeocode, | |
| function (c, b) { | |
| var d = new google.maps.Geocoder(); | |
| d.geocode({ | |
| address: b.address | |
| }, | |
| function (f, e) { | |
| if (e == "OK") { | |
| delete a.addressesToGeocode[c]; | |
| a.markers[c] = { | |
| results: f, | |
| key: c, | |
| place: b | |
| }; | |
| if (a.getSize(a.addressesToGeocode) == 0) { | |
| a.renderMarkers() | |
| } | |
| } else { | |
| ap.log("something wrong with: " + c) | |
| } | |
| }) | |
| }) | |
| }, | |
| setInfoboxContent: function (a) { | |
| a.infobox.setContent(this.createInfoBoxContent(a.context)) | |
| }, | |
| renderMarkers: function () { | |
| var c = this; | |
| var d = c.getSize(c.markers); | |
| var f = { | |
| single: [], | |
| group: [] | |
| }; | |
| if (d == 3 && (c.markers.death && c.markers.artwork && c.markers.death) && (c.markers.birth.place.address == c.markers.death.place.address) && (c.markers.death.place.address == c.markers.artwork.place.address)) { | |
| $.each(c.markers, | |
| function (k, l) { | |
| f.group.push(l) | |
| }) | |
| } else { | |
| if ((c.markers.birth && c.markers.death) && (c.markers.birth.place.address == c.markers.death.place.address)) { | |
| f.group.push(c.markers.birth); | |
| f.group.push(c.markers.death); | |
| if (d == 3) { | |
| f.single.push(c.markers.artwork) | |
| } | |
| } else { | |
| if ((c.markers.birth && c.markers.artwork) && (c.markers.birth.place.address == c.markers.artwork.place.address)) { | |
| f.group.push(c.markers.birth); | |
| f.group.push(c.markers.artwork); | |
| if (d == 3) { | |
| f.single.push(c.markers.death) | |
| } | |
| } else { | |
| if ((c.markers.death && c.markers.artwork) && (c.markers.death.place.address == c.markers.artwork.place.address)) { | |
| f.group.push(c.markers.death); | |
| f.group.push(c.markers.artwork); | |
| if (d == 3) { | |
| f.single.push(c.markers.birth) | |
| } | |
| } else { | |
| $.each(c.markers, | |
| function (k, l) { | |
| if (l) { | |
| f.single.push(l) | |
| } | |
| }) | |
| } | |
| } | |
| } | |
| } | |
| var b = []; | |
| $.each(f.single, | |
| function (k, l) { | |
| if (l) { | |
| a = c.addMarker(l.results, l.place.icon_suffix); | |
| a.context = [l.place]; | |
| c.setInfoboxContent(a); | |
| a.infobox.open(c.map, a); | |
| b.push(a) | |
| } | |
| }); | |
| var j = f.group.length; | |
| if (j) { | |
| var e = "black"; | |
| if (j == 3) { | |
| e = "triple" | |
| } | |
| var a = c.addMarker(f.group[0].results, e); | |
| a.context = []; | |
| $.each(f.group, | |
| function (k, l) { | |
| a.context.push(l.place) | |
| }); | |
| c.setInfoboxContent(a); | |
| a.infobox.open(c.map, a); | |
| b.push(a) | |
| } | |
| c.fitMarkers(b) | |
| }, | |
| createMarkers: function () { | |
| var l = this; | |
| var e = l.context.artist; | |
| var d = l.context.artwork; | |
| var b = e.birth_place ? e.birth_place : null; | |
| var f = e.birth_date_display ? e.birth_date_display : (e.birth_year ? e.birth_year : null); | |
| var c = e.death_place ? e.death_place : null; | |
| var k = e.death_date_display ? e.death_date_display : (e.death_year ? e.death_year : null); | |
| var a = d.place_name ? d.place_name : null; | |
| var j = null; | |
| if (d.place_earliest_date && d.place_latest_date) { | |
| j = d.place_earliest_date + " - " + d.place_latest_date | |
| } else { | |
| if (d.place_earliest_date) { | |
| j = d.place_earliest_date | |
| } else { | |
| if (d.place_latest_date) { | |
| j = d.place_latest_date | |
| } | |
| } | |
| } | |
| l.addressesToGeocode = {}; | |
| if (b) { | |
| l.addressesToGeocode.birth = { | |
| action: "Born", | |
| date: f, | |
| address: b, | |
| icon_suffix: "black" | |
| } | |
| } else { | |
| l.markers.birth = null | |
| } | |
| if (a) { | |
| l.addressesToGeocode.artwork = { | |
| action: "Created", | |
| date: j, | |
| address: a, | |
| icon_suffix: "yellow", | |
| "class": "yellow" | |
| } | |
| } else { | |
| l.markers.artwork = null | |
| } | |
| if (c) { | |
| l.addressesToGeocode.death = { | |
| action: "Died", | |
| date: k, | |
| address: c, | |
| icon_suffix: "black" | |
| } | |
| } else { | |
| l.markers.death = null | |
| } | |
| if (b || a || c) { | |
| return true | |
| } else { | |
| return false | |
| } | |
| }, | |
| fitMarkers: function (b) { | |
| var c = this; | |
| var a = new google.maps.LatLngBounds(); | |
| $.each(b, | |
| function (e, d) { | |
| if (d) { | |
| a.extend(d.position) | |
| } | |
| }); | |
| c.map.fitBounds(a); | |
| if (c.map.getZoom() > 5) { | |
| c.map.setZoom(5) | |
| } | |
| if (b.length == 1) { | |
| c.map.setCenter(b[0].position) | |
| } | |
| c.refreshMap(true) | |
| }, | |
| loadMapsAPI: function (c) { | |
| if (_.isUndefined(window.google.maps) || _.isUndefined(window.google.maps.Geocoder)) { | |
| var b = ap.getMapsApiKey(); | |
| var a = "//maps.googleapis.com/maps/api/js?key=" + b + "&sensor=false&callback=" + c; | |
| $('<script src="' + a + '">').appendTo($("body")) | |
| } else { | |
| this.render() | |
| } | |
| }, | |
| loadExtraScripts: function () { | |
| $.each(this.extraScripts, | |
| function (b, c) { | |
| var a = $("<script />"); | |
| a.attr("type", "text/javascript"); | |
| a.attr("src", "/skip_media_generator/" + c + ".js"); | |
| $("body").append(a) | |
| }); | |
| this.render() | |
| }, | |
| refreshMap: function (a) { | |
| google.maps.event.trigger(this.map, "resize"); | |
| if (a !== true) { | |
| this.map.setCenter(this.mainMapOptions.center) | |
| } | |
| this.map.setZoom(this.map.getZoom()) | |
| }, | |
| setupInfobox: function () { | |
| this.infoboxOptions = { | |
| disableAutoPan: true, | |
| maxWidth: 0, | |
| pixelOffset: new google.maps.Size(-37, 0), | |
| zIndex: null, | |
| closeBoxURL: "", | |
| infoBoxClearance: new google.maps.Size(1, 1), | |
| pane: "floatPane", | |
| enableEventPropagation: true | |
| } | |
| }, | |
| render: function () { | |
| if (this.createMarkers()) { | |
| this.el = $(this.el); | |
| this.el.html(_.template(this.template)); | |
| this.options.container.append(this.el); | |
| this.mapCanvas = this.el.find(".mapcanvas").eq(0); | |
| this.mainMapOptions.center = new google.maps.LatLng(this.mainMapOptions.centre.lat, this.mainMapOptions.centre.lng); | |
| this.mainMapOptions.mapTypeId = "roadmap"; | |
| this.map = new google.maps.Map(this.mapCanvas.get(0), this.mainMapOptions); | |
| this.setupInfobox(); | |
| this.geocodeAll() | |
| } else { | |
| $("li[data-asset-type=map]").remove(); | |
| this.options.parentView.setup() | |
| } | |
| return this | |
| } | |
| }); | |
| ap.namespace("ap.artwork.layout").DetailsPaneView = Backbone.View.extend({ | |
| tagName: "div", | |
| className: "artwork-details", | |
| template: null, | |
| mainScrollingView: null, | |
| jScrollPaneApi: null, | |
| maxImageWidth: 770, | |
| thumbWidth: 73, | |
| activeAssetType: "image", | |
| mainPane: null, | |
| context: null, | |
| imagesToPreload: [], | |
| imagePreloader: null, | |
| audioPlayer: null, | |
| playlist: null, | |
| playlistItems: [], | |
| primaryImage: null, | |
| aspectRatio: null, | |
| parentView: null, | |
| initialize: function () { | |
| _.bindAll(this, "render", "setup", "doScroll", "playItem", "recalculateHeights", "assetThumbClick"); | |
| var a = this; | |
| a.context = a.options.context; | |
| a.parentView = a.options.parentView; | |
| a.primaryImage = a.context.artwork.aggregation_image_url; | |
| a.aspectRatio = a.context.artwork.primary_image_aspect_ratio; | |
| a.openAfterLoad = a.options.openAfterLoad; | |
| $.each(a.context.assets, | |
| function (b, c) { | |
| if (c.kind == "image" && c.full_url) { | |
| a.imagesToPreload.push(c.full_url + "=s" + a.maxImageWidth) | |
| } | |
| }); | |
| a.imagePreloader = new ap.system.imagePreload("artworkDetailsPane-" + a.context.artwork.id, { | |
| batchLoaded: function () { | |
| a.render() | |
| } | |
| }); | |
| $.each(a.imagesToPreload, | |
| function (b, c) { | |
| a.imagePreloader.addToQueue(c) | |
| }); | |
| if (a.context.artwork.collection_logo) { | |
| a.imagePreloader.addToQueue(a.context.artwork.collection_logo) | |
| } | |
| a.imagePreloader.load() | |
| }, | |
| recalculateHeights: function (e, k) { | |
| var d = this; | |
| var c = $(".artwork_assets_wrapper"); | |
| var b = 0; | |
| $.each($(".artwork_assets_wrapper ul li.asset"), | |
| function (m, l) { | |
| if ($(l).height() > b) { | |
| b = $(l).height() | |
| } | |
| }); | |
| if (e) { | |
| var a = c.height(); | |
| var f = $(".artwork-details").outerHeight(); | |
| var j = b - a; | |
| c.animate({ | |
| height: b | |
| }); | |
| $(".content-wrapper").animate({ | |
| height: f + j | |
| }, | |
| function () { | |
| if (k) { | |
| k() | |
| } | |
| }) | |
| } else { | |
| c.css("height", b); | |
| d.parentView.resizeMicroscopeViewer(false) | |
| } | |
| ap.log("[Debug] recalculateHeights done") | |
| }, | |
| assetThumbClick: function (b) { | |
| var c = this; | |
| var e = $(b.currentTarget); | |
| var d = $(e).index(); | |
| var a = $(".artwork_assets_wrapper li.asset").eq(d); | |
| c.doScroll(0, a); | |
| c.trackAssetView(e, d) | |
| }, | |
| trackAssetView: function (d, b) { | |
| var c = d.attr("class").split(/\s+/); | |
| var a = ""; | |
| $.each(c, | |
| function (e, f) { | |
| if (f === "details" || f === "image" || f === "video" || f === "audio" || f === "map") { | |
| a = f | |
| } | |
| }); | |
| ap.trackDetailsPane({ | |
| tab_index: b, | |
| tab_content_type: a | |
| }, ap.getMuseumAnalyticsId()) | |
| }, | |
| setup: function () { | |
| var l = this; | |
| var f = $(".artwork_assets_wrapper ul.asset_list"); | |
| var e = f.find("li.asset"); | |
| var c = e.length * $(e[0]).width(); | |
| if (e.length == 1) { | |
| $(".floating-arrow-right").hide() | |
| } | |
| f.width(c); | |
| l.jScrollPaneApi.reinitialise({ | |
| contentWidth: c | |
| }); | |
| var m = $(".artwork_thumbs ul.asset_list"); | |
| m.find("li.asset:last").css("margin-right", 0); | |
| var k = m.find("li.asset"); | |
| var a = k.length * k.eq(0).outerWidth(true); | |
| m.css("width", a); | |
| l.thumbjScrollPaneApi.reinitialise(); | |
| var b = $(".artwork_object_details ul.asset_list"); | |
| var j = b.find("li"); | |
| var d = j.length * j.eq(0).width(); | |
| b.css("width", d); | |
| $.each($(".facet"), | |
| function (n, o) { | |
| new ap.artwork.layout.CollapserView({ | |
| container: $(this), | |
| detailsView: l | |
| }) | |
| }); | |
| l.recalculateHeights(); | |
| l.jScrollPaneApi.reinitialise(); | |
| l.el.find(".artwork_thumbs ul.asset_list li.asset").click(l.assetThumbClick); | |
| l.el.find(".playlist-item").click(l.playItem); | |
| $(".details-trigger").addClass("ready"); | |
| if (l.openAfterLoad) { | |
| l.parentView.showArtworkDetails() | |
| } | |
| }, | |
| doScroll: function (n, k) { | |
| if (n == 1) { | |
| var l = Math.ceil(this.jScrollPaneApi.getContentPositionX() / this.maxImageWidth) | |
| } else { | |
| var l = Math.floor(this.jScrollPaneApi.getContentPositionX() / this.maxImageWidth) | |
| } | |
| if (typeof (k) == "undefined") { | |
| var j = l + n; | |
| if (j < 0) { | |
| j = 0 | |
| } | |
| var b = $(".artwork_assets_wrapper li.asset").eq(j); | |
| var e = j; | |
| if (e <= 0) { | |
| e = 0 | |
| } else { | |
| if (e >= $(".artwork_assets_wrapper li.asset").length) { | |
| e -= 1 | |
| } | |
| } | |
| } else { | |
| var b = k; | |
| var e = k.index() | |
| } | |
| $(".artwork_thumbs ul.asset_list li.asset").removeClass("active"); | |
| var m = $(".artwork_thumbs ul.asset_list li.asset").eq(e); | |
| m.addClass("active"); | |
| if (b.length) { | |
| if (this.activeAssetType != b.data("asset-type")) { | |
| this.activeAssetType = b.data("asset-type"); | |
| var d = $(".artwork_object_details li.asset_description").filter("[data-asset-type=" + this.activeAssetType + "]") | |
| } | |
| if (this.activeAssetType == "map") { | |
| var a = this.mapView.map.getCenter(); | |
| this.mapView.map.setCenter(a); | |
| google.maps.event.trigger(this.mapView.map, "resize") | |
| } | |
| if (!ap.isMobile) { | |
| this.jScrollPaneApi.scrollToX(b.position().left); | |
| if (e == 0) { | |
| this.thumbjScrollPaneApi.scrollToX(0) | |
| } else { | |
| var f = m.position().left - ((770 - 60) / 2); | |
| this.thumbjScrollPaneApi.scrollToX(f) | |
| } | |
| } else { | |
| var c = $(".artwork_assets_wrapper .asset").eq(e); | |
| $(".artwork_assets_wrapper .asset").removeClass("current"); | |
| c.addClass("current") | |
| } | |
| } | |
| this.trackAssetView(b, j) | |
| }, | |
| playItem: function (b) { | |
| var a = $(b.currentTarget); | |
| this.playlist.find("a.selected").removeClass("selected"); | |
| a.addClass("selected"); | |
| this.audioPlayer.player.select(a.index()); | |
| this.audioPlayer.setupTitleScroller(); | |
| setTimeout(this.audioPlayer.scrollTitle, this.audioPlayer.scrollDelayDuration); | |
| this.audioPlayer.player.play() | |
| }, | |
| unbind: function () { | |
| $(this.el).find(".artwork_thumbs ul.asset_list li.asset").unbind("click"); | |
| $("#more-art a").unbind("click"); | |
| $(this.el).find(".close-details").unbind("click"); | |
| $(this.el).find(".playlist-item").unbind("click") | |
| }, | |
| render: function () { | |
| var b = this; | |
| b.el = $(b.el); | |
| b.template = _.template($("#artwork_detail_pane-template").html(), b.context); | |
| b.el.html(b.template); | |
| b.parentView.elements.$artworkWrapper.append(b.el); | |
| b.recommendedBarView = new ap.artwork.layout.RecommendedBarView({ | |
| container: b.el, | |
| artwork: b.context.artwork, | |
| parentView: b.parentView | |
| }); | |
| b.recommendedBarView.render(); | |
| b.el.find(".close-details").click(function () { | |
| b.parentView.showArtwork(function () { | |
| b.parentView.onSidebarResize() | |
| }) | |
| }); | |
| b.el.find(".museum_logo img").load(function () { | |
| ap.log("[Debug] Museum logo loaded"); | |
| b.recalculateHeights() | |
| }); | |
| var c = new ap.Artwork(b.context.artwork); | |
| b.artworkView = new ap.aggregation.layout.ArtworkView({ | |
| model: c | |
| }); | |
| b.artworkView.render({ | |
| maxHeight: 184, | |
| maxWidth: 184, | |
| height: 184 | |
| }, null, true); | |
| b.el.find(".artwork-placeholder").append(b.artworkView.el); | |
| ap.aggregation.layout.Global.currentRowView = ap.aggregation.layout.Config.singleArtworkView; | |
| var a = new ap.aggregation.layout.ArtworkMagnifierView(); | |
| a.render(); | |
| b.mainScrollingView = new ap.aggregation.layout.MainScrollingView({ | |
| el: $(".artwork_assets"), | |
| element: $(".artwork_assets_wrapper.scroll-pane"), | |
| useWheelScrolling: false, | |
| useDragScrolling: false, | |
| scrollBy: b.maxImageWidth, | |
| customScrollHandler: b.doScroll, | |
| floatingArrowOptions: { | |
| arrowPosition: "close", | |
| hideAfter: false | |
| }, | |
| events: { | |
| "jsp-scroll-x": b.scrolled | |
| }, | |
| jScrollPaneSettings: { | |
| useMouseWheel: false, | |
| horizontalGutter: 0 | |
| } | |
| }); | |
| b.jScrollPaneApi = b.mainScrollingView.render(); | |
| b.thumbScrollingView = new ap.aggregation.layout.MainScrollingView({ | |
| el: $(".artwork_thumbs_wrapper"), | |
| element: $(".artwork_thumbs"), | |
| useWheelScrolling: false, | |
| useDragScrolling: false, | |
| useKeyboardScrolling: false, | |
| floatingArrowOptions: { | |
| arrowPosition: "inside", | |
| hideAfter: false | |
| }, | |
| scrollBy: 292, | |
| jScrollPaneSettings: { | |
| useMouseWheel: false, | |
| horizontalGutter: 0 | |
| } | |
| }); | |
| b.thumbjScrollPaneApi = b.thumbScrollingView.render(); | |
| b.playlist = $("#playlist-" + b.context.artwork.id); | |
| $.each(b.playlist.find("a"), | |
| function (d, e) { | |
| if (d == 0) { | |
| $(this).addClass("selected") | |
| } | |
| b.playlistItems.push({ | |
| title: $(this).data("title"), | |
| mp3: $(this).data("mp3") | |
| }) | |
| }); | |
| b.audioPlayer = new ap.globals.AudioPlayerView({ | |
| el: $("#audioplayer-" + b.context.artwork.id), | |
| playlistItems: b.playlistItems | |
| }); | |
| b.mapView = new ap.artwork.layout.MapView({ | |
| container: $(b.el).find(".artwork_assets_wrapper .asset_list .asset.map .map-wrapper").eq(0), | |
| context: b.context, | |
| parentView: b | |
| }); | |
| ap.namespace("ap.maps").detailsMapsCallback = b.mapView.loadExtraScripts; | |
| b.mapView.loadMapsAPI("ap.maps.detailsMapsCallback"); | |
| b.audioPlayer.render(); | |
| if (ap.isMobile) { | |
| $(".artwork_assets_wrapper .asset").eq(0).addClass("current") | |
| } | |
| b.setup(); | |
| return b | |
| } | |
| }); | |
| ap.namespace("ap.artwork.layout").PivotView = Backbone.View.extend({ | |
| el: $("#artwork-wrapper"), | |
| events: { | |
| "click .option": "changeStripContent" | |
| }, | |
| template: null, | |
| thumbnailStrip: null, | |
| collection_id: null, | |
| artist_id: null, | |
| date: null, | |
| initialize: function () { | |
| _.bindAll(this, "render", "changeStripContent"); | |
| this.thumbnailStrip = this.options.thumbnailStrip; | |
| this.setup(); | |
| return this.render() | |
| }, | |
| setup: function () { | |
| var a = $("body"); | |
| this.collection_id = a.data("museum-id"); | |
| this.artist_id = a.data("artist-id"); | |
| this.canonical_artist_id = a.data("canonical-artist-id"); | |
| this.earliest_date = a.data("earliest-date"); | |
| this.latest_date = a.data("latest-date") | |
| }, | |
| changeStripContent: function (a) { | |
| a.preventDefault(); | |
| var d = $(a.currentTarget).data("list-type"); | |
| this.setup(); | |
| var c = { | |
| offset: 0, | |
| limit: 20 | |
| }; | |
| if (d == "date") { | |
| if (this.earliest_date) { | |
| c.latest_date__gte = this.earliest_date | |
| } | |
| if (this.latest_date) { | |
| c.latest_date__lte = this.latest_date | |
| } | |
| c.order_by = "latest_date" | |
| } else { | |
| c[d] = this[d + "_id"] | |
| } | |
| var b = ap.buildApiUrl(["artwork"], c); | |
| var e = new ap.ArtworkList(null, { | |
| url: b | |
| }); | |
| this.thumbnailStrip.el.trigger("artworkListChange", [e]); | |
| this.thumbnailStrip.processManager.reset(); | |
| this.thumbnailStrip.processManager.start(); | |
| this.thumbnailStrip.artworkList.fetch() | |
| }, | |
| render: function () { | |
| this.template = _.template($("#pivots-template").html(), { | |
| canonical_artist: this.canonical_artist_id | |
| }); | |
| this.el.append(this.template); | |
| this.el = $("#pivots"); | |
| return this | |
| } | |
| }); | |
| ap.namespace("ap.thumbnailstrip.layout").Main = Backbone.View.extend({ | |
| tagName: "div", | |
| id: "thumbnail-strip", | |
| className: "thumbnail-strip", | |
| isSlideshow: false, | |
| template: '<div class="wrapper scroll-pane"><div class="thumbnails"></div></div><a class="scroll scrollLeft"><span></span></a><a class="scroll scrollRight"><span></span></a><div class="preloader left"></div>', | |
| events: { | |
| "mouseenter .artwork": "magnifyImage", | |
| "mouseleave .artwork": "hideMagnifiedImage", | |
| artworkListChange: "artworkListChange" | |
| }, | |
| options: { | |
| imageUrl: null, | |
| urlParts: ["artwork"], | |
| qs_params: { | |
| collection: $("body").data("museum-id") | |
| } | |
| }, | |
| leftArrow: null, | |
| rightArrow: null, | |
| animating: false, | |
| artworkList: null, | |
| numberOfImages: 0, | |
| hide: true, | |
| hideTimeout: null, | |
| hideTimeoutDuration: 1000, | |
| microscope: null, | |
| parentView: null, | |
| scrollTimeout: null, | |
| scrollAmount: 200, | |
| thumbnails: null, | |
| processManager: null, | |
| preloader: null, | |
| mainScrollingView: null, | |
| jScrollPaneApi: null, | |
| hasMoved: false, | |
| eventsAttached: false, | |
| magnifyMultiplier: 4, | |
| preloadTimeout: null, | |
| preloadDelay: 500, | |
| wrapperWidth: 0, | |
| thumbsWidth: 0, | |
| settings: { | |
| artworkClickCallback: null, | |
| showPivots: true, | |
| autoHide: true, | |
| isSlideshow: false, | |
| collectionToUse: null | |
| }, | |
| initialize: function () { | |
| _.bindAll(this, "render", "addAll", "addOne", "addNewlyLoaded", "showStrip", "hideStrip", "clearHideTimeout", "setHideTimeout", "dontHide", "doHide", "attachEvents", "clickHandler", "leftArrowClick", "rightArrowClick", "scrollToElement", "calculateWidth", "displayPreloader", "hidePreloader", "scrollPanelXScroll", "magnifyImage", "hideMagnifiedImage", "artworkListChange", "calculateOffsetsForClone", "artworkClick", "highlightArtwork", "scrollToCurrentArtwork", "unload"); | |
| var a = this; | |
| if (this.options.settings) { | |
| $.extend(this.settings, this.options.settings) | |
| } | |
| a.parentView = a.options.parentView; | |
| a.container = a.options.container; | |
| if (a.options.imageUrl == null) { | |
| a.options.imageUrl = ap.buildApiUrl(a.options.urlParts, $.extend({ | |
| offset: 0, | |
| limit: 20 | |
| }, a.options.qs_params)) | |
| } | |
| if (a.settings.collectionToUse === null) { | |
| a.artworkList = new ap.ArtworkList(null, { | |
| url: a.options.imageUrl, | |
| noMagnifier: true | |
| }) | |
| } else { | |
| a.artworkList = a.settings.collectionToUse | |
| } | |
| a.artworkList.bind("reset", a.addAll); | |
| a.artworkList.bind("addNewlyLoaded", a.addNewlyLoaded); | |
| a.processManager = new ap.system.ProcessManager("paging"); | |
| $(a.processManager).bind("processStarted_paging", a.displayPreloader); | |
| $(a.processManager).bind("processEnded_paging", a.hidePreloader); | |
| $(a.processManager).bind("processTerminated_paging", a.hidePreloader); | |
| $(a.processManager).bind("processStarted_paging", a.logStarted); | |
| $(a.processManager).bind("processEnded_paging", a.logEnded); | |
| $(a.processManager).bind("processTerminated_paging", a.logTerminated); | |
| $(a.processManager).bind("processTerminated_paging", a.logTerminated); | |
| return a.render() | |
| }, | |
| logStarted: function () { | |
| ap.log("I started my job", "info") | |
| }, | |
| logEnded: function () { | |
| ap.log("I finished my job", "info") | |
| }, | |
| logTerminated: function () { | |
| ap.log("Someone finished my job", "warn") | |
| }, | |
| logReset: function () { | |
| ap.log("I'm happy now, 'cause I'm reset!", "warn") | |
| }, | |
| artworkListChange: function (a, c) { | |
| var b = this; | |
| if (this.parentView.sidebar) { | |
| this.parentView.sidebar.disableButton(".slideshow") | |
| } | |
| b.jScrollPaneApi.scrollToX(0); | |
| b.preloader.addClass("left"); | |
| b.el.find(".scroll").hide(); | |
| b.artworkList = c; | |
| b.artworkList.reset(c.models); | |
| b.artworkList.bind("addNewlyLoaded", b.addNewlyLoaded); | |
| b.artworkList.bind("reset", b.addAll); | |
| b.el.find(".artwork").remove() | |
| }, | |
| scrollPanelXScroll: function (a, b, d, c) { | |
| c = c || this.isAtRight(); | |
| if (c && !this.processManager.isBusy && !this.processManager.isTerminated) { | |
| this.processManager.start(); | |
| this.artworkList.nextPage() | |
| } | |
| if (d && !this.processManager.isBusy && !this.processManager.isTerminated) {} | |
| }, | |
| isAtRight: function () { | |
| var a = this.jScrollPaneApi.getContentPositionX(); | |
| var b = this.thumbsWidth - this.wrapperWidth - 100; | |
| if (a > b) { | |
| return true | |
| } else { | |
| return false | |
| } | |
| }, | |
| scrollPanelYScroll: function (a) { | |
| return false | |
| }, | |
| leftArrowClick: function (a) { | |
| this.dontHide(); | |
| this.mainScrollingView.scrollLeftHandler(a) | |
| }, | |
| rightArrowClick: function (a) { | |
| this.dontHide(); | |
| this.mainScrollingView.scrollRightHandler(a) | |
| }, | |
| scrollToArtwork: function (a) { | |
| var b = this.el.find(".artwork[data-artwork-id=" + a + "]"); | |
| if (b) { | |
| this.scrollToElement($(b), true) | |
| } | |
| }, | |
| scrollToCurrentArtwork: function () { | |
| var a = this.el.find(".artwork.current"); | |
| if (a) { | |
| this.scrollToElement($(a), false) | |
| } | |
| }, | |
| highlightArtwork: function (a) { | |
| var b = this.el.find(".artwork[data-artwork-id=" + a + "]"); | |
| this.el.find(".artwork.current").removeClass("current"); | |
| if (b) { | |
| $(b).addClass("current") | |
| } | |
| }, | |
| scrollToElement: function (e, b) { | |
| if (e.position()) { | |
| var a = this; | |
| var d = a.el.width(); | |
| var c = e.position().left; | |
| var f = Math.abs(a.thumbnails.position().left); | |
| var k = (c - f); | |
| var j = -(f + k) + ((d - e.outerWidth(true)) / 2); | |
| a.jScrollPaneApi.scrollToX(-j, b) | |
| } | |
| }, | |
| calculateOffsetsForClone: function (e, m) { | |
| var o = this; | |
| var n = m.height() * this.magnifyMultiplier; | |
| var c = m.width() * this.magnifyMultiplier; | |
| var a = o.parentView.sidebar; | |
| var j = 0; | |
| var l = ((c - m.attr("width")) / 2); | |
| if (a) { | |
| var b = a.el.width(); | |
| if (a.open) { | |
| j = b + a.el.position().left | |
| } else { | |
| j = b | |
| } | |
| } | |
| j = e.offset().left - j; | |
| var d = j - l; | |
| if (d < 0) { | |
| d = 0 | |
| } | |
| var k = -1 * n; | |
| var f = { | |
| origWidth: m.width(), | |
| origHeight: m.height(), | |
| origLeft: j, | |
| width: c, | |
| height: n, | |
| left: d, | |
| top: k, | |
| arrowLeft: (c / 2) | |
| }; | |
| return f | |
| }, | |
| preloadMagnifiedImage: function (b) { | |
| var c = $("#clone-" + b.data("artwork-id")); | |
| if (c.length && !c.hasClass("loading") && !c.hasClass("loaded")) { | |
| c.addClass("loading"); | |
| var a = new ap.system.imagePreload("thumbnailStripMagnifier-" + c.attr("id"), { | |
| imageLoaded: function (d) { | |
| b.data("highresimage", d.src); | |
| c.find("img").attr("src", d.src); | |
| c.removeClass("loading").addClass("loaded") | |
| } | |
| }); | |
| a.addToQueue(c.data("imageurl"), null); | |
| a.load() | |
| } | |
| }, | |
| magnifyImage: function (k) { | |
| if (!ap.isMobile) { | |
| var a = this; | |
| var c = $(k.currentTarget); | |
| var d = c.find("img"); | |
| var j = "clone-" + c.data("artwork-id"); | |
| var l = $("#" + j); | |
| var b = this.calculateOffsetsForClone(c, d); | |
| if (!l.length) { | |
| l = $('<div class="clone"><span></span></div>'); | |
| var f = d.clone(); | |
| f.css("height", ""); | |
| l.attr("id", j).attr("width", "").attr("height", "").addClass("clone").css({ | |
| left: b.origLeft + "px", | |
| top: -1 * b.origHeight + "px", | |
| width: b.origWidth + "px", | |
| height: b.origHeight + "px", | |
| opacity: "0" | |
| }); | |
| if (c.data("highresimage")) { | |
| l.data("imageurl", c.data("highresimage")); | |
| l.addClass("loaded"); | |
| f.attr("src", c.data("highresimage")) | |
| } else { | |
| l.data("imageurl", c.data("imageurl") + "=s" + Math.round(((b.width > b.height) ? b.width : b.height))) | |
| } | |
| l.data("offsets", b); | |
| l.data("preloadTimer", null); | |
| l.append(f); | |
| this.el.append(l) | |
| } else { | |
| l.stop(true, false) | |
| } | |
| clearTimeout(l.data("preloadTimer")); | |
| l.data("preloadTimer", setTimeout(function () { | |
| a.preloadMagnifiedImage(c) | |
| }, a.preloadDelay)); | |
| l.find("span").css("left", b.arrowLeft); | |
| l.animate({ | |
| top: b.top + "px", | |
| left: b.left + "px", | |
| height: b.height + "px", | |
| width: b.width + "px", | |
| opacity: 1 | |
| }) | |
| } | |
| }, | |
| hideMagnifiedImage: function (d) { | |
| var b = $(d.currentTarget); | |
| var c = "clone-" + b.data("artwork-id"); | |
| var f = $("#" + c); | |
| if (f.length) { | |
| clearTimeout(f.data("preloadTimer")); | |
| var a = f.data("offsets"); | |
| f.stop().animate({ | |
| top: -1 * a.origHeight + "px", | |
| left: a.origLeft + "px", | |
| height: a.origHeight + "px", | |
| width: a.origWidth + "px", | |
| opacity: 0 | |
| }, | |
| function () { | |
| if (!f.is(":animated") && !b.is(":hover")) { | |
| f.remove() | |
| } | |
| }) | |
| } | |
| }, | |
| attachEvents: function () { | |
| if (!this.eventsAttached) { | |
| this.eventsAttached = true; | |
| this.leftArrow.click(this.leftArrowClick); | |
| this.rightArrow.click(this.rightArrowClick); | |
| this.el.mouseenter(this.dontHide); | |
| this.el.mouseenter(this.showStrip); | |
| this.el.mouseleave(this.doHide) | |
| } | |
| }, | |
| detachEvents: function () { | |
| this.eventsAttached = false; | |
| this.leftArrow.unbind("click"); | |
| this.rightArrow.unbind("click"); | |
| this.el.unbind("mouseenter", this.showStrip); | |
| this.el.unbind("mouseenter", this.dontHide); | |
| this.el.unbind("mouseleave", this.doHide) | |
| }, | |
| dontHide: function () { | |
| this.hide = false; | |
| this.clearHideTimeout() | |
| }, | |
| doHide: function () { | |
| if (!this.processManager.isBusy) { | |
| this.hide = true; | |
| this.setHideTimeout() | |
| } | |
| }, | |
| clearHideTimeout: function () { | |
| var a = this; | |
| clearTimeout(a.hideTimeout) | |
| }, | |
| setHideTimeout: function () { | |
| var a = this; | |
| if (a.hide && a.settings.autoHide) { | |
| a.hideTimeout = setTimeout(a.hideStrip, a.hideTimeoutDuration) | |
| } | |
| }, | |
| showStrip: function () { | |
| var a = this; | |
| if (!a.animating) { | |
| a.animating = true; | |
| a.clearHideTimeout(); | |
| a.el.show(); | |
| $(a.el).children().not(".clone").stop().animate({ | |
| top: "0" | |
| }, 200, | |
| function () { | |
| a.animating = false; | |
| if (a.hide) { | |
| a.doHide() | |
| } | |
| }) | |
| } | |
| }, | |
| hideStrip: function () { | |
| var a = this; | |
| if (!a.animating && a.hide && !ap.isMobile && !a.processManager.isBusy) { | |
| a.animating = true; | |
| a.clearHideTimeout(); | |
| $(a.el).children().not(".clone").stop().animate({ | |
| top: a.el.height() + "px" | |
| }, | |
| function () { | |
| a.animating = false | |
| }) | |
| } | |
| }, | |
| addNewlyLoaded: function (a) { | |
| var b = this; | |
| $.each(b.artworkList.newlyAdded, | |
| function (d, c) { | |
| b.addOne(c, true) | |
| }); | |
| b.checkInfiniteLoad() | |
| }, | |
| displayPreloader: function () { | |
| var a = this; | |
| a.dontHide(); | |
| a.showStrip(); | |
| a.detachEvents(); | |
| a.thumbnails.addClass("loading"); | |
| a.preloader.show() | |
| }, | |
| hidePreloader: function () { | |
| var a = this; | |
| a.thumbnails.removeClass("loading"); | |
| a.preloader.removeClass("left").hide(); | |
| a.doHide(); | |
| a.attachEvents() | |
| }, | |
| checkInfiniteLoad: function () { | |
| var b = this; | |
| b.el.find(".scroll").show(); | |
| b.showStrip(); | |
| var a = b.calculateWidth(); | |
| if (b.wrapper.width() > a) { | |
| var c = b.artworkList.nextPage(); | |
| if (c === (false || null)) { | |
| b.attachEvents(); | |
| b.processManager.end() | |
| } | |
| } else { | |
| b.attachEvents(); | |
| b.processManager.end() | |
| } | |
| b.jScrollPaneApi.reinitialise(); | |
| setTimeout(function () { | |
| b.jScrollPaneApi.reinitialise() | |
| }, 500) | |
| }, | |
| addAll: function () { | |
| var a = this; | |
| a.artworkList.each(a.addOne); | |
| a.preloader.removeClass("left"); | |
| a.checkInfiniteLoad(); | |
| if (this.parentView.sidebar) { | |
| this.parentView.sidebar.enableButton(".slideshow") | |
| } | |
| }, | |
| addOne: function (d, b) { | |
| var e = this; | |
| var a = (ap.isMobile) ? 40 : 40; | |
| if (d.artworkModel) { | |
| var c = new ap.aggregation.layout.BookmarkArtworkView({ | |
| data_vieworder: ++e.numberOfImages, | |
| model: d, | |
| isAppendToExisting: b, | |
| clickCallback: e.artworkClick, | |
| imageSize: a, | |
| noMagnifier: true | |
| }) | |
| } else { | |
| var c = new ap.aggregation.layout.ArtworkView({ | |
| data_vieworder: ++e.numberOfImages, | |
| model: d, | |
| isAppendToExisting: b, | |
| clickCallback: e.artworkClick, | |
| imageSize: a, | |
| noMagnifier: true | |
| }) | |
| } | |
| c.render({ | |
| height: a | |
| }); | |
| e.thumbnails.append(c.el) | |
| }, | |
| calculateWidth: function () { | |
| var b = this.thumbnails.find("img"); | |
| var a = 0; | |
| $.each(b, | |
| function (d, c) { | |
| a += $(c).outerWidth(true) | |
| }); | |
| this.thumbnails.css("width", a + 15); | |
| this.thumbsWidth = a + 15; | |
| return a | |
| }, | |
| artworkClick: function (b, a) { | |
| $(this).trigger("artworkClicked", a); | |
| if (!this.isSlideshow) { | |
| this.clickHandler(b, a) | |
| } | |
| }, | |
| clickHandler: function (b, a) { | |
| var c = this; | |
| $(".details-trigger").removeClass("ready"); | |
| $("body").data("artwork-id", a.model.attributes.id); | |
| $("body").data("museum-id", a.model.attributes.collection_id); | |
| $("body").data("artist-id", a.model.attributes.artist_id); | |
| this.thumbnails.find(".artwork.active").removeClass("active"); | |
| $(b.currentTarget).addClass("active"); | |
| c.scrollToElement($(b.currentTarget)); | |
| if (c.parentView.router) { | |
| c.parentView.router.navigate($(b.currentTarget).attr("href").replace("/", ""), true) | |
| } else { | |
| document.location.href = $(b.currentTarget).attr("href") | |
| } | |
| return false | |
| }, | |
| resize: function (a) { | |
| this.wrapper.css({ | |
| width: a | |
| }); | |
| this.jScrollPaneApi.reinitialise(); | |
| this.checkInfiniteLoad(); | |
| self.wrapperWidth = a; | |
| self.thumbsWidth = self.thumbnails.width() | |
| }, | |
| render: function () { | |
| var a = this; | |
| $(a.el).html(_.template(a.template)); | |
| a.el = $(a.el); | |
| a.options.container.prepend(a.el); | |
| a.preloader = a.el.find(".preloader").eq(0); | |
| a.thumbnails = a.el.find(".thumbnails").eq(0); | |
| a.leftArrow = a.el.find(".scrollLeft").eq(0); | |
| a.rightArrow = a.el.find(".scrollRight").eq(0); | |
| a.wrapper = a.el.find(".wrapper").eq(0); | |
| a.microscope = a.options.microscope; | |
| a.mainScrollingView = new ap.aggregation.layout.MainScrollingView({ | |
| element: a.wrapper, | |
| useWheelScrolling: false, | |
| useDragScrolling: false, | |
| useFloatingArrows: false, | |
| useKeyboardScrolling: false, | |
| jScrollPaneSettings: { | |
| useMouseWheel: false | |
| } | |
| }); | |
| a.jScrollPaneApi = a.mainScrollingView.render(); | |
| if (this.settings.showPivots && !ap.isMobile) { | |
| a.pivotView = new ap.artwork.layout.PivotView({ | |
| thumbnailStrip: a | |
| }) | |
| } else { | |
| if (this.settings.showPivots && ap.isMobile) { | |
| a.pivotView = new ap.mobile.artwork.PivotView({ | |
| thumbnailStrip: a | |
| }) | |
| } | |
| } | |
| if (a.settings.collectionToUse === null) { | |
| a.processManager.start(); | |
| a.artworkList.fetch() | |
| } else { | |
| a.addAll() | |
| } | |
| if (ap.isMobile) { | |
| a.wrapper.on("scroll", a.scrollPanelXScroll) | |
| } else { | |
| a.wrapper.on("jsp-scroll-x", a.scrollPanelXScroll); | |
| $(this.el).on("mousewheel", a.scrollPanelYScroll) | |
| } | |
| a.wrapperWidth = a.wrapper.width(); | |
| a.thumbsWidth = a.thumbnails.width(); | |
| return a | |
| }, | |
| unload: function () { | |
| var a = this; | |
| if (a.artworkList) { | |
| a.artworkList.unbind(); | |
| a.artworkList = null | |
| } | |
| $(a.el).remove() | |
| } | |
| }); | |
| ap.slideshow.layout.ThumbnailStripView = ap.thumbnailstrip.layout.Main.extend({ | |
| id: "slideshow-thumbnail-strip", | |
| isSlideshow: true, | |
| initialize: function () { | |
| ap.thumbnailstrip.layout.Main.prototype.initialize.call(this, [this.options]) | |
| } | |
| }); | |
| ap.namespace("ap.artwork.layout").Main = ap.globals.MainBaseView.extend({ | |
| el: $("body"), | |
| options: { | |
| visibleButtons: [".plusone", ".discover", ".share", ".add-to-collection", ".slideshow", ".streetview"] | |
| }, | |
| cssHooks: { | |
| DETAILS_CLASS: "showing_details", | |
| SECONDARY_NAV_EXPANDED: "secondary_expanded" | |
| }, | |
| config: { | |
| overviewBarAnimSpeed: 250, | |
| viewTransitionSpeed: 1000, | |
| titleCharTruncCount: 8, | |
| artistCharTruncCount: 6 | |
| }, | |
| events: function () { | |
| var a = { | |
| "click .details-trigger": "setupDetails" | |
| }; | |
| if (!ap.isMobile) { | |
| a["mousemove .microscope"] = "setPivotHideTimeout"; | |
| a["mouseenter #pivots"] = "clearPivotHideTimeout" | |
| } | |
| return a | |
| }, | |
| elements: { | |
| $artwork: $("div.artwork"), | |
| $artworkDetails: $(".artwork-details"), | |
| $artworkWrapper: $("#artwork-wrapper"), | |
| $header: $("#header"), | |
| $footer: $("#footer"), | |
| $overviewBarProp: $("#secondary-prop"), | |
| $secondaryNav: $("nav.secondary"), | |
| $thumbSlider: $(".artwork_thumbs .track .slider"), | |
| $artworkAssets: $(".artwork_assets_wrapper li.asset"), | |
| $artworkDescriptions: $(".artwork_object_details li.asset_description"), | |
| $detailsTrigger: $("a.details-trigger"), | |
| $pageContent: $(".content-wrapper") | |
| }, | |
| overviewBarData: { | |
| $overviewBar: $("nav.secondary"), | |
| $artwork_location: $(".artwork-info-container ul.artwork-info-data-list"), | |
| $artwork_location_height: "", | |
| $artwork_title: $(".artwork-info-container .artwork-title"), | |
| $artwork_title_marginTop: "", | |
| $artwork_info_container: $(".artwork-info-container") | |
| }, | |
| isInitalLoad: true, | |
| jScrollPaneApi: null, | |
| secondaryjScrollPaneApi: null, | |
| thumbnailStrip: null, | |
| microscope: null, | |
| artworkDetailView: null, | |
| pivotHideTimeout: null, | |
| pivotHideDelay: 1000, | |
| slideShowData: { | |
| collection: null, | |
| startModel: null | |
| }, | |
| initialize: function (b) { | |
| var a = this; | |
| ap.globals.MainBaseView.prototype.initialize.call(a, [b]); | |
| _.bindAll(this, "onBeforeSidebarResize", "onSidebarResize", "getArtworkResourceUri", "updateArtwork", "resizeMicroscopeViewer", "showArtworkDetails", "showArtwork", "setupDetails", "setPivotHideTimeout", "togglePivots", "clearPivotHideTimeout"); | |
| a.microscope = new ap.microscope.layout.Main({ | |
| container: a.elements.$artworkWrapper, | |
| imageUrl: a.elements.$artworkWrapper.data("image-url"), | |
| aspectRatio: a.elements.$artworkWrapper.data("aspect-ratio") | |
| }); | |
| a.resizeMicroscopeViewer(false); | |
| if (!a.elements.$artworkWrapper.hasClass("hide-thumbnails")) { | |
| a.thumbnailStrip = new ap.thumbnailstrip.layout.Main({ | |
| container: a.elements.$artworkWrapper, | |
| microscope: a.microscope.microscope, | |
| parentView: a | |
| }) | |
| } | |
| a.slideShowData.collection = a.thumbnailStrip.artworkList; | |
| a.setupOverviewBar(); | |
| a.render(); | |
| a.setupDetails() | |
| }, | |
| clearPivotHideTimeout: function () { | |
| clearTimeout(this.pivotHideTimeout) | |
| }, | |
| setPivotHideTimeout: function () { | |
| if (this.thumbnailStrip) { | |
| this.thumbnailStrip.pivotView.el.css("opacity", 1) | |
| } | |
| this.clearPivotHideTimeout(); | |
| this.pivotHideTimeout = setTimeout(this.togglePivots, this.pivotHideDelay) | |
| }, | |
| togglePivots: function () { | |
| this.thumbnailStrip.pivotView.el.css("opacity", 0) | |
| }, | |
| setupAnalyticsTracking: function () { | |
| var b = this; | |
| var a = $("body").data("museum-url"); | |
| $("li.asset.details").on("click", 'a[href^="http"]', | |
| function (d) { | |
| var c = encodeURIComponent(d.attr("href")); | |
| ap.trackMuseumLinkClicked({ | |
| collection_slug: $("body").data("museum-url"), | |
| external_url: c | |
| }, ap.getMuseumAnalyticsId()) | |
| }) | |
| }, | |
| setupOverviewBar: function () { | |
| var b = this; | |
| var c = b.cssHooks; | |
| var d = b.elements; | |
| var a = b.overviewBarData; | |
| a.$artwork_location_height = a.$artwork_location.height(); | |
| a.$artwork_location.show().css("height", "1px"); | |
| b.overviewBarData.$artwork_info_container.bind("mouseenter", | |
| function () { | |
| $(this).addClass(c.SECONDARY_NAV_EXPANDED); | |
| a.$artwork_location.stop().animate({ | |
| height: a.$artwork_location_height | |
| }, { | |
| duration: b.$overviewBarAnimSpeed, | |
| queue: false | |
| }); | |
| a.$artwork_info_container.stop().animate({ | |
| top: -1 * a.$artwork_location_height / 2 | |
| }, { | |
| duration: b.$overviewBarAnimSpeed, | |
| queue: false | |
| }) | |
| }); | |
| b.overviewBarData.$artwork_info_container.bind("mouseleave", | |
| function () { | |
| if (!b.el.hasClass(c.DETAILS_CLASS)) { | |
| $(this).removeClass(c.SECONDARY_NAV_EXPANDED); | |
| a.$artwork_location.animate({ | |
| height: 1 | |
| }, { | |
| duration: b.$overviewBarAnimSpeed, | |
| queue: false | |
| }); | |
| a.$artwork_info_container.stop().animate({ | |
| top: 0 | |
| }, { | |
| duration: b.$overviewBarAnimSpeed, | |
| queue: false | |
| }) | |
| } | |
| }) | |
| }, | |
| setupDetails: function () { | |
| var a = this; | |
| if (a.el.hasClass(a.cssHooks.DETAILS_CLASS)) { | |
| a.el.removeClass(a.cssHooks.DETAILS_CLASS); | |
| a.resizeMicroscopeViewer(true); | |
| a.showArtwork(function () { | |
| a.onSidebarResize() | |
| }) | |
| } else { | |
| a.onBeforeSidebarResize(); | |
| a.showArtworkDetails() | |
| } | |
| }, | |
| resizeMicroscopeViewer: function (b, j) { | |
| var a = this; | |
| if (a.el.hasClass(a.cssHooks.DETAILS_CLASS)) { | |
| if (b) { | |
| a.elements.$pageContent.animate({ | |
| height: $(".artwork-details").outerHeight() | |
| }, | |
| function () { | |
| if (j) { | |
| j() | |
| } | |
| }) | |
| } else { | |
| a.elements.$pageContent.height($(".artwork-details").outerHeight()) | |
| } | |
| } else { | |
| var f = parseInt($(window).height(), 10); | |
| var c = f - (a.elements.$secondaryNav.height() + (a.elements.$header.height() + a.elements.$footer.outerHeight())); | |
| if (b === undefined || b === false) { | |
| a.microscope.el.height(c); | |
| a.elements.$pageContent.height(c) | |
| } else { | |
| a.microscope.el.animate({ | |
| height: c | |
| }); | |
| a.elements.$pageContent.animate({ | |
| height: c | |
| }, | |
| function () { | |
| if (j) { | |
| j() | |
| } | |
| }) | |
| } | |
| } | |
| if (a.sidebar) { | |
| var d = $(window).width(); | |
| var e = a.sidebar.closedWidth + a.sidebar.el.position().left; | |
| $(".content-with-sidebar").css({ | |
| marginLeft: e, | |
| width: (d - e) + "px" | |
| }) | |
| } | |
| if (a.jScrollPaneApi !== null) { | |
| a.jScrollPaneApi.reinitialise() | |
| } | |
| }, | |
| showArtwork: function (c) { | |
| var a = this; | |
| a.elements.$detailsTrigger.removeClass("active").attr("href", "#").text(TRANSLATIONS.details); | |
| a.el.removeClass(a.cssHooks.DETAILS_CLASS); | |
| a.elements.$artworkWrapper.animate({ | |
| top: "0" | |
| }); | |
| var b = a.microscope.el.outerHeight(); | |
| a.elements.$pageContent.animate({ | |
| height: b | |
| }, c); | |
| a.sidebar.el.removeClass("grey"); | |
| a.overviewBarData.$artwork_info_container.trigger("mouseleave"); | |
| if (a.recommendedBarView) { | |
| a.recommendedBarView.el.hide() | |
| } | |
| }, | |
| showArtworkDetails: function (d) { | |
| var b = this; | |
| if (b.streetview && b.streetview.sidebar.open) { | |
| b.streetview.sidebar.killMuseumView(); | |
| b.streetview.sidebar.closeSidebar() | |
| } | |
| if (b.artworkDetailView) { | |
| b.elements.$detailsTrigger.addClass("active").attr("href", "#details").text(TRANSLATIONS.close_details); | |
| b.el.addClass(b.cssHooks.DETAILS_CLASS); | |
| b.overviewBarData.$artwork_info_container.trigger("mouseenter"); | |
| var c = b.microscope.el.height(); | |
| b.elements.$artworkWrapper.animate({ | |
| top: "-" + c + "px" | |
| }); | |
| var a = $(".artwork-details").outerHeight(); | |
| if (a > c) { | |
| b.elements.$pageContent.animate({ | |
| height: a | |
| }) | |
| } | |
| b.sidebar.el.addClass("grey"); | |
| if (typeof d === "function") { | |
| d() | |
| } | |
| ap.trackDetailsPane({}, ap.getMuseumAnalyticsId()) | |
| } | |
| if (b.recommendedBarView) { | |
| b.recommendedBarView.el.show() | |
| } | |
| }, | |
| onBeforeSidebarResize: function () { | |
| var a = this; | |
| a.thumbnailStrip.hide = false; | |
| a.thumbnailStrip.clearHideTimeout(); | |
| a.thumbnailStrip.detachEvents(); | |
| a.thumbnailStrip.doHide() | |
| }, | |
| onSidebarResize: function () { | |
| var a = this; | |
| if (!$("body").hasClass(a.cssHooks.DETAILS_CLASS)) { | |
| a.thumbnailStrip.el.show(); | |
| a.thumbnailStrip.hide = true; | |
| a.thumbnailStrip.setHideTimeout(); | |
| a.thumbnailStrip.attachEvents(); | |
| a.thumbnailStrip.jScrollPaneApi.reinitialise() | |
| } | |
| }, | |
| getArtworkResourceUri: function (e, f, a, k) { | |
| var l = this; | |
| l.elements.$detailsTrigger.removeClass("ready"); | |
| var d = l.el.find("a.artwork[data-artwork-id=" + a + "]"); | |
| var c; | |
| var j = false; | |
| if (d.length) { | |
| j = true; | |
| var b = $(d).data("model"); | |
| $(".add-to-collection-content .artwork-panel img").attr("src", b.attributes.aggregation_image_url + "=s100"); | |
| l.updateArtwork(b.attributes, j, k); | |
| l.attachArrowEvents() | |
| } else { | |
| if (CURRENT_ARTWORK) { | |
| $(".add-to-collection-content .artwork-panel img").attr("src", CURRENT_ARTWORK.attributes.aggregation_image_url + "=s100"); | |
| l.updateArtwork(CURRENT_ARTWORK.attributes, j, k); | |
| l.attachArrowEvents(); | |
| CURRENT_ARTWORK = null | |
| } else { | |
| c = ap.buildApiUrl(["artwork", a]); | |
| $.get(c, | |
| function (m) { | |
| l.updateArtwork(m, j, k); | |
| l.attachArrowEvents() | |
| }) | |
| } | |
| } | |
| }, | |
| attachArrowEvents: function () { | |
| var b = $("a.artwork.active"); | |
| var a = $(b).next(); | |
| if (a.length) { | |
| $(".artwork-next").attr("href", a.attr("href")); | |
| $(".artwork-next").unbind("click").click(function () { | |
| a.click(); | |
| return false | |
| }) | |
| } | |
| var c = $(b).prev(); | |
| if (c.length) { | |
| $(".artwork-previous").attr("href", c.attr("href")); | |
| $(".artwork-previous").unbind("click").click(function () { | |
| c.click(); | |
| return false | |
| }) | |
| } | |
| }, | |
| updateArtwork: function (d, k, p) { | |
| var q = this, | |
| j, m; | |
| if (!q.isInitalLoad) { | |
| ap.log("Not initial load - tracking the new pageview", "info"); | |
| ap.setMuseumAnalyticsId(d.collection_analytics_id); | |
| ap.trackDynamicPageView(ap.getMuseumAnalyticsId()) | |
| } | |
| if (q.artworkDetailView) { | |
| q.artworkDetailView.unbind(); | |
| q.artworkDetailView.remove() | |
| } | |
| q.slideShowData.startModel = d; | |
| if (k) { | |
| q.microscope.loadImage(d.cached_artwork_primary_image_full_url, d.primary_image_aspect_ratio) | |
| } | |
| q.el.data("artwork-id", d.id).attr("data-artwork-id", d.id); | |
| q.el.data("artwork-slug", d.slug).attr("artwork-slug", d.slug); | |
| q.el.data("museum-url", d.collection_detail_url).attr("museum-url", d.collection_detail_url); | |
| q.el.data("artist-id", d.artist_id).attr("data-artist-id", d.artist_id); | |
| q.el.data("canonical-artist-id", d.canonical_artist_id).attr("data-canonical-artist-id", d.canonical_artist_id); | |
| q.el.data("earliest-date", d.pivot_earliest_decade).attr("data-earliest-date", d.pivot_earliest_decade); | |
| q.el.data("latest-date", d.pivot_latest_decade).attr("data-latest-date", d.pivot_latest_decade); | |
| $("#artwork-wrapper").data("artwork-id", d.id); | |
| q.onSidebarResize(); | |
| var n = ($(".artwork-info-wrapper").hasClass("showing-hidden") && ap.isMobile) ? false : true; | |
| if (n) { | |
| var l = ap.truncatewords(d.title, q.config.titleCharTruncCount); | |
| var c = d.title; | |
| var f = ap.truncatewords(d.artist_display_name, q.config.artistCharTruncCount); | |
| var o = d.artist_display_name | |
| } else { | |
| var l = d.title; | |
| var c = ap.truncatewords(d.title, q.config.titleCharTruncCount); | |
| var f = d.artist_display_name; | |
| var o = ap.truncatewords(d.artist_display_name, q.config.artistCharTruncCount) | |
| } | |
| ap.updateTitle(ap.truncatewords(l, q.config.titleCharTruncCount)); | |
| $(".artwork-name").text(l); | |
| $(".artwork-name").data("alt", c); | |
| j = d.canonical_artist_detail_url; | |
| m = $("<a />", { | |
| text: f | |
| }).attr("href", j); | |
| $(".artwork-artist").html(m); | |
| $(".artwork-artist").data("alt", o); | |
| var b; | |
| if (d.pretty_display_date) { | |
| b = d.pretty_display_date | |
| } else { | |
| b = "" | |
| } | |
| $(".artwork-date_range").text(b); | |
| $(".museum-link a").attr("href", d.collection_detail_url).text(d.collection_display_name); | |
| if (d.level) { | |
| $(".artwork-level a").attr("href", d.level_detail_url).text(d.level_display_name).show() | |
| } else { | |
| $(".artwork-level a").hide() | |
| } | |
| if (d.level && d.room) { | |
| $(".artwork-room a").attr("href", d.room_detail_url).text(d.room_display_name).show() | |
| } else { | |
| $(".artwork-room a").hide() | |
| } | |
| var e = ap.buildApiUrl(["asset"], { | |
| artwork: d.id, | |
| limit: 50 | |
| }); | |
| var a = { | |
| artwork: d, | |
| assets: [], | |
| artist: {} | |
| }; | |
| if (CURRENT_ARTWORK_ASSETS && CURRENT_ARTWORK_ARTIST) { | |
| a.assets = CURRENT_ARTWORK_ASSETS.objects; | |
| a.artist = CURRENT_ARTWORK_ARTIST; | |
| CURRENT_ARTWORK_ARTIST = null; | |
| CURRENT_ARTWORK_ASSETS = null; | |
| q.artworkDetailView = new ap.artwork.layout.DetailsPaneView({ | |
| context: a, | |
| parentView: q, | |
| openAfterLoad: p | |
| }) | |
| } else { | |
| $.get(e, | |
| function (r) { | |
| a.assets = r.objects; | |
| $.get(a.artwork.artist + "?format=json", | |
| function (s) { | |
| a.artist = s; | |
| q.artworkDetailView = new ap.artwork.layout.DetailsPaneView({ | |
| context: a, | |
| parentView: q, | |
| openAfterLoad: p | |
| }) | |
| }) | |
| }) | |
| } | |
| this.isInitalLoad = false; | |
| $(".content-with-sidebar").trigger("content-change") | |
| }, | |
| render: function () { | |
| var b = this; | |
| ap.globals.MainBaseView.prototype.render.call(b, [b.options]); | |
| var a = $(window).width() - b.sidebar.el.width(); | |
| b.elements.$artwork.width(a); | |
| $(document).on("beforeResize", b.sidebar.el.selector, b.onBeforeSidebarResize); | |
| $(document).on("resize", b.sidebar.el.selector, b.onSidebarResize); | |
| $(window).smartresize(function () { | |
| b.resizeMicroscopeViewer(false) | |
| }) | |
| } | |
| }); | |
| var ArtworkRouter = Backbone.Router.extend({ | |
| routes: { | |
| "collection/:museumslug/artwork/:artworkslug/:artworkid/museumview/*encodedLocation": "showMuseumView", | |
| ":countryCode/collection/:museumslug/artwork/:artworkslug/:artworkid/museumview/*encodedLocation": "showMuseumViewI18N", | |
| "collection/:museumslug/artwork/:artworkslug/:artworkid/": "getArtworkResourceUri", | |
| "*lang/collection/:museumslug/artwork/:artworkslug/:artworkid/": "getArtworkResourceUri" | |
| }, | |
| showMuseumViewI18N: function (c, b, d, e, a) { | |
| this.showMuseumView(b, d, e, a) | |
| }, | |
| showMuseumView: function (b, c, d, a) { | |
| if (window.location.hash == "#ref='annotation'") { | |
| ap.trackAnnotationClicked({ | |
| collection_slug: $("body").data("museum-url"), | |
| aw_slug: $("body").data("artwork-slug"), | |
| aw_id: $("body").data("artwork-id") | |
| }, ap.getMuseumAnalyticsId()) | |
| } else { | |
| ap.trackOpenMuseumView($("body").data("museum-url"), ap.getMuseumAnalyticsId()) | |
| } | |
| window.app.sidebar.killMuseumView(); | |
| window.app.sidebar.showMuseumView(null, a) | |
| }, | |
| hideMuseumView: function () { | |
| window.app.sidebar.hideMuseumView() | |
| }, | |
| getArtworkResourceUri: function (f, d, c, b) { | |
| window.app.sidebar.hideMuseumView(); | |
| var a, e, k, j = false; | |
| if (typeof b === "undefined") { | |
| a = f; | |
| e = d; | |
| k = c | |
| } else { | |
| a = d; | |
| e = c; | |
| k = b | |
| } | |
| if (window.location.hash == "#details") { | |
| j = true | |
| } | |
| window.app.getArtworkResourceUri(a, e, k, j) | |
| } | |
| }); | |
| $(document).ready(function () { | |
| if ($("#artwork").length && !ap.isMobile) { | |
| window.app = new ap.artwork.layout.Main(); | |
| window.app.router = new ArtworkRouter(); | |
| Backbone.history.start({ | |
| pushState: true | |
| }) | |
| } | |
| }); | |
| ap.namespace("ap.artist.layout").ColumnView = Backbone.View.extend({ | |
| tagName: "div", | |
| className: "column", | |
| itemCount: 0, | |
| contentString: "", | |
| initialize: function () { | |
| _.bindAll(this, "render"); | |
| return this.render() | |
| }, | |
| render: function () { | |
| return this | |
| } | |
| }); | |
| ap.namespace("ap.artist.layout").LetterView = Backbone.View.extend({ | |
| template: '<div class="item letter"><span></span><%= letter %></div>', | |
| initialize: function () { | |
| var a = this; | |
| _.bindAll(this, "render"); | |
| a.el = _.template(a.template, { | |
| letter: a.options.letter.toUpperCase() | |
| }); | |
| return a.render() | |
| }, | |
| render: function () { | |
| return this | |
| } | |
| }); | |
| ap.namespace("ap.artist.layout").ArtistView = Backbone.View.extend({ | |
| template: null, | |
| isLetter: false, | |
| initialize: function () { | |
| var a = this; | |
| this.el = _.template($("#artist-template").html(), { | |
| artist: a.model.attributes | |
| }); | |
| return this.render() | |
| }, | |
| render: function () { | |
| return this | |
| } | |
| }); | |
| ap.namespace("ap.artist.layout").MainView = ap.globals.MainNameListView.extend({ | |
| el: $(".content-with-sidebar"), | |
| container: $(".content-with-sidebar .artists"), | |
| defaultQueryStringParams: { | |
| offset: 0, | |
| limit: 30 | |
| }, | |
| events: { | |
| "click .item.letter.grey": "applyFilter" | |
| }, | |
| currentLetter: null, | |
| currentColumn: null, | |
| maxItemsInColumn: 0, | |
| aggregationConfig: { | |
| aggregationType: "ArtistList", | |
| collectionOptions: {}, | |
| modelViewType: "ArtistView", | |
| useDynamicRows: false, | |
| viewType: null, | |
| urlParts: ["canonical_artist"], | |
| isSearch: true | |
| }, | |
| options: { | |
| disabledButtons: [".add-to-collection", ".slideshow"], | |
| visibleButtons: [".plusone", ".discover", ".share", ".add-to-collection", ".slideshow"], | |
| }, | |
| attributeToSlice: "display_name", | |
| modelView: ap.artist.layout.ArtistView, | |
| columns: [], | |
| columnsCount: 1, | |
| itemHeight: 54, | |
| isEmptyCall: false, | |
| showingInitialItems: true, | |
| initialize: function () { | |
| var a = this; | |
| _.bindAll(this, "render", "addOne", "createNewColumn", "filterCurrentCollection", "applyFilter", "reorganiseColumns"); | |
| a.initialItems = a.container.children().clone(); | |
| $.extend(a.options, { | |
| urlParts: a.aggregationConfig.urlParts, | |
| aggregationConfig: a.aggregationConfig, | |
| disabledButtons: [".add-to-collection", ".slideshow"], | |
| visibleButtons: [".plusone", ".discover", ".share", ".add-to-collection", ".slideshow"] | |
| }); | |
| a.bind("filterCurrentCollection", a.checkForFilterReset); | |
| ap.globals.MainNameListView.prototype.initialize.apply(a, [a.options]); | |
| $(window).smartresize(this.reorganiseColumns) | |
| }, | |
| applyFilter: function (a) { | |
| a.preventDefault(); | |
| var c = $(a.currentTarget); | |
| var b = c.data("letter").toLowerCase(); | |
| this.showingInitialItems = false; | |
| this.isEmptyCall = false; | |
| this.topFiltersView.setActiveFilter("display_name_firstletter", b); | |
| this.filterCurrentCollection("display_name_firstletter", b); | |
| return false | |
| }, | |
| checkForFilterReset: function (b, c, a) { | |
| if (arguments.length == 0) { | |
| this.isEmptyCall = true | |
| } | |
| }, | |
| clearCollectionElements: function (a) { | |
| if (a !== true) { | |
| this.currentColumn = null | |
| } | |
| this.columnsCount = 1; | |
| this.currentLetter = null; | |
| this.container.empty(); | |
| this.container.width(0) | |
| }, | |
| filterCurrentCollection: function () { | |
| this.jScrollPaneApi.scrollToX(0, false); | |
| if (this.currentXHR) { | |
| this.currentXHR.abort() | |
| } | |
| if (this.isEmptyCall) { | |
| this.isEmptyCall = false; | |
| this.showingInitialItems = true; | |
| this.showInitialItems() | |
| } else { | |
| this.itemHeight = 44; | |
| ap.globals.MainNameListView.prototype.filterCurrentCollection.apply(this, arguments) | |
| } | |
| }, | |
| showInitialItems: function () { | |
| this.itemHeight = 54; | |
| this.clearCollectionElements(); | |
| this.container.append(this.initialItems.clone()); | |
| this.reorganiseColumns(false) | |
| }, | |
| calculateMaxHeight: function () { | |
| var a = this; | |
| var b = $(a.el).height() - 60; | |
| var c = Math.floor(b / a.itemHeight); | |
| a.maxItemsInColumn = c | |
| }, | |
| addNewlyLoaded: function () { | |
| if (!this.showingInitialItems) { | |
| ap.globals.MainNameListView.prototype.addNewlyLoaded.apply(this) | |
| } | |
| }, | |
| addOne: function (c) { | |
| var b = this; | |
| var a = c.attributes[b.attributeToSlice].slice(0, 1).toLowerCase(); | |
| if (b.currentLetter != a) { | |
| b.currentLetter = a; | |
| var d = new ap.artist.layout.LetterView({ | |
| letter: b.currentLetter | |
| }); | |
| b.addToColumn(d.el) | |
| } | |
| var e = new b.modelView({ | |
| model: c | |
| }); | |
| b.addToColumn(e.el) | |
| }, | |
| needToLoadMore: function () { | |
| return this.container.width() < $(this.el).width() + 320 | |
| }, | |
| render: function () { | |
| ap.globals.MainBaseView.prototype.render.apply(this, [this.options]); | |
| this.preloaderview = new ap.aggregation.layout.PreloaderView(); | |
| this.preloaderview.render(); | |
| this.preloaderview.displayPreloader(true); | |
| if (this.topFiltersView) { | |
| this.topFiltersView.render() | |
| } | |
| this.mainScrollingView = new ap.aggregation.layout.MainScrollingView({ | |
| el: this.el | |
| }); | |
| this.jScrollPaneApi = this.mainScrollingView.render(); | |
| this.infiniteScrollingView = new ap.aggregation.layout.InfiniteScrollingView({ | |
| el: this.el, | |
| jScrollPaneApi: this.jScrollPaneApi, | |
| collection: this.currentCollection, | |
| selector: ".column:last-child", | |
| scrollTriggerOffset: 30 | |
| }); | |
| this.infiniteScrollingView.render(); | |
| $(this.sidebar.el.selector).on("resize", this.sidebar.el.selector, this.onSidebarResize); | |
| this.reorganiseColumns() | |
| } | |
| }); | |
| $(document).ready(function () { | |
| if ($("#artists").length) { | |
| window.app = new ap.artist.layout.MainView(); | |
| window.app.render() | |
| } | |
| }); | |
| ap.namespace("ap.museumlist.layout").MuseumView = Backbone.View.extend({ | |
| tagName: "div", | |
| className: "item museum", | |
| template: null, | |
| logo: null, | |
| museumName: null, | |
| optionsContainer: null, | |
| infoContainer: null, | |
| optionTexts: null, | |
| animOptions: { | |
| queue: false, | |
| duration: 400 | |
| }, | |
| widthsCalculated: false, | |
| isExpanded: false, | |
| isLetter: false, | |
| initialize: function () { | |
| _.bindAll(this, "render", "expand", "shrink", "setOptionTextWidths"); | |
| this.render(); | |
| return this | |
| }, | |
| shrink: function () { | |
| this.isExpanded = false; | |
| this.$el.removeClass("hover") | |
| }, | |
| expand: function () { | |
| this.isExpanded = true; | |
| this.$el.addClass("hover") | |
| }, | |
| expandOption: function (a) { | |
| if (!this.isExpanded) { | |
| return | |
| } | |
| a.stop().animate({ | |
| paddingRight: 7, | |
| width: a.data("width") | |
| }, this.animOptions) | |
| }, | |
| shrinkOption: function (a) { | |
| a.stop().animate({ | |
| paddingRight: 0, | |
| width: 0 | |
| }, this.animOptions) | |
| }, | |
| setOptionTextWidths: function () { | |
| $.each(this.optionTexts, | |
| function (a, b) { | |
| $(b).data("width", $(b).width()); | |
| $(b).width(0) | |
| }) | |
| }, | |
| render: function () { | |
| this.$el = $(this.el); | |
| this.$el.html(_.template($("#collection-template").html(), { | |
| museum: this.model.attributes | |
| })); | |
| return this | |
| } | |
| }); | |
| ap.namespace("ap.museumlist.layout").ContinentDropdownView = Backbone.View.extend({ | |
| el: $("#continent_filter"), | |
| elWidth: null, | |
| events: { | |
| "click li a": "showNext", | |
| "click a.current": "toggleDropdown", | |
| }, | |
| map: null, | |
| menuWrapper: null, | |
| continents: null, | |
| countries: null, | |
| cities: null, | |
| previousLevel: null, | |
| currentLevel: "continents", | |
| nextLevel: "countries", | |
| initialHeight: 0, | |
| levels: { | |
| continents: { | |
| previous: null, | |
| next: "countries" | |
| }, | |
| countries: { | |
| previous: "continents", | |
| next: "cities" | |
| }, | |
| cities: { | |
| previous: "countries", | |
| next: null | |
| } | |
| }, | |
| initialize: function () { | |
| var b = this; | |
| $("body").on("click", | |
| function () { | |
| b.hideDropdown() | |
| }); | |
| _.bindAll(this, "render", "showDropdown", "showNext"); | |
| this.mapView = this.options.mapView; | |
| this.menuWrapper = this.el.find(".filter-wrapper").eq(0); | |
| var a = this.el.find("ul"); | |
| this.continents = a.eq(0); | |
| this.worldLink = this.continents.find("li:first a").text(); | |
| this.countries = this.continents.find("ul"); | |
| this.cities = this.countries.find("ul"); | |
| this.currentPlaceLink = this.el.find("a.current").eq(0); | |
| this.parentView = this.options.parentView | |
| }, | |
| showDropdown: function (a) { | |
| this.menuWrapper.show(); | |
| if (this.initialHeight == 0) { | |
| this.initialHeight = this.continents.outerHeight() | |
| } | |
| this.elWidth = this.elWidth || this.el.outerWidth(); | |
| this.el.width(this.elWidth); | |
| this.menuWrapper.width(this.elWidth); | |
| this.menuWrapper.fadeIn(); | |
| $("#continent_filter a.current").addClass("open"); | |
| a.stopPropagation() | |
| }, | |
| hideDropdown: function () { | |
| this.menuWrapper.fadeOut(); | |
| $("#continent_filter a.current").removeClass("open") | |
| }, | |
| render: function () {}, | |
| showNext: function (a) { | |
| a.preventDefault(); | |
| var f = $(a.currentTarget); | |
| var d = f.parent().hasClass("back"); | |
| if (f.data("level") == "reset") { | |
| this.parentView.trigger("mapLocationFiltered"); | |
| if (this.mapView) { | |
| this.mapView.resetLocationFilter() | |
| } | |
| } else { | |
| if (f.data("level") == "countries" && f.data("filter-value")) { | |
| this.parentView.trigger("mapLocationFiltered", f.data("filter-value")); | |
| this.hideDropdown() | |
| } | |
| } | |
| this.currentLevel = this.levels[f.data("level")]; | |
| if (this.currentLevel) { | |
| if (!d) { | |
| this.currentPlaceLink.text(f.text()); | |
| if (this.mapView) { | |
| this.mapView.findPlace(f.text()) | |
| } | |
| } | |
| if (!d && this.currentLevel.next) { | |
| var e = f.next(); | |
| this[this.currentLevel.next].hide(); | |
| e.show(); | |
| this.menuWrapper.animate({ | |
| height: e.outerHeight(), | |
| width: this.elWidth | |
| }); | |
| if (e[0]) { | |
| this.menuWrapper.find("ul").eq(0).animate({ | |
| left: "-=" + this.elWidth | |
| }) | |
| } | |
| } else { | |
| if (d && this.currentLevel.previous) { | |
| var c = f.parents("ul"); | |
| var e = c.eq(1); | |
| var b = c.eq(0); | |
| this.currentPlaceLink.text(b.prev().text()); | |
| if (this.mapView) { | |
| this.mapView.findPlace(b.prev().text()) | |
| } | |
| if (e.hasClass("first")) { | |
| this.menuWrapper.animate({ | |
| height: e.outerHeight(), | |
| width: this.elWidth | |
| }) | |
| } else { | |
| this.menuWrapper.animate({ | |
| height: e.outerHeight(), | |
| width: this.elWidth | |
| }) | |
| } | |
| this.menuWrapper.find("ul").eq(0).animate({ | |
| left: "+=" + this.elWidth | |
| }) | |
| } | |
| } | |
| } else { | |
| this.currentPlaceLink.text(f.text()); | |
| this.hideDropdown(); | |
| if (this.mapView) { | |
| this.mapView.resetMap() | |
| } | |
| } | |
| a.stopPropagation() | |
| }, | |
| resetDropdown: function () { | |
| if (this.initialHeight > 0) { | |
| this.currentPlaceLink.text(this.worldLink); | |
| this.previousLevel = null; | |
| this.currentLevel = "continents"; | |
| this.nextLevel = "countries"; | |
| this.menuWrapper.css({ | |
| height: this.initialHeight, | |
| width: this.elWidth | |
| }); | |
| this.continents.css({ | |
| left: 0 | |
| }) | |
| } | |
| if (this.mapView) { | |
| this.mapView.resetMap() | |
| } | |
| }, | |
| toggleDropdown: function (b) { | |
| var a = this; | |
| if (a.$(".filter-wrapper").is(":visible")) { | |
| a.hideDropdown(b) | |
| } else { | |
| a.showDropdown(b) | |
| } | |
| } | |
| }); | |
| ap.namespace("ap.museumlist.layout").MarkerView = Backbone.View.extend({ | |
| template: null, | |
| initialize: function () { | |
| var a = this; | |
| this.el = _.template($("#map-marker-template").html(), { | |
| museum: a.model.attributes | |
| }); | |
| return this.render() | |
| }, | |
| render: function () { | |
| return this | |
| } | |
| }); | |
| ap.namespace("ap.museumlist.layout").ContinentDropdownView = Backbone.View.extend({ | |
| el: $("#continent_filter"), | |
| elWidth: null, | |
| events: { | |
| "click li a": "showNext", | |
| "click a.current": "toggleDropdown", | |
| }, | |
| map: null, | |
| menuWrapper: null, | |
| continents: null, | |
| countries: null, | |
| cities: null, | |
| previousLevel: null, | |
| currentLevel: "continents", | |
| nextLevel: "countries", | |
| initialHeight: 0, | |
| levels: { | |
| continents: { | |
| previous: null, | |
| next: "countries" | |
| }, | |
| countries: { | |
| previous: "continents", | |
| next: "cities" | |
| }, | |
| cities: { | |
| previous: "countries", | |
| next: null | |
| } | |
| }, | |
| initialize: function () { | |
| var b = this; | |
| $("body").on("click", | |
| function () { | |
| b.hideDropdown() | |
| }); | |
| _.bindAll(this, "render", "showDropdown", "showNext"); | |
| this.mapView = this.options.mapView; | |
| this.menuWrapper = this.el.find(".filter-wrapper").eq(0); | |
| var a = this.el.find("ul"); | |
| this.continents = a.eq(0); | |
| this.worldLink = this.continents.find("li:first a").text(); | |
| this.countries = this.continents.find("ul"); | |
| this.cities = this.countries.find("ul"); | |
| this.currentPlaceLink = this.el.find("a.current").eq(0); | |
| this.parentView = this.options.parentView | |
| }, | |
| showDropdown: function (a) { | |
| this.menuWrapper.show(); | |
| if (this.initialHeight == 0) { | |
| this.initialHeight = this.continents.outerHeight() | |
| } | |
| this.elWidth = this.elWidth || this.el.outerWidth(); | |
| this.el.width(this.elWidth); | |
| this.menuWrapper.width(this.elWidth); | |
| this.menuWrapper.fadeIn(); | |
| $("#continent_filter a.current").addClass("open"); | |
| a.stopPropagation() | |
| }, | |
| hideDropdown: function () { | |
| this.menuWrapper.fadeOut(); | |
| $("#continent_filter a.current").removeClass("open") | |
| }, | |
| render: function () {}, | |
| showNext: function (a) { | |
| a.preventDefault(); | |
| var f = $(a.currentTarget); | |
| var d = f.parent().hasClass("back"); | |
| if (f.data("level") == "reset") { | |
| this.parentView.trigger("mapLocationFiltered"); | |
| if (this.mapView) { | |
| this.mapView.resetLocationFilter() | |
| } | |
| } else { | |
| if (f.data("level") == "countries" && f.data("filter-value")) { | |
| this.parentView.trigger("mapLocationFiltered", f.data("filter-value")); | |
| this.hideDropdown() | |
| } | |
| } | |
| this.currentLevel = this.levels[f.data("level")]; | |
| if (this.currentLevel) { | |
| if (!d) { | |
| this.currentPlaceLink.text(f.text()); | |
| if (this.mapView) { | |
| this.mapView.findPlace(f.text()) | |
| } | |
| } | |
| if (!d && this.currentLevel.next) { | |
| var e = f.next(); | |
| this[this.currentLevel.next].hide(); | |
| e.show(); | |
| this.menuWrapper.animate({ | |
| height: e.outerHeight(), | |
| width: this.elWidth | |
| }); | |
| if (e[0]) { | |
| this.menuWrapper.find("ul").eq(0).animate({ | |
| left: "-=" + this.elWidth | |
| }) | |
| } | |
| } else { | |
| if (d && this.currentLevel.previous) { | |
| var c = f.parents("ul"); | |
| var e = c.eq(1); | |
| var b = c.eq(0); | |
| this.currentPlaceLink.text(b.prev().text()); | |
| if (this.mapView) { | |
| this.mapView.findPlace(b.prev().text()) | |
| } | |
| if (e.hasClass("first")) { | |
| this.menuWrapper.animate({ | |
| height: e.outerHeight(), | |
| width: this.elWidth | |
| }) | |
| } else { | |
| this.menuWrapper.animate({ | |
| height: e.outerHeight(), | |
| width: this.elWidth | |
| }) | |
| } | |
| this.menuWrapper.find("ul").eq(0).animate({ | |
| left: "+=" + this.elWidth | |
| }) | |
| } | |
| } | |
| } else { | |
| this.currentPlaceLink.text(f.text()); | |
| this.hideDropdown(); | |
| if (this.mapView) { | |
| this.mapView.resetMap() | |
| } | |
| } | |
| a.stopPropagation() | |
| }, | |
| resetDropdown: function () { | |
| if (this.initialHeight > 0) { | |
| this.currentPlaceLink.text(this.worldLink); | |
| this.previousLevel = null; | |
| this.currentLevel = "continents"; | |
| this.nextLevel = "countries"; | |
| this.menuWrapper.css({ | |
| height: this.initialHeight, | |
| width: this.elWidth | |
| }); | |
| this.continents.css({ | |
| left: 0 | |
| }) | |
| } | |
| if (this.mapView) { | |
| this.mapView.resetMap() | |
| } | |
| }, | |
| toggleDropdown: function (b) { | |
| var a = this; | |
| if (a.$(".filter-wrapper").is(":visible")) { | |
| a.hideDropdown(b) | |
| } else { | |
| a.showDropdown(b) | |
| } | |
| } | |
| }); | |
| ap.namespace("ap.maps.layout").Main = Backbone.View.extend({ | |
| el: $(document), | |
| mapStyles: [{ | |
| stylers: [{ | |
| invert_lightness: true | |
| }, { | |
| saturation: -100 | |
| }, { | |
| visibility: "on" | |
| }, { | |
| gamma: 0.7 | |
| }] | |
| }], | |
| mapCanvas: $(".map"), | |
| markerData: [], | |
| map: null, | |
| mapCentre: null, | |
| mapZoom: 0, | |
| markerClusterer: null, | |
| markerList: [], | |
| mainMapOptions: {}, | |
| mapLoaded: false, | |
| infobox: null, | |
| infoboxTemplate: $("#map-marker-template").html(), | |
| pinIcon: "/skip_media_generator/map-pin.png", | |
| clusterStyle: [{ | |
| fontWeight: "normal", | |
| gridSize: 32, | |
| height: 22, | |
| textColor: "#030303", | |
| textSize: 12, | |
| url: "/skip_media_generator/map-pin-circle-yellow.png", | |
| width: 22 | |
| }], | |
| extraScripts: ["markerwithlabel", "markerclusterer", "infobox"], | |
| sidebarView: null, | |
| parentView: null, | |
| showMapAfterLoad: false, | |
| initialize: function () { | |
| _.bindAll(this, "initMap", "loadExtraScripts", "show", "hide", "findPlace", "resetMap"); | |
| this.sidebarView = this.options.sidebarView; | |
| this.parentView = this.options.parentView | |
| }, | |
| resetMap: function () { | |
| this.map.setCenter(this.mapCentre); | |
| this.map.setZoom(this.mapZoom) | |
| }, | |
| initMap: function () { | |
| var a = this; | |
| var c = a.mapCanvas.data("lat"); | |
| var b = a.mapCanvas.data("lng"); | |
| a.mapZoom = a.mapCanvas.data("zoom"); | |
| a.mapCentre = new google.maps.LatLng(c, b); | |
| a.mainMapOptions = { | |
| center: a.mapCentre, | |
| disableDefaultUI: true, | |
| mapTypeId: google.maps.MapTypeId.ROADMAP, | |
| minZoom: 2, | |
| styles: a.mapStyles, | |
| zoom: a.mapZoom | |
| }; | |
| a.map = new google.maps.Map(a.mapCanvas.get(0), a.mainMapOptions); | |
| var d = { | |
| disableAutoPan: true, | |
| maxWidth: 0, | |
| pixelOffset: new google.maps.Size(-160, - 131), | |
| zIndex: null, | |
| closeBoxURL: "", | |
| infoBoxClearance: new google.maps.Size(1, 1), | |
| pane: "floatPane", | |
| enableEventPropagation: true | |
| }; | |
| a.infobox = new InfoBox(d); | |
| $.each(a.parentView.rawModels, | |
| function (f, e) { | |
| a.markerData.push(e.attributes) | |
| }); | |
| $.each(a.markerData, | |
| function (f, e) { | |
| if (e.latitude && e.longitude) { | |
| a.addMarker(e) | |
| } | |
| }); | |
| a.markerClusterer = new MarkerClusterer(a.map, a.markerList, { | |
| gridSize: 22, | |
| styles: a.clusterStyle | |
| }); | |
| a.addZoomControl(); | |
| a.attachEvents(); | |
| a.mapLoaded = true; | |
| ap.log("[Debug] Finished Init"); | |
| if (a.showMapAfterLoad) { | |
| a.show() | |
| } | |
| }, | |
| resetLocationFilter: function () { | |
| this.parentView.trigger("mapLocationFiltered", false) | |
| }, | |
| findPlace: function (a) { | |
| var b = this, | |
| c = new google.maps.Geocoder(); | |
| c.geocode({ | |
| address: a.replace(" ", "+") | |
| }, | |
| function (l, j) { | |
| var m, e, o, f, p, n, d, k, q; | |
| if (j === "OK") { | |
| m = l[0].geometry; | |
| e = m.viewport.getNorthEast(); | |
| o = m.viewport.getSouthWest(); | |
| f = 256; | |
| p = o.lng(); | |
| n = e.lng(); | |
| d = n - p; | |
| k = $(b.map.getDiv()).outerWidth(); | |
| if (d < 0) { | |
| d += 360 | |
| } | |
| q = Math.round(Math.log(k * 360 / d / f) / Math.LN2); | |
| b.map.setZoom(q - 1); | |
| b.map.setCenter(m.location) | |
| } | |
| }) | |
| }, | |
| refreshMap: function () { | |
| google.maps.event.trigger(this.map, "resize"); | |
| this.map.setCenter(this.mapCentre); | |
| this.map.setZoom(this.mapZoom) | |
| }, | |
| show: function () { | |
| var a = this; | |
| if (a.mapLoaded) { | |
| a.parentView.resetFilters(); | |
| a.mapCanvas.parent().show(); | |
| a.refreshMap(); | |
| $("body").removeClass("view-multi-rows").addClass("view-map") | |
| } else { | |
| setTimeout(a.show, 100) | |
| } | |
| }, | |
| hide: function () { | |
| var a = this; | |
| if (a.mapLoaded) { | |
| a.mapCanvas.parent().hide(); | |
| $("body").removeClass("view-map").addClass("view-multi-rows") | |
| } | |
| }, | |
| attachEvents: function () { | |
| var a = this; | |
| google.maps.event.addDomListener(a.map, "zoom_changed", | |
| function () { | |
| if (a.map.getZoom() == a.mainMapOptions.minZoom) { | |
| a.map.panTo(a.mapCentre) | |
| } | |
| }) | |
| }, | |
| addZoomControl: function () { | |
| var c = this; | |
| var b = $('<div id="zoomControl"></div>'); | |
| var d = $('<a class="zoomIn"></a>'); | |
| var a = $('<a class="zoomOut"></a>'); | |
| b.append(d).append(a); | |
| c.map.controls[google.maps.ControlPosition.TOP_RIGHT].push(b.get(0)); | |
| google.maps.event.addDomListener(d.get(0), "click", | |
| function () { | |
| c.map.setZoom(c.map.getZoom() + 1) | |
| }); | |
| google.maps.event.addDomListener(a.get(0), "click", | |
| function () { | |
| c.map.setZoom(c.map.getZoom() - 1) | |
| }) | |
| }, | |
| createInfoBoxContent: function (a) { | |
| var b = this; | |
| var c = _.template(b.infoboxTemplate, a.museum); | |
| return c | |
| }, | |
| addMarker: function (c) { | |
| var b = this; | |
| var a = new MarkerWithLabel({ | |
| draggable: false, | |
| icon: b.pinIcon, | |
| labelAnchor: new google.maps.Point(3, 31), | |
| labelClass: "map-label", | |
| labelContent: "", | |
| labelInBackground: true, | |
| map: b.map, | |
| museum: c, | |
| position: new google.maps.LatLng(c.latitude, c.longitude), | |
| url: c.detail_url | |
| }); | |
| google.maps.event.addListener(a, "click", | |
| function () { | |
| ap.redirectTo(a.url) | |
| }); | |
| google.maps.event.addListener(a, "mouseover", | |
| function (d) { | |
| b.infobox.setContent(b.createInfoBoxContent(a)); | |
| b.infobox.open(b.map, this) | |
| }); | |
| google.maps.event.addListener(a, "mouseout", | |
| function () { | |
| b.infobox.close() | |
| }); | |
| b.markerList.push(a) | |
| }, | |
| loadMapsAPI: function (c) { | |
| var b = ap.getMapsApiKey(); | |
| var a = "http://maps.googleapis.com/maps/api/js?key=" + b + "&sensor=false&callback=" + c; | |
| ap.log("[Debug] Loading Google Maps API"); | |
| $('<script src="' + a + '">').appendTo($("body")) | |
| }, | |
| loadExtraScripts: function () { | |
| $.each(this.extraScripts, | |
| function (b, c) { | |
| ap.log("[Debug] Loading JS: " + c); | |
| var a = $("<script />"); | |
| a.attr("type", "text/javascript"); | |
| a.attr("src", "/skip_media_generator/" + c + ".js"); | |
| $("body").append(a) | |
| }); | |
| ap.log("[Debug] Init map start"); | |
| this.initMap() | |
| } | |
| }); | |
| ap.namespace("ap.museumlist.layout").MainView = ap.globals.MainNameListView.extend({ | |
| el: $(".content-with-sidebar"), | |
| container: $(".content-with-sidebar .museums"), | |
| aggregationConfig: { | |
| aggregationType: "MuseumList", | |
| collectionOptions: {}, | |
| modelViewType: "MuseumView", | |
| useDynamicRows: false, | |
| viewType: null, | |
| urlParts: ["collection"] | |
| }, | |
| options: { | |
| disabledButtons: [".slideshow", ".add-to-collection", ".streetview"] | |
| }, | |
| defaultQueryStringParams: { | |
| offset: 0, | |
| limit: 200 | |
| }, | |
| events: { | |
| "click .museum": "gotoMuseum", | |
| "click .view-option-map": "showMap", | |
| "click .view-option-multi": "hideMap", | |
| currentCollectionChange: "currentCollectionChange", | |
| "mouseenter .item.museum": "expand", | |
| "mouseleave .item.museum": "shrink", | |
| "mouseenter .option": "expandOption", | |
| "mouseleave .option": "shrinkOption" | |
| }, | |
| museumHoverTimeout: null, | |
| optionHoverTimeout: null, | |
| mainScrollingView: null, | |
| jScrollPaneApi: null, | |
| mapsView: null, | |
| items: $(".pane-wrapper"), | |
| attributeToSlice: "name_lower", | |
| modelView: ap.museumlist.layout.MuseumView, | |
| loadMapsAfterLoad: false, | |
| animOptions: { | |
| queue: false, | |
| duration: 400 | |
| }, | |
| initialize: function () { | |
| var a = this, | |
| b = document.location.hash; | |
| $.extend(a.options, { | |
| urlParts: a.aggregationConfig.urlParts, | |
| aggregationConfig: a.aggregationConfig | |
| }); | |
| ap.globals.MainNameListView.prototype.initialize.apply(this, [this.options]); | |
| _.bindAll(this, "render", "onSidebarResize", "reorganiseColumns", "showMap", "hideMap", "addAll", "addNewlyLoaded", "filterByLocation"); | |
| if (b && b == "#MuseumView" && a.topFiltersView) { | |
| a.topFiltersView.setActiveFilter("collection_type", "A", TRANSLATIONS.museumview); | |
| a.currentCollection.setFilter("collection_type", "A") | |
| } | |
| $("#main-nav").on("click", ".pegman", | |
| function (d) { | |
| d.preventDefault(); | |
| var c = document.location.hash; | |
| $("#main-filters .filter-museumView > a").click(); | |
| if (c && c == "#MuseumView") { | |
| document.location.hash = "" | |
| } else { | |
| document.location.hash = "#MuseumView" | |
| } | |
| }); | |
| this.rawModels = this.currentCollection.models || []; | |
| $("#continent_filter").show(); | |
| this.validCountries = {}; | |
| $("#continent_filter .second .filter-list-item").each(function () { | |
| a.validCountries[$(this).data("filter-value")] = $(this).text() | |
| }); | |
| $(window).smartresize(this.reorganiseColumns); | |
| this.bind("mapLocationFiltered", this.filterByLocation); | |
| a.continentDropdown = new ap.museumlist.layout.ContinentDropdownView({ | |
| parentView: a | |
| }); | |
| a.currentCollection.bind("reset", | |
| function () { | |
| if (a.rawModels.length == 0) { | |
| a.rawModels = a.currentCollection.models.slice(0); | |
| a.continentDropdown.mapView = a.mapsView | |
| } | |
| }); | |
| this.render() | |
| }, | |
| addAll: function () { | |
| ap.globals.MainNameListView.prototype.addAll.apply(this); | |
| if (this.loadMapsAfterLoad) { | |
| this.showMap() | |
| } | |
| }, | |
| addOne: function (c) { | |
| var b = this; | |
| var a = c.attributes[b.attributeToSlice].slice(0, 1).toUpperCase(); | |
| if (b.currentLetter != a) { | |
| b.currentLetter = a; | |
| b.addToColumn('<div class="item letter"><span></span>' + b.currentLetter + "</div>") | |
| } | |
| b.addToColumn(_.template($("#collection-template").html(), { | |
| museum: c.attributes | |
| })) | |
| }, | |
| expand: function (a) { | |
| var b = this; | |
| clearTimeout(this.museumHoverTimeout); | |
| var d = $(a.currentTarget); | |
| if (!d.data("optionWidthsCalculated")) { | |
| var c = d.find(".option"); | |
| $.each(c, | |
| function (e, f) { | |
| if (!$(f).data("width") || $(f).data("width") == 0) { | |
| b.setOptionTextWidths(d); | |
| d.data("optionWidthsCalculated", true) | |
| } | |
| }) | |
| } | |
| this.museumHoverTimeout = setTimeout(function () { | |
| d.data("expanded", true); | |
| d.addClass("hover") | |
| }, 120) | |
| }, | |
| shrink: function (a) { | |
| clearTimeout(this.museumHoverTimeout); | |
| var c = $(a.currentTarget), | |
| b = c.data("expanded"); | |
| if (b) { | |
| c.data("expanded", false); | |
| c.removeClass("hover") | |
| } | |
| }, | |
| shrinkOption: function (a) { | |
| clearTimeout(this.optionHoverTimeout); | |
| var c = $(a.currentTarget), | |
| b = c.data("expanded"); | |
| if (b) { | |
| c.data("expanded", false); | |
| c.stop().animate({ | |
| paddingRight: 0, | |
| width: 0 | |
| }, this.animOptions) | |
| } | |
| }, | |
| expandOption: function (a) { | |
| clearTimeout(this.optionHoverTimeout); | |
| var b = $(a.currentTarget); | |
| if (!b.data("width") || b.data("width") == 0) { | |
| this.setOptionTextWidths(b.parent().parent()) | |
| } | |
| this.optionHoverTimeout = setTimeout(function () { | |
| b.data("expanded", true); | |
| b.stop().animate({ | |
| paddingRight: 7, | |
| width: b.data("width") | |
| }, this.animOptions) | |
| }, 120) | |
| }, | |
| setOptionTextWidths: function (a) { | |
| var b = a.find(".option"); | |
| $.each(b, | |
| function (c, d) { | |
| $(d).data("width", $(d).width()); | |
| $(d).width(0) | |
| }) | |
| }, | |
| showMap: function () { | |
| var a = this; | |
| if (a.mapsView) { | |
| if (!a.loadMapsAfterLoad) { | |
| a.mapsView.show() | |
| } else { | |
| a.mapsView.showMapAfterLoad = true; | |
| a.mapsView.loadMapsAPI("ap.maps.mapsCallback"); | |
| a.loadMapsAfterLoad = false | |
| } | |
| } else { | |
| if (!a.loadMapsAfterLoad) { | |
| a.mapsView = new ap.maps.layout.Main({ | |
| parentView: a | |
| }); | |
| a.continentDropdown.mapView = a.mapsView; | |
| ap.namespace("ap.maps").mapsCallback = a.mapsView.loadExtraScripts; | |
| a.loadMapsAfterLoad = true | |
| } | |
| } | |
| }, | |
| hideMap: function () { | |
| if (this.mapsView) { | |
| this.mapsView.hide() | |
| } | |
| this.resetFilters() | |
| }, | |
| gotoMuseum: function (a) { | |
| window.location = $(a.currentTarget).find(".option.artwork_view").attr("href") | |
| }, | |
| remove: function () {}, | |
| resetFilters: function () { | |
| var a = this; | |
| a.topFiltersView.resetFilters(); | |
| a.topFiltersView.closeFilter(); | |
| a.continentDropdown.resetDropdown() | |
| }, | |
| onSidebarResize: function () { | |
| this.jScrollPaneApi.reinitialise(); | |
| if (this.mapsView) { | |
| this.mapsView.refreshMap() | |
| } | |
| }, | |
| filterByLocation: function (a) { | |
| if (a) { | |
| this.topFiltersView.resetFilters(); | |
| this.topFiltersView.setActiveFilter("country", a, this.validCountries[a]); | |
| this.filterCurrentCollection("country", a) | |
| } else { | |
| this.topFiltersView.removeActiveFilter("country"); | |
| this.filterCurrentCollection("country") | |
| } | |
| } | |
| }); | |
| var MuseumListRouter = Backbone.Router.extend({ | |
| routes: { | |
| ":section": "showHideMap" | |
| }, | |
| showHideMap: function (a) { | |
| if (a == "map") { | |
| window.app.showMap() | |
| } else { | |
| if (a == "list") { | |
| window.app.hideMap() | |
| } | |
| } | |
| } | |
| }); | |
| $(document).ready(function () { | |
| if ($("#museumlist").length && !ap.isMobile) { | |
| window.app = new ap.museumlist.layout.MainView(); | |
| window.app.router = new MuseumListRouter(); | |
| Backbone.history.start() | |
| } | |
| }); | |
| ap.namespace("ap.details.layout").Main = Backbone.View.extend({ | |
| el: $(".detailpopup"), | |
| $popupwrapper: $(".popupwrapper"), | |
| $columnWrappers: $(".column_wrapper"), | |
| $columns: $(".column"), | |
| $popupMargins: [], | |
| $mainContent: $(".main-content"), | |
| jScrollPaneApi: null, | |
| sidebar: null, | |
| initialize: function () { | |
| _.bindAll(this, "render", "togglePopup"); | |
| this.sidebar = this.options.sidebar; | |
| this.$popupMargins = [parseInt(this.$popupwrapper.css("margin-top"), 10), parseInt(this.$popupwrapper.css("margin-bottom"), 10)]; | |
| this.parentView = this.options.parentView; | |
| this.render() | |
| }, | |
| direction: "down", | |
| getScrollHeight: function () { | |
| return this.el.parent().height() | |
| }, | |
| calculateMaxHeights: function (b) { | |
| var c = $(".main-content").position().top; | |
| var a = b.getScrollHeight(); | |
| $(b.el).css({ | |
| height: a | |
| }).data("initialTop", c); | |
| if (b.direction == "up") { | |
| $(b.el).css({ | |
| top: c | |
| }) | |
| } else { | |
| $(b.el).css({ | |
| top: -1 * a | |
| }) | |
| } | |
| var e = b.getScrollHeight() - (b.$popupMargins[0] + b.$popupMargins[1]); | |
| b.$popupwrapper.css({ | |
| height: e | |
| }); | |
| var d = 0; | |
| _.each(b.$columnWrappers, | |
| function (f) { | |
| if ($(f).outerHeight() > d) { | |
| d = $(f).outerHeight() | |
| } | |
| }); | |
| if (d < e) { | |
| d = e | |
| } | |
| b.$columns.height(d) | |
| }, | |
| render: function () { | |
| this.el.show(); | |
| this.calculateMaxHeights(this); | |
| this.mainScrollingView = new ap.aggregation.layout.MainScrollingView({ | |
| element: this.$popupwrapper, | |
| useFloatingArrows: false, | |
| useDragScrolling: false, | |
| useKeyboardScrolling: false, | |
| scrollBy: 30 | |
| }); | |
| this.jScrollPaneApi = this.mainScrollingView.render(); | |
| this.attachEvents(); | |
| this.setupAnalyticsTracking() | |
| }, | |
| attachEvents: function () { | |
| var a = this; | |
| $(".details-trigger").click(function () { | |
| a.togglePopup() | |
| }); | |
| $(a.$(".close")).click(function (b) { | |
| b.preventDefault(); | |
| a.togglePopup() | |
| }); | |
| $(window).resize(function () { | |
| a.calculateMaxHeights(a); | |
| a.jScrollPaneApi.reinitialise() | |
| }) | |
| }, | |
| setupAnalyticsTracking: function () { | |
| var b = this; | |
| var a = $("body").data("museum-url"); | |
| $(".detailpopup").on("click", 'a[href^="http"]', | |
| function (d) { | |
| var c = encodeURIComponent(d.attr("href")); | |
| b.trackExternalMuseumLinkFollow(c) | |
| }) | |
| }, | |
| togglePopup: function (d) { | |
| var b = this, | |
| c; | |
| if (!_.isUndefined(d)) { | |
| b.direction = d | |
| } else { | |
| c = b.sidebar.parentView.streetview; | |
| if (c && c.sidebar && c.sidebar.open) { | |
| c.sidebar.killMuseumView(); | |
| c.sidebar.closeSidebar() | |
| } | |
| } | |
| b.el.stop(); | |
| var a = b.getScrollHeight(); | |
| b.el.height(a); | |
| var e = -1 * $(b.el).height(); | |
| var f = null; | |
| if (b.direction == "down") { | |
| b.direction = "up"; | |
| e = b.el.data("initialTop"); | |
| $(".details-trigger").addClass("active").text(TRANSLATIONS.close_details); | |
| b.sidebar.el.addClass("grey"); | |
| if (b.parentView.topFiltersView) { | |
| b.parentView.topFiltersView.closeFilter(); | |
| b.parentView.topFiltersView.hideFilterButton() | |
| } | |
| f = function () { | |
| b.$mainContent.hide() | |
| }; | |
| ap.trackDetailsPane({}, ap.getMuseumAnalyticsId()) | |
| } else { | |
| $(".details-trigger").removeClass("active").text(TRANSLATIONS.details); | |
| b.sidebar.el.removeClass("grey"); | |
| b.direction = "down"; | |
| b.$mainContent.show(); | |
| if (b.parentView.topFiltersView) { | |
| b.parentView.topFiltersView.showFilterButton() | |
| } | |
| } | |
| if (parseInt(b.el.css("top"), 10) != e) { | |
| b.el.animate({ | |
| top: e | |
| }, | |
| function () { | |
| $(window).trigger("resize"); | |
| if (f) { | |
| f() | |
| } | |
| }); | |
| b.jScrollPaneApi.reinitialise() | |
| } else { | |
| if (f) { | |
| f() | |
| } | |
| } | |
| }, | |
| trackExternalMuseumLinkFollow: function (a) { | |
| ap.trackMuseumLinkClicked({ | |
| collection_slug: $("body").data("museum-url"), | |
| external_url: a | |
| }, ap.getMuseumAnalyticsId()) | |
| } | |
| }); | |
| ap.namespace("ap.searchoverview.layout").MainView = ap.globals.MainBaseView.extend({ | |
| options: { | |
| disabledButtons: [".add-to-collection", ".slideshow"], | |
| }, | |
| mainScrollingView: null, | |
| jScrollPaneApi: null, | |
| mapsView: null, | |
| initialize: function (a) { | |
| ap.log("ap.searchoverview.layout.MainView::initalize()"); | |
| this.constructor.__super__.initialize.apply(this, [a]); | |
| _.bindAll(this, "render", "onSidebarResize", "recalculateElements"); | |
| this.render() | |
| }, | |
| render: function () { | |
| this.constructor.__super__.render.apply(this, [this.options]); | |
| this.calculateWidths(); | |
| this.mainScrollingView = new ap.aggregation.layout.MainScrollingView({ | |
| useFloatingArrows: false, | |
| jScrollPaneSettings: { | |
| hijackInternalLinks: false, | |
| } | |
| }); | |
| this.jScrollPaneApi = this.mainScrollingView.render(); | |
| this.recalculateElements(); | |
| this.el.on("resize", this.sidebar.el.selector, this.onSidebarResize) | |
| }, | |
| calculateWidths: function () { | |
| var b = this; | |
| var c = $(".column"); | |
| var d = c.outerWidth(true); | |
| var a = c.length * d; | |
| $(".pane-wrapper").width(a) | |
| }, | |
| recalculateElements: function () { | |
| var a = this; | |
| var b = (!ap.isMobile) ? $(".main-content .jspContainer") : $(".main-content"); | |
| $(".column").each(function (d, f) { | |
| var k = $(f); | |
| var m = k.find("li"); | |
| var e = m.size(); | |
| for (var j = 0; j < e; j++) { | |
| var c = k.height(); | |
| if (c >= b.height()) { | |
| ap.log("height is greater - height: " + c + " jspPaneHeight: " + b.height()); | |
| a.hideItem(k) | |
| } else { | |
| var l = m.filter(".hidden-result"); | |
| if (l.size() > 0) { | |
| a.showItem(k) | |
| } | |
| } | |
| } | |
| }); | |
| a.jScrollPaneApi.reinitialise() | |
| }, | |
| hideItem: function (b) { | |
| ap.log("Hiding item in column: "); | |
| ap.log(b); | |
| var a = b.find("li").not(".hidden-result").last(); | |
| ap.log("Hiding item: "); | |
| ap.log(a); | |
| a.addClass("hidden-result") | |
| }, | |
| showItem: function (a) { | |
| ap.log("Showing item in column: "); | |
| ap.log(a); | |
| var b = a.find("li").filter(".hidden-result").first(); | |
| ap.log("Showing item: " + b); | |
| ap.log(ap.log(b)); | |
| b.removeClass("hidden-result") | |
| }, | |
| onSidebarResize: function () { | |
| this.jScrollPaneApi.reinitialise() | |
| } | |
| }); | |
| $(document).ready(function () { | |
| if ($("#searchoverview").length) { | |
| window.app = new ap.searchoverview.layout.MainView() | |
| } | |
| }); | |
| ap.namespace("ap.aggregation.layout").SearchBaseView = Backbone.View.extend({ | |
| highlightTerms: function () { | |
| var a = $(body).data("search-query") | |
| } | |
| }); | |
| ap.namespace("ap.aggregation.layout").SearchArtworkView = Backbone.View.extend({ | |
| tagName: "div", | |
| className: "row-item artwork", | |
| template: $("#search-artwork-view-template").html(), | |
| events: {}, | |
| initialize: function () { | |
| _.bindAll(this, "render") | |
| }, | |
| highlightTerms: function () { | |
| var a = $(body).data("search-query") | |
| }, | |
| render: function (e, d) { | |
| var a = this.model.attributes; | |
| var f = this.model.calculateImageSizeForAPI(e); | |
| var b; | |
| var j = this.model.attributes.primary_image_aspect_ratio < 1; | |
| if (j) { | |
| b = "height: " + e.height + "px;" | |
| } else { | |
| b = "width: " + e.width + "px;" | |
| } | |
| var c = { | |
| artist_display_name: this.model.attributes.artist_display_name, | |
| detail_url: this.model.attributes.detail_url, | |
| img_path: this.model.image(f), | |
| title: this.model.attributes.title, | |
| pretty_display_date: this.model.attributes.pretty_display_date, | |
| portrait: j, | |
| style: b | |
| }; | |
| $(this.el).attr("data-cid", this.model.cid); | |
| $(this.el).attr("data-vieworder", this.model.viewOrder); | |
| $(this.el).attr("data-imageurl", this.model.attributes.cached_artwork_primary_image_full_url); | |
| $(this.el).attr("data-slug", this.model.attributes.slug); | |
| $(this.el).attr("data-artwork-id", this.model.attributes.id); | |
| $(this.el).data("model", this.model); | |
| $(this.el).html(_.template(this.template, c)); | |
| return this | |
| } | |
| }); | |
| ap.namespace("ap.aggregation.layout").SearchArtistView = ap.aggregation.layout.SearchBaseView.extend({ | |
| tagName: "div", | |
| className: "row-item artwork", | |
| template: $("#search-artist-view-template").html(), | |
| events: {}, | |
| initialize: function () { | |
| _.bindAll(this, "render") | |
| }, | |
| render: function (c, b) { | |
| var a = this.model.attributes; | |
| $(this.el).data("model", this.model); | |
| $(this.el).html(_.template(this.template, a)); | |
| return this | |
| } | |
| }); | |
| ap.namespace("ap.aggregation.layout").SearchMuseumView = ap.aggregation.layout.SearchBaseView.extend({ | |
| tagName: "div", | |
| className: "row-item artwork", | |
| template: $("#search-museum-view-template").html(), | |
| events: {}, | |
| initialize: function () { | |
| _.bindAll(this, "render") | |
| }, | |
| render: function (d, c) { | |
| var a = this.model.attributes; | |
| var b = $.extend({}, a, { | |
| style: "height: 80px;" | |
| }); | |
| $(this.el).data("model", this.model); | |
| $(this.el).html(_.template(this.template, b)); | |
| return this | |
| } | |
| }); | |
| ap.namespace("ap.aggregation.layout").SearchBookmarkGroupView = ap.aggregation.layout.SearchBaseView.extend({ | |
| tagName: "div", | |
| className: "row-item artwork", | |
| template: $("#search-gallery-view-template").html(), | |
| events: {}, | |
| initialize: function () { | |
| _.bindAll(this, "render") | |
| }, | |
| render: function (c, b) { | |
| var a = this.model.attributes; | |
| $(this.el).data("model", this.model); | |
| $(this.el).html(_.template(this.template, a)); | |
| return this | |
| } | |
| }); | |
| $(document).ready(function () { | |
| $("#faq-videos ul a").click(function () { | |
| $("#faq-videos ul a").removeClass("active"); | |
| $(this).addClass("active"); | |
| ytid = $(this).attr("data-ytid"); | |
| $("#faq-videos iframe").attr("src", "//www.youtube.com/embed/" + ytid + "?autoplay=1"); | |
| return false | |
| }); | |
| $("#education .answer, #faqs dd").each(function () { | |
| $(this).data("height", $(this).height()); | |
| $(this).css({ | |
| visibility: "visible", | |
| height: 0 | |
| }) | |
| }); | |
| if (window.location.hash == "#user_galleries_tutorial") { | |
| var a = $(".user-gallery-tutorial-content"); | |
| a.css("height", a.data("height")) | |
| } | |
| $("#faqs dt").on("click", | |
| function (j) { | |
| var c = $(this); | |
| var k = c.next(); | |
| var d = k.height(); | |
| var b; | |
| var f; | |
| if (d > 0) { | |
| b = 0; | |
| f = 250 | |
| } else { | |
| b = k.data("height"); | |
| f = 500 | |
| } | |
| k.animate({ | |
| height: b | |
| }, f); | |
| return false | |
| }); | |
| $("#education .answer-trigger").on("click", | |
| function (k) { | |
| var c = $(this); | |
| var l = c.next(".answer"); | |
| var f = l.height(); | |
| var d; | |
| var j; | |
| var b; | |
| if (f > 0) { | |
| d = 0; | |
| j = 250; | |
| b = "Show Answers"; | |
| c.css("background-position", "-467px -107px") | |
| } else { | |
| d = l.data("height"); | |
| j = 500; | |
| b = "Hide Answers"; | |
| c.css("background-position", "-467px -125px") | |
| } | |
| l.animate({ | |
| height: d | |
| }, j); | |
| c.text(b); | |
| return false | |
| }) | |
| }); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's the original source: http://www.googleartproject.com/media/2012_07_14_07_17_15/main-1cd2708dd3eb0ea8eb1a6eca57a907fa7cf1785e.js