diff app/assets/javascripts/init.tabs.js @ 134:3c777dbd6b11

Moved function declarations to beginning.
author Edho Arief <edho@myconan.net>
date Mon, 12 Nov 2012 17:30:22 +0700
parents 342373709d16
children 0cd87e69dd65
line wrap: on
line diff
--- a/app/assets/javascripts/init.tabs.js	Mon Nov 12 17:28:12 2012 +0700
+++ b/app/assets/javascripts/init.tabs.js	Mon Nov 12 17:30:22 2012 +0700
@@ -3,7 +3,33 @@
     return;
   }
   var raw = $('#plain pre').text(),
-    markdown = $('#markdown div');
+    markdown = $('#markdown div'),
+    update_state = function() {
+      var paste = $('#paste'),
+        mode = paste.data('mode'),
+        width = paste.data('width'),
+        qstring = '#!' + mode + '.' + width;
+      if (width == 'auto') {
+        qstring = '#!';
+        if (mode != 'plain') {
+          qstring += mode;
+        }
+      }
+      window.location = qstring;
+    },
+    paste_resize = function(size) {
+      var paste = $('#paste'),
+        title = $('#paste-resize a.btn');
+      title.html(title.html().replace(/(auto|\d+px)/, size));
+      if (size == 'auto') {
+        paste.css('width', '');
+        paste.data('width', size);
+      } else {
+        paste.css('width', size);
+        paste.data('width', size);
+      }
+      update_state();
+    };
 
   markdown.html(marked(raw));
   $('#highlight pre').text(raw);
@@ -12,34 +38,6 @@
   markdown.find('a').prop('rel', 'nofollow');
   prettyPrint();
 
-  update_state = function() {
-    var paste = $('#paste'),
-      mode = paste.data('mode'),
-      width = paste.data('width'),
-      qstring = '#!' + mode + '.' + width;
-    if (width == 'auto') {
-      qstring = '#!';
-      if (mode != 'plain') {
-        qstring += mode;
-      }
-    }
-    window.location = qstring;
-  };
-
-  paste_resize = function(size) {
-    var paste = $('#paste'),
-      title = $('#paste-resize a.btn');
-    title.html(title.html().replace(/(auto|\d+px)/, size));
-    if (size == 'auto') {
-      paste.css('width', '');
-      paste.data('width', size);
-    } else {
-      paste.css('width', size);
-      paste.data('width', size);
-    }
-    update_state();
-  }
-
   $('#paste-mode a').click(function() {
     $('#paste').data('mode', $(this).prop('href').split('#')[1]);
     update_state();