admin-ui-controller.js
98 lines
| 1 | jQuery(document).ready(function() { |
| 2 | |
| 3 | // You can override the icon names here, in case you prefer your own or have URL issues: |
| 4 | // E.g. "http://mysite.com/cross.png/images/cross.png" would have "cross.png" replaced twice... |
| 5 | // Styling should be done in your custom CSS |
| 6 | var cookie_bar_on_icon = "tick.png"; |
| 7 | var cookie_bar_off_icon = "cross.png"; |
| 8 | |
| 9 | // jQuery only CSS: |
| 10 | jQuery('HTML').addClass('JS'); |
| 11 | |
| 12 | /* |
| 13 | Work in progress... open same tab position between saves |
| 14 | If you are a web developer and fancy beating me to this, please get in touch... :) |
| 15 | |
| 16 | DONE: |
| 17 | if 'cliopentab' GET param is set: |
| 18 | find out value of 'cliopentab' |
| 19 | call accordion with 'cliopentab' value |
| 20 | |
| 21 | TO DO: |
| 22 | on accordion changing the active div: |
| 23 | update form action with &cliopentab= <div number>: |
| 24 | parse form action |
| 25 | if 'cliopentab' GET param is set: |
| 26 | update 'cliopentab' value with <div number> |
| 27 | else: |
| 28 | add &cliopentab= <div number> |
| 29 | */ |
| 30 | function getURLParameter(name) { |
| 31 | return decodeURI( |
| 32 | (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1] |
| 33 | ); |
| 34 | } |
| 35 | switch ( getURLParameter("cliopentab") ) { |
| 36 | case "0": |
| 37 | jQuery("#cookielawinfo-accordion").accordion( { autoHeight: false, active: 0 } ); |
| 38 | break; |
| 39 | case "2": |
| 40 | jQuery("#cookielawinfo-accordion").accordion( { autoHeight: false, active: 2 } ); |
| 41 | break; |
| 42 | case "3": |
| 43 | jQuery("#cookielawinfo-accordion").accordion( { autoHeight: false, active: 3 } ); |
| 44 | break; |
| 45 | case "1": |
| 46 | default: |
| 47 | jQuery("#cookielawinfo-accordion").accordion( { autoHeight: false, active: 1 } ); |
| 48 | } |
| 49 | |
| 50 | |
| 51 | // Cookie bar is on/off message handling: |
| 52 | var f = jQuery("#header_on_off_alert"); |
| 53 | var t = jQuery("#header_on_off_field_warning"); |
| 54 | var icon = jQuery("#cli-plugin-status-icon"); |
| 55 | |
| 56 | jQuery('#is_on_field_yes').click(function(){ |
| 57 | // Cookie bar is on |
| 58 | f.text("Your Cookie Law Info bar is switched on"); |
| 59 | t.text("Your Cookie Law Info bar is switched on"); |
| 60 | t.removeClass('warning'); |
| 61 | swap_icon( cookie_bar_on_icon ); |
| 62 | }); |
| 63 | jQuery('#is_on_field_no').click(function(){ |
| 64 | // Cookie bar is off |
| 65 | f.text("Your Cookie Law Info bar is switched off"); |
| 66 | t.text("Your Cookie Law Info bar is switched off"); |
| 67 | t.addClass('warning'); |
| 68 | swap_icon( cookie_bar_off_icon ); |
| 69 | }); |
| 70 | function swap_icon(new_icon) { |
| 71 | old_icon = ( new_icon == cookie_bar_off_icon ) ? cookie_bar_on_icon : cookie_bar_off_icon; |
| 72 | var original_src = icon.attr('src'); |
| 73 | var new_src = original_src.replace(old_icon, new_icon); |
| 74 | icon.attr('src', new_src); |
| 75 | } |
| 76 | |
| 77 | |
| 78 | // Toggle admin display to show/hide action/URL fields |
| 79 | var rows = jQuery('.cli-plugin-row'); |
| 80 | var combobox = jQuery('#cli-plugin-button-1-action'); |
| 81 | |
| 82 | toggle_combobox(); |
| 83 | |
| 84 | combobox.change(function() { |
| 85 | toggle_combobox(); |
| 86 | }); |
| 87 | |
| 88 | function toggle_combobox() { |
| 89 | var selected = jQuery("#cli-plugin-button-1-action option:selected").val(); |
| 90 | if ( selected == "CONSTANT_OPEN_URL" ) { |
| 91 | rows.show(); |
| 92 | } |
| 93 | else { |
| 94 | rows.hide(); |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | }); |