Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special copy/paste handler for math. #84

Merged
merged 17 commits into from
Oct 18, 2013
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/plugins/oer/assorted/css/image.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ figure.aloha-oer-block .image-wrapper .image-edit {
left: 100%;
padding: 2px 10px 2px 5px;
border-radius: 0 4px 4px 0;
width: 100px;
width: 20em;
top: -8px;
word-wrap: break-word;
line-height: 16px;
}

figure.aloha-oer-block .image-wrapper .image-edit:hover {
Expand All @@ -73,7 +74,6 @@ figure.aloha-oer-block .image-wrapper .image-edit:not(.passive):hover {
border: 1px dotted #1B86D2;
background-color: #D9E7F1;
z-index: 400;
width: 100px;
word-wrap: break-word;
}

Expand Down Expand Up @@ -119,11 +119,15 @@ figure.aloha-oer-block .image-wrapper .image-edit.passive {
}

i.icon-warning {
display: inline-block;
background-image: url(../img/warning-01.png);
background-position: 0 0;
background-position: 0 bottom;
background-repeat: no-repeat;
margin-right: 4px;
margin-left: 4px;
width: 16px;
height: 16px;
vertical-align: bottom;
}

.warning-text {
Expand Down
19 changes: 9 additions & 10 deletions src/plugins/oer/assorted/css/link.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ ul.nav.nav-tabs {
.link-popover {
width: auto;
min-width: 236px; /* bootstrap's default popover width */
max-width: none; /* override bootstrap default so that the link options don't wrap */
}

.link-popover-details .edit-link,
Expand All @@ -53,17 +54,14 @@ ul.nav.nav-tabs {
white-space: nowrap;
}


.edit-link,
.delete-link,
.visit-link {
.aloha.popover .link-popover-details button, .visit-link{
padding: 0 10px;
}

/* Add a border (separator) only around the 1st 2 buttons */
.edit-link,
.delete-link {
border-right: 1px solid black;
/* Add a separator after the 1st 2 buttons */
.aloha.popover button.edit-link,
.aloha.popover button.delete-link {
border-right: 1px solid #bbb;
}

i.icon-edit-link {
Expand All @@ -76,8 +74,9 @@ i.icon-delete-link {
background-image: url(../img/delete-link.png);
background-position: 0 0;
}

i.icon-external-link {
/* commenting out for now since it's conflicting with .icon-external-link:before's image
background-image: url(../img/external-link.png);
background-position: 0 0;
}
*/
}
3 changes: 1 addition & 2 deletions src/plugins/oer/assorted/lib/link.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ define [
</button>
<a class="visit-link" target="_blank" title="Visit the link in a new window or tab">
<i class="icon-external-link"></i>
<span class="title"></span>
</a>
<span class="title"></span></a>
</span>
<br/>
'''
Expand Down
5 changes: 2 additions & 3 deletions src/plugins/oer/assorted/lib/link.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 51 additions & 22 deletions src/plugins/oer/copy/lib/copy-plugin.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@ define ['aloha', 'aloha/plugin', 'jquery', 'ui/ui', 'ui/button', 'PubSub', './pa

buffer = ''
srcpath = null
content_type = null

getSection = ($el) ->
headings = ['h1', 'h2', 'h3']
level = headings.indexOf $el[0].nodeName.toLowerCase()
# Pick up all elements until the next heading of the same level or higher
selector = headings.slice(0, level+1).join(',')

if $el.addBack
# Jquery >= 1.8
$el = $el.nextUntil(selector).addBack()
else
# Jquery < 1.8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this code exist somewhere else (maybe in another PR)? I thought I remember @tmsp1 mentioning jQuery < 1.8 was not possible

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making a ticket out of this so I can merge this. #96

$el = $el.nextUntil(selector).andSelf()
html = ''
html += jQuery(e).outerHtml() for e in $el
return html

Plugin.create 'copy',
getCurrentPath: ->
Expand All @@ -26,13 +43,21 @@ define ['aloha', 'aloha/plugin', 'jquery', 'ui/ui', 'ui/button', 'PubSub', './pa
else
return srcpath

buffer: (content, path) ->
getContentType: ->
if localStorage
return localStorage.alohaOerCopyContentType
else
return content_type

buffer: (content, type, path) ->
buffer = content
buffer = buffer.replace /id="[^"]+"/, ''
srcpath = path
content_type = type or 'text/html'
srcpath = path or @getCurrentPath()

localStorage.alohaOerCopyBuffer = buffer if localStorage
localStorage.alohaOerCopySrcPath = srcpath if localStorage
localStorage.alohaOerCopyContentType = content_type if localStorage

# Disable copy button, it will re-enable when you move the cursor. This
# gives visual feedback and prevents you from copying the same thing
Expand All @@ -42,25 +67,16 @@ define ['aloha', 'aloha/plugin', 'jquery', 'ui/ui', 'ui/button', 'PubSub', './pa
@pastebutton.flash?()

copySection: ($el) ->
headings = ['h1', 'h2', 'h3']
level = headings.indexOf $el[0].nodeName.toLowerCase()
# Pick up all elements until the next heading of the same level or higher
selector = headings.slice(0, level+1).join(',')

if $el.addBack
# Jquery >= 1.8
$el = $el.nextUntil(selector).addBack()
else
# Jquery < 1.8
$el = $el.nextUntil(selector).andSelf()
html = ''
html += jQuery(e).outerHtml() for e in $el

path = @getCurrentPath()
if path != null
@buffer html, path
else
@buffer html
content = getSection($el)

# Fire a copy event, allow something more suitable to handle this.
evt = $.Event('copy')
evt.oerContent = content
evt.clipboardData =
setData: (t, c) => @buffer c, t
Aloha.activeEditable.obj.trigger(evt)
if not evt.isDefaultPrevented()
@buffer content

init: ->
plugin = @
Expand Down Expand Up @@ -89,7 +105,19 @@ define ['aloha', 'aloha/plugin', 'jquery', 'ui/ui', 'ui/button', 'PubSub', './pa
tooltip: 'Paste',
click: (e) ->
e.preventDefault()
range = Aloha.Selection.getRangeObject()

# Fire a paste event, allow something else to handle this, if that
# something deems itself more suitable.
evt = $.Event('paste')
evt.clipboardData =
getData: (t) ->
if t == plugin.getContentType()
return plugin.getBuffer()
return null
Aloha.activeEditable.obj.trigger(evt)
return if evt.isDefaultPrevented()

# Default paste behaviour follows
$elements = jQuery plugin.getBuffer()

dstpath = plugin.getCurrentPath()
Expand All @@ -111,6 +139,7 @@ define ['aloha', 'aloha/plugin', 'jquery', 'ui/ui', 'ui/button', 'PubSub', './pa
else
console.log "Image path already absolute: #{imgpath}"

range = Aloha.Selection.getRangeObject()
GENTICS.Utils.Dom.insertIntoDOM $elements, range, Aloha.activeEditable.obj

@copybutton = UI.adopt "copy", Button,
Expand Down
87 changes: 61 additions & 26 deletions src/plugins/oer/copy/lib/copy-plugin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/plugins/oer/definition/css/definition-plugin.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dl.definition.aloha-oer-block {
}

.aloha-oer-block.definition .term-wrapper:before {
content: "\25A0 Definition";
content: "\25A0 Definition";
font-weight: bold;
margin: 5px 10px 0 5px;
color: #369;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/oer/example/lib/example-plugin.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ define [

TYPE_CONTAINER = jQuery '''
<span class="type-container dropdown aloha-ephemera">
<a class="type" href="#" data-toggle="dropdown"></a>
<span class="type btn-link" href="#" data-toggle="dropdown"></span>
<ul class="dropdown-menu">
</ul>
</span>
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/oer/example/lib/example-plugin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/plugins/oer/math/css/math.css
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,6 @@ math,
background-image: url(../img/remove-02.png);
}

button.done {
button.done, button.copy {
float: right;
}
Loading