diff app/assets/javascripts/zp.viewer_width.js @ 214:22c4b5f90e24

Massive javascript and html refactor. Also, ie9
author Edho Arief <edho@myconan.net>
date Sun, 12 May 2013 02:43:38 +0900
parents
children f057e8c78e50
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/assets/javascripts/zp.viewer_width.js	Sun May 12 02:43:38 2013 +0900
@@ -0,0 +1,25 @@
+(function($) {
+  window.zp.viewer_width = {
+    links: function() { return $("#paste-resize ul li a") },
+    current: "auto",
+    resize: function(width) {
+      var
+        paste = $("#paste"),
+        title = $("#paste-resize .btn")
+      title.text(title.data("base").replace(":size:", width))
+      this.current = width
+      if (width == "auto") {
+        paste.css("width", "")
+      } else {
+        paste.css("width", width)
+      }
+      zp.hash_magic.set_hash()
+    },
+    do_switch: function(e) {
+      this.resize($(e.target).text())
+    },
+    init: function() {
+      this.links().click($.proxy(this.do_switch, this))
+    }
+  }
+})(jQuery)