non security modules update
This commit is contained in:
@@ -1,20 +1,27 @@
|
||||
(function ($) {
|
||||
|
||||
function extlinkAttach(context) {
|
||||
Drupal.extlink = Drupal.extlink || {};
|
||||
|
||||
Drupal.extlink.attach = function (context, settings) {
|
||||
if (!settings.hasOwnProperty('extlink')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Strip the host name down, removing ports, subdomains, or www.
|
||||
var pattern = /^(([^\/:]+?\.)*)([^\.:]{4,})((\.[a-z]{1,4})*)(:[0-9]{1,5})?$/;
|
||||
var host = window.location.host.replace(pattern, '$3$4');
|
||||
var subdomain = window.location.host.replace(pattern, '$1');
|
||||
|
||||
// Determine what subdomains are considered internal.
|
||||
if (Drupal.settings.extlink.extSubdomains) {
|
||||
var subdomains = "([^/]*\\.)?";
|
||||
var subdomains;
|
||||
if (settings.extlink.extSubdomains) {
|
||||
subdomains = "([^/]*\\.)?";
|
||||
}
|
||||
else if (subdomain == 'www.' || subdomain == '') {
|
||||
var subdomains = "(www\\.)?";
|
||||
subdomains = "(www\\.)?";
|
||||
}
|
||||
else {
|
||||
var subdomains = subdomain.replace(".", "\\.");
|
||||
subdomains = subdomain.replace(".", "\\.");
|
||||
}
|
||||
|
||||
// Build regular expressions that define an internal link.
|
||||
@@ -22,29 +29,29 @@ function extlinkAttach(context) {
|
||||
|
||||
// Extra internal link matching.
|
||||
var extInclude = false;
|
||||
if (Drupal.settings.extlink.extInclude) {
|
||||
extInclude = new RegExp(Drupal.settings.extlink.extInclude.replace(/\\/, '\\'));
|
||||
if (settings.extlink.extInclude) {
|
||||
extInclude = new RegExp(settings.extlink.extInclude.replace(/\\/, '\\'), "i");
|
||||
}
|
||||
|
||||
// Extra external link matching.
|
||||
var extExclude = false;
|
||||
if (Drupal.settings.extlink.extExclude) {
|
||||
extExclude = new RegExp(Drupal.settings.extlink.extExclude.replace(/\\/, '\\'));
|
||||
if (settings.extlink.extExclude) {
|
||||
extExclude = new RegExp(settings.extlink.extExclude.replace(/\\/, '\\'), "i");
|
||||
}
|
||||
|
||||
// Extra external link CSS selector exclusion.
|
||||
var extCssExclude = false;
|
||||
if (Drupal.settings.extlink.extCssExclude) {
|
||||
extCssExclude = Drupal.settings.extlink.extCssExclude;
|
||||
if (settings.extlink.extCssExclude) {
|
||||
extCssExclude = settings.extlink.extCssExclude;
|
||||
}
|
||||
|
||||
// Extra external link CSS selector explicit.
|
||||
var extCssExplicit = false;
|
||||
if (Drupal.settings.extlink.extCssExplicit) {
|
||||
extCssExplicit = Drupal.settings.extlink.extCssExplicit;
|
||||
if (settings.extlink.extCssExplicit) {
|
||||
extCssExplicit = settings.extlink.extCssExplicit;
|
||||
}
|
||||
|
||||
// Find all links which are NOT internal and begin with http (as opposed
|
||||
// Find all links which are NOT internal and begin with http as opposed
|
||||
// to ftp://, javascript:, etc. other kinds of links.
|
||||
// When operating on the 'this' variable, the host has been appended to
|
||||
// all links by the browser, even local ones.
|
||||
@@ -52,75 +59,103 @@ function extlinkAttach(context) {
|
||||
// available in jQuery 1.0 (Drupal 5 default).
|
||||
var external_links = new Array();
|
||||
var mailto_links = new Array();
|
||||
$("a:not(." + Drupal.settings.extlink.extClass + ", ." + Drupal.settings.extlink.mailtoClass + "), area:not(." + Drupal.settings.extlink.extClass + ", ." + Drupal.settings.extlink.mailtoClass + ")", context).each(function(el) {
|
||||
$("a:not(." + settings.extlink.extClass + ", ." + settings.extlink.mailtoClass + "), area:not(." + settings.extlink.extClass + ", ." + settings.extlink.mailtoClass + ")", context).each(function(el) {
|
||||
try {
|
||||
var url = this.href.toLowerCase();
|
||||
if (url.indexOf('http') == 0
|
||||
&& (!url.match(internal_link) || (extInclude && url.match(extInclude)))
|
||||
&& !(extExclude && url.match(extExclude))
|
||||
&& !(extCssExclude && $(this).parents(extCssExclude).length > 0)
|
||||
&& !(extCssExplicit && $(this).parents(extCssExplicit).length < 1)) {
|
||||
if (url.indexOf('http') == 0
|
||||
&& ((!url.match(internal_link) && !(extExclude && url.match(extExclude))) || (extInclude && url.match(extInclude)))
|
||||
&& !(extCssExclude && $(this).parents(extCssExclude).length > 0)
|
||||
&& !(extCssExplicit && $(this).parents(extCssExplicit).length < 1)) {
|
||||
external_links.push(this);
|
||||
}
|
||||
// Do not include area tags with begin with mailto: (this prohibits
|
||||
// icons from being added to image-maps).
|
||||
else if (this.tagName != 'AREA'
|
||||
&& url.indexOf('mailto:') == 0
|
||||
&& !(extCssExclude && $(this).parents(extCssExclude).length > 0)
|
||||
&& !(extCssExplicit && $(this).parents(extCssExplicit).length < 1)) {
|
||||
&& url.indexOf('mailto:') == 0
|
||||
&& !(extCssExclude && $(this).parents(extCssExclude).length > 0)
|
||||
&& !(extCssExplicit && $(this).parents(extCssExplicit).length < 1)) {
|
||||
mailto_links.push(this);
|
||||
}
|
||||
}
|
||||
// IE7 throws errors often when dealing with irregular links, such as:
|
||||
// <a href="node/10"></a> Empty tags.
|
||||
// <a href="http://user:pass@example.com">example</a> User:pass syntax.
|
||||
catch(error) {
|
||||
catch (error) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if (Drupal.settings.extlink.extClass) {
|
||||
// Apply the "ext" class to all links not containing images.
|
||||
if (parseFloat($().jquery) < 1.2) {
|
||||
$(external_links).not('[img]').addClass(Drupal.settings.extlink.extClass).each(function() { if ($(this).css('display') == 'inline') $(this).after('<span class=' + Drupal.settings.extlink.extClass + '></span>'); });
|
||||
}
|
||||
else {
|
||||
$(external_links).not($(external_links).find('img').parents('a')).addClass(Drupal.settings.extlink.extClass).each(function() { if ($(this).css('display') == 'inline') $(this).after('<span class=' + Drupal.settings.extlink.extClass + '></span>'); });
|
||||
}
|
||||
if (settings.extlink.extClass) {
|
||||
Drupal.extlink.applyClassAndSpan(external_links, settings.extlink.extClass);
|
||||
}
|
||||
|
||||
if (Drupal.settings.extlink.mailtoClass) {
|
||||
// Apply the "mailto" class to all mailto links not containing images.
|
||||
if (parseFloat($().jquery) < 1.2) {
|
||||
$(mailto_links).not('[img]').addClass(Drupal.settings.extlink.mailtoClass).each(function() { if ($(this).css('display') == 'inline') $(this).after('<span class=' + Drupal.settings.extlink.mailtoClass + '></span>'); });
|
||||
}
|
||||
else {
|
||||
$(mailto_links).not($(mailto_links).find('img').parents('a')).addClass(Drupal.settings.extlink.mailtoClass).each(function() { if ($(this).css('display') == 'inline') $(this).after('<span class=' + Drupal.settings.extlink.mailtoClass + '></span>'); });
|
||||
}
|
||||
if (settings.extlink.mailtoClass) {
|
||||
Drupal.extlink.applyClassAndSpan(mailto_links, settings.extlink.mailtoClass);
|
||||
}
|
||||
|
||||
if (Drupal.settings.extlink.extTarget) {
|
||||
if (settings.extlink.extTarget) {
|
||||
// Apply the target attribute to all links.
|
||||
$(external_links).attr('target', Drupal.settings.extlink.extTarget);
|
||||
$(external_links).attr('target', settings.extlink.extTarget);
|
||||
}
|
||||
|
||||
if (Drupal.settings.extlink.extAlert) {
|
||||
// Add pop-up click-through dialog.
|
||||
$(external_links).click(function(e) {
|
||||
return confirm(Drupal.settings.extlink.extAlertText);
|
||||
});
|
||||
}
|
||||
Drupal.extlink = Drupal.extlink || {};
|
||||
|
||||
// Work around for Internet Explorer box model problems.
|
||||
if (($.support && !($.support.boxModel === undefined) && !$.support.boxModel) || ($.browser.msie && parseInt($.browser.version) <= 7)) {
|
||||
$('span.ext, span.mailto').css('display', 'inline-block');
|
||||
}
|
||||
}
|
||||
// Set up default click function for the external links popup. This should be
|
||||
// overridden by modules wanting to alter the popup.
|
||||
Drupal.extlink.popupClickHandler = Drupal.extlink.popupClickHandler || function() {
|
||||
if (settings.extlink.extAlert) {
|
||||
return confirm(settings.extlink.extAlertText);
|
||||
}
|
||||
}
|
||||
|
||||
Drupal.behaviors.extlink = {
|
||||
attach: function(context){
|
||||
$(external_links).click(function(e) {
|
||||
return Drupal.extlink.popupClickHandler(e);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Apply a class and a trailing <span> to all links not containing images.
|
||||
*
|
||||
* @param links
|
||||
* An array of DOM elements representing the links.
|
||||
* @param class_name
|
||||
* The class to apply to the links.
|
||||
*/
|
||||
Drupal.extlink.applyClassAndSpan = function (links, class_name) {
|
||||
var $links_to_process;
|
||||
if (Drupal.settings.extlink.extImgClass){
|
||||
$links_to_process = $(links);
|
||||
}
|
||||
else {
|
||||
var links_with_images = $(links).find('img').parents('a');
|
||||
$links_to_process = $(links).not(links_with_images);
|
||||
}
|
||||
$links_to_process.addClass(class_name);
|
||||
var i;
|
||||
var length = $links_to_process.length;
|
||||
for (i = 0; i < length; i++) {
|
||||
var $link = $($links_to_process[i]);
|
||||
if ($link.css('display') == 'inline' || $link.css('display') == 'inline-block') {
|
||||
if (class_name == Drupal.settings.extlink.mailtoClass) {
|
||||
$link.append('<span class="' + class_name + '"><span class="element-invisible"> ' + Drupal.settings.extlink.mailtoLabel + '</span></span>');
|
||||
}
|
||||
else {
|
||||
$link.append('<span class="' + class_name + '"><span class="element-invisible"> ' + Drupal.settings.extlink.extLabel + '</span></span>');
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.behaviors.extlink = Drupal.behaviors.extlink || {};
|
||||
Drupal.behaviors.extlink.attach = function (context, settings) {
|
||||
// Backwards compatibility, for the benefit of modules overriding extlink
|
||||
// functionality by defining an "extlinkAttach" global function.
|
||||
if (typeof extlinkAttach === 'function') {
|
||||
extlinkAttach(context);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Drupal.extlink.attach(context, settings);
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
Reference in New Issue
Block a user