... | in text_editor.naml |
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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
<macro name="editor_shared_scripts" parameters="textarea_id, node_id">
<script type="text/javascript">
var textareaID = "<n.textarea_id/>";
var nodeId = "<n.hide_null Binary Namespace: BasicNamespace
Parameters:
value
♦ ♦
<![CDATA[
Nabble.closeWindows = function() {
$('div.editor-dropdown').fadeOut('fast');
};
Nabble.insert = function(t) {
Nabble.insertTag(t);
Nabble.closeWindows();
};
Nabble.insertTag = function(tag) {
var textarea = Nabble.get(textareaID);
var s = this.getSelection(textarea);
if( s != "") {
this.setSelection( textarea, "<" + tag + ">" + s + "</" + tag + ">" );
} else {
this.setSelection( textarea, "<" + tag + "></" + tag + ">" );
}
textarea.focus();
};
Nabble.getSelection = function(textarea) {
if (document.selection) {
textarea.focus();
return document.selection.createRange().text;
} else if (textarea.selectionStart) {
return textarea.value.substr(textarea.selectionStart,textarea.selectionEnd-textarea.selectionStart);
} else if (textarea.selectionEnd) {
return textarea.value.substr(0,textarea.selectionEnd);
}
return '';
};
Nabble.setSelection = function(textarea,text) {
var hasStart = typeof (textarea.selectionStart) != 'undefined';
var hasEnd = typeof (textarea.selectionEnd) != 'undefined';
if (hasStart || hasEnd) {
var start = textarea.selectionStart? textarea.selectionStart : 0;
var t = textarea.value;
var s = start + text.length;
var scrollTop;
if (textarea.scrollTop)
scrollTop = textarea.scrollTop;
textarea.value = t.substr(0,start) + text + t.substr(textarea.selectionEnd);
if (typeof scrollTop != 'undefined')
textarea.scrollTop = scrollTop;
textarea.setSelectionRange(s,s);
return;
}
if( document.selection ) {
var r = document.selection.createRange();
if( r.parentElement()==textarea ) {
r.text = text;
r.select();
return;
}
}
textarea.value += text;
};
$(document).ready(function() {
var $buttons = $('td button.toolbar');
var h = $buttons.eq(0).outerHeight();
$buttons.each(function() {
$(this).height(h);
});
$(document).click(function(o){
var $btn = $(o.target).parents();
if ($btn.hasClass('has-dropdown'))
return;
Nabble.closeWindows();
});
});
]]>
</script>
</macro>
|