cancel
Showing results for 
Search instead for 
Did you mean: 

Wait message in Share javascript component object

fast3r
Champ on-the-rise
Champ on-the-rise
Hi everybody,
I'm trying to configurate a waiting message in the javascript part of a Webscript. In a few words, when a user changes the selection of a select field, some operations are made in the page DOM and, until they're finished, I want a message to be displayed to the user.

I have an event listener for the select change in the standard Alfresco onReady function:
YAHOO.util.Event.addListener(some_select_field_element, "change", this.applyFilters, this, true);

The applyFilters() function is something like this:


this._setBusy(message);

// do some long operations

this._releaseBusy();

And the  _setBusy() and _releaseBusy() are:


      _releaseBusy: function Schedule_releaseBusy()
      {
         if (this.busy)
         {
            this.widgets.busyMessage.destroy();
            this.busy = false;
            return true;
         }
         else
         {
            return false;
         }
      },

      _setBusy: function Schedule_setBusy(message)
      {
         if (this.busy)
         {
            return false;
         }
         this.busy = true;
         this.widgets.busyMessage = Alfresco.util.PopupManager.displayMessage(
         {
            text: message,
            spanClass: "wait",
            displayTime: 0,
         });
         return true;
      },

The question is that the message is showed only AFTER the "long operations" have been made, just a few time before the _releaseBusy() function call. Why??! Am I missing something?
I have seen this pattern in a few components in Share, for example when deleting a Site, and it works correctly!

Thank you for any help…
4 REPLIES 4

mikeh
Star Contributor
Star Contributor
By default, the pop-up messages animate in on a 0.5 second animation. Because you're tying up the browser, it doesn't have enough idle time to run this so you get the effect you've described.

Try:
         this.widgets.busyMessage = Alfresco.util.PopupManager.displayMessage(
         {
            text: message,
            spanClass: "wait",
            displayTime: 0,
            effect: null
         });

Also be careful of trailing commas in object literal sections - that code would have thrown errors on MSIE browsers.

Thanks,
Mike

fast3r
Champ on-the-rise
Champ on-the-rise
Thank you for the answer!
I've tried the solution you listed, unfortunately nothing changes. I've also tried to set effectDuration to 0 and setting a different displayTime, but unsuccesfully.
The message div appears after the other code!
It's really weird…

mikeh
Star Contributor
Star Contributor
I guess the browser isn't getting enough time to render the DIV. You could try wrapping your long-running function in a YAHOO.lang.later() call. See http://developer.yahoo.com/yui/docs/YAHOO.lang.html#method_later for details.

Thanks,
Mike

fast3r
Champ on-the-rise
Champ on-the-rise
I guess the browser isn't getting enough time to render the DIV.

I think this is the real problem.
Do you mean to trap the (sometimes) long running function or the throwing message function?
I've tried both with no results. I think there is a conflict between the Alfresco mechanism for showing the message div and my function, which makes some modifications to the page DOM.

Thanks anyway for your help!