(function( $ ) { var radioCheck = /radio|checkbox/i, keyBreaker = /[^\[\]]+/g, numberMatcher = /^[\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?$/; var isNumber = function( value ) { if ( typeof value == 'number' ) { return true; } if ( typeof value != 'string' ) { return false; } return value.match(numberMatcher); }; $.fn.extend({ /** * @parent dom * @download http://jmvcsite.heroku.com/pluginify?plugins[]=jquery/dom/form_params/form_params.js * @plugin jquery/dom/form_params * @test jquery/dom/form_params/qunit.html *

Returns an object of name-value pairs that represents values in a form. * It is able to nest values whose element's name has square brackets.

* Example html: * @codestart html * <form> * <input name="foo[bar]" value='2'/> * <input name="foo[ced]" value='4'/> * <form/> * @codeend * Example code: * @codestart * $('form').formParams() //-> { foo:{bar:2, ced: 4} } * @codeend * * @demo jquery/dom/form_params/form_params.html * * @param {Boolean} [convert] True if strings that look like numbers and booleans should be converted. Defaults to true. * @return {Object} An object of name-value pairs. */ formParams: function( convert ) { if ( this[0].nodeName.toLowerCase() == 'form' && this[0].elements ) { return jQuery(jQuery.makeArray(this[0].elements)).getParams(convert); } return jQuery("input[name], textarea[name], select[name]", this[0]).getParams(convert); }, getParams: function( convert ) { var data = {}, current; convert = convert === undefined ? true : convert; this.each(function() { var el = this, type = el.type && el.type.toLowerCase(); //if we are submit, ignore if ((type == 'submit') || !el.name ) { return; } var key = el.name, value = $.data(el, "value") || $.fn.val.call([el]), isRadioCheck = radioCheck.test(el.type), parts = key.match(keyBreaker), write = !isRadioCheck || !! el.checked, //make an array of values lastPart; if ( convert ) { if ( isNumber(value) ) { value = parseFloat(value); } else if ( value === 'true' || value === 'false' ) { value = Boolean(value); } } // go through and create nested objects current = data; for ( var i = 0; i < parts.length - 1; i++ ) { if (!current[parts[i]] ) { current[parts[i]] = {}; } current = current[parts[i]]; } lastPart = parts[parts.length - 1]; //now we are on the last part, set the value if ( lastPart in current && type === "checkbox" ) { if (!$.isArray(current[lastPart]) ) { current[lastPart] = current[lastPart] === undefined ? [] : [current[lastPart]]; } if ( write ) { current[lastPart].push(value); } } else if ( write || !current[lastPart] ) { current[lastPart] = write ? value : undefined; } }); return data; } }); })(jQuery) var lsTrBuilder = { selectTransition : function(el) { // Get parent var parent = jQuery(el).hasClass('3d') ? jQuery('.ls-tr-list-3d') : jQuery('.ls-tr-list-2d'); // Get index var index = jQuery(el).find('option:selected').index(); // Stop preview lsTrBuilder.stopPreview( parent.children('.active') ); // Hide the previous transition box jQuery(parent).children().removeClass('active') // Show the new one jQuery(parent).children().eq(index).addClass('active') }, addTransition : function(el) { // Get select var select = jQuery(el).prev(); // Get parent var parent = jQuery(el).hasClass('3d') ? jQuery('.ls-tr-list-3d') : jQuery('.ls-tr-list-2d'); // Remove notification if any if(parent.find('.ls-no-transitions-notification').length) { // Remove notification parent.children('.ls-no-transitions-notification').remove(); // Remove option from select select.children('.notification').remove(); } // Get clone var clone = jQuery(el).hasClass('3d') ? jQuery('#ls-tr-sample-3d') : jQuery('#ls-tr-sample-2d'); // Append clone var tr = clone.children().clone().appendTo(parent); // Find tr name var name = tr.find('input[name="name"]').val(); // Stop current preview lsTrBuilder.stopPreview(parent); // Append tr to list and select it select.children().prop('selected', false); jQuery( jQuery('