How to use the can/map/.extend function in can

To help you get started, we’ve selected a few can examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mysamai / mysam / public / sam / recognizer.js View on Github external
import Map from 'can/map/';
import 'can/map/define/';

// recognition.continuous = true;
// recognition.interimResults = true;

export default Map.extend({
  define: {
    transcript: {
      value: ''
    },

    restart: {
      value: true
    }
  },

  init() {
    this.recognition = new webkitSpeechRecognition();
    this.recognition.onresult = this.result.bind(this);
  },

  result(event) {
github donejs / donejs / docs / theme / static / js / components / upcoming-event / upcoming-event.js View on Github external
/* global moment */
import $ from 'jquery';
// import moment from 'moment'; // added globally
import Component from 'can/component/';
import Map from 'can/map/';
import 'can/map/define/';
import template from './upcoming-event.stache!';
import 'dotdotdot';

export const ViewModel = Map.extend({
  define: {
    eventBody: {
      get: function() {
        return (this.attr('model.description') || '').trim();
      }
    },
    eventDate: {
      get: function() {
        var start = this.attr('model.start');
        var startDate = start.attr('date');
        var startDateTime = start.attr('dateTime');
        if (startDateTime) {
          var datetime = moment.tz(startDateTime, 'America/Chicago').tz(start.attr('timeZone'));
          return datetime.format('MMM Do, YYYY — h:mma');
        } else if (startDate) {
          var date = moment(startDate, moment.ISO_8601);
github marshallswain / AmityApp / public / src / components / pages / settings / settings.js View on Github external
import Component from 'can/component/';
import Map from 'can/map/';
import 'can/map/define/';
import './settings.less!';
import template from './settings.stache!';

export const ViewModel = Map.extend({
  define: {
    message: {
      value: 'This is the page-settings component'
    }
  }
});

export default Component.extend({
  tag: 'page-settings',
  viewModel: ViewModel,
  template
});
github mysamai / mysam / public / sam / state.js View on Github external
import Map from 'can/map/';
import 'can/map/define/';

import Recognizer from './recognizer';
const recognition = new Recognizer();

export default Map.extend({
  define: {
    recognition: {
      value: recognition
    },

    threshold: {
      value: 0.1
    },

    name: {
      value: 'sam'
    },

    timeout: {
      value: 30000
    },
github marshallswain / AmityApp / public / src / components / pages / database / database.js View on Github external
import Component from 'can/component/';
import Map from 'can/map/';
import 'can/map/define/';
import './database.less!';
import template from './database.stache!';

export const ViewModel = Map.extend({
  define: {
    message: {
      value: 'This is the page-database component'
    }
  }
});

export default Component.extend({
  tag: 'page-database',
  viewModel: ViewModel,
  template
});
github marshallswain / AmityApp / public / src / components / pages / error / error.js View on Github external
import Component from 'can/component/';
import Map from 'can/map/';
import 'can/map/define/';
import './error.less!';
import template from './error.stache!';

export const ViewModel = Map.extend({
  define: {
    message: {
      value: 'This is the page-error component'
    }
  }
});

export default Component.extend({
  tag: 'page-error',
  viewModel: ViewModel,
  template
});
github marshallswain / AmityApp / public / src / components / sidebars / data / data.js View on Github external
import Component from 'can/component/';
import Map from 'can/map/';
import 'can/map/define/';
import './data.less!';
import template from './data.stache!';

export const ViewModel = Map.extend({
  define: {
  }
});

export default Component.extend({
  tag: 'data-sidebar',
  viewModel: ViewModel,
  template
});
github marshallswain / AmityApp / public / src / components / sidebars / left / left-sidebar.js View on Github external
import Component from 'can/component/';
import Map from 'can/map/';
import 'can/map/define/';
import './left-sidebar.less!';
import template from './left-sidebar.stache!';

export const ViewModel = Map.extend({
  define: {
    dataSideScrollPanel: {
      value: 'servers'
    },
    serverName: {
      value: null
    }
  },
  setSideScrollPanel(panelName, serverName){
    this.attr('serverName', serverName);
    this.attr('dataSideScrollPanel', panelName);
  }
});

export default Component.extend({
  tag: 'left-sidebar',
github retro / generator-canjs / app / 0.9.6 / templates / src / app.js View on Github external
import Map from "can/map/";
import route from "can/route/";
import 'can/map/define/';
import 'can/route/pushstate/';

const AppViewModel = Map.extend({
  define: {
    message: {
      value: 'Hello World!',
      serialize: false
    },
    title: {
      value: '<%= name %>',
      serialize: false
    }
  }
});

export default AppViewModel;
github donejs / place-my-order / public / pmo / restaurant / details / details.js View on Github external
import Component from 'can/component/component';
import Map from 'can/map/';
import 'can/map/define/';

import template from './details.stache!';
import Restaurant from 'pmo/models/restaurant';

export const ViewModel = Map.extend({
  define: {
    restaurant: {
      get(old) {
        let _id = this.attr('slug');
        if(!old && _id) {
          let params = { _id };
          let restaurant = Restaurant.findOne(params);
          return this.attr('@root').pageData("restaurant", params, restaurant);
        }

        return old;
      }
    }
  }
});