1"use strict"; 2 3waitryApp.filter('checkForDomain', ["config", function (config) { 4 return function (item) { 5 var pat = /^https?:\/\//i; 6 if (pat.test(item)){ 7 return item; 8 } 9 return config.imgServerUrl + item; 10 }; 11}]); 12 13//create a valid Date format to aply ng date filters 14waitryApp.filter("asDate", ["sessionControl", function(sessionControl) { 15 return function (input) { 16 if(input==undefined){ 17 return new Date(); 18 } 19 var offset = sessionControl.get('timezoneOffset'); 20 if(offset==null || offset==''){ 21 offset = '-0300'; 22 } 23 24 // date in UTC 25 // 2018-07-07: Ahora en la base se guarda en Buenos Aires (-0300) por eso para el UTC le restamos -3 26 var dateUtc = input.substring(0,10)+'T'+input.substring(11,19)+'-0300'; 27 dateUtc = new Date(dateUtc); 28 29 // add or rest offset 30 return changeTimeZone(dateUtc, offset); 31 } 32}]); 33 34waitryApp.filter('abs', function() { 35 return function(num) { return Math.abs(num); } 36}); 37 38 39waitryApp.filter('join', function () { 40 return function join(array, separator, prop) { 41 if (!Array.isArray(array)) { 42 return array; // if not array return original - can also throw error 43 } 44 45 return (!angular.isUndefined(prop) ? array.map(function (item) { 46 return item[prop]; 47 }) : array).join(separator); 48 }; 49}); 50 51waitryApp.directive('wSrc', function(config) { 52 return { 53 restrict: 'A', 54 link: function (scope, elem, attrs) { 55 scope.$watch( function(value) { 56 return attrs.wSrc; 57 }, function () { 58 var url = attrs.wSrc; 59 if(url!='' && url!=null && url!=undefined && url!='noimage'){ 60 if(url.substring(0,4)!='http'){ 61 url = config.imgServerUrl+url; 62 }else if(attrs.sizeFb!='' && attrs.sizeFb!=undefined && url.indexOf('https://graph.facebook.com')==0){ 63 url = url.replace('normal',attrs.sizeFb); 64 } 65 } 66 if(url=='noimage' || url==''){ 67 if(attrs.wProfile!=undefined && attrs.wProfile==1){ 68 url = attrs.wNoImg ? attrs.wNoImg : config.standardPicProfile; 69 }else if(attrs.wBanner!=undefined && attrs.wBanner==1){ 70 url = attrs.wNoImg ? attrs.wNoImg : config.standardPicBanner; 71 }else{ 72 url = config.standardPicProfile; 73 } 74 } 75 elem.attr('src', url); 76 }); 77 } 78 }; 79}); 80 81waitryApp.directive('liveView', function($templateRequest, $compile) { 82 return { 83 restrict: "A", 84 scope: true, 85 link: function (scope, elem, attrs) { 86 scope.$watch( function(value) { 87 return attrs.src; 88 }, function () { 89 var srcView = attrs.src; 90 if(srcView == undefined){ 91 srcView = 'SingleOrder'; 92 } 93 //elem.empty(); 94 //var existTemplate = angular.element(document).find("md-grid-list"); 95 var existTemplate = angular.element(document.querySelector('#'+srcView)); 96 if(existTemplate.length==0){ 97 $templateRequest('./modules/live/views/layout'+srcView+'.html').then(function(html){ 98 var template = angular.element(html); 99 elem.append(template); 100 $compile(template)(scope); 101 }); 102 } 103 }); 104 } 105 }; 106}); 107 108waitryApp.directive('stringToNumber', function() { 109 return { 110 require: 'ngModel', 111 link: function(scope, element, attrs, ngModel) { 112 ngModel.$parsers.push(function(value) { 113 return '' + value; 114 }); 115 ngModel.$formatters.push(function(value) { 116 return parseFloat(value); 117 }); 118 } 119 }; 120}); 121 122waitryApp.directive('focusOn', function() { 123 return function(scope, elem, attr) { 124 scope.$on('focusOn', function(e, name) { 125 if(name === attr.focusOn) { 126 elem[0].focus(); 127 } 128 }); 129 }; 130 }); 131 132 waitryApp.directive('googleplace', [function() { 133 return { 134 require: 'ngModel', 135 scope: { 136 ngModel: '=', 137 city: '=?', 138 region: '=?', 139 country: '=?', 140 postalcode: '=?', 141 placeid: '=?', 142 latitude: '=?', 143 longitude: '=?', 144 street: '=?', 145 number: '=?', 146 gplace: '=?' 147 }, 148 link: function(scope, element, attrs, model) { 149 150 var types = attrs.geotype ? attrs.geotype : ""; 151 var fullAddress = attrs.fulladdress ? attrs.fulladdress : false;
152 var sessionToken = null; 153 154 if (sessionToken == null) { 155 newSessionToken(); 156 } 157 158 var options = { 159 types: Array.isArray(types) ? types : [types], 160 fields: ['address_components', 'formatted_address', 'name', 'place_id', 'geometry.location'], 161 sessionToken: sessionToken 162 }; 163 164 var componentForm = { 165 street_number: 'short_name', 166 route: 'long_name', 167 locality: 'long_name', 168 administrative_area_level_1: 'short_name', 169 country: 'long_name', 170 postal_code: 'short_name' 171 }; 172 173 var variables = { 174 "street_number": "number", 175 "route": "street", 176 "locality": "city", 177 "administrative_area_level_1": "region", 178 "country": "country", 179 "postal_code": "postal_code" 180 }; 181 182 scope.gplace = new google.maps.places.Autocomplete(element[0], options); 183 184 // scope.gplace.setFields(['address_component']); 185 186 google.maps.event.addListener(scope.gplace, 'place_changed', function() { 187 var geoComponents = scope.gplace.getPlace(); 188 applyComponents(geoComponents); 189 newSessionToken(); 190 }); 191 192 var observerHack = new MutationObserver(function() { 193 observerHack.disconnect(); 194 $(element[0]).attr("autocomplete", "new-password"); 195 }); 196 197 observerHack.observe(element[0], { 198 attributes: true, 199 attributeFilter: ['autocomplete'] 200 }); 201 202 function newSessionToken() { 203 sessionToken = new google.maps.places.AutocompleteSessionToken(); 204 } 205 206 function applyComponents(geoComponents) { 207 var details = {}; 208 var addressComponents = geoComponents.address_components; 209 210 for (var i = 0; i < addressComponents.length; i++) { 211 var addressType = addressComponents[i].types[0]; 212 var varType = variables[addressType]; 213 if (componentForm[addressType]) { 214 details[varType] = addressComponents[i][componentForm[addressType]]; 215 } 216 } 217 218 var address = fullAddress && geoComponents.formatted_address ? geoComponents.formatted_address : geoComponents.name ? geoComponents.name : geoComponents.address_components[0].long_name; 219 220 switch (types) { 221 case "(cities)": 222 { 223 element.val(details.city); 224 break; 225 226 } 227 default: 228 { 229 element.val(address); 230 break; 231 } 232 } 233 234 scope.$apply(function() { 235 scope.street = details.street; 236 scope.number = details.number; 237 scope.city = details.city; 238 scope.region = details.region; 239 scope.country = details.country; 240 scope.postalcode = details.postal_code; 241 scope.placeid = geoComponents.place_id; 242 scope.latitude = geoComponents.geometry.location.lat(); 243 scope.longitude = geoComponents.geometry.location.lng(); 244 model.$setViewValue(element.val()); 245 }); 246 } 247 248 } 249 }; 250}]); 251 252waitryApp.directive('ngClickCopy', ['ngCopy', function (ngCopy) { 253 return { 254 restrict: 'A', 255 link: function (scope, element, attrs) { 256 element.bind('click', function (e) { 257 ngCopy(attrs.ngClickCopy); 258 }); 259 } 260 } 261}]); 262 263waitryApp.directive('fileDropZone',['$rootScope', function($parse){ 264 return { 265 restrict: 'A', 266 scope: { 267 importedProductsFile: "=" 268 }, 269 link: function ($rootScope, element, attributes) { 270 element.bind('dragover', function(e){ 271 if(e != null){ 272 e.preventDefault(); 273 } 274 element.attr('class', 'file-over'); 275 }); 276 277 278 element.bind('dragleave', function(e){ 279 if(e != null){ 280 e.preventDefault(); 281 } 282 element.removeAttr('class', 'file-over'); 283 }) 284 285 element.bind('drop', function(e){ 286 if(e != null){ 287 e.preventDefault(); 288 e.stopPropagation(); 289 } 290 291 var file = ''; 292 file = e.originalEvent.dataTransfer.files[0]; 293 $rootScope.$emit('droppedFile', file) 294 $rootScope.$$phase || $rootScope.$apply(); 295 }) 296 } 297 } 298}]); 299 300waitryApp.directive('waitryHelpIcon',['$rootScope', '$compile', '$timeout', function($rootScope, $compile, $timeout){ 301 return { 302 restrict: 'A', 303 link: function ($scope, element, attributes) { 304 var icon="<md-icon md-svg-icon='material:help'></md-icon>"; 305 var content = $compile(icon)($scope); 306 element.append(content); 307 } 308 } 309}]); 310 311waitryApp.directive('waitryHelp',['$rootScope','helpService','$translate', function($rootScope, helpService, $translate){ 312 return { 313 restrict: 'A', 314 link: function ($scope, element, attributes) { 315 element.on('click', function() { 316 helpService.getHelp(attributes.waitryHelp, $translate.use()) 317 .then(function(response) { 318 $rootScope.helpContent = response; 319 $rootScope.toggleHelpSideNav(); 320 $rootScope.$$phase || $rootScope.$apply(); 321 }); 322 }); 323 element.attr('class', element.attr('class') + ' is-pointer'); 324 } 325 } 326}]); 327 328waitryApp.directive('masonryx', function ($timeout) { 329 return { 330 restrict: 'AC', 331 link: function (scope, elem, attrs) { 332 var container = elem[0]; 333 var options = angular.extend({ 334 itemSelector: '.item' 335 }
335, angular.fromJson(attrs.masonry)); 336 337 var masonry = scope.masonry = new Masonry(container, options); 338 339 var debounceTimeout = 0; 340 scope.update = function () { 341 if (debounceTimeout) { 342 $timeout.cancel(debounceTimeout); 343 } 344 debounceTimeout = $timeout(function () { 345 debounceTimeout = 0; 346 347 masonry.reloadItems(); 348 masonry.layout(); 349 350 elem.children(options.itemSelector).css('visibility', 'visible'); 351 }, 500); 352 }; 353 354 scope.removeBrick = function () { 355 $timeout(function () { 356 masonry.reloadItems(); 357 masonry.layout(); 358 }, 500); 359 }; 360 361 scope.appendBricks = function (ele) { 362 masonry.appended(ele); 363 }; 364 365 scope.$on('masonry.layout', function () { 366 masonry.layout(); 367 }); 368 369 scope.update(); 370 } 371 }; 372}).directive('masonryTile', function () { 373 return { 374 restrict: 'AC', 375 link: function (scope, elem) { 376 elem.css('visibility', 'hidden'); 377 var master = elem.parent('*[masonry]:first').scope(), 378 update = master.update, 379 removeBrick = master.removeBrick, 380 appendBricks = master.appendBricks; 381 if (update) { 382 elem.ready(update); 383 } 384 if (appendBricks) { 385 appendBricks(elem); 386 } 387 scope.$on('$destroy', function () { 388 if (removeBrick) { 389 removeBrick(); 390 } 391 }); 392 } 393 }; 394}).directive("devicePreview", function ($window, $timeout) { 395 return { 396 restrict: 'A', 397 link: function (scope, elem) { 398 function doResize() { 399 400 var $el = elem.get(0); 401 var elHeight = $el.clientHeight; 402 var elWidth = $el.clientWidth; 403 404 var $wrapper = $el.parentElement; 405 406 var scale = Math.min( 407 $wrapper.clientWidth / elWidth, 408 $wrapper.clientHeight / elHeight 409 ); 410 411 console.log(scale); 412 413 elem.css("transform", "translate(-50%, -50%) scale(" + scale + ")"); 414 415 } 416 $timeout(doResize, 100); 417 angular.element($window).bind('resize', function () { 418 doResize(); 419 scope.$digest(); 420 }); 421 } 422 } 423}).directive('emailUnique', function (apiService, $q) { 424 return { 425 require: 'ngModel', 426 link: function ($scope, $element, $attrs, $ctrl) { 427 $ctrl.$asyncValidators.available = function (modelValue, viewValue) { 428 var value = modelValue || viewValue; 429 var deferred = $q.defer(); 430 apiService.getEP('/user/user/checkMail', { 431 email: value 432 }).then(function () { 433 var res = apiService.getRawResponse(); 434 if (res.available) { 435 deferred.resolve(); 436 } else { 437 deferred.reject(); 438 } 439 }); 440 return deferred.promise; 441 }; 442 } 443 } 444}).directive('validSocialLink', function ($q) { 445 return { 446 require: 'ngModel', 447 link: function ($scope, $element, $attrs, $ctrl) { 448 $ctrl.$asyncValidators.validSocialLink = function (modelValue, viewValue) { 449 var value = modelValue || viewValue; 450 var deferred = $q.defer(); 451 452 switch ($scope.signupData.social_link) { 453 case 'facebook': 454 value.includes('facebook.com') && value.length > 22 ? deferred.resolve() : deferred.reject(); 455 case 'instagram': 456 value.includes('instagram.com') && value.length > 23 ? deferred.resolve() : deferred.reject(); 457 case 'linkedin': 458 value.includes('linkedin.com') && value.length > 22 ? deferred.resolve() : deferred.reject(); 459 case 'website': 460 value.length > 6 ? deferred.resolve() : deferred.reject(); 461 } 462 463 return deferred.promise; 464 }; 465 } 466 } 467}); 468 469waitryApp.directive('metric-direc', ['metrics', function (metrics) { 470 return { 471 restrict: 'A', 472 link: function (scope, element, attrs) { 473 element.bind('click', function (e) { 474 metrics(attrs.viewMetric); 475 }); 476 } 477 } 478}]); 479 480waitryApp.directive('rightClickMenu', function ($parse) { 481 return { 482 restrict: 'A', 483 link: function (scope, element, attrs) { 484 var fn = $parse(attrs.ngRightClick); 485 486 element.bind('contextmenu', function (event) { 487 scope.$apply(function () { 488 event.preventDefault(); 489 fn(scope, { $event: event }); 490 }); 491 }); 492 } 493 }; 494});
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.