Permalink
Browse files

refactor

  • Loading branch information...
1 parent 02f706c commit e5184a07dac7ae6eb59c3c54f7c2ef89b8c57617 Calvin Metcalf committed Mar 13, 2013
View
@@ -0,0 +1,22 @@
+fs = require 'fs'
+coffee = require 'coffee-script'
+uglifyjs = require 'uglify-js'
+
+task 'build', 'build it', () ->
+ blankB = fs.readFileSync "./src/blank.png"
+ blank = blankB.toString("base64")
+ fs.writeFile "./dist/blank.png", blankB
+ spriteB = fs.readFileSync "./src/sprite.png"
+ sprite = spriteB.toString("base64")
+ fs.writeFile "./dist/sprite.png", spriteB
+ fs.readFile "./src/sprite.coffee", "utf8",(e,file)->
+ unless e
+ cs = coffee.compile "blankDURI = 'data:image/png;base64,#{ blank }'\nspriteDURI='data:image/png;base64,#{ sprite }'\n#{ file }"
+ fs.writeFile './dist/leaflet.sprite.js', cs
+ console.log "compliled"
+ ast = uglifyjs.parse cs
+ ast.figure_out_scope();
+ ast.compute_char_frequency();
+ ast.mangle_names();
+ fs.writeFile './dist/leaflet.sprite.min.js', ast.print_to_string()
+ console.log "minified"
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -0,0 +1,89 @@
+/* Left will inherit from right (so we don't need to duplicate code */
+.github-fork-ribbon {
+ /* The right and left lasses determine the side we attach our banner to */
+ position: absolute;
+
+ /* Add a bit of padding to give some substance outside the "stitching" */
+ padding: 2px 0;
+
+ /* Set the base colour */
+ background-color: #a00;
+
+ /* Set a gradient: transparent black at the top to almost-transparent black at the bottom */
+ background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(0, 0, 0, 0.00)), to(rgba(0, 0, 0, 0.15)));
+ background-image: -webkit-linear-gradient(top, rgba(0, 0, 0, 0.00), rgba(0, 0, 0, 0.15));
+ background-image: -moz-linear-gradient(top, rgba(0, 0, 0, 0.00), rgba(0, 0, 0, 0.15));
+ background-image: -o-linear-gradient(top, rgba(0, 0, 0, 0.00), rgba(0, 0, 0, 0.15));
+ background-image: -ms-linear-gradient(top, rgba(0, 0, 0, 0.00), rgba(0, 0, 0, 0.15));
+ background-image: linear-gradient(top, rgba(0, 0, 0, 0.00), rgba(0, 0, 0, 0.15));
+ filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,StartColorStr='#000000', EndColorStr='#000000');
+
+ /* Add a drop shadow */
+ -webkit-box-shadow: 0px 2px 3px 0px rgba(0, 0, 0, 0.5);
+ box-shadow: 0px 2px 3px 0px rgba(0, 0, 0, 0.5);
+ z-index:5;
+}
+.github-fork-ribbon a {
+ /* Set the font */
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
+ font-size: 13px;
+ font-weight: 700;
+ color: white;
+
+ /* Set the text properties */
+ text-decoration: none;
+ text-shadow: 0 -1px rgba(0,0,0,0.5);
+ text-align: center;
+
+ /* Set the geometry. If you fiddle with these you'll also need to tweak the top and right values in #github-fork-ribbon. */
+ width: 200px;
+ line-height: 20px;
+
+ /* Set the layout properties */
+ display: inline-block;
+ padding: 2px 0;
+
+ /* Add "stitching" effect */
+ border-width: 1px 0;
+ border-style: dotted;
+ border-color: rgba(255,255,255,0.7);
+}
+
+.github-fork-ribbon-wrapper {
+ width: 150px;
+ height: 150px;
+ position: absolute;
+ overflow: hidden;
+ top: 0;
+}
+
+.github-fork-ribbon-wrapper.left {
+ left: 0;
+}
+
+.github-fork-ribbon-wrapper.right {
+ right: 0;
+}
+
+.github-fork-ribbon-wrapper.right .github-fork-ribbon {
+ top: 42px;
+ right: -43px;
+
+ /* Rotate the banner 45 degrees */
+ -webkit-transform: rotate(45deg);
+ -moz-transform: rotate(45deg);
+ -o-transform: rotate(45deg);
+ transform: rotate(45deg);
+}
+
+.github-fork-ribbon-wrapper.left .github-fork-ribbon {
+ /* Attach to the left of the page */
+ top: 42px;
+ left: -43px;
+
+ /* Rotate the banner -45 degrees */
+ -webkit-transform: rotate(-45deg);
+ -moz-transform: rotate(-45deg);
+ -o-transform: rotate(-45deg);
+ transform: rotate(-45deg);
+}
@@ -0,0 +1,68 @@
+/* IE voodoo courtesy of http://stackoverflow.com/a/4617511/263871 and
+ * http://www.useragentman.com/IETransformsTranslator */
+.github-fork-ribbon-wrapper.right .github-fork-ribbon {
+ /* IE positioning hack (couldn't find a transform-origin alternative for IE) */
+ top: -22px;
+ right: -62px;
+
+ /* IE8+ */
+ -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.7071067811865474, M12=-0.7071067811865477, M21=0.7071067811865477, M22=0.7071067811865474, SizingMethod='auto expand')";
+ /* IE6 and 7 */
+ filter: progid:DXImageTransform.Microsoft.Matrix(
+ M11=0.7071067811865474,
+ M12=-0.7071067811865477,
+ M21=0.7071067811865477,
+ M22=0.7071067811865474,
+ SizingMethod='auto expand'
+ );
+}
+
+.github-fork-ribbon-wrapper.left .github-fork-ribbon {
+ top: -22px;
+ left: -22px;
+
+ /* IE8+ */
+ -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.7071067811865483, M12=0.7071067811865467, M21=-0.7071067811865467, M22=0.7071067811865483, SizingMethod='auto expand')";
+ /* IE6 and 7 */
+ filter: progid:DXImageTransform.Microsoft.Matrix(
+ M11=0.7071067811865483,
+ M12=0.7071067811865467,
+ M21=-0.7071067811865467,
+ M22=0.7071067811865483,
+ SizingMethod='auto expand'
+ );
+}
+
+.github-fork-ribbon-wrapper.left-bottom .github-fork-ribbon {
+ /* IE positioning hack (couldn't find a transform-origin alternative for IE) */
+ top: 12px;
+ left: -22px;
+
+
+ /* IE8+ */
+ -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.7071067811865474, M12=-0.7071067811865477, M21=0.7071067811865477, M22=0.7071067811865474, SizingMethod='auto expand')";
+ /* IE6 and 7 */
+/* filter: progid:DXImageTransform.Microsoft.Matrix(
+ M11=0.7071067811865474,
+ M12=-0.7071067811865477,
+ M21=0.7071067811865477,
+ M22=0.7071067811865474,
+ SizingMethod='auto expand'
+ );
+*/}
+
+.github-fork-ribbon-wrapper.right-bottom .github-fork-ribbon {
+ top: 12px;
+ right: -62px;
+
+ /* IE8+ */
+ -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.7071067811865483, M12=0.7071067811865467, M21=-0.7071067811865467, M22=0.7071067811865483, SizingMethod='auto expand')";
+ /* IE6 and 7 */
+ filter: progid:DXImageTransform.Microsoft.Matrix(
+ M11=0.7071067811865483,
+ M12=0.7071067811865467,
+ M21=-0.7071067811865467,
+ M22=0.7071067811865483,
+ SizingMethod='auto expand'
+ );
+}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -0,0 +1,38 @@
+var m, mq;
+
+m = L.map('map').setView([42.2, -71], 8);
+
+mq = L.tileLayer("http://otile{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.jpeg", {
+ attribution: 'Tiles Courtesy of <a href="http://www.mapquest.com/">MapQuest</a> &mdash; Map data &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
+ subdomains: '1234'
+}).addTo(m);
+
+L.marker([42, -71], {
+ icon: L.spriteIcon()
+}).addTo(m);
+
+L.marker([42, -71.5], {
+ icon: L.spriteIcon("red")
+}).addTo(m);
+
+L.marker([42, -72], {
+ icon: L.spriteIcon("green")
+}).addTo(m);
+
+L.marker([42, -72.5], {
+ icon: L.spriteIcon("orange")
+}).addTo(m);
+
+L.marker([42.5, -72.5], {
+ icon: L.spriteIcon("purple")
+}).addTo(m);
+
+L.marker([42.5, -72], {
+ icon: L.spriteIcon("violet")
+}).addTo(m);
+
+L.marker([42.5, -71.5], {
+ icon: L.spriteIcon("yellow")
+}).addTo(m);
+
+L.marker([42.5, -71]).addTo(m);
View
@@ -0,0 +1,14 @@
+{
+ "name": "leaflet-sprite",
+ "version": "0.0.1",
+ "dependencies": {
+ "coffee-script":"1.x",
+ "uglify-js" : ">= 0.0.1"
+ },
+ "author": {
+ "name" : "Calvin Metcalf",
+ "email" : "calvin.metcalf@state.ma.us",
+ "url" : "http://cwmma.tumblr.com/"
+ }
+}
+
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -0,0 +1,39 @@
+if L.Browser.vml
+ scripts=document.getElementsByTagName("script")
+ for tag in scripts
+ if tag.src.match /\.sprite(?:\.min)?\.js/
+ base = tag.src.slice(0,tag.src.lastIndexOf("/")+1)
+ break
+ blank = base+'blank.png'
+ sprite = base+'sprite.png'
+else
+ blank=blankDURI
+ sprite=spriteDURI
+L.spriteIcon = (color="blue")->
+ L.icon({className:"leaflet-sprite leaflet-sprite-#{color}",iconSize:[24, 41],shadowsize:[41,41],iconAnchor:[12,41],iconUrl:blank,shadowUrl: L.Icon.Default.imagePath+"/marker-shadow.png"})
+cssRegular = """.leaflet-sprite{background:url(#{sprite}) no-repeat top left;}
+.leaflet-sprite-blue{ background-position: 0 -132px; width: 41px; height: 41px; }
+.leaflet-sprite-green{ background-position: 0 -355px; width: 41px; height: 41px; }
+.leaflet-sprite-orange{ background-position: 0 -578px; width: 41px; height: 41px; }
+.leaflet-sprite-purple{ background-position: 0 -801px; width: 41px; height: 41px; }
+.leaflet-sprite-red{ background-position: 0 -1024px; width: 41px; height: 41px; }
+.leaflet-sprite-violet{ background-position: 0 -1247px; width: 41px; height: 41px; }
+.leaflet-sprite-yellow{ background-position: 0 -1470px; width: 41px; height: 41px; }
+ """
+cssRetina = """.leaflet-sprite{
+background:url(#{sprite}) no-repeat top left;
+background-size:41px, 41px
+}
+ .leaflet-sprite-blue{ background-position: 0 0; width: 82px; height: 82px; }
+ .leaflet-sprite-green{ background-position: 0 -111px; width: 82px; height: 82px; }
+ .leaflet-sprite-orange{ background-position: 0 -223px; width: 82px; height: 82px; }
+ .leaflet-sprite-purple{ background-position: 0 -334px; width: 82px; height: 82px; }
+ .leaflet-sprite-red{ background-position: 0 -446px; width: 82px; height: 82px; }
+ .leaflet-sprite-violet{ background-position: 0 -557px; width: 82px; height: 82px; }
+ .leaflet-sprite-yellow{ background-position: 0 -669px; width: 82px; height: 82px; }
+"""
+if L.Browser.retina
+ L.css([cssRetina])
+else
+ L.css([cssRegular])
+
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e5184a0

Please sign in to comment.