Skip to content

Commit 26dbaf2

Browse files
committed
Merge remote-tracking branch 'origin/maint-v1.2'
2 parents 74e8089 + 37eed39 commit 26dbaf2

File tree

4 files changed

+49
-24
lines changed

4 files changed

+49
-24
lines changed

changes.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@
4040

4141
- Add a new [gallery](demo/gallery/index.html) pattern.
4242

43+
44+
## 1.2.1 - Released April 5, 2013
45+
46+
- Fix use of an undeclared variable in the parser could result in problems
47+
in IE8. This fixes
48+
[Ticket 298](https://github.com/Patternslib/Patterns/issues/298).
49+
4350
- Fix handling of trailing semicolons in the the argument parser. This fixes
4451
[Ticket 295](https://github.com/Patternslib/Patterns/issues/295).
4552

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
"jcrop",
4646
"jquery",
4747
"jquery.anythingslider",
48-
"jquery.autosuggest",
4948
"jquery.chosen",
5049
"jquery.form",
5150
"jquery.fullcalendar",

src/pat/inject.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,25 @@ define([
251251

252252
// perform injection
253253
cfg.$target.each(function() {
254+
var $src;
255+
256+
// $source.clone() does not work with shived elements in IE8
257+
if (document.all && document.querySelector &&
258+
!document.addEventListener) {
259+
$src = $source.map(function() {
260+
return $(this.outerHTML)[0];
261+
});
262+
} else {
263+
$src = $source.clone();
264+
}
265+
254266
var $target = $(this),
255-
$src = $source.clone(),
256267
$injected = cfg.$injected || $src;
268+
269+
$src.findInclusive('img').on('load', function() {
270+
$(this).trigger('pat-inject-content-loaded');
271+
});
272+
257273
if (_._inject($src, $target, cfg.action, cfg["class"])) {
258274
$injected.filter(function() {
259275
// setting data on textnode fails in IE8
@@ -425,6 +441,14 @@ define([
425441
$this.attr(attrName, value);
426442
}
427443
});
444+
// XXX: IE8 changes the order of attributes in html. The following
445+
// lines move data-pat-inject-rebase-src to src.
446+
$page.find('[data-pat-inject-rebase-src]').each(function() {
447+
var $el = $(this);
448+
$el.attr('src', $el.attr('data-pat-inject-rebase-src'))
449+
.removeAttr('data-pat-inject-rebase-src');
450+
});
451+
428452
return $page.html().replace(
429453
/src="" data-pat-inject-rebase-/g, ''
430454
).trim();

src/pat/modal.js

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ define([
22
"jquery",
33
"../core/parser",
44
"../registry",
5+
"../utils",
56
"./inject"
6-
], function($, Parser, registry, inject) {
7+
], function($, Parser, registry, utils, inject) {
78
var parser = new Parser("modal");
89

910
parser.add_argument("class");
@@ -66,17 +67,14 @@ define([
6667
},
6768

6869
setPosition: function() {
69-
// bail if repositioning already in progress
70-
if ($('#pat-modal-clone').length > 0) {
70+
var $el = $('div.pat-modal,#pat-modal');
71+
if ($el.length === 0) {
7172
return;
7273
}
7374

74-
var $el = $('div.pat-modal,#pat-modal'),
75-
maxHeight = $(window).innerHeight() - $el.outerHeight(true) +
76-
$el.outerHeight();
77-
78-
if ($el.length === 0) {
79-
return;
75+
var $oldClone = $('#pat-modal-clone');
76+
if ($oldClone.length > 0) {
77+
$oldClone.remove();
8078
}
8179

8280
var $clone = $el.clone();
@@ -86,35 +84,30 @@ define([
8684
.css({
8785
'visibility': 'hidden',
8886
'position': 'absolute',
89-
'height': '',
90-
'max-height': maxHeight
87+
'height': ''
9188
}).appendTo('body');
9289

9390
// wait for browser to update DOM
9491
setTimeout(modal.measure, 0);
9592
},
9693

9794
measure: function() {
95+
var $clone = $('#pat-modal-clone');
96+
if ($clone.length === 0) {
97+
return;
98+
}
99+
98100
var $el = $('div.pat-modal,#pat-modal'),
99-
$clone = $('#pat-modal-clone'),
100101
maxHeight = $(window).innerHeight() - $clone.outerHeight(true) +
101102
$clone.outerHeight(),
102103
height = $clone.outerHeight();
103104

104105
$clone.remove();
105106

106107
if (maxHeight - height < 0) {
107-
$el.addClass('max-height')
108-
.css({
109-
'height': maxHeight,
110-
'max-height': ''
111-
});
108+
$el.addClass('max-height').css('height', maxHeight);
112109
} else {
113-
$el.removeClass('max-height')
114-
.css({
115-
'height': '',
116-
'max-height': maxHeight
117-
});
110+
$el.removeClass('max-height').css('height', '');
118111
}
119112

120113
var top = ($(window).innerHeight() - $el.outerHeight(true)) / 2;
@@ -130,6 +123,8 @@ define([
130123
};
131124

132125
$(window).on('resize.pat-modal-position', modal.setPosition);
126+
$(window).on('pat-inject-content-loaded.pat-modal-position', '#pat-modal',
127+
modal.setPosition);
133128
$(document).on('patterns-injected.pat-modal-position', '#pat-modal,div.pat-modal',
134129
modal.setPosition);
135130

0 commit comments

Comments
 (0)