Index: branches/5.3.x/core/admin_templates/js/forms.js =================================================================== --- branches/5.3.x/core/admin_templates/js/forms.js (revision 16594) +++ branches/5.3.x/core/admin_templates/js/forms.js (revision 16595) @@ -1,439 +1,451 @@ var last_shown_error = false; var errors = {}; var first_error = {}; var fields = {}; function show_form_error(prefix, field, sticky) { if ( isset(errors[prefix]) && isset(errors[prefix][field]) ) { span = document.getElementById('error_msg_' + prefix); span.innerHTML = fields[prefix][field] + ' - ' + errors[prefix][field]; if ( sticky ) { last_shown_error = field; } } } function hide_form_error(prefix) { span = document.getElementById('error_msg_' + prefix); if ( !span ) { return; } span.innerHTML = '
'; if ( typeof(last_shown_error) != 'undefined' && last_shown_error ) { show_form_error(prefix, last_shown_error); } } function add_form_error(prefix, field, element, error_msg, block_name) { if ( error_msg == '' ) { // no error message - do nothing return; } if ( typeof(errors[prefix]) == 'undefined' ) { errors[prefix] = {}; } errors[prefix][field] = error_msg; var $input_fields = $('#' + jq(element)); switch (block_name) { case 'inp_edit_timezone': $input_fields = $input_fields.add('#timezone_group'); break; case 'cf:datetime': case 'inp_edit_date_time': $input_fields = $input_fields.add('#' + jq(element.replace(field, field + '_date'))); $input_fields = $input_fields.add('#' + jq(element.replace(field, field + '_time'))); break; case 'inp_edit_combo_target': $input_fields = $input_fields.add('#' + jq(element.replace(field, field + 'Type'))); break; case 'cf:multiselect': case 'inp_edit_multioptions': $input_fields = $('#' + jq(element) + '_select'); break; case 'cf:checkbox': case 'inp_edit_checkbox': $input_fields = $('#_cb_' + jq(element)); break; case 'cf:radio': case 'inp_edit_radio': case 'inp_edit_checkboxes': $input_fields = $("input[id^='" + jq(element) + "_']"); break; case 'inp_edit_weight': $input_fields = $input_fields.add('#' + jq(element.replace(field, field + '_a'))); $input_fields = $input_fields.add('#' + jq(element.replace(field, field + '_b'))); break; case 'inp_edit_picker': $input_fields = $('#' + jq(element) + '_selected'); break; case 'inp_edit_cron_box': $input_fields = $input_fields.add('#' + jq(element.replace(field, field + 'Hints'))); break; } if ( $input_fields.length > 0 ) { // some controls don't have element to focus on (e.g. swf uploader) $input_fields.focus(function ($e) { show_form_error(prefix, field, true); }); $input_fields.blur(function ($e) { last_shown_error = false; }); } /*else { console.log('error: focusing failed for [', prefix, '.', field, '] = ', element); }*/ if ( typeof(first_error[prefix]) == 'undefined' || first_error[prefix] == false ) { first_error[prefix] = [field, element]; } } function FCKeditor_OnComplete( editor ) { Form.Resize(); } function InitEditors() { if ( !$.isEmptyObject($CKEditors) ) { // process all CKEditor instances CKEDITOR.on( 'instanceReady', function( ev ) { FCKeditor_OnComplete( CKEDITOR.instances[ ev.editor.name ] ); } ); ckeditors_apply_typekit(); for (var $editor_id in $CKEditors) { CKEDITOR.replace($editor_id, $CKEditors[$editor_id]); } } // process all CodePress instances if ($.isFunction(window.CodePress)) { CodePress.run(/*FCKeditor_OnComplete*/); } if ( !$.isEmptyObject($CodeMirrorEditors) ) { - var $editor; - - for (var $editor_id in $CodeMirrorEditors) { - var $textarea_element = $('#' + jq($editor_id)), + $.each($CodeMirrorEditors, function ($editor_id, $editor_options) { + var $editor, + $textarea_element = $('#' + jq($editor_id)), $height = parseInt($textarea_element.height(), 10); - $editor = CodeMirror.fromTextArea($textarea_element.get(0), $CodeMirrorEditors[$editor_id]); + if ( $textarea_element.is(':disabled') ) { + $editor_options.readOnly = 'nocursor'; + } + + $editor = CodeMirror.fromTextArea($textarea_element.get(0), $editor_options); $editor.setSize(null, $height); - } + + $textarea_element + .on('change', function ($e) { + $editor.getDoc().setValue($textarea_element.val()); + }) + .on('refresh', function ($e) { + $editor.setOption('readOnly', $textarea_element.is(':disabled') ? 'nocursor' : ''); + }) + ; + }); } } function Form() {} Form = new Form(); Form.Controls = new Array(); Form.Div = false; Form.MinControlsHeight = 0; Form.Options = new Object(); Form.FlexibleCount = 0; Form.ScrollerW = 17; Form.ScrollerH = 17; Form.HasChanged = false; Form.Init = function(id) { this.Div = document.getElementById(id); if (!this.Div) { return ; } for (var i = 0; i < this.Controls.length; i++) { dim = getDimensions( document.getElementById(this.Controls[i]) ); options = this.Options[this.Controls[i]]; if (options.height) { // fixed height options.min_height = options.height; options.max_height = options.height; } if (!options.min_height) { options.min_height = $( jq('#' + this.Controls[i]) ).outerHeight(); // dim.innerHeight } // if ( $( jq('#' + this.Controls[i]) ).parents('tr:first').is(':visible') ) { this.MinControlsHeight += options.min_height; // } if (dim.innerHeight < options.min_height) { document.getElementById(this.Controls[i]).style.height = options.min_height+'px'; } // alert('adding element '+this.Controls[i]+' height: '+options.min_height+' total: '+this.MinControlsHeight) } // all - \ No newline at end of file + Index: branches/5.3.x/core/admin_templates/forms/form_edit_emails.tpl =================================================================== --- branches/5.3.x/core/admin_templates/forms/form_edit_emails.tpl (revision 16594) +++ branches/5.3.x/core/admin_templates/forms/form_edit_emails.tpl (revision 16595) @@ -1,108 +1,109 @@
- \ No newline at end of file +