Skip to content

Commit

Permalink
doc() document the edit inline feature
Browse files Browse the repository at this point in the history
  • Loading branch information
batiste committed Dec 13, 2016
1 parent 306e3f4 commit 67e8944
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
1 change: 1 addition & 0 deletions doc/index.rst
Expand Up @@ -28,6 +28,7 @@ Table of content
placeholders.rst
installation.rst
display-content.rst
edit-content.rst
navigation-template-tags.rst

3rd-party-apps.rst
Expand Down
4 changes: 2 additions & 2 deletions doc/placeholders.rst
Expand Up @@ -134,8 +134,8 @@ The **shared** keyword

If you add the keyword **shared** the placeholder's content
will be the same for all the pages. In effect the placeholder is
no linked to any particular pages and editing it in one page change
it in all the other.
not linked to any page and editing it change
its content in all pages.

Template syntax example::

Expand Down
4 changes: 3 additions & 1 deletion example/templates/index.html
Expand Up @@ -96,7 +96,9 @@
{% block header %}
<h1>{% placeholder 'title' %}</h1>
<p class="lead">{% placeholder 'lead' %}</p>
<div>{% imageplaceholder 'header-image' %}</div>
{% if request.user.is_staff %}
<button>Change image: {% imageplaceholder 'header-image' %}</button>
{% endif %}
{% page_has_content 'header-image' current_page %}
{% imageplaceholder 'header-image' as image %}
<img src="{{ MEDIA_URL }}{{ image }}" class="img-responsive" alt="">
Expand Down
4 changes: 3 additions & 1 deletion pages/static/pages/css/inline-edit.css
@@ -1,9 +1,11 @@
.edit-placeholder:hover {

[data-placeholder-name]:hover {
outline: none;
border-color: #9ecaed;
box-shadow: 0 0 10px #9ecaed;
cursor:pointer;
}

#edit-overlay {
position:absolute;
background-color:#fff;
Expand Down
13 changes: 5 additions & 8 deletions pages/templates/pages/inline-edit.html
Expand Up @@ -12,12 +12,12 @@
<script>
var plc = $("*").contents().filter(function(){
return (this.nodeValue && this.nodeValue.startsWith("placeholder") && this.nodeType == Node.COMMENT_NODE)
})
});
var page_id = "{{ current_page.id }}";
var lang = "{{ lang }}";

plc.each(function(i, el) {
$(el.parentNode).addClass('edit-placeholder');
$(el.parentNode).attr('data-placeholder-name', el.nodeValue.split(";")[1]);
$(el.parentNode).attr('data-page-id', el.nodeValue.split(";")[2]);
$(el.parentNode).attr('data-language', el.nodeValue.split(";")[3]);
$(el).remove();
});

Expand All @@ -36,13 +36,10 @@
//overlay.find('form').submit();
});

$(document).on('click', '.edit-placeholder', function(){
$(document).on('click', '[data-placeholder-name]', function(){
element = $(this);
overlay.show();
name = $(this).attr('data-placeholder-name');
page_id = $(this).attr('data-page-id');
lang = $(this).attr('data-language');


var modify_url = '{% url "admin:page-modify-placeholder" current_page.id %}';
modify_url = modify_url + '?content_type=' + name + '&language_id=' + lang
Expand Down

0 comments on commit 67e8944

Please sign in to comment.