From: Łukasz Rekucki <lrekucki@gmail.com> Date: Fri, 4 Sep 2009 11:06:59 +0000 (+0200) Subject: Przyciski do zmiany czcionki. X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/1c64c03bd096ac6c92bee4361926611be3d22259?ds=inline;hp=-c Przyciski do zmiany czcionki. --- 1c64c03bd096ac6c92bee4361926611be3d22259 diff --git a/apps/toolbar/templates/toolbar/toolbar.html b/apps/toolbar/templates/toolbar/toolbar.html index 29528c16..21135305 100644 --- a/apps/toolbar/templates/toolbar/toolbar.html +++ b/apps/toolbar/templates/toolbar/toolbar.html @@ -21,7 +21,7 @@ ui:action-params="{{ button.params|escape }}" {% if button.key %}ui:hotkey="{{ button.key|keycode }}"{% endif %} {% if button.tooltip %}ui:tooltip="{{ button.tooltip }}"{% endif %} > - {{ button.label }} + {{ button.label|safe }} </button> {% endfor %} </p> diff --git a/dump_toolbar.sh b/dump_toolbar.sh new file mode 100755 index 00000000..3bac9fe6 --- /dev/null +++ b/dump_toolbar.sh @@ -0,0 +1 @@ +./project/manage.py dumpdata --format=xml toolbar > fixtures/przyciski.xml diff --git a/fixtures/przyciski.xml b/fixtures/przyciski.xml index a8ad2c19..287a0cc9 100644 --- a/fixtures/przyciski.xml +++ b/fixtures/przyciski.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<django-objects version="1.0"><object pk="2" model="toolbar.buttongroup"><field type="CharField" name="name">Autokorekta</field><field type="SlugField" name="slug">autokorekta</field><field type="IntegerField" name="position">0</field></object><object pk="1" model="toolbar.buttongroup"><field type="CharField" name="name">Formatowanie</field><field type="SlugField" name="slug">formatowanie</field><field type="IntegerField" name="position">0</field></object><object pk="4" model="toolbar.button"><field type="CharField" name="label">Novelpages</field><field type="SlugField" name="slug">novelpages</field><field type="TextField" name="params">({exprs: [ +<django-objects version="1.0"><object pk="2" model="toolbar.buttongroup"><field type="CharField" name="name">Autokorekta</field><field type="SlugField" name="slug">autokorekta</field><field type="IntegerField" name="position">0</field></object><object pk="1" model="toolbar.buttongroup"><field type="CharField" name="name">Formatowanie</field><field type="SlugField" name="slug">formatowanie</field><field type="IntegerField" name="position">0</field></object><object pk="3" model="toolbar.buttongroup"><field type="CharField" name="name">Widok</field><field type="SlugField" name="slug">display_options</field><field type="IntegerField" name="position">2</field></object><object pk="5" model="toolbar.button"><field type="CharField" name="label">A<sup>+</sup></field><field type="SlugField" name="slug">increase_font_size</field><field type="TextField" name="params">({change: 2})</field><field to="toolbar.scriptlet" name="scriptlet" rel="ManyToOneRel">codemirror_fontsize</field><field type="CharField" name="key">+</field><field type="CharField" name="tooltip">ZwiÄksz rozmiar czcionki.</field><field to="toolbar.buttongroup" name="group" rel="ManyToManyRel"><object pk="3"></object></field></object><object pk="6" model="toolbar.button"><field type="CharField" name="label">A<sup>-</sup></field><field type="SlugField" name="slug">descrease_font_size</field><field type="TextField" name="params">({change: -2})</field><field to="toolbar.scriptlet" name="scriptlet" rel="ManyToOneRel">codemirror_fontsize</field><field type="CharField" name="key">-</field><field type="CharField" name="tooltip">Zmniejsz rozmiar czcionki.</field><field to="toolbar.buttongroup" name="group" rel="ManyToManyRel"><object pk="3"></object></field></object><object pk="7" model="toolbar.button"><field type="CharField" name="label">A<sup>=</sup></field><field type="SlugField" name="slug">reset_font_size</field><field type="TextField" name="params">({fontSize: 13})</field><field to="toolbar.scriptlet" name="scriptlet" rel="ManyToOneRel">codemirror_fontsize</field><field type="CharField" name="key">=</field><field type="CharField" name="tooltip">PrzywrÃ³Ä orginalny rozmiar czcionki.</field><field to="toolbar.buttongroup" name="group" rel="ManyToManyRel"><object pk="3"></object></field></object><object pk="4" model="toolbar.button"><field type="CharField" name="label">Novelpages</field><field type="SlugField" name="slug">novelpages</field><field type="TextField" name="params">({exprs: [ ["\\,\\.\\.|\\.\\,\\.|\\.\\.\\,", "..."], ["â", ",,"] /* DOUBLE LOW-9 QUOTATION MARK */ ]}) @@ -50,4 +50,13 @@ else { cm.setLineContent(line, content); line = cm.nextLine(line); } while( !(line === false) ); +}</field></object><object pk="codemirror_fontsize" model="toolbar.scriptlet"><field type="TextField" name="code">var texteditor = panel.texteditor; +var frameBody = $('body', $(texteditor.frame).contents()); + +if(params.fontSize) { + frameBody.css('font-size', params.fontSize); +} +else { + var old_size = parseInt(frameBody.css('font-size')); + frameBody.css('font-size', old_size + (params.change || 0) ); }</field></object></django-objects> diff --git a/project/templates/explorer/panels/xmleditor.html b/project/templates/explorer/panels/xmleditor.html index 39a05e52..76018ca7 100644 --- a/project/templates/explorer/panels/xmleditor.html +++ b/project/templates/explorer/panels/xmleditor.html @@ -1,15 +1,9 @@ {% load toolbar_tags %} -<div class="change-font-size" style=""> - <div class="decrease-font-size">A<sup>-</sup></div> - <div class="increase-font-size">A<sup>+</sup></div> -</div> - <div class="iframe-container" style="position: absolute; top: 41pt; left:0px; right:0px; bottom: 0px;"> <textarea name="text">{{ text }}</textarea> </div> - {% toolbar %} <script type="text/javascript" charset="utf-8"> @@ -39,22 +33,8 @@ panel_hooks = { $.fbind(self, self.isHotkey) ); } }) - - $(texteditor.frame).css({width: '100%', height: '100%'}); - - - $('.decrease-font-size', panel).click(function() { - var frameBody = $('body', $(texteditor.frame).contents()); - console.log(frameBody.css('font-size')); - frameBody.css('font-size', parseInt(frameBody.css('font-size')) - 2); - }); - - $('.increase-font-size', panel).click(function() { - var frameBody = $('body', $(texteditor.frame).contents()); - console.log(frameBody.css('font-size')); - frameBody.css('font-size', parseInt(frameBody.css('font-size')) + 2); - }); + $(texteditor.frame).css({width: '100%', height: '100%'}); this.texteditor = texteditor; },