Skip to content
Permalink
Browse files

Rich-text editor for textbox's <textarea>

... using NicEdit
  • Loading branch information
vpithart authored and LarsMichelsen committed Oct 9, 2019
1 parent 9148b76 commit b91ab57ccf8f61b81c08d3735933ff42438c9efb
@@ -5,6 +5,9 @@ Core:
* Add new map global option "ignore_linked_maps_summary_state" (issue #223)
* FIX: Worldmap max_zoom is now 20 (issue #228)

Frontend:
* Textboxes can now be edited using a simple WYSIWIG editor (issue #216)

1.9.17
Core:
* FIX: Fix PHP 5.3 incompatibility introduced with 1.9.16

Large diffs are not rendered by default.

@@ -155,7 +155,8 @@ function getFormParams(formId, skipHelperFields) {
return data;

// Get relevant input elements
var aFields = oForm.getElementsByTagName('input');
var aFields = Array.from(oForm.getElementsByTagName('input'))
aFields = Array.prototype.concat(aFields, Array.from(oForm.getElementsByTagName('textarea')));
for (var i = 0, len = aFields.length; i < len; i++) {
// Filter helper fields (if told to do so)
if (skipHelperFields && aFields[i].name.charAt(0) === '_')
@@ -173,6 +174,7 @@ function getFormParams(formId, skipHelperFields) {

if (aFields[i].type == "hidden"
|| aFields[i].type == "text"
|| aFields[i].type == "textarea"
|| aFields[i].type == "password"
|| aFields[i].type == "submit") {
add_data(aFields[i].name, aFields[i].value);
@@ -117,17 +117,16 @@ function clearFormValue(id) {
}

function showFrontendDialog(sUrl, sTitle, sWidth) {
if (typeof sWidth === 'undefined' || sWidth === null)
sWidth = 450;

call_ajax(sUrl, {
response_handler: function(response, data) {
if (isset(response)) {
// Store url for maybe later refresh
response.url = sUrl;

if(typeof response !== 'undefined' && typeof response.code !== 'undefined') {
popupWindow(data.title, response, data.width);
let width = data.sWidth || 450;
if (response.object_type === 'textbox') width = 800
popupWindow(data.title, response, width);
}
}
},
@@ -432,7 +431,7 @@ function set_zoom(val) {

function zoom(how) {
var cur_zoom = getZoomFactor();
// This is not really correct. Assume
// This is not really correct. Assume
if (cur_zoom == 'fill')
cur_zoom = 100;
var new_zoom = 100;
@@ -130,7 +130,10 @@ public function handleAction() {
break;
case 'addModify':
$VIEW = new ViewMapAddModify();
$sReturn = json_encode(Array('code' => $VIEW->parse()));
$sReturn = json_encode(Array(
'code' => $VIEW->parse(),
'object_type' => $VIEW->object_type()
));
break;
case 'manageTmpl':
$VIEW = new ViewMapManageTmpl();
@@ -624,5 +624,10 @@ public function parse() {

return ob_get_clean();
}

public function object_type()
{
return $this->object_type;
}
}
?>
@@ -25,7 +25,7 @@
/**
* @author Lars Michelsen <lm@larsmichelsen.com>
*/
define('MATCH_ALL', '/^.*$/i');
define('MATCH_ALL', '/^.*$/mi');
define('MATCH_NOT_EMPTY', '/^.+$/');
define('MATCH_REGEX', '/^.*$/i');

@@ -271,7 +271,21 @@ function textarea($name, $default = '', $class = '', $style = '') {
if (submitted($form_name))
$default = post($name, $default);

echo '<textarea name="'.$name.'"'.$class.$style.'>'.escape_html($default).'</textarea>'.N;
// plain <textarea>
echo '<textarea id="textarea_'.$name.'" name="'.$name.'"'.$class.$style.'>'.escape_html($default).'</textarea>'.N;

// better <textarea>
echo '
<script>
let script = document.createElement("script");
script.src = "js/ExtNicEdit.js"
document.head.append(script);
script.onload = function() {
new nicEditor({fullPanel : true}).panelInstance("textarea_'.$name.'")
};
</script>
';

}

function select($name, $options, $default = '', $onchange = '', $style = '', $size = null) {
@@ -404,8 +404,6 @@ div#popupWindow h1 {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
max-width: 167px;
width: 165px;
}
#popupWindowContent input[type="radio"] {
vertical-align: middle;
@@ -416,10 +414,10 @@ div#popupWindow h1 {
#popupWindowContent table.mytable tr td.tdfield input,
#popupWindowContent table.mytable tr td.tdfield textarea,
#popupWindowContent table.mytable tr td.tdfield select {
width: 163px;
width: 99%;
}
#popupWindowContent table.mytable tr td.tdfield textarea {
height: 150px;
height: 250px;
}
#popupWindowContent table.mytable tr td.tdfield input[type="checkbox"] {
width: auto;

0 comments on commit b91ab57

Please sign in to comment.
You can’t perform that action at this time.