|
1 /* |
|
2 Theme Name: Arcade |
|
3 Theme URI: http://www.obox-design.com/ |
|
4 Description: The first of six limited edition themes from the Obox Signature Series collection. |
|
5 Version: 1.0 |
|
6 Author: Marc and David Perel |
|
7 Author URI: http://www.obox-design.com/ |
|
8 */ |
|
9 function check_nan(element, element_value, max_value) |
|
10 { |
|
11 var len = element_value.length; |
|
12 if(isNaN(element_value)) |
|
13 { |
|
14 alert("Only number vlues are allow in this input."); |
|
15 element.value = element_value.substring(0, (len/1)-1); |
|
16 } |
|
17 |
|
18 if(max_value && ((element_value/1) > (max_value/1))) |
|
19 { |
|
20 alert("The maximum value allowed for this input is "+max_value); |
|
21 element.value = max_value; |
|
22 } |
|
23 } |
|
24 function check_linked($this_id, $link_id) |
|
25 { |
|
26 $this_id = "#"+$this_id; |
|
27 $link_id = "#"+$link_id; |
|
28 if($($this_id).attr("value") !== "0") |
|
29 { |
|
30 $($link_id).attr("disabled", "true"); |
|
31 } |
|
32 else |
|
33 {$($link_id).removeAttr("disabled");} |
|
34 |
|
35 } |
|
36 $(document).ready(function() |
|
37 { |
|
38 /* Tab Swapping */ |
|
39 $(".ocmx-tabs > ul > li > a").click(function() |
|
40 { |
|
41 /* Create the id to reference the content*/ |
|
42 $id = this.id.toString().substr(9, 1); |
|
43 $tab_id = "#tab-" + $id; |
|
44 $top_submit_id = "#submit-top-" + $id; |
|
45 $bottom_submit_id = "#submit-bottom-" + $id; |
|
46 /* Set the form action so we know which tab to refresh onto */ |
|
47 $current_action = $("#ocmx_form").attr("action") |
|
48 //Check if there's a tab already set and if so change it, otherwise, add it... |
|
49 $tab_start = $("#ocmx_form").attr("action").toString().indexOf("tab="); |
|
50 if($tab_start !== -1) |
|
51 {$new_action = $current_action.substr(0, $tab_start)+"tab="+$id;} |
|
52 else |
|
53 {$new_action = $current_action+"¤t_tab="+$id;} |
|
54 //Apply the new action to the form... |
|
55 $("#ocmx_form").attr("action", $new_action); |
|
56 // If we're clicking a new tab, fade it in. |
|
57 if($(".selected > a").attr("id") !== this.id) |
|
58 { |
|
59 //Fade the Old Form Out |
|
60 $(".selected_tab").slideUp("3000"); |
|
61 //Fade the New Form out, Change it's Class, and Fade it in again |
|
62 $($tab_id).fadeOut("fast").attr("class", "selected_tab").slideDown("3000"); |
|
63 if($($top_submit_id).html()) |
|
64 { |
|
65 $(".submit").fadeOut("3000"); |
|
66 $($top_submit_id).fadeOut("3000").attr("class", "submit").fadeIn("3000"); |
|
67 $($bottom_submit_id).fadeOut("3000").attr("class", "submit").fadeIn("3000"); |
|
68 } |
|
69 //Clear the Class of the Selected Tab |
|
70 $(".selected").attr("class", "") |
|
71 //Clear the Class of the New Tab |
|
72 $(this).parent().attr("class", "selected") |
|
73 } |
|
74 }); |
|
75 //Show all the Menu Items we've selected to display |
|
76 $("input[id^='main_page_']:checked").parent().children("ul").fadeIn("fast"); |
|
77 //Set the main page checkboxes selector |
|
78 $page_input = ".selection_sections > ul > li > input"; |
|
79 $("input[id^='main_page_']").click(function() |
|
80 { |
|
81 $id = $(this).attr("id").replace("main_page_", ""); |
|
82 $sub_menu_id= "#sub_pages_"+$id; |
|
83 if(this.checked == true) |
|
84 {$($sub_menu_id).slideDown("fast");} |
|
85 else |
|
86 {$($sub_menu_id).slideUp("fast");} |
|
87 }); |
|
88 |
|
89 //Show all the Menu Items we've selected to display |
|
90 $("input[id^='main_category_']:checked").parent().children("ul").fadeIn("fast"); |
|
91 //Set the main category checkboxes selector |
|
92 $category_input = ".selection_sections > ul > li > input"; |
|
93 $("input[id^='main_category_']").click(function() |
|
94 { |
|
95 $id = $(this).attr("id").replace("main_category_", ""); |
|
96 $sub_menu_id= "#sub_categories_"+$id; |
|
97 if(this.checked == true) |
|
98 {$($sub_menu_id).slideDown("fast");} |
|
99 else |
|
100 {$($sub_menu_id).slideUp("fast");} |
|
101 }); |
|
102 |
|
103 |
|
104 // Disable 3rd party ads Script Input when entering the page (if Required)... |
|
105 if($("#ocmx_header_buysell_ads option:selected").attr("value") == "off"){$("#ocmx_header_buysell_id").attr("disabled", "true");} |
|
106 $("#ocmx_header_buysell_ads").change(function() |
|
107 { |
|
108 // Enable/Disable BuySell Ad Script |
|
109 if($(this).attr("value") == "on") |
|
110 {$("#ocmx_header_buysell_id").removeAttr("disabled");} |
|
111 else |
|
112 {$("#ocmx_header_buysell_id").attr("disabled", "true");} |
|
113 }); |
|
114 // Disable 3rd party ads Script Input when entering the page (if Required)... |
|
115 if($("#ocmx_main_buysell_ads option:selected").attr("value") == "off"){$("#ocmx_main_buysell_id").attr("disabled", "true");} |
|
116 $("#ocmx_main_buysell_ads").change(function() |
|
117 { |
|
118 // Enable/Disable BuySell Ad Script |
|
119 if($(this).attr("value") == "on") |
|
120 {$("#ocmx_main_buysell_id").removeAttr("disabled");} |
|
121 else |
|
122 {$("#ocmx_main_buysell_id").attr("disabled", "true");} |
|
123 }); |
|
124 // Disable 3rd party ads Script Input when entering the page (if Required)... |
|
125 if($("#ocmx_small_buysell_ads option:selected").attr("value") == "off"){$("#ocmx_small_buysell_id").attr("disabled", "true");} |
|
126 $("#ocmx_small_buysell_ads").change(function() |
|
127 { |
|
128 // Enable/Disable BuySell Ad Script |
|
129 if($(this).attr("value") == "on") |
|
130 {$("#ocmx_small_buysell_id").removeAttr("disabled");} |
|
131 else |
|
132 {$("#ocmx_small_buysell_id").attr("disabled", "true");} |
|
133 }); |
|
134 |
|
135 //AS we change the amount of small ads we're using, reload the #small-ads-div div |
|
136 $("#ocmx_small_ads").change(function() |
|
137 { |
|
138 $ad_number = $(this).attr("value"); |
|
139 $("#small-ads-div").attr("class", "loading"); |
|
140 |
|
141 $("#small-ads-div").fadeOut("slow", function(){$("#small-ads-div").load($("#template-directory").html()+"/ocmx/ads_refresh.php?small_ads="+$ad_number, function(){$("#small-ads-div").fadeIn("fast");});}).attr("class", ""); |
|
142 $("#ocmx_small_buysell_ads option").each(function () { |
|
143 //Since we're setting our own ads, disable Buy and Sell |
|
144 if($ad_number !== "0" && $(this).attr("value") == "0") |
|
145 {$(this).attr("selected", "true");} |
|
146 }); |
|
147 }); |
|
148 $("input[id^='ocmx_small_ad_link_']").live("keyup", function() |
|
149 { |
|
150 //Set the Id of this Textarea |
|
151 $id = "#"+$(this).attr("id"); |
|
152 //Set the length so we can find the ID integer |
|
153 $ad_id = $(this).attr("id").replace("ocmx_small_ad_link_", ""); |
|
154 //Set the href Id |
|
155 $href_id = "#ocmx_small_ad_href_"+$ad_id; |
|
156 //Change the href value |
|
157 $($href_id).attr("href", $($id).attr("value")); |
|
158 |
|
159 }); |
|
160 $("input[id^='ocmx_small_ad_img_']").live("keyup", function() |
|
161 { |
|
162 //Set the Id of this Textarea |
|
163 $id = "#"+$(this).attr("id"); |
|
164 //Set the length so we can find the ID integer |
|
165 $ad_id = $(this).attr("id").replace("ocmx_small_ad_img_", ""); |
|
166 //Set the href Id |
|
167 $href_id = "#ocmx_small_ad_href_"+$ad_id; |
|
168 //Show a loading Bar, Change the href background |
|
169 $($href_id).removeAttr("style"); |
|
170 $($href_id).attr("class", "loading"); |
|
171 $($href_id).attr("style", "background: url('"+$($id).attr("value")+"') no-repeat center;"); |
|
172 $($href_id).attr("class", "std_link"); |
|
173 |
|
174 }); |
|
175 |
|
176 if($("#ocmx_medium_buysell_ads option:selected").attr("value") == "off"){$("#ocmx_medium_buysell_id").attr("disabled", "true");} |
|
177 $("#ocmx_medium_buysell_ads").change(function() |
|
178 { |
|
179 // Enable/Disable BuySell Ad Script |
|
180 if($(this).attr("value") == "on") |
|
181 {$("#ocmx_medium_buysell_id").removeAttr("disabled");} |
|
182 else |
|
183 {$("#ocmx_medium_buysell_id").attr("disabled", "true");} |
|
184 }); |
|
185 |
|
186 //AS we change the amount of small ads we're using, reload the #small-ads-div div |
|
187 $("#ocmx_medium_ads").change(function() |
|
188 { |
|
189 $ad_number = $(this).attr("value"); |
|
190 $("#medium-ads-div").attr("class", "loading"); |
|
191 |
|
192 $("#medium-ads-div").fadeOut("slow", function(){$("#medium-ads-div").load($("#template-directory").html()+"/ocmx/ads_refresh.php?medium_ads="+$ad_number, function(){$("#medium-ads-div").fadeIn("fast");});}).attr("class", ""); |
|
193 $("#ocmx_medium_buysell_ads option").each(function () { |
|
194 //Since we're setting our own ads, disable Buy and Sell |
|
195 if($ad_number !== "0" && $(this).attr("value") == "0") |
|
196 {$(this).attr("selected", "true");} |
|
197 }); |
|
198 }); |
|
199 $("input[id^='ocmx_medium_ad_link_']").live("keyup", function() |
|
200 { |
|
201 //Set the Id of this Textarea |
|
202 $id = "#"+$(this).attr("id"); |
|
203 //Set the length so we can find the ID integer |
|
204 $ad_id = $(this).attr("id").replace("ocmx_medium_ad_link_", ""); |
|
205 //Set the href Id |
|
206 $href_id = "#ocmx_medium_ad_href_"+$ad_id; |
|
207 //Change the href value |
|
208 $($href_id).attr("href", $($id).attr("value")); |
|
209 |
|
210 }); |
|
211 $("input[id^='ocmx_medium_ad_img_']").live("keyup", function() |
|
212 { |
|
213 //Set the Id of this Textarea |
|
214 $id = "#"+$(this).attr("id"); |
|
215 //Set the length so we can find the ID integer |
|
216 $ad_id = $(this).attr("id").replace("ocmx_medium_ad_img_", ""); |
|
217 //Set the href Id |
|
218 $href_id = "#ocmx_medium_ad_href_"+$ad_id; |
|
219 //Show a loading Bar, Change the href background |
|
220 $($href_id).removeAttr("style"); |
|
221 $($href_id).attr("class", "loading"); |
|
222 $($href_id).attr("style", "background: url('"+$($id).attr("value")+"') no-repeat center;"); |
|
223 $($href_id).attr("class", "std_link"); |
|
224 |
|
225 }); |
|
226 $("#ocmx_comment_form").submit(function() |
|
227 { |
|
228 $send_form = confirm("Are you sure you would like to save these changes, which may include removing selected comments?"); |
|
229 if(!$send_form) |
|
230 {return false;} |
|
231 else |
|
232 {return true;} |
|
233 }); |
|
234 /*********************/ |
|
235 /* COMMENT FUNCTIONS */ |
|
236 $("[id^=view-comment-]").click(function(){ |
|
237 $id = $(this).attr("id").replace("view-comment-", ""); |
|
238 $content_id = "#ocmx-comment-"+$id; |
|
239 if($($content_id).attr("class") == "no_display") |
|
240 {$($content_id).fadeIn("slow").removeClass("no_display");} |
|
241 else |
|
242 {$($content_id).fadeOut("slow").addClass("no_display");} |
|
243 return false; |
|
244 }); |
|
245 |
|
246 |
|
247 /*********************/ |
|
248 /* GALLERY FUNCTIONS */ |
|
249 |
|
250 $("#width_1, #height_1, #percentage_1").keyup(function() |
|
251 { |
|
252 if($(this).attr("id") == "percentage_1") |
|
253 { |
|
254 check_nan(this, $(this).attr("value"), '100'); |
|
255 if($(this).attr("value") == "") |
|
256 {$("#width_1, #height_1").removeAttr("disabled");} |
|
257 else |
|
258 {$("#width_1, #height_1").attr("disabled", "true");} |
|
259 } |
|
260 else |
|
261 {check_nan(this, $(this).attr("value"));} |
|
262 // switch_dimensions('1', this.value) |
|
263 }); |
|
264 |
|
265 $("#width_2, #height_2, #percentage_2").keyup(function() |
|
266 { |
|
267 if($(this).attr("id") == "percentage_2") |
|
268 { |
|
269 check_nan(this, $(this).attr("value"), '100'); |
|
270 if($(this).attr("value") == "") |
|
271 {$("#width_2, #height_2").removeAttr("disabled");} |
|
272 else |
|
273 {$("#width_2, #height_2").attr("disabled", "true");} |
|
274 } |
|
275 else |
|
276 {check_nan(this, $(this).attr("value"));} |
|
277 // switch_dimensions('1', this.value) |
|
278 }); |
|
279 |
|
280 $("input[id^='ocmx-gallery-add']").click(function() |
|
281 { |
|
282 $url = $("#add_url").attr("value"); |
|
283 window.location = ($url); |
|
284 }); |
|
285 |
|
286 $("input[id^='ocmx-gallery-save']").click(function() |
|
287 { |
|
288 $save_element = "<input type=\"hidden\" name=\"ocmx_gallery_save\" value=\"1\" />"; |
|
289 $($save_element).appendTo("#ocmx_form"); |
|
290 $("#ocmx_form").submit(); |
|
291 }); |
|
292 |
|
293 $("input[id^='ocmx-gallery-delete']").click(function() |
|
294 { |
|
295 $delete_gallery = confirm("Are you sure you want to delete the selected galleries?"); |
|
296 if(!$delete_gallery) |
|
297 {} |
|
298 else |
|
299 { |
|
300 $delete_element = "<input type=\"hidden\" name=\"ocmx_gallery_delete\" value=\"1\" />"; |
|
301 $($delete_element).appendTo("#ocmx_form"); |
|
302 $("#ocmx_form").submit(); |
|
303 } |
|
304 }); |
|
305 /* Set Permalink */ |
|
306 $("#ocmx_form").submit(function(){ |
|
307 $("#linkTitle").removeAttr("disabled"); |
|
308 }) |
|
309 $("#item").blur(function(){ |
|
310 $check_value = $("#item").attr("value"); |
|
311 $use_value = ""; |
|
312 $validchar = "1234567980abcdefghijklmnopqrstuvwxyz- "; |
|
313 $i_max = $("#item").attr("value").length; |
|
314 for($i = 0; $i < $i_max; $i++) |
|
315 { |
|
316 $this_char = $check_value.toLowerCase().charAt($i) |
|
317 if($validchar.indexOf($this_char) !== -1) |
|
318 {$use_value = $use_value + $this_char;} |
|
319 } |
|
320 $use_value = $use_value.replace(/ /g, "-"); |
|
321 $("#linkTitle").attr("value", $use_value); |
|
322 }); |
|
323 }); |