1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
| $.fn.editor = function(url, options)
{
// Options
options = arrayMerge(
{
"url" : url,
},options);
// init
this.each(function()
{
init($(this));
});
function init(me)
{
myId = me.attr('id');
myWidth = me.width();
myHeight = me.height();
html_link = '<div class="K_editor_link"><a id="K_editor_linkBold_'+myId+'">Gras</a>|<a id="K_editor_linkItalic_'+myId+'">Italique</a>|<a id="K_editor_linkUnderline_'+myId+'">Souligne</a></div>';
html_area = '<div name="'+me.text()+'" class="K_editor_area"><textarea id="K_editor_textarea_'+myId+'" name="'+myId+'">'+me.text()+'</textarea></div>';
html = html_link+html_area;
me.append(html);
myLink = me.children('.K_editor_link');
myTextarea = me.children('.K_editor_area').children('textarea');
$('#K_editor_linkBold_'+myId).click(function()
{
insertTag('<bold>','</bold>','K_editor_textarea_'+myId);
});
$('#K_editor_linkItalic_'+myId).click(function()
{
insertTag('<italic>','</italic>','K_editor_textarea_'+myId);
});
$('#K_editor_linkUnderline_'+myId).click(function()
{
insertTag('<underline>','</underline>','K_editor_textarea_'+myId);
});
}
// function
function insertTag(startTag, endTag, textareaId, tagType)
{
var field = document.getElementById(textareaId);
/* Ajoutes les balises autour du texte sélectionné dans field */
}
function arrayMerge(a, b)
{
/* fonction arrayMerge */
};
}; |
Partager