Skip to content

Commit

Permalink
Updated to 0.5.0
Browse files Browse the repository at this point in the history
Updated to ES6 and removed support for instances prior to the API
  • Loading branch information
cpradio committed Jul 5, 2016
1 parent 07b8bfa commit 3ee7c9a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 78 deletions.
7 changes: 4 additions & 3 deletions assets/javascripts/discourse/controllers/replygif.js.es6
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import ModalFunctionality from 'discourse/mixins/modal-functionality';
import AjaxLib from 'discourse/lib/ajax';

export default Ember.Controller.extend(ModalFunctionality, {
loading: true,
Expand Down Expand Up @@ -60,7 +61,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
url += "&tag-operator=and&tag=" + this.get("selectedTags").join(",");
}

Discourse.ajax(url).then(function(resp) {
AjaxLib.ajax(url).then(function(resp) {
this.get("currentGifs").setObjects(resp);
this.set("loading", false);
}.bind(this));
Expand All @@ -69,15 +70,15 @@ export default Ember.Controller.extend(ModalFunctionality, {
onShow: function() {
this.setProperties({"loading": true, "categories": [], "selectedCategory": "", "selectedTags": [], tags: [], selectedGifs: [] });

Discourse.ajax(this.getUrl("replies")).then(
AjaxLib.ajax(this.getUrl("replies")).then(
function(resp) {
this.set("categories", resp);
this.set("selectedCategory", this.get("filterCategories")[0].title);
this.refresh();
}.bind(this)
);

Discourse.ajax(this.getUrl("tags")).then(
AjaxLib.ajax(this.getUrl("tags")).then(
function(resp) {
this.set("tags", resp);
}.bind(this)
Expand Down
89 changes: 16 additions & 73 deletions assets/javascripts/discourse/initializers/replygif.js.es6
Original file line number Diff line number Diff line change
@@ -1,60 +1,6 @@
import { withPluginApi } from 'discourse/lib/plugin-api';
import { onToolbarCreate } from 'discourse/components/d-editor';
import NewComposer from 'discourse/components/d-editor';
import Composer from 'discourse/components/d-editor';
import showModal from 'discourse/lib/show-modal';
import ApplicationRoute from 'discourse/routes/application';
import ComposerView from 'discourse/views/composer';

function priorToApi(container)
{
const siteSettings = container.lookup('site-settings:main');

if (siteSettings.replygif_enabled
&& siteSettings.replygif_api_url
&& siteSettings.replygif_api_key) {
if (NewComposer !== "undefined") {
NewComposer.reopen({
actions: {
showReplyGif: function() {
showModal('replygif').setProperties({composerView: this});
}
}
});

onToolbarCreate(toolbar => {
toolbar.addButton({
id: "replygif_button",
group: "extras",
icon: "play-circle-o",
action: 'showReplyGif'
});
});
} else {
ApplicationRoute.reopen({
actions: {
showReplyGif: function (composerView) {
showModal('replygif');
this.controllerFor('replygif').setProperties({composerViewOld: composerView});
}
}
});

ComposerView.reopen({
initEditor: function () {
// overwrite and wrap.
this._super();
var view = this;
var button_text = I18n.t("replygif.composer_button_text");
var btn = $('<button class="wmd-button wmd-replygif-button" title="' + button_text + '" aria-label="' + button_text + '"></button>');
btn.click(function () {
view.get("controller").send("showReplyGif", view);
});
$("#wmd-button-row,.wmd-button-row").append(btn);
}
});
}
}
}

function initializePlugin(api)
{
Expand All @@ -63,33 +9,30 @@ function initializePlugin(api)
if (siteSettings.replygif_enabled
&& siteSettings.replygif_api_url
&& siteSettings.replygif_api_key) {
if (NewComposer !== "undefined") {
NewComposer.reopen({
actions: {
showReplyGif: function () {
showModal('replygif').setProperties({composerView: this});
}
Composer.reopen({
actions: {
showReplyGif: function () {
showModal('replygif').setProperties({composerView: this});
}
}
});

api.onToolbarCreate(toolbar => {
toolbar.addButton({
id: "replygif_button",
group: "extras",
icon: "play-circle-o",
action: 'showReplyGif'
});

api.onToolbarCreate(toolbar => {
toolbar.addButton({
id: "replygif_button",
group: "extras",
icon: "play-circle-o",
action: 'showReplyGif'
});
});
}
});
}

}

export default
{
name: 'replygif',
initialize(container)
{
withPluginApi('0.1', api => initializePlugin(api), { noApi: () => priorToApi(container) });
withPluginApi('0.1', api => initializePlugin(api));
}
};
3 changes: 1 addition & 2 deletions plugin.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# name: discourse-plugin-replygif
# about: Add ReplyGIF support
# version: 0.4.0
# version: 0.5.0
# authors: Matthew Wilkin
# url: https://github.com/cpradio/discourse-plugin-replygif

enabled_site_setting :replygif_enabled

register_asset "javascripts/discourse/templates/replygif.hbs"

register_asset 'stylesheets/replygif.scss'

0 comments on commit 3ee7c9a

Please sign in to comment.