On Sat, Mar 1, 2008 at 6:57 AM, <[EMAIL PROTECTED]> wrote:

> Author: lindner
> Date: Sat Mar  1 06:57:57 2008
> New Revision: 632597
>
> URL: http://svn.apache.org/viewvc?rev=632597&view=rev
> Log:
> Implement skins feature as described in SHINDIG-98
>
> Modified:
>    incubator/shindig/trunk/config/syndicator.js
>    incubator/shindig/trunk/features/skins/skins.js
>
> Modified: incubator/shindig/trunk/config/syndicator.js
> URL:
> http://svn.apache.org/viewvc/incubator/shindig/trunk/config/syndicator.js?rev=632597&r1=632596&r2=632597&view=diff
>
> ==============================================================================
> --- incubator/shindig/trunk/config/syndicator.js (original)
> +++ incubator/shindig/trunk/config/syndicator.js Sat Mar  1 06:57:57 2008
> @@ -79,4 +79,15 @@
>     // requests.
>     "useLegacyProtocol" : false,
>   },
> +  // Skin defaults
> +  "skins" : {
> +    "properties" : {
> +         "BG_COLOR": "",
> +         "BG_IMAGE": "",
> +         "BG_POSITION": "",
> +         "BG_REPEAT": "",
> +         "FONT_COLOR": "",
> +         "ANCHOR_COLOR": "",
> +    }
> +  },
>  }}
>
> Modified: incubator/shindig/trunk/features/skins/skins.js
> URL:
> http://svn.apache.org/viewvc/incubator/shindig/trunk/features/skins/skins.js?rev=632597&r1=632596&r2=632597&view=diff
>
> ==============================================================================
> --- incubator/shindig/trunk/features/skins/skins.js (original)
> +++ incubator/shindig/trunk/features/skins/skins.js Sat Mar  1 06:57:57
> 2008
> @@ -28,20 +28,48 @@
>  *     currently shown skin.
>  * @name gadgets.skins
>  */
> -gadgets.skins = gadgets.skins || {};
> +gadgets.skins = function() {
> +  var skinProperties = {};
> +
> +  var requiredConfig = {
> +    "properties": gadgets.config.ExistsValidator
> +  };
> +
> +  gadgets.config.register("skins", requiredConfig, function(config) {
> +        skinProperties = config["skins"].properties;
> +      });
>
> -/**
> - * Fetches the display property mapped to the given key.
> - *
> - * @param {String} propertyKey The key to get data for;
> - *    keys are defined in <a href="gadgets.skins.Property.html"><code>
> - *    gadgets.skins.Property</code></a>
> - * @return {String} The data
> - *
> - * @member gadgets.skins
> - */
> -gadgets.skins.getProperty = function(propertyKey) {};
>
> +  return {
> +    /**
> +     * Override the default properties with a new set of properties.
> +     *
> +     * @param {Object} properties The mapping of property names to values
> +     */
> +    init : function(properties) {
> +      skinProperties = properties;
> +    },


This seems redundant -- you already have it wired to the normal config
registration.


>
> +
> +    /**
> +     * Fetches the display property mapped to the given key.
> +     *
> +     * @param {String} propertyKey The key to get data for;
> +     *    keys are defined in <a href="gadgets.skins.Property.html
> "><code>
> +     *    gadgets.skins.Property</code></a>
> +     * @return {String} The data
> +     *
> +     * @member gadgets.skins
> +     */
> +    getProperty : function(propertyKey) {
> +
> +      var property = skinProperties[propertyKey];
> +      if (property) {
> +        return property;
> +      }
> +      return "";


You can shorten this to return skinProperties[propertyKey] || "";
(coincidentally,  it looks like  the skins API spec needs to be amended to
be specific about what  is supposed to be returned for invalid properties).


>
> +    }
> +  }
> +}();
>  /**
>  * @static
>  * @class
> @@ -71,8 +99,21 @@
>   FONT_COLOR : 'FONT_COLOR',
>
>   /**
> +   * The positioning of the background image
> +   * @member gadgets.skins.Property
> +   */
> +  BG_POSITION : 'BG_POSITION',
> +
> +  /**
> +   * The repeat characteristics for the background image
> +   * @member gadgets.skins.Property
> +   */
> +  BG_REPEAT : 'BG_REPEAT',
> +
> +  /**
>    * The color that anchor tags should use.
>    * @member gadgets.skins.Property
>    */
>   ANCHOR_COLOR : 'ANCHOR_COLOR'
> +
>  };



We should probalby use gadgets.util.makeEnum() for this.


-- 
~Kevin

Reply via email to