setup: function(){
    var self = this;
    view = this.subject();
    view.set("parentView", {content: {model: {commit_id: "abc1234"}}});

    //Attach the reference view to dependant parent
    parentView = Ember.ContainerView.extend({
      classNames: ["card-event", "card-event-referenced"],
      childViews: [view],
      container: self.container
    }).create();
    Ember.run(function(){
      parentView.appendTo('#ember-testing');
    });

    //Setup Dummy controller
    var controller = {
      fetchCommit: function(){
        return new Promise(function(resolve, reject){
          resolve("abc1234");
        });
      }
    };
    Ember.run(function(){
      view.set("controller", controller);
    });
  }
    context.__setup_properties__.append = function(selector) {
      var containerView = Ember.ContainerView.create({container: container});
      var view = Ember.run(function(){
        var subject = context.subject();
        containerView.pushObject(subject);
        // TODO: destory this somewhere
        containerView.appendTo('#ember-testing');
        return subject;
      });

      return view.$();
    };
    this.callbacks.render = function() {
      var containerView = Ember.ContainerView.create({container: container});
      Ember.run(function(){
        var subject = context.subject();
        containerView.pushObject(subject);
        containerView.appendTo('#ember-testing');
      });

      _this.teardownSteps.unshift(function() {
        Ember.run(function() {
          Ember.tryInvoke(containerView, 'destroy');
        });
      });
    };
    context.__setup_properties__.render = function() {
      var containerView = Ember.ContainerView.create({container: container});
      var view = Ember.run(function(){
        var subject = context.subject();
        containerView.pushObject(subject);
        containerView.appendTo('#ember-testing');
        return subject;
      });

      var oldTeardown = this.teardown;
      this.teardown = function() {
        Ember.run(function() {
          Ember.tryInvoke(containerView, 'destroy');
        });

        if (oldTeardown) {
          return oldTeardown.apply(this, arguments);
        }
      };

      return view.$();
    };
import Ember from "ember";
import template_mapping from "../utils/template-mapping";
import vis_registry from "../utils/visualization-registry";

/* global _ */
export default Ember.ArrayController.extend({
    isToggled: true,
    layoutOptions: {},
    structureOptions: {},
    slideShowContainer: Ember.ContainerView.create(),
    datasource: Ember.computed.alias("selectedVisualization.datasource"),
    visualizationConfiguration: [{}],
    visualizationSVG: "",
    exportFormats: ["SVG", "PNG"],
    selectedFormat: "PNG",
    configName: "",
    categorizedProperties: (function () {
        var categorizedProperties = {};
        var selectedVisualization = this.get("selectedVisualization");
        var dataselection = selectedVisualization.get("dataselection");
        var propertyInfos = dataselection.get("propertyInfos");

        for (var i = 0; i < propertyInfos.length; i++) {
            var propertyInfo = propertyInfos[i];
            var category = propertyInfo.type;
            var dtype = propertyInfo.datatype;

            if (!categorizedProperties[category]) {
                categorizedProperties[category] = {
                    name: category,
                    datatype: dtype,
Exemple #6
0
export default Ember.ContainerView.extend({
  classNames: ['liquid-container'],
  growDuration: 250,
  growPixelsPerSecond: 200,
  growEasing: 'slide',
  enableGrowth: true,

  init: function(){
    // The ContainerView constructor normally sticks our "currentView"
    // directly into _childViews, but we want to leave that up to
    // _currentViewDidChange so we have the opportunity to launch a
    // transition.
    this._super();
    Ember.A(this._childViews).clear();

    if (this.get('containerless')) {
      // This prevents Ember from throwing an assertion when we try to
      // render as a virtual view.
      this.set('innerClassNameBindings', this.get('classNameBindings'));
      this.set('classNameBindings', Ember.A());
    }
  },

  // Deliberately overriding a private method from
  // Ember.ContainerView!
  //
  // We need to stop it from destroying our outgoing child view
  // prematurely.
  _currentViewWillChange: Ember.beforeObserver('currentView', function() {}),

  // Deliberately overriding a private method from
  // Ember.ContainerView!
  _currentViewDidChange: Ember.on('init', Ember.observer('currentView', function() {
    // Normally there is only one child (the view we're
    // replacing). But sometimes there may be two children (because a
    // transition is already in progress). In any case, we tell all of
    // them to start heading for the exits now.

    var oldView = this.get('childViews.lastObject'),
        newView = this.get('currentView'),
        firstTime;

    // For the convenience of the transition rules, we explicitly
    // track our first transition, which happens at initial render.
    firstTime = !this._hasTransitioned;
    this._hasTransitioned = true;

    // Idempotence
    if ((!oldView && !newView) ||
        (oldView && oldView.get('currentView') === newView) ||
        (this._runningTransition &&
         this._runningTransition.oldView === oldView &&
         this._runningTransition.newContent === newView
        )) {
      return;
    }

    // `transitions` comes from dependency injection, see the
    // liquid-fire app initializer.
    var transition = this.get('transitions').transitionFor(this, oldView, newView, this.get('use'), firstTime);

    if (this._runningTransition) {
      this._runningTransition.interrupt();
    }

    this._runningTransition = transition;
    transition.run().catch(function(err){
      // Force any errors through to the RSVP error handler, because
      // of https://github.com/tildeio/rsvp.js/pull/278.  The fix got
      // into Ember 1.7, so we can drop this once we decide 1.6 is
      // EOL.
      Ember.RSVP.Promise.resolve()._onerror(err);
    });
  })),

  _liquidChildFor: function(content) {
    if (content && !content.get('hasLiquidContext')){
      content.set('liquidContext', content.get('context'));
    }
    var LiquidChild = this.container.lookupFactory('view:liquid-child');
    var childProperties = {
      currentView: content
    };
    if (this.get('containerless')) {
      childProperties.classNames = this.get('classNames').without('liquid-container');
      childProperties.classNameBindings = this.get('innerClassNameBindings');
    }
    return LiquidChild.create(childProperties);
  },

  _pushNewView: function(newView) {
    if (!newView) {
      return Promise.resolve();
    }
    var child = this._liquidChildFor(newView),
        promise = new Promise(function(resolve) {
          child._resolveInsertion = resolve;
        });
    this.pushObject(child);
    return promise;
  },

  cacheSize: function() {
    var elt = this.$();
    if (elt) {
      // Measure original size.
      this._cachedSize = getSize(elt);
    }
  },

  unlockSize: function() {
    var self = this;
    function doUnlock(){
      var elt = self.$();
      if (elt) {
        elt.css({width: '', height: ''});
      }
    }
    if (this._scaling) {
      this._scaling.then(doUnlock);
    } else {
      doUnlock();
    }
  },

  _durationFor: function(before, after) {
    return Math.min(this.get('growDuration'), 1000*Math.abs(before - after)/this.get('growPixelsPerSecond'));
  },

  _adaptDimension: function(dimension, before, after) {
    if (before[dimension] === after[dimension] || !this.get('enableGrowth')) {
      var elt = this.$();
      if (elt) {
        elt[dimension](after[dimension]);
      }
      return Promise.resolve();
    } else {
      // Velocity deals in literal width/height, whereas jQuery deals
      // in box-sizing-dependent measurements.
      var target = {};
      target[dimension] = [
        after['literal'+capitalize(dimension)],
        before['literal'+capitalize(dimension)],
      ];
      return animate(this, target, {
        duration: this._durationFor(before[dimension], after[dimension]),
        queue: false,
        easing: this.get('growEasing')
      });
    }
  },

  adaptSize: function() {
    stop(this);

    var elt = this.$();
    if (!elt) { return; }

    // Measure new size.
    var newSize = getSize(elt);
    if (typeof(this._cachedSize) === 'undefined') {
      this._cachedSize = newSize;
    }

    // Now that measurements have been taken, lock the size
    // before the invoking the scaling transition.
    elt.width(this._cachedSize.width);
    elt.height(this._cachedSize.height);

    this._scaling = Promise.all([
      this._adaptDimension('width', this._cachedSize, newSize),
      this._adaptDimension('height', this._cachedSize, newSize),
    ]);
  }

});
var LlamaTable = Em.ContainerView.extend(ScrollXYMixin, {
	classNames: 'llama-table',
	dualHeaders: bool('controller.dualHeaders'),
	showFooter: bool('controller.showFooter'),
	scrollLeft: alias('controller.scrollLeft'),
	scrollTop: alias('controller.scrollTop'),

	rows: null,
	columngroups: null,

	headerView: computed(function () {
		var View = this.get('controller.HeaderView');
		return this.createChildView(View, {
			columngroups: this.get('columngroups')
		});
	}),

	dualHeaderView: computed(function () {
		var View = this.get('controller.HeaderView');
		return this.createChildView(View, {
			columngroups: this.get('columngroups')
		});
	}),

	bodyView: computed(function () {
		var View = this.get('controller.BodyView');
		return this.createChildView(View, {
			columngroups: this.get('columngroups'),
			rows: this.get('rows')
		});
	}),

	footerView: null,

	init: function () {
		this._super();
		this.pushObject(this.get('headerView'));
		this.pushObject(this.get('bodyView'));
	},

	didInsertElement: function () {
		this._super();
		this.toggleDualHeader();
		this.toggleFooter();
		this.setHeight();
		this.updateScrollPosition();
	},

	toggleDualHeader: observer('dualHeaders', function () {
		var dualHeaders = this.get('dualHeaders');
		if (dualHeaders) {
			this.pushObject(this.get('dualHeaderView'));
		}
		else {
			this.removeObject(this.get('dualHeaderView'));
		}
	}),

	toggleFooter: observer('showFooter', function () {
		var showFooter = this.get('showFooter');
		var View, footerView;
		if (showFooter) {
			// create and show footer
			View = this.get('controller.FooterView');
			footerView = this.createChildView(View, {
				columngroups: this.get('columngroups'),
				rows: this.get('rows')
			});
			this.set('footerView', footerView);
			this.pushObject(footerView);
		}
		else {
			// remove and unset footer
			footerView = this.get('footerView');
			this.removeObject(footerView);
			this.set('footerView', null);
		}
	}),

	updateScrollPosition: observer('scrollLeft', 'scrollTop', function () {
		var $table = Em.$(this.$());
		$table.scrollLeft(this.get('scrollLeft'));
		$table.scrollTop(this.get('scrollTop'));
	}),

	setHeight: observer('controller.maxHeight', function () {
		var $table = Em.$(this.$());
		$table.css('maxHeight', this.get('controller.maxHeight'));
	}),

	actions: {
		scrollX: function (pos) {
			this.set('scrollLeft', pos);
		},
		scrollY: function (pos) {
			this.set('scrollTop', pos);
		}
	}
});
import Ember from 'ember';

var PackageContainerView = Ember.ContainerView.extend({
  classNames: ["row"],
  childViews: Ember.computed.alias("staticView"),

  staticView:  function(){
    var view;
    if(this.get('noPackages') && this.get('noSubItemType')) {
      view = Ember.View.create({
        templateName: "packages/static_item_type_component",
        id: 0
      });
    }
    return view ? [view] : [];
  }.property(),
});

export default PackageContainerView;
var LlamaEmbed = Em.ContainerView.extend({
	classNames: 'llama-embed',
	height: alias('row.subcontentHeight'),

	row: null,

	rows: alias('controller.sortedRows'),

	didInsertElement: function () {
		this._super();
		this.updateOffsetTop();
		this.updateHeight();
	},

	calculateRowHeight: function (row) {
		var result = get(row, 'height');
		if (get(row, 'isExpanded')) {
			result += get(row, 'subcontentHeight') || 0;
		}
		return result;
	},

	offsetTop: computed('*****@*****.**', '*****@*****.**', '*****@*****.**', function () {
		var sortedRows = this.get('rows');
		var row = this.get('row');
		var index = sortedRows.indexOf(row);
		var previous = sortedRows.slice(0, index);
		var calc = this.calculateRowHeight;
		var previousHeight = previous.reduce(function (total, row) {
			return total + calc(row);
		}, 0);
		var thisHeight = get(row, 'height');
		var offsetTop = previousHeight + thisHeight;
		return offsetTop;
	}),

	updateOffsetTop: observer('offsetTop', function () {
		var $embed = Em.$(this.$());
		$embed.css('top', this.get('offsetTop'));
	}),

	updateHeight: observer('height', function () {
		var $embed = Em.$(this.$());
		$embed.css('height', this.get('height'));
	}),

	subcontentView: computed(function () {
		var View = this.get('controller.config.subcontentView');
		return this.createChildView(View, {
			content: this.get('content')
		});
	}),

	init: function () {
		this._super();
		this.pushObject(this.get('subcontentView'));
	}
});
export default Ember.ContainerView.extend({
  classNames: ['polymer-container'],
  tagName: 'core-animated-pages',
  animations: '',

  didInsertElement: function() {
    var self = this;
    var view = this.$();
    var animations = this.get('animations');

    view[0].setAttribute('selected', 0);
    if (animations) {
      view[0].setAttribute('transitions', animations);
    }

    view.on('core-animated-pages-transition-end', function(e) {
      e.stopPropagation();
      var i;

      if (self._childViews.length > 1) {
        for (i = self._childViews.length; i > 1; i--) {
          self.removeChild(self._childViews[0]);
        }
      }

      view[0].setAttribute('selected', self._childViews.length - 1);
    });
  },

  _currentViewWillChange: Ember.beforeObserver('currentView', function() {}),

  _currentViewDidChange: Ember.observer('currentView', function() {
    var oldView = this.get('childViews.lastObject');
    var newView = this.get('currentView');
    var isSlide = this.get('slide');
    var view = this.$();

    this._super();
    if (!oldView || (!oldView && !newView) || (oldView && oldView.get('currentView') === newView)) {
      return;
    }

    if (isSlide && oldView && newView) {
      var oldOrder = oldView.get('order');
      var newOrder = newView.get('order');
      var transitions = this.get('animations').split(' ');

      if (oldOrder <= newOrder) {
        transitions.push('slide-from-right-fo-shizzle');
      } else {
        transitions.push('slide-from-left-fo-shizzle');
      }

      view[0].setAttribute('transitions', transitions.join(' ') + ' hero-transition');
    }

    view[0].setAttribute('selected', 1);

  })
});
Exemple #11
0
export default Ember.ContainerView.extend(Ember._Metamorph, {
  init: function(){
    // The ContainerView constructor normally sticks our "currentView"
    // directly into _childViews, but we want to leave that up to
    // _currentViewDidChange so we have the opportunity to launch a
    // transition.
    this._super();
    this._childViews.clear();
  },

  // Deliberately overriding a private method from
  // Ember.ContainerView!
  //
  // We need to stop it from destroying our outgoing child view
  // prematurely.
  _currentViewWillChange: Ember.beforeObserver('currentView', function() {}),

  // Deliberately overriding a private method from
  // Ember.ContainerView!
  _currentViewDidChange: Ember.observer('currentView', function() {
    // Normally there is only one child (the view we're
    // replacing). But sometimes there may be two children (because a
    // transition is already in progress). In any case, we tell all of
    // them to start heading for the exits now.

    var oldView = this.get('childViews.lastObject'),
        newView = this.get('currentView');

    // Idempotence
    if ((!oldView && !newView) ||
        (oldView && oldView.get('currentView') === newView) ||
        (this._runningTransition &&
         this._runningTransition.oldView === oldView &&
         this._runningTransition.newContent === newView
        )) {
      return;
    }

    // `transitions` comes from dependency injection, see the
    // liquid-fire app initializer.
    var transition = this.get('transitions').transitionFor(this, oldView, newView);

    if (this._runningTransition) {
      this._runningTransition.interrupt();
    }

    this._runningTransition = transition;
    transition.run();
  }).on('init'),

  _liquidChildFor: function(content) {
    if (content && !content.get('hasLiquidContext')){
      content.set('liquidContext', content.get('context'));
    }
    var LiquidChild = this.container.lookupFactory('view:liquid-child');
    return LiquidChild.create({
      currentView: content,
      classNames: this.get('classNames'),
      classNameBindings: this.get('classNameBindings')
    });
  },

  _pushNewView: function(newView) {
    var child = this._liquidChildFor(newView),
        promise = new Promise(function(resolve) {
          child._resolveInsertion = resolve;
        });
    this.pushObject(child);
    return promise;
  }


});
export default Ember.ContainerView.extend(
StyleBindingsMixin, {
  classNames: 'lazy-list-container',
  styleBindings: ['height'],
  content: null,
  itemViewClass: null,
  rowHeight: null,
  scrollTop: null,
  startIndex: null,
  sortingColumns: null,

  init: function() {
    this._super();
    return this.onNumChildViewsDidChange();
  },

  height: Ember.computed(function() {
    return this.get('content.length') * this.get('rowHeight');
  }).property('content.length', 'rowHeight'),

  numChildViews: Ember.computed(function() {
    return this.get('numItemsShowing') + 2;
  }).property('numItemsShowing'),

  onNumChildViewsDidChange: Ember.observer(function() {
    var view = this;
    // We are getting the class from a string e.g. "Ember.Table.Row"
    var itemViewClass = this.get('itemViewClass');
    if (typeof itemViewClass === 'string') {
      if (/[A-Z]+/.exec(itemViewClass)) {
        // Global var lookup - 'App.MessagePreviewView'
        itemViewClass = Ember.get(Ember.lookup, itemViewClass);
      } else {
        // Ember CLI Style lookup - 'message/preview'
        itemViewClass = this.container.lookupFactory("view:" + itemViewClass);
      }
    }
    var newNumViews = this.get('numChildViews');
    if (!itemViewClass || !newNumViews) {
      return;
    }
    var oldNumViews = this.get('length');
    var numViewsToInsert = newNumViews - oldNumViews;
    // if newNumViews < oldNumViews we need to remove some views
    if (numViewsToInsert < 0) {
      var viewsToRemove = this.slice(newNumViews, oldNumViews);
      this.removeObjects(viewsToRemove);
    // if oldNumViews < newNumViews we need to add more views
    } else if (numViewsToInsert > 0) {
      for (var i = 0; i < numViewsToInsert; ++i) {
        this.pushObject(view.createChildView(itemViewClass));
      }
    }
    this.viewportDidChange();
  }, 'numChildViews', 'itemViewClass'),

  // TODO(Peter): Consider making this a computed... binding logic will go
  // into the LazyItemMixin
  viewportDidChange: Ember.observer(function() {
    var childViews = this.get('childViews');
    var content = this.get('content') || [];
    var clength = content.get('length');
    var numShownViews = Math.min(this.get('length'), clength);
    var startIndex = this.get('startIndex');
    // this is a necessary check otherwise we are trying to access an object
    // that doesn't exist
    if (startIndex + numShownViews >= clength) {
      startIndex = clength - numShownViews;
    }
    if (startIndex < 0) {
      startIndex = 0;
    }
    // for all views that we are not using... just remove content
    // this makes them invisible
    childViews.forEach(function(childView, i) {
      if (i >= numShownViews) {
        childView.set('content', null);
        return;
      }
      var itemIndex = startIndex + i;
      childView = childViews.objectAt(itemIndex % numShownViews);
      var item = content.objectAt(itemIndex);
      if (childView && item !== childView.get('content')) {
        childView.teardownContent();
        childView.set('itemIndex', itemIndex);
        childView.set('content', item);
        childView.prepareContent();
      }
    });
  }, 'content.length', 'length', 'startIndex')
});
import Ember from 'ember';

export default Ember.ContainerView.extend({});
export default Ember.ContainerView.extend({
    options: null, // structure or layout options
    config: null, // visualization configuration
    tagName: "ul",
    children: (function () {
        this.clear();

        var options = this.get("options");
        var configArray = this.get("config");

        if (configArray === null || options === null) {
            return;
        }

        console.log("VISUALIZATION OPTIONS VIEW - CREATING CONFIGURATION VIEWS ...");

        // Ensures that config changes are only propagated when endPropertyChanges is called, i.e. after the for loop
        configArray.beginPropertyChanges();

        try {
            var optionNames = Object.getOwnPropertyNames(options);
            for (var i = 0; i < optionNames.length; i++) {

                var optionName = optionNames[i];
                var optionTemplate = options[optionName];

                var view = Ember.View.extend({
                    tagName: "li",
                    templateName: optionTemplate.template,
                    name: optionName,
                    label: optionTemplate.label,
                    content: optionTemplate.value,
                    metadata: optionTemplate.metadata ? optionTemplate.metadata.types : "",
                    maxCardinality: optionTemplate.maxCardinality,
                    contentObserver: (function () {
                        var content = this.get("content");
                        var name = this.get("name");
                        var configMap = configArray[0];
                        configMap[name] = content;
                        configArray.setObjects([configMap]);
                        optionTemplate.value = content;
                    }).observes("content.@each").on("init")
                }).create();

                this.pushObject(view);
            }
        } finally {
            console.log("VISUALIZATION OPTIONS VIEW - CREATED CONFIGURATION ARRAY");
            console.dir(configArray);

            // Inside finally block to make sure that this is executed even if the for loop crashes
            configArray.endPropertyChanges();
        }
    }).observes("options").on("init")
});
Exemple #15
0
export default Ember.ContainerView.extend(ListViewMixin, {
  css: {
    position: 'relative',
    overflow: 'auto',
    '-webkit-overflow-scrolling': 'touch',
    'overflow-scrolling': 'touch'
  },

  applyTransform: ListViewHelper.applyTransform,

  _scrollTo: function(scrollTop) {
    var element = this.element;

    if (element) { element.scrollTop = scrollTop; }
  },

  didInsertElement: function() {
    var that = this;

    this._updateScrollableHeight();

    this._scroll = function(e) { that.scroll(e); };

    Ember.$(this.element).on('scroll', this._scroll);
  },

  willDestroyElement: function() {
    Ember.$(this.element).off('scroll', this._scroll);
  },

  scroll: function(e) {
    this.scrollTo(e.target.scrollTop);
  },

  scrollTo: function(y) {
    this._scrollTo(y);
    this._scrollContentTo(y);
  },

  totalHeightDidChange: Ember.observer(function () {
    Ember.run.scheduleOnce('afterRender', this, this._updateScrollableHeight);
  }, 'totalHeight'),

  _updateScrollableHeight: function () {
    var height, state;

    // Support old and new Ember versions
    state = this._state || this.state;

    if (state === 'inDOM') {
      // if the list is currently displaying the emptyView, remove the height
      if (this._isChildEmptyView()) {
          height = '';
      } else {
          height = get(this, 'totalHeight');
      }

      this.$('.ember-list-container').css({
        height: height
      });
    }
  }
});
import Ember from 'ember';
import UserLikesComponent from 'page-unliker/components/user-likes';

export default Ember.ContainerView.extend({
  classNames: ['container-view'],
  init: function() {
    this._super();


    // Get controller and fetch pages.
    var controller = this.get('controller');
    var pages = controller.get('pages');

    // Initialize initial component view with these pages.
    var initView = UserLikesComponent.create({
      pages: pages
    });

    // Add this component to the container.
    this.pushObject(initView);
  },
  aView: UserLikesComponent.create({
    templateName: 'components/user-likes',
    pages: []
  }),
  bView: Ember.View.create({
    templateName: 'likes'
  }),
});
Exemple #17
0
import Ember from "ember";

export default Ember.ContainerView.extend({
  classNames: ['liquid-child'],
  resolveInsertionPromise: Ember.on('didInsertElement', function(){
    // Children start out hidden and invisible.
    // Measurement will `show` them and Velocity will make them visible.
    // This prevents a flash of pre-animated content.
    this.$().css({visibility: 'hidden'}).hide();
    if (this._resolveInsertion) {
      this._resolveInsertion(this);
    }
  })
});

Exemple #18
0
import Ember from 'ember';

/*global google */
var maps = Ember.ContainerView.extend({

  id: 'map-canvas',
  tagName: 'div',

  attributeBindings: ['style'],
  style:"height: 600px;",
  
  map:null,

  didInsertElement: function() {
    var mapOptions = {
      center: new google.maps.LatLng(36.054099, -112.143160),
      zoom: 13,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(this.$().get(0),mapOptions);
    this.set("map",map);
  }
});


export default maps;
Exemple #19
0
import Ember from "ember";

export default Ember.ContainerView.extend({
  classNames: ['liquid-child'],
  resolveInsertionPromise: Ember.on('didInsertElement', function(){
    // Children start out hidden. Animations should reveal them. This
    // prevents a flash of pre-animated content.
    this.$().hide();
    if (this._resolveInsertion) {
      this._resolveInsertion(this);
    }
  })
});