stripLoadedTextTags: false,
submitOnBlur: false,
width: null,
+ autoWidth: false,
/** Default Callbacks **/
callback: function(form)
fld.value = text; // No HTML breaks conversion anymore
fld.className = 'editor_field';
if (this.options.width) {
- fld.setStyle({ width: this.options.width + 'px' });
+ var w = this.options.width + 'px';
+ } else if (this.options.autoWidth) {
+ var w = this.element.up().getWidth() + 'px';
}
+ fld.setStyle({ width: w });
if (this.options.submitOnBlur) {
fld.observe('blur', this._boundSubmitHandler);
}
--- /dev/null
+<?php
+/**
+ * Mnemo_Ajax_Imple_EditNote:: class for performing Ajax note editing.
+ *
+ * Copyright 2008-2010 The Horde Project (http://www.horde.org/)
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @package Mnemo
+ */
+class Mnemo_Ajax_Imple_EditNote extends Horde_Core_Ajax_Imple
+{
+ public function __construct($params)
+ {
+ /* Set up some defaults */
+ if (empty($params['rows'])) {
+ $params['rows'] = 2;
+ }
+ if (empty($params['cols'])) {
+ $params['cols'] = 20;
+ }
+ parent::__construct($params);
+ }
+
+ public function attach()
+ {
+ Horde::addScriptFile('effects.js', 'horde');
+ Horde::addScriptFile('inplaceeditor.js', 'horde');
+
+ $params = array('input' => 'value',
+ 'id' => $this->_params['id']);
+
+ $url = $this->_getUrl('EditNote', 'mnemo', $params);
+ $loadTextUrl = $this->_getUrl('EditNote', 'mnemo', array_merge($params, array('action' => 'load')));
+ $js = array();
+
+ $js[] = "new InPlaceEditor('" . $this->_params['domid'] . "', '" . $url . "', {"
+ . " callback: function(form, value) {"
+ . " return 'value=' + encodeURIComponent(value);},"
+ . " loadTextURL: '". $loadTextUrl . "',"
+ . " rows: 4, "
+ . " autoWidth: true,"
+ . " emptyText: '" . _("Click to add text...") . "',"
+ . " onComplete: function(ipe, opts) { ipe.checkEmpty() },"
+ . " cancelText: '" . _("Cancel") . "',"
+ . " okText: '" . _("Ok") . "',"
+ . " cancelClassName: ''"
+ . " });";
+
+ Horde::addInlineScript($js, 'dom');
+ }
+
+ public function handle($args, $post)
+ {
+ if ($GLOBALS['registry']->getAuth()) {
+ /* Are we requesting the unformatted text? */
+ if (!empty($args['action']) && $args['action'] == 'load') {
+ $id = $args['id'];
+ $storage = Mnemo_Driver::singleton();
+ $memo = $storage->getByUID($id);
+ return $memo['body'];
+ }
+ if (empty($args['input']) ||
+ is_null($pref_value = Horde_Util::getPost($args['input'], null)) ||
+ empty($args['id'])) {
+
+ return '';
+ }
+
+ $storage = Mnemo_Driver::singleton();
+ $memo = $storage->getByUID($args['id']);
+ $share = $GLOBALS['mnemo_shares']->getShare($memo['memolist_id']);
+ if (!$share->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
+ throw new Horde_Exception_PermissionDenied(_("You do not have permission to edit this note."));
+ }
+
+ $storage->modify($memo['memo_id'], $memo['desc'], $pref_value);
+ return $GLOBALS['injector']->getInstance('Horde_Text_Filter')->filter(
+ $pref_value,
+ 'text2html',
+ array('parselevel' => Horde_Text_Filter_Text2html::MICRO));
+ }
+ }
+
+}
protected function _content()
{
$memo = $this->_getNote();
- $html = '<div class="noteBody">';
+ $html = '<div id="noteBody' . $memo['memo_id'] . '" class="noteBody">';
$body = $GLOBALS['injector']->getInstance('Horde_Text_Filter')->filter($memo['body'], 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO));
try {
$body = Horde::callHook('format_description', array($body), 'mnemo', $body);
} catch (Horde_Exception_HookNotSet $e) {}
$html .= $body . '</div>';
-
+ $GLOBALS['injector']->getInstance('Horde_Ajax_Imple')->getImple(array('mnemo', 'EditNote'), array(
+ 'domid' => "noteBody" . $memo['memo_id'],
+ 'id' => $this->_params['note_uid']
+ ));
return $html;
}