import Ember from 'ember';
import layout from '../templates/components/materialize-navbar';

export default Ember.Component.extend({
  tagName: 'nav',
  layout: layout,

  didInsertElement() {
    this._super(...arguments);
    Ember.run.scheduleOnce('afterRender', this, function(){
      if(Ember.typeOf(Ember.$('.button-collapse').sideNav) === 'function'){
        this.$('.button-collapse').sideNav({
          closeOnClick: true
        });
      }
    });
  }
});
 focusHandle: Ember.on('didInsertElement', function() {
   Ember.run.later(() => {
     this.$('input').eq(0).focus();
   });
 }),
示例#3
0
export function initialize(container, application) {
  Ember.run.schedule('afterRender', function() {
    container.lookup('service:framework7').initSwipePanels('left');
  });
}
示例#4
0
 Ember.EnumerableUtils.forEach(['start', 'stop'], function(callback) {
   opts[callback] = Ember.run.bind(this, callback);
 }, this);
    initializeDatepicker: function (owner) {
        var dateFormat,
            minDate = null,
            maxDate = null,
            minYear = '1900',
            maxYear = '2099',
            quickSelect = this.get('quickSelect'),
            primaryInput,
            component = this;

        // Set any minimum and maximum date values
        if (this.get('minDate')) {
            minDate = new Date(moment(this.get('minDate')));
            minYear = moment(minDate).format('YYYY');
        }
        if (this.get('maxDate')) {
            maxDate = new Date(moment(this.get('maxDate')));
            maxYear = moment(maxDate).format('YYYY');
        }

        // Convert the universal date format tokens into those recognized by the plugin
        dateFormat = this.normalizeDateFormat();

        // Wait until the child elements load
        Ember.run.scheduleOnce('afterRender', this, function () {
            primaryInput = this.$(owner);

            // Identify the primary input element (other components may have been used in selectors)
            primaryInput.addClass('primary-input');
            this.set('dateInput', primaryInput);

            // Initialize the datepicker on the input
            primaryInput.datepicker({
                // Date format
                dateFormat: dateFormat,
                // Min and max date values (null is no limit)
                minDate: minDate,
                maxDate: maxDate,
                // Options for allowing quick-select of month and year
                changeMonth: quickSelect,
                changeYear: quickSelect,
                yearRange: minYear + ':' + maxYear,
                // Set the position of the datepicker below the input (helps avoid initial conflict with sticky scroll)
                beforeShow: function (inputElement, datepickerInstance) {
                    var offset = component.$(inputElement).offset(),
                        height = component.$(inputElement).height();

                    window.setTimeout(function () {
                        datepickerInstance.dpDiv.css({ top: (offset.top + height + 10) + 'px', left: offset.left + 'px' });
                    }, 1);
                },
                // Respond to changes in the month and year selector
                onChangeMonthYear: function(year, month/*, inst*/){
                    var selectedDate = component.$(this).datepicker('getDate'); // Returns Date object

                    // If date has been selected
                    if (selectedDate) {
                        // Update the month and year on the selected date
                        selectedDate.setMonth(month - 1); // month is 1-12, setMonth is 0-11
                        selectedDate.setFullYear(year);

                        component.$(this).datepicker('setDate', selectedDate);
                    }
                }
            });
        });
    },
  style: Ember.computed('height', function() {
    let height = this.get('height');
    if(height) {
      let css = "min-height: " + height + ";";
      return new Ember.Handlebars.SafeString(css);
    }
  }),

  init() {
    this._super(...arguments);
    this.setProperties({ mode: 'editing', previewedOnce: false });
  },

  didRender() {
    this._super(...arguments);
    Ember.run.scheduleOnce('afterRender', this, '_attemptFocus');
  },

  didUpdateAttrs() {
    this._super(...arguments);
    if(!this.get('isLoading')) {
      this._resetHeight();
    }
  },

  actions: {
    blurTextarea() {
      this.set('textareaFocused', false);
    },

    edit() {
示例#7
0
 didInsertElement: function () {
     this.set('scrollWrapper', this.$().closest('.entry-preview-content'));
     Ember.run.scheduleOnce('afterRender', this, this.dropzoneHandler);
 },
示例#8
0
 */
import Ember from 'ember';

export default Ember.Component.extend({
  classNames:['section-controls-container'],
  classNameBindings: ['invisible'],
  attributeBindings:['style'],
  layoutCoordinator: Ember.inject.service('layout-coordinator'),
  invisible: Ember.computed.not('visible'),
  componentPosition:null,
  sectionComponent:null,
  style:'',

  init(){
    this._super(...arguments);
    this.get('layoutCoordinator').on('showSectionControls', Ember.run.bind(this, this.showSectionControls));
  },
  willDestroyElement(){
    this.get('layoutCoordinator').off('showSectionControls', this.showSectionControls);
  },

  showSectionControls(sectionComponent){
    if(sectionComponent){
      this.set('sectionComponent', sectionComponent);
      this.updateStyle( sectionComponent.get('componentPosition') );
      this.set('invisible', false);
    }else{
      this.updateStyle( null );
      this.set('invisible', true);
    }
  },
示例#9
0
 didInsertElement: function() {
   this._super();
   Ember.run.next(this, 'exec');
 },
 return new RSVP.Promise(function(resolve) {
   resolve(data);
   Ember.run.later(function() {
     data.pushObject('owner');
   }, 100);
 });
 this.numbersPromise = new RSVP.Promise(function(resolve) {
   Ember.run.later(function() {resolve(numbers); }, 100);
 });
 this.numbersPromise = new RSVP.Promise(function(resolve) {
   Ember.run.later(function() { console.debug('resolved!'); resolve(numbers); }, 100);
 });
 initSwiper: Ember.on('init', function() {
   Ember.run.later(this, () => {
     this.set('swiper', new Swiper(`#${this.get('elementId')}`, this.get('swiperOptions')));
   });
 })
 updateTriggered: Ember.observer('updateFor', function() {
   Ember.run.once(this, this.get('swiper').update);
 }),
示例#15
0
 isShowingChanged: Ember.observer('isShowing', function() {
   Ember.run.later(() => {
     this.set('isShowing', false);
   }, 3000);
 })
示例#16
0
文件: index.js 项目: apache/tez
 setupController: function (controller, model) {
   this._super(controller, model);
   Ember.run.later(this, "startCrumbBubble");
 },
/**
 * Prevent click events after a touchend.
 *
 * Inspired/copy-paste from this article of Google by Ryan Fioravanti
 * https://developers.google.com/mobile/articles/fast_buttons#ghost
 *
 * USAGE:
 * Prevent the click event for an certain element
 * ````
 *  PreventGhostClick($element);
 * ````
 *
 */
function makeGhostBuster() {
  var coordinates = [];
  var threshold = 25;
  var timeout = 2500;

  // no touch support
  if(!mobileDetection.is()) {
    return { add : function(){}, remove : function(){} };
  }

  /**
   * prevent clicks if they're in a registered XY region
   * @param {MouseEvent} event
   */
  function preventGhostClick(event) {

    var ev = event.originalEvent || event;
    //don't prevent fastclicks
    if (ev.fastclick) { return true; }

    for (var i = 0; i < coordinates.length; i++) {
      var x = coordinates[i][0];
      var y = coordinates[i][1];

      // within the range, so prevent the click
      if (Math.abs(ev.clientX - x) < threshold && Math.abs(ev.clientY - y) < threshold) {
        event.stopPropagation();
        event.stopImmediatePropagation();
        event.preventDefault();
        return false;
      }
    }

  }

  /**
   * reset the coordinates array
   */
  function resetCoordinates() {
    coordinates = [];
  }

  /**
   * remove the first coordinates set from the array
   */
  function popCoordinates() {
    coordinates.splice(0, 1);
  }

  /**
   * if it is an final touchend, we want to register it's place
   * @param {TouchEvent} event
   */
  function registerCoordinates(event) {
    var ev = event.originalEvent || event;

    // It seems that touchend is the cause for derived events like 'change' for
    // checkboxes. Since we're creating fastclicks, which will also cause 'change'
    // events to fire, we need to prevent default on touchend events, which has
    // the effect of not causing these derived events to be created. I am not
    // sure if this has any other negative consequences.
    ev.preventDefault();

    // touchend is triggered on every releasing finger
    // changed touches always contain the removed touches on a touchend
    // the touches object might contain these also at some browsers (firefox os)
    // so touches - changedTouches will be 0 or lower, like -1, on the final touchend
    if(ev.touches.length - ev.changedTouches.length <= 0) {
      var touch = ev.changedTouches[0];
      coordinates.push([touch.clientX, touch.clientY]);
      setTimeout(popCoordinates, timeout);
    }
  }


  /**
   * prevent click events for the given element
   * @param {EventTarget} $element jQuery object
   */
  return {
    add : Ember.run.bind(this, function ($element) {
      $element.on("touchstart.ghost-click-buster", resetCoordinates);
      $element.on("touchend.ghost-click-buster", registerCoordinates);
      // register the click buster on with the selector, '*', which will
      // cause it to fire on the first element that gets clicked on so that
      // if this is a ghost click it will get killed immediately.
      $element.on("click.ghost-click-buster", '*', preventGhostClick);
    }),
    remove : Ember.run.bind(this, function ($element) {
      $element.off('.ghost-click-buster');
    })
  };

}
示例#18
0
    if (shouldFocus) {
      // One shouldn't set an attribute when they mean to set a property.
      // Except when a property is only settable if the attribute is present.
      // We have to make the element interactive prior to focusing it.
      this.element.setAttribute('tabindex', '-1');
      this.element.setAttribute('role', 'group');

      // If we don't do this, the scroll triggered by the focus will be unfortunate.
      // This effectively swallows one scroll event.
      // TODO: Investigate setting focus to something inside of overflow: auto;
      scrollLeft = document.body.scrollLeft;
      scrollTop = document.body.scrollTop;
      window.addEventListener('scroll', handler);

      // Set the focus to the target outlet wrapper.
      Ember.run.schedule('afterRender', this, function() { this.element.focus(); });
    } else {
      this.element.removeAttribute('tabindex');
      this.element.removeAttribute('role');
    }
  },

  actions: {
    checkFocus(outletState) {
      let owner = Ember.getOwner(this);
      let pivotHandler = owner.get('_stashedHandlerInfos.pivotHandler.handler.routeName');

      let outletName = this.get('outletName');

      let currentRoute = get(outletState, `${outletName}.render.name`);
      if (!currentRoute) {
示例#19
0
 reInitDropzones: function () {
     Ember.run.scheduleOnce('afterRender', this, this.dropzoneHandler);
 }.observes('markdown')
示例#20
0
 loadChannelImage: function () {
   Ember.run.later(this, function () {
     if(this.get('lazyIMG')) { this.get('lazyIMG').update(); }
   }, 200);
 }.observes('controller.model')
示例#21
0
 arrayDidChangeAfterElementInserted: function() {
   Ember.run.scheduleOnce('afterRender', this, this._refreshSortable);
 },
示例#22
0
        case 'externalservice':     route = 'service.new-external'; break;
        default: return void this.send('error','Unknown service type: ' + this.get('type'));
      }

      this.get('application').transitionToRoute(route, {queryParams: {
        serviceId: this.get('id'),
        stackId: this.get('stackId'),
      }});
    },
  },

  scaleTimer: null,
  saveScale() {
    if ( this.get('scaleTimer') )
    {
      Ember.run.cancel(this.get('scaleTimer'));
    }

    var timer = Ember.run.later(this, function() {
      this.save().catch((err) => {
        this.get('growl').fromError('Error updating scale',err);
      });
    }, 500);

    this.set('scaleTimer', timer);
  },

  availableActions: function() {
    var a = this.get('actionLinks');

    var canUpgrade = !!a.upgrade && this.get('canUpgrade');
		return new Ember.RSVP.Promise(function (resolve, reject) {
			// First check if the item is already in the store - if it is no need to bring it again!
			var itemRecord = store.peekRecord('item', placeId);
			if (itemRecord && itemRecord.get('additionalInfoComplete')) resolve(itemRecord);
			// Otherwise, we will get additional information with a delay to prevent overloading the quota
			Ember.run.later(function () {
				self.get('googlePlaces.service').getDetails({placeId: placeId}, function (result, status) {
					//console.log(result);
					var item = store.peekRecord('item', placeId);
					if (!item || !result){
						//TODO: if the status is "over query limit" we could resend the request later
						reject({message: "didn't find the item or its representation in the store," +  status});
					} else {
						ga('send', 'event', 'googlePlaces', 'getDetails');
						item.set('phone', result.international_phone_number);
						if (!item.get('googleHours') && result.opening_hours) item.set('googleHours', result.opening_hours.periods);
						if (!item.get('name')) item.set('name', result.name);
						if (!item.get('lat') && result.geometry) {
							item.set('lat', result.geometry.location.lat());
							item.set('lng', result.geometry.location.lng());
						}
						if (result.types && result.types.length > 0) {
							item.set('itemType', result.types[0]);
						}
						if (!item.get('image') && result.photos && result.photos[0]) {
							item.set('image', result.photos[0].getUrl({maxWidth: 3000}));
							//item.set('imageAttribution', result.photos[0].html_attributions[0]);
						}
						//TODO: save additional photos
						//TODO: Save reviews
						if (result.address_components) {
							var ancestryNames = self.getAncestryFromAddress(result.address_components, result.name);
							//console.log('ancestryNames', ancestryNames);
							// Update the item record with the proper ancestry names
							item.set('ancestryNames', ancestryNames);
							// Save an index in the store to easily find this item based on its pathname
							var pathNames = item.get('pathNames');
							store.push({data: {id: pathNames,
								type: 'pathIndex',
								attributes: {
									itemId: placeId
								}}
							});
							self.findParentFromAncestry(ancestryNames, item.get('lat'), item.get('lng'), item)
								.then(function (parent) {
									if (parent) {
										item.set('ancestryNames', parent.get('pathNames'));
										item.set('ancestry', parent.get('path'));
									}
									item.save()
										.then(function (savedItem) {
											resolve(savedItem);
										});
								});
						} else {
							item.save()
								.then(function (savedItem) {
									resolve(savedItem);
								});
						}
					}
				});
			}, 1100);

		});
示例#24
0
		this.manifest();
		this.fastclick();
	},

	promise() {
		Promise.config({
			warnings: true,
			monitoring: true,
			cancellation: true,
			longStackTraces: true
		});
	},

	fastclick() {
		Ember.run.scheduleOnce('afterRender', function() {
			FastClick(document.body);
		});
	},

	origin() {
		if (window.location.origin) { return; }
		window.location.origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port: '');
	},

	manifest() {
		window.addEventListener('load', () => {
			// window.applicationCache.update();
			window.applicationCache.addEventListener('updateready', () => {
				if (window.applicationCache.status === window.applicationCache.UPDATEREADY) {
					// window.applicationCache.swapCache();
					setTimeout(() => { window.location.reload(); }, 1000);
    initializeDatetimepicker: function (owner) {
        var datetimeFormat,
            minDatetime = false,
            maxDatetime = false,
            primaryInput;

        // Set any minimum and maximum datetime values
        if (this.get('minDatetime')) {
            minDatetime = new Date(moment(this.get('minDatetime')));
        }
        if (this.get('maxDatetime')) {
            maxDatetime = new Date(moment(this.get('maxDatetime')));
        }

        // Convert the universal date format tokens into those recognized by the plugin
        datetimeFormat = this.normalizeDatetimeFormat();

        // Wait for child elements to load
        Ember.run.scheduleOnce('afterRender', this, function () {
            primaryInput = this.$(owner);

            // Identify the primary input element (other components may have been used in selectors)
            primaryInput.addClass('primary-input');
            this.set('datetimeInput', primaryInput);

            // Add Bootstrap datetimepicker functionality to the datetime input
            primaryInput.datetimepicker({
                // Allow the picker to be inspected
                //debug: true,
                // Picker positioning
                widgetPositioning: {
                    horizontal: 'left',
                    vertical: 'bottom'
                },
                // Show the datepicker and timepicker together (no-toggling)
                sideBySide: true,
                // Display format
                format: datetimeFormat,
                // Initial min and max constriants
                minDate: minDatetime,
                maxDate: maxDatetime,
                // Combined with readonly on the element effectively disables manual input
                ignoreReadonly: true,
                // Do not overwrite dates that are outside min/max
                keepInvalid: true,
                // Specifies whether to auto-populate the input with the current date
                useCurrent: false
            // Picker hide event
            }).on('dp.hide', {scope: this}, function (event) {
                var component;

                // If the event object exists and has a data property
                if (event && event.data) {
                    // Set the component context
                    component = event.data.scope;
                    // If the event has a target and we have a component context
                    if (event.target && component) {
                        // Blur the form control in order to trigger a component value update
                        component.$(event.target).blur();
                    }
                }
            }).on('dp.show', {scope: this}, function (event) {
                var component = event.data.scope,
                    componentValue = component.get('value'),
                    defaultValue = component.get('defaultDisplayValue');

                // If the component value is blank and the default value exists
                if (!componentValue && defaultValue) {
                    // Set the default value as the component value
                    component.set('value', defaultValue);
                    // Update the plugin picker date so that the new date is highlighted
                    component.$('.form-control-input .primary-input').data('DateTimePicker').date(component.get('displayProxy'));
                }
            }).on('dp.change', { scope: this }, function (event) {
                var component = event.data.scope,
                    selectedDatetime = event.date.format(component.get('datetimeStorageFormat'));

                // Update the selector-defaults service with the updated datetime value
                component.selectorDefaults.set('defaultDatetime', selectedDatetime);
            });

            // Add observers to update the datetime picker UI  min/max constraints when
            // the component min/max values are updated
            this.addObserver('minDatetime', this, this.updateDatetimepickerMin);
            this.addObserver('maxDatetime', this, this.updateDatetimepickerMax);
        });
    },
    limit = parseInt(value);
    if (limit) {
      this.set('isSaving', true);
      savingFinished = () => {
        return this.set('isSaving', false);
      };
      return repo.saveSettings({
        maximum_number_of_builds: limit
      }).then(savingFinished, savingFinished);
    }
  },

  toggle: task(function * () {
    if (!this.get('enabled') && this.get('value') !== 0) {
      try {
        yield this.get('repo').saveSettings({
          maximum_number_of_builds: 0
        });
      } catch(e) {}

      this.set('value', 0);
    }
  }),

  actions: {
    limitChanged() {
      return Ember.run.debounce(this, 'limitChanged', 1000);
    }
  }
});
示例#27
0
      success: function(data) {
        this.set('weatherData', data);

        this.trigger('weatherEvent');
      }.bind(this)
    });
  },

  // Starts the pollster, i.e. executes the `onPoll` function every interval.
  start() {
    this.set('timer', this.schedule(this.get('onPoll')));
  },

  // Stops the pollster
  stop() {
    Ember.run.cancel(this.get('timer'));
  },

  // Schedules the function `f` to be executed every `interval` time.
  schedule(f) {
    return Ember.run.later(this, function() {
      f.apply(this);
      this.set('timer', this.schedule(f));
    }, this.get('pollInterval'));
  },

  init() {
    this._super(...arguments);

    let geohandler = this.get('geohandler');
    if (geohandler.get('onceReceived')) {
示例#28
0
 didInsertElement : function(){
   this._super();
   Ember.run.scheduleOnce('afterRender', this, function() {Ember.$('[data-lorem]').html('').lorem();});
 }});
示例#29
0
 setupController: function(controller, model) {
   this._super(controller, model);
   Ember.run.later(this, this.refresh, 5000);
 }
      @param {String} componentName The name of objectlistview component.
    */
    resetFilters(componentName) {
      this.set('page', 1);
      this.set('filters', null);
      this.send('refreshList');
      this.get('objectlistviewEventsService').resetFiltersTrigger(componentName);
    },

    /**
      Changes current pattern for objects filtering.

      @method filterByAnyMatch
      @param {String} pattern A substring that is searched in objects while filtering.
      @param {String} filterCondition Condition for predicate, can be `or` or `and`.
    */
    filterByAnyMatch(pattern, filterCondition) {
      if (this.get('filter') !== pattern || this.get('filterCondition') !== filterCondition) {
        let _this = this;
        Ember.run.later((function() {
          _this.setProperties({
            filterCondition: filterCondition,
            filter: pattern,
            page: 1
          });
        }), 50);
      }
    },
  },
});