ponymail-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From humbed...@apache.org
Subject [1/7] incubator-ponymail git commit: ensure uniqueness
Date Fri, 02 Sep 2016 19:17:39 GMT
Repository: incubator-ponymail
Updated Branches:
  refs/heads/coffee-and-cake a2c1b83f5 -> 5cc211735


ensure uniqueness

this allows us to (potentially) add multiple calendar
objects to the same page.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/c8555092
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/c8555092
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/c8555092

Branch: refs/heads/coffee-and-cake
Commit: c855509243063a6399bb039eda2c3705d3e16429
Parents: a2c1b83
Author: Daniel Gruno <humbedooh@apache.org>
Authored: Fri Sep 2 20:23:48 2016 +0200
Committer: Daniel Gruno <humbedooh@apache.org>
Committed: Fri Sep 2 20:23:48 2016 +0200

----------------------------------------------------------------------
 site/js/coffee/calendar.coffee | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/c8555092/site/js/coffee/calendar.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/calendar.coffee b/site/js/coffee/calendar.coffee
index b8eb76a..a0242ae 100644
--- a/site/js/coffee/calendar.coffee
+++ b/site/js/coffee/calendar.coffee
@@ -22,6 +22,7 @@ calendar_months = [
 class Calendar
     constructor: (start, end, jumpTo) ->
         now = new Date()
+        uid = parseInt(Math.random()*100000000).toString(16)
         
         ### Split start and end into years and months ###
         [sYear, sMonth] = String(start).split("-")
@@ -42,7 +43,7 @@ class Calendar
         years = []
         for year in [parseInt(sYear)..parseInt(eYear)]
             yDiv = new HTML('div', {
-                id: "calendar_year_" + year
+                id: "calendar_year_#{uid}_" + year
                 data: String(year)
                 class: "calendar_year"
                 onclick: "toggleYear(this);"
@@ -58,7 +59,7 @@ class Calendar
                     else "none",
                 }
                 class: "calendar_months"
-                id: "calendar_months_" + year
+                id: "calendar_months_#{uid}_" + year
             })
             
             ### For each month, make a div ###
@@ -67,7 +68,7 @@ class Calendar
                 if (year > sYear or month >= sMonth) and (year < eYear or month
<= eMonth)
                     monthDiv = new HTML('div', {
                         class: "calendar_month"
-                        id: "calendar_month_#{year}-#{month}"
+                        id: "calendar_month_#{uid}_#{year}-#{month}"
                         data: "#{year}-#{month}"
                         onclick: "toggleMonth(this)"
                     }, calendar_months[month-1])
@@ -80,6 +81,7 @@ class Calendar
         ### Return a combined div ###
         div = new HTML('div', {
             class: "calendar"
+            id: uid
             data: sYear + "-" + eYear
             }, years)
         
@@ -92,13 +94,16 @@ toggleYear = (div) ->
     
     ### Get the year we clicked on ###
     year = parseInt(div.getAttribute("data"))
+    
+    ## Get Calendar UID
+    uid = div.parentNode.getAttribute("id")
 
     ### For each year, hide if not this year, else show ###
     for y in [parseInt(sYear)..parseInt(eYear)]
         if y == year
-            get('calendar_months_' + y).show(true)
+            get("calendar_months_#{uid}_#{y}").show(true)
         else
-            get('calendar_months_' + y).show(false)
+            get("calendar_months_#{uid}_#{y}").show(false)
             
 toggleMonth = (div) ->
     #### TODO later... ###


Mime
View raw message