function autoFocus($timeout) { return { link: function (scope, element, attrs) { attrs.$observe("autoFocus", function(newValue){ if (newValue === "true") $timeout(function(){element.focus()}); }); } }; }; function autofocusIf($timeout) { return { restrict: 'A', scope: { autofocusIf: '&' }, link: function($scope, $element) { $scope.$watch('autofocusIf', function(shouldFocus) { if (shouldFocus()) { $timeout(function() { $element[0].focus(); }); } else { $timeout(function() { $element[0].blur(); }); } }); } }; }; function btnClick(users,post) { return { restrict: 'A', scope: { dataform:'=', result:'=', }, link: function (scope, element, attrs) { element.bind('click', function() { var user = users.data(); var input = attrs.fid; var pid = attrs.btnClick; var grp = attrs.grp; var file = attrs.file; var func = attrs.func; var data = ''; var param = {rt: grp + '.' + file +'.' + func,id:input, user:user, pid:pid, tms:tms(), data: scope.dataform}; busy(); post(param).success(function(e){ rest(); if(e == 0){ toastr.error(e, 'Unsuccessfull',{timeOut: 5000}); console.log(e); } else { scope.result = e; toastr.success('Successfull'); } }); }); } }; }; function calendar ($timeout) { return { restrict: 'A', require: 'ngModel', scope: { ngModel: "=", from: "=", to: "=", duraday: "=", }, link: function(scope, el, attr, ngModel) { $timeout(function(){ // scope.$apply(attr.ngModel + "='test'"); // var dt = new Date(); // scope.$apply(attr.ngModel + "='test'"); var myformat = "yyyy-mm-dd"; $(el).attr('readonly','readonly'); // $(el).attr('placeholder','Enter date...'); var input = $(el); var attrib = { // keyboardNavigation: false, // forceParse: false, // autoclose: true, format: myformat, // startDate: "2019-09-02", // endDate: endYear, // minViewMode: "months", // maxViewMode: "years", // viewDate: new Date(), // onSelect: function(dateText) { // scope.$apply(function() { // ngModel.$setViewValue(dateText); // }); // // var expression = attr.ngModel + " = " + "'" + dateText + "'"; // // scope.$apply(expression); // } } if(attr.viewWeek){ attrib.calendarWeeks = attr.viewWeek; } if(attr.minViewMode){ attrib.minViewMode = attr.minViewMode; } if(attr.startDate){ attrib.startDate = new Date(attr.startDate); } if(attr.endDate){ attrib.endDate = new Date(attr.endDate); //new Date(new Date().getFullYear(), 11, 31); } if(attr.datepicker == "now"){ // input.datepicker("setDate", new Date()); attrib.setDate = new Date(); } input.datepicker(attrib); // $(input[0].firstChild).css('margin','auto'); if(scope.ngModel == '0000-00-00'){ // attrib.defaultDate = new Date(); } input.on('changeDate',function(e){ var curDate = strtodate(e.date); var getDate = curDate; if(attr.format){ getDate = ''; var aDate = curDate.split('-'); // attrib.format = attr.format; var f = attr.format.toUpperCase(); var fmx = f.length; var strf = ''; var mtchY = 0; var mtchM = 0; var mtchD = 0; var sparator = ''; for (var i = 0; i < fmx; i++) { if(f[i] == 'Y'){ mtchY += 1; } if(f[i] == 'M'){ mtchM += 1; } if(f[i] == 'D'){ mtchD += 1; } if(f[i] == '-'){ sparator = f[i]; } if(f[i] == '/'){ sparator = f[i]; } } var obj = {}; if(mtchY == 1){ obj.Y = aDate[0].substr(2); } else if(mtchY > 1){ obj.Y = aDate[0]; } if(mtchM > 0) obj.M = aDate[1]; if(mtchD > 0) obj.D = aDate[2]; var match = ''; var str = ''; for (var i = 0; i < f.length; i++) { if(match == f[i]) continue; match = f[i]; if(obj[match]) { str += obj[match]; } else { str += match } } getDate = str; } scope.$apply(function() { return ngModel.$setViewValue(getDate); }); }); // input.on('changeDate',function(e){ // var currMonth = new Date(e.date).getMonth() + 1; // var currYear = String(e.date).split(" ")[3]; // var currMthYr = currYear+currMonth; // }) }, 50); } }; } /** * chatSlimScroll - Directive for slim scroll for small chat */ function chatSlimScroll ($timeout) { return { restrict: 'A', link: function(scope, element) { $timeout(function(){ element.slimscroll({ height: '234px', railOpacity: 0.4 }); }); } }; }; function checkClick(users,post) { return { restrict: 'A', scope: { // dataform:'=', result: '=', val: '=ngModel', }, link: function (scope, element, attrs) { element.bind('click', function() { var user = users.data(); var pid = attrs.checkClick; var grp = attrs.grp; var file = attrs.file; var func = attrs.func; var data = ''; var rt = attrs.rt.split('_').join('.'); var param = {rt:rt, user:user, pid:pid, val: scope.val}; if(attrs.fid) { input = attrs.fid; param.id = input; } param.tms = 0; if(scope.val == 1){ param.tms = attrs.temp; } busy(); post(param).success(function(e){ rest(); if(e == 0){ toastr.error(e, 'Unsuccessfull',{timeOut: 5000}); console.log(e); } else { if(scope.result) scope.result = e; // toastr.success('Successfull'); } }); }); } }; }; function checkVal ($timeout) { return { scope: { checkVal: '=', value: '@' }, link: function(scope, elem, attrs ) { var handler = function(setup) { if (setup){ // console.log ('value1 = '+ scope.value) var checked = scope.checkVal&scope.value; elem.prop('checked', checked); }else{ // console.log ('value2 = '+ scope.value) var checked = elem.prop('checked'); if (!scope.checkVal&scope.value) scope.checkVal |= scope.value else scope.checkVal ^= scope.value } // console.log ('bit = '+ scope.checkVal) // console.log ('value = '+ scope.value) // console.log ('checked ='+ checked) }; var setupHandler = handler.bind(null, true); var changeHandler = handler.bind(null, false); elem.on('change', function() { scope.$apply(changeHandler); }); scope.$watch('checkVal', setupHandler, true); } }; }; /** * clockPicker - Directive for clock picker plugin */ function clockPicker1 () { return { restrict: 'A', link: function(scope, element) { element.clockpicker(); } }; }; function clockpicker ($timeout){ // $('#dtout,#dtin').clockpicker(); return { restrict: 'A', link: function(scope, el, attr){ $timeout(function(){ $(el).clockpicker({ placement: 'bottom', align: 'left', autoclose: false, twelvehour:false, 'default': 'now', donetext: 'Done', }); },50); } }; } function closeOffCanvas() { return { restrict: 'A', template: '', controller: function ($scope, $element) { $scope.closeOffCanvas = function () { $("body").toggleClass("mini-navbar"); } } }; }; function createInput ($compile){ return { template: '
', replace: true, link: function(scope, element) { var validate = scope.input.validform +'.' + scope.input.name; var required = scope.input.required; var el = angular.element('
'); switch(scope.input.inputType) { case 'checkbox': // el.append(''); el.append(''); break; case 'text': // el.append(''); el.append(''); el.append('

Ruangan ini diperlukan.

'); break; } $compile(el)(scope); element.append(el); } } } /** * customValid - Directive for custom validation example */ function customValid (){ return { require: 'ngModel', link: function(scope, ele, attrs, c) { scope.$watch(attrs.ngModel, function() { // You can call a $http method here // Or create custom validation var validText = "Inspinia"; if(scope.extras == validText) { c.$setValidity('cvalid', true); } else { c.$setValidity('cvalid', false); } }); } } }; function datepicker ($timeout) { return { restrict: 'A', require: 'ngModel', scope: { ngModel: "=", from: "=", to: "=", duraday: "=", }, link: function(scope, el, attr) { $timeout(function(){ // scope.$apply(attr.ngModel + "='test'"); // var dt = new Date(); // scope.$apply(attr.ngModel + "='test'"); var len = attr.datepicker.length; var myformat = "yyyy-mm-dd"; $(el).attr('readonly','readonly'); // $(el).attr('placeholder','Enter date...'); // if(len==10) myformat = attr.datepicker; var input = $(el); var attrib = { keyboardNavigation: false, forceParse: false, autoclose: true, format: myformat, // startDate: "2019-09-02", // endDate: endYear, // minViewMode: "months", // maxViewMode: "years", // viewDate: new Date(), // onSelect: function(dateText) { // scope.$apply(function() { // ngModel.$setViewValue(dateText); // }); // // var expression = attr.ngModel + " = " + "'" + dateText + "'"; // // scope.$apply(expression); // } } if(attr.viewWeek){ attrib.calendarWeeks = attr.viewWeek; } if(attr.minViewMode){ attrib.minViewMode = attr.minViewMode; } if(attr.format){ attrib.format = attr.format; } if(attr.startDate){ attrib.startDate = new Date(attr.startDate); } if(attr.endDate){ attrib.endDate = new Date(attr.endDate); //new Date(new Date().getFullYear(), 11, 31); } if(attr.datepicker == "now"){ // input.datepicker("setDate", new Date()); attrib.setDate = new Date(); } input.datepicker(attrib); if(scope.ngModel == '0000-00-00'){ // attrib.defaultDate = new Date(); } // input.on('changeDate',function(e){ // var currMonth = new Date(e.date).getMonth() + 1; // var currYear = String(e.date).split(" ")[3]; // var currMthYr = currYear+currMonth; // // scope.$apply(function() { // // ngModel.$setViewValue(currMthYr); // // }); // }) dura(); }, 50); function dura(){ var a = scope.from; var b = scope.to; var difference; if(a){ difference = dateDiffInDays(a, scope.ngModel); } else if(b){ difference = dateDiffInDays(scope.ngModel, b); } if(isNumber(difference)){ difference += ' days'; } // modelSetter(scope, difference); scope.duraday = difference; scope.$apply(); } el.on('change', function (e) { e.stopPropagation(); e.preventDefault(); dura(); return false; }); } }; } function datepickerButton () { return { restrict: 'EA', require: '?ngModel', scope: { name:'@', }, template: '', link: function(scope, el, attr, controller) { // if(!controller) return; // do nothing if no ng-model var attrib = { // keyboardNavigation: false, // forceParse: false, autoclose: true, toggleActive: false, setDate: new Date(), todayHighlight: true, // daysOfWeekHighlighted: "0", } if(attr.viewWeek){ attrib.calendarWeeks = attr.viewWeek; } if(attr.minViewMode){ attrib.minViewMode = attr.minViewMode; } if(attr.format){ attrib.format = attr.format; } if(attr.startDate){ attrib.startDate = new Date(attr.startDate); } if(attr.endDate){ attrib.endDate = new Date(attr.endDate); } if(attr.datepickerBtn == "now"){ attrib.setDate = new Date(); } el.datepicker(attrib).on('changeDate',function(e){ var value = el.find('input').val(); if(attr.callback) { var callback = attr.callback; var parent = scope.$parent; var p = parent[callback]; p(value); // controller.$formatters.push(function(value) { // // viewValue = value // }); } }) } }; } function decimal () { return { require: '?ngModel', link: function(scope, element, attrs, ngModelCtrl) { if(!ngModelCtrl) { return; } ngModelCtrl.$parsers.push(function(val) { if (angular.isUndefined(val)) { var val = ''; } var clean = val.replace(/[^-0-9\.]/g, ''); var negativeCheck = clean.split('-'); var decimalCheck = clean.split('.'); if(!angular.isUndefined(negativeCheck[1])) { negativeCheck[1] = negativeCheck[1].slice(0, negativeCheck[1].length); clean =negativeCheck[0] + '-' + negativeCheck[1]; if(negativeCheck[0].length > 0) { clean =negativeCheck[0]; } } if(!angular.isUndefined(decimalCheck[1])) { decimalCheck[1] = decimalCheck[1].slice(0,2); clean =decimalCheck[0] + '.' + decimalCheck[1]; } if (val !== clean) { ngModelCtrl.$setViewValue(clean); ngModelCtrl.$render(); } return clean; }); element.bind('keypress', function(event) { if(event.keyCode === 32) { event.preventDefault(); } }); } }; } function drawComponent($compile){ return{ restrict: 'EA', // scope : { type:'@', post:'@', text:'@', func:'@' }, scope: false, replace: true, link: function(scope, element, attrs){ var tpl; var el; function isEmpty(str) { return (!str || 0 === str.length); } function getType(p) { if (Array.isArray(p)) return 'array'; // else if (typeof p == 'string') return 'string'; else if (p != null && typeof p == 'object') return 'object'; else return 'string'; } function oAlign(o){ var m; switch (o) { case 'C': return 'text-center'; break; case 'L': return 'text-left'; break; case 'R': return 'text-right'; break; default: } return m; } function tempObj(e){ var obj = e.element; var o; var attr = ''; var target = e; if(obj == undefined) return e; if(e.hasOwnProperty('attrib')){ attr += attribute(e); } else { for(var key in target){ var value = target[key]; if(key == 'element' || key == 'content') continue; if(!isEmpty(attr)) attr += ' '; if(value !== 'null'){ attr += key + '="' + target[key] + '"'; } else { attr += key; } } } switch (obj) { case 'break': o = '
'; break; case 'a': case 'b': case 'button': case 'div': case 'form': case 'fieldset': case 'h1': case 'h2': case 'h3': case 'h4': case 'h5': case 'h6': case 'i': case 'iframe': case 'label': case 'li': case 'option': case 'p': case 'picture': case 'span': case 'strong': case 'style': case 'script': case 'select': case 'small': case 'table': case 'textarea': case 'thead': case 'tbody': case 'tfoot': case 'tr': case 'td': case 'th': case 'ul': var c = e.content; var dtyp = getType(c); o = '<' + obj + ' ' + attr + '>'; switch (dtyp) { case 'array': c.forEach(function(d) { o += tempObj(d); }); break; case 'object': o += tempObj(c); break; default: if(c !== undefined) o += c; } o += ''; break; case 'hr': case 'br': case 'img': case 'input': var c = e.content; if(c == undefined) c = ''; o = '<' + obj + ' ' + attr + '>' + c; break; case 'ibox': var head = e.header; var htyp = getType(head); var body = e.body; var dtyp = getType(body); o = '
'; if(head){ o += '
'; switch (htyp) { case 'array': head.forEach(function(d) { o += tempObj(d); }); break; case 'object': o += tempObj(head); break; default: o += head; } o += '
'; } if(body){ o += '
'; switch (dtyp) { case 'array': body.forEach(function(d) { o += tempObj(d); }); break; case 'object': o += tempObj(body); break; default: o += body; } o += '
'; } o += '
'; break; case 'static': o = '

'; break; case 'tabled': var atrb = attribute(e); o = ''; // thead if(e.hasOwnProperty('thead')){ o += elmt('thead',e,'tr',function(e){ return elmt('tr',e,'th',function(k){ return elmt('th',k,'val',function(k){ return elmt(k); }); }); }) } // tbody if(e.hasOwnProperty('tbody')){ o += elmt('tbody',e,'tr',function(e){ return elmt('tr',e,'td',function(k){ return elmt('td',k,'val',function(e){ return elmt(e); }); }); }) } o += '
'; break; default: o = 'NONE'; } return o; } function attribute(a){ var ret = ''; if(a.hasOwnProperty('attrib')){ var atrb = a.attrib; if(Array.isArray(atrb)){ for(var i = 0; i0) ret += ' '; ret += atrb[i]; } } else { ret = atrb; } } return ret; } function elmt(el,data,find,arg){ var o = '' ; if(data !== undefined){ var obj = data[el]; if(obj === undefined){ obj = data; } if(obj.hasOwnProperty(find)){ o += '<'+el+' ' + attribute(obj) + '>'; o += arg(obj[find]); o += ''; } else { for(var i=0; i'; o += arg(arr[find]); o += ''; } } } else { return el; } return o; } tpl = tempObj(scope.ele); el = $compile(tpl)(scope); element.replaceWith(el); }, controller: function($scope){ $('[data-toggle="tooltip"]').tooltip(); // change date // $(document).on('focusout','.datetime',function(e){ // var name = $(this).attr('name'); // var date = $(this).val(); // $scope.data[name] = $(this).val(); // }) } } }; function drawComponent1($compile){ return{ restrict: 'EA', // scope : { type:'@', post:'@', text:'@', func:'@' }, scope: false, replace: true, link: function(scope, element, attrs){ var tpl; var el; function isEmpty(str) { return (!str || 0 === str.length); } function getType(p) { if (Array.isArray(p)) return 'array'; // else if (typeof p == 'string') return 'string'; else if (p != null && typeof p == 'object') return 'object'; else return 'string'; } function oAlign(o){ var m; switch (o) { case 'C': return 'text-center'; break; case 'L': return 'text-left'; break; case 'R': return 'text-right'; break; default: } return m; } function tempObj(e){ var obj = e.element; var o; var attr = ''; var target = e; if(obj == undefined) return e; if(e.hasOwnProperty('attrib')){ attr += attribute(e); } else { for(var key in target){ var value = target[key]; if(key == 'element' || key == 'content') continue; if(!isEmpty(attr)) attr += ' '; if(value !== 'null'){ attr += key + '="' + target[key] + '"'; } else { attr += key; } } } switch (obj) { case 'break': o = '
'; break; case 'a': case 'b': case 'button': case 'div': case 'form': case 'fieldset': case 'h1': case 'h2': case 'h3': case 'h4': case 'h5': case 'h6': case 'i': case 'iframe': case 'label': case 'li': case 'option': case 'p': case 'picture': case 'span': case 'strong': case 'style': case 'script': case 'select': case 'small': case 'table': case 'textarea': case 'thead': case 'tbody': case 'tfoot': case 'tr': case 'td': case 'th': case 'ul': var c = e.content; var dtyp = getType(c); o = '<' + obj + ' ' + attr + '>'; switch (dtyp) { case 'array': c.forEach(function(d) { o += tempObj(d); }); break; case 'object': o += tempObj(c); break; default: if(c !== undefined) o += c; } o += ''; break; case 'hr': case 'br': case 'img': case 'input': var c = e.content; if(c == undefined) c = ''; o = '<' + obj + ' ' + attr + '>' + c; break; case 'ibox': var head = e.header; var htyp = getType(head); var body = e.body; var dtyp = getType(body); o = '
'; if(head){ o += '
'; switch (htyp) { case 'array': head.forEach(function(d) { o += tempObj(d); }); break; case 'object': o += tempObj(head); break; default: o += head; } o += '
'; } if(body){ o += '
'; switch (dtyp) { case 'array': body.forEach(function(d) { o += tempObj(d); }); break; case 'object': o += tempObj(body); break; default: o += body; } o += '
'; } o += '
'; break; case 'static': o = '

'; break; case 'tabled': var atrb = attribute(e); o = ''; // thead if(e.hasOwnProperty('thead')){ o += elmt('thead',e,'tr',function(e){ return elmt('tr',e,'th',function(k){ return elmt('th',k,'val',function(k){ return elmt(k); }); }); }) } // tbody if(e.hasOwnProperty('tbody')){ o += elmt('tbody',e,'tr',function(e){ return elmt('tr',e,'td',function(k){ return elmt('td',k,'val',function(e){ return elmt(e); }); }); }) } o += '
'; break; default: o = 'NONE'; } return o; } function attribute(a){ var ret = ''; if(a.hasOwnProperty('attrib')){ var atrb = a.attrib; if(Array.isArray(atrb)){ for(var i = 0; i0) ret += ' '; ret += atrb[i]; } } else { ret = atrb; } } return ret; } function elmt(el,data,find,arg){ var o = '' ; if(data !== undefined){ var obj = data[el]; if(obj === undefined){ obj = data; } if(obj.hasOwnProperty(find)){ o += '<'+el+' ' + attribute(obj) + '>'; o += arg(obj[find]); o += ''; } else { for(var i=0; i'; o += arg(arr[find]); o += ''; } } } else { return el; } return o; } tpl = tempObj(scope.ele); el = $compile(tpl)(scope); element.replaceWith(el); }, controller: function($scope){ $('[data-toggle="tooltip"]').tooltip(); // change date // $(document).on('focusout','.datetime',function(e){ // var name = $(this).attr('name'); // var date = $(this).val(); // $scope.data[name] = $(this).val(); // }) } } }; /** * dropZone - Directive for Drag and drop zone file upload plugin */ function dropZone () { return { restrict: 'C', link: function(scope, element, attrs) { var config = { url: 'http://localhost:8080/upload', maxFilesize: 100, paramName: "uploadfile", maxThumbnailFilesize: 10, parallelUploads: 1, autoProcessQueue: false }; var eventHandlers = { 'addedfile': function(file) { scope.file = file; if (this.files[1]!=null) { this.removeFile(this.files[0]); } scope.$apply(function() { scope.fileAdded = true; }); }, 'success': function (file, response) { } }; dropzone = new Dropzone(element[0], config); angular.forEach(eventHandlers, function(handler, event) { dropzone.on(event, handler); }); scope.processDropzone = function() { dropzone.processQueue(); }; scope.resetDropzone = function() { dropzone.removeAllFiles(); } } } }; function editSetting(uiModal,post,users) { return { link: function (scope, element, attr) { element.bind('click', function() { var user = users.data(); var id = attr.id; var name = attr.name; var mdata = attr.mdata; if(id == undefined) id = 0; var modal = { param: {rt:'setting.' + name + '.modal',id:id}, close: function(e){ var param = ''; if(e.mode == 1){ param = {rt:'setting.' + name + '.save',id:id,data:e.data,user:user}; } else if (e.mode == 9){ // delete param = {rt:'setting.' + name + '.delete',id:id,data:e.data,user:user}; } if(attr.group){ param.group = attr.group; } post(param).success(function(e){ if(isArray(e)){ scope.mdata[mdata] = e; // scope.$apply(function() { // // modelSetter(scope, element[0].files[0]); // }); } else { if(isNumber(e)){ console.log(e); } else { alert(e); } } }); }, dismiss: function(){} }; if(attr.size) modal.size = attr.size; uiModal(modal); }); } }; }; function fileDelete(users,post) { return { restrict: 'A', link: function (scope, element, attrs) { // element.bind('change', function(){ // // let files = element[0].files; // }); element.bind('click', function() { var user = users.data(); var input = attrs.fid; var pid = attrs.fileDelete; var grp = attrs.grp; var file = attrs.file; var mdata = attrs.mdata; var func = 'deletefile'; if(attrs.func){ func = attrs.func; } if(!confirm('Confirm to delete?')) return; busy(); var param = {rt: grp + '.' + file +'.' + func,id:input, user:user, pid:pid, tms:tms()}; post(param).success(function(e){ rest(); if(isArray(e)){ scope.mdata[mdata] = e; // $scope.files = []; } else { console.log(e); } }); }); } }; }; function fileModel($parse) { return { restrict: 'A', link: function(scope, element, attrs) { var model = $parse(attrs.fileModel); var modelSetter = model.assign; element.bind('change', function() { scope.$apply(function() { modelSetter(scope, element[0].files[0]); }); }); } }; }; function filePrint() { return { link: function (scope, element, attrs) { element.bind('click', function() { var newWin = window.frames["printout"]; newWin.print(); }); } }; }; function fileUpload(file,users,$parse) { return { restrict: 'A', link: function (scope, element, attrs) { // element.bind('change', function(){ // // let files = element[0].files; // }); element.bind('change', function() { var user = users.data(); var input = element[0].files; var pid = attrs.fileUpload; var grp = attrs.grp; var func = attrs.file; var mdata = attrs.mdata; if(input == undefined){ toastr.error('You did not select a file to upload.', 'Incomplete') return; } busy(); var param = {rt:grp + '.' + func +'.upload','file[]':input, user:user, pid:pid, tms:tms()}; file(param).success(function(e){ rest(); if(isArray(e)){ scope.mdata[mdata] = e; // input.list = []; } else { console.log(e); } }); }); element.on('$destroy', function() { element.off(); }); } }; }; /** * fitHeight - Directive for set height fit to window height */ function fitHeight(){ return { restrict: 'A', link: function(scope, element) { element.css("height", $(window).height() + "px"); element.css("min-height", $(window).height() + "px"); } }; } function focusOnShow ($timeout) { return { restrict: 'A', link: function($scope, $element, $attr) { if ($attr.ngShow){ $scope.$watch($attr.ngShow, function(newValue){ if(newValue){ $timeout(function(){ $element[0].focus(); }, 0); } }) } if ($attr.ngHide){ $scope.$watch($attr.ngHide, function(newValue){ if(!newValue){ $timeout(function(){ $element[0].focus(); }, 0); } }) } } }; } /** * fullScroll - Directive for slimScroll with 100% */ function fullScroll ($timeout){ return { restrict: 'A', link: function(scope, element) { $timeout(function(){ element.slimscroll({ height: '100%', railOpacity: 0.9 }); }); } }; }; /** * iboxTools - Directive for iBox tools elements in right corner of ibox */ function iboxTools($timeout) { return { restrict: 'A', scope: true, templateUrl: 'views/common/ibox_tools.html', controller: function ($scope, $element) { // Function for collapse ibox $scope.showhide = function () { var ibox = $element.closest('div.ibox'); var icon = $element.find('i:first'); var content = ibox.find('div.ibox-content'); content.slideToggle(200); // Toggle icon from up to down icon.toggleClass('fa-chevron-up').toggleClass('fa-chevron-down'); ibox.toggleClass('').toggleClass('border-bottom'); $timeout(function () { ibox.resize(); ibox.find('[id^=map-]').resize(); }, 50); }; // Function for close ibox $scope.closebox = function () { var ibox = $element.closest('div.ibox'); ibox.remove(); } } }; }; /** * iboxTools with full screen - Directive for iBox tools elements in right corner of ibox with full screen option */ function iboxToolsFullScreen($timeout) { return { restrict: 'A', scope: true, templateUrl: 'views/common/ibox_tools_full_screen.html', controller: function ($scope, $element) { // Function for collapse ibox $scope.showhide = function () { var ibox = $element.closest('div.ibox'); var icon = $element.find('i:first'); var content = ibox.find('div.ibox-content'); content.slideToggle(200); // Toggle icon from up to down icon.toggleClass('fa-chevron-up').toggleClass('fa-chevron-down'); ibox.toggleClass('').toggleClass('border-bottom'); $timeout(function () { ibox.resize(); ibox.find('[id^=map-]').resize(); }, 50); }; // Function for close ibox $scope.closebox = function () { var ibox = $element.closest('div.ibox'); ibox.remove(); }; // Function for full screen $scope.fullscreen = function () { var ibox = $element.closest('div.ibox'); var button = $element.find('i.fa-expand'); $('body').toggleClass('fullscreen-ibox-mode'); button.toggleClass('fa-expand').toggleClass('fa-compress'); ibox.toggleClass('fullscreen'); setTimeout(function() { $(window).trigger('resize'); }, 100); } } }; }; /** * icheck - Directive for custom checkbox icheck */ function icheck($timeout) { return { restrict: 'A', require: 'ngModel', link: function($scope, element, $attrs, ngModel) { return $timeout(function() { var value; value = $attrs['value']; $scope.$watch($attrs['ngModel'], function(newValue){ $(element).iCheck('update'); }) return $(element).iCheck({ checkboxClass: 'icheckbox_square-green', radioClass: 'iradio_square-green' }).on('ifChanged', function(event) { if ($(element).attr('type') === 'checkbox' && $attrs['ngModel']) { $scope.$apply(function() { return ngModel.$setViewValue(event.target.checked); }); } if ($(element).attr('type') === 'radio' && $attrs['ngModel']) { return $scope.$apply(function() { return ngModel.$setViewValue(value); }); } }); }); } }; }; /** * ionRangeSlider - Directive for Ion Range Slider */ function ionRangeSlider () { return { restrict: 'A', scope: { rangeOptions: '=' }, link: function (scope, elem, attrs) { elem.ionRangeSlider(scope.rangeOptions); } } }; /** * landingScrollspy - Directive for scrollspy in landing page */ function landingScrollspy (){ return { restrict: 'A', link: function (scope, element, attrs) { element.scrollspy({ target: '.navbar-fixed-top', offset: 80 }); } } } /** * markdownEditor - Directive for Bootstrap Markdown */ function markdownEditor() { return { restrict: "A", require: 'ngModel', link: function (scope, element, attrs, ngModel) { $(element).markdown({ savable:false, onChange: function(e){ ngModel.$setViewValue(e.getContent()); } }); } } } function ngConfirmClick(post,users,$state,uiModal){ return { scope: { get: '=', set: '=', action: '=', }, link: function (scope, element, attr) { var msg = attr.ngConfirmClick || "Are you sure?"; var clickAction = attr.confirmedClick; element.bind('click', function (e) { var user = users.data(); var param = Object.assign({rt:'job.general.confirmation', user:user, tms:tms()}, scope.get); // if (window.confirm(msg)) { // e.stopImmediatePropagation(); // e.preventDefault(); // scope.$eval(clickAction) // } uiModal({ param: param, close: function(e){ param = Object.assign({tms:tms(), user:user, data:e.data}, scope.set); post(param).success(function(e){ // if(attr.action){ // scope.$eval(attr.action) // } if(e == 0){ toastr.error(e,'Unsuccessfull',{timeOut:5000}); console.log(e); } else { if(scope.action) scope.action = e; toastr.success('Successfull');} }); }, }); }); } }; } function ngDuration($parse) { return { restrict: 'EA', scope: { ngDuration: '=', from: '=', to: '=', }, link: function (scope, element, attrs) { var a = scope.from; var b = scope.to; var difference; difference = dateDiffInDays(a, b); if(isNumber(difference)){ difference += ' days'; } scope.ngDuration = difference; // element.val(difference); } }; }; function ngEnter(){ return function (scope, element, attrs) { element.bind("keydown keypress", function (event) { if(event.which === 13) { scope.$apply(function (){ scope.$eval(attrs.ngEnter); }); event.preventDefault(); } }); }; }; function ngFile($timeout) { return { // link: function (scope, element, attrs) { // attrs.$observe("autoFocus", function(newValue){ // if (newValue === "true") // $timeout(function(){element.focus()}); // }); // } restrict: 'A', link: function (scope, element, attrs) { var onChangeFunc = scope.$eval(attrs.ngFile); element.bind('change', onChangeFunc); element.on('$destroy', function() { element.off(); }); } }; }; function ngFileModel($parse) { return { restrict: 'A', link: function (scope, element, attrs) { var model = $parse(attrs.ngFileModel); var is_single = attrs.single; // var isMultiple = attrs.multiple; var modelSetter = model.assign; element.bind('change', function () { var values = []; // var nm = ''; var fileinput = element[0].files; angular.forEach(fileinput, function (item) { var value = { // File Name name: item.name, //File Size size: item.size, //File URL to view url: URL.createObjectURL(item), // File Input Value _file: item }; values.push(value); // nm += item.name; }); scope.$apply(function () { var res; if (is_single) { res = {list:values[0], file:fileinput}; } else { res = {list:values, file:fileinput}; } modelSetter(scope, res); }); // var fileName = $(this).val().split("\\").pop(); // $(this).siblings(".custom-file-label").addClass("selected").html(nm); }); } }; }; function ngReceive(users,post,uiModal,$state,$window) { return { restrict: 'A', link: function (scope, element, attrs) { // element.bind('change', function(){ // // let files = element[0].files; // }); element.bind('click', function() { var user = users.data(); var input = attrs.fid; var pid = attrs.ngReceive; var grp = attrs.grp; var param = {rt: 'job.general.modalpaid',user:user, pid:pid, tms:tms(),group:grp}; if(input){ param.id = input; } var dialog = { param: param, size: 'lg', close: function(e){ busy(); var param = {rt: 'job.general.savepaid',pid:pid,data:e.data,user:user,tms:tms()}; if(input){ param.id = input; } post(param).success(function(e){ rest(); if(e == 102){ $state.go(grp + '.project'); } else if ( e == 101){ // toastr.success('Successfull payment received'); $window.location.reload(); } else if(e == 0){ toastr.error('Update payment was unsuccessful','Unsuccessfull',{timeOut: 5000}) console.log(e); } }); }, }; uiModal(dialog); }); } }; }; function ngWorkconfirm(post,users,$state,uiModal){ return { scope: { get: '=', set: '=', rt: '@', action: '=', callback: '=', }, link: function (scope, element, attr) { // var msg = attr.ngConfirmClick || "Are you sure?"; // var clickAction = attr.ngWorkconfirm; element.bind('click', function (e) { // if (window.confirm(msg)) { // e.stopImmediatePropagation(); // e.preventDefault(); // scope.$eval(clickAction) // } var pid = attr.ngWorkconfirm; var user = users.data(); var param = Object.assign({rt:'job.general.modalworkconfirm', user:user, tms:tms()}, scope.get); uiModal({ param: param, close: function(e){ var parampost = {rt: scope.rt, tms:tms(), user:user, data:e.data, pid: pid}; if(attr.id){ parampost.id = attr.id; } post(parampost).success(function(e){ if( e == 0 ){ toastr.error('Submmission unsuccessfull. please contact administrator','Unsuccessfull',{timeOut:5000}); console.log(e); } else { if(parseInt(e)){ if(scope.callback) { scope.callback(e); return; } if(attr.goto){ $state.go(attr.goto); return; } toastr.success('Successfull'); // users.setParam({id:e, pid: xpid}); // $state.go('oths.confirmation'); } else { toastr.error('Submmission unsuccessfull. please contact administrator','Unsuccessfull',{timeOut:5000}); console.log(e); } } }); }, }); }); } }; } function numbersWithSelect () { return { require: 'ngModel', restrict: 'A', link: function($scope, $element, attrs, model) { var max_length = parseInt(attrs.numbersWithSelect, 10); // $element.bind('keydown', function(e) { $element.bind('keypress', function(e) { // console.log(e.which); // if (e.which === 32) { // e.preventDefault(); // } var charCode = (e.which) ? e.which : event.keyCode; if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57)) { e.preventDefault(); return false; } else { return true; } }); $element.on('click', function () { this.select(); /* if (!$window.getSelection().toString()) { //Required for mobile Safari this.setSelectionRange(0, this.value.length) } */ }); var input_value_parser = function(value) { if(value.length > max_length) { value = value.substring(0, max_length); model.$setViewValue(value); model.$render(); } return value; }; model.$parsers.push(input_value_parser); } }; } function onlyNumbers () { return { require: 'ngModel', restrict: 'A', link: function($scope, $element, attrs, model) { var max_length = parseInt(attrs.onlyNumbers, 10); // $element.bind('keydown', function(e) { $element.bind('keypress', function(e) { // console.log(e.which); // if (e.which === 32) { // e.preventDefault(); // } var charCode = (e.which) ? e.which : event.keyCode; if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57)) { e.preventDefault(); return false; } else { return true; } }); var input_value_parser = function(value) { if(value.length > max_length) { value = value.substring(0, max_length); model.$setViewValue(value); model.$render(); } return value; }; model.$parsers.push(input_value_parser); } }; } function onlyNumbers1 () { return { require: 'ngModel', link: function(scope, element, attrs, modelCtrl) { modelCtrl.$parsers.push(function (inputValue) { // this next if is necessary for when using ng-required on your input. // In such cases, when a letter is typed first, this parser will be called // again, and the 2nd time, the value will be undefined if (inputValue == undefined) return '' var transformedInput = inputValue.replace(/[^0-9.]/g, ''); if (transformedInput!=inputValue) { modelCtrl.$setViewValue(transformedInput); modelCtrl.$render(); } return transformedInput; }); } }; } /** * pageTitle - Directive for set Page title - mata title */ function pageTitle($rootScope, $timeout) { return { link: function(scope, element) { var listener = function(event, toState, toParams, fromState, fromParams) { // Default title - load on Dashboard 1 var title = 'MZZ Setia | '; // Create your own title pattern if (toState.data && toState.data.pageTitle) title = 'MZZ Setia | ' + toState.data.pageTitle; $timeout(function() { element.text(title); }); }; $rootScope.$on('$stateChangeStart', listener); } } }; function preWrap($compile){ return { replace: true, restrict:"EA", transclude: true, scope: { model: '=', width: '@', }, link: function(scope, element, attrs) { var tpl = scope.model; if(tpl == undefined) return; /* Replace * to bold format */ // re = new RegExp('/\*.*?\*/g'); var re = /\*(.*?)\*/g; tpl = tpl.replace(re,"$1"); /* Replace _ to italic format */ var re = /\_(.*?)\_/g; tpl = tpl.replace(re,"$1"); // /* Replace [] to ul */ // // var re = /\[(.*?)\]/isg; // var re = /\[(.*?)\]/g; // // tpl = tpl.replace(re, '
    $1
'); // var data = tpl.match(re); // if(data){ // for(var i=0; i'; // } // ol += ''; // tpl = tpl.replace(data[i],ol); // } // } // // tpl = tpl.replace( /[\r\n]+/gm, "

" ); // tpl = '

' + tpl.replace( /[\r\n]+/gm, "

" ) + '

'; // tpl = tpl.replace('

-

','
'); // replace component var el = $compile(tpl)(scope); element.replaceWith('
' + tpl + '
'); } } }; function reject(post,users,$state) { return { link: function (scope, element, attrs) { element.bind('click', function() { if(!confirm("Do you want to return back?")) return; var user = users.data(); var rt = attrs.rt; //'job.tmm.reject' var xpid = attrs.id; var page = attrs.page; post({rt:'job.general.reject',id:xpid,user:user,tms:tms()}).success(function(e){ if(parseInt(e) == 1){ $state.go(page); //'tmm.project' } else { console.log(e); } }); }); } }; }; /** * responsibleVideo - Directive for responsive video */ function responsiveVideo() { return { restrict: 'A', link: function(scope, element) { var figure = element; var video = element.children(); video .attr('data-aspectRatio', video.height() / video.width()) .removeAttr('height') .removeAttr('width') //We can use $watch on $window.innerWidth also. $(window).resize(function() { var newWidth = figure.width(); video .width(newWidth) .height(newWidth * video.attr('data-aspectRatio')); }).resize(); } } }; function restrictTo ($timeout) { return { restrict: 'A', link: function (scope, element, attrs) { var re = RegExp(attrs.restrictTo); var exclude = /Backspace|Enter|Tab|Delete|Del|ArrowUp|Up|ArrowDown|Down|ArrowLeft|Left|ArrowRight|Right/; element[0].addEventListener('keydown', function(event) { if (!exclude.test(event.key) && !re.test(event.key)) { event.preventDefault(); } }); } } } function rowDelete(users,post,$window) { return { restrict: 'A', link: function (scope, element, attrs) { // element.bind('change', function(){ // // let files = element[0].files; // }); element.bind('click', function() { var user = users.data(); var input = attrs.fid; var pid = attrs.rowDelete; var grp = attrs.grp; var file = attrs.file; var mdata = attrs.mdata; var func = attrs.func; var reload = attrs.reload; var arr = mdata.split(','); if(!confirm('Confirm to delete?')) return; busy(); var param = {rt: grp + '.' + file +'.' + func,id:input, user:user, pid:pid, tms:tms()}; post(param).success(function(e){ rest(); if(reload){ $window.location.reload(); return } // if(parseInt(e) == 0){ // toastr.error(e,'Unsuccessfull',{timeOut: 5000}) // console.log(e); // return; // } if(isArray(e)){ scope.mdata[mdata] = e; } else if(isObject(e)){ for (var i = 0; i < arr.length; i++) { mdata = arr[i]; scope.mdata[mdata] = e[mdata]; } } else { toastr.error(e,'Unsuccessfull',{timeOut: 5000}); return; } toastr.success('Delete successfull'); }); }); } }; }; function rowEdit(users,post,uiModal,$state) { return { restrict: 'A', link: function (scope, element, attrs) { // element.bind('change', function(){ // // let files = element[0].files; // }); element.bind('click', function() { var user = users.data(); var input = attrs.fid; var pid = attrs.rowEdit; var grp = attrs.grp; var file = attrs.file; var mdata = attrs.mdata; var modal = ''; var ctrl = attrs.ctrl; if(attrs.modal){ modal = attrs.modal; } var func = 'submit'; if(attrs.func){ func = attrs.func; } // var param = {rt: grp + '.' + file +'.' + modal,id:input, user:user, pid:pid, tms:tms(),group:grp}; var param = {rt: grp + '.' + file +'.' + modal,user:user, pid:pid, tms:tms(),group:grp}; if(input){ param.id = input; } var dialog = { param: param, size: 'lg', close: function(e){ busy(); // var param = {rt: grp + '.' + file +'.' + func,id:input,pid:pid,data:e.data,user:user,tms:tms()}; var param = {rt: grp + '.' + file +'.' + func,pid:pid,data:e.data,user:user,tms:tms()}; if(input){ param.id = input; } post(param).success(function(e){ rest(); if(attrs.fn){ var fnstring = attrs.fn; scope.$eval(fnstring + '(' + e +')'); } else if(attrs.openpage) { $state.go(attrs.openpage); } else { if(e > 0){ toastr.success('Successfull'); } else if(isArray(e)){ scope.mdata[mdata] = e; toastr.success('Successfull'); } else { toastr.error(e,'Unsuccessfull',{timeOut: 5000}) console.log(e); } } }); }, }; if(ctrl){ dialog.controller = ctrl; } uiModal(dialog); }); } }; }; function rowNew(users,post,uiModal) { return { restrict: 'A', link: function (scope, element, attrs) { // element.bind('change', function(){ // // let files = element[0].files; // }); element.bind('click', function() { var user = users.data(); var pid = attrs.rowNew; var grp = attrs.grp; var file = attrs.file; var mdata = attrs.mdata; var func = ''; if(attrs.func){ func = attrs.func; } var func = 'submit'; if(attrs.func){ func = attrs.func; } var param = {rt: grp + '.' + file +'.' + func,id:0, user:user, pid:pid, tms:tms(),group:grp}; busy(); post(param).success(function(e){ rest(); if(e < 1){ toastr.error(e,'Unsuccessfull',{timeOut: 5000}) console.log(e); return; } scope.mdata[mdata] = e; toastr.success('Successfull'); }); }); } }; }; function rowViews(users,post,uiModal,$parse) { return { restrict: 'A', link: function (scope, element, attrs) { // element.bind('change', function(){ // // let files = element[0].files; // }); element.bind('click', function() { // var model = $parse(attrs.rowViews); // var modelSetter = model.assign; var user = users.data(); var input = attrs.fid; var pid = attrs.rowViews; var grp = attrs.grp; var file = attrs.file; var mdata = attrs.mdata; var scp = attrs.scp; var modal = ''; var ctrl = attrs.ctrl; if(attrs.modal){ modal = attrs.modal; } var param = {rt: grp + '.' + file +'.' + modal,id:input, user:user, pid:pid, tms:tms(),group:grp}; var dialog = { param: param, size: 'lg', close: function(e){ if(mdata){ scope.mdata[mdata] = e; } if(scp){ scope[scp] = e; } }, }; if(ctrl){ dialog.controller = ctrl; } uiModal(dialog); }); } }; }; function selectOnFocus ($timeout) { return { restrict: 'A', link: function (scope, element, attrs) { var focusedElement = null; element.on('focus', function () { var self = this; if (focusedElement != self) { focusedElement = self; $timeout(function () { self.select(); }, 10); } }); element.on('blur', function () { focusedElement = null; }); } } } function sendBack(post,users,$state,uiModal) { return { link: function (scope, element, attrs) { element.bind('click', function() { var user = users.data(); var pid = attrs.sendBack; var group = attrs.group; uiModal({ param: {rt:'job.general.sendbackmodal',pid:pid, tms:tms()}, close: function(e){ var param = {rt:'job.general.sendbacksave',pid:pid,data:e.data,user:user,tms:tms()}; post(param).success(function(e){ if(e == 1){ // toastr.success('Submit successfull'); $state.go(group + '.project') } else { toastr.error(e,'Unsuccessfull',{timeOut:5000}); console.log(e); } }); }, }); // post({rt:'job.general.reject',id:xpid,user:user,tms:tms()}).success(function(e){ // if(parseInt(e) == 1){ // $state.go(page); //'tmm.project' // } else { // console.log(e); // } // }); }); } }; }; function sendBackTo(post,users,$state,uiModal) { return { link: function (scope, element, attrs) { element.bind('click', function() { var user = users.data(); var pid = attrs.sendBackTo; var group = attrs.group; uiModal({ param: {rt:'job.general.modalreturnto',pid:pid, tms:tms()}, close: function(e){ var param = {rt:'job.general.savereturnto',pid:pid,data:e.data,user:user,tms:tms()}; post(param).success(function(e){ if(e == 1){ $state.go(group + '.project') } else { toastr.error(e,'Unsuccessfull',{timeOut:5000}); console.log(e); } }); }, }); }); } }; }; function sendTo(post,users,$state,uiModal) { return { link: function (scope, element, attrs) { element.bind('click', function() { var user = users.data(); var pid = attrs.sendTo; var group = attrs.group; uiModal({ param: {rt:'job.general.sendtomodal',pid:pid, tms:tms()}, close: function(e){ var param = {rt:'job.general.sendtosave',pid:pid,data:e.data,user:user,tms:tms()}; post(param).success(function(e){ if(e == 1){ // toastr.success('Submit successfull'); $state.go(group + '.project') } else { toastr.error(e,'Unsuccessfull',{timeOut:5000}); console.log(e); } }); }, }); // post({rt:'job.general.reject',id:xpid,user:user,tms:tms()}).success(function(e){ // if(parseInt(e) == 1){ // $state.go(page); //'tmm.project' // } else { // console.log(e); // } // }); }); } }; }; /** * sideNavigation - Directive for run metsiMenu on sidebar navigation */ function sideNavigation($timeout) { return { restrict: 'A', link: function(scope, element) { // Call the metsiMenu plugin and plug it to sidebar navigation $timeout(function(){ element.metisMenu(); }); } }; }; /** * slimScroll - Directive for slimScroll with custom height */ function slimScroll ($timeout){ return { restrict: 'A', scope: { boxHeight: '@' }, link: function(scope, element) { $timeout(function(){ element.slimscroll({ height: scope.boxHeight, railOpacity: 0.9 }); }); } }; } /** * sparkline - Directive for Sparkline chart */ function sparkline() { return { restrict: 'A', scope: { sparkData: '=', sparkOptions: '=', }, link: function (scope, element, attrs) { scope.$watch(scope.sparkData, function () { render(); }); scope.$watch(scope.sparkOptions, function(){ render(); }); var render = function () { $(element).sparkline(scope.sparkData, scope.sparkOptions); }; } } }; function stringToNumber(){ return { require: 'ngModel', link: function(scope, element, attrs, ngModel) { ngModel.$parsers.push(function(value) { return '' + value; }); ngModel.$formatters.push(function(value) { return parseFloat(value, 10); }); } }; }; function sumString () { return { scope: { sqty: '=', samt: '=', stotal: '=', qty: '=?qty', amt: '=', total: '=', }, link: function($scope, $element, attrs, model) { $element[0].addEventListener('keyup', function(event) { var charCode = (event.which) ? event.which : event.keyCode; var q = ''; var p = '' var total = 0; var tq = 0; var tp = 0; var st = ''; // 'up': 38,'right':39,'down':40,'left':37, // 'escape':27,'backspace':8,'tab':9,'enter':13,'del':46, // '0':48,'1':49,'2':50,'3':51,'4':52,'5':53,'6':54,'7':55,'8':56,'9':57 // '190':., // var keys = [38,39,40,37,27,8,9,13,46,48,49,50,51,52,53,54,55,56,57,190] ; // if(keys.indexOf(event.keyCode) == -1) { event.preventDefault(); return false} if($scope.sqty != undefined && $scope.samt != undefined){ // q = $scope.sqty.match(/[+-]?\d+(?:\.\d+)?/g).map(Number); // p = $scope.samt.match(/[+-]?\d+(?:\.\d+)?/g).map(Number); q = $scope.sqty.split('\n').map(Number); p = $scope.samt.split('\n').map(Number); for(var x in q){ var t = parseFloat(p[x] * q[x]); tq += q[x]; if(!isNaN(t)){ if(x > 0){ st += '\n'; } // st += '\n'; if(t > 0){ st += t.toFixed(2); } total += t; } if(p[x]) tp += p[x]; } } $scope.stotal = st; $scope.qty = tq; $scope.amt = tp; $scope.total = total.toFixed(2); if (!$scope.$$phase) $scope.$apply() }); } }; } function tdFormat($compile){ return { restrict:"A", replace: true, link: function(scope, element, attrs) { var tpl = attrs.tdFormat; /* Replace * to bold format */ // re = new RegExp('/\*.*?\*/g'); var re = /\*(.*?)\*/g; tpl = tpl.replace(re,"$1"); /* Replace _ to italic format */ var re = /\_(.*?)\_/g; tpl = tpl.replace(re,"$1"); /* Replace [] to ul */ // var re = /\[(.*?)\]/isg; var re = /\[(.*?)\]/g; // tpl = tpl.replace(re, '
    $1
'); var data = tpl.match(re); if(data){ for(var i=0; i'; } ol += ''; tpl = tpl.replace(data[i],ol); } } tpl = tpl.replace( /[\r\n]+/gm, "

" ); tpl = '

' + tpl.replace( /[\r\n]+/gm, "

" ) + '

'; tpl = tpl.replace('

-

','
'); // replace component var el = $compile(tpl)(scope); element.replaceWith(el); } } }; /** * touchSpin - Directive for Bootstrap TouchSpin */ function touchSpin () { return { restrict: 'A', scope: { spinOptions: '=' }, link: function (scope, element, attrs) { scope.$watch(scope.spinOptions, function(){ render(); }); var render = function () { $(element).TouchSpin(scope.spinOptions); }; } } } /** * truncate - Directive for truncate string */ function truncate($timeout){ return { restrict: 'A', scope: { truncateOptions: '=' }, link: function(scope, element) { $timeout(function(){ element.dotdotdot(scope.truncateOptions); }); } }; } /** * vectorMap - Directive for Vector map plugin */ function vectorMap() { return { restrict: 'A', scope: { myMapData: '=', }, link: function (scope, element, attrs) { var map = element.vectorMap({ map: 'world_mill_en', backgroundColor: "transparent", regionStyle: { initial: { fill: '#e4e4e4', "fill-opacity": 0.9, stroke: 'none', "stroke-width": 0, "stroke-opacity": 0 } }, series: { regions: [ { values: scope.myMapData, scale: ["#1ab394", "#22d6b1"], normalizeFunction: 'polynomial' } ] }, }); var destroyMap = function(){ element.remove(); }; scope.$on('$destroy', function() { destroyMap(); }); } } }; function viewFiles(uiModal) { return { link: function (scope, element, attrs) { element.bind('click', function() { // scope.$apply(function() { // modelSetter(scope, element[0].files[0]); // }); var keyval = JSON.parse(attrs.fileval); var keyid = attrs.fileid; var keyname = attrs.filename; var rt = attrs.record; var data = [keyid,keyname,keyval]; // var data = ['psvid','tmmsitevisit',1]; uiModal({ param: {rt:rt,data:data, tms:tms()}, size: 'xlg', close: function(e){ }, }); }); } }; }; function viewQuot($timeout) { return { restrict: 'E', templateUrl: function(tElement,tAttrs){ return tAttrs.templateUrl ? tAttrs.templateUrl : 'hello.html'; } }; }; angular.module('mzzsetia').directive('autoFocus',autoFocus).directive('autofocusIf',autofocusIf).directive('btnClick',btnClick).directive('calendar',calendar).directive('chatSlimScroll',chatSlimScroll).directive('checkClick',checkClick).directive('checkVal',checkVal).directive('clockPicker1',clockPicker1).directive('clockpicker',clockpicker).directive('closeOffCanvas',closeOffCanvas).directive('createInput',createInput).directive('customValid',customValid).directive('datepicker',datepicker).directive('datepickerButton',datepickerButton).directive('decimal',decimal).directive('drawComponent',drawComponent).directive('drawComponent1',drawComponent1).directive('dropZone',dropZone).directive('editSetting',editSetting).directive('fileDelete',fileDelete).directive('fileModel',fileModel).directive('filePrint',filePrint).directive('fileUpload',fileUpload).directive('fitHeight',fitHeight).directive('focusOnShow',focusOnShow).directive('fullScroll',fullScroll).directive('iboxTools',iboxTools).directive('iboxToolsFullScreen',iboxToolsFullScreen).directive('icheck',icheck).directive('ionRangeSlider',ionRangeSlider).directive('landingScrollspy',landingScrollspy).directive('markdownEditor',markdownEditor).directive('ngConfirmClick',ngConfirmClick).directive('ngDuration',ngDuration).directive('ngEnter',ngEnter).directive('ngFile',ngFile).directive('ngFileModel',ngFileModel).directive('ngReceive',ngReceive).directive('ngWorkconfirm',ngWorkconfirm).directive('numbersWithSelect',numbersWithSelect).directive('onlyNumbers',onlyNumbers).directive('onlyNumbers1',onlyNumbers1).directive('pageTitle',pageTitle).directive('preWrap',preWrap).directive('reject',reject).directive('responsiveVideo',responsiveVideo).directive('restrictTo',restrictTo).directive('rowDelete',rowDelete).directive('rowEdit',rowEdit).directive('rowNew',rowNew).directive('rowViews',rowViews).directive('selectOnFocus',selectOnFocus).directive('sendBack',sendBack).directive('sendBackTo',sendBackTo).directive('sendTo',sendTo).directive('sideNavigation',sideNavigation).directive('slimScroll',slimScroll).directive('sparkline',sparkline).directive('stringToNumber',stringToNumber).directive('sumString',sumString).directive('tdFormat',tdFormat).directive('touchSpin',touchSpin).directive('truncate',truncate).directive('vectorMap',vectorMap).directive('viewFiles',viewFiles).directive('viewQuot',viewQuot)