Index: includes/form.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/form.inc,v retrieving revision 1.220 diff -u -p -r1.220 form.inc --- includes/form.inc 10 Aug 2007 10:51:16 -0000 1.220 +++ includes/form.inc 21 Aug 2007 15:16:45 -0000 @@ -1578,15 +1578,16 @@ function form_expand_ahah($element) { // Adding the same javascript settings twice will cause a recursion error, // we avoid the problem by checking if the javascript has already been added. if (!isset($js_added[$element['#id']]) && isset($element['#ahah_event']) && isset($element['#ahah_path'])) { + drupal_add_js('misc/jquery.form.js'); drupal_add_js('misc/ahah.js'); drupal_add_js('misc/progress.js'); $ahah_binding = array( - 'id' => $element['#id'], - 'uri' => url($element['#ahah_path']), + 'uri' => url($element['#ahah_path']), 'event' => $element['#ahah_event'], - 'effect' => empty($element['#ahah_effect']) ? 'none' : $element['#ahah_effect'], - 'method' => empty($element['#ahah_method']) ? 'replace' : $element['#ahah_method'], + 'selector' => empty($element['#ahah_selector']) ? '#'. $element['#id'] : $element['#ahah_selector'], + 'effect' => empty($element['#ahah_effect']) ? 'none' : $element['#ahah_effect'], + 'method' => empty($element['#ahah_method']) ? 'replace' : $element['#ahah_method'], ); if (!empty($element['#ahah_wrapper'])) { Index: misc/ahah.js =================================================================== RCS file: /cvs/drupal/drupal/misc/ahah.js,v retrieving revision 1.1 diff -u -p -r1.1 ahah.js --- misc/ahah.js 4 Jul 2007 15:42:38 -0000 1.1 +++ misc/ahah.js 21 Aug 2007 15:16:45 -0000 @@ -31,6 +31,7 @@ Drupal.behaviors.ahah = function(context Drupal.ahah = function(base, element) { // Set the properties for this object. this.id = '#' + base; + this.selector = element.selector; this.event = element.event; this.uri = element.uri; this.wrapper = '#'+ element.wrapper; @@ -39,47 +40,88 @@ Drupal.ahah = function(base, element) { if (this.effect == 'none') { this.showEffect = 'show'; this.hideEffect = 'hide'; + this.showSpeed = ''; } else if (this.effect == 'fade') { this.showEffect = 'fadeIn'; this.hideEffect = 'fadeOut'; + this.showSpeed = 'slow'; } else { this.showEffect = this.effect + 'Toggle'; this.hideEffect = this.effect + 'Toggle'; + this.showSpeed = 'slow'; } - Drupal.redirectFormButton(this.uri, $(this.id).get(0), this); + + // Record the form action and target, needed for iFrame file uploads. + var form = $(this.id).parents('form'); + this.form_action = form.attr('action'); + this.form_target = form.attr('target'); + this.form_encattr = form.attr('encattr'); + + // Set the options for the ajaxSubmit function. + // The 'this' variable will not persist inside of the options object. + var ahah = this; + var options = { + url: ahah.uri, + beforeSubmit: function(form_values, element, options) { + return ahah.beforeSubmit(form_values, element, options); + }, + success: function(response, status) { + // Sanity check for browser support (object expected). + // When using iFrame uploads, responses must be returned as a string. + if (typeof(response) == 'string') { + response = Drupal.parseJson(response); + } + return ahah.success(response, status); + }, + complete: function(response, status) { + if (status == 'error') { + return ahah.error(response.responseText); + } + }, + dataType: 'json', + type: 'POST' + }; + + // Bind the ajaxSubmit function to the element event. + $(ahah.selector).bind(ahah.event, function() { + options.element = this; + $(ahah.id).parents('form').ajaxSubmit(options); + return false; + }); + }; /** * Handler for the form redirection submission. */ -Drupal.ahah.prototype.onsubmit = function () { +Drupal.ahah.prototype.beforeSubmit = function (form_values, element, options) { // Insert progressbar and stretch to take the same space. this.progress = new Drupal.progressBar('ahah_progress'); this.progress.setProgress(-1, Drupal.t('Please wait...')); var wrapper = $(this.wrapper); - var button = $(this.id); - var progress_element = $(this.progress.element); + var element = $(options.element); + var progress_element = $(this.progress.element).addClass('ahah-progress'); - progress_element.css('float', 'left').css({ - display: 'none', - width: '10em', - margin: '0 0 0 20px' - }); - button.css('float', 'left').attr('disabled', true).after(progress_element); - eval('progress_element.' + this.showEffect + '()'); + element.addClass('progress-disabled').attr('disabled', true).after(progress_element); }; /** * Handler for the form redirection completion. */ -Drupal.ahah.prototype.oncomplete = function (data) { +Drupal.ahah.prototype.success = function (response, status) { var wrapper = $(this.wrapper); - var button = $(this.id); + var element = $(this.id); + var form = element.parents('form'); var progress_element = $(this.progress.element); - var new_content = $('
' + data + '
'); + var new_content = $('
' + response.data + '
'); + + // Resore the previous action and target to the form. + form.attr('action', this.form_action); + this.form_target ? form.attr('target', this.form_target) : form.removeAttr('target'); + this.form_encattr ? form.attr('target', this.form_encattr) : form.removeAttr('encattr'); Drupal.freezeHeight(); @@ -87,17 +129,29 @@ Drupal.ahah.prototype.oncomplete = funct progress_element.remove(); // Hide the new content before adding to page. - new_content.hide(); + if (this.showEffect != 'show') { + new_content.hide(); + } - // Add the form and re-attach behavior. + // Add the new content to the page. if (this.method == 'replace') { wrapper.empty().append(new_content); } else { - eval('wrapper.' + this.method + '(new_content)'); + wrapper[this.method](new_content); + } + + // Determine what effect use and what content will receive the effect, + // then show the new content. + if ($('.ahah-new-content', new_content).size() > 0) { + $('.ahah-new-content', new_content).hide(); + new_content.show(); + $(".ahah-new-content", new_content)[this.showEffect](this.showSpeed); + } + else if (this.showEffect != 'show') { + new_content[this.showEffect](this.showSpeed); } - eval('new_content.' + this.showEffect + '()'); - button.css('float', 'none').attr('disabled', false); + element.removeClass('progess-disabled').attr('disabled', false); Drupal.attachBehaviors(new_content); Drupal.unfreezeHeight(); @@ -106,13 +160,15 @@ Drupal.ahah.prototype.oncomplete = funct /** * Handler for the form redirection error. */ -Drupal.ahah.prototype.onerror = function (error) { +Drupal.ahah.prototype.error = function (error) { alert(Drupal.t('An error occurred:\n\n@error', { '@error': error })); + // Resore the previous action and target to the form. + element.parent('form').attr( { action: this.form_action, target: this.form_target} ); // Remove progressbar. $(this.progress.element).remove(); this.progress = null; // Undo hide. $(this.wrapper).show(); // Re-enable the element. - $(this.id).css('float', 'none').attr('disabled', false); + $(this.id).removeClass('progess-disabled').attr('disabled', false); }; Index: misc/drupal.js =================================================================== RCS file: /cvs/drupal/drupal/misc/drupal.js,v retrieving revision 1.36 diff -u -p -r1.36 drupal.js --- misc/drupal.js 13 Jul 2007 20:07:15 -0000 1.36 +++ misc/drupal.js 21 Aug 2007 15:16:45 -0000 @@ -195,69 +195,6 @@ Drupal.theme = function(func) { }; /** - * Redirects a button's form submission to a hidden iframe and displays the result - * in a given wrapper. The iframe should contain a call to - * window.parent.iframeHandler() after submission. - */ -Drupal.redirectFormButton = function (uri, button, handler) { - // Trap the button - button.onmouseover = button.onfocus = function() { - button.onclick = function() { - // Create target iframe - Drupal.createIframe(); - - // Prepare variables for use in anonymous function. - var button = this; - var action = button.form.action; - var target = button.form.target; - - // Redirect form submission to iframe - this.form.action = uri; - this.form.target = 'redirect-target'; - - handler.onsubmit(); - - // Set iframe handler for later - window.iframeHandler = function () { - var iframe = $('#redirect-target').get(0); - // Restore form submission - button.form.action = action; - button.form.target = target; - - // Get response from iframe body - try { - response = (iframe.contentWindow || iframe.contentDocument || iframe).document.body.innerHTML; - // Firefox 1.0.x hack: Remove (corrupted) control characters - response = response.replace(/[\f\n\r\t]/g, ' '); - if (window.opera) { - // Opera-hack: it returns innerHTML sanitized. - response = response.replace(/"/g, '"'); - } - } - catch (e) { - response = null; - } - - response = Drupal.parseJson(response); - // Check response code - if (response.status == 0) { - handler.onerror(response.data); - return; - } - handler.oncomplete(response.data); - - return true; - }; - - return true; - }; - }; - button.onmouseout = button.onblur = function() { - button.onclick = null; - }; -}; - -/** * Retrieves the absolute position of an element on the screen */ Drupal.absolutePosition = function (el) { @@ -305,41 +242,6 @@ Drupal.parseJson = function (data) { }; /** - * Create an invisible iframe for form submissions. - */ -Drupal.createIframe = function () { - if ($('#redirect-holder').size()) { - return; - } - // Note: some browsers require the literal name/id attributes on the tag, - // some want them set through JS. We do both. - window.iframeHandler = function () {}; - var div = document.createElement('div'); - div.id = 'redirect-holder'; - $(div).html(''); - var iframe = div.firstChild; - $(iframe) - .attr({ - name: 'redirect-target', - id: 'redirect-target' - }) - .css({ - position: 'absolute', - height: '1px', - width: '1px', - visibility: 'hidden' - }); - $('body').append(div); -}; - -/** - * Delete the invisible iframe - */ -Drupal.deleteIframe = function () { - $('#redirect-holder').remove(); -}; - -/** * Freeze the current body height (as minimum height). Used to prevent * unnecessary upwards scrolling when doing DOM manipulations. */ Index: misc/jquery.form.js =================================================================== RCS file: misc/jquery.form.js diff -N misc/jquery.form.js --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ misc/jquery.form.js 21 Aug 2007 15:16:45 -0000 @@ -0,0 +1,14 @@ +// $Id$ + +/* + * jQuery form plugin + * @requires jQuery v1.1 or later + * + * Examples at: http://malsup.com/jquery/form/ + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + * + * Version: 1.0.3 + */ +eval(function(p,a,c,k,e,r){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(5($){$.7.1f=5(o){3(H o==\'5\')o={K:o};o=$.25({1b:4.R(\'1J\')||1i.2q,P:4.R(\'2b\')||\'27\'},o||{});2 a=4.1v(o.2V);3(o.1M&&o.1M(a,4,o)===F)6 4;2 p={};$.N.O(\'Y.G.2m\',[a,4,o,p]);3(p.3s)6 4;2 q=$.1A(a);3(o.P.3j()==\'27\'){o.1b+=(o.1b.3g(\'?\')>=0?\'&\':\'?\')+q;o.19=B}A o.19=q;2 r=4,M=[];3(o.1p)M.C(5(){r.1p()});3(o.1o)M.C(5(){r.1o()});3(!o.16&&o.15){2 u=o.K;M.C(5(a){$(o.15).R("1K",a).2I().Q(u,2C)})}A 3(o.K)M.C(o.K);o.K=5(a,b){J(2 i=0,D=M.E;i\');2 j=i[0];2 k=$.1w.1Z&&1i.1Z.32()<9;3($.1w.1W||k)j.2Z=\'2Y:F;1l.2X("");\';i.2W({2U:\'2T\',1Q:\'-1R\',1N:\'-1R\'});2 l={X:B,1d:B,2O:0,2N:\'n/a\',2J:5(){},2H:5(){},2F:5(){}};2 g=f.2E;3(g&&!$.2c++)$.N.O("2z");3(g)$.N.O("2y",[l,f]);2 m=0;2 n=0;1a(5(){i.2u(\'1j\');j.1I?j.1I(\'1H\',V):j.2t(\'1G\',V,F);2 a=d.1F?\'1F\':\'2s\';2 t=r.R(\'15\');r.R({15:h,2b:\'2r\',2o:\'2n/Y-19\',1J:f.1b});3(f.1h)1a(5(){n=18;V()},f.1h);d.G();r.R(\'15\',t)},10);5 V(){3(m++)6;j.1C?j.1C(\'1H\',V):j.2l(\'1G\',V,F);2 a=18;2k{3(n)2j\'1h\';2 b,I;I=j.2i?j.2i.1l:j.2g?j.2g:j.1l;l.X=I.1j?I.1j.1K:B;l.1d=I.2f?I.2f:I;3(f.16==\'2e\'||f.16==\'3r\'){2 c=I.1B(\'1z\')[0];b=c?c.z:l.X;3(f.16==\'2e\')3n("19 = "+b);A $.3k(b)}A 3(f.16==\'2a\'){b=l.1d;3(!b&&l.X!=B)b=29(l.X)}A{b=l.X}}3h(e){a=F;$.3f(f,l,\'26\',e)}3(a){f.K(b,\'K\');3(g)$.N.O("3d",[l,f])}3(g)$.N.O("3c",[l,f]);3(g&&!--$.2c)$.N.O("3b");3(f.24)f.24(l,a?\'K\':\'26\');1a(5(){i.39();l.1d=B},38)};5 29(s,a){3(1i.22){a=21 22(\'37.36\');a.35=\'F\';a.34(s)}A a=(21 33()).31(s,\'1u/2a\');6(a&&a.1X&&a.1X.1t!=\'30\')?a:B}}};$.7.1f.1e=0;$.7.T=5(a){6 4.1V().G(1s).Q(5(){4.1r=$.7.T.1e++;$.7.T.1q[4.1r]=a;$(":G,12:U",4).1U(1m)})};$.7.T.1e=1;$.7.T.1q={};5 1m(e){2 a=4.Y;a.L=4;3(4.P==\'U\'){3(e.1T!=17){a.S=e.1T;a.Z=e.2S}A 3(H $.7.1P==\'5\'){2 b=$(4).1P();a.S=e.1S-b.1N;a.Z=e.1O-b.1Q}A{a.S=e.1S-4.2R;a.Z=e.1O-4.2Q}}1a(5(){a.L=a.S=a.Z=B},10)};5 1s(){2 a=4.1r;2 b=$.7.T.1q[a];$(4).1f(b);6 F};$.7.1V=5(){4.1Y(\'G\',1s);6 4.Q(5(){$(":G,12:U",4).1Y(\'1U\',1m)})};$.7.1v=5(b){2 a=[];3(4.E==0)6 a;2 c=4[0];2 d=b?c.1B(\'*\'):c.2P;3(!d)6 a;J(2 i=0,D=d.E;iis_region_first: TRUE or FALSE depending on the listed blocks + * positioning. Used here to insert a region header. + * - $data->region_title: Region title for the listed block. + * - $data->block_title: Block title. + * - $data->region_select: Drop-down menu for assigning a region. + * - $data->weight_select: Drop-down menu for setting weights. + * - $data->throttle_check: Checkbox to enable throttling. + * - $data->configure_link: Block configuration link. + * - $data->delete_link: For deleting user added blocks. + * + * @see template_preprocess_block_admin_display_form() + * @see theme_block_admin_display() + */ +?> + + + + + + + + + + + + + + + + + + + is_region_first): ?> + + + + + + + + + + + + + + + + + + +
region_title; ?>
block_title; ?>region_select; ?>weight_select; ?>throttle_check; ?>configure_link; ?>delete_link; ?>
+ + Index: modules/block/block-admin-display.tpl.php =================================================================== RCS file: modules/block/block-admin-display.tpl.php diff -N modules/block/block-admin-display.tpl.php --- modules/block/block-admin-display.tpl.php 7 Aug 2007 08:39:35 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,66 +0,0 @@ -is_region_first: TRUE or FALSE depending on the listed blocks - * positioning. Used here to insert a region header. - * - $data->region_title: Region title for the listed block. - * - $data->block_title: Block title. - * - $data->region_select: Drop-down menu for assigning a region. - * - $data->weight_select: Drop-down menu for setting weights. - * - $data->throttle_check: Checkbox to enable throttling. - * - $data->configure_link: Block configuration link. - * - $data->delete_link: For deleting user added blocks. - * - * @see template_preprocess_block_admin_display() - * @see theme_block_admin_display() - */ -?> - - - - - - - - - - - - - - - - - - is_region_first): ?> - - - - - - - - - - - - - - - - - - -
region_title; ?>
block_title; ?>region_select; ?>weight_select; ?>throttle_check; ?>configure_link; ?>delete_link; ?>
- - Index: modules/block/block.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.admin.inc,v retrieving revision 1.7 diff -u -p -r1.7 block.admin.inc --- modules/block/block.admin.inc 20 Aug 2007 06:41:38 -0000 1.7 +++ modules/block/block.admin.inc 21 Aug 2007 15:16:45 -0000 @@ -7,62 +7,98 @@ */ /** + * Menu callback for admin/build/block. + */ +function block_admin_display($theme = NULL) { + global $custom_theme; + + // If non-default theme configuration has been selected, set the custom theme. + $custom_theme = isset($theme) ? $theme : variable_get('theme_default', 'garland'); + + // Fetch and sort blocks + $blocks = _block_rehash(); + usort($blocks, '_block_compare'); + + return drupal_get_form('block_admin_display_form', $blocks, $theme); +} + +/** * Generate main block administration form. */ -function block_admin_display(&$form_state, $theme = NULL) { +function block_admin_display_form(&$form_state, $blocks, $theme = NULL) { global $theme_key, $custom_theme; // Add CSS drupal_add_css(drupal_get_path('module', 'block') .'/block.css', 'module', 'all', FALSE); // If non-default theme configuration has been selected, set the custom theme. - if ($theme) { - $custom_theme = $theme; - } - else { - $custom_theme = variable_get('theme_default', 'garland'); - } + $custom_theme = isset($theme) ? $theme : variable_get('theme_default', 'garland'); init_theme(); - // Fetch and sort blocks - $blocks = _block_rehash(); - usort($blocks, '_block_compare'); - $throttle = module_exists('throttle'); $block_regions = array(BLOCK_REGION_NONE => '<'. t('none') .'>') + system_region_list($theme_key); // Build form tree - $form['#action'] = arg(3) ? url('admin/build/block/list/'. $theme_key) : url('admin/build/block'); - $form['#tree'] = TRUE; + $form = array( + '#action' => arg(3) ? url('admin/build/block/list/'. $theme_key) : url('admin/build/block'), + '#tree' => TRUE, + '#cache' => TRUE, + ); foreach ($blocks as $i => $block) { - $form[$i]['module'] = array('#type' => 'value', '#value' => $block['module']); - $form[$i]['delta'] = array('#type' => 'value', '#value' => $block['delta']); - $form[$i]['info'] = array('#value' => check_plain($block['info'])); - $form[$i]['theme'] = array('#type' => 'hidden', '#value' => $theme_key); - $form[$i]['weight'] = array('#type' => 'weight', '#default_value' => $block['weight']); - $form[$i]['region'] = array('#type' => 'select', + $key = $block['module'] .'_'. $block['delta']; + $form[$key]['module'] = array( + '#type' => 'value', + '#value' => $block['module'], + ); + $form[$key]['delta'] = array( + '#type' => 'value', + '#value' => $block['delta'], + ); + $form[$key]['info'] = array( + '#value' => check_plain($block['info']) + ); + $form[$key]['theme'] = array( + '#type' => 'hidden', + '#value' => $theme_key + ); + $form[$key]['weight'] = array( + '#type' => 'weight', + '#default_value' => $block['weight'], + ); + $form[$key]['region'] = array( + '#type' => 'select', '#default_value' => $block['status'] ? (isset($block['region']) ? $block['region'] : system_default_region($theme_key)) : BLOCK_REGION_NONE, '#options' => $block_regions, ); if ($throttle) { - $form[$i]['throttle'] = array('#type' => 'checkbox', '#default_value' => isset($block['throttle']) ? $block['throttle'] : FALSE); + $form[$key]['throttle'] = array('#type' => 'checkbox', '#default_value' => isset($block['throttle']) ? $block['throttle'] : FALSE); } - $form[$i]['configure'] = array('#value' => l(t('configure'), 'admin/build/block/configure/'. $block['module'] .'/'. $block['delta'])); + $form[$key]['configure'] = array('#value' => l(t('configure'), 'admin/build/block/configure/'. $block['module'] .'/'. $block['delta'])); if ($block['module'] == 'block') { - $form[$i]['delete'] = array('#value' => l(t('delete'), 'admin/build/block/delete/'. $block['delta'])); + $form[$key]['delete'] = array('#value' => l(t('delete'), 'admin/build/block/delete/'. $block['delta'])); } } - $form['submit'] = array('#type' => 'submit', '#value' => t('Save blocks')); + + // Attach the AHAH events to the submit button. Set the form id as the wrapper + // and set the selector to every select item in the form. + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Save blocks'), + '#ahah_path' => 'admin/build/block/list/js/'. $theme_key, + '#ahah_selector' => '#block-admin-display-form select', + '#ahah_wrapper' => 'block-admin-display-form', + '#ahah_event' => 'change', + '#ahah_effect' => 'fade', + ); return $form; } - /** * Process main block administration form submission. */ -function block_admin_display_submit($form, &$form_state) { +function block_admin_display_form_submit($form, &$form_state) { foreach ($form_state['values'] as $block) { $block['status'] = $block['region'] != BLOCK_REGION_NONE; $block['region'] = $block['status'] ? $block['region'] : ''; @@ -73,6 +109,78 @@ function block_admin_display_submit($for } /** + * Javascript callback for AHAH replacement. Re-generate the form with the + * updated values and return necessary html. + */ +function block_admin_display_js($theme = NULL) { + // Load the cached form. + $form_cache = cache_get('form_'. $_POST['form_build_id'], 'cache_form'); + + // Set the new weights and regions for each block. + $blocks = array(); + foreach (element_children($form_cache->data) as $key) { + $field = $form_cache->data[$key]; + if (isset($field['info'])) { + $block = array( + 'module' => $field['module']['#value'], + 'delta' => $field['delta']['#value'], + 'info' => html_entity_decode($field['info']['#value'], ENT_QUOTES), + 'region' => $_POST[$key]['region'], + 'weight' => $_POST[$key]['weight'], + 'status' => $_POST[$key]['region'] == BLOCK_REGION_NONE ? 0 : 1, + ); + + $throttle = module_exists('throttle'); + if ($throttle) { + $block['throttle'] = $_POST[$key]['throttle']; + } + + if ($block['weight'] != $form_cache->data[$key]['weight']['#default_value'] || $block['region'] != $form_cache->data[$key]['region']['#default_value']) { + $changed_block = $block['module'] .'_'. $block['delta']; + } + + $blocks[] = $block; + } + } + + // Resort the blocks with the new weights. + usort($blocks, '_block_compare'); + + // Create a form in the new order. + $form_state = array('submitted' => FALSE); + $form = block_admin_display_form($form_state, $blocks, $theme); + + // Preserve the order of the new form while merging the previous data. + $form_order = array_flip(array_keys($form)); // Save the form order. + $form = array_merge($form_cache->data, $form); // Merge the data. + $form = array_merge($form_order, $form); // Put back into the correct order. + + cache_set('form_'. $_POST['form_build_id'], $form, 'cache_form', $form_cache->expire); + + // Add a class to mark the new AHAH content. + $form[$changed_block]['#attributes']['class'] = empty($form[$changed_block]['attributes']['class']) ? 'ahah-new-content' : ' ahah-new-content'; + $form['js_modified'] = array( + '#type' => 'value', + '#value' => TRUE, + ); + + $form['#post'] = $_POST; + $form['#theme'] = 'block_admin_display_form'; + + // Add messages to our output. + drupal_set_message(t('Your settings will not be saved until you click the Save blocks button.')); + + // Render the form. + drupal_alter('form', $form, array(), 'block_admin_display_form'); + $form = form_builder('block_admin_display_form', $form, $form_state); + + $output = drupal_render($form); + + // Return the output in JSON format. + drupal_json(array('status' => TRUE, 'data' => $output)); +} + +/** * Helper function for sorting blocks on admin/build/block. * * Active blocks are sorted by region, then by weight. Index: modules/block/block.css =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.css,v retrieving revision 1.3 diff -u -p -r1.3 block.css --- modules/block/block.css 27 May 2007 17:57:47 -0000 1.3 +++ modules/block/block.css 21 Aug 2007 15:16:45 -0000 @@ -12,3 +12,10 @@ margin-bottom: 4px; padding: 3px; } +#blocks .progress .bar { + width: 1em; + height: 1em; +} +#blocks .progress .message { + display: none; +} Index: modules/block/block.module =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.module,v retrieving revision 1.275 diff -u -p -r1.275 block.module --- modules/block/block.module 19 Aug 2007 08:08:44 -0000 1.275 +++ modules/block/block.module 21 Aug 2007 15:16:46 -0000 @@ -102,23 +102,23 @@ function block_help($path, $arg) { */ function block_theme() { return array( - 'block_admin_display' => array( - 'file' => 'block-admin-display', + 'block_admin_display_form' => array( + 'file' => 'block-admin-display-form', 'arguments' => array('form' => NULL), ), ); } /** - * Process variables for block-admin-display.tpl.php. + * Process variables for block-admin-display-form.tpl.php. * * The $variables array contains the following arguments: * - $form * - * @see block-admin-display.tpl.php - * @see theme_block_admin_display() + * @see block-admin-display-form.tpl.php + * @see theme_block_admin_display_form() */ -function template_preprocess_block_admin_display(&$variables) { +function template_preprocess_block_admin_display_form(&$variables) { global $theme_key; $variables['throttle'] = module_exists('throttle'); @@ -139,7 +139,7 @@ function template_preprocess_block_admin // Fetch region for current block. $region = $block['region']['#default_value']; - // Track first block listing to insert region header inside block_admin_display.tpl.php. + // Track first block listing to insert region header inside block-admin-display-form.tpl.php. $is_region_first = FALSE; if ($last_region != $region) { $is_region_first = TRUE; @@ -153,6 +153,7 @@ function template_preprocess_block_admin } $variables['block_listing'][$i]->is_region_first = $is_region_first; + $variables['block_listing'][$i]->row_class = isset($block['#attributes']['class']) ? $block['#attributes']['class'] : ''; $variables['block_listing'][$i]->region_title = $region_title; $variables['block_listing'][$i]->block_title = drupal_render($block['info']); $variables['block_listing'][$i]->region_select = drupal_render($block['region']) . drupal_render($block['theme']); @@ -165,6 +166,7 @@ function template_preprocess_block_admin } } + $variables['messages'] = isset($variables['form']['js_modified']) ? theme('status_messages') : ''; $variables['form_submit'] = drupal_render($variables['form']); } @@ -182,8 +184,7 @@ function block_menu() { $items['admin/build/block'] = array( 'title' => 'Blocks', 'description' => 'Configure what block content appears in your site\'s sidebars and other regions.', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('block_admin_display'), + 'page callback' => 'block_admin_display', 'access arguments' => array('administer blocks'), 'file' => 'block.admin.inc', ); @@ -192,6 +193,12 @@ function block_menu() { 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10, ); + $items['admin/build/block/list/js'] = array( + 'title' => 'Javascript List Form', + 'page callback' => 'block_admin_display_js', + 'type' => MENU_CALLBACK, + 'file' => 'block.admin.inc', + ); $items['admin/build/block/configure'] = array( 'title' => 'Configure block', 'page arguments' => array('block_admin_configure'), @@ -206,6 +213,7 @@ function block_menu() { ); $items['admin/build/block/add'] = array( 'title' => 'Add block', + 'page callback' => 'drupal_get_form', 'page arguments' => array('block_add_block_form'), 'type' => MENU_LOCAL_TASK, 'file' => 'block.admin.inc', @@ -214,7 +222,7 @@ function block_menu() { foreach (list_themes() as $key => $theme) { $items['admin/build/block/list/'. $key] = array( 'title' => check_plain($theme->info['name']), - 'page arguments' => array('block_admin_display', $key), + 'page arguments' => array($key), 'type' => $key == $default ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK, 'weight' => $key == $default ? -10 : 0, 'file' => 'block.admin.inc', Index: modules/system/system-rtl.css =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system-rtl.css,v retrieving revision 1.3 diff -u -p -r1.3 system-rtl.css --- modules/system/system-rtl.css 8 Jun 2007 06:04:15 -0000 1.3 +++ modules/system/system-rtl.css 21 Aug 2007 15:16:46 -0000 @@ -83,6 +83,12 @@ div.teaser-button-wrapper { .progress .percentage { float: left; } +.progress.ahah-progress { + float: right; +} +.progess-disabled { + float: right; +} input.password-field { margin-left: 10px; margin-right: inherit; Index: modules/system/system.css =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.css,v retrieving revision 1.32 diff -u -p -r1.32 system.css --- modules/system/system.css 27 Jun 2007 17:54:49 -0000 1.32 +++ modules/system/system.css 21 Aug 2007 15:16:46 -0000 @@ -413,8 +413,9 @@ html.js .no-js { .progress .bar { background: #fff url(../../misc/progress.gif); border: 1px solid #00375a; + width: 5em; height: 1.5em; - margin-top: 0.2em; + margin: 0.2em 0 0 0.2em; } .progress .filled { background: #0072b9; @@ -425,6 +426,12 @@ html.js .no-js { .progress .percentage { float: right; /* LTR */ } +.progress.ahah-progress { + float: left; /* LTR */ +} +.progress-disabled { + float: left; /* LTR */ +} /* ** Formatting for welcome page Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.521 diff -u -p -r1.521 system.module --- modules/system/system.module 20 Aug 2007 18:26:41 -0000 1.521 +++ modules/system/system.module 21 Aug 2007 15:16:53 -0000 @@ -103,28 +103,28 @@ function system_elements() { $type['form'] = array('#method' => 'post', '#action' => request_uri()); // Inputs - $type['submit'] = array('#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', '#executes_submit_callback' => TRUE, '#ahah_event' => 'submit', '#process' => array('form_expand_ahah')); - $type['button'] = array('#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', '#executes_submit_callback' => FALSE, '#ahah_event' => 'submit', '#process' => array('form_expand_ahah')); - $type['image_button'] = array('#input' => TRUE, '#button_type' => 'submit','#executes_submit_callback' => TRUE, '#ahah_event' => 'submit', '#process' => array('form_expand_ahah'), '#return_value' => TRUE, '#has_garbage_value' => TRUE, '#src' => NULL); - $type['textfield'] = array('#input' => TRUE, '#size' => 60, '#maxlength' => 128, '#autocomplete_path' => FALSE); - $type['password'] = array('#input' => TRUE, '#size' => 60, '#maxlength' => 128); - $type['password_confirm'] = array('#input' => TRUE, '#process' => array('expand_password_confirm')); - $type['textarea'] = array('#input' => TRUE, '#cols' => 60, '#rows' => 5, '#resizable' => TRUE); + $type['submit'] = array('#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', '#executes_submit_callback' => TRUE, '#ahah_event' => 'click', '#process' => array('form_expand_ahah')); + $type['button'] = array('#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', '#executes_submit_callback' => FALSE, '#ahah_event' => 'click', '#process' => array('form_expand_ahah')); + $type['image_button'] = array('#input' => TRUE, '#button_type' => 'submit','#executes_submit_callback' => TRUE, '#ahah_event' => 'click', '#process' => array('form_expand_ahah'), '#return_value' => TRUE, '#has_garbage_value' => TRUE, '#src' => NULL); + $type['textfield'] = array('#input' => TRUE, '#size' => 60, '#maxlength' => 128, '#autocomplete_path' => FALSE, '#ahah_event' => 'blur', '#process' => array('form_expand_ahah')); + $type['password'] = array('#input' => TRUE, '#size' => 60, '#maxlength' => 128, '#ahah_event' => 'blur', '#process' => array('form_expand_ahah')); + $type['password_confirm'] = array('#input' => TRUE, '#ahah_event' => 'blur', '#process' => array('expand_password_confirm', 'form_expand_ahah')); + $type['textarea'] = array('#input' => TRUE, '#cols' => 60, '#rows' => 5, '#resizable' => TRUE, '#ahah_event' => 'blur', '#process' => array('form_expand_ahah')); $type['radios'] = array('#input' => TRUE, '#process' => array('expand_radios')); - $type['radio'] = array('#input' => TRUE, '#default_value' => NULL); + $type['radio'] = array('#input' => TRUE, '#default_value' => NULL, '#ahah_event' => 'change', '#process' => array('form_expand_ahah')); $type['checkboxes'] = array('#input' => TRUE, '#process' => array('expand_checkboxes'), '#tree' => TRUE); - $type['checkbox'] = array('#input' => TRUE, '#return_value' => 1); - $type['select'] = array('#input' => TRUE, '#size' => 0, '#multiple' => FALSE); - $type['weight'] = array('#input' => TRUE, '#delta' => 10, '#default_value' => 0, '#process' => array('process_weight')); + $type['checkbox'] = array('#input' => TRUE, '#return_value' => 1, '#ahah_event' => 'change', '#process' => array('form_expand_ahah')); + $type['select'] = array('#input' => TRUE, '#size' => 0, '#multiple' => FALSE, '#ahah_event' => 'change', '#process' => array('form_expand_ahah')); + $type['weight'] = array('#input' => TRUE, '#delta' => 10, '#default_value' => 0, '#ahah_event' => 'blur', '#process' => array('process_weight', 'form_expand_ahah')); $type['date'] = array('#input' => TRUE, '#process' => array('expand_date'), '#element_validate' => array('date_validate')); $type['file'] = array('#input' => TRUE, '#size' => 60); // Form structure $type['item'] = array('#value' => ''); - $type['hidden'] = array('#input' => TRUE); + $type['hidden'] = array('#input' => TRUE, '#process' => array('expand_ahah')); $type['value'] = array('#input' => TRUE); $type['markup'] = array('#prefix' => '', '#suffix' => ''); - $type['fieldset'] = array('#collapsible' => FALSE, '#collapsed' => FALSE, '#value' => NULL); + $type['fieldset'] = array('#collapsible' => FALSE, '#collapsed' => FALSE, '#value' => NULL, '#process' => array('expand_ahah')); $type['token'] = array('#input' => TRUE); return $type; }