- Timestamp:
- 02/05/12 23:00:59 (4 months ago)
- File:
-
- 1 edited
-
trunk/inc/js/jquery.dolPopup.js (modified) (6 diffs)
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);
Note: See TracChangeset
for help on using the changeset viewer.