margin: 0.5em 1em;
}
+.change-notification {
+ color: red;
+}
function loadPanel(target, url) {
console.log('ajax', url, 'into', target);
+ $('.change-notification', $(target).parent()).fadeOut();
$(document).trigger('panel:unload', target);
$.ajax({
url: url,
$(target).html(data);
console.log(target, 'triggering panel:load');
$(document).trigger('panel:load', target);
- // panel(target);
},
error: function(request, textStatus, errorThrown) {
console.log('ajax', url, target, 'error:', textStatus, errorThrown);
<div id="panels">
<div id="left-panel-wrap" class="panel-wrap">
<div id="left-panel-toolbar" class="panel-toolbar">
- <label for="select-left-panel">Lewy panel:</label>
- <select name="select-left-panel" id="select-left-panel">
- <option value="{% url xmleditor_panel hash %}">Edytor XML</option>
- <option value="{% url htmleditor_panel hash %}">Edytor HTML</option>
- <option value="{% url gallery_panel hash %}">Galeria skanów</option> </select>
+ <label for="select-left-panel">Lewy panel:</label>
+ <select name="select-left-panel" id="select-left-panel">
+ <option value="{% url xmleditor_panel hash %}">Edytor XML</option>
+ <option value="{% url htmleditor_panel hash %}">Edytor HTML</option>
+ <option value="{% url gallery_panel hash %}">Galeria skanów</option>
+ </select>
+ <strong class="change-notification" style="display: none">Zmieniono!</strong>
</div>
<div id="left-panel-content" class="panel-content"></div>
<button class="panel-slider"> </button>
</div>
<div id="right-panel-wrap" class="panel-wrap last-panel">
<div id="right-panel-toolbar" class="panel-toolbar">
- <label for="select-right-panel">Prawy panel:</label>
+ <label for="select-right-panel">Prawy panel:</label>
<select name="select-right-panel" id="select-right-panel">
- <option value="{% url xmleditor_panel hash %}">Edytor XML</option>
- <option value="{% url htmleditor_panel hash %}">Edytor HTML</option>
- <option value="{% url gallery_panel hash %}">Galeria skanów</option>
+ <option value="{% url xmleditor_panel hash %}">Edytor XML</option>
+ <option value="{% url htmleditor_panel hash %}">Edytor HTML</option>
+ <option value="{% url gallery_panel hash %}">Galeria skanów</option>
</select>
+ <strong class="change-notification" style="display: none">Zmieniono!</strong>
</div>
<div id="right-panel-content" class="panel-content"></div>
</div>
</div>
<script type="text/javascript" charset="utf-8">
(function() {
- function resizeEditor(event, panel) {
- var panel = panel || event.data.panel;
- $('.htmleditor', panel).height($(panel).height());
- }
-
+ var id = Math.ceil(Math.random() * 1000000000);
+
panel(function(event, panel) {
- $(window).bind('resize', {'panel': panel}, resizeEditor);
- resizeEditor(null, panel);
- }, function(event, panel) {});
+ $(document).bind('panel:contentChanged.' + id, function(event, p) {
+ $('.change-notification', $(panel).parent()).fadeIn();
+ })
+ }, function(event, panel) {
+ $(document).unbind('panel:contentChanged.' + id);
+ });
})()
</script>
\ No newline at end of file
path: "/static/js/codemirror/",
stylesheet: "/static/css/xmlcolors.css",
parserConfig: {useHTMLKludges: false},
- initCallback: function() {
+ onChange: function() {
+ $(document).trigger('panel:contentChanged', panel);
+ },
+ initCallback: function(editor) {
// Toolbar
$('.toolbar-tabs li', panel).click(function() {
var id = $(this).attr('p:button-list');
var pos = editor.cursorPosition();
editor.selectLines(pos.line, pos.character + tag.length + 2);
}
+ $(document).trigger('panel:contentChanged', panel);
}
if ($(this).attr('p:key')) {
keys[$(this).attr('p:key')] = handler;