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