Browse Source

Moved js from source to template

Signed-off-by: emanuele <[email protected]>
emanuele 13 years ago
parent
commit
94f43df955

+ 1 - 26
Sources/Subs-Editor.php

@@ -1461,32 +1461,7 @@ function create_control_richedit($editorOptions)
 		// ]]></script>
 		<link rel="stylesheet" href="' . $settings['default_theme_url'] . '/css/jquery.sceditor.css" type="text/css" media="all" />
 		<script type="text/javascript" src="' . $settings['default_theme_url'] . '/scripts/jquery.sceditor.js"></script>
-		<script type="text/javascript" src="' . $settings['default_theme_url'] . '/scripts/jquery.sceditor.bbcode.js"></script>
-		<script>
-			(function($) {
-				var extensionMethods = {
-					InsertText: function(text) {
-						var bIsSource = this.inSourceMode();
-						var current_value = this.getWysiwygEditorValue() + "\n" + text;
-
-						if (!bIsSource)
-							this.toggleTextMode();
-
-						this.setTextareaValue(current_value);
-
-						if (!bIsSource)
-							this.toggleTextMode();
-					}
-				};
-
-				$.extend(true, $[\'sceditor\'].prototype, extensionMethods);
-			})(jQuery);
-
-			$(document).ready(function() {
-				$("#' . $editorOptions['id'] . '").sceditorBBCodePlugin({
-					style: "' . $settings['default_theme_url'] . '/css/jquery.sceditor.default.css"
-				});
-		});</script>';
+		<script type="text/javascript" src="' . $settings['default_theme_url'] . '/scripts/jquery.sceditor.bbcode.js"></script>';
 
 		$context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && function_exists('pspell_new');
 		if ($context['show_spellchecking'])

+ 29 - 1
Themes/default/GenericControls.template.php

@@ -30,7 +30,33 @@ function template_control_richedit($editor_id, $smileyContainer = null, $bbcCont
 		<script type="text/javascript"><!-- // --><![CDATA[
 			var bbc_quote_from = \'', $txt['quote_from'], '\'
 			var bbc_quote = \'', $txt['quote'], '\'
-			var bbc_search_on = \'', $txt['search_on'], '\'';
+			var bbc_search_on = \'', $txt['search_on'], '\';
+
+			(function($) {
+				var extensionMethods = {
+					InsertText: function(text) {
+						var bIsSource = this.inSourceMode();
+						var current_value = this.getWysiwygEditorValue() + "\n" + text;
+
+						// @TODO make it put the quote close to the current selection
+
+						if (!bIsSource)
+							this.toggleTextMode();
+
+						this.setTextareaValue(current_value);
+
+						if (!bIsSource)
+							this.toggleTextMode();
+					alert(this.this.getWysiwygEditorValue());
+					}
+				};
+
+				$.extend(true, $[\'sceditor\'].prototype, extensionMethods);
+			})(jQuery);
+
+			$(document).ready(function() {
+				$("#' . $editor_id . '").sceditorBBCodePlugin({
+					style: "' . $settings['default_theme_url'] . '/css/jquery.sceditor.default.css"';
 
 		// Show the smileys.
 // 		if ((!empty($context['smileys']['postform']) || !empty($context['smileys']['popup'])) && !$editor_context['disable_smiley_box'] && $smileyContainer !== null)
@@ -254,6 +280,8 @@ function template_control_richedit($editor_id, $smileyContainer = null, $bbcCont
 // 				smf_editorArray[smf_editorArray.length] = oEditorHandle_', $editor_id, ';';
 
 		echo '
+				});
+		});
 			// ]]></script>';
 }
 

+ 5 - 11
Themes/default/Post.template.php

@@ -850,20 +850,14 @@ function template_main()
 			function onDocReceived(XMLDoc)
 			{
 				var text = \'\';
-// 				var bIsSource = $("#', $context['post_box_name'], '").data("sceditor").inSourceMode();
 
 				for (var i = 0, n = XMLDoc.getElementsByTagName(\'quote\')[0].childNodes.length; i < n; i++)
 					text += XMLDoc.getElementsByTagName(\'quote\')[0].childNodes[i].nodeValue;
 				$("#', $context['post_box_name'], '").data("sceditor").InsertText(text);
-
-/*				var current_value = $("#', $context['post_box_name'], '").data("sceditor").getWysiwygEditorValue() + "\n" + text;
-				if (!bIsSource)
-					$("#', $context['post_box_name'], '").data("sceditor").toggleTextMode();
-
-				$("#', $context['post_box_name'], '").data("sceditor").setTextareaValue(current_value);
-
-				if (!bIsSource)
-					$("#', $context['post_box_name'], '").data("sceditor").toggleTextMode();*/
+			}
+			function onReceiveOpener(text)
+			{
+				$("#', $context['post_box_name'], '").data("sceditor").InsertText(text);
 			}
 		// ]]></script>';
 	}
@@ -984,7 +978,7 @@ function template_quotefast()
 			if (\'opera\' in window)
 				quote = quote.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, \'"\').replace(/&amp;/g, "&");
 
-			window.opener.oEditorHandle_', $context['post_box_name'], '.InsertText(quote);
+			window.opener.onReceiveOpener(quote);
 
 			window.focus();
 			setTimeout("window.close();", 400);';