diff app/assets/javascripts/zp.formatter.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 c8757469da39
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/assets/javascripts/zp.formatter.js	Sun May 12 02:43:38 2013 +0900
@@ -0,0 +1,23 @@
+//= require config/marked
+//= require config/prettify
+(function($) {
+  window.zp.formatter = {
+    raw: function() { return $("#pl pre").text() },
+    links: function() { return $("#paste-mode a") },
+    current: function() { return this.links().filter(".active").attr("href").slice(1) },
+    markdown: function() {
+      var area = $("#md div")
+      area.html(marked(this.raw()))
+      area.find("pre").addClass("prettyprint")
+      area.find("a").prop("rel", "nofollow")
+    },
+    highlight: function() {
+      $("#hl pre").text(this.raw())
+      prettyPrint()
+    },
+    init: function() {
+      this.markdown()
+      this.highlight()
+    }
+  }
+})(jQuery)