Commit a1f73f7b by cahrens Committed by Andy Armstrong

Simplify how underscore.string is referred to.

parent dd2a2036
......@@ -2,7 +2,7 @@
'use strict';
define(["jquery", "underscore", "underscore.string", "common/js/components/views/feedback"],
function($, _, str, SystemFeedbackView) {
str = str || _.str;
var Alert = SystemFeedbackView.extend({
options: $.extend({}, SystemFeedbackView.prototype.options, {
type: "alert"
......
......@@ -2,7 +2,7 @@
'use strict';
define(["jquery", "underscore", "underscore.string", "common/js/components/views/feedback"],
function($, _, str, SystemFeedbackView) {
str = str || _.str;
var Notification = SystemFeedbackView.extend({
options: $.extend({}, SystemFeedbackView.prototype.options, {
type: "notification",
......
......@@ -2,7 +2,7 @@
'use strict';
define(["jquery", "underscore", "underscore.string", "common/js/components/views/feedback"],
function($, _, str, SystemFeedbackView) {
str = str || _.str;
var Prompt = SystemFeedbackView.extend({
options: $.extend({}, SystemFeedbackView.prototype.options, {
type: "prompt",
......
......@@ -15,9 +15,6 @@
* by the access view, but doing it here helps keep the
* utility self-contained.
*/
if (_.isUndefined(_s)) {
_s = _.str;
}
_.mixin( _s.exports() );
utils = (function(){
......
......@@ -1237,6 +1237,7 @@ base_vendor_js = [
'js/vendor/jquery.cookie.js',
'js/vendor/url.min.js',
'js/vendor/underscore-min.js',
'js/vendor/underscore.string.min.js',
'js/vendor/requirejs/require.js',
'js/RequireJS-namespace-undefine.js',
'js/vendor/URI.min.js',
......
......@@ -12,7 +12,6 @@
],
function(_, str, Backbone, gettext){
str = str || _.str;
return Backbone.Model.extend({
idAttribute: 'id',
......
......@@ -8,7 +8,6 @@
['underscore', 'underscore.string', 'gettext', 'backbone'],
function(_, str, gettext, Backbone) {
str = str || _.str;
return Backbone.Model.extend({
idAttribute: 'id',
......
......@@ -181,22 +181,7 @@
},
'underscore': {
deps: ['underscore.string'],
exports: '_',
init: function(UnderscoreString) {
/* Mix non-conflicting functions from underscore.string
* (all but include, contains, and reverse) into the
* Underscore namespace. This allows the login, register,
* and password reset templates to render independent of the
* access view.
*/
_.mixin(UnderscoreString.exports());
/* Since the access view is not using RequireJS, we also
* expose underscore.string at _.str, so that the access
* view can perform the mixin on its own.
*/
_.str = UnderscoreString;
}
exports: '_'
},
'backbone': {
deps: ['underscore', 'jquery'],
......@@ -374,7 +359,12 @@
},
'js/verify_student/views/step_view': {
exports: 'edx.verify_student.StepView',
deps: [ 'jquery', 'underscore', 'underscore.string', 'backbone', 'gettext' ]
deps: [ 'jquery', 'underscore', 'underscore.string', 'backbone', 'gettext' ],
init: function() {
// Set global variables that the payment code is expecting to be defined
window._ = require('underscore');
window._.str = require('underscore.string');
}
},
'js/verify_student/views/intro_step_view': {
exports: 'edx.verify_student.IntroStepView',
......
......@@ -19,10 +19,6 @@
function($, utility, _, _s, Backbone, LoginModel, PasswordResetModel, RegisterModel, LoginView,
PasswordResetView, RegisterView, InstitutionLoginView, HintedLoginView) {
if (_.isUndefined(_s)) {
_s = _.str;
}
return Backbone.View.extend({
tpl: '#access-tpl',
events: {
......
/*global jQuery, _, Backbone, gettext */
/**
* Base view for defining steps in the payment/verification flow.
*
......@@ -8,7 +10,7 @@
*/
var edx = edx || {};
(function( $, _, _s, Backbone, gettext ) {
(function( $, _, Backbone, gettext ) {
'use strict';
edx.verify_student = edx.verify_student || {};
......@@ -21,13 +23,8 @@
/* Mix non-conflicting functions from underscore.string
* (all but include, contains, and reverse) into the
* Underscore namespace.
*
* TODO: when running unit tests, _s is not defined. My first attempt at upgrading
* underscore.string did not solve this issue.
*/
if (_s) {
_.mixin(_s.exports());
}
_.mixin(_.str.exports());
},
render: function() {
......@@ -106,4 +103,4 @@
});
})( jQuery, _, _.str, Backbone, gettext );
})( jQuery, _, Backbone, gettext );
......@@ -66,6 +66,7 @@
'jquery.url': 'empty:',
'backbone': 'empty:',
'underscore': 'empty:',
'underscore.string': 'empty:',
'logger': 'empty:',
'utility': 'empty:',
'URI': 'empty:',
......
......@@ -19,6 +19,12 @@
};
defineDependency("jQuery", "jquery");
defineDependency("_", "underscore");
if (window._ && window._.str) {
define("underscore.string", [], function () {return window._.str;});
}
else {
console.error("Expected _.str (underscore.string) to be on the window object, but not found.");
}
defineDependency("gettext", "gettext");
defineDependency("Logger", "logger");
defineDependency("URI", "URI");
......
......@@ -19,7 +19,6 @@ from django.utils.translation import ugettext as _
</%block>
<%block name="js_extra">
<script src="${static.url('js/vendor/jquery.ajax-retry.js')}"></script>
<script src="${static.url('js/vendor/underscore.string.min.js')}"></script>
<script src="${static.url('js/src/tooltip_manager.js')}"></script>
<script src="${static.url('js/commerce/credit.js')}"></script>
<script src="${static.url('js/commerce/views/receipt_view.js')}"></script>
......
......@@ -18,7 +18,6 @@ from django.utils.translation import ugettext as _
% endfor
</%block>
<%block name="js_extra">
<script src="${static.url('js/vendor/underscore.string.min.js')}"></script>
<script src="${static.url('js/src/tooltip_manager.js')}"></script>
<%static:js group='incourse_reverify'/>
</%block>
......
......@@ -41,7 +41,6 @@ from lms.djangoapps.verify_student.views import PayAndVerifyView
% endfor
</%block>
<%block name="js_extra">
<script src="${static.url('js/vendor/underscore.string.min.js')}"></script>
<script src="${static.url('js/src/tooltip_manager.js')}"></script>
<%static:js group='verify_student'/>
</%block>
......
......@@ -16,7 +16,6 @@ from django.utils.translation import ugettext as _
% endfor
</%block>
<%block name="js_extra">
<script src="${static.url('js/vendor/underscore.string.min.js')}"></script>
<script src="${static.url('js/src/tooltip_manager.js')}"></script>
<%static:js group='reverify'/>
</%block>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment