| @@ 41-127 (lines=87) @@ | ||
| 38 | -------------------------------------------------------------------------*/ |
|
| 39 | ||
| 40 | // Expand drawer |
|
| 41 | objects.on('expand.drawer', function expand(event, speed, stay) { |
|
| 42 | var drawer = $(this), |
|
| 43 | position = drawer.data('position'), |
|
| 44 | buttons = $('.button.drawer'), |
|
| 45 | button = buttons.filter('[href="#' + drawer.attr('id') + '"]'), |
|
| 46 | samePositionButtons = buttons.filter('.' + position), |
|
| 47 | context = drawer.data('context') ? '.' + drawer.data('context') : '', |
|
| 48 | height = getHeight(); |
|
| 49 | ||
| 50 | drawer.trigger('expandstart.drawer'); |
|
| 51 | ||
| 52 | speed = (typeof speed === 'undefined' ? settings.speed : speed); |
|
| 53 | stay = (typeof stay === 'undefined' ? false : true); |
|
| 54 | ||
| 55 | // update button state |
|
| 56 | samePositionButtons.removeClass('selected'); |
|
| 57 | ||
| 58 | // Close opened drawers from same region |
|
| 59 | $('.drawer.' + position).filter(function() { |
|
| 60 | return $(this).data('open'); |
|
| 61 | }).trigger('collapse.drawer', [speed, true]); |
|
| 62 | ||
| 63 | if (position === 'vertical-left') { |
|
| 64 | drawer.css({ |
|
| 65 | width: 0, |
|
| 66 | height: height, |
|
| 67 | display: 'block' |
|
| 68 | }) |
|
| 69 | .animate({ |
|
| 70 | width: settings.verticalWidth |
|
| 71 | }, { |
|
| 72 | duration: speed, |
|
| 73 | step: function(now){ |
|
| 74 | form.css('margin-left', now + 1); // +1px right border |
|
| 75 | }, |
|
| 76 | complete: function() { |
|
| 77 | form.css('margin-left', settings.verticalWidth + 1); // +1px right border |
|
| 78 | drawer.trigger('expandstop.drawer'); |
|
| 79 | } |
|
| 80 | }); |
|
| 81 | } |
|
| 82 | else if (position === 'vertical-right') { |
|
| 83 | drawer.css({ |
|
| 84 | width: 0, |
|
| 85 | height: height, |
|
| 86 | display: 'block' |
|
| 87 | }) |
|
| 88 | .animate({ |
|
| 89 | width: settings.verticalWidth |
|
| 90 | }, { |
|
| 91 | duration: speed, |
|
| 92 | step: function(now){ |
|
| 93 | form.css('margin-right', now + 1); // +1px left border |
|
| 94 | }, |
|
| 95 | complete: function() { |
|
| 96 | form.css('margin-right', settings.verticalWidth + 1); // +1px right border |
|
| 97 | drawer.trigger('expandstop.drawer'); |
|
| 98 | } |
|
| 99 | }); |
|
| 100 | } |
|
| 101 | else if (position === 'horizontal') { |
|
| 102 | drawer.animate({ |
|
| 103 | height: 'show' |
|
| 104 | }, { |
|
| 105 | duration: speed, |
|
| 106 | complete: function() { |
|
| 107 | drawer.trigger('expandstop.drawer'); |
|
| 108 | } |
|
| 109 | }); |
|
| 110 | } |
|
| 111 | ||
| 112 | button.addClass('selected'); |
|
| 113 | ||
| 114 | // store state |
|
| 115 | if(Symphony.Support.localStorage === true) { |
|
| 116 | // Put in a try/catch incase we exceed storage space |
|
| 117 | try { |
|
| 118 | window.localStorage['symphony.drawer.' + drawer.attr('id') + context] = 'opened'; |
|
| 119 | } |
|
| 120 | catch(e) { |
|
| 121 | window.onerror(e.message); |
|
| 122 | } |
|
| 123 | } |
|
| 124 | ||
| 125 | wrapper.addClass('drawer-' + position); |
|
| 126 | drawer.data('open', true); |
|
| 127 | }); |
|
| 128 | ||
| 129 | // Collapse drawer |
|
| 130 | objects.on('collapse.drawer', function collapse(event, speed, stay) { |
|
| @@ 130-205 (lines=76) @@ | ||
| 127 | }); |
|
| 128 | ||
| 129 | // Collapse drawer |
|
| 130 | objects.on('collapse.drawer', function collapse(event, speed, stay) { |
|
| 131 | var drawer = $(this), |
|
| 132 | position = drawer.data('position'), |
|
| 133 | buttons = $('.button.drawer'), |
|
| 134 | button = buttons.filter('[href="#' + drawer.attr('id') + '"]'), |
|
| 135 | context = drawer.data('context') ? '.' + drawer.data('context') : ''; |
|
| 136 | ||
| 137 | drawer.trigger('collapsestart.drawer'); |
|
| 138 | ||
| 139 | speed = (typeof speed === 'undefined' ? settings.speed : speed); |
|
| 140 | stay = (typeof stay === 'undefined' ? false : true); |
|
| 141 | ||
| 142 | // update button state |
|
| 143 | button.removeClass('selected'); |
|
| 144 | ||
| 145 | if (position === 'vertical-left') { |
|
| 146 | drawer.animate({ |
|
| 147 | width: 0 |
|
| 148 | }, { |
|
| 149 | duration: speed, |
|
| 150 | step: function(now){ |
|
| 151 | if (!stay) { |
|
| 152 | form.css('margin-left', now); |
|
| 153 | } |
|
| 154 | }, |
|
| 155 | complete: function() { |
|
| 156 | drawer.css({ |
|
| 157 | display: 'none' |
|
| 158 | }) |
|
| 159 | .trigger('collapsestop.drawer'); |
|
| 160 | } |
|
| 161 | }); |
|
| 162 | } |
|
| 163 | else if (position === 'vertical-right') { |
|
| 164 | drawer.animate({ |
|
| 165 | width: 0 |
|
| 166 | }, { |
|
| 167 | duration: speed, |
|
| 168 | step: function(now){ |
|
| 169 | if (!stay) { |
|
| 170 | form.css('margin-right', now); |
|
| 171 | } |
|
| 172 | }, |
|
| 173 | complete: function() { |
|
| 174 | drawer.css({ |
|
| 175 | display: 'none' |
|
| 176 | }) |
|
| 177 | .trigger('collapsestop.drawer'); |
|
| 178 | } |
|
| 179 | }); |
|
| 180 | } |
|
| 181 | else if (position === 'horizontal') { |
|
| 182 | drawer.animate({ |
|
| 183 | height: 'hide' |
|
| 184 | }, { |
|
| 185 | duration: speed, |
|
| 186 | complete: function() { |
|
| 187 | drawer.trigger('collapsestop.drawer'); |
|
| 188 | } |
|
| 189 | }); |
|
| 190 | } |
|
| 191 | ||
| 192 | // store state |
|
| 193 | if(Symphony.Support.localStorage === true) { |
|
| 194 | // Put in a try/catch incase we exceed storage space |
|
| 195 | try { |
|
| 196 | window.localStorage['symphony.drawer.' + drawer.attr('id') + context] = 'closed'; |
|
| 197 | } |
|
| 198 | catch(e) { |
|
| 199 | window.onerror(e.message); |
|
| 200 | } |
|
| 201 | } |
|
| 202 | ||
| 203 | wrapper.removeClass('drawer-' + position); |
|
| 204 | drawer.data('open', false); |
|
| 205 | }); |
|
| 206 | ||
| 207 | // Resize drawers |
|
| 208 | $(window).on('resize.drawer load.drawer', function() { |
|