shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

jquery.binding.js (1251B)


      1 /**
      2  * jQuery plugin for Sortable
      3  * @author	RubaXa   <trash@rubaxa.org>
      4  * @license MIT
      5  */
      6 (function (factory) {
      7 	"use strict";
      8 
      9 	if (typeof define === "function" && define.amd) {
     10 		define(["jquery"], factory);
     11 	}
     12 	else {
     13 		/* jshint sub:true */
     14 		factory(jQuery);
     15 	}
     16 })(function ($) {
     17 	"use strict";
     18 
     19 
     20 	/* CODE */
     21 
     22 
     23 	/**
     24 	 * jQuery plugin for Sortable
     25 	 * @param   {Object|String} options
     26 	 * @param   {..*}           [args]
     27 	 * @returns {jQuery|*}
     28 	 */
     29 	$.fn.sortable = function (options) {
     30 		var retVal,
     31 			args = arguments;
     32 
     33 		this.each(function () {
     34 			var $el = $(this),
     35 				sortable = $el.data('sortable');
     36 
     37 			if (!sortable && (options instanceof Object || !options)) {
     38 				sortable = new Sortable(this, options);
     39 				$el.data('sortable', sortable);
     40 			}
     41 
     42 			if (sortable) {
     43 				if (options === 'widget') {
     44 					return sortable;
     45 				}
     46 				else if (options === 'destroy') {
     47 					sortable.destroy();
     48 					$el.removeData('sortable');
     49 				}
     50 				else if (typeof sortable[options] === 'function') {
     51 					retVal = sortable[options].apply(sortable, [].slice.call(args, 1));
     52 				}
     53 				else if (options in sortable.options) {
     54 					retVal = sortable.option.apply(sortable, args);
     55 				}
     56 			}
     57 		});
     58 
     59 		return (retVal === void 0) ? this : retVal;
     60 	};
     61 });