Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. $(`<script src="//code.jquery.com/ui/1.12.1/jquery-ui.min.js"
  2. integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU="
  3. crossorigin="anonymous"></script>`).appendTo('head')
  4.  
  5. $(`<link href="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css" rel="stylesheet" type="text/css" />`).appendTo('head');
  6.  
  7. var createBox = () => {
  8. const w = 100;
  9. const h = 100;
  10. const style = `
  11. background: rgba(0,0,0,.4);
  12. position:absolute;
  13. top: 0;
  14. left: 0;
  15. z-index: 9999;
  16. font-size: 12px;
  17. color: #fff;
  18. font-weight: bold;
  19. `;
  20.  
  21. const $box = $(`<div style="${style}"><span data-size>${w}, ${h}</span></div>`).appendTo('body');
  22. $box.css({ width: w, height: h });
  23. $box.draggable().resizable({
  24. resize(event, ui) {
  25. $box.find('[data-size]').text(`${ui.size.width}, ${ui.size.height}`);
  26. }
  27. });
  28. };
  29.  
  30. function createRuler(axis, options) {
  31. axis = axis || 'y';
  32.  
  33. var opts = {
  34. color: 'red',
  35. background: 'rgba(0,0,0,.3)'
  36. };
  37.  
  38. $.extend(opts, options);
  39.  
  40. var dimensions = axis === 'y' ? 'width:100%; height: 40px;' : 'height: 100%;width: 40px;';
  41. var divStyle = `cursor:pointer; border-top:1px solid ${opts.color}; background:${opts.background};position:fixed;top:0;left:0;z-index:9999`;
  42. var closeStyle = 'color:#fff;position:absolute;right:10px;top:5px;font-size:13px;text-decoration:none;';
  43. var $ruler = $(`<div style="${dimensions}${divStyle}">
  44. <a data-cmd="close" style="${closeStyle}">
  45. <span>close</span>
  46. </a>
  47. </div>`).appendTo('body');
  48.  
  49. $ruler.draggable({
  50. axis: axis
  51. });
  52.  
  53. $ruler.on('click', '[data-cmd=close]', function (e) {
  54. $ruler.remove();
  55. return false;
  56. });
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement