|
1 | 1 | /*!
|
2 | 2 | * jQuery HTMLplus plugin
|
3 |
| - * Version 1.1.0 |
4 |
| - * @requires jQuery v1.3.2 or later |
| 3 | + * Version 1.2.0 |
| 4 | + * @requires jQuery v1.5.0 or later |
5 | 5 | *
|
6 | 6 | * Copyright (c) 2013 Andrea Vallorani, [email protected]
|
7 | 7 | * Released under the MIT license
|
|
30 | 30 | if(typeof options[tag] === 'object'){
|
31 | 31 | tagOptions=options[tag];
|
32 | 32 | }
|
33 |
| - var nodes=($root.is(tag)) ? $root : $root.find(tag+'[class]'); |
| 33 | + var nodes=($root.is(tag)) ? $root : $(tag+'[class]',$root); |
34 | 34 | $.fn.HTMLplus[tag](nodes,tagOptions,options.prefix);
|
35 | 35 | }
|
36 | 36 | });
|
|
48 | 48 | disabledMsg: 'alert',
|
49 | 49 | scroll: {speed:300,offsetY:0},
|
50 | 50 | notify: {life:10,type:null},
|
51 |
| - dialog: {dialogClass:'htmlplus-dialog'} |
| 51 | + dialog: {dialogClass:'htmlplus-dialog'}, |
| 52 | + ajax: {loadMsg:'<img src="loader.gif" />'} |
52 | 53 | },options);
|
53 | 54 |
|
54 | 55 | nodes.filter('.'+x+'confirm,.'+x+'dialog,.'+x+'disabled').each(function(){
|
|
126 | 127 | else if(confirm(msg)) return a.data('confirmed',true).triggerHandler('click');
|
127 | 128 | return false;
|
128 | 129 | }
|
129 |
| - if(a.hasClass(x+'dialog')){ |
| 130 | + if(a.hasClass('ajax')){ |
| 131 | + var ajaxSett=$.extend({},options.ajax,a.classPre(x+'ajax',1)); |
| 132 | + var aId = (typeof(a.attr('id'))==='undefined') ? a.text() : a.attr('id'); |
| 133 | + ajaxSett.to = (ajaxSett.to===null) ? 'body' : '#'+ajaxSett.to; |
| 134 | + if(typeof(ajaxSett.from)==='undefined' || ajaxSett.from===null) ajaxSett.from=ajaxSett.to; |
| 135 | + var to=$(ajaxSett.to); |
| 136 | + var localCache=to.children('div[data-rel="'+aId+'"]'); |
| 137 | + var toH=to.height(); |
| 138 | + to.children().hide(); |
| 139 | + if(localCache.length){ |
| 140 | + localCache.show(); |
| 141 | + } |
| 142 | + else{ |
| 143 | + var container=$('<div data-rel="'+aId+'" />'); |
| 144 | + container.html('<div class="loader" style="text-align:center;line-height:'+toH+'px;">'+ajaxSett.loadMsg+'</div>').appendTo(to); |
| 145 | + $.ajax({url:url,dataType:'html'}).done(function(data){ |
| 146 | + data = '<div>'+data.replace(/^[\s\S]*<body.*?>|<\/body>[\s\S]*$/g, '')+'</div>'; |
| 147 | + if(ajaxSett.to==='body') container.html($(data).html()); |
| 148 | + else container.html($(data).find(ajaxSett.from).html()); |
| 149 | + }); |
| 150 | + } |
| 151 | + return false; |
| 152 | + } |
| 153 | + else if(a.hasClass(x+'dialog')){ |
130 | 154 | if(jQuery.ui){
|
131 | 155 | var dSett=$.extend({},options.dialog,a.classPre(x+'dialog',1));
|
132 | 156 | if(!IsAnchor(url)){
|
|
302 | 326 | if(heightas){
|
303 | 327 | var newHeight=0;
|
304 | 328 | switch(heightas){
|
305 |
| - case 'parent': |
306 |
| - if($el.parent().is('body')){ |
307 |
| - var body=$el.parent(); |
308 |
| - if($(window).height()>body.height()){ |
309 |
| - newHeight=$(window).height()-parseInt(body.css('marginTop'),10)-parseInt(body.css('marginBottom'),10); |
310 |
| - } |
311 |
| - else{ |
312 |
| - newHeight=body.height(); |
313 |
| - } |
| 329 | + case 'parent': |
| 330 | + if($el.parent().is('body')){ |
| 331 | + var body=$el.parent(); |
| 332 | + if($(window).height()>body.height()){ |
| 333 | + newHeight=$(window).height()-parseInt(body.css('marginTop'),10)-parseInt(body.css('marginBottom'),10); |
314 | 334 | }
|
315 | 335 | else{
|
316 |
| - newHeight=$el.parent().height(); |
| 336 | + newHeight=body.height(); |
317 | 337 | }
|
| 338 | + } |
| 339 | + else{ |
| 340 | + newHeight=$el.parent().height(); |
| 341 | + } |
318 | 342 | break;
|
319 |
| - case 'sibling': |
320 |
| - $el.parent().children('div').each(function(){ |
321 |
| - if($(this).height()>newHeight){ |
322 |
| - newHeight=$(this).height(); |
323 |
| - } |
324 |
| - }); |
| 343 | + case 'sibling': |
| 344 | + $el.parent().children('div').each(function(){ |
| 345 | + if($(this).height()>newHeight){ |
| 346 | + newHeight=$(this).height(); |
| 347 | + } |
| 348 | + }); |
325 | 349 | break;
|
326 |
| - default: var $obj=$('#'+heightas); |
327 |
| - if($obj.length) newHeight=$obj.eq(0).height(); |
| 350 | + default: |
| 351 | + var $obj=$('#'+heightas); |
| 352 | + if($obj.length) newHeight=$obj.eq(0).height(); |
328 | 353 | }
|
329 | 354 |
|
330 | 355 | if($el.height()<newHeight) $el.css('height',newHeight);
|
|
0 commit comments