Commit 6f8b9452 authored by Liuba Kazakov's avatar Liuba Kazakov Committed by Hugh Davenport
Browse files

Responsive Design: Do not display tinyMCE for mobile



devices as it doesn't work on some of them and can
disable the editing of a textarea field

Bug #1041645

Change-Id: I37fc83bfaa307a58691aa24c560b26e427720240
Signed-off-by: default avatarLiuba Kazakov <liuba@catalyst-au.net>
parent ff2da31b
......@@ -112,34 +112,39 @@ function smarty($javascript = array(), $headers = array(), $pagestrings = array(
$langdirection = get_string('thisdirection', 'langconfig');
// TinyMCE must be included first for some reason we're not sure about
$checkarray = array(&$javascript, &$headers);
$found_tinymce = false;
foreach ($checkarray as &$check) {
if (($key = array_search('tinymce', $check)) !== false || ($key = array_search('tinytinymce', $check)) !== false) {
if (!$found_tinymce) {
$found_tinymce = $check[$key];
$javascript_array[] = $jsroot . 'tinymce/tiny_mce.js';
$content_css = json_encode($THEME->get_url('style/tinymce.css'));
$language = substr(current_language(), 0, 2);
if ($language != 'en' && !file_exists(get_config('docroot') . 'js/tinymce/langs/' . $language . '.js')) {
$language = 'en';
}
$extrasetup = isset($extraconfig['tinymcesetup']) ? $extraconfig['tinymcesetup'] : '';
$adv_buttons = array(
"undo,redo,separator,bold,italic,underline,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,separator,link,unlink,separator,code,fullscreen",
"bold,italic,underline,strikethrough,separator,forecolor,backcolor,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,hr,emotions,image,spellchecker,cleanup,separator,link,unlink,separator,code,fullscreen",
"undo,redo,separator,bullist,numlist,separator,tablecontrols,separator,cut,copy,paste,pasteword",
"fontselect,separator,fontsizeselect,separator,formatselect",
);
// For right-to-left langs, reverse button order & align controls right.
$tinymce_langdir = $langdirection == 'rtl' ? 'rtl' : 'ltr';
$toolbar_align = 'left';
if ($check[$key] == 'tinymce') {
$spellchecker_rpc = $jsroot.'tinymce/plugins/spellchecker/rpc.php';
$tinymce_config = <<<EOF
//
// Note: we do not display tinyMCE for mobile devices
// as it doesn't work on some of them and can
// disable the editing of a textarea field
if ($SESSION->get('mobile') == false) {
$checkarray = array(&$javascript, &$headers);
$found_tinymce = false;
foreach ($checkarray as &$check) {
if (($key = array_search('tinymce', $check)) !== false || ($key = array_search('tinytinymce', $check)) !== false) {
if (!$found_tinymce) {
$found_tinymce = $check[$key];
$javascript_array[] = $jsroot . 'tinymce/tiny_mce.js';
$content_css = json_encode($THEME->get_url('style/tinymce.css'));
$language = substr(current_language(), 0, 2);
if ($language != 'en' && !file_exists(get_config('docroot') . 'js/tinymce/langs/' . $language . '.js')) {
$language = 'en';
}
$extrasetup = isset($extraconfig['tinymcesetup']) ? $extraconfig['tinymcesetup'] : '';
$adv_buttons = array(
"undo,redo,separator,bold,italic,underline,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,separator,link,unlink,separator,code,fullscreen",
"bold,italic,underline,strikethrough,separator,forecolor,backcolor,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,hr,emotions,image,spellchecker,cleanup,separator,link,unlink,separator,code,fullscreen",
"undo,redo,separator,bullist,numlist,separator,tablecontrols,separator,cut,copy,paste,pasteword",
"fontselect,separator,fontsizeselect,separator,formatselect",
);
// For right-to-left langs, reverse button order & align controls right.
$tinymce_langdir = $langdirection == 'rtl' ? 'rtl' : 'ltr';
$toolbar_align = 'left';
if ($check[$key] == 'tinymce') {
$spellchecker_rpc = $jsroot.'tinymce/plugins/spellchecker/rpc.php';
$tinymce_config = <<<EOF
mode: "none",
theme: "advanced",
plugins: "table,emotions,spellchecker,inlinepopups,paste,fullscreen",
......@@ -152,9 +157,9 @@ function smarty($javascript = array(), $headers = array(), $pagestrings = array(
spellchecker_rpc_url : "{$spellchecker_rpc}",
//width: '512',
EOF;
}
else {
$tinymce_config = <<<EOF
}
else {
$tinymce_config = <<<EOF
mode: "textareas",
editor_selector: 'tinywysiwyg',
theme: "advanced",
......@@ -173,9 +178,9 @@ EOF;
theme_advanced_buttons3 : "{$adv_buttons[3]}"
},
EOF;
}
}
$headers[] = <<<EOF
$headers[] = <<<EOF
<script type="text/javascript">
tinyMCE.init({
button_tile_map: true,
......@@ -220,19 +225,20 @@ function custom_urlconvert (u, n, e) {
</script>
EOF;
unset($check[$key]);
}
else {
if ($check[$key] != $found_tinymce) {
log_warn('Two differently configured tinyMCE instances have been asked for on this page! This is not possible');
unset($check[$key]);
}
else {
if ($check[$key] != $found_tinymce) {
log_warn('Two differently configured tinyMCE instances have been asked for on this page! This is not possible');
}
unset($check[$key]);
}
unset($check[$key]);
}
}
// If any page adds jquery explicitly, remove it from the list
if (($key = array_search('jquery', $check)) !== false) {
unset($check[$key]);
// If any page adds jquery explicitly, remove it from the list
if (($key = array_search('jquery', $check)) !== false) {
unset($check[$key]);
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment