Inital
This commit is contained in:
@@ -0,0 +1,122 @@
|
||||
/* ===========================================================
|
||||
* trumbowyg.mention.js v0.1
|
||||
* Mention plugin for Trumbowyg
|
||||
* http://alex-d.github.com/Trumbowyg
|
||||
* ===========================================================
|
||||
* Author : Viper
|
||||
* Github: https://github.com/Globulopolis
|
||||
* Website: http://киноархив.com
|
||||
*/
|
||||
|
||||
(function ($) {
|
||||
'use strict';
|
||||
|
||||
var defaultOptions = {
|
||||
source: [],
|
||||
formatDropdownItem: formatDropdownItem,
|
||||
formatResult: formatResult
|
||||
};
|
||||
|
||||
$.extend(true, $.trumbowyg, {
|
||||
langs: {
|
||||
// jshint camelcase:false
|
||||
en: {
|
||||
mention: 'Mention'
|
||||
},
|
||||
da: {
|
||||
mention: 'Nævn'
|
||||
},
|
||||
et: {
|
||||
mention: 'Maini'
|
||||
},
|
||||
fr: {
|
||||
mention: 'Mentionner'
|
||||
},
|
||||
hu: {
|
||||
mention: 'Említ'
|
||||
},
|
||||
ko: {
|
||||
mention: '언급'
|
||||
},
|
||||
pt_br: {
|
||||
mention: 'Menção'
|
||||
},
|
||||
ru: {
|
||||
mention: 'Упомянуть'
|
||||
},
|
||||
tr: {
|
||||
mention: 'Bahset'
|
||||
},
|
||||
zh_tw: {
|
||||
mention: '標記'
|
||||
},
|
||||
// jshint camelcase:true
|
||||
},
|
||||
|
||||
plugins: {
|
||||
mention: {
|
||||
init: function (trumbowyg) {
|
||||
trumbowyg.o.plugins.mention = $.extend(true, {}, defaultOptions, trumbowyg.o.plugins.mention || {});
|
||||
|
||||
var btnDef = {
|
||||
dropdown: buildDropdown(trumbowyg.o.plugins.mention.source, trumbowyg)
|
||||
};
|
||||
|
||||
trumbowyg.addBtnDef('mention', btnDef);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Build dropdown list
|
||||
*
|
||||
* @param {Array} items Items
|
||||
* @param {object} trumbowyg Editor
|
||||
*
|
||||
* @return {Array}
|
||||
*/
|
||||
function buildDropdown(items, trumbowyg) {
|
||||
var dropdown = [];
|
||||
|
||||
$.each(items, function (i, item) {
|
||||
var btn = 'mention-' + i,
|
||||
btnDef = {
|
||||
hasIcon: false,
|
||||
text: trumbowyg.o.plugins.mention.formatDropdownItem(item),
|
||||
fn: function () {
|
||||
trumbowyg.execCmd('insertHTML', trumbowyg.o.plugins.mention.formatResult(item));
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
trumbowyg.addBtnDef(btn, btnDef);
|
||||
dropdown.push(btn);
|
||||
});
|
||||
|
||||
return dropdown;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format item in dropdown.
|
||||
*
|
||||
* @param {object} item Item object.
|
||||
*
|
||||
* @return {string}
|
||||
*/
|
||||
function formatDropdownItem(item) {
|
||||
return item.login;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format result pasted in editor.
|
||||
*
|
||||
* @param {object} item Item object.
|
||||
*
|
||||
* @return {string}
|
||||
*/
|
||||
function formatResult(item) {
|
||||
return '@' + item.login + ' ';
|
||||
}
|
||||
})(jQuery);
|
||||
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128">
|
||||
<path fill-rule="evenodd" d="M73.309 62.5c-1.53 9.86-8.16 17.85-14.45 17.85-5.61 0-8.5-4.08-8.5-10.54 0-13.089 8.84-24.139 20.06-24.139 2.21 0 3.91.34 5.27.68L73.309 62.5zm14.45 44.2c-6.8 3.57-15.98 5.44-24.65 5.44-25.329 0-43.519-16.15-43.519-44.54 0-32.469 22.78-52.869 48.789-52.869 26.35 0 40.63 17.17 40.63 39.27 0 19.549-9.18 28.899-16.49 28.729-4.76-.17-5.95-4.76-4.25-14.79l5.1-31.449c-4.25-2.38-12.75-4.25-20.23-4.25-24.48 0-39.779 18.87-39.779 39.609 0 13.94 7.99 22.1 19.039 22.1 9.01 0 16.66-4.42 21.93-13.09h.34c.85 9.01 6.63 13.09 14.62 13.09 18.36 0 32.3-15.64 32.3-40.459 0-28.56-21.42-49.13-51.34-49.13C31.83 4.361 6.67 34.451 6.67 69.13c0 33.32 24.82 53.55 53.039 53.55 12.07 0 20.91-1.53 31.11-6.12l-3.06-9.86z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 805 B |
@@ -0,0 +1,18 @@
|
||||
.trumbowyg-dropdown-mention {
|
||||
button {
|
||||
position: relative;
|
||||
white-space: nowrap;
|
||||
|
||||
&:after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
width: 15%;
|
||||
height: 100%;
|
||||
background-size: 100%;
|
||||
background-image: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, #ffffff 80%, #ffffff 100%);
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user