浏览代码

N.480 Page broken (missing menu + ...) when bulk modifying Document Notes (having various values)

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@4486 a333f486-631f-4898-b8df-5754b55c2be0
romainq 8 年之前
父节点
当前提交
68e100c743
共有 1 个文件被更改,包括 22 次插入6 次删除
  1. 22 6
      application/ui.htmleditorwidget.class.inc.php

+ 22 - 6
application/ui.htmleditorwidget.class.inc.php

@@ -1,5 +1,5 @@
 <?php
-// Copyright (C) 2010-2015 Combodo SARL
+// Copyright (C) 2010-2016 Combodo SARL
 //
 //   This file is part of iTop.
 //
@@ -20,9 +20,8 @@
  * Class UIHTMLEditorWidget
  * UI wdiget for displaying and editing one-way encrypted passwords
  *
- * @author      Phil Eddies
  * @author      Romain Quetiez
- * @copyright   Copyright (C) 2010-2015 Combodo SARL
+ * @copyright   Copyright (C) 2010-2016 Combodo SARL
  * @license     http://opensource.org/licenses/AGPL-3.0
  */
 
@@ -99,9 +98,26 @@ class UIHTMLEditorWidget
 
 		// Could also be bound to 'instanceReady.ckeditor'
 		$oPage->add_ready_script("$('#$iId').bind('validate', function(evt, sFormId) { return ValidateCKEditField('$iId', '', {$this->m_sMandatory}, sFormId, '') } );\n");
-		$oPage->add_ready_script("$('#$iId').bind('update', function() { BlockField('cke_$iId', $('#$iId').attr('disabled')); $(this).data('ckeditorInstance').setReadOnly($(this).prop('disabled')); } );\n");
-
+		$oPage->add_ready_script(
+				<<<EOF
+$('#$iId').bind('update', function(evt){
+	BlockField('cke_$iId', $('#$iId').attr('disabled'));
+	//Delayed execution - ckeditor must be properly initialized before setting readonly
+	var retryCount = 0;
+	var oMe = $('#$iId');
+	var delayedSetReadOnly = function () {
+		if (oMe.data('ckeditorInstance').editable() == undefined && retryCount++ < 10) {
+			setTimeout(delayedSetReadOnly, retryCount * 100); //Wait a while longer each iteration
+		}
+		else
+		{
+			oMe.data('ckeditorInstance').setReadOnly(oMe.prop('disabled'));
+		}
+	};
+	setTimeout(delayedSetReadOnly, 50);
+});
+EOF
+		);
 		return $sHtmlValue;
 	}
 }
-?>