chain.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. CKEDITOR.dialog.add( 'chainDialog', function( editor ) {
  2. return {
  3. title: 'Âñòàâêà Îïðîñà',
  4. minWidth: 400,
  5. minHeight: 200,
  6. contents: [
  7. {
  8. id: 'tab-basic',
  9. label: 'Áàçîâûå',
  10. elements: [
  11. {
  12. type: 'text',
  13. id: 'url',
  14. label: 'Âñòàâüòå íîìåð òðàíñëÿöèè, áðàòü ó ðîáîòà',
  15. validate: CKEDITOR.dialog.validate.notEmpty( "Ïîëå äëÿ íîìåðà òðàíñëÿöèè, íå äîëæíî áûòü ïóñòûì" ),
  16. setup: function( element ) {
  17. //his.setValue( 'hhhh' );
  18. this.setValue( element.getAttribute( "url" ) );
  19. console.log( element );
  20. },
  21. commit: function( element ) {
  22. element.setText( this.getValue() );
  23. }
  24. },
  25. {
  26. type: 'radio',
  27. id: 'type',
  28. label: 'Âûáðàòü',
  29. items: [ [ 'Âàðèàíò - timeline', '1' ], [ 'Âàðèàíò - ñòðîãèé', '2' ] ],
  30. 'default': '1',
  31. setup: function( element ) {
  32. console.log(element.getAttribute( "type" ));
  33. this.setValue( element.getAttribute( "type" ) );
  34. },
  35. commit: function( element ) {
  36. element.setAttribute( "type", this.getValue() );
  37. }
  38. }
  39. ]
  40. },
  41. ],
  42. onShow: function() {
  43. var selection = editor.getSelection();
  44. var element = selection.getStartElement();
  45. // if ( element )
  46. // element = element.getAttribute( 'url' );
  47. //console.log($(element).attr('id'));
  48. if ( !element || $(element).attr('id') != 'widgetchain' ) {
  49. element = editor.document.createElement( 'chain' );
  50. this.insertMode = true;
  51. }
  52. else
  53. this.insertMode = false;
  54. this.element = element;
  55. // console.log(element);
  56. // console.log(selection);
  57. if ( !this.insertMode )
  58. this.setupContent( this.element );
  59. },
  60. onOk: function() {
  61. var dialog = this;
  62. var chain = editor.document.createElement( 'div' );
  63. chain.setAttribute('id', 'widgetchain');
  64. chain.setAttribute( 'type', dialog.getValueOf('tab-basic', 'type') );
  65. chain.setAttribute( 'url', dialog.getValueOf( 'tab-basic', 'url' ) );
  66. chain.setHtml('  ');
  67. //this.commitContent( chain );
  68. editor.insertElement( chain );
  69. }
  70. };
  71. });