// Generated by CoffeeScript 1.7.1 (function() { ko.bindingHandlers.appearif = { init: function(element, valueAccessor) { var value; value = ko.utils.unwrapObservable(valueAccessor()); return $(element).toggle(value); }, update: function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) { var appear, duration; appear = ko.utils.unwrapObservable(valueAccessor()); duration = allBindingsAccessor().duration || 400; if (appear) { $(element).fadeIn(duration); return $(element).focus(); } else { return $(element).fadeOut(duration); } } }; ko.bindingHandlers.appearifnot = { init: function(element, valueAccessor) { var value; value = ko.utils.unwrapObservable(valueAccessor()); return $(element).toggle(!value); }, update: function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) { var appear, duration; appear = ko.utils.unwrapObservable(valueAccessor()); duration = allBindingsAccessor().duration || 400; if (!appear) { $(element).fadeIn(duration); return $(element).focus(); } else { return $(element).fadeOut(duration); } } }; ko.bindingHandlers.slidedownif = { init: function(element, valueAccessor) { var value; value = ko.utils.unwrapObservable(valueAccessor()); return $(element).toggle(value); }, update: function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) { var appear, duration; appear = ko.utils.unwrapObservable(valueAccessor()); duration = allBindingsAccessor().duration || 1000; if (appear) { $(element).slideDown(duration); return $(element).focus(); } else { return $(element).slideUp(duration); } } }; ko.bindingHandlers.slidedownifnot = { init: function(element, valueAccessor) { var value; value = ko.utils.unwrapObservable(valueAccessor()); return $(element).toggle(!value); }, update: function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) { var appear, duration; appear = ko.utils.unwrapObservable(valueAccessor()); duration = allBindingsAccessor().duration || 1000; if (!appear) { $(element).slideDown(duration); return $(element).focus(); } else { return $(element).slideUp(duration); } } }; ko.bindingHandlers.slideleftif = { init: function(element, valueAccessor) { var value; value = ko.utils.unwrapObservable(valueAccessor()); if (!value) { $(element).hide(); return $(element).transition({ x: '10000px' }, 1); } else { $(element).show(); return $(element).focus(); } }, update: function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) { var appear, duration; appear = ko.utils.unwrapObservable(valueAccessor()); duration = allBindingsAccessor().duration || 1000; if (appear) { $(element).show(); return $(element).transition({ x: 0 }, duration); } else { return $(element).transition({ x: '10000px' }, duration, function() { return $(element).hide(); }); } } }; ko.bindingHandlers.slideleftifnot = { init: function(element, valueAccessor) { var value; value = ko.utils.unwrapObservable(valueAccessor()); if (value) { $(element).hide(); return $(element).transition({ x: '10000px' }, 1); } else { $(element).show(); return $(element).focus(); } }, update: function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) { var appear, duration; appear = ko.utils.unwrapObservable(valueAccessor()); duration = allBindingsAccessor().duration || 1000; if (!appear) { $(element).show(); return $(element).transition({ x: 0 }, duration); } else { return $(element).transition({ x: '10000px' }, duration, function() { return $(element).hide(); }); } } }; ko.bindingHandlers.sliderightif = { init: function(element, valueAccessor) { var value; value = ko.utils.unwrapObservable(valueAccessor()); if (!value) { $(element).hide(); return $(element).transition({ x: '-10000px' }, 1); } else { $(element).show(); return $(element).focus(); } }, update: function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) { var appear, duration; appear = ko.utils.unwrapObservable(valueAccessor()); duration = allBindingsAccessor().duration || 1000; if (appear) { $(element).show(); return $(element).transition({ x: 0 }, duration); } else { return $(element).transition({ x: '-10000px' }, duration, function() { return $(element).hide(); }); } } }; ko.bindingHandlers.sliderightifnot = { init: function(element, valueAccessor) { var value; value = ko.utils.unwrapObservable(valueAccessor()); if (value) { $(element).hide(); return $(element).transition({ x: '-10000px' }, 1); } else { $(element).show(); return $(element).focus(); } }, update: function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) { var appear, duration; appear = ko.utils.unwrapObservable(valueAccessor()); duration = allBindingsAccessor().duration || 1000; if (!appear) { $(element).show(); return $(element).transition({ x: 0 }, duration); } else { return $(element).transition({ x: '-10000px' }, duration, function() { return $(element).hide(); }); } } }; ko.bindingHandlers.swipeleft = { init: function(element, valueAccessor) { return Hammer(element).on('swipeleft', function(event) { var value; value = valueAccessor(); return value(event); }); } }; ko.bindingHandlers.swiperight = { init: function(element, valueAccessor) { return Hammer(element).on('swiperight', function(event) { var value; value = valueAccessor(); return value(event); }); } }; ko.bindingHandlers.swipeup = { init: function(element, valueAccessor) { return Hammer(element).on('swipeup', function(event) { var value; value = valueAccessor(); return value(event); }); } }; ko.bindingHandlers.swipedown = { init: function(element, valueAccessor) { return Hammer(element).on('swipedown', function(event) { var value; value = valueAccessor(); return value(event); }); } }; ko.bindingHandlers.fileupload = { init: function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) { var onComplete, onStartUpload, options, parameter, property, uploadFile, url; options = ko.utils.unwrapObservable(valueAccessor()); property = ko.utils.unwrapObservable(options.property); parameter = ko.utils.unwrapObservable(options.parameter); onStartUpload = ko.utils.unwrapObservable(options.onStartUpload); onComplete = ko.utils.unwrapObservable(options.onComplete); url = ko.utils.unwrapObservable(options.url); if (!(property && url && parameter)) { return false; } uploadFile = (function(_this) { return function(file) { var formData, xhr; if (viewModel[onStartUpload] != null) { viewModel[onStartUpload](); } formData = new FormData; formData.append(parameter, file); xhr = new XMLHttpRequest; if (xhr.addEventListener != null) { xhr.addEventListener('load', function(event) { if (viewModel[onComplete] != null) { return viewModel[onComplete](); } }); } else { xhr.attachEvent('load', function(event) { if (viewModel[onComplete] != null) { return viewModel[onComplete](); } }); } xhr.open('POST', url); return xhr.send(formData); }; })(this); if (element.addEventListener == null) { element.addEventListener = element.attachEvent; } element.addEventListener('drop', (function(_this) { return function(event) { var files; event.stopPropagation(); event.preventDefault(); files = event.dataTransfer.files; if (!(files.length > 0)) { return; } return uploadFile(files[0]); }; })(this)); element.addEventListener('change', (function(_this) { return function(event) { var file; event.stopPropagation(); event.preventDefault(); file = event.target.files[0]; return uploadFile(file); }; })(this)); return true; } }; ko.bindingHandlers.wysiwyg = { init: function(element, valueAccessor, allBindingsAccessor) { var value; value = ko.utils.unwrapObservable(valueAccessor()); $(element).wysiwyg(); $(element).bind('blur keyup paste copy cut mouseup', (function(_this) { return function() { var newValue, observable; $(element).attr('data-edit-in-progress', 'true'); observable = valueAccessor(); newValue = $(element).cleanHtml(); observable(newValue); return $(element).attr('data-edit-in-progress', ''); }; })(this)); return ko.utils.domNodeDisposal.addDisposeCallback(element, (function(_this) { return function() { return $(element).wysiwyg('destroy'); }; })(this)); }, update: function(element, valueAccessor) { var value; if ($(element).attr('data-edit-in-progress') === 'true') { return; } value = ko.utils.unwrapObservable(valueAccessor()); $(element).html(value); return ko.bindingHandlers.value.update(element, valueAccessor); } }; ko.bindingHandlers.richtext = { init: function(element, valueAccessor, allBindingsAccessor) { var value; value = ko.utils.unwrapObservable(valueAccessor()); $(element).wysihtml5({ 'events': { 'blur': function() { var newValue, observable; $(element).attr('data-edit-in-progress', 'true'); observable = valueAccessor(); newValue = $(element).val(); observable(newValue); return $(element).attr('data-edit-in-progress', ''); } } }); return ko.utils.domNodeDisposal.addDisposeCallback(element, (function(_this) { return function() { return $(element).wysihtml5('destroy'); }; })(this)); }, update: function(element, valueAccessor) { var value; if ($(element).attr('data-edit-in-progress') === 'true') { return; } value = ko.utils.unwrapObservable(valueAccessor()); $(element).data('wysihtml5').editor.setValue(value); return ko.bindingHandlers.value.update(element, valueAccessor); } }; }).call(this);