applied changes for rfe 9200 to later version of object.js
This commit is contained in:
parent
f4dab79093
commit
2584482fcf
1 changed files with 115 additions and 62 deletions
|
|
@ -1,73 +1,126 @@
|
||||||
if (typeof Survey == "undefined") {
|
|
||||||
|
/*global Survey, YAHOO */
|
||||||
|
if (typeof Survey === "undefined") {
|
||||||
var Survey = {};
|
var Survey = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Survey.ObjectTemplate = new function(){
|
Survey.ObjectTemplate = (function(){
|
||||||
|
|
||||||
this.loadObject = function(html,type){
|
// Keep references to widgets here so that we can destory any instances before
|
||||||
|
// creating new ones (to avoid memory leaks)
|
||||||
|
var dialog;
|
||||||
|
var editor;
|
||||||
|
|
||||||
document.getElementById('edit').innerHTML = html;
|
return {
|
||||||
|
|
||||||
var myTextarea;
|
unloadObject: function(){
|
||||||
|
// First destory the editor..
|
||||||
|
if (editor) {
|
||||||
|
editor.destroy();
|
||||||
|
editor = null;
|
||||||
|
}
|
||||||
|
|
||||||
var handleSubmit = function(){
|
// And then the Dialog that contains it.
|
||||||
myTextarea.saveHTML();
|
if (dialog) {
|
||||||
this.submit();
|
dialog.destroy();
|
||||||
}
|
dialog = null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
var butts = [
|
loadObject: function(html, type){
|
||||||
{ text:"Submit", handler:handleSubmit, isDefault:true },
|
// Make sure we purge any event listeners before overwrite innerHTML..
|
||||||
{ text:"Copy", handler:function(){document.getElementById('copy').value = 1; this.submit();}},
|
YAHOO.util.Event.purgeElement('edit', true);
|
||||||
{ text:"Cancel", handler:function(){this.cancel();}},
|
document.getElementById('edit').innerHTML = html;
|
||||||
{ text:"Delete", handler:function(){document.getElementById('delete').value = 1; this.submit();}}
|
|
||||||
];
|
|
||||||
|
|
||||||
var form = new YAHOO.widget.Dialog(type,
|
var btns = [{
|
||||||
{
|
text: "Submit",
|
||||||
width : "500px",
|
handler: function(){
|
||||||
fixedcenter : true,
|
editor.saveHTML();
|
||||||
visible : false,
|
this.submit();
|
||||||
constraintoviewport : true,
|
},
|
||||||
buttons : butts
|
isDefault: true
|
||||||
} );
|
}, {
|
||||||
|
text: "Copy",
|
||||||
|
handler: function(){
|
||||||
|
document.getElementById('copy').value = 1;
|
||||||
|
this.submit();
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
text: "Cancel",
|
||||||
|
handler: function(){
|
||||||
|
this.cancel();
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
text: "Delete",
|
||||||
|
handler: function(){
|
||||||
|
document.getElementById('delete').value = 1;
|
||||||
|
this.submit();
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
text: "Preview",
|
||||||
|
handler: function(){
|
||||||
|
if (type === 'answer') {
|
||||||
|
alert('Sorry, preview is only supported for Sections and Questions, not Answers');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var msg = 'This will delete any Survey responses you have made under this ' +
|
||||||
|
'user account and redirect you to the Take Survey page starting at the selected item. ' +
|
||||||
|
"\n\nAre you sure you want to continue?";
|
||||||
|
if (confirm(msg)) {
|
||||||
|
window.location.search = 'func=jumpTo;id=' + dialog.getData().id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
|
||||||
form.callback = Survey.Comm.callback;
|
dialog = new YAHOO.widget.Dialog(type, {
|
||||||
form.render();
|
width: "600px",
|
||||||
|
context: [document.body, 'tr', 'tr'],
|
||||||
|
visible: false,
|
||||||
|
constraintoviewport: true,
|
||||||
|
buttons: btns
|
||||||
|
});
|
||||||
|
|
||||||
if(type == 'question'){
|
dialog.callback = Survey.Comm.callback;
|
||||||
var resize = new YAHOO.util.Resize('resize_randomWords_formId');
|
dialog.render();
|
||||||
resize.on('resize', function(ev) {
|
|
||||||
YAHOO.util.Dom.setStyle('randomWords_formId', 'width', (ev.width - 6) + "px");
|
|
||||||
YAHOO.util.Dom.setStyle('randomWords_formId', 'height', (ev.height - 6) + "px");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if(type == 'answer'){
|
if(type == 'question'){
|
||||||
var resize = new YAHOO.util.Resize('resize_gotoExpression_formId');
|
var resize = new YAHOO.util.Resize('resize_randomWords_formId');
|
||||||
resize.on('resize', function(ev) {
|
resize.on('resize', function(ev) {
|
||||||
YAHOO.util.Dom.setStyle('gotoExpression_formId', 'width', (ev.width - 6) + "px");
|
YAHOO.util.Dom.setStyle('randomWords_formId', 'width', (ev.width - 6) + "px");
|
||||||
YAHOO.util.Dom.setStyle('gotoExpression_formId', 'height', (ev.height - 6) + "px");
|
YAHOO.util.Dom.setStyle('randomWords_formId', 'height', (ev.height - 6) + "px");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var textareaId = type+'Text';
|
if(type == 'answer'){
|
||||||
var textarea = YAHOO.util.Dom.get(textareaId);
|
var resize = new YAHOO.util.Resize('resize_gotoExpression_formId');
|
||||||
var height = YAHOO.util.Dom.getStyle(textarea,'height');
|
resize.on('resize', function(ev) {
|
||||||
if (height == ''){
|
YAHOO.util.Dom.setStyle('gotoExpression_formId', 'width', (ev.width - 6) + "px");
|
||||||
height = '300px';
|
YAHOO.util.Dom.setStyle('gotoExpression_formId', 'height', (ev.height - 6) + "px");
|
||||||
}
|
});
|
||||||
var width = YAHOO.util.Dom.getStyle(textarea,'width');
|
}
|
||||||
if (width == ''){
|
|
||||||
width = '500px';
|
|
||||||
}
|
|
||||||
myTextarea = new YAHOO.widget.SimpleEditor(textareaId, {
|
|
||||||
height: height,
|
|
||||||
width: width,
|
|
||||||
dompath: false //Turns on the bar at the bottom
|
|
||||||
});
|
|
||||||
myTextarea.render();
|
|
||||||
|
|
||||||
form.show();
|
var textareaId = type + 'Text';
|
||||||
}
|
var textarea = YAHOO.util.Dom.get(textareaId);
|
||||||
}();
|
|
||||||
|
|
||||||
|
var height = YAHOO.util.Dom.getStyle(textarea, 'height');
|
||||||
|
if (!height) {
|
||||||
|
height = '300px';
|
||||||
|
}
|
||||||
|
|
||||||
|
// N.B. SimpleEditor has a memory leak so this eats memory on every instantiation
|
||||||
|
editor = new YAHOO.widget.SimpleEditor(textareaId, {
|
||||||
|
height: height,
|
||||||
|
width: '100%',
|
||||||
|
dompath: false //Turns on the bar at the bottom
|
||||||
|
});
|
||||||
|
|
||||||
|
if (editor.get('toolbar')) {
|
||||||
|
editor.get('toolbar').titlebar = false;
|
||||||
|
}
|
||||||
|
editor.render();
|
||||||
|
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue