[Proto-Scripty] Re: method ON vs OBSERVE

2011-10-28 Thread Victor
Here is the code (borrowed from some project) I'm using for bubbling focus 
and blur events:

/**
 * Bubbling focus:in and focus:out events.
 * Usage:
 *   document.on(focus:in, selector, focusHandler); // on focus
 *   document.on(focus:out, selector, blurHandler); // on blur
 */
(function() {
  // custom stripped version of Event.findElement
  function element(event) {
//var node = Event.extend(event).target;
var node = event.target || event.srcElement;
return Element.extend(node.nodeType == Node.TEXT_NODE ? node.parentNode 
: node);
  }

  // custom optimized version of event firing
  var fire = document.createEvent ? (function fireDOM(element, eventName) {
if (element == document  !element.dispatchEvent) {
  element = document.documentElement;
}
var event = document.createEvent('HTMLEvents');
event.initEvent('dataavailable', true, true);
event.eventName = eventName;
event.memo = {};
element.dispatchEvent(event);
  }) : (function fireIE(element, eventName) {
var event = document.createEventObject();
event.eventType = 'ondataavailable';
event.eventName = eventName;
event.memo = {};
element.fireEvent(event.eventType, event);
  });

  function focusInHandler(event) {
//Event.findElement(event).fire(focus:in);
fire(element(event), focus:in);
  }
  function focusOutHandler(event) {
//Event.findElement(event).fire(focus:out);
fire(element(event), focus:out);
  }

  if (document.addEventListener) {
document.addEventListener(focus, focusInHandler, true);
document.addEventListener(blur, focusOutHandler, true);
  } else {
document.observe(focusin, focusInHandler);
document.observe(focusout, focusOutHandler);
  }
})();

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/prototype-scriptaculous/-/CKUmXBHB7ZMJ.
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: What performs better? 30 observers on specific elements or 1 Observer observing every click?

2011-10-28 Thread Victor


 you suggest adding one special class or attribute to all clickable 
 elements, so that in my observer I can check for that class/attribute in 
 the very first line minimizing the amount of if statements


yes
 

 PLUS you suggest to delegate the triggered event to the [clicked] element


to module/class/etc., which is responsible for processing events on 
elements of this type
 

 so that I don't have one big eventhandler and can keep a good software 
 structure?


exactly

Also you can develop new modules without changing main event handler, and 
add/remove elements in document dynamically.

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/prototype-scriptaculous/-/4P2bGPMHmugJ.
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.



RE: [Proto-Scripty] Re: An idea from jQuery which might be borrowed to Prototype

2011-10-28 Thread wwwboy
It’s depend on your mood :)

 

From: prototype-scriptaculous@googlegroups.com 
[mailto:prototype-scriptaculous@googlegroups.com] On Behalf Of Victor
Sent: Thursday, October 27, 2011 11:52 PM
To: prototype-scriptaculous@googlegroups.com
Subject: [Proto-Scripty] Re: An idea from jQuery which might be borrowed to 
Prototype

 

Jon Dow == John Doe? ;) 

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/prototype-scriptaculous/-/2jp7KMInIvAJ.
To post to this group, send email to  
mailto:prototype-scriptaculous@googlegroups.com 
prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to  
mailto:prototype-scriptaculous+unsubscr...@googlegroups.com 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at  
http://groups.google.com/group/prototype-scriptaculous?hl=en 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

-- 
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] Done but with errors on when page loads.

2011-10-28 Thread DeveloperDavid
I am using prototype 1.7 and get an error on line 5736
element.fireEvent(event.eventType, event);
and 5988
return $(parentElement ||
document.body).getElementsByClassName(className); prototype.js
element.fireEvent(event.eventType, event);

The error I receive is
Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/
4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR
3.0.30729; .NET4.0C; .NET4.0E; InfoPath.3)
Timestamp: Fri, 28 Oct 2011 13:27:44 UTC


Message: Object doesn't support this property or method
Line: 5988
Char: 5
Code: 0
URI: http://dev.my.tweb02.mcphs.edu/scripts/prototype.js


Message: Object doesn't support this property or method
Line: 5736
Char: 7
Code: 0
URI: http://dev.my.tweb02.mcphs.edu/scripts/prototype.js

Is this a known issue? I am using IE8.


-- 
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.



Re: [Proto-Scripty] Silly Question

2011-10-28 Thread Richard Quadling
Locally, I had to put delays on my server code to actually allow this
to be visible. Once I was convinced things were working, I removed the
delay and I don't think I ever so it now.


On 11 October 2011 15:08, Phil Petree phil.pet...@gmail.com wrote:
 I'm with you Richard.

 I have a hidden div that loads the spinner and in the AJAX onCreate I
 disable the form and unhide the div while in the  onComplete I hide the div
 and enable the form.

 What I have found is that if the AJAX call starts and completes quickly then
 the spinner never gets displayed as the browser is smart enough not to do
 a repaint if not needed.

 On Tue, Oct 11, 2011 at 7:12 AM, Richard Quadling rquadl...@gmail.com
 wrote:

 On 11 October 2011 00:04, nelian i...@myskills.co.za wrote:
  I am somewhat new to AJAX, but one thing that I have not touch upon is
  the following -
 
  When my App is making an AJAX call, from the users perspective it
  seems to be doing nothing, how does one go about freezing the page
  (Not sure what else to call it) and indicate to the user that
  something is happening?
  (I have seen it on a couple of sites, but cannot seem to find an
  example at the moment)
 
  Thanks in advance for the help
 
  Ian
 
  --
  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.
 
 

 I use the Ajax.Responders
 (http://api.prototypejs.org/ajax/Ajax/Responders/) to allow me to
 handle the creation and completion of all AJAX requests.

 In my requests, I fade in a little spinner image after 0.25s. It fades
 out on completion.

 So, if the request is handled in handled in under 0.25s, then no spinner.

 This seems to work quite well for me.

 --
 Richard Quadling
 Twitter : EE : Zend : PHPDoc
 @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

 --
 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.


 --
 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.




-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc : Fantasy Shopper
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea :
fan.sh/6/370

-- 
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.



Re: [Proto-Scripty] Re: Adding CSS-Rules to a styletag in Prototype

2011-10-28 Thread Richard Quadling
On 20 October 2011 13:30, Luke lukas.bomb...@googlemail.com wrote:
 Thanks, Joe T.
 Walter: The problem is, that on my page the user can add/remove contents and
 also change the styles of those contents dynamically using JS. Now if you
 set a Style to certain elements, either via changing the style-tag or adding
 a class-name and *afterwards* add content, that content won't be styled. Of
 course, I save the applied style-settings in my backend and so I could apply
 the style-definitions when I generate the added content, but that maybe that
 might not be the case anymore in the future and also it's easier to set a
 style-definition in a style tag, rather than doing the backend-thing.

I've no idea if this will be useful, but just to explain some background.

I have a page which displays about 100 company names in columns
(rather than in rows). To achieve this, knowing the maximum width of
the elements was required and then setting the CSS width for that
style so all were styled correctly.

IE, FF and Chrome supported.

Also, I use a CSS and JS combinator, so I only have 1 JS and CSS file request.

Working on using a single image one also, so 4 loads per page (HTML,
CSS, JS and IMG). CSS, JS and IMG are cached, so page loading is a LOT
faster and server load WAY down.

But I digress ...

function sizeElements(o_Container)
{
console.group('sizeElements(', arguments, ')');

// Set the size on formInput labels and scrollBox labels
// Siblings only.
['.formInput  label', '.scrollBox  label'].each
(
function(s_CSS)
{
console.group('sizeElements.each(', arguments, ')');

// Size the labels to the widest.
var i_LargestLabel = o_Container.select(s_CSS +
':not(.nonSpacing):not(.shortNonSpacing)').invoke('getWidth').max();

// If there was a size, then update the container's CSS 
rule.
if ( i_LargestLabel != undefined)
{
var o_CSS = window.document.styleSheets[0];
var o_CSSRules = (o_CSS.cssRules) ? 
o_CSS.cssRules : o_CSS.rules;
var o_CSSRule =
o_CSSRules[$A(o_CSSRules).pluck('selectorText').invoke('toLowerCase').indexOf('#'
+ o_Container.id.toLowerCase() + ' ' + s_CSS.toLowerCase())];

o_CSSRule.style.width = i_LargestLabel + 'px';
}
console.groupEnd();
}
);

console.groupEnd();
}


Programmatically, I'm looking to set the width on the CSS rules of

.formInput  label
and
.scrollBox  label



-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc : Fantasy Shopper
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea :
fan.sh/6/370

-- 
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: Done but with errors on when page loads.

2011-10-28 Thread Victor
You are trying to invoke methods on not extended element in IE8, right? 
E.g. instead of $(element).fire(some:thing) you are using 
element.fire(some:thing).

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/prototype-scriptaculous/-/r1R5tMbY3zQJ.
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: Done but with errors on when page loads.

2011-10-28 Thread T.J. Crowder
On Oct 28, 2:31 pm, DeveloperDavid d.smith38h...@gmail.com wrote:
 Message: Object doesn't support this property or method

Have a read through this tutorial from the prototypejs.org site:
http://prototypejs.org/learn/extensions

Elements can be automagically extended on other browsers, but not IE.
You have to make sure you're dealing with an extended one. All
elements you get via Prototype are pre-extended for you, but if you
create or retrieve them via other means, they won't be. See the
article for details.
--
T.J. Crowder
Independent Software Engineer
tj / crowder software / com
www / crowder software / com

-- 
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.