Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to click bylines #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions public/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ define([
// Localize or create a new JavaScript Template object.
var JST = window.JST = window.JST || {};

BostonGlobe = {};
BostonGlobe.vent = _.extend({}, Backbone.Events);

// Configure LayoutManager with Backbone Boilerplate defaults.
Backbone.Layout.configure({
// Allow LayoutManager to augment Backbone.View.prototype.
Expand Down
9 changes: 8 additions & 1 deletion public/app/modules/articles.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,13 @@ define([
Article.Views.AuthorListItem = Backbone.View.extend({
template: "articles/authorListItem",
tagName: "li",
events: {
"click" : "onAuthorListSelection"
},
onAuthorListSelection: function(e){
url = "http://50.17.92.83/s?key=chris&bq=(and%20byname:'" + encodeURIComponent(this.model.attributes.name) + "'%20printpublicationdate:" + moment().subtract("days", 60).format("YYYYMMDD") + ".." + moment().format("YYYYMMDD") + ")&return-fields=id&start=0&size=50&rank=-printpublicationdate";
BostonGlobe.vent.trigger("Job.Views.Form:enqueueNewJob",{url:url , name:"author: " + this.model.attributes.name});
},
serialize: function() {
return this.model.toJSON();
}
Expand All @@ -322,4 +329,4 @@ define([
});

return Article;
});
});
22 changes: 14 additions & 8 deletions public/app/modules/jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,15 @@ define([
// pass a job_list option pointing to the job list view.
initialize : function(attrs, options) {
this.job_list = options.job_list;

BostonGlobe.vent.on("Job.Views.Form:enqueueNewJob", this.enqueueNewJob, this)

},

// interrupt normal form submission to use backbon'e save
// method instead.
onSubmit : function(e) {

enqueueNewJob : function(args){
// save the url in our job model.
var url_value = this.$el.find('#url').val();
var name = this.$el.find('#query_name').val();
this.model.set({ 'url': url_value, 'name' : name });
this.model.set({ 'url':args.url, 'name' : args.name });

// save the model. On success add it to the job list!
this.model.save({}, { wait: true }).then(_.bind(function() {
Expand All @@ -133,11 +132,18 @@ define([
this.$el.find('#query_name').val('');

}, this));
},


// interrupt normal form submission to use backbon'e save
// method instead.
onSubmit : function(e) {
// save the url in our job model.
var url_value = this.$el.find('#url').val();
var name = this.$el.find('#query_name').val();
this.enqueueNewJob({url:url_value, name: name});
return false;
}
});

return Job;
});
});