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
3cca6046
Commit
3cca6046
authored
Jun 29, 2016
by
Brian Jacobel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Change topic name truncation."
This reverts commit
d75e6335
.
parent
17fb156b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
8 deletions
+49
-8
common/static/common/js/discussion/views/discussion_topic_menu_view.js
+26
-6
common/static/common/js/spec/discussion/view/discussion_topic_menu_view_spec.js
+23
-2
No files found.
common/static/common/js/discussion/views/discussion_topic_menu_view.js
View file @
3cca6046
...
...
@@ -16,7 +16,7 @@
initialize
:
function
(
options
)
{
this
.
course_settings
=
options
.
course_settings
;
this
.
currentTopicId
=
options
.
topicId
;
this
.
maxNameWidth
=
26
;
this
.
maxNameWidth
=
100
;
_
.
bindAll
(
this
,
'toggleTopicDropdown'
,
'handleTopicEvent'
,
'hideTopicDropdown'
,
'ignoreClick'
);
...
...
@@ -90,6 +90,9 @@
this
.
dropdownButton
.
addClass
(
'dropped'
);
this
.
topicMenu
.
show
();
$
(
document
.
body
).
on
(
'click.topicMenu'
,
this
.
hideTopicDropdown
);
// Set here because 1) the window might get resized and things could
// change and 2) can't set in initialize because the button is hidden
this
.
maxNameWidth
=
this
.
dropdownButton
.
width
()
-
40
;
return
this
;
},
...
...
@@ -146,11 +149,28 @@
},
// @TODO move into utils.coffee
getNameWidth
:
function
(
name
)
{
var
test
=
$
(
'<div>'
),
width
;
test
.
css
({
'font-size'
:
this
.
dropdownButton
.
css
(
'font-size'
),
'opacity'
:
0
,
'position'
:
'absolute'
,
'left'
:
-
1000
,
'top'
:
-
1000
}).
html
(
name
).
appendTo
(
document
.
body
);
width
=
test
.
width
();
test
.
remove
();
return
width
;
},
// @TODO move into utils.coffee
fitName
:
function
(
name
)
{
var
ellipsisText
=
gettext
(
'…'
),
partialName
,
path
,
rawName
;
if
(
name
.
length
<
this
.
maxNameWidth
)
{
if
(
this
.
getNameWidth
(
name
)
<
this
.
maxNameWidth
)
{
return
name
;
}
else
{
path
=
_
.
map
(
name
.
split
(
'/'
),
function
(
item
){
...
...
@@ -158,15 +178,15 @@
});
while
(
path
.
length
>
1
)
{
path
.
shift
();
partialName
=
ellipsisText
+
'
/'
+
path
.
join
(
'/
'
);
if
(
partialName
.
length
>
this
.
maxNameWidth
)
{
partialName
=
ellipsisText
+
'
/ '
+
path
.
join
(
' /
'
);
if
(
this
.
getNameWidth
(
partialName
)
<
this
.
maxNameWidth
)
{
return
partialName
;
}
}
rawName
=
path
[
0
];
name
=
ellipsisText
+
' / '
+
rawName
;
while
(
name
.
length
>
this
.
maxNameWidth
)
{
rawName
=
rawName
.
slice
(
0
,
this
.
maxNameWidth
);
while
(
this
.
getNameWidth
(
name
)
>
this
.
maxNameWidth
)
{
rawName
=
rawName
.
slice
(
0
,
-
1
);
name
=
ellipsisText
+
' / '
+
rawName
+
' '
+
ellipsisText
;
}
}
...
...
common/static/common/js/spec/discussion/view/discussion_topic_menu_view_spec.js
View file @
3cca6046
...
...
@@ -10,7 +10,7 @@
},
options
);
this
.
view
=
new
DiscussionTopicMenuView
(
options
);
this
.
view
.
render
().
appendTo
(
'#fixture-element'
);
this
.
defaultTextWidth
=
this
.
completeText
.
length
;
this
.
defaultTextWidth
=
this
.
view
.
getNameWidth
(
this
.
completeText
)
;
};
this
.
openMenu
=
function
()
{
...
...
@@ -68,10 +68,31 @@
expect
(
this
.
completeText
).
toEqual
(
dropdownText
);
});
it
(
'completely show just sub-category'
,
function
()
{
var
dropdownText
;
this
.
createTopicView
();
this
.
view
.
maxNameWidth
=
this
.
defaultTextWidth
-
10
;
this
.
view
.
$el
.
find
(
'a.topic-title'
).
first
().
click
();
dropdownText
=
this
.
view
.
$el
.
find
(
'.js-selected-topic'
).
text
();
expect
(
dropdownText
.
indexOf
(
'…'
)).
toEqual
(
0
);
expect
(
dropdownText
).
toContain
(
this
.
selectedOptionText
);
});
it
(
'partially show sub-category'
,
function
()
{
this
.
createTopicView
();
var
parentWidth
=
this
.
view
.
getNameWidth
(
this
.
parentCategoryText
),
dropdownText
;
this
.
view
.
maxNameWidth
=
this
.
defaultTextWidth
-
parentWidth
;
this
.
view
.
$el
.
find
(
'a.topic-title'
).
first
().
click
();
dropdownText
=
this
.
view
.
$el
.
find
(
'.js-selected-topic'
).
text
();
expect
(
dropdownText
.
indexOf
(
'…'
)).
toEqual
(
0
);
expect
(
dropdownText
.
lastIndexOf
(
'…'
)).
toBeGreaterThan
(
0
);
});
it
(
'broken span doesn
\'
t occur'
,
function
()
{
var
dropdownText
;
this
.
createTopicView
();
this
.
view
.
maxNameWidth
=
this
.
selectedOptionText
.
length
+
100
;
this
.
view
.
maxNameWidth
=
this
.
view
.
getNameWidth
(
this
.
selectedOptionText
)
+
100
;
this
.
view
.
$el
.
find
(
'a.topic-title'
).
first
().
click
();
dropdownText
=
this
.
view
.
$el
.
find
(
'.js-selected-topic'
).
text
();
expect
(
dropdownText
.
indexOf
(
'/ span>'
)).
toEqual
(
-
1
);
...
...
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