Posted By

netcraft on 02/28/08


Tagged

yahoo config yui ui


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

tcol


A guide to YUI Config utility


 / Published in: JavaScript
 

Config is a utility used within an Object to allow the implementer to maintain a list of local configuration properties and listen for changes to those properties dynamically using CustomEvent. The initial values are also maintained so that the configuration can be reset at any given point to its initial state.

Dependencies: * yahoo.js * event.js

  1. // JScript source code
  2. var Object = function(){
  3. var cfg = new YAHOO.util.Config(this);
  4. element;
  5.  
  6. initDefaultConfig: function() {
  7.  
  8. this.cfg.addProperty(
  9. "color",
  10. {
  11. value: "#000000",
  12. handler: setColor
  13. }
  14. );
  15.  
  16. this.cfg.addProperty(
  17. "width",
  18. {
  19. value: null,
  20. handler: setWidth
  21. }
  22. );
  23.  
  24. this.cfg.fireQueue();
  25. }
  26.  
  27. var setColor = function(type, args, obj){
  28. var color = args[0];
  29. YAHOO.util.Dom.setStyle(element, "color", color);
  30. }
  31.  
  32. var setWidth = function(type, args, obj){
  33. var width = args[0] + "px";
  34. YAHOO.util.Dom.setStyle(element, "width", width);
  35. }
  36.  
  37. this.init = function(elementId){
  38. element = YAHOO.util.Dom.get(elementId);
  39. initDefaultConfig();
  40. }
  41. };

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: netcraft on February 28, 2008

This is my post.. I can't seem to find the edit post option anywhere... HELP?

Posted By: jaytee on February 28, 2008

It should be on the side under "Snippet Actions" when you are viewing the snippet.

You need to login to post a comment.