-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Map.js
1 lines (1 loc) · 19 KB
/
Map.js
1
!function e(t,a,s){function n(o,r){if(!a[o]){if(!t[o]){var c="function"==typeof require&&require;if(!r&&c)return c(o,!0);if(i)return i(o,!0);var p=new Error("Cannot find module '"+o+"'");throw p.code="MODULE_NOT_FOUND",p}var l=a[o]={exports:{}};t[o][0].call(l.exports,function(e){var a=t[o][1][e];return n(a?a:e)},l,l.exports,e,t,a,s)}return a[o].exports}for(var i="function"==typeof require&&require,o=0;o<s.length;o++)n(s[o]);return n}({1:[function(e,t,a){"use strict";var s=e("./ConnectMapSettings.jsx"),n=e("./EditMapPoint.jsx"),i=e("./forms/icons.jsx"),o=e("./MapPointMessage.jsx");t.exports=React.createClass({displayName:"exports",_map:{},_mapListener:{},getInitialState:function(){return this.security=ConnectMap.modules[this.props.moduleId].security,this.service=ConnectMap.modules[this.props.moduleId].service,this.resources=ConnectMap.modules[this.props.moduleId].resources,{moduleId:this.props.moduleId,settings:ConnectMap.modules[this.props.moduleId].settings,mapPoints:ConnectMap.modules[this.props.moduleId].mapPoints,isAdding:!1}},render:function(){var e=React.createElement("span",null),t=React.createElement("span",null),a=React.createElement("span",null);return this.security.CanEdit&&(e=React.createElement("a",{href:"#",className:"conLink connectMapSettings",title:this.resources.ShowSettings},React.createElement(i,{type:"map"})),t=React.createElement("a",{href:"#",className:"conLink",onClick:this.setMap,title:this.resources.SetMap},React.createElement(i,{type:"crosshairs"}))),this.security.IsPointer&&(a=React.createElement("a",{href:"#",className:"conLink",onClick:this.addPoint,title:this.resources.AddPoint},React.createElement(i,{type:"map-marker"}))),React.createElement("div",null,React.createElement("div",{ref:"mapDiv"}),React.createElement("div",{className:"conMgtPanel"},e,t,a))},shouldComponentUpdate:function(e,t){return t.settings!==this.state.settings},componentDidMount:function(){var e=this;this.setMapSize(),this._map=new google.maps.Map(this.refs.mapDiv.getDOMNode(),{center:new google.maps.LatLng(this.state.settings.MapOriginLat,this.state.settings.MapOriginLong),zoom:this.state.settings.Zoom,mapTypeId:google.maps.MapTypeId[this.state.settings.MapType]}),$.each(this.state.mapPoints,function(t,a){e.addPointToMap(a)}),$(".connectMapSettings").off("click"),$(".connectMapSettings").click(function(){return React.render(React.createElement(s,{Settings:e.state.settings,onUpdate:e.onSettingsUpdate,resources:e.resources}),$("#connectMapPanel")[0]),window.ConnectMap.slidePanel($("#connectMapPanel")),!1})},onSettingsUpdate:function(e){var t=this;this.service.updateSettings(e,function(e){t.setState({settings:e}),t.setMapSize(),t._map.setMapTypeId(google.maps.MapTypeId[e.MapType])})},setMap:function(){if(confirm(this.resources.SetMapConfirm)){var e=this.state.settings;e.MapOriginLat=this._map.getCenter().lat(),e.MapOriginLong=this._map.getCenter().lng(),e.Zoom=this._map.getZoom(),this.service.updateSettings(e)}return!1},setMapSize:function(){var e=$(this.refs.mapDiv.getDOMNode());e.width(this.state.settings.MapWidth),e.height(this.state.settings.MapHeight)},addPoint:function(){var e=this;return this.state.isAdding?this.stopAddingPoint():(this._map.setOptions({draggableCursor:"crosshair"}),this.setState({isAdding:!0}),this._mapListener=google.maps.event.addListener(this._map,"click",function(t){var a={Latitude:t.latLng.lat(),Longitude:t.latLng.lng(),Message:"",MapPointId:-1};React.render(React.createElement(n,{MapPoint:a,onUpdate:e.onAddPoint,resources:e.resources}),$("#connectMapPanel")[0]),window.ConnectMap.slidePanel($("#connectMapPanel")),e.stopAddingPoint()}),!1)},stopAddingPoint:function(){return this._map.setOptions({draggableCursor:"grab"}),this.setState({isAdding:!1}),google.maps.event.removeListener(this._mapListener),!1},onAddPoint:function(e,t){var a=this;this.service.submitPoint(e,function(s){if(void 0===t){a.addPointToMap(s);var n=a.state.mapPoints;n.push(s),a.setState({mapPoints:n})}else{for(var n=a.state.mapPoints,i=0;i<n.length;i++)n[i].MapPointId===e.MapPointId&&(n[i]=e);a.setState({mapPoints:n})}})},onDeletePoint:function(e,t){this.service.deletePoint(e.MapPointId,function(e){t.setMap(null)})},addPointToMap:function(e){var t=this,a=this.security.IsPointer&&(e.CreatedByUserID==this.security.UserId||this.state.settings.AllowOtherEdit)||this.security.CanEdit,s=new google.maps.Marker({position:new google.maps.LatLng(e.Latitude,e.Longitude),map:this._map,draggable:a,mapPoint:e}),n=$('<div id="point'+e.MapPointId+'" class="conPointMessage"></div>').appendTo("body");React.render(React.createElement(o,{MapPoint:e,CanEdit:a,OnEdit:this.onAddPoint,OnDelete:this.onDeletePoint,Marker:s,resources:this.resources}),n[0]);var i=new google.maps.InfoWindow;i.setContent(n[0]),n.remove(),google.maps.event.addListener(s,"click",function(e){i.open(t._map,s)}),google.maps.event.addListener(s,"dragend",function(e){var a=s.mapPoint;a.Latitude=e.latLng.lat(),a.Longitude=e.latLng.lng(),t.onAddPoint(a,s)})}})},{"./ConnectMapSettings.jsx":2,"./EditMapPoint.jsx":3,"./MapPointMessage.jsx":4,"./forms/icons.jsx":7}],2:[function(e,t,a){"use strict";var s=e("./forms/textbox.jsx"),n=e("./forms/checkbox.jsx"),i=e("./forms/dropdown.jsx");t.exports=React.createClass({displayName:"exports",getInitialState:function(){return{}},render:function(){return React.createElement("div",{className:"conSettings"},React.createElement(s,{text:this.props.resources.MapWidth,ref:"txtMapWidth",value:this.props.Settings.MapWidth,regex:"(\\d+)(px|%)",errorMessage:this.props.resources.CssSizeError,groupClass:"conInput"}),React.createElement(s,{text:this.props.resources.MapHeight,ref:"txtMapHeight",value:this.props.Settings.MapHeight,regex:"(\\d+)(px|%)",errorMessage:this.props.resources.CssSizeError,groupClass:"conInput"}),React.createElement(n,{text:this.props.resources.AllowOtherEdit,ref:"chkAllowOtherEdit",value:this.props.Settings.AllowOtherEdit,groupClass:"conInput"}),React.createElement(s,{text:this.props.resources.GoogleMapsAPIKey,ref:"txtGoogleKey",value:this.props.Settings.GoogleMapApiKey,groupClass:"conInput"}),React.createElement(i,{text:this.props.resources.MapType,ref:"ddMapType",value:this.props.Settings.MapType,options:["ROADMAP","SATELLITE","HYBRID","TERRAIN"],groupClass:"conInput"}),React.createElement("button",{className:"dnnPrimaryAction",onClick:this.handleUpdate},this.props.resources.Update))},componentDidMount:function(){this.refs.txtMapWidth.getDOMNode().value=this.props.Settings.MapWidth,this.refs.txtMapHeight.getDOMNode().value=this.props.Settings.MapHeight,this.refs.chkAllowOtherEdit.getDOMNode().value=this.props.Settings.AllowOtherEdit,this.refs.txtGoogleKey.getDOMNode().value=this.props.Settings.GoogleMapApiKey},handleUpdate:function(){var e=this.props.Settings;e.MapWidth=this.refs.txtMapWidth.getValue()||e.MapWidth,e.MapHeight=this.refs.txtMapHeight.getValue()||e.MapHeight,e.AllowOtherEdit=this.refs.chkAllowOtherEdit.getValue()||e.AllowOtherEdit,e.GoogleMapApiKey=this.refs.txtGoogleKey.getValue(),e.MapType=this.refs.ddMapType.getValue(),this.props.onUpdate(e),window.ConnectMap.slidePanel($("#connectMapPanel"))}})},{"./forms/checkbox.jsx":5,"./forms/dropdown.jsx":6,"./forms/textbox.jsx":9}],3:[function(e,t,a){"use strict";var s=e("./forms/textblock.jsx");t.exports=React.createClass({displayName:"exports",getInitialState:function(){return{}},handleUpdate:function(){var e=this.props.MapPoint;e.Message=this.refs.txtMessage.getValue(),this.props.onUpdate(e,this.props.Marker),window.ConnectMap.slidePanel($("#connectMapPanel"))},render:function(){var e=this.props.resources.UpdatePoint;return void 0===this.props.MapPoint.MapPointId&&(e=this.props.resources.AddPoint),React.createElement("div",null,React.createElement("div",null,"Latitude: ",this.props.MapPoint.Latitude),React.createElement("div",null,"Longitude: ",this.props.MapPoint.Longitude),React.createElement(s,{className:"formFocus",text:this.props.resources.Message,ref:"txtMessage",value:this.props.MapPoint.Message,groupClass:"conInput"}),React.createElement("button",{className:"dnnPrimaryAction",onClick:this.handleUpdate},e))}})},{"./forms/textblock.jsx":8}],4:[function(e,t,a){"use strict";var s=e("./EditMapPoint.jsx");t.exports=React.createClass({displayName:"exports",getInitialState:function(){return{mapPoint:this.props.MapPoint}},componentWillReceiveProps:function(e){this.setState({mapPoint:e.MapPoint})},onEdit:function(e,t){this.setState({mapPoint:e}),this.props.OnEdit(e,t)},edit:function(){return React.render(React.createElement(s,{MapPoint:this.props.MapPoint,onUpdate:this.onEdit,Marker:this.props.Marker,resources:this.props.resources}),$("#connectMapPanel")[0]),window.ConnectMap.slidePanel($("#connectMapPanel")),!1},deletePoint:function(){return confirm(this.props.resources.DeletePointConfirm)&&this.props.OnDelete(this.props.MapPoint,this.props.Marker),!1},render:function(){var e,t;return this.props.CanEdit&&(e=React.createElement("a",{href:"#",onClick:this.edit},this.props.resources.Edit),t=React.createElement("a",{href:"#",onClick:this.deletePoint},this.props.resources.Delete)),React.createElement("div",null,this.state.mapPoint.Message,React.createElement("br",null),React.createElement("em",null,this.props.resources.CreatedBy," ",this.state.mapPoint.CreatedByUser),React.createElement("br",null),e," ",t)}})},{"./EditMapPoint.jsx":3}],5:[function(e,t,a){"use strict";t.exports=React.createClass({displayName:"exports",getInitialState:function(){return{value:this.props.value}},componentWillReceiveProps:function(e){this.setState({value:e.value})},handleChange:function(e){this.setState({value:!this.state.value})},getValue:function(){return this.state.value},render:function(){return React.createElement("div",{className:this.props.groupClass,ref:"mainDiv"},React.createElement("label",{htmlFor:this.props.text,className:"conInputCheck"},React.createElement("span",null,this.props.text)),React.createElement("input",{type:"checkbox",ref:"chk",checked:this.state.value,onChange:this.handleChange}))}})},{}],6:[function(e,t,a){"use strict";var s=React.createClass({displayName:"DropDown",getInitialState:function(){return{}},render:function(){var e=this.props.options.map(function(e){return this.props.value==e?React.createElement("option",{value:e,selected:!0},e):React.createElement("option",{value:e},e)}.bind(this));return React.createElement("div",{className:this.props.groupClass,ref:"mainDiv"},React.createElement("label",{htmlFor:this.props.text},React.createElement("span",null,this.props.text)),React.createElement("select",{className:"form-control",ref:"dropdown"},e))},getValue:function(){var e=this.refs.dropdown.getDOMNode();return e.options[e.selectedIndex].value}});t.exports=s},{}],7:[function(e,t,a){"use strict";t.exports=React.createClass({displayName:"exports",render:function(){switch(this.props.type){case"map-marker":return React.createElement("svg",{viewBox:"0 0 1024 1792",className:"map-marker"},React.createElement("path",{d:"M768 640q0-106-75-181t-181-75-181 75-75 181 75 181 181 75 181-75 75-181zm256 0q0 109-33 179l-364 774q-16 33-47.5 \r 52t-67.5 19-67.5-19-46.5-52l-365-774q-33-70-33-179 0-212 150-362t362-150 362 150 150 362z"}));case"map":return React.createElement("svg",{viewBox:"0 0 1792 1792",className:"map"},React.createElement("path",{d:"M512 0q13 0 22.5 9.5t9.5 22.5v1472q0 20-17 28l-480 256q-7 4-15 4-13 0-22.5-9.5t-9.5-22.5v-1472q0-20 \r 17-28l480-256q7-4 15-4zm1248 0q13 0 22.5 9.5t9.5 22.5v1472q0 20-17 28l-480 256q-7 4-15 4-13 0-22.5-9.5t-9.5-22.5v-1472q0-20 \r 17-28l480-256q7-4 15-4zm-1120 0q8 0 14 3l512 256q18 10 18 29v1472q0 13-9.5 22.5t-22.5 9.5q-8 0-14-3l-512-256q-18-10-18-29v-1472q0-13 \r 9.5-22.5t22.5-9.5z"}));case"gear":return React.createElement("svg",{viewBox:"0 0 1536 1792",className:"gear"},React.createElement("path",{d:"M1024 896q0-106-75-181t-181-75-181 75-75 181 75 181 181 75 181-75 75-181zm512-109v222q0 12-8 23t-20 13l-185 28q-19 54-39 \r 91 35 50 107 138 10 12 10 25t-9 23q-27 37-99 108t-94 71q-12 0-26-9l-138-108q-44 23-91 38-16 136-29 186-7 28-36 28h-222q-14 \r 0-24.5-8.5t-11.5-21.5l-28-184q-49-16-90-37l-141 107q-10 9-25 9-14 0-25-11-126-114-165-168-7-10-7-23 0-12 8-23 15-21 \r 51-66.5t54-70.5q-27-50-41-99l-183-27q-13-2-21-12.5t-8-23.5v-222q0-12 8-23t19-13l186-28q14-46 39-92-40-57-107-138-10-12-10-24 \r 0-10 9-23 26-36 98.5-107.5t94.5-71.5q13 0 26 10l138 107q44-23 91-38 16-136 29-186 7-28 36-28h222q14 0 24.5 8.5t11.5 21.5l28 184q49 \r 16 90 37l142-107q9-9 24-9 13 0 25 10 129 119 165 170 7 8 7 22 0 12-8 23-15 21-51 66.5t-54 70.5q26 50 41 98l183 28q13 2 21 12.5t8 23.5z"}));case"crosshairs":return React.createElement("svg",{viewBox:"0 0 1536 1792",className:"crosshairs"},React.createElement("path",{d:"M1197 1024h-109q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h109q-32-108-112.5-188.5t-188.5-112.5v109q0 26-19 45t-45 19h-128q-26 \r 0-45-19t-19-45v-109q-108 32-188.5 112.5t-112.5 188.5h109q26 0 45 19t19 45v128q0 26-19 45t-45 19h-109q32 108 112.5 188.5t188.5 \r 112.5v-109q0-26 19-45t45-19h128q26 0 45 19t19 45v109q108-32 188.5-112.5t112.5-188.5zm339-192v128q0 26-19 45t-45 19h-143q-37 161-154.5 \r 278.5t-278.5 154.5v143q0 26-19 45t-45 19h-128q-26 0-45-19t-19-45v-143q-161-37-278.5-154.5t-154.5-278.5h-143q-26 0-45-19t-19-45v-128q0-26 \r 19-45t45-19h143q37-161 154.5-278.5t278.5-154.5v-143q0-26 19-45t45-19h128q26 0 45 19t19 45v143q161 37 278.5 154.5t154.5 278.5h143q26 0 45 \r 19t19 45z"}));case"check-circle":return React.createElement("svg",{viewBox:"0 0 1536 1792",className:"check-circle"},React.createElement("path",{d:"M1171 813l-422 422q-19 19-45 19t-45-19l-294-294q-19-19-19-45t19-45l102-102q19-19 45-19t45 19l147 147 275-275q19-19 45-19t45 \r 19l102 102q19 19 19 45t-19 45zm141 83q0-148-73-273t-198-198-273-73-273 73-198 198-73 273 73 273 198 198 273 73 273-73 198-198 73-273zm224 \r 0q0 209-103 385.5t-279.5 279.5-385.5 103-385.5-103-279.5-279.5-103-385.5 103-385.5 279.5-279.5 385.5-103 385.5 103 279.5 279.5 103 385.5z"}));case"exclamation-circle":return React.createElement("svg",{viewBox:"0 0 1536 1792",className:"exclamation-circle"},React.createElement("path",{d:"M768 128q209 0 385.5 103t279.5 279.5 103 385.5-103 385.5-279.5 279.5-385.5 103-385.5-103-279.5-279.5-103-385.5 103-385.5 \r 279.5-279.5 385.5-103zm128 1247v-190q0-14-9-23.5t-22-9.5h-192q-13 0-23 10t-10 23v190q0 13 10 23t23 10h192q13 0 \r 22-9.5t9-23.5zm-2-344l18-621q0-12-10-18-10-8-24-8h-220q-14 0-24 8-10 6-10 18l17 621q0 10 10 17.5t24 7.5h185q14 0 23.5-7.5t10.5-17.5z"}))}}})},{}],8:[function(e,t,a){"use strict";t.exports=React.createClass({displayName:"exports",getInitialState:function(){return{value:this.props.value}},componentWillReceiveProps:function(e){this.setState({value:e.value})},handleChange:function(e){this.setState({value:e.target.value})},getValue:function(){return this.refs.txtInput.getDOMNode().value},render:function(){return React.createElement("div",{className:this.props.groupClass,ref:"mainDiv"},React.createElement("label",{htmlFor:this.props.text},React.createElement("span",null,this.props.text)),React.createElement("textarea",{ref:"txtInput",value:this.state.value,onChange:this.handleChange,className:this.props.className}))}})},{}],9:[function(e,t,a){"use strict";var s=e("./icons.jsx");t.exports=React.createClass({displayName:"exports",getInitialState:function(){return{value:this.props.value,iconState:this.getIconState(this.props.value)}},requiredPassed:function(e){return void 0===this.props.required?!0:""!=e},regexPassed:function(e){if(void 0===this.props.regex)return!0;var t=new RegExp(this.props.regex);return t.test(e)},handleChange:function(e){this.setState({value:e.target.value,iconState:this.getIconState(e.target.value)})},getValue:function(){return"check-circle"==this.state.iconState?this.state.value:null},getIconState:function(e){return this.regexPassed(e)&&this.requiredPassed(e)?"check-circle":"exclamation-circle"},setIconTitle:function(){var e=$(this.refs.mainDiv.getDOMNode()).children("svg")[0];"check-circle"==this.state.iconState?e.setAttribute("title","OK"):e.setAttribute("title",this.props.errorMessage)},componentDidMount:function(){this.setIconTitle()},render:function(){return React.createElement("div",{className:this.props.groupClass,ref:"mainDiv"},React.createElement("label",{htmlFor:this.props.text},React.createElement("span",null,this.props.text)),React.createElement("input",{type:"text",ref:"txtInput",value:this.state.value,onChange:this.handleChange,className:this.props.className}),React.createElement(s,{type:this.state.iconState}))},componentDidUpdate:function(){this.setIconTitle()}})},{"./icons.jsx":7}],10:[function(e,t,a){"use strict";var s=e("./ConnectMap.jsx"),n=e("./service");!function(e,t,a,i){e(a).ready(function(){0==e("#connectMapPanel").length&&e("body").append('<div id="connectMapPanel" class="connectMapPanel"></div>'),ConnectMap.loadData()}),t.ConnectMap={modules:{},googleLoaded:!1,nrMapsToLoad:0,loadData:function(){var t=this;this.nrMapsToLoad=e(".connectMap").length,e(".connectMap").each(function(a,s){var i=e(s).data("moduleid"),o={service:new n(e,i)};ConnectMap.modules[i]=o,ConnectMap.modules[i].service.getInitialData(function(e){ConnectMap.modules[i].settings=e.Settings,ConnectMap.modules[i].mapPoints=e.MapPoints,ConnectMap.modules[i].security=e.Security,ConnectMap.modules[i].resources=e.ClientResources,1==t.nrMapsToLoad&&ConnectMap.loadGoogle(ConnectMap.modules[i].settings.GoogleMapApiKey),t.nrMapsToLoad-=1})})},loadMaps:function(){e(".connectMap").each(function(t,a){var n=e(a).data("moduleid");React.render(React.createElement(s,{moduleId:n}),a)})},loadGoogle:function(e){if(!ConnectMap.googleLoaded){var t=location.protocol+"//maps.googleapis.com/maps/api/js?callback=ConnectMap.loadMaps";e&&""!==e&&(t+="&key="+e),ConnectMap.loadScript(t)}},slidePanel:function(s){if("block"==s.css("display"))e("body").off("click"),s.animate({right:-t.innerWidth},800,function(){s.css("display","none"),e("body").css("overflow","auto")});else{e("body").css("overflow","hidden"),s.css("right",-t.innerWidth),s.css("display","block"),s.css("top",e(a).scrollTop());var n=this;s.animate({right:0},800,function(){var t=a.getElementsByClassName("formFocus");t.length>0&&t[0].focus(),e("body").on("click",function(t){0==e(t.target).closest("#"+s[0].id).length&&n.slidePanel(s)})})}},formatString:function(e){var t=Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})},loadScript:function(e,t){var s,n,o,r=this;n=!1,s=a.createElement("script"),s.type="text/javascript",s.src=e,s.onload=s.onreadystatechange=function(){n||r.readyState&&"complete"!=r.readyState||(n=!0,t!==i&&t())},o=a.getElementsByTagName("script")[0],o.parentNode.insertBefore(s,o)}}}(jQuery,window,document)},{"./ConnectMap.jsx":1,"./service":11}],11:[function(e,t,a){"use strict";t.exports=function(e,t){var a=t,s=e.dnnSF(a).getServiceRoot("Connect/Map");this.ajaxCall=function(t,n,i,o,r,c,p){e.ajax({type:t,url:s+n+"/"+i+(null!=o?"/"+o:""),beforeSend:e.dnnSF(a).setModuleHeaders,data:r}).done(function(e){void 0!=c&&c(e)}).fail(function(e,t){void 0!=p&&p(e.responseText)})},this.getInitialData=function(e){this.ajaxCall("GET","Module","InitialData",null,null,e)},this.updateSettings=function(e,t){this.ajaxCall("POST","Settings","Update",null,e,t)},this.submitPoint=function(e,t){this.ajaxCall("POST","MapPoints","MapPoint",null,e,t)},this.deletePoint=function(e,t){this.ajaxCall("POST","MapPoints","Delete",e,null,t)}}},{}]},{},[10]);