rails-bootstrap-markdown 0.0.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b27bac04a913814ecb58b4abbb151d3e8aac8acb
4
+ data.tar.gz: 1f18da19cced94651de9f54d38a46e40ae18ae6d
5
+ SHA512:
6
+ metadata.gz: 6ef374aaeba24702f1797416d7f1dc329842d934921edf829527f152f4b4236e2566a43ad8737646f8b4f780dfb95844e8b7c2588acf97bf446fb63da91de205
7
+ data.tar.gz: 265fc5fb77cf588995e50a95980822f1f6e798cce7c7a7a50726f9a0cb4d210bdde2baf7d76926f7d2e1c4bf973ed68b367b94804032d636a91b1b07a0ac52d1
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Rails::Bootstrap::Markdown
2
2
 
3
- A rails gem for [Bootstrap Markdown](http://toopay.github.io/bootstrap-markdown/), rewritten to SCSS for use with [bootstrap-sass](https://github.com/thomas-mcdonald/bootstrap-sass)
3
+ A rails gem for [Bootstrap Markdown](http://toopay.github.io/bootstrap-markdown/), rewritten to SCSS for use with [bootstrap-sass](https://github.com/thomas-mcdonald/bootstrap-sass).
4
4
 
5
5
  3rd party libraries included:
6
6
 
@@ -16,7 +16,7 @@ Add this line to your application's Gemfile:
16
16
 
17
17
  And then execute:
18
18
 
19
- $ bundle
19
+ $ bundle install
20
20
 
21
21
  Or install it yourself as:
22
22
 
@@ -33,7 +33,7 @@ Or install it yourself as:
33
33
  ### Javascript
34
34
 
35
35
  ```
36
- //= requrie bootstrap-markdown
36
+ //= require bootstrap-markdown
37
37
  ```
38
38
 
39
39
  ## Contributing
@@ -1,5 +1,5 @@
1
1
  /* ===================================================
2
- * bootstrap-markdown.js v1.0.0
2
+ * bootstrap-markdown.js v2.1.0
3
3
  * http://github.com/toopay/bootstrap-markdown
4
4
  * ===================================================
5
5
  * Copyright 2013 Taufan Aditya
@@ -33,7 +33,6 @@
33
33
  this.$ns = 'bootstrap-markdown'
34
34
  this.$element = $(element)
35
35
  this.$editable = {el:null, type:null,attrKeys:[], attrValues:[], content:null}
36
- this.$cloneEditor = {el:null, type:null,attrKeys:[], attrValues:[], content:null}
37
36
  this.$options = $.extend(true, {}, $.fn.markdown.defaults, options)
38
37
  this.$oldContent = null
39
38
  this.$isPreview = false
@@ -86,22 +85,32 @@
86
85
 
87
86
  for (z=0;z<buttons.length;z++) {
88
87
  var button = buttons[z],
88
+ buttonToggle = '',
89
89
  buttonHandler = ns+'-'+button.name,
90
90
  btnText = button.btnText ? button.btnText : '',
91
- btnClass = button.btnClass ? button.btnClass : 'btn'
91
+ btnClass = button.btnClass ? button.btnClass : 'btn',
92
+ tabIndex = button.tabIndex ? button.tabIndex : '-1'
93
+
94
+ if (button.toggle == true) {
95
+ buttonToggle = ' data-toggle="button"'
96
+ }
92
97
 
93
98
  // Attach the button object
94
99
  btnGroupContainer.append('<button class="'
95
100
  +btnClass
96
- +' btn-small" title="'
101
+ +' btn-default btn-sm" title="'
97
102
  +button.title
103
+ +'" tabindex="'
104
+ +tabIndex
98
105
  +'" data-provider="'
99
106
  +ns
100
107
  +'" data-handler="'
101
108
  +buttonHandler
102
- +'"><i class="'
109
+ +'"'
110
+ +buttonToggle
111
+ +'><span class="'
103
112
  +button.icon
104
- +'"></i> '
113
+ +'"></span> '
105
114
  +btnText
106
115
  +'</button>')
107
116
 
@@ -183,7 +192,7 @@
183
192
  if (this.$editor == null) {
184
193
  // Create the panel
185
194
  var editorHeader = $('<div/>', {
186
- 'class': 'md-header'
195
+ 'class': 'md-header btn-toolbar'
187
196
  })
188
197
 
189
198
  // Build the main buttons
@@ -292,8 +301,8 @@
292
301
  var options = this.$options,
293
302
  callbackContent = options.onPreview(this), // Try to get the content from callback
294
303
  container = this.$textarea,
304
+ afterContainer = container.next(),
295
305
  replacementContainer = $('<div/>',{'class':'md-preview','data-provider':'markdown-preview'}),
296
- cloneEditor = this.$cloneEditor,
297
306
  content
298
307
 
299
308
  // Give flag that tell the editor enter preview mode
@@ -301,18 +310,6 @@
301
310
  // Disable all buttons
302
311
  this.disableButtons('all').enableButtons('cmdPreview')
303
312
 
304
- // Save the editor
305
- cloneEditor.el = container
306
- cloneEditor.type = container.prop('tagName').toLowerCase()
307
- cloneEditor.content = container.val()
308
-
309
- $(container[0].attributes).each(function(){
310
- cloneEditor.attrKeys.push(this.nodeName)
311
- cloneEditor.attrValues.push(this.nodeValue)
312
- })
313
-
314
- this.$cloneEditor = cloneEditor
315
-
316
313
  if (typeof callbackContent == 'string') {
317
314
  // Set the content based by callback content
318
315
  content = callbackContent
@@ -321,9 +318,19 @@
321
318
  content = (typeof markdown == 'object') ? markdown.toHTML(container.val()) : container.val()
322
319
  }
323
320
 
324
- // Build preview element and replace the editor temporarily
321
+ // Build preview element
325
322
  replacementContainer.html(content)
326
- container.replaceWith(replacementContainer)
323
+
324
+ if (afterContainer && afterContainer.attr('class') == 'md-footer') {
325
+ // If there is footer element, insert the preview container before it
326
+ replacementContainer.insertBefore(afterContainer)
327
+ } else {
328
+ // Otherwise, just append it after textarea
329
+ container.parent().append(replacementContainer)
330
+ }
331
+
332
+ // Hide the last-active textarea
333
+ container.hide()
327
334
 
328
335
  // Attach the editor instances
329
336
  replacementContainer.data('markdown',this)
@@ -335,26 +342,17 @@
335
342
  // Give flag that tell the editor quit preview mode
336
343
  this.$isPreview = false
337
344
 
338
- // Build the original element
339
- var container = this.$editor.find('div[data-provider="markdown-preview"]'),
340
- cloneEditor = this.$cloneEditor,
341
- oldElement = $('<'+cloneEditor.type+'/>')
345
+ // Obtain the preview container
346
+ var container = this.$editor.find('div[data-provider="markdown-preview"]')
342
347
 
343
- $(cloneEditor.attrKeys).each(function(k,v) {
344
- oldElement.attr(cloneEditor.attrKeys[k],cloneEditor.attrValues[k])
345
- })
346
-
347
- // Set the editor content
348
- oldElement.val(cloneEditor.content)
349
-
350
- // Set the editor data
351
- container.replaceWith(oldElement)
348
+ // Remove the preview container
349
+ container.remove()
352
350
 
353
351
  // Enable all buttons
354
352
  this.enableButtons('all')
355
353
 
356
354
  // Back to the editor
357
- this.$textarea = oldElement
355
+ this.$textarea.show()
358
356
  this.__setListener()
359
357
 
360
358
  return this
@@ -365,7 +363,7 @@
365
363
  }
366
364
 
367
365
  , getContent: function() {
368
- return (this.$isPreview) ? this.$cloneEditor.content : this.$textarea.val()
366
+ return this.$textarea.val()
369
367
  }
370
368
 
371
369
  , setContent: function(content) {
@@ -548,12 +546,25 @@
548
546
  setTimeout(function(){
549
547
  that.setSelection(nextTab.start,nextTab.end)
550
548
  },500)
549
+
550
+ blocked = true
551
551
  } else {
552
- // Put the cursor to the end
553
- this.setSelection(this.getContent().length,this.getContent().length)
552
+ // The next tab memory contains nothing...
553
+ // check the cursor position to determine tab action
554
+ var cursor = this.getSelection()
555
+
556
+ if (cursor.start == cursor.end && cursor.end == this.getContent().length) {
557
+ // The cursor already reach the end of the content
558
+ blocked = false
559
+
560
+ } else {
561
+ // Put the cursor to the end
562
+ this.setSelection(this.getContent().length,this.getContent().length)
563
+
564
+ blocked = true
565
+ }
554
566
  }
555
567
 
556
- blocked = true
557
568
  break
558
569
 
559
570
  case 13: // enter
@@ -603,11 +614,6 @@
603
614
  editor = this.$editor,
604
615
  editable = this.$editable
605
616
 
606
- // Force to quit preview mode
607
- if (this.$isPreview) {
608
- this.hidePreview()
609
- }
610
-
611
617
  if (editor.hasClass('active') || this.$element.parent().length == 0) {
612
618
  editor.removeClass('active')
613
619
 
@@ -672,7 +678,7 @@
672
678
  data: [{
673
679
  name: 'cmdBold',
674
680
  title: 'Bold',
675
- icon: 'icon icon-bold',
681
+ icon: 'glyphicon glyphicon-bold',
676
682
  callback: function(e){
677
683
  // Give/remove ** surround the selection
678
684
  var chunk, cursor, selected = e.getSelection(), content = e.getContent()
@@ -701,7 +707,7 @@
701
707
  },{
702
708
  name: 'cmdItalic',
703
709
  title: 'Italic',
704
- icon: 'icon icon-italic',
710
+ icon: 'glyphicon glyphicon-italic',
705
711
  callback: function(e){
706
712
  // Give/remove * surround the selection
707
713
  var chunk, cursor, selected = e.getSelection(), content = e.getContent()
@@ -730,7 +736,7 @@
730
736
  },{
731
737
  name: 'cmdHeading',
732
738
  title: 'Heading',
733
- icon: 'icon icon-font',
739
+ icon: 'glyphicon glyphicon-font',
734
740
  callback: function(e){
735
741
  // Append/remove ### surround the selection
736
742
  var chunk, cursor, selected = e.getSelection(), content = e.getContent(), pointer, prevChar
@@ -766,7 +772,7 @@
766
772
  data: [{
767
773
  name: 'cmdUrl',
768
774
  title: 'URL/Link',
769
- icon: 'icon icon-globe',
775
+ icon: 'glyphicon glyphicon-globe',
770
776
  callback: function(e){
771
777
  // Give [] surround the selection and prepend the link
772
778
  var chunk, cursor, selected = e.getSelection(), content = e.getContent(), link
@@ -792,7 +798,7 @@
792
798
  },{
793
799
  name: 'cmdImage',
794
800
  title: 'Image',
795
- icon: 'icon icon-picture',
801
+ icon: 'glyphicon glyphicon-picture',
796
802
  callback: function(e){
797
803
  // Give ![] surround the selection and prepend the image link
798
804
  var chunk, cursor, selected = e.getSelection(), content = e.getContent(), link
@@ -824,7 +830,7 @@
824
830
  data: [{
825
831
  name: 'cmdList',
826
832
  title: 'List',
827
- icon: 'icon icon-list',
833
+ icon: 'glyphicon glyphicon-list',
828
834
  callback: function(e){
829
835
  // Prepend/Give - surround the selection
830
836
  var chunk, cursor, selected = e.getSelection(), content = e.getContent()
@@ -873,10 +879,11 @@
873
879
  name: 'groupUtil',
874
880
  data: [{
875
881
  name: 'cmdPreview',
882
+ toggle: true,
876
883
  title: 'Preview',
877
884
  btnText: 'Preview',
878
- btnClass: 'btn btn-inverse',
879
- icon: 'icon icon-white icon-search',
885
+ btnClass: 'btn btn-primary btn-sm',
886
+ icon: 'glyphicon glyphicon-search',
880
887
  callback: function(e){
881
888
  // Check the preview mode and toggle based on this flag
882
889
  var isPreview = e.$isPreview,content
@@ -986,4 +993,4 @@
986
993
  })
987
994
  })
988
995
 
989
- }(window.jQuery);
996
+ }(window.jQuery);
@@ -1,62 +1,60 @@
1
1
  /**
2
- * Bootstrap-Markdown.css.scss
3
- *
4
- * Converted to SCSS by Danny Tatom @dannytatom
2
+ * Bootstrap-Markdown.less
5
3
  *
6
4
  * @author Taufan Aditya @taufanaditya
7
5
  * @copyright 2013 Taufan Aditya
8
6
  */
9
7
 
10
- @import "bootstrap/variables";
11
- @import "bootstrap/mixins";
8
+ @import "bootstrap/variables"; // Point this into your bootstrap variables
9
+ @import "bootstrap/mixins"; // Point this into your bootstrap variables
10
+
11
+ // Hover state
12
+ $color: $input-border-focus;
13
+ $color-rgba: rgba(red($color), green($color), blue($color), .6);
12
14
 
13
15
  .md-editor {
14
16
  display: block;
15
- border: 1px solid $tableBorder;
17
+ border: 1px solid $table-border-color;
16
18
 
17
19
  .md-header, .md-footer {
18
20
  display: block;
19
21
  padding: 6px 4px;
20
- background: $white;
22
+ background: $panel-default-heading-bg;
21
23
  }
22
24
 
23
25
  .md-preview {
24
- background: $white;
25
- border-top: 1px dashed $tableBorder;
26
- border-bottom: 1px dashed $tableBorder;
26
+ background: $panel-bg;
27
+ border-top: 1px dashed $table-border-color;
28
+ border-bottom: 1px dashed $table-border-color;
27
29
  min-height: 10px;
28
30
  }
29
31
 
30
32
  textarea {
31
- font-family: $monoFontFamily;
32
- font-size: $baseFontSize;
33
+ font-family: $font-family-monospace;
34
+ font-size: $font-size-base;
33
35
  outline: 0;
34
- outline: thin dotted \9; /* IE6-9 */
36
+ outline: thin dotted \9; /* IE6-9 */
35
37
  margin: 0;
36
38
  display: block;
37
39
  padding: 0;
38
40
  width: 100%;
39
41
  border: 0;
40
- border-top: 1px dashed $tableBorder;
41
- border-bottom: 1px dashed $tableBorder;
42
+ border-top: 1px dashed $table-border-color;
43
+ border-bottom: 1px dashed $table-border-color;
42
44
  border-radius: 0;
43
45
  box-shadow: none;
44
- background: $inputDisabledBackground;
46
+ background: $input-bg-disabled;
45
47
 
46
48
  &:focus {
47
49
  box-shadow: none;
48
- background: $inputBackground;
50
+ background: $input-bg;
49
51
  }
50
52
  }
51
53
 
52
- // Hover state
53
54
  &.active {
54
- @include box-shadow("inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(82,168,236,.6)");
55
-
56
- border-color: rgba(82,168,236,.8);
55
+ border-color: $color;
57
56
  outline: 0;
58
- outline: thin dotted \9; /* IE6-9 */
59
57
 
60
- @include transition(border linear .2s, box-shadow linear .2s);
58
+ @include box-shadow("inset 0 1px 1px rgba(0, 0, 0, 0.75), 0 0 0 8px rgba(#{$color-rgba})")
61
59
  }
62
- }
60
+ }
@@ -1,7 +1,7 @@
1
1
  module Rails
2
2
  module Bootstrap
3
3
  module Markdown
4
- VERSION = "0.0.2"
4
+ VERSION = "1.0.0"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-bootstrap-markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Danny Tatom
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-05-11 00:00:00.000000000 Z
11
+ date: 2013-10-26 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description:
15
14
  email:
@@ -32,32 +31,26 @@ files:
32
31
  - rails-bootstrap-markdown.gemspec
33
32
  homepage: http://github.com/dannytatom/rails-bootstrap-markdown
34
33
  licenses: []
34
+ metadata: {}
35
35
  post_install_message:
36
36
  rdoc_options: []
37
37
  require_paths:
38
38
  - lib
39
39
  required_ruby_version: !ruby/object:Gem::Requirement
40
- none: false
41
40
  requirements:
42
- - - ! '>='
41
+ - - '>='
43
42
  - !ruby/object:Gem::Version
44
43
  version: '0'
45
- segments:
46
- - 0
47
- hash: -2957847032896564447
48
44
  required_rubygems_version: !ruby/object:Gem::Requirement
49
- none: false
50
45
  requirements:
51
- - - ! '>='
46
+ - - '>='
52
47
  - !ruby/object:Gem::Version
53
48
  version: '0'
54
- segments:
55
- - 0
56
- hash: -2957847032896564447
57
49
  requirements: []
58
50
  rubyforge_project:
59
- rubygems_version: 1.8.23
51
+ rubygems_version: 2.0.2
60
52
  signing_key:
61
- specification_version: 3
53
+ specification_version: 4
62
54
  summary: A Rails gem for Bootstrap Markdown
63
55
  test_files: []
56
+ has_rdoc: