Browse Source

Fix list and quote tags

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

+ 45 - 46
Themes/default/css/jquery.sceditor.css

@@ -4,9 +4,8 @@
  *
  * Copyright (C) 2011, Sam Clarke (samclarke.com)
  *
- * SCEditor is dual licensed under the MIT and GPL licenses:
+ * SCEditor is licensed under the MIT license:
  *	http://www.opensource.org/licenses/mit-license.php
- *	http://www.gnu.org/licenses/gpl.html
  *
  * Icons by Mark James (http://www.famfamfam.com/lab/icons/silk/)
  * Licensed under the Creative Commons CC-BY license (http://creativecommons.org/licenses/by/3.0/)
@@ -66,7 +65,7 @@ div.sceditor-dropdown, div.sceditor-dropdown div {
 		bottom: 0;
 		right: 0;
 		z-index: 3;
-		background: url('icons/grip.png');
+		background: url('../images/bbc/icons/grip.png');
 	}
 	div.sceditor-dropdown {
 		position: absolute;
@@ -177,46 +176,46 @@ div.sceditor-dropdown, div.sceditor-dropdown div {
 			text-indent: -9999px;
 		}
 		.sceditor-button:hover { background: #eee; }
-			.sceditor-button-bold div { background: url('icons/text_bold.png'); }
-			.sceditor-button-italic div { background: url('icons/text_italic.png'); }
-			.sceditor-button-underline div { background: url('icons/text_underline.png'); }
-			.sceditor-button-strike div { background: url('icons/text_strikethrough.png'); }
-			.sceditor-button-subscript div { background: url('icons/text_subscript.png'); }
-			.sceditor-button-superscript div { background: url('icons/text_superscript.png'); }
-
-			.sceditor-button-left div { background: url('icons/text_align_left.png'); }
-			.sceditor-button-center div { background: url('icons/text_align_center.png'); }
-			.sceditor-button-right div { background: url('icons/text_align_right.png'); }
-			.sceditor-button-justify div { background: url('icons/text_align_justify.png'); }
-
-			.sceditor-button-font div { background: url('icons/font.png'); }
-			.sceditor-button-size div { background: url('icons/font_size.png'); }
-			.sceditor-button-color div { background: url('icons/color_swatch.png'); }
-			.sceditor-button-removeformat div { background: url('icons/font_delete.png'); }
-
-			.sceditor-button-cut div { background: url('icons/cut.png'); }
-			.sceditor-button-copy div { background: url('icons/page_copy.png'); }
-			.sceditor-button-paste div { background: url('icons/page_white_paste.png'); }
-			.sceditor-button-pastetext div { background: url('icons/paste_plain.png'); }
-
-			.sceditor-button-bulletlist div { background: url('icons/text_list_bullets.png'); }
-			.sceditor-button-orderedlist div { background: url('icons/text_list_numbers.png'); }
-
-			.sceditor-button-table div { background: url('icons/table_add.png'); }
-
-			.sceditor-button-horizontalrule div { background: url('icons/text_horizontalrule.png'); }
-			.sceditor-button-image div { background: url('icons/image_add.png'); }
-			.sceditor-button-code div { background: url('icons/script_code.png'); }
-			.sceditor-button-email div { background: url('icons/email_add.png'); }
-			.sceditor-button-link div { background: url('icons/link_add.png'); }
-			.sceditor-button-unlink div { background: url('icons/link_break.png'); }
-
-			.sceditor-button-quote div { background: url('icons/comment.png'); }
-
-			.sceditor-button-emoticon div { background: url('icons/emoticon_smile.png'); }
-			.sceditor-button-youtube div { background: url('icons/youtube.png'); }
-			.sceditor-button-date div { background: url('icons/date_add.png'); }
-			.sceditor-button-time div { background: url('icons/time_add.png'); }
-
-			.sceditor-button-print div { background: url('icons/printer.png'); }
-			.sceditor-button-source div { background: url('icons/page_white_text.png'); }
+			.sceditor-button-bold div { background: url('../images/bbc/icons/text_bold.png'); }
+			.sceditor-button-italic div { background: url('../images/bbc/icons/text_italic.png'); }
+			.sceditor-button-underline div { background: url('../images/bbc/icons/text_underline.png'); }
+			.sceditor-button-strike div { background: url('../images/bbc/icons/text_strikethrough.png'); }
+			.sceditor-button-subscript div { background: url('../images/bbc/icons/text_subscript.png'); }
+			.sceditor-button-superscript div { background: url('../images/bbc/icons/text_superscript.png'); }
+
+			.sceditor-button-left div { background: url('../images/bbc/icons/text_align_left.png'); }
+			.sceditor-button-center div { background: url('../images/bbc/icons/text_align_center.png'); }
+			.sceditor-button-right div { background: url('../images/bbc/icons/text_align_right.png'); }
+			.sceditor-button-justify div { background: url('../images/bbc/icons/text_align_justify.png'); }
+
+			.sceditor-button-font div { background: url('../images/bbc/icons/font.png'); }
+			.sceditor-button-size div { background: url('../images/bbc/icons/font_size.png'); }
+			.sceditor-button-color div { background: url('../images/bbc/icons/color_swatch.png'); }
+			.sceditor-button-removeformat div { background: url('../images/bbc/icons/font_delete.png'); }
+
+			.sceditor-button-cut div { background: url('../images/bbc/icons/cut.png'); }
+			.sceditor-button-copy div { background: url('../images/bbc/icons/page_copy.png'); }
+			.sceditor-button-paste div { background: url('../images/bbc/icons/page_white_paste.png'); }
+			.sceditor-button-pastetext div { background: url('../images/bbc/icons/paste_plain.png'); }
+
+			.sceditor-button-bulletlist div { background: url('../images/bbc/icons/text_list_bullets.png'); }
+			.sceditor-button-orderedlist div { background: url('../images/bbc/icons/text_list_numbers.png'); }
+
+			.sceditor-button-table div { background: url('../images/bbc/icons/table_add.png'); }
+
+			.sceditor-button-horizontalrule div { background: url('../images/bbc/icons/text_horizontalrule.png'); }
+			.sceditor-button-image div { background: url('../images/bbc/icons/image_add.png'); }
+			.sceditor-button-code div { background: url('../images/bbc/icons/script_code.png'); }
+			.sceditor-button-email div { background: url('../images/bbc/icons/email_add.png'); }
+			.sceditor-button-link div { background: url('../images/bbc/icons/link_add.png'); }
+			.sceditor-button-unlink div { background: url('../images/bbc/icons/link_break.png'); }
+
+			.sceditor-button-quote div { background: url('../images/bbc/icons/comment.png'); }
+
+			.sceditor-button-emoticon div { background: url('../images/bbc/icons/emoticon_smile.png'); }
+			.sceditor-button-youtube div { background: url('../images/bbc/icons/youtube.png'); }
+			.sceditor-button-date div { background: url('../images/bbc/icons/date_add.png'); }
+			.sceditor-button-time div { background: url('../images/bbc/icons/time_add.png'); }
+
+			.sceditor-button-print div { background: url('../images/bbc/icons/printer.png'); }
+			.sceditor-button-source div { background: url('../images/bbc/icons/page_white_text.png'); }

+ 69 - 17
Themes/default/scripts/jquery.sceditor.bbcode.js

@@ -4,9 +4,8 @@
  *
  * Copyright (C) 2011-2012, Sam Clarke (samclarke.com)
  *
- * SCEditor is dual licensed under the MIT and GPL licenses:
+ * SCEditor is licensed under the MIT license:
  *	http://www.opensource.org/licenses/mit-license.php
- *	http://www.gnu.org/licenses/gpl.html
  */
 
 // ==ClosureCompiler==
@@ -57,8 +56,7 @@
 		 * @private
 		 */
 		var validChildren = {
-			ul: ['li'],
-			ol: ['li'],
+			list: ['li'],
 			table: ['tr'],
 			tr: ['td', 'th'],
 			code: ['br', 'p', 'div'],
@@ -430,7 +428,7 @@
 		 */
 		base.getTextHandler = function(text, isPaste) {
 			var	oldText, replaceBBCodeFunc,
-				bbcodeRegex = /\[([^\[\s=]*?)(?:([^\[]*?))?\]((?:[\s\S(?!=\[\\\1)](?!\[\1))*?)\[\/(\1)\]/g,
+				bbcodeRegex = /\[([^\[\s=]*?)(?:([\s=][^\[]*?))?\]((?:[\s\S(?!=\[\\\1)](?!\[\1))*?)\[\/(\1)\]/g,
 				atribsRegex = /(\S+)=((?:(?:(["'])(?:\\\3|[^\3])*?\3))|(?:[^'"\s]+))/g;
 
 			replaceBBCodeFunc = function(str, bbcode, attrs, content)
@@ -776,15 +774,28 @@
 		// END_COMMAND
 
 		// START_COMMAND: Lists
+		list: {
+			isBlock: true,
+			html: function(element, attrs, content) {
+				var style = '';
+				var code = 'ul';
+				if (attrs.type)
+						style = ' style="list-style-type: ' + attrs.type + '"';
+
+				return '<' + code + style + '>' + content + '</' + code + '>';
+			}
+		},
 		ul: {
 			tags: {
 				ul: null
 			},
 			isBlock: true,
-			format: "[ul]{0}[/ul]",
-			html: '<ul>{0}</ul>'
-		},
-		list: {
+			format: function(element, content) {
+				if ($(element[0]).css('list-style-type') == 'disc')
+					return '[list]' + content + '[/list]';
+				else
+					return '[list type=' + $(element[0]).css('list-style-type') + ']' + content + '[/list]';
+			},
 			html: '<ul>{0}</ul>'
 		},
 		ol: {
@@ -792,7 +803,7 @@
 				ol: null
 			},
 			isBlock: true,
-			format: "[ol]{0}[/ol]",
+			format: '[list type=decimal]{0}[/list]',
 			html: '<ol>{0}</ol>'
 		},
 		li: {
@@ -948,23 +959,64 @@
 			},
 			isBlock: true,
 			format: function(element, content) {
-				var	attr = '';
+				var author = '';
+				var date = '';
+				var link = '';
+
+				if ($(element).children("cite:first").length === 1)
+				{
+					author = $(element).children("cite:first").find("author").text();
+					date = $(element).children("cite:first").find("date").attr('timestamp');
+					link = $(element).children("cite:first").find("quote_link").text();
 
-				if($(element).children("cite:first").length === 1) {
-					attr = '=' + $(element).children("cite:first").text();
+					if (author != '')
+						author = ' author=' + author;
+					if (date != '')
+						date = ' date=' + date;
+					if (link != '')
+						link = ' link=' + link;
 
 					content = '';
 					$(element).children("cite:first").remove();
 					content = this.elementToBbcode($(element));
 				}
 
-				return '[quote' + attr + ']' + content + '[/quote]';
+				return '[quote' + author + date + link + ']' + content + '[/quote]';
 			},
 			html: function(element, attrs, content) {
-				if(typeof attrs.defaultAttr !== "undefined")
-					content = '<cite>' + attrs.defaultAttr + '</cite>' + content;
+				var author = '';
+				var sDate = '';
+				var link = '';
+				if(typeof attrs.author !== "undefined")
+					author = bbc_quote_from + ': <author>' + attrs.author + '</author>';
+
+				// Links could be in the form: link=topic=71.msg201#msg201 that would fool javascript, so we need a workaround
+				for (var key in attrs)
+				{
+					if (key.substr(0, 4) == 'link' && attrs.hasOwnProperty(key))
+					{
+						var possible_url = key.length > 4 ? key.substr(5) + '=' + attrs[key] : attrs[key];
 
-				return '<blockquote>' + content + '</blockquote>';
+						link = possible_url.substr(0, 7) == 'http://' ? possible_url : smf_scripturl + '?' + possible_url;
+						author = author == '' ? '<a href="' + link + '">' + bbc_quote_from + ': <author>' + link + '</author></a>' : '<a href="' + link + '">' + author + '</a>';
+						link = '<quote_link style="display:none">' + possible_url + '</quote_link>';
+					}
+				}
+
+				if(typeof attrs.date !== "undefined")
+				{
+					var date = new Date(attrs.date * 1000);
+					sDate = date;
+				}
+
+				if (author == '' && sDate == '')
+					author = bbc_quote;
+				else
+					author += ' ';
+
+				content = '<blockquote><cite>' + author + bbc_search_on + ' ' + '<date timestamp="' + attrs.date + '">' + sDate + '</date>' + link + '</cite>' + content + '</blockquote>';
+
+				return content;
 			}
 		},
 		// END_COMMAND

+ 1 - 2
Themes/default/scripts/jquery.sceditor.js

@@ -4,9 +4,8 @@
  *
  * Copyright (C) 2011-2012, Sam Clarke (samclarke.com)
  *
- * SCEditor is dual licensed under the MIT and GPL licenses:
+ * SCEditor is licensed under the MIT license:
  *	http://www.opensource.org/licenses/mit-license.php
- *	http://www.gnu.org/licenses/gpl.html
  */
 
 // ==ClosureCompiler==