Page MenuHomePhabricator

No OneTemporary

diff --git a/plugin.info.txt b/plugin.info.txt
--- a/plugin.info.txt
+++ b/plugin.info.txt
@@ -1,7 +1,7 @@
base metaeditor
author Andreas Boehler
email dev@aboehler.at
-date 2016-04-21
+date 2016-05-15
name Meta Data Editor
desc Edit metadata of pages
url http://www.dokuwiki.org/plugin:metaeditor
diff --git a/script.js b/script.js
--- a/script.js
+++ b/script.js
@@ -1,415 +1,436 @@
/* DOKUWIKI:include_once jstree.js */
jQuery(function()
{
var selectedPageId = null;
var selectedNode = null;
var selectedNodePath = null;
var selectedNodeValue = null;
var sectok = jQuery('#fileTree').data('sectok');
if(!sectok) return;
jqModalManager.init();
jQuery('#event_save').click(function() {
var newVal = jQuery('#event_value').val();
jQuery.post(
DOKU_BASE + 'lib/exe/ajax.php',
{
call: 'plugin_metaeditor',
q: 'setMetaValue',
r: selectedPageId,
sectok: sectok,
opts: {
key : selectedNode,
oldval : selectedNodeValue,
newval : newVal
}
},
function(data) {
jqModalManager.msg = data[1];
jqModalManager.showInfoDialog();
selectedNodeValue = newVal;
}
);
});
function refreshMetaTree() {
jQuery.post(
DOKU_BASE + 'lib/exe/ajax.php',
{
call: 'plugin_metaeditor',
q: 'getMeta',
r: selectedPageId,
sectok: sectok
},
function(data) {
jQuery('#event_path').html('');
jQuery('#event_value').val('...');
selectedNodePath = null;
selectedNodeValue = null;
selectedNode = null;
jQuery('#metaTree').jstree(true).settings.core.data = data;
jQuery('#metaTree').jstree(true).refresh();
}
);
}
function customMenu(node) {
// The default set of all items
var items = {
/*renameItem: { // The "rename" menu item
label: "Rename",
action: function () {
alert('rename called');
}
},*/
deleteItem: { // The "delete" menu item
label: "Delete",
action: function () {
jqModalManager.data =
{
call : 'plugin_metaeditor',
q: 'deleteMetaValue',
r: selectedPageId,
sectok: sectok,
opts: {
key: selectedNodePath,
oldval: selectedNodeValue
}
};
jqModalManager.msg = "Do you really want to delete the selected node?<br>&nbsp;<br>";
jqModalManager.msg += "PageId: " + selectedPageId + "<br>";
jqModalManager.msg += "NodePath: " + selectedNodePath + "<br>";
jqModalManager.msg += "Value: " + selectedNodeValue;
jqModalManager.completeCb = function(data) {
jqModalManager.msg = data[1];
jqModalManager.showInfoDialog();
refreshMetaTree();
};
jqModalManager.showConfirmDialog();
}
},
createFolderItem: { // The "Create folder" menu item
label: "Create Folder",
action: function (data) {
var tree = jQuery("#metaTree").jstree(true);
var nodePath = tree.get_path(node);
if(node.li_attr['data-type'] == 'file')
{
var id = tree.get_parent(node);
var parentNode = tree.get_node(id);
nodePath = tree.get_path(parentNode);
}
jqModalManager.data =
{
call : 'plugin_metaeditor',
q: 'createMetaArray',
r: selectedPageId,
sectok: sectok,
opts: {
key : nodePath,
newval: null
}
};
jqModalManager.msg = "Create new folder<br>&nbsp;<br>";
jqModalManager.msg += "Parent: " + nodePath;
jqModalManager.completeCb = function(data) {
jqModalManager.msg = data[1];
jqModalManager.showInfoDialog();
refreshMetaTree();
};
jqModalManager.createValue = false;
jqModalManager.showCreateDialog();
}
},
createItem: { // The "Create" menu item
label: "Create Property",
action: function () {
var tree = jQuery("#metaTree").jstree(true);
var nodePath = tree.get_path(node);
if(node.li_attr['data-type'] == 'file')
{
var id = tree.get_parent(node);
var parentNode = tree.get_node(id);
nodePath = tree.get_path(parentNode);
}
jqModalManager.data =
{
call : 'plugin_metaeditor',
q: 'createMetaValue',
r: selectedPageId,
sectok: sectok,
opts: {
key : nodePath,
newkey: null,
newval: null
}
};
jqModalManager.msg = "Create new item<br>&nbsp;<br>";
jqModalManager.msg += "Parent: " + nodePath;
jqModalManager.completeCb = function(data) {
jqModalManager.msg = data[1];
jqModalManager.showInfoDialog();
refreshMetaTree();
};
jqModalManager.createValue = true;
jqModalManager.showCreateDialog();
}
}
};
return items;
}
jQuery('#metaTree').on('changed.jstree', function (e, data) {
var i, j, r;
if(data.selected.length != 1)
return;
var node = data.instance.get_node(data.selected[0]);
r = data.instance.get_path(data.selected[0]);
selectedNodePath = r;
if(node.li_attr['data-type'] == 'folder')
return;
//if(!data.instance.is_leaf(node))
// return;
selectedNode = r;
jQuery.post(
DOKU_BASE + 'lib/exe/ajax.php',
{
call: 'plugin_metaeditor',
q: 'getMetaValue',
r: selectedPageId,
sectok: sectok,
opts: {
key: r
}
},
function(data) {
jQuery('#event_path').html(selectedNode.join(':'));
jQuery('#event_value').val(data);
selectedNodeValue = data;
}
);
})
// create the instance
.jstree({
core : {
multiple: false,
},
plugins: ["wholerow", "contextmenu"],
contextmenu: { items: customMenu }
});
jQuery('#fileTree').on('changed.jstree', function (e, data) {
var i, j, r;
if(data.selected.length != 1)
return;
var node = data.instance.get_node(data.selected[0]);
if(!data.instance.is_leaf(node))
return;
r = node.text;
selectedPageId = r;
jQuery.post(
DOKU_BASE + 'lib/exe/ajax.php',
{
call: 'plugin_metaeditor',
q: 'getMeta',
sectok: sectok,
r: r
},
function(data) {
jQuery('#metaTree').jstree(true).settings.core.data = data;
jQuery('#metaTree').jstree(true).refresh();
}
);
})
// create the instance
.jstree({
core : {
multiple: false
},
plugins: ["wholerow"]
});
});
var jqModalManager = {
jqConfirmModal : null,
jqCreateModal : null,
jqInfoModal : null,
completeCb : null,
data : null,
msg : null,
createValue: false,
init : function()
{
},
showCreateDialog : function() {
jqModalManager.jqCreateModal = 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: "Create",
resizable: true,
buttons: {
Create: function() {
if(jqModalManager.createValue)
{
jqModalManager.data.opts.newkey = jQuery("#metaeditor__createInput").val();
jqModalManager.data.opts.newval = jQuery("#metaeditor__createValue").val();
}
else
{
jqModalManager.data.opts.newval = jQuery("#metaeditor__createInput").val();
}
jQuery.post(
DOKU_BASE + 'lib/exe/ajax.php',
jqModalManager.data,
function(data) {
jqModalManager.completeCb(data);
}
);
jqModalManager.hideCreateDialog();
},
Cancel: function() {
jqModalManager.hideCreateDialog();
}
}
})
.html(
'<div>' + jqModalManager.msg + '</div>' +
'<div>Name <input type="text" id="metaeditor__createInput"></div>' +
(jqModalManager.createValue ? '<div>Value <input type="text" id="metaeditor__createValue"></div>' : '')
)
.parent()
.attr('id','metaeditor__create')
.show()
.appendTo('.dokuwiki:first');
jQuery('#metaeditor__createInput').focus();
jQuery('#metaeditor__create').position({
my: "center",
at: "center",
of: window
});
// attach event handlers
jQuery('#metaeditor__create .ui-dialog-titlebar-close').click(function(){
jqModalManager.hideCreateDialog();
});
},
showInfoDialog : function() {
jqModalManager.jqInfoModal = 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: "Info",
resizable: true,
buttons: {
OK: function() {
jqModalManager.hideInfoDialog();
}
}
})
.html(
'<div>' + jqModalManager.msg + '</div>'
)
.parent()
.attr('id','metaeditor__info')
.show()
.appendTo('.dokuwiki:first');
jQuery('#metaeditor__info').position({
my: "center",
at: "center",
of: window
});
// attach event handlers
jQuery('#metaeditor__info .ui-dialog-titlebar-close').click(function(){
jqModalManager.hideInfoDialog();
});
},
showConfirmDialog : function() {
jqModalManager.jqConfirmModal = 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: "Confirmation",
resizable: true,
buttons: {
Yes: function() {
jQuery.post(
DOKU_BASE + 'lib/exe/ajax.php',
jqModalManager.data,
function(data) {
jqModalManager.completeCb(data);
}
);
jqModalManager.hideConfirmDialog();
},
Cancel: function() {
jqModalManager.hideConfirmDialog();
}
}
})
.html(
'<div>' + jqModalManager.msg + '</div>'
)
.parent()
.attr('id','metaeditor__confirm')
.show()
.appendTo('.dokuwiki:first');
jQuery('#metaeditor__confirm').position({
my: "center",
at: "center",
of: window
});
// attach event handlers
jQuery('#metaeditor__confirm .ui-dialog-titlebar-close').click(function(){
jqModalManager.hideConfirmDialog();
});
},
hideConfirmDialog : function() {
jqModalManager.jqConfirmModal.empty();
jqModalManager.jqConfirmModal.remove();
jqModalManager.jqConfirmModal = null;
},
hideCreateDialog : function() {
jqModalManager.jqCreateModal.empty();
jqModalManager.jqCreateModal.remove();
jqModalManager.jqCreateModal = null;
},
hideInfoDialog : function() {
jqModalManager.jqInfoModal.empty();
jqModalManager.jqInfoModal.remove();
jqModalManager.jqInfoModal = null;
}
};

File Metadata

Mime Type
text/x-diff
Expires
Thu, Dec 5, 2:38 PM (1 d, 4 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
524827
Default Alt Text
(13 KB)

Event Timeline