vigiboard / README / README_jquery / ui_dialog.py @ 4a49ed53
History | View | Annotate | Download (3.21 KB)
1 | 4a49ed53 | Thomas ANDREJAK | # -*- coding: utf-8 -*-
|
---|---|---|---|
2 | # vim:set expandtab tabstop=4 shiftwidth=4:
|
||
3 | |||
4 | 49c8da1d | Thomas ANDREJAK | # Permission is hereby granted, free of charge, to any person obtaining a copy
|
5 | # of this software and associated documentation files (the "Software"), to deal
|
||
6 | # in the Software without restriction, including without limitation the rights
|
||
7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||
8 | # copies of the Software, and to permit persons to whom the Software is
|
||
9 | # furnished to do so, subject to the following conditions:
|
||
10 | #
|
||
11 | # The above copyright notice and this permission notice shall be included in
|
||
12 | # all copies or substantial portions of the Software.
|
||
13 | #
|
||
14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||
15 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||
16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||
17 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||
18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||
19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||
20 | # THE SOFTWARE.
|
||
21 | |||
22 | 4a49ed53 | Thomas ANDREJAK | from tw.api import Widget, CSSLink, js_function |
23 | from tw.jquery.direction import jquery_direction_js |
||
24 | 49c8da1d | Thomas ANDREJAK | from ui_core import jquery_ui_core_js |
25 | from ui import ui_dialog_js , ui_draggable_js, ui_resizable_js |
||
26 | |||
27 | 20367931 | Thomas ANDREJAK | __all__ = ["jquery_ui_dialog_js"]
|
28 | 49c8da1d | Thomas ANDREJAK | |
29 | 4a49ed53 | Thomas ANDREJAK | jquery_ui_dialog_css = CSSLink(modname=__name__, |
30 | filename='static/css/ui.all.css')
|
||
31 | 49c8da1d | Thomas ANDREJAK | |
32 | jQuery = js_function('jQuery')
|
||
33 | |||
34 | class JQueryUIDialog(Widget): |
||
35 | |||
36 | 4a49ed53 | Thomas ANDREJAK | """Generate an instance for an UI Dialog"""
|
37 | |||
38 | javascript = [ui_dialog_js,ui_draggable_js,jquery_ui_core_js, |
||
39 | jquery_direction_js,ui_resizable_js] |
||
40 | css = [jquery_ui_dialog_css] |
||
41 | 49c8da1d | Thomas ANDREJAK | |
42 | 4a49ed53 | Thomas ANDREJAK | params = ['autoOpen', 'bgiframe', 'buttons', 'closeOnEscape', 'dialogClass' |
43 | 'draggable', 'height', 'hide', 'maxHeight', 'maxWidht', 'minHeight', 'minWidth' |
||
44 | 'modal', 'position', 'resizable', 'show', 'stack', 'title', 'width', 'zindex' ] |
||
45 | 49c8da1d | Thomas ANDREJAK | |
46 | autoOpen = True
|
||
47 | bgiframe = False
|
||
48 | buttons = {} |
||
49 | closeOnEscape = True
|
||
50 | dialogClass = ""
|
||
51 | draggable = True
|
||
52 | height = "auto"
|
||
53 | hide = None
|
||
54 | maxHeight = False
|
||
55 | maxWidth = False
|
||
56 | minHeight = 15
|
||
57 | minWidth = 15
|
||
58 | modal = False
|
||
59 | position = "center"
|
||
60 | resizable = False
|
||
61 | show = None
|
||
62 | stack = True
|
||
63 | title = ''
|
||
64 | width = "auto"
|
||
65 | zindex = 1000
|
||
66 | 4a49ed53 | Thomas ANDREJAK | |
67 | 49c8da1d | Thomas ANDREJAK | def update_params(self, d): |
68 | 4a49ed53 | Thomas ANDREJAK | |
69 | """Allow the user to update the UI Dialog parameters"""
|
||
70 | |||
71 | 49c8da1d | Thomas ANDREJAK | super(JQueryUIDialog, self).update_params(d) |
72 | 4a49ed53 | Thomas ANDREJAK | |
73 | if not getattr(d, "id", None): |
||
74 | 49c8da1d | Thomas ANDREJAK | raise ValueError, "JQueryUIDialog is supposed to have id" |
75 | 4a49ed53 | Thomas ANDREJAK | |
76 | dialog_params = dict ( autoOpen = self.autoOpen, |
||
77 | 49c8da1d | Thomas ANDREJAK | bgiframe = self.bgiframe,
|
78 | buttons = self.buttons,
|
||
79 | closeOnEscape = self.closeOnEscape,
|
||
80 | dialogClass = self.dialogClass,
|
||
81 | draggable = self.draggable,
|
||
82 | height = self.height,
|
||
83 | hide = self.hide,
|
||
84 | maxHeight = self.maxHeight,
|
||
85 | maxWidth = self.maxWidth,
|
||
86 | minHeight = self.minHeight,
|
||
87 | minWidth = self.minWidth,
|
||
88 | modal = self.modal,
|
||
89 | position = self.position,
|
||
90 | resizable = self.resizable,
|
||
91 | show = self.show,
|
||
92 | stack = self.stack,
|
||
93 | title = self.title,
|
||
94 | width = self.width,
|
||
95 | 20367931 | Thomas ANDREJAK | zindex = self.zindex
|
96 | 49c8da1d | Thomas ANDREJAK | |
97 | ) |
||
98 | self.add_call(jQuery("#%s" % d.id).dialog(dialog_params)) |