diff --git a/app/assets/javascripts/admin.js b/app/assets/javascripts/admin.js index fe83282..5f5a2fd 100644 --- a/app/assets/javascripts/admin.js +++ b/app/assets/javascripts/admin.js @@ -1,19 +1,19 @@ /* -*= require ./shared/jquery.js -*= require ./shared/jquery-ui.js +=require jquery += require jquery.ui.all -*= require ./shared/jquery.strings.js -*= require ./shared/jquery.utils.js -*= require ./shared/ui.timepickr.js -*= require ./shared/modernizr.custom.39712.js +require ./shared/jquery.strings.js +require ./shared/jquery.utils.js +require ./shared/ui.timepickr.js +require ./shared/modernizr.custom.39712.js *= require jquery_ujs *=require_tree ./admin -*=require_tree ./wysihtml5 + *= require ./shared/raphael *= require ./shared/morris @@ -21,4 +21,16 @@ *= require_tree ./note_files + + + + */ + +$(document).ready(function(){ + + $(".raptor").editor({ + initialLocale: 'fr', + + }); +}); \ No newline at end of file diff --git a/app/assets/javascripts/admin/fr.js b/app/assets/javascripts/admin/fr.js new file mode 100644 index 0000000..6e6cf56 --- /dev/null +++ b/app/assets/javascripts/admin/fr.js @@ -0,0 +1,68 @@ +var RELANG = {}; +RELANG['fr'] = { + html: 'Code HTML', + video: 'Insérer une vidéo...', + image: 'Insérer une image...', + table: 'Tableau', + link: 'Lien', + link_insert: 'Insérer un lien...', + unlink: 'Supprimer le lien', + formatting: 'Styles', + paragraph: 'Paragraphe', + quote: 'Citation', + code: 'Code', + header1: 'Titre 1', + header2: 'Titre 2', + header3: 'Titre 3', + header4: 'Titre 4', + bold: 'Gras', + italic: 'Italique', + fontcolor: 'Couleur du texte', + backcolor: 'Couleur d\'arrière plan du texte', + unorderedlist: 'Liste à puces', + orderedlist: 'Liste numérotée', + outdent: 'Diminuer le trait', + indent: 'Augmenter le trait', + cancel: 'Annuler', + insert: 'Insérer', + save: 'Sauvegarder', + _delete: 'Supprimer', + insert_table: 'Insérer un tableau...', + insert_row_above: 'Ajouter une rangée au-dessus', + insert_row_below: 'Ajouter une rangée en-dessous', + insert_column_left: 'Ajouter une colonne à gauche', + insert_column_right: 'Ajouter une colonne à droite', + delete_column: 'Supprimer la colonne', + delete_row: 'Supprimer la rangée', + delete_table: 'Supprimer le tableau', + rows: 'Rangées', + columns: 'Colonnes', + add_head: 'Ajouter un en-tête', + delete_head: 'Supprimer l\'en-tête', + title: 'Titre', + image_position: 'Position', + none: 'Aucun', + left: 'Gauche', + right: 'Droite', + image_web_link: 'Adresse URL de l\'image', + text: 'Texte', + mailto: 'Courriel', + web: 'Adresse URL', + video_html_code: 'Code d\'intégration du vidéo', + file: 'Insérer un fichier...', + upload: 'Téléverser', + download: 'Télécharger', + choose: 'Choisir', + or_choose: 'Ou choisissez', + drop_file_here: 'Déposez le fichier ici', + align_left: 'Aligner à gauche', + align_center: 'Aligner au centre', + align_right: 'Aligner à droite', + align_justify: 'Justifier', + horizontalrule: 'Insérer une ligne horizontale', + deleted: 'Supprimé', + anchor: 'Ancre', + link_new_tab: 'Ouvrir le lien dans un nouvel onglet', + underline: 'Underline', + alignment: 'Alignment' +}; \ No newline at end of file diff --git a/app/assets/javascripts/admin/redactor.js b/app/assets/javascripts/admin/redactor.js new file mode 100755 index 0000000..08b8ccf --- /dev/null +++ b/app/assets/javascripts/admin/redactor.js @@ -0,0 +1,4210 @@ +/* + Redactor v8.2.2 + Updated: January 17, 2013 + + http://redactorjs.com/ + + Copyright (c) 2009-2013, Imperavi Inc. + License: http://redactorjs.com/license/ + + Usage: $('#content').redactor(); +*/ + +var rwindow, rdocument; + +if (typeof RELANG === 'undefined') +{ + var RELANG = {}; +} + +var RLANG = { + html: 'HTML', + video: 'Insert Video', + image: 'Insert Image', + table: 'Table', + link: 'Link', + link_insert: 'Insert link', + unlink: 'Unlink', + formatting: 'Formatting', + paragraph: 'Paragraph', + quote: 'Quote', + code: 'Code', + header1: 'Header 1', + header2: 'Header 2', + header3: 'Header 3', + header4: 'Header 4', + bold: 'Bold', + italic: 'Italic', + fontcolor: 'Font Color', + backcolor: 'Back Color', + unorderedlist: 'Unordered List', + orderedlist: 'Ordered List', + outdent: 'Outdent', + indent: 'Indent', + cancel: 'Cancel', + insert: 'Insert', + save: 'Save', + _delete: 'Delete', + insert_table: 'Insert Table', + insert_row_above: 'Add Row Above', + insert_row_below: 'Add Row Below', + insert_column_left: 'Add Column Left', + insert_column_right: 'Add Column Right', + delete_column: 'Delete Column', + delete_row: 'Delete Row', + delete_table: 'Delete Table', + rows: 'Rows', + columns: 'Columns', + add_head: 'Add Head', + delete_head: 'Delete Head', + title: 'Title', + image_position: 'Position', + none: 'None', + left: 'Left', + right: 'Right', + image_web_link: 'Image Web Link', + text: 'Text', + mailto: 'Email', + web: 'URL', + video_html_code: 'Video Embed Code', + file: 'Insert File', + upload: 'Upload', + download: 'Download', + choose: 'Choose', + or_choose: 'Or choose', + drop_file_here: 'Drop file here', + align_left: 'Align text to the left', + align_center: 'Center text', + align_right: 'Align text to the right', + align_justify: 'Justify text', + horizontalrule: 'Insert Horizontal Rule', + deleted: 'Deleted', + anchor: 'Anchor', + link_new_tab: 'Open link in new tab', + underline: 'Underline', + alignment: 'Alignment' +}; + +(function($){ + + // Plugin + jQuery.fn.redactor = function(option) + { + return this.each(function() + { + var $obj = $(this); + + var data = $obj.data('redactor'); + if (!data) + { + $obj.data('redactor', (data = new Redactor(this, option))); + } + }); + }; + + + // Initialization + var Redactor = function(element, options) + { + // Element + this.$el = $(element); + + // Lang + if (typeof options !== 'undefined' && typeof options.lang !== 'undefined' && options.lang !== 'en' && typeof RELANG[options.lang] !== 'undefined') + { + RLANG = RELANG[options.lang]; + } + + // Options + this.opts = $.extend({ + + iframe: false, + css: false, // url + + lang: 'en', + direction: 'ltr', // ltr or rtl + + callback: false, // function + keyupCallback: false, // function + keydownCallback: false, // function + execCommandCallback: false, // function + + plugins: false, + cleanup: true, + + focus: false, + tabindex: false, + autoresize: true, + minHeight: false, + fixed: false, + fixedTop: 0, // pixels + fixedBox: false, + source: true, + shortcuts: true, + + mobile: true, + air: false, // true or toolbar + wym: false, + + convertLinks: true, + convertDivs: true, + protocol: 'http://', // for links http or https or ftp or false + + autosave: false, // false or url + autosaveCallback: false, // function + interval: 60, // seconds + + imageGetJson: false, // url (ex. /folder/images.json ) or false + + imageUpload: false, // url + imageUploadCallback: false, // function + imageUploadErrorCallback: false, // function + + fileUpload: false, // url + fileUploadCallback: false, // function + fileUploadErrorCallback: false, // function + + uploadCrossDomain: false, + uploadFields: false, + + observeImages: true, + overlay: true, // modal overlay + + allowedTags: ["form", "input", "button", "select", "option", "datalist", "output", "textarea", "fieldset", "legend", + "section", "header", "hgroup", "aside", "footer", "article", "details", "nav", "progress", "time", "canvas", + "code", "span", "div", "label", "a", "br", "p", "b", "i", "del", "strike", "u", + "img", "video", "source", "track", "audio", "iframe", "object", "embed", "param", "blockquote", + "mark", "cite", "small", "ul", "ol", "li", "hr", "dl", "dt", "dd", "sup", "sub", + "big", "pre", "code", "figure", "figcaption", "strong", "em", "table", "tr", "td", + "th", "tbody", "thead", "tfoot", "h1", "h2", "h3", "h4", "h5", "h6"], + + toolbarExternal: false, // ID selector + + buttonsCustom: {}, + buttonsAdd: [], + buttons: ['html', '|', 'formatting', '|', 'bold', 'italic', 'deleted', '|', 'unorderedlist', 'orderedlist', 'outdent', 'indent', '|', + 'image', 'video', 'file', 'table', 'link', '|', + 'fontcolor', 'backcolor', '|', 'alignment', '|', 'horizontalrule'], // 'underline', 'alignleft', 'aligncenter', 'alignright', 'justify' + + airButtons: ['formatting', '|', 'bold', 'italic', 'deleted', '|', 'unorderedlist', 'orderedlist', 'outdent', 'indent', '|', 'fontcolor', 'backcolor'], + + formattingTags: ['p', 'blockquote', 'pre', 'h1', 'h2', 'h3', 'h4'], + + activeButtons: ['deleted', 'italic', 'bold', 'underline', 'unorderedlist', 'orderedlist'], // 'alignleft', 'aligncenter', 'alignright', 'justify' + activeButtonsStates: { + b: 'bold', + strong: 'bold', + i: 'italic', + em: 'italic', + del: 'deleted', + strike: 'deleted', + ul: 'unorderedlist', + ol: 'orderedlist', + u: 'underline' + }, + + colors: [ + '#ffffff', '#000000', '#eeece1', '#1f497d', '#4f81bd', '#c0504d', '#9bbb59', '#8064a2', '#4bacc6', '#f79646', '#ffff00', + '#f2f2f2', '#7f7f7f', '#ddd9c3', '#c6d9f0', '#dbe5f1', '#f2dcdb', '#ebf1dd', '#e5e0ec', '#dbeef3', '#fdeada', '#fff2ca', + '#d8d8d8', '#595959', '#c4bd97', '#8db3e2', '#b8cce4', '#e5b9b7', '#d7e3bc', '#ccc1d9', '#b7dde8', '#fbd5b5', '#ffe694', + '#bfbfbf', '#3f3f3f', '#938953', '#548dd4', '#95b3d7', '#d99694', '#c3d69b', '#b2a2c7', '#b7dde8', '#fac08f', '#f2c314', + '#a5a5a5', '#262626', '#494429', '#17365d', '#366092', '#953734', '#76923c', '#5f497a', '#92cddc', '#e36c09', '#c09100', + '#7f7f7f', '#0c0c0c', '#1d1b10', '#0f243e', '#244061', '#632423', '#4f6128', '#3f3151', '#31859b', '#974806', '#7f6000'], + + // private + emptyHtml: '
' + $(parent).html() + '
'); + $(parent).replaceWith(node); + } + else + { + this.execRun(cmd, 'p'); + } + } + else if ($(parent).get(0).tagName === 'P') + { + var parent2 = $(parent).parent(); + if ($(parent2).get(0).tagName === 'BLOCKQUOTE') + { + var node = $('' + $(parent).html() + '
'); + $(parent2).replaceWith(node); + this.setSelection(node[0], 0, node[0], 0); + } + else + { + if (this.browser('msie')) + { + var node = $('' + $(parent).html() + ''); + $(parent).replaceWith(node); + } + else + { + this.execRun(cmd, param); + } + } + } + else + { + this.execRun(cmd, param); + } + } + else if (cmd === 'formatblock' && (param === 'pre' || param === 'p')) + { + parent = this.getParentNode(); + + if ($(parent).get(0).tagName === 'PRE') + { + $(parent).replaceWith('
' + this.encodeEntities($(parent).text()) + '
'); + } + else + { + this.execRun(cmd, param); + } + } + else + { + if (cmd === 'inserthorizontalrule' && this.browser('msie')) + { + this.$editor.focus(); + } + + if (cmd === 'formatblock' && this.browser('mozilla')) + { + this.$editor.focus(); + } + + this.execRun(cmd, param); + } + + if (cmd === 'inserthorizontalrule') + { + this.$editor.find('hr').removeAttr('id'); + } + + this.syncCode(); + + if (this.oldIE()) + { + this.$editor.focus(); + } + + if (typeof this.opts.execCommandCallback === 'function') + { + this.opts.execCommandCallback(this, cmd); + } + + if (this.opts.air) + { + this.air.hide(); + } + } + catch (e) { } + }, + execRun: function(cmd, param) + { + if (cmd === 'formatblock' && this.browser('msie')) + { + param = '<' + param + '>'; + } + + this.document.execCommand(cmd, false, param); + }, + + // FORMAT NEW LINE + formatNewLine: function(e) + { + var parent = this.getParentNode(); + + if (parent.nodeName === 'DIV' && parent.className === 'redactor_editor') + { + var element = $(this.getCurrentNode()); + + if (element.get(0).tagName === 'DIV' && (element.html() === '' || element.html() === '').append(element.clone().get(0).childNodes);
+ element.replaceWith(newElement);
+ newElement.html('
');
+ this.setSelection(newElement[0], 0, newElement[0], 0);
+ }
+ }
+ },
+
+ // SAFARI SHIFT KEY + ENTER
+ safariShiftKeyEnter: function(e, key)
+ {
+ if (e.shiftKey && key === 13)
+ {
+ e.preventDefault();
+ this.insertNodeAtCaret($('
').get(0));
+ this.syncCode();
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ },
+
+ // FORMAT EMPTY
+ formatEmpty: function(e)
+ {
+ var html = $.trim(this.$editor.html());
+
+ if (this.browser('mozilla'))
+ {
+ html = html.replace(/
/i, '');
+ }
+
+ var thtml = html.replace(/<(?:.|\n)*?>/gm, '');
+
+ if (html === '' || thtml === '')
+ {
+ e.preventDefault();
+
+ var node = $(this.opts.emptyHtml).get(0);
+ this.$editor.html(node);
+ this.setSelection(node, 0, node, 0);
+
+ this.syncCode();
+ return false;
+ }
+ else
+ {
+ this.syncCode();
+ }
+ },
+
+ // PARAGRAPHY
+ paragraphy: function (str)
+ {
+ str = $.trim(str);
+ if (str === '' || str === '
$2
'); + } + + // inner functions + var X = function(x, a, b) { return x.replace(new RegExp(a, 'g'), b); }; + var R = function(a, b) { return X(str, a, b); }; + + // block elements + var blocks = '(table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|style|script|object|input|param|p|h[1-6])'; + + //str = '' + str;
+ str += '\n';
+
+ R('
\\s*
', '\n\n');
+ R('(<' + blocks + '[^>]*>)', '\n$1');
+ R('(' + blocks + '>)', '$1\n\n');
+ R('\r\n|\r', '\n'); // newlines
+ R('\n\n+', '\n\n'); // remove duplicates
+ R('\n?((.|\n)+?)$', '
$1
\n'); // including one at the end + R('\\s*?
', ''); // remove empty p + R('(
'); + R('
([^<]+)\\s*?((div|address|form)[^>]*>)', '
$1
$2'); + R('\\s*(?' + blocks + '[^>]*>)\\s*
', '$1'); + R('(
\\s*(?' + blocks + '[^>]*>)', '$1'); + R('(?' + blocks + '[^>]*>)\\s*
', '$1'); + R('(?' + blocks + '[^>]*>)\\s*)((.|\n)*?)', function(m0, m1, m2, m3) + { + return X(m1, '\\\\([\'\"\\\\])', '$1') + X(X(X(m3, '
', '\n'), '
|([\w\W]*?)<\/pre>/gi); + if (pre !== null) + { + $.each(pre, $.proxy(function(i,s) + { + var arr = s.match(/([\w\W]*?)<\/pre>/i); + arr[2] = this.encodeEntities(arr[2]); + html = html.replace(s, '' + arr[2] + ''); + }, this)); + } + + return html; + }, + encodeEntities: function(str) + { + str = String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"'); + return String(str).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"'); + }, + cleanupPre: function(s) + { + s = s.replace(/
/gi, '\n'); + s = s.replace(/<\/p>/gi, '\n'); + s = s.replace(/<\/div>/gi, '\n'); + + var tmp = this.document.createElement("div"); + tmp.innerHTML = s; + return tmp.textContent||tmp.innerText; + + }, + + + // PASTE CLEANUP + pasteCleanUp: function(html) + { + var parent = this.getParentNode(); + + // clean up pre + if ($(parent).get(0).tagName === 'PRE') + { + html = this.cleanupPre(html); + this.pasteCleanUpInsert(html); + return true; + } + + // remove comments and php tags + html = html.replace(/|<\?(?:php)?[\s\S]*?\?>/gi, ''); + + // remove nbsp + html = html.replace(/( ){2,}/gi, ' '); + + // remove google docs marker + html = html.replace(/([\w\W]*?)<\/b>/gi, "$2"); + + // strip tags + html = this.stripTags(html); + + // prevert + html = html.replace(/<\/td>/gi, '[td]'); + html = html.replace(/ <\/td>/gi, '[td]'); + html = html.replace(/ ', '', '']; + for (var i = 0; i < atags.length; ++i) + { + var aaa = atags[i]; + html = html.replace(new RegExp(aaa,'gi'),aaa+lb); + } + + return html; + }, + formatting: function(html) + { + html = this.formattingRemove(html); + + // empty tags + html = this.formattingEmptyTags(html); + + // add formatting before + html = this.formattingAddBefore(html); + + // add formatting after + html = this.formattingAddAfter(html); + + // indenting + html = this.formattingIndenting(html); + + return html; + }, + + // TOGGLE + toggle: function() + { + var html; + + if (this.opts.visual) + { + var height = this.$editor.innerHeight(); + + this.$editor.hide(); + this.$content.hide(); + + html = this.$editor.html(); + //html = $.trim(this.formatting(html)); + + this.$el.height(height).val(html).show().focus(); + + this.setBtnActive('html'); + this.opts.visual = false; + } + else + { + this.$el.hide(); + var html = this.$el.val(); + + //html = this.savePreCode(html); + + // clean up + //html = this.stripTags(html); + + // set code + this.$editor.html(html).show(); + this.$content.show(); + + if (this.$editor.html() === '') + { + this.setCode(this.opts.emptyHtml); + } + + this.$editor.focus(); + + this.setBtnInactive('html'); + this.opts.visual = true; + + this.observeImages(); + this.observeTables(); + } + }, + + // AUTOSAVE + autoSave: function() + { + this.autosaveInterval = setInterval($.proxy(function() + { + $.ajax({ + url: this.opts.autosave, + type: 'post', + data: this.$el.attr('name') + '=' + escape(encodeURIComponent(this.getCode())), + success: $.proxy(function(data) + { + // callback + if (typeof this.opts.autosaveCallback === 'function') + { + this.opts.autosaveCallback(data, this); + } + + }, this) + }); + + + }, this), this.opts.interval*1000); + }, + + // TOOLBAR + buildToolbar: function() + { + if (this.opts.toolbar === false) + { + return false; + } + + this.$toolbar = $('
<\/td>/gi, '[td]'); + html = html.replace(/([\w\W]*?)<\/a>/gi, '[a href="$2"]$4[/a]'); + html = html.replace(/