Sha256: c398acb3fb3bbdaa453461ca8c41787ba249cb08389da751a449b9e78e8fc9ef

Contents?: true

Size: 1 KB

Versions: 26

Compression:

Stored size: 1 KB

Contents

pageflow.widgets = (function() {
  return {
    isPresent: function(name) {
      return !!$('div.' + className(name)).length;
    },

    areLoaded: function() {
      return !!$('div.widgets_present').length;
    },

    use: function(options, callback) {
      var original = options.insteadOf;

      var originalClassName = className(original);
      var replacementClassNames =
        className(options.name) + ' ' +
        className(original, 'replaced');

      if (this.isPresent(original)) {
        replace(originalClassName, replacementClassNames);

        callback(function() {
          replace(replacementClassNames, originalClassName);
        });
      }
      else {
        callback(function() {});
      }
    }
  };

  function replace(original, replacement) {
    $('div.widgets_present')
      .removeClass(original)
      .addClass(replacement);

    pageflow.events.trigger('widgets:update');
  }

  function className(name, state) {
    return 'widget_' + name + '_' + (state || 'present');
  }
}());

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
pageflow-12.4.1 app/assets/javascripts/pageflow/widgets.js
pageflow-13.0.0 app/assets/javascripts/pageflow/widgets.js
pageflow-13.0.0.rc1 app/assets/javascripts/pageflow/widgets.js
pageflow-12.4.0 app/assets/javascripts/pageflow/widgets.js
pageflow-12.3.0 app/assets/javascripts/pageflow/widgets.js
pageflow-13.0.0.beta7 app/assets/javascripts/pageflow/widgets.js
pageflow-13.0.0.beta6 app/assets/javascripts/pageflow/widgets.js
pageflow-13.0.0.beta5 app/assets/javascripts/pageflow/widgets.js
pageflow-13.0.0.beta4 app/assets/javascripts/pageflow/widgets.js
pageflow-13.0.0.beta3 app/assets/javascripts/pageflow/widgets.js
pageflow-13.0.0.beta2 app/assets/javascripts/pageflow/widgets.js
pageflow-13.0.0.beta1 app/assets/javascripts/pageflow/widgets.js
pageflow-12.2.0 app/assets/javascripts/pageflow/widgets.js
pageflow-12.1.0 app/assets/javascripts/pageflow/widgets.js
pageflow-12.0.4 app/assets/javascripts/pageflow/widgets.js
pageflow-12.0.3 app/assets/javascripts/pageflow/widgets.js
pageflow-12.0.2 app/assets/javascripts/pageflow/widgets.js
pageflow-12.0.1 app/assets/javascripts/pageflow/widgets.js
pageflow-12.0.0 app/assets/javascripts/pageflow/widgets.js
pageflow-12.0.0.rc7 app/assets/javascripts/pageflow/widgets.js