[Proto-Scripty] Re: draggable onEnd calling function

2009-05-06 Thread Alex McAuley

try this

new Draggable(newElement,{
handle: 'thehandleID',
starteffect: function() {
   // some function
},
endeffect : function () {
 // some function
},
onEnd: function(element,event) {
 cool();
},// end onEnd
onDrag : function() {
// some other function
}
});

this works fine for me, its cross browser  and works every time and i use it 
(with my own functions to stop elements being dragged out of the viewport)


HTH
Alex

- Original Message - 
From: "Bobby Brown" 
To: "Prototype & script.aculo.us" 
Sent: Thursday, May 07, 2009 6:04 AM
Subject: [Proto-Scripty] draggable onEnd calling function


>
> I'm trying to execute a function when an object is done being dragged
> (ie: onEnd).  The function checks to make sure the draggable is inside
> the parent div I want it to stay in. I can get it to work now as long
> as I pass no variables to the function.  if I do, the function
> executes onload, and NOT onEnd.  Below is the code.
>
> var cool = function(){
> /*get position of the draggable and the top left corner of container,
> which is a 1x1 div I've fixed in the top corner*/
> var arr = $('barcode_drag').positionedOffset();
> var topleft = $('fixed').positionedOffset();
>
> /*get width of container and draggable*/
> var container_width = $('coupon_container').getWidth();
> var barcode_width = $('barcode_image').getWidth();
>
> /*get height of container and draggable*/
> var container_height = $('coupon_container').getHeight();
> var barcode_height = $('barcode_image').getHeight();
>
> /*checks if it's too far left*/
> if(arr[0] < topleft[0]){
> document.getElementById('barcode_drag').style.left = "0px";
> var left = 0;
> }
> /*checks if it's too far top*/
> if(arr[1] < topleft[1]){
> document.getElementById('barcode_drag').style.top = "0px";
> var top = 0;
> }
>
> /*checks if it's too far right*/
> if(arr[0] + barcode_width > (topleft[0] + container_width) - 5){
> var temp = container_width - barcode_width - 5;
> document.getElementById('barcode_drag').style.left = temp+"px";
> var left = temp;
> }
>
> /*checks if it's too far bottom*/
> if(arr[1] + barcode_height > (topleft[1] + container_height) - 5){
> var temp = container_height - barcode_height - 5;
> document.getElementById('barcode_drag').style.top = temp+"px";
> var top = temp;
> }
>
> /*tells user x coordinate of drop*/
> if(typeof left == "undefined"){
> var left = arr[0] - topleft[0];
> }
>
> /*tells user y coordinate of drop*/
> if(typeof top == "undefined"){
> var top = arr[1] - topleft[1];
> }
>
> /*tell user where image is*/
> document.getElementById('barcode_x').innerHTML = "Left:"+left+"px";
> document.getElementById('barcode_y').innerHTML = "Top:"+top+"px";
>
> /*set input so refresh doesn't reset position*/
> document.getElementById('barcode_left').value = left;
> document.getElementById('barcode_top').value = top;
> }
>
> var options = { onEnd : cool};
> new Draggable ('barcode_drag', options);
>
>
> It is right here at the end I have the problem. This way works fine,
> but if I put
>
> var options = { onEnd: cool()};
>
> it doesn't execute properly.  I'd like to be able to pass variables
> into the "cool" function so I don't have to write a new one to
> constrain every one of my draggables.
>
> Thanks in advance for any help!
> >
> 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] draggable onEnd calling function

2009-05-06 Thread Bobby Brown

I'm trying to execute a function when an object is done being dragged
(ie: onEnd).  The function checks to make sure the draggable is inside
the parent div I want it to stay in. I can get it to work now as long
as I pass no variables to the function.  if I do, the function
executes onload, and NOT onEnd.  Below is the code.

var cool = function(){
/*get position of the draggable and the top left corner of container,
which is a 1x1 div I've fixed in the top corner*/
var arr = $('barcode_drag').positionedOffset();
var topleft = $('fixed').positionedOffset();

/*get width of container and draggable*/
var container_width = $('coupon_container').getWidth();
var barcode_width = $('barcode_image').getWidth();

/*get height of container and draggable*/
var container_height = $('coupon_container').getHeight();
var barcode_height = $('barcode_image').getHeight();

/*checks if it's too far left*/
if(arr[0] < topleft[0]){
document.getElementById('barcode_drag').style.left = "0px";
var left = 0;
}
/*checks if it's too far top*/
if(arr[1] < topleft[1]){
document.getElementById('barcode_drag').style.top = "0px";
var top = 0;
}

/*checks if it's too far right*/
if(arr[0] + barcode_width > (topleft[0] + container_width) - 5){
var temp = container_width - barcode_width - 5;
document.getElementById('barcode_drag').style.left = temp+"px";
var left = temp;
}

/*checks if it's too far bottom*/
if(arr[1] + barcode_height > (topleft[1] + container_height) - 5){
var temp = container_height - barcode_height - 5;
document.getElementById('barcode_drag').style.top = temp+"px";
var top = temp;
}

/*tells user x coordinate of drop*/
if(typeof left == "undefined"){
var left = arr[0] - topleft[0];
}

/*tells user y coordinate of drop*/
if(typeof top == "undefined"){
var top = arr[1] - topleft[1];
}

/*tell user where image is*/
document.getElementById('barcode_x').innerHTML = "Left:"+left+"px";
document.getElementById('barcode_y').innerHTML = "Top:"+top+"px";

/*set input so refresh doesn't reset position*/
document.getElementById('barcode_left').value = left;
document.getElementById('barcode_top').value = top;
}

var options = { onEnd : cool};
new Draggable ('barcode_drag', options);


It is right here at the end I have the problem. This way works fine,
but if I put

var options = { onEnd: cool()};

it doesn't execute properly.  I'd like to be able to pass variables
into the "cool" function so I don't have to write a new one to
constrain every one of my draggables.

Thanks in advance for any help!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Help! How to get document.body height using Element.getDimensions

2009-05-06 Thread Paul Kim
Hi T.J.,

Thanks for the clear explanation regarding the viewport's height. I did
expect the body element's height to be the viewport's height and I was wrong
to make that assumption.  Since Prototype javascript library seems to iron
out various cross-browser implementations of native javascript (Internet
Explorer in particular), I thought there was a simple method in Prototype
that could easily determine the body element's width and height.

- Paul K

On Wed, May 6, 2009 at 2:05 AM, T.J. Crowder  wrote:

>
> Hi Paul,
>
> Just to add to that, I'm guessing the height was "wrong" because you
> were expecting the body element's height to be the viewport's height.
> The body element's height is determined by its content (barring CSS
> rules to the contrary), not the height of the viewport.  Try this CSS:
>
> body {
>border:   1px solid red;
> }
>
> ...with this body:
>
> 
> This is a test
> 
>
> ...and you'll see the red border around the (outside of the)
> paragraph, not around the entire page viewport.  If you ask its
> dimensions, you'll find the body is 40-50px high depending on your
> font sizes, etc.  If you have lots of content in the body, such that
> it fills or overfills the viewport, the red border is (of course)
> around all of the content.
>
> You were probably expecting the body to be at least the height of the
> viewport, perhaps because some CSS rules are applied as if that were
> true.  Add a background color, for instance:
>
> body {
>border:   1px solid red;
>background-color: yellow;
> }
>
> ...and the yellow background fills the viewport, even though the body
> doesn't.
>
> Fun, eh?
> --
> T.J. Crowder
> tj / crowder software / com
> Independent Software Engineer, consulting services available
>
> On May 5, 5:25 pm, Paul Kim  wrote:
> > Thank you, Douglas. Works like a charm!
> >
> > - Paul K
> >
> > On Tue, May 5, 2009 at 9:19 AM, Douglas 
> wrote:
> >
> > > I hope this snippet helps :o)
> >
> > > [code]
> > >var w = 0,
> > >h = 0;
> >
> > >if (typeof(window.innerWidth) == 'number') {
> > >w = window.innerWidth;
> > >h = window.innerHeight;
> > >} else if (document.documentElement &&
> > > (document.documentElement.clientWidth ||
> >
> > > document.documentElement.clientHeight))
> > >{
> > >//IE 6+ in 'standards compliant mode'
> > >w = document.documentElement.clientWidth;
> > >h = document.documentElement.clientHeight;
> > >} else if (document.body && (document.body.clientWidth ||
> > > document.body.clientHeight))
> > >{
> > >//IE 4 compatible
> > >w = document.body.clientWidth;
> > >h = document.body.clientHeight;
> > >}
> > > [/code]
> >
> > > On Tue, May 5, 2009 at 1:14 PM, kimbaudi  wrote:
> >
> > > > Hi, I am unable to get the height of the  tag using
> > > > Element.getDimensions although I can get the width of the  tag
> > > > fine. How can I get the height of the  tag? I have my simple
> > > > code pasted athttp://pastie.org/468828. Here is the snippet of code
> > > > below as well:
> >
> > > > function alertBodyDim() {
> > > >   /* $('main') refers to  */
> > > >var dimensions = $('main').getDimensions();
> > > >alert(dimensions.width);
> > > >alert(dimensions.height);
> >
> > > > }
> >
> > > > - Paul K
> >
> > > --
> > > Believe nothing, no matter where you read it, or who said it, no
> > > matter if I have said it, unless it agrees with your own reason and
> > > your own common sense. ~Buddha
> >
> >
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Prototype Ajax with Perl script gets random "internal server error"

2009-05-06 Thread Nobody

Hi Diodeus,
as i wrote, i ran the code several times without errors, but other
times it crashed.
I can really exclude an error in the server-side code. I replaced my
code with a simple Perl one line script "print '123test';" and even
with this simple code it sometimes worked, sometimes didn't...

On 6 Mai, 18:29, Diodeus  wrote:
> All I can suggest is performing some error-trapping in your server-
> side code to see where it's crapping-out.
>
> On May 5, 2:55 pm, Nobody  wrote:
>
> > Hi guys,
> > i got a problem with prototype in connection with a perl script. I'm
> > performing AJAX-requests with Ajax.Request of prototype calling a perl
> > script for performing the backend functions.
> > Somehow i get random "500 Internal Server Error" messages. I tried so
> > many things (checking permissions, checking error.log, etc.) but i got
> > no further with this.
> > The cryptic part is that i can run the AJAX-request several times,
> > every time succesfully, but if i run it once more, it crashes with the
> > mentioned error. I can exclude an error within the perl script. I ran
> > it several times without an AJAX-request just through a normal POST-
> > call and i never got errors. Even more weird is the fact that the perl
> > script evidently performs the commands it should perform even if i get
> > the internal server error.
> > Anybody got me any idea how to solve this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Prototype Ajax with Perl script gets random "internal server error"

2009-05-06 Thread Diodeus

All I can suggest is performing some error-trapping in your server-
side code to see where it's crapping-out.



On May 5, 2:55 pm, Nobody  wrote:
> Hi guys,
> i got a problem with prototype in connection with a perl script. I'm
> performing AJAX-requests with Ajax.Request of prototype calling a perl
> script for performing the backend functions.
> Somehow i get random "500 Internal Server Error" messages. I tried so
> many things (checking permissions, checking error.log, etc.) but i got
> no further with this.
> The cryptic part is that i can run the AJAX-request several times,
> every time succesfully, but if i run it once more, it crashes with the
> mentioned error. I can exclude an error within the perl script. I ran
> it several times without an AJAX-request just through a normal POST-
> call and i never got errors. Even more weird is the fact that the perl
> script evidently performs the commands it should perform even if i get
> the internal server error.
> Anybody got me any idea how to solve this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Prototype & script.aculo.us not working in firefox

2009-05-06 Thread Diodeus

Please post the URL.

On May 6, 7:00 am, lesserone  wrote:
> Hi all I am using Prototype & script.aculo.us.
>
> All I want to do is use a horizontal slider with a list of images.
>
> If I do not use a master page then it all works in IE but not in
> Firefox.
>
> If I use a master page still nothing in Firefox and the Images are not
> hidden but all of them show please help.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: help with ajax.

2009-05-06 Thread T.J. Crowder

Hi,

> I am running the vendor code and my prototype code from the same folder
> on the same server with almost the same file name.

So, something else is going on. :-)  I'd recommend walking through the
call using a debugger (Firebug[1], for instance).  If you're not even
seeing the call get initiated, that suggests that Prototype isn't
firing off the request, so you should be able to see why not.

[1] http://www.getfirebug.com

HTH,
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available


On May 6, 2:18 pm, "Russell Keith" 
wrote:
> Also when I tried to do a cross domain call before that didn't work I
> thought I got an access denied error.  This isn't even trying to make
> the call.  I have a proxy setup to view the traffic and I see the call
> to my page the code is on and a call to the prototype.js file, but it
> doesn't even appear to be trying to make the call to the web service.
>
> -Original Message-
> From: prototype-scriptaculous@googlegroups.com
>
> [mailto:prototype-scriptacul...@googlegroups.com] On Behalf Of Russell
> Keith
> Sent: Wednesday, May 06, 2009 8:15 AM
> To: prototype-scriptaculous@googlegroups.com
> Subject: [Proto-Scripty] Re: help with ajax.
>
> I am running the vendor code and my prototype code from the same folder
> on the same server with almost the same file name.  The only difference
> is I added pt to the filename that my prototype code is trying to run
> from.
>
> http://server_a/ajaxIG.htmlis the vendor code and it 
> callshttp://server_b/cm/servlet/cmwebservicewih no issue.
>
> my prototype code ishttp://server_a/ajaxIGpt.htmland it calls the same
> web service.  
>
> I am using prototype to successfully make calls to other internal
> servers on the network without an issue.
>
> fromhttp://server_a/signer.htmlI use prototype to 
> callhttp://server_c/somewebservicewithout a problem.
>
> I guess I am going to have to stick with the vendor code even though
> it's not as pretty as prototype.
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Ajax.Autocompleter error in IE 6

2009-05-06 Thread Sabri LABBENE
Hi,
You need to apply a small patch to your prototype.js
Instead of " while ((element = element.parentNode) && element !=
document.body", put:
while ((element = element.parentNode) && element != document.body &&
Object.isElement(element))

I have the 1.6.1_rc2 and the patch is to apply in Line 2411.
If you have a different version of prototype, the patch can also work.

Even if IE sucks, it still be considered as the corporate web browser in
many companies :-(

-- Sabri.

On Wed, May 6, 2009 at 5:12 PM, Alex McAuley <
webmas...@thecarmarketplace.com> wrote:

>
> IE6 sucks dont support it .. if developers stop supporting it then it
> will force change in the industry and we wont have these headaches anymore!
>
>
> - Original Message -
> From: "virchete" 
> To: "Prototype & script.aculo.us" <
> prototype-scriptaculous@googlegroups.com>
> Sent: Wednesday, May 06, 2009 4:05 PM
> Subject: [Proto-Scripty] Ajax.Autocompleter error in IE 6
>
>
> >
> > hello,
> >
> > I have been looking for the solution in the web and I didn't find
> > anything. My problem appears only in IE and works fine in Firefox. The
> > problem is the following:
> >
> > -The first time that I write something I don't receive the list. If
> > you stop writting (for example 1 second) and then continue writting or
> > deleting.. (pressing a key) you receive the list of items. But the
> > first time you do not receive anything.
> >
> > -Just to confirm where is the error I have made the following checks:
> >  -The server receives the ajax request.
> >  -The server response correctly the Ajax request with a list of
> > results.
> > Then no result is displayed.
> >
> > Could someone tell me what is the function in controls.js or other
> > file of prototype that take the response of the server, parse and
> > include in the div specified in the Ajax.Autocompleter request.
> >
> > Thanks
> > >
> >
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Ajax.Autocompleter error in IE 6

2009-05-06 Thread Alex McAuley

IE6 sucks dont support it .. if developers stop supporting it then it 
will force change in the industry and we wont have these headaches anymore!


- Original Message - 
From: "virchete" 
To: "Prototype & script.aculo.us" 
Sent: Wednesday, May 06, 2009 4:05 PM
Subject: [Proto-Scripty] Ajax.Autocompleter error in IE 6


>
> hello,
>
> I have been looking for the solution in the web and I didn't find
> anything. My problem appears only in IE and works fine in Firefox. The
> problem is the following:
>
> -The first time that I write something I don't receive the list. If
> you stop writting (for example 1 second) and then continue writting or
> deleting.. (pressing a key) you receive the list of items. But the
> first time you do not receive anything.
>
> -Just to confirm where is the error I have made the following checks:
>  -The server receives the ajax request.
>  -The server response correctly the Ajax request with a list of
> results.
> Then no result is displayed.
>
> Could someone tell me what is the function in controls.js or other
> file of prototype that take the response of the server, parse and
> include in the div specified in the Ajax.Autocompleter request.
>
> Thanks
> >
> 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Ajax.Autocompleter error in IE 6

2009-05-06 Thread virchete

hello,

I have been looking for the solution in the web and I didn't find
anything. My problem appears only in IE and works fine in Firefox. The
problem is the following:

 -The first time that I write something I don't receive the list. If
you stop writting (for example 1 second) and then continue writting or
deleting.. (pressing a key) you receive the list of items. But the
first time you do not receive anything.

-Just to confirm where is the error I have made the following checks:
  -The server receives the ajax request.
  -The server response correctly the Ajax request with a list of
results.
Then no result is displayed.

Could someone tell me what is the function in controls.js or other
file of prototype that take the response of the server, parse and
include in the div specified in the Ajax.Autocompleter request.

Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Ajax.Updater and JavaScript source files inclusions

2009-05-06 Thread T.J. Crowder

Hi,

> Yes, I could control this as output mostly comes from source files
> that have been automatically generated (MDA approach) but I think this
> solution would break browser file cache.

It wouldn't, but you couldn't have known that as you couldn't see the
wiki article. :-)

> I couldn't check Proto-
> Scripty wiki (seems to be down...) to learn about dynamic script
> loading but this put me in the way.

Wow, I've never known wikidot (where the wiki is hosted) to be down.
I suppose it must happen. :-)  It's working right now as I write this
(I followed the link in my earlier note to make sure it wasn't a
typo).

> Nevertheless, it seems that Firefox does not load external script
> files unless they are inserted in the HTML head element (can someone
> confirm that?).

It doesn't process them if you assign them as strings via innerHTML,
which is what your modified update would do (Element#update uses
innerHTML behind the scenes).  It does process them correctly if you
insert them using DOM methods as your code does, even if you don't put
them in the head.  But putting them in the head is probably the most
appropriate thing to do anyway, and indeed is exactly what the
unofficial wiki article does. :-)

> In fact, I choose to use Ajax.Responders to parse response text from
> output and dynamically load any external source files...

Ah, interesting approach.  I think I'd prefer to leave Prototype
unmodified and build my own updater-like-thing via Ajax.Request, but
obviously it's up to you.

> Nevertheless, I think that inline scripts may be executed before
> external resource has been completely interpreted, which may lead to
> invalid references.

Very likely.  The inline scripts will get evaluated very, very soon
after the content is updated (Element#update does it via Function#defer
[1]), whereas the external scripts may still be downloading at that
point.  A really robust solution would probably walk through the
script tags (inline and external) in the order in which they appear
and load/execute them sequentially.  I think if you were going to do
that, you'd have to retrieve the script files directly (via XHR calls)
rather than inserting script tags, because otherwise I'm not sure how
you'd be able to know that the file had finished loading.  XHR stuff
*should* use the browser cache, and I understand it mostly does
although there are some revalidation issues reported in the XHR
Wikipedia article (mostly indicating that stale content may get
reused, as opposed to getting re-retrieved too often).[2]

[1] http://prototypejs.org/api/function/defer
[2] http://en.wikipedia.org/wiki/XMLHttpRequest

Have fun,
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available

On May 6, 2:45 pm, almeidap  wrote:
> Thanks for your quick and complete answer! I've followed your hints
> and I think that I've reached an elegant (but maybe not performant)
> solution.
>
> > String#evalScripts uses String#extractScripts[4], which uses this
> > regex repeatedly to build an array of the contents of script tags:
> > ']*>([\\S\\s]*?)<\/script>' ...
>
> Right! I adapted Prototype's regex to leave script tags that reference
> an external source file, simply by redefining the Prototype's
> ScriptFragment property (argh, it took me about 1 hour to find that
> crazy regex):
> Prototype.ScriptFragment = ']*>([\\S\\s]*?)<\/
> script>';
>
> Nevertheless, it seems that Firefox does not load external script
> files unless they are inserted in the HTML head element (can someone
> confirm that?). That means that even if the script element was
> inserted into the DOM after update, script contents were never
> interpreted.
>
> > The second approach, which may be simpler, only works if you're in
> > control of what comes back (e.g., you're not calling some third-party
> > code you don't have control over).  If you are in control of it, you
> > could change it to use inline script to load external scripts, rather
> > than script tags.
>
> Yes, I could control this as output mostly comes from source files
> that have been automatically generated (MDA approach) but I think this
> solution would break browser file cache. I couldn't check Proto-
> Scripty wiki (seems to be down...) to learn about dynamic script
> loading but this put me in the way.
>
> In fact, I choose to use Ajax.Responders to parse response text from
> output and dynamically load any external source files by appending a
> script element in the HTML head (inspired by [1], feel free to reveal
> problems or to suggest optimizations):
>
> Ajax.Responders.register({
>   onComplete: function(responder) {
>     var reponseText = responder.transport.responseText;
>         reponseText.scan(/]*src="(.*)"[^>]*>/, function(match){
>                 ActionUtils.loadScript(match[1]);
>         });
>   }
>
> });
>
> ActionUtils = {
>
>         ...
>
>         Resources : [],
>
>         loadScript : function(resource, onload) {
>                 if(

[Proto-Scripty] Re: script.aculo.us Drag&Drop on the serverside

2009-05-06 Thread ColinFine



On May 6, 12:49 pm, sandy  wrote:
> Hi all,
>
> Still i am stuck on the same issue as above i.e. nothing is happening
> on dropping the image in panel-2.I am able to drag the iamge from
> panel-1 to panel-2 but the Droppable.add(...) is not firing .The whole
> code is same as above posted .
>
> And server side means,all the script in .cs file and i am fetching all
> the images from data base so every thing is a dynamic here and all the
> script is written on the page load method.
>
> Any help will be very help full for me.
> Thanks Sandeep
>
Either I am misunderstanding you, or you are misunderstanding
something very basic about the web..

When you display a web page, the browser issues a request, and the
server prepares the page (perhaps just reading a file, perhaps running
a program) and sends it to the browser. THE SERVER HAS THEN FINISHED
ITS JOB and has no further knowledge or interest in the page, whatever
the user may do with it. The only way, originally, to get the server
to do any more work was to issue a new request, for example by
clicking a link, or submitting a form.

For the first few years of the WWW, that was the whole story. But then
some clever person invented Ajax: a mechanism whereby a browser could
send a further request while still staying on the displayed page,
receive an answer back from the server, and (usually) make changes to
the page in consequence. But in order to use this, you need to run
some code on the browser (usually in Javascript) to submit this Ajax
request, and process the result; and have some code on the server that
will act on this request.

Forgive me if I am explaining something that you already understand;
but it seems to me from all you have said that you do not realise that
you need to write some (javascript) code to issue the Ajax request and
process the results - such as "new Ajax.Updater" (from
script.aculo.us). This is nothing to do with page load, except of
course that you have to get the code onto the page in the first place
to do it. I guess that your 'onDropFunction' needs to include such a
call, and it needs to include the URL of a CGI script you write on the
server which will update the database and send the results back.


Colin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Prototype & script.aculo.us not working in firefox

2009-05-06 Thread lesserone

Hi all I am using Prototype & script.aculo.us.

All I want to do is use a horizontal slider with a list of images.

If I do not use a master page then it all works in IE but not in
Firefox.

If I use a master page still nothing in Firefox and the Images are not
hidden but all of them show please help.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Ajax.Updater and JavaScript source files inclusions

2009-05-06 Thread almeidap

Thanks for your quick and complete answer! I've followed your hints
and I think that I've reached an elegant (but maybe not performant)
solution.

> String#evalScripts uses String#extractScripts[4], which uses this
> regex repeatedly to build an array of the contents of script tags:
> ']*>([\\S\\s]*?)<\/script>' ...

Right! I adapted Prototype's regex to leave script tags that reference
an external source file, simply by redefining the Prototype's
ScriptFragment property (argh, it took me about 1 hour to find that
crazy regex):
Prototype.ScriptFragment = ']*>([\\S\\s]*?)<\/
script>';

Nevertheless, it seems that Firefox does not load external script
files unless they are inserted in the HTML head element (can someone
confirm that?). That means that even if the script element was
inserted into the DOM after update, script contents were never
interpreted.

> The second approach, which may be simpler, only works if you're in
> control of what comes back (e.g., you're not calling some third-party
> code you don't have control over).  If you are in control of it, you
> could change it to use inline script to load external scripts, rather
> than script tags.

Yes, I could control this as output mostly comes from source files
that have been automatically generated (MDA approach) but I think this
solution would break browser file cache. I couldn't check Proto-
Scripty wiki (seems to be down...) to learn about dynamic script
loading but this put me in the way.

In fact, I choose to use Ajax.Responders to parse response text from
output and dynamically load any external source files by appending a
script element in the HTML head (inspired by [1], feel free to reveal
problems or to suggest optimizations):

Ajax.Responders.register({
  onComplete: function(responder) {
var reponseText = responder.transport.responseText;
reponseText.scan(/]*src="(.*)"[^>]*>/, function(match){
ActionUtils.loadScript(match[1]);
});
  }
});

ActionUtils = {

...

Resources : [],

loadScript : function(resource, onload) {
if(!this.Resources.include(resource)){
var script = new Element('script', {
'type' : 'text/javascript',
'src' : resource
});

script.onload = onload | this.emptyFunction;
this.getHtmlHead().insert(script);
this.Resources.push(resource);
}
}
}

(Prototype's ScriptFragment property has not been changed in this
scenario!)

In this way, developpers don't bother how to include external JS
files, the asynchronous circuit does all the job for them.
Nevertheless, I think that inline scripts may be executed before
external resource has been completely interpreted, which may lead to
invalid references.

This has only been tested on Firefox, so let me know if it works with
other main browsers.

[1] http://www.phpied.com/javascript-include-ready-onload/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Drag and drop Images

2009-05-06 Thread Diodeus

I suggest you make a stripped-down version instead of expecting people
to pore over hundreds of lines of code, which you didn't even bother
to remove the commented-out parts.

On May 6, 3:27 am, sandy  wrote:
> Hi all ,
>
> I am doing image drag and drop functionality in asp.net, the drag
> functionality is working fine but my drop functionality is not working
> fine so i need help.
> I am getting the error in prototype.js file in line number 1903 "var
> value = element.style[style];" element is null. and i ma stuck on this
> from last one week.the whole code of my aspx file is here...
>
> <%@ Page Language="C#" AutoEventWireup="true"
> CodeBehind="ImageUpload.aspx.cs"
> Inherits="WebPages2.Advertiser.ImageUpload" MasterPageFile="~/
> Advertiser/AdvertiserMaster.Master" %>
>
>  runat="server">
>
>      script>
>