Neues Initialrelease mit IonicMaterial

This commit is contained in:
Carsten Hilmer
2016-08-22 12:55:52 +02:00
parent 30a5df79aa
commit 45e482b14d
1249 changed files with 305225 additions and 68794 deletions

View File

@@ -0,0 +1,78 @@
<!--View Information-->
<!--View name : Device Information-->
<!--Controller name : deviceInformationCtrl-->
<!--Controller path : www/templates/hardware-connect/device-information/js/controllers.js-->
<!--State name : app.deviceInformation-->
<!--URL : #app/deviceInformation-->
<ion-view title="">
<ion-content scroll="false">
<!--toolbar section-->
<md-toolbar class="bar-subheader md-tall md-primary toolbar-medium toolbar-in-content">
<div>
<h1>
<i class="fa fa-info-circle"></i>
</h1>
<h3> Device Information </h3>
</div>
</md-toolbar> <!--end toolbar section-->
<!--device information section-->
<!--lise section-->
<md-list id="device-information-content" class="fade-in">
<md-list-item class="row">
<div class="col-50 title">
Platform :
</div>
<div class="col-50">
{{deviceInformation.platform}}
</div>
</md-list-item>
<md-divider></md-divider>
<md-list-item class="row">
<div class="col-50 title">
Model :
</div>
<div class="col-50">
{{deviceInformation.model}}
</div>
</md-list-item>
<md-divider></md-divider>
<md-list-item class="row">
<div class="col-50 title">
Version :
</div>
<div class="col-50">
{{deviceInformation.version}}
</div>
</md-list-item>
<md-divider></md-divider>
<md-list-item class="row">
<div class="col-50 title">
Manufacturer :
</div>
<div class="col-50">
{{deviceInformation.manufacturer}}
</div>
</md-list-item>
<md-divider></md-divider>
<md-list-item>
<div class="col">
{{deviceInformation.uuid}}
</div>
</md-list-item>
<md-divider></md-divider>
</md-list>
<!--end lise section-->
<!--end device information section-->
</ion-content>
<!--loading progress-->
<div id="device-information-loading-progress" class="loading-progress fade-in">
<ion-spinner ng-if="!isAndroid" class="progress-circular"></ion-spinner>
<md-progress-circular ng-if="isAndroid" md-mode="indeterminate"></md-progress-circular>
</div><!--end loading progress-->
</ion-view>

View File

@@ -0,0 +1,39 @@
// Controller of device information page.
// It use ionic.Platform.device() for getting device information. It will return object of current device.
// Learn more about ionic.Platform.device():
// http://ionicframework.com/docs/api/utility/ionic.Platform/
appControllers.controller('deviceInformationCtrl', function ($scope, $timeout) {
// initialForm is the first activity in the controller.
// It will initial all variable data and let the function works when page load.
$scope.initialForm = function () {
// $scope.deviceInformation is store device information data.
$scope.deviceInformation = {};
// Loading progress.
$timeout(function () {
if ($scope.isAndroid) {
jQuery('#device-information-loading-progress').show();
}
else {
jQuery('#device-information-loading-progress').fadeIn(700);
}
}, 400);
$timeout(function () {
$scope.deviceInformation = ionic.Platform.device();
jQuery('#device-information-loading-progress').hide();
jQuery('#device-information-content').fadeIn();
}, 1000);
}; // End initialForm.
// getDeviceInformation is for get device information by calling ionic Platform device.
$scope.getDeviceInformation = function () {
$scope.deviceInformation = ionic.Platform.device();
}; // End getDeviceInformation.
$scope.initialForm();
});// End of device information Controller.

View File

@@ -0,0 +1,29 @@
<!--View Information-->
<!--View name : Device Flashlight-->
<!--Controller name : flashLightCtrl-->
<!--Controller path : www/templates/hardware-connect/flash-light/js/controllers.js-->
<!--State name : app.flashLight-->
<!--URL : #app/flashLight-->
<ion-view title="Flash Light">
<!--flash light section-->
<!--flash light icon section-->
<ion-content id="flash-light-content" scroll="false">
<div class="row">
<div id="flash-light-icon" class="col">
<i ng-class="{'flash-light-color' : isTurnOn}" class="fa fa-diamond center-screen icon-flash-light"></i>
</div>
</div><!--end flash light icon section-->
<div class="row">
<!--flash light control section-->
<div id="flash-light-control" class="col">
<p>Devise Flash Light</p>
<a ng-class="{'md-warn' : isTurnOn}" class="md-raised md-primary md-button md-default-theme"
ng-click="flashLight()">
Turn {{isTurnOn == true ? 'OFF' : 'On'}}
</a>
</div><!--end flash light control section-->
</div>
</ion-content><!--end flash light section-->
</ion-view>

View File

@@ -0,0 +1,52 @@
// For using flashlight you have to install $cordovaFlashlight by running the following
// command in your cmd.exe for windows or terminal for mac:
// $ cd your_project_path
// $ ionic plugin remove nl.x-services.plugins.flashlight
// $ ionic plugin add https://github.com/EddyVerbruggen/Flashlight-PhoneGap-Plugin.git
//
// Learn more about $cordovaFlashlight :
// http://ngcordova.com/docs/plugins/flashlight/
//
// Controller of Flashlight page.
appControllers.controller('flashLightCtrl', function ($scope, $cordovaFlashlight, $timeout) {
// initialForm is the first activity in the controller.
// It will initial all variable data and let the function works when page load.
$scope.initialForm = function () {
//$scope.isTurnOn is Flashlight status.
$scope.isTurnOn = false;
//$scope.deviceInformation is getting device platform.
$scope.deviceInformation = ionic.Platform.device();
//If you start your application with flash Light feature.
//You have to add timeout for 2 sec before run it.
}; // End initialForm.
// flashLight for turn on and off flashLight.
$scope.flashLight = function () {
// turn on flashLight
if ($scope.isTurnOn == false) {
// turn on flashLight for Android
if ($scope.deviceInformation.platform == "Android") {
$scope.isTurnOn = true;
$timeout(function () {
$cordovaFlashlight.switchOn();
}, 50);
}
// turn on flashLight for IOS
else {
$scope.isTurnOn = true;
$cordovaFlashlight.switchOn();
}
} // End turn on flashLight.
// turn off flashLight.
else {
$scope.isTurnOn = false;
$cordovaFlashlight.switchOff();
}// End turn off flashLight.
};// End flashLight.
$scope.initialForm();
});// End of Flashlight Controller.

View File

@@ -0,0 +1,61 @@
<!--View Information-->
<!--View name : Device Image Picker-->
<!--Controller name : imagePickerCtrl-->
<!--Controller path : www/templates/hardware-connect/image-picker/js/controllers.js-->
<!--State name : app.imagePicker-->
<!--URL : #app/imagePicker-->
<ion-view view-title="">
<!--toolbar section-->
<md-toolbar class="bar-subheader md-tall md-primary toolbar-medium">
<div>
<h1>Image Picker</h1>
<h2>Device Image Gallery</h2>
</div>
<a class="md-button md-accent md-fab fab-toolbar-medium"
ng-click="showListBottomSheet($event)"
aria-label="showListBottomSheet">
<i class="fa fa-picture-o"></i>
</a>
</md-toolbar> <!--end toolbar section-->
<!--image picker section-->
<ion-content id="image-picker-content">
<!--list section-->
<md-list>
<md-card ng-repeat="image in imageList">
<img ng-src="{{image}}" class="md-card-image" alt="image{{$index+1}}">
<md-card-content>
<h2 class="md-title">Image {{$index+1}}</h2>
</md-card-content>
</md-card>
</md-list> <!--end list section-->
</ion-content><!--end image picker section-->
<!--angular template section-->
<script type="text/ng-template" id="image-picker-actions-template">
<md-bottom-sheet class="md-list md-has-header">
<h1 class="md-bottom-sheet-header">Image Picker Actions</h1>
<!--list section-->
<md-list>
<md-list-item>
<a class="md-default-theme md-bottom-sheet-list-item"
ng-click="selectImage(1)">
<i class="ion-image"></i>
<span>Single Select</span>
</a>
</md-list-item>
<md-list-item>
<a class="md-default-theme md-bottom-sheet-list-item"
ng-click="selectImage(9999)">
<i class="ion-images"></i>
<span>Multiple Select</span>
</a>
</md-list-item>
</md-list><!--end list section-->
</md-bottom-sheet>
</script><!--end angular template section-->
</ion-view>

View File

@@ -0,0 +1,61 @@
// For using imagePicker you have to install $cordovaImagePicker by running the following
// command in your cmd.exe for windows or terminal for mac:
// $ cd your_project_path
// $ ionic plugin remove com.synconset.imagepicker
// $ ionic plugin add https://github.com/wymsee/cordova-imagePicker.git
//
// Learn more about $cordovaImagePicker :
// http://ngcordova.com/docs/plugins/imagePicker/
//
// Controller of image picker page.
appControllers.controller('imagePickerCtrl', function ($scope, $mdBottomSheet, $cordovaImagePicker) {
// initialForm is the first activity in the controller.
// It will initial all variable data and let the function works when page load.
$scope.initialForm = function () {
// $scope.imageList is for store image data.
$scope.imageList = [];
};// End initialForm.
// selectImage is for select image from mobile gallery
// Parameter :
// limit = limit number that can select images.
$scope.selectImage = function (limit) {
//hide BottomSheet.
$mdBottomSheet.hide();
// Set options for select image from mobile gallery.
var options = {
maximumImagesCount: limit,
width: 300,
height: 300,
quality: 100
}; // End Set options.
// select image by calling $cordovaImagePicker.getPictures(options)
// Parameter :
// options = options of select image.
$cordovaImagePicker.getPictures(options)
.then(function (results) {
// store image data to imageList.
$scope.imageList = [];
for (var i = 0; i < results.length; i++) {
$scope.imageList.push(results[i]);
}
}, function (error) {
console.log(error);
});
};// End selectImage.
// showListBottomSheet for show BottomSheet.
$scope.showListBottomSheet = function ($event) {
$mdBottomSheet.show({
templateUrl: 'image-picker-actions-template',
targetEvent: $event,
scope: $scope.$new(false),
});
}; // End showListBottomSheet.
$scope.initialForm();
});// End of image picker Controller.

View File

@@ -0,0 +1,132 @@
<!--View Information-->
<!--View name : Device Mobile Contract Detail-->
<!--Controller name : mobileContractDetailCtrl-->
<!--Controller path : www/templates/hardware-connect/mobile-contract/js/controllers.js-->
<!--State name : app.mobileContractDetail-->
<!--URL : #app/mobileContractDetail-->
<ion-view view-title="">
<!--left button on navigation bar-->
<ion-nav-buttons side="left">
<a ng-click="$ionicGoBack()" class="button back-button buttons button-clear header-item nav-back-btn">
<i class="ion-android-arrow-back"></i>
</a>
</ion-nav-buttons><!--end left button on navigation bar-->
<form name="noteForm">
<ion-content class="header-in-content">
<!--toolbar section-->
<md-toolbar class="bar-subheader md-tall md-primary toolbar-medium toolbar-in-content">
<div>
<h1>
<i class="ion-android-person"></i>
</h1>
<h3> Contract Detail </h3>
</div>
<a class="md-button md-accent md-fab fab-toolbar-medium"
ng-click="showListBottomSheet($event,contract)"
aria-label="showListBottomSheet">
<i class="ion-android-star"></i>
</a>
</md-toolbar> <!--end toolbar section-->
<!--mobile contract detail section-->
<div id="mobile-contract-detail-content">
<!--input section-->
<md-input-container md-no-float>
<i class="ion-android-person"></i>
<input ng-model="contract.name.honorificPrefix" name="firstName" placeholder="Name Prefix">
</md-input-container>
<md-input-container md-no-float>
<i class="ion-android-person"></i>
<input ng-model="contract.name.givenName" name="firstName" required
placeholder="* First Name (required)">
</md-input-container>
<md-input-container md-no-float>
<i class="ion-android-person"></i>
<input ng-model="contract.name.middleName" name="firstName" placeholder="Middle Name">
</md-input-container>
<md-input-container md-no-float>
<i class="ion-android-person"></i>
<input ng-model="contract.name.familyName" name="firstName" placeholder="Last Name">
</md-input-container>
<md-input-container md-no-float>
<i class="ion-android-person"></i>
<input ng-model="contract.name.honorificSuffix" name="firstName" placeholder="Name Suffix">
</md-input-container>
<md-input-container ng-repeat="number in contract.phoneNumbers" md-no-float>
<i class="ion-android-phone-portrait"></i>
<input ng-model="number.value" name="telephone" class="input-tel"
placeholder="* Telephone" type="tel">
<i ng-show="number.value.length > 0"
ng-click="callTo(number.value)"
class="ion-android-call tel"></i>
<i ng-show="number.value.length > 0"
ng-click="sentSms(number.value)"
class="ion-android-textsms message"></i>
</md-input-container>
<md-input-container ng-repeat="email in contract.emails" md-no-float>
<i class="ion-android-mail"></i>
<input ng-model="email.value" class="input-mail" name="email" placeholder="Email">
<i ng-show="email.value.length > 0"
ng-click="sentEmail(email.value)"
class="ion-android-send mail"></i>
</md-input-container>
<!--end input section-->
</div> <!--end mobile contract detail section-->
</ion-content>
</form>
<!--angular template section-->
<script type="text/ng-template" id="mobile-contract-actions-template.html">
<md-bottom-sheet class="md-list md-has-header">
<h1 class="md-bottom-sheet-header">Contract Actions</h1>
<!--list section-->
<md-list>
<md-list-item>
<a class="md-default-theme md-bottom-sheet-list-item" ng-click="addNumber()">
<i class="ion-android-call"></i>
<span>New Number</span>
</a>
</md-list-item>
<md-list-item>
<a class="md-default-theme md-bottom-sheet-list-item" ng-click="addMail()">
<i class="ion-android-mail"></i>
<span>New Email</span>
</a>
</md-list-item>
<md-list-item>
<a class="md-default-theme md-bottom-sheet-list-item"
ng-class="{ 'disabled-link': disableSaveBtn}"
ng-click="saveContract(contract,$event)">
<i class="ion-android-list"></i>
<span>Save</span>
</a>
</md-list-item>
<md-list-item ng-show="actionDelete">
<a class="md-default-theme md-bottom-sheet-list-item"
ng-click="deleteContract(contract,$event)">
<i class="ion-android-delete"></i>
<span>Remove</span>
</a>
</md-list-item>
</md-list><!--end list section-->
</md-bottom-sheet>
</script><!--end angular template section-->
</ion-view>

View File

@@ -0,0 +1,81 @@
<!--View Information-->
<!--View name : Device Mobile Contract List-->
<!--Controller name : mobileContractListCtrl-->
<!--Controller path : www/templates/hardware-connect/mobile-contract/js/controllers.js-->
<!--State name : app.mobileContractList-->
<!--URL : #app/mobileContractList-->
<ion-view view-title="">
<!--toolbar section-->
<md-toolbar class="bar-subheader md-tall md-primary toolbar-medium">
<div>
<h1>Mobile Contract</h1>
<md-input-container md-no-float="">
<input ng-model="filterText" id="name_2" placeholder="Search for contacts.">
</md-input-container>
</div>
<a class="md-button md-accent md-fab fab-toolbar-medium"
ng-click="navigateTo('app.mobileContractDetail')"
aria-label="Add">
<i class="icon ion-plus"></i>
</a>
</md-toolbar> <!--end toolbar section-->
<!--mobile contract list section-->
<ion-content id="mobile-contract-list-content">
<!--list section-->
<md-list class="ng-hide" ng-show="!loading">
<md-list-item class="md-list-item-default" item-height="46px" item-width="100%"
collection-repeat="contract in contracts | filter: filterText | orderBy: 'firstName'">
<span>
<i class="ion-android-person"></i>
</span>
<p>
{{contract.name.formatted}}
</p>
<md-menu md-position-mode="target-right target" class="md-list-item-md-menu-right">
<p ng-click="$mdOpenMenu()">
<md-icon md-menu-origin md-svg-icon="more"></md-icon>
</p>
<md-menu-content width="1">
<md-menu-item ng-repeat="number in contract.phoneNumbers">
<a class="md-button md-default-theme" ng-click="callTo(number.value)">
<span class="menu-item-button" content="telephone=no">
<i class="ion-android-call"></i> {{number.value}}
</span>
</a>
</md-menu-item>
<md-menu-item>
<a class="md-button md-default-theme"
ng-click="navigateTo('app.mobileContractDetail',contract)">
<span class="menu-item-button">View</span>
</a>
</md-menu-item>
<md-menu-item>
<a class="md-button md-default-theme" ng-click="deleteContract(contract,$event)">
<span class="menu-item-button">Remove</span>
</a>
</md-menu-item>
</md-menu-content>
</md-menu>
</md-list-item>
</md-list><!--end list section-->
</ion-content><!--end mobile contract list section-->
<!--loading progress-->
<div id="mobile-contract-list-loading-progress" class="loading-progress fade-in">
<ion-spinner ng-if="!isAndroid" class="progress-circular"></ion-spinner>
<md-progress-circular ng-if="isAndroid" md-mode="indeterminate"></md-progress-circular>
</div><!--end loading progress-->
</ion-view>

View File

@@ -0,0 +1,486 @@
// For get mobile contract you have to install $cordovaContacts by running the following
// command in your cmd.exe for windows or terminal for mac:
// $ cd your_project_path
// $ ionic plugin remove cordova-plugin-contacts
// $ ionic plugin add cordova-plugin-contacts
//
// Learn more about $cordovaContacts :
// http://ngcordova.com/docs/plugins/contacts/
//
// For sent email you have to install $cordovaSocialSharing by running the following
// command in your cmd.exe for windows or terminal for mac:
// $ cd your_project_path
// $ ionic plugin remove nl.x-services.plugins.socialsharing
// $ ionic plugin add https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin.git
//
// Learn more about $cordovaSocialSharing :
// http://ngcordova.com/docs/plugins/socialSharing/
//
// For sent message you have to install $cordovaSMS by running the following
// command in your cmd.exe for windows or terminal for mac:
// $ cd your_project_path
// $ ionic plugin remove com.cordova.plugins.sms
// $ ionic plugin add https://github.com/cordova-sms/cordova-sms-plugin.git
//
// Learn more about $cordovaSMS :
// http://ngcordova.com/docs/plugins/sms/
//
// For using mobile calling you must go to yourProjectPath/config.xml
// and put this following code in the access area.
// <access origin="tel:*" launch-external="yes"/>
//
// Controller of contracts list page.
appControllers.controller('mobileContractListCtrl', function ($scope, $filter, $mdDialog, $timeout, $mdToast, $ionicModal, $state, $mdBottomSheet, $cordovaContacts) {
// This function is the first activity in the controller.
// It will initial all variable data and let the function works when page load.
$scope.initialForm = function () {
// $scope.loading is for loading progress.
$scope.loading = true;
// $scope.contracts is store contracts data.
$scope.contracts = [];
// $scope.filterText is the variable that use for searching.
$scope.filterText = "";
// To hide $mdBottomSheet
$mdBottomSheet.cancel();
// To hide $mdDialog
$mdDialog.cancel();
// The function for show/hide loading progress.
$timeout(function () {
if ($scope.isAndroid) {
jQuery('#mobile-contract-list-loading-progress').show();
}
else {
jQuery('#mobile-contract-list-loading-progress').fadeIn(700);
}
}, 400);
$timeout(function () {
// To get all contracts.
$scope.getContractList(true);
}, 2000);
}; // End initialForm.
// callTo is for using mobile calling.
// Parameter :
// number = number that going to call.
$scope.callTo = function (number) {
window.open("tel:" + number);
}// End callTo.
// getContractList is for get all contracts from mobile.
// Parameter :
// IsInit(bool) = for stop loading progress.
$scope.getContractList = function (isInit) {
// options for get contracts.
var options = {multiple: true};
// Calling $cordovaContacts.find to get all contracts.
// Parameter :
// options = options for get contracts.
$cordovaContacts.find(options).then(
function (contractList) {
// Success retrieve data from mobile contract.
// It will return all contracts then store it in to $scope.contracts
$scope.contracts = contractList;
// To stop loading progress.
if (isInit) {
$timeout(function () {
$scope.loading = false;
jQuery('#mobile-contract-list-loading-progress').hide();
}, 2000);
}
},
function () {
// Error retrieve data from mobile contract.
console.log("mobile contract is error");
});
}; // End getContractList.
// deleteContract is for delete contract.
// contract(object) = contract object that user want to delete.
// $event(object) = position of control that user tap.
$scope.deleteContract = function (contract, $event) {
//mdBottomSheet.hide() use for hide bottom sheet.
$mdBottomSheet.hide();
//mdDialog.show use for show alert box for Confirm to remove contract.
$mdDialog.show({
controller: 'DialogController',
templateUrl: 'confirm-dialog.html',
targetEvent: $event,
locals: {
displayOption: {
title: "Confirm to remove contract?",
content: "Data will remove from Mobile Contract.",
ok: "Confirm",
cancel: "Close"
}
}
}).then(function () {
// For confirm button to remove all contract.
// remove contract by calling $cordovaContacts.remove.
try {
$cordovaContacts.remove(contract).then(function (result) {
}, function (error) {
console.log(error);
});
// set filterText to empty for searching contract.
$scope.filterText = "";
// Refresh contract page.
$scope.getContractList(false);
// Showing toast for Contract Removed !.
$mdToast.show({
controller: 'toastController',
templateUrl: 'toast.html',
hideDelay: 400,
position: 'top',
locals: {
displayOption: {
title: "Contract Removed !"
}
}
});
}
catch (e) {
// remove error.
// Showing toast for unable to remove contract.
$mdToast.show({
controller: 'toastController',
templateUrl: 'toast.html',
hideDelay: 800,
position: 'top',
locals: {
displayOption: {
title: window.globalVariable.message.errorMessage
}
}
});
}
}
, function () {
// For cancel button to remove data.
});
};// End deleteContract.
// navigateTo is for navigate to other page
// by using targetPage to be the destination page
// and sending objectData to the destination page.
// Parameter :
// targetPage = destination page.
// objectData = object that will sent to destination page.
$scope.navigateTo = function (targetPage, objectData) {
$state.go(targetPage, {
contractDetail: objectData,
actionDelete: (objectData == null ? false : true)
});
}; // End navigateTo.
$scope.initialForm();
});// End of contract list controller.
// Controller of contracts detail page.
appControllers.controller('mobileContractDetailCtrl', function ($mdBottomSheet, $timeout, $mdToast, $scope, $stateParams
, $filter, $mdDialog, $ionicHistory, $cordovaContacts, $cordovaSms, $cordovaSocialSharing) {
// This function is the first activity in the controller.
// It will initial all variable data and let the function works when page load.
$scope.initialForm = function () {
//$scope.disableSaveBtn is the variable for setting disable or enable the save button.
$scope.disableSaveBtn = false;
//$scope.actionDelete is the variable for allow or not allow to delete data.
// It will allow to delete data when have data in the mobile contract.
// $stateParams.actionDelete(bool) = status that pass from contract list page.
$scope.actionDelete = $stateParams.actionDelete;
//$scope.contract is the variable that store contract data.
// $stateParams.contractDetail = contract data that pass from contract list page.
$scope.contract = $stateParams.contractDetail;
// For initial temp contract data in case of add new contract.
if ($scope.actionDelete == false) {
$scope.contract = {
"name": {
givenName: ""
},
"phoneNumbers": [{
id: 0,
pref: false,
type: "mobile",
value: ""
}],
"emails": [{
id: 0,
pref: false,
type: "home",
value: ""
}]
};
}// End initial temp contract data.
// If contract don't have phone number it will create a blank array for text box
// for user to input there number.
if ($scope.contract.phoneNumbers == null) {
$scope.addNumber();
}
// If contract don't have email it will create a blank array of text box
// for user to input there email.
if ($scope.contract.emails == null) {
$scope.addMail();
}
}; // End initialForm.
// addNumber for create a blank array of text box for user to input there number.
$scope.addNumber = function () {
if ($scope.contract.phoneNumbers == null) {
$scope.contract.phoneNumbers = [{value: ""}];
}
else {
$scope.contract.phoneNumbers.push({value: ""});
}
$timeout(function () {
// To hide $mdBottomSheet
$mdBottomSheet.hide();
// To hide $mdDialog
$mdDialog.hide();
}, 400);
};// End addNumber.
// addMail for create a blank array of text box for user to input there email.
$scope.addMail = function () {
if ($scope.contract.emails == null) {
$scope.contract.emails = [{value: ""}];
}
else {
$scope.contract.emails.push({value: ""});
}
$timeout(function () {
// To hide $mdBottomSheet
$mdBottomSheet.hide();
// To hide $mdDialog
$mdDialog.hide();
}, 400);
};// End addMail.
// saveContract for saving contract
// Parameter :
// contract(object) = contract object that presenting on the view.
// $event(object) = position of control that user tap.
$scope.saveContract = function (contract, $event) {
// To hide $mdBottomSheet
$mdBottomSheet.hide();
// tempPhoneNumbers is array of temporary phone number.
var tempPhoneNumbers = [];
// Create new object by cloning object that present on the view.
// For prepare data to save.
angular.copy($scope.contract.phoneNumbers, tempPhoneNumbers);
// To packing array of temporary phone number to save to contract.
for (var index = (tempPhoneNumbers.length - 1); index > -1; index--) {
if (tempPhoneNumbers[index].value == "") {
$scope.contract.phoneNumbers.splice(index, 1);
}
}
// tempMail is temporary array of email.
var tempMail = [];
// Create new object by cloning object that present on the view.
// For prepare data to save.
angular.copy($scope.contract.emails, tempMail);
// To packing array of temporary email to save to contract.
for (var index = (tempMail.length - 1); index > -1; index--) {
if (tempMail[index].value == "") {
$scope.contract.emails.splice(index, 1);
}
}
//mdDialog.show use for show alert box for Confirm to save data.
$mdDialog.show({
controller: 'DialogController',
templateUrl: 'confirm-dialog.html',
targetEvent: $event,
locals: {
displayOption: {
title: "Confirm to save contract?",
content: "Data will save to mobile contract.",
ok: "Confirm",
cancel: "Close"
}
}
}).then(function () {
// For confirm button to save data.
try {
// Save contract to mobile contract by calling $cordovaContacts.save(contract)
$cordovaContacts.save(contract).then(function (result) {
}, function (error) {
console.log(error);
});
// Showing toast for save data is success.
$mdToast.show({
controller: 'toastController',
templateUrl: 'toast.html',
hideDelay: 400,
position: 'top',
locals: {
displayOption: {
title: "Contract Saved !"
}
}
});
// After save success it will navigate back to contract list page.
$timeout(function () {
$ionicHistory.goBack();
}, 800);
}
catch (e) {
// Showing toast for unable to save data.
$mdToast.show({
controller: 'toastController',
templateUrl: 'toast.html',
hideDelay: 800,
position: 'top',
locals: {
displayOption: {
title: window.globalVariable.message.errorMessage
}
}
});
}
}, function () {
// For cancel button to save data.
});// End alert box.
};// End saveContract.
// deleteContract for delete contract
// Parameter :
// contract(object) = contract object that presenting on the view.
// $event(object) = position of control that user tap.
$scope.deleteContract = function (contract, $event) {
//mdBottomSheet.hide() use for hide bottom sheet.
$mdBottomSheet.hide();
//mdDialog.show use for show alert box for Confirm to remove contract.
$mdDialog.show({
controller: 'DialogController',
templateUrl: 'confirm-dialog.html',
targetEvent: $event,
locals: {
displayOption: {
title: "Confirm to remove contract?",
content: "Data will remove from Mobile Contract.",
ok: "Confirm",
cancel: "Close"
}
}
}).then(function () {
// For confirm button to remove contract.
try {
// remove contract by calling $cordovaContacts.remove.
$cordovaContacts.remove(contract).then(function (result) {
}, function (error) {
console.log(error);
});
// After remove success it will navigate back to contract list.
$ionicHistory.goBack();
} catch (e) {
//// Showing toast for unable to remove data.
$mdToast.show({
controller: 'toastController',
templateUrl: 'toast.html',
hideDelay: 800,
position: 'top',
locals: {
displayOption: {
title: window.globalVariable.message.errorMessage
}
}
});
} //End showing toast.
}, function () {
// For cancel button to remove data.
});
};// End deleteContract.
// validateRequiredField is for validate the required field.
// Parameter :
// contractForm(object) = contract object that presenting on the view.
$scope.validateRequiredField = function (contractForm) {
return ((typeof contractForm.name.givenName) == "undefined" ) || (contractForm.name.givenName.length == 0);
};// End validate the required field.
// showListBottomSheet is for showing the bottom sheet.
// Parameter :
// $event(object) = position of control that user tap.
// contractForm(object) = contract object that presenting on the view.
$scope.showListBottomSheet = function ($event, contractForm) {
$scope.disableSaveBtn = $scope.validateRequiredField(contractForm);
$mdBottomSheet.show({
templateUrl: 'mobile-contract-actions-template.html',
targetEvent: $event,
scope: $scope.$new(false),
});
};// End showing the bottom sheet.
// callTo is for using mobile calling.
// Parameter :
// number = number that going to call
$scope.callTo = function (number) {
window.open("tel:" + number);
}// End callTo.
// sentEmail is for send email by calling $cordovaSocialSharing.
// Parameter :
// email = email of receiver.
$scope.sentEmail = function (email) {
$cordovaSocialSharing.shareViaEmail(" ", " ", email, "", "", "");
// format of sent email by using $cordovaSocialSharing is :
//$cordovaSocialSharing.shareViaEmail(message, subject, toArr, ccArr, bccArr,file)
// toArr, ccArr and bccArr must be an array, file can be either null, string or array.
}; // End sentEmail.
// sentSms is for send message by calling $cordovaSms.
// Parameter :
// phoneNumber = number of sending message
$scope.sentSms = function (numbers) {
//config options to sent message
var options = {
replaceLineBreaks: false, // true to replace \n by a new line, false by default.
android: {
intent: 'INTENT' // send SMS with the native android SMS messaging
//intent: '' // send SMS without open any other app.
}
};
// calling $cordovaSms to sent message.
$cordovaSms.send(numbers, " ", options);
};// End sentSms.
$scope.initialForm();
});// End of contract detail controller.

View File

@@ -0,0 +1,30 @@
<!--View Information-->
<!--View name : Device Vibration-->
<!--Controller name : vibrationCtrl-->
<!--Controller path : www/templates/hardware-connect/vibration/js/controllers.js-->
<!--State name : app.vibration-->
<!--URL : #app/vibration-->
<ion-view title="Vibration">
<!--vibration section-->
<ion-content scroll="false">
<div class="row">
<!--vibration icon section-->
<div id="vibration-icon" class="col">
<i ng-class="{'vibration-sad-color' : vibrateing}"
class="ion-android-happy center-screen icon-vibration"></i>
</div>
<!--end vibration icon section-->
</div>
<div class="row">
<!--vibration control section-->
<div id="vibration-control" class="col">
<p>Devise Vibration</p>
<a class="md-raised md-warn md-button md-default-theme" ng-click="vibrate()">
Vibrate
</a>
</div><!--end vibration control section-->
</div>
</ion-content><!--end vibration section-->
</ion-view>

View File

@@ -0,0 +1,31 @@
// For using vibration you have to install $cordovaVibration by running the following
// command in your cmd.exe for windows or terminal for mac:
// $ cd your_project_path
// $ ionic plugin remove cordova-plugin-vibration
// $ ionic plugin add cordova-plugin-vibration
//
// Learn more about $cordovaVibration :
// http://ngcordova.com/docs/plugins/vibration/
//
// Controller of vibration page.
appControllers.controller('vibrationCtrl', function ($scope, $timeout, $cordovaVibration) {
// initialForm is the first activity in the controller.
// It will initial all variable data and let the function works when page load.
$scope.initialForm = function () {
// $scope.vibrateing is vibrateing status.
$scope.vibrateing = false;
};
// vibrate for vibrate by calling $cordovaVibration.vibrate(milliseconds of vibrateing)
$scope.vibrate = function () {
$scope.vibrateing = true;
$cordovaVibration.vibrate(400);
$timeout(function () {
$scope.vibrateing = false;
}, 400);
};// End vibrate.
$scope.initialForm();
});// End of vibration Controller.