Hello,
I want to add a checkbox in the Link box, when the writer precises an URL (so with the "protocol" list and "url" textbox). What would do the checkbox is simple: add the following attributes to the link:
class: "highslide" onclick="return hs.expand(this)"
So that I could give a highslide effect.
I followed this answer on StackOverFlow that was pretty helpful, so I did the same changes. I click to the Link Button, I add a Link and check my checkbox, I go into Source to check if the attributes are there: yes they are. Then, I go back in normal mode :
- if I click on "Source" again, some of my attributes have been removed;
- if I click on "Link" again, the box isn't checked;
I don't really know what to do at this point. Could somebody help me?
Maybe the StackOverflow reference is too old (one year) and there is a better example to follow?
Here are my changes:
In file plugins/link/dialogs/link.js (the only one modified) : http://pastebin.com/5wELVBAq for colors
around line 153: when loading target:
if ( element ) {
/* HIGHSLIDE */
var h = element.getAttribute( 'h' );
retval.button = h;
var target = element.getAttribute( 'target' );
I used a "h" attribute, because I already add 2 attributes, and would like to check only 1 unique element.
around line 461: just before the definition of the browse button:
{/* HIGHSLIDE */
type: 'checkbox',
id: 'highslide',
label: 'Effet highslide pour zoomer sur l\'image ?',
setup: function(data){
this.allowOnChange = false ;
if(data.button){
this.setValue(data.button);
}
this.allowOnChange = true;
},
commit: function(data){
data.button = this.getValue()
this.allowOnChange = false;
}
},
// block for that you could find using Ctrl+F on: id: 'browse',
around line 1096: inside onOk function:
this.commitContent( data );
/* HIGHSLIDE */
if(data.button){
attributes["h"] = "true";
attributes["class"] = 'highslide';
attributes["onClick"] = 'hs.expand(this)';
}else{
attributes["h"] = '';
attributes["class"] = '';
attributes["onClick"] = '';
}
The important attributes are class and onClick. I use h because I though this would help me get around that problem by checking only 1 attribute instead of the 2 others. Looks like I'm wrong on this one.