ko.bindingHandlers.truncatedText = { update: function(element, valueAccessor, allBindingsAccessor) { var value = ko.utils.unwrapObservable(valueAccessor()), length = ko.utils.unwrapObservable(allBindingsAccessor().length) || ko.bindingHandlers.truncatedText.defaultLength, truncatedValue = value.length > length ? value.substring(0, Math.min(value.length, length)) + " ..." : value; ko.bindingHandlers.text.update(element, function() { return truncatedValue; }); }, defaultLength: 15 }; ko.bindingHandlers.truncatedTextCenter = { update: function(element, valueAccessor, allBindingsAccessor) { var value = ko.utils.unwrapObservable(valueAccessor()) var maxLength = 60; if(value.length > maxLength) { var charsToShow = maxLength - 3, frontChars = Math.ceil(charsToShow/2), backChars = Math.floor(charsToShow/2); var truncatedValue = value.substr(0, frontChars) + '…' + value.substr(value.length - backChars); } else { var truncatedValue = value; } ko.bindingHandlers.html.update(element, function() { return truncatedValue; }); } }; ko.bindingHandlers.filedrop = { init: function(element, valueAccessor) { var options = $.extend({}, { overlaySelector: null }, valueAccessor()); if(!options.onFileDrop) return; else if(!window.File || !window.FileReader || !window.FileList || !window.FormData) { console.log("File drop disabled because this browser is too old"); return; } $(element).bind("dragenter", function(e) { e.stopPropagation(); e.preventDefault(); if(options.overlaySelector) $(options.overlaySelector).show(); }); $(element).bind("dragleave", function(e) { e.stopPropagation(); e.preventDefault(); // EDITED FOR FIREFOX! // Without the check for is(), the screen will blink in firefox! if(options.overlaySelector && $(e.target).is('.main-filedrop')) $(options.overlaySelector).hide(); }); $(element).bind("drop", function(e) { e.stopPropagation(); e.preventDefault(); if(options.overlaySelector) $(options.overlaySelector).hide(); if(typeof options.onFileDrop === "function") $.each(e.originalEvent.dataTransfer.files, function() { options.onFileDrop(this); }); }); } }; $(document).bind('dragover', function(e) { e.preventDefault(); }); // knockout-sortable 0.8.4 | (c) 2013 Ryan Niemeyer | http://www.opensource.org/licenses/mit-license ; (function(factory) { if(typeof define === "function" && define.amd) { // AMD anonymous module define(["knockout", "jquery", "jquery.ui.sortable"], factory); } else { // No module loader (plain