From b930e7cf1f798df62b3993e6f07c447171e8cb39 Mon Sep 17 00:00:00 2001 From: Brandon Dail Date: Sun, 1 Mar 2015 11:55:05 -0600 Subject: [PATCH 01/12] Removed needless DOM query cached body element in local variable to avoid multiple DOM queries on the same element --- source/javascripts/main.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/javascripts/main.js b/source/javascripts/main.js index 89847c1..7ce9945 100644 --- a/source/javascripts/main.js +++ b/source/javascripts/main.js @@ -4,6 +4,8 @@ (function(){ 'use strict'; + + var body = document.querySelector('body'); Lib.ready(function() { /* jshint -W031 */ @@ -22,11 +24,11 @@ ]); document.querySelector('#switch-dark').addEventListener('click', function() { - document.querySelector('body').className = 'index black'; + body.className = 'index black'; }); document.querySelector('#switch-light').addEventListener('click', function() { - document.querySelector('body').className = 'index white'; + body.className = 'index white'; }); }); })(); From 71e179188eb6439e5dfd2b9dd8c02ac0c42be373 Mon Sep 17 00:00:00 2001 From: Willson Mock Date: Tue, 3 Mar 2015 00:20:43 -0800 Subject: [PATCH 02/12] Update year in License --- LICENSE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.md b/LICENSE.md index 2349446..039bffc 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ # The MIT License (MIT) -Copyright (c) 2014 Sebastian Müller +Copyright (c) 2014-2015 Sebastian Müller Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 9f421dcdeb9727ab40d28a2c3a9ba26aef9466b9 Mon Sep 17 00:00:00 2001 From: sbstjn Date: Tue, 3 Mar 2015 20:31:08 +0100 Subject: [PATCH 03/12] Minor fixes. Bower.json added --- bower.json | 38 +++++++++++++++++++++ dist/timesheet.css | 2 +- source/index.haml | 4 +-- source/javascripts/main.js | 6 ++-- source/layouts/layout.haml | 10 +++--- source/stylesheets/timesheet-white.css.sass | 3 +- source/stylesheets/timesheet.css.sass | 3 +- 7 files changed, 50 insertions(+), 16 deletions(-) create mode 100644 bower.json diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..5abf354 --- /dev/null +++ b/bower.json @@ -0,0 +1,38 @@ +{ + "name": "timesheet.js", + "version": "1.0.0", + "homepage": "https://sbstjn.github.io/timesheet.js/", + "authors": [ + "sbstjn " + ], + "description": "With Timesheet.js you can easily create simple time and data sheets or timelines using HTML5, JavaScript and CSS3. Yep, it's a Vanilla JS library!", + "main": ["dist/timesheet.js", "dist/timesheet.css"], + "moduleType": [ + "amd" + ], + "keywords": [ + "timeline", + "timesheet", + "timebar", + "line", + "bar", + "graph", + "visualize", + "chart" + ], + "license": "MIT", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests", + "screen.png", + "source", + "config.rb", + "Gruntfile.js", + "Gemfile", + "Gemfile.lock", + "package.json" + ] +} diff --git a/dist/timesheet.css b/dist/timesheet.css index a342a94..a1e3d1b 100644 --- a/dist/timesheet.css +++ b/dist/timesheet.css @@ -1 +1 @@ -.timesheet{width:720px;height:292px;margin:0 auto}.timesheet{border-top:1px solid rgba(250,250,250,0.5);background-color:#333;position:relative}.timesheet.color-scheme-default .bubble-default{background-color:RGBA(252, 70, 74, 1)}.timesheet.color-scheme-default .bubble-lorem{background-color:RGBA(154, 202, 39, 1)}.timesheet.color-scheme-default .bubble-ipsum{background-color:RGBA(60, 182, 227, 1)}.timesheet.color-scheme-default .bubble-dolor{background-color:RGBA(244, 207, 48, 1)}.timesheet.color-scheme-default .bubble-sit{background-color:RGBA(169, 105, 202, 1)}.timesheet.color-scheme-alternative .bubble-default{background-color:#f3552e}.timesheet.color-scheme-alternative .bubble-lorem{background-color:#88c33a}.timesheet.color-scheme-alternative .bubble-ipsum{background-color:#436ae0}.timesheet.color-scheme-alternative .bubble-dolor{background-color:#f4d234}.timesheet.color-scheme-alternative .bubble-set{background-color:#707d86}.timesheet .scale{height:100%;position:absolute;top:0;left:0;float:left}.timesheet .scale section{float:left;width:59px;text-align:center;color:rgba(250,250,250,0.8);font-family:"Signika Negative";font-size:13px;line-height:24px;font-weight:lighter;border-left:1px dashed rgba(250,250,250,0.2);height:100%}.timesheet .data{margin:28px 0 0 0;padding:0;text-align:left;list-style-type:none;color:rgba(250,250,250,0.8);font-family:"Signika Negative";font-size:13px;overflow:hidden}.timesheet .data li{margin:0 0 3px 0;line-height:22px;height:21px;display:block;cursor:pointer;clear:both;position:relative;white-space:nowrap}.timesheet .data li:hover .bubble{opacity:1}.timesheet .data li .date{color:#b5b5b5;font-size:14px}.timesheet .data li .label{font-weight:lighter;font-size:14px;padding-left:5px;line-height:21px;color:#979796;white-space:nowrap}.timesheet .data li .bubble{width:24px;height:7px;display:block;float:left;position:relative;top:7px;border-radius:4px;margin:0 10px 0 0;opacity:0.7}#timesheet-alternative{background-color:RGBA(247, 247, 247, 1);border-radius:5px}#timesheet-alternative section{color:RGBA(63, 68, 72, 1);border-left:1px dashed RGBA(63, 68, 72, 0.2)}#timesheet-alternative section:first-child{border-left:1px dashed transparent}#timesheet-alternative .date{display:none}#timesheet-alternative .bubble{margin-right:7px}#timesheet-alternative .label{padding-left:0px;color:RGBA(48, 48, 48, 1)} +.timesheet{width:720px;height:292px;margin:0 auto}.timesheet{border-top:1px solid rgba(250,250,250,0.5);background-color:#333;position:relative}.timesheet.color-scheme-default .bubble-default{background-color:RGBA(252, 70, 74, 1)}.timesheet.color-scheme-default .bubble-lorem{background-color:RGBA(154, 202, 39, 1)}.timesheet.color-scheme-default .bubble-ipsum{background-color:RGBA(60, 182, 227, 1)}.timesheet.color-scheme-default .bubble-dolor{background-color:RGBA(244, 207, 48, 1)}.timesheet.color-scheme-default .bubble-sit{background-color:RGBA(169, 105, 202, 1)}.timesheet.color-scheme-alternative .bubble-default{background-color:#f3552e}.timesheet.color-scheme-alternative .bubble-lorem{background-color:#88c33a}.timesheet.color-scheme-alternative .bubble-ipsum{background-color:#436ae0}.timesheet.color-scheme-alternative .bubble-dolor{background-color:#f4d234}.timesheet.color-scheme-alternative .bubble-sit{background-color:#707d86}.timesheet .scale{height:100%;position:absolute;top:0;left:0;float:left}.timesheet .scale section{float:left;width:59px;text-align:center;color:rgba(250,250,250,0.8);font-family:"Signika Negative";font-size:13px;line-height:24px;font-weight:lighter;border-left:1px dashed rgba(250,250,250,0.2);height:100%}.timesheet .data{margin:28px 0 0 0;padding:0;text-align:left;list-style-type:none;color:rgba(250,250,250,0.8);font-family:"Signika Negative";font-size:13px;overflow:hidden}.timesheet .data li{margin:0 0 3px 0;line-height:22px;height:21px;display:block;clear:both;position:relative;white-space:nowrap}.timesheet .data li:hover .bubble{opacity:1}.timesheet .data li .date{color:#b5b5b5;font-size:14px}.timesheet .data li .label{font-weight:lighter;font-size:14px;padding-left:5px;line-height:21px;color:#979796;white-space:nowrap}.timesheet .data li .bubble{width:24px;height:7px;display:block;float:left;position:relative;top:7px;border-radius:4px;margin:0 10px 0 0;opacity:0.7}#timesheet-alternative{background-color:RGBA(247, 247, 247, 1);border-radius:5px}#timesheet-alternative section{color:RGBA(63, 68, 72, 1);border-left:1px dashed RGBA(63, 68, 72, 0.2)}#timesheet-alternative section:first-child{border-left:1px dashed transparent}#timesheet-alternative .date{display:none}#timesheet-alternative .bubble{margin-right:7px}#timesheet-alternative .label{padding-left:0px;color:RGBA(48, 48, 48, 1)} diff --git a/source/index.haml b/source/index.haml index 54e062c..402e3c7 100644 --- a/source/index.haml +++ b/source/index.haml @@ -6,7 +6,7 @@ #timesheet-default - %p Just include Timesheet.js and configure your data. No external dependencies, no jQuery needed and of course no Angular.JS! Just a few lines JavaScript to generate a beautiful HTML5 layout and some really delicious CSS to be customized by mighty you. + %p Just include Timesheet.js and configure your data. No external dependencies, no jQuery needed and of course no Angular.JS! Just a few lines JavaScript to generate a beautiful HTML5 layout and some really delicious CSS to be customized by almighty you. %code %pre @@ -36,4 +36,4 @@ %p It's that simple to use Timesheet.js. So, have a nice day, thank you for smoking and maybe try using Timesheet.js with custom styles … - %p.footer Timesheet.js is licensed under MIT License
Cheers to Cheeaun and Ilya




dark | light + %p.footer Timesheet.js is licensed under MIT License
Cheers to Cheeaun and Ilya




dark | light diff --git a/source/javascripts/main.js b/source/javascripts/main.js index 7ce9945..676dd0c 100644 --- a/source/javascripts/main.js +++ b/source/javascripts/main.js @@ -5,8 +5,6 @@ (function(){ 'use strict'; - var body = document.querySelector('body'); - Lib.ready(function() { /* jshint -W031 */ new Timesheet('timesheet-default', 2002, 2013, [ @@ -24,11 +22,11 @@ ]); document.querySelector('#switch-dark').addEventListener('click', function() { - body.className = 'index black'; + document.querySelector('body').className = 'index black'; }); document.querySelector('#switch-light').addEventListener('click', function() { - body.className = 'index white'; + document.querySelector('body').className = 'index white'; }); }); })(); diff --git a/source/layouts/layout.haml b/source/layouts/layout.haml index af9698b..dc7c290 100644 --- a/source/layouts/layout.haml +++ b/source/layouts/layout.haml @@ -4,17 +4,17 @@ %meta{:charset => 'utf-8'} %meta{:content => 'IE=edge,chrome=1', 'http-equiv' => 'X-UA-Compatible'} %meta{:property => 'og:title', :content => 'Timesheet.js'} - %meta{:property => 'og:description', :content => 'With Timesheet.js you can create simple time and data sheets using HTML5, JavaScript and CSS3.'} - %meta{:property => 'og:url', :content => 'https://semu.github.io/timesheet.js/'} + %meta{:property => 'og:description', :content => 'With Timesheet.js you can easily create simple time and data sheets or timelines using HTML5, JavaScript and CSS3. Yep, it\'s a Vanilla JS library!'} + %meta{:property => 'og:url', :content => 'https://sbstjn.github.io/timesheet.js/'} %meta{:property => 'og:image', :content => 'https://raw.githubusercontent.com/semu/timesheet.js/master/screen.png'} %meta{:property => 'fb:admins', :content => '669118929'} %title Timesheet.js - Open time tables with HTML, JavaScript and CSS … = javascript_include_tag 'timesheet.js', 'main.js' - = stylesheet_link_tag 'http://fonts.googleapis.com/css?family=Oxygen+Mono:400,600,800' - = stylesheet_link_tag 'http://fonts.googleapis.com/css?family=Open+Sans:400,600,800' - = stylesheet_link_tag 'http://fonts.googleapis.com/css?family=Signika+Negative:300,400,600,700' + = stylesheet_link_tag '//fonts.googleapis.com/css?family=Oxygen+Mono:400,600,800' + = stylesheet_link_tag '//fonts.googleapis.com/css?family=Open+Sans:400,600,800' + = stylesheet_link_tag '//fonts.googleapis.com/css?family=Signika+Negative:300,400,600,700' = stylesheet_link_tag 'all.css' = yield_content :head %body.black{ :class => page_classes } diff --git a/source/stylesheets/timesheet-white.css.sass b/source/stylesheets/timesheet-white.css.sass index dfeb4ba..7be335b 100644 --- a/source/stylesheets/timesheet-white.css.sass +++ b/source/stylesheets/timesheet-white.css.sass @@ -29,7 +29,7 @@ background-color: rgba(67, 106, 224, 1) .bubble-dolor background-color: rgba(244, 210, 52, 1) - .bubble-set + .bubble-sit background-color: rgba(112, 125, 134, 1) @@ -43,7 +43,6 @@ section float: left width: 59px - text-align: center color: rgba(50, 50, 50, 0.8) font-family: 'Signika Negative' font-size: 13px diff --git a/source/stylesheets/timesheet.css.sass b/source/stylesheets/timesheet.css.sass index fa64900..ae171bf 100644 --- a/source/stylesheets/timesheet.css.sass +++ b/source/stylesheets/timesheet.css.sass @@ -29,7 +29,7 @@ background-color: rgba(67, 106, 224, 1) .bubble-dolor background-color: rgba(244, 210, 52, 1) - .bubble-set + .bubble-sit background-color: rgba(112, 125, 134, 1) @@ -67,7 +67,6 @@ line-height: 22px height: 21px display: block - cursor: pointer clear: both position: relative white-space: nowrap From dc7a1a66076fd5bb7ea5e159b5d428c913a78ff5 Mon Sep 17 00:00:00 2001 From: sbstjn Date: Tue, 3 Mar 2015 20:43:35 +0100 Subject: [PATCH 04/12] Updated README.md --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8c428c2..6517209 100644 --- a/README.md +++ b/README.md @@ -26,4 +26,10 @@ new Timesheet('timesheet', 2002, 2013, [ ]); ``` -Timesheet.js is licensed under MIT License. +### Bower + +`$ > bower install https://github.com/sbstjn/timesheet.js.git` + +## License + +Timesheet.js is licensed under MIT License. \ No newline at end of file From bb166d7662899877123b375c8107af4987628801 Mon Sep 17 00:00:00 2001 From: sbstjn Date: Tue, 3 Mar 2015 20:58:30 +0100 Subject: [PATCH 05/12] Removed timesheet.bubble.js --- source/javascripts/timesheet.bubble.js | 78 ------------------------- source/javascripts/timesheet.js | 79 ++++++++++++++++++++++++-- source/layouts/layout.haml | 2 +- 3 files changed, 76 insertions(+), 83 deletions(-) delete mode 100644 source/javascripts/timesheet.bubble.js diff --git a/source/javascripts/timesheet.bubble.js b/source/javascripts/timesheet.bubble.js deleted file mode 100644 index 98d3af8..0000000 --- a/source/javascripts/timesheet.bubble.js +++ /dev/null @@ -1,78 +0,0 @@ -(function() { - 'use strict'; - - /** - * Timesheet Bubble - */ - var Bubble = function(wMonth, min, start, end) { - this.min = min; - this.start = start; - this.end = end; - this.widthMonth = wMonth; - }; - - /** - * Format month number - */ - Bubble.prototype.formatMonth = function(num) { - num = parseInt(num, 10); - - return num >= 10 ? num : '0' + num; - }; - - /** - * Calculate starting offset for bubble - */ - Bubble.prototype.getStartOffset = function() { - return (this.widthMonth/12) * (12 * (this.start.getFullYear() - this.min) + this.start.getMonth()); - }; - - /** - * Get count of full years from start to end - */ - Bubble.prototype.getFullYears = function() { - return ((this.end && this.end.getFullYear()) || this.start.getFullYear()) - this.start.getFullYear(); - }; - - /** - * Get count of all months in Timesheet Bubble - */ - Bubble.prototype.getMonths = function() { - var fullYears = this.getFullYears(); - var months = 0; - - if (!this.end) { - months += !this.start.hasMonth ? 12 : 1; - } else { - if (!this.end.hasMonth) { - months += 12 - (this.start.hasMonth ? this.start.getMonth() : 0); - months += 12 * (fullYears-1 > 0 ? fullYears-1 : 0); - } else { - months += this.end.getMonth() + 1; - months += 12 - (this.start.hasMonth ? this.start.getMonth() : 0); - months += 12 * (fullYears-1); - } - } - - return months; - }; - - /** - * Get bubble's width in pixel - */ - Bubble.prototype.getWidth = function() { - return (this.widthMonth/12) * this.getMonths(); - }; - - /** - * Get the bubble's label - */ - Bubble.prototype.getDateLabel = function() { - return [ - (this.start.hasMonth ? this.formatMonth(this.start.getMonth() + 1) + '/' : '' ) + this.start.getFullYear(), - (this.end ? '-' + ((this.end.hasMonth ? this.formatMonth(this.end.getMonth() + 1) + '/' : '' ) + this.end.getFullYear()) : '') - ].join(''); - }; - - window.TimesheetBubble = Bubble; -})(); diff --git a/source/javascripts/timesheet.js b/source/javascripts/timesheet.js index 3b79f15..5494c8f 100644 --- a/source/javascripts/timesheet.js +++ b/source/javascripts/timesheet.js @@ -1,5 +1,3 @@ -// require 'timesheet.bubble' - /* global TimesheetBubble */ (function() { @@ -33,7 +31,7 @@ for (var n = 0, m = this.data.length; n < m; n++) { var cur = this.data[n]; - var bubble = new TimesheetBubble(widthMonth, this.year.min, cur.start, cur.end); + var bubble = new Bubble(widthMonth, this.year.min, cur.start, cur.end); var line = [ '', @@ -100,6 +98,79 @@ this.data.push({start: beg, end: end, label: lbl, type: cat}); } }; + + /** + * Timesheet Bubble + */ + var Bubble = function(wMonth, min, start, end) { + this.min = min; + this.start = start; + this.end = end; + this.widthMonth = wMonth; + }; + + /** + * Format month number + */ + Bubble.prototype.formatMonth = function(num) { + num = parseInt(num, 10); + + return num >= 10 ? num : '0' + num; + }; + + /** + * Calculate starting offset for bubble + */ + Bubble.prototype.getStartOffset = function() { + return (this.widthMonth/12) * (12 * (this.start.getFullYear() - this.min) + this.start.getMonth()); + }; + + /** + * Get count of full years from start to end + */ + Bubble.prototype.getFullYears = function() { + return ((this.end && this.end.getFullYear()) || this.start.getFullYear()) - this.start.getFullYear(); + }; + + /** + * Get count of all months in Timesheet Bubble + */ + Bubble.prototype.getMonths = function() { + var fullYears = this.getFullYears(); + var months = 0; + + if (!this.end) { + months += !this.start.hasMonth ? 12 : 1; + } else { + if (!this.end.hasMonth) { + months += 12 - (this.start.hasMonth ? this.start.getMonth() : 0); + months += 12 * (fullYears-1 > 0 ? fullYears-1 : 0); + } else { + months += this.end.getMonth() + 1; + months += 12 - (this.start.hasMonth ? this.start.getMonth() : 0); + months += 12 * (fullYears-1); + } + } + + return months; + }; + + /** + * Get bubble's width in pixel + */ + Bubble.prototype.getWidth = function() { + return (this.widthMonth/12) * this.getMonths(); + }; + + /** + * Get the bubble's label + */ + Bubble.prototype.getDateLabel = function() { + return [ + (this.start.hasMonth ? this.formatMonth(this.start.getMonth() + 1) + '/' : '' ) + this.start.getFullYear(), + (this.end ? '-' + ((this.end.hasMonth ? this.formatMonth(this.end.getMonth() + 1) + '/' : '' ) + this.end.getFullYear()) : '') + ].join(''); + }; window.Timesheet = Timesheet; -})(); +})(); \ No newline at end of file diff --git a/source/layouts/layout.haml b/source/layouts/layout.haml index dc7c290..09be0e9 100644 --- a/source/layouts/layout.haml +++ b/source/layouts/layout.haml @@ -6,7 +6,7 @@ %meta{:property => 'og:title', :content => 'Timesheet.js'} %meta{:property => 'og:description', :content => 'With Timesheet.js you can easily create simple time and data sheets or timelines using HTML5, JavaScript and CSS3. Yep, it\'s a Vanilla JS library!'} %meta{:property => 'og:url', :content => 'https://sbstjn.github.io/timesheet.js/'} - %meta{:property => 'og:image', :content => 'https://raw.githubusercontent.com/semu/timesheet.js/master/screen.png'} + %meta{:property => 'og:image', :content => 'https://raw.githubusercontent.com/sbstjn/timesheet.js/master/screen.png'} %meta{:property => 'fb:admins', :content => '669118929'} %title Timesheet.js - Open time tables with HTML, JavaScript and CSS … From a75c24c4035742162cb2c5bddab071499c93e949 Mon Sep 17 00:00:00 2001 From: sbstjn Date: Tue, 3 Mar 2015 20:59:08 +0100 Subject: [PATCH 06/12] Fixed GitHub link --- source/layouts/layout.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/layouts/layout.haml b/source/layouts/layout.haml index 09be0e9..16fd305 100644 --- a/source/layouts/layout.haml +++ b/source/layouts/layout.haml @@ -18,7 +18,7 @@ = stylesheet_link_tag 'all.css' = yield_content :head %body.black{ :class => page_classes } - %span Fork me on GitHub + %span Fork me on GitHub #container = yield %script{:type => 'text/javascript'} var _gauges = _gauges || []; (function() { var t = document.createElement('script'); t.type = 'text/javascript'; t.async = true; t.id = 'gauges-tracker'; t.setAttribute('data-site-id', '538272a38bfdf705f50037c3'); t.src = '//secure.gaug.es/track.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(t, s); })(); From 3030ee1439c44a719e291b1e09a73046dac72c64 Mon Sep 17 00:00:00 2001 From: sbstjn Date: Tue, 3 Mar 2015 21:02:35 +0100 Subject: [PATCH 07/12] Merged Pull Request #28 --- source/javascripts/timesheet.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/javascripts/timesheet.js b/source/javascripts/timesheet.js index 5494c8f..d0914c9 100644 --- a/source/javascripts/timesheet.js +++ b/source/javascripts/timesheet.js @@ -83,7 +83,7 @@ var beg = this.parseDate(data[n][0]); var end = data[n].length === 4 ? this.parseDate(data[n][1]) : null; var lbl = data[n].length === 4 ? data[n][2] : data[n][1]; - var cat = data[n][3] || 'default'; + var cat = data[n].length === 4 ? data[n][3] : data[n].length === 3 ? data[n][2] : 'default'; if (beg.getFullYear() < this.year.min) { this.year.min = beg.getFullYear(); From 8e77a9f2ab6c439bfb3ce048707f7fa3aa2bb1d2 Mon Sep 17 00:00:00 2001 From: sbstjn Date: Tue, 3 Mar 2015 21:10:53 +0100 Subject: [PATCH 08/12] Updated package.json --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index abc24b6..849a180 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "timesheet.js", - "version": "0.0.1", - "description": "Middleman, Grunt, JSHint, SASS, HAML", - "author": "semu", + "version": "1.0.0", + "description": "With Timesheet.js you can easily create simple time and data sheets or timelines using HTML5, JavaScript and CSS3. Yep, it's a Vanilla JS library!", + "author": "sbstjn ", "devDependencies": { "grunt": "~0.4.1", "grunt-cli": "~0.1.11", From 8731c93268593bb450d835ba4ae57f0166485195 Mon Sep 17 00:00:00 2001 From: sbstjn Date: Sat, 4 Jul 2015 19:14:23 +0200 Subject: [PATCH 09/12] Removed Ruby dependencies. Cleaned up. --- .gitignore | 3 + Gemfile | 14 -- Gemfile.lock | 120 ----------- Gruntfile.js | 193 +++++++++++------- bower.json | 5 +- config.rb | 14 -- dist/timesheet-white.min.css | 2 + dist/timesheet-white.min.css.map | 7 + dist/timesheet.js | 1 - dist/{timesheet.css => timesheet.min.css} | 1 + dist/timesheet.min.css.map | 7 + dist/timesheet.min.js | 1 + package.json | 14 +- serve.js | 50 +++++ source/index.haml | 84 ++++---- source/javascripts/main.js | 4 +- source/javascripts/timesheet.js | 31 +-- source/layouts/layout.haml | 24 --- source/snippets/example-date.js | 13 ++ .../{_normalize.css.sass => _normalize.sass} | 0 .../stylesheets/{all.css.sass => style.sass} | 6 - source/stylesheets/timesheet-white.css.sass | 99 --------- source/stylesheets/timesheet-white.sass | 101 +++++++++ .../{timesheet.css.sass => timesheet.sass} | 0 test/timesheet.js | 21 +- 25 files changed, 394 insertions(+), 421 deletions(-) delete mode 100644 Gemfile delete mode 100644 Gemfile.lock delete mode 100644 config.rb create mode 100644 dist/timesheet-white.min.css create mode 100644 dist/timesheet-white.min.css.map delete mode 100644 dist/timesheet.js rename dist/{timesheet.css => timesheet.min.css} (98%) create mode 100644 dist/timesheet.min.css.map create mode 100644 dist/timesheet.min.js create mode 100644 serve.js delete mode 100644 source/layouts/layout.haml create mode 100644 source/snippets/example-date.js rename source/stylesheets/{_normalize.css.sass => _normalize.sass} (100%) rename source/stylesheets/{all.css.sass => style.sass} (97%) delete mode 100644 source/stylesheets/timesheet-white.css.sass create mode 100644 source/stylesheets/timesheet-white.sass rename source/stylesheets/{timesheet.css.sass => timesheet.sass} (100%) diff --git a/.gitignore b/.gitignore index 3b8db8c..7e5b1c2 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,9 @@ /.sass-cache /.cache +# Built gh-pages +/gh-pages + # Ignore .DS_store file .DS_Store diff --git a/Gemfile b/Gemfile deleted file mode 100644 index ad8d771..0000000 --- a/Gemfile +++ /dev/null @@ -1,14 +0,0 @@ -# If you have OpenSSL installed, we recommend updating -# the following line to use "https" -source 'http://rubygems.org/' - -gem "middleman", "~>3.3.2" - -# Live-reloading plugin -gem "middleman-livereload", "~> 3.1.0" - -# For faster file watcher updates on Windows: -gem "wdm", "~> 0.1.0", :platforms => [:mswin, :mingw] - -# Windows does not come with time zone data -gem "tzinfo-data", platforms: [:mswin, :mingw] diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index 5517e4c..0000000 --- a/Gemfile.lock +++ /dev/null @@ -1,120 +0,0 @@ -GEM - remote: http://rubygems.org/ - specs: - activesupport (4.0.4) - i18n (~> 0.6, >= 0.6.9) - minitest (~> 4.2) - multi_json (~> 1.3) - thread_safe (~> 0.1) - tzinfo (~> 0.3.37) - chunky_png (1.3.0) - coffee-script (2.2.0) - coffee-script-source - execjs - coffee-script-source (1.7.0) - compass (0.12.6) - chunky_png (~> 1.2) - fssm (>= 0.2.7) - sass (~> 3.2.19) - compass-import-once (1.0.4) - sass (>= 3.2, < 3.5) - em-websocket (0.5.1) - eventmachine (>= 0.12.9) - http_parser.rb (~> 0.6.0) - erubis (2.7.0) - eventmachine (1.0.3) - execjs (2.0.2) - ffi (1.9.3) - fssm (0.2.10) - haml (4.0.5) - tilt - hike (1.2.3) - hooks (0.4.0) - uber (~> 0.0.4) - http_parser.rb (0.6.0) - i18n (0.6.9) - json (1.8.1) - kramdown (1.3.3) - listen (1.3.1) - rb-fsevent (>= 0.9.3) - rb-inotify (>= 0.9) - rb-kqueue (>= 0.2) - middleman (3.3.2) - coffee-script (~> 2.2.0) - compass (>= 0.12.4) - compass-import-once (~> 1.0.4) - execjs (~> 2.0) - haml (>= 4.0.5) - kramdown (~> 1.2) - middleman-core (= 3.3.2) - middleman-sprockets (>= 3.1.2) - sass (>= 3.2.17, < 4.0) - uglifier (~> 2.5) - middleman-core (3.3.2) - activesupport (~> 4.0.1) - bundler (~> 1.1) - erubis - hooks (~> 0.3) - i18n (~> 0.6.9) - listen (~> 1.1) - padrino-helpers (~> 0.12.1) - rack (>= 1.4.5, < 2.0) - rack-test (~> 0.6.2) - thor (>= 0.15.2, < 2.0) - tilt (~> 1.4.1, < 2.0) - middleman-livereload (3.1.1) - em-websocket (>= 0.2.0) - middleman-core (>= 3.0.2) - multi_json (~> 1.0) - rack-livereload - middleman-sprockets (3.3.3) - middleman-core (>= 3.2) - sprockets (~> 2.2) - sprockets-helpers (~> 1.1.0) - sprockets-sass (~> 1.1.0) - minitest (4.7.5) - multi_json (1.9.3) - padrino-helpers (0.12.1) - i18n (~> 0.6, >= 0.6.7) - padrino-support (= 0.12.1) - tilt (~> 1.4.1) - padrino-support (0.12.1) - activesupport (>= 3.1) - rack (1.5.2) - rack-livereload (0.3.15) - rack - rack-test (0.6.2) - rack (>= 1.0) - rb-fsevent (0.9.4) - rb-inotify (0.9.4) - ffi (>= 0.5.0) - rb-kqueue (0.2.2) - ffi (>= 0.5.0) - sass (3.2.19) - sprockets (2.12.1) - hike (~> 1.2) - multi_json (~> 1.0) - rack (~> 1.0) - tilt (~> 1.1, != 1.3.0) - sprockets-helpers (1.1.0) - sprockets (~> 2.0) - sprockets-sass (1.1.0) - sprockets (~> 2.0) - tilt (~> 1.1) - thor (0.19.1) - thread_safe (0.3.3) - tilt (1.4.1) - tzinfo (0.3.39) - uber (0.0.4) - uglifier (2.5.0) - execjs (>= 0.3.0) - json (>= 1.8.0) - -PLATFORMS - ruby - -DEPENDENCIES - middleman (~> 3.3.2) - middleman-livereload (~> 3.1.0) - tzinfo-data - wdm (~> 0.1.0) diff --git a/Gruntfile.js b/Gruntfile.js index 786fdbf..c8d6d58 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,78 +1,129 @@ module.exports = function(grunt) { - 'use strict'; + 'use strict'; - grunt.initConfig({ - uglify: { - options: { - mangle: false - }, - my_target: { - files: { - 'dist/timesheet.js': ['source/javascripts/timesheet.bubble.js', 'source/javascripts/timesheet.js'] - } - } - }, - sass: { - dist: { - options: { - style: 'compressed' - }, - files: { - 'dist/timesheet.css': 'source/stylesheets/timesheet.css.sass' - } - } - }, - jshint: { - all: { - src: [ - 'source/javascripts/*.js', - 'source/javascripts/**/*.js.erb' - ], - options: { - jshintrc: '.jshintrc' - } - } - }, - simplemocha: { - options: { - globals: ['should'], - timeout: 3000, - ignoreLeaks: false, - grep: '', - ui: 'tdd', - reporter: 'spec' - }, - all: { src: ['test/**/*.js'] } - }, - watch: { - scripts: { - files: [ - '.jshintrc', - 'Gruntfile.js', - 'source/**/*.js', - 'source/**/*.js.erb', - 'test/*.js', - '.jshint' - ], - tasks: ['simplemocha', 'jshint'], - options: { - interrupt: true, - }, - }, - } - }); + var fs = require('fs'); - // For this to work, you need to have run `npm install grunt-simple-mocha` - grunt.loadNpmTasks('grunt-contrib-jshint'); - grunt.loadNpmTasks('grunt-contrib-watch'); - grunt.loadNpmTasks('grunt-simple-mocha'); + grunt.initConfig({ + uglify: { + options: { + mangle: false + }, + my_target: { + files: { + 'dist/timesheet.min.js': ['source/javascripts/timesheet.js'] + } + } + }, + sass: { + gh: { + options: { + style: 'compressed' + }, + files: { + 'gh-pages/styles/style.css': 'source/stylesheets/style.sass' + } + }, + dist: { + options: { + style: 'compressed' + }, + files: { + 'dist/timesheet.min.css': 'source/stylesheets/timesheet.sass', + 'dist/timesheet-white.min.css': 'source/stylesheets/timesheet-white.sass' + } + } + }, + jshint: { + all: { + src: [ + 'source/javascripts/*.js' + ], + options: { + jshintrc: '.jshintrc' + } + } + }, + simplemocha: { + options: { + globals: ['should'], + timeout: 3000, + ignoreLeaks: false, + grep: '', + ui: 'tdd', + reporter: 'spec' + }, + all: { src: ['test/**/*.js'] } + }, + express: { + options: { + port: 8080 + }, + dev: { + options: { + script: __dirname + '/serve.js' + } + } + }, + watch: { + scripts: { + files: 'source/javascripts/*.js', + tasks: ['simplemocha', 'jshint', 'uglify'], + options: { + interrupt: true, + } + }, + styles: { + files: 'source/stylesheets/*.sass', + tasks: ['sass'], + options: { + interrupt: true, + } + } + }, + haml: { + gh: { + files: { + 'gh-pages/index.html': 'source/index.haml' + }, + options: { + context: { + code: fs.readFileSync(__dirname + '/source/snippets/example-date.js') + } + } + } + }, + copy: { + gh: { + files: [ + {expand: false, src: __dirname + '/source/javascripts/lib.js', dest: __dirname + '/gh-pages/script/lib.js'}, + {expand: false, src: __dirname + '/source/javascripts/main.js', dest: __dirname + '/gh-pages/script/main.js'}, + {expand: false, src: __dirname + '/dist/timesheet.min.js', dest: __dirname + '/gh-pages/script/timesheet.min.js'}, + {expand: false, src: __dirname + '/dist/timesheet.min.css', dest: __dirname + '/gh-pages/styles/timesheet.css'}, + {expand: false, src: __dirname + '/dist/timesheet-white.min.css', dest: __dirname + '/gh-pages/styles/timesheet-white.css'}, + {expand: false, src: __dirname + '/dist/timesheet.min.css.map', dest: __dirname + '/gh-pages/styles/timesheet.css.map'}, + {expand: false, src: __dirname + '/dist/timesheet-white.min.css.map', dest: __dirname + '/gh-pages/styles/timesheet-white.css.map'} + ] + } + } + }); - grunt.loadNpmTasks('grunt-contrib-uglify'); - grunt.loadNpmTasks('grunt-contrib-sass'); + grunt.loadNpmTasks('grunt-contrib-jshint'); + grunt.loadNpmTasks('grunt-contrib-watch'); + grunt.loadNpmTasks('grunt-simple-mocha'); - // Default task - grunt.registerTask('default', ['simplemocha', 'jshint']); + grunt.loadNpmTasks('grunt-contrib-copy'); + + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-contrib-sass'); + + grunt.loadNpmTasks('grunt-express-server'); + + grunt.loadNpmTasks('grunt-haml'); + + // Default task + grunt.registerTask('default', ['build']); + grunt.registerTask('build', ['simplemocha', 'jshint', 'uglify', 'sass']); + grunt.registerTask('server', ['express:dev', 'watch' ]) + grunt.registerTask('gh', ['build', 'haml:gh', 'sass:gh', 'copy:gh']); - // Build task - grunt.registerTask('build', ['uglify', 'sass']); }; diff --git a/bower.json b/bower.json index 5abf354..3e12a78 100644 --- a/bower.json +++ b/bower.json @@ -6,7 +6,7 @@ "sbstjn " ], "description": "With Timesheet.js you can easily create simple time and data sheets or timelines using HTML5, JavaScript and CSS3. Yep, it's a Vanilla JS library!", - "main": ["dist/timesheet.js", "dist/timesheet.css"], + "main": ["dist/timesheet.min.js", "dist/timesheet.min.css"], "moduleType": [ "amd" ], @@ -29,10 +29,7 @@ "tests", "screen.png", "source", - "config.rb", "Gruntfile.js", - "Gemfile", - "Gemfile.lock", "package.json" ] } diff --git a/config.rb b/config.rb deleted file mode 100644 index 9d8de79..0000000 --- a/config.rb +++ /dev/null @@ -1,14 +0,0 @@ -set :haml, { :ugly => false, :format => :html5 } - -set :css_dir, 'stylesheets' -set :js_dir, 'javascripts' -set :images_dir, 'images' - -activate :livereload - -configure :build do - activate :minify_css - activate :minify_javascript - activate :asset_hash, :ignore => [] - activate :relative_assets -end diff --git a/dist/timesheet-white.min.css b/dist/timesheet-white.min.css new file mode 100644 index 0000000..ffeb63f --- /dev/null +++ b/dist/timesheet-white.min.css @@ -0,0 +1,2 @@ +.white .timesheet{width:720px;height:292px;margin:0 auto}.white .timesheet{border-top:1px solid rgba(60,60,60,0.3);background-color:#fbfbfb;position:relative}.white .timesheet.color-scheme-default .bubble-default{background-color:RGBA(252, 70, 74, 1)}.white .timesheet.color-scheme-default .bubble-lorem{background-color:RGBA(154, 202, 39, 1)}.white .timesheet.color-scheme-default .bubble-ipsum{background-color:RGBA(60, 182, 227, 1)}.white .timesheet.color-scheme-default .bubble-dolor{background-color:RGBA(244, 207, 48, 1)}.white .timesheet.color-scheme-default .bubble-sit{background-color:RGBA(169, 105, 202, 1)}.white .timesheet.color-scheme-alternative .bubble-default{background-color:#f3552e}.white .timesheet.color-scheme-alternative .bubble-lorem{background-color:#88c33a}.white .timesheet.color-scheme-alternative .bubble-ipsum{background-color:#436ae0}.white .timesheet.color-scheme-alternative .bubble-dolor{background-color:#f4d234}.white .timesheet.color-scheme-alternative .bubble-sit{background-color:#707d86}.white .timesheet .scale{height:100%;position:absolute;top:0;left:0;float:left}.white .timesheet .scale section{float:left;width:59px;color:rgba(50,50,50,0.8);font-family:"Signika Negative";font-size:13px;line-height:24px;font-weight:300;border-left:1px dashed rgba(50,50,50,0.1);height:100%}.white .timesheet .data{margin:28px 0 0 0;padding:0;text-align:left;list-style-type:none;color:rgba(250,250,250,0.8);font-family:"Signika Negative";font-size:13px;overflow:hidden}.white .timesheet .data li{margin:0 0 3px 0;line-height:22px;height:21px;display:block;cursor:pointer;clear:both;position:relative;white-space:nowrap}.white .timesheet .data li:hover .bubble{opacity:1}.white .timesheet .data li .date{color:#797979;font-size:14px}.white .timesheet .data li .label{font-weight:lighter;font-size:14px;padding-left:5px;line-height:21px;color:#333332;white-space:nowrap}.white .timesheet .data li .bubble{width:24px;height:7px;display:block;float:left;position:relative;top:7px;border-radius:4px;margin:0 10px 0 0;opacity:0.7} +/*# sourceMappingURL=timesheet-white.min.css.map */ diff --git a/dist/timesheet-white.min.css.map b/dist/timesheet-white.min.css.map new file mode 100644 index 0000000..4698b1e --- /dev/null +++ b/dist/timesheet-white.min.css.map @@ -0,0 +1,7 @@ +{ +"version": 3, +"mappings": "AAEE,iBAAU,CACR,KAAK,CAAE,KAAK,CACZ,MAAM,CAAE,KAAK,CACb,MAAM,CAAE,MAAM,CAEhB,iBAAU,CACR,UAAU,CAAE,4BAA+B,CAC3C,gBAAgB,CAAE,OAAsB,CACxC,QAAQ,CAAE,QAAQ,CAGhB,sDAAe,CACb,gBAAgB,CAAE,oBAAoB,CACxC,oDAAa,CACX,gBAAgB,CAAE,qBAAqB,CACzC,oDAAa,CACX,gBAAgB,CAAE,qBAAqB,CACzC,oDAAa,CACX,gBAAgB,CAAE,qBAAqB,CACzC,kDAAW,CACT,gBAAgB,CAAE,sBAAsB,CAG1C,0DAAe,CACb,gBAAgB,CAAE,OAAoB,CACxC,wDAAa,CACX,gBAAgB,CAAE,OAAqB,CACzC,wDAAa,CACX,gBAAgB,CAAE,OAAqB,CACzC,wDAAa,CACX,gBAAgB,CAAE,OAAqB,CACzC,sDAAW,CACT,gBAAgB,CAAE,OAAsB,CAG5C,wBAAM,CACJ,MAAM,CAAE,IAAI,CACZ,QAAQ,CAAE,QAAQ,CAClB,GAAG,CAAE,CAAC,CACN,IAAI,CAAE,CAAC,CACP,KAAK,CAAE,IAAI,CAEX,gCAAO,CACL,KAAK,CAAE,IAAI,CACX,KAAK,CAAE,IAAI,CACX,KAAK,CAAE,kBAAqB,CAC5B,WAAW,CAAE,kBAAkB,CAC/B,SAAS,CAAE,IAAI,CACf,WAAW,CAAE,IAAI,CACjB,WAAW,CAAE,GAAG,CAChB,WAAW,CAAE,6BAAgC,CAC7C,MAAM,CAAE,IAAI,CAEhB,uBAAK,CACH,MAAM,CAAE,UAAU,CAClB,OAAO,CAAE,CAAC,CACV,UAAU,CAAE,IAAI,CAChB,eAAe,CAAE,IAAI,CACrB,KAAK,CAAE,qBAAwB,CAC/B,WAAW,CAAE,kBAAkB,CAC/B,SAAS,CAAE,IAAI,CACf,QAAQ,CAAE,MAAM,CAEhB,0BAAE,CACA,MAAM,CAAE,SAAS,CACjB,WAAW,CAAE,IAAI,CACjB,MAAM,CAAE,IAAI,CACZ,OAAO,CAAE,KAAK,CACd,MAAM,CAAE,OAAO,CACf,KAAK,CAAE,IAAI,CACX,QAAQ,CAAE,QAAQ,CAClB,WAAW,CAAE,MAAM,CAGjB,wCAAO,CACL,OAAO,CAAE,CAAC,CAEd,gCAAK,CACH,KAAK,CAAE,OAAsB,CAC7B,SAAS,CAAE,IAAI,CAEjB,iCAAM,CACJ,WAAW,CAAE,OAAO,CACpB,SAAS,CAAE,IAAI,CACf,YAAY,CAAE,GAAG,CACjB,WAAW,CAAE,IAAI,CACjB,KAAK,CAAE,OAAmB,CAC1B,WAAW,CAAE,MAAM,CAErB,kCAAO,CACL,KAAK,CAAE,IAAI,CACX,MAAM,CAAE,GAAG,CACX,OAAO,CAAE,KAAK,CACd,KAAK,CAAE,IAAI,CACX,QAAQ,CAAE,QAAQ,CAClB,GAAG,CAAE,GAAG,CACR,aAAa,CAAE,GAAG,CAClB,MAAM,CAAE,UAAU,CAClB,OAAO,CAAE,GAAG", +"sources": ["../source/stylesheets/timesheet-white.sass"], +"names": [], +"file": "timesheet-white.min.css" +} diff --git a/dist/timesheet.js b/dist/timesheet.js deleted file mode 100644 index 17b13b2..0000000 --- a/dist/timesheet.js +++ /dev/null @@ -1 +0,0 @@ -!function(){"use strict";var Bubble=function(wMonth,min,start,end){this.min=min,this.start=start,this.end=end,this.widthMonth=wMonth};Bubble.prototype.formatMonth=function(num){return num=parseInt(num,10),num>=10?num:"0"+num},Bubble.prototype.getStartOffset=function(){return this.widthMonth/12*(12*(this.start.getFullYear()-this.min)+this.start.getMonth())},Bubble.prototype.getFullYears=function(){return(this.end&&this.end.getFullYear()||this.start.getFullYear())-this.start.getFullYear()},Bubble.prototype.getMonths=function(){var fullYears=this.getFullYears(),months=0;return this.end?this.end.hasMonth?(months+=this.end.getMonth()+1,months+=12-(this.start.hasMonth?this.start.getMonth():0),months+=12*(fullYears-1)):(months+=12-(this.start.hasMonth?this.start.getMonth():0),months+=12*(fullYears-1>0?fullYears-1:0)):months+=this.start.hasMonth?1:12,months},Bubble.prototype.getWidth=function(){return this.widthMonth/12*this.getMonths()},Bubble.prototype.getDateLabel=function(){return[(this.start.hasMonth?this.formatMonth(this.start.getMonth()+1)+"/":"")+this.start.getFullYear(),this.end?"-"+((this.end.hasMonth?this.formatMonth(this.end.getMonth()+1)+"/":"")+this.end.getFullYear()):""].join("")},window.TimesheetBubble=Bubble}(),function(){"use strict";var Timesheet=function(container,min,max,data){this.data=[],this.year={min:min,max:max},this.parse(data||[]),"undefined"!=typeof document&&(this.container="string"==typeof container?document.querySelector("#"+container):container,this.drawSections(),this.insertData())};Timesheet.prototype.insertData=function(){for(var html=[],widthMonth=this.container.querySelector(".scale section").offsetWidth,n=0,m=this.data.length;m>n;n++){var cur=this.data[n],bubble=new TimesheetBubble(widthMonth,this.year.min,cur.start,cur.end),line=['',''+bubble.getDateLabel()+" ",''+cur.label+""].join("");html.push("
  • "+line+"
  • ")}this.container.innerHTML+='
      '+html.join("")+"
    "},Timesheet.prototype.drawSections=function(){for(var html=[],c=this.year.min;c<=this.year.max;c++)html.push("
    "+c+"
    ");this.container.className="timesheet color-scheme-default",this.container.innerHTML='
    '+html.join("")+"
    "},Timesheet.prototype.parseDate=function(date){return-1===date.indexOf("/")?(date=new Date(parseInt(date,10),0,1),date.hasMonth=!1):(date=date.split("/"),date=new Date(parseInt(date[1],10),parseInt(date[0],10)-1,1),date.hasMonth=!0),date},Timesheet.prototype.parse=function(data){for(var n=0,m=data.length;m>n;n++){var beg=this.parseDate(data[n][0]),end=4===data[n].length?this.parseDate(data[n][1]):null,lbl=4===data[n].length?data[n][2]:data[n][1],cat=data[n][3]||"default";beg.getFullYear()this.year.max?this.year.max=end.getFullYear():beg.getFullYear()>this.year.max&&(this.year.max=beg.getFullYear()),this.data.push({start:beg,end:end,label:lbl,type:cat})}},window.Timesheet=Timesheet}(); \ No newline at end of file diff --git a/dist/timesheet.css b/dist/timesheet.min.css similarity index 98% rename from dist/timesheet.css rename to dist/timesheet.min.css index a1e3d1b..ec2eb90 100644 --- a/dist/timesheet.css +++ b/dist/timesheet.min.css @@ -1 +1,2 @@ .timesheet{width:720px;height:292px;margin:0 auto}.timesheet{border-top:1px solid rgba(250,250,250,0.5);background-color:#333;position:relative}.timesheet.color-scheme-default .bubble-default{background-color:RGBA(252, 70, 74, 1)}.timesheet.color-scheme-default .bubble-lorem{background-color:RGBA(154, 202, 39, 1)}.timesheet.color-scheme-default .bubble-ipsum{background-color:RGBA(60, 182, 227, 1)}.timesheet.color-scheme-default .bubble-dolor{background-color:RGBA(244, 207, 48, 1)}.timesheet.color-scheme-default .bubble-sit{background-color:RGBA(169, 105, 202, 1)}.timesheet.color-scheme-alternative .bubble-default{background-color:#f3552e}.timesheet.color-scheme-alternative .bubble-lorem{background-color:#88c33a}.timesheet.color-scheme-alternative .bubble-ipsum{background-color:#436ae0}.timesheet.color-scheme-alternative .bubble-dolor{background-color:#f4d234}.timesheet.color-scheme-alternative .bubble-sit{background-color:#707d86}.timesheet .scale{height:100%;position:absolute;top:0;left:0;float:left}.timesheet .scale section{float:left;width:59px;text-align:center;color:rgba(250,250,250,0.8);font-family:"Signika Negative";font-size:13px;line-height:24px;font-weight:lighter;border-left:1px dashed rgba(250,250,250,0.2);height:100%}.timesheet .data{margin:28px 0 0 0;padding:0;text-align:left;list-style-type:none;color:rgba(250,250,250,0.8);font-family:"Signika Negative";font-size:13px;overflow:hidden}.timesheet .data li{margin:0 0 3px 0;line-height:22px;height:21px;display:block;clear:both;position:relative;white-space:nowrap}.timesheet .data li:hover .bubble{opacity:1}.timesheet .data li .date{color:#b5b5b5;font-size:14px}.timesheet .data li .label{font-weight:lighter;font-size:14px;padding-left:5px;line-height:21px;color:#979796;white-space:nowrap}.timesheet .data li .bubble{width:24px;height:7px;display:block;float:left;position:relative;top:7px;border-radius:4px;margin:0 10px 0 0;opacity:0.7}#timesheet-alternative{background-color:RGBA(247, 247, 247, 1);border-radius:5px}#timesheet-alternative section{color:RGBA(63, 68, 72, 1);border-left:1px dashed RGBA(63, 68, 72, 0.2)}#timesheet-alternative section:first-child{border-left:1px dashed transparent}#timesheet-alternative .date{display:none}#timesheet-alternative .bubble{margin-right:7px}#timesheet-alternative .label{padding-left:0px;color:RGBA(48, 48, 48, 1)} +/*# sourceMappingURL=timesheet.min.css.map */ diff --git a/dist/timesheet.min.css.map b/dist/timesheet.min.css.map new file mode 100644 index 0000000..25084fc --- /dev/null +++ b/dist/timesheet.min.css.map @@ -0,0 +1,7 @@ +{ +"version": 3, +"mappings": "AAAA,UAAU,CACR,KAAK,CAAE,KAAK,CACZ,MAAM,CAAE,KAAK,CACb,MAAM,CAAE,MAAM,CAEhB,UAAU,CACR,UAAU,CAAE,+BAAkC,CAC9C,gBAAgB,CAAE,IAAmB,CACrC,QAAQ,CAAE,QAAQ,CAGhB,+CAAe,CACb,gBAAgB,CAAE,oBAAoB,CACxC,6CAAa,CACX,gBAAgB,CAAE,qBAAqB,CACzC,6CAAa,CACX,gBAAgB,CAAE,qBAAqB,CACzC,6CAAa,CACX,gBAAgB,CAAE,qBAAqB,CACzC,2CAAW,CACT,gBAAgB,CAAE,sBAAsB,CAG1C,mDAAe,CACb,gBAAgB,CAAE,OAAoB,CACxC,iDAAa,CACX,gBAAgB,CAAE,OAAqB,CACzC,iDAAa,CACX,gBAAgB,CAAE,OAAqB,CACzC,iDAAa,CACX,gBAAgB,CAAE,OAAqB,CACzC,+CAAW,CACT,gBAAgB,CAAE,OAAsB,CAG5C,iBAAM,CACJ,MAAM,CAAE,IAAI,CACZ,QAAQ,CAAE,QAAQ,CAClB,GAAG,CAAE,CAAC,CACN,IAAI,CAAE,CAAC,CACP,KAAK,CAAE,IAAI,CAEX,yBAAO,CACL,KAAK,CAAE,IAAI,CACX,KAAK,CAAE,IAAI,CACX,UAAU,CAAE,MAAM,CAClB,KAAK,CAAE,qBAAwB,CAC/B,WAAW,CAAE,kBAAkB,CAC/B,SAAS,CAAE,IAAI,CACf,WAAW,CAAE,IAAI,CACjB,WAAW,CAAE,OAAO,CACpB,WAAW,CAAE,gCAAmC,CAChD,MAAM,CAAE,IAAI,CAEhB,gBAAK,CACH,MAAM,CAAE,UAAU,CAClB,OAAO,CAAE,CAAC,CACV,UAAU,CAAE,IAAI,CAChB,eAAe,CAAE,IAAI,CACrB,KAAK,CAAE,qBAAwB,CAC/B,WAAW,CAAE,kBAAkB,CAC/B,SAAS,CAAE,IAAI,CACf,QAAQ,CAAE,MAAM,CAEhB,mBAAE,CACA,MAAM,CAAE,SAAS,CACjB,WAAW,CAAE,IAAI,CACjB,MAAM,CAAE,IAAI,CACZ,OAAO,CAAE,KAAK,CACd,KAAK,CAAE,IAAI,CACX,QAAQ,CAAE,QAAQ,CAClB,WAAW,CAAE,MAAM,CAGjB,iCAAO,CACL,OAAO,CAAE,CAAC,CAEd,yBAAK,CACH,KAAK,CAAE,OAAsB,CAC7B,SAAS,CAAE,IAAI,CAEjB,0BAAM,CACJ,WAAW,CAAE,OAAO,CACpB,SAAS,CAAE,IAAI,CACf,YAAY,CAAE,GAAG,CACjB,WAAW,CAAE,IAAI,CACjB,KAAK,CAAE,OAAsB,CAC7B,WAAW,CAAE,MAAM,CAErB,2BAAO,CACL,KAAK,CAAE,IAAI,CACX,MAAM,CAAE,GAAG,CACX,OAAO,CAAE,KAAK,CACd,KAAK,CAAE,IAAI,CACX,QAAQ,CAAE,QAAQ,CAClB,GAAG,CAAE,GAAG,CACR,aAAa,CAAE,GAAG,CAClB,MAAM,CAAE,UAAU,CAClB,OAAO,CAAE,GAAG,CAEpB,sBAAsB,CACpB,gBAAgB,CAAE,sBAAsB,CACxC,aAAa,CAAE,GAAG,CAElB,8BAAO,CACL,KAAK,CAAE,mBAAmB,CAC1B,WAAW,CAAE,gCAAgC,CAE7C,0CAAa,CACX,WAAW,CAAE,sBAAsB,CAEvC,4BAAK,CACH,OAAO,CAAE,IAAI,CAEf,8BAAO,CACL,YAAY,CAAE,GAAG,CAEnB,6BAAM,CACJ,YAAY,CAAE,GAAG,CACjB,KAAK,CAAE,mBAAmB", +"sources": ["../source/stylesheets/timesheet.sass"], +"names": [], +"file": "timesheet.min.css" +} diff --git a/dist/timesheet.min.js b/dist/timesheet.min.js new file mode 100644 index 0000000..8c498e0 --- /dev/null +++ b/dist/timesheet.min.js @@ -0,0 +1 @@ +!function(){"use strict";var Timesheet=function(container,min,max,data){this.data=[],this.year={min:min,max:max},this.parse(data||[]),"undefined"!=typeof document&&(this.container="string"==typeof container?document.querySelector("#"+container):container,this.drawSections(),this.insertData())};Timesheet.prototype.insertData=function(){for(var html=[],widthMonth=this.container.querySelector(".scale section").offsetWidth,n=0,m=this.data.length;m>n;n++){var cur=this.data[n],bubble=this.createBubble(widthMonth,this.year.min,cur.start,cur.end),line=['',''+bubble.getDateLabel()+" ",''+cur.label+""].join("");html.push("
  • "+line+"
  • ")}this.container.innerHTML+='
      '+html.join("")+"
    "},Timesheet.prototype.drawSections=function(){for(var html=[],c=this.year.min;c<=this.year.max;c++)html.push("
    "+c+"
    ");this.container.className="timesheet color-scheme-default",this.container.innerHTML='
    '+html.join("")+"
    "},Timesheet.prototype.parseDate=function(date){return-1===date.indexOf("/")?(date=new Date(parseInt(date,10),0,1),date.hasMonth=!1):(date=date.split("/"),date=new Date(parseInt(date[1],10),parseInt(date[0],10)-1,1),date.hasMonth=!0),date},Timesheet.prototype.parse=function(data){for(var n=0,m=data.length;m>n;n++){var beg=this.parseDate(data[n][0]),end=4===data[n].length?this.parseDate(data[n][1]):null,lbl=4===data[n].length?data[n][2]:data[n][1],cat=4===data[n].length?data[n][3]:3===data[n].length?data[n][2]:"default";beg.getFullYear()this.year.max?this.year.max=end.getFullYear():beg.getFullYear()>this.year.max&&(this.year.max=beg.getFullYear()),this.data.push({start:beg,end:end,label:lbl,type:cat})}},Timesheet.prototype.createBubble=function(wMonth,min,start,end){return new Bubble(wMonth,min,start,end)};var Bubble=function(wMonth,min,start,end){this.min=min,this.start=start,this.end=end,this.widthMonth=wMonth};Bubble.prototype.formatMonth=function(num){return num=parseInt(num,10),num>=10?num:"0"+num},Bubble.prototype.getStartOffset=function(){return this.widthMonth/12*(12*(this.start.getFullYear()-this.min)+this.start.getMonth())},Bubble.prototype.getFullYears=function(){return(this.end&&this.end.getFullYear()||this.start.getFullYear())-this.start.getFullYear()},Bubble.prototype.getMonths=function(){var fullYears=this.getFullYears(),months=0;return this.end?this.end.hasMonth?(months+=this.end.getMonth()+1,months+=12-(this.start.hasMonth?this.start.getMonth():0),months+=12*(fullYears-1)):(months+=12-(this.start.hasMonth?this.start.getMonth():0),months+=12*(fullYears-1>0?fullYears-1:0)):months+=this.start.hasMonth?1:12,months},Bubble.prototype.getWidth=function(){return this.widthMonth/12*this.getMonths()},Bubble.prototype.getDateLabel=function(){return[(this.start.hasMonth?this.formatMonth(this.start.getMonth()+1)+"/":"")+this.start.getFullYear(),this.end?"-"+((this.end.hasMonth?this.formatMonth(this.end.getMonth()+1)+"/":"")+this.end.getFullYear()):""].join("")},window.Timesheet=Timesheet}(); \ No newline at end of file diff --git a/package.json b/package.json index 849a180..10e6124 100644 --- a/package.json +++ b/package.json @@ -4,13 +4,21 @@ "description": "With Timesheet.js you can easily create simple time and data sheets or timelines using HTML5, JavaScript and CSS3. Yep, it's a Vanilla JS library!", "author": "sbstjn ", "devDependencies": { + "consolidate": "^0.13.1", + "express": "^4.12.4", "grunt": "~0.4.1", "grunt-cli": "~0.1.11", - "grunt-jslint": "~1.1.1", + "grunt-contrib-copy": "^0.8.0", "grunt-contrib-jshint": "~0.7.2", + "grunt-contrib-sass": "^0.7.3", + "grunt-contrib-uglify": "^0.4.0", "grunt-contrib-watch": "^0.6.1", + "grunt-express-server": "^0.5.1", + "grunt-haml": "^0.9.0", + "grunt-jslint": "~1.1.1", "grunt-simple-mocha": "^0.4.0", - "grunt-contrib-uglify": "^0.4.0", - "grunt-contrib-sass": "^0.7.3" + "haml": "^0.4.3", + "hamljs": "^0.6.2", + "node-sass": "^3.2.0" } } diff --git a/serve.js b/serve.js new file mode 100644 index 0000000..9e66861 --- /dev/null +++ b/serve.js @@ -0,0 +1,50 @@ +var express = require('express'); +var sass = require('node-sass'); +var fs = require('fs'); +var app = express(); +var engines = require('consolidate'); + +app.engine('haml', engines.haml); +app.set('views', __dirname + '/source'); + +app.get('/script/lib.js', function(req, res) { + res.end(fs.readFileSync(__dirname + '/source/javascripts/lib.js')); +}); + +app.get('/script/main.js', function(req, res) { + res.end(fs.readFileSync(__dirname + '/source/javascripts/main.js')); +}); + +app.get('/script/timesheet.min.js', function(req, res) { + res.end(fs.readFileSync(__dirname + '/dist/timesheet.min.js')); +}); + +app.get('/styles/timesheet.css', function(req, res) { + res.end(fs.readFileSync(__dirname + '/dist/timesheet.min.css')); +}); + +app.get('/styles/timesheet-white.css', function(req, res) { + res.end(fs.readFileSync(__dirname + '/dist/timesheet-white.min.css')); +}); + +app.get('/styles/style.css', function(req, res) { + sass.render({ + file: __dirname + '/source/stylesheets/style.sass', + outputStyle: req.query.style || "" + }, function(err, result) { + res.end(result.css.toString()); + }); +}); + +app.get('/', function (req, res) { + res.render('index.haml', { + code: fs.readFileSync(__dirname + '/source/snippets/example-date.js') + '' + }); +}); + +var server = app.listen(process.env.PORT || 3000, function () { + var host = server.address().address; + var port = server.address().port; + + console.log('Example app listening at http://%s:%s', host, port); +}); diff --git a/source/index.haml b/source/index.haml index 402e3c7..a0e732b 100644 --- a/source/index.haml +++ b/source/index.haml @@ -1,39 +1,45 @@ -#box - #box-inner - %h1 - Timesheet.js - %p Visualize your data and events with sexy HTML5 and CSS3. Create simple time sheets with sneaky JavaScript. Style them with CSS and have mobile fun as well … - - #timesheet-default - - %p Just include Timesheet.js and configure your data. No external dependencies, no jQuery needed and of course no Angular.JS! Just a few lines JavaScript to generate a beautiful HTML5 layout and some really delicious CSS to be customized by almighty you. - - %code - %pre - = preserve do - :escaped -