;(function ($, document, window) {
    'use strict';

    /**
     * Batch View plugin.
     */
    function ViewBatch(element, options)
    {
        this.element = element;
        this.options = options;
        this.helper = {
            'msg': '<span class="help-block" {{id}} style="cursor:pointer;"><i class="fa fa-{{icon}}"></i> {{action}}</span>',
            'enable_id': 'data-batch="enable"',
            'disable_id': 'data-batch="disable"'
        };

        this.init();
    }

    ViewBatch.prototype = {

        /**
         * Initialize method
         *
         * @return {undefined}
         */
        init: function () {
            var that = this;

            $(that.options.target_id).each(function () {
                $(this).attr('disabled', true);
                var msg = that.helper.msg
                    .replace('{{id}}', that.helper.enable_id)
                    .replace('{{icon}}', 'check-circle')
                    .replace('{{action}}', 'Click to edit');
                $(this).parents(that.options.wrapper_id).append(msg);
            });

            $(document).on('click', that.options.disable_id, function () {
                var field = $(this).parent().find(that.options.target_id);
                var msg = that.helper.msg
                    .replace('{{id}}', that.helper.enable_id)
                    .replace('{{icon}}', 'check-circle')
                    .replace('{{action}}', 'Click to edit');
                $(field).parents(that.options.wrapper_id).append(msg);
                if (!$(field).attr('disabled')) {
                    $(field).attr('disabled', true);
                }
                $(this).remove();
            });

            $(document).on('click', that.options.enable_id, function () {
                var field = $(this).parent().find(that.options.target_id);
                var msg = that.helper.msg
                    .replace('{{id}}', that.helper.disable_id)
                    .replace('{{icon}}', 'times-circle')
                    .replace('{{action}}', 'Do not change');
                $(field).parents(that.options.wrapper_id).append(msg);
                if ($(field).attr('disabled')) {
                    $(field).attr('disabled', false);
                    $(field).focus();
                }
                $(this).remove();
            });
        }
    };

    $.fn.viewBatch = function (options) {
        return this.each(function () {
            new ViewBatch(this, options);
        });
    };

})(jQuery, document, window);

@@ -456,24 +456,51 @@
         %7D;%0A%0A
+        this.updateForm();%0A
         this
@@ -2374,24 +2374,590 @@
         %7D);%0A
+        %7D,%0A%0A        updateForm: function () %7B%0A            var that = this;%0A%0A            // update form action%0A            $(this.element).attr('action', $(this.element).attr('action') + '/edit');%0A%0A            // add batch ids to the form as hidden inputs%0A            $(this.options.batch_ids).each(function () %7B%0A                $(that.element).append('%3Cinput type=%22hidden%22 name=%22batch%5Bids%5D%5B%5D%22 value=%22' + this + '%22%3E');%0A            %7D);%0A%0A            // add batch execute flag%0A            $(that.element).append('%3Cinput type=%22hidden%22 name=%22batch%5Bexecute%5D%22 value=%221%22%3E');%0A
         %7D%0A  

Add batch ids and execute flag inputs (task #812)