- Timestamp:
- 01/28/15 09:14:40 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
SRUAggregator/trunk/src/main/resources/assets/js/search.js
r5954 r5957 52 52 return r; 53 53 } 54 var t1 = x.title ? x.title : x.displayName; 55 var t2 = y.title ? y.title : y.displayName; 56 return t1.toLowerCase().localeCompare(t2.toLowerCase()); 54 return x.title.toLowerCase().localeCompare(y.title.toLowerCase()); 57 55 }; 58 56 … … 177 175 corpora: new Corpora([], this.updateCorpora), 178 176 languageMap: {}, 177 query: "", 179 178 language: this.anyLanguage, 180 179 languageFilter: 'byMeta', … … 214 213 }, 215 214 216 search: function( query) {217 // console.log(query);215 search: function() { 216 var query = this.state.query; 218 217 if (!query) { 219 218 this.setState({ hits: this.nohits, searchId: null }); … … 253 252 // console.log("new search in: " + this.timeout+ "ms"); 254 253 } else { 255 // console.log("search ended");254 console.log("search ended; hits:", json); 256 255 } 257 256 this.setState({hits:json}); 258 // console.log("hits:", json);259 257 }.bind(this), 260 258 }); … … 316 314 }, 317 315 316 handleChange: function(event) { 317 this.setState({query: event.target.value}); 318 }, 319 320 handleKey: function(event) { 321 if (event.keyCode==13) { 322 this.search(); 323 } 324 }, 325 318 326 renderAggregator: function() { 319 327 var layer = layerMap[this.state.searchLayerId]; … … 327 335 ), 328 336 329 React.createElement(SearchBox, {search: this.search, placeholder: layer.searchPlaceholder}), 337 React.createElement("input", {className: "form-control input-lg search", name: "query", type: "text", 338 value: this.state.query, placeholder: this.props.placeholder, 339 tabIndex: "1", onChange: this.handleChange, onKeyDown: this.handleKey}), 330 340 React.createElement("div", {className: "input-group-btn"}, 331 341 React.createElement("button", {className: "btn btn-default input-lg", type: "button", onClick: this.search}, … … 496 506 } 497 507 }); 498 /////////////////////////////////499 500 var SearchBox = React.createClass({displayName: 'SearchBox',501 propTypes: {502 search: PT.func.isRequired,503 placeholder: PT.string.isRequired,504 },505 506 getInitialState: function () {507 return {508 query: "",509 };510 },511 512 handleChange: function(event) {513 this.setState({query: event.target.value});514 },515 516 handleKey: function(event) {517 if (event.keyCode==13) {518 this.search();519 }520 },521 522 search: function() {523 this.props.search(this.state.query);524 },525 526 render: function() {527 return React.createElement("input", {className: "form-control input-lg search",528 name: "query",529 type: "text",530 value: this.state.query,531 placeholder: this.props.placeholder,532 tabIndex: "1",533 onChange: this.handleChange,534 onKeyDown: this.handleKey}) ;535 }536 });537 508 538 509 ///////////////////////////////// … … 584 555 var inline = {display:"inline-block"}; 585 556 return React.createElement("div", {style: inline}, 586 React.createElement("span", {className: "corpusName"}, " ", corpus.title ? corpus.title : corpus.displayName),557 React.createElement("span", {className: "corpusName"}, " ", corpus.title), 587 558 React.createElement("span", {className: "institutionName"}, " â ", corpus.institution.name) 588 559 ); … … 592 563 var inline = {display:"inline-block"}; 593 564 return React.createElement("div", null, 594 React.createElement(InfoPopover, {placement: "left", 595 title: corpus.title ? corpus.title : corpus.displayName}, 565 React.createElement(InfoPopover, {placement: "left", title: corpus.title}, 596 566 React.createElement("dl", {className: "dl-horizontal"}, 597 567 React.createElement("dt", null, "Institution"), … … 625 595 626 596 return corpusHit.diagnostics.map(function(d) { 627 return React.createElement("div", {className: "alert alert-danger", role: "alert" },597 return React.createElement("div", {className: "alert alert-danger", role: "alert", key: d.dgnUri}, 628 598 d.dgnMessage, ": ", d.dgnDiagnostic 629 599 ); … … 653 623 return false; 654 624 } 655 return React.createElement(Panel, {key: corpusHit.corpus. displayName,625 return React.createElement(Panel, {key: corpusHit.corpus.title, 656 626 title: this.renderPanelTitle(corpusHit.corpus), 657 627 info: this.renderPanelInfo(corpusHit.corpus)},
Note: See TracChangeset
for help on using the changeset viewer.