Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 18 commits
  • 1 file changed
  • 0 commit comments
  • 3 contributors
Commits on Feb 03, 2013
@kashif-umair embed multiple lines from a gist file 6f11b68
@kashif-umair moved splittedFileName generation under file presence check 28e9929
@kashif-umair merge conflicts resolved. c4a8194
@kashif-umair Merge pull request #3 from kashif-umair/hotfix/fixed_file_name_split_bug
moved splittedFileName generation under file presence check
d09ebd6
@kashif-umair merge conflict resolved 61290be
@kashif-umair Merge pull request #4 from kashif-umair/hotfix/fixed_file_name_split_bug
merge conflicts resolved.
d88c366
@kashif-umair Merge pull request #5 from kashif-umair/feature/show_multiple_lines
Feature/show multiple lines
85ee074
@kashif-umair margin bottom removed for gist-file class 3608dff
@kashif-umair Merge branch 'master' of github.com:kashif-umair/gist-embed into feat…
…ure/my_own_blog
eb0c518
Commits on Feb 12, 2013
@kashif-umair merged with master 779825d
@kashif-umair Merge pull request #6 from kashif-umair/chore/update_readme
Chore/update readme
ca54b20
Commits on Jun 25, 2013
@kashif-umair Rename gist-embed.js to gist-embed.txt ca8f19e
@kashif-umair Merge pull request #8 from kashif-umair/feature/my_own_blog
Feature/my own blog
e9d024e
@kashif-umair Merge branch 'master' of github.com:kashif-umair/gist-embed into develop 73d29bf
@kashif-umair Merge pull request #9 from kashif-umair/develop
Develop
a7d2911
@kashif-umair renamed gist-embed javascript file 801dc6c
Commits on Jun 26, 2013
@tommaitland tommaitland Use full jQuery instead of $ alias for noConflict support. 4e64e84
@kashif-umair Merge pull request #11 from tommaitland/patch-1
Use full jQuery instead of $ alias for noConflict support.
781c754
Showing with 27 additions and 30 deletions.
  1. +27 −30 gist-embed.js
View
57 gist-embed.js
@@ -1,6 +1,6 @@
//author: Blair Vanderhoof
//https://github.com/blairvanderhoof/gist-embed
-$(function(){
+jQuery(function($){
var gistMarkerId = 'gist-';
//find all code elements containing "gist-" the id attribute.
@@ -12,13 +12,13 @@ $(function(){
line,
data = {};
- id = $elem.attr('id') || '';
- file = $elem.attr('data-file');
- line = $elem.attr('data-line');
- splittedFileName = file.split('.').join('-');
+ id = $elem.attr('id') || '';
+ file = $elem.attr('data-file');
+ line = $elem.attr('data-line');
if(file){
data.file = file;
+ splittedFileName = file.split('.').join('-');
}
//if the id doesn't begin with 'gist-', then ignore the code block
@@ -54,26 +54,36 @@ $(function(){
l.href = response.stylesheet;
head.insertBefore(l, head.firstChild);
}
+
+ var random = Math.floor(Math.random() * 100000);
+ $elem.html("<div id='" + random + "'>" + response.div + "</div>");
+
if(line){
var lineNumbers = getLineNumbers(line);
- console.log(lineNumbers);
-
- $(response.div).find('.line').each(function(index){
- if(!($.inArray(index + 1, lineNumbers))){
- $(this).hide();
+ $('#' + random).find('.line').each(function(index){
+ if(($.inArray(index + 1, lineNumbers)) == -1){
+ $(this).remove();
}
- console.log(($.inArray(index + 1, lineNumbers)));
- console.log(index + 1);
});
- $(response.div).find('.line-number').each(function(index){
- if(!($.inArray(index + 1, lineNumbers))) $(this).hide();
+ lineNumber = 1;
+ $('#' + random).find('.line-number').each(function(index){
+ if(($.inArray(index + 1, lineNumbers)) == -1){
+ $(this).remove();
+ }
+ else{
+ $(this).html(lineNumber++);
+ }
});
- $elem.html(response.div);
}
- else{
- $elem.html(response.div);
+ if($elem.attr('data-showFooter') && $elem.attr('data-showFooter') == "false"){
+ $('#' + random).find('.gist-meta').remove();
}
+
+ if($elem.attr('data-showLineNumbers') && $elem.attr('data-showLineNumbers') == "false"){
+ $('#' + random).find('.line-numbers').remove();
+ }
+ $('#' + random).find('.gist-file').css('margin-bottom', '0px');
}else{
$elem.html('Failed loading gist ' + url);
}
@@ -104,16 +114,3 @@ function getLineNumbers(lineRangeString){
}
return lineNumbers;
}
-
-function extractLines(gistId, lineCodes, splittedFileName){
- html = '<div id="gist' + gistId + '" class="gist"><div class="gist-file">' +
- '<div class="gist-data gist-syntax"><div class="file-data">' +
- '<table cellpadding="0" cellspacing="0" class="lines highlight">' +
- '<tbody><tr><td class="line-data"><pre class="line-pre">';
- for(var i = 0; i < lineCodes.length; i++){
- html += '<div class="line" id="file-' + splittedFileName + '-LC' + (i + 1) + '">' +
- lineCodes[i] + '</div>';
- }
- html += '</pre></td></tr></tbody></table></div></div></div></div>';
- return html;
-}

No commit comments for this range

Something went wrong with that request. Please try again.