PluginProbe
Wp-Insert / 1.3.1
Wp-Insert v1.3.1
trunk 1.0 1.1 1.2 1.2.1 1.2.2 1.3.0 1.3.1 1.3.3 1.4 1.5.0 1.5.1 1.5.2 1.5.3 1.6.0 1.6.1 1.6.2 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 2.0 All 63 releases
wp-insert / js / common.js

common.js in Wp-Insert 1.3.1, at js/common.js

251 lines 7.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 function wpInsertToggleNotSavedAlert() {
2 document.getElementById("message").style.display = "block";
3 jQuery("#message").animate({opacity: 1, height: "100%"}, 1500);
4 }
5
6 function wpInsertToggleAdWidget(sender, pointerid) {
7 if(jQuery(sender).attr("value") == "Click to Activate") {
8 jQuery(pointerid).attr("checked", true);
9 jQuery(sender).animate({color: "red"}, 1500, "linear", function() { wpInsertToggleNotSavedAlert(); } );
10 jQuery(sender).attr("value", "Click to Deactivate");
11 }
12 else {
13 jQuery(pointerid).attr("checked", false);
14 jQuery(sender).animate({color: "#2f9303"}, 1500, "linear", function() { wpInsertToggleNotSavedAlert(); } );
15 jQuery(sender).attr("value", "Click to Activate");
16 }
17 }
18
19 /* PopUps */
20
21 //Code to find Y coordinates of any element starts here
22
23 function YPos(obj) {
24 var curtop = 0;
25 if (obj.offsetParent) {
26 while (1) {
27 curtop += obj.offsetTop;
28 if (!obj.offsetParent)
29 break;
30 obj = obj.offsetParent;
31 }
32 }
33 else if (obj.y) {
34 curtop += obj.y;
35 }
36 return curtop;
37 }
38
39 //Code to find Y coordinates of any element ends here
40
41 /****************************************/
42
43 //Code to find X coordinates of any element starts here
44
45 function XPos(obj) {
46 var curtop = 0;
47 if (obj.offsetParent) {
48 while (1) {
49 curtop += obj.offsetLeft;
50 if (!obj.offsetParent)
51 break;
52 obj = obj.offsetParent;
53 }
54 }
55 else if (obj.x) {
56 curtop += obj.x;
57 }
58 return curtop;
59 }
60
61 //Code to find X coordinates of any element ends here
62
63 //Code to find page Height/Width starts here
64
65 function GetPageHeight() {
66 if (window.innerHeight && window.scrollMaxY) {// Firefox
67 yWithScroll = window.innerHeight + window.scrollMaxY;
68 xWithScroll = window.innerWidth + window.scrollMaxX;
69 } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
70 yWithScroll = document.body.scrollHeight;
71 xWithScroll = document.body.scrollWidth;
72 } else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
73 yWithScroll = document.body.offsetHeight;
74 xWithScroll = document.body.offsetWidth;
75 }
76 return yWithScroll;
77
78 }
79
80 function GetPageWidth() {
81 var IE=document.all;
82 var iXPos;
83 if (!IE) {
84 iXPos = self.innerWidth;
85 }
86 else {
87 iXPos = (document.body.clientWidth);
88 }
89 return iXPos;
90 }
91
92 //Code to find page Height/Width starts here
93
94
95 function vIE() {
96 if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) { //test for MSIE x.x;
97 var ieversion = new Number(RegExp.jQuery1) // capture x.x portion and store as a number
98 return ieversion;
99 }
100 else
101 return 0; // this is for other browsers
102 }
103
104 function InitialisePopUP(width, height, ypos, xpos) {
105
106 if (width > 749) { alert('Please Use a smaller value for the Popup (less than 749)'); }
107 if (height > 540) { alert('Please Use a smaller value for the Popup (less than 540)'); }
108 jQuery("#popUpMaster").draggable({
109 containment: ['parent'],
110 effect: ['fade', 'fade']
111 });
112 var top;
113 var bottom;
114 var left;
115 var right;
116 var contentHeight;
117 var contentWidth;
118 left = height - 40;
119 right = left - 16;
120 top = width - 24;
121 bottom = top - 19;
122 contentWidth = top;
123 if (vIE()) {
124 right = left - 16;
125 contentHeight = height - 44;
126
127 if (vIE() >= 7) {
128 contentHeight = height - 46;
129 right = right;
130 bottom = bottom;
131 }
132 }
133 else if (vIE() == 0) {
134 contentHeight = height - 45;
135 right = right;
136 bottom = bottom;
137 }
138 jQuery("#popUpMaster").css('width', width);
139 jQuery("#popUpMaster").css('height', height);
140 jQuery("#popUpTop").css('width', top);
141 jQuery("#popUpLft").css('height', left);
142 jQuery("#popUpRgt").css('height', right);
143 jQuery("#popUpBtm").css('width', bottom);
144 jQuery("#content").css('width', contentWidth);
145 jQuery("#content").css('height', contentHeight);
146
147 jQuery("#popUpMaster").show();
148 jQuery("#popUpMaster").css('top', ypos);
149 jQuery("#popUpMaster").css('left', xpos);
150
151 if (vIE() == 6) {
152 jQuery('img[@srcjQuery=.png], div#popUpMaster').ifixpng();
153 }
154 }
155
156 function GreyOutScreen() {
157 var divGreyOut = document.createElement("div");
158 divGreyOut.id = "GreyOut";
159 divGreyOut.className = "GreyOutLayer";
160 divGreyOut.style.visibility = "visible";
161 divGreyOut.style.height = GetPageHeight().toString(10) + "px";
162 document.body.appendChild(divGreyOut);
163 }
164
165 function CreatePopUp(headerText, width, height, top, left) {
166 var divTemp = document.createElement("div");
167
168 divTemp.style.padding = "0";
169 divTemp.style.zIndex = "103";
170 divTemp.style.position = "absolute";
171 divTemp.id = "popUpMaster";
172
173 var headingText = document.createElement("h4");
174 headingText.innerHTML = headerText;
175
176 var closeButton = document.createElement("a");
177 closeButton.innerHTML = "&nbsp&nbsp&nbsp&nbsp";
178 closeButton.href = "javascript:;";
179 closeButton.className = "closePopUp";
180 closeButton.onclick = ClosePopup;
181 closeButton.id = "closeButton";
182
183 var img1 = document.createElement("img");
184 img1.src ="../wp-content/plugins/wp-insert/images/popUpTopLft.png";
185 img1.id = "popUpTopLft";
186
187 var img2 = document.createElement("img");
188 img2.src = "../wp-content/plugins/wp-insert/images/popUpTop.png";
189 img2.id = "popUpTop";
190
191 var img3 = document.createElement("img");
192 img3.src = "../wp-content/plugins/wp-insert/images/popUpTopRgt.png";
193 img3.id = "popUpTopRgt";
194
195 var img4 = document.createElement("img");
196 img4.src = "../wp-content/plugins/wp-insert/images/popUpLft.png";
197 img4.id = "popUpLft";
198
199 var img5 = document.createElement("img");
200 img5.src = "../wp-content/plugins/wp-insert/images/popUpRgt.png";
201 img5.id = "popUpRgt";
202
203 var img6 = document.createElement("img");
204 img6.src = "../wp-content/plugins/wp-insert/images/popUpBtmLft.png";
205 img6.id = "popUpBtmLft";
206
207 var img7 = document.createElement("img");
208 img7.src = "../wp-content/plugins/wp-insert/images/popUpBtmRgt.png";
209 img7.id = "popUpBtmRgt";
210
211 var img8 = document.createElement("img");
212 img8.src = "../wp-content/plugins/wp-insert/images/popUpBtm.png";
213 img8.id = "popUpBtm";
214
215 var divContentArea = document.createElement("div");
216 divContentArea.id = "content";
217
218 divTemp.appendChild(headingText);
219 divTemp.appendChild(closeButton);
220 divTemp.appendChild(img1);
221 divTemp.appendChild(img2);
222 divTemp.appendChild(img3);
223 divTemp.appendChild(img4);
224 divTemp.appendChild(img5);
225 divTemp.appendChild(img6);
226 divTemp.appendChild(img7);
227 divTemp.appendChild(img8);
228 divTemp.appendChild(divContentArea);
229
230
231 document.body.appendChild(divTemp);
232
233 try {
234 InitialisePopUP(width, height, top, left);
235 }
236 catch (err) {
237 }
238 return divContentArea; ;
239
240 }
241
242 function ClosePopup() {
243 if (document.getElementById("popUpMaster")) {
244 document.body.removeChild(document.getElementById("popUpMaster"));
245 }
246 if (document.getElementById("GreyOut")) {
247 document.body.removeChild(document.getElementById("GreyOut"));
248 }
249 }
250
251 /* End PopUps */