-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dan Lasky
committed
Mar 3, 2016
1 parent
0545f08
commit 0d8b227
Showing
4 changed files
with
199 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script language="javascript" src="../../bower_components/webcomponentsjs/webcomponents-lite.js"></script> | ||
<link rel="import" href="mm-array-munge.html"> | ||
<style type="text/css"> | ||
body, html { | ||
height: 100%; | ||
min-height: 100%; | ||
} | ||
|
||
body { | ||
margin:0; | ||
padding:0; | ||
background: #eee; | ||
} | ||
|
||
|
||
</style> | ||
</head> | ||
<body> | ||
<dom-module id="munge-test"> | ||
<template> | ||
<mm-array-munge input="{{input}}" output="{{output}}" rules="a->name,a->value"></mm-array-munge> | ||
</template> | ||
</dom-module> | ||
<script> | ||
HTMLImports.whenReady(function() { | ||
Polymer({ | ||
is:'munge-test', | ||
properties:{ | ||
input:{ | ||
type:Array, | ||
value: function() { | ||
return [ | ||
{a:1}, | ||
{a:2}, | ||
{a:3} | ||
]; | ||
} | ||
}, | ||
output:{ | ||
type:Array, | ||
} | ||
}, | ||
_mash: function(o) { | ||
return o.map(JSON.stringify); | ||
} | ||
}); | ||
}); | ||
</script> | ||
<munge-test></munge-test> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!-- | ||
* @license | ||
* Copyright (c) 2015 MediaMath Inc. All rights reserved. | ||
* This code may only be used under the BSD style license found at http://mediamath.github.io/strand/LICENSE.txt | ||
--> | ||
<link rel="import" href="../../bower_components/polymer/polymer.html"/> | ||
<link rel="import" href="../shared/fonts/fonts.html"/> | ||
<link rel="import" href="../shared/js/colors.html"/> | ||
<link rel="import" href="../shared/behaviors/resolvable.html"/> | ||
<link rel="import" href="../shared/behaviors/stylable.html"/> | ||
<link rel="import" href="../shared/behaviors/refable.html"/> | ||
|
||
<dom-module id="mm-action"> | ||
<link rel="import" type="css" href="mm-array-munge.css"/> | ||
<template> | ||
</template> | ||
</dom-module> | ||
<script src="mm-array-munge.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/** | ||
* @license | ||
* Copyright (c) 2015 MediaMath Inc. All rights reserved. | ||
* This code may only be used under the BSD style license found at http://mediamath.github.io/strand/LICENSE.txt | ||
*/ | ||
(function (scope) { | ||
|
||
scope.ArrayMunge = Polymer({ | ||
is: "mm-array-munge", | ||
|
||
behaviors: [ | ||
StrandTraits.Resolvable, | ||
StrandTraits.Refable | ||
], | ||
|
||
properties: { | ||
_parsedRules:{ | ||
type:Array, | ||
value: function() { return []; } | ||
}, | ||
input:{ | ||
type:Array, | ||
notify:true | ||
}, | ||
output:{ | ||
type:Array, | ||
notify:true | ||
}, | ||
rules:{ | ||
type:String, | ||
value:"", | ||
observer:"_parseRules" | ||
} | ||
}, | ||
|
||
observers:['_handleInputUpdate(input.*, _parsedRules)'], | ||
|
||
_handleInputUpdate() { | ||
var o = this.input.map(function(i) { | ||
var o = {}; | ||
this._parsedRules.forEach(function(rule) { | ||
var val = rule.from === '.' ? i : i[rule.from]; | ||
if (rule.to !== '.') { | ||
o[rule.to] = val; | ||
} else { | ||
o = val; | ||
} | ||
}) | ||
return o; | ||
},this); | ||
this.set('output', o); | ||
}, | ||
|
||
_parseRules: function() { | ||
this._parsedRules = this.rules.split(",").map(function(rule) { | ||
var parsed = rule.split("->"); | ||
if (parsed.length === 2) { | ||
return { | ||
from:parsed[0], | ||
to:parsed[1] | ||
} | ||
} | ||
}, this).filter(function(o) { return !!o }); | ||
} | ||
|
||
}); | ||
|
||
})(window.Strand = window.Strand || {}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/** | ||
* @license | ||
* Copyright (c) 2015 MediaMath Inc. All rights reserved. | ||
* This code may only be used under the BSD style license found at http://mediamath.github.io/strand/LICENSE.txt | ||
*/ | ||
/* test.sass */ | ||
@import "_bourbon"; | ||
@import "_color"; | ||
@import "_mixins"; | ||
|
||
:host { | ||
color: $color-D0; | ||
position: relative; | ||
display: inline-block; | ||
vertical-align: middle; | ||
font-size: 0em; | ||
line-height: 0em; | ||
} | ||
|
||
:host([disabled]) { | ||
pointer-events:none; | ||
opacity: 0.5; | ||
} | ||
|
||
.action { | ||
display: inline-flex; | ||
align-items: center; | ||
|
||
color: inherit; | ||
cursor: pointer; | ||
text-decoration: none; | ||
|
||
&.underline > ::content label { | ||
text-decoration: underline; | ||
} | ||
|
||
&.underline:hover > ::content label { | ||
text-decoration: none; | ||
} | ||
|
||
& > ::content label { | ||
@include fontSmoothing(); | ||
font-size: 13px; | ||
line-height: 15px; | ||
font-family: "ArimoRegular", sans-serif; | ||
pointer-events: none; | ||
color: inherit; | ||
} | ||
|
||
& > ::content mm-icon { | ||
pointer-events: none; | ||
padding-right: 5px; | ||
margin-top: -1px; | ||
color: inherit; | ||
} | ||
} |