mirror of
https://github.com/ansible/awx.git
synced 2026-04-09 03:59:21 -02:30
Merge pull request #3013 from jlmitch5/readOnlyCodeMirror
add options for code mirror to be read only
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "angular-codemirror",
|
"name": "angular-codemirror",
|
||||||
"version": "1.0.2",
|
"version": "1.0.3",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"angular": "latest",
|
"angular": "latest",
|
||||||
"angular-route": "latest",
|
"angular-route": "latest",
|
||||||
@@ -13,14 +13,13 @@
|
|||||||
"codemirror": "latest"
|
"codemirror": "latest"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/chouseknecht/angular-codemirror",
|
"homepage": "https://github.com/chouseknecht/angular-codemirror",
|
||||||
"_release": "1.0.2",
|
"_release": "1.0.3",
|
||||||
"_resolution": {
|
"_resolution": {
|
||||||
"type": "version",
|
"type": "version",
|
||||||
"tag": "v1.0.2",
|
"tag": "1.0.3",
|
||||||
"commit": "94b7aac548b036f4fbd94e56129ed9574e472616"
|
"commit": "b94dc86fde8f60a50b324054806d29d742177d21"
|
||||||
},
|
},
|
||||||
"_source": "git://github.com/chouseknecht/angular-codemirror.git",
|
"_source": "https://github.com/chouseknecht/angular-codemirror.git",
|
||||||
"_target": "~1.0.2",
|
"_target": "~1.0.3",
|
||||||
"_originalSource": "angular-codemirror",
|
"_originalSource": "angular-codemirror"
|
||||||
"_direct": true
|
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "angular-codemirror",
|
"name": "angular-codemirror",
|
||||||
"version": "0.0.3",
|
"version": "1.0.2",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"angular": "latest",
|
"angular": "latest",
|
||||||
"angular-route": "latest",
|
"angular-route": "latest",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/**********************************************
|
/**********************************************
|
||||||
* AngularCodeMirror.css
|
* AngularCodeMirror.css
|
||||||
*
|
*
|
||||||
* CodeMirror.css overrides
|
* CodeMirror.css overrides
|
||||||
*
|
*
|
||||||
* Copyright (c) 2014 Chris Houseknecht
|
* Copyright (c) 2014 Chris Houseknecht
|
||||||
@@ -30,14 +30,14 @@
|
|||||||
.CodeMirror {
|
.CodeMirror {
|
||||||
height: auto;
|
height: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror-activeline-background {
|
.CodeMirror-activeline-background {
|
||||||
background-color: #f7f7f7;
|
background-color: #f7f7f7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Modal dialog overrides to make jqueryui dialog blend in with Twitter.
|
||||||
/* Modal dialog overrides to make jqueryui dialog blend in with Twitter.
|
|
||||||
Why? Twitter's modal is not draggable or resizable, which is not very
|
Why? Twitter's modal is not draggable or resizable, which is not very
|
||||||
useful for a code editor */
|
useful for a code editor */
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@
|
|||||||
border-color: #ffffff;
|
border-color: #ffffff;
|
||||||
color: #A9A9A9;
|
color: #A9A9A9;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ui-dialog .ui-resizable-se {
|
.ui-dialog .ui-resizable-se {
|
||||||
right: 5px;
|
right: 5px;
|
||||||
bottom: 5px;
|
bottom: 5px;
|
||||||
@@ -108,3 +108,4 @@
|
|||||||
.CodeMirror-lint-tooltip {
|
.CodeMirror-lint-tooltip {
|
||||||
z-index: 2060;
|
z-index: 2060;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
angular.module('AngularCodeMirrorModule', [])
|
angular.module('AngularCodeMirrorModule', [])
|
||||||
|
|
||||||
.factory('AngularCodeMirror', [ function() {
|
.factory('AngularCodeMirror', [ function() {
|
||||||
return function() {
|
return function(readOnly) {
|
||||||
var fn = function() {
|
var fn = function() {
|
||||||
|
|
||||||
this.myCodeMirror = null;
|
this.myCodeMirror = null;
|
||||||
@@ -43,7 +43,6 @@ angular.module('AngularCodeMirrorModule', [])
|
|||||||
model = params.model,
|
model = params.model,
|
||||||
mode = params.mode,
|
mode = params.mode,
|
||||||
onReady = params.onReady,
|
onReady = params.onReady,
|
||||||
onChange = params.onChange,
|
|
||||||
height = 0;
|
height = 0;
|
||||||
|
|
||||||
self.element = $(element);
|
self.element = $(element);
|
||||||
@@ -69,6 +68,15 @@ angular.module('AngularCodeMirrorModule', [])
|
|||||||
|
|
||||||
// Initialize CodeMirror
|
// Initialize CodeMirror
|
||||||
self.modes[mode].value = scope[model];
|
self.modes[mode].value = scope[model];
|
||||||
|
|
||||||
|
// if readOnly is passed to AngularCodeMirror, set the
|
||||||
|
// options for all modes to be readOnly
|
||||||
|
if (readOnly) {
|
||||||
|
Object.keys(self.modes).forEach(function(val) {
|
||||||
|
self.modes[val].readOnly = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
self.myCodeMirror = CodeMirror(document.getElementById('cm-' + model + '-container'), self.modes[mode]);
|
self.myCodeMirror = CodeMirror(document.getElementById('cm-' + model + '-container'), self.modes[mode]);
|
||||||
|
|
||||||
// Adjust the height
|
// Adjust the height
|
||||||
@@ -85,14 +93,7 @@ angular.module('AngularCodeMirrorModule', [])
|
|||||||
|
|
||||||
// Update the model on change
|
// Update the model on change
|
||||||
self.myCodeMirror.on('change', function() {
|
self.myCodeMirror.on('change', function() {
|
||||||
setTimeout(function() {
|
setTimeout(function() { scope.$apply(function(){ scope[model] = self.myCodeMirror.getValue(); }); }, 500);
|
||||||
scope.$apply(function(){
|
|
||||||
scope[model] = self.myCodeMirror.getValue();
|
|
||||||
if (onChange) {
|
|
||||||
onChange();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}, 500);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -52,8 +52,7 @@
|
|||||||
"tag": "2.0.0",
|
"tag": "2.0.0",
|
||||||
"commit": "8a1951c54a956c33964c99b338f3a4830e652689"
|
"commit": "8a1951c54a956c33964c99b338f3a4830e652689"
|
||||||
},
|
},
|
||||||
"_source": "git://github.com/tameraydin/ngToast.git",
|
"_source": "https://github.com/tameraydin/ngToast.git",
|
||||||
"_target": "~2.0.0",
|
"_target": "~2.0.0",
|
||||||
"_originalSource": "ngtoast",
|
"_originalSource": "ngtoast"
|
||||||
"_direct": true
|
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,8 @@ export default
|
|||||||
fld = (params.variable) ? params.variable : 'variables',
|
fld = (params.variable) ? params.variable : 'variables',
|
||||||
pfld = (params.parse_variable) ? params.parse_variable : 'parseType',
|
pfld = (params.parse_variable) ? params.parse_variable : 'parseType',
|
||||||
onReady = params.onReady,
|
onReady = params.onReady,
|
||||||
onChange = params.onChange;
|
onChange = params.onChange,
|
||||||
|
readOnly = params.readOnly;
|
||||||
|
|
||||||
function removeField(fld) {
|
function removeField(fld) {
|
||||||
//set our model to the last change in CodeMirror and then destroy CodeMirror
|
//set our model to the last change in CodeMirror and then destroy CodeMirror
|
||||||
@@ -35,8 +36,7 @@ export default
|
|||||||
|
|
||||||
function createField(onChange, onReady, fld) {
|
function createField(onChange, onReady, fld) {
|
||||||
//hide the textarea and show a fresh CodeMirror with the current mode (json or yaml)
|
//hide the textarea and show a fresh CodeMirror with the current mode (json or yaml)
|
||||||
|
scope[fld + 'codeMirror'] = AngularCodeMirror(readOnly);
|
||||||
scope[fld + 'codeMirror'] = AngularCodeMirror();
|
|
||||||
scope[fld + 'codeMirror'].addModes($AnsibleConfig.variable_edit_modes);
|
scope[fld + 'codeMirror'].addModes($AnsibleConfig.variable_edit_modes);
|
||||||
scope[fld + 'codeMirror'].showTextArea({
|
scope[fld + 'codeMirror'].showTextArea({
|
||||||
scope: scope,
|
scope: scope,
|
||||||
|
|||||||
@@ -641,7 +641,7 @@ export default
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
//scope.setSearchAll('host');
|
//scope.setSearchAll('host');
|
||||||
ParseTypeChange({ scope: scope, field_id: 'pre-formatted-variables' });
|
ParseTypeChange({ scope: scope, field_id: 'pre-formatted-variables', readOnly: true });
|
||||||
scope.$emit('LoadPlays', data.related.job_events);
|
scope.$emit('LoadPlays', data.related.job_events);
|
||||||
})
|
})
|
||||||
.error(function(data, status) {
|
.error(function(data, status) {
|
||||||
|
|||||||
Reference in New Issue
Block a user