Merge branch 'master' into social

* master:
  Updating bookmarklet. Showing when the bookmarklet is broken, and fixes bugs with enumerable prototype chain fucking.
This commit is contained in:
Samuel Clay 2012-04-21 17:31:01 -07:00
commit 1f18f0e8dc
3 changed files with 35 additions and 1 deletions

View file

@ -83,7 +83,7 @@ def add_site_load_script(request, token):
return render_to_response('api/bookmarklet_subscribe.js', {
'code': code,
'token': token,
'folders': usf and usf.folders,
'folders': (usf and usf.folders) or [],
'accept_image': accept_image,
'error_image': error_image,
'add_image': add_image,

View file

@ -498,6 +498,7 @@
}
.NB-bookmarklet .NB-modal-submit {
margin: 24px 0 8px;
padding: 0 0 6px;
}
.NB-bookmarklet .NB-modal-submit-button {
clear: both;
@ -505,6 +506,7 @@
line-height: 24px;
width: 200px;
text-align: center;
text-shadow: none;
}
.NB-bookmarklet .NB-modal-submit-button img {
margin: 5px 6px 0 0;
@ -530,4 +532,16 @@
}
.NB-bookmarklet .NB-folders {
float: right;
}
.NB-bookmarklet .NB-error-invalid {
padding: 12px 12px;
font-size: 13px;
text-shadow: none;
color: white;
background-color: #690F0F;
border-radius: 8px;
}
.NB-bookmarklet .NB-error-invalid a {
color: #9FC6F5;
text-decoration: underline;
}

View file

@ -18,6 +18,10 @@
this.options = $.extend({}, defaults, options);
this.runner();
{% if code < 0 %}
this.show_error();
{% endif %}
};
NEWSBLUR.BookmarkletModal.prototype = {
@ -47,6 +51,15 @@
this.$modal.bind('click', $.rescope(this.handle_clicks, this));
},
show_error: function() {
$('.NB-bookmarklet-folder-container', this.$modal).hide();
$('.NB-modal-submit', this.$modal).html($.make('div', { className: 'NB-error-invalid' }, [
'This bookmarklet no longer matches an account. Re-create it in ',
$.make('a', { href: 'http://www.newsblur.com/?next=goodies' }, 'Goodies on NewsBlur'),
'.'
]));
},
attach_css: function() {
var css = "{% include_bookmarklet_css %}";
var style = '<style>' + css + '</style>';
@ -110,11 +123,18 @@
},
make_folder_options: function($options, items, depth) {
if (depth && depth.length > 5) {
return $options;
}
for (var i in items) {
if (!items.hasOwnProperty(i)) continue;
var item = items[i];
if (typeof item == "object") {
for (var o in item) {
if (!item.hasOwnProperty(o)) continue;
var folder = item[o];
console.log(["make_folder_options", folder, o, depth]);
var $option = $.make('option', { value: o }, depth + ' ' + o);
$options.append($option);
$options = this.make_folder_options($options, folder, depth+'-');