Changeset 3709:c88e69474c34 for plugins/tags
- Timestamp:
- 02/18/18 18:16:29 (8 years ago)
- Branch:
- default
- Location:
- plugins/tags/js
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/tags/js/ckeditor-tags-plugin.js
r2939 r3709 1 /*global $, dotclear, CKEDITOR */ 2 'use strict'; 3 1 4 (function() { 2 3 4 5 6 if (editor.getSelection().getNative().toString().replace(/\s*/,'')!='') {7 var str = editor.getSelection().getNative().toString().replace(/\s*/,'');8 9 10 var link = '<a href="'+$.stripBaseURL(url+'/'+str)+'">'+str+'</a>';11 12 13 14 15 5 CKEDITOR.plugins.add('dctags', { 6 init: function(editor) { 7 editor.addCommand('dcTagsCommand', { 8 exec: function(editor) { 9 if (editor.getSelection().getNative().toString().replace(/\s*/, '') != '') { 10 var str = editor.getSelection().getNative().toString().replace(/\s*/, ''); 11 var url = dotclear.msg.tag_url; 12 window.dc_tag_editor.addMeta(str); 13 var link = '<a href="' + $.stripBaseURL(url + '/' + str) + '">' + str + '</a>'; 14 var element = CKEDITOR.dom.element.createFromHtml(link); 15 editor.insertElement(element); 16 } 17 } 18 }); 16 19 17 18 19 20 21 22 23 24 20 editor.ui.addButton('dcTags', { 21 label: dotclear.msg.tag_title, 22 command: 'dcTagsCommand', 23 toolbar: 'insert', 24 icon: this.path + 'tag.png' 25 }); 26 } 27 }); 25 28 })(); -
plugins/tags/js/legacy-post.js
r2924 r3709 1 /*global dotclear, jsToolBar */ 2 'use strict'; 3 1 4 // Toolbar button for tags 2 5 jsToolBar.prototype.elements.tagSpace = { 3 4 format:{5 wysiwyg:true,6 wiki:true,7 xhtml:true,8 markdown:true9 6 type: 'space', 7 format: { 8 wysiwyg: true, 9 wiki: true, 10 xhtml: true, 11 markdown: true 12 } 10 13 }; 11 14 12 jsToolBar.prototype.elements.tag = {type: 'button', title: 'Keyword', fn:{} }; 15 jsToolBar.prototype.elements.tag = { 16 type: 'button', 17 title: 'Keyword', 18 fn: {} 19 }; 13 20 jsToolBar.prototype.elements.tag.context = 'post'; 14 21 jsToolBar.prototype.elements.tag.icon = 'index.php?pf=tags/img/tag-add.png'; 15 22 jsToolBar.prototype.elements.tag.fn.wiki = function() { 16 this.encloseSelection('','',function(str) { 17 if (str == '') { window.alert(dotclear.msg.no_selection); return ''; } 18 if (str.indexOf(',') != -1) { 19 return str; 20 } else { 21 window.dc_tag_editor.addMeta(str); 22 return '['+str+'|tag:'+str+']'; 23 } 24 }); 23 this.encloseSelection('', '', function(str) { 24 if (str == '') { 25 window.alert(dotclear.msg.no_selection); 26 return ''; 27 } 28 if (str.indexOf(',') != -1) { 29 return str; 30 } else { 31 window.dc_tag_editor.addMeta(str); 32 return '[' + str + '|tag:' + str + ']'; 33 } 34 }); 25 35 }; 26 36 jsToolBar.prototype.elements.tag.fn.markdown = function() { 27 var url = this.elements.tag.url; 28 this.encloseSelection('','',function(str) { 29 if (str == '') { window.alert(dotclear.msg.no_selection); return ''; } 30 if (str.indexOf(',') != -1) { 31 return str; 32 } else { 33 window.dc_tag_editor.addMeta(str); 34 return '['+str+']('+this.stripBaseURL(url+'/'+str)+')'; 35 } 36 }); 37 var url = this.elements.tag.url; 38 this.encloseSelection('', '', function(str) { 39 if (str == '') { 40 window.alert(dotclear.msg.no_selection); 41 return ''; 42 } 43 if (str.indexOf(',') != -1) { 44 return str; 45 } else { 46 window.dc_tag_editor.addMeta(str); 47 return '[' + str + '](' + this.stripBaseURL(url + '/' + str) + ')'; 48 } 49 }); 37 50 }; 38 51 jsToolBar.prototype.elements.tag.fn.xhtml = function() { 39 var url = this.elements.tag.url; 40 this.encloseSelection('','',function(str) { 41 if (str == '') { window.alert(dotclear.msg.no_selection); return ''; } 42 if (str.indexOf(',') != -1) { 43 return str; 44 } else { 45 window.dc_tag_editor.addMeta(str); 46 return '<a href="'+this.stripBaseURL(url+'/'+str)+'">'+str+'</a>'; 47 } 48 }); 52 var url = this.elements.tag.url; 53 this.encloseSelection('', '', function(str) { 54 if (str == '') { 55 window.alert(dotclear.msg.no_selection); 56 return ''; 57 } 58 if (str.indexOf(',') != -1) { 59 return str; 60 } else { 61 window.dc_tag_editor.addMeta(str); 62 return '<a href="' + this.stripBaseURL(url + '/' + str) + '">' + str + '</a>'; 63 } 64 }); 49 65 }; 50 66 jsToolBar.prototype.elements.tag.fn.wysiwyg = function() { 51 67 var t = this.getSelectedText(); 52 68 53 if (t == '') { window.alert(dotclear.msg.no_selection); return; } 54 if (t.indexOf(',') != -1) { return; } 69 if (t == '') { 70 window.alert(dotclear.msg.no_selection); 71 return; 72 } 73 if (t.indexOf(',') != -1) { 74 return; 75 } 55 76 56 57 58 a.href = this.stripBaseURL(this.elements.tag.url+'/'+t);59 60 61 77 var n = this.getSelectedNode(); 78 var a = document.createElement('a'); 79 a.href = this.stripBaseURL(this.elements.tag.url + '/' + t); 80 a.appendChild(n); 81 this.insertNode(a); 82 window.dc_tag_editor.addMeta(t); 62 83 }; -
plugins/tags/js/post.js
r2924 r3709 1 /*global $, dotclear, metaEditor, editor_tags_options */ 2 'use strict'; 3 1 4 $(function() { 2 $('#edit-entry').onetabload(function() { 3 var tags_edit = $('#tags-edit'); 4 var post_id = $('#id'); 5 var meta_field = null; 5 $('#edit-entry').onetabload(function() { 6 var tags_edit = $('#tags-edit'); 7 var post_id = $('#id'); 8 var meta_field = null; 9 var mEdit = null; 6 10 7 8 9 10 11 12 13 var mEdit = new metaEditor(tags_edit,meta_field,'tag',editor_tags_options);14 15 mEdit.displayMeta('tag',post_id);11 if (tags_edit.length > 0) { 12 post_id = (post_id.length > 0) ? post_id.get(0).value : false; 13 if (post_id == false) { 14 meta_field = $('<input type="hidden" name="post_tags" />'); 15 meta_field.val($('#post_tags').val()); 16 } 17 mEdit = new metaEditor(tags_edit, meta_field, 'tag', editor_tags_options); 18 mEdit.meta_url = 'plugin.php?p=tags&m=tag_posts&tag='; 19 mEdit.displayMeta('tag', post_id); 16 20 17 18 19 21 // mEdit object reference for toolBar 22 window.dc_tag_editor = mEdit; 23 } 20 24 21 22 23 24 25 26 27 28 multipleSeparator: ", ",29 30 31 32 33 $(xml).find('meta').each(function(){34 35 36 "id": $(this).text(),37 "count": $(this).attr("count"),38 "percent": $(this).attr("roundpercent")39 40 41 42 43 44 45 46 47 48 replace('%p',tag.percent).49 replace('%e',tag.count + ' ' +50 51 52 53 54 55 56 57 58 59 60 25 $('#post_meta_input').autocomplete(mEdit.service_uri, { 26 extraParams: { 27 'f': 'searchMeta', 28 'metaType': 'tag' 29 }, 30 delay: 1000, 31 multiple: true, 32 multipleSeparator: ', ', 33 matchSubset: false, 34 matchContains: true, 35 parse: function(xml) { 36 var results = []; 37 $(xml).find('meta').each(function() { 38 results[results.length] = { 39 data: { 40 'id': $(this).text(), 41 'count': $(this).attr('count'), 42 'percent': $(this).attr('roundpercent') 43 }, 44 result: $(this).text() 45 }; 46 }); 47 return results; 48 }, 49 formatItem: function(tag) { 50 return tag.id + ' <em>(' + 51 dotclear.msg.tags_autocomplete. 52 replace('%p', tag.percent). 53 replace('%e', tag.count + ' ' + 54 (tag.count > 1 ? 55 dotclear.msg.entries : 56 dotclear.msg.entry) 57 ) + 58 ')</em>'; 59 }, 60 formatResult: function(tag) { 61 return tag.result; 62 } 63 }); 64 }); 61 65 62 $('h5 .s-tags').toggleWithLegend($('.s-tags').not('label'),{63 64 65 66 $('h5 .s-tags').toggleWithLegend($('.s-tags').not('label'), { 67 user_pref: 'post_tags', 68 legend_click: true 69 }); 66 70 67 71 }); -
plugins/tags/js/posts_actions.js
r2546 r3709 1 /*global $, dotclear, metaEditor, editor_tags_options */ 2 'use strict'; 3 1 4 $(function() { 2 5 var tag_field = $('#new_tags'); … … 22 25 $('#post_meta_input').autocomplete(mEdit.service_uri, { 23 26 extraParams: { 24 'f': 'searchMeta',27 'f': 'searchMeta', 25 28 'metaType': 'tag' 26 29 }, … … 34 37 results[results.length] = { 35 38 data: { 36 "id":$(this).text(),37 "count": $(this).attr("count"),38 "percent": $(this).attr("roundpercent")39 'id': $(this).text(), 40 'count': $(this).attr('count'), 41 'percent': $(this).attr('roundpercent') 39 42 }, 40 43 result: $(this).text()
Note: See TracChangeset
for help on using the changeset viewer.