1 // Match links against PDF, PPT, PPS, and TIF files
2 var VIEWER_URL
= 'http://freewheel.autodesk.com/dwf.aspx?path=';
3 var pattern
= new RegExp('^[^\\?#]+\\.(dwf)((#|\\?).*)?$', 'i');
4 var provideMenu
= false;
8 * Checks a link to see if it points to a potential gview supported file.
9 * If so, rewrites the link to point to the Docs Viewer.
11 function checkLink() {
13 if (pattern
.test(href
)) {
14 // Show context menu on right click
15 $(this).bind('contextmenu', function(e
) {
17 $('#gview-cmenu').removeClass('gview-hidden').css(
18 {'left':e
.pageX
, 'top':e
.pageY
})[0].focus();
22 this.href
= VIEWER_URL
+ encodeURI(href
);
27 // Ignore checks on docs viewer domain
28 if (!/^https?:\/\/freewheel.autodesk.com/.test(window
.location
.href
)) {
29 // Check all the links in the page
30 $('a').each(checkLink
);
31 // Create context menu
33 var menu
= $("<ul id='gview-cmenu' class='gview-hidden' tabindex='9999'/>");
35 menu
.blur(function (e
) {
36 $(this).addClass('gview-hidden');
38 // Add open in new tab option
39 var item
= $("<li class='gview-cmenu-item'>Open Link in New Tab</li>");
40 item
.click(function (e
) { window
.open(VIEWER_URL
+ encodeURI(targetHref
)); });
42 // Add download option
43 var item
= $("<li class='gview-cmenu-item'>Download</li>");
44 item
.click(function (e
) { window
.location
.href
= targetHref
; });
46 // Add open as Doc option
48 item = $("<li class='gview-cmenu-item'>Save in Google Docs</li>");
49 item.click(function (e) {
50 window.open(VIEWER_URL + encodeURI(targetHref) + '&a=sv');
54 $(document
.body
).append(menu
);
This page took 1.35128 seconds and 4 git commands to generate.