Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed license

  • Loading branch information...
commit 46b402962ca596221e3b4d6c3cd50c96dd8bb38f 1 parent 7153d95
@tnightingale authored
Showing with 8 additions and 48 deletions.
  1. +3 −23 dist/Leaflet.widget.js
  2. +3 −23 dist/Leaflet.widget.min.js
  3. +2 −2 grunt.js
View
26 dist/Leaflet.widget.js
@@ -1,26 +1,6 @@
-/*! Leaflet.widget - v0.1.0 - 2012-10-23
-* Copyright (c) 2012 function () {
-
-// If the string looks like an identifier, then we can return it as is.
-// If the string contains no control characters, no quote characters, and no
-// backslash characters, then we can simply slap some quotes around it.
-// Otherwise we must also replace the offending characters with safe
-// sequences.
-
- if (ix.test(this)) {
- return this;
- }
- if (nx.test(this)) {
- return '"' + this.replace(nxg, function (a) {
- var c = escapes[a];
- if (c) {
- return c;
- }
- return '\\u' + ('0000' + a.charCodeAt().toString(16)).slice(-4);
- }) + '"';
- }
- return '"' + this + '"';
- }; */
+/*! Leaflet.widget - v0.1.0 - 2012-10-24
+* Copyright (c) 2012 Affinity Bridge - Tom Nightingale <tom@affinitybridge.com> (http://affinitybridge.com)
+* Licensed BSD */
L.GeoJSONUtil = {
featureCollection: function (features) {
View
26 dist/Leaflet.widget.min.js
@@ -1,24 +1,4 @@
-/*! Leaflet.widget - v0.1.0 - 2012-10-23
-* Copyright (c) 2012 function () {
-
-// If the string looks like an identifier, then we can return it as is.
-// If the string contains no control characters, no quote characters, and no
-// backslash characters, then we can simply slap some quotes around it.
-// Otherwise we must also replace the offending characters with safe
-// sequences.
-
- if (ix.test(this)) {
- return this;
- }
- if (nx.test(this)) {
- return '"' + this.replace(nxg, function (a) {
- var c = escapes[a];
- if (c) {
- return c;
- }
- return '\\u' + ('0000' + a.charCodeAt().toString(16)).slice(-4);
- }) + '"';
- }
- return '"' + this + '"';
- }; */
+/*! Leaflet.widget - v0.1.0 - 2012-10-24
+* Copyright (c) 2012 Affinity Bridge - Tom Nightingale <tom@affinitybridge.com> (http://affinitybridge.com)
+* Licensed BSD */
L.GeoJSONUtil={featureCollection:function(e){return{type:"FeatureCollection",features:e||[]}},feature:function(e,t){return{type:"Feature",geometry:e,properties:t||{}}},latLngsToCoords:function(e){var t=[],n;for(var r=0,i=e.length;r<i;r++)n=L.GeoJSONUtil.latLngToCoord(e[r]),t.push(n);return t},latLngToCoord:function(e){return[e.lng,e.lat]}},L.WidgetFeatureGroup=L.LayerGroup.extend({initialize:function(e){L.LayerGroup.prototype.initialize.call(this,e),this._size=e?e.length:0},addLayer:function(e){this._size+=1,L.LayerGroup.prototype.addLayer.call(this,e)},removeLayer:function(e){this._size-=1,L.LayerGroup.prototype.removeLayer.call(this,e)},clearLayers:function(){this._size=0,L.LayerGroup.prototype.clearLayers.call(this)},toGeoJSON:function(){var e=[];return this.eachLayer(function(t){e.push(t.toGeoJSON())}),L.GeoJSONUtil.featureCollection(e)},size:function(){return this._size},getBounds:L.FeatureGroup.prototype.getBounds}),L.widgetFeatureGroup=function(e){return new L.WidgetFeatureGroup(e)},L.Path.include({toGeoJSON:function(){return L.GeoJSONUtil.feature(this.toGeometry())}}),L.FeatureGroup.include({toGeometry:function(){var e=[];return this.eachLayer(function(t){var n=t.toGeometry();if(n.type!=="Point")return;e.push(n.coordinates)}),{type:"MultiPoint",coordinates:e}}}),L.Marker.include({toGeometry:function(){return{type:"Point",coordinates:L.GeoJSONUtil.latLngToCoord(this.getLatLng())}},toGeoJSON:function(){return L.GeoJSONUtil.feature(this.toGeometry())}}),L.Polyline.include({toGeometry:function(){return{type:"LineString",coordinates:L.GeoJSONUtil.latLngsToCoords(this.getLatLngs())}}}),L.Polygon.include({toGeometry:function(){return{type:"Polygon",coordinates:[L.GeoJSONUtil.latLngsToCoords(this.getLatLngs())]}}}),L.MultiPolyline.include({toGeometry:function(){var e=[];return this.eachLayer(function(t){e.push(t.toGeometry().coordinates)}),{type:"MultiLineString",coordinates:e}},toGeoJSON:function(){return L.GeoJSONUtil.feature(this.toGeometry())}}),L.MultiPolygon.include({toGeometry:function(){var e=[];return this.eachLayer(function(t){e.push(t.toGeometry().coordinates)}),{type:"MultiPolygon",coordinates:e}},toGeoJSON:function(){return L.GeoJSONUtil.feature(this.toGeometry())}}),L.Control.Draw.mergeOptions({select:{title:"Select items"}});var onAdd=L.Control.Draw.prototype.onAdd;L.Control.Draw.include({onAdd:function(e){var t="leaflet-control-draw",n=onAdd.call(this,e);return this.options.select&&(this.handlers.select=new L.Handler.Select(e,this.options.select),this._createButton(this.options.select.title,t+"-select",n,this.handlers.select.enable,this.handlers.select),this.handlers.select.on("activated",this._disableInactiveModes,this)),n}}),L.Handler.Select=L.Handler.extend({includes:L.Mixin.Events,options:{},initialize:function(e,t){L.Util.setOptions(this,t),L.Handler.prototype.initialize.call(this,e)},enable:function(){this.fire("activated"),L.Handler.prototype.enable.call(this)},addHooks:function(){this._map&&this.options.selectable&&(this._selected=L.layerGroup(),this._selectable=this.options.selectable,this._selectable.eachLayer(function(e){this._bind(e)},this),this._map.on({layeradd:this._bind,layerremove:this._unbind},this))},removeHooks:function(){this._map&&this._selectable&&(this._selectable.eachLayer(function(e){this._unbind(e)},this),delete this._selected,this._map.off({layeradd:this._bind,layerremove:this._unbind},this))},select:function(e){var t=e.layer||e.target||e;t.off("click",this.select),t.on("click",this.deselect,this),this._selected.addLayer(t),this._map.fire("selected",{layer:t})},deselect:function(e,t){var n=e.layer||e.target||e;n.off("click",this.deselect),this._selected.removeLayer(n),this._map.fire("deselected",{layer:n}),t||n.on("click",this.select,this)},applyToSelected:function(e,t){this._selected.eachLayer(e,t)},_bind:function(e){var t=e.layer?e.layer:e;this._selectable.hasLayer(t)&&t.on("click",this.select,this)},_unbind:function(e){var t=e.layer?e.layer:e;this._selectable.hasLayer(t)&&this._selected.hasLayer(t)&&this.deselect(t,!0)}}),L.LayerGroup.include({hasLayer:function(e){return!!this._layers[L.Util.stamp(e)]}}),L.Control.Select=L.Control.extend({options:{title:"Remove selected features",position:"bottomright",remove:!0},onAdd:function(e){this._map=e;var t="leaflet-select-control",n=L.DomUtil.create("div",t);return this.options.remove&&this._createButton(this.options.remove.title,t+"-remove",n,this._delete,this),n},_delete:function(){this._map.drawControl.handlers.select.applyToSelected(function(e){this._map.removeLayer(e)},this)},_createButton:function(e,t,n,r,i){var s=L.DomUtil.create("a",t,n);return s.href="#",s.title=e,L.DomEvent.on(s,"click",L.DomEvent.stopPropagation).on(s,"mousedown",L.DomEvent.stopPropagation).on(s,"dblclick",L.DomEvent.stopPropagation).on(s,"click",L.DomEvent.preventDefault).on(s,"click",r,i),s}}),L.Map.addInitHook(function(){this.options.drawControl.select&&(this.selectControl=L.Control.select(this.options.drawControl.select),this.addControl(this.selectControl))}),L.Control.select=function(e){return new L.Control.Select(e)},L.Map.mergeOptions({widget:!1}),L.Handler.Widget=L.Handler.extend({includes:L.Mixin.Events,options:{multiple:!0,cardinality:0,autoCenter:!0,defaultVectorStyle:{color:"#0033ff"},selectedVectorStyle:{color:"#F00"},drawVectorStyle:{color:"#F0F",clickable:!0}},initialize:function(e,t){L.Util.setOptions(this,t),L.Handler.prototype.initialize.call(this,e),this._map.drawControl||this._initDraw()},addHooks:function(){this._map&&this.options.attach&&(this.vectors=L.widgetFeatureGroup().addTo(this._map),this._attach=L.DomUtil.get(this.options.attach),this._full=!1,this._cardinality=this.options.multiple?this.options.cardinality:1,this.load(this._attach.value),this._map.drawControl.handlers.select.options.selectable=this.vectors,this._map.on({"draw:poly-created draw:marker-created":this._onCreated,selected:this._onSelected,deselected:this._onDeselected,layerremove:this._unbind},this),this.vectors.size()>0&&this.options.autoCenter&&this._map.fitBounds(this.vectors.getBounds()))},removeHooks:function(){this._map&&(this._map.removeLayer(this.vectors),delete this.vectors,this._map.off({"draw:poly-created draw:marker-created":this._onCreated,selected:this._onSelected,deselected:this._onDeselected,layerremove:this._unbind},this))},_initDraw:function(){this._map.drawControl=(new L.Control.Draw({position:"topright",polyline:{shapeOptions:this.options.drawVectorStyle},polygon:{shapeOptions:this.options.drawVectorStyle},circle:!1,rectangle:!1})).addTo(this._map),this._map.selectControl=L.Control.select().addTo(this._map)},_addVector:function(e){this.vectors.addLayer(e),this._cardinality>0&&this._cardinality<=this.vectors.size()&&(this._full=!0)},_onCreated:function(e){var t=/(?!:)[a-z]+(?=-)/.exec(e.type)[0],n=e[t]||!1;n&&!this._full&&this._addVector(n)},_onSelected:function(e){var t=e.layer;if(t.setStyle)t.setStyle(this.options.selectedVectorStyle);else{var n=t.options.icon;n.options.className="marker-selected",t.setIcon(n),n.options.className=""}},_onDeselected:function(e){var t=e.layer;t.setStyle?t.setStyle(this.options.defaultVectorStyle):t.setIcon(t.options.icon)},_unbind:function(e){var t=e.layer;this.vectors.hasLayer(t)&&(this.vectors.removeLayer(t),this._cardinality>this.vectors.size()&&(this._full=!1))},load:function(e){var t,n=function(e,t){this._addVector(t)};if(!e)return;return t=typeof e=="string"?JSON.parse(e):e,L.geoJson(t,{onEachFeature:L.Util.bind(n,this)})},write:function(){var e=this.vectors.toGeoJSON();this._attach.value=JSON.stringify(e)}}),L.Map.addInitHook(function(){if(this.options.widget){var e=this.options.widget;this.widget=new L.Handler.Widget(this,e)}});
View
4 grunt.js
@@ -10,8 +10,8 @@ module.exports = function(grunt) {
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' +
- '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>; */' //' +
- // ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'
+ '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
+ '* Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'
},
lint: {
files: ['grunt.js', 'src/**/*.js', 'test/**/*.js']
Please sign in to comment.
Something went wrong with that request. Please try again.