mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-31 21:41:33 +00:00
Merge branch 'master' into chooser
Conflicts: media/js/newsblur/reader_classifier.js media/js/newsblur/reader_manage_feed.js media/js/underscore.js
This commit is contained in:
commit
20195f4345
15 changed files with 679 additions and 807 deletions
|
@ -68,7 +68,7 @@ def save_classifier(request):
|
|||
_save_classifier(MClassifierAuthor, 'author')
|
||||
_save_classifier(MClassifierTag, 'tag')
|
||||
_save_classifier(MClassifierTitle, 'title')
|
||||
_save_classifier(MClassifierFeed, 'publisher')
|
||||
_save_classifier(MClassifierFeed, 'feed')
|
||||
|
||||
logging.info(" ---> [%s] Feed training: %s" % (request.user, feed))
|
||||
|
||||
|
|
|
@ -793,8 +793,8 @@ background: transparent;
|
|||
margin-left: 24px;
|
||||
}
|
||||
|
||||
#story_titles .NB-feedbar .NB-feedbar-manage-feed {
|
||||
background: transparent url("../img/icons/silk/cog.png") no-repeat center center;
|
||||
#story_titles .NB-feedbar .NB-feedbar-train-feed {
|
||||
background: transparent url("../img/icons/silk/bricks.png") no-repeat center center;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
/* display: none;*/
|
||||
|
@ -908,12 +908,12 @@ background: transparent;
|
|||
|
||||
#story_titles .NB-feedbar .NB-feed-like {
|
||||
right: 24px;
|
||||
background: transparent url('../img/reader/thumbs-up.png') no-repeat 0 0;
|
||||
background: transparent url('../img/reader/thumbs_up.png') no-repeat 0 0;
|
||||
}
|
||||
|
||||
#story_titles .NB-feedbar .NB-feed-dislike {
|
||||
right: 4px;
|
||||
background: transparent url('../img/reader/thumbs-down.png') no-repeat 0 -4px;
|
||||
background: transparent url('../img/reader/thumbs_down.png') no-repeat 0 -4px;
|
||||
}
|
||||
|
||||
#story_titles .feed .unread_count.unread_count_full {
|
||||
|
@ -999,12 +999,12 @@ background: transparent;
|
|||
|
||||
#story_titles .NB-story-like {
|
||||
left: 22px;
|
||||
background: transparent url('../img/reader/thumbs-up.png') no-repeat 2px 0;
|
||||
background: transparent url('../img/reader/thumbs_up.png') no-repeat 2px 0;
|
||||
}
|
||||
|
||||
#story_titles .NB-story-dislike {
|
||||
left: 0px;
|
||||
background: transparent url('../img/reader/thumbs-down.png') no-repeat 4px -4px;
|
||||
background: transparent url('../img/reader/thumbs_down.png') no-repeat 4px -4px;
|
||||
}
|
||||
|
||||
#story_titles .story.read {
|
||||
|
@ -1891,17 +1891,17 @@ a.NB-splash-link:hover {
|
|||
}
|
||||
|
||||
.NB-classifier .NB-modal-loading {
|
||||
margin: 8px 120px 0 0;
|
||||
margin: 8px 0px 0 0;
|
||||
}
|
||||
|
||||
.NB-classifier h2.NB-like {
|
||||
.NB-modal-classifiers h2.NB-like {
|
||||
color: #007000;
|
||||
}
|
||||
|
||||
.NB-classifier h2.NB-dislike {
|
||||
.NB-modal-classifiers h2.NB-dislike {
|
||||
color: #700000;
|
||||
}
|
||||
.NB-classifier .NB-classifier-facet-disabled {
|
||||
.NB-modal-classifiers .NB-classifier-facet-disabled {
|
||||
color: #A0A0A0;
|
||||
}
|
||||
|
||||
|
@ -1910,7 +1910,7 @@ a.NB-splash-link:hover {
|
|||
text-shadow: none;
|
||||
}
|
||||
|
||||
.NB-classifier .NB-classifier-title-highlight {
|
||||
.NB-modal-classifiers .NB-classifier-title-highlight {
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
|
@ -1918,57 +1918,45 @@ a.NB-splash-link:hover {
|
|||
margin: 6px 0 0 0;
|
||||
}
|
||||
|
||||
.NB-classifier .NB-publisher .NB-classifier-authors input {
|
||||
.NB-modal-classifiers .NB-publisher .NB-classifier-authors input {
|
||||
float: none;
|
||||
margin: 4px 6px 0 0;
|
||||
}
|
||||
|
||||
.NB-classifier .NB-classifier-container {
|
||||
.NB-modal-classifiers .NB-classifier-container {
|
||||
white-space: nowrap;
|
||||
float: left;
|
||||
display: block;
|
||||
margin: 2px 6px 6px 0;
|
||||
}
|
||||
|
||||
.NB-classifier .NB-classifier-container .NB-classifier {
|
||||
.NB-modal-classifiers .NB-classifier-container .NB-classifier {
|
||||
margin: 0 2px 0 0;
|
||||
}
|
||||
|
||||
.NB-classifier .NB-classifier-tag {
|
||||
background-color: #E0E0FF;
|
||||
padding: 2px 6px 2px 0px;
|
||||
}
|
||||
|
||||
.NB-classifier .NB-classifier-tag input[type=checkbox] {
|
||||
margin: 0px 4px 0px;
|
||||
float: none;
|
||||
}
|
||||
|
||||
.NB-classifier .NB-classifier-tag label {
|
||||
}
|
||||
|
||||
.NB-classifier .NB-classifier-tag-count {
|
||||
.NB-classifier .NB-classifier-count {
|
||||
font-size: 10px;
|
||||
font-weight: bold;
|
||||
margin: 0 6px 0 2px;
|
||||
}
|
||||
|
||||
.NB-classifier .NB-modal-title .NB-classifier-like {
|
||||
.NB-modal-classifiers .NB-modal-title .NB-classifier-title-like {
|
||||
color: #3D931B;
|
||||
padding-left: 20px;
|
||||
background: transparent url('../img/reader/thumbs_up.png') no-repeat 0 6px;
|
||||
|
||||
}
|
||||
|
||||
.NB-classifier .NB-modal-title .NB-classifier-dislike {
|
||||
.NB-modal-classifiers .NB-modal-title .NB-classifier-title-dislike {
|
||||
color: #932C15;
|
||||
padding-right: 20px;
|
||||
background: transparent url('../img/reader/thumbs_down.png') no-repeat right 2px;
|
||||
}
|
||||
|
||||
.simplemodal-wrap {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.NB-classifiers {
|
||||
}
|
||||
|
||||
|
||||
/* ====================== */
|
||||
/* = Classifier Trainer = */
|
||||
/* ====================== */
|
||||
|
@ -1996,7 +1984,7 @@ a.NB-splash-link:hover {
|
|||
.NB-modal-trainer .NB-classifier-trainer-counts {
|
||||
float: right;
|
||||
color: #606060;
|
||||
font-size: 17px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.NB-modal-trainer .NB-trainer-points li {
|
||||
|
@ -2168,12 +2156,17 @@ a.NB-splash-link:hover {
|
|||
padding: 0 18px 18px 0;
|
||||
}
|
||||
|
||||
.NB-manage .NB-classifier-like {
|
||||
.NB-manage .NB-classifier-title-like {
|
||||
color: #3D931B;
|
||||
padding-left: 20px;
|
||||
background: transparent url('../img/reader/thumbs_up.png') no-repeat 0 0;
|
||||
|
||||
}
|
||||
|
||||
.NB-manage .NB-classifier-dislike {
|
||||
.NB-manage .NB-classifier-title-dislike {
|
||||
color: #932C15;
|
||||
padding-left: 20px;
|
||||
background: transparent url('../img/reader/thumbs_down.png') no-repeat 0 0;
|
||||
}
|
||||
|
||||
.NB-manage .NB-manage-classifier {
|
||||
|
@ -2288,9 +2281,12 @@ background: transparent;
|
|||
display: block;
|
||||
margin: 2px 6px 6px 0;
|
||||
cursor: pointer;
|
||||
padding: 0 9px 0 4px;
|
||||
padding: 0 30px 0 26px;
|
||||
font-size: 12px;
|
||||
text-transform: uppercase;
|
||||
background-color: #F5CD09;
|
||||
position: relative;
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
|
||||
.NB-classifiers .NB-classifier input[type=checkbox] {
|
||||
|
@ -2308,43 +2304,143 @@ background: transparent;
|
|||
}
|
||||
|
||||
.NB-classifiers .NB-classifier label b {
|
||||
color: #303030;
|
||||
color: #957D09;
|
||||
text-shadow: none;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.NB-classifiers .NB-classifier.NB-classifier-tag {
|
||||
background-color: #FFA200;
|
||||
}
|
||||
.NB-classifiers .NB-classifier.NB-classifier-tag label {
|
||||
text-shadow: 1px 1px 0 #cF7200;
|
||||
}
|
||||
|
||||
.NB-classifiers .NB-classifier.NB-classifier-title {
|
||||
background-color: #FF7940;
|
||||
}
|
||||
.NB-classifiers .NB-classifier.NB-classifier-title label {
|
||||
text-shadow: 1px 1px 0 #cF4910;
|
||||
}
|
||||
|
||||
.NB-classifiers .NB-classifier.NB-classifier-author {
|
||||
background-color: #60D6A7;
|
||||
}
|
||||
.NB-classifiers .NB-classifier.NB-classifier-author label {
|
||||
text-shadow: 1px 1px 0 #30a677;
|
||||
}
|
||||
|
||||
.NB-classifiers .NB-classifier.NB-classifier-publisher {
|
||||
background-color: #6a93d4;
|
||||
}
|
||||
.NB-classifiers .NB-classifier.NB-classifier-publisher label {
|
||||
text-shadow: 1px 1px 0 #3A63A4;
|
||||
.NB-classifiers .NB-classifier label span {
|
||||
text-shadow: 1px 1px 0 #F4E576;
|
||||
}
|
||||
|
||||
.NB-classifiers .NB-classifier.NB-classifier-facet-disabled {
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.NB-classifiers .NB-classifier input {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.NB-classifiers .NB-classifier .feed_favicon {
|
||||
margin-top: -2px;
|
||||
}
|
||||
|
||||
.NB-classifiers .NB-classifier .NB-classifier-icon-like {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
background: transparent url('../img/reader/thumbs_up.png') no-repeat 0 0;
|
||||
position: absolute;
|
||||
left: 6px;
|
||||
top: 2px;
|
||||
opacity: .2;
|
||||
}
|
||||
|
||||
.NB-classifiers .NB-classifier .NB-classifier-icon-dislike {
|
||||
width: 27px;
|
||||
height: 22px;
|
||||
position: absolute;
|
||||
top: -1px;
|
||||
right: -1px;
|
||||
background: transparent url('../img/reader/thumbs_down.png') no-repeat 5px -1px;
|
||||
opacity: .2;
|
||||
}
|
||||
|
||||
.NB-classifiers .NB-classifier .NB-classifier-icon-dislike-inner {
|
||||
margin: 4px 4px 0 0;
|
||||
width: 18px;
|
||||
height: 13px;
|
||||
border-left: 1px solid #EBEBE1;
|
||||
}
|
||||
|
||||
.NB-classifiers .NB-classifier.NB-classifier-like {
|
||||
background-color: #34912E;
|
||||
border: 1px solid #202020;
|
||||
-webkit-box-shadow: 1px 1px 1px #BDC0D7;
|
||||
-moz-box-shadow: 1px 1px 1px #BDC0D7;
|
||||
box-shadow: 1px 1px 1px #BDC0D7;
|
||||
}
|
||||
.NB-classifiers .NB-classifier.NB-classifier-dislike {
|
||||
background-color: #A90103;
|
||||
border: 1px solid #000;
|
||||
-webkit-box-shadow: 1px 1px 1px #BDC0D7;
|
||||
-moz-box-shadow: 1px 1px 1px #BDC0D7;
|
||||
box-shadow: 1px 1px 1px #BDC0D7;
|
||||
}
|
||||
|
||||
.NB-classifiers .NB-classifier.NB-classifier-hover-like {
|
||||
background-color: #54A54E;
|
||||
}
|
||||
.NB-classifiers .NB-classifier.NB-classifier-like.NB-classifier-hover-like {
|
||||
background-color: #34912E;
|
||||
}
|
||||
.NB-classifiers .NB-classifier.NB-classifier-dislike.NB-classifier-hover-like {
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
.NB-classifiers .NB-classifier.NB-classifier-like label b,
|
||||
.NB-classifiers .NB-classifier.NB-classifier-hover-like label b {
|
||||
color: white;
|
||||
}
|
||||
.NB-classifiers .NB-classifier.NB-classifier-like label span,
|
||||
.NB-classifiers .NB-classifier.NB-classifier-hover-like label span {
|
||||
color: white;
|
||||
text-shadow: 1px 1px 0 #254E18;
|
||||
}
|
||||
.NB-classifiers .NB-classifier.NB-classifier-like .NB-classifier-icon-dislike,
|
||||
.NB-classifiers .NB-classifier.NB-classifier-hover-like .NB-classifier-icon-dislike {
|
||||
opacity: .1;
|
||||
}
|
||||
.NB-classifiers .NB-classifier.NB-classifier-dislike .NB-classifier-icon-dislike,
|
||||
.NB-classifiers .NB-classifier.NB-classifier-hover-dislike .NB-classifier-icon-dislike {
|
||||
opacity: 1;
|
||||
}
|
||||
.NB-classifiers .NB-classifier.NB-classifier-dislike .NB-classifier-icon-like,
|
||||
.NB-classifiers .NB-classifier.NB-classifier-hover-dislike .NB-classifier-icon-like {
|
||||
opacity: .1;
|
||||
}
|
||||
.NB-classifiers .NB-classifier.NB-classifier-dislike.NB-classifier-hover-like .NB-classifier-icon-like {
|
||||
opacity: 1;
|
||||
}
|
||||
.NB-classifiers .NB-classifier.NB-classifier-dislike.NB-classifier-hover-like .NB-classifier-icon-dislike {
|
||||
opacity: .1;
|
||||
}
|
||||
.NB-classifiers .NB-classifier.NB-classifier-hover-like.NB-classifier-hover-dislike .NB-classifier-icon-dislike {
|
||||
opacity: 1;
|
||||
}
|
||||
.NB-classifiers .NB-classifier.NB-classifier-hover-like.NB-classifier-hover-dislike .NB-classifier-icon-like {
|
||||
opacity: .1;
|
||||
}
|
||||
.NB-classifiers .NB-classifier.NB-classifier-like .NB-classifier-icon-like,
|
||||
.NB-classifiers .NB-classifier.NB-classifier-hover-like .NB-classifier-icon-like,
|
||||
.NB-classifiers .NB-classifier.NB-classifier-dislike .NB-classifier-icon-dislike,
|
||||
.NB-classifiers .NB-classifier.NB-classifier-hover-dislike .NB-classifier-icon-dislike {
|
||||
opacity: 1;
|
||||
}
|
||||
.NB-classifiers .NB-classifier.NB-classifier-hover-dislike {
|
||||
background-color: #C92123;
|
||||
}
|
||||
.NB-classifiers .NB-classifier.NB-classifier-like.NB-classifier-hover-dislike {
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
.NB-classifiers .NB-classifier.NB-classifier-like.NB-classifier-hover-like.NB-classifier-hover-dislike {
|
||||
background-color: #C92123;
|
||||
}
|
||||
.NB-classifiers .NB-classifier.NB-classifier-dislike.NB-classifier-hover-like.NB-classifier-hover-dislike {
|
||||
border: 1px solid #000;
|
||||
background-color: #A90103;
|
||||
}
|
||||
.NB-classifiers .NB-classifier.NB-classifier-dislike .NB-classifier-icon-dislike-inner,
|
||||
.NB-classifiers .NB-classifier.NB-classifier-hover-dislike .NB-classifier-icon-dislike-inner {
|
||||
border-left-color: #C17C52;
|
||||
}
|
||||
.NB-classifiers .NB-classifier.NB-classifier-dislike label b,
|
||||
.NB-classifiers .NB-classifier.NB-classifier-hover-dislike label b {
|
||||
color: white;
|
||||
}
|
||||
.NB-classifiers .NB-classifier.NB-classifier-dislike label span,
|
||||
.NB-classifiers .NB-classifier.NB-classifier-hover-dislike label span {
|
||||
color: white;
|
||||
text-shadow: 1px 1px 0 #7F1012;
|
||||
}
|
||||
/* =================== */
|
||||
/* = Mouse Indicator = */
|
||||
/* =================== */
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.4 KiB |
BIN
media/img/reader/thumbs_down.png
Normal file
BIN
media/img/reader/thumbs_down.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 421 B |
BIN
media/img/reader/thumbs_up.png
Normal file
BIN
media/img/reader/thumbs_up.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 358 B |
158
media/js/inflector.js
Normal file
158
media/js/inflector.js
Normal file
|
@ -0,0 +1,158 @@
|
|||
// Naive English transformations on words.
|
||||
window.Inflector = {
|
||||
|
||||
small : "(a|an|and|as|at|but|by|en|for|if|in|of|on|or|the|to|v[.]?|via|vs[.]?)",
|
||||
punct : "([!\"#$%&'()*+,./:;<=>?@[\\\\\\]^_`{|}~-]*)",
|
||||
|
||||
// Titleize function by John Resig after John Gruber. MIT Licensed.
|
||||
titleize : function(s) {
|
||||
s = s.replace(/[-.\/_]/g, ' ').replace(/\s+/gm, ' ');
|
||||
var cap = this.capitalize;
|
||||
var parts = [], split = /[:.;?!] |(?: |^)["Ò]/g, index = 0;
|
||||
while (true) {
|
||||
var m = split.exec(s);
|
||||
parts.push( s.substring(index, m ? m.index : s.length)
|
||||
.replace(/\b([A-Za-z][a-z.'Õ]*)\b/g, function(all){
|
||||
return (/[A-Za-z]\.[A-Za-z]/).test(all) ? all : cap(all);
|
||||
})
|
||||
.replace(RegExp("\\b" + this.small + "\\b", "ig"), this.lowercase)
|
||||
.replace(RegExp("^" + this.punct + this.small + "\\b", "ig"), function(all, punct, word) {
|
||||
return punct + cap(word);
|
||||
})
|
||||
.replace(RegExp("\\b" + this.small + this.punct + "$", "ig"), cap));
|
||||
index = split.lastIndex;
|
||||
if ( m ) parts.push( m[0] );
|
||||
else break;
|
||||
}
|
||||
return parts.join("").replace(/ V(s?)\. /ig, " v$1. ")
|
||||
.replace(/(['Õ])S\b/ig, "$1s")
|
||||
.replace(/\b(AT&T|Q&A)\b/ig, function(all){
|
||||
return all.toUpperCase();
|
||||
});
|
||||
},
|
||||
|
||||
// Delegate to the ECMA5 String.prototype.trim function, if available.
|
||||
trim : function(s) {
|
||||
return s.trim ? s.trim() : s.replace(/^\s+|\s+$/g, '');
|
||||
},
|
||||
|
||||
// Trim leading and trailing non-whitespace characters, and add ellipses.
|
||||
// Try to find natural breaks in the sentence, and avoid breaking HTML fragments.
|
||||
trimExcerpt : function(s) {
|
||||
s = s.replace(/^([^<>]{0,100}?[.,!]|[^<>\s]+)/g, '');
|
||||
s = s.replace(/(([.,!]\s?)[^<>]{0,100}?|[^<>\s]+)$/g, '$2');
|
||||
return '…' + s + '…';
|
||||
},
|
||||
|
||||
camelize : function(s) {
|
||||
var parts = s.split('-'), len = parts.length;
|
||||
if (len == 1) return parts[0];
|
||||
|
||||
var camelized = s.charAt(0) == '-'
|
||||
? parts[0].charAt(0).toUpperCase() + parts[0].substring(1)
|
||||
: parts[0];
|
||||
|
||||
for (var i = 1; i < len; i++)
|
||||
camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1);
|
||||
|
||||
return camelized;
|
||||
},
|
||||
|
||||
lowercase : function(s) {
|
||||
return s.toLowerCase();
|
||||
},
|
||||
|
||||
capitalize : function(s) {
|
||||
return s.charAt(0).toUpperCase() + s.substring(1).toLowerCase();
|
||||
},
|
||||
|
||||
underscore : function(s) {
|
||||
return s.replace(/::/g, '/').replace(/([A-Z]+)([A-Z][a-z])/g,'$1_$2').replace(/([a-z\d])([A-Z])/g,'$1_$2').replace(/-/g,'_').toLowerCase();
|
||||
},
|
||||
|
||||
spacify : function(s) {
|
||||
return s.replace(/_/g, ' ');
|
||||
},
|
||||
|
||||
dasherize : function(s) {
|
||||
return s.replace(/_/g,'-');
|
||||
},
|
||||
|
||||
singularize : function(s) {
|
||||
return s.replace(/s$/, '');
|
||||
},
|
||||
|
||||
// Only works for words that pluralize by adding an 's', end in a 'y', or
|
||||
// that we've special-cased. Not comprehensive.
|
||||
pluralize : function(s, count) {
|
||||
if (count == 1) return s;
|
||||
if (s == 'person') return 'people';
|
||||
if (s.match(/y$/i)) return s.replace(/y$/i, 'ies');
|
||||
return s + 's';
|
||||
},
|
||||
|
||||
classify : function(s) {
|
||||
return this.camelize(this.capitalize(this.dasherize(this.singularize(s))));
|
||||
},
|
||||
|
||||
possessivize : function(s) {
|
||||
var endsInS = s.charAt(s.length - 1) == 's';
|
||||
return s + (endsInS ? "'" : "'s");
|
||||
},
|
||||
|
||||
truncate : function(s, length, truncation) {
|
||||
length = length || 30;
|
||||
truncation = _.isUndefined(truncation) ? '...' : truncation;
|
||||
return s.length > length ? s.slice(0, length - truncation.length) + truncation : s;
|
||||
},
|
||||
|
||||
// Convert a string (usually a title), to something appropriate for use in a URL.
|
||||
// Apostrophes and quotes are removed, non-word-chars become spaces, whitespace
|
||||
// is trimmed, lowercased, and spaces become dashes.
|
||||
sluggify : function(s) {
|
||||
return $.trim(s.replace(/['"]+/g, '').replace(/\W+/g, ' ')).toLowerCase().replace(/\s+/g, '-');
|
||||
},
|
||||
|
||||
commify : function(list, options) {
|
||||
var words = [];
|
||||
_.each(list, function(word, i) {
|
||||
if (options.quote) word = '"' + word + '"';
|
||||
words.push(word);
|
||||
var end = i == list.length - 1 ? '' :
|
||||
(i == list.length - 2) && options.conjunction ? ', ' + options.conjunction + ' ' :
|
||||
', ';
|
||||
words.push(end);
|
||||
});
|
||||
return words.join('');
|
||||
},
|
||||
|
||||
// Convert bytes into KB or MB
|
||||
bytesToMB : function(bytes) {
|
||||
var byteSize = Math.round(bytes / 1024 * 100) * 0.01;
|
||||
var suffix = 'KB';
|
||||
if (byteSize > 1000) {
|
||||
byteSize = Math.round(byteSize * 0.001 * 100) * 0.01;
|
||||
suffix = 'MB';
|
||||
}
|
||||
var sizeParts = byteSize.toString().split('.');
|
||||
byteSize = sizeParts[0] + (sizeParts.length > 1 ? '.' + sizeParts[1].substr(0,1) : '');
|
||||
return byteSize + ' ' + suffix;
|
||||
},
|
||||
|
||||
// Normalize an entered-by-hand url, trimming and adding the protocol, if missing.
|
||||
normalizeUrl : function(s) {
|
||||
s = Inflector.trim(s);
|
||||
if (!s) return null;
|
||||
return (/^https?:\/\//).test(s) ? s : 'http://' + s;
|
||||
},
|
||||
|
||||
// From Prototype.js. Strip out HTML tags.
|
||||
stripTags : function(s) {
|
||||
return s.replace(/<\w+(\s+("[^"]*"|'[^']*'|[^>])+)?>|<\/\w+>/gi, '');
|
||||
},
|
||||
|
||||
escapeRegExp : function(s) {
|
||||
return s.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
|
||||
}
|
||||
|
||||
};
|
|
@ -458,10 +458,10 @@ NEWSBLUR.AssetModel.Reader.prototype = {
|
|||
var folders = NEWSBLUR.Preferences.collapsed_folders;
|
||||
var changed = false;
|
||||
|
||||
if (is_collapsed && NEWSBLUR.Preferences.collapsed_folders.indexOf(folder_title) == -1) {
|
||||
if (is_collapsed && _.contains(NEWSBLUR.Preferences.collapsed_folders, folder_title)) {
|
||||
NEWSBLUR.Preferences.collapsed_folders.push(folder_title);
|
||||
changed = true;
|
||||
} else if (!is_collapsed && NEWSBLUR.Preferences.collapsed_folders.indexOf(folder_title) != -1) {
|
||||
} else if (!is_collapsed && _.contains(NEWSBLUR.Preferences.collapsed_folders, folder_title)) {
|
||||
NEWSBLUR.Preferences.collapsed_folders = _.without(folders, folder_title);
|
||||
changed = true;
|
||||
}
|
||||
|
|
|
@ -470,40 +470,39 @@
|
|||
}
|
||||
},
|
||||
|
||||
show_next_feed: function(direction) {
|
||||
show_next_feed: function(direction, $current_feed) {
|
||||
var $feed_list = this.$s.$feed_list;
|
||||
var $current_feed = $('.selected', $feed_list);
|
||||
var $current_feed = $current_feed || $('.selected', $feed_list);
|
||||
var $next_feed,
|
||||
scroll;
|
||||
var $feeds = $('.feed', $feed_list);
|
||||
|
||||
if (!$current_feed.length) {
|
||||
$current_feed = $('.feed:first', $feed_list);
|
||||
$next_feed = $current_feed;
|
||||
} else if (direction == 1) {
|
||||
$next_feed = $current_feed.next('.feed');
|
||||
} else if (direction == -1) {
|
||||
$next_feed = $current_feed.prev('.feed');
|
||||
}
|
||||
|
||||
if (!$next_feed.length) {
|
||||
if (direction == 1) {
|
||||
$next_feed = $current_feed.parents('.folder').next('.folder').find('.feed:first');
|
||||
} else if (direction == -1) {
|
||||
$next_feed = $current_feed.parents('.folder').prev('.folder').find('.feed:last');
|
||||
}
|
||||
} else {
|
||||
$feeds.each(function(i) {
|
||||
if (this == $current_feed[0]) {
|
||||
current_feed = i;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
$next_feed = $feeds.eq(current_feed+direction);
|
||||
}
|
||||
|
||||
var feed_id = $next_feed.data('feed_id');
|
||||
if (feed_id) {
|
||||
if (feed_id && feed_id == this.active_feed) {
|
||||
this.show_next_feed(direction, $next_feed);
|
||||
} else if (feed_id) {
|
||||
var position = $feed_list.scrollTop() + $next_feed.offset().top - $next_feed.outerHeight();
|
||||
var showing = $feed_list.height();
|
||||
var showing = $feed_list.height() - 100;
|
||||
if (position > showing) {
|
||||
scroll = position;
|
||||
} else {
|
||||
scroll = 0;
|
||||
}
|
||||
$feed_list.scrollTop(scroll);
|
||||
// this.open_feed(feed_id);
|
||||
this.open_feed(feed_id, false, $next_feed);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -633,7 +632,7 @@
|
|||
]),
|
||||
$.make('ul', { className: 'folder' })
|
||||
]).css({'display': 'none'});
|
||||
var is_collapsed = NEWSBLUR.Preferences.collapsed_folders.indexOf(o) != -1;
|
||||
var is_collapsed = _.contains(NEWSBLUR.Preferences.collapsed_folders, o);
|
||||
|
||||
(function($feeds, $folder, is_collapsed, collapsed_parent) {
|
||||
var continue_loading_next_feed = function() {
|
||||
|
@ -698,7 +697,7 @@
|
|||
$.make('img', { className: 'feed_favicon', src: NEWSBLUR.Globals.google_favicon_url + feed.feed_link }),
|
||||
$.make('span', { className: 'feed_title' }, [
|
||||
feed.feed_title,
|
||||
$.make('span', { className: 'NB-feedbar-manage-feed', title: 'Manage Intelligence' }),
|
||||
$.make('span', { className: 'NB-feedbar-train-feed', title: 'Train Intelligence' }),
|
||||
(type == 'story' && $.make('span', { className: 'NB-feedbar-statistics', title: 'Statistics' }))
|
||||
]),
|
||||
(type == 'story' && $.make('div', { className: 'NB-feedbar-last-updated' }, [
|
||||
|
@ -2382,10 +2381,6 @@
|
|||
$.make('div', { className: 'NB-menu-manage-image' }),
|
||||
$.make('div', { className: 'NB-menu-manage-title' }, 'Intelligence trainer')
|
||||
]),
|
||||
$.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-feed-manage' }, [
|
||||
$.make('div', { className: 'NB-menu-manage-image' }),
|
||||
$.make('div', { className: 'NB-menu-manage-title' }, 'Intelligence manager')
|
||||
]),
|
||||
$.make('li', { className: 'NB-menu-separator' }),
|
||||
$.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-delete NB-menu-manage-feed-delete' }, [
|
||||
$.make('div', { className: 'NB-menu-manage-image' }),
|
||||
|
@ -2765,7 +2760,7 @@
|
|||
self.model.classifiers.titles[value] = score;
|
||||
} else if (name == 'author') {
|
||||
self.model.classifiers.authors[value] = score;
|
||||
} else if (name == 'publisher') {
|
||||
} else if (name == 'feed') {
|
||||
self.model.classifiers.feeds[feed_id] = score;
|
||||
}
|
||||
} else {
|
||||
|
@ -2775,7 +2770,7 @@
|
|||
delete self.model.classifiers.titles[value];
|
||||
} else if (name == 'author' && self.model.classifiers.authors[value] == score) {
|
||||
delete self.model.classifiers.authors[value];
|
||||
} else if (name == 'publisher' && self.model.classifiers.feeds[feed_id] == score) {
|
||||
} else if (name == 'feed' && self.model.classifiers.feeds[feed_id] == score) {
|
||||
delete self.model.classifiers.feeds[feed_id];
|
||||
}
|
||||
}
|
||||
|
@ -3332,10 +3327,10 @@
|
|||
$.targetIs(e, { tagSelector: '.NB-feedbar-statistics' }, function($t, $p){
|
||||
self.open_feed_statistics_modal();
|
||||
});
|
||||
$.targetIs(e, { tagSelector: '.NB-feedbar-manage-feed' }, function($t, $p){
|
||||
$.targetIs(e, { tagSelector: '.NB-feedbar-train-feed' }, function($t, $p){
|
||||
e.preventDefault();
|
||||
if (!$('.NB-task-manage').hasClass('NB-disabled')) {
|
||||
self.open_manage_feed_modal();
|
||||
self.open_feed_intelligence_modal(1, this.active_feed, true);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -3405,13 +3400,6 @@
|
|||
self.show_manage_menu('site', $t);
|
||||
}
|
||||
});
|
||||
$.targetIs(e, { tagSelector: '.NB-menu-manage-feed-manage' }, function($t, $p){
|
||||
e.preventDefault();
|
||||
if (!$t.hasClass('NB-disabled')) {
|
||||
var feed_id = $t.parents('.NB-menu-manage').data('feed_id');
|
||||
self.open_manage_feed_modal(feed_id);
|
||||
}
|
||||
});
|
||||
$.targetIs(e, { tagSelector: '.NB-menu-manage-feed-train' }, function($t, $p){
|
||||
e.preventDefault();
|
||||
if (!$t.hasClass('NB-disabled')) {
|
||||
|
@ -3769,6 +3757,22 @@
|
|||
$document.bind('keydown', 'k', function(e) {
|
||||
e.preventDefault();
|
||||
self.show_next_story(-1);
|
||||
});
|
||||
$document.bind('keydown', 'shift+j', function(e) {
|
||||
e.preventDefault();
|
||||
self.show_next_feed(1);
|
||||
});
|
||||
$document.bind('keydown', 'shift+k', function(e) {
|
||||
e.preventDefault();
|
||||
self.show_next_feed(-1);
|
||||
});
|
||||
$document.bind('keydown', 'shift+down', function(e) {
|
||||
e.preventDefault();
|
||||
self.show_next_feed(1);
|
||||
});
|
||||
$document.bind('keydown', 'shift+up', function(e) {
|
||||
e.preventDefault();
|
||||
self.show_next_feed(-1);
|
||||
});
|
||||
$document.bind('keydown', 'left', function(e) {
|
||||
e.preventDefault();
|
||||
|
|
|
@ -11,7 +11,7 @@ NEWSBLUR.ReaderClassifierTrainer = function(options) {
|
|||
'modal_loaded': false
|
||||
};
|
||||
this.cache = {};
|
||||
this.trainer_iterator = 0;
|
||||
this.trainer_iterator = -1;
|
||||
this.feed_id = null;
|
||||
this.options = $.extend({}, defaults, options);
|
||||
this.score = this.options['score'];
|
||||
|
@ -34,7 +34,7 @@ NEWSBLUR.ReaderClassifierFeed = function(feed_id, options) {
|
|||
};
|
||||
this.cache = {};
|
||||
this.feed_id = feed_id;
|
||||
this.trainer_iterator = 0;
|
||||
this.trainer_iterator = -1;
|
||||
this.options = $.extend({}, defaults, options);
|
||||
this.score = this.options['score'];
|
||||
this.model = NEWSBLUR.AssetModel.reader();
|
||||
|
@ -61,16 +61,14 @@ NEWSBLUR.ReaderClassifierStory = function(story_id, feed_id, options) {
|
|||
this.runner_story();
|
||||
};
|
||||
|
||||
var classifier = {
|
||||
var classifier_prototype = {
|
||||
|
||||
runner_trainer: function() {
|
||||
this.user_classifiers = {};
|
||||
|
||||
this.make_trainer_intro();
|
||||
this.get_feeds_trainer();
|
||||
this.handle_select_checkboxes();
|
||||
this.handle_cancel();
|
||||
this.handle_select_title();
|
||||
this.open_modal();
|
||||
|
||||
this.$modal.parent().bind('click.reader_classifer', $.rescope(this.handle_clicks, this));
|
||||
|
@ -86,11 +84,9 @@ var classifier = {
|
|||
this.find_story_and_feed();
|
||||
this.make_modal_feed();
|
||||
this.make_modal_title();
|
||||
this.make_modal_intelligence_slider();
|
||||
this.handle_select_checkboxes();
|
||||
this.handle_cancel();
|
||||
this.handle_select_title();
|
||||
this.open_modal();
|
||||
this.$modal.parent().bind('click.reader_classifer', $.rescope(this.handle_clicks, this));
|
||||
|
||||
if (!this.options.feed_loaded) {
|
||||
_.defer(_.bind(function() {
|
||||
|
@ -106,42 +102,38 @@ var classifier = {
|
|||
this.make_modal_story();
|
||||
this.make_modal_title();
|
||||
this.handle_text_highlight();
|
||||
this.handle_select_checkboxes();
|
||||
this.handle_cancel();
|
||||
this.handle_select_title();
|
||||
this.open_modal();
|
||||
this.$modal.parent().bind('click.reader_classifer', $.rescope(this.handle_clicks, this));
|
||||
},
|
||||
|
||||
load_previous_feed_in_trainer: function() {
|
||||
this.trainer_iterator = this.trainer_iterator - 1;
|
||||
|
||||
var trainer_data_length = this.trainer_data.length;
|
||||
|
||||
if (this.trainer_iterator < 1) {
|
||||
NEWSBLUR.log(['intro', this.trainer_iterator]);
|
||||
this.trainer_iterator = this.trainer_iterator - 1;
|
||||
var trainer_data = this.trainer_data[this.trainer_iterator];
|
||||
NEWSBLUR.log(['load_previous_feed_in_trainer', this.trainer_iterator, trainer_data]);
|
||||
if (!trainer_data || this.trainer_iterator < 0) {
|
||||
this.make_trainer_intro();
|
||||
this.load_feeds_trainer(null, this.trainer_data);
|
||||
this.reload_modal();
|
||||
} else if (this.trainer_iterator > 0 && this.trainer_iterator <= trainer_data_length) {
|
||||
var trainer_data = this.trainer_data[this.trainer_iterator-1];
|
||||
NEWSBLUR.log(['previous', trainer_data_length, this.trainer_iterator-1, trainer_data]);
|
||||
} else {
|
||||
this.feed_id = trainer_data['feed_id'];
|
||||
this.load_feed(trainer_data);
|
||||
}
|
||||
},
|
||||
|
||||
load_next_feed_in_trainer: function(backwards) {
|
||||
this.trainer_iterator = this.trainer_iterator + 1;
|
||||
|
||||
var trainer_data_length = this.trainer_data.length;
|
||||
|
||||
if (this.trainer_iterator > trainer_data_length) {
|
||||
NEWSBLUR.log(['outro', this.trainer_iterator, trainer_data_length]);
|
||||
this.trainer_iterator = this.trainer_iterator + 1;
|
||||
var trainer_data = this.trainer_data[this.trainer_iterator];
|
||||
NEWSBLUR.log(['load_next_feed_in_trainer', this.trainer_iterator, trainer_data]);
|
||||
if (!trainer_data || this.trainer_iterator >= trainer_data_length) {
|
||||
this.make_trainer_outro();
|
||||
this.load_feeds_trainer(null, this.trainer_data);
|
||||
this.reload_modal();
|
||||
this.load_feeds_trainer(null, this.trainer_data);
|
||||
} else {
|
||||
var trainer_data = this.trainer_data[this.trainer_iterator-1];
|
||||
NEWSBLUR.log(['next', trainer_data_length, this.trainer_iterator-1, trainer_data]);
|
||||
this.feed_id = trainer_data['feed_id'];
|
||||
this.load_feed(trainer_data);
|
||||
}
|
||||
},
|
||||
|
@ -172,7 +164,6 @@ var classifier = {
|
|||
$('.NB-modal').empty().append(this.$modal.children());
|
||||
this.$modal = $('.NB-modal'); // This is bonkers. I shouldn't have to reattach like this
|
||||
$(window).trigger('resize.simplemodal');
|
||||
this.handle_select_checkboxes();
|
||||
this.handle_cancel();
|
||||
}
|
||||
}, this), 125);
|
||||
|
@ -187,11 +178,15 @@ var classifier = {
|
|||
|
||||
NEWSBLUR.log(['data', data]);
|
||||
this.trainer_data = data;
|
||||
|
||||
$begin.text('Begin Training')
|
||||
.addClass('NB-modal-submit-green')
|
||||
.removeClass('NB-modal-submit-close')
|
||||
.removeClass('NB-disabled');
|
||||
|
||||
if (!data || !data.length) {
|
||||
this.make_trainer_outro();
|
||||
this.reload_modal();
|
||||
} else {
|
||||
$begin.text('Begin Training')
|
||||
.addClass('NB-modal-submit-green')
|
||||
.removeClass('NB-disabled');
|
||||
}
|
||||
},
|
||||
|
||||
find_story_and_feed: function() {
|
||||
|
@ -226,7 +221,7 @@ var classifier = {
|
|||
make_trainer_intro: function() {
|
||||
var self = this;
|
||||
|
||||
this.$modal = $.make('div', { className: 'NB-classifier NB-modal NB-modal-trainer'}, [
|
||||
this.$modal = $.make('div', { className: 'NB-modal-classifiers NB-modal NB-modal-trainer'}, [
|
||||
$.make('h2', { className: 'NB-modal-title' }, 'Intelligence Trainer'),
|
||||
$.make('h3', { className: 'NB-modal-subtitle' }, 'Here\'s what to do:'),
|
||||
$.make('ol', { className: 'NB-trainer-points' }, [
|
||||
|
@ -255,8 +250,8 @@ var classifier = {
|
|||
$.make('li', [
|
||||
$.make('b', 'Don\'t worry if you don\'t know what you like right now.'),
|
||||
' Just skip the site. You can click the ',
|
||||
$.make('img', { src: NEWSBLUR.Globals.MEDIA_URL + '/img/reader/thumbs-up.png', style: 'vertical-align: middle;padding: 0 8px 0 2px', width: 14, height: 20 }),
|
||||
$.make('img', { src: NEWSBLUR.Globals.MEDIA_URL + '/img/reader/thumbs-down.png', style: 'vertical-align: top; padding: 0', width: 14, height: 20 }),
|
||||
$.make('img', { src: NEWSBLUR.Globals.MEDIA_URL + '/img/reader/thumbs_up.png', style: 'vertical-align: middle;padding: 0 8px 0 2px', width: 14, height: 20 }),
|
||||
$.make('img', { src: NEWSBLUR.Globals.MEDIA_URL + '/img/reader/thumbs_down.png', style: 'vertical-align: top; padding: 0', width: 14, height: 20 }),
|
||||
' buttons as you read stories.'
|
||||
])
|
||||
]),
|
||||
|
@ -272,7 +267,7 @@ var classifier = {
|
|||
make_trainer_outro: function() {
|
||||
var self = this;
|
||||
|
||||
this.$modal = $.make('div', { className: 'NB-classifier NB-modal NB-modal-trainer'}, [
|
||||
this.$modal = $.make('div', { className: 'NB-modal-classifiers NB-modal NB-modal-trainer'}, [
|
||||
$.make('h2', { className: 'NB-modal-title' }, 'Congratulations! You\'re done.'),
|
||||
$.make('h3', { className: 'NB-modal-subtitle' }, 'Here\'s what happens next:'),
|
||||
$.make('ol', { className: 'NB-trainer-points' }, [
|
||||
|
@ -280,8 +275,8 @@ var classifier = {
|
|||
$.make('img', { src: NEWSBLUR.Globals.MEDIA_URL + '/img/reader/sample_classifier_tag.png', style: 'float: right', width: 135, height: 20 }),
|
||||
$.make('b', 'You can change your opinions.'),
|
||||
' You can click the ',
|
||||
$.make('img', { src: NEWSBLUR.Globals.MEDIA_URL + '/img/reader/thumbs-up.png', style: 'vertical-align: middle;padding: 0 8px 0 2px', width: 14, height: 20 }),
|
||||
$.make('img', { src: NEWSBLUR.Globals.MEDIA_URL + '/img/reader/thumbs-down.png', style: 'vertical-align: top; padding: 0', width: 14, height: 20 }),
|
||||
$.make('img', { src: NEWSBLUR.Globals.MEDIA_URL + '/img/reader/thumbs_up.png', style: 'vertical-align: middle;padding: 0 8px 0 2px', width: 14, height: 20 }),
|
||||
$.make('img', { src: NEWSBLUR.Globals.MEDIA_URL + '/img/reader/thumbs_down.png', style: 'vertical-align: top; padding: 0', width: 14, height: 20 }),
|
||||
' buttons next to stories as you read them.'
|
||||
]),
|
||||
$.make('li', [
|
||||
|
@ -312,59 +307,58 @@ var classifier = {
|
|||
make_modal_feed: function() {
|
||||
var self = this;
|
||||
var feed = this.feed;
|
||||
var opinion = (this.score == 1 ? 'like_' : 'dislike_');
|
||||
|
||||
|
||||
// NEWSBLUR.log(['Make feed', feed, this.feed_authors, this.feed_tags]);
|
||||
|
||||
this.$modal = $.make('div', { className: 'NB-classifier NB-modal ' + (this.options['training'] && 'NB-modal-trainer') }, [
|
||||
this.$modal = $.make('div', { className: 'NB-modal-classifiers NB-modal ' + (this.options['training'] && 'NB-modal-trainer') }, [
|
||||
$.make('div', { className: 'NB-modal-loading' }),
|
||||
(!this.options['training'] && this.make_modal_intelligence_slider()),
|
||||
(this.options['training'] && $.make('div', { className: 'NB-classifier-trainer-counts' })),
|
||||
$.make('h2', { className: 'NB-modal-title' }, ''),
|
||||
$.make('h2', { className: 'NB-modal-subtitle' }, [
|
||||
(this.options['training'] && $.make('div', { className: 'NB-classifier-trainer-counts' })),
|
||||
$.make('img', { className: 'NB-modal-feed-image feed_favicon', src: NEWSBLUR.Globals.google_favicon_url + this.feed.feed_link }),
|
||||
$.make('span', { className: 'NB-modal-feed-title' }, this.feed.feed_title)
|
||||
]),
|
||||
(this.options['feed_loaded'] &&
|
||||
$.make('form', { method: 'post', className: 'NB-publisher' }, [
|
||||
(!_.isEmpty(this.user_classifiers.titles) && $.make('div', { className: 'NB-modal-field NB-fieldset NB-classifiers' }, [
|
||||
$.make('h5', 'Titles and Phrases'),
|
||||
$.make('div', { className: 'NB-classifier-titles NB-fieldset-fields NB-classifiers' },
|
||||
this.make_user_titles()
|
||||
)
|
||||
])),
|
||||
(this.feed_authors.length && $.make('div', { className: 'NB-modal-field NB-fieldset NB-classifiers' }, [
|
||||
$.make('h5', 'Authors'),
|
||||
$.make('div', { className: 'NB-classifier-authors NB-fieldset-fields NB-classifiers' },
|
||||
this.make_authors(this.feed_authors, opinion)
|
||||
this.make_authors(this.feed_authors).concat(this.make_user_authors())
|
||||
)
|
||||
])),
|
||||
(this.feed_tags.length && $.make('div', { className: 'NB-modal-field NB-fieldset NB-classifiers' }, [
|
||||
$.make('h5', 'Categories & Tags'),
|
||||
$.make('div', { className: 'NB-classifier-tags NB-fieldset-fields NB-classifiers' },
|
||||
this.make_tags(this.feed_tags, opinion)
|
||||
this.make_tags(this.feed_tags).concat(this.make_user_tags())
|
||||
)
|
||||
])),
|
||||
$.make('div', { className: 'NB-modal-field NB-fieldset NB-classifiers' }, [
|
||||
$.make('h5', 'Everything by This Publisher'),
|
||||
$.make('div', { className: 'NB-fieldset-fields NB-classifiers' },
|
||||
this.make_publisher(feed, opinion)
|
||||
this.make_publisher(feed)
|
||||
)
|
||||
]),
|
||||
(this.options['training'] && $.make('div', { className: 'NB-modal-submit' }, [
|
||||
$.make('input', { name: 'score', value: this.score, type: 'hidden' }),
|
||||
$.make('input', { name: 'feed_id', value: this.feed_id, type: 'hidden' }),
|
||||
$.make('a', { href: '#', className: 'NB-modal-submit-button NB-modal-submit-back' }, $.entity('«') + ' Back'),
|
||||
$.make('a', { href: '#', className: 'NB-modal-submit-button NB-modal-submit-green NB-modal-submit-save' }, 'Save & Next '+$.entity('»')),
|
||||
$.make('a', { href: '#', className: 'NB-modal-submit-button NB-modal-submit-green NB-modal-submit-next NB-modal-submit-save' }, 'Save & Next '+$.entity('»')),
|
||||
$.make('a', { href: '#', className: 'NB-modal-submit-button NB-modal-submit-close' }, 'Close')
|
||||
])),
|
||||
(!this.options['training'] && $.make('div', { className: 'NB-modal-submit' }, [
|
||||
$.make('input', { name: 'score', value: this.score, type: 'hidden' }),
|
||||
$.make('input', { name: 'story_id', value: this.story_id, type: 'hidden' }),
|
||||
$.make('input', { name: 'feed_id', value: this.feed_id, type: 'hidden' }),
|
||||
$.make('input', { type: 'submit', disabled: 'true', className: 'NB-modal-submit-save NB-modal-submit-green NB-disabled', value: 'Check what you like above...' }),
|
||||
' or ',
|
||||
$.make('a', { href: '#', className: 'NB-modal-cancel' }, 'cancel')
|
||||
]))
|
||||
]).bind('submit', function(e) {
|
||||
e.preventDefault();
|
||||
self.save_publisher();
|
||||
return false;
|
||||
})
|
||||
])
|
||||
)
|
||||
]);
|
||||
},
|
||||
|
@ -380,21 +374,14 @@ var classifier = {
|
|||
// HTML entities decoding.
|
||||
story.story_title = $('<div/>').html(story.story_title).text();
|
||||
|
||||
this.$modal = $.make('div', { className: 'NB-classifier NB-modal' }, [
|
||||
this.make_modal_intelligence_slider(),
|
||||
this.$modal = $.make('div', { className: 'NB-modal-classifiers NB-modal' }, [
|
||||
$.make('h2', { className: 'NB-modal-title' }),
|
||||
$.make('form', { method: 'post' }, [
|
||||
(story.story_title && $.make('div', { className: 'NB-modal-field NB-fieldset' }, [
|
||||
$.make('h5', 'Story Title'),
|
||||
$.make('div', { className: 'NB-fieldset-fields NB-classifiers' }, [
|
||||
$.make('input', { type: 'text', value: story.story_title, className: 'NB-classifier-title-highlight' }),
|
||||
$.make('div', { className: 'NB-classifier NB-classifier-title NB-classifier-facet-disabled' }, [
|
||||
$.make('input', { type: 'checkbox', name: opinion+'title', value: '', id: 'classifier_title' }),
|
||||
$.make('label', { 'for': 'classifier_title' }, [
|
||||
$.make('b', 'Look for: '),
|
||||
$.make('span', { className: 'NB-classifier-title-text' }, 'Highlight phrases to look for in future stories')
|
||||
])
|
||||
])
|
||||
this.make_classifier('<span class="NB-classifier-title-text">Highlight phrases to look for in future stories</span>', '', 'title')
|
||||
])
|
||||
])),
|
||||
(story.story_authors && $.make('div', { className: 'NB-modal-field NB-fieldset' }, [
|
||||
|
@ -416,7 +403,6 @@ var classifier = {
|
|||
)
|
||||
]),
|
||||
$.make('div', { className: 'NB-modal-submit' }, [
|
||||
$.make('input', { name: 'score', value: this.score, type: 'hidden' }),
|
||||
$.make('input', { name: 'story_id', value: this.story_id, type: 'hidden' }),
|
||||
$.make('input', { name: 'feed_id', value: this.feed_id, type: 'hidden' }),
|
||||
$.make('input', { type: 'submit', disabled: 'true', className: 'NB-modal-submit-save NB-modal-submit-green NB-disabled', value: 'Check what you like above...' }),
|
||||
|
@ -434,60 +420,37 @@ var classifier = {
|
|||
make_modal_title: function() {
|
||||
var $modal_title = $('.NB-modal-title', this.$modal);
|
||||
|
||||
if (this.flags['publisher']) {
|
||||
if (this.score == 1) {
|
||||
$modal_title.html('What do you <b class="NB-classifier-like">like</b> about this site?');
|
||||
} else if (this.score == -1) {
|
||||
$modal_title.html('What do you <b class="NB-classifier-dislike">dislike</b> about this site?');
|
||||
}
|
||||
} else if (this.flags['story']) {
|
||||
if (this.score == 1) {
|
||||
$modal_title.html('What do you <b class="NB-classifier-like">like</b> about this story?');
|
||||
} else if (this.score == -1) {
|
||||
$modal_title.html('What do you <b class="NB-classifier-dislike">dislike</b> about this story?');
|
||||
}
|
||||
}
|
||||
var $title = $.make('div', [
|
||||
'What do you ',
|
||||
$.make('b', { className: 'NB-classifier-title-like' }, 'like'),
|
||||
' and ',
|
||||
$.make('b', { className: 'NB-classifier-title-dislike' }, 'dislike'),
|
||||
' about this ',
|
||||
(this.flags['publisher'] && 'site'),
|
||||
(this.flags['story'] && 'story'),
|
||||
'?'
|
||||
]);
|
||||
|
||||
$modal_title.html($title);
|
||||
},
|
||||
|
||||
make_modal_trainer_count: function() {
|
||||
var $count = $('.NB-classifier-trainer-counts', this.$modal);
|
||||
var count = this.trainer_iterator;
|
||||
var count = this.trainer_iterator + 1;
|
||||
var total = this.trainer_data.length;
|
||||
$count.html(count + '/' + total);
|
||||
},
|
||||
|
||||
make_modal_intelligence_slider: function() {
|
||||
var self = this;
|
||||
var $slider = $.make('div', { className: 'NB-taskbar-intelligence NB-modal-slider' }, [
|
||||
$.make('div', { className: 'NB-taskbar-intelligence-indicator NB-taskbar-intelligence-negative' }),
|
||||
$.make('div', { className: 'NB-taskbar-intelligence-indicator NB-taskbar-intelligence-neutral' }),
|
||||
$.make('div', { className: 'NB-taskbar-intelligence-indicator NB-taskbar-intelligence-positive' }),
|
||||
$.make('div', { className: 'NB-intelligence-slider' })
|
||||
]);
|
||||
make_user_titles: function() {
|
||||
var $titles = [];
|
||||
var titles = _.keys(this.user_classifiers.titles);
|
||||
|
||||
$('.NB-intelligence-slider', $slider).slider({
|
||||
range: 'max',
|
||||
min: 0,
|
||||
max: 2,
|
||||
step: 2,
|
||||
value: this.score + 1,
|
||||
slide: function(e, ui) {
|
||||
// self.switch_feed_view_unread_view(ui.value);
|
||||
self.score = ui.value - 1;
|
||||
self.make_modal_title();
|
||||
$('input[name^=like],input[name^=dislike]', self.$modal).attr('name', function(i, current_name) {
|
||||
if (self.score == -1) {
|
||||
return 'dis' + current_name.substr(current_name.indexOf('like_'));
|
||||
} else if (self.score == 1) {
|
||||
return current_name.substr(current_name.indexOf('like_'));
|
||||
}
|
||||
});
|
||||
var $submit = $('input[type=submit]', self.$modal);
|
||||
$submit.removeClass("NB-disabled").removeAttr('disabled').attr('value', 'Save');
|
||||
}
|
||||
});
|
||||
_.each(titles, _.bind(function(title) {
|
||||
var $title = this.make_classifier(title, title, 'title');
|
||||
$titles.push($title);
|
||||
}, this));
|
||||
|
||||
return $slider;
|
||||
return $titles;
|
||||
},
|
||||
|
||||
make_authors: function(authors, opinion) {
|
||||
|
@ -505,37 +468,25 @@ var classifier = {
|
|||
|
||||
if (!author) continue;
|
||||
|
||||
var input_attrs = {
|
||||
type: 'checkbox',
|
||||
name: opinion+'author',
|
||||
value: author,
|
||||
id: 'classifier_author_'+a
|
||||
};
|
||||
|
||||
if (author in this.user_classifiers.authors
|
||||
&& this.user_classifiers.authors[author] == this.score) {
|
||||
input_attrs['checked'] = 'checked';
|
||||
}
|
||||
|
||||
var $author = $.make('span', { className: 'NB-classifier-container NB-classifier-author-container' }, [
|
||||
$.make('span', { className: 'NB-classifier NB-classifier-author' }, [
|
||||
$.make('input', input_attrs),
|
||||
$.make('label', { 'for': 'classifier_author_'+a }, [
|
||||
$.make('b', 'Author: '),
|
||||
$.make('span', author)
|
||||
])
|
||||
]),
|
||||
(author_count && $.make('span', { className: 'NB-classifier-tag-count' }, [
|
||||
'× ',
|
||||
author_count
|
||||
]))
|
||||
]);
|
||||
var $author = this.make_classifier(author, author, 'author', author_count);
|
||||
$authors.push($author);
|
||||
}
|
||||
return $authors;
|
||||
},
|
||||
|
||||
make_tags: function(tags, opinion) {
|
||||
make_user_authors: function() {
|
||||
var $authors = [];
|
||||
var user_authors = _.keys(this.user_classifiers.authors);
|
||||
var feed_authors = _.map(this.feed_authors, function(author) { return author[0]; });
|
||||
var authors = _.reduce(user_authors, function(memo, author, i) {
|
||||
if (!_.contains(feed_authors, author)) return memo.concat(author);
|
||||
return memo;
|
||||
}, []);
|
||||
|
||||
return this.make_authors(authors);
|
||||
},
|
||||
|
||||
make_tags: function(tags) {
|
||||
var $tags = [];
|
||||
|
||||
for (var t in tags) {
|
||||
|
@ -550,70 +501,136 @@ var classifier = {
|
|||
|
||||
if (!tag) continue;
|
||||
|
||||
var input_attrs = {
|
||||
type: 'checkbox',
|
||||
name: opinion+'tag',
|
||||
value: tag,
|
||||
id: 'classifier_tag_'+t
|
||||
};
|
||||
|
||||
if (tag in this.user_classifiers.tags && this.user_classifiers.tags[tag] == this.score) {
|
||||
input_attrs['checked'] = 'checked';
|
||||
}
|
||||
|
||||
var $tag = $.make('span', { className: 'NB-classifier-container NB-classifier-tag-container' }, [
|
||||
$.make('span', { className: 'NB-classifier NB-classifier-tag' }, [
|
||||
$.make('input', input_attrs),
|
||||
$.make('label', { 'for': 'classifier_tag_'+t }, [
|
||||
$.make('b', 'Tag: '),
|
||||
$.make('span', tag)
|
||||
])
|
||||
]),
|
||||
(tag_count && $.make('span', { className: 'NB-classifier-tag-count' }, [
|
||||
'× ',
|
||||
tag_count
|
||||
]))
|
||||
]);
|
||||
var $tag = this.make_classifier(tag, tag, 'tag', tag_count);
|
||||
$tags.push($tag);
|
||||
}
|
||||
|
||||
return $tags;
|
||||
},
|
||||
|
||||
make_user_tags: function() {
|
||||
var $tags = [];
|
||||
var user_tags = _.keys(this.user_classifiers.tags);
|
||||
var feed_tags = _.map(this.feed_tags, function(tag) { return tag[0]; });
|
||||
var tags = _.reduce(user_tags, function(memo, tag, i) {
|
||||
if (!_.contains(feed_tags, tag)) return memo.concat(tag);
|
||||
return memo;
|
||||
}, []);
|
||||
|
||||
return this.make_tags(tags);
|
||||
},
|
||||
|
||||
make_publisher: function(publisher, opinion) {
|
||||
var input_attrs = {
|
||||
type: 'checkbox',
|
||||
name: opinion+'publisher',
|
||||
value: this.feed_id,
|
||||
id: 'classifier_publisher',
|
||||
checked: false
|
||||
};
|
||||
if (this.user_classifiers.feeds[this.feed_id] == this.score) {
|
||||
input_attrs['checked'] = true;
|
||||
}
|
||||
|
||||
var $publisher = $.make('div', { className: 'NB-classifier NB-classifier-publisher' }, [
|
||||
$.make('input', input_attrs),
|
||||
$.make('label', { 'for': 'classifier_publisher' }, [
|
||||
$.make('img', { className: 'feed_favicon', src: NEWSBLUR.Globals.google_favicon_url + publisher.feed_link }),
|
||||
$.make('span', { className: 'feed_title' }, [
|
||||
$.make('b', 'Publisher: '),
|
||||
$.make('span', publisher.feed_title)
|
||||
])
|
||||
])
|
||||
]);
|
||||
var $publisher = this.make_classifier(publisher.feed_title, this.feed_id, 'feed');
|
||||
return $publisher;
|
||||
},
|
||||
|
||||
make_title: function(title, t, opinion) {
|
||||
var $title = $.make('div', { className: 'NB-classifier NB-classifier-title' }, [
|
||||
$.make('input', { type: 'checkbox', name: opinion+'title', value: title, id: 'classifier_title_'+t, checked: 'checked' }),
|
||||
$.make('label', { 'for': 'classifier_title_'+t }, [
|
||||
$.make('b', 'Title: '),
|
||||
$.make('span', title)
|
||||
])
|
||||
make_classifier: function(classifier_title, classifier_value, classifier_type, classifier_count) {
|
||||
var score = 0;
|
||||
// NEWSBLUR.log(['classifiers', this.user_classifiers, classifier_value, this.user_classifiers[classifier_type+'s']]);
|
||||
if (classifier_value in this.user_classifiers[classifier_type+'s']) {
|
||||
score = this.user_classifiers[classifier_type+'s'][classifier_value];
|
||||
}
|
||||
|
||||
var classifier_type_title = Inflector.capitalize(classifier_type=='feed' ?
|
||||
'publisher' :
|
||||
classifier_type);
|
||||
|
||||
var $classifier = $.make('span', { className: 'NB-classifier-container' }, [
|
||||
$.make('span', { className: 'NB-classifier NB-classifier-'+classifier_type }, [
|
||||
$.make('input', {
|
||||
type: 'checkbox',
|
||||
className: 'NB-classifier-input-like',
|
||||
name: 'like_'+classifier_type,
|
||||
value: classifier_value
|
||||
}),
|
||||
$.make('input', {
|
||||
type: 'checkbox',
|
||||
className: 'NB-classifier-input-dislike',
|
||||
name: 'dislike_'+classifier_type,
|
||||
value: classifier_value
|
||||
}),
|
||||
$.make('div', { className: 'NB-classifier-icon-like' }),
|
||||
$.make('div', { className: 'NB-classifier-icon-dislike' }, [
|
||||
$.make('div', { className: 'NB-classifier-icon-dislike-inner' })
|
||||
]),
|
||||
$.make('label', [
|
||||
(classifier_type == 'feed' &&
|
||||
$.make('img', {
|
||||
className: 'feed_favicon',
|
||||
src: NEWSBLUR.Globals.google_favicon_url + this.feed.feed_link
|
||||
})),
|
||||
$.make('b', classifier_type_title+': '),
|
||||
$.make('span', classifier_title)
|
||||
])
|
||||
]),
|
||||
(classifier_count && $.make('span', { className: 'NB-classifier-count' }, [
|
||||
'× ',
|
||||
classifier_count
|
||||
]))
|
||||
]);
|
||||
return $title;
|
||||
|
||||
if (score > 0) {
|
||||
$('.NB-classifier', $classifier).addClass('NB-classifier-like');
|
||||
$('.NB-classifier-input-like', $classifier).attr('checked', true);
|
||||
} else if (score < 0) {
|
||||
$('.NB-classifier', $classifier).addClass('NB-classifier-dislike');
|
||||
$('.NB-classifier-input-dislike', $classifier).attr('checked', true);
|
||||
}
|
||||
|
||||
$('.NB-classifier', $classifier).bind('mouseenter', function(e) {
|
||||
$(e.currentTarget).addClass('NB-classifier-hover-like');
|
||||
}).bind('mouseleave', function(e) {
|
||||
$(e.currentTarget).removeClass('NB-classifier-hover-like');
|
||||
});
|
||||
|
||||
$('.NB-classifier-icon-dislike', $classifier).bind('mouseenter', function(e) {
|
||||
$('.NB-classifier', $classifier).addClass('NB-classifier-hover-dislike');
|
||||
}).bind('mouseleave', function(e) {
|
||||
$('.NB-classifier', $classifier).removeClass('NB-classifier-hover-dislike');
|
||||
});
|
||||
|
||||
return $classifier;
|
||||
},
|
||||
|
||||
change_classifier: function($classifier, classifier_opinion) {
|
||||
var $like = $('.NB-classifier-input-like', $classifier);
|
||||
var $dislike = $('.NB-classifier-input-dislike', $classifier);
|
||||
|
||||
var $save = $('.NB-modal-submit-save', this.$modal);
|
||||
var $close = $('.NB-modal-submit-close', this.$modal);
|
||||
var $back = $('.NB-modal-submit-back', this.$modal);
|
||||
|
||||
if (classifier_opinion == 'like') {
|
||||
if ($classifier.is('.NB-classifier-like')) {
|
||||
$classifier.removeClass('NB-classifier-like');
|
||||
$dislike.attr('checked', false);
|
||||
$like.attr('checked', false);
|
||||
} else {
|
||||
$classifier.removeClass('NB-classifier-dislike');
|
||||
$classifier.addClass('NB-classifier-like');
|
||||
$dislike.attr('checked', false);
|
||||
$like.attr('checked', true);
|
||||
}
|
||||
} else if (classifier_opinion == 'dislike') {
|
||||
if ($classifier.is('.NB-classifier-dislike')) {
|
||||
$classifier.removeClass('NB-classifier-dislike');
|
||||
$like.attr('checked', false);
|
||||
$dislike.attr('checked', false);
|
||||
} else {
|
||||
$classifier.removeClass('NB-classifier-like');
|
||||
$classifier.addClass('NB-classifier-dislike');
|
||||
$like.attr('checked', false);
|
||||
$dislike.attr('checked', true);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.options['training']) {
|
||||
$close.val('Save & Close');
|
||||
} else {
|
||||
$save.removeClass("NB-disabled").removeAttr('disabled').attr('value', 'Save');
|
||||
}
|
||||
// NEWSBLUR.log(['change_classifier', classifier_opinion, $classifier, $like.is(':checked'), $dislike.is(':checked')]);
|
||||
},
|
||||
|
||||
open_modal: function() {
|
||||
|
@ -676,19 +693,21 @@ var classifier = {
|
|||
// ==========
|
||||
|
||||
handle_text_highlight: function() {
|
||||
var self = this;
|
||||
var $title_highlight = $('.NB-classifier-title-highlight', this.$modal);
|
||||
var $title = $('.NB-classifier-title-text', this.$modal);
|
||||
var $title_checkbox = $('#classifier_title', this.$modal);
|
||||
|
||||
var $title_classifier = $title.parents('.NB-classifier').eq(0);
|
||||
var $title_checkboxs = $('.NB-classifier-input-like, .NB-classifier-input-dislike', $title_classifier);
|
||||
|
||||
var update = function() {
|
||||
var text = $.trim($(this).getSelection().text);
|
||||
|
||||
if ($title.text() != text && text.length) {
|
||||
$title_checkbox.attr('checked', 'checked').change();
|
||||
if (text.length && $title.text() != text) {
|
||||
$title.text(text);
|
||||
$title_checkbox.parents('.NB-classifier-facet-disabled')
|
||||
.removeClass('NB-classifier-facet-disabled');
|
||||
$title_checkbox.val(text);
|
||||
$title_checkboxs.val(text);
|
||||
if (!$title_classifier.is('.NB-classifier-like,.NB-classifier-dislike')) {
|
||||
self.change_classifier($title.parents('.NB-classifier').eq(0), 'like');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -697,38 +716,6 @@ var classifier = {
|
|||
.mousedown(update).mouseup(update).mousemove(update);
|
||||
},
|
||||
|
||||
handle_select_title: function() {
|
||||
var $title_checkbox = $('#classifier_title', this.$modal);
|
||||
var $title = $('.NB-classifier-title-text', this.$modal);
|
||||
var $title_highlight = $('.NB-classifier-title-highlight', this.$modal);
|
||||
|
||||
$title_checkbox.change(function() {;
|
||||
if ($title.parents('.NB-classifier-facet-disabled').length) {
|
||||
var text = $title_highlight.val();
|
||||
$title.text(text);
|
||||
$title_checkbox.parents('.NB-classifier-facet-disabled')
|
||||
.removeClass('NB-classifier-facet-disabled');
|
||||
$title_checkbox.val(text);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
handle_select_checkboxes: function() {
|
||||
var self = this;
|
||||
var $save = $('.NB-modal-submit-save', this.$modal);
|
||||
var $close = $('.NB-modal-submit-close', this.$modal);
|
||||
var $back = $('.NB-modal-submit-back', this.$modal);
|
||||
|
||||
$('input', this.$modal).change(function() {
|
||||
// var count = $('input:checked', self.$modal).length;
|
||||
if (self.options['training']) {
|
||||
$close.val('Save & Close');
|
||||
} else {
|
||||
$save.removeClass("NB-disabled").removeAttr('disabled').attr('value', 'Save');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
handle_cancel: function() {
|
||||
var $cancel = $('.NB-modal-cancel', this.$modal);
|
||||
|
||||
|
@ -741,50 +728,72 @@ var classifier = {
|
|||
handle_clicks: function(elem, e) {
|
||||
var self = this;
|
||||
|
||||
$.targetIs(e, { tagSelector: '.NB-modal-submit-begin' }, function($t, $p){
|
||||
e.preventDefault();
|
||||
self.load_next_feed_in_trainer();
|
||||
});
|
||||
if (this.options['training']) {
|
||||
$.targetIs(e, { tagSelector: '.NB-modal-submit-begin' }, function($t, $p){
|
||||
e.preventDefault();
|
||||
self.load_next_feed_in_trainer();
|
||||
});
|
||||
$.targetIs(e, { tagSelector: '.NB-modal-submit-save.NB-modal-submit-next' }, function($t, $p){
|
||||
e.preventDefault();
|
||||
self.save_publisher(true);
|
||||
self.load_next_feed_in_trainer();
|
||||
self.update_homepage_counts();
|
||||
});
|
||||
|
||||
$.targetIs(e, { tagSelector: '.NB-modal-submit-save:not(.NB-modal-submit-begin)' }, function($t, $p){
|
||||
e.preventDefault();
|
||||
self.save_publisher(true);
|
||||
self.load_next_feed_in_trainer();
|
||||
self.update_homepage_counts();
|
||||
});
|
||||
$.targetIs(e, { tagSelector: '.NB-modal-submit-back' }, function($t, $p){
|
||||
e.preventDefault();
|
||||
self.load_previous_feed_in_trainer();
|
||||
});
|
||||
|
||||
$.targetIs(e, { tagSelector: '.NB-modal-submit-back' }, function($t, $p){
|
||||
e.preventDefault();
|
||||
self.load_previous_feed_in_trainer();
|
||||
});
|
||||
$.targetIs(e, { tagSelector: '.NB-modal-submit-close' }, function($t, $p){
|
||||
e.preventDefault();
|
||||
self.save_publisher();
|
||||
});
|
||||
|
||||
$.targetIs(e, { tagSelector: '.NB-modal-submit-close' }, function($t, $p){
|
||||
$.targetIs(e, { tagSelector: '.NB-modal-submit-end' }, function($t, $p){
|
||||
e.preventDefault();
|
||||
NEWSBLUR.reader.force_feeds_refresh();
|
||||
// NEWSBLUR.reader.open_feed(self.feed_id, true);
|
||||
// TODO: Update counts in active feed.
|
||||
$.modal.close();
|
||||
});
|
||||
} else {
|
||||
$.targetIs(e, { tagSelector: '.NB-modal-submit-save:not(.NB-modal-submit-next)' }, function($t, $p){
|
||||
e.preventDefault();
|
||||
self.save_publisher();
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
var stop = false;
|
||||
$.targetIs(e, { tagSelector: '.NB-classifier-icon-dislike' }, function($t, $p){
|
||||
e.preventDefault();
|
||||
self.save_publisher();
|
||||
stop = true;
|
||||
self.change_classifier($t.parents('.NB-classifier').eq(0), 'dislike');
|
||||
});
|
||||
|
||||
$.targetIs(e, { tagSelector: '.NB-modal-submit-end' }, function($t, $p){
|
||||
if (stop) return;
|
||||
$.targetIs(e, { tagSelector: '.NB-classifier' }, function($t, $p){
|
||||
e.preventDefault();
|
||||
self.end();
|
||||
self.change_classifier($t, 'like');
|
||||
});
|
||||
},
|
||||
|
||||
serialize_classifier: function() {
|
||||
var checked_data = $('input', this.$modal).serialize();
|
||||
|
||||
var $unchecked = $('input[type=checkbox]:not(:checked)', this.$modal);
|
||||
$unchecked.attr('checked', true);
|
||||
$unchecked.each(function() {
|
||||
$(this).attr('name', 'remove_' + $(this).attr('name'));
|
||||
var data = [];
|
||||
$('.NB-classifier', this.$modal).each(function() {
|
||||
if ($('.NB-classifier-input-like, .NB-classifier-input-dislike', this).is(':checked')) {
|
||||
data.push([$('input:checked', this).attr('name'), $('.NB-classifier-input-like', this).val()]);
|
||||
} else {
|
||||
data.push(['remove_'+$('.NB-classifier-input-like', this).attr('name'), $('.NB-classifier-input-like', this).val()]);
|
||||
}
|
||||
});
|
||||
|
||||
var unchecked_data = $unchecked.serialize();
|
||||
$unchecked.each(function() {
|
||||
$(this).attr('name', $(this).attr('name').replace(/^remove_/, ''));
|
||||
});
|
||||
$unchecked.attr('checked', false);
|
||||
|
||||
var data = [checked_data, unchecked_data].join('&');
|
||||
data.push(['feed_id', this.feed_id]);
|
||||
if (this.story_id) {
|
||||
data.push(['story_id', this.story_id]);
|
||||
}
|
||||
data = _.map(data, function(c) {
|
||||
return [c[0], '=', c[1]].join('');
|
||||
}).join('&');
|
||||
return data;
|
||||
},
|
||||
|
||||
|
@ -806,9 +815,8 @@ var classifier = {
|
|||
this.model.save_classifier_publisher(data, function() {
|
||||
if (!keep_modal_open) {
|
||||
NEWSBLUR.reader.force_feeds_refresh();
|
||||
if (self.feed_id == NEWSBLUR.reader.active_feed) {
|
||||
NEWSBLUR.reader.load_feed(self.feed_id, null, true);
|
||||
}
|
||||
// NEWSBLUR.reader.open_feed(self.feed_id, true);
|
||||
// TODO: Update counts in active feed.
|
||||
$.modal.close();
|
||||
}
|
||||
});
|
||||
|
@ -832,6 +840,6 @@ var classifier = {
|
|||
|
||||
};
|
||||
|
||||
NEWSBLUR.ReaderClassifierStory.prototype = classifier;
|
||||
NEWSBLUR.ReaderClassifierFeed.prototype = classifier;
|
||||
NEWSBLUR.ReaderClassifierTrainer.prototype = classifier;
|
||||
NEWSBLUR.ReaderClassifierStory.prototype = classifier_prototype;
|
||||
NEWSBLUR.ReaderClassifierFeed.prototype = classifier_prototype;
|
||||
NEWSBLUR.ReaderClassifierTrainer.prototype = classifier_prototype;
|
||||
|
|
|
@ -24,8 +24,9 @@ NEWSBLUR.ReaderKeyboard.prototype = {
|
|||
$.make('div', { className: 'NB-keyboard-shortcut' }, [
|
||||
$.make('div', { className: 'NB-keyboard-shortcut-explanation' }, 'Next story'),
|
||||
$.make('div', { className: 'NB-keyboard-shortcut-key' }, [
|
||||
'↓',
|
||||
$.make('span', 'or'),
|
||||
'↓'
|
||||
]),
|
||||
$.make('div', { className: 'NB-keyboard-shortcut-key' }, [
|
||||
'j'
|
||||
]),
|
||||
$.make('div', { className: 'NB-keyboard-shortcut-image' }, [
|
||||
|
@ -35,8 +36,9 @@ NEWSBLUR.ReaderKeyboard.prototype = {
|
|||
$.make('div', { className: 'NB-keyboard-shortcut NB-last' }, [
|
||||
$.make('div', { className: 'NB-keyboard-shortcut-explanation' }, 'Previous story'),
|
||||
$.make('div', { className: 'NB-keyboard-shortcut-key' }, [
|
||||
'↑',
|
||||
$.make('span', 'or'),
|
||||
'↑'
|
||||
]),
|
||||
$.make('div', { className: 'NB-keyboard-shortcut-key' }, [
|
||||
'k'
|
||||
]),
|
||||
$.make('div', { className: 'NB-keyboard-shortcut-image' }, [
|
||||
|
@ -44,6 +46,34 @@ NEWSBLUR.ReaderKeyboard.prototype = {
|
|||
])
|
||||
])
|
||||
]),
|
||||
$.make('div', { className: 'NB-keyboard-group' }, [
|
||||
$.make('div', { className: 'NB-keyboard-shortcut' }, [
|
||||
$.make('div', { className: 'NB-keyboard-shortcut-explanation' }, 'Next site'),
|
||||
$.make('div', { className: 'NB-keyboard-shortcut-key' }, [
|
||||
'shift',
|
||||
$.make('span', '+'),
|
||||
'↓'
|
||||
]),
|
||||
$.make('div', { className: 'NB-keyboard-shortcut-key' }, [
|
||||
'shift',
|
||||
$.make('span', '+'),
|
||||
'j'
|
||||
])
|
||||
]),
|
||||
$.make('div', { className: 'NB-keyboard-shortcut NB-last' }, [
|
||||
$.make('div', { className: 'NB-keyboard-shortcut-explanation' }, 'Prev. site'),
|
||||
$.make('div', { className: 'NB-keyboard-shortcut-key' }, [
|
||||
'shift',
|
||||
$.make('span', '+'),
|
||||
'↑'
|
||||
]),
|
||||
$.make('div', { className: 'NB-keyboard-shortcut-key' }, [
|
||||
'shift',
|
||||
$.make('span', '+'),
|
||||
'k'
|
||||
])
|
||||
])
|
||||
]),
|
||||
$.make('div', { className: 'NB-keyboard-group' }, [
|
||||
$.make('div', { className: 'NB-keyboard-shortcut' }, [
|
||||
$.make('div', { className: 'NB-keyboard-shortcut-explanation' }, 'Switch views'),
|
||||
|
|
|
@ -1,423 +0,0 @@
|
|||
NEWSBLUR.ReaderManageFeed = function(feed_id, options) {
|
||||
var defaults = {};
|
||||
|
||||
this.options = $.extend({}, defaults, options);
|
||||
this.model = NEWSBLUR.AssetModel.reader();
|
||||
this.feed_id = feed_id;
|
||||
this.counters = {
|
||||
'classifier': 0
|
||||
};
|
||||
this.runner();
|
||||
};
|
||||
|
||||
NEWSBLUR.ReaderManageFeed.prototype = {
|
||||
|
||||
runner: function() {
|
||||
this.feeds = this.model.get_feeds();
|
||||
|
||||
if (!this.feed_id) {
|
||||
// No feed selected, so just choose a random feed.
|
||||
var feeds_list = [];
|
||||
for (var f in this.feeds) {
|
||||
feeds_list.push(f);
|
||||
}
|
||||
this.feed_id = feeds_list[Math.round(Math.random() * 1000 % (feeds_list.length-1))];
|
||||
if (!this.feed_id) this.feed_id = f;
|
||||
}
|
||||
this.feed = this.model.get_feed(this.feed_id);
|
||||
|
||||
if (this.feed_id) {
|
||||
this.make_modal();
|
||||
this.initialize_feed();
|
||||
this.handle_cancel();
|
||||
this.open_modal();
|
||||
this.load_feed_classifier();
|
||||
|
||||
this.$manage.bind('click', $.rescope(this.handle_click, this));
|
||||
this.$manage.bind('change', $.rescope(this.handle_change, this));
|
||||
this.$manage.bind('keyup', $.rescope(this.handle_keyup, this));
|
||||
}
|
||||
},
|
||||
|
||||
initialize_feed: function(feed_id) {
|
||||
if (feed_id) this.feed_id = feed_id;
|
||||
this.feed = this.model.get_feed(this.feed_id);
|
||||
$('.NB-modal-title', this.$manage).html(this.feed['feed_title']);
|
||||
$('input[name=feed_id]', this.$manage).val(this.feed_id);
|
||||
$('input[name=rename_title]', this.$manage).val(this.feed['feed_title']);
|
||||
},
|
||||
|
||||
make_modal: function() {
|
||||
var self = this;
|
||||
|
||||
this.$manage = $.make('div', { className: 'NB-manage NB-modal' }, [
|
||||
$.make('form', { method: 'post', className: 'NB-manage-form' }, [
|
||||
$.make('div', { className: 'NB-manage-container'}, [
|
||||
$.make('div', { className: 'NB-modal-loading' }),
|
||||
$.make('h2', { className: 'NB-modal-title' }),
|
||||
$.make('div', { className: 'NB-manage-field' }, [
|
||||
$.make('div', { className: 'NB-fieldset' }, [
|
||||
$.make('h5', [
|
||||
'What you ',
|
||||
$.make('span', { className: 'NB-classifier-like' }, 'like')
|
||||
]),
|
||||
$.make('div', { className: 'NB-manage-classifier NB-manage-classifier-likes NB-fieldset-fields' })
|
||||
]),
|
||||
$.make('div', { className: 'NB-fieldset' }, [
|
||||
$.make('h5', [
|
||||
'What you ',
|
||||
$.make('span', { className: 'NB-classifier-dislike' }, 'dislike')
|
||||
]),
|
||||
$.make('div', { className: 'NB-manage-classifier NB-manage-classifier-dislikes NB-fieldset-fields' })
|
||||
]),
|
||||
$.make('div', { className: 'NB-fieldset' }, [
|
||||
$.make('h5', 'Management'),
|
||||
$.make('div', { className: 'NB-manage-management NB-fieldset-fields NB-modal-submit' }, [
|
||||
$.make('div', { className: 'NB-manage-rename' }, [
|
||||
$.make('label', { className: 'NB-manage-rename-label', 'for': 'id_rename' }, "Feed Title: "),
|
||||
$.make('input', { name: 'rename_title', id: 'id_rename' })
|
||||
]),
|
||||
$.make('input', { type: 'submit', value: 'Fetch and refresh this site', className: 'NB-modal-submit-green NB-modal-submit-retry' }),
|
||||
$.make('div', { className: 'NB-manage-delete' }, [
|
||||
$.make('input', { type: 'submit', value: 'Delete this site', className: 'NB-modal-submit-green NB-modal-submit-delete' }),
|
||||
$.make('a', { className: 'NB-delete-confirm', href: '#' }, "Yes, delete this feed!"),
|
||||
$.make('a', { className: 'NB-delete-cancel', href: '#' }, "cancel")
|
||||
])
|
||||
])
|
||||
])
|
||||
])
|
||||
]),
|
||||
$.make('div', { className: 'NB-modal-feed-chooser-container'}, [
|
||||
this.make_feed_chooser()
|
||||
]),
|
||||
$.make('div', { className: 'NB-modal-submit' }, [
|
||||
$.make('input', { name: 'feed_id', type: 'hidden' }),
|
||||
$.make('input', { type: 'submit', disabled: 'true', className: 'NB-modal-submit-save NB-modal-submit-green NB-disabled', value: 'Check what you like above...' }),
|
||||
' or ',
|
||||
$.make('a', { href: '#', className: 'NB-modal-cancel' }, 'cancel')
|
||||
])
|
||||
]).bind('submit', function(e) {
|
||||
e.preventDefault();
|
||||
self.save();
|
||||
return false;
|
||||
})
|
||||
]);
|
||||
|
||||
},
|
||||
|
||||
make_feed_chooser: function() {
|
||||
var $chooser = $.make('select', { name: 'feed', className: 'NB-modal-feed-chooser' });
|
||||
|
||||
for (var f in this.feeds) {
|
||||
var feed = this.feeds[f];
|
||||
var $option = $.make('option', { value: feed.id }, feed.feed_title);
|
||||
$option.appendTo($chooser);
|
||||
|
||||
if (feed.id == this.feed_id) {
|
||||
$option.attr('selected', true);
|
||||
}
|
||||
}
|
||||
|
||||
$('option', $chooser).tsort();
|
||||
return $chooser;
|
||||
},
|
||||
|
||||
make_classifiers: function(classifiers, score) {
|
||||
var $classifiers = $.make('div');
|
||||
var i = this.counters['classifier'];
|
||||
var opinion = (score == 1 ? 'like_' : 'dislike_');
|
||||
|
||||
// Tags
|
||||
var $tags = $.make('div', { className: 'NB-classifiers NB-classifier-tags'});
|
||||
for (var t in classifiers.tags) {
|
||||
if (classifiers.tags[t] == score) {
|
||||
var $tag = this.make_tag(t, i++, opinion);
|
||||
$tags.append($tag);
|
||||
}
|
||||
}
|
||||
|
||||
// Authors
|
||||
var $authors = $.make('div', { className: 'NB-classifiers NB-classifier-authors'});
|
||||
for (var fa in classifiers.authors) {
|
||||
if (classifiers.authors[fa] == score) {
|
||||
var $author = this.make_author(fa, i++, opinion);
|
||||
$authors.append($author);
|
||||
}
|
||||
}
|
||||
|
||||
// Titles
|
||||
var $titles = $.make('div', { className: 'NB-classifiers NB-classifier-titles'});
|
||||
for (var t in classifiers.titles) {
|
||||
if (classifiers.titles[t] == score) {
|
||||
var $title = this.make_title(t, i++, opinion);
|
||||
$titles.append($title);
|
||||
}
|
||||
}
|
||||
|
||||
// Publisher
|
||||
var $publishers = $.make('div', { className: 'NB-classifiers NB-classifier-publishers'});
|
||||
for (var feed_id in classifiers.feeds) {
|
||||
if (classifiers.feeds[feed_id] == score) {
|
||||
var $publisher = this.make_publisher(feed_id, i++, opinion);
|
||||
$publishers.append($publisher);
|
||||
}
|
||||
}
|
||||
|
||||
$classifiers.append($tags);
|
||||
$classifiers.append($authors);
|
||||
$classifiers.append($titles);
|
||||
$classifiers.append($publishers);
|
||||
|
||||
if (!$('.NB-classifier', $classifiers).length) {
|
||||
var $empty_classifier = $.make('div', { className: 'NB-classifier-empty' }, [
|
||||
'No opinions yet. Use the ',
|
||||
$.make('img', { src: NEWSBLUR.Globals.MEDIA_URL + 'img/reader/thumbs-down.png', className: 'NB-dislike' }),
|
||||
$.make('img', { src: NEWSBLUR.Globals.MEDIA_URL + 'img/reader/thumbs-up.png', className: 'NB-like' }),
|
||||
' buttons next to stories.'
|
||||
]);
|
||||
$classifiers.append($empty_classifier);
|
||||
}
|
||||
|
||||
this.counters['classifier'] = i;
|
||||
return $classifiers;
|
||||
},
|
||||
|
||||
make_author: function(feed_author, i, opinion) {
|
||||
var $author = $.make('span', { className: 'NB-classifier NB-classifier-author' }, [
|
||||
$.make('input', { type: 'checkbox', name: opinion+'author', value: feed_author, id: 'classifier_author_'+i, checked: 'checked' }),
|
||||
$.make('label', { 'for': 'classifier_author_'+i }, [
|
||||
$.make('b', 'Author: '),
|
||||
$.make('span', feed_author)
|
||||
])
|
||||
]);
|
||||
return $author;
|
||||
},
|
||||
|
||||
make_tag: function(tag, t, opinion) {
|
||||
var $tag = $.make('span', { className: 'NB-classifier-tag-container' }, [
|
||||
$.make('span', { className: 'NB-classifier NB-classifier-tag' }, [
|
||||
$.make('input', { type: 'checkbox', name: opinion+'tag', value: tag, id: 'classifier_tag_'+t, checked: 'checked' }),
|
||||
$.make('label', { 'for': 'classifier_tag_'+t }, [
|
||||
$.make('b', 'Tag: '),
|
||||
$.make('span', tag)
|
||||
])
|
||||
])
|
||||
]);
|
||||
return $tag;
|
||||
},
|
||||
|
||||
make_publisher: function(feed_id, i, opinion) {
|
||||
var publisher = this.model.get_feed(feed_id);
|
||||
var $publisher = $.make('div', { className: 'NB-classifier NB-classifier-publisher' }, [
|
||||
$.make('input', { type: 'checkbox', name: opinion+'publisher', value: this.feed_id, id: 'classifier_publisher', checked: 'checked' }),
|
||||
$.make('label', { 'for': 'classifier_publisher' }, [
|
||||
$.make('img', { className: 'feed_favicon', src: NEWSBLUR.Globals.google_favicon_url + publisher.feed_link }),
|
||||
$.make('span', { className: 'feed_title' }, [
|
||||
$.make('b', 'Publisher: '),
|
||||
$.make('span', publisher.feed_title)
|
||||
])
|
||||
])
|
||||
]);
|
||||
return $publisher;
|
||||
},
|
||||
|
||||
make_title: function(title, t, opinion) {
|
||||
var $title = $.make('div', { className: 'NB-classifier NB-classifier-title' }, [
|
||||
$.make('input', { type: 'checkbox', name: opinion+'title', value: title, id: 'classifier_title_'+t, checked: 'checked' }),
|
||||
$.make('label', { 'for': 'classifier_title_'+t }, [
|
||||
$.make('b', 'Title: '),
|
||||
$.make('span', title)
|
||||
])
|
||||
]);
|
||||
return $title;
|
||||
},
|
||||
|
||||
load_feed_classifier: function() {
|
||||
var $loading = $('.NB-modal-loading', this.$manage);
|
||||
$loading.addClass('NB-active');
|
||||
|
||||
this.model.get_feed_classifier(this.feed_id, $.rescope(this.post_load_feed_classifier, this));
|
||||
},
|
||||
|
||||
post_load_feed_classifier: function(e, classifiers) {
|
||||
var $loading = $('.NB-modal-loading', this.$manage);
|
||||
$loading.removeClass('NB-active');
|
||||
|
||||
var $likes = $('.NB-manage-classifier-likes');
|
||||
var $classifiers_likes = this.make_classifiers(classifiers.payload, 1);
|
||||
$likes.empty().append($classifiers_likes);
|
||||
|
||||
var $dislikes = $('.NB-manage-classifier-dislikes');
|
||||
var $classifiers_dislikes = this.make_classifiers(classifiers.payload, -1);
|
||||
$dislikes.empty().append($classifiers_dislikes);
|
||||
|
||||
$('.NB-classifier', this.$manage).corner('14px');
|
||||
},
|
||||
|
||||
open_modal: function() {
|
||||
var self = this;
|
||||
|
||||
this.$manage.modal({
|
||||
'minWidth': 600,
|
||||
'maxWidth': 600,
|
||||
'overlayClose': true,
|
||||
'onOpen': function (dialog) {
|
||||
dialog.overlay.fadeIn(200, function () {
|
||||
dialog.container.fadeIn(200);
|
||||
dialog.data.fadeIn(200);
|
||||
});
|
||||
},
|
||||
'onShow': function(dialog) {
|
||||
$('#simplemodal-container').corner('6px');
|
||||
// $('.NB-classifier-tag', self.$manage).corner('4px');
|
||||
},
|
||||
'onClose': function(dialog) {
|
||||
dialog.data.hide().empty().remove();
|
||||
dialog.container.hide().empty().remove();
|
||||
dialog.overlay.fadeOut(200, function() {
|
||||
dialog.overlay.empty().remove();
|
||||
$.modal.close();
|
||||
});
|
||||
$('.NB-modal-holder').empty().remove();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
handle_cancel: function() {
|
||||
var $cancel = $('.NB-modal-cancel', this.$manage);
|
||||
|
||||
$cancel.click(function(e) {
|
||||
e.preventDefault();
|
||||
$.modal.close();
|
||||
});
|
||||
},
|
||||
|
||||
serialize_classifier: function() {
|
||||
var checked_data = $('input', this.$manage).serialize();
|
||||
var $unchecked = $('input[type=checkbox]:not(:checked)', this.$manage);
|
||||
$unchecked.attr('checked', true);
|
||||
$unchecked.each(function() {
|
||||
$(this).attr('name', 'remove_' + $(this).attr('name'));
|
||||
});
|
||||
var unchecked_data = $unchecked.serialize();
|
||||
$unchecked.each(function() {
|
||||
$(this).attr('name', $(this).attr('name').replace(/^remove_/, ''));
|
||||
});
|
||||
$unchecked.attr('checked', false);
|
||||
|
||||
var data = [checked_data, unchecked_data].join('&');
|
||||
return data;
|
||||
},
|
||||
|
||||
save: function() {
|
||||
var self = this;
|
||||
var $save = $('.NB-modal-submit-save', this.$manage);
|
||||
var data = this.serialize_classifier();
|
||||
|
||||
NEWSBLUR.reader.update_opinions(this.$manage, this.feed_id);
|
||||
|
||||
$save.text('Saving...').addClass('NB-disabled').attr('disabled', true);
|
||||
this.model.save_classifier_publisher(data, function() {
|
||||
NEWSBLUR.reader.force_feed_refresh(self.feed_id);
|
||||
$.modal.close();
|
||||
});
|
||||
},
|
||||
|
||||
save_retry_feed: function() {
|
||||
var self = this;
|
||||
var $loading = $('.NB-modal-loading', this.$manage);
|
||||
$loading.addClass('NB-active');
|
||||
|
||||
$('.NB-modal-submit-retry', this.$manage).addClass('NB-disabled').attr('value', 'Fetching...');
|
||||
this.model.save_exception_retry(this.feed_id, function() {
|
||||
NEWSBLUR.reader.force_feed_refresh(self.feed_id, function() {
|
||||
if (NEWSBLUR.reader.active_feed == self.feed_id) {
|
||||
NEWSBLUR.reader.open_feed(self.feed_id, true);
|
||||
}
|
||||
$.modal.close();
|
||||
}, true);
|
||||
});
|
||||
},
|
||||
|
||||
delete_feed: function() {
|
||||
var $loading = $('.NB-modal-loading', this.$manage);
|
||||
$loading.addClass('NB-active');
|
||||
var feed_id = this.feed_id;
|
||||
|
||||
this.model.delete_publisher(feed_id, function() {
|
||||
NEWSBLUR.reader.delete_feed(feed_id);
|
||||
$.modal.close();
|
||||
});
|
||||
},
|
||||
|
||||
handle_click: function(elem, e) {
|
||||
var self = this;
|
||||
|
||||
$.targetIs(e, { tagSelector: '.NB-modal-submit-delete' }, function($t, $p){
|
||||
e.preventDefault();
|
||||
|
||||
var $confirm = $('.NB-delete-confirm', self.$manage);
|
||||
var $cancel = $('.NB-delete-cancel', self.$manage);
|
||||
var $delete = $('.NB-modal-submit-delete', self.$manage);
|
||||
|
||||
$delete.animate({'opacity': 0}, {'duration': 500});
|
||||
$confirm.fadeIn(500);
|
||||
$cancel.fadeIn(500);
|
||||
});
|
||||
|
||||
$.targetIs(e, { tagSelector: '.NB-delete-cancel' }, function($t, $p){
|
||||
e.preventDefault();
|
||||
|
||||
var $confirm = $('.NB-delete-confirm', self.$manage);
|
||||
var $cancel = $('.NB-delete-cancel', self.$manage);
|
||||
var $delete = $('.NB-modal-submit-delete', self.$manage);
|
||||
|
||||
$delete.css({'opacity': 1});
|
||||
$confirm.css({'display': 'none'});
|
||||
$cancel.css({'display': 'none'});
|
||||
});
|
||||
|
||||
$.targetIs(e, { tagSelector: '.NB-delete-confirm' }, function($t, $p){
|
||||
e.preventDefault();
|
||||
|
||||
self.delete_feed();
|
||||
});
|
||||
|
||||
$.targetIs(e, { tagSelector: 'input', childOf: '.NB-classifier' }, function($t, $p) {
|
||||
var $submit = $('.NB-modal-submit-save', self.$manage);
|
||||
$submit.removeClass("NB-disabled").removeAttr('disabled').attr('value', 'Save');
|
||||
});
|
||||
|
||||
$.targetIs(e, { tagSelector: '.NB-modal-submit-retry' }, function($t, $p) {
|
||||
e.preventDefault();
|
||||
|
||||
self.save_retry_feed();
|
||||
});
|
||||
},
|
||||
|
||||
handle_change: function(elem, e) {
|
||||
var self = this;
|
||||
|
||||
$.targetIs(e, { tagSelector: '.NB-modal-feed-chooser' }, function($t, $p){
|
||||
var feed_id = $t.val();
|
||||
self.initialize_feed(feed_id);
|
||||
self.load_feed_classifier();
|
||||
});
|
||||
|
||||
$.targetIs(e, { tagSelector: 'input[type=checkbox]', childOf: '.NB-classifier' }, function($t, $p) {
|
||||
var $submit = $('.NB-modal-submit-save', self.$manage);
|
||||
$submit.removeClass("NB-disabled").removeAttr('disabled').attr('value', 'Save');
|
||||
});
|
||||
},
|
||||
|
||||
handle_keyup: function(elem, e) {
|
||||
var self = this;
|
||||
|
||||
$.targetIs(e, { tagSelector: 'input', childOf: '.NB-manage-rename' }, function($t, $p) {
|
||||
if ($t.val() != self.feed.feed_title) {
|
||||
var $submit = $('.NB-modal-submit-save', self.$manage);
|
||||
$submit.removeClass("NB-disabled").removeAttr('disabled').attr('value', 'Save');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
|
@ -85,7 +85,7 @@
|
|||
if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context);
|
||||
var results = [];
|
||||
each(obj, function(value, index, list) {
|
||||
results.push(iterator.call(context, value, index, list));
|
||||
results[results.length] = iterator.call(context, value, index, list);
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
@ -132,7 +132,7 @@
|
|||
if (nativeFilter && obj.filter === nativeFilter) return obj.filter(iterator, context);
|
||||
var results = [];
|
||||
each(obj, function(value, index, list) {
|
||||
iterator.call(context, value, index, list) && results.push(value);
|
||||
if (iterator.call(context, value, index, list)) results[results.length] = value;
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
@ -141,7 +141,7 @@
|
|||
_.reject = function(obj, iterator, context) {
|
||||
var results = [];
|
||||
each(obj, function(value, index, list) {
|
||||
!iterator.call(context, value, index, list) && results.push(value);
|
||||
if (!iterator.call(context, value, index, list)) results[results.length] = value;
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
@ -285,7 +285,7 @@
|
|||
_.flatten = function(array) {
|
||||
return _.reduce(array, function(memo, value) {
|
||||
if (_.isArray(value)) return memo.concat(_.flatten(value));
|
||||
memo.push(value);
|
||||
memo[memo.length] = value;
|
||||
return memo;
|
||||
}, []);
|
||||
};
|
||||
|
@ -300,7 +300,7 @@
|
|||
// been sorted, you have the option of using a faster algorithm.
|
||||
_.uniq = function(array, isSorted) {
|
||||
return _.reduce(array, function(memo, el, i) {
|
||||
if (0 == i || (isSorted === true ? _.last(memo) != el : !_.include(memo, el))) memo.push(el);
|
||||
if (0 == i || (isSorted === true ? _.last(memo) != el : !_.include(memo, el))) memo[memo.length] = el;
|
||||
return memo;
|
||||
}, []);
|
||||
};
|
||||
|
@ -322,7 +322,7 @@
|
|||
var args = _.toArray(arguments);
|
||||
var length = _.max(_.pluck(args, 'length'));
|
||||
var results = new Array(length);
|
||||
for (var i = 0; i < length; i++) results[i] = _.pluck(args, String(i));
|
||||
for (var i = 0; i < length; i++) results[i] = _.pluck(args, "" + i);
|
||||
return results;
|
||||
};
|
||||
|
||||
|
@ -434,7 +434,7 @@
|
|||
_.keys = nativeKeys || function(obj) {
|
||||
if (_.isArray(obj)) return _.range(0, obj.length);
|
||||
var keys = [];
|
||||
for (var key in obj) if (hasOwnProperty.call(obj, key)) keys.push(key);
|
||||
for (var key in obj) if (hasOwnProperty.call(obj, key)) keys[keys.length] = key;
|
||||
return keys;
|
||||
};
|
||||
|
||||
|
@ -525,7 +525,7 @@
|
|||
|
||||
// Is a given variable an arguments object?
|
||||
_.isArguments = function(obj) {
|
||||
return obj && obj.callee;
|
||||
return !!(obj && obj.callee);
|
||||
};
|
||||
|
||||
// Is a given value a function?
|
||||
|
@ -630,8 +630,8 @@
|
|||
var c = _.templateSettings;
|
||||
var endMatch = new RegExp("'(?=[^"+c.end.substr(0, 1)+"]*"+escapeRegExp(c.end)+")","g");
|
||||
var fn = new Function('obj',
|
||||
'var p=[],print=function(){p.push.apply(p,arguments);};' +
|
||||
'with(obj||{}){p.push(\'' +
|
||||
'var __p=[],print=function(){__p.push.apply(__p,arguments);};' +
|
||||
'with(obj||{}){__p.push(\'' +
|
||||
str.replace(/\r/g, '\\r')
|
||||
.replace(/\n/g, '\\n')
|
||||
.replace(/\t/g, '\\t')
|
||||
|
@ -640,8 +640,8 @@
|
|||
.split("✄").join("'")
|
||||
.replace(c.interpolate, "',$1,'")
|
||||
.split(c.start).join("');")
|
||||
.split(c.end).join("p.push('")
|
||||
+ "');}return p.join('');");
|
||||
.split(c.end).join("__p.push('")
|
||||
+ "');}return __p.join('');");
|
||||
return data ? fn(data) : fn;
|
||||
};
|
||||
|
||||
|
|
|
@ -86,6 +86,7 @@ COMPRESS_JS = {
|
|||
'all': {
|
||||
'source_filenames': (
|
||||
'js/jquery-1.4.2.js',
|
||||
'js/inflector.js',
|
||||
'js/jquery.json.js',
|
||||
'js/jquery.easing.js',
|
||||
'js/jquery.newsblur.js',
|
||||
|
@ -114,7 +115,6 @@ COMPRESS_JS = {
|
|||
'js/newsblur/reader.js',
|
||||
'js/newsblur/reader_classifier.js',
|
||||
'js/newsblur/reader_add_feed.js',
|
||||
'js/newsblur/reader_manage_feed.js',
|
||||
'js/newsblur/reader_mark_read.js',
|
||||
'js/newsblur/reader_preferences.js',
|
||||
'js/newsblur/reader_feedchooser.js',
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
{% load compressed utils_tags %}
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>{% block title %}NewsBlur{% endblock %}</title>
|
||||
|
|
Loading…
Add table
Reference in a new issue