| 1 | <?php require('../../../../wp-config.php'); ?> |
|---|
| 2 | <?php if(get_option('canvas_auto_publish') == 'true') $on_update = ', onUpdate:function(){ Canvas.saveAll;}'; |
|---|
| 3 | else $on_update = ', onUpdate: Canvas.changePublish'; ?> |
|---|
| 4 | Event.observe(window, 'load', function() { Canvas.initialize() }, false); |
|---|
| 5 | Event.observe(window, 'unload', Event.unloadCache, false); |
|---|
| 6 | |
|---|
| 7 | var CanvasAjax = Ajax; |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | var Canvas = { |
|---|
| 11 | |
|---|
| 12 | addListItem: function(id, name) { |
|---|
| 13 | var count = $F('listcount'); |
|---|
| 14 | var elementId = id.parentNode; |
|---|
| 15 | var copiedElement = elementId.cloneNode(true); |
|---|
| 16 | copiedElement.id = name + count; |
|---|
| 17 | copiedElement.firstChild.name = count + 'canvaslist_' + name; |
|---|
| 18 | var parent = elementId.parentNode; |
|---|
| 19 | parent.insertBefore(copiedElement, elementId.nextSibling); |
|---|
| 20 | $('listcount').value++; |
|---|
| 21 | }, |
|---|
| 22 | |
|---|
| 23 | canvasOption: function(name, value) { |
|---|
| 24 | var url = JS_CANVASURI + 'ajax/canvas-save-option.php'; |
|---|
| 25 | var pars = name+'='+value; |
|---|
| 26 | var myAjax = new Ajax.Request(url, |
|---|
| 27 | {method: 'post', |
|---|
| 28 | parameters: pars } |
|---|
| 29 | ); |
|---|
| 30 | }, |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | changePublishImg: function() { |
|---|
| 35 | image = $('publish_image'); |
|---|
| 36 | if(image) image.src = JS_CANVASURI + 'images/publish-changed.gif'; |
|---|
| 37 | }, |
|---|
| 38 | |
|---|
| 39 | changePublish: function(myelement) { |
|---|
| 40 | |
|---|
| 41 | Canvas.changePublishImg(); |
|---|
| 42 | Canvas.canvasHideMsg(); |
|---|
| 43 | |
|---|
| 44 | if (myelement.id != "shelf"){ |
|---|
| 45 | default_template_name = $(myelement.id + '_' + 'template_name').value; |
|---|
| 46 | template_size = Canvas.canvasMapTemplateSize($(myelement.id + '_' + 'template_size').value); |
|---|
| 47 | allow_other_sizes = $(myelement.id + '_' + 'allow_other_sizes').value; |
|---|
| 48 | allow_other_modules = $(myelement.id + '_' + 'allow_other_modules').value; |
|---|
| 49 | default_module = $(myelement.id + '_' + 'default_module').value; |
|---|
| 50 | |
|---|
| 51 | var children = myelement.childElements(); |
|---|
| 52 | children.each( |
|---|
| 53 | function(myelement){ |
|---|
| 54 | if (myelement.hasClassName('container-plugin')){ |
|---|
| 55 | if (!(allow_other_modules) && default_module != $F(myelement.id + '_module_name')){ |
|---|
| 56 | myelement.remove(); |
|---|
| 57 | $('shelf').insert(myelement); |
|---|
| 58 | Canvas.canvasDisplayMsg("Failed! Default module (" + default_module + ") only can be placed in this canvas.") |
|---|
| 59 | } |
|---|
| 60 | else if (Canvas.canvasMapTemplateSize($F(myelement.id + '_module_size')) > template_size){ |
|---|
| 61 | if (allow_other_sizes){ |
|---|
| 62 | Canvas.canvasDisplayMsg("Warning! You have placed a module with size greater than the canvas size.") |
|---|
| 63 | } |
|---|
| 64 | else{ |
|---|
| 65 | myelement.remove(); |
|---|
| 66 | $('shelf').insert(myelement); |
|---|
| 67 | Canvas.canvasDisplayMsg("Failed! The selected module size is greater than the canvas size.") |
|---|
| 68 | } |
|---|
| 69 | } |
|---|
| 70 | if ($F(myelement.id + '_module_template_name') == "") $(myelement.id + '_module_template_name').value = default_template_name; |
|---|
| 71 | if ($F(myelement.id + '_module_size') == "") $(myelement.id + '_module_size').value = template_size; |
|---|
| 72 | |
|---|
| 73 | } |
|---|
| 74 | |
|---|
| 75 | }); |
|---|
| 76 | } |
|---|
| 77 | else{ |
|---|
| 78 | // Make sure all template name and sizes for modules on the shelf are reset |
|---|
| 79 | myelement.childElements().each( |
|---|
| 80 | function(childElement){ |
|---|
| 81 | if (childElement.hasClassName('container-plugin')){ |
|---|
| 82 | $(childElement.id + '_module_template_name').value = ""; |
|---|
| 83 | $(childElement.id + '_module_size').value = ""; |
|---|
| 84 | |
|---|
| 85 | } |
|---|
| 86 | } |
|---|
| 87 | ); |
|---|
| 88 | } |
|---|
| 89 | }, |
|---|
| 90 | |
|---|
| 91 | canvasDisplayMsg: function(msg) { |
|---|
| 92 | |
|---|
| 93 | $('canvas_status').style.display = ""; |
|---|
| 94 | $('canvas_status').innerHTML = "<p>" + msg + "</p>"; |
|---|
| 95 | }, |
|---|
| 96 | |
|---|
| 97 | canvasHideMsg: function(msg) { |
|---|
| 98 | $('canvas_status').style.display = "none"; |
|---|
| 99 | }, |
|---|
| 100 | |
|---|
| 101 | |
|---|
| 102 | canvasMapTemplateSize: function(templateValue) { |
|---|
| 103 | return templateValue; |
|---|
| 104 | /*if (templateValue > 0) return templateValue; |
|---|
| 105 | switch (templateValue){ |
|---|
| 106 | |
|---|
| 107 | case "-1": // MODULE_TEMPLATE_SIZE_SMALL |
|---|
| 108 | return 240; |
|---|
| 109 | break; |
|---|
| 110 | |
|---|
| 111 | case "-2": // MODULE_TEMPLATE_SIZE_MEDIUM |
|---|
| 112 | return 480; |
|---|
| 113 | break; |
|---|
| 114 | |
|---|
| 115 | case "-3": // MODULE_TEMPLATE_SIZE_LARGE |
|---|
| 116 | return 720; |
|---|
| 117 | break; |
|---|
| 118 | |
|---|
| 119 | case "-4": // MODULE_TEMPLATE_SIZE_FULL |
|---|
| 120 | return 960; |
|---|
| 121 | break; |
|---|
| 122 | }*/ |
|---|
| 123 | |
|---|
| 124 | }, |
|---|
| 125 | |
|---|
| 126 | endDrag: function(myelement) { |
|---|
| 127 | //myelement.revert = true; |
|---|
| 128 | //myelement.options.revert = true; |
|---|
| 129 | |
|---|
| 130 | |
|---|
| 131 | }, |
|---|
| 132 | |
|---|
| 133 | |
|---|
| 134 | |
|---|
| 135 | createDroppables: function(id) { |
|---|
| 136 | var elements = $$('#'+id+' div.canvas_droppable_zone'); |
|---|
| 137 | var shelf = $('shelf'); |
|---|
| 138 | Sortable.create('shelf',{tag:'div', only: ['container','container-plugin'], overlap:'horizontal', handle:'handle', constraint:false, containment:elements.concat(shelf), dropOnEmpty:true<?php echo $on_update; ?>}); |
|---|
| 139 | |
|---|
| 140 | elements.each(function(item){ |
|---|
| 141 | Sortable.create(item.id,{tag:'div', only: ['container','container-plugin'], overlap:'horizontal', handle:'handle', constraint:false, containment:elements.concat(shelf), dropOnEmpty:true<?php echo $on_update; ?>}); |
|---|
| 142 | |
|---|
| 143 | //Grab default module |
|---|
| 144 | default_module = $(item.id + '_' + 'default_module').value; |
|---|
| 145 | allow_other_modules = $(item.id + '_' + 'allow_other_modules').value; |
|---|
| 146 | |
|---|
| 147 | default_template_name = $(item.id + '_' + 'template_name').value; |
|---|
| 148 | template_size = Canvas.canvasMapTemplateSize($(item.id + '_' + 'template_size').value); |
|---|
| 149 | |
|---|
| 150 | var children = $('shelf').childElements(); |
|---|
| 151 | children.each( |
|---|
| 152 | function(myelement){ |
|---|
| 153 | if (default_module == $F(myelement.id + '_module_name')){ |
|---|
| 154 | // Check whether there is any modules in this canvas |
|---|
| 155 | var children = $(item.id).childElements(); |
|---|
| 156 | modulesExist = false; |
|---|
| 157 | children.each( function(item){ |
|---|
| 158 | if (item.hasClassName('container-plugin')){ |
|---|
| 159 | modulesExist = true; |
|---|
| 160 | } |
|---|
| 161 | }); |
|---|
| 162 | |
|---|
| 163 | if (!modulesExist && LOAD_DEFAULT_MODULES){ |
|---|
| 164 | myelement.remove(); |
|---|
| 165 | $(item.id).insert(myelement); |
|---|
| 166 | |
|---|
| 167 | if ($F(myelement.id + '_module_template_name') == "") $(myelement.id + '_module_template_name').value = default_template_name; |
|---|
| 168 | if ($F(myelement.id + '_module_size') == "") $(myelement.id + '_module_size').value = template_size; |
|---|
| 169 | |
|---|
| 170 | Canvas.changePublish($('shelf')); |
|---|
| 171 | Canvas.canvasDisplayMsg("Default modules are added automatically to the canvas. Click Publish to save changes."); |
|---|
| 172 | if (!(allow_other_modules)){ |
|---|
| 173 | myelement.select( 'h6.handle').find(function(s) {s.remove();}); |
|---|
| 174 | } |
|---|
| 175 | } |
|---|
| 176 | } |
|---|
| 177 | |
|---|
| 178 | } |
|---|
| 179 | ); |
|---|
| 180 | |
|---|
| 181 | var children1 = $(item.id).childElements(); |
|---|
| 182 | children1.each( |
|---|
| 183 | function(myelement){ |
|---|
| 184 | //console.log(item.id +" - " + myelement.id + '_module_name' +" - " + Object.isElement(myelement.id + '_module_name') +" - " + default_module+" - " ) ; |
|---|
| 185 | if ($(myelement.id).hasClassName('container-plugin') && default_module == $F(myelement.id + '_module_name')){ |
|---|
| 186 | if (!(allow_other_modules)){ |
|---|
| 187 | myelement.select( 'h6.handle').find(function(s) {s.remove();}); |
|---|
| 188 | } |
|---|
| 189 | } |
|---|
| 190 | |
|---|
| 191 | } |
|---|
| 192 | ); |
|---|
| 193 | }); |
|---|
| 194 | |
|---|
| 195 | |
|---|
| 196 | |
|---|
| 197 | /*Droppables.add('shelf', { |
|---|
| 198 | accept: ['container','container-plugin'] |
|---|
| 199 | }); |
|---|
| 200 | |
|---|
| 201 | var elements = $$('#'+id+' div.canvas_droppable_zone'); |
|---|
| 202 | elements.each(function(item){ |
|---|
| 203 | Droppables.add(item.id, { |
|---|
| 204 | accept: ['container','container-plugin'] |
|---|
| 205 | }); |
|---|
| 206 | |
|---|
| 207 | }); |
|---|
| 208 | |
|---|
| 209 | |
|---|
| 210 | $$('#'+$F('canvas_page')+' div.canvas_droppable_zone').concat($('shelf')).each(function(item){ |
|---|
| 211 | var children = item.childElements(); |
|---|
| 212 | children.each( function(myelement){ |
|---|
| 213 | if (myelement.hasClassName('container-plugin')){ |
|---|
| 214 | new Draggable(myelement.id, {}); |
|---|
| 215 | } |
|---|
| 216 | }); |
|---|
| 217 | });*/ |
|---|
| 218 | }, |
|---|
| 219 | |
|---|
| 220 | destroyDroppables: function(id) { |
|---|
| 221 | Sortable.destroy('shelf'); |
|---|
| 222 | $$('#'+id+' div.canvas_droppable_zone').each(function(item){ |
|---|
| 223 | Sortable.destroy(item.id); |
|---|
| 224 | }); |
|---|
| 225 | }, |
|---|
| 226 | |
|---|
| 227 | |
|---|
| 228 | gallerySwitch: function(id) { |
|---|
| 229 | if($F('selected_image') != '') $($F('selected_image')).className = ''; |
|---|
| 230 | $(id).className = 'selected_image'; |
|---|
| 231 | $('selected_image').value = id; |
|---|
| 232 | $('path').value = $F('directory')+id; |
|---|
| 233 | }, |
|---|
| 234 | |
|---|
| 235 | importXml: function() { |
|---|
| 236 | var pars = 'path_to_xml='+$F('path_to_xml'); |
|---|
| 237 | $('export_message').className = "importing"; |
|---|
| 238 | var target = 'export_message'; |
|---|
| 239 | var url = JS_CANVASURI + 'ajax/canvas-import.php'; |
|---|
| 240 | var myAjax = new Ajax.Updater({success: target}, url, |
|---|
| 241 | {method: 'post', |
|---|
| 242 | parameters: pars, |
|---|
| 243 | onComplete: function() { $('export_message').className = ''; $('export_message').style.paddingLeft = '0px'; } |
|---|
| 244 | }); |
|---|
| 245 | }, |
|---|
| 246 | |
|---|
| 247 | initialize: function() { |
|---|
| 248 | //var bigdiv = document.createElement('div'); |
|---|
| 249 | //document.body.insertBefore(bigdiv, $('wphead')); |
|---|
| 250 | //bigdiv.appendChild($('wphead')); |
|---|
| 251 | //bigdiv.appendChild($('adminmenu')); |
|---|
| 252 | //bigdiv.appendChild($('submenu')); |
|---|
| 253 | |
|---|
| 254 | var hide_instructions = $('hide_instructions'); |
|---|
| 255 | if(hide_instructions) { |
|---|
| 256 | hide_instructions.onclick = function(){ |
|---|
| 257 | Canvas.canvasOption('canvas_show_instructions','0'); |
|---|
| 258 | new Effect.Fade('instructions', { duration: 0.4 }); |
|---|
| 259 | }; |
|---|
| 260 | } |
|---|
| 261 | $$('ul.page_dropdown ul li a').each(function(item){ |
|---|
| 262 | //$(item).onclick = function(){ Canvas.switchCanvas(item.id) }; |
|---|
| 263 | }); |
|---|
| 264 | //$('show_content').onclick = function(){ Canvas.toggleMenu('show_content', 'hide_content', bigdiv); }; |
|---|
| 265 | //$('hide_content').onclick = function(){ Canvas.toggleMenu('show_content', 'hide_content', bigdiv); }; |
|---|
| 266 | $$('div.titlebar a img').each(function(item){ |
|---|
| 267 | $(item).onclick = function(){ Canvas.sortGroups(item.id) }; |
|---|
| 268 | }); |
|---|
| 269 | $$('.canvas_droppable_zone h8').each(function(item){ |
|---|
| 270 | $(item).onclick = function(){ Canvas.toggleZoneOptions(item.id) }; |
|---|
| 271 | }); |
|---|
| 272 | if($('canvas_page')) { |
|---|
| 273 | mainpage = $F('canvas_page'); |
|---|
| 274 | curr_page = gup('t_page'); |
|---|
| 275 | if (curr_page == '') |
|---|
| 276 | curr_page = mainpage; |
|---|
| 277 | $(curr_page).style.display = "block"; |
|---|
| 278 | var mainmenu = $(curr_page+'__menu'); |
|---|
| 279 | if(mainmenu) { mainmenu.parentNode.className = 'selected'; } |
|---|
| 280 | var publish = $('publish'); |
|---|
| 281 | if(publish) { publish.onclick = Canvas.saveAll; } |
|---|
| 282 | Canvas.createDroppables(mainpage); |
|---|
| 283 | } |
|---|
| 284 | }, |
|---|
| 285 | |
|---|
| 286 | removeListItem: function(id) { |
|---|
| 287 | if(window.confirm('Are you sure you want to remove this item?')) { |
|---|
| 288 | new Effect.Fade(id.parentNode,{ duration: 0.6, afterFinish: function(){ Element.remove(id.parentNode); } }); |
|---|
| 289 | } |
|---|
| 290 | }, |
|---|
| 291 | |
|---|
| 292 | restorePublish: function() { |
|---|
| 293 | image = $('publish_image'); |
|---|
| 294 | if(image) image.src = JS_CANVASURI + 'images/publish.gif'; |
|---|
| 295 | }, |
|---|
| 296 | |
|---|
| 297 | saveAll: function() { |
|---|
| 298 | Canvas.canvasHideMsg(); |
|---|
| 299 | |
|---|
| 300 | if($('publish')) { |
|---|
| 301 | $('publish').setStyle({backgroundImage: "url(" + JS_CANVASURI + "images/spinner.gif)"}); |
|---|
| 302 | } |
|---|
| 303 | var layout_params; |
|---|
| 304 | var saveCheckError = false; |
|---|
| 305 | $$('#'+$F('canvas_page')+' div.canvas_droppable_zone').concat($('shelf')).each(function(item){ |
|---|
| 306 | |
|---|
| 307 | if (item.id == 'shelf') { |
|---|
| 308 | layout_params = Canvas.serializeHelper(layout_params, item.id); |
|---|
| 309 | return; |
|---|
| 310 | } |
|---|
| 311 | |
|---|
| 312 | template_size = Canvas.canvasMapTemplateSize($(item.id + '_' + 'template_size').value); |
|---|
| 313 | allow_other_sizes = $(item.id + '_' + 'allow_other_sizes').value; |
|---|
| 314 | |
|---|
| 315 | // Verify there are no invalid template size |
|---|
| 316 | item.childElements().each( |
|---|
| 317 | function(myelement){ |
|---|
| 318 | if (myelement.hasClassName('container-plugin')){ |
|---|
| 319 | if (Canvas.canvasMapTemplateSize($F(myelement.id + '_module_size')) > template_size){ |
|---|
| 320 | if (!allow_other_sizes){ |
|---|
| 321 | Canvas.canvasDisplayMsg("Error! You have placed module (" + $F(myelement.id + '_module_name') + ") with size greater than the canvas size.") |
|---|
| 322 | saveCheckError = true; |
|---|
| 323 | } |
|---|
| 324 | } |
|---|
| 325 | |
|---|
| 326 | } |
|---|
| 327 | }); |
|---|
| 328 | |
|---|
| 329 | layout_params = Canvas.serializeHelper(layout_params, item.id); |
|---|
| 330 | }); |
|---|
| 331 | |
|---|
| 332 | if (!saveCheckError) { |
|---|
| 333 | Canvas.saveLayout(layout_params); |
|---|
| 334 | Canvas.zoneOptions(); |
|---|
| 335 | } |
|---|
| 336 | else{ |
|---|
| 337 | if($('publish')){ $('publish').style.backgroundImage = "url('')"; Canvas.restorePublish(); } |
|---|
| 338 | } |
|---|
| 339 | }, |
|---|
| 340 | |
|---|
| 341 | saveBlock: function(element, pars) { |
|---|
| 342 | |
|---|
| 343 | // Update the module template name and size |
|---|
| 344 | $($F('updated_module_template_size_id')).value = $F('template_size'); //.getValue(); |
|---|
| 345 | $($F('updated_module_template_name_id')).value = $F('template_name'); |
|---|
| 346 | |
|---|
| 347 | var url = JS_CANVASURI + 'ajax/canvas-save-plugin.php'; |
|---|
| 348 | var myAjax = new Ajax.Request(url, |
|---|
| 349 | {method: 'get', |
|---|
| 350 | parameters: pars } |
|---|
| 351 | ); |
|---|
| 352 | }, |
|---|
| 353 | |
|---|
| 354 | saveLayout: function(pars) { |
|---|
| 355 | var url = JS_CANVASURI + 'ajax/canvas-save-layout.php'; |
|---|
| 356 | var myAjax = new Ajax.Request(url, |
|---|
| 357 | {method: 'get', |
|---|
| 358 | parameters: pars |
|---|
| 359 | }); |
|---|
| 360 | }, |
|---|
| 361 | |
|---|
| 362 | saveZone: function(pars) { |
|---|
| 363 | var url = JS_CANVASURI + 'ajax/canvas-save-zone-options.php'; |
|---|
| 364 | var myAjax = new Ajax.Request(url, |
|---|
| 365 | {method: 'get', |
|---|
| 366 | parameters: pars, |
|---|
| 367 | onComplete: function(){ if($('publish')){ $('publish').style.backgroundImage = "url('')"; Canvas.restorePublish(); } } |
|---|
| 368 | }); |
|---|
| 369 | }, |
|---|
| 370 | |
|---|
| 371 | serializeHelper: function(layout_params, block) { |
|---|
| 372 | layout_params = Try.these ( |
|---|
| 373 | function() { |
|---|
| 374 | //template_name = Canvas.getBlockAttribute(block, 'template_name'); |
|---|
| 375 | //template_size = Canvas.getBlockAttribute(block, 'template_size'); |
|---|
| 376 | |
|---|
| 377 | |
|---|
| 378 | |
|---|
| 379 | content_exists = Canvas.customSerialize(block);//Sortable.serialize(block); |
|---|
| 380 | |
|---|
| 381 | if (content_exists == '') { |
|---|
| 382 | return layout_params; |
|---|
| 383 | } else if (typeof(layout_params) == 'undefined') { |
|---|
| 384 | return content_exists; |
|---|
| 385 | } else { |
|---|
| 386 | return layout_params + content_exists; |
|---|
| 387 | } |
|---|
| 388 | } |
|---|
| 389 | ); |
|---|
| 390 | return layout_params; |
|---|
| 391 | }, |
|---|
| 392 | |
|---|
| 393 | getBlockAttribute: function(block, attribute) { |
|---|
| 394 | if (block != "shelf") { |
|---|
| 395 | attribute_val = $(block + '_' + attribute).value; |
|---|
| 396 | return '_' + block + '_' + attribute + '=' + attribute_val + "&"; |
|---|
| 397 | } |
|---|
| 398 | return ""; |
|---|
| 399 | }, |
|---|
| 400 | |
|---|
| 401 | customSerialize: function(block) { |
|---|
| 402 | newContent = Sortable.serialize(block) + "&"; |
|---|
| 403 | |
|---|
| 404 | if (block != "shelf") { |
|---|
| 405 | name = encodeURIComponent(block); |
|---|
| 406 | |
|---|
| 407 | var children = $(block).childElements(); |
|---|
| 408 | children.each( |
|---|
| 409 | function(item){ |
|---|
| 410 | if (item.hasClassName('container-plugin')){ |
|---|
| 411 | newContent = newContent + "_" + name + "_template_size[]=" + encodeURIComponent($F(item.id + '_module_size')) + "&"; |
|---|
| 412 | newContent = newContent + "_" + name + "_template_name[]=" + encodeURIComponent($F(item.id + '_module_template_name')) + "&"; |
|---|
| 413 | } |
|---|
| 414 | }); |
|---|
| 415 | } |
|---|
| 416 | |
|---|
| 417 | return newContent; |
|---|
| 418 | }, |
|---|
| 419 | |
|---|
| 420 | |
|---|
| 421 | |
|---|
| 422 | |
|---|
| 423 | |
|---|
| 424 | |
|---|
| 425 | sortGroups: function(group) { |
|---|
| 426 | if(group == 'all') { |
|---|
| 427 | $$('div.shelf_column div').each(function(item){ |
|---|
| 428 | $(item).style.display = 'block'; |
|---|
| 429 | }); |
|---|
| 430 | } else { |
|---|
| 431 | $$('div.shelf_column div.container').each(function(item){ |
|---|
| 432 | $(item).style.display = 'none'; |
|---|
| 433 | }); |
|---|
| 434 | $$('div.shelf_column div.container-plugin').each(function(item){ |
|---|
| 435 | $(item).style.display = 'none'; |
|---|
| 436 | }); |
|---|
| 437 | $$('div.shelf_column div.'+group).each(function(item){ |
|---|
| 438 | $(item).style.display = 'block'; |
|---|
| 439 | }); |
|---|
| 440 | } |
|---|
| 441 | }, |
|---|
| 442 | |
|---|
| 443 | switchCanvas: function(element) { |
|---|
| 444 | var currentPage = $F('canvas_page'); |
|---|
| 445 | $$('ul.page_dropdown ul li').each(function(item){ if($(item).className == 'selected') $(item).className = ''; }); |
|---|
| 446 | $(element).parentNode.className = 'selected'; |
|---|
| 447 | var string = element.split('__'); |
|---|
| 448 | $(currentPage).style.display = 'none'; |
|---|
| 449 | Canvas.destroyDroppables(currentPage); |
|---|
| 450 | $(string[0]).style.display = 'block'; |
|---|
| 451 | $('canvas_page').value = string[0]; |
|---|
| 452 | Canvas.createDroppables(string[0]); |
|---|
| 453 | }, |
|---|
| 454 | |
|---|
| 455 | toggleMenu: function(show,hide,block) { |
|---|
| 456 | if($(block).style.display == "none") { |
|---|
| 457 | $(show).style.display = "none"; |
|---|
| 458 | $(hide).style.display = "inline"; |
|---|
| 459 | new Effect.BlindDown(block, {duration: 0.3 }) |
|---|
| 460 | } else { |
|---|
| 461 | $(show).style.display = "inline"; |
|---|
| 462 | $(hide).style.display = "none"; |
|---|
| 463 | new Effect.BlindUp(block, {duration: 0.3 }) |
|---|
| 464 | } |
|---|
| 465 | }, |
|---|
| 466 | |
|---|
| 467 | toggleZoneOptions: function(id) { |
|---|
| 468 | if($(id.replace('togglezoneoption_','options_')).style.display == 'block') { |
|---|
| 469 | $(id.replace('togglezoneoption_','options_')).style.display = 'none'; |
|---|
| 470 | $(id).style.backgroundColor = '#CFCFCF'; |
|---|
| 471 | } else { |
|---|
| 472 | $(id.replace('togglezoneoption_','options_')).style.display = 'block'; |
|---|
| 473 | $(id).style.backgroundColor = 'transparent'; |
|---|
| 474 | } |
|---|
| 475 | }, |
|---|
| 476 | |
|---|
| 477 | zoneHandler: function(zone, position) { |
|---|
| 478 | $$('span#options_' + zone + ' img').each(function(item){ |
|---|
| 479 | item.src = item.src.replace('_down', '_up'); |
|---|
| 480 | item.src = item.src.replace(position+'_up', position+'_down'); |
|---|
| 481 | }); |
|---|
| 482 | $('zoneoption_'+zone).value = position; |
|---|
| 483 | Canvas.changePublish(); |
|---|
| 484 | }, |
|---|
| 485 | |
|---|
| 486 | zoneOptions: function() { |
|---|
| 487 | string = ''; |
|---|
| 488 | $$('#'+$F('canvas_page')+' select.zone_content_options').each(function(item){ |
|---|
| 489 | string = string + '&' + item.id + '=' + $F(item.id); |
|---|
| 490 | }); |
|---|
| 491 | Canvas.saveZone(string); |
|---|
| 492 | } |
|---|
| 493 | }; |
|---|
| 494 | |
|---|
| 495 | |
|---|
| 496 | // This code was found here: http://www.softcomplex.com/docs/get_window_size_and_scrollbar_position.html |
|---|
| 497 | |
|---|
| 498 | function f_clientWidth() { |
|---|
| 499 | return f_filterResults ( |
|---|
| 500 | window.innerWidth ? window.innerWidth : 0, |
|---|
| 501 | document.documentElement ? document.documentElement.clientWidth : 0, |
|---|
| 502 | document.body ? document.body.clientWidth : 0 |
|---|
| 503 | ); |
|---|
| 504 | } |
|---|
| 505 | function f_clientHeight() { |
|---|
| 506 | return f_filterResults ( |
|---|
| 507 | window.innerHeight ? window.innerHeight : 0, |
|---|
| 508 | document.documentElement ? document.documentElement.clientHeight : 0, |
|---|
| 509 | document.body ? document.body.clientHeight : 0 |
|---|
| 510 | ); |
|---|
| 511 | } |
|---|
| 512 | function f_scrollLeft() { |
|---|
| 513 | return f_filterResults ( |
|---|
| 514 | window.pageXOffset ? window.pageXOffset : 0, |
|---|
| 515 | document.documentElement ? document.documentElement.scrollLeft : 0, |
|---|
| 516 | document.body ? document.body.scrollLeft : 0 |
|---|
| 517 | ); |
|---|
| 518 | } |
|---|
| 519 | function f_scrollTop() { |
|---|
| 520 | return f_filterResults ( |
|---|
| 521 | window.pageYOffset ? window.pageYOffset : 0, |
|---|
| 522 | document.documentElement ? document.documentElement.scrollTop : 0, |
|---|
| 523 | document.body ? document.body.scrollTop : 0 |
|---|
| 524 | ); |
|---|
| 525 | } |
|---|
| 526 | function f_filterResults(n_win, n_docel, n_body) { |
|---|
| 527 | var n_result = n_win ? n_win : 0; |
|---|
| 528 | if (n_docel && (!n_result || (n_result > n_docel))) |
|---|
| 529 | n_result = n_docel; |
|---|
| 530 | return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result; |
|---|
| 531 | } |
|---|
| 532 | |
|---|
| 533 | /* This script and many more are available free online at |
|---|
| 534 | The JavaScript Source :: http://javascript.internet.com |
|---|
| 535 | Created by: Francis Cocharrua :: http://scripts.franciscocharrua.com/ */ |
|---|
| 536 | |
|---|
| 537 | function Select_Value_Set(SelectName, Value) { |
|---|
| 538 | eval('SelectObject = document.' + SelectName + ';'); |
|---|
| 539 | |
|---|
| 540 | for(index = 0; index < SelectObject.length; index++) { |
|---|
| 541 | if(SelectObject[index].value == Value) |
|---|
| 542 | SelectObject.selectedIndex = index; |
|---|
| 543 | } |
|---|
| 544 | } |
|---|
| 545 | |
|---|
| 546 | /* |
|---|
| 547 | Get the value of an HTML GET parameter |
|---|
| 548 | */ |
|---|
| 549 | function gup( name ) |
|---|
| 550 | { |
|---|
| 551 | name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); |
|---|
| 552 | var regexS = "[\\?&]"+name+"=([^&#]*)"; |
|---|
| 553 | var regex = new RegExp( regexS ); |
|---|
| 554 | var results = regex.exec( window.location.href ); |
|---|
| 555 | if( results == null ) |
|---|
| 556 | return ""; |
|---|
| 557 | else |
|---|
| 558 | return results[1]; |
|---|
| 559 | } |
|---|