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:07 UTC
[05/17] incubator-ponymail git commit: refactor cog function using
the new DOM tools
refactor cog function using the new DOM tools
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/8b7e9c41
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/8b7e9c41
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/8b7e9c41
Branch: refs/heads/coffee-and-cake
Commit: 8b7e9c415556ed7916ade077d947c8cfde158ca9
Parents: f36d556
Author: Daniel Gruno <hu...@apache.org>
Authored: Thu Sep 1 17:07:15 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Thu Sep 1 17:07:15 2016 +0200
----------------------------------------------------------------------
site/js/coffee/dom_utils.coffee | 34 +++++++++++++++++++---------------
1 file changed, 19 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/8b7e9c41/site/js/coffee/dom_utils.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/dom_utils.coffee b/site/js/coffee/dom_utils.coffee
index 847dc1e..5ac2692 100644
--- a/site/js/coffee/dom_utils.coffee
+++ b/site/js/coffee/dom_utils.coffee
@@ -33,27 +33,27 @@ mk = (type, params, children) ->
if params
for k, v of params
# Standard string value?
- if typeof v == "string"
+ if typeof v is "string"
r.setAttribute(k, v)
# Are we passing a list of data to set? concatenate then
else if isArray(v)
r.setAttribute(k, v.join(" "))
# Are we trying to set multiple sub elements, like a style?
- else if typeof(v) == "object"
+ else if typeof(v) is "object"
for x,y of v
r[k][x] = y
# If any children have been passed, add them to the element
if children
# If string, convert to textNode using txt()
- if typeof children == "string"
+ if typeof children is "string"
app(r, txt(children))
else
# If children is an array of elems, iterate and add
if isArray children
for k in children
# String? Convert via txt() then
- if typeof k == "string"
+ if typeof k is "string"
app(r, txt(k))
# Plain element, add normally
else
@@ -72,14 +72,14 @@ app = (a,b) ->
if isArray b
for item in b
# String? Convert to textNode first then
- if typeof item == "string"
+ if typeof item is "string"
item = txt(item)
# Otherwise just add it
a.appendChild(item)
# Otherwise, just add
else
# String? Convert first
- if typeof b == "string"
+ if typeof b is "string"
a.appendChild(txt(b))
# Not a string, add normally
return a.appendChild(b)
@@ -100,14 +100,18 @@ get = (a) ->
# Cog: Loading panel for when waiting for a response
cog = (div, size = 200) ->
- idiv = document.createElement('div')
- idiv.setAttribute("class", "icon")
- idiv.setAttribute("style", "text-align: center; vertical-align: middle; height: 500px;")
- i = document.createElement('i')
- i.setAttribute("class", "fa fa-spin fa-cog")
- i.setAttribute("style", "font-size: " + size + "pt !important; color: #AAB;")
- idiv.appendChild(i)
- idiv.appendChild(document.createElement('br'))
- idiv.appendChild(document.createTextNode('Loading data, please wait...'))
+ idiv = mk('div', { class: "icon", style: {
+ texAlign: 'center',
+ verticalAlign: 'middle',
+ height: '500px'
+ }
+ )
+
+ i = mk('i', { class: 'fa fa-spin fa-cog', style: {
+ fontSize: size+'pt !important',
+ color: '#AAB'
+ }
+ )
+ app(idiv, [i, mk('br'), "Loading data, please wait..."])
div.innerHTML = ""
div.appendChild(idiv)