Socket
Socket
Sign inDemoInstall

exlink

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.2.1 to 2.3.0

.npmignore

49

jquery.exLink.js

@@ -7,3 +7,3 @@ // jQuery.exLink

// Support: @YupItsZac - Twitter, or fb.me/yupitszac
// Version 2.1.0 June 30, 2015
// Version 2.3.0 November 20, 2015

@@ -24,4 +24,4 @@

fancyBoxIgnore: true,
linkCallback: null,
fileCallback: null,
navigateCallback: null,
navigateState: null,
gaTracking: false,

@@ -53,15 +53,13 @@ gaTrackLabel: 'External Links',

if(options != 're') {
opts = $.extend({}, defaults, options);
opts = $.extend({}, defaults, options);
$('body').on('click','.exLink, .docuLink',function(event){
event.preventDefault();
$('body').on('click','.exLink, .docuLink',function(event){
event.preventDefault();
if(event.handled != true) {
catchClick(event);
}
if(event.handled != true) {
catchClick(event);
}
event.handled = true;
});
}
event.handled = true;
});

@@ -152,4 +150,4 @@ var self = this;

showLinkWarning(href);
if ($.isFunction(opts.linkCallback)) {
opts.linkCallback(obj, true);
if ($.isFunction(opts.navigateCallback)) {
opts.navigateCallback(obj, 1, true);
}

@@ -164,4 +162,4 @@ } else {

window.open(href, '_blank');
if ($.isFunction(opts.linkCallback)) {
opts.linkCallback(obj, false);
if ($.isFunction(opts.navigateCallback)) {
opts.navigateCallback(obj, 1, false);
}

@@ -181,4 +179,4 @@

if($.isFunction(opts.fileCallback)) {
opts.fileCallback(obj, true);
if($.isFunction(opts.navigateCallback)) {
opts.navigateCallback(obj, 1, true);
}

@@ -194,4 +192,4 @@

if($.isFunction(opts.fileCallback)) {
opts.fileCallback(obj, false);
if($.isFunction(opts.navigateCallback)) {
opts.navigateCallback(obj, 2, false);
}

@@ -267,8 +265,13 @@ }

window.open(href, opts.titleWindow, 'height='+opts.heightWindow+', width='+opts.widthWindow);
if($.isFunction(opts.navigateState)) {
opts.navigateState(href, 1);
}
} else {
window.open(href, '_blank');
if($.isFunction(opts.navigateState)) {
opts.navigateState(href, 2);
}
}
$('.modalBG').remove();
$('.modal-dialog').remove();
$('.modalBG, .modal-dialog').remove();
};

@@ -275,0 +278,0 @@

@@ -1,1 +0,1 @@

var exLink=function(){return initialize=function(o){var n={protocols:["http","https"],filetypes:["pdf","xls","docx","doc","ppt","pptx"],hostCompare:!1,noFollow:!1,fancyBoxIgnore:!0,linkCallback:null,fileCallback:null,gaTracking:!1,gaTrackLabel:"External Links",gaTrackOld:!1,linkWarning:!0,linkWarningBody:"You are about to leave this website and navigate to the link below. Would you like to continue?",fileWarning:!0,fileWarningBody:"You are about to open the file below. Do you wish to continue?",dialogConfirm:"#006600",dialogCancel:"#CC0000",dialogConfirmText:"#fff",dialogCancelText:"#fff",dialogCancelButton:"Cancel",dialogConfirmButton:"Continue",modalDisplayBG:!0,modalWidth:"320px",modalHeight:"240px",externalColor:"",documentColor:"",clickedColor:"",newWindow:!1,widthWindow:"500",heightWindow:"400;",titleWindow:"exLink by YupItsZac.com"};"re"!=o&&(jQuery.options=$.extend({},n,o),$("body").on("click",".exLink, .docuLink",function(o){o.preventDefault(),1!=o.handled&&catchClick(o),o.handled=!0}));jQuery.options.hostCompare?targetByHost():targetByProtocol(),$(".exLink").css("color",jQuery.options.externalColor),$(".docuLink").css("color",jQuery.options.documentColor)},targetByProtocol=function(){jQuery.each(jQuery.options.protocols,function(o,n){jQuery.options.noFollow?jQuery.options.fancyBoxIgnore?$('a[href^="'+n+'://"]').not(".docuLink, .iframe").addClass("exLink").attr("rel","nofollow"):$('a[href^="'+n+'://"]').not(".docuLink").addClass("exLink").attr("rel","nofollow"):jQuery.options.fancyBoxIgnore?$('a[href^="'+n+'://"]').not(".docuLink, .iframe").addClass("exLink"):$('a[href^="'+n+'://"]').not(".docuLink").addClass("exLink")}),identifyDocuments()},targetByHost=function(){identifyDocuments();var o=new RegExp(location.host);$("a").each(function(){o.test($(this).attr("href"))===!1&&(jQuery.options.noFollow?jQuery.options.fancyBoxignore?$(this).not(".docuLink, .iframe").addClass("exLink").attr("rel","nofollow"):$(this).not(".docuLink").addClass("exLink").attr("rel","nofollow"):jQuery.options.fancyBoxIgnore?$(this).not(".docuLink, .iframe").addClass("exLink"):$(this).not(".docuLink").addClass("exLink"))})},identifyDocuments=function(){jQuery.each(jQuery.options.filetypes,function(o,n){$('a[href$="'+n+'"]').not(".exLink").addClass("docuLink").css("color",jQuery.options.documentColor)})},catchClick=function(o){if($(o.target).is(".exLink"))if(jQuery.options.linkWarning){if($(o.target).is("a"))var n=o.target.href;else var n=$(o.target).closest("a").attr("href");showLinkWarning(n),$.isFunction(jQuery.options.linkCallback)&&jQuery.options.linkCallback(o,!0)}else{if($(o.target).is("a"))var n=o.target.href;else var n=$(o.target).closest("a").attr("href");window.open(n,"_blank"),$.isFunction(jQuery.options.linkCallback)&&jQuery.options.linkCallback(o,!1)}else if(jQuery.options.fileWarning){if($(o.target).is("a"))var n=o.target.href;else var n=$(o.target).closest("a").attr("href");showDocWarning(n),$.isFunction(jQuery.options.fileCallback)&&jQuery.options.fileCallback(o,!0)}else{if($(o.target).is("a"))var n=o.target.href;else var n=$(o.target).closest("a").attr("href");window.open(n,"_blank"),$.isFunction(jQuery.options.fileCallback)&&jQuery.options.fileCallback(o,!1)}jQuery.options.clickedColor&&$(o.target).css("color",jQuery.options.clickedColor),window.lastObj=o},showLinkWarning=function(o){jQuery.options.modalDisplayBG&&($("body").append('<div class="modalBG"></div>'),$(".modalBG").fadeIn("slow")),$("body").append('<div class="modal-dialog">'+jQuery.options.linkWarningBody+"<br><br><p><center><b>"+o+'</b></center></p><br><br><div class="exLinkButton exLinkCancel" onclick="exLink.closeModal();">'+jQuery.options.dialogCancelButton+'</div><div class="exLinkButton exLinkContinue" onclick="exLink.navigate(&quot;'+o+'&quot;);">'+jQuery.options.dialogConfirmButton+"</div></div>"),$(".modal-dialog").fadeIn("slow"),$(".exLinkCancel").css("background-color",jQuery.options.dialogCancel),$(".exLinkContinue").css("background-color",jQuery.options.dialogConfirm),$(".exLinkCancel").css("color",jQuery.options.dialogCancelText),$(".exLinkContinue").css("color",jQuery.options.dialogConfirmText),$(".modal-dialog").css("width",jQuery.options.modalWidth),$(".modal-dialog").css("height",jQuery.options.modalHeight)},showDocWarning=function(o){jQuery.options.modalDisplayBG&&($("body").append('<div class="modalBG"></div>'),$(".modalBG").fadeIn("slow")),$("body").append('<div class="modal-dialog">'+jQuery.options.fileWarningBody+"<br><br><p><center><b>"+o+'</b></center></p><br><br><div class="exLinkButton exLinkCancel" onclick="exLink.closeModal();">'+jQuery.options.dialogCancelButton+'</div><div class="exLinkButton exLinkContinue" onclick="exLink.navigate(&quot;'+o+'&quot;);">'+jQuery.options.dialogConfirmButton+"</div></div>"),$(".modal-dialog").fadeIn("slow"),$(".exLinkCancel").css("background-color",jQuery.options.dialogCancel),$(".exLinkContinue").css("background-color",jQuery.options.dialogConfirm),$(".exLinkCancel").css("color",jQuery.options.dialogCancelText),$(".exLinkContinue").css("color",jQuery.options.dialogConfirmText),$(".modal-dialog").css("width",jQuery.options.modalWidth),$(".modal-dialog").css("height",jQuery.options.modalHeight)},closeModal=function(){$(".modalBG").remove(),$(".modal-dialog").remove()},navigateLocation=function(o){if(jQuery.options.gaTracking){var n=window.location.hostname;if(jQuery.options.gaTrackOld){_gaq.push(["_trackEvent",jQuery.options.gaTrackLabel,n,o])}else ga("send","event",jQuery.options.gaTrackLabel,n,o)}jQuery.options.newWindow?window.open(o,jQuery.options.titleWindow,"height="+jQuery.options.heightWindow+", width="+jQuery.options.widthWindow):window.open(o,"_blank"),$(".modalBG").remove(),$(".modal-dialog").remove()},{init:initialize,closeModal:closeModal,navigate:navigateLocation}}();
var exLink=function(){var o={};return initialize=function(a){var n={protocols:["http","https"],filetypes:["pdf","xls","docx","doc","ppt","pptx"],hostCompare:!1,noFollow:!1,fancyBoxIgnore:!0,navigateCallback:null,navigateState:null,gaTracking:!1,gaTrackLabel:"External Links",gaTrackOld:!1,linkWarning:!0,linkWarningBody:"You are about to leave this website and navigate to the link below. Would you like to continue?",fileWarning:!0,fileWarningBody:"You are about to open the file below. Do you wish to continue?",dialogConfirm:"#006600",dialogCancel:"#CC0000",dialogConfirmText:"#fff",dialogCancelText:"#fff",dialogCancelButton:"Cancel",dialogConfirmButton:"Continue",modalDisplayBG:!0,modalWidth:"320px",modalHeight:"240px",externalColor:"",documentColor:"",clickedColor:"",newWindow:!1,widthWindow:"500",heightWindow:"400;",titleWindow:"exLink by YupItsZac.com"};o=$.extend({},n,a),$("body").on("click",".exLink, .docuLink",function(o){o.preventDefault(),1!=o.handled&&catchClick(o),o.handled=!0});o.hostCompare?targetByHost():targetByProtocol(),$(".exLink").css("color",o.externalColor),$(".docuLink").css("color",o.documentColor)},targetByProtocol=function(){jQuery.each(o.protocols,function(a,n){o.noFollow?o.fancyBoxIgnore?$('a[href^="'+n+'://"]').not(".docuLink, .iframe").addClass("exLink").attr("rel","nofollow"):$('a[href^="'+n+'://"]').not(".docuLink").addClass("exLink").attr("rel","nofollow"):o.fancyBoxIgnore?$('a[href^="'+n+'://"]').not(".docuLink, .iframe").addClass("exLink"):$('a[href^="'+n+'://"]').not(".docuLink").addClass("exLink")}),identifyDocuments()},targetByHost=function(){identifyDocuments();var a=new RegExp(location.host);$("a").each(function(){a.test($(this).attr("href"))===!1&&(o.noFollow?o.fancyBoxignore?$(this).not(".docuLink, .iframe").addClass("exLink").attr("rel","nofollow"):$(this).not(".docuLink").addClass("exLink").attr("rel","nofollow"):o.fancyBoxIgnore?$(this).not(".docuLink, .iframe").addClass("exLink"):$(this).not(".docuLink").addClass("exLink"))})},identifyDocuments=function(){jQuery.each(o.filetypes,function(a,n){$('a[href$="'+n+'"]').not(".exLink").addClass("docuLink").css("color",o.documentColor)})},catchClick=function(a){if($(a.target).is(".exLink"))if(o.linkWarning){if($(a.target).is("a"))var n=a.target.href;else var n=$(a.target).closest("a").attr("href");showLinkWarning(n),$.isFunction(o.navigateCallback)&&o.navigateCallback(a,1,!0)}else{if($(a.target).is("a"))var n=a.target.href;else var n=$(a.target).closest("a").attr("href");window.open(n,"_blank"),$.isFunction(o.navigateCallback)&&o.navigateCallback(a,1,!1)}else if(o.fileWarning){if($(a.target).is("a"))var n=a.target.href;else var n=$(a.target).closest("a").attr("href");showDocWarning(n),$.isFunction(o.navigateCallback)&&o.navigateCallback(a,1,!0)}else{if($(a.target).is("a"))var n=a.target.href;else var n=$(a.target).closest("a").attr("href");window.open(n,"_blank"),$.isFunction(o.navigateCallback)&&o.navigateCallback(a,2,!1)}o.clickedColor&&$(a.target).css("color",o.clickedColor),window.lastObj=a},showLinkWarning=function(a){o.modalDisplayBG&&($("body").append('<div class="modalBG"></div>'),$(".modalBG").fadeIn("slow")),$("body").append('<div class="modal-dialog">'+o.linkWarningBody+"<br><br><p><center><b>"+a+'</b></center></p><br><br><div class="exLinkButton exLinkCancel" onclick="exLink.closeModal();">'+o.dialogCancelButton+'</div><div class="exLinkButton exLinkContinue" onclick="exLink.navigate(&quot;'+a+'&quot;);">'+o.dialogConfirmButton+"</div></div>"),$(".modal-dialog").fadeIn("slow"),$(".exLinkCancel").css("background-color",o.dialogCancel),$(".exLinkContinue").css("background-color",o.dialogConfirm),$(".exLinkCancel").css("color",o.dialogCancelText),$(".exLinkContinue").css("color",o.dialogConfirmText),$(".modal-dialog").css("width",o.modalWidth),$(".modal-dialog").css("height",o.modalHeight)},showDocWarning=function(a){o.modalDisplayBG&&($("body").append('<div class="modalBG"></div>'),$(".modalBG").fadeIn("slow")),$("body").append('<div class="modal-dialog">'+o.fileWarningBody+"<br><br><p><center><b>"+a+'</b></center></p><br><br><div class="exLinkButton exLinkCancel" onclick="exLink.closeModal();">'+o.dialogCancelButton+'</div><div class="exLinkButton exLinkContinue" onclick="exLink.navigate(&quot;'+a+'&quot;);">'+o.dialogConfirmButton+"</div></div>"),$(".modal-dialog").fadeIn("slow"),$(".exLinkCancel").css("background-color",o.dialogCancel),$(".exLinkContinue").css("background-color",o.dialogConfirm),$(".exLinkCancel").css("color",o.dialogCancelText),$(".exLinkContinue").css("color",o.dialogConfirmText),$(".modal-dialog").css("width",o.modalWidth),$(".modal-dialog").css("height",o.modalHeight)},closeModal=function(){$(".modalBG").remove(),$(".modal-dialog").remove()},navigateLocation=function(a){if(o.gaTracking){var n=window.location.hostname;if(o.gaTrackOld){_gaq.push(["_trackEvent",o.gaTrackLabel,n,a])}else ga("send","event",o.gaTrackLabel,n,a)}o.newWindow?(window.open(a,o.titleWindow,"height="+o.heightWindow+", width="+o.widthWindow),$.isFunction(o.navigateState)&&o.navigateState(a,1)):(window.open(a,"_blank"),$.isFunction(o.navigateState)&&o.navigateState(a,2)),$(".modalBG, .modal-dialog").remove()},{init:initialize,closeModal:closeModal,navigate:navigateLocation}}();
{
"name": "exlink",
"version": "2.2.1",
"version": "2.3.0",
"description": "jQuery.exLink forces all external links (specified by protocol) and documents (specified by format) to open in a new tab. jQuery.exLink also suports a viausal notification that users are navigating to an external site, or opening a document.",

@@ -5,0 +5,0 @@ "main": "jquery.exLink.js",

@@ -10,5 +10,5 @@ jQuery exLink

**Current Version:** 2.2.1
**Current Version:** 2.3.0
**Release Date:** August 26, 2015
**Release Date:** November 20, 2015

@@ -110,6 +110,10 @@

**linkWarning** - Display a warning notifying the user that they are navigating to an external link. By default, this is enabled. Ex: linkWarning: true
**navigateCallback** - New in version 2.3.0, if set, this exLink will make the callback to the desired function with the element clicked, if the link was a file (1) or external website (2), and if a warning dialog was displayed (true) or not (false).
**fileWarning** - Similar to linkWarning, this notifies the user that they are opening a document and asks for confirmation ot proceed. By default, this is also enabled. Ex: fileWarning: true
**navigateState** - New in version 2.3.0, this options enables a callback for each link opened by exLink. Included in the callback is the link clicked and if the link was opened in a new window (1) or a new tab (2).
**linkWarning** - Removed in version 2.3.0: Display a warning notifying the user that they are navigating to an external link. By default, this is enabled. Ex: linkWarning: true
**fileWarning** - Removed in version 2.3.0: Similar to linkWarning, this notifies the user that they are opening a document and asks for confirmation ot proceed. By default, this is also enabled. Ex: fileWarning: true
**hostCompare** - New in version 1.2.0, set this as true to identify external links based on a hostname comparison. If false, which is the default case, exLink will identify the external links based on protocol information. By default, this is disabled. Ex: hostCompare: true

@@ -121,6 +125,2 @@

**linkCallback** - Added in version 1.2.7, this enables developers to execute a function each time an external link has been clicked. This returns the object clicked, and an indication if a warning dialog was displayed or not. This is null by default. Ex: linkCallback: callback
**fileCallback** - New in version 1.2.7, this enables developers to execute a function each time a document link has been clicked. This returns the object clicked, and an indication if a warning dialog was displayed or not. This is null by default. Ex: fileCallback: docCallback
**gaTracking** - Introduced in version 2.0.2, this option enables a Google Analytics event to trigger when any of the links are clicked. Classic and Universeral analytics supported. This is a boolean value set to false by default. Ex: gaTracking: false

@@ -170,2 +170,10 @@

######Deprecated Options & Methods
**linkCallback** - Removed in version 2.3.0: Added in version 1.2.7, this enables developers to execute a function each time an external link has been clicked. This returns the object clicked, and an indication if a warning dialog was displayed or not. This is null by default. (Replaced by navigateCallback) Ex: linkCallback: callback
**fileCallback** - Removed in version 2.3.0: New in version 1.2.7, this enables developers to execute a function each time a document link has been clicked. This returns the object clicked, and an indication if a warning dialog was displayed or not. This is null by default. (Replaced by navigateCallback) Ex: fileCallback: docCallback
**exLink.init('re')** - Removed in version 2.3.0: The need to re-initialize exLink after new content has been added via AJAX is no longer necessary. exLink automatically detects these changes.
exLink Demo & Other Stuffs

@@ -176,3 +184,2 @@ ==

- [jQuery.exLink Demo](http://www.yupitszac.com/demo/jquery-exlink)
- [exLink on npm](http://www.npmjs.com/package/exlink)

@@ -211,3 +218,3 @@ - [exLink on jQuer.in](http://www.jquer.in/helpful-jquery-plugins-for-html5-websites/exlink/)

3). If you are loading content via AJAX or will be adding any content after exLink has been initialized, you'll need to reinitialize the plugin. If you specify the string 're' as your options, then the options will not be affected and all external links/documents will be redetected to account for your new additions.
3). DEPRECATED 2.3.0: If you are loading content via AJAX or will be adding any content after exLink has been initialized, you'll need to reinitialize the plugin. If you specify the string 're' as your options, then the options will not be affected and all external links/documents will be redetected to account for your new additions.

@@ -230,3 +237,3 @@ ```javascript

6). If you choose to use the linkCallback or fileCallback options, your callback function may look something like this:
6). Prior to version 2.3.0, if you choose to use the linkCallback or fileCallback options, your callback function may look something like this:

@@ -242,3 +249,33 @@ ```javascript

7). After version 2.3.0, if you choose to use the navigateCallback option, your callback might look something like this:
```javascript
//obj is the object clicked
//type is the type of link clicked: 1 = file, 2 = external website
//warn indicates if a warning dialog was displayed - true/false
function callback(obj, type, warn) {
console.log('Object: '.obj);
console.log('Link Type: '.type);
console.log('Warning: '.warn);
}
```
7). After version 2.3.0, if you choose to use the navigateState option, your callback might look something like this:
```javascript
//href is the link opened
//type is the type of link: 1 = file, 2 = external website
function callback(obj, type, warn) {
console.log('Link Href: '.href);
console.log('Link Type: '.type);
}
```
Help & Support

@@ -245,0 +282,0 @@ ===

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc