You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

691 lines
20 KiB

  1. /*
  2. Copyright (c) 2012-2017 Open Lab
  3. Permission is hereby granted, free of charge, to any person obtaining
  4. a copy of this software and associated documentation files (the
  5. "Software"), to deal in the Software without restriction, including
  6. without limitation the rights to use, copy, modify, merge, publish,
  7. distribute, sublicense, and/or sell copies of the Software, and to
  8. permit persons to whom the Software is furnished to do so, subject to
  9. the following conditions:
  10. The above copyright notice and this permission notice shall be
  11. included in all copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  13. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  14. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  15. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  16. LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  17. OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  18. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  19. */
  20. var muteAlertOnChange = false;
  21. // isRequired ----------------------------------------------------------------------------
  22. //return true if every mandatory field is filled and highlight empty ones
  23. jQuery.fn.isFullfilled = function () {
  24. var canSubmit = true;
  25. var firstErrorElement = "";
  26. this.each(function () {
  27. var theElement = $(this);
  28. theElement.removeClass("formElementsError");
  29. //if (theElement.val().trim().length == 0 || theElement.attr("invalid") == "true") { //robicch 13/2/15
  30. if (theElement.is("[required]") && theElement.val().trim().length == 0 || theElement.attr("invalid") == "true") {
  31. if (theElement.attr("type") == "hidden") {
  32. theElement = theElement.prevAll("#" + theElement.prop("id") + "_txt:first");
  33. } else if (theElement.is("[withTinyMCE]")){
  34. if (tinymce.activeEditor.getContent()=="")
  35. theElement=$("#"+theElement.attr("name")+"_tbl");
  36. else
  37. return true;// in order to continue the loop
  38. }
  39. theElement.addClass("formElementsError");
  40. canSubmit = false;
  41. if (firstErrorElement == "")
  42. firstErrorElement = theElement;
  43. }
  44. });
  45. if (!canSubmit) {
  46. // get the tabdiv
  47. var theTabDiv = firstErrorElement.closest(".tabBox");
  48. if (theTabDiv.length > 0)
  49. clickTab(theTabDiv.attr("tabId"));
  50. // highlight element
  51. firstErrorElement.effect("highlight", { color:"red" }, 1500);
  52. }
  53. return canSubmit;
  54. };
  55. function canSubmitForm(formOrId) {
  56. //console.debug("canSubmitForm",formOrId);
  57. if (typeof formOrId != "object")
  58. formOrId=$("#" + formOrId);
  59. return formOrId.find(":input[required],:input[invalid=true]").isFullfilled();
  60. }
  61. function showSavingMessage() {
  62. $("#savingMessage:hidden").fadeIn();
  63. $("body").addClass("waiting");
  64. $(window).resize();
  65. }
  66. function hideSavingMessage() {
  67. $("#savingMessage:visible").fadeOut();
  68. $("body").removeClass("waiting");
  69. $(window).resize();
  70. }
  71. /* Types Function */
  72. function isValidURL(url) {
  73. var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;
  74. return RegExp.test(url);
  75. }
  76. function isValidEmail(email) {
  77. //var RegExp = /^((([a-z]|[0-9]|!|#|$|%|&|'|\*|\+|\-|\/|=|\?|\^|_|`|\{|\||\}|~)+(\.([a-z]|[0-9]|!|#|$|%|&|'|\*|\+|\-|\/|=|\?|\^|_|`|\{|\||\}|~)+)*)@((((([a-z]|[0-9])([a-z]|[0-9]|\-){0,61}([a-z]|[0-9])\.))*([a-z]|[0-9])([a-z]|[0-9]|\-){0,61}([a-z]|[0-9])\.)[\w]{2,4}|(((([0-9]){1,3}\.){3}([0-9]){1,3}))|(\[((([0-9]){1,3}\.){3}([0-9]){1,3})\])))$/;
  78. var RegExp = /^.+@\S+\.\S+$/;
  79. return RegExp.test(email);
  80. }
  81. function isValidInteger(n) {
  82. reg = new RegExp("^[-+]{0,1}[0-9]*$");
  83. return reg.test(n) || isNumericExpression(n);
  84. }
  85. function isValidDouble(n) {
  86. var sep = Number.decimalSeparator;
  87. reg = new RegExp("^[-+]{0,1}[0-9]*[" + sep + "]{0,1}[0-9]*$");
  88. return reg.test(n) || isNumericExpression(n);
  89. }
  90. function isValidTime(n) {
  91. return !isNaN(millisFromHourMinute(n));
  92. }
  93. function isValidDurationDays(n) {
  94. return !isNaN(daysFromString(n));
  95. }
  96. function isValidDurationMillis(n) {
  97. return !isNaN(millisFromString(n));
  98. }
  99. function isNumericExpression(expr) {
  100. try {
  101. var a = eval(expr);
  102. return typeof(a) == 'number';
  103. } catch (t) {
  104. return false;
  105. }
  106. }
  107. function getNumericExpression(expr) {
  108. var ret;
  109. try {
  110. var a = eval(expr);
  111. if (typeof(a) == 'number')
  112. ret = a;
  113. } catch (t) {
  114. }
  115. return ret;
  116. }
  117. /*
  118. supports almost all Java currency format e.g.: ###,##0.00EUR €#,###.00 #,###.00€ -$#,###.00 $-#,###.00
  119. */
  120. function isValidCurrency(numStr) {
  121. //first try to convert format in a regex
  122. var regex = "";
  123. var format = Number.currencyFormat + "";
  124. var minusFound = false;
  125. var numFound = false;
  126. var currencyString = "";
  127. var numberRegex = "[0-9\\" + Number.groupingSeparator + "]+[\\" + Number.decimalSeparator + "]?[0-9]*";
  128. for (var i = 0; i < format.length; i++) {
  129. var ch = format.charAt(i);
  130. if (ch == "." || ch == "," || ch == "0") {
  131. //skip it
  132. if (currencyString != "") {
  133. regex = regex + "(?:" + RegExp.quote(currencyString) + ")?";
  134. currencyString = "";
  135. }
  136. } else if (ch == "#") {
  137. if (currencyString != "") {
  138. regex = regex + "(?:" + RegExp.quote(currencyString) + ")?";
  139. currencyString = "";
  140. }
  141. if (!numFound) {
  142. numFound = true;
  143. regex = regex + numberRegex;
  144. }
  145. } else if (ch == "-") {
  146. if (currencyString != "") {
  147. regex = regex + "(?:" + RegExp.quote(currencyString) + ")?";
  148. currencyString = "";
  149. }
  150. if (!minusFound) {
  151. minusFound = true;
  152. regex = regex + "[-]?";
  153. }
  154. } else {
  155. currencyString = currencyString + ch;
  156. }
  157. }
  158. if (!minusFound)
  159. regex = "[-]?" + regex;
  160. if (currencyString != "")
  161. regex = regex + "(?:" + RegExp.quote(currencyString) + ")?";
  162. regex = "^" + regex + "$";
  163. var rg = new RegExp(regex);
  164. return rg.test(numStr) || isNumericExpression(numStr);
  165. }
  166. function getCurrencyValue(numStr) {
  167. if (!isValidCurrency(numStr))
  168. return NaN;
  169. var ripul = numStr.replaceAll(Number.groupingSeparator, "").replaceAll(Number.decimalSeparator, ".");
  170. return getNumericExpression(ripul) || parseFloat(ripul.replace(/[^-0123456789.]/, ""));
  171. }
  172. function formatCurrency(numberString) {
  173. return formatNumber(numberString, Number.currencyFormat);
  174. }
  175. function formatNumber(numberString, format) {
  176. if (!format)
  177. format = "##0.00";
  178. var dec = Number.decimalSeparator;
  179. var group = Number.groupingSeparator;
  180. var neg = Number.minusSign;
  181. var round = true;
  182. var validFormat = "0#-,.";
  183. // strip all the invalid characters at the beginning and the end
  184. // of the format, and we'll stick them back on at the end
  185. // make a special case for the negative sign "-" though, so
  186. // we can have formats like -$23.32
  187. var prefix = "";
  188. var negativeInFront = false;
  189. for (var i = 0; i < format.length; i++) {
  190. if (validFormat.indexOf(format.charAt(i)) == -1) {
  191. prefix = prefix + format.charAt(i);
  192. } else {
  193. if (i == 0 && format.charAt(i) == '-') {
  194. negativeInFront = true;
  195. } else {
  196. break;
  197. }
  198. }
  199. }
  200. var suffix = "";
  201. for (var i = format.length - 1; i >= 0; i--) {
  202. if (validFormat.indexOf(format.charAt(i)) == -1)
  203. suffix = format.charAt(i) + suffix;
  204. else
  205. break;
  206. }
  207. format = format.substring(prefix.length);
  208. format = format.substring(0, format.length - suffix.length);
  209. // now we need to convert it into a number
  210. //while (numberString.indexOf(group) > -1)
  211. // numberString = numberString.replace(group, '');
  212. //var number = new Number(numberString.replace(dec, ".").replace(neg, "-"));
  213. var number = new Number(numberString);
  214. var forcedToZero = false;
  215. if (isNaN(number)) {
  216. number = 0;
  217. forcedToZero = true;
  218. }
  219. // special case for percentages
  220. if (suffix == "%")
  221. number = number * 100;
  222. var returnString = "";
  223. if (format.indexOf(".") > -1) {
  224. var decimalPortion = dec;
  225. var decimalFormat = format.substring(format.lastIndexOf(".") + 1);
  226. // round or truncate number as needed
  227. if (round)
  228. number = new Number(number.toFixed(decimalFormat.length));
  229. else {
  230. var numStr = number.toString();
  231. numStr = numStr.substring(0, numStr.lastIndexOf('.') + decimalFormat.length + 1);
  232. number = new Number(numStr);
  233. }
  234. var decimalValue = number % 1;
  235. var decimalString = new String(decimalValue.toFixed(decimalFormat.length));
  236. decimalString = decimalString.substring(decimalString.lastIndexOf(".") + 1);
  237. for (var i = 0; i < decimalFormat.length; i++) {
  238. if (decimalFormat.charAt(i) == '#' && decimalString.charAt(i) != '0') {
  239. decimalPortion += decimalString.charAt(i);
  240. } else if (decimalFormat.charAt(i) == '#' && decimalString.charAt(i) == '0') {
  241. var notParsed = decimalString.substring(i);
  242. if (notParsed.match('[1-9]')) {
  243. decimalPortion += decimalString.charAt(i);
  244. } else {
  245. break;
  246. }
  247. } else if (decimalFormat.charAt(i) == "0") {
  248. decimalPortion += decimalString.charAt(i);
  249. }
  250. }
  251. returnString += decimalPortion;
  252. } else {
  253. number = Math.round(number);
  254. }
  255. var ones = Math.floor(number);
  256. if (number < 0)
  257. ones = Math.ceil(number);
  258. var onesFormat = "";
  259. if (format.indexOf(".") == -1)
  260. onesFormat = format;
  261. else
  262. onesFormat = format.substring(0, format.indexOf("."));
  263. var onePortion = "";
  264. if (!(ones == 0 && onesFormat.substr(onesFormat.length - 1) == '#') || forcedToZero) {
  265. // find how many digits are in the group
  266. var oneText = new String(Math.abs(ones));
  267. var groupLength = 9999;
  268. if (onesFormat.lastIndexOf(",") != -1)
  269. groupLength = onesFormat.length - onesFormat.lastIndexOf(",") - 1;
  270. var groupCount = 0;
  271. for (var i = oneText.length - 1; i > -1; i--) {
  272. onePortion = oneText.charAt(i) + onePortion;
  273. groupCount++;
  274. if (groupCount == groupLength && i != 0) {
  275. onePortion = group + onePortion;
  276. groupCount = 0;
  277. }
  278. }
  279. // account for any pre-data padding
  280. if (onesFormat.length > onePortion.length) {
  281. var padStart = onesFormat.indexOf('0');
  282. if (padStart != -1) {
  283. var padLen = onesFormat.length - padStart;
  284. // pad to left with 0's or group char
  285. var pos = onesFormat.length - onePortion.length - 1;
  286. while (onePortion.length < padLen) {
  287. var padChar = onesFormat.charAt(pos);
  288. // replace with real group char if needed
  289. if (padChar == ',')
  290. padChar = group;
  291. onePortion = padChar + onePortion;
  292. pos--;
  293. }
  294. }
  295. }
  296. }
  297. if (!onePortion && onesFormat.indexOf('0', onesFormat.length - 1) !== -1)
  298. onePortion = '0';
  299. returnString = onePortion + returnString;
  300. // handle special case where negative is in front of the invalid characters
  301. if (number < 0 && negativeInFront && prefix.length > 0)
  302. prefix = neg + prefix;
  303. else if (number < 0)
  304. returnString = neg + returnString;
  305. if (returnString.lastIndexOf(dec) == returnString.length - 1) {
  306. returnString = returnString.substring(0, returnString.length - 1);
  307. }
  308. returnString = prefix + returnString + suffix;
  309. return returnString;
  310. }
  311. //validation functions - used by textfield and datefield
  312. jQuery.fn.validateField = function () {
  313. var isValid = true;
  314. this.each(function () {
  315. var el = $(this);
  316. el.clearErrorAlert();
  317. var value = el.val();
  318. if (value) {
  319. var rett = true;
  320. var type = (el.attr('entryType')+"").toUpperCase();
  321. var errParam;
  322. if (type == "INTEGER") {
  323. rett = isValidInteger(value);
  324. } else if (type == "DOUBLE") {
  325. rett = isValidDouble(value);
  326. } else if (type == "PERCENTILE") {
  327. rett = isValidDouble(value);
  328. } else if (type == "URL") {
  329. rett = isValidURL(value);
  330. } else if (type == "EMAIL") {
  331. rett = isValidEmail(value);
  332. } else if (type == "DURATIONMILLIS") {
  333. rett = isValidDurationMillis(value);
  334. } else if (type == "DURATIONDAYS") {
  335. rett = isValidDurationDays(value);
  336. } else if (type == "DATE") {
  337. rett = Date.isValid(value, el.attr("format"), true);
  338. if (!rett)
  339. errParam = el.attr("format");
  340. } else if (type == "TIME") {
  341. rett = isValidTime(value);
  342. } else if (type == "CURRENCY") {
  343. rett = isValidCurrency(value);
  344. }
  345. if (!rett) {
  346. el.createErrorAlert(i18n.ERROR_ON_FIELD, i18n.INVALID_DATA + (errParam ? " " + errParam : ""));
  347. isValid=false;
  348. }
  349. //check limits minValue : maxValue
  350. if (rett && (el.attr("minValue") || el.attr("maxValue"))){
  351. var val=value;
  352. var min=el.attr("minValue");
  353. var max=el.attr("maxValue");
  354. if (type == "INTEGER") {
  355. val=parseInt(value);
  356. min=parseInt(min);
  357. max=parseInt(max);
  358. } else if (type == "DOUBLE" || type == "PERCENTILE") {
  359. val=parseDouble(value);
  360. min=parseDouble(min);
  361. max=parseDouble(max);
  362. } else if (type == "URL") {
  363. val=value;
  364. } else if (type == "EMAIL") {
  365. val=value;
  366. } else if (type == "DURATIONMILLIS") {
  367. val=millisFromString(value);
  368. min=millisFromString(min);
  369. max=millisFromString(max);
  370. } else if (type == "DURATIONDAYS") {
  371. val=daysFromString(value);
  372. min=daysFromString(min);
  373. max=daysFromString(max);
  374. } else if (type == "DATE") {
  375. val=Date.parseString(value, el.attr("format"),true).getTime();
  376. min=Date.parseString(min, el.attr("format"),true).getTime();
  377. max=Date.parseString(max, el.attr("format"),true).getTime();
  378. } else if (type == "TIME") {
  379. val = millisFromHourMinute(value);
  380. min = millisFromHourMinute(min);
  381. max = millisFromHourMinute(max);
  382. } else if (type == "CURRENCY") {
  383. val=getCurrencyValue(value);
  384. min=getCurrencyValue(min);
  385. max=getCurrencyValue(max);
  386. }
  387. if (el.attr("minValue") && val<min){
  388. el.createErrorAlert(i18n.ERROR_ON_FIELD, i18n.OUT_OF_BOUDARIES + " ("+el.attr("minValue")+" : "+(el.attr("maxValue")?el.attr("maxValue"):"--")+")");
  389. rett=false;
  390. isValid=false;
  391. $("body").trigger("error");
  392. }
  393. if (rett && el.attr("maxValue") && val>max){
  394. el.createErrorAlert(i18n.ERROR_ON_FIELD, i18n.OUT_OF_BOUDARIES + " ("+(el.attr("minValue")?el.attr("minValue"):"--")+" : "+el.attr("maxValue")+")");
  395. rett=false;
  396. isValid=false;
  397. }
  398. }
  399. }
  400. });
  401. return isValid;
  402. };
  403. jQuery.fn.clearErrorAlert = function () {
  404. this.each(function () {
  405. var el = $(this);
  406. el.removeAttr("invalid").removeClass("formElementsError");
  407. $("#" + el.prop("id") + "error").remove();
  408. });
  409. return this;
  410. };
  411. jQuery.fn.createErrorAlert = function (errorCode, message) {
  412. this.each(function () {
  413. var el = $(this);
  414. el.attr("invalid", "true").addClass("formElementsError");
  415. if ($("#" + el.prop("id") + "error").length <= 0) {
  416. var errMess = (errorCode ? errorCode : "") + ": " + (message ? message : "");
  417. var err = "<span class='formElementExclamation' id=\"" + el.prop("id") + "error\" error='1'";
  418. err += " onclick=\"alert($(this).attr('title'))\" border='0' align='absmiddle'>&nbsp;";
  419. err += "</span>\n";
  420. err = $(err);
  421. err.prop("title", errMess);
  422. el.after(err);
  423. }
  424. });
  425. return this;
  426. };
  427. // button submit support BEGIN ------------------
  428. function saveFormValues(idForm) {
  429. var formx = obj(idForm);
  430. formx.setAttribute("savedAction", formx.action);
  431. formx.setAttribute("savedTarget", formx.target);
  432. var el = formx.elements;
  433. for (i = 0; i < el.length; i++) {
  434. if (el[i].getAttribute("savedValue") != null) {
  435. el[i].setAttribute("savedValue", el[i].value);
  436. }
  437. }
  438. }
  439. function restoreFormValues(idForm) {
  440. var formx = obj(idForm);
  441. formx.action = formx.getAttribute("savedAction");
  442. formx.target = formx.getAttribute("savedTarget");
  443. var el = formx.elements;
  444. for (i = 0; i < el.length; i++) {
  445. if (el[i].getAttribute("savedValue") != null) {
  446. el[i].value = el[i].getAttribute("savedValue");
  447. }
  448. }
  449. }
  450. function changeActionAndSubmit(action,command){
  451. var f=$("form:first");
  452. f.prop("action",action);
  453. f.find("[name=CM]").val(command);
  454. f.submit();
  455. }
  456. // textarea limit size -------------------------------------------------
  457. function limitSize(ob) {
  458. if (ob.getAttribute("maxlength")) {
  459. var ml =parseInt(ob.getAttribute("maxlength"));
  460. var val = ob.value;//.replace(/\r\n/g,"\n");
  461. if (val.length > ml) {
  462. ob.value = val.substr(0, ml);
  463. $(ob).createErrorAlert("Error",i18n.ERR_FIELD_MAX_SIZE_EXCEEDED);
  464. } else {
  465. $(ob).clearErrorAlert();
  466. }
  467. }
  468. return true;
  469. }
  470. // verify before unload BEGIN ----------------------------------------------------------------------------
  471. function alertOnUnload(container) {
  472. //console.debug("alertOnUnload",container,muteAlertOnChange);
  473. if (!muteAlertOnChange) {
  474. //first try to call a function eventually defined on the page
  475. if (typeof(managePageUnload) == "function")
  476. managePageUnload();
  477. container=container||$("body");
  478. var inps= $("[alertonchange=true]",container).find("[oldValue=1]");
  479. for (var j = 0; j < inps.length; j++) {
  480. var anInput = inps.eq(j);
  481. //console.debug(j,anInput,anInput.isValueChanged())
  482. var oldValue = anInput.getOldValue() + "";
  483. if (!('true' == '' + anInput.attr('excludeFromAlert'))) {
  484. if (anInput.attr("maleficoTiny")) {
  485. if (tinymce.EditorManager.get(anInput.prop("id")).isDirty()) {
  486. return i18n.FORM_IS_CHANGED + " \"" + anInput.prop("name") + "\"";
  487. }
  488. } else if (anInput.isValueChanged()) {
  489. var inputLabel = $("label[for='" + anInput.prop("id") + "']").text(); //use label element
  490. inputLabel = inputLabel ? inputLabel : anInput.prop("name");
  491. return i18n.FORM_IS_CHANGED + " \"" + inputLabel + "\"";
  492. }
  493. }
  494. }
  495. }
  496. return undefined;
  497. }
  498. function canILeave(){
  499. var ret = window.onbeforeunload();
  500. if (typeof(ret)!="undefined" && !confirm(ret+" \n"+i18n.PROCEED))
  501. return false;
  502. else
  503. return true;
  504. }
  505. // ---------------------------------- oldvalues management
  506. // update all values selected
  507. jQuery.fn.updateOldValue = function () {
  508. this.each(function () {
  509. var el = $(this);
  510. var val=(el.is(":checkbox,:radio")?el.prop("checked"):el.val())+"";
  511. el.data("_oldvalue", val);
  512. });
  513. return this;
  514. };
  515. // return true if at least one element has changed
  516. jQuery.fn.isValueChanged = function () {
  517. var ret = false;
  518. this.each(function () {
  519. var el = $(this);
  520. var val=(el.is(":checkbox,:radio")?el.prop("checked"):el.val())+"";
  521. if (val != el.data("_oldvalue") + "") {
  522. //console.debug("io sono diverso "+el.prop("id")+ " :"+el.val()+" != "+el.data("_oldvalue"));
  523. ret = true;
  524. return false;
  525. }
  526. });
  527. return ret;
  528. };
  529. jQuery.fn.getOldValue = function () {
  530. return $(this).data("_oldvalue");
  531. };
  532. jQuery.fn.fillJsonWithInputValues = function (jsonObject) {
  533. var inputs = this.find(":input");
  534. $.each(inputs.serializeArray(),function(){
  535. if (this.name) {
  536. jsonObject[this.name] = this.value;
  537. }
  538. });
  539. inputs.filter(":checkbox[name]").each(function () {
  540. var el = $(this);
  541. jsonObject[el.attr("name")] = el.is(":checked") ? "yes" : "no";
  542. })
  543. return this;
  544. };
  545. function enlargeTextArea(immediate) {
  546. //console.debug("enlargeTextArea",immediate);
  547. var el = $(this);
  548. var delay=immediate===true?1:300;
  549. el.stopTime("taResizeApply");
  550. el.oneTime(delay,"taResizeApply",function(){
  551. var miH = el.is("[minHeight]") ? parseInt(el.attr("minHeight")) : 30;
  552. var maH = el.is("[maxHeight]") ? parseInt(el.attr("maxHeight")) : 400;
  553. var inc = el.is("[lineHeight]") ? parseInt(el.attr("lineHeight")) : 30;
  554. //si copiano nel css per sicurezza
  555. el.css({maxHeight:maH,minHeight:miH});
  556. var domEl = el.get(0);
  557. var pad = el.outerHeight()-el.height();
  558. //devo allargare
  559. if (domEl.scrollHeight>el.outerHeight() && el.outerHeight()<maH){
  560. var nh=domEl.scrollHeight-pad + inc;
  561. nh=nh>maH-pad?maH-pad:nh;
  562. el.height(nh);
  563. } else if (el.height()>miH){
  564. //devo stringere
  565. el.height(el.height()-inc);
  566. while(el.outerHeight()-domEl.scrollHeight > 0 && el.height()>miH){
  567. el.height(el.height()-inc);
  568. }
  569. var newH=domEl.scrollHeight-pad +inc;
  570. //newH=newH<minH?minH:newH;
  571. el.height(newH);
  572. }
  573. el.stopTime("winResize");
  574. });
  575. }