ui_bibz 2.0.10 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +49 -49
  3. data/app/assets/javascripts/input-connected.coffee +1 -2
  4. data/app/assets/javascripts/ui_bibz.coffee +2 -9
  5. data/app/assets/stylesheets/fix-bootstrap-4.sass +0 -4
  6. data/app/assets/stylesheets/fix_addon.sass +6 -6
  7. data/app/assets/stylesheets/notifications.sass +0 -7
  8. data/app/assets/stylesheets/ui_bibz.sass +1 -4
  9. data/lib/ui_bibz.rb +0 -1
  10. data/lib/ui_bibz/helpers/ui/core/icons_helper.rb +0 -9
  11. data/lib/ui_bibz/infos.rb +2 -2
  12. data/lib/ui_bibz/rails/engine.rb +1 -5
  13. data/lib/ui_bibz/ui/core/forms/dropdowns/components/dropdown_header.rb +1 -1
  14. data/lib/ui_bibz/ui/core/forms/textareas/markdown_editor_field.rb +1 -1
  15. data/lib/ui_bibz/ui/core/icons/glyph.rb +1 -1
  16. data/lib/ui_bibz/ui/core/notifications/components/bar.rb +2 -11
  17. data/lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb +12 -4
  18. data/vendor/assets/javascripts/bootstrap-markdown.js +56 -159
  19. data/vendor/assets/javascripts/fontawesome-all.min.js +5 -0
  20. data/vendor/assets/stylesheets/fa-svg-with-js.css +345 -0
  21. metadata +4 -21
  22. data/lib/ui_bibz/utils/glyph_changer.rb +0 -54
  23. data/vendor/assets/fonts/fa-brands-400.eot +0 -0
  24. data/vendor/assets/fonts/fa-brands-400.svg +0 -1154
  25. data/vendor/assets/fonts/fa-brands-400.ttf +0 -0
  26. data/vendor/assets/fonts/fa-brands-400.woff +0 -0
  27. data/vendor/assets/fonts/fa-brands-400.woff2 +0 -0
  28. data/vendor/assets/fonts/fa-regular-400.eot +0 -0
  29. data/vendor/assets/fonts/fa-regular-400.svg +0 -467
  30. data/vendor/assets/fonts/fa-regular-400.ttf +0 -0
  31. data/vendor/assets/fonts/fa-regular-400.woff +0 -0
  32. data/vendor/assets/fonts/fa-regular-400.woff2 +0 -0
  33. data/vendor/assets/fonts/fa-solid-900.eot +0 -0
  34. data/vendor/assets/fonts/fa-solid-900.svg +0 -2444
  35. data/vendor/assets/fonts/fa-solid-900.ttf +0 -0
  36. data/vendor/assets/fonts/fa-solid-900.woff +0 -0
  37. data/vendor/assets/fonts/fa-solid-900.woff2 +0 -0
  38. data/vendor/assets/javascripts/all.js +0 -3685
  39. data/vendor/assets/stylesheets/all.min.css +0 -5
  40. data/vendor/assets/stylesheets/svg-with-js.css +0 -5
@@ -18,13 +18,13 @@
18
18
  * ========================================================== */
19
19
  (function(factory) {
20
20
  if (typeof define === "function" && define.amd) {
21
- // RequireJS
21
+ //RequireJS
22
22
  define(["jquery"], factory);
23
23
  } else if (typeof exports === 'object') {
24
- // Backbone.js
24
+ //Backbone.js
25
25
  factory(require('jquery'));
26
26
  } else {
27
- // jQuery plugin
27
+ //Jquery plugin
28
28
  factory(jQuery);
29
29
  }
30
30
  }(function($) {
@@ -113,7 +113,7 @@
113
113
  var button = buttons[z],
114
114
  buttonContainer, buttonIconContainer,
115
115
  buttonHandler = ns + '-' + button.name,
116
- buttonIcon = this.__getIcon(button),
116
+ buttonIcon = this.__getIcon(button.icon),
117
117
  btnText = button.btnText ? button.btnText : '',
118
118
  btnClass = button.btnClass ? button.btnClass : 'btn',
119
119
  tabIndex = button.tabIndex ? button.tabIndex : '-1',
@@ -149,7 +149,7 @@
149
149
  callback.push(button.callback);
150
150
  }
151
151
 
152
- // Attach the button group into container DOM
152
+ // Attach the button group into container dom
153
153
  container.append(btnGroupContainer);
154
154
  }
155
155
  }
@@ -167,10 +167,6 @@
167
167
  this.$textarea.css('resize', this.$options.resize);
168
168
  }
169
169
 
170
- // Re-attach markdown data
171
- this.$textarea.data('markdown', this);
172
- },
173
- __setEventListeners: function() {
174
170
  this.$textarea.on({
175
171
  'focus': $.proxy(this.focus, this),
176
172
  'keyup': $.proxy(this.keyup, this),
@@ -185,6 +181,9 @@
185
181
  if (this.eventSupported('keypress')) {
186
182
  this.$textarea.on('keypress', $.proxy(this.keypress, this));
187
183
  }
184
+
185
+ // Re-attach markdown data
186
+ this.$textarea.data('markdown', this);
188
187
  },
189
188
  __handle: function(e) {
190
189
  var target = $(e.currentTarget),
@@ -223,14 +222,7 @@
223
222
  return string;
224
223
  },
225
224
  __getIcon: function(src) {
226
- if(typeof src == 'object'){
227
- var customIcon = this.$options.customIcons[src.name];
228
- console.log(customIcon)
229
- console.log(this.$options)
230
- return typeof customIcon == 'undefined' ? src.icon[this.$options.iconlibrary] : customIcon;
231
- } else {
232
- return src;
233
- }
225
+ return typeof src == 'object' ? src[this.$options.iconlibrary] : src;
234
226
  },
235
227
  setFullscreen: function(mode) {
236
228
  var $editor = this.$editor,
@@ -284,12 +276,12 @@
284
276
  // iterate the additional button groups
285
277
  $.each(options.additionalButtons[0], function(idx, buttonGroup) {
286
278
 
287
- // see if the group name of the additional group matches an existing group
279
+ // see if the group name of the addional group matches an existing group
288
280
  var matchingGroups = $.grep(allBtnGroups, function(allButtonGroup, allIdx) {
289
281
  return allButtonGroup.name === buttonGroup.name;
290
282
  });
291
283
 
292
- // if it matches add the additional buttons to that group, if not just add it to the all buttons group
284
+ // if it matches add the addional buttons to that group, if not just add it to the all buttons group
293
285
  if (matchingGroups.length > 0) {
294
286
  matchingGroups[0].data = matchingGroups[0].data.concat(buttonGroup.data);
295
287
  } else {
@@ -354,7 +346,7 @@
354
346
  editable.attrValues.push(this.nodeValue);
355
347
  });
356
348
 
357
- // Set editor to block the original container
349
+ // Set editor to blocked the original container
358
350
  container.replaceWith(editor);
359
351
  }
360
352
 
@@ -421,7 +413,6 @@
421
413
  this.$oldContent = this.getContent();
422
414
 
423
415
  this.__setListener();
424
- this.__setEventListeners();
425
416
 
426
417
  // Set editor attributes, data short-hand API and listener
427
418
  this.$editor.attr('id', (new Date()).getTime());
@@ -480,51 +471,26 @@
480
471
  // enable dropZone if available and configured
481
472
  if (options.dropZoneOptions) {
482
473
  if (this.$editor.dropzone) {
483
- if(!options.dropZoneOptions.init) {
484
- options.dropZoneOptions.init = function() {
485
- var caretPos = 0;
486
- this.on('drop', function(e) {
487
- caretPos = textarea.prop('selectionStart');
488
- });
489
- this.on('success', function(file, path) {
490
- var text = textarea.val();
491
- textarea.val(text.substring(0, caretPos) + '\n![description](' + path + ')\n' + text.substring(caretPos));
492
- });
493
- this.on('error', function(file, error, xhr) {
494
- console.log('Error:', error);
495
- });
496
- };
497
- }
498
- this.$editor.addClass('dropzone');
474
+ options.dropZoneOptions.init = function() {
475
+ var caretPos = 0;
476
+ this.on('drop', function(e) {
477
+ caretPos = textarea.prop('selectionStart');
478
+ });
479
+ this.on('success', function(file, path) {
480
+ var text = textarea.val();
481
+ textarea.val(text.substring(0, caretPos) + '\n![description](' + path + ')\n' + text.substring(caretPos));
482
+ });
483
+ this.on('error', function(file, error, xhr) {
484
+ console.log('Error:', error);
485
+ });
486
+ };
487
+ this.$textarea.addClass('dropzone');
499
488
  this.$editor.dropzone(options.dropZoneOptions);
500
489
  } else {
501
490
  console.log('dropZoneOptions was configured, but DropZone was not detected.');
502
491
  }
503
492
  }
504
493
 
505
- // enable data-uris via drag and drop
506
- if (options.enableDropDataUri === true) {
507
- this.$editor.on('drop', function(e) {
508
- var caretPos = textarea.prop('selectionStart');
509
- e.stopPropagation();
510
- e.preventDefault();
511
- $.each(e.originalEvent.dataTransfer.files, function(index, file){
512
- var fileReader = new FileReader();
513
- fileReader.onload = (function(file) {
514
- var type = file.type.split('/')[0];
515
- return function(e) {
516
- var text = textarea.val();
517
- if (type === 'image')
518
- textarea.val(text.substring(0, caretPos) + '\n<img src="'+ e.target.result +'" />\n' + text.substring(caretPos) );
519
- else
520
- textarea.val(text.substring(0, caretPos) + '\n<a href="'+ e.target.result +'">Download ' + file.name + '</a>\n' + text.substring(caretPos) );
521
- };
522
- })(file);
523
- fileReader.readAsDataURL(file);
524
- });
525
- });
526
- }
527
-
528
494
  // Trigger the onShow hook
529
495
  options.onShow(this);
530
496
 
@@ -560,19 +526,19 @@
560
526
  callbackContent;
561
527
 
562
528
  if (this.$isPreview === true) {
563
- // Avoid sequenced element creation on misused scenario
529
+ // Avoid sequenced element creation on missused scenario
564
530
  // @see https://github.com/toopay/bootstrap-markdown/issues/170
565
531
  return this;
566
532
  }
567
533
 
568
- // Give flag that tells the editor to enter preview mode
534
+ // Give flag that tell the editor enter preview mode
569
535
  this.$isPreview = true;
570
536
  // Disable all buttons
571
537
  this.disableButtons('all').enableButtons('cmdPreview');
572
538
 
573
539
  // Try to get the content from callback
574
- callbackContent = options.onPreview(this, replacementContainer);
575
- // Set the content based on the callback content if string, otherwise parse value from textarea
540
+ callbackContent = options.onPreview(this);
541
+ // Set the content based from the callback content if string otherwise parse value from textarea
576
542
  content = typeof callbackContent == 'string' ? callbackContent : this.parseContent();
577
543
 
578
544
  // Build preview element
@@ -588,9 +554,8 @@
588
554
 
589
555
  // Set the preview element dimensions
590
556
  replacementContainer.css({
591
- "width": container.outerWidth() + 'px',
592
- "min-height": container.outerHeight() + 'px',
593
- "height": "auto"
557
+ width: container.outerWidth() + 'px',
558
+ height: container.outerHeight() + 'px'
594
559
  });
595
560
 
596
561
  if (this.$options.resize) {
@@ -611,7 +576,7 @@
611
576
  return this;
612
577
  },
613
578
  hidePreview: function() {
614
- // Give flag that tells the editor to quit preview mode
579
+ // Give flag that tell the editor quit preview mode
615
580
  this.$isPreview = false;
616
581
 
617
582
  // Obtain the preview container
@@ -625,9 +590,6 @@
625
590
  // Disable configured disabled buttons
626
591
  this.disableButtons(this.$options.disabledButtons);
627
592
 
628
- // Perform any callbacks
629
- this.$options.onPreviewEnd(this);
630
-
631
593
  // Back to the editor
632
594
  this.$textarea.show();
633
595
  this.__setListener();
@@ -845,12 +807,12 @@
845
807
 
846
808
  blocked = true;
847
809
  } else {
848
- // The next tab's memory contains nothing...
810
+ // The next tab memory contains nothing...
849
811
  // check the cursor position to determine tab action
850
812
  var cursor = this.getSelection();
851
813
 
852
814
  if (cursor.start == cursor.end && cursor.end == this.getContent().length) {
853
- // The cursor has reached the end of the content
815
+ // The cursor already reach the end of the content
854
816
  blocked = false;
855
817
  } else {
856
818
  // Put the cursor to the end
@@ -864,29 +826,7 @@
864
826
 
865
827
  case 13: // enter
866
828
  blocked = false;
867
- var chars = this.getContent().split('');
868
- var enterIndex = this.getSelection().start;
869
- var priorNewlineIndex = -1; // initial line break at before index 0
870
-
871
- // traverse backwards through chars to check if last line break was num/bullet item
872
- for (var i = enterIndex - 2; i >= 0; i--) {
873
- if (chars[i] === '\n') {
874
- priorNewlineIndex = i;
875
- break;
876
- }
877
- }
878
-
879
- var charFollowingLastLineBreak = chars[priorNewlineIndex + 1];
880
- if (charFollowingLastLineBreak === '-') {
881
- this.addBullet(enterIndex);
882
- } else if ($.isNumeric(charFollowingLastLineBreak)) {
883
- var numBullet = this.getBulletNumber(priorNewlineIndex + 1);
884
- if (numBullet) {
885
- this.addNumberedBullet(enterIndex, numBullet);
886
- }
887
- }
888
829
  break;
889
-
890
830
  case 27: // escape
891
831
  if (this.$isFullscreen) this.setFullscreen(false);
892
832
  blocked = false;
@@ -903,26 +843,6 @@
903
843
 
904
844
  this.$options.onChange(this);
905
845
  },
906
- insertContent: function(index, content) {
907
- var firstHalf = this.getContent().slice(0, index);
908
- var secondHalf = this.getContent().slice(index + 1);
909
- this.setContent(firstHalf.concat(content).concat(secondHalf));
910
- },
911
- addBullet: function(index) {
912
- this.insertContent(index, '- \n');
913
- this.setSelection(index + 2, index + 2); // Put the cursor after the bullet
914
- },
915
- addNumberedBullet: function(index, num) {
916
- var numBullet = (num + 1) + '. \n';
917
- this.insertContent(index, numBullet);
918
-
919
- var prefixLength = num.toString().length + 2;
920
- this.setSelection(index + prefixLength, index + prefixLength); // Put the cursor after the number
921
- },
922
- getBulletNumber: function(startIndex) {
923
- var bulletNum = this.getContent().slice(startIndex).split('.')[0];
924
- return $.isNumeric(bulletNum) ? parseInt(bulletNum) : null;
925
- },
926
846
  change: function(e) {
927
847
  this.$options.onChange(this);
928
848
  return this;
@@ -1028,7 +948,6 @@
1028
948
  initialstate: 'editor',
1029
949
  parser: null,
1030
950
  dropZoneOptions: null,
1031
- enableDropDataUri: false,
1032
951
 
1033
952
  /* Buttons Properties */
1034
953
  buttons: [
@@ -1040,9 +959,8 @@
1040
959
  title: 'Bold',
1041
960
  icon: {
1042
961
  glyph: 'glyphicon glyphicon-bold',
1043
- fa: 'fa fa-bold',
962
+ fa: 'fas fa-bold',
1044
963
  'fa-3': 'icon-bold',
1045
- 'fa-5': 'fas fa-bold',
1046
964
  octicons: 'octicon octicon-bold'
1047
965
  },
1048
966
  callback: function(e) {
@@ -1077,9 +995,8 @@
1077
995
  hotkey: 'Ctrl+I',
1078
996
  icon: {
1079
997
  glyph: 'glyphicon glyphicon-italic',
1080
- fa: 'fa fa-italic',
998
+ fa: 'fas fa-italic',
1081
999
  'fa-3': 'icon-italic',
1082
- 'fa-5': 'fas fa-italic',
1083
1000
  octicons: 'octicon octicon-italic'
1084
1001
  },
1085
1002
  callback: function(e) {
@@ -1114,9 +1031,8 @@
1114
1031
  hotkey: 'Ctrl+H',
1115
1032
  icon: {
1116
1033
  glyph: 'glyphicon glyphicon-header',
1117
- fa: 'fa fa-header',
1034
+ fa: 'fas fa-header',
1118
1035
  'fa-3': 'icon-font',
1119
- 'fa-5': 'fas fa-heading',
1120
1036
  octicons: 'octicon octicon-text-size'
1121
1037
  },
1122
1038
  callback: function(e) {
@@ -1159,9 +1075,8 @@
1159
1075
  hotkey: 'Ctrl+L',
1160
1076
  icon: {
1161
1077
  glyph: 'glyphicon glyphicon-link',
1162
- fa: 'fa fa-link',
1078
+ fa: 'fas fa-link',
1163
1079
  'fa-3': 'icon-link',
1164
- 'fa-5': 'fas fa-link',
1165
1080
  octicons: 'octicon octicon-link'
1166
1081
  },
1167
1082
  callback: function(e) {
@@ -1197,9 +1112,8 @@
1197
1112
  hotkey: 'Ctrl+G',
1198
1113
  icon: {
1199
1114
  glyph: 'glyphicon glyphicon-picture',
1200
- fa: 'fa fa-picture-o',
1115
+ fa: 'fas fa-picture-o',
1201
1116
  'fa-3': 'icon-picture',
1202
- 'fa-5': 'far fa-image',
1203
1117
  octicons: 'octicon octicon-file-media'
1204
1118
  },
1205
1119
  callback: function(e) {
@@ -1241,9 +1155,8 @@
1241
1155
  title: 'Unordered List',
1242
1156
  icon: {
1243
1157
  glyph: 'glyphicon glyphicon-list',
1244
- fa: 'fa fa-list',
1158
+ fa: 'fas fa-list',
1245
1159
  'fa-3': 'icon-list-ul',
1246
- 'fa-5': 'fas fa-list-ul',
1247
1160
  octicons: 'octicon octicon-list-unordered'
1248
1161
  },
1249
1162
  callback: function(e) {
@@ -1293,9 +1206,8 @@
1293
1206
  title: 'Ordered List',
1294
1207
  icon: {
1295
1208
  glyph: 'glyphicon glyphicon-th-list',
1296
- fa: 'fa fa-list-ol',
1209
+ fa: 'fas fa-list-ol',
1297
1210
  'fa-3': 'icon-list-ol',
1298
- 'fa-5': 'fas fa-list-ol',
1299
1211
  octicons: 'octicon octicon-list-ordered'
1300
1212
  },
1301
1213
  callback: function(e) {
@@ -1320,15 +1232,13 @@
1320
1232
  // Set the cursor
1321
1233
  cursor = selected.start + 3;
1322
1234
  } else {
1323
- var i = 1;
1324
1235
  var list = [];
1325
1236
 
1326
1237
  list = selected.text.split('\n');
1327
1238
  chunk = list[0];
1328
1239
 
1329
1240
  $.each(list, function(k, v) {
1330
- list[k] = i + '. ' + v;
1331
- i++;
1241
+ list[k] = '1. ' + v;
1332
1242
  });
1333
1243
 
1334
1244
  e.replaceSelection('\n\n' + list.join('\n'));
@@ -1346,10 +1256,9 @@
1346
1256
  hotkey: 'Ctrl+K',
1347
1257
  title: 'Code',
1348
1258
  icon: {
1349
- glyph: 'glyphicon glyphicon-console',
1350
- fa: 'fa fa-code',
1259
+ glyph: 'glyphicon glyphicon-asterisk',
1260
+ fa: 'fas fa-code',
1351
1261
  'fa-3': 'icon-code',
1352
- 'fa-5': 'fas fa-code',
1353
1262
  octicons: 'octicon octicon-code'
1354
1263
  },
1355
1264
  callback: function(e) {
@@ -1392,9 +1301,8 @@
1392
1301
  title: 'Quote',
1393
1302
  icon: {
1394
1303
  glyph: 'glyphicon glyphicon-comment',
1395
- fa: 'fa fa-quote-left',
1304
+ fa: 'fas fa-quote-left',
1396
1305
  'fa-3': 'icon-quote-left',
1397
- 'fa-5': 'fas fa-quote-left',
1398
1306
  octicons: 'octicon octicon-quote'
1399
1307
  },
1400
1308
  callback: function(e) {
@@ -1451,9 +1359,8 @@
1451
1359
  btnClass: 'btn btn-primary btn-sm',
1452
1360
  icon: {
1453
1361
  glyph: 'glyphicon glyphicon-search',
1454
- fa: 'fa fa-search',
1362
+ fa: 'fas fa-search',
1455
1363
  'fa-3': 'icon-search',
1456
- 'fa-5': 'fas fa-search',
1457
1364
  octicons: 'octicon octicon-search'
1458
1365
  },
1459
1366
  callback: function(e) {
@@ -1462,7 +1369,7 @@
1462
1369
  content;
1463
1370
 
1464
1371
  if (isPreview === false) {
1465
- // Give flag that tells the editor to enter preview mode
1372
+ // Give flag that tell the editor enter preview mode
1466
1373
  e.showPreview();
1467
1374
  } else {
1468
1375
  e.hidePreview();
@@ -1471,7 +1378,6 @@
1471
1378
  }]
1472
1379
  }]
1473
1380
  ],
1474
- customIcons: {},
1475
1381
  additionalButtons: [], // Place to hook more buttons by code
1476
1382
  reorderButtonGroups: [],
1477
1383
  hiddenButtons: [], // Default hidden buttons
@@ -1481,24 +1387,16 @@
1481
1387
  enable: true,
1482
1388
  icons: {
1483
1389
  fullscreenOn: {
1484
- name: "fullscreenOn",
1485
- icon: {
1486
- fa: 'fa fa-expand',
1487
- glyph: 'glyphicon glyphicon-fullscreen',
1488
- 'fa-3': 'icon-resize-full',
1489
- 'fa-5': 'fas fa-expand-arrows-alt',
1490
- octicons: 'octicon octicon-link-external'
1491
- }
1390
+ fa: 'fas fa-expand',
1391
+ glyph: 'glyphicon glyphicon-fullscreen',
1392
+ 'fa-3': 'icon-resize-full',
1393
+ octicons: 'octicon octicon-link-external'
1492
1394
  },
1493
1395
  fullscreenOff: {
1494
- name: "fullscreenOff",
1495
- icon: {
1496
- fa: 'fa fa-compress',
1497
- glyph: 'glyphicon glyphicon-fullscreen',
1498
- 'fa-3': 'icon-resize-small',
1499
- 'fa-5': 'fas fa-compress',
1500
- octicons: 'octicon octicon-browser'
1501
- }
1396
+ fa: 'fas fa-compress',
1397
+ glyph: 'glyphicon glyphicon-fullscreen',
1398
+ 'fa-3': 'icon-resize-small',
1399
+ octicons: 'octicon octicon-browser'
1502
1400
  }
1503
1401
  }
1504
1402
  },
@@ -1506,7 +1404,6 @@
1506
1404
  /* Events hook */
1507
1405
  onShow: function(e) {},
1508
1406
  onPreview: function(e) {},
1509
- onPreviewEnd: function(e) {},
1510
1407
  onSave: function(e) {},
1511
1408
  onBlur: function(e) {},
1512
1409
  onFocus: function(e) {},