Skip to content

Commit ea51234

Browse files
committed
version 1.2.0
1 parent 3759d8d commit ea51234

File tree

3 files changed

+54
-23
lines changed

3 files changed

+54
-23
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ Popular examples:
4444

4545
##Changelog
4646

47+
**1.2.0** (2013-04-17)
48+
* Add class **ajax** for A elements
49+
* Add class **ajax-to-**_value_ for A elements
50+
* Add class **ajax-from-**_value_ for A elements
51+
* Add option **ajax** for A elements
52+
4753
**1.1.0** (2013-04-02)
4854
* Add class **heightas-**_value_ for DIV elements
4955
* Add class **language-**_value_ for CODE elements

jquery.HTMLplus.js

Lines changed: 48 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
* 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
55
*
66
* Copyright (c) 2013 Andrea Vallorani, [email protected]
77
* Released under the MIT license
@@ -30,7 +30,7 @@
3030
if(typeof options[tag] === 'object'){
3131
tagOptions=options[tag];
3232
}
33-
var nodes=($root.is(tag)) ? $root : $root.find(tag+'[class]');
33+
var nodes=($root.is(tag)) ? $root : $(tag+'[class]',$root);
3434
$.fn.HTMLplus[tag](nodes,tagOptions,options.prefix);
3535
}
3636
});
@@ -48,7 +48,8 @@
4848
disabledMsg: 'alert',
4949
scroll: {speed:300,offsetY:0},
5050
notify: {life:10,type:null},
51-
dialog: {dialogClass:'htmlplus-dialog'}
51+
dialog: {dialogClass:'htmlplus-dialog'},
52+
ajax: {loadMsg:'<img src="loader.gif" />'}
5253
},options);
5354

5455
nodes.filter('.'+x+'confirm,.'+x+'dialog,.'+x+'disabled').each(function(){
@@ -126,7 +127,30 @@
126127
else if(confirm(msg)) return a.data('confirmed',true).triggerHandler('click');
127128
return false;
128129
}
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')){
130154
if(jQuery.ui){
131155
var dSett=$.extend({},options.dialog,a.classPre(x+'dialog',1));
132156
if(!IsAnchor(url)){
@@ -302,29 +326,30 @@
302326
if(heightas){
303327
var newHeight=0;
304328
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);
314334
}
315335
else{
316-
newHeight=$el.parent().height();
336+
newHeight=body.height();
317337
}
338+
}
339+
else{
340+
newHeight=$el.parent().height();
341+
}
318342
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+
});
325349
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();
328353
}
329354

330355
if($el.height()<newHeight) $el.css('height',newHeight);

loader.gif

723 Bytes
Loading

0 commit comments

Comments
 (0)