Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

vigiboard / README_jquery / ui_dialog.py @ 805cc54a

History | View | Annotate | Download (3.56 KB)

1
# Permission is hereby granted, free of charge, to any person obtaining a copy
2
# of this software and associated documentation files (the "Software"), to deal
3
# in the Software without restriction, including without limitation the rights
4
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
# copies of the Software, and to permit persons to whom the Software is
6
# furnished to do so, subject to the following conditions:
7
#
8
# The above copyright notice and this permission notice shall be included in
9
# all copies or substantial portions of the Software.
10
#
11
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
17
# THE SOFTWARE.
18

    
19
from tw.api import Widget, JSLink, CSSLink, js_function, js_callback
20
from tw.jquery import JQuery
21
from tw.jquery.direction import *
22
from tw.forms import FormField
23
from ui_core import jquery_ui_core_js
24
from ui import ui_dialog_js , ui_draggable_js, ui_resizable_js
25
__all__ = ["jquery_ui_dialog_js"]
26

    
27

    
28
# declare your static resources here
29

    
30
## JS dependencies can be listed at 'javascript' so they'll get included
31
## before
32

    
33
jquery_ui_dialog_css    = CSSLink(modname=__name__, filename='static/css/ui.all.css')
34
#jquery_ui_dialog_js    = JSLink(modname=__name__, filename='static/javascript/ui/ui.dialog.js', javascript=[jquery_ui_core_js,jquery_direction_js])
35

    
36
#jquery_ui_draggable_js =  JSLink(modname=__name__, filename='static/javascript/ui/ui.draggable.js')
37

    
38

    
39
jQuery = js_function('jQuery')
40

    
41
class JQueryUIDialog(Widget):
42
    
43
    javascript = [ui_dialog_js,ui_draggable_js,jquery_ui_core_js,jquery_direction_js,ui_resizable_js]
44
    css=[jquery_ui_dialog_css]
45
    
46
    params = ["autoOpen","bgiframe","buttons","closeOnEscape","dialogClass"
47
        "draggable","height","hide","maxHeight","maxWidht","minHeight","minWidth"
48
        "modal","position","resizable","show","stack","title","width","zindex" ]
49
   
50
    autoOpen = True
51
    bgiframe = False
52
    buttons = {}
53
    closeOnEscape = True 
54
    dialogClass = ""
55
    draggable = True
56
    height = "auto"
57
    hide = None
58
    maxHeight = False
59
    maxWidth = False
60
    minHeight = 150
61
    minWidth = 150
62
    modal = False
63
    position = "center"
64
    resizable = True
65
    show = None
66
    stack = True
67
    title = ''
68
    width = 300
69
    zindex = 1000
70
    def update_params(self, d):
71
        super(JQueryUIDialog, self).update_params(d)
72
        if not getattr(d,"id",None):
73
            raise ValueError, "JQueryUIDialog is supposed to have id"
74
            dialog_params = dict (     autoOpen = self.autoOpen,
75
                        bgiframe = self.bgiframe,
76
                        buttons = self.buttons,
77
                        closeOnEscape = self.closeOnEscape,
78
                        dialogClass = self.dialogClass,
79
                        draggable = self.draggable,
80
                        height = self.height,
81
                        hide = self.hide,
82
                        maxHeight = self.maxHeight,
83
                        maxWidth = self.maxWidth,
84
                        minHeight = self.minHeight,
85
                        minWidth = self.minWidth,
86
                        modal = self.modal,
87
                        position = self.position,
88
                        resizable = self.resizable,
89
                        show = self.show,
90
                        stack = self.stack,
91
                        title = self.title,
92
                        width = self.width,
93
                        zindex = self.zindex#,
94
                        #open = js_callback('function(event,ui) { for ( i in event ) { alert(i);}}') # $(\'#%s\').dialog(\'option\' , \'position\' , \'top\')}' % d.id )
95

    
96
                        )
97
        self.add_call(jQuery("#%s" % d.id).dialog(dialog_params))
98
        
99