Sha256: 7671d050aecaa21406bc58bc9cb54554342aa682717575c1021b2d9c39fdac9a

Contents?: true

Size: 1.66 KB

Versions: 42

Compression:

Stored size: 1.66 KB

Contents

/*
 * Better Select Multiple Sortable Plugin
 *
 * Copyright (c) 2010 by Victor Berchet - http://www.github.com/vicb
 *
 * Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses.
 *
 * version: v1.1.1 - 2010-11-17
 */
(function($) {
  $.bsmSelect.plugins.sortable = function(sortConfig, options)
  {
    if (!(this instanceof arguments.callee)) {
      return new arguments.callee(sortConfig, options);
    }
    this.sortConfig = sortConfig;
    this.options = $.extend({}, this.defaultOpt, options || {});
  }

  $.extend($.bsmSelect.plugins.sortable.prototype, {
    defaultOpt: {
      listSortableClass:  'bsmListSortable'
    },

    init: function(bsm) {
      var o = $.extend({}, this.options, bsm.options),
        config = $.extend({}, this.sortConfig, { items: '.' + o.listItemClass }),
        self = this;
      bsm.$list.addClass(o.listSortableClass).sortable(config);
      bsm.$original.bind('change', function(e, info) { self.onChange.call(self, bsm, e, info); } );
      bsm.$list.bind('sortupdate', function(e, ui) { self.onSort.call(self, bsm, e, ui); } );
    },

    onChange: function(bsm, e, info) {
      if (info && info.type == 'add' && !bsm.buildingSelect) {
        info.option.detach()[bsm.options.addItemTarget == 'top' ? 'prependTo' : 'appendTo'](bsm.$original);
        bsm.$list.sortable('refresh');
      }
    },

    onSort: function(bsm, e, ui) {
      $('.' + bsm.options.listItemClass, bsm.$list).each(function() {
        $(this).data('bsm-option').data('orig-option').detach().appendTo(bsm.$original);
      });
      bsm.triggerOriginalChange($(ui.item).data('bsm-option').data('orig-option'), 'sort');
    }
  });
})(jQuery);

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
spiderfw-1.0.1 apps/core/components/public/js/jquery/plugins/bsmselect/js/jquery.bsmselect.sortable.js
spiderfw-1.0.0 apps/core/components/public/js/jquery/plugins/bsmselect/js/jquery.bsmselect.sortable.js
spiderfw-0.6.39 apps/core/components/public/js/jquery/plugins/bsmselect/js/jquery.bsmselect.sortable.js
spiderfw-0.6.38 apps/core/components/public/js/jquery/plugins/bsmselect/js/jquery.bsmselect.sortable.js
spiderfw-0.6.37 apps/core/components/public/js/jquery/plugins/bsmselect/js/jquery.bsmselect.sortable.js
spiderfw-0.6.35 apps/core/components/public/js/jquery/plugins/bsmselect/js/jquery.bsmselect.sortable.js
spiderfw-0.6.34 apps/core/components/public/js/jquery/plugins/bsmselect/js/jquery.bsmselect.sortable.js
spiderfw-0.6.33 apps/core/components/public/js/jquery/plugins/bsmselect/js/jquery.bsmselect.sortable.js
spiderfw-0.6.32 apps/core/components/public/js/jquery/plugins/bsmselect/js/jquery.bsmselect.sortable.js
spiderfw-0.6.31 apps/core/components/public/js/jquery/plugins/bsmselect/js/jquery.bsmselect.sortable.js
spiderfw-0.6.30 apps/core/components/public/js/jquery/plugins/bsmselect/js/jquery.bsmselect.sortable.js
spiderfw-0.6.29 apps/core/components/public/js/jquery/plugins/bsmselect/js/jquery.bsmselect.sortable.js
spiderfw-0.6.28 apps/core/components/public/js/jquery/plugins/bsmselect/js/jquery.bsmselect.sortable.js
spiderfw-0.6.27 apps/core/components/public/js/jquery/plugins/bsmselect/js/jquery.bsmselect.sortable.js
spiderfw-0.6.26 apps/core/components/public/js/jquery/plugins/bsmselect/js/jquery.bsmselect.sortable.js
spiderfw-0.6.26.pre1 apps/core/components/public/js/jquery/plugins/bsmselect/js/jquery.bsmselect.sortable.js
spiderfw-0.6.25 apps/core/components/public/js/jquery/plugins/bsmselect/js/jquery.bsmselect.sortable.js
spiderfw-0.6.24 apps/core/components/public/js/jquery/plugins/bsmselect/js/jquery.bsmselect.sortable.js
spiderfw-0.6.23 apps/core/components/public/js/jquery/plugins/bsmselect/js/jquery.bsmselect.sortable.js
spiderfw-0.6.22 apps/core/components/public/js/jquery/plugins/bsmselect/js/jquery.bsmselect.sortable.js