-
-
Save Ptico/1980867 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App = {}; | |
// Another sandbox functions | |
/** | |
* Creates namespace in sandbox by string definition | |
* If part of namespace already defined - keep it untouchable, | |
* else - create empty object. | |
* | |
* App.namespace("Hello.World"); | |
* | |
* @property {String} str Dot-separated namespace definition | |
*/ | |
App.namespace = function(str) { | |
var pieces = str.split("."), | |
len = pieces.length, | |
i = 0, | |
root = this, | |
part; | |
while (i < len) { | |
part = pieces[i++]; | |
root[part] = root[part] || {}; | |
root = root[part]; | |
} | |
return root; | |
}; | |
/** | |
* @namespace Holds Vacation sorter plugin | |
*/ | |
App.namespace("Admin.Vacation.Sorter"); | |
/** | |
* Sorter for vacations | |
* Sort various shit with motherfucking vacations | |
* | |
* new App.Admin.Vacation.Sorter("#sortable"); | |
* | |
* @class | |
* @property {jQuery} sortable Container for sortable element | |
*/ | |
App.Admin.Vacation.Sorter = (function() { | |
/** | |
* Initializes sortable element | |
* | |
* @constructor | |
* @param {String} selector CSS-selector for root element | |
*/ | |
function Sorter(selector) { | |
this.selector = selector; | |
this.sortable = $(selector).sortable(this.options).disableSelection(); | |
} | |
Sorter.prototype = { | |
/** | |
* Default options for sorter | |
* | |
* @type Object | |
* @property {String} axis Sort axis | |
* @property {String} containment WTF? | |
* @property {String} cursor Cursor icon when under sortable | |
* @property {Function} update Handler for update event | |
* @property {Function} helper | |
*/ | |
options: { | |
axis: 'y', | |
containment: 'parent', | |
cursor: 'move', | |
update: this.updateHandler, | |
helper: this.uiHelper | |
}, | |
/** | |
* Handle `update` event | |
* | |
* @param {jQuery.Event} ev Event object | |
* @param {Object} ui UI object | |
*/ | |
updateHandler: function(ev, ui) { | |
console.log(event); | |
console.log($(this)); | |
}, | |
/** | |
* Helper for ui | |
* | |
* @param {jQuery.Event} ev Event object | |
* @param {jQuery.UI} ui UI object | |
*/ | |
uiHelper: function(ev, ui) { | |
ui.children().each(function() { | |
$(this).width($(this).width()); | |
}); | |
return ui; | |
} | |
}; | |
return Sorter; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment