-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e689d0d
Showing
12 changed files
with
592 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
*.gem | ||
*.rbc | ||
.bundle | ||
.config | ||
.yardoc | ||
Gemfile.lock | ||
InstalledFiles | ||
_yardoc | ||
coverage | ||
doc/ | ||
lib/bundler/man | ||
pkg | ||
rdoc | ||
spec/reports | ||
test/tmp | ||
test/version_tmp | ||
tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source 'https://rubygems.org' | ||
|
||
# Specify your gem's dependencies in md_simple_editor.gemspec | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Copyright (c) 2014 Ruben Espinosa | ||
|
||
MIT License | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# MdSimpleEditor | ||
|
||
TODO: Write a gem description | ||
|
||
## Installation | ||
|
||
Add this line to your application's Gemfile: | ||
|
||
gem 'md_simple_editor' | ||
|
||
And then execute: | ||
|
||
$ bundle | ||
|
||
Or install it yourself as: | ||
|
||
$ gem install md_simple_editor | ||
|
||
## Usage | ||
|
||
TODO: Write usage instructions here | ||
|
||
## Contributing | ||
|
||
1. Fork it | ||
2. Create your feature branch (`git checkout -b my-new-feature`) | ||
3. Commit your changes (`git commit -am 'Add some feature'`) | ||
4. Push to the branch (`git push origin my-new-feature`) | ||
5. Create new Pull Request |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require "bundler/gem_tasks" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Place all the behaviors and hooks related to the matching controller here. | ||
# All this logic will automatically be available in application.js. | ||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ | ||
|
||
$ -> | ||
$('#md-toolbar #btn-group button').mousedown -> | ||
att_class = this.classList | ||
rgex = /md_/ | ||
|
||
option = $.grep att_class, (item) -> | ||
return rgex.test(item) | ||
|
||
option = option[0].toString() | ||
|
||
text = if option == 'md_h1' | ||
"# Your Title here" | ||
else if option == 'md_h2' | ||
"## Your Title here" | ||
else if option == 'md_h3' | ||
"### Your Title here" | ||
else if option == 'md_h4' | ||
"#### Your Title here" | ||
else if option == 'md_h5' | ||
"##### Your Title here" | ||
else if option == 'md_italic' | ||
"_Your italic text here_" | ||
else if option == 'md_bold' | ||
"__Your bold text here__" | ||
else if option == 'md_list-ul' | ||
"\n\n* Item 1\n* Item 2\n* Item 3 \n\n<br>" | ||
else if option == 'md_list-ol' | ||
"\n\n1. Item 1\n2. Item 2\n3. Item 3 \n\n<br> " | ||
else if option == 'md_indent' | ||
">Your indented text here" | ||
else if option == 'md_underline' | ||
"<u>Your undelined text here </u>" | ||
else if option == 'md_table' | ||
"\n|Header|Header|Header|\n|:------|:-------:|------:|\n|Left aligment|Centered|right aligment|\n\n<br>" | ||
else if option == 'md_minus' | ||
"\n<hr>\n" | ||
else if option == 'md_square' | ||
"\n\tjebdhwiedwef Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam ut aliquet velit. Nam fermentum, mi quis egestas ornare, massa velit pharetra ante, sed | ||
pellentesque tortor nisl non quam. Nunc eget egestas orci.\n\n<br> " | ||
|
||
textarea = $('#md-editor #md-text textarea') | ||
insertAtCaret(textarea.attr('id'), text) | ||
|
||
insertAtCaret = (areaId, text) -> | ||
txtarea = document.getElementById(areaId) | ||
scrollPos = txtarea.scrollTop | ||
strPos = 0 | ||
br = ((if (txtarea.selectionStart or txtarea.selectionStart is "0") then "ff" else ((if document.selection then "ie" else false)))) | ||
if br is "ie" | ||
txtarea.focus() | ||
range = document.selection.createRange() | ||
range.moveStart "character", -txtarea.value.length | ||
strPos = range.text.length | ||
else strPos = txtarea.selectionStart if br is "ff" | ||
front = (txtarea.value).substring(0, strPos) | ||
back = (txtarea.value).substring(strPos, txtarea.value.length) | ||
txtarea.value = front + text + back | ||
strPos = strPos + text.length | ||
if br is "ie" | ||
txtarea.focus() | ||
range = document.selection.createRange() | ||
range.moveStart "character", -txtarea.value.length | ||
range.moveStart "character", strPos | ||
range.moveEnd "character", 0 | ||
range.select() | ||
else if br is "ff" | ||
txtarea.selectionStart = strPos | ||
txtarea.selectionEnd = strPos | ||
txtarea.focus() | ||
txtarea.scrollTop = scrollPos |
Oops, something went wrong.