2016-12-25 15:41:57 +01:00
|
|
|
|
/**
|
|
|
|
|
* Image plugin for codex-editor
|
|
|
|
|
* @author CodeX Team <team@ifmo.su>
|
|
|
|
|
*
|
|
|
|
|
* @version 1.1.3
|
|
|
|
|
*/
|
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
var image = (function(image) {
|
|
|
|
|
|
|
|
|
|
var elementClasses = {
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
|
|
|
|
ce_image : 'ce-image',
|
|
|
|
|
loading : 'ce-plugin-image__loader',
|
|
|
|
|
blockStretched: 'ce-block--stretched',
|
|
|
|
|
uploadedImage : {
|
2017-01-18 16:12:50 +01:00
|
|
|
|
centered : 'ce-plugin-image__uploaded--centered',
|
|
|
|
|
stretched : 'ce-plugin-image__uploaded--stretched'
|
2016-12-25 15:41:57 +01:00
|
|
|
|
},
|
|
|
|
|
imageCaption : 'ce-plugin-image__caption',
|
|
|
|
|
imageWrapper : 'ce-plugin-image__wrapper',
|
|
|
|
|
formHolder : 'ce-plugin-image__holder',
|
2017-01-18 16:12:50 +01:00
|
|
|
|
uploadButton : 'ce-plugin-image__button'
|
|
|
|
|
};
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
var holder = null;
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
|
|
|
|
/** Default path to redactors images */
|
2017-01-18 16:12:50 +01:00
|
|
|
|
var path = '/upload/redactor_images/';
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
var ui = {
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
holder : function(){
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
var element = document.createElement('DIV');
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
element.classList.add(elementClasses.formHolder);
|
|
|
|
|
element.classList.add(elementClasses.ce_image);
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
return element;
|
|
|
|
|
},
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
uploadButton : function(){
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
var button = document.createElement('SPAN');
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
button.classList.add(elementClasses.uploadButton);
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
button.innerHTML = '<i class="ce-icon-picture"> </i>';
|
|
|
|
|
button.innerHTML += 'Загрузить фотографию';
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
return button;
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
},
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
/**
|
|
|
|
|
* @param {string} source - file path
|
|
|
|
|
* @param {string} style - css class
|
|
|
|
|
* @return {object} image - document IMG tag
|
|
|
|
|
*/
|
|
|
|
|
image : function(source, style) {
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
var image = document.createElement('IMG');
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
image.classList.add(style);
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
image.src = source;
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
return image;
|
|
|
|
|
},
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
wrapper : function() {
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
var div = document.createElement('div');
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
div.classList.add(elementClasses.imageWrapper);
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
return div;
|
|
|
|
|
},
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
caption : function() {
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
var div = document.createElement('div');
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
div.classList.add(elementClasses.imageCaption);
|
|
|
|
|
div.contentEditable = true;
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
return div;
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* Draws form for image upload
|
|
|
|
|
*/
|
|
|
|
|
makeForm : function() {
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
var holder = ui.holder(),
|
|
|
|
|
uploadButton = ui.uploadButton();
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
holder.appendChild(uploadButton);
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
uploadButton.addEventListener('click', methods.uploadButtonClicked, false );
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
holder = holder;
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
return holder;
|
|
|
|
|
},
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
/**
|
|
|
|
|
* wraps image and caption
|
|
|
|
|
* @param {object} data - image information
|
|
|
|
|
* @param {string} imageTypeClass - plugin's style
|
|
|
|
|
* @param {boolean} stretched - stretched or not
|
|
|
|
|
* @return wrapped block with image and caption
|
|
|
|
|
*/
|
|
|
|
|
makeImage : function(data, imageTypeClass, stretched) {
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
var file = data.file.url,
|
|
|
|
|
text = data.caption,
|
|
|
|
|
type = data.type,
|
|
|
|
|
image = ui.image(file, imageTypeClass),
|
|
|
|
|
caption = ui.caption(),
|
|
|
|
|
wrapper = ui.wrapper();
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
caption.textContent = text;
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
wrapper.dataset.stretched = stretched;
|
|
|
|
|
/** Appeding to the wrapper */
|
|
|
|
|
wrapper.appendChild(image);
|
|
|
|
|
wrapper.appendChild(caption);
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
return wrapper;
|
|
|
|
|
},
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
/**
|
|
|
|
|
* @param {HTML} data - Rendered block with image
|
|
|
|
|
*/
|
|
|
|
|
getImage : function(data) {
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
var image = data.querySelector('.' + elementClasses.uploadedImage.centered) ||
|
|
|
|
|
data.querySelector('.' + elementClasses.uploadedImage.stretched);
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
return image;
|
|
|
|
|
},
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
/**
|
|
|
|
|
* wraps image and caption
|
|
|
|
|
* @deprecated
|
|
|
|
|
* @param {object} data - image information
|
|
|
|
|
* @return wrapped block with image and caption
|
|
|
|
|
*/
|
|
|
|
|
centeredImage : function(data) {
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
var file = data.file.url,
|
|
|
|
|
text = data.caption,
|
|
|
|
|
type = data.type,
|
|
|
|
|
image = ui.image(file, elementClasses.uploadedImage.centered),
|
|
|
|
|
caption = ui.caption(),
|
|
|
|
|
wrapper = ui.wrapper();
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
caption.textContent = text;
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
wrapper.dataset.stretched = 'false';
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
/** Appeding to the wrapper */
|
|
|
|
|
wrapper.appendChild(image);
|
|
|
|
|
wrapper.appendChild(caption);
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
return wrapper;
|
|
|
|
|
},
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
/**
|
|
|
|
|
* wraps image and caption
|
|
|
|
|
* @deprecated
|
|
|
|
|
* @param {object} data - image information
|
|
|
|
|
* @return stretched image
|
|
|
|
|
*/
|
|
|
|
|
stretchedImage : function(data) {
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
var file = data.file.url,
|
|
|
|
|
text = data.caption,
|
|
|
|
|
type = data.type,
|
|
|
|
|
image = ui.image(file, elementClasses.uploadedImage.stretched),
|
|
|
|
|
caption = ui.caption(),
|
|
|
|
|
wrapper = ui.wrapper();
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
caption.textContent = text;
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
wrapper.dataset.stretched = 'true';
|
|
|
|
|
/** Appeding to the wrapper */
|
|
|
|
|
wrapper.appendChild(image);
|
|
|
|
|
wrapper.appendChild(caption);
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
return wrapper;
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
}
|
|
|
|
|
};
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
var methods = {
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
uploadButtonClicked : function(event) {
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
/** Define callbacks */
|
|
|
|
|
codex.transport.selectAndUpload({
|
|
|
|
|
beforeSend: photoUploadingCallbacks.beforeSend,
|
|
|
|
|
success: photoUploadingCallbacks.success,
|
|
|
|
|
error: photoUploadingCallbacks.error
|
|
|
|
|
});
|
|
|
|
|
},
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
addSelectTypeClickListener : function(el, type) {
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
el.addEventListener('click', function() {
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
methods.selectTypeClicked(type);
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
}, false);
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
},
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
selectTypeClicked : function(type) {
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
var current = codex.content.currentNode,
|
|
|
|
|
blockContent = current.childNodes[0],
|
|
|
|
|
image = ui.getImage(current),
|
|
|
|
|
wrapper = current.querySelector('.' + elementClasses.imageWrapper);
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
/** Clear classList */
|
|
|
|
|
current.className = '';
|
|
|
|
|
image.className = '';
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
/** Add important first-level class ce_block */
|
|
|
|
|
current.classList.add(codex.ui.className.BLOCK_CLASSNAME);
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
if (type === 'stretched') {
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
image.classList.add(elementClasses.uploadedImage.stretched);
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
blockContent.classList.add(elementClasses.blockStretched);
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
/** Setting dataset for saver */
|
|
|
|
|
wrapper.dataset.stretched = true;
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
} else if (type === 'centered') {
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
image.classList.add(elementClasses.uploadedImage.centered);
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
blockContent.classList.remove(elementClasses.blockStretched);
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
/** Setting dataset for saver */
|
|
|
|
|
wrapper.dataset.stretched = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
var photoUploadingCallbacks = {
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
/** Before sending ajax request */
|
|
|
|
|
beforeSend : function() {
|
|
|
|
|
holder.classList.add(elementClasses.loading);
|
|
|
|
|
},
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
/** Photo was uploaded successfully */
|
|
|
|
|
success : function(result) {
|
|
|
|
|
|
|
|
|
|
var parsed = JSON.parse(result),
|
|
|
|
|
data,
|
|
|
|
|
currentBlock = codex.content.currentNode,
|
|
|
|
|
imageReady;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Preparing {Object} data to draw an image
|
|
|
|
|
* @uses make method
|
|
|
|
|
*/
|
|
|
|
|
data = {
|
|
|
|
|
background : false,
|
|
|
|
|
border : false,
|
|
|
|
|
isStretch : false,
|
|
|
|
|
file : {
|
|
|
|
|
url : path + 'o_' + parsed.filename,
|
|
|
|
|
bigUrl : null,
|
|
|
|
|
width : null,
|
|
|
|
|
height : null,
|
|
|
|
|
additionalData : null
|
|
|
|
|
},
|
|
|
|
|
caption : '',
|
|
|
|
|
cover : null
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
imageReady = image.make(data);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* If current block is empty, we can replace it to uploaded image
|
|
|
|
|
* Or insert new block
|
|
|
|
|
*/
|
|
|
|
|
codex.content.switchBlock(holder, imageReady, 'image');
|
|
|
|
|
},
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
/** Error callback. Sends notification to user that something happend or plugin doesn't supports method */
|
|
|
|
|
error : function(result) {
|
|
|
|
|
console.log('Choosen file is not an image or image is corrupted');
|
|
|
|
|
codex.notifications.errorThrown();
|
|
|
|
|
}
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
};
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
/**
|
|
|
|
|
* Public method
|
|
|
|
|
*/
|
|
|
|
|
image.make = function ( data ) {
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
var imageHolder;
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
if (data) {
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
if ( data.isStretch !== 'true') {
|
|
|
|
|
imageHolder = ui.makeImage(data, elementClasses.uploadedImage.centered, 'false');
|
|
|
|
|
} else {
|
|
|
|
|
imageHolder = ui.makeImage(data, elementClasses.uploadedImage.stretched, 'true');
|
|
|
|
|
}
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
} else {
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
imageHolder = ui.makeForm();
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
}
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
holder = imageHolder;
|
|
|
|
|
return imageHolder;
|
|
|
|
|
};
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
|
|
|
|
/**
|
2017-01-18 16:12:50 +01:00
|
|
|
|
* this tool works when tool is clicked in toolbox
|
|
|
|
|
*/
|
|
|
|
|
image.appendCallback = function(event) {
|
|
|
|
|
|
|
|
|
|
/** Upload image and call success callback*/
|
|
|
|
|
methods.uploadButtonClicked(event);
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
};
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
/**
|
|
|
|
|
* Settings panel content
|
|
|
|
|
* @return {Element} element contains all settings
|
|
|
|
|
*/
|
|
|
|
|
image.makeSettings = function () {
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
var holder = document.createElement('DIV'),
|
|
|
|
|
types = {
|
|
|
|
|
centered : 'По центру',
|
|
|
|
|
stretched : 'На всю ширину'
|
|
|
|
|
},
|
|
|
|
|
selectTypeButton;
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
/** Add holder classname */
|
|
|
|
|
holder.className = 'ce_plugin_image--settings';
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
/** Now add type selectors */
|
|
|
|
|
for (var type in types){
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
selectTypeButton = document.createElement('SPAN');
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
selectTypeButton.textContent = types[type];
|
|
|
|
|
selectTypeButton.className = 'ce_plugin_image--select_button';
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
methods.addSelectTypeClickListener(selectTypeButton, type);
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
holder.appendChild(selectTypeButton);
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
}
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
return holder;
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
};
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
image.render = function( data ) {
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
return image.make(data);
|
|
|
|
|
};
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
image.save = function ( block ) {
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
var content = block,
|
|
|
|
|
image = ui.getImage(content),
|
|
|
|
|
caption = content.querySelector('.' + elementClasses.imageCaption);
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
var data = {
|
2016-12-25 15:41:57 +01:00
|
|
|
|
background : false,
|
2017-01-18 16:12:50 +01:00
|
|
|
|
border : false,
|
|
|
|
|
isStretch : content.dataset.stretched,
|
2016-12-25 15:41:57 +01:00
|
|
|
|
file : {
|
2017-01-18 16:12:50 +01:00
|
|
|
|
url : image.src,
|
2016-12-25 15:41:57 +01:00
|
|
|
|
bigUrl : null,
|
2017-01-18 16:12:50 +01:00
|
|
|
|
width : image.width,
|
|
|
|
|
height : image.height,
|
|
|
|
|
additionalData :null
|
2016-12-25 15:41:57 +01:00
|
|
|
|
},
|
2017-01-18 16:12:50 +01:00
|
|
|
|
caption : caption.textContent,
|
|
|
|
|
cover : null
|
2016-12-25 15:41:57 +01:00
|
|
|
|
};
|
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
return data;
|
|
|
|
|
};
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
return image;
|
2016-12-25 15:41:57 +01:00
|
|
|
|
|
2017-01-18 16:12:50 +01:00
|
|
|
|
})({});
|