2017-01-26 01:59:41 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Quote plugin
|
|
|
|
*/
|
|
|
|
|
2017-02-13 18:54:18 +01:00
|
|
|
var quote = (function(quote_plugin) {
|
2017-01-26 01:59:41 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
*
|
|
|
|
* CSS styles
|
|
|
|
*/
|
|
|
|
var elementClasses_ = {
|
|
|
|
|
|
|
|
ce_quote : 'ce-quote',
|
|
|
|
quoteText : 'ce_quote--text',
|
|
|
|
quoteAuthor : 'ce_quote--author',
|
|
|
|
authorsJob : 'ce_quote--job',
|
|
|
|
authorsPhoto : 'authorsPhoto',
|
|
|
|
authorsPhotoWrapper : 'authorsPhoto-wrapper',
|
2017-01-26 18:01:22 +01:00
|
|
|
authorsPhotoWrapper_preview : 'authorsPhotoWrapper_preview',
|
2017-01-26 01:59:41 +01:00
|
|
|
|
|
|
|
simple : {
|
|
|
|
text : 'quoteStyle-simple--text'
|
|
|
|
},
|
|
|
|
|
|
|
|
withCaption : {
|
|
|
|
blockquote : 'quoteStyle-withCaption--blockquote',
|
|
|
|
author : 'quoteStyle-withCaption--author'
|
|
|
|
},
|
|
|
|
|
|
|
|
withPhoto : {
|
|
|
|
photo : 'quoteStyle-withPhoto--photo',
|
|
|
|
author : 'quoteStyle-withPhoto--author',
|
|
|
|
job : 'quoteStyle-withPhoto--job',
|
|
|
|
quote : 'quoteStyle-withPhoto--quote',
|
|
|
|
wrapper : 'quoteStyle-withPhoto--wrapper',
|
|
|
|
authorHolder : 'quoteStyle-withPhoto--authorWrapper'
|
|
|
|
},
|
|
|
|
|
|
|
|
settings : {
|
2017-02-08 07:39:07 +01:00
|
|
|
holder : 'cdx-plugin-settings--horisontal',
|
2017-01-26 01:59:41 +01:00
|
|
|
caption : 'ce_plugin_quote--caption',
|
2017-02-08 07:39:07 +01:00
|
|
|
buttons : 'cdx-plugin-settings__item',
|
2017-01-26 01:59:41 +01:00
|
|
|
selectedType : 'ce-quote-settings--selected'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
var methods_ = {
|
|
|
|
|
|
|
|
changeStyleClicked : function() {
|
|
|
|
|
|
|
|
var changeStyleButton = this,
|
2017-02-01 18:25:59 +01:00
|
|
|
quote = codex.editor.content.currentNode.querySelector('.' + elementClasses_.ce_quote),
|
2017-01-26 01:59:41 +01:00
|
|
|
newStyle = changeStyleButton.dataset.style,
|
|
|
|
styleSelectors = this.parentNode.childNodes;
|
|
|
|
|
|
|
|
quote.dataset.quoteStyle = newStyle;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Mark selected style button
|
|
|
|
*/
|
|
|
|
for (var i = styleSelectors.length - 1; i >= 0; i--) {
|
|
|
|
styleSelectors[i].classList.remove(elementClasses_.settings.selectedType);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.classList.add(elementClasses_.settings.selectedType);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
*/
|
|
|
|
selectTypeQuoteStyle : function(type) {
|
|
|
|
|
|
|
|
var quoteStyleFunction;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Choose Quote style to replace
|
|
|
|
*/
|
|
|
|
switch (type) {
|
|
|
|
case 'simple':
|
|
|
|
quoteStyleFunction = methods_.makeSimpleQuote;
|
|
|
|
break;
|
|
|
|
case 'withCaption':
|
|
|
|
quoteStyleFunction = methods_.makeQuoteWithCaption;
|
|
|
|
break;
|
|
|
|
case 'withPhoto':
|
|
|
|
quoteStyleFunction = methods_.makeQuoteWithPhoto;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return quoteStyleFunction;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
*/
|
|
|
|
addSelectTypeClickListener : function(el, quoteStyle) {
|
|
|
|
|
|
|
|
el.addEventListener('click', function () {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parsing currentNode to JSON.
|
|
|
|
*/
|
|
|
|
var parsedOldQuote = methods_.parseBlockQuote(),
|
|
|
|
newStyledQuote = quoteStyle(parsedOldQuote);
|
|
|
|
|
2017-02-01 18:25:59 +01:00
|
|
|
var wrapper = codex.editor.content.composeNewBlock(newStyledQuote, 'quote');
|
2017-01-26 01:59:41 +01:00
|
|
|
wrapper.appendChild(newStyledQuote);
|
|
|
|
|
2017-02-01 18:25:59 +01:00
|
|
|
codex.editor.content.switchBlock(codex.editor.content.currentNode, newStyledQuote, 'quote');
|
2017-01-26 01:59:41 +01:00
|
|
|
|
|
|
|
/** Close settings after replacing */
|
2017-02-01 18:25:59 +01:00
|
|
|
codex.editor.toolbar.settings.close();
|
2017-01-26 01:59:41 +01:00
|
|
|
|
|
|
|
}, false);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
*/
|
|
|
|
makeSimpleQuote : function(data) {
|
|
|
|
|
|
|
|
var wrapper = ui_.makeBlock('BLOCKQUOTE', [elementClasses_.simple.text, elementClasses_.quoteText]);
|
|
|
|
|
|
|
|
wrapper.innerHTML = data.text || '';
|
|
|
|
|
|
|
|
wrapper.dataset.quoteStyle = 'simple';
|
|
|
|
wrapper.classList.add(elementClasses_.ce_quote);
|
|
|
|
wrapper.contentEditable = 'true';
|
|
|
|
|
|
|
|
return wrapper;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
*/
|
|
|
|
makeQuoteWithCaption : function(data) {
|
|
|
|
|
|
|
|
var wrapper = ui_.blockquote(),
|
|
|
|
text = ui_.makeBlock('DIV', [elementClasses_.withCaption.blockquote, elementClasses_.quoteText]),
|
|
|
|
author = ui_.makeBlock('DIV', [elementClasses_.withCaption.author, elementClasses_.quoteAuthor]);
|
|
|
|
|
|
|
|
/* make text block ontentEditable */
|
|
|
|
text.contentEditable = 'true';
|
|
|
|
|
2017-01-31 13:20:09 +01:00
|
|
|
text.innerHTML = data.text || '';
|
2017-01-26 01:59:41 +01:00
|
|
|
|
|
|
|
/* make Author contentEditable */
|
|
|
|
author.contentEditable = 'true';
|
|
|
|
|
2017-01-31 13:20:09 +01:00
|
|
|
author.textContent = data.cite || '';
|
2017-01-26 01:59:41 +01:00
|
|
|
|
|
|
|
/* Appending created components */
|
|
|
|
wrapper.dataset.quoteStyle = 'withCaption';
|
|
|
|
wrapper.classList.add(elementClasses_.ce_quote);
|
|
|
|
|
|
|
|
wrapper.appendChild(text);
|
|
|
|
wrapper.appendChild(author);
|
|
|
|
|
|
|
|
return wrapper;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
makeQuoteWithPhoto : function(data) {
|
|
|
|
|
|
|
|
var wrapper = ui_.blockquote(),
|
|
|
|
photo = ui_.makeBlock('DIV', [elementClasses_.withPhoto.photo]),
|
|
|
|
author = ui_.makeBlock('DIV', [elementClasses_.withPhoto.author, elementClasses_.quoteAuthor]),
|
|
|
|
job = ui_.makeBlock('DIV', [elementClasses_.withPhoto.job, elementClasses_.authorsJob]),
|
|
|
|
quote = ui_.makeBlock('DIV', [elementClasses_.withPhoto.quote, elementClasses_.quoteText]);
|
|
|
|
|
|
|
|
/* Default Image src */
|
|
|
|
if (!data.image) {
|
|
|
|
|
|
|
|
var icon = ui_.makeBlock('SPAN', ['ce-icon-picture']);
|
|
|
|
photo.appendChild(icon);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
var authorsPhoto = ui_.img(elementClasses_.authorsPhoto);
|
|
|
|
|
|
|
|
authorsPhoto.src = data.image;
|
|
|
|
authorsPhoto.dataset.bigUrl = data.image;
|
|
|
|
|
|
|
|
photo.classList.add(elementClasses_.authorsPhotoWrapper);
|
|
|
|
photo.appendChild(authorsPhoto);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
photo.addEventListener('click', fileUploadClicked_, false);
|
|
|
|
|
|
|
|
/* make author block contentEditable */
|
|
|
|
author.contentEditable = 'true';
|
2017-01-31 13:20:09 +01:00
|
|
|
author.textContent = data.cite || '';
|
2017-01-26 01:59:41 +01:00
|
|
|
|
|
|
|
/* Author's position and job */
|
|
|
|
job.contentEditable = 'true';
|
2017-01-31 13:20:09 +01:00
|
|
|
job.textContent = data.caption || '';
|
2017-01-26 01:59:41 +01:00
|
|
|
|
|
|
|
var authorsWrapper = ui_.makeBlock('DIV', [elementClasses_.withPhoto.authorHolder]);
|
|
|
|
authorsWrapper.appendChild(author);
|
|
|
|
authorsWrapper.appendChild(job);
|
|
|
|
|
|
|
|
/* make quote text contentEditable */
|
|
|
|
quote.contentEditable = 'true';
|
2017-01-31 13:20:09 +01:00
|
|
|
quote.innerHTML = data.text || '';
|
2017-01-26 01:59:41 +01:00
|
|
|
|
|
|
|
wrapper.classList.add(elementClasses_.ce_quote);
|
|
|
|
wrapper.classList.add(elementClasses_.withPhoto.wrapper);
|
|
|
|
wrapper.dataset.quoteStyle = 'withPhoto';
|
|
|
|
|
|
|
|
wrapper.appendChild(quote);
|
|
|
|
wrapper.appendChild(photo);
|
|
|
|
wrapper.appendChild(authorsWrapper);
|
|
|
|
|
|
|
|
return wrapper;
|
|
|
|
},
|
|
|
|
|
|
|
|
parseBlockQuote : function(block) {
|
|
|
|
|
2017-02-01 18:25:59 +01:00
|
|
|
var currentNode = block || codex.editor.content.currentNode,
|
2017-01-26 01:59:41 +01:00
|
|
|
photo = currentNode.getElementsByTagName('img')[0],
|
|
|
|
author = currentNode.querySelector('.' + elementClasses_.quoteAuthor),
|
|
|
|
job = currentNode.querySelector('.' + elementClasses_.authorsJob),
|
|
|
|
quote ;
|
|
|
|
|
|
|
|
/** Simple quote text placed in Blockquote tag*/
|
|
|
|
if ( currentNode.dataset.quoteStyle == 'simple' )
|
2017-01-31 13:20:09 +01:00
|
|
|
quote = currentNode.innerHTML || '';
|
2017-01-26 01:59:41 +01:00
|
|
|
else
|
|
|
|
quote = currentNode.querySelector('.' + elementClasses_.quoteText).innerHTML;
|
|
|
|
|
|
|
|
if (job)
|
2017-01-31 13:20:09 +01:00
|
|
|
job = job.textContent || '';
|
2017-01-26 01:59:41 +01:00
|
|
|
|
|
|
|
if (author)
|
2017-01-31 13:20:09 +01:00
|
|
|
author = author.textContent || '';
|
2017-01-26 01:59:41 +01:00
|
|
|
|
|
|
|
if (photo)
|
|
|
|
photo = photo.dataset.bigUrl;
|
|
|
|
|
|
|
|
var data = {
|
|
|
|
style : currentNode.dataset.quoteStyle,
|
|
|
|
text : quote,
|
|
|
|
author : author,
|
|
|
|
job : job,
|
|
|
|
photo : photo
|
|
|
|
};
|
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
*
|
|
|
|
* Author image Uploader
|
|
|
|
*/
|
|
|
|
var fileUploadClicked_ = function() {
|
|
|
|
|
|
|
|
var beforeSend = photoUploadingCallbacks_.beforeSend,
|
|
|
|
success = photoUploadingCallbacks_.success,
|
|
|
|
error = photoUploadingCallbacks_.error;
|
|
|
|
|
2017-02-01 18:25:59 +01:00
|
|
|
codex.editor.transport.selectAndUpload({
|
2017-01-26 01:59:41 +01:00
|
|
|
beforeSend: beforeSend,
|
|
|
|
success: success,
|
|
|
|
error: error
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
var ui_ = {
|
|
|
|
|
|
|
|
wrapper : function($classList) {
|
|
|
|
|
|
|
|
var el = document.createElement('DIV');
|
|
|
|
|
|
|
|
el.classList.add($classList);
|
|
|
|
|
|
|
|
return el;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
blockquote : function() {
|
|
|
|
|
|
|
|
var el = document.createElement('BLOCKQUOTE');
|
|
|
|
|
|
|
|
return el;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
img : function(attribute) {
|
|
|
|
|
|
|
|
var imageTag = document.createElement('IMG');
|
|
|
|
imageTag.classList.add(attribute);
|
|
|
|
|
|
|
|
return imageTag;
|
|
|
|
},
|
|
|
|
|
|
|
|
makeBlock : function(tag, classList) {
|
|
|
|
|
|
|
|
var el = document.createElement(tag);
|
|
|
|
|
|
|
|
if ( classList ) {
|
|
|
|
|
|
|
|
for( var i = 0; i < classList.length; i++)
|
|
|
|
el.className += ' ' + classList[i];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return el;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2017-01-26 18:12:30 +01:00
|
|
|
|
|
|
|
|
2017-01-26 01:59:41 +01:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
*
|
|
|
|
* Callbacks
|
|
|
|
*/
|
|
|
|
var photoUploadingCallbacks_ = {
|
|
|
|
|
2017-01-26 18:12:30 +01:00
|
|
|
preview_ : function(e) {
|
|
|
|
|
2017-02-01 18:25:59 +01:00
|
|
|
var uploadImageWrapper = codex.editor.content.currentNode.querySelector('.' + elementClasses_.withPhoto.photo),
|
2017-01-26 18:12:30 +01:00
|
|
|
authorsPhoto = ui_.img(elementClasses_.authorsPhoto);
|
|
|
|
|
2017-01-28 20:54:04 +01:00
|
|
|
/** Appending uploaded image */
|
|
|
|
uploadImageWrapper.classList.add(elementClasses_.authorsPhotoWrapper, elementClasses_.authorsPhotoWrapper_preview);
|
|
|
|
|
2017-01-26 18:12:30 +01:00
|
|
|
authorsPhoto.src = e.target.result;
|
|
|
|
|
|
|
|
/** Remove icon from image wrapper */
|
|
|
|
uploadImageWrapper.innerHTML = '';
|
|
|
|
|
|
|
|
uploadImageWrapper.appendChild(authorsPhoto);
|
|
|
|
},
|
|
|
|
|
2017-01-26 01:59:41 +01:00
|
|
|
beforeSend : function() {
|
|
|
|
|
2017-02-01 18:25:59 +01:00
|
|
|
var input = codex.editor.transport.input,
|
2017-01-26 18:01:22 +01:00
|
|
|
files = input.files,
|
|
|
|
file = files[0],
|
|
|
|
fileReader = new FileReader();
|
|
|
|
|
|
|
|
fileReader.readAsDataURL(file);
|
|
|
|
|
2017-01-28 14:33:09 +01:00
|
|
|
fileReader.onload = photoUploadingCallbacks_.preview_;
|
2017-01-26 18:01:22 +01:00
|
|
|
|
2017-01-26 01:59:41 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Success callbacks for uploaded photo.
|
|
|
|
* Replace upload icon with uploaded photo
|
|
|
|
*/
|
|
|
|
success : function(result) {
|
|
|
|
|
|
|
|
var parsed = JSON.parse(result),
|
|
|
|
filename = parsed.filename,
|
2017-02-01 18:25:59 +01:00
|
|
|
uploadImageWrapper = codex.editor.content.currentNode.querySelector('.' + elementClasses_.withPhoto.photo);
|
2017-01-26 01:59:41 +01:00
|
|
|
|
2017-01-26 18:01:22 +01:00
|
|
|
var img = uploadImageWrapper.querySelector('IMG');
|
|
|
|
img.src = parsed.data.file.bigUrl;
|
2017-01-28 14:38:10 +01:00
|
|
|
img.dataset.bigUrl = parsed.data.file.bigUrl;
|
2017-01-26 01:59:41 +01:00
|
|
|
|
2017-01-26 18:01:22 +01:00
|
|
|
uploadImageWrapper.classList.remove(elementClasses_.authorsPhotoWrapper_preview);
|
2017-01-26 01:59:41 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
/** Error callback. Sends notification to user that something happend or plugin doesn't supports method */
|
|
|
|
error : function(result) {
|
|
|
|
console.log('Can\'t upload an image');
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
*
|
|
|
|
* Make Quote from JSON datasets
|
|
|
|
*/
|
|
|
|
var make_ = function(data) {
|
|
|
|
|
|
|
|
var tag;
|
|
|
|
|
|
|
|
if (data && data.size) {
|
|
|
|
|
2017-02-13 18:54:18 +01:00
|
|
|
data.style = quote_plugin.config.defaultStyle;
|
2017-01-26 01:59:41 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Supported types
|
|
|
|
*/
|
|
|
|
switch (data.style) {
|
|
|
|
|
|
|
|
case 'simple':
|
2017-01-26 02:15:16 +01:00
|
|
|
tag = methods_.makeSimpleQuote(data);
|
2017-01-26 01:59:41 +01:00
|
|
|
break;
|
|
|
|
case 'withCaption':
|
2017-01-26 02:15:16 +01:00
|
|
|
tag = methods_.makeQuoteWithCaption(data);
|
2017-01-26 01:59:41 +01:00
|
|
|
break;
|
|
|
|
case 'withPhoto':
|
2017-01-26 02:15:16 +01:00
|
|
|
tag = methods_.makeQuoteWithPhoto(data);
|
2017-01-26 01:59:41 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
tag.dataset.quoteStyle = data.size;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
var settings = {
|
|
|
|
"text" : null,
|
|
|
|
"format" : "html",
|
|
|
|
"cite" : null,
|
|
|
|
"caption": null,
|
|
|
|
"size" : null,
|
|
|
|
"image" : null
|
|
|
|
};
|
|
|
|
|
|
|
|
tag = methods_.makeQuoteWithPhoto(settings);
|
|
|
|
}
|
|
|
|
|
|
|
|
return tag;
|
|
|
|
};
|
|
|
|
|
|
|
|
var prepareDataForSave_ = function(data) {
|
|
|
|
|
2017-01-26 17:12:08 +01:00
|
|
|
if (data.size == 'withPhoto') {
|
|
|
|
data.size = 'small';
|
|
|
|
}
|
|
|
|
|
2017-01-30 17:56:52 +01:00
|
|
|
/** Make paragraphs */
|
2017-02-01 18:25:59 +01:00
|
|
|
data.text = codex.editor.content.wrapTextWithParagraphs(data.text);
|
2017-01-26 18:01:22 +01:00
|
|
|
|
2017-01-26 17:12:08 +01:00
|
|
|
return data;
|
2017-01-26 01:59:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*
|
|
|
|
* Renderer
|
|
|
|
*
|
|
|
|
* @param data
|
|
|
|
*/
|
2017-02-13 18:54:18 +01:00
|
|
|
quote_plugin.render = function(data) {
|
2017-01-26 01:59:41 +01:00
|
|
|
return make_(data);
|
|
|
|
};
|
|
|
|
|
2017-02-13 18:54:18 +01:00
|
|
|
quote_plugin.validate = function(output) {
|
2017-01-26 01:59:41 +01:00
|
|
|
|
|
|
|
if (typeof output.text != "string") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
return output;
|
|
|
|
};
|
|
|
|
|
2017-02-13 18:54:18 +01:00
|
|
|
quote_plugin.save = function(blockContent) {
|
2017-01-26 01:59:41 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Extracts JSON quote data from HTML block
|
|
|
|
* @param {Text} text, {Text} author, {Object} photo
|
|
|
|
*/
|
|
|
|
var parsedblock = methods_.parseBlockQuote(blockContent);
|
|
|
|
|
2017-01-30 17:56:52 +01:00
|
|
|
var outputData = {
|
2017-01-26 01:59:41 +01:00
|
|
|
"text" : parsedblock.text,
|
|
|
|
"format" : "html",
|
2017-01-30 18:37:47 +01:00
|
|
|
"cite" : parsedblock.author || '',
|
|
|
|
"caption": parsedblock.job || '',
|
2017-01-26 01:59:41 +01:00
|
|
|
"size" : parsedblock.style,
|
|
|
|
"image" : parsedblock.photo
|
|
|
|
};
|
|
|
|
|
2017-01-30 17:56:52 +01:00
|
|
|
return prepareDataForSave_(outputData);
|
2017-01-26 01:59:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*
|
|
|
|
* Draws settings
|
|
|
|
*/
|
2017-02-13 18:54:18 +01:00
|
|
|
quote_plugin.makeSettings = function(data) {
|
2017-01-26 01:59:41 +01:00
|
|
|
|
|
|
|
var holder = document.createElement('DIV'),
|
|
|
|
types = {
|
|
|
|
big : 'По центру',
|
|
|
|
small : 'Врезка'
|
|
|
|
},
|
|
|
|
selectTypeButton;
|
|
|
|
|
|
|
|
/** Add holder classname */
|
|
|
|
holder.className = elementClasses_.settings.holder;
|
|
|
|
|
|
|
|
/** Now add type selectors */
|
|
|
|
for (var type in types){
|
|
|
|
|
|
|
|
selectTypeButton = document.createElement('SPAN');
|
|
|
|
|
|
|
|
selectTypeButton.textContent = types[type];
|
|
|
|
selectTypeButton.className = elementClasses_.settings.buttons;
|
|
|
|
|
|
|
|
selectTypeButton.dataset.style = type;
|
|
|
|
|
2017-02-13 18:54:18 +01:00
|
|
|
if ( type == quote_plugin.config.defaultStyle ){
|
2017-01-26 01:59:41 +01:00
|
|
|
selectTypeButton.classList.add(quoteTools.styles.settings.selectedType);
|
|
|
|
}
|
|
|
|
|
|
|
|
// var quoteStyle = quoteTools.selectTypeQuoteStyle(type);
|
|
|
|
|
|
|
|
selectTypeButton.addEventListener('click', methods_.changeStyleClicked, false);
|
|
|
|
// quoteTools.addSelectTypeClickListener(selectTypeButton, quoteStyle);
|
|
|
|
|
|
|
|
holder.appendChild(selectTypeButton);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return holder;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
* Default path to redactors images
|
|
|
|
* @type {null}
|
|
|
|
*/
|
2017-02-13 18:54:18 +01:00
|
|
|
quote_plugin.path = null;
|
2017-01-26 01:59:41 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*
|
|
|
|
* @type {null}
|
|
|
|
*/
|
2017-02-13 18:54:18 +01:00
|
|
|
quote_plugin.config = null;
|
2017-01-26 01:59:41 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*
|
|
|
|
* @param config
|
|
|
|
*/
|
2017-02-13 18:54:18 +01:00
|
|
|
quote_plugin.prepare = function(config) {
|
2017-02-01 10:14:00 +01:00
|
|
|
|
2017-02-13 18:54:18 +01:00
|
|
|
quote_plugin.config = config;
|
2017-02-01 10:14:00 +01:00
|
|
|
|
|
|
|
return Promise.resolve();
|
2017-01-26 01:59:41 +01:00
|
|
|
};
|
|
|
|
|
2017-02-13 18:54:18 +01:00
|
|
|
quote_plugin.destroy = function () {
|
|
|
|
|
|
|
|
quote = null;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
return quote_plugin;
|
2017-01-26 01:59:41 +01:00
|
|
|
|
|
|
|
})({});
|