summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authorStanislau Wolski <stanislau.wolski@gmail.com>2013-10-28 17:57:28 +0300
committerStanislau Wolski <stanislau.wolski@gmail.com>2013-10-28 17:57:28 +0300
commit7547bd91160ef3a525dfe7c990fefb67212e3ae3 (patch)
treef4fafb42cf91a6f4bf40a1903a3238277f212c13 /js
downloadangular-scheduler-demo-7547bd91160ef3a525dfe7c990fefb67212e3ae3.zip
angular-scheduler-demo-7547bd91160ef3a525dfe7c990fefb67212e3ae3.tar.gz
angular-scheduler-demo-7547bd91160ef3a525dfe7c990fefb67212e3ae3.tar.bz2
[add] initial versionorigin/gh-pages
Diffstat (limited to 'js')
-rw-r--r--js/app.js19
-rw-r--r--js/app.scheduler.js70
2 files changed, 89 insertions, 0 deletions
diff --git a/js/app.js b/js/app.js
new file mode 100644
index 0000000..8e90e54
--- /dev/null
+++ b/js/app.js
@@ -0,0 +1,19 @@
+'use strict';
+
+/* App Module */
+
+var app = angular.module('schedulerApp', [ ]);
+
+app.controller('MainSchedulerCtrl', function($scope) {
+ $scope.events = [
+ { id:1, text:"Task A-12458",
+ start_date: new Date(2013, 10, 12),
+ end_date: new Date(2013, 10, 16) },
+ { id:2, text:"Task A-83473",
+ start_date: new Date(2013, 10, 22 ),
+ end_date: new Date(2013, 10, 24 ) }
+ ];
+
+ $scope.scheduler = { date : new Date(2013,10,1) };
+
+}); \ No newline at end of file
diff --git a/js/app.scheduler.js b/js/app.scheduler.js
new file mode 100644
index 0000000..cd6fc44
--- /dev/null
+++ b/js/app.scheduler.js
@@ -0,0 +1,70 @@
+app.directive('dhxScheduler', function() {
+ return {
+ restrict: 'A',
+ scope: false,
+ transclude: true,
+ template:'<div class="dhx_cal_navline" ng-transclude></div><div class="dhx_cal_header"></div><div class="dhx_cal_data"></div>',
+
+
+
+ link:function ($scope, $element, $attrs, $controller){
+ //default state of the scheduler
+ if (!$scope.scheduler)
+ $scope.scheduler = {};
+ $scope.scheduler.mode = $scope.scheduler.mode || "month";
+ $scope.scheduler.date = $scope.scheduler.date || new Date();
+
+ //watch data collection, reload on changes
+ $scope.$watch($attrs.data, function(collection){
+ scheduler.clearAll();
+ scheduler.parse(collection, "json");
+ }, true);
+
+ //mode or date
+ $scope.$watch(function(){
+ return $scope.scheduler.mode + $scope.scheduler.date.toString();
+ }, function(nv, ov) {
+ var mode = scheduler.getState();
+ if (nv.date != mode.date || nv.mode != mode.mode)
+ scheduler.setCurrentView($scope.scheduler.date, $scope.scheduler.mode);
+ }, true);
+
+ //size of scheduler
+ $scope.$watch(function() {
+ return $element[0].offsetWidth + "." + $element[0].offsetHeight;
+ }, function() {
+ scheduler.setCurrentView();
+ });
+
+ //styling for dhtmlx scheduler
+ $element.addClass("dhx_cal_container");
+
+ //init scheduler
+ scheduler.init($element[0], $scope.scheduler.mode, $scope.scheduler.date);
+ }
+ }
+});
+
+app.directive('dhxTemplate', ['$filter', function($filter){
+ scheduler.aFilter = $filter;
+
+ return {
+ restrict: 'AE',
+ terminal:true,
+
+ link:function($scope, $element, $attrs, $controller){
+ $element[0].style.display = 'none';
+
+ var template = $element[0].innerHTML;
+ template = template.replace(/[\r\n]/g,"").replace(/"/g, "\\\"").replace(/\{\{event\.([^\}]+)\}\}/g, function(match, prop){
+ if (prop.indexOf("|") != -1){
+ var parts = prop.split("|");
+ return "\"+scheduler.aFilter('"+(parts[1]).trim()+"')(event."+(parts[0]).trim()+")+\"";
+ }
+ return '"+event.'+prop+'+"';
+ });
+ var templateFunc = Function('sd','ed','event', 'return "'+template+'"');
+ scheduler.templates[$attrs.dhxTemplate] = templateFunc;
+ }
+ };
+}]); \ No newline at end of file