UNPKG

pip-webui

Version:

HTML5 UI for LOB applications

1 lines 14.4 kB
!function(){"use strict";angular.module("pipLocations",["pipLocation","pipLocationMap","pipLocationIp","pipLocationEdit","pipLocationEditDialog"])}(),function(o){try{o=angular.module("pipLocations.Templates")}catch(n){o=angular.module("pipLocations.Templates",[])}o.run(["$templateCache",function(o){o.put("location_dialog/location_dialog.html",'<md-dialog class="pip-dialog pip-location-edit-dialog layout-column" md-theme="{{theme}}"><div class="pip-header layout-column layout-align-start-start"><md-progress-linear ng-show="transaction.busy()" md-mode="indeterminate" class="pip-progress-top"></md-progress-linear><h3 class="m0 w-stretch flex">{{ \'LOCATION_SET_LOCATION\' | translate }}</h3></div><div class="pip-footer"><div class="layout-row layout-align-start-center"><md-button class="md-accent" ng-click="onAddPin()" ng-show="locationPos == null" ng-disabled="transaction.busy()" aria-label="{{ ::\'LOCATION_ADD_PIN\' | translate }}">{{ ::\'LOCATION_ADD_PIN\' | translate }}</md-button><md-button class="md-accent" ng-click="onRemovePin()" ng-show="locationPos != null" ng-disabled="transaction.busy()" aria-label="{{ ::\'LOCATION_REMOVE_PIN\' | translate }}">{{ ::\'LOCATION_REMOVE_PIN\' | translate }}</md-button></div><div class="flex"></div><div class="layout-row layout-align-end-center"><md-button ng-click="onCancel()" aria-label="{{ ::\'CANCEL\' | translate }}">{{ ::\'CANCEL\' | translate }}</md-button><md-button class="md-accent" ng-click="onApply()" ng-disabled="transaction.busy()" aria-label="{{ ::\'APPLY\' | translate }}">{{ ::\'APPLY\' | translate }}</md-button></div></div><div class="pip-body"><div class="pip-location-container"></div><md-button class="md-icon-button md-fab pip-zoom-in" ng-click="onZoomIn()" aria-label="{{ ::\'LOCATION_ZOOM_IN\' | translate }}"><md-icon md-svg-icon="icons:plus"></md-icon></md-button><md-button class="md-icon-button md-fab pip-zoom-out" ng-click="onZoomOut()" aria-label="{{ ::\'LOCATION_ZOOM_OUT\' | translate }}"><md-icon md-svg-icon="icons:minus"></md-icon></md-button><md-button class="md-icon-button md-fab pip-set-location" ng-click="onSetLocation()" aria-label="{{ ::\'LOCATION_SET_LOCATION\' | translate }}" ng-show="supportSet" ng-disabled="transaction.busy()"><md-icon md-svg-icon="icons:target"></md-icon></md-button></div></md-dialog>')}])}(),function(){"use strict";var o=angular.module("pipLocation",["pipUtils"]);o.directive("pipLocation",["pipUtils",function(o){return{restrict:"EA",scope:{pipLocationName:"&",pipLocationPos:"&",pipLocationResize:"&",pipShowLocationIcon:"="},template:function(n,i){return o.toBoolean(i.pipCollapse)?String()+'<div class="pip-location-name bm0" ng-click="pipLocationResize()" ng-hide="!pipLocationName()"ng-class="pipShowLocationIcon ? \'lp24-flex rp16\' : \'\'"><md-icon md-svg-icon="icons:location" class="flex-fixed pip-icon" ng-if="pipShowLocationIcon"></md-icon><span class="pip-location-text">{{pipLocationName()}}</span> </div><div class="pip-location-container bm8" ng-hide="!pipLocationPos()"></div>':String()+'<md-button class="pip-location-name" ng-click="pipLocationResize()" ng-class="pipShowLocationIcon ? \'lp24-flex rp16\' : \'\'"><div class="layout-align-start-center layout-row w-stretch"><md-icon md-svg-icon="icons:location" class="flex-fixed pip-icon" ng-if="pipShowLocationIcon"></md-icon><span class="pip-location-text flex">{{pipLocationName()}}</span><md-icon md-svg-icon="icons:triangle-down" class="flex-fixed" ng-if="!showMap"></md-icon><md-icon md-svg-icon="icons:triangle-up" class="flex-fixed" ng-if="showMap"></md-icon></div></md-button><div class="pip-location-container bm8"ng-class="pipShowLocationIcon ? \'lm24-flex rm24-flex\' : \'\'"></div>'},controller:"pipLocationController"}}]),o.controller("pipLocationController",["$scope","$element","$attrs","pipUtils",function(o,n,i,t){function a(){p&&p.remove(),p=null,c.hide()}function e(){var n=o.pipLocationPos();if(0==o.showMap||null==n||null==n.coordinates||n.coordinates.length<0)return void a();var i=new google.maps.LatLng(n.coordinates[0],n.coordinates[1]);p&&p.remove(),p=$("<div></div>"),c.show(),p.appendTo(c);var t={center:i,zoom:12,mapTypeId:google.maps.MapTypeId.ROADMAP,disableDefaultUI:!0,disableDoubleClickZoom:!0,scrollwheel:!1,draggable:!1},e=new google.maps.Map(p[0],t);new google.maps.Marker({position:i,map:e})}var l=n.children(".pip-location-name"),c=n.children(".pip-location-container"),p=null,s=n.find(".icon-up"),r=n.find(".icon-down"),d=t.toBoolean(i.pipCollapse);d||(o.showMap=!1,s.hide(),c.hide(),l.click(function(n){n.stopPropagation(),i.disabled||(o.showMap=!o.showMap,s[o.showMap?"show":"hide"](),r[o.showMap?"hide":"show"](),e())})),t.toBoolean(i.pipRebind)&&o.$watch(o.pipLocationPos,function(o){e()}),n.addClass("pip-location"),o.pipLocationPos()?e():a()}])}(),function(){"use strict";var o=angular.module("pipLocationEditDialog",["ngMaterial","pipTranslate","pipTransactions","pipLocations.Templates"]);o.config(["pipTranslateProvider",function(o){o.translations("en",{LOCATION_ADD_LOCATION:"Add location",LOCATION_SET_LOCATION:"Set location",LOCATION_ADD_PIN:"Add pin",LOCATION_REMOVE_PIN:"Remove pin"}),o.translations("ru",{LOCATION_ADD_LOCATION:"Добавить местоположение",LOCATION_SET_LOCATION:"Определить положение",LOCATION_ADD_PIN:"Добавить точку",LOCATION_REMOVE_PIN:"Убрать точку"})}]),o.factory("pipLocationEditDialog",["$mdDialog",function(o){return{show:function(n,i,t){o.show({controller:"pipLocationEditDialogController",templateUrl:"location_dialog/location_dialog.html",locals:{locationName:n.locationName,locationPos:n.locationPos},clickOutsideToClose:!0}).then(function(o){i&&i(o)},function(){t&&t()})}}}]),o.controller("pipLocationEditDialogController",["$scope","$rootScope","$timeout","$mdDialog","pipTransaction","locationPos","locationName",function(o,n,i,t,a,e,l){o.theme=n.$theme,o.locationPos=e&&"Point"==e.type&&e.coordinates&&2==e.coordinates.length?e:null,o.locationName=l,o.supportSet=null!=navigator.geolocation,o.transaction=a("location_edit_dialog",o);var c=null,p=null,s=function(o){if(p&&p.setMap(null),o){p=new google.maps.Marker({position:o,map:c,draggable:!0,animation:google.maps.Animation.DROP});var n=p;google.maps.event.addListener(n,"dragend",function(){var o=n.getPosition();r(o)})}else p=null;return p},r=function(n,i){if(o.locationPos={type:"Point",coordinates:[n.lat(),n.lng()]},o.locationName=null,null!=i||(i=o.transaction.begin(),null!=i)){var t=new google.maps.Geocoder;t.geocode({location:n},function(n,t){o.transaction.aborted(i)||(t==google.maps.GeocoderStatus.OK&&n&&n.length>0&&(o.locationName=n[0].formatted_address),o.transaction.end(),o.$apply())})}};i(function(){var n=$(".pip-location-edit-dialog .pip-location-container"),i=o.locationPos?new google.maps.LatLng(o.locationPos.coordinates[0],o.locationPos.coordinates[1]):null,t={center:new google.maps.LatLng(0,0),zoom:1,mapTypeId:google.maps.MapTypeId.ROADMAP,disableDefaultUI:!0};null!=i&&(t.center=i,t.zoom=12),c=new google.maps.Map(n[0],t),p=s(i),setTimeout(function(){google.maps.event.trigger(c,"resize")},1e3)},0),o.$on("pipLayoutResized",function(o){null!=c&&google.maps.event.trigger(c,"resize")}),o.onAddPin=function(){if(null!=c){var o=c.getCenter();p=s(o),r(o)}},o.onRemovePin=function(){null!=c&&(p=s(null),o.locationPos=null,o.locationName=null)},o.onZoomIn=function(){if(null!=c){var o=c.getZoom();c.setZoom(o+1)}},o.onZoomOut=function(){if(null!=c){var o=c.getZoom();c.setZoom(o>1?o-1:o)}},o.onSetLocation=function(){if(null!=c){var n=o.transaction.begin();null!=n&&navigator.geolocation.getCurrentPosition(function(i){if(!o.transaction.aborted(n)){var t=new google.maps.LatLng(i.coords.latitude,i.coords.longitude);p=s(t),c.setCenter(t),c.setZoom(12),r(t,n)}},function(){o.transaction.end(),o.$apply()},{maximumAge:0,enableHighAccuracy:!0,timeout:5e3})}},o.onCancel=function(){t.cancel()},o.onApply=function(){t.hide({location:o.locationPos,locationPos:o.locationPos,locationName:o.locationName})}}])}(),function(){"use strict";var o=angular.module("pipLocationIp",["pipUtils"]);o.directive("pipLocationIp",function(){return{restrict:"EA",scope:{pipIpaddress:"&",pipExtraInfo:"&"},template:'<div class="pip-location-container"></div>',controller:"pipLocationIpController"}}),o.controller("pipLocationIpController",["$scope","$element","$attrs","$http","pipUtils",function(o,n,i,t,a){function e(){s&&s.remove(),s=null}function l(o,n){if(null==o||null==n)return void e();var i=new google.maps.LatLng(o,n);s&&s.remove(),s=$("<div></div>"),s.appendTo(p);var t={center:i,zoom:12,mapTypeId:google.maps.MapTypeId.ROADMAP,disableDefaultUI:!0,disableDoubleClickZoom:!0,scrollwheel:!1,draggable:!1},a=new google.maps.Map(s[0],t);new google.maps.Marker({position:i,map:a})}function c(){var n=o.pipIpaddress();return""==n?void e():void t.jsonp("http://www.geoplugin.net/json.gp?ip="+n+"&jsoncallback=JSON_CALLBACK").success(function(n){if(null!=n&&null!=n.geoplugin_latitude&&null!=n.geoplugin_longitude){if(l(n.geoplugin_latitude,n.geoplugin_longitude),o.pipExtraInfo){var i={city:n.geoplugin_city,regionCode:n.geoplugin_regionCode,region:n.geoplugin_regionName,areaCode:n.geoplugin_areaCode,countryCode:n.geoplugin_countryCode,country:n.geoplugin_countryName,continentCode:n.geoplugin_continentCode};o.pipExtraInfo({extraInfo:i})}}else e()}).error(function(o){console.error(o),e()})}var p=n.children(".pip-location-container"),s=null;a.toBoolean(i.pipRebind)&&o.$watch(function(){return o.pipIpaddress()},function(o){c()}),n.addClass("pip-location-ip"),c()}])}(),function(){"use strict";var o=angular.module("pipLocationEdit",["pipLocationEditDialog"]);o.directive("pipLocationEdit",["$parse","$http","pipLocationEditDialog",function(o,n,i){return{restrict:"EAC",scope:{pipLocationName:"=",pipLocationPos:"=",pipLocationHolder:"=",ngDisabled:"&",pipChanged:"&"},template:String()+'<md-input-container class="md-block"><label>{{ \'LOCATION\' | translate }}</label><input ng-model="pipLocationName"ng-disabled="ngDisabled()"/></md-input-container><div class="pip-location-empty" layout="column" layout-align="center center"><md-button class="md-raised" ng-disabled="ngDisabled()" ng-click="onSetLocation()"aria-label="LOCATION_ADD_LOCATION"><span class="icon-location"></span> {{::\'LOCATION_ADD_LOCATION\' | translate}}</md-button></div><div class="pip-location-container" tabindex="{{ ngDisabled() ? -1 : 0 }}" ng-click="onMapClick($event)" ng-keypress=""onMapKeyPress($event)"></div>',controller:["$scope","$element",function(o,n){n.find("md-input-container").attr("md-no-float",!!o.pipLocationHolder)}],link:function(o,n){var t=n.children(".pip-location-empty"),a=n.children(".pip-location-container"),e=null,l=function(){e&&e.remove(),e=null,a.hide(),t.show()},c=function(){var n=o.pipLocationPos;if(null==n||null==n.coordinates||n.coordinates.length<0)return void l();var i=new google.maps.LatLng(n.coordinates[0],n.coordinates[1]);e&&e.remove(),a.show(),t.hide(),e=$("<div></div>"),e.appendTo(a);var c={center:i,zoom:12,mapTypeId:google.maps.MapTypeId.ROADMAP,disableDefaultUI:!0,disableDoubleClickZoom:!0,scrollwheel:!1,draggable:!1},p=new google.maps.Map(e[0],c);new google.maps.Marker({position:i,map:p})},p=function(){var n=o.pipLocationName;if(""==n)return o.pipLocationPos=null,l(),void o.$apply();var i=new google.maps.Geocoder;i.geocode({address:n},function(n,i){o.$apply(function(){if(i==google.maps.GeocoderStatus.OK){if(null==n||0==n.length)return o.pipLocationPos=null,void l();var t=n[0].geometry||{},a=t.location||{};if(null==a.lat||null==a.lng)return o.pipLocationPos=null,void l();o.pipLocationPos={type:"Point",coordinates:[a.lat(),a.lng()]}}else console.error(response),o.pipLocationPos=null})})},s=_.debounce(p,2e3);o.onSetLocation=function(){o.ngDisabled()||i.show({locationName:o.pipLocationName,locationPos:o.pipLocationPos},function(n){var i=n.location,t=n.locationName;o.pipLocationPos&&"Point"==o.pipLocationPos.type&&2==o.pipLocationPos.coordinates.length&&i&&2==i.coordinates.length&&o.pipLocationPos.coordinates[0]-i.coordinates[0]<1e-4&&o.pipLocationPos.coordinates[1]-i.coordinates[1]<1e-4&&t==o.pipLocationName||(o.pipLocationPos=i,o.pipLocationName=t,null==t&&null!=i&&(o.pipLocationName="("+n.location.coordinates[0]+","+n.location.coordinates[1]+")"),o.pipChanged(),a[0].focus())})},o.onMapClick=function(n){o.ngDisabled()||(a[0].focus(),o.onSetLocation())},o.onMapKeyPress=function(n){o.ngDisabled()||13!=n.keyCode&&32!=n.keyCode||o.onSetLocation()},o.$watch(function(){return o.pipLocationName},function(o,n){o!=n&&s()}),o.$watch(function(){return o.pipLocationPos},function(){c()}),n.addClass("pip-location-edit"),o.pipLocationPos?c():l()}}}])}(),function(){"use strict";var o=angular.module("pipLocationMap",["pipUtils"]);o.directive("pipLocationMap",function(){return{restrict:"EA",scope:{pipLocationPos:"&",pipLocationPositions:"&",pipIconPath:"&",pipDraggable:"&",pipStretch:"&"},template:'<div class="pip-location-container"></div>',controller:"pipLocationMapController"}}),o.controller("pipLocationMapController",["$scope","$element","$attrs","$parse","pipUtils",function(o,n,i,t,a){function e(){r&&r.remove(),r=null}function l(o){return!(null==o||null==o.coordinates||o.coordinates.length<0)}function c(o){var n=new google.maps.LatLng(o.coordinates[0],o.coordinates[1]);return n.fill=o.fill,n.stroke=o.stroke,n}function p(){var n=o.pipLocationPos(),i=o.pipLocationPositions(),t=[],a=o.pipDraggable()||!1;if(l(n)?t.push(c(n)):i&&i.length&&i.length>0&&i.forEach(function(o){l(o)&&t.push(c(o))}),0===t.length)return void e();r&&r.remove(),r=$("<div></div>"),r.appendTo(s);var p={center:t[0],zoom:12,mapTypeId:google.maps.MapTypeId.ROADMAP,disableDefaultUI:!0,disableDoubleClickZoom:!0,scrollwheel:a,draggable:a},d=new google.maps.Map(r[0],p),g=new google.maps.LatLngBounds;t.forEach(function(o){var n={path:u,fillColor:o.fill||"#EF5350",fillOpacity:1,scale:1,strokeColor:o.stroke||"white",strokeWeight:5};new google.maps.Marker({position:o,map:d,icon:u?n:null}),g.extend(o)}),t.length>1&&d.fitBounds(g)}var s=n.children(".pip-location-container"),r=null,d=o.pipStretch()||!1,u=o.pipIconPath();a.toBoolean(i.pipRebind)&&o.$watch(function(){return o.pipLocationPos()},function(){p()}),n.addClass("pip-location-map"),d&&s.addClass("stretch"),o.pipLocationPos()||o.pipLocationPositions()?p():e()}])}();