Changeset 15946
- Timestamp:
- 02/05/12 23:00:59 (4 months ago)
- Location:
- trunk
- Files:
-
- 7 edited
-
inc/js/jquery.dolPopup.js (modified) (6 diffs)
-
menu.php (modified) (1 diff)
-
samples/popup.php (modified) (3 diffs)
-
templates/base/_footer.html (modified) (1 diff)
-
templates/base/_header.html (modified) (1 diff)
-
templates/base/css/menu.css (modified) (1 diff)
-
templates/base/scripts/BxBaseMenu.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/inc/js/jquery.dolPopup.js
r15942 r15946 7 7 (function($) { 8 8 9 $.fn.dolPopupDefaultOptions = { 10 closeOnOuterClick: true, 11 closeElement: '.bx-popup-element-close', // link to element which will close popup 12 position: 'centered', // | 'absolute' | 'fixed' | event | element, 13 fog: {color: '#fff', opacity: .7}, // {color, opacity}, 14 pointer: false, // {el:(string_id|jquery_object), align: (left|right|center)}, 15 left: 0, // only for fixed or absolute 16 top: 0, // only for fixed 17 onBeforeShow: function () {}, 18 onShow: function () {}, 19 onBeforeHide: function () {}, 20 onHide: function () {}, 21 speed: 150 22 }; 23 24 $.fn.dolPopupDefaultPointerOptions = { 25 align: 'right', 26 offset: '0 0', 27 offset_pointer: '0 0' 28 }; 29 9 30 $.fn.dolPopup = function(options) { 10 31 var options = options || {}; 11 var defaults = { 12 closeOnOuterClick: true, 13 closeElement: '.bx-popup-element-close', // link to element which will close popup 14 position: 'centered', // | 'absolute' | 'fixed' | event | element, 15 fog: {color: '#fff', opacity: .7}, // {color, opacity}, 16 pointer: false, // {el:(string_id|jquery_object), align: (left|right|center)}, 17 left: 0, // only for fixed or absolute 18 top: 0, // only for fixed 19 onBeforeShow: function () {}, 20 onShow: function () {}, 21 onBeforeHide: function () {}, 22 onHide: function () {}, 23 speed: 150 24 }; 25 26 var o = $.extend({}, defaults, options); 27 28 var defaults_pointer = { 29 align: 'right', 30 offset: '0 0', 31 offset_pointer: '0 0', 32 } 32 var o = $.extend({}, $.fn.dolPopupDefaultOptions, options); 33 33 34 34 if (false != o.pointer) { 35 35 o.fog = false; 36 o.pointer = $.extend({}, defaults_pointer, $(document).data('bx-popup-options') ? $(document).data('bx-popup-options') : {}, o.pointer);36 o.pointer = $.extend({}, $.fn.dolPopupDefaultPointerOptions, $(document).data('bx-popup-options') ? $(document).data('bx-popup-options') : {}, o.pointer); 37 37 } 38 38 … … 163 163 164 164 $.fn.dolPopupAjax = function(options) { 165 165 166 166 if ('undefined' == typeof(options) || 'object' != typeof(options) || 'undefined' == typeof(options.url)) 167 167 return; … … 169 169 var bx_menu_on = function (e, b) { 170 170 var li = $(e).parents('li:first'); 171 if (!li.length) 172 return; 171 173 if (b) { 172 174 var ul = $(e).parents('ul:first'); … … 180 182 var bx_menu_is_on = function (e) { 181 183 var li = $(e).parents('li:first'); 184 if (!li.length) 185 return false; 182 186 return li.hasClass('bx-menu-tab-active'); 183 187 } … … 185 189 return this.each(function() { 186 190 var e = $(this); 187 188 var id = ('undefined' == typeof(options.id) ? parseInt(2147483647 * Math.random()) : options.id); 189 190 if ($("#bx-popup-ajax-" + id + ":visible").length) { 191 var id; 192 193 // get id 194 if ('undefined' == typeof(e.attr('bx-popup-id'))) { 195 id = ('undefined' == typeof(options.id) ? parseInt(2147483647 * Math.random()) : options.id); 196 e.attr('bx-popup-id', id); 197 } else { 198 id = e.attr('bx-popup-id'); 199 } 200 201 if ($("#bx-popup-ajax-wrapper-" + id + ":visible").length) { // if popup exists and is shown - hide it 191 202 192 $("#bx-popup-ajax-" + id).dolPopupHide(); 193 194 } else if ($("#bx-popup-ajax-" + id).length) { 195 196 bx_menu_on(e, true); 197 $("#bx-popup-ajax-" + id).dolPopup({ 198 pointer: {el:$(e)}, 203 $("#bx-popup-ajax-wrapper-" + id).dolPopupHide(); 204 205 } else if ($("#bx-popup-ajax-wrapper-" + id).length) { // if popup exists but not shown - unhide it 206 207 if (!$.isWindow(e[0])) 208 bx_menu_on(e, true); 209 210 $("#bx-popup-ajax-wrapper-" + id).dolPopup({ 211 pointer: $.isWindow(e[0]) ? false : {el:$(e), align:'center'}, 199 212 onHide: function () { 200 bx_menu_on(e, false); 213 if (!$.isWindow(e[0])) 214 bx_menu_on(e, false); 201 215 } 202 216 }); 203 217 204 } else { 205 206 bx_menu_on(e, true); 207 bx_loading_content($('#bx-popup-loading .bx-popup-ajax-content'), true, true); 208 $('#bx-popup-loading').dolPopup({ 209 pointer: {el:e}, 210 closeOnOuterClick: false 211 }); 212 $('<div id="bx-popup-ajax-' + id + '" style="display:none;"><div>').appendTo($('body')).load(sUrlRoot + options.url, 213 function() { 214 if (!bx_menu_is_on(e)) 215 return; 216 $('#bx-popup-loading').dolPopupHide({ 217 onHide: function () { 218 $('#bx-popup-ajax-' + id).dolPopup({ 219 pointer: {el:e}, 220 onHide: function () { 221 bx_menu_on(e, false); 222 } 223 }); 224 } 225 }); 218 } else { // if popup doesn't exists - create new one from provided url 219 220 if (!$.isWindow(e[0])) 221 bx_menu_on(e, true); 222 223 $('body').append('<div id="bx-popup-ajax-wrapper-' + id + '" style="display:none;">' + $('#bx-popup-loading').html() + '</div>'); 224 bx_loading_content($('#bx-popup-ajax-wrapper-' + id + ' .bx-popup-ajax-content'), true, true); 225 console.log('iswin:' + $.isWindow(e[0]) + " / "); 226 console.log(e); 227 $('#bx-popup-ajax-wrapper-' + id).dolPopup({ 228 pointer: $.isWindow(e[0]) ? false : {el:e, align:'center'}, 229 onHide: function () { 230 if (!$.isWindow(e[0])) 231 bx_menu_on(e, false); 226 232 } 227 ); 233 }); 234 235 $('#bx-popup-ajax-wrapper-' + id + ' .bx-popup-ajax-content').load(sUrlRoot + options.url, function () { 236 $('#bx-popup-ajax-wrapper-' + id)._dolPopupSetPosition({ 237 pointer: $.isWindow(e[0]) ? false : {el:e, align:'center'} 238 }); 239 }); 228 240 229 241 } … … 232 244 }; 233 245 234 $.fn._dolPopupSetPosition = function(o) { 246 $.fn._dolPopupSetPosition = function(options) { 247 248 var o = $.extend({}, $.fn.dolPopupDefaultOptions, options); 249 250 if (undefined != o.pointer && false != o.pointer) 251 o.pointer = $.extend({}, $.fn.dolPopupDefaultPointerOptions, $(document).data('bx-popup-options') ? $(document).data('bx-popup-options') : {}, o.pointer); 252 235 253 return this.each(function() { 236 254 var $el = $(this); -
trunk/menu.php
r15942 r15946 23 23 24 24 header('Content-type: text/html; charset=utf-8'); 25 echo $oMenu->getCode ForPopup();25 echo $oMenu->getCode (); 26 26 27 27 /** @} */ -
trunk/samples/popup.php
r15931 r15946 22 22 23 23 if( isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) and $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' ) { 24 echo BxTemplFunctions::getInstance()->transBox('<div class="bx-def-padding bx-def-color-bg-block">AJAX content here: ' . date(DATE_RFC822) . '</div>'); 24 sleep(2); // to see AJAX loader 25 echo date(DATE_RFC822); 25 26 exit; 26 27 } … … 45 46 46 47 // transBox AJAX 47 echo ' 48 <script> 49 function bx_sample_ajax_popup () { 50 $("#bx-sample-popup-ajax").remove(); 51 $(\'<div id="bx-sample-popup-ajax" style="display: none;"></div>\').prependTo("body").load( 52 "' . BX_DOL_URL_ROOT . 'samples/popup.php", 53 function() { 54 $(this).dolPopup(); 55 } 56 ); 57 } 58 </script>'; 59 echo '<button class="bx-btn bx-def-margin-left" onclick="bx_sample_ajax_popup ()">transBox AJAX</button>'; 48 echo '<button class="bx-btn bx-def-margin-left" onclick="$(window).dolPopupAjax({url: \'samples/popup.php\'})">transBox AJAX</button>'; 60 49 61 50 // popupBox … … 82 71 echo '<button class="bx-btn bx-def-margin-left" onclick="$(\'#bx-sample-popup-box-with-pointer\').dolPopup({pointer:{el:$(this)}})">popupBox with pointer</button>'; 83 72 73 // popupBox with pointer AJAX 74 echo BxTemplFunctions::getInstance()->popupBox('bx-sample-popup-box-with-pointer', 'popupBox', 'popupBox with pointer AJAX', array(), true); 75 echo '<button class="bx-btn bx-def-margin-left" onclick="$(this).dolPopupAjax({url: \'samples/popup.php\'})">popupBox with pointer AJAX</button>'; 76 84 77 echo '<div class="bx-clear"></div>'; 85 78 -
trunk/templates/base/_footer.html
r15211 r15946 1 __popup_loading__ 1 2 <bx_injection:injection_footer /> 2 3 </body> -
trunk/templates/base/_header.html
r15942 r15946 27 27 __flush_header__ 28 28 <body class="bx-def-font bx-def-color-bg-page" <bx_injection:injection_body /> > 29 <bx_injection:injection_header /> 30 __popup_loading__ 29 <bx_injection:injection_header /> -
trunk/templates/base/css/menu.css
r15942 r15946 101 101 .bx-menu-main li:active, 102 102 .bx-menu-main li.bx-menu-tab-active { 103 background-color:#f0f0f0; 104 103 105 -webkit-box-shadow: inset 0px 0px 8px rgba(128, 128, 128, 0.35); 104 106 -moz-box-shadow: inset 0px 0px 8px rgba(128, 128, 128, 0.35); -
trunk/templates/base/scripts/BxBaseMenu.php
r15942 r15946 45 45 46 46 /** 47 * Get menu code for displaying menu in popup.48 * @return string49 */50 public function getCodeForPopup () {51 bx_import('BxTemplFunctions');52 return BxTemplFunctions::getInstance()->transBox('<div class="bx-def-padding bx-def-color-bg-block">' . $this->getCode () . '</div>');53 }54 55 /**56 47 * Get menu items array, which are ready to pass to template. 57 48 * @return array
Note: See TracChangeset
for help on using the changeset viewer.