App_Part = { options: { 'btnId' : 'btnSubmit', 'addNewSetId' : 'addNewSet', 'newSetCurrent' : false }, init: function(params) { if (typeof params != 'undefined') { this.options = $.extend(this.options, params); } if (this.options.newSetCurrent) { $('#' + App_Part.options.addNewSetId).bind('click', function() { alert('Please note that you can\'t create new set unless you save the data for the current one'); }); } this.showFixedProcessAlert(); }, showFixedProcessAlert: function() { $('#' + this.options.formId + ' #' + this.options.btnId).bind('click', function(){ if (confirm(App_Part.options.message)) { $('#' + App_Part.options.formId).submit(); } return false; }); } }; App_Part_Administration = { 'isChangedSvg' : false, 'checkProcess' : null, options: { 'formSelector' : '#part-form', 'processElementSelector' : '#process-element', 'processNameSelector' : '#process-name', 'defaultProcessSelector' : '#defaultProcessId', 'notChangedSelector' : '#versionNotChanged-element', 'changedSelector' : '#versionChanged-element, #versionType-label, #versionType-element, #comments-label, #comments-element', 'submitGroupSelector': '#submitGroup-element', 'lockedElementSelector' : '#versionLocked-element' }, init: function(params) { var self = this; if (typeof params != 'undefined') { this.options = $.extend(this.options, params); } $(this.options.formSelector).change(function(){ self.formChanged(); }); this.checkingSvgChanges(); $(self.options.submitGroupSelector).hide(); App_Part_Administration.initDefaultProcess(); }, checkingSvgChanges: function() { var frame = document.getElementById('svgedit'); var canvas = null; var canvasOld = null; var self = this; if (frame) { this.checkProcess = setInterval(function(){ canvas = frame.contentWindow.svgCanvas.getSvgString(); if (canvas.length > 213 && canvasOld == null) { canvasOld = frame.contentWindow.svgCanvas.getSvgString(); } if (canvas && canvasOld && canvas != canvasOld) { self.formChanged(); } }, 500); } }, stopCheckingSvgChanges: function() { if (this.checkProcess) { clearInterval(this.checkProcess); } }, formChanged: function() { this.stopCheckingSvgChanges(); $(this.options.notChangedSelector).hide(); $(this.options.changedSelector).show(); $(this.options.submitGroupSelector).show(); var locked = ($(this.options.lockedElementSelector).length > 0) ? true : false; if (locked) { $('input#btnSubmit').remove(); } }, initDefaultProcess: function() { $(App_Part_Administration.options.processElementSelector + ' input').bind('change', function(){ var checkboxElements = []; $(App_Part_Administration.options.processElementSelector + ' input:checked').each(function(i, val){ checkboxElements[i] = $(val).attr('value'); }); var optionsHtml = ''; var oldValue = intval($(App_Part_Administration.options.defaultProcessSelector + ' option:selected').val()); for (var i in checkboxElements) { optionsHtml += ''; } $(App_Part_Administration.options.defaultProcessSelector).html(optionsHtml); $(App_Part_Administration.options.defaultProcessSelector + " [value='" + oldValue + "']").attr("selected", "selected"); }); $(App_Part_Administration.options.processElementSelector + ' input').change(); } }; function FCKeditor_OnComplete(editorInstance) { editorInstance.ResetIsDirty(); editorInstance.Events.AttachEvent('OnSelectionChange', function(editorInstance){ if (editorInstance.IsDirty()) { App_Part_Administration.formChanged(); } }); }