Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

re-edting of changed text works now; content-type text/css and text/j…

…avascript added; line feed to <br> replacement only for text/plain
  • Loading branch information...
commit 3d778842f136bc8e7c9b5739816bb6aea79f9d27 1 parent da52332
@amorgner amorgner authored
View
2  structr/structr-ui/src/main/java/org/structr/web/servlet/HtmlServlet.java
@@ -615,7 +615,7 @@ private void getContent(HttpServletRequest request, final String resourceId, fin
}
// replace newlines with <br /> for rendering
- if ((contentType == null || !contentType.equals("text/css")) && (content != null) && !content.isEmpty()) {
+ if ((contentType == null || contentType.equals("text/plain")) && (content != null) && !content.isEmpty()) {
content = content.replaceAll("[\\n]{1}", "<br />");
}
View
1  structr/structr-ui/src/main/webapp/structr/css/main.css
@@ -424,7 +424,6 @@ ul#previewTabs {
display: none;
}
-
.content .content_ {
display: inline-block;
width: 40%;
View
31 structr/structr-ui/src/main/webapp/structr/js/contents.js
@@ -101,12 +101,14 @@ var _Contents = {
div.append('<img title="Edit ' + content.name + ' [' + content.id + ']" alt="Edit ' + content.name + ' [' + content.id + ']" class="edit_icon button" src="icon/pencil.png">');
$('.edit_icon', div).on('click', function() {
+ var self = $(this);
+ var text = self.parent().find('.content_').text();
Structr.dialog('Edit content of ' + content.id, function() {
if (debug) console.log('content saved')
}, function() {
if (debug) console.log('cancelled')
});
- _Contents.editContent(this, content, $('#dialogBox .dialogText'));
+ _Contents.editContent(this, content, text, $('#dialogBox .dialogText'));
});
_Entities.appendEditPropertiesIcon(div, content);
@@ -114,13 +116,13 @@ var _Contents = {
return div;
},
- editContent : function (button, entity, element) {
+ editContent : function (button, entity, text, element) {
if (isDisabled(button)) return;
var div = element.append('<div class="editor"></div>');
if (debug) console.log(div);
var contentBox = $('.editor', element);
editor = CodeMirror(contentBox.get(0), {
- value: unescapeTags(entity.content),
+ value: unescapeTags(text),
mode: "htmlmixed",
lineNumbers: true,
onChange: function(cm, changes) {
@@ -146,20 +148,21 @@ var _Contents = {
});
element.append('<span class="' + entity.id + '_"><label for="contentTypeSelect">Content-Type:</label>'
- + '<select class="contentType_" id="contentTypeSelect">'
- + '<option value="text/plain">text/plain</option>'
- + '<option value="text/css">text/css</option>'
- + '<option value="text/markdown">text/markdown</option>'
- + '<option value="text/textile">text/textile</option>'
- + '<option value="text/mediawiki">text/mediawiki</option>'
- + '<option value="text/tracwiki">text/tracwiki</option>'
- + '<option value="text/confluence">text/confluence</option>'
- + '</select>'
- + '</span>');
+ + '<select class="contentType_" id="contentTypeSelect">'
+ + '<option value="text/plain">text/plain</option>'
+ + '<option value="text/css">text/css</option>'
+ + '<option value="text/javascript">text/javascript</option>'
+ + '<option value="text/markdown">text/markdown</option>'
+ + '<option value="text/textile">text/textile</option>'
+ + '<option value="text/mediawiki">text/mediawiki</option>'
+ + '<option value="text/tracwiki">text/tracwiki</option>'
+ + '<option value="text/confluence">text/confluence</option>'
+ + '</select>'
+ + '</span>');
Command.getProperty(entity.id, 'contentType', '#dialogBox');
var select = $('#contentTypeSelect', element);
select.on('change', function() {
- Command.setProperty(entity.id, 'contentType', select.val());
+ Command.setProperty(entity.id, 'contentType', select.val());
});
editor.id = entity.id;
View
64 structr/structr-ui/src/main/webapp/structr/js/init.js
@@ -71,6 +71,19 @@ $(document).ready(function() {
_Resources.resize();
});
+
+ $('#resources_').droppable({
+ accept: '.element, .content',
+ greedy: true,
+ hoverClass: 'nodeHover',
+ tolerance: 'pointer',
+ drop: function(event, ui) {
+
+ var self = $(this);
+ alert('dropped', self);
+ }
+ });
+
$('#components_').on('click', function() {
main.empty();
Structr.activateMenuEntry('components');
@@ -246,54 +259,7 @@ var Structr = {
}
}
},
- //
- // saveSession : function() {
- // alert('saveSession');
- //
- // if (lastMenuEntry && lastMenuEntry != 'logout') {
- //
- // $.cookie('structrLastMenuEntry', lastMenuEntry, {
- // expires: 7,
- // path: '/'
- // });
- //
- // if (debug) console.log('set cookie for active tab', activeTab);
- // $.cookie('structrActiveTab', activeTab, {
- // expires: 7,
- // path: '/'
- // });
- //
- // if (resources) $.cookie('structrResourcesVisible', resources.is(':visible'), {
- // expires: 7,
- // path: '/'
- // });
- //
- // if (components) $.cookie('structrComponentsVisible', components.is(':visible'), {
- // expires: 7,
- // path: '/'
- // });
- //
- // if (elements) $.cookie('structrElementsVisible', elements.is(':visible'), {
- // expires: 7,
- // path: '/'
- // });
- //
- // if (contents) $.cookie('structrContentsVisible', contents.is(':visible'), {
- // expires: 7,
- // path: '/'
- // });
- //
- // if (getExpanded()) {
- // console.log('storing expanded ids', getExpanded());
- // $.cookie('structrTreeExpandedIds', $.toJSON(getExpanded()), {
- // expires: 7,
- // path: '/'
- // });
- // }
- // }
- // //console.log('cooke value now: ', $.cookie('structrActiveTab'));
- // },
-
+
clearMain : function() {
main.empty();
},
@@ -425,7 +391,7 @@ var Structr = {
numberOfNodes : function(element) {
var n = ($(element).children('.node')).length;
- console.log('number of nodes in element', element, n);
+ if (debug) console.log('number of nodes in element', element, n);
return n
},
View
113 structr/structr-ui/src/main/webapp/structr/js/resources.js
@@ -716,9 +716,9 @@ var _Resources = {
if (!div) return false;
- console.log('appendElementElement div', div);
+ if (debug) console.log('appendElementElement div', div);
var pos = Structr.numberOfNodes($(div).parent())-1;
- console.log('pos', entity.id, pos);
+ if (debug) console.log('pos', entity.id, pos);
if (parentId) {
@@ -861,18 +861,22 @@ var _Resources = {
return div;
},
- appendComponentElement : function(component, parentId, componentId, resourceId, removeExisting, hasChildren) {
+ appendComponentElement : function(entity, parentId, componentId, resourceId, removeExisting, hasChildren) {
if (debug) console.log('Resources.appendComponentElement');
- var div = _Components.appendComponentElement(component, parentId, componentId, resourceId, removeExisting, hasChildren);
+ var div = _Components.appendComponentElement(entity, parentId, componentId, resourceId, removeExisting, hasChildren);
//console.log(div);
if (!div) return false;
+ console.log('appendComponentElement div', div);
+ var pos = Structr.numberOfNodes($(div).parent())-1;
+ console.log('pos', entity.id, pos);
+
if (parentId) {
- $('.delete_icon', div).replaceWith('<img title="Remove component \'' + component.name + '\' from resource ' + parentId + '" '
- + 'alt="Remove component ' + component.name + ' from ' + parentId + '" class="delete_icon button" src="' + _Components.delete_icon + '">');
+ $('.delete_icon', div).replaceWith('<img title="Remove component \'' + entity.name + '\' from resource ' + parentId + '" '
+ + 'alt="Remove component ' + entity.name + ' from ' + parentId + '" class="delete_icon button" src="' + _Components.delete_icon + '">');
$('.delete_icon', div).on('click', function() {
- Command.removeSourceFromTarget(component.id, parentId);
+ Command.removeSourceFromTarget(entity.id, parentId, componentId, resourceId, pos);
});
}
@@ -885,6 +889,13 @@ var _Resources = {
zIndex: 1,
helper: 'clone'
});
+ } else {
+ div.draggable({
+ containment: 'body',
+ revert: 'invalid',
+ zIndex: 1,
+ helper: 'clone'
+ });
}
var sorting = false;
@@ -969,14 +980,14 @@ var _Resources = {
},
appendContentElement : function(content, parentId, componentId, resourceId) {
- console.log('Resources.appendContentElement', content, parentId, componentId, resourceId);
+ if (debug) console.log('Resources.appendContentElement', content, parentId, componentId, resourceId);
var div = _Contents.appendContentElement(content, parentId, componentId, resourceId);
if (!div) return false;
- console.log('appendContentElement div', div);
+ if (debug) console.log('appendContentElement div', div);
var pos = Structr.numberOfNodes($(div).parent())-1;
- console.log('pos', content.id, pos);
+ if (debug) console.log('pos', content.id, pos);
//var div = Structr.node(content.id, parentId, componentId, resourceId, pos);
@@ -988,7 +999,7 @@ var _Resources = {
var self = $(this);
self.off('click');
self.off('mouseover');
- console.log('Command.removeSourceFromTarget', content.id, parentId, componentId, resourceId, pos);
+ if (debug) console.log('Command.removeSourceFromTarget', content.id, parentId, componentId, resourceId, pos);
Command.removeSourceFromTarget(content.id, parentId, componentId, resourceId, pos)
});
}
@@ -1023,45 +1034,45 @@ var _Resources = {
Command.removeSourceFromTarget(entityId, parentId, componentId, resourceId, pos);
},
-//
-// removeElementFromResource : function(entityId, parentId, componentId, resourceId, pos) {
-// if (debug) console.log('Resources.removeElementFromResource');
-//
-// var resource = Structr.node(resourceId);
-// var element = Structr.node(entityId, parentId, componentId, resourceId, pos);
-// //element.remove();
-//
-// if (!Structr.containsNodes(resource)) {
-// _Entities.removeExpandIcon(resource);
-// }
-//
-// var numberOfElements = $('.element', resource).size();
-// if (debug) console.log(numberOfElements);
-// if (numberOfElements == 0) {
-// enable($('.delete_icon', resource)[0]);
-// }
-// Command.removeSourceFromTarget(entityId, parentId, componentId, resourceId, pos);
-//
-// },
-//
-// removeContentFromElement : function(entityId, parentId, componentId, resourceId, pos) {
-//
-// var element = Structr.node(parentId, null, componentId, resourceId, pos);
-// var contentEl = Structr.node(entityId, parentId, componentId, resourceId, pos);
-// //contentEl.remove();
-//
-// if (!Structr.containsNodes(element)) {
-// _Entities.removeExpandIcon(element);
-// }
-//
-// var numberOfContents = $('.element', element).size();
-// if (debug) console.log(numberOfContents);
-// if (numberOfContents == 0) {
-// enable($('.delete_icon', element)[0]);
-// }
-// Command.removeSourceFromTarget(entityId, parentId, componentId, resourceId, pos);
-//
-// },
+ //
+ // removeElementFromResource : function(entityId, parentId, componentId, resourceId, pos) {
+ // if (debug) console.log('Resources.removeElementFromResource');
+ //
+ // var resource = Structr.node(resourceId);
+ // var element = Structr.node(entityId, parentId, componentId, resourceId, pos);
+ // //element.remove();
+ //
+ // if (!Structr.containsNodes(resource)) {
+ // _Entities.removeExpandIcon(resource);
+ // }
+ //
+ // var numberOfElements = $('.element', resource).size();
+ // if (debug) console.log(numberOfElements);
+ // if (numberOfElements == 0) {
+ // enable($('.delete_icon', resource)[0]);
+ // }
+ // Command.removeSourceFromTarget(entityId, parentId, componentId, resourceId, pos);
+ //
+ // },
+ //
+ // removeContentFromElement : function(entityId, parentId, componentId, resourceId, pos) {
+ //
+ // var element = Structr.node(parentId, null, componentId, resourceId, pos);
+ // var contentEl = Structr.node(entityId, parentId, componentId, resourceId, pos);
+ // //contentEl.remove();
+ //
+ // if (!Structr.containsNodes(element)) {
+ // _Entities.removeExpandIcon(element);
+ // }
+ //
+ // var numberOfContents = $('.element', element).size();
+ // if (debug) console.log(numberOfContents);
+ // if (numberOfContents == 0) {
+ // enable($('.delete_icon', element)[0]);
+ // }
+ // Command.removeSourceFromTarget(entityId, parentId, componentId, resourceId, pos);
+ //
+ // },
removeFrom : function(entityId, parentId, componentId, resourceId, pos) {
console.log('Resources.removeFrom', entityId, parentId, componentId, resourceId, pos);
@@ -1077,7 +1088,7 @@ var _Resources = {
if (!Structr.containsNodes(parent)) {
_Entities.removeExpandIcon(parent);
- //enable('.delete_icon', parent);
+ //enable('.delete_icon', parent);
}
View
7 structr/structr-ui/src/main/webapp/structr/js/websocket.js
@@ -248,12 +248,7 @@ function connect() {
if (debug) console.log('remove user from group');
_UsersAndGroups.removeUserFromGroup(entityId, parentId, position);
- } else if (entity.hasClass('component')) {
- if (debug) console.log('remove component from resource');
- _Resources.removeComponentFromResource(entityId, parentId, componentId, resourceId, position);
- _Resources.reloadPreviews();
-
- } else if (entity.hasClass('element') || entity.hasClass('content')) {
+ } else if (entity.hasClass('element') || entity.hasClass('content') || entity.hasClass('component')) {
if (debug) console.log('remove element from resource');
_Resources.removeFrom(entityId, parentId, componentId, resourceId, position);
_Resources.reloadPreviews();
Please sign in to comment.
Something went wrong with that request. Please try again.