[Proto-Scripty] Re: OverLIB Clone - IE not appending to Style Tag - setStyle() sometimes not working

2009-06-05 Thread IMBI-Indie-Portal

Thanks Walter!
 Some good advice. I'll bare those methods in mind for future
projects..

I guess the best practice would be as follows:

If you have to use a 'name' which needs to be quoted, quote them all!

I didn't know about the 'cssName' type, so I'll be trying those as
well.

If I find a solution using Prototype to the IE problem of not
appending to the style tag I will add it to this posting group, in
case someone else has the same problem.

Thanks Again!
 Gilbert Rehling


On Jun 3, 11:26 pm, Walter Lee Davis wa...@wdstudio.com wrote:
 But to reiterate, the key here is to pick one format for the entire  
 hash, and stick to it. Prototype sniffs the first element in the  
 hash to figure out which method to use all the rest of the way through  
 the rest of the hash. This is done for performance reasons.

 Walter

 On Jun 3, 2009, at 9:06 AM, Walter Lee Davis wrote:



   if you want to use the bare
  camelCase words.- Hide quoted text -

 - Show quoted text -
--~--~-~--~~~---~--~~
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: OverLIB Clone - IE not appending to Style Tag - setStyle() sometimes not working

2009-06-03 Thread IMBI-Indie-Portal

Thanks Walter, I have noticed some varied usage of 'quoted' and
unquoted, and some reports that some 'names' must be quoted and others
work fine unquoted... in particular 'float' must be quoted to work at
all..

Seems like odd behaviour to me

Thanks Colin, I think its time for me to organise sime spectacles. It
was a loing week at the Laptop screen...

Yes, I wanted to use a shortcut method to get IE writing to the
style tag..
Unfortunatly the code for IE does not work for Firefox..

From -- www.rule52.com/

var CSSRules = function() {

 var headElement = document.getElementsByTagName(head)[0],
  styleElement = document.createElement(style);
 styleElement.type = text/css;
 headElement.appendChild(styleElement);

 // memoize the browser-dependent add function
 var add = function() {
  // IE doesn't allow you to append text nodes to style elements
  if (styleElement.styleSheet) {
   return function(selector, rule) { // IE Method
 if (styleElement.styleSheet.cssText == '') {
   styleElement.styleSheet.cssText = '';
 }
 styleElement.styleSheet.cssText += selector +  {  + rule +
 };
   }
  } else {
   return function(selector, rule) { // Firefox and Co..
styleElement.appendChild(document.createTextNode(selector +  { 
+ rule +  }));
   }
  }
 }();

 return {
  add : add
 }

A long way for a short job!!

I might try messing with the $$(CSS) method when the weekend comes
along and see if I can get something happening..

Thanks for the responses..

Regards,
 Gilbert R



On Jun 3, 12:07 am, ColinFine colin.f...@pace.com wrote:
 On Jun 2, 1:37 pm, IMBI-Indie-Portal imbil...@tpg.com.au wrote: Thanks 
 Colin, but, there is a space, if you check the source code
  page, It didn't fit to well into the post.
  As you can see, it works as a HTMLDOM style, almost the same code..
  border: this.olc_divborder+'px' +this.olc_bordercol+ 'solid'
  there is one space on each side.

 There is not. There is a space *outside* the quotes, but not one that
 will go into the string which you are generating. This will pass an
 object like

 { border: '222pxblacksolid' }

  The way I read it from the DOCS is that if it works as a HTMLDOM
  shorthand method, it should work in setStyle(); ???

 Yes. But the shorthand property  has a different name from the
 individual property. You appeared to be trying to say
 { backgroundImage: 'url(xxx) top left' }
 instead of
 { background: 'url(xxx) top left' }
 or
 { backgroundImage: 'url(xxx)',
   backgroundPosition: 'top left' }

 I don't know about the appendChild 
 problem.http://www.phpied.com/dynamic-script-and-style-elements-in-ie/gives a
 solution, but I think you know this and are asking about whether
 Prototype helps with it or not, and I don't know the answer.
--~--~-~--~~~---~--~~
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: OverLIB Clone - IE not appending to Style Tag - setStyle() sometimes not working

2009-06-02 Thread IMBI-Indie-Portal

Thanks Colin, but, there is a space, if you check the source code
page, It didn't fit to well into the post.
As you can see, it works as a HTMLDOM style, almost the same code..
border: this.olc_divborder+'px' +this.olc_bordercol+ 'solid'
there is one space on each side.

The way I read it from the DOCS is that if it works as a HTMLDOM
shorthand method, it should work in setStyle(); ???
The W3 page doesn't show any value/rule references...
I'll try the backgroundImage without the extras - I'm sure I saw an
example somewhere using all though.

The extra $$('head') is not really there, I tried to use that at the
beginning, but it did not work as expected, I just pasted it there on
the end instead of deleting it, just ignore it please

The actual problem there is that IE wont append data into the  the
style tag. Firefox woks OK.
- headElement.appendChild(styleElement); (fails in IE)

I tried the  headElement = $$('head') thinking it would extend some
methods on the head object to help prototype deal with the IE
business, but to no avail??

I'm wonder is there a way Prototype can deal with this IE
appendTextNode problem??

THat popup is the 4th one down on the right on the sample page if you
want to try it out live..
http://www.imbi.com.au/overlib-clone-mini-prototype-class/overlib-clone-sample.php

Apart from that she works quite well
Can't say more than that.

Regards and Thanks,
  Gilbert R


On Jun 1, 11:19 pm, ColinFine colin.f...@pace.com wrote:
 On May 31, 1:37 pm, Imbi Rehling imbil...@tpg.com.au wrote:



   if(this.olc_divborder) {
      $(id).style.border=this.olc_divborder+'px solid '+this.olc_bordercol;
      /* $(id).setStyle({ border: this.olc_divborder+'px' +this.olc_bordercol+
   'solid' }); */
      this.diagnostics('div border set to '+this.olc_divborder+'px');
   }

 In the commented-out code there are no spaces after 'px' or before
 'solid'.

   The commented out code is not working. Any thoughts???
   Second Part:
   if(this.olc_background){
      $('textDiv').style.backgroundImage=url(+this.olc_background+);
      /* $('textDiv').setStyle({ backgroundImage:
   'url('+this.olc_background+') top left' }); */
      this.diagnostics('text area background set!');
   }

 backgroundImage wants only the image. If you want to give more than
 one property, you need to use the other 'backgroundXxx' properties, or
 use 'background' to give them all together.







   No2:
      I created a method to add a style tag into the head and add some
   selector-rules code into it. Firstly its for the (Click to Close Link) and
   for generating fixed classes for various popup elements including the new
   (Feature Selector) method...
          It works OK in firefox, but, apparently IE has some issues adding a
   'textnode' into a style element (tag). I had hoped that prototype would
  have
   circumvented this problem??
   The method called 'add_style is on line 504..
   Here is the code I'm using within the method:

   var headElement = document.getElementsByTagName(head)[0], styleElement =
   document.createElement(style), selector, rule; /* headElement =
   document.getElementsByTagName(head)[0], headElement = $$('head') */

 In your commented code you're setting 'headElement' twice, and the
 second time you're setting it to an Array, not an Element.

 Why not use just use var headElement = head; (or window.head if you
 prefer) since there's only one of them?

 I haven't looked to see if there are any other errors: these are just
 the obvious ones at the start.- Hide quoted text -

 - Show quoted text -
--~--~-~--~~~---~--~~
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: Using this.arrayname to add data to an array not working

2009-04-30 Thread IMBI-Indie-Portal

Hi, Yes I found some good info by Mr Crockford and friends a few weeks
ago.
I was looking up some info on advanced AJAX security techniques.

Found these pages:
http://www.webdirections.org/resources/douglas-crockford-ajax-security/
Some interesting presentation slides...
and from there a link to:
http://www.codinghorror.com/blog/archives/001175.html

Unfortunatly I wont be buying any more books untill I get a job.
Have an Interview with a 'recruiting crowd' today [friday].
Fingers crossed..

I have now replaced the XML in the Q and A app with JSON, and, added
caching for the fetched q and a sets.
Works like a dream.

Any thoughts yet on why the bind() function won't work within the
Ajax.Request??

Not important, just curious..
Mabye its an unexpected bug in the prototype AJAX implementation?
Is there another group/list where that question might be more
appropriate?

Thanks Again!
Gilbert R..
--~--~-~--~~~---~--~~
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: Using this.arrayname to add data to an array not working

2009-04-28 Thread IMBI-Indie-Portal

Hi! Thanks T.J and Colin.

So Far So Good!

I stayed with the 'inline method', to save code.

I could Not get the bind() to work within the Ajax.Request though??
I tried it as T.J showed, and several other ways.
Firebug reported different errors.
Suggested method for inline returned (' missing } from property
statement') with parenthes ')' and
syntax errors without them.
Trying in other positions had similar errors..

One odd bit of behaviour noted though.
After populating the arrays and after exiting the Ajax.functions, when
I did 'alert(this.cap_questions) before the method finished only got a
blank result, not undefined, just blank.
I figured that self = this is like using the PHP  operator which
binds the new var to the original?
I even tried to alert(self.cap_questions) and got the same blank
result.
Yet, the arrays where populated as expected?? I guess part of the game
is having faith in what your doing!

I used the 'var self = this;'  Worked like a dream - thanks.

I did use the bind() in a few other places, like inside some
setTimeout's - where I wrap in a function() as per LINT methods..

I definately learnt a few new things tonight. Much appretiated. I
relate a lot to my PHP Classes and basic JS knowledge, but I'll have
to do some homework on Prototype Classes and Js Classes and Objects.
My Js function days are over. Classes from now on..

The second issue about calling one method from within another resolved
itself using the bind().

I also did a quick test, regarding what you said about 'global vars'.
I set a var in one method and tested for in in the next one that runs,
but it returned 'undefined'..
I did tidy up the vars as you suggested though!

I'll study the links that you gave me to see if I can undeestand how
globals (declared vars) run their scope in Js classes.
I think thats the key issue with all od this, scope..

I know that globals can be a bad thing as per ADSafe specs..

I'm going to be re-writing most of my JS into classes now, so you may
hear from me again on classes if I get stuck..

I have another problem with prototype that I want to ask about, but as
its not related so I'll start a new thread tommorow.
Its bedtime now here in Oz..

Thanks again for your prompt help. This is a great group.
Signing Off - Gilbert R
--~--~-~--~~~---~--~~
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: Using this.arrayname to add data to an array not working

2009-04-27 Thread IMBI-Indie-Portal

Thanks T.J.

I probably should have been more specific.

I'm actually building a Q and A Captcha, not a Logger. I used that as
an example.

The issue is, I am using proto's Ajax.Request and I'm running that
code within the 'onComplete: function(transport){ callback }' and this
is executing within a method which get an array of questions from a
database.
Another method then creates a select list and renders it to the page.

I have found that if I declare a var using the 'this.arrayName' before
running the Ajax.Request I can load the array OK.

What is strange, is that I can then do 'this.ArrayName  = var;' and
populate the objects array whilst I'm still in the  'onComplete
callback'.

Why is it that I cant load the this,arrayName as shown, but it lets be
're-value it'??

Here is a sample of the code: some var declarations are Not show for
simplicity...

var qArr = this.cap_questions; // I CREATE THE USABLE VAR WORKAROUND
HERE 
var url = path-to-php-script-sid=+Math.random();
var req = new Ajax.Request( url, {  // I USE THE var = req TO MAKE
JSLINT HAPPY ??
method: 'get', contentType: 'application/xml', onComplete: function
(transport) {
res = transport.responseXML; cap_nodes = 
res.getElementsByTagName
('group');
for(i=0; i  cap_nodes.length; i++){
qArr.push(cap_nodes[i].childNodes[0].nodeValue);
}
this.cap_questions = qArr; // HERE IT LETS ME RE-DECLARE THIS
OBJECTS VALUE?
}
});

If I try to declare the VAR within the callback it won't work either,
Has to be before the new Ajax.Request.
I checked with 'typeof' and it returns 'undefined'

I have another problem as well.

How can I call a method within another method, like in PHP.

Using 'this.methodName() does not seem to work.
After completion of one methods db retrieval, I do a check for state,
and would like to call a method within the working method.
The idea worked (as functions) before I re-wrote the whole idea into
a  single class.
I want the class to be as dynamic as possible, and dont want to have
to add more intelect to the pages code.
This will be a publicly available App, so I'm trying to make it as
simple as possible to setup.

Thanks again for the Quick HELP. Its much appreciated!
Cheers, Gilbert R..
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---