commit
2512676406
@ -0,0 +1,22 @@
|
||||
$(document).on('turbolinks:load', function(){
|
||||
if ($('body.admins-shixun-feedback-messages-index-page').length > 0) {
|
||||
|
||||
var baseOptions = {
|
||||
autoclose: true,
|
||||
language: 'zh-CN',
|
||||
format: 'yyyy-mm-dd 00:00:00',
|
||||
startDate: '2017-04-01'
|
||||
}
|
||||
|
||||
var defineDateRangeSelect = function(element){
|
||||
var options = $.extend({inputs: $(element).find('.start-date, .end-date')}, baseOptions);
|
||||
$(element).datepicker(options);
|
||||
|
||||
$(element).find('.start-date').datepicker().on('changeDate', function(e){
|
||||
$(element).find('.end-date').datepicker('setStartDate', e.date);
|
||||
})
|
||||
};
|
||||
|
||||
defineDateRangeSelect('.grow-date-input-daterange');
|
||||
}
|
||||
})
|
@ -0,0 +1,22 @@
|
||||
class Admins::ShixunFeedbackMessagesController < Admins::BaseController
|
||||
|
||||
def index
|
||||
@params_page = params[:page] || 1
|
||||
if params[:keyword].present?
|
||||
discusses = Discuss.joins("LEFT JOIN shixuns ON discusses.dis_id = shixuns.id AND dis_type = 'Shixun'")
|
||||
.where("shixuns.name like ?", "%#{params[:keyword]}%")
|
||||
else
|
||||
discusses = Discuss.where(:dis_type => 'Shixun').includes(:user, :dis)
|
||||
end
|
||||
|
||||
if params[:begin_date].present?
|
||||
discusses = discusses.where("discusses.created_at > ?", params[:begin_date])
|
||||
end
|
||||
|
||||
if params[:end_date].present?
|
||||
discusses = discusses.where("discusses.created_at < ?", params[:end_date])
|
||||
end
|
||||
|
||||
@discusses = paginate discusses.order("created_at desc")
|
||||
end
|
||||
end
|
@ -1,6 +1,6 @@
|
||||
class HackSet < ApplicationRecord
|
||||
validates :input, presence: { message: "测试集输入不能为空" }
|
||||
validates :output, uniqueness: { message: "测试集输出不能为空" }
|
||||
validates :output, presence: { message: "测试集输出不能为空" }
|
||||
# 编程题测试集
|
||||
belongs_to :hack
|
||||
end
|
||||
|
@ -0,0 +1,23 @@
|
||||
<% define_admin_breadcrumbs do %>
|
||||
<% add_admin_breadcrumb('实训反馈', admins_shixun_feedback_messages_path) %>
|
||||
<% end %>
|
||||
|
||||
<div class="box search-form-container">
|
||||
<%= form_tag(admins_shixun_feedback_messages_path, method: :get, class: 'form-inline search-form', remote: true) do %>
|
||||
<%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-md-4 ml-3', placeholder: '输入实训名称关键字进行搜索') %>
|
||||
<div class="time-select">
|
||||
<div class="form-group grow-date-container">
|
||||
<div class="input-group input-daterange grow-date-input-daterange">
|
||||
<%= text_field_tag :begin_date, params[:begin_date], class: 'form-control start-date mx-0', placeholder: '开始时间' %>
|
||||
<div class="input-group-prepend"><span class="input-group-text">到</span></div>
|
||||
<%= text_field_tag :end_date, params[:end_date], class: 'form-control end-date mx-0', placeholder: '结束时间' %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="box admin-list-container shixun_feedback_messages-list-container">
|
||||
<%= render(partial: 'admins/shixun_feedback_messages/shared/list', locals: {discusses: @discusses}) %>
|
||||
</div>
|
@ -0,0 +1,2 @@
|
||||
$(".shixun_feedback_messages-list-container")
|
||||
.html("<%= j render partial: "admins/shixun_feedback_messages/shared/list", locals: {discusses: @discusses} %>")
|
@ -0,0 +1,29 @@
|
||||
<table class="table table-hover text-center">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th width="5%">序号</th>
|
||||
<th width="25%" class="text-left">实训名称</th>
|
||||
<th width="50%" class="text-left">评论内容</th>
|
||||
<th width="10%">评论者</th>
|
||||
<th width="10%">评论时间</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% if discusses.present? %>
|
||||
<% discusses.each_with_index do |discuss, index| %>
|
||||
<tr>
|
||||
<td><%= (@params_page.to_i - 1) * 20 + index + 1 %></td>
|
||||
<% identifier = Game.find_by(challenge_id: discuss.challenge_id, user_id: discuss.user_id)&.identifier %>
|
||||
<td class="text-left"><%= link_to discuss.dis.name, "/tasks/#{identifier}", target: '_blank'%></td>
|
||||
<td class="text-left"><%= content_safe discuss.content %></td>
|
||||
<td><%= discuss.user.show_real_name %></td>
|
||||
<td><%= format_time discuss.created_at %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= render 'admins/shared/no_data_for_table' %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<%= render partial: 'admins/shared/paginate', locals: { objects: discusses } %>
|
@ -1,2 +1,3 @@
|
||||
json.(@hack_user, :id, :status, :error_line, :error_msg, :expected_output,
|
||||
:input, :output, :execute_time, :execute_memory)
|
||||
:input, :output, :execute_time, :execute_memory)
|
||||
json.language @hack_user.hack.language
|
@ -0,0 +1 @@
|
||||
json.code @hack.code
|
@ -1,7 +1,12 @@
|
||||
json.(@result, :id, :status, :error_line, :error_msg,
|
||||
:input, :output, :execute_time, :execute_memory)
|
||||
json.status 0
|
||||
json.message "评测成功"
|
||||
json.data do
|
||||
json.(@result, :id, :status, :error_line, :error_msg,
|
||||
:input, :output, :execute_time, :execute_memory)
|
||||
# 提交模式多了一个预计输出
|
||||
if @mode == "submit"
|
||||
json.expected_output @result.expected_output
|
||||
if @mode == "submit"
|
||||
json.expected_output @result.expected_output
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
json.array! @my_hack.hack_user_codes do |hack_user|
|
||||
json.(hack_user, :id, :created_at, :status, :execute_time, :execute_memory)
|
||||
json.language hack_user.hack.language
|
||||
end
|
@ -0,0 +1,4 @@
|
||||
json.status 1
|
||||
json.message "发送成功"
|
||||
json.course_id @course.id
|
||||
json.first_category_url module_url(@course.none_hidden_course_modules.first, @course)
|
@ -0,0 +1,3 @@
|
||||
json.shixun_identifier @shixun.identifier
|
||||
json.shixun_name @shixun.name
|
||||
json.shixun_id @shixun.id
|
@ -1,2 +1,3 @@
|
||||
json.count @count
|
||||
json.tidings @tidings, partial: 'tidings/tiding', as: :tiding
|
||||
json.course_apply_count @course_apply_count
|
||||
|
@ -0,0 +1,4 @@
|
||||
json.status 0
|
||||
json.user do
|
||||
json.partial! 'weapps/shared/user', locals: { user: @user }
|
||||
end
|
@ -1,237 +1,238 @@
|
||||
/*!
|
||||
* Code block dialog plugin for Editor.md
|
||||
*
|
||||
* @file code-block-dialog.js
|
||||
* @author pandao
|
||||
* @version 1.2.0
|
||||
* @updateTime 2015-03-07
|
||||
* {@link https://github.com/pandao/editor.md}
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
var factory = function (exports) {
|
||||
var cmEditor;
|
||||
var pluginName = "code-block-dialog";
|
||||
|
||||
// for CodeBlock dialog select
|
||||
var codeLanguages = exports.codeLanguages = {
|
||||
asp : ["ASP", "vbscript"],
|
||||
actionscript : ["ActionScript(3.0)/Flash/Flex", "clike"],
|
||||
bash : ["Bash/Bat", "shell"],
|
||||
css : ["CSS", "css"],
|
||||
c : ["C", "clike"],
|
||||
cpp : ["C++", "clike"],
|
||||
csharp : ["C#", "clike"],
|
||||
coffeescript : ["CoffeeScript", "coffeescript"],
|
||||
d : ["D", "d"],
|
||||
dart : ["Dart", "dart"],
|
||||
delphi : ["Delphi/Pascal", "pascal"],
|
||||
erlang : ["Erlang", "erlang"],
|
||||
go : ["Golang", "go"],
|
||||
groovy : ["Groovy", "groovy"],
|
||||
html : ["HTML", "text/html"],
|
||||
java : ["Java", "clike"],
|
||||
json : ["JSON", "text/json"],
|
||||
javascript : ["Javascript", "javascript"],
|
||||
lua : ["Lua", "lua"],
|
||||
less : ["LESS", "css"],
|
||||
markdown : ["Markdown", "gfm"],
|
||||
"objective-c" : ["Objective-C", "clike"],
|
||||
php : ["PHP", "php"],
|
||||
perl : ["Perl", "perl"],
|
||||
python : ["Python", "python"],
|
||||
r : ["R", "r"],
|
||||
rst : ["reStructedText", "rst"],
|
||||
ruby : ["Ruby", "ruby"],
|
||||
sql : ["SQL", "sql"],
|
||||
sass : ["SASS/SCSS", "sass"],
|
||||
shell : ["Shell", "shell"],
|
||||
scala : ["Scala", "clike"],
|
||||
swift : ["Swift", "clike"],
|
||||
vb : ["VB/VBScript", "vb"],
|
||||
xml : ["XML", "text/xml"],
|
||||
yaml : ["YAML", "yaml"]
|
||||
};
|
||||
|
||||
exports.fn.codeBlockDialog = function() {
|
||||
|
||||
var _this = this;
|
||||
var cm = this.cm;
|
||||
var lang = this.lang;
|
||||
var editor = this.editor;
|
||||
var settings = this.settings;
|
||||
var cursor = cm.getCursor();
|
||||
var selection = cm.getSelection();
|
||||
var classPrefix = this.classPrefix;
|
||||
var dialogName = classPrefix + pluginName, dialog;
|
||||
var dialogLang = lang.dialog.codeBlock;
|
||||
|
||||
cm.focus();
|
||||
|
||||
if (editor.find("." + dialogName).length > 0)
|
||||
{
|
||||
dialog = editor.find("." + dialogName);
|
||||
dialog.find("option:first").attr("selected", "selected");
|
||||
dialog.find("textarea").val(selection);
|
||||
|
||||
this.dialogShowMask(dialog);
|
||||
this.dialogLockScreen();
|
||||
dialog.show();
|
||||
}
|
||||
else
|
||||
{
|
||||
var dialogHTML = "<div class=\"" + classPrefix + "code-toolbar\">" +
|
||||
dialogLang.selectLabel + "<select><option selected=\"selected\" value=\"\">" + dialogLang.selectDefaultText + "</option></select>" +
|
||||
"</div>" +
|
||||
"<textarea placeholder=\"coding now....\" style=\"display:none;\">" + selection + "</textarea>";
|
||||
|
||||
dialog = this.createDialog({
|
||||
name : dialogName,
|
||||
title : dialogLang.title,
|
||||
width : 780,
|
||||
height : 565,
|
||||
mask : settings.dialogShowMask,
|
||||
drag : settings.dialogDraggable,
|
||||
content : dialogHTML,
|
||||
lockScreen : settings.dialogLockScreen,
|
||||
maskStyle : {
|
||||
opacity : settings.dialogMaskOpacity,
|
||||
backgroundColor : settings.dialogMaskBgColor
|
||||
},
|
||||
buttons : {
|
||||
enter : [lang.buttons.enter, function() {
|
||||
var codeTexts = this.find("textarea").val();
|
||||
var langName = this.find("select").val();
|
||||
|
||||
if (langName === "")
|
||||
{
|
||||
alert(lang.dialog.codeBlock.unselectedLanguageAlert);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (codeTexts === "")
|
||||
{
|
||||
alert(lang.dialog.codeBlock.codeEmptyAlert);
|
||||
return false;
|
||||
}
|
||||
|
||||
langName = (langName === "other") ? "" : langName;
|
||||
|
||||
cm.replaceSelection(["```" + langName, codeTexts, "```"].join("\n"));
|
||||
|
||||
if (langName === "") {
|
||||
cm.setCursor(cursor.line, cursor.ch + 3);
|
||||
}
|
||||
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
|
||||
return false;
|
||||
}],
|
||||
cancel : [lang.buttons.cancel, function() {
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
|
||||
return false;
|
||||
}]
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var langSelect = dialog.find("select");
|
||||
|
||||
if (langSelect.find("option").length === 1)
|
||||
{
|
||||
for (var key in codeLanguages)
|
||||
{
|
||||
var codeLang = codeLanguages[key];
|
||||
langSelect.append("<option value=\"" + key + "\" mode=\"" + codeLang[1] + "\">" + codeLang[0] + "</option>");
|
||||
}
|
||||
|
||||
langSelect.append("<option value=\"other\">" + dialogLang.otherLanguage + "</option>");
|
||||
}
|
||||
|
||||
var mode = langSelect.find("option:selected").attr("mode");
|
||||
|
||||
var cmConfig = {
|
||||
mode : (mode) ? mode : "text/html",
|
||||
theme : settings.theme,
|
||||
tabSize : 4,
|
||||
autofocus : true,
|
||||
autoCloseTags : true,
|
||||
indentUnit : 4,
|
||||
lineNumbers : true,
|
||||
lineWrapping : true,
|
||||
extraKeys : {"Ctrl-Q": function(cm){ cm.foldCode(cm.getCursor()); }},
|
||||
foldGutter : true,
|
||||
gutters : ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
|
||||
matchBrackets : true,
|
||||
indentWithTabs : true,
|
||||
styleActiveLine : true,
|
||||
styleSelectedText : true,
|
||||
autoCloseBrackets : true,
|
||||
showTrailingSpace : true,
|
||||
highlightSelectionMatches : true
|
||||
};
|
||||
|
||||
var textarea = dialog.find("textarea");
|
||||
var cmObj = dialog.find(".CodeMirror");
|
||||
|
||||
if (dialog.find(".CodeMirror").length < 1)
|
||||
{
|
||||
cmEditor = exports.$CodeMirror.fromTextArea(textarea[0], cmConfig);
|
||||
cmObj = dialog.find(".CodeMirror");
|
||||
|
||||
cmObj.css({
|
||||
"float" : "none",
|
||||
margin : "8px 0",
|
||||
border : "1px solid #ddd",
|
||||
fontSize : settings.fontSize,
|
||||
width : "100%",
|
||||
height : "390px"
|
||||
});
|
||||
|
||||
cmEditor.on("change", function(cm) {
|
||||
textarea.val(cm.getValue());
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
cmEditor.setValue(cm.getSelection());
|
||||
}
|
||||
|
||||
langSelect.change(function(){
|
||||
var _mode = $(this).find("option:selected").attr("mode");
|
||||
cmEditor.setOption("mode", _mode);
|
||||
});
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
// CommonJS/Node.js
|
||||
if (typeof require === "function" && typeof exports === "object" && typeof module === "object")
|
||||
{
|
||||
module.exports = factory;
|
||||
}
|
||||
else if (typeof define === "function") // AMD/CMD/Sea.js
|
||||
{
|
||||
if (define.amd) { // for Require.js
|
||||
|
||||
define(["editormd"], function(editormd) {
|
||||
factory(editormd);
|
||||
});
|
||||
|
||||
} else { // for Sea.js
|
||||
define(function(require) {
|
||||
var editormd = require("./../../editormd");
|
||||
factory(editormd);
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
factory(window.editormd);
|
||||
}
|
||||
|
||||
})();
|
||||
/*!
|
||||
* Code block dialog plugin for Editor.md
|
||||
*
|
||||
* @file code-block-dialog.js
|
||||
* @author pandao
|
||||
* @version 1.2.0
|
||||
* @updateTime 2015-03-07
|
||||
* {@link https://github.com/pandao/editor.md}
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
var factory = function (exports) {
|
||||
var cmEditor;
|
||||
var pluginName = "code-block-dialog";
|
||||
|
||||
// for CodeBlock dialog select
|
||||
var codeLanguages = exports.codeLanguages = {
|
||||
asp : ["ASP", "vbscript"],
|
||||
actionscript : ["ActionScript(3.0)/Flash/Flex", "clike"],
|
||||
bash : ["Bash/Bat", "shell"],
|
||||
css : ["CSS", "css"],
|
||||
c : ["C", "clike"],
|
||||
cpp : ["C++", "clike"],
|
||||
csharp : ["C#", "clike"],
|
||||
coffeescript : ["CoffeeScript", "coffeescript"],
|
||||
d : ["D", "d"],
|
||||
dart : ["Dart", "dart"],
|
||||
delphi : ["Delphi/Pascal", "pascal"],
|
||||
erlang : ["Erlang", "erlang"],
|
||||
go : ["Golang", "go"],
|
||||
groovy : ["Groovy", "groovy"],
|
||||
html : ["HTML", "text/html"],
|
||||
java : ["Java", "clike"],
|
||||
json : ["JSON", "text/json"],
|
||||
javascript : ["Javascript", "javascript"],
|
||||
lua : ["Lua", "lua"],
|
||||
less : ["LESS", "css"],
|
||||
markdown : ["Markdown", "gfm"],
|
||||
"objective-c" : ["Objective-C", "clike"],
|
||||
php : ["PHP", "php"],
|
||||
perl : ["Perl", "perl"],
|
||||
python : ["Python", "python"],
|
||||
r : ["R", "r"],
|
||||
rst : ["reStructedText", "rst"],
|
||||
ruby : ["Ruby", "ruby"],
|
||||
sql : ["SQL", "sql"],
|
||||
sass : ["SASS/SCSS", "sass"],
|
||||
shell : ["Shell", "shell"],
|
||||
scala : ["Scala", "clike"],
|
||||
swift : ["Swift", "clike"],
|
||||
vb : ["VB/VBScript", "vb"],
|
||||
xml : ["XML", "text/xml"],
|
||||
yaml : ["YAML", "yaml"]
|
||||
};
|
||||
|
||||
exports.fn.codeBlockDialog = function() {
|
||||
|
||||
var _this = this;
|
||||
var cm = this.cm;
|
||||
var lang = this.lang;
|
||||
var editor = this.editor;
|
||||
var settings = this.settings;
|
||||
var cursor = cm.getCursor();
|
||||
var selection = cm.getSelection();
|
||||
var classPrefix = this.classPrefix;
|
||||
var dialogName = classPrefix + pluginName, dialog;
|
||||
var dialogLang = lang.dialog.codeBlock;
|
||||
|
||||
cm.focus();
|
||||
|
||||
if (editor.find("." + dialogName).length > 0)
|
||||
{
|
||||
dialog = editor.find("." + dialogName);
|
||||
dialog.find("option:first").attr("selected", "selected");
|
||||
dialog.find("textarea").val(selection);
|
||||
|
||||
this.dialogShowMask(dialog);
|
||||
this.dialogLockScreen();
|
||||
dialog.show();
|
||||
}
|
||||
else
|
||||
{
|
||||
var dialogHTML = "<div class=\"" + classPrefix + "code-toolbar\">" +
|
||||
dialogLang.selectLabel + "<select><option selected=\"selected\" value=\"\">" + dialogLang.selectDefaultText + "</option></select>" +
|
||||
"</div>" +
|
||||
"<textarea placeholder=\"coding now....\" style=\"display:none;\">" + selection + "</textarea>";
|
||||
|
||||
dialog = this.createDialog({
|
||||
name : dialogName,
|
||||
title : dialogLang.title,
|
||||
width : 780,
|
||||
height : 565,
|
||||
mask : settings.dialogShowMask,
|
||||
drag : settings.dialogDraggable,
|
||||
content : dialogHTML,
|
||||
lockScreen : settings.dialogLockScreen,
|
||||
maskStyle : {
|
||||
opacity : settings.dialogMaskOpacity,
|
||||
backgroundColor : settings.dialogMaskBgColor
|
||||
},
|
||||
buttons : {
|
||||
enter : [lang.buttons.enter, function() {
|
||||
var codeTexts = this.find("textarea").val();
|
||||
var langName = this.find("select").val();
|
||||
|
||||
if (langName === "")
|
||||
{
|
||||
alert(lang.dialog.codeBlock.unselectedLanguageAlert);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (codeTexts === "")
|
||||
{
|
||||
alert(lang.dialog.codeBlock.codeEmptyAlert);
|
||||
return false;
|
||||
}
|
||||
|
||||
langName = (langName === "other") ? "" : langName;
|
||||
|
||||
cm.replaceSelection(["```" + langName, codeTexts, "```"].join("\n"));
|
||||
|
||||
if (langName === "") {
|
||||
cm.setCursor(cursor.line, cursor.ch + 3);
|
||||
}
|
||||
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
|
||||
cm.focus && cm.focus();
|
||||
return false;
|
||||
}],
|
||||
cancel : [lang.buttons.cancel, function() {
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
cm.focus && cm.focus();
|
||||
return false;
|
||||
}]
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var langSelect = dialog.find("select");
|
||||
|
||||
if (langSelect.find("option").length === 1)
|
||||
{
|
||||
for (var key in codeLanguages)
|
||||
{
|
||||
var codeLang = codeLanguages[key];
|
||||
langSelect.append("<option value=\"" + key + "\" mode=\"" + codeLang[1] + "\">" + codeLang[0] + "</option>");
|
||||
}
|
||||
|
||||
langSelect.append("<option value=\"other\">" + dialogLang.otherLanguage + "</option>");
|
||||
}
|
||||
|
||||
var mode = langSelect.find("option:selected").attr("mode");
|
||||
|
||||
var cmConfig = {
|
||||
mode : (mode) ? mode : "text/html",
|
||||
theme : settings.theme,
|
||||
tabSize : 4,
|
||||
autofocus : true,
|
||||
autoCloseTags : true,
|
||||
indentUnit : 4,
|
||||
lineNumbers : true,
|
||||
lineWrapping : true,
|
||||
extraKeys : {"Ctrl-Q": function(cm){ cm.foldCode(cm.getCursor()); }},
|
||||
foldGutter : true,
|
||||
gutters : ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
|
||||
matchBrackets : true,
|
||||
indentWithTabs : true,
|
||||
styleActiveLine : true,
|
||||
styleSelectedText : true,
|
||||
autoCloseBrackets : true,
|
||||
showTrailingSpace : true,
|
||||
highlightSelectionMatches : true
|
||||
};
|
||||
|
||||
var textarea = dialog.find("textarea");
|
||||
var cmObj = dialog.find(".CodeMirror");
|
||||
|
||||
if (dialog.find(".CodeMirror").length < 1)
|
||||
{
|
||||
cmEditor = exports.$CodeMirror.fromTextArea(textarea[0], cmConfig);
|
||||
cmObj = dialog.find(".CodeMirror");
|
||||
|
||||
cmObj.css({
|
||||
"float" : "none",
|
||||
margin : "8px 0",
|
||||
border : "1px solid #ddd",
|
||||
fontSize : settings.fontSize,
|
||||
width : "100%",
|
||||
height : "390px"
|
||||
});
|
||||
|
||||
cmEditor.on("change", function(cm) {
|
||||
textarea.val(cm.getValue());
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
cmEditor.setValue(cm.getSelection());
|
||||
}
|
||||
|
||||
langSelect.change(function(){
|
||||
var _mode = $(this).find("option:selected").attr("mode");
|
||||
cmEditor.setOption("mode", _mode);
|
||||
});
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
// CommonJS/Node.js
|
||||
if (typeof require === "function" && typeof exports === "object" && typeof module === "object")
|
||||
{
|
||||
module.exports = factory;
|
||||
}
|
||||
else if (typeof define === "function") // AMD/CMD/Sea.js
|
||||
{
|
||||
if (define.amd) { // for Require.js
|
||||
|
||||
define(["editormd"], function(editormd) {
|
||||
factory(editormd);
|
||||
});
|
||||
|
||||
} else { // for Sea.js
|
||||
define(function(require) {
|
||||
var editormd = require("./../../editormd");
|
||||
factory(editormd);
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
factory(window.editormd);
|
||||
}
|
||||
|
||||
})();
|
||||
|
@ -1,327 +1,329 @@
|
||||
/*!
|
||||
* Emoji dialog plugin for Editor.md
|
||||
*
|
||||
* @file emoji-dialog.js
|
||||
* @author pandao
|
||||
* @version 1.2.0
|
||||
* @updateTime 2015-03-08
|
||||
* {@link https://github.com/pandao/editor.md}
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
var factory = function (exports) {
|
||||
|
||||
var $ = jQuery;
|
||||
var pluginName = "emoji-dialog";
|
||||
var emojiTabIndex = 0;
|
||||
var emojiData = [];
|
||||
var selecteds = [];
|
||||
|
||||
var logoPrefix = "editormd-logo";
|
||||
var logos = [
|
||||
logoPrefix,
|
||||
logoPrefix + "-1x",
|
||||
logoPrefix + "-2x",
|
||||
logoPrefix + "-3x",
|
||||
logoPrefix + "-4x",
|
||||
logoPrefix + "-5x",
|
||||
logoPrefix + "-6x",
|
||||
logoPrefix + "-7x",
|
||||
logoPrefix + "-8x"
|
||||
];
|
||||
|
||||
var langs = {
|
||||
"zh-cn" : {
|
||||
toolbar : {
|
||||
emoji : "Emoji 表情"
|
||||
},
|
||||
dialog : {
|
||||
emoji : {
|
||||
title : "Emoji 表情"
|
||||
}
|
||||
}
|
||||
},
|
||||
"zh-tw" : {
|
||||
toolbar : {
|
||||
emoji : "Emoji 表情"
|
||||
},
|
||||
dialog : {
|
||||
emoji : {
|
||||
title : "Emoji 表情"
|
||||
}
|
||||
}
|
||||
},
|
||||
"en" : {
|
||||
toolbar : {
|
||||
emoji : "Emoji"
|
||||
},
|
||||
dialog : {
|
||||
emoji : {
|
||||
title : "Emoji"
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.fn.emojiDialog = function() {
|
||||
var _this = this;
|
||||
var cm = this.cm;
|
||||
var settings = _this.settings;
|
||||
|
||||
if (!settings.emoji)
|
||||
{
|
||||
alert("settings.emoji == false");
|
||||
return ;
|
||||
}
|
||||
|
||||
var path = settings.pluginPath + pluginName + "/";
|
||||
var editor = this.editor;
|
||||
var cursor = cm.getCursor();
|
||||
var selection = cm.getSelection();
|
||||
var classPrefix = this.classPrefix;
|
||||
|
||||
$.extend(true, this.lang, langs[this.lang.name]);
|
||||
this.setToolbar();
|
||||
|
||||
var lang = this.lang;
|
||||
var dialogName = classPrefix + pluginName, dialog;
|
||||
var dialogLang = lang.dialog.emoji;
|
||||
|
||||
var dialogContent = [
|
||||
"<div class=\"" + classPrefix + "emoji-dialog-box\" style=\"width: 760px;height: 334px;margin-bottom: 8px;overflow: hidden;\">",
|
||||
"<div class=\"" + classPrefix + "tab\"></div>",
|
||||
"</div>",
|
||||
].join("\n");
|
||||
|
||||
cm.focus();
|
||||
|
||||
if (editor.find("." + dialogName).length > 0)
|
||||
{
|
||||
dialog = editor.find("." + dialogName);
|
||||
|
||||
selecteds = [];
|
||||
dialog.find("a").removeClass("selected");
|
||||
|
||||
this.dialogShowMask(dialog);
|
||||
this.dialogLockScreen();
|
||||
dialog.show();
|
||||
}
|
||||
else
|
||||
{
|
||||
dialog = this.createDialog({
|
||||
name : dialogName,
|
||||
title : dialogLang.title,
|
||||
width : 800,
|
||||
height : 475,
|
||||
mask : settings.dialogShowMask,
|
||||
drag : settings.dialogDraggable,
|
||||
content : dialogContent,
|
||||
lockScreen : settings.dialogLockScreen,
|
||||
maskStyle : {
|
||||
opacity : settings.dialogMaskOpacity,
|
||||
backgroundColor : settings.dialogMaskBgColor
|
||||
},
|
||||
buttons : {
|
||||
enter : [lang.buttons.enter, function() {
|
||||
cm.replaceSelection(selecteds.join(" "));
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
|
||||
return false;
|
||||
}],
|
||||
cancel : [lang.buttons.cancel, function() {
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
|
||||
return false;
|
||||
}]
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var category = ["Github emoji", "Twemoji", "Font awesome", "Editor.md logo"];
|
||||
var tab = dialog.find("." + classPrefix + "tab");
|
||||
|
||||
if (tab.html() === "")
|
||||
{
|
||||
var head = "<ul class=\"" + classPrefix + "tab-head\">";
|
||||
|
||||
for (var i = 0; i<4; i++) {
|
||||
var active = (i === 0) ? " class=\"active\"" : "";
|
||||
head += "<li" + active + "><a href=\"javascript:;\">" + category[i] + "</a></li>";
|
||||
}
|
||||
|
||||
head += "</ul>";
|
||||
|
||||
tab.append(head);
|
||||
|
||||
var container = "<div class=\"" + classPrefix + "tab-container\">";
|
||||
|
||||
for (var x = 0; x < 4; x++)
|
||||
{
|
||||
var display = (x === 0) ? "" : "display:none;";
|
||||
container += "<div class=\"" + classPrefix + "tab-box\" style=\"height: 260px;overflow: hidden;overflow-y: auto;" + display + "\"></div>";
|
||||
}
|
||||
|
||||
container += "</div>";
|
||||
|
||||
tab.append(container);
|
||||
}
|
||||
|
||||
var tabBoxs = tab.find("." + classPrefix + "tab-box");
|
||||
var emojiCategories = ["github-emoji", "twemoji", "font-awesome", logoPrefix];
|
||||
|
||||
var drawTable = function() {
|
||||
var cname = emojiCategories[emojiTabIndex];
|
||||
var $data = emojiData[cname];
|
||||
var $tab = tabBoxs.eq(emojiTabIndex);
|
||||
|
||||
if ($tab.html() !== "") {
|
||||
//console.log("break =>", cname);
|
||||
return ;
|
||||
}
|
||||
|
||||
var pagination = function(data, type) {
|
||||
var rowNumber = (type === "editormd-logo") ? "5" : 20;
|
||||
var pageTotal = Math.ceil(data.length / rowNumber);
|
||||
var table = "<div class=\"" + classPrefix + "grid-table\">";
|
||||
|
||||
for (var i = 0; i < pageTotal; i++)
|
||||
{
|
||||
var row = "<div class=\"" + classPrefix + "grid-table-row\">";
|
||||
|
||||
for (var x = 0; x < rowNumber; x++)
|
||||
{
|
||||
var emoji = $.trim(data[(i * rowNumber) + x]);
|
||||
|
||||
if (typeof emoji !== "undefined" && emoji !== "")
|
||||
{
|
||||
var img = "", icon = "";
|
||||
|
||||
if (type === "github-emoji")
|
||||
{
|
||||
var src = (emoji === "+1") ? "plus1" : emoji;
|
||||
src = (src === "black_large_square") ? "black_square" : src;
|
||||
src = (src === "moon") ? "waxing_gibbous_moon" : src;
|
||||
|
||||
src = exports.emoji.path + src + exports.emoji.ext;
|
||||
img = "<img src=\"" + src + "\" width=\"24\" class=\"emoji\" title=\":" + emoji + ":\" alt=\":" + emoji + ":\" />";
|
||||
row += "<a href=\"javascript:;\" value=\":" + emoji + ":\" title=\":" + emoji + ":\" class=\"" + classPrefix + "emoji-btn\">" + img + "</a>";
|
||||
}
|
||||
else if (type === "twemoji")
|
||||
{
|
||||
var twemojiSrc = exports.twemoji.path + emoji + exports.twemoji.ext;
|
||||
img = "<img src=\"" + twemojiSrc + "\" width=\"24\" title=\"twemoji-" + emoji + "\" alt=\"twemoji-" + emoji + "\" class=\"emoji twemoji\" />";
|
||||
row += "<a href=\"javascript:;\" value=\":tw-" + emoji + ":\" title=\":tw-" + emoji + ":\" class=\"" + classPrefix + "emoji-btn\">" + img + "</a>";
|
||||
}
|
||||
else if (type === "font-awesome")
|
||||
{
|
||||
icon = "<i class=\"fa fa-" + emoji + " fa-emoji\" title=\"" + emoji + "\"></i>";
|
||||
row += "<a href=\"javascript:;\" value=\":fa-" + emoji + ":\" title=\":fa-" + emoji + ":\" class=\"" + classPrefix + "emoji-btn\">" + icon + "</a>";
|
||||
}
|
||||
else if (type === "editormd-logo")
|
||||
{
|
||||
icon = "<i class=\"" + emoji + "\" title=\"Editor.md logo (" + emoji + ")\"></i>";
|
||||
row += "<a href=\"javascript:;\" value=\":" + emoji + ":\" title=\":" + emoji + ":\" style=\"width:20%;\" class=\"" + classPrefix + "emoji-btn\">" + icon + "</a>";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
row += "<a href=\"javascript:;\" value=\"\"></a>";
|
||||
}
|
||||
}
|
||||
|
||||
row += "</div>";
|
||||
|
||||
table += row;
|
||||
}
|
||||
|
||||
table += "</div>";
|
||||
|
||||
return table;
|
||||
};
|
||||
|
||||
if (emojiTabIndex === 0)
|
||||
{
|
||||
for (var i = 0, len = $data.length; i < len; i++)
|
||||
{
|
||||
var h4Style = (i === 0) ? " style=\"margin: 0 0 10px;\"" : " style=\"margin: 10px 0;\"";
|
||||
$tab.append("<h4" + h4Style + ">" + $data[i].category + "</h4>");
|
||||
$tab.append(pagination($data[i].list, cname));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$tab.append(pagination($data, cname));
|
||||
}
|
||||
|
||||
$tab.find("." + classPrefix + "emoji-btn").bind(exports.mouseOrTouch("click", "touchend"), function() {
|
||||
$(this).toggleClass("selected");
|
||||
|
||||
if ($(this).hasClass("selected"))
|
||||
{
|
||||
selecteds.push($(this).attr("value"));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (emojiData.length < 1)
|
||||
{
|
||||
if (typeof dialog.loading === "function") {
|
||||
dialog.loading(true);
|
||||
}
|
||||
|
||||
$.getJSON(path + "emoji.json?temp=" + Math.random(), function(json) {
|
||||
|
||||
if (typeof dialog.loading === "function") {
|
||||
dialog.loading(false);
|
||||
}
|
||||
|
||||
emojiData = json;
|
||||
emojiData[logoPrefix] = logos;
|
||||
drawTable();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
drawTable();
|
||||
}
|
||||
|
||||
tab.find("li").bind(exports.mouseOrTouch("click", "touchend"), function() {
|
||||
var $this = $(this);
|
||||
emojiTabIndex = $this.index();
|
||||
|
||||
$this.addClass("active").siblings().removeClass("active");
|
||||
tabBoxs.eq(emojiTabIndex).show().siblings().hide();
|
||||
drawTable();
|
||||
});
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
// CommonJS/Node.js
|
||||
if (typeof require === "function" && typeof exports === "object" && typeof module === "object")
|
||||
{
|
||||
module.exports = factory;
|
||||
}
|
||||
else if (typeof define === "function") // AMD/CMD/Sea.js
|
||||
{
|
||||
if (define.amd) { // for Require.js
|
||||
|
||||
define(["editormd"], function(editormd) {
|
||||
factory(editormd);
|
||||
});
|
||||
|
||||
} else { // for Sea.js
|
||||
define(function(require) {
|
||||
var editormd = require("./../../editormd");
|
||||
factory(editormd);
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
factory(window.editormd);
|
||||
}
|
||||
|
||||
})();
|
||||
/*!
|
||||
* Emoji dialog plugin for Editor.md
|
||||
*
|
||||
* @file emoji-dialog.js
|
||||
* @author pandao
|
||||
* @version 1.2.0
|
||||
* @updateTime 2015-03-08
|
||||
* {@link https://github.com/pandao/editor.md}
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
var factory = function (exports) {
|
||||
|
||||
var $ = jQuery;
|
||||
var pluginName = "emoji-dialog";
|
||||
var emojiTabIndex = 0;
|
||||
var emojiData = [];
|
||||
var selecteds = [];
|
||||
|
||||
var logoPrefix = "editormd-logo";
|
||||
var logos = [
|
||||
logoPrefix,
|
||||
logoPrefix + "-1x",
|
||||
logoPrefix + "-2x",
|
||||
logoPrefix + "-3x",
|
||||
logoPrefix + "-4x",
|
||||
logoPrefix + "-5x",
|
||||
logoPrefix + "-6x",
|
||||
logoPrefix + "-7x",
|
||||
logoPrefix + "-8x"
|
||||
];
|
||||
|
||||
var langs = {
|
||||
"zh-cn" : {
|
||||
toolbar : {
|
||||
emoji : "Emoji 表情"
|
||||
},
|
||||
dialog : {
|
||||
emoji : {
|
||||
title : "Emoji 表情"
|
||||
}
|
||||
}
|
||||
},
|
||||
"zh-tw" : {
|
||||
toolbar : {
|
||||
emoji : "Emoji 表情"
|
||||
},
|
||||
dialog : {
|
||||
emoji : {
|
||||
title : "Emoji 表情"
|
||||
}
|
||||
}
|
||||
},
|
||||
"en" : {
|
||||
toolbar : {
|
||||
emoji : "Emoji"
|
||||
},
|
||||
dialog : {
|
||||
emoji : {
|
||||
title : "Emoji"
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.fn.emojiDialog = function() {
|
||||
var _this = this;
|
||||
var cm = this.cm;
|
||||
var settings = _this.settings;
|
||||
|
||||
if (!settings.emoji)
|
||||
{
|
||||
alert("settings.emoji == false");
|
||||
return ;
|
||||
}
|
||||
|
||||
var path = settings.pluginPath + pluginName + "/";
|
||||
var editor = this.editor;
|
||||
var cursor = cm.getCursor();
|
||||
var selection = cm.getSelection();
|
||||
var classPrefix = this.classPrefix;
|
||||
|
||||
$.extend(true, this.lang, langs[this.lang.name]);
|
||||
this.setToolbar();
|
||||
|
||||
var lang = this.lang;
|
||||
var dialogName = classPrefix + pluginName, dialog;
|
||||
var dialogLang = lang.dialog.emoji;
|
||||
|
||||
var dialogContent = [
|
||||
"<div class=\"" + classPrefix + "emoji-dialog-box\" style=\"width: 760px;height: 334px;margin-bottom: 8px;overflow: hidden;\">",
|
||||
"<div class=\"" + classPrefix + "tab\"></div>",
|
||||
"</div>",
|
||||
].join("\n");
|
||||
|
||||
cm.focus();
|
||||
|
||||
if (editor.find("." + dialogName).length > 0)
|
||||
{
|
||||
dialog = editor.find("." + dialogName);
|
||||
|
||||
selecteds = [];
|
||||
dialog.find("a").removeClass("selected");
|
||||
|
||||
this.dialogShowMask(dialog);
|
||||
this.dialogLockScreen();
|
||||
dialog.show();
|
||||
}
|
||||
else
|
||||
{
|
||||
dialog = this.createDialog({
|
||||
name : dialogName,
|
||||
title : dialogLang.title,
|
||||
width : 800,
|
||||
height : 475,
|
||||
mask : settings.dialogShowMask,
|
||||
drag : settings.dialogDraggable,
|
||||
content : dialogContent,
|
||||
lockScreen : settings.dialogLockScreen,
|
||||
maskStyle : {
|
||||
opacity : settings.dialogMaskOpacity,
|
||||
backgroundColor : settings.dialogMaskBgColor
|
||||
},
|
||||
buttons : {
|
||||
enter : [lang.buttons.enter, function() {
|
||||
cm.replaceSelection(selecteds.join(" "));
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
cm.focus && cm.focus();
|
||||
|
||||
return false;
|
||||
}],
|
||||
cancel : [lang.buttons.cancel, function() {
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
cm.focus && cm.focus();
|
||||
|
||||
return false;
|
||||
}]
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var category = ["Github emoji", "Twemoji", "Font awesome", "Editor.md logo"];
|
||||
var tab = dialog.find("." + classPrefix + "tab");
|
||||
|
||||
if (tab.html() === "")
|
||||
{
|
||||
var head = "<ul class=\"" + classPrefix + "tab-head\">";
|
||||
|
||||
for (var i = 0; i<4; i++) {
|
||||
var active = (i === 0) ? " class=\"active\"" : "";
|
||||
head += "<li" + active + "><a href=\"javascript:;\">" + category[i] + "</a></li>";
|
||||
}
|
||||
|
||||
head += "</ul>";
|
||||
|
||||
tab.append(head);
|
||||
|
||||
var container = "<div class=\"" + classPrefix + "tab-container\">";
|
||||
|
||||
for (var x = 0; x < 4; x++)
|
||||
{
|
||||
var display = (x === 0) ? "" : "display:none;";
|
||||
container += "<div class=\"" + classPrefix + "tab-box\" style=\"height: 260px;overflow: hidden;overflow-y: auto;" + display + "\"></div>";
|
||||
}
|
||||
|
||||
container += "</div>";
|
||||
|
||||
tab.append(container);
|
||||
}
|
||||
|
||||
var tabBoxs = tab.find("." + classPrefix + "tab-box");
|
||||
var emojiCategories = ["github-emoji", "twemoji", "font-awesome", logoPrefix];
|
||||
|
||||
var drawTable = function() {
|
||||
var cname = emojiCategories[emojiTabIndex];
|
||||
var $data = emojiData[cname];
|
||||
var $tab = tabBoxs.eq(emojiTabIndex);
|
||||
|
||||
if ($tab.html() !== "") {
|
||||
//console.log("break =>", cname);
|
||||
return ;
|
||||
}
|
||||
|
||||
var pagination = function(data, type) {
|
||||
var rowNumber = (type === "editormd-logo") ? "5" : 20;
|
||||
var pageTotal = Math.ceil(data.length / rowNumber);
|
||||
var table = "<div class=\"" + classPrefix + "grid-table\">";
|
||||
|
||||
for (var i = 0; i < pageTotal; i++)
|
||||
{
|
||||
var row = "<div class=\"" + classPrefix + "grid-table-row\">";
|
||||
|
||||
for (var x = 0; x < rowNumber; x++)
|
||||
{
|
||||
var emoji = $.trim(data[(i * rowNumber) + x]);
|
||||
|
||||
if (typeof emoji !== "undefined" && emoji !== "")
|
||||
{
|
||||
var img = "", icon = "";
|
||||
|
||||
if (type === "github-emoji")
|
||||
{
|
||||
var src = (emoji === "+1") ? "plus1" : emoji;
|
||||
src = (src === "black_large_square") ? "black_square" : src;
|
||||
src = (src === "moon") ? "waxing_gibbous_moon" : src;
|
||||
|
||||
src = exports.emoji.path + src + exports.emoji.ext;
|
||||
img = "<img src=\"" + src + "\" width=\"24\" class=\"emoji\" title=\":" + emoji + ":\" alt=\":" + emoji + ":\" />";
|
||||
row += "<a href=\"javascript:;\" value=\":" + emoji + ":\" title=\":" + emoji + ":\" class=\"" + classPrefix + "emoji-btn\">" + img + "</a>";
|
||||
}
|
||||
else if (type === "twemoji")
|
||||
{
|
||||
var twemojiSrc = exports.twemoji.path + emoji + exports.twemoji.ext;
|
||||
img = "<img src=\"" + twemojiSrc + "\" width=\"24\" title=\"twemoji-" + emoji + "\" alt=\"twemoji-" + emoji + "\" class=\"emoji twemoji\" />";
|
||||
row += "<a href=\"javascript:;\" value=\":tw-" + emoji + ":\" title=\":tw-" + emoji + ":\" class=\"" + classPrefix + "emoji-btn\">" + img + "</a>";
|
||||
}
|
||||
else if (type === "font-awesome")
|
||||
{
|
||||
icon = "<i class=\"fa fa-" + emoji + " fa-emoji\" title=\"" + emoji + "\"></i>";
|
||||
row += "<a href=\"javascript:;\" value=\":fa-" + emoji + ":\" title=\":fa-" + emoji + ":\" class=\"" + classPrefix + "emoji-btn\">" + icon + "</a>";
|
||||
}
|
||||
else if (type === "editormd-logo")
|
||||
{
|
||||
icon = "<i class=\"" + emoji + "\" title=\"Editor.md logo (" + emoji + ")\"></i>";
|
||||
row += "<a href=\"javascript:;\" value=\":" + emoji + ":\" title=\":" + emoji + ":\" style=\"width:20%;\" class=\"" + classPrefix + "emoji-btn\">" + icon + "</a>";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
row += "<a href=\"javascript:;\" value=\"\"></a>";
|
||||
}
|
||||
}
|
||||
|
||||
row += "</div>";
|
||||
|
||||
table += row;
|
||||
}
|
||||
|
||||
table += "</div>";
|
||||
|
||||
return table;
|
||||
};
|
||||
|
||||
if (emojiTabIndex === 0)
|
||||
{
|
||||
for (var i = 0, len = $data.length; i < len; i++)
|
||||
{
|
||||
var h4Style = (i === 0) ? " style=\"margin: 0 0 10px;\"" : " style=\"margin: 10px 0;\"";
|
||||
$tab.append("<h4" + h4Style + ">" + $data[i].category + "</h4>");
|
||||
$tab.append(pagination($data[i].list, cname));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$tab.append(pagination($data, cname));
|
||||
}
|
||||
|
||||
$tab.find("." + classPrefix + "emoji-btn").bind(exports.mouseOrTouch("click", "touchend"), function() {
|
||||
$(this).toggleClass("selected");
|
||||
|
||||
if ($(this).hasClass("selected"))
|
||||
{
|
||||
selecteds.push($(this).attr("value"));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (emojiData.length < 1)
|
||||
{
|
||||
if (typeof dialog.loading === "function") {
|
||||
dialog.loading(true);
|
||||
}
|
||||
|
||||
$.getJSON(path + "emoji.json?temp=" + Math.random(), function(json) {
|
||||
|
||||
if (typeof dialog.loading === "function") {
|
||||
dialog.loading(false);
|
||||
}
|
||||
|
||||
emojiData = json;
|
||||
emojiData[logoPrefix] = logos;
|
||||
drawTable();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
drawTable();
|
||||
}
|
||||
|
||||
tab.find("li").bind(exports.mouseOrTouch("click", "touchend"), function() {
|
||||
var $this = $(this);
|
||||
emojiTabIndex = $this.index();
|
||||
|
||||
$this.addClass("active").siblings().removeClass("active");
|
||||
tabBoxs.eq(emojiTabIndex).show().siblings().hide();
|
||||
drawTable();
|
||||
});
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
// CommonJS/Node.js
|
||||
if (typeof require === "function" && typeof exports === "object" && typeof module === "object")
|
||||
{
|
||||
module.exports = factory;
|
||||
}
|
||||
else if (typeof define === "function") // AMD/CMD/Sea.js
|
||||
{
|
||||
if (define.amd) { // for Require.js
|
||||
|
||||
define(["editormd"], function(editormd) {
|
||||
factory(editormd);
|
||||
});
|
||||
|
||||
} else { // for Sea.js
|
||||
define(function(require) {
|
||||
var editormd = require("./../../editormd");
|
||||
factory(editormd);
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
factory(window.editormd);
|
||||
}
|
||||
|
||||
})();
|
||||
|
@ -1,157 +1,159 @@
|
||||
/*!
|
||||
* Goto line dialog plugin for Editor.md
|
||||
*
|
||||
* @file goto-line-dialog.js
|
||||
* @author pandao
|
||||
* @version 1.2.1
|
||||
* @updateTime 2015-06-09
|
||||
* {@link https://github.com/pandao/editor.md}
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
var factory = function (exports) {
|
||||
|
||||
var $ = jQuery;
|
||||
var pluginName = "goto-line-dialog";
|
||||
|
||||
var langs = {
|
||||
"zh-cn" : {
|
||||
toolbar : {
|
||||
"goto-line" : "跳转到行"
|
||||
},
|
||||
dialog : {
|
||||
"goto-line" : {
|
||||
title : "跳转到行",
|
||||
label : "请输入行号",
|
||||
error : "错误:"
|
||||
}
|
||||
}
|
||||
},
|
||||
"zh-tw" : {
|
||||
toolbar : {
|
||||
"goto-line" : "跳轉到行"
|
||||
},
|
||||
dialog : {
|
||||
"goto-line" : {
|
||||
title : "跳轉到行",
|
||||
label : "請輸入行號",
|
||||
error : "錯誤:"
|
||||
}
|
||||
}
|
||||
},
|
||||
"en" : {
|
||||
toolbar : {
|
||||
"goto-line" : "Goto line"
|
||||
},
|
||||
dialog : {
|
||||
"goto-line" : {
|
||||
title : "Goto line",
|
||||
label : "Enter a line number, range ",
|
||||
error : "Error: "
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.fn.gotoLineDialog = function() {
|
||||
var _this = this;
|
||||
var cm = this.cm;
|
||||
var editor = this.editor;
|
||||
var settings = this.settings;
|
||||
var path = settings.pluginPath + pluginName +"/";
|
||||
var classPrefix = this.classPrefix;
|
||||
var dialogName = classPrefix + pluginName, dialog;
|
||||
|
||||
$.extend(true, this.lang, langs[this.lang.name]);
|
||||
this.setToolbar();
|
||||
|
||||
var lang = this.lang;
|
||||
var dialogLang = lang.dialog["goto-line"];
|
||||
var lineCount = cm.lineCount();
|
||||
|
||||
dialogLang.error += dialogLang.label + " 1-" + lineCount;
|
||||
|
||||
if (editor.find("." + dialogName).length < 1)
|
||||
{
|
||||
var dialogContent = [
|
||||
"<div class=\"editormd-form\" style=\"padding: 10px 0;\">",
|
||||
"<p style=\"margin: 0;\">" + dialogLang.label + " 1-" + lineCount +" <input type=\"number\" class=\"number-input\" style=\"width: 60px;\" value=\"1\" max=\"" + lineCount + "\" min=\"1\" data-line-number /></p>",
|
||||
"</div>"
|
||||
].join("\n");
|
||||
|
||||
dialog = this.createDialog({
|
||||
name : dialogName,
|
||||
title : dialogLang.title,
|
||||
width : 400,
|
||||
height : 180,
|
||||
mask : settings.dialogShowMask,
|
||||
drag : settings.dialogDraggable,
|
||||
content : dialogContent,
|
||||
lockScreen : settings.dialogLockScreen,
|
||||
maskStyle : {
|
||||
opacity : settings.dialogMaskOpacity,
|
||||
backgroundColor : settings.dialogMaskBgColor
|
||||
},
|
||||
buttons : {
|
||||
enter : [lang.buttons.enter, function() {
|
||||
var line = parseInt(this.find("[data-line-number]").val());
|
||||
|
||||
if (line < 1 || line > lineCount) {
|
||||
alert(dialogLang.error);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
_this.gotoLine(line);
|
||||
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
|
||||
return false;
|
||||
}],
|
||||
|
||||
cancel : [lang.buttons.cancel, function() {
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
|
||||
return false;
|
||||
}]
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dialog = editor.find("." + dialogName);
|
||||
|
||||
this.dialogShowMask(dialog);
|
||||
this.dialogLockScreen();
|
||||
dialog.show();
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
// CommonJS/Node.js
|
||||
if (typeof require === "function" && typeof exports === "object" && typeof module === "object")
|
||||
{
|
||||
module.exports = factory;
|
||||
}
|
||||
else if (typeof define === "function") // AMD/CMD/Sea.js
|
||||
{
|
||||
if (define.amd) { // for Require.js
|
||||
|
||||
define(["editormd"], function(editormd) {
|
||||
factory(editormd);
|
||||
});
|
||||
|
||||
} else { // for Sea.js
|
||||
define(function(require) {
|
||||
var editormd = require("./../../editormd");
|
||||
factory(editormd);
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
factory(window.editormd);
|
||||
}
|
||||
|
||||
})();
|
||||
/*!
|
||||
* Goto line dialog plugin for Editor.md
|
||||
*
|
||||
* @file goto-line-dialog.js
|
||||
* @author pandao
|
||||
* @version 1.2.1
|
||||
* @updateTime 2015-06-09
|
||||
* {@link https://github.com/pandao/editor.md}
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
var factory = function (exports) {
|
||||
|
||||
var $ = jQuery;
|
||||
var pluginName = "goto-line-dialog";
|
||||
|
||||
var langs = {
|
||||
"zh-cn" : {
|
||||
toolbar : {
|
||||
"goto-line" : "跳转到行"
|
||||
},
|
||||
dialog : {
|
||||
"goto-line" : {
|
||||
title : "跳转到行",
|
||||
label : "请输入行号",
|
||||
error : "错误:"
|
||||
}
|
||||
}
|
||||
},
|
||||
"zh-tw" : {
|
||||
toolbar : {
|
||||
"goto-line" : "跳轉到行"
|
||||
},
|
||||
dialog : {
|
||||
"goto-line" : {
|
||||
title : "跳轉到行",
|
||||
label : "請輸入行號",
|
||||
error : "錯誤:"
|
||||
}
|
||||
}
|
||||
},
|
||||
"en" : {
|
||||
toolbar : {
|
||||
"goto-line" : "Goto line"
|
||||
},
|
||||
dialog : {
|
||||
"goto-line" : {
|
||||
title : "Goto line",
|
||||
label : "Enter a line number, range ",
|
||||
error : "Error: "
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.fn.gotoLineDialog = function() {
|
||||
var _this = this;
|
||||
var cm = this.cm;
|
||||
var editor = this.editor;
|
||||
var settings = this.settings;
|
||||
var path = settings.pluginPath + pluginName +"/";
|
||||
var classPrefix = this.classPrefix;
|
||||
var dialogName = classPrefix + pluginName, dialog;
|
||||
|
||||
$.extend(true, this.lang, langs[this.lang.name]);
|
||||
this.setToolbar();
|
||||
|
||||
var lang = this.lang;
|
||||
var dialogLang = lang.dialog["goto-line"];
|
||||
var lineCount = cm.lineCount();
|
||||
|
||||
dialogLang.error += dialogLang.label + " 1-" + lineCount;
|
||||
|
||||
if (editor.find("." + dialogName).length < 1)
|
||||
{
|
||||
var dialogContent = [
|
||||
"<div class=\"editormd-form\" style=\"padding: 10px 0;\">",
|
||||
"<p style=\"margin: 0;\">" + dialogLang.label + " 1-" + lineCount +" <input type=\"number\" class=\"number-input\" style=\"width: 60px;\" value=\"1\" max=\"" + lineCount + "\" min=\"1\" data-line-number /></p>",
|
||||
"</div>"
|
||||
].join("\n");
|
||||
|
||||
dialog = this.createDialog({
|
||||
name : dialogName,
|
||||
title : dialogLang.title,
|
||||
width : 400,
|
||||
height : 180,
|
||||
mask : settings.dialogShowMask,
|
||||
drag : settings.dialogDraggable,
|
||||
content : dialogContent,
|
||||
lockScreen : settings.dialogLockScreen,
|
||||
maskStyle : {
|
||||
opacity : settings.dialogMaskOpacity,
|
||||
backgroundColor : settings.dialogMaskBgColor
|
||||
},
|
||||
buttons : {
|
||||
enter : [lang.buttons.enter, function() {
|
||||
var line = parseInt(this.find("[data-line-number]").val());
|
||||
|
||||
if (line < 1 || line > lineCount) {
|
||||
alert(dialogLang.error);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
_this.gotoLine(line);
|
||||
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
cm.focus && cm.focus();
|
||||
|
||||
return false;
|
||||
}],
|
||||
|
||||
cancel : [lang.buttons.cancel, function() {
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
cm.focus && cm.focus();
|
||||
|
||||
return false;
|
||||
}]
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dialog = editor.find("." + dialogName);
|
||||
|
||||
this.dialogShowMask(dialog);
|
||||
this.dialogLockScreen();
|
||||
dialog.show();
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
// CommonJS/Node.js
|
||||
if (typeof require === "function" && typeof exports === "object" && typeof module === "object")
|
||||
{
|
||||
module.exports = factory;
|
||||
}
|
||||
else if (typeof define === "function") // AMD/CMD/Sea.js
|
||||
{
|
||||
if (define.amd) { // for Require.js
|
||||
|
||||
define(["editormd"], function(editormd) {
|
||||
factory(editormd);
|
||||
});
|
||||
|
||||
} else { // for Sea.js
|
||||
define(function(require) {
|
||||
var editormd = require("./../../editormd");
|
||||
factory(editormd);
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
factory(window.editormd);
|
||||
}
|
||||
|
||||
})();
|
||||
|
@ -1,102 +1,104 @@
|
||||
/*!
|
||||
* Help dialog plugin for Editor.md
|
||||
*
|
||||
* @file help-dialog.js
|
||||
* @author pandao
|
||||
* @version 1.2.0
|
||||
* @updateTime 2015-03-08
|
||||
* {@link https://github.com/pandao/editor.md}
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
var factory = function (exports) {
|
||||
|
||||
var $ = jQuery;
|
||||
var pluginName = "help-dialog";
|
||||
|
||||
exports.fn.helpDialog = function() {
|
||||
var _this = this;
|
||||
var lang = this.lang;
|
||||
var editor = this.editor;
|
||||
var settings = this.settings;
|
||||
var path = settings.pluginPath + pluginName + "/";
|
||||
var classPrefix = this.classPrefix;
|
||||
var dialogName = classPrefix + pluginName, dialog;
|
||||
var dialogLang = lang.dialog.help;
|
||||
|
||||
if (editor.find("." + dialogName).length < 1)
|
||||
{
|
||||
var dialogContent = "<div class=\"markdown-body\" style=\"font-family:微软雅黑, Helvetica, Tahoma, STXihei,Arial;height:390px;overflow:auto;font-size:14px;border-bottom:1px solid #ddd;padding:0 20px 20px 0;\"></div>";
|
||||
|
||||
dialog = this.createDialog({
|
||||
name : dialogName,
|
||||
title : dialogLang.title,
|
||||
width : 840,
|
||||
height : 540,
|
||||
mask : settings.dialogShowMask,
|
||||
drag : settings.dialogDraggable,
|
||||
content : dialogContent,
|
||||
lockScreen : settings.dialogLockScreen,
|
||||
maskStyle : {
|
||||
opacity : settings.dialogMaskOpacity,
|
||||
backgroundColor : settings.dialogMaskBgColor
|
||||
},
|
||||
buttons : {
|
||||
close : [lang.buttons.close, function() {
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
|
||||
return false;
|
||||
}]
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dialog = editor.find("." + dialogName);
|
||||
|
||||
this.dialogShowMask(dialog);
|
||||
this.dialogLockScreen();
|
||||
dialog.show();
|
||||
|
||||
var helpContent = dialog.find(".markdown-body");
|
||||
|
||||
if (helpContent.html() === "")
|
||||
{
|
||||
$.get(path + "help.md", function(text) {
|
||||
var md = exports.$marked(text);
|
||||
helpContent.html(md);
|
||||
|
||||
helpContent.find("a").attr("target", "_blank");
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
// CommonJS/Node.js
|
||||
if (typeof require === "function" && typeof exports === "object" && typeof module === "object")
|
||||
{
|
||||
module.exports = factory;
|
||||
}
|
||||
else if (typeof define === "function") // AMD/CMD/Sea.js
|
||||
{
|
||||
if (define.amd) { // for Require.js
|
||||
|
||||
define(["editormd"], function(editormd) {
|
||||
factory(editormd);
|
||||
});
|
||||
|
||||
} else { // for Sea.js
|
||||
define(function(require) {
|
||||
var editormd = require("./../../editormd");
|
||||
factory(editormd);
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
factory(window.editormd);
|
||||
}
|
||||
|
||||
})();
|
||||
/*!
|
||||
* Help dialog plugin for Editor.md
|
||||
*
|
||||
* @file help-dialog.js
|
||||
* @author pandao
|
||||
* @version 1.2.0
|
||||
* @updateTime 2015-03-08
|
||||
* {@link https://github.com/pandao/editor.md}
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
var factory = function (exports) {
|
||||
|
||||
var $ = jQuery;
|
||||
var pluginName = "help-dialog";
|
||||
|
||||
exports.fn.helpDialog = function() {
|
||||
var _this = this;
|
||||
var lang = this.lang;
|
||||
var cm = this.cm;
|
||||
var editor = this.editor;
|
||||
var settings = this.settings;
|
||||
var path = settings.pluginPath + pluginName + "/";
|
||||
var classPrefix = this.classPrefix;
|
||||
var dialogName = classPrefix + pluginName, dialog;
|
||||
var dialogLang = lang.dialog.help;
|
||||
|
||||
if (editor.find("." + dialogName).length < 1)
|
||||
{
|
||||
var dialogContent = "<div class=\"markdown-body\" style=\"font-family:微软雅黑, Helvetica, Tahoma, STXihei,Arial;height:390px;overflow:auto;font-size:14px;border-bottom:1px solid #ddd;padding:0 20px 20px 0;\"></div>";
|
||||
|
||||
dialog = this.createDialog({
|
||||
name : dialogName,
|
||||
title : dialogLang.title,
|
||||
width : 840,
|
||||
height : 540,
|
||||
mask : settings.dialogShowMask,
|
||||
drag : settings.dialogDraggable,
|
||||
content : dialogContent,
|
||||
lockScreen : settings.dialogLockScreen,
|
||||
maskStyle : {
|
||||
opacity : settings.dialogMaskOpacity,
|
||||
backgroundColor : settings.dialogMaskBgColor
|
||||
},
|
||||
buttons : {
|
||||
close : [lang.buttons.close, function() {
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
cm.focus && cm.focus();
|
||||
|
||||
return false;
|
||||
}]
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dialog = editor.find("." + dialogName);
|
||||
|
||||
this.dialogShowMask(dialog);
|
||||
this.dialogLockScreen();
|
||||
dialog.show();
|
||||
|
||||
var helpContent = dialog.find(".markdown-body");
|
||||
|
||||
if (helpContent.html() === "")
|
||||
{
|
||||
$.get(path + "help.md", function(text) {
|
||||
var md = exports.$marked(text);
|
||||
helpContent.html(md);
|
||||
|
||||
helpContent.find("a").attr("target", "_blank");
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
// CommonJS/Node.js
|
||||
if (typeof require === "function" && typeof exports === "object" && typeof module === "object")
|
||||
{
|
||||
module.exports = factory;
|
||||
}
|
||||
else if (typeof define === "function") // AMD/CMD/Sea.js
|
||||
{
|
||||
if (define.amd) { // for Require.js
|
||||
|
||||
define(["editormd"], function(editormd) {
|
||||
factory(editormd);
|
||||
});
|
||||
|
||||
} else { // for Sea.js
|
||||
define(function(require) {
|
||||
var editormd = require("./../../editormd");
|
||||
factory(editormd);
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
factory(window.editormd);
|
||||
}
|
||||
|
||||
})();
|
||||
|
@ -1,173 +1,173 @@
|
||||
/*!
|
||||
* HTML entities dialog plugin for Editor.md
|
||||
*
|
||||
* @file html-entities-dialog.js
|
||||
* @author pandao
|
||||
* @version 1.2.0
|
||||
* @updateTime 2015-03-08
|
||||
* {@link https://github.com/pandao/editor.md}
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
var factory = function (exports) {
|
||||
|
||||
var $ = jQuery;
|
||||
var pluginName = "html-entities-dialog";
|
||||
var selecteds = [];
|
||||
var entitiesData = [];
|
||||
|
||||
exports.fn.htmlEntitiesDialog = function() {
|
||||
var _this = this;
|
||||
var cm = this.cm;
|
||||
var lang = _this.lang;
|
||||
var settings = _this.settings;
|
||||
var path = settings.pluginPath + pluginName + "/";
|
||||
var editor = this.editor;
|
||||
var cursor = cm.getCursor();
|
||||
var selection = cm.getSelection();
|
||||
var classPrefix = _this.classPrefix;
|
||||
|
||||
var dialogName = classPrefix + "dialog-" + pluginName, dialog;
|
||||
var dialogLang = lang.dialog.htmlEntities;
|
||||
|
||||
var dialogContent = [
|
||||
'<div class="' + classPrefix + 'html-entities-box" style=\"width: 760px;height: 334px;margin-bottom: 8px;overflow: hidden;overflow-y: auto;\">',
|
||||
'<div class="' + classPrefix + 'grid-table">',
|
||||
'</div>',
|
||||
'</div>',
|
||||
].join("\r\n");
|
||||
|
||||
cm.focus();
|
||||
|
||||
if (editor.find("." + dialogName).length > 0)
|
||||
{
|
||||
dialog = editor.find("." + dialogName);
|
||||
|
||||
selecteds = [];
|
||||
dialog.find("a").removeClass("selected");
|
||||
|
||||
this.dialogShowMask(dialog);
|
||||
this.dialogLockScreen();
|
||||
dialog.show();
|
||||
}
|
||||
else
|
||||
{
|
||||
dialog = this.createDialog({
|
||||
name : dialogName,
|
||||
title : dialogLang.title,
|
||||
width : 800,
|
||||
height : 475,
|
||||
mask : settings.dialogShowMask,
|
||||
drag : settings.dialogDraggable,
|
||||
content : dialogContent,
|
||||
lockScreen : settings.dialogLockScreen,
|
||||
maskStyle : {
|
||||
opacity : settings.dialogMaskOpacity,
|
||||
backgroundColor : settings.dialogMaskBgColor
|
||||
},
|
||||
buttons : {
|
||||
enter : [lang.buttons.enter, function() {
|
||||
cm.replaceSelection(selecteds.join(" "));
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
|
||||
return false;
|
||||
}],
|
||||
cancel : [lang.buttons.cancel, function() {
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
|
||||
return false;
|
||||
}]
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var table = dialog.find("." + classPrefix + "grid-table");
|
||||
|
||||
var drawTable = function() {
|
||||
|
||||
if (entitiesData.length < 1) return ;
|
||||
|
||||
var rowNumber = 20;
|
||||
var pageTotal = Math.ceil(entitiesData.length / rowNumber);
|
||||
|
||||
table.html("");
|
||||
|
||||
for (var i = 0; i < pageTotal; i++)
|
||||
{
|
||||
var row = "<div class=\"" + classPrefix + "grid-table-row\">";
|
||||
|
||||
for (var x = 0; x < rowNumber; x++)
|
||||
{
|
||||
var entity = entitiesData[(i * rowNumber) + x];
|
||||
|
||||
if (typeof entity !== "undefined")
|
||||
{
|
||||
var name = entity.name.replace("&", "&");
|
||||
|
||||
row += "<a href=\"javascript:;\" value=\"" + entity.name + "\" title=\"" + name + "\" class=\"" + classPrefix + "html-entity-btn\">" + name + "</a>";
|
||||
}
|
||||
}
|
||||
|
||||
row += "</div>";
|
||||
|
||||
table.append(row);
|
||||
}
|
||||
|
||||
dialog.find("." + classPrefix + "html-entity-btn").bind(exports.mouseOrTouch("click", "touchend"), function() {
|
||||
$(this).toggleClass("selected");
|
||||
|
||||
if ($(this).hasClass("selected"))
|
||||
{
|
||||
selecteds.push($(this).attr("value"));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (entitiesData.length < 1)
|
||||
{
|
||||
if (typeof (dialog.loading) == "function") dialog.loading(true);
|
||||
|
||||
$.getJSON(path + pluginName.replace("-dialog", "") + ".json", function(json) {
|
||||
|
||||
if (typeof (dialog.loading) == "function") dialog.loading(false);
|
||||
|
||||
entitiesData = json;
|
||||
drawTable();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
drawTable();
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
// CommonJS/Node.js
|
||||
if (typeof require === "function" && typeof exports === "object" && typeof module === "object")
|
||||
{
|
||||
module.exports = factory;
|
||||
}
|
||||
else if (typeof define === "function") // AMD/CMD/Sea.js
|
||||
{
|
||||
if (define.amd) { // for Require.js
|
||||
|
||||
define(["editormd"], function(editormd) {
|
||||
factory(editormd);
|
||||
});
|
||||
|
||||
} else { // for Sea.js
|
||||
define(function(require) {
|
||||
var editormd = require("./../../editormd");
|
||||
factory(editormd);
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
factory(window.editormd);
|
||||
}
|
||||
|
||||
})();
|
||||
/*!
|
||||
* HTML entities dialog plugin for Editor.md
|
||||
*
|
||||
* @file html-entities-dialog.js
|
||||
* @author pandao
|
||||
* @version 1.2.0
|
||||
* @updateTime 2015-03-08
|
||||
* {@link https://github.com/pandao/editor.md}
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
var factory = function (exports) {
|
||||
|
||||
var $ = jQuery;
|
||||
var pluginName = "html-entities-dialog";
|
||||
var selecteds = [];
|
||||
var entitiesData = [];
|
||||
|
||||
exports.fn.htmlEntitiesDialog = function() {
|
||||
var _this = this;
|
||||
var cm = this.cm;
|
||||
var lang = _this.lang;
|
||||
var settings = _this.settings;
|
||||
var path = settings.pluginPath + pluginName + "/";
|
||||
var editor = this.editor;
|
||||
var cursor = cm.getCursor();
|
||||
var selection = cm.getSelection();
|
||||
var classPrefix = _this.classPrefix;
|
||||
|
||||
var dialogName = classPrefix + "dialog-" + pluginName, dialog;
|
||||
var dialogLang = lang.dialog.htmlEntities;
|
||||
|
||||
var dialogContent = [
|
||||
'<div class="' + classPrefix + 'html-entities-box" style=\"width: 760px;height: 334px;margin-bottom: 8px;overflow: hidden;overflow-y: auto;\">',
|
||||
'<div class="' + classPrefix + 'grid-table">',
|
||||
'</div>',
|
||||
'</div>',
|
||||
].join("\r\n");
|
||||
|
||||
cm.focus();
|
||||
|
||||
if (editor.find("." + dialogName).length > 0)
|
||||
{
|
||||
dialog = editor.find("." + dialogName);
|
||||
|
||||
selecteds = [];
|
||||
dialog.find("a").removeClass("selected");
|
||||
|
||||
this.dialogShowMask(dialog);
|
||||
this.dialogLockScreen();
|
||||
dialog.show();
|
||||
}
|
||||
else
|
||||
{
|
||||
dialog = this.createDialog({
|
||||
name : dialogName,
|
||||
title : dialogLang.title,
|
||||
width : 800,
|
||||
height : 475,
|
||||
mask : settings.dialogShowMask,
|
||||
drag : settings.dialogDraggable,
|
||||
content : dialogContent,
|
||||
lockScreen : settings.dialogLockScreen,
|
||||
maskStyle : {
|
||||
opacity : settings.dialogMaskOpacity,
|
||||
backgroundColor : settings.dialogMaskBgColor
|
||||
},
|
||||
buttons : {
|
||||
enter : [lang.buttons.enter, function() {
|
||||
cm.replaceSelection(selecteds.join(" "));
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
cm.focus && cm.focus();
|
||||
return false;
|
||||
}],
|
||||
cancel : [lang.buttons.cancel, function() {
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
cm.focus && cm.focus();
|
||||
return false;
|
||||
}]
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var table = dialog.find("." + classPrefix + "grid-table");
|
||||
|
||||
var drawTable = function() {
|
||||
|
||||
if (entitiesData.length < 1) return ;
|
||||
|
||||
var rowNumber = 20;
|
||||
var pageTotal = Math.ceil(entitiesData.length / rowNumber);
|
||||
|
||||
table.html("");
|
||||
|
||||
for (var i = 0; i < pageTotal; i++)
|
||||
{
|
||||
var row = "<div class=\"" + classPrefix + "grid-table-row\">";
|
||||
|
||||
for (var x = 0; x < rowNumber; x++)
|
||||
{
|
||||
var entity = entitiesData[(i * rowNumber) + x];
|
||||
|
||||
if (typeof entity !== "undefined")
|
||||
{
|
||||
var name = entity.name.replace("&", "&");
|
||||
|
||||
row += "<a href=\"javascript:;\" value=\"" + entity.name + "\" title=\"" + name + "\" class=\"" + classPrefix + "html-entity-btn\">" + name + "</a>";
|
||||
}
|
||||
}
|
||||
|
||||
row += "</div>";
|
||||
|
||||
table.append(row);
|
||||
}
|
||||
|
||||
dialog.find("." + classPrefix + "html-entity-btn").bind(exports.mouseOrTouch("click", "touchend"), function() {
|
||||
$(this).toggleClass("selected");
|
||||
|
||||
if ($(this).hasClass("selected"))
|
||||
{
|
||||
selecteds.push($(this).attr("value"));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (entitiesData.length < 1)
|
||||
{
|
||||
if (typeof (dialog.loading) == "function") dialog.loading(true);
|
||||
|
||||
$.getJSON(path + pluginName.replace("-dialog", "") + ".json", function(json) {
|
||||
|
||||
if (typeof (dialog.loading) == "function") dialog.loading(false);
|
||||
|
||||
entitiesData = json;
|
||||
drawTable();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
drawTable();
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
// CommonJS/Node.js
|
||||
if (typeof require === "function" && typeof exports === "object" && typeof module === "object")
|
||||
{
|
||||
module.exports = factory;
|
||||
}
|
||||
else if (typeof define === "function") // AMD/CMD/Sea.js
|
||||
{
|
||||
if (define.amd) { // for Require.js
|
||||
|
||||
define(["editormd"], function(editormd) {
|
||||
factory(editormd);
|
||||
});
|
||||
|
||||
} else { // for Sea.js
|
||||
define(function(require) {
|
||||
var editormd = require("./../../editormd");
|
||||
factory(editormd);
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
factory(window.editormd);
|
||||
}
|
||||
|
||||
})();
|
||||
|
@ -1,133 +1,134 @@
|
||||
/*!
|
||||
* Link dialog plugin for Editor.md
|
||||
*
|
||||
* @file link-dialog.js
|
||||
* @author pandao
|
||||
* @version 1.2.1
|
||||
* @updateTime 2015-06-09
|
||||
* {@link https://github.com/pandao/editor.md}
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
var factory = function (exports) {
|
||||
|
||||
var pluginName = "link-dialog";
|
||||
|
||||
exports.fn.linkDialog = function() {
|
||||
|
||||
var _this = this;
|
||||
var cm = this.cm;
|
||||
var editor = this.editor;
|
||||
var settings = this.settings;
|
||||
var selection = cm.getSelection();
|
||||
var lang = this.lang;
|
||||
var linkLang = lang.dialog.link;
|
||||
var classPrefix = this.classPrefix;
|
||||
var dialogName = classPrefix + pluginName, dialog;
|
||||
|
||||
cm.focus();
|
||||
|
||||
if (editor.find("." + dialogName).length > 0)
|
||||
{
|
||||
dialog = editor.find("." + dialogName);
|
||||
dialog.find("[data-url]").val("http://");
|
||||
dialog.find("[data-title]").val(selection);
|
||||
|
||||
this.dialogShowMask(dialog);
|
||||
this.dialogLockScreen();
|
||||
dialog.show();
|
||||
}
|
||||
else
|
||||
{
|
||||
var dialogHTML = "<div class=\"" + classPrefix + "form\">" +
|
||||
"<label>" + linkLang.url + "</label>" +
|
||||
"<input type=\"text\" value=\"http://\" data-url />" +
|
||||
"<br/>" +
|
||||
"<label>" + linkLang.urlTitle + "</label>" +
|
||||
"<input type=\"text\" value=\"" + selection + "\" data-title />" +
|
||||
"<br/>" +
|
||||
"</div>";
|
||||
|
||||
dialog = this.createDialog({
|
||||
title : linkLang.title,
|
||||
width : 380,
|
||||
height : 211,
|
||||
content : dialogHTML,
|
||||
mask : settings.dialogShowMask,
|
||||
drag : settings.dialogDraggable,
|
||||
lockScreen : settings.dialogLockScreen,
|
||||
maskStyle : {
|
||||
opacity : settings.dialogMaskOpacity,
|
||||
backgroundColor : settings.dialogMaskBgColor
|
||||
},
|
||||
buttons : {
|
||||
enter : [lang.buttons.enter, function() {
|
||||
var url = this.find("[data-url]").val();
|
||||
var title = this.find("[data-title]").val();
|
||||
|
||||
if (url === "http://" || url === "")
|
||||
{
|
||||
alert(linkLang.urlEmpty);
|
||||
return false;
|
||||
}
|
||||
|
||||
/*if (title === "")
|
||||
{
|
||||
alert(linkLang.titleEmpty);
|
||||
return false;
|
||||
}*/
|
||||
|
||||
var str = "[" + title + "](" + url + " \"" + title + "\")";
|
||||
|
||||
if (title == "")
|
||||
{
|
||||
str = "[" + url + "](" + url + ")";
|
||||
}
|
||||
|
||||
cm.replaceSelection(str);
|
||||
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
|
||||
return false;
|
||||
}],
|
||||
|
||||
cancel : [lang.buttons.cancel, function() {
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
|
||||
return false;
|
||||
}]
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
// CommonJS/Node.js
|
||||
if (typeof require === "function" && typeof exports === "object" && typeof module === "object")
|
||||
{
|
||||
module.exports = factory;
|
||||
}
|
||||
else if (typeof define === "function") // AMD/CMD/Sea.js
|
||||
{
|
||||
if (define.amd) { // for Require.js
|
||||
|
||||
define(["editormd"], function(editormd) {
|
||||
factory(editormd);
|
||||
});
|
||||
|
||||
} else { // for Sea.js
|
||||
define(function(require) {
|
||||
var editormd = require("./../../editormd");
|
||||
factory(editormd);
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
factory(window.editormd);
|
||||
}
|
||||
|
||||
})();
|
||||
/*!
|
||||
* Link dialog plugin for Editor.md
|
||||
*
|
||||
* @file link-dialog.js
|
||||
* @author pandao
|
||||
* @version 1.2.1
|
||||
* @updateTime 2015-06-09
|
||||
* {@link https://github.com/pandao/editor.md}
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
var factory = function (exports) {
|
||||
|
||||
var pluginName = "link-dialog";
|
||||
|
||||
exports.fn.linkDialog = function() {
|
||||
|
||||
var _this = this;
|
||||
var cm = this.cm;
|
||||
var editor = this.editor;
|
||||
var settings = this.settings;
|
||||
var selection = cm.getSelection();
|
||||
var lang = this.lang;
|
||||
var linkLang = lang.dialog.link;
|
||||
var classPrefix = this.classPrefix;
|
||||
var dialogName = classPrefix + pluginName, dialog;
|
||||
|
||||
cm.focus();
|
||||
|
||||
if (editor.find("." + dialogName).length > 0)
|
||||
{
|
||||
dialog = editor.find("." + dialogName);
|
||||
dialog.find("[data-url]").val("http://");
|
||||
dialog.find("[data-title]").val(selection);
|
||||
|
||||
this.dialogShowMask(dialog);
|
||||
this.dialogLockScreen();
|
||||
dialog.show();
|
||||
}
|
||||
else
|
||||
{
|
||||
var dialogHTML = "<div class=\"" + classPrefix + "form\">" +
|
||||
"<label>" + linkLang.url + "</label>" +
|
||||
"<input type=\"text\" value=\"http://\" data-url />" +
|
||||
"<br/>" +
|
||||
"<label>" + linkLang.urlTitle + "</label>" +
|
||||
"<input type=\"text\" value=\"" + selection + "\" data-title />" +
|
||||
"<br/>" +
|
||||
"</div>";
|
||||
|
||||
dialog = this.createDialog({
|
||||
title : linkLang.title,
|
||||
width : 380,
|
||||
height : 211,
|
||||
content : dialogHTML,
|
||||
mask : settings.dialogShowMask,
|
||||
drag : settings.dialogDraggable,
|
||||
lockScreen : settings.dialogLockScreen,
|
||||
maskStyle : {
|
||||
opacity : settings.dialogMaskOpacity,
|
||||
backgroundColor : settings.dialogMaskBgColor
|
||||
},
|
||||
buttons : {
|
||||
enter : [lang.buttons.enter, function() {
|
||||
var url = this.find("[data-url]").val();
|
||||
var title = this.find("[data-title]").val();
|
||||
|
||||
if (url === "http://" || url === "")
|
||||
{
|
||||
alert(linkLang.urlEmpty);
|
||||
return false;
|
||||
}
|
||||
|
||||
/*if (title === "")
|
||||
{
|
||||
alert(linkLang.titleEmpty);
|
||||
return false;
|
||||
}*/
|
||||
|
||||
var str = "[" + title + "](" + url + " \"" + title + "\")";
|
||||
|
||||
if (title == "")
|
||||
{
|
||||
str = "[" + url + "](" + url + ")";
|
||||
}
|
||||
|
||||
cm.replaceSelection(str);
|
||||
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
cm.focus && cm.focus();
|
||||
|
||||
return false;
|
||||
}],
|
||||
|
||||
cancel : [lang.buttons.cancel, function() {
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
cm.focus && cm.focus();
|
||||
return false;
|
||||
}]
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
// CommonJS/Node.js
|
||||
if (typeof require === "function" && typeof exports === "object" && typeof module === "object")
|
||||
{
|
||||
module.exports = factory;
|
||||
}
|
||||
else if (typeof define === "function") // AMD/CMD/Sea.js
|
||||
{
|
||||
if (define.amd) { // for Require.js
|
||||
|
||||
define(["editormd"], function(editormd) {
|
||||
factory(editormd);
|
||||
});
|
||||
|
||||
} else { // for Sea.js
|
||||
define(function(require) {
|
||||
var editormd = require("./../../editormd");
|
||||
factory(editormd);
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
factory(window.editormd);
|
||||
}
|
||||
|
||||
})();
|
||||
|
@ -1,172 +1,174 @@
|
||||
/*!
|
||||
* Preformatted text dialog plugin for Editor.md
|
||||
*
|
||||
* @file preformatted-text-dialog.js
|
||||
* @author pandao
|
||||
* @version 1.2.0
|
||||
* @updateTime 2015-03-07
|
||||
* {@link https://github.com/pandao/editor.md}
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
var factory = function (exports) {
|
||||
var cmEditor;
|
||||
var pluginName = "preformatted-text-dialog";
|
||||
|
||||
exports.fn.preformattedTextDialog = function() {
|
||||
|
||||
var _this = this;
|
||||
var cm = this.cm;
|
||||
var lang = this.lang;
|
||||
var editor = this.editor;
|
||||
var settings = this.settings;
|
||||
var cursor = cm.getCursor();
|
||||
var selection = cm.getSelection();
|
||||
var classPrefix = this.classPrefix;
|
||||
var dialogLang = lang.dialog.preformattedText;
|
||||
var dialogName = classPrefix + pluginName, dialog;
|
||||
|
||||
cm.focus();
|
||||
|
||||
if (editor.find("." + dialogName).length > 0)
|
||||
{
|
||||
dialog = editor.find("." + dialogName);
|
||||
dialog.find("textarea").val(selection);
|
||||
|
||||
this.dialogShowMask(dialog);
|
||||
this.dialogLockScreen();
|
||||
dialog.show();
|
||||
}
|
||||
else
|
||||
{
|
||||
var dialogContent = "<textarea placeholder=\"coding now....\" style=\"display:none;\">" + selection + "</textarea>";
|
||||
|
||||
dialog = this.createDialog({
|
||||
name : dialogName,
|
||||
title : dialogLang.title,
|
||||
width : 780,
|
||||
height : 540,
|
||||
mask : settings.dialogShowMask,
|
||||
drag : settings.dialogDraggable,
|
||||
content : dialogContent,
|
||||
lockScreen : settings.dialogLockScreen,
|
||||
maskStyle : {
|
||||
opacity : settings.dialogMaskOpacity,
|
||||
backgroundColor : settings.dialogMaskBgColor
|
||||
},
|
||||
buttons : {
|
||||
enter : [lang.buttons.enter, function() {
|
||||
var codeTexts = this.find("textarea").val();
|
||||
|
||||
if (codeTexts === "")
|
||||
{
|
||||
alert(dialogLang.emptyAlert);
|
||||
return false;
|
||||
}
|
||||
|
||||
codeTexts = codeTexts.split("\n");
|
||||
|
||||
for (var i in codeTexts)
|
||||
{
|
||||
codeTexts[i] = " " + codeTexts[i];
|
||||
}
|
||||
|
||||
codeTexts = codeTexts.join("\n");
|
||||
|
||||
if (cursor.ch !== 0) {
|
||||
codeTexts = "\r\n\r\n" + codeTexts;
|
||||
}
|
||||
|
||||
cm.replaceSelection(codeTexts);
|
||||
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
|
||||
return false;
|
||||
}],
|
||||
cancel : [lang.buttons.cancel, function() {
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
|
||||
return false;
|
||||
}]
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var cmConfig = {
|
||||
mode : "text/html",
|
||||
theme : settings.theme,
|
||||
tabSize : 4,
|
||||
autofocus : true,
|
||||
autoCloseTags : true,
|
||||
indentUnit : 4,
|
||||
lineNumbers : true,
|
||||
lineWrapping : true,
|
||||
extraKeys : {"Ctrl-Q": function(cm){ cm.foldCode(cm.getCursor()); }},
|
||||
foldGutter : true,
|
||||
gutters : ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
|
||||
matchBrackets : true,
|
||||
indentWithTabs : true,
|
||||
styleActiveLine : true,
|
||||
styleSelectedText : true,
|
||||
autoCloseBrackets : true,
|
||||
showTrailingSpace : true,
|
||||
highlightSelectionMatches : true
|
||||
};
|
||||
|
||||
var textarea = dialog.find("textarea");
|
||||
var cmObj = dialog.find(".CodeMirror");
|
||||
|
||||
if (dialog.find(".CodeMirror").length < 1)
|
||||
{
|
||||
cmEditor = exports.$CodeMirror.fromTextArea(textarea[0], cmConfig);
|
||||
cmObj = dialog.find(".CodeMirror");
|
||||
|
||||
cmObj.css({
|
||||
"float" : "none",
|
||||
margin : "0 0 5px",
|
||||
border : "1px solid #ddd",
|
||||
fontSize : settings.fontSize,
|
||||
width : "100%",
|
||||
height : "410px"
|
||||
});
|
||||
|
||||
cmEditor.on("change", function(cm) {
|
||||
textarea.val(cm.getValue());
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
cmEditor.setValue(cm.getSelection());
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
// CommonJS/Node.js
|
||||
if (typeof require === "function" && typeof exports === "object" && typeof module === "object")
|
||||
{
|
||||
module.exports = factory;
|
||||
}
|
||||
else if (typeof define === "function") // AMD/CMD/Sea.js
|
||||
{
|
||||
if (define.amd) { // for Require.js
|
||||
|
||||
define(["editormd"], function(editormd) {
|
||||
factory(editormd);
|
||||
});
|
||||
|
||||
} else { // for Sea.js
|
||||
define(function(require) {
|
||||
var editormd = require("./../../editormd");
|
||||
factory(editormd);
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
factory(window.editormd);
|
||||
}
|
||||
|
||||
})();
|
||||
/*!
|
||||
* Preformatted text dialog plugin for Editor.md
|
||||
*
|
||||
* @file preformatted-text-dialog.js
|
||||
* @author pandao
|
||||
* @version 1.2.0
|
||||
* @updateTime 2015-03-07
|
||||
* {@link https://github.com/pandao/editor.md}
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
var factory = function (exports) {
|
||||
var cmEditor;
|
||||
var pluginName = "preformatted-text-dialog";
|
||||
|
||||
exports.fn.preformattedTextDialog = function() {
|
||||
|
||||
var _this = this;
|
||||
var cm = this.cm;
|
||||
var lang = this.lang;
|
||||
var editor = this.editor;
|
||||
var settings = this.settings;
|
||||
var cursor = cm.getCursor();
|
||||
var selection = cm.getSelection();
|
||||
var classPrefix = this.classPrefix;
|
||||
var dialogLang = lang.dialog.preformattedText;
|
||||
var dialogName = classPrefix + pluginName, dialog;
|
||||
|
||||
cm.focus();
|
||||
|
||||
if (editor.find("." + dialogName).length > 0)
|
||||
{
|
||||
dialog = editor.find("." + dialogName);
|
||||
dialog.find("textarea").val(selection);
|
||||
|
||||
this.dialogShowMask(dialog);
|
||||
this.dialogLockScreen();
|
||||
dialog.show();
|
||||
}
|
||||
else
|
||||
{
|
||||
var dialogContent = "<textarea placeholder=\"coding now....\" style=\"display:none;\">" + selection + "</textarea>";
|
||||
|
||||
dialog = this.createDialog({
|
||||
name : dialogName,
|
||||
title : dialogLang.title,
|
||||
width : 780,
|
||||
height : 540,
|
||||
mask : settings.dialogShowMask,
|
||||
drag : settings.dialogDraggable,
|
||||
content : dialogContent,
|
||||
lockScreen : settings.dialogLockScreen,
|
||||
maskStyle : {
|
||||
opacity : settings.dialogMaskOpacity,
|
||||
backgroundColor : settings.dialogMaskBgColor
|
||||
},
|
||||
buttons : {
|
||||
enter : [lang.buttons.enter, function() {
|
||||
var codeTexts = this.find("textarea").val();
|
||||
|
||||
if (codeTexts === "")
|
||||
{
|
||||
alert(dialogLang.emptyAlert);
|
||||
return false;
|
||||
}
|
||||
|
||||
codeTexts = codeTexts.split("\n");
|
||||
|
||||
for (var i in codeTexts)
|
||||
{
|
||||
codeTexts[i] = " " + codeTexts[i];
|
||||
}
|
||||
|
||||
codeTexts = codeTexts.join("\n");
|
||||
|
||||
if (cursor.ch !== 0) {
|
||||
codeTexts = "\r\n\r\n" + codeTexts;
|
||||
}
|
||||
|
||||
cm.replaceSelection(codeTexts);
|
||||
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
cm.focus && cm.focus();
|
||||
|
||||
return false;
|
||||
}],
|
||||
cancel : [lang.buttons.cancel, function() {
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
cm.focus && cm.focus();
|
||||
|
||||
return false;
|
||||
}]
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var cmConfig = {
|
||||
mode : "text/html",
|
||||
theme : settings.theme,
|
||||
tabSize : 4,
|
||||
autofocus : true,
|
||||
autoCloseTags : true,
|
||||
indentUnit : 4,
|
||||
lineNumbers : true,
|
||||
lineWrapping : true,
|
||||
extraKeys : {"Ctrl-Q": function(cm){ cm.foldCode(cm.getCursor()); }},
|
||||
foldGutter : true,
|
||||
gutters : ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
|
||||
matchBrackets : true,
|
||||
indentWithTabs : true,
|
||||
styleActiveLine : true,
|
||||
styleSelectedText : true,
|
||||
autoCloseBrackets : true,
|
||||
showTrailingSpace : true,
|
||||
highlightSelectionMatches : true
|
||||
};
|
||||
|
||||
var textarea = dialog.find("textarea");
|
||||
var cmObj = dialog.find(".CodeMirror");
|
||||
|
||||
if (dialog.find(".CodeMirror").length < 1)
|
||||
{
|
||||
cmEditor = exports.$CodeMirror.fromTextArea(textarea[0], cmConfig);
|
||||
cmObj = dialog.find(".CodeMirror");
|
||||
|
||||
cmObj.css({
|
||||
"float" : "none",
|
||||
margin : "0 0 5px",
|
||||
border : "1px solid #ddd",
|
||||
fontSize : settings.fontSize,
|
||||
width : "100%",
|
||||
height : "410px"
|
||||
});
|
||||
|
||||
cmEditor.on("change", function(cm) {
|
||||
textarea.val(cm.getValue());
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
cmEditor.setValue(cm.getSelection());
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
// CommonJS/Node.js
|
||||
if (typeof require === "function" && typeof exports === "object" && typeof module === "object")
|
||||
{
|
||||
module.exports = factory;
|
||||
}
|
||||
else if (typeof define === "function") // AMD/CMD/Sea.js
|
||||
{
|
||||
if (define.amd) { // for Require.js
|
||||
|
||||
define(["editormd"], function(editormd) {
|
||||
factory(editormd);
|
||||
});
|
||||
|
||||
} else { // for Sea.js
|
||||
define(function(require) {
|
||||
var editormd = require("./../../editormd");
|
||||
factory(editormd);
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
factory(window.editormd);
|
||||
}
|
||||
|
||||
})();
|
||||
|
@ -1,153 +1,155 @@
|
||||
/*!
|
||||
* Reference link dialog plugin for Editor.md
|
||||
*
|
||||
* @file reference-link-dialog.js
|
||||
* @author pandao
|
||||
* @version 1.2.1
|
||||
* @updateTime 2015-06-09
|
||||
* {@link https://github.com/pandao/editor.md}
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
var factory = function (exports) {
|
||||
|
||||
var pluginName = "reference-link-dialog";
|
||||
var ReLinkId = 1;
|
||||
|
||||
exports.fn.referenceLinkDialog = function() {
|
||||
|
||||
var _this = this;
|
||||
var cm = this.cm;
|
||||
var lang = this.lang;
|
||||
var editor = this.editor;
|
||||
var settings = this.settings;
|
||||
var cursor = cm.getCursor();
|
||||
var selection = cm.getSelection();
|
||||
var dialogLang = lang.dialog.referenceLink;
|
||||
var classPrefix = this.classPrefix;
|
||||
var dialogName = classPrefix + pluginName, dialog;
|
||||
|
||||
cm.focus();
|
||||
|
||||
if (editor.find("." + dialogName).length < 1)
|
||||
{
|
||||
var dialogHTML = "<div class=\"" + classPrefix + "form\">" +
|
||||
"<label>" + dialogLang.name + "</label>" +
|
||||
"<input type=\"text\" value=\"[" + ReLinkId + "]\" data-name />" +
|
||||
"<br/>" +
|
||||
"<label>" + dialogLang.urlId + "</label>" +
|
||||
"<input type=\"text\" data-url-id />" +
|
||||
"<br/>" +
|
||||
"<label>" + dialogLang.url + "</label>" +
|
||||
"<input type=\"text\" value=\"http://\" data-url />" +
|
||||
"<br/>" +
|
||||
"<label>" + dialogLang.urlTitle + "</label>" +
|
||||
"<input type=\"text\" value=\"" + selection + "\" data-title />" +
|
||||
"<br/>" +
|
||||
"</div>";
|
||||
|
||||
dialog = this.createDialog({
|
||||
name : dialogName,
|
||||
title : dialogLang.title,
|
||||
width : 380,
|
||||
height : 296,
|
||||
content : dialogHTML,
|
||||
mask : settings.dialogShowMask,
|
||||
drag : settings.dialogDraggable,
|
||||
lockScreen : settings.dialogLockScreen,
|
||||
maskStyle : {
|
||||
opacity : settings.dialogMaskOpacity,
|
||||
backgroundColor : settings.dialogMaskBgColor
|
||||
},
|
||||
buttons : {
|
||||
enter : [lang.buttons.enter, function() {
|
||||
var name = this.find("[data-name]").val();
|
||||
var url = this.find("[data-url]").val();
|
||||
var rid = this.find("[data-url-id]").val();
|
||||
var title = this.find("[data-title]").val();
|
||||
|
||||
if (name === "")
|
||||
{
|
||||
alert(dialogLang.nameEmpty);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (rid === "")
|
||||
{
|
||||
alert(dialogLang.idEmpty);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (url === "http://" || url === "")
|
||||
{
|
||||
alert(dialogLang.urlEmpty);
|
||||
return false;
|
||||
}
|
||||
|
||||
//cm.replaceSelection("[" + title + "][" + name + "]\n[" + name + "]: " + url + "");
|
||||
cm.replaceSelection("[" + name + "][" + rid + "]");
|
||||
|
||||
if (selection === "") {
|
||||
cm.setCursor(cursor.line, cursor.ch + 1);
|
||||
}
|
||||
|
||||
title = (title === "") ? "" : " \"" + title + "\"";
|
||||
|
||||
cm.setValue(cm.getValue() + "\n[" + rid + "]: " + url + title + "");
|
||||
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
|
||||
return false;
|
||||
}],
|
||||
cancel : [lang.buttons.cancel, function() {
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
|
||||
return false;
|
||||
}]
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dialog = editor.find("." + dialogName);
|
||||
dialog.find("[data-name]").val("[" + ReLinkId + "]");
|
||||
dialog.find("[data-url-id]").val("");
|
||||
dialog.find("[data-url]").val("http://");
|
||||
dialog.find("[data-title]").val(selection);
|
||||
|
||||
this.dialogShowMask(dialog);
|
||||
this.dialogLockScreen();
|
||||
dialog.show();
|
||||
|
||||
ReLinkId++;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
// CommonJS/Node.js
|
||||
if (typeof require === "function" && typeof exports === "object" && typeof module === "object")
|
||||
{
|
||||
module.exports = factory;
|
||||
}
|
||||
else if (typeof define === "function") // AMD/CMD/Sea.js
|
||||
{
|
||||
if (define.amd) { // for Require.js
|
||||
|
||||
define(["editormd"], function(editormd) {
|
||||
factory(editormd);
|
||||
});
|
||||
|
||||
} else { // for Sea.js
|
||||
define(function(require) {
|
||||
var editormd = require("./../../editormd");
|
||||
factory(editormd);
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
factory(window.editormd);
|
||||
}
|
||||
|
||||
})();
|
||||
/*!
|
||||
* Reference link dialog plugin for Editor.md
|
||||
*
|
||||
* @file reference-link-dialog.js
|
||||
* @author pandao
|
||||
* @version 1.2.1
|
||||
* @updateTime 2015-06-09
|
||||
* {@link https://github.com/pandao/editor.md}
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
var factory = function (exports) {
|
||||
|
||||
var pluginName = "reference-link-dialog";
|
||||
var ReLinkId = 1;
|
||||
|
||||
exports.fn.referenceLinkDialog = function() {
|
||||
|
||||
var _this = this;
|
||||
var cm = this.cm;
|
||||
var lang = this.lang;
|
||||
var editor = this.editor;
|
||||
var settings = this.settings;
|
||||
var cursor = cm.getCursor();
|
||||
var selection = cm.getSelection();
|
||||
var dialogLang = lang.dialog.referenceLink;
|
||||
var classPrefix = this.classPrefix;
|
||||
var dialogName = classPrefix + pluginName, dialog;
|
||||
|
||||
cm.focus();
|
||||
|
||||
if (editor.find("." + dialogName).length < 1)
|
||||
{
|
||||
var dialogHTML = "<div class=\"" + classPrefix + "form\">" +
|
||||
"<label>" + dialogLang.name + "</label>" +
|
||||
"<input type=\"text\" value=\"[" + ReLinkId + "]\" data-name />" +
|
||||
"<br/>" +
|
||||
"<label>" + dialogLang.urlId + "</label>" +
|
||||
"<input type=\"text\" data-url-id />" +
|
||||
"<br/>" +
|
||||
"<label>" + dialogLang.url + "</label>" +
|
||||
"<input type=\"text\" value=\"http://\" data-url />" +
|
||||
"<br/>" +
|
||||
"<label>" + dialogLang.urlTitle + "</label>" +
|
||||
"<input type=\"text\" value=\"" + selection + "\" data-title />" +
|
||||
"<br/>" +
|
||||
"</div>";
|
||||
|
||||
dialog = this.createDialog({
|
||||
name : dialogName,
|
||||
title : dialogLang.title,
|
||||
width : 380,
|
||||
height : 296,
|
||||
content : dialogHTML,
|
||||
mask : settings.dialogShowMask,
|
||||
drag : settings.dialogDraggable,
|
||||
lockScreen : settings.dialogLockScreen,
|
||||
maskStyle : {
|
||||
opacity : settings.dialogMaskOpacity,
|
||||
backgroundColor : settings.dialogMaskBgColor
|
||||
},
|
||||
buttons : {
|
||||
enter : [lang.buttons.enter, function() {
|
||||
var name = this.find("[data-name]").val();
|
||||
var url = this.find("[data-url]").val();
|
||||
var rid = this.find("[data-url-id]").val();
|
||||
var title = this.find("[data-title]").val();
|
||||
|
||||
if (name === "")
|
||||
{
|
||||
alert(dialogLang.nameEmpty);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (rid === "")
|
||||
{
|
||||
alert(dialogLang.idEmpty);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (url === "http://" || url === "")
|
||||
{
|
||||
alert(dialogLang.urlEmpty);
|
||||
return false;
|
||||
}
|
||||
|
||||
//cm.replaceSelection("[" + title + "][" + name + "]\n[" + name + "]: " + url + "");
|
||||
cm.replaceSelection("[" + name + "][" + rid + "]");
|
||||
|
||||
if (selection === "") {
|
||||
cm.setCursor(cursor.line, cursor.ch + 1);
|
||||
}
|
||||
|
||||
title = (title === "") ? "" : " \"" + title + "\"";
|
||||
|
||||
cm.setValue(cm.getValue() + "\n[" + rid + "]: " + url + title + "");
|
||||
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
cm.focus && cm.focus();
|
||||
|
||||
return false;
|
||||
}],
|
||||
cancel : [lang.buttons.cancel, function() {
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
cm.focus && cm.focus();
|
||||
|
||||
return false;
|
||||
}]
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dialog = editor.find("." + dialogName);
|
||||
dialog.find("[data-name]").val("[" + ReLinkId + "]");
|
||||
dialog.find("[data-url-id]").val("");
|
||||
dialog.find("[data-url]").val("http://");
|
||||
dialog.find("[data-title]").val(selection);
|
||||
|
||||
this.dialogShowMask(dialog);
|
||||
this.dialogLockScreen();
|
||||
dialog.show();
|
||||
|
||||
ReLinkId++;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
// CommonJS/Node.js
|
||||
if (typeof require === "function" && typeof exports === "object" && typeof module === "object")
|
||||
{
|
||||
module.exports = factory;
|
||||
}
|
||||
else if (typeof define === "function") // AMD/CMD/Sea.js
|
||||
{
|
||||
if (define.amd) { // for Require.js
|
||||
|
||||
define(["editormd"], function(editormd) {
|
||||
factory(editormd);
|
||||
});
|
||||
|
||||
} else { // for Sea.js
|
||||
define(function(require) {
|
||||
var editormd = require("./../../editormd");
|
||||
factory(editormd);
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
factory(window.editormd);
|
||||
}
|
||||
|
||||
})();
|
||||
|
@ -1,218 +1,220 @@
|
||||
/*!
|
||||
* Table dialog plugin for Editor.md
|
||||
*
|
||||
* @file table-dialog.js
|
||||
* @author pandao
|
||||
* @version 1.2.1
|
||||
* @updateTime 2015-06-09
|
||||
* {@link https://github.com/pandao/editor.md}
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
var factory = function (exports) {
|
||||
|
||||
var $ = jQuery;
|
||||
var pluginName = "table-dialog";
|
||||
|
||||
var langs = {
|
||||
"zh-cn" : {
|
||||
toolbar : {
|
||||
table : "表格"
|
||||
},
|
||||
dialog : {
|
||||
table : {
|
||||
title : "添加表格",
|
||||
cellsLabel : "单元格数",
|
||||
alignLabel : "对齐方式",
|
||||
rows : "行数",
|
||||
cols : "列数",
|
||||
aligns : ["默认", "左对齐", "居中对齐", "右对齐"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"zh-tw" : {
|
||||
toolbar : {
|
||||
table : "添加表格"
|
||||
},
|
||||
dialog : {
|
||||
table : {
|
||||
title : "添加表格",
|
||||
cellsLabel : "單元格數",
|
||||
alignLabel : "對齊方式",
|
||||
rows : "行數",
|
||||
cols : "列數",
|
||||
aligns : ["默認", "左對齊", "居中對齊", "右對齊"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"en" : {
|
||||
toolbar : {
|
||||
table : "Tables"
|
||||
},
|
||||
dialog : {
|
||||
table : {
|
||||
title : "Tables",
|
||||
cellsLabel : "Cells",
|
||||
alignLabel : "Align",
|
||||
rows : "Rows",
|
||||
cols : "Cols",
|
||||
aligns : ["Default", "Left align", "Center align", "Right align"]
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.fn.tableDialog = function() {
|
||||
var _this = this;
|
||||
var cm = this.cm;
|
||||
var editor = this.editor;
|
||||
var settings = this.settings;
|
||||
var path = settings.path + "../plugins/" + pluginName +"/";
|
||||
var classPrefix = this.classPrefix;
|
||||
var dialogName = classPrefix + pluginName, dialog;
|
||||
|
||||
$.extend(true, this.lang, langs[this.lang.name]);
|
||||
this.setToolbar();
|
||||
|
||||
var lang = this.lang;
|
||||
var dialogLang = lang.dialog.table;
|
||||
|
||||
var dialogContent = [
|
||||
"<div class=\"editormd-form\" style=\"padding: 13px 0;\">",
|
||||
"<label>" + dialogLang.cellsLabel + "</label>",
|
||||
dialogLang.rows + " <input type=\"number\" value=\"3\" class=\"number-input\" style=\"width:40px;\" max=\"100\" min=\"2\" data-rows /> ",
|
||||
dialogLang.cols + " <input type=\"number\" value=\"2\" class=\"number-input\" style=\"width:40px;\" max=\"100\" min=\"1\" data-cols /><br/>",
|
||||
"<label>" + dialogLang.alignLabel + "</label>",
|
||||
"<div class=\"fa-btns\"></div>",
|
||||
"</div>"
|
||||
].join("\n");
|
||||
|
||||
if (editor.find("." + dialogName).length > 0)
|
||||
{
|
||||
dialog = editor.find("." + dialogName);
|
||||
|
||||
this.dialogShowMask(dialog);
|
||||
this.dialogLockScreen();
|
||||
dialog.show();
|
||||
}
|
||||
else
|
||||
{
|
||||
dialog = this.createDialog({
|
||||
name : dialogName,
|
||||
title : dialogLang.title,
|
||||
width : 360,
|
||||
height : 244,
|
||||
mask : settings.dialogShowMask,
|
||||
drag : settings.dialogDraggable,
|
||||
content : dialogContent,
|
||||
lockScreen : settings.dialogLockScreen,
|
||||
maskStyle : {
|
||||
opacity : settings.dialogMaskOpacity,
|
||||
backgroundColor : settings.dialogMaskBgColor
|
||||
},
|
||||
buttons : {
|
||||
enter : [lang.buttons.enter, function() {
|
||||
var rows = parseInt(this.find("[data-rows]").val());
|
||||
var cols = parseInt(this.find("[data-cols]").val());
|
||||
var align = this.find("[name=\"table-align\"]:checked").val();
|
||||
var table = "";
|
||||
var hrLine = "------------";
|
||||
|
||||
var alignSign = {
|
||||
_default : hrLine,
|
||||
left : ":" + hrLine,
|
||||
center : ":" + hrLine + ":",
|
||||
right : hrLine + ":"
|
||||
};
|
||||
|
||||
if ( rows > 1 && cols > 0)
|
||||
{
|
||||
for (var r = 0, len = rows; r < len; r++)
|
||||
{
|
||||
var row = [];
|
||||
var head = [];
|
||||
|
||||
for (var c = 0, len2 = cols; c < len2; c++)
|
||||
{
|
||||
if (r === 1) {
|
||||
head.push(alignSign[align]);
|
||||
}
|
||||
|
||||
row.push(" ");
|
||||
}
|
||||
|
||||
if (r === 1) {
|
||||
table += "| " + head.join(" | ") + " |" + "\n";
|
||||
}
|
||||
|
||||
table += "| " + row.join( (cols === 1) ? "" : " | " ) + " |" + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
cm.replaceSelection(table);
|
||||
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
|
||||
return false;
|
||||
}],
|
||||
|
||||
cancel : [lang.buttons.cancel, function() {
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
|
||||
return false;
|
||||
}]
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var faBtns = dialog.find(".fa-btns");
|
||||
|
||||
if (faBtns.html() === "")
|
||||
{
|
||||
var icons = ["align-justify", "align-left", "align-center", "align-right"];
|
||||
var _lang = dialogLang.aligns;
|
||||
var values = ["_default", "left", "center", "right"];
|
||||
|
||||
for (var i = 0, len = icons.length; i < len; i++)
|
||||
{
|
||||
var checked = (i === 0) ? " checked=\"checked\"" : "";
|
||||
var btn = "<a href=\"javascript:;\"><label for=\"editormd-table-dialog-radio"+i+"\" title=\"" + _lang[i] + "\">";
|
||||
btn += "<input type=\"radio\" name=\"table-align\" id=\"editormd-table-dialog-radio"+i+"\" value=\"" + values[i] + "\"" +checked + " /> ";
|
||||
btn += "<i class=\"fa fa-" + icons[i] + "\"></i>";
|
||||
btn += "</label></a>";
|
||||
|
||||
faBtns.append(btn);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
// CommonJS/Node.js
|
||||
if (typeof require === "function" && typeof exports === "object" && typeof module === "object")
|
||||
{
|
||||
module.exports = factory;
|
||||
}
|
||||
else if (typeof define === "function") // AMD/CMD/Sea.js
|
||||
{
|
||||
if (define.amd) { // for Require.js
|
||||
|
||||
define(["editormd"], function(editormd) {
|
||||
factory(editormd);
|
||||
});
|
||||
|
||||
} else { // for Sea.js
|
||||
define(function(require) {
|
||||
var editormd = require("./../../editormd");
|
||||
factory(editormd);
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
factory(window.editormd);
|
||||
}
|
||||
|
||||
})();
|
||||
/*!
|
||||
* Table dialog plugin for Editor.md
|
||||
*
|
||||
* @file table-dialog.js
|
||||
* @author pandao
|
||||
* @version 1.2.1
|
||||
* @updateTime 2015-06-09
|
||||
* {@link https://github.com/pandao/editor.md}
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
var factory = function (exports) {
|
||||
|
||||
var $ = jQuery;
|
||||
var pluginName = "table-dialog";
|
||||
|
||||
var langs = {
|
||||
"zh-cn" : {
|
||||
toolbar : {
|
||||
table : "表格"
|
||||
},
|
||||
dialog : {
|
||||
table : {
|
||||
title : "添加表格",
|
||||
cellsLabel : "单元格数",
|
||||
alignLabel : "对齐方式",
|
||||
rows : "行数",
|
||||
cols : "列数",
|
||||
aligns : ["默认", "左对齐", "居中对齐", "右对齐"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"zh-tw" : {
|
||||
toolbar : {
|
||||
table : "添加表格"
|
||||
},
|
||||
dialog : {
|
||||
table : {
|
||||
title : "添加表格",
|
||||
cellsLabel : "單元格數",
|
||||
alignLabel : "對齊方式",
|
||||
rows : "行數",
|
||||
cols : "列數",
|
||||
aligns : ["默認", "左對齊", "居中對齊", "右對齊"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"en" : {
|
||||
toolbar : {
|
||||
table : "Tables"
|
||||
},
|
||||
dialog : {
|
||||
table : {
|
||||
title : "Tables",
|
||||
cellsLabel : "Cells",
|
||||
alignLabel : "Align",
|
||||
rows : "Rows",
|
||||
cols : "Cols",
|
||||
aligns : ["Default", "Left align", "Center align", "Right align"]
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.fn.tableDialog = function() {
|
||||
var _this = this;
|
||||
var cm = this.cm;
|
||||
var editor = this.editor;
|
||||
var settings = this.settings;
|
||||
var path = settings.path + "../plugins/" + pluginName +"/";
|
||||
var classPrefix = this.classPrefix;
|
||||
var dialogName = classPrefix + pluginName, dialog;
|
||||
|
||||
$.extend(true, this.lang, langs[this.lang.name]);
|
||||
this.setToolbar();
|
||||
|
||||
var lang = this.lang;
|
||||
var dialogLang = lang.dialog.table;
|
||||
|
||||
var dialogContent = [
|
||||
"<div class=\"editormd-form\" style=\"padding: 13px 0;\">",
|
||||
"<label>" + dialogLang.cellsLabel + "</label>",
|
||||
dialogLang.rows + " <input type=\"number\" value=\"3\" class=\"number-input\" style=\"width:40px;\" max=\"100\" min=\"2\" data-rows /> ",
|
||||
dialogLang.cols + " <input type=\"number\" value=\"2\" class=\"number-input\" style=\"width:40px;\" max=\"100\" min=\"1\" data-cols /><br/>",
|
||||
"<label>" + dialogLang.alignLabel + "</label>",
|
||||
"<div class=\"fa-btns\"></div>",
|
||||
"</div>"
|
||||
].join("\n");
|
||||
|
||||
if (editor.find("." + dialogName).length > 0)
|
||||
{
|
||||
dialog = editor.find("." + dialogName);
|
||||
|
||||
this.dialogShowMask(dialog);
|
||||
this.dialogLockScreen();
|
||||
dialog.show();
|
||||
}
|
||||
else
|
||||
{
|
||||
dialog = this.createDialog({
|
||||
name : dialogName,
|
||||
title : dialogLang.title,
|
||||
width : 360,
|
||||
height : 244,
|
||||
mask : settings.dialogShowMask,
|
||||
drag : settings.dialogDraggable,
|
||||
content : dialogContent,
|
||||
lockScreen : settings.dialogLockScreen,
|
||||
maskStyle : {
|
||||
opacity : settings.dialogMaskOpacity,
|
||||
backgroundColor : settings.dialogMaskBgColor
|
||||
},
|
||||
buttons : {
|
||||
enter : [lang.buttons.enter, function() {
|
||||
var rows = parseInt(this.find("[data-rows]").val());
|
||||
var cols = parseInt(this.find("[data-cols]").val());
|
||||
var align = this.find("[name=\"table-align\"]:checked").val();
|
||||
var table = "";
|
||||
var hrLine = "------------";
|
||||
|
||||
var alignSign = {
|
||||
_default : hrLine,
|
||||
left : ":" + hrLine,
|
||||
center : ":" + hrLine + ":",
|
||||
right : hrLine + ":"
|
||||
};
|
||||
|
||||
if ( rows > 1 && cols > 0)
|
||||
{
|
||||
for (var r = 0, len = rows; r < len; r++)
|
||||
{
|
||||
var row = [];
|
||||
var head = [];
|
||||
|
||||
for (var c = 0, len2 = cols; c < len2; c++)
|
||||
{
|
||||
if (r === 1) {
|
||||
head.push(alignSign[align]);
|
||||
}
|
||||
|
||||
row.push(" ");
|
||||
}
|
||||
|
||||
if (r === 1) {
|
||||
table += "| " + head.join(" | ") + " |" + "\n";
|
||||
}
|
||||
|
||||
table += "| " + row.join( (cols === 1) ? "" : " | " ) + " |" + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
cm.replaceSelection(table);
|
||||
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
cm.focus && cm.focus();
|
||||
|
||||
return false;
|
||||
}],
|
||||
|
||||
cancel : [lang.buttons.cancel, function() {
|
||||
this.hide().lockScreen(false).hideMask();
|
||||
cm.focus && cm.focus();
|
||||
|
||||
return false;
|
||||
}]
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var faBtns = dialog.find(".fa-btns");
|
||||
|
||||
if (faBtns.html() === "")
|
||||
{
|
||||
var icons = ["align-justify", "align-left", "align-center", "align-right"];
|
||||
var _lang = dialogLang.aligns;
|
||||
var values = ["_default", "left", "center", "right"];
|
||||
|
||||
for (var i = 0, len = icons.length; i < len; i++)
|
||||
{
|
||||
var checked = (i === 0) ? " checked=\"checked\"" : "";
|
||||
var btn = "<a href=\"javascript:;\"><label for=\"editormd-table-dialog-radio"+i+"\" title=\"" + _lang[i] + "\">";
|
||||
btn += "<input type=\"radio\" name=\"table-align\" id=\"editormd-table-dialog-radio"+i+"\" value=\"" + values[i] + "\"" +checked + " /> ";
|
||||
btn += "<i class=\"fa fa-" + icons[i] + "\"></i>";
|
||||
btn += "</label></a>";
|
||||
|
||||
faBtns.append(btn);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
// CommonJS/Node.js
|
||||
if (typeof require === "function" && typeof exports === "object" && typeof module === "object")
|
||||
{
|
||||
module.exports = factory;
|
||||
}
|
||||
else if (typeof define === "function") // AMD/CMD/Sea.js
|
||||
{
|
||||
if (define.amd) { // for Require.js
|
||||
|
||||
define(["editormd"], function(editormd) {
|
||||
factory(editormd);
|
||||
});
|
||||
|
||||
} else { // for Sea.js
|
||||
define(function(require) {
|
||||
var editormd = require("./../../editormd");
|
||||
factory(editormd);
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
factory(window.editormd);
|
||||
}
|
||||
|
||||
})();
|
||||
|
After Width: | Height: | Size: 65 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 210 KiB |
Loading…
Reference in new issue