Sha256: 485a23ba534560ee6b981834915416111e0055efd81e32e554437eb1124cacd2
Contents?: true
Size: 1.9 KB
Versions: 31
Compression:
Stored size: 1.9 KB
Contents
(function() { var activate, onSlide, onStop, parse, template; template = function() { return $('<div></div>'); }; onStop = function(event, ui) { var cmsField, content; cmsField = $(this).data('cmsField'); content = ui.value; return cmsField.scrivito('save', content).done(function() { cmsField.trigger('save.scrivito_editors'); return cmsField.trigger('scrivito_editors:blur'); }); }; onSlide = function(event, ui) { var cmsField, content; cmsField = $(this).data('cmsField'); content = ui.value; return cmsField.text(ui.value); }; parse = function(string, fallback) { var value; value = parseInt(string); if (isNaN(value)) { return fallback; } else { return value; } }; activate = function(element) { return $(element).on('click', function() { var cmsField, content, max, min, step; cmsField = $(element); if (cmsField.data('scrivito_editors_active')) { return; } cmsField.data('scrivito_editors_active', true); content = cmsField.scrivito('content'); min = cmsField.data('scrivito-editors-min'); max = cmsField.data('scrivito-editors-max'); step = cmsField.data('scrivito-editors-step'); return template().data('cmsField', cmsField).insertAfter(cmsField).slider({ min: parse(min, 1), max: parse(max, 10), step: parse(step, 1), value: parse(content, 0), range: 'min', slide: onSlide, stop: onStop }).find('.ui-slider-handle').focus(); }); }; scrivito.editors.slider_editor = { can_edit: function(element) { return $(element).is('[data-scrivito-field-type=string]'); }, activate: function(element) { return activate(element); } }; scrivito.on('load', function() { return scrivito.define_editor('slider', scrivito.editors.slider_editor); }); }).call(this);
Version data entries
31 entries across 31 versions & 1 rubygems