Subversion Repositories DevTools

Rev

Rev 5245 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5245 Rev 5266
Line 2... Line 2...
2
//
2
//
3
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
3
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
4
//  Generate a confirmation dialog
4
//  Generate a confirmation dialog
5
//  Args:   text - Body of the message
5
//  Args:   text - Body of the message
6
//          parms - A simple object of options - see defaults
6
//          parms - A simple object of options - see defaults
-
 
7
//                  Special: position of 'center' will place in center of visible screen.
7
//  Note: will return BEFORE the user makes a selection
8
//  Note: will return BEFORE the user makes a selection
8
//        Can call a function and/or a URL if confirmed
9
//        Can call a function and/or a URL if confirmed
9
//        Can 'show' a progress element
10
//        Can 'show' a progress element
10
//        See 'defaults' below for bits that can be modified
11
//        See 'defaults' below for bits that can be modified
11
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
12
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Line 62... Line 63...
62
            }
63
            }
63
        }];
64
        }];
64
 
65
 
65
     var dd = $( "<div>Confirm</div>" ).dialog(defaults);
66
     var dd = $( "<div>Confirm</div>" ).dialog(defaults);
66
     // Once the dialog has been instantiated the autosize dimensions are known
67
     // Once the dialog has been instantiated the autosize dimensions are known
67
     // and the dislog can be correctly positioned
68
     // and the dialog can be correctly positioned
-
 
69
     if (defaults.position == 'center')
-
 
70
     {
-
 
71
         dd.dialog("widget").center();
-
 
72
         console.log("Center in Window");
-
 
73
     }
-
 
74
     else
-
 
75
     {
68
     dd.dialog("widget").position(defaults.position);
76
         dd.dialog("widget").position(defaults.position);
-
 
77
         console.log("Original position");
-
 
78
     }
69
 
79
     
70
     // Return false incase this is used as an onClick
80
     // Return false incase this is used as an onClick
71
     return false;
81
     return false;
72
}
82
}
73
 
83
 
74
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
84
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Line 110... Line 120...
110
                $(this).dialog("close");
120
                $(this).dialog("close");
111
            }
121
            }
112
        }
122
        }
113
     });
123
     });
114
     // Once the dialog has been instantiated the autosize dimensions are known
124
     // Once the dialog has been instantiated the autosize dimensions are known
115
     // and the dislog can be correctly positioned
125
     // and the dialog can be correctly positioned
116
     // Note: Appears that we need to position it twice
126
     // Note: Appears that we need to position it twice
117
     //       Once in the dialog creation, and once here
127
     //       Once in the dialog creation, and once here
118
     dd.dialog("widget").position({ my: "top", at: "top+100", of: window });
128
     dd.dialog("widget").position({ my: "top", at: "top+100", of: window });
119
 
129
 
120
     return dbo;
130
     return dbo;
121
}
131
}
122
 
132
 
-
 
133
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
 
134
//  jQuery extension function
-
 
135
//  Position an element inthe center of the visible window. Not the document and not the window(viewport).
-
 
136
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
 
137
jQuery.fn.center = function () {
-
 
138
 
-
 
139
    //  Support many browsers
-
 
140
    var w = window.innerWidth  || document.documentElement.clientWidth  || document.body.clientWidth;
-
 
141
    var h = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
-
 
142
 
-
 
143
    this.css("position","fixed");
-
 
144
    this.css("top", Math.max(0,  ((h - $(this).outerHeight()) / 2) ) + "px");
-
 
145
    this.css("left", Math.max(0, ((w - $(this).outerWidth()) / 2) ) + "px");
-
 
146
    return this;
-
 
147
}
-
 
148
 
-
 
149
//--------- Support to open modal dialog in an iFrame
-
 
150
//  Example: <a class="vixIframeDialog" href="aaa.asp" title="Some Title" data-width=500 data-height=300>Link Text</a>
-
 
151
//
-
 
152
var vixIframe = {};
-
 
153
$(document).ready(function () {
-
 
154
    $('.vixIframeDialog').on('click', function (e) {
-
 
155
        e.preventDefault();
-
 
156
        vixIframe.parent = this;
-
 
157
        vixIframe.pagetitle = $(this).attr("title");
-
 
158
        var page = $(this).attr("href");
-
 
159
        var iframe = $('<iframe onload="resizeIframe(this);" id="iframe" style="border:0px; overflow: scroll;" src="' + page + '" width="100%" height="100%" ></iframe>');
-
 
160
        var $dialog = $('<div></div>').html(iframe);
-
 
161
        var $dialog2 = $dialog.dialog({
-
 
162
            autoOpen: true,
-
 
163
            modal: true,
-
 
164
            zheight: $(this).data('height')|| 200,
-
 
165
            zwidth: $(this).data('width') || 300,
-
 
166
            height : 'auto,', width : 'auto',
-
 
167
            dialogClass: "rounded_box",
-
 
168
            title: 'Loading - ' + vixIframe.pagetitle,
-
 
169
            close: function(event, ui){
-
 
170
                //console.log('closing dialog');
-
 
171
                $(this).dialog("destroy");
-
 
172
                vixIframe = {};
-
 
173
                window.onbeforeunload = null;
-
 
174
                window.onunload = null;
-
 
175
 
-
 
176
                },
-
 
177
        });
-
 
178
        vixIframe.Dialog = $dialog;
-
 
179
        vixIframe.DialogWidget = $($dialog2).dialog('widget');
-
 
180
        //$(currentDialogWidget).find(".ui-dialog-titlebar").remove();
-
 
181
        $(vixIframe.DialogWidget).position({my:'top', at: 'top+100', of : window});
-
 
182
        //$dialog.dialog('open');
-
 
183
 
-
 
184
        //  Prevent the user from navigating away from the iframe
-
 
185
 
-
 
186
//      window.onbeforeunload = function(){
-
 
187
//          console.log("confirmBrowseAway");
-
 
188
//          console.log("window.location.href:" + window.location.href);
-
 
189
//          parent.closeIFrame(12);
-
 
190
//          return null};
-
 
191
        window.onunload = function(){
-
 
192
            console.log("Unloading");
-
 
193
            //parent.closeIFrame(12);
-
 
194
        }
-
 
195
 
-
 
196
    });
-
 
197
 
-
 
198
    //
-
 
199
    // Prevent (at least control) the user from navigating within the iframe
-
 
200
    // If this invocation is within an iFrame, then close the iFrame if
-
 
201
    // the user attempt to navigate away from the iFrame.
-
 
202
    //      This means that the iFrame cannot replace itself
-
 
203
    // 
-
 
204
    if (typeof parent.vixIframe.pagetitle !== 'undefined')
-
 
205
    {
-
 
206
        console.log("DocumentReady within iframe");
-
 
207
        //window.onbeforeunload = function(){console.log("onbeforeunload");parent.closeIFrame(13); return null};
-
 
208
        window.onunload = function(){
-
 
209
            console.log("Unloading within iframe");
-
 
210
            //parent.closeIFrame(13);
-
 
211
        }
-
 
212
    }
-
 
213
 
-
 
214
});
-
 
215
 
-
 
216
function resizeIframe(iframe) {
-
 
217
    iframe.height = iframe.contentWindow.document.body.scrollHeight + "px";
-
 
218
    $(vixIframe.Dialog).height(iframe.height);
-
 
219
    //console.log ("Resize Iframe:",iframe.height );
-
 
220
 
-
 
221
    iframe.width = iframe.contentWindow.document.body.scrollWidth;
-
 
222
    $(vixIframe.Dialog).width(iframe.width);
-
 
223
    //console.log ("Resize Iframe:",iframe.width );
-
 
224
 
-
 
225
    $(vixIframe.DialogWidget).position({my:'top', at: 'top+100', of : window});
-
 
226
 
-
 
227
    // New reset the title
-
 
228
    vixIframe.Dialog.dialog('option','title', vixIframe.pagetitle);
-
 
229
    //console.log("Ifame:", vixIframe)
-
 
230
};
-
 
231
 
-
 
232
function closeIFrame(aa)
-
 
233
{
-
 
234
    if (vixIframe.Dialog != null) {
-
 
235
        console.log('closing iframe:' + aa);
-
 
236
        vixIframe.Dialog.dialog('close');
-
 
237
        vixIframe = {};
-
 
238
    }
-
 
239
}
-
 
240
 
-
 
241
 
123
 
242