Commit b1b0d213 authored by Hermann Mayer's avatar Hermann Mayer

Some refactoring on the editor controller. Added JS classes to handle dynamic…

Some refactoring on the editor controller. Added JS classes to handle dynamic changes on these components. Designed a nice frontend for Sidebar Controller. Added Breadcrumb functionality.
parent 9f90a73a
......@@ -23,6 +23,7 @@ class AppKernel extends Kernel
new Knp\Bundle\MarkdownBundle\KnpMarkdownBundle(),
new Jity\HomepageBundle\JityHomepageBundle(),
new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
new Xi\Bundle\BreadcrumbsBundle\XiBreadcrumbsBundle(),
);
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
......
{% if breadcrumbs|length %}
<ul class="breadcrumb">
{% for bc in breadcrumbs %}
{% if loop.last or not bc.url %}
<li class="active">{{ bc.label|trans }}</li>
{% else %}
<li><a href="{{ bc.url }}">{{ bc.label|trans }}</a> <span class="divider">/</span></li>
{% endif %}
{% endfor %}
</ul>
{% endif %}
No preview for this file type
......@@ -18,7 +18,7 @@
"symfony/symfony": "2.1.*",
"doctrine/orm": ">=2.2.3,<2.4-dev",
"doctrine/doctrine-bundle": "1.0.*",
"twig/twig": "1.9.*",
"twig/twig": "1.*",
"twig/extensions": "1.0.*",
"symfony/assetic-bundle": "2.1.*",
"symfony/swiftmailer-bundle": "2.1.*",
......@@ -31,7 +31,8 @@
"doctrine/doctrine-fixtures-bundle": "dev-master",
"doctrine/data-fixtures": "dev-master",
"knplabs/knp-markdown-bundle": "dev-master",
"stof/doctrine-extensions-bundle": "dev-master"
"stof/doctrine-extensions-bundle": "dev-master",
"xi/breadcrumbs-bundle": "dev-master"
},
"scripts": {
"post-install-cmd": [
......
{
"hash": "8f627fcee2e68ff16db3137e5bb3f3bf",
"hash": "9dfcd511dbc0d40724c84829dc10dea6",
"packages": [
{
"name": "doctrine/common",
......@@ -1411,26 +1411,26 @@
},
{
"name": "twig/twig",
"version": "v1.9.2",
"version": "v1.10.0",
"source": {
"type": "git",
"url": "git://github.com/fabpot/Twig.git",
"reference": "v1.9.2"
"reference": "v1.10.0"
},
"dist": {
"type": "zip",
"url": "https://github.com/fabpot/Twig/zipball/v1.9.2",
"reference": "v1.9.2",
"url": "https://github.com/fabpot/Twig/zipball/v1.10.0",
"reference": "v1.10.0",
"shasum": ""
},
"require": {
"php": ">=5.2.4"
},
"time": "2012-08-25 17:32:57",
"time": "2012-09-28 20:11:39",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.9-dev"
"dev-master": "1.10-dev"
}
},
"installation-source": "dist",
......@@ -1457,6 +1457,62 @@
"keywords": [
"templating"
]
},
{
"name": "xi/breadcrumbs-bundle",
"version": "dev-master",
"target-dir": "Xi/Bundle/BreadcrumbsBundle",
"source": {
"type": "git",
"url": "git://github.com/xi-project/xi-bundle-breadcrumbs.git",
"reference": "42fc73bcd9870deb793b4eb51ba96908ba1ed6a3"
},
"dist": {
"type": "zip",
"url": "https://github.com/xi-project/xi-bundle-breadcrumbs/zipball/42fc73bcd9870deb793b4eb51ba96908ba1ed6a3",
"reference": "42fc73bcd9870deb793b4eb51ba96908ba1ed6a3",
"shasum": ""
},
"require": {
"symfony/framework-bundle": ">=v2.0.14",
"symfony/locale": ">=v2.0.14",
"symfony/twig-bundle": ">=v2.0.14",
"symfony/yaml": ">=v2.0.14"
},
"require-dev": {
"besimple/i18n-routing-bundle": "=2.0.x-dev",
"symfony/browser-kit": ">=v2.0.14",
"symfony/class-loader": ">=v2.0.14",
"symfony/css-selector": ">=v2.0.14",
"symfony/finder": ">=v2.0.14"
},
"suggest": {
"besimple/i18n-routing-bundle": "Enables internationalised routes and breaadcrumbs."
},
"time": "1342533426",
"type": "symfony-bundle",
"installation-source": "source",
"autoload": {
"psr-0": {
"Xi\\Bundle\\BreadcrumbsBundle": ""
}
},
"license": [
"BSD"
],
"authors": [
{
"name": "xi-project",
"email": "xi.devs@gmail.com"
}
],
"description": "Xi breadcrumbs bundle for Symfony2 that utilises routes as a tree to build the breadcrumbs in order to not pollute the controller actions with repetitive breadcrumbs code.",
"keywords": [
"routing",
"internationalisation",
"breadcrumbs",
"Xi"
]
}
],
"packages-dev": null,
......@@ -1468,6 +1524,7 @@
"doctrine/doctrine-fixtures-bundle": 20,
"doctrine/data-fixtures": 20,
"knplabs/knp-markdown-bundle": 20,
"stof/doctrine-extensions-bundle": 20
"stof/doctrine-extensions-bundle": 20,
"xi/breadcrumbs-bundle": 20
}
}
......@@ -99,7 +99,7 @@ class EditorController extends Controller
* @access public
* @return void
*/
public function buildAction($syncElement, $title = 'Texteditor', $mode = 'markdown')
public function buildAction($syncElement = '', $title = 'Texteditor', $mode = 'markdown')
{
return $this->render('JityHomepageBundle:Editor:editor.html.twig', array(
'syncElement' => $syncElement,
......
admin_dashboard:
pattern: /
defaults: { _controller: JityHomepageBundle:Admin:showDashboard }
......@@ -23,3 +23,4 @@ register_done:
register_validate:
pattern: /register/validate/{userId}/{salt}
defaults: { _controller: JityHomepageBundle:Security:validateEmail }
author_dashboard:
pattern: /
defaults: { _controller: JityHomepageBundle:Author:showDashboard }
defaults: { _controller: JityHomepageBundle:Author:showDashboard, label: "Autorenbereich" }
author_category:
pattern: /
defaults: { _controller: "JityHomepageBundle:Category:index" }
defaults: { _controller: "JityHomepageBundle:Category:index", label: "Kategorien", parent: "author_dashboard" }
author_category_show:
pattern: /{id}/show
defaults: { _controller: "JityHomepageBundle:Category:show" }
defaults: { _controller: "JityHomepageBundle:Category:show", label: "Details", parent: "author_category" }
author_category_new:
pattern: /new
defaults: { _controller: "JityHomepageBundle:Category:new" }
defaults: { _controller: "JityHomepageBundle:Category:new", label: "Anlegen", parent: "author_category" }
author_category_create:
pattern: /create
......@@ -17,7 +17,7 @@ author_category_create:
author_category_edit:
pattern: /{id}/edit
defaults: { _controller: "JityHomepageBundle:Category:edit" }
defaults: { _controller: "JityHomepageBundle:Category:edit", label: "Bearbeiten", parent: "author_category" }
author_category_update:
pattern: /{id}/update
......@@ -28,3 +28,4 @@ author_category_delete:
pattern: /{id}/delete
defaults: { _controller: "JityHomepageBundle:Category:delete" }
requirements: { _method: post }
author_page:
pattern: /
defaults: { _controller: "JityHomepageBundle:Page:index" }
defaults: { _controller: "JityHomepageBundle:Page:index", label: "Seiten", parent: "author_dashboard" }
author_page_show:
pattern: /{id}/show
defaults: { _controller: "JityHomepageBundle:Page:show" }
defaults: { _controller: "JityHomepageBundle:Page:show", label: "Details", parent: "author_page" }
author_page_new:
pattern: /new
defaults: { _controller: "JityHomepageBundle:Page:new" }
defaults: { _controller: "JityHomepageBundle:Page:new", label: "Anlegen", parent: "author_page" }
author_page_create:
pattern: /create
......@@ -17,7 +17,7 @@ author_page_create:
author_page_edit:
pattern: /{id}/edit
defaults: { _controller: "JityHomepageBundle:Page:edit" }
defaults: { _controller: "JityHomepageBundle:Page:edit", label: "Bearbeiten", parent: "author_page" }
author_page_update:
pattern: /{id}/update
......@@ -28,3 +28,4 @@ author_page_delete:
pattern: /{id}/delete
defaults: { _controller: "JityHomepageBundle:Page:delete" }
requirements: { _method: post }
author_sidebar:
pattern: /
defaults: { _controller: "JityHomepageBundle:Sidebar:index" }
defaults: { _controller: "JityHomepageBundle:Sidebar:index", label: "Sidebars", parent: "author_dashboard" }
author_sidebar_show:
pattern: /{id}/show
defaults: { _controller: "JityHomepageBundle:Sidebar:show" }
defaults: { _controller: "JityHomepageBundle:Sidebar:show", label: "Details", parent: "author_sidebar" }
author_sidebar_new:
pattern: /new
defaults: { _controller: "JityHomepageBundle:Sidebar:new" }
defaults: { _controller: "JityHomepageBundle:Sidebar:new", label: "Anlegen", parent: "author_sidebar" }
author_sidebar_create:
pattern: /create
......@@ -17,7 +17,7 @@ author_sidebar_create:
author_sidebar_edit:
pattern: /{id}/edit
defaults: { _controller: "JityHomepageBundle:Sidebar:edit" }
defaults: { _controller: "JityHomepageBundle:Sidebar:edit", label: "Bearbeiten", parent: "author_sidebar" }
author_sidebar_update:
pattern: /{id}/update
......@@ -28,3 +28,4 @@ author_sidebar_delete:
pattern: /{id}/delete
defaults: { _controller: "JityHomepageBundle:Sidebar:delete" }
requirements: { _method: post }
user_dashboard:
pattern: /
defaults: { _controller: JityHomepageBundle:User:showDashboard }
defaults: { _controller: JityHomepageBundle:User:showDashboard, label: "Benutzer Profil" }
user_edit:
pattern: /edit/{mode}
defaults: { _controller: JityHomepageBundle:User:edit }
defaults: { _controller: JityHomepageBundle:User:edit, label: "Bearbeiten", parent: "user_dashboard" }
user_update:
pattern: /update/{mode}
defaults: { _controller: "JityHomepageBundle:User:update" }
requirements: { _method: post }
......@@ -162,8 +162,11 @@ p {
#sidebar {
border-left: 2px solid #722C0F;
padding-left: 20px;
margin-right: -22px;
margin-left: 20px;
}
#sidebar-wrapper {
padding-left: 20px;
}
#sidebar .btn {
......@@ -219,6 +222,16 @@ legend, .form_embedded_label {
padding-bottom: 8px;
}
.h1 {
font-size: 26px;
}
.h2 {
font-size: 20px;
}
.h3 {
font-size: 14px;
}
textarea, input[type="text"], input[type="password"], input[type="datetime"],
input[type="datetime-local"], input[type="date"], input[type="month"],
input[type="time"], input[type="week"], input[type="number"], input[type="email"],
......@@ -363,6 +376,9 @@ hr {
margin-top: 30px;
padding: 20px;
position: relative;
padding-left: 25px;
padding-right: 59px;
}
.sortable .dragbar {
......@@ -377,15 +393,22 @@ hr {
border-right: 1px solid #282624;
}
.sortable .dragbar div {
font-weight: 200;
left: -93px;
position: absolute;
top: 90px;
transform: rotate(-90deg);
width: 200px;
}
.sortable .controllpanel {
position: absolute;
top: 0;
right: 0;
width: 100px;
height: 33px;
width: 44px;
border-radius: 6px 6px 6px 6px;
padding: 5px;
padding-left: -5px;
background-color: #0F0F0F;
border-left: 1px solid #282624;
......@@ -393,6 +416,29 @@ hr {
}
.sortable .controllpanel .btn {
margin-left: 5px;
margin-top: 0px !important;
}
.ui-state-highlight {
box-shadow: inset 0px 0px 20px #000000;
background-color: #181818;
border-radius: 6px 6px 6px 6px;
margin-top: 30px;
height: 6em;
line-height: 1.2em;
border-bottom: 1px solid #515151;
border-right: 1px solid #515151;
}
.breadcrumb {
background-image: linear-gradient(to bottom, #222222, #282624);
background-color: #282624;
}
.breadcrumb li {
text-shadow: 0 1px 0 #000000;
}
......@@ -11,15 +11,18 @@
{% if sections %}
<div class="span8">
{% else %}
<div class="span11">
<div class="span12">
{% endif %}
{{ xi_breadcrumbs() }}
{{ parent() }}
{% block layout_content %}{% endblock %}
</div>
{% if sections %}
<div id="sidebar" class="span4">
<div>
<div id="sidebar-wrapper">
{% block sidebar %}{% endblock %}
</div>
</div>
......
......@@ -18,37 +18,57 @@
<script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$(document).ready(function() {
$(document).ready(function() {
//
// # Javascript class for the ace editor
// # With the help of this class you can change
// # the syncElement dynamically on the fly.
//
editor = {
// Build new Editor instance
var editor = ace.edit("editor");
editor.setTheme("ace/theme/tomorrow_night");
editor.getSession().setMode("ace/mode/{{ mode }}");
obj: undefined,
syncElement: '{{ syncElement|raw }}',
// Event hook for displaying
$('#editor_modal').on('shown', function () {
configure: function() {
// Build new Editor instance
this.obj = ace.edit("editor");
this.obj.setTheme("ace/theme/tomorrow_night");
this.obj.getSession().setMode("ace/mode/{{ mode }}");
// Focus on editor on modal show
editor.focus();
document.getElementById('editor').style.fontSize='14px';
// // To count total no. of lines
// var lines = editor.getSession().getValue().split("\n").length;
$('#editor_modal').on('show', {editor: this}, function (e) {
// // Go to end of document
// editor.gotoLine(lines);
});
var editor = e.data.editor;
var se = $(editor.syncElement);
// Sync editor with textarea
document.getElementById('editor').style.fontSize='14px';
editor.obj.getSession().setValue(se.val());
});
var textarea = $('{{ syncElement|raw }}');
editor.getSession().setValue(textarea.val());
$('#editor_modal').on('shown', function () {
editor.getSession().on('change', function(){
textarea.val(editor.getSession().getValue());
});
});
editor.obj.focus();
editor.obj.gotoLine(1);
editor.obj.getSelection().moveCursorLineEnd();
editor.obj.getSession().on('change', function(){
var se = $(editor.syncElement);
se.val(editor.obj.getSession().getValue());
});
});
},
setSyncElement: function(syncElement) {
this.syncElement = syncElement;
}
};
// Run the configure method of our editor class
editor.configure();
});
</script>
......@@ -50,6 +50,12 @@ $(document).ready(function() {
var el = $('#' + {{ name }}Modal.name + '_btn_' + cur.id);
if (false == cur.visible) {
el.hide();
} else {
el.show();
}
if (cur.class) {
el.attr('class', el.attr('class') + ' ' + cur.class);
}
......
......@@ -54,9 +54,6 @@
<div class="dragbar"></div>
<div class="controllpanel">
<a class="btn btn-danger btn-add" title="Neues Element hinzufügen" href="#">
<i class="icon-white icon-plus"></i>
</a>
<a class="btn btn-danger btn-remove" title="Entfernen" href="#">
<i class="icon-white icon-remove"></i>
</a>
......@@ -75,68 +72,5 @@
</div>
{% endspaceless %}
{% render 'JityHomepageBundle:Editor:modal' with {
'name': 'confirm',
'label': '',
'enableJS': true,
'buttons': [
{
'id': 1,
},
{
'id': 2,
},
],
'body': '',
} %}
<script>
$(document).ready(function() {
$('.collection > div').sortable({
placeholder: "ui-state-highlight",
helper:'clone'
});
$('.btn-remove').click(function (e){
// Dont do anything on link clicking
e.preventDefault();
// Configure and run the modal
confirmModal
.setLabel('Bestätigung der Löschaktion')
.setBody('Möchten Sie dieses Element wirklich löschen?')
.setButtons([
{
id: 1,
class: 'btn-danger',
icon: 'icon-share-alt',
value: 'Abbrechen'
},
{
id: 2,
class: 'btn-primary',
icon: 'icon-ok',
value: 'Löschen',
data: this,
click: function (data){
var el = $(data).closest('.sortable');
el.slideUp(function() {
// At end of sliding remove element from dom
el.remove();
});
}
}
])
.show()
;
});
});
</script>
{% endblock collection_widget %}
<h1>Sidebar edit</h1>
<form action="{{ path('author_sidebar_update', { 'id': entity.id }) }}" method="post" {{ form_enctype(edit_form) }}>
{{ form_widget(edit_form) }}
<p>
<button type="submit">Edit</button>
</p>
</form>
<ul class="record_actions">
<li>
<a href="{{ path('author_sidebar') }}">
Back to the list
</a>
</li>
<li>
<form action="{{ path('author_sidebar_delete', { 'id': entity.id }) }}" method="post">
{{ form_widget(delete_form) }}
<button type="submit">Delete</button>
</form>
</li>
</ul>
{% extends 'JityHomepageBundle:Default:layout.html.twig' %}
{% form_theme edit_form 'JityHomepageBundle:Form:fields.html.twig' %}
{% block layout_content %}
<form novalidate action="{{ path('author_page_update', { 'id': entity.id }) }}" method="post" {{ form_enctype(edit_form) }} class="form-horizontal hero-unit">
<legend>Sidebar bearbeiten</legend>
{{ form_widget(edit_form) }}
<div class="form-actions">
<button type="submit" class="btn btn-primary">
<i class="icon-ok icon-white"></i>
Speichern
</button>
<a href="{{ path('author_page') }}" class="btn btn-danger">
<i class="icon-share-alt icon-white"></i>
Zurück zur Liste
</a>
<a href="javascript:document.delete_form.submit();" class="btn btn-danger">
<i class="icon-remove icon-white"></i>
Löschen
</a>
</div>
</form>
<form name="delete_form" action="{{ path('author_sidebar_delete', { 'id': entity.id }) }}" method="post" >
{{ form_widget(delete_form) }}
</form>
{% include 'JityHomepageBundle:Sidebar:usability.html.twig' %}
{% endblock %}
......@@ -26,5 +26,7 @@
</form>
{% include 'JityHomepageBundle:Sidebar:usability.html.twig' %}
{% endblock %}
{% render 'JityHomepageBundle:Editor:build' %}
{% render 'JityHomepageBundle:Editor:modal' with {
'name': 'confirm',
'label': '',
'enableJS': true,
'buttons': [
{
'id': 1,
},
{
'id': 2,
},
],
'body': '',
} %}
<script>
$('textarea[data-target="#editor_modal"]').bind('focus', function(){
editor.setSyncElement('#' + $(this).attr('id'));
});
$('.form_embedded_label').html($('.form_embedded_label').html() + '<div class="pull-right">'
+ '<a href="#" title="Neues Element hinzufügen" class="btn btn-small btn-danger" id="section_btn_add">'
+ '<i class="icon-white icon-plus"></i>'
+ '</a>'
+ '</div>'
);
$('.collection > div').sortable({
placeholder: "ui-state-highlight",
helper:'clone'
});
$('.btn-remove').click(function (e){