Sha256: 2a64572dae8d247a2478b8a3e688b9e75e55a8351dc45e32f9a20725a119566f

Contents?: true

Size: 1.11 KB

Versions: 24

Compression:

Stored size: 1.11 KB

Contents

FORGE.features.forms = {
  init: function () {
    var self = FORGE.features.forms;
    self.setupRadioSliders();
    self.protectChanges();
  },

  protectChanges: function () {
    var self = FORGE.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 = FORGE.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'forge/slider-button.png' %>'});
  }


}

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
forge-cli-0.1.10 lib/forge/app/assets/javascripts/forge/features/forms.js.erb
forge-cli-0.1.9 lib/forge/app/assets/javascripts/forge/features/forms.js.erb
forge-cli-0.1.8 lib/forge/lib/assets/javascripts/forge/features/forms.js.erb
forge-cli-0.1.7 lib/forge/lib/assets/javascripts/forge/features/forms.js.erb
forge-cli-0.1.6 lib/forge/lib/assets/javascripts/forge/features/forms.js.erb
forge-cli-0.1.5 lib/forge/lib/assets/javascripts/forge/features/forms.js.erb
forge-cli-0.1.4 lib/forge/lib/assets/javascripts/forge/features/forms.js.erb
forge-cli-0.1.3 lib/forge/lib/assets/javascripts/forge/features/forms.js.erb
forge-cli-0.1.2 lib/forge/lib/assets/javascripts/forge/features/forms.js.erb
forge-cli-0.1.1 lib/forge/lib/assets/javascripts/forge/features/forms.js.erb
forge-cli-0.1.0 lib/forge/lib/assets/javascripts/forge/features/forms.js.erb
forge-cli-0.0.18 lib/forge/lib/assets/javascripts/forge/features/forms.js.erb
forge-cli-0.0.17 lib/forge/lib/assets/javascripts/forge/features/forms.js.erb
forge-cli-0.0.16 lib/forge/lib/assets/javascripts/forge/features/forms.js.erb
forge-cli-0.0.15 lib/forge/lib/assets/javascripts/forge/features/forms.js.erb
forge-cli-0.0.14 lib/forge/lib/assets/javascripts/forge/features/forms.js.erb
forge-cli-0.0.13 lib/forge/lib/assets/javascripts/forge/features/forms.js.erb
forge-cli-0.0.12 lib/forge/lib/assets/javascripts/forge/features/forms.js.erb
forge-cli-0.0.11 lib/forge/lib/assets/javascripts/forge/features/forms.js.erb
forge-cli-0.0.10 lib/forge/lib/assets/javascripts/forge/features/forms.js.erb