Permalink
Browse files

Revert "Display editor fields in same order regardless of widget inve…

…rsion. Closes #94."

This reverts commit fabb339.
  • Loading branch information...
1 parent a23967b commit 2552c3eb2dc052d52767760a272579ed96a1f7f2 @nickstenning nickstenning committed Feb 28, 2012
Showing with 21 additions and 9 deletions.
  1. +21 −9 src/editor.coffee
View
@@ -23,6 +23,7 @@ class Annotator.Editor extends Annotator.Widget
<a href="#cancel" class="annotator-cancel">""" + _t('Cancel') + """</a>
<a href="#save" class="annotator-save annotator-focus">""" + _t('Save') + """</a>
</div>
+ <span class="annotator-resize"></span>
</form>
</div>
"""
@@ -55,6 +56,8 @@ class Annotator.Editor extends Annotator.Widget
@fields = []
@annotation = {}
+ this.setupDraggables()
+
# Public: Displays the Editor and fires a "show" event.
# Can be used as an event callback and will call Event#preventDefault()
# on the supplied event.
@@ -256,12 +259,26 @@ class Annotator.Editor extends Annotator.Widget
@fields.push field
- # When main textarea is added, add resize handle
- if @fields.length is 1 and field.type is 'textarea'
- this.setupDraggables()
-
field.element
+ checkOrientation: ->
+ super
+
+ list = @element.find('ul')
+ controls = @element.find('.annotator-controls')
+
+ flipFields = ->
+ list.children().each -> $(this).parent().prepend(this)
+
+ if @element.hasClass(@classes.invert.y) and list.is(':first-child')
+ controls.insertBefore(list)
+ flipFields()
+ else if controls.is(':first-child')
+ controls.insertAfter(list)
+ flipFields()
+
+ this
+
# Event callback. Listens for the following special keypresses.
# - escape: Hides the editor
# - enter: Submits the editor
@@ -289,11 +306,6 @@ class Annotator.Editor extends Annotator.Widget
#
# Returns nothing.
setupDraggables: () ->
- # Find the first text area if there is one.
- textarea = @element.find('textarea:first')
- if textarea
- $('<span class="annotator-resize"></span>').insertAfter(textarea)
-
mousedown = null
classes = @classes
editor = @element

0 comments on commit 2552c3e

Please sign in to comment.