Skip to content
Snippets Groups Projects
Commit 4a9c3187 authored by Lachlan Ennis's avatar Lachlan Ennis
Browse files

Merge branch '7.x-1.x' of git.drupal.org:project/extlink into 7.x-1.x

parents 3a05b22a ba6b8ec4
No related branches found
No related tags found
No related merge requests found
......@@ -3,12 +3,14 @@ span.ext {
width: 10px;
height: 10px;
padding-right: 12px;
text-decoration: none;
}
span.mailto {
background: url(extlink_s.png) -20px center no-repeat;
width: 10px;
height: 10px;
padding-right: 12px;
text-decoration: none;
}
/* Hide the extra spans when printing. */
......
......@@ -15,3 +15,10 @@ function extlink_uninstall() {
db_query("DELETE FROM {variable} WHERE name LIKE 'extlink_%'");
cache_clear_all('variables', 'cache');
}
/**
* Delete "extlink_target_value" variable (now uses "extlink_target" directly).
*/
function extlink_update_7101(&$sandbox) {
variable_del('extlink_target_value');
}
......@@ -30,13 +30,13 @@ Drupal.extlink.attach = function (context, settings) {
// Extra internal link matching.
var extInclude = false;
if (settings.extlink.extInclude) {
extInclude = new RegExp(settings.extlink.extInclude.replace(/\\/, '\\'));
extInclude = new RegExp(settings.extlink.extInclude.replace(/\\/, '\\'), "i");
}
// Extra external link matching.
var extExclude = false;
if (settings.extlink.extExclude) {
extExclude = new RegExp(settings.extlink.extExclude.replace(/\\/, '\\'));
extExclude = new RegExp(settings.extlink.extExclude.replace(/\\/, '\\'), "i");
}
// Extra external link CSS selector exclusion.
......@@ -63,8 +63,7 @@ Drupal.extlink.attach = function (context, settings) {
try {
var url = this.href.toLowerCase();
if (url.indexOf('http') == 0
&& (!url.match(internal_link) && !(extExclude && url.match(extExclude)))
|| (extInclude && url.match(extInclude))
&& ((!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);
......@@ -96,7 +95,7 @@ Drupal.extlink.attach = function (context, settings) {
if (settings.extlink.extTarget) {
// Apply the target attribute to all links.
$(external_links).attr('target', settings.extlink.extTargetValue);
$(external_links).attr('target', settings.extlink.extTarget);
}
Drupal.extlink = Drupal.extlink || {};
......@@ -112,11 +111,6 @@ Drupal.extlink.attach = function (context, settings) {
$(external_links).click(function(e) {
return Drupal.extlink.popupClickHandler(e);
});
// 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');
}
};
/**
......@@ -129,16 +123,11 @@ Drupal.extlink.attach = function (context, settings) {
*/
Drupal.extlink.applyClassAndSpan = function (links, class_name) {
var $links_to_process;
if(Drupal.settings.extlink.extImgClass){
if (Drupal.settings.extlink.extImgClass){
$links_to_process = $(links);
}else {
if (parseFloat($().jquery) < 1.2) {
$links_to_process = $(links).not('[img]');
}
else {
var links_with_images = $(links).find('img').parents('a');
$links_to_process = $(links).not(links_with_images);
}
}
else {
$links_to_process = $(links).not('[img]');
}
$links_to_process.addClass(class_name);
var i;
......@@ -147,9 +136,10 @@ Drupal.extlink.applyClassAndSpan = function (links, class_name) {
var $link = $($links_to_process[i]);
if ($link.css('display') == 'inline' || $link.css('display') == 'inline-block') {
if (class_name == Drupal.settings.extlink.mailtoClass) {
$link.after('<span class=' + class_name + '><div class="element-invisible">' + Drupal.t('Email links icon') + '</div></span>');
}else {
$link.after('<span class=' + class_name + '><div class="element-invisible">' + Drupal.t('External Links icon') + '</div></span>');
$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>');
}
}
}
......
......@@ -23,8 +23,8 @@ function extlink_page_build() {
drupal_add_js($path .'/extlink.js', array('every_page' => TRUE));
drupal_add_js(array('extlink' => array(
'extTarget' => variable_get('extlink_target', 0),
'extTargetValue'=> variable_get('extlink_target_value', ''),
'extClass' => variable_get('extlink_class', 'ext'),
'extLabel' => check_plain(variable_get('extlink_label', t('(link is external)'))),
'extImgClass' => variable_get('extlink_img_class', 0),
'extSubdomains' => variable_get('extlink_subdomains', 1),
'extExclude' => variable_get('extlink_exclude', ''),
......@@ -33,8 +33,9 @@ function extlink_page_build() {
'extCssExplicit' => variable_get('extlink_css_explicit', ''),
'extAlert' => variable_get('extlink_alert', 0),
'extAlertText' => variable_get('extlink_alert_text', 'This link will take you to an external web site. We are not responsible for their content.'),
'mailtoClass' => variable_get('extlink_mailto_class', 'mailto'))), 'setting'
);
'mailtoClass' => variable_get('extlink_mailto_class', 'mailto'),
'mailtoLabel' => check_plain(variable_get('extlink_mailto_label', t('(link sends e-mail)'))),
)), 'setting');
}
function extlink_admin_settings() {
......@@ -77,20 +78,6 @@ function extlink_admin_settings() {
'#return_value' => '_blank',
'#default_value' => variable_get('extlink_target', 0),
);
$form['extlink_target_value'] = array(
'#type' => 'textarea',
'#title' => t('Target value for new window.'),
'#rows' => 1,
'#default_value' => variable_get('extlink_target_value', '_blank'),
'#wysiwyg' => FALSE,
'#states' => array(
// Only show this field when user opts to open in new window.
'visible' => array(
':input[name="extlink_target"]' => array('checked' => TRUE),
),
),
);
$form['extlink_alert'] = array(
'#type' => 'checkbox',
......@@ -114,16 +101,16 @@ function extlink_admin_settings() {
);
$patterns = array(
'<em>(example\.com)</em> ' . t('Matches example.com.'),
'<em>(example\.com)|(example\.net)</em> ' . t('Multiple patterns can be strung together by using a pipe. Matches example.com OR example.net.'),
'<em>(links/goto/[0-9]+/[0-9]+)</em> ' . t('Matches links that go through the <a href="http://drupal.org/project/links">Links module</a> redirect.'),
'<code>(example\.com)</code> ' . t('Matches example.com.'),
'<code>(example\.com)|(example\.net)</code> ' . t('Multiple patterns can be strung together by using a pipe. Matches example.com OR example.net.'),
'<code>(links/goto/[0-9]+/[0-9]+)</code> ' . t('Matches links that go through the <a href="http://drupal.org/project/links">Links module</a> redirect.'),
);
$wildcards = array(
'<em>.</em> ' . t('Matches any character.'),
'<em>?</em> ' . t('The previous character or set is optional.'),
'<em>\d</em> ' . t('Matches any digit (0-9).'),
'<em>[a-z]</em> ' . t('Brackets may be used to match a custom set of characters. This matches any alphabetic letter.'),
'<code>.</code> ' . t('Matches any character.'),
'<code>?</code> ' . t('The previous character or set is optional.'),
'<code>\d</code> ' . t('Matches any digit (0-9).'),
'<code>[a-z]</code> ' . t('Brackets may be used to match a custom set of characters. This matches any alphabetic letter.'),
);
$form['patterns'] = array(
......@@ -138,7 +125,7 @@ function extlink_admin_settings() {
theme('item_list', array('items' => $patterns)) .
t('Common special characters:') .
theme('item_list', array('items' => $wildcards)) .
'<p>' . t('All special characters (<em>^ $ . ? ( ) | * +</em>) must also be escaped with backslashes. Patterns are not case-sensitive. Any <a href="http://www.javascriptkit.com/javatutors/redev2.shtml">pattern supported by JavaScript</a> may be used.') . '</p>',
'<p>' . t('All special characters (!characters) must also be escaped with backslashes. Patterns are not case-sensitive. Any <a href="http://www.javascriptkit.com/javatutors/redev2.shtml">pattern supported by JavaScript</a> may be used.', array('!characters' => '<code>^ $ . ? ( ) | * +</code>')) . '</p>',
);
$form['patterns']['extlink_exclude'] = array(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment