Skip to content

Commit

Permalink
Placeholder for search (#3)
Browse files Browse the repository at this point in the history
* PlaceHolder with Layer Name

* Just in case

* assume not applicationProperties

* assume not itemData

* fixed undefined appId bug

* Fix Language 3 AppId Error

* Master (#2)

* Cleanup

* Fixed AppId for Language 3
  • Loading branch information
Horiatu authored Jan 24, 2017
1 parent 3be3229 commit ac69d7d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion js/LanguageSelect/LanguageSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ define([
//console.log(e.srcElement.parentElement);
var locale=e.srcElement.parentElement.dataset.code;
var appId=e.srcElement.parentElement.dataset.appid;
if(!appId || appId==='' || appId === undefined) {
if(!appId || appId==='' || appId === "undefined") {
appId = /(?:[?|&]appid=)([a-z0-9]*)/gi.exec(location.search);
if(appId && appId.length===2) {
appId = appId[1];
Expand Down
27 changes: 24 additions & 3 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,6 @@ define(["dojo/ready",

_addDetails: function (tool, toolbar, deferred) {
//Add the default map description panel
//var deferred = new Deferred();
if (has("details")) {
var description = this.config.description || this.config.response.itemInfo.item.description || this.config.response.itemInfo.item.snippet || " ";

Expand All @@ -748,7 +747,7 @@ define(["dojo/ready",
tabindex:0
});
detailDiv.innerHTML = "<div tabindex=0 id='detailDiv'>"+description+"</div>";
var detailDiv = dojo.query("#detailDiv")[0];
detailDiv = dojo.query("#detailDiv")[0];
if(!has("instructions"))
domClass.add(detailDiv, "detailFull");
else
Expand Down Expand Up @@ -1526,7 +1525,11 @@ define(["dojo/ready",
}));

//Add search layers defined on the web map item
if (this.config.response.itemInfo.itemData && this.config.response.itemInfo.itemData.applicationProperties && this.config.response.itemInfo.itemData.applicationProperties.viewing && this.config.response.itemInfo.itemData.applicationProperties.viewing.search) {
if (this.config.response.itemInfo.itemData &&
this.config.response.itemInfo.itemData.applicationProperties &&
this.config.response.itemInfo.itemData.applicationProperties.viewing &&
this.config.response.itemInfo.itemData.applicationProperties.viewing.search) {

var searchOptions = this.config.response.itemInfo.itemData.applicationProperties.viewing.search;

array.forEach(searchOptions.layers, lang.hitch(this, function (searchLayer) {
Expand Down Expand Up @@ -1570,6 +1573,16 @@ define(["dojo/ready",
}));
}

defaultSources.forEach(function(source) {
if(!source.placeholder || source.placeholder === undefined || source.placeholder ==="") {
if(source.featureLayer && source.featureLayer.name) {
source.placeholder = i18n.searchEnterCriteria+" "+source.featureLayer.name;
}
else {
source.placeholder = i18n.searchPlaceholder;
}
}
});
search.set("sources", defaultSources);

search.startup();
Expand Down Expand Up @@ -1843,6 +1856,14 @@ define(["dojo/ready",

domAttr.set(dom.byId("panelText"),"TabIndex",0);
this.config.title = title;
if(!response.itemInfo.itemData)
response.itemInfo.itemData = {};
if(!response.itemInfo.itemData.applicationProperties)
response.itemInfo.itemData.applicationProperties = {};
if(!response.itemInfo.itemData.applicationProperties.viewing)
response.itemInfo.itemData.applicationProperties.viewing = {};
if(!response.itemInfo.itemData.applicationProperties.viewing.search)
response.itemInfo.itemData.applicationProperties.viewing.search = { hintText: i18n.searchPlaceholder };
this.config.response = response;
window.config = this.config;

Expand Down
1 change: 1 addition & 0 deletions js/nls/fr/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ define(
},
search : "Recherche: ",
searchPlaceholder: "Trouver une adresse ou un lieu",
searchEnterCriteria : "Terme recherché pour",
pressAlt : "Appuyer sur ALT + 0 à 7 pour naviguer rapidement",
instructions:"instructions.french",
wcagViewer : "Explorateur WCAG"
Expand Down
1 change: 1 addition & 0 deletions js/nls/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ define({
},
search : "Search: ",
searchPlaceholder: "Find address or place",
searchEnterCriteria : "Enter search term for",
pressAlt : "Press ALT + 0 to 7 keys for fast navigation",
instructions:"instructions",
wcagViewer : "WCAG Viewer"
Expand Down

0 comments on commit ac69d7d

Please sign in to comment.