Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

simplify code

  • Loading branch information...
commit 186685cf2e272c7e4ca672f924c18c53605c9c55 1 parent e8abad3
jtwb2 jtwb2 authored

Showing 1 changed file with 26 additions and 33 deletions. Show diff stats Hide diff stats

  1. +26 33 static/draggies.js
59 static/draggies.js
@@ -76,45 +76,38 @@ $(function(){
76 76 var clientId = getNewId(),
77 77 fayeclient = new Faye.Client('/fayeclient'),
78 78 remote = new Remote(fayeclient, clientId),
  79 + boxHtml = '<div class="dg-box"></div>',
79 80 newBox = function(id, pos) {
80   - var boxHtml = '<div class="dg-box"></div>';
81 81 return $(boxHtml).appendTo($('#dg-boxstart'))
82   - .draggable(dragOpts.box)
83   - .css({
  82 + .draggable({
  83 + containment: 'window',
  84 + grid: [51, 51],
  85 + stop: function(event, ui){
  86 + if (ui.helper.hasClass('dg-dead')) return;
  87 + remote.fire('place', {
  88 + el: ui.helper.attr('id'),
  89 + pos: ui.position,
  90 + });
  91 + }
  92 + }).css({
84 93 top: pos.top || pos.y || pos[1],
85 94 left: pos.left || pos.x || pos[0]
86 95 }).attr('id', id);
87   - },
88   - dragOpts = {
89   - box: {
90   - containment: 'window',
91   - grid: [51, 51],
92   - stop: function(event, ui){
93   - if (ui.helper.hasClass('dg-dead')) return;
94   - remote.fire('place', {
95   - el: ui.helper.attr('id'),
96   - pos: ui.position,
97   - });
98   - }
99   - },
100   - spawn: {
101   - containment: 'window',
102   - grid: [51, 51],
103   - helper: 'clone',
104   - stop: function(event, ui){
105   - var newId = 'dg-box-' + getNewId();
106   - newBox(newId, ui.position);
107   - remote.fire('place', {
108   - el: newId,
109   - pos: ui.position
110   - });
111   - }
112   - }
113   - };
114   -
115   - $(".dg-spawn").draggable(dragOpts.spawn);
  96 + };
116 97
117   - //$(".dg-box").draggable(dragOpts.box);
  98 + $(".dg-spawn").draggable({
  99 + containment: 'window',
  100 + grid: [51, 51],
  101 + helper: 'clone',
  102 + stop: function(event, ui){
  103 + var newId = 'dg-box-' + getNewId();
  104 + newBox(newId, ui.position);
  105 + remote.fire('place', {
  106 + el: newId,
  107 + pos: ui.position
  108 + });
  109 + }
  110 + });
118 111
119 112 $(".dg-trash").droppable({
120 113 drop: function(event, ui){

0 comments on commit 186685c

Please sign in to comment.
Something went wrong with that request. Please try again.