changelog_bot (changelog_bot) wrote in changelog,
changelog_bot
changelog_bot
changelog

[livejournal] r20501: LJSUP-10323: Editor for s2 styles does n...

Committer: dpetrov
LJSUP-10323: Editor for s2 styles does not save position of the cursor on the page after compile
U   trunk/htdocs/js/s2edit/s2edit.js
U   trunk/htdocs/js/s2edit/s2gui.js
Modified: trunk/htdocs/js/s2edit/s2edit.js
===================================================================
--- trunk/htdocs/js/s2edit/s2edit.js	2011-11-08 14:01:16 UTC (rev 20500)
+++ trunk/htdocs/js/s2edit/s2edit.js	2011-11-09 08:50:03 UTC (rev 20501)
@@ -61,22 +61,33 @@
 		},
 
 		initGui: function() {
-			var self = this;
-			jQuery('.turbo-mode').click(function(ev) {
+			var self = this,
+				turboButton = jQuery('.turbo-mode'),
+				toggleTurboButton = function(enable) {
+					if (enable) {
+						turboButton.val('Back to old editor');
+					} else {
+						turboButton.val('Show new editor');
+					}
+				};
+
+			turboButton.click(function(ev) {
 				var modeEnabled = !s2settings.load('turboMode');
 				s2settings.save('turboMode', modeEnabled);
+				toggleTurboButton(modeEnabled);
 				if (modeEnabled) {
 					if (!s2isAceActive()) {
 						self.toggleEditor();
 					}
-					this.value = 'Back to old editor';
 				} else {
 					if (s2isAceActive()) {
 						self.toggleEditor();
 					}
-					this.value = 'Show new editor';
 				}
 			});
+
+			var modeEnabled = !!s2settings.load('turboMode');
+			toggleTurboButton(modeEnabled);
 		},
 
 		isAceSupported: function() {

Modified: trunk/htdocs/js/s2edit/s2gui.js
===================================================================
--- trunk/htdocs/js/s2edit/s2gui.js	2011-11-08 14:01:16 UTC (rev 20500)
+++ trunk/htdocs/js/s2edit/s2gui.js	2011-11-09 08:50:03 UTC (rev 20501)
@@ -332,8 +332,8 @@
 	s2buildClasses();
 	s2buildFunctions();
 	s2buildProperties();
-	
-	if (window.name)
+
+	if (!s2settings.turboEnabled() && window.name)
 	{
 		setTimeout(function() {
 			var pos = window.name.split(':'), textarea = s2getCodeArea();
@@ -550,5 +550,7 @@
 	if (s2settings.turboEnabled()) {
 		s2edit.save(textarea.value);
 		return false;
+	} else {
+		window.name = textarea.scrollTop + ':' + nxgetPositionCursor(textarea);
 	}
 }

Tags: can3p, dpetrov, js, livejournal
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments