PluginProbe
Wp-Insert / 1.6.2
Wp-Insert v1.6.2
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.6.2, at js/common.js

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