Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Wtower committed Nov 10, 2016
0 parents commit 4f7818e
Show file tree
Hide file tree
Showing 50 changed files with 967 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
coverage
.idea/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 George Karakostas <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ng-gentelella
=============

Under initial development
21 changes: 21 additions & 0 deletions gentelella/form-field-checkbox/form-field-checkbox.component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Created by gkarak on 30/9/2016.
*
* Render a gentelella checkbox form field.
*/

angular
.module('formFieldCheckbox')
.component('formFieldCheckbox', {
templateUrl: 'javascripts/gentelella/form-field-checkbox/form-field-checkbox.template.html',
bindings: {
fieldId: '@',
fieldLabel: '@',
fieldPlaceholder: '@',
fieldWidth: '@',
fieldLabelWidth: '@',
onChange: '&',
fieldValue: '='
},
transclude: true
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/**
* Created by gkarak on 30/9/2016.
*/
6 changes: 6 additions & 0 deletions gentelella/form-field-checkbox/form-field-checkbox.module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* Created by gkarak on 30/9/2016.
*/

angular.module('formFieldCheckbox', [
]);
12 changes: 12 additions & 0 deletions gentelella/form-field-checkbox/form-field-checkbox.template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<div class="form-group">
<label class="control-label col-md-{{ $ctrl.fieldLabelWidth || 3 }} col-sm-{{ $ctrl.fieldLabelWidth || 3 }} col-xs-12">
{{ $ctrl.fieldLabel }}</label>
<div class="col-md-{{ $ctrl.fieldWidth || 6 }} col-sm-{{ $ctrl.fieldWidth || 6 }} col-xs-12">
<div class="checkbox" ng-transclude>
<label>
<input type="checkbox" id="{{ $ctrl.fieldId }}" ng-model="$ctrl.fieldValue" ng-change="$ctrl.onChange()">
{{ $ctrl.fieldPlaceholder }}
</label>
</div>
</div>
</div>
60 changes: 60 additions & 0 deletions gentelella/form-field-image/form-field-image.component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* Created by gkarak on 30/9/2016.
*
* Render an image ng-upload form field.
*/

angular
.module('formFieldImage')
.component('formFieldImage', {
templateUrl: 'javascripts/gentelella/form-field-image/form-field-image.template.html',
bindings: {
fieldId: '@',
fieldLabel: '@',
fieldRequired: '@',
fieldWidth: '@',
fieldLabelWidth: '@',
fieldMediaUrl: '@',
fieldTitle: '@',
fieldData: '<',
fieldValue: '='
},
transclude: true,
controller: ['Upload',
function FormFieldTextController(Upload) {
var self = this;

self.$onInit = function () {
// Otherwise illegal invocation error on upload
self.data = self.fieldData;
};

self.upload = function(file) {
Upload.upload({
url: 'api/uploads',
method: 'POST',
data: self.data,
file: file
}).then(function (resp) {
new PNotify({
title: 'Image uploaded',
text: 'Submit the form to update changes.',
type: 'success',
styling: 'bootstrap3'
});
self.fieldValue = resp.data.upload;
}, function (error) {
new PNotify({
title: 'Image not uploaded',
text: error.data,
type: 'error',
styling: 'bootstrap3'
});
console.log(error);
}, function (evt) {
self.progress = parseInt(100.0 * evt.loaded / evt.total);
});
};
}
]
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/**
* Created by gkarak on 30/9/2016.
*/
7 changes: 7 additions & 0 deletions gentelella/form-field-image/form-field-image.module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Created by gkarak on 30/9/2016.
*/

angular.module('formFieldImage', [
'ngFileUpload'
]);
27 changes: 27 additions & 0 deletions gentelella/form-field-image/form-field-image.template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<div class="form-group">
<label class="control-label col-md-{{ $ctrl.fieldLabelWidth || 3 }} col-sm-{{ $ctrl.fieldLabelWidth || 3 }} col-xs-12"
for="{{ $ctrl.fieldId }}">
{{ $ctrl.fieldLabel || 'Image' }} <span ng-if="$ctrl.fieldRequired" class="required">*</span>
</label>
<div class="col-md-{{ $ctrl.fieldWidth || 9 }} col-sm-{{ $ctrl.fieldWidth || 9 }} col-xs-12">
<p class="thumbnail" ng-transclude>
<span ng-if="!$ctrl.fieldValue">No image uploaded. Select a file to upload below, <br>
and then submit the form to update.</span>
<img ng-if="$ctrl.fieldValue"
ng-src="{{ $ctrl.fieldMediaUrl }}/{{ $ctrl.fieldValue }}"
title="{{ $ctrl.fieldTitle }}"
alt="{{ $ctrl.fieldTitle }}">
</p>
<input type="file"
id="{{ $ctrl.fieldId }}"
class="form-control"
ngf-select="$ctrl.upload($file)"
ngf-accept="'image/*'">
<div class="progress" ng-if="($ctrl.progress > 0) && ($ctrl.progress < 100)">
<div class="progress-bar progress-bar-success"
data-transitiongoal="{{ $ctrl.progress }}"
aria-valuenow="{{ $ctrl.progress }}"
ng-attr-style="width: {{ $ctrl.progress }}%"></div>
</div>
</div>
</div>
32 changes: 32 additions & 0 deletions gentelella/form-field-select/form-field-select.component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Created by gkarak on 29/9/2016.
*
* Render a gentelella select form field.
* https://docs.angularjs.org/error/$compile/selmulti
*/

angular
.module('formFieldSelect')
.component('formFieldSelect', {
templateUrl: 'javascripts/gentelella/form-field-select/form-field-select.template.html',
bindings: {
fieldId: '@',
fieldLabel: '@',
fieldPlaceholder: '@',
fieldRequired: '@',
fieldWidth: '@',
fieldLabelWidth: '@',
fieldMultiple: '@',
fieldLink: '@',
fieldLinkText: '@',
onChange: '&',
fieldValue: '='
},
transclude: true,
controller: [
function FormFieldSelectController() {
// select2();
// Temporary due to #12
}
]
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/**
* Created by gkarak on 29/9/2016.
*/
6 changes: 6 additions & 0 deletions gentelella/form-field-select/form-field-select.module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* Created by gkarak on 29/9/2016.
*/

angular.module('formFieldSelect', [
]);
34 changes: 34 additions & 0 deletions gentelella/form-field-select/form-field-select.template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<div class="form-group">
<label class="control-label col-md-{{ $ctrl.fieldLabelWidth || 3 }} col-sm-{{ $ctrl.fieldLabelWidth || 3 }} col-xs-12"
for="{{ $ctrl.fieldId }}">
{{ $ctrl.fieldLabel }} <span ng-if="$ctrl.fieldRequired" class="required">*</span>
</label>
<div class="col-md-{{ $ctrl.fieldWidth || 6 }} col-sm-{{ $ctrl.fieldWidth || 6 }} col-xs-12">
<select class="select2 select2-single form-control"
ng-if="!$ctrl.fieldMultiple"
id="{{ $ctrl.fieldId }}"
aria-hidden="true"
data-placeholder="{{ $ctrl.fieldPlaceholder }}"
data-allow-clear="{{ !$ctrl.fieldRequired }}"
ng-required="$ctrl.fieldRequired"
ng-change="$ctrl.onChange()"
ng-model="$ctrl.fieldValue"
ng-transclude>
</select>
<select class="select2 select2-multiple form-control"
ng-if="$ctrl.fieldMultiple"
multiple="multiple"
ng-attr-id="{{ $ctrl.fieldId }}"
aria-hidden="true"
data-placeholder="{{ $ctrl.fieldPlaceholder }}"
data-allow-clear="{{ !$ctrl.fieldRequired }}"
ng-required="$ctrl.fieldRequired"
ng-change="$ctrl.onChange()"
ng-model="$ctrl.fieldValue"
ng-transclude>
</select>
</div>
<div ng-if="$ctrl.fieldLink" class="label-link col-md-1">
<a href="{{ $ctrl.fieldLink }}"><i class="fa fa-external-link-square" title="{{ $ctrl.fieldLinkText }}"></i></a>
</div>
</div>
36 changes: 36 additions & 0 deletions gentelella/form-field-text/form-field-text.component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Created by gkarak on 29/9/2016.
*
* Render a gentelella text form field.
*/

angular
.module('formFieldText')
.component('formFieldText', {
templateUrl: 'javascripts/gentelella/form-field-text/form-field-text.template.html',
bindings: {
fieldId: '@',
fieldType: '@',
fieldName: '@',
fieldLabel: '@',
fieldPlaceholder: '@',
fieldRequired: '@',
fieldWidth: '@',
fieldLabelWidth: '@',
fieldForm: '=',
fieldPattern: '@',
fieldAlert: '@',
onChange: '&',
fieldValue: '='
},
controller: [
function FormFieldTextController() {
var self = this;
self.$onInit = function () {
if (!self.fieldType) self.fieldType = 'text';
// http://stackoverflow.com/questions/28731451/is-it-possible-to-use-ng-pattern-with-a-variable
self.pattern = new RegExp(self.fieldPattern);
}
}
]
});
3 changes: 3 additions & 0 deletions gentelella/form-field-text/form-field-text.component.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/**
* Created by gkarak on 29/9/2016.
*/
6 changes: 6 additions & 0 deletions gentelella/form-field-text/form-field-text.module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* Created by gkarak on 29/9/2016.
*/

angular.module('formFieldText', [
]);
19 changes: 19 additions & 0 deletions gentelella/form-field-text/form-field-text.template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<div class="form-group item"
ng-class="{bad: $ctrl.fieldForm && $ctrl.fieldName && !$ctrl.fieldForm[$ctrl.fieldName].$valid && !$ctrl.fieldForm[$ctrl.fieldName].$untouched}">
<label class="control-label col-md-{{ $ctrl.fieldLabelWidth || 3 }} col-sm-{{ $ctrl.fieldLabelWidth || 3 }} col-xs-12"
for="{{ $ctrl.fieldId }}">
{{ $ctrl.fieldLabel }} <span ng-if="$ctrl.fieldRequired" class="required">*</span>
</label>
<div class="col-md-{{ $ctrl.fieldWidth || 6 }} col-sm-{{ $ctrl.fieldWidth || 6 }} col-xs-12">
<input type="{{ $ctrl.fieldType }}"
id="{{ $ctrl.fieldId }}"
name="{{ $ctrl.fieldName }}"
class="form-control"
placeholder="{{ $ctrl.fieldPlaceholder }}"
ng-required="$ctrl.fieldRequired"
ng-pattern="$ctrl.pattern"
ng-change="$ctrl.onChange()"
ng-model="$ctrl.fieldValue">
</div>
<div ng-if="$ctrl.fieldAlert" class="alert">{{ $ctrl.fieldAlert }}</div>
</div>
45 changes: 45 additions & 0 deletions gentelella/ga-paginate/ga-paginate.component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Created by gkarak on 7/10/2016.
*/

angular
.module('gaPaginate')
.component('gaPaginate', {
templateUrl: 'javascripts/gentelella/ga-paginate/ga-paginate.template.html',
bindings: {
paginateList: '<',
paginateLimit: '=',
paginateSkip: '=',
paginateId: '@'
},
transclude: true,
controller: [
function GaPaginateController() {
var self = this;
self.items = '2';

self.range = function (max) {
var range = [];
for (var i = 0; i < max; i++) range.push(i);
return range;
};

self.paginate = function (page) {
self.page = page || self.page || 1;
self.pages = Math.ceil(self.paginateList.length / self.items);
if (self.page < 1) self.page = 1;
if (self.page > self.pages) self.page = self.pages;
self.to = Math.min(self.page * self.items, self.paginateList.length);
self.from = (self.page * self.items) - self.items;
self.paginateLimit = self.items;
self.paginateSkip = self.from;
};

self.paginate();

self.rePaginate = function () {
self.paginate(Math.ceil(self.from / self.items));
};
}
]
});
3 changes: 3 additions & 0 deletions gentelella/ga-paginate/ga-paginate.component.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/**
* Created by gkarak on 7/10/2016.
*/
6 changes: 6 additions & 0 deletions gentelella/ga-paginate/ga-paginate.module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* Created by gkarak on 7/10/2016.
*/

angular.module('gaPaginate', [
]);
Loading

0 comments on commit 4f7818e

Please sign in to comment.