Sha256: ee990bae6ddf46a5d9ac3f267b90349a8e00c22287890e2a38dd3f84a6e4953a

Contents?: true

Size: 1.83 KB

Versions: 13

Compression:

Stored size: 1.83 KB

Contents

(function(){

spud.admin.modal = {

  displayWithOptions: function(options){
    var modal = $('#modal_window');
    if (options.title){
      modal.find('.modal-title').text(options.title);
    }
    if (options.html){
      modal.find('.modal-body').html(options.html);
    }
    if (options.size) {
      var sizeClass = '';
      switch (options.size) {
        case "lg": //because some people like brevity
        case "large": //some like accuracy
        case "modal-lg": // some like bootstrap
          sizeClass = "modal-lg";
          break;
        case "sm":
        case "small":
        case "modal-sm":
          sizeClass = "modal-sm";
          break;
      }
      modal.find('.modal-dialog').addClass(sizeClass);
    }
    var defaultFooter = modal.find('.modal-footer-default');
    if(options.buttons){
      var newFooter = defaultFooter.clone();
      newFooter.removeClass('modal-footer-default').addClass('modal-footer-additional');
      newFooter.find('.form-submit').remove();
      for(var key in options.buttons){
        newFooter.append('<button class="btn btn-default '+key+'">'+options.buttons[key]+'</button>');
      }
      defaultFooter.hide();
      newFooter.insertAfter(defaultFooter);
    } else {
      $('modal-footer-additional').remove();
      if(options.hideFooter){
        defaultFooter.hide();
      } else{
        defaultFooter.show();  
      }
    }

    // modalArgs are passed straight to the modal and can contain bootstrap default properties.
    var modalArgs = 'show';
    if (options.disableClose) {
      // This modal cannot be closed by pressing escape or clicking the background page.
      modalArgs = {
        backdrop: 'static',
        keyboard: false
      };
    }

    modal.modal(modalArgs);
  },

  hide: function(){
    var modal = $('#modal_window');
    modal.modal('hide');
  }

};

})();

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
tb_core-1.4.3.1 app/assets/javascripts/admin/core/modal.js
tb_core-1.4.3 app/assets/javascripts/admin/core/modal.js
tb_core-1.4.2 app/assets/javascripts/admin/core/modal.js
tb_core-1.4.1 app/assets/javascripts/admin/core/modal.js
tb_core-1.4.0.1 app/assets/javascripts/admin/core/modal.js
tb_core-1.4.beta2 app/assets/javascripts/admin/core/modal.js
tb_core-1.4.beta1 app/assets/javascripts/admin/core/modal.js
tb_core-1.3.10 app/assets/javascripts/admin/core/modal.js
tb_core-1.3.9 app/assets/javascripts/admin/core/modal.js
tb_core-1.3.7 app/assets/javascripts/admin/core/modal.js
tb_core-1.3.6 app/assets/javascripts/admin/core/modal.js
tb_core-1.3.5 app/assets/javascripts/admin/core/modal.js
tb_core-1.3.4 app/assets/javascripts/admin/core/modal.js