Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

edx-ui-toolkit

Package Overview
Dependencies
Maintainers
11
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

edx-ui-toolkit - npm Package Compare versions

Comparing version 1.4.1 to 1.5.0

.eslintignore

5

CHANGELOG.md
# Changelog
## 1.5.0 (2016-10-03)
* Add DateUtils
- - -
## 1.4.1 (2016-06-24)

@@ -4,0 +9,0 @@ * Fix minor issue with unnecessary DOM node in breadcrumbs

16

package.json
{
"name": "edx-ui-toolkit",
"version": "1.4.1",
"version": "1.5.0",
"description": "A JavaScript toolkit for building edX user interfaces",

@@ -17,3 +17,4 @@ "license": "Apache-2.0",

"scripts": {
"test": "gulp test"
"test": "gulp test",
"lint": "eslint ."
},

@@ -23,6 +24,9 @@ "dependencies": {

"backbone.paginator": "~2.0.3",
"gulp-shell": "^0.5.2",
"jquery": "~2.2.0",
"moment": "^2.15.1",
"moment-timezone": "~0.5.5",
"requirejs": "~2.1.22",
"requirejs-text": "~2.0.12",
"sinon": "~1.17.3",
"sinon": "1.17.3 || >1.17.4",
"underscore": "~1.8.3",

@@ -36,2 +40,4 @@ "urijs": "~1.16.1"

"edx-pattern-library": "~0.12.5",
"eslint": "~2.13.1",
"eslint-config-edx": "~1.2.1",
"extract-text-webpack-plugin": "~1.0.1",

@@ -41,4 +47,2 @@ "gulp": "~3.9.1",

"gulp-gh-pages": "~0.5.4",
"gulp-jscs": "~3.0.2",
"gulp-jshint": "~2.0.0",
"gulp-karma": "~0.0.5",

@@ -51,4 +55,2 @@ "gulp-rename": "~1.2.2",

"jsdox": "~0.4.9",
"jscs": "~2.9.0",
"jshint": "~2.9.1",
"karma": "~0.13.22",

@@ -55,0 +57,0 @@ "karma-chrome-launcher": "~0.2.2",

@@ -23,10 +23,10 @@ /**

*/
;(function (define) {
(function(define) {
'use strict';
define(['backbone'], function (Backbone) {
define(['backbone'], function(Backbone) {
var BreadcrumbsModel = Backbone.Model.extend({
defaults: {
'breadcrumbs': null,
'label': ''
breadcrumbs: null,
label: ''
}

@@ -33,0 +33,0 @@ });

@@ -22,8 +22,8 @@ /**

*/
;(function (define) {
(function(define) {
'use strict';
define(['backbone', 'edx-ui-toolkit/js/utils/html-utils', 'text!./breadcrumbs.underscore'],
function (Backbone, HtmlUtils, breadcrumbsTemplate) {
function(Backbone, HtmlUtils, breadcrumbsTemplate) {
var BreadcrumbsView = Backbone.View.extend({
initialize: function (options) {
initialize: function() {
this.template = HtmlUtils.template(breadcrumbsTemplate);

@@ -34,3 +34,3 @@ this.listenTo(this.model, 'change', this.render);

render: function () {
render: function() {
var json = this.model.attributes;

@@ -37,0 +37,0 @@ HtmlUtils.setHtml(this.$el, this.template(json));

@@ -11,3 +11,3 @@ /**

*/
;(function(define) {
(function(define) {
'use strict';

@@ -14,0 +14,0 @@

@@ -36,11 +36,11 @@ /**

*/
;(function(define) {
(function(define) {
'use strict';
define([
'backbone',
'jquery',
'underscore',
'edx-ui-toolkit/js/utils/constants',
'text!./dropdown.underscore'
],
'backbone',
'jquery',
'underscore',
'edx-ui-toolkit/js/utils/constants',
'text!./dropdown.underscore'
],
function(Backbone, $, _, constants, DropdownTpl) {

@@ -53,3 +53,3 @@ var DropdownMenuView = Backbone.View.extend({

'click a': 'analyticsLinkClick',
'keydown': 'viewKeypress'
keydown: 'viewKeypress'
},

@@ -115,3 +115,3 @@

*
* @param {object} event The event to be tracked.
* @param {object} event The event to be tracked.
* @returns {*} The event.

@@ -118,0 +118,0 @@ */

@@ -28,5 +28,5 @@ /**

*/
;(function (define) {
(function(define) {
'use strict';
define(['jquery', 'underscore', 'backbone.paginator'], function ($, _, PageableCollection) {
define(['jquery', 'underscore', 'backbone.paginator'], function($, _, PageableCollection) {
var PagingCollection = PageableCollection.extend({

@@ -56,3 +56,3 @@ mode: 'server',

constructor: function (models, options) {
constructor: function(models, options) {
this.state = _.extend({}, PagingCollection.prototype.state, this.state);

@@ -63,3 +63,3 @@ this.queryParams = _.extend({}, PagingCollection.prototype.queryParams, this.queryParams);

initialize: function (models, options) {
initialize: function(models, options) {
// These must be initialized in the constructor

@@ -74,3 +74,3 @@ // because otherwise all PagingCollections would point

parse: function (response, options) {
parse: function(response, options) {
// PageableCollection expects the response to be an

@@ -93,3 +93,3 @@ // array of two elements - the server-side state

*/
getPageNumber: function () {
getPageNumber: function() {
return this.state.currentPage + (1 - this.state.firstPage);

@@ -104,3 +104,3 @@ },

*/
getTotalPages: function () {
getTotalPages: function() {
return this.state.totalPages;

@@ -114,3 +114,3 @@ },

*/
getTotalRecords: function () {
getTotalRecords: function() {
return this.state.totalRecords;

@@ -124,3 +124,3 @@ },

*/
getPageSize: function () {
getPageSize: function() {
return this.state.pageSize;

@@ -139,3 +139,3 @@ },

*/
setPage: function (page) {
setPage: function(page) {
var oldPage = this.state.currentPage,

@@ -145,3 +145,3 @@ self = this,

this.getPage(page - (1 - this.state.firstPage), {reset: true}).then(
function () {
function() {
self.isStale = false;

@@ -151,3 +151,3 @@ self.trigger('page_changed');

},
function () {
function() {
self.state.currentPage = oldPage;

@@ -185,3 +185,3 @@ deferred.fail();

*/
hasNextPage: function () {
hasNextPage: function() {
return this.getPageNumber() < this.state.totalPages;

@@ -196,3 +196,3 @@ },

*/
hasPreviousPage: function () {
hasPreviousPage: function() {
return this.getPageNumber() > 1;

@@ -204,3 +204,3 @@ },

*/
nextPage: function () {
nextPage: function() {
if (this.hasNextPage()) {

@@ -214,3 +214,3 @@ this.setPage(this.getPageNumber() + 1);

*/
previousPage: function () {
previousPage: function() {
if (this.hasPreviousPage()) {

@@ -229,3 +229,3 @@ this.setPage(this.getPageNumber() - 1);

*/
registerSortableField: function (fieldName, displayName) {
registerSortableField: function(fieldName, displayName) {
this.addField(this.sortableFields, fieldName, displayName);

@@ -242,3 +242,3 @@ },

*/
registerFilterableField: function (fieldName, displayName) {
registerFilterableField: function(fieldName, displayName) {
this.addField(this.filterableFields, fieldName, displayName);

@@ -255,6 +255,8 @@ },

*/
addField: function (fields, fieldName, displayName) {
fields[fieldName] = {
addField: function(fields, fieldName, displayName) {
var newField = {};
newField[fieldName] = {
displayName: displayName
};
_.extend(fields, newField);
},

@@ -268,3 +270,3 @@

*/
sortDisplayName: function () {
sortDisplayName: function() {
if (this.state.sortKey) {

@@ -284,3 +286,3 @@ return this.sortableFields[this.state.sortKey].displayName;

*/
filterDisplayName: function (fieldName) {
filterDisplayName: function(fieldName) {
if (!_.isUndefined(this.filterableFields[fieldName])) {

@@ -301,3 +303,3 @@ return this.filterableFields[fieldName].displayName;

*/
setSortField: function (fieldName, toggleDirection) {
setSortField: function(fieldName, toggleDirection) {
var direction = toggleDirection ? 0 - this.state.order : this.state.order;

@@ -320,3 +322,3 @@ if (fieldName !== this.state.sortKey || toggleDirection) {

*/
sortDirection: function () {
sortDirection: function() {
return (this.state.order === -1) ?

@@ -335,3 +337,3 @@ PagingCollection.SortDirection.ASCENDING :

*/
setSortDirection: function (direction) {
setSortDirection: function(direction) {
var currentOrder = this.state.order,

@@ -353,3 +355,3 @@ newOrder = currentOrder;

*/
flipSortDirection: function () {
flipSortDirection: function() {
this.setSorting(this.state.sortKey, 0 - this.state.order);

@@ -367,3 +369,3 @@ this.isStale = true;

*/
hasRegisteredFilterField: function (fieldName) {
hasRegisteredFilterField: function(fieldName) {
return _.has(this.filterableFields, fieldName) &&

@@ -380,3 +382,3 @@ !_.isUndefined(this.filterableFields[fieldName].displayName);

*/
hasSetFilterField: function (fieldName) {
hasSetFilterField: function(fieldName) {
return _.has(this.filterableFields, fieldName) && !_.isNull(this.filterableFields[fieldName].value);

@@ -393,8 +395,8 @@ },

*/
getActiveFilterFields: function (includeSearch) {
getActiveFilterFields: function(includeSearch) {
var activeFilterFields = _.chain(this.filterableFields)
.pick(function (fieldData, fieldName) {
.pick(function(fieldData) {
return !_.isNull(fieldData.value) && !_.isUndefined(fieldData.value);
})
.mapObject(function (data) {
.mapObject(function(data) {
return data.value;

@@ -414,4 +416,4 @@ });

*/
getFilterFieldValue: function (filterFieldName) {
var val = this.getActiveFilterFields(true)[filterFieldName]
getFilterFieldValue: function(filterFieldName) {
var val = this.getActiveFilterFields(true)[filterFieldName];
return (_.isNull(val) || _.isUndefined(val)) ? null : val;

@@ -428,3 +430,3 @@ },

*/
setFilterField: function (fieldName, value) {
setFilterField: function(fieldName, value) {
var queryStringValue;

@@ -440,3 +442,3 @@ if (!this.hasRegisteredFilterField(fieldName)) {

}
this.queryParams[fieldName] = function () {
this.queryParams[fieldName] = function() {
return queryStringValue || null;

@@ -454,3 +456,3 @@ };

*/
unsetFilterField: function (fieldName) {
unsetFilterField: function(fieldName) {
if (this.hasSetFilterField(fieldName)) {

@@ -465,3 +467,3 @@ this.setFilterField(fieldName, null);

*/
unsetAllFilterFields: function () {
unsetAllFilterFields: function() {
_.each(_.keys(this.filterableFields), _.bind(this.unsetFilterField, this));

@@ -476,3 +478,3 @@ },

*/
getSearchString: function () {
getSearchString: function() {
return this.getFilterFieldValue(PagingCollection.DefaultSearchKey);

@@ -486,3 +488,3 @@ },

*/
hasActiveSearch: function () {
hasActiveSearch: function() {
var currentSearch = this.getSearchString();

@@ -499,3 +501,3 @@ return !_.isNull(currentSearch) && currentSearch !== '';

*/
setSearchString: function (searchString) {
setSearchString: function(searchString) {
if (searchString !== this.getSearchString()) {

@@ -510,3 +512,3 @@ this.setFilterField(PagingCollection.DefaultSearchKey, searchString);

*/
unsetSearchString: function () {
unsetSearchString: function() {
this.unsetFilterField(PagingCollection.DefaultSearchKey);

@@ -513,0 +515,0 @@ }

/**
* Reusable constants.
*/
;(function(define) {
(function(define) {
'use strict';

@@ -42,2 +42,3 @@ define([], function() {

// 3. else use the GlobalLoader to install the class into the edx namespace
// eslint-disable-next-line no-nested-ternary
typeof define === 'function' && define.amd ? define :

@@ -44,0 +45,0 @@ (typeof RequireJS !== 'undefined' ? RequireJS.define :

@@ -6,2 +6,3 @@ /**

*/
/* global $, _ */
(function() {

@@ -13,3 +14,4 @@ 'use strict';

window.edx.GlobalLoader = (function() {
var registeredModules = {};
var registeredModules = {},
GlobalLoader;

@@ -20,3 +22,3 @@ // Register standard libraries

return {
GlobalLoader = {
/**

@@ -51,3 +53,2 @@ * Define a module that can be accessed globally in the edx namespace.

defineAs: function(name, path) {
return function(requiredPaths, moduleFunction) {

@@ -63,3 +64,3 @@ var requiredModules = [],

}
module = moduleFunction.apply(this, requiredModules);
module = moduleFunction.apply(GlobalLoader, requiredModules);
registeredModules[path] = module;

@@ -79,3 +80,5 @@ edx[name] = module;

};
})();
return GlobalLoader;
}());
}).call(this);

@@ -8,10 +8,11 @@ /**

* platform with
* [Preventing Cross Site Scripting Vulnerabilities](http://edx.readthedocs.org/projects/edx-developer-guide/en/latest/conventions/safe_templates.html).
* [Preventing Cross Site Scripting Vulnerabilities][1].
* [1]: http://edx.readthedocs.org/projects/edx-developer-guide/en/latest/conventions/safe_templates.html
*
* @module HtmlUtils
*/
;(function(define) {
(function(define) {
'use strict';
define(['underscore', 'jquery', 'edx-ui-toolkit/js/utils/string-utils'], function(_, $, StringUtils) {
var ensureHtml, interpolateHtml, joinHtml, HTML, template, setHtml, append, prepend;
var HtmlUtils, ensureHtml, interpolateHtml, joinHtml, HTML, template, setHtml, append, prepend;

@@ -160,15 +161,12 @@ /**

template = function(text, settings) {
var HtmlUtils = this,
rawTemplate = _.template(text, settings),
template = function(data) {
var augmentedData = _.extend(
{
HtmlUtils: HtmlUtils,
StringUtils: StringUtils
},
data || {}
);
return HTML(rawTemplate(augmentedData));
};
return template;
return function(data) {
var augmentedData = _.extend(
{
HtmlUtils: HtmlUtils,
StringUtils: StringUtils
},
data || {}
);
return HTML(_.template(text, settings)(augmentedData));
};
};

@@ -224,3 +222,3 @@

return {
HtmlUtils = {
append: append,

@@ -236,2 +234,4 @@ ensureHtml: ensureHtml,

};
return HtmlUtils;
});

@@ -244,2 +244,3 @@ }).call(

// 3. else use the GlobalLoader to install the class into the edx namespace
// eslint-disable-next-line no-nested-ternary
typeof define === 'function' && define.amd ? define :

@@ -246,0 +247,0 @@ (typeof RequireJS !== 'undefined' ? RequireJS.define :

@@ -210,3 +210,4 @@ /**

expect(request.readyState).toEqual(XHR_READY_STATES.UNSENT);
requests.currentIndex++;
// Our ESLint config bans mutating params, but fixing this would require breaking AjaxHelpers API
requests.currentIndex++; // eslint-disable-line no-param-reassign
};

@@ -233,3 +234,3 @@

);
requests.currentIndex++;
requests.currentIndex++; // eslint-disable-line no-param-reassign
};

@@ -236,0 +237,0 @@

@@ -9,2 +9,4 @@ /**

var withData, withConfiguration;
/**

@@ -19,13 +21,8 @@ * Runs func as a test case multiple times, using entries from data as arguments.

*/
var withData = function(data, func) {
/* jshint loopfunc:true */
for (var name in data) {
if (data.hasOwnProperty(name)) {
(function(name) {
it(name, function() {
func.apply(this, data[name]);
});
})(name);
}
}
withData = function(data, func) {
Object.keys(data).forEach(function(key) {
it(key, function() {
func.apply(this, data[key]);
});
});
};

@@ -45,16 +42,11 @@

*/
var withConfiguration = function(config, setup, test) {
/* jshint loopfunc:true */
for (var name in config) {
if (config.hasOwnProperty(name)) {
(function(name) {
describe(name, function() {
beforeEach(function() {
setup.apply(this, config[name]);
});
test();
});
})(name);
}
}
withConfiguration = function(config, setup, test) {
Object.keys(config).forEach(function(key) {
describe(key, function() {
beforeEach(function() {
setup.apply(this, config[key]);
});
test();
});
});
};

@@ -61,0 +53,0 @@

@@ -6,3 +6,3 @@ /**

*/
;(function(define) {
(function(define) {
'use strict';

@@ -61,3 +61,3 @@ define([], function() {

function(parameter) {
var parameterName = parameter.slice(1,-1);
var parameterName = parameter.slice(1, -1);
return String(parameters[parameterName]);

@@ -77,2 +77,3 @@ });

// 3. else use the GlobalLoader to install the class into the edx namespace
// eslint-disable-next-line no-nested-ternary
typeof define === 'function' && define.amd ? define :

@@ -79,0 +80,0 @@ (typeof RequireJS !== 'undefined' ? RequireJS.define :

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc