Created
March 20, 2016 18:36
-
-
Save Reflic/61c37d119feebdbec05b to your computer and use it in GitHub Desktop.
main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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