Skip to content

Commit

Permalink
if attribute value in feature info box hast ftp://, http://, https://…
Browse files Browse the repository at this point in the history
… then make it a hyperlink that opens in new tab.
  • Loading branch information
smesdaghi committed Jan 22, 2015
1 parent 397b107 commit 6a17481
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/common/featuremanager/FeatureInfoBoxDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
});
});

scope.isUrl = function(str) {
if (!/^(f|ht)tps?:\/\//i.test(str)) {
return false;
}
return true;
};

scope.isShowingAttributes = function() {
var schema = featureManagerService.getSelectedLayer().get('metadata').schema;

Expand Down
5 changes: 4 additions & 1 deletion src/common/featuremanager/partial/featureinfobox.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@
<span ng-repeat="prop in featureManagerService.getSelectedItemProperties()">
<div ng-if="prop[0] !== 'fotos' && prop[0] !== 'photos'" ng-show="isAttributeVisible(prop[0])">
<span class="info-box-attribute">{{prop[0]}}</span>
<span class="info-box-attribute-value">{{prop[1]}}</span>
<span ng-switch on="isUrl(prop[1])">
<a ng-switch-when="true" class="info-box-attribute-value" target="_blank" href="{{prop[1]}}">{{prop[1]}}</a>
<span ng-switch-default class="info-box-attribute-value">{{prop[1]}}</span>
</span>
</div>
</span>
</div>
Expand Down

0 comments on commit 6a17481

Please # to comment.