Browse Source

Whitespace fixing

Added template validate() function
pull/24/head
Jordan 7 years ago
parent
commit
0c1d82ad46
2 changed files with 38 additions and 27 deletions
  1. +10
    -0
      models/template.go
  2. +28
    -27
      static/js/app/app.js

+ 10
- 0
models/template.go View File

@ -11,6 +11,16 @@ type Template struct {
ModifiedDate time.Time `json:"modified_date"`
}
func (t *Template) Validate() (string, bool) {
switch {
case t.Name == "":
return "Template Name not specified", false
case t.Text == "" && t.Html == "":
return "Need to specify at least plaintext or HTML format", false
}
return "", true
}
type UserTemplate struct {
UserId int64 `json:"-"`
TemplateId int64 `json:"-"`

+ 28
- 27
static/js/app/app.js View File

@ -18,7 +18,7 @@ app.config(function($routeProvider) {
templateUrl: 'js/app/partials/campaign_results.html',
controller: 'CampaignResultsCtrl'
})
.when('/users', {
templateUrl: 'js/app/partials/users.html',
controller: 'GroupCtrl'
@ -38,31 +38,32 @@ app.config(function($routeProvider) {
// Example provided by http://docs.angularjs.org/api/ng/type/ngModel.NgModelController
app.directive('contenteditable', function() {
return {
restrict: 'A', // only activate on element attribute
require: '?ngModel', // get a hold of NgModelCtrl
link: function(scope, element, attrs, ngModel) {
if(!ngModel) return; // do nothing if no ng-model
// Specify how UI should be updated
ngModel.$render = function() {
element.html(ngModel.$viewValue || '');
};
// Listen for change events to enable binding
element.on('blur keyup change', function() {
scope.$apply(read);
});
// Write data to the model
function read() {
var html = element.html();
// When we clear the content editable the browser leaves a <br> behind
// If strip-br attribute is provided then we strip this out
if( attrs.stripBr && html == '<br>' ) {
html = '';
}
ngModel.$setViewValue(html);
restrict: 'A', // only activate on element attribute
require: '?ngModel', // get a hold of NgModelCtrl
link: function(scope, element, attrs, ngModel) {
if (!ngModel) return; // do nothing if no ng-model
// Specify how UI should be updated
ngModel.$render = function() {
element.html(ngModel.$viewValue || '');
};
// Listen for change events to enable binding
element.on('blur keyup change', function() {
scope.$apply(read);
});
// Write data to the model
function read() {
var html = element.html();
// When we clear the content editable the browser leaves a <br> behind
// If strip-br attribute is provided then we strip this out
if (attrs.stripBr && html == '<br>') {
html = '';
}
ngModel.$setViewValue(html);
}
}
}
};
});
});

Loading…
Cancel
Save