Skip to content
Snippets Groups Projects
Commit 82a9d4f4 authored by drcolossos's avatar drcolossos Committed by Lachlan Ennis
Browse files
parent fd62a203
No related branches found
No related tags found
No related merge requests found
......@@ -51,6 +51,9 @@ Drupal.extlink.attach = function (context, settings) {
extCssExplicit = settings.extlink.extCssExplicit;
}
// Define the jQuery method (either 'append' or 'prepend') of placing the icon, defaults to 'append'
var extIconPlacement = settings.extlink.extIconPlacement || 'append';
// 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
......@@ -86,11 +89,11 @@ Drupal.extlink.attach = function (context, settings) {
});
if (settings.extlink.extClass) {
Drupal.extlink.applyClassAndSpan(external_links, settings.extlink.extClass);
Drupal.extlink.applyClassAndSpan(external_links, settings.extlink.extClass, extIconPlacement);
}
if (settings.extlink.mailtoClass) {
Drupal.extlink.applyClassAndSpan(mailto_links, settings.extlink.mailtoClass);
Drupal.extlink.applyClassAndSpan(mailto_links, settings.extlink.mailtoClass, extIconPlacement);
}
if (settings.extlink.extTarget) {
......@@ -120,8 +123,10 @@ Drupal.extlink.attach = function (context, settings) {
* An array of DOM elements representing the links.
* @param class_name
* The class to apply to the links.
* @param icon_placement
* 'append' or 'prepend' the icon to the link.
*/
Drupal.extlink.applyClassAndSpan = function (links, class_name) {
Drupal.extlink.applyClassAndSpan = function (links, class_name, icon_placement) {
var $links_to_process;
if (Drupal.settings.extlink.extImgClass){
$links_to_process = $(links);
......@@ -137,10 +142,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.append('<span class="' + class_name + '"><span class="element-invisible"> ' + Drupal.settings.extlink.mailtoLabel + '</span></span>');
$link[icon_placement]('<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>');
$link[icon_placement]('<span class="' + class_name + '"><span class="element-invisible"> ' + Drupal.settings.extlink.extLabel + '</span></span>');
}
}
}
......
......@@ -26,6 +26,7 @@ function extlink_page_build() {
'extClass' => variable_get('extlink_class', 'ext'),
'extLabel' => check_plain(variable_get('extlink_label', t('(link is external)'))),
'extImgClass' => variable_get('extlink_img_class', 0),
'extIconPlacement' => variable_get('extlink_icon_placement', 'append'),
'extSubdomains' => variable_get('extlink_subdomains', 1),
'extExclude' => variable_get('extlink_exclude', ''),
'extInclude' => variable_get('extlink_include', ''),
......@@ -65,6 +66,14 @@ function extlink_admin_settings() {
'#description' => t('If checked, images wrapped in an anchor tag will be treated as external links.'),
);
$form['extlink_icon_placement'] = array(
'#type' => 'checkbox',
'#title' => t('Add icon in front of any processed link'),
'#return_value' => 'prepend',
'#default_value' => variable_get('extlink_icon_placement', 'append'),
'#description' => t('If checked, the icon will be placed in front of any external link, otherwise it will be placed behind it.'),
);
$form['extlink_subdomains'] = array(
'#type' => 'checkbox',
'#title' => t('Exclude links with the same primary domain.'),
......
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