canvas-lms/app/jsx
Brent Burgoyne c64dded173 add js helper to parse number string for locale
also includes a helper to validate number strings for current locale

closes CNVS-33191

test plan:
- NA (a future commit demonstrating the use of the helper with be
  qa-able)

Change-Id: I1722aad263e611d127317b2f1a3832537742c3fb
Reviewed-on: https://gerrit.instructure.com/96677
Reviewed-by: Ryan Shaw <ryan@instructure.com>
Tested-by: Jenkins
QA-Review: Benjamin Christian Nelson <bcnelson@instructure.com>
Product-Review: Brent Burgoyne <bburgoyne@instructure.com>
2016-12-13 22:42:18 +00:00
..
account_course_user_search use node_modules wherever possible 2016-11-01 15:14:52 +00:00
add_people fix bad require 2016-11-02 20:41:16 +00:00
announcements Add announcements to home page with setting 2016-11-23 17:29:51 +00:00
assignments show student context cards on the moderation page 2016-12-12 23:12:11 +00:00
authentication_providers Update AuthenticationTypePicker to work with React 0.13.3 2015-11-19 00:32:45 +00:00
calendar add code coverage to appointment_groups 2016-12-05 16:51:32 +00:00
choose_mastery_path use node_modules wherever possible 2016-11-01 15:14:52 +00:00
collaborations Add current users permission for collaboration API 2016-11-22 21:01:05 +00:00
conditional_release_stats use node_modules wherever possible 2016-11-01 15:14:52 +00:00
context_cards updates StudentContextCardTrigger to render tray 2016-12-12 23:03:33 +00:00
context_modules Start using Babel to compile files in the JSX folder 2015-10-23 20:54:35 +00:00
course_link_validator improve course link validator handling with head requests 2016-04-29 17:26:20 +00:00
course_settings Revert and bring InstIcons into Canvas 2016-11-29 20:52:54 +00:00
course_wizard fix a11y issues with course setup checklist 2016-04-25 16:16:37 +00:00
custom_help_link_settings Modify Help Menu URL validation to accept mailto: 2016-12-05 23:13:15 +00:00
dashboard_card Make dashcard reordering a11y friendly 2016-12-09 00:33:44 +00:00
discussion_topics Reactify discussion keyboard shortcut modal 2016-01-12 17:41:26 +00:00
due_dates fix 'loading' in place of student names when editing assignment 2016-12-13 21:11:18 +00:00
editor clean up RCE abstraction layer and service sidebar 2016-03-30 18:03:24 +00:00
eportfolios eportfolios a11y for reorder pages/sections 2016-12-08 21:40:38 +00:00
epub_exports use node_modules wherever possible 2016-11-01 15:14:52 +00:00
external_apps fix external apps tab visibility a11y 2016-12-05 20:04:34 +00:00
files add accept button when renaming files/folders 2016-11-09 18:23:11 +00:00
gradebook fix 'loading' in place of student names when editing assignment 2016-12-13 21:11:18 +00:00
gradebook2 don't load overrides in gradebook 2016-12-02 23:38:12 +00:00
grading show timezone conversions for grading periods 2016-11-15 05:07:46 +00:00
groups fix student group dialog allows invite of non-students 2016-11-22 15:56:02 +00:00
help_dialog don't double-escape course names in the help menu 2016-11-07 12:42:58 +00:00
login manage focus switching between login and forgot password 2016-05-18 05:42:01 +00:00
modules/utils Allow items to be moved into new modules without refresh 2016-09-28 15:13:37 +00:00
navigation_header Add Spinner loading icon to canvas help menu 2016-11-03 20:12:44 +00:00
notification_preferences Upgrade InstUI to 0.14.4 2016-09-23 16:18:27 +00:00
outcomes Add popover menu and modal dialog for outcomes landing page 2016-11-16 18:34:59 +00:00
quizzes focus on the close button when dialog opens 2016-06-28 23:18:14 +00:00
shared add js helper to parse number string for locale 2016-12-13 22:42:18 +00:00
speed_grader speedgrader: disable grading in closed grading periods 2016-09-21 19:55:24 +00:00
styleguide Update react-modals in Canvas 2015-12-15 13:52:34 +00:00
theme_editor Remove .ic-app-main-layout-horizontal element 2016-11-08 20:37:16 +00:00
README.md Start using Babel to compile files in the JSX folder 2015-10-23 20:54:35 +00:00
fakeRequireJSFallback.jsx in webpack: provide a fallback so require(['jquery'] works 2016-09-20 17:15:30 +00:00
railsFlashNotificationsHelper.jsx fix flash notifications escaping links 2016-07-15 22:45:22 +00:00

README.md

This directory is temporary until we rework the front-end build This is where we are headed.

Stuff you can do in Canvas JSX files

BUT WAIT!

Your file needs to:

  1. Have a file name with the .jsx extension.

JSX

function foo(paths) {
  return <svg>{paths}</svg>;
}

Arrow Functions

Arrow Function Reference

var arr = ['hydrogen', 'helium', 'lithium'];

// es5
var a = arr.map(function(s){ return s.length });

// es6
var b = arr.map( s => s.length );

// with curlies requires normal return
var b = arr.map( (s) => {
  return s.length
});

// lexical `this`
var obj = {
  multiplier: 3,

  multiplyStuff (stuff) {
    return stuff.map((x) =>
      // no bind!
      return this.multiplier * x;
    )
  }
};

Classes

Class Reference

class EventEmitter {
  constructor() {
    // called when created
  }
  emit() {
    // ...
  }
  on() {
    // ...
  }
  once() {
    // ...
  }
  removeListener() {
    // ...
  }
  removeAllListeners() {
    // ...
  }
}

Extending and calling super.

class Domain extends EventEmitter {
  constructor() {
    super();
    this.members = [];
  }
}

Creating instances

var domain = new Domain();

Destructuring

// es5
var map = _.map;
var each = _.each;

// es6
var {map, each} = _;

Concise Object Methods

// es5
var obj = {
  foo: function() {}
  bar: function() {}
};

// es6
var obj = {
  foo() {}
  bar() {}
};

Object Short Notation

// es5
function() {
  // ...
  return {foo: foo, bar: bar, x: 10};
}

// es6
function() {
  // ...
  return {foo, bar, x: 10};
}

Rest Parameters

Rest Parameters Reference

// es5
function multiply(multiplier) {
  var numbers = Array.prototype.slice.call(arguments, 0);
  return number.map(function(n) { return multiplier * n; });
}

// es6
function multiply(multiplier, ...numbers) {
  return numbers.map( n => multiplier * n);
}

String Templates

String Template Reference

Multiline strings:

// es5
console.log("string text line 1" +
"string text line 2");

// es6
console.log(`string text line 1
string text line 2`);

Interpolated strings

var a = 5;
var b = 10;

// es5
console.log("Fifteen is " + (a + b) + " and not " + (2 * a + b) + ".");

// es6
console.log(`Fifteen is ${a + b} and not ${2 * a + b}.`);