validation-controller.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /** Controller for the main index.html page */
  2. define(
  3. function( require ) {
  4. var Marionette = require( "marionette" ),
  5. Backbone = require( "backbone" ),
  6. _ = require( "underscore" ),
  7. fui = require( "app/fui" ),
  8. ValidationOptions = require( "app/views/validation-options" ),
  9. ValidationService = require( "app/services/validation-service" );
  10. var ValidationController = function() {
  11. this.initServices();
  12. this.initEvents();
  13. };
  14. // add the behaviours defined on the controller
  15. _.extend( ValidationController.prototype, {
  16. initEvents: function() {
  17. fui.vent.on( "models.validation-options.ready", this.onValidationOptionsModelReady );
  18. $(".validation").on( "click", "a.perform-validation", function( event ) {
  19. fui.services.validation.performValidation( fui.views.validationOptions.model );
  20. } );
  21. },
  22. onValidationOptionsModelReady: function( e ) {
  23. fui.views.validationOptions = new ValidationOptions( {model: fui.models.validationOptions} );
  24. },
  25. initServices: function() {
  26. fui.services.validation = new ValidationService( "#query-edit-cm", "#validation-output-cm" );
  27. fui.services.validation.init();
  28. }
  29. } );
  30. return ValidationController;
  31. }
  32. );