Handle click-to-deselect selected snipt

master
Nick Sergeant 2012-01-24 18:48:42 -05:00
parent 17d30a2c35
commit 26e03692e3
2 changed files with 13 additions and 5 deletions

View File

@ -7,8 +7,9 @@
initialize: function(opts) {
this.$search_query = $('input#search-query', this.el);
this.$snipts = $('section#snipts article.snipt', this.el);
this.$el = $(this.el);
this.$search_query = $('input#search-query', this.$el);
this.$snipts = $('section#snipts article.snipt', this.$el);
this.keyboardShortcuts();
this.inFieldLabels();
@ -17,6 +18,12 @@
if (this.$snipts.length) {
SniptListView = Snipt.Views.SniptListView;
SniptList = new SniptListView({ 'snipts': this.$snipts });
$('body').click(function() {
if (window.$selected) {
window.$selected.trigger('deselect');
}
});
}
// Search
@ -45,12 +52,11 @@
});
},
inFieldLabels: function () {
$('div.infield label', this.el).inFieldLabels({
$('div.infield label', this.$el).inFieldLabels({
fadeDuration: 200
});
}
});
Site.Views = {
'SiteView': SiteView
};

View File

@ -88,8 +88,9 @@
window.$selected = this.$el;
},
selectFromClick: function() {
selectFromClick: function(e) {
this.select(true);
e.stopPropagation();
}
});
SniptListView = Backbone.View.extend({
@ -103,6 +104,7 @@
this.keyboardShortcuts();
},
addSnipt: function() {
model = new SniptView({ el: this });
},