Rev 5207 | Rev 5245 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
// Vix specific Javascript for jquery use//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Generate a confirmation dialog// Args: text - Body of the message// parms - A simple object of options - see defaults// Note: will return BEFORE the user makes a selection// Can call a function and/or a URL if confirmed// Can 'show' a progress element// See 'defaults' below for bits that can be modified////////////////////////////////////////////////////////////////////////////////////////////////////////////////////function vixConfirm(text, parms){var defaults = {resizable: true,height: 'auto',width : 'auto',modal: true,position: { my: "top", at: "top+100", of: window },title: "Confirm",icon: "images/i_warning.gif",url : null,ok : null,post : null,button : "Confirm",progress : "#ProgressBar",};$.extend( defaults, parms);defaults.open = function() {$(this).siblings('.ui-dialog-buttonpane').find('button:eq(1)').focus();var markup = '<img src="'+defaults.icon+'" style="float:left; margin:0 7px 20px 0;">' + text;$(this).html(markup);};defaults.close = function() {$(this).remove();};defaults.buttons = [{text : defaults.button,click : function (){if (defaults.ok != null ){defaults.ok(defaults);}if ( defaults.progress != null) {$(defaults.progress).show().css("visibility", "visible");}if (defaults.url != null ) {window.location.href = defaults.url;}if (defaults.post != null ) {$('form[name="'+defaults.post+'"]').submit();}$(this).dialog("close");}},{text : 'Cancel',click : function (){$(this).dialog("close");}}];var dd = $( "<div>Confirm</div>" ).dialog(defaults);// Once the dialog has been instantiated the autosize dimensions are known// and the dislog can be correctly positioneddd.dialog("widget").position(defaults.position);// Return false incase this is used as an onClickreturn false;}////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Compatability function// Confirm Deletion of an item// Assumes that the item is within an 'anchor' and that an href can be located// Uses VixConfirm to do the heavy lifting////////////////////////////////////////////////////////////////////////////////////////////////////////////////////function vixConfirmDelete (txt){var href = window.event.currentTarget.href;vixConfirm('Are you sure you want to delete '+ txt +'?', {url : href})return false;}////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Similar to 'alert', but uses the jquery dialog mechnaism// Note: will return BEFORE the user makes a selection// Returns a Defereed object that will be rejected when the dialog is closed.////////////////////////////////////////////////////////////////////////////////////////////////////////////////////function vixAlert(text){var dbo = $.Deferred();var dd = $( "<div>Alert</div>" ).dialog({resizable: true,height: 'auto',width : 'auto',modal: true,title:'Alert',position: { my: "top", at: "top+100", of: window },open: function() {$(this).html('<img src="images/i_critical.gif" style="float:left; margin:0 7px 20px 0;">' + text);},close : function() {$(this).remove();dbo.reject();},buttons: {"Ok": function() {$(this).dialog("close");}}});// Once the dialog has been instantiated the autosize dimensions are known// and the dislog can be correctly positioned// Note: Appears that we need to position it twice// Once in the dialog creation, and once heredd.dialog("widget").position({ my: "top", at: "top+100", of: window });return dbo;}