kit_cms 2.3.8 → 2.3.9
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/codemirror/codemirror.js +5104 -0
- data/app/assets/javascripts/codemirror/collapserange.js +68 -0
- data/app/assets/javascripts/codemirror/css.js +465 -0
- data/app/assets/javascripts/codemirror/dialog.js +76 -0
- data/app/assets/javascripts/codemirror/editor.js +19 -0
- data/app/assets/javascripts/codemirror/foldcode.js +183 -0
- data/app/assets/javascripts/codemirror/formatting.js +108 -0
- data/app/assets/javascripts/codemirror/htmlmixed.js +84 -0
- data/app/assets/javascripts/codemirror/javascript.js +422 -0
- data/app/assets/javascripts/codemirror/jquery.js +4 -0
- data/app/assets/javascripts/codemirror/loadmode.js +51 -0
- data/app/assets/javascripts/codemirror/match-highlighter.js +46 -0
- data/app/assets/javascripts/codemirror/matchbrackets.js +63 -0
- data/app/assets/javascripts/codemirror/multiplex.js +95 -0
- data/app/assets/javascripts/codemirror/overlay.js +59 -0
- data/app/assets/javascripts/codemirror/search.js +131 -0
- data/app/assets/javascripts/codemirror/searchcursor.js +131 -0
- data/app/assets/javascripts/codemirror/xml.js +324 -0
- data/app/assets/stylesheets/codemirror/dialog.css +32 -0
- data/app/assets/stylesheets/codemirror/style.css +242 -0
- data/app/assets/stylesheets/codemirror/theme.css +25 -0
- data/app/views/layouts/_html-editor.html.haml +1 -0
- data/app/views/layouts/mercury-editor.html.erb +5 -5
- data/app/views/utility/mercury_html.html.haml +28 -3
- metadata +41 -39
- data/app/assets/javascripts/kit/markitup/jquery.markitup.js +0 -634
- data/app/assets/javascripts/kit/markitup/settings.js +0 -31
- data/app/assets/stylesheets/kit/markitup/html.css +0 -59
- data/app/assets/stylesheets/kit/markitup/images/bg-container.png +0 -0
- data/app/assets/stylesheets/kit/markitup/images/bg-editor-bbcode.png +0 -0
- data/app/assets/stylesheets/kit/markitup/images/bg-editor-dotclear.png +0 -0
- data/app/assets/stylesheets/kit/markitup/images/bg-editor-html.png +0 -0
- data/app/assets/stylesheets/kit/markitup/images/bg-editor-json.png +0 -0
- data/app/assets/stylesheets/kit/markitup/images/bg-editor-markdown.png +0 -0
- data/app/assets/stylesheets/kit/markitup/images/bg-editor-textile.png +0 -0
- data/app/assets/stylesheets/kit/markitup/images/bg-editor-wiki.png +0 -0
- data/app/assets/stylesheets/kit/markitup/images/bg-editor-xml.png +0 -0
- data/app/assets/stylesheets/kit/markitup/images/bg-editor.png +0 -0
- data/app/assets/stylesheets/kit/markitup/images/bold.png +0 -0
- data/app/assets/stylesheets/kit/markitup/images/clean.png +0 -0
- data/app/assets/stylesheets/kit/markitup/images/h1.png +0 -0
- data/app/assets/stylesheets/kit/markitup/images/h2.png +0 -0
- data/app/assets/stylesheets/kit/markitup/images/h3.png +0 -0
- data/app/assets/stylesheets/kit/markitup/images/h4.png +0 -0
- data/app/assets/stylesheets/kit/markitup/images/h5.png +0 -0
- data/app/assets/stylesheets/kit/markitup/images/h6.png +0 -0
- data/app/assets/stylesheets/kit/markitup/images/handle.png +0 -0
- data/app/assets/stylesheets/kit/markitup/images/image.png +0 -0
- data/app/assets/stylesheets/kit/markitup/images/italic.png +0 -0
- data/app/assets/stylesheets/kit/markitup/images/link.png +0 -0
- data/app/assets/stylesheets/kit/markitup/images/list-bullet.png +0 -0
- data/app/assets/stylesheets/kit/markitup/images/list-item.png +0 -0
- data/app/assets/stylesheets/kit/markitup/images/list-numeric.png +0 -0
- data/app/assets/stylesheets/kit/markitup/images/menu.png +0 -0
- data/app/assets/stylesheets/kit/markitup/images/paragraph.png +0 -0
- data/app/assets/stylesheets/kit/markitup/images/picture.png +0 -0
- data/app/assets/stylesheets/kit/markitup/images/preview.png +0 -0
- data/app/assets/stylesheets/kit/markitup/images/stroke.png +0 -0
- data/app/assets/stylesheets/kit/markitup/images/submenu.png +0 -0
- data/app/assets/stylesheets/kit/markitup/style.css +0 -145
- data/lib/kit_cms/version.rb +0 -3
@@ -0,0 +1,25 @@
|
|
1
|
+
/* Port of TextMate's Blackboard theme */
|
2
|
+
|
3
|
+
.cm-s-blackboard.CodeMirror { background: #0C1021; color: #F8F8F8; }
|
4
|
+
.cm-s-blackboard .CodeMirror-selected { background: blue !important; }
|
5
|
+
.cm-s-blackboard .CodeMirror-gutters { background: #0C1021; border-right: 0; }
|
6
|
+
.cm-s-blackboard .CodeMirror-linenumber { color: #888; }
|
7
|
+
.cm-s-blackboard .CodeMirror-cursor { border-left: 1px solid #A7A7A7 !important; }
|
8
|
+
|
9
|
+
.cm-s-blackboard .cm-keyword { color: #FBDE2D; }
|
10
|
+
.cm-s-blackboard .cm-atom { color: #D8FA3C; }
|
11
|
+
.cm-s-blackboard .cm-number { color: #D8FA3C; }
|
12
|
+
.cm-s-blackboard .cm-def { color: #8DA6CE; }
|
13
|
+
.cm-s-blackboard .cm-variable { color: #FF6400; }
|
14
|
+
.cm-s-blackboard .cm-operator { color: #FBDE2D;}
|
15
|
+
.cm-s-blackboard .cm-comment { color: #AEAEAE; }
|
16
|
+
.cm-s-blackboard .cm-string { color: #61CE3C; }
|
17
|
+
.cm-s-blackboard .cm-string-2 { color: #61CE3C; }
|
18
|
+
.cm-s-blackboard .cm-meta { color: #D8FA3C; }
|
19
|
+
.cm-s-blackboard .cm-error { background: #9D1E15; color: #F8F8F8; }
|
20
|
+
.cm-s-blackboard .cm-builtin { color: #8DA6CE; }
|
21
|
+
.cm-s-blackboard .cm-tag { color: #8DA6CE; }
|
22
|
+
.cm-s-blackboard .cm-attribute { color: #8DA6CE; }
|
23
|
+
.cm-s-blackboard .cm-header { color: #FF6400; }
|
24
|
+
.cm-s-blackboard .cm-hr { color: #AEAEAE; }
|
25
|
+
.cm-s-blackboard .cm-link { color: #8DA6CE; }
|
@@ -0,0 +1 @@
|
|
1
|
+
NOT USED
|
@@ -7,16 +7,16 @@
|
|
7
7
|
<script type="text/javascript">
|
8
8
|
var page_id = <%= @page.id %>;
|
9
9
|
var is_draft = <%= params[:draft] ? 'true' : 'false' %>;
|
10
|
-
|
10
|
+
</script>
|
11
11
|
|
12
12
|
<%= stylesheet_link_tag 'mercury', 'mercury_editor' %>
|
13
13
|
<%= javascript_include_tag 'kit/mercury-editor' %>
|
14
14
|
<%= javascript_include_tag 'kit/utilities.js' %>
|
15
15
|
<%= javascript_include_tag 'kit/application-edit' %>
|
16
|
-
<%= javascript_include_tag "
|
17
|
-
<%=
|
18
|
-
<%= stylesheet_link_tag '
|
19
|
-
<%= stylesheet_link_tag '
|
16
|
+
<%= javascript_include_tag "codemirror/editor" %>
|
17
|
+
<%= stylesheet_link_tag 'codemirror/style.css' %>
|
18
|
+
<%= stylesheet_link_tag 'codemirror/theme.css' %>
|
19
|
+
<%= stylesheet_link_tag 'codemirror/dialog.css' %>
|
20
20
|
|
21
21
|
</head>
|
22
22
|
<body>
|
@@ -1,14 +1,39 @@
|
|
1
1
|
%form(id="mercury_html_editor" style="width:900px;")
|
2
|
-
%textarea(class="mercury-display-pane-container" id='edit' )
|
2
|
+
%textarea(class="mercury-display-pane-container" id='edit' style="" )
|
3
3
|
|
4
4
|
.mercury-display-controls
|
5
5
|
%fieldset(class="buttons")
|
6
6
|
%ol
|
7
|
+
%li(class="commit button" style='margin-right: 610px;')
|
8
|
+
%input(class="submit" onClick="parent.frames[0].lorem();" type="button" value="Lorem Ipsum")
|
7
9
|
%li(class="commit button")
|
8
|
-
%input(class="submit" name="commit" type="submit" value="Save and Replace")
|
10
|
+
%input(onClick="parent.frames[0].html_editor.toTextArea(); " class="submit" name="commit" type="submit" value="Save and Replace")
|
9
11
|
|
12
|
+
/ Note, the dialog box in which this appears is in the context of the parent window, but the page which you're editing is the context of an iframe
|
13
|
+
|
10
14
|
%script(type='text/javascript')
|
15
|
+
var html_editor;
|
11
16
|
$(document).ready(function() {
|
12
|
-
|
17
|
+
setTimeout(setup_editor, 200);
|
13
18
|
});
|
14
19
|
|
20
|
+
function setup_editor() {
|
21
|
+
var editor_a = parent.document.getElementById('edit');
|
22
|
+
var options = { lineNumbers: true, theme: 'blackboard', indentUnit: 2, lineWrapping: true, matchBrackets: true , collapseRange: true};
|
23
|
+
html_editor = parent.CodeMirror.fromTextArea(editor_a, options);
|
24
|
+
html_editor.focus();
|
25
|
+
html_editor.on('change', function() {
|
26
|
+
console.debug(html_editor.getValue());
|
27
|
+
});
|
28
|
+
}
|
29
|
+
|
30
|
+
function the_editor() {
|
31
|
+
return parent.frames[0].html_editor;
|
32
|
+
}
|
33
|
+
|
34
|
+
function lorem() {
|
35
|
+
the_editor().replaceSelection('Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.');
|
36
|
+
the_editor().focus();
|
37
|
+
}
|
38
|
+
|
39
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kit_cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -59,6 +59,22 @@ dependencies:
|
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: kiteditor
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.0.5
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 1.0.5
|
62
78
|
- !ruby/object:Gem::Dependency
|
63
79
|
name: tire
|
64
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -2383,6 +2399,24 @@ files:
|
|
2383
2399
|
- app/assets/javascripts/admin/kit_engagement.js
|
2384
2400
|
- app/assets/javascripts/admin/order.js
|
2385
2401
|
- app/assets/javascripts/application.js
|
2402
|
+
- app/assets/javascripts/codemirror/codemirror.js
|
2403
|
+
- app/assets/javascripts/codemirror/collapserange.js
|
2404
|
+
- app/assets/javascripts/codemirror/css.js
|
2405
|
+
- app/assets/javascripts/codemirror/dialog.js
|
2406
|
+
- app/assets/javascripts/codemirror/editor.js
|
2407
|
+
- app/assets/javascripts/codemirror/foldcode.js
|
2408
|
+
- app/assets/javascripts/codemirror/formatting.js
|
2409
|
+
- app/assets/javascripts/codemirror/htmlmixed.js
|
2410
|
+
- app/assets/javascripts/codemirror/javascript.js
|
2411
|
+
- app/assets/javascripts/codemirror/jquery.js
|
2412
|
+
- app/assets/javascripts/codemirror/loadmode.js
|
2413
|
+
- app/assets/javascripts/codemirror/match-highlighter.js
|
2414
|
+
- app/assets/javascripts/codemirror/matchbrackets.js
|
2415
|
+
- app/assets/javascripts/codemirror/multiplex.js
|
2416
|
+
- app/assets/javascripts/codemirror/overlay.js
|
2417
|
+
- app/assets/javascripts/codemirror/search.js
|
2418
|
+
- app/assets/javascripts/codemirror/searchcursor.js
|
2419
|
+
- app/assets/javascripts/codemirror/xml.js
|
2386
2420
|
- app/assets/javascripts/kit/ace/ace.js
|
2387
2421
|
- app/assets/javascripts/kit/ace/ext-static_highlight.js
|
2388
2422
|
- app/assets/javascripts/kit/ace/ext-textarea.js
|
@@ -2536,8 +2570,6 @@ files:
|
|
2536
2570
|
- app/assets/javascripts/kit/jquery.validate.js
|
2537
2571
|
- app/assets/javascripts/kit/jsplumb-min.js
|
2538
2572
|
- app/assets/javascripts/kit/markdown.js
|
2539
|
-
- app/assets/javascripts/kit/markitup/jquery.markitup.js
|
2540
|
-
- app/assets/javascripts/kit/markitup/settings.js
|
2541
2573
|
- app/assets/javascripts/kit/mercury-editor.js.erb
|
2542
2574
|
- app/assets/javascripts/kit/messaging.js
|
2543
2575
|
- app/assets/javascripts/kit/rails_admin/application.js
|
@@ -2606,6 +2638,9 @@ files:
|
|
2606
2638
|
- app/assets/stylesheets/admin/kit_engagement.css
|
2607
2639
|
- app/assets/stylesheets/admin/order.css
|
2608
2640
|
- app/assets/stylesheets/application.css
|
2641
|
+
- app/assets/stylesheets/codemirror/dialog.css
|
2642
|
+
- app/assets/stylesheets/codemirror/style.css
|
2643
|
+
- app/assets/stylesheets/codemirror/theme.css
|
2609
2644
|
- app/assets/stylesheets/jquery.fileupload-ui.css
|
2610
2645
|
- app/assets/stylesheets/kit/calendar.css
|
2611
2646
|
- app/assets/stylesheets/kit/cms/cms.css
|
@@ -2615,39 +2650,6 @@ files:
|
|
2615
2650
|
- app/assets/stylesheets/kit/fancybox.css
|
2616
2651
|
- app/assets/stylesheets/kit/forums.css
|
2617
2652
|
- app/assets/stylesheets/kit/markdown.css
|
2618
|
-
- app/assets/stylesheets/kit/markitup/html.css
|
2619
|
-
- app/assets/stylesheets/kit/markitup/images/bg-container.png
|
2620
|
-
- app/assets/stylesheets/kit/markitup/images/bg-editor-bbcode.png
|
2621
|
-
- app/assets/stylesheets/kit/markitup/images/bg-editor-dotclear.png
|
2622
|
-
- app/assets/stylesheets/kit/markitup/images/bg-editor-html.png
|
2623
|
-
- app/assets/stylesheets/kit/markitup/images/bg-editor-json.png
|
2624
|
-
- app/assets/stylesheets/kit/markitup/images/bg-editor-markdown.png
|
2625
|
-
- app/assets/stylesheets/kit/markitup/images/bg-editor-textile.png
|
2626
|
-
- app/assets/stylesheets/kit/markitup/images/bg-editor-wiki.png
|
2627
|
-
- app/assets/stylesheets/kit/markitup/images/bg-editor-xml.png
|
2628
|
-
- app/assets/stylesheets/kit/markitup/images/bg-editor.png
|
2629
|
-
- app/assets/stylesheets/kit/markitup/images/bold.png
|
2630
|
-
- app/assets/stylesheets/kit/markitup/images/clean.png
|
2631
|
-
- app/assets/stylesheets/kit/markitup/images/h1.png
|
2632
|
-
- app/assets/stylesheets/kit/markitup/images/h2.png
|
2633
|
-
- app/assets/stylesheets/kit/markitup/images/h3.png
|
2634
|
-
- app/assets/stylesheets/kit/markitup/images/h4.png
|
2635
|
-
- app/assets/stylesheets/kit/markitup/images/h5.png
|
2636
|
-
- app/assets/stylesheets/kit/markitup/images/h6.png
|
2637
|
-
- app/assets/stylesheets/kit/markitup/images/handle.png
|
2638
|
-
- app/assets/stylesheets/kit/markitup/images/image.png
|
2639
|
-
- app/assets/stylesheets/kit/markitup/images/italic.png
|
2640
|
-
- app/assets/stylesheets/kit/markitup/images/link.png
|
2641
|
-
- app/assets/stylesheets/kit/markitup/images/list-bullet.png
|
2642
|
-
- app/assets/stylesheets/kit/markitup/images/list-item.png
|
2643
|
-
- app/assets/stylesheets/kit/markitup/images/list-numeric.png
|
2644
|
-
- app/assets/stylesheets/kit/markitup/images/menu.png
|
2645
|
-
- app/assets/stylesheets/kit/markitup/images/paragraph.png
|
2646
|
-
- app/assets/stylesheets/kit/markitup/images/picture.png
|
2647
|
-
- app/assets/stylesheets/kit/markitup/images/preview.png
|
2648
|
-
- app/assets/stylesheets/kit/markitup/images/stroke.png
|
2649
|
-
- app/assets/stylesheets/kit/markitup/images/submenu.png
|
2650
|
-
- app/assets/stylesheets/kit/markitup/style.css
|
2651
2653
|
- app/assets/stylesheets/kit/rails_admin/aristo/images/bg_fallback.png
|
2652
2654
|
- app/assets/stylesheets/kit/rails_admin/aristo/images/icon_sprite.png
|
2653
2655
|
- app/assets/stylesheets/kit/rails_admin/aristo/images/progress_bar.gif
|
@@ -3256,6 +3258,7 @@ files:
|
|
3256
3258
|
- app/views/images/index.js.erb
|
3257
3259
|
- app/views/images/media_modal.html.erb
|
3258
3260
|
- app/views/layouts/_cms-common.html.erb
|
3261
|
+
- app/views/layouts/_html-editor.html.haml
|
3259
3262
|
- app/views/layouts/_kit_header.html.haml
|
3260
3263
|
- app/views/layouts/_messages.html.haml
|
3261
3264
|
- app/views/layouts/admin.html.erb
|
@@ -3388,7 +3391,6 @@ files:
|
|
3388
3391
|
- lib/generators/initializer/initializer_generator.rb
|
3389
3392
|
- lib/generators/initializer/USAGE
|
3390
3393
|
- lib/kit_cms/engine.rb
|
3391
|
-
- lib/kit_cms/version.rb
|
3392
3394
|
- lib/kit_cms.rb
|
3393
3395
|
- lib/recipes/aaf_recipes.rb
|
3394
3396
|
- lib/simple_rss.rb
|
@@ -3744,7 +3746,7 @@ rubyforge_project:
|
|
3744
3746
|
rubygems_version: 1.8.24
|
3745
3747
|
signing_key:
|
3746
3748
|
specification_version: 3
|
3747
|
-
summary: Community and Content Management System as a Rails 3.
|
3749
|
+
summary: Community and Content Management System as a Rails 3.2+ Engine
|
3748
3750
|
test_files:
|
3749
3751
|
- test/dummy/app/assets/javascripts/application.js
|
3750
3752
|
- test/dummy/app/assets/javascripts/application.js.erb
|
@@ -1,634 +0,0 @@
|
|
1
|
-
// ----------------------------------------------------------------------------
|
2
|
-
// markItUp! Universal MarkUp Engine, JQuery plugin
|
3
|
-
// v 1.1.x
|
4
|
-
// Dual licensed under the MIT and GPL licenses.
|
5
|
-
// ----------------------------------------------------------------------------
|
6
|
-
// Copyright (C) 2007-2012 Jay Salvat
|
7
|
-
// http://markitup.jaysalvat.com/
|
8
|
-
// ----------------------------------------------------------------------------
|
9
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
10
|
-
// of this software and associated documentation files (the "Software"), to deal
|
11
|
-
// in the Software without restriction, including without limitation the rights
|
12
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
13
|
-
// copies of the Software, and to permit persons to whom the Software is
|
14
|
-
// furnished to do so, subject to the following conditions:
|
15
|
-
//
|
16
|
-
// The above copyright notice and this permission notice shall be included in
|
17
|
-
// all copies or substantial portions of the Software.
|
18
|
-
//
|
19
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
20
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
21
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
22
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
23
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
24
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
25
|
-
// THE SOFTWARE.
|
26
|
-
// ----------------------------------------------------------------------------
|
27
|
-
(function($) {
|
28
|
-
$.fn.markItUp = function(settings, extraSettings) {
|
29
|
-
var method, params, options, ctrlKey, shiftKey, altKey; ctrlKey = shiftKey = altKey = false;
|
30
|
-
|
31
|
-
if (typeof settings == 'string') {
|
32
|
-
method = settings;
|
33
|
-
params = extraSettings;
|
34
|
-
}
|
35
|
-
|
36
|
-
options = { id: '',
|
37
|
-
nameSpace: '',
|
38
|
-
root: '',
|
39
|
-
previewHandler: false,
|
40
|
-
previewInWindow: '', // 'width=800, height=600, resizable=yes, scrollbars=yes'
|
41
|
-
previewInElement: '',
|
42
|
-
previewAutoRefresh: true,
|
43
|
-
previewPosition: 'after',
|
44
|
-
previewTemplatePath: '~/templates/preview.html',
|
45
|
-
previewParser: false,
|
46
|
-
previewParserPath: '',
|
47
|
-
previewParserVar: 'data',
|
48
|
-
resizeHandle: true,
|
49
|
-
beforeInsert: '',
|
50
|
-
afterInsert: '',
|
51
|
-
onEnter: {},
|
52
|
-
onShiftEnter: {},
|
53
|
-
onCtrlEnter: {},
|
54
|
-
onTab: {},
|
55
|
-
markupSet: [ { /* set */ } ]
|
56
|
-
};
|
57
|
-
$.extend(options, settings, extraSettings);
|
58
|
-
|
59
|
-
// compute markItUp! path
|
60
|
-
if (!options.root) {
|
61
|
-
$('script').each(function(a, tag) {
|
62
|
-
miuScript = $(tag).get(0).src.match(/(.*)jquery\.markitup(\.pack)?\.js$/);
|
63
|
-
if (miuScript !== null) {
|
64
|
-
options.root = miuScript[1];
|
65
|
-
}
|
66
|
-
});
|
67
|
-
}
|
68
|
-
|
69
|
-
return this.each(function() {
|
70
|
-
var $$, textarea, levels, scrollPosition, caretPosition, caretOffset,
|
71
|
-
clicked, hash, header, footer, previewWindow, template, iFrame, abort;
|
72
|
-
$$ = $(this);
|
73
|
-
textarea = this;
|
74
|
-
levels = [];
|
75
|
-
abort = false;
|
76
|
-
scrollPosition = caretPosition = 0;
|
77
|
-
caretOffset = -1;
|
78
|
-
|
79
|
-
options.previewParserPath = localize(options.previewParserPath);
|
80
|
-
options.previewTemplatePath = localize(options.previewTemplatePath);
|
81
|
-
|
82
|
-
if (method) {
|
83
|
-
switch(method) {
|
84
|
-
case 'remove':
|
85
|
-
remove();
|
86
|
-
break;
|
87
|
-
case 'insert':
|
88
|
-
markup(params);
|
89
|
-
break;
|
90
|
-
default:
|
91
|
-
$.error('Method ' + method + ' does not exist on jQuery.markItUp');
|
92
|
-
}
|
93
|
-
return;
|
94
|
-
}
|
95
|
-
|
96
|
-
// apply the computed path to ~/
|
97
|
-
function localize(data, inText) {
|
98
|
-
if (inText) {
|
99
|
-
return data.replace(/("|')~\//g, "$1"+options.root);
|
100
|
-
}
|
101
|
-
return data.replace(/^~\//, options.root);
|
102
|
-
}
|
103
|
-
|
104
|
-
// init and build editor
|
105
|
-
function init() {
|
106
|
-
id = ''; nameSpace = '';
|
107
|
-
if (options.id) {
|
108
|
-
id = 'id="'+options.id+'"';
|
109
|
-
} else if ($$.attr("id")) {
|
110
|
-
id = 'id="markItUp'+($$.attr("id").substr(0, 1).toUpperCase())+($$.attr("id").substr(1))+'"';
|
111
|
-
|
112
|
-
}
|
113
|
-
if (options.nameSpace) {
|
114
|
-
nameSpace = 'class="'+options.nameSpace+'"';
|
115
|
-
}
|
116
|
-
$$.wrap('<div '+nameSpace+'></div>');
|
117
|
-
$$.wrap('<div '+id+' class="markItUp"></div>');
|
118
|
-
$$.wrap('<div class="markItUpContainer"></div>');
|
119
|
-
$$.addClass("markItUpEditor");
|
120
|
-
|
121
|
-
// add the header before the textarea
|
122
|
-
header = $('<div class="markItUpHeader"></div>').insertBefore($$);
|
123
|
-
$(dropMenus(options.markupSet)).appendTo(header);
|
124
|
-
|
125
|
-
// add the footer after the textarea
|
126
|
-
footer = $('<div class="markItUpFooter"></div>').insertAfter($$);
|
127
|
-
|
128
|
-
// add the resize handle after textarea
|
129
|
-
if (options.resizeHandle === true && $.browser.safari !== true) {
|
130
|
-
resizeHandle = $('<div class="markItUpResizeHandle"></div>')
|
131
|
-
.insertAfter($$)
|
132
|
-
.bind("mousedown.markItUp", function(e) {
|
133
|
-
var h = $$.height(), y = e.clientY, mouseMove, mouseUp;
|
134
|
-
mouseMove = function(e) {
|
135
|
-
$$.css("height", Math.max(20, e.clientY+h-y)+"px");
|
136
|
-
return false;
|
137
|
-
};
|
138
|
-
mouseUp = function(e) {
|
139
|
-
$("html").unbind("mousemove.markItUp", mouseMove).unbind("mouseup.markItUp", mouseUp);
|
140
|
-
return false;
|
141
|
-
};
|
142
|
-
$("html").bind("mousemove.markItUp", mouseMove).bind("mouseup.markItUp", mouseUp);
|
143
|
-
});
|
144
|
-
footer.append(resizeHandle);
|
145
|
-
}
|
146
|
-
|
147
|
-
// listen key events
|
148
|
-
$$.bind('keydown.markItUp', keyPressed).bind('keyup', keyPressed);
|
149
|
-
|
150
|
-
// bind an event to catch external calls
|
151
|
-
$$.bind("insertion.markItUp", function(e, settings) {
|
152
|
-
if (settings.target !== false) {
|
153
|
-
get();
|
154
|
-
}
|
155
|
-
if (textarea === $.markItUp.focused) {
|
156
|
-
markup(settings);
|
157
|
-
}
|
158
|
-
});
|
159
|
-
|
160
|
-
// remember the last focus
|
161
|
-
$$.bind('focus.markItUp', function() {
|
162
|
-
$.markItUp.focused = this;
|
163
|
-
});
|
164
|
-
|
165
|
-
if (options.previewInElement) {
|
166
|
-
refreshPreview();
|
167
|
-
}
|
168
|
-
}
|
169
|
-
|
170
|
-
// recursively build header with dropMenus from markupset
|
171
|
-
function dropMenus(markupSet) {
|
172
|
-
var ul = $('<ul></ul>'), i = 0;
|
173
|
-
$('li:hover > ul', ul).css('display', 'block');
|
174
|
-
$.each(markupSet, function() {
|
175
|
-
var button = this, t = '', title, li, j;
|
176
|
-
title = (button.key) ? (button.name||'')+' [Ctrl+'+button.key+']' : (button.name||'');
|
177
|
-
key = (button.key) ? 'accesskey="'+button.key+'"' : '';
|
178
|
-
if (button.separator) {
|
179
|
-
li = $('<li class="markItUpSeparator">'+(button.separator||'')+'</li>').appendTo(ul);
|
180
|
-
} else {
|
181
|
-
i++;
|
182
|
-
for (j = levels.length -1; j >= 0; j--) {
|
183
|
-
t += levels[j]+"-";
|
184
|
-
}
|
185
|
-
li = $('<li class="markItUpButton markItUpButton'+t+(i)+' '+(button.className||'')+'"><a href="" '+key+' title="'+title+'">'+(button.name||'')+'</a></li>')
|
186
|
-
.bind("contextmenu.markItUp", function() { // prevent contextmenu on mac and allow ctrl+click
|
187
|
-
return false;
|
188
|
-
}).bind('click.markItUp', function() {
|
189
|
-
return false;
|
190
|
-
}).bind("focusin.markItUp", function(){
|
191
|
-
$$.focus();
|
192
|
-
}).bind('mouseup', function() {
|
193
|
-
if (button.call) {
|
194
|
-
eval(button.call)();
|
195
|
-
}
|
196
|
-
setTimeout(function() { markup(button) },1);
|
197
|
-
return false;
|
198
|
-
}).bind('mouseenter.markItUp', function() {
|
199
|
-
$('> ul', this).show();
|
200
|
-
$(document).one('click', function() { // close dropmenu if click outside
|
201
|
-
$('ul ul', header).hide();
|
202
|
-
}
|
203
|
-
);
|
204
|
-
}).bind('mouseleave.markItUp', function() {
|
205
|
-
$('> ul', this).hide();
|
206
|
-
}).appendTo(ul);
|
207
|
-
if (button.dropMenu) {
|
208
|
-
levels.push(i);
|
209
|
-
$(li).addClass('markItUpDropMenu').append(dropMenus(button.dropMenu));
|
210
|
-
}
|
211
|
-
}
|
212
|
-
});
|
213
|
-
levels.pop();
|
214
|
-
return ul;
|
215
|
-
}
|
216
|
-
|
217
|
-
// markItUp! markups
|
218
|
-
function magicMarkups(string) {
|
219
|
-
if (string) {
|
220
|
-
string = string.toString();
|
221
|
-
string = string.replace(/\(\!\(([\s\S]*?)\)\!\)/g,
|
222
|
-
function(x, a) {
|
223
|
-
var b = a.split('|!|');
|
224
|
-
if (altKey === true) {
|
225
|
-
return (b[1] !== undefined) ? b[1] : b[0];
|
226
|
-
} else {
|
227
|
-
return (b[1] === undefined) ? "" : b[0];
|
228
|
-
}
|
229
|
-
}
|
230
|
-
);
|
231
|
-
// [![prompt]!], [![prompt:!:value]!]
|
232
|
-
string = string.replace(/\[\!\[([\s\S]*?)\]\!\]/g,
|
233
|
-
function(x, a) {
|
234
|
-
var b = a.split(':!:');
|
235
|
-
if (abort === true) {
|
236
|
-
return false;
|
237
|
-
}
|
238
|
-
value = prompt(b[0], (b[1]) ? b[1] : '');
|
239
|
-
if (value === null) {
|
240
|
-
abort = true;
|
241
|
-
}
|
242
|
-
return value;
|
243
|
-
}
|
244
|
-
);
|
245
|
-
return string;
|
246
|
-
}
|
247
|
-
return "";
|
248
|
-
}
|
249
|
-
|
250
|
-
// prepare action
|
251
|
-
function prepare(action) {
|
252
|
-
if ($.isFunction(action)) {
|
253
|
-
action = action(hash);
|
254
|
-
}
|
255
|
-
return magicMarkups(action);
|
256
|
-
}
|
257
|
-
|
258
|
-
// build block to insert
|
259
|
-
function build(string) {
|
260
|
-
var openWith = prepare(clicked.openWith);
|
261
|
-
var placeHolder = prepare(clicked.placeHolder);
|
262
|
-
var replaceWith = prepare(clicked.replaceWith);
|
263
|
-
var closeWith = prepare(clicked.closeWith);
|
264
|
-
var openBlockWith = prepare(clicked.openBlockWith);
|
265
|
-
var closeBlockWith = prepare(clicked.closeBlockWith);
|
266
|
-
var multiline = clicked.multiline;
|
267
|
-
|
268
|
-
if (replaceWith !== "") {
|
269
|
-
block = openWith + replaceWith + closeWith;
|
270
|
-
} else if (selection === '' && placeHolder !== '') {
|
271
|
-
block = openWith + placeHolder + closeWith;
|
272
|
-
} else {
|
273
|
-
string = string || selection;
|
274
|
-
|
275
|
-
var lines = [string], blocks = [];
|
276
|
-
|
277
|
-
if (multiline === true) {
|
278
|
-
lines = string.split(/\r?\n/);
|
279
|
-
}
|
280
|
-
|
281
|
-
for (var l = 0; l < lines.length; l++) {
|
282
|
-
line = lines[l];
|
283
|
-
var trailingSpaces;
|
284
|
-
if (trailingSpaces = line.match(/ *$/)) {
|
285
|
-
blocks.push(openWith + line.replace(/ *$/g, '') + closeWith + trailingSpaces);
|
286
|
-
} else {
|
287
|
-
blocks.push(openWith + line + closeWith);
|
288
|
-
}
|
289
|
-
}
|
290
|
-
|
291
|
-
block = blocks.join("\n");
|
292
|
-
}
|
293
|
-
|
294
|
-
block = openBlockWith + block + closeBlockWith;
|
295
|
-
|
296
|
-
return { block:block,
|
297
|
-
openWith:openWith,
|
298
|
-
replaceWith:replaceWith,
|
299
|
-
placeHolder:placeHolder,
|
300
|
-
closeWith:closeWith
|
301
|
-
};
|
302
|
-
}
|
303
|
-
|
304
|
-
// define markup to insert
|
305
|
-
function markup(button) {
|
306
|
-
var len, j, n, i;
|
307
|
-
hash = clicked = button;
|
308
|
-
get();
|
309
|
-
$.extend(hash, { line:"",
|
310
|
-
root:options.root,
|
311
|
-
textarea:textarea,
|
312
|
-
selection:(selection||''),
|
313
|
-
caretPosition:caretPosition,
|
314
|
-
ctrlKey:ctrlKey,
|
315
|
-
shiftKey:shiftKey,
|
316
|
-
altKey:altKey
|
317
|
-
}
|
318
|
-
);
|
319
|
-
// callbacks before insertion
|
320
|
-
prepare(options.beforeInsert);
|
321
|
-
prepare(clicked.beforeInsert);
|
322
|
-
if ((ctrlKey === true && shiftKey === true) || button.multiline === true) {
|
323
|
-
prepare(clicked.beforeMultiInsert);
|
324
|
-
}
|
325
|
-
$.extend(hash, { line:1 });
|
326
|
-
|
327
|
-
if ((ctrlKey === true && shiftKey === true)) {
|
328
|
-
lines = selection.split(/\r?\n/);
|
329
|
-
for (j = 0, n = lines.length, i = 0; i < n; i++) {
|
330
|
-
if ($.trim(lines[i]) !== '') {
|
331
|
-
$.extend(hash, { line:++j, selection:lines[i] } );
|
332
|
-
lines[i] = build(lines[i]).block;
|
333
|
-
} else {
|
334
|
-
lines[i] = "";
|
335
|
-
}
|
336
|
-
}
|
337
|
-
|
338
|
-
string = { block:lines.join('\n')};
|
339
|
-
start = caretPosition;
|
340
|
-
len = string.block.length + (($.browser.opera) ? n-1 : 0);
|
341
|
-
} else if (ctrlKey === true) {
|
342
|
-
string = build(selection);
|
343
|
-
start = caretPosition + string.openWith.length;
|
344
|
-
len = string.block.length - string.openWith.length - string.closeWith.length;
|
345
|
-
len = len - (string.block.match(/ $/) ? 1 : 0);
|
346
|
-
len -= fixIeBug(string.block);
|
347
|
-
} else if (shiftKey === true) {
|
348
|
-
string = build(selection);
|
349
|
-
start = caretPosition;
|
350
|
-
len = string.block.length;
|
351
|
-
len -= fixIeBug(string.block);
|
352
|
-
} else {
|
353
|
-
string = build(selection);
|
354
|
-
start = caretPosition + string.block.length ;
|
355
|
-
len = 0;
|
356
|
-
start -= fixIeBug(string.block);
|
357
|
-
}
|
358
|
-
if ((selection === '' && string.replaceWith === '')) {
|
359
|
-
caretOffset += fixOperaBug(string.block);
|
360
|
-
|
361
|
-
start = caretPosition + string.openWith.length;
|
362
|
-
len = string.block.length - string.openWith.length - string.closeWith.length;
|
363
|
-
|
364
|
-
caretOffset = $$.val().substring(caretPosition, $$.val().length).length;
|
365
|
-
caretOffset -= fixOperaBug($$.val().substring(0, caretPosition));
|
366
|
-
}
|
367
|
-
$.extend(hash, { caretPosition:caretPosition, scrollPosition:scrollPosition } );
|
368
|
-
|
369
|
-
if (string.block !== selection && abort === false) {
|
370
|
-
insert(string.block);
|
371
|
-
set(start, len);
|
372
|
-
} else {
|
373
|
-
caretOffset = -1;
|
374
|
-
}
|
375
|
-
get();
|
376
|
-
|
377
|
-
$.extend(hash, { line:'', selection:selection });
|
378
|
-
|
379
|
-
// callbacks after insertion
|
380
|
-
if ((ctrlKey === true && shiftKey === true) || button.multiline === true) {
|
381
|
-
prepare(clicked.afterMultiInsert);
|
382
|
-
}
|
383
|
-
prepare(clicked.afterInsert);
|
384
|
-
prepare(options.afterInsert);
|
385
|
-
|
386
|
-
// refresh preview if opened
|
387
|
-
if (previewWindow && options.previewAutoRefresh) {
|
388
|
-
refreshPreview();
|
389
|
-
}
|
390
|
-
|
391
|
-
// reinit keyevent
|
392
|
-
shiftKey = altKey = ctrlKey = abort = false;
|
393
|
-
}
|
394
|
-
|
395
|
-
// Substract linefeed in Opera
|
396
|
-
function fixOperaBug(string) {
|
397
|
-
if ($.browser.opera) {
|
398
|
-
return string.length - string.replace(/\n*/g, '').length;
|
399
|
-
}
|
400
|
-
return 0;
|
401
|
-
}
|
402
|
-
// Substract linefeed in IE
|
403
|
-
function fixIeBug(string) {
|
404
|
-
if ($.browser.msie) {
|
405
|
-
return string.length - string.replace(/\r*/g, '').length;
|
406
|
-
}
|
407
|
-
return 0;
|
408
|
-
}
|
409
|
-
|
410
|
-
// add markup
|
411
|
-
function insert(block) {
|
412
|
-
if (document.selection) {
|
413
|
-
var newSelection = document.selection.createRange();
|
414
|
-
newSelection.text = block;
|
415
|
-
} else {
|
416
|
-
textarea.value = textarea.value.substring(0, caretPosition) + block + textarea.value.substring(caretPosition + selection.length, textarea.value.length);
|
417
|
-
}
|
418
|
-
}
|
419
|
-
|
420
|
-
// set a selection
|
421
|
-
function set(start, len) {
|
422
|
-
if (textarea.createTextRange){
|
423
|
-
// quick fix to make it work on Opera 9.5
|
424
|
-
if ($.browser.opera && $.browser.version >= 9.5 && len == 0) {
|
425
|
-
return false;
|
426
|
-
}
|
427
|
-
range = textarea.createTextRange();
|
428
|
-
range.collapse(true);
|
429
|
-
range.moveStart('character', start);
|
430
|
-
range.moveEnd('character', len);
|
431
|
-
range.select();
|
432
|
-
} else if (textarea.setSelectionRange ){
|
433
|
-
textarea.setSelectionRange(start, start + len);
|
434
|
-
}
|
435
|
-
textarea.scrollTop = scrollPosition;
|
436
|
-
textarea.focus();
|
437
|
-
}
|
438
|
-
|
439
|
-
// get the selection
|
440
|
-
function get() {
|
441
|
-
textarea.focus();
|
442
|
-
|
443
|
-
scrollPosition = textarea.scrollTop;
|
444
|
-
if (document.selection) {
|
445
|
-
selection = document.selection.createRange().text;
|
446
|
-
if ($.browser.msie) { // ie
|
447
|
-
var range = document.selection.createRange(), rangeCopy = range.duplicate();
|
448
|
-
rangeCopy.moveToElementText(textarea);
|
449
|
-
caretPosition = -1;
|
450
|
-
while(rangeCopy.inRange(range)) {
|
451
|
-
rangeCopy.moveStart('character');
|
452
|
-
caretPosition ++;
|
453
|
-
}
|
454
|
-
} else { // opera
|
455
|
-
caretPosition = textarea.selectionStart;
|
456
|
-
}
|
457
|
-
} else { // gecko & webkit
|
458
|
-
caretPosition = textarea.selectionStart;
|
459
|
-
|
460
|
-
selection = textarea.value.substring(caretPosition, textarea.selectionEnd);
|
461
|
-
}
|
462
|
-
return selection;
|
463
|
-
}
|
464
|
-
|
465
|
-
// open preview window
|
466
|
-
function preview() {
|
467
|
-
if (typeof options.previewHandler === 'function') {
|
468
|
-
previewWindow = true;
|
469
|
-
} else if (options.previewInElement) {
|
470
|
-
previewWindow = $(options.previewInElement);
|
471
|
-
} else if (!previewWindow || previewWindow.closed) {
|
472
|
-
if (options.previewInWindow) {
|
473
|
-
previewWindow = window.open('', 'preview', options.previewInWindow);
|
474
|
-
$(window).unload(function() {
|
475
|
-
previewWindow.close();
|
476
|
-
});
|
477
|
-
} else {
|
478
|
-
iFrame = $('<iframe class="markItUpPreviewFrame"></iframe>');
|
479
|
-
if (options.previewPosition == 'after') {
|
480
|
-
iFrame.insertAfter(footer);
|
481
|
-
} else {
|
482
|
-
iFrame.insertBefore(header);
|
483
|
-
}
|
484
|
-
previewWindow = iFrame[iFrame.length - 1].contentWindow || frame[iFrame.length - 1];
|
485
|
-
}
|
486
|
-
} else if (altKey === true) {
|
487
|
-
if (iFrame) {
|
488
|
-
iFrame.remove();
|
489
|
-
} else {
|
490
|
-
previewWindow.close();
|
491
|
-
}
|
492
|
-
previewWindow = iFrame = false;
|
493
|
-
}
|
494
|
-
if (!options.previewAutoRefresh) {
|
495
|
-
refreshPreview();
|
496
|
-
}
|
497
|
-
if (options.previewInWindow) {
|
498
|
-
previewWindow.focus();
|
499
|
-
}
|
500
|
-
}
|
501
|
-
|
502
|
-
// refresh Preview window
|
503
|
-
function refreshPreview() {
|
504
|
-
renderPreview();
|
505
|
-
}
|
506
|
-
|
507
|
-
function renderPreview() {
|
508
|
-
var phtml;
|
509
|
-
if (options.previewHandler && typeof options.previewHandler === 'function') {
|
510
|
-
options.previewHandler( $$.val() );
|
511
|
-
} else if (options.previewParser && typeof options.previewParser === 'function') {
|
512
|
-
var data = options.previewParser( $$.val() );
|
513
|
-
writeInPreview(localize(data, 1) );
|
514
|
-
} else if (options.previewParserPath !== '') {
|
515
|
-
$.ajax({
|
516
|
-
type: 'POST',
|
517
|
-
dataType: 'text',
|
518
|
-
global: false,
|
519
|
-
url: options.previewParserPath,
|
520
|
-
data: options.previewParserVar+'='+encodeURIComponent($$.val()),
|
521
|
-
success: function(data) {
|
522
|
-
writeInPreview( localize(data, 1) );
|
523
|
-
}
|
524
|
-
});
|
525
|
-
} else {
|
526
|
-
if (!template) {
|
527
|
-
$.ajax({
|
528
|
-
url: options.previewTemplatePath,
|
529
|
-
dataType: 'text',
|
530
|
-
global: false,
|
531
|
-
success: function(data) {
|
532
|
-
writeInPreview( localize(data, 1).replace(/<!-- content -->/g, $$.val()) );
|
533
|
-
}
|
534
|
-
});
|
535
|
-
}
|
536
|
-
}
|
537
|
-
return false;
|
538
|
-
}
|
539
|
-
|
540
|
-
function writeInPreview(data) {
|
541
|
-
if (options.previewInElement) {
|
542
|
-
$(options.previewInElement).html(data);
|
543
|
-
} else if (previewWindow && previewWindow.document) {
|
544
|
-
try {
|
545
|
-
sp = previewWindow.document.documentElement.scrollTop
|
546
|
-
} catch(e) {
|
547
|
-
sp = 0;
|
548
|
-
}
|
549
|
-
previewWindow.document.open();
|
550
|
-
previewWindow.document.write(data);
|
551
|
-
previewWindow.document.close();
|
552
|
-
previewWindow.document.documentElement.scrollTop = sp;
|
553
|
-
}
|
554
|
-
}
|
555
|
-
|
556
|
-
// set keys pressed
|
557
|
-
function keyPressed(e) {
|
558
|
-
shiftKey = e.shiftKey;
|
559
|
-
altKey = e.altKey;
|
560
|
-
ctrlKey = (!(e.altKey && e.ctrlKey)) ? (e.ctrlKey || e.metaKey) : false;
|
561
|
-
|
562
|
-
if (e.type === 'keydown') {
|
563
|
-
if (ctrlKey === true) {
|
564
|
-
li = $('a[accesskey="'+((e.keyCode == 13) ? '\\n' : String.fromCharCode(e.keyCode))+'"]', header).parent('li');
|
565
|
-
if (li.length !== 0) {
|
566
|
-
ctrlKey = false;
|
567
|
-
setTimeout(function() {
|
568
|
-
li.triggerHandler('mouseup');
|
569
|
-
},1);
|
570
|
-
return false;
|
571
|
-
}
|
572
|
-
}
|
573
|
-
if (e.keyCode === 13 || e.keyCode === 10) { // Enter key
|
574
|
-
if (ctrlKey === true) { // Enter + Ctrl
|
575
|
-
ctrlKey = false;
|
576
|
-
markup(options.onCtrlEnter);
|
577
|
-
return options.onCtrlEnter.keepDefault;
|
578
|
-
} else if (shiftKey === true) { // Enter + Shift
|
579
|
-
shiftKey = false;
|
580
|
-
markup(options.onShiftEnter);
|
581
|
-
return options.onShiftEnter.keepDefault;
|
582
|
-
} else { // only Enter
|
583
|
-
markup(options.onEnter);
|
584
|
-
return options.onEnter.keepDefault;
|
585
|
-
}
|
586
|
-
}
|
587
|
-
if (e.keyCode === 9) { // Tab key
|
588
|
-
if (shiftKey == true || ctrlKey == true || altKey == true) {
|
589
|
-
return false;
|
590
|
-
}
|
591
|
-
if (caretOffset !== -1) {
|
592
|
-
get();
|
593
|
-
caretOffset = $$.val().length - caretOffset;
|
594
|
-
set(caretOffset, 0);
|
595
|
-
caretOffset = -1;
|
596
|
-
return false;
|
597
|
-
} else {
|
598
|
-
markup(options.onTab);
|
599
|
-
return options.onTab.keepDefault;
|
600
|
-
}
|
601
|
-
}
|
602
|
-
}
|
603
|
-
}
|
604
|
-
|
605
|
-
function remove() {
|
606
|
-
$$.unbind(".markItUp").removeClass('markItUpEditor');
|
607
|
-
$$.parent('div').parent('div.markItUp').parent('div').replaceWith($$);
|
608
|
-
$$.data('markItUp', null);
|
609
|
-
}
|
610
|
-
|
611
|
-
init();
|
612
|
-
});
|
613
|
-
};
|
614
|
-
|
615
|
-
$.fn.markItUpRemove = function() {
|
616
|
-
return this.each(function() {
|
617
|
-
$(this).markItUp('remove');
|
618
|
-
}
|
619
|
-
);
|
620
|
-
};
|
621
|
-
|
622
|
-
$.markItUp = function(settings) {
|
623
|
-
var options = { target:false };
|
624
|
-
$.extend(options, settings);
|
625
|
-
if (options.target) {
|
626
|
-
return $(options.target).each(function() {
|
627
|
-
$(this).focus();
|
628
|
-
$(this).trigger('insertion', [options]);
|
629
|
-
});
|
630
|
-
} else {
|
631
|
-
$('textarea').trigger('insertion', [options]);
|
632
|
-
}
|
633
|
-
};
|
634
|
-
})(jQuery);
|