polymer-rails-forms 0.2.01 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/assets/rails-forms/rails-form-helpers.html +295 -422
- data/assets/rails-forms/rails-form-validators.html +24 -18
- data/assets/rails-forms/rails-form.html +533 -186
- metadata +4 -3
| @@ -1,14 +1,11 @@ | |
| 1 1 | 
             
            <script>
         | 
| 2 2 | 
             
            	var Validation = {
         | 
| 3 | 
            -
            		 | 
| 4 | 
            -
            		validatedInputs: {},
         | 
| 5 | 
            -
             | 
| 6 | 
            -
            		addValidation: function(type, input){
         | 
| 3 | 
            +
            		addValidation: function(type, input, structure, key, data){
         | 
| 7 4 | 
             
            			//TODO should validate everything
         | 
| 8 | 
            -
            		    if ( | 
| 9 | 
            -
            		        var fn = function(){ this.validate( | 
| 10 | 
            -
            		    } else if (!! | 
| 11 | 
            -
            		    	var fn =  function(){ this[ | 
| 5 | 
            +
            		    if (structure.required){
         | 
| 6 | 
            +
            		        var fn = function(k){ return this.validate(structure.type, input, true, data, k); }.bind(this, key)
         | 
| 7 | 
            +
            		    } else if (!!structure.validates){
         | 
| 8 | 
            +
            		    	var fn =  function(k){ return this[structure.validates](type, input, true || false, data, k) }.bind(this, key)
         | 
| 12 9 | 
             
            		    } else {
         | 
| 13 10 | 
             
            		    	var fn = function(){ return false; }
         | 
| 14 11 | 
             
            		    }
         | 
| @@ -19,6 +16,15 @@ | |
| 19 16 | 
             
            		    input.addEventListener('DOMNodeRemoved', function(){ delete this.validatedInputs[key] }.bind(this), false);
         | 
| 20 17 | 
             
            		},
         | 
| 21 18 |  | 
| 19 | 
            +
            		genIndexStoreKey: function(){
         | 
| 20 | 
            +
            	      var key = "_" + ((Math.random() * 1000000) | 0); 
         | 
| 21 | 
            +
            	      while(this.validatedInputs[key] !== void(0)){
         | 
| 22 | 
            +
            	        key = "_" + ((Math.random() * 1000000) | 0);
         | 
| 23 | 
            +
            	      }
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            	      return key;
         | 
| 26 | 
            +
            	    },
         | 
| 27 | 
            +
            		
         | 
| 22 28 | 
             
            		invalidate: function(type, input, isInvalid){
         | 
| 23 29 | 
             
            			var parent = this.findParent(input, 'gc-input-decorator'),
         | 
| 24 30 | 
             
            				wrapper = this.findParent(input, '.input-wrapper'),
         | 
| @@ -43,10 +49,8 @@ | |
| 43 49 | 
             
            			}
         | 
| 44 50 | 
             
            		},
         | 
| 45 51 |  | 
| 46 | 
            -
            		validate: function(type, input, required,  | 
| 47 | 
            -
            			 | 
| 48 | 
            -
            			invalidate = invalidate || true;
         | 
| 49 | 
            -
             | 
| 52 | 
            +
            		validate: function(type, input, required, data, key){
         | 
| 53 | 
            +
            			
         | 
| 50 54 | 
             
            			var validators = {
         | 
| 51 55 | 
             
            				string: function(){
         | 
| 52 56 | 
             
            		        	return !(required && input.value.replace(/(^ *| *$)/g, "").length > 0);
         | 
| @@ -89,13 +93,17 @@ | |
| 89 93 | 
             
            		        }.bind(this),
         | 
| 90 94 |  | 
| 91 95 | 
             
            		        location: function(){
         | 
| 92 | 
            -
             | 
| 96 | 
            +
            		        	return data[key].lat === null || data[key].lng === null
         | 
| 93 97 | 
             
            		        }.bind(this),
         | 
| 94 98 |  | 
| 95 99 | 
             
            		        image: function(){
         | 
| 96 100 | 
             
            		        	return !(required && input.value.length > 0)
         | 
| 97 101 | 
             
            		        }.bind(this),
         | 
| 98 102 |  | 
| 103 | 
            +
            		        file: function(){
         | 
| 104 | 
            +
            		        	return !(required && input.value.length > 0)
         | 
| 105 | 
            +
            		        }.bind(this),
         | 
| 106 | 
            +
             | 
| 99 107 | 
             
            		        select: function(){
         | 
| 100 108 | 
             
            		        	return false;
         | 
| 101 109 | 
             
            		        }
         | 
| @@ -103,10 +111,9 @@ | |
| 103 111 |  | 
| 104 112 | 
             
            			var isInvalid = (!!validators[type] && validators[type]())
         | 
| 105 113 |  | 
| 106 | 
            -
            			 | 
| 107 | 
            -
             | 
| 108 | 
            -
            			 | 
| 109 | 
            -
             | 
| 114 | 
            +
            			
         | 
| 115 | 
            +
            			this.invalidate(type, input, isInvalid);
         | 
| 116 | 
            +
            			
         | 
| 110 117 | 
             
            			return isInvalid;
         | 
| 111 118 | 
             
            		},
         | 
| 112 119 |  | 
| @@ -117,7 +124,6 @@ | |
| 117 124 | 
             
            					isInvalid = true;
         | 
| 118 125 | 
             
            				}
         | 
| 119 126 | 
             
            			}
         | 
| 120 | 
            -
             | 
| 121 127 | 
             
            			return isInvalid;
         | 
| 122 128 | 
             
            		}
         | 
| 123 129 | 
             
            	}
         |