Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save weirdyang/8f151a99f6c1a37adbd144e4f081e9f5 to your computer and use it in GitHub Desktop.

Select an option

Save weirdyang/8f151a99f6c1a37adbd144e4f081e9f5 to your computer and use it in GitHub Desktop.
Webinar widget - 02 | Added simple widget designer
// SitefinityWebapp\Mvc\Scripts\Webinar\DesignerView-Friendly.js
angular.module('designer')
.controller('FriendlyCtrl', ['$scope', 'propertyService', function ($scope, propertyService) {
$scope.feedback.showLoadingIndicator = true;
// Get widget properies and load them in the controller's scope
propertyService.get()
.then(function (data) {
if (data) {
$scope.properties = propertyService.toAssociativeArray(data.Items);
if ($scope.properties.Start.PropertyValue && !($scope.properties.Start.PropertyValue instanceof Date)) {
var startDate = $scope.properties.Start.PropertyValue;
// This parsing is specific for UK dates. It may be different depending on your website culture.
// Dealing with dates is always a complex matter in the programming :)
$scope.properties.Start.PropertyValue = new Date(startDate.split('/')[2], startDate.split('/')[1] - 1, startDate.split('/')[0]);
}
if ($scope.properties.End.PropertyValue && !($scope.properties.End.PropertyValue instanceof Date)) {
var endDate = $scope.properties.End.PropertyValue;
$scope.properties.End.PropertyValue = new Date(endDate.split('/')[2], endDate.split('/')[1] - 1, endDate.split('/')[0]);
}
}
}, function (data) {
$scope.feedback.showError = true;
if (data) {
$scope.feedback.errorMessage = data.Detail;
}
})
.finally(function () {
$scope.feedback.showLoadingIndicator = false;
});
}]);
@* SitefinityWebapp\Mvc\Views\Webinar\DesignerView.Friendly.cshtml *@
<div>
<label>Webinar title: </label>
<input type="text" ng-model="properties.Title.PropertyValue" />
</div>
<div>
<label>Description: </label>
<input type="text" ng-model="properties.Description.PropertyValue" />
</div>
<div>
<label>Webinar starts at: </label>
<!-- input of type date will not work in IE and Firefox. Use Chrome, or Edge to see the result -->
<input type="date" ng-model="properties.Start.PropertyValue" />
</div>
<div>
<label>Webinar ends at: </label>
<!-- input of type date will not work in IE and Firefox. Use Chrome, or Edge to see the result -->
<input type="date" ng-model="properties.End.PropertyValue" />
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment