Ignore:
Timestamp:
01/28/15 09:14:40 (9 years ago)
Author:
emanuel.dima@uni-tuebingen.de
Message:
  1. alpha15: added support for new spec explains/search; misc UI corrections
File:
1 edited

Legend:

Unmodified
Added
Removed
  • SRUAggregator/trunk/src/main/resources/assets/js/search.js

    r5954 r5957  
    5252                        return r;
    5353                }
    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());
    5755        };
    5856
     
    177175                        corpora: new Corpora([], this.updateCorpora),
    178176                        languageMap: {},
     177                        query: "",
    179178                        language: this.anyLanguage,
    180179                        languageFilter: 'byMeta',
     
    214213        },
    215214
    216         search: function(query) {
    217                 // console.log(query);
     215        search: function() {
     216                var query = this.state.query;
    218217                if (!query) {
    219218                        this.setState({ hits: this.nohits, searchId: null });
     
    253252                                        // console.log("new search in: " + this.timeout+ "ms");
    254253                                } else {
    255                                         // console.log("search ended");
     254                                        console.log("search ended; hits:", json);
    256255                                }
    257256                                this.setState({hits:json});
    258                                 // console.log("hits:", json);
    259257                        }.bind(this),
    260258                });
     
    316314        },
    317315
     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
    318326        renderAggregator: function() {
    319327                var layer = layerMap[this.state.searchLayerId];
     
    327335                                                        ),
    328336
    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}),
    330340                                                        React.createElement("div", {className: "input-group-btn"},
    331341                                                                React.createElement("button", {className: "btn btn-default input-lg", type: "button", onClick: this.search},
     
    496506        }
    497507});
    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 });
    537508
    538509/////////////////////////////////
     
    584555                var inline = {display:"inline-block"};
    585556                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),
    587558                                        React.createElement("span", {className: "institutionName"}, " — ", corpus.institution.name)
    588559                                );
     
    592563                var inline = {display:"inline-block"};
    593564                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},
    596566                                                React.createElement("dl", {className: "dl-horizontal"},
    597567                                                        React.createElement("dt", null, "Institution"),
     
    625595
    626596                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},
    628598                                                d.dgnMessage, ": ", d.dgnDiagnostic
    629599                                        );
     
    653623                        return false;
    654624                }
    655                 return  React.createElement(Panel, {key: corpusHit.corpus.displayName,
     625                return  React.createElement(Panel, {key: corpusHit.corpus.title,
    656626                                                title: this.renderPanelTitle(corpusHit.corpus),
    657627                                                info: this.renderPanelInfo(corpusHit.corpus)},
Note: See TracChangeset for help on using the changeset viewer.