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 11:26:43 UTC
[1/2] incubator-ponymail git commit: elaborate test a bit
Repository: incubator-ponymail
Updated Branches:
refs/heads/coffee-and-cake e3d0fc756 -> a9040b3cb
elaborate test a bit
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/7569231b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/7569231b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/7569231b
Branch: refs/heads/coffee-and-cake
Commit: 7569231b474dc0697c3c5ca283a11929d6e54203
Parents: e3d0fc7
Author: Daniel Gruno <hu...@apache.org>
Authored: Fri Sep 2 13:22:38 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Fri Sep 2 13:22:38 2016 +0200
----------------------------------------------------------------------
site/js/coffee/test.coffee | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/7569231b/site/js/coffee/test.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/test.coffee b/site/js/coffee/test.coffee
index 30a7cb1..bff04c4 100644
--- a/site/js/coffee/test.coffee
+++ b/site/js/coffee/test.coffee
@@ -2,10 +2,18 @@ testCoffee = () ->
### Get main div from HTML ###
parent = get('testdiv')
# Make a paragraph with some text in it
- p = mk('p', { onclick: 'testToggle(this);', class: "fooclass", style: { textAlign: 'center'}}, "Text goes here")
+ p = mk('p', { class: "fooclass", style: { textAlign: 'center'}}, "Text goes here")
+
# Inject paragraph into div
parent.inject(p)
- p.inject(". More text here")
+
+ # Add some plain text and a break
+ p.inject([". Here's a textNode added afterwards", mk('br')])
+
+ # Make an object we can hide when clicked on, using the show() prototype
+ hider = mk('b', { onclick: 'testToggle(this);'}, "Click here to hide this text!")
+ p.inject(hider)
+
testToggle = (div) ->
div.show()
\ No newline at end of file
[2/2] incubator-ponymail git commit: reshape mk as a HTML class
Posted by hu...@apache.org.
reshape mk as a HTML class
this makes it more logical what we're doing, which is
essentially creating a new object.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/a9040b3c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/a9040b3c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/a9040b3c
Branch: refs/heads/coffee-and-cake
Commit: a9040b3cb11e41ff17b1054156c7dc836432499b
Parents: 7569231
Author: Daniel Gruno <hu...@apache.org>
Authored: Fri Sep 2 13:26:16 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Fri Sep 2 13:26:16 2016 +0200
----------------------------------------------------------------------
site/js/coffee/dom_utils.coffee | 73 ++++++++++++++++++------------------
site/js/coffee/test.coffee | 6 +--
2 files changed, 40 insertions(+), 39 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/a9040b3c/site/js/coffee/dom_utils.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/dom_utils.coffee b/site/js/coffee/dom_utils.coffee
index 9ca7fed..ac4db5c 100644
--- a/site/js/coffee/dom_utils.coffee
+++ b/site/js/coffee/dom_utils.coffee
@@ -27,43 +27,44 @@
# - children: optional child or children objects to insert into the new element
# 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)
-
- ### If params have been passed, set them ###
- if isHash(params)
- for k, v of params
- ### Standard string value? ###
- if typeof v is "string"
- r.setAttribute(k, v)
- else if isArray(v)
- ### Are we passing a list of data to set? concatenate then ###
- r.setAttribute(k, v.join(" "))
- else if isHash(v)
- ### Are we trying to set multiple sub elements, like a style? ###
- 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 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 is "string"
- app(r, txt(k))
- else
- ### Plain element, add normally ###
- app(r, k)
+class HTML
+ constructor: (type, params, children) ->
+ ### create the raw element ###
+ r = document.createElement(type)
+
+ ### If params have been passed, set them ###
+ if isHash(params)
+ for k, v of params
+ ### Standard string value? ###
+ if typeof v is "string"
+ r.setAttribute(k, v)
+ else if isArray(v)
+ ### Are we passing a list of data to set? concatenate then ###
+ r.setAttribute(k, v.join(" "))
+ else if isHash(v)
+ ### Are we trying to set multiple sub elements, like a style? ###
+ 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 is "string"
+ app(r, txt(children))
else
- ### Just a single element, add it ###
- app(r, children)
- return r
+ ### 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 is "string"
+ app(r, txt(k))
+ else
+ ### Plain element, add normally ###
+ app(r, k)
+ else
+ ### Just a single element, add it ###
+ app(r, children)
+ return r
###*
# App: Shortcut for document.appendChild with modifications
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/a9040b3c/site/js/coffee/test.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/test.coffee b/site/js/coffee/test.coffee
index bff04c4..2f02187 100644
--- a/site/js/coffee/test.coffee
+++ b/site/js/coffee/test.coffee
@@ -2,16 +2,16 @@ testCoffee = () ->
### Get main div from HTML ###
parent = get('testdiv')
# Make a paragraph with some text in it
- p = mk('p', { class: "fooclass", style: { textAlign: 'center'}}, "Text goes here")
+ p = new HTML('p', { class: "fooclass", style: { textAlign: 'center'}}, "Text goes here")
# Inject paragraph into div
parent.inject(p)
# Add some plain text and a break
- p.inject([". Here's a textNode added afterwards", mk('br')])
+ p.inject([". Here's a textNode added afterwards", new HTML('br')])
# Make an object we can hide when clicked on, using the show() prototype
- hider = mk('b', { onclick: 'testToggle(this);'}, "Click here to hide this text!")
+ hider = new HTML('b', { onclick: 'testToggle(this);'}, "Click here to hide this text!")
p.inject(hider)