From 363925074d413b63e07246a75da73748253cacab Mon Sep 17 00:00:00 2001 From: Deepu KS Date: Thu, 27 Aug 2015 11:45:10 +0800 Subject: [PATCH] 0.5.0 --- bower.json | 2 +- dist/angular-clock.js | 72 ++++++++++++++++++++++------------ dist/angular-clock.js.tar.gz | Bin 5808 -> 6111 bytes dist/angular-clock.min.js | 2 +- dist/angular-clock.min.js.map | 2 +- examples/app.js | 8 +++- examples/index.html | 32 ++++++++++----- examples/index.template.html | 30 +++++++++----- package.json | 2 +- 9 files changed, 99 insertions(+), 51 deletions(-) diff --git a/bower.json b/bower.json index 10040c1..a977cc0 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-ui-clock", - "version": "0.4.0", + "version": "0.5.0", "main": [ "./dist/angular-clock.js", "./dist/angular-clock.css" diff --git a/dist/angular-clock.js b/dist/angular-clock.js index da78e62..390edfd 100644 --- a/dist/angular-clock.js +++ b/dist/angular-clock.js @@ -1,7 +1,10 @@ (function() { 'use strict'; - /* */ + /** + * Usage pattern + * + */ var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; @@ -17,23 +20,24 @@ restrict: 'EA', scope: { gmtOffset: '=gmtOffset', - digitalFormat: '=digitalFormat' + digitalFormat: '=digitalFormat', + showDigital: '=showDigital', + showAnalog: '=showAnalog', + startTime: '=startTime', + theme: '=theme' }, - template: '
{{digital}}
{{gmtInfo}}
', + template: '
{{digital}}
{{gmtInfo}}
', link: function(scope, element, attrs) { var format, // date format stopTime; // so that we can cancel the time updates - var o = {}; //angular.copy(defaults) + var o = {}; var gmtOffset = scope.gmtOffset; - var digitalFormat = scope.digitalFormat !== undefined ? scope.digitalFormat : 'HH:mm:ss'; - //o.gmtOffset = (gmtOffset !== undefined && gmtOffset !== null) ? parseFloat(gmtOffset) : false; - //o.showSecs = attrs.hideSecs !== undefined ? false : true; - //o.showAmPm = attrs.showAmPm !== undefined ? true : false; - o.showDigital = attrs.showDigital !== undefined ? true : false; - o.showAnalog = attrs.showAnalog !== undefined ? true : false; + var digitalFormat = scope.digitalFormat ? scope.digitalFormat : 'HH:mm:ss'; + o.showDigital = scope.showDigital != null ? scope.showDigital : attrs.showDigital !== undefined ? true : false; + o.showAnalog = scope.showAnalog != null ? scope.showAnalog : attrs.showAnalog !== undefined ? true : false; o.showGmtInfo = attrs.showGmtInfo !== undefined ? true : false; - o.startTime = parseInt(attrs.startTime, 10); // ms - scope.theme = attrs.theme !== undefined ? attrs.theme : 'light'; + o.startTime = parseInt(scope.startTime, 10); // ms + scope.themeClass = scope.theme ? scope.theme : attrs.theme ? attrs.theme : 'light'; if (!o.showDigital && !o.showAnalog) { o.showAnalog = true; o.showDigital = true; @@ -60,17 +64,38 @@ stopTime = $interval(tick, 1000); // watch the expression, and update the UI on change. - scope.$watch('gmtOffset', function(value) { + scope.$watch('gmtOffset', function(value, old) { + gmtOffset = value; - o.gmtOffset = (gmtOffset !== undefined && gmtOffset !== null) ? getGMTbase100(gmtOffset) : false; + o.gmtOffset = (gmtOffset != null) ? getGMTbase100(gmtOffset) : false; if (o.showGmtInfo && o.gmtOffset !== false) { scope.gmtInfo = getGMTText(o.gmtOffset); } + tick(); }); - /*scope.$watch('digitalFormat', function(value) { - digitalFormat = value; - });*/ + scope.$watch('digitalFormat', function(value, old) { + if(value != old){ + digitalFormat = value; + } + }); + scope.$watch('showDigital', function(value, old) { + if(value != old){ + o.showDigital = value; + scope.digital = o.showDigital ? 'Loading..' : false;; + } + }); + scope.$watch('showAnalog', function(value, old) { + if(value != old){ + o.showAnalog = value; + scope.analog = value; + } + }); + scope.$watch('theme', function(value, old) { + if(value != old){ + scope.themeClass = value ? value : attrs.theme ? attrs.theme : 'light'; + } + }); // listen on DOM destroy (removal) event, and cancel the next UI update // to prevent updating time after the DOM element was removed. element.on('$destroy', function() { @@ -123,10 +148,10 @@ function getDate(o) { var now = (!isNaN(o.startTime)) ? new Date(o.startTime) : new Date(); if (o.gmtOffset !== null && o.gmtOffset !== false) { - // Use GMT + gmtOffset - // convert to msec - // add local time zone offset - // get UTC time in msec + /*Use GMT + gmtOffset + convert to msec + add local time zone offset + get UTC time in msec*/ var utc = now.getTime() + (now.getTimezoneOffset() * 60000); // create new Date object for different city // using supplied offset @@ -150,11 +175,6 @@ function timeText(d, format, timezone, $filter) { return $filter('date')(d.date, format, timezone); - /*return '' + - (o.showAmPm ? ((d.hrs % 12) === 0 ? 12 : (d.hrs % 12)) : d.hrs) + ':' + - lpad(d.mins) + - (o.showSecs ? ':' + lpad(d.secs) : '') + - (o.showAmPm ? (d.hrs < 12 ? ' AM' : ' PM') : '');*/ } })(); diff --git a/dist/angular-clock.js.tar.gz b/dist/angular-clock.js.tar.gz index ba3bb0e574d81c7ecfdde21d7553bd2751d18c10..c566c6fbb100dc8765e7dbb87927f842d51e11a3 100644 GIT binary patch literal 6111 zcmV<57a-^#iwFP!000023+)_jQ`<(fpF8vX2SraCED*Mg!89fgBMXN(lu!aRP3n9Q zw)~RVk}JuOg!;cfyL%_;?kpRV&`h5hJOjR$y?wpgTit2x`u*w14L3WZp!2cViJ~9w z|6^HJb$eUGZ}_O+R=KicY2~e*>h6wJ*|n;gRo>d(-GcrfzQbo4#cl|!+=GykaQ`Qt z;`OlG_hM#$t=Jv*hp{`liM>zpraKz;{aVNKV=tU3fbnqb-Sh%K-t4*K;plU1?d-GP z2_|mrt(lSQN1Krs4tsk95)Hq2wXNcgH{Kh&VSnh?EEQk$*VGNYn@JE2<6+>}LT}{8 z!z*tOz~VuzY*|0=4ZLB05ZA1|iQDZC{r=`<5XZroIu(4;RX@Y!UPi%a8t37n^2qDO z^BmC^NZ0XhqBsmbdbR&nDwVz7a5Sp@x7X{b@Z+H$gemBgCr|cRd6Q8s?#vBvKL`U5 zw=|%v!ViL}1fIhH2$@1utJOIrd!4}VrVwRox9WBCfi^qA6zzUZdQyhSj4F&2yKX3}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MeaFPgONlML{cF#?{%g;_|7+_h2Kmii#9*}R(HvxzqYu&4@bmd|t@SenDHuLN5l!gSVamQ{qQLGBA`!e(7!rK&Jh zirKob^u+tlm0|M?xk7DNwuP5hhb?qPQ6Z)nH)X85R*9v2J+n?MMK9X@f74pA6w0rt z7LzfpP%ow`U_r%LcD9xkzNYCo9h-3~|0i3iE%=-YvS{d{8nOuHYwDb&-FtQ&nJki0 zkCk*R7ORpW)i>n$Zgpi}EQwlSCM)IJ$?_F-W*Juc5w&KEH7C`aMZBq1XY!fS9qP{F zX(b9}veC?`JyZTax%s^Nv%IfRho<~rdMnnV&AMA$jV8O;SJ$J-Cb(-wTB70Xnlz<9 zRh6dn&96&Sz_KdS5`eF%O;b5twK`21m06#ra`z<_YBOG}tWoo;)MTiIb!tj-wy07~ zIh$2$)uhF3!8DwySX)6hcbQb~a(Ue4lDKnZm>&sNtzt`siPh`aqJc^!Tf*cws%4W7 uvy^JK8A40z+2*pgN<~{r&s5iT|G#$Lf9^l`pZm}M+~>a;#g@weXaE4RE;r%; diff --git a/dist/angular-clock.min.js b/dist/angular-clock.min.js index 0e4dc34..9bcd335 100644 --- a/dist/angular-clock.min.js +++ b/dist/angular-clock.min.js @@ -1,2 +1,2 @@ -!function(){"use strict";function t(t,n){return{restrict:"EA",scope:{gmtOffset:"=gmtOffset",digitalFormat:"=digitalFormat"},template:'
{{digital}}
{{gmtInfo}}
',link:function(s,o,g){var l,m={},c=s.gmtOffset,f=void 0!==s.digitalFormat?s.digitalFormat:"HH:mm:ss";m.showDigital=void 0!==g.showDigital?!0:!1,m.showAnalog=void 0!==g.showAnalog?!0:!1,m.showGmtInfo=void 0!==g.showGmtInfo?!0:!1,m.startTime=parseInt(g.startTime,10),s.theme=void 0!==g.theme?g.theme:"light",m.showDigital||m.showAnalog||(m.showAnalog=!0,m.showDigital=!0),s.gmtInfo=!1,s.date=i(m),s.digital=m.showDigital?"Loading..":!1,s.analog=m.showAnalog,s.majors=new Array(12),s.minors=new Array(60);var d=null,u=function(){isNaN(m.startTime)||(m.startTime=m.startTime+1e3),d=i(m),s.date=d,m.showDigital&&(s.digital=r(d,f,c,n))};l=t(u,1e3),s.$watch("gmtOffset",function(t){c=t,m.gmtOffset=void 0!==c&&null!==c?e(c):!1,m.showGmtInfo&&m.gmtOffset!==!1&&(s.gmtInfo=a(m.gmtOffset)),u()}),o.on("$destroy",function(){t.cancel(l),l=null})}}}function e(t){t=parseFloat(t);var e=t>0?Math.floor(t):Math.ceil(t),a=t%1/.6;return e+a}function a(t){var e=t>0?Math.floor(t):Math.ceil(t),a=Math.round((t>0?t:-1*t)%1*60);return"GMT"+(0===t?"":(t>0?" +":" ")+n(e)+"."+s(a).substring(0,2))}function n(t){return 0>t?(t>-10?"-0":"-")+-1*t:(10>t?"0":"")+t}function s(t){return t+(10>t?"0":"")}function i(t){var e=isNaN(t.startTime)?new Date:new Date(t.startTime);if(null!==t.gmtOffset&&t.gmtOffset!==!1){var a=e.getTime()+6e4*e.getTimezoneOffset(),n=new Date(a+36e5*t.gmtOffset);return{hrs:n.getHours(),mins:n.getMinutes(),secs:n.getSeconds(),date:n}}return{hrs:e.getHours(),mins:e.getMinutes(),secs:e.getSeconds(),date:e}}function r(t,e,a,n){return n("date")(t.date,e,a)}angular.module("ds.clock",[]).directive("dsWidgetClock",["$interval","$filter",function(e,a){return t(e,a)}])}(); +!function(){"use strict";function t(t,n){return{restrict:"EA",scope:{gmtOffset:"=gmtOffset",digitalFormat:"=digitalFormat",showDigital:"=showDigital",showAnalog:"=showAnalog",startTime:"=startTime",theme:"=theme"},template:'
{{digital}}
{{gmtInfo}}
',link:function(s,r,l){var g,m={},c=s.gmtOffset,f=s.digitalFormat?s.digitalFormat:"HH:mm:ss";m.showDigital=null!=s.showDigital?s.showDigital:void 0!==l.showDigital?!0:!1,m.showAnalog=null!=s.showAnalog?s.showAnalog:void 0!==l.showAnalog?!0:!1,m.showGmtInfo=void 0!==l.showGmtInfo?!0:!1,m.startTime=parseInt(s.startTime,10),s.themeClass=s.theme?s.theme:l.theme?l.theme:"light",m.showDigital||m.showAnalog||(m.showAnalog=!0,m.showDigital=!0),s.gmtInfo=!1,s.date=i(m),s.digital=m.showDigital?"Loading..":!1,s.analog=m.showAnalog,s.majors=new Array(12),s.minors=new Array(60);var h=null,d=function(){isNaN(m.startTime)||(m.startTime=m.startTime+1e3),h=i(m),s.date=h,m.showDigital&&(s.digital=o(h,f,c,n))};g=t(d,1e3),s.$watch("gmtOffset",function(t){c=t,m.gmtOffset=null!=c?a(c):!1,m.showGmtInfo&&m.gmtOffset!==!1&&(s.gmtInfo=e(m.gmtOffset)),d()}),s.$watch("digitalFormat",function(t,a){t!=a&&(f=t)}),s.$watch("showDigital",function(t,a){t!=a&&(m.showDigital=t,s.digital=m.showDigital?"Loading..":!1)}),s.$watch("showAnalog",function(t,a){t!=a&&(m.showAnalog=t,s.analog=t)}),s.$watch("theme",function(t,a){t!=a&&(s.themeClass=t?t:l.theme?l.theme:"light")}),r.on("$destroy",function(){t.cancel(g),g=null})}}}function a(t){t=parseFloat(t);var a=t>0?Math.floor(t):Math.ceil(t),e=t%1/.6;return a+e}function e(t){var a=t>0?Math.floor(t):Math.ceil(t),e=Math.round((t>0?t:-1*t)%1*60);return"GMT"+(0===t?"":(t>0?" +":" ")+n(a)+"."+s(e).substring(0,2))}function n(t){return 0>t?(t>-10?"-0":"-")+-1*t:(10>t?"0":"")+t}function s(t){return t+(10>t?"0":"")}function i(t){var a=isNaN(t.startTime)?new Date:new Date(t.startTime);if(null!==t.gmtOffset&&t.gmtOffset!==!1){var e=a.getTime()+6e4*a.getTimezoneOffset(),n=new Date(e+36e5*t.gmtOffset);return{hrs:n.getHours(),mins:n.getMinutes(),secs:n.getSeconds(),date:n}}return{hrs:a.getHours(),mins:a.getMinutes(),secs:a.getSeconds(),date:a}}function o(t,a,e,n){return n("date")(t.date,a,e)}angular.module("ds.clock",[]).directive("dsWidgetClock",["$interval","$filter",function(a,e){return t(a,e)}])}(); //# sourceMappingURL=angular-clock.min.js.map \ No newline at end of file diff --git a/dist/angular-clock.min.js.map b/dist/angular-clock.min.js.map index 5d1f7bf..23f0858 100644 --- a/dist/angular-clock.min.js.map +++ b/dist/angular-clock.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["angular-clock.min.js"],"names":["clock","$interval","$filter","restrict","scope","gmtOffset","digitalFormat","template","link","element","attrs","stopTime","o","undefined","showDigital","showAnalog","showGmtInfo","startTime","parseInt","theme","gmtInfo","date","getDate","digital","analog","majors","Array","minors","tick","isNaN","timeText","$watch","value","getGMTbase100","getGMTText","on","cancel","offset","parseFloat","f","Math","floor","ceil","s","round","lpad","rpad","substring","num","now","Date","utc","getTime","getTimezoneOffset","offsetNow","hrs","getHours","mins","getMinutes","secs","getSeconds","d","format","timezone","angular","module","directive"],"mappings":"CAAA,WACE,YAaA,SAASA,GAAMC,EAAWC,GACxB,OACEC,SAAU,KACVC,OACEC,UAAW,aACXC,cAAe,kBAEjBC,SAAU,ugCACVC,KAAM,SAASJ,EAAOK,EAASC,GAC7B,GACEC,GACEC,KACAP,EAAYD,EAAMC,UAClBC,EAAwCO,SAAxBT,EAAME,cAA8BF,EAAME,cAAgB,UAI9EM,GAAEE,YAAoCD,SAAtBH,EAAMI,aAA4B,GAAO,EACzDF,EAAEG,WAAkCF,SAArBH,EAAMK,YAA2B,GAAO,EACvDH,EAAEI,YAAoCH,SAAtBH,EAAMM,aAA4B,GAAO,EACzDJ,EAAEK,UAAYC,SAASR,EAAMO,UAAW,IACxCb,EAAMe,MAAwBN,SAAhBH,EAAMS,MAAsBT,EAAMS,MAAQ,QACnDP,EAAEE,aAAgBF,EAAEG,aACvBH,EAAEG,YAAa,EACfH,EAAEE,aAAc,GAElBV,EAAMgB,SAAU,EAEhBhB,EAAMiB,KAAOC,EAAQV,GAErBR,EAAMmB,QAAUX,EAAEE,YAAc,aAAc,EAC9CV,EAAMoB,OAASZ,EAAEG,WACjBX,EAAMqB,OAAS,GAAIC,OAAM,IACzBt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7C,IAAoB,OAAhBL,EAAEP,WAAsBO,EAAEP,aAAc,EAAO,CAKjD,GAAI8C,GAAMF,EAAIG,UAAuC,IAA1BH,EAAII,oBAG3BC,EAAY,GAAIJ,MAAKC,EAAO,KAAUvC,EAAEP,UAC5C,QACEkD,IAAKD,EAAUE,WACfC,KAAMH,EAAUI,aAChBC,KAAML,EAAUM,aAChBvC,KAAMiC,GAIR,OACEC,IAAKN,EAAIO,WACTC,KAAMR,EAAIS,aACVC,KAAMV,EAAIW,aACVvC,KAAM4B,GAKZ,QAASnB,GAAS+B,EAAGC,EAAQC,EAAU7D,GACrC,MAAOA,GAAQ,QAAQ2D,EAAExC,KAAMyC,EAAQC,GAhJzCC,QAAQC,OAAO,eACZC,UAAU,iBAAkB,YAAa,UACxC,SAASjE,EAAWC,GAClB,MAAOF,GAAMC,EAAWC","file":"angular-clock.min.js","sourcesContent":["(function() {\r\n 'use strict';\r\n\r\n /* */\r\n var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];\r\n var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];\r\n\r\n angular.module('ds.clock', [])\r\n .directive('dsWidgetClock', ['$interval', '$filter',\r\n function($interval, $filter) {\r\n return clock($interval, $filter);\r\n }\r\n ]);\r\n\r\n function clock($interval, $filter) {\r\n return {\r\n restrict: 'EA',\r\n scope: {\r\n gmtOffset: '=gmtOffset',\r\n digitalFormat: '=digitalFormat'\r\n },\r\n template: '
{{digital}}
{{gmtInfo}}
',\r\n link: function(scope, element, attrs) {\r\n var format, // date format\r\n stopTime; // so that we can cancel the time updates\r\n var o = {}; //angular.copy(defaults)\r\n var gmtOffset = scope.gmtOffset;\r\n var digitalFormat = scope.digitalFormat !== undefined ? scope.digitalFormat : 'HH:mm:ss';\r\n //o.gmtOffset = (gmtOffset !== undefined && gmtOffset !== null) ? parseFloat(gmtOffset) : false;\r\n //o.showSecs = attrs.hideSecs !== undefined ? false : true;\r\n //o.showAmPm = attrs.showAmPm !== undefined ? true : false;\r\n o.showDigital = attrs.showDigital !== undefined ? true : false;\r\n o.showAnalog = attrs.showAnalog !== undefined ? true : false;\r\n o.showGmtInfo = attrs.showGmtInfo !== undefined ? true : false;\r\n o.startTime = parseInt(attrs.startTime, 10); // ms\r\n scope.theme = attrs.theme !== undefined ? attrs.theme : 'light';\r\n if (!o.showDigital && !o.showAnalog) {\r\n o.showAnalog = true;\r\n o.showDigital = true;\r\n }\r\n scope.gmtInfo = false;\r\n\r\n scope.date = getDate(o);\r\n\r\n scope.digital = o.showDigital ? 'Loading..' : false;\r\n scope.analog = o.showAnalog;\r\n scope.majors = new Array(12);\r\n scope.minors = new Array(60);\r\n var date = null;\r\n var tick = function() {\r\n if (!isNaN(o.startTime)) {\r\n o.startTime = o.startTime + 1000;\r\n }\r\n date = getDate(o);\r\n scope.date = date;\r\n if (o.showDigital) {\r\n scope.digital = timeText(date, digitalFormat, gmtOffset, $filter);\r\n }\r\n };\r\n\r\n stopTime = $interval(tick, 1000);\r\n // watch the expression, and update the UI on change.\r\n scope.$watch('gmtOffset', function(value) {\r\n gmtOffset = value;\r\n o.gmtOffset = (gmtOffset !== undefined && gmtOffset !== null) ? getGMTbase100(gmtOffset) : false;\r\n if (o.showGmtInfo && o.gmtOffset !== false) {\r\n scope.gmtInfo = getGMTText(o.gmtOffset);\r\n }\r\n tick();\r\n });\r\n /*scope.$watch('digitalFormat', function(value) {\r\n digitalFormat = value;\r\n });*/\r\n // listen on DOM destroy (removal) event, and cancel the next UI update\r\n // to prevent updating time after the DOM element was removed.\r\n element.on('$destroy', function() {\r\n $interval.cancel(stopTime);\r\n stopTime = null;\r\n });\r\n\r\n }\r\n };\r\n }\r\n\r\n function getGMTbase100(offset) {\r\n offset = parseFloat(offset);\r\n var f = offset > 0 ? Math.floor(offset) : Math.ceil(offset),\r\n s = (offset % 1) / 0.6;\r\n\r\n return f + s;\r\n\r\n }\r\n\r\n function getGMTbase60(offset) {\r\n var f = offset > 0 ? Math.floor(offset) : Math.ceil(offset),\r\n s = ((offset > 0 ? offset : offset * -1) % 1) * 60;\r\n return f + s;\r\n\r\n }\r\n\r\n function getGMTText(offset) {\r\n\r\n var f = offset > 0 ? Math.floor(offset) : Math.ceil(offset),\r\n s = Math.round(((offset > 0 ? offset : offset * -1) % 1) * 60);\r\n\r\n return 'GMT' + (offset === 0 ? '' : ((offset > 0 ? ' +' : ' ') + lpad(f) + '.' + rpad(s).substring(0, 2)));\r\n\r\n }\r\n\r\n function lpad(num) {\r\n if (num < 0) {\r\n return (num > -10 ? '-0' : '-') + (num * -1);\r\n } else {\r\n return (num < 10 ? '0' : '') + num;\r\n }\r\n\r\n }\r\n\r\n function rpad(num) {\r\n return num + (num < 10 ? '0' : '');\r\n }\r\n // Checkfor offset and get correct time\r\n function getDate(o) {\r\n var now = (!isNaN(o.startTime)) ? new Date(o.startTime) : new Date();\r\n if (o.gmtOffset !== null && o.gmtOffset !== false) {\r\n // Use GMT + gmtOffset\r\n // convert to msec\r\n // add local time zone offset\r\n // get UTC time in msec\r\n var utc = now.getTime() + (now.getTimezoneOffset() * 60000);\r\n // create new Date object for different city\r\n // using supplied offset\r\n var offsetNow = new Date(utc + (3600000 * o.gmtOffset));\r\n return {\r\n hrs: offsetNow.getHours(),\r\n mins: offsetNow.getMinutes(),\r\n secs: offsetNow.getSeconds(),\r\n date: offsetNow\r\n };\r\n } else {\r\n // Use local time\r\n return {\r\n hrs: now.getHours(),\r\n mins: now.getMinutes(),\r\n secs: now.getSeconds(),\r\n date: now\r\n };\r\n }\r\n }\r\n\r\n function timeText(d, format, timezone, $filter) {\r\n return $filter('date')(d.date, format, timezone);\r\n /*return '' +\r\n (o.showAmPm ? ((d.hrs % 12) === 0 ? 12 : (d.hrs % 12)) : d.hrs) + ':' +\r\n lpad(d.mins) +\r\n (o.showSecs ? ':' + lpad(d.secs) : '') +\r\n (o.showAmPm ? (d.hrs < 12 ? ' AM' : ' PM') : '');*/\r\n }\r\n\r\n})();\r\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["angular-clock.min.js"],"names":["clock","$interval","$filter","restrict","scope","gmtOffset","digitalFormat","showDigital","showAnalog","startTime","theme","template","link","element","attrs","stopTime","o","undefined","showGmtInfo","parseInt","themeClass","gmtInfo","date","getDate","digital","analog","majors","Array","minors","tick","isNaN","timeText","$watch","value","getGMTbase100","getGMTText","old","on","cancel","offset","parseFloat","f","Math","floor","ceil","s","round","lpad","rpad","substring","num","now","Date","utc","getTime","getTimezoneOffset","offsetNow","hrs","getHours","mins","getMinutes","secs","getSeconds","d","format","timezone","angular","module","directive"],"mappings":"CAAA,WACE,YAgBA,SAASA,GAAMC,EAAWC,GACxB,OACEC,SAAU,KACVC,OACEC,UAAW,aACXC,cAAe,iBACfC,YAAa,eACbC,WAAY,cACZC,UAAW,aACXC,MAAO,UAETC,SAAU,4gCACVC,KAAM,SAASR,EAAOS,EAASC,GAC7B,GACEC,GACEC,KACAX,EAAYD,EAAMC,UAClBC,EAAgBF,EAAME,cAAgBF,EAAME,cAAgB,UAChEU,GAAET,YAAmC,MAArBH,EAAMG,YAAsBH,EAAMG,YAAoCU,SAAtBH,EAAMP,aAA4B,GAAO,EACzGS,EAAER,WAAiC,MAApBJ,EAAMI,WAAqBJ,EAAMI,WAAkCS,SAArBH,EAAMN,YAA2B,GAAO,EACrGQ,EAAEE,YAAoCD,SAAtBH,EAAMI,aAA4B,GAAO,EACzDF,EAAEP,UAAYU,SAASf,EAAMK,UAAW,IACxCL,EAAMgB,WAAahB,EAAMM,MAAQN,EAAMM,MAAQI,EAAMJ,MAAQI,EAAMJ,MAAQ,QACtEM,EAAET,aAAgBS,EAAER,aACvBQ,EAAER,YAAa,EACfQ,EAAET,aAAc,GAElBH,EAAMiB,SAAU,EAEhBjB,EAAMkB,KAAOC,EAAQP,GAErBZ,EAAMoB,QAAUR,EAAET,YAAc,aAAc,EAC9CH,EAAMqB,OAAST,EAAER,WACjBJ,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AKI,OAAQP,EAAS,EAAIA,EAAkB,GAATA,GAAe,EAAK,GAE7D,OAAO,OAAoB,IAAXA,EAAe,IAAOA,EAAS,EAAI,KAAO,KAAOQ,EAAKN,GAAK,IAAMO,EAAKH,GAAGI,UAAU,EAAG,IAIxG,QAASF,GAAKG,GACZ,MAAU,GAANA,GACMA,EAAM,IAAM,KAAO,KAAc,GAANA,GAErB,GAANA,EAAW,IAAM,IAAMA,EAKnC,QAASF,GAAKE,GACZ,MAAOA,IAAa,GAANA,EAAW,IAAM,IAGjC,QAAS3B,GAAQP,GACf,GAAImC,GAAQrB,MAAMd,EAAEP,WAAsC,GAAI2C,MAA5B,GAAIA,MAAKpC,EAAEP,UAC7C,IAAoB,OAAhBO,EAAEX,WAAsBW,EAAEX,aAAc,EAAO,CAKjD,GAAIgD,GAAMF,EAAIG,UAAuC,IAA1BH,EAAII,oBAG3BC,EAAY,GAAIJ,MAAKC,EAAO,KAAUrC,EAAEX,UAC5C,QACEoD,IAAKD,EAAUE,WACfC,KAAMH,EAAUI,aAChBC,KAAML,EAAUM,aAChBxC,KAAMkC,GAIR,OACEC,IAAKN,EAAIO,WACTC,KAAMR,EAAIS,aACVC,KAAMV,EAAIW,aACVxC,KAAM6B,GAKZ,QAASpB,GAASgC,EAAGC,EAAQC,EAAU/D,GACrC,MAAOA,GAAQ,QAAQ6D,EAAEzC,KAAM0C,EAAQC,GAtKzCC,QAAQC,OAAO,eACZC,UAAU,iBAAkB,YAAa,UACxC,SAASnE,EAAWC,GAClB,MAAOF,GAAMC,EAAWC","file":"angular-clock.min.js","sourcesContent":["(function() {\r\n 'use strict';\r\n\r\n /**\r\n * Usage pattern\r\n * \r\n */\r\n var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];\r\n var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];\r\n\r\n angular.module('ds.clock', [])\r\n .directive('dsWidgetClock', ['$interval', '$filter',\r\n function($interval, $filter) {\r\n return clock($interval, $filter);\r\n }\r\n ]);\r\n\r\n function clock($interval, $filter) {\r\n return {\r\n restrict: 'EA',\r\n scope: {\r\n gmtOffset: '=gmtOffset',\r\n digitalFormat: '=digitalFormat',\r\n showDigital: '=showDigital',\r\n showAnalog: '=showAnalog',\r\n startTime: '=startTime',\r\n theme: '=theme'\r\n },\r\n template: '
{{digital}}
{{gmtInfo}}
',\r\n link: function(scope, element, attrs) {\r\n var format, // date format\r\n stopTime; // so that we can cancel the time updates\r\n var o = {};\r\n var gmtOffset = scope.gmtOffset;\r\n var digitalFormat = scope.digitalFormat ? scope.digitalFormat : 'HH:mm:ss';\r\n o.showDigital = scope.showDigital != null ? scope.showDigital : attrs.showDigital !== undefined ? true : false;\r\n o.showAnalog = scope.showAnalog != null ? scope.showAnalog : attrs.showAnalog !== undefined ? true : false;\r\n o.showGmtInfo = attrs.showGmtInfo !== undefined ? true : false;\r\n o.startTime = parseInt(scope.startTime, 10); // ms\r\n scope.themeClass = scope.theme ? scope.theme : attrs.theme ? attrs.theme : 'light';\r\n if (!o.showDigital && !o.showAnalog) {\r\n o.showAnalog = true;\r\n o.showDigital = true;\r\n }\r\n scope.gmtInfo = false;\r\n\r\n scope.date = getDate(o);\r\n\r\n scope.digital = o.showDigital ? 'Loading..' : false;\r\n scope.analog = o.showAnalog;\r\n scope.majors = new Array(12);\r\n scope.minors = new Array(60);\r\n var date = null;\r\n var tick = function() {\r\n if (!isNaN(o.startTime)) {\r\n o.startTime = o.startTime + 1000;\r\n }\r\n date = getDate(o);\r\n scope.date = date;\r\n if (o.showDigital) {\r\n scope.digital = timeText(date, digitalFormat, gmtOffset, $filter);\r\n }\r\n };\r\n\r\n stopTime = $interval(tick, 1000);\r\n // watch the expression, and update the UI on change.\r\n scope.$watch('gmtOffset', function(value, old) {\r\n \r\n gmtOffset = value;\r\n o.gmtOffset = (gmtOffset != null) ? getGMTbase100(gmtOffset) : false;\r\n if (o.showGmtInfo && o.gmtOffset !== false) {\r\n scope.gmtInfo = getGMTText(o.gmtOffset);\r\n }\r\n \r\n tick();\r\n });\r\n scope.$watch('digitalFormat', function(value, old) {\r\n if(value != old){\r\n digitalFormat = value;\r\n }\r\n });\r\n scope.$watch('showDigital', function(value, old) {\r\n if(value != old){\r\n o.showDigital = value;\r\n scope.digital = o.showDigital ? 'Loading..' : false;;\r\n }\r\n });\r\n scope.$watch('showAnalog', function(value, old) {\r\n if(value != old){\r\n o.showAnalog = value;\r\n scope.analog = value;\r\n }\r\n });\r\n scope.$watch('theme', function(value, old) {\r\n if(value != old){\r\n scope.themeClass = value ? value : attrs.theme ? attrs.theme : 'light';\r\n }\r\n });\r\n // listen on DOM destroy (removal) event, and cancel the next UI update\r\n // to prevent updating time after the DOM element was removed.\r\n element.on('$destroy', function() {\r\n $interval.cancel(stopTime);\r\n stopTime = null;\r\n });\r\n\r\n }\r\n };\r\n }\r\n\r\n function getGMTbase100(offset) {\r\n offset = parseFloat(offset);\r\n var f = offset > 0 ? Math.floor(offset) : Math.ceil(offset),\r\n s = (offset % 1) / 0.6;\r\n\r\n return f + s;\r\n\r\n }\r\n\r\n function getGMTbase60(offset) {\r\n var f = offset > 0 ? Math.floor(offset) : Math.ceil(offset),\r\n s = ((offset > 0 ? offset : offset * -1) % 1) * 60;\r\n return f + s;\r\n\r\n }\r\n\r\n function getGMTText(offset) {\r\n\r\n var f = offset > 0 ? Math.floor(offset) : Math.ceil(offset),\r\n s = Math.round(((offset > 0 ? offset : offset * -1) % 1) * 60);\r\n\r\n return 'GMT' + (offset === 0 ? '' : ((offset > 0 ? ' +' : ' ') + lpad(f) + '.' + rpad(s).substring(0, 2)));\r\n\r\n }\r\n\r\n function lpad(num) {\r\n if (num < 0) {\r\n return (num > -10 ? '-0' : '-') + (num * -1);\r\n } else {\r\n return (num < 10 ? '0' : '') + num;\r\n }\r\n\r\n }\r\n\r\n function rpad(num) {\r\n return num + (num < 10 ? '0' : '');\r\n }\r\n // Checkfor offset and get correct time\r\n function getDate(o) {\r\n var now = (!isNaN(o.startTime)) ? new Date(o.startTime) : new Date();\r\n if (o.gmtOffset !== null && o.gmtOffset !== false) {\r\n /*Use GMT + gmtOffset\r\n convert to msec\r\n add local time zone offset\r\n get UTC time in msec*/\r\n var utc = now.getTime() + (now.getTimezoneOffset() * 60000);\r\n // create new Date object for different city\r\n // using supplied offset\r\n var offsetNow = new Date(utc + (3600000 * o.gmtOffset));\r\n return {\r\n hrs: offsetNow.getHours(),\r\n mins: offsetNow.getMinutes(),\r\n secs: offsetNow.getSeconds(),\r\n date: offsetNow\r\n };\r\n } else {\r\n // Use local time\r\n return {\r\n hrs: now.getHours(),\r\n mins: now.getMinutes(),\r\n secs: now.getSeconds(),\r\n date: now\r\n };\r\n }\r\n }\r\n\r\n function timeText(d, format, timezone, $filter) {\r\n return $filter('date')(d.date, format, timezone);\r\n }\r\n\r\n})();\r\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/examples/app.js b/examples/app.js index 8a8cfb5..b14921b 100644 --- a/examples/app.js +++ b/examples/app.js @@ -11,13 +11,17 @@ app.controller('HeadCtrl', ['$scope', function($scope) { + $scope.theme = 'blue-light'; + $scope.digital = true; } ]); app.controller('BaseCtrl', ['$scope', function($scope) { - $scope.gmtValue = 5.45; - $scope.startTimeValue = 1430990693334; + $scope.gmtValue = 5.45; + $scope.startTimeValue = 1430990693334; + $scope.format = 'dd-MMM-yyyy hh:mm:ss a'; + } ]); diff --git a/examples/index.html b/examples/index.html index 0231e2e..6c31820 100644 --- a/examples/index.html +++ b/examples/index.html @@ -55,7 +55,13 @@
- + + + show digital
@@ -104,14 +110,16 @@

Options

There are several options that you can set as attributes on the directive element(can use other angular flavors like data-*, ng-attr-*, x-* also)

  1. start-time : init clock with specific time in milliseconds, (default: undefined)
  2. -
  3. digital-format : digital clock format in angular date filter format (default: 'HH-mm-ss'). Pass as string enclosed in single quate
  4. +
  5. digital-format : digital clock format in angular date filter format (default: 'HH-mm-ss'). Pass as string enclosed in single quote or bound to a scope variable
  6. gmt-offset : shows time for the given GMT offset in clock, (default: false, shows local time) example: India -> 5.30, Singapore -> 8 , venezula -> -4.30, Nepal -> 5.45
  7. show-digital: shows digital clock, (default: true if both show-analog &show-digital are not set)
  8. show-analog : shows analog clock, (default: true if both show-analog &show-digital are not set)
  9. show-gmt-info : shows GMT offset value, (default: false) shows only if gmt-offset attribute is set
  10. theme : analog clockface theme, (default: light)
-

All clocks are responsive and reactive and will update automatically when data changes.

+

All clocks are responsive and reactive and will update automatically when data changes. start-time, digital-format, + and gmt-offset are bound attributes and hence need to be set in the scope or using gmt-offset="'5.3'" format with extra single quotes.

+

show-digital, show-analog and theme can be used as bound attributes or as normal attributes