Sha256: 02f1a123dc084dc57b812c44facb1f16ad96dd03169e9a9a96d86128645491f3
Contents?: true
Size: 1.3 KB
Versions: 31
Compression:
Stored size: 1.3 KB
Contents
Tenon.features.forms = { init: function () { var self = Tenon.features.forms; self.setupRadioSliders(); self.protectChanges(); self.focusFirstField(); }, protectChanges: function () { var self = Tenon.features.forms; self.changesMade = false; $('input, select, textarea').bind('keyup change', function() { if ($(this).attr('id') != "quick-search") { self.changesMade = true; } }); // don't run the check if the user is submitting a form of course $(document).on('submit', 'form', function() { window.onbeforeunload = null; }); window.onbeforeunload = self.confirmNavigation; }, confirmNavigation: function () { var self = Tenon.features.forms; if (typeof CKEDITOR != 'undefined') { for ( instance in CKEDITOR.instances ) if(CKEDITOR.instances[instance].checkDirty()) { self.changesMade = true} } if (self.changesMade) { return "You have unsaved changes, are you sure you want to leave this page?"; } }, setupRadioSliders: function () { $('.radio-slider').radioSlider({sliderImage: '<%= asset_path'tenon/slider-button.png' %>'}); }, focusFirstField: function () { el = $(".main-content form input[type!='hidden'], .main-content form select, .main-content form textarea")[0]; $(el).focus(); } }
Version data entries
31 entries across 31 versions & 1 rubygems