| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873 |
- var vstartdate = [];
- var datefor = null;
- var testcal = "";
- define(['angularAMD', 'angular-route', 'angular-animate', 'angular-bootstrap', 'moment', 'angularTreeview','angularjs-dropdown-multiselect'], function (angularAMD) {
- var app = angular.module("tti", ['ngRoute', 'ui.bootstrap', 'angularTreeview','angularjs-datetime-picker','angularjs-dropdown-multiselect']);
- app.config(function ($routeProvider) {
- $routeProvider
- .when("/login", angularAMD.route({
- templateUrl: 'module/login/login.html', controller: 'LoginCtrl', controllerUrl: 'module/login/js/login', languageUrl: "language/logdata"
- }))
- .when("/user", angularAMD.route({
- templateUrl: 'module/user/user.html', controller: 'UserCtrl', controllerUrl: 'module/user/js/user', languageUrl: "language/userdata"
- }))
- .when("/dealer", angularAMD.route({
- templateUrl: 'module/dealer/dealer.html', controller: 'DealerCtrl', controllerUrl: 'module/dealer/js/dealer', languageUrl: "language/dealerdata"
- }))
- .when("/question", angularAMD.route({
- templateUrl: 'module/question/question.html', controller: 'QuestionCtrl', controllerUrl: 'module/question/js/question', languageUrl: "language/questiondata"
- }))
- .when("/assessment", angularAMD.route({
- templateUrl: 'module/assessment/assessment.html', controller: 'AssessmentCtrl', controllerUrl: 'module/assessment/js/assessment', languageUrl: "language/assessmentdata"
- }))
- .when("/content", angularAMD.route({
- templateUrl: 'module/content/content.html', controller: 'ContentCtrl', controllerUrl: 'module/content/js/content', languageUrl: "language/contentdata"
- }))
- .when("/training", angularAMD.route({
- templateUrl: 'module/training/training.html', controller: 'TrainingCtrl', controllerUrl: 'module/training/js/training', languageUrl: "language/trainingdata"
- }))
- .when("/survey", angularAMD.route({
- templateUrl: 'module/survey/survey.html', controller: 'SurveyCtrl', controllerUrl: 'module/survey/js/survey', languageUrl: "language/surveydata"
- }))
- .when("/bulletin", angularAMD.route({
- templateUrl: 'module/bulletin/bulletin.html', controller: 'BulletinCtrl', controllerUrl: 'module/bulletin/js/bulletin', languageUrl: "language/bulletindata"
- }))
- .when("/redeem", angularAMD.route({
- templateUrl: 'module/redeem/redeem.html', controller: 'RedeemCtrl', controllerUrl: 'module/redeem/js/redeem', languageUrl: "language/redeemdata"
- }))
- .when("/user-registartion", angularAMD.route({
- templateUrl: 'module/report/user-registration/user-registration.html', controller: 'UserRegistrationCtrl', controllerUrl: 'module/report/user-registration/js/user-registration', languageUrl: "language/user-registration-data"
- }))
- .when("/user-report", angularAMD.route({
- templateUrl: 'module/report/user-report/user-report.html', controller: 'UserReportCtrl', controllerUrl: 'module/report/user-report/js/user-report', languageUrl: "language/user-report-data"
- }))
- .when("/content-report", angularAMD.route({
- templateUrl: 'module/report/content-report/content-report.html', controller: 'ContentReportCtrl', controllerUrl: 'module/report/content-report/js/content-report', languageUrl: "language/user-content-data"
- }))
- .when("/assessment-report", angularAMD.route({
- templateUrl: 'module/report/assessment-report/assessment-report.html', controller: 'AssessmentReportCtrl', controllerUrl: 'module/report/assessment-report/js/assessment-report', languageUrl: "language/user-assessment-data"
- }))
- .when("/sales-report", angularAMD.route({
- templateUrl: 'module/report/sales-report/sales-report.html', controller: 'SalesReportCtrl', controllerUrl: 'module/report/sales-report/js/sales-report', languageUrl: "language/user-sales-data"
- }))
- .when("/certification-report", angularAMD.route({
- templateUrl: 'module/report/certification-report/certification-report.html', controller: 'CertificationReportCtrl', controllerUrl: 'module/report/certification-report/js/certification-report', languageUrl: "language/user-certification-data"
- }))
- .when("/setsales-report", angularAMD.route({
- templateUrl: 'module/report/setsales-report/setsales-report.html', controller: 'SetsalesReportCtrl', controllerUrl: 'module/report/setsales-report/js/setsales-report', languageUrl: "language/user-setsales-data"
- }))
- .when("/redeem-report", angularAMD.route({
- templateUrl: 'module/report/redeem-report/redeem-report.html', controller: 'RedeemReportCtrl', controllerUrl: 'module/report/redeem-report/js/redeem-report', languageUrl: "language/redeem-report-data"
- }))
- .when("/attrition-report", angularAMD.route({
- templateUrl: 'module/report/attrition-report/attrition-report.html', controller: 'AttritionReportCtrl', controllerUrl: 'module/report/attrition-report/js/attrition-report', languageUrl: "language/attrition-data"
- }))
- .when("/customer-experience-report", angularAMD.route({
- templateUrl: 'module/report/customer-experience-report/customer-experience-report.html', controller: 'ExperienceReportCtrl', controllerUrl: 'module/report/customer-experience-report/js/customer-experience-report', languageUrl: "language/experience-data"
- }))
- .when("/current-login-report", angularAMD.route({
- templateUrl: 'module/report/current-login-report/current-login-report.html', controller: 'CurrentloginReportCtrl', controllerUrl: 'module/report/current-login-report/js/current-login-report', languageUrl: "language/user-current-login-report-data"
- }))
- .when("/bulletin-report", angularAMD.route({
- templateUrl: 'module/report/bulletin-report/bulletin-report.html', controller: 'BulletinReportCtrl', controllerUrl: 'module/report/bulletin-report/js/bulletin-report', languageUrl: "language/user-bulletin-report-data"
- }))
- .when("/enquiry-report", angularAMD.route({
- templateUrl: 'module/report/enquiry-report/enquiry-report.html', controller: 'EnquiryReportCtrl', controllerUrl: 'module/report/enquiry-report/js/enquiry-report', languageUrl: "language/user-enquiry-report-data"
- }))
- .when("/notification", angularAMD.route({
- templateUrl: 'module/report/notification/notification.html', controller: 'NotificationCtrl', controllerUrl: 'module/report/notification/js/notification', languageUrl: "language/notification"
- }))
- .when("/ilearning", angularAMD.route({
- templateUrl: 'module/ilearning/ilearning.html', controller: 'IlearningCtrl', controllerUrl: 'module/ilearning/js/ilearning', languageUrl: "language/ilearning"
- }))
- .when("/sales", angularAMD.route({
- templateUrl: 'module/import/sales/sales.html', controller: 'SalesCtrl', controllerUrl: 'module/import/sales/js/sales', languageUrl: "language/sales"
- }))
- .when("/dsesales", angularAMD.route({
- templateUrl: 'module/import/dsesales/dsesales.html', controller: 'DSESalesCtrl', controllerUrl: 'module/import/dsesales/js/dsesales', languageUrl: "language/dsesales"
- }))
- .otherwise({ redirectTo: "/login" });
- });
- app.run(function ($rootScope, $templateCache, $location, $route) {
- // alert($rootScope.is_logged)
- $rootScope.modalLogShown = false;
- $rootScope.cofirmWindow = false;
- $rootScope.selLanguage = "en_us";
- $rootScope.is_logged = true;
- $rootScope.sidemenuhigh = window.innerHeight - (180);
- $rootScope.logoutfn = function () {
- $rootScope.log = false;
- // console.log($rootScope.log)
- $rootScope.cofirmWindow = true;
- $rootScope.modalLogShown = true;
- $rootScope.message = "Are you sure you want to logout ?";
- }
- $rootScope.$on("cofirm", function () {
- $rootScope.cofirmWindow = false;
- $rootScope.modalLogShown = false;
- $rootScope.is_logged = false;
- // console.log($rootScope.log)
- $location.path("/login");
- })
- });
- app.directive('modalDialog', function ($rootScope) {
- return {
- templateUrl: "module/alert.html",
- restrict: 'E',
- transclude: true,
- replace: true,
- backdrop: 'static',
- scope: {
- show: '=',
- type: '=',
- },
- replace: true, // Replace with the template below
- transclude: true, // we want to insert custom content inside the directive
- link: function ($scope, element, attrs) {
- $('#' + attrs.id).css('display', 'block');
- $scope.dialogStyle = {};
- if (attrs.width)
- $scope.dialogStyle.width = attrs.width;
- if (attrs.height)
- $scope.dialogStyle.height = attrs.height;
- $scope.hideModal = function () {
- $scope.show = false;
- $scope.type = false;
- };
- $scope.okClickModal = function () {
- // console.log(attrs.id)
- $rootScope.$broadcast('confirmDelete');
- $scope.show = false;
- $scope.type = false;
- };
- }
- };
- });
- app.directive('modalPublishForm', function ($rootScope) {
- return {
- templateUrl: "module/publish_form.html",
- restrict: 'E',
- transclude: true,
- replace: true,
- backdrop: 'static',
- scope: {
- show: '=',
- type: '=',
- },
- replace: true, // Replace with the template below
- transclude: true, // we want to insert custom content inside the directive
- link: function ($scope, element, attrs) {
- $('#' + attrs.id).css('display', 'block');
- // console.log(attrs.id)
- $scope.dialogStyle = {};
- if (attrs.width)
- $scope.dialogStyle.width = attrs.width;
- if (attrs.height)
- $scope.dialogStyle.height = attrs.height;
- $scope.hideModal = function () {
- $scope.show = false;
- $scope.type = false;
- $rootScope.num = 1;
- // console.log($rootScope.num)
- };
- $scope.okModal = function () {
- // console.log("here")
- $rootScope.$broadcast('confirmPublish');
- $scope.show = false;
- $scope.type = false;
- };
- }
- };
- });
- app.directive('modalLogpopup', function ($rootScope) {
- return {
- templateUrl: "module/logout.html",
- restrict: 'E',
- transclude: true,
- replace: true,
- backdrop: 'static',
- scope: {
- show: '=',
- type: '=',
- },
- replace: true, // Replace with the template below
- transclude: true, // we want to insert custom content inside the directive
- link: function ($scope, element, attrs) {
- $('#' + attrs.id).css('display', 'block');
- $scope.dialogStyle = {};
- if (attrs.width) {
- $scope.dialogStyle.width = attrs.width;
- }
- if (attrs.height) {
- $scope.dialogStyle.height = attrs.height;
- }
- $scope.$watch(function (value) {
- $scope.title = $rootScope.popuptitle;
- });
- $scope.hideModal = function () {
- $scope.show = false;
- $scope.type = false;
- };
- $scope.okModal = function () {
- $rootScope.$broadcast('cofirm');
- $scope.show = false;
- $scope.type = false;
- };
- }
- };
- });
- app.directive('ngDatepickermin', function ($rootScope) {
- return {
- restrict: 'A',
- require: '?ngModel',
- scope: {
- },
- link: function ($scope, element, attrs, ngModel) {
- if (attrs.isblockdate == "true") {
- element.datepicker({
- dateFormat: 'yy-mm-dd',
- minDate: '01-01-1900',
- maxDate: '+3m',
- onSelect: function (date) {
- if (attrs.name == "dob") {
- $scope.$parent.formData.date_of_join = date;
- } else if (attrs.name == "start_date") {
- $scope.$parent.formData.publisheddate = date;
- } else if (attrs.name == "clsstartdate") {
- $scope.$parent.formData.startdate = date;
- }
- $scope.$parent.$apply();
- }
- });
- } else if (attrs.isblockdate == "false") {
- //console.log("Yes calender 2",attrs.isblockdate)
- element.datepicker({
- minDate: '01-01-16',
- dateFormat: 'dd-mm-yy',
- /*onSelect: function (date) {
-
- testcal=date;
-
- //vstartdate = String(date).split("-");
- datefor = date;
- //datefor = new Date("2016-7-20");
- //datefor = new Date(vstartdate[2],vstartdate[1]-1,vstartdate[0]);
- $scope.$parent.$apply();
- }*/
- onSelect: function (selected) {
- /*var date2 = $('#vechcal1').datepicker('getDate');
- date2.setDate(date2.getDate()+4);
-
- $("#vechcal2").datepicker("option","maxDate", date2)
- $("#vechcal2").datepicker("option","minDate", selected)*/
- $rootScope.startdate = selected;
- //$scope.vstdate = selected;
- //$scope.$parent.formData.enddates = selected;
- //$scope.$parent.$apply();
- //console.log(vstdate)
- }
- });
- }
- }
- }
- })
- app.directive('ngDatepickermax', function ($rootScope) {
- return {
- restrict: 'A',
- require: '?ngModel',
- scope: {
- },
- link: function ($scope, element, attrs, ngModel) {
- if (attrs.isblockdate == "true") {
- element.datepicker({
- dateFormat: 'yy-mm-dd',
- minDate: 0,
- maxDate: '+3m',
- onSelect: function (date) {
- if (attrs.name == "clspublishdate") {
- $scope.$parent.formData.publishdate = date;
- } else if (attrs.name == "clsenddate") {
- $scope.$parent.formData.enddate = date;
- } else if (attrs.name == "clsstartdate") {
- $scope.$parent.formData.start_date = date;
- } else if (attrs.name == "clsend_date") {
- $scope.$parent.formData.end_date = date;
- }
- $scope.$parent.$apply();
- }
- });
- }
- else if (attrs.isblockdate == "false") {
- //console.log("Yes calender 2",attrs.isblockdate)
- element.datepicker({
- dateFormat: 'dd-mm-yy',
- /*onSelect: function (date) {
- console.log(datefor)
- $scope.$parent.$apply();
- }
- */
- onSelect: function (selected) {
- /*var date1 = $('#vechcal2').datepicker('getDate');
- date1.setDate(date1.getDate()-5);
- $("#vechcal1").datepicker({"minDate": date1});*/
- $scope.$parent.vendtdate = selected;
- //$scope.$parent.formData.publishdates = selected;
- //console.log($scope.$parent.vendtdate);
- $rootScope.enddate = selected;
- //$scope.$parent.$apply();
- //$rootScope.vendtdate = selected;
- }
- });
- }
- }
- }
- })
- /////////////// Report datepicker /////////////
- app.directive('ngReportpickermin', function ($rootScope) {
- return {
- restrict: 'A',
- require: '?ngModel',
- scope: {
- },
- link: function ($scope, element, attrs, ngModel) {
- if (attrs.isblockdate == "true") {
- element.datepicker({
- dateFormat: 'yy-mm-dd',
- // minDate: '0',
- maxDate: '0',
- onSelect: function (date) {
- // console.log(date)
-
- if (attrs.name == "fromdate") {
- $scope.$parent.formData.from_date = date;
- if((new Date($scope.$parent.formData.from_date).getTime() > new Date($scope.$parent.formData.to_date).getTime())){
- $scope.$parent.formData.to_date = '';
- }
- var datearr = date.split('-');
- // console.log(datearr, (Number(datearr[0]) + 1) + "-" + datearr[1] + "-" + datearr[2])
- $("#todate").datepicker("option", "maxDate", 0);
- $('#todate').datepicker("option", 'minDate', datearr[0] + "-" + datearr[1] + "-" + (Number(datearr[2]) + 1));
- // $scope.$parent.formData.to_date = ''
- } else if (attrs.name == "todate") {
-
- // $("#todate").datepicker("option", "maxDate", (Number(datearr[0]) + 1) + "-" + datearr[1] + "-" + datearr[2]);
- $scope.$parent.formData.to_date = date;
- if((new Date($scope.$parent.formData.from_date).getTime() > new Date($scope.$parent.formData.to_date).getTime())){
- $scope.$parent.formData.from_date = '';
- }
- }
- $scope.$parent.$apply();
- }
- });
- } else if (attrs.isblockdate == "false") {
- //console.log("Yes calender 2",attrs.isblockdate)
- element.datepicker({
- minDate: '01-01-16',
- dateFormat: 'dd-mm-yy',
- /*onSelect: function (date) {
-
- testcal=date;
-
- //vstartdate = String(date).split("-");
- datefor = date;
- //datefor = new Date("2016-7-20");
- //datefor = new Date(vstartdate[2],vstartdate[1]-1,vstartdate[0]);
- $scope.$parent.$apply();
- }*/
- onSelect: function (selected) {
- /*var date2 = $('#vechcal1').datepicker('getDate');
- date2.setDate(date2.getDate()+4);
-
- $("#vechcal2").datepicker("option","maxDate", date2)
- $("#vechcal2").datepicker("option","minDate", selected)*/
- $rootScope.startdate = selected;
- //$scope.vstdate = selected;
- //$scope.$parent.formData.enddates = selected;
- //$scope.$parent.$apply();
- //console.log(vstdate)
- }
- });
- }
- }
- }
- })
- app.directive('ngReportpickermax', function ($rootScope) {
- return {
- restrict: 'A',
- require: '?ngModel',
- scope: {
- },
- link: function ($scope, element, attrs, ngModel) {
-
- if (attrs.isblockdate == "true") {
- element.datepicker({
- dateFormat: 'yy-mm-dd',
- minDate: 0,
- maxDate: '+3m',
- onSelect: function (date) {
- if (attrs.name == "clspublishdate") {
- $scope.$parent.formData.publishdate = date;
- } else if (attrs.name == "clsenddate") {
- $scope.$parent.formData.enddate = date;
- } else if (attrs.name == "clsstartdate") {
- $scope.$parent.formData.start_date = date;
- } else if (attrs.name == "clsend_date") {
- $scope.$parent.formData.end_date = date;
- }
- $scope.$parent.$apply();
- }
- });
- }
- else if (attrs.isblockdate == "false") {
- //console.log("Yes calender 2",attrs.isblockdate)
- element.datepicker({
- dateFormat: 'dd-mm-yy',
- /*onSelect: function (date) {
- console.log(datefor)
- $scope.$parent.$apply();
- }
- */
- onSelect: function (selected) {
- /*var date1 = $('#vechcal2').datepicker('getDate');
- date1.setDate(date1.getDate()-5);
- $("#vechcal1").datepicker({"minDate": date1});*/
- $scope.$parent.vendtdate = selected;
- //$scope.$parent.formData.publishdates = selected;
- //console.log($scope.$parent.vendtdate);
- $rootScope.enddate = selected;
- //$scope.$parent.$apply();
- //$rootScope.vendtdate = selected;
- }
- });
- }
- }
- }
- })
- app.directive('ngMonthPick', function ($rootScope) {
- return {
- restrict: 'A',
- require: '?ngModel',
- scope: {
- date: "=",
- onSubmit: "&onSelect"
- },
- link: function (scope, element, attrs, ngModel) {
- element.datepicker({
- changeMonth: true,
- changeYear: true,
- showButtonPanel: true,
- viewMode: "months",
- minViewMode: "months",
- pickTime: false,
- dateFormat: 'MM yy',
- maxDate:0,
- onChangeMonthYear:function(){
- $('.ui-datepicker-calendar').css({
- display: "none"
- })
- },
- onClose: function(dateText, inst) {
-
- $('.ui-datepicker-calendar').css({
- display: "none"
- })
- function isDonePressed(){
- return ($('#ui-datepicker-div').html().indexOf('ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all ui-state-hover') > -1);
- }
- if (isDonePressed()){
- var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
- var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
- $(this).datepicker('setDate', new Date(year, month, 1)).trigger('change');
-
-
- }
- },
- beforeShow: function(input, ele) {
- var rect = input.getBoundingClientRect();
- setTimeout(function () {
- ele.dpDiv.css({ top: rect.top + 40, left: rect.left + 0 });
- }, 0);
- $('.ui-datepicker-calendar').css({
- display: "none"
- })
-
- if ((datestr = $(this).val()).length > 0) {
- year = datestr.substring(datestr.length - 4, datestr.length);
- month = jQuery.inArray(datestr.substring(0, datestr.length - 5), $(this).datepicker('option', 'monthNames'));
- $(this).datepicker('option', 'defaultDate', new Date(year, month, 1));
- $(this).datepicker('setDate', new Date(year, month, 1));
- }
-
- var other = this.id == "from" ? "#to" : "#from";
- var option = this.id == "from" ? "maxDate" : "minDate";
- if ((selectedDate = $(other).val()).length > 0) {
- year = selectedDate.substring(selectedDate.length - 4, selectedDate.length);
- month = jQuery.inArray(selectedDate.substring(0, selectedDate.length - 5), $(this).datepicker('option', 'monthNames'));
- $(this).datepicker("option", option, new Date(year, month, 1));
- }
-
- }
-
- })
- .on("click",function(e){
-
- $('.ui-datepicker-calendar').css({
- display: "none"
- })
- })
- $('.custom_month').focusin(function(){
-
- $('.ui-datepicker-calendar').css("display","none");
- });
- }
- }
- })
- app.directive('monthPick', function ($rootScope) {
- return {
- restrict: 'A',
- require: '?ngModel',
- scope: {
- },
- link: function (scope, element, attrs, ngModel) {
- // console.log(element)
- element.datepicker({
- changeMonth: true,
- changeYear: true,
- showButtonPanel: true,
- dateFormat: 'MM yy',
- maxDate:0,
- onClose: function(dateText, inst) {
- // console.log("inst-->",inst)
- $(this).datepicker('setDate', new Date(inst.selectedYear, inst.selectedMonth, 1));
- }
- })
- }
- }
- });
- // app.directive('datetimez', function ($rootScope) {
- // return {
- // restrict: 'A',
- // require: 'ngModel',
- // link: function (scope, element, attrs, ngModelCtrl) {
- // element.datetimepicker({
- // format: "MM-yyyy",
- // viewMode: "months",
- // minViewMode: "months",
- // pickTime: false,
- // }).on('changeDate', function (e) {
- // $('.bootstrap-datetimepicker-widget').css({
- // display: "none"
- // })
- // console.log(e, e.date.getMonth(), attrs)
- // ngModelCtrl.$setViewValue(e.date);
- // scope.$apply();
- // });
- // }
- // };
- // });
- app.service("AppData", function ($rootScope, $http, $httpParamSerializerJQLike) {
- $http.defaults.transformRequest.unshift($httpParamSerializerJQLike);
- $rootScope.loadingCont = false;
- //EDIT 20 Sept
- var url_str =window.location.href;
- if(url_str.indexOf('.cygnusa.in') !== -1)
- {
- var url_arr=url_str.split("cygnusa.in/");
- $rootScope.static_url = url_arr[0]+"cygnusa.in/";
- }else{
- // $rootScope.static_url = "https://hyper-m-dev.cygnusa.in/";
- $rootScope.static_url = "https://hyper-m.cygnusa.in/";
- }
- var data = {};
- data.sendData = sendData;
- data.checkArrayValue = checkArrayValue;
- function rand() {
- return (new Date()).getTime();
- }
- function checkArrayValue(arr, type, value) {
- var obj = {};
- obj.cont = false;
- for (var id = 0; id < arr.length; id++) {
- if (arr[id][type] == value) {
- obj.cont = true;
- obj.mid = id;
- break;
- }
- }
- return obj;
- }
- function sendData(urllink, data, returnFun) {
- // console.log(urllink)
- $rootScope.loadingCont = true;
- var req = {
- method: 'POST',
- url: $rootScope.static_url + urllink + rand(),
- // url: urllink + rand(),
- headers: { "Connection": "Keep-Alive", 'Content-Type': 'application/x-www-form-urlencoded' },
- data: data
- }
- $http(req).then(function (res) {
- $rootScope.loadingCont = false
- if (returnFun != undefined) {
- returnFun(res.data);
- }
- }, function () {
- });
- }
- return data;
- })
- app.directive('setHeight', function ($window) {
- return {
- link: function (scope, element, attrs) {
- element.css('height', $window.innerHeight - 105 + 'px');
- //element.height($window.innerHeight/3);
- }
- }
- })
- app.directive('uibPagination', function ($rootScope) {
- return {
- templateUrl: "module/pagination.html",
- restrict: 'E',
- transclude: true,
- replace: true,
- backdrop: 'static',
- scope: {
- show: '=',
- type: '=',
- },
- replace: true, // Replace with the template below
- transclude: true, // we want to insert custom content inside the directive
- link: function ($scope, element, attrs) {
- // console.log(attrs)
- $('#' + attrs.id).css('display', 'block');
- $scope.dialogStyle = {};
- if (attrs.width) {
- $scope.dialogStyle.width = attrs.width;
- }
- if (attrs.height) {
- $scope.dialogStyle.height = attrs.height;
- }
- $scope.$watch(function (value) {
- });
- $scope.hideModal = function () {
- $scope.show = false;
- $scope.type = false;
- };
- $scope.okModal = function () {
- $rootScope.$broadcast('cofirm');
- $scope.show = false;
- $scope.type = false;
- };
- }
- };
- });
- app.directive('multipleAutocomplete', [
- '$filter',
- '$http',
- function ($filter, $http) {
- return {
- restrict: 'EA',
- scope: {
- suggestionsArr: '=?',
- modelArr: '=ngModel',
- apiUrl: '@',
- beforeSelectItem: '=?',
- afterSelectItem: '=?',
- beforeRemoveItem: '=?',
- afterRemoveItem: '=?'
- },
- templateUrl: 'multiple-autocomplete-tpl.html',
- link: function (scope, element, attr) {
- scope.objectProperty = attr.objectProperty;
- scope.selectedItemIndex = 0;
- scope.name = attr.name;
- scope.isRequired = attr.required;
- scope.errMsgRequired = attr.errMsgRequired;
- scope.isHover = false;
- scope.isFocused = false;
- var getSuggestionsList = function () {
- var url = scope.apiUrl;
- $http({
- method: 'GET',
- url: url
- }).then(function (response) {
- scope.suggestionsArr = response.data;
- }, function (response) {
- });
- };
- if (scope.suggestionsArr == null || scope.suggestionsArr == "") {
- if (scope.apiUrl != null && scope.apiUrl != "")
- getSuggestionsList();
- else {
- }
- }
- // console.log("scope.modelArr ", scope.modelArr)
- if (scope.modelArr == null || scope.modelArr == "" || scope.modelArr == undefined) {
- scope.modelArr = [];
- }
- // console.log(scope.modelArr)
- scope.onFocus = function () {
- scope.isFocused = true
- };
- scope.onMouseEnter = function () {
- scope.isHover = true
- };
- scope.onMouseLeave = function () {
- scope.isHover = false;
- };
- scope.onBlur = function () {
- scope.isFocused = false;
- };
- scope.onChange = function () {
- scope.selectedItemIndex = 0;
- };
- scope.keyParser = function ($event) {
- var keys = {
- 38: 'up',
- 40: 'down',
- 8: 'backspace',
- 13: 'enter',
- 9: 'tab',
- 27: 'esc'
- };
- var key = keys[$event.keyCode];
- if (key == 'backspace' && scope.inputValue == "") {
- if (scope.modelArr.length != 0) {
- scope.removeAddedValues(scope.modelArr[scope.modelArr.length - 1]);
- //scope.modelArr.pop();
- }
- }
- else if (key == 'down') {
- var filteredSuggestionArr = $filter('filter')(scope.suggestionsArr, scope.inputValue);
- filteredSuggestionArr = $filter('filter')(filteredSuggestionArr, scope.alreadyAddedValues);
- if (scope.selectedItemIndex < filteredSuggestionArr.length - 1)
- scope.selectedItemIndex++;
- }
- else if (key == 'up' && scope.selectedItemIndex > 0) {
- scope.selectedItemIndex--;
- }
- else if (key == 'esc') {
- scope.isHover = false;
- scope.isFocused = false;
- }
- else if (key == 'enter') {
- var filteredSuggestionArr = $filter('filter')(scope.suggestionsArr, scope.inputValue);
- filteredSuggestionArr = $filter('filter')(filteredSuggestionArr, scope.alreadyAddedValues);
- if (scope.selectedItemIndex < filteredSuggestionArr.length)
- scope.onSuggestedItemsClick(filteredSuggestionArr[scope.selectedItemIndex]);
- }
- };
- scope.onSuggestedItemsClick = function (selectedValue) {
- if (scope.modelArr == null || scope.modelArr == "" || scope.modelArr == undefined) {
- scope.modelArr = [];
- }
- if (scope.beforeSelectItem && typeof (scope.beforeSelectItem) == 'function')
- scope.beforeSelectItem(selectedValue);
- scope.modelArr.push(selectedValue);
- // console.log(scope.modelArr)
- if (scope.afterSelectItem && typeof (scope.afterSelectItem) == 'function')
- scope.afterSelectItem(selectedValue);
- scope.inputValue = "";
- };
- var isDuplicate = function (arr, item) {
- var duplicate = false;
- if (arr == null || arr == "")
- return duplicate;
- for (var i = 0; i < arr.length; i++) {
- duplicate = angular.equals(arr[i], item);
- if (duplicate)
- break;
- }
- return duplicate;
- };
- scope.alreadyAddedValues = function (item) {
- var isAdded = true;
- isAdded = !isDuplicate(scope.modelArr, item);
- //if(scope.modelArr != null && scope.modelArr != ""){
- // isAdded = scope.modelArr.indexOf(item) == -1;
- // console.log("****************************");
- // console.log(item);
- // console.log(scope.modelArr);
- // console.log(isAdded);
- //}
- return isAdded;
- };
- scope.removeAddedValues = function (item) {
- if (scope.modelArr != null && scope.modelArr != "") {
- var itemIndex = scope.modelArr.indexOf(item);
- if (itemIndex != -1) {
- if (scope.beforeRemoveItem && typeof (scope.beforeRemoveItem) == 'function')
- scope.beforeRemoveItem(item);
- scope.modelArr.splice(itemIndex, 1);
- if (scope.afterRemoveItem && typeof (scope.afterRemoveItem) == 'function')
- scope.afterRemoveItem(item);
- }
- }
- };
- scope.mouseEnterOnItem = function (index) {
- scope.selectedItemIndex = index;
- };
- }
- };
- }
- ]);
- return angularAMD.bootstrap(app);
- });
|