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