$(function() { $(".portletContainer").sortable({ disabled: true, connectWith: '.portletContainer' }); $(".portletContainer").addClass("ui-widget ui-widget-content") .find(".portlet-header") .addClass("ui-widget-header ui-corner-all") .prepend('', '', '') .end() .find(".portlet-content"); $(".portletSidebar").addClass("ui-widget ui-widget-content") .find(".portlet-header") .addClass("ui-widget-header ui-corner-all") .prepend('') .end() .find(".portlet-content"); $(".portletContainer_minimized_only").addClass("ui-widget ui-widget-content") .find(".portlet-header") .addClass("ui-widget-header ui-corner-all") .prepend('') .end() .find(".portlet-content"); $(".portletContainer_noIcon").addClass("ui-widget ui-widget-content") .find(".portlet-header") .addClass("ui-widget-header ui-corner-all") .prepend('') .end() .find(".portlet-content"); setIconMin( $(".portlet-header .ui-icon-minimize") ); setIconPrint( $(".portlet-header .ui-icon-print") ); setIconSave( $(".portlet-header .ui-icon-save") ); //$(".portletContainer").disableSelection(); }); function setIconMin(obj){ $(obj).click(function() { $(this).toggleClass("ui-icon-minimize").toggleClass("ui-icon-maximize"); $(this).parents(".portlet:first").find(".portlet-content").toggle(); }); } function setIconPrint(obj){ $(obj).click(portletPrint); } /* * added ajaxButtonLog("PORTLET_PRINT"); by BCT * */ function portletPrint(){ if (isLogin){ ajaxButtonLog("PORTLET_PRINT"); } getSavePrintComponent($(this), "PRINT"); } function setIconSave(obj){ $(obj).click(portletSave); } /* * added ajaxButtonLog("PORTLET_SAVE"); by BCT * */ function portletSave(){ if (isLogin){ ajaxButtonLog("PORTLET_SAVE"); } getSavePrintComponent($(this),"SAVE"); } function getSavePrintComponent(obj,actionType){ var portlet = obj.parents(".portlet:first"); if ( portlet.length == 0 ){ portlet = $("body").find(".portlet:first"); } var title = encodeURI(portlet.find(".portlet-header").text()); var content = portlet.find(".portlet-content").formhtml(); content = content.replace(/\+/g, "%2B"); content = encodeURI(content); cssNames = encodeURI(additionCssList); var toDay = new Date(); win=window.open("about:blank","win"+toDay.getTime(),"toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no,height=500,width=1010"); // assign popup width as that of #wrapper in common.css.jsp createSavePrintFormAndSubmit(win.name, actionType, title, content, cssNames); //submitAndPopup(win,actionType, title, content, cssNames); } function createSavePrintFormAndSubmit(winName, actionType, title, content, cssNames){ var formObj = document.createElement('form'); $(formObj).attr("id", "savePrintForm"); $(formObj).attr("target", winName); $(formObj).attr("method", "post"); if (!isLogin){ $(formObj).attr("action","/bct/common/savePrintAjax.htm"); }else{ $(formObj).attr("action","/bct/common/savePrintUserAjax.htm"); } $(formObj).append(''); $(formObj).append(''); $(formObj).append(''); $(formObj).append(''); $(formObj).append(''); document.body.appendChild(formObj); $(formObj).submit(); formObj.parentNode.removeChild(formObj); } /* function submitAndPopup(win, actionType, title, content, cssNames){ win.document.write(''); win.document.write("Please wait..."); win.document.write(''); win.document.write('
'); if (!isLogin){ win.document.write('
'); }else{ win.document.write(''); } win.document.write(''); win.document.write(''); win.document.write(''); win.document.write(''); win.document.write(''); win.document.write('
'); win.document.write('
'); win.document.write(''); win.document.write(""); } */ /** * change the double quote to single quote */ function changeSpecialCharacter(str) { str=str.replace(/\"/g,"\'"); return str; } //================================================================ /** * fix Print & Save in firefox * firefix ignore the change in DOM */ (function($) { var oldHTML = $.fn.html; $.fn.formhtml = function() { if (arguments.length) return oldHTML.apply(this,arguments); $("input[type='text'],button", this).each(function() { this.setAttribute('value',changeSpecialCharacter(this.value)); }); $("textarea",this).each(function(){ if ( !$.browser.msie ){ this.setAttribute('value',changeSpecialCharacter(this.value)); this.innerHTML=this.value; } }); $(":radio,:checkbox", this).each(function() { // im not really even sure you need to do this for "checked" // but what the heck, better safe than sorry if (this.checked) this.setAttribute('checked', 'checked'); else this.removeAttribute('checked'); }); $("option", this).each(function() { // also not sure, but, better safe... if (this.selected) this.setAttribute('selected', 'selected'); else this.removeAttribute('selected'); }); return oldHTML.apply(this); }; //optional to override real .html() if you want // $.fn.html = $.fn.formhtml; })(jQuery);