Skip to content

Instantly share code, notes, and snippets.

@Reflic
Created March 20, 2016 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Reflic/61c37d119feebdbec05b to your computer and use it in GitHub Desktop.
Save Reflic/61c37d119feebdbec05b to your computer and use it in GitHub Desktop.
main.js
import { extend } from 'flarum/extend';
import TextEditor from 'flarum/components/TextEditor';
import UploadButton from 'reflic/file-upload/components/UploadButton';
console.log("test2");
app.initializers.add('reflic-file-upload', app => {
console.log("test2");
/**
* Add the upload button to the post composer.
*/
extend(TextEditor.prototype, 'controlItems', function(items)
{
console.log("test2");
// check whether the user can upload images. If not, returns.
if (!app.forum.attribute('canUploadImages')) return;
// create and add the button
var uploadButton = new UploadButton;
uploadButton.textAreaObj = this;
console.log("test");
items.add('reflic-file-upload', uploadButton, 0);
// animate the button on hover: shows the label
$('.Button-label', '.item-reflic-file-upload > div').hide();
$('.item-reflic-file-upload > div').hover(
function(){ $('.Button-label', this).show(); $(this).removeClass('Button--icon')},
function(){ $('.Button-label', this).hide(); $(this).addClass('Button--icon')}
);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment