';
},
setup: function(appendTo) {
_spoiler.ID = 'spoiler-dialog';
// appendTo is what we attach the message HTML to
if (!appendTo) appendTo = 'body';
// Inject the message structure
delete _spoiler.effects[_spoilerL10n.default_effect];
var html = '
';
jQuery(appendTo).append(html);
jQuery('#spoiler-form').submit(function(){_spoiler.okay(); return false;});
var okay = _spoilerL10n.okay;
var cancel = _spoilerL10n.cancel;
var buttons = { okay: _spoiler.okay, cancel: _spoiler.close };
jQuery('#'+_spoiler.ID).dialog({ autoOpen: false, width: 410, minWidth: 380, height: 240, minHeight: 240, maxHeight: 240, title: _spoilerL10n.title, buttons: buttons });
// add quicktag button
jQuery("#ed_toolbar").append('');
},
popup: function(){
jQuery('#'+_spoiler.ID).dialog("open");
},
okay: function(){
var options = jQuery('#spoiler-form').formToArray();
var text='[spoiler';
for (var i=0; i < options.length; i++) {
switch(options[i].name) {
case 'spoiler-effect':
if (options[i].value != _spoilerL10n.default_effect)
text += ' effect="'+options[i].value+'"';
break;
case 'spoiler-showtext':
if (options[i].value != _spoilerL10n.showtext)
text += ' show="'+options[i].value+'"';
break;
case 'spoiler-hidetext':
if (options[i].value != _spoilerL10n.hidetext)
text += ' hide="'+options[i].value+'"';
break;
default:
continue;
break;
}
}
text += ']';
if ( typeof tinyMCE != 'undefined' && ( ed = tinyMCE.activeEditor ) && !ed.isHidden() ) {
ed.focus();
if (tinymce.isIE)
ed.selection.moveToBookmark(tinymce.EditorManager.activeEditor.windowManager.bookmark);
text += ed.selection.getRng();
text += '[/spoiler]';
ed.execCommand('mceInsertContent', false, text);
} else {
text += _spoiler.getRng(edCanvas);
text += '[/spoiler]';
edInsertContent(edCanvas, text);
}
_spoiler.close();
},
close: function(){
// jQuery('#spoiler-form').resetForm();
jQuery('#'+_spoiler.ID).dialog("close");
},
getRng: function(field) {
var r= '';
if (document.selection) {
field.focus();
sel = document.selection.createRange();
r = sel.text;
}
//MOZILLA/NETSCAPE support
else if (field.selectionStart || field.selectionStart == '0') {
var startPos = field.selectionStart;
var endPos = field.selectionEnd;
if (startPos != endPos)
r = field.value.substring(startPos, endPos);
}
return r;
}
};
jQuery(document).ready( function() {
_spoiler.setup();
})