/*
* Linkit javascript lib
*/
var linkit_helper = {};
(function ($) {
linkit_helper = {
/*
* Makes an AJAX requst when a link is about to be edited with Linkit
*/
search_styled_link : function(string) {
$('#linkit .form-item-link input').hide();
$('#linkit .form-item-link label').after($('').addClass('throbber').html('' + Drupal.t('Loading path...') + ''));
// DO AJAX!
var result = $.get(Drupal.settings.linkit.ajaxcall, { string: string } , function(data) {
if(data) {
$('#linkit #edit-link--2').val(data);
$('#linkit .form-item-link .throbber').remove();
$('#linkit .form-item-link input').show();
} else {
$('#linkit #edit-link--2').val(string);
$('#linkit .form-item-link .throbber').remove();
$('#linkit .form-item-link input').show();
}
});
},
/*
* Show helper text
* If there is no selection, the link text will be the result title.
*/
show_no_selection_text : function() {
var info_text = Drupal.t('Notice: No selection element was found, your link text will appear as the item title you are linking to.');
$('#linkit .form-item-link').prepend(info_text);
},
/*
* IMCE integration
*/
openFileBrowser : function () {
window.open(decodeURIComponent(Drupal.settings.linkit.IMCEurl), '', 'width=760,height=560,resizable=1');
},
/*
* See if the link contains a #anchor
*/
seek_for_anchor : function(href) {
var matches = href.match(/.*(#.*)/i);
anchor = (matches == null) ? '' : matches[1].substring(1);
return anchor;
}
}
Drupal.behaviors.linkit_imce = {
attach: function(context, settings) {
$('#linkit-imce').click(function() {
linkit_helper.openFileBrowser();
return false;
});
}
}
})(jQuery);