Browse Source

code and php tags fixed (the first with a bad display hack to show the <equal> part at the same level of the text code...

Signed-off-by: emanuele <emanuele45@gmail.com>
emanuele 13 years ago
parent
commit
4a3e9a4240

+ 6 - 1
Themes/default/css/jquery.sceditor.default.css

@@ -44,11 +44,16 @@ blockquote {
 	border: 1px solid #aaa;
 	padding: .25em;
 }
-blockquote cite {
+blockquote cite, code cite {
 	font-weight: bold;
 	display: block;
 	font-size: 1em;
 	border-bottom: 1px solid #aaa;
 }
+code cite {
+	position: relative;
+	top: -1.6em;
+	padding-left: 3em;
+}
 div { min-height: 1em; /*height:auto !important; height: 1em;*/ }
 h1, h2, h3, h4, h5, h6 { padding: 0; margin: 0; }

+ 43 - 5
Themes/default/scripts/jquery.sceditor.bbcode.js

@@ -1008,11 +1008,11 @@
 				}
 				else
 				{
-					if ($(element).attr('author') != 'undefined');
+					if ($(element).attr('author') != undefined);
 						author = ' author=' + $(element).attr('author').php_unhtmlspecialchars();
-					if ($(element).attr('date') != 'undefined');
+					if ($(element).attr('date') != undefined);
 						date = ' date=' + $(element).attr('date');
-					if ($(element).attr('link') != 'undefined');
+					if ($(element).attr('link') != undefined);
 						link = ' link=' + $(element).attr('link');
 				}
 
@@ -1066,8 +1066,46 @@
 				code: null
 			},
 			isBlock: true,
-			format: "[code]{0}[/code]",
-			html: '<code>{0}</code>'
+			format: function(element, content) {
+				if ($(element[0]).hasClass('php'))
+					return '[php]' + content + '[/php]';
+
+				var from = '';
+				if ($(element).children("cite:first").length === 1)
+				{
+					from = $(element).children("cite:first").text();
+
+					$(element).attr({'from': from.php_htmlspecialchars()});
+
+					from = '=' + from;
+					content = '';
+					$(element).children("cite:first").remove();
+					content = this.elementToBbcode($(element));
+				}
+				else
+				{
+					if ($(element).attr('from') != undefined)
+					{
+						alert($(element).attr('from'));
+						alert($(element).attr('from').php_unhtmlspecialchars());
+						from = '=' + $(element).attr('from').php_unhtmlspecialchars();
+					}
+				}
+
+				return '[code' + from + ']' + content + '[/code]';
+			},
+			html:  function(element, attrs, content) {
+				var from = '';
+				if(typeof attrs.defaultAttr !== "undefined")
+					from = '<cite>' + attrs.defaultAttr + '</cite>';
+				
+				return '<code>' + from + content + '</code>'
+			}
+		},
+		php: {
+			isBlock: true,
+			format: "[php]{0}[/php]",
+			html: '<code class="php">{0}</code>'
 		},
 		// END_COMMAND