mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
Integrated tinymce
This commit is contained in:
parent
d461861263
commit
c4d0f38a67
20
bower.json
Normal file
20
bower.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "oxbow",
|
||||
"version": "0.0.0",
|
||||
"authors": [
|
||||
"Dan Brown <ssddanbrown@googlemail.com>"
|
||||
],
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"public/bower/",
|
||||
"test",
|
||||
"tests"
|
||||
],
|
||||
"dependencies": {
|
||||
"dropzone": "~4.0.1",
|
||||
"tinymce-dist": "~4.2.1"
|
||||
}
|
||||
}
|
74
public/js/image-manager.js
Normal file
74
public/js/image-manager.js
Normal file
@ -0,0 +1,74 @@
|
||||
|
||||
(function() {
|
||||
|
||||
var isInit = false;
|
||||
var elem;
|
||||
var overlay;
|
||||
var display;
|
||||
var imageIndexUrl = '/images/all';
|
||||
|
||||
var ImageManager = {};
|
||||
var action = false;
|
||||
|
||||
ImageManager.show = function(selector, callback) {
|
||||
if(isInit) {
|
||||
showWindow();
|
||||
} else {
|
||||
this.init(selector)
|
||||
showWindow();
|
||||
}
|
||||
|
||||
action = (typeof callback !== 'undefined') ? callback : false;
|
||||
};
|
||||
|
||||
ImageManager.init = function(selector) {
|
||||
console.log('cat');
|
||||
elem = $(selector);
|
||||
overlay = elem.closest('.overlay');
|
||||
display = elem.find('.image-manager-display').first()
|
||||
|
||||
// Get recent images and show
|
||||
$.getJSON(imageIndexUrl, showImages);
|
||||
function showImages(images) {
|
||||
for(var i = 0; i < images.length; i++) {
|
||||
var image = images[i];
|
||||
var newImage = $('<img />').attr('data-image-id', image.id);
|
||||
newImage.attr('title', image.name).attr('src', image.thumbnail);
|
||||
display.append(newImage);
|
||||
newImage.data('imageData', image);
|
||||
}
|
||||
}
|
||||
|
||||
elem.on('dblclick', '.image-manager-display img', function() {
|
||||
var imageElem = $(this);
|
||||
var imageData = imageElem.data('imageData');
|
||||
closeWindow();
|
||||
if(action) {
|
||||
action(imageData);
|
||||
}
|
||||
});
|
||||
|
||||
elem.find('button[data-action="close"]').click(function() {
|
||||
closeWindow();
|
||||
});
|
||||
|
||||
// Set up dropzone
|
||||
elem.find('.image-manager-dropzone').first().dropzone({
|
||||
uploadMultiple: false
|
||||
})
|
||||
|
||||
isInit = true;
|
||||
};
|
||||
|
||||
function showWindow() {
|
||||
overlay.closest('body').css('overflow', 'hidden');
|
||||
overlay.show();
|
||||
}
|
||||
|
||||
function closeWindow() {
|
||||
overlay.hide();
|
||||
overlay.closest('body').css('overflow', 'auto');
|
||||
}
|
||||
|
||||
window.ImageManager = ImageManager;
|
||||
})();
|
Loading…
Reference in New Issue
Block a user