function insertAtCursor(myField, myValue) { if (document.selection) { // IE support myField.focus(); sel = document.selection.createRange(); sel.text = myValue; } else if (myField.selectionStart || myField.selectionStart == '0') { // MOZILLA/NETSCAPE support var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length); } else { myField.value += myValue; } } "; return $txt; } /** * No WYSIWYG Editor - copy editor content to form field * * @param string The name of the editor */ function onSave( $editor ) { return; } /** * No WYSIWYG Editor - get the editor content * * @param string The name of the editor */ function onGetContent( $editor ) { return "document.getElementById( '$editor' ).value;\n"; } /** * No WYSIWYG Editor - set the editor content * * @param string The name of the editor */ function onSetContent( $editor, $html ) { return "document.getElementById( '$editor' ).value = $html;\n"; } /** * No WYSIWYG Editor - display the editor * * @param string The name of the editor area * @param string The content of the field * @param string The name of the form field * @param string The width of the editor area * @param string The height of the editor area * @param int The number of columns for the editor area * @param int The number of rows for the editor area */ function onDisplay( $name, $content, $width, $height, $col, $row, $buttons = true ) { // Only add "px" to width and height if they are not given as a percentage if (is_numeric( $width )) { $width .= 'px'; } if (is_numeric( $height )) { $height .= 'px'; } $buttons = $this->_displayButtons($name, $buttons); $editor = "" . $buttons; return $editor; } function onGetInsertMethod($name) { $doc = & JFactory::getDocument(); $js= "\tfunction jInsertEditorText( text, editor ) { insertAtCursor( document.getElementById(editor), text ); }"; $doc->addScriptDeclaration($js); return true; } function _displayButtons($name, $buttons) { // Load modal popup behavior JHTML::_('behavior.modal', 'a.modal-button'); $args['name'] = $name; $args['event'] = 'onGetInsertMethod'; $return = ''; $results[] = $this->update($args); foreach ($results as $result) { if (is_string($result) && trim($result)) { $return .= $result; } } if(!empty($buttons)) { $results = $this->_subject->getButtons($name, $buttons); /* * This will allow plugins to attach buttons or change the behavior on the fly using AJAX */ $return .= "\n
\n"; foreach ($results as $button) { /* * Results should be an object */ if ( $button->get('name') ) { $modal = ($button->get('modal')) ? 'class="modal-button"' : null; $href = ($button->get('link')) ? 'href="'.$button->get('link').'"' : null; $onclick = ($button->get('onclick')) ? 'onclick="'.$button->get('onclick').'"' : null; $return .= "
\n"; } } $return .= "
\n"; } return $return; } }