More Markdown refactoring - fixed bug with Pagedown not showing on user profile - replaced jQuery occurrences with $.
This commit is contained in:
parent
cf09e200a5
commit
86af49e663
|
@ -25,7 +25,7 @@ Discourse.AdminEmailLogsController = Ember.ArrayController.extend(Discourse.Pres
|
||||||
sendTestEmail: function() {
|
sendTestEmail: function() {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
_this.set('sentTestEmail', false);
|
_this.set('sentTestEmail', false);
|
||||||
jQuery.ajax({
|
$.ajax({
|
||||||
url: '/admin/email_logs/test',
|
url: '/admin/email_logs/test',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: { email_address: this.get('testEmailAddress') },
|
data: { email_address: this.get('testEmailAddress') },
|
||||||
|
|
|
@ -10,7 +10,7 @@ Discourse.AdminUser = Discourse.Model.extend({
|
||||||
|
|
||||||
deleteAllPosts: function() {
|
deleteAllPosts: function() {
|
||||||
this.set('can_delete_all_posts', false);
|
this.set('can_delete_all_posts', false);
|
||||||
jQuery.ajax("/admin/users/" + (this.get('id')) + "/delete_all_posts", {type: 'PUT'});
|
$.ajax("/admin/users/" + (this.get('id')) + "/delete_all_posts", {type: 'PUT'});
|
||||||
},
|
},
|
||||||
|
|
||||||
// Revoke the user's admin access
|
// Revoke the user's admin access
|
||||||
|
@ -18,14 +18,14 @@ Discourse.AdminUser = Discourse.Model.extend({
|
||||||
this.set('admin', false);
|
this.set('admin', false);
|
||||||
this.set('can_grant_admin', true);
|
this.set('can_grant_admin', true);
|
||||||
this.set('can_revoke_admin', false);
|
this.set('can_revoke_admin', false);
|
||||||
return jQuery.ajax("/admin/users/" + (this.get('id')) + "/revoke_admin", {type: 'PUT'});
|
return $.ajax("/admin/users/" + (this.get('id')) + "/revoke_admin", {type: 'PUT'});
|
||||||
},
|
},
|
||||||
|
|
||||||
grantAdmin: function() {
|
grantAdmin: function() {
|
||||||
this.set('admin', true);
|
this.set('admin', true);
|
||||||
this.set('can_grant_admin', false);
|
this.set('can_grant_admin', false);
|
||||||
this.set('can_revoke_admin', true);
|
this.set('can_revoke_admin', true);
|
||||||
jQuery.ajax("/admin/users/" + (this.get('id')) + "/grant_admin", {type: 'PUT'});
|
$.ajax("/admin/users/" + (this.get('id')) + "/grant_admin", {type: 'PUT'});
|
||||||
},
|
},
|
||||||
|
|
||||||
// Revoke the user's moderation access
|
// Revoke the user's moderation access
|
||||||
|
@ -33,18 +33,18 @@ Discourse.AdminUser = Discourse.Model.extend({
|
||||||
this.set('moderator', false);
|
this.set('moderator', false);
|
||||||
this.set('can_grant_moderation', true);
|
this.set('can_grant_moderation', true);
|
||||||
this.set('can_revoke_moderation', false);
|
this.set('can_revoke_moderation', false);
|
||||||
return jQuery.ajax("/admin/users/" + (this.get('id')) + "/revoke_moderation", {type: 'PUT'});
|
return $.ajax("/admin/users/" + (this.get('id')) + "/revoke_moderation", {type: 'PUT'});
|
||||||
},
|
},
|
||||||
|
|
||||||
grantModeration: function() {
|
grantModeration: function() {
|
||||||
this.set('moderator', true);
|
this.set('moderator', true);
|
||||||
this.set('can_grant_moderation', false);
|
this.set('can_grant_moderation', false);
|
||||||
this.set('can_revoke_moderation', true);
|
this.set('can_revoke_moderation', true);
|
||||||
jQuery.ajax("/admin/users/" + (this.get('id')) + "/grant_moderation", {type: 'PUT'});
|
$.ajax("/admin/users/" + (this.get('id')) + "/grant_moderation", {type: 'PUT'});
|
||||||
},
|
},
|
||||||
|
|
||||||
refreshBrowsers: function() {
|
refreshBrowsers: function() {
|
||||||
jQuery.ajax("/admin/users/" + (this.get('id')) + "/refresh_browsers", {type: 'POST'});
|
$.ajax("/admin/users/" + (this.get('id')) + "/refresh_browsers", {type: 'POST'});
|
||||||
bootbox.alert("Message sent to all clients!");
|
bootbox.alert("Message sent to all clients!");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ Discourse.AdminUser = Discourse.Model.extend({
|
||||||
this.set('can_approve', false);
|
this.set('can_approve', false);
|
||||||
this.set('approved', true);
|
this.set('approved', true);
|
||||||
this.set('approved_by', Discourse.get('currentUser'));
|
this.set('approved_by', Discourse.get('currentUser'));
|
||||||
jQuery.ajax("/admin/users/" + (this.get('id')) + "/approve", {type: 'PUT'});
|
$.ajax("/admin/users/" + (this.get('id')) + "/approve", {type: 'PUT'});
|
||||||
},
|
},
|
||||||
|
|
||||||
username_lower: (function() {
|
username_lower: (function() {
|
||||||
|
@ -79,7 +79,7 @@ Discourse.AdminUser = Discourse.Model.extend({
|
||||||
_this = this;
|
_this = this;
|
||||||
if (duration = parseInt(window.prompt(Em.String.i18n('admin.user.ban_duration')), 10)) {
|
if (duration = parseInt(window.prompt(Em.String.i18n('admin.user.ban_duration')), 10)) {
|
||||||
if (duration > 0) {
|
if (duration > 0) {
|
||||||
return jQuery.ajax("/admin/users/" + this.id + "/ban", {
|
return $.ajax("/admin/users/" + this.id + "/ban", {
|
||||||
type: 'PUT',
|
type: 'PUT',
|
||||||
data: {duration: duration},
|
data: {duration: duration},
|
||||||
success: function() {
|
success: function() {
|
||||||
|
@ -99,7 +99,7 @@ Discourse.AdminUser = Discourse.Model.extend({
|
||||||
|
|
||||||
unban: function() {
|
unban: function() {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
return jQuery.ajax("/admin/users/" + this.id + "/unban", {
|
return $.ajax("/admin/users/" + this.id + "/unban", {
|
||||||
type: 'PUT',
|
type: 'PUT',
|
||||||
success: function() {
|
success: function() {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
|
@ -116,7 +116,7 @@ Discourse.AdminUser = Discourse.Model.extend({
|
||||||
|
|
||||||
impersonate: function() {
|
impersonate: function() {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
return jQuery.ajax("/admin/impersonate", {
|
return $.ajax("/admin/impersonate", {
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: {
|
data: {
|
||||||
username_or_email: this.get('username')
|
username_or_email: this.get('username')
|
||||||
|
@ -145,7 +145,7 @@ Discourse.AdminUser.reopenClass({
|
||||||
user.set('can_approve', false);
|
user.set('can_approve', false);
|
||||||
return user.set('selected', false);
|
return user.set('selected', false);
|
||||||
});
|
});
|
||||||
return jQuery.ajax("/admin/users/approve-bulk", {
|
return $.ajax("/admin/users/approve-bulk", {
|
||||||
type: 'PUT',
|
type: 'PUT',
|
||||||
data: {
|
data: {
|
||||||
users: users.map(function(u) {
|
users: users.map(function(u) {
|
||||||
|
@ -158,7 +158,7 @@ Discourse.AdminUser.reopenClass({
|
||||||
find: function(username) {
|
find: function(username) {
|
||||||
var promise;
|
var promise;
|
||||||
promise = new RSVP.Promise();
|
promise = new RSVP.Promise();
|
||||||
jQuery.ajax({
|
$.ajax({
|
||||||
url: "/admin/users/" + username,
|
url: "/admin/users/" + username,
|
||||||
success: function(result) {
|
success: function(result) {
|
||||||
return promise.resolve(Discourse.AdminUser.create(result));
|
return promise.resolve(Discourse.AdminUser.create(result));
|
||||||
|
@ -170,7 +170,7 @@ Discourse.AdminUser.reopenClass({
|
||||||
findAll: function(query, filter) {
|
findAll: function(query, filter) {
|
||||||
var result;
|
var result;
|
||||||
result = Em.A();
|
result = Em.A();
|
||||||
jQuery.ajax({
|
$.ajax({
|
||||||
url: "/admin/users/list/" + query + ".json",
|
url: "/admin/users/list/" + query + ".json",
|
||||||
data: {
|
data: {
|
||||||
filter: filter
|
filter: filter
|
||||||
|
|
|
@ -19,7 +19,7 @@ Discourse.EmailLog.reopenClass({
|
||||||
findAll: function(filter) {
|
findAll: function(filter) {
|
||||||
var result;
|
var result;
|
||||||
result = Em.A();
|
result = Em.A();
|
||||||
jQuery.ajax({
|
$.ajax({
|
||||||
url: "/admin/email_logs.json",
|
url: "/admin/email_logs.json",
|
||||||
data: { filter: filter },
|
data: { filter: filter },
|
||||||
success: function(logs) {
|
success: function(logs) {
|
||||||
|
|
|
@ -49,7 +49,7 @@ Discourse.FlaggedPost = Discourse.Post.extend({
|
||||||
var promise;
|
var promise;
|
||||||
promise = new RSVP.Promise();
|
promise = new RSVP.Promise();
|
||||||
if (this.get('post_number') === "1") {
|
if (this.get('post_number') === "1") {
|
||||||
return jQuery.ajax("/t/" + this.topic_id, {
|
return $.ajax("/t/" + this.topic_id, {
|
||||||
type: 'DELETE',
|
type: 'DELETE',
|
||||||
cache: false,
|
cache: false,
|
||||||
success: function() {
|
success: function() {
|
||||||
|
@ -60,7 +60,7 @@ Discourse.FlaggedPost = Discourse.Post.extend({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
return jQuery.ajax("/posts/" + this.id, {
|
return $.ajax("/posts/" + this.id, {
|
||||||
type: 'DELETE',
|
type: 'DELETE',
|
||||||
cache: false,
|
cache: false,
|
||||||
success: function() {
|
success: function() {
|
||||||
|
@ -76,7 +76,7 @@ Discourse.FlaggedPost = Discourse.Post.extend({
|
||||||
clearFlags: function() {
|
clearFlags: function() {
|
||||||
var promise;
|
var promise;
|
||||||
promise = new RSVP.Promise();
|
promise = new RSVP.Promise();
|
||||||
jQuery.ajax("/admin/flags/clear/" + this.id, {
|
$.ajax("/admin/flags/clear/" + this.id, {
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
cache: false,
|
cache: false,
|
||||||
success: function() {
|
success: function() {
|
||||||
|
@ -99,7 +99,7 @@ Discourse.FlaggedPost.reopenClass({
|
||||||
findAll: function(filter) {
|
findAll: function(filter) {
|
||||||
var result;
|
var result;
|
||||||
result = Em.A();
|
result = Em.A();
|
||||||
jQuery.ajax({
|
$.ajax({
|
||||||
url: "/admin/flags/" + filter + ".json",
|
url: "/admin/flags/" + filter + ".json",
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
var userLookup;
|
var userLookup;
|
||||||
|
|
|
@ -3,7 +3,7 @@ Discourse.Report = Discourse.Model.extend({});
|
||||||
Discourse.Report.reopenClass({
|
Discourse.Report.reopenClass({
|
||||||
find: function(type) {
|
find: function(type) {
|
||||||
var model = Discourse.Report.create();
|
var model = Discourse.Report.create();
|
||||||
jQuery.ajax("/admin/reports/" + type, {
|
$.ajax("/admin/reports/" + type, {
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
model.mergeAttributes(json.report);
|
model.mergeAttributes(json.report);
|
||||||
|
|
|
@ -55,7 +55,7 @@ Discourse.SiteCustomization = Discourse.Model.extend({
|
||||||
header: this.header,
|
header: this.header,
|
||||||
override_default_style: this.override_default_style
|
override_default_style: this.override_default_style
|
||||||
};
|
};
|
||||||
return jQuery.ajax({
|
return $.ajax({
|
||||||
url: "/admin/site_customizations" + (this.id ? '/' + this.id : ''),
|
url: "/admin/site_customizations" + (this.id ? '/' + this.id : ''),
|
||||||
data: {
|
data: {
|
||||||
site_customization: data
|
site_customization: data
|
||||||
|
@ -67,7 +67,7 @@ Discourse.SiteCustomization = Discourse.Model.extend({
|
||||||
"delete": function() {
|
"delete": function() {
|
||||||
if (!this.id) return;
|
if (!this.id) return;
|
||||||
|
|
||||||
return jQuery.ajax({
|
return $.ajax({
|
||||||
url: "/admin/site_customizations/" + this.id,
|
url: "/admin/site_customizations/" + this.id,
|
||||||
type: 'DELETE'
|
type: 'DELETE'
|
||||||
});
|
});
|
||||||
|
@ -93,7 +93,7 @@ Discourse.SiteCustomization.reopenClass({
|
||||||
content: [],
|
content: [],
|
||||||
loading: true
|
loading: true
|
||||||
});
|
});
|
||||||
jQuery.ajax({
|
$.ajax({
|
||||||
url: "/admin/site_customizations",
|
url: "/admin/site_customizations",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
|
|
|
@ -72,7 +72,7 @@ Discourse.SiteSetting = Discourse.Model.extend({
|
||||||
save: function() {
|
save: function() {
|
||||||
// Update the setting
|
// Update the setting
|
||||||
var setting = this;
|
var setting = this;
|
||||||
return jQuery.ajax("/admin/site_settings/" + (this.get('setting')), {
|
return $.ajax("/admin/site_settings/" + (this.get('setting')), {
|
||||||
data: { value: this.get('value') },
|
data: { value: this.get('value') },
|
||||||
type: 'PUT',
|
type: 'PUT',
|
||||||
success: function() {
|
success: function() {
|
||||||
|
@ -91,7 +91,7 @@ Discourse.SiteSetting.reopenClass({
|
||||||
**/
|
**/
|
||||||
findAll: function() {
|
findAll: function() {
|
||||||
var result = Em.A();
|
var result = Em.A();
|
||||||
jQuery.get("/admin/site_settings", function(settings) {
|
$.get("/admin/site_settings", function(settings) {
|
||||||
return settings.each(function(s) {
|
return settings.each(function(s) {
|
||||||
s.originalValue = s.value;
|
s.originalValue = s.value;
|
||||||
return result.pushObject(Discourse.SiteSetting.create(s));
|
return result.pushObject(Discourse.SiteSetting.create(s));
|
||||||
|
|
|
@ -23,7 +23,7 @@ Discourse.VersionCheck = Discourse.Model.extend({
|
||||||
Discourse.VersionCheck.reopenClass({
|
Discourse.VersionCheck.reopenClass({
|
||||||
find: function() {
|
find: function() {
|
||||||
var promise = new RSVP.Promise();
|
var promise = new RSVP.Promise();
|
||||||
jQuery.ajax({
|
$.ajax({
|
||||||
url: '/admin/version_check',
|
url: '/admin/version_check',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
|
|
|
@ -142,7 +142,7 @@ Discourse = Ember.Application.createWithMixins({
|
||||||
|
|
||||||
// Add a CSRF token to all AJAX requests
|
// Add a CSRF token to all AJAX requests
|
||||||
var csrfToken = $('meta[name=csrf-token]').attr('content');
|
var csrfToken = $('meta[name=csrf-token]').attr('content');
|
||||||
jQuery.ajaxPrefilter(function(options, originalOptions, xhr) {
|
$.ajaxPrefilter(function(options, originalOptions, xhr) {
|
||||||
if (!options.crossDomain) {
|
if (!options.crossDomain) {
|
||||||
xhr.setRequestHeader('X-CSRF-Token', csrfToken);
|
xhr.setRequestHeader('X-CSRF-Token', csrfToken);
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ Discourse = Ember.Application.createWithMixins({
|
||||||
**/
|
**/
|
||||||
logout: function() {
|
logout: function() {
|
||||||
Discourse.KeyValueStore.abandonLocal();
|
Discourse.KeyValueStore.abandonLocal();
|
||||||
return jQuery.ajax("/session/" + this.get('currentUser.username'), {
|
return $.ajax("/session/" + this.get('currentUser.username'), {
|
||||||
type: 'DELETE',
|
type: 'DELETE',
|
||||||
success: function(result) {
|
success: function(result) {
|
||||||
// To keep lots of our variables unbound, we can handle a redirect on logging out.
|
// To keep lots of our variables unbound, we can handle a redirect on logging out.
|
||||||
|
|
|
@ -47,7 +47,7 @@ $.fn.autocomplete = function(options) {
|
||||||
}
|
}
|
||||||
return d.find('a').click(function() {
|
return d.find('a').click(function() {
|
||||||
closeAutocomplete();
|
closeAutocomplete();
|
||||||
inputSelectedItems.splice(jQuery.inArray(item), 1);
|
inputSelectedItems.splice($.inArray(item), 1);
|
||||||
$(this).parent().parent().remove();
|
$(this).parent().parent().remove();
|
||||||
if (options.onChangeItems) {
|
if (options.onChangeItems) {
|
||||||
return options.onChangeItems(inputSelectedItems);
|
return options.onChangeItems(inputSelectedItems);
|
||||||
|
|
|
@ -70,7 +70,7 @@ Discourse.ClickTrack = {
|
||||||
|
|
||||||
// if they want to open in a new tab, do an AJAX request
|
// if they want to open in a new tab, do an AJAX request
|
||||||
if (e.metaKey || e.ctrlKey || e.which === 2) {
|
if (e.metaKey || e.ctrlKey || e.which === 2) {
|
||||||
jQuery.get("/clicks/track", {
|
$.get("/clicks/track", {
|
||||||
url: href,
|
url: href,
|
||||||
post_id: postId,
|
post_id: postId,
|
||||||
topic_id: topicId,
|
topic_id: topicId,
|
||||||
|
@ -82,7 +82,7 @@ Discourse.ClickTrack = {
|
||||||
|
|
||||||
// If we're on the same site, use the router and track via AJAX
|
// If we're on the same site, use the router and track via AJAX
|
||||||
if (href.indexOf(window.location.origin) === 0) {
|
if (href.indexOf(window.location.origin) === 0) {
|
||||||
jQuery.get("/clicks/track", {
|
$.get("/clicks/track", {
|
||||||
url: href,
|
url: href,
|
||||||
post_id: postId,
|
post_id: postId,
|
||||||
topic_id: topicId,
|
topic_id: topicId,
|
||||||
|
|
|
@ -129,7 +129,7 @@ Discourse.Development = {
|
||||||
return $LAB.script(js + "?hash=" + me.hash).wait(function() {
|
return $LAB.script(js + "?hash=" + me.hash).wait(function() {
|
||||||
var templateName;
|
var templateName;
|
||||||
templateName = js.replace(".js", "").replace("/assets/", "");
|
templateName = js.replace(".js", "").replace("/assets/", "");
|
||||||
return jQuery.each(Ember.View.views, function() {
|
return $.each(Ember.View.views, function() {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
if (this.get('templateName') === templateName) {
|
if (this.get('templateName') === templateName) {
|
||||||
this.set('templateName', 'empty');
|
this.set('templateName', 'empty');
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*global sanitizeHtml:true Markdown:true */
|
/*global Markdown:true */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Contains methods to help us with markdown formatting.
|
Contains methods to help us with markdown formatting.
|
||||||
|
@ -15,6 +15,7 @@ Discourse.Markdown = {
|
||||||
@method cook
|
@method cook
|
||||||
@param {String} raw the raw string we want to apply markdown to
|
@param {String} raw the raw string we want to apply markdown to
|
||||||
@param {Object} opts the options for the rendering
|
@param {Object} opts the options for the rendering
|
||||||
|
@return {String} the cooked markdown string
|
||||||
**/
|
**/
|
||||||
cook: function(raw, opts) {
|
cook: function(raw, opts) {
|
||||||
if (!opts) opts = {};
|
if (!opts) opts = {};
|
||||||
|
@ -23,60 +24,67 @@ Discourse.Markdown = {
|
||||||
if (!raw) return "";
|
if (!raw) return "";
|
||||||
if (raw.length === 0) return "";
|
if (raw.length === 0) return "";
|
||||||
|
|
||||||
this.converter = this.markdownConverter(opts);
|
return this.markdownConverter(opts).makeHtml(raw);
|
||||||
return this.converter.makeHtml(raw);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Creates a new markdown editor
|
Creates a new pagedown markdown editor, supplying i18n translations.
|
||||||
|
|
||||||
@method createNewMarkdownEditor
|
@method createEditor
|
||||||
@param {Markdown.Converter} markdownConverter the converter object
|
@param {Object} converterOptions custom options for our markdown converter
|
||||||
@param {String} idPostfix
|
@return {Markdown.Editor} the editor instance
|
||||||
@param {Object} options the options for the markdown editor
|
|
||||||
**/
|
**/
|
||||||
createNewMarkdownEditor: function(markdownConverter, idPostfix, options) {
|
createEditor: function(converterOptions) {
|
||||||
options = options || {};
|
|
||||||
options.strings = {
|
|
||||||
bold: I18n.t("js.composer.bold_title") + " <strong> Ctrl+B",
|
|
||||||
boldexample: I18n.t("js.composer.bold_text"),
|
|
||||||
|
|
||||||
italic: I18n.t("js.composer.italic_title") + " <em> Ctrl+I",
|
if (!converterOptions) converterOptions = {};
|
||||||
italicexample: I18n.t("js.composer.italic_text"),
|
|
||||||
|
|
||||||
link: I18n.t("js.composer.link_title") + " <a> Ctrl+L",
|
// By default we always sanitize content in the editor
|
||||||
linkdescription: "enter link description here",
|
converterOptions.sanitize = true;
|
||||||
linkdialog: "<p><b>" + I18n.t("js.composer.link_dialog_title") + "</b></p><p>http://example.com/ \"" +
|
|
||||||
I18n.t("js.composer.link_optional_text") + "\"</p>",
|
|
||||||
|
|
||||||
quote: I18n.t("js.composer.quote_title") + " <blockquote> Ctrl+Q",
|
var markdownConverter = Discourse.Markdown.markdownConverter(converterOptions);
|
||||||
quoteexample: I18n.t("js.composer.quote_text"),
|
|
||||||
|
|
||||||
code: I18n.t("js.composer.code_title") + " <pre><code> Ctrl+K",
|
var editorOptions = {
|
||||||
codeexample: I18n.t("js.composer.code_text"),
|
strings: {
|
||||||
|
bold: I18n.t("js.composer.bold_title") + " <strong> Ctrl+B",
|
||||||
|
boldexample: I18n.t("js.composer.bold_text"),
|
||||||
|
|
||||||
image: I18n.t("js.composer.image_title") + " <img> Ctrl+G",
|
italic: I18n.t("js.composer.italic_title") + " <em> Ctrl+I",
|
||||||
imagedescription: I18n.t("js.composer.image_description"),
|
italicexample: I18n.t("js.composer.italic_text"),
|
||||||
imagedialog: "<p><b>" + I18n.t("js.composer.image_dialog_title") + "</b></p><p>http://example.com/images/diagram.jpg \"" +
|
|
||||||
I18n.t("js.composer.image_optional_text") + "\"<br><br>" + I18n.t("js.composer.image_hosting_hint") + "</p>",
|
|
||||||
|
|
||||||
olist: I18n.t("js.composer.olist_title") + " <ol> Ctrl+O",
|
link: I18n.t("js.composer.link_title") + " <a> Ctrl+L",
|
||||||
ulist: I18n.t("js.composer.ulist_title") + " <ul> Ctrl+U",
|
linkdescription: "enter link description here",
|
||||||
litem: I18n.t("js.compser.list_item"),
|
linkdialog: "<p><b>" + I18n.t("js.composer.link_dialog_title") + "</b></p><p>http://example.com/ \"" +
|
||||||
|
I18n.t("js.composer.link_optional_text") + "\"</p>",
|
||||||
|
|
||||||
heading: I18n.t("js.composer.heading_title") + " <h1>/<h2> Ctrl+H",
|
quote: I18n.t("js.composer.quote_title") + " <blockquote> Ctrl+Q",
|
||||||
headingexample: I18n.t("js.composer.heading_text"),
|
quoteexample: I18n.t("js.composer.quote_text"),
|
||||||
|
|
||||||
hr: I18n.t("js.composer_hr_title") + " <hr> Ctrl+R",
|
code: I18n.t("js.composer.code_title") + " <pre><code> Ctrl+K",
|
||||||
|
codeexample: I18n.t("js.composer.code_text"),
|
||||||
|
|
||||||
undo: I18n.t("js.composer.undo_title") + " - Ctrl+Z",
|
image: I18n.t("js.composer.image_title") + " <img> Ctrl+G",
|
||||||
redo: I18n.t("js.composer.redo_title") + " - Ctrl+Y",
|
imagedescription: I18n.t("js.composer.image_description"),
|
||||||
redomac: I18n.t("js.composer.redo_title") + " - Ctrl+Shift+Z",
|
imagedialog: "<p><b>" + I18n.t("js.composer.image_dialog_title") + "</b></p><p>http://example.com/images/diagram.jpg \"" +
|
||||||
|
I18n.t("js.composer.image_optional_text") + "\"<br><br>" + I18n.t("js.composer.image_hosting_hint") + "</p>",
|
||||||
|
|
||||||
help: I18n.t("js.composer.help")
|
olist: I18n.t("js.composer.olist_title") + " <ol> Ctrl+O",
|
||||||
|
ulist: I18n.t("js.composer.ulist_title") + " <ul> Ctrl+U",
|
||||||
|
litem: I18n.t("js.compser.list_item"),
|
||||||
|
|
||||||
|
heading: I18n.t("js.composer.heading_title") + " <h1>/<h2> Ctrl+H",
|
||||||
|
headingexample: I18n.t("js.composer.heading_text"),
|
||||||
|
|
||||||
|
hr: I18n.t("js.composer_hr_title") + " <hr> Ctrl+R",
|
||||||
|
|
||||||
|
undo: I18n.t("js.composer.undo_title") + " - Ctrl+Z",
|
||||||
|
redo: I18n.t("js.composer.redo_title") + " - Ctrl+Y",
|
||||||
|
redomac: I18n.t("js.composer.redo_title") + " - Ctrl+Shift+Z",
|
||||||
|
|
||||||
|
help: I18n.t("js.composer.help")
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return new Markdown.Editor(markdownConverter, idPostfix, options);
|
return new Markdown.Editor(markdownConverter, undefined, editorOptions);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -86,21 +94,15 @@ Discourse.Markdown = {
|
||||||
@param {Object} opts the converting options
|
@param {Object} opts the converting options
|
||||||
**/
|
**/
|
||||||
markdownConverter: function(opts) {
|
markdownConverter: function(opts) {
|
||||||
var converter, mentionLookup,
|
if (!opts) opts = {};
|
||||||
_this = this;
|
|
||||||
converter = new Markdown.Converter();
|
var converter = new Markdown.Converter();
|
||||||
if (opts) {
|
var mentionLookup = opts.mentionLookup || Discourse.Mention.lookupCache;
|
||||||
mentionLookup = opts.mentionLookup;
|
|
||||||
}
|
|
||||||
mentionLookup = mentionLookup || Discourse.Mention.lookupCache;
|
|
||||||
|
|
||||||
// Before cooking callbacks
|
// Before cooking callbacks
|
||||||
converter.hooks.chain("preConversion", function(text) {
|
converter.hooks.chain("preConversion", function(text) {
|
||||||
_this.trigger('beforeCook', {
|
Discourse.Markdown.trigger('beforeCook', { detail: text, opts: opts });
|
||||||
detail: text,
|
return Discourse.Markdown.textResult || text;
|
||||||
opts: opts
|
|
||||||
});
|
|
||||||
return _this.textResult || text;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Support autolinking of www.something.com
|
// Support autolinking of www.something.com
|
||||||
|
@ -114,9 +116,7 @@ Discourse.Markdown = {
|
||||||
if (!Discourse.SiteSettings.traditional_markdown_linebreaks) {
|
if (!Discourse.SiteSettings.traditional_markdown_linebreaks) {
|
||||||
converter.hooks.chain("preConversion", function(text) {
|
converter.hooks.chain("preConversion", function(text) {
|
||||||
return text.replace(/(^[\w<][^\n]*\n+)/gim, function(t) {
|
return text.replace(/(^[\w<][^\n]*\n+)/gim, function(t) {
|
||||||
if (t.match(/\n{2}/gim)) {
|
if (t.match(/\n{2}/gim)) return t;
|
||||||
return t;
|
|
||||||
}
|
|
||||||
return t.replace("\n", " \n");
|
return t.replace("\n", " \n");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -125,8 +125,7 @@ Discourse.Markdown = {
|
||||||
// github style fenced code
|
// github style fenced code
|
||||||
converter.hooks.chain("preConversion", function(text) {
|
converter.hooks.chain("preConversion", function(text) {
|
||||||
return text.replace(/^`{3}(?:(.*$)\n)?([\s\S]*?)^`{3}/gm, function(wholeMatch, m1, m2) {
|
return text.replace(/^`{3}(?:(.*$)\n)?([\s\S]*?)^`{3}/gm, function(wholeMatch, m1, m2) {
|
||||||
var escaped;
|
var escaped = Handlebars.Utils.escapeExpression(m2);
|
||||||
escaped = Handlebars.Utils.escapeExpression(m2);
|
|
||||||
return "<pre><code class='" + (m1 || 'lang-auto') + "'>" + escaped + "</code></pre>";
|
return "<pre><code class='" + (m1 || 'lang-auto') + "'>" + escaped + "</code></pre>";
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -142,20 +141,19 @@ Discourse.Markdown = {
|
||||||
// Add @mentions of names
|
// Add @mentions of names
|
||||||
text = text.replace(/([\s\t>,:'|";\]])(@[A-Za-z0-9_-|\.]*[A-Za-z0-9_-|]+)(?=[\s\t<\!:|;',"\?\.])/g, function(x, pre, name) {
|
text = text.replace(/([\s\t>,:'|";\]])(@[A-Za-z0-9_-|\.]*[A-Za-z0-9_-|]+)(?=[\s\t<\!:|;',"\?\.])/g, function(x, pre, name) {
|
||||||
if (mentionLookup(name.substr(1))) {
|
if (mentionLookup(name.substr(1))) {
|
||||||
return "" + pre + "<a href='/users/" + (name.substr(1).toLowerCase()) + "' class='mention'>" + name + "</a>";
|
return pre + "<a href='/users/" + (name.substr(1).toLowerCase()) + "' class='mention'>" + name + "</a>";
|
||||||
} else {
|
} else {
|
||||||
return "" + pre + "<span class='mention'>" + name + "</span>";
|
return pre + "<span class='mention'>" + name + "</span>";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// a primitive attempt at oneboxing, this regex gives me much eye sores
|
// a primitive attempt at oneboxing, this regex gives me much eye sores
|
||||||
text = text.replace(/(<li>)?((<p>|<br>)[\s\n\r]*)(<a href=["]([^"]+)[^>]*)>([^<]+<\/a>[\s\n\r]*(?=<\/p>|<br>))/gi, function() {
|
text = text.replace(/(<li>)?((<p>|<br>)[\s\n\r]*)(<a href=["]([^"]+)[^>]*)>([^<]+<\/a>[\s\n\r]*(?=<\/p>|<br>))/gi, function() {
|
||||||
// We don't onebox items in a list
|
// We don't onebox items in a list
|
||||||
var onebox, url;
|
if (arguments[1]) return arguments[0];
|
||||||
if (arguments[1]) {
|
var url = arguments[5];
|
||||||
return arguments[0];
|
var onebox;
|
||||||
}
|
|
||||||
url = arguments[5];
|
|
||||||
if (Discourse && Discourse.Onebox) {
|
if (Discourse && Discourse.Onebox) {
|
||||||
onebox = Discourse.Onebox.lookupCache(url);
|
onebox = Discourse.Onebox.lookupCache(url);
|
||||||
}
|
}
|
||||||
|
@ -175,10 +173,8 @@ Discourse.Markdown = {
|
||||||
|
|
||||||
if (opts.sanitize) {
|
if (opts.sanitize) {
|
||||||
converter.hooks.chain("postConversion", function(text) {
|
converter.hooks.chain("postConversion", function(text) {
|
||||||
if (!window.sanitizeHtml) {
|
if (!window.sanitizeHtml) return "";
|
||||||
return "";
|
return window.sanitizeHtml(text);
|
||||||
}
|
|
||||||
return sanitizeHtml(text);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return converter;
|
return converter;
|
||||||
|
|
|
@ -21,7 +21,7 @@ Discourse.Mention = (function() {
|
||||||
callback(cached);
|
callback(cached);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
jQuery.get("/users/is_local_username", {
|
$.get("/users/is_local_username", {
|
||||||
username: name
|
username: name
|
||||||
}, function(r) {
|
}, function(r) {
|
||||||
cache(name, r.valid);
|
cache(name, r.valid);
|
||||||
|
|
|
@ -68,7 +68,7 @@ Discourse.MessageBus = (function() {
|
||||||
data[c.channel] = c.last_id === void 0 ? -1 : c.last_id;
|
data[c.channel] = c.last_id === void 0 ? -1 : c.last_id;
|
||||||
});
|
});
|
||||||
gotData = false;
|
gotData = false;
|
||||||
_this.longPoll = jQuery.ajax("/message-bus/" + clientId + "/poll?" + (isHidden() || !_this.enableLongPolling ? "dlp=t" : ""), {
|
_this.longPoll = $.ajax("/message-bus/" + clientId + "/poll?" + (isHidden() || !_this.enableLongPolling ? "dlp=t" : ""), {
|
||||||
data: data,
|
data: data,
|
||||||
cache: false,
|
cache: false,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
|
|
|
@ -98,7 +98,7 @@ Discourse.ScreenTrack = Ember.Object.extend({
|
||||||
highestSeenByTopic[topicId] = this.highestSeen;
|
highestSeenByTopic[topicId] = this.highestSeen;
|
||||||
}
|
}
|
||||||
if (!Object.isEmpty(newTimings)) {
|
if (!Object.isEmpty(newTimings)) {
|
||||||
jQuery.ajax('/topics/timings', {
|
$.ajax('/topics/timings', {
|
||||||
data: {
|
data: {
|
||||||
timings: newTimings,
|
timings: newTimings,
|
||||||
topic_time: this.topicTime,
|
topic_time: this.topicTime,
|
||||||
|
|
|
@ -14,7 +14,7 @@ cacheTopicId = null;
|
||||||
cacheTime = null;
|
cacheTime = null;
|
||||||
|
|
||||||
doSearch = function(term, topicId, success) {
|
doSearch = function(term, topicId, success) {
|
||||||
return jQuery.ajax({
|
return $.ajax({
|
||||||
url: '/users/search/users',
|
url: '/users/search/users',
|
||||||
dataType: 'JSON',
|
dataType: 'JSON',
|
||||||
data: {
|
data: {
|
||||||
|
|
|
@ -22,7 +22,7 @@ Discourse.StaticController = Discourse.Controller.extend({
|
||||||
text = text[1];
|
text = text[1];
|
||||||
return this.set('content', text);
|
return this.set('content', text);
|
||||||
} else {
|
} else {
|
||||||
return jQuery.ajax({
|
return $.ajax({
|
||||||
url: "" + path + ".json",
|
url: "" + path + ".json",
|
||||||
success: function(result) {
|
success: function(result) {
|
||||||
return _this.set('content', result);
|
return _this.set('content', result);
|
||||||
|
|
|
@ -54,7 +54,7 @@ Discourse.ActionSummary = Discourse.Model.extend({
|
||||||
|
|
||||||
// Create our post action
|
// Create our post action
|
||||||
promise = new RSVP.Promise();
|
promise = new RSVP.Promise();
|
||||||
jQuery.ajax({
|
$.ajax({
|
||||||
url: "/post_actions",
|
url: "/post_actions",
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: {
|
data: {
|
||||||
|
@ -65,7 +65,7 @@ Discourse.ActionSummary = Discourse.Model.extend({
|
||||||
error: function(error) {
|
error: function(error) {
|
||||||
var errors;
|
var errors;
|
||||||
_this.removeAction();
|
_this.removeAction();
|
||||||
errors = jQuery.parseJSON(error.responseText).errors;
|
errors = $.parseJSON(error.responseText).errors;
|
||||||
return promise.reject(errors);
|
return promise.reject(errors);
|
||||||
},
|
},
|
||||||
success: function() {
|
success: function() {
|
||||||
|
@ -80,7 +80,7 @@ Discourse.ActionSummary = Discourse.Model.extend({
|
||||||
this.removeAction();
|
this.removeAction();
|
||||||
|
|
||||||
// Remove our post action
|
// Remove our post action
|
||||||
return jQuery.ajax({
|
return $.ajax({
|
||||||
url: "/post_actions/" + (this.get('post.id')),
|
url: "/post_actions/" + (this.get('post.id')),
|
||||||
type: 'DELETE',
|
type: 'DELETE',
|
||||||
data: {
|
data: {
|
||||||
|
@ -91,7 +91,7 @@ Discourse.ActionSummary = Discourse.Model.extend({
|
||||||
|
|
||||||
clearFlags: function() {
|
clearFlags: function() {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
return jQuery.ajax({
|
return $.ajax({
|
||||||
url: "/post_actions/clear_flags",
|
url: "/post_actions/clear_flags",
|
||||||
type: "POST",
|
type: "POST",
|
||||||
data: {
|
data: {
|
||||||
|
@ -107,7 +107,7 @@ Discourse.ActionSummary = Discourse.Model.extend({
|
||||||
|
|
||||||
loadUsers: function() {
|
loadUsers: function() {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
return jQuery.getJSON("/post_actions/users", {
|
return $.getJSON("/post_actions/users", {
|
||||||
id: this.get('post.id'),
|
id: this.get('post.id'),
|
||||||
post_action_type_id: this.get('id')
|
post_action_type_id: this.get('id')
|
||||||
}, function(result) {
|
}, function(result) {
|
||||||
|
|
|
@ -42,7 +42,7 @@ Discourse.Category = Discourse.Model.extend({
|
||||||
|
|
||||||
"delete": function(callback) {
|
"delete": function(callback) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
return jQuery.ajax("/categories/" + (this.get('slug')), {
|
return $.ajax("/categories/" + (this.get('slug')), {
|
||||||
type: 'DELETE',
|
type: 'DELETE',
|
||||||
success: function() {
|
success: function() {
|
||||||
return callback();
|
return callback();
|
||||||
|
|
|
@ -34,7 +34,7 @@ Discourse.CategoryList.reopenClass({
|
||||||
var promise,
|
var promise,
|
||||||
_this = this;
|
_this = this;
|
||||||
promise = new RSVP.Promise();
|
promise = new RSVP.Promise();
|
||||||
jQuery.getJSON("/" + filter + ".json").then(function(result) {
|
$.getJSON("/" + filter + ".json").then(function(result) {
|
||||||
var categoryList;
|
var categoryList;
|
||||||
categoryList = Discourse.TopicList.create();
|
categoryList = Discourse.TopicList.create();
|
||||||
categoryList.set('can_create_category', result.category_list.can_create_category);
|
categoryList.set('can_create_category', result.category_list.can_create_category);
|
||||||
|
|
|
@ -318,7 +318,7 @@ Discourse.Composer = Discourse.Model.extend({
|
||||||
}
|
}
|
||||||
}, function(error) {
|
}, function(error) {
|
||||||
var errors;
|
var errors;
|
||||||
errors = jQuery.parseJSON(error.responseText).errors;
|
errors = $.parseJSON(error.responseText).errors;
|
||||||
promise.reject(errors[0]);
|
promise.reject(errors[0]);
|
||||||
post.set('cooked', oldCooked);
|
post.set('cooked', oldCooked);
|
||||||
return _this.set('composeState', OPEN);
|
return _this.set('composeState', OPEN);
|
||||||
|
@ -419,7 +419,7 @@ Discourse.Composer = Discourse.Model.extend({
|
||||||
if (topic) {
|
if (topic) {
|
||||||
topic.posts.removeObject(createdPost);
|
topic.posts.removeObject(createdPost);
|
||||||
}
|
}
|
||||||
errors = jQuery.parseJSON(error.responseText).errors;
|
errors = $.parseJSON(error.responseText).errors;
|
||||||
promise.reject(errors[0]);
|
promise.reject(errors[0]);
|
||||||
return _this.set('composeState', OPEN);
|
return _this.set('composeState', OPEN);
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,7 +11,7 @@ Discourse.Draft = Discourse.Model.extend({});
|
||||||
Discourse.Draft.reopenClass({
|
Discourse.Draft.reopenClass({
|
||||||
|
|
||||||
clear: function(key, sequence) {
|
clear: function(key, sequence) {
|
||||||
return jQuery.ajax({
|
return $.ajax({
|
||||||
type: 'DELETE',
|
type: 'DELETE',
|
||||||
url: "/draft",
|
url: "/draft",
|
||||||
data: {
|
data: {
|
||||||
|
@ -25,7 +25,7 @@ Discourse.Draft.reopenClass({
|
||||||
var promise,
|
var promise,
|
||||||
_this = this;
|
_this = this;
|
||||||
promise = new RSVP.Promise();
|
promise = new RSVP.Promise();
|
||||||
jQuery.ajax({
|
$.ajax({
|
||||||
url: '/draft',
|
url: '/draft',
|
||||||
data: {
|
data: {
|
||||||
draft_key: key
|
draft_key: key
|
||||||
|
@ -47,7 +47,7 @@ Discourse.Draft.reopenClass({
|
||||||
var promise;
|
var promise;
|
||||||
promise = new RSVP.Promise();
|
promise = new RSVP.Promise();
|
||||||
data = typeof data === "string" ? data : JSON.stringify(data);
|
data = typeof data === "string" ? data : JSON.stringify(data);
|
||||||
jQuery.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
url: "/draft",
|
url: "/draft",
|
||||||
data: {
|
data: {
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
Discourse.Invite = Discourse.Model.extend({
|
Discourse.Invite = Discourse.Model.extend({
|
||||||
|
|
||||||
rescind: function() {
|
rescind: function() {
|
||||||
jQuery.ajax('/invites', {
|
$.ajax('/invites', {
|
||||||
type: 'DELETE',
|
type: 'DELETE',
|
||||||
data: { email: this.get('email') }
|
data: { email: this.get('email') }
|
||||||
});
|
});
|
||||||
|
|
|
@ -17,7 +17,7 @@ Discourse.InviteList.reopenClass({
|
||||||
findInvitedBy: function(user) {
|
findInvitedBy: function(user) {
|
||||||
var promise;
|
var promise;
|
||||||
promise = new RSVP.Promise();
|
promise = new RSVP.Promise();
|
||||||
jQuery.ajax({
|
$.ajax({
|
||||||
url: "/users/" + (user.get('username_lower')) + "/invited.json",
|
url: "/users/" + (user.get('username_lower')) + "/invited.json",
|
||||||
success: function(result) {
|
success: function(result) {
|
||||||
var invitedList;
|
var invitedList;
|
||||||
|
|
|
@ -14,14 +14,14 @@ Discourse.Model = Ember.Object.extend(Discourse.Presence, {
|
||||||
|
|
||||||
@method ajax
|
@method ajax
|
||||||
@param {String} url The url to contact
|
@param {String} url The url to contact
|
||||||
@param {Object} args The arguments to pass to jQuery.ajax
|
@param {Object} args The arguments to pass to $.ajax
|
||||||
**/
|
**/
|
||||||
ajax: function(url, args) {
|
ajax: function(url, args) {
|
||||||
var oldError = args.error;
|
var oldError = args.error;
|
||||||
args.error = function(xhr) {
|
args.error = function(xhr) {
|
||||||
return oldError(jQuery.parseJSON(xhr.responseText).errors);
|
return oldError($.parseJSON(xhr.responseText).errors);
|
||||||
};
|
};
|
||||||
return jQuery.ajax(url, args);
|
return $.ajax(url, args);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -64,7 +64,7 @@ Discourse.Post = Discourse.Model.extend({
|
||||||
|
|
||||||
bookmarkedChanged: (function() {
|
bookmarkedChanged: (function() {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
return jQuery.ajax({
|
return $.ajax({
|
||||||
url: "/posts/" + (this.get('id')) + "/bookmark",
|
url: "/posts/" + (this.get('id')) + "/bookmark",
|
||||||
type: 'PUT',
|
type: 'PUT',
|
||||||
data: {
|
data: {
|
||||||
|
@ -72,7 +72,7 @@ Discourse.Post = Discourse.Model.extend({
|
||||||
},
|
},
|
||||||
error: function(error) {
|
error: function(error) {
|
||||||
var errors;
|
var errors;
|
||||||
errors = jQuery.parseJSON(error.responseText).errors;
|
errors = $.parseJSON(error.responseText).errors;
|
||||||
bootbox.alert(errors[0]);
|
bootbox.alert(errors[0]);
|
||||||
return _this.toggleProperty('bookmarked');
|
return _this.toggleProperty('bookmarked');
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ Discourse.Post = Discourse.Model.extend({
|
||||||
var data, metaData;
|
var data, metaData;
|
||||||
if (!this.get('newPost')) {
|
if (!this.get('newPost')) {
|
||||||
// We're updating a post
|
// We're updating a post
|
||||||
return jQuery.ajax({
|
return $.ajax({
|
||||||
url: "/posts/" + (this.get('id')),
|
url: "/posts/" + (this.get('id')),
|
||||||
type: 'PUT',
|
type: 'PUT',
|
||||||
data: {
|
data: {
|
||||||
|
@ -153,7 +153,7 @@ Discourse.Post = Discourse.Model.extend({
|
||||||
data.meta_data = {};
|
data.meta_data = {};
|
||||||
Ember.keys(metaData).forEach(function(key) { data.meta_data[key] = metaData.get(key); });
|
Ember.keys(metaData).forEach(function(key) { data.meta_data[key] = metaData.get(key); });
|
||||||
}
|
}
|
||||||
return jQuery.ajax({
|
return $.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
url: "/posts",
|
url: "/posts",
|
||||||
data: data,
|
data: data,
|
||||||
|
@ -168,11 +168,11 @@ Discourse.Post = Discourse.Model.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
recover: function() {
|
recover: function() {
|
||||||
return jQuery.ajax("/posts/" + (this.get('id')) + "/recover", { type: 'PUT', cache: false });
|
return $.ajax("/posts/" + (this.get('id')) + "/recover", { type: 'PUT', cache: false });
|
||||||
},
|
},
|
||||||
|
|
||||||
"delete": function(complete) {
|
"delete": function(complete) {
|
||||||
return jQuery.ajax("/posts/" + (this.get('id')), {
|
return $.ajax("/posts/" + (this.get('id')), {
|
||||||
type: 'DELETE',
|
type: 'DELETE',
|
||||||
success: function(result) {
|
success: function(result) {
|
||||||
return typeof complete === "function" ? complete() : void 0;
|
return typeof complete === "function" ? complete() : void 0;
|
||||||
|
@ -220,7 +220,7 @@ Discourse.Post = Discourse.Model.extend({
|
||||||
promise = new RSVP.Promise();
|
promise = new RSVP.Promise();
|
||||||
this.set('loadingReplies', true);
|
this.set('loadingReplies', true);
|
||||||
this.set('replies', []);
|
this.set('replies', []);
|
||||||
jQuery.getJSON("/posts/" + (this.get('id')) + "/replies", function(loaded) {
|
$.getJSON("/posts/" + (this.get('id')) + "/replies", function(loaded) {
|
||||||
loaded.each(function(reply) {
|
loaded.each(function(reply) {
|
||||||
var post;
|
var post;
|
||||||
post = Discourse.Post.create(reply);
|
post = Discourse.Post.create(reply);
|
||||||
|
@ -234,7 +234,7 @@ Discourse.Post = Discourse.Model.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
loadVersions: function(callback) {
|
loadVersions: function(callback) {
|
||||||
return jQuery.get("/posts/" + (this.get('id')) + "/versions.json", function(result) {
|
return $.get("/posts/" + (this.get('id')) + "/versions.json", function(result) {
|
||||||
return callback(result);
|
return callback(result);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -290,7 +290,7 @@ Discourse.Post.reopenClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
deleteMany: function(posts) {
|
deleteMany: function(posts) {
|
||||||
return jQuery.ajax("/posts/destroy_many", {
|
return $.ajax("/posts/destroy_many", {
|
||||||
type: 'DELETE',
|
type: 'DELETE',
|
||||||
data: {
|
data: {
|
||||||
post_ids: posts.map(function(p) {
|
post_ids: posts.map(function(p) {
|
||||||
|
@ -302,14 +302,14 @@ Discourse.Post.reopenClass({
|
||||||
|
|
||||||
loadVersion: function(postId, version, callback) {
|
loadVersion: function(postId, version, callback) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
return jQuery.getJSON("/posts/" + postId + ".json?version=" + version, function(result) {
|
return $.getJSON("/posts/" + postId + ".json?version=" + version, function(result) {
|
||||||
return callback(Discourse.Post.create(result));
|
return callback(Discourse.Post.create(result));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
loadByPostNumber: function(topicId, postId, callback) {
|
loadByPostNumber: function(topicId, postId, callback) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
return jQuery.getJSON("/posts/by_number/" + topicId + "/" + postId + ".json", function(result) {
|
return $.getJSON("/posts/by_number/" + topicId + "/" + postId + ".json", function(result) {
|
||||||
return callback(Discourse.Post.create(result));
|
return callback(Discourse.Post.create(result));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -318,7 +318,7 @@ Discourse.Post.reopenClass({
|
||||||
var promise,
|
var promise,
|
||||||
_this = this;
|
_this = this;
|
||||||
promise = new RSVP.Promise();
|
promise = new RSVP.Promise();
|
||||||
jQuery.getJSON("/posts/" + postId + ".json", function(result) {
|
$.getJSON("/posts/" + postId + ".json", function(result) {
|
||||||
var post;
|
var post;
|
||||||
post = Discourse.Post.create(result);
|
post = Discourse.Post.create(result);
|
||||||
return promise.resolve(Discourse.BBCode.buildQuoteBBCode(post, post.get('raw')));
|
return promise.resolve(Discourse.BBCode.buildQuoteBBCode(post, post.get('raw')));
|
||||||
|
@ -328,7 +328,7 @@ Discourse.Post.reopenClass({
|
||||||
|
|
||||||
load: function(postId, callback) {
|
load: function(postId, callback) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
return jQuery.getJSON("/posts/" + postId + ".json", function(result) {
|
return $.getJSON("/posts/" + postId + ".json", function(result) {
|
||||||
return callback(Discourse.Post.create(result));
|
return callback(Discourse.Post.create(result));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ Discourse.Topic = Discourse.Model.extend({
|
||||||
a = this.get('archetype');
|
a = this.get('archetype');
|
||||||
if (a !== 'regular' && a !== 'private_message') {
|
if (a !== 'regular' && a !== 'private_message') {
|
||||||
this.set('archetype', 'regular');
|
this.set('archetype', 'regular');
|
||||||
return jQuery.post(this.get('url'), {
|
return $.post(this.get('url'), {
|
||||||
_method: 'put',
|
_method: 'put',
|
||||||
archetype: 'regular'
|
archetype: 'regular'
|
||||||
});
|
});
|
||||||
|
@ -134,7 +134,7 @@ Discourse.Topic = Discourse.Model.extend({
|
||||||
|
|
||||||
toggleStatus: function(property) {
|
toggleStatus: function(property) {
|
||||||
this.toggleProperty(property);
|
this.toggleProperty(property);
|
||||||
return jQuery.post("" + (this.get('url')) + "/status", {
|
return $.post("" + (this.get('url')) + "/status", {
|
||||||
_method: 'put',
|
_method: 'put',
|
||||||
status: property,
|
status: property,
|
||||||
enabled: this.get(property) ? 'true' : 'false'
|
enabled: this.get(property) ? 'true' : 'false'
|
||||||
|
@ -144,13 +144,13 @@ Discourse.Topic = Discourse.Model.extend({
|
||||||
toggleStar: function() {
|
toggleStar: function() {
|
||||||
var topic = this;
|
var topic = this;
|
||||||
topic.toggleProperty('starred');
|
topic.toggleProperty('starred');
|
||||||
return jQuery.ajax({
|
return $.ajax({
|
||||||
url: "" + (this.get('url')) + "/star",
|
url: "" + (this.get('url')) + "/star",
|
||||||
type: 'PUT',
|
type: 'PUT',
|
||||||
data: { starred: topic.get('starred') ? true : false },
|
data: { starred: topic.get('starred') ? true : false },
|
||||||
error: function(error) {
|
error: function(error) {
|
||||||
topic.toggleProperty('starred');
|
topic.toggleProperty('starred');
|
||||||
var errors = jQuery.parseJSON(error.responseText).errors;
|
var errors = $.parseJSON(error.responseText).errors;
|
||||||
return bootbox.alert(errors[0]);
|
return bootbox.alert(errors[0]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -160,7 +160,7 @@ Discourse.Topic = Discourse.Model.extend({
|
||||||
save: function() {
|
save: function() {
|
||||||
// Don't save unless we can
|
// Don't save unless we can
|
||||||
if (!this.get('can_edit')) return;
|
if (!this.get('can_edit')) return;
|
||||||
return jQuery.post(this.get('url'), {
|
return $.post(this.get('url'), {
|
||||||
_method: 'put',
|
_method: 'put',
|
||||||
title: this.get('title'),
|
title: this.get('title'),
|
||||||
category: this.get('category.name')
|
category: this.get('category.name')
|
||||||
|
@ -169,7 +169,7 @@ Discourse.Topic = Discourse.Model.extend({
|
||||||
|
|
||||||
// Reset our read data for this topic
|
// Reset our read data for this topic
|
||||||
resetRead: function(callback) {
|
resetRead: function(callback) {
|
||||||
return jQuery.ajax("/t/" + (this.get('id')) + "/timings", {
|
return $.ajax("/t/" + (this.get('id')) + "/timings", {
|
||||||
type: 'DELETE',
|
type: 'DELETE',
|
||||||
success: function() {
|
success: function() {
|
||||||
return typeof callback === "function" ? callback() : void 0;
|
return typeof callback === "function" ? callback() : void 0;
|
||||||
|
@ -179,7 +179,7 @@ Discourse.Topic = Discourse.Model.extend({
|
||||||
|
|
||||||
// Invite a user to this topic
|
// Invite a user to this topic
|
||||||
inviteUser: function(user) {
|
inviteUser: function(user) {
|
||||||
return jQuery.ajax({
|
return $.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
url: "/t/" + (this.get('id')) + "/invite",
|
url: "/t/" + (this.get('id')) + "/invite",
|
||||||
data: {
|
data: {
|
||||||
|
@ -190,7 +190,7 @@ Discourse.Topic = Discourse.Model.extend({
|
||||||
|
|
||||||
// Delete this topic
|
// Delete this topic
|
||||||
"delete": function(callback) {
|
"delete": function(callback) {
|
||||||
return jQuery.ajax("/t/" + (this.get('id')), {
|
return $.ajax("/t/" + (this.get('id')), {
|
||||||
type: 'DELETE',
|
type: 'DELETE',
|
||||||
success: function() {
|
success: function() {
|
||||||
return typeof callback === "function" ? callback() : void 0;
|
return typeof callback === "function" ? callback() : void 0;
|
||||||
|
@ -305,7 +305,7 @@ Discourse.Topic = Discourse.Model.extend({
|
||||||
updateNotifications: function(v) {
|
updateNotifications: function(v) {
|
||||||
this.set('notification_level', v);
|
this.set('notification_level', v);
|
||||||
this.set('notifications_reason_id', null);
|
this.set('notifications_reason_id', null);
|
||||||
return jQuery.ajax({
|
return $.ajax({
|
||||||
url: "/t/" + (this.get('id')) + "/notifications",
|
url: "/t/" + (this.get('id')) + "/notifications",
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: {
|
data: {
|
||||||
|
@ -389,7 +389,7 @@ Discourse.Topic.reopenClass({
|
||||||
// Check the preload store. If not, load it via JSON
|
// Check the preload store. If not, load it via JSON
|
||||||
promise = new RSVP.Promise();
|
promise = new RSVP.Promise();
|
||||||
PreloadStore.get("topic_" + topicId, function() {
|
PreloadStore.get("topic_" + topicId, function() {
|
||||||
return jQuery.getJSON(url + ".json", data);
|
return $.getJSON(url + ".json", data);
|
||||||
}).then(function(result) {
|
}).then(function(result) {
|
||||||
var first;
|
var first;
|
||||||
first = result.posts.first();
|
first = result.posts.first();
|
||||||
|
@ -405,7 +405,7 @@ Discourse.Topic.reopenClass({
|
||||||
|
|
||||||
// Create a topic from posts
|
// Create a topic from posts
|
||||||
movePosts: function(topicId, title, postIds) {
|
movePosts: function(topicId, title, postIds) {
|
||||||
return jQuery.ajax("/t/" + topicId + "/move-posts", {
|
return $.ajax("/t/" + topicId + "/move-posts", {
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: { title: title, post_ids: postIds }
|
data: { title: title, post_ids: postIds }
|
||||||
});
|
});
|
||||||
|
|
|
@ -15,7 +15,7 @@ Discourse.TopicList = Discourse.Model.extend({
|
||||||
promise = new RSVP.Promise();
|
promise = new RSVP.Promise();
|
||||||
if (moreUrl = this.get('more_topics_url')) {
|
if (moreUrl = this.get('more_topics_url')) {
|
||||||
Discourse.URL.replaceState("/" + (this.get('filter')) + "/more");
|
Discourse.URL.replaceState("/" + (this.get('filter')) + "/more");
|
||||||
jQuery.ajax(moreUrl, {
|
$.ajax(moreUrl, {
|
||||||
success: function(result) {
|
success: function(result) {
|
||||||
var newTopics, topicIds, topics;
|
var newTopics, topicIds, topics;
|
||||||
if (result) {
|
if (result) {
|
||||||
|
@ -108,7 +108,7 @@ Discourse.TopicList.reopenClass({
|
||||||
promise = new RSVP.Promise();
|
promise = new RSVP.Promise();
|
||||||
found = PreloadStore.contains('topic_list');
|
found = PreloadStore.contains('topic_list');
|
||||||
PreloadStore.get("topic_list", function() {
|
PreloadStore.get("topic_list", function() {
|
||||||
return jQuery.getJSON(url);
|
return $.getJSON(url);
|
||||||
}).then(function(result) {
|
}).then(function(result) {
|
||||||
topic_list.set('topics', Discourse.TopicList.topicsFrom(result));
|
topic_list.set('topics', Discourse.TopicList.topicsFrom(result));
|
||||||
topic_list.set('can_create_topic', result.topic_list.can_create_topic);
|
topic_list.set('can_create_topic', result.topic_list.can_create_topic);
|
||||||
|
|
|
@ -33,7 +33,7 @@ Discourse.User = Discourse.Model.extend({
|
||||||
}).property('trust_level'),
|
}).property('trust_level'),
|
||||||
|
|
||||||
changeUsername: function(newUsername) {
|
changeUsername: function(newUsername) {
|
||||||
return jQuery.ajax({
|
return $.ajax({
|
||||||
url: "/users/" + (this.get('username_lower')) + "/preferences/username",
|
url: "/users/" + (this.get('username_lower')) + "/preferences/username",
|
||||||
type: 'PUT',
|
type: 'PUT',
|
||||||
data: {
|
data: {
|
||||||
|
@ -43,7 +43,7 @@ Discourse.User = Discourse.Model.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
changeEmail: function(email) {
|
changeEmail: function(email) {
|
||||||
return jQuery.ajax({
|
return $.ajax({
|
||||||
url: "/users/" + (this.get('username_lower')) + "/preferences/email",
|
url: "/users/" + (this.get('username_lower')) + "/preferences/email",
|
||||||
type: 'PUT',
|
type: 'PUT',
|
||||||
data: {
|
data: {
|
||||||
|
@ -58,7 +58,7 @@ Discourse.User = Discourse.Model.extend({
|
||||||
|
|
||||||
save: function(finished) {
|
save: function(finished) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
return jQuery.ajax("/users/" + this.get('username').toLowerCase(), {
|
return $.ajax("/users/" + this.get('username').toLowerCase(), {
|
||||||
data: this.getProperties('auto_track_topics_after_msecs',
|
data: this.getProperties('auto_track_topics_after_msecs',
|
||||||
'bio_raw',
|
'bio_raw',
|
||||||
'website',
|
'website',
|
||||||
|
@ -77,7 +77,7 @@ Discourse.User = Discourse.Model.extend({
|
||||||
changePassword: function(callback) {
|
changePassword: function(callback) {
|
||||||
var good;
|
var good;
|
||||||
good = false;
|
good = false;
|
||||||
return jQuery.ajax({
|
return $.ajax({
|
||||||
url: '/session/forgot_password',
|
url: '/session/forgot_password',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
data: {
|
data: {
|
||||||
|
@ -109,7 +109,7 @@ Discourse.User = Discourse.Model.extend({
|
||||||
var stream,
|
var stream,
|
||||||
_this = this;
|
_this = this;
|
||||||
stream = this.get('stream');
|
stream = this.get('stream');
|
||||||
return jQuery.ajax({
|
return $.ajax({
|
||||||
url: "/user_actions/" + id + ".json",
|
url: "/user_actions/" + id + ".json",
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
cache: 'false',
|
cache: 'false',
|
||||||
|
@ -142,7 +142,7 @@ Discourse.User = Discourse.Model.extend({
|
||||||
url += "&filter=" + (this.get('streamFilter'));
|
url += "&filter=" + (this.get('streamFilter'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return jQuery.ajax({
|
return $.ajax({
|
||||||
url: url,
|
url: url,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
cache: 'false',
|
cache: 'false',
|
||||||
|
@ -226,7 +226,7 @@ Discourse.User = Discourse.Model.extend({
|
||||||
Discourse.User.reopenClass({
|
Discourse.User.reopenClass({
|
||||||
|
|
||||||
checkUsername: function(username, email) {
|
checkUsername: function(username, email) {
|
||||||
return jQuery.ajax({
|
return $.ajax({
|
||||||
url: '/users/check_username',
|
url: '/users/check_username',
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
data: {
|
data: {
|
||||||
|
@ -278,7 +278,7 @@ Discourse.User.reopenClass({
|
||||||
var promise,
|
var promise,
|
||||||
_this = this;
|
_this = this;
|
||||||
promise = new RSVP.Promise();
|
promise = new RSVP.Promise();
|
||||||
jQuery.ajax({
|
$.ajax({
|
||||||
url: "/users/" + username + '.json',
|
url: "/users/" + username + '.json',
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
// todo: decompose to object
|
// todo: decompose to object
|
||||||
|
@ -305,7 +305,7 @@ Discourse.User.reopenClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
createAccount: function(name, email, password, username, passwordConfirm, challenge) {
|
createAccount: function(name, email, password, username, passwordConfirm, challenge) {
|
||||||
return jQuery.ajax({
|
return $.ajax({
|
||||||
url: '/users',
|
url: '/users',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
data: {
|
data: {
|
||||||
|
|
|
@ -18,7 +18,7 @@ var popstateReady = false;
|
||||||
Ember.DiscourseLocation = Ember.Object.extend({
|
Ember.DiscourseLocation = Ember.Object.extend({
|
||||||
init: function() {
|
init: function() {
|
||||||
set(this, 'location', get(this, 'location') || window.location);
|
set(this, 'location', get(this, 'location') || window.location);
|
||||||
if ( jQuery.inArray('state', jQuery.event.props) < 0 )
|
if ( $.inArray('state', $.event.props) < 0 )
|
||||||
jQuery.event.props.push('state')
|
jQuery.event.props.push('state')
|
||||||
this.initState();
|
this.initState();
|
||||||
},
|
},
|
||||||
|
|
|
@ -89,7 +89,7 @@ Discourse.ComposerView = Discourse.View.extend({
|
||||||
|
|
||||||
// If visible update the text
|
// If visible update the text
|
||||||
educationKey = this.get('content.creatingTopic') ? 'new-topic' : 'new-reply';
|
educationKey = this.get('content.creatingTopic') ? 'new-topic' : 'new-reply';
|
||||||
return jQuery.get("/education/" + educationKey).then(function(result) {
|
return $.get("/education/" + educationKey).then(function(result) {
|
||||||
return _this.set('educationContents', result);
|
return _this.set('educationContents', result);
|
||||||
});
|
});
|
||||||
}).observes('controller.hasReply', 'content.creatingTopic', 'Discourse.currentUser.reply_count'),
|
}).observes('controller.hasReply', 'content.creatingTopic', 'Discourse.currentUser.reply_count'),
|
||||||
|
@ -251,15 +251,11 @@ Discourse.ComposerView = Discourse.View.extend({
|
||||||
});
|
});
|
||||||
|
|
||||||
topic = this.get('topic');
|
topic = this.get('topic');
|
||||||
this.editor = editor = Discourse.Markdown.createNewMarkdownEditor(Discourse.Markdown.markdownConverter({
|
this.editor = editor = Discourse.Markdown.createEditor({
|
||||||
lookupAvatar: function(username) {
|
lookupAvatar: function(username) {
|
||||||
return Discourse.Utilities.avatarImg({
|
return Discourse.Utilities.avatarImg({ username: username, size: 'tiny' });
|
||||||
username: username,
|
}
|
||||||
size: 'tiny'
|
});
|
||||||
});
|
|
||||||
},
|
|
||||||
sanitize: true
|
|
||||||
}));
|
|
||||||
|
|
||||||
$uploadTarget = $('#reply-control');
|
$uploadTarget = $('#reply-control');
|
||||||
this.editor.hooks.insertImageDialog = function(callback) {
|
this.editor.hooks.insertImageDialog = function(callback) {
|
||||||
|
|
|
@ -53,7 +53,7 @@ Discourse.HeaderView = Discourse.View.extend({
|
||||||
|
|
||||||
showNotifications: function() {
|
showNotifications: function() {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
jQuery.get("/notifications").then(function(result) {
|
$.get("/notifications").then(function(result) {
|
||||||
_this.set('notifications', result.map(function(n) {
|
_this.set('notifications', result.map(function(n) {
|
||||||
return Discourse.Notification.create(n);
|
return Discourse.Notification.create(n);
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -240,7 +240,7 @@ Discourse.CreateAccountView = Discourse.ModalBodyView.extend({
|
||||||
|
|
||||||
fetchConfirmationValue: function() {
|
fetchConfirmationValue: function() {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
return jQuery.ajax({
|
return $.ajax({
|
||||||
url: '/users/hp.json',
|
url: '/users/hp.json',
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
_this.set('accountPasswordConfirm', json.value);
|
_this.set('accountPasswordConfirm', json.value);
|
||||||
|
|
|
@ -16,7 +16,7 @@ Discourse.ForgotPasswordView = Discourse.ModalBodyView.extend({
|
||||||
}).property('accountEmailOrUsername'),
|
}).property('accountEmailOrUsername'),
|
||||||
|
|
||||||
submit: function() {
|
submit: function() {
|
||||||
jQuery.post("/session/forgot_password", {
|
$.post("/session/forgot_password", {
|
||||||
username: this.get('accountEmailOrUsername')
|
username: this.get('accountEmailOrUsername')
|
||||||
});
|
});
|
||||||
// don't tell people what happened, this keeps it more secure (ensure same on server)
|
// don't tell people what happened, this keeps it more secure (ensure same on server)
|
||||||
|
|
|
@ -45,7 +45,7 @@ Discourse.LoginView = Discourse.ModalBodyView.extend({
|
||||||
login: function() {
|
login: function() {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
this.set('loggingIn', true);
|
this.set('loggingIn', true);
|
||||||
jQuery.post("/session", {
|
$.post("/session", {
|
||||||
login: this.get('loginName'),
|
login: this.get('loginName'),
|
||||||
password: this.get('loginPassword')
|
password: this.get('loginPassword')
|
||||||
}).success(function(result) {
|
}).success(function(result) {
|
||||||
|
|
|
@ -12,7 +12,7 @@ Discourse.NotActivatedView = Discourse.ModalBodyView.extend({
|
||||||
emailSent: false,
|
emailSent: false,
|
||||||
|
|
||||||
sendActivationEmail: function() {
|
sendActivationEmail: function() {
|
||||||
jQuery.get('/users/' + this.get('username') + '/send_activation_email');
|
$.get('/users/' + this.get('username') + '/send_activation_email');
|
||||||
this.set('emailSent', true);
|
this.set('emailSent', true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*global Markdown:true*/
|
/*global Markdown:true assetPath:true */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
A control to support using PageDown as an Ember view.
|
A control to support using PageDown as an Ember view.
|
||||||
|
@ -14,14 +14,13 @@ Discourse.PagedownEditor = Ember.ContainerView.extend({
|
||||||
init: function() {
|
init: function() {
|
||||||
this._super();
|
this._super();
|
||||||
|
|
||||||
|
$LAB.script(assetPath('defer/html-sanitizer-bundle'));
|
||||||
|
|
||||||
// Add a button bar
|
// Add a button bar
|
||||||
this.pushObject(Em.View.create({ elementId: 'wmd-button-bar' }));
|
this.pushObject(Em.View.create({ elementId: 'wmd-button-bar' }));
|
||||||
this.pushObject(Em.TextArea.create({
|
this.pushObject(Em.TextArea.create({ valueBinding: 'parentView.value', elementId: 'wmd-input' }));
|
||||||
valueBinding: 'parentView.value',
|
|
||||||
elementId: 'wmd-input'
|
|
||||||
}));
|
|
||||||
|
|
||||||
this.pushObject(Em.View.createWithMixins(Discourse.Presence, {
|
this.pushObject(Discourse.View.createWithMixins({
|
||||||
elementId: 'wmd-preview',
|
elementId: 'wmd-preview',
|
||||||
classNameBindings: [':preview', 'hidden'],
|
classNameBindings: [':preview', 'hidden'],
|
||||||
hidden: (function() {
|
hidden: (function() {
|
||||||
|
@ -31,12 +30,9 @@ Discourse.PagedownEditor = Ember.ContainerView.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
didInsertElement: function() {
|
didInsertElement: function() {
|
||||||
var $wmdInput;
|
var $wmdInput = $('#wmd-input');
|
||||||
$wmdInput = $('#wmd-input');
|
|
||||||
$wmdInput.data('init', true);
|
$wmdInput.data('init', true);
|
||||||
this.editor = Discourse.Markdown.createNewMarkdownEditor(Discourse.Markdown.markdownConverter({
|
this.editor = Discourse.Markdown.createEditor();
|
||||||
sanitize: true
|
|
||||||
}));
|
|
||||||
return this.editor.run();
|
return this.editor.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -190,7 +190,7 @@ Discourse.PostView = Discourse.View.extend({
|
||||||
if ($aside.data('topic')) {
|
if ($aside.data('topic')) {
|
||||||
topic_id = $aside.data('topic');
|
topic_id = $aside.data('topic');
|
||||||
}
|
}
|
||||||
jQuery.getJSON("/posts/by_number/" + topic_id + "/" + ($aside.data('post')), function(result) {
|
$.getJSON("/posts/by_number/" + topic_id + "/" + ($aside.data('post')), function(result) {
|
||||||
var parsed;
|
var parsed;
|
||||||
parsed = $(result.cooked);
|
parsed = $(result.cooked);
|
||||||
parsed.replaceText(originalText, "<span class='highlighted'>" + originalText + "</span>");
|
parsed.replaceText(originalText, "<span class='highlighted'>" + originalText + "</span>");
|
||||||
|
|
|
@ -94,7 +94,7 @@ Discourse.SearchView = Discourse.View.extend({
|
||||||
this.currentSearch = null;
|
this.currentSearch = null;
|
||||||
}
|
}
|
||||||
this.searcher = this.searcher || Discourse.debounce(function(term, typeFilter) {
|
this.searcher = this.searcher || Discourse.debounce(function(term, typeFilter) {
|
||||||
_this.currentSearch = jQuery.ajax({
|
_this.currentSearch = $.ajax({
|
||||||
url: '/search',
|
url: '/search',
|
||||||
data: {
|
data: {
|
||||||
term: term,
|
term: term,
|
||||||
|
|
|
@ -1023,6 +1023,7 @@
|
||||||
var previewSetter;
|
var previewSetter;
|
||||||
|
|
||||||
var previewSet = function (text) {
|
var previewSet = function (text) {
|
||||||
|
|
||||||
if (previewSetter)
|
if (previewSetter)
|
||||||
return previewSetter(text);
|
return previewSetter(text);
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ var console = window.console = {};
|
||||||
console.log = console.info = console.warn = console.error = function(){};
|
console.log = console.info = console.warn = console.error = function(){};
|
||||||
|
|
||||||
// jQuery
|
// jQuery
|
||||||
var jQuery = window.jQuery = function() { return jQuery; };
|
var $ = jQuery = window.jQuery = function() { return jQuery; };
|
||||||
jQuery.ready = function() { return jQuery; };
|
jQuery.ready = function() { return jQuery; };
|
||||||
jQuery.inArray = function() { return jQuery; };
|
jQuery.inArray = function() { return jQuery; };
|
||||||
jQuery.event = {
|
jQuery.event = {
|
||||||
|
|
|
@ -12,13 +12,13 @@ describe("Discourse.Onebox", function() {
|
||||||
it("Stops rapid calls with cache true", function() {
|
it("Stops rapid calls with cache true", function() {
|
||||||
Discourse.Onebox.load(anchor, true);
|
Discourse.Onebox.load(anchor, true);
|
||||||
Discourse.Onebox.load(anchor, true);
|
Discourse.Onebox.load(anchor, true);
|
||||||
expect(jQuery.ajax.calls.length).toBe(1);
|
expect($.ajax.calls.length).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Stops rapid calls with cache false", function() {
|
it("Stops rapid calls with cache false", function() {
|
||||||
Discourse.Onebox.load(anchor, false);
|
Discourse.Onebox.load(anchor, false);
|
||||||
Discourse.Onebox.load(anchor, false);
|
Discourse.Onebox.load(anchor, false);
|
||||||
expect(jQuery.ajax.calls.length).toBe(1);
|
expect($.ajax.calls.length).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue