Commit 66390fe8 by kevalbhatt

ATLAS-3294 : UI: Quick-search UI visual appearance enhancement

parent 569d5596
...@@ -88,6 +88,16 @@ ...@@ -88,6 +88,16 @@
.details-backbutton { .details-backbutton {
display: table-cell !important; display: table-cell !important;
} }
.searched-term-highlight {
background-color: #eeee31;
transition: background-color 4s, font-weight 2s;
&.bold {
background-color: transparent;
font-weight: bold;
}
}
} }
pre { pre {
......
...@@ -45,12 +45,6 @@ header.atlas-header { ...@@ -45,12 +45,6 @@ header.atlas-header {
padding: 3px 2px; padding: 3px 2px;
position: relative; position: relative;
transition: width 0.3s !important; transition: width 0.3s !important;
.global-search-container {
width: input {
width: 100%;
}
}
} }
} }
...@@ -499,6 +493,13 @@ hr[size="10"] { ...@@ -499,6 +493,13 @@ hr[size="10"] {
} }
} }
span.searched-term {
display: inline-block;
padding: 0;
font-weight: bold;
color: $black !important;
}
.ui-state-active { .ui-state-active {
margin: 0px; margin: 0px;
border: none; border: none;
......
...@@ -89,6 +89,16 @@ define([ ...@@ -89,6 +89,16 @@ define([
}); });
}, },
showRegions: function() {}, showRegions: function() {},
renderViewIfNotExists: function(options) {
var view = options.view,
render = options.render,
manualRender = options.manualRender;
if (!view.currentView) {
if (render) view.show(options.render());
} else {
if (manualRender) options.manualRender();
}
},
/** /**
* @override * @override
...@@ -110,6 +120,17 @@ define([ ...@@ -110,6 +120,17 @@ define([
// console.log("Post-Route Change Operations can be performed here !!"); // console.log("Post-Route Change Operations can be performed here !!");
// console.log("Route changed: ", name); // console.log("Route changed: ", name);
}, },
getHeaderOptions: function(Header) {
return {
view: App.rNHeader,
manualRender: function() {
this.view.currentView.manualRender();
},
render: function() {
return new Header();
}
}
},
detailPage: function(id) { detailPage: function(id) {
var that = this; var that = this;
if (id) { if (id) {
...@@ -121,14 +142,18 @@ define([ ...@@ -121,14 +142,18 @@ define([
], function(Header, DetailPageLayoutView, SideNavLayoutView, VEntityList) { ], function(Header, DetailPageLayoutView, SideNavLayoutView, VEntityList) {
this.entityCollection = new VEntityList([], {}); this.entityCollection = new VEntityList([], {});
var paramObj = Utils.getUrlState.getQueryParams(); var paramObj = Utils.getUrlState.getQueryParams();
App.rNHeader.show(new Header()); that.renderViewIfNotExists(that.getHeaderOptions(Header));
if (!App.rSideNav.currentView) { that.renderViewIfNotExists({
App.rSideNav.show(new SideNavLayoutView( view: App.rSideNav,
manualRender: function() {
this.view.currentView.selectTab();
},
render: function() {
return new SideNavLayoutView(
_.extend({}, that.preFetchedCollectionLists, that.sharedObj) _.extend({}, that.preFetchedCollectionLists, that.sharedObj)
)); );
} else {
App.rSideNav.currentView.selectTab();
} }
});
App.rNContent.show(new DetailPageLayoutView(_.extend({ App.rNContent.show(new DetailPageLayoutView(_.extend({
'collection': this.entityCollection, 'collection': this.entityCollection,
'id': id, 'id': id,
...@@ -148,8 +173,10 @@ define([ ...@@ -148,8 +173,10 @@ define([
], function(Header, SideNavLayoutView, TagDetailLayoutView) { ], function(Header, SideNavLayoutView, TagDetailLayoutView) {
var paramObj = Utils.getUrlState.getQueryParams(), var paramObj = Utils.getUrlState.getQueryParams(),
url = Utils.getUrlState.getQueryUrl().queyParams[0]; url = Utils.getUrlState.getQueryUrl().queyParams[0];
App.rNHeader.show(new Header()); that.renderViewIfNotExists(that.getHeaderOptions(Header));
if (!App.rSideNav.currentView) { that.renderViewIfNotExists({
view: App.rSideNav,
manualRender: function() {
if (paramObj && paramObj.dlttag) { if (paramObj && paramObj.dlttag) {
Utils.setUrl({ Utils.setUrl({
url: url, url: url,
...@@ -157,13 +184,10 @@ define([ ...@@ -157,13 +184,10 @@ define([
updateTabState: true updateTabState: true
}); });
} }
App.rSideNav.show(new SideNavLayoutView( this.view.currentView.RTagLayoutView.currentView.manualRender(_.extend({}, paramObj, { 'tagName': tagName }));
_.extend({ this.view.currentView.selectTab();
'tag': tagName, },
'value': paramObj render: function() {
}, that.preFetchedCollectionLists, that.sharedObj)
));
} else {
if (paramObj && paramObj.dlttag) { if (paramObj && paramObj.dlttag) {
Utils.setUrl({ Utils.setUrl({
url: url, url: url,
...@@ -171,9 +195,14 @@ define([ ...@@ -171,9 +195,14 @@ define([
updateTabState: true updateTabState: true
}); });
} }
App.rSideNav.currentView.RTagLayoutView.currentView.manualRender(_.extend({}, paramObj, { 'tagName': tagName })); return new SideNavLayoutView(
App.rSideNav.currentView.selectTab(); _.extend({
'tag': tagName,
'value': paramObj
}, that.preFetchedCollectionLists, that.sharedObj)
);
} }
});
if (tagName) { if (tagName) {
// updating paramObj to check for new queryparam. // updating paramObj to check for new queryparam.
paramObj = Utils.getUrlState.getQueryParams(); paramObj = Utils.getUrlState.getQueryParams();
...@@ -198,15 +227,19 @@ define([ ...@@ -198,15 +227,19 @@ define([
'views/site/SideNavLayoutView' 'views/site/SideNavLayoutView'
], function(Header, GlossaryDetailLayoutView, SideNavLayoutView) { ], function(Header, GlossaryDetailLayoutView, SideNavLayoutView) {
var paramObj = Utils.getUrlState.getQueryParams(); var paramObj = Utils.getUrlState.getQueryParams();
App.rNHeader.show(new Header()); that.renderViewIfNotExists(that.getHeaderOptions(Header));
if (!App.rSideNav.currentView) { that.renderViewIfNotExists({
App.rSideNav.show(new SideNavLayoutView( view: App.rSideNav,
manualRender: function() {
this.view.currentView.RGlossaryLayoutView.currentView.manualRender(_.extend({}, { 'guid': id, 'value': paramObj }));
this.view.currentView.selectTab();
},
render: function() {
return new SideNavLayoutView(
_.extend({}, that.preFetchedCollectionLists, that.sharedObj, { 'guid': id, 'value': paramObj }) _.extend({}, that.preFetchedCollectionLists, that.sharedObj, { 'guid': id, 'value': paramObj })
)); )
} else {
App.rSideNav.currentView.RGlossaryLayoutView.currentView.manualRender(_.extend({}, { 'guid': id, 'value': paramObj }));
App.rSideNav.currentView.selectTab();
} }
});
App.rNContent.show(new GlossaryDetailLayoutView(_.extend({ App.rNContent.show(new GlossaryDetailLayoutView(_.extend({
'guid': id, 'guid': id,
'value': paramObj 'value': paramObj
...@@ -222,21 +255,25 @@ define([ ...@@ -222,21 +255,25 @@ define([
'views/search/SearchDetailLayoutView', 'views/search/SearchDetailLayoutView',
], function(Header, SideNavLayoutView, SearchDetailLayoutView) { ], function(Header, SideNavLayoutView, SearchDetailLayoutView) {
var paramObj = Utils.getUrlState.getQueryParams(); var paramObj = Utils.getUrlState.getQueryParams();
App.rNHeader.show(new Header()); that.renderViewIfNotExists(that.getHeaderOptions(Header));
if (!App.rSideNav.currentView) { that.renderViewIfNotExists({
App.rSideNav.show(new SideNavLayoutView( view: App.rSideNav,
_.extend({ manualRender: function() {
'searchVent': that.searchVent this.view.currentView.selectTab();
}, that.preFetchedCollectionLists, that.sharedObj)
));
} else {
App.rSideNav.currentView.selectTab();
if (Utils.getUrlState.isTagTab()) { if (Utils.getUrlState.isTagTab()) {
App.rSideNav.currentView.RTagLayoutView.currentView.manualRender(); this.view.currentView.RTagLayoutView.currentView.manualRender();
} else if (Utils.getUrlState.isGlossaryTab()) { } else if (Utils.getUrlState.isGlossaryTab()) {
App.rSideNav.currentView.RGlossaryLayoutView.currentView.manualRender(_.extend({ "isTrigger": true }, { "value": paramObj })); this.view.currentView.RGlossaryLayoutView.currentView.manualRender(_.extend({ "isTrigger": true }, { "value": paramObj }));
} }
},
render: function() {
return new SideNavLayoutView(
_.extend({
'searchVent': that.searchVent
}, that.preFetchedCollectionLists, that.sharedObj)
)
} }
});
if (Globals.entityCreate && Utils.getUrlState.isSearchTab()) { if (Globals.entityCreate && Utils.getUrlState.isSearchTab()) {
App.rNContent.show(new SearchDetailLayoutView( App.rNContent.show(new SearchDetailLayoutView(
...@@ -263,17 +300,21 @@ define([ ...@@ -263,17 +300,21 @@ define([
var isinitialView = true, var isinitialView = true,
isTypeTagNotExists = false, isTypeTagNotExists = false,
tempParam = _.extend({}, paramObj); tempParam = _.extend({}, paramObj);
App.rNHeader.show(new Header()); that.renderViewIfNotExists(that.getHeaderOptions(Header));
if (!App.rSideNav.currentView) { that.renderViewIfNotExists({
App.rSideNav.show(new SideNavLayoutView( view: App.rSideNav,
manualRender: function() {
this.view.currentView.RSearchLayoutView.currentView.manualRender(paramObj);
},
render: function() {
return new SideNavLayoutView(
_.extend({ _.extend({
'value': paramObj, 'value': paramObj,
'searchVent': that.searchVent 'searchVent': that.searchVent
}, that.preFetchedCollectionLists, that.sharedObj) }, that.preFetchedCollectionLists, that.sharedObj)
)); )
} else {
App.rSideNav.currentView.RSearchLayoutView.currentView.manualRender(paramObj);
} }
});
App.rSideNav.currentView.selectTab(); App.rSideNav.currentView.selectTab();
if (paramObj) { if (paramObj) {
isinitialView = (paramObj.type || (paramObj.dslChecked == "true" ? "" : (paramObj.tag || paramObj.term)) || (paramObj.query ? paramObj.query.trim() : "")).length === 0; isinitialView = (paramObj.type || (paramObj.dslChecked == "true" ? "" : (paramObj.tag || paramObj.term)) || (paramObj.query ? paramObj.query.trim() : "")).length === 0;
......
...@@ -80,15 +80,29 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -80,15 +80,29 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
attributeDefs = options.attributeDefs, attributeDefs = options.attributeDefs,
formatIntVal = options.formatIntVal, formatIntVal = options.formatIntVal,
showListCount = options.showListCount || true, showListCount = options.showListCount || true,
highlightString = options.highlightString,
numberFormat = options.numberFormat || _.numberFormatWithComa; numberFormat = options.numberFormat || _.numberFormatWithComa;
var table = "", var table = "",
getHighlightedString = function(resultStr) {
if (highlightString && highlightString.length) {
try {
return resultStr.replace(new RegExp(highlightString, "gi"), function(foundStr) {
return "<span class='searched-term-highlight'>" + foundStr + "</span>"
});
} catch (error) {
return resultStr;
}
} else {
return resultStr;
}
},
getValue = function(val) { getValue = function(val) {
if (val) { if (val) {
if ((_.isNumber(val) || !_.isNaN(parseInt(val))) && formatIntVal) { if ((_.isNumber(val) || !_.isNaN(parseInt(val))) && formatIntVal) {
return numberFormat(val); return numberFormat(val);
} else { } else {
return val; return getHighlightedString(val);
} }
} else { } else {
return "N/A"; return "N/A";
...@@ -180,9 +194,9 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -180,9 +194,9 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
} }
} }
}); });
valueOfArray.push(Utils.JSONPrettyPrint(newAttributesList)); valueOfArray.push(Utils.JSONPrettyPrint(newAttributesList, getValue));
} else { } else {
valueOfArray.push(Utils.JSONPrettyPrint(attributesList)); valueOfArray.push(Utils.JSONPrettyPrint(attributesList, getValue));
} }
} }
if (id && inputOutputField) { if (id && inputOutputField) {
...@@ -193,7 +207,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -193,7 +207,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
fetchInputOutputValue(fetchId, defEntity); fetchInputOutputValue(fetchId, defEntity);
tempLink += '<div data-id="' + fetchId + '"><div class="value-loader"></div></div>'; tempLink += '<div data-id="' + fetchId + '"><div class="value-loader"></div></div>';
} else { } else {
tempLink += '<a href="#!/detailPage/' + id + '">' + name + '</a>' tempLink += '<a href="#!/detailPage/' + id + '">' + getValue(name) + '</a>'
} }
} }
if (readOnly) { if (readOnly) {
...@@ -247,14 +261,14 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -247,14 +261,14 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
if (_.isObject(valueObject[key])) { if (_.isObject(valueObject[key])) {
val = keyValue val = keyValue
} else if (Utils.isUrl(keyValue)) { } else if (Utils.isUrl(keyValue)) {
val = '<a target="_blank" class="blue-link" href="' + keyValue + '">' + keyValue + '</a>'; val = '<a target="_blank" class="blue-link" href="' + keyValue + '">' + getValue(keyValue) + '</a>';
} else if (key === 'guid' || key === "__guid") { } else if (key === 'guid' || key === "__guid") {
val = '<a title="' + key + '" href="#!/detailPage/' + keyValue + '">' + keyValue + '</a>'; val = '<a title="' + key + '" href="#!/detailPage/' + keyValue + '">' + getValue(keyValue) + '</a>';
} else { } else {
val = _.escape(keyValue); val = getValue(_.escape(keyValue));
} }
if (isTable) { if (isTable) {
var value = getValue(val), var value = val,
appendClass = (value == "N/A" ? "hide-row" : ""), appendClass = (value == "N/A" ? "hide-row" : ""),
htmlTag = '<div class="scroll-y">' + value + '</div>'; htmlTag = '<div class="scroll-y">' + value + '</div>';
if (_.isObject(valueObject[key]) && !_.isEmpty(valueObject[key])) { if (_.isObject(valueObject[key]) && !_.isEmpty(valueObject[key])) {
......
...@@ -816,7 +816,7 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums', ...@@ -816,7 +816,7 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums',
return regexp.test(url); return regexp.test(url);
} }
Utils.JSONPrettyPrint = function(obj) { Utils.JSONPrettyPrint = function(obj, getValue) {
var replacer = function(match, pIndent, pKey, pVal, pEnd) { var replacer = function(match, pIndent, pKey, pVal, pEnd) {
var key = '<span class=json-key>'; var key = '<span class=json-key>';
var val = '<span class=json-value>'; var val = '<span class=json-value>';
...@@ -825,7 +825,7 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums', ...@@ -825,7 +825,7 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums',
if (pKey) if (pKey)
r = r + key + pKey.replace(/[": ]/g, '') + '</span>: '; r = r + key + pKey.replace(/[": ]/g, '') + '</span>: ';
if (pVal) if (pVal)
r = r + (pVal[0] == '"' ? str : val) + pVal + '</span>'; r = r + (pVal[0] == '"' ? str : val) + getValue(pVal) + '</span>';
return r + (pEnd || ''); return r + (pEnd || '');
}, },
jsonLine = /^( *)("[\w]+": )?("[^"]*"|[\w.+-]*)?([,[{])?$/mg; jsonLine = /^( *)("[\w]+": )?("[^"]*"|[\w.+-]*)?([,[{])?$/mg;
......
...@@ -64,12 +64,22 @@ define(['require', ...@@ -64,12 +64,22 @@ define(['require',
this.entityTableGenerate(); this.entityTableGenerate();
}, },
entityTableGenerate: function() { entityTableGenerate: function() {
var table = CommonViewFunction.propertyTable({ scope: this, valueObject: this.entity.attributes, attributeDefs: this.attributeDefs }); var that = this,
highlightString = $(".atlas-header .global-search-container input.global-search").val(),
table = CommonViewFunction.propertyTable({
scope: this,
valueObject: this.entity.attributes,
attributeDefs: this.attributeDefs,
highlightString: highlightString
});
this.ui.detailValue.append(table); this.ui.detailValue.append(table);
Utils.togglePropertyRelationshipTableEmptyValues({ Utils.togglePropertyRelationshipTableEmptyValues({
"inputType": this.ui.noValueToggle, "inputType": this.ui.noValueToggle,
"tableEl": this.ui.detailValue "tableEl": this.ui.detailValue
}); });
setTimeout(function() {
that.$el.find(".searched-term-highlight").addClass("bold");
}, 5000)
} }
}); });
return EntityDetailTableLayoutView; return EntityDetailTableLayoutView;
......
...@@ -228,6 +228,9 @@ define(['require', ...@@ -228,6 +228,9 @@ define(['require',
skipDefaultError: true, skipDefaultError: true,
queryParam: queryParam, queryParam: queryParam,
success: function(data) { success: function(data) {
if (that.isDestroyed) {
return;
}
if (data.relations.length) { if (data.relations.length) {
that.lineageData = $.extend(true, {}, data); that.lineageData = $.extend(true, {}, data);
that.relationshipMap = that.crateLineageRelationshipHashMap(data); that.relationshipMap = that.crateLineageRelationshipHashMap(data);
...@@ -864,7 +867,7 @@ define(['require', ...@@ -864,7 +867,7 @@ define(['require',
typeStr += '<option value="' + obj.guid + '">' + obj.attributes.name + '</option>'; typeStr += '<option value="' + obj.guid + '">' + obj.attributes.name + '</option>';
}); });
} }
that.ui.lineageTypeSearch.html(typeStr); this.ui.lineageTypeSearch.html(typeStr);
this.initilizelineageTypeSearch(); this.initilizelineageTypeSearch();
}, },
initilizelineageTypeSearch: function() { initilizelineageTypeSearch: function() {
......
...@@ -76,7 +76,7 @@ define(['require', ...@@ -76,7 +76,7 @@ define(['require',
}, },
setSearchBoxWidth: function(options) { setSearchBoxWidth: function(options) {
var atlasHeaderWidth = this.$el.find(".atlas-header").width(), var atlasHeaderWidth = this.$el.find(".atlas-header").width(),
minusWidth = Utils.getUrlState.isDetailPage() ? 400 : 250; minusWidth = Utils.getUrlState.isDetailPage() ? 413 : 263;
if (options && options.updateWidth) { if (options && options.updateWidth) {
atlasHeaderWidth = options.updateWidth(atlasHeaderWidth); atlasHeaderWidth = options.updateWidth(atlasHeaderWidth);
} }
...@@ -87,7 +87,7 @@ define(['require', ...@@ -87,7 +87,7 @@ define(['require',
bindEvent: function() { bindEvent: function() {
var that = this; var that = this;
$(window).resize(function() { $(window).resize(function() {
that.setSearchBoxWidth() that.setSearchBoxWidth();
}); });
}, },
onRender: function() { onRender: function() {
...@@ -103,16 +103,20 @@ define(['require', ...@@ -103,16 +103,20 @@ define(['require',
onBeforeDestroy: function() { onBeforeDestroy: function() {
this.ui.globalSearch.atlasAutoComplete("destroy"); this.ui.globalSearch.atlasAutoComplete("destroy");
}, },
manualRender: function() {
this.setSearchBoxWidth();
},
fetchSearchData: function(options) { fetchSearchData: function(options) {
var that = this, var that = this,
request = options.request, request = options.request,
response = options.response, response = options.response,
term = request.term, term = request.term,
data = {},
sendResponse = function() { sendResponse = function() {
var query = that.cache[term].query, var query = data.query,
suggestions = that.cache[term].suggestions; suggestions = data.suggestions;
if (query !== undefined && suggestions !== undefined) { if (query !== undefined && suggestions !== undefined) {
response(that.cache[term]); response(data);
} }
}; };
$.ajax({ $.ajax({
...@@ -124,9 +128,9 @@ define(['require', ...@@ -124,9 +128,9 @@ define(['require',
"offset": 0 "offset": 0
}, },
cache: true, cache: true,
success: function(data) { success: function(response) {
var data = data.searchResults.entities || []; var rData = response.searchResults.entities || [];
that.cache[term] = _.extend({}, that.cache[term], { query: { category: "entities", data: data, order: 1 } }); data.query = { category: "entities", data: rData, order: 1 };
sendResponse(); sendResponse();
} }
}); });
...@@ -138,10 +142,10 @@ define(['require', ...@@ -138,10 +142,10 @@ define(['require',
"prefixString": term "prefixString": term
}, },
cache: true, cache: true,
success: function(data) { success: function(response) {
var data = data.suggestions || []; var rData = response.suggestions || [];
that.cache[term] = _.extend({}, that.cache[term], { suggestions: { category: "suggestions", data: data, order: 2 } }); data.suggestions = { category: "suggestions", data: rData, order: 2 };
sendResponse(data); sendResponse();
} }
}); });
}, },
...@@ -152,9 +156,16 @@ define(['require', ...@@ -152,9 +156,16 @@ define(['require',
return str; return str;
} }
}, },
triggerBuasicSearch: function(query) {
Utils.setUrl({
url: '#!/search/searchResult?query=' + encodeURIComponent(query) + '&searchType=basic',
mergeBrowserUrl: false,
trigger: true,
updateTabState: true
});
},
initializeGlobalSearch: function() { initializeGlobalSearch: function() {
var that = this; var that = this;
this.cache = {};
this.ui.globalSearch.atlasAutoComplete({ this.ui.globalSearch.atlasAutoComplete({
minLength: 1, minLength: 1,
autoFocus: false, autoFocus: false,
...@@ -171,13 +182,11 @@ define(['require', ...@@ -171,13 +182,11 @@ define(['require',
var item = ui && ui.item; var item = ui && ui.item;
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
if (_.isString(item)) {
var $el = $(this); var $el = $(this);
if (_.isString(item)) {
$el.val(item); $el.val(item);
$el.data("valSelected", true); $el.data("valSelected", true);
setTimeout(function() { that.triggerBuasicSearch(item);
$el.atlasAutoComplete("search");
}, 10);
} else if (_.isObject(item) && item.guid) { } else if (_.isObject(item) && item.guid) {
Utils.setUrl({ Utils.setUrl({
url: '#!/detailPage/' + item.guid, url: '#!/detailPage/' + item.guid,
...@@ -185,14 +194,10 @@ define(['require', ...@@ -185,14 +194,10 @@ define(['require',
trigger: true trigger: true
}); });
} }
$el.blur();
return true; return true;
}, },
source: function(request, response) { source: function(request, response) {
var term = request.term;
if (that.cache && that.cache[term]) {
response(that.cache[term]);
return;
}
that.fetchSearchData({ that.fetchSearchData({
request: request, request: request,
response: response response: response
...@@ -207,19 +212,26 @@ define(['require', ...@@ -207,19 +212,26 @@ define(['require',
that.ui.clearGlobalSearch.addClass("in"); that.ui.clearGlobalSearch.addClass("in");
if (event.keyCode == 13) { if (event.keyCode == 13) {
if ($(this).data("valSelected") !== true) { if ($(this).data("valSelected") !== true) {
Utils.setUrl({ that.triggerBuasicSearch(that.getSearchString($(this).val()));
url: '#!/search/searchResult?query=' + encodeURIComponent(that.getSearchString($(this).val())) + '&searchType=basic',
mergeBrowserUrl: false,
trigger: true
});
} else { } else {
$(this).data("valSelected", false); $(this).data("valSelected", false);
} }
} }
} }
}).atlasAutoComplete("instance")._renderItem = function(ul, searchItem) { }).atlasAutoComplete("instance")._renderItem = function(ul, searchItem) {
if (searchItem) { if (searchItem) {
var data = searchItem.data; var data = searchItem.data,
searchTerm = this.term,
getHighlightedTerm = function(resultStr) {
try {
return resultStr.replace(new RegExp(searchTerm, "gi"), function(foundStr) {
return "<span class='searched-term'>" + foundStr + "</span>";
});
} catch (error) {
return resultStr;
}
}
if (data) { if (data) {
if (data.length == 0) { if (data.length == 0) {
return $("<li class='empty'></li>") return $("<li class='empty'></li>")
...@@ -237,16 +249,15 @@ define(['require', ...@@ -237,16 +249,15 @@ define(['require',
var img = $('<img src="' + Utils.getEntityIconPath(options) + '">').on('error', function(error, s) { var img = $('<img src="' + Utils.getEntityIconPath(options) + '">').on('error', function(error, s) {
this.src = Utils.getEntityIconPath(_.extend(options, { errorUrl: this.src })); this.src = Utils.getEntityIconPath(_.extend(options, { errorUrl: this.src }));
}); });
var span = $("<span>" + item.itemText + "</span>") var span = $("<span>" + (getHighlightedTerm(item.itemText)) + "</span>")
.prepend(img); .prepend(img);
li = $("<li class='with-icon'>") li = $("<li class='with-icon'>")
.append(span); .append(span);
li.data("ui-autocomplete-item", item);
} else { } else {
li = $("<li>") li = $("<li>")
.append("<span>" + item + "</span>") .append("<span>" + (getHighlightedTerm(item)) + "</span>");
li.data("ui-autocomplete-item", item);
} }
li.data("ui-autocomplete-item", item);
if (searchItem.category) { if (searchItem.category) {
items.push(li.attr("aria-label", searchItem.category + " : " + (_.isObject(item) ? item.itemText : item))); items.push(li.attr("aria-label", searchItem.category + " : " + (_.isObject(item) ? item.itemText : item)));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment