ink_ui_rails 2.1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.md +21 -0
- data/README.md +39 -0
- data/lib/ink_ui_rails.rb +8 -0
- data/lib/ink_ui_rails/version.rb +3 -0
- data/vendor/assets/fonts/font/FontAwesome.otf +0 -0
- data/vendor/assets/fonts/font/fontawesome-webfont.eot +0 -0
- data/vendor/assets/fonts/font/fontawesome-webfont.svg +399 -0
- data/vendor/assets/fonts/font/fontawesome-webfont.ttf +0 -0
- data/vendor/assets/fonts/font/fontawesome-webfont.woff +0 -0
- data/vendor/assets/fonts/font/ubuntu-b-webfont.eot +0 -0
- data/vendor/assets/fonts/font/ubuntu-b-webfont.svg +245 -0
- data/vendor/assets/fonts/font/ubuntu-b-webfont.ttf +0 -0
- data/vendor/assets/fonts/font/ubuntu-b-webfont.woff +0 -0
- data/vendor/assets/fonts/font/ubuntu-bi-webfont.eot +0 -0
- data/vendor/assets/fonts/font/ubuntu-bi-webfont.svg +245 -0
- data/vendor/assets/fonts/font/ubuntu-bi-webfont.ttf +0 -0
- data/vendor/assets/fonts/font/ubuntu-bi-webfont.woff +0 -0
- data/vendor/assets/fonts/font/ubuntu-c-webfont.eot +0 -0
- data/vendor/assets/fonts/font/ubuntu-c-webfont.svg +245 -0
- data/vendor/assets/fonts/font/ubuntu-c-webfont.ttf +0 -0
- data/vendor/assets/fonts/font/ubuntu-c-webfont.woff +0 -0
- data/vendor/assets/fonts/font/ubuntu-l-webfont.eot +0 -0
- data/vendor/assets/fonts/font/ubuntu-l-webfont.svg +245 -0
- data/vendor/assets/fonts/font/ubuntu-l-webfont.ttf +0 -0
- data/vendor/assets/fonts/font/ubuntu-l-webfont.woff +0 -0
- data/vendor/assets/fonts/font/ubuntu-li-webfont.eot +0 -0
- data/vendor/assets/fonts/font/ubuntu-li-webfont.svg +245 -0
- data/vendor/assets/fonts/font/ubuntu-li-webfont.ttf +0 -0
- data/vendor/assets/fonts/font/ubuntu-li-webfont.woff +0 -0
- data/vendor/assets/fonts/font/ubuntu-m-webfont.eot +0 -0
- data/vendor/assets/fonts/font/ubuntu-m-webfont.svg +245 -0
- data/vendor/assets/fonts/font/ubuntu-m-webfont.ttf +0 -0
- data/vendor/assets/fonts/font/ubuntu-m-webfont.woff +0 -0
- data/vendor/assets/fonts/font/ubuntu-mi-webfont.eot +0 -0
- data/vendor/assets/fonts/font/ubuntu-mi-webfont.svg +245 -0
- data/vendor/assets/fonts/font/ubuntu-mi-webfont.ttf +0 -0
- data/vendor/assets/fonts/font/ubuntu-mi-webfont.woff +0 -0
- data/vendor/assets/fonts/font/ubuntu-r-webfont.eot +0 -0
- data/vendor/assets/fonts/font/ubuntu-r-webfont.svg +245 -0
- data/vendor/assets/fonts/font/ubuntu-r-webfont.ttf +0 -0
- data/vendor/assets/fonts/font/ubuntu-r-webfont.woff +0 -0
- data/vendor/assets/fonts/font/ubuntu-ri-webfont.eot +0 -0
- data/vendor/assets/fonts/font/ubuntu-ri-webfont.svg +245 -0
- data/vendor/assets/fonts/font/ubuntu-ri-webfont.ttf +0 -0
- data/vendor/assets/fonts/font/ubuntu-ri-webfont.woff +0 -0
- data/vendor/assets/fonts/font/ubuntumono-b-webfont.eot +0 -0
- data/vendor/assets/fonts/font/ubuntumono-b-webfont.svg +242 -0
- data/vendor/assets/fonts/font/ubuntumono-b-webfont.ttf +0 -0
- data/vendor/assets/fonts/font/ubuntumono-b-webfont.woff +0 -0
- data/vendor/assets/fonts/font/ubuntumono-bi-webfont.eot +0 -0
- data/vendor/assets/fonts/font/ubuntumono-bi-webfont.svg +242 -0
- data/vendor/assets/fonts/font/ubuntumono-bi-webfont.ttf +0 -0
- data/vendor/assets/fonts/font/ubuntumono-bi-webfont.woff +0 -0
- data/vendor/assets/fonts/font/ubuntumono-r-webfont.eot +0 -0
- data/vendor/assets/fonts/font/ubuntumono-r-webfont.svg +242 -0
- data/vendor/assets/fonts/font/ubuntumono-r-webfont.ttf +0 -0
- data/vendor/assets/fonts/font/ubuntumono-r-webfont.woff +0 -0
- data/vendor/assets/fonts/font/ubuntumono-ri-webfont.eot +0 -0
- data/vendor/assets/fonts/font/ubuntumono-ri-webfont.svg +242 -0
- data/vendor/assets/fonts/font/ubuntumono-ri-webfont.ttf +0 -0
- data/vendor/assets/fonts/font/ubuntumono-ri-webfont.woff +0 -0
- data/vendor/assets/images/img/SAPOlogo.png +0 -0
- data/vendor/assets/images/img/favicon.ico +0 -0
- data/vendor/assets/images/img/home_bkg.png +0 -0
- data/vendor/assets/images/img/home_logo_IE.jpg +0 -0
- data/vendor/assets/images/img/icon_Sprite.png +0 -0
- data/vendor/assets/images/img/ink-favicon.ico +0 -0
- data/vendor/assets/images/img/logo_home.png +0 -0
- data/vendor/assets/images/img/shot_ink.png +0 -0
- data/vendor/assets/images/img/shot_intra.png +0 -0
- data/vendor/assets/images/img/shot_livebots.png +0 -0
- data/vendor/assets/images/img/shot_meo.png +0 -0
- data/vendor/assets/images/img/shot_musicbox.png +0 -0
- data/vendor/assets/images/img/shot_pessoa.png +0 -0
- data/vendor/assets/images/img/splash.1024x748.png +0 -0
- data/vendor/assets/images/img/splash.320x460.png +0 -0
- data/vendor/assets/images/img/splash.768x1004.png +0 -0
- data/vendor/assets/images/img/touch-icon.114.png +0 -0
- data/vendor/assets/images/img/touch-icon.16.png +0 -0
- data/vendor/assets/images/img/touch-icon.256.png +0 -0
- data/vendor/assets/images/img/touch-icon.57.png +0 -0
- data/vendor/assets/images/img/touch-icon.72.png +0 -0
- data/vendor/assets/javascripts/autoload.js +85 -0
- data/vendor/assets/javascripts/example.json +1174 -0
- data/vendor/assets/javascripts/holder.js +440 -0
- data/vendor/assets/javascripts/html5shiv-printshiv.js +496 -0
- data/vendor/assets/javascripts/html5shiv.js +298 -0
- data/vendor/assets/javascripts/ink-all.js +18015 -0
- data/vendor/assets/javascripts/ink-ui.js +7737 -0
- data/vendor/assets/javascripts/ink.aux.js +506 -0
- data/vendor/assets/javascripts/ink.close.js +54 -0
- data/vendor/assets/javascripts/ink.datepicker.js +1194 -0
- data/vendor/assets/javascripts/ink.datepicker.pt.js +32 -0
- data/vendor/assets/javascripts/ink.draggable.js +437 -0
- data/vendor/assets/javascripts/ink.droppable.js +193 -0
- data/vendor/assets/javascripts/ink.formvalidator.js +712 -0
- data/vendor/assets/javascripts/ink.gallery.js +757 -0
- data/vendor/assets/javascripts/ink.imagequery.js +259 -0
- data/vendor/assets/javascripts/ink.js +10278 -0
- data/vendor/assets/javascripts/ink.modal.js +628 -0
- data/vendor/assets/javascripts/ink.pagination.js +473 -0
- data/vendor/assets/javascripts/ink.progressbar.js +110 -0
- data/vendor/assets/javascripts/ink.smoothscroller.js +234 -0
- data/vendor/assets/javascripts/ink.sortablelist.js +338 -0
- data/vendor/assets/javascripts/ink.spy.js +123 -0
- data/vendor/assets/javascripts/ink.sticky.js +254 -0
- data/vendor/assets/javascripts/ink.table.js +621 -0
- data/vendor/assets/javascripts/ink.tabs.js +426 -0
- data/vendor/assets/javascripts/ink.toggle.js +218 -0
- data/vendor/assets/javascripts/ink.treeview.js +179 -0
- data/vendor/assets/javascripts/ink_ui.js +1 -0
- data/vendor/assets/javascripts/modernizr.js +815 -0
- data/vendor/assets/javascripts/prettify.js +28 -0
- data/vendor/assets/stylesheets/ink/_ink-ie7.css +1662 -0
- data/vendor/assets/stylesheets/ink/_ink.css +7496 -0
- data/vendor/assets/stylesheets/ink/ink_ui.scss.css +2 -0
- data/vendor/assets/stylesheets/ink_ui.scss.css +1 -0
- metadata +203 -0
@@ -0,0 +1,440 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
Holder - 1.9 - client side image placeholders
|
4
|
+
(c) 2012-2013 Ivan Malopinsky / http://imsky.co
|
5
|
+
|
6
|
+
Provided under the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
Commercial use requires attribution.
|
8
|
+
|
9
|
+
*/
|
10
|
+
|
11
|
+
var Holder = Holder || {};
|
12
|
+
(function (app, win) {
|
13
|
+
|
14
|
+
var preempted = false,
|
15
|
+
fallback = false,
|
16
|
+
canvas = document.createElement('canvas');
|
17
|
+
|
18
|
+
//getElementsByClassName polyfill
|
19
|
+
document.getElementsByClassName||(document.getElementsByClassName=function(e){var t=document,n,r,i,s=[];if(t.querySelectorAll)return t.querySelectorAll("."+e);if(t.evaluate){r=".//*[contains(concat(' ', @class, ' '), ' "+e+" ')]",n=t.evaluate(r,t,null,0,null);while(i=n.iterateNext())s.push(i)}else{n=t.getElementsByTagName("*"),r=new RegExp("(^|\\s)"+e+"(\\s|$)");for(i=0;i<n.length;i++)r.test(n[i].className)&&s.push(n[i])}return s})
|
20
|
+
|
21
|
+
//getComputedStyle polyfill
|
22
|
+
window.getComputedStyle||(window.getComputedStyle=function(e,t){return this.el=e,this.getPropertyValue=function(t){var n=/(\-([a-z]){1})/g;return t=="float"&&(t="styleFloat"),n.test(t)&&(t=t.replace(n,function(){return arguments[2].toUpperCase()})),e.currentStyle[t]?e.currentStyle[t]:null},this})
|
23
|
+
|
24
|
+
//http://javascript.nwbox.com/ContentLoaded by Diego Perini with modifications
|
25
|
+
function contentLoaded(n,t){var l="complete",s="readystatechange",u=!1,h=u,c=!0,i=n.document,a=i.documentElement,e=i.addEventListener?"addEventListener":"attachEvent",v=i.addEventListener?"removeEventListener":"detachEvent",f=i.addEventListener?"":"on",r=function(e){(e.type!=s||i.readyState==l)&&((e.type=="load"?n:i)[v](f+e.type,r,u),!h&&(h=!0)&&t.call(n,null))},o=function(){try{a.doScroll("left")}catch(n){setTimeout(o,50);return}r("poll")};if(i.readyState==l)t.call(n,"lazy");else{if(i.createEventObject&&a.doScroll){try{c=!n.frameElement}catch(y){}c&&o()}i[e](f+"DOMContentLoaded",r,u),i[e](f+s,r,u),n[e](f+"load",r,u)}};
|
26
|
+
|
27
|
+
//https://gist.github.com/991057 by Jed Schmidt with modifications
|
28
|
+
function selector(a){
|
29
|
+
a=a.match(/^(\W)?(.*)/);var b=document["getElement"+(a[1]?a[1]=="#"?"ById":"sByClassName":"sByTagName")](a[2]);
|
30
|
+
var ret=[]; b!=null&&(b.length?ret=b:b.length==0?ret=b:ret=[b]); return ret;
|
31
|
+
}
|
32
|
+
|
33
|
+
//shallow object property extend
|
34
|
+
function extend(a,b){var c={};for(var d in a)c[d]=a[d];for(var e in b)c[e]=b[e];return c}
|
35
|
+
|
36
|
+
//hasOwnProperty polyfill
|
37
|
+
if (!Object.prototype.hasOwnProperty)
|
38
|
+
Object.prototype.hasOwnProperty = function(prop) {
|
39
|
+
var proto = this.__proto__ || this.constructor.prototype;
|
40
|
+
return (prop in this) && (!(prop in proto) || proto[prop] !== this[prop]);
|
41
|
+
}
|
42
|
+
|
43
|
+
function text_size(width, height, template) {
|
44
|
+
var dimension_arr = [height, width].sort();
|
45
|
+
var maxFactor = Math.round(dimension_arr[1] / 16),
|
46
|
+
minFactor = Math.round(dimension_arr[0] / 16);
|
47
|
+
var text_height = Math.max(template.size, maxFactor);
|
48
|
+
return {
|
49
|
+
height: text_height
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
function draw(ctx, dimensions, template, ratio) {
|
54
|
+
var ts = text_size(dimensions.width, dimensions.height, template);
|
55
|
+
var text_height = ts.height;
|
56
|
+
var width = dimensions.width * ratio,
|
57
|
+
height = dimensions.height * ratio;
|
58
|
+
var font = template.font ? template.font : "sans-serif";
|
59
|
+
canvas.width = width;
|
60
|
+
canvas.height = height;
|
61
|
+
ctx.textAlign = "center";
|
62
|
+
ctx.textBaseline = "middle";
|
63
|
+
ctx.fillStyle = template.background;
|
64
|
+
ctx.fillRect(0, 0, width, height);
|
65
|
+
ctx.fillStyle = template.foreground;
|
66
|
+
ctx.font = "bold " + text_height + "px " + font;
|
67
|
+
var text = template.text ? template.text : (dimensions.width + "x" + dimensions.height);
|
68
|
+
if (ctx.measureText(text).width / width > 1) {
|
69
|
+
text_height = template.size / (ctx.measureText(text).width / width);
|
70
|
+
}
|
71
|
+
//Resetting font size if necessary
|
72
|
+
ctx.font = "bold " + (text_height * ratio) + "px " + font;
|
73
|
+
ctx.fillText(text, (width / 2), (height / 2), width);
|
74
|
+
return canvas.toDataURL("image/png");
|
75
|
+
}
|
76
|
+
|
77
|
+
function render(mode, el, holder, src) {
|
78
|
+
var dimensions = holder.dimensions,
|
79
|
+
theme = holder.theme,
|
80
|
+
text = holder.text ? decodeURIComponent(holder.text) : holder.text;
|
81
|
+
var dimensions_caption = dimensions.width + "x" + dimensions.height;
|
82
|
+
|
83
|
+
theme = (text ? extend(theme, {
|
84
|
+
text: text
|
85
|
+
}) : theme);
|
86
|
+
theme = (holder.font ? extend(theme, {
|
87
|
+
font: holder.font
|
88
|
+
}) : theme);
|
89
|
+
|
90
|
+
if (mode == "image") {
|
91
|
+
el.setAttribute("data-src", src);
|
92
|
+
el.setAttribute("alt", text ? text : theme.text ? theme.text + " [" + dimensions_caption + "]" : dimensions_caption);
|
93
|
+
|
94
|
+
if (fallback || !holder.auto) {
|
95
|
+
el.style.width = dimensions.width + "px";
|
96
|
+
el.style.height = dimensions.height + "px";
|
97
|
+
}
|
98
|
+
|
99
|
+
if (fallback) {
|
100
|
+
el.style.backgroundColor = theme.background;
|
101
|
+
|
102
|
+
} else {
|
103
|
+
el.setAttribute("src", draw(ctx, dimensions, theme, ratio));
|
104
|
+
}
|
105
|
+
} else {
|
106
|
+
if (!fallback) {
|
107
|
+
el.style.backgroundImage = "url(" + draw(ctx, dimensions, theme, ratio) + ")";
|
108
|
+
el.style.backgroundSize = dimensions.width + "px " + dimensions.height + "px";
|
109
|
+
}
|
110
|
+
}
|
111
|
+
};
|
112
|
+
|
113
|
+
function fluid(el, holder, src) {
|
114
|
+
var dimensions = holder.dimensions,
|
115
|
+
theme = holder.theme,
|
116
|
+
text = holder.text;
|
117
|
+
var dimensions_caption = dimensions.width + "x" + dimensions.height;
|
118
|
+
theme = (text ? extend(theme, {
|
119
|
+
text: text
|
120
|
+
}) : theme);
|
121
|
+
|
122
|
+
var fluid = document.createElement("div");
|
123
|
+
|
124
|
+
if (el.fluidRef) {
|
125
|
+
fluid = el.fluidRef;
|
126
|
+
}
|
127
|
+
|
128
|
+
fluid.style.backgroundColor = theme.background;
|
129
|
+
fluid.style.color = theme.foreground;
|
130
|
+
fluid.className = el.className + " holderjs-fluid";
|
131
|
+
fluid.style.width = holder.dimensions.width + (holder.dimensions.width.indexOf("%") > 0 ? "" : "px");
|
132
|
+
fluid.style.height = holder.dimensions.height + (holder.dimensions.height.indexOf("%") > 0 ? "" : "px");
|
133
|
+
fluid.id = el.id;
|
134
|
+
|
135
|
+
el.style.width = 0;
|
136
|
+
el.style.height = 0;
|
137
|
+
|
138
|
+
if (!el.fluidRef) {
|
139
|
+
|
140
|
+
if (theme.text) {
|
141
|
+
fluid.appendChild(document.createTextNode(theme.text))
|
142
|
+
} else {
|
143
|
+
fluid.appendChild(document.createTextNode(dimensions_caption))
|
144
|
+
fluid_images.push(fluid);
|
145
|
+
setTimeout(fluid_update, 0);
|
146
|
+
}
|
147
|
+
|
148
|
+
}
|
149
|
+
|
150
|
+
el.fluidRef = fluid;
|
151
|
+
el.parentNode.insertBefore(fluid, el.nextSibling)
|
152
|
+
|
153
|
+
if (window.jQuery) {
|
154
|
+
jQuery(function ($) {
|
155
|
+
$(el).on("load", function () {
|
156
|
+
el.style.width = fluid.style.width;
|
157
|
+
el.style.height = fluid.style.height;
|
158
|
+
$(el).show();
|
159
|
+
$(fluid).remove();
|
160
|
+
});
|
161
|
+
})
|
162
|
+
}
|
163
|
+
}
|
164
|
+
|
165
|
+
function fluid_update() {
|
166
|
+
for (i in fluid_images) {
|
167
|
+
if (!fluid_images.hasOwnProperty(i)) continue;
|
168
|
+
var el = fluid_images[i],
|
169
|
+
label = el.firstChild;
|
170
|
+
|
171
|
+
el.style.lineHeight = el.offsetHeight + "px";
|
172
|
+
label.data = el.offsetWidth + "x" + el.offsetHeight;
|
173
|
+
}
|
174
|
+
}
|
175
|
+
|
176
|
+
function parse_flags(flags, options) {
|
177
|
+
|
178
|
+
var ret = {
|
179
|
+
theme: settings.themes.gray
|
180
|
+
}, render = false;
|
181
|
+
|
182
|
+
for (sl = flags.length, j = 0; j < sl; j++) {
|
183
|
+
var flag = flags[j];
|
184
|
+
if (app.flags.dimensions.match(flag)) {
|
185
|
+
render = true;
|
186
|
+
ret.dimensions = app.flags.dimensions.output(flag);
|
187
|
+
} else if (app.flags.fluid.match(flag)) {
|
188
|
+
render = true;
|
189
|
+
ret.dimensions = app.flags.fluid.output(flag);
|
190
|
+
ret.fluid = true;
|
191
|
+
} else if (app.flags.colors.match(flag)) {
|
192
|
+
ret.theme = app.flags.colors.output(flag);
|
193
|
+
} else if (options.themes[flag]) {
|
194
|
+
//If a theme is specified, it will override custom colors
|
195
|
+
ret.theme = options.themes[flag];
|
196
|
+
} else if (app.flags.text.match(flag)) {
|
197
|
+
ret.text = app.flags.text.output(flag);
|
198
|
+
} else if (app.flags.font.match(flag)) {
|
199
|
+
ret.font = app.flags.font.output(flag);
|
200
|
+
} else if (app.flags.auto.match(flag)) {
|
201
|
+
ret.auto = true;
|
202
|
+
}
|
203
|
+
}
|
204
|
+
|
205
|
+
return render ? ret : false;
|
206
|
+
|
207
|
+
};
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
if (!canvas.getContext) {
|
212
|
+
fallback = true;
|
213
|
+
} else {
|
214
|
+
if (canvas.toDataURL("image/png")
|
215
|
+
.indexOf("data:image/png") < 0) {
|
216
|
+
//Android doesn't support data URI
|
217
|
+
fallback = true;
|
218
|
+
} else {
|
219
|
+
var ctx = canvas.getContext("2d");
|
220
|
+
}
|
221
|
+
}
|
222
|
+
|
223
|
+
var dpr = 1, bsr = 1;
|
224
|
+
|
225
|
+
if(!fallback){
|
226
|
+
dpr = window.devicePixelRatio || 1,
|
227
|
+
bsr = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
|
228
|
+
}
|
229
|
+
|
230
|
+
var ratio = dpr / bsr;
|
231
|
+
|
232
|
+
var fluid_images = [];
|
233
|
+
|
234
|
+
var settings = {
|
235
|
+
domain: "holder.js",
|
236
|
+
images: "img",
|
237
|
+
bgnodes: ".holderjs",
|
238
|
+
themes: {
|
239
|
+
"gray": {
|
240
|
+
background: "#eee",
|
241
|
+
foreground: "#aaa",
|
242
|
+
size: 12
|
243
|
+
},
|
244
|
+
"social": {
|
245
|
+
background: "#3a5a97",
|
246
|
+
foreground: "#fff",
|
247
|
+
size: 12
|
248
|
+
},
|
249
|
+
"industrial": {
|
250
|
+
background: "#434A52",
|
251
|
+
foreground: "#C2F200",
|
252
|
+
size: 12
|
253
|
+
},
|
254
|
+
"ink": {
|
255
|
+
background: "#222",
|
256
|
+
foreground: "#fff",
|
257
|
+
size: 18
|
258
|
+
}
|
259
|
+
},
|
260
|
+
stylesheet: ".holderjs-fluid {font-size:16px;font-weight:bold;text-align:center;font-family:sans-serif;margin:0}"
|
261
|
+
};
|
262
|
+
|
263
|
+
|
264
|
+
app.flags = {
|
265
|
+
dimensions: {
|
266
|
+
regex: /^(\d+)x(\d+)$/,
|
267
|
+
output: function (val) {
|
268
|
+
var exec = this.regex.exec(val);
|
269
|
+
return {
|
270
|
+
width: +exec[1],
|
271
|
+
height: +exec[2]
|
272
|
+
}
|
273
|
+
}
|
274
|
+
},
|
275
|
+
fluid: {
|
276
|
+
regex: /^([0-9%]+)x([0-9%]+)$/,
|
277
|
+
output: function (val) {
|
278
|
+
var exec = this.regex.exec(val);
|
279
|
+
return {
|
280
|
+
width: exec[1],
|
281
|
+
height: exec[2]
|
282
|
+
}
|
283
|
+
}
|
284
|
+
},
|
285
|
+
colors: {
|
286
|
+
regex: /#([0-9a-f]{3,})\:#([0-9a-f]{3,})/i,
|
287
|
+
output: function (val) {
|
288
|
+
var exec = this.regex.exec(val);
|
289
|
+
return {
|
290
|
+
size: settings.themes.gray.size,
|
291
|
+
foreground: "#" + exec[2],
|
292
|
+
background: "#" + exec[1]
|
293
|
+
}
|
294
|
+
}
|
295
|
+
},
|
296
|
+
text: {
|
297
|
+
regex: /text\:(.*)/,
|
298
|
+
output: function (val) {
|
299
|
+
return this.regex.exec(val)[1];
|
300
|
+
}
|
301
|
+
},
|
302
|
+
font: {
|
303
|
+
regex: /font\:(.*)/,
|
304
|
+
output: function (val) {
|
305
|
+
return this.regex.exec(val)[1];
|
306
|
+
}
|
307
|
+
},
|
308
|
+
auto: {
|
309
|
+
regex: /^auto$/
|
310
|
+
}
|
311
|
+
}
|
312
|
+
|
313
|
+
for (var flag in app.flags) {
|
314
|
+
if (!app.flags.hasOwnProperty(flag)) continue;
|
315
|
+
app.flags[flag].match = function (val) {
|
316
|
+
return val.match(this.regex)
|
317
|
+
}
|
318
|
+
}
|
319
|
+
|
320
|
+
app.add_theme = function (name, theme) {
|
321
|
+
name != null && theme != null && (settings.themes[name] = theme);
|
322
|
+
return app;
|
323
|
+
};
|
324
|
+
|
325
|
+
app.add_image = function (src, el) {
|
326
|
+
var node = selector(el);
|
327
|
+
if (node.length) {
|
328
|
+
for (var i = 0, l = node.length; i < l; i++) {
|
329
|
+
var img = document.createElement("img")
|
330
|
+
img.setAttribute("data-src", src);
|
331
|
+
node[i].appendChild(img);
|
332
|
+
}
|
333
|
+
}
|
334
|
+
return app;
|
335
|
+
};
|
336
|
+
|
337
|
+
app.run = function (o) {
|
338
|
+
var options = extend(settings, o),
|
339
|
+
images = [], imageNodes = [], bgnodes = [];
|
340
|
+
|
341
|
+
if(typeof(options.images) == "string"){
|
342
|
+
imageNodes = selector(options.images);
|
343
|
+
}
|
344
|
+
else if (window.NodeList && options.images instanceof window.NodeList) {
|
345
|
+
imageNodes = options.images;
|
346
|
+
} else if (window.Node && options.images instanceof window.Node) {
|
347
|
+
imageNodes = [options.images];
|
348
|
+
}
|
349
|
+
|
350
|
+
if(typeof(options.bgnodes) == "string"){
|
351
|
+
bgnodes = selector(options.bgnodes);
|
352
|
+
} else if (window.NodeList && options.elements instanceof window.NodeList) {
|
353
|
+
bgnodes = options.bgnodes;
|
354
|
+
} else if (window.Node && options.bgnodes instanceof window.Node) {
|
355
|
+
bgnodes = [options.bgnodes];
|
356
|
+
}
|
357
|
+
|
358
|
+
preempted = true;
|
359
|
+
|
360
|
+
for (i = 0, l = imageNodes.length; i < l; i++) images.push(imageNodes[i]);
|
361
|
+
|
362
|
+
var holdercss = document.getElementById("holderjs-style");
|
363
|
+
if (!holdercss) {
|
364
|
+
holdercss = document.createElement("style");
|
365
|
+
holdercss.setAttribute("id", "holderjs-style");
|
366
|
+
holdercss.type = "text/css";
|
367
|
+
document.getElementsByTagName("head")[0].appendChild(holdercss);
|
368
|
+
}
|
369
|
+
|
370
|
+
if (!options.nocss) {
|
371
|
+
if (holdercss.styleSheet) {
|
372
|
+
holdercss.styleSheet.cssText += options.stylesheet;
|
373
|
+
} else {
|
374
|
+
holdercss.appendChild(document.createTextNode(options.stylesheet));
|
375
|
+
}
|
376
|
+
}
|
377
|
+
|
378
|
+
|
379
|
+
|
380
|
+
var cssregex = new RegExp(options.domain + "\/(.*?)\"?\\)");
|
381
|
+
|
382
|
+
for (var l = bgnodes.length, i = 0; i < l; i++) {
|
383
|
+
var src = window.getComputedStyle(bgnodes[i], null)
|
384
|
+
.getPropertyValue("background-image");
|
385
|
+
var flags = src.match(cssregex);
|
386
|
+
if (flags) {
|
387
|
+
var holder = parse_flags(flags[1].split("/"), options);
|
388
|
+
if (holder) {
|
389
|
+
render("background", bgnodes[i], holder, src);
|
390
|
+
}
|
391
|
+
}
|
392
|
+
}
|
393
|
+
|
394
|
+
for (l = images.length, i = 0; i < l; i++) {
|
395
|
+
|
396
|
+
var attr_src = attr_data_src = src = null;
|
397
|
+
|
398
|
+
try{
|
399
|
+
attr_src = images[i].getAttribute("src");
|
400
|
+
attr_datasrc = images[i].getAttribute("data-src");
|
401
|
+
}catch(e){}
|
402
|
+
|
403
|
+
if (attr_datasrc == null && !! attr_src && attr_src.indexOf(options.domain) >= 0) {
|
404
|
+
src = attr_src;
|
405
|
+
} else if ( !! attr_datasrc && attr_datasrc.indexOf(options.domain) >= 0) {
|
406
|
+
src = attr_datasrc;
|
407
|
+
}
|
408
|
+
|
409
|
+
if (src) {
|
410
|
+
var holder = parse_flags(src.substr(src.lastIndexOf(options.domain) + options.domain.length + 1)
|
411
|
+
.split("/"), options);
|
412
|
+
if (holder) {
|
413
|
+
if (holder.fluid) {
|
414
|
+
fluid(images[i], holder, src);
|
415
|
+
} else {
|
416
|
+
render("image", images[i], holder, src);
|
417
|
+
}
|
418
|
+
}
|
419
|
+
}
|
420
|
+
}
|
421
|
+
return app;
|
422
|
+
};
|
423
|
+
|
424
|
+
contentLoaded(win, function () {
|
425
|
+
if (window.addEventListener) {
|
426
|
+
window.addEventListener("resize", fluid_update, false);
|
427
|
+
window.addEventListener("orientationchange", fluid_update, false);
|
428
|
+
} else {
|
429
|
+
window.attachEvent("onresize", fluid_update)
|
430
|
+
}
|
431
|
+
preempted || app.run();
|
432
|
+
});
|
433
|
+
|
434
|
+
if (typeof define === "function" && define.amd) {
|
435
|
+
define("Holder", [], function () {
|
436
|
+
return app;
|
437
|
+
});
|
438
|
+
}
|
439
|
+
|
440
|
+
})(Holder, window);
|
@@ -0,0 +1,496 @@
|
|
1
|
+
/**
|
2
|
+
* @preserve HTML5 Shiv v3.6.2pre | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
|
3
|
+
*/
|
4
|
+
;(function(window, document) {
|
5
|
+
/*jshint evil:true */
|
6
|
+
/** version */
|
7
|
+
var version = '3.6.2pre';
|
8
|
+
|
9
|
+
/** Preset options */
|
10
|
+
var options = window.html5 || {};
|
11
|
+
|
12
|
+
/** Used to skip problem elements */
|
13
|
+
var reSkip = /^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i;
|
14
|
+
|
15
|
+
/** Not all elements can be cloned in IE **/
|
16
|
+
var saveClones = /^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i;
|
17
|
+
|
18
|
+
/** Detect whether the browser supports default html5 styles */
|
19
|
+
var supportsHtml5Styles;
|
20
|
+
|
21
|
+
/** Name of the expando, to work with multiple documents or to re-shiv one document */
|
22
|
+
var expando = '_html5shiv';
|
23
|
+
|
24
|
+
/** The id for the the documents expando */
|
25
|
+
var expanID = 0;
|
26
|
+
|
27
|
+
/** Cached data for each document */
|
28
|
+
var expandoData = {};
|
29
|
+
|
30
|
+
/** Detect whether the browser supports unknown elements */
|
31
|
+
var supportsUnknownElements;
|
32
|
+
|
33
|
+
(function() {
|
34
|
+
try {
|
35
|
+
var a = document.createElement('a');
|
36
|
+
a.innerHTML = '<xyz></xyz>';
|
37
|
+
//if the hidden property is implemented we can assume, that the browser supports basic HTML5 Styles
|
38
|
+
supportsHtml5Styles = ('hidden' in a);
|
39
|
+
|
40
|
+
supportsUnknownElements = a.childNodes.length == 1 || (function() {
|
41
|
+
// assign a false positive if unable to shiv
|
42
|
+
(document.createElement)('a');
|
43
|
+
var frag = document.createDocumentFragment();
|
44
|
+
return (
|
45
|
+
typeof frag.cloneNode == 'undefined' ||
|
46
|
+
typeof frag.createDocumentFragment == 'undefined' ||
|
47
|
+
typeof frag.createElement == 'undefined'
|
48
|
+
);
|
49
|
+
}());
|
50
|
+
} catch(e) {
|
51
|
+
supportsHtml5Styles = true;
|
52
|
+
supportsUnknownElements = true;
|
53
|
+
}
|
54
|
+
|
55
|
+
}());
|
56
|
+
|
57
|
+
/*--------------------------------------------------------------------------*/
|
58
|
+
|
59
|
+
/**
|
60
|
+
* Creates a style sheet with the given CSS text and adds it to the document.
|
61
|
+
* @private
|
62
|
+
* @param {Document} ownerDocument The document.
|
63
|
+
* @param {String} cssText The CSS text.
|
64
|
+
* @returns {StyleSheet} The style element.
|
65
|
+
*/
|
66
|
+
function addStyleSheet(ownerDocument, cssText) {
|
67
|
+
var p = ownerDocument.createElement('p'),
|
68
|
+
parent = ownerDocument.getElementsByTagName('head')[0] || ownerDocument.documentElement;
|
69
|
+
|
70
|
+
p.innerHTML = 'x<style>' + cssText + '</style>';
|
71
|
+
return parent.insertBefore(p.lastChild, parent.firstChild);
|
72
|
+
}
|
73
|
+
|
74
|
+
/**
|
75
|
+
* Returns the value of `html5.elements` as an array.
|
76
|
+
* @private
|
77
|
+
* @returns {Array} An array of shived element node names.
|
78
|
+
*/
|
79
|
+
function getElements() {
|
80
|
+
var elements = html5.elements;
|
81
|
+
return typeof elements == 'string' ? elements.split(' ') : elements;
|
82
|
+
}
|
83
|
+
|
84
|
+
/**
|
85
|
+
* Returns the data associated to the given document
|
86
|
+
* @private
|
87
|
+
* @param {Document} ownerDocument The document.
|
88
|
+
* @returns {Object} An object of data.
|
89
|
+
*/
|
90
|
+
function getExpandoData(ownerDocument) {
|
91
|
+
var data = expandoData[ownerDocument[expando]];
|
92
|
+
if (!data) {
|
93
|
+
data = {};
|
94
|
+
expanID++;
|
95
|
+
ownerDocument[expando] = expanID;
|
96
|
+
expandoData[expanID] = data;
|
97
|
+
}
|
98
|
+
return data;
|
99
|
+
}
|
100
|
+
|
101
|
+
/**
|
102
|
+
* returns a shived element for the given nodeName and document
|
103
|
+
* @memberOf html5
|
104
|
+
* @param {String} nodeName name of the element
|
105
|
+
* @param {Document} ownerDocument The context document.
|
106
|
+
* @returns {Object} The shived element.
|
107
|
+
*/
|
108
|
+
function createElement(nodeName, ownerDocument, data){
|
109
|
+
if (!ownerDocument) {
|
110
|
+
ownerDocument = document;
|
111
|
+
}
|
112
|
+
if(supportsUnknownElements){
|
113
|
+
return ownerDocument.createElement(nodeName);
|
114
|
+
}
|
115
|
+
if (!data) {
|
116
|
+
data = getExpandoData(ownerDocument);
|
117
|
+
}
|
118
|
+
var node;
|
119
|
+
|
120
|
+
if (data.cache[nodeName]) {
|
121
|
+
node = data.cache[nodeName].cloneNode();
|
122
|
+
} else if (saveClones.test(nodeName)) {
|
123
|
+
node = (data.cache[nodeName] = data.createElem(nodeName)).cloneNode();
|
124
|
+
} else {
|
125
|
+
node = data.createElem(nodeName);
|
126
|
+
}
|
127
|
+
|
128
|
+
// Avoid adding some elements to fragments in IE < 9 because
|
129
|
+
// * Attributes like `name` or `type` cannot be set/changed once an element
|
130
|
+
// is inserted into a document/fragment
|
131
|
+
// * Link elements with `src` attributes that are inaccessible, as with
|
132
|
+
// a 403 response, will cause the tab/window to crash
|
133
|
+
// * Script elements appended to fragments will execute when their `src`
|
134
|
+
// or `text` property is set
|
135
|
+
return node.canHaveChildren && !reSkip.test(nodeName) ? data.frag.appendChild(node) : node;
|
136
|
+
}
|
137
|
+
|
138
|
+
/**
|
139
|
+
* returns a shived DocumentFragment for the given document
|
140
|
+
* @memberOf html5
|
141
|
+
* @param {Document} ownerDocument The context document.
|
142
|
+
* @returns {Object} The shived DocumentFragment.
|
143
|
+
*/
|
144
|
+
function createDocumentFragment(ownerDocument, data){
|
145
|
+
if (!ownerDocument) {
|
146
|
+
ownerDocument = document;
|
147
|
+
}
|
148
|
+
if(supportsUnknownElements){
|
149
|
+
return ownerDocument.createDocumentFragment();
|
150
|
+
}
|
151
|
+
data = data || getExpandoData(ownerDocument);
|
152
|
+
var clone = data.frag.cloneNode(),
|
153
|
+
i = 0,
|
154
|
+
elems = getElements(),
|
155
|
+
l = elems.length;
|
156
|
+
for(;i<l;i++){
|
157
|
+
clone.createElement(elems[i]);
|
158
|
+
}
|
159
|
+
return clone;
|
160
|
+
}
|
161
|
+
|
162
|
+
/**
|
163
|
+
* Shivs the `createElement` and `createDocumentFragment` methods of the document.
|
164
|
+
* @private
|
165
|
+
* @param {Document|DocumentFragment} ownerDocument The document.
|
166
|
+
* @param {Object} data of the document.
|
167
|
+
*/
|
168
|
+
function shivMethods(ownerDocument, data) {
|
169
|
+
if (!data.cache) {
|
170
|
+
data.cache = {};
|
171
|
+
data.createElem = ownerDocument.createElement;
|
172
|
+
data.createFrag = ownerDocument.createDocumentFragment;
|
173
|
+
data.frag = data.createFrag();
|
174
|
+
}
|
175
|
+
|
176
|
+
|
177
|
+
ownerDocument.createElement = function(nodeName) {
|
178
|
+
//abort shiv
|
179
|
+
if (!html5.shivMethods) {
|
180
|
+
return data.createElem(nodeName);
|
181
|
+
}
|
182
|
+
return createElement(nodeName, ownerDocument, data);
|
183
|
+
};
|
184
|
+
|
185
|
+
ownerDocument.createDocumentFragment = Function('h,f', 'return function(){' +
|
186
|
+
'var n=f.cloneNode(),c=n.createElement;' +
|
187
|
+
'h.shivMethods&&(' +
|
188
|
+
// unroll the `createElement` calls
|
189
|
+
getElements().join().replace(/\w+/g, function(nodeName) {
|
190
|
+
data.createElem(nodeName);
|
191
|
+
data.frag.createElement(nodeName);
|
192
|
+
return 'c("' + nodeName + '")';
|
193
|
+
}) +
|
194
|
+
');return n}'
|
195
|
+
)(html5, data.frag);
|
196
|
+
}
|
197
|
+
|
198
|
+
/*--------------------------------------------------------------------------*/
|
199
|
+
|
200
|
+
/**
|
201
|
+
* Shivs the given document.
|
202
|
+
* @memberOf html5
|
203
|
+
* @param {Document} ownerDocument The document to shiv.
|
204
|
+
* @returns {Document} The shived document.
|
205
|
+
*/
|
206
|
+
function shivDocument(ownerDocument) {
|
207
|
+
if (!ownerDocument) {
|
208
|
+
ownerDocument = document;
|
209
|
+
}
|
210
|
+
var data = getExpandoData(ownerDocument);
|
211
|
+
|
212
|
+
if (html5.shivCSS && !supportsHtml5Styles && !data.hasCSS) {
|
213
|
+
data.hasCSS = !!addStyleSheet(ownerDocument,
|
214
|
+
// corrects block display not defined in IE6/7/8/9
|
215
|
+
'article,aside,figcaption,figure,footer,header,hgroup,nav,section{display:block}' +
|
216
|
+
// adds styling not present in IE6/7/8/9
|
217
|
+
'mark{background:#FF0;color:#000}'
|
218
|
+
);
|
219
|
+
}
|
220
|
+
if (!supportsUnknownElements) {
|
221
|
+
shivMethods(ownerDocument, data);
|
222
|
+
}
|
223
|
+
return ownerDocument;
|
224
|
+
}
|
225
|
+
|
226
|
+
/*--------------------------------------------------------------------------*/
|
227
|
+
|
228
|
+
/**
|
229
|
+
* The `html5` object is exposed so that more elements can be shived and
|
230
|
+
* existing shiving can be detected on iframes.
|
231
|
+
* @type Object
|
232
|
+
* @example
|
233
|
+
*
|
234
|
+
* // options can be changed before the script is included
|
235
|
+
* html5 = { 'elements': 'mark section', 'shivCSS': false, 'shivMethods': false };
|
236
|
+
*/
|
237
|
+
var html5 = {
|
238
|
+
|
239
|
+
/**
|
240
|
+
* An array or space separated string of node names of the elements to shiv.
|
241
|
+
* @memberOf html5
|
242
|
+
* @type Array|String
|
243
|
+
*/
|
244
|
+
'elements': options.elements || 'abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video',
|
245
|
+
|
246
|
+
/**
|
247
|
+
* current version of html5shiv
|
248
|
+
*/
|
249
|
+
'version': version,
|
250
|
+
|
251
|
+
/**
|
252
|
+
* A flag to indicate that the HTML5 style sheet should be inserted.
|
253
|
+
* @memberOf html5
|
254
|
+
* @type Boolean
|
255
|
+
*/
|
256
|
+
'shivCSS': (options.shivCSS !== false),
|
257
|
+
|
258
|
+
/**
|
259
|
+
* Is equal to true if a browser supports creating unknown/HTML5 elements
|
260
|
+
* @memberOf html5
|
261
|
+
* @type boolean
|
262
|
+
*/
|
263
|
+
'supportsUnknownElements': supportsUnknownElements,
|
264
|
+
|
265
|
+
/**
|
266
|
+
* A flag to indicate that the document's `createElement` and `createDocumentFragment`
|
267
|
+
* methods should be overwritten.
|
268
|
+
* @memberOf html5
|
269
|
+
* @type Boolean
|
270
|
+
*/
|
271
|
+
'shivMethods': (options.shivMethods !== false),
|
272
|
+
|
273
|
+
/**
|
274
|
+
* A string to describe the type of `html5` object ("default" or "default print").
|
275
|
+
* @memberOf html5
|
276
|
+
* @type String
|
277
|
+
*/
|
278
|
+
'type': 'default',
|
279
|
+
|
280
|
+
// shivs the document according to the specified `html5` object options
|
281
|
+
'shivDocument': shivDocument,
|
282
|
+
|
283
|
+
//creates a shived element
|
284
|
+
createElement: createElement,
|
285
|
+
|
286
|
+
//creates a shived documentFragment
|
287
|
+
createDocumentFragment: createDocumentFragment
|
288
|
+
};
|
289
|
+
|
290
|
+
/*--------------------------------------------------------------------------*/
|
291
|
+
|
292
|
+
// expose html5
|
293
|
+
window.html5 = html5;
|
294
|
+
|
295
|
+
// shiv the document
|
296
|
+
shivDocument(document);
|
297
|
+
|
298
|
+
/*------------------------------- Print Shiv -------------------------------*/
|
299
|
+
|
300
|
+
/** Used to filter media types */
|
301
|
+
var reMedia = /^$|\b(?:all|print)\b/;
|
302
|
+
|
303
|
+
/** Used to namespace printable elements */
|
304
|
+
var shivNamespace = 'html5shiv';
|
305
|
+
|
306
|
+
/** Detect whether the browser supports shivable style sheets */
|
307
|
+
var supportsShivableSheets = !supportsUnknownElements && (function() {
|
308
|
+
// assign a false negative if unable to shiv
|
309
|
+
var docEl = document.documentElement;
|
310
|
+
return !(
|
311
|
+
typeof document.namespaces == 'undefined' ||
|
312
|
+
typeof document.parentWindow == 'undefined' ||
|
313
|
+
typeof docEl.applyElement == 'undefined' ||
|
314
|
+
typeof docEl.removeNode == 'undefined' ||
|
315
|
+
typeof window.attachEvent == 'undefined'
|
316
|
+
);
|
317
|
+
}());
|
318
|
+
|
319
|
+
/*--------------------------------------------------------------------------*/
|
320
|
+
|
321
|
+
/**
|
322
|
+
* Wraps all HTML5 elements in the given document with printable elements.
|
323
|
+
* (eg. the "header" element is wrapped with the "html5shiv:header" element)
|
324
|
+
* @private
|
325
|
+
* @param {Document} ownerDocument The document.
|
326
|
+
* @returns {Array} An array wrappers added.
|
327
|
+
*/
|
328
|
+
function addWrappers(ownerDocument) {
|
329
|
+
var node,
|
330
|
+
nodes = ownerDocument.getElementsByTagName('*'),
|
331
|
+
index = nodes.length,
|
332
|
+
reElements = RegExp('^(?:' + getElements().join('|') + ')$', 'i'),
|
333
|
+
result = [];
|
334
|
+
|
335
|
+
while (index--) {
|
336
|
+
node = nodes[index];
|
337
|
+
if (reElements.test(node.nodeName)) {
|
338
|
+
result.push(node.applyElement(createWrapper(node)));
|
339
|
+
}
|
340
|
+
}
|
341
|
+
return result;
|
342
|
+
}
|
343
|
+
|
344
|
+
/**
|
345
|
+
* Creates a printable wrapper for the given element.
|
346
|
+
* @private
|
347
|
+
* @param {Element} element The element.
|
348
|
+
* @returns {Element} The wrapper.
|
349
|
+
*/
|
350
|
+
function createWrapper(element) {
|
351
|
+
var node,
|
352
|
+
nodes = element.attributes,
|
353
|
+
index = nodes.length,
|
354
|
+
wrapper = element.ownerDocument.createElement(shivNamespace + ':' + element.nodeName);
|
355
|
+
|
356
|
+
// copy element attributes to the wrapper
|
357
|
+
while (index--) {
|
358
|
+
node = nodes[index];
|
359
|
+
node.specified && wrapper.setAttribute(node.nodeName, node.nodeValue);
|
360
|
+
}
|
361
|
+
// copy element styles to the wrapper
|
362
|
+
wrapper.style.cssText = element.style.cssText;
|
363
|
+
return wrapper;
|
364
|
+
}
|
365
|
+
|
366
|
+
/**
|
367
|
+
* Shivs the given CSS text.
|
368
|
+
* (eg. header{} becomes html5shiv\:header{})
|
369
|
+
* @private
|
370
|
+
* @param {String} cssText The CSS text to shiv.
|
371
|
+
* @returns {String} The shived CSS text.
|
372
|
+
*/
|
373
|
+
function shivCssText(cssText) {
|
374
|
+
var pair,
|
375
|
+
parts = cssText.split('{'),
|
376
|
+
index = parts.length,
|
377
|
+
reElements = RegExp('(^|[\\s,>+~])(' + getElements().join('|') + ')(?=[[\\s,>+~#.:]|$)', 'gi'),
|
378
|
+
replacement = '$1' + shivNamespace + '\\:$2';
|
379
|
+
|
380
|
+
while (index--) {
|
381
|
+
pair = parts[index] = parts[index].split('}');
|
382
|
+
pair[pair.length - 1] = pair[pair.length - 1].replace(reElements, replacement);
|
383
|
+
parts[index] = pair.join('}');
|
384
|
+
}
|
385
|
+
return parts.join('{');
|
386
|
+
}
|
387
|
+
|
388
|
+
/**
|
389
|
+
* Removes the given wrappers, leaving the original elements.
|
390
|
+
* @private
|
391
|
+
* @params {Array} wrappers An array of printable wrappers.
|
392
|
+
*/
|
393
|
+
function removeWrappers(wrappers) {
|
394
|
+
var index = wrappers.length;
|
395
|
+
while (index--) {
|
396
|
+
wrappers[index].removeNode();
|
397
|
+
}
|
398
|
+
}
|
399
|
+
|
400
|
+
/*--------------------------------------------------------------------------*/
|
401
|
+
|
402
|
+
/**
|
403
|
+
* Shivs the given document for print.
|
404
|
+
* @memberOf html5
|
405
|
+
* @param {Document} ownerDocument The document to shiv.
|
406
|
+
* @returns {Document} The shived document.
|
407
|
+
*/
|
408
|
+
function shivPrint(ownerDocument) {
|
409
|
+
var shivedSheet,
|
410
|
+
wrappers,
|
411
|
+
data = getExpandoData(ownerDocument),
|
412
|
+
namespaces = ownerDocument.namespaces,
|
413
|
+
ownerWindow = ownerDocument.parentWindow;
|
414
|
+
|
415
|
+
if (!supportsShivableSheets || ownerDocument.printShived) {
|
416
|
+
return ownerDocument;
|
417
|
+
}
|
418
|
+
if (typeof namespaces[shivNamespace] == 'undefined') {
|
419
|
+
namespaces.add(shivNamespace);
|
420
|
+
}
|
421
|
+
|
422
|
+
function removeSheet() {
|
423
|
+
clearTimeout(data._removeSheetTimer);
|
424
|
+
if (shivedSheet) {
|
425
|
+
shivedSheet.removeNode(true);
|
426
|
+
}
|
427
|
+
shivedSheet= null;
|
428
|
+
}
|
429
|
+
|
430
|
+
ownerWindow.attachEvent('onbeforeprint', function() {
|
431
|
+
|
432
|
+
removeSheet();
|
433
|
+
|
434
|
+
var imports,
|
435
|
+
length,
|
436
|
+
sheet,
|
437
|
+
collection = ownerDocument.styleSheets,
|
438
|
+
cssText = [],
|
439
|
+
index = collection.length,
|
440
|
+
sheets = Array(index);
|
441
|
+
|
442
|
+
// convert styleSheets collection to an array
|
443
|
+
while (index--) {
|
444
|
+
sheets[index] = collection[index];
|
445
|
+
}
|
446
|
+
// concat all style sheet CSS text
|
447
|
+
while ((sheet = sheets.pop())) {
|
448
|
+
// IE does not enforce a same origin policy for external style sheets...
|
449
|
+
// but has trouble with some dynamically created stylesheets
|
450
|
+
if (!sheet.disabled && reMedia.test(sheet.media)) {
|
451
|
+
|
452
|
+
try {
|
453
|
+
imports = sheet.imports;
|
454
|
+
length = imports.length;
|
455
|
+
} catch(er){
|
456
|
+
length = 0;
|
457
|
+
}
|
458
|
+
|
459
|
+
for (index = 0; index < length; index++) {
|
460
|
+
sheets.push(imports[index]);
|
461
|
+
}
|
462
|
+
|
463
|
+
try {
|
464
|
+
cssText.push(sheet.cssText);
|
465
|
+
} catch(er){}
|
466
|
+
}
|
467
|
+
}
|
468
|
+
|
469
|
+
// wrap all HTML5 elements with printable elements and add the shived style sheet
|
470
|
+
cssText = shivCssText(cssText.reverse().join(''));
|
471
|
+
wrappers = addWrappers(ownerDocument);
|
472
|
+
shivedSheet = addStyleSheet(ownerDocument, cssText);
|
473
|
+
|
474
|
+
});
|
475
|
+
|
476
|
+
ownerWindow.attachEvent('onafterprint', function() {
|
477
|
+
// remove wrappers, leaving the original elements, and remove the shived style sheet
|
478
|
+
removeWrappers(wrappers);
|
479
|
+
clearTimeout(data._removeSheetTimer);
|
480
|
+
data._removeSheetTimer = setTimeout(removeSheet, 500);
|
481
|
+
});
|
482
|
+
|
483
|
+
ownerDocument.printShived = true;
|
484
|
+
return ownerDocument;
|
485
|
+
}
|
486
|
+
|
487
|
+
/*--------------------------------------------------------------------------*/
|
488
|
+
|
489
|
+
// expose API
|
490
|
+
html5.type += ' print';
|
491
|
+
html5.shivPrint = shivPrint;
|
492
|
+
|
493
|
+
// shiv for print
|
494
|
+
shivPrint(document);
|
495
|
+
|
496
|
+
}(this, document));
|