Neues Initialrelease mit IonicMaterial
This commit is contained in:
34
www/js/shared/controllers.js
Normal file
34
www/js/shared/controllers.js
Normal file
@@ -0,0 +1,34 @@
|
||||
//This is Controller for Dialog box.
|
||||
appControllers.controller('DialogController', function ($scope, $mdDialog, displayOption) {
|
||||
|
||||
//This variable for display wording of dialog.
|
||||
//object schema:
|
||||
//displayOption: {
|
||||
// title: "Confirm to remove all data?",
|
||||
// content: "All data will remove from local storage.",
|
||||
// ok: "Confirm",
|
||||
// cancel: "Close"
|
||||
//}
|
||||
$scope.displayOption = displayOption;
|
||||
|
||||
$scope.cancel = function () {
|
||||
$mdDialog.cancel(); //close dialog.
|
||||
};
|
||||
|
||||
$scope.ok = function () {
|
||||
$mdDialog.hide();//hide dialog.
|
||||
};
|
||||
});// End Controller for Dialog box.
|
||||
|
||||
//Controller for Toast.
|
||||
appControllers.controller('toastController', function ($scope, displayOption) {
|
||||
|
||||
//this variable for display wording of toast.
|
||||
//object schema:
|
||||
// displayOption: {
|
||||
// title: "Data Saved !"
|
||||
//}
|
||||
|
||||
$scope.displayOption = displayOption;
|
||||
});// End Controller for Toast.
|
||||
|
||||
25
www/js/shared/directives.js
Normal file
25
www/js/shared/directives.js
Normal file
@@ -0,0 +1,25 @@
|
||||
//Directive numbersOnly :
|
||||
//Use for change input to have ability accept only number.
|
||||
//Example : <input ng-model="contract.age" numbers-only type="tel">
|
||||
//
|
||||
appControllers.directive('numbersOnly', function () {
|
||||
return {
|
||||
require: 'ngModel',
|
||||
link: function (scope, element, attr, ngModelCtrl) {
|
||||
function fromUser(text) {
|
||||
if (text) {
|
||||
var transformedInput = text.replace(/[^0-9]/g, '');
|
||||
|
||||
if (transformedInput !== text) {
|
||||
ngModelCtrl.$setViewValue(transformedInput);
|
||||
ngModelCtrl.$render();
|
||||
}
|
||||
return transformedInput;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
ngModelCtrl.$parsers.push(fromUser);
|
||||
}
|
||||
};
|
||||
});// End Directive numbersOnly.
|
||||
33
www/js/shared/filter.js
Normal file
33
www/js/shared/filter.js
Normal file
@@ -0,0 +1,33 @@
|
||||
//Filter epochToDate :
|
||||
//Use for convert epoch date format to default date format.
|
||||
//Example :
|
||||
//<p>{{item.createdAt |epochToDate | date:"short"}}</p>
|
||||
appControllers.filter('epochToDate', function ($filter) {
|
||||
return function (input) {
|
||||
return new Date(Date(input));
|
||||
};
|
||||
});// End Filter epochToDate.
|
||||
|
||||
//Filter numberSuffix :
|
||||
//Use for convert number to have suffix 1,000 to 1K.
|
||||
//Example :
|
||||
//{{item.likes.summary.total_count | numberSuffix}}
|
||||
//
|
||||
appControllers.filter('numberSuffix', function () {
|
||||
return function (input) {
|
||||
var exp;
|
||||
var suffixes = ['k', 'M', 'G', 'T', 'P', 'E'];
|
||||
|
||||
if (window.isNaN(input)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (input < 1000) {
|
||||
return input;
|
||||
}
|
||||
|
||||
exp = Math.floor(Math.log(input) / Math.log(1000));
|
||||
|
||||
return (input / Math.pow(1000, exp)).toFixed(1) + suffixes[exp - 1];
|
||||
}
|
||||
});// End Filter numberSuffix.
|
||||
Reference in New Issue
Block a user