Sha256: 312a83d56e827e4bf465307da2cb882dac4ea5a62da74349e4e8180d38461eda

Contents?: true

Size: 1.7 KB

Versions: 163

Compression:

Stored size: 1.7 KB

Contents

(function (factory) {
	"use strict";
	var sortable,
		jq,
		_this = this
	;

	if (typeof define === "function" && define.amd) {
		try {
			define(["sortablejs", "jquery"], function(Sortable, $) {
				sortable = Sortable;
				jq = $;
				checkErrors();
				factory(Sortable, $);
			});
		} catch(err) {
			checkErrors();
		}
		return;
	} else if (typeof exports === 'object') {
		try {
			sortable = require('sortablejs');
			jq = require('jquery');
		} catch(err) { }
	}

	if (typeof jQuery === 'function' || typeof $ === 'function') {
		jq = jQuery || $;
	}

	if (typeof Sortable !== 'undefined') {
		sortable = Sortable;
	}

	function checkErrors() {
		if (!jq) {
			throw new Error('jQuery is required for jquery-sortablejs');
		}

		if (!sortable) {
			throw new Error('SortableJS is required for jquery-sortablejs (https://github.com/SortableJS/Sortable)');
		}
	}
	checkErrors();
	factory(sortable, jq);
})(function (Sortable, $) {
	"use strict";

	$.fn.sortable = function (options) {
		var retVal,
			args = arguments;

		this.each(function () {
			var $el = $(this),
				sortable = $el.data('sortable');

			if (!sortable && (options instanceof Object || !options)) {
				sortable = new Sortable(this, options);
				$el.data('sortable', sortable);
			} else if (sortable) {
				if (options === 'destroy') {
					sortable.destroy();
					$el.removeData('sortable');
				} else if (options === 'widget') {
					retVal = sortable;
				} else if (typeof sortable[options] === 'function') {
					retVal = sortable[options].apply(sortable, [].slice.call(args, 1));
				} else if (options in sortable.options) {
					retVal = sortable.option.apply(sortable, args);
				}
			}
		});

		return (retVal === void 0) ? this : retVal;
	};
});

Version data entries

163 entries across 163 versions & 2 rubygems

Version Path
effective_bootstrap-1.19.13 app/assets/javascripts/effective_has_many/sortable-jquery.js
para-0.12.5 app/javascripts/para/vendor/jquery.sortable.js
effective_bootstrap-1.19.12 app/assets/javascripts/effective_has_many/sortable-jquery.js
effective_bootstrap-1.19.11 app/assets/javascripts/effective_has_many/sortable-jquery.js
effective_bootstrap-1.19.10 app/assets/javascripts/effective_has_many/sortable-jquery.js
effective_bootstrap-1.19.9 app/assets/javascripts/effective_has_many/sortable-jquery.js
effective_bootstrap-1.19.8 app/assets/javascripts/effective_has_many/sortable-jquery.js
effective_bootstrap-1.19.7 app/assets/javascripts/effective_has_many/sortable-jquery.js
effective_bootstrap-1.19.6 app/assets/javascripts/effective_has_many/sortable-jquery.js
effective_bootstrap-1.19.5 app/assets/javascripts/effective_has_many/sortable-jquery.js
effective_bootstrap-1.19.4 app/assets/javascripts/effective_has_many/sortable-jquery.js
para-0.12.4 app/javascripts/para/vendor/jquery.sortable.js
effective_bootstrap-1.19.3 app/assets/javascripts/effective_has_many/sortable-jquery.js
para-0.12.3 app/javascripts/para/vendor/jquery.sortable.js
effective_bootstrap-1.19.2 app/assets/javascripts/effective_has_many/sortable-jquery.js
para-0.12.2 app/javascripts/para/vendor/jquery.sortable.js
effective_bootstrap-1.19.1 app/assets/javascripts/effective_has_many/sortable-jquery.js
effective_bootstrap-1.19.0 app/assets/javascripts/effective_has_many/sortable-jquery.js
effective_bootstrap-1.18.7 app/assets/javascripts/effective_has_many/sortable-jquery.js
para-0.12.1 app/javascripts/para/vendor/jquery.sortable.js