From e6e1017c531add5a7a5cbd4e24dc38fce4da0ea0 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Tue, 7 Dec 2010 14:29:47 +0100 Subject: [PATCH 1/1] #977: slugify tool --- apps/toolbar/fixtures/initial_data.yaml | 14 ++++++++++++++ redakcja/static/js/button_scripts.js | 6 ++++++ 2 files changed, 20 insertions(+) diff --git a/apps/toolbar/fixtures/initial_data.yaml b/apps/toolbar/fixtures/initial_data.yaml index 21feb1f4..ba3148a6 100644 --- a/apps/toolbar/fixtures/initial_data.yaml +++ b/apps/toolbar/fixtures/initial_data.yaml @@ -684,6 +684,17 @@ tooltip: "frazy w j\u0119zykach innych ni\u017C polski/definiendum w przypisie" model: toolbar.button pk: 46 +- fields: + accesskey: '' + group: [2] + label: slug + link: '' + params: '[]' + scriptlet: slugify + slug: slug + tooltip: slugifikacja + model: toolbar.button + pk: 105 - fields: accesskey: '' group: [1] @@ -980,4 +991,7 @@ \r\n\r\n\r\n\r\n\r\n\r\n\r\npanel.fireEvent('contentChanged');"} model: toolbar.scriptlet pk: insert_stanza +- fields: {code: '-'} + model: toolbar.scriptlet + pk: slugify diff --git a/redakcja/static/js/button_scripts.js b/redakcja/static/js/button_scripts.js index ff17eea4..ef2b794d 100644 --- a/redakcja/static/js/button_scripts.js +++ b/redakcja/static/js/button_scripts.js @@ -282,6 +282,12 @@ function ScriptletCenter() done(output, move_forward, move_up); }.bind(this); + + this.scriptlets['slugify'] = function(context, params, text, move_forward, move_up, done) + { + done(slugify(text.replace(/_/g, '-')), move_forward, move_up); + }.bind(this); + } ScriptletCenter.prototype.callInteractive = function(opts) { -- 2.20.1