vigiboard / README / README_jquery / ui_dialog.py @ 52661754
History | View | Annotate | Download (3.22 KB)
1 |
# -*- coding: utf-8 -*-
|
---|---|
2 |
# vim:set expandtab tabstop=4 shiftwidth=4:
|
3 |
|
4 |
# 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 |
from tw.api import Widget, CSSLink, js_function |
23 |
from tw.jquery.direction import jquery_direction_js |
24 |
from ui_core import jquery_ui_core_js |
25 |
from ui import ui_dialog_js , ui_draggable_js, ui_resizable_js |
26 |
|
27 |
__all__ = ["jquery_ui_dialog_js"]
|
28 |
|
29 |
jquery_ui_dialog_css = CSSLink(modname=__name__, |
30 |
filename='static/css/ui.all.css')
|
31 |
|
32 |
jQuery = js_function('jQuery')
|
33 |
|
34 |
class JQueryUIDialog(Widget): |
35 |
|
36 |
"""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 |
|
42 |
params = ['autoOpen', 'bgiframe', 'buttons', 'closeOnEscape', 'dialogClass' |
43 |
'draggable', 'height', 'hide', 'maxHeight', 'maxWidht', 'minHeight', 'minWidth' |
44 |
'modal', 'position', 'resizable', 'show', 'stack', 'title', 'width', 'zindex' ] |
45 |
|
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 |
|
67 |
def update_params(self, d): |
68 |
|
69 |
"""Allow the user to update the UI Dialog parameters"""
|
70 |
|
71 |
super(JQueryUIDialog, self).update_params(d) |
72 |
|
73 |
if not getattr(d, "id", None): |
74 |
raise ValueError, "JQueryUIDialog is supposed to have id" |
75 |
|
76 |
dialog_params = dict ( autoOpen = self.autoOpen, |
77 |
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 |
zindex = self.zindex
|
96 |
|
97 |
) |
98 |
self.add_call(jQuery("#%s" % d.id).dialog(dialog_params)) |