Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
229 changes: 123 additions & 106 deletions demo/demo-controller.js
Original file line number Diff line number Diff line change
@@ -1,109 +1,126 @@
/*globals angular, moment, $ */
(function () {
'use strict';

angular
.module('demo.demoController', [])
.controller('demoController', demoController);

demoController.$inject = ['$scope', '$log'];

function demoController($scope, $log) {

var validViews = ['year', 'month', 'day', 'hour', 'minute'];
var selectable = true;

$scope.controllerName = 'demoController';

/* Bindable functions
-----------------------------------------------*/
$scope.beforeRender = beforeRender;
$scope.changeConfig = changeConfig;
$scope.checkboxOnTimeSet = checkboxOnTimeSet;
$scope.configFunction = configFunction;
$scope.getLocale = getLocale;
$scope.guardianOnSetTime = guardianOnSetTime;
$scope.inputOnTimeSet = inputOnTimeSet;
$scope.renderOnBeforeRender = renderOnBeforeRender;
$scope.renderOnClick = renderOnClick;
$scope.setLocale = setLocale;

moment.locale('en');

$scope.config = {
datetimePicker: {
startView: 'year'
}
};

$scope.data = {
guardians: [
{
name: 'Peter Quill',
dob: null
},
{
name: 'Groot',
dob: null
}
]
};

$scope.config = {
configureOnConfig: {
startView: 'year',
configureOn: 'config-changed'
},
renderOnConfig: {
startView: 'year',
renderOn: 'valid-dates-changed'
}
};

function checkboxOnTimeSet() {
$scope.data.checked = false;
}

function inputOnTimeSet(newDate) {
// If you are not using jQuery or bootstrap.js,
// this will throw an error.
// However, can write this function to take any
// action necessary once the user has selected a
// date/time using the picker
$log.info(newDate);
$('#dropdown3').dropdown('toggle');
}

function getLocale() {
return moment.locale();
}

function setLocale(newLocale) {
moment.locale(newLocale);
}

angular.module('demo.demoController', [])
.controller('demoController', [
'$scope',
'$log',
function ($scope, $log) {
'use strict';
$scope.controllerName = 'demoController';

moment.locale('en');

$scope.data = {
guardians: [
{
name: 'Peter Quill',
dob: null
},
{
name: 'Groot',
dob: null
}
]
};

$scope.checkboxOnTimeSet = function () {
$scope.data.checked = false;
};

$scope.inputOnTimeSet = function (newDate) {
// If you are not using jQuery or bootstrap.js,
// this will throw an error.
// However, can write this function to take any
// action necessary once the user has selected a
// date/time using the picker
$log.info(newDate);
$('#dropdown3').dropdown('toggle');
};

$scope.getLocale = function () {
return moment.locale();
};

$scope.setLocale = function (newLocale) {
moment.locale(newLocale);
};


$scope.guardianOnSetTime = function ($index, guardian, newDate, oldDate) {
$log.info($index);
$log.info(guardian.name);
$log.info(newDate);
$log.info(oldDate);
angular.element('#guardian' + $index).dropdown('toggle');
};

$scope.beforeRender = function ($dates) {
var index = Math.ceil($dates.length / 2);
$log.info(index);
$dates[index].selectable = false;
};

$scope.config = {
datetimePicker: {
startView: 'year'
}
};

$scope.configFunction = function configFunction() {
return {startView: 'month'};
};

$scope.config = {
configureOnConfig: {
startView: 'year',
configureOn: 'config-changed'
},
renderOnConfig: {
startView: 'year',
renderOn: 'valid-dates-changed'
}
};

var validViews = ['year', 'month', 'day', 'hour', 'minute'];

$scope.changeConfig = function changeConfig() {
var newIndex = validViews.indexOf($scope.config.configureOnConfig.startView) + 1;
console.log(newIndex);
if (newIndex >= validViews.length) {
newIndex = 0;
}
$scope.config.configureOnConfig.startView = validViews[newIndex];
$scope.$broadcast('config-changed');
};

var selectable = true;

$scope.renderOnBeforeRender = function ($dates) {
angular.forEach($dates, function (dateObject) {
dateObject.selectable = selectable;
});
};

$scope.renderOnClick = function renderOnClick() {
selectable = (!selectable);
$scope.$broadcast('valid-dates-changed');
};
function guardianOnSetTime($index, guardian, newDate, oldDate) {
$log.info($index);
$log.info(guardian.name);
$log.info(newDate);
$log.info(oldDate);
angular.element('#guardian' + $index).dropdown('toggle');
};

function beforeRender($dates) {
var index = Math.ceil($dates.length / 2);
$log.info(index);
$dates[index].selectable = false;
};

function configFunction() {
return {startView: 'month'};
}
]);

function changeConfig() {
var newIndex = validViews.indexOf($scope.config.configureOnConfig.startView) + 1;
console.log(newIndex);
if (newIndex >= validViews.length) {
newIndex = 0;
}
$scope.config.configureOnConfig.startView = validViews[newIndex];
$scope.$broadcast('config-changed');
}

function renderOnBeforeRender($dates) {
angular.forEach($dates, function (dateObject) {
dateObject.selectable = selectable;
});
}

function renderOnClick() {
selectable = (!selectable);
$scope.$broadcast('valid-dates-changed');
}

}

})();