diaspora/app/assets/javascripts/app/views/bookmarklet_view.js
theworldbright 98f11b944a Fix styleguide violations
Fix hound remark 12

Remove unnecessary explicit div tag

Rename el_**** to ****El (hound remark 2 and 3)

Only find and replace operations were done with
this commit

Fix hound remark 4 and 8

Fix hound remark 6

Fix hound remark 7

Fix hound remark 9

Fix hound remark 10 and 11

Fix hound remark 13

Fix hound remark 1

Change single quotes to double quotes

Change single quotes to double in publisher view

Fix camelCase and missing {} in publisher view

Change single quotes to double in bookmarklet view

Use dot notation for serializedForm in publisher

Change single quotes to double in bookmarklet spec

Change single quotes to double in publisher spec

Fix missing {} in publisher views

Use ruby 1.9 hash syntax in invite_link

Fix indentation in publisher view
2015-06-04 18:05:44 +02:00

53 lines
1.4 KiB
JavaScript

// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
app.views.Bookmarklet = Backbone.View.extend({
separator: "\n\n",
initialize: function(opts) {
// init a standalone publisher
app.publisher = new app.views.Publisher({standalone: true});
app.publisher.on("publisher:add", this._postSubmit, this);
app.publisher.on("publisher:sync", this._postSuccess, this);
app.publisher.on("publisher:error", this._postError, this);
this.param_contents = opts;
},
render: function() {
app.publisher.open();
app.publisher.setText(this._publisherContent());
return this;
},
_publisherContent: function() {
var p = this.param_contents;
if( p.content ) return p.content;
var contents = "### " + p.title + this.separator;
if( p.notes ) {
var notes = p.notes.toString().replace(/(?:\r\n|\r|\n)/g, "\n> ");
contents += "> " + notes + this.separator;
}
contents += p.url;
return contents;
},
_postSubmit: function() {
this.$("h4").text(Diaspora.I18n.t("bookmarklet.post_submit"));
},
_postSuccess: function() {
this.$("h4").text(Diaspora.I18n.t("bookmarklet.post_success"));
app.publisher.close();
this.$("#publisher").addClass("hidden");
_.delay(window.close, 2000);
},
_postError: function() {
this.$("h4").text(Diaspora.I18n.t("bookmarklet.post_something"));
}
});
// @license-end