Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
e9e5b5bd
Commit
e9e5b5bd
authored
Jul 21, 2015
by
Christina Roberts
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8765 from edx/christina/lms-requirejs/notes
Optimize edxnotes files.
parents
ad16f9f9
497d76fa
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
51 additions
and
50 deletions
+51
-50
common/djangoapps/pipeline_mako/templates/static_content.html
+5
-1
common/static/js/vendor/underscore.string.min.js
+0
-0
common/templates/edxnotes_wrapper.html
+5
-8
lms/static/js/edxnotes/models/note.js
+2
-2
lms/static/js/edxnotes/plugins/events.js
+1
-1
lms/static/js/edxnotes/views/notes_visibility_factory.js
+14
-10
lms/static/js/spec/edxnotes/views/notes_visibility_factory_spec.js
+7
-8
lms/static/js/spec/main.js
+1
-1
lms/static/lms/js/build.js
+2
-0
lms/templates/edxnotes/edxnotes.html
+9
-12
lms/templates/edxnotes/toggle_notes.html
+5
-7
No files found.
common/djangoapps/pipeline_mako/templates/static_content.html
View file @
e9e5b5bd
...
@@ -60,7 +60,11 @@ source, template_path = _loader.load_template_source(path)
...
@@ -60,7 +60,11 @@ source, template_path = _loader.load_template_source(path)
$
{
caller
.
body
()}
$
{
caller
.
body
()}
});
});
%
else
:
%
else
:
require
([
'${staticfiles_storage.url(module_name + ".js")}'
],
function
()
{
##
The
"raw"
parameter
is
specified
to
avoid
the
URL
from
being
further
maninpulated
by
##
static_replace
calls
(
as
woudl
happen
if
require_module
is
used
within
courseware
).
##
Without
specifying
"raw"
,
a
call
to
static_replace
would
result
in
the
MD5
hash
being
##
being
appended
more
than
once
,
causing
the
import
to
fail
in
production
environments
.
require
([
'${staticfiles_storage.url(module_name + ".js") + "?raw"}'
],
function
()
{
require
([
'${module_name}'
],
function
(
$
{
class_name
})
{
require
([
'${module_name}'
],
function
(
$
{
class_name
})
{
$
{
caller
.
body
()}
$
{
caller
.
body
()}
});
});
...
...
common/static/js/vendor/underscore.string.min.js
View file @
e9e5b5bd
This diff is collapsed.
Click to expand it.
common/templates/edxnotes_wrapper.html
View file @
e9e5b5bd
...
@@ -3,6 +3,7 @@ import json
...
@@ -3,6 +3,7 @@ import json
from
django
.
utils
.
translation
import
ugettext
as
_
from
django
.
utils
.
translation
import
ugettext
as
_
from
student
.
models
import
anonymous_id_for_user
from
student
.
models
import
anonymous_id_for_user
%
>
%
>
<
%
namespace
name=
'static'
file=
'/static_content.html'
/>
<
%
<
%
if
user:
if
user:
params
.
update
({'
user
'
:
anonymous_id_for_user
(
user
,
None
)})
params
.
update
({'
user
'
:
anonymous_id_for_user
(
user
,
None
)})
...
@@ -10,11 +11,7 @@ from student.models import anonymous_id_for_user
...
@@ -10,11 +11,7 @@ from student.models import anonymous_id_for_user
<div
id=
"edx-notes-wrapper-${uid}"
class=
"edx-notes-wrapper"
>
<div
id=
"edx-notes-wrapper-${uid}"
class=
"edx-notes-wrapper"
>
<div
class=
"edx-notes-wrapper-content"
>
${content}
</div>
<div
class=
"edx-notes-wrapper-content"
>
${content}
</div>
</div>
</div>
<script
type=
"text/javascript"
>
<
%
static:require_module
module_name=
"js/edxnotes/views/notes_visibility_factory"
class_name=
"NotesVisibilityFactory"
>
(
function
(
require
)
{
var element = document.getElementById('edx-notes-wrapper-${uid}');
require
([
'js/edxnotes/views/visibility_decorator'
],
function
(
EdxnotesVisibilityDecorator
)
{
NotesVisibilityFactory.VisibilityDecorator.factory(element, ${json.dumps(params)}, ${edxnotes_visibility});
var
element
=
document
.
getElementById
(
'edx-notes-wrapper-${uid}'
);
</
%
static:require
_module
>
EdxnotesVisibilityDecorator
.
factory
(
element
,
$
{
json
.
dumps
(
params
)},
$
{
edxnotes_visibility
});
});
}).
call
(
this
,
require
||
RequireJS
.
require
);
</script>
lms/static/js/edxnotes/models/note.js
View file @
e9e5b5bd
;(
function
(
define
)
{
;(
function
(
define
)
{
'use strict'
;
'use strict'
;
define
([
'backbone'
,
'js/edxnotes/utils/utils'
,
'underscore.string'
],
function
(
Backbone
,
Utils
)
{
define
([
'backbone'
,
'js/edxnotes/utils/utils'
,
'underscore.string'
],
function
(
Backbone
,
Utils
,
str
)
{
var
NoteModel
=
Backbone
.
Model
.
extend
({
var
NoteModel
=
Backbone
.
Model
.
extend
({
defaults
:
{
defaults
:
{
'id'
:
null
,
'id'
:
null
,
...
@@ -47,7 +47,7 @@ define(['backbone', 'js/edxnotes/utils/utils', 'underscore.string'], function (B
...
@@ -47,7 +47,7 @@ define(['backbone', 'js/edxnotes/utils/utils', 'underscore.string'], function (B
var
message
=
this
.
get
(
'quote'
);
var
message
=
this
.
get
(
'quote'
);
if
(
!
this
.
get
(
'is_expanded'
)
&&
this
.
get
(
'show_link'
))
{
if
(
!
this
.
get
(
'is_expanded'
)
&&
this
.
get
(
'show_link'
))
{
message
=
_
.
str
.
prune
(
message
,
this
.
textSize
);
message
=
str
.
prune
(
message
,
this
.
textSize
);
}
}
return
message
;
return
message
;
...
...
lms/static/js/edxnotes/plugins/events.js
View file @
e9e5b5bd
;(
function
(
define
,
undefined
)
{
;(
function
(
define
,
undefined
)
{
'use strict'
;
'use strict'
;
define
([
define
([
'underscore'
,
'annotator_1.2.9'
,
'underscore.string'
'underscore'
,
'annotator_1.2.9'
],
function
(
_
,
Annotator
)
{
],
function
(
_
,
Annotator
)
{
/**
/**
* Modifies Annotator.Plugin.Store.annotationCreated to make it trigger a new
* Modifies Annotator.Plugin.Store.annotationCreated to make it trigger a new
...
...
lms/static/js/edxnotes/views/
toggle_notes
_factory.js
→
lms/static/js/edxnotes/views/
notes_visibility
_factory.js
View file @
e9e5b5bd
...
@@ -3,8 +3,8 @@
...
@@ -3,8 +3,8 @@
define
([
define
([
'jquery'
,
'underscore'
,
'backbone'
,
'gettext'
,
'jquery'
,
'underscore'
,
'backbone'
,
'gettext'
,
'annotator_1.2.9'
,
'js/edxnotes/views/visibility_decorator'
,
'js/utils/animation'
'annotator_1.2.9'
,
'js/edxnotes/views/visibility_decorator'
,
'js/utils/animation'
],
function
(
$
,
_
,
Backbone
,
gettext
,
Annotator
,
Edxnotes
VisibilityDecorator
)
{
],
function
(
$
,
_
,
Backbone
,
gettext
,
Annotator
,
VisibilityDecorator
)
{
var
Toggle
Notes
View
=
Backbone
.
View
.
extend
({
var
Toggle
Visibility
View
=
Backbone
.
View
.
extend
({
events
:
{
events
:
{
'click .action-toggle-notes'
:
'toggleHandler'
'click .action-toggle-notes'
:
'toggleHandler'
},
},
...
@@ -52,14 +52,14 @@ define([
...
@@ -52,14 +52,14 @@ define([
},
},
enableNotes
:
function
()
{
enableNotes
:
function
()
{
_
.
each
(
$
(
'.edx-notes-wrapper'
),
Edxnotes
VisibilityDecorator
.
enableNote
);
_
.
each
(
$
(
'.edx-notes-wrapper'
),
VisibilityDecorator
.
enableNote
);
this
.
actionLink
.
addClass
(
'is-active'
);
this
.
actionLink
.
addClass
(
'is-active'
);
this
.
label
.
text
(
gettext
(
'Hide notes'
));
this
.
label
.
text
(
gettext
(
'Hide notes'
));
this
.
actionToggleMessage
.
text
(
gettext
(
'Notes visible'
));
this
.
actionToggleMessage
.
text
(
gettext
(
'Notes visible'
));
},
},
disableNotes
:
function
()
{
disableNotes
:
function
()
{
Edxnotes
VisibilityDecorator
.
disableNotes
();
VisibilityDecorator
.
disableNotes
();
this
.
actionLink
.
removeClass
(
'is-active'
);
this
.
actionLink
.
removeClass
(
'is-active'
);
this
.
label
.
text
(
gettext
(
'Show notes'
));
this
.
label
.
text
(
gettext
(
'Show notes'
));
this
.
actionToggleMessage
.
text
(
gettext
(
'Notes hidden'
));
this
.
actionToggleMessage
.
text
(
gettext
(
'Notes hidden'
));
...
@@ -93,12 +93,16 @@ define([
...
@@ -93,12 +93,16 @@ define([
}
}
});
});
return
function
(
visibility
,
visibilityUrl
)
{
return
{
return
new
ToggleNotesView
({
ToggleVisibilityView
:
function
(
visibility
,
visibilityUrl
)
{
el
:
$
(
'.edx-notes-visibility'
).
get
(
0
),
return
new
ToggleVisibilityView
({
visibility
:
visibility
,
el
:
$
(
'.edx-notes-visibility'
).
get
(
0
),
visibilityUrl
:
visibilityUrl
visibility
:
visibility
,
});
visibilityUrl
:
visibilityUrl
});
},
VisibilityDecorator
:
VisibilityDecorator
};
};
});
});
}).
call
(
this
,
define
||
RequireJS
.
define
);
}).
call
(
this
,
define
||
RequireJS
.
define
);
lms/static/js/spec/edxnotes/views/
toggle_notes
_factory_spec.js
→
lms/static/js/spec/edxnotes/views/
notes_visibility
_factory_spec.js
View file @
e9e5b5bd
define
([
define
([
'jquery'
,
'
annotator_1.2.9'
,
'common/js/spec_helpers/ajax_helpers'
,
'js/edxnotes/views/visibility_decorator
'
,
'jquery'
,
'
underscore'
,
'annotator_1.2.9'
,
'common/js/spec_helpers/ajax_helpers
'
,
'js/edxnotes/views/
toggle_notes
_factory'
,
'js/spec/edxnotes/helpers'
,
'js/edxnotes/views/
notes_visibility
_factory'
,
'js/spec/edxnotes/helpers'
,
'js/spec/edxnotes/custom_matchers'
,
'jasmine-jquery'
'js/spec/edxnotes/custom_matchers'
,
'jasmine-jquery'
],
function
(
],
function
(
$
,
Annotator
,
AjaxHelpers
,
VisibilityDecorator
,
ToggleNotesFactory
,
Helpers
,
$
,
_
,
Annotator
,
AjaxHelpers
,
NotesVisibilityFactory
,
Helpers
,
customMatchers
customMatchers
)
{
)
{
'use strict'
;
'use strict'
;
describe
(
'EdxNotes ToggleNotesFactory'
,
function
()
{
describe
(
'EdxNotes ToggleNotesFactory'
,
function
()
{
...
@@ -23,13 +22,13 @@ define([
...
@@ -23,13 +22,13 @@ define([
'js/fixtures/edxnotes/edxnotes_wrapper.html'
,
'js/fixtures/edxnotes/edxnotes_wrapper.html'
,
'js/fixtures/edxnotes/toggle_notes.html'
'js/fixtures/edxnotes/toggle_notes.html'
);
);
VisibilityDecorator
.
factory
(
NotesVisibilityFactory
.
VisibilityDecorator
.
factory
(
document
.
getElementById
(
'edx-notes-wrapper-123'
),
params
,
true
document
.
getElementById
(
'edx-notes-wrapper-123'
),
params
,
true
);
);
VisibilityDecorator
.
factory
(
NotesVisibilityFactory
.
VisibilityDecorator
.
factory
(
document
.
getElementById
(
'edx-notes-wrapper-456'
),
params
,
true
document
.
getElementById
(
'edx-notes-wrapper-456'
),
params
,
true
);
);
this
.
toggleNotes
=
ToggleNotesFactory
(
true
,
'/test_url'
);
this
.
toggleNotes
=
NotesVisibilityFactory
.
ToggleVisibilityView
(
true
,
'/test_url'
);
this
.
button
=
$
(
'.action-toggle-notes'
);
this
.
button
=
$
(
'.action-toggle-notes'
);
this
.
label
=
this
.
button
.
find
(
'.utility-control-label'
);
this
.
label
=
this
.
button
.
find
(
'.utility-control-label'
);
this
.
toggleMessage
=
$
(
'.action-toggle-message'
);
this
.
toggleMessage
=
$
(
'.action-toggle-message'
);
...
@@ -37,7 +36,7 @@ define([
...
@@ -37,7 +36,7 @@ define([
});
});
afterEach
(
function
()
{
afterEach
(
function
()
{
VisibilityDecorator
.
_setVisibility
(
null
);
NotesVisibilityFactory
.
VisibilityDecorator
.
_setVisibility
(
null
);
_
.
invoke
(
Annotator
.
_instances
,
'destroy'
);
_
.
invoke
(
Annotator
.
_instances
,
'destroy'
);
$
(
'.annotator-notice'
).
remove
();
$
(
'.annotator-notice'
).
remove
();
});
});
...
...
lms/static/js/spec/main.js
View file @
e9e5b5bd
...
@@ -580,7 +580,7 @@
...
@@ -580,7 +580,7 @@
'lms/include/js/spec/edxnotes/views/tabs/course_structure_spec.js'
,
'lms/include/js/spec/edxnotes/views/tabs/course_structure_spec.js'
,
'lms/include/js/spec/edxnotes/views/tabs/tags_spec.js'
,
'lms/include/js/spec/edxnotes/views/tabs/tags_spec.js'
,
'lms/include/js/spec/edxnotes/views/visibility_decorator_spec.js'
,
'lms/include/js/spec/edxnotes/views/visibility_decorator_spec.js'
,
'lms/include/js/spec/edxnotes/views/
toggle_notes
_factory_spec.js'
,
'lms/include/js/spec/edxnotes/views/
notes_visibility
_factory_spec.js'
,
'lms/include/js/spec/edxnotes/models/tab_spec.js'
,
'lms/include/js/spec/edxnotes/models/tab_spec.js'
,
'lms/include/js/spec/edxnotes/models/note_spec.js'
,
'lms/include/js/spec/edxnotes/models/note_spec.js'
,
'lms/include/js/spec/edxnotes/plugins/accessibility_spec.js'
,
'lms/include/js/spec/edxnotes/plugins/accessibility_spec.js'
,
...
...
lms/static/lms/js/build.js
View file @
e9e5b5bd
...
@@ -19,6 +19,8 @@
...
@@ -19,6 +19,8 @@
*/
*/
modules
:
getModulesList
([
modules
:
getModulesList
([
'js/discovery/discovery_factory'
,
'js/discovery/discovery_factory'
,
'js/edxnotes/views/notes_visibility_factory'
,
'js/edxnotes/views/page_factory'
,
'js/groups/views/cohorts_dashboard_factory'
,
'js/groups/views/cohorts_dashboard_factory'
,
'js/search/course/course_search_factory'
,
'js/search/course/course_search_factory'
,
'js/search/dashboard/dashboard_search_factory'
,
'js/search/dashboard/dashboard_search_factory'
,
...
...
lms/templates/edxnotes/edxnotes.html
View file @
e9e5b5bd
...
@@ -102,17 +102,14 @@ import json
...
@@ -102,17 +102,14 @@ import json
</script>
</script>
% endfor
% endfor
</
%
block>
</
%
block>
<
%
block
name=
"js_extra"
>
% if notes:
% if notes:
<script
type=
"text/javascript"
>
<
%
block
name=
"js_extra"
>
(
function
(
require
)
{
<
%
static:require_module
module_name=
"js/edxnotes/views/page_factory"
class_name=
"NotesPageFactory"
>
require
([
'js/edxnotes/views/page_factory'
],
function
(
NotesPageFactory
)
{
NotesPageFactory({
var
pageView
=
new
NotesPageFactory
({
notesList: ${notes if notes is not None else []},
notesList
:
$
{
notes
},
debugMode: ${debug}
debugMode
:
$
{
debug
}
});
});
</
%
static:require
_module
>
});
</
%
block>
}).
call
(
this
,
require
||
RequireJS
.
require
);
</script>
% endif
% endif
</
%
block>
lms/templates/edxnotes/toggle_notes.html
View file @
e9e5b5bd
...
@@ -3,6 +3,7 @@ import json
...
@@ -3,6 +3,7 @@ import json
from
django
.
utils
.
translation
import
ugettext
as
_
from
django
.
utils
.
translation
import
ugettext
as
_
from
django
.
core
.
urlresolvers
import
reverse
from
django
.
core
.
urlresolvers
import
reverse
%
>
%
>
<
%
namespace
name=
'static'
file=
'/static_content.html'
/>
<
%
page
args=
"course"
/>
<
%
page
args=
"course"
/>
<
%
<
%
...
@@ -20,10 +21,7 @@ from django.core.urlresolvers import reverse
...
@@ -20,10 +21,7 @@ from django.core.urlresolvers import reverse
% endif
% endif
</button>
</button>
</div>
</div>
<script
type=
"text/javascript"
>
(
function
(
require
)
{
<
%
static:require_module
module_name=
"js/edxnotes/views/notes_visibility_factory"
class_name=
"NotesVisibilityFactory"
>
require
([
'js/edxnotes/views/toggle_notes_factory'
],
function
(
ToggleNotesFactory
)
{
NotesVisibilityFactory.ToggleVisibilityView(${json.dumps(edxnotes_visibility)}, '${edxnotes_visibility_url}');
ToggleNotesFactory
(
$
{
json
.
dumps
(
edxnotes_visibility
)},
'${edxnotes_visibility_url}'
);
</
%
static:require
_module
>
});
}).
call
(
this
,
require
||
RequireJS
.
require
);
</script>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment