define(['jquery', 'bootstrap', 'backend', 'form', 'ace/ace', 'tools'], function ($, undefined, Backend, Form, ace, undefined) {
var Controller = {
index: function () {
//初始化编辑器
editor = Controller.api.editpageInit(false, true);
//设置标题
var parent_title = $('.layui-layer-title:last', window.parent.document).html() + ' ' + Config.filepath;
$('.layui-layer-title:last', window.parent.document).html(parent_title);
//改变的时候记录未保存
editor.on("change", function () {
$('#update_file').html(' 未保存');
});
// 复制路径
$(document).on("click", ".btn-copy", function () {
Controller.api.copy($(this).data('path'));
});
//Ctrl + S 保存
$(document).bind("keydown", function(e) {
console.log(e.which);
if (e.ctrlKey && (e.which == 83)) {
e.preventDefault();
$("form[role=form]").submit();
return false;
}
});
//点击保存事件
$(document).on("click", "#editpage_btn", function () {
$("form[role=form]").submit();
});
//表单提交事件绑定
Form.api.bindevent($("#add-form"), function (data, ret) {
return false;
}, function (data, ret) {
var content = editor.getValue();
var file = $('#file').val();
Fast.api.ajax({
url: 'editpage/savefile',
data: {file: file, content: content}
}, function (data, ret) {
$('#update_file').html('已保存');
});
return false;
});
},
command: function () {
//初始化编辑器
editor = Controller.api.editpageInit('text', false);
//点击命令按钮
$('.btn').click(function() {
var val = $(this).data('val');
editor.setValue($('#' + val).html() + "\n", true);
})
$(document).keydown(function(){
if (event.keyCode == 13) {//回车键的键值为13
var content = editor.getValue();
var content = content.split(/[\n,]/g);
for(var i =0;i拷贝路径成功,请使用Ctrl+V粘贴。
' + val);
}
}
};
return Controller;
});