2014-07-13 21:03:48 +04:00
|
|
|
/*global CodeMirror, device, FastClick*/
|
2014-06-24 05:17:57 +04:00
|
|
|
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);
|
|
|
|
};
|
|
|
|
|
2014-10-25 01:09:50 +04:00
|
|
|
CodeMirror.keyMap = {basic: {}};
|
2014-06-24 05:17:57 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
init = function init() {
|
2014-10-25 01:09:50 +04:00
|
|
|
// Codemirror does not function on mobile devices, or on any iDevice
|
2014-06-30 22:29:36 +04:00
|
|
|
if (device.mobile() || (device.tablet() && device.ios())) {
|
2014-06-24 05:17:57 +04:00
|
|
|
$('body').addClass('touch-editor');
|
|
|
|
|
|
|
|
Ember.touchEditor = true;
|
2014-10-25 01:09:50 +04:00
|
|
|
|
|
|
|
// initialize FastClick to remove touch delays
|
2014-07-13 21:03:48 +04:00
|
|
|
Ember.run.scheduleOnce('afterRender', null, function () {
|
|
|
|
FastClick.attach(document.body);
|
|
|
|
});
|
2014-10-25 01:09:50 +04:00
|
|
|
|
2014-06-24 05:17:57 +04:00
|
|
|
TouchEditor = createTouchEditor();
|
|
|
|
setupMobileCodeMirror();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export default {
|
|
|
|
createIfMobile: init
|
|
|
|
};
|