Skip to content
This repository has been archived by the owner on Mar 2, 2018. It is now read-only.

Commit

Permalink
fix a var name to pos
Browse files Browse the repository at this point in the history
  • Loading branch information
tmtk75 committed Jan 25, 2015
1 parent 55f11b2 commit b83436c
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 23 deletions.
4 changes: 2 additions & 2 deletions lib/js/ClassDiagram.coffee
@@ -1,5 +1,5 @@
Diagram = require "Diagram.coffee"
utils = require "position.coffee"
pos = require "position.coffee"

class ClassDiagram extends Diagram

Expand All @@ -24,7 +24,7 @@ ClassDiagram::declare = (normval) ->
@append clz

ClassDiagram::preferredWidth = ->
utils.mostLeftRight(@find(".class .icon")).width() + 16 ##WORKAROUND: 16 is magic number.
pos.mostLeftRight(@find(".class .icon")).width() + 16 ##WORKAROUND: 16 is magic number.

ClassDiagram::preferredHeight = ->
@find(".class .icon").mostTopBottom().height()
Expand Down
6 changes: 3 additions & 3 deletions lib/js/RobustnessDiagramLayout.coffee
@@ -1,5 +1,5 @@
DiagramLayout = require "DiagramLayout.coffee"
utils = require "position.coffee"
pos = require "position.coffee"

class RobustnessDiagramLayout extends DiagramLayout

Expand All @@ -14,8 +14,8 @@ RobustnessDiagramLayout::_layout = ->
left:p.left + (i % 3) * 120
top:p.top + (i / 3) * 100

mlr = utils.mostLeftRight(elems, true)
mtb = utils.mostTopBottom(elems, true)
mlr = pos.mostLeftRight(elems, true)
mtb = pos.mostTopBottom(elems, true)
@diagram.width(mlr.width())
.height(mtb.height())

Expand Down
14 changes: 7 additions & 7 deletions lib/js/SequenceDiagramLayout.coffee
@@ -1,5 +1,5 @@
core = require "core.coffee"
utils = require "position.coffee"
pos = require "position.coffee"
DiagramLayout = require "DiagramLayout.coffee"
HTMLElementLayout = require "HTMLElementLayout.coffee"
SequenceLifeline = require "SequenceLifeline.coffee"
Expand Down Expand Up @@ -37,8 +37,8 @@ SequenceDiagramLayout::_layout = ->
$(mr[mr.length - 1]).addClass "rightmost"

objs = @diagram.find("*").not(".interaction")
l = utils.min objs, (e)-> $(e).offset().left
r = utils.max objs, (e)->
l = pos.min objs, (e)-> $(e).offset().left
r = pos.max objs, (e)->
e = $(e)
a = e.css("box-shadow").match /[0-9]+px/g
hblur = if a then parseInt(a[2]) else 0
Expand Down Expand Up @@ -104,13 +104,13 @@ SequenceDiagramLayout::pack_fragments_horizontally = ->
if fragments.length > 0
# To controll the width, you can write selector below.
# ".participant:eq(0), > .interaction > .occurrence .interaction"
most = utils.mostLeftRight @_q(".participant")
most = pos.mostLeftRight @_q(".participant")
left = fragments.offset().left
fragments.width (most.right - left) + (most.left - left)

# fragments inside diagram
fixwidth = (fragment) ->
most = utils.mostLeftRight $(".occurrence, .message, .fragment", fragment).not(".return, .lost")
most = pos.mostLeftRight $(".occurrence, .message, .fragment", fragment).not(".return, .lost")
fragment.width(most.width() - (fragment.outerWidth() - fragment.width()))
## WORKAROUND: it's tentative for both of next condition and the body
msg = fragment.find("> .interaction > .message").data "_self"
Expand Down Expand Up @@ -141,7 +141,7 @@ SequenceDiagramLayout::align_lifelines_vertically = ->
b = iters.filter(":last")
mh = (b.offset().top + b.height() - 1) - a.offset().top

min = utils.min @diagram.find(".participant"), (e)-> $(e).offset().top
min = pos.min @diagram.find(".participant"), (e)-> $(e).offset().top

@_q(".lifeline").each (i, e) ->
a = $(e).data "_self"
Expand Down Expand Up @@ -178,7 +178,7 @@ SequenceDiagramLayout::rebuild_asynchronous_self_calling = ->
msg.css("z-index", -1)
.offset
left: occurr.offset().left
top : utils.outerBottom(prev.find(".occurrence")) - msg.height()/3
top : pos.outerBottom(prev.find(".occurrence")) - msg.height()/3

SequenceDiagramLayout::render_icons = ->
selfEach @_q(".participant"), (e)-> e.renderIcon?()
Expand Down
1 change: 0 additions & 1 deletion lib/js/SequenceFragment.coffee
@@ -1,6 +1,5 @@
$ = require "jquery"
HTMLElement = require "HTMLElement.coffee"
utils = require "position.coffee"

class SequenceFragment extends HTMLElement
constructor: (args)->
Expand Down
4 changes: 2 additions & 2 deletions lib/js/SequenceMessage.coffee
@@ -1,5 +1,5 @@
core = require "core.coffee"
utils = require "position.coffee"
pos = require "position.coffee"
_g2d = require "g2d.coffee"
HTMLElement = require "HTMLElement.coffee"

Expand Down Expand Up @@ -163,7 +163,7 @@ SequenceMessage::_to_be_creation = ->
obj = dst._actor
obj.offset top:msg.offset().top - obj.height()/3
mt = parseInt dst.css "margin-top"
dst.offset top:utils.outerBottom(obj) + mt
dst.offset top:pos.outerBottom(obj) + mt

@outerWidth (line_width this) + src.outerWidth() - 1
shift_downward this
Expand Down
4 changes: 2 additions & 2 deletions lib/js/SequenceOccurrence.coffee
@@ -1,5 +1,5 @@
$ = require "jquery"
utils = require "position.coffee"
pos = require "position.coffee"
HTMLElement = require "HTMLElement.coffee"
SequenceInteraction = require "SequenceInteraction.coffee"
SequenceFragment = require "SequenceFragment.coffee"
Expand Down Expand Up @@ -40,7 +40,7 @@ SequenceOccurrence::create = (objsrc) ->

SequenceOccurrence::_move_horizontally = ->
if @parent().hasClass "lost"
offset left:utils.mostLeftRight(@parents(".diagram").find(".participant")).right
offset left:pos.mostLeftRight(@parents(".diagram").find(".participant")).right
return this
if not @is_on_another()
left = @_actor.offset().left + (@_actor.preferred_width() - @width())/2
Expand Down
8 changes: 4 additions & 4 deletions lib/js/SequenceRef.coffee
@@ -1,6 +1,6 @@
$ = require "jquery"
HTMLElement = require "HTMLElement.coffee"
utils = require "position.coffee"
pos = require "position.coffee"

class SequenceRef extends HTMLElement
constructor: (args)->
Expand All @@ -23,7 +23,7 @@ SequenceRef::preferred_left_and_width = ->

if iact.length is 0
lines = $(".lifeline .line", diag)
most = utils.mostLeftRight(lines)
most = pos.mostLeftRight(lines)
most.width = most.width()
return most

Expand All @@ -43,14 +43,14 @@ SequenceRef::preferred_left_and_width = ->
if (alt = @parents(".alt:eq(0)")).length is 1
left = alt.parents(".occurrence")
l = left.offset().left + left.outerWidth() - 1
r = utils.max @parent().find(".occurrence"), (e)-> $(e).offset().left + $(e).outerWidth()/2
r = pos.max @parent().find(".occurrence"), (e)-> $(e).offset().left + $(e).outerWidth()/2
d = left.outerWidth()/2 - 1
return left:l - d, width:(r - l)

dh = diag.self()
.find(".occurrence:eq(0)").width()
occurs = iact.find(".occurrence")
most = utils.mostLeftRight(occurs)
most = pos.mostLeftRight(occurs)
most.left -= dh
most.width = most.width()
most
Expand Down
4 changes: 2 additions & 2 deletions lib/js/position.coffee
Expand Up @@ -4,7 +4,7 @@ _outerBottom = ($e)-> $e.offset().top + $e.outerHeight() - 1

_choose = (nodes, ef, cmpf)-> $.map(nodes, ef).sort(cmpf)[0]

utils =
position =
max: (nodes, ef)-> _choose(nodes, ef, (a, b)-> b - a)
min: (nodes, ef)-> _choose(nodes, ef, (a, b)-> a - b)

Expand All @@ -24,4 +24,4 @@ utils =

outerBottom: _outerBottom

module.exports = utils
module.exports = position

0 comments on commit b83436c

Please sign in to comment.