Fixing autocomplete issues with saved story tagging.

This commit is contained in:
Samuel Clay 2013-11-21 17:24:52 -08:00
parent 8e7800b30b
commit ba5bff3759
4 changed files with 38 additions and 15 deletions

View file

@ -809,11 +809,11 @@ body {
.NB-feedlist .feed.NB-selected,
.NB-feeds-header.NB-selected,
.NB-feedlist .folder.NB-selected > .folder_title {
background-color: #FDED8D;
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#FFFFD2), to(#FDED8D));
background: -moz-linear-gradient(center top , #FFFFD2 0%, #FDED8D 100%);
border-top: 1px solid #EBE0BE;
border-bottom: 1px solid #E3D0AE;
background-color: #FFFFD2;
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#FFFFD2), to(#F5F9B4));
background: -moz-linear-gradient(center top , #FFFFD2 0%, #F5F9B4 100%);
border-top: 1px solid #D6D682;
border-bottom: 1px solid #D6D682;
}
.NB-feedlist .folder.NB-selected > .folder_title {
text-shadow: 0 1px 0 rgba(255, 255, 255, .5);
@ -1088,11 +1088,11 @@ body {
.NB-feed-story-header-info ::-moz-selection {
background: transparent;
background: transparent;
}
.NB-feed-story-header-info ::selection {
background: transparent;
background: transparent;
}
#story_titles {
@ -1754,10 +1754,7 @@ background: transparent;
color: #304080;
border-top: 1px solid #EFEEC3;
border-bottom: 1px solid #EFEEC3;
background-color: #FFFDDF;
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#FFFDEF), to(#FFFDDF));
background: -moz-linear-gradient(center top , #FFFDEF 0%, #FFFDDF 100%);
background: linear-gradient(center top , #FFFDEF 0%, #FFFDDF 100%);
background-color: #FFFEE2;
}
#story_titles .NB-story-title:hover:not(.NB-selected) {
@ -3076,6 +3073,14 @@ background: transparent;
overflow: hidden;
display: none;
}
.NB-sideoption-save-wrapper ::-moz-selection {
background: transparent;
}
.NB-sideoption-save-wrapper ::selection {
background: transparent;
}
.NB-sideoption-save-wrapper.NB-active {
display: block;
}

View file

@ -79,7 +79,8 @@ NEWSBLUR.Views.StorySaveView = Backbone.View.extend({
fieldName: "tags",
availableTags: this.model.all_tags(),
autocomplete: {delay: 0, minLength: 0},
showAutocompleteOnFocus: false,
showAutocompleteOnFocus: true,
createTagOnBlur: false,
removeConfirmation: true,
caseSensitive: false,
allowDuplicates: false,
@ -91,7 +92,6 @@ NEWSBLUR.Views.StorySaveView = Backbone.View.extend({
singleFieldNode: null,
tabIndex: null,
// Events
afterTagAdded: function(event, options) {
options = options || {};
self.resize();
@ -108,6 +108,7 @@ NEWSBLUR.Views.StorySaveView = Backbone.View.extend({
}
});
$tag_input.tagit('addClassAutocomplete', 'NB-tagging-autocomplete');
if (options.animate_scroll) {
var $scroll_container = NEWSBLUR.reader.$s.$story_titles;
if (_.contains(['split', 'full'], NEWSBLUR.assets.preference('story_layout'))) {

View file

@ -76,6 +76,7 @@ NEWSBLUR.Views.StoryTitleView = Backbone.View.extend({
});
this.text_view.fetch_and_render(this.model, temporary_text);
this.$(".NB-story-detail").html(this.text_view.$el);
this.story_detail.render_starred_tags();
} else {
this.story_detail = new NEWSBLUR.Views.StoryDetailView({
model: this.model,
@ -85,6 +86,8 @@ NEWSBLUR.Views.StoryTitleView = Backbone.View.extend({
}).render();
this.$(".NB-story-detail").html(this.story_detail.$el);
this.story_detail.watch_images_for_story_height();
this.story_detail.render_starred_tags();
}
},

View file

@ -35,6 +35,7 @@
readOnly : false, // Disables editing.
removeConfirmation: false, // Require confirmation to remove tags.
tagLimit : null, // Max number of tags allowed (null for unlimited).
createTagOnBlur : true, // Create a tag when input loses focus.
// Used for autocomplete, unless you override `autocomplete.source`.
availableTags : [],
@ -266,14 +267,19 @@
}
// Autocomplete will create its own tag from a selection and close automatically.
if (!that.tagInput.data('autocomplete-open')) {
var menu = that.tagInput.autocomplete('widget').data('ui-menu');
if (!(that.tagInput.data('autocomplete-open') &&
that.tagInput.data('autocomplete-focus'))) {
that.createTag(that._cleanedInput());
}
}
}).blur(function(e){
// Create a tag when the element loses focus.
// If autocomplete is enabled and suggestion was clicked, don't add it.
if (!that.tagInput.data('autocomplete-open')) {
if (!this.createTagOnBlur) return;
if (!(that.tagInput.data('autocomplete-open') &&
that.tagInput.data('autocomplete-focus'))) {
that.createTag(that._cleanedInput());
}
});
@ -295,6 +301,10 @@
that.tagInput.data('autocomplete-open', true);
}).bind('autocompleteclose', function(event, ui) {
that.tagInput.data('autocomplete-open', false);
}).bind('autocompletefocus', function(event, ui) {
that.tagInput.data('autocomplete-focus', true);
}).bind('autocompletefocus', function(event, ui) {
that.tagInput.data('autocomplete-focus', false);
});
}
},
@ -393,6 +403,10 @@
value = $.trim(value);
if (this.tagInput.data('autocomplete-open')) {
this.tagInput.autocomplete('close');
}
if(this.options.preprocessTag) {
value = this.options.preprocessTag(value);
}