From 8748bc65094dff9848bccbfb3d2b66a44b39d7c3 Mon Sep 17 00:00:00 2001 From: Victor Saisa Lopez Date: Tue, 23 Jul 2013 15:45:41 -0400 Subject: [PATCH] BUG 10870 "A better trigger editor is needed" SOLVED MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Problema con la identacion cuando se ingresa texto en el editor de triggers - Problema resuelto, se ha aƱdo codigo para la identacion, esto para los triggers (PHP) * Available from version ProcessMaker-2.5.2-testing.1 --- gulliver/js/codemirror/mode/php/php.js | 32 +++++++++++++++++++++----- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/gulliver/js/codemirror/mode/php/php.js b/gulliver/js/codemirror/mode/php/php.js index d6ef81a19..acc0053d2 100644 --- a/gulliver/js/codemirror/mode/php/php.js +++ b/gulliver/js/codemirror/mode/php/php.js @@ -11,7 +11,7 @@ return "string"; }; } - + var PM_keywords = function(){ function PMkey() {return {style: "PMbuiltin"};} var PMfunctions = { @@ -32,7 +32,7 @@ "PMFGetCaseNotes":PMkey()}; return PMfunctions; }(); - + var php_keywords = function(){ function phpbuild() {return {style: "builtin"};} function phpatom() {return {style: "atom"};} @@ -171,8 +171,8 @@ "__FUNCTION__":phpatom(),"__NAMESPACE__":phpatom()}; return Phpfunctions; }(); - - + + var phpConfig = { name: "clike", keywords: keywords("abstract and array as break case catch class clone const continue declare default " + @@ -221,7 +221,7 @@ function dispatch(stream, state) { var isPHP = state.curMode == phpMode; if (stream.sol() && state.pending != '"') state.pending = null; - + if (!isPHP) { if (stream.match(/^<\?\w*/)) { state.curMode = phpMode; @@ -300,7 +300,27 @@ if ((state.curMode != phpMode && /^\s*<\//.test(textAfter)) || (state.curMode == phpMode && /^\?>/.test(textAfter))) return htmlMode.indent(state.html, textAfter); - return state.curMode.indent(state.curState, textAfter); + + var firstChar = textAfter && textAfter.charAt(0); + var lastChar = textAfter && textAfter != "" && textAfter.charAt(textAfter.length - 1); + + if (state.curState.context.type == "statement") { + if (state.curState.context.prev.type == "}") { //{ + return state.curState.context.indented; + } else { + if (firstChar == "}") { + if (lastChar == "{") { + return state.curState.context.indented - config.indentUnit; + } else { + return state.curState.context.indented - state.curState.context.prev.indented; + } + } else { + return state.curState.context.prev.indented; + } + } + } else { + return state.curMode.indent(state.curState, textAfter); + } }, electricChars: "/{}:",