comparison browser_side/tools.py @ 196:c2639c9f86ea

Browser Side: Widgets can now be moved, header (title bar) is draggable: - DragLabel moved to tools - new LiberviaDragWidget which manage currently dragged widget - getLiberviaWidgetsCount give number of widget of WidgetsPanel - LiberviaWidget's header has now its own class - new "WIDGET" drag type /!\ not fully finished, can crash if moved on the bad border (like last row border if the widget is the only one on this row)
author Goffi <goffi@goffi.org>
date Tue, 05 Mar 2013 01:20:59 +0100
parents 67365f17069e
children f7ec248192de
comparison
equal deleted inserted replaced
195:dd27072d8ae0 196:c2639c9f86ea
17 17
18 You should have received a copy of the GNU Affero General Public License 18 You should have received a copy of the GNU Affero General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. 19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 """ 20 """
21 21
22 from pyjamas.ui.DragWidget import DragWidget
23
22 def html_sanitize(html): 24 def html_sanitize(html):
23 """Naive sanitization of HTML""" 25 """Naive sanitization of HTML"""
24 return html.replace('<','&lt;').replace('>','&gt;') 26 return html.replace('<','&lt;').replace('>','&gt;')
27
28 class DragLabel(DragWidget):
29
30 def __init__(self, text, _type):
31 DragWidget.__init__(self)
32 self._text = text
33 self._type = _type
34
35 def onDragStart(self, event):
36 dt = event.dataTransfer
37 dt.setData('text/plain', "%s\n%s" % (self._text, self._type))
38 dt.setDragImage(self.getElement(), 15, 15)
39
40 class LiberviaDragWidget(DragLabel):
41 """ A DragLabel which keep the widget being dragged as class value """
42 current = None # widget currently dragged
43
44 def __init__(self, text, _type, widget):
45 DragLabel.__init__(self, text, _type)
46 self.widget = widget
47
48 def onDragStart(self, event):
49 LiberviaDragWidget.current = self.widget
50 DragLabel.onDragStart(self, event)
51
52 def onDragEnd(self, event):
53 LiberviaDragWidget.current = None