Hi.

I would like to use ajax when deleting a status message, as opposed to being redirected to a confirmation page. Or at least, just have the status message deleted when a user clicks delete. Would this be possible to implement using views?

I sincerely appreciate any advice you can offer and thanks for sharing the module with us.

Kind regards,

Shane.

CommentFileSizeAuthor
#20 modals.zip2.79 KBpribeh

Comments

icecreamyou’s picture

Title: Disable Delete Status Confirmation Page » Confirm Delete Using AJAX (via ModalFrame)
Assigned: moosh101 » Unassigned
Category: support » feature
Priority: Major » Normal
Status: Active » Postponed

Doing AJAX deletion securely is extremely difficult. I'm not adding new features to the 2.x branch and this is not a priority for the 3.x branch.

I am planning to support the ModalFrame module in the 3.x branch, which will make it possible to show the delete confirmation page in an AJAX modal dialog. I'm not planning to add in-place bubbles or anything like that.

pribeh’s picture

Wicked stuff ice. Double plus bump.

Michsk’s picture

Ice have you got an indication of when 3.x will be somewhat active and able to do live sites? There are so many places where i would love to see modalframe come in action for facebook_statusses. Reply, views conversation, delete etc etc.

icecreamyou’s picture

Michsk’s picture

Anything changed in the couple of days between posts? ;-)

I can do some work to make modalframe work with 2.x no problem. I allready got it working with quite some more modules. If you are interested i can post the work done here.

icecreamyou’s picture

If you post a patch against 2.x-dev I will probably commit it.

moosh101’s picture

Assigned: Unassigned » moosh101

Hi all,

Very interesting comments. Version 3 sounds really good. Also, would it be possible to integrate some kind of user privacy options? For example, allow users to choose who can view their statuses, public, self, or friends (using the relationships module). This option could be available in user account settings.

I would be very keen to learn how Iasac got modalframe working with FBSS 2.0, as this is what I would like to achieve, if only for a delete popup. It would be good if you could share your techniques :-)

Thanks everyone,

Shane.

icecreamyou’s picture

Assigned: moosh101 » Unassigned

Also, would it be possible to integrate some kind of user privacy options?

One topic per issue, please.

Also please only assign issues to yourself if you intend to work on a patch to resolve them.

Michsk’s picture

Assigned: Unassigned » moosh101

@#7: This is basically the whole javascript.

(function ($) {
Drupal.behaviors.modals = function(context) {
  $('#messaging', context).addClass('modalframe-message-processed').each(function() {
    $(this).parent().prepend('<div class="modalframe-modals-messages" style="display:none;"></div>');
  });

  // Create an element to dynamically render status messages.
  var modalsConfigurationClick = function(action, url, refreshAfterSubmit) {
    // Hide status messages before opening the modal frame.
    $('.modalframe-modals-messages').hide();

    if (refreshAfterSubmit) {
      url += (url.indexOf('?') == -1 ? '?' : '&') +'refresh=1';
    }
	
    var onSubmitCallback = function(args, statusMessages) {
      if (args && args.submitted) {
        // Render new status messages, if any.
		if (statusMessages && statusMessages.length) {
          $('.modalframe-modals-messages').html(statusMessages).show('fast');
          window.scrollTo(0, 0);
        }
        if (refreshAfterSubmit) {
          window.scrollTo(0, 0);
          setTimeout(function() { window.location.reload(); }, 1500);
        }
      }
    };
    var modalFrameOptions = {
      url: url,
      width: 800,
      height: 200,
      draggable: false,
      //customDialogOptions: (modalFrameOptions.height = 100),
      onSubmit: onSubmitCallback
    };

    Drupal.modalFrame.open(modalFrameOptions);
    return false;
  };
 
  //modalize facebook status react
  $('a.facebook_status_conversation_link ', context).not('.modalframe-processed').attr('href', function() {
	return this.href + '&modal=1'
  }).addClass('use-modal').click(function(){
	var $link = $(this), url = $link.attr('href');
	return modalsConfigurationClick('', url, true);  
  });

  
}; 
})(jQuery)

And your php

<?php
function modals_init() {
  drupal_add_js(drupal_get_path('module', 'modals') .'/assets/modals.js');
  if(!isset($_GET['modal'])){
    modalframe_parent_js();
  } else{
    modalframe_child_js();
	//modalframe_close_dialog($args);
  }
}

/**
 * Implementation of hook_form_alter().
 */
function modals_form_alter(&$form, $form_state, $form_id) {
  if(isset($_GET['modal'])){
    if ($form_id == 'user_login' || $form_id == 'user_register' || $form_id == 'user_relationships_ui_request' || $form_id == 'flag_confirm' || $form_id == 'user_relationships_ui_pending_requested') {
      $form['#submit'][] = 'modals_child_form_submit';
	  //print 'testing';
	  //dvr($form);

	  // remove cancle links
	  if( $form_id == 'flag_confirm' || $form_id == 'user_relationships_ui_pending_requested' || $form_id == 'user_relationships_ui_request'){
	    unset($form['actions']['cancel']);
	  }
    }
    if ($form_id == 'privatemsg_new') {
      $form['privatemsg']['submit']['#submit'][] = 'modals_child_form_submit';
    }
  }
}

/**
 * Process the block settings or block delete forms.
 */
function modals_child_form_submit($form, &$form_state) {
  $modalframe_args = array(
    'submitted' => TRUE,
  );
  modalframe_close_dialog($modalframe_args);
}

The php side has some other form_id's in it because i use modalframe on multiple places, but above should help you. But you will have to tweak it for your own use.

Privacy thing, i completely agree, but you should make a new issue for that and not place it here.

Michsk’s picture

Assigned: moosh101 » Unassigned

mm dont know why it changed the assigned to option.

pribeh’s picture

Hi Iasac,

Did you put your code from #9 in a custom module? I'm not a very good module programmer so if you could provide just a bit more guidance that would be super appreciated.

Best,

Thomas

moosh101’s picture

Status: Postponed » Active

Hi Iasac,

I would also like to request a custom module using the code in #9, or at lease could you please describe how to implement your code?

I sincerely appreciate all your time and support.

Many thanks,

Shane.

fugazi’s picture

Subscribe

Michsk’s picture

I put it in a own module,yes. Search how to make your own module call it modals and use the code

fugazi’s picture

#14 @lasac - I am a beginner, you can explain this more as they have done. Unfortunately I can not create your own modules. Sorry for my bad english. regards

pribeh’s picture

Hey fugazi,

I'll try assembling this into a module and attaching it in a zip file for everyone else sometime today.

fugazi’s picture

ohh that would be great ... many thanks

glitz’s picture

subscribe

glitz’s picture

If you have this module assembled could you send it to me also please?
thanks

pribeh’s picture

StatusFileSize
new2.79 KB

Hi, here's the module made from Iasac's code in #9. I can't seem to get this to work. Any help would be much appreciated. I've checked to see if the javascript is being attached by the module via firebug and it seems to be. Beyond that my debugging skills are limited - sorry.

Michsk’s picture

wow i didn't know this issue was a roadmap blocker. I'll dive in to this as soon as i can.

franzkewd’s picture

subscribe

icecreamyou’s picture

Version: 6.x-2.x-dev » 6.x-3.x-dev
Status: Active » Fixed

So it turns out there is a related issue for the comments submodule and I went to solve that one and wasn't paying attention and added Modal Frame integration for the main module instead. There is still a bug in that for some reason submitting the edit-status form doesn't force the modal frame to close; however, this can be addressed in a new issue. (The delete process works well.)

(Also, only committing new features to 3.x.)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

madhusudan’s picture

Status: Closed (fixed) » Active

#20
enabled modals module but This module is not working...
the delete confirm form loads in separate page.

icecreamyou’s picture

Status: Active » Closed (fixed)

Open a support request, please don't spam a closed issue.