Commit df6af09d authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Merge branch 'dev' into 'master'

Dev

See merge request redmic-project/client/templates!13
parents 2fddecad 9c5510f1
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -15,7 +15,6 @@ module.exports = function(grunt) {
						qualityControl: true,
						GroupIcon: true,
						GroupIconInspire: true,
						Legend: true,
						Image: true,
						URL: true,
						UrlWebcam: true,
@@ -74,6 +73,8 @@ module.exports = function(grunt) {
						ActivityInspireTheme: true,
						ActivityResources: true,
						ActivityStarred: true,
						ServiceOGCAttribution: true,
						ServiceOGCLegend: true,

						// string
						Capitalize: true
@@ -153,6 +154,7 @@ module.exports = function(grunt) {
				, 'dist/ServiceOGCAtlasDetails.js': 'src/ServiceOGC/AtlasDetails.hbs'
				, 'dist/ServiceOGCTitle.js': 'src/ServiceOGC/Title.hbs'
				, 'dist/ServiceOGCInfo.js': 'src/ServiceOGC/Info.hbs'
				, 'dist/ServiceOGCSourceInfo.js': 'src/ServiceOGC/SourceInfo.hbs'
				, 'dist/ServiceOGCImage.js': 'src/ServiceOGC/Image.hbs'
				, 'dist/TaxonList.js': 'src/Taxon/List.hbs'
				, 'dist/PlaceNamesList.js': 'src/PlaceNames/List.hbs'
@@ -232,6 +234,7 @@ module.exports = function(grunt) {
				, 'dist/ThematicTypeSet.js': 'src/ThematicType/Set.hbs'

				, 'dist/ProtocolsSet.js': 'src/Protocols/Set.hbs'
				, 'dist/DownloadsSet.js': 'src/Downloads/Set.hbs'

				, 'dist/WhatIsRedmicLongTermChallenge.js': 'src/WhatIsRedmic/LongTermChallenge.hbs'
				, 'dist/WhatIsRedmicInfoType.js': 'src/WhatIsRedmic/InfoType.hbs'

src/Downloads/Set.hbs

0 → 100644
+10 −0
Original line number Diff line number Diff line
<span class='spanTemplate'>
	<span>
		{{data.name}}
	</span>
	{{#if data.url}}
	<span class='subtitle'>
		{{data.url}}
	</span>
	{{/if}}
</span>
+70 −2
Original line number Diff line number Diff line
define([
	'handlebars/handlebars.min'
	'dojo/_base/lang'
	, 'handlebars/handlebars.min'
], function(
	handlebars
	lang
	, handlebars
) {

	'use strict';
@@ -78,6 +80,72 @@ define([
				result = '<i title="' + i18n[title] + '" class="' + className + '"></i>';
			}
			return new handlebars.SafeString(result);
		},

		ServiceOGCAttribution: function(attribution) {

			var result;

			if (typeof attribution === 'string') {
				result = attribution;
			} else if (attribution && typeof attribution === 'object') {
				var href = attribution.onlineResource,
					text = attribution.title;

				if (!text) {
					result = '';
				} else if (!href) {
					result = text;
				} else {
					result = '<a href="' + href + '" target="_blank" title="' + href + '">' + text + '</a>';
				}
			}

			return new handlebars.SafeString(result);
		},

		ServiceOGCLegend: function(layer) {

			var imgClass = 'detailsPhoto',
				noImgUrl = '/resources/images/noIMG.png',
				legendOptsParam = 'legend_options=forceLabels:on;fontAntiAliasing:true',
				imgUrl;

			if (!layer || !(layer.legend || layer.stylesLayer)) {
				imgUrl = noImgUrl;
			} else if (layer.legend) {
				imgUrl = layer.legend + '&' + legendOptsParam;
			} else {
				var fixedStyles = layer.styles,
					firstStyle;

				if (fixedStyles) {
					var firstFixedStyleName = fixedStyles.split(',')[0],
						firstStyleNameSplit = firstFixedStyleName.split(':'),
						styleWithoutWorkspace = firstStyleNameSplit[firstStyleNameSplit.length - 1];

					var stylesFound = layer.stylesLayer.filter(lang.partial(function(style, item) {

						return item.name === style;
					}, styleWithoutWorkspace));

					if (stylesFound.length) {
						firstStyle = stylesFound[0];
					} else {
						imgUrl = noImgUrl;
					}
				} else {
					firstStyle = layer.stylesLayer[0];
				}

				if (firstStyle) {
					imgUrl = firstStyle.url + '&' + legendOptsParam;
				}
			}

			var imgElement = '<img src="' + imgUrl + '" class="' + imgClass + '" />';

			return new handlebars.SafeString(imgElement);
		}
	};
});
+0 −66
Original line number Diff line number Diff line
@@ -331,31 +331,6 @@ define([
			return new handlebars.SafeString(content + "'></i>");
		},

		'Legend': function(url) {

			var content;

			if (url) {
				var params = {
					legend_options: "fontAntiAliasing:true;dpi:100"
				};

				var paramsStr = L.Util.getParamString(params);

				if (url.indexOf("?") >= 0) {
					paramsStr = "&" + paramsStr.substr(1, paramsStr.length);
				}

				url = url + paramsStr;

				content = "<img src='" + url + "' class='detailsPhoto' /><br>";
			} else {
				content = "<img src='/resources/images/noIMG.png' class='detailsPhoto' /><br>";
			}

			return new handlebars.SafeString(content);
		},

		'Image': function(image, urlDefault) {

			var content;
@@ -834,47 +809,6 @@ define([
			return new handlebars.SafeString(content);
		},

		'DownloadServiceOGC': function(urlSource, name) {

			var urlSourceSplitted = urlSource.split('/');
			urlSourceSplitted.pop();

			var workspace = urlSourceSplitted[urlSourceSplitted.length - 1];
			urlSourceSplitted.push('ows');

			var urlCommonParams = 'service=WFS&version=1.0.0&request=GetFeature&typeName=' + workspace + ':' + name,
				urlCommonPrefix = urlSourceSplitted.join('/') + '?' + urlCommonParams,
				content = '',
				downloadFormats = [{
					name: 'CSV',
					descriptor: 'csv'
				},{
					name: 'Shapefile',
					descriptor: 'shape-zip'
				},{
					name: 'GeoJSON',
					descriptor: 'application/json'
				},{
					name: 'KML',
					descriptor: 'application/vnd.google-earth.kml%2Bxml'
				},{
					name: 'GML 3.2',
					descriptor: 'application/gml%2Bxml; version=3.2'
				}];

			for (var i = 0; i < downloadFormats.length; i++) {
				var format = downloadFormats[i],
					formatName = format.name,
					descriptor = format.descriptor,
					downloadUrl = '<span><a href="' + urlCommonPrefix + '&outputFormat=' + descriptor +
						'" target="_blank">' + formatName + '</a></span>';

				content += downloadUrl;
			}

			return new handlebars.SafeString(content);
		},

		'breaklines': breaklines,

		'textOrSpace': function(text) {
+1 −1
Original line number Diff line number Diff line
{{Legend data.styleLayer.url}}
{{ServiceOGCLegend data}}
Loading