1+ /**
2+ * @license
3+ * Copyright (c) 2015 MediaMath Inc. All rights reserved.
4+ * This code may only be used under the BSD style license found at http://mediamath.github.io/strand/LICENSE.txt
5+
6+ */
7+
8+ ( function ( scope ) {
9+
10+ scope . TestFormView = Polymer ( {
11+ is : "mm-test-form-view" ,
12+
13+ behaviors : [ ] ,
14+
15+ properties : {
16+ // custom form items:
17+ isStandard : {
18+ type : Boolean
19+ } ,
20+
21+ width : {
22+ type : Number ,
23+ observer : '_widthChanged'
24+ } ,
25+
26+ height : {
27+ type : Number ,
28+ observer : '_heightChanged'
29+ } ,
30+
31+ // form data/config:
32+ formData : {
33+ type : Object ,
34+ value : {
35+ 'input' : {
36+ validation : 'int|empty' ,
37+ errorMsg : 'You need to type a number' ,
38+ label : 'Type a number' ,
39+ // value: '100'
40+ } ,
41+ 'dropdown' : {
42+ validation : 'empty' ,
43+ errorMsg : 'You need to select an item' ,
44+ label : 'Select an Item' ,
45+ // value: 'List Item 4'
46+ } ,
47+ 'radio' : {
48+ validation : function ( name , value , data ) {
49+ return data [ name ] === 'Red' && value === 'Red' ;
50+ } ,
51+ errorMsg : 'You need to select \'Red\'' ,
52+ label : 'Select a Color' ,
53+ // value: 'Red'
54+ } ,
55+ 'width' : {
56+ validation : function ( name , value , data ) {
57+ return parseInt ( value ) >= 0 ;
58+ } ,
59+ errorMsg : 'You need to type a number'
60+ } ,
61+ 'height' : {
62+ validation : function ( name , value , data ) {
63+ return parseInt ( value ) >= 0 ;
64+ } ,
65+ errorMsg : 'You need to type a number'
66+ }
67+ }
68+ } ,
69+
70+ } ,
71+
72+ _handleRadioSelected : function ( e ) {
73+ switch ( e . detail . item . id ) {
74+ case 'standardSize' :
75+ this . isStandard = true ;
76+ break ;
77+ case 'nonStandardSize' :
78+ this . isStandard = false ;
79+ break ;
80+ default :
81+ return ;
82+ }
83+ } ,
84+
85+ // _valueChanged: function(newVal, oldVal) {
86+ // if (newVal) {
87+ // this.fire('changed', { value: newVal });
88+
89+ // // set the dropdown if needed
90+ // if (!this.nonStandardSize) {
91+ // if (!this.$.standardSizeDdl.value) {
92+ // this.$.standardSizeDdl.value = String(
93+ // this.value.width + 'x' + this.value.height
94+ // );
95+ // }
96+ // } else {
97+ // this.$.width.value = this.value.width;
98+ // this.$.height.value = this.value.height;
99+ // }
100+ // }
101+ // },
102+
103+ _standardSizeChanged : function ( e ) {
104+ var dimensions = e . detail . value . split ( 'x' ) ,
105+ width = parseInt ( dimensions [ 0 ] ) ,
106+ height = parseInt ( dimensions [ 1 ] ) ;
107+ this . _dimensionsChanged ( width , height ) ;
108+ } ,
109+
110+ _widthChanged : function ( newVal , oldVal ) {
111+ console . log ( '_widthChanged: ' , newVal ) ;
112+ } ,
113+
114+ _heightChanged : function ( newVal , oldVal ) {
115+ console . log ( '_heightChanged: ' , newVal ) ;
116+ } ,
117+
118+ _dimensionsChanged : function ( width , height ) {
119+ this . width = width ;
120+ this . height = height ;
121+ }
122+
123+ } ) ;
124+
125+ } ) ( window . Strand = window . Strand || { } ) ;
0 commit comments