You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by hu...@apache.org on 2016/09/02 07:44:04 UTC
[02/17] incubator-ponymail git commit: allow for hash-type element
parameters
allow for hash-type element parameters
this will enable things like styles to be set
using a hash instead of a long string.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/b43dd969
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/b43dd969
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/b43dd969
Branch: refs/heads/coffee-and-cake
Commit: b43dd96981599876f472841b85a3c15aa8ec93de
Parents: 6dad4bc
Author: Daniel Gruno <hu...@apache.org>
Authored: Thu Sep 1 16:58:41 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Thu Sep 1 16:58:41 2016 +0200
----------------------------------------------------------------------
site/js/coffee/dom_utils.coffee | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/b43dd969/site/js/coffee/dom_utils.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/dom_utils.coffee b/site/js/coffee/dom_utils.coffee
index 43bc815..3419119 100644
--- a/site/js/coffee/dom_utils.coffee
+++ b/site/js/coffee/dom_utils.coffee
@@ -20,7 +20,7 @@
# - type: HTML element type (div, table, p etc) to produce
# - params: hash of element params to add (class, style etc)
# - children: optional child or children objects to insert into the new element
-# Example: mk('div', { class: "footer", style: "font-weight: bold;"}, "Some text inside a div")
+# Example: mk('div', { class: "footer", style: {fontWeight: "bold"}}, "Some text inside a div")
mk = (type, params, children) ->
# create the raw element
r = document.createElement(type)
@@ -28,8 +28,13 @@ mk = (type, params, children) ->
# If params have been passed, set them
if params
for k, v of params
- if v
+ # Standard string value?
+ if typeof v == "string"
r.setAttribute(k, v)
+ # Are we trying to set multiple sub elements, like a style?
+ else if typeof(v) == "object" and not isArray(v)
+ for x,y of v
+ r[k][x] = y
# If any children have been passed, add them to the element
if children