-
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.
- flatten values - add formable behavior - test form component
- Loading branch information
1 parent
5dbed33
commit a4ba778
Showing
15 changed files
with
231 additions
and
145 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
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
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
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,10 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script language="javascript" src="../../bower_components/webcomponentsjs/webcomponents-lite.js"></script> | ||
<link rel="import" href="mm-dimensions.html"/> | ||
</head> | ||
<body> | ||
<mm-dimensions></mm-dimensions> | ||
</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,52 @@ | ||
<!-- | ||
* @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="../mm-dropdown/mm-dropdown.html" /> | ||
<link rel="import" href="../mm-input/mm-input.html" /> | ||
<link rel="import" href="../mm-inline-box/mm-inline-box.html" /> | ||
<link rel="import" href="../mm-radio/mm-radio.html" /> | ||
<link rel="import" href="../mm-group/mm-group.html" /> | ||
|
||
<link rel="import" href="../shared/behaviors/resolvable.html"/> | ||
<link rel="import" href="../shared/behaviors/formable.html"/> | ||
|
||
<dom-module id="mm-dimensions"> | ||
<link rel="import" type="css" href="mm-dimensions.css"/> | ||
<template> | ||
<mm-radio | ||
id="standardSize" | ||
group="sizes" | ||
checked | ||
on-selected="_handleRadioSelected"></mm-radio> | ||
<mm-dropdown | ||
id="standardSizeDdl" | ||
disabled$="{{!isStandard}}" | ||
on-changed="_standardSizeChanged" | ||
placeholder="Select One"> | ||
<mm-list-item>160x600</mm-list-item> | ||
<mm-list-item>728x90</mm-list-item> | ||
<mm-list-item>300x250</mm-list-item> | ||
</mm-dropdown> | ||
<mm-radio | ||
id="nonStandardSize" | ||
group="sizes" | ||
on-selected="_handleRadioSelected"></mm-radio> | ||
<mm-group id="nonStandardSizeGroup" disabled$="{{isStandard}}"> | ||
<mm-input | ||
id="width" | ||
placeholder="Width" | ||
validation="int" | ||
on-changed="_widthChanged"></mm-input> | ||
<mm-input | ||
id="height" | ||
placeholder="Height" | ||
validation="int" | ||
on-changed="_heightChanged"></mm-input> | ||
</mm-group> | ||
</template> | ||
</dom-module> | ||
|
||
<script src="mm-dimensions.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,97 @@ | ||
/** | ||
* @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) { | ||
|
||
// special form component to validate assumptions: | ||
scope.Dimensions = Polymer({ | ||
is: "mm-dimensions", | ||
|
||
behaviors: [ | ||
StrandTraits.Resolvable, | ||
StrandTraits.Formable | ||
], | ||
|
||
properties: { | ||
value: { | ||
type: Object, | ||
notify: true, | ||
value: function() { | ||
return { | ||
width: null, | ||
height: null | ||
} | ||
}, | ||
observer: "_valueChanged" | ||
}, | ||
isStandard: { | ||
type: Boolean | ||
} | ||
}, | ||
|
||
_handleRadioSelected: function(e) { | ||
switch (e.detail.item.id) { | ||
case 'standardSize': | ||
this.isStandard = true; | ||
break; | ||
case 'nonStandardSize': | ||
this.isStandard = false; | ||
break; | ||
default: | ||
return; | ||
} | ||
}, | ||
|
||
_valueChanged: function(newVal, oldVal) { | ||
if (newVal) { | ||
this.fire('changed', { value: newVal }); | ||
|
||
// set the dropdown if needed | ||
if (!this.nonStandardSize) { | ||
if (!this.$.standardSizeDdl.value) { | ||
this.$.standardSizeDdl.value = String( | ||
this.value.width + 'x' + this.value.height | ||
); | ||
} | ||
} else { | ||
this.$.width.value = this.value.width; | ||
this.$.height.value = this.value.height; | ||
} | ||
} | ||
}, | ||
|
||
_standardSizeChanged: function(e) { | ||
var dimensions = e.detail.value.split('x'), | ||
width = parseInt(dimensions[0]), | ||
height = parseInt(dimensions[1]); | ||
this._dimensionsChanged(width, height); | ||
}, | ||
_widthChanged: function(e) { | ||
e.preventDefault(); | ||
if (e.detail.value) { | ||
var width = parseInt(e.detail.value), | ||
height = this.value ? this.value.height : null; | ||
this._dimensionsChanged(width, height); | ||
} | ||
}, | ||
_heightChanged: function(e) { | ||
e.preventDefault(); | ||
if (e.detail.value) { | ||
var width = this.value ? this.value.width : null, | ||
height = parseInt(e.detail.value); | ||
this._dimensionsChanged(width, height); | ||
} | ||
}, | ||
_dimensionsChanged: function(width, height) { | ||
this.value = { | ||
width: width, | ||
height: height | ||
} | ||
} | ||
}); | ||
|
||
})(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,18 @@ | ||
/** | ||
* @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 | ||
*/ | ||
@import "_bourbon"; | ||
|
||
:host { | ||
position: relative; | ||
display: flex; | ||
align-items: center; | ||
font-size: 0; | ||
} | ||
|
||
mm-dropdown { | ||
margin-right: 15px; | ||
} |
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
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
Oops, something went wrong.