Commit 2cfffe2d authored by iStryker's avatar iStryker
Browse files

Auto fill alt and title text and hide file url field

parent b692bb7c
......@@ -70,6 +70,14 @@ function intelligencebank_form_file_entity_add_upload_alter(&$form, &$form_state
// Swap the upload field for an embed field when on the first step of the web
// tab.
if ($form_id == 'intelligencebank_add_upload' && $step == 4) {
if (isset($form_state['values']['alt_text'])) {
$form['field_file_image_alt_text'][LANGUAGE_NONE][0]['value']['#default_value'] = $form_state['values']['alt_text'];
}
if (isset($form_state['values']['title_text'])) {
$form['field_file_image_title_text'][LANGUAGE_NONE][0]['value']['#default_value'] = $form_state['values']['title_text'];
}
}
if ($form_id == 'intelligencebank_add_upload' && $step == 1) {
unset($form['upload']);
......@@ -77,6 +85,12 @@ function intelligencebank_form_file_entity_add_upload_alter(&$form, &$form_state
'#type' => 'markup',
'#markup' => '<iframe style="width: 100%; min-height: 400px;" id="ib-iframe" src="https://ucprod.intelligencebank.com/app"></iframe>',
];
$form['alt_text'] = [
'#type' => 'hidden',
];
$form['title_text'] = [
'#type' => 'hidden',
];
$form['embed_code'] = [
'#type' => 'textfield',
......@@ -87,6 +101,8 @@ function intelligencebank_form_file_entity_add_upload_alter(&$form, &$form_state
// Explorer supports up to 2083 (http://support.microsoft.com/kb/208427)
// so we assume publicly available media URLs are within this limit.
'#maxlength' => 2083,
'#prefix' => '<div id="embed-code-hidden" style="display: none;">',
'#suffix' => '</div>',
'#required' => TRUE,
'#default_value' => isset($form_state['storage']['embed_code']) ? $form_state['storage']['embed_code'] : NULL,
];
......
(function ($) {
Drupal.behaviors.intelligenceBank = {
attach: function (context, settings) {
// requires jQuery 1.10
// $(window).on('message', function(e) {
......@@ -9,8 +8,12 @@
if (event.origin !== 'https://ucprod.intelligencebank.com') { return; }
var a = JSON.parse(e.data);
if ("resource_link" === a.action) {
var loadingMsg = "Loading file, please wait...</b><div class='ajax-progress'><div class='throbber'></div></div>";
var mediaBrowser = $('#mediaBrowser');
var loadingMsg = "Loading file, please wait...</b><div class='ajax-progress'><div class='throbber'></div></div>";
mediaBrowser.contents().find('#edit-embed-code').toggle();
mediaBrowser.contents().find('#embed-code-hidden').toggle();
mediaBrowser.contents().find('[name=alt_text').val(a.name);
mediaBrowser.contents().find('[name=title_text').val(a.name);
mediaBrowser.contents().find('#edit-embed-code').val(a.url);
mediaBrowser.contents().find('#ib-iframe').toggle();
mediaBrowser.contents().find('#edit-next').click();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment