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
dff33121
Commit
dff33121
authored
Aug 05, 2013
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor the coffeescript a bit more. Hopefully to resolve Jasmine failures
parent
d2f91121
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
13 deletions
+14
-13
common/lib/xmodule/xmodule/js/src/html/edit.coffee
+14
-13
No files found.
common/lib/xmodule/xmodule/js/src/html/edit.coffee
View file @
dff33121
...
@@ -48,7 +48,7 @@ class @HTMLEditingDescriptor
...
@@ -48,7 +48,7 @@ class @HTMLEditingDescriptor
setup
:
@
setupTinyMCE
,
setup
:
@
setupTinyMCE
,
# Cannot get access to tinyMCE Editor instance (for focusing) until after it is rendered.
# Cannot get access to tinyMCE Editor instance (for focusing) until after it is rendered.
# The tinyMCE callback passes in the editor as a paramter.
# The tinyMCE callback passes in the editor as a paramter.
init_instance_callback
:
@
focusVisualEditor
init_instance_callback
:
@
initInstanceCallback
})
})
@
showingVisualEditor
=
true
@
showingVisualEditor
=
true
...
@@ -96,29 +96,32 @@ class @HTMLEditingDescriptor
...
@@ -96,29 +96,32 @@ class @HTMLEditingDescriptor
# Show the Advanced (codemirror) Editor. Pulled out as a helper method for unit testing.
# Show the Advanced (codemirror) Editor. Pulled out as a helper method for unit testing.
showAdvancedEditor
:
(
visualEditor
)
->
showAdvancedEditor
:
(
visualEditor
)
->
if
visualEditor
.
isDirty
()
if
visualEditor
.
isDirty
()
content
=
visualEditor
.
getContent
({
no_events
:
1
})
content
=
@
rewriteStaticLinks
(
visualEditor
.
getContent
({
no_events
:
1
}),
@
base_asset_url
,
'/static/'
)
regex
=
new
RegExp
(
@
base_asset_url
,
'g'
)
content
=
content
.
replace
(
regex
,
'/static/'
)
@
advanced_editor
.
setValue
(
content
)
@
advanced_editor
.
setValue
(
content
)
@
advanced_editor
.
setCursor
(
0
)
@
advanced_editor
.
setCursor
(
0
)
@
advanced_editor
.
refresh
()
@
advanced_editor
.
refresh
()
@
advanced_editor
.
focus
()
@
advanced_editor
.
focus
()
@
showingVisualEditor
=
false
@
showingVisualEditor
=
false
rewriteStaticLinks
:
(
content
,
from
,
to
)
->
regex
=
new
RegExp
(
from
,
'g'
)
return
content
.
replace
(
regex
,
to
)
# Show the Visual (tinyMCE) Editor. Pulled out as a helper method for unit testing.
# Show the Visual (tinyMCE) Editor. Pulled out as a helper method for unit testing.
showVisualEditor
:
(
visualEditor
)
->
showVisualEditor
:
(
visualEditor
)
->
# In order for isDirty() to return true ONLY if edits have been made after setting the text,
# In order for isDirty() to return true ONLY if edits have been made after setting the text,
# both the startContent must be sync'ed up and the dirty flag set to false.
# both the startContent must be sync'ed up and the dirty flag set to false.
visualEditor
.
startContent
=
visualEditor
.
getContent
({
format
:
"raw"
,
no_events
:
1
});
content
=
@
rewriteStaticLinks
(
@
advanced_editor
.
getValue
(),
'/static/'
,
@
base_asset_url
)
visualEditor
.
setContent
(
content
)
visualEditor
.
startContent
=
content
@
focusVisualEditor
(
visualEditor
)
@
focusVisualEditor
(
visualEditor
)
@
showingVisualEditor
=
true
@
showingVisualEditor
=
true
focusVisualEditor
:
(
visualEditor
)
=>
initInstanceCallback
:
(
visualEditor
)
=>
content
=
@
advanced_editor
.
getValue
()
visualEditor
.
setContent
(
@
rewriteStaticLinks
(
@
advanced_editor
.
getValue
(),
'/static/'
,
@
base_asset_url
))
regex
=
new
RegExp
(
'/static/'
,
'g'
)
@
focusVisualEditor
(
visualEditor
)
content
=
content
.
replace
(
regex
,
@
base_asset_url
)
visualEditor
.
setContent
(
content
)
focusVisualEditor
:
(
visualEditor
)
=>
visualEditor
.
focus
()
visualEditor
.
focus
()
# Need to mark editor as not dirty both when it is initially created and when we switch back to it.
# Need to mark editor as not dirty both when it is initially created and when we switch back to it.
visualEditor
.
isNotDirty
=
true
visualEditor
.
isNotDirty
=
true
...
@@ -139,7 +142,5 @@ class @HTMLEditingDescriptor
...
@@ -139,7 +142,5 @@ class @HTMLEditingDescriptor
text
=
@
advanced_editor
.
getValue
()
text
=
@
advanced_editor
.
getValue
()
visualEditor
=
@
getVisualEditor
()
visualEditor
=
@
getVisualEditor
()
if
@
showingVisualEditor
and
visualEditor
.
isDirty
()
if
@
showingVisualEditor
and
visualEditor
.
isDirty
()
text
=
visualEditor
.
getContent
({
no_events
:
1
})
text
=
@
rewriteStaticLinks
(
visualEditor
.
getContent
({
no_events
:
1
}),
@
base_asset_url
,
'/static/'
)
regex
=
new
RegExp
(
@
base_asset_url
,
'g'
)
text
=
text
.
replace
(
regex
,
'/static/'
)
data
:
text
data
:
text
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