Index: components/exhibition/html/view.html =================================================================== --- components/exhibition/html/view.html (revision 0) +++ components/exhibition/html/view.html (revision 0) @@ -0,0 +1,41 @@ + + + + + + + Exhibition + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + \ No newline at end of file Index: components/exhibition/html/viewCurrent.html =================================================================== --- components/exhibition/html/viewCurrent.html (revision 0) +++ components/exhibition/html/viewCurrent.html (revision 0) @@ -0,0 +1,52 @@ +
+
+

Exhibition Name

+
+
+
    +
  1. + + About... + Exhibition Image + Display Date + Exhibition Description + +
  2. +
  3. + + Events + +
  4. +
  5. + + Catalogue + N objects + +
  6. +
+
+
+
+

Show Guest's book (14 comments)

+
+
+

Some contents in a paragraph

+
+
+
+
+

Show Audio and View (n)

+
+ +
+
\ No newline at end of file Index: components/exhibition/html/viewUpcoming.html =================================================================== --- components/exhibition/html/viewUpcoming.html (revision 0) +++ components/exhibition/html/viewUpcoming.html (revision 0) @@ -0,0 +1,13 @@ +
+
+

Exhibitions

+
+
+

Upcoming Exhibitions

+
+
+

Exhibition Title

+Exhibition Image +
From Date
+ +
Exhibition Description
\ No newline at end of file Index: components/exhibition/js/ExhibitionView.js =================================================================== --- components/exhibition/js/ExhibitionView.js (revision 0) +++ components/exhibition/js/ExhibitionView.js (revision 0) @@ -0,0 +1,163 @@ +/* +Copyright 2009 University of Toronto + +Licensed under the Educational Community License (ECL), Version 2.0 or the New +BSD license. You may not use this file except in compliance with one these +Licenses. + +You may obtain a copy of the ECL 2.0 License and BSD License at +https://source.fluidproject.org/svn/LICENSE.txt +*/ + +/*global jQuery*/ +/*global fluid*/ + +fluid = fluid || {}; + +(function ($) { + + var buildViewUpcomingCutpoints = function (selectors) { + return [ + {id: "title", selector: selectors.title}, + {id: "image", selector: selectors.image}, + {id: "fromDate", selector: selectors.fromDate}, + {id: "description", selector: selectors.description} + ]; + }; + + var buildUpcomingViewTree = function (that) { + var model = that.model; + return { + children: [{ + ID: "title", + value: model.title + }, { + ID: "image", + decorators: [{ + attrs: { + src: model.image + } + }] + }, { + ID: "fromDate", + value: model.displayDate + }, { + ID: "description", + markup: model.introduction ? model.introduction : model.content + }] + }; + }; + + var buildViewCurrentCutpoints = function (selectors) { + return [ + {id: "title", selector: selectors.title}, + {id: "image", selector: selectors.image}, + {id: "displayDate", selector: selectors.displayDate}, + {id: "description", selector: selectors.description}, + {id: "catalogueSize", selector: selectors.catalogueSize} + ]; + }; + + var buildCurrentViewTree = function (that) { + var model = that.model; + return { + children: [{ + ID: "title", + value: model.title + }, { + ID: "image", + decorators: [{ + attrs: { + src: model.image + } + }] + }, { + ID: "displayDate", + value: model.displayDate + }, { + ID: "description", + markup: model.introduction ? model.introduction : model.content +// decorators: [{ +// type: "fluid", +// func: "fluid.description", +// options: { +// model: model.introduction ? model.introduction : model.content +// } +// }] + }, { + ID: "catalogueSize", + value: fluid.stringTemplate(that.options.strings.catalogueSize, {size: model.catalogueSize}) + }] + }; + }; + + var setupResources = function (url, buildCutpoints, selectors) { + return { + view: { + href: url, + cutpoints: buildCutpoints(selectors) + } + }; + }; + + var renderExhibition = function (that, resources, buildTree) { + fluid.fetchResources(resources, function () { + var templates = fluid.parseTemplates(resources, ["view"], {}); + var node = $("
", that.container[0].ownerDocument); + fluid.reRender(templates, node, buildTree(that), {model: that.model}); + that.container.append(node); + setupSubcomponents(that); + }); + }; + + var setupSubcomponents = function (that) { + that.exhibitionCabinet = fluid.initSubcomponent(that, "exhibitionCabinet", + [that.locate("currentCabinet"), {model: that.options.exhibitionCabinet.lists}]); + }; + + var setupCurrentExhibition = function (that) { + var resources = setupResources(that.options.viewCurrentURL, buildViewCurrentCutpoints, that.options.selectors); + renderExhibition(that, resources, buildCurrentViewTree); + }; + + var setupUpcomingExhibition = function (that) { + var resources = setupResources(that.options.viewUpcomingURL, buildViewUpcomingCutpoints, that.options.selectors); + renderExhibition(that, resources, buildUpcomingViewTree); + }; + + var setup = function (that) { + if (that.model.isCurrent === "yes") { + setupCurrentExhibition(that); + } + else { + setupUpcomingExhibition(that); + } + }; + + fluid.exhibition = function (container, options) { + var that = fluid.initView("fluid.exhibition", container, options); + that.model = that.options.model; + setup(that); + return that; + }; + + fluid.defaults("fluid.exhibition", { + selectors: { + title: ".flc-exhibition-title", + image: ".flc-exhibition-image", + fromDate: ".flc-exhibition-fromDate", + description: ".flc-exhibition-description", + displayDate: ".flc-exhibition-displayDate", + catalogueSize: ".flc-exhibition-catalogue-size", + currentCabinet: ".flc-exhibition-cabinet" + }, + exhibitionCabinet: { + type: "fluid.cabinet" + }, + strings: { + catalogueSize: "%size objects" + }, + viewCurrentURL: "../../../../fluid-engage-core/components/exhibition/html/viewCurrent.html", + viewUpcomingURL: "../../../../fluid-engage-core/components/exhibition/html/viewUpcoming.html" + }); +}(jQuery)); \ No newline at end of file Index: framework/js/Engage.js =================================================================== --- framework/js/Engage.js (revision 8931) +++ framework/js/Engage.js (working copy) @@ -32,7 +32,24 @@ return typeof value === "string"; }; - fluid.engage.collections = { + var wrap = function (value, tag) { + return "<" + tag + ">" + value + ""; + }; + + var buildHTML = function (value) { + var node = value.strong ? (value.strong.em ? wrap(wrap(value.strong.em, "em"), "strong") : value.strong) : ""; + var nodetext = value.nodetext; + for (var key in value) { + if (value.hasOwnProperty(key)) { + if (!(key === "nodetext" || key === "br" || key === "strong")) { + node = node + wrap(value[key] instanceof Object ? buildHTML(value[key]) : value[key], key); + } + } + } + return node + (nodetext ? nodetext : ""); + }; + + fluid.engage.specs = { mmi: { dataSpec: { "category": "Collection category", @@ -215,12 +232,102 @@ return tryFunc(getArtist, value); } } + }, + mccord_exhibitions: { + dataSpec: { + "isCurrent": "value.isCurrent", + "title": "key", + "displayDate": "value.displayDate", + "endDate": "value.endDate", + "image": { + "path": "value.image", + "func": "getExhibitionImage" + } + }, + mappers: { + getExhibitionImage: function (value) { + var getImage = function () { + return "http://www.mccord-museum.qc.ca" + $.makeArray(value.small)[0].nodetext; + }; + return tryFunc(getImage, value); + } + } + }, + mccord_exhibitions_view: { + dataSpec: { + "isCurrent": "value.isCurrent", + "title": "key", + "displayDate": "value.displayDate", + "endDate": "value.endDate", + "image": { + "path": "value.image", + "func": "getExhibitionImage" + }, + "introduction": { + "path": "value.introduction", + "func": "getIntroduction" + }, + "content": { + "path": "value.content", + "func": "getContent" + }, + "catalogueSize": "value.catalogueSize" + }, + mappers: { + getContent: function (value) { + var buildContent = function (value) { + var content = value.h2 ? value.h2 : ""; + if (value.p) { + if (typeof(value.p) === "string") { + content = content + wrap(value.p, "p") + } + else { + for (var i in value.p) { + content = content + wrap(buildHTML(value.p[i]), "p") + } + } + } + return content ? content : undefined; + }; + return tryFunc(buildContent, value, ""); + }, + getIntroduction: function (value) { + var buildIntro = function (value) { + var intro = ""; + if (value.p) { + if (typeof(value.p) === "string") { + content = content + wrap(value.p, "p") + } + else { + for (var i in value.p) { + intro = intro + wrap(buildHTML(value.p[i]), "p") + } + } + return intro; + } + return intro ? intro : undefined; + }; + return tryFunc(buildIntro, value, ""); + }, + getExhibitionImage: function (value) { + var getImage = function () { + if ($.makeArray(value.large)[0].height) { + return "http://www.mccord-museum.qc.ca" + $.makeArray(value.large)[0].nodetext; + } + else if ($.makeArray(value.medium)[0].height) { + return "http://www.mccord-museum.qc.ca" + $.makeArray(value.medium)[0].nodetext; + } + return "http://www.mccord-museum.qc.ca" + $.makeArray(value.small)[0].nodetext; + }; + return tryFunc(getImage, value); + } + } } }; fluid.engage.mapModel = function (model, dbName, spec) { - spec = spec || fluid.engage.collections; + spec = spec || fluid.engage.specs; var normalizedModel = {};