From cda03f71e9a2cfc020c79154be746107a2f23a84 Mon Sep 17 00:00:00 2001 From: rolux Date: Sat, 23 Apr 2011 14:33:41 +0200 Subject: [PATCH] updates for loader --- demos/calendar/js/calendar.js | 262 +++++++++++++++++----------------- source/js/OxUI.js | 163 +++++++++++++-------- 2 files changed, 233 insertions(+), 192 deletions(-) diff --git a/demos/calendar/js/calendar.js b/demos/calendar/js/calendar.js index 7b99d181..e148fb9c 100644 --- a/demos/calendar/js/calendar.js +++ b/demos/calendar/js/calendar.js @@ -7,140 +7,136 @@ Ox.UI(function() { console.log('running Ox.UI()') //console.log('Ox =', Ox) - Ox.UI.ready(function() { + Ox.theme('modern'); - Ox.theme('modern'); + //Ox.print('$$$$', Ox.Calendar) - //Ox.print('$$$$', Ox.Calendar) - - new Ox.Calendar({ - date: new Date(0), - dates: [ - {name: 'Genghis Khan', start: new Date('1162'), stop: new Date('1228'), type: 'Person'}, - {name: 'Marco Polo', start: new Date('1254'), stop: new Date('1324-01-09'), type: 'Person'}, - {name: 'Columbus', start: new Date('1451-08-22'), stop: new Date('1506-05-21'), type: 'Person'}, - {name: 'Da Vinci', start: new Date('1452-04-15'), stop: new Date('1519-05-03'), type: 'Person'}, - {name: 'Michelangelo', start: new Date('1475-03-06'), stop: new Date('1564-02-19'), type: 'Person'}, - {name: 'Bruegel', start: new Date('1525'), stop: new Date('1569-09-10'), type: 'Person'}, - {name: 'Galilei', start: new Date('1564-02-15'), stop: new Date('1642-01-09'), type: 'Person'}, - {name: 'Shakespeare', start: new Date('1564-04-26'), stop: new Date('1616-04-24'), type: 'Person'}, - {name: 'Descartes', start: new Date('1596-03-31'), stop: new Date('1650-02-12'), type: 'Person'}, - {name: 'Velazquez', start: new Date('1599-06-06'), stop: new Date('1660-08-07'), type: 'Person'}, - {name: 'Vermeer', start: new Date('1632-10-31'), stop: new Date('1675-12-16'), type: 'Person'}, - {name: 'Spinoza', start: new Date('1632-11-24'), stop: new Date('1677-02-22'), type: 'Person'}, - {name: 'Louix XIV', start: new Date('1638-09-05'), stop: new Date('1715-09-02'), type: 'Person'}, - {name: 'Newton', start: new Date('1643-01-04'), stop: new Date('1727-04-01'), type: 'Person'}, - {name: 'Leibniz', start: new Date('1646-07-01'), stop: new Date('1716-11-15'), type: 'Person'}, - {name: 'Kant', start: new Date('1724-04-22'), stop: new Date('1804-02-13'), type: 'Person'}, - {name: 'Napoleon', start: new Date('1769-08-15'), stop: new Date('1821-05-06'), type: 'Person'}, - {name: 'Hegel', start: new Date('1770-08-27'), stop: new Date('1831-11-15'), type: 'Person'}, - {name: 'Darwin', start: new Date('1809-02-12'), stop: new Date('1882-04-20'), type: 'Person'}, - {name: 'Marx', start: new Date('1818-05-05'), stop: new Date('1883-03-15'), type: 'Person'}, - /* - {name: 'Gandhi', start: new Date('1869-10-02'), stop: new Date('1948-01-31'), type: 'Person'}, - {name: 'Lenin', start: new Date('1870-04-22'), stop: new Date('1924-01-22'), type: 'Person'}, - {name: 'Stalin', start: new Date('1878-12-18'), stop: new Date('1953-03-06'), type: 'Person'}, - {name: 'Einstein', start: new Date('1879-03-14'), stop: new Date('1955-04-19'), type: 'Person'}, - {name: 'Picasso', start: new Date('1881-10-25'), stop: new Date('1973-04-09'), type: 'Person'}, - {name: 'Roosevelt', start: new Date('1882-01-30'), stop: new Date('1945-04-13'), type: 'Person'}, - {name: 'Hitler', start: new Date('1889-04-20'), stop: new Date('1945-05-01'), type: 'Person'}, - {name: 'Hitchcock', start: new Date('1899-08-13'), stop: new Date('1980-04-30'), type: 'Person'}, - {name: 'Turing', start: new Date('1912-06-23'), stop: new Date('1954-06-08'), type: 'Person'}, - {name: 'Kennedy', start: new Date('1917-05-29'), stop: new Date('1963-11-23'), type: 'Person'}, - {name: 'Deleuze', start: new Date('1925-01-18'), stop: new Date('1995-11-05'), type: 'Person'}, - {name: 'Warhol', start: new Date('1928-08-06'), stop: new Date('1987-02-23'), type: 'Person'}, - {name: 'Debord', start: new Date('1931-12-28'), stop: new Date('1994-12-01'), type: 'Person'}, - */ - {name: 'Test', start: new Date('1970-01-01'), stop: new Date('1970-01-02')}, - {name: 'Battle of Hastings', start: new Date('1066-10-14'), stop: new Date('1066-10-15')}, - {name: 'Renaissance', start: new Date('1300'), stop: new Date('1700')}, - {name: 'Spanish Inquisition', start: new Date('1480-09-27'), stop: new Date('1820-03-10')}, - {name: 'Discovery of America', start: new Date('1492'), stop: new Date('1493')}, - {name: 'East India Company', start: new Date('1600'), stop: new Date('1874')}, - {name: 'Thirty Years\' War', start: new Date('1618'), stop: new Date('1649')}, - {name: 'Declaration of Independence', start: new Date('1776-07-04'), stop: new Date('1776-07-05')}, - {name: 'French Revolution', start: new Date('1789'), stop: new Date('1800')}, - {name: 'Storming of the Bastille', start: new Date('1789-07-14'), stop: new Date('1789-07-15')}, - {name: 'Napoleonic Era', start: new Date('1799-11-09'), stop: new Date('1815-06-29')}, - {name: 'The Year Without a Summer', start: new Date('1816'), stop: new Date('1817')}, - {name: 'Queen Victoria', start: new Date('1837-06-20'), stop: new Date('1901-01-23')}, - {name: 'Crimean War', start: new Date('1853-10'), stop: new Date('1856-03')}, - {name: 'American Civil War', start: new Date('1861-04-12'), stop: new Date('1865-04-10')}, - {name: 'Franco-Prussian War', start: new Date('1870-07-19'), stop: new Date('1871-05-11')}, - {name: 'Paris Commune', start: new Date('1871-03-18'), stop: new Date('1871-05-29')}, - {name: 'Congo Free State', start: new Date('1885-07-11'), stop: new Date('1908-11-16')}, - {name: '20th century', start: new Date('1900'), stop: new Date('2000')}, - {name: 'Titanic', start: new Date('1912-04-15'), stop: new Date('1912-04-16')}, - {name: 'World War One', start: new Date('1914-07-28'), stop: new Date('1918-11-12')}, - {name: 'Battle of Verdun', start: new Date('1916-02-21'), stop: new Date('1916-12-19')}, - {name: 'Russian Revolution', start: new Date('1917'), stop: new Date('1918')}, - {name: 'October Revolution', start: new Date('1917-11-07'), stop: new Date('1917-11-09')}, - {name: 'Spanish Flu', start: new Date('1918'), stop: new Date('1919')}, - {name: 'Weimar Republic', start: new Date('1918-11-09'), stop: new Date('1933-01-30')}, - {name: 'Treaty of Versailles', start: new Date('1919-06-28'), stop: new Date('1919-06-29')}, - {name: '1920s', start: new Date('1920'), stop: new Date('1930')}, - {name: 'Soviet Union', start: new Date('1922-12-30'), stop: new Date('1991-12-27')}, - {name: 'The Third Reich', start: new Date('1933-01-30'), stop: new Date('1945-05-09')}, - {name: 'Spanish Civil War', start: new Date('1936-07-17'), stop: new Date('1939-04-02')}, - {name: '1936 Summer Olympics', start: new Date('1936-08-01'), stop: new Date('1936-08-17')}, - {name: 'Hindenburg', start: new Date('1937-05-06'), stop: new Date('1937-05-07')}, - {name: 'World War Two', start: new Date('1939-09-01'), stop: new Date('1945-09-03')}, - {name: 'Pearl Harbour', start: new Date('1941-12-07'), stop: new Date('1941-12-08')}, - {name: 'Wannsee Conference', start: new Date('1942-01-20'), stop: new Date('1942-01-21')}, - {name: 'Battle of Stalingrad', start: new Date('1942-08-23'), stop: new Date('1943-02-03')}, - {name: 'D-Day', start: new Date('1944-06-06'), stop: new Date('1944-06-07')}, - {name: 'Liberation of Auschwitz', start: new Date('1945-01-27'), stop: new Date('1945-01-28')}, - {name: 'Hiroshima', start: new Date('1945-08-06'), stop: new Date('1945-08-07')}, - {name: 'Nagasaki', start: new Date('1945-08-09'), stop: new Date('1945-08-10')}, - {name: 'Nuremburg Trials', start: new Date('1945-11-20'), stop: new Date('1946-10-02')}, - {name: 'Fourth Republic', start: new Date('1946-10-14'), stop: new Date('1958-10-05')}, - {name: 'West Germany', start: new Date('1949-05-23'), stop: new Date('1990-10-03')}, - {name: 'Korean War', start: new Date('1950-06-25'), stop: new Date('1953-07-28')}, - {name: 'Cuban Revolution', start: new Date('1953-07-26'), stop: new Date('1959-01-02')}, - {name: 'Algerian War', start: new Date('1954-11-01'), stop: new Date('1962-03-20')}, - {name: 'Vietnam War', start: new Date('1955-11-01'), stop: new Date('1975-05-01')}, - {name: '1960s', start: new Date('1960-01-01'), stop: new Date('1970-01-01')}, - {name: 'Eichmann Trial', start: new Date('1961-04-11'), stop: new Date('1961-08-15')}, - {name: 'Bay of Pigs', start: new Date('1961-04-17'), stop: new Date('1961-04-20')}, - {name: 'Berlin Wall', start: new Date('1961-08-13'), stop: new Date('1989-11-09')}, - {name: 'Cuban Missile Crisis', start: new Date('1962-10'), stop: new Date('1962-12')}, - {name: 'Assassination of John F. Kennedy', start: new Date('1963-11-22'), stop: new Date('1963-11-23')}, - {name: 'Sgt. Pepper', start: new Date('1967-06-01'), stop: new Date('1967-06-02')}, - {name: 'Assassination of Benno Ohnesorg', start: new Date('1967-06-02'), stop: new Date('1967-06-03')}, - {name: 'Six-Day War', start: new Date('1967-06-05'), stop: new Date('1967-06-11')}, - {name: '1968', start: new Date('1968-01-01'), stop: new Date('1969-01-01')}, - {name: 'My Lai', start: new Date('1968-03-16'), stop: new Date('1968-03-17')}, - {name: 'Assassination of Martin Luther King', start: new Date('1968-04-04'), stop: new Date('1968-04-05')}, - {name: 'Assassination of Rudi Dutschke', start: new Date('1968-04-11'), stop: new Date('1968-04-12')}, - {name: 'May 1968', start: new Date('1968-05-01'), stop: new Date('1968-06-01')}, - {name: '1968 Cannes Film Festival', start: new Date('1968-05-10'), stop: new Date('1968-05-20')}, - {name: 'Valerie Solanas', start: new Date('1968-06-03'), stop: new Date('1968-06-04')}, - {name: 'Assassination of Robert F. Kennedy', start: new Date('1968-06-05'), stop: new Date('1968-06-06')}, - {name: '1968 Summer Olympics', start: new Date('1968-10-12'), stop: new Date('1968-10-28')}, - {name: 'Apollo 11', start: new Date('1969-07-16'), stop: new Date('1969-07-25')}, - {name: 'Moon Landing', start: new Date('1969-07-20'), stop: new Date('1969-07-21')}, - {name: 'The Epoch', start: new Date('1970-01-01 00:00:00'), stop: new Date('1970-01-01 00:00:01')}, - {name: '1970s', start: new Date('1970-01-01'), stop: new Date('1980-01-01')}, - {name: '1972 Summer Olympics', start: new Date('1972-08-26'), stop: new Date('1972-09-11')}, - {name: 'Apollo 17', start: new Date('1972-12-07'), stop: new Date('1972-12-20')}, - {name: 'World Trade Center', start: new Date('1973-04-04'), stop: new Date('2001-09-11')}, - {name: '1980s', start: new Date('1980-01-01'), stop: new Date('1990-01-01')}, - {name: 'Iran-Iraq War', start: new Date('1980-09-22'), stop: new Date('1988-08-21')}, - {name: 'Tschernobyl', start: new Date('1986-04-26'), stop: new Date('1986-04-27')}, - {name: 'Fall of the Berlin Wall', start: new Date('1989-11-09'), stop: new Date('1989-11-10')}, - {name: 'Gulf War', start: new Date('1990-08-02'), stop: new Date('1991-03-01')}, - {name: 'Clinton Presidency', start: new Date('1993-01-20'), stop: new Date('2001-01-20')}, - {name: 'German Reunification', start: new Date('1990-10-03'), stop: new Date('1990-10-04')}, - {name: 'The Battle of Seattle', start: new Date('1999-11-30'), stop: new Date('1999-12-01')}, - {name: 'George W. Bush', start: new Date('2001-01-20'), stop: new Date('2009-01-20')}, - {name: 'Carlo Giuliani', start: new Date('2001-07-20'), stop: new Date('2001-07-21')}, - {name: '9-11', start: new Date('2001-09-11'), stop: new Date('2001-09-12')}, - {name: 'Fukushima', start: new Date('2011-03-11'), stop: new Date('2011-03-12')} - ], - height: window.innerHeight, - width: window.innerWidth - }).appendTo(Ox.UI.$body); - - }); + new Ox.Calendar({ + date: new Date(0), + dates: [ + {name: 'Genghis Khan', start: new Date('1162'), stop: new Date('1228'), type: 'Person'}, + {name: 'Marco Polo', start: new Date('1254'), stop: new Date('1324-01-09'), type: 'Person'}, + {name: 'Columbus', start: new Date('1451-08-22'), stop: new Date('1506-05-21'), type: 'Person'}, + {name: 'Da Vinci', start: new Date('1452-04-15'), stop: new Date('1519-05-03'), type: 'Person'}, + {name: 'Michelangelo', start: new Date('1475-03-06'), stop: new Date('1564-02-19'), type: 'Person'}, + {name: 'Bruegel', start: new Date('1525'), stop: new Date('1569-09-10'), type: 'Person'}, + {name: 'Galilei', start: new Date('1564-02-15'), stop: new Date('1642-01-09'), type: 'Person'}, + {name: 'Shakespeare', start: new Date('1564-04-26'), stop: new Date('1616-04-24'), type: 'Person'}, + {name: 'Descartes', start: new Date('1596-03-31'), stop: new Date('1650-02-12'), type: 'Person'}, + {name: 'Velazquez', start: new Date('1599-06-06'), stop: new Date('1660-08-07'), type: 'Person'}, + {name: 'Vermeer', start: new Date('1632-10-31'), stop: new Date('1675-12-16'), type: 'Person'}, + {name: 'Spinoza', start: new Date('1632-11-24'), stop: new Date('1677-02-22'), type: 'Person'}, + {name: 'Louix XIV', start: new Date('1638-09-05'), stop: new Date('1715-09-02'), type: 'Person'}, + {name: 'Newton', start: new Date('1643-01-04'), stop: new Date('1727-04-01'), type: 'Person'}, + {name: 'Leibniz', start: new Date('1646-07-01'), stop: new Date('1716-11-15'), type: 'Person'}, + {name: 'Kant', start: new Date('1724-04-22'), stop: new Date('1804-02-13'), type: 'Person'}, + {name: 'Napoleon', start: new Date('1769-08-15'), stop: new Date('1821-05-06'), type: 'Person'}, + {name: 'Hegel', start: new Date('1770-08-27'), stop: new Date('1831-11-15'), type: 'Person'}, + {name: 'Darwin', start: new Date('1809-02-12'), stop: new Date('1882-04-20'), type: 'Person'}, + {name: 'Marx', start: new Date('1818-05-05'), stop: new Date('1883-03-15'), type: 'Person'}, + /* + {name: 'Gandhi', start: new Date('1869-10-02'), stop: new Date('1948-01-31'), type: 'Person'}, + {name: 'Lenin', start: new Date('1870-04-22'), stop: new Date('1924-01-22'), type: 'Person'}, + {name: 'Stalin', start: new Date('1878-12-18'), stop: new Date('1953-03-06'), type: 'Person'}, + {name: 'Einstein', start: new Date('1879-03-14'), stop: new Date('1955-04-19'), type: 'Person'}, + {name: 'Picasso', start: new Date('1881-10-25'), stop: new Date('1973-04-09'), type: 'Person'}, + {name: 'Roosevelt', start: new Date('1882-01-30'), stop: new Date('1945-04-13'), type: 'Person'}, + {name: 'Hitler', start: new Date('1889-04-20'), stop: new Date('1945-05-01'), type: 'Person'}, + {name: 'Hitchcock', start: new Date('1899-08-13'), stop: new Date('1980-04-30'), type: 'Person'}, + {name: 'Turing', start: new Date('1912-06-23'), stop: new Date('1954-06-08'), type: 'Person'}, + {name: 'Kennedy', start: new Date('1917-05-29'), stop: new Date('1963-11-23'), type: 'Person'}, + {name: 'Deleuze', start: new Date('1925-01-18'), stop: new Date('1995-11-05'), type: 'Person'}, + {name: 'Warhol', start: new Date('1928-08-06'), stop: new Date('1987-02-23'), type: 'Person'}, + {name: 'Debord', start: new Date('1931-12-28'), stop: new Date('1994-12-01'), type: 'Person'}, + */ + {name: 'Test', start: new Date('1970-01-01'), stop: new Date('1970-01-02')}, + {name: 'Battle of Hastings', start: new Date('1066-10-14'), stop: new Date('1066-10-15')}, + {name: 'Renaissance', start: new Date('1300'), stop: new Date('1700')}, + {name: 'Spanish Inquisition', start: new Date('1480-09-27'), stop: new Date('1820-03-10')}, + {name: 'Discovery of America', start: new Date('1492'), stop: new Date('1493')}, + {name: 'East India Company', start: new Date('1600'), stop: new Date('1874')}, + {name: 'Thirty Years\' War', start: new Date('1618'), stop: new Date('1649')}, + {name: 'Declaration of Independence', start: new Date('1776-07-04'), stop: new Date('1776-07-05')}, + {name: 'French Revolution', start: new Date('1789'), stop: new Date('1800')}, + {name: 'Storming of the Bastille', start: new Date('1789-07-14'), stop: new Date('1789-07-15')}, + {name: 'Napoleonic Era', start: new Date('1799-11-09'), stop: new Date('1815-06-29')}, + {name: 'The Year Without a Summer', start: new Date('1816'), stop: new Date('1817')}, + {name: 'Queen Victoria', start: new Date('1837-06-20'), stop: new Date('1901-01-23')}, + {name: 'Crimean War', start: new Date('1853-10'), stop: new Date('1856-03')}, + {name: 'American Civil War', start: new Date('1861-04-12'), stop: new Date('1865-04-10')}, + {name: 'Franco-Prussian War', start: new Date('1870-07-19'), stop: new Date('1871-05-11')}, + {name: 'Paris Commune', start: new Date('1871-03-18'), stop: new Date('1871-05-29')}, + {name: 'Congo Free State', start: new Date('1885-07-11'), stop: new Date('1908-11-16')}, + {name: '20th century', start: new Date('1900'), stop: new Date('2000')}, + {name: 'Titanic', start: new Date('1912-04-15'), stop: new Date('1912-04-16')}, + {name: 'World War One', start: new Date('1914-07-28'), stop: new Date('1918-11-12')}, + {name: 'Battle of Verdun', start: new Date('1916-02-21'), stop: new Date('1916-12-19')}, + {name: 'Russian Revolution', start: new Date('1917'), stop: new Date('1918')}, + {name: 'October Revolution', start: new Date('1917-11-07'), stop: new Date('1917-11-09')}, + {name: 'Spanish Flu', start: new Date('1918'), stop: new Date('1919')}, + {name: 'Weimar Republic', start: new Date('1918-11-09'), stop: new Date('1933-01-30')}, + {name: 'Treaty of Versailles', start: new Date('1919-06-28'), stop: new Date('1919-06-29')}, + {name: '1920s', start: new Date('1920'), stop: new Date('1930')}, + {name: 'Soviet Union', start: new Date('1922-12-30'), stop: new Date('1991-12-27')}, + {name: 'The Third Reich', start: new Date('1933-01-30'), stop: new Date('1945-05-09')}, + {name: 'Spanish Civil War', start: new Date('1936-07-17'), stop: new Date('1939-04-02')}, + {name: '1936 Summer Olympics', start: new Date('1936-08-01'), stop: new Date('1936-08-17')}, + {name: 'Hindenburg', start: new Date('1937-05-06'), stop: new Date('1937-05-07')}, + {name: 'World War Two', start: new Date('1939-09-01'), stop: new Date('1945-09-03')}, + {name: 'Pearl Harbour', start: new Date('1941-12-07'), stop: new Date('1941-12-08')}, + {name: 'Wannsee Conference', start: new Date('1942-01-20'), stop: new Date('1942-01-21')}, + {name: 'Battle of Stalingrad', start: new Date('1942-08-23'), stop: new Date('1943-02-03')}, + {name: 'D-Day', start: new Date('1944-06-06'), stop: new Date('1944-06-07')}, + {name: 'Liberation of Auschwitz', start: new Date('1945-01-27'), stop: new Date('1945-01-28')}, + {name: 'Hiroshima', start: new Date('1945-08-06'), stop: new Date('1945-08-07')}, + {name: 'Nagasaki', start: new Date('1945-08-09'), stop: new Date('1945-08-10')}, + {name: 'Nuremburg Trials', start: new Date('1945-11-20'), stop: new Date('1946-10-02')}, + {name: 'Fourth Republic', start: new Date('1946-10-14'), stop: new Date('1958-10-05')}, + {name: 'West Germany', start: new Date('1949-05-23'), stop: new Date('1990-10-03')}, + {name: 'Korean War', start: new Date('1950-06-25'), stop: new Date('1953-07-28')}, + {name: 'Cuban Revolution', start: new Date('1953-07-26'), stop: new Date('1959-01-02')}, + {name: 'Algerian War', start: new Date('1954-11-01'), stop: new Date('1962-03-20')}, + {name: 'Vietnam War', start: new Date('1955-11-01'), stop: new Date('1975-05-01')}, + {name: '1960s', start: new Date('1960-01-01'), stop: new Date('1970-01-01')}, + {name: 'Eichmann Trial', start: new Date('1961-04-11'), stop: new Date('1961-08-15')}, + {name: 'Bay of Pigs', start: new Date('1961-04-17'), stop: new Date('1961-04-20')}, + {name: 'Berlin Wall', start: new Date('1961-08-13'), stop: new Date('1989-11-09')}, + {name: 'Cuban Missile Crisis', start: new Date('1962-10'), stop: new Date('1962-12')}, + {name: 'Assassination of John F. Kennedy', start: new Date('1963-11-22'), stop: new Date('1963-11-23')}, + {name: 'Sgt. Pepper', start: new Date('1967-06-01'), stop: new Date('1967-06-02')}, + {name: 'Assassination of Benno Ohnesorg', start: new Date('1967-06-02'), stop: new Date('1967-06-03')}, + {name: 'Six-Day War', start: new Date('1967-06-05'), stop: new Date('1967-06-11')}, + {name: '1968', start: new Date('1968-01-01'), stop: new Date('1969-01-01')}, + {name: 'My Lai', start: new Date('1968-03-16'), stop: new Date('1968-03-17')}, + {name: 'Assassination of Martin Luther King', start: new Date('1968-04-04'), stop: new Date('1968-04-05')}, + {name: 'Assassination of Rudi Dutschke', start: new Date('1968-04-11'), stop: new Date('1968-04-12')}, + {name: 'May 1968', start: new Date('1968-05-01'), stop: new Date('1968-06-01')}, + {name: '1968 Cannes Film Festival', start: new Date('1968-05-10'), stop: new Date('1968-05-20')}, + {name: 'Valerie Solanas', start: new Date('1968-06-03'), stop: new Date('1968-06-04')}, + {name: 'Assassination of Robert F. Kennedy', start: new Date('1968-06-05'), stop: new Date('1968-06-06')}, + {name: '1968 Summer Olympics', start: new Date('1968-10-12'), stop: new Date('1968-10-28')}, + {name: 'Apollo 11', start: new Date('1969-07-16'), stop: new Date('1969-07-25')}, + {name: 'Moon Landing', start: new Date('1969-07-20'), stop: new Date('1969-07-21')}, + {name: 'The Epoch', start: new Date('1970-01-01 00:00:00'), stop: new Date('1970-01-01 00:00:01')}, + {name: '1970s', start: new Date('1970-01-01'), stop: new Date('1980-01-01')}, + {name: '1972 Summer Olympics', start: new Date('1972-08-26'), stop: new Date('1972-09-11')}, + {name: 'Apollo 17', start: new Date('1972-12-07'), stop: new Date('1972-12-20')}, + {name: 'World Trade Center', start: new Date('1973-04-04'), stop: new Date('2001-09-11')}, + {name: '1980s', start: new Date('1980-01-01'), stop: new Date('1990-01-01')}, + {name: 'Iran-Iraq War', start: new Date('1980-09-22'), stop: new Date('1988-08-21')}, + {name: 'Tschernobyl', start: new Date('1986-04-26'), stop: new Date('1986-04-27')}, + {name: 'Fall of the Berlin Wall', start: new Date('1989-11-09'), stop: new Date('1989-11-10')}, + {name: 'Gulf War', start: new Date('1990-08-02'), stop: new Date('1991-03-01')}, + {name: 'Clinton Presidency', start: new Date('1993-01-20'), stop: new Date('2001-01-20')}, + {name: 'German Reunification', start: new Date('1990-10-03'), stop: new Date('1990-10-04')}, + {name: 'The Battle of Seattle', start: new Date('1999-11-30'), stop: new Date('1999-12-01')}, + {name: 'George W. Bush', start: new Date('2001-01-20'), stop: new Date('2009-01-20')}, + {name: 'Carlo Giuliani', start: new Date('2001-07-20'), stop: new Date('2001-07-21')}, + {name: '9-11', start: new Date('2001-09-11'), stop: new Date('2001-09-12')}, + {name: 'Fukushima', start: new Date('2011-03-11'), stop: new Date('2011-03-12')} + ], + height: window.innerHeight, + width: window.innerWidth + }).appendTo(Ox.UI.$body); }); \ No newline at end of file diff --git a/source/js/OxUI.js b/source/js/OxUI.js index 184641ba..8e386b6f 100644 --- a/source/js/OxUI.js +++ b/source/js/OxUI.js @@ -6,7 +6,7 @@ OxUI Loader Provides function Ox.UI([options], callback) that fires when OxUI.css, Ox.js und jquery.js have loaded all images have loaded - the DOM is ready + the document is ready */ (function() { @@ -15,19 +15,18 @@ Provides function Ox.UI([options], callback) that fires when path = Array.prototype.slice.apply( document.getElementsByTagName('script') ).filter(function(element) { - return /OxUI\.js$/(element.src); + return /OxUI\.js$/.test(element.src); })[0].src.replace('js/OxUI.js', ''), head = document.getElementsByTagName('head')[0], oxUICallback = function() {}, - oxUIFunction = function(options, callback) { - var defaults = { - // 'classic', 'modern', 'verbose' or anything falsy - display: 'classic' - }; - oxUICallback = arguments.length == 2 ? callback : options; - oxUIOptions = arguments.length == 2 && options ? options : {}; + oxUIDefaults = { + // 'classic', 'modern', 'console' or 'none' + display: 'classic' + }, + oxUIFunction = function(options, callback) { + oxUICallback = arguments.length == 2 ? callback : options; + oxUIOptions = arguments.length == 2 && options ? options : oxUIDefaults; }, - oxUIOptions = {}, documentReady = false, documentReadyCallbacks = []; @@ -78,7 +77,7 @@ Provides function Ox.UI([options], callback) that fires when }); function isFileType(src, type) { - return new RegExp('\.' + type + '$')(src); + return new RegExp('\.' + type + '$').test(src); } function isIncluded(src) { @@ -95,8 +94,9 @@ Provides function Ox.UI([options], callback) that fires when function waitForDocument() { document.addEventListener('DOMContentLoaded', onload, false); function onload() { - console.log('DOMContentLoaded') + console.log('document ready') document.removeEventListener('DOMContentLoaded', onload, false); + documentReady = true; bootOxUI(); } } @@ -111,7 +111,18 @@ Provides function Ox.UI([options], callback) that fires when function bootOxUI() { - var body = element('body'), + // runs when the document is ready + + var body, css, div, + options = oxUIOptions || oxUIDefaults, + userAgents = [ + {name: 'Chrome', url: 'http://www.google.com/chrome/'}, + {name: 'Firefox', url: 'http://www.mozilla.org/firefox/'}, + {name: 'Safari', url: 'http://www.apple.com/safari/'} + ]; + + if (options.display != 'none') { + body = element('body'); css = { position: 'absolute', left: 0, @@ -121,7 +132,7 @@ Provides function Ox.UI([options], callback) that fires when margin: 'auto', MozUserSelect: 'none', WebkitUserSelect: 'none' - }, + }; div = element('
') .css({ position: 'absolute', @@ -129,16 +140,17 @@ Provides function Ox.UI([options], callback) that fires when top: 0, right: 0, bottom: 0, - background: 'rgb(240, 240, 240)', + background: 'rgb(' + ( + options.display == 'classic' ? '240, 240, 240' : '16, 16, 16') + + ')', + color: 'rgb(240, 240, 240)', opacity: 1, zIndex: 1000 }) - .appendTo(body), - userAgents = [ - {name: 'Chrome', url: 'http://www.google.com/chrome/'}, - {name: 'Firefox', url: 'http://www.mozilla.org/firefox/'}, - {name: 'Safari', url: 'http://www.apple.com/safari/'} - ]; + .appendTo(body); + } + + console.log('userAgent', getUserAgent()) getUserAgent() ? start() : stop(); @@ -152,7 +164,6 @@ Provides function Ox.UI([options], callback) that fires when return userAgent; } - function element(str) { // Generic HTML Element Object (mimics jQuery) return { @@ -195,12 +206,13 @@ Provides function Ox.UI([options], callback) that fires when } function start() { + console.log('start') var image = new Image(), src = path + 'svg/ox.ui.classic/symbolLoading.svg'; image.onload = function() { element('') .attr({ - src: src + src: src, }) .css(css) .css({ @@ -212,28 +224,48 @@ Provides function Ox.UI([options], callback) that fires when }) .appendTo(div); }; - image.src = src; + image.src = src; } function stop() { - var counter = 0; - userAgents.forEach(function(userAgent) { - var image = new Image(); - userAgent.src = path + 'png/ox.ui/browser' + userAgent.name + '128.png'; - image.onload = function() { - ++counter == userAgents.length && loaded(); + console.log('stop') + var counter = 0, + message = 'Browser not supported, use ' + userAgents.map(function(userAgent, i) { + return userAgent.name + ( + i == userAgent.length - 1 ? '.' : + i == userAgent.length - 2 ? ' or' : ',' + ); + }).join(' '); + if (options.display == 'none') { + throw new Error(message); + } else { + div.addClass('error'); + if (options.display == 'console') { + element('
').html(message).appendTo(body); + } else { + userAgents.forEach(function(userAgent) { + var image = new Image(); + userAgent.src = path + 'png/ox.ui/browser' + userAgent.name + '128.png'; + image.onload = function() { + ++counter == userAgents.length && showImages(); + } + image.src = userAgent.src; + }); } - image.src = userAgent.src; - }); - function loaded() { + } + function showImages() { var box = element('
') .css(css) + .css({ + width: (userAgents.length * 72) + 'px', + height: '72px' + }) .appendTo(div); userAgents.forEach(function(userAgent, i) { var link = element('') .attr({ - href: userAgents[name], - title: name + href: userAgent.url, + title: userAgent.name }) .css({ position: 'absolute', @@ -243,6 +275,9 @@ Provides function Ox.UI([options], callback) that fires when }) .appendTo(box); element('') + .attr({ + src: userAgent.src + }) .css(css) .css({ width: '64px', @@ -262,19 +297,15 @@ Provides function Ox.UI([options], callback) that fires when function loadOxUI() { - Ox.UI = {}; - Ox.UI.ready = function(callback) { - if (!documentReady) { - documentReadyCallbacks.push(callback); - } else { - callback(); - } - }; + // runs when css and js files have loaded + + documentReady && initDocument(); $.getJSON(path + 'json/OxUI.json', function(data) { var $head = $('head'), - promises = [waitForDocument()]; + promises = documentReady ? [] : [waitForDocument()]; + // fixme: find a better way to not wait for flags data = data.filter(function(image) { return !Ox.startsWith(image, 'svg/ox.map/'); @@ -284,14 +315,17 @@ Provides function Ox.UI([options], callback) that fires when }); $.when.apply(null, promises) .then(function() { - var $div = Ox.UI.$body.find('div'); - Ox.UI.$body.find('img').remove(); - $div.animate({ - opacity: 0 - }, 1000, function() { - $div.remove(); - }); - oxUICallback(); + var $div, error = $('.error').length; + if (!error) { + $div = $('div'); + $('img').remove(); + $div.animate({ + opacity: 0 + }, 1000, function() { + $div.remove(); + }); + oxUICallback(); + } }) .fail(function() { throw new Error('File not found.'); @@ -316,14 +350,8 @@ Provides function Ox.UI([options], callback) that fires when function waitForDocument() { var dfd = new $.Deferred(); $(function() { - Ox.UI.$body = $('body'); - Ox.UI.$document = $(document); - Ox.UI.$head = $('head'); - Ox.UI.$window = $(window); documentReady = true; - documentReadyCallbacks.forEach(function(callback) { - callback(); - }); + initDocument() dfd.resolve(); }); return dfd.promise(); @@ -331,6 +359,23 @@ Provides function Ox.UI([options], callback) that fires when }); + function initDocument() { + Ox.UI.$body = $('body'); + Ox.UI.$document = $(document); + Ox.UI.$head = $('head'); + Ox.UI.$window = $(window); + documentReadyCallbacks.forEach(function(callback) { + callback(); + }); + } + + Ox.UI.ready = function(callback) { + if (!documentReady) { + documentReadyCallbacks.push(callback); + } else { + callback(); + } + }; Ox.UI.elements = {}; Ox.UI.DEFAULT_THEME = 'classic';