Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

updates for latest gist.github.com design

  • Loading branch information...
commit ae0d9f2e784211346fefd30699d94ce6cadeaf06 1 parent cf8860d
@revathskumar authored
Showing with 14 additions and 26 deletions.
  1. +14 −26 gist_markdown_preview.js
View
40 gist_markdown_preview.js
@@ -1,16 +1,16 @@
function preview(e){
e.preventDefault();
e.stopPropagation();
- if($textarea.is(":visible")){
- $textarea.hide();
- $preview_container.show();
- $preview_button.html("Edit");
+ if($(".ace_editor").is(":visible")){
+ $(".ace_editor").hide();
+ $("#readme article").show();
+ $("#gist-preview span").html("Edit");
} else {
- $preview_container.hide();
- $textarea.show();
- $preview_button.html("Preview");
+ $("#readme article").hide();
+ $(".ace_editor").show();
+ $("#gist-preview span").html("Preview");
}
- $preview_container.html($.markdown($textarea.val()));
+ $("#readme article").html($.markdown($(".input > textarea").val()));
return false;
}
@@ -18,10 +18,9 @@ function appendHtml(e){
ele = e.currentTarget;
selected_item = $(ele).html().replace(/<(?:.|\n)*?>/gm, '');
var isMarkdown = false;
- if(selected_item == "Markdown" && e.type == "click"){
+ if($("input.gist-language").val() == "Markdown"){
isMarkdown = true;
}
-
if(e.type == "change"){
selected_item = $(ele).val();
$.each([".md",".markdown"],function(k,v){
@@ -30,30 +29,19 @@ function appendHtml(e){
}
});
}
-
if(!isMarkdown){
$("#readme").remove();
- if($preview_button){
- $preview_button.parent().remove();
- }
- $textarea.show();
- $preview_button = $preview = null;
+ $("#gist-preview span").parent().remove();
+ $(".ace_editor").show();
return;
}
- if(!$preview){
- $preview = $('<div class="blob instapaper_body" id="readme"><article class="markdown-body entry-content" itemprop="mainContentOfPage"></article>');
- $textarea.parent().append($preview);
- $(".form-actions").append("<button type='button' class='classy' id='gist-preview'><span>Preview</span></button>");
- }
- $preview_button = $("#gist-preview span");
- $preview_container = $("#readme article");
+ preview_area = $('<div class="blob instapaper_body" id="readme"><article class="markdown-body entry-content" itemprop="mainContentOfPage"></article>');
+ $(".ace_editor").parent().append(preview_area);
+ $(".form-actions").append("<button type='button' class='classy' id='gist-preview'><span>Preview</span></button>");
}
jQuery(function($){
- $textarea = $("div.input textarea");
- $preview_button = $preview = null;
- $(".chzn-results li").live("click",appendHtml);
$("#gist-preview").live("click",preview);
$(".gist-name-textbox").live("change", appendHtml);
});
Please sign in to comment.
Something went wrong with that request. Please try again.