* master: (127 commits) Prefill in the email address in the ITransact credentials form from the user's Shop address. fixed Matrix best/worst rated lists Fix bad form variable for phone number in EMS Badge address info. - Added a switch to allow the use of non-WebGUI objects with the Workflow fixing a problem with previous survey fix fixed #9671: Survey - breaks admin bar fixed a Matrix sql problem i18n the image labels and title for the asset manager, manage screen. Prevent an imported package from changing the a current asset's status from pending to anything else. Remove trailing comma in Shop/Transaction JS so IE6 works. fixed documentation fixed a bug when a matrix listing didn't have a forum attached small char encoding fix to merged upgrade fix small issue in addChild adding merge point Fix a problem with purging an EMS. Update this template so that it passes the template i18n test. Fix a broken i18n label in answer edit template for the Survey. Unify all Survey CSS into 1 file, and use it. Adding/fixing Survey i18n and Help ... Conflicts: lib/WebGUI/Asset/Wobject/Survey.pm lib/WebGUI/Asset/Wobject/Survey/ResponseJSON.pm lib/WebGUI/i18n/English/Asset_Survey.pm www/extras/wobject/Survey/editsurvey/object.js
127 lines
4.3 KiB
JavaScript
127 lines
4.3 KiB
JavaScript
|
|
/*global Survey, YAHOO */
|
|
if (typeof Survey === "undefined") {
|
|
var Survey = {};
|
|
}
|
|
|
|
Survey.ObjectTemplate = (function(){
|
|
|
|
// Keep references to widgets here so that we can destory any instances before
|
|
// creating new ones (to avoid memory leaks)
|
|
var dialog;
|
|
var editor;
|
|
|
|
return {
|
|
|
|
unloadObject: function(){
|
|
// First destory the editor..
|
|
if (editor) {
|
|
editor.destroy();
|
|
editor = null;
|
|
}
|
|
|
|
// And then the Dialog that contains it.
|
|
if (dialog) {
|
|
dialog.destroy();
|
|
dialog = null;
|
|
}
|
|
},
|
|
|
|
loadObject: function(html, type){
|
|
// Make sure we purge any event listeners before overwrite innerHTML..
|
|
YAHOO.util.Event.purgeElement('edit', true);
|
|
document.getElementById('edit').innerHTML = html;
|
|
|
|
var btns = [{
|
|
text: "Submit",
|
|
handler: function(){
|
|
editor.saveHTML();
|
|
this.submit();
|
|
},
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
}];
|
|
|
|
dialog = new YAHOO.widget.Dialog(type, {
|
|
width: "600px",
|
|
context: [document.body, 'tr', 'tr'],
|
|
visible: false,
|
|
constraintoviewport: true,
|
|
buttons: btns
|
|
});
|
|
|
|
dialog.callback = Survey.Comm.callback;
|
|
dialog.render();
|
|
|
|
if(type == 'question'){
|
|
var resize = new YAHOO.util.Resize('resize_randomWords_formId');
|
|
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'){
|
|
var resize = new YAHOO.util.Resize('resize_gotoExpression_formId');
|
|
resize.on('resize', function(ev) {
|
|
YAHOO.util.Dom.setStyle('gotoExpression_formId', 'width', (ev.width - 6) + "px");
|
|
YAHOO.util.Dom.setStyle('gotoExpression_formId', 'height', (ev.height - 6) + "px");
|
|
});
|
|
}
|
|
|
|
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();
|
|
initHoverHelp(type);
|
|
}
|
|
};
|
|
})();
|