can3p (can3p) wrote in changelog,
can3p
can3p
changelog

[livejournal] r20387: LJSUP-10187: Add a button to toggle all ...

Committer: dpetrov
LJSUP-10187: Add a button to toggle all new functionality in the s2 layers editor
U   trunk/htdocs/js/s2edit/s2edit.js
U   trunk/htdocs/js/s2edit/s2gui.js
U   trunk/templates/Widgets/layereditor.tmpl
Modified: trunk/htdocs/js/s2edit/s2edit.js
===================================================================
--- trunk/htdocs/js/s2edit/s2edit.js	2011-10-19 13:08:47 UTC (rev 20386)
+++ trunk/htdocs/js/s2edit/s2edit.js	2011-10-20 07:25:29 UTC (rev 20387)
@@ -20,6 +20,7 @@
 			s2lineCount = 0;
 
 			this.initSettings();
+			this.initGui();
 
 			s2initIndex();
 			s2initParser();
@@ -51,16 +52,34 @@
 
 					settings[item] = val;
 					jQuery.storage.setItem('s2edit', settings);
+				},
+
+				turboEnabled: function() {
+					return !!this.load('turboMode')
 				}
 			};
 		},
 
+		initGui: function() {
+			var self = this;
+			jQuery('.turbo-mode').click(function(ev) {
+				var modeEnabled = !s2settings.load('turboMode');
+				s2settings.save('turboMode', modeEnabled);
+				if (modeEnabled) {
+					if (!s2isAceActive()) {
+						self.toggleEditor();
+					}
+					this.value = 'Back to old editor';
+				} else {
+					if (s2isAceActive()) {
+						self.toggleEditor();
+					}
+					this.value = 'Show new editor';
+				}
+			});
+		},
+
 		aceInit: function() {
-			jQuery('<input type="button" id="toggleEditor" class="compilelink"/>')
-				.click(this.toggleEditor.bind(this))
-				.val('Toggle source view')
-				.insertAfter('.header .compilelink');
-
 			var textarea = jQuery('#main'),
 				pre = jQuery('<pre id="editor"/>')
 					.addClass('maintext')

Modified: trunk/htdocs/js/s2edit/s2gui.js
===================================================================
--- trunk/htdocs/js/s2edit/s2gui.js	2011-10-19 13:08:47 UTC (rev 20386)
+++ trunk/htdocs/js/s2edit/s2gui.js	2011-10-20 07:25:29 UTC (rev 20387)
@@ -26,6 +26,10 @@
 		init: function() {
 			el = jQuery('#out');
 
+			if (!s2settings.turboEnabled()) {
+				return;
+			}
+
 			var text = el.html();
 			if (text.length > 0) {
 				text = parseLineNumbers(text);
@@ -537,6 +541,8 @@
 		textarea.value = aceEditor.getSession().getValue();
 	}
 
-	s2edit.save(textarea.value);
-	return false;
+	if (s2settings.turboEnabled()) {
+		s2edit.save(textarea.value);
+		return false;
+	}
 }

Modified: trunk/templates/Widgets/layereditor.tmpl
===================================================================
--- trunk/templates/Widgets/layereditor.tmpl	2011-10-19 13:08:47 UTC (rev 20386)
+++ trunk/templates/Widgets/layereditor.tmpl	2011-10-20 07:25:29 UTC (rev 20387)
@@ -8,6 +8,7 @@
             <a href="<TMPL_VAR s2doc>" target="_blank">Documentation</a>
         </div>
         <input type="submit" value="Save & Compile" class="compilelink" />
+        <input type="button" value="Enable new editor" class="compilelink turbo-mode" />
     </div>
     <div class="main" id="maindiv">
         <div class="maincontainer">

Tags: can3p, dpetrov, js, livejournal, tmpl
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