From 48438d456edb5407ac6ad7167e468ed297661b4b Mon Sep 17 00:00:00 2001 From: khaydarov Date: Thu, 26 Jan 2017 19:12:08 +0300 Subject: [PATCH 1/4] merged --- example.html | 10 ++-------- plugins/quote/quote.js | 15 +++++++++------ 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/example.html b/example.html index bfebc917..fd845009 100644 --- a/example.html +++ b/example.html @@ -151,15 +151,9 @@ type: 'instagram', iconClassname: 'ce-icon-instagram', prepare: instagram.prepare, - make: instagram.make, - appendCallback: null, - settings: null, render: instagram.reneder, validate: instagram.validate, - save: instagram.save, - displayInToolbox: false, - enableLineBreaks: false, - allowedToPaste: false + save: instagram.save }, twitter: { type: 'twitter', @@ -177,7 +171,7 @@ make: embed.make, render: embed.render, save: embed.save, - validate: embed.validate, + validate: embed.validate } }, data : { diff --git a/plugins/quote/quote.js b/plugins/quote/quote.js index 53549451..4686eb3c 100644 --- a/plugins/quote/quote.js +++ b/plugins/quote/quote.js @@ -418,6 +418,13 @@ var quote = (function(quote) { var prepareDataForSave_ = function(data) { + if (data.size == 'withPhoto') { + data.size = 'small'; + } + + console.log(data); + + return data; }; /** @@ -448,11 +455,7 @@ var quote = (function(quote) { */ var parsedblock = methods_.parseBlockQuote(blockContent); - if (parsedblock.style == 'withPhoto') { - parsedblock.style = 'small'; - } - - data = { + var data = { "text" : parsedblock.text, "format" : "html", "cite" : parsedblock.author, @@ -461,7 +464,7 @@ var quote = (function(quote) { "image" : parsedblock.photo }; - return data; + return prepareDataForSave_(data); }; /** From 6e88738c9bcb9dff9a75701e81194849d0276007 Mon Sep 17 00:00:00 2001 From: khaydarov Date: Thu, 26 Jan 2017 19:27:48 +0300 Subject: [PATCH 2/4] quote modifications --- plugins/quote/quote.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/plugins/quote/quote.js b/plugins/quote/quote.js index 4686eb3c..684f6160 100644 --- a/plugins/quote/quote.js +++ b/plugins/quote/quote.js @@ -422,8 +422,24 @@ var quote = (function(quote) { data.size = 'small'; } - console.log(data); + var wrapper = document.createElement('DIV'); + wrapper.innerHTML = data.text; + var child; + + for (child = 0; child < wrapper.childNodes.length; child++) { + // is TEXT node ? + if (wrapper.childNodes[child].nodeType === 3) { + + var paragraph = document.createElement('P'); + paragraph.innerHTML = wrapper.childNodes[child].textContent; + + wrapper.childNodes[child].replaceWith(paragraph); + } + } + + data.text = wrapper.innerHTML; + return data; }; From e710a41e8cb22f77bf8b44801b31f15ccf776f41 Mon Sep 17 00:00:00 2001 From: khaydarov Date: Thu, 26 Jan 2017 20:01:22 +0300 Subject: [PATCH 3/4] quote photo preview --- plugins/quote/quote.css | 7 +++++++ plugins/quote/quote.js | 42 +++++++++++++++++++++++++++++------------ 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/plugins/quote/quote.css b/plugins/quote/quote.css index ee3a3d82..e21dfd9b 100644 --- a/plugins/quote/quote.css +++ b/plugins/quote/quote.css @@ -127,6 +127,13 @@ .authorsPhoto-wrapper { border: 0 !important; + transition: all 500ms ease-in; + will-change: opacity, filter; +} + +.authorsPhotoWrapper_preview { + opacity: .5; + filter: blur(1.7px) grayscale(1); } .quoteStyle-withPhoto--photo .ce-icon-picture { diff --git a/plugins/quote/quote.js b/plugins/quote/quote.js index 684f6160..370ae3b9 100644 --- a/plugins/quote/quote.js +++ b/plugins/quote/quote.js @@ -18,6 +18,7 @@ var quote = (function(quote) { authorsJob : 'ce_quote--job', authorsPhoto : 'authorsPhoto', authorsPhotoWrapper : 'authorsPhoto-wrapper', + authorsPhotoWrapper_preview : 'authorsPhotoWrapper_preview', simple : { text : 'quoteStyle-simple--text' @@ -336,6 +337,30 @@ var quote = (function(quote) { beforeSend : function() { + var input = codex.transport.input, + files = input.files, + file = files[0], + fileReader = new FileReader(); + + fileReader.readAsDataURL(file); + + fileReader.onload = function(e) { + + var uploadImageWrapper = codex.content.currentNode.querySelector('.' + elementClasses_.withPhoto.photo), + authorsPhoto = ui_.img(elementClasses_.authorsPhoto); + + authorsPhoto.src = e.target.result; + + /** Remove icon from image wrapper */ + uploadImageWrapper.innerHTML = ''; + + /** Appending uploaded image */ + uploadImageWrapper.classList.add(elementClasses_.authorsPhotoWrapper); + uploadImageWrapper.classList.add(elementClasses_.authorsPhotoWrapper_preview); + + uploadImageWrapper.appendChild(authorsPhoto); + }; + }, /** @@ -346,19 +371,12 @@ var quote = (function(quote) { var parsed = JSON.parse(result), filename = parsed.filename, - uploadImageWrapper = codex.content.currentNode.querySelector('.' + elementClasses_.withPhoto.photo), - authorsPhoto = ui_.img(elementClasses_.authorsPhoto); + uploadImageWrapper = codex.content.currentNode.querySelector('.' + elementClasses_.withPhoto.photo); - authorsPhoto.src = parsed.data.file.url; + var img = uploadImageWrapper.querySelector('IMG'); + img.src = parsed.data.file.bigUrl; - /** Remove icon from image wrapper */ - uploadImageWrapper.innerHTML = ''; - - /** Appending uploaded image */ - uploadImageWrapper.classList.add(elementClasses_.authorsPhotoWrapper); - uploadImageWrapper.appendChild(authorsPhoto); - - authorsPhoto.dataset.bigUrl = parsed.data.file.bigUrl; + uploadImageWrapper.classList.remove(elementClasses_.authorsPhotoWrapper_preview); }, /** Error callback. Sends notification to user that something happend or plugin doesn't supports method */ @@ -439,7 +457,7 @@ var quote = (function(quote) { } data.text = wrapper.innerHTML; - + return data; }; From b6148a747ccceeed17b271110fc8c935dbf8f726 Mon Sep 17 00:00:00 2001 From: khaydarov Date: Thu, 26 Jan 2017 20:12:30 +0300 Subject: [PATCH 4/4] upd --- plugins/quote/quote.js | 47 ++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/plugins/quote/quote.js b/plugins/quote/quote.js index 370ae3b9..affdf04f 100644 --- a/plugins/quote/quote.js +++ b/plugins/quote/quote.js @@ -328,6 +328,8 @@ var quote = (function(quote) { }; + + /** * @private * @@ -335,6 +337,22 @@ var quote = (function(quote) { */ var photoUploadingCallbacks_ = { + preview_ : function(e) { + + var uploadImageWrapper = codex.content.currentNode.querySelector('.' + elementClasses_.withPhoto.photo), + authorsPhoto = ui_.img(elementClasses_.authorsPhoto); + + authorsPhoto.src = e.target.result; + + /** Remove icon from image wrapper */ + uploadImageWrapper.innerHTML = ''; + + /** Appending uploaded image */ + uploadImageWrapper.classList.add(elementClasses_.authorsPhotoWrapper, elementClasses_.authorsPhotoWrapper_preview); + + uploadImageWrapper.appendChild(authorsPhoto); + }, + beforeSend : function() { var input = codex.transport.input, @@ -344,22 +362,7 @@ var quote = (function(quote) { fileReader.readAsDataURL(file); - fileReader.onload = function(e) { - - var uploadImageWrapper = codex.content.currentNode.querySelector('.' + elementClasses_.withPhoto.photo), - authorsPhoto = ui_.img(elementClasses_.authorsPhoto); - - authorsPhoto.src = e.target.result; - - /** Remove icon from image wrapper */ - uploadImageWrapper.innerHTML = ''; - - /** Appending uploaded image */ - uploadImageWrapper.classList.add(elementClasses_.authorsPhotoWrapper); - uploadImageWrapper.classList.add(elementClasses_.authorsPhotoWrapper_preview); - - uploadImageWrapper.appendChild(authorsPhoto); - }; + fileReader.onload = photoUploadingCallbacks_.preview_(e); }, @@ -436,6 +439,8 @@ var quote = (function(quote) { var prepareDataForSave_ = function(data) { + var TEXTNODE = 3; + if (data.size == 'withPhoto') { data.size = 'small'; } @@ -443,13 +448,15 @@ var quote = (function(quote) { var wrapper = document.createElement('DIV'); wrapper.innerHTML = data.text; - var child; + var child, + paragraph; for (child = 0; child < wrapper.childNodes.length; child++) { - // is TEXT node ? - if (wrapper.childNodes[child].nodeType === 3) { - var paragraph = document.createElement('P'); + // is TEXT node ? + if (wrapper.childNodes[child].nodeType === TEXTNODE) { + + paragraph = document.createElement('P'); paragraph.innerHTML = wrapper.childNodes[child].textContent; wrapper.childNodes[child].replaceWith(paragraph);