index.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. var quill; // Expose as global so people can easily try out the API
  2. $(document).ready(function() {
  3. quill = new Quill('#editor', {
  4. modules: {
  5. 'toolbar': { container: '#toolbar' },
  6. 'image-tooltip': true,
  7. 'link-tooltip': true
  8. },
  9. theme: 'snow'
  10. });
  11. // Bootstrap Toolbar has positioning but when showing manually when tooltip is offscreen
  12. $('.quill-wrapper').tooltip({ trigger: 'manual', animation: false }).tooltip('show');
  13. $('.quill-wrapper + .tooltip').hide();
  14. var tooltipTimer = setTimeout(function() {
  15. $('.quill-wrapper + .tooltip').fadeIn(1000);
  16. }, 2500);
  17. quill.once('selection-change', function(hasFocus) {
  18. $('#editor').toggleClass('focus', hasFocus);
  19. // Hack for inability to scroll on mobile
  20. if (/mobile/i.test(navigator.userAgent)) {
  21. $('#editor').css('height', quill.root.scrollHeight + 30) // 30 for padding
  22. }
  23. $('.quill-wrapper').tooltip('destroy');
  24. clearTimeout(tooltipTimer);
  25. });
  26. var users = {
  27. 'Asana': 'https://asana.com/',
  28. 'Front': 'https://frontapp.com/',
  29. 'Intuit': 'https://www.intuit.com/',
  30. 'Lever': 'https://www.lever.co/',
  31. 'MerchantCircle': 'https://www.merchantcircle.com/',
  32. 'Reedsy': 'https://reedsy.com/',
  33. 'RelateIQ': 'https://www.relateiq.com/',
  34. 'Respondly': 'https://respond.ly/',
  35. 'Salesforce': 'https://www.salesforce.com/',
  36. 'ThemeXpert': 'https://www.themexpert.com/',
  37. 'Vox Media': 'https://www.voxmedia.com/',
  38. 'Writer': 'https://chrome.google.com/webstore/detail/writer/hlddiopdeghmcmdjjmpdegemnojihpib?hl=en'
  39. };
  40. var keys = Object.keys(users);
  41. // Show users randomly
  42. $('#users-container a').each(function(i, link) {
  43. var index = Math.floor(Math.random() * keys.length);
  44. var key = keys[index];
  45. keys.splice(index, 1);
  46. $(link).attr({ href: users[key], title: key });
  47. $('img', link).attr({
  48. src: '/0.20/assets/images/users/' + (key.toLowerCase().replace(/\s/g, '')) + '.png',
  49. alt: key
  50. });
  51. });
  52. console.log("Welcome to Quill!\n\nThe editor on this page is available via `quill`. Give the API a try:\n\n\tquill.formatText(6, 10, 'bold', true);\n\nVisit the API documenation page to learn more: https://quilljs.com/docs/api/\n");
  53. });