123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356 |
-
- Namespace.register("U.Img");
- U.Img.Create = function (UDE, UI, UME, UCB) {
- U.M.StopBubble();
- return (new U.Img.Create.init(UDE, UI, UME, UCB)).Create();
- }
- U.Img.Create.init = function (UDE, UI, UME, UCB) {
-
- this.Iss;
- this.UIOD;
- this.BL;
- this.UIMG;
- this.W;
- this.h;
- this.R = 0;
- this.I = typeof UI == "number" ? UI : 0;
- this.UCB = UCB;
- this.CTF = true;
- this.AIMG = UDE;
- for (var i in UME) {
- if (UME.hasOwnProperty(i)) {
- this[i] = UME[i];
- }
- }
- }
- U.Img.Create.init.prototype = {
- ET: [],
-
- ImgT: function (UDE, UDID) {
- var i,
- _UDOD, _UDTD, _UDSD, _UDKD, _UDCD, _UDID,
- _UCE = [["放大", "UD_SYJDXB"], ["缩小", "UD_SYJDXS"], ["左转", "UD_SYJDXL"], ["右转", "UD_SYJDXR"]];
-
- if ((_UDOD = $("#" + UDID)[0])) {
- _UDID = $(_UDOD).childg(0)[0];
- _UDID = $(_UDID).Child()[2];
- _UDID = $("img", _UDID);
- $(_UDOD).Center();
- _UDID.length ? (_UDID = _UDID[0], _UDID.src = UDE["Thm"]) : (_UDTD.innerHTML = "",
- _UDCD = $$("div", { "className": "UD_SYJZO" }, _UDTD),
- _UDID = $$("img", { "onerror": U.M.apply(this, [[U.M.ImgError, ["this", 1]]]), "onselectstart": U.M.apply(), "ondragstart": U.M.apply(), "src": U.M.GetImgU(UDE["Thm"]) }, _UDCD));
- }
-
- else {
- _UDOD = $$("div", { "className": "UD_SYJ UD_SYJO", id: UDID, "onmousewheel": [[U.M.StopBubble], [this.Wheel, [this]]], "__size__": "false", "onmousedown": [[U.D.DragMouseDown, ["this"]]] });
- _UDTD = $$("div", { "className": "UD_SYJA" }, _UDOD);
- _UDSD = $$("div", { "className": "UD_SYJD", "onmousedown": U.M.StopBubble, "onclick": U.M.StopBubble }, _UDTD);
- _UDSD = $$("div", { "className": "UD_SYJDX" }, _UDSD); _UDSD = $$("div", { "className": "UD_SYJDXS" }, _UDSD);
- for (i = 0; i < _UCE.length; i++) {
- _UDKD = $$("div", { "className": "UD_SYJDXC", "style": i ? {} : { "margin": "0px" }, "title": _UCE[i][0], onclick: U.M.apply(this, [[i > 1 ? this.Rotate : this.Zoom, [i > 1 ? (i - 2) * 2 - 1 : (i ? "Out" : "In"), _UDOD, this]]]) }, _UDSD);
- if (!i) { _UDCD = $$("div", {}, _UDKD); $$("div", { "title": "回到原图", "innerHTML": " 100%", onclick: U.M.apply(this, [[this.Zoom, [100, _UDOD, this]]]) }, _UDKD); } else { _UDCD = _UDKD; }
- $$("div", { "className": "UD_SYI UD_SYJDXO " + _UCE[i][1] }, _UDCD);
- $$("div", { "className": "UD_SYJDXT", "title": "点击" + _UCE[i][0], "innerHTML": _UCE[i][0] }, _UDCD);
- }
- $$("div", { "className": "UD_SYJL UD_SYJLO UD_SYI", "onmousedown": U.M.StopBubble, "onclick": U.M.StopBubble }, _UDTD);
- _UDCD = $$("div", { "className": "UD_SYJZ", "onmousedown": U.M.StopBubble }, _UDTD); $$("div", { "className": "UD_SYJL UD_SYJRO UD_SYI", "onmousedown": U.M.StopBubble, "onclick": U.M.StopBubble }, _UDTD);
- _UDCD = $$("div", { "className": "UD_SYJZO" }, _UDCD); _UDID = $$("img", { "onerror": U.M.apply(this, [[U.M.ImgError, ["this", 1]]]), "onselectstart": U.M.apply(), "ondragstart": U.M.apply(), "src": U.M.GetImgU(UDE["Thm"]) }, _UDCD);
- $$("div", { "className": "UD_SYI UD_SYQC UD_SYQCT", style: { top: "0", right: "0" }, "title": "关闭", "onmousedown": U.M.StopBubble, "onclick": U.M.apply(this, [[this.Close, [null, this]]]) }, _UDOD);
- $(_UDOD).appendTo((this.parent || document.body)).Center();
- }
-
- return [(this.UIOD = _UDOD), (this.UIMG = _UDID)];
- },
-
- Create: function () {
- if (this.AIMG) {
-
- this.AIMG = this.AIMG.length != null ? this.AIMG : [this.AIMG];
- var _UIE = this.AIMG[this.I],
- _UDE = (this.UCB ? this.UCB(_UIE) : this.ImgT(_UIE, "Usestudio_Img"));
- this.R = 0;
- this.Iss = $(this.UIOD).attr("__size__") == "false";
-
- U.M.imgReady(U.M.GetImgU(_UIE["Img"]), U.M.apply(null, [[this.Ready, [_UDE[0], _UDE[1], this, _UIE]]]), U.M.apply(null, [[this.Load, [_UDE[0], _UDE[1], this, _UIE]]]), U.M.apply(this, [[this.Error, [_UIE["Img"]]]]));
- return this;
- }
- },
-
- XSI: function (UIOD, UT, UTF) {
- if (UT.CTF) { UT.Close(UIOD, UT, UTF); }
- UT.CTF = true;
- },
-
- Wheel: function (UT, UE) {
- UE = event || UE;
- var _UWD = UE.wheelDelta ? (UE.wheelDelta / 120) : (-(UE.detail || UE.deltaY) / 3), _UTF = _UWD > 0 ? "In" : "Out";
- UT.Zoom(_UTF, UT.UIOD, UT);
- },
-
- Change: function (UTF, UT, UCB) {
-
- UTF = UT.I + UTF;
- UT.I = UTF = (UTF < 0 || UTF >= UT.AIMG.length) ? ((UTF < 0) ? UT.AIMG.length - 1 : 0) : UTF;
-
- var _UIID = $(UT.UIMG).addAttrArray({ "src": UT.AIMG[UTF]["Thm"], "style": { "filter": "alpha(opacity=30)",
- "MozOpacity": "0.3", "Khtml-opacity": "0.3", "opacity": "0.3"
- }
- });
-
- UT.PJ("", "", UT.UIOD, UT.UIMG);
- UT.Rotate((UT.R = 0), UT.UIOD, UT);
-
- U.M.imgReady(UT.AIMG[UTF]["Img"], U.M.apply(null, [[UT.Ready, [UT.UIOD, _UIID[0], UT]]]),
- U.M.apply(null, [[UT.Load, [UT.UIOD, _UIID[0], UT]]]), U.M.apply(this, [[UT.Error]]));
- (UCB) && (U.M.apply(UT, UCB)());
- },
-
- Zoom: function (US, UIOD, UT) {
-
-
- var US,
- _UW,
- _UH,
- _UIMG = $(this.UIMG);
- ("Out,In".indexOf(US) > -1) && (US = US == "Out" ? this.BL * 0.8 : this.BL / 0.8);
- UT.W = UT.W || _UIMG[0].width; UT.H = UT.H || _UIMG[0].height;
- this.BL = US = Math.max(Math.min(300, US), 22);
- _UH = parseInt(UT.H * (US / 100)); _UW = parseInt(UT.W * (US / 100));
- _UIMG.addAttrArray({ "style": { "width": _UW + "px", "height": _UH + "px"} });
- UT.PJ(_UW, _UH, UIOD, _UIMG[0]);
- U.D.PopupWindow(UIOD);
- },
-
- PJ: function (UW, UH, UIOD, UIID) {
- var _UDPD = $(UIID).Parent();
-
- _UDPD.style.height = UH ? UH + "px" : "";
- _UDPD.style.width = UW ? UW + "px" : "";
-
- (!this.Iss) && (UIOD.style.width = _UDPD.style.width);
- (UH) && ($(_UDPD).css("marginTop", ((UH = (($(_UDPD).Parent().offsetHeight - UH) / 2)) > 0 ? UH : 0) + "px"));
- },
-
- Rotate: function (UV, UIOD, UT) {
-
- var _UIMG = $(UT.UIMG),
- _UDPD = _UIMG.Parent(),
- _UWH = [_UDPD.offsetWidth, _UDPD.offsetHeight];
- (UV) && (_UWH.reverse());
- UV = UT.R + UV; UV = UV >= 4 ? 0 : UV; UV = UV < 0 ? 3 : UV;
- UT.R = UV; _UWH[2] = UV % 2 ? ((_UWH[(UV - 1) / 2] / 2) + "px") : "center";
- _UIMG.addAttrArray({ style: {
- "filter": "Progid:DXImageTransform.Microsoft.BasicImage(Rotation=" + UV + ")",
- "transformOrigin": _UWH[2] + " " + _UWH[2], "WebkitTransform": "rotate(" + UV * 90 + "deg)",
- "MozTransform": "rotate(" + UV * 90 + "deg)",
- "transform": "rotate(" + UV * 90 + "deg)",
- "OTransform": "rotate(" + UV * 90 + "deg)"
- }
- });
- UT.PJ(_UWH[0], _UWH[1], UIOD, _UIMG[0]);
- U.D.PopupWindow(UIOD);
- },
-
- MoveScroll: function (UDOD, UT) {
- UDOD.setCapture();
- document.onmousemove = U.M.apply(UT, [[UT.Move, [UDOD, event.clientX, event.clientY, [UDOD.scrollTop, UDOD.scrollLeft], UT]]]);
- document.onmouseup = U.M.apply(UT, [[UT.Up, [UDOD]]]);
- },
-
- Move: function (UDOD, UX, UY, UTL, UT) {
- UT.CTF = false;
- $(UDOD).addAttrArray({
- "scrollTop": UTL[0] - (event.clientY - UY),
- "scrollLeft": UTL[1] - (event.clientX - UX)
- });
- },
-
- Up: function (UDOD) {
- UDOD.releaseCapture();
- document.onmousemove = document.onmouseup = null;
- },
-
- Download: function (FN) {
- FN = FN.replace(US.fs, "");
- U.Dk.RE.ODL(FN, "1473用户图片.jpg");
- },
-
- Close: function (UIOD, UT, UTF) {
- U.D.CloseWindow(UIOD || this.UIOD, UTF ? "remove" : false);
- this.ET.splice(this.ET.indexOf(UT), 1);
- },
-
- Ready: function (UIOD, UIID, T, UDE) {
- if (UIOD.style.display != "none" && (UDE && UDE["Thm"] == UIID.src || !UDE || !UDE["Thm"])) {
-
- $[UIID, UIID.parentNode].addAttrArray({ "style": { "width": this.width + "px", "height": this.height + "px"} });
- T.W = this.width;
- T.H = this.height;
-
- T.PJ(T.W, T.H, UIOD, UIID);
- U.D.PopupWindow(UIOD);
- return true;
- }
- else { return false; }
- },
-
- Load: function (UIOD, UIID, T, UDE) {
- if (this.src && UIOD.style.display != "none" && (UDE && UDE["Thm"] == UIID.src || !UDE || !UDE["Thm"])) {
- var _UDPD = $(UIID).Parent(),
- _UWH = this.Iss ? [_UDPD.offsetWidth, _UDPD.offsetHeight] : [US.Width, US.Height];
-
- $(UIID).addAttrArray({ "src": this.src, "style": { "MozOpacity": "1", "Khtml-opacity": "1", "opacity": "1", "filter": "alpha(opacity=100)"} });
- T.W = this.width;
- T.H = this.height;
- UIOD = $(UIOD);
- T.Zoom(Math.min(Math.min(T.W, _UWH[0]) / this.width, Math.min(T.H, _UWH[1]) / this.height) * 100, UIOD[0], T);
- UIOD.Center();
- }
- },
-
- Error: function (URL, ITF) {
- var UIOD;
- var _UIID = this.UIMG;
- ITF = ITF || 0;
- ITF++;
- if (ITF < 3 && this.TF == 2) {
- U.M.imgReady(URL + "?&n=" + ITF, U.M.apply(null, [[this.Ready, [this.UIOD, _UIID, this]]]),
- U.M.apply(null, [[this.Load, [this.UIOD, _UIID, this]]]), U.M.apply(this, [[this.Error, [URL, ITF]]]));
- }
- else {
- U.Alert("图片丢失");
- $(_UIID).css({ "width": "auto", "height": "auto" });
- U.M.ImgError(_UIID, (this.TF || 1));
- this.Zoom(100, this.UIOD, this);
- U.D.PopupWindow(this.UIOD)
- }
- }
- };
|