Page MenuHomePhabricator

script.js
No OneTemporary

script.js

jQuery(function() {
// Attach to addressbook links
var addressbookpage = jQuery('#davcardAddressbookList').data('addressbookpage');
if(!addressbookpage) return;
dw_davcard__modals.page = addressbookpage;
jQuery('div.davcardAddressbookAddNew a').each(function() {
var $link = jQuery(this);
var href = $link.attr('href');
if (!href) return;
$link.click(
function(e) {
dw_davcard__modals.showEditContactDialog(null, false);
e.preventDefault();
return '';
}
);
}
);
});
/**
* This holds all modal windows that DAVCal uses.
*/
var dw_davcard__modals = {
$editContactDialog: null,
$confirmDialog: null,
page: null,
uri: null,
action: null,
completeCb: null,
msg: null,
showEditContactDialog : function(entry, edit) {
if(dw_davcard__modals.$editContactDialog)
return;
var title = '';
var dialogButtons = {};
if(edit)
{
title = LANG.plugins.davcard['edit_entry'];
dialogButtons[LANG.plugins.davcard['edit']] = function() {
var postArray = { };
var pageid = dw_davcard__modals.page;
jQuery("input.dw_davcard__editcontact").each(function() {
if(jQuery(this).attr('type') == 'checkbox')
{
postArray[jQuery(this).prop('name')] = jQuery(this).prop('checked') ? 1 : 0;
}
else
{
postArray[jQuery(this).prop('name')] = jQuery(this).val();
}
});
jQuery('#dw_davcard__ajaxedit').html('<img src="'+DOKU_BASE+'lib/images/throbber.gif" alt="" width="16" height="16" />');
jQuery.post(
DOKU_BASE + 'lib/exe/ajax.php',
{
call: 'plugin_davcard',
id: pageid,
page: dw_davcard__modals.page,
action: 'editContact',
params: postArray,
sectok: JSINFO.plugin.davcal['sectok']
},
function(data)
{
var result = data['result'];
var html = data['html'];
jQuery('#dw_davcard__ajaxedit').html(html);
if(result === true)
{
dw_davcard__modals.hideEditContactDialog();
location.reload();
}
}
);
};
dialogButtons[LANG.plugins.davcal['delete']] = function() {
dw_davcard__modals.action = 'deleteContact';
dw_davcard__modals.msg = LANG.plugins.davcard['really_delete_this_entry'];
dw_davcard__modals.completeCb = function(data) {
var result = data['result'];
if(result === true)
{
dw_davcard__modals.hideEditContactDialog();
location.reload();
}
};
dw_davcard__modals.showDialog(true);
};
}
else
{
title = LANG.plugins.davcard['create_entry'];
dialogButtons[LANG.plugins.davcard['create']] = function() {
var postArray = { };
var pageid = dw_davcard__modals.page;
jQuery("input.dw_davcard__editcontact").each(function() {
if(jQuery(this).attr('type') == 'checkbox')
{
postArray[jQuery(this).prop('name')] = jQuery(this).prop('checked') ? 1 : 0;
}
else
{
postArray[jQuery(this).prop('name')] = jQuery(this).val();
}
});
jQuery('#dw_davcard__ajaxedit').html('<img src="'+DOKU_BASE+'lib/images/throbber.gif" alt="" width="16" height="16" />');
jQuery.post(
DOKU_BASE + 'lib/exe/ajax.php',
{
call: 'plugin_davcard',
id: pageid,
page: dw_davcard__modals.page,
action: 'newContact',
params: postArray,
sectok: JSINFO.plugin.davcard['sectok']
},
function(data)
{
var result = data['result'];
var html = data['html'];
jQuery('#dw_davcard__ajaxedit').html(html);
if(result === true)
{
dw_davcard__modals.hideEditContactDialog();
location.reload();
}
}
);
};
}
dialogButtons[LANG.plugins.davcard['cancel']] = function() {
dw_davcard__modals.hideEditContactDialog();
};
dw_davcard__modals.$editContactDialog = jQuery(document.createElement('div'))
.dialog({
autoOpen: false,
draggable: true,
// fix for dragging: http://stackoverflow.com/questions/17247486/jquery-ui-dialog-dragging-issues
drag: function(event, ui) {
var fixPix = jQuery(document).scrollTop();
iObj = ui.position;
iObj.top = iObj.top - fixPix;
jQuery(this).closest(".ui-dialog").css("top", iObj.top + "px");
},
title: title,
resizable: true,
buttons: dialogButtons,
})
.html(
'<div><table>' +
// FIXME: '<tr><td>' + LANG.plugins.davcal['calendar'] + '</td><td><select id="dw_davcal__editevent_calendar"></select></td></tr>' +
'<tr><td>' + LANG.plugins.davcard['firstname'] + '</td><td><input type="text" id="dw_davcard__firstname_edit" name="firstname" class="dw_davcard__editcontact"></td></tr>' +
'<tr><td>' + LANG.plugins.davcard['lastname'] + '</td><td><input type="text" id="dw_davcard__lastname_edit" name="lastname" class="dw_davcard__editcontact"></td></tr>' +
'<tr><td>' + LANG.plugins.davcard['cellphone'] + '</td><td><input type="text" id="dw_davcard__cellphone_edit" name="cellphone" class="dw_davcard__editcontact"></td></tr>' +
'<tr><td>' + LANG.plugins.davcard['phone'] + '</td><td><input type="text" id="dw_davcard__phone_edit" name="phone" class="dw_davcard__editcontact"></td></tr>' +
'<tr><td>' + LANG.plugins.davcard['email'] + '</td><td><input type="text" id="dw_davcard__email_edit" name="email" class="dw_davcard__editcontact"></td></tr>' +
'<tr><td>' + LANG.plugins.davcard['street'] + '</td><td><input type="text" id="dw_davcard__street_edit" name="street" class="dw_davcard__editcontact"></td></tr>' +
'<tr><td>' + LANG.plugins.davcard['zipcode'] + '</td><td><input type="text" id="dw_davcard__zipcode_edit" name="zipcode" class="dw_davcard__editcontact"></td></tr>' +
'<tr><td>' + LANG.plugins.davcard['city'] + '</td><td><input type="text" id="dw_davcard__city_edit" name="city" class="dw_davcard__editcontact"></td></tr>' +
'<tr><td>' + LANG.plugins.davcard['country'] + '</td><td><input type="text" id="dw_davcard__country_edit" name="country" class="dw_davcard__editcontact"></td></tr>' +
'</table>' +
'<input type="hidden" name="uri" id="dw_davcard__uid_edit" class="dw_davcard__editcontact">' +
'</div>' +
'<div id="dw_davcard__ajaxedit"></div>'
)
.parent()
.attr('id','dw_davcard__edit')
.show()
.appendTo('.dokuwiki:first');
jQuery('#dw_davcard__edit').position({
my: "center",
at: "center",
of: window
});
// attach event handlers
jQuery('#dw_davcard__edit .ui-dialog-titlebar-close').click(function(){
dw_davcard__modals.hideEditContactDialog();
});
},
hideEditContactDialog : function() {
dw_davcard__modals.$editContactDialog.empty();
dw_davcard__modals.$editContactDialog.remove();
dw_davcard__modals.$editContactDialog = null;
},
hideDialog: function() {
dw_davcard__modals.$dialog.empty();
dw_davcard__modals.$dialog.remove();
dw_davcard__modals.$dialog = null;
},
showDialog : function(confirm)
{
if(dw_davcard__modals.$confirmDialog)
return;
var dialogButtons = {};
var title = '';
if(confirm)
{
title = LANG.plugins.davcard['confirmation'];
var pageid = dw_davcard__modals.page;
dialogButtons[LANG.plugins.davcard['yes']] = function() {
jQuery.post(
DOKU_BASE + 'lib/exe/ajax.php',
{
call: 'plugin_davcard',
id: pageid,
page: dw_davcard__modals.page,
action: dw_davcard__modals.action,
params: {
uri: dw_davcard__modals.uri
},
sectok: JSINFO.plugin.davcard['sectok']
},
function(data)
{
dw_davcard__modals.completeCb(data);
}
);
dw_davcard__modals.hideDialog();
};
dialogButtons[LANG.plugins.davcard['cancel']] = function() {
dw_davcard__modals.hideDialog();
};
}
else
{
title = LANG.plugins.davcard['info'];
dialogButtons[LANG.plugins.davcard['ok']] = function() {
dw_davcard__modals.hideDialog();
};
}
dw_davcard__modals.$dialog = jQuery(document.createElement('div'))
.dialog({
autoOpen: false,
draggable: true,
//fix for dragging: http://stackoverflow.com/questions/17247486/jquery-ui-dialog-dragging-issues
drag: function(event, ui) {
var fixPix = jQuery(document).scrollTop();
iObj = ui.position;
iObj.top = iObj.top - fixPix;
jQuery(this).closest(".ui-dialog").css("top", iObj.top + "px");
},
title: title,
resizable: true,
buttons: dialogButtons,
})
.html(
'<div>' + dw_davcard__modals.msg + '</div>'
)
.parent()
.attr('id','dw_davcard__confirm')
.show()
.appendTo('.dokuwiki:first');
jQuery('#dw_davcard__confirm').position({
my: "center",
at: "center",
of: window
});
// attach event handlers
jQuery('#dw_davcard__confirm .ui-dialog-titlebar-close').click(function(){
dw_davcard__modals.hideDialog();
});
},
};

File Metadata

Mime Type
text/plain
Expires
Thu, Jan 23, 6:13 PM (25 m, 52 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
926237
Default Alt Text
script.js (11 KB)

Event Timeline