Sha256: b535a8c1dacc42ba0ad0f969db405bc7dbc3583219b80f4901f7087393dedca2

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

// Nestable demo
// ----------------------------------- 


(function(window, document, $, undefined){

  $(function(){

    if ( ! $.fn.nestable ) return;

    var updateOutput = function(e)
    {
        var list   = e.length ? e : $(e.target),
            output = list.data('output');
        
        if ( !output) return;

        if (window.JSON) {
            output.val(window.JSON.stringify(list.nestable('serialize')));//, null, 2));
        } else {
            output.val('JSON browser support required for this demo.');
        }
    };

    // activate Nestable for list 1
    $('#nestable').nestable({
        group: 1
    })
    .on('change', updateOutput);

    // activate Nestable for list 2
    $('#nestable2').nestable({
        group: 1
    })
    .on('change', updateOutput);

    // output initial serialised data
    updateOutput($('#nestable').data('output', $('#nestable-output')));
    updateOutput($('#nestable2').data('output', $('#nestable2-output')));

    $('.js-nestable-action').on('click', function(e)
    {
        var target = $(e.target),
            action = target.data('action');
        if (action === 'expand-all') {
            $('.dd').nestable('expandAll');
        }
        if (action === 'collapse-all') {
            $('.dd').nestable('collapseAll');
        }
    });

  });

})(window, document, window.jQuery);

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
radius-rails-3.1.4 app/assets/javascripts/radius-theme/modules/demo/demo-nestable.js