convert public/javascript that export something to import/export

These files can only be converted to import/export
if we pass them through babel (so we can use the
interopRequireDefault and “addModuleExports” stuff
babel provides) to make it work with our coffeescript.

closes: CNVS-35466

test plan:
* nothing should change
* the build should pass
* pages that use this should still work

Change-Id: I994e84e26f081c3f5670c64027a285c6a0419529
Reviewed-on: https://gerrit.instructure.com/106265
Tested-by: Jenkins
Reviewed-by: Brent Burgoyne <bburgoyne@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
QA-Review: Ryan Shaw <ryan@instructure.com>
This commit is contained in:
Ryan Shaw 2017-03-24 10:34:54 -06:00
parent 9b0ff6d479
commit dde014778c
53 changed files with 829 additions and 1011 deletions

View File

@ -27,7 +27,7 @@ define [
'jquery.loadingImg' # loadingImage #
'vendor/jquery.scrollTo' # /\.scrollTo/ #
'jqueryui/datepicker' # /\.datepicker/ #
], ($, calendarMonths, RichContentEditor, KeyboardShortcuts) ->
], ($, {changeMonth}, RichContentEditor, KeyboardShortcuts) ->
specialDatesAreHidden = false
@ -141,14 +141,14 @@ define [
prev_next_links = $mini_month.find('.next_month_link, .prev_month_link')
prev_next_links.on 'click', (ev) ->
ev.preventDefault()
calendarMonths.changeMonth $mini_month, if $(this).hasClass('next_month_link') then 1 else -1
changeMonth $mini_month, if $(this).hasClass('next_month_link') then 1 else -1
highlightDaysWithEvents()
miniCalendarDayClick = (ev) ->
ev.preventDefault()
date = $(ev.target).closest('.mini_calendar_day')[0].id.slice(9)
[year, month, day] = date.split('_')
calendarMonths.changeMonth $mini_month, "#{month}/#{day}/#{year}"
changeMonth $mini_month, "#{month}/#{day}/#{year}"
highlightDaysWithEvents()
selectDate(date)
$(".events_#{date}").ifExists ($events) ->
@ -173,7 +173,7 @@ define [
return false if !dateString || dateString > todayString
$lastBefore = $(this)
calendarMonths.changeMonth $mini_month, $.datepicker.formatDate 'mm/dd/yy', new Date
changeMonth $mini_month, $.datepicker.formatDate 'mm/dd/yy', new Date
highlightDaysWithEvents()
$lastBefore ||= $('tr.date:first')

View File

@ -21,7 +21,7 @@ import React from 'react'
import PropTypes from 'prop-types'
import _ from 'underscore'
import I18n from 'i18n!account_course_user_search'
import userUtils from 'user_utils'
import {firstNameFirst, lastNameFirst, nameParts} from 'user_utils'
import Modal from 'jsx/shared/modal'
import ModalContent from 'jsx/shared/modal-content'
import ModalButtons from 'jsx/shared/modal-buttons'
@ -76,10 +76,10 @@ import 'compiled/jquery.rails_flash_notifications'
newData[field] = value;
if (field === 'name') {
// shamelessly copypasted from user_sortable_name.js
var sortable_name_parts = userUtils.nameParts(data.sortable_name);
if ($.trim(data.sortable_name) == '' || userUtils.firstNameFirst(sortable_name_parts) == $.trim(data.name)) {
var parts = userUtils.nameParts(value, sortable_name_parts[1]);
newData.sortable_name = userUtils.lastNameFirst(parts);
var sortable_name_parts = nameParts(data.sortable_name);
if ($.trim(data.sortable_name) == '' || firstNameFirst(sortable_name_parts) == $.trim(data.name)) {
var parts = nameParts(value, sortable_name_parts[1]);
newData.sortable_name = lastNameFirst(parts);
}
if ($.trim(data.short_name) == '' || data.short_name == data.name) {

View File

@ -16,6 +16,6 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import submissions from 'submissions'
import {setup} from 'submissions'
submissions.setup()
setup()

View File

@ -16,24 +16,22 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
'i18n!account_settings',
'jquery', // $
'tinymce.config',
'global_announcements',
'jquery.ajaxJSON', // ajaxJSON
'jquery.instructure_date_and_time', // date_field, time_field, datetime_field, /\$\.datetime/
'jquery.instructure_forms', // formSubmit, getFormData, validateForm
'jqueryui/dialog',
'jquery.instructure_misc_helpers', // replaceTags
'jquery.instructure_misc_plugins', // confirmDelete, showIf, /\.log/
'jquery.loadingImg', // loadingImg, loadingImage
'vendor/date', // Date.parse
'vendor/jquery.scrollTo', // /\.scrollTo/
'jqueryui/tabs' // /\.tabs/
], function(I18n, $, EditorConfig, globalAnnouncements) {
import I18n from 'i18n!account_settings'
import $ from 'jquery'
import EditorConfig from './tinymce.config'
import globalAnnouncements from './global_announcements'
import './jquery.ajaxJSON'
import './jquery.instructure_date_and_time' // date_field, time_field, datetime_field, /\$\.datetime/
import './jquery.instructure_forms' // formSubmit, getFormData, validateForm
import 'jqueryui/dialog'
import './jquery.instructure_misc_helpers' // replaceTags
import './jquery.instructure_misc_plugins' // confirmDelete, showIf, /\.log/
import './jquery.loadingImg'
import './vendor/date' // Date.parse
import './vendor/jquery.scrollTo'
import 'jqueryui/tabs'
function openReportDescriptionLink (event) {
export function openReportDescriptionLink (event) {
event.preventDefault();
var title = $(this).parents('.title').find('span.title').text();
var $desc = $(this).parent('.reports').find('.report_description');
@ -43,7 +41,7 @@ define([
});
}
function addUsersLink (event) {
export function addUsersLink (event) {
event.preventDefault();
var $enroll_users_form = $('#enroll_users_form');
$(this).hide();
@ -326,10 +324,3 @@ define([
$('#global_includes_warning_message_wrapper').toggleClass('alert', this.checked);
}).trigger('change');
});
return {
addUsersLink: addUsersLink,
openReportDescriptionLink: openReportDescriptionLink
}
});

View File

@ -16,17 +16,17 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define(['../../node_modules/axios'], function (axios) {
// Add CSRF stuffs to make Canvas happy when we are making requests with axios
axios.defaults.xsrfCookieName = '_csrf_token';
axios.defaults.xsrfHeaderName = 'X-CSRF-Token';
import axios from '../../node_modules/axios'
// Handle stringified IDs for JSON responses
var originalDefaults = axios.defaults.headers.common['Accept'];
axios.defaults.headers.common['Accept'] = 'application/json+canvas-string-ids, ' + originalDefaults;
// Add CSRF stuffs to make Canvas happy when we are making requests with axios
axios.defaults.xsrfCookieName = '_csrf_token';
axios.defaults.xsrfHeaderName = 'X-CSRF-Token';
// Rails checks this header to decide if a request is an xhr request
axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
// Handle stringified IDs for JSON responses
var originalDefaults = axios.defaults.headers.common['Accept'];
axios.defaults.headers.common['Accept'] = 'application/json+canvas-string-ids, ' + originalDefaults;
return axios;
});
// Rails checks this header to decide if a request is an xhr request
axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
export default axios

View File

@ -15,156 +15,150 @@
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import I18n from 'i18nObj'
import $ from 'jquery'
import './jquery.instructure_date_and_time'
import './jquery.templateData' /* fillTemplateData */
import 'jqueryui/datepicker'
define([
'i18nObj',
'jquery' /* $ */,
'jquery.instructure_date_and_time' /* datepicker */,
'jquery.templateData' /* fillTemplateData */,
'jqueryui/datepicker' /* /\.datepicker/ */
], function(I18n, $) {
const monthNames = I18n.lookup('date.month_names')
var monthNames = I18n.lookup('date.month_names');
function makeDate (date) {
return {
day: date.getDate(),
month: date.getMonth(),
year: date.getFullYear()
}
}
function makeDate(date) {
return {
day: date.getDate(),
month: date.getMonth(),
year: date.getFullYear()
export function changeMonth ($month, change) {
const monthData = $month.data('calendar_objects')
var data = {}
var current = null
if (typeof (change) === 'string') {
var current = $.datepicker.oldParseDate('mm/dd/yy', change)
if (current) {
current.setDate(1)
}
}
return {
changeMonth: function($month, change) {
var monthData = $month.data('calendar_objects');
var data = {};
var current = null;
if(typeof(change) == "string") {
var current = $.datepicker.oldParseDate('mm/dd/yy', change);
if(current) {
current.setDate(1);
}
}
if(!current) {
var month = parseInt($month.find(".month_number").text(), 10);
var year = parseInt($month.find(".year_number").text(), 10);
var current = new Date(year, month + change - 1, 1);
}
var data = {
month_name: monthNames[current.getMonth() + 1],
month_number: current.getMonth() + 1,
year_number: current.getFullYear()
};
$month.fillTemplateData({data: data});
var date = new Date();
var today = makeDate(date);
var firstDayOfMonth = makeDate(current);
date = current;
date.setDate(0);
date.setDate(date.getDate() - date.getDay());
var firstDayOfSquare = makeDate(date);
var lastDayOfPreviousMonth = null;
if(firstDayOfMonth.day != firstDayOfSquare.day) {
date.setDate(1);
date.setMonth(date.getMonth() + 1);
date.setDate(0);
lastDayOfPreviousMonth = {
day: date.getDate(),
month: firstDayOfSquare.month,
year: firstDayOfSquare.year
}
date.setDate(1);
date.setMonth(date.getMonth() + 1);
}
date.setMonth(current.getMonth() + 1);
date.setDate(0);
var lastDayOfMonth = {
day: date.getDate(),
month: firstDayOfMonth.month,
year: firstDayOfMonth.yearh
}
date.setDate(date.getDate() + 1);
date.setDate(date.getDate() + (6 - date.getDay()));
date.setDate(date.getDate() + 7);
var lastDayOfSquare = makeDate(date);
var $days = $month.data("days");
if(!$days) {
$days = $month.find(".calendar_day_holder");
$month.data("days", $days);
}
if($month.hasClass('mini_month')) {
$days = $month.find(".day");
}
$month.find(".calendar_event").remove();
var idx = 0;
var day = firstDayOfSquare.day;
var month = firstDayOfSquare.month;
var year = firstDayOfSquare.year;
while(day <= lastDayOfSquare.day || month != lastDayOfSquare.month) {
var $day = $days.eq(idx);
if($day.length > 0) {
var classes = $day.attr('class').split(" ");
var class_names = [];
for(var i = 0; i < classes.length; i++) {
if(classes[i].indexOf('date_') == 0) {
} else {
class_names.push(classes[i]);
}
}
$day.attr('class', class_names.join(" "));
}
$day.show().addClass('visible').parents("tr").show().addClass('visible');
var data = {
day_number: day
}
var month_number = month < 9 ? "0" + (month + 1) : (month + 1);
var day_number = day < 10 ? "0" + day : day;
var id = "day_" + year + "_" + month_number + "_" + day_number;
if($month.hasClass('mini_month')) {
id = "mini_" + id;
}
$day.attr('id', id)
.addClass("date_" + month_number + "_" + day_number + "_" + year)
.find(".day_number").text(day).attr('title', month_number + "/" + day_number + "/" + year)
.addClass("date_" + month_number + "_" + day_number + "_" + year); // left here because I don't know what it'll break...
var $div = $day.children('div');
if($month.hasClass('mini_month')) {
$div = $day;
}
$div.removeClass('current_month other_month next_month previous_month today');
if(month == firstDayOfMonth.month) {
$div.addClass('current_month');
if (!current) {
var month = parseInt($month.find('.month_number').text(), 10)
var year = parseInt($month.find('.year_number').text(), 10)
var current = new Date(year, month + change - 1, 1)
}
var data = {
month_name: monthNames[current.getMonth() + 1],
month_number: current.getMonth() + 1,
year_number: current.getFullYear()
}
$month.fillTemplateData({data})
let date = new Date()
const today = makeDate(date)
const firstDayOfMonth = makeDate(current)
date = current
date.setDate(0)
date.setDate(date.getDate() - date.getDay())
const firstDayOfSquare = makeDate(date)
let lastDayOfPreviousMonth = null
if (firstDayOfMonth.day != firstDayOfSquare.day) {
date.setDate(1)
date.setMonth(date.getMonth() + 1)
date.setDate(0)
lastDayOfPreviousMonth = {
day: date.getDate(),
month: firstDayOfSquare.month,
year: firstDayOfSquare.year
}
date.setDate(1)
date.setMonth(date.getMonth() + 1)
}
date.setMonth(current.getMonth() + 1)
date.setDate(0)
const lastDayOfMonth = {
day: date.getDate(),
month: firstDayOfMonth.month,
year: firstDayOfMonth.yearh
}
date.setDate(date.getDate() + 1)
date.setDate(date.getDate() + (6 - date.getDay()))
date.setDate(date.getDate() + 7)
const lastDayOfSquare = makeDate(date)
let $days = $month.data('days')
if (!$days) {
$days = $month.find('.calendar_day_holder')
$month.data('days', $days)
}
if ($month.hasClass('mini_month')) {
$days = $month.find('.day')
}
$month.find('.calendar_event').remove()
let idx = 0
let day = firstDayOfSquare.day
var month = firstDayOfSquare.month
var year = firstDayOfSquare.year
while (day <= lastDayOfSquare.day || month != lastDayOfSquare.month) {
var $day = $days.eq(idx)
if ($day.length > 0) {
const classes = $day.attr('class').split(' ')
const class_names = []
for (let i = 0; i < classes.length; i++) {
if (classes[i].indexOf('date_') == 0) {
} else {
$div.addClass('other_month');
if(firstDayOfMonth.month == (month + 1) % 12) {
$div.addClass('previous_month');
} else {
$div.addClass('next_month');
}
}
if(month == today.month && day == today.day && year == today.year) {
$div.addClass('today');
}
day++;
idx++;
if((lastDayOfPreviousMonth && day > lastDayOfPreviousMonth.day && month == lastDayOfPreviousMonth.month)
|| (day > lastDayOfMonth.day && month == lastDayOfMonth.month)) {
month = month + 1;
if(month >= 12) {
month -= 12;
year++;
}
day = 1;
class_names.push(classes[i])
}
}
while(idx < $days.length) {
var $day = $days.eq(idx);
$day.parents("tr").hide().removeClass('visible');
$day.hide().removeClass('visible');
idx++;
}
if(!$month.hasClass('mini_month')) {
$day.attr('class', class_names.join(' '))
}
$day.show().addClass('visible').parents('tr').show().addClass('visible')
var data = {
day_number: day
}
const month_number = month < 9 ? `0${month + 1}` : (month + 1)
const day_number = day < 10 ? `0${day}` : day
let id = `day_${year}_${month_number}_${day_number}`
if ($month.hasClass('mini_month')) {
id = `mini_${id}`
}
$day.attr('id', id)
.addClass(`date_${month_number}_${day_number}_${year}`)
.find('.day_number').text(day).attr('title', `${month_number}/${day_number}/${year}`)
.addClass(`date_${month_number}_${day_number}_${year}`) // left here because I don't know what it'll break...
let $div = $day.children('div')
if ($month.hasClass('mini_month')) {
$div = $day
}
$div.removeClass('current_month other_month next_month previous_month today')
if (month == firstDayOfMonth.month) {
$div.addClass('current_month')
} else {
$div.addClass('other_month')
if (firstDayOfMonth.month == (month + 1) % 12) {
$div.addClass('previous_month')
} else {
$div.addClass('next_month')
}
}
};
});
if (month == today.month && day == today.day && year == today.year) {
$div.addClass('today')
}
day++
idx++
if ((lastDayOfPreviousMonth && day > lastDayOfPreviousMonth.day && month == lastDayOfPreviousMonth.month)
|| (day > lastDayOfMonth.day && month == lastDayOfMonth.month)) {
month += 1
if (month >= 12) {
month -= 12
year++
}
day = 1
}
}
while (idx < $days.length) {
var $day = $days.eq(idx)
$day.parents('tr').hide().removeClass('visible')
$day.hide().removeClass('visible')
idx++
}
if (!$month.hasClass('mini_month')) {
}
}

View File

@ -15,18 +15,15 @@
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
'i18n!collaborations',
'jquery' /* $ */,
'jquery.ajaxJSON' /* ajaxJSON */,
'jquery.instructure_forms' /* fillFormData, getFormData, errorBox */,
'jqueryui/dialog',
'jquery.instructure_misc_plugins' /* .dim, confirmDelete, fragmentChange, showIf */,
'jquery.templateData' /* getTemplateData */,
'vendor/jquery.scrollTo' /* /\.scrollTo/ */,
'compiled/jquery.rails_flash_notifications' /* screen reader notifications*/
], function(I18n, $) {
import I18n from 'i18n!collaborations'
import $ from 'jquery'
import './jquery.ajaxJSON'
import './jquery.instructure_forms' /* fillFormData, getFormData, errorBox */
import 'jqueryui/dialog'
import './jquery.instructure_misc_plugins' /* .dim, confirmDelete, fragmentChange, showIf */
import './jquery.templateData' /* getTemplateData */
import './vendor/jquery.scrollTo'
import 'compiled/jquery.rails_flash_notifications'
var CollaborationsPage = {};
@ -168,6 +165,4 @@ define([
$(document).ready(CollaborationsPage.Events.init.bind(CollaborationsPage.Events));
return CollaborationsPage;
});
export default CollaborationsPage;

View File

@ -16,47 +16,43 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
'underscore',
'compiled/models/ModuleFile',
'jsx/shared/PublishCloud',
'react',
'react-dom',
'compiled/models/PublishableModuleItem',
'compiled/views/PublishIconView',
'compiled/views/LockIconView',
'jsx/blueprint_courses/apps/MasterCourseModuleLock',
'INST' /* INST */,
'i18n!context_modules',
'jquery' /* $ */,
'context_modules_helper', /* Helper */
'jsx/shared/conditional_release/CyoeHelper',
'compiled/views/context_modules/context_modules' /* handles the publish/unpublish state */,
'compiled/views/modules/RelockModulesDialog',
'compiled/util/vddTooltip',
'jst/_vddTooltip',
'compiled/models/Publishable',
'compiled/views/PublishButtonView',
'str/htmlEscape',
'jsx/modules/utils/setupContentIds',
'jsx/shared/dig',
'jquery.ajaxJSON' /* ajaxJSON */,
'jquery.instructure_date_and_time' /* dateString, datetimeString, time_field, datetime_field */,
'jquery.instructure_forms' /* formSubmit, fillFormData, formErrors, errorBox */,
'jqueryui/dialog',
'compiled/jquery/fixDialogButtons' /* fix dialog formatting */,
'jquery.instructure_misc_helpers' /* /\$\.underscore/ */,
'jquery.instructure_misc_plugins' /* .dim, confirmDelete, fragmentChange, showIf */,
'jquery.keycodes' /* keycodes */,
'jquery.loadingImg' /* loadingImage */,
'jquery.templateData' /* fillTemplateData, getTemplateData */,
'vendor/date' /* Date.parse */,
'vendor/jquery.scrollTo' /* /\.scrollTo/ */,
'jqueryui/sortable' /* /\.sortable/ */,
'compiled/jquery.rails_flash_notifications'
], function (_, ModuleFile, PublishCloud, React, ReactDOM, PublishableModuleItem, PublishIconView,
LockIconView, MasterCourseModuleLock, INST, I18n, $, Helper, CyoeHelper, ContextModulesView, RelockModulesDialog,
vddTooltip, vddTooltipView, Publishable, PublishButtonView, htmlEscape, setupContentIds, dig) {
import _ from 'underscore'
import ModuleFile from 'compiled/models/ModuleFile'
import PublishCloud from 'jsx/shared/PublishCloud'
import React from 'react'
import ReactDOM from 'react-dom'
import PublishableModuleItem from 'compiled/models/PublishableModuleItem'
import PublishIconView from 'compiled/views/PublishIconView'
import LockIconView from 'compiled/views/LockIconView'
import MasterCourseModuleLock from 'jsx/blueprint_courses/apps/MasterCourseModuleLock'
import INST from './INST'
import I18n from 'i18n!context_modules'
import $ from 'jquery'
import Helper from './context_modules_helper'
import CyoeHelper from 'jsx/shared/conditional_release/CyoeHelper'
import ContextModulesView from 'compiled/views/context_modules/context_modules' /* handles the publish/unpublish state */
import RelockModulesDialog from 'compiled/views/modules/RelockModulesDialog'
import vddTooltip from 'compiled/util/vddTooltip'
import vddTooltipView from 'jst/_vddTooltip'
import Publishable from 'compiled/models/Publishable'
import PublishButtonView from 'compiled/views/PublishButtonView'
import htmlEscape from './str/htmlEscape'
import setupContentIds from 'jsx/modules/utils/setupContentIds'
import dig from 'jsx/shared/dig'
import './jquery.ajaxJSON'
import './jquery.instructure_date_and_time' /* dateString, datetimeString, time_field, datetime_field */
import './jquery.instructure_forms' /* formSubmit, fillFormData, formErrors, errorBox */
import 'jqueryui/dialog'
import 'compiled/jquery/fixDialogButtons'
import './jquery.instructure_misc_helpers' /* /\$\.underscore/ */
import './jquery.instructure_misc_plugins' /* .dim, confirmDelete, fragmentChange, showIf */
import './jquery.keycodes'
import './jquery.loadingImg'
import './jquery.templateData' /* fillTemplateData, getTemplateData */
import './vendor/date' /* Date.parse */
import './vendor/jquery.scrollTo'
import 'jqueryui/sortable'
import 'compiled/jquery.rails_flash_notifications'
// TODO: AMD don't export global, use as module
/*global modules*/
@ -2026,5 +2022,4 @@ define([
});
return modules;
});
export default modules;

View File

@ -16,8 +16,6 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
], function () {
var Helper = {}
Helper.setWindowLocation = function (url) {
@ -29,5 +27,4 @@ define([
this.setWindowLocation($elt.attr('data-item-href'))
}.bind(Helper)
return Helper
})
export default Helper

View File

@ -16,52 +16,43 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([], function () {
function camelizeString(str, lowerFirst) {
return (str || '').replace (/(?:^|[-_])(\w)/g, function (_, c, index) {
if (index === 0 && lowerFirst) {
return c ? c.toLowerCase() : '';
}
else {
return c ? c.toUpperCase () : '';
}
});
}
function underscoreString(str) {
return str.replace(/([A-Z])/g, function($1){
return '_' + $1.toLowerCase();
});
}
return {
// Convert all property keys in an object to camelCase
camelize: function(props) {
var prop;
var attrs = {};
for (prop in props) {
if (props.hasOwnProperty(prop)) {
attrs[camelizeString(prop, true)] = props[prop];
}
}
return attrs;
},
underscore: function(props) {
var prop;
var attrs = {};
for (prop in props) {
if (props.hasOwnProperty(prop)) {
attrs[underscoreString(prop)] = props[prop];
}
}
return attrs;
function camelizeString (str, lowerFirst) {
return (str || '').replace(/(?:^|[-_])(\w)/g, (_, c, index) => {
if (index === 0 && lowerFirst) {
return c ? c.toLowerCase() : ''
} else {
return c ? c.toUpperCase() : ''
}
};
})
}
});
function underscoreString (str) {
return str.replace(/([A-Z])/g, $1 => `_${$1.toLowerCase()}`)
}
// Convert all property keys in an object to camelCase
export function camelize (props) {
let prop
const attrs = {}
for (prop in props) {
if (props.hasOwnProperty(prop)) {
attrs[camelizeString(prop, true)] = props[prop]
}
}
return attrs
}
export function underscore (props) {
let prop
const attrs = {}
for (prop in props) {
if (props.hasOwnProperty(prop)) {
attrs[underscoreString(prop)] = props[prop]
}
}
return attrs
}

View File

@ -16,8 +16,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([], function() {
var tabIdFromElement = function(el) {
export function tabIdFromElement (el) {
var tabIdStr = el.id;
if (tabIdStr) {
var tabId = tabIdStr.replace(/^nav_edit_tab_id_/, '');
@ -30,8 +29,3 @@ define([], function() {
}
return null;
}
return {
'tabIdFromElement': tabIdFromElement
};
});

View File

@ -16,7 +16,6 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define( function(){
// based on this solution:
// http://stackoverflow.com/questions/7394748/whats-the-right-way-to-decode-a-string-that-has-special-html-entities-in-it
@ -24,9 +23,8 @@ define( function(){
// round trip through a textarea to do it. this seems to be a best practice,
// as far as we can tell.
return function(encodedString){
export default function(encodedString){
var textArea = document.createElement('textarea');
textArea.innerHTML = encodedString;
return textArea.value;
}
});

View File

@ -16,26 +16,24 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
'i18n!edit_rubric',
'jst/changePointsPossibleToMatchRubricDialog',
'jquery' /* $ */,
'underscore' /* _ */,
'str/htmlEscape',
'jsx/shared/helpers/numberHelper',
'find_outcome',
'jquery.ajaxJSON' /* ajaxJSON */,
'jquery.instructure_forms' /* formSubmit, fillFormData, getFormData */,
'jqueryui/dialog',
'jquery.instructure_misc_helpers' /* replaceTags */,
'jquery.instructure_misc_plugins' /* confirmDelete, showIf */,
'jquery.loadingImg' /* loadingImage */,
'jquery.templateData' /* fillTemplateData, getTemplateData */,
'compiled/jquery.rails_flash_notifications',
'vendor/jquery.ba-tinypubsub',
'vendor/jquery.scrollTo' /* /\.scrollTo/ */,
'compiled/jquery/fixDialogButtons'
], function(I18n, changePointsPossibleToMatchRubricDialog, $, _, htmlEscape, numberHelper) {
import I18n from 'i18n!edit_rubric'
import changePointsPossibleToMatchRubricDialog from 'jst/changePointsPossibleToMatchRubricDialog'
import $ from 'jquery'
import _ from 'underscore'
import htmlEscape from './str/htmlEscape'
import numberHelper from 'jsx/shared/helpers/numberHelper'
import 'find_outcome'
import './jquery.ajaxJSON'
import './jquery.instructure_forms' /* formSubmit, fillFormData, getFormData */
import 'jqueryui/dialog'
import './jquery.instructure_misc_helpers' /* replaceTags */
import './jquery.instructure_misc_plugins' /* confirmDelete, showIf */
import './jquery.loadingImg'
import './jquery.templateData' /* fillTemplateData, getTemplateData */
import 'compiled/jquery.rails_flash_notifications'
import 'vendor/jquery.ba-tinypubsub'
import './vendor/jquery.scrollTo'
import 'compiled/jquery/fixDialogButtons'
var rubricEditing = {
htmlBody: null,
@ -1024,5 +1022,4 @@ define([
$.publish('edit_rubric/initted')
};
return rubricEditing;
});
export default rubricEditing;

View File

@ -1,3 +1,4 @@
/*
* Copyright (C) 2016 - present Instructure, Inc.
*
@ -16,10 +17,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([], function() {
return {
fetchContent: function($section, section_type, name){
export function fetchContent ($section, section_type, name){
var data = {}
if(section_type == "rich_text") {
data[name + '[section_type]'] = "rich_text";
@ -37,6 +35,3 @@ define([], function() {
}
return data
}
}
})

View File

@ -16,14 +16,12 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
'i18n!find_outcome',
'jquery' /* $ */,
'compiled/str/TextHelper',
'jquery.ajaxJSON' /* ajaxJSON */,
'jqueryui/dialog',
'jquery.templateData' /* fillTemplateData, getTemplateData */
], function(I18n, $, TextHelper) {
import I18n from 'i18n!find_outcome'
import $ from 'jquery'
import TextHelper from 'compiled/str/TextHelper'
import './jquery.ajaxJSON'
import 'jqueryui/dialog'
import './jquery.templateData' /* fillTemplateData, getTemplateData */
var find_outcome = (function() {
return {
@ -120,6 +118,4 @@ $(document).ready(function() {
});
});
return find_outcome;
});
export default find_outcome;

View File

@ -16,13 +16,12 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
'i18n!account_settings',
'jquery',
'jsx/shared/rce/RichContentEditor',
'jquery.instructure_forms', // errorBox, validateForm
'jquery.instructure_misc_plugins' // confirmDelete, showIf
], function(I18n, $, RichContentEditor) {
import I18n from 'i18n!account_settings'
import $ from 'jquery'
import RichContentEditor from 'jsx/shared/rce/RichContentEditor'
import './jquery.instructure_forms'
import './jquery.instructure_misc_plugins'
// optimization so user isn't waiting on RCS to
// respond when they hit announcements
RichContentEditor.preloadRemoteModule()
@ -30,7 +29,7 @@ define([
// account_settings.js mixes a lot of dom management for each of it's
// tabs, so this file is meant to encapsulate just the javascript
// used for working with the Announcements tab
return {
export default {
bindDomEvents: function(){
$(".add_notification_toggle_focus").click(function() {
var aria_expanded = $('add_notification_form').attr('aria-expanded') === "true";
@ -106,4 +105,3 @@ define([
})
}
};
});

View File

@ -16,13 +16,12 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
'i18n!gradebook',
'jquery' /* $ */,
'jsx/gradebook/shared/helpers/GradeFormatHelper',
'jquery.ajaxJSON' /* ajaxJSON */,
'jquery.instructure_date_and_time' /* datetimeString */
], function (I18n, $, GradeFormatHelper) {
import I18n from 'i18n!gradebook'
import $ from 'jquery'
import GradeFormatHelper from 'jsx/gradebook/shared/helpers/GradeFormatHelper'
import './jquery.ajaxJSON'
import './jquery.instructure_date_and_time' /* datetimeString */
function announceUpdatedCurrentGrade (currentGrade) {
var noGrade = '--';
var flashMessage;
@ -96,5 +95,4 @@ define([
}
};
return GradebookHistory;
});
export default GradebookHistory;

View File

@ -15,22 +15,20 @@
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import I18n from 'i18n!gradebook'
import $ from 'jquery'
import _ from 'underscore'
import htmlEscape from './str/htmlEscape'
import numberHelper from 'jsx/shared/helpers/numberHelper'
import waitForProcessing from 'jsx/gradebook/uploads/wait_for_processing'
import ProcessGradebookUpload from 'jsx/gradebook/uploads/process_gradebook_upload'
import GradeFormatHelper from 'jsx/gradebook/shared/helpers/GradeFormatHelper'
import './vendor/slickgrid' /* global Slick */
import './vendor/slickgrid/slick.editors' /* global.Slick.Editors */
import './jquery.instructure_forms' /* errorBox */
import './jquery.instructure_misc_helpers' /* /\.detect/ */
import './jquery.templateData' /* fillTemplateData */
define([
'i18n!gradebook',
'jquery',
'underscore',
'str/htmlEscape',
'jsx/shared/helpers/numberHelper',
'jsx/gradebook/uploads/wait_for_processing',
'jsx/gradebook/uploads/process_gradebook_upload',
'jsx/gradebook/shared/helpers/GradeFormatHelper',
'vendor/slickgrid' /* global Slick */,
'vendor/slickgrid/slick.editors' /* global.Slick.Editors */,
'jquery.instructure_forms' /* errorBox */,
'jquery.instructure_misc_helpers' /* /\.detect/ */,
'jquery.templateData' /* fillTemplateData */
], function (I18n, $, _, htmlEscape, numberHelper, waitForProcessing, ProcessGradebookUpload, GradeFormatHelper) {
var GradebookUploader = {
createGeneralFormatter: function (attribute) {
return function (row, cell, value) {
@ -382,5 +380,4 @@ define([
}
};
return GradebookUploader;
});
export default GradebookUploader;

View File

@ -15,17 +15,14 @@
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
'i18n!instructure',
'jquery' /* $ */,
'str/htmlEscape',
'compiled/behaviors/authenticity_token',
'jquery.ajaxJSON' /* ajaxJSON */,
'jqueryui/dialog',
'jquery.scrollToVisible' /* scrollToVisible */,
'vendor/jquery.scrollTo' /* /\.scrollTo/ */
], function(I18n, $, htmlEscape, authenticity_token) {
import I18n from 'i18n!instructure'
import $ from 'jquery'
import htmlEscape from './str/htmlEscape'
import authenticity_token from 'compiled/behaviors/authenticity_token'
import './jquery.ajaxJSON'
import 'jqueryui/dialog'
import './jquery.scrollToVisible'
import './vendor/jquery.scrollTo'
$.fn.setOptions = function(prompt, options) {
var result = prompt ? "<option value=''>" + htmlEscape(prompt) + "</option>" : "";
@ -420,5 +417,4 @@ define([
};
return $;
});
export default $;

View File

@ -16,14 +16,13 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
'i18n!message_students',
'jquery' /* $ */,
'jsx/shared/helpers/numberHelper',
'jquery.instructure_forms' /* formSubmit */,
'jqueryui/dialog',
'jquery.instructure_misc_plugins', /* showIf */
], function (I18n, $, numberHelper) {
import I18n from 'i18n!message_students'
import $ from 'jquery'
import numberHelper from 'jsx/shared/helpers/numberHelper'
import './jquery.instructure_forms' /* formSubmit */
import 'jqueryui/dialog'
import './jquery.instructure_misc_plugins' /* showIf */
var $message_students_dialog = $("#message_students_dialog");
var $sendButton = $message_students_dialog.find(".send_button");
var currentSettings = {};
@ -198,5 +197,4 @@ define([
disableButtons(disabled, $sendButton);
}
return messageStudents;
});
export default messageStudents;

View File

@ -16,27 +16,24 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
'i18n!question_bank',
'jquery' /* $ */,
'find_outcome',
'jst/quiz/move_question',
'str/htmlEscape',
'jsx/quizzes/question_bank/moveMultipleQuestionBanks',
'jsx/quizzes/question_bank/loadBanks',
'jsx/quizzes/question_bank/addBank',
'jquery.ajaxJSON' /* ajaxJSON */,
'jquery.instructure_forms' /* formSubmit, getFormData, formErrors */,
'jqueryui/dialog',
'jquery.instructure_misc_helpers' /* replaceTags */,
'jquery.instructure_misc_plugins' /* confirmDelete, showIf, .dim */,
'jquery.keycodes' /* keycodes */,
'jquery.loadingImg' /* loadingImage */,
'jquery.templateData' /* fillTemplateData, getTemplateData */
], function(I18n, $, find_outcome, moveQuestionTemplate, htmlEscape, moveMultipleQuestionBanks, loadBanks, addBank) {
import I18n from 'i18n!question_bank'
import $ from 'jquery'
import find_outcome from './find_outcome'
import moveQuestionTemplate from 'jst/quiz/move_question'
import htmlEscape from './str/htmlEscape'
import moveMultipleQuestionBanks from 'jsx/quizzes/question_bank/moveMultipleQuestionBanks'
import loadBanks from 'jsx/quizzes/question_bank/loadBanks'
import addBank from 'jsx/quizzes/question_bank/addBank'
import './jquery.ajaxJSON'
import './jquery.instructure_forms' /* formSubmit, getFormData, formErrors */
import 'jqueryui/dialog'
import './jquery.instructure_misc_helpers' /* replaceTags */
import './jquery.instructure_misc_plugins' /* confirmDelete, showIf, .dim */
import './jquery.keycodes'
import './jquery.loadingImg'
import './jquery.templateData'
var questionBankPage = {
updateAlignments: function(alignments) {
export function updateAlignments (alignments) {
$(".add_outcome_text").text(I18n.t("updating_outcomes", "Updating Outcomes...")).attr('disabled', true);
var params = {};
for(var idx in alignments) {
@ -75,9 +72,9 @@ define([
}, function(data) {
$(".add_outcome_text").text(I18n.t("update_outcomes_fail", "Updating Outcomes Failed")).attr('disabled', false);
});
},
}
_attachPageEvents: function(e) {
export function attachPageEvents(e) {
$("#aligned_outcomes_list").delegate('.delete_outcome_link', 'click', function(event) {
event.preventDefault();
var result = confirm(I18n.t("remove_outcome_from_bank", "Are you sure you want to remove this outcome from the bank?")),
@ -94,7 +91,7 @@ define([
alignments.push([id, pct]);
}
});
questionBankPage.updateAlignments(alignments);
updateAlignments(alignments);
}
});
@ -312,10 +309,3 @@ define([
$("#move_question_dialog .new_question_bank_name").showIf($(this).attr('checked') && $(this).val() == 'new');
});
}
};
questionBankPage.attachPageEvents = questionBankPage._attachPageEvents.bind(questionBankPage);
return questionBankPage;
});

View File

@ -16,38 +16,33 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([], function(){
function QuizFormulaSolution(result){
this.result = result;
export default class QuizFormulaSolution {
constructor (result) {
this.result = result
}
QuizFormulaSolution.prototype.rawValue = function(){
return parseFloat(this.rawText(), 10);
};
rawValue () {
return parseFloat(this.rawText(), 10)
}
QuizFormulaSolution.prototype.rawText = function(){
if(this.result === null || this.result === undefined){
return "NaN";
rawText () {
if (this.result === null || this.result === undefined) {
return 'NaN'
}
return this.result.substring(1).trim();
};
return this.result.substring(1).trim()
}
QuizFormulaSolution.prototype.isValid = function(){
isValid () {
return !!(this._wellFormedString() && this._appropriateSolutionValue())
};
}
//private
QuizFormulaSolution.prototype._wellFormedString = function(){
var result = this.result;
return !!(result.match(/^=/) && result != "= NaN" && result != "= Infinity")
};
_wellFormedString () {
const result = this.result
return !!(result.match(/^=/) && result != '= NaN' && result != '= Infinity')
}
QuizFormulaSolution.prototype._appropriateSolutionValue = function(){
var rawVal = this.rawValue();
return !!(rawVal == 0 || rawVal);
};
return QuizFormulaSolution;
})
_appropriateSolutionValue () {
const rawVal = this.rawValue()
return !!(rawVal == 0 || rawVal)
}
}

View File

@ -16,7 +16,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define(['jquery'], function($) {
import $ from 'jquery'
var inputMethods = {
disableInputs: function(inputs) {
var $body = $('body'),
@ -49,5 +49,4 @@ define(['jquery'], function($) {
}
};
return inputMethods;
});
export default inputMethods;

View File

@ -16,29 +16,24 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
'i18n!quizzes.timing',
'jquery' /* $ */
], function(I18n, $) {
import I18n from 'i18n!quizzes.timing'
import $ from 'jquery'
function addAriaDescription($answer, id) {
var text = I18n.t("Answer %{answerId}", {answerId: id})
var labelId = "answer" + id
export default function addAriaDescription ($answer, id) {
const text = I18n.t('Answer %{answerId}', {answerId: id})
const labelId = `answer${id}`
var $label = $("<label/>", {
id: labelId,
"class": "screenreader-only",
text: text
})
const $label = $('<label/>', {
id: labelId,
class: 'screenreader-only',
text
})
$answer.find('input:text').attr('aria-describedby', labelId)
$answer.find('.deleteAnswerId').text(text)
$answer.find('.editAnswerId').text(text)
$answer.find('.commentAnswerId').text(text)
$answer.find('.selectAsCorrectAnswerId').text(text)
$answer.find('input:text').attr('aria-describedby', labelId)
$answer.find('.deleteAnswerId').text(text)
$answer.find('.editAnswerId').text(text)
$answer.find('.commentAnswerId').text(text)
$answer.find('.selectAsCorrectAnswerId').text(text)
$answer.prepend($label)
}
return addAriaDescription;
});
$answer.prepend($label)
}

View File

@ -16,12 +16,10 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
'i18n!quizzes.rubric',
'jquery' /* $ */,
'jqueryui/dialog',
'rubricEditBinding' // event handler for rubricEditDataReady
], function(I18n, $) {
import I18n from 'i18n!quizzes.rubric'
import $ from 'jquery'
import 'jqueryui/dialog'
import 'rubricEditBinding' // event handler for rubricEditDataReady
var quizRubric = {
ready: function() {
@ -76,6 +74,4 @@ define([
});
});
return quizRubric;
});
export default quizRubric;

View File

@ -16,11 +16,9 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
'i18n!quizzes.timing',
'jquery' /* $ */,
'vendor/date' /* Date.parse */
], function(I18n, $) {
import I18n from 'i18n!quizzes.timing'
import $ from 'jquery'
import './vendor/date' /* Date.parse */
var timing = {
initialTime: new Date(),
@ -47,5 +45,4 @@ var timing = {
}
};
return timing;
});
export default timing;

View File

@ -19,60 +19,52 @@
// xsslint jqueryObject.function makeFormAnswer makeDisplayAnswer
// xsslint jqueryObject.property sortable placeholder
// xsslint safeString.property question_text
define([
'jst/quiz/regrade',
'i18n!quizzes',
'underscore',
'jquery' /* $ */,
'calcCmd',
'str/htmlEscape',
'str/pluralize',
'compiled/handlebars_helpers',
'compiled/views/assignments/DueDateOverride',
'compiled/models/Quiz',
'compiled/models/DueDateList',
'compiled/views/quizzes/QuizRegradeView',
'compiled/collections/SectionCollection',
'compiled/views/calendar/MissingDateDialogView',
'compiled/editor/MultipleChoiceToggle',
'compiled/editor/EditorToggle',
'compiled/str/TextHelper',
'compiled/views/editor/KeyboardShortcuts',
'INST', // safari sniffing for VO workarounds
'quiz_formula_solution',
'quiz_labels',
'jsx/shared/rce/RichContentEditor',
'jsx/shared/conditional_release/ConditionalRelease',
'compiled/util/deparam',
'compiled/util/SisValidationHelper',
'jsx/blueprint_courses/apps/LockManager',
'jquery.ajaxJSON' /* ajaxJSON */,
'jquery.instructure_date_and_time' /* time_field, datetime_field */,
'jquery.instructure_forms' /* formSubmit, fillFormData, getFormData, formErrors, errorBox */,
'jqueryui/dialog',
'jquery.instructure_misc_helpers' /* replaceTags, /\$\.underscore/ */,
'jquery.instructure_misc_plugins' /* .dim, confirmDelete, showIf */,
'jquery.keycodes' /* keycodes */,
'jquery.loadingImg' /* loadingImage */,
'compiled/jquery.rails_flash_notifications',
'jquery.templateData' /* fillTemplateData, getTemplateData */,
'supercalc' /* superCalc */,
'vendor/jquery.scrollTo' /* /\.scrollTo/ */,
'jqueryui/sortable' /* /\.sortable/ */,
'jqueryui/tabs' /* /\.tabs/ */
], function (regradeTemplate, I18n, _, $, calcCmd, htmlEscape, pluralize,
Handlebars, DueDateOverrideView, Quiz,
DueDateList, QuizRegradeView, SectionList,
MissingDateDialog,MultipleChoiceToggle,EditorToggle,TextHelper,
RCEKeyboardShortcuts, INST, QuizFormulaSolution, addAriaDescription,
RichContentEditor, ConditionalRelease, deparam, SisValidationHelper, LockManager) {
var lockManager = new LockManager()
lockManager.init({ itemType: 'quiz', page: 'edit' })
import regradeTemplate from 'jst/quiz/regrade'
import I18n from 'i18n!quizzes'
import _ from 'underscore'
import $ from 'jquery'
import calcCmd from './calcCmd'
import htmlEscape from './str/htmlEscape'
import pluralize from './str/pluralize'
import Handlebars from 'compiled/handlebars_helpers'
import DueDateOverrideView from 'compiled/views/assignments/DueDateOverride'
import Quiz from 'compiled/models/Quiz'
import DueDateList from 'compiled/models/DueDateList'
import QuizRegradeView from 'compiled/views/quizzes/QuizRegradeView'
import SectionList from 'compiled/collections/SectionCollection'
import MissingDateDialog from 'compiled/views/calendar/MissingDateDialogView'
import MultipleChoiceToggle from 'compiled/editor/MultipleChoiceToggle'
import EditorToggle from 'compiled/editor/EditorToggle'
import TextHelper from 'compiled/str/TextHelper'
import RCEKeyboardShortcuts from 'compiled/views/editor/KeyboardShortcuts'
import INST from './INST' // safari sniffing for VO workarounds
import QuizFormulaSolution from './quiz_formula_solution'
import addAriaDescription from './quiz_labels'
import RichContentEditor from 'jsx/shared/rce/RichContentEditor'
import ConditionalRelease from 'jsx/shared/conditional_release/ConditionalRelease'
import deparam from 'compiled/util/deparam'
import SisValidationHelper from 'compiled/util/SisValidationHelper'
import LockManager from 'jsx/blueprint_courses/apps/LockManager'
import './jquery.ajaxJSON'
import './jquery.instructure_date_and_time' /* time_field, datetime_field */
import './jquery.instructure_forms' /* formSubmit, fillFormData, getFormData, formErrors, errorBox */
import 'jqueryui/dialog'
import './jquery.instructure_misc_helpers' /* replaceTags, /\$\.underscore/ */
import './jquery.instructure_misc_plugins' /* .dim, confirmDelete, showIf */
import './jquery.keycodes'
import './jquery.loadingImg'
import 'compiled/jquery.rails_flash_notifications'
import './jquery.templateData'
import './supercalc'
import './vendor/jquery.scrollTo'
import 'jqueryui/sortable'
import 'jqueryui/tabs'
var dueDateList, overrideView, quizModel, sectionList, correctAnswerVisibility,
scoreValidation;
var dueDateList, overrideView, quizModel, sectionList, correctAnswerVisibility, scoreValidation;
const lockedItems = lockManager.isChildContent() ? lockManager.getItemLocks() : {}
var lockManager = new LockManager()
lockManager.init({ itemType: 'quiz', page: 'edit' })
const lockedItems = lockManager.isChildContent() ? lockManager.getItemLocks() : {}
RichContentEditor.preloadRemoteModule();
@ -171,7 +163,7 @@ define([
}
}
function isChangeMultiFuncBound ($questionContent) {
export function isChangeMultiFuncBound ($questionContent) {
var ret = false;
var events = $._data($questionContent[0], 'events');
if (events && events.change) {
@ -230,8 +222,7 @@ define([
// TODO: refactor this... it's not going to be horrible, but it will
// take a little bit of work. I just wrapped it in a closure for now
// to not pollute the global namespace, but it could use more.
var quiz = window.quiz = {};
quiz = {
export const quiz = window.quiz = {
uniqueLocalIDStore: {},
// Should cache any elements used throughout the object here
@ -4292,8 +4283,3 @@ define([
}).triggerHandler('change');
});
return {
quiz: quiz,
isChangeMultiFuncBound: isChangeMultiFuncBound
}
});

View File

@ -15,20 +15,18 @@
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import I18n from 'i18n!rubric_assessment'
import $ from 'jquery'
import htmlEscape from './str/htmlEscape'
import TextHelper from 'compiled/str/TextHelper'
import round from 'compiled/util/round'
import numberHelper from 'jsx/shared/helpers/numberHelper'
import './jquery.instructure_forms' /* fillFormData */
import 'jqueryui/dialog'
import './jquery.instructure_misc_plugins' /* showIf */
import './jquery.templateData'
import './vendor/jquery.scrollTo'
define([
'i18n!rubric_assessment',
'jquery' /* $ */,
'str/htmlEscape',
'compiled/str/TextHelper',
'compiled/util/round',
'jsx/shared/helpers/numberHelper',
'jquery.instructure_forms' /* fillFormData */,
'jqueryui/dialog',
'jquery.instructure_misc_plugins' /* showIf */,
'jquery.templateData' /* fillTemplateData, getTemplateData */,
'vendor/jquery.scrollTo' /* /\.scrollTo/ */
], function (I18n, $, htmlEscape, TextHelper, round, numberHelper) {
// TODO: stop managing this in the view and get it out of the global scope submissions/show.html.erb
/*global rubricAssessment*/
window.rubricAssessment = {
@ -352,5 +350,4 @@ function ratingHasScore(rating) {
$(rubricAssessment.init);
return rubricAssessment;
});
export default rubricAssessment;

View File

@ -16,25 +16,23 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
'INST' /* INST */,
'i18n!select_content_dialog',
'jquery' /* $ */,
'react',
'react-dom',
'jsx/context_modules/FileSelectBox',
'underscore',
'jquery.instructure_date_and_time' /* datetime_field */,
'jquery.ajaxJSON' /* ajaxJSON */,
'jquery.instructure_forms' /* formSubmit, ajaxJSONFiles, getFormData, errorBox */,
'jqueryui/dialog',
'compiled/jquery/fixDialogButtons' /* fix dialog formatting */,
'jquery.instructure_misc_helpers' /* replaceTags, getUserServices, findLinkForService */,
'jquery.instructure_misc_plugins' /* showIf */,
'jquery.keycodes' /* keycodes */,
'jquery.loadingImg' /* loadingImage */,
'jquery.templateData' /* fillTemplateData */
], function(INST, I18n, $, React, ReactDOM, FileSelectBox, _) {
import INST from './INST'
import I18n from 'i18n!select_content_dialog'
import $ from 'jquery'
import React from 'react'
import ReactDOM from 'react-dom'
import FileSelectBox from 'jsx/context_modules/FileSelectBox'
import _ from 'underscore'
import './jquery.instructure_date_and_time' /* datetime_field */
import './jquery.ajaxJSON'
import './jquery.instructure_forms' /* formSubmit, ajaxJSONFiles, getFormData, errorBox */
import 'jqueryui/dialog'
import 'compiled/jquery/fixDialogButtons'
import './jquery.instructure_misc_helpers' /* replaceTags, getUserServices, findLinkForService */
import './jquery.instructure_misc_plugins' /* showIf */
import './jquery.keycodes'
import './jquery.loadingImg'
import './jquery.templateData'
var SelectContentDialog = {};
@ -170,7 +168,6 @@ define([
$(document).ready(function() {
var external_services = null;
var $dialog = $("#select_context_content_dialog");
INST = INST || {};
INST.selectContentDialog = function(options) {
var options = options || {};
var for_modules = options.for_modules;
@ -440,5 +437,4 @@ define([
});
});
return SelectContentDialog;
});
export default SelectContentDialog;

View File

@ -16,12 +16,11 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
'jquery',
'compiled/editor/editorAccessibility',
'INST'
], function($, EditorAccessibility, INST){
return function (tinymce, autoFocus, enableBookmarkingOverride) {
import $ from 'jquery'
import EditorAccessibility from 'compiled/editor/editorAccessibility'
import INST from './INST'
export default function setupAndFocusTinyMCEConfig (tinymce, autoFocus, enableBookmarkingOverride) {
if (enableBookmarkingOverride == undefined) {
var enableBookmarking = !!INST.browser.ie;
@ -102,4 +101,3 @@ define([
} // function setup()
}
};
});

View File

@ -16,7 +16,9 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define(['jquery', 'i18n!LongTextEditor', 'str/htmlEscape'], function($, I18n, htmlEscape) {
import $ from 'jquery'
import I18n from 'i18n!LongTextEditor'
import htmlEscape from './str/htmlEscape'
/*
* this is just LongTextEditor from slick.editors.js but with i18n and a
@ -122,5 +124,4 @@ define(['jquery', 'i18n!LongTextEditor', 'str/htmlEscape'], function($, I18n, ht
this.init();
}
return LongTextEditor;
});
export default LongTextEditor;

View File

@ -17,54 +17,49 @@
*/
/*global jsonData*/
define([
'jsx/speed_grader/gradingPeriod',
'jsx/grading/helpers/OutlierScoreHelper',
'jsx/grading/quizzesNextSpeedGrading',
'jsx/shared/helpers/numberHelper',
'jsx/gradebook/shared/helpers/GradeFormatHelper',
'jst/speed_grader/student_viewed_at',
'jst/speed_grader/submissions_dropdown',
'jst/speed_grader/speech_recognition',
'compiled/util/round',
'underscore',
'INST' /* INST */,
'i18n!gradebook',
'compiled/util/natcompare',
'jquery' /* $ */,
'timezone',
'compiled/userSettings',
'str/htmlEscape',
'rubric_assessment',
'speed_grader_select_menu',
'speed_grader_helpers',
'jst/_turnitinInfo',
'jst/_turnitinScore',
'jst/_vericiteInfo',
'jst/_vericiteScore',
'jqueryui/draggable' /* /\.draggable/ */,
'jquery.ajaxJSON' /* getJSON, ajaxJSON */,
'jquery.instructure_forms' /* ajaxJSONFiles */,
'jquery.doc_previews' /* loadDocPreview */,
'jquery.instructure_date_and_time' /* datetimeString */,
'jqueryui/dialog',
'jquery.instructure_misc_helpers' /* replaceTags */,
'jquery.instructure_misc_plugins' /* confirmDelete, showIf, hasScrollbar */,
'jquery.keycodes' /* keycodes */,
'jquery.loadingImg' /* loadingImg, loadingImage */,
'jquery.templateData' /* fillTemplateData, getTemplateData */,
'media_comments' /* mediaComment */,
'compiled/jquery/mediaCommentThumbnail',
'compiled/jquery.rails_flash_notifications',
'jquery.elastic' /* elastic */,
'jquery-getscrollbarwidth',
'vendor/jquery.scrollTo' /* /\.scrollTo/ */,
'vendor/ui.selectmenu' /* /\.selectmenu/ */
], function (MGP, OutlierScoreHelper, quizzesNextSpeedGrading, numberHelper,
GradeFormatHelper, studentViewedAtTemplate, submissionsDropdownTemplate,
speechRecognitionTemplate, round, _, INST, I18n, natcompare, $, tz, userSettings, htmlEscape,
rubricAssessment, SpeedgraderSelectMenu, SpeedgraderHelpers, turnitinInfoTemplate,
turnitinScoreTemplate, vericiteInfoTemplate, vericiteScoreTemplate) {
import MGP from 'jsx/speed_grader/gradingPeriod'
import OutlierScoreHelper from 'jsx/grading/helpers/OutlierScoreHelper'
import quizzesNextSpeedGrading from 'jsx/grading/quizzesNextSpeedGrading'
import numberHelper from 'jsx/shared/helpers/numberHelper'
import GradeFormatHelper from 'jsx/gradebook/shared/helpers/GradeFormatHelper'
import studentViewedAtTemplate from 'jst/speed_grader/student_viewed_at'
import submissionsDropdownTemplate from 'jst/speed_grader/submissions_dropdown'
import speechRecognitionTemplate from 'jst/speed_grader/speech_recognition'
import round from 'compiled/util/round'
import _ from 'underscore'
import INST from './INST'
import I18n from 'i18n!gradebook'
import natcompare from 'compiled/util/natcompare'
import $ from 'jquery'
import tz from 'timezone'
import userSettings from 'compiled/userSettings'
import htmlEscape from './str/htmlEscape'
import rubricAssessment from './rubric_assessment'
import SpeedgraderSelectMenu from './speed_grader_select_menu'
import SpeedgraderHelpers from './speed_grader_helpers'
import turnitinInfoTemplate from 'jst/_turnitinInfo'
import turnitinScoreTemplate from 'jst/_turnitinScore'
import vericiteInfoTemplate from 'jst/_vericiteInfo'
import vericiteScoreTemplate from 'jst/_vericiteScore'
import 'jqueryui/draggable'
import './jquery.ajaxJSON' /* getJSON, ajaxJSON */
import './jquery.instructure_forms' /* ajaxJSONFiles */
import './jquery.doc_previews' /* loadDocPreview */
import './jquery.instructure_date_and_time' /* datetimeString */
import 'jqueryui/dialog'
import './jquery.instructure_misc_helpers' /* replaceTags */
import './jquery.instructure_misc_plugins' /* confirmDelete, showIf, hasScrollbar */
import './jquery.keycodes'
import './jquery.loadingImg'
import './jquery.templateData'
import './media_comments'
import 'compiled/jquery/mediaCommentThumbnail'
import 'compiled/jquery.rails_flash_notifications'
import 'jquery.elastic'
import 'jquery-getscrollbarwidth'
import './vendor/jquery.scrollTo'
import './vendor/ui.selectmenu'
// PRIVATE VARIABLES AND FUNCTIONS
// all of the $ variables here are to speed up access to dom nodes,
// so that the jquery selector does not have to be run every time.
@ -2617,7 +2612,7 @@ define([
EG.jsonReady();
}
return {
export default {
setup: function() {
function registerQuizzesNext (overriddenShowSubmission) {
showSubmissionOverride = overriddenShowSubmission;
@ -2637,4 +2632,3 @@ define([
},
EG: EG
};
});

View File

@ -16,12 +16,10 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
'jquery',
'underscore',
'i18n!gradebook',
'jquery.instructure_date_and_time'
], function($, _, I18n) {
import $ from 'jquery'
import _ from 'underscore'
import I18n from 'i18n!gradebook'
import './jquery.instructure_date_and_time'
var speedgraderHelpers = {
urlContainer: function(submission, defaultEl, originalityReportEl) {
if (submission.has_originality_report) {
@ -135,5 +133,4 @@ define([
}
return speedgraderHelpers;
});
export default speedgraderHelpers;

View File

@ -16,13 +16,11 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
'jquery', /* $ */
'str/htmlEscape',
'vendor/ui.selectmenu' /* /\.selectmenu/ */
], function($, htmlEscape) {
import $ from 'jquery'
import htmlEscape from './str/htmlEscape'
import 'vendor/ui.selectmenu'
var speedgraderSelectMenu = function(optionsHtml, delimiter){
export default function speedgraderSelectMenu (optionsHtml, delimiter){
this.html = "<select id='students_selectmenu'>" + optionsHtml + "</select>";
this.option_index = 0;
@ -146,5 +144,3 @@ define([
};
};
return speedgraderSelectMenu;
});

View File

@ -16,9 +16,6 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define(function() {
return function(string) {
return string.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
}
});
export default function escapeRegex(string) {
return string.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
}

View File

@ -16,58 +16,54 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define(['INST'], function(INST) {
function SafeString(string) {
this.string = (typeof string === 'string' ? string : "" + string);
import INST from '../INST'
class SafeString {
constructor (string) {
this.string = (typeof string === 'string' ? string : `${string}`)
}
SafeString.prototype.toString = function() {
return this.string;
};
toString () {
return this.string
}
}
var ENTITIES = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#x27;',
'/': '&#x2F;',
'`': '&#x60;', // for old versions of IE
'=': '&#x3D;' // in case of unquoted attributes
};
const ENTITIES = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#x27;',
'/': '&#x2F;',
'`': '&#x60;', // for old versions of IE
'=': '&#x3D;' // in case of unquoted attributes
}
var htmlEscape = function(str) {
// ideally we should wrap this in a SafeString, but this is how it has
// always worked :-/
return str.replace(/[&<>"'\/`=]/g, function(c) {
return ENTITIES[c];
});
function htmlEscape (str) {
// ideally we should wrap this in a SafeString, but this is how it has
// always worked :-/
return str.replace(/[&<>"'\/`=]/g, c => ENTITIES[c])
}
// Escapes HTML tags from string, or object string props of `strOrObject`.
// returns the new string, or the object with escaped properties
export default function escape (strOrObject) {
if (typeof strOrObject === 'string') {
return htmlEscape(strOrObject)
} else if (strOrObject instanceof SafeString) {
return strOrObject
} else if (typeof strOrObject === 'number') {
return escape(strOrObject.toString())
}
// Escapes HTML tags from string, or object string props of `strOrObject`.
// returns the new string, or the object with escaped properties
var escape = function(strOrObject) {
if (typeof strOrObject === 'string') {
return htmlEscape(strOrObject);
} else if (strOrObject instanceof SafeString) {
return strOrObject;
} else if (typeof strOrObject === 'number') {
return escape(strOrObject.toString())
for (let k in strOrObject) {
let v = strOrObject[k]
if (typeof v === 'string') {
strOrObject[k] = htmlEscape(v)
}
}
return strOrObject
}
escape.SafeString = SafeString
var k, v;
for (k in strOrObject) {
v = strOrObject[k];
if (typeof v === "string") {
strOrObject[k] = htmlEscape(v);
}
}
return strOrObject;
};
escape.SafeString = SafeString;
// tinymce plugins use this and they need it global :(
INST.htmlEscape = escape;
return escape;
});
// tinymce plugins use this and they need it global :(
INST.htmlEscape = escape

View File

@ -16,22 +16,20 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
'compiled/util/round',
'i18n!submissions',
'jquery',
'jsx/gradebook/shared/helpers/GradeFormatHelper',
'jquery.ajaxJSON' /* ajaxJSON */,
'jquery.instructure_forms' /* ajaxJSONFiles */,
'jquery.instructure_date_and_time' /* datetimeString */,
'jquery.instructure_misc_plugins' /* fragmentChange, showIf */,
'jquery.loadingImg' /* loadingImg, loadingImage */,
'jquery.templateData' /* fillTemplateData, getTemplateData */,
'media_comments' /* mediaComment */,
'compiled/jquery/mediaCommentThumbnail',
'vendor/jquery.scrollTo', /* /\.scrollTo/ */
'rubric_assessment' /*global rubricAssessment*/
], function (round, I18n, $, GradeFormatHelper) {
import round from 'compiled/util/round'
import I18n from 'i18n!submissions'
import $ from 'jquery'
import GradeFormatHelper from 'jsx/gradebook/shared/helpers/GradeFormatHelper'
import './jquery.ajaxJSON'
import './jquery.instructure_forms' /* ajaxJSONFiles */
import './jquery.instructure_date_and_time' /* datetimeString */
import './jquery.instructure_misc_plugins' /* fragmentChange, showIf */
import './jquery.loadingImg'
import './jquery.templateData'
import './media_comments'
import 'compiled/jquery/mediaCommentThumbnail'
import './vendor/jquery.scrollTo'
import './rubric_assessment' /*global rubricAssessment*/
var rubricAssessments = ENV.rubricAssessments;
@ -165,11 +163,11 @@ define([
$("#rubric_holder").css({'maxHeight': height - 50, 'overflow': 'auto', 'zIndex': 5});
$(".comments").height(height);
};
var SubmissionsObj = {};
// This `setup` function allows us to control when the setup is triggered.
// submissions.coffee requires this file and then immediately triggers it,
// while submissionsSpec.jsx triggers it after setup is complete.
SubmissionsObj.setup = function() {
export function setup () {
$(document).ready(function() {
$(".comments .comment_list .play_comment_link").mediaCommentThumbnail('small');
$(window).bind('resize', windowResize).triggerHandler('resize');
@ -365,7 +363,7 @@ define([
});
};
// necessary for tests
SubmissionsObj.teardown = function() {
export function teardown () {
$(window).unbind('resize', windowResize);
$(document).unbind('comment_change');
$(document).unbind('grading_change');
@ -390,6 +388,3 @@ define([
$.ajaxJSON(url, 'GET', {}, submissionLoaded);
}, 500);
};
return SubmissionsObj;
});

View File

@ -16,29 +16,26 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
'i18n!assignments' /* I18n.t */,
'jquery' /* $ */,
'underscore' /* _ */,
'compiled/views/GoogleDocsTreeView',
'jst/assignments/homework_submission_tool',
'compiled/external_tools/HomeworkSubmissionLtiContainer',
'compiled/views/editor/KeyboardShortcuts' /* TinyMCE Keyboard Shortcuts for a11y */,
'jsx/shared/rce/RichContentEditor',
'submit_assignment_helper',
'compiled/jquery.rails_flash_notifications',
'jquery.ajaxJSON' /* ajaxJSON */,
'jquery.inst_tree' /* instTree */,
'jquery.instructure_forms' /* ajaxJSONPreparedFiles, getFormData */,
'jqueryui/dialog',
'jquery.instructure_misc_plugins' /* fragmentChange, showIf, /\.log\(/ */,
'jquery.templateData' /* getTemplateData */,
'media_comments' /* mediaComment */,
'vendor/jquery.scrollTo' /* /\.scrollTo/ */,
'jqueryui/tabs' /* /\.tabs/ */
], function(I18n, $, _, GoogleDocsTreeView, homework_submission_tool,
HomeworkSubmissionLtiContainer, RCEKeyboardShortcuts,
RichContentEditor, SubmitAssignmentHelper) {
import I18n from 'i18n!assignments'
import $ from 'jquery'
import _ from 'underscore'
import GoogleDocsTreeView from 'compiled/views/GoogleDocsTreeView'
import homework_submission_tool from 'jst/assignments/homework_submission_tool'
import HomeworkSubmissionLtiContainer from 'compiled/external_tools/HomeworkSubmissionLtiContainer'
import RCEKeyboardShortcuts from 'compiled/views/editor/KeyboardShortcuts' /* TinyMCE Keyboard Shortcuts for a11y */
import RichContentEditor from 'jsx/shared/rce/RichContentEditor'
import {submitContentItem} from './submit_assignment_helper'
import 'compiled/jquery.rails_flash_notifications'
import './jquery.ajaxJSON'
import './jquery.inst_tree'
import './jquery.instructure_forms' /* ajaxJSONPreparedFiles, getFormData */
import 'jqueryui/dialog'
import './jquery.instructure_misc_plugins' /* fragmentChange, showIf, /\.log\(/ */
import './jquery.templateData'
import './media_comments'
import './vendor/jquery.scrollTo'
import 'jqueryui/tabs'
var SubmitAssignment = {
toolDropDownClickHandler: function(event) {
@ -59,7 +56,7 @@ define([
tabindex: '0'
}).css({width: width, height: height}))
.bind('selection', function(event, data) {
SubmitAssignmentHelper.submitContentItem(event.contentItems[0]);
submitContentItem(event.contentItems[0]);
$div.off('dialogbeforeclose', SubmitAssignment.dialogCancelHandler)
$div.dialog('close');
})
@ -513,5 +510,5 @@ define([
};
$("#submit_from_external_tool_form .tools li").live('click', SubmitAssignment.toolDropDownClickHandler);
return SubmitAssignment;
});
export default SubmitAssignment;

View File

@ -15,13 +15,10 @@
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
'jquery',
'i18n!assignments',
'jquery.instructure_misc_plugins',
'compiled/jquery.rails_flash_notifications'
], function($, I18n) {
import $ from 'jquery'
import I18n from 'i18n!assignments'
import './jquery.instructure_misc_plugins'
import 'compiled/jquery.rails_flash_notifications'
var validFileSubmission = function(ext, contentItem) {
return !ENV.SUBMIT_ASSIGNMENT ||
@ -36,7 +33,7 @@ define([
return false;
};
var submitContentItem = function(contentItem) {
export function submitContentItem (contentItem) {
if (!contentItem) {
return false;
}
@ -74,8 +71,3 @@ define([
return true;
};
return {
'submitContentItem': submitContentItem
};
});

View File

@ -16,11 +16,9 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
'compiled/editor/stocktiny',
'i18n!editor',
'str/htmlEscape'
], function(tinymce, I18n, htmlEscape) {
import tinymce from 'compiled/editor/stocktiny'
import I18n from 'i18n!editor'
import htmlEscape from '../../str/htmlEscape'
tinymce.create('tinymce.plugins.InstructureEquation', {
init : function(ed, url) {
@ -46,4 +44,3 @@ define([
// Register plugin
tinymce.PluginManager.add('instructure_equation', tinymce.plugins.InstructureEquation);
});

View File

@ -16,14 +16,12 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
'i18n!editor',
'jquery',
'str/htmlEscape',
'jquery.dropdownList',
'jquery.instructure_misc_helpers',
'underscore'
], function (I18n, $, htmlEscape) {
import I18n from 'i18n!editor'
import $ from 'jquery'
import htmlEscape from '../../str/htmlEscape'
import '../../jquery.dropdownList'
import '../../jquery.instructure_misc_helpers'
/**
* A module for holding helper functions pulled out of the instructure_external_tools/plugin.
*
@ -35,7 +33,7 @@ define([
* @exports
*/
return {
export default {
/**
* build the TinyMCE configuration hash for each
@ -128,4 +126,3 @@ define([
});
}
};
});

View File

@ -16,17 +16,15 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
'i18n!editor',
'jquery',
'str/htmlEscape',
'tinymce_plugins/instructure_external_tools/TinyMCEContentItem',
'tinymce_plugins/instructure_external_tools/ExternalToolsHelper',
'jsx/shared/rce/RceCommandShim',
'jquery.instructure_misc_helpers',
'jqueryui/dialog',
'jquery.instructure_misc_plugins'
], function (I18n, $, htmlEscape, TinyMCEContentItem, ExternalToolsHelper, RceCommandShim) {
import I18n from 'i18n!editor'
import $ from 'jquery'
import htmlEscape from '../../str/htmlEscape'
import TinyMCEContentItem from 'tinymce_plugins/instructure_external_tools/TinyMCEContentItem'
import ExternalToolsHelper from 'tinymce_plugins/instructure_external_tools/ExternalToolsHelper'
import {send} from 'jsx/shared/rce/RceCommandShim'
import '../../jquery.instructure_misc_helpers'
import 'jqueryui/dialog'
import '../../jquery.instructure_misc_plugins'
var TRANSLATIONS = {
embed_from_external_tool: I18n.t('embed_from_external_tool', '"Embed content from External Tool"'),
@ -141,7 +139,7 @@ define([
for(var i = 0; i < itemLength; i++){
codePayload = TinyMCEContentItem.fromJSON(contentItems[i]).codePayload;
RceCommandShim.send($("#" + editor.id), 'insert_code', codePayload)
send($("#" + editor.id), 'insert_code', codePayload)
}
$dialog.find('iframe').attr('src', 'about:blank');
$dialog.off("dialogbeforeclose", ExternalToolsPlugin.dialogCancelHandler);
@ -180,5 +178,4 @@ define([
return ExternalToolsPlugin
});
export default ExternalToolsPlugin

View File

@ -16,12 +16,10 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
'compiled/editor/stocktiny',
'tinymce_plugins/instructure_external_tools/initializeExternalTools',
'tinymce_plugins/instructure_external_tools/ExternalToolsHelper',
'INST'
], function(tinymce, initializeExternalTools, ExternalToolsHelper, INST) {
import tinymce from 'compiled/editor/stocktiny'
import initializeExternalTools from './initializeExternalTools'
import ExternalToolsHelper from './ExternalToolsHelper'
import INST from '../../INST'
tinymce.create('tinymce.plugins.InstructureExternalTools', {
init : function(ed, url){
@ -41,5 +39,4 @@ define([
// Register plugin
tinymce.PluginManager.add('instructure_external_tools', tinymce.plugins.InstructureExternalTools);
return tinymce;
});
export default tinymce;

View File

@ -16,13 +16,11 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
'compiled/editor/stocktiny',
'i18n!editor',
'jquery',
'str/htmlEscape',
'jqueryui/dialog'
], function(tinymce, I18n, $, htmlEscape) {
import tinymce from 'compiled/editor/stocktiny'
import I18n from 'i18n!editor'
import $ from 'jquery'
import htmlEscape from '../../str/htmlEscape'
import 'jqueryui/dialog'
tinymce.create('tinymce.plugins.InstructureImagePlugin', {
init : function(ed, url) {
@ -68,4 +66,3 @@ define([
// Register plugin
tinymce.PluginManager.add('instructure_image', tinymce.plugins.InstructureImagePlugin);
});

View File

@ -16,7 +16,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define(["jquery", 'jsx/shared/rce/RceCommandShim'], function($, RceCommandShim){
import $ from "jquery"
import {send} from 'jsx/shared/rce/RceCommandShim'
/**
* This is not yet a complete extraction, but the idea is to continue
@ -69,7 +70,7 @@ define(["jquery", 'jsx/shared/rce/RceCommandShim'], function($, RceCommandShim){
* @param {Object} [dataAttrs] key value pairs for link data attributes
*/
this.createLink = function(text, classes, dataAttrs){
RceCommandShim.send(this.getEditor(), "create_link",{
send(this.getEditor(), "create_link",{
url: text,
classes: classes,
selectedContent: this.selectedContent,
@ -78,5 +79,4 @@ define(["jquery", 'jsx/shared/rce/RceCommandShim'], function($, RceCommandShim){
};
};
return LinkableEditor;
});
export default LinkableEditor;

View File

@ -16,15 +16,15 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
'jquery',
'str/htmlEscape',
'tinymce_plugins/instructure_links/linkable_editor',
'jsx/shared/rce/RceCommandShim',
'jquery.instructure_misc_helpers',
'jqueryui/dialog',
'jquery.instructure_misc_plugins'
], function ($, htmlEscape, LinkableEditor, RceCommandShim) {
import $ from 'jquery'
import htmlEscape from '../../str/htmlEscape'
import LinkableEditor from './linkable_editor'
import {send} from 'jsx/shared/rce/RceCommandShim'
import '../../jquery.instructure_misc_helpers'
import 'jqueryui/dialog'
import '../../jquery.instructure_misc_plugins'
// TODO: Allow disabling of inline media as well. Right now
// the link is just '#' so disabling it actually ruins it. It'd
// be nice if the link were a URL to download the media file.
@ -167,7 +167,7 @@ define([
$("#instructure_link_prompt").dialog('close');
$.findLinkForService($(this).data('service').service, function(data) {
$("#instructure_link_prompt").dialog('close');
RceCommandShim.send($editor, 'create_link', {
send($editor, 'create_link', {
title: data.title,
url: data.url,
classes: priorClasses
@ -436,7 +436,7 @@ define([
initializedEditors.set(ed, true)
}
return {
export default {
buttonToImg: buttonToImg,
prepEditorForDialog: prepEditorForDialog,
buildLinkClasses: buildLinkClasses,
@ -444,5 +444,4 @@ define([
renderDialog: renderDialog,
updateLinks: updateLinks,
initEditor: initEditor
};
})
}

View File

@ -16,18 +16,16 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
'jquery',
'str/htmlEscape',
'jsx/shared/rce/RceCommandShim',
'media_comments'
], function($, htmlEscape, RceCommandShim) {
import $ from 'jquery'
import htmlEscape from '../../str/htmlEscape'
import {send} from 'jsx/shared/rce/RceCommandShim'
import '../../media_comments'
var mediaEditorLoader = {
insertCode: function(ed, mediaCommentId, mediaType){
var $editor = $("#" + ed.id);
var linkCode = this.makeLinkHtml(mediaCommentId, mediaType)
RceCommandShim.send($editor, 'insert_code', linkCode);
send($editor, 'insert_code', linkCode);
},
makeLinkHtml: function(mediaCommentId, mediaType) {
@ -60,5 +58,4 @@ define([
}
}
return mediaEditorLoader;
});
export default mediaEditorLoader;

View File

@ -17,7 +17,7 @@
*/
import $ from 'jquery'
import userUtils from 'user_utils'
import {firstNameFirst, lastNameFirst, nameParts} from './user_utils'
$(function () {
var $short_name = $('input[name="user[short_name]"]')
@ -29,10 +29,10 @@ $(function () {
$name.keyup(function() {
var name = $name.attr('value');
var sortable_name = $sortable_name.attr('value');
var sortable_name_parts = userUtils.nameParts(sortable_name);
if (jQuery.trim(sortable_name) === '' || userUtils.firstNameFirst(sortable_name_parts) === jQuery.trim(prior_name)) {
var parts = userUtils.nameParts(name, sortable_name_parts[1]);
$sortable_name.attr('value', userUtils.lastNameFirst(parts));
var sortable_name_parts = nameParts(sortable_name);
if (jQuery.trim(sortable_name) === '' || firstNameFirst(sortable_name_parts) === $.trim(prior_name)) {
var parts = nameParts(name, sortable_name_parts[1]);
$sortable_name.attr('value', lastNameFirst(parts));
}
var short_name = $short_name.attr('value');
if (jQuery.trim(short_name) === '' || short_name === prior_name) {

View File

@ -16,75 +16,76 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define(['jquery'], function($) {
import $ from 'jquery'
// see also User.name_parts in user.rb
return {
nameParts: function(name, prior_surname) {
var SUFFIXES = /^(Sn?r\.?|Senior|Jn?r\.?|Junior|II|III|IV|V|VI|Esq\.?|Esquire)$/i
var surname, given, suffix, given_parts, prior_surname_parts, name_parts;
if (!name || $.trim(name) === '') {
return [null, null, null];
}
name_parts = $.map(name.split(','), function(str) {
return $.trim(str);
});
surname = name_parts[0];
given = name_parts[1];
suffix = name_parts.slice(2).join(', ');
if (suffix === '') {
suffix = null;
}
if (suffix && !SUFFIXES.test(suffix)) {
given = given + ' ' + suffix;
suffix = null;
}
if (typeof given === 'string') {
// John Doe, Sr.
if (!suffix && SUFFIXES.test(given)) {
suffix = given;
given = surname;
surname = null;
}
} else {
// John Doe
given = $.trim(name);
surname = null;
}
given_parts = given.split(/\s+/)
if (given_parts.length === 1 && given_parts[0] === '') {
given_parts = [];
}
// John Doe Sr.
if (!suffix && given_parts.length > 1 && SUFFIXES.test(given_parts[given_parts.length - 1])) {
suffix = given_parts.pop();
}
// Use prior information on the last name to try and reconstruct it
// This just checks if prior_surname was provided, and if it matches
// the trailing words of given_parts
if (!surname && prior_surname && !(/^\s*$/).test(prior_surname) &&
(prior_surname_parts = prior_surname.split(/\s+/)) &&
given_parts.length >= prior_surname_parts.length &&
given_parts.slice(given_parts.length - prior_surname_parts.length).join(' ') === prior_surname_parts.join(' ')) {
surname = given_parts.splice(given_parts.length - prior_surname_parts.length, prior_surname_parts.length).join(' ')
}
// Last resort; last name is just the last word given
if (!surname && given_parts.length > 1) {
surname = given_parts.pop();
}
return [ given_parts.length === 0 ? null : given_parts.join(' '), surname, suffix ];
},
lastNameFirst: function(parts) {
var given = $.trim([parts[0], parts[2]].join(' '));
return $.trim((parts[1] ? parts[1] + ', ' + given : given));
},
firstNameFirst: function(parts) {
return $.trim(parts.join(' ').replace(/\s+/, ' '));
export function nameParts (name, prior_surname) {
const SUFFIXES = /^(Sn?r\.?|Senior|Jn?r\.?|Junior|II|III|IV|V|VI|Esq\.?|Esquire)$/i
let surname,
given,
suffix,
given_parts,
prior_surname_parts,
name_parts
if (!name || $.trim(name) === '') {
return [null, null, null]
}
name_parts = $.map(name.split(','), str => $.trim(str))
surname = name_parts[0]
given = name_parts[1]
suffix = name_parts.slice(2).join(', ')
if (suffix === '') {
suffix = null
}
};
});
if (suffix && !SUFFIXES.test(suffix)) {
given = `${given} ${suffix}`
suffix = null
}
if (typeof given === 'string') {
// John Doe, Sr.
if (!suffix && SUFFIXES.test(given)) {
suffix = given
given = surname
surname = null
}
} else {
// John Doe
given = $.trim(name)
surname = null
}
given_parts = given.split(/\s+/)
if (given_parts.length === 1 && given_parts[0] === '') {
given_parts = []
}
// John Doe Sr.
if (!suffix && given_parts.length > 1 && SUFFIXES.test(given_parts[given_parts.length - 1])) {
suffix = given_parts.pop()
}
// Use prior information on the last name to try and reconstruct it
// This just checks if prior_surname was provided, and if it matches
// the trailing words of given_parts
if (!surname && prior_surname && !(/^\s*$/).test(prior_surname) &&
(prior_surname_parts = prior_surname.split(/\s+/)) &&
given_parts.length >= prior_surname_parts.length &&
given_parts.slice(given_parts.length - prior_surname_parts.length).join(' ') === prior_surname_parts.join(' ')) {
surname = given_parts.splice(given_parts.length - prior_surname_parts.length, prior_surname_parts.length).join(' ')
}
// Last resort; last name is just the last word given
if (!surname && given_parts.length > 1) {
surname = given_parts.pop()
}
return [given_parts.length === 0 ? null : given_parts.join(' '), surname, suffix]
}
export function lastNameFirst (parts) {
const given = $.trim([parts[0], parts[2]].join(' '))
return $.trim((parts[1] ? `${parts[1]}, ${given}` : given))
}
export function firstNameFirst (parts) {
return $.trim(parts.join(' ').replace(/\s+/, ' '))
}

View File

@ -16,24 +16,22 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
'i18n!wiki.sidebar',
'jquery' /* $ */,
'str/htmlEscape',
'compiled/util/UsageRights' /* Usage Rights for File Uploading */,
'jquery.ajaxJSON' /* ajaxJSON */,
'jquery.inst_tree' /* instTree */,
'jquery.instructure_forms' /* formSubmit, handlesHTML5Files, ajaxFileUpload, fileData */,
'jqueryui/dialog',
'jquery.instructure_misc_helpers' /* replaceTags */,
'jquery.instructure_misc_plugins' /* /\.log\(/ */,
'compiled/jquery.rails_flash_notifications',
'jquery.templateData' /* fillTemplateData */,
// 'tinymce.editor_box', // required, but not loaded here so that all of tinymce doesn't end up in the common bundle
'vendor/jquery.pageless' /* pageless */,
'jqueryui/accordion' /* /\.accordion\(/ */,
'jqueryui/tabs' /* /\.tabs/ */
], function(I18n, $, htmlEscape, UsageRights) {
import I18n from 'i18n!wiki.sidebar'
import $ from 'jquery'
import htmlEscape from './str/htmlEscape'
import UsageRights from 'compiled/util/UsageRights'
import './jquery.ajaxJSON'
import './jquery.inst_tree'
import './jquery.instructure_forms' /* formSubmit, handlesHTML5Files, ajaxFileUpload, fileData */
import 'jqueryui/dialog'
import './jquery.instructure_misc_helpers' /* replaceTags */
import './jquery.instructure_misc_plugins' /* /\.log\(/ */
import 'compiled/jquery.rails_flash_notifications'
import './jquery.templateData' /* fillTemplateData */
// 'tinymce.editor_box', // required, but not loaded here so that all of tinymce doesn't end up in the common bundle
import 'vendor/jquery.pageless'
import 'jqueryui/accordion'
import 'jqueryui/tabs'
var $editor_tabs,
$tree1,
@ -658,6 +656,4 @@ define([
}
};
return wikiSidebar;
});
export default wikiSidebar;

View File

@ -15,30 +15,30 @@
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
define [ 'user_utils' ], (userUtils) ->
import {nameParts} from 'user_utils'
QUnit.module "UserNameParts"
test "should infer name parts", ->
deepEqual userUtils.nameParts("Cody Cutrer"), [ "Cody", "Cutrer", null ]
deepEqual userUtils.nameParts(" Cody Cutrer "), [ "Cody", "Cutrer", null ]
deepEqual userUtils.nameParts("Cutrer, Cody"), [ "Cody", "Cutrer", null ]
deepEqual userUtils.nameParts("Cutrer, Cody Houston"), [ "Cody Houston", "Cutrer", null ]
deepEqual userUtils.nameParts("St. Clair, John"), [ "John", "St. Clair", null ]
deepEqual userUtils.nameParts("John St. Clair"), [ "John St.", "Clair", null ]
deepEqual userUtils.nameParts("Jefferson Thomas Cutrer, IV"), [ "Jefferson Thomas", "Cutrer", "IV" ]
deepEqual userUtils.nameParts("Jefferson Thomas Cutrer IV"), [ "Jefferson Thomas", "Cutrer", "IV" ]
deepEqual userUtils.nameParts(null), [ null, null, null ]
deepEqual userUtils.nameParts("Bob"), [ "Bob", null, null ]
deepEqual userUtils.nameParts("Ho, Chi, Min"), [ "Chi Min", "Ho", null ]
deepEqual userUtils.nameParts("Ho Chi Min"), [ "Ho Chi", "Min", null ]
deepEqual userUtils.nameParts(""), [ null, null, null ]
deepEqual userUtils.nameParts("John Doe"), [ "John", "Doe", null ]
deepEqual userUtils.nameParts("Junior"), [ "Junior", null, null ]
QUnit.module "UserNameParts"
test "should infer name parts", ->
deepEqual nameParts("Cody Cutrer"), [ "Cody", "Cutrer", null ]
deepEqual nameParts(" Cody Cutrer "), [ "Cody", "Cutrer", null ]
deepEqual nameParts("Cutrer, Cody"), [ "Cody", "Cutrer", null ]
deepEqual nameParts("Cutrer, Cody Houston"), [ "Cody Houston", "Cutrer", null ]
deepEqual nameParts("St. Clair, John"), [ "John", "St. Clair", null ]
deepEqual nameParts("John St. Clair"), [ "John St.", "Clair", null ]
deepEqual nameParts("Jefferson Thomas Cutrer, IV"), [ "Jefferson Thomas", "Cutrer", "IV" ]
deepEqual nameParts("Jefferson Thomas Cutrer IV"), [ "Jefferson Thomas", "Cutrer", "IV" ]
deepEqual nameParts(null), [ null, null, null ]
deepEqual nameParts("Bob"), [ "Bob", null, null ]
deepEqual nameParts("Ho, Chi, Min"), [ "Chi Min", "Ho", null ]
deepEqual nameParts("Ho Chi Min"), [ "Ho Chi", "Min", null ]
deepEqual nameParts(""), [ null, null, null ]
deepEqual nameParts("John Doe"), [ "John", "Doe", null ]
deepEqual nameParts("Junior"), [ "Junior", null, null ]
test "should use prior_surname", ->
deepEqual userUtils.nameParts("John St. Clair", "St. Clair"), [ "John", "St. Clair", null ]
deepEqual userUtils.nameParts("John St. Clair", "Cutrer"), [ "John St.", "Clair", null ]
deepEqual userUtils.nameParts("St. Clair", "St. Clair"), [ null, "St. Clair", null ]
test "should use prior_surname", ->
deepEqual nameParts("John St. Clair", "St. Clair"), [ "John", "St. Clair", null ]
deepEqual nameParts("John St. Clair", "Cutrer"), [ "John St.", "Clair", null ]
deepEqual nameParts("St. Clair", "St. Clair"), [ null, "St. Clair", null ]
test "should infer surname with no given name", ->
deepEqual userUtils.nameParts("St. Clair,"), [ null, "St. Clair", null ]
test "should infer surname with no given name", ->
deepEqual nameParts("St. Clair,"), [ null, "St. Clair", null ]

View File

@ -16,10 +16,9 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
'jquery',
'account_settings'
], ($, {addUsersLink, openReportDescriptionLink}) => {
import $ from 'jquery'
import {addUsersLink, openReportDescriptionLink} from 'account_settings'
QUnit.module('AccountSettings.openReportDescriptionLink', {
setup () {
const $html = $('<div>').addClass('title').addClass('reports')
@ -60,4 +59,3 @@ define([
$('#fixtures .trigger').click();
equal(document.activeElement, $('#admin_role_id')[0]);
});
})

View File

@ -16,29 +16,27 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
'context_modules_helper'
], (Helper) => {
QUnit.module('ContextModulesHelper', {
setup() {
sinon.stub(Helper, 'setWindowLocation')
},
import Helper from 'context_modules_helper'
teardown() {
Helper.setWindowLocation.restore()
},
})
QUnit.module('ContextModulesHelper', {
setup () {
sinon.stub(Helper, 'setWindowLocation')
},
test('externalUrlLinkClick', () => {
const event = {
preventDefault: sinon.spy()
}
const elt = {
attr: sinon.spy()
}
Helper.externalUrlLinkClick(event, elt)
ok(event.preventDefault.calledOnce, 'preventDefault not called')
ok(elt.attr.calledWith('data-item-href'), 'elt.attr not called')
ok(Helper.setWindowLocation.calledOnce, 'window redirected')
})
teardown () {
Helper.setWindowLocation.restore()
},
})
test('externalUrlLinkClick', () => {
const event = {
preventDefault: sinon.spy()
}
const elt = {
attr: sinon.spy()
}
Helper.externalUrlLinkClick(event, elt)
ok(event.preventDefault.calledOnce, 'preventDefault not called')
ok(elt.attr.calledWith('data-item-href'), 'elt.attr not called')
ok(Helper.setWindowLocation.calledOnce, 'window redirected')
})