1// xXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxX 2// xXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxX 3// 4// Southwest.js // UI Extensions for Angular 5// by AJB 6// 7// xXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxX 8// xXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxX 9function incrementNumber(numberValue, number) { 10 if(numberValue == 100) { 11 clearTimeout(numberAnimation); 12 return; 13 } 14 15 numberValue++ 16 17 if (numberValue > number.text()) { 18 number.text(numberValue); 19 } 20 21 var numberAnimation = setTimeout(function() { 22 incrementNumber(numberValue, number); 23 }, 10); 24} 25 26apollo.service('Southwest', function($window, $rootScope, $timeout) { 27 var service = {}; 28 29 $rootScope.dimensions = { 30 height: $window.innerHeight, 31 width: $window.innerWidth 32 } 33 service.mobile = ($rootScope.dimensions.width <= 768) 34 35 36 angular.element(window).resize(function(){ 37 $rootScope.$apply(function(){ 38 $rootScope.dimensions.height = $window.innerHeight; 39 $rootScope.dimensions.width = $window.innerWidth; 40 }); 41 service.mobile = ($rootScope.dimensions.width <= 768) 42 }); 43 44 45 service.smartFill = function (offset) { 46 var computed = $rootScope.dimensions.height - offset; 47 return { 48 maxHeight: computed, 49 height: computed, 50 top: offset 51 } 52 } 53 54 /* 55 56 service.seed = null; 57 service.grow = function (start, finish) { 58 c('seed is '+service.seed); 59 if (service.seed === null) { 60 service.seed = start; 61 } 62 if (service.seed >= finish) { 63 service.seed = null; 64 return finish; 65 } 66 service.seed++; 67 return $timeout(function(){ 68 service.grow(start, finish); 69 },10); 70 } 71 72 service.grow(1,100).then(function(val){ console.log('finished at '+val); }) 73 */ 74 75 // height 76 77 service.smartHeight = function (offset) { 78 var computed = $rootScope.dimensions.height - offset; 79 return { 80 maxHeight: computed, 81 height: computed 82 }; 83 } 84 service.getSmartHeight = function (offset) { 85 return $rootScope.dimensions.height - offset; 86 } 87 service.getPercentOfHeight = function (percent) { 88 return $rootScope.dimensions.height * (percent/100); 89 } 90 service.getPercentOfSmartHeight = function (percent, offset) { 91 return service.getSmartHeight(offset) * (percent/100); 92 } 93 service.heightShare = function (factor) { 94 var computedHeight = $rootScope.dimensions.height * factor; 95 return { 96 maxHeight: computedHeight, 97 height: computedHeight 98 } 99 } 100 service.getHeightShare = function (factor) { 101 return $rootScope.dimensions.height * factor; 102 } 103 104 // width 105 106 service.smartWidth = function (offset) { 107 var computed = $rootScope.dimensions.width - offset; 108 return { 109 maxWidth: computed, 110 width: computed 111 }; 112 } 113 service.getSmartWidth = function (offset) { 114 return $rootScope.dimensions.width - offset; 115 } 116 service.getPercentOfWidth = function (percent) { 117 return $rootScope.dimensions.width * (percent/100); 118 } 119 service.getPercentOfSmartWidth = function (percent, offset) { 120 return service.getSmartWidth(offset) * (percent/100); 121 } 122 service.widthShare = function (factor) { 123 var computedWidth = $rootScope.dimensions.width * factor; 124 return { 125 maxWidth: computedWidth, 126 width: computedWidth 127 } 128 } 129 service.smartFont = function (text, smartWidthArg, maxSize) { 130 if (!text || !text.length) { return maxSize + 'px'; } 131 var pixelsPerLetter = 9 + service.getPercentOfSmartWidth(100/text.length, smartWidthArg); 132 133 return (maxSize < pixelsPerLetter ? maxSize : pixelsPerLetter ) + 'px'; 134 } 135 136 service.scaleFont = function ( percent, mobilePercent, min ) { 137 return { fontSize: $scope.getScaleFont(percent, mobilePercent, min) + 'px' }; 138 } 139 service.getScaleFont = function (percent, mobilePercent, min) { 140 // get percent of screenwide 141 var x = $rootScope.dimensions.width * (percent/100); 142 if (mobilePercent && $rootScope.dimensions.width <= 768) { 143 x = $rootScope.dimensions.width * (mobilePercent/100); 144 } 145 x = (min && min > x ? min : x); 146 return x; 147 } 148 149 service.getWidthShare = function (factor) { 150 return $rootScope.dimensions.width * factor; 151 } 152 153 return service; 154});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.