Integrated tinymce

This commit is contained in:
Dan Brown 2015-07-14 22:34:55 +01:00
parent d461861263
commit c4d0f38a67
3 changed files with 97 additions and 0 deletions

3
.bowerrc Normal file
View File

@ -0,0 +1,3 @@
{
"directory": "public/bower/"
}

20
bower.json Normal file
View 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"
}
}

View 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;
})();