Commit ae85abb9 authored by Dries's avatar Dries

- Patch #955610 by casey: impossible to have multiple node forms on one page due to fixed IDs.

parent e920fe34
......@@ -4,8 +4,8 @@
Drupal.behaviors.bookFieldsetSummaries = {
attach: function (context) {
$('fieldset#edit-book', context).drupalSetSummary(function (context) {
var val = $('#edit-book-bid').val();
$('fieldset.book-form', context).drupalSetSummary(function (context) {
var val = $('.form-item-book-bid select').val();
if (val === '0') {
return Drupal.t('Not in book');
......@@ -14,7 +14,7 @@ Drupal.behaviors.bookFieldsetSummaries = {
return Drupal.t('New book');
}
else {
return Drupal.checkPlain($('#edit-book-bid :selected').text());
return Drupal.checkPlain($('.form-item-book-bid select :selected').text());
}
});
}
......
......@@ -488,6 +488,9 @@ function _book_add_form_elements(&$form, &$form_state, $node) {
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'additional_settings',
'#attributes' => array(
'class' => array('book-form'),
),
'#attached' => array(
'js' => array(drupal_get_path('module', 'book') . '/book.js'),
),
......
......@@ -4,24 +4,25 @@
Drupal.behaviors.commentFieldsetSummaries = {
attach: function (context) {
$('fieldset#edit-comment-settings', context).drupalSetSummary(function (context) {
return Drupal.checkPlain($('input:checked', context).next('label').text());
$('fieldset.comment-node-settings-form', context).drupalSetSummary(function (context) {
return Drupal.checkPlain($('.form-item-comment input:checked', context).next('label').text());
});
// Provide the summary for the node type form.
$('fieldset#edit-comment', context).drupalSetSummary(function(context) {
$('fieldset.comment-node-type-settings-form', context).drupalSetSummary(function(context) {
var vals = [];
// Default comment setting.
vals.push($("select[name='comment'] option:selected", context).text());
vals.push($(".form-item-comment select option:selected", context).text());
// Threading.
var threading = $("input[name='comment_default_mode']:checked", context).next('label').text();
var threading = $(".form-item-comment-default-mode input:checked", context).next('label').text();
if (threading) {
vals.push(threading);
}
// Comments per page.
var number = $("select[name='comment_default_per_page'] option:selected", context).val();
var number = $(".form-item-comment-default-per-page select option:selected", context).val();
vals.push(Drupal.t('@number comments per page', {'@number': number}));
return Drupal.checkPlain(vals.join(', '));
......
......@@ -1093,6 +1093,9 @@ function comment_form_node_type_form_alter(&$form, $form_state) {
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'additional_settings',
'#attributes' => array(
'class' => array('comment-node-type-settings-form'),
),
'#attached' => array(
'js' => array(drupal_get_path('module', 'comment') . '/comment-node-form.js'),
),
......@@ -1164,6 +1167,9 @@ function comment_form_node_form_alter(&$form, $form_state) {
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'additional_settings',
'#attributes' => array(
'class' => array('comment-node-settings-form'),
),
'#attached' => array(
'js' => array(drupal_get_path('module', 'comment') . '/comment-node-form.js'),
),
......@@ -1188,7 +1194,6 @@ function comment_form_node_form_alter(&$form, $form_state) {
'#description' => t('Users with the "Post comments" permission can post comments.'),
'#return_value' => COMMENT_NODE_OPEN,
'#default_value' => $comment_settings,
'#id' => 'edit-comment-2',
'#parents' => array('comment'),
),
COMMENT_NODE_CLOSED => array(
......@@ -1197,7 +1202,6 @@ function comment_form_node_form_alter(&$form, $form_state) {
'#description' => t('Users cannot post comments, but existing comments will be displayed.'),
'#return_value' => COMMENT_NODE_CLOSED,
'#default_value' => $comment_settings,
'#id' => 'edit-comment-1',
'#parents' => array('comment'),
),
COMMENT_NODE_HIDDEN => array(
......@@ -1206,7 +1210,6 @@ function comment_form_node_form_alter(&$form, $form_state) {
'#description' => t('Comments are hidden from view.'),
'#return_value' => COMMENT_NODE_HIDDEN,
'#default_value' => $comment_settings,
'#id' => 'edit-comment-0',
'#parents' => array('comment'),
),
);
......
......@@ -5,8 +5,8 @@
Drupal.behaviors.menuFieldsetSummaries = {
attach: function (context) {
$('fieldset.menu-link-form', context).drupalSetSummary(function (context) {
if ($('#edit-menu-enabled', context).attr('checked')) {
return Drupal.checkPlain($('#edit-menu-link-title', context).val());
if ($('.form-item-menu-enabled input', context).is(':checked')) {
return Drupal.checkPlain($('.form-item-menu-link-title input', context).val());
}
else {
return Drupal.t('Not in menu');
......@@ -20,44 +20,46 @@ Drupal.behaviors.menuFieldsetSummaries = {
*/
Drupal.behaviors.menuLinkAutomaticTitle = {
attach: function (context) {
// Try to find menu settings widget elements as well as a 'title' field in
// the form, but play nicely with user permissions and form alterations.
var $checkbox = $('fieldset.menu-link-form #edit-menu-enabled', context);
var $link_title = $('#edit-menu-link-title', context);
var $title = $('#edit-title', context);
// Bail out if we do not have all required fields.
if (!($checkbox.length && $link_title.length && $title.length)) {
return;
}
// If there is a link title already, mark it as overridden. The user expects
// that toggling the checkbox twice will take over the node's title.
if ($checkbox.attr('checked') && $link_title.val().length) {
$link_title.data('menuLinkAutomaticTitleOveridden', true);
}
// Whenever the value is changed manually, disable this behavior.
$link_title.keyup(function () {
$link_title.data('menuLinkAutomaticTitleOveridden', true);
});
// Global trigger on checkbox (do not fill-in a value when disabled).
$checkbox.change(function () {
if ($checkbox.attr('checked')) {
if (!$link_title.data('menuLinkAutomaticTitleOveridden')) {
$link_title.val($title.val());
}
}
else {
$link_title.val('');
$link_title.removeData('menuLinkAutomaticTitleOveridden');
$('fieldset.menu-link-form', context).each(function () {
// Try to find menu settings widget elements as well as a 'title' field in
// the form, but play nicely with user permissions and form alterations.
var $checkbox = $('.form-item-menu-enabled input', this);
var $link_title = $('.form-item-menu-link-title input', context);
var $title = $(this).closest('form').find('.form-item-title input');
// Bail out if we do not have all required fields.
if (!($checkbox.length && $link_title.length && $title.length)) {
return;
}
$checkbox.closest('fieldset.vertical-tabs-pane').trigger('summaryUpdated');
$checkbox.trigger('formUpdated');
});
// Take over any title change.
$title.keyup(function () {
if (!$link_title.data('menuLinkAutomaticTitleOveridden') && $checkbox.attr('checked')) {
$link_title.val($title.val());
$link_title.val($title.val()).trigger('formUpdated');
// If there is a link title already, mark it as overridden. The user expects
// that toggling the checkbox twice will take over the node's title.
if ($checkbox.is(':checked') && $link_title.val().length) {
$link_title.data('menuLinkAutomaticTitleOveridden', true);
}
// Whenever the value is changed manually, disable this behavior.
$link_title.keyup(function () {
$link_title.data('menuLinkAutomaticTitleOveridden', true);
});
// Global trigger on checkbox (do not fill-in a value when disabled).
$checkbox.change(function () {
if ($checkbox.is(':checked')) {
if (!$link_title.data('menuLinkAutomaticTitleOveridden')) {
$link_title.val($title.val());
}
}
else {
$link_title.val('');
$link_title.removeData('menuLinkAutomaticTitleOveridden');
}
$checkbox.closest('fieldset.vertical-tabs-pane').trigger('summaryUpdated');
$checkbox.trigger('formUpdated');
});
// Take over any title change.
$title.keyup(function () {
if (!$link_title.data('menuLinkAutomaticTitleOveridden') && $checkbox.is(':checked')) {
$link_title.val($title.val());
$link_title.val($title.val()).trigger('formUpdated');
}
});
});
}
};
......
......@@ -4,28 +4,28 @@
Drupal.behaviors.nodeFieldsetSummaries = {
attach: function (context) {
$('fieldset#edit-revision-information', context).drupalSetSummary(function (context) {
return $('#edit-revision', context).is(':checked') ?
$('fieldset.node-form-revision-information', context).drupalSetSummary(function (context) {
return $('.form-item-revision input', context).is(':checked') ?
Drupal.t('New revision') :
Drupal.t('No revision');
});
$('fieldset#edit-author', context).drupalSetSummary(function (context) {
var name = $('#edit-name').val() || Drupal.settings.anonymous,
date = $('#edit-date').val();
$('fieldset.node-form-author', context).drupalSetSummary(function (context) {
var name = $('.form-item-name input', context).val() || Drupal.settings.anonymous,
date = $('.form-item-date input', context).val();
return date ?
Drupal.t('By @name on @date', { '@name': name, '@date': date }) :
Drupal.t('By @name', { '@name': name });
});
$('fieldset#edit-options', context).drupalSetSummary(function (context) {
$('fieldset.node-form-options', context).drupalSetSummary(function (context) {
var vals = [];
$('input:checked', context).parent().each(function () {
vals.push(Drupal.checkPlain($.trim($(this).text())));
});
if (!$('#edit-status', context).is(':checked')) {
if (!$('.form-item-status input', context).is(':checked')) {
vals.unshift(Drupal.t('Not published'));
}
return vals.join(', ');
......
......@@ -166,6 +166,9 @@ function node_form($form, &$form_state, $node) {
// Collapsed by default when "Create new revision" is unchecked
'#collapsed' => !$node->revision,
'#group' => 'additional_settings',
'#attributes' => array(
'class' => array('node-form-revision-information'),
),
'#attached' => array(
'js' => array(drupal_get_path('module', 'node') . '/node.js'),
),
......@@ -204,6 +207,9 @@ function node_form($form, &$form_state, $node) {
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'additional_settings',
'#attributes' => array(
'class' => array('node-form-author'),
),
'#attached' => array(
'js' => array(
drupal_get_path('module', 'node') . '/node.js',
......@@ -240,6 +246,9 @@ function node_form($form, &$form_state, $node) {
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'additional_settings',
'#attributes' => array(
'class' => array('node-form-options'),
),
'#attached' => array(
'js' => array(drupal_get_path('module', 'node') . '/node.js'),
),
......
......@@ -4,8 +4,8 @@
Drupal.behaviors.pathFieldsetSummaries = {
attach: function (context) {
$('fieldset#edit-path', context).drupalSetSummary(function (context) {
var path = $('#edit-path-alias').val();
$('fieldset.path-form', context).drupalSetSummary(function (context) {
var path = $('.form-item-path-alias input').val();
return path ?
Drupal.t('Alias: @alias', { '@alias': path }) :
......
......@@ -119,6 +119,9 @@ function path_form_node_form_alter(&$form, $form_state) {
'#collapsible' => TRUE,
'#collapsed' => empty($path['alias']),
'#group' => 'additional_settings',
'#attributes' => array(
'class' => array('path-form'),
),
'#attached' => array(
'js' => array(drupal_get_path('module', 'path') . '/path.js'),
),
......
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