| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 | 
							- (function ($) {
 
-     "use strict";
 
-     
 
-     var Address = function (options) {
 
-         this.init('address', options, Address.defaults);
 
-     };
 
-     //inherit from Abstract input
 
-     $.fn.editableutils.inherit(Address, $.fn.editabletypes.abstractinput);
 
-     $.extend(Address.prototype, {
 
-         /**
 
-         Renders input from tpl
 
-         @method render() 
 
-         **/        
 
-         render: function() {
 
-            this.$input = this.$tpl.find('input');
 
-         },
 
-         
 
-         /**
 
-         Default method to show value in element. Can be overwritten by display option.
 
-         
 
-         @method value2html(value, element) 
 
-         **/
 
-         value2html: function(value, element) {
 
-             if(!value) {
 
-                 $(element).empty();
 
-                 return; 
 
-             }
 
-             var html = $('<div>').text(value.city).html() + ', ' + $('<div>').text(value.street).html() + ' st., bld. ' + $('<div>').text(value.building).html();
 
-             $(element).html(html); 
 
-         },
 
-         
 
-         /**
 
-         Gets value from element's html
 
-         
 
-         @method html2value(html) 
 
-         **/        
 
-         html2value: function(html) {        
 
-           /*
 
-             you may write parsing method to get value by element's html
 
-             e.g. "Moscow, st. Lenina, bld. 15" => {city: "Moscow", street: "Lenina", building: "15"}
 
-             but for complex structures it's not recommended.
 
-             Better set value directly via javascript, e.g. 
 
-             editable({
 
-                 value: {
 
-                     city: "Moscow", 
 
-                     street: "Lenina", 
 
-                     building: "15"
 
-                 }
 
-             });
 
-           */ 
 
-           return null;  
 
-         },
 
-       
 
-        /**
 
-         Converts value to string. 
 
-         It is used in internal comparing (not for sending to server).
 
-         
 
-         @method value2str(value)  
 
-        **/
 
-        value2str: function(value) {
 
-            var str = '';
 
-            if(value) {
 
-                for(var k in value) {
 
-                    str = str + k + ':' + value[k] + ';';  
 
-                }
 
-            }
 
-            return str;
 
-        }, 
 
-        
 
-        /*
 
-         Converts string to value. Used for reading value from 'data-value' attribute.
 
-         
 
-         @method str2value(str)  
 
-        */
 
-        str2value: function(str) {
 
-            /*
 
-            this is mainly for parsing value defined in data-value attribute. 
 
-            If you will always set value by javascript, no need to overwrite it
 
-            */
 
-            return str;
 
-        },                
 
-        
 
-        /**
 
-         Sets value of input.
 
-         
 
-         @method value2input(value) 
 
-         @param {mixed} value
 
-        **/         
 
-        value2input: function(value) {
 
-            if(!value) {
 
-              return;
 
-            }
 
-            this.$input.filter('[name="city"]').val(value.city);
 
-            this.$input.filter('[name="street"]').val(value.street);
 
-            this.$input.filter('[name="building"]').val(value.building);
 
-        },       
 
-        
 
-        /**
 
-         Returns value of input.
 
-         
 
-         @method input2value() 
 
-        **/          
 
-        input2value: function() { 
 
-            return {
 
-               city: this.$input.filter('[name="city"]').val(), 
 
-               street: this.$input.filter('[name="street"]').val(), 
 
-               building: this.$input.filter('[name="building"]').val()
 
-            };
 
-        },        
 
-        
 
-         /**
 
-         Activates input: sets focus on the first field.
 
-         
 
-         @method activate() 
 
-        **/        
 
-        activate: function() {
 
-             this.$input.filter('[name="city"]').focus();
 
-        },  
 
-        
 
-        /**
 
-         Attaches handler to submit form in case of 'showbuttons=false' mode
 
-         
 
-         @method autosubmit() 
 
-        **/       
 
-        autosubmit: function() {
 
-            this.$input.keydown(function (e) {
 
-                 if (e.which === 13) {
 
-                     $(this).closest('form').submit();
 
-                 }
 
-            });
 
-        }       
 
-     });
 
-     Address.defaults = $.extend({}, $.fn.editabletypes.abstractinput.defaults, {
 
-         tpl: '<div class="form-group editable-address margin-bottom-15"><label>City:</label> <input type="text" name="city" class="form-control"></div>'+
 
-              '<div class="form-group editable-address margin-bottom-15"><label>Street:</label> <input type="text" name="street" class="form-control"></div>'+
 
-              '<div class="form-group editable-address margin-bottom-15"><label>Building:</label> <input type="text" name="building" class="form-control"></div>',
 
-              
 
-         inputclass: ''
 
-     });
 
-     $.fn.editabletypes.address = Address;
 
- }(window.jQuery));
 
 
  |