芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/rentandbuyrealty.com/mobile/js/directives.js
function MultiRangeDirective ($compile) { var directive = { restrict: 'E', scope: { ngModelMin: '=', ngModelMax: '=', ngMin: '=', ngMax: '=', ngStep: '=', ngChangeMin: '&', ngChangeMax: '&' }, link: link }; return directive; //////////////////// function link ($scope, $element, $attrs) { var min, max, step, $inputMin = angular.element('
'), $inputMax; $scope.ngChangeMin = $scope.ngChangeMin || angular.noop; $scope.ngChangeMax = $scope.ngChangeMax || angular.noop; if (typeof $scope.ngMin == 'undefined') { min = 0; } else { min = $scope.ngMin; $inputMin.attr('min', min); } if (typeof $scope.ngMax == 'undefined') { max = 0; } else { max = $scope.ngMax; $inputMin.attr('max', max); } if (typeof $scope.ngStep == 'undefined') { step = 0; } else { step = $scope.ngStep; $inputMin.attr('step', step); } $inputMax = $inputMin.clone(); $inputMin.attr('ng-model', 'ngModelMin'); $inputMax.attr('ng-model', 'ngModelMax'); $compile($inputMin)($scope); $compile($inputMax)($scope); $element.append($inputMin).append($inputMax); $scope.ngModelMin = $scope.ngModelMin || min; $scope.ngModelMax = $scope.ngModelMax || max; $scope.$watch('ngModelMin', function (newVal, oldVal) { if (newVal > $scope.ngModelMax) { $scope.ngModelMin = oldVal; } else { $scope.ngChangeMin(); } }); $scope.$watch('ngModelMax', function (newVal, oldVal) { if (newVal < $scope.ngModelMin) { $scope.ngModelMax = oldVal; } else { $scope.ngChangeMax(); } }); } } angular.module('starter.directives', []) .directive('noScroll', function() { return { restrict: 'A', link: function($scope, $element, $attr) { $element.on('touchmove', function(e) { e.preventDefault(); }); } } }) .directive('photoPickable', function() { return { restrict: 'AE', scope: { number: '@', imgSrc: '=' }, template: '' + '
' + '
Profile photo
' + '
' + '
' + '
' + '
', controller: function($scope,$localstorage, $cordovaCamera) { var options; var u = $localstorage.getObject('user'); $scope.user = u.profile_photo; document.addEventListener("deviceready", function () { options = { quality: 50, destinationType: Camera.DestinationType.FILE_URI, sourceType: Camera.PictureSourceType.SAVEDPHOTOALBUM, mediaType: Camera.MediaType.PICTURE, allowEdit: true, encodingType: Camera.EncodingType.JPEG, targetWidth: 640, targetHeight: 640, popoverOptions: CameraPopoverOptions, saveToPhotoAlbum: false }; }); $scope.pick = function() { if (Camera === undefined) return false; $cordovaCamera.getPicture(options) .then(function(imageData) { // $scope.imgSrc = "data:image/jpeg;base64," + imageData; $scope.imgSrc = imageData; }, function(err) { // error }); } } } }) .filter('trustUrl', function ($sce) { return function(url) { return $sce.trustAsResourceUrl(url); }; }) .directive('uiMultiRange', MultiRangeDirective) .directive('googleAd', ['$timeout', function($timeout) { return { restrict: 'A', link: function(scope, element, attr) { return $timeout(function() { var adsbygoogle, html, rand; rand = Math.random(); html = '
'; $(element).append(html); return (adsbygoogle = window.adsbygoogle || []).push({}); }); } }; } ])