Merge branch 'master' into gh-pages
This commit is contained in:
@@ -31,30 +31,21 @@
|
|||||||
float: left;
|
float: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header .recline-query-editor .text-query input {
|
.header .recline-query-editor .pagination input {
|
||||||
float: left;
|
width: 30px;
|
||||||
}
|
height: 18px;
|
||||||
|
padding: 2px 4px;
|
||||||
.recline-query-editor .text-query .btn-group {
|
margin-top: -4px;
|
||||||
display: inline;
|
|
||||||
float:left;
|
|
||||||
margin-left:-2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.recline-query-editor .text-query .btn-group .dropdown-toggle {
|
|
||||||
-moz-border-radius:0px 3px 3px 0px;
|
|
||||||
-webkit-border-radius:0px 3px 3px 0px;
|
|
||||||
border-radius:0px 3px 3px 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.recline-query-editor .text-query .btn-group ul {
|
|
||||||
margin-left:-110px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.header .recline-query-editor .pagination a {
|
.header .recline-query-editor .pagination a {
|
||||||
line-height: 26px;
|
line-height: 26px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.header .recline-query-editor form button {
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
.data-view-container {
|
.data-view-container {
|
||||||
display: block;
|
display: block;
|
||||||
clear: both;
|
clear: both;
|
||||||
|
|||||||
40
src/view.js
40
src/view.js
@@ -218,28 +218,21 @@ my.QueryEditor = Backbone.View.extend({
|
|||||||
<div class="input-prepend text-query"> \
|
<div class="input-prepend text-query"> \
|
||||||
<span class="add-on"><i class="icon-search"></i></span> \
|
<span class="add-on"><i class="icon-search"></i></span> \
|
||||||
<input type="text" name="q" value="{{q}}" class="span2" placeholder="Search data ..." class="search-query" /> \
|
<input type="text" name="q" value="{{q}}" class="span2" placeholder="Search data ..." class="search-query" /> \
|
||||||
<div class="btn-group menu"> \
|
|
||||||
<a class="btn dropdown-toggle" data-toggle="dropdown"><i class="icon-cog"></i><span class="caret"></span></a> \
|
|
||||||
<ul class="dropdown-menu"> \
|
|
||||||
<li><a data-action="size" href="">Number of items to show ({{size}})</a></li> \
|
|
||||||
<li><a data-action="from" href="">Show from ({{from}})</a></li> \
|
|
||||||
</ul> \
|
|
||||||
</div> \
|
|
||||||
</div> \
|
</div> \
|
||||||
<div class="pagination"> \
|
<div class="pagination"> \
|
||||||
<ul> \
|
<ul> \
|
||||||
<li class="prev action-pagination-update"><a href="">«</a></li> \
|
<li class="prev action-pagination-update"><a href="">«</a></li> \
|
||||||
<li class="active"><a>{{from}} – {{to}}</a></li> \
|
<li class="active"><a><input name="from" type="text" value="{{from}}" /> – <input name="to" type="text" value="{{to}}" /> </a></li> \
|
||||||
<li class="next action-pagination-update"><a href="">»</a></li> \
|
<li class="next action-pagination-update"><a href="">»</a></li> \
|
||||||
</ul> \
|
</ul> \
|
||||||
</div> \
|
</div> \
|
||||||
|
<button type="submit" class="btn">Go »</button> \
|
||||||
</form> \
|
</form> \
|
||||||
',
|
',
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
'submit form': 'onFormSubmit'
|
'submit form': 'onFormSubmit'
|
||||||
, 'click .action-pagination-update': 'onPaginationUpdate'
|
, 'click .action-pagination-update': 'onPaginationUpdate'
|
||||||
, 'click .menu li a': 'onMenuItemClick'
|
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
@@ -251,7 +244,9 @@ my.QueryEditor = Backbone.View.extend({
|
|||||||
onFormSubmit: function(e) {
|
onFormSubmit: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var query = this.el.find('.text-query input').val();
|
var query = this.el.find('.text-query input').val();
|
||||||
this.model.set({q: query});
|
var newFrom = parseInt(this.el.find('input[name="from"]').val());
|
||||||
|
var newSize = parseInt(this.el.find('input[name="to"]').val()) - newFrom;
|
||||||
|
this.model.set({size: newSize, from: newFrom, q: query});
|
||||||
},
|
},
|
||||||
onPaginationUpdate: function(e) {
|
onPaginationUpdate: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -263,20 +258,6 @@ my.QueryEditor = Backbone.View.extend({
|
|||||||
}
|
}
|
||||||
this.model.set({from: newFrom});
|
this.model.set({from: newFrom});
|
||||||
},
|
},
|
||||||
onMenuItemClick: function(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
var attrName = $(e.target).attr('data-action');
|
|
||||||
var msg = _.template('New value (<%= value %>)',
|
|
||||||
{value: this.model.get(attrName)}
|
|
||||||
);
|
|
||||||
var newValue = prompt(msg);
|
|
||||||
if (newValue) {
|
|
||||||
newValue = parseInt(newValue);
|
|
||||||
var update = {};
|
|
||||||
update[attrName] = newValue;
|
|
||||||
this.model.set(update);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var tmplData = this.model.toJSON();
|
var tmplData = this.model.toJSON();
|
||||||
tmplData.to = this.model.get('from') + this.model.get('size');
|
tmplData.to = this.model.get('from') + this.model.get('size');
|
||||||
@@ -396,7 +377,7 @@ my.FacetViewer = Backbone.View.extend({
|
|||||||
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#"><i class="icon-chevron-down"></i> {{id}} {{label}}</a> \
|
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#"><i class="icon-chevron-down"></i> {{id}} {{label}}</a> \
|
||||||
<ul class="facet-items dropdown-menu"> \
|
<ul class="facet-items dropdown-menu"> \
|
||||||
{{#terms}} \
|
{{#terms}} \
|
||||||
<li><input type="checkbox" class="facet-choice js-facet-filter" value="{{term}}" name="{{term}}" /> <label for="{{term}}">{{term}} ({{count}})</label></li> \
|
<li><a class="facet-choice js-facet-filter" data-value="{{term}}">{{term}} ({{count}})</a></li> \
|
||||||
{{/terms}} \
|
{{/terms}} \
|
||||||
</ul> \
|
</ul> \
|
||||||
</div> \
|
</div> \
|
||||||
@@ -406,7 +387,7 @@ my.FacetViewer = Backbone.View.extend({
|
|||||||
|
|
||||||
events: {
|
events: {
|
||||||
'click .js-hide': 'onHide',
|
'click .js-hide': 'onHide',
|
||||||
'change .js-facet-filter': 'onFacetFilter'
|
'click .js-facet-filter': 'onFacetFilter'
|
||||||
},
|
},
|
||||||
initialize: function(model) {
|
initialize: function(model) {
|
||||||
_.bindAll(this, 'render');
|
_.bindAll(this, 'render');
|
||||||
@@ -434,10 +415,9 @@ my.FacetViewer = Backbone.View.extend({
|
|||||||
this.el.hide();
|
this.el.hide();
|
||||||
},
|
},
|
||||||
onFacetFilter: function(e) {
|
onFacetFilter: function(e) {
|
||||||
// todo: uncheck
|
var $target= $(e.target);
|
||||||
var $checkbox = $(e.target);
|
var fieldId = $target.closest('.facet-summary').attr('data-facet');
|
||||||
var fieldId = $checkbox.closest('.facet-summary').attr('data-facet');
|
var value = $target.attr('data-value');
|
||||||
var value = $checkbox.val();
|
|
||||||
this.model.queryState.addTermFilter(fieldId, value);
|
this.model.queryState.addTermFilter(fieldId, value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user