Changeset 18975 for extensions/Autosize/js/Affiche_script.js
- Timestamp:
- Nov 8, 2012, 1:59:34 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Autosize/js/Affiche_script.js
r18949 r18975 246 246 } 247 247 } 248 Affiche_limite(pictureSelType_user); 249 jQuery("#derivativeChecked" + options.pictureDeriv).css({ visibility: 'visible' }); 248 250 249 251 } … … 438 440 jQuery(window).resize(function (event, ui) { 439 441 Autosize_resize(true, options); 440 441 return;442 443 444 445 442 }); 446 443 //_____________ widow.resize _______________ … … 457 454 marges_llgbo = 0; 458 455 //========================================================================================== 459 if (options.valide) { 460 461 init_gen(); 462 463 464 } 456 init_gen(); 457 465 458 466 459 }); … … 502 495 503 496 options = jQuery.extend(defaults, options); 504 505 506 for (i = 0; i < options.liste_type.length; i++) {507 options.liste_type[i] = options.liste_type[i].split(",");508 }509 510 497 options.theMainImageWidth = options.theMainImageWidth; 511 498 options.theMainImageHeight = options.theMainImageHeight; 512 499 jQuery("#the_page").append("<div id='form_autosize_picture' ></div>"); 513 500 jQuery("#form_autosize_picture").addClass("Autosize"); 514 501 //===== marges suplémentaires en fonction theme === 515 502 options.valide = jQuery(".Autosize").css("display") != "none"; 516 517 503 options.marge_haute = jQuery(".Autosize").Get_Val_int(jQuery(".Autosize").css("top")); 518 504 options.marge_basse = jQuery(".Autosize").Get_Val_int(jQuery(".Autosize").css("bottom")); 519 505 options.marge_gauche = jQuery(".Autosize").Get_Val_int(jQuery(".Autosize").css("left")); 520 506 options.marge_droite = jQuery(".Autosize").Get_Val_int(jQuery(".Autosize").css("right")); 507 jQuery(".Autosize").hide(); 508 521 509 fade_in = options.fade_in || 0; 522 510 imageComment_id = ".imageComment"; … … 546 534 var useMap = options.pictureMap; // #mapxxx 547 535 var user_status = options.user_status; 536 var chk = eval("options." + user_status + "_enabled"); 537 if (chk == "") { options.valide = false; } 548 538 549 539 var pictureDeriv = options.pictureDeriv; // xxx 550 540 var pictureSelType_user = eval("options." + user_status + "_type"); //limite taille 541 551 542 if (Type_Img == "pamoorama") 552 543 options.pictureSelType = "Autosize"; … … 566 557 } 567 558 568 559 for (i = 0; i < options.liste_type.length; i++) { 560 options.liste_type[i] = options.liste_type[i].split(","); 561 } 562 563 564 // auto_details 565 //==== limite affichage selection = select_type ==== 566 var path_names = new Array(); 567 568 Affiche_limite = function (pictureSelType_Maxi) { 569 n = 0; 570 var pt = new Array(); 571 path_names = new Array(); 572 jQuery("#derivativeSwitchBox a").css('visibility', 'hidden'); 573 jQuery(".switchCheck").css('visibility', 'hidden'); 574 var maxi_display = false; 575 jQuery("#derivativeSwitchBox a").each(function (i) { 576 href_path = jQuery(this).attr("href"); 577 patname = href_path.replace("javascript\:", ""); 578 path_names.push(patname); 579 pt[i] = href_path.split("','"); 580 tsz = pt[i][2].replace("')", ""); 581 if (!maxi_display) 582 jQuery(this).css('visibility', 'visible'); 583 else { 584 jQuery(this).next().next().remove(); 585 jQuery(this).next().remove(); 586 jQuery(this).remove(); 587 } 588 //--- recherche limite --- 589 590 if (!options.valide && (tsz == "Autosize" || tsz == "SelMaxi")) { 591 jQuery(this).next().next().remove(); 592 jQuery(this).next().remove(); 593 jQuery(this).remove(); 594 } else { 595 if (tsz == "Original" && (pictureSelType_Maxi != "Autosize" && pictureSelType_Maxi != "SelMaxi")) { 596 maxi_display = true; 597 } 598 if (tsz == pictureSelType_Maxi && (pictureSelType_Maxi != "Autosize" && pictureSelType_Maxi != "SelMaxi")) { 599 maxi_display = true; 600 601 } 602 603 } 604 //--- type en cours --- 605 if (tsz.match(RegExp("^" + options.pictureDeriv, "gi"))) { 606 us = n; 607 } 608 609 n++; 610 }); 611 } 569 612 //============================================================= 570 613 // REPONSE ACTION … … 715 758 if (typeof decode_href != 'function') { 716 759 function decode_href(myObj) { 717 href_path = jQuery(myObj).attr("href"); 718 pt = href_path.split("("); 719 pt = pt[1].split(")"); 720 pt = pt[0].replace(RegExp("'", "g"), ""); 760 hrefPath = jQuery(myObj).attr("href"); 761 if (hrefPath.indexOf("changeImg") == 0) { 762 pt = hrefPath; 763 } else { 764 pt = hrefPath.split("("); 765 pt = pt[1].split(")"); 766 pt = pt[0].replace(RegExp("'", "g"), ""); 767 } 721 768 pt = pt.replace(RegExp(" ", "g"), ""); 722 769 pt = pt.split(","); 723 770 source = pt[0]; 771 724 772 pictureDeriv = pt[1]; 725 773 pictureMap = pt[2]; … … 738 786 739 787 jQuery("#derivativeSwitchBox a").click(function (e) { 788 Affiche_limite(pictureSelType_user); 740 789 retour = decode_href(this); 741 790 theImg = document.getElementById(theMainImage_id.replace("#", "")); … … 750 799 n = Get_dimensions(true, options); 751 800 } else { 801 752 802 } 753 803 … … 812 862 ***************************/ 813 863 Autosize_resize = function (force, parametres) { 814 n = Get_dimensions(true, options);815 if (n == false) return; 864 nAuto = Get_dimensions(true, options); 865 816 866 Save_cookies(options); 817 if (options.pictureSelType != "Autosize" && options.pictureSelType != "SelMaxi") { 818 /**/ 867 if (!options.valide || nAuto == false || (options.pictureSelType != "Autosize" && options.pictureSelType != "SelMaxi")) { 819 868 jQuery(theImg).width(Zone_image.image_init.width); 820 869 jQuery(theImg).height(Zone_image.image_init.height); 821 822 870 set_cl("no"); 823 871 Set_llbgo(true); … … 892 940 jQuery("#theMainImage").height(png_h); 893 941 jQuery("#" + Type_Img).height(png_h); 894 942 895 943 896 944 } else { … … 922 970 if (url.match(RegExp("i.php", "gi"))) { 923 971 urls = url.split("?"); 972 urls = urls[1].split("?"); 973 // Set_images(urls); 974 924 975 } 925 976 } … … 947 998 options.pictureDeriv = typeSave; 948 999 document.cookie = 'picture_deriv=' + typeSave + ';path=' + COOKIE_PATH; 949 950 951 952 jQuery("#theMainImage").removeAttr("width height") .attr("src", url)1000 jQuery("#theMainImage").attr("src", url); 1001 1002 // jQuery("#theMainImage," + theMainImage_id + ",.preload, .next1 , ") 1003 jQuery("#theMainImage").removeAttr("width height") 953 1004 .load(function (i) { 954 1005 if (!init_img(this)) { … … 958 1009 959 1010 }) 960 .live("ON", function (e) { 961 theMainImage_st = this.complete; 1011 .error(function (e) { 962 1012 imgsrc = this.src; 963 // alert(this.src + ' Image does not exist !!'); 964 }).error(function (i) { 965 imgsrc = this.src; 966 }); 967 /*********************** 968 * 969 **********************/ 970 jQuery("#theMainImage," + theMainImage_id + ",.preload, .next1 , ") 971 .error(function (e) { 972 if (!this.complete) { 973 // le fichier n'est pas present 974 src = jQuery(this).attr("src").replace("./_data/i/", "", 1); 975 src = this.src.split("/_data/i")[1]; 976 url = 'i.php?' + src + "&ajaxload=true"; 977 jQuery(theMainImage_id).attr("src", url); 978 /* 979 jQuery.ajax({ 980 type: 'GET', 981 url: 'i.php?' + src + "&ajaxload=true", 982 dataType: 'json', 983 success: (function (data) { 984 j = data.url; 985 // jQuery(theMainImage_id).attr("src", data.url); 1013 if (!this.complete) { 1014 // le fichier n'est pas present 1015 imgsrc = jQuery(this).attr("src"); 1016 1017 return false; 1018 1019 imgsrc = jQuery(this).attr("src").replace("./_data/i/", "", 1); 1020 imgsrc = this.src.split("/_data/i")[1]; 1021 if (typeof imgsrc == "undefined") return false; 1022 url = 'i.php?' + imgsrc + "&ajaxload=true"; 1023 jQuery(theMainImage_id).attr("src", url); 1024 // getDerivativeUrls(imgsrc); 1025 } 1026 1027 }) 1028 .live("Success", function (e) { 1029 if (typeof imageInfos_id == "undefined") return false; 1030 }) 1031 1032 .live("Error", function (data) { 1033 if (typeof imageInfos_id == "undefined") return; 1034 1035 }) 1036 .live("fail", function (data) { 1037 if (typeof imageInfos_id == "undefined") return; 986 1038 987 1039 }) 988 989 }); 990 */ 991 992 993 994 } 1040 .live("Progress", function (data) { 1041 if (typeof imageInfos_id == "undefined") return; 1042 1043 }) 1044 .live("IsRejected", function (data) { 1045 if (typeof imageInfos_id == "undefined") return; 1046 1047 }) 1048 .live("Finish", function (e, data) { 1049 if (typeof imageInfos_id == "undefined") return; 995 1050 996 1051 }) 997 . bind("Finish", function (e, data) {998 if (typeof imageInfos_id == "undefined") return;999 1052 .live("change", function (e) { 1053 theMainImage_st = this.complete; 1054 imgsrc = this.src; 1000 1055 }) 1001 .bind("ON", function (e, data) { 1002 if (data.status != "ok") { 1003 popup = jQuery(".errors"); 1004 if (popup.length == 0) { 1005 jQuery("#theImage").append("<div class='errors'><span></span></div>"); 1056 .live("Complete", function (e, data) { 1057 if (data.statusText != "OK") { 1058 popup = jQuery(".errors"); 1059 if (popup.length == 0) { 1060 jQuery("#theImage").append("<div class='errors'><span></span></div>"); 1061 } 1062 jQuery(".errors").text("Erreur : [" + data.done + "] " + data.src); 1063 jQuery(".errors").show().delay(10000).hide(2000); 1064 return; 1006 1065 } 1007 jQuery(".errors").text("Erreur : [" + data.done + "] " + data.responseText); 1008 jQuery(".errors").show().delay(10000).hide(2000); 1009 return; 1010 } 1011 if (data.src) { 1012 if (typeof imageInfos_id == "undefined") return; 1066 if (data.src) { } 1013 1067 if (options.pictureDeriv == "Original" && data.src.match(RegExp("\-.." + ".jpg", "gi"))) { 1014 1068 Autosize_resize(true, options); … … 1018 1072 1019 1073 } 1020 } 1021 }); 1074 type = options.pictureSelType; 1075 typeSave = options.pictureDeriv; 1076 jQuery('#derivativeSwitchBox .switchCheck').css('visibility', 'hidden'); 1077 if (typeof type != "undefined" && (type == "Autosize" || type == "SelMaxi")) { 1078 jQuery('#derivativeChecked' + type).css('visibility', 'visible'); 1079 } else { 1080 jQuery('#derivativeChecked' + typeSave).css('visibility', 'visible'); 1081 } 1082 1083 }); 1022 1084 //_________ theMainImage ___________ 1023 1085 … … 1100 1162 //__________________ Wait_pamoorama ______________________ 1101 1163 jQuery(".pwg-icon-clock-minus, .pwg-icon-clock-plus").click(function (i) { 1102 1103 1104 1105 1106 1164 1107 1165 }).mouseover(function (i) { … … 1290 1348 jQuery(pt).each(function (i) { 1291 1349 vn = this; 1292 size_derive = { w: parseInt(vn[2]), h: parseInt(vn[3]) }; 1293 if (vn[0] == options.pictureSelType || vn[0] == "Original") { 1350 v_pictureDeriv = vn[0]; v_imgSrc = vn[1]; v_width = parseInt(vn[2]); v_height = parseInt(vn[3]); 1351 size_derive = { w: v_width, h: v_height }; 1352 if (v_pictureDeriv == options.pictureSelType || v_pictureDeriv == "Original") { 1294 1353 maxi_size = size_derive; 1295 1354 maxi_size.idx = n; … … 1297 1356 } 1298 1357 1299 if (v n[0] != "square" && vn[0] != "thumb" && vn[0] != "SelMaxi" && vn[0]!= "Autosize") {1358 if (v_pictureDeriv != "square" && v_pictureDeriv != "thumb" && v_pictureDeriv != "SelMaxi" && v_pictureDeriv != "Autosize") { 1300 1359 if (size_derive.h > size_encours.h) { 1301 1360 if (maxi_size.idx < 0) { … … 1337 1396 last_id = this.id.replace("derivativeChecked", ""); 1338 1397 } 1339 if (last_id.match(RegExp(pictureDeriv, "gi"))) return false; 1398 if (last_id == pictureDeriv) 1399 return false; 1340 1400 }); 1341 1401 … … 1388 1448 identique = Zone_image.src.match(RegExp(imgSrc, "gi")); 1389 1449 if (identique) return; 1390 href_path = "javascript:changeImgSrc('" + imgSrc + "', '" + IMg.pictureDeriv + "', '" + IMg.pictureMap + "', '" + options.pictureSelType + "')"; 1450 href = get_href(IMg.pictureDeriv); 1451 href_path = "javascript:" + href; 1391 1452 jQuery(".linkAutosize").attr("href", href_path); 1392 1453 theImg = document.getElementById(theMainImage_id.replace("#", "")); … … 1398 1459 } else { 1399 1460 last_id = IMg.pictureDeriv; 1400 changeImgSrc(imgSrc, last_id, IMg.pictureMap, options.pictureSelType); 1461 eval(href); 1462 //changeImgSrc(imgSrc, last_id, IMg.pictureMap, options.pictureSelType); 1401 1463 } 1402 1464 … … 1421 1483 }; //_______________ Select_Image ______ 1422 1484 1485 get_href = function (NewpictureDeriv) { 1486 for (i = 0; i < path_names.length; i++) { 1487 newHref = path_names[i]; 1488 match = ",'" + NewpictureDeriv; 1489 newHref_ind = newHref.indexOf(match); 1490 if (newHref_ind > 0) { 1491 href = newHref; 1492 if (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi") { 1493 href = href.replace("')", "','" + options.pictureSelType + "')"); 1494 } 1495 break; 1496 } 1497 1498 } 1499 return href; 1500 }; 1423 1501 1424 1502 /************************************************* … … 1567 1645 marge_right = options.marge_right | 0; 1568 1646 marge_top = options.marge_top | 0; 1569 marge_bottom = options.marge_bottom | 0; 1647 1570 1648 1571 1649 //========================================================== … … 1615 1693 //========== Format Image ============== 1616 1694 retrait_img.height = Math.ceil(options.marges_llgbo || 0) 1617 + Math.ceil(infos_theMainImage.general.marges.height); 1695 + Math.ceil(infos_theMainImage.general.marges.height) + 1696 +Math.ceil(options.marges_llgbo || 0); 1618 1697 retrait_img.height += 2; 1619 1698 … … 1625 1704 retrait_img.width += 2; 1626 1705 if (!options.check_desc_v) 1627 marge_bottom= 0;1628 1706 options.marge_bottom_2 = 0; 1707 marge_bottom = options.marge_bottom_2 + options.marge_bottom; 1629 1708 //================== Limite Format Image ===================== 1630 1709 container.height_interne = container.height - marge_top - marge_bottom; … … 1702 1781 options.theImageLeft = new_dim.left; 1703 1782 options.theImageRight = (new_win.width - new_dim.right); 1704 options.marge_bottom = Math.ceil(new_dim.out.bottom - new_img.out.bottom);1783 options.marge_bottom_2 = Math.ceil(new_dim.out.bottom - new_img.out.bottom); 1705 1784 if (Type_Img == "iframe") { } 1706 new_dim.out.bottom = new_win.height - options.marge_bottom ;1785 new_dim.out.bottom = new_win.height - options.marge_bottom_2; 1707 1786 1708 1787 options.theImageBottom = new_win.height - new_dim.out.bottom; 1709 1788 options.marge_top = Math.ceil(new_img.top - new_dim.top); 1710 1789 1711 if (options.theImageBottom < 0) {1712 options.theImageBottom = 0;1790 if (options.theImageBottom_2 < 0) { 1791 options.theImageBottom_2 = 0; 1713 1792 } 1714 1793 options.theImageWidth = new_win.width - options.theImageLeft - options.theImageRight; 1715 1794 options.theImageHeight = new_win.height - options.marge_top - options.theImageBottom - options.theImageTop; 1716 var chk = eval("options." + user_status + "_enabled");1717 if (chk == "") { return; }1718 1795 1719 1796 if (Type_Img != "map" && Type_Img != "iframe") … … 1722 1799 Zone_image.src = infos_theMainImage.src; 1723 1800 useMap = options.pictureSelType; 1724 /*1725 if (useMap) {1726 if (!useMap.match(RegExp("Autosize", "gi"))) {1727 if (typeof img_height != "undefined") {1728 jQuery(theImg).height(img_height);1729 jQuery(theImg).width(img_width);1730 }1731 return;1732 }1733 }1734 1735 if (options.imageAutosize) {1736 return true; //stripped1737 }1738 1739 if (typeof options.cl_visible == "undefined") return;1740 if (!options.cl_visible == true) { return; }1741 */1742 1743 1801 //================================================================= 1744 1802 switch (Type_Img) { … … 1763 1821 case "img_autre": 1764 1822 if (!theMainImage_id) { 1765 if (DEBUG_autosize.match("true", gi)) alert("The_MainImage=null");1823 if (DEBUG_autosize.match("true", "gi")) alert("The_MainImage=null"); 1766 1824 return; 1767 1825 … … 1871 1929 1872 1930 options.marge_top = infos_theMainImage.top - infos_theImage.top; 1873 } else 1931 options.marge_bottom = Math.ceil(options.marge_basse + options.marge_top); 1932 1933 } else { 1874 1934 pos_top = infos_theImageAndInfos.top; 1935 options.marge_bottom = Math.ceil(options.marge_basse); 1936 } 1875 1937 1876 1938 options.pos_top = pos_top; … … 1878 1940 options.marge_right = infos_theImage.general.marges.right + Math.ceil(options.marge_droite); 1879 1941 options.marge_top += infos_theImage.general.marges.top + infos_content.general.marges.top + Math.ceil(options.marge_haute); 1880 options.marge_bottom = Math.ceil(options.marge_basse); // +infos_content.general.marges.bottom; ; 1942 1881 1943 if (options.pictureDeriv == null) 1882 1944 options.first = true; … … 1913 1975 pictureSelType = options.pictureSelType; 1914 1976 } 1977 Affiche_limite(pictureSelType_user); 1978 1915 1979 //=================== 2================================== 1916 href_path = "javascript:changeImgSrc('" + options.imgSrc + "', '" + options.pictureDeriv + "', '" + options.pictureDeriv + "', '" + "SelMaxi" + "')"; 1980 sav_p = options.pictureSelType; 1981 options.pictureSelType = "SelMaxi"; 1982 href = get_href(options.pictureDeriv); 1983 href_path = "javascript:" + href; 1984 1917 1985 spans = jQuery("#derivativeCheckedSelMaxi").next(); 1918 1986 spans.attr("href", href_path); … … 1922 1990 spans.text("(" + options.theMainImageWidth + " x " + options.theMainImageHeight + ")"); 1923 1991 //========================================================== 1924 href_path = "javascript:changeImgSrc('" + options.imgSrc + "', '" + options.pictureDeriv + "', '" + options.pictureDeriv + "', '" + "Autosize" + "')"; 1992 options.pictureSelType = "Autosize"; 1993 href = get_href(options.pictureDeriv); 1994 href_path = "javascript:" + href; 1925 1995 1926 1996 spans = jQuery("#derivativeCheckedAutosize").next(); … … 1931 2001 spans.text("(" + options.theMainImageWidth + " x " + options.theMainImageHeight + ")"); 1932 2002 //========================================================== 2003 options.pictureSelType = sav_p; 1933 2004 1934 2005 if (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi") { … … 1940 2011 Autosize_resize(true, options); 1941 2012 Autosize_resize(true, options); 2013 1942 2014 }; 1943 2015 //_______________________ init_gen _______________________ … … 2147 2219 2148 2220 2149 }); // ready 2221 }); // ready 2222 2150 2223 2151 2224
Note: See TracChangeset
for help on using the changeset viewer.