mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
6658675646
closes #2957 - add FastClick library to Gruntfile.js - add touch-editor to client/assets/lib/ - add mobile-specific utils to util/mobile-utils.js - add codemirror util to set up TouchEditor only if we're really on mobile - change gh-codemirror from having a default action to a named action. prevents Ember.TextArea firing action on change - change gh-codemirror `cm.getDoc().getValue()` to `cm.getValue()` for portability - change codemirror-shortcuts ES6 export/import style - changed ghostimagepreview.js to check for Ember.touchEditor in addition to Ghost.touchEditor
55 lines
1.4 KiB
JavaScript
55 lines
1.4 KiB
JavaScript
var createTouchEditor = function createTouchEditor() {
|
|
var noop = function () {},
|
|
TouchEditor;
|
|
|
|
TouchEditor = function (el, options) {
|
|
/*jshint unused:false*/
|
|
this.textarea = el;
|
|
this.win = { document : this.textarea };
|
|
this.ready = true;
|
|
this.wrapping = document.createElement('div');
|
|
|
|
var textareaParent = this.textarea.parentNode;
|
|
this.wrapping.appendChild(this.textarea);
|
|
textareaParent.appendChild(this.wrapping);
|
|
|
|
this.textarea.style.opacity = 1;
|
|
};
|
|
|
|
TouchEditor.prototype = {
|
|
setOption: function (type, handler) {
|
|
if (type === 'onChange') {
|
|
$(this.textarea).change(handler);
|
|
}
|
|
},
|
|
eachLine: function () {
|
|
return [];
|
|
},
|
|
getValue: function () {
|
|
return this.textarea.value;
|
|
},
|
|
setValue: function (code) {
|
|
this.textarea.value = code;
|
|
},
|
|
focus: noop,
|
|
getCursor: function () {
|
|
return { line: 0, ch: 0 };
|
|
},
|
|
setCursor: noop,
|
|
currentLine: function () {
|
|
return 0;
|
|
},
|
|
cursorPosition: function () {
|
|
return { character: 0 };
|
|
},
|
|
addMarkdown: noop,
|
|
nthLine: noop,
|
|
refresh: noop,
|
|
selectLines: noop,
|
|
on: noop
|
|
};
|
|
|
|
return TouchEditor;
|
|
};
|
|
|
|
export default createTouchEditor;
|