Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit to import code to git
- Loading branch information
Jawish Hameed
committed
Apr 20, 2014
0 parents
commit ed2f813
Showing
4 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* jQuery.gdocViewer - Embed linked documents using Google Docs Viewer | ||
* Licensed under MIT license. | ||
* Date: 2011/01/16 | ||
* | ||
* @author Jawish Hameed | ||
* @version 1.0 | ||
*/ | ||
(function($){ | ||
$.fn.gdocsViewer = function(options) { | ||
|
||
var settings = { | ||
width : '600', | ||
height : '700' | ||
}; | ||
|
||
if (options) { | ||
$.extend(settings, options); | ||
} | ||
|
||
return this.each(function() { | ||
var file = $(this).attr('href'); | ||
var ext = file.substring(file.lastIndexOf('.') + 1); | ||
|
||
if (/^(tiff|pdf|ppt|pps|doc|docx)$/.test(ext)) { | ||
$(this).after(function () { | ||
var id = $(this).attr('id'); | ||
var gdvId = (typeof id !== 'undefined' && id !== false) ? id + '-gdocsviewer' : ''; | ||
return '<div id="' + gdvId + '" class="gdocsviewer"><iframe src="http://docs.google.com/viewer?embedded=true&url=' + encodeURIComponent(file) + '" width="' + settings.width + '" height="' + settings.height + '" style="border: none;"></iframe></div>'; | ||
}) | ||
} | ||
}); | ||
}; | ||
})( jQuery ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* jQuery.gdocViewer - Embed linked documents using Google Docs Viewer | ||
* Licensed under MIT license. | ||
* Date: 2011/01/16 | ||
* | ||
* @author Jawish Hameed | ||
* @version 1.0 | ||
*/ | ||
(function(a){a.fn.gdocsViewer=function(b){var c={width:"600",height:"700"};if(b){a.extend(c,b)}return this.each(function(){var d=a(this).attr("href");var e=d.substring(d.lastIndexOf(".")+1);if(/^(tiff|pdf|ppt|pps|doc|docx)$/.test(e)){a(this).after(function(){var g=a(this).attr("id");var f=(typeof g!=="undefined"&&g!==false)?g+"-gdocsviewer":"";return'<div id="'+f+'" class="gdocsviewer"><iframe src="http://docs.google.com/viewer?embedded=true&url='+encodeURIComponent(d)+'" width="'+c.width+'" height="'+c.height+'" style="border: none;"></iframe></div>'})}})}})(jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<html> | ||
<head> | ||
<title>gDocsViewer Demo</title> | ||
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script> | ||
<script type="text/javascript" src="jquery.gdocsviewer.min.js"></script> | ||
<style type="text/css"> | ||
/* Style the second URL with a red border */ | ||
#test-gdocsviewer { | ||
border: 5px red solid; | ||
padding: 20px; | ||
width: 650px; | ||
background: #ccc; | ||
text-align: center; | ||
} | ||
/* Style all gdocsviewer containers */ | ||
.gdocsviewer { | ||
margin:10px; | ||
} | ||
</style> | ||
<script type="text/javascript"> | ||
/*<![CDATA[*/ | ||
$(document).ready(function() { | ||
$('a.embed').gdocsViewer({width: 600, height: 750}); | ||
$('#embedURL').gdocsViewer(); | ||
}); | ||
/*]]>*/ | ||
</script> | ||
</head> | ||
<body style="background:#999; font-family:arial, helvetica, sans-serif; font-size:14px;"> | ||
<div style="background:#fff; width:960px; margin:0 auto; padding:20px;"> | ||
<h1>gDocsViewer jQuery plugin v1.0 Demo</h1> | ||
<div> | ||
<p>By <a href="http://www.jawish.org/">Jawish Hameed</a></p> | ||
|
||
<p>See <a href="http://www.jawish.org/blog/archives/394-Google-Docs-Viewer-plugin-for-jQuery.html" target="_blank">documentation and usage guide</a></p> | ||
|
||
</div> | ||
<hr size="1" /> | ||
<div> | ||
<h2>Examples</h2> | ||
<h3>URLs with class: embed</h3> | ||
<a href="http://finaid.georgetown.edu/sample.pdf" class="embed">PDF test georgetown.edu</a> | ||
<a href="http://plugindoc.mozdev.org/testpages/test.pdf" class="embed" id="test">PDF at mozdev.org</a> | ||
|
||
<h3>URLs with id: embedURL</h3> | ||
<a href="http://samplepdf.com/sample.pdf" id="embedURL">Sample PDF at samplepdf.com</a> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |