Ghost/core/client/utils/codemirror-mobile.js
Jason Williams 0f17378b26 Enable JSCS checking on client.
Refs #4001
- grunt-jscs@0.8.1 which provides ES6 support.
2014-10-25 16:13:04 +00:00

45 lines
1.1 KiB
JavaScript

/*global CodeMirror, device, FastClick*/
import createTouchEditor from 'ghost/assets/lib/touch-editor';
var setupMobileCodeMirror,
TouchEditor,
init;
setupMobileCodeMirror = function setupMobileCodeMirror() {
var noop = function () {},
key;
for (key in CodeMirror) {
if (CodeMirror.hasOwnProperty(key)) {
CodeMirror[key] = noop;
}
}
CodeMirror.fromTextArea = function (el, options) {
return new TouchEditor(el, options);
};
CodeMirror.keyMap = {basic: {}};
};
init = function init() {
// Codemirror does not function on mobile devices, or on any iDevice
if (device.mobile() || (device.tablet() && device.ios())) {
$('body').addClass('touch-editor');
Ember.touchEditor = true;
// initialize FastClick to remove touch delays
Ember.run.scheduleOnce('afterRender', null, function () {
FastClick.attach(document.body);
});
TouchEditor = createTouchEditor();
setupMobileCodeMirror();
}
};
export default {
createIfMobile: init
};