CKEditor - Save Multiple contenteditable - Divs Stripped Out - plugins

I have an inline web page editor which allows the user to edit the content (specified in the div id='saveableContent') for each page.
I'm using CKEditor 4.2.1 along with the Youtube plugin: https://github.com/fonini/ckeditor-youtube-plugin
The inline editor has multiple contenteditable='true' divs for the parts of the page that can be editable, much like following: the http://nightly.ckeditor.com/14-01-03-07-05/standard/samples/inlineall.html
I will post an example with only one contenteditable div but note that there may be multiple on a page.
Before I was using the YouTube plugin, I would simply save the entire content by getting:
$('#saveableContent').html();
which kept all the code intact. However, once I started using the YouTube plugin, when adding a YouTube video it displays it as an iFrame image.
<div aria-describedby="cke_66" title="Rich Text Editor, content" aria-label="Rich Text Editor, content" role="textbox" style="position: relative;" spellcheck="false" tabindex="0" class="entry editablecontent cke_editable cke_editable_inline cke_contents_ltr cke_show_borders cke_focus" id="content" contenteditable="true">
<!--{cke_protected}{C}%3C!%2D%2D%20Home%20page%20heading%20%2D%2D%3E--><h2>Freight</h2>
<!--{cke_protected}{C}%3C!%2D%2D%20Para%20%2D%2D%3E-->
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.<br></p><p><span></span>
<img class="cke_iframe" data-cke-realelement="%3Ciframe%20src%3D%22%2F%2Fwww.youtube.com%2Fembed%2F3i_bsfwPE1s%22%20allowfullscreen%3D%22%22%20frameborder%3D%220%22%20height%3D%22360%22%20width%3D%22640%22%3E%3C%2Fiframe%3E" data-cke-real-node-type="1" alt="IFrame" title="IFrame" src="http://pcbca-new.dev/ckeditor/plugins/fakeobjects/images/spacer.gif?t=D7UD" data-cke-real-element-type="iframe" data-cke-resizable="true" style="width:640px;height:360px;" align="">
<br></p><br></div>
In order for it to convert to a real iFrame html, I would need to use
CKEDITOR.instances.content.getData();
Which contains the real converted iFrame code:
<!-- Home page heading -->
<h2>Freight</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<p><iframe allowfullscreen="" frameborder="0" height="360" src="//www.youtube.com/embed/3i_bsfwPE1s" width="640"></iframe><span> </span><span> </span></p>
but the problem is, it strips out all my divs that contain the contenteditable='true' so the next round the page is loaded for editing, none of the sections are editable anymore.
Sooooo.... I want to be able to maintain all the code as is ($('#saveableContent').html();) but at the same time have the iFrame image converted to a real iFrame (CKEDITOR.instances.content.getData();).
I thought maybe I can disable the automatic cleaning of the code by CKEditor so I tried
config.allowedContent = true;
But that didn't work.
What can I do to ensure that all iFrame images on the page are converted to the real iFrame code while at the same time the div's are maintained with all it's attributes?

While CKEditor protects iframes, scripts videos and stuff while running, I see several solutions of your problem, depending on your needs:
The "right way": Don't save the contents of #saveableContent as a whole but iterate over CKEDITOR.instances and collect editor.getData(). Then, when rendering the page de-serialize that HTML (quite likely an array of editor contents) back into editors in #saveableContent (editor.setData( html )). This way #saveableContent is never stored in database and you gain control over your HTML: you can discard/modify/alter contents of a particular editor if you need.
The "somewhat right way": Iterate over CKEDITOR.instances and collect editor.getData(). Concatenate it with a string '<div id="saveableContent">' + ... + '</div>'. Note that your data is not structured any longer.
The "nasty way": Iterate over CKEDITOR.instances and call editor.destroy() before saving the contents of #saveableContent. Note that it may be no solution for you if you want to keep editors alive (i.e. "auto-save").

Related

Put Facebook like XFBML button in line with Pinterest button

I know similar questions have been aske before but I'm new at this and can't make sense of it. I'm fairly sure its a straightforward task but I can't do it.
I'm using a CMS on which I cannot access the css template currently.
All I want is to add a Pinterest button and facebook like button to my individual product pages using the html source code editor in a nice neat row. At the moment they display one below the other.
These are the codes:
<a data-pin-config="above" href="//pinterest.com/pin/create/button/" data-pin-do="buttonBookmark">
<img src="//assets.pinterest.com/images/pidgets/pin_it_button.png" />
</a>
<fb:like send="true" layout="button_count" width="100" show_faces="false"></fb:like>
How to write the correct styling code to achieve this?

Facebook buttons not expanding container div

I am having a problem getting a div containing facebook like/send buttons to expand when the buttons are clicked. I have searched and tried and tried to fix this, but I'm hitting a wall. I believe it has something to do with how the buttons render an iframe, but I'm not sure.
Here's the code, plain and simple (with an example link for og data).
<div id="fb_btns">
<fb:like href="http://www.imdb.com/title/tt0117500/" data-send="true" layout="button_count" width="450" show_faces="false" ></fb:like>
</div>
and the non-expanding div can be seen here
http://spadeballink.com/GALLOWS/TheGoddamnGallows.html
Any help counts! Thanks in advance!
*Also there is no css declaring the height of this div, the only heights declared are for html and body to be 100% (needed for the background image).
Are you using XFBML or Iframe version of like button? For Iframe version you need to use layout=standard for people to be able to see fly-out comment box.

Facebook login button with html elements

About a year ago on our page we included a fb:login-button that instead of simple text for buttons text it had a html element inside.
<fb:login-button onlogin="document.getElementById('buttonid').click();">
<span onclick="some_function();">Login with Facebook</span>
</fb:login-button>
The span element is required becouse there is an implementation that handles different clicks (if ctrl is held for example).
This has been working until around 5th June. I have tried to find any information on recent changes but had no luck.
Does anyone know if there is still a way to have html elements inside a fb:login-button tag?

How to include iframe coding in joomla

How to include iframe coding in joomla
Joomla has TinyMCE as default Editor. It don't allow iframe tag.
You can enable iframe tag in Editor.
Go to > Extensions > Plugins > TinyMCE
Paste iframe[src|style|width|height|scrolling|marginwidth|marginheight|frameborder]
in Extended Valid Elements
Now go back to your editor, open html view and paste your iframe code. It will save it.
Edit HTML in the editor and add the <iframe> tag there.
I needed to paste an image in a frame, so after i understood that i can't use frames i paste this code, cause i needed scroller.
<p style="overflow:scroll;width:700px;"><img style="border: 1px solid #000000;" src="/images/img.png" alt="img"></p>
If you need to paste a video from youtube it is better to hide the video under a image (screensho for example) giving the link to video. not iframe nor embed doesn't work in joomla.
hope that help)

facebook like box stream height

How to control the facebook like box stream part height alone. Its normal to reduce height of whole box but if tries to control it fans images are not shown.
The css .fan_box .page_stream{ ...,width:300px} to .fan_box .page_stream{...,width:150px}
i'm asking because the stream box inside iframe
There isn't a way to change the height. Facebook doesn't provide a way to change the height and there isn't a way to change the height using JavaScript and CSS.
Why can't I do it with JavaScript and CSS?
CSS just doesn't apply through an iFrame because thats how an iFrame works -- its basically a window to another page with its own CSS.
Javascript won't allow you to access the content of an iFrame if the URL of the iFrame is different than the page that contains the iFrame. Doing:
document.getElementById('iframeID').contentWindow.document
Will give you the following warning in Chrome.
Unsafe JavaScript attempt to access frame with URL... Domains, protocols and ports must match.
The reason for this is to prevent XSS. Here's more on the Same Origin Policy.
I saw this on the Like Box page and figured I'd respond that you can use the 'data-height' attribute:
data-height="250"
Worked for me. Here's my example:
http://www.skonet.com/Resources/Articles/Index.aspx
you can reduce the height of the encasing div, hide its overflow and if you want push the top of it underneath an absolutely positioned element with a higher z-index like so:
<div style="position:absolute;z-index:2;top:0;left:0;width:300px;height:130px;background-color:#c0c;opacity:0.5;filter:alpha(opacity=50);-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";"></div>
<div style="height:140px;width:140px;overflow:hidden;background-color:#0c0; margin-top: 60px;color: #fff;padding: 30px;font-family:arial;">
facebook like box goes here - only the green part will be visible if you make the pink box white and take out the 0.5 opacity and the bottom will get cut off so you can just display whatever part you want
</div>
I suppose you guys still need it and this is the most acurate trick I can provide and its also promising to work with the every day changing of the facebook like box by facebook.
Its a bit tricky but will work for you guys..
create two seprate like box of the same page, and close them in seprate div right in my case
<div class="up1">
facbook like box 1 code
<div class="up2">
facbook like box 2 code
Now in the css
use position absolute to class up1
.up1 {
position:absolute;
z-index:99999;
background-color:white;
}
and in up2
.up2 {
padding-top:87px;
}
What it does it will put the box 1 over the box 2 hiding its facebook like and bla bla making it feel like you have one box that contain picture and streaming of your desired lenght
I was looking around cos I had a problem like this one. Facebook has no standard way of customizing the stream if the faces and header are checked.
The solution is to take them differently. If you need the stream as long as 1000px, just uncheck everything except the stream. This will change its height from the default 300px to whatever value you type in the height field.
See an example below:
<div class="fb-like-box" data-href="https://www.facebook.com/MadeinHeavenEvents" data-width="800" data-height="2000" data-colorscheme="light" data-show-faces="false" data-header="false" data-stream="true" data-show-border="true"></div>
Then if you still need the one with faces, get a new code and set the height differently, then uncheck the others. Below is an example:
<div class="fb-like-box" data-href="https://www.facebook.com/MadeinHeavenEvents" data-width="800" data-height="500" data-colorscheme="light" data-show-faces="true" data-header="true" data-stream="false" data-show-border="true"></div>
Don't forget to add the SDK before these codes.
I know it's a long time since this was posted, but here is the solution that helped me today
Yes the data-height to 250 will work as it reduce the outside iframe
Now try to set data-height to 1000 - it is still 300px height,
because the inner div inside the iframe hard coded to 300px and
you can not control that as it is in a cross domain iframe...
<div class="fb-like-box" data-href="http://www.facebook.com/example" data-width="292" data-height="250" data-show-faces="true" data-stream="false" data-header="false"></div>
Adjust the height in this code to what works best for you.